@mittwald/flow-react-components 0.2.0-alpha.552 → 0.2.0-alpha.553
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/CHANGELOG.md +4 -0
- package/dist/assets/doc-properties.json +16428 -11732
- package/dist/css/all.css +1 -1
- package/dist/js/_virtual/_.locale.json@bb0db7b5021f874310cbe5b6cc3d9cac.mjs +2 -2
- package/dist/js/components/src/components/Action/Action.mjs +1 -0
- package/dist/js/components/src/components/Action/Action.mjs.map +1 -1
- package/dist/js/components/src/components/Action/models/ActionState.mjs +1 -1
- package/dist/js/components/src/components/Action/models/ActionState.mjs.map +1 -1
- package/dist/js/components/src/components/Autocomplete/Autocomplete.mjs +1 -1
- package/dist/js/components/src/components/Autocomplete/Autocomplete.mjs.map +1 -1
- package/dist/js/components/src/components/Button/Button.mjs +1 -1
- package/dist/js/components/src/components/Button/Button.mjs.map +1 -1
- package/dist/js/components/src/components/Checkbox/Checkbox.mjs +18 -6
- package/dist/js/components/src/components/Checkbox/Checkbox.mjs.map +1 -1
- package/dist/js/components/src/components/CheckboxButton/CheckboxButton.mjs +15 -3
- package/dist/js/components/src/components/CheckboxButton/CheckboxButton.mjs.map +1 -1
- package/dist/js/components/src/components/ComboBox/ComboBox.mjs +25 -4
- package/dist/js/components/src/components/ComboBox/ComboBox.mjs.map +1 -1
- package/dist/js/components/src/components/FileField/FileField.mjs +7 -3
- package/dist/js/components/src/components/FileField/FileField.mjs.map +1 -1
- package/dist/js/components/src/components/Markdown/Markdown.mjs +2 -1
- package/dist/js/components/src/components/Markdown/Markdown.mjs.map +1 -1
- package/dist/js/components/src/components/MarkdownEditor/MarkdownEditor.mjs +107 -45
- package/dist/js/components/src/components/MarkdownEditor/MarkdownEditor.mjs.map +1 -1
- package/dist/js/components/src/components/MarkdownEditor/MarkdownEditor.module.scss.mjs +3 -3
- package/dist/js/components/src/components/MarkdownEditor/components/ToolbarButton.mjs +1 -0
- package/dist/js/components/src/components/MarkdownEditor/components/ToolbarButton.mjs.map +1 -1
- package/dist/js/components/src/components/MarkdownEditor/lib/{handleKeyDown.mjs → modifyValueByMarkdownSyntax.mjs} +20 -29
- package/dist/js/components/src/components/MarkdownEditor/lib/modifyValueByMarkdownSyntax.mjs.map +1 -0
- package/dist/js/components/src/components/MarkdownEditor/lib/{insertAtCursor.mjs → modifyValueByType.mjs} +17 -11
- package/dist/js/components/src/components/MarkdownEditor/lib/modifyValueByType.mjs.map +1 -0
- package/dist/js/components/src/components/NumberField/NumberField.mjs +11 -2
- package/dist/js/components/src/components/NumberField/NumberField.mjs.map +1 -1
- package/dist/js/components/src/components/Popover/Popover.mjs +9 -2
- package/dist/js/components/src/components/Popover/Popover.mjs.map +1 -1
- package/dist/js/components/src/components/SearchField/SearchField.mjs +1 -1
- package/dist/js/components/src/components/SearchField/SearchField.mjs.map +1 -1
- package/dist/js/components/src/components/Select/Select.mjs +9 -9
- package/dist/js/components/src/components/Select/Select.mjs.map +1 -1
- package/dist/js/components/src/components/TextArea/TextArea.mjs +10 -5
- package/dist/js/components/src/components/TextArea/TextArea.mjs.map +1 -1
- package/dist/js/components/src/components/TextField/TextField.mjs +9 -2
- package/dist/js/components/src/components/TextField/TextField.mjs.map +1 -1
- package/dist/js/components/src/components/propTypes/index.mjs +2 -0
- package/dist/js/components/src/components/propTypes/index.mjs.map +1 -1
- package/dist/js/components/src/integrations/react-hook-form/components/Field/Field.mjs +14 -0
- package/dist/js/components/src/integrations/react-hook-form/components/Field/Field.mjs.map +1 -1
- package/dist/js/components/src/integrations/react-hook-form/components/Form/Form.mjs +22 -11
- package/dist/js/components/src/integrations/react-hook-form/components/Form/Form.mjs.map +1 -1
- package/dist/js/components/src/integrations/react-hook-form/components/Form/lib/useRegisterActionStateContext.mjs +2 -1
- package/dist/js/components/src/integrations/react-hook-form/components/Form/lib/useRegisterActionStateContext.mjs.map +1 -1
- package/dist/js/components/src/integrations/react-hook-form/components/ResetButton/ResetButton.mjs +51 -0
- package/dist/js/components/src/integrations/react-hook-form/components/ResetButton/ResetButton.mjs.map +1 -0
- package/dist/js/components/src/integrations/react-hook-form/components/SubmitButton/SubmitButton.mjs +57 -0
- package/dist/js/components/src/integrations/react-hook-form/components/SubmitButton/SubmitButton.mjs.map +1 -0
- package/dist/js/components/src/integrations/react-hook-form/components/context/formContext.mjs.map +1 -1
- package/dist/js/components/src/lib/react/ReactAriaControlledValueFix.mjs +18 -10
- package/dist/js/components/src/lib/react/ReactAriaControlledValueFix.mjs.map +1 -1
- package/dist/js/react-hook-form.mjs +2 -0
- package/dist/js/react-hook-form.mjs.map +1 -1
- package/dist/types/components/Action/Action.d.ts.map +1 -1
- package/dist/types/components/Action/models/ActionState.d.ts +5 -0
- package/dist/types/components/Action/models/ActionState.d.ts.map +1 -1
- package/dist/types/components/Checkbox/Checkbox.d.ts +2 -1
- package/dist/types/components/Checkbox/Checkbox.d.ts.map +1 -1
- package/dist/types/components/CheckboxButton/CheckboxButton.d.ts +2 -0
- package/dist/types/components/CheckboxButton/CheckboxButton.d.ts.map +1 -1
- package/dist/types/components/ComboBox/ComboBox.d.ts +2 -1
- package/dist/types/components/ComboBox/ComboBox.d.ts.map +1 -1
- package/dist/types/components/FileField/FileField.d.ts +2 -1
- package/dist/types/components/FileField/FileField.d.ts.map +1 -1
- package/dist/types/components/List/typedList.d.ts +1 -1
- package/dist/types/components/Markdown/Markdown.d.ts +2 -1
- package/dist/types/components/Markdown/Markdown.d.ts.map +1 -1
- package/dist/types/components/MarkdownEditor/MarkdownEditor.d.ts +7 -3
- package/dist/types/components/MarkdownEditor/MarkdownEditor.d.ts.map +1 -1
- package/dist/types/components/MarkdownEditor/MarkdownEditor.test.d.ts +2 -0
- package/dist/types/components/MarkdownEditor/MarkdownEditor.test.d.ts.map +1 -0
- package/dist/types/components/MarkdownEditor/components/ToolbarButton.d.ts +1 -1
- package/dist/types/components/MarkdownEditor/components/ToolbarButton.d.ts.map +1 -1
- package/dist/types/components/MarkdownEditor/lib/modifyValueByMarkdownSyntax.d.ts +8 -0
- package/dist/types/components/MarkdownEditor/lib/modifyValueByMarkdownSyntax.d.ts.map +1 -0
- package/dist/types/components/MarkdownEditor/lib/modifyValueByMarkdownSyntax.test.d.ts +2 -0
- package/dist/types/components/MarkdownEditor/lib/modifyValueByMarkdownSyntax.test.d.ts.map +1 -0
- package/dist/types/components/MarkdownEditor/lib/modifyValueByType.d.ts +12 -0
- package/dist/types/components/MarkdownEditor/lib/modifyValueByType.d.ts.map +1 -0
- package/dist/types/components/MarkdownEditor/lib/modifyValueByType.test.d.ts +2 -0
- package/dist/types/components/MarkdownEditor/lib/modifyValueByType.test.d.ts.map +1 -0
- package/dist/types/components/NumberField/NumberField.d.ts +4 -3
- package/dist/types/components/NumberField/NumberField.d.ts.map +1 -1
- package/dist/types/components/Popover/Popover.d.ts.map +1 -1
- package/dist/types/components/Select/Select.d.ts.map +1 -1
- package/dist/types/components/TextArea/TextArea.d.ts +4 -7
- package/dist/types/components/TextArea/TextArea.d.ts.map +1 -1
- package/dist/types/components/TextField/TextField.d.ts.map +1 -1
- package/dist/types/components/propTypes/index.d.ts +4 -0
- package/dist/types/components/propTypes/index.d.ts.map +1 -1
- package/dist/types/integrations/react-hook-form/components/Field/Field.d.ts.map +1 -1
- package/dist/types/integrations/react-hook-form/components/Field/stories/Autocomplete.stories.d.ts.map +1 -1
- package/dist/types/integrations/react-hook-form/components/Field/stories/Checkbox.stories.d.ts.map +1 -1
- package/dist/types/integrations/react-hook-form/components/Field/stories/CheckboxButton.stories.d.ts.map +1 -1
- package/dist/types/integrations/react-hook-form/components/Field/stories/CheckboxGroup.stories.d.ts.map +1 -1
- package/dist/types/integrations/react-hook-form/components/Field/stories/ComboBox.stories.d.ts.map +1 -1
- package/dist/types/integrations/react-hook-form/components/Field/stories/DatePicker.stories.d.ts.map +1 -1
- package/dist/types/integrations/react-hook-form/components/Field/stories/DateRangePicker.stories.d.ts.map +1 -1
- package/dist/types/integrations/react-hook-form/components/Field/stories/FileField.stories.d.ts.map +1 -1
- package/dist/types/integrations/react-hook-form/components/Field/stories/MarkdownEditor.stories.d.ts.map +1 -1
- package/dist/types/integrations/react-hook-form/components/Field/stories/NumberField.stories.d.ts.map +1 -1
- package/dist/types/integrations/react-hook-form/components/Field/stories/PasswordCreationField.stories.d.ts.map +1 -1
- package/dist/types/integrations/react-hook-form/components/Field/stories/RadioGroup.stories.d.ts.map +1 -1
- package/dist/types/integrations/react-hook-form/components/Field/stories/SearchField.stories.d.ts.map +1 -1
- package/dist/types/integrations/react-hook-form/components/Field/stories/SegmentedControl.stories.d.ts.map +1 -1
- package/dist/types/integrations/react-hook-form/components/Field/stories/Select.stories.d.ts.map +1 -1
- package/dist/types/integrations/react-hook-form/components/Field/stories/Slider.stories.d.ts.map +1 -1
- package/dist/types/integrations/react-hook-form/components/Field/stories/Switch.stories.d.ts.map +1 -1
- package/dist/types/integrations/react-hook-form/components/Field/stories/TextArea.stories.d.ts.map +1 -1
- package/dist/types/integrations/react-hook-form/components/Field/stories/TextField.stories.d.ts.map +1 -1
- package/dist/types/integrations/react-hook-form/components/Field/stories/TimeField.stories.d.ts.map +1 -1
- package/dist/types/integrations/react-hook-form/components/Form/Form.d.ts +4 -3
- package/dist/types/integrations/react-hook-form/components/Form/Form.d.ts.map +1 -1
- package/dist/types/integrations/react-hook-form/components/Form/lib/useRegisterActionStateContext.d.ts +1 -0
- package/dist/types/integrations/react-hook-form/components/Form/lib/useRegisterActionStateContext.d.ts.map +1 -1
- package/dist/types/integrations/react-hook-form/components/ResetButton/ResetButton.d.ts +10 -0
- package/dist/types/integrations/react-hook-form/components/ResetButton/ResetButton.d.ts.map +1 -0
- package/dist/types/integrations/react-hook-form/components/ResetButton/ResetButton.test.d.ts +2 -0
- package/dist/types/integrations/react-hook-form/components/ResetButton/ResetButton.test.d.ts.map +1 -0
- package/dist/types/integrations/react-hook-form/components/ResetButton/index.d.ts +3 -0
- package/dist/types/integrations/react-hook-form/components/ResetButton/index.d.ts.map +1 -0
- package/dist/types/integrations/react-hook-form/components/SubmitButton/SubmitButton.d.ts +10 -0
- package/dist/types/integrations/react-hook-form/components/SubmitButton/SubmitButton.d.ts.map +1 -0
- package/dist/types/integrations/react-hook-form/components/SubmitButton/SubmitButton.test.d.ts +2 -0
- package/dist/types/integrations/react-hook-form/components/SubmitButton/SubmitButton.test.d.ts.map +1 -0
- package/dist/types/integrations/react-hook-form/components/SubmitButton/index.d.ts +3 -0
- package/dist/types/integrations/react-hook-form/components/SubmitButton/index.d.ts.map +1 -0
- package/dist/types/integrations/react-hook-form/components/context/formContext.d.ts +6 -2
- package/dist/types/integrations/react-hook-form/components/context/formContext.d.ts.map +1 -1
- package/dist/types/integrations/react-hook-form/index.d.ts +2 -0
- package/dist/types/integrations/react-hook-form/index.d.ts.map +1 -1
- package/dist/types/lib/dev/vitest.d.ts +3 -0
- package/dist/types/lib/dev/vitest.d.ts.map +1 -0
- package/dist/types/lib/propsContext/nestedPropsContext/lib.d.ts +2 -0
- package/dist/types/lib/propsContext/nestedPropsContext/lib.d.ts.map +1 -1
- package/dist/types/lib/react/ReactAriaControlledValueFix.d.ts.map +1 -1
- package/package.json +5 -4
- package/dist/js/components/src/components/MarkdownEditor/lib/handleKeyDown.mjs.map +0 -1
- package/dist/js/components/src/components/MarkdownEditor/lib/insertAtCursor.mjs.map +0 -1
- package/dist/types/components/MarkdownEditor/lib/handleKeyDown.d.ts +0 -3
- package/dist/types/components/MarkdownEditor/lib/handleKeyDown.d.ts.map +0 -1
- package/dist/types/components/MarkdownEditor/lib/handleKeyDown.test.d.ts +0 -2
- package/dist/types/components/MarkdownEditor/lib/handleKeyDown.test.d.ts.map +0 -1
- package/dist/types/components/MarkdownEditor/lib/insertAtCursor.d.ts +0 -4
- package/dist/types/components/MarkdownEditor/lib/insertAtCursor.d.ts.map +0 -1
- package/dist/types/components/MarkdownEditor/lib/insertAtCursor.test.d.ts +0 -2
- package/dist/types/components/MarkdownEditor/lib/insertAtCursor.test.d.ts.map +0 -1
- package/dist/types/lib/dev/vitestUserEvent.d.ts +0 -3
- package/dist/types/lib/dev/vitestUserEvent.d.ts.map +0 -1
|
@@ -25,10 +25,8 @@ const Select = flowComponent("Select", (props) => {
|
|
|
25
25
|
const {
|
|
26
26
|
children,
|
|
27
27
|
className,
|
|
28
|
-
onChange
|
|
29
|
-
|
|
30
|
-
onSelectionChange = () => {
|
|
31
|
-
},
|
|
28
|
+
onChange,
|
|
29
|
+
onSelectionChange,
|
|
32
30
|
controller: controllerFromProps,
|
|
33
31
|
ref,
|
|
34
32
|
isReadOnly,
|
|
@@ -51,10 +49,6 @@ const Select = flowComponent("Select", (props) => {
|
|
|
51
49
|
},
|
|
52
50
|
...fieldPropsContext
|
|
53
51
|
};
|
|
54
|
-
const handleOnSelectionChange = (id) => {
|
|
55
|
-
onChange(id);
|
|
56
|
-
onSelectionChange(id);
|
|
57
|
-
};
|
|
58
52
|
const controllerFromContext = useOverlayController("Select", {
|
|
59
53
|
reuseControllerFromContext: true
|
|
60
54
|
});
|
|
@@ -62,6 +56,7 @@ const Select = flowComponent("Select", (props) => {
|
|
|
62
56
|
const localButtonRef = useRef(null);
|
|
63
57
|
useMakeFocusable(localSelectRef, () => {
|
|
64
58
|
localButtonRef.current?.focus();
|
|
59
|
+
controller.setOpen(true);
|
|
65
60
|
});
|
|
66
61
|
const controller = controllerFromProps ?? controllerFromContext;
|
|
67
62
|
const isOpen = controller.useIsOpen();
|
|
@@ -72,7 +67,12 @@ const Select = flowComponent("Select", (props) => {
|
|
|
72
67
|
...fieldProps,
|
|
73
68
|
className: clsx(rootClassName, fieldProps.className),
|
|
74
69
|
ref: localSelectRef,
|
|
75
|
-
|
|
70
|
+
onChange: (value) => {
|
|
71
|
+
if (!isReadOnly) {
|
|
72
|
+
onChange?.(value);
|
|
73
|
+
onSelectionChange?.(value);
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
76
|
onOpenChange: (isOpen2) => !isReadOnly && controller.setOpen(isOpen2),
|
|
77
77
|
isOpen,
|
|
78
78
|
"data-readonly": isReadOnly,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Select.mjs","sources":["../../../../../../src/components/Select/Select.tsx"],"sourcesContent":["import { type PropsWithChildren, useRef } from \"react\";\nimport type { Key } from \"react-aria-components\";\nimport * as Aria from \"react-aria-components\";\nimport type { PropsContext } from \"@/lib/propsContext\";\nimport { PropsContextProvider } from \"@/lib/propsContext\";\nimport formFieldStyles from \"@/components/FormField/FormField.module.scss\";\nimport styles from \"./Select.module.scss\";\nimport clsx from \"clsx\";\nimport { IconChevronDown } from \"@/components/Icon/components/icons\";\nimport type { FlowComponentProps } from \"@/lib/componentFactory/flowComponent\";\nimport { flowComponent } from \"@/lib/componentFactory/flowComponent\";\nimport { Options } from \"@/components/Options\";\nimport { TunnelExit, TunnelProvider } from \"@mittwald/react-tunnel\";\nimport type { PropsWithClassName } from \"@/lib/types/props\";\nimport { type OverlayController, useOverlayController } from \"@/lib/controller\";\nimport { useObjectRef } from \"@react-aria/utils\";\nimport { useMakeFocusable } from \"@/lib/hooks/dom/useMakeFocusable\";\nimport { useFieldComponent } from \"@/lib/hooks/useFieldComponent\";\n\nexport interface SelectProps\n extends PropsWithChildren<Omit<Aria.SelectProps, \"children\" | \"className\">>,\n FlowComponentProps,\n PropsWithClassName {\n /** Handler that is called when the selected value changes. */\n onChange?: (value: Key | null) => void;\n /** An overlay controller to control the select option popover state. */\n controller?: OverlayController;\n /** Whether the component is read only. */\n isReadOnly?: boolean;\n}\n\n/** @flr-generate all */\nexport const Select = flowComponent(\"Select\", (props) => {\n const {\n children,\n className,\n onChange
|
|
1
|
+
{"version":3,"file":"Select.mjs","sources":["../../../../../../src/components/Select/Select.tsx"],"sourcesContent":["import { type PropsWithChildren, useRef } from \"react\";\nimport type { Key } from \"react-aria-components\";\nimport * as Aria from \"react-aria-components\";\nimport type { PropsContext } from \"@/lib/propsContext\";\nimport { PropsContextProvider } from \"@/lib/propsContext\";\nimport formFieldStyles from \"@/components/FormField/FormField.module.scss\";\nimport styles from \"./Select.module.scss\";\nimport clsx from \"clsx\";\nimport { IconChevronDown } from \"@/components/Icon/components/icons\";\nimport type { FlowComponentProps } from \"@/lib/componentFactory/flowComponent\";\nimport { flowComponent } from \"@/lib/componentFactory/flowComponent\";\nimport { Options } from \"@/components/Options\";\nimport { TunnelExit, TunnelProvider } from \"@mittwald/react-tunnel\";\nimport type { PropsWithClassName } from \"@/lib/types/props\";\nimport { type OverlayController, useOverlayController } from \"@/lib/controller\";\nimport { useObjectRef } from \"@react-aria/utils\";\nimport { useMakeFocusable } from \"@/lib/hooks/dom/useMakeFocusable\";\nimport { useFieldComponent } from \"@/lib/hooks/useFieldComponent\";\n\nexport interface SelectProps\n extends PropsWithChildren<Omit<Aria.SelectProps, \"children\" | \"className\">>,\n FlowComponentProps,\n PropsWithClassName {\n /** Handler that is called when the selected value changes. */\n onChange?: (value: Key | null) => void;\n /** An overlay controller to control the select option popover state. */\n controller?: OverlayController;\n /** Whether the component is read only. */\n isReadOnly?: boolean;\n}\n\n/** @flr-generate all */\nexport const Select = flowComponent(\"Select\", (props) => {\n const {\n children,\n className,\n onChange,\n onSelectionChange,\n controller: controllerFromProps,\n ref,\n isReadOnly,\n ...rest\n } = props;\n\n const {\n FieldErrorView,\n fieldPropsContext,\n fieldProps,\n FieldErrorCaptureContext,\n } = useFieldComponent(props);\n\n const rootClassName = clsx(\n styles.select,\n formFieldStyles.formField,\n className,\n );\n\n const propsContext: PropsContext = {\n Option: {\n tunnelId: \"options\",\n },\n ...fieldPropsContext,\n };\n\n const controllerFromContext = useOverlayController(\"Select\", {\n reuseControllerFromContext: true,\n });\n\n const localSelectRef = useObjectRef(ref);\n const localButtonRef = useRef<HTMLButtonElement>(null);\n\n useMakeFocusable(localSelectRef, () => {\n localButtonRef.current?.focus();\n controller.setOpen(true);\n });\n\n const controller = controllerFromProps ?? controllerFromContext;\n const isOpen = controller.useIsOpen();\n\n return (\n <Aria.Select\n {...rest}\n {...fieldProps}\n className={clsx(rootClassName, fieldProps.className)}\n ref={localSelectRef}\n onChange={(value) => {\n if (!isReadOnly) {\n onChange?.(value);\n onSelectionChange?.(value);\n }\n }}\n onOpenChange={(isOpen) => !isReadOnly && controller.setOpen(isOpen)}\n isOpen={isOpen}\n data-readonly={isReadOnly}\n >\n <TunnelProvider>\n <FieldErrorCaptureContext>\n <PropsContextProvider props={propsContext}>\n <Aria.Button\n ref={localButtonRef}\n data-readonly={isReadOnly}\n className={styles.toggle}\n >\n <Aria.SelectValue />\n <IconChevronDown />\n </Aria.Button>\n {children}\n <Options controller={controller}>\n <TunnelExit id=\"options\" />\n </Options>\n </PropsContextProvider>\n </FieldErrorCaptureContext>\n <FieldErrorView />\n </TunnelProvider>\n </Aria.Select>\n );\n});\n\nexport default Select;\n"],"names":["isOpen"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAgCO,MAAM,MAAA,GAAS,aAAA,CAAc,QAAA,EAAU,CAAC,KAAA,KAAU;AACvD,EAAA,MAAM;AAAA,IACJ,QAAA;AAAA,IACA,SAAA;AAAA,IACA,QAAA;AAAA,IACA,iBAAA;AAAA,IACA,UAAA,EAAY,mBAAA;AAAA,IACZ,GAAA;AAAA,IACA,UAAA;AAAA,IACA,GAAG;AAAA,GACL,GAAI,KAAA;AAEJ,EAAA,MAAM;AAAA,IACJ,cAAA;AAAA,IACA,iBAAA;AAAA,IACA,UAAA;AAAA,IACA;AAAA,GACF,GAAI,kBAAkB,KAAK,CAAA;AAE3B,EAAA,MAAM,aAAA,GAAgB,IAAA;AAAA,IACpB,MAAA,CAAO,MAAA;AAAA,IACP,eAAA,CAAgB,SAAA;AAAA,IAChB;AAAA,GACF;AAEA,EAAA,MAAM,YAAA,GAA6B;AAAA,IACjC,MAAA,EAAQ;AAAA,MACN,QAAA,EAAU;AAAA,KACZ;AAAA,IACA,GAAG;AAAA,GACL;AAEA,EAAA,MAAM,qBAAA,GAAwB,qBAAqB,QAAA,EAAU;AAAA,IAC3D,0BAAA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A,cAElB,QAAA,EAAA;AAAA,gCAAA,GAAA,CAAC,IAAA,CAAK,aAAL,EAAiB,CAAA;AAAA,oCACjB,eAAA,EAAA,EAAgB;AAAA;AAAA;AAAA,WACnB;AAAA,UACC,QAAA;AAAA,8BACA,OAAA,EAAA,EAAQ,UAAA,EACP,8BAAC,UAAA,EAAA,EAAW,EAAA,EAAG,WAAU,CAAA,EAC3B;AAAA,SAAA,EACF,CAAA,EACF,CAAA;AAAA,4BACC,cAAA,EAAA,EAAe;AAAA,OAAA,EAClB;AAAA;AAAA,GACF;AAEJ,CAAC;;;;"}
|
|
@@ -20,16 +20,20 @@ const TextArea = flowComponent("TextArea", (props) => {
|
|
|
20
20
|
rows = 5,
|
|
21
21
|
autoResizeMaxRows = rows,
|
|
22
22
|
ref,
|
|
23
|
-
allowResize,
|
|
24
23
|
allowVerticalResize,
|
|
25
24
|
allowHorizontalResize,
|
|
26
25
|
...rest
|
|
27
26
|
} = props;
|
|
27
|
+
let { allowResize } = props;
|
|
28
|
+
if (allowVerticalResize) {
|
|
29
|
+
allowResize = "vertical";
|
|
30
|
+
} else if (allowHorizontalResize) {
|
|
31
|
+
allowResize = "horizontal";
|
|
32
|
+
}
|
|
28
33
|
const rootClassName = clsx(
|
|
29
34
|
styles.textArea,
|
|
30
|
-
allowResize && styles.resize,
|
|
31
|
-
|
|
32
|
-
allowHorizontalResize && styles.horizontalResize
|
|
35
|
+
typeof allowResize === "boolean" && allowResize ? styles.resize : null,
|
|
36
|
+
allowResize === "horizontal" ? styles.horizontalResize : allowResize === "vertical" ? styles.verticalResize : null
|
|
33
37
|
);
|
|
34
38
|
const localRef = useObjectRef(ref);
|
|
35
39
|
const getHeight = (rows2) => {
|
|
@@ -37,7 +41,7 @@ const TextArea = flowComponent("TextArea", (props) => {
|
|
|
37
41
|
};
|
|
38
42
|
const [resized, setResized] = useState(false);
|
|
39
43
|
const autoResizable = rows !== autoResizeMaxRows;
|
|
40
|
-
const verticallyResizable =
|
|
44
|
+
const verticallyResizable = allowResize && (!autoResizable || autoResizable && resized);
|
|
41
45
|
useEffect(() => {
|
|
42
46
|
const textarea = localRef.current;
|
|
43
47
|
if (!textarea) return;
|
|
@@ -82,6 +86,7 @@ const TextArea = flowComponent("TextArea", (props) => {
|
|
|
82
86
|
Aria.TextArea,
|
|
83
87
|
{
|
|
84
88
|
rows,
|
|
89
|
+
"aria-hidden": props["aria-hidden"],
|
|
85
90
|
placeholder,
|
|
86
91
|
className: rootClassName,
|
|
87
92
|
ref: localRef,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextArea.mjs","sources":["../../../../../../src/components/TextArea/TextArea.tsx"],"sourcesContent":["import * as Aria from \"react-aria-components\";\nimport type { TextFieldBaseProps } from \"@/components/TextFieldBase\";\nimport { TextFieldBase } from \"@/components/TextFieldBase\";\nimport styles from \"./TextArea.module.scss\";\nimport type { FlowComponentProps } from \"@/lib/componentFactory/flowComponent\";\nimport { flowComponent } from \"@/lib/componentFactory/flowComponent\";\nimport { useObjectRef } from \"@react-aria/utils\";\nimport { ReactAriaControlledValueFix } from \"@/lib/react/ReactAriaControlledValueFix\";\nimport { useFieldComponent } from \"@/lib/hooks/useFieldComponent\";\nimport { PropsContextProvider } from \"@/lib/propsContext\";\nimport clsx from \"clsx\";\nimport { useEffect, useState } from \"react\";\n\nexport interface TextAreaProps\n extends Omit<\n TextFieldBaseProps,\n \"FieldErrorView\" | \"FieldErrorCaptureContext\" | \"input\" | \"ref\"\n >,\n Pick<Aria.TextAreaProps, \"placeholder\" | \"rows\">,\n FlowComponentProps<HTMLTextAreaElement> {\n /**\n * Whether the text area should grow if its content gets longer than its\n * initial height.\n */\n autoResizeMaxRows?: number;\n /** Allows the user to manually resize the textArea horizontally. */\n
|
|
1
|
+
{"version":3,"file":"TextArea.mjs","sources":["../../../../../../src/components/TextArea/TextArea.tsx"],"sourcesContent":["import * as Aria from \"react-aria-components\";\nimport type { TextFieldBaseProps } from \"@/components/TextFieldBase\";\nimport { TextFieldBase } from \"@/components/TextFieldBase\";\nimport styles from \"./TextArea.module.scss\";\nimport type { FlowComponentProps } from \"@/lib/componentFactory/flowComponent\";\nimport { flowComponent } from \"@/lib/componentFactory/flowComponent\";\nimport { useObjectRef } from \"@react-aria/utils\";\nimport { ReactAriaControlledValueFix } from \"@/lib/react/ReactAriaControlledValueFix\";\nimport { useFieldComponent } from \"@/lib/hooks/useFieldComponent\";\nimport { PropsContextProvider } from \"@/lib/propsContext\";\nimport clsx from \"clsx\";\nimport { useEffect, useState } from \"react\";\n\nexport interface TextAreaProps\n extends Omit<\n TextFieldBaseProps,\n \"FieldErrorView\" | \"FieldErrorCaptureContext\" | \"input\" | \"ref\"\n >,\n Pick<Aria.TextAreaProps, \"placeholder\" | \"rows\" | \"aria-hidden\">,\n FlowComponentProps<HTMLTextAreaElement> {\n /**\n * Whether the text area should grow if its content gets longer than its\n * initial height.\n */\n autoResizeMaxRows?: number;\n /** Allows the user to manually resize the textArea horizontally. */\n allowResize?: boolean | \"horizontal\" | \"vertical\";\n\n /** @deprecated Use `allowResize` instead. */\n allowHorizontalResize?: boolean;\n /** @deprecated Use `allowResize` instead. */\n allowVerticalResize?: boolean;\n}\n\n/** @flr-generate all */\nexport const TextArea = flowComponent(\"TextArea\", (props) => {\n const {\n children,\n placeholder,\n rows = 5,\n autoResizeMaxRows = rows,\n ref,\n allowVerticalResize,\n allowHorizontalResize,\n ...rest\n } = props;\n\n let { allowResize } = props;\n if (allowVerticalResize) {\n allowResize = \"vertical\";\n } else if (allowHorizontalResize) {\n allowResize = \"horizontal\";\n }\n\n const rootClassName = clsx(\n styles.textArea,\n typeof allowResize === \"boolean\" && allowResize ? styles.resize : null,\n allowResize === \"horizontal\"\n ? styles.horizontalResize\n : allowResize === \"vertical\"\n ? styles.verticalResize\n : null,\n );\n\n const localRef = useObjectRef(ref);\n\n const getHeight = (rows: number) => {\n return `calc(var(--line-height--m) * ${rows} + (var(--form-control--padding-y) * 2))`;\n };\n\n const [resized, setResized] = useState(false);\n\n const autoResizable = rows !== autoResizeMaxRows;\n\n const verticallyResizable =\n allowResize && (!autoResizable || (autoResizable && resized));\n\n useEffect(() => {\n const textarea = localRef.current;\n if (!textarea) return;\n\n const startHeight = textarea.offsetHeight;\n let tracking = false;\n\n const handleMouseDown = () => {\n tracking = true;\n };\n\n const handleMouseMove = () => {\n if (!tracking || resized) return;\n\n const currentHeight = textarea.offsetHeight;\n\n if (currentHeight !== startHeight) {\n setResized(true);\n tracking = false;\n }\n };\n\n const handleMouseUp = () => {\n tracking = false;\n };\n\n window.addEventListener(\"mousedown\", handleMouseDown);\n window.addEventListener(\"mousemove\", handleMouseMove);\n window.addEventListener(\"mouseup\", handleMouseUp);\n\n return () => {\n window.removeEventListener(\"mousedown\", handleMouseDown);\n window.removeEventListener(\"mousemove\", handleMouseMove);\n window.removeEventListener(\"mouseup\", handleMouseUp);\n };\n }, [resized]);\n\n const updateHeight = () => {\n if (localRef.current && autoResizable && !verticallyResizable) {\n // https://stackoverflow.com/a/60795884\n localRef.current.style.height = \"0px\";\n const scrollHeight = localRef.current.scrollHeight;\n // + 2 to add border height\n localRef.current.style.height = scrollHeight + 2 + \"px\";\n }\n };\n\n const input = (\n <ReactAriaControlledValueFix\n inputContext={Aria.TextAreaContext}\n props={props}\n >\n <Aria.TextArea\n rows={rows}\n aria-hidden={props[\"aria-hidden\"]}\n placeholder={placeholder}\n className={rootClassName}\n ref={localRef}\n onChange={updateHeight}\n style={{\n minHeight: getHeight(rows),\n maxHeight: verticallyResizable\n ? undefined\n : getHeight(autoResizeMaxRows),\n }}\n />\n </ReactAriaControlledValueFix>\n );\n\n const {\n FieldErrorView,\n FieldErrorCaptureContext,\n fieldPropsContext,\n fieldProps,\n } = useFieldComponent(props);\n\n return (\n <TextFieldBase\n {...rest}\n {...fieldProps}\n className={clsx(rest.className, fieldProps.className)}\n FieldErrorView={FieldErrorView}\n FieldErrorCaptureContext={FieldErrorCaptureContext}\n input={input}\n >\n <PropsContextProvider props={f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CAAS,OAAA,CAAQ,KAAA,CAAM,MAAA,GAAS,YAAA,GAAe,CAAA,GAAI,IAAA;AAAA,IACrD;AAAA,EACF,CAAA;AAEA,EAAA,MAAM,KAAA,mBACJ,GAAA;AAAA,IAAC,2BAAA;AAAA,IAAA;AAAA,MACC,cAAc,IAAA,CAAK,eAAA;AAAA,MACnB,KAAA;AAAA,MAEA,QAAA,kBAAA,GAAA;AAAA,QAAC,IAAA,CAAK,QAAA;AAAA,QAAL;AAAA,UACC,IAAA;AAAA,UACA,aAAA,EAAa,MAAM,aAAa,CAAA;AAAA,UAChC,WAAA;AAAA,UACA,SAAA,EAAW,aAAA;AAAA,UACX,GAAA,EAAK,QAAA;AAAA,UACL,QAAA,EAAU,YAAA;AAAA,UACV,KAAA,EAAO;AAAA,YACL,SAAA,EAAW,UAAU,IAAI,CAAA;AAAA,YACzB,SAAA,EAAW,mBAAA,GACP,MAAA,GACA,SAAA,CAAU,iBAAiB;AAAA;AACjC;AAAA;AACF;AAAA,GACF;AAGF,EAAA,MAAM;AAAA,IACJ,cAAA;AAAA,IACA,wBAAA;AAAA,IACA,iBAAA;AAAA,IACA;AAAA,GACF,GAAI,kBAAkB,KAAK,CAAA;AAE3B,EAAA,uBACE,GAAA;AAAA,IAAC,aAAA;AAAA,IAAA;AAAA,MACE,GAAG,IAAA;AAAA,MACH,GAAG,UAAA;AAAA,MACJ,SAAA,EAAW,IAAA,CAAK,IAAA,CAAK,SAAA,EAAW,WAAW,SAAS,CAAA;AAAA,MACpD,cAAA;AAAA,MACA,wBAAA;AAAA,MACA,KAAA;AAAA,MAEA,QAAA,kBAAA,GAAA,CAAC,oBAAA,EAAA,EAAqB,KAAA,EAAO,iBAAA,EAC1B,QAAA,EACH;AAAA;AAAA,GACF;AAEJ,CAAC;;;;"}
|
|
@@ -11,8 +11,15 @@ import '../../lib/propsContext/propsContext.mjs';
|
|
|
11
11
|
import { PropsContextProvider } from '../../lib/propsContext/components/PropsContextProvider.mjs';
|
|
12
12
|
|
|
13
13
|
const TextField = flowComponent("TextField", (props) => {
|
|
14
|
-
const {
|
|
15
|
-
|
|
14
|
+
const {
|
|
15
|
+
children,
|
|
16
|
+
placeholder,
|
|
17
|
+
ref,
|
|
18
|
+
form,
|
|
19
|
+
inputContext = Aria.TextFieldContext,
|
|
20
|
+
...rest
|
|
21
|
+
} = props;
|
|
22
|
+
const input = /* @__PURE__ */ jsx(ReactAriaControlledValueFix, { inputContext, props, children: /* @__PURE__ */ jsx(
|
|
16
23
|
Aria.Input,
|
|
17
24
|
{
|
|
18
25
|
form,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextField.mjs","sources":["../../../../../../src/components/TextField/TextField.tsx"],"sourcesContent":["import * as Aria from \"react-aria-components\";\nimport {\n TextFieldBase,\n type TextFieldBaseProps,\n} from \"@/components/TextFieldBase\";\nimport styles from \"./TextField.module.scss\";\nimport type { FlowComponentProps } from \"@/lib/componentFactory/flowComponent\";\nimport { flowComponent } from \"@/lib/componentFactory/flowComponent\";\nimport type { PropsWithClassName } from \"@/lib/types/props\";\nimport {
|
|
1
|
+
{"version":3,"file":"TextField.mjs","sources":["../../../../../../src/components/TextField/TextField.tsx"],"sourcesContent":["import * as Aria from \"react-aria-components\";\nimport {\n TextFieldBase,\n type TextFieldBaseProps,\n} from \"@/components/TextFieldBase\";\nimport styles from \"./TextField.module.scss\";\nimport type { FlowComponentProps } from \"@/lib/componentFactory/flowComponent\";\nimport { flowComponent } from \"@/lib/componentFactory/flowComponent\";\nimport type { PropsWithClassName } from \"@/lib/types/props\";\nimport {\n ReactAriaControlledValueFix,\n type ReactAriaControlledValueFixProps,\n} from \"@/lib/react/ReactAriaControlledValueFix\";\nimport { useFieldComponent } from \"@/lib/hooks/useFieldComponent\";\nimport { PropsContextProvider } from \"@/lib/propsContext\";\n\nexport interface TextFieldProps\n extends Omit<\n TextFieldBaseProps,\n \"FieldErrorView\" | \"FieldErrorCaptureContext\" | \"input\" | \"className\"\n >,\n Pick<Aria.InputProps, \"placeholder\" | \"form\">,\n PropsWithClassName,\n FlowComponentProps<HTMLInputElement> {\n /** @internal */\n inputContext?: ReactAriaControlledValueFixProps[\"inputContext\"];\n}\n\n/** @flr-generate all */\nexport const TextField = flowComponent(\"TextField\", (props) => {\n const {\n children,\n placeholder,\n ref,\n form,\n inputContext = Aria.TextFieldContext,\n ...rest\n } = props;\n\n const input = (\n <ReactAriaControlledValueFix inputContext={inputContext} props={props}>\n <Aria.Input\n form={form}\n placeholder={placeholder}\n className={styles.textField}\n ref={ref}\n />\n </ReactAriaControlledValueFix>\n );\n\n const {\n FieldErrorView,\n FieldErrorCaptureContext,\n fieldPropsContext,\n fieldProps,\n } = useFieldComponent(props);\n\n return (\n <TextFieldBase\n {...rest}\n {...fieldProps}\n FieldErrorView={FieldErrorView}\n FieldErrorCaptureContext={FieldErrorCaptureContext}\n input={input}\n >\n <PropsContextProvider props={fieldPropsContext}>\n {children}\n </PropsContextProvider>\n </TextFieldBase>\n );\n});\n\nexport default TextField;\n"],"names":[],"mappings":";;;;;;;;;;AA6BO,MAAM,SAAA,GAAY,aAAA,CAAc,WAAA,EAAa,CAAC,KAAA,KAAU;AAC7D,EAAA,MAAM;AAAA,IACJ,QAAA;AAAA,IACA,WAAA;AAAA,IACA,GAAA;AAAA,IACA,IAAA;AAAA,IACA,eAAe,IAAA,CAAK,gBAAA;AAAA,IACpB,GAAG;AAAA,GACL,GAAI,KAAA;AAEJ,EAAA,MAAM,KAAA,mBACJ,GAAA,CAAC,2BAAA,EAAA,EAA4B,YAAA,EAA4B,KAAA,EACvD,QAAA,kBAAA,GAAA;AAAA,IAAC,IAAA,CAAK,KAAA;AAAA,IAAL;AAAA,MACC,IAAA;AAAA,MACA,WAAA;AAAA,MACA,WAAW,MAAA,CAAO,SAAA;AAAA,MAClB;AAAA;AAAA,GACF,EACF,CAAA;AAGF,EAAA,MAAM;AAAA,IACJ,cAAA;AAAA,IACA,wBAAA;AAAA,IACA,iBAAA;AAAA,IACA;AAAA,GACF,GAAI,kBAAkB,KAAK,CAAA;AAE3B,EAAA,uBACE,GAAA;AAAA,IAAC,aAAA;AAAA,IAAA;AAAA,MACE,GAAG,IAAA;AAAA,MACH,GAAG,UAAA;AAAA,MACJ,cAAA;AAAA,MACA,wBAAA;AAAA,MACA,KAAA;AAAA,MAEA,QAAA,kBAAA,GAAA,CAAC,oBAAA,EAAA,EAAqB,KAAA,EAAO,iBAAA,EAC1B,QAAA,EACH;AAAA;AAAA,GACF;AAEJ,CAAC;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../../../../../src/components/propTypes/index.ts"],"sourcesContent":["import type { TextProps } from \"@/components/Text\";\nimport type { ButtonProps } from \"@/components/Button\";\nimport type { IconProps } from \"@/components/Icon\";\nimport type { LabelProps } from \"@/components/Label\";\nimport type { ContentProps } from \"@/components/Content\";\nimport type { LayoutCardProps } from \"@/components/LayoutCard\";\nimport type { LinkProps } from \"@/components/Link\";\nimport type { LightBoxProps } from \"@/components/LightBox\";\nimport type { FieldErrorProps } from \"@/components/FieldError\";\nimport type { FieldDescriptionProps } from \"@/components/FieldDescription\";\nimport type { AlertProps } from \"@/components/Alert\";\nimport type { HeadingProps } from \"@/components/Heading\";\nimport type { InitialsProps } from \"@/components/Initials\";\nimport type { ImageProps } from \"@/components/Image\";\nimport type { CopyButtonProps } from \"@/components/CopyButton\";\nimport type { HeaderProps } from \"@/components/Header/\";\nimport type { SwitchProps } from \"@/components/Switch\";\nimport type { AlertBadgeProps } from \"@/components/AlertBadge\";\nimport type { ActionGroupProps } from \"@/components/ActionGroup\";\nimport type { AvatarProps } from \"@/components/Avatar\";\nimport type { ActionProps } from \"@/components/Action\";\nimport type {\n ContextMenuProps,\n ContextMenuTriggerProps,\n MenuItemProps,\n} from \"@/components/ContextMenu\";\nimport type { SelectProps } from \"@/components/Select\";\nimport type {\n RadioButtonProps,\n RadioGroupProps,\n RadioProps,\n} from \"@/components/RadioGroup\";\nimport type { TextFieldProps } from \"@/components/TextField\";\nimport type { NumberFieldProps } from \"@/components/NumberField\";\nimport type { TextAreaProps } from \"@/components/TextArea\";\nimport type { CheckboxGroupProps } from \"@/components/CheckboxGroup\";\nimport type { CheckboxProps } from \"@/components/Checkbox\";\nimport type { CheckboxButtonProps } from \"@/components/CheckboxButton\";\nimport type { TabsProps } from \"@/components/Tabs\";\nimport type { ModalProps } from \"@/components/Modal\";\nimport type { SectionProps } from \"@/components/Section\";\nimport type { SliderProps } from \"@/components/Slider\";\nimport type { CounterBadgeProps } from \"@/components/CounterBadge\";\nimport type { FlowComponentName } from \"@/components/propTypes/types\";\nimport type {\n ContextualHelpProps,\n ContextualHelpTriggerProps,\n} from \"@/components/ContextualHelp\";\nimport type { PopoverProps, PopoverTriggerProps } from \"@/components/Popover\";\nimport type { ContextMenuSectionProps } from \"@/components/ContextMenu/components/ContextMenuSection\";\nimport type { ListProps } from \"@/components/List\";\nimport type { PasswordCreationFieldProps } from \"@/components/PasswordCreationField\";\nimport type { SearchFieldProps } from \"@/components/SearchField\";\nimport type { BadgeProps } from \"@/components/Badge\";\nimport type { DatePickerProps } from \"@/components/DatePicker\";\nimport type * as Aria from \"react-aria-components\";\nimport type { DateRangePickerProps } from \"@/components/DateRangePicker\";\nimport type { TimeFieldProps } from \"@/components/TimeField\";\nimport type { AlertIconProps } from \"@/components/AlertIcon\";\nimport type { ListSummaryProps } from \"@/components/List/components/ListSummary/ListSummary\";\nimport type { SegmentedControlProps } from \"@/components/SegmentedControl\";\nimport type { SegmentProps } from \"@/components/SegmentedControl/components/Segment\";\nimport type { FileCardProps } from \"@/components/FileCard\";\nimport type { FileFieldProps } from \"@/components/FileField\";\nimport type { AlignProps } from \"@/components/Align\";\nimport type { CountryOptionsProps } from \"src/components/CountryOptions\";\nimport type { ComboBoxProps } from \"@/components/ComboBox\";\nimport type { OptionProps } from \"@/components/Option\";\nimport type { MessageProps } from \"@/components/Message\";\nimport type { MessageThreadProps } from \"@/components/MessageThread\";\nimport type { FileCardListProps } from \"@/components/FileCardList\";\nimport type { AccentBoxProps } from \"@/components/AccentBox\";\nimport type { ColumnLayoutProps } from \"@/components/ColumnLayout\";\nimport type { MenuTriggerProps } from \"@/components/OverlayTrigger\";\nimport type { ProgressBarProps } from \"@/components/ProgressBar\";\nimport type { FileDropZoneProps } from \"@/components/FileDropZone\";\nimport type { NavigationProps } from \"@/components/Navigation\";\nimport type { NavigationGroupProps } from \"@/components/Navigation/components/NavigationGroup\";\nimport type { AutocompleteProps } from \"@/components/Autocomplete/Autocomplete\";\nimport type { OptionsProps } from \"@/components/Options/Options\";\nimport type { MarkdownEditorProps } from \"@/components/MarkdownEditor\";\n\nexport * from \"./types\";\n\nexport interface FlowComponentPropsTypes {\n AccentBox: AccentBoxProps;\n Action: ActionProps;\n ActionGroup: ActionGroupProps;\n Alert: AlertProps;\n AlertBadge: AlertBadgeProps;\n AlertIcon: AlertIconProps;\n Align: AlignProps;\n Avatar: AvatarProps;\n Autocomplete: AutocompleteProps;\n Badge: BadgeProps;\n Button: ButtonProps;\n Checkbox: CheckboxProps;\n CheckboxButton: CheckboxButtonProps;\n CheckboxGroup: CheckboxGroupProps;\n ColumnLayout: ColumnLayoutProps;\n ComboBox: ComboBoxProps;\n Content: ContentProps;\n ContextMenu: ContextMenuProps;\n ContextMenuSection: ContextMenuSectionProps;\n ContextMenuTrigger: ContextMenuTriggerProps;\n ContextualHelp: ContextualHelpProps;\n ContextualHelpTrigger: ContextualHelpTriggerProps;\n CopyButton: CopyButtonProps;\n CounterBadge: CounterBadgeProps;\n CountryOptions: CountryOptionsProps;\n DatePicker: DatePickerProps<Aria.DateValue>;\n DateRangePicker: DateRangePickerProps<Aria.DateValue>;\n FieldDescription: FieldDescriptionProps;\n FieldError: FieldErrorProps;\n FileCard: FileCardProps;\n FileCardList: FileCardListProps;\n FileField: FileFieldProps;\n FileDropZone: FileDropZoneProps;\n Header: HeaderProps;\n Heading: HeadingProps;\n Icon: IconProps;\n Image: ImageProps;\n Initials: InitialsProps;\n Label: LabelProps;\n LayoutCard: LayoutCardProps;\n LightBox: LightBoxProps;\n Link: LinkProps;\n List: ListProps<never>;\n ListSummary: ListSummaryProps;\n MarkdownEditor: MarkdownEditorProps;\n MenuItem: MenuItemProps;\n MenuTrigger: MenuTriggerProps;\n Message: MessageProps;\n MessageThread: MessageThreadProps;\n Modal: ModalProps;\n Navigation: NavigationProps;\n NavigationGroup: NavigationGroupProps;\n NumberField: NumberFieldProps;\n Option: OptionProps;\n Options: OptionsProps;\n Popover: PopoverProps;\n PopoverTrigger: PopoverTriggerProps;\n PasswordCreationField: PasswordCreationFieldProps;\n ProgressBar: ProgressBarProps;\n Radio: RadioProps;\n RadioButton: RadioButtonProps;\n RadioGroup: RadioGroupProps;\n SearchField: SearchFieldProps;\n Section: SectionProps;\n Segment: SegmentProps;\n SegmentedControl: SegmentedControlProps;\n Select: SelectProps;\n Slider: SliderProps;\n Switch: SwitchProps;\n Tabs: TabsProps;\n TabTitle: TabsProps;\n Text: TextProps;\n TextArea: TextAreaProps;\n TextField: TextFieldProps;\n TimeField: TimeFieldProps;\n}\n\nconst propsContextSupportingComponentsMap: Record<\n keyof FlowComponentPropsTypes,\n true\n> = {\n AccentBox: true,\n Action: true,\n ActionGroup: true,\n Avatar: true,\n Autocomplete: true,\n Alert: true,\n AlertBadge: true,\n AlertIcon: true,\n Align: true,\n Badge: true,\n Button: true,\n Checkbox: true,\n CheckboxButton: true,\n CheckboxGroup: true,\n ColumnLayout: true,\n ComboBox: true,\n Content: true,\n ContextMenu: true,\n ContextMenuSection: true,\n ContextMenuTrigger: true,\n ContextualHelp: true,\n ContextualHelpTrigger: true,\n CopyButton: true,\n CounterBadge: true,\n CountryOptions: true,\n DatePicker: true,\n DateRangePicker: true,\n FieldDescription: true,\n FieldError: true,\n FileCard: true,\n FileCardList: true,\n FileField: true,\n FileDropZone: true,\n Header: true,\n Heading: true,\n Icon: true,\n Image: true,\n Initials: true,\n Label: true,\n LayoutCard: true,\n LightBox: true,\n Link: true,\n List: true,\n ListSummary: true,\n MarkdownEditor: true,\n MenuItem: true,\n MenuTrigger: true,\n Message: true,\n MessageThread: true,\n Modal: true,\n Navigation: true,\n NavigationGroup: true,\n NumberField: true,\n Radio: true,\n Option: true,\n Options: true,\n Popover: true,\n PopoverTrigger: true,\n PasswordCreationField: true,\n ProgressBar: true,\n RadioButton: true,\n RadioGroup: true,\n SearchField: true,\n Section: true,\n Segment: true,\n SegmentedControl: true,\n Select: true,\n Slider: true,\n Switch: true,\n Tabs: true,\n TabTitle: true,\n TestComponent: true,\n Text: true,\n TextArea: true,\n TextField: true,\n TimeField: true,\n};\n\nexport const propsContextSupportingComponents = Object.keys(\n propsContextSupportingComponentsMap,\n) as FlowComponentName[];\n"],"names":[],"mappings":"AAkKA,MAAM,mCAAA,GAGF;AAAA,EACF,SAAA,EAAW,IAAA;AAAA,EACX,MAAA,EAAQ,IAAA;AAAA,EACR,WAAA,EAAa,IAAA;AAAA,EACb,MAAA,EAAQ,IAAA;AAAA,EACR,YAAA,EAAc,IAAA;AAAA,EACd,KAAA,EAAO,IAAA;AAAA,EACP,UAAA,EAAY,IAAA;AAAA,EACZ,SAAA,EAAW,IAAA;AAAA,EACX,KAAA,EAAO,IAAA;AAAA,EACP,KAAA,EAAO,IAAA;AAAA,EACP,MAAA,EAAQ,IAAA;AAAA,EACR,QAAA,EAAU,IAAA;AAAA,EACV,cAAA,EAAgB,IAAA;AAAA,EAChB,aAAA,EAAe,IAAA;AAAA,EACf,YAAA,EAAc,IAAA;AAAA,EACd,QAAA,EAAU,IAAA;AAAA,EACV,OAAA,EAAS,IAAA;AAAA,EACT,WAAA,EAAa,IAAA;AAAA,EACb,kBAAA,EAAoB,IAAA;AAAA,EACpB,kBAAA,EAAoB,IAAA;AAAA,EACpB,cAAA,EAAgB,IAAA;AAAA,EAChB,qBAAA,EAAuB,IAAA;AAAA,EACvB,UAAA,EAAY,IAAA;AAAA,EACZ,YAAA,EAAc,IAAA;AA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B,IAAA;AAAA,EAClB,MAAA,EAAQ,IAAA;AAAA,EACR,MAAA,EAAQ,IAAA;AAAA,EACR,MAAA,EAAQ,IAAA;AAAA,EACR,IAAA,EAAM,IAAA;AAAA,EACN,QAAA,EAAU,IAAA;AAAA,EACV,aAAA,EAAe,IAAA;AAAA,EACf,IAAA,EAAM,IAAA;AAAA,EACN,QAAA,EAAU,IAAA;AAAA,EACV,SAAA,EAAW,IAAA;AAAA,EACX,SAAA,EAAW;AACb,CAAA;AAEO,MAAM,mCAAmC,MAAA,CAAO,IAAA;AAAA,EACrD;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../../../../../src/components/propTypes/index.ts"],"sourcesContent":["import type { TextProps } from \"@/components/Text\";\nimport type { ButtonProps } from \"@/components/Button\";\nimport type { IconProps } from \"@/components/Icon\";\nimport type { LabelProps } from \"@/components/Label\";\nimport type { ContentProps } from \"@/components/Content\";\nimport type { LayoutCardProps } from \"@/components/LayoutCard\";\nimport type { LinkProps } from \"@/components/Link\";\nimport type { LightBoxProps } from \"@/components/LightBox\";\nimport type { FieldErrorProps } from \"@/components/FieldError\";\nimport type { FieldDescriptionProps } from \"@/components/FieldDescription\";\nimport type { AlertProps } from \"@/components/Alert\";\nimport type { HeadingProps } from \"@/components/Heading\";\nimport type { InitialsProps } from \"@/components/Initials\";\nimport type { ImageProps } from \"@/components/Image\";\nimport type { CopyButtonProps } from \"@/components/CopyButton\";\nimport type { HeaderProps } from \"@/components/Header/\";\nimport type { SwitchProps } from \"@/components/Switch\";\nimport type { AlertBadgeProps } from \"@/components/AlertBadge\";\nimport type { ActionGroupProps } from \"@/components/ActionGroup\";\nimport type { AvatarProps } from \"@/components/Avatar\";\nimport type { ActionProps } from \"@/components/Action\";\nimport type {\n ContextMenuProps,\n ContextMenuTriggerProps,\n MenuItemProps,\n} from \"@/components/ContextMenu\";\nimport type { SelectProps } from \"@/components/Select\";\nimport type {\n RadioButtonProps,\n RadioGroupProps,\n RadioProps,\n} from \"@/components/RadioGroup\";\nimport type { TextFieldProps } from \"@/components/TextField\";\nimport type { NumberFieldProps } from \"@/components/NumberField\";\nimport type { TextAreaProps } from \"@/components/TextArea\";\nimport type { CheckboxGroupProps } from \"@/components/CheckboxGroup\";\nimport type { CheckboxProps } from \"@/components/Checkbox\";\nimport type { CheckboxButtonProps } from \"@/components/CheckboxButton\";\nimport type { TabsProps } from \"@/components/Tabs\";\nimport type { ModalProps } from \"@/components/Modal\";\nimport type { SectionProps } from \"@/components/Section\";\nimport type { SliderProps } from \"@/components/Slider\";\nimport type { CounterBadgeProps } from \"@/components/CounterBadge\";\nimport type { FlowComponentName } from \"@/components/propTypes/types\";\nimport type {\n ContextualHelpProps,\n ContextualHelpTriggerProps,\n} from \"@/components/ContextualHelp\";\nimport type { PopoverProps, PopoverTriggerProps } from \"@/components/Popover\";\nimport type { ContextMenuSectionProps } from \"@/components/ContextMenu/components/ContextMenuSection\";\nimport type { ListProps } from \"@/components/List\";\nimport type { PasswordCreationFieldProps } from \"@/components/PasswordCreationField\";\nimport type { SearchFieldProps } from \"@/components/SearchField\";\nimport type { BadgeProps } from \"@/components/Badge\";\nimport type { DatePickerProps } from \"@/components/DatePicker\";\nimport type * as Aria from \"react-aria-components\";\nimport type { DateRangePickerProps } from \"@/components/DateRangePicker\";\nimport type { TimeFieldProps } from \"@/components/TimeField\";\nimport type { AlertIconProps } from \"@/components/AlertIcon\";\nimport type { ListSummaryProps } from \"@/components/List/components/ListSummary/ListSummary\";\nimport type { SegmentedControlProps } from \"@/components/SegmentedControl\";\nimport type { SegmentProps } from \"@/components/SegmentedControl/components/Segment\";\nimport type { FileCardProps } from \"@/components/FileCard\";\nimport type { FileFieldProps } from \"@/components/FileField\";\nimport type { AlignProps } from \"@/components/Align\";\nimport type { CountryOptionsProps } from \"src/components/CountryOptions\";\nimport type { ComboBoxProps } from \"@/components/ComboBox\";\nimport type { OptionProps } from \"@/components/Option\";\nimport type { MessageProps } from \"@/components/Message\";\nimport type { MessageThreadProps } from \"@/components/MessageThread\";\nimport type { FileCardListProps } from \"@/components/FileCardList\";\nimport type { AccentBoxProps } from \"@/components/AccentBox\";\nimport type { ColumnLayoutProps } from \"@/components/ColumnLayout\";\nimport type { MenuTriggerProps } from \"@/components/OverlayTrigger\";\nimport type { ProgressBarProps } from \"@/components/ProgressBar\";\nimport type { FileDropZoneProps } from \"@/components/FileDropZone\";\nimport type { NavigationProps } from \"@/components/Navigation\";\nimport type { NavigationGroupProps } from \"@/components/Navigation/components/NavigationGroup\";\nimport type { AutocompleteProps } from \"@/components/Autocomplete/Autocomplete\";\nimport type { OptionsProps } from \"@/components/Options/Options\";\nimport type { MarkdownEditorProps } from \"@/components/MarkdownEditor\";\nimport type { SubmitButtonProps } from \"@/integrations/react-hook-form/components/SubmitButton/SubmitButton\";\nimport type { ResetButtonProps } from \"@/integrations/react-hook-form/components/ResetButton/ResetButton\";\n\nexport * from \"./types\";\n\nexport interface FlowComponentPropsTypes {\n AccentBox: AccentBoxProps;\n Action: ActionProps;\n ActionGroup: ActionGroupProps;\n Alert: AlertProps;\n AlertBadge: AlertBadgeProps;\n AlertIcon: AlertIconProps;\n Align: AlignProps;\n Avatar: AvatarProps;\n Autocomplete: AutocompleteProps;\n Badge: BadgeProps;\n Button: ButtonProps;\n Checkbox: CheckboxProps;\n CheckboxButton: CheckboxButtonProps;\n CheckboxGroup: CheckboxGroupProps;\n ColumnLayout: ColumnLayoutProps;\n ComboBox: ComboBoxProps;\n Content: ContentProps;\n ContextMenu: ContextMenuProps;\n ContextMenuSection: ContextMenuSectionProps;\n ContextMenuTrigger: ContextMenuTriggerProps;\n ContextualHelp: ContextualHelpProps;\n ContextualHelpTrigger: ContextualHelpTriggerProps;\n CopyButton: CopyButtonProps;\n CounterBadge: CounterBadgeProps;\n CountryOptions: CountryOptionsProps;\n DatePicker: DatePickerProps<Aria.DateValue>;\n DateRangePicker: DateRangePickerProps<Aria.DateValue>;\n FieldDescription: FieldDescriptionProps;\n FieldError: FieldErrorProps;\n FileCard: FileCardProps;\n FileCardList: FileCardListProps;\n FileField: FileFieldProps;\n FileDropZone: FileDropZoneProps;\n Header: HeaderProps;\n Heading: HeadingProps;\n Icon: IconProps;\n Image: ImageProps;\n Initials: InitialsProps;\n Label: LabelProps;\n LayoutCard: LayoutCardProps;\n LightBox: LightBoxProps;\n Link: LinkProps;\n List: ListProps<never>;\n ListSummary: ListSummaryProps;\n MarkdownEditor: MarkdownEditorProps;\n MenuItem: MenuItemProps;\n MenuTrigger: MenuTriggerProps;\n Message: MessageProps;\n MessageThread: MessageThreadProps;\n Modal: ModalProps;\n Navigation: NavigationProps;\n NavigationGroup: NavigationGroupProps;\n NumberField: NumberFieldProps;\n Option: OptionProps;\n Options: OptionsProps;\n Popover: PopoverProps;\n PopoverTrigger: PopoverTriggerProps;\n PasswordCreationField: PasswordCreationFieldProps;\n ProgressBar: ProgressBarProps;\n Radio: RadioProps;\n RadioButton: RadioButtonProps;\n RadioGroup: RadioGroupProps;\n SearchField: SearchFieldProps;\n Section: SectionProps;\n Segment: SegmentProps;\n SegmentedControl: SegmentedControlProps;\n Select: SelectProps;\n Slider: SliderProps;\n SubmitButton: SubmitButtonProps;\n ResetButton: ResetButtonProps;\n Switch: SwitchProps;\n Tabs: TabsProps;\n TabTitle: TabsProps;\n Text: TextProps;\n TextArea: TextAreaProps;\n TextField: TextFieldProps;\n TimeField: TimeFieldProps;\n}\n\nconst propsContextSupportingComponentsMap: Record<\n keyof FlowComponentPropsTypes,\n true\n> = {\n AccentBox: true,\n Action: true,\n ActionGroup: true,\n Avatar: true,\n Autocomplete: true,\n Alert: true,\n AlertBadge: true,\n AlertIcon: true,\n Align: true,\n Badge: true,\n Button: true,\n Checkbox: true,\n CheckboxButton: true,\n CheckboxGroup: true,\n ColumnLayout: true,\n ComboBox: true,\n Content: true,\n ContextMenu: true,\n ContextMenuSection: true,\n ContextMenuTrigger: true,\n ContextualHelp: true,\n ContextualHelpTrigger: true,\n CopyButton: true,\n CounterBadge: true,\n CountryOptions: true,\n DatePicker: true,\n DateRangePicker: true,\n FieldDescription: true,\n FieldError: true,\n FileCard: true,\n FileCardList: true,\n FileField: true,\n FileDropZone: true,\n Header: true,\n Heading: true,\n Icon: true,\n Image: true,\n Initials: true,\n Label: true,\n LayoutCard: true,\n LightBox: true,\n Link: true,\n List: true,\n ListSummary: true,\n MarkdownEditor: true,\n MenuItem: true,\n MenuTrigger: true,\n Message: true,\n MessageThread: true,\n Modal: true,\n Navigation: true,\n NavigationGroup: true,\n NumberField: true,\n Radio: true,\n Option: true,\n Options: true,\n Popover: true,\n PopoverTrigger: true,\n PasswordCreationField: true,\n ProgressBar: true,\n RadioButton: true,\n RadioGroup: true,\n SearchField: true,\n Section: true,\n Segment: true,\n SegmentedControl: true,\n Select: true,\n Slider: true,\n SubmitButton: true,\n ResetButton: true,\n Switch: true,\n Tabs: true,\n TabTitle: true,\n TestComponent: true,\n Text: true,\n TextArea: true,\n TextField: true,\n TimeField: true,\n};\n\nexport const propsContextSupportingComponents = Object.keys(\n propsContextSupportingComponentsMap,\n) as FlowComponentName[];\n"],"names":[],"mappings":"AAsKA,MAAM,mCAAA,GAGF;AAAA,EACF,SAAA,EAAW,IAAA;AAAA,EACX,MAAA,EAAQ,IAAA;AAAA,EACR,WAAA,EAAa,IAAA;AAAA,EACb,MAAA,EAAQ,IAAA;AAAA,EACR,YAAA,EAAc,IAAA;AAAA,EACd,KAAA,EAAO,IAAA;AAAA,EACP,UAAA,EAAY,IAAA;AAAA,EACZ,SAAA,EAAW,IAAA;AAAA,EACX,KAAA,EAAO,IAAA;AAAA,EACP,KAAA,EAAO,IAAA;AAAA,EACP,MAAA,EAAQ,IAAA;AAAA,EACR,QAAA,EAAU,IAAA;AAAA,EACV,cAAA,EAAgB,IAAA;AAAA,EAChB,aAAA,EAAe,IAAA;AAAA,EACf,YAAA,EAAc,IAAA;AAAA,EACd,QAAA,EAAU,IAAA;AAAA,EACV,OAAA,EAAS,IAAA;AAAA,EACT,WA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,IAAA;AAAA,EACvB,WAAA,EAAa,IAAA;AAAA,EACb,WAAA,EAAa,IAAA;AAAA,EACb,UAAA,EAAY,IAAA;AAAA,EACZ,WAAA,EAAa,IAAA;AAAA,EACb,OAAA,EAAS,IAAA;AAAA,EACT,OAAA,EAAS,IAAA;AAAA,EACT,gBAAA,EAAkB,IAAA;AAAA,EAClB,MAAA,EAAQ,IAAA;AAAA,EACR,MAAA,EAAQ,IAAA;AAAA,EACR,YAAA,EAAc,IAAA;AAAA,EACd,WAAA,EAAa,IAAA;AAAA,EACb,MAAA,EAAQ,IAAA;AAAA,EACR,IAAA,EAAM,IAAA;AAAA,EACN,QAAA,EAAU,IAAA;AAAA,EACV,aAAA,EAAe,IAAA;AAAA,EACf,IAAA,EAAM,IAAA;AAAA,EACN,QAAA,EAAU,IAAA;AAAA,EACV,SAAA,EAAW,IAAA;AAAA,EACX,SAAA,EAAW;AACb,CAAA;AAEO,MAAM,mCAAmC,MAAA,CAAO,IAAA;AAAA,EACrD;AACF;;;;"}
|
|
@@ -11,6 +11,8 @@ import { useLocalizedStringFormatter } from 'react-aria';
|
|
|
11
11
|
import locales from '../../../../../../_virtual/_.locale.json@72ba2ce40f190df671686fec50c04ddf.mjs';
|
|
12
12
|
import { inheritProps } from '../../../../lib/propsContext/inherit/types.mjs';
|
|
13
13
|
import FieldErrorView from '../../../../views/FieldErrorView.mjs';
|
|
14
|
+
import { useHotkeys } from 'react-hotkeys-hook';
|
|
15
|
+
import { useMergeRefs } from 'use-callback-ref';
|
|
14
16
|
|
|
15
17
|
function Field(props) {
|
|
16
18
|
const { children, name, defaultValue, ...rest } = props;
|
|
@@ -39,9 +41,21 @@ function Field(props) {
|
|
|
39
41
|
name
|
|
40
42
|
}) ?? controller.field.value;
|
|
41
43
|
const isFieldInvalid = controller.fieldState.invalid;
|
|
44
|
+
const hotkeyRef = useHotkeys(
|
|
45
|
+
"meta+enter, ctrl+enter",
|
|
46
|
+
() => {
|
|
47
|
+
formContext.submit();
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
enableOnFormTags: true,
|
|
51
|
+
enableOnContentEditable: true
|
|
52
|
+
}
|
|
53
|
+
);
|
|
54
|
+
const fieldRef = useMergeRefs([controller.field.ref, hotkeyRef]);
|
|
42
55
|
const fieldProps = {
|
|
43
56
|
...inheritProps,
|
|
44
57
|
...controller.field,
|
|
58
|
+
ref: fieldRef,
|
|
45
59
|
value,
|
|
46
60
|
name,
|
|
47
61
|
form: formContext.id,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Field.mjs","sources":["../../../../../../../../src/integrations/react-hook-form/components/Field/Field.tsx"],"sourcesContent":["import { useFormContext } from \"@/integrations/react-hook-form/components/context/formContext\";\nimport { dynamic, type PropsContext } from \"@/lib/propsContext\";\nimport { PropsContextProvider } from \"@/lib/propsContext\";\nimport { type PropsWithChildren } from \"react\";\nimport {\n type ControllerProps,\n type FieldValues,\n useController,\n type UseFormReturn,\n useWatch,\n} from \"react-hook-form\";\nimport { useLocalizedStringFormatter } from \"react-aria\";\nimport locales from \"./locales/*.locale.json\";\nimport { inheritProps } from \"@/lib/propsContext/inherit/types\";\nimport FieldErrorView from \"@/views/FieldErrorView\";\n\nexport interface FieldProps<T extends FieldValues>\n extends Omit<ControllerProps<T>, \"render\">,\n PropsWithChildren {}\n\nexport function Field<T extends FieldValues>(props: FieldProps<T>) {\n const { children, name, defaultValue, ...rest } = props;\n\n const stringFormatter = useLocalizedStringFormatter(locales);\n\n const controller = useController({\n ...props,\n rules: {\n ...props.rules,\n minLength:\n typeof rest.rules?.minLength === \"number\"\n ? {\n value: rest.rules.minLength,\n message: stringFormatter.format(\"minLength\", {\n number: rest.rules.minLength,\n }),\n }\n : rest.rules?.minLength,\n maxLength:\n typeof rest.rules?.maxLength === \"number\"\n ? {\n value: rest.rules.maxLength,\n message: stringFormatter.format(\"maxLength\", {\n number: rest.rules.maxLength,\n }),\n }\n : rest.rules?.maxLength,\n },\n });\n const formContext = useFormContext<T>();\n /**\n * We don't use controller.field.value here, because it doesn't update when\n * the form value is updated outside of this field (e.g. when setting values\n * with form.setValue or resetting the form), and the Field unmounts in\n * between. This is generally a feature of React Hook Form, but this breaks\n * dynamic forms where fields are conditionally rendered.\n *\n * By using formContext.form.watch(name), we ensure that the field value is\n * always in sync with the form state. See:\n * https://react-hook-form.com/api/usecontroller/controller/\n */\n const value =\n useWatch({\n control: formContext.form.control,\n name,\n }) ?? controller.field.value;\n\n const isFieldInvalid = controller.fieldState.invalid;\n\n const fieldProps = {\n ...inheritProps,\n ...controller.field,\n value,\n name,\n form: formContext.id,\n isRequired: !!rest.rules?.required,\n isReadOnly: formContext.isReadOnly,\n validationBehavior: \"aria\" as const,\n defaultValue,\n isInvalid: isFieldInvalid,\n children: dynamic((p) => {\n return (\n <>\n {p.children}\n <FieldErrorView>\n {controller.fieldState.error?.message}\n </FieldErrorView>\n </>\n );\n }),\n };\n\n const { value: ignoredValue, ...fieldPropsWithoutValue } = fieldProps;\n\n const propsContext: PropsContext = {\n SearchField: fieldProps,\n TextField: fieldProps,\n TextArea: fieldProps,\n MarkdownEditor: fieldProps,\n Checkbox: {\n ...fieldProps,\n isSelected: value,\n },\n CheckboxGroup: {\n ...fieldProps,\n },\n CheckboxButton: {\n ...fieldProps,\n isSelected: value,\n },\n FileField: fieldProps,\n FileDropZone: fieldProps,\n NumberField: fieldProps,\n RadioGroup: fieldProps,\n Switch: {\n ...fieldProps,\n isSelected: value,\n },\n Slider: fieldProps,\n PasswordCreationField: fieldProps,\n DatePicker: fieldProps,\n DateRangePicker: fieldProps,\n TimeField: fieldProps,\n SegmentedControl: fieldProps,\n Select: {\n ...fieldProps,\n selectedKey: value,\n },\n ComboBox: {\n ...fieldPropsWithoutValue,\n selectedKey: value,\n },\n };\n\n return (\n <PropsContextProvider\n props={propsContext}\n dependencies={[\n controller.fieldState,\n controller.field,\n value,\n formContext.isReadOnly,\n ]}\n >\n {children}\n </PropsContextProvider>\n );\n}\n\nexport const typedField = <T extends FieldValues>(\n ignoredForm: UseFormReturn<T> | UseFormReturn<T>[\"control\"],\n): typeof Field<T> => Field;\n\nexport default Field;\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Field.mjs","sources":["../../../../../../../../src/integrations/react-hook-form/components/Field/Field.tsx"],"sourcesContent":["import { useFormContext } from \"@/integrations/react-hook-form/components/context/formContext\";\nimport { dynamic, type PropsContext } from \"@/lib/propsContext\";\nimport { PropsContextProvider } from \"@/lib/propsContext\";\nimport { type PropsWithChildren } from \"react\";\nimport {\n type ControllerProps,\n type FieldValues,\n useController,\n type UseFormReturn,\n useWatch,\n} from \"react-hook-form\";\nimport { useLocalizedStringFormatter } from \"react-aria\";\nimport locales from \"./locales/*.locale.json\";\nimport { inheritProps } from \"@/lib/propsContext/inherit/types\";\nimport FieldErrorView from \"@/views/FieldErrorView\";\nimport { useHotkeys } from \"react-hotkeys-hook\";\nimport { useMergeRefs } from \"use-callback-ref\";\n\nexport interface FieldProps<T extends FieldValues>\n extends Omit<ControllerProps<T>, \"render\">,\n PropsWithChildren {}\n\nexport function Field<T extends FieldValues>(props: FieldProps<T>) {\n const { children, name, defaultValue, ...rest } = props;\n\n const stringFormatter = useLocalizedStringFormatter(locales);\n\n const controller = useController({\n ...props,\n rules: {\n ...props.rules,\n minLength:\n typeof rest.rules?.minLength === \"number\"\n ? {\n value: rest.rules.minLength,\n message: stringFormatter.format(\"minLength\", {\n number: rest.rules.minLength,\n }),\n }\n : rest.rules?.minLength,\n maxLength:\n typeof rest.rules?.maxLength === \"number\"\n ? {\n value: rest.rules.maxLength,\n message: stringFormatter.format(\"maxLength\", {\n number: rest.rules.maxLength,\n }),\n }\n : rest.rules?.maxLength,\n },\n });\n const formContext = useFormContext<T>();\n /**\n * We don't use controller.field.value here, because it doesn't update when\n * the form value is updated outside of this field (e.g. when setting values\n * with form.setValue or resetting the form), and the Field unmounts in\n * between. This is generally a feature of React Hook Form, but this breaks\n * dynamic forms where fields are conditionally rendered.\n *\n * By using formContext.form.watch(name), we ensure that the field value is\n * always in sync with the form state. See:\n * https://react-hook-form.com/api/usecontroller/controller/\n */\n const value =\n useWatch({\n control: formContext.form.control,\n name,\n }) ?? controller.field.value;\n\n const isFieldInvalid = controller.fieldState.invalid;\n\n const hotkeyRef = useHotkeys<never>(\n \"meta+enter, ctrl+enter\",\n () => {\n formContext.submit();\n },\n {\n enableOnFormTags: true,\n enableOnContentEditable: true,\n },\n );\n const fieldRef = useMergeRefs([controller.field.ref, hotkeyRef]);\n\n const fieldProps = {\n ...inheritProps,\n ...controller.field,\n ref: fieldRef,\n value,\n name,\n form: formContext.id,\n isRequired: !!rest.rules?.required,\n isReadOnly: formContext.isReadOnly,\n validationBehavior: \"aria\" as const,\n defaultValue,\n isInvalid: isFieldInvalid,\n children: dynamic((p) => {\n return (\n <>\n {p.children}\n <FieldErrorView>\n {controller.fieldState.error?.message}\n </FieldErrorView>\n </>\n );\n }),\n };\n\n const { value: ignoredValue, ...fieldPropsWithoutValue } = fieldProps;\n\n const propsContext: PropsContext = {\n SearchField: fieldProps,\n TextField: fieldProps,\n TextArea: fieldProps,\n MarkdownEditor: fieldProps,\n Checkbox: {\n ...fieldProps,\n isSelected: value,\n },\n CheckboxGroup: {\n ...fieldProps,\n },\n CheckboxButton: {\n ...fieldProps,\n isSelected: value,\n },\n FileField: fieldProps,\n FileDropZone: fieldProps,\n NumberField: fieldProps,\n RadioGroup: fieldProps,\n Switch: {\n ...fieldProps,\n isSelected: value,\n },\n Slider: fieldProps,\n PasswordCreationField: fieldProps,\n DatePicker: fieldProps,\n DateRangePicker: fieldProps,\n TimeField: fieldProps,\n SegmentedControl: fieldProps,\n Select: {\n ...fieldProps,\n selectedKey: value,\n },\n ComboBox: {\n ...fieldPropsWithoutValue,\n selectedKey: value,\n },\n };\n\n return (\n <PropsContextProvider\n props={propsContext}\n dependencies={[\n controller.fieldState,\n controller.field,\n value,\n formContext.isReadOnly,\n ]}\n >\n {children}\n </PropsContextProvider>\n );\n}\n\nexport const typedField = <T extends FieldValues>(\n ignoredForm: UseFormReturn<T> | UseFormReturn<T>[\"control\"],\n): typeof Field<T> => Field;\n\nexport default Field;\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAsBO,SAAS,MAA6B,KAAA,EAAsB;AACjE,EAAA,MAAM,EAAE,QAAA,EAAU,IAAA,EAAM,YAAA,EAAc,GAAG,MAAK,GAAI,KAAA;AAElD,EAAA,MAAM,eAAA,GAAkB,4BAA4B,OAAO,CAAA;AAE3D,EAAA,MAAM,aAAa,aAAA,CAAc;AAAA,IAC/B,GAAG,KAAA;AAAA,IACH,KAAA,EAAO;AAAA,MACL,GAAG,KAAA,CAAM,KAAA;AAAA,MACT,SAAA,EACE,OAAO,IAAA,CAAK,KAAA,EAAO,cAAc,QAAA,GAC7B;AAAA,QACE,KAAA,EAAO,KAAK,KAAA,CAAM,SAAA;AAAA,QAClB,OAAA,EAAS,eAAA,CAAgB,MAAA,CAAO,WAAA,EAAa;AAAA,UAC3C,MAAA,EAAQ,KAAK,KAAA,CAAM;AAAA,SACpB;AAAA,OACH,GACA,KAAK,KAAA,EAAO,SAAA;AAAA,MAClB,SAAA,EACE,OAAO,IAAA,CAAK,KAAA,EAAO,cAAc,QAAA,GAC7B;AAAA,QACE,KAAA,EAAO,KAAK,KAAA,CAAM,SAAA;AAAA,QAClB,OAAA,EAAS,eAAA,CAAgB,MAAA,CAAO,WAAA,EAAa;AAAA,UAC3C,MAAA,EAAQ,KAAK,KAAA,CAAM;AAAA,SACpB;AAAA,OACH,GACA,KAAK,KAAA,EAAO;AAAA;AACpB,GACD,CAAA;AACD,EAAA,MAAM,cAAc,cAAA,EAAkB;AAYtC,EAAA,MAAM,QACJ,QAAA,CAAS;AAAA,IACP,OAAA,EAAS,YAAY,IAAA,CAAK,OAAA;AAAA,IAC1B;AAAA,GACD,CAAA,IAAK,UAAA,CAAW,KAAA,CAAM,KAAA;AAEzB,EAAA,MAAM,cAAA,GAAiB,WAAW,UAAA,CAAW,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AAG,UAAA;AAAA,MACH,UAAA,EAAY;AAAA,KACd;AAAA,IACA,aAAA,EAAe;AAAA,MACb,GAAG;AAAA,KACL;AAAA,IACA,cAAA,EAAgB;AAAA,MACd,GAAG,UAAA;AAAA,MACH,UAAA,EAAY;AAAA,KACd;AAAA,IACA,SAAA,EAAW,UAAA;AAAA,IACX,YAAA,EAAc,UAAA;AAAA,IACd,WAAA,EAAa,UAAA;AAAA,IACb,UAAA,EAAY,UAAA;AAAA,IACZ,MAAA,EAAQ;AAAA,MACN,GAAG,UAAA;AAAA,MACH,UAAA,EAAY;AAAA,KACd;AAAA,IACA,MAAA,EAAQ,UAAA;AAAA,IACR,qBAAA,EAAuB,UAAA;AAAA,IACvB,UAAA,EAAY,UAAA;AAAA,IACZ,eAAA,EAAiB,UAAA;AAAA,IACjB,SAAA,EAAW,UAAA;AAAA,IACX,gBAAA,EAAkB,UAAA;AAAA,IAClB,MAAA,EAAQ;AAAA,MACN,GAAG,UAAA;AAAA,MACH,WAAA,EAAa;AAAA,KACf;AAAA,IACA,QAAA,EAAU;AAAA,MACR,GAAG,sBAAA;AAAA,MACH,WAAA,EAAa;AAAA;AACf,GACF;AAEA,EAAA,uBACE,GAAA;AAAA,IAAC,oBAAA;AAAA,IAAA;AAAA,MACC,KAAA,EAAO,YAAA;AAAA,MACP,YAAA,EAAc;AAAA,QACZ,UAAA,CAAW,UAAA;AAAA,QACX,UAAA,CAAW,KAAA;AAAA,QACX,KAAA;AAAA,QACA,WAAA,CAAY;AAAA,OACd;AAAA,MAEC;AAAA;AAAA,GACH;AAEJ;AAEO,MAAM,UAAA,GAAa,CACxB,WAAA,KACoB;;;;"}
|
|
@@ -2,11 +2,9 @@
|
|
|
2
2
|
/* */
|
|
3
3
|
import { jsx } from 'react/jsx-runtime';
|
|
4
4
|
import { FormContextProvider } from '../context/formContext.mjs';
|
|
5
|
-
import { useState, useId, useMemo } from 'react';
|
|
5
|
+
import { useState, useId, useMemo, useRef } from 'react';
|
|
6
6
|
import { FormProvider } from 'react-hook-form';
|
|
7
|
-
import {
|
|
8
|
-
import 'react-aria';
|
|
9
|
-
import '@react-aria/live-announcer';
|
|
7
|
+
import { useObjectRef } from '@react-aria/utils';
|
|
10
8
|
import { useRegisterActionStateContext } from './lib/useRegisterActionStateContext.mjs';
|
|
11
9
|
|
|
12
10
|
const DefaultFormComponent = (p) => /* @__PURE__ */ jsx("form", { ...p });
|
|
@@ -17,13 +15,17 @@ function Form(props) {
|
|
|
17
15
|
onSubmit,
|
|
18
16
|
formComponent: FormView = DefaultFormComponent,
|
|
19
17
|
isReadOnly: isReadOnlyFromProps,
|
|
18
|
+
ref,
|
|
20
19
|
...formProps
|
|
21
20
|
} = props;
|
|
22
21
|
const [readonlyContextState, setReadOnlyContextState] = useState(!!isReadOnlyFromProps);
|
|
23
|
-
const isReadOnly = isReadOnlyFromProps || readonlyContextState;
|
|
24
22
|
const formId = useId();
|
|
25
23
|
const FormViewComponent = useMemo(() => FormView, [formId]);
|
|
26
|
-
const
|
|
24
|
+
const formRef = useObjectRef(ref);
|
|
25
|
+
const submitButtonRef = useRef(null);
|
|
26
|
+
const submitHandlerResultRef = useRef(null);
|
|
27
|
+
const isReadOnly = isReadOnlyFromProps || readonlyContextState;
|
|
28
|
+
const { action, registerSubmitResult, callAfterSubmitFunction } = useRegisterActionStateContext(form);
|
|
27
29
|
const handleOnSubmit = (e) => {
|
|
28
30
|
const { isSubmitting, isValidating } = form.control._formState;
|
|
29
31
|
const formEvent = e && "nativeEvent" in e ? e : void 0;
|
|
@@ -32,11 +34,16 @@ function Form(props) {
|
|
|
32
34
|
formEvent?.preventDefault();
|
|
33
35
|
return;
|
|
34
36
|
}
|
|
35
|
-
form.handleSubmit((values) => {
|
|
37
|
+
const submit = form.handleSubmit((values) => {
|
|
38
|
+
setReadOnlyContextState(true);
|
|
36
39
|
const result = onSubmit(values, formEvent);
|
|
37
40
|
registerSubmitResult(result);
|
|
38
41
|
return result;
|
|
39
|
-
})
|
|
42
|
+
});
|
|
43
|
+
return submit(formEvent).finally(() => {
|
|
44
|
+
callAfterSubmitFunction(submitHandlerResultRef.current);
|
|
45
|
+
setReadOnlyContextState(false);
|
|
46
|
+
});
|
|
40
47
|
};
|
|
41
48
|
return /* @__PURE__ */ jsx(FormProvider, { ...form, children: /* @__PURE__ */ jsx(
|
|
42
49
|
FormContextProvider,
|
|
@@ -45,17 +52,21 @@ function Form(props) {
|
|
|
45
52
|
form,
|
|
46
53
|
id: formId,
|
|
47
54
|
isReadOnly,
|
|
48
|
-
setReadOnly: setReadOnlyContextState
|
|
55
|
+
setReadOnly: setReadOnlyContextState,
|
|
56
|
+
submit: handleOnSubmit,
|
|
57
|
+
submitButtonRef,
|
|
58
|
+
formActionModel: action
|
|
49
59
|
},
|
|
50
|
-
children: /* @__PURE__ */ jsx(
|
|
60
|
+
children: /* @__PURE__ */ jsx(
|
|
51
61
|
FormViewComponent,
|
|
52
62
|
{
|
|
53
63
|
...formProps,
|
|
64
|
+
ref: formRef,
|
|
54
65
|
id: formId,
|
|
55
66
|
onSubmit: handleOnSubmit,
|
|
56
67
|
children
|
|
57
68
|
}
|
|
58
|
-
)
|
|
69
|
+
)
|
|
59
70
|
}
|
|
60
71
|
) });
|
|
61
72
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Form.mjs","sources":["../../../../../../../../src/integrations/react-hook-form/components/Form/Form.tsx"],"sourcesContent":["import { FormContextProvider } from \"@/integrations/react-hook-form/components/context/formContext\";\nimport {\n type ComponentProps,\n type
|
|
1
|
+
{"version":3,"file":"Form.mjs","sources":["../../../../../../../../src/integrations/react-hook-form/components/Form/Form.tsx"],"sourcesContent":["import { FormContextProvider } from \"@/integrations/react-hook-form/components/context/formContext\";\nimport {\n type ComponentProps,\n type FormEvent,\n type FormEventHandler,\n type PropsWithChildren,\n type RefObject,\n useId,\n useMemo,\n useState,\n useRef,\n type FC,\n} from \"react\";\nimport type {\n FieldValues,\n SubmitHandler,\n UseFormReturn,\n} from \"react-hook-form\";\nimport { FormProvider as RhfFormContextProvider } from \"react-hook-form\";\nimport { useObjectRef } from \"@react-aria/utils\";\nimport { useRegisterActionStateContext } from \"@/integrations/react-hook-form/components/Form/lib/useRegisterActionStateContext\";\n\nexport type FormOnSubmitHandler<F extends FieldValues> = SubmitHandler<F>;\n\ntype FormComponentType = FC<\n PropsWithChildren<{\n id: string;\n onSubmit?: FormEventHandler | FormOnSubmitHandler<never>;\n ref?: RefObject<HTMLFormElement | null>;\n }>\n>;\n\nexport interface FormProps<F extends FieldValues>\n extends Omit<ComponentProps<\"form\">, \"onSubmit\">,\n PropsWithChildren {\n form: UseFormReturn<F>;\n onSubmit: FormOnSubmitHandler<F>;\n formComponent?: FC<Omit<FormComponentType, \"ref\">>;\n isReadOnly?: boolean;\n}\n\nconst DefaultFormComponent: FormComponentType = (p) => <form {...p} />;\n\nexport function Form<F extends FieldValues>(props: FormProps<F>) {\n const {\n form,\n children,\n onSubmit,\n formComponent: FormView = DefaultFormComponent,\n isReadOnly: isReadOnlyFromProps,\n ref,\n ...formProps\n } = props;\n\n const [readonlyContextState, setReadOnlyContextState] =\n useState(!!isReadOnlyFromProps);\n\n const formId = useId();\n const FormViewComponent = useMemo(() => FormView, [formId]);\n\n const formRef = useObjectRef(ref);\n const submitButtonRef = useRef<HTMLButtonElement>(null);\n const submitHandlerResultRef = useRef<unknown>(null);\n\n const isReadOnly = isReadOnlyFromProps || readonlyContextState;\n\n const { action, registerSubmitResult, callAfterSubmitFunction } =\n useRegisterActionStateContext(form);\n\n const handleOnSubmit = (e?: FormEvent<HTMLFormElement> | F) => {\n const { isSubmitting, isValidating } = form.control._formState;\n const formEvent =\n e && \"nativeEvent\" in e ? (e as FormEvent<HTMLFormElement>) : undefined;\n\n formEvent?.stopPropagation();\n\n if (isSubmitting || isValidating) {\n formEvent?.preventDefault();\n return;\n }\n\n const submit = form.handleSubmit((values) => {\n setReadOnlyContextState(true);\n const result = onSubmit(values, formEvent);\n registerSubmitResult(result);\n return result;\n });\n\n return submit(formEvent).finally(() => {\n callAfterSubmitFunction(submitHandlerResultRef.current);\n setReadOnlyContextState(false);\n });\n };\n\n return (\n <RhfFormContextProvider {...form}>\n <FormContextProvider\n value={{\n form,\n id: formId,\n isReadOnly,\n setReadOnly: setReadOnlyContextState,\n submit: handleOnSubmit,\n submitButtonRef: submitButtonRef,\n formActionModel: action,\n }}\n >\n <FormViewComponent\n {...formProps}\n ref={formRef}\n id={formId}\n onSubmit={handleOnSubmit}\n >\n {children}\n </FormViewComponent>\n </FormContextProvider>\n </RhfFormContextProvider>\n );\n}\n\nexport default Form;\n"],"names":["RhfFormContextProvider"],"mappings":";;;;;;;AAyCA,MAAM,uBAA0C,CAAC,CAAA,qBAAM,GAAA,CAAC,MAAA,EAAA,EAAM,GAAG,CAAA,EAAG,CAAA;AAE7D,SAAS,KAA4B,KAAA,EAAqB;AAC/D,EAAA,MAAM;AAAA,IACJ,IAAA;AAAA,IACA,QAAA;AAAA,IACA,QAAA;AAAA,IACA,eAAe,QAAA,GAAW,oBAAA;AAAA,IAC1B,UAAA,EAAY,mBAAA;AAAA,IACZ,GAAA;AAAA,IACA,GAAG;AAAA,GACL,GAAI,KAAA;AAEJ,EAAA,MAAM,CAAC,oBAAA,EAAsB,uBAAuB,IAClD,QAAA,CAAS,CAAC,CAAC,mBAAmB,CAAA;AAEhC,EAAA,MAAM,SAAS,KAAA,EAAM;AACrB,EAAA,MAAM,oBAAoB,OAAA,CAAQ,MAAM,QAAA,EAAU,CAAC,MAAM,CAAC,CAAA;AAE1D,EAAA,MAAM,OAAA,GAAU,aAAa,GAAG,CAAA;AAChC,EAAA,MAAM,eAAA,GAAkB,OAA0B,IAAI,CAAA;AACtD,EAAA,MAAM,sBAAA,GAAyB,OAAgB,IAAI,CAAA;AAEnD,EAAA,MAAM,aAAa,mBAAA,IAAuB,oBAAA;AAE1C,EAAA,MAAM,EAAE,MAAA,EAAQ,oBAAA,EAAsB,uBAAA,EAAwB,GAC5D,8BA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,SAAA;AAAA,UACJ,GAAA,EAAK,OAAA;AAAA,UACL,EAAA,EAAI,MAAA;AAAA,UACJ,QAAA,EAAU,cAAA;AAAA,UAET;AAAA;AAAA;AACH;AAAA,GACF,EACF,CAAA;AAEJ;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRegisterActionStateContext.mjs","sources":["../../../../../../../../../src/integrations/react-hook-form/components/Form/lib/useRegisterActionStateContext.ts"],"sourcesContent":["import { ActionModel } from \"@/components/Action/models/ActionModel\";\nimport { useEffect, useRef } from \"react\";\nimport { isPromise } from \"remeda\";\nimport type { FieldValues, UseFormReturn } from \"react-hook-form\";\n\nconst callAfterSubmitFunction = (result: unknown) => {\n const callFn = (something: unknown) => {\n if (typeof something === \"function\") {\n something();\n }\n };\n\n if (result instanceof Promise) {\n result.then(callFn);\n } else {\n callFn(result);\n }\n};\n\nexport const useRegisterActionStateContext = <T extends FieldValues>(\n form: UseFormReturn<T>,\n) => {\n const action = ActionModel.useNew({});\n const trackedSubmitCount = useRef(0);\n const submitHandlerResultRef = useRef<unknown>(null);\n\n useEffect(() => {\n return form.subscribe({\n formState: {\n errors: true,\n isValid: true,\n },\n callback: ({\n isValid,\n isSubmitted = false,\n isSubmitSuccessful = false,\n submitCount = 0,\n errors,\n }) => {\n if (submitCount === 0 && trackedSubmitCount.current > 0) {\n trackedSubmitCount.current = 0;\n }\n\n if (trackedSubmitCount.current === submitCount) {\n return;\n }\n trackedSubmitCount.current = submitCount;\n\n if (isSubmitted) {\n if (isSubmitSuccessful) {\n void action.state.onSucceeded();\n\n if (isValid) {\n callAfterSubmitFunction(submitHandlerResultRef.current);\n }\n } else {\n const hasFailedWithError =\n isSubmitted && errors && Object.entries(errors).length > 0\n ? errors\n : undefined;\n\n void action.state.onFailed(hasFailedWithError);\n }\n }\n },\n });\n }, [form.subscribe, action.state]);\n\n const registerSubmitResult = (result: unknown) => {\n if (isPromise(result)) {\n void action.state.onAsyncStart();\n result.then((submitResult) => {\n submitHandlerResultRef.current = submitResult;\n });\n } else {\n submitHandlerResultRef.current = result;\n }\n };\n\n return {\n action,\n registerSubmitResult,\n } as const;\n};\n"],"names":[],"mappings":";;;;AAKA,MAAM,uBAAA,GAA0B,CAAC,MAAA,KAAoB;AACnD,EAAA,MAAM,MAAA,GAAS,CAAC,SAAA,KAAuB;AACrC,IAAA,IAAI,OAAO,cAAc,UAAA,EAAY;AACnC,MAAA,SAAA,EAAU;AAAA,IACZ;AAAA,EACF,CAAA;AAEA,EAAA,IAAI,kBAAkB,OAAA,EAAS;AAC7B,IAAA,MAAA,CAAO,KAAK,MAAM,CAAA;AAAA,EACpB,CAAA,MAAO;AACL,IAAA,MAAA,CAAO,MAAM,CAAA;AAAA,EACf;AACF,CAAA;AAEO,MAAM,6BAAA,GAAgC,CAC3C,IAAA,KACG;AACH,EAAA,MAAM,MAAA,GAAS,WAAA,CAAY,MAAA,CAAO,EAAE,CAAA;AACpC,EAAA,MAAM,kBAAA,GAAqB,OAAO,CAAC,CAAA;AACnC,EAAA,MAAM,sBAAA,GAAyB,OAAgB,IAAI,CAAA;AAEnD,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,OAAO,KAAK,SAAA,CAAU;AAAA,MACpB,SAAA,EAAW;AAAA,QACT,MAAA,EAAQ,IAAA;AAAA,QACR,OAAA,EAAS;AAAA,OACX;AAAA,MACA,UAAU,CAAC;AAAA,QACT,OAAA;AAAA,QACA,WAAA,GAAc,KAAA;AAAA,QACd,kBAAA,GAAqB,KAAA;AAAA,QACrB,WAAA,GAAc,CAAA;AAAA,QACd;AAAA,OACF,KAAM;AACJ,QAAA,IAAI,WAAA,KAAgB,CAAA,IAAK,kBAAA,CAAmB,OAAA,GAAU,CAAA,EAAG;AACvD,UAAA,kBAAA,CAAmB,OAAA,GAAU,CAAA;AAAA,QAC/B;AAEA,QAAA,IAAI,kBAAA,CAAmB,YAAY,WAAA,EAAa;AAC9C,UAAA;AAAA,QACF;AACA,QAAA,kBAAA,CAAmB,OAAA,GAAU,WAAA;AAE7B,QAAA,IAAI,WAAA,EAAa;AACf,UAAA,IAAI,kBAAA,EAAoB;AACtB,YAAA,KAAK,MAAA,CAAO,MAAM,WAAA,EAAY;AAE9B,YAAA,IAAI,OAAA,EAAS;AACX,cAAA,uBAAA,CAAwB,uBAAuB,OAAO,CAAA;AAAA,YACxD;AAAA,UACF,CAAA,MAAO;AACL,YAAA,MAAM,kBAAA,GACJ,eAAe,MAAA,IAAU,MAAA,CAAO,QAAQ,MAAM,CAAA,CAAE,MAAA,GAAS,CAAA,GACrD,MAAA,GACA,MAAA;AAEN,YAAA,KAAK,MAAA,CAAO,KAAA,CAAM,QAAA,CAAS,kBAAkB,CAAA;AAAA,UAC/C;AAAA,QACF;AAAA,MACF;AAAA,KACD,CAAA;AAAA,EACH,GAAG,CAAC,IAAA,CAAK,SAAA,EAAW,MAAA,CAAO,KAAK,CAAC,CAAA;AAEjC,EAAA,MAAM,oBAAA,GAAuB,CAAC,MAAA,KAAoB;AAChD,IAAA,IAAI,SAAA,CAAU,MAAM,CAAA,EAAG;AACrB,MAAA,KAAK,MAAA,CAAO,MAAM,YAAA,EAAa;AAC/B,MAAA,MAAA,CAAO,IAAA,CAAK,CAAC,YAAA,KAAiB;AAC5B,QAAA,sBAAA,CAAuB,OAAA,GAAU,YAAA;AAAA,MACnC,CAAC,CAAA;AAAA,IACH,CAAA,MAAO;AACL,MAAA,sBAAA,CAAuB,OAAA,GAAU,MAAA;AAAA,IACnC;AAAA,EACF,CAAA;AAEA,EAAA,OAAO;AAAA,IACL,MAAA;AAAA,IACA;AAAA,GACF;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"useRegisterActionStateContext.mjs","sources":["../../../../../../../../../src/integrations/react-hook-form/components/Form/lib/useRegisterActionStateContext.ts"],"sourcesContent":["import { ActionModel } from \"@/components/Action/models/ActionModel\";\nimport { useEffect, useRef } from \"react\";\nimport { isPromise } from \"remeda\";\nimport type { FieldValues, UseFormReturn } from \"react-hook-form\";\n\nconst callAfterSubmitFunction = (result: unknown) => {\n const callFn = (something: unknown) => {\n if (typeof something === \"function\") {\n something();\n }\n };\n\n if (result instanceof Promise) {\n result.then(callFn);\n } else {\n callFn(result);\n }\n};\n\nexport const useRegisterActionStateContext = <T extends FieldValues>(\n form: UseFormReturn<T>,\n) => {\n const action = ActionModel.useNew({});\n const trackedSubmitCount = useRef(0);\n const submitHandlerResultRef = useRef<unknown>(null);\n\n useEffect(() => {\n return form.subscribe({\n formState: {\n errors: true,\n isValid: true,\n },\n callback: ({\n isValid,\n isSubmitted = false,\n isSubmitSuccessful = false,\n submitCount = 0,\n errors,\n }) => {\n if (submitCount === 0 && trackedSubmitCount.current > 0) {\n trackedSubmitCount.current = 0;\n }\n\n if (trackedSubmitCount.current === submitCount) {\n return;\n }\n trackedSubmitCount.current = submitCount;\n\n if (isSubmitted) {\n if (isSubmitSuccessful) {\n void action.state.onSucceeded();\n\n if (isValid) {\n callAfterSubmitFunction(submitHandlerResultRef.current);\n }\n } else {\n const hasFailedWithError =\n isSubmitted && errors && Object.entries(errors).length > 0\n ? errors\n : undefined;\n\n void action.state.onFailed(hasFailedWithError);\n }\n }\n },\n });\n }, [form.subscribe, action.state]);\n\n const registerSubmitResult = (result: unknown) => {\n if (isPromise(result)) {\n void action.state.onAsyncStart();\n result.then((submitResult) => {\n submitHandlerResultRef.current = submitResult;\n });\n } else {\n submitHandlerResultRef.current = result;\n }\n };\n\n return {\n action,\n registerSubmitResult,\n callAfterSubmitFunction,\n } as const;\n};\n"],"names":[],"mappings":";;;;AAKA,MAAM,uBAAA,GAA0B,CAAC,MAAA,KAAoB;AACnD,EAAA,MAAM,MAAA,GAAS,CAAC,SAAA,KAAuB;AACrC,IAAA,IAAI,OAAO,cAAc,UAAA,EAAY;AACnC,MAAA,SAAA,EAAU;AAAA,IACZ;AAAA,EACF,CAAA;AAEA,EAAA,IAAI,kBAAkB,OAAA,EAAS;AAC7B,IAAA,MAAA,CAAO,KAAK,MAAM,C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,MAAA,CAAO,KAAA,CAAM,QAAA,CAAS,kBAAkB,CAAA;AAAA,UAC/C;AAAA,QACF;AAAA,MACF;AAAA,KACD,CAAA;AAAA,EACH,GAAG,CAAC,IAAA,CAAK,SAAA,EAAW,MAAA,CAAO,KAAK,CAAC,CAAA;AAEjC,EAAA,MAAM,oBAAA,GAAuB,CAAC,MAAA,KAAoB;AAChD,IAAA,IAAI,SAAA,CAAU,MAAM,CAAA,EAAG;AACrB,MAAA,KAAK,MAAA,CAAO,MAAM,YAAA,EAAa;AAC/B,MAAA,MAAA,CAAO,IAAA,CAAK,CAAC,YAAA,KAAiB;AAC5B,QAAA,sBAAA,CAAuB,OAAA,GAAU,YAAA;AAAA,MACnC,CAAC,CAAA;AAAA,IACH,CAAA,MAAO;AACL,MAAA,sBAAA,CAAuB,OAAA,GAAU,MAAA;AAAA,IACnC;AAAA,EACF,CAAA;AAEA,EAAA,OAAO;AAAA,IACL,MAAA;AAAA,IACA,oBAAA;AAAA,IACA;AAAA,GACF;AACF;;;;"}
|
package/dist/js/components/src/integrations/react-hook-form/components/ResetButton/ResetButton.mjs
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
/* */
|
|
3
|
+
import { jsx } from 'react/jsx-runtime';
|
|
4
|
+
import { Button } from '../../../../components/Button/Button.mjs';
|
|
5
|
+
import { flowComponent } from '../../../../lib/componentFactory/flowComponent.mjs';
|
|
6
|
+
import { useFormContext } from '../context/formContext.mjs';
|
|
7
|
+
import '../../../../lib/propsContext/propsContext.mjs';
|
|
8
|
+
import '../../../../lib/propsContext/components/PropsContextProvider.mjs';
|
|
9
|
+
import { useMemo } from 'react';
|
|
10
|
+
import 'react-hook-form';
|
|
11
|
+
import 'react-aria';
|
|
12
|
+
import '../../../../views/FieldErrorView.mjs';
|
|
13
|
+
import 'react-hotkeys-hook';
|
|
14
|
+
import 'use-callback-ref';
|
|
15
|
+
import '@react-aria/utils';
|
|
16
|
+
import 'mobx';
|
|
17
|
+
import '../../../../lib/controller/overlay/context.mjs';
|
|
18
|
+
import 'invariant';
|
|
19
|
+
import '../../../../components/Action/context.mjs';
|
|
20
|
+
import '../../../../components/Action/models/ActionStateContext.mjs';
|
|
21
|
+
import 'remeda';
|
|
22
|
+
import '../SubmitButton/SubmitButton.mjs';
|
|
23
|
+
|
|
24
|
+
const ResetButton = flowComponent("ResetButton", (props) => {
|
|
25
|
+
const {
|
|
26
|
+
children,
|
|
27
|
+
ref,
|
|
28
|
+
buttonComponent: ButtonComponent = Button,
|
|
29
|
+
...rest
|
|
30
|
+
} = props;
|
|
31
|
+
const { id: formId = props.form, form, formActionModel } = useFormContext();
|
|
32
|
+
const ButtonViewComponent = useMemo(() => ButtonComponent, [formId]);
|
|
33
|
+
const actionState = formActionModel.state.useValue();
|
|
34
|
+
return /* @__PURE__ */ jsx(
|
|
35
|
+
ButtonViewComponent,
|
|
36
|
+
{
|
|
37
|
+
color: "secondary",
|
|
38
|
+
variant: "soft",
|
|
39
|
+
...rest,
|
|
40
|
+
ref,
|
|
41
|
+
isReadOnly: actionState === "isExecuting" || actionState === "isPending",
|
|
42
|
+
type: "reset",
|
|
43
|
+
onPress: () => form.reset(),
|
|
44
|
+
form: formId,
|
|
45
|
+
children
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
export { ResetButton, ResetButton as default };
|
|
51
|
+
//# sourceMappingURL=ResetButton.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResetButton.mjs","sources":["../../../../../../../../src/integrations/react-hook-form/components/ResetButton/ResetButton.tsx"],"sourcesContent":["import { Button, type ButtonProps } from \"@/components/Button\";\nimport { flowComponent } from \"@/lib/componentFactory/flowComponent\";\nimport { useFormContext } from \"@/integrations/react-hook-form\";\nimport { type FC, useMemo } from \"react\";\n\nexport type ResetButtonProps = Omit<\n ButtonProps,\n \"isFailed\" | \"isSucceeded\" | \"isPending\" | \"isReadOnly\" | \"type\"\n> & {\n buttonComponent?: FC<Omit<ButtonProps, \"ref\">>;\n};\n\nexport const ResetButton = flowComponent(\"ResetButton\", (props) => {\n const {\n children,\n ref,\n buttonComponent: ButtonComponent = Button,\n ...rest\n } = props;\n\n const { id: formId = props.form, form, formActionModel } = useFormContext();\n\n const ButtonViewComponent = useMemo(() => ButtonComponent, [formId]);\n const actionState = formActionModel.state.useValue();\n\n return (\n <ButtonViewComponent\n color=\"secondary\"\n variant=\"soft\"\n {...rest}\n ref={ref}\n isReadOnly={actionState === \"isExecuting\" || actionState === \"isPending\"}\n type=\"reset\"\n onPress={() => form.reset()}\n form={formId}\n >\n {children}\n </ButtonViewComponent>\n );\n});\n\nexport default ResetButton;\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAYO,MAAM,WAAA,GAAc,aAAA,CAAc,aAAA,EAAe,CAAC,KAAA,KAAU;AACjE,EAAA,MAAM;AAAA,IACJ,QAAA;AAAA,IACA,GAAA;AAAA,IACA,iBAAiB,eAAA,GAAkB,MAAA;AAAA,IACnC,GAAG;AAAA,GACL,GAAI,KAAA;AAEJ,EAAA,MAAM,EAAE,IAAI,MAAA,GAAS,KAAA,CAAM,MAAM,IAAA,EAAM,eAAA,KAAoB,cAAA,EAAe;AAE1E,EAAA,MAAM,sBAAsB,OAAA,CAAQ,MAAM,eAAA,EAAiB,CAAC,MAAM,CAAC,CAAA;AACnE,EAAA,MAAM,WAAA,GAAc,eAAA,CAAgB,KAAA,CAAM,QAAA,EAAS;AAEnD,EAAA,uBACE,GAAA;AAAA,IAAC,mBAAA;AAAA,IAAA;AAAA,MACC,KAAA,EAAM,WAAA;AAAA,MACN,OAAA,EAAQ,MAAA;AAAA,MACP,GAAG,IAAA;AAAA,MACJ,GAAA;AAAA,MACA,UAAA,EAAY,WAAA,KAAgB,aAAA,IAAiB,WAAA,KAAgB,WAAA;AAAA,MAC7D,IAAA,EAAK,OAAA;AAAA,MACL,OAAA,EAAS,MAAM,IAAA,CAAK,KAAA,EAAM;AAAA,MAC1B,IAAA,EAAM,MAAA;AAAA,MAEL;AAAA;AAAA,GACH;AAEJ,CAAC;;;;"}
|
package/dist/js/components/src/integrations/react-hook-form/components/SubmitButton/SubmitButton.mjs
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
/* */
|
|
3
|
+
import { jsx } from 'react/jsx-runtime';
|
|
4
|
+
import { Button } from '../../../../components/Button/Button.mjs';
|
|
5
|
+
import { flowComponent } from '../../../../lib/componentFactory/flowComponent.mjs';
|
|
6
|
+
import { useFormContext } from '../context/formContext.mjs';
|
|
7
|
+
import '../../../../lib/propsContext/propsContext.mjs';
|
|
8
|
+
import '../../../../lib/propsContext/components/PropsContextProvider.mjs';
|
|
9
|
+
import { useMemo } from 'react';
|
|
10
|
+
import 'react-hook-form';
|
|
11
|
+
import 'react-aria';
|
|
12
|
+
import '../../../../views/FieldErrorView.mjs';
|
|
13
|
+
import 'react-hotkeys-hook';
|
|
14
|
+
import { useMergeRefs } from 'use-callback-ref';
|
|
15
|
+
import { useObjectRef } from '@react-aria/utils';
|
|
16
|
+
import 'mobx';
|
|
17
|
+
import '../../../../lib/controller/overlay/context.mjs';
|
|
18
|
+
import 'invariant';
|
|
19
|
+
import '../../../../components/Action/context.mjs';
|
|
20
|
+
import '../../../../components/Action/models/ActionStateContext.mjs';
|
|
21
|
+
import 'remeda';
|
|
22
|
+
import '../ResetButton/ResetButton.mjs';
|
|
23
|
+
import { Action } from '../../../../components/Action/Action.mjs';
|
|
24
|
+
import '@react-aria/live-announcer';
|
|
25
|
+
|
|
26
|
+
const SubmitButton = flowComponent("SubmitButton", (props) => {
|
|
27
|
+
const {
|
|
28
|
+
children,
|
|
29
|
+
ref,
|
|
30
|
+
buttonComponent: ButtonComponent = Button,
|
|
31
|
+
...rest
|
|
32
|
+
} = props;
|
|
33
|
+
const {
|
|
34
|
+
id: formId = props.form,
|
|
35
|
+
formActionModel,
|
|
36
|
+
submitButtonRef: submitButtonRefFromFormContext
|
|
37
|
+
} = useFormContext();
|
|
38
|
+
const ButtonViewComponent = useMemo(() => ButtonComponent, [formId]);
|
|
39
|
+
const submitButtonRefFromProps = useObjectRef(ref);
|
|
40
|
+
const submitButtonRef = useMergeRefs([
|
|
41
|
+
submitButtonRefFromProps,
|
|
42
|
+
submitButtonRefFromFormContext
|
|
43
|
+
]);
|
|
44
|
+
return /* @__PURE__ */ jsx(Action, { actionModel: formActionModel, children: /* @__PURE__ */ jsx(
|
|
45
|
+
ButtonViewComponent,
|
|
46
|
+
{
|
|
47
|
+
...rest,
|
|
48
|
+
ref: submitButtonRef,
|
|
49
|
+
type: "submit",
|
|
50
|
+
form: formId,
|
|
51
|
+
children
|
|
52
|
+
}
|
|
53
|
+
) });
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
export { SubmitButton, SubmitButton as default };
|
|
57
|
+
//# sourceMappingURL=SubmitButton.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SubmitButton.mjs","sources":["../../../../../../../../src/integrations/react-hook-form/components/SubmitButton/SubmitButton.tsx"],"sourcesContent":["import { Button, type ButtonProps } from \"@/components/Button\";\nimport { flowComponent } from \"@/lib/componentFactory/flowComponent\";\nimport { useFormContext } from \"@/integrations/react-hook-form\";\nimport { Action } from \"@/components/Action\";\nimport { useObjectRef } from \"@react-aria/utils\";\nimport { useMergeRefs } from \"use-callback-ref\";\nimport { type FC, useMemo } from \"react\";\n\nexport type SubmitButtonProps = Omit<\n ButtonProps,\n \"isFailed\" | \"isSucceeded\" | \"isPending\" | \"isReadOnly\" | \"type\"\n> & {\n buttonComponent?: FC<Omit<ButtonProps, \"ref\">>;\n};\n\nexport const SubmitButton = flowComponent(\"SubmitButton\", (props) => {\n const {\n children,\n ref,\n buttonComponent: ButtonComponent = Button,\n ...rest\n } = props;\n\n const {\n id: formId = props.form,\n formActionModel,\n submitButtonRef: submitButtonRefFromFormContext,\n } = useFormContext();\n const ButtonViewComponent = useMemo(() => ButtonComponent, [formId]);\n\n const submitButtonRefFromProps = useObjectRef(ref);\n const submitButtonRef = useMergeRefs([\n submitButtonRefFromProps,\n submitButtonRefFromFormContext,\n ]);\n\n return (\n <Action actionModel={formActionModel}>\n <ButtonViewComponent\n {...rest}\n ref={submitButtonRef}\n type=\"submit\"\n form={formId}\n >\n {children}\n </ButtonViewComponent>\n </Action>\n );\n});\n\nexport default SubmitButton;\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAeO,MAAM,YAAA,GAAe,aAAA,CAAc,cAAA,EAAgB,CAAC,KAAA,KAAU;AACnE,EAAA,MAAM;AAAA,IACJ,QAAA;AAAA,IACA,GAAA;AAAA,IACA,iBAAiB,eAAA,GAAkB,MAAA;AAAA,IACnC,GAAG;AAAA,GACL,GAAI,KAAA;AAEJ,EAAA,MAAM;AAAA,IACJ,EAAA,EAAI,SAAS,KAAA,CAAM,IAAA;AAAA,IACnB,eAAA;AAAA,IACA,eAAA,EAAiB;AAAA,MACf,cAAA,EAAe;AACnB,EAAA,MAAM,sBAAsB,OAAA,CAAQ,MAAM,eAAA,EAAiB,CAAC,MAAM,CAAC,CAAA;AAEnE,EAAA,MAAM,wBAAA,GAA2B,aAAa,GAAG,CAAA;AACjD,EAAA,MAAM,kBAAkB,YAAA,CAAa;AAAA,IACnC,wBAAA;AAAA,IACA;AAAA,GACD,CAAA;AAED,EAAA,uBACE,GAAA,CAAC,MAAA,EAAA,EAAO,WAAA,EAAa,eAAA,EACnB,QAAA,kBAAA,GAAA;AAAA,IAAC,mBAAA;AAAA,IAAA;AAAA,MACE,GAAG,IAAA;AAAA,MACJ,GAAA,EAAK,eAAA;AAAA,MACL,IAAA,EAAK,QAAA;AAAA,MACL,IAAA,EAAM,MAAA;AAAA,MAEL;AAAA;AAAA,GACH,EACF,CAAA;AAEJ,CAAC;;;;"}
|