Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/chilly-crews-mix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@cube-dev/ui-kit': patch
---

Improve TextInputMapper styles inside Form.'
16 changes: 15 additions & 1 deletion src/components/fields/TextInputMapper/TextInputMapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import { useEvent } from '../../../_internal/hooks';
import { FieldBaseProps } from '../../../shared';
import { mergeProps } from '../../../utils/react/index';
import { useFieldProps, useFormProps, wrapWithField } from '../../form';
import { CloseIcon, PlusIcon } from '../../../icons';
import { Button } from '../../actions';
Expand All @@ -34,6 +35,19 @@
valueProps?: Partial<CubeTextInputMapperInputProps>;
}

// Rewrites upper level field component styles
// @TODO: Remove this after the release of new Element API
const PROPS_GRID_HACK = {
styles: {
InputArea: {
gridColumn: {
'': 'auto',
'has-sider': 'auto',
},
},
},
};

// remove duplicates in mappings
function removeDuplicates(mappings: Mapping[]) {
const keys = new Set<string>();
Expand Down Expand Up @@ -139,7 +153,7 @@
ValueComponent = ValueComponent ?? TextInputMapperInput;

const onKeyChange = useEvent((id: number, value: string) => {
mappings.find((mapping) => {

Check warning on line 156 in src/components/fields/TextInputMapper/TextInputMapper.tsx

View workflow job for this annotation

GitHub Actions / Tests & lint

Array.prototype.find() expects a return value from arrow function
if (mapping.id === id) {
mapping.key = value;
}
Expand All @@ -149,7 +163,7 @@
});

const onValueChange = useEvent((id: number, value: string) => {
mappings.find((mapping) => {

Check warning on line 166 in src/components/fields/TextInputMapper/TextInputMapper.tsx

View workflow job for this annotation

GitHub Actions / Tests & lint

Array.prototype.find() expects a return value from arrow function
if (mapping.id === id) {
mapping.value = value;
}
Expand Down Expand Up @@ -254,7 +268,7 @@
<TextInput
qa="AddMapping"
width="auto"
{...rest}
{...mergeProps(rest, PROPS_GRID_HACK)}
id={undefined}
value={value}
labelPosition="top"
Expand Down
Loading