@tsed/react-formio 3.0.0-alpha.10 → 3.0.0-alpha.12
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/dist/atoms/icon/Icon.js.map +1 -1
- package/dist/chunks/index.js +33 -30
- package/dist/chunks/index.js.map +1 -1
- package/dist/chunks/index.module.js +16 -16
- package/dist/chunks/index.module.js.map +1 -1
- package/dist/chunks/react-select-animated.esm.js +1204 -1101
- package/dist/chunks/react-select-animated.esm.js.map +1 -1
- package/dist/hooks/keyboard.constants.d.ts +38 -0
- package/dist/hooks/keyboard.constants.js +7 -0
- package/dist/hooks/keyboard.constants.js.map +1 -0
- package/dist/hooks/useKeyboardControls.d.ts +12 -0
- package/dist/hooks/useKeyboardControls.js +35 -0
- package/dist/hooks/useKeyboardControls.js.map +1 -0
- package/dist/hooks/useTooltip.js.map +1 -1
- package/dist/interfaces/Operation.d.ts +12 -2
- package/dist/molecules/alert/Alert.js.map +1 -1
- package/dist/molecules/button/Button.d.ts +18 -5
- package/dist/molecules/button/Button.js +22 -26
- package/dist/molecules/button/Button.js.map +1 -1
- package/dist/molecules/card/Card.js +7 -5
- package/dist/molecules/card/Card.js.map +1 -1
- package/dist/molecules/forms/form-control/FormControl.js.map +1 -1
- package/dist/molecules/forms/input-tags/InputTags.js +14 -14
- package/dist/molecules/forms/input-tags/InputTags.js.map +1 -1
- package/dist/molecules/forms/input-tags/components/ChoicesTags.js +26 -26
- package/dist/molecules/forms/input-tags/components/ChoicesTags.js.map +1 -1
- package/dist/molecules/forms/input-tags/components/ReactTags.js +289 -300
- package/dist/molecules/forms/input-tags/components/ReactTags.js.map +1 -1
- package/dist/molecules/forms/input-text/InputText.js +3 -3
- package/dist/molecules/forms/input-text/InputText.js.map +1 -1
- package/dist/molecules/forms/select/Select.js.map +1 -1
- package/dist/molecules/forms/select/components/ChoicesSelect.js +71 -73
- package/dist/molecules/forms/select/components/ChoicesSelect.js.map +1 -1
- package/dist/molecules/forms/select/components/HtmlSelect.js.map +1 -1
- package/dist/molecules/forms/select/components/ReactSelect.js +13 -14
- package/dist/molecules/forms/select/components/ReactSelect.js.map +1 -1
- package/dist/molecules/forms/select/components/choices.template.js +2340 -2257
- package/dist/molecules/forms/select/components/choices.template.js.map +1 -1
- package/dist/molecules/forms/select/hooks/useOptions.js.map +1 -1
- package/dist/molecules/loader/Loader.js.map +1 -1
- package/dist/molecules/modal/Modal.js +23 -24
- package/dist/molecules/modal/Modal.js.map +1 -1
- package/dist/molecules/pagination/Pagination.js +19 -19
- package/dist/molecules/pagination/Pagination.js.map +1 -1
- package/dist/molecules/pagination/PaginationButton.js.map +1 -1
- package/dist/molecules/pagination/utils/getPageNumbers.js.map +1 -1
- package/dist/molecules/table/Table.d.ts +11 -3
- package/dist/molecules/table/Table.js +31 -32
- package/dist/molecules/table/Table.js.map +1 -1
- package/dist/molecules/table/components/DefaultArrowSort.js.map +1 -1
- package/dist/molecules/table/components/DefaultCell.js.map +1 -1
- package/dist/molecules/table/components/DefaultCellFooter.js.map +1 -1
- package/dist/molecules/table/components/DefaultCellHeader.js.map +1 -1
- package/dist/molecules/table/components/DefaultCellOperations.d.ts +12 -4
- package/dist/molecules/table/components/DefaultCellOperations.js +13 -7
- package/dist/molecules/table/components/DefaultCellOperations.js.map +1 -1
- package/dist/molecules/table/components/DefaultFilter.js.map +1 -1
- package/dist/molecules/table/components/DefaultOperationButton.d.ts +12 -4
- package/dist/molecules/table/components/DefaultOperationButton.js +1 -1
- package/dist/molecules/table/components/DefaultOperationButton.js.map +1 -1
- package/dist/molecules/table/filters/RangeFilter.js +23 -24
- package/dist/molecules/table/filters/RangeFilter.js.map +1 -1
- package/dist/molecules/table/filters/SelectFilter.js +11 -13
- package/dist/molecules/table/filters/SelectFilter.js.map +1 -1
- package/dist/molecules/table/filters/TextFieldFilter.js.map +1 -1
- package/dist/molecules/table/hooks/useTable.d.ts +12 -4
- package/dist/molecules/table/hooks/useTable.js +7 -7
- package/dist/molecules/table/hooks/useTable.js.map +1 -1
- package/dist/molecules/table/hooks/useUniqValues.js.map +1 -1
- package/dist/molecules/table/utils/mapFormToColumns.js +20 -21
- package/dist/molecules/table/utils/mapFormToColumns.js.map +1 -1
- package/dist/molecules/tabs/Tab.d.ts +13 -0
- package/dist/molecules/tabs/Tab.js +66 -0
- package/dist/molecules/tabs/Tab.js.map +1 -0
- package/dist/molecules/tabs/TabList.d.ts +2 -0
- package/dist/molecules/tabs/TabList.js +23 -0
- package/dist/molecules/tabs/TabList.js.map +1 -0
- package/dist/molecules/tabs/TabPanel.d.ts +9 -0
- package/dist/molecules/tabs/TabPanel.js +27 -0
- package/dist/molecules/tabs/TabPanel.js.map +1 -0
- package/dist/molecules/tabs/Tabs.d.ts +4 -16
- package/dist/molecules/tabs/Tabs.js +7 -67
- package/dist/molecules/tabs/Tabs.js.map +1 -1
- package/dist/molecules/tabs/TabsBody.d.ts +1 -0
- package/dist/molecules/tabs/TabsBody.js +10 -0
- package/dist/molecules/tabs/TabsBody.js.map +1 -0
- package/dist/molecules/tabs/TabsLegacy.d.ts +17 -0
- package/dist/molecules/tabs/TabsLegacy.js +49 -0
- package/dist/molecules/tabs/TabsLegacy.js.map +1 -0
- package/dist/molecules/tabs/all.d.ts +5 -0
- package/dist/molecules/tabs/all.js +13 -0
- package/dist/molecules/tabs/all.js.map +1 -0
- package/dist/molecules/tabs/context/TabControl.d.ts +52 -0
- package/dist/molecules/tabs/context/TabControl.js +85 -0
- package/dist/molecules/tabs/context/TabControl.js.map +1 -0
- package/dist/molecules/tabs/hooks/tabControl.d.ts +44 -0
- package/dist/molecules/tabs/hooks/tabControl.js +34 -0
- package/dist/molecules/tabs/hooks/tabControl.js.map +1 -0
- package/dist/organisms/form/Form.js.map +1 -1
- package/dist/organisms/form/access/FormAccess.js +41 -41
- package/dist/organisms/form/access/FormAccess.js.map +1 -1
- package/dist/organisms/form/access/FormAccess.schema.js.map +1 -1
- package/dist/organisms/form/access/FormAccess.utils.js +2 -2
- package/dist/organisms/form/access/FormAccess.utils.js.map +1 -1
- package/dist/organisms/form/{action → actions}/FormAction.js +7 -8
- package/dist/organisms/form/actions/FormAction.js.map +1 -0
- package/dist/organisms/form/builder/FormBuilder.js.map +1 -1
- package/dist/organisms/form/builder/FormEdit.d.ts +3 -1
- package/dist/organisms/form/builder/FormEdit.js +38 -35
- package/dist/organisms/form/builder/FormEdit.js.map +1 -1
- package/dist/organisms/form/builder/FormEdit.reducer.js.map +1 -1
- package/dist/organisms/form/builder/FormEditCtas.js +34 -34
- package/dist/organisms/form/builder/FormEditCtas.js.map +1 -1
- package/dist/organisms/form/builder/FormParameters.js.map +1 -1
- package/dist/organisms/form/builder/useFormBuilder.js +41 -38
- package/dist/organisms/form/builder/useFormBuilder.js.map +1 -1
- package/dist/organisms/form/builder/useFormEdit.js +1 -1
- package/dist/organisms/form/builder/useFormEdit.js.map +1 -1
- package/dist/organisms/form/exports/FormExport.d.ts +5 -0
- package/dist/organisms/form/exports/FormExport.js +55 -0
- package/dist/organisms/form/exports/FormExport.js.map +1 -0
- package/dist/organisms/form/preview/FormPreview.d.ts +6 -0
- package/dist/organisms/form/preview/FormPreview.js +11 -0
- package/dist/organisms/form/preview/FormPreview.js.map +1 -0
- package/dist/organisms/form/settings/FormSettings.js +24 -24
- package/dist/organisms/form/settings/FormSettings.js.map +1 -1
- package/dist/organisms/form/settings/FormSettings.schema.js.map +1 -1
- package/dist/organisms/form/settings/FormSettings.utils.js.map +1 -1
- package/dist/organisms/form/useForm.js +664 -661
- package/dist/organisms/form/useForm.js.map +1 -1
- package/dist/organisms/modal/RemoveModal.js +16 -17
- package/dist/organisms/modal/RemoveModal.js.map +1 -1
- package/dist/organisms/table/actions/ActionsTable.js.map +1 -1
- package/dist/organisms/table/forms/FormsTable.js.map +1 -1
- package/dist/organisms/table/forms/components/FormsCell.js.map +1 -1
- package/dist/organisms/table/submissions/SubmissionsTable.d.ts +11 -3
- package/dist/organisms/table/submissions/SubmissionsTable.js +4 -1
- package/dist/organisms/table/submissions/SubmissionsTable.js.map +1 -1
- package/dist/organisms/views/FormViews.d.ts +24 -0
- package/dist/organisms/views/FormViews.js +96 -0
- package/dist/organisms/views/FormViews.js.map +1 -0
- package/dist/registries/components.js.map +1 -1
- package/dist/utils/getEventValue.js.map +1 -1
- package/dist/utils/iconClass.js.map +1 -1
- package/dist/utils/mapPagination.js.map +1 -1
- package/dist/utils/stopPropagationWrapper.js.map +1 -1
- package/package.json +7 -7
- package/src/atoms/icon/Icon.stories.tsx +1 -1
- package/src/hooks/keyboard.constants.ts +40 -0
- package/src/hooks/useKeyboardControls.spec.tsx +208 -0
- package/src/hooks/useKeyboardControls.ts +84 -0
- package/src/interfaces/Operation.ts +9 -3
- package/src/molecules/button/Button.stories.tsx +1 -1
- package/src/molecules/button/Button.tsx +43 -24
- package/src/molecules/card/Card.tsx +4 -0
- package/src/molecules/forms/form-control/FormControl.stories.tsx +1 -1
- package/src/molecules/forms/input-tags/InputTags.tsx +1 -1
- package/src/molecules/forms/input-tags/components/ChoicesTags.stories.tsx +1 -1
- package/src/molecules/forms/input-tags/components/ReactTags.stories.tsx +1 -1
- package/src/molecules/forms/input-text/InputText.stories.tsx +2 -2
- package/src/molecules/forms/select/components/ChoicesSelect.stories.tsx +2 -2
- package/src/molecules/forms/select/components/HtmlSelect.stories.tsx +2 -2
- package/src/molecules/forms/select/components/ReactSelect.stories.tsx +2 -2
- package/src/molecules/loader/Loader.stories.tsx +1 -1
- package/src/molecules/modal/Modal.stories.tsx +1 -1
- package/src/molecules/pagination/Pagination.stories.tsx +1 -8
- package/src/molecules/pagination/Pagination.tsx +0 -1
- package/src/molecules/table/Table.stories.tsx +36 -3
- package/src/molecules/table/Table.tsx +12 -6
- package/src/molecules/table/components/DefaultCellOperations.tsx +13 -7
- package/src/molecules/table/components/DefaultOperationButton.tsx +5 -4
- package/src/molecules/table/filters/SelectFilter.tsx +1 -1
- package/src/molecules/table/hooks/useTable.tsx +5 -5
- package/src/molecules/tabs/Tab.tsx +106 -0
- package/src/molecules/tabs/TabList.tsx +37 -0
- package/src/molecules/tabs/TabPanel.tsx +37 -0
- package/src/molecules/tabs/Tabs.spec.tsx +126 -73
- package/src/molecules/tabs/Tabs.stories.tsx +298 -65
- package/src/molecules/tabs/Tabs.tsx +10 -81
- package/src/molecules/tabs/TabsBody.tsx +11 -0
- package/src/molecules/tabs/TabsLegacy.stories.tsx +103 -0
- package/src/molecules/tabs/TabsLegacy.tsx +84 -0
- package/src/molecules/tabs/all.ts +5 -0
- package/src/molecules/tabs/context/TabControl.tsx +166 -0
- package/src/molecules/tabs/hooks/tabControl.spec.tsx +388 -0
- package/src/molecules/tabs/hooks/tabControl.ts +52 -0
- package/src/organisms/__fixtures__/form-firstname.fixture.json +1 -0
- package/src/organisms/__fixtures__/form.fixture.json +1 -0
- package/src/organisms/form/Form.stories.tsx +94 -118
- package/src/organisms/form/access/FormAccess.stories.tsx +2 -2
- package/src/organisms/form/actions/FormAction.stories.tsx +422 -0
- package/src/organisms/form/builder/FormBuilder.stories.tsx +4 -1
- package/src/organisms/form/builder/FormEdit.stories.tsx +1 -1
- package/src/organisms/form/builder/FormEdit.tsx +7 -1
- package/src/organisms/form/builder/useFormBuilder.ts +5 -1
- package/src/organisms/form/builder/useFormEdit.ts +1 -1
- package/src/organisms/form/exports/FormExport.stories.tsx +71 -0
- package/src/organisms/form/exports/FormExport.tsx +58 -0
- package/src/organisms/form/preview/FormPreview.stories.tsx +61 -0
- package/src/organisms/form/preview/FormPreview.tsx +21 -0
- package/src/organisms/modal/RemoveModal.stories.tsx +1 -1
- package/src/organisms/table/actions/ActionsTable.stories.tsx +38 -36
- package/src/organisms/table/submissions/SubmissionsTable.stories.tsx +103 -57
- package/src/organisms/table/submissions/SubmissionsTable.tsx +10 -4
- package/src/organisms/views/FormViews.stories.tsx +224 -0
- package/src/organisms/views/FormViews.tsx +146 -0
- package/vite.config.mts +2 -2
- package/dist/organisms/form/action/FormAction.js.map +0 -1
- package/src/organisms/form/action/FormAction.stories.tsx +0 -364
- package/tsconfig.app.json +0 -11
- package/tsconfig.json +0 -21
- package/tsconfig.node.json +0 -13
- package/tsconfig.spec.json +0 -14
- /package/dist/organisms/form/{action → actions}/FormAction.d.ts +0 -0
- /package/src/organisms/form/{action → actions}/FormAction.tsx +0 -0
|
@@ -3,7 +3,7 @@ import { useState as C, useEffect as I } from "react";
|
|
|
3
3
|
import { c as x } from "../../../chunks/index.module.js";
|
|
4
4
|
import { registerComponent as g, getComponent as v } from "../../../registries/components.js";
|
|
5
5
|
import { getEventValue as b } from "../../../utils/getEventValue.js";
|
|
6
|
-
import {
|
|
6
|
+
import { cleanFormControlProps as y, FormControl as N } from "../form-control/FormControl.js";
|
|
7
7
|
function V(o) {
|
|
8
8
|
const { name: e, id: n = e, value: t, onChange: r, required: a, type: u, placeholder: m, debounceDelay: c = 300, ...l } = o, [p, i] = C(t), f = x(r || (() => {
|
|
9
9
|
}), c);
|
|
@@ -12,7 +12,7 @@ function V(o) {
|
|
|
12
12
|
}, [t]), /* @__PURE__ */ s(
|
|
13
13
|
"input",
|
|
14
14
|
{
|
|
15
|
-
...
|
|
15
|
+
...y(l, ["className"]),
|
|
16
16
|
type: u || "text",
|
|
17
17
|
"data-testid": `input_${e || ""}`,
|
|
18
18
|
className: "form-control",
|
|
@@ -32,7 +32,7 @@ g("Input", V);
|
|
|
32
32
|
function q(o) {
|
|
33
33
|
const { name: e, id: n = e, label: t, required: r, size: a, before: u, after: m, description: c, className: l } = o, p = v("Input");
|
|
34
34
|
return /* @__PURE__ */ s(
|
|
35
|
-
|
|
35
|
+
N,
|
|
36
36
|
{
|
|
37
37
|
id: n,
|
|
38
38
|
name: e,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InputText.js","sources":["../../../../src/molecules/forms/input-text/InputText.tsx"],"sourcesContent":["import { ComponentType, useEffect, useState } from \"react\";\nimport { useDebouncedCallback } from \"use-debounce\";\n\nimport { getComponent, registerComponent } from \"../../../registries/components\";\nimport { getEventValue } from \"../../../utils/getEventValue\";\nimport { cleanFormControlProps, FormControl } from \"../form-control/FormControl\";\nimport { InputTextProps } from \"./InputText.interface\";\n\nfunction Input<Data = any>(props: InputTextProps<Data>) {\n const { name, id = name, value, onChange, required, type, placeholder, debounceDelay = 300, ...otherProps } = props;\n\n const [localValue, setValue] = useState(value);\n const change = useDebouncedCallback(onChange || (() => {}), debounceDelay);\n\n useEffect(() => {\n setValue(value);\n }, [value]);\n\n return (\n <input\n {...cleanFormControlProps(otherProps, [\"className\"])}\n type={type || \"text\"}\n data-testid={`input_${name || \"\"}`}\n className={\"form-control\"}\n id={id}\n name={name}\n required={required}\n value={(localValue || \"\") as any}\n placeholder={placeholder}\n onChange={(event) => {\n const value = getEventValue(event);\n setValue(value);\n\n return change && change(name, value);\n }}\n />\n );\n}\n\nregisterComponent(\"Input\", Input);\n\nexport function InputText<Data = any>(props: InputTextProps<Data>) {\n const { name, id = name, label, required, size, before, after, description, className } = props;\n const Input = getComponent<ComponentType<InputTextProps<Data>>>(\"Input\");\n\n return (\n <FormControl\n id={id}\n name={name}\n label={label}\n required={required}\n description={description}\n before={before}\n after={after}\n size={size}\n className={className}\n >\n <Input {...props} />\n </FormControl>\n );\n}\n\nregisterComponent(\"InputText\", InputText);\n"],"names":["Input","props","name","id","value","onChange","required","type","placeholder","debounceDelay","otherProps","localValue","setValue","useState","change","useDebouncedCallback","useEffect","jsx","cleanFormControlProps","event","getEventValue","registerComponent","InputText","label","size","before","after","description","className","getComponent","FormControl"],"mappings":";;;;;;AAQA,SAASA,EAAkBC,GAA6B;AACtD,QAAM,EAAE,MAAAC,GAAM,IAAAC,IAAKD,GAAM,OAAAE,GAAO,UAAAC,GAAU,UAAAC,GAAU,MAAAC,GAAM,aAAAC,GAAa,eAAAC,IAAgB,KAAK,GAAGC,
|
|
1
|
+
{"version":3,"file":"InputText.js","sources":["../../../../src/molecules/forms/input-text/InputText.tsx"],"sourcesContent":["import { ComponentType, useEffect, useState } from \"react\";\nimport { useDebouncedCallback } from \"use-debounce\";\n\nimport { getComponent, registerComponent } from \"../../../registries/components\";\nimport { getEventValue } from \"../../../utils/getEventValue\";\nimport { cleanFormControlProps, FormControl } from \"../form-control/FormControl\";\nimport { InputTextProps } from \"./InputText.interface\";\n\nfunction Input<Data = any>(props: InputTextProps<Data>) {\n const { name, id = name, value, onChange, required, type, placeholder, debounceDelay = 300, ...otherProps } = props;\n\n const [localValue, setValue] = useState(value);\n const change = useDebouncedCallback(onChange || (() => {}), debounceDelay);\n\n useEffect(() => {\n setValue(value);\n }, [value]);\n\n return (\n <input\n {...cleanFormControlProps(otherProps, [\"className\"])}\n type={type || \"text\"}\n data-testid={`input_${name || \"\"}`}\n className={\"form-control\"}\n id={id}\n name={name}\n required={required}\n value={(localValue || \"\") as any}\n placeholder={placeholder}\n onChange={(event) => {\n const value = getEventValue(event);\n setValue(value);\n\n return change && change(name, value);\n }}\n />\n );\n}\n\nregisterComponent(\"Input\", Input);\n\nexport function InputText<Data = any>(props: InputTextProps<Data>) {\n const { name, id = name, label, required, size, before, after, description, className } = props;\n const Input = getComponent<ComponentType<InputTextProps<Data>>>(\"Input\");\n\n return (\n <FormControl\n id={id}\n name={name}\n label={label}\n required={required}\n description={description}\n before={before}\n after={after}\n size={size}\n className={className}\n >\n <Input {...props} />\n </FormControl>\n );\n}\n\nregisterComponent(\"InputText\", InputText);\n"],"names":["Input","props","name","id","value","onChange","required","type","placeholder","debounceDelay","otherProps","localValue","setValue","useState","change","useDebouncedCallback","useEffect","jsx","cleanFormControlProps","event","getEventValue","registerComponent","InputText","label","size","before","after","description","className","getComponent","FormControl"],"mappings":";;;;;;AAQA,SAASA,EAAkBC,GAA6B;AACtD,QAAM,EAAE,MAAAC,GAAM,IAAAC,IAAKD,GAAM,OAAAE,GAAO,UAAAC,GAAU,UAAAC,GAAU,MAAAC,GAAM,aAAAC,GAAa,eAAAC,IAAgB,KAAK,GAAGC,MAAeT,GAExG,CAACU,GAAYC,CAAQ,IAAI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js","sources":["../../../../src/molecules/forms/select/Select.tsx"],"sourcesContent":["import type { ComponentType } from \"react\";\n\nimport { getComponent, registerComponent } from \"../../../registries/components\";\nimport type { FormControl as DefaultFormControl } from \"../form-control/FormControl\";\nimport { useOptions } from \"./hooks/useOptions\";\nimport { AllSelectProps } from \"./Select.interface\";\n\nlet uuid = 0;\n\nexport function Select<Data = string>(props: AllSelectProps<Data>) {\n const { className, name = \"\", id = `field-select-${++uuid}`, label, description = \"\" } = props;\n\n const options = useOptions<Data>({\n ...props,\n value: (Array.isArray(props.value) ? props.value : [props.value]) as any\n });\n\n const FormControl = getComponent<typeof DefaultFormControl>(\"FormControl\");\n const Component = getComponent<ComponentType<AllSelectProps<Data>>>([\"Select.\" + props.layout, \"Select.html5\"]);\n\n return (\n <FormControl {...(props as any)} id={id} description={description} shadow={false} className={className} label={label}>\n <Component {...props} options={options} name={name} id={id} />\n </FormControl>\n );\n}\n\nregisterComponent(\"Select\", Select);\n"],"names":["uuid","Select","props","className","name","id","label","description","options","useOptions","FormControl","getComponent","Component","registerComponent"],"mappings":";;;AAOA,IAAIA,IAAO;AAEJ,SAASC,EAAsBC,GAA6B;AACjE,QAAM,EAAE,WAAAC,GAAW,MAAAC,IAAO,IAAI,IAAAC,IAAK,gBAAgB,EAAEL,CAAI,IAAI,OAAAM,GAAO,aAAAC,IAAc,
|
|
1
|
+
{"version":3,"file":"Select.js","sources":["../../../../src/molecules/forms/select/Select.tsx"],"sourcesContent":["import type { ComponentType } from \"react\";\n\nimport { getComponent, registerComponent } from \"../../../registries/components\";\nimport type { FormControl as DefaultFormControl } from \"../form-control/FormControl\";\nimport { useOptions } from \"./hooks/useOptions\";\nimport { AllSelectProps } from \"./Select.interface\";\n\nlet uuid = 0;\n\nexport function Select<Data = string>(props: AllSelectProps<Data>) {\n const { className, name = \"\", id = `field-select-${++uuid}`, label, description = \"\" } = props;\n\n const options = useOptions<Data>({\n ...props,\n value: (Array.isArray(props.value) ? props.value : [props.value]) as any\n });\n\n const FormControl = getComponent<typeof DefaultFormControl>(\"FormControl\");\n const Component = getComponent<ComponentType<AllSelectProps<Data>>>([\"Select.\" + props.layout, \"Select.html5\"]);\n\n return (\n <FormControl {...(props as any)} id={id} description={description} shadow={false} className={className} label={label}>\n <Component {...props} options={options} name={name} id={id} />\n </FormControl>\n );\n}\n\nregisterComponent(\"Select\", Select);\n"],"names":["uuid","Select","props","className","name","id","label","description","options","useOptions","FormControl","getComponent","Component","registerComponent"],"mappings":";;;AAOA,IAAIA,IAAO;AAEJ,SAASC,EAAsBC,GAA6B;AACjE,QAAM,EAAE,WAAAC,GAAW,MAAAC,IAAO,IAAI,IAAAC,IAAK,gBAAgB,EAAEL,CAAI,IAAI,OAAAM,GAAO,aAAAC,IAAc,GAAA,IAAOL,GAEnFM,IAAUC,EAAiB;AAAA,IAC/B,GAAGP;AAAA,IACH,OAAQ,MAAM,QAAQA,EAAM,KAAK,IAAIA,EAAM,QAAQ,CAACA,EAAM,KAAK;AAAA,EAAA,CAChE,GAEKQ,IAAcC,EAAwC,aAAa,GACnEC,IAAYD,EAAkD,CAAC,YAAYT,EAAM,QAAQ,cAAc,CAAC;AAE9G,2BACGQ,GAAA,EAAa,GAAIR,GAAe,IAAAG,GAAQ,aAAAE,GAA0B,QAAQ,IAAO,WAAAJ,GAAsB,OAAAG,GACtG,4BAACM,GAAA,EAAW,GAAGV,GAAO,SAAAM,GAAkB,MAAAJ,GAAY,IAAAC,GAAQ,GAC9D;AAEJ;AAEAQ,EAAkB,UAAUZ,CAAM;"}
|
|
@@ -1,95 +1,93 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import { c as
|
|
4
|
-
import { useRef as
|
|
5
|
-
import { c as
|
|
6
|
-
import { registerComponent as
|
|
7
|
-
import { cleanFormControlProps as
|
|
8
|
-
import { callbackOnCreateTemplates as
|
|
9
|
-
function
|
|
1
|
+
import { jsx as T } from "react/jsx-runtime";
|
|
2
|
+
import w from "@formio/choices.js";
|
|
3
|
+
import { c as z } from "../../../../chunks/index.js";
|
|
4
|
+
import { useRef as E, useMemo as M, useEffect as b } from "react";
|
|
5
|
+
import { c as g } from "../../../../chunks/index.module.js";
|
|
6
|
+
import { registerComponent as j } from "../../../../registries/components.js";
|
|
7
|
+
import { cleanFormControlProps as k } from "../../form-control/FormControl.js";
|
|
8
|
+
import { callbackOnCreateTemplates as B } from "./choices.template.js";
|
|
9
|
+
function H({
|
|
10
10
|
name: r,
|
|
11
|
-
disabled:
|
|
12
|
-
multiple:
|
|
13
|
-
options:
|
|
14
|
-
placeholder:
|
|
15
|
-
searchEnabled:
|
|
16
|
-
customProperties:
|
|
17
|
-
size:
|
|
18
|
-
value:
|
|
19
|
-
required:
|
|
20
|
-
onChange:
|
|
11
|
+
disabled: i,
|
|
12
|
+
multiple: c,
|
|
13
|
+
options: f,
|
|
14
|
+
placeholder: l,
|
|
15
|
+
searchEnabled: d = !0,
|
|
16
|
+
customProperties: v = {},
|
|
17
|
+
size: I,
|
|
18
|
+
value: a,
|
|
19
|
+
required: h,
|
|
20
|
+
onChange: S
|
|
21
21
|
}) {
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
...
|
|
25
|
-
choices:
|
|
26
|
-
...
|
|
27
|
-
selected: s
|
|
22
|
+
const C = E(), t = E(), m = M(() => {
|
|
23
|
+
const o = (e) => [].concat(a).includes(e), n = f.map((e) => (e.options && (e = {
|
|
24
|
+
...e,
|
|
25
|
+
choices: e.options.map((s) => ({
|
|
26
|
+
...s,
|
|
27
|
+
selected: o(s.value)
|
|
28
28
|
}))
|
|
29
29
|
}), {
|
|
30
|
-
...
|
|
31
|
-
selected:
|
|
30
|
+
...e,
|
|
31
|
+
selected: o(e.value)
|
|
32
32
|
}));
|
|
33
|
-
return !
|
|
33
|
+
return !c && l ? [
|
|
34
34
|
{
|
|
35
|
-
disabled:
|
|
36
|
-
label:
|
|
35
|
+
disabled: h,
|
|
36
|
+
label: l,
|
|
37
37
|
value: ""
|
|
38
38
|
},
|
|
39
|
-
...
|
|
40
|
-
] :
|
|
41
|
-
}, [
|
|
42
|
-
|
|
39
|
+
...n
|
|
40
|
+
] : n;
|
|
41
|
+
}, [f, a, h, c, l]), u = g((o, n) => {
|
|
42
|
+
S?.(o, n);
|
|
43
43
|
}, 50);
|
|
44
|
-
return
|
|
45
|
-
|
|
46
|
-
}, [
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
placeholder: m,
|
|
44
|
+
return b(() => {
|
|
45
|
+
t.current && (c && t.current.clearStore(), t.current.setChoices(m, "value", "label", !0));
|
|
46
|
+
}, [m]), b(() => {
|
|
47
|
+
if (!t.current) {
|
|
48
|
+
const { allowHTML: e = !0, silent: s = !0, removeItemButton: p = !0, shouldSort: L = !1, itemSelectText: x = "" } = v;
|
|
49
|
+
t.current = new w(C.current, {
|
|
50
|
+
...v,
|
|
51
|
+
allowHTML: e,
|
|
52
|
+
silent: s,
|
|
53
|
+
searchEnabled: d,
|
|
54
|
+
removeItemButton: p,
|
|
55
|
+
choices: m,
|
|
56
|
+
placeholder: l,
|
|
58
57
|
placeholderValue: "",
|
|
59
|
-
itemSelectText:
|
|
60
|
-
shouldSort:
|
|
61
|
-
callbackOnCreateTemplates:
|
|
58
|
+
itemSelectText: x,
|
|
59
|
+
shouldSort: L,
|
|
60
|
+
callbackOnCreateTemplates: B
|
|
62
61
|
});
|
|
63
62
|
}
|
|
64
|
-
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
},
|
|
68
|
-
|
|
63
|
+
i ? t.current?.disable() : t.current?.enable();
|
|
64
|
+
const o = ({ detail: { value: e } }) => {
|
|
65
|
+
u(r, c ? [.../* @__PURE__ */ new Set([...new Set(a), e])] : e);
|
|
66
|
+
}, n = ({ detail: { value: e } }) => {
|
|
67
|
+
c ? u(
|
|
69
68
|
r,
|
|
70
|
-
|
|
71
|
-
) :
|
|
69
|
+
a.filter((s) => s !== e)
|
|
70
|
+
) : u(r, void 0);
|
|
72
71
|
};
|
|
73
|
-
return
|
|
74
|
-
|
|
75
|
-
(o = e.current) == null || o.passedElement.element.removeEventListener("addItem", s), (n = e.current) == null || n.passedElement.element.removeEventListener("removeItem", c);
|
|
72
|
+
return t.current?.passedElement.element.addEventListener("addItem", o), t.current?.passedElement.element.addEventListener("removeItem", n), () => {
|
|
73
|
+
t.current?.passedElement.element.removeEventListener("addItem", o), t.current?.passedElement.element.removeEventListener("removeItem", n);
|
|
76
74
|
};
|
|
77
|
-
}, [
|
|
78
|
-
ref:
|
|
79
|
-
choicesRef:
|
|
75
|
+
}, [i, S, m, l, d, I, a]), {
|
|
76
|
+
ref: C,
|
|
77
|
+
choicesRef: t
|
|
80
78
|
};
|
|
81
79
|
}
|
|
82
|
-
function
|
|
83
|
-
const { ref:
|
|
80
|
+
function N(r) {
|
|
81
|
+
const { ref: i } = H({
|
|
84
82
|
...r,
|
|
85
83
|
searchEnabled: !r.disableSearch
|
|
86
84
|
});
|
|
87
|
-
return /* @__PURE__ */
|
|
85
|
+
return /* @__PURE__ */ T(
|
|
88
86
|
"select",
|
|
89
87
|
{
|
|
90
|
-
ref:
|
|
88
|
+
ref: i,
|
|
91
89
|
"data-testid": `select_${r.name}`,
|
|
92
|
-
|
|
90
|
+
...k(r, [
|
|
93
91
|
"className",
|
|
94
92
|
"size",
|
|
95
93
|
"value",
|
|
@@ -103,13 +101,13 @@ function P(r) {
|
|
|
103
101
|
"itemSelectText",
|
|
104
102
|
"customProperties"
|
|
105
103
|
]),
|
|
106
|
-
className:
|
|
104
|
+
className: z("form-control", r.size && `form-control-${r.size}`)
|
|
107
105
|
}
|
|
108
106
|
);
|
|
109
107
|
}
|
|
110
|
-
|
|
108
|
+
j("Select.choicesjs", N);
|
|
111
109
|
export {
|
|
112
|
-
|
|
113
|
-
|
|
110
|
+
N as ChoiceSelect,
|
|
111
|
+
H as useChoices
|
|
114
112
|
};
|
|
115
113
|
//# sourceMappingURL=ChoicesSelect.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChoicesSelect.js","sources":["../../../../../src/molecules/forms/select/components/ChoicesSelect.tsx"],"sourcesContent":["import Choices from \"@formio/choices.js\";\nimport cx from \"classnames\";\nimport { useEffect, useMemo, useRef } from \"react\";\nimport { useDebouncedCallback } from \"use-debounce\";\n\nimport { registerComponent } from \"../../../../registries/components\";\nimport { cleanFormControlProps } from \"../../form-control/FormControl\";\nimport type { AllSelectProps } from \"../Select.interface\";\nimport { callbackOnCreateTemplates } from \"./choices.template\";\n\nexport function useChoices({\n name,\n disabled,\n multiple,\n options,\n placeholder,\n searchEnabled = true,\n customProperties = {},\n size,\n value,\n required,\n onChange\n}: AllSelectProps) {\n const ref = useRef<any>();\n const choicesRef = useRef<Choices>();\n\n const opts = useMemo(() => {\n const isSelected = (itemValue: any) => [].concat(value as any).includes(itemValue as never);\n\n const opts = options.map((item) => {\n if (item.options) {\n item = {\n ...item,\n choices: item.options.map((item: any) => ({\n ...item,\n selected: isSelected(item.value)\n }))\n };\n }\n\n return {\n ...item,\n selected: isSelected(item.value)\n };\n });\n\n if (!multiple && placeholder) {\n return [\n {\n disabled: required,\n label: placeholder,\n value: \"\"\n },\n ...opts\n ];\n }\n\n return opts;\n }, [options, value, required, multiple, placeholder]);\n\n const onChangeCallback = useDebouncedCallback((name: string | undefined, value: any) => {\n onChange?.(name, value);\n }, 50);\n\n useEffect(() => {\n if (choicesRef.current) {\n if (multiple) {\n choicesRef.current.clearStore();\n choicesRef.current.setChoices(opts, \"value\", \"label\", true);\n } else {\n choicesRef.current.setChoices(opts, \"value\", \"label\", true);\n }\n }\n }, [opts]);\n\n useEffect(() => {\n if (!choicesRef.current) {\n const { allowHTML = true, silent = true, removeItemButton = true, shouldSort = false, itemSelectText = \"\" } = customProperties;\n choicesRef.current = new Choices(ref.current, {\n ...customProperties,\n allowHTML,\n silent,\n searchEnabled,\n removeItemButton,\n choices: opts,\n placeholder: placeholder as string,\n placeholderValue: \"\" as string,\n itemSelectText,\n shouldSort,\n callbackOnCreateTemplates\n } as any);\n }\n\n if (disabled) {\n choicesRef.current?.disable();\n } else {\n choicesRef.current?.enable();\n }\n\n const addItem = ({ detail: { value: newValue } }: any) => {\n onChangeCallback(name, multiple ? [...new Set([...new Set(value as string[]), newValue])] : newValue);\n };\n\n const removeItem = ({ detail: { value: newValue } }: any) => {\n if (multiple) {\n onChangeCallback(\n name,\n (value as string[]).filter((v) => v !== newValue)\n );\n } else {\n onChangeCallback(name, undefined as any);\n }\n };\n\n choicesRef.current?.passedElement.element.addEventListener(\"addItem\", addItem);\n choicesRef.current?.passedElement.element.addEventListener(\"removeItem\", removeItem);\n\n return () => {\n choicesRef.current?.passedElement.element.removeEventListener(\"addItem\", addItem);\n choicesRef.current?.passedElement.element.removeEventListener(\"removeItem\", removeItem);\n };\n }, [disabled, onChange, opts, placeholder, searchEnabled, size, value]);\n\n return {\n ref,\n choicesRef\n };\n}\n\nexport function ChoiceSelect(props: AllSelectProps) {\n const { ref } = useChoices({\n ...props,\n searchEnabled: !props.disableSearch\n });\n\n return (\n <select\n ref={ref}\n data-testid={`select_${props.name}`}\n {...cleanFormControlProps(props as any, [\n \"className\",\n \"size\",\n \"value\",\n \"options\",\n \"placeholder\",\n \"onChange\",\n \"allowHTML\",\n \"silent\",\n \"removeItemButton\",\n \"shouldSort\",\n \"itemSelectText\",\n \"customProperties\"\n ])}\n className={cx(\"form-control\", props.size && `form-control-${props.size}`)}\n />\n );\n}\n\nregisterComponent(\"Select.choicesjs\", ChoiceSelect);\n"],"names":["useChoices","name","disabled","multiple","options","placeholder","searchEnabled","customProperties","size","value","required","onChange","ref","useRef","choicesRef","opts","useMemo","isSelected","itemValue","item","onChangeCallback","useDebouncedCallback","useEffect","allowHTML","silent","removeItemButton","shouldSort","itemSelectText","Choices","callbackOnCreateTemplates","
|
|
1
|
+
{"version":3,"file":"ChoicesSelect.js","sources":["../../../../../src/molecules/forms/select/components/ChoicesSelect.tsx"],"sourcesContent":["import Choices from \"@formio/choices.js\";\nimport cx from \"classnames\";\nimport { useEffect, useMemo, useRef } from \"react\";\nimport { useDebouncedCallback } from \"use-debounce\";\n\nimport { registerComponent } from \"../../../../registries/components\";\nimport { cleanFormControlProps } from \"../../form-control/FormControl\";\nimport type { AllSelectProps } from \"../Select.interface\";\nimport { callbackOnCreateTemplates } from \"./choices.template\";\n\nexport function useChoices({\n name,\n disabled,\n multiple,\n options,\n placeholder,\n searchEnabled = true,\n customProperties = {},\n size,\n value,\n required,\n onChange\n}: AllSelectProps) {\n const ref = useRef<any>();\n const choicesRef = useRef<Choices>();\n\n const opts = useMemo(() => {\n const isSelected = (itemValue: any) => [].concat(value as any).includes(itemValue as never);\n\n const opts = options.map((item) => {\n if (item.options) {\n item = {\n ...item,\n choices: item.options.map((item: any) => ({\n ...item,\n selected: isSelected(item.value)\n }))\n };\n }\n\n return {\n ...item,\n selected: isSelected(item.value)\n };\n });\n\n if (!multiple && placeholder) {\n return [\n {\n disabled: required,\n label: placeholder,\n value: \"\"\n },\n ...opts\n ];\n }\n\n return opts;\n }, [options, value, required, multiple, placeholder]);\n\n const onChangeCallback = useDebouncedCallback((name: string | undefined, value: any) => {\n onChange?.(name, value);\n }, 50);\n\n useEffect(() => {\n if (choicesRef.current) {\n if (multiple) {\n choicesRef.current.clearStore();\n choicesRef.current.setChoices(opts, \"value\", \"label\", true);\n } else {\n choicesRef.current.setChoices(opts, \"value\", \"label\", true);\n }\n }\n }, [opts]);\n\n useEffect(() => {\n if (!choicesRef.current) {\n const { allowHTML = true, silent = true, removeItemButton = true, shouldSort = false, itemSelectText = \"\" } = customProperties;\n choicesRef.current = new Choices(ref.current, {\n ...customProperties,\n allowHTML,\n silent,\n searchEnabled,\n removeItemButton,\n choices: opts,\n placeholder: placeholder as string,\n placeholderValue: \"\" as string,\n itemSelectText,\n shouldSort,\n callbackOnCreateTemplates\n } as any);\n }\n\n if (disabled) {\n choicesRef.current?.disable();\n } else {\n choicesRef.current?.enable();\n }\n\n const addItem = ({ detail: { value: newValue } }: any) => {\n onChangeCallback(name, multiple ? [...new Set([...new Set(value as string[]), newValue])] : newValue);\n };\n\n const removeItem = ({ detail: { value: newValue } }: any) => {\n if (multiple) {\n onChangeCallback(\n name,\n (value as string[]).filter((v) => v !== newValue)\n );\n } else {\n onChangeCallback(name, undefined as any);\n }\n };\n\n choicesRef.current?.passedElement.element.addEventListener(\"addItem\", addItem);\n choicesRef.current?.passedElement.element.addEventListener(\"removeItem\", removeItem);\n\n return () => {\n choicesRef.current?.passedElement.element.removeEventListener(\"addItem\", addItem);\n choicesRef.current?.passedElement.element.removeEventListener(\"removeItem\", removeItem);\n };\n }, [disabled, onChange, opts, placeholder, searchEnabled, size, value]);\n\n return {\n ref,\n choicesRef\n };\n}\n\nexport function ChoiceSelect(props: AllSelectProps) {\n const { ref } = useChoices({\n ...props,\n searchEnabled: !props.disableSearch\n });\n\n return (\n <select\n ref={ref}\n data-testid={`select_${props.name}`}\n {...cleanFormControlProps(props as any, [\n \"className\",\n \"size\",\n \"value\",\n \"options\",\n \"placeholder\",\n \"onChange\",\n \"allowHTML\",\n \"silent\",\n \"removeItemButton\",\n \"shouldSort\",\n \"itemSelectText\",\n \"customProperties\"\n ])}\n className={cx(\"form-control\", props.size && `form-control-${props.size}`)}\n />\n );\n}\n\nregisterComponent(\"Select.choicesjs\", ChoiceSelect);\n"],"names":["useChoices","name","disabled","multiple","options","placeholder","searchEnabled","customProperties","size","value","required","onChange","ref","useRef","choicesRef","opts","useMemo","isSelected","itemValue","item","onChangeCallback","useDebouncedCallback","useEffect","allowHTML","silent","removeItemButton","shouldSort","itemSelectText","Choices","callbackOnCreateTemplates","addItem","newValue","removeItem","v","ChoiceSelect","props","jsx","cleanFormControlProps","cx","registerComponent"],"mappings":";;;;;;;;AAUO,SAASA,EAAW;AAAA,EACzB,MAAAC;AAAA,EACA,UAAAC;AAAA,EACA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EJ;AAEO,SAASoB,EAAaC,GAAuB;AAClD,QAAM,EAAE,KAAAvB,EAAA,IAAQZ,EAAW;AAAA,IACzB,GAAGmC;AAAA,IACH,eAAe,CAACA,EAAM;AAAA,EAAA,CACvB;AAED,SACE,gBAAAC;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,KAAAxB;AAAA,MACA,eAAa,UAAUuB,EAAM,IAAI;AAAA,MAChC,GAAGE,EAAsBF,GAAc;AAAA,QACtC;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MAAA,CACD;AAAA,MACD,WAAWG,EAAG,gBAAgBH,EAAM,QAAQ,gBAAgBA,EAAM,IAAI,EAAE;AAAA,IAAA;AAAA,EAAA;AAG9E;AAEAI,EAAkB,oBAAoBL,CAAY;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HtmlSelect.js","sources":["../../../../../src/molecules/forms/select/components/HtmlSelect.tsx"],"sourcesContent":["import cx from \"classnames\";\n\nimport { registerComponent } from \"../../../../registries/components\";\nimport { getEventValue } from \"../../../../utils/getEventValue\";\nimport { cleanFormControlProps } from \"../../form-control/FormControl\";\nimport { AllSelectProps, SelectOptionBaseProps } from \"../Select.interface\";\n\nfunction Option({ value, label, ...props }: SelectOptionBaseProps) {\n return (\n <option {...props} value={value as any}>\n {label}\n </option>\n );\n}\n\nexport function HTMLSelect({ name, id = name, size, value, multiple, onChange, options, placeholder, ...props }: AllSelectProps) {\n const hasGroup = !!options[0].options;\n\n return (\n <select\n data-testid={`select_${name}`}\n {...cleanFormControlProps(props as any)}\n className={cx(\"form-control\", size && `form-control-${size}`)}\n name={name}\n id={id}\n multiple={multiple}\n value={value || (\"\" as any)}\n onChange={(event) => {\n onChange && onChange(name, getEventValue(event));\n }}\n >\n {placeholder && !multiple && (\n <option value='' disabled>\n {placeholder}\n </option>\n )}\n {hasGroup\n ? options.map(({ label, options }) => {\n return (\n <optgroup key={label} label={label}>\n {options.map((props: SelectOptionBaseProps) => {\n return <Option key={String(props.value)} {...props} />;\n })}\n </optgroup>\n );\n })\n : (options as SelectOptionBaseProps[]).map((props) => {\n return <Option key={String(props.value)} {...props} />;\n })}\n </select>\n );\n}\n\nregisterComponent(\"Select.html5\", HTMLSelect);\n"],"names":["Option","value","label","props","jsx","HTMLSelect","name","id","size","multiple","onChange","options","placeholder","hasGroup","jsxs","cleanFormControlProps","cx","event","getEventValue","registerComponent"],"mappings":";;;;;AAOA,SAASA,EAAO,EAAE,OAAAC,GAAO,OAAAC,GAAO,GAAGC,KAAgC;AACjE,
|
|
1
|
+
{"version":3,"file":"HtmlSelect.js","sources":["../../../../../src/molecules/forms/select/components/HtmlSelect.tsx"],"sourcesContent":["import cx from \"classnames\";\n\nimport { registerComponent } from \"../../../../registries/components\";\nimport { getEventValue } from \"../../../../utils/getEventValue\";\nimport { cleanFormControlProps } from \"../../form-control/FormControl\";\nimport { AllSelectProps, SelectOptionBaseProps } from \"../Select.interface\";\n\nfunction Option({ value, label, ...props }: SelectOptionBaseProps) {\n return (\n <option {...props} value={value as any}>\n {label}\n </option>\n );\n}\n\nexport function HTMLSelect({ name, id = name, size, value, multiple, onChange, options, placeholder, ...props }: AllSelectProps) {\n const hasGroup = !!options[0].options;\n\n return (\n <select\n data-testid={`select_${name}`}\n {...cleanFormControlProps(props as any)}\n className={cx(\"form-control\", size && `form-control-${size}`)}\n name={name}\n id={id}\n multiple={multiple}\n value={value || (\"\" as any)}\n onChange={(event) => {\n onChange && onChange(name, getEventValue(event));\n }}\n >\n {placeholder && !multiple && (\n <option value='' disabled>\n {placeholder}\n </option>\n )}\n {hasGroup\n ? options.map(({ label, options }) => {\n return (\n <optgroup key={label} label={label}>\n {options.map((props: SelectOptionBaseProps) => {\n return <Option key={String(props.value)} {...props} />;\n })}\n </optgroup>\n );\n })\n : (options as SelectOptionBaseProps[]).map((props) => {\n return <Option key={String(props.value)} {...props} />;\n })}\n </select>\n );\n}\n\nregisterComponent(\"Select.html5\", HTMLSelect);\n"],"names":["Option","value","label","props","jsx","HTMLSelect","name","id","size","multiple","onChange","options","placeholder","hasGroup","jsxs","cleanFormControlProps","cx","event","getEventValue","registerComponent"],"mappings":";;;;;AAOA,SAASA,EAAO,EAAE,OAAAC,GAAO,OAAAC,GAAO,GAAGC,KAAgC;AACjE,SACE,gBAAAC,EAAC,UAAA,EAAQ,GAAGD,GAAO,OAAAF,GAChB,UAAAC,GACH;AAEJ;AAEO,SAASG,EAAW,EAAE,MAAAC,GAAM,IAAAC,IAAKD,GAAM,MAAAE,GAAM,OAAAP,GAAO,UAAAQ,GAAU,UAAAC,GAAU,SAAAC,GAAS,aAAAC,GAAa,GAAGT,KAAyB;AAC/H,QAAMU,IAAW,CAAC,CAACF,EAAQ,CAAC,EAAE;AAE9B,SACE,gBAAAG;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,eAAa,UAAUR,CAAI;AAAA,MAC1B,GAAGS,EAAsBZ,CAAY;AAAA,MACtC,WAAWa,EAAG,gBAAgBR,KAAQ,gBAAgBA,CAAI,EAAE;AAAA,MAC5D,MAAAF;AAAA,MACA,IAAAC;AAAA,MACA,UAAAE;AAAA,MACA,OAAOR,KAAU;AAAA,MACjB,UAAU,CAACgB,MAAU;AACnB,QAAAP,KAAYA,EAASJ,GAAMY,EAAcD,CAAK,CAAC;AAAA,MACjD;AAAA,MAEC,UAAA;AAAA,QAAAL,KAAe,CAACH,KACf,gBAAAL,EAAC,UAAA,EAAO,OAAM,IAAG,UAAQ,IACtB,UAAAQ,EAAA,CACH;AAAA,QAEDC,IACGF,EAAQ,IAAI,CAAC,EAAE,OAAAT,GAAO,SAAAS,0BAEjB,YAAA,EAAqB,OAAAT,GACnB,UAAAS,EAAQ,IAAI,CAACR,wBACJH,GAAA,EAAkC,GAAGG,KAAzB,OAAOA,EAAM,KAAK,CAAc,CACrD,KAHYD,CAIf,CAEH,IACAS,EAAoC,IAAI,CAACR,wBAChCH,GAAA,EAAkC,GAAGG,KAAzB,OAAOA,EAAM,KAAK,CAAc,CACrD;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGX;AAEAgB,EAAkB,gBAAgBd,CAAU;"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as r } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
2
|
+
import u from "react-select";
|
|
3
3
|
import { i as s } from "../../../../chunks/react-select-animated.esm.js";
|
|
4
|
-
import { registerComponent as
|
|
5
|
-
const
|
|
6
|
-
function
|
|
4
|
+
import { registerComponent as m } from "../../../../registries/components.js";
|
|
5
|
+
const f = s();
|
|
6
|
+
function d(e, a) {
|
|
7
7
|
const t = [].concat(e);
|
|
8
8
|
return a.flatMap((n) => {
|
|
9
9
|
if (t.includes(n.value))
|
|
@@ -12,13 +12,13 @@ function v(e, a) {
|
|
|
12
12
|
return n.options.filter((l) => t.includes(l.value));
|
|
13
13
|
}).filter(Boolean);
|
|
14
14
|
}
|
|
15
|
-
function
|
|
15
|
+
function v(e, a) {
|
|
16
16
|
return a ? [].concat(e).filter(Boolean).map((t) => t.value) : e.value;
|
|
17
17
|
}
|
|
18
|
-
function
|
|
19
|
-
const { placeholder: a, options: t, multiple: n, searchEnabled: l = !0, customProperties: o = {} } = e, i =
|
|
18
|
+
function h(e) {
|
|
19
|
+
const { placeholder: a, options: t, multiple: n, searchEnabled: l = !0, customProperties: o = {} } = e, i = d(e.value, e.options);
|
|
20
20
|
return /* @__PURE__ */ r(
|
|
21
|
-
|
|
21
|
+
u,
|
|
22
22
|
{
|
|
23
23
|
...o,
|
|
24
24
|
id: e.id,
|
|
@@ -26,21 +26,20 @@ function b(e) {
|
|
|
26
26
|
className: "react-select-container",
|
|
27
27
|
classNamePrefix: "react-select",
|
|
28
28
|
name: e.name || "",
|
|
29
|
-
components:
|
|
29
|
+
components: f,
|
|
30
30
|
options: t,
|
|
31
31
|
isDisabled: e.disabled,
|
|
32
32
|
isSearchable: l,
|
|
33
33
|
isMulti: e.multiple,
|
|
34
34
|
value: n ? i : i[0],
|
|
35
|
-
onChange: (
|
|
36
|
-
|
|
37
|
-
(c = e.onChange) == null || c.call(e, e.name, h(u, e.multiple));
|
|
35
|
+
onChange: (c) => {
|
|
36
|
+
e.onChange?.(e.name, v(c, e.multiple));
|
|
38
37
|
}
|
|
39
38
|
}
|
|
40
39
|
);
|
|
41
40
|
}
|
|
42
|
-
|
|
41
|
+
m("Select.react", h);
|
|
43
42
|
export {
|
|
44
|
-
|
|
43
|
+
h as ReactSelect
|
|
45
44
|
};
|
|
46
45
|
//# sourceMappingURL=ReactSelect.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReactSelect.js","sources":["../../../../../src/molecules/forms/select/components/ReactSelect.tsx"],"sourcesContent":["import Select, { OptionsOrGroups } from \"react-select\";\nimport makeAnimated from \"react-select/animated\";\n\nimport { registerComponent } from \"../../../../registries/components\";\nimport { AllSelectProps } from \"../Select.interface\";\n\nconst animatedComponents = makeAnimated();\n\nfunction findValues(value: string | string[], options: AllSelectProps[\"options\"][0]) {\n const localValue: string[] = [].concat(value as never);\n\n return options\n .flatMap((item: any) => {\n if (localValue.includes(item.value)) {\n return item;\n }\n\n if (item.options) {\n return item.options.filter((option: any) => localValue.includes(option.value));\n }\n })\n .filter(Boolean);\n}\n\nfunction mapValues(value: { label: string; value: never[] } | null, multiple?: boolean) {\n return multiple\n ? []\n .concat(value as never)\n .filter(Boolean)\n .map((v: { value: unknown }) => v.value)\n : (value as any).value;\n}\n\nexport function ReactSelect(props: AllSelectProps) {\n const { placeholder, options, multiple, searchEnabled = true, customProperties = {} } = props;\n\n const values = findValues(props.value!, props.options);\n\n return (\n <Select<{ label: string; value: never | never[] }>\n {...customProperties}\n id={props.id}\n placeholder={placeholder}\n className='react-select-container'\n classNamePrefix='react-select'\n name={props.name || \"\"}\n components={animatedComponents}\n options={options as OptionsOrGroups<any, any>}\n isDisabled={props.disabled}\n isSearchable={searchEnabled}\n isMulti={props.multiple as false}\n value={multiple ? values : values[0]}\n onChange={(value) => {\n props.onChange?.(props.name, mapValues(value, props.multiple));\n }}\n />\n );\n}\n\nregisterComponent(\"Select.react\", ReactSelect);\n"],"names":["animatedComponents","makeAnimated","findValues","value","options","localValue","item","option","mapValues","multiple","v","ReactSelect","props","placeholder","searchEnabled","customProperties","values","jsx","Select","
|
|
1
|
+
{"version":3,"file":"ReactSelect.js","sources":["../../../../../src/molecules/forms/select/components/ReactSelect.tsx"],"sourcesContent":["import Select, { OptionsOrGroups } from \"react-select\";\nimport makeAnimated from \"react-select/animated\";\n\nimport { registerComponent } from \"../../../../registries/components\";\nimport { AllSelectProps } from \"../Select.interface\";\n\nconst animatedComponents = makeAnimated();\n\nfunction findValues(value: string | string[], options: AllSelectProps[\"options\"][0]) {\n const localValue: string[] = [].concat(value as never);\n\n return options\n .flatMap((item: any) => {\n if (localValue.includes(item.value)) {\n return item;\n }\n\n if (item.options) {\n return item.options.filter((option: any) => localValue.includes(option.value));\n }\n })\n .filter(Boolean);\n}\n\nfunction mapValues(value: { label: string; value: never[] } | null, multiple?: boolean) {\n return multiple\n ? []\n .concat(value as never)\n .filter(Boolean)\n .map((v: { value: unknown }) => v.value)\n : (value as any).value;\n}\n\nexport function ReactSelect(props: AllSelectProps) {\n const { placeholder, options, multiple, searchEnabled = true, customProperties = {} } = props;\n\n const values = findValues(props.value!, props.options);\n\n return (\n <Select<{ label: string; value: never | never[] }>\n {...customProperties}\n id={props.id}\n placeholder={placeholder}\n className='react-select-container'\n classNamePrefix='react-select'\n name={props.name || \"\"}\n components={animatedComponents}\n options={options as OptionsOrGroups<any, any>}\n isDisabled={props.disabled}\n isSearchable={searchEnabled}\n isMulti={props.multiple as false}\n value={multiple ? values : values[0]}\n onChange={(value) => {\n props.onChange?.(props.name, mapValues(value, props.multiple));\n }}\n />\n );\n}\n\nregisterComponent(\"Select.react\", ReactSelect);\n"],"names":["animatedComponents","makeAnimated","findValues","value","options","localValue","item","option","mapValues","multiple","v","ReactSelect","props","placeholder","searchEnabled","customProperties","values","jsx","Select","registerComponent"],"mappings":";;;;AAMA,MAAMA,IAAqBC,EAAA;AAE3B,SAASC,EAAWC,GAA0BC,GAAuC;AACnF,QAAMC,IAAuB,CAAA,EAAG,OAAOF,CAAc;AAErD,SAAOC,EACJ,QAAQ,CAACE,MAAc;AACtB,QAAID,EAAW,SAASC,EAAK,KAAK;AAChC,aAAOA;AAGT,QAAIA,EAAK;AACP,aAAOA,EAAK,QAAQ,OAAO,CAACC,MAAgBF,EAAW,SAASE,EAAO,KAAK,CAAC;AAAA,EAEjF,CAAC,EACA,OAAO,OAAO;AACnB;AAEA,SAASC,EAAUL,GAAiDM,GAAoB;AACtF,SAAOA,IACH,CAAA,EACG,OAAON,CAAc,EACrB,OAAO,OAAO,EACd,IAAI,CAACO,MAA0BA,EAAE,KAAK,IACxCP,EAAc;AACrB;AAEO,SAASQ,EAAYC,GAAuB;AACjD,QAAM,EAAE,aAAAC,GAAa,SAAAT,GAAS,UAAAK,GAAU,eAAAK,IAAgB,IAAM,kBAAAC,IAAmB,CAAA,EAAC,IAAMH,GAElFI,IAASd,EAAWU,EAAM,OAAQA,EAAM,OAAO;AAErD,SACE,gBAAAK;AAAA,IAACC;AAAA,IAAA;AAAA,MACE,GAAGH;AAAA,MACJ,IAAIH,EAAM;AAAA,MACV,aAAAC;AAAA,MACA,WAAU;AAAA,MACV,iBAAgB;AAAA,MAChB,MAAMD,EAAM,QAAQ;AAAA,MACpB,YAAYZ;AAAA,MACZ,SAAAI;AAAA,MACA,YAAYQ,EAAM;AAAA,MAClB,cAAcE;AAAA,MACd,SAASF,EAAM;AAAA,MACf,OAAOH,IAAWO,IAASA,EAAO,CAAC;AAAA,MACnC,UAAU,CAACb,MAAU;AACnB,QAAAS,EAAM,WAAWA,EAAM,MAAMJ,EAAUL,GAAOS,EAAM,QAAQ,CAAC;AAAA,MAC/D;AAAA,IAAA;AAAA,EAAA;AAGN;AAEAO,EAAkB,gBAAgBR,CAAW;"}
|