@tsed/react-formio 3.0.0-rc.22 → 3.0.0-rc.23
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/chunks/_baseClone.js +1 -0
- package/dist/chunks/choices.js +2984 -0
- package/dist/chunks/choices.js.map +1 -0
- package/dist/chunks/index2.js +21101 -18657
- package/dist/chunks/index2.js.map +1 -1
- package/dist/hooks/useI18n.d.ts +1 -1
- package/dist/molecules/forms/input-tags/components/ChoicesTags.d.ts +1 -1
- package/dist/molecules/forms/input-tags/components/ChoicesTags.js +1 -1
- package/dist/molecules/forms/input-tags/components/ChoicesTags.js.map +1 -1
- package/dist/molecules/forms/select/components/ChoicesSelect.d.ts +1 -1
- package/dist/molecules/forms/select/components/ChoicesSelect.js +7 -7
- package/dist/molecules/forms/select/components/ChoicesSelect.js.map +1 -1
- package/dist/molecules/table/hooks/useTable.d.ts +1 -1
- package/package.json +3 -3
- package/src/molecules/forms/input-tags/components/ChoicesTags.tsx +1 -1
- package/src/molecules/forms/select/components/ChoicesSelect.tsx +1 -1
package/dist/hooks/useI18n.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as h } from "react/jsx-runtime";
|
|
2
|
-
import g from "
|
|
2
|
+
import { C as g } from "../../../../chunks/choices.js";
|
|
3
3
|
import { useRef as i, useEffect as C } from "react";
|
|
4
4
|
import { c as a } from "../../../../chunks/index.module.js";
|
|
5
5
|
import { registerComponent as I } from "../../../../registries/components.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChoicesTags.js","sources":["../../../../../src/molecules/forms/input-tags/components/ChoicesTags.tsx"],"sourcesContent":["import Choices from \"
|
|
1
|
+
{"version":3,"file":"ChoicesTags.js","sources":["../../../../../src/molecules/forms/input-tags/components/ChoicesTags.tsx"],"sourcesContent":["import Choices from \"choices.js\";\nimport { useEffect, useRef } from \"react\";\nimport { useDebouncedCallback } from \"use-debounce\";\n\nimport { registerComponent } from \"../../../../registries/components\";\nimport { cleanFormControlProps } from \"../../form-control/FormControl\";\nimport type { InputTagsProps } from \"../InputTags.interface\";\n\nexport function useChoiceTags<Data = string>(props: InputTagsProps<Data>) {\n const { value, onChange, name = \"\", delimiter, customProperties, ...otherProps } = props;\n const ref = useRef<HTMLInputElement | null>(null);\n const instanceRef = useRef<Choices | null>(null);\n\n const onAdd = useDebouncedCallback((add: Data) => {\n const values = ((value || []) as Data[]).concat(add);\n\n onChange?.(name, [...values]);\n }, 100);\n\n const onDelete = useDebouncedCallback((remove: Data) => {\n const values = (value || []).filter((v) => v !== remove);\n\n onChange?.(name, [...values]);\n });\n\n useEffect(() => {\n if (ref.current) {\n const instance = new Choices(ref.current!, {\n duplicateItemsAllowed: false,\n ...customProperties,\n delimiter,\n editItems: true,\n removeItemButton: true\n });\n\n instance.setValue((value || []) as string[]);\n\n instanceRef.current = instance;\n\n instance.passedElement.element.addEventListener(\"addItem\", (event) => {\n onAdd((event.target as any).value as Data);\n });\n\n instance.passedElement.element.addEventListener(\"removeItem\", (event) => {\n onDelete((event.target as any).value as Data);\n });\n }\n\n return () => {\n if (instanceRef.current) {\n instanceRef.current.destroy();\n }\n };\n }, [delimiter]);\n\n return {\n otherProps: {\n ...otherProps,\n name\n },\n ref,\n instanceRef\n };\n}\n\nexport function ChoicesTags<Data = string>(props: InputTagsProps<Data>) {\n const { ref, otherProps } = useChoiceTags<Data>(props);\n\n return <input type='text' {...cleanFormControlProps(otherProps)} ref={ref} />;\n}\n\nregisterComponent(\"InputTags.choicesjs\", ChoicesTags);\n"],"names":["useChoiceTags","props","value","onChange","name","delimiter","customProperties","otherProps","ref","useRef","instanceRef","onAdd","useDebouncedCallback","add","values","onDelete","remove","useEffect","instance","Choices","event","ChoicesTags","jsx","cleanFormControlProps","registerComponent"],"mappings":";;;;;;AAQO,SAASA,EAA6BC,GAA6B;AACxE,QAAM,EAAE,OAAAC,GAAO,UAAAC,GAAU,MAAAC,IAAO,IAA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AAE,KAAAO,GAAK,YAAAD,MAAeP,EAAoBC,CAAK;AAErD,SAAO,gBAAAqB,EAAC,WAAM,MAAK,QAAQ,GAAGC,EAAsBhB,CAAU,GAAG,KAAAC,GAAU;AAC7E;AAEAgB,EAAkB,uBAAuBH,CAAW;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { default as Choices } from '
|
|
1
|
+
import { default as Choices } from 'choices.js';
|
|
2
2
|
import { AllSelectProps } from '../Select.interface';
|
|
3
3
|
export declare function useChoices({ name, disabled, multiple, options, placeholder, searchEnabled, customProperties, size, value, required, onChange }: AllSelectProps): {
|
|
4
4
|
ref: import('react').MutableRefObject<any>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as T } from "react/jsx-runtime";
|
|
2
|
-
import w from "
|
|
2
|
+
import { C as w } from "../../../../chunks/choices.js";
|
|
3
3
|
import { c as z } from "../../../../chunks/index.js";
|
|
4
4
|
import { useRef as E, useMemo as M, useEffect as b } from "react";
|
|
5
5
|
import { c as g } from "../../../../chunks/index.module.js";
|
|
@@ -17,9 +17,9 @@ function H({
|
|
|
17
17
|
size: I,
|
|
18
18
|
value: a,
|
|
19
19
|
required: h,
|
|
20
|
-
onChange:
|
|
20
|
+
onChange: C
|
|
21
21
|
}) {
|
|
22
|
-
const
|
|
22
|
+
const S = E(), t = E(), m = M(() => {
|
|
23
23
|
const o = (e) => [].concat(a).includes(e), n = f.map((e) => (e.options && (e = {
|
|
24
24
|
...e,
|
|
25
25
|
choices: e.options.map((s) => ({
|
|
@@ -39,14 +39,14 @@ function H({
|
|
|
39
39
|
...n
|
|
40
40
|
] : n;
|
|
41
41
|
}, [f, a, h, c, l]), u = g((o, n) => {
|
|
42
|
-
|
|
42
|
+
C?.(o, n);
|
|
43
43
|
}, 50);
|
|
44
44
|
return b(() => {
|
|
45
45
|
t.current && (c && t.current.clearStore(), t.current.setChoices(m, "value", "label", !0));
|
|
46
46
|
}, [m]), b(() => {
|
|
47
47
|
if (!t.current) {
|
|
48
48
|
const { allowHTML: e = !0, silent: s = !0, removeItemButton: p = !0, shouldSort: L = !1, itemSelectText: x = "" } = v;
|
|
49
|
-
t.current = new w(
|
|
49
|
+
t.current = new w(S.current, {
|
|
50
50
|
...v,
|
|
51
51
|
allowHTML: e,
|
|
52
52
|
silent: s,
|
|
@@ -72,8 +72,8 @@ function H({
|
|
|
72
72
|
return t.current?.passedElement.element.addEventListener("addItem", o), t.current?.passedElement.element.addEventListener("removeItem", n), () => {
|
|
73
73
|
t.current?.passedElement.element.removeEventListener("addItem", o), t.current?.passedElement.element.removeEventListener("removeItem", n);
|
|
74
74
|
};
|
|
75
|
-
}, [i,
|
|
76
|
-
ref:
|
|
75
|
+
}, [i, C, m, l, d, I, a]), {
|
|
76
|
+
ref: S,
|
|
77
77
|
choicesRef: t
|
|
78
78
|
};
|
|
79
79
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChoicesSelect.js","sources":["../../../../../src/molecules/forms/select/components/ChoicesSelect.tsx"],"sourcesContent":["import Choices from \"
|
|
1
|
+
{"version":3,"file":"ChoicesSelect.js","sources":["../../../../../src/molecules/forms/select/components/ChoicesSelect.tsx"],"sourcesContent":["import Choices from \"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 as any, \"value\", \"label\", true);\n } else {\n choicesRef.current.setChoices(opts as any, \"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,UAAAC;AAAA,EACA,SAAAC;AAAA,EACA,aAAAC;AAAA,EACA,eAAAC,IAAgB;AAAA,EAChB,kBAAAC,IAAmB,CAAA;AAAA,EACnB,MAAAC;AAAA,EACA,OAAAC;AAAA,EACA,UAAAC;AAAA,EACA,UAAAC;AACF,GAAmB;AACjB,QAAMC,IAAMC,EAAA,GACNC,IAAaD,EAAA,GAEbE,IAAOC,EAAQ,MAAM;AACzB,UAAMC,IAAa,CAACC,MAAmB,CAAA,EAAG,OAAOT,CAAY,EAAE,SAASS,CAAkB,GAEpFH,IAAOX,EAAQ,IAAI,CAACe,OACpBA,EAAK,YACPA,IAAO;AAAA,MACL,GAAGA;AAAA,MACH,SAASA,EAAK,QAAQ,IAAI,CAACA,OAAe;AAAA,QACxC,GAAGA;AAAAA,QACH,UAAUF,EAAWE,EAAK,KAAK;AAAA,MAAA,EA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I,EAAkB,oBAAoBL,CAAY;"}
|
|
@@ -11,6 +11,6 @@ export interface UseTableProps<Data extends object = JSONRecord> extends Omit<Ta
|
|
|
11
11
|
pageSizes?: number[];
|
|
12
12
|
}
|
|
13
13
|
export declare function useTable<Data extends object = JSONRecord>(props: UseTableProps<Data>): {
|
|
14
|
-
i18n: (key: string, defaultValue?: string) =>
|
|
14
|
+
i18n: (key: string, defaultValue?: string) => any;
|
|
15
15
|
tableInstance: import('@tanstack/table-core').Table<Data>;
|
|
16
16
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsed/react-formio",
|
|
3
|
-
"version": "3.0.0-rc.
|
|
3
|
+
"version": "3.0.0-rc.23",
|
|
4
4
|
"description": "Provide a react formio wrapper. Written in TypeScript.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@tanstack/react-table": ">=8.20.6",
|
|
47
|
-
"@tsed/tailwind-formio": "3.0.0-rc.
|
|
48
|
-
"@tsed/typescript": "3.0.0-rc.
|
|
47
|
+
"@tsed/tailwind-formio": "3.0.0-rc.23",
|
|
48
|
+
"@tsed/typescript": "3.0.0-rc.23",
|
|
49
49
|
"microbundle": "0.13.0",
|
|
50
50
|
"vite": "7.1.5",
|
|
51
51
|
"vitest": "3.2.4"
|