@povio/ui 6.0.0-rc.11 → 6.0.0-rc.13
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/README.md +470 -43
- package/dist/{Accordion-Cup5eRZz.d.ts → Accordion-CR9oomZY.d.ts} +29 -17
- package/dist/{Accordion-ORBin0EZ.js → Accordion-gUW7u1Zn.js} +41 -41
- package/dist/Alert-DwnALnFY.d.ts +36 -0
- package/dist/AlertDialog-BcRiqY_n.d.ts +70 -0
- package/dist/Autocomplete-CV4Aa1Ok.js +319 -0
- package/dist/Autocomplete-DRwQxx0U.d.ts +123 -0
- package/dist/Badge-CO-ZsmbR.d.ts +67 -0
- package/dist/{BottomSheet-CGipksM_.js → BottomSheet-APVu5TUd.js} +8 -8
- package/dist/BottomSheet-Be0HtQzP.d.ts +65 -0
- package/dist/{BottomSheet.lazy-CuJMUeJP.d.ts → BottomSheet.lazy-NNB7ivkW.d.ts} +1 -1
- package/dist/{Breadcrumbs-CcB0oOF8.d.ts → Breadcrumbs-Bn3fqVYx.d.ts} +6 -3
- package/dist/{Breadcrumbs-a1-q_he0.js → Breadcrumbs-Cd75RPbS.js} +33 -17
- package/dist/{Button-C1YB5dOw.js → Button-BJJkLVNj.js} +1 -5
- package/dist/{Button-BaODzvZd.js → Button-CzEs3tcV.js} +1 -1
- package/dist/{Button-0SswSdDg.d.ts → Button-Hk8zm9q_.d.ts} +2 -2
- package/dist/ButtonBase-Cp1w00t2.d.ts +47 -0
- package/dist/{ButtonBase-s-VV7oCa.js → ButtonBase-aGz6DYum.js} +10 -18
- package/dist/{ButtonContent-Dztbuz3q.js → ButtonContent-2KsbdWRO.js} +5 -5
- package/dist/{Calendar-DX0dVo6z.js → Calendar-DN-i_b-_.js} +19 -17
- package/dist/{Calendar.lazy-W51M56GQ.js → Calendar.lazy-CqmyDSND.js} +4 -4
- package/dist/{Checkbox-Bjsbx-wK.js → Checkbox-CzKXZw_w.js} +35 -9
- package/dist/Checkbox-D32MOIhF.d.ts +49 -0
- package/dist/CheckboxCheckmark-DDU_Ie7-.js +42 -0
- package/dist/CheckboxGroup-B5Mn1G3u.d.ts +52 -0
- package/dist/{CheckboxGroup-B3O3IUiu.js → CheckboxGroup-BqWt09kZ.js} +75 -35
- package/dist/DatePicker-CmoVbapu.d.ts +80 -0
- package/dist/{DatePicker-CqNS7lgR.js → DatePicker-DQewd1By.js} +80 -41
- package/dist/{DatePickerInput-vLlL5ATh.d.ts → DatePickerInput-B9VnExeA.d.ts} +3 -3
- package/dist/{DatePickerInput-B2Pc_aJr.js → DatePickerInput-Bp9ZIN5E.js} +37 -26
- package/dist/{DateRangePicker-C3ClfSfj.js → DateRangePicker-DRZ1hLlR.js} +93 -169
- package/dist/DateRangePicker-LX1VJlnD.d.ts +102 -0
- package/dist/DateTimePicker-D9pODhAj.d.ts +83 -0
- package/dist/{DateTimePicker-CYa2J-1r.js → DateTimePicker-DWtKPaE6.js} +70 -35
- package/dist/{Dialog-C9H9_BmK.js → Dialog-BJ13KRQo.js} +1 -1
- package/dist/{Dialog-96c4Pzfm.js → Dialog-BzQYDPJ9.js} +23 -19
- package/dist/Dialog-D0SeePPz.d.ts +66 -0
- package/dist/{Disclosure-BRSkMbZQ.js → Disclosure-Bjm5IOpg.js} +1 -1
- package/dist/Drawer-o018RqIt.d.ts +42 -0
- package/dist/DropdownMenu-DTr7b-XO.d.ts +51 -0
- package/dist/{DropdownMenu-DS0RaEfH.js → DropdownMenu-DrshB60h.js} +33 -21
- package/dist/{DropdownMenuDesktop-DGPIfex-.js → DropdownMenuDesktop-DxGA0yvx.js} +14 -8
- package/dist/FileInput-Bokcp9nH.d.ts +61 -0
- package/dist/{FileInput-IRM0C9W6.js → FileInput-LMhFxlqB.js} +75 -80
- package/dist/FileUpload-BqXd4_nz.d.ts +181 -0
- package/dist/FileUpload-CJZrkr_U.js +679 -0
- package/dist/{FormField-dduTMkNH.js → FormField-TI8Vx5aC.js} +10 -10
- package/dist/FormField-XQbjfGSv.d.ts +70 -0
- package/dist/{FormFieldError-BT4uxbKY.d.ts → FormFieldError-C7yOdjzQ.d.ts} +1 -0
- package/dist/FormFieldHeaderTooltip-DB7KrrcD.js +22 -0
- package/dist/HiddenFormValue-DZ2d9eoA.js +20 -0
- package/dist/IconButton-CQLHX8-Y.d.ts +24 -0
- package/dist/{IconSlot-CqNuZl0E.js → IconSlot-TAWTJ6iK.js} +2 -4
- package/dist/{InlineTooltipWrapper-CKTiFpZn.js → InlineTooltipWrapper-CjDUsi2I.js} +1 -1
- package/dist/{Input-UbFhc_J2.js → Input-CeRJeAoR.js} +94 -59
- package/dist/Input-onUj0DKg.d.ts +56 -0
- package/dist/{InputContent-D7lnNLWk.js → InputContent-B8OCdbVP.js} +15 -13
- package/dist/InputContent-D5ZkB9hO.d.ts +39 -0
- package/dist/Link-BdnWVYL9.d.ts +15 -0
- package/dist/{ListBox-DhR5kojP.js → ListBox-gR4iSV7N.js} +3 -3
- package/dist/{Modal-DcLWF9cB.js → Modal-DAMsCwzb.js} +1 -1
- package/dist/{NumberField-twW8zuJ9.js → NumberField-6Q9LHGSo.js} +91 -62
- package/dist/NumberField-Sb30Qao3.d.ts +41 -0
- package/dist/{NumberRangeInput-gT6gEJIz.js → NumberRangeInput-BDSkcHVJ.js} +152 -101
- package/dist/NumberRangeInput-Dvq8mOUY.d.ts +89 -0
- package/dist/{PageHeader-DTfzf-dA.d.ts → PageHeader-eJk6GNK6.d.ts} +6 -5
- package/dist/{PasswordInput.bound-CXtbMCD6.js → PasswordInput-BcHpV0Ie.js} +6 -6
- package/dist/PasswordInput-VHzP4VPU.d.ts +16 -0
- package/dist/Popover-qplPGDnR.d.ts +51 -0
- package/dist/Progress-DH-w99MU.d.ts +26 -0
- package/dist/Progress-WzWvbvtp.js +180 -0
- package/dist/ProgressBar-BsSimmJF.js +46 -0
- package/dist/RadioGroup-CC8bKtBN.d.ts +52 -0
- package/dist/{RadioGroup-IL4Y8XHO.js → RadioGroup-PKqFHoKP.js} +66 -26
- package/dist/{RangeCalendar-0W1YFZqn.js → RangeCalendar-DqCTlIuy.js} +42 -13
- package/dist/Select-CSyfDyxG.d.ts +248 -0
- package/dist/{Select-B-TuE_Fh.js → Select-D3fuXwVt.js} +435 -184
- package/dist/{SelectListBox-Dlonoc5z.js → SelectListBox-DqAxkT1f.js} +46 -37
- package/dist/{SidebarWorkspaces-DJknAfS9.js → SidebarWorkspaces-BGl_PIsH.js} +280 -363
- package/dist/{SidebarWorkspaces-DDHJAdNH.d.ts → SidebarWorkspaces-CdtK2M-C.d.ts} +31 -17
- package/dist/{Slider-DCsCCPFx.js → Slider-BCUiALjE.js} +69 -12
- package/dist/Slider-DxalZD3o.d.ts +57 -0
- package/dist/Spinner-BTrEbNFy.d.ts +13 -0
- package/dist/SplitButton-Dv5l8p5t.d.ts +25 -0
- package/dist/Stepper-B1IOUcSI.d.ts +49 -0
- package/dist/{Stepper-Dyhxp0Tl.js → Stepper-DA2G546I.js} +116 -88
- package/dist/{Switch-BfpSMMpv.js → Switch-Ce-bJOVw.js} +54 -12
- package/dist/Switch-urNrop0P.d.ts +42 -0
- package/dist/{TabsFilters-CWUNeqYa.js → TabsFilters-Cweij8He.js} +44 -33
- package/dist/TabsFilters-M5Ld7eb8.d.ts +59 -0
- package/dist/Tag-BKR1AZFa.d.ts +26 -0
- package/dist/TextArea-D7YVclaz.d.ts +33 -0
- package/dist/{TextArea-DakA3nzZ.js → TextArea-P8F0oD_A.js} +59 -32
- package/dist/TimePicker-Ai1M2TGW.d.ts +63 -0
- package/dist/{TimePicker-RFzfDezn.js → TimePicker-l4Ysk2AX.js} +99 -50
- package/dist/{TimePickerForm-DohOZViU.js → TimePickerForm-BMqNpDPT.js} +5 -5
- package/dist/{ToastContainer-Dd0LPykL.js → ToastContainer-BeklfvlK.js} +4 -4
- package/dist/{ToggleButton-HUZ8ij6i.d.ts → ToggleButton-DWw53pTt.d.ts} +2 -2
- package/dist/ToggleGroup-BQk3k0at.d.ts +95 -0
- package/dist/ToggleGroup-BdIgqoqA.js +500 -0
- package/dist/{Tooltip-DRB6lo0U.js → Tooltip-BkXPEBqw.js} +2 -2
- package/dist/Tooltip-H8OB7CqY.d.ts +33 -0
- package/dist/TooltipEllipsis-7QF00kXk.d.ts +21 -0
- package/dist/{TooltipWrapper-DLBksJsF.js → TooltipWrapper-ubbBHHVD.js} +6 -6
- package/dist/{Typography-DJojwiXV.d.ts → Typography-Cx1oRGxd.d.ts} +5 -1
- package/dist/{badgeButton.cva-t5PQOH4M.js → badge.cva-BpoxNggB.js} +20 -22
- package/dist/{button.cva-Ciga0rdG.js → button.cva-C2aoXMh-.js} +10 -16
- package/dist/{buttonContent.cva-BapnODby.d.ts → buttonContent.cva-Dyy_RUZU.d.ts} +1 -1
- package/dist/{checkbox.cva-aLJS7v4z.js → checkbox.cva-qU_q0lSX.js} +14 -14
- package/dist/components/accordion.d.ts +1 -1
- package/dist/components/accordion.js +1 -1
- package/dist/components/alert-dialog.d.ts +2 -2
- package/dist/components/alert-dialog.js +174 -128
- package/dist/components/alert.d.ts +1 -1
- package/dist/components/alert.js +17 -15
- package/dist/components/autocomplete.d.ts +2 -2
- package/dist/components/autocomplete.js +1 -1
- package/dist/components/badge.d.ts +2 -2
- package/dist/components/badge.js +159 -81
- package/dist/components/bottom-sheet-header.d.ts +1 -1
- package/dist/components/bottom-sheet-header.js +4 -4
- package/dist/components/bottom-sheet.d.ts +2 -2
- package/dist/components/bottom-sheet.js +2 -2
- package/dist/components/breadcrumbs.d.ts +1 -1
- package/dist/components/breadcrumbs.js +1 -1
- package/dist/components/button.d.ts +2 -2
- package/dist/components/button.js +1 -1
- package/dist/components/checkbox-group.d.ts +2 -2
- package/dist/components/checkbox-group.js +1 -1
- package/dist/components/checkbox.d.ts +2 -2
- package/dist/components/checkbox.js +1 -1
- package/dist/components/date-picker.d.ts +2 -2
- package/dist/components/date-picker.js +1 -1
- package/dist/components/date-range-picker.d.ts +4 -41
- package/dist/components/date-range-picker.js +4 -2
- package/dist/components/date-range-presets.d.ts +2 -0
- package/dist/components/date-range-presets.js +3 -0
- package/dist/components/date-time-picker.d.ts +2 -2
- package/dist/components/date-time-picker.js +1 -1
- package/dist/components/dialog.d.ts +1 -1
- package/dist/components/dialog.js +1 -1
- package/dist/components/drawer.d.ts +1 -1
- package/dist/components/drawer.js +16 -80
- package/dist/components/dropdown-menu.d.ts +2 -3
- package/dist/components/dropdown-menu.js +2 -3
- package/dist/components/file-input.d.ts +2 -2
- package/dist/components/file-input.js +1 -1
- package/dist/components/file-upload.d.ts +2 -3
- package/dist/components/file-upload.js +1 -1
- package/dist/components/form-field.d.ts +3 -2
- package/dist/components/form-field.js +1 -1
- package/dist/components/icon-button.d.ts +1 -1
- package/dist/components/icon-button.js +22 -25
- package/dist/components/icon-slot.d.ts +1 -2
- package/dist/components/icon-slot.js +2 -2
- package/dist/components/input-frame.d.ts +6 -10
- package/dist/components/input-frame.js +29 -26
- package/dist/components/input.d.ts +2 -2
- package/dist/components/input.js +2 -2
- package/dist/components/link.d.ts +1 -1
- package/dist/components/link.js +1 -1
- package/dist/components/number-field.d.ts +2 -2
- package/dist/components/number-field.js +2 -2
- package/dist/components/number-range-input.d.ts +2 -2
- package/dist/components/number-range-input.js +1 -1
- package/dist/components/page-header.d.ts +1 -1
- package/dist/components/page-header.js +5 -5
- package/dist/components/password-input.d.ts +2 -2
- package/dist/components/password-input.js +1 -22
- package/dist/components/popover.d.ts +1 -1
- package/dist/components/popover.js +105 -87
- package/dist/components/progress.d.ts +2 -2
- package/dist/components/progress.js +1 -1
- package/dist/components/radio-group.d.ts +2 -2
- package/dist/components/radio-group.js +1 -1
- package/dist/components/select.d.ts +2 -2
- package/dist/components/select.js +1 -1
- package/dist/components/sidebar.d.ts +1 -1
- package/dist/components/sidebar.js +1 -1
- package/dist/components/slider.d.ts +2 -2
- package/dist/components/slider.js +1 -1
- package/dist/components/spinner.d.ts +1 -1
- package/dist/components/spinner.js +71 -1
- package/dist/components/split-button.d.ts +1 -1
- package/dist/components/split-button.js +15 -4
- package/dist/components/stepper.d.ts +1 -1
- package/dist/components/stepper.js +1 -1
- package/dist/components/style-definitions.d.ts +2 -2
- package/dist/components/style-definitions.js +33 -18
- package/dist/components/switch.d.ts +2 -2
- package/dist/components/switch.js +1 -1
- package/dist/components/tabs-filters.d.ts +1 -1
- package/dist/components/tabs-filters.js +1 -1
- package/dist/components/tag.d.ts +1 -1
- package/dist/components/tag.js +50 -64
- package/dist/components/text-area.d.ts +2 -2
- package/dist/components/text-area.js +1 -1
- package/dist/components/time-picker.d.ts +2 -2
- package/dist/components/time-picker.js +1 -1
- package/dist/components/toast.d.ts +3 -3
- package/dist/components/toast.js +4 -3
- package/dist/components/toggle-button.d.ts +1 -1
- package/dist/components/toggle-button.js +1 -1
- package/dist/components/toggle-group.d.ts +2 -2
- package/dist/components/toggle-group.js +1 -1
- package/dist/components/tooltip-ellipsis.d.ts +1 -1
- package/dist/components/tooltip-ellipsis.js +1 -1
- package/dist/components/tooltip.d.ts +1 -1
- package/dist/components/tooltip.js +1 -1
- package/dist/components/typography.d.ts +2 -2
- package/dist/components/use-toast.d.ts +2 -2
- package/dist/components/use-toast.js +1 -41
- package/dist/config/component-configuration.d.ts +1 -1
- package/dist/config/component-configuration.js +53 -2
- package/dist/config/confirmation.d.ts +1 -1
- package/dist/config/confirmation.js +1 -1
- package/dist/config/link-context.d.ts +3 -3
- package/dist/config/link-context.js +1 -1
- package/dist/config/resources.d.ts +1 -1
- package/dist/config/resources.js +1 -1
- package/dist/config/ui-config.d.ts +2 -2
- package/dist/config/ui-config.js +1 -1
- package/dist/config/ui-router.d.ts +1 -1
- package/dist/config/ui-router.js +1 -1
- package/dist/confirmation.context-BflM4Vxg.js +93 -0
- package/dist/confirmation.context-C_js9qNv.d.ts +32 -0
- package/dist/{datePickerInput.cva-Du0Zn04v.js → datePickerInput.cva-CWkV2fut.js} +1 -1
- package/dist/dateRangePreset.utils-Bnb-rjTt.js +116 -0
- package/dist/{dialog.cva-BIpz6HcA.js → dialog.cva-BjVggO5l.js} +1 -1
- package/dist/{dist-DEZzXa0W.js → dist-DZOoWaZz.js} +63 -38
- package/dist/{dropdownMenu.cva-DwSOcbmR.js → dropdownMenu.cva-BopsvbOy.js} +19 -7
- package/dist/{exports-BNrTn8Tj.js → exports-DeBGRThC.js} +3 -3
- package/dist/{file.utils-Crb-mIHs.d.ts → file.utils-DUADtzdt.d.ts} +3 -3
- package/dist/{file.utils-DqQxnuAm.js → file.utils-X6tkeWaz.js} +2 -6
- package/dist/fileInputButton.cva-gbqRUf1g.js +39 -0
- package/dist/{fileUpload.cva-BYzXGc9C.js → fileUpload.cva-MH5ziWUe.js} +2 -2
- package/dist/form-field-Bw7U_ZPI.d.ts +1 -0
- package/dist/form.binding-Brdjq2yr.js +161 -0
- package/dist/form.binding-DSXB2AOD.d.ts +127 -0
- package/dist/form.types-a2WVJDQX.d.ts +43 -0
- package/dist/formReset-CnZl_yze.js +35 -0
- package/dist/hints-B09_WDhL.d.ts +17 -0
- package/dist/hooks/use-async-list.d.ts +1 -1
- package/dist/hooks/use-async-list.js +1 -1
- package/dist/hooks/use-breakpoint.d.ts +3 -0
- package/dist/hooks/use-breakpoint.js +2 -0
- package/dist/hooks/use-filters.d.ts +2 -2
- package/dist/hooks/use-filters.js +1 -1
- package/dist/{i18n-EDC8xyfH.d.ts → i18n-B3PeqBM7.d.ts} +100 -20
- package/dist/{i18n-BE9Wvs9L.js → i18n-DQs7jPjv.js} +99 -25
- package/dist/iconSlot.cva-DyhOI7EK.js +5 -0
- package/dist/{import-Dkfk7PHt.js → import-C73fI3WD.js} +2 -2
- package/dist/index.d.ts +64 -85
- package/dist/index.js +55 -92
- package/dist/{input.cva-DZii82eS.js → input.cva-mm1dnfKP.js} +27 -23
- package/dist/inputLayout-CIVpuUBq.js +7 -0
- package/dist/inputRow.clsx-BbcaXVta.js +6 -0
- package/dist/{label.cva-DTfT6FrX.js → label.cva-DJ5Dmbz5.js} +7 -7
- package/dist/link.context-BcBuP9ZT.d.ts +20 -0
- package/dist/{link.context-TPjDtjw3.js → link.context-CD5h_b5O.js} +12 -11
- package/dist/link.cva-D6L1c2wq.d.ts +2157 -0
- package/dist/{logger-CqZjM-sn.js → logger-CW24po62.js} +10 -1
- package/dist/{progress.cva-CsGaGVJ-.js → progress.cva-mkJxrrac.js} +2 -2
- package/dist/{radio.cva-DistaZtZ.js → radio.cva-Dt5N2ul2.js} +7 -7
- package/dist/rich-text-editor.d.ts +44 -2
- package/dist/rich-text-editor.js +733 -1
- package/dist/router.context-B6j_M4cN.js +151 -0
- package/dist/router.context-CSd9JYQ4.d.ts +33 -0
- package/dist/{selectDesktop.cva-DStkOdwm.js → selectDesktop.cva-30JAvtgB.js} +1 -1
- package/dist/sidebar.cva-BgxTCejU.js +150 -0
- package/dist/spinner.cva-j4kGmIWC.js +17 -0
- package/dist/{staticDateTimeSegments-4tIzPL8l.js → staticDateTimeSegments-BYk1tcxs.js} +43 -13
- package/dist/{status.cva-CYgi3Htz.js → status.cva-WLEqUAjH.js} +9 -9
- package/dist/styles/input.d.ts +1 -1
- package/dist/tanstack/form.d.ts +3 -3
- package/dist/tanstack/form.js +3 -3
- package/dist/tanstack/table.d.ts +5 -3
- package/dist/tanstack/table.js +2 -2
- package/dist/tanstack-ABeiJISz.js +10 -0
- package/dist/tanstack-bLXoUPDY.d.ts +165 -0
- package/dist/tanstack.d.ts +64 -85
- package/dist/tanstack.js +55 -92
- package/dist/{toast.cva-B6NXTwbZ.js → toast.cva-C3oA7He3.js} +8 -8
- package/dist/toast.runtime-BHXdSTXV.js +25 -0
- package/dist/{toggleGroup.cva-CJ-3Ps7j.js → toggleGroup.cva-CvNS5QO1.js} +2 -2
- package/dist/uiConfig.context-CN_QgxGO.d.ts +19 -0
- package/dist/{uiConfig.context-3DN9w6oU.js → uiConfig.context-CjnLnQOo.js} +5 -7
- package/dist/{uiConfig.context-BnCORTNm.d.ts → uiConfig.types-B0sPL7nN.d.ts} +34 -34
- package/dist/{useAsyncList-Ct74ve3i.js → useAsyncList-CQgkDfjW.js} +140 -35
- package/dist/useAsyncList-F-328rtE.d.ts +25 -0
- package/dist/useAutoFocus-K-bfNxa2.js +16 -0
- package/dist/{useBreakpoint-CJ3mx7UF.js → useBreakpoint-BrJrvp9_.js} +5 -1
- package/dist/useBreakpoint-D-SVcBeQ.d.ts +9 -0
- package/dist/useDebounceCallback-BjePw6y4.js +90 -0
- package/dist/useFilters-CybBXUAA.js +217 -0
- package/dist/useFilters-DrfBFNLw.d.ts +57 -0
- package/dist/useFormAutosave-BN-zueci.js +419 -0
- package/dist/{useFormAutosave-BBLm3Ujo.d.ts → useFormAutosave-ClMnzVE7.d.ts} +1 -1
- package/dist/{useIntersectionObserver-DFAhTsV0.js → useIntersectionObserver-B8msnQTR.js} +15 -3
- package/dist/{numberStatic.utils-BIyZuILs.js → useLiveNumberFieldState-B7qGzySj.js} +103 -2
- package/dist/useRemoveButton-B6-IGvpY.js +98 -0
- package/dist/useResolveDateRangePreset-C_L-doA6.js +26 -0
- package/dist/useResolveDateRangePreset-DOSzJR-N.d.ts +64 -0
- package/dist/{useScrollableListBox-oYKqU3Hp.js → useScrollableListBox-C8chM7c-.js} +1 -1
- package/dist/{useStaticInputHandoff-BN0fOerH.js → useStaticInputHandoff-DrNFrvD7.js} +6 -1
- package/dist/{useTableColumnConfig-D3KH4Rpo.js → useTableColumnConfig-B9cYBKo3.js} +956 -689
- package/dist/useTableNav-rP1wDkhV.d.ts +372 -0
- package/dist/useToast-D2C9pROU.d.ts +78 -0
- package/dist/useToast-DSoOiSw0.js +63 -0
- package/dist/utils/file.d.ts +1 -1
- package/dist/utils/file.js +1 -1
- package/dist/utils/logger.js +1 -1
- package/llms.txt +3116 -0
- package/package.json +13 -131
- package/MIGRATION.md +0 -673
- package/dist/Alert-D4X7OWiv.d.ts +0 -34
- package/dist/AlertDialog-DklLDjmw.d.ts +0 -26
- package/dist/Autocomplete-BgFz3kuR.d.ts +0 -23
- package/dist/Autocomplete-BxRjxjtp.js +0 -145
- package/dist/Autocomplete.bound-CpHZZ3C9.d.ts +0 -9
- package/dist/Autocomplete.bound-DweyHUI5.js +0 -28
- package/dist/Badge-Db1ndK67.d.ts +0 -30
- package/dist/BadgeButton-BPhWDAnc.d.ts +0 -15
- package/dist/BottomSheet-BZmDJBR-.d.ts +0 -33
- package/dist/ButtonBase-CZuEy3Pk.d.ts +0 -32
- package/dist/Checkbox-w2j5hLOQ.d.ts +0 -27
- package/dist/Checkbox.bound-D2nBglJz.js +0 -33
- package/dist/Checkbox.bound-DD_RCjVm.d.ts +0 -9
- package/dist/CheckboxCheckmark-DWsYVZuu.js +0 -25
- package/dist/CheckboxGroup-BYI15Y09.d.ts +0 -30
- package/dist/CheckboxGroup.bound-DY0HKGSh.js +0 -32
- package/dist/CheckboxGroup.bound-QiJ-P0KR.d.ts +0 -9
- package/dist/ComboBox-ChsdI0lt.js +0 -212
- package/dist/DatePicker-QzfQf21b.d.ts +0 -56
- package/dist/DatePicker.bound-DoCAqhM4.d.ts +0 -9
- package/dist/DatePicker.bound-Dxg2LM89.js +0 -36
- package/dist/DateRangePicker-32D4pWJg.d.ts +0 -97
- package/dist/DateRangePicker.bound-CVtoVsho.d.ts +0 -9
- package/dist/DateRangePicker.bound-PR9rBoXc.js +0 -35
- package/dist/DateTimePicker-BTRIUagV.d.ts +0 -55
- package/dist/DateTimePicker.bound-CQxnRveH.js +0 -32
- package/dist/DateTimePicker.bound-X4DTyQ1b.d.ts +0 -9
- package/dist/Dialog-CO9xljD3.d.ts +0 -21
- package/dist/Drawer-D1cHiBFO.d.ts +0 -18
- package/dist/DropdownMenu-D_9z9ond.d.ts +0 -25
- package/dist/FileInput-BEaECoBS.d.ts +0 -75
- package/dist/FileInput.bound-CctyulN9.js +0 -30
- package/dist/FileInput.bound-D2HuuqSb.d.ts +0 -8
- package/dist/FileUpload-BUTSqHVk.d.ts +0 -11
- package/dist/FileUpload-Dfs3FvJ7.js +0 -749
- package/dist/FileUpload.bound-CGQXb4iT.d.ts +0 -16
- package/dist/FileUpload.bound-vik_sTkm.js +0 -30
- package/dist/FileUploadContainer-Dzg5aXXZ.d.ts +0 -5
- package/dist/FormField-DGyCDxOp.d.ts +0 -42
- package/dist/FormFieldHeaderTooltip-Dt-g40Tc.js +0 -17
- package/dist/IconButton-shH_9wcl.d.ts +0 -25
- package/dist/Input-CTp_9mS9.d.ts +0 -34
- package/dist/Input.bound-0iJO2-ia.js +0 -31
- package/dist/Input.bound-B9a62ylL.d.ts +0 -9
- package/dist/InputContent-BCNkN4Fx.d.ts +0 -27
- package/dist/Link-PvYB_M-j.d.ts +0 -30
- package/dist/MenuItem-U3-pu1j5.d.ts +0 -6
- package/dist/NumberField-WXebfxjK.d.ts +0 -34
- package/dist/NumberField.bound-DHDsBNvI.js +0 -32
- package/dist/NumberField.bound-Dy0A5iVc.d.ts +0 -9
- package/dist/NumberRangeInput-BCKQaGpy.d.ts +0 -50
- package/dist/NumberRangeInput.bound-5Yv3Og73.js +0 -32
- package/dist/NumberRangeInput.bound-BNXxIQ0b.d.ts +0 -9
- package/dist/Pagination-BCGUVYOF.d.ts +0 -12
- package/dist/PaginationList-CvlSkJGn.d.ts +0 -18
- package/dist/PaginationList-D7SRwySe.js +0 -220
- package/dist/PasswordInput-EhQjYyJS.d.ts +0 -11
- package/dist/PasswordInput.bound-CK5GwKL4.d.ts +0 -9
- package/dist/Popover-D_t1XDPA.d.ts +0 -20
- package/dist/Progress-Ckfpi_-M.d.ts +0 -45
- package/dist/Progress-RiEGGxNG.js +0 -119
- package/dist/RadioGroup-6e-Z6jW8.d.ts +0 -26
- package/dist/RadioGroup.bound-BFWSq-on.js +0 -32
- package/dist/RadioGroup.bound-w3SZqSkH.d.ts +0 -9
- package/dist/RichTextEditor-BuqZth3X.js +0 -651
- package/dist/RichTextEditor-DHhuBeT6.d.ts +0 -28
- package/dist/Select-C34ENdjq.d.ts +0 -119
- package/dist/Select.bound-CNCChZww.js +0 -34
- package/dist/Select.bound-qOihchei.d.ts +0 -17
- package/dist/Slider-DRg8zKRM.d.ts +0 -23
- package/dist/Slider.bound-CByTXPTr.js +0 -31
- package/dist/Slider.bound-CaEF19um.d.ts +0 -9
- package/dist/Spinner-Cvy_6zgD.d.ts +0 -30
- package/dist/Spinner-DqjP06T1.js +0 -101
- package/dist/SplitButton-V1f2NWfh.d.ts +0 -15
- package/dist/Stepper-k91x_m-E.d.ts +0 -114
- package/dist/Switch-ELVPkPx0.d.ts +0 -24
- package/dist/Switch.bound-DeEdVvZV.d.ts +0 -9
- package/dist/Switch.bound-Dv0cHsMM.js +0 -33
- package/dist/TableDnd-CuHxANWh.js +0 -133
- package/dist/TableRowDetails-D8HFTghI.d.ts +0 -109
- package/dist/TabsFilters-DePddjCk.d.ts +0 -30
- package/dist/Tag-B2_ZiSE-.d.ts +0 -44
- package/dist/TextArea-iqUeB2QY.d.ts +0 -26
- package/dist/TextArea.bound-BJHyCogp.d.ts +0 -9
- package/dist/TextArea.bound-CDVPP_qb.js +0 -28
- package/dist/TimePicker-BZ1ocsBX.d.ts +0 -45
- package/dist/TimePicker.bound-8DmjMXuE.d.ts +0 -9
- package/dist/TimePicker.bound-DPia51Qs.js +0 -32
- package/dist/Toast-D9pdadZ4.d.ts +0 -16
- package/dist/ToggleGroup-CrDoeLN0.js +0 -333
- package/dist/ToggleGroup-DvjnSinl.d.ts +0 -42
- package/dist/ToggleGroup.bound-B03ISHQ8.d.ts +0 -9
- package/dist/ToggleGroup.bound-DCnYwmBt.js +0 -67
- package/dist/Tooltip-B8DTURLQ.d.ts +0 -16
- package/dist/TooltipEllipsis-Di9Dvd4x.d.ts +0 -11
- package/dist/badgeButton.cva-CBFIhr1S.d.ts +0 -41
- package/dist/button.cva-C8LGtNJ3.d.ts +0 -94
- package/dist/checkbox.cva-CCh_UlrC.d.ts +0 -76
- package/dist/components/badge-button.d.ts +0 -2
- package/dist/components/badge-button.js +0 -74
- package/dist/components/file-upload-container.d.ts +0 -3
- package/dist/components/file-upload-container.js +0 -15
- package/dist/components/pagination-list.d.ts +0 -2
- package/dist/components/pagination-list.js +0 -2
- package/dist/components/pagination.d.ts +0 -2
- package/dist/components/pagination.js +0 -138
- package/dist/confirmation.context-BwlIEVeF.js +0 -114
- package/dist/confirmation.context-C_GDRn3a.d.ts +0 -23
- package/dist/fileUpload.types-C-ke21yY.d.ts +0 -110
- package/dist/form.binding-DOR5gIQf.js +0 -49
- package/dist/form.types-C8P4sznq.d.ts +0 -22
- package/dist/formFieldHelper.cva-DRmSyRZN.js +0 -14
- package/dist/iconSlot.cva-CLB5Tlsr.d.ts +0 -9
- package/dist/icons.d.ts +0 -4
- package/dist/icons.js +0 -3
- package/dist/input.cva-BjuHsDGy.d.ts +0 -80
- package/dist/inputLayout-KdAtunGk.js +0 -5
- package/dist/link.context-BCHn7NSy.d.ts +0 -12
- package/dist/radio.cva-D7M1hqLe.d.ts +0 -56
- package/dist/router.context-CtafjXV7.d.ts +0 -16
- package/dist/router.context-MckTbHw9.js +0 -63
- package/dist/routing.utils-DfxEt0_Y.js +0 -30
- package/dist/style-definitions-Dx6aFDiR.d.ts +0 -1038
- package/dist/switch.cva-r6vcS25Q.d.ts +0 -16
- package/dist/tanstack/autocomplete.d.ts +0 -3
- package/dist/tanstack/autocomplete.js +0 -2
- package/dist/tanstack/checkbox-group.d.ts +0 -3
- package/dist/tanstack/checkbox-group.js +0 -2
- package/dist/tanstack/checkbox.d.ts +0 -3
- package/dist/tanstack/checkbox.js +0 -2
- package/dist/tanstack/date-picker.d.ts +0 -3
- package/dist/tanstack/date-picker.js +0 -2
- package/dist/tanstack/date-range-picker.d.ts +0 -3
- package/dist/tanstack/date-range-picker.js +0 -2
- package/dist/tanstack/date-time-picker.d.ts +0 -3
- package/dist/tanstack/date-time-picker.js +0 -2
- package/dist/tanstack/file-input.d.ts +0 -3
- package/dist/tanstack/file-input.js +0 -2
- package/dist/tanstack/file-upload.d.ts +0 -4
- package/dist/tanstack/file-upload.js +0 -2
- package/dist/tanstack/input.d.ts +0 -3
- package/dist/tanstack/input.js +0 -2
- package/dist/tanstack/number-field.d.ts +0 -3
- package/dist/tanstack/number-field.js +0 -2
- package/dist/tanstack/number-range-input.d.ts +0 -3
- package/dist/tanstack/number-range-input.js +0 -2
- package/dist/tanstack/password-input.d.ts +0 -2
- package/dist/tanstack/password-input.js +0 -2
- package/dist/tanstack/radio-group.d.ts +0 -3
- package/dist/tanstack/radio-group.js +0 -2
- package/dist/tanstack/rich-text-editor.d.ts +0 -9
- package/dist/tanstack/rich-text-editor.js +0 -28
- package/dist/tanstack/select.d.ts +0 -3
- package/dist/tanstack/select.js +0 -2
- package/dist/tanstack/slider.d.ts +0 -3
- package/dist/tanstack/slider.js +0 -2
- package/dist/tanstack/switch.d.ts +0 -3
- package/dist/tanstack/switch.js +0 -2
- package/dist/tanstack/text-area.d.ts +0 -3
- package/dist/tanstack/text-area.js +0 -2
- package/dist/tanstack/time-picker.d.ts +0 -3
- package/dist/tanstack/time-picker.js +0 -2
- package/dist/tanstack/toggle-group.d.ts +0 -3
- package/dist/tanstack/toggle-group.js +0 -2
- package/dist/tanstack-Bgdv0qU1.js +0 -19
- package/dist/tanstack-CtuKX9Ss.d.ts +0 -568
- package/dist/toast.cva-AmLw6Cf5.d.ts +0 -61
- package/dist/toast.runtime-Drd2IJ_j.js +0 -17
- package/dist/toastActivation.store-BELtcr76.js +0 -16
- package/dist/toggleGroup.cva-DA4U21gn.d.ts +0 -26
- package/dist/typography.cva-BCHlTHdM.d.ts +0 -36
- package/dist/useAsyncList-Cu-Y8If2.d.ts +0 -9
- package/dist/useFilters-BxRScJdn.d.ts +0 -11
- package/dist/useFilters-DMi94RZK.js +0 -190
- package/dist/useForm-Cb7KWLds.js +0 -217
- package/dist/useForm-I6z23FXf.d.ts +0 -51
- package/dist/useFormAutosave-BPGlChiY.js +0 -216
- package/dist/useTableNav-H5DrogZU.d.ts +0 -215
- package/dist/useToast-DsA8CVoY.d.ts +0 -16
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import { n as RoutingUtils, t as UIRouter } from "./router.context-B6j_M4cN.js";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import { useEffect, useRef, useState } from "react";
|
|
4
|
+
//#region src/hooks/useFilters.ts
|
|
5
|
+
const NUMBER_TEXT = /^-?(0|[1-9]\d*)(\.\d+)?([eE][+-]?\d+)?$/;
|
|
6
|
+
const ISO_DATE_TEXT = /^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:\d{2})?)?$/;
|
|
7
|
+
const mapDeep = (value, map) => {
|
|
8
|
+
if (Array.isArray(value)) return value.map((item) => mapDeep(item, map));
|
|
9
|
+
if (value !== null && typeof value === "object" && Object.getPrototypeOf(value) === Object.prototype) return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, mapDeep(item, map)]));
|
|
10
|
+
return map(value);
|
|
11
|
+
};
|
|
12
|
+
const toUrlValue = (value) => mapDeep(value, (leaf) => leaf instanceof Date ? leaf.toISOString() : leaf);
|
|
13
|
+
const reviveDates = (value) => mapDeep(value, (leaf) => typeof leaf === "string" && ISO_DATE_TEXT.test(leaf) && !Number.isNaN(Date.parse(leaf)) ? new Date(leaf) : leaf);
|
|
14
|
+
const getReadings = (decoded, raw) => {
|
|
15
|
+
const text = typeof decoded === "string" ? decoded : raw;
|
|
16
|
+
const readings = [decoded, raw];
|
|
17
|
+
if (NUMBER_TEXT.test(text) && Number.isFinite(Number(text))) readings.push(Number(text));
|
|
18
|
+
if (text === "true" || text === "false") readings.push(text === "true");
|
|
19
|
+
readings.push(reviveDates(decoded));
|
|
20
|
+
return readings;
|
|
21
|
+
};
|
|
22
|
+
const parseField = (fieldSchema, decoded, raw) => {
|
|
23
|
+
for (const reading of getReadings(decoded, raw)) try {
|
|
24
|
+
const result = fieldSchema.safeParse(reading);
|
|
25
|
+
if (result.success) return { value: result.data };
|
|
26
|
+
} catch {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
const toSearchKey = (prefix, key) => prefix ? `filter[${prefix}][${key}]` : `filter[${key}]`;
|
|
31
|
+
const toFilterKey = (prefix, searchKey) => {
|
|
32
|
+
const head = prefix ? `filter[${prefix}][` : "filter[";
|
|
33
|
+
if (!searchKey.startsWith(head) || !searchKey.endsWith("]")) return;
|
|
34
|
+
const key = searchKey.slice(head.length, -1);
|
|
35
|
+
return key === "" || key.includes("[") || key.includes("]") ? void 0 : key;
|
|
36
|
+
};
|
|
37
|
+
const serializeFiltersToQuery = (filterData, prefix) => {
|
|
38
|
+
const query = {};
|
|
39
|
+
for (const [key, value] of Object.entries(filterData)) {
|
|
40
|
+
if (value === null || value === void 0) continue;
|
|
41
|
+
query[toSearchKey(prefix, key)] = toUrlValue(value);
|
|
42
|
+
}
|
|
43
|
+
return query;
|
|
44
|
+
};
|
|
45
|
+
const parseFilterFromQuery = (searchParams, prefix, schema) => {
|
|
46
|
+
const filter = {};
|
|
47
|
+
const shape = schema?.shape;
|
|
48
|
+
const rawValues = new Map(searchParams.entries());
|
|
49
|
+
for (const [key, value] of Object.entries(RoutingUtils.toRouterSearch(searchParams))) {
|
|
50
|
+
const filterKey = toFilterKey(prefix, key);
|
|
51
|
+
if (filterKey === void 0 || filterKey === "__proto__") continue;
|
|
52
|
+
if (!shape) {
|
|
53
|
+
filter[filterKey] = value;
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
if (!Object.hasOwn(shape, filterKey)) continue;
|
|
57
|
+
const field = parseField(shape[filterKey], value, rawValues.get(key) ?? "");
|
|
58
|
+
if (field) filter[filterKey] = field.value;
|
|
59
|
+
}
|
|
60
|
+
return filter;
|
|
61
|
+
};
|
|
62
|
+
function useFilters(t0) {
|
|
63
|
+
const $ = c(37);
|
|
64
|
+
let t1;
|
|
65
|
+
if ($[0] !== t0) {
|
|
66
|
+
t1 = t0 === void 0 ? {} : t0;
|
|
67
|
+
$[0] = t0;
|
|
68
|
+
$[1] = t1;
|
|
69
|
+
} else t1 = $[1];
|
|
70
|
+
const { defaultValues: defaultFilterValues, prefix: t2, schema: schemaOption } = t1;
|
|
71
|
+
const prefix = t2 === void 0 ? "" : t2;
|
|
72
|
+
const schema = schemaOption;
|
|
73
|
+
const { searchParams, updateSearch } = UIRouter.useUIRouter();
|
|
74
|
+
let t3;
|
|
75
|
+
if ($[2] !== prefix || $[3] !== schema || $[4] !== searchParams) {
|
|
76
|
+
t3 = () => parseFilterFromQuery(searchParams, prefix, schema);
|
|
77
|
+
$[2] = prefix;
|
|
78
|
+
$[3] = schema;
|
|
79
|
+
$[4] = searchParams;
|
|
80
|
+
$[5] = t3;
|
|
81
|
+
} else t3 = $[5];
|
|
82
|
+
const [filterData, setFilterData] = useState(t3);
|
|
83
|
+
const writtenRef = useRef(null);
|
|
84
|
+
let t4;
|
|
85
|
+
if ($[6] !== defaultFilterValues || $[7] !== prefix || $[8] !== schema || $[9] !== searchParams || $[10] !== updateSearch) {
|
|
86
|
+
t4 = () => {
|
|
87
|
+
if (!defaultFilterValues || Object.keys(parseFilterFromQuery(searchParams, prefix, schema)).length > 0) return;
|
|
88
|
+
const defaultQuery = serializeFiltersToQuery(defaultFilterValues, prefix);
|
|
89
|
+
writtenRef.current = {
|
|
90
|
+
searchParams,
|
|
91
|
+
prefix,
|
|
92
|
+
filters: { ...defaultFilterValues }
|
|
93
|
+
};
|
|
94
|
+
updateSearch((search) => ({
|
|
95
|
+
...search,
|
|
96
|
+
...defaultQuery
|
|
97
|
+
}));
|
|
98
|
+
};
|
|
99
|
+
$[6] = defaultFilterValues;
|
|
100
|
+
$[7] = prefix;
|
|
101
|
+
$[8] = schema;
|
|
102
|
+
$[9] = searchParams;
|
|
103
|
+
$[10] = updateSearch;
|
|
104
|
+
$[11] = t4;
|
|
105
|
+
} else t4 = $[11];
|
|
106
|
+
let t5;
|
|
107
|
+
if ($[12] !== defaultFilterValues || $[13] !== prefix || $[14] !== schema) {
|
|
108
|
+
t5 = [
|
|
109
|
+
defaultFilterValues,
|
|
110
|
+
prefix,
|
|
111
|
+
schema
|
|
112
|
+
];
|
|
113
|
+
$[12] = defaultFilterValues;
|
|
114
|
+
$[13] = prefix;
|
|
115
|
+
$[14] = schema;
|
|
116
|
+
$[15] = t5;
|
|
117
|
+
} else t5 = $[15];
|
|
118
|
+
useEffect(t4, t5);
|
|
119
|
+
let t6;
|
|
120
|
+
let t7;
|
|
121
|
+
if ($[16] !== prefix || $[17] !== schema || $[18] !== searchParams) {
|
|
122
|
+
t6 = () => {
|
|
123
|
+
const newQueryFilters = parseFilterFromQuery(searchParams, prefix, schema);
|
|
124
|
+
setFilterData(newQueryFilters);
|
|
125
|
+
};
|
|
126
|
+
t7 = [
|
|
127
|
+
searchParams,
|
|
128
|
+
prefix,
|
|
129
|
+
schema
|
|
130
|
+
];
|
|
131
|
+
$[16] = prefix;
|
|
132
|
+
$[17] = schema;
|
|
133
|
+
$[18] = searchParams;
|
|
134
|
+
$[19] = t6;
|
|
135
|
+
$[20] = t7;
|
|
136
|
+
} else {
|
|
137
|
+
t6 = $[19];
|
|
138
|
+
t7 = $[20];
|
|
139
|
+
}
|
|
140
|
+
useEffect(t6, t7);
|
|
141
|
+
let t8;
|
|
142
|
+
if ($[21] !== defaultFilterValues || $[22] !== filterData || $[23] !== prefix || $[24] !== searchParams || $[25] !== updateSearch) {
|
|
143
|
+
t8 = (data) => {
|
|
144
|
+
const written = writtenRef.current;
|
|
145
|
+
let newFilters = { ...written?.searchParams === searchParams && written.prefix === prefix ? written.filters : filterData };
|
|
146
|
+
const isReset = Object.keys(data).length === 0;
|
|
147
|
+
if (data === defaultFilterValues) newFilters = { ...defaultFilterValues };
|
|
148
|
+
else if (isReset) newFilters = {};
|
|
149
|
+
else Object.entries(data).forEach((t9) => {
|
|
150
|
+
const [key, value] = t9;
|
|
151
|
+
if (value === void 0) delete newFilters[key];
|
|
152
|
+
else newFilters[key] = value;
|
|
153
|
+
});
|
|
154
|
+
const filterQuery = serializeFiltersToQuery(newFilters, prefix);
|
|
155
|
+
writtenRef.current = {
|
|
156
|
+
searchParams,
|
|
157
|
+
prefix,
|
|
158
|
+
filters: newFilters
|
|
159
|
+
};
|
|
160
|
+
updateSearch((search_0) => ({
|
|
161
|
+
...Object.fromEntries(Object.entries(search_0).filter((t10) => {
|
|
162
|
+
const [key_0] = t10;
|
|
163
|
+
return toFilterKey(prefix, key_0) === void 0;
|
|
164
|
+
})),
|
|
165
|
+
...filterQuery
|
|
166
|
+
}));
|
|
167
|
+
setFilterData(newFilters);
|
|
168
|
+
};
|
|
169
|
+
$[21] = defaultFilterValues;
|
|
170
|
+
$[22] = filterData;
|
|
171
|
+
$[23] = prefix;
|
|
172
|
+
$[24] = searchParams;
|
|
173
|
+
$[25] = updateSearch;
|
|
174
|
+
$[26] = t8;
|
|
175
|
+
} else t8 = $[26];
|
|
176
|
+
const setFilterValue = t8;
|
|
177
|
+
let t9;
|
|
178
|
+
if ($[27] !== filterData) {
|
|
179
|
+
t9 = (keys) => {
|
|
180
|
+
const result = {};
|
|
181
|
+
keys.forEach((key_1) => {
|
|
182
|
+
result[key_1] = filterData[key_1];
|
|
183
|
+
});
|
|
184
|
+
return result;
|
|
185
|
+
};
|
|
186
|
+
$[27] = filterData;
|
|
187
|
+
$[28] = t9;
|
|
188
|
+
} else t9 = $[28];
|
|
189
|
+
const getFilterValue = t9;
|
|
190
|
+
let t10;
|
|
191
|
+
if ($[29] !== defaultFilterValues || $[30] !== setFilterValue) {
|
|
192
|
+
t10 = () => {
|
|
193
|
+
setFilterValue(defaultFilterValues ?? {});
|
|
194
|
+
};
|
|
195
|
+
$[29] = defaultFilterValues;
|
|
196
|
+
$[30] = setFilterValue;
|
|
197
|
+
$[31] = t10;
|
|
198
|
+
} else t10 = $[31];
|
|
199
|
+
const clearAllFilters = t10;
|
|
200
|
+
let t11;
|
|
201
|
+
if ($[32] !== clearAllFilters || $[33] !== filterData || $[34] !== getFilterValue || $[35] !== setFilterValue) {
|
|
202
|
+
t11 = {
|
|
203
|
+
filterData,
|
|
204
|
+
setFilterValue,
|
|
205
|
+
getFilterValue,
|
|
206
|
+
clearAllFilters
|
|
207
|
+
};
|
|
208
|
+
$[32] = clearAllFilters;
|
|
209
|
+
$[33] = filterData;
|
|
210
|
+
$[34] = getFilterValue;
|
|
211
|
+
$[35] = setFilterValue;
|
|
212
|
+
$[36] = t11;
|
|
213
|
+
} else t11 = $[36];
|
|
214
|
+
return t11;
|
|
215
|
+
}
|
|
216
|
+
//#endregion
|
|
217
|
+
export { useFilters as t };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { t as Hint } from "./hints-B09_WDhL.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
//#region src/hooks/useFilters.d.ts
|
|
4
|
+
/** A Zod object schema whose output is `TFilterData`. */
|
|
5
|
+
type FilterSchema<TFilterData> = z.ZodObject & z.ZodType<TFilterData, unknown>;
|
|
6
|
+
interface FilterStore<TFilterData> {
|
|
7
|
+
/**
|
|
8
|
+
* The filters in the URL. Any key can be missing: the URL may lack it, and with a `schema` values that fail it and keys
|
|
9
|
+
* outside it are left out.
|
|
10
|
+
*/
|
|
11
|
+
filterData: Partial<TFilterData>;
|
|
12
|
+
/**
|
|
13
|
+
* Merges `data` into the filters and writes them to the URL. A key set to `undefined` is removed; `{}` clears all.
|
|
14
|
+
* Calls in one handler build on each other.
|
|
15
|
+
*/
|
|
16
|
+
setFilterValue: (data: Partial<TFilterData>) => void;
|
|
17
|
+
getFilterValue: (keys: (keyof TFilterData)[]) => Partial<TFilterData>;
|
|
18
|
+
/** Restores `defaultValues`, or removes every filter when there are none. */
|
|
19
|
+
clearAllFilters: () => void;
|
|
20
|
+
}
|
|
21
|
+
interface UseFiltersOptions<TFilterData> {
|
|
22
|
+
/**
|
|
23
|
+
* Filters written to the URL when it holds none, and restored by `clearAllFilters`. Define it outside the component
|
|
24
|
+
* so the reference stays stable.
|
|
25
|
+
*/
|
|
26
|
+
defaultValues?: NoInfer<Partial<TFilterData>>;
|
|
27
|
+
/**
|
|
28
|
+
* Namespaces the query keys (`filter[<prefix>][<key>]`) so several filter sets can share one page. Every store reads
|
|
29
|
+
* and writes only its own keys. A prefix holds no `[` or `]`.
|
|
30
|
+
*/
|
|
31
|
+
prefix?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Zod object of the filters; the store is typed from it. Each URL value is checked against its field, with numbers,
|
|
34
|
+
* booleans and ISO dates (for `z.date()`) read back from URL text. Values that fail and keys outside the schema are
|
|
35
|
+
* left out of `filterData`, never thrown. Define it outside the component so the reference stays stable.
|
|
36
|
+
*/
|
|
37
|
+
schema?: FilterSchema<TFilterData>;
|
|
38
|
+
}
|
|
39
|
+
type UntypedFilters = Record<string, unknown>;
|
|
40
|
+
/**
|
|
41
|
+
* Filter state kept in the URL query: `filter[<key>]`, or `filter[<prefix>][<key>]` with a `prefix`. Needs
|
|
42
|
+
* `UIRouter.UIRouterProvider` from `@povio/ui/ui-router` above it, which connects the app router.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* const orderFiltersSchema = z.object({ status: z.string().optional(), minTotal: z.number().optional() });
|
|
46
|
+
* const filters = useFilters({ schema: orderFiltersSchema });
|
|
47
|
+
* filters.filterData.minTotal; // number | undefined
|
|
48
|
+
*/
|
|
49
|
+
declare function useFilters<TFilterData extends object>(options: UseFiltersOptions<TFilterData> & {
|
|
50
|
+
schema: FilterSchema<TFilterData> | Hint<"Pass `schema`: without it URL values are only decoded (`1` becomes the number 1) and never checked against the type argument">;
|
|
51
|
+
}): FilterStore<TFilterData>;
|
|
52
|
+
/** Without a `schema` every `filter[...]` key of the store is kept, with values only decoded from the URL. */
|
|
53
|
+
declare function useFilters(options?: Omit<UseFiltersOptions<UntypedFilters>, "schema"> & {
|
|
54
|
+
schema?: undefined | Hint<"A `schema` that may be `undefined` matches neither form: branch on it, or always pass one">;
|
|
55
|
+
}): FilterStore<UntypedFilters>;
|
|
56
|
+
//#endregion
|
|
57
|
+
export { UseFiltersOptions as n, useFilters as r, FilterStore as t };
|
|
@@ -0,0 +1,419 @@
|
|
|
1
|
+
import { t as logger } from "./logger-CW24po62.js";
|
|
2
|
+
import { n as ObjectUtils, t as isEqual } from "./isEqual-LFw0W5rU.js";
|
|
3
|
+
import { a as registerFormDisabledStore } from "./form.binding-Brdjq2yr.js";
|
|
4
|
+
import { i as subscribeFormReset, n as notifyFormReset, r as refreshAutosaveForm, t as getFormResetVersion } from "./formReset-CnZl_yze.js";
|
|
5
|
+
import { c } from "react/compiler-runtime";
|
|
6
|
+
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef } from "react";
|
|
7
|
+
import { getBy, setBy, useForm, useStore } from "@tanstack/react-form";
|
|
8
|
+
import { Store } from "@tanstack/store";
|
|
9
|
+
//#region src/hooks/autosaveFields.ts
|
|
10
|
+
/** Raw fields edited since a submitted snapshot. Arrays and dates are replaced whole. */
|
|
11
|
+
function getChangedAutosaveFields(current, submitted, path = "") {
|
|
12
|
+
if (isEqual(current, submitted)) return [];
|
|
13
|
+
if (!ObjectUtils.isObject(current) || Array.isArray(current) || ObjectUtils.isDate(current) || ObjectUtils.isRegExp(current) || ObjectUtils.isEmpty(current)) return [[path, current]];
|
|
14
|
+
const values = current;
|
|
15
|
+
const previous = ObjectUtils.isObject(submitted) ? submitted : {};
|
|
16
|
+
return [.../* @__PURE__ */ new Set([...Object.keys(values), ...Object.keys(previous)])].flatMap((key) => getChangedAutosaveFields(values[key], previous[key], path ? `${path}.${key}` : key));
|
|
17
|
+
}
|
|
18
|
+
/** Select raw field paths included by a parsed patch, stopping at atomic raw fields. */
|
|
19
|
+
function getSubmittedAutosaveFields(patch, raw, path = "") {
|
|
20
|
+
if (!ObjectUtils.isObject(raw) || Array.isArray(raw) || ObjectUtils.isDate(raw) || ObjectUtils.isRegExp(raw) || !ObjectUtils.isObject(patch) || Array.isArray(patch)) return [[path, raw]];
|
|
21
|
+
return Object.entries(patch).flatMap(([key, value]) => getSubmittedAutosaveFields(value, raw[key], path ? `${path}.${key}` : key));
|
|
22
|
+
}
|
|
23
|
+
/** Project raw changes into parsed values, retaining explicit undefined clears. */
|
|
24
|
+
function getAutosavePatch(parsed, changes) {
|
|
25
|
+
let patch = {};
|
|
26
|
+
for (const [path] of changes) {
|
|
27
|
+
if (!path) return parsed;
|
|
28
|
+
patch = setBy(patch, path, getBy(parsed, path));
|
|
29
|
+
}
|
|
30
|
+
return patch;
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
33
|
+
//#region src/hooks/useAutosave.ts
|
|
34
|
+
const snapshot = (value) => structuredClone(value);
|
|
35
|
+
/** Autosaves changed fields only. Schemas must preserve raw field paths in their object output. */
|
|
36
|
+
function useAutosave({ form, delay = 500, enabled = true, trigger = "change", onSave, onSaveSuccess }) {
|
|
37
|
+
const timeoutRef = useRef(void 0);
|
|
38
|
+
const savedSnapshotRef = useRef(snapshot(form.state.values));
|
|
39
|
+
const saveQueueRef = useRef(Promise.resolve());
|
|
40
|
+
const acknowledgedFieldsRef = useRef(/* @__PURE__ */ new Map());
|
|
41
|
+
const resetRevisionRef = useRef(getFormResetVersion(form));
|
|
42
|
+
const latestSaveRef = useRef({
|
|
43
|
+
onSave,
|
|
44
|
+
onSaveSuccess
|
|
45
|
+
});
|
|
46
|
+
latestSaveRef.current = {
|
|
47
|
+
onSave,
|
|
48
|
+
onSaveSuccess
|
|
49
|
+
};
|
|
50
|
+
useEffect(() => {
|
|
51
|
+
let active = true;
|
|
52
|
+
const clearPending = () => {
|
|
53
|
+
if (timeoutRef.current) {
|
|
54
|
+
clearTimeout(timeoutRef.current);
|
|
55
|
+
timeoutRef.current = void 0;
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
const queueSave = () => {
|
|
59
|
+
if (!enabled) return;
|
|
60
|
+
clearPending();
|
|
61
|
+
const revision = resetRevisionRef.current;
|
|
62
|
+
timeoutRef.current = setTimeout(() => {
|
|
63
|
+
saveQueueRef.current = saveQueueRef.current.then(async () => {
|
|
64
|
+
if (!active || revision !== resetRevisionRef.current) return;
|
|
65
|
+
const valuesAtSaveTime = snapshot(form.state.values);
|
|
66
|
+
const previousSavedValues = savedSnapshotRef.current;
|
|
67
|
+
const changedFields = getChangedAutosaveFields(valuesAtSaveTime, previousSavedValues);
|
|
68
|
+
if (changedFields.length === 0) return;
|
|
69
|
+
let transformedValues;
|
|
70
|
+
try {
|
|
71
|
+
transformedValues = form.parseValues(valuesAtSaveTime);
|
|
72
|
+
} catch {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const payload = getAutosavePatch(transformedValues, changedFields);
|
|
76
|
+
if (ObjectUtils.isEmpty(payload)) return;
|
|
77
|
+
acknowledgedFieldsRef.current.clear();
|
|
78
|
+
try {
|
|
79
|
+
await latestSaveRef.current.onSave(payload);
|
|
80
|
+
if (!active || revision !== resetRevisionRef.current) return;
|
|
81
|
+
for (const [path, value] of getChangedAutosaveFields(valuesAtSaveTime, previousSavedValues)) {
|
|
82
|
+
if (acknowledgedFieldsRef.current.has(path) && isEqual(acknowledgedFieldsRef.current.get(path), value)) continue;
|
|
83
|
+
savedSnapshotRef.current = setBy(savedSnapshotRef.current, path, value);
|
|
84
|
+
}
|
|
85
|
+
for (const name of Object.keys(form.state.fieldMeta)) {
|
|
86
|
+
const submittedValue = getBy(valuesAtSaveTime, name);
|
|
87
|
+
if (!isEqual(getBy(previousSavedValues, name), submittedValue) && isEqual(form.getFieldValue(name), submittedValue)) form.setFieldMeta(name, (meta) => ({
|
|
88
|
+
...meta,
|
|
89
|
+
isDirty: false
|
|
90
|
+
}));
|
|
91
|
+
}
|
|
92
|
+
latestSaveRef.current.onSaveSuccess?.();
|
|
93
|
+
} catch {}
|
|
94
|
+
});
|
|
95
|
+
}, delay);
|
|
96
|
+
};
|
|
97
|
+
const unsubscribeStore = trigger === "change" ? form.store.subscribe(() => {
|
|
98
|
+
if (!isEqual(form.state.values, savedSnapshotRef.current)) queueSave();
|
|
99
|
+
}) : void 0;
|
|
100
|
+
const unsubscribeBlur = trigger === "blur" ? form.subscribeBlur(queueSave) : void 0;
|
|
101
|
+
const syncReset = (refresh) => {
|
|
102
|
+
if (refresh) {
|
|
103
|
+
for (const [path_0, value_0] of refresh.acknowledged) acknowledgedFieldsRef.current.set(path_0, value_0);
|
|
104
|
+
savedSnapshotRef.current = snapshot(refresh.baseline);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
resetRevisionRef.current = getFormResetVersion(form);
|
|
108
|
+
acknowledgedFieldsRef.current.clear();
|
|
109
|
+
clearPending();
|
|
110
|
+
savedSnapshotRef.current = snapshot(form.state.values);
|
|
111
|
+
};
|
|
112
|
+
if (resetRevisionRef.current !== getFormResetVersion(form)) syncReset();
|
|
113
|
+
const unsubscribeReset = subscribeFormReset(form, syncReset);
|
|
114
|
+
return () => {
|
|
115
|
+
active = false;
|
|
116
|
+
clearPending();
|
|
117
|
+
unsubscribeStore?.unsubscribe();
|
|
118
|
+
unsubscribeBlur?.();
|
|
119
|
+
unsubscribeReset();
|
|
120
|
+
};
|
|
121
|
+
}, [
|
|
122
|
+
delay,
|
|
123
|
+
enabled,
|
|
124
|
+
form,
|
|
125
|
+
trigger
|
|
126
|
+
]);
|
|
127
|
+
}
|
|
128
|
+
//#endregion
|
|
129
|
+
//#region src/hooks/useForm.ts
|
|
130
|
+
function useForm$1({ defaultValues, disabled = false, mode = "onSubmit", validateOnSubmitAsync, zodSchema } = {}) {
|
|
131
|
+
const submitHandlerRef = useRef(() => void 0);
|
|
132
|
+
const submitErrorHandlerRef = useRef(void 0);
|
|
133
|
+
const blurListenersRef = useRef(/* @__PURE__ */ new Set());
|
|
134
|
+
const touchedFieldsRef = useRef(/* @__PURE__ */ new Set());
|
|
135
|
+
const defaultValuesRef = useRef(defaultValues);
|
|
136
|
+
const fieldValidators = useMemo(() => {
|
|
137
|
+
return /* @__PURE__ */ new Map();
|
|
138
|
+
}, [mode, zodSchema]);
|
|
139
|
+
const formValidator = useMemo(() => {
|
|
140
|
+
if (!zodSchema) return;
|
|
141
|
+
return ({ value }) => {
|
|
142
|
+
const result = zodSchema.safeParse(value);
|
|
143
|
+
if (result.success) return;
|
|
144
|
+
return { fields: Object.fromEntries(result.error.issues.map((issue) => [pathToString(issue.path), issue.message])) };
|
|
145
|
+
};
|
|
146
|
+
}, [zodSchema]);
|
|
147
|
+
const initialDefaultValues = defaultValuesRef.current;
|
|
148
|
+
const form = useForm({
|
|
149
|
+
defaultValues: (typeof initialDefaultValues === "function" ? {} : initialDefaultValues) ?? {},
|
|
150
|
+
validators: formValidator || validateOnSubmitAsync ? {
|
|
151
|
+
onChange: formValidator,
|
|
152
|
+
onMount: formValidator ? (props) => formValidator(props) ? INVALID_ON_MOUNT : void 0 : void 0,
|
|
153
|
+
onSubmit: formValidator,
|
|
154
|
+
onSubmitAsync: validateOnSubmitAsync ? async ({ value: value_0 }) => {
|
|
155
|
+
const result_0 = await validateOnSubmitAsync({ value: value_0 });
|
|
156
|
+
return result_0 && Object.keys(result_0.fields).length > 0 ? { fields: result_0.fields } : void 0;
|
|
157
|
+
} : void 0
|
|
158
|
+
} : void 0,
|
|
159
|
+
onSubmit: async ({ value: value_1 }) => {
|
|
160
|
+
const transformed = zodSchema ? zodSchema.parse(value_1) : value_1;
|
|
161
|
+
await submitHandlerRef.current(transformed);
|
|
162
|
+
},
|
|
163
|
+
onSubmitInvalid: ({ value: value_2, formApi }) => {
|
|
164
|
+
submitErrorHandlerRef.current?.(getFieldErrors(formApi.state.fieldMeta), value_2);
|
|
165
|
+
},
|
|
166
|
+
listeners: { onChange: ({ formApi: formApi_0, fieldApi }) => clearNestedSubmitErrors(formApi_0, fieldApi.name) }
|
|
167
|
+
});
|
|
168
|
+
const originalHandleSubmit = useMemo(() => form.handleSubmit.bind(form), [form]);
|
|
169
|
+
const originalReset = useMemo(() => form.reset.bind(form), [form]);
|
|
170
|
+
const disabledStoreRef = useRef(void 0);
|
|
171
|
+
disabledStoreRef.current ??= new Store(disabled);
|
|
172
|
+
const disabledStore = disabledStoreRef.current;
|
|
173
|
+
const uiForm = form;
|
|
174
|
+
Object.defineProperty(uiForm, "disabled", {
|
|
175
|
+
configurable: true,
|
|
176
|
+
value: disabled,
|
|
177
|
+
writable: true
|
|
178
|
+
});
|
|
179
|
+
registerFormDisabledStore(uiForm, disabledStore);
|
|
180
|
+
uiForm.getFieldValidators = (name) => {
|
|
181
|
+
const cached = fieldValidators.get(name);
|
|
182
|
+
if (cached || fieldValidators.has(name)) return cached;
|
|
183
|
+
const schema = zodSchema ? getSchemaAtPath(zodSchema, name) : void 0;
|
|
184
|
+
if (!schema || mode === "onSubmit") {
|
|
185
|
+
fieldValidators.set(name, void 0);
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
const validate = ({ value: value_3 }) => {
|
|
189
|
+
const result_1 = schema.safeParse(value_3);
|
|
190
|
+
return result_1.success ? void 0 : result_1.error.issues[0]?.message;
|
|
191
|
+
};
|
|
192
|
+
const validators = mode === "all" ? {
|
|
193
|
+
onBlur: validate,
|
|
194
|
+
onChange: validate
|
|
195
|
+
} : mode === "onChange" ? { onChange: validate } : mode === "onBlur" ? { onBlur: validate } : {
|
|
196
|
+
onBlur: validate,
|
|
197
|
+
onChange: (props_0) => touchedFieldsRef.current.has(name) ? validate(props_0) : void 0
|
|
198
|
+
};
|
|
199
|
+
fieldValidators.set(name, validators);
|
|
200
|
+
return validators;
|
|
201
|
+
};
|
|
202
|
+
uiForm.notifyBlur = (name_0) => {
|
|
203
|
+
touchedFieldsRef.current.add(name_0);
|
|
204
|
+
for (const listener of blurListenersRef.current) listener(name_0);
|
|
205
|
+
};
|
|
206
|
+
uiForm.parseValues = (values) => zodSchema ? zodSchema.parse(values) : values;
|
|
207
|
+
uiForm.reset = (...args) => {
|
|
208
|
+
touchedFieldsRef.current.clear();
|
|
209
|
+
if (args[0] !== void 0 && !args[1]?.keepDefaultValues) defaultValuesRef.current = args[0];
|
|
210
|
+
originalReset(...args);
|
|
211
|
+
notifyFormReset(uiForm);
|
|
212
|
+
};
|
|
213
|
+
uiForm.subscribeBlur = (listener_0) => {
|
|
214
|
+
blurListenersRef.current.add(listener_0);
|
|
215
|
+
return () => blurListenersRef.current.delete(listener_0);
|
|
216
|
+
};
|
|
217
|
+
uiForm.handleSubmit = (onValid, onInvalid) => async (event) => {
|
|
218
|
+
event?.preventDefault?.();
|
|
219
|
+
event?.stopPropagation?.();
|
|
220
|
+
submitHandlerRef.current = onValid;
|
|
221
|
+
submitErrorHandlerRef.current = onInvalid;
|
|
222
|
+
if (form.state.errorMap.onMount) {
|
|
223
|
+
form.setErrorMap({ onMount: void 0 });
|
|
224
|
+
form.validateSync("submit");
|
|
225
|
+
}
|
|
226
|
+
await originalHandleSubmit();
|
|
227
|
+
};
|
|
228
|
+
useEffect(() => {
|
|
229
|
+
let active = true;
|
|
230
|
+
const revision = getFormResetVersion(form);
|
|
231
|
+
const valuesAtLoad = structuredClone(form.state.values);
|
|
232
|
+
if (typeof initialDefaultValues === "function") initialDefaultValues().then((values_0) => {
|
|
233
|
+
if (!active || revision !== getFormResetVersion(form)) return;
|
|
234
|
+
const edits = getChangedAutosaveFields(form.state.values, valuesAtLoad);
|
|
235
|
+
form.reset(values_0);
|
|
236
|
+
for (const [path, value_4] of edits) {
|
|
237
|
+
if (!path) continue;
|
|
238
|
+
const name_1 = path;
|
|
239
|
+
form.setFieldValue(name_1, value_4);
|
|
240
|
+
}
|
|
241
|
+
}).catch((error) => logger.warn("Unable to load form defaults", error));
|
|
242
|
+
return () => {
|
|
243
|
+
active = false;
|
|
244
|
+
};
|
|
245
|
+
}, [form, initialDefaultValues]);
|
|
246
|
+
useLayoutEffect(() => {
|
|
247
|
+
if (disabledStore.state !== disabled) disabledStore.setState(() => disabled);
|
|
248
|
+
}, [disabled, disabledStore]);
|
|
249
|
+
return uiForm;
|
|
250
|
+
}
|
|
251
|
+
const useFormValue = (form, selector) => {
|
|
252
|
+
const $ = c(2);
|
|
253
|
+
let t0;
|
|
254
|
+
if ($[0] !== selector) {
|
|
255
|
+
t0 = (state) => selector(state.values);
|
|
256
|
+
$[0] = selector;
|
|
257
|
+
$[1] = t0;
|
|
258
|
+
} else t0 = $[1];
|
|
259
|
+
return useStore(form.store, t0);
|
|
260
|
+
};
|
|
261
|
+
const useFormState = (form, selector) => {
|
|
262
|
+
return useStore(form.store, selector);
|
|
263
|
+
};
|
|
264
|
+
const getSchemaAtPath = (rootSchema, path) => {
|
|
265
|
+
let schema = rootSchema;
|
|
266
|
+
for (const segment of parsePath(path)) {
|
|
267
|
+
while (schema?.unwrap && !schema.shape && !schema.element && !schema.items) schema = schema.unwrap();
|
|
268
|
+
schema = typeof segment === "number" ? schema?.element ?? schema?.items?.[segment] : schema?.shape?.[segment];
|
|
269
|
+
if (!schema) return;
|
|
270
|
+
}
|
|
271
|
+
return schema;
|
|
272
|
+
};
|
|
273
|
+
const INVALID_ON_MOUNT = "invalid";
|
|
274
|
+
/**
|
|
275
|
+
* A changed field clears its own submit error, but the schema's errors below it (`range.start`) have no field to
|
|
276
|
+
* clear them, so they would keep showing and fail the next submit before the schema runs again.
|
|
277
|
+
*/
|
|
278
|
+
const clearNestedSubmitErrors = (form, name) => {
|
|
279
|
+
for (const [path, meta] of Object.entries(form.state.fieldMeta)) {
|
|
280
|
+
if (!path.startsWith(`${name}.`) && !path.startsWith(`${name}[`)) continue;
|
|
281
|
+
if (!meta?.errorMap.onSubmit || meta.errorSourceMap.onSubmit !== "form") continue;
|
|
282
|
+
form.setFieldMeta(path, (prev) => ({
|
|
283
|
+
...prev,
|
|
284
|
+
errorMap: {
|
|
285
|
+
...prev.errorMap,
|
|
286
|
+
onSubmit: void 0
|
|
287
|
+
}
|
|
288
|
+
}));
|
|
289
|
+
}
|
|
290
|
+
};
|
|
291
|
+
const getFieldErrors = (fieldMeta) => {
|
|
292
|
+
const errors = {};
|
|
293
|
+
for (const [path, meta] of Object.entries(fieldMeta)) for (const error of meta?.errors ?? []) {
|
|
294
|
+
const message = typeof error === "string" ? error : error && typeof error === "object" && "message" in error ? String(error.message) : void 0;
|
|
295
|
+
if (message) {
|
|
296
|
+
errors[path] = message;
|
|
297
|
+
break;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
return errors;
|
|
301
|
+
};
|
|
302
|
+
const parsePath = (path) => path.replaceAll("[", ".").replaceAll("]", "").split(".").filter(Boolean).map((segment) => /^\d+$/.test(segment) ? Number(segment) : segment);
|
|
303
|
+
const pathToString = (path) => path.reduce((result, segment) => typeof segment === "number" ? `${result}[${segment}]` : result ? `${result}.${String(segment)}` : String(segment), "");
|
|
304
|
+
//#endregion
|
|
305
|
+
//#region src/hooks/useFormAutosave.ts
|
|
306
|
+
const getResetTimeoutErrorMessage = (resetTimeout) => `Form Reset Timeout (${resetTimeout}ms) - Action Required
|
|
307
|
+
Problem: Form values weren't reset after submission.
|
|
308
|
+
|
|
309
|
+
Likely causes:
|
|
310
|
+
• Missing variables in reset dependency array
|
|
311
|
+
• Reset dependencies not updating after form save
|
|
312
|
+
• Async operations blocking timely reset
|
|
313
|
+
|
|
314
|
+
Solutions:
|
|
315
|
+
1. Ensure reset dependencies include all relevant state variables
|
|
316
|
+
2. Confirm your submission handler updates state properly (check query invalidation)
|
|
317
|
+
3. For slower operations, consider increasing the timeout threshold`;
|
|
318
|
+
/** Autosave schemas must produce objects preserving every raw field path, including optional fields. */
|
|
319
|
+
function useFormAutosave({ autosaveDelay, enableAutosave, autosaveOn = "change", normalizeAutosaveData, onAutosave, getResetValues, resetDeps, resetTimeout = 5e3, ...props }) {
|
|
320
|
+
const initialValues = getResetValues();
|
|
321
|
+
const form = useForm$1(...[{
|
|
322
|
+
...props,
|
|
323
|
+
defaultValues: typeof initialValues === "function" ? void 0 : initialValues
|
|
324
|
+
}]);
|
|
325
|
+
const serverBaselineRef = useRef(structuredClone(form.state.values));
|
|
326
|
+
const pendingRefreshesRef = useRef([]);
|
|
327
|
+
const resetFormValuesTimeoutRef = useRef(void 0);
|
|
328
|
+
useEffect(() => {
|
|
329
|
+
const clearRefreshes = () => {
|
|
330
|
+
pendingRefreshesRef.current = [];
|
|
331
|
+
if (resetFormValuesTimeoutRef.current) clearTimeout(resetFormValuesTimeoutRef.current);
|
|
332
|
+
};
|
|
333
|
+
const unsubscribe = subscribeFormReset(form, (refresh) => {
|
|
334
|
+
if (!refresh) {
|
|
335
|
+
serverBaselineRef.current = structuredClone(form.state.values);
|
|
336
|
+
clearRefreshes();
|
|
337
|
+
}
|
|
338
|
+
});
|
|
339
|
+
return () => {
|
|
340
|
+
unsubscribe();
|
|
341
|
+
clearRefreshes();
|
|
342
|
+
};
|
|
343
|
+
}, [form]);
|
|
344
|
+
useEffect(() => {
|
|
345
|
+
const resetValues = getResetValues();
|
|
346
|
+
if (resetValues === void 0) return;
|
|
347
|
+
let active = true;
|
|
348
|
+
const revision = getFormResetVersion(form);
|
|
349
|
+
const resetFormValues = async () => {
|
|
350
|
+
let values;
|
|
351
|
+
if (ObjectUtils.isFunction(resetValues)) values = await resetValues();
|
|
352
|
+
else values = resetValues;
|
|
353
|
+
if (!active || revision !== getFormResetVersion(form)) return;
|
|
354
|
+
const refreshedIndex = Math.max(0, pendingRefreshesRef.current.findLastIndex((pending) => pending.completed));
|
|
355
|
+
const submitted = pendingRefreshesRef.current[refreshedIndex];
|
|
356
|
+
pendingRefreshesRef.current.splice(0, refreshedIndex + 1);
|
|
357
|
+
const edits = getChangedAutosaveFields(form.state.values, submitted?.values ?? serverBaselineRef.current);
|
|
358
|
+
serverBaselineRef.current = structuredClone(values);
|
|
359
|
+
for (const pending_0 of pendingRefreshesRef.current) {
|
|
360
|
+
pending_0.values = structuredClone(values);
|
|
361
|
+
for (const [path, value] of pending_0.fields) pending_0.values = setBy(pending_0.values, path, value);
|
|
362
|
+
}
|
|
363
|
+
const applyRefresh = () => {
|
|
364
|
+
form.reset(values);
|
|
365
|
+
for (const [path_0, value_0] of edits) {
|
|
366
|
+
const name = path_0;
|
|
367
|
+
form.setFieldValue(name, value_0);
|
|
368
|
+
}
|
|
369
|
+
};
|
|
370
|
+
refreshAutosaveForm(form, values, applyRefresh, submitted?.fields);
|
|
371
|
+
if (pendingRefreshesRef.current.length === 0 && resetFormValuesTimeoutRef.current) clearTimeout(resetFormValuesTimeoutRef.current);
|
|
372
|
+
};
|
|
373
|
+
resetFormValues().catch((error) => logger.warn("Unable to refresh autosave form", error));
|
|
374
|
+
return () => {
|
|
375
|
+
active = false;
|
|
376
|
+
};
|
|
377
|
+
}, [...resetDeps]);
|
|
378
|
+
const prepareForSaveReset = () => {
|
|
379
|
+
if (resetFormValuesTimeoutRef.current) clearTimeout(resetFormValuesTimeoutRef.current);
|
|
380
|
+
resetFormValuesTimeoutRef.current = setTimeout(() => {
|
|
381
|
+
if (pendingRefreshesRef.current.length > 0) logger.warn(getResetTimeoutErrorMessage(resetTimeout));
|
|
382
|
+
}, resetTimeout);
|
|
383
|
+
};
|
|
384
|
+
useAutosave({
|
|
385
|
+
form,
|
|
386
|
+
delay: autosaveDelay,
|
|
387
|
+
enabled: enableAutosave,
|
|
388
|
+
trigger: autosaveOn,
|
|
389
|
+
onSave: useCallback(async (data) => {
|
|
390
|
+
const normalizedData = normalizeAutosaveData ? normalizeAutosaveData(data) : data;
|
|
391
|
+
if (!normalizedData || ObjectUtils.isEmpty(normalizedData)) return;
|
|
392
|
+
const values_0 = structuredClone(form.state.values);
|
|
393
|
+
const submitted_0 = {
|
|
394
|
+
values: values_0,
|
|
395
|
+
fields: getSubmittedAutosaveFields(normalizedData, values_0),
|
|
396
|
+
completed: false
|
|
397
|
+
};
|
|
398
|
+
pendingRefreshesRef.current.push(submitted_0);
|
|
399
|
+
prepareForSaveReset();
|
|
400
|
+
try {
|
|
401
|
+
const response = await onAutosave(normalizedData);
|
|
402
|
+
submitted_0.completed = true;
|
|
403
|
+
pendingRefreshesRef.current = pendingRefreshesRef.current.filter((pending_2) => !pending_2.completed || pending_2 === submitted_0);
|
|
404
|
+
return response;
|
|
405
|
+
} catch (error_0) {
|
|
406
|
+
pendingRefreshesRef.current = pendingRefreshesRef.current.filter((pending_1) => pending_1 !== submitted_0);
|
|
407
|
+
if (pendingRefreshesRef.current.length === 0 && resetFormValuesTimeoutRef.current) clearTimeout(resetFormValuesTimeoutRef.current);
|
|
408
|
+
throw error_0;
|
|
409
|
+
}
|
|
410
|
+
}, [
|
|
411
|
+
normalizeAutosaveData,
|
|
412
|
+
onAutosave,
|
|
413
|
+
resetTimeout
|
|
414
|
+
])
|
|
415
|
+
});
|
|
416
|
+
return form;
|
|
417
|
+
}
|
|
418
|
+
//#endregion
|
|
419
|
+
export { useAutosave as a, useFormValue as i, useForm$1 as n, useFormState as r, useFormAutosave as t };
|