datajunction-ui 0.0.71 → 0.0.72

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "datajunction-ui",
3
- "version": "0.0.71",
3
+ "version": "0.0.72",
4
4
  "description": "DataJunction UI",
5
5
  "module": "src/index.tsx",
6
6
  "repository": {
@@ -39,10 +39,33 @@ export const FormikSelect = ({
39
39
  }
40
40
  };
41
41
 
42
+ // Convert Formik field value to React Select format
43
+ const getSelectValue = () => {
44
+ if (!field.value) {
45
+ return isMulti ? [] : null;
46
+ }
47
+
48
+ if (isMulti) {
49
+ // For multi-select, map array of values to option objects
50
+ return Array.isArray(field.value)
51
+ ? field.value.map(
52
+ val =>
53
+ selectOptions.find(opt => opt.value === val) || {
54
+ value: val,
55
+ label: val,
56
+ },
57
+ )
58
+ : [];
59
+ } else {
60
+ // For single-select, find the matching option
61
+ return selectOptions.find(opt => opt.value === field.value) || null;
62
+ }
63
+ };
64
+
42
65
  return (
43
66
  <Select
44
67
  className={className}
45
- defaultValue={defaultValue}
68
+ value={getSelectValue()}
46
69
  options={selectOptions}
47
70
  name={field.name}
48
71
  placeholder={placeholder}
@@ -14,7 +14,7 @@ describe('FormikSelect', () => {
14
14
 
15
15
  const singleSelect = () => {
16
16
  const utils = render(
17
- <Formik initialValues={{ selectedOption: '' }} onSubmit={jest.fn()}>
17
+ <Formik initialValues={{ namespace: '' }} onSubmit={jest.fn()}>
18
18
  <Form>
19
19
  <FormikSelect
20
20
  selectOptions={namespaces}
@@ -38,7 +38,7 @@ describe('FormikSelect', () => {
38
38
 
39
39
  const multiSelect = () => {
40
40
  const utils = render(
41
- <Formik initialValues={{ selectedOption: '' }} onSubmit={jest.fn()}>
41
+ <Formik initialValues={{ namespace: [] }} onSubmit={jest.fn()}>
42
42
  <Form>
43
43
  <FormikSelect
44
44
  selectOptions={namespaces}
@@ -61,15 +61,15 @@ describe('FormikSelect', () => {
61
61
  };
62
62
  };
63
63
 
64
- it('renders the single select component with provided options', () => {
64
+ it('renders the single select component with provided options', async () => {
65
65
  singleSelect();
66
- userEvent.click(screen.getByRole('combobox')); // to open the dropdown
66
+ await userEvent.click(screen.getByRole('combobox')); // to open the dropdown
67
67
  expect(screen.getByText('basic.one')).toBeInTheDocument();
68
68
  });
69
69
 
70
- it('renders the multi-select component with provided options', () => {
70
+ it('renders the multi-select component with provided options', async () => {
71
71
  multiSelect();
72
- userEvent.click(screen.getByRole('combobox')); // to open the dropdown
72
+ await userEvent.click(screen.getByRole('combobox')); // to open the dropdown
73
73
  expect(screen.getByText('basic.one')).toBeInTheDocument();
74
74
  });
75
75
  });
@@ -63,7 +63,7 @@ export default function EditColumnPopover({ column, node, options, onSubmit }) {
63
63
  initialValues={{
64
64
  column: column.name,
65
65
  node: node.name,
66
- attributes: [],
66
+ attributes: column.attributes.map(attr => attr.attribute_type.name),
67
67
  }}
68
68
  onSubmit={saveAttributes}
69
69
  >