@mittwald/flow-react-components 0.2.0-alpha.523 → 0.2.0-alpha.525
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 +10 -0
- package/dist/assets/doc-properties.json +291 -253
- package/dist/css/all.css +1 -1
- package/dist/js/components/src/components/Autocomplete/Autocomplete.mjs +48 -36
- package/dist/js/components/src/components/Autocomplete/Autocomplete.mjs.map +1 -1
- package/dist/js/components/src/components/Checkbox/Checkbox.mjs +25 -7
- package/dist/js/components/src/components/Checkbox/Checkbox.mjs.map +1 -1
- package/dist/js/components/src/components/Checkbox/Checkbox.module.scss.mjs +3 -1
- package/dist/js/components/src/components/Checkbox/Checkbox.module.scss.mjs.map +1 -1
- package/dist/js/components/src/components/CheckboxButton/CheckboxButton.mjs +28 -6
- package/dist/js/components/src/components/CheckboxButton/CheckboxButton.mjs.map +1 -1
- package/dist/js/components/src/components/CheckboxButton/CheckboxButton.module.scss.mjs +6 -4
- package/dist/js/components/src/components/CheckboxButton/CheckboxButton.module.scss.mjs.map +1 -1
- package/dist/js/components/src/components/CheckboxGroup/CheckboxGroup.mjs +22 -26
- package/dist/js/components/src/components/CheckboxGroup/CheckboxGroup.mjs.map +1 -1
- package/dist/js/components/src/components/ComboBox/ComboBox.mjs +31 -27
- package/dist/js/components/src/components/ComboBox/ComboBox.mjs.map +1 -1
- package/dist/js/components/src/components/DatePicker/DatePicker.mjs +8 -18
- package/dist/js/components/src/components/DatePicker/DatePicker.mjs.map +1 -1
- package/dist/js/components/src/components/DateRangePicker/DateRangePicker.mjs +7 -19
- package/dist/js/components/src/components/DateRangePicker/DateRangePicker.mjs.map +1 -1
- package/dist/js/components/src/components/FieldError/FieldError.mjs +36 -5
- package/dist/js/components/src/components/FieldError/FieldError.mjs.map +1 -1
- package/dist/js/components/src/components/FileDropZone/FileDropZone.mjs +22 -11
- package/dist/js/components/src/components/FileDropZone/FileDropZone.mjs.map +1 -1
- package/dist/js/components/src/components/FileField/FileField.mjs +33 -31
- package/dist/js/components/src/components/FileField/FileField.mjs.map +1 -1
- package/dist/js/components/src/components/FormField/FormField.module.scss.mjs +1 -3
- package/dist/js/components/src/components/FormField/FormField.module.scss.mjs.map +1 -1
- package/dist/js/components/src/components/NumberField/NumberField.mjs +9 -18
- package/dist/js/components/src/components/NumberField/NumberField.mjs.map +1 -1
- package/dist/js/components/src/components/PasswordCreationField/PasswordCreationField.mjs +85 -79
- package/dist/js/components/src/components/PasswordCreationField/PasswordCreationField.mjs.map +1 -1
- package/dist/js/components/src/components/PasswordCreationField/lib/generateValidationTranslation.mjs +1 -0
- package/dist/js/components/src/components/PasswordCreationField/lib/generateValidationTranslation.mjs.map +1 -1
- package/dist/js/components/src/components/PasswordCreationField/lib/getStateFromLatestPolicyValidationResult.mjs +1 -0
- package/dist/js/components/src/components/PasswordCreationField/lib/getStateFromLatestPolicyValidationResult.mjs.map +1 -1
- package/dist/js/components/src/components/PasswordCreationField/worker/generatePassword.mjs +1 -0
- package/dist/js/components/src/components/PasswordCreationField/worker/generatePassword.mjs.map +1 -1
- package/dist/js/components/src/components/RadioGroup/RadioGroup.mjs +36 -34
- package/dist/js/components/src/components/RadioGroup/RadioGroup.mjs.map +1 -1
- package/dist/js/components/src/components/SearchField/SearchField.mjs +12 -17
- package/dist/js/components/src/components/SearchField/SearchField.mjs.map +1 -1
- package/dist/js/components/src/components/SegmentedControl/SegmentedControl.mjs +25 -23
- package/dist/js/components/src/components/SegmentedControl/SegmentedControl.mjs.map +1 -1
- package/dist/js/components/src/components/Select/Select.mjs +30 -30
- package/dist/js/components/src/components/Select/Select.mjs.map +1 -1
- package/dist/js/components/src/components/Slider/Slider.mjs +10 -5
- package/dist/js/components/src/components/Slider/Slider.mjs.map +1 -1
- package/dist/js/components/src/components/Switch/Switch.mjs +22 -31
- package/dist/js/components/src/components/Switch/Switch.mjs.map +1 -1
- package/dist/js/components/src/components/Switch/Switch.module.scss.mjs +2 -4
- package/dist/js/components/src/components/Switch/Switch.module.scss.mjs.map +1 -1
- package/dist/js/components/src/components/TextArea/TextArea.mjs +16 -1
- package/dist/js/components/src/components/TextArea/TextArea.mjs.map +1 -1
- package/dist/js/components/src/components/TextField/TextField.mjs +14 -1
- package/dist/js/components/src/components/TextField/TextField.mjs.map +1 -1
- package/dist/js/components/src/components/TextFieldBase/TextFieldBase.mjs +13 -22
- package/dist/js/components/src/components/TextFieldBase/TextFieldBase.mjs.map +1 -1
- package/dist/js/components/src/components/TimeField/TimeField.mjs +8 -32
- package/dist/js/components/src/components/TimeField/TimeField.mjs.map +1 -1
- package/dist/js/components/src/integrations/@mittwald/password-tools-js/generatePasswordCreationFieldValidation.mjs +19 -13
- package/dist/js/components/src/integrations/@mittwald/password-tools-js/generatePasswordCreationFieldValidation.mjs.map +1 -1
- package/dist/js/components/src/integrations/react-hook-form/components/Field/Field.mjs +29 -14
- package/dist/js/components/src/integrations/react-hook-form/components/Field/Field.mjs.map +1 -1
- package/dist/js/components/src/lib/hooks/useFieldComponent.mjs +36 -0
- package/dist/js/components/src/lib/hooks/useFieldComponent.mjs.map +1 -0
- package/dist/js/components/src/lib/hooks/useFieldError.mjs +43 -0
- package/dist/js/components/src/lib/hooks/useFieldError.mjs.map +1 -0
- package/dist/js/components/src/lib/hooks/useManagedValue.mjs +7 -3
- package/dist/js/components/src/lib/hooks/useManagedValue.mjs.map +1 -1
- package/dist/types/components/Autocomplete/Autocomplete.d.ts +1 -0
- package/dist/types/components/Autocomplete/Autocomplete.d.ts.map +1 -1
- package/dist/types/components/Checkbox/Checkbox.d.ts +3 -2
- package/dist/types/components/Checkbox/Checkbox.d.ts.map +1 -1
- package/dist/types/components/CheckboxButton/CheckboxButton.d.ts +2 -2
- package/dist/types/components/CheckboxButton/CheckboxButton.d.ts.map +1 -1
- package/dist/types/components/CheckboxGroup/CheckboxGroup.d.ts.map +1 -1
- package/dist/types/components/ComboBox/ComboBox.d.ts.map +1 -1
- package/dist/types/components/ComboBox/stories/Default.stories.d.ts.map +1 -1
- package/dist/types/components/DatePicker/DatePicker.d.ts +1 -3
- package/dist/types/components/DatePicker/DatePicker.d.ts.map +1 -1
- package/dist/types/components/DatePicker/stories/Default.stories.d.ts.map +1 -1
- package/dist/types/components/DateRangePicker/DateRangePicker.d.ts +1 -3
- package/dist/types/components/DateRangePicker/DateRangePicker.d.ts.map +1 -1
- package/dist/types/components/DateRangePicker/stories/Default.stories.d.ts.map +1 -1
- package/dist/types/components/FieldError/FieldError.d.ts +2 -2
- package/dist/types/components/FieldError/FieldError.d.ts.map +1 -1
- package/dist/types/components/FileDropZone/FileDropZone.d.ts.map +1 -1
- package/dist/types/components/FileDropZone/stories/Default.stories.d.ts.map +1 -1
- package/dist/types/components/FileField/FileField.d.ts.map +1 -1
- package/dist/types/components/NumberField/NumberField.d.ts +2 -2
- package/dist/types/components/NumberField/NumberField.d.ts.map +1 -1
- package/dist/types/components/PasswordCreationField/PasswordCreationField.d.ts.map +1 -1
- package/dist/types/components/RadioGroup/RadioGroup.d.ts.map +1 -1
- package/dist/types/components/SearchField/SearchField.d.ts.map +1 -1
- package/dist/types/components/SegmentedControl/SegmentedControl.d.ts.map +1 -1
- package/dist/types/components/Select/Select.d.ts.map +1 -1
- package/dist/types/components/Slider/Slider.d.ts +1 -0
- package/dist/types/components/Slider/Slider.d.ts.map +1 -1
- package/dist/types/components/Switch/Switch.d.ts.map +1 -1
- package/dist/types/components/TextArea/TextArea.d.ts +1 -1
- package/dist/types/components/TextArea/TextArea.d.ts.map +1 -1
- package/dist/types/components/TextField/TextField.d.ts +1 -1
- package/dist/types/components/TextField/TextField.d.ts.map +1 -1
- package/dist/types/components/TextFieldBase/TextFieldBase.d.ts +2 -1
- package/dist/types/components/TextFieldBase/TextFieldBase.d.ts.map +1 -1
- package/dist/types/components/TimeField/TimeField.d.ts +2 -4
- package/dist/types/components/TimeField/TimeField.d.ts.map +1 -1
- package/dist/types/integrations/@mittwald/password-tools-js/generatePasswordCreationFieldValidation.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 +2 -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 +2 -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 +9 -0
- package/dist/types/integrations/react-hook-form/components/Field/stories/CheckboxButton.stories.d.ts.map +1 -0
- package/dist/types/integrations/react-hook-form/components/Field/stories/CheckboxGroup.stories.d.ts +2 -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 +2 -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 +2 -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 +2 -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 +2 -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 +2 -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 +2 -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 +2 -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 +2 -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 +2 -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 +2 -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 +2 -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 +2 -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 +2 -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 +2 -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 +2 -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 +2 -1
- package/dist/types/integrations/react-hook-form/components/Field/stories/TimeField.stories.d.ts.map +1 -1
- package/dist/types/lib/hooks/useFieldComponent.d.ts +19 -0
- package/dist/types/lib/hooks/useFieldComponent.d.ts.map +1 -0
- package/dist/types/lib/hooks/useFieldError.d.ts +10 -0
- package/dist/types/lib/hooks/useFieldError.d.ts.map +1 -0
- package/dist/types/lib/hooks/useManagedValue.d.ts +9 -7
- package/dist/types/lib/hooks/useManagedValue.d.ts.map +1 -1
- package/package.json +4 -4
- package/dist/js/components/src/views/FieldErrorView.mjs +0 -15
- package/dist/js/components/src/views/FieldErrorView.mjs.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
/* */
|
|
3
|
-
import {
|
|
3
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
4
4
|
import { useRef } from 'react';
|
|
5
5
|
import '../../lib/propsContext/propsContext.mjs';
|
|
6
6
|
import { PropsContextProvider } from '../../lib/propsContext/components/PropsContextProvider.mjs';
|
|
@@ -15,9 +15,10 @@ import { Text } from '../Text/Text.mjs';
|
|
|
15
15
|
import styles from './Autocomplete.module.scss.mjs';
|
|
16
16
|
import { useLocalizedStringFormatter, useFocusWithin, UNSAFE_PortalProvider } from 'react-aria';
|
|
17
17
|
import { emitElementValueChange } from '../../lib/react/emitElementValueChange.mjs';
|
|
18
|
+
import { useFieldComponent } from '../../lib/hooks/useFieldComponent.mjs';
|
|
18
19
|
|
|
19
20
|
const Autocomplete = flowComponent("Autocomplete", (props) => {
|
|
20
|
-
const { children, ...rest } = props;
|
|
21
|
+
const { children, isInvalid, ...rest } = props;
|
|
21
22
|
const { contains } = Aria.useFilter({ sensitivity: "base" });
|
|
22
23
|
const stringFormatter = useLocalizedStringFormatter(locales);
|
|
23
24
|
const container = useRef(null);
|
|
@@ -34,19 +35,10 @@ const Autocomplete = flowComponent("Autocomplete", (props) => {
|
|
|
34
35
|
e.preventDefault();
|
|
35
36
|
}
|
|
36
37
|
},
|
|
38
|
+
isInvalid,
|
|
37
39
|
ref: triggerRef
|
|
38
40
|
};
|
|
39
41
|
const renderEmptyState = () => /* @__PURE__ */ jsx(Text, { className: styles.empty, children: stringFormatter.format("autocomplete.empty") });
|
|
40
|
-
const propsContext = {
|
|
41
|
-
SearchField: inputProps,
|
|
42
|
-
TextField: inputProps,
|
|
43
|
-
Option: {
|
|
44
|
-
tunnelId: "options"
|
|
45
|
-
},
|
|
46
|
-
Popover: {
|
|
47
|
-
className: styles.popover
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
42
|
const handleOnInputChange = (value) => {
|
|
51
43
|
if (!value) {
|
|
52
44
|
controller.close();
|
|
@@ -61,30 +53,50 @@ const Autocomplete = flowComponent("Autocomplete", (props) => {
|
|
|
61
53
|
}
|
|
62
54
|
controller.close();
|
|
63
55
|
};
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
56
|
+
const {
|
|
57
|
+
FieldErrorView,
|
|
58
|
+
FieldErrorResetContext,
|
|
59
|
+
fieldPropsContext,
|
|
60
|
+
fieldProps
|
|
61
|
+
} = useFieldComponent(props);
|
|
62
|
+
const propsContext = {
|
|
63
|
+
SearchField: inputProps,
|
|
64
|
+
TextField: inputProps,
|
|
65
|
+
Option: {
|
|
66
|
+
tunnelId: "options"
|
|
67
|
+
},
|
|
68
|
+
Popover: {
|
|
69
|
+
className: styles.popover
|
|
70
|
+
},
|
|
71
|
+
...fieldPropsContext
|
|
72
|
+
};
|
|
73
|
+
return /* @__PURE__ */ jsxs("div", { ...fieldProps, children: [
|
|
74
|
+
/* @__PURE__ */ jsx(FieldErrorResetContext, { children: /* @__PURE__ */ jsx(PropsContextProvider, { props: propsContext, children: /* @__PURE__ */ jsx("div", { ...focusWithin.focusWithinProps, ref: container, children: /* @__PURE__ */ jsx(UNSAFE_PortalProvider, { getContainer: () => container.current, children: /* @__PURE__ */ jsxs(
|
|
75
|
+
Aria.Autocomplete,
|
|
76
|
+
{
|
|
77
|
+
onInputChange: handleOnInputChange,
|
|
78
|
+
filter: contains,
|
|
79
|
+
disableAutoFocusFirst: true,
|
|
80
|
+
...rest,
|
|
81
|
+
children: [
|
|
82
|
+
children,
|
|
83
|
+
/* @__PURE__ */ jsx(
|
|
84
|
+
Options,
|
|
85
|
+
{
|
|
86
|
+
onAction: handleOptionAction,
|
|
87
|
+
triggerRef,
|
|
88
|
+
controller,
|
|
89
|
+
renderEmptyState,
|
|
90
|
+
isNonModal: true,
|
|
91
|
+
placement: "bottom start",
|
|
92
|
+
children: /* @__PURE__ */ jsx(TunnelExit, { id: "options" })
|
|
93
|
+
}
|
|
94
|
+
)
|
|
95
|
+
]
|
|
96
|
+
}
|
|
97
|
+
) }) }) }) }),
|
|
98
|
+
/* @__PURE__ */ jsx(FieldErrorView, {})
|
|
99
|
+
] });
|
|
88
100
|
});
|
|
89
101
|
|
|
90
102
|
export { Autocomplete, Autocomplete as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Autocomplete.mjs","sources":["../../../../../../src/components/Autocomplete/Autocomplete.tsx"],"sourcesContent":["import { useRef, type PropsWithChildren } from \"react\";\nimport type { PropsWithClassName } from \"@/lib/types/props\";\nimport { type PropsContext, PropsContextProvider } from \"@/lib/propsContext\";\nimport * as Aria from \"react-aria-components\";\nimport { useOverlayController } from \"@/lib/controller\";\nimport {\n flowComponent,\n type FlowComponentProps,\n} from \"@/lib/componentFactory/flowComponent\";\nimport type { SearchFieldProps } from \"@/components/SearchField\";\nimport type { TextFieldProps } from \"@/components/TextField\";\nimport Options from \"@/components/Options\";\nimport { TunnelExit } from \"@mittwald/react-tunnel\";\nimport locales from \"./locales/*.locale.json\";\nimport Text from \"@/components/Text\";\nimport styles from \"./Autocomplete.module.scss\";\nimport {\n UNSAFE_PortalProvider,\n useFocusWithin,\n useLocalizedStringFormatter,\n} from \"react-aria\";\nimport { emitElementValueChange } from \"@/lib/react/emitElementValueChange\";\nexport interface AutocompleteProps\n extends PropsWithChildren,\n PropsWithClassName,\n FlowComponentProps,\n Omit<Aria.AutocompleteProps, \"children\" | \"onInputChange\" | \"inputValue\"> {}\n\n/** @flr-generate all */\nexport const Autocomplete = flowComponent(\"Autocomplete\", (props) => {\n const { children, ...rest } = props;\n\n const { contains } = Aria.useFilter({ sensitivity: \"base\" });\n const stringFormatter = useLocalizedStringFormatter(locales);\n const container = useRef(null);\n const triggerRef = useRef<HTMLInputElement>(null);\n\n const controller = useOverlayController(\"Popover\", {\n reuseControllerFromContext: false,\n });\n\n const focusWithin = useFocusWithin({\n onBlurWithin: controller.close,\n });\n\n const inputProps: SearchFieldProps & TextFieldProps = {\n onKeyDown: (e) => {\n if (e.key === \"Enter\" && controller.isOpen) {\n e.preventDefault();\n }\n },\n ref: triggerRef,\n };\n\n const renderEmptyState = () => (\n <Text className={styles.empty}>\n {stringFormatter.format(\"autocomplete.empty\")}\n </Text>\n );\n\n const
|
|
1
|
+
{"version":3,"file":"Autocomplete.mjs","sources":["../../../../../../src/components/Autocomplete/Autocomplete.tsx"],"sourcesContent":["import { useRef, type PropsWithChildren } from \"react\";\nimport type { PropsWithClassName } from \"@/lib/types/props\";\nimport { type PropsContext, PropsContextProvider } from \"@/lib/propsContext\";\nimport * as Aria from \"react-aria-components\";\nimport { useOverlayController } from \"@/lib/controller\";\nimport {\n flowComponent,\n type FlowComponentProps,\n} from \"@/lib/componentFactory/flowComponent\";\nimport type { SearchFieldProps } from \"@/components/SearchField\";\nimport type { TextFieldProps } from \"@/components/TextField\";\nimport Options from \"@/components/Options\";\nimport { TunnelExit } from \"@mittwald/react-tunnel\";\nimport locales from \"./locales/*.locale.json\";\nimport Text from \"@/components/Text\";\nimport styles from \"./Autocomplete.module.scss\";\nimport {\n UNSAFE_PortalProvider,\n useFocusWithin,\n useLocalizedStringFormatter,\n} from \"react-aria\";\nimport { emitElementValueChange } from \"@/lib/react/emitElementValueChange\";\nimport { useFieldComponent } from \"@/lib/hooks/useFieldComponent\";\nexport interface AutocompleteProps\n extends PropsWithChildren,\n PropsWithClassName,\n FlowComponentProps,\n Omit<Aria.AutocompleteProps, \"children\" | \"onInputChange\" | \"inputValue\"> {\n isInvalid?: boolean;\n}\n\n/** @flr-generate all */\nexport const Autocomplete = flowComponent(\"Autocomplete\", (props) => {\n const { children, isInvalid, ...rest } = props;\n\n const { contains } = Aria.useFilter({ sensitivity: \"base\" });\n const stringFormatter = useLocalizedStringFormatter(locales);\n const container = useRef(null);\n const triggerRef = useRef<HTMLInputElement>(null);\n\n const controller = useOverlayController(\"Popover\", {\n reuseControllerFromContext: false,\n });\n\n const focusWithin = useFocusWithin({\n onBlurWithin: controller.close,\n });\n\n const inputProps: SearchFieldProps & TextFieldProps = {\n onKeyDown: (e) => {\n if (e.key === \"Enter\" && controller.isOpen) {\n e.preventDefault();\n }\n },\n isInvalid,\n ref: triggerRef,\n };\n\n const renderEmptyState = () => (\n <Text className={styles.empty}>\n {stringFormatter.format(\"autocomplete.empty\")}\n </Text>\n );\n\n const handleOnInputChange = (value: string) => {\n if (!value) {\n controller.close();\n } else if (!controller.isOpen) {\n controller.open();\n }\n };\n\n const handleOptionAction = (key: Aria.Key) => {\n const inputElement = triggerRef.current;\n if (inputElement) {\n // Set value on input element and trigger change event\n emitElementValueChange(inputElement, String(key));\n }\n controller.close();\n };\n\n const {\n FieldErrorView,\n FieldErrorResetContext,\n fieldPropsContext,\n fieldProps,\n } = useFieldComponent(props);\n\n const propsContext: PropsContext = {\n SearchField: inputProps,\n TextField: inputProps,\n Option: {\n tunnelId: \"options\",\n },\n Popover: {\n className: styles.popover,\n },\n ...fieldPropsContext,\n };\n\n return (\n <div {...fieldProps}>\n <FieldErrorResetContext>\n <PropsContextProvider props={propsContext}>\n <div {...focusWithin.focusWithinProps} ref={container}>\n <UNSAFE_PortalProvider getContainer={() => container.current}>\n <Aria.Autocomplete\n onInputChange={handleOnInputChange}\n filter={contains}\n disableAutoFocusFirst\n {...rest}\n >\n {children}\n <Options\n onAction={handleOptionAction}\n triggerRef={triggerRef}\n controller={controller}\n renderEmptyState={renderEmptyState}\n isNonModal\n placement=\"bottom start\"\n >\n <TunnelExit id=\"options\" />\n </Options>\n </Aria.Autocomplete>\n </UNSAFE_PortalProvider>\n </div>\n </PropsContextProvider>\n </FieldErrorResetContext>\n <FieldErrorView />\n </div>\n );\n});\n\nexport default Autocomplete;\n"],"names":[],"mappings":"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"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
/* */
|
|
3
|
-
import {
|
|
3
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
4
4
|
import 'react';
|
|
5
5
|
import '@tabler/icons-react';
|
|
6
6
|
import '../Icon/Icon.mjs';
|
|
@@ -12,14 +12,32 @@ import { flowComponent } from '../../lib/componentFactory/flowComponent.mjs';
|
|
|
12
12
|
import clsx from 'clsx';
|
|
13
13
|
import * as Aria from 'react-aria-components';
|
|
14
14
|
import styles from './Checkbox.module.scss.mjs';
|
|
15
|
+
import { useFieldComponent } from '../../lib/hooks/useFieldComponent.mjs';
|
|
16
|
+
import '../../lib/propsContext/propsContext.mjs';
|
|
17
|
+
import { PropsContextProvider } from '../../lib/propsContext/components/PropsContextProvider.mjs';
|
|
18
|
+
import { useObjectRef } from '@react-aria/utils';
|
|
19
|
+
import { useMakeFocusable } from '../../lib/hooks/dom/useMakeFocusable.mjs';
|
|
15
20
|
|
|
16
21
|
const Checkbox = flowComponent("Checkbox", (props) => {
|
|
17
|
-
const { children, className, ref, ...rest } = props;
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
const { children, className, ref, inputClassName, ...rest } = props;
|
|
23
|
+
const { FieldErrorView, fieldPropsContext, fieldProps } = useFieldComponent(props);
|
|
24
|
+
const localCheckboxRef = useObjectRef(ref);
|
|
25
|
+
useMakeFocusable(localCheckboxRef);
|
|
26
|
+
return /* @__PURE__ */ jsxs(
|
|
27
|
+
"div",
|
|
28
|
+
{
|
|
29
|
+
...fieldProps,
|
|
30
|
+
className: clsx(styles.checkbox, className, fieldProps.className),
|
|
31
|
+
ref: localCheckboxRef,
|
|
32
|
+
children: [
|
|
33
|
+
/* @__PURE__ */ jsx(Aria.Checkbox, { ...rest, className: clsx(inputClassName, styles.input), children: ({ isSelected, isIndeterminate }) => /* @__PURE__ */ jsxs(PropsContextProvider, { props: fieldPropsContext, children: [
|
|
34
|
+
isSelected ? /* @__PURE__ */ jsx(IconCheckboxChecked, { className: styles.icon }) : isIndeterminate ? /* @__PURE__ */ jsx(IconCheckboxIndeterminate, { className: styles.icon }) : /* @__PURE__ */ jsx(IconCheckboxEmpty, { className: styles.icon }),
|
|
35
|
+
children
|
|
36
|
+
] }) }),
|
|
37
|
+
/* @__PURE__ */ jsx(FieldErrorView, {})
|
|
38
|
+
]
|
|
39
|
+
}
|
|
40
|
+
);
|
|
23
41
|
});
|
|
24
42
|
|
|
25
43
|
export { Checkbox, Checkbox as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkbox.mjs","sources":["../../../../../../src/components/Checkbox/Checkbox.tsx"],"sourcesContent":["import {\n IconCheckboxChecked,\n IconCheckboxEmpty,\n IconCheckboxIndeterminate,\n} from \"@/components/Icon/components/icons\";\nimport type { FlowComponentProps } from \"@/lib/componentFactory/flowComponent\";\nimport { flowComponent } from \"@/lib/componentFactory/flowComponent\";\nimport clsx from \"clsx\";\nimport type { PropsWithChildren } from \"react\";\nimport * as Aria from \"react-aria-components\";\nimport styles from \"./Checkbox.module.scss\";\n\nexport interface CheckboxProps\n extends PropsWithChildren<Omit<Aria.CheckboxProps, \"children\">>,\n FlowComponentProps
|
|
1
|
+
{"version":3,"file":"Checkbox.mjs","sources":["../../../../../../src/components/Checkbox/Checkbox.tsx"],"sourcesContent":["import {\n IconCheckboxChecked,\n IconCheckboxEmpty,\n IconCheckboxIndeterminate,\n} from \"@/components/Icon/components/icons\";\nimport type { FlowComponentProps } from \"@/lib/componentFactory/flowComponent\";\nimport { flowComponent } from \"@/lib/componentFactory/flowComponent\";\nimport clsx from \"clsx\";\nimport type { PropsWithChildren } from \"react\";\nimport * as Aria from \"react-aria-components\";\nimport styles from \"./Checkbox.module.scss\";\nimport { useFieldComponent } from \"@/lib/hooks/useFieldComponent\";\nimport { PropsContextProvider } from \"@/lib/propsContext\";\nimport { useObjectRef } from \"@react-aria/utils\";\nimport { useMakeFocusable } from \"@/lib/hooks/dom/useMakeFocusable\";\n\nexport interface CheckboxProps\n extends PropsWithChildren<Omit<Aria.CheckboxProps, \"children\">>,\n FlowComponentProps {\n inputClassName?: string;\n}\n\n/** @flr-generate all */\nexport const Checkbox = flowComponent(\"Checkbox\", (props) => {\n const { children, className, ref, inputClassName, ...rest } = props;\n\n const { FieldErrorView, fieldPropsContext, fieldProps } =\n useFieldComponent(props);\n\n const localCheckboxRef = useObjectRef(ref);\n useMakeFocusable(localCheckboxRef);\n\n return (\n <div\n {...fieldProps}\n className={clsx(styles.checkbox, className, fieldProps.className)}\n ref={localCheckboxRef}\n >\n <Aria.Checkbox {...rest} className={clsx(inputClassName, styles.input)}>\n {({ isSelected, isIndeterminate }) => (\n <PropsContextProvider props={fieldPropsContext}>\n {isSelected ? (\n <IconCheckboxChecked className={styles.icon} />\n ) : isIndeterminate ? (\n <IconCheckboxIndeterminate className={styles.icon} />\n ) : (\n <IconCheckboxEmpty className={styles.icon} />\n )}\n {children}\n </PropsContextProvider>\n )}\n </Aria.Checkbox>\n <FieldErrorView />\n </div>\n );\n});\n\nexport default Checkbox;\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAuBO,MAAM,QAAA,GAAW,aAAA,CAAc,UAAA,EAAY,CAAC,KAAA,KAAU;AAC3D,EAAA,MAAM,EAAE,QAAA,EAAU,SAAA,EAAW,KAAK,cAAA,EAAgB,GAAG,MAAK,GAAI,KAAA;AAE9D,EAAA,MAAM,EAAE,cAAA,EAAgB,iBAAA,EAAmB,UAAA,EAAW,GACpD,kBAAkB,KAAK,CAAA;AAEzB,EAAA,MAAM,gBAAA,GAAmB,aAAa,GAAG,CAAA;AACzC,EAAA,gBAAA,CAAiB,gBAAgB,CAAA;AAEjC,EAAA,uBACE,IAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACE,GAAG,UAAA;AAAA,MACJ,WAAW,IAAA,CAAK,MAAA,CAAO,QAAA,EAAU,SAAA,EAAW,WAAW,SAAS,CAAA;AAAA,MAChE,GAAA,EAAK,gBAAA;AAAA,MAEL,QAAA,EAAA;AAAA,wBAAA,GAAA,CAAC,KAAK,QAAA,EAAL,EAAe,GAAG,IAAA,EAAM,SAAA,EAAW,KAAK,cAAA,EAAgB,MAAA,CAAO,KAAK,CAAA,EAClE,QAAA,EAAA,CAAC,EAAE,UAAA,EAAY,eAAA,uBACd,IAAA,CAAC,oBAAA,EAAA,EAAqB,OAAO,iBAAA,EAC1B,QAAA,EAAA;AAAA,UAAA,UAAA,uBACE,mBAAA,EAAA,EAAoB,SAAA,EAAW,MAAA,CAAO,IAAA,EAAM,IAC3C,eAAA,mBACF,GAAA,CAAC,yBAAA,EAAA,EAA0B,SAAA,EAAW,OAAO,IAAA,EAAM,CAAA,uBAElD,iBAAA,EAAA,EAAkB,SAAA,EAAW,OAAO,IAAA,EAAM,CAAA;AAAA,UAE5C;AAAA,SAAA,EACH,CAAA,EAEJ,CAAA;AAAA,4BACC,cAAA,EAAA,EAAe;AAAA;AAAA;AAAA,GAClB;AAEJ,CAAC;;;;"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
/* */
|
|
3
3
|
const checkbox = "flow--checkbox";
|
|
4
|
+
const input = "flow--checkbox--input";
|
|
4
5
|
const icon = "flow--checkbox--icon";
|
|
5
6
|
const styles = {
|
|
6
7
|
checkbox: checkbox,
|
|
8
|
+
input: input,
|
|
7
9
|
icon: icon
|
|
8
10
|
};
|
|
9
11
|
|
|
10
|
-
export { checkbox, styles as default, icon };
|
|
12
|
+
export { checkbox, styles as default, icon, input };
|
|
11
13
|
//# sourceMappingURL=Checkbox.module.scss.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkbox.module.scss.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Checkbox.module.scss.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;"}
|
|
@@ -1,25 +1,47 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
/* */
|
|
3
|
-
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
4
4
|
import styles from './CheckboxButton.module.scss.mjs';
|
|
5
5
|
import clsx from 'clsx';
|
|
6
6
|
import '../../lib/propsContext/propsContext.mjs';
|
|
7
7
|
import { PropsContextProvider } from '../../lib/propsContext/components/PropsContextProvider.mjs';
|
|
8
8
|
import { Checkbox } from '../Checkbox/Checkbox.mjs';
|
|
9
9
|
import { flowComponent } from '../../lib/componentFactory/flowComponent.mjs';
|
|
10
|
+
import { useFieldComponent } from '../../lib/hooks/useFieldComponent.mjs';
|
|
11
|
+
import { useObjectRef } from '@react-aria/utils';
|
|
12
|
+
import { useMakeFocusable } from '../../lib/hooks/dom/useMakeFocusable.mjs';
|
|
10
13
|
|
|
11
14
|
const CheckboxButton = flowComponent("CheckboxButton", (props) => {
|
|
12
|
-
const { children, className, ref, ...rest } = props;
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
+
const { children, className, ref, inputClassName, ...rest } = props;
|
|
16
|
+
const {
|
|
17
|
+
fieldPropsContext,
|
|
18
|
+
fieldProps,
|
|
19
|
+
FieldErrorView,
|
|
20
|
+
FieldErrorResetContext
|
|
21
|
+
} = useFieldComponent(props);
|
|
22
|
+
const mergedPropsContext = {
|
|
15
23
|
Text: {
|
|
16
24
|
className: styles.label
|
|
17
25
|
},
|
|
18
26
|
Content: {
|
|
19
27
|
className: styles.content
|
|
20
|
-
}
|
|
28
|
+
},
|
|
29
|
+
...fieldPropsContext
|
|
21
30
|
};
|
|
22
|
-
|
|
31
|
+
const localCheckboxButtonRef = useObjectRef(ref);
|
|
32
|
+
useMakeFocusable(localCheckboxButtonRef);
|
|
33
|
+
return /* @__PURE__ */ jsxs(
|
|
34
|
+
"div",
|
|
35
|
+
{
|
|
36
|
+
...fieldProps,
|
|
37
|
+
className: clsx(fieldProps.className, styles.checkboxButton, className),
|
|
38
|
+
ref: localCheckboxButtonRef,
|
|
39
|
+
children: [
|
|
40
|
+
/* @__PURE__ */ jsx(FieldErrorResetContext, { children: /* @__PURE__ */ jsx(Checkbox, { ...rest, inputClassName: clsx(inputClassName, styles.input), children: /* @__PURE__ */ jsx(PropsContextProvider, { props: mergedPropsContext, clear: true, children }) }) }),
|
|
41
|
+
/* @__PURE__ */ jsx(FieldErrorView, {})
|
|
42
|
+
]
|
|
43
|
+
}
|
|
44
|
+
);
|
|
23
45
|
});
|
|
24
46
|
|
|
25
47
|
export { CheckboxButton, CheckboxButton as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CheckboxButton.mjs","sources":["../../../../../../src/components/CheckboxButton/CheckboxButton.tsx"],"sourcesContent":["import styles from \"./CheckboxButton.module.scss\";\nimport clsx from \"clsx\";\nimport type { PropsContext } from \"@/lib/propsContext\";\nimport { PropsContextProvider } from \"@/lib/propsContext\";\nimport type { CheckboxProps } from \"@/components/Checkbox\";\nimport { Checkbox } from \"@/components/Checkbox\";\nimport type { FlowComponentProps } from \"@/lib/componentFactory/flowComponent\";\nimport { flowComponent } from \"@/lib/componentFactory/flowComponent\";\n\nexport interface CheckboxButtonProps\n extends CheckboxProps,\n FlowComponentProps
|
|
1
|
+
{"version":3,"file":"CheckboxButton.mjs","sources":["../../../../../../src/components/CheckboxButton/CheckboxButton.tsx"],"sourcesContent":["import styles from \"./CheckboxButton.module.scss\";\nimport clsx from \"clsx\";\nimport type { PropsContext } from \"@/lib/propsContext\";\nimport { PropsContextProvider } from \"@/lib/propsContext\";\nimport type { CheckboxProps } from \"@/components/Checkbox\";\nimport { Checkbox } from \"@/components/Checkbox\";\nimport type { FlowComponentProps } from \"@/lib/componentFactory/flowComponent\";\nimport { flowComponent } from \"@/lib/componentFactory/flowComponent\";\nimport { useFieldComponent } from \"@/lib/hooks/useFieldComponent\";\nimport { useObjectRef } from \"@react-aria/utils\";\nimport { useMakeFocusable } from \"@/lib/hooks/dom/useMakeFocusable\";\n\nexport interface CheckboxButtonProps\n extends CheckboxProps,\n FlowComponentProps {}\n\n/** @flr-generate all */\nexport const CheckboxButton = flowComponent(\"CheckboxButton\", (props) => {\n const { children, className, ref, inputClassName, ...rest } = props;\n\n const {\n fieldPropsContext,\n fieldProps,\n FieldErrorView,\n FieldErrorResetContext,\n } = useFieldComponent(props);\n\n const mergedPropsContext: PropsContext = {\n Text: {\n className: styles.label,\n },\n Content: {\n className: styles.content,\n },\n ...fieldPropsContext,\n };\n\n const localCheckboxButtonRef = useObjectRef(ref);\n useMakeFocusable(localCheckboxButtonRef);\n\n return (\n <div\n {...fieldProps}\n className={clsx(fieldProps.className, styles.checkboxButton, className)}\n ref={localCheckboxButtonRef}\n >\n <FieldErrorResetContext>\n <Checkbox {...rest} inputClassName={clsx(inputClassName, styles.input)}>\n <PropsContextProvider props={mergedPropsContext} clear>\n {children}\n </PropsContextProvider>\n </Checkbox>\n </FieldErrorResetContext>\n <FieldErrorView />\n </div>\n );\n});\n\nexport default CheckboxButton;\n"],"names":[],"mappings":";;;;;;;;;;;AAiBO,MAAM,cAAA,GAAiB,aAAA,CAAc,gBAAA,EAAkB,CAAC,KAAA,KAAU;AACvE,EAAA,MAAM,EAAE,QAAA,EAAU,SAAA,EAAW,KAAK,cAAA,EAAgB,GAAG,MAAK,GAAI,KAAA;AAE9D,EAAA,MAAM;AAAA,IACJ,iBAAA;AAAA,IACA,UAAA;AAAA,IACA,cAAA;AAAA,IACA;AAAA,GACF,GAAI,kBAAkB,KAAK,CAAA;AAE3B,EAAA,MAAM,kBAAA,GAAmC;AAAA,IACvC,IAAA,EAAM;AAAA,MACJ,WAAW,MAAA,CAAO;AAAA,KACpB;AAAA,IACA,OAAA,EAAS;AAAA,MACP,WAAW,MAAA,CAAO;AAAA,KACpB;AAAA,IACA,GAAG;AAAA,GACL;AAEA,EAAA,MAAM,sBAAA,GAAyB,aAAa,GAAG,CAAA;AAC/C,EAAA,gBAAA,CAAiB,sBAAsB,CAAA;AAEvC,EAAA,uBACE,IAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACE,GAAG,UAAA;AAAA,MACJ,WAAW,IAAA,CAAK,UAAA,CAAW,SAAA,EAAW,MAAA,CAAO,gBAAgB,SAAS,CAAA;AAAA,MACtE,GAAA,EAAK,sBAAA;AAAA,MAEL,QAAA,EAAA;AAAA,wBAAA,GAAA,CAAC,0BACC,QAAA,kBAAA,GAAA,CAAC,QAAA,EAAA,EAAU,GAAG,IAAA,EAAM,cAAA,EAAgB,KAAK,cAAA,EAAgB,MAAA,CAAO,KAAK,CAAA,EACnE,QAAA,kBAAA,GAAA,CAAC,wBAAqB,KAAA,EAAO,kBAAA,EAAoB,OAAK,IAAA,EACnD,QAAA,EACH,GACF,CAAA,EACF,CAAA;AAAA,4BACC,cAAA,EAAA,EAAe;AAAA;AAAA;AAAA,GAClB;AAEJ,CAAC;;;;"}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
/* */
|
|
3
3
|
const checkboxButton = "flow--checkbox-button";
|
|
4
|
-
const
|
|
4
|
+
const input = "flow--checkbox-button--input";
|
|
5
5
|
const content = "flow--checkbox-button--content";
|
|
6
|
+
const label = "flow--checkbox-button--label";
|
|
6
7
|
const styles = {
|
|
7
8
|
checkboxButton: checkboxButton,
|
|
8
|
-
|
|
9
|
-
content: content
|
|
9
|
+
input: input,
|
|
10
|
+
content: content,
|
|
11
|
+
label: label
|
|
10
12
|
};
|
|
11
13
|
|
|
12
|
-
export { checkboxButton, content, styles as default, label };
|
|
14
|
+
export { checkboxButton, content, styles as default, input, label };
|
|
13
15
|
//# sourceMappingURL=CheckboxButton.module.scss.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CheckboxButton.module.scss.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CheckboxButton.module.scss.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;"}
|
|
@@ -1,53 +1,51 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
/* */
|
|
3
|
-
import {
|
|
3
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
4
4
|
import { ColumnLayout } from '../ColumnLayout/ColumnLayout.mjs';
|
|
5
|
-
import { FieldError } from '../FieldError/FieldError.mjs';
|
|
6
5
|
import { flowComponent } from '../../lib/componentFactory/flowComponent.mjs';
|
|
7
6
|
import '../../lib/propsContext/propsContext.mjs';
|
|
8
7
|
import { PropsContextProvider } from '../../lib/propsContext/components/PropsContextProvider.mjs';
|
|
9
8
|
import { TunnelProvider, TunnelExit } from '@mittwald/react-tunnel';
|
|
10
9
|
import clsx from 'clsx';
|
|
11
10
|
import * as Aria from 'react-aria-components';
|
|
12
|
-
import formFieldStyles from '../FormField/FormField.module.scss.mjs';
|
|
13
11
|
import styles from './CheckboxGroup.module.scss.mjs';
|
|
14
12
|
import { useObjectRef } from '@react-aria/utils';
|
|
15
13
|
import { useMakeFocusable } from '../../lib/hooks/dom/useMakeFocusable.mjs';
|
|
14
|
+
import { useFieldComponent } from '../../lib/hooks/useFieldComponent.mjs';
|
|
16
15
|
|
|
17
16
|
const CheckboxGroup = flowComponent("CheckboxGroup", (props) => {
|
|
18
|
-
const { children, className, s, m, l, ref, ...rest } = props;
|
|
19
|
-
const
|
|
17
|
+
const { children, className, isInvalid, s, m, l, ref, ...rest } = props;
|
|
18
|
+
const {
|
|
19
|
+
FieldErrorView,
|
|
20
|
+
fieldPropsContext,
|
|
21
|
+
fieldProps,
|
|
22
|
+
FieldErrorResetContext
|
|
23
|
+
} = useFieldComponent(props);
|
|
20
24
|
const propsContext = {
|
|
21
|
-
Label: {
|
|
22
|
-
className: formFieldStyles.label
|
|
23
|
-
},
|
|
24
|
-
FieldDescription: {
|
|
25
|
-
className: formFieldStyles.fieldDescription,
|
|
26
|
-
tunnelId: "fieldDescription"
|
|
27
|
-
},
|
|
28
|
-
FieldError: {
|
|
29
|
-
className: formFieldStyles.customFieldError,
|
|
30
|
-
tunnelId: "fieldError"
|
|
31
|
-
},
|
|
32
25
|
Checkbox: {
|
|
26
|
+
isInvalid,
|
|
33
27
|
tunnelId: "checkboxes",
|
|
34
28
|
className: styles.checkbox
|
|
35
29
|
},
|
|
36
30
|
CheckboxButton: {
|
|
31
|
+
isInvalid,
|
|
37
32
|
tunnelId: "checkboxButtons",
|
|
38
33
|
className: styles.checkboxButton
|
|
39
|
-
}
|
|
34
|
+
},
|
|
35
|
+
...fieldPropsContext
|
|
40
36
|
};
|
|
41
37
|
const localCheckboxGroupRef = useObjectRef(ref);
|
|
42
38
|
useMakeFocusable(localCheckboxGroupRef);
|
|
43
|
-
return /* @__PURE__ */
|
|
39
|
+
return /* @__PURE__ */ jsx(
|
|
44
40
|
Aria.CheckboxGroup,
|
|
45
41
|
{
|
|
46
42
|
...rest,
|
|
47
|
-
|
|
43
|
+
...fieldProps,
|
|
44
|
+
isInvalid,
|
|
45
|
+
className: clsx(fieldProps.className, className),
|
|
48
46
|
ref: localCheckboxGroupRef,
|
|
49
|
-
children: [
|
|
50
|
-
/* @__PURE__ */ jsx(
|
|
47
|
+
children: /* @__PURE__ */ jsxs(TunnelProvider, { children: [
|
|
48
|
+
/* @__PURE__ */ jsx(FieldErrorResetContext, { children: /* @__PURE__ */ jsxs(PropsContextProvider, { props: propsContext, clear: true, children: [
|
|
51
49
|
children,
|
|
52
50
|
/* @__PURE__ */ jsx(ColumnLayout, { s, m, l, className: styles.checkboxGroup, children: /* @__PURE__ */ jsx(TunnelExit, { id: "checkboxButtons" }) }),
|
|
53
51
|
/* @__PURE__ */ jsx(
|
|
@@ -60,12 +58,10 @@ const CheckboxGroup = flowComponent("CheckboxGroup", (props) => {
|
|
|
60
58
|
className: styles.checkboxGroup,
|
|
61
59
|
children: /* @__PURE__ */ jsx(TunnelExit, { id: "checkboxes" })
|
|
62
60
|
}
|
|
63
|
-
)
|
|
64
|
-
/* @__PURE__ */ jsx(TunnelExit, { id: "fieldDescription" }),
|
|
65
|
-
/* @__PURE__ */ jsx(TunnelExit, { id: "fieldError" })
|
|
61
|
+
)
|
|
66
62
|
] }) }),
|
|
67
|
-
/* @__PURE__ */ jsx(
|
|
68
|
-
]
|
|
63
|
+
/* @__PURE__ */ jsx(FieldErrorView, {})
|
|
64
|
+
] })
|
|
69
65
|
}
|
|
70
66
|
);
|
|
71
67
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CheckboxGroup.mjs","sources":["../../../../../../src/components/CheckboxGroup/CheckboxGroup.tsx"],"sourcesContent":["import type { ColumnLayoutProps } from \"@/components/ColumnLayout\";\nimport { ColumnLayout } from \"@/components/ColumnLayout\";\nimport
|
|
1
|
+
{"version":3,"file":"CheckboxGroup.mjs","sources":["../../../../../../src/components/CheckboxGroup/CheckboxGroup.tsx"],"sourcesContent":["import type { ColumnLayoutProps } from \"@/components/ColumnLayout\";\nimport { ColumnLayout } from \"@/components/ColumnLayout\";\nimport type { FlowComponentProps } from \"@/lib/componentFactory/flowComponent\";\nimport { flowComponent } from \"@/lib/componentFactory/flowComponent\";\nimport type { PropsContext } from \"@/lib/propsContext\";\nimport { PropsContextProvider } from \"@/lib/propsContext\";\nimport { TunnelExit, TunnelProvider } from \"@mittwald/react-tunnel\";\nimport clsx from \"clsx\";\nimport type { PropsWithChildren } from \"react\";\nimport * as Aria from \"react-aria-components\";\nimport styles from \"./CheckboxGroup.module.scss\";\nimport { useObjectRef } from \"@react-aria/utils\";\nimport { useMakeFocusable } from \"@/lib/hooks/dom/useMakeFocusable\";\nimport { useFieldComponent } from \"@/lib/hooks/useFieldComponent\";\n\nexport interface CheckboxGroupProps\n extends PropsWithChildren<Omit<Aria.CheckboxGroupProps, \"children\">>,\n Pick<ColumnLayoutProps, \"s\" | \"m\" | \"l\">,\n FlowComponentProps {}\n\n/** @flr-generate all */\nexport const CheckboxGroup = flowComponent(\"CheckboxGroup\", (props) => {\n const { children, className, isInvalid, s, m, l, ref, ...rest } = props;\n\n const {\n FieldErrorView,\n fieldPropsContext,\n fieldProps,\n FieldErrorResetContext,\n } = useFieldComponent(props);\n\n const propsContext: PropsContext = {\n Checkbox: {\n isInvalid,\n tunnelId: \"checkboxes\",\n className: styles.checkbox,\n },\n CheckboxButton: {\n isInvalid,\n tunnelId: \"checkboxButtons\",\n className: styles.checkboxButton,\n },\n ...fieldPropsContext,\n };\n\n const localCheckboxGroupRef = useObjectRef(ref);\n useMakeFocusable(localCheckboxGroupRef);\n\n return (\n <Aria.CheckboxGroup\n {...rest}\n {...fieldProps}\n isInvalid={isInvalid}\n className={clsx(fieldProps.className, className)}\n ref={localCheckboxGroupRef}\n >\n <TunnelProvider>\n <FieldErrorResetContext>\n <PropsContextProvider props={propsContext} clear>\n {children}\n <ColumnLayout s={s} m={m} l={l} className={styles.checkboxGroup}>\n <TunnelExit id=\"checkboxButtons\" />\n </ColumnLayout>\n\n <ColumnLayout\n s={s ?? [1]}\n m={m ?? [1]}\n l={l ?? [1]}\n rowGap=\"s\"\n className={styles.checkboxGroup}\n >\n <TunnelExit id=\"checkboxes\" />\n </ColumnLayout>\n </PropsContextProvider>\n </FieldErrorResetContext>\n <FieldErrorView />\n </TunnelProvider>\n </Aria.CheckboxGroup>\n );\n});\n\nexport default CheckboxGroup;\n"],"names":[],"mappings":";;;;;;;;;;;;;AAqBO,MAAM,aAAA,GAAgB,aAAA,CAAc,eAAA,EAAiB,CAAC,KAAA,KAAU;AACrE,EAAA,MAAM,EAAE,QAAA,EAAU,SAAA,EAAW,SAAA,EAAW,CAAA,EAAG,GAAG,CAAA,EAAG,GAAA,EAAK,GAAG,IAAA,EAAK,GAAI,KAAA;AAElE,EAAA,MAAM;AAAA,IACJ,cAAA;AAAA,IACA,iBAAA;AAAA,IACA,UAAA;AAAA,IACA;AAAA,GACF,GAAI,kBAAkB,KAAK,CAAA;AAE3B,EAAA,MAAM,YAAA,GAA6B;AAAA,IACjC,QAAA,EAAU;AAAA,MACR,SAAA;AAAA,MACA,QAAA,EAAU,YAAA;AAAA,MACV,WAAW,MAAA,CAAO;AAAA,KACpB;AAAA,IACA,cAAA,EAAgB;AAAA,MACd,SAAA;AAAA,MACA,QAAA,EAAU,iBAAA;AAAA,MACV,WAAW,MAAA,CAAO;AAAA,KACpB;AAAA,IACA,GAAG;AAAA,GACL;AAEA,EAAA,MAAM,qBAAA,GAAwB,aAAa,GAAG,CAAA;AAC9C,EAAA,gBAAA,CAAiB,qBAAqB,CAAA;AAEtC,EAAA,uBACE,GAAA;AAAA,IAAC,IAAA,CAAK,aAAA;AAAA,IAAL;AAAA,MACE,GAAG,IAAA;AAAA,MACH,GAAG,UAAA;AAAA,MACJ,SAAA;AAAA,MACA,SAAA,EAAW,IAAA,CAAK,UAAA,CAAW,SAAA,EAAW,SAAS,CAAA;AAAA,MAC/C,GAAA,EAAK,qBAAA;AAAA,MAEL,+BAAC,cAAA,EAAA,EACC,QAAA,EAAA;AAAA,wBAAA,GAAA,CAAC,0BACC,QAAA,kBAAA,IAAA,CAAC,oBAAA,EAAA,EAAqB,KAAA,EAAO,YAAA,EAAc,OAAK,IAAA,EAC7C,QAAA,EAAA;AAAA,UAAA,QAAA;AAAA,0BACD,GAAA,CAAC,YAAA,EAAA,EAAa,CAAA,EAAM,CAAA,EAAM,CAAA,EAAM,SAAA,EAAW,MAAA,CAAO,aAAA,EAChD,QAAA,kBAAA,GAAA,CAAC,UAAA,EAAA,EAAW,EAAA,EAAG,iBAAA,EAAkB,CAAA,EACnC,CAAA;AAAA,0BAEA,GAAA;AAAA,YAAC,YAAA;AAAA,YAAA;AAAA,cACC,CAAA,EAAG,CAAA,IAAK,CAAC,CAAC,CAAA;AAAA,cACV,CAAA,EAAG,CAAA,IAAK,CAAC,CAAC,CAAA;AAAA,cACV,CAAA,EAAG,CAAA,IAAK,CAAC,CAAC,CAAA;AAAA,cACV,MAAA,EAAO,GAAA;AAAA,cACP,WAAW,MAAA,CAAO,aAAA;AAAA,cAElB,QAAA,kBAAA,GAAA,CAAC,UAAA,EAAA,EAAW,EAAA,EAAG,YAAA,EAAa;AAAA;AAAA;AAC9B,SAAA,EACF,CAAA,EACF,CAAA;AAAA,4BACC,cAAA,EAAA,EAAe;AAAA,OAAA,EAClB;AAAA;AAAA,GACF;AAEJ,CAAC;;;;"}
|
|
@@ -14,7 +14,6 @@ import '../../lib/propsContext/propsContext.mjs';
|
|
|
14
14
|
import { PropsContextProvider } from '../../lib/propsContext/components/PropsContextProvider.mjs';
|
|
15
15
|
import clsx from 'clsx';
|
|
16
16
|
import styles from './ComboBox.module.scss.mjs';
|
|
17
|
-
import formFieldStyles from '../FormField/FormField.module.scss.mjs';
|
|
18
17
|
import locales from '../../../../_virtual/_.locale.json@51dcf4944c990e2cbe26472300dae78d.mjs';
|
|
19
18
|
import { useLocalizedStringFormatter } from 'react-aria';
|
|
20
19
|
import { flowComponent } from '../../lib/componentFactory/flowComponent.mjs';
|
|
@@ -22,6 +21,7 @@ import 'mobx';
|
|
|
22
21
|
import { useOverlayController } from '../../lib/controller/overlay/useOverlayController.mjs';
|
|
23
22
|
import { useObjectRef } from '@react-aria/utils';
|
|
24
23
|
import { useMakeFocusable } from '../../lib/hooks/dom/useMakeFocusable.mjs';
|
|
24
|
+
import { useFieldComponent } from '../../lib/hooks/useFieldComponent.mjs';
|
|
25
25
|
|
|
26
26
|
const ComboBox = flowComponent("ComboBox", (props) => {
|
|
27
27
|
const {
|
|
@@ -38,26 +38,19 @@ const ComboBox = flowComponent("ComboBox", (props) => {
|
|
|
38
38
|
renderEmptyState,
|
|
39
39
|
...rest
|
|
40
40
|
} = props;
|
|
41
|
+
const {
|
|
42
|
+
FieldErrorView,
|
|
43
|
+
FieldErrorResetContext,
|
|
44
|
+
fieldProps,
|
|
45
|
+
fieldPropsContext
|
|
46
|
+
} = useFieldComponent(props);
|
|
41
47
|
const stringFormatter = useLocalizedStringFormatter(locales);
|
|
42
|
-
const rootClassName = clsx(
|
|
43
|
-
styles.comboBox,
|
|
44
|
-
formFieldStyles.formField,
|
|
45
|
-
className
|
|
46
|
-
);
|
|
48
|
+
const rootClassName = clsx(fieldProps.className, styles.comboBox, className);
|
|
47
49
|
const propsContext = {
|
|
48
|
-
Label: {
|
|
49
|
-
className: formFieldStyles.label,
|
|
50
|
-
optional: !props.isRequired
|
|
51
|
-
},
|
|
52
|
-
FieldDescription: {
|
|
53
|
-
className: formFieldStyles.fieldDescription
|
|
54
|
-
},
|
|
55
|
-
FieldError: {
|
|
56
|
-
className: formFieldStyles.customFieldError
|
|
57
|
-
},
|
|
58
50
|
Option: {
|
|
59
51
|
tunnelId: "options"
|
|
60
|
-
}
|
|
52
|
+
},
|
|
53
|
+
...fieldPropsContext
|
|
61
54
|
};
|
|
62
55
|
const handleOnSelectionChange = (key) => {
|
|
63
56
|
if (key === null) {
|
|
@@ -75,6 +68,7 @@ const ComboBox = flowComponent("ComboBox", (props) => {
|
|
|
75
68
|
return /* @__PURE__ */ jsx(
|
|
76
69
|
Aria.ComboBox,
|
|
77
70
|
{
|
|
71
|
+
...fieldProps,
|
|
78
72
|
menuTrigger,
|
|
79
73
|
className: rootClassName,
|
|
80
74
|
...rest,
|
|
@@ -82,21 +76,31 @@ const ComboBox = flowComponent("ComboBox", (props) => {
|
|
|
82
76
|
onSelectionChange: handleOnSelectionChange,
|
|
83
77
|
onOpenChange: (isOpen) => controller.setOpen(isOpen),
|
|
84
78
|
children: /* @__PURE__ */ jsx(PropsContextProvider, { props: propsContext, children: /* @__PURE__ */ jsxs(TunnelProvider, { children: [
|
|
85
|
-
/* @__PURE__ */ jsxs(
|
|
86
|
-
/* @__PURE__ */
|
|
79
|
+
/* @__PURE__ */ jsxs(FieldErrorResetContext, { children: [
|
|
80
|
+
/* @__PURE__ */ jsxs("div", { className: styles.input, children: [
|
|
81
|
+
/* @__PURE__ */ jsx(Aria.Input, { placeholder }),
|
|
82
|
+
/* @__PURE__ */ jsx(
|
|
83
|
+
Button,
|
|
84
|
+
{
|
|
85
|
+
className: styles.toggle,
|
|
86
|
+
"aria-label": stringFormatter.format("comboBox.showOptions"),
|
|
87
|
+
variant: "plain",
|
|
88
|
+
color: "secondary",
|
|
89
|
+
children: /* @__PURE__ */ jsx(IconChevronDown, {})
|
|
90
|
+
}
|
|
91
|
+
)
|
|
92
|
+
] }),
|
|
93
|
+
children,
|
|
87
94
|
/* @__PURE__ */ jsx(
|
|
88
|
-
|
|
95
|
+
Options,
|
|
89
96
|
{
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
color: "secondary",
|
|
94
|
-
children: /* @__PURE__ */ jsx(IconChevronDown, {})
|
|
97
|
+
controller,
|
|
98
|
+
renderEmptyState,
|
|
99
|
+
children: /* @__PURE__ */ jsx(TunnelExit, { id: "options" })
|
|
95
100
|
}
|
|
96
101
|
)
|
|
97
102
|
] }),
|
|
98
|
-
|
|
99
|
-
/* @__PURE__ */ jsx(Options, { controller, renderEmptyState, children: /* @__PURE__ */ jsx(TunnelExit, { id: "options" }) })
|
|
103
|
+
/* @__PURE__ */ jsx(FieldErrorView, {})
|
|
100
104
|
] }) })
|
|
101
105
|
}
|
|
102
106
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComboBox.mjs","sources":["../../../../../../src/components/ComboBox/ComboBox.tsx"],"sourcesContent":["import type { PropsWithChildren } from \"react\";\nimport type { Key } from \"react-aria-components\";\nimport * as Aria from \"react-aria-components\";\nimport { TunnelExit, TunnelProvider } from \"@mittwald/react-tunnel\";\nimport { Button } from \"@/components/Button\";\nimport { IconChevronDown } from \"@/components/Icon/components/icons\";\nimport { Options } from \"@/components/Options\";\nimport type { PropsContext } from \"@/lib/propsContext\";\nimport { PropsContextProvider } from \"@/lib/propsContext\";\nimport clsx from \"clsx\";\nimport styles from \"./ComboBox.module.scss\";\nimport
|
|
1
|
+
{"version":3,"file":"ComboBox.mjs","sources":["../../../../../../src/components/ComboBox/ComboBox.tsx"],"sourcesContent":["import type { PropsWithChildren } from \"react\";\nimport type { Key } from \"react-aria-components\";\nimport * as Aria from \"react-aria-components\";\nimport { TunnelExit, TunnelProvider } from \"@mittwald/react-tunnel\";\nimport { Button } from \"@/components/Button\";\nimport { IconChevronDown } from \"@/components/Icon/components/icons\";\nimport { Options } from \"@/components/Options\";\nimport type { PropsContext } from \"@/lib/propsContext\";\nimport { PropsContextProvider } from \"@/lib/propsContext\";\nimport clsx from \"clsx\";\nimport styles from \"./ComboBox.module.scss\";\nimport locales from \"./locales/*.locale.json\";\nimport { useLocalizedStringFormatter } from \"react-aria\";\nimport type { FlowComponentProps } from \"@/lib/componentFactory/flowComponent\";\nimport { flowComponent } from \"@/lib/componentFactory/flowComponent\";\nimport { type OverlayController, useOverlayController } from \"@/lib/controller\";\nimport type { OptionsProps } from \"@/components/Options/Options\";\nimport { useObjectRef } from \"@react-aria/utils\";\nimport { useMakeFocusable } from \"@/lib/hooks/dom/useMakeFocusable\";\nimport { useFieldComponent } from \"@/lib/hooks/useFieldComponent\";\n\nexport interface ComboBoxProps\n extends Omit<Aria.ComboBoxProps<never>, \"children\">,\n Pick<Aria.InputProps, \"placeholder\">,\n Pick<OptionsProps, \"renderEmptyState\">,\n PropsWithChildren,\n FlowComponentProps {\n onChange?: (value: string) => void;\n controller?: OverlayController;\n}\n\n/** @flr-generate all */\nexport const ComboBox = flowComponent(\"ComboBox\", (props) => {\n const {\n children,\n className,\n menuTrigger = \"focus\",\n onChange = () => {\n // default: do nothing\n },\n onSelectionChange = () => {\n // default: do nothing\n },\n controller: controllerFromProps,\n placeholder,\n ref,\n renderEmptyState,\n\n ...rest\n } = props;\n\n const {\n FieldErrorView,\n FieldErrorResetContext,\n fieldProps,\n fieldPropsContext,\n } = useFieldComponent(props);\n\n const stringFormatter = useLocalizedStringFormatter(locales);\n\n const rootClassName = clsx(fieldProps.className, styles.comboBox, className);\n\n const propsContext: PropsContext = {\n Option: {\n tunnelId: \"options\",\n },\n ...fieldPropsContext,\n };\n\n const handleOnSelectionChange = (key: Key | null) => {\n if (key === null) {\n return;\n }\n onChange(String(key));\n onSelectionChange(key);\n };\n\n const controllerFromContext = useOverlayController(\"ComboBox\", {\n reuseControllerFromContext: true,\n });\n\n const controller = controllerFromProps ?? controllerFromContext;\n\n const localComboBoxRef = useObjectRef(ref);\n useMakeFocusable(localComboBoxRef);\n\n return (\n <Aria.ComboBox\n {...fieldProps}\n menuTrigger={menuTrigger}\n className={rootClassName}\n {...rest}\n ref={localComboBoxRef}\n onSelectionChange={handleOnSelectionChange}\n onOpenChange={(isOpen) => controller.setOpen(isOpen)}\n >\n <PropsContextProvider props={propsContext}>\n <TunnelProvider>\n <FieldErrorResetContext>\n <div className={styles.input}>\n <Aria.Input placeholder={placeholder} />\n <Button\n className={styles.toggle}\n aria-label={stringFormatter.format(\"comboBox.showOptions\")}\n variant=\"plain\"\n color=\"secondary\"\n >\n <IconChevronDown />\n </Button>\n </div>\n\n {children}\n\n <Options\n controller={controller}\n renderEmptyState={renderEmptyState}\n >\n <TunnelExit id=\"options\" />\n </Options>\n </FieldErrorResetContext>\n <FieldErrorView />\n </TunnelProvider>\n </PropsContextProvider>\n </Aria.ComboBox>\n );\n});\n\nexport default ComboBox;\n"],"names":[],"mappings":"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"}
|