@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 { jsx, jsxs } from 'react/jsx-runtime';
|
|
4
4
|
import { flowComponent } from '../../lib/componentFactory/flowComponent.mjs';
|
|
5
5
|
import 'react';
|
|
6
6
|
import * as Aria from 'react-aria-components';
|
|
@@ -10,10 +10,10 @@ import { getContainerBreakpointSizeClassName } from '../../lib/getContainerBreak
|
|
|
10
10
|
import '../../lib/propsContext/propsContext.mjs';
|
|
11
11
|
import { PropsContextProvider } from '../../lib/propsContext/components/PropsContextProvider.mjs';
|
|
12
12
|
import { TunnelProvider, TunnelExit } from '@mittwald/react-tunnel';
|
|
13
|
-
import { FieldError } from '../FieldError/FieldError.mjs';
|
|
14
13
|
import clsx from 'clsx';
|
|
15
14
|
import { useObjectRef } from '@react-aria/utils';
|
|
16
15
|
import { useMakeFocusable } from '../../lib/hooks/dom/useMakeFocusable.mjs';
|
|
16
|
+
import { useFieldComponent } from '../../lib/hooks/useFieldComponent.mjs';
|
|
17
17
|
|
|
18
18
|
const SegmentedControl = flowComponent("SegmentedControl", (props) => {
|
|
19
19
|
const {
|
|
@@ -23,6 +23,12 @@ const SegmentedControl = flowComponent("SegmentedControl", (props) => {
|
|
|
23
23
|
ref,
|
|
24
24
|
...rest
|
|
25
25
|
} = props;
|
|
26
|
+
const {
|
|
27
|
+
FieldErrorView,
|
|
28
|
+
fieldPropsContext,
|
|
29
|
+
fieldProps,
|
|
30
|
+
FieldErrorResetContext
|
|
31
|
+
} = useFieldComponent(props);
|
|
26
32
|
const rootClassName = clsx(
|
|
27
33
|
formFieldStyles.formField,
|
|
28
34
|
styles.segmentedControlContainer,
|
|
@@ -30,33 +36,29 @@ const SegmentedControl = flowComponent("SegmentedControl", (props) => {
|
|
|
30
36
|
styles[getContainerBreakpointSizeClassName(containerBreakpointSize)]
|
|
31
37
|
);
|
|
32
38
|
const propsContext = {
|
|
33
|
-
Label: {
|
|
34
|
-
className: formFieldStyles.label
|
|
35
|
-
},
|
|
36
|
-
FieldDescription: {
|
|
37
|
-
className: formFieldStyles.fieldDescription,
|
|
38
|
-
tunnelId: "fieldDescription"
|
|
39
|
-
},
|
|
40
|
-
FieldError: {
|
|
41
|
-
className: formFieldStyles.customFieldError,
|
|
42
|
-
tunnelId: "fieldError"
|
|
43
|
-
},
|
|
44
39
|
Segment: {
|
|
45
40
|
tunnelId: "segments",
|
|
46
41
|
className: styles.segment
|
|
47
|
-
}
|
|
42
|
+
},
|
|
43
|
+
...fieldPropsContext
|
|
48
44
|
};
|
|
49
45
|
const localRadioRef = useObjectRef(ref);
|
|
50
46
|
useMakeFocusable(localRadioRef);
|
|
51
|
-
return /* @__PURE__ */
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
47
|
+
return /* @__PURE__ */ jsx(
|
|
48
|
+
Aria.RadioGroup,
|
|
49
|
+
{
|
|
50
|
+
...rest,
|
|
51
|
+
className: clsx(rootClassName, fieldProps.className),
|
|
52
|
+
ref: localRadioRef,
|
|
53
|
+
children: /* @__PURE__ */ jsxs(TunnelProvider, { children: [
|
|
54
|
+
/* @__PURE__ */ jsx(FieldErrorResetContext, { children: /* @__PURE__ */ jsxs(PropsContextProvider, { dependencies: ["segment"], props: propsContext, children: [
|
|
55
|
+
/* @__PURE__ */ jsx("div", { className: styles.segmentedControl, children: /* @__PURE__ */ jsx("div", { className: styles.segments, children: /* @__PURE__ */ jsx(TunnelExit, { id: "segments" }) }) }),
|
|
56
|
+
children
|
|
57
|
+
] }) }),
|
|
58
|
+
/* @__PURE__ */ jsx(FieldErrorView, {})
|
|
59
|
+
] })
|
|
60
|
+
}
|
|
61
|
+
);
|
|
60
62
|
});
|
|
61
63
|
|
|
62
64
|
export { SegmentedControl, SegmentedControl as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SegmentedControl.mjs","sources":["../../../../../../src/components/SegmentedControl/SegmentedControl.tsx"],"sourcesContent":["import {\n flowComponent,\n type FlowComponentProps,\n} from \"@/lib/componentFactory/flowComponent\";\nimport type { PropsWithContainerBreakpointSize } from \"@/lib/types/props\";\nimport React, { type PropsWithChildren } from \"react\";\nimport * as Aria from \"react-aria-components\";\nimport formFieldStyles from \"@/components/FormField/FormField.module.scss\";\nimport styles from \"./SegmentedControl.module.scss\";\nimport { getContainerBreakpointSizeClassName } from \"@/lib/getContainerBreakpointSizeClassName\";\nimport { type PropsContext } from \"@/lib/propsContext\";\nimport { PropsContextProvider } from \"@/lib/propsContext\";\nimport { TunnelExit, TunnelProvider } from \"@mittwald/react-tunnel\";\nimport
|
|
1
|
+
{"version":3,"file":"SegmentedControl.mjs","sources":["../../../../../../src/components/SegmentedControl/SegmentedControl.tsx"],"sourcesContent":["import {\n flowComponent,\n type FlowComponentProps,\n} from \"@/lib/componentFactory/flowComponent\";\nimport type { PropsWithContainerBreakpointSize } from \"@/lib/types/props\";\nimport React, { type PropsWithChildren } from \"react\";\nimport * as Aria from \"react-aria-components\";\nimport formFieldStyles from \"@/components/FormField/FormField.module.scss\";\nimport styles from \"./SegmentedControl.module.scss\";\nimport { getContainerBreakpointSizeClassName } from \"@/lib/getContainerBreakpointSizeClassName\";\nimport { type PropsContext } from \"@/lib/propsContext\";\nimport { PropsContextProvider } from \"@/lib/propsContext\";\nimport { TunnelExit, TunnelProvider } from \"@mittwald/react-tunnel\";\nimport clsx from \"clsx\";\nimport { useObjectRef } from \"@react-aria/utils\";\nimport { useMakeFocusable } from \"@/lib/hooks/dom/useMakeFocusable\";\nimport { useFieldComponent } from \"@/lib/hooks/useFieldComponent\";\n\nexport interface SegmentedControlProps\n extends PropsWithChildren<Omit<Aria.RadioGroupProps, \"children\">>,\n FlowComponentProps,\n PropsWithContainerBreakpointSize {}\n\n/** @flr-generate all */\nexport const SegmentedControl = flowComponent(\"SegmentedControl\", (props) => {\n const {\n children,\n className,\n containerBreakpointSize = \"m\",\n ref,\n ...rest\n } = props;\n\n const {\n FieldErrorView,\n fieldPropsContext,\n fieldProps,\n FieldErrorResetContext,\n } = useFieldComponent(props);\n\n const rootClassName = clsx(\n formFieldStyles.formField,\n styles.segmentedControlContainer,\n className,\n styles[getContainerBreakpointSizeClassName(containerBreakpointSize)],\n );\n\n const propsContext: PropsContext = {\n Segment: {\n tunnelId: \"segments\",\n className: styles.segment,\n },\n ...fieldPropsContext,\n };\n\n const localRadioRef = useObjectRef(ref);\n useMakeFocusable(localRadioRef);\n\n return (\n <Aria.RadioGroup\n {...rest}\n className={clsx(rootClassName, fieldProps.className)}\n ref={localRadioRef}\n >\n <TunnelProvider>\n <FieldErrorResetContext>\n <PropsContextProvider dependencies={[\"segment\"]} props={propsContext}>\n <div className={styles.segmentedControl}>\n <div className={styles.segments}>\n <TunnelExit id=\"segments\" />\n </div>\n </div>\n {children}\n </PropsContextProvider>\n </FieldErrorResetContext>\n <FieldErrorView />\n </TunnelProvider>\n </Aria.RadioGroup>\n );\n});\n\nexport default SegmentedControl;\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAwBO,MAAM,gBAAA,GAAmB,aAAA,CAAc,kBAAA,EAAoB,CAAC,KAAA,KAAU;AAC3E,EAAA,MAAM;AAAA,IACJ,QAAA;AAAA,IACA,SAAA;AAAA,IACA,uBAAA,GAA0B,GAAA;AAAA,IAC1B,GAAA;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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
|
7
7
|
import { PropsContextProvider } from '../../lib/propsContext/components/PropsContextProvider.mjs';
|
|
8
8
|
import formFieldStyles from '../FormField/FormField.module.scss.mjs';
|
|
9
|
-
import { FieldError } from '../FieldError/FieldError.mjs';
|
|
10
9
|
import styles from './Select.module.scss.mjs';
|
|
11
10
|
import clsx from 'clsx';
|
|
12
11
|
import '@tabler/icons-react';
|
|
@@ -20,6 +19,7 @@ import 'mobx';
|
|
|
20
19
|
import { useOverlayController } from '../../lib/controller/overlay/useOverlayController.mjs';
|
|
21
20
|
import { useObjectRef } from '@react-aria/utils';
|
|
22
21
|
import { useMakeFocusable } from '../../lib/hooks/dom/useMakeFocusable.mjs';
|
|
22
|
+
import { useFieldComponent } from '../../lib/hooks/useFieldComponent.mjs';
|
|
23
23
|
|
|
24
24
|
const Select = flowComponent("Select", (props) => {
|
|
25
25
|
const {
|
|
@@ -34,25 +34,22 @@ const Select = flowComponent("Select", (props) => {
|
|
|
34
34
|
isReadOnly,
|
|
35
35
|
...rest
|
|
36
36
|
} = props;
|
|
37
|
+
const {
|
|
38
|
+
FieldErrorView,
|
|
39
|
+
fieldPropsContext,
|
|
40
|
+
fieldProps,
|
|
41
|
+
FieldErrorResetContext
|
|
42
|
+
} = useFieldComponent(props);
|
|
37
43
|
const rootClassName = clsx(
|
|
38
44
|
styles.select,
|
|
39
45
|
formFieldStyles.formField,
|
|
40
46
|
className
|
|
41
47
|
);
|
|
42
48
|
const propsContext = {
|
|
43
|
-
Label: {
|
|
44
|
-
className: formFieldStyles.label,
|
|
45
|
-
optional: !props.isRequired
|
|
46
|
-
},
|
|
47
|
-
FieldDescription: {
|
|
48
|
-
className: formFieldStyles.fieldDescription
|
|
49
|
-
},
|
|
50
|
-
FieldError: {
|
|
51
|
-
className: formFieldStyles.customFieldError
|
|
52
|
-
},
|
|
53
49
|
Option: {
|
|
54
50
|
tunnelId: "options"
|
|
55
|
-
}
|
|
51
|
+
},
|
|
52
|
+
...fieldPropsContext
|
|
56
53
|
};
|
|
57
54
|
const handleOnSelectionChange = (id) => {
|
|
58
55
|
onChange(id);
|
|
@@ -72,29 +69,32 @@ const Select = flowComponent("Select", (props) => {
|
|
|
72
69
|
Aria.Select,
|
|
73
70
|
{
|
|
74
71
|
...rest,
|
|
75
|
-
|
|
72
|
+
...fieldProps,
|
|
73
|
+
className: clsx(rootClassName, fieldProps.className),
|
|
76
74
|
ref: localSelectRef,
|
|
77
75
|
onSelectionChange: isReadOnly ? void 0 : handleOnSelectionChange,
|
|
78
76
|
onOpenChange: (isOpen2) => !isReadOnly && controller.setOpen(isOpen2),
|
|
79
77
|
isOpen,
|
|
80
78
|
"data-readonly": isReadOnly,
|
|
81
|
-
children: /* @__PURE__ */
|
|
82
|
-
/* @__PURE__ */ jsxs(
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
79
|
+
children: /* @__PURE__ */ jsxs(TunnelProvider, { children: [
|
|
80
|
+
/* @__PURE__ */ jsx(FieldErrorResetContext, { children: /* @__PURE__ */ jsxs(PropsContextProvider, { props: propsContext, children: [
|
|
81
|
+
/* @__PURE__ */ jsxs(
|
|
82
|
+
Aria.Button,
|
|
83
|
+
{
|
|
84
|
+
ref: localButtonRef,
|
|
85
|
+
"data-readonly": isReadOnly,
|
|
86
|
+
className: styles.toggle,
|
|
87
|
+
children: [
|
|
88
|
+
/* @__PURE__ */ jsx(Aria.SelectValue, {}),
|
|
89
|
+
/* @__PURE__ */ jsx(IconChevronDown, {})
|
|
90
|
+
]
|
|
91
|
+
}
|
|
92
|
+
),
|
|
93
|
+
children,
|
|
94
|
+
/* @__PURE__ */ jsx(Options, { controller, children: /* @__PURE__ */ jsx(TunnelExit, { id: "options" }) })
|
|
95
|
+
] }) }),
|
|
96
|
+
/* @__PURE__ */ jsx(FieldErrorView, {})
|
|
97
|
+
] })
|
|
98
98
|
}
|
|
99
99
|
);
|
|
100
100
|
});
|
|
@@ -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
|
|
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 // default: do nothing\n },\n onSelectionChange = () => {\n // default: do nothing\n },\n controller: controllerFromProps,\n ref,\n isReadOnly,\n ...rest\n } = props;\n\n const {\n FieldErrorView,\n fieldPropsContext,\n fieldProps,\n FieldErrorResetContext,\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 handleOnSelectionChange = (id: Key | null) => {\n onChange(id);\n onSelectionChange(id);\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 });\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 onSelectionChange={isReadOnly ? undefined : handleOnSelectionChange}\n onOpenChange={(isOpen) => !isReadOnly && controller.setOpen(isOpen)}\n isOpen={isOpen}\n data-readonly={isReadOnly}\n >\n <TunnelProvider>\n <FieldErrorResetContext>\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\n {children}\n <Options controller={controller}>\n <TunnelExit id=\"options\" />\n </Options>\n </PropsContextProvider>\n </FieldErrorResetContext>\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,KA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ACE,GAAG,IAAA;AAAA,MACH,GAAG,UAAA;AAAA,MACJ,SAAA,EAAW,IAAA,CAAK,aAAA,EAAe,UAAA,CAAW,SAAS,CAAA;AAAA,MACnD,GAAA,EAAK,cAAA;AAAA,MACL,iBAAA,EAAmB,aAAa,MAAA,GAAY,uBAAA;AAAA,MAC5C,cAAc,CAACA,OAAAA,KAAW,CAAC,UAAA,IAAc,UAAA,CAAW,QAAQA,OAAM,CAAA;AAAA,MAClE,MAAA;AAAA,MACA,eAAA,EAAe,UAAA;AAAA,MAEf,+BAAC,cAAA,EAAA,EACC,QAAA,EAAA;AAAA,wBAAA,GAAA,CAAC,sBAAA,EAAA,EACC,QAAA,kBAAA,IAAA,CAAC,oBAAA,EAAA,EAAqB,KAAA,EAAO,YAAA,EAC3B,QAAA,EAAA;AAAA,0BAAA,IAAA;AAAA,YAAC,IAAA,CAAK,MAAA;AAAA,YAAL;AAAA,cACC,GAAA,EAAK,cAAA;AAAA,cACL,eAAA,EAAe,UAAA;AAAA,cACf,WAAW,MAAA,CAAO,MAAA;AAAA,cAElB,QAAA,EAAA;AAAA,gCAAA,GAAA,CAAC,IAAA,CAAK,aAAL,EAAiB,CAAA;AAAA,oCACjB,eAAA,EAAA,EAAgB;AAAA;AAAA;AAAA,WACnB;AAAA,UAEC,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;;;;"}
|
|
@@ -19,6 +19,7 @@ import { useLocalizedStringFormatter } from 'react-aria';
|
|
|
19
19
|
import { TunnelExit } from '@mittwald/react-tunnel';
|
|
20
20
|
import { useObjectRef } from '@react-aria/utils';
|
|
21
21
|
import { useMakeFocusable } from '../../lib/hooks/dom/useMakeFocusable.mjs';
|
|
22
|
+
import { useFieldComponent } from '../../lib/hooks/useFieldComponent.mjs';
|
|
22
23
|
|
|
23
24
|
const Slider = flowComponent("Slider", (props) => {
|
|
24
25
|
const {
|
|
@@ -38,6 +39,7 @@ const Slider = flowComponent("Slider", (props) => {
|
|
|
38
39
|
isDisabled && styles.disabled,
|
|
39
40
|
className
|
|
40
41
|
);
|
|
42
|
+
const { FieldErrorView, fieldPropsContext, fieldProps } = useFieldComponent(props);
|
|
41
43
|
const stringFormatter = useLocalizedStringFormatter(locales);
|
|
42
44
|
const localSliderRef = useObjectRef(ref);
|
|
43
45
|
const localInputRef = useObjectRef(inputRef);
|
|
@@ -45,12 +47,14 @@ const Slider = flowComponent("Slider", (props) => {
|
|
|
45
47
|
localInputRef.current?.focus();
|
|
46
48
|
});
|
|
47
49
|
const propsContext = {
|
|
50
|
+
...fieldPropsContext,
|
|
48
51
|
Label: {
|
|
49
52
|
unstyled: true,
|
|
50
|
-
tunnelId: "label"
|
|
53
|
+
tunnelId: "label",
|
|
54
|
+
...fieldPropsContext.Label
|
|
51
55
|
}
|
|
52
56
|
};
|
|
53
|
-
return /* @__PURE__ */ jsx(
|
|
57
|
+
return /* @__PURE__ */ jsx("div", { ...fieldProps, children: /* @__PURE__ */ jsx(
|
|
54
58
|
Aria.Slider,
|
|
55
59
|
{
|
|
56
60
|
...rest,
|
|
@@ -58,7 +62,7 @@ const Slider = flowComponent("Slider", (props) => {
|
|
|
58
62
|
className: rootClassName,
|
|
59
63
|
isDisabled,
|
|
60
64
|
defaultValue,
|
|
61
|
-
children: [
|
|
65
|
+
children: /* @__PURE__ */ jsxs(PropsContextProvider, { props: propsContext, children: [
|
|
62
66
|
/* @__PURE__ */ jsxs("div", { className: styles.text, children: [
|
|
63
67
|
/* @__PURE__ */ jsx(Aria.SliderOutput, { className: styles.value }),
|
|
64
68
|
/* @__PURE__ */ jsx(TunnelExit, { id: "label" })
|
|
@@ -125,8 +129,9 @@ const Slider = flowComponent("Slider", (props) => {
|
|
|
125
129
|
]
|
|
126
130
|
}
|
|
127
131
|
) }),
|
|
128
|
-
children
|
|
129
|
-
|
|
132
|
+
children,
|
|
133
|
+
/* @__PURE__ */ jsx(FieldErrorView, {})
|
|
134
|
+
] })
|
|
130
135
|
}
|
|
131
136
|
) });
|
|
132
137
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Slider.mjs","sources":["../../../../../../src/components/Slider/Slider.tsx"],"sourcesContent":["import { type PropsWithChildren } from \"react\";\nimport React from \"react\";\nimport type { FlowComponentProps } from \"@/lib/componentFactory/flowComponent\";\nimport { flowComponent } from \"@/lib/componentFactory/flowComponent\";\nimport * as Aria from \"react-aria-components\";\nimport clsx from \"clsx\";\nimport styles from \"./Slider.module.scss\";\nimport type { PropsContext } from \"@/lib/propsContext\";\nimport { PropsContextProvider } from \"@/lib/propsContext\";\nimport { Button } from \"@/components/Button\";\nimport { IconMinus, IconPlus } from \"@/components/Icon/components/icons\";\nimport locales from \"./locales/*.locale.json\";\nimport { useLocalizedStringFormatter } from \"react-aria\";\nimport { TunnelExit } from \"@mittwald/react-tunnel\";\nimport { useObjectRef } from \"@react-aria/utils\";\nimport { useMakeFocusable } from \"@/lib/hooks/dom/useMakeFocusable\";\n\nexport interface SliderProps\n extends FlowComponentProps,\n PropsWithChildren<Aria.SliderProps>,\n Pick<Aria.SliderThumbProps, \"inputRef\" | \"name\"> {\n showInitialMarker?: boolean;\n /** Whether the component is read only. */\n isReadOnly?: boolean;\n}\n\n/** @flr-generate all */\nexport const Slider = flowComponent(\"Slider\", (props) => {\n const {\n className,\n children,\n name,\n isDisabled,\n defaultValue,\n showInitialMarker,\n isReadOnly,\n ref,\n inputRef,\n ...rest\n } = props;\n\n const rootClassName = clsx(\n styles.slider,\n isDisabled && styles.disabled,\n className,\n );\n\n const stringFormatter = useLocalizedStringFormatter(locales);\n\n const localSliderRef = useObjectRef(ref);\n const localInputRef = useObjectRef(inputRef);\n\n useMakeFocusable(localSliderRef, () => {\n localInputRef.current?.focus();\n });\n\n const propsContext: PropsContext = {\n Label: {\n unstyled: true,\n tunnelId: \"label\",\n },\n };\n\n return (\n <
|
|
1
|
+
{"version":3,"file":"Slider.mjs","sources":["../../../../../../src/components/Slider/Slider.tsx"],"sourcesContent":["import { type PropsWithChildren } from \"react\";\nimport React from \"react\";\nimport type { FlowComponentProps } from \"@/lib/componentFactory/flowComponent\";\nimport { flowComponent } from \"@/lib/componentFactory/flowComponent\";\nimport * as Aria from \"react-aria-components\";\nimport clsx from \"clsx\";\nimport styles from \"./Slider.module.scss\";\nimport type { PropsContext } from \"@/lib/propsContext\";\nimport { PropsContextProvider } from \"@/lib/propsContext\";\nimport { Button } from \"@/components/Button\";\nimport { IconMinus, IconPlus } from \"@/components/Icon/components/icons\";\nimport locales from \"./locales/*.locale.json\";\nimport { useLocalizedStringFormatter } from \"react-aria\";\nimport { TunnelExit } from \"@mittwald/react-tunnel\";\nimport { useObjectRef } from \"@react-aria/utils\";\nimport { useMakeFocusable } from \"@/lib/hooks/dom/useMakeFocusable\";\nimport { useFieldComponent } from \"@/lib/hooks/useFieldComponent\";\n\nexport interface SliderProps\n extends FlowComponentProps,\n PropsWithChildren<Aria.SliderProps>,\n Pick<Aria.SliderThumbProps, \"inputRef\" | \"name\"> {\n showInitialMarker?: boolean;\n /** Whether the component is read only. */\n isReadOnly?: boolean;\n isInvalid?: boolean;\n}\n\n/** @flr-generate all */\nexport const Slider = flowComponent(\"Slider\", (props) => {\n const {\n className,\n children,\n name,\n isDisabled,\n defaultValue,\n showInitialMarker,\n isReadOnly,\n ref,\n inputRef,\n ...rest\n } = props;\n\n const rootClassName = clsx(\n styles.slider,\n isDisabled && styles.disabled,\n className,\n );\n\n const { FieldErrorView, fieldPropsContext, fieldProps } =\n useFieldComponent(props);\n\n const stringFormatter = useLocalizedStringFormatter(locales);\n\n const localSliderRef = useObjectRef(ref);\n const localInputRef = useObjectRef(inputRef);\n\n useMakeFocusable(localSliderRef, () => {\n localInputRef.current?.focus();\n });\n\n const propsContext: PropsContext = {\n ...fieldPropsContext,\n Label: {\n unstyled: true,\n tunnelId: \"label\",\n ...fieldPropsContext.Label,\n },\n };\n\n return (\n <div {...fieldProps}>\n <Aria.Slider\n {...rest}\n ref={localSliderRef}\n className={rootClassName}\n isDisabled={isDisabled}\n defaultValue={defaultValue}\n >\n <PropsContextProvider props={propsContext}>\n <div className={styles.text}>\n <Aria.SliderOutput className={styles.value} />\n <TunnelExit id=\"label\" />\n </div>\n\n <Aria.SliderTrack className={styles.track}>\n {({ state }) => (\n <PropsContextProvider\n props={{\n Button: {\n isPending: false,\n isFailed: false,\n isSucceeded: false,\n isReadOnly: isReadOnly,\n excludeFromTabOrder: true,\n isDisabled,\n variant: \"plain\",\n color: \"secondary\",\n },\n }}\n >\n <Button\n onPress={() => state.decrementThumb(0)}\n aria-label={stringFormatter.format(\"slider.decrement\")}\n className={styles.decrement}\n >\n <IconMinus />\n </Button>\n\n <Button\n onPress={() => state.incrementThumb(0)}\n aria-label={stringFormatter.format(\"slider.increment\")}\n className={styles.increment}\n >\n <IconPlus />\n </Button>\n\n <div\n className={styles.fill}\n style={{ width: state.getThumbPercent(0) * 100 + \"%\" }}\n />\n\n {showInitialMarker &&\n defaultValue &&\n typeof defaultValue === \"number\" && (\n <div\n className={styles.initialMarker}\n style={{\n left: `calc(${state.getValuePercent(defaultValue) * 100}% - 2px)`,\n }}\n />\n )}\n <Aria.SliderThumb\n inputRef={localInputRef}\n name={name}\n className={styles.handle}\n isDisabled={isReadOnly}\n />\n </PropsContextProvider>\n )}\n </Aria.SliderTrack>\n {children}\n <FieldErrorView />\n </PropsContextProvider>\n </Aria.Slider>\n </div>\n );\n});\n\nexport default Slider;\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AA6BO,MAAM,MAAA,GAAS,aAAA,CAAc,QAAA,EAAU,CAAC,KAAA,KAAU;AACvD,EAAA,MAAM;AAAA,IACJ,SAAA;AAAA,IACA,QAAA;AAAA,IACA,IAAA;AAAA,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C,KAAA;AAAA,gBAAA;AAAA,kBACC,WAAW,MAAA,CAAO,IAAA;AAAA,kBAClB,KAAA,EAAO,EAAE,KAAA,EAAO,KAAA,CAAM,gBAAgB,CAAC,CAAA,GAAI,MAAM,GAAA;AAAI;AAAA,eACvD;AAAA,cAEC,iBAAA,IACC,YAAA,IACA,OAAO,YAAA,KAAiB,QAAA,oBACtB,GAAA;AAAA,gBAAC,KAAA;AAAA,gBAAA;AAAA,kBACC,WAAW,MAAA,CAAO,aAAA;AAAA,kBAClB,KAAA,EAAO;AAAA,oBACL,MAAM,CAAA,KAAA,EAAQ,KAAA,CAAM,eAAA,CAAgB,YAAY,IAAI,GAAG,CAAA,QAAA;AAAA;AACzD;AAAA,eACF;AAAA,8BAEJ,GAAA;AAAA,gBAAC,IAAA,CAAK,WAAA;AAAA,gBAAL;AAAA,kBACC,QAAA,EAAU,aAAA;AAAA,kBACV,IAAA;AAAA,kBACA,WAAW,MAAA,CAAO,MAAA;AAAA,kBAClB,UAAA,EAAY;AAAA;AAAA;AACd;AAAA;AAAA,SACF,EAEJ,CAAA;AAAA,QACC,QAAA;AAAA,4BACA,cAAA,EAAA,EAAe;AAAA,OAAA,EAClB;AAAA;AAAA,GACF,EACF,CAAA;AAEJ,CAAC;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
/* */
|
|
3
|
-
import { jsxs, jsx
|
|
3
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
4
4
|
import 'react';
|
|
5
5
|
import * as Aria from 'react-aria-components';
|
|
6
6
|
import styles from './Switch.module.scss.mjs';
|
|
@@ -11,10 +11,11 @@ import '../../views/IconView.mjs';
|
|
|
11
11
|
import { IconCheck } from '../Icon/components/icons/IconCheck.mjs';
|
|
12
12
|
import { IconClose } from '../Icon/components/icons/IconClose.mjs';
|
|
13
13
|
import { flowComponent } from '../../lib/componentFactory/flowComponent.mjs';
|
|
14
|
+
import { useFieldComponent } from '../../lib/hooks/useFieldComponent.mjs';
|
|
14
15
|
import '../../lib/propsContext/propsContext.mjs';
|
|
15
16
|
import { PropsContextProvider } from '../../lib/propsContext/components/PropsContextProvider.mjs';
|
|
16
|
-
import { TunnelExit } from '@mittwald/react-tunnel';
|
|
17
17
|
import { useObjectRef } from '@react-aria/utils';
|
|
18
|
+
import styles$1 from '../Label/Label.module.scss.mjs';
|
|
18
19
|
import { useMakeFocusable } from '../../lib/hooks/dom/useMakeFocusable.mjs';
|
|
19
20
|
|
|
20
21
|
const Switch = flowComponent("Switch", (props) => {
|
|
@@ -28,41 +29,31 @@ const Switch = flowComponent("Switch", (props) => {
|
|
|
28
29
|
} = props;
|
|
29
30
|
const rootClassName = clsx(
|
|
30
31
|
styles.switch,
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
className,
|
|
33
|
+
styles[`label-${labelPosition}`]
|
|
33
34
|
);
|
|
34
35
|
const localSwitchRef = useObjectRef(ref);
|
|
35
36
|
const localInputRef = useObjectRef(inputRef);
|
|
36
37
|
useMakeFocusable(localSwitchRef, () => {
|
|
37
38
|
localInputRef.current?.focus();
|
|
38
39
|
});
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
children: ({ isSelected }) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
57
|
-
/* @__PURE__ */ jsx("div", { className: styles.track, children: /* @__PURE__ */ jsx("div", { className: styles.handle, children: isSelected ? /* @__PURE__ */ jsx(IconCheck, { size: "s" }) : /* @__PURE__ */ jsx(IconClose, { size: "s" }) }) }),
|
|
58
|
-
/* @__PURE__ */ jsx(TunnelExit, { id: "label" })
|
|
59
|
-
] })
|
|
60
|
-
}
|
|
61
|
-
),
|
|
62
|
-
children
|
|
63
|
-
]
|
|
64
|
-
}
|
|
65
|
-
);
|
|
40
|
+
const { FieldErrorView, fieldPropsContext, fieldProps } = useFieldComponent(props);
|
|
41
|
+
return /* @__PURE__ */ jsxs("div", { ...fieldProps, children: [
|
|
42
|
+
/* @__PURE__ */ jsx(
|
|
43
|
+
Aria.Switch,
|
|
44
|
+
{
|
|
45
|
+
...rest,
|
|
46
|
+
className: rootClassName,
|
|
47
|
+
ref: localSwitchRef,
|
|
48
|
+
inputRef: localInputRef,
|
|
49
|
+
children: ({ isSelected }) => /* @__PURE__ */ jsxs(PropsContextProvider, { props: fieldPropsContext, children: [
|
|
50
|
+
/* @__PURE__ */ jsx("div", { className: styles.track, children: /* @__PURE__ */ jsx("div", { className: styles.handle, children: isSelected ? /* @__PURE__ */ jsx(IconCheck, { size: "s" }) : /* @__PURE__ */ jsx(IconClose, { size: "s" }) }) }),
|
|
51
|
+
/* @__PURE__ */ jsx("div", { className: styles$1.label, children })
|
|
52
|
+
] })
|
|
53
|
+
}
|
|
54
|
+
),
|
|
55
|
+
/* @__PURE__ */ jsx(FieldErrorView, {})
|
|
56
|
+
] });
|
|
66
57
|
});
|
|
67
58
|
|
|
68
59
|
export { Switch, Switch as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Switch.mjs","sources":["../../../../../../src/components/Switch/Switch.tsx"],"sourcesContent":["import { type PropsWithChildren } from \"react\";\nimport * as Aria from \"react-aria-components\";\nimport styles from \"./Switch.module.scss\";\nimport clsx from \"clsx\";\nimport { IconCheck, IconClose } from \"@/components/Icon/components/icons\";\nimport type { FlowComponentProps } from \"@/lib/componentFactory/flowComponent\";\nimport { flowComponent } from \"@/lib/componentFactory/flowComponent\";\nimport {
|
|
1
|
+
{"version":3,"file":"Switch.mjs","sources":["../../../../../../src/components/Switch/Switch.tsx"],"sourcesContent":["import { type PropsWithChildren } from \"react\";\nimport * as Aria from \"react-aria-components\";\nimport styles from \"./Switch.module.scss\";\nimport clsx from \"clsx\";\nimport { IconCheck, IconClose } from \"@/components/Icon/components/icons\";\nimport type { FlowComponentProps } from \"@/lib/componentFactory/flowComponent\";\nimport { flowComponent } from \"@/lib/componentFactory/flowComponent\";\nimport { useFieldComponent } from \"@/lib/hooks/useFieldComponent\";\nimport { PropsContextProvider } from \"@/lib/propsContext\";\nimport { useObjectRef } from \"@react-aria/utils\";\nimport labelStyles from \"../Label/Label.module.scss\";\nimport { useMakeFocusable } from \"@/lib/hooks/dom/useMakeFocusable\";\n\nexport interface SwitchProps\n extends PropsWithChildren<Omit<Aria.SwitchProps, \"children\">>,\n FlowComponentProps<HTMLLabelElement> {\n /**\n * Whether the label should appear before or after the switch. @default\n * \"trailing\"\n */\n labelPosition?: \"leading\" | \"trailing\";\n}\n\n/** @flr-generate all */\nexport const Switch = flowComponent(\"Switch\", (props) => {\n const {\n children,\n className,\n labelPosition = \"trailing\",\n ref,\n inputRef,\n ...rest\n } = props;\n\n const rootClassName = clsx(\n styles.switch,\n className,\n styles[`label-${labelPosition}`],\n );\n\n const localSwitchRef = useObjectRef(ref);\n const localInputRef = useObjectRef(inputRef);\n\n useMakeFocusable(localSwitchRef, () => {\n localInputRef.current?.focus();\n });\n\n const { FieldErrorView, fieldPropsContext, fieldProps } =\n useFieldComponent(props);\n\n return (\n <div {...fieldProps}>\n <Aria.Switch\n {...rest}\n className={rootClassName}\n ref={localSwitchRef}\n inputRef={localInputRef}\n >\n {({ isSelected }) => (\n <PropsContextProvider props={fieldPropsContext}>\n <div className={styles.track}>\n <div className={styles.handle}>\n {isSelected ? <IconCheck size=\"s\" /> : <IconClose size=\"s\" />}\n </div>\n </div>\n <div className={labelStyles.label}>{children}</div>\n </PropsContextProvider>\n )}\n </Aria.Switch>\n <FieldErrorView />\n </div>\n );\n});\n\nexport default Switch;\n"],"names":["labelStyles"],"mappings":";;;;;;;;;;;;;;;;;;AAwBO,MAAM,MAAA,GAAS,aAAA,CAAc,QAAA,EAAU,CAAC,KAAA,KAAU;AACvD,EAAA,MAAM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,CAAC,KAAA,EAAA,EAAI,SAAA,EAAWA,QAAA,CAAY,OAAQ,QAAA,EAAS;AAAA,SAAA,EAC/C;AAAA;AAAA,KAEJ;AAAA,wBACC,cAAA,EAAA,EAAe;AAAA,GAAA,EAClB,CAAA;AAEJ,CAAC;;;;"}
|
|
@@ -2,14 +2,12 @@
|
|
|
2
2
|
/* */
|
|
3
3
|
const track = "flow--switch--track";
|
|
4
4
|
const handle = "flow--switch--handle";
|
|
5
|
-
const label = "flow--switch--label";
|
|
6
5
|
const styles = {
|
|
7
6
|
"switch": "flow--switch",
|
|
8
7
|
"label-leading": "flow--switch--label-leading",
|
|
9
8
|
track: track,
|
|
10
|
-
handle: handle
|
|
11
|
-
label: label
|
|
9
|
+
handle: handle
|
|
12
10
|
};
|
|
13
11
|
|
|
14
|
-
export { styles as default, handle,
|
|
12
|
+
export { styles as default, handle, track };
|
|
15
13
|
//# sourceMappingURL=Switch.module.scss.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Switch.module.scss.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Switch.module.scss.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;"}
|
|
@@ -7,6 +7,10 @@ import styles from './TextArea.module.scss.mjs';
|
|
|
7
7
|
import { flowComponent } from '../../lib/componentFactory/flowComponent.mjs';
|
|
8
8
|
import { useObjectRef } from '@react-aria/utils';
|
|
9
9
|
import { ReactAriaControlledValueFix } from '../../lib/react/ReactAriaControlledValueFix.mjs';
|
|
10
|
+
import { useFieldComponent } from '../../lib/hooks/useFieldComponent.mjs';
|
|
11
|
+
import '../../lib/propsContext/propsContext.mjs';
|
|
12
|
+
import { PropsContextProvider } from '../../lib/propsContext/components/PropsContextProvider.mjs';
|
|
13
|
+
import clsx from 'clsx';
|
|
10
14
|
|
|
11
15
|
const TextArea = flowComponent("TextArea", (props) => {
|
|
12
16
|
const {
|
|
@@ -49,7 +53,18 @@ const TextArea = flowComponent("TextArea", (props) => {
|
|
|
49
53
|
)
|
|
50
54
|
}
|
|
51
55
|
);
|
|
52
|
-
|
|
56
|
+
const { FieldErrorView, fieldPropsContext, fieldProps } = useFieldComponent(props);
|
|
57
|
+
return /* @__PURE__ */ jsx(
|
|
58
|
+
TextFieldBase,
|
|
59
|
+
{
|
|
60
|
+
...rest,
|
|
61
|
+
...fieldProps,
|
|
62
|
+
className: clsx(rest.className, fieldProps.className),
|
|
63
|
+
FieldErrorView,
|
|
64
|
+
input,
|
|
65
|
+
children: /* @__PURE__ */ jsx(PropsContextProvider, { props: fieldPropsContext, children })
|
|
66
|
+
}
|
|
67
|
+
);
|
|
53
68
|
});
|
|
54
69
|
|
|
55
70
|
export { TextArea, TextArea as default };
|
|
@@ -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\";\n\nexport interface TextAreaProps\n extends Omit<TextFieldBaseProps, \"input\" | \"ref\">,\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}\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 ...rest\n } = props;\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 updateHeight = () => {\n if (localRef.current && rows !== autoResizeMaxRows) {\n // https://stackoverflow.com/a/60795884\n localRef.current.style.height = \"0px\";\n const scrollHeight = localRef.current.scrollHeight;\n localRef.current.style.height = scrollHeight + \"px\";\n }\n };\n\n const input = (\n <ReactAriaControlledValueFix\n inputContext={Aria.TextAreaContext}\n props={props}\n >\n <Aria.TextArea\n rows={rows}\n placeholder={placeholder}\n className={styles.textArea}\n ref={localRef}\n onChange={updateHeight}\n style={{\n minHeight: getHeight(rows),\n maxHeight: getHeight(autoResizeMaxRows),\n }}\n />\n </ReactAriaControlledValueFix>\n );\n\n return (\n <TextFieldBase
|
|
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\";\n\nexport interface TextAreaProps\n extends Omit<TextFieldBaseProps, \"FieldErrorView\" | \"input\" | \"ref\">,\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}\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 ...rest\n } = props;\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 updateHeight = () => {\n if (localRef.current && rows !== autoResizeMaxRows) {\n // https://stackoverflow.com/a/60795884\n localRef.current.style.height = \"0px\";\n const scrollHeight = localRef.current.scrollHeight;\n localRef.current.style.height = scrollHeight + \"px\";\n }\n };\n\n const input = (\n <ReactAriaControlledValueFix\n inputContext={Aria.TextAreaContext}\n props={props}\n >\n <Aria.TextArea\n rows={rows}\n placeholder={placeholder}\n className={styles.textArea}\n ref={localRef}\n onChange={updateHeight}\n style={{\n minHeight: getHeight(rows),\n maxHeight: getHeight(autoResizeMaxRows),\n }}\n />\n </ReactAriaControlledValueFix>\n );\n\n const { FieldErrorView, fieldPropsContext, fieldProps } =\n useFieldComponent(props);\n\n return (\n <TextFieldBase\n {...rest}\n {...fieldProps}\n className={clsx(rest.className, fieldProps.className)}\n FieldErrorView={FieldErrorView}\n input={input}\n >\n <PropsContextProvider props={fieldPropsContext}>\n {children}\n </PropsContextProvider>\n </TextFieldBase>\n );\n});\n\nexport default TextArea;\n"],"names":["rows"],"mappings":";;;;;;;;;;;;AAwBO,MAAM,QAAA,GAAW,aAAA,CAAc,UAAA,EAAY,CAAC,KAAA,KAAU;AAC3D,EAAA,MAAM;AAAA,IACJ,QAAA;AAAA,IACA,WAAA;AAAA,IACA,IAAA,GAAO,CAAA;AAAA,IACP,iBAAA,GAAoB,IAAA;AAAA,IACpB,GAAA;AAAA,IACA,GAAG;AAAA,GACL,GAAI,KAAA;AAEJ,EAAA,MAAM,QAAA,GAAW,aAAa,GAAG,CAAA;AAEjC,EAAA,MAAM,SAAA,GAAY,CAACA,KAAAA,KAAiB;AAClC,IAAA,OAAO,gCAAgCA,KAAI,CAAA,wCAAA,CAAA;AAAA,EAC7C,CAAA;AAEA,EAAA,MAAM,eAAe,MAAM;AACzB,IAAA,IAAI,QAAA,CAAS,OAAA,IAAW,IAA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.module.scss.mjs';
|
|
7
7
|
import { flowComponent } from '../../lib/componentFactory/flowComponent.mjs';
|
|
8
8
|
import { ReactAriaControlledValueFix } from '../../lib/react/ReactAriaControlledValueFix.mjs';
|
|
9
|
+
import { useFieldComponent } from '../../lib/hooks/useFieldComponent.mjs';
|
|
10
|
+
import '../../lib/propsContext/propsContext.mjs';
|
|
11
|
+
import { PropsContextProvider } from '../../lib/propsContext/components/PropsContextProvider.mjs';
|
|
9
12
|
|
|
10
13
|
const TextField = flowComponent("TextField", (props) => {
|
|
11
14
|
const { children, placeholder, ref, form, ...rest } = props;
|
|
@@ -18,7 +21,17 @@ const TextField = flowComponent("TextField", (props) => {
|
|
|
18
21
|
ref
|
|
19
22
|
}
|
|
20
23
|
) });
|
|
21
|
-
|
|
24
|
+
const { FieldErrorView, fieldPropsContext, fieldProps } = useFieldComponent(props);
|
|
25
|
+
return /* @__PURE__ */ jsx(
|
|
26
|
+
TextFieldBase,
|
|
27
|
+
{
|
|
28
|
+
...rest,
|
|
29
|
+
...fieldProps,
|
|
30
|
+
FieldErrorView,
|
|
31
|
+
input,
|
|
32
|
+
children: /* @__PURE__ */ jsx(PropsContextProvider, { props: fieldPropsContext, children })
|
|
33
|
+
}
|
|
34
|
+
);
|
|
22
35
|
});
|
|
23
36
|
|
|
24
37
|
export { TextField, TextField as default };
|
|
@@ -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 { ReactAriaControlledValueFix } from \"@/lib/react/ReactAriaControlledValueFix\";\n\nexport interface TextFieldProps\n extends Omit<TextFieldBaseProps, \"input\" | \"className\">,\n Pick<Aria.InputProps, \"placeholder\" | \"form\">,\n PropsWithClassName,\n FlowComponentProps<HTMLInputElement> {}\n\n/** @flr-generate all */\nexport const TextField = flowComponent(\"TextField\", (props) => {\n const { children, placeholder, ref, form, ...rest } = props;\n\n const input = (\n <ReactAriaControlledValueFix inputContext={Aria.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 return (\n <TextFieldBase
|
|
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 { ReactAriaControlledValueFix } from \"@/lib/react/ReactAriaControlledValueFix\";\nimport { useFieldComponent } from \"@/lib/hooks/useFieldComponent\";\nimport { PropsContextProvider } from \"@/lib/propsContext\";\n\nexport interface TextFieldProps\n extends Omit<TextFieldBaseProps, \"FieldErrorView\" | \"input\" | \"className\">,\n Pick<Aria.InputProps, \"placeholder\" | \"form\">,\n PropsWithClassName,\n FlowComponentProps<HTMLInputElement> {}\n\n/** @flr-generate all */\nexport const TextField = flowComponent(\"TextField\", (props) => {\n const { children, placeholder, ref, form, ...rest } = props;\n\n const input = (\n <ReactAriaControlledValueFix inputContext={Aria.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 { FieldErrorView, fieldPropsContext, fieldProps } =\n useFieldComponent(props);\n\n return (\n <TextFieldBase\n {...rest}\n {...fieldProps}\n FieldErrorView={FieldErrorView}\n input={input}\n >\n <PropsContextProvider props={fieldPropsContext}>\n {children}\n </PropsContextProvider>\n </TextFieldBase>\n );\n});\n\nexport default TextField;\n"],"names":[],"mappings":";;;;;;;;;;AAoBO,MAAM,SAAA,GAAY,aAAA,CAAc,WAAA,EAAa,CAAC,KAAA,KAAU;AAC7D,EAAA,MAAM,EAAE,QAAA,EAAU,WAAA,EAAa,KAAK,IAAA,EAAM,GAAG,MAAK,GAAI,KAAA;AAEtD,EAAA,MAAM,wBACJ,GAAA,CAAC,2BAAA,EAAA,EAA4B,YAAA,EAAc,IAAA,CAAK,cAAc,KAAA,EAC5D,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,EAAE,cAAA,EAAgB,iBAAA,EAAmB,UAAA,EAAW,GACpD,kBAAkB,KAAK,CAAA;AAEzB,EAAA,uBACE,GAAA;AAAA,IAAC,aAAA;AAAA,IAAA;AAAA,MACE,GAAG,IAAA;AAAA,MACH,GAAG,UAAA;AAAA,MACJ,cAAA;AAAA,MACA,KAAA;AAAA,MAEA,QAAA,kBAAA,GAAA,CAAC,oBAAA,EAAA,EAAqB,KAAA,EAAO,iBAAA,EAC1B,QAAA,EACH;AAAA;AAAA,GACF;AAEJ,CAAC;;;;"}
|