@portnet/ui 6.0.1 → 6.0.2
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 +85 -0
- package/dist/esm/index.js +18 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/v2/__tests__/FieldError.test.js +0 -1
- package/dist/esm/v2/__tests__/FieldError.test.js.map +1 -1
- package/dist/esm/v2/__tests__/FieldWidth.test.js +146 -0
- package/dist/esm/v2/__tests__/FieldWidth.test.js.map +1 -0
- package/dist/esm/v2/__tests__/FileCard.test.js +0 -1
- package/dist/esm/v2/__tests__/FileCard.test.js.map +1 -1
- package/dist/esm/v2/__tests__/FormikCheckbox.test.js +265 -0
- package/dist/esm/v2/__tests__/FormikCheckbox.test.js.map +1 -0
- package/dist/esm/v2/__tests__/FormikDateTimePicker.test.js +248 -0
- package/dist/esm/v2/__tests__/FormikDateTimePicker.test.js.map +1 -0
- package/dist/esm/v2/__tests__/FormikRadioGroup.test.js +380 -0
- package/dist/esm/v2/__tests__/FormikRadioGroup.test.js.map +1 -0
- package/dist/esm/v2/__tests__/MobileRowCard.test.js +0 -1
- package/dist/esm/v2/__tests__/MobileRowCard.test.js.map +1 -1
- package/dist/esm/v2/__tests__/SectionErrorBoundary.test.js.map +1 -1
- package/dist/esm/v2/__tests__/labels-merge.test.js +0 -1
- package/dist/esm/v2/__tests__/labels-merge.test.js.map +1 -1
- package/dist/esm/v2/components/DateTimePicker.js +37 -4
- package/dist/esm/v2/components/DateTimePicker.js.map +1 -1
- package/dist/esm/v2/components/Field.js +63 -1
- package/dist/esm/v2/components/Field.js.map +1 -1
- package/dist/esm/v2/components/index.js +27 -0
- package/dist/esm/v2/components/index.js.map +1 -1
- package/dist/esm/v2/index.js +12 -1
- package/dist/esm/v2/index.js.map +1 -1
- package/dist/esm/v2/patterns/FavoriteColumn.js +14 -61
- package/dist/esm/v2/patterns/FavoriteColumn.js.map +1 -1
- package/dist/esm/v2/patterns/FormikCheckbox.js +140 -0
- package/dist/esm/v2/patterns/FormikCheckbox.js.map +1 -0
- package/dist/esm/v2/patterns/FormikCombobox.js +5 -2
- package/dist/esm/v2/patterns/FormikCombobox.js.map +1 -1
- package/dist/esm/v2/patterns/FormikDatePicker.js +13 -47
- package/dist/esm/v2/patterns/FormikDatePicker.js.map +1 -1
- package/dist/esm/v2/patterns/FormikDateTimePicker.js +150 -0
- package/dist/esm/v2/patterns/FormikDateTimePicker.js.map +1 -0
- package/dist/esm/v2/patterns/FormikInput.js +5 -2
- package/dist/esm/v2/patterns/FormikInput.js.map +1 -1
- package/dist/esm/v2/patterns/FormikRadioGroup.js +141 -0
- package/dist/esm/v2/patterns/FormikRadioGroup.js.map +1 -0
- package/dist/esm/v2/patterns/FormikSelect.js +5 -2
- package/dist/esm/v2/patterns/FormikSelect.js.map +1 -1
- package/dist/esm/v2/patterns/FormikTextarea.js +5 -2
- package/dist/esm/v2/patterns/FormikTextarea.js.map +1 -1
- package/dist/esm/v2/patterns/KeyboardShortcutsHelp.js +25 -8
- package/dist/esm/v2/patterns/KeyboardShortcutsHelp.js.map +1 -1
- package/dist/esm/v2/patterns/RowFavoriteToggle.js +122 -0
- package/dist/esm/v2/patterns/RowFavoriteToggle.js.map +1 -0
- package/dist/esm/v2/patterns/_pickerSerialisation.js +74 -0
- package/dist/esm/v2/patterns/_pickerSerialisation.js.map +1 -0
- package/dist/esm/v2/patterns/index.js +83 -0
- package/dist/esm/v2/patterns/index.js.map +1 -1
- package/dist/esm/v2/personalization/capabilities/gridPreferences.js +209 -0
- package/dist/esm/v2/personalization/capabilities/gridPreferences.js.map +1 -0
- package/dist/esm/v2/personalization/capabilities/index.js +5 -0
- package/dist/esm/v2/personalization/capabilities/index.js.map +1 -1
- package/dist/esm/v2/personalization/index.js +18 -0
- package/dist/esm/v2/personalization/index.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -1
- package/dist/v2/__tests__/FieldError.test.js +26 -30
- package/dist/v2/__tests__/FieldError.test.js.map +1 -1
- package/dist/v2/__tests__/FieldWidth.test.js +150 -0
- package/dist/v2/__tests__/FieldWidth.test.js.map +1 -0
- package/dist/v2/__tests__/FileCard.test.js +25 -29
- package/dist/v2/__tests__/FileCard.test.js.map +1 -1
- package/dist/v2/__tests__/FormikCheckbox.test.js +268 -0
- package/dist/v2/__tests__/FormikCheckbox.test.js.map +1 -0
- package/dist/v2/__tests__/FormikDateTimePicker.test.js +247 -0
- package/dist/v2/__tests__/FormikDateTimePicker.test.js.map +1 -0
- package/dist/v2/__tests__/FormikRadioGroup.test.js +381 -0
- package/dist/v2/__tests__/FormikRadioGroup.test.js.map +1 -0
- package/dist/v2/__tests__/MobileRowCard.test.js +52 -56
- package/dist/v2/__tests__/MobileRowCard.test.js.map +1 -1
- package/dist/v2/__tests__/SectionErrorBoundary.test.js.map +1 -1
- package/dist/v2/__tests__/labels-merge.test.js +20 -24
- package/dist/v2/__tests__/labels-merge.test.js.map +1 -1
- package/dist/v2/components/DateTimePicker.d.ts.map +1 -1
- package/dist/v2/components/DateTimePicker.js +37 -4
- package/dist/v2/components/DateTimePicker.js.map +1 -1
- package/dist/v2/components/Field.d.ts +59 -1
- package/dist/v2/components/Field.d.ts.map +1 -1
- package/dist/v2/components/Field.js +62 -2
- package/dist/v2/components/Field.js.map +1 -1
- package/dist/v2/components/index.d.ts +27 -0
- package/dist/v2/components/index.d.ts.map +1 -1
- package/dist/v2/components/index.js.map +1 -1
- package/dist/v2/index.d.ts.map +1 -1
- package/dist/v2/index.js.map +1 -1
- package/dist/v2/patterns/FavoriteColumn.d.ts +9 -9
- package/dist/v2/patterns/FavoriteColumn.d.ts.map +1 -1
- package/dist/v2/patterns/FavoriteColumn.js +14 -61
- package/dist/v2/patterns/FavoriteColumn.js.map +1 -1
- package/dist/v2/patterns/FormikCheckbox.d.ts +77 -0
- package/dist/v2/patterns/FormikCheckbox.d.ts.map +1 -0
- package/dist/v2/patterns/FormikCheckbox.js +147 -0
- package/dist/v2/patterns/FormikCheckbox.js.map +1 -0
- package/dist/v2/patterns/FormikCombobox.d.ts +7 -1
- package/dist/v2/patterns/FormikCombobox.d.ts.map +1 -1
- package/dist/v2/patterns/FormikCombobox.js +5 -2
- package/dist/v2/patterns/FormikCombobox.js.map +1 -1
- package/dist/v2/patterns/FormikDatePicker.d.ts +13 -1
- package/dist/v2/patterns/FormikDatePicker.d.ts.map +1 -1
- package/dist/v2/patterns/FormikDatePicker.js +33 -66
- package/dist/v2/patterns/FormikDatePicker.js.map +1 -1
- package/dist/v2/patterns/FormikDateTimePicker.d.ts +111 -0
- package/dist/v2/patterns/FormikDateTimePicker.d.ts.map +1 -0
- package/dist/v2/patterns/FormikDateTimePicker.js +158 -0
- package/dist/v2/patterns/FormikDateTimePicker.js.map +1 -0
- package/dist/v2/patterns/FormikInput.d.ts +11 -1
- package/dist/v2/patterns/FormikInput.d.ts.map +1 -1
- package/dist/v2/patterns/FormikInput.js +5 -2
- package/dist/v2/patterns/FormikInput.js.map +1 -1
- package/dist/v2/patterns/FormikRadioGroup.d.ts +80 -0
- package/dist/v2/patterns/FormikRadioGroup.d.ts.map +1 -0
- package/dist/v2/patterns/FormikRadioGroup.js +148 -0
- package/dist/v2/patterns/FormikRadioGroup.js.map +1 -0
- package/dist/v2/patterns/FormikSelect.d.ts +9 -1
- package/dist/v2/patterns/FormikSelect.d.ts.map +1 -1
- package/dist/v2/patterns/FormikSelect.js +5 -2
- package/dist/v2/patterns/FormikSelect.js.map +1 -1
- package/dist/v2/patterns/FormikTextarea.d.ts +9 -1
- package/dist/v2/patterns/FormikTextarea.d.ts.map +1 -1
- package/dist/v2/patterns/FormikTextarea.js +5 -2
- package/dist/v2/patterns/FormikTextarea.js.map +1 -1
- package/dist/v2/patterns/KeyboardShortcutsHelp.d.ts +14 -1
- package/dist/v2/patterns/KeyboardShortcutsHelp.d.ts.map +1 -1
- package/dist/v2/patterns/KeyboardShortcutsHelp.js +25 -8
- package/dist/v2/patterns/KeyboardShortcutsHelp.js.map +1 -1
- package/dist/v2/patterns/RowFavoriteToggle.d.ts +92 -0
- package/dist/v2/patterns/RowFavoriteToggle.d.ts.map +1 -0
- package/dist/v2/patterns/RowFavoriteToggle.js +127 -0
- package/dist/v2/patterns/RowFavoriteToggle.js.map +1 -0
- package/dist/v2/patterns/_pickerSerialisation.d.ts +44 -0
- package/dist/v2/patterns/_pickerSerialisation.d.ts.map +1 -0
- package/dist/v2/patterns/_pickerSerialisation.js +81 -0
- package/dist/v2/patterns/_pickerSerialisation.js.map +1 -0
- package/dist/v2/patterns/index.d.ts +87 -0
- package/dist/v2/patterns/index.d.ts.map +1 -1
- package/dist/v2/patterns/index.js +34 -0
- package/dist/v2/patterns/index.js.map +1 -1
- package/dist/v2/personalization/capabilities/gridPreferences.d.ts +100 -0
- package/dist/v2/personalization/capabilities/gridPreferences.d.ts.map +1 -0
- package/dist/v2/personalization/capabilities/gridPreferences.js +215 -0
- package/dist/v2/personalization/capabilities/gridPreferences.js.map +1 -0
- package/dist/v2/personalization/capabilities/index.d.ts +6 -0
- package/dist/v2/personalization/capabilities/index.d.ts.map +1 -1
- package/dist/v2/personalization/capabilities/index.js +13 -0
- package/dist/v2/personalization/capabilities/index.js.map +1 -1
- package/dist/v2/personalization/index.d.ts +18 -0
- package/dist/v2/personalization/index.d.ts.map +1 -1
- package/dist/v2/personalization/index.js +13 -0
- package/dist/v2/personalization/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormikCombobox.js","names":["useField","useFormikContext","Field","Combobox","jsx","_jsx","FormikCombobox","_ref","_field$value","name","label","required","_ref$options","options","loading","disabled","htmlFor","hint","getOptionLabel","getOptionValue","descriptionField","onSelectionChange","rest","_objectWithoutProperties","_excluded","_useField","_useField2","_slicedToArray","field","meta","_useFormikContext","setFieldValue","setFieldTouched","hasError","Boolean","touched","error","v2Options","map","opt","_ref2","_ref3","_typeof","rec","rawLabel","safeLabel","String","helper","value","__raw","handleChange","next","_raw","_v2Options$find","picked","find","o","_objectSpread","undefined","children","onChange"],"sources":["../../../../src/lib/v2/patterns/FormikCombobox.tsx"],"sourcesContent":["/**\r\n * FormikCombobox — bridge between Formik state and v2.Field +\r\n * v2.Combobox.\r\n *\r\n * Maps caller-supplied raw options to v2.Combobox's {value, label,\r\n * helper} shape and exposes onSelectionChange(rawOption) for\r\n * consumers that need cross-field side effects on pick.\r\n *\r\n * Charter R-Sel.1 → R-Sel.4. Peer dependency: formik >= 2.x.\r\n *\r\n * Hardening notes:\r\n * - B7: defensive String() cast on the resolved label so a\r\n * consumer-supplied getOptionLabel that returns a React node\r\n * never crashes Autocomplete with the cryptic \"Objects are\r\n * not valid as a React child\" error.\r\n * - B10: `descriptionField` alias mirrors the legacy\r\n * AppFormikSelect API — surfaces option[descriptionField] as\r\n * the helper line under each Combobox row.\r\n */\r\n\r\nimport type { ReactNode } from \"react\";\r\nimport { useField, useFormikContext } from \"formik\";\r\nimport Field from \"../components/Field\";\r\nimport Combobox from \"../components/Combobox\";\r\nimport type {\r\n ComboboxProps,\r\n ComboboxOption,\r\n ComboboxOptionValue,\r\n ComboboxValue,\r\n} from \"../components/Combobox\";\r\n\r\nexport interface FormikComboboxProps<TOption = unknown>\r\n extends Omit<\r\n ComboboxProps,\r\n \"value\" | \"onChange\" | \"options\" | \"loading\" | \"disabled\" | \"getOptionLabel\"\r\n > {\r\n name: string;\r\n label?: ReactNode | undefined;\r\n required?: boolean | undefined;\r\n options?: readonly TOption[] | undefined;\r\n loading?: boolean | undefined;\r\n disabled?: boolean | undefined;\r\n htmlFor?: string | undefined;\r\n hint?: ReactNode | undefined;\r\n getOptionLabel?: ((opt: TOption) => ReactNode) | undefined;\r\n getOptionValue?: ((opt: TOption) => ComboboxOptionValue) | undefined;\r\n /**\r\n * Key on each raw option whose value should appear as a helper\r\n * line beneath the main label in the dropdown. Equivalent to\r\n * the legacy `descriptionField` prop on AppFormikSelect.\r\n */\r\n descriptionField?: string | undefined;\r\n onSelectionChange?: ((raw: TOption | null) => void) | undefined;\r\n}\r\n\r\nfunction FormikCombobox<TOption = unknown>({\r\n name,\r\n label,\r\n required,\r\n options = [],\r\n loading,\r\n disabled,\r\n htmlFor,\r\n hint,\r\n getOptionLabel,\r\n getOptionValue,\r\n descriptionField,\r\n onSelectionChange,\r\n ...rest\r\n}: FormikComboboxProps<TOption>) {\r\n const [field, meta] = useField(name);\r\n const { setFieldValue, setFieldTouched } = useFormikContext();\r\n const hasError = Boolean(meta.touched && meta.error);\r\n\r\n const v2Options = options.map((opt) => {\r\n if (opt == null || typeof opt !== \"object\") return opt;\r\n const rec = opt as Record<string, unknown>;\r\n const rawLabel =\r\n typeof getOptionLabel === \"function\" ? getOptionLabel(opt) : rec[\"label\"];\r\n // B7: harden against getOptionLabel returning a React node.\r\n // v2.Combobox feeds the label back through its internal\r\n // labelOf when computing the displayed value, and that path\r\n // assumes string. Always coerce defensively.\r\n const safeLabel =\r\n typeof rawLabel === \"string\" || rawLabel == null\r\n ? rawLabel\r\n : String(rawLabel);\r\n // B10: descriptionField alias → helper. Falls back to the\r\n // canonical `helper`/`summary` fields if neither is set.\r\n const helper =\r\n ((descriptionField && rec[descriptionField]) ?? rec[\"helper\"] ?? rec[\"summary\"]) as ReactNode;\r\n return {\r\n value: typeof getOptionValue === \"function\" ? getOptionValue(opt) : opt,\r\n label: safeLabel,\r\n helper,\r\n __raw: opt,\r\n };\r\n });\r\n\r\n const handleChange = (next: ComboboxValue): void => {\r\n setFieldValue(name, next);\r\n setFieldTouched(name, true, false);\r\n if (typeof onSelectionChange === \"function\") {\r\n const picked =\r\n (\r\n v2Options.find(\r\n (o) =>\r\n o != null &&\r\n typeof o === \"object\" &&\r\n \"value\" in o &&\r\n (o as { value?: unknown }).value === next\r\n ) as { __raw?: unknown } | undefined\r\n )?.__raw ?? null;\r\n onSelectionChange(picked as TOption | null);\r\n }\r\n };\r\n\r\n return (\r\n <Field\r\n label={label}\r\n error={hasError ? meta.error : null}\r\n hint={!hasError ? hint : undefined}\r\n htmlFor={htmlFor || name}\r\n {...(required !== undefined ? { required } : {})}\r\n {...(disabled !== undefined ? { disabled } : {})}\r\n >\r\n <Combobox\r\n value={field.value ?? null}\r\n options={v2Options as Array<string | ComboboxOption>}\r\n onChange={handleChange}\r\n {...rest}\r\n {...(loading !== undefined ? { loading } : {})}\r\n />\r\n </Field>\r\n );\r\n}\r\n\r\nexport default FormikCombobox;\r\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,QAAQ,EAAEC,gBAAgB,QAAQ,QAAQ;AACnD,OAAOC,KAAK,MAAM,qBAAqB;AACvC,OAAOC,QAAQ,MAAM,wBAAwB;AAAC,SAAAC,GAAA,IAAAC,IAAA;
|
|
1
|
+
{"version":3,"file":"FormikCombobox.js","names":["useField","useFormikContext","Field","Combobox","jsx","_jsx","FormikCombobox","_ref","_field$value","name","label","required","_ref$options","options","loading","disabled","htmlFor","hint","getOptionLabel","getOptionValue","descriptionField","width","onSelectionChange","rest","_objectWithoutProperties","_excluded","_useField","_useField2","_slicedToArray","field","meta","_useFormikContext","setFieldValue","setFieldTouched","hasError","Boolean","touched","error","v2Options","map","opt","_ref2","_ref3","_typeof","rec","rawLabel","safeLabel","String","helper","value","__raw","handleChange","next","_raw","_v2Options$find","picked","find","o","_objectSpread","undefined","children","onChange"],"sources":["../../../../src/lib/v2/patterns/FormikCombobox.tsx"],"sourcesContent":["/**\r\n * FormikCombobox — bridge between Formik state and v2.Field +\r\n * v2.Combobox.\r\n *\r\n * Maps caller-supplied raw options to v2.Combobox's {value, label,\r\n * helper} shape and exposes onSelectionChange(rawOption) for\r\n * consumers that need cross-field side effects on pick.\r\n *\r\n * Charter R-Sel.1 → R-Sel.4. Peer dependency: formik >= 2.x.\r\n *\r\n * Hardening notes:\r\n * - B7: defensive String() cast on the resolved label so a\r\n * consumer-supplied getOptionLabel that returns a React node\r\n * never crashes Autocomplete with the cryptic \"Objects are\r\n * not valid as a React child\" error.\r\n * - B10: `descriptionField` alias mirrors the legacy\r\n * AppFormikSelect API — surfaces option[descriptionField] as\r\n * the helper line under each Combobox row.\r\n */\r\n\r\nimport type { ReactNode } from \"react\";\r\nimport { useField, useFormikContext } from \"formik\";\r\nimport Field from \"../components/Field\";\r\nimport Combobox from \"../components/Combobox\";\r\nimport type { FieldWidth } from \"../components/Field\";\r\nimport type {\r\n ComboboxProps,\r\n ComboboxOption,\r\n ComboboxOptionValue,\r\n ComboboxValue,\r\n} from \"../components/Combobox\";\r\n\r\nexport interface FormikComboboxProps<TOption = unknown>\r\n extends Omit<\r\n ComboboxProps,\r\n \"value\" | \"onChange\" | \"options\" | \"loading\" | \"disabled\" | \"getOptionLabel\"\r\n > {\r\n name: string;\r\n label?: ReactNode | undefined;\r\n required?: boolean | undefined;\r\n options?: readonly TOption[] | undefined;\r\n loading?: boolean | undefined;\r\n disabled?: boolean | undefined;\r\n htmlFor?: string | undefined;\r\n hint?: ReactNode | undefined;\r\n getOptionLabel?: ((opt: TOption) => ReactNode) | undefined;\r\n getOptionValue?: ((opt: TOption) => ComboboxOptionValue) | undefined;\r\n /**\r\n * Key on each raw option whose value should appear as a helper\r\n * line beneath the main label in the dropdown. Equivalent to\r\n * the legacy `descriptionField` prop on AppFormikSelect.\r\n */\r\n descriptionField?: string | undefined;\r\n /**\r\n * Gabarit de largeur semantique (G-H). Le standard range les « complex\r\n * search auto-completes » en `l` : c'est le cas le plus courant ici.\r\n */\r\n width?: FieldWidth | undefined;\r\n onSelectionChange?: ((raw: TOption | null) => void) | undefined;\r\n}\r\n\r\nfunction FormikCombobox<TOption = unknown>({\r\n name,\r\n label,\r\n required,\r\n options = [],\r\n loading,\r\n disabled,\r\n htmlFor,\r\n hint,\r\n getOptionLabel,\r\n getOptionValue,\r\n descriptionField,\r\n width,\r\n onSelectionChange,\r\n ...rest\r\n}: FormikComboboxProps<TOption>) {\r\n const [field, meta] = useField(name);\r\n const { setFieldValue, setFieldTouched } = useFormikContext();\r\n const hasError = Boolean(meta.touched && meta.error);\r\n\r\n const v2Options = options.map((opt) => {\r\n if (opt == null || typeof opt !== \"object\") return opt;\r\n const rec = opt as Record<string, unknown>;\r\n const rawLabel =\r\n typeof getOptionLabel === \"function\" ? getOptionLabel(opt) : rec[\"label\"];\r\n // B7: harden against getOptionLabel returning a React node.\r\n // v2.Combobox feeds the label back through its internal\r\n // labelOf when computing the displayed value, and that path\r\n // assumes string. Always coerce defensively.\r\n const safeLabel =\r\n typeof rawLabel === \"string\" || rawLabel == null\r\n ? rawLabel\r\n : String(rawLabel);\r\n // B10: descriptionField alias → helper. Falls back to the\r\n // canonical `helper`/`summary` fields if neither is set.\r\n const helper =\r\n ((descriptionField && rec[descriptionField]) ?? rec[\"helper\"] ?? rec[\"summary\"]) as ReactNode;\r\n return {\r\n value: typeof getOptionValue === \"function\" ? getOptionValue(opt) : opt,\r\n label: safeLabel,\r\n helper,\r\n __raw: opt,\r\n };\r\n });\r\n\r\n const handleChange = (next: ComboboxValue): void => {\r\n setFieldValue(name, next);\r\n setFieldTouched(name, true, false);\r\n if (typeof onSelectionChange === \"function\") {\r\n const picked =\r\n (\r\n v2Options.find(\r\n (o) =>\r\n o != null &&\r\n typeof o === \"object\" &&\r\n \"value\" in o &&\r\n (o as { value?: unknown }).value === next\r\n ) as { __raw?: unknown } | undefined\r\n )?.__raw ?? null;\r\n onSelectionChange(picked as TOption | null);\r\n }\r\n };\r\n\r\n return (\r\n <Field\r\n label={label}\r\n error={hasError ? meta.error : null}\r\n hint={!hasError ? hint : undefined}\r\n htmlFor={htmlFor || name}\r\n {...(required !== undefined ? { required } : {})}\r\n {...(disabled !== undefined ? { disabled } : {})}\r\n {...(width !== undefined ? { width } : {})}\r\n >\r\n <Combobox\r\n value={field.value ?? null}\r\n options={v2Options as Array<string | ComboboxOption>}\r\n onChange={handleChange}\r\n {...rest}\r\n {...(loading !== undefined ? { loading } : {})}\r\n />\r\n </Field>\r\n );\r\n}\r\n\r\nexport default FormikCombobox;\r\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,QAAQ,EAAEC,gBAAgB,QAAQ,QAAQ;AACnD,OAAOC,KAAK,MAAM,qBAAqB;AACvC,OAAOC,QAAQ,MAAM,wBAAwB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAsC9C,SAASC,cAAcA,CAAAC,IAAA,EAeU;EAAA,IAAAC,YAAA;EAAA,IAd/BC,IAAI,GAAAF,IAAA,CAAJE,IAAI;IACJC,KAAK,GAAAH,IAAA,CAALG,KAAK;IACLC,QAAQ,GAAAJ,IAAA,CAARI,QAAQ;IAAAC,YAAA,GAAAL,IAAA,CACRM,OAAO;IAAPA,OAAO,GAAAD,YAAA,cAAG,EAAE,GAAAA,YAAA;IACZE,OAAO,GAAAP,IAAA,CAAPO,OAAO;IACPC,QAAQ,GAAAR,IAAA,CAARQ,QAAQ;IACRC,OAAO,GAAAT,IAAA,CAAPS,OAAO;IACPC,IAAI,GAAAV,IAAA,CAAJU,IAAI;IACJC,cAAc,GAAAX,IAAA,CAAdW,cAAc;IACdC,cAAc,GAAAZ,IAAA,CAAdY,cAAc;IACdC,gBAAgB,GAAAb,IAAA,CAAhBa,gBAAgB;IAChBC,KAAK,GAAAd,IAAA,CAALc,KAAK;IACLC,iBAAiB,GAAAf,IAAA,CAAjBe,iBAAiB;IACdC,IAAI,GAAAC,wBAAA,CAAAjB,IAAA,EAAAkB,SAAA;EAEP,IAAAC,SAAA,GAAsB1B,QAAQ,CAACS,IAAI,CAAC;IAAAkB,UAAA,GAAAC,cAAA,CAAAF,SAAA;IAA7BG,KAAK,GAAAF,UAAA;IAAEG,IAAI,GAAAH,UA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AAA,GAAI,IAAK;MAC3BK,OAAO,EAAEyB,SAA4C;MACrDuB,QAAQ,EAAEV;IAAa,GACnB5B,IAAI,GACHT,OAAO,KAAK6C,SAAS,GAAG;MAAE7C,OAAO,EAAPA;IAAQ,CAAC,GAAG,CAAC,CAAC,CAC9C;EAAC,EACG,CAAC;AAEZ;AAEA,eAAeR,cAAc","ignoreList":[]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
+
var _excluded = ["name", "label", "required", "disabled", "readOnly", "readOnlyFormat", "htmlFor", "hint", "outputFormat", "width"];
|
|
2
3
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
3
4
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
5
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
@@ -12,7 +13,6 @@ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefine
|
|
|
12
13
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
13
14
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
14
15
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
15
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
16
16
|
/**
|
|
17
17
|
* FormikDatePicker — bridge between Formik state and v2.Field +
|
|
18
18
|
* v2.DatePicker.
|
|
@@ -63,6 +63,12 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
|
63
63
|
* objects, so they have no serialisation step and no equivalent asymmetry;
|
|
64
64
|
* _pickerShared carries only Date<->Moment converters, not string parsing.
|
|
65
65
|
*
|
|
66
|
+
* UPDATE (gap G-E): `FormikDateTimePicker` now exists too, and the two bridges
|
|
67
|
+
* SHARE `coerceToDate` / `serialiseDate` via `./_pickerSerialisation`. Keeping
|
|
68
|
+
* a private copy in each would have re-created the very asymmetry S-03
|
|
69
|
+
* describes, in a form even harder to spot: two bridges that look alike, that
|
|
70
|
+
* nobody compares, and that each look correct on their own.
|
|
71
|
+
*
|
|
66
72
|
* Modal / Drawer usage (MUI X v9):
|
|
67
73
|
* When rendered inside a v2.Drawer or a MUI Modal, the DatePicker
|
|
68
74
|
* calendar popup may render behind the modal surface (both default
|
|
@@ -86,51 +92,8 @@ import { useField, useFormikContext } from "formik";
|
|
|
86
92
|
import Field from "../components/Field";
|
|
87
93
|
import DatePicker from "../components/DatePicker";
|
|
88
94
|
import FormikDisplay from "../components/FormikDisplay";
|
|
95
|
+
import { coerceToDate, serialiseDate } from "./_pickerSerialisation";
|
|
89
96
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
90
|
-
/**
|
|
91
|
-
* Read a Formik-stored value back into a Date.
|
|
92
|
-
*
|
|
93
|
-
* `outputFormat` is threaded in so the read is SYMMETRIC with `serialiseDate`
|
|
94
|
-
* (S-03). Without it, a non-ISO format written by moment was read by
|
|
95
|
-
* `new Date()`, which either rejects it or misreads it as MM-DD.
|
|
96
|
-
*/
|
|
97
|
-
var coerceToDate = function coerceToDate(raw, outputFormat) {
|
|
98
|
-
if (raw == null || raw === "") return null;
|
|
99
|
-
if (raw instanceof Date) return raw;
|
|
100
|
-
if (_typeof(raw) === "object" && typeof raw.toDate === "function") {
|
|
101
|
-
var _d$getTime;
|
|
102
|
-
var _d = raw.toDate();
|
|
103
|
-
return isNaN(_d === null || _d === void 0 ? void 0 : (_d$getTime = _d.getTime) === null || _d$getTime === void 0 ? void 0 : _d$getTime.call(_d)) ? null : _d;
|
|
104
|
-
}
|
|
105
|
-
/* S-03 — parse with the format it was written with. STRICT mode: a stored value
|
|
106
|
-
* that does not match yields null rather than moment's best guess.
|
|
107
|
-
*
|
|
108
|
-
* Guarded on `typeof raw === "string"` so a numeric timestamp keeps the
|
|
109
|
-
* `new Date(number)` path — moment(number, format) is meaningless. "iso" is
|
|
110
|
-
* excluded: it is not a moment token, and `new Date(isoString)` is already
|
|
111
|
-
* correct. */
|
|
112
|
-
if (typeof raw === "string" && outputFormat !== undefined && outputFormat !== "iso") {
|
|
113
|
-
var parsed = moment(raw, outputFormat, true);
|
|
114
|
-
return parsed.isValid() ? parsed.toDate() : null;
|
|
115
|
-
}
|
|
116
|
-
var d = new Date(raw);
|
|
117
|
-
return isNaN(d.getTime()) ? null : d;
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Serialise a Date to the requested output format.
|
|
122
|
-
* undefined → return the Date as-is (default — backward-compat)
|
|
123
|
-
* "iso" → Date.toISOString()
|
|
124
|
-
* any string → moment(date).format(outputFormat)
|
|
125
|
-
*/
|
|
126
|
-
function serialiseDate(date, outputFormat) {
|
|
127
|
-
if (!date || !(date instanceof Date) || isNaN(date.getTime())) {
|
|
128
|
-
return outputFormat ? "" : null;
|
|
129
|
-
}
|
|
130
|
-
if (!outputFormat) return date;
|
|
131
|
-
if (outputFormat === "iso") return date.toISOString();
|
|
132
|
-
return moment(date).format(outputFormat);
|
|
133
|
-
}
|
|
134
97
|
var FormikDatePicker = function FormikDatePicker(_ref) {
|
|
135
98
|
var name = _ref.name,
|
|
136
99
|
label = _ref.label,
|
|
@@ -142,6 +105,7 @@ var FormikDatePicker = function FormikDatePicker(_ref) {
|
|
|
142
105
|
htmlFor = _ref.htmlFor,
|
|
143
106
|
hint = _ref.hint,
|
|
144
107
|
outputFormat = _ref.outputFormat,
|
|
108
|
+
width = _ref.width,
|
|
145
109
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
146
110
|
var _useField = useField(name),
|
|
147
111
|
_useField2 = _slicedToArray(_useField, 2),
|
|
@@ -173,7 +137,7 @@ var FormikDatePicker = function FormikDatePicker(_ref) {
|
|
|
173
137
|
}
|
|
174
138
|
}));
|
|
175
139
|
}
|
|
176
|
-
return /*#__PURE__*/_jsx(Field, _objectSpread(_objectSpread(_objectSpread({
|
|
140
|
+
return /*#__PURE__*/_jsx(Field, _objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
177
141
|
label: label,
|
|
178
142
|
error: hasError ? meta.error : null,
|
|
179
143
|
hint: !hasError ? hint : undefined,
|
|
@@ -182,6 +146,8 @@ var FormikDatePicker = function FormikDatePicker(_ref) {
|
|
|
182
146
|
required: required
|
|
183
147
|
} : {}), disabled !== undefined ? {
|
|
184
148
|
disabled: disabled
|
|
149
|
+
} : {}), width !== undefined ? {
|
|
150
|
+
width: width
|
|
185
151
|
} : {}), {}, {
|
|
186
152
|
children: /*#__PURE__*/_jsx(DatePicker, _objectSpread({
|
|
187
153
|
value: coerceToDate(field.value, outputFormat),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormikDatePicker.js","names":["React","moment","useField","useFormikContext","Field","DatePicker","FormikDisplay","jsx","_jsx","coerceToDate","raw","outputFormat","Date","_typeof","toDate","_d$getTime","d","isNaN","getTime","call","undefined","parsed","isValid","serialiseDate","date","toISOString","format","FormikDatePicker","_ref","name","label","required","disabled","readOnly","_ref$readOnlyFormat","readOnlyFormat","htmlFor","hint","rest","_objectWithoutProperties","_excluded","_useField","_useField2","_slicedToArray","field","meta","_useFormikContext","setFieldValue","setFieldTouched","hasError","Boolean","touched","error","_objectSpread","children","value","onChange","next"],"sources":["../../../../src/lib/v2/patterns/FormikDatePicker.tsx"],"sourcesContent":["/**\r\n * FormikDatePicker — bridge between Formik state and v2.Field +\r\n * v2.DatePicker.\r\n *\r\n * v2.DatePicker emits Date | null. Formik state may carry Date,\r\n * ISO string, or moment instance — this bridge normalises inbound\r\n * values to Date for the picker.\r\n *\r\n * outputFormat prop (Charter R-I.*):\r\n * By default, onChange writes a Date | null back to Formik, which\r\n * is fine for Yup.date() schemas. If your schema uses Yup.string()\r\n * with a format test (e.g. \"DD-MM-YYYY\"), pass the matching moment\r\n * format string:\r\n *\r\n * <FormikDatePicker name=\"dateNaissance\" outputFormat=\"DD-MM-YYYY\" />\r\n *\r\n * The field then stores \"03-05-2026\" instead of a Date object.\r\n * Pass outputFormat=\"iso\" to store an ISO 8601 string instead.\r\n * Default (undefined) = Date | null (backward-compatible).\r\n *\r\n * ── outputFormat MUST ROUND-TRIP — and now does (S-03) ────────────────\r\n *\r\n * This bridge used to serialise OUT through moment but read BACK through\r\n * `new Date(raw)`, ignoring outputFormat. The asymmetry silently corrupted any\r\n * non-ISO format:\r\n *\r\n * new Date(\"31-12-2026\") -> month 31 invalid -> Invalid Date -> null\r\n * -> the field rendered EMPTY when re-populated\r\n * new Date(\"05-03-2026\") -> V8 reads MM-DD -> 3 May, not 5 March\r\n * -> saving untouched wrote back \"03-05-2026\"\r\n *\r\n * The write path worked, so a form filled in and submitted immediately behaved\r\n * correctly; the damage only surfaced on RE-POPULATE, i.e. an edit flow — the\r\n * path a smoke test is least likely to exercise. `procuration-portnet-fe` shipped\r\n * it for seven batches under a clean strict typecheck.\r\n *\r\n * `coerceToDate` now parses with the SAME format it was written with, in moment's\r\n * STRICT mode, so a malformed stored value yields null instead of a plausible\r\n * wrong date. A missing date is recoverable; a date quietly off by two months is\r\n * not.\r\n *\r\n * BEHAVIOURAL NOTE for existing non-ISO callers: they were mis-parsing before.\r\n * This changes their result from wrong to right — which is the point, but it is a\r\n * change. Callers passing nothing, or \"iso\", are on the identical code path.\r\n *\r\n * Audit: this is the ONLY Formik date bridge in the library. DateTimePicker,\r\n * TimePicker and DateRangePicker are exposed as bare components exchanging Date\r\n * objects, so they have no serialisation step and no equivalent asymmetry;\r\n * _pickerShared carries only Date<->Moment converters, not string parsing.\r\n *\r\n * Modal / Drawer usage (MUI X v9):\r\n * When rendered inside a v2.Drawer or a MUI Modal, the DatePicker\r\n * calendar popup may render behind the modal surface (both default\r\n * to zIndex 1300). In MUI X v9, the popper slot is forwarded via\r\n * slotProps.popper (the legacy `PopperProps` was removed). Pass:\r\n *\r\n * <FormikDatePicker\r\n * slotProps={{ popper: { sx: { zIndex: 1400 } } }}\r\n * />\r\n *\r\n * Slot props forward through ...rest to v2.DatePicker and on to\r\n * MuiDatePicker, where they merge with the textField slot bag\r\n * already wired by v2.DatePicker.\r\n *\r\n * Charter R-I.*.\r\n */\r\n\r\nimport * as React from \"react\";\r\nimport moment from \"moment\";\r\nimport { useField, useFormikContext } from \"formik\";\r\nimport Field from \"../components/Field\";\r\nimport DatePicker from \"../components/DatePicker\";\r\nimport FormikDisplay from \"../components/FormikDisplay\";\r\nimport type { DatePickerProps } from \"../components/DatePicker\";\r\n\r\n/**\r\n * Read a Formik-stored value back into a Date.\r\n *\r\n * `outputFormat` is threaded in so the read is SYMMETRIC with `serialiseDate`\r\n * (S-03). Without it, a non-ISO format written by moment was read by\r\n * `new Date()`, which either rejects it or misreads it as MM-DD.\r\n */\r\nconst coerceToDate = (raw: unknown, outputFormat?: string): Date | null => {\r\n if (raw == null || raw === \"\") return null;\r\n if (raw instanceof Date) return raw;\r\n if (typeof raw === \"object\" && typeof (raw as { toDate?: () => Date }).toDate === \"function\") {\r\n const d = (raw as { toDate: () => Date }).toDate();\r\n return isNaN(d?.getTime?.()) ? null : d;\r\n }\r\n /* S-03 — parse with the format it was written with. STRICT mode: a stored value\r\n * that does not match yields null rather than moment's best guess.\r\n *\r\n * Guarded on `typeof raw === \"string\"` so a numeric timestamp keeps the\r\n * `new Date(number)` path — moment(number, format) is meaningless. \"iso\" is\r\n * excluded: it is not a moment token, and `new Date(isoString)` is already\r\n * correct. */\r\n if (\r\n typeof raw === \"string\" &&\r\n outputFormat !== undefined &&\r\n outputFormat !== \"iso\"\r\n ) {\r\n const parsed = moment(raw, outputFormat, true);\r\n return parsed.isValid() ? parsed.toDate() : null;\r\n }\r\n const d = new Date(raw as string | number);\r\n return isNaN(d.getTime()) ? null : d;\r\n};\r\n\r\n/**\r\n * Serialise a Date to the requested output format.\r\n * undefined → return the Date as-is (default — backward-compat)\r\n * \"iso\" → Date.toISOString()\r\n * any string → moment(date).format(outputFormat)\r\n */\r\nfunction serialiseDate(date: Date | null, outputFormat: string | undefined): Date | string | null {\r\n if (!date || !(date instanceof Date) || isNaN(date.getTime())) {\r\n return outputFormat ? \"\" : null;\r\n }\r\n if (!outputFormat) return date;\r\n if (outputFormat === \"iso\") return date.toISOString();\r\n return moment(date).format(outputFormat);\r\n}\r\n\r\nexport interface FormikDatePickerProps\r\n extends Omit<\r\n DatePickerProps,\r\n \"value\" | \"onChange\" | \"disabled\" | \"error\" | \"label\" | \"readOnly\"\r\n > {\r\n name: string;\r\n label?: React.ReactNode | undefined;\r\n required?: boolean | undefined;\r\n disabled?: boolean | undefined;\r\n htmlFor?: string | undefined;\r\n hint?: React.ReactNode | undefined;\r\n /**\r\n * outputFormat — when provided, the Formik field stores a formatted\r\n * string instead of a Date object. Use when your Yup schema uses\r\n * Yup.string() with a format-specific test (e.g. \"DD-MM-YYYY\").\r\n * Pass \"iso\" for ISO 8601, or any moment format token string.\r\n * Defaults to undefined (Date | null — backward-compatible).\r\n */\r\n outputFormat?: string | undefined;\r\n /**\r\n * Render the date as read-only text via FormikDisplay instead of a picker.\r\n * `disabled` wins when both are passed — same rule as FormikInput.\r\n *\r\n * `readOnly` IS OMITTED FROM `DatePickerProps` ABOVE, for two reasons.\r\n *\r\n * Mechanically: MUI declares it `readOnly?: boolean` with no `| undefined`,\r\n * so under `exactOptionalPropertyTypes` a host passing an optional\r\n * `boolean | undefined` — which is what a `readOnly?: boolean | undefined`\r\n * section prop is — could not satisfy the inherited signature.\r\n *\r\n * Semantically: this prop SUPERSEDES MUI's meaning. MUI's `readOnly` keeps the\r\n * text field and blocks editing; this one replaces the field with text, so\r\n * there is no input left to mark read-only and forwarding both would be\r\n * contradictory.\r\n *\r\n * BEHAVIOURAL NOTE for existing callers: `readOnly` previously fell through\r\n * `...rest` to MUI and produced a non-editable INPUT. It now produces display\r\n * text. Any caller relying on the old rendering should switch to `disabled`.\r\n */\r\n readOnly?: boolean | undefined;\r\n /**\r\n * Display format in read-only mode. Defaults to the French convention rather\r\n * than to `outputFormat`: what the field STORES and what a reader should SEE\r\n * are different concerns — a field storing \"iso\" or \"YYYY-MM-DD\" should still\r\n * read as 31/12/2026.\r\n */\r\n readOnlyFormat?: string | undefined;\r\n}\r\n\r\nconst FormikDatePicker = ({\r\n name,\r\n label,\r\n required,\r\n disabled,\r\n readOnly,\r\n readOnlyFormat = \"DD/MM/YYYY\",\r\n htmlFor,\r\n hint,\r\n outputFormat,\r\n ...rest\r\n}: FormikDatePickerProps) => {\r\n const [field, meta] = useField(name);\r\n const { setFieldValue, setFieldTouched } = useFormikContext();\r\n const hasError = Boolean(meta.touched && meta.error);\r\n\r\n /* Lecture seule. On repasse par `coerceToDate` avec le MÊME `outputFormat`\r\n * que le champ utilise pour écrire : c'est la symétrie que S-03 a installée,\r\n * et s'en écarter ici reproduirait exactement le bug qu'il a corrigé (une date\r\n * \"31-12-2026\" relue par `new Date()` devient Invalid Date).\r\n *\r\n * `format` court-circuite la branche « valeur vide » de FormikDisplay, donc le\r\n * marqueur « — » est reproduit ici plutôt que délégué — sans quoi un champ\r\n * sans date afficherait un panneau vide. */\r\n if (readOnly && !disabled) {\r\n return (\r\n <FormikDisplay\r\n name={name}\r\n label={label}\r\n {...(hint !== undefined ? { hint } : {})}\r\n format={(raw) => {\r\n const parsed = coerceToDate(raw, outputFormat);\r\n return parsed ? moment(parsed).format(readOnlyFormat) : \"\\u2014\";\r\n }}\r\n />\r\n );\r\n }\r\n\r\n return (\r\n <Field\r\n label={label}\r\n error={hasError ? meta.error : null}\r\n hint={!hasError ? hint : undefined}\r\n htmlFor={htmlFor || name}\r\n {...(required !== undefined ? { required } : {})}\r\n {...(disabled !== undefined ? { disabled } : {})}\r\n >\r\n <DatePicker\r\n value={coerceToDate(field.value, outputFormat)}\r\n onChange={(next) => {\r\n setFieldValue(name, serialiseDate(next, outputFormat));\r\n setFieldTouched(name, true, false);\r\n }}\r\n {...rest}\r\n />\r\n </Field>\r\n );\r\n};\r\n\r\nexport default FormikDatePicker;\r\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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KAAKZ,SAAS,GAAG;IAAEY,QAAQ,EAARA;EAAS,CAAC,GAAG,CAAC,CAAC;IAAAsB,QAAA,eAE/C9C,IAAA,CAACH,UAAU,EAAAgD,aAAA;MACTE,KAAK,EAAE9C,YAAY,CAACmC,KAAK,CAACW,KAAK,EAAE5C,YAAY,CAAE;MAC/C6C,QAAQ,EAAE,SAAAA,SAACC,IAAI,EAAK;QAClBV,aAAa,CAAClB,IAAI,EAAEN,aAAa,CAACkC,IAAI,EAAE9C,YAAY,CAAC,CAAC;QACtDqC,eAAe,CAACnB,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC;MACpC;IAAE,GACES,IAAI,CACT;EAAC,EACG,CAAC;AAEZ,CAAC;AAED,eAAeX,gBAAgB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"FormikDatePicker.js","names":["React","moment","useField","useFormikContext","Field","DatePicker","FormikDisplay","coerceToDate","serialiseDate","jsx","_jsx","FormikDatePicker","_ref","name","label","required","disabled","readOnly","_ref$readOnlyFormat","readOnlyFormat","htmlFor","hint","outputFormat","width","rest","_objectWithoutProperties","_excluded","_useField","_useField2","_slicedToArray","field","meta","_useFormikContext","setFieldValue","setFieldTouched","hasError","Boolean","touched","error","_objectSpread","undefined","format","raw","parsed","children","value","onChange","next"],"sources":["../../../../src/lib/v2/patterns/FormikDatePicker.tsx"],"sourcesContent":["/**\r\n * FormikDatePicker — bridge between Formik state and v2.Field +\r\n * v2.DatePicker.\r\n *\r\n * v2.DatePicker emits Date | null. Formik state may carry Date,\r\n * ISO string, or moment instance — this bridge normalises inbound\r\n * values to Date for the picker.\r\n *\r\n * outputFormat prop (Charter R-I.*):\r\n * By default, onChange writes a Date | null back to Formik, which\r\n * is fine for Yup.date() schemas. If your schema uses Yup.string()\r\n * with a format test (e.g. \"DD-MM-YYYY\"), pass the matching moment\r\n * format string:\r\n *\r\n * <FormikDatePicker name=\"dateNaissance\" outputFormat=\"DD-MM-YYYY\" />\r\n *\r\n * The field then stores \"03-05-2026\" instead of a Date object.\r\n * Pass outputFormat=\"iso\" to store an ISO 8601 string instead.\r\n * Default (undefined) = Date | null (backward-compatible).\r\n *\r\n * ── outputFormat MUST ROUND-TRIP — and now does (S-03) ────────────────\r\n *\r\n * This bridge used to serialise OUT through moment but read BACK through\r\n * `new Date(raw)`, ignoring outputFormat. The asymmetry silently corrupted any\r\n * non-ISO format:\r\n *\r\n * new Date(\"31-12-2026\") -> month 31 invalid -> Invalid Date -> null\r\n * -> the field rendered EMPTY when re-populated\r\n * new Date(\"05-03-2026\") -> V8 reads MM-DD -> 3 May, not 5 March\r\n * -> saving untouched wrote back \"03-05-2026\"\r\n *\r\n * The write path worked, so a form filled in and submitted immediately behaved\r\n * correctly; the damage only surfaced on RE-POPULATE, i.e. an edit flow — the\r\n * path a smoke test is least likely to exercise. `procuration-portnet-fe` shipped\r\n * it for seven batches under a clean strict typecheck.\r\n *\r\n * `coerceToDate` now parses with the SAME format it was written with, in moment's\r\n * STRICT mode, so a malformed stored value yields null instead of a plausible\r\n * wrong date. A missing date is recoverable; a date quietly off by two months is\r\n * not.\r\n *\r\n * BEHAVIOURAL NOTE for existing non-ISO callers: they were mis-parsing before.\r\n * This changes their result from wrong to right — which is the point, but it is a\r\n * change. Callers passing nothing, or \"iso\", are on the identical code path.\r\n *\r\n * Audit: this is the ONLY Formik date bridge in the library. DateTimePicker,\r\n * TimePicker and DateRangePicker are exposed as bare components exchanging Date\r\n * objects, so they have no serialisation step and no equivalent asymmetry;\r\n * _pickerShared carries only Date<->Moment converters, not string parsing.\r\n *\r\n * UPDATE (gap G-E): `FormikDateTimePicker` now exists too, and the two bridges\r\n * SHARE `coerceToDate` / `serialiseDate` via `./_pickerSerialisation`. Keeping\r\n * a private copy in each would have re-created the very asymmetry S-03\r\n * describes, in a form even harder to spot: two bridges that look alike, that\r\n * nobody compares, and that each look correct on their own.\r\n *\r\n * Modal / Drawer usage (MUI X v9):\r\n * When rendered inside a v2.Drawer or a MUI Modal, the DatePicker\r\n * calendar popup may render behind the modal surface (both default\r\n * to zIndex 1300). In MUI X v9, the popper slot is forwarded via\r\n * slotProps.popper (the legacy `PopperProps` was removed). Pass:\r\n *\r\n * <FormikDatePicker\r\n * slotProps={{ popper: { sx: { zIndex: 1400 } } }}\r\n * />\r\n *\r\n * Slot props forward through ...rest to v2.DatePicker and on to\r\n * MuiDatePicker, where they merge with the textField slot bag\r\n * already wired by v2.DatePicker.\r\n *\r\n * Charter R-I.*.\r\n */\r\n\r\nimport * as React from \"react\";\r\nimport moment from \"moment\";\r\nimport { useField, useFormikContext } from \"formik\";\r\nimport Field from \"../components/Field\";\r\nimport DatePicker from \"../components/DatePicker\";\r\nimport FormikDisplay from \"../components/FormikDisplay\";\r\nimport { coerceToDate, serialiseDate } from \"./_pickerSerialisation\";\r\nimport type { FieldWidth } from \"../components/Field\";\r\nimport type { DatePickerProps } from \"../components/DatePicker\";\r\n\r\nexport interface FormikDatePickerProps\r\n extends Omit<\r\n DatePickerProps,\r\n \"value\" | \"onChange\" | \"disabled\" | \"error\" | \"label\" | \"readOnly\"\r\n > {\r\n name: string;\r\n label?: React.ReactNode | undefined;\r\n required?: boolean | undefined;\r\n disabled?: boolean | undefined;\r\n htmlFor?: string | undefined;\r\n hint?: React.ReactNode | undefined;\r\n /**\r\n * outputFormat — when provided, the Formik field stores a formatted\r\n * string instead of a Date object. Use when your Yup schema uses\r\n * Yup.string() with a format-specific test (e.g. \"DD-MM-YYYY\").\r\n * Pass \"iso\" for ISO 8601, or any moment format token string.\r\n * Defaults to undefined (Date | null — backward-compatible).\r\n */\r\n outputFormat?: string | undefined;\r\n /**\r\n * Render the date as read-only text via FormikDisplay instead of a picker.\r\n * `disabled` wins when both are passed — same rule as FormikInput.\r\n *\r\n * `readOnly` IS OMITTED FROM `DatePickerProps` ABOVE, for two reasons.\r\n *\r\n * Mechanically: MUI declares it `readOnly?: boolean` with no `| undefined`,\r\n * so under `exactOptionalPropertyTypes` a host passing an optional\r\n * `boolean | undefined` — which is what a `readOnly?: boolean | undefined`\r\n * section prop is — could not satisfy the inherited signature.\r\n *\r\n * Semantically: this prop SUPERSEDES MUI's meaning. MUI's `readOnly` keeps the\r\n * text field and blocks editing; this one replaces the field with text, so\r\n * there is no input left to mark read-only and forwarding both would be\r\n * contradictory.\r\n *\r\n * BEHAVIOURAL NOTE for existing callers: `readOnly` previously fell through\r\n * `...rest` to MUI and produced a non-editable INPUT. It now produces display\r\n * text. Any caller relying on the old rendering should switch to `disabled`.\r\n */\r\n readOnly?: boolean | undefined;\r\n /**\r\n * Display format in read-only mode. Defaults to the French convention rather\r\n * than to `outputFormat`: what the field STORES and what a reader should SEE\r\n * are different concerns — a field storing \"iso\" or \"YYYY-MM-DD\" should still\r\n * read as 31/12/2026.\r\n */\r\n readOnlyFormat?: string | undefined;\r\n /**\r\n * Gabarit de largeur semantique (G-H). Le standard range explicitement les\r\n * dates en `s` (6 a 15 caracteres). Ne s'applique pas en mode `readOnly`.\r\n */\r\n width?: FieldWidth | undefined;\r\n}\r\n\r\nconst FormikDatePicker = ({\r\n name,\r\n label,\r\n required,\r\n disabled,\r\n readOnly,\r\n readOnlyFormat = \"DD/MM/YYYY\",\r\n htmlFor,\r\n hint,\r\n outputFormat,\r\n width,\r\n ...rest\r\n}: FormikDatePickerProps) => {\r\n const [field, meta] = useField(name);\r\n const { setFieldValue, setFieldTouched } = useFormikContext();\r\n const hasError = Boolean(meta.touched && meta.error);\r\n\r\n /* Lecture seule. On repasse par `coerceToDate` avec le MÊME `outputFormat`\r\n * que le champ utilise pour écrire : c'est la symétrie que S-03 a installée,\r\n * et s'en écarter ici reproduirait exactement le bug qu'il a corrigé (une date\r\n * \"31-12-2026\" relue par `new Date()` devient Invalid Date).\r\n *\r\n * `format` court-circuite la branche « valeur vide » de FormikDisplay, donc le\r\n * marqueur « — » est reproduit ici plutôt que délégué — sans quoi un champ\r\n * sans date afficherait un panneau vide. */\r\n if (readOnly && !disabled) {\r\n return (\r\n <FormikDisplay\r\n name={name}\r\n label={label}\r\n {...(hint !== undefined ? { hint } : {})}\r\n format={(raw) => {\r\n const parsed = coerceToDate(raw, outputFormat);\r\n return parsed ? moment(parsed).format(readOnlyFormat) : \"\\u2014\";\r\n }}\r\n />\r\n );\r\n }\r\n\r\n return (\r\n <Field\r\n label={label}\r\n error={hasError ? meta.error : null}\r\n hint={!hasError ? hint : undefined}\r\n htmlFor={htmlFor || name}\r\n {...(required !== undefined ? { required } : {})}\r\n {...(disabled !== undefined ? { disabled } : {})}\r\n {...(width !== undefined ? { width } : {})}\r\n >\r\n <DatePicker\r\n value={coerceToDate(field.value, outputFormat)}\r\n onChange={(next) => {\r\n setFieldValue(name, serialiseDate(next, outputFormat));\r\n setFieldTouched(name, true, false);\r\n }}\r\n {...rest}\r\n />\r\n </Field>\r\n );\r\n};\r\n\r\nexport default FormikDatePicker;\r\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,OAAOC,MAAM,MAAM,QAAQ;AAC3B,SAASC,QAAQ,EAAEC,gBAAgB,QAAQ,QAAQ;AACnD,OAAOC,KAAK,MAAM,qBAAqB;AACvC,OAAOC,UAAU,MAAM,0BAA0B;AACjD,OAAOC,aAAa,MAAM,6BAA6B;AACvD,SAASC,YAAY,EAAEC,aAAa,QAAQ,wBAAwB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AA0DrE,IAAMC,gBAAgB,GAAG,SA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Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
+
var _excluded = ["name", "label", "required", "disabled", "readOnly", "readOnlyFormat", "htmlFor", "hint", "outputFormat", "width"];
|
|
3
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
5
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
7
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
8
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
9
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
10
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
11
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
12
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0) { ; } } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
13
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
14
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
15
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
16
|
+
/**
|
|
17
|
+
* FormikDateTimePicker — bridge between Formik state and v2.Field +
|
|
18
|
+
* v2.DateTimePicker.
|
|
19
|
+
*
|
|
20
|
+
* ── WHY (gap G-E) ────────────────────────────────────────────────────
|
|
21
|
+
*
|
|
22
|
+
* `FormikDatePicker` was the ONLY Formik date bridge in the library, and it is
|
|
23
|
+
* date-only. Any host with a date-AND-TIME field therefore had two options:
|
|
24
|
+
* drop the time, or hand-wire `useField` + the bare `DateTimePicker`.
|
|
25
|
+
*
|
|
26
|
+
* Dropping the time is not a styling compromise — it CHANGES WHAT THE BACKEND
|
|
27
|
+
* RECEIVES. Reported from refonte-frontend (lot 7): the physical-visit form
|
|
28
|
+
* stores a visit date carrying an hour and submits
|
|
29
|
+
* `moment(value).format("YYYY-MM-DD HH:mm")`. Routed through the date-only
|
|
30
|
+
* bridge, every visit would have been scheduled at 00:00 — silently, with no
|
|
31
|
+
* error anywhere, and only the agent showing up at the wrong time would
|
|
32
|
+
* eventually notice.
|
|
33
|
+
*
|
|
34
|
+
* Hand-wiring is the duplication R-2.1 forbids, and the shape in which
|
|
35
|
+
* validation messages go missing (see gaps G-A and G-C, same story).
|
|
36
|
+
*
|
|
37
|
+
* Usage:
|
|
38
|
+
*
|
|
39
|
+
* <FormikDateTimePicker
|
|
40
|
+
* name="dateVisite"
|
|
41
|
+
* label="Date de la visite"
|
|
42
|
+
* required
|
|
43
|
+
* />
|
|
44
|
+
*
|
|
45
|
+
* // Field must store a string in the charter datetime format:
|
|
46
|
+
* <FormikDateTimePicker
|
|
47
|
+
* name="dateVisite"
|
|
48
|
+
* outputFormat={DATETIME_FORMAT_CHARTER} // "YYYY-MM-DD HH:mm"
|
|
49
|
+
* />
|
|
50
|
+
*
|
|
51
|
+
* ── SERIALISATION IS SHARED WITH FormikDatePicker, DELIBERATELY ──────
|
|
52
|
+
*
|
|
53
|
+
* `coerceToDate` / `serialiseDate` live in `./_pickerSerialisation` and are
|
|
54
|
+
* used by BOTH bridges. That is not tidiness: `FormikDatePicker`'s S-03 note
|
|
55
|
+
* documents what happens when the read and the write of a date disagree — a
|
|
56
|
+
* stored "31-12-2026" read back by `new Date()` becomes Invalid Date, a stored
|
|
57
|
+
* "05-03-2026" becomes 3 May instead of 5 March. The write path works, so the
|
|
58
|
+
* damage only appears on RE-POPULATE, i.e. in an edit flow, which is the path
|
|
59
|
+
* a smoke test is least likely to exercise. One module shipped that for seven
|
|
60
|
+
* batches under a clean strict typecheck.
|
|
61
|
+
*
|
|
62
|
+
* Two private copies of that couple would have re-created the same class of
|
|
63
|
+
* bug in a form even harder to spot.
|
|
64
|
+
*
|
|
65
|
+
* ── DEFAULT OUTPUT IS A Date, LIKE THE SIBLING ──────────────────────
|
|
66
|
+
*
|
|
67
|
+
* With no `outputFormat`, the field stores `Date | null` — which is what
|
|
68
|
+
* `Yup.date()` expects and what a host formatting at submit time already
|
|
69
|
+
* handles. Pass `"iso"` for ISO 8601, or any moment token string (typically
|
|
70
|
+
* `DATETIME_FORMAT_CHARTER`) when the schema is a `Yup.string()` with a format
|
|
71
|
+
* test. Whatever is chosen, reading back uses the SAME format.
|
|
72
|
+
*
|
|
73
|
+
* Modal / Drawer usage (MUI X v9): the picker popup may render behind a modal
|
|
74
|
+
* surface (both default to zIndex 1300). Forward
|
|
75
|
+
* `slotProps={{ popper: { sx: { zIndex: 1400 } } }}` — it reaches
|
|
76
|
+
* MuiDateTimePicker through `...rest`, exactly as on `FormikDatePicker`.
|
|
77
|
+
*
|
|
78
|
+
* Charter §03 · R-I.*. Peer dependency: formik >= 2.x.
|
|
79
|
+
*/
|
|
80
|
+
|
|
81
|
+
import * as React from "react";
|
|
82
|
+
import moment from "moment";
|
|
83
|
+
import { useField, useFormikContext } from "formik";
|
|
84
|
+
import Field from "../components/Field";
|
|
85
|
+
import DateTimePicker from "../components/DateTimePicker";
|
|
86
|
+
import FormikDisplay from "../components/FormikDisplay";
|
|
87
|
+
import { coerceToDate, serialiseDate } from "./_pickerSerialisation";
|
|
88
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
89
|
+
var FormikDateTimePicker = function FormikDateTimePicker(_ref) {
|
|
90
|
+
var name = _ref.name,
|
|
91
|
+
label = _ref.label,
|
|
92
|
+
required = _ref.required,
|
|
93
|
+
disabled = _ref.disabled,
|
|
94
|
+
readOnly = _ref.readOnly,
|
|
95
|
+
_ref$readOnlyFormat = _ref.readOnlyFormat,
|
|
96
|
+
readOnlyFormat = _ref$readOnlyFormat === void 0 ? "DD/MM/YYYY HH:mm" : _ref$readOnlyFormat,
|
|
97
|
+
htmlFor = _ref.htmlFor,
|
|
98
|
+
hint = _ref.hint,
|
|
99
|
+
outputFormat = _ref.outputFormat,
|
|
100
|
+
width = _ref.width,
|
|
101
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
102
|
+
var _useField = useField(name),
|
|
103
|
+
_useField2 = _slicedToArray(_useField, 2),
|
|
104
|
+
field = _useField2[0],
|
|
105
|
+
meta = _useField2[1];
|
|
106
|
+
var _useFormikContext = useFormikContext(),
|
|
107
|
+
setFieldValue = _useFormikContext.setFieldValue,
|
|
108
|
+
setFieldTouched = _useFormikContext.setFieldTouched;
|
|
109
|
+
var hasError = Boolean(meta.touched && meta.error);
|
|
110
|
+
|
|
111
|
+
/* Lecture seule. On repasse par `coerceToDate` avec le MEME `outputFormat`
|
|
112
|
+
* que le champ utilise pour ecrire : c'est la symetrie de S-03. `format`
|
|
113
|
+
* court-circuite la branche « valeur vide » de FormikDisplay, donc le
|
|
114
|
+
* marqueur est reproduit ici plutot que delegue. */
|
|
115
|
+
if (readOnly && !disabled) {
|
|
116
|
+
return /*#__PURE__*/_jsx(FormikDisplay, _objectSpread(_objectSpread({
|
|
117
|
+
name: name,
|
|
118
|
+
label: label
|
|
119
|
+
}, hint !== undefined ? {
|
|
120
|
+
hint: hint
|
|
121
|
+
} : {}), {}, {
|
|
122
|
+
format: function format(raw) {
|
|
123
|
+
var parsed = coerceToDate(raw, outputFormat);
|
|
124
|
+
return parsed ? moment(parsed).format(readOnlyFormat) : "\u2014";
|
|
125
|
+
}
|
|
126
|
+
}));
|
|
127
|
+
}
|
|
128
|
+
return /*#__PURE__*/_jsx(Field, _objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
129
|
+
label: label,
|
|
130
|
+
error: hasError ? meta.error : null,
|
|
131
|
+
hint: !hasError ? hint : undefined,
|
|
132
|
+
htmlFor: htmlFor || name
|
|
133
|
+
}, required !== undefined ? {
|
|
134
|
+
required: required
|
|
135
|
+
} : {}), disabled !== undefined ? {
|
|
136
|
+
disabled: disabled
|
|
137
|
+
} : {}), width !== undefined ? {
|
|
138
|
+
width: width
|
|
139
|
+
} : {}), {}, {
|
|
140
|
+
children: /*#__PURE__*/_jsx(DateTimePicker, _objectSpread({
|
|
141
|
+
value: coerceToDate(field.value, outputFormat),
|
|
142
|
+
onChange: function onChange(next) {
|
|
143
|
+
setFieldValue(name, serialiseDate(next, outputFormat));
|
|
144
|
+
setFieldTouched(name, true, false);
|
|
145
|
+
}
|
|
146
|
+
}, rest))
|
|
147
|
+
}));
|
|
148
|
+
};
|
|
149
|
+
export default FormikDateTimePicker;
|
|
150
|
+
//# sourceMappingURL=FormikDateTimePicker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormikDateTimePicker.js","names":["React","moment","useField","useFormikContext","Field","DateTimePicker","FormikDisplay","coerceToDate","serialiseDate","jsx","_jsx","FormikDateTimePicker","_ref","name","label","required","disabled","readOnly","_ref$readOnlyFormat","readOnlyFormat","htmlFor","hint","outputFormat","width","rest","_objectWithoutProperties","_excluded","_useField","_useField2","_slicedToArray","field","meta","_useFormikContext","setFieldValue","setFieldTouched","hasError","Boolean","touched","error","_objectSpread","undefined","format","raw","parsed","children","value","onChange","next"],"sources":["../../../../src/lib/v2/patterns/FormikDateTimePicker.tsx"],"sourcesContent":["/**\r\n * FormikDateTimePicker — bridge between Formik state and v2.Field +\r\n * v2.DateTimePicker.\r\n *\r\n * ── WHY (gap G-E) ────────────────────────────────────────────────────\r\n *\r\n * `FormikDatePicker` was the ONLY Formik date bridge in the library, and it is\r\n * date-only. Any host with a date-AND-TIME field therefore had two options:\r\n * drop the time, or hand-wire `useField` + the bare `DateTimePicker`.\r\n *\r\n * Dropping the time is not a styling compromise — it CHANGES WHAT THE BACKEND\r\n * RECEIVES. Reported from refonte-frontend (lot 7): the physical-visit form\r\n * stores a visit date carrying an hour and submits\r\n * `moment(value).format(\"YYYY-MM-DD HH:mm\")`. Routed through the date-only\r\n * bridge, every visit would have been scheduled at 00:00 — silently, with no\r\n * error anywhere, and only the agent showing up at the wrong time would\r\n * eventually notice.\r\n *\r\n * Hand-wiring is the duplication R-2.1 forbids, and the shape in which\r\n * validation messages go missing (see gaps G-A and G-C, same story).\r\n *\r\n * Usage:\r\n *\r\n * <FormikDateTimePicker\r\n * name=\"dateVisite\"\r\n * label=\"Date de la visite\"\r\n * required\r\n * />\r\n *\r\n * // Field must store a string in the charter datetime format:\r\n * <FormikDateTimePicker\r\n * name=\"dateVisite\"\r\n * outputFormat={DATETIME_FORMAT_CHARTER} // \"YYYY-MM-DD HH:mm\"\r\n * />\r\n *\r\n * ── SERIALISATION IS SHARED WITH FormikDatePicker, DELIBERATELY ──────\r\n *\r\n * `coerceToDate` / `serialiseDate` live in `./_pickerSerialisation` and are\r\n * used by BOTH bridges. That is not tidiness: `FormikDatePicker`'s S-03 note\r\n * documents what happens when the read and the write of a date disagree — a\r\n * stored \"31-12-2026\" read back by `new Date()` becomes Invalid Date, a stored\r\n * \"05-03-2026\" becomes 3 May instead of 5 March. The write path works, so the\r\n * damage only appears on RE-POPULATE, i.e. in an edit flow, which is the path\r\n * a smoke test is least likely to exercise. One module shipped that for seven\r\n * batches under a clean strict typecheck.\r\n *\r\n * Two private copies of that couple would have re-created the same class of\r\n * bug in a form even harder to spot.\r\n *\r\n * ── DEFAULT OUTPUT IS A Date, LIKE THE SIBLING ──────────────────────\r\n *\r\n * With no `outputFormat`, the field stores `Date | null` — which is what\r\n * `Yup.date()` expects and what a host formatting at submit time already\r\n * handles. Pass `\"iso\"` for ISO 8601, or any moment token string (typically\r\n * `DATETIME_FORMAT_CHARTER`) when the schema is a `Yup.string()` with a format\r\n * test. Whatever is chosen, reading back uses the SAME format.\r\n *\r\n * Modal / Drawer usage (MUI X v9): the picker popup may render behind a modal\r\n * surface (both default to zIndex 1300). Forward\r\n * `slotProps={{ popper: { sx: { zIndex: 1400 } } }}` — it reaches\r\n * MuiDateTimePicker through `...rest`, exactly as on `FormikDatePicker`.\r\n *\r\n * Charter §03 · R-I.*. Peer dependency: formik >= 2.x.\r\n */\r\n\r\nimport * as React from \"react\";\r\nimport moment from \"moment\";\r\nimport { useField, useFormikContext } from \"formik\";\r\nimport Field from \"../components/Field\";\r\nimport DateTimePicker from \"../components/DateTimePicker\";\r\nimport FormikDisplay from \"../components/FormikDisplay\";\r\nimport { coerceToDate, serialiseDate } from \"./_pickerSerialisation\";\r\nimport type { FieldWidth } from \"../components/Field\";\r\nimport type { DateTimePickerProps } from \"../components/DateTimePicker\";\r\n\r\nexport interface FormikDateTimePickerProps\r\n extends Omit<\r\n DateTimePickerProps,\r\n \"value\" | \"onChange\" | \"disabled\" | \"error\" | \"label\" | \"readOnly\"\r\n > {\r\n name: string;\r\n label?: React.ReactNode | undefined;\r\n required?: boolean | undefined;\r\n disabled?: boolean | undefined;\r\n htmlFor?: string | undefined;\r\n hint?: React.ReactNode | undefined;\r\n /**\r\n * When provided, the Formik field stores a formatted STRING instead of a\r\n * `Date`. Pass `\"iso\"` for ISO 8601, or any moment token string — typically\r\n * `DATETIME_FORMAT_CHARTER` (\"YYYY-MM-DD HH:mm\"). Defaults to undefined\r\n * (`Date | null`).\r\n */\r\n outputFormat?: string | undefined;\r\n /**\r\n * Render the value as read-only text via `FormikDisplay` instead of a\r\n * picker. `disabled` wins when both are passed — same rule as\r\n * `FormikInput` and `FormikDatePicker`.\r\n *\r\n * Omitted from `DateTimePickerProps` above for the same two reasons as on\r\n * the sibling: MUI declares `readOnly?: boolean` with no `| undefined`, which\r\n * an optional section prop cannot satisfy under\r\n * `exactOptionalPropertyTypes`; and this prop SUPERSEDES MUI's meaning —\r\n * MUI keeps the text field and blocks editing, this one replaces the field\r\n * with text, so there is no input left to mark read-only.\r\n */\r\n readOnly?: boolean | undefined;\r\n /**\r\n * Display format in read-only mode. Defaults to the French convention rather\r\n * than to `outputFormat`: what the field STORES and what a reader should SEE\r\n * are different concerns — a field storing ISO should still read as\r\n * 31/12/2026 14:30.\r\n */\r\n readOnlyFormat?: string | undefined;\r\n /**\r\n * Gabarit de largeur semantique (G-H). Le standard range les dates en `s`\r\n * (6 a 15 caracteres) : une date-heure au format charte en fait 16, donc `s`\r\n * ou `m` selon la place disponible. Ne s'applique pas en mode `readOnly`.\r\n */\r\n width?: FieldWidth | undefined;\r\n}\r\n\r\nconst FormikDateTimePicker = ({\r\n name,\r\n label,\r\n required,\r\n disabled,\r\n readOnly,\r\n readOnlyFormat = \"DD/MM/YYYY HH:mm\",\r\n htmlFor,\r\n hint,\r\n outputFormat,\r\n width,\r\n ...rest\r\n}: FormikDateTimePickerProps) => {\r\n const [field, meta] = useField(name);\r\n const { setFieldValue, setFieldTouched } = useFormikContext();\r\n const hasError = Boolean(meta.touched && meta.error);\r\n\r\n /* Lecture seule. On repasse par `coerceToDate` avec le MEME `outputFormat`\r\n * que le champ utilise pour ecrire : c'est la symetrie de S-03. `format`\r\n * court-circuite la branche « valeur vide » de FormikDisplay, donc le\r\n * marqueur est reproduit ici plutot que delegue. */\r\n if (readOnly && !disabled) {\r\n return (\r\n <FormikDisplay\r\n name={name}\r\n label={label}\r\n {...(hint !== undefined ? { hint } : {})}\r\n format={(raw) => {\r\n const parsed = coerceToDate(raw, outputFormat);\r\n return parsed ? moment(parsed).format(readOnlyFormat) : \"\\u2014\";\r\n }}\r\n />\r\n );\r\n }\r\n\r\n return (\r\n <Field\r\n label={label}\r\n error={hasError ? meta.error : null}\r\n hint={!hasError ? hint : undefined}\r\n htmlFor={htmlFor || name}\r\n {...(required !== undefined ? { required } : {})}\r\n {...(disabled !== undefined ? { disabled } : {})}\r\n {...(width !== undefined ? { width } : {})}\r\n >\r\n <DateTimePicker\r\n value={coerceToDate(field.value, outputFormat)}\r\n onChange={(next) => {\r\n setFieldValue(name, serialiseDate(next, outputFormat));\r\n setFieldTouched(name, true, false);\r\n }}\r\n {...rest}\r\n />\r\n </Field>\r\n );\r\n};\r\n\r\nexport default FormikDateTimePicker;\r\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,OAAOC,MAAM,MAAM,QAAQ;AAC3B,SAASC,QAAQ,EAAEC,gBAAgB,QAAQ,QAAQ;AACnD,OAAOC,KAAK,MAAM,qBAAqB;AACvC,OAAOC,cAAc,MAAM,8BAA8B;AACzD,OAAOC,aAAa,MAAM,6BAA6B;AACvD,SAASC,YAAY,EAAEC,aAAa,QAAQ,wBAAwB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAkDrE,IAAMC,oBAAoB,GAAG,SAAvBA,oBAAoBA,CAAAC,IAAA,EAYO;EAAA,IAX/BC,IAAI,GAAAD,IAAA,CAAJC,IAAI;IACJC,KAAK,GAAAF,IAAA,CAALE,KAAK;IACLC,QAAQ,GAAAH,IAAA,CAARG,QAAQ;IACRC,QAAQ,GAAAJ,IAAA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AEN;EAEA,oBACET,IAAA,CAACN,KAAK,EAAAmC,aAAA,CAAAA,aAAA,CAAAA,aAAA,CAAAA,aAAA;IACJzB,KAAK,EAAEA,KAAM;IACbwB,KAAK,EAAEH,QAAQ,GAAGJ,IAAI,CAACO,KAAK,GAAG,IAAK;IACpCjB,IAAI,EAAE,CAACc,QAAQ,GAAGd,IAAI,GAAGmB,SAAU;IACnCpB,OAAO,EAAEA,OAAO,IAAIP;EAAK,GACpBE,QAAQ,KAAKyB,SAAS,GAAG;IAAEzB,QAAQ,EAARA;EAAS,CAAC,GAAG,CAAC,CAAC,GAC1CC,QAAQ,KAAKwB,SAAS,GAAG;IAAExB,QAAQ,EAARA;EAAS,CAAC,GAAG,CAAC,CAAC,GAC1CO,KAAK,KAAKiB,SAAS,GAAG;IAAEjB,KAAK,EAALA;EAAM,CAAC,GAAG,CAAC,CAAC;IAAAqB,QAAA,eAEzClC,IAAA,CAACL,cAAc,EAAAkC,aAAA;MACbM,KAAK,EAAEtC,YAAY,CAACuB,KAAK,CAACe,KAAK,EAAEvB,YAAY,CAAE;MAC/CwB,QAAQ,EAAE,SAAAA,SAACC,IAAI,EAAK;QAClBd,aAAa,CAACpB,IAAI,EAAEL,aAAa,CAACuC,IAAI,EAAEzB,YAAY,CAAC,CAAC;QACtDY,eAAe,CAACrB,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC;MACpC;IAAE,GACEW,IAAI,CACT;EAAC,EACG,CAAC;AAEZ,CAAC;AAED,eAAeb,oBAAoB","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
-
var _excluded = ["name", "label", "required", "disabled", "readOnly", "mono", "htmlFor", "hint"];
|
|
2
|
+
var _excluded = ["name", "label", "required", "disabled", "readOnly", "mono", "htmlFor", "hint", "width"];
|
|
3
3
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
4
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
5
5
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
@@ -85,6 +85,7 @@ var FormikInput = function FormikInput(_ref) {
|
|
|
85
85
|
mono = _ref.mono,
|
|
86
86
|
htmlFor = _ref.htmlFor,
|
|
87
87
|
hint = _ref.hint,
|
|
88
|
+
width = _ref.width,
|
|
88
89
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
89
90
|
var _useField = useField(name),
|
|
90
91
|
_useField2 = _slicedToArray(_useField, 2),
|
|
@@ -105,7 +106,7 @@ var FormikInput = function FormikInput(_ref) {
|
|
|
105
106
|
mono: mono
|
|
106
107
|
} : {}));
|
|
107
108
|
}
|
|
108
|
-
return /*#__PURE__*/_jsx(Field, _objectSpread(_objectSpread(_objectSpread({
|
|
109
|
+
return /*#__PURE__*/_jsx(Field, _objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
109
110
|
label: label,
|
|
110
111
|
error: hasError ? meta.error : null,
|
|
111
112
|
hint: !hasError ? hint : undefined,
|
|
@@ -114,6 +115,8 @@ var FormikInput = function FormikInput(_ref) {
|
|
|
114
115
|
required: required
|
|
115
116
|
} : {}), disabled !== undefined ? {
|
|
116
117
|
disabled: disabled
|
|
118
|
+
} : {}), width !== undefined ? {
|
|
119
|
+
width: width
|
|
117
120
|
} : {}), {}, {
|
|
118
121
|
children: /*#__PURE__*/_jsx(Input, _objectSpread({
|
|
119
122
|
name: field.name,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormikInput.js","names":["React","useField","Field","Input","FormikDisplay","jsx","_jsx","FormikInput","_ref","_field$value","name","label","required","disabled","readOnly","mono","htmlFor","hint","rest","_objectWithoutProperties","_excluded","_useField","_useField2","_slicedToArray","field","meta","hasError","Boolean","touched","error","_objectSpread","undefined","children","value","onChange","onBlur"],"sources":["../../../../src/lib/v2/patterns/FormikInput.tsx"],"sourcesContent":["/**\r\n * FormikInput — bridge between Formik state and v2.Field + v2.Input.\r\n *\r\n * Charter §03 / R-I.1 → R-I.6. Replaces the inline copy of this\r\n * bridge that consumer modules previously duplicated.\r\n *\r\n * Peer dependency: `formik` >= 2.x must be installed in the host\r\n * module. The lib does not bundle Formik.\r\n *\r\n * Usage:\r\n *\r\n * import { FormikInput } from \"@portnet/ui/lib/v2\";\r\n *\r\n * <FormikInput\r\n * name=\"numeroRc\"\r\n * label=\"Numéro RC\"\r\n * required\r\n * inputProps={{ maxLength: 20 }}\r\n * />\r\n *\r\n * Error semantics: errors surface only after the field is\r\n * touched (first blur). This matches Charter R-I.4 — do not\r\n * shout at the user on every keystroke.\r\n *\r\n * ── `readOnly` vs `disabled` ─────────────────────────────────────────\r\n *\r\n * <FormikInput name=\"raison\" label=\"Raison sociale\" readOnly={isDetail} />\r\n *\r\n * `readOnly` renders the value through `FormikDisplay` — grey panel, no input\r\n * chrome, selectable text. `disabled` keeps an input and greys it out.\r\n *\r\n * THE TWO ARE NOT INTERCHANGEABLE, and modules had only `disabled`. Consumers\r\n * that reuse ONE form for create, edit AND consultation were therefore passing\r\n * `disabled={readOnly}` on every field, so a detail page rendered ~100 greyed\r\n * INPUTS. That is the wrong affordance: a disabled control means \"temporarily\r\n * unavailable, may become editable\", not \"this is information\". Reported from\r\n * amssnur-ui testing across its whole demande form.\r\n *\r\n * Note WCAG does NOT forbid the old behaviour — SC 1.4.3 exempts \"text that is\r\n * part of an inactive user interface component\" from contrast requirements. So\r\n * this is a Charter and affordance defect, not an accessibility violation. But\r\n * `FormikDisplay` is measurably better anyway: its own audit records 7.52:1\r\n * (AAA) for `--fg-muted` on `--bg-subtle`, against roughly 2.9:1 for MUI's\r\n * disabled text.\r\n *\r\n * Why here and not in each module: `FormikDisplay` already existed and was\r\n * already correct — nothing routed to it automatically, so every module had to\r\n * branch by hand per field, and none did. The certified reference (`ms-ti-fe`)\r\n * sidesteps the problem by building SEPARATE read-only components for its\r\n * detail pages, which is a valid architecture but not one a module reusing a\r\n * single form can adopt without a rewrite.\r\n *\r\n * `disabled` wins when both are passed: a field that is genuinely unavailable\r\n * (dependency not yet chosen) must not be presented as settled information.\r\n */\r\n\r\nimport * as React from \"react\";\r\nimport { useField } from \"formik\";\r\nimport Field from \"../components/Field\";\r\nimport Input from \"../components/Input\";\r\nimport FormikDisplay from \"../components/FormikDisplay\";\r\nimport type { InputProps } from \"../components/Input\";\r\n\r\nexport interface FormikInputProps\r\n extends Omit<\r\n InputProps,\r\n \"name\" | \"value\" | \"onChange\" | \"onBlur\" | \"label\" | \"required\" | \"disabled\" | \"error\"\r\n > {\r\n name: string;\r\n label?: React.ReactNode | undefined;\r\n required?: boolean | undefined;\r\n disabled?: boolean | undefined;\r\n /** Render as read-only text via FormikDisplay instead of an input. */\r\n readOnly?: boolean | undefined;\r\n /** Tabular-nums monospace in read-only mode — IDs, amounts, codes. */\r\n mono?: boolean | undefined;\r\n htmlFor?: string | undefined;\r\n hint?: React.ReactNode | undefined;\r\n}\r\n\r\nconst FormikInput = ({\r\n name,\r\n label,\r\n required,\r\n disabled,\r\n readOnly,\r\n mono,\r\n htmlFor,\r\n hint,\r\n ...rest\r\n}: FormikInputProps) => {\r\n const [field, meta] = useField<string | number>(name);\r\n const hasError = Boolean(meta.touched && meta.error);\r\n\r\n /* Read-only display. `disabled` takes precedence deliberately — see header.\r\n * `required` is dropped: an asterisk on information the user cannot supply is\r\n * noise, and validation cannot fire on a field with no input. */\r\n if (readOnly && !disabled) {\r\n return (\r\n <FormikDisplay\r\n name={name}\r\n label={label}\r\n {...(hint !== undefined ? { hint } : {})}\r\n {...(mono !== undefined ? { mono } : {})}\r\n />\r\n );\r\n }\r\n\r\n return (\r\n <Field\r\n label={label}\r\n error={hasError ? meta.error : null}\r\n hint={!hasError ? hint : undefined}\r\n htmlFor={htmlFor || name}\r\n {...(required !== undefined ? { required } : {})}\r\n {...(disabled !== undefined ? { disabled } : {})}\r\n >\r\n <Input\r\n name={field.name}\r\n value={field.value ?? \"\"}\r\n onChange={field.onChange}\r\n onBlur={field.onBlur}\r\n {...rest}\r\n />\r\n </Field>\r\n );\r\n};\r\n\r\nexport default FormikInput;\r\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAASC,QAAQ,QAAQ,QAAQ;AACjC,OAAOC,KAAK,MAAM,qBAAqB;AACvC,OAAOC,KAAK,MAAM,qBAAqB;AACvC,OAAOC,aAAa,MAAM,6BAA6B;AAAC,SAAAC,GAAA,IAAAC,IAAA;
|
|
1
|
+
{"version":3,"file":"FormikInput.js","names":["React","useField","Field","Input","FormikDisplay","jsx","_jsx","FormikInput","_ref","_field$value","name","label","required","disabled","readOnly","mono","htmlFor","hint","width","rest","_objectWithoutProperties","_excluded","_useField","_useField2","_slicedToArray","field","meta","hasError","Boolean","touched","error","_objectSpread","undefined","children","value","onChange","onBlur"],"sources":["../../../../src/lib/v2/patterns/FormikInput.tsx"],"sourcesContent":["/**\r\n * FormikInput — bridge between Formik state and v2.Field + v2.Input.\r\n *\r\n * Charter §03 / R-I.1 → R-I.6. Replaces the inline copy of this\r\n * bridge that consumer modules previously duplicated.\r\n *\r\n * Peer dependency: `formik` >= 2.x must be installed in the host\r\n * module. The lib does not bundle Formik.\r\n *\r\n * Usage:\r\n *\r\n * import { FormikInput } from \"@portnet/ui/lib/v2\";\r\n *\r\n * <FormikInput\r\n * name=\"numeroRc\"\r\n * label=\"Numéro RC\"\r\n * required\r\n * inputProps={{ maxLength: 20 }}\r\n * />\r\n *\r\n * Error semantics: errors surface only after the field is\r\n * touched (first blur). This matches Charter R-I.4 — do not\r\n * shout at the user on every keystroke.\r\n *\r\n * ── `readOnly` vs `disabled` ─────────────────────────────────────────\r\n *\r\n * <FormikInput name=\"raison\" label=\"Raison sociale\" readOnly={isDetail} />\r\n *\r\n * `readOnly` renders the value through `FormikDisplay` — grey panel, no input\r\n * chrome, selectable text. `disabled` keeps an input and greys it out.\r\n *\r\n * THE TWO ARE NOT INTERCHANGEABLE, and modules had only `disabled`. Consumers\r\n * that reuse ONE form for create, edit AND consultation were therefore passing\r\n * `disabled={readOnly}` on every field, so a detail page rendered ~100 greyed\r\n * INPUTS. That is the wrong affordance: a disabled control means \"temporarily\r\n * unavailable, may become editable\", not \"this is information\". Reported from\r\n * amssnur-ui testing across its whole demande form.\r\n *\r\n * Note WCAG does NOT forbid the old behaviour — SC 1.4.3 exempts \"text that is\r\n * part of an inactive user interface component\" from contrast requirements. So\r\n * this is a Charter and affordance defect, not an accessibility violation. But\r\n * `FormikDisplay` is measurably better anyway: its own audit records 7.52:1\r\n * (AAA) for `--fg-muted` on `--bg-subtle`, against roughly 2.9:1 for MUI's\r\n * disabled text.\r\n *\r\n * Why here and not in each module: `FormikDisplay` already existed and was\r\n * already correct — nothing routed to it automatically, so every module had to\r\n * branch by hand per field, and none did. The certified reference (`ms-ti-fe`)\r\n * sidesteps the problem by building SEPARATE read-only components for its\r\n * detail pages, which is a valid architecture but not one a module reusing a\r\n * single form can adopt without a rewrite.\r\n *\r\n * `disabled` wins when both are passed: a field that is genuinely unavailable\r\n * (dependency not yet chosen) must not be presented as settled information.\r\n */\r\n\r\nimport * as React from \"react\";\r\nimport { useField } from \"formik\";\r\nimport Field from \"../components/Field\";\r\nimport Input from \"../components/Input\";\r\nimport FormikDisplay from \"../components/FormikDisplay\";\r\nimport type { FieldWidth } from \"../components/Field\";\r\nimport type { InputProps } from \"../components/Input\";\r\n\r\nexport interface FormikInputProps\r\n extends Omit<\r\n InputProps,\r\n \"name\" | \"value\" | \"onChange\" | \"onBlur\" | \"label\" | \"required\" | \"disabled\" | \"error\"\r\n > {\r\n name: string;\r\n label?: React.ReactNode | undefined;\r\n required?: boolean | undefined;\r\n disabled?: boolean | undefined;\r\n /** Render as read-only text via FormikDisplay instead of an input. */\r\n readOnly?: boolean | undefined;\r\n /** Tabular-nums monospace in read-only mode — IDs, amounts, codes. */\r\n mono?: boolean | undefined;\r\n htmlFor?: string | undefined;\r\n hint?: React.ReactNode | undefined;\r\n /**\r\n * Gabarit de largeur semantique (G-H), d'apres la contrainte de CARACTERES\r\n * du champ. Relaye a `Field`, qui en fait un plafond a partir de `sm`.\r\n *\r\n * NE S'APPLIQUE PAS en mode `readOnly` : c'est alors `FormikDisplay` qui est\r\n * rendu, et il possede sa propre boite. A revoir si un ecran de consultation\r\n * en a besoin.\r\n */\r\n width?: FieldWidth | undefined;\r\n}\r\n\r\nconst FormikInput = ({\r\n name,\r\n label,\r\n required,\r\n disabled,\r\n readOnly,\r\n mono,\r\n htmlFor,\r\n hint,\r\n width,\r\n ...rest\r\n}: FormikInputProps) => {\r\n const [field, meta] = useField<string | number>(name);\r\n const hasError = Boolean(meta.touched && meta.error);\r\n\r\n /* Read-only display. `disabled` takes precedence deliberately — see header.\r\n * `required` is dropped: an asterisk on information the user cannot supply is\r\n * noise, and validation cannot fire on a field with no input. */\r\n if (readOnly && !disabled) {\r\n return (\r\n <FormikDisplay\r\n name={name}\r\n label={label}\r\n {...(hint !== undefined ? { hint } : {})}\r\n {...(mono !== undefined ? { mono } : {})}\r\n />\r\n );\r\n }\r\n\r\n return (\r\n <Field\r\n label={label}\r\n error={hasError ? meta.error : null}\r\n hint={!hasError ? hint : undefined}\r\n htmlFor={htmlFor || name}\r\n {...(required !== undefined ? { required } : {})}\r\n {...(disabled !== undefined ? { disabled } : {})}\r\n {...(width !== undefined ? { width } : {})}\r\n >\r\n <Input\r\n name={field.name}\r\n value={field.value ?? \"\"}\r\n onChange={field.onChange}\r\n onBlur={field.onBlur}\r\n {...rest}\r\n />\r\n </Field>\r\n );\r\n};\r\n\r\nexport default FormikInput;\r\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAASC,QAAQ,QAAQ,QAAQ;AACjC,OAAOC,KAAK,MAAM,qBAAqB;AACvC,OAAOC,KAAK,MAAM,qBAAqB;AACvC,OAAOC,aAAa,MAAM,6BAA6B;AAAC,SAAAC,GAAA,IAAAC,IAAA;AA8BxD,IAAMC,WAAW,GAAG,SAAdA,WAAWA,CAAAC,IAAA,EAWO;EAAA,IAAAC,YAAA;EAAA,IAVtBC,IAAI,GAAAF,IAAA,CAAJE,IAA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