@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.
Files changed (160) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/assets/doc-properties.json +291 -253
  3. package/dist/css/all.css +1 -1
  4. package/dist/js/components/src/components/Autocomplete/Autocomplete.mjs +48 -36
  5. package/dist/js/components/src/components/Autocomplete/Autocomplete.mjs.map +1 -1
  6. package/dist/js/components/src/components/Checkbox/Checkbox.mjs +25 -7
  7. package/dist/js/components/src/components/Checkbox/Checkbox.mjs.map +1 -1
  8. package/dist/js/components/src/components/Checkbox/Checkbox.module.scss.mjs +3 -1
  9. package/dist/js/components/src/components/Checkbox/Checkbox.module.scss.mjs.map +1 -1
  10. package/dist/js/components/src/components/CheckboxButton/CheckboxButton.mjs +28 -6
  11. package/dist/js/components/src/components/CheckboxButton/CheckboxButton.mjs.map +1 -1
  12. package/dist/js/components/src/components/CheckboxButton/CheckboxButton.module.scss.mjs +6 -4
  13. package/dist/js/components/src/components/CheckboxButton/CheckboxButton.module.scss.mjs.map +1 -1
  14. package/dist/js/components/src/components/CheckboxGroup/CheckboxGroup.mjs +22 -26
  15. package/dist/js/components/src/components/CheckboxGroup/CheckboxGroup.mjs.map +1 -1
  16. package/dist/js/components/src/components/ComboBox/ComboBox.mjs +31 -27
  17. package/dist/js/components/src/components/ComboBox/ComboBox.mjs.map +1 -1
  18. package/dist/js/components/src/components/DatePicker/DatePicker.mjs +8 -18
  19. package/dist/js/components/src/components/DatePicker/DatePicker.mjs.map +1 -1
  20. package/dist/js/components/src/components/DateRangePicker/DateRangePicker.mjs +7 -19
  21. package/dist/js/components/src/components/DateRangePicker/DateRangePicker.mjs.map +1 -1
  22. package/dist/js/components/src/components/FieldError/FieldError.mjs +36 -5
  23. package/dist/js/components/src/components/FieldError/FieldError.mjs.map +1 -1
  24. package/dist/js/components/src/components/FileDropZone/FileDropZone.mjs +22 -11
  25. package/dist/js/components/src/components/FileDropZone/FileDropZone.mjs.map +1 -1
  26. package/dist/js/components/src/components/FileField/FileField.mjs +33 -31
  27. package/dist/js/components/src/components/FileField/FileField.mjs.map +1 -1
  28. package/dist/js/components/src/components/FormField/FormField.module.scss.mjs +1 -3
  29. package/dist/js/components/src/components/FormField/FormField.module.scss.mjs.map +1 -1
  30. package/dist/js/components/src/components/NumberField/NumberField.mjs +9 -18
  31. package/dist/js/components/src/components/NumberField/NumberField.mjs.map +1 -1
  32. package/dist/js/components/src/components/PasswordCreationField/PasswordCreationField.mjs +85 -79
  33. package/dist/js/components/src/components/PasswordCreationField/PasswordCreationField.mjs.map +1 -1
  34. package/dist/js/components/src/components/PasswordCreationField/lib/generateValidationTranslation.mjs +1 -0
  35. package/dist/js/components/src/components/PasswordCreationField/lib/generateValidationTranslation.mjs.map +1 -1
  36. package/dist/js/components/src/components/PasswordCreationField/lib/getStateFromLatestPolicyValidationResult.mjs +1 -0
  37. package/dist/js/components/src/components/PasswordCreationField/lib/getStateFromLatestPolicyValidationResult.mjs.map +1 -1
  38. package/dist/js/components/src/components/PasswordCreationField/worker/generatePassword.mjs +1 -0
  39. package/dist/js/components/src/components/PasswordCreationField/worker/generatePassword.mjs.map +1 -1
  40. package/dist/js/components/src/components/RadioGroup/RadioGroup.mjs +36 -34
  41. package/dist/js/components/src/components/RadioGroup/RadioGroup.mjs.map +1 -1
  42. package/dist/js/components/src/components/SearchField/SearchField.mjs +12 -17
  43. package/dist/js/components/src/components/SearchField/SearchField.mjs.map +1 -1
  44. package/dist/js/components/src/components/SegmentedControl/SegmentedControl.mjs +25 -23
  45. package/dist/js/components/src/components/SegmentedControl/SegmentedControl.mjs.map +1 -1
  46. package/dist/js/components/src/components/Select/Select.mjs +30 -30
  47. package/dist/js/components/src/components/Select/Select.mjs.map +1 -1
  48. package/dist/js/components/src/components/Slider/Slider.mjs +10 -5
  49. package/dist/js/components/src/components/Slider/Slider.mjs.map +1 -1
  50. package/dist/js/components/src/components/Switch/Switch.mjs +22 -31
  51. package/dist/js/components/src/components/Switch/Switch.mjs.map +1 -1
  52. package/dist/js/components/src/components/Switch/Switch.module.scss.mjs +2 -4
  53. package/dist/js/components/src/components/Switch/Switch.module.scss.mjs.map +1 -1
  54. package/dist/js/components/src/components/TextArea/TextArea.mjs +16 -1
  55. package/dist/js/components/src/components/TextArea/TextArea.mjs.map +1 -1
  56. package/dist/js/components/src/components/TextField/TextField.mjs +14 -1
  57. package/dist/js/components/src/components/TextField/TextField.mjs.map +1 -1
  58. package/dist/js/components/src/components/TextFieldBase/TextFieldBase.mjs +13 -22
  59. package/dist/js/components/src/components/TextFieldBase/TextFieldBase.mjs.map +1 -1
  60. package/dist/js/components/src/components/TimeField/TimeField.mjs +8 -32
  61. package/dist/js/components/src/components/TimeField/TimeField.mjs.map +1 -1
  62. package/dist/js/components/src/integrations/@mittwald/password-tools-js/generatePasswordCreationFieldValidation.mjs +19 -13
  63. package/dist/js/components/src/integrations/@mittwald/password-tools-js/generatePasswordCreationFieldValidation.mjs.map +1 -1
  64. package/dist/js/components/src/integrations/react-hook-form/components/Field/Field.mjs +29 -14
  65. package/dist/js/components/src/integrations/react-hook-form/components/Field/Field.mjs.map +1 -1
  66. package/dist/js/components/src/lib/hooks/useFieldComponent.mjs +36 -0
  67. package/dist/js/components/src/lib/hooks/useFieldComponent.mjs.map +1 -0
  68. package/dist/js/components/src/lib/hooks/useFieldError.mjs +43 -0
  69. package/dist/js/components/src/lib/hooks/useFieldError.mjs.map +1 -0
  70. package/dist/js/components/src/lib/hooks/useManagedValue.mjs +7 -3
  71. package/dist/js/components/src/lib/hooks/useManagedValue.mjs.map +1 -1
  72. package/dist/types/components/Autocomplete/Autocomplete.d.ts +1 -0
  73. package/dist/types/components/Autocomplete/Autocomplete.d.ts.map +1 -1
  74. package/dist/types/components/Checkbox/Checkbox.d.ts +3 -2
  75. package/dist/types/components/Checkbox/Checkbox.d.ts.map +1 -1
  76. package/dist/types/components/CheckboxButton/CheckboxButton.d.ts +2 -2
  77. package/dist/types/components/CheckboxButton/CheckboxButton.d.ts.map +1 -1
  78. package/dist/types/components/CheckboxGroup/CheckboxGroup.d.ts.map +1 -1
  79. package/dist/types/components/ComboBox/ComboBox.d.ts.map +1 -1
  80. package/dist/types/components/ComboBox/stories/Default.stories.d.ts.map +1 -1
  81. package/dist/types/components/DatePicker/DatePicker.d.ts +1 -3
  82. package/dist/types/components/DatePicker/DatePicker.d.ts.map +1 -1
  83. package/dist/types/components/DatePicker/stories/Default.stories.d.ts.map +1 -1
  84. package/dist/types/components/DateRangePicker/DateRangePicker.d.ts +1 -3
  85. package/dist/types/components/DateRangePicker/DateRangePicker.d.ts.map +1 -1
  86. package/dist/types/components/DateRangePicker/stories/Default.stories.d.ts.map +1 -1
  87. package/dist/types/components/FieldError/FieldError.d.ts +2 -2
  88. package/dist/types/components/FieldError/FieldError.d.ts.map +1 -1
  89. package/dist/types/components/FileDropZone/FileDropZone.d.ts.map +1 -1
  90. package/dist/types/components/FileDropZone/stories/Default.stories.d.ts.map +1 -1
  91. package/dist/types/components/FileField/FileField.d.ts.map +1 -1
  92. package/dist/types/components/NumberField/NumberField.d.ts +2 -2
  93. package/dist/types/components/NumberField/NumberField.d.ts.map +1 -1
  94. package/dist/types/components/PasswordCreationField/PasswordCreationField.d.ts.map +1 -1
  95. package/dist/types/components/RadioGroup/RadioGroup.d.ts.map +1 -1
  96. package/dist/types/components/SearchField/SearchField.d.ts.map +1 -1
  97. package/dist/types/components/SegmentedControl/SegmentedControl.d.ts.map +1 -1
  98. package/dist/types/components/Select/Select.d.ts.map +1 -1
  99. package/dist/types/components/Slider/Slider.d.ts +1 -0
  100. package/dist/types/components/Slider/Slider.d.ts.map +1 -1
  101. package/dist/types/components/Switch/Switch.d.ts.map +1 -1
  102. package/dist/types/components/TextArea/TextArea.d.ts +1 -1
  103. package/dist/types/components/TextArea/TextArea.d.ts.map +1 -1
  104. package/dist/types/components/TextField/TextField.d.ts +1 -1
  105. package/dist/types/components/TextField/TextField.d.ts.map +1 -1
  106. package/dist/types/components/TextFieldBase/TextFieldBase.d.ts +2 -1
  107. package/dist/types/components/TextFieldBase/TextFieldBase.d.ts.map +1 -1
  108. package/dist/types/components/TimeField/TimeField.d.ts +2 -4
  109. package/dist/types/components/TimeField/TimeField.d.ts.map +1 -1
  110. package/dist/types/integrations/@mittwald/password-tools-js/generatePasswordCreationFieldValidation.d.ts.map +1 -1
  111. package/dist/types/integrations/react-hook-form/components/Field/Field.d.ts.map +1 -1
  112. package/dist/types/integrations/react-hook-form/components/Field/stories/Autocomplete.stories.d.ts +2 -1
  113. package/dist/types/integrations/react-hook-form/components/Field/stories/Autocomplete.stories.d.ts.map +1 -1
  114. package/dist/types/integrations/react-hook-form/components/Field/stories/Checkbox.stories.d.ts +2 -1
  115. package/dist/types/integrations/react-hook-form/components/Field/stories/Checkbox.stories.d.ts.map +1 -1
  116. package/dist/types/integrations/react-hook-form/components/Field/stories/CheckboxButton.stories.d.ts +9 -0
  117. package/dist/types/integrations/react-hook-form/components/Field/stories/CheckboxButton.stories.d.ts.map +1 -0
  118. package/dist/types/integrations/react-hook-form/components/Field/stories/CheckboxGroup.stories.d.ts +2 -1
  119. package/dist/types/integrations/react-hook-form/components/Field/stories/CheckboxGroup.stories.d.ts.map +1 -1
  120. package/dist/types/integrations/react-hook-form/components/Field/stories/ComboBox.stories.d.ts +2 -1
  121. package/dist/types/integrations/react-hook-form/components/Field/stories/ComboBox.stories.d.ts.map +1 -1
  122. package/dist/types/integrations/react-hook-form/components/Field/stories/DatePicker.stories.d.ts +2 -1
  123. package/dist/types/integrations/react-hook-form/components/Field/stories/DatePicker.stories.d.ts.map +1 -1
  124. package/dist/types/integrations/react-hook-form/components/Field/stories/DateRangePicker.stories.d.ts +2 -1
  125. package/dist/types/integrations/react-hook-form/components/Field/stories/DateRangePicker.stories.d.ts.map +1 -1
  126. package/dist/types/integrations/react-hook-form/components/Field/stories/FileField.stories.d.ts +2 -1
  127. package/dist/types/integrations/react-hook-form/components/Field/stories/FileField.stories.d.ts.map +1 -1
  128. package/dist/types/integrations/react-hook-form/components/Field/stories/MarkdownEditor.stories.d.ts +2 -1
  129. package/dist/types/integrations/react-hook-form/components/Field/stories/MarkdownEditor.stories.d.ts.map +1 -1
  130. package/dist/types/integrations/react-hook-form/components/Field/stories/NumberField.stories.d.ts +2 -1
  131. package/dist/types/integrations/react-hook-form/components/Field/stories/NumberField.stories.d.ts.map +1 -1
  132. package/dist/types/integrations/react-hook-form/components/Field/stories/PasswordCreationField.stories.d.ts +2 -1
  133. package/dist/types/integrations/react-hook-form/components/Field/stories/PasswordCreationField.stories.d.ts.map +1 -1
  134. package/dist/types/integrations/react-hook-form/components/Field/stories/RadioGroup.stories.d.ts +2 -1
  135. package/dist/types/integrations/react-hook-form/components/Field/stories/RadioGroup.stories.d.ts.map +1 -1
  136. package/dist/types/integrations/react-hook-form/components/Field/stories/SearchField.stories.d.ts +2 -1
  137. package/dist/types/integrations/react-hook-form/components/Field/stories/SearchField.stories.d.ts.map +1 -1
  138. package/dist/types/integrations/react-hook-form/components/Field/stories/SegmentedControl.stories.d.ts +2 -1
  139. package/dist/types/integrations/react-hook-form/components/Field/stories/SegmentedControl.stories.d.ts.map +1 -1
  140. package/dist/types/integrations/react-hook-form/components/Field/stories/Select.stories.d.ts +2 -1
  141. package/dist/types/integrations/react-hook-form/components/Field/stories/Select.stories.d.ts.map +1 -1
  142. package/dist/types/integrations/react-hook-form/components/Field/stories/Slider.stories.d.ts +2 -1
  143. package/dist/types/integrations/react-hook-form/components/Field/stories/Slider.stories.d.ts.map +1 -1
  144. package/dist/types/integrations/react-hook-form/components/Field/stories/Switch.stories.d.ts +2 -1
  145. package/dist/types/integrations/react-hook-form/components/Field/stories/Switch.stories.d.ts.map +1 -1
  146. package/dist/types/integrations/react-hook-form/components/Field/stories/TextArea.stories.d.ts +2 -1
  147. package/dist/types/integrations/react-hook-form/components/Field/stories/TextArea.stories.d.ts.map +1 -1
  148. package/dist/types/integrations/react-hook-form/components/Field/stories/TextField.stories.d.ts +2 -1
  149. package/dist/types/integrations/react-hook-form/components/Field/stories/TextField.stories.d.ts.map +1 -1
  150. package/dist/types/integrations/react-hook-form/components/Field/stories/TimeField.stories.d.ts +2 -1
  151. package/dist/types/integrations/react-hook-form/components/Field/stories/TimeField.stories.d.ts.map +1 -1
  152. package/dist/types/lib/hooks/useFieldComponent.d.ts +19 -0
  153. package/dist/types/lib/hooks/useFieldComponent.d.ts.map +1 -0
  154. package/dist/types/lib/hooks/useFieldError.d.ts +10 -0
  155. package/dist/types/lib/hooks/useFieldError.d.ts.map +1 -0
  156. package/dist/types/lib/hooks/useManagedValue.d.ts +9 -7
  157. package/dist/types/lib/hooks/useManagedValue.d.ts.map +1 -1
  158. package/package.json +4 -4
  159. package/dist/js/components/src/views/FieldErrorView.mjs +0 -15
  160. package/dist/js/components/src/views/FieldErrorView.mjs.map +0 -1
@@ -7,7 +7,6 @@ import '../../lib/propsContext/propsContext.mjs';
7
7
  import { PropsContextProvider } from '../../lib/propsContext/components/PropsContextProvider.mjs';
8
8
  import * as Aria from 'react-aria-components';
9
9
  import { DateInput } from './components/DateInput/DateInput.mjs';
10
- import { FieldError } from '../FieldError/FieldError.mjs';
11
10
  import formFieldStyles from '../FormField/FormField.module.scss.mjs';
12
11
  import { Popover } from '../Popover/Popover.mjs';
13
12
  import 'mobx';
@@ -20,22 +19,12 @@ import '../Icon/Icon.mjs';
20
19
  import '../../views/IconView.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 DatePicker = flowComponent("DatePicker", (props) => {
25
- const { children, className, errorMessage, onChange, ref, ...rest } = props;
25
+ const { children, className, onChange, ref, ...rest } = props;
26
+ const { FieldErrorView, fieldProps, fieldPropsContext } = useFieldComponent(props);
26
27
  const rootClassName = clsx(formFieldStyles.formField, className);
27
- const propsContext = {
28
- Label: {
29
- className: formFieldStyles.label,
30
- optional: !props.isRequired
31
- },
32
- FieldDescription: {
33
- className: formFieldStyles.fieldDescription
34
- },
35
- FieldError: {
36
- className: formFieldStyles.customFieldError
37
- }
38
- };
39
28
  const localRef = useObjectRef(ref);
40
29
  useMakeFocusable(localRef);
41
30
  const popoverController = useOverlayController("Popover");
@@ -44,7 +33,8 @@ const DatePicker = flowComponent("DatePicker", (props) => {
44
33
  {
45
34
  ref: localRef,
46
35
  ...rest,
47
- className: rootClassName,
36
+ ...fieldProps,
37
+ className: clsx(fieldProps.className, rootClassName),
48
38
  onOpenChange: (v) => popoverController.setOpen(v),
49
39
  isOpen: popoverController.isOpen,
50
40
  onChange: (value) => {
@@ -55,8 +45,7 @@ const DatePicker = flowComponent("DatePicker", (props) => {
55
45
  },
56
46
  children: [
57
47
  /* @__PURE__ */ jsx(DateInput, { isDisabled: props.isDisabled }),
58
- /* @__PURE__ */ jsx(PropsContextProvider, { props: propsContext, children }),
59
- /* @__PURE__ */ jsx(FieldError, { className: formFieldStyles.fieldError, children: errorMessage }),
48
+ /* @__PURE__ */ jsx(PropsContextProvider, { props: fieldPropsContext, children }),
60
49
  /* @__PURE__ */ jsx(
61
50
  Popover,
62
51
  {
@@ -65,7 +54,8 @@ const DatePicker = flowComponent("DatePicker", (props) => {
65
54
  controller: popoverController,
66
55
  children: /* @__PURE__ */ jsx(Calendar, {})
67
56
  }
68
- )
57
+ ),
58
+ /* @__PURE__ */ jsx(FieldErrorView, {})
69
59
  ]
70
60
  }
71
61
  );
@@ -1 +1 @@
1
- {"version":3,"file":"DatePicker.mjs","sources":["../../../../../../src/components/DatePicker/DatePicker.tsx"],"sourcesContent":["import { type PropsWithChildren, type ReactNode } from \"react\";\nimport clsx from \"clsx\";\nimport type { PropsContext } from \"@/lib/propsContext\";\nimport { PropsContextProvider } from \"@/lib/propsContext\";\nimport * as Aria from \"react-aria-components\";\nimport { DateInput } from \"./components/DateInput\";\nimport { FieldError } from \"@/components/FieldError\";\nimport styles from \"../FormField/FormField.module.scss\";\nimport { Popover } from \"@/components/Popover/Popover\";\nimport { useOverlayController } from \"@/lib/controller\";\nimport {\n flowComponent,\n type FlowComponentProps,\n} from \"@/lib/componentFactory/flowComponent\";\nimport { Calendar } from \"@/components/Calendar\";\nimport { useObjectRef } from \"@react-aria/utils\";\nimport { useMakeFocusable } from \"@/lib/hooks/dom/useMakeFocusable\";\n\nexport interface DatePickerProps<T extends Aria.DateValue = Aria.DateValue>\n extends PropsWithChildren<Omit<Aria.DatePickerProps<T>, \"children\">>,\n FlowComponentProps {\n /** The error message that is displayed below the input. */\n errorMessage?: ReactNode;\n}\n\n/** @flr-generate all */\nexport const DatePicker = flowComponent(\"DatePicker\", (props) => {\n const { children, className, errorMessage, onChange, ref, ...rest } = props;\n\n const rootClassName = clsx(styles.formField, className);\n\n const propsContext: PropsContext = {\n Label: {\n className: styles.label,\n optional: !props.isRequired,\n },\n FieldDescription: {\n className: styles.fieldDescription,\n },\n FieldError: {\n className: styles.customFieldError,\n },\n };\n\n const localRef = useObjectRef(ref);\n useMakeFocusable(localRef);\n\n const popoverController = useOverlayController(\"Popover\");\n\n return (\n <Aria.DatePicker\n ref={localRef}\n {...rest}\n className={rootClassName}\n onOpenChange={(v) => popoverController.setOpen(v)}\n isOpen={popoverController.isOpen}\n onChange={(value) => {\n if (onChange) {\n onChange(value);\n }\n popoverController.close();\n }}\n >\n <DateInput isDisabled={props.isDisabled} />\n <PropsContextProvider props={propsContext}>\n {children}\n </PropsContextProvider>\n <FieldError className={styles.fieldError}>{errorMessage}</FieldError>\n <Popover\n placement=\"bottom end\"\n isDialogContent\n controller={popoverController}\n >\n <Calendar />\n </Popover>\n </Aria.DatePicker>\n );\n});\n\nexport default DatePicker;\n"],"names":["styles"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA0BO,MAAM,UAAA,GAAa,aAAA,CAAc,YAAA,EAAc,CAAC,KAAA,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B,QAAA,EACH,CAAA;AAAA,wBACA,GAAA,CAAC,UAAA,EAAA,EAAW,SAAA,EAAWA,eAAA,CAAO,YAAa,QAAA,EAAA,YAAA,EAAa,CAAA;AAAA,wBACxD,GAAA;AAAA,UAAC,OAAA;AAAA,UAAA;AAAA,YACC,SAAA,EAAU,YAAA;AAAA,YACV,eAAA,EAAe,IAAA;AAAA,YACf,UAAA,EAAY,iBAAA;AAAA,YAEZ,8BAAC,QAAA,EAAA,EAAS;AAAA;AAAA;AACZ;AAAA;AAAA,GACF;AAEJ,CAAC;;;;"}
1
+ {"version":3,"file":"DatePicker.mjs","sources":["../../../../../../src/components/DatePicker/DatePicker.tsx"],"sourcesContent":["import { type PropsWithChildren } from \"react\";\nimport clsx from \"clsx\";\nimport { PropsContextProvider } from \"@/lib/propsContext\";\nimport * as Aria from \"react-aria-components\";\nimport { DateInput } from \"./components/DateInput\";\nimport styles from \"../FormField/FormField.module.scss\";\nimport { Popover } from \"@/components/Popover/Popover\";\nimport { useOverlayController } from \"@/lib/controller\";\nimport {\n flowComponent,\n type FlowComponentProps,\n} from \"@/lib/componentFactory/flowComponent\";\nimport { Calendar } from \"@/components/Calendar\";\nimport { useObjectRef } from \"@react-aria/utils\";\nimport { useMakeFocusable } from \"@/lib/hooks/dom/useMakeFocusable\";\nimport { useFieldComponent } from \"@/lib/hooks/useFieldComponent\";\n\nexport interface DatePickerProps<T extends Aria.DateValue = Aria.DateValue>\n extends PropsWithChildren<Omit<Aria.DatePickerProps<T>, \"children\">>,\n FlowComponentProps {}\n\n/** @flr-generate all */\nexport const DatePicker = flowComponent(\"DatePicker\", (props) => {\n const { children, className, onChange, ref, ...rest } = props;\n\n const { FieldErrorView, fieldProps, fieldPropsContext } =\n useFieldComponent(props);\n\n const rootClassName = clsx(styles.formField, className);\n\n const localRef = useObjectRef(ref);\n useMakeFocusable(localRef);\n\n const popoverController = useOverlayController(\"Popover\");\n\n return (\n <Aria.DatePicker\n ref={localRef}\n {...rest}\n {...fieldProps}\n className={clsx(fieldProps.className, rootClassName)}\n onOpenChange={(v) => popoverController.setOpen(v)}\n isOpen={popoverController.isOpen}\n onChange={(value) => {\n if (onChange) {\n onChange(value);\n }\n popoverController.close();\n }}\n >\n <DateInput isDisabled={props.isDisabled} />\n <PropsContextProvider props={fieldPropsContext}>\n {children}\n </PropsContextProvider>\n <Popover\n placement=\"bottom end\"\n isDialogContent\n controller={popoverController}\n >\n <Calendar />\n </Popover>\n <FieldErrorView />\n </Aria.DatePicker>\n );\n});\n\nexport default DatePicker;\n"],"names":["styles"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAsBO,MAAM,UAAA,GAAa,aAAA,CAAc,YAAA,EAAc,CAAC,KAAA,KAAU;AAC/D,EAAA,MAAM,EAAE,QAAA,EAAU,SAAA,EAAW,UAAU,GAAA,EAAK,GAAG,MAAK,GAAI,KAAA;AAExD,EAAA,MAAM,EAAE,cAAA,EAAgB,UAAA,EAAY,iBAAA,EAAkB,GACpD,kBAAkB,KAAK,CAAA;AAEzB,EAAA,MAAM,aAAA,GAAgB,IAAA,CAAKA,eAAA,CAAO,SAAA,EAAW,SAAS,CAAA;AAEtD,EAAA,MAAM,QAAA,GAAW,aAAa,GAAG,CAAA;AACjC,EAAA,gBAAA,CAAiB,QAAQ,CAAA;AAEzB,EAAA,MAAM,iBAAA,GAAoB,qBAAqB,SAAS,CAAA;AAExD,EAAA,uBACE,IAAA;AAAA,IAAC,IAAA,CAAK,UAAA;AAAA,IAAL;AAAA,MACC,GAAA,EAAK,QAAA;AAAA,MACJ,GAAG,IAAA;AAAA,MACH,GAAG,UAAA;AAAA,MACJ,SAAA,EAAW,IAAA,CAAK,UAAA,CAAW,SAAA,EAAW,aAAa,CAAA;AAAA,MACnD,YAAA,EAAc,CAAC,CAAA,KAAM,iBAAA,CAAkB,QAAQ,CAAC,CAAA;AAAA,MAChD,QAAQ,iBAAA,CAAkB,MAAA;AAAA,MAC1B,QAAA,EAAU,CAAC,KAAA,KAAU;AACnB,QAAA,IAAI,QAAA,EAAU;AACZ,UAAA,QAAA,CAAS,KAAK,CAAA;AAAA,QAChB;AACA,QAAA,iBAAA,CAAkB,KAAA,EAAM;AAAA,MAC1B,CAAA;AAAA,MAEA,QAAA,EAAA;AAAA,wBAAA,GAAA,CAAC,SAAA,EAAA,EAAU,UAAA,EAAY,KAAA,CAAM,UAAA,EAAY,CAAA;AAAA,wBACzC,GAAA,CAAC,oBAAA,EAAA,EAAqB,KAAA,EAAO,iBAAA,EAC1B,QAAA,EACH,CAAA;AAAA,wBACA,GAAA;AAAA,UAAC,OAAA;AAAA,UAAA;AAAA,YACC,SAAA,EAAU,YAAA;AAAA,YACV,eAAA,EAAe,IAAA;AAAA,YACf,UAAA,EAAY,iBAAA;AAAA,YAEZ,8BAAC,QAAA,EAAA,EAAS;AAAA;AAAA,SACZ;AAAA,4BACC,cAAA,EAAA,EAAe;AAAA;AAAA;AAAA,GAClB;AAEJ,CAAC;;;;"}
@@ -1,7 +1,6 @@
1
1
  "use client"
2
2
  /* */
3
3
  import { jsxs, jsx } from 'react/jsx-runtime';
4
- import formFieldStyles from '../FormField/FormField.module.scss.mjs';
5
4
  import clsx from 'clsx';
6
5
  import '../../lib/propsContext/propsContext.mjs';
7
6
  import { PropsContextProvider } from '../../lib/propsContext/components/PropsContextProvider.mjs';
@@ -9,29 +8,18 @@ import * as Aria from 'react-aria-components';
9
8
  import { Popover } from '../Popover/Popover.mjs';
10
9
  import { RangeCalendar } from '../Calendar/RangeCalendar.mjs';
11
10
  import { DateRangeInput } from './components/DateRangeInput/DateRangeInput.mjs';
12
- import { FieldError } from '../FieldError/FieldError.mjs';
13
11
  import 'mobx';
14
12
  import 'react';
15
13
  import { useOverlayController } from '../../lib/controller/overlay/useOverlayController.mjs';
16
14
  import { flowComponent } from '../../lib/componentFactory/flowComponent.mjs';
17
15
  import { useMakeFocusable } from '../../lib/hooks/dom/useMakeFocusable.mjs';
18
16
  import { useObjectRef } from '@react-aria/utils';
17
+ import { useFieldComponent } from '../../lib/hooks/useFieldComponent.mjs';
19
18
 
20
19
  const DateRangePicker = flowComponent("DateRangePicker", (props) => {
21
- const { children, className, errorMessage, onChange, ref, ...rest } = props;
22
- const rootClassName = clsx(formFieldStyles.formField, className);
23
- const propsContext = {
24
- Label: {
25
- className: formFieldStyles.label,
26
- optional: !props.isRequired
27
- },
28
- FieldDescription: {
29
- className: formFieldStyles.fieldDescription
30
- },
31
- FieldError: {
32
- className: formFieldStyles.customFieldError
33
- }
34
- };
20
+ const { children, className, onChange, ref, ...rest } = props;
21
+ const { FieldErrorView, fieldProps, fieldPropsContext } = useFieldComponent(props);
22
+ const rootClassName = clsx(fieldProps.className, className);
35
23
  const popoverController = useOverlayController("Popover");
36
24
  const localDateRangePickerRef = useObjectRef(ref);
37
25
  useMakeFocusable(localDateRangePickerRef);
@@ -51,8 +39,7 @@ const DateRangePicker = flowComponent("DateRangePicker", (props) => {
51
39
  },
52
40
  children: [
53
41
  /* @__PURE__ */ jsx(DateRangeInput, { isDisabled: props.isDisabled }),
54
- /* @__PURE__ */ jsx(PropsContextProvider, { props: propsContext, children }),
55
- /* @__PURE__ */ jsx(FieldError, { className: formFieldStyles.fieldError, children: errorMessage }),
42
+ /* @__PURE__ */ jsx(PropsContextProvider, { props: fieldPropsContext, children }),
56
43
  /* @__PURE__ */ jsx(
57
44
  Popover,
58
45
  {
@@ -61,7 +48,8 @@ const DateRangePicker = flowComponent("DateRangePicker", (props) => {
61
48
  controller: popoverController,
62
49
  children: /* @__PURE__ */ jsx(RangeCalendar, {})
63
50
  }
64
- )
51
+ ),
52
+ /* @__PURE__ */ jsx(FieldErrorView, {})
65
53
  ]
66
54
  }
67
55
  );
@@ -1 +1 @@
1
- {"version":3,"file":"DateRangePicker.mjs","sources":["../../../../../../src/components/DateRangePicker/DateRangePicker.tsx"],"sourcesContent":["import type { PropsWithChildren, ReactNode } from \"react\";\nimport styles from \"../FormField/FormField.module.scss\";\nimport clsx from \"clsx\";\nimport type { PropsContext } from \"@/lib/propsContext\";\nimport { PropsContextProvider } from \"@/lib/propsContext\";\nimport * as Aria from \"react-aria-components\";\nimport { Popover } from \"@/components/Popover/Popover\";\nimport { RangeCalendar } from \"../Calendar/RangeCalendar\";\nimport { DateRangeInput } from \"./components/DateRangeInput\";\nimport { FieldError } from \"@/components/FieldError\";\nimport { useOverlayController } from \"@/lib/controller\";\nimport {\n flowComponent,\n type FlowComponentProps,\n} from \"@/lib/componentFactory/flowComponent\";\nimport { useMakeFocusable } from \"@/lib/hooks/dom/useMakeFocusable\";\nimport { useObjectRef } from \"@react-aria/utils\";\n\nexport interface DateRangePickerProps<T extends Aria.DateValue = Aria.DateValue>\n extends PropsWithChildren<Omit<Aria.DateRangePickerProps<T>, \"children\">>,\n FlowComponentProps {\n /** The error message that is displayed below the input. */\n errorMessage?: ReactNode;\n}\n\n/** @flr-generate all */\nexport const DateRangePicker = flowComponent(\"DateRangePicker\", (props) => {\n const { children, className, errorMessage, onChange, ref, ...rest } = props;\n\n const rootClassName = clsx(styles.formField, className);\n\n const propsContext: PropsContext = {\n Label: {\n className: styles.label,\n optional: !props.isRequired,\n },\n FieldDescription: {\n className: styles.fieldDescription,\n },\n FieldError: {\n className: styles.customFieldError,\n },\n };\n\n const popoverController = useOverlayController(\"Popover\");\n\n const localDateRangePickerRef = useObjectRef(ref);\n useMakeFocusable(localDateRangePickerRef);\n\n return (\n <Aria.DateRangePicker\n ref={localDateRangePickerRef}\n {...rest}\n className={rootClassName}\n onOpenChange={(v) => popoverController.setOpen(v)}\n isOpen={popoverController.isOpen}\n onChange={(value) => {\n if (onChange) {\n onChange(value);\n }\n popoverController.close();\n }}\n >\n <DateRangeInput isDisabled={props.isDisabled} />\n <PropsContextProvider props={propsContext}>\n {children}\n </PropsContextProvider>\n <FieldError className={styles.fieldError}>{errorMessage}</FieldError>\n <Popover\n placement=\"bottom end\"\n isDialogContent\n controller={popoverController}\n >\n <RangeCalendar />\n </Popover>\n </Aria.DateRangePicker>\n );\n});\n\nexport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A,EAAe,UAAA,EAAY,KAAA,CAAM,UAAA,EAAY,CAAA;AAAA,wBAC9C,GAAA,CAAC,oBAAA,EAAA,EAAqB,KAAA,EAAO,YAAA,EAC1B,QAAA,EACH,CAAA;AAAA,wBACA,GAAA,CAAC,UAAA,EAAA,EAAW,SAAA,EAAWA,eAAA,CAAO,YAAa,QAAA,EAAA,YAAA,EAAa,CAAA;AAAA,wBACxD,GAAA;AAAA,UAAC,OAAA;AAAA,UAAA;AAAA,YACC,SAAA,EAAU,YAAA;AAAA,YACV,eAAA,EAAe,IAAA;AAAA,YACf,UAAA,EAAY,iBAAA;AAAA,YAEZ,8BAAC,aAAA,EAAA,EAAc;AAAA;AAAA;AACjB;AAAA;AAAA,GACF;AAEJ,CAAC;;;;"}
1
+ {"version":3,"file":"DateRangePicker.mjs","sources":["../../../../../../src/components/DateRangePicker/DateRangePicker.tsx"],"sourcesContent":["import type { PropsWithChildren } from \"react\";\nimport clsx from \"clsx\";\nimport { PropsContextProvider } from \"@/lib/propsContext\";\nimport * as Aria from \"react-aria-components\";\nimport { Popover } from \"@/components/Popover/Popover\";\nimport { RangeCalendar } from \"../Calendar/RangeCalendar\";\nimport { DateRangeInput } from \"./components/DateRangeInput\";\nimport { useOverlayController } from \"@/lib/controller\";\nimport {\n flowComponent,\n type FlowComponentProps,\n} from \"@/lib/componentFactory/flowComponent\";\nimport { useMakeFocusable } from \"@/lib/hooks/dom/useMakeFocusable\";\nimport { useObjectRef } from \"@react-aria/utils\";\nimport { useFieldComponent } from \"@/lib/hooks/useFieldComponent\";\n\nexport interface DateRangePickerProps<T extends Aria.DateValue = Aria.DateValue>\n extends PropsWithChildren<Omit<Aria.DateRangePickerProps<T>, \"children\">>,\n FlowComponentProps {}\n\n/** @flr-generate all */\nexport const DateRangePicker = flowComponent(\"DateRangePicker\", (props) => {\n const { children, className, onChange, ref, ...rest } = props;\n\n const { FieldErrorView, fieldProps, fieldPropsContext } =\n useFieldComponent(props);\n\n const rootClassName = clsx(fieldProps.className, className);\n\n const popoverController = useOverlayController(\"Popover\");\n\n const localDateRangePickerRef = useObjectRef(ref);\n useMakeFocusable(localDateRangePickerRef);\n\n return (\n <Aria.DateRangePicker\n ref={localDateRangePickerRef}\n {...rest}\n className={rootClassName}\n onOpenChange={(v) => popoverController.setOpen(v)}\n isOpen={popoverController.isOpen}\n onChange={(value) => {\n if (onChange) {\n onChange(value);\n }\n popoverController.close();\n }}\n >\n <DateRangeInput isDisabled={props.isDisabled} />\n <PropsContextProvider props={fieldPropsContext}>\n {children}\n </PropsContextProvider>\n <Popover\n placement=\"bottom end\"\n isDialogContent\n controller={popoverController}\n >\n <RangeCalendar />\n </Popover>\n <FieldErrorView />\n </Aria.DateRangePicker>\n );\n});\n\nexport default DateRangePicker;\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAqBO,MAAM,eAAA,GAAkB,aAAA,CAAc,iBAAA,EAAmB,CAAC,KAAA,KAAU;AACzE,EAAA,MAAM,EAAE,QAAA,EAAU,SAAA,EAAW,UAAU,GAAA,EAAK,GAAG,MAAK,GAAI,KAAA;AAExD,EAAA,MAAM,EAAE,cAAA,EAAgB,UAAA,EAAY,iBAAA,EAAkB,GACpD,kBAAkB,KAAK,CAAA;AAEzB,EAAA,MAAM,aAAA,GAAgB,IAAA,CAAK,UAAA,CAAW,SAAA,EAAW,SAAS,CAAA;AAE1D,EAAA,MAAM,iBAAA,GAAoB,qBAAqB,SAAS,CAAA;AAExD,EAAA,MAAM,uBAAA,GAA0B,aAAa,GAAG,CAAA;AAChD,EAAA,gBAAA,CAAiB,uBAAuB,CAAA;AAExC,EAAA,uBACE,IAAA;AAAA,IAAC,IAAA,CAAK,eAAA;AAAA,IAAL;AAAA,MACC,GAAA,EAAK,uBAAA;AAAA,MACJ,GAAG,IAAA;AAAA,MACJ,SAAA,EAAW,aAAA;AAAA,MACX,YAAA,EAAc,CAAC,CAAA,KAAM,iBAAA,CAAkB,QAAQ,CAAC,CAAA;AAAA,MAChD,QAAQ,iBAAA,CAAkB,MAAA;AAAA,MAC1B,QAAA,EAAU,CAAC,KAAA,KAAU;AACnB,QAAA,IAAI,QAAA,EAAU;AACZ,UAAA,QAAA,CAAS,KAAK,CAAA;AAAA,QAChB;AACA,QAAA,iBAAA,CAAkB,KAAA,EAAM;AAAA,MAC1B,CAAA;AAAA,MAEA,QAAA,EAAA;AAAA,wBAAA,GAAA,CAAC,cAAA,EAAA,EAAe,UAAA,EAAY,KAAA,CAAM,UAAA,EAAY,CAAA;AAAA,wBAC9C,GAAA,CAAC,oBAAA,EAAA,EAAqB,KAAA,EAAO,iBAAA,EAC1B,QAAA,EACH,CAAA;AAAA,wBACA,GAAA;AAAA,UAAC,OAAA;AAAA,UAAA;AAAA,YACC,SAAA,EAAU,YAAA;AAAA,YACV,eAAA,EAAe,IAAA;AAAA,YACf,UAAA,EAAY,iBAAA;AAAA,YAEZ,8BAAC,aAAA,EAAA,EAAc;AAAA;AAAA,SACjB;AAAA,4BACC,cAAA,EAAA,EAAe;AAAA;AAAA;AAAA,GAClB;AAEJ,CAAC;;;;"}
@@ -1,23 +1,54 @@
1
1
  "use client"
2
2
  /* */
3
3
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
4
+ import React, { useContext, useMemo } from 'react';
4
5
  import styles from './FieldError.module.scss.mjs';
5
6
  import * as Aria from 'react-aria-components';
7
+ import { FieldErrorContext } from 'react-aria-components';
6
8
  import clsx from 'clsx';
7
- import 'react';
8
9
  import '@tabler/icons-react';
9
10
  import '../Icon/Icon.mjs';
10
11
  import '../../views/IconView.mjs';
11
12
  import { IconDanger } from '../Icon/components/icons/IconDanger.mjs';
12
13
  import { flowComponent } from '../../lib/componentFactory/flowComponent.mjs';
14
+ import { onlyText } from 'react-children-utilities';
13
15
 
14
16
  const FieldError = flowComponent("FieldError", (props) => {
15
17
  const { children, className, ref, ...rest } = props;
16
18
  const rootClassName = clsx(styles.fieldError, className);
17
- return /* @__PURE__ */ jsx(Aria.FieldError, { ref, ...rest, className: rootClassName, children: ({ validationErrors }) => /* @__PURE__ */ jsxs(Fragment, { children: [
18
- /* @__PURE__ */ jsx(IconDanger, { size: "s" }),
19
- /* @__PURE__ */ jsx("span", { children: children ? children : validationErrors.join(" ") })
20
- ] }) });
19
+ const fieldErrorFromAriaContext = useContext(FieldErrorContext);
20
+ const mergedErrorState = useMemo(() => {
21
+ if (React.Children.count(children) >= 1) {
22
+ const textChildren = onlyText(children);
23
+ if (!textChildren) {
24
+ return fieldErrorFromAriaContext;
25
+ }
26
+ return {
27
+ isInvalid: true,
28
+ validationErrors: [textChildren],
29
+ validationDetails: {
30
+ valid: false,
31
+ badInput: false,
32
+ customError: true,
33
+ patternMismatch: false,
34
+ rangeOverflow: false,
35
+ rangeUnderflow: false,
36
+ stepMismatch: false,
37
+ tooLong: false,
38
+ tooShort: false,
39
+ valueMissing: false,
40
+ typeMismatch: false
41
+ }
42
+ };
43
+ }
44
+ return fieldErrorFromAriaContext;
45
+ }, [fieldErrorFromAriaContext, children]);
46
+ return /* @__PURE__ */ jsx(FieldErrorContext, { value: mergedErrorState, children: /* @__PURE__ */ jsx(Aria.FieldError, { ref, ...rest, className: rootClassName, children: ({ validationErrors }) => {
47
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
48
+ /* @__PURE__ */ jsx(IconDanger, { size: "s" }),
49
+ /* @__PURE__ */ jsx("span", { children: validationErrors.join(" ") })
50
+ ] });
51
+ } }) });
21
52
  });
22
53
 
23
54
  export { FieldError, FieldError as default };
@@ -1 +1 @@
1
- {"version":3,"file":"FieldError.mjs","sources":["../../../../../../src/components/FieldError/FieldError.tsx"],"sourcesContent":["import type { PropsWithChildren } from \"react\";\nimport styles from \"./FieldError.module.scss\";\nimport * as Aria from \"react-aria-components\";\nimport clsx from \"clsx\";\nimport { IconDanger } from \"@/components/Icon/components/icons\";\nimport type { FlowComponentProps } from \"@/lib/componentFactory/flowComponent\";\nimport { flowComponent } from \"@/lib/componentFactory/flowComponent\";\n\nexport interface FieldErrorProps\n extends PropsWithChildren<Omit<Aria.FieldErrorProps, \"children\">>,\n FlowComponentProps {}\n\n/** @flr-generate all */\nexport const FieldError = flowComponent(\"FieldError\", (props) => {\n const { children, className, ref, ...rest } = props;\n\n const rootClassName = clsx(styles.fieldError, className);\n\n return (\n <Aria.FieldError ref={ref} {...rest} className={rootClassName}>\n {({ validationErrors }) => (\n <>\n <IconDanger size=\"s\" />\n <span>{children ? children : validationErrors.join(\" \")}</span>\n </>\n )}\n </Aria.FieldError>\n );\n});\n\nexport default FieldError;\n"],"names":[],"mappings":";;;;;;;;;;;AAaO,MAAM,UAAA,GAAa,aAAA,CAAc,YAAA,EAAc,CAAC,KAAA,KAAU;AAC/D,EAAA,MAAM,EAAE,QAAA,EAAU,SAAA,EAAW,GAAA,EAAK,GAAG,MAAK,GAAI,KAAA;AAE9C,EAAA,MAAM,aAAA,GAAgB,IAAA,CAAK,MAAA,CAAO,UAAA,EAAY,SAAS,CAAA;AAEvD,EAAA,uBACE,GAAA,CAAC,IAAA,CAAK,UAAA,EAAL,EAAgB,GAAA,EAAW,GAAG,IAAA,EAAM,SAAA,EAAW,aAAA,EAC7C,QAAA,EAAA,CAAC,EAAE,gBAAA,uBACF,IAAA,CAAA,QAAA,EAAA,EACE,QAAA,EAAA;AAAA,oBAAA,GAAA,CAAC,UAAA,EAAA,EAAW,MAAK,GAAA,EAAI,CAAA;AAAA,wBACpB,MAAA,EAAA,EAAM,QAAA,EAAA,QAAA,GAAW,WAAW,gBAAA,CAAiB,IAAA,CAAK,GAAG,CAAA,EAAE;AAAA,GAAA,EAC1D,CAAA,EAEJ,CAAA;AAEJ,CAAC;;;;"}
1
+ {"version":3,"file":"FieldError.mjs","sources":["../../../../../../src/components/FieldError/FieldError.tsx"],"sourcesContent":["import { type PropsWithChildren, useContext, useMemo } from \"react\";\nimport React from \"react\";\nimport styles from \"./FieldError.module.scss\";\nimport * as Aria from \"react-aria-components\";\nimport clsx from \"clsx\";\nimport { IconDanger } from \"@/components/Icon/components/icons\";\nimport type { FlowComponentProps } from \"@/lib/componentFactory/flowComponent\";\nimport { flowComponent } from \"@/lib/componentFactory/flowComponent\";\nimport { FieldErrorContext } from \"react-aria-components\";\nimport { onlyText } from \"react-children-utilities\";\n\nexport interface FieldErrorProps\n extends PropsWithChildren<Omit<Aria.FieldErrorProps, \"children\">>,\n FlowComponentProps {}\n\n/** @flr-generate all */\nexport const FieldError = flowComponent(\"FieldError\", (props) => {\n const { children, className, ref, ...rest } = props;\n\n const rootClassName = clsx(styles.fieldError, className);\n const fieldErrorFromAriaContext = useContext(FieldErrorContext);\n\n const mergedErrorState = useMemo(() => {\n if (React.Children.count(children) >= 1) {\n const textChildren = onlyText(children);\n if (!textChildren) {\n return fieldErrorFromAriaContext;\n }\n\n return {\n isInvalid: true,\n validationErrors: [textChildren],\n validationDetails: {\n valid: false,\n badInput: false,\n customError: true,\n patternMismatch: false,\n rangeOverflow: false,\n rangeUnderflow: false,\n stepMismatch: false,\n tooLong: false,\n tooShort: false,\n valueMissing: false,\n typeMismatch: false,\n },\n };\n }\n\n return fieldErrorFromAriaContext;\n }, [fieldErrorFromAriaContext, children]);\n\n return (\n <FieldErrorContext value={mergedErrorState}>\n <Aria.FieldError ref={ref} {...rest} className={rootClassName}>\n {({ validationErrors }) => {\n return (\n <>\n <IconDanger size=\"s\" />\n <span>{validationErrors.join(\" \")}</span>\n </>\n );\n }}\n </Aria.FieldError>\n </FieldErrorContext>\n );\n});\n\nexport default FieldError;\n"],"names":[],"mappings":";;;;;;;;;;;;;AAgBO,MAAM,UAAA,GAAa,aAAA,CAAc,YAAA,EAAc,CAAC,KAAA,KAAU;AAC/D,EAAA,MAAM,EAAE,QAAA,EAAU,SAAA,EAAW,GAAA,EAAK,GAAG,MAAK,GAAI,KAAA;AAE9C,EAAA,MAAM,aAAA,GAAgB,IAAA,CAAK,MAAA,CAAO,UAAA,EAAY,SAAS,CAAA;AACvD,EAAA,MAAM,yBAAA,GAA4B,WAAW,iBAAiB,CAAA;AAE9D,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EACpC,CAAA;AAAA,EAEJ,GACF,CAAA,EACF,CAAA;AAEJ,CAAC;;;;"}
@@ -1,6 +1,6 @@
1
1
  "use client"
2
2
  /* */
3
- import { jsx } from 'react/jsx-runtime';
3
+ import { jsxs, jsx } from 'react/jsx-runtime';
4
4
  import { useRef } from 'react';
5
5
  import * as Aria from 'react-aria-components';
6
6
  import { IllustratedMessage } from '../IllustratedMessage/IllustratedMessage.mjs';
@@ -10,6 +10,7 @@ import '../../lib/propsContext/propsContext.mjs';
10
10
  import { PropsContextProvider } from '../../lib/propsContext/components/PropsContextProvider.mjs';
11
11
  import { flowComponent } from '../../lib/componentFactory/flowComponent.mjs';
12
12
  import { addAwaitedArrayBuffer } from '../../../../core/src/file.mjs';
13
+ import { useFieldComponent } from '../../lib/hooks/useFieldComponent.mjs';
13
14
 
14
15
  const FileDropZone = flowComponent(
15
16
  "FileDropZone",
@@ -24,6 +25,12 @@ const FileDropZone = flowComponent(
24
25
  isDisabled,
25
26
  isReadOnly
26
27
  } = props;
28
+ const {
29
+ FieldErrorView,
30
+ FieldErrorResetContext,
31
+ fieldProps,
32
+ fieldPropsContext
33
+ } = useFieldComponent(props);
27
34
  const fileFieldRef = useRef(null);
28
35
  const rootClassName = clsx(
29
36
  styles.fileDropZone,
@@ -31,6 +38,7 @@ const FileDropZone = flowComponent(
31
38
  className
32
39
  );
33
40
  const propsContext = {
41
+ ...fieldPropsContext,
34
42
  FileField: {
35
43
  name,
36
44
  onChange: onChangeDropZone,
@@ -73,16 +81,19 @@ const FileDropZone = flowComponent(
73
81
  }
74
82
  }
75
83
  };
76
- return /* @__PURE__ */ jsx(
77
- Aria.DropZone,
78
- {
79
- className: rootClassName,
80
- onDrop: onDropHandler,
81
- isDisabled,
82
- "data-readonly": isReadOnly,
83
- children: /* @__PURE__ */ jsx(IllustratedMessage, { color: "dark", children: /* @__PURE__ */ jsx(PropsContextProvider, { props: propsContext, children }) })
84
- }
85
- );
84
+ return /* @__PURE__ */ jsxs("div", { ...fieldProps, children: [
85
+ /* @__PURE__ */ jsx(FieldErrorResetContext, { children: /* @__PURE__ */ jsx(PropsContextProvider, { props: propsContext, children: /* @__PURE__ */ jsx(
86
+ Aria.DropZone,
87
+ {
88
+ className: rootClassName,
89
+ onDrop: onDropHandler,
90
+ isDisabled,
91
+ "data-readonly": isReadOnly,
92
+ children: /* @__PURE__ */ jsx(IllustratedMessage, { color: "dark", children })
93
+ }
94
+ ) }) }),
95
+ /* @__PURE__ */ jsx(FieldErrorView, {})
96
+ ] });
86
97
  }
87
98
  );
88
99
 
@@ -1 +1 @@
1
- {"version":3,"file":"FileDropZone.mjs","sources":["../../../../../../src/components/FileDropZone/FileDropZone.tsx"],"sourcesContent":["import { type FC, type PropsWithChildren, useRef } from \"react\";\nimport * as Aria from \"react-aria-components\";\nimport { IllustratedMessage } from \"@/components/IllustratedMessage\";\nimport type { PropsWithClassName } from \"@/lib/types/props\";\nimport styles from \"./FileDropZone.module.scss\";\nimport clsx from \"clsx\";\nimport type { FileInputOnChangeHandler } from \"@/components/FileField/components/FileInput\";\nimport type { PropsContext } from \"@/lib/propsContext\";\nimport { PropsContextProvider } from \"@/lib/propsContext\";\nimport {\n flowComponent,\n type FlowComponentProps,\n} from \"@/lib/componentFactory/flowComponent\";\nimport type { DropEvent, FocusableElement } from \"@react-types/shared\";\nimport { addAwaitedArrayBuffer } from \"@mittwald/flow-core\";\n\nexport interface FileDropZoneProps\n extends PropsWithClassName,\n FlowComponentProps<FocusableElement>,\n PropsWithChildren,\n Pick<Aria.InputProps, \"accept\" | \"multiple\" | \"name\">,\n Pick<Aria.DropZoneProps, \"isDisabled\"> {\n onChange?: FileInputOnChangeHandler;\n /** Whether the component is read only. */\n isReadOnly?: boolean;\n}\n\n/** @flr-generate all */\nexport const FileDropZone: FC<FileDropZoneProps> = flowComponent(\n \"FileDropZone\",\n (props) => {\n const {\n multiple,\n accept,\n className,\n onChange: onChangeDropZone,\n children,\n name,\n isDisabled,\n isReadOnly,\n } = props;\n\n const fileFieldRef = useRef<HTMLInputElement>(null);\n const rootClassName = clsx(\n styles.fileDropZone,\n isDisabled && styles.disabled,\n className,\n );\n\n const propsContext: PropsContext = {\n FileField: {\n name,\n onChange: onChangeDropZone,\n ref: fileFieldRef,\n accept: accept,\n multiple: multiple,\n Button: { variant: \"outline\", color: \"dark\" },\n isDisabled,\n isReadOnly,\n },\n Heading: {\n className: styles.heading,\n },\n Icon: { className: styles.icon },\n Text: { className: styles.text },\n };\n\n const onDropHandler = async (event: DropEvent) => {\n if (isReadOnly) {\n return;\n }\n\n const fileDropItems = event.items.filter(\n (file) => file.kind === \"file\",\n ) as Aria.FileDropItem[];\n\n const files = await Promise.all(\n fileDropItems\n .filter((f) => !accept || accept?.includes(f.type))\n .map(async (f) => {\n const file = await f.getFile();\n return await addAwaitedArrayBuffer(file);\n }),\n );\n\n if (files.length > 0) {\n const fileTransfer = new DataTransfer();\n for (const file of multiple ? files : [files[0]]) {\n if (file) {\n fileTransfer.items.add(file);\n }\n }\n\n onChangeDropZone?.(fileTransfer.files);\n if (fileFieldRef.current) {\n fileFieldRef.current.files = fileTransfer.files;\n }\n }\n };\n\n return (\n <Aria.DropZone\n className={rootClassName}\n onDrop={onDropHandler}\n isDisabled={isDisabled}\n data-readonly={isReadOnly}\n >\n <IllustratedMessage color=\"dark\">\n <PropsContextProvider props={propsContext}>\n {children}\n </PropsContextProvider>\n </IllustratedMessage>\n </Aria.DropZone>\n );\n },\n);\n\nexport default FileDropZone;\n"],"names":[],"mappings":";;;;;;;;;;;AA4BO,MAAM,YAAA,GAAsC,aAAA;AAAA,EACjD,cAAA;AAAA,EACA,CAAC,KAAA,KAAU;AACT,IAAA,MAAM;AAAA,MACJ,QAAA;AAAA,MACA,MAAA;AAAA,MACA,SAAA;AAAA,MACA,QAAA,EAAU,gBAAA;AAAA,MACV,QAAA;AAAA,MACA,IAAA;AAAA,MACA,UAAA;AAAA,MACA;AAAA,KACF,GAAI,KAAA;AAEJ,IAAA,MAAM,YAAA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AAA,CAAM,SAAS,CAAA,EAAG;AACpB,QAAA,MAAM,YAAA,GAAe,IAAI,YAAA,EAAa;AACtC,QAAA,KAAA,MAAW,QAAQ,QAAA,GAAW,KAAA,GAAQ,CAAC,KAAA,CAAM,CAAC,CAAC,CAAA,EAAG;AAChD,UAAA,IAAI,IAAA,EAAM;AACR,YAAA,YAAA,CAAa,KAAA,CAAM,IAAI,IAAI,CAAA;AAAA,UAC7B;AAAA,QACF;AAEA,QAAA,gBAAA,GAAmB,aAAa,KAAK,CAAA;AACrC,QAAA,IAAI,aAAa,OAAA,EAAS;AACxB,UAAA,YAAA,CAAa,OAAA,CAAQ,QAAQ,YAAA,CAAa,KAAA;AAAA,QAC5C;AAAA,MACF;AAAA,IACF,CAAA;AAEA,IAAA,uBACE,GAAA;AAAA,MAAC,IAAA,CAAK,QAAA;AAAA,MAAL;AAAA,QACC,SAAA,EAAW,aAAA;AAAA,QACX,MAAA,EAAQ,aAAA;AAAA,QACR,UAAA;AAAA,QACA,eAAA,EAAe,UAAA;AAAA,QAEf,QAAA,kBAAA,GAAA,CAAC,sBAAmB,KAAA,EAAM,MAAA,EACxB,8BAAC,oBAAA,EAAA,EAAqB,KAAA,EAAO,YAAA,EAC1B,QAAA,EACH,CAAA,EACF;AAAA;AAAA,KACF;AAAA,EAEJ;AACF;;;;"}
1
+ {"version":3,"file":"FileDropZone.mjs","sources":["../../../../../../src/components/FileDropZone/FileDropZone.tsx"],"sourcesContent":["import { type FC, type PropsWithChildren, useRef } from \"react\";\nimport * as Aria from \"react-aria-components\";\nimport { IllustratedMessage } from \"@/components/IllustratedMessage\";\nimport type { PropsWithClassName } from \"@/lib/types/props\";\nimport styles from \"./FileDropZone.module.scss\";\nimport clsx from \"clsx\";\nimport type { FileInputOnChangeHandler } from \"@/components/FileField/components/FileInput\";\nimport type { PropsContext } from \"@/lib/propsContext\";\nimport { PropsContextProvider } from \"@/lib/propsContext\";\nimport {\n flowComponent,\n type FlowComponentProps,\n} from \"@/lib/componentFactory/flowComponent\";\nimport type { DropEvent, FocusableElement } from \"@react-types/shared\";\nimport { addAwaitedArrayBuffer } from \"@mittwald/flow-core\";\nimport { useFieldComponent } from \"@/lib/hooks/useFieldComponent\";\n\nexport interface FileDropZoneProps\n extends PropsWithClassName,\n FlowComponentProps<FocusableElement>,\n PropsWithChildren,\n Pick<Aria.InputProps, \"accept\" | \"multiple\" | \"name\">,\n Pick<Aria.DropZoneProps, \"isDisabled\"> {\n onChange?: FileInputOnChangeHandler;\n /** Whether the component is read only. */\n isReadOnly?: boolean;\n}\n\n/** @flr-generate all */\nexport const FileDropZone: FC<FileDropZoneProps> = flowComponent(\n \"FileDropZone\",\n (props) => {\n const {\n multiple,\n accept,\n className,\n onChange: onChangeDropZone,\n children,\n name,\n isDisabled,\n isReadOnly,\n } = props;\n\n const {\n FieldErrorView,\n FieldErrorResetContext,\n fieldProps,\n fieldPropsContext,\n } = useFieldComponent(props);\n\n const fileFieldRef = useRef<HTMLInputElement>(null);\n const rootClassName = clsx(\n styles.fileDropZone,\n isDisabled && styles.disabled,\n className,\n );\n\n const propsContext: PropsContext = {\n ...fieldPropsContext,\n FileField: {\n name,\n onChange: onChangeDropZone,\n ref: fileFieldRef,\n accept: accept,\n multiple: multiple,\n Button: { variant: \"outline\", color: \"dark\" },\n isDisabled,\n isReadOnly,\n },\n Heading: {\n className: styles.heading,\n },\n Icon: { className: styles.icon },\n Text: { className: styles.text },\n };\n\n const onDropHandler = async (event: DropEvent) => {\n if (isReadOnly) {\n return;\n }\n\n const fileDropItems = event.items.filter(\n (file) => file.kind === \"file\",\n ) as Aria.FileDropItem[];\n\n const files = await Promise.all(\n fileDropItems\n .filter((f) => !accept || accept?.includes(f.type))\n .map(async (f) => {\n const file = await f.getFile();\n return await addAwaitedArrayBuffer(file);\n }),\n );\n\n if (files.length > 0) {\n const fileTransfer = new DataTransfer();\n for (const file of multiple ? files : [files[0]]) {\n if (file) {\n fileTransfer.items.add(file);\n }\n }\n\n onChangeDropZone?.(fileTransfer.files);\n if (fileFieldRef.current) {\n fileFieldRef.current.files = fileTransfer.files;\n }\n }\n };\n\n return (\n <div {...fieldProps}>\n <FieldErrorResetContext>\n <PropsContextProvider props={propsContext}>\n <Aria.DropZone\n className={rootClassName}\n onDrop={onDropHandler}\n isDisabled={isDisabled}\n data-readonly={isReadOnly}\n >\n <IllustratedMessage color=\"dark\">{children}</IllustratedMessage>\n </Aria.DropZone>\n </PropsContextProvider>\n </FieldErrorResetContext>\n <FieldErrorView />\n </div>\n );\n },\n);\n\nexport default FileDropZone;\n"],"names":[],"mappings":";;;;;;;;;;;;AA6BO,MAAM,YAAA,GAAsC,aAAA;AAAA,EACjD,cAAA;AAAA,EACA,CAAC,KAAA,KAAU;AACT,IAAA,MAAM;AAAA,MACJ,QAAA;AAAA,MACA,MAAA;AAAA,MACA,SAAA;AAAA,MACA,QAAA,EAAU,gBAAA;AAAA,MACV,QAAA;AAAA,MACA,IAAA;AAAA,MACA,UAAA;AAAA,MACA;AAAA,KACF,GAAI,KAAA;AAEJ,IAAA,MAAM;AAAA,MACJ,cAAA;AAAA,MACA,sBAAA;AAAA,MACA,UAAA;AAAA,MACA;AAAA,KACF,GAAI,kBAAkB,KAAK,CAAA;AAE3B,IAAA,MAAM,YAAA,GAAe,OAAyB,IAAI,CAAA;AAClD,IAAA,MAAM,aAAA,GAAgB,IAAA;AAAA,MACpB,MAAA,CAAO,YAAA;AAAA,MACP,cAAc,MAAA,CAAO,QAAA;AAAA,MACrB;AAAA,KACF;AAEA,IAAA,MAAM,YAAA,GAA6B;AAAA,MACjC,GAAG,iBAAA;AAAA,MACH,SAAA,EAAW;AAAA,QACT,IAAA;AAAA,QACA,QAAA,EAAU,gBAAA;AAAA,QACV,GAAA,EAAK,YAAA;AAAA,QACL,MAAA;AAAA,QACA,QAAA;AAAA,QACA,MAAA,EAAQ,EAAE,OAAA,EAAS,SAAA,EAAW,OAAO,MAAA,EAAO;AAAA,QAC5C,UAAA;AAAA,QACA;AAAA,OAC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AAA,QAC5C;AAAA,MACF;AAAA,IACF,CAAA;AAEA,IAAA,uBACE,IAAA,CAAC,KAAA,EAAA,EAAK,GAAG,UAAA,EACP,QAAA,EAAA;AAAA,sBAAA,GAAA,CAAC,sBAAA,EAAA,EACC,QAAA,kBAAA,GAAA,CAAC,oBAAA,EAAA,EAAqB,KAAA,EAAO,YAAA,EAC3B,QAAA,kBAAA,GAAA;AAAA,QAAC,IAAA,CAAK,QAAA;AAAA,QAAL;AAAA,UACC,SAAA,EAAW,aAAA;AAAA,UACX,MAAA,EAAQ,aAAA;AAAA,UACR,UAAA;AAAA,UACA,eAAA,EAAe,UAAA;AAAA,UAEf,QAAA,kBAAA,GAAA,CAAC,kBAAA,EAAA,EAAmB,KAAA,EAAM,MAAA,EAAQ,QAAA,EAAS;AAAA;AAAA,SAE/C,CAAA,EACF,CAAA;AAAA,0BACC,cAAA,EAAA,EAAe;AAAA,KAAA,EAClB,CAAA;AAAA,EAEJ;AACF;;;;"}
@@ -1,7 +1,6 @@
1
1
  "use client"
2
2
  /* */
3
- import { jsx } from 'react/jsx-runtime';
4
- import formFieldStyles from '../FormField/FormField.module.scss.mjs';
3
+ import { jsx, jsxs } from 'react/jsx-runtime';
5
4
  import { useFormValidation } from '@react-aria/form';
6
5
  import { useFormValidationState } from '@react-stately/form';
7
6
  import { InputContext, FieldErrorContext } from 'react-aria-components';
@@ -12,6 +11,7 @@ import { PropsContextProvider } from '../../lib/propsContext/components/PropsCon
12
11
  import { useObjectRef } from '@react-aria/utils';
13
12
  import { addAwaitedArrayBuffer } from '../../../../core/src/file.mjs';
14
13
  import { useMakeFocusable } from '../../lib/hooks/dom/useMakeFocusable.mjs';
14
+ import { useFieldComponent } from '../../lib/hooks/useFieldComponent.mjs';
15
15
 
16
16
  const FileField = flowComponent("FileField", (props) => {
17
17
  const {
@@ -25,6 +25,12 @@ const FileField = flowComponent("FileField", (props) => {
25
25
  isReadOnly,
26
26
  ...restInputProps
27
27
  } = props;
28
+ const {
29
+ FieldErrorView,
30
+ FieldErrorResetContext,
31
+ fieldProps,
32
+ fieldPropsContext
33
+ } = useFieldComponent(props);
28
34
  const inputRef = useObjectRef(ref);
29
35
  const formValidationState = useFormValidationState({
30
36
  value: void 0,
@@ -37,18 +43,6 @@ const FileField = flowComponent("FileField", (props) => {
37
43
  "aria-invalid": formValidationState.displayValidation.isInvalid,
38
44
  value: void 0
39
45
  };
40
- const propsContext = {
41
- Label: {
42
- className: formFieldStyles.label,
43
- optional: !props.isRequired
44
- },
45
- FieldDescription: {
46
- className: formFieldStyles.fieldDescription
47
- },
48
- FieldError: {
49
- className: formFieldStyles.customFieldError
50
- }
51
- };
52
46
  const handleOnChange = (fileList) => {
53
47
  if (fileList && onChange) {
54
48
  Promise.all(Array.from(fileList).map(addAwaitedArrayBuffer)).then(
@@ -57,25 +51,33 @@ const FileField = flowComponent("FileField", (props) => {
57
51
  }
58
52
  };
59
53
  useMakeFocusable(inputRef);
60
- return /* @__PURE__ */ jsx(InputContext.Provider, { value: inputProps, children: /* @__PURE__ */ jsx(FieldErrorContext.Provider, { value: formValidationState.displayValidation, children: /* @__PURE__ */ jsx(PropsContextProvider, { props: propsContext, children: /* @__PURE__ */ jsx(
61
- "div",
54
+ return /* @__PURE__ */ jsx("div", { ...fieldProps, children: /* @__PURE__ */ jsx(InputContext.Provider, { value: inputProps, children: /* @__PURE__ */ jsxs(
55
+ FieldErrorContext.Provider,
62
56
  {
63
- "data-readonly": isReadOnly,
64
- "data-required": !!isRequired || void 0,
65
- "data-invalid": formValidationState.displayValidation.isInvalid || void 0,
66
- className: formFieldStyles.formField,
67
- children: /* @__PURE__ */ jsx(
68
- FileInput,
69
- {
70
- ref: inputRef,
71
- isReadOnly,
72
- onChange: isReadOnly ? void 0 : handleOnChange,
73
- isDisabled,
74
- children
75
- }
76
- )
57
+ value: formValidationState.displayValidation,
58
+ children: [
59
+ /* @__PURE__ */ jsx(FieldErrorResetContext, { children: /* @__PURE__ */ jsx(PropsContextProvider, { props: fieldPropsContext, children: /* @__PURE__ */ jsx(
60
+ "div",
61
+ {
62
+ "data-readonly": isReadOnly,
63
+ "data-required": !!isRequired || void 0,
64
+ "data-invalid": formValidationState.displayValidation.isInvalid || void 0,
65
+ children: /* @__PURE__ */ jsx(
66
+ FileInput,
67
+ {
68
+ ref: inputRef,
69
+ isReadOnly,
70
+ onChange: isReadOnly ? void 0 : handleOnChange,
71
+ isDisabled,
72
+ children
73
+ }
74
+ )
75
+ }
76
+ ) }) }),
77
+ /* @__PURE__ */ jsx(FieldErrorView, {})
78
+ ]
77
79
  }
78
- ) }) }) });
80
+ ) }) });
79
81
  });
80
82
 
81
83
  export { FileField, FileField as default };
@@ -1 +1 @@
1
- {"version":3,"file":"FileField.mjs","sources":["../../../../../../src/components/FileField/FileField.tsx"],"sourcesContent":["import formFieldStyles from \"@/components/FormField/FormField.module.scss\";\nimport { useFormValidation } from \"@react-aria/form\";\nimport { useFormValidationState } from \"@react-stately/form\";\nimport type { PropsWithChildren } from \"react\";\nimport type * as Aria from \"react-aria-components\";\nimport { FieldErrorContext, InputContext } from \"react-aria-components\";\nimport type { FileInputOnChangeHandler } from \"@/components/FileField/components/FileInput\";\nimport { FileInput } from \"@/components/FileField/components/FileInput\";\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 { useObjectRef } from \"@react-aria/utils\";\nimport { addAwaitedArrayBuffer } from \"@mittwald/flow-core\";\nimport { useMakeFocusable } from \"@/lib/hooks/dom/useMakeFocusable\";\n\nexport interface FileFieldProps\n extends PropsWithChildren,\n FlowComponentProps<HTMLInputElement>,\n Pick<Aria.InputProps, \"accept\" | \"multiple\" | \"name\">,\n Pick<\n Aria.TextFieldProps,\n \"isRequired\" | \"isInvalid\" | \"validationBehavior\" | \"isDisabled\"\n > {\n /** Handler that is called when the file input changes. */\n onChange?: FileInputOnChangeHandler;\n /** Whether the component is read only. */\n isReadOnly?: boolean;\n}\n\n/** @flr-generate all */\nexport const FileField = flowComponent(\"FileField\", (props) => {\n const {\n children,\n ref,\n isRequired,\n isInvalid,\n isDisabled,\n validationBehavior,\n onChange,\n isReadOnly,\n ...restInputProps\n } = props;\n const inputRef = useObjectRef(ref);\n\n const formValidationState = useFormValidationState({\n value: undefined,\n validationBehavior,\n isInvalid,\n });\n\n useFormValidation({ validationBehavior }, formValidationState, inputRef);\n\n const inputProps = {\n ...restInputProps,\n \"aria-invalid\": formValidationState.displayValidation.isInvalid,\n value: undefined,\n };\n\n const propsContext: PropsContext = {\n Label: {\n className: formFieldStyles.label,\n optional: !props.isRequired,\n },\n FieldDescription: {\n className: formFieldStyles.fieldDescription,\n },\n FieldError: {\n className: formFieldStyles.customFieldError,\n },\n };\n\n const handleOnChange: FileInputOnChangeHandler = (fileList) => {\n if (fileList && onChange) {\n Promise.all(Array.from(fileList).map(addAwaitedArrayBuffer)).then(() =>\n onChange(fileList),\n );\n }\n };\n\n useMakeFocusable(inputRef);\n\n return (\n <InputContext.Provider value={inputProps}>\n <FieldErrorContext.Provider value={formValidationState.displayValidation}>\n <PropsContextProvider props={propsContext}>\n <div\n data-readonly={isReadOnly}\n data-required={!!isRequired || undefined}\n data-invalid={\n formValidationState.displayValidation.isInvalid || undefined\n }\n className={formFieldStyles.formField}\n >\n <FileInput\n ref={inputRef}\n isReadOnly={isReadOnly}\n onChange={isReadOnly ? undefined : handleOnChange}\n isDisabled={isDisabled}\n >\n {children}\n </FileInput>\n </div>\n </PropsContextProvider>\n </FieldErrorContext.Provider>\n </InputContext.Provider>\n );\n});\nexport default FileField;\n"],"names":[],"mappings":";;;;;;;;;;;;;AA+BO,MAAM,SAAA,GAAY,aAAA,CAAc,WAAA,EAAa,CAAC,KAAA,KAAU;AAC7D,EAAA,MAAM;AAAA,IACJ,QAAA;AAAA,IACA,GAAA;AAAA,IACA,UAAA;AAAA,IACA,SAA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,mBAAA,CAAoB,iBAAA,EACrD,QAAA,kBAAA,GAAA,CAAC,oBAAA,EAAA,EAAqB,OAAO,YAAA,EAC3B,QAAA,kBAAA,GAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,eAAA,EAAe,UAAA;AAAA,MACf,eAAA,EAAe,CAAC,CAAC,UAAA,IAAc,MAAA;AAAA,MAC/B,cAAA,EACE,mBAAA,CAAoB,iBAAA,CAAkB,SAAA,IAAa,MAAA;AAAA,MAErD,WAAW,eAAA,CAAgB,SAAA;AAAA,MAE3B,QAAA,kBAAA,GAAA;AAAA,QAAC,SAAA;AAAA,QAAA;AAAA,UACC,GAAA,EAAK,QAAA;AAAA,UACL,UAAA;AAAA,UACA,QAAA,EAAU,aAAa,MAAA,GAAY,cAAA;AAAA,UACnC,UAAA;AAAA,UAEC;AAAA;AAAA;AACH;AAAA,GACF,EACF,GACF,CAAA,EACF,CAAA;AAEJ,CAAC;;;;"}
1
+ {"version":3,"file":"FileField.mjs","sources":["../../../../../../src/components/FileField/FileField.tsx"],"sourcesContent":["import { useFormValidation } from \"@react-aria/form\";\nimport { useFormValidationState } from \"@react-stately/form\";\nimport type { PropsWithChildren } from \"react\";\nimport type * as Aria from \"react-aria-components\";\nimport { FieldErrorContext, InputContext } from \"react-aria-components\";\nimport type { FileInputOnChangeHandler } from \"@/components/FileField/components/FileInput\";\nimport { FileInput } from \"@/components/FileField/components/FileInput\";\nimport type { FlowComponentProps } from \"@/lib/componentFactory/flowComponent\";\nimport { flowComponent } from \"@/lib/componentFactory/flowComponent\";\nimport { PropsContextProvider } from \"@/lib/propsContext\";\nimport { useObjectRef } from \"@react-aria/utils\";\nimport { addAwaitedArrayBuffer } from \"@mittwald/flow-core\";\nimport { useMakeFocusable } from \"@/lib/hooks/dom/useMakeFocusable\";\nimport { useFieldComponent } from \"@/lib/hooks/useFieldComponent\";\n\nexport interface FileFieldProps\n extends PropsWithChildren,\n FlowComponentProps<HTMLInputElement>,\n Pick<Aria.InputProps, \"accept\" | \"multiple\" | \"name\">,\n Pick<\n Aria.TextFieldProps,\n \"isRequired\" | \"isInvalid\" | \"validationBehavior\" | \"isDisabled\"\n > {\n /** Handler that is called when the file input changes. */\n onChange?: FileInputOnChangeHandler;\n /** Whether the component is read only. */\n isReadOnly?: boolean;\n}\n\n/** @flr-generate all */\nexport const FileField = flowComponent(\"FileField\", (props) => {\n const {\n children,\n ref,\n isRequired,\n isInvalid,\n isDisabled,\n validationBehavior,\n onChange,\n isReadOnly,\n ...restInputProps\n } = props;\n\n const {\n FieldErrorView,\n FieldErrorResetContext,\n fieldProps,\n fieldPropsContext,\n } = useFieldComponent(props);\n\n const inputRef = useObjectRef(ref);\n\n const formValidationState = useFormValidationState({\n value: undefined,\n validationBehavior,\n isInvalid,\n });\n\n useFormValidation({ validationBehavior }, formValidationState, inputRef);\n\n const inputProps = {\n ...restInputProps,\n \"aria-invalid\": formValidationState.displayValidation.isInvalid,\n value: undefined,\n };\n\n const handleOnChange: FileInputOnChangeHandler = (fileList) => {\n if (fileList && onChange) {\n Promise.all(Array.from(fileList).map(addAwaitedArrayBuffer)).then(() =>\n onChange(fileList),\n );\n }\n };\n\n useMakeFocusable(inputRef);\n\n return (\n <div {...fieldProps}>\n <InputContext.Provider value={inputProps}>\n <FieldErrorContext.Provider\n value={formValidationState.displayValidation}\n >\n <FieldErrorResetContext>\n <PropsContextProvider props={fieldPropsContext}>\n <div\n data-readonly={isReadOnly}\n data-required={!!isRequired || undefined}\n data-invalid={\n formValidationState.displayValidation.isInvalid || undefined\n }\n >\n <FileInput\n ref={inputRef}\n isReadOnly={isReadOnly}\n onChange={isReadOnly ? undefined : handleOnChange}\n isDisabled={isDisabled}\n >\n {children}\n </FileInput>\n </div>\n </PropsContextProvider>\n </FieldErrorResetContext>\n <FieldErrorView />\n </FieldErrorContext.Provider>\n </InputContext.Provider>\n </div>\n );\n});\nexport default FileField;\n"],"names":[],"mappings":";;;;;;;;;;;;;AA8BO,MAAM,SAAA,GAA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AAA,IAAlB;AAAA,MACC,OAAO,mBAAA,CAAoB,iBAAA;AAAA,MAE3B,QAAA,EAAA;AAAA,wBAAA,GAAA,CAAC,sBAAA,EAAA,EACC,QAAA,kBAAA,GAAA,CAAC,oBAAA,EAAA,EAAqB,KAAA,EAAO,iBAAA,EAC3B,QAAA,kBAAA,GAAA;AAAA,UAAC,KAAA;AAAA,UAAA;AAAA,YACC,eAAA,EAAe,UAAA;AAAA,YACf,eAAA,EAAe,CAAC,CAAC,UAAA,IAAc,MAAA;AAAA,YAC/B,cAAA,EACE,mBAAA,CAAoB,iBAAA,CAAkB,SAAA,IAAa,MAAA;AAAA,YAGrD,QAAA,kBAAA,GAAA;AAAA,cAAC,SAAA;AAAA,cAAA;AAAA,gBACC,GAAA,EAAK,QAAA;AAAA,gBACL,UAAA;AAAA,gBACA,QAAA,EAAU,aAAa,MAAA,GAAY,cAAA;AAAA,gBACnC,UAAA;AAAA,gBAEC;AAAA;AAAA;AACH;AAAA,WAEJ,CAAA,EACF,CAAA;AAAA,4BACC,cAAA,EAAA,EAAe;AAAA;AAAA;AAAA,KAEpB,CAAA,EACF,CAAA;AAEJ,CAAC;;;;"}
@@ -3,15 +3,13 @@
3
3
  const formField = "flow--form-field";
4
4
  const label = "flow--form-field--label";
5
5
  const fieldError = "flow--form-field--field-error";
6
- const customFieldError = "flow--form-field--custom-field-error";
7
6
  const fieldDescription = "flow--form-field--field-description";
8
7
  const formFieldStyles = {
9
8
  formField: formField,
10
9
  label: label,
11
10
  fieldError: fieldError,
12
- customFieldError: customFieldError,
13
11
  fieldDescription: fieldDescription
14
12
  };
15
13
 
16
- export { customFieldError, formFieldStyles as default, fieldDescription, fieldError, formField, label };
14
+ export { formFieldStyles as default, fieldDescription, fieldError, formField, label };
17
15
  //# sourceMappingURL=FormField.module.scss.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"FormField.module.scss.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"FormField.module.scss.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;"}
@@ -1,15 +1,14 @@
1
1
  "use client"
2
2
  /* */
3
3
  import { jsxs, jsx } from 'react/jsx-runtime';
4
+ import 'react';
4
5
  import * as Aria from 'react-aria-components';
5
6
  import formFieldStyles from '../FormField/FormField.module.scss.mjs';
6
7
  import styles from './NumberField.module.scss.mjs';
7
8
  import clsx from 'clsx';
8
9
  import '../../lib/propsContext/propsContext.mjs';
9
10
  import { PropsContextProvider } from '../../lib/propsContext/components/PropsContextProvider.mjs';
10
- import { FieldError } from '../FieldError/FieldError.mjs';
11
11
  import { Button } from '../Button/Button.mjs';
12
- import 'react';
13
12
  import '@tabler/icons-react';
14
13
  import '../Icon/Icon.mjs';
15
14
  import '../../views/IconView.mjs';
@@ -19,6 +18,7 @@ import { IconMinus } from '../Icon/components/icons/IconMinus.mjs';
19
18
  import { IconPlus } from '../Icon/components/icons/IconPlus.mjs';
20
19
  import { flowComponent } from '../../lib/componentFactory/flowComponent.mjs';
21
20
  import { ReactAriaControlledValueFix } from '../../lib/react/ReactAriaControlledValueFix.mjs';
21
+ import { useFieldComponent } from '../../lib/hooks/useFieldComponent.mjs';
22
22
 
23
23
  const NumberField = flowComponent("NumberField", (props) => {
24
24
  const {
@@ -29,28 +29,20 @@ const NumberField = flowComponent("NumberField", (props) => {
29
29
  isWheelDisabled = true,
30
30
  ...rest
31
31
  } = props;
32
+ const { FieldErrorView, fieldProps, fieldPropsContext } = useFieldComponent(props);
32
33
  const rootClassName = clsx(formFieldStyles.formField, className);
33
- const propsContext = {
34
- Label: {
35
- className: formFieldStyles.label,
36
- optional: !props.isRequired
37
- },
38
- FieldDescription: {
39
- className: formFieldStyles.fieldDescription
40
- },
41
- FieldError: {
42
- className: formFieldStyles.customFieldError
43
- }
44
- };
45
34
  return /* @__PURE__ */ jsxs(
46
35
  Aria.NumberField,
47
36
  {
48
37
  ...rest,
49
38
  isWheelDisabled,
50
39
  defaultValue,
51
- className: rootClassName,
40
+ className: clsx(rootClassName, fieldProps.className),
52
41
  children: [
53
- /* @__PURE__ */ jsx(PropsContextProvider, { props: propsContext, children }),
42
+ /* @__PURE__ */ jsxs(PropsContextProvider, { props: fieldPropsContext, children: [
43
+ children,
44
+ /* @__PURE__ */ jsx(FieldErrorView, {})
45
+ ] }),
54
46
  /* @__PURE__ */ jsxs(Aria.Group, { className: styles.group, children: [
55
47
  /* @__PURE__ */ jsxs(
56
48
  Button,
@@ -88,8 +80,7 @@ const NumberField = flowComponent("NumberField", (props) => {
88
80
  ]
89
81
  }
90
82
  )
91
- ] }),
92
- /* @__PURE__ */ jsx(FieldError, { className: formFieldStyles.fieldError })
83
+ ] })
93
84
  ]
94
85
  }
95
86
  );
@@ -1 +1 @@
1
- {"version":3,"file":"NumberField.mjs","sources":["../../../../../../src/components/NumberField/NumberField.tsx"],"sourcesContent":["import type { PropsWithChildren } from \"react\";\nimport * as Aria from \"react-aria-components\";\nimport formFieldStyles from \"../FormField/FormField.module.scss\";\nimport styles from \"./NumberField.module.scss\";\nimport clsx from \"clsx\";\nimport type { PropsContext } from \"@/lib/propsContext\";\nimport { PropsContextProvider } from \"@/lib/propsContext\";\nimport { FieldError } from \"@/components/FieldError\";\nimport { Button } from \"@/components/Button\";\nimport {\n IconChevronDown,\n IconChevronUp,\n IconMinus,\n IconPlus,\n} from \"@/components/Icon/components/icons\";\nimport type { FlowComponentProps } from \"@/lib/componentFactory/flowComponent\";\nimport { flowComponent } from \"@/lib/componentFactory/flowComponent\";\nimport { ReactAriaControlledValueFix } from \"@/lib/react/ReactAriaControlledValueFix\";\n\nexport interface NumberFieldProps\n extends PropsWithChildren<Omit<Aria.NumberFieldProps, \"children\">>,\n FlowComponentProps<HTMLInputElement> {}\n\n/** @flr-generate all */\nexport const NumberField = flowComponent(\"NumberField\", (props) => {\n const {\n children,\n className,\n ref,\n defaultValue,\n isWheelDisabled = true,\n ...rest\n } = props;\n\n const rootClassName = clsx(formFieldStyles.formField, className);\n\n const propsContext: PropsContext = {\n Label: {\n className: formFieldStyles.label,\n optional: !props.isRequired,\n },\n FieldDescription: {\n className: formFieldStyles.fieldDescription,\n },\n FieldError: {\n className: formFieldStyles.customFieldError,\n },\n };\n\n return (\n <Aria.NumberField\n {...rest}\n isWheelDisabled={isWheelDisabled}\n defaultValue={defaultValue}\n className={rootClassName}\n >\n <PropsContextProvider props={propsContext}>\n {children}\n </PropsContextProvider>\n <Aria.Group className={styles.group}>\n <Button\n ariaSlot=\"decrement\"\n className={styles.decrementButton}\n size=\"s\"\n variant=\"plain\"\n color=\"secondary\"\n >\n <IconChevronDown />\n <IconMinus className={styles.coarsePointerIcon} />\n </Button>\n <ReactAriaControlledValueFix\n inputContext={Aria.InputContext}\n props={props}\n >\n <Aria.Input className={styles.input} ref={ref} />\n </ReactAriaControlledValueFix>\n <Button\n ariaSlot=\"increment\"\n className={styles.incrementButton}\n size=\"s\"\n variant=\"plain\"\n color=\"secondary\"\n >\n <IconChevronUp />\n <IconPlus className={styles.coarsePointerIcon} />\n </Button>\n </Aria.Group>\n <FieldError className={formFieldStyles.fieldError} />\n </Aria.NumberField>\n );\n});\n\nexport default NumberField;\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAwBO,MAAM,WAAA,GAAc,aAAA,CAAc,aAAA,EAAe,CAAC,KAAA,KAAU;AACjE,EAAA,MAAM;AAAA,IACJ,QAAA;AAAA,IACA,SAAA;AAAA,IACA,GAAA;AAAA,IACA,YAAA;AAAA,IACA,eAAA,GAAkB,IAAA;AAAA,IAClB,GAAG;AAAA,GACL,GAAI,KAAA;AAEJ,EAAA,MAAM,aAAA,GAAgB,IAAA,CAAK,eAAA,CAAgB,SAAA,EAAW,SAAS,CAAA;AAE/D,EAAA,MAAM,YAAA,GAA6B;AAAA,IACjC,KAAA,EAAO;AAAA,MACL,WAAW,eAAA,CAAgB,KAAA;AAAA,MAC3B,QAAA,EAAU,CAAC,KAAA,CAAM;AAAA,KAC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AAA,cACL,OAAA,EAAQ,OAAA;AAAA,cACR,KAAA,EAAM,WAAA;AAAA,cAEN,QAAA,EAAA;AAAA,gCAAA,GAAA,CAAC,aAAA,EAAA,EAAc,CAAA;AAAA,gCACf,GAAA,CAAC,QAAA,EAAA,EAAS,SAAA,EAAW,MAAA,CAAO,iBAAA,EAAmB;AAAA;AAAA;AAAA;AACjD,SAAA,EACF,CAAA;AAAA,wBACA,GAAA,CAAC,UAAA,EAAA,EAAW,SAAA,EAAW,eAAA,CAAgB,UAAA,EAAY;AAAA;AAAA;AAAA,GACrD;AAEJ,CAAC;;;;"}
1
+ {"version":3,"file":"NumberField.mjs","sources":["../../../../../../src/components/NumberField/NumberField.tsx"],"sourcesContent":["import React, { type PropsWithChildren } from \"react\";\nimport * as Aria from \"react-aria-components\";\nimport formFieldStyles from \"../FormField/FormField.module.scss\";\nimport styles from \"./NumberField.module.scss\";\nimport clsx from \"clsx\";\nimport { PropsContextProvider } from \"@/lib/propsContext\";\nimport { Button } from \"@/components/Button\";\nimport {\n IconChevronDown,\n IconChevronUp,\n IconMinus,\n IconPlus,\n} from \"@/components/Icon/components/icons\";\nimport type { FlowComponentProps } from \"@/lib/componentFactory/flowComponent\";\nimport { flowComponent } from \"@/lib/componentFactory/flowComponent\";\nimport { ReactAriaControlledValueFix } from \"@/lib/react/ReactAriaControlledValueFix\";\nimport { useFieldComponent } from \"@/lib/hooks/useFieldComponent\";\n\nexport interface NumberFieldProps\n extends PropsWithChildren<Omit<Aria.NumberFieldProps, \"children\">>,\n FlowComponentProps<HTMLInputElement> {}\n\n/** @flr-generate all */\nexport const NumberField = flowComponent(\"NumberField\", (props) => {\n const {\n children,\n className,\n ref,\n defaultValue,\n isWheelDisabled = true,\n ...rest\n } = props;\n\n const { FieldErrorView, fieldProps, fieldPropsContext } =\n useFieldComponent(props);\n\n const rootClassName = clsx(formFieldStyles.formField, className);\n\n return (\n <Aria.NumberField\n {...rest}\n isWheelDisabled={isWheelDisabled}\n defaultValue={defaultValue}\n className={clsx(rootClassName, fieldProps.className)}\n >\n <PropsContextProvider props={fieldPropsContext}>\n {children}\n <FieldErrorView />\n </PropsContextProvider>\n <Aria.Group className={styles.group}>\n <Button\n ariaSlot=\"decrement\"\n className={styles.decrementButton}\n size=\"s\"\n variant=\"plain\"\n color=\"secondary\"\n >\n <IconChevronDown />\n <IconMinus className={styles.coarsePointerIcon} />\n </Button>\n <ReactAriaControlledValueFix\n inputContext={Aria.InputContext}\n props={props}\n >\n <Aria.Input className={styles.input} ref={ref} />\n </ReactAriaControlledValueFix>\n <Button\n ariaSlot=\"increment\"\n className={styles.incrementButton}\n size=\"s\"\n variant=\"plain\"\n color=\"secondary\"\n >\n <IconChevronUp />\n <IconPlus className={styles.coarsePointerIcon} />\n </Button>\n </Aria.Group>\n </Aria.NumberField>\n );\n});\n\nexport default NumberField;\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAuBO,MAAM,WAAA,GAAc,aAAA,CAAc,aAAA,EAAe,CAAC,KAAA,KAAU;AACjE,EAAA,MAAM;AAAA,IACJ,QAAA;AAAA,IACA,SAAA;AAAA,IACA,GAAA;AAAA,IACA,YAAA;AAAA,IACA,eAAA,GAAkB,IAAA;AAAA,IAClB,GAAG;AAAA,GACL,GAAI,KAAA;AAEJ,EAAA,MAAM,EAAE,cAAA,EAAgB,UAAA,EAAY,iBAAA,EAAkB,GACpD,kBAAkB,KAAK,CAAA;AAEzB,EAAA,MAAM,aAAA,GAAgB,IAAA,CAAK,eAAA,CAAgB,SAAA,EAAW,SAAS,CAAA;AAE/D,EAAA,uBACE,IAAA;AAAA,IAAC,IAAA,CAAK,WAAA;AAAA,IAAL;AAAA,MACE,GAAG,IAAA;AAAA,MACJ,eAAA;AAAA,MACA,YAAA;AAAA,MACA,SAAA,EAAW,IAAA,CAAK,aAAA,EAAe,UAAA,CAAW,SAAS,CAAA;AAAA,MAEnD,QAAA,EAAA;AAAA,wBAAA,IAAA,CAAC,oBAAA,EAAA,EAAqB,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