@eifi1/ui-kit 0.11.0 → 0.13.0
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 +59 -34
- package/dist/chart.d.ts +3 -1
- package/dist/chart.js +2 -0
- package/dist/chart.js.map +1 -1
- package/dist/components/account-settings-labels.d.ts +105 -0
- package/dist/components/account-settings-labels.js +81 -0
- package/dist/components/account-settings-labels.js.map +1 -0
- package/dist/components/account-settings.d.ts +36 -52
- package/dist/components/account-settings.js +44 -8
- package/dist/components/account-settings.js.map +1 -1
- package/dist/components/amount-input.d.ts +40 -4
- package/dist/components/amount-input.js +50 -12
- package/dist/components/amount-input.js.map +1 -1
- package/dist/components/authed-image.d.ts +68 -0
- package/dist/components/authed-image.js +117 -0
- package/dist/components/authed-image.js.map +1 -0
- package/dist/components/breadcrumbs.d.ts +2 -1
- package/dist/components/breadcrumbs.js +5 -2
- package/dist/components/breadcrumbs.js.map +1 -1
- package/dist/components/bulk-action-bar.d.ts +10 -2
- package/dist/components/bulk-action-bar.js.map +1 -1
- package/dist/components/button-group.d.ts +51 -2
- package/dist/components/button-group.js +5 -1
- package/dist/components/button-group.js.map +1 -1
- package/dist/components/calculator.d.ts +15 -4
- package/dist/components/calendar-heatmap.d.ts +41 -3
- package/dist/components/calendar-heatmap.js +48 -7
- package/dist/components/calendar-heatmap.js.map +1 -1
- package/dist/components/chart.js +14 -8
- package/dist/components/chart.js.map +1 -1
- package/dist/components/chip.d.ts +2 -1
- package/dist/components/chip.js +26 -18
- package/dist/components/chip.js.map +1 -1
- package/dist/components/choice-card.d.ts +35 -3
- package/dist/components/choice-card.js +83 -25
- package/dist/components/choice-card.js.map +1 -1
- package/dist/components/combobox-core.d.ts +3 -1
- package/dist/components/combobox-core.js +18 -5
- package/dist/components/combobox-core.js.map +1 -1
- package/dist/components/combobox.d.ts +2 -2
- package/dist/components/combobox.js +31 -9
- package/dist/components/combobox.js.map +1 -1
- package/dist/components/copy-button.d.ts +51 -70
- package/dist/components/copy-button.js +1 -1
- package/dist/components/copy-button.js.map +1 -1
- package/dist/components/data-table-cells.d.ts +63 -0
- package/dist/components/data-table-cells.js +64 -0
- package/dist/components/data-table-cells.js.map +1 -0
- package/dist/components/data-table-filter-popover.d.ts +1 -1
- package/dist/components/data-table-filter-popover.js +8 -1
- package/dist/components/data-table-filter-popover.js.map +1 -1
- package/dist/components/data-table-filters.d.ts +1 -1
- package/dist/components/data-table-filters.js +31 -1
- package/dist/components/data-table-filters.js.map +1 -1
- package/dist/components/data-table-labels.d.ts +13 -0
- package/dist/components/data-table-labels.js +8 -1
- package/dist/components/data-table-labels.js.map +1 -1
- package/dist/components/data-table.d.ts +1 -1
- package/dist/components/data-table.js +125 -27
- package/dist/components/data-table.js.map +1 -1
- package/dist/components/date-picker.d.ts +3 -1
- package/dist/components/date-picker.js +15 -2
- package/dist/components/date-picker.js.map +1 -1
- package/dist/components/description-list.d.ts +23 -3
- package/dist/components/description-list.js +23 -3
- package/dist/components/description-list.js.map +1 -1
- package/dist/components/dialog-frame.d.ts +1 -0
- package/dist/components/entity-combobox.d.ts +1 -1
- package/dist/components/entity-combobox.js +40 -20
- package/dist/components/entity-combobox.js.map +1 -1
- package/dist/components/error-boundary.d.ts +281 -0
- package/dist/components/error-boundary.js +302 -0
- package/dist/components/error-boundary.js.map +1 -0
- package/dist/components/field-sync.js +90 -83
- package/dist/components/field-sync.js.map +1 -1
- package/dist/components/field.d.ts +30 -4
- package/dist/components/field.js +40 -17
- package/dist/components/field.js.map +1 -1
- package/dist/components/file-button.d.ts +50 -208
- package/dist/components/file-dropzone.d.ts +49 -2
- package/dist/components/floating-panel.d.ts +13 -4
- package/dist/components/floating-panel.js +7 -3
- package/dist/components/floating-panel.js.map +1 -1
- package/dist/components/form-actions.d.ts +53 -0
- package/dist/components/form-actions.js +98 -0
- package/dist/components/form-actions.js.map +1 -0
- package/dist/components/full-bleed-dialog.js +4 -0
- package/dist/components/full-bleed-dialog.js.map +1 -1
- package/dist/components/hover-menu.js +64 -56
- package/dist/components/hover-menu.js.map +1 -1
- package/dist/components/image-grid.d.ts +67 -0
- package/dist/components/image-grid.js +112 -0
- package/dist/components/image-grid.js.map +1 -0
- package/dist/components/lightbox.d.ts +104 -0
- package/dist/components/lightbox.js +229 -0
- package/dist/components/lightbox.js.map +1 -0
- package/dist/components/line-items.d.ts +114 -0
- package/dist/components/line-items.js +238 -0
- package/dist/components/line-items.js.map +1 -0
- package/dist/components/list.d.ts +37 -4
- package/dist/components/list.js +35 -14
- package/dist/components/list.js.map +1 -1
- package/dist/components/loading-state.d.ts +24 -0
- package/dist/components/loading-state.js +32 -0
- package/dist/components/loading-state.js.map +1 -0
- package/dist/components/menu-item.d.ts +2 -1
- package/dist/components/menu-item.js +5 -1
- package/dist/components/menu-item.js.map +1 -1
- package/dist/components/mini-calendar.d.ts +13 -1
- package/dist/components/mini-calendar.js +46 -2
- package/dist/components/mini-calendar.js.map +1 -1
- package/dist/components/modal.d.ts +20 -1
- package/dist/components/modal.js +26 -2
- package/dist/components/modal.js.map +1 -1
- package/dist/components/month-picker.d.ts +21 -1
- package/dist/components/month-picker.js +139 -26
- package/dist/components/month-picker.js.map +1 -1
- package/dist/components/multi-entity-combobox.d.ts +1 -1
- package/dist/components/multi-entity-combobox.js +42 -20
- package/dist/components/multi-entity-combobox.js.map +1 -1
- package/dist/components/nav-pills.d.ts +2 -1
- package/dist/components/nav-pills.js +5 -1
- package/dist/components/nav-pills.js.map +1 -1
- package/dist/components/number-field.d.ts +24 -5
- package/dist/components/number-field.js +5 -7
- package/dist/components/number-field.js.map +1 -1
- package/dist/components/number-input.d.ts +25 -5
- package/dist/components/number-input.js +7 -1
- package/dist/components/number-input.js.map +1 -1
- package/dist/components/numpad-sheet.d.ts +20 -5
- package/dist/components/numpad-sheet.js +3 -2
- package/dist/components/numpad-sheet.js.map +1 -1
- package/dist/components/page-header.d.ts +35 -6
- package/dist/components/page-header.js +7 -1
- package/dist/components/page-header.js.map +1 -1
- package/dist/components/passkeys-setting.d.ts +67 -0
- package/dist/components/passkeys-setting.js +214 -0
- package/dist/components/passkeys-setting.js.map +1 -0
- package/dist/components/picker-sheet.js +5 -1
- package/dist/components/picker-sheet.js.map +1 -1
- package/dist/components/pie-chart-labels.d.ts +20 -0
- package/dist/components/pie-chart-labels.js +12 -0
- package/dist/components/pie-chart-labels.js.map +1 -0
- package/dist/components/pie-chart.d.ts +101 -0
- package/dist/components/pie-chart.js +283 -0
- package/dist/components/pie-chart.js.map +1 -0
- package/dist/components/popover.js +3 -0
- package/dist/components/popover.js.map +1 -1
- package/dist/components/progress-bar.d.ts +44 -3
- package/dist/components/progress-bar.js +58 -22
- package/dist/components/progress-bar.js.map +1 -1
- package/dist/components/qr-code.d.ts +34 -0
- package/dist/components/qr-code.js +57 -0
- package/dist/components/qr-code.js.map +1 -0
- package/dist/components/search-field.d.ts +15 -3
- package/dist/components/search-field.js +5 -1
- package/dist/components/search-field.js.map +1 -1
- package/dist/components/settings-fields.d.ts +49 -1
- package/dist/components/signed-amount.d.ts +122 -0
- package/dist/components/signed-amount.js +152 -0
- package/dist/components/signed-amount.js.map +1 -0
- package/dist/components/skeleton.d.ts +10 -3
- package/dist/components/skeleton.js +12 -2
- package/dist/components/skeleton.js.map +1 -1
- package/dist/components/stat-tile.d.ts +2 -1
- package/dist/components/stat-tile.js +6 -3
- package/dist/components/stat-tile.js.map +1 -1
- package/dist/components/swipeable-row.js +4 -3
- package/dist/components/swipeable-row.js.map +1 -1
- package/dist/components/table.d.ts +39 -5
- package/dist/components/table.js +45 -11
- package/dist/components/table.js.map +1 -1
- package/dist/components/text-link.d.ts +238 -0
- package/dist/components/text-link.js +144 -0
- package/dist/components/text-link.js.map +1 -0
- package/dist/components/text.d.ts +26 -2
- package/dist/components/text.js +16 -2
- package/dist/components/text.js.map +1 -1
- package/dist/components/time-input.d.ts +49 -1
- package/dist/components/toggle-group.d.ts +35 -0
- package/dist/components/toggle-group.js +43 -14
- package/dist/components/toggle-group.js.map +1 -1
- package/dist/components/toggle-legend.d.ts +53 -3
- package/dist/components/toggle-legend.js +54 -1
- package/dist/components/toggle-legend.js.map +1 -1
- package/dist/components/tooltip.d.ts +51 -1
- package/dist/components/tooltip.js +59 -35
- package/dist/components/tooltip.js.map +1 -1
- package/dist/components/ui.d.ts +51 -779
- package/dist/components/ui.js +364 -34
- package/dist/components/ui.js.map +1 -1
- package/dist/components/use-table-state.d.ts +3 -52
- package/dist/components/use-table-state.js +128 -30
- package/dist/components/use-table-state.js.map +1 -1
- package/dist/{data-table-filters-Dh9uF_S-.d.ts → data-table-Drun8Fk9.d.ts} +305 -61
- package/dist/data-table.d.ts +2 -1
- package/dist/data-table.js +5 -1
- package/dist/data-table.js.map +1 -1
- package/dist/feedback/feedback-attachment.js +4 -6
- package/dist/feedback/feedback-attachment.js.map +1 -1
- package/dist/feedback/feedback-dialog.d.ts +26 -3
- package/dist/feedback/feedback-dialog.js +21 -5
- package/dist/feedback/feedback-dialog.js.map +1 -1
- package/dist/feedback/feedback-inbox.js +86 -75
- package/dist/feedback/feedback-inbox.js.map +1 -1
- package/dist/feedback/feedback-thread.d.ts +173 -0
- package/dist/feedback/feedback-thread.js +264 -0
- package/dist/feedback/feedback-thread.js.map +1 -0
- package/dist/feedback.d.ts +2 -1
- package/dist/feedback.js +1 -0
- package/dist/feedback.js.map +1 -1
- package/dist/hooks/use-authed-src.d.ts +71 -0
- package/dist/hooks/use-authed-src.js +63 -0
- package/dist/hooks/use-authed-src.js.map +1 -0
- package/dist/hooks/use-file-drop.d.ts +49 -2
- package/dist/hooks/use-hotkey.d.ts +59 -0
- package/dist/hooks/use-hotkey.js +105 -0
- package/dist/hooks/use-hotkey.js.map +1 -0
- package/dist/hooks/use-search-param-state.d.ts +83 -0
- package/dist/hooks/use-search-param-state.js +94 -0
- package/dist/hooks/use-search-param-state.js.map +1 -0
- package/dist/i18n/defaults.d.ts +15 -4
- package/dist/i18n/defaults.js +31 -1
- package/dist/i18n/defaults.js.map +1 -1
- package/dist/i18n/kit-labels.d.ts +46 -312
- package/dist/i18n/kit-labels.js +20 -5
- package/dist/i18n/kit-labels.js.map +1 -1
- package/dist/i18n/locales/de-CH-informal.d.ts +15 -4
- package/dist/i18n/locales/de-CH.d.ts +15 -4
- package/dist/i18n/locales/de-informal.d.ts +15 -4
- package/dist/i18n/locales/de.d.ts +15 -4
- package/dist/i18n/locales/de.js +164 -3
- package/dist/i18n/locales/de.js.map +1 -1
- package/dist/i18n/locales/es.d.ts +15 -4
- package/dist/i18n/locales/es.js +161 -3
- package/dist/i18n/locales/es.js.map +1 -1
- package/dist/i18n/locales/fr.d.ts +15 -4
- package/dist/i18n/locales/fr.js +161 -3
- package/dist/i18n/locales/fr.js.map +1 -1
- package/dist/i18n/locales/hu.d.ts +15 -4
- package/dist/i18n/locales/hu.js +161 -3
- package/dist/i18n/locales/hu.js.map +1 -1
- package/dist/i18n/locales/it.d.ts +15 -4
- package/dist/i18n/locales/it.js +161 -3
- package/dist/i18n/locales/it.js.map +1 -1
- package/dist/i18n/locales/zh.d.ts +15 -4
- package/dist/i18n/locales/zh.js +161 -3
- package/dist/i18n/locales/zh.js.map +1 -1
- package/dist/index.d.ts +39 -19
- package/dist/index.js +40 -1
- package/dist/index.js.map +1 -1
- package/dist/kit-labels-Mz8zZHIF.d.ts +1744 -0
- package/dist/lib/format.d.ts +162 -0
- package/dist/lib/format.js +151 -0
- package/dist/lib/format.js.map +1 -0
- package/dist/lib/qr-encode.d.ts +44 -0
- package/dist/lib/qr-encode.js +338 -0
- package/dist/lib/qr-encode.js.map +1 -0
- package/dist/rhf/fields.d.ts +283 -0
- package/dist/rhf/fields.js +631 -0
- package/dist/rhf/fields.js.map +1 -0
- package/dist/rhf/form.d.ts +49 -1
- package/dist/rhf/line-items.d.ts +31 -0
- package/dist/rhf/line-items.js +59 -0
- package/dist/rhf/line-items.js.map +1 -0
- package/dist/rhf.d.ts +61 -1
- package/dist/rhf.js +2 -0
- package/dist/rhf.js.map +1 -1
- package/dist/search/command-palette.js +20 -14
- package/dist/search/command-palette.js.map +1 -1
- package/dist/shell/app-shell.d.ts +99 -2
- package/dist/shell/app-shell.js +120 -57
- package/dist/shell/app-shell.js.map +1 -1
- package/dist/shell/auth-layout.d.ts +74 -0
- package/dist/shell/auth-layout.js +97 -0
- package/dist/shell/auth-layout.js.map +1 -0
- package/dist/shell/top-bar-brand.d.ts +81 -0
- package/dist/shell/top-bar-brand.js +47 -0
- package/dist/shell/top-bar-brand.js.map +1 -0
- package/dist/shell/topbar-action-menu.d.ts +21 -4
- package/dist/shell/topbar-action-menu.js +18 -2
- package/dist/shell/topbar-action-menu.js.map +1 -1
- package/dist/shell.d.ts +56 -1
- package/dist/shell.js +2 -0
- package/dist/shell.js.map +1 -1
- package/dist/tour/tour.js +10 -4
- package/dist/tour/tour.js.map +1 -1
- package/dist/wizard/stepper-nav.d.ts +48 -1
- package/dist/wizard/use-wizard.js +4 -2
- package/dist/wizard/use-wizard.js.map +1 -1
- package/dist/wizard/wizard-context.d.ts +24 -1
- package/dist/wizard/wizard-context.js +19 -2
- package/dist/wizard/wizard-context.js.map +1 -1
- package/dist/wizard/wizard-step.d.ts +30 -5
- package/dist/wizard/wizard-step.js +34 -3
- package/dist/wizard/wizard-step.js.map +1 -1
- package/dist/wizard.d.ts +50 -3
- package/package.json +6 -6
- package/src/chart.ts +4 -0
- package/src/components/account-settings-labels.ts +190 -0
- package/src/components/account-settings.tsx +110 -63
- package/src/components/amount-input.tsx +109 -10
- package/src/components/authed-image.tsx +190 -0
- package/src/components/breadcrumbs.tsx +8 -2
- package/src/components/bulk-action-bar.tsx +16 -3
- package/src/components/button-group.tsx +7 -2
- package/src/components/calendar-heatmap.tsx +105 -10
- package/src/components/chart.tsx +19 -8
- package/src/components/chip.tsx +14 -4
- package/src/components/choice-card.tsx +136 -25
- package/src/components/combobox-core.tsx +33 -9
- package/src/components/combobox.tsx +33 -9
- package/src/components/copy-button.tsx +3 -2
- package/src/components/data-table-cells.tsx +119 -0
- package/src/components/data-table-filter-popover.tsx +13 -5
- package/src/components/data-table-filters.ts +77 -0
- package/src/components/data-table-labels.ts +23 -0
- package/src/components/data-table.tsx +230 -13
- package/src/components/date-picker.tsx +19 -3
- package/src/components/description-list.tsx +52 -3
- package/src/components/entity-combobox.tsx +25 -7
- package/src/components/error-boundary.tsx +640 -0
- package/src/components/field-sync.tsx +48 -40
- package/src/components/field.tsx +56 -5
- package/src/components/floating-panel.tsx +20 -7
- package/src/components/form-actions.tsx +191 -0
- package/src/components/full-bleed-dialog.tsx +4 -0
- package/src/components/hover-menu.tsx +26 -17
- package/src/components/image-grid.tsx +181 -0
- package/src/components/lightbox.tsx +374 -0
- package/src/components/line-items.tsx +385 -0
- package/src/components/list.tsx +82 -19
- package/src/components/loading-state.tsx +47 -0
- package/src/components/menu-item.tsx +7 -2
- package/src/components/mini-calendar.tsx +72 -3
- package/src/components/modal.tsx +65 -3
- package/src/components/month-picker.tsx +181 -26
- package/src/components/multi-entity-combobox.tsx +27 -7
- package/src/components/nav-pills.tsx +8 -1
- package/src/components/number-field.tsx +15 -10
- package/src/components/number-input.tsx +17 -1
- package/src/components/numpad-sheet.tsx +6 -1
- package/src/components/page-header.tsx +42 -5
- package/src/components/passkeys-setting.tsx +331 -0
- package/src/components/picker-sheet.tsx +10 -1
- package/src/components/pie-chart-labels.ts +32 -0
- package/src/components/pie-chart.tsx +479 -0
- package/src/components/popover.tsx +3 -0
- package/src/components/progress-bar.tsx +129 -19
- package/src/components/qr-code.tsx +83 -0
- package/src/components/search-field.tsx +20 -4
- package/src/components/signed-amount.tsx +295 -0
- package/src/components/skeleton.tsx +21 -3
- package/src/components/stat-tile.tsx +11 -3
- package/src/components/swipeable-row.tsx +7 -7
- package/src/components/table.tsx +102 -13
- package/src/components/text-link.tsx +356 -0
- package/src/components/text.tsx +46 -2
- package/src/components/toggle-group.tsx +93 -20
- package/src/components/toggle-legend.tsx +108 -2
- package/src/components/tooltip.tsx +79 -8
- package/src/components/ui.tsx +707 -49
- package/src/components/use-table-state.ts +265 -33
- package/src/data-table.ts +10 -0
- package/src/feedback/feedback-attachment.tsx +10 -7
- package/src/feedback/feedback-dialog.tsx +49 -7
- package/src/feedback/feedback-inbox.tsx +7 -0
- package/src/feedback/feedback-thread.tsx +510 -0
- package/src/feedback.ts +1 -0
- package/src/hooks/use-authed-src.ts +161 -0
- package/src/hooks/use-hotkey.ts +172 -0
- package/src/hooks/use-search-param-state.ts +187 -0
- package/src/i18n/defaults.ts +30 -0
- package/src/i18n/kit-labels.tsx +118 -8
- package/src/i18n/locales/de.ts +161 -0
- package/src/i18n/locales/es.ts +158 -0
- package/src/i18n/locales/fr.ts +161 -0
- package/src/i18n/locales/hu.ts +159 -0
- package/src/i18n/locales/it.ts +159 -0
- package/src/i18n/locales/zh.ts +158 -0
- package/src/index.ts +59 -0
- package/src/lib/format.ts +348 -0
- package/src/lib/qr-encode.ts +420 -0
- package/src/rhf/fields.tsx +1135 -0
- package/src/rhf/line-items.tsx +130 -0
- package/src/rhf.ts +6 -0
- package/src/search/command-palette.tsx +29 -19
- package/src/shell/app-shell.tsx +153 -3
- package/src/shell/auth-layout.tsx +190 -0
- package/src/shell/top-bar-brand.tsx +76 -0
- package/src/shell/topbar-action-menu.tsx +32 -4
- package/src/shell.ts +2 -0
- package/src/tour/tour.tsx +16 -5
- package/src/wizard/use-wizard.ts +8 -4
- package/src/wizard/wizard-context.tsx +41 -1
- package/src/wizard/wizard-step.tsx +75 -6
- package/tokens.css +12 -0
|
@@ -1,54 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import 'react';
|
|
2
|
+
import './data-table-sort.js';
|
|
3
|
+
export { z as DEFAULT_PERSIST_PREFIX, T as TableUrlState, g as TableUrlStateProps, h as TableUrlSync, U as UseTableUrlStateOptions, i as UseTableUrlStateReturn, r as readTableUrlState, A as useTableState, w as useTableUrlState } from '../data-table-Drun8Fk9.js';
|
|
4
4
|
import './swipeable-row.js';
|
|
5
5
|
import './data-table-labels.js';
|
|
6
|
-
|
|
7
|
-
declare const DEFAULT_PERSIST_PREFIX = "hbui-table:";
|
|
8
|
-
/**
|
|
9
|
-
* Where a table's view lives: what it is sorted and filtered by, which page, how wide
|
|
10
|
-
* the columns are and which are hidden — plus the two places that outlives a render.
|
|
11
|
-
*
|
|
12
|
-
* Lifted out of `DataTable`, which was 984 lines and twenty hooks in one function. This
|
|
13
|
-
* is the part that is genuinely about STATE rather than about drawing, and the three
|
|
14
|
-
* rules it encodes are easy to lose among the markup:
|
|
15
|
-
*
|
|
16
|
-
* * **The URL is read once, on mount.** A shared or deep link populates the initial view;
|
|
17
|
-
* after that the state is local, or the browser's own history would fight the user's
|
|
18
|
-
* next click.
|
|
19
|
-
* * **Sorting and filtering are optionally CONTROLLED.** A server-driven table passes
|
|
20
|
-
* state and a callback and owns them; everything else is self-owned. That is the
|
|
21
|
-
* `sortsProp ?? internalSorts` pair, and it is why the setters are exposed separately.
|
|
22
|
-
* * **Persistence writes on every change, the URL only when asked.** `storageKey` is the
|
|
23
|
-
* per-table identity; `urlSync` is opt-in because only some tables want their view in
|
|
24
|
-
* a shareable address.
|
|
25
|
-
* * **A controlled filter or sort that changes sends the table back to page 1.** See
|
|
26
|
-
* the note at the reset below.
|
|
27
|
-
*/
|
|
28
|
-
declare function useTableState<T>({ columns, storageKey, storageKeyPrefix, urlSync, defaultPageSize, sortsProp, filtersProp, }: {
|
|
29
|
-
columns: DataTableColumn<T>[];
|
|
30
|
-
storageKey?: string;
|
|
31
|
-
storageKeyPrefix: string;
|
|
32
|
-
urlSync?: boolean;
|
|
33
|
-
defaultPageSize: number;
|
|
34
|
-
sortsProp?: SortState[];
|
|
35
|
-
filtersProp?: FilterState;
|
|
36
|
-
}): {
|
|
37
|
-
sorts: SortState[];
|
|
38
|
-
filters: FilterState;
|
|
39
|
-
setInternalSorts: react.Dispatch<react.SetStateAction<SortState[]>>;
|
|
40
|
-
setInternalFilters: react.Dispatch<react.SetStateAction<FilterState>>;
|
|
41
|
-
page: number;
|
|
42
|
-
setPage: react.Dispatch<react.SetStateAction<number>>;
|
|
43
|
-
pageSize: number;
|
|
44
|
-
setPageSize: react.Dispatch<react.SetStateAction<number>>;
|
|
45
|
-
widths: Record<string, number>;
|
|
46
|
-
setWidths: react.Dispatch<react.SetStateAction<Record<string, number>>>;
|
|
47
|
-
hiddenCols: Set<string>;
|
|
48
|
-
setHiddenCols: react.Dispatch<react.SetStateAction<Set<string>>>;
|
|
49
|
-
showSettings: boolean;
|
|
50
|
-
setShowSettings: react.Dispatch<react.SetStateAction<boolean>>;
|
|
51
|
-
headRefs: Map<string, HTMLTableCellElement>;
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
export { DEFAULT_PERSIST_PREFIX, useTableState };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useEffect, useMemo, useRef, useState } from "react";
|
|
3
|
-
import { useSearchParams } from "react-router";
|
|
3
|
+
import { useLocation, useSearchParams } from "react-router";
|
|
4
4
|
import { readStored, writeStored } from "../lib/safe-storage.js";
|
|
5
5
|
import {
|
|
6
6
|
decodeFilterValue,
|
|
@@ -28,80 +28,102 @@ const URL_FILTER_PREFIX = "f.";
|
|
|
28
28
|
const URL_SORT_KEY = "sort";
|
|
29
29
|
const URL_PAGE_KEY = "p";
|
|
30
30
|
const URL_PAGE_SIZE_KEY = "ps";
|
|
31
|
-
|
|
31
|
+
const URL_SEARCH_KEY = "q";
|
|
32
|
+
function urlKeys(prefix = "") {
|
|
33
|
+
return {
|
|
34
|
+
filter: prefix + URL_FILTER_PREFIX,
|
|
35
|
+
sort: prefix + URL_SORT_KEY,
|
|
36
|
+
page: prefix + URL_PAGE_KEY,
|
|
37
|
+
pageSize: prefix + URL_PAGE_SIZE_KEY,
|
|
38
|
+
search: prefix + URL_SEARCH_KEY
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function resolveTableUrlSync(urlSync) {
|
|
42
|
+
if (!urlSync) return { enabled: false, prefix: "" };
|
|
43
|
+
return { enabled: true, prefix: urlSync === true ? "" : urlSync.prefix ?? "" };
|
|
44
|
+
}
|
|
45
|
+
function readTableUrlState(sp, columns, prefix) {
|
|
46
|
+
const keys = urlKeys(prefix);
|
|
32
47
|
const out = {};
|
|
33
48
|
const filters = {};
|
|
34
49
|
for (const col of columns) {
|
|
35
50
|
const filter = resolveFilter(col);
|
|
36
51
|
if (!filter) continue;
|
|
37
|
-
const raw = sp.get(
|
|
52
|
+
const raw = sp.get(keys.filter + col.key);
|
|
38
53
|
if (raw == null) continue;
|
|
39
54
|
filters[col.key] = decodeFilterValue(filter, raw);
|
|
40
55
|
}
|
|
41
56
|
if (Object.keys(filters).length) out.filters = filters;
|
|
42
|
-
const sortRaw = sp.get(
|
|
57
|
+
const sortRaw = sp.get(keys.sort);
|
|
43
58
|
if (sortRaw) {
|
|
44
59
|
const decoded = decodeSorts(sortRaw, new Set(columns.map((c) => c.key)));
|
|
45
60
|
if (decoded.length) out.sorts = decoded;
|
|
46
61
|
}
|
|
47
|
-
const psRaw = sp.get(
|
|
62
|
+
const psRaw = sp.get(keys.pageSize);
|
|
48
63
|
if (psRaw === "all") out.pageSize = Infinity;
|
|
49
64
|
else if (psRaw && Number(psRaw) > 0) out.pageSize = Number(psRaw);
|
|
50
|
-
const pRaw = sp.get(
|
|
65
|
+
const pRaw = sp.get(keys.page);
|
|
51
66
|
if (pRaw && Number(pRaw) >= 1) out.page = Number(pRaw) - 1;
|
|
52
67
|
return out;
|
|
53
68
|
}
|
|
54
|
-
function urlSignature(columns, sorts, filters, pageSize, page, defaultPageSize) {
|
|
69
|
+
function urlSignature(columns, sorts, filters, pageSize, page, defaultPageSize, keys) {
|
|
55
70
|
const parts = [];
|
|
56
71
|
for (const col of columns) {
|
|
57
72
|
const state = filters[col.key];
|
|
58
73
|
if (!state || !isFilterActive(state)) continue;
|
|
59
74
|
const enc = encodeFilterValue(state);
|
|
60
|
-
if (enc != null) parts.push(`${
|
|
75
|
+
if (enc != null) parts.push(`${keys.filter}${col.key}=${enc}`);
|
|
61
76
|
}
|
|
62
|
-
parts.push(`${
|
|
77
|
+
parts.push(`${keys.sort}=${encodeSorts(sorts)}`);
|
|
63
78
|
parts.push(
|
|
64
|
-
`${
|
|
79
|
+
`${keys.pageSize}=${pageSize === Infinity ? "all" : pageSize === defaultPageSize ? "" : String(pageSize)}`
|
|
65
80
|
);
|
|
66
|
-
parts.push(`${
|
|
81
|
+
parts.push(`${keys.page}=${page > 0 ? String(page + 1) : ""}`);
|
|
67
82
|
return parts.join("&");
|
|
68
83
|
}
|
|
69
|
-
function writeUrlState(setSearchParams, columns, sorts, filters, pageSize, page, defaultPageSize) {
|
|
84
|
+
function writeUrlState(setSearchParams, columns, sorts, filters, pageSize, page, defaultPageSize, search, state, keys) {
|
|
70
85
|
setSearchParams(
|
|
71
86
|
(prev) => {
|
|
72
87
|
const next = new URLSearchParams(prev);
|
|
73
|
-
for (const col of columns) next.delete(
|
|
74
|
-
next.delete(
|
|
75
|
-
next.delete(
|
|
76
|
-
next.delete(
|
|
88
|
+
for (const col of columns) next.delete(keys.filter + col.key);
|
|
89
|
+
next.delete(keys.sort);
|
|
90
|
+
next.delete(keys.page);
|
|
91
|
+
next.delete(keys.pageSize);
|
|
92
|
+
if (search !== void 0) {
|
|
93
|
+
next.delete(keys.search);
|
|
94
|
+
if (search.trim()) next.set(keys.search, search);
|
|
95
|
+
}
|
|
77
96
|
for (const col of columns) {
|
|
78
|
-
const
|
|
79
|
-
if (!
|
|
80
|
-
const enc = encodeFilterValue(
|
|
81
|
-
if (enc != null) next.set(
|
|
97
|
+
const state2 = filters[col.key];
|
|
98
|
+
if (!state2 || !isFilterActive(state2)) continue;
|
|
99
|
+
const enc = encodeFilterValue(state2);
|
|
100
|
+
if (enc != null) next.set(keys.filter + col.key, enc);
|
|
82
101
|
}
|
|
83
102
|
const sortEnc = encodeSorts(sorts);
|
|
84
|
-
if (sortEnc) next.set(
|
|
85
|
-
if (pageSize === Infinity) next.set(
|
|
86
|
-
else if (pageSize !== defaultPageSize) next.set(
|
|
87
|
-
if (page > 0) next.set(
|
|
103
|
+
if (sortEnc) next.set(keys.sort, sortEnc);
|
|
104
|
+
if (pageSize === Infinity) next.set(keys.pageSize, "all");
|
|
105
|
+
else if (pageSize !== defaultPageSize) next.set(keys.pageSize, String(pageSize));
|
|
106
|
+
if (page > 0) next.set(keys.page, String(page + 1));
|
|
88
107
|
return next;
|
|
89
108
|
},
|
|
90
|
-
{ replace: true }
|
|
109
|
+
{ replace: true, state }
|
|
91
110
|
);
|
|
92
111
|
}
|
|
93
112
|
function useTableState({
|
|
94
113
|
columns,
|
|
95
114
|
storageKey,
|
|
96
115
|
storageKeyPrefix,
|
|
97
|
-
urlSync,
|
|
116
|
+
urlSync: urlSyncOption,
|
|
98
117
|
defaultPageSize,
|
|
99
118
|
sortsProp,
|
|
100
119
|
filtersProp
|
|
101
120
|
}) {
|
|
121
|
+
const { enabled: urlSync, prefix: urlPrefix } = resolveTableUrlSync(urlSyncOption);
|
|
122
|
+
const keys = useMemo(() => urlKeys(urlPrefix), [urlPrefix]);
|
|
102
123
|
const [searchParams, setSearchParams] = useSearchParams();
|
|
124
|
+
const location = useLocation();
|
|
103
125
|
const [urlInitial] = useState(
|
|
104
|
-
() => urlSync ?
|
|
126
|
+
() => urlSync ? readTableUrlState(searchParams, columns, urlPrefix) : {}
|
|
105
127
|
);
|
|
106
128
|
const initial = useMemo(
|
|
107
129
|
() => loadPersisted(storageKey, storageKeyPrefix),
|
|
@@ -149,12 +171,12 @@ function useTableState({
|
|
|
149
171
|
writeStored(target, persisted);
|
|
150
172
|
}, [storageKey, storageKeyPrefix, persisted]);
|
|
151
173
|
const lastUrl = useRef(null);
|
|
152
|
-
const urlSig = urlSync ? urlSignature(columns, sorts, filters, pageSize, page, defaultPageSize) : "";
|
|
174
|
+
const urlSig = urlSync ? urlSignature(columns, sorts, filters, pageSize, page, defaultPageSize, keys) : "";
|
|
153
175
|
useEffect(() => {
|
|
154
176
|
if (!urlSync) return;
|
|
155
177
|
if (lastUrl.current === urlSig) return;
|
|
156
178
|
lastUrl.current = urlSig;
|
|
157
|
-
writeUrlState(setSearchParams, columns, sorts, filters, pageSize, page, defaultPageSize);
|
|
179
|
+
writeUrlState(setSearchParams, columns, sorts, filters, pageSize, page, defaultPageSize, void 0, location.state, keys);
|
|
158
180
|
}, [urlSync, urlSig]);
|
|
159
181
|
return {
|
|
160
182
|
sorts,
|
|
@@ -174,8 +196,84 @@ function useTableState({
|
|
|
174
196
|
headRefs
|
|
175
197
|
};
|
|
176
198
|
}
|
|
199
|
+
function useTableUrlState({
|
|
200
|
+
columns,
|
|
201
|
+
defaultPageSize = 25,
|
|
202
|
+
urlSync: urlSyncOption = true,
|
|
203
|
+
urlPrefix: urlPrefixOption,
|
|
204
|
+
search: manageSearch = false
|
|
205
|
+
}) {
|
|
206
|
+
const resolved = resolveTableUrlSync(urlSyncOption);
|
|
207
|
+
const urlSync = resolved.enabled;
|
|
208
|
+
const urlPrefix = urlPrefixOption ?? resolved.prefix;
|
|
209
|
+
const keys = useMemo(() => urlKeys(urlPrefix), [urlPrefix]);
|
|
210
|
+
const [searchParams, setSearchParams] = useSearchParams();
|
|
211
|
+
const location = useLocation();
|
|
212
|
+
const [state, setState] = useState(() => {
|
|
213
|
+
const url = urlSync ? readTableUrlState(searchParams, columns, urlPrefix) : {};
|
|
214
|
+
return {
|
|
215
|
+
sorts: url.sorts ?? [],
|
|
216
|
+
filters: url.filters ?? {},
|
|
217
|
+
pageSize: url.pageSize ?? defaultPageSize,
|
|
218
|
+
page: url.page ?? 0,
|
|
219
|
+
search: urlSync && manageSearch ? searchParams.get(keys.search) ?? "" : ""
|
|
220
|
+
};
|
|
221
|
+
});
|
|
222
|
+
const lastUrl = useRef(null);
|
|
223
|
+
const urlSig = urlSync ? urlSignature(columns, state.sorts, state.filters, state.pageSize, state.page, defaultPageSize, keys) + (manageSearch ? `&${keys.search}=${state.search.trim() ? state.search : ""}` : "") : "";
|
|
224
|
+
useEffect(() => {
|
|
225
|
+
if (!urlSync) return;
|
|
226
|
+
if (lastUrl.current === urlSig) return;
|
|
227
|
+
lastUrl.current = urlSig;
|
|
228
|
+
writeUrlState(
|
|
229
|
+
setSearchParams,
|
|
230
|
+
columns,
|
|
231
|
+
state.sorts,
|
|
232
|
+
state.filters,
|
|
233
|
+
state.pageSize,
|
|
234
|
+
state.page,
|
|
235
|
+
defaultPageSize,
|
|
236
|
+
manageSearch ? state.search : void 0,
|
|
237
|
+
location.state,
|
|
238
|
+
keys
|
|
239
|
+
);
|
|
240
|
+
}, [urlSync, urlSig]);
|
|
241
|
+
const setPage = (page) => setState((s) => ({ ...s, page }));
|
|
242
|
+
const setPageSize = (pageSize) => setState((s) => ({ ...s, pageSize, page: 0 }));
|
|
243
|
+
const setFilters = (filters) => setState((s) => ({ ...s, filters, page: 0 }));
|
|
244
|
+
const setSorts = (sorts) => setState((s) => ({ ...s, sorts, page: 0 }));
|
|
245
|
+
const setSearch = (search) => setState((s) => ({ ...s, search, page: 0 }));
|
|
246
|
+
return {
|
|
247
|
+
page: state.page,
|
|
248
|
+
setPage,
|
|
249
|
+
pageSize: state.pageSize,
|
|
250
|
+
setPageSize,
|
|
251
|
+
filters: state.filters,
|
|
252
|
+
setFilters,
|
|
253
|
+
sorts: state.sorts,
|
|
254
|
+
setSorts,
|
|
255
|
+
search: state.search,
|
|
256
|
+
setSearch,
|
|
257
|
+
tableProps: (total, options) => ({
|
|
258
|
+
serverPagination: {
|
|
259
|
+
page: state.page,
|
|
260
|
+
pageSize: state.pageSize,
|
|
261
|
+
total,
|
|
262
|
+
onPageChange: setPage,
|
|
263
|
+
onPageSizeChange: setPageSize,
|
|
264
|
+
isLoading: options?.isLoading
|
|
265
|
+
},
|
|
266
|
+
filters: state.filters,
|
|
267
|
+
onFiltersChange: setFilters,
|
|
268
|
+
sorts: state.sorts,
|
|
269
|
+
onSortsChange: setSorts
|
|
270
|
+
})
|
|
271
|
+
};
|
|
272
|
+
}
|
|
177
273
|
export {
|
|
178
274
|
DEFAULT_PERSIST_PREFIX,
|
|
179
|
-
|
|
275
|
+
readTableUrlState,
|
|
276
|
+
useTableState,
|
|
277
|
+
useTableUrlState
|
|
180
278
|
};
|
|
181
279
|
//# sourceMappingURL=use-table-state.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/use-table-state.ts"],"sourcesContent":["import { useEffect, useMemo, useRef, useState } from \"react\";\nimport { useSearchParams } from \"react-router\";\nimport { readStored, writeStored } from \"../lib/safe-storage\";\nimport {\n decodeFilterValue,\n encodeFilterValue,\n isFilterActive,\n resolveFilter,\n} from \"./data-table-filters\";\nimport { decodeSorts, encodeSorts, normalizeSorts, type SortState } from \"./data-table-sort\";\nimport type { DataTableColumn, FilterState } from \"./data-table\";\n\n// ---------- Persisted + URL-encoded view state ----------\n//\n// Moved here with `useTableState` when `DataTable` was split: these are what the hook\n// reads and writes, and nothing else in the table ever called them.\n\ninterface PersistedState {\n // Multi-sort array; blobs from before the upgrade hold a single {key, dir}\n // object (or null) — read back through normalizeSorts.\n sort: SortState[] | { key: string; dir: string } | null;\n filters: FilterState;\n pageSize: number | \"all\";\n widths?: Record<string, number>;\n hidden?: string[];\n}\n\nexport const DEFAULT_PERSIST_PREFIX = \"hbui-table:\";\n\nfunction loadPersisted(storageKey: string | undefined, prefix: string): Partial<PersistedState> {\n if (!storageKey) return {};\n const raw = readStored(prefix + storageKey);\n if (!raw) return {};\n try {\n const parsed = JSON.parse(raw) as Partial<PersistedState>;\n return parsed && typeof parsed === \"object\" ? parsed : {};\n } catch {\n return {}; // corrupt JSON — the storage access itself is guarded by readStored\n }\n}\n\n/** The blob that would be stored — also the value the effect below compares by, so\n * the comparison and the write can never disagree about what \"unchanged\" means. */\nfunction serializePersisted(state: PersistedState): string {\n return JSON.stringify(state);\n}\n\n// ---------- URL sync helpers ----------\n\nconst URL_FILTER_PREFIX = \"f.\";\nconst URL_SORT_KEY = \"sort\";\nconst URL_PAGE_KEY = \"p\";\nconst URL_PAGE_SIZE_KEY = \"ps\";\n\ninterface UrlState {\n sorts?: SortState[];\n filters?: FilterState;\n pageSize?: number; // Infinity for \"all\"\n page?: number; // 0-based\n}\n\n/**\n * The managed keys out of the ROUTER's query string — the one `setSearchParams` writes.\n *\n * This read `window.location.search` until 0.7.0, which is the same string only under a\n * BrowserRouter. Under a HashRouter the router's query lives after the `#`\n * (`/#/tx?f.payee=Rewe`) and `window.location.search` is empty: a shared link opened\n * unfiltered, and the table's first write then replaced the link's filter with its own\n * empty state. Reading and writing through `useSearchParams` is one source for both\n * directions under every router, MemoryRouter included.\n */\nfunction readUrlState<T>(sp: URLSearchParams, columns: DataTableColumn<T>[]): UrlState {\n const out: UrlState = {};\n\n const filters: FilterState = {};\n for (const col of columns) {\n const filter = resolveFilter(col);\n if (!filter) continue;\n const raw = sp.get(URL_FILTER_PREFIX + col.key);\n if (raw == null) continue;\n filters[col.key] = decodeFilterValue(filter, raw);\n }\n if (Object.keys(filters).length) out.filters = filters;\n\n const sortRaw = sp.get(URL_SORT_KEY);\n if (sortRaw) {\n const decoded = decodeSorts(sortRaw, new Set(columns.map((c) => c.key)));\n if (decoded.length) out.sorts = decoded;\n }\n\n const psRaw = sp.get(URL_PAGE_SIZE_KEY);\n if (psRaw === \"all\") out.pageSize = Infinity;\n else if (psRaw && Number(psRaw) > 0) out.pageSize = Number(psRaw);\n\n const pRaw = sp.get(URL_PAGE_KEY);\n if (pRaw && Number(pRaw) >= 1) out.page = Number(pRaw) - 1;\n\n return out;\n}\n\n/**\n * The managed part of the query string, as a string, for comparing by VALUE.\n *\n * Everything the table puts in the address and nothing else, in a fixed order.\n * `columns` is walked for its keys only, which is why it can be left out of the\n * effect's dependencies without lying: a new column ARRAY carrying the same keys\n * produces the same signature, and a genuinely different set of filterable columns\n * produces a different one.\n */\nfunction urlSignature<T>(\n columns: DataTableColumn<T>[],\n sorts: SortState[],\n filters: FilterState,\n pageSize: number,\n page: number,\n defaultPageSize: number,\n): string {\n const parts: string[] = [];\n for (const col of columns) {\n const state = filters[col.key];\n if (!state || !isFilterActive(state)) continue;\n const enc = encodeFilterValue(state);\n if (enc != null) parts.push(`${URL_FILTER_PREFIX}${col.key}=${enc}`);\n }\n parts.push(`${URL_SORT_KEY}=${encodeSorts(sorts)}`);\n parts.push(\n `${URL_PAGE_SIZE_KEY}=${\n pageSize === Infinity ? \"all\" : pageSize === defaultPageSize ? \"\" : String(pageSize)\n }`,\n );\n parts.push(`${URL_PAGE_KEY}=${page > 0 ? String(page + 1) : \"\"}`);\n return parts.join(\"&\");\n}\n\nfunction writeUrlState<T>(\n setSearchParams: ReturnType<typeof useSearchParams>[1],\n columns: DataTableColumn<T>[],\n sorts: SortState[],\n filters: FilterState,\n pageSize: number,\n page: number,\n defaultPageSize: number,\n): void {\n setSearchParams(\n (prev) => {\n const next = new URLSearchParams(prev);\n // clear managed keys\n for (const col of columns) next.delete(URL_FILTER_PREFIX + col.key);\n next.delete(URL_SORT_KEY);\n next.delete(URL_PAGE_KEY);\n next.delete(URL_PAGE_SIZE_KEY);\n // write filters\n for (const col of columns) {\n const state = filters[col.key];\n if (!state || !isFilterActive(state)) continue;\n const enc = encodeFilterValue(state);\n if (enc != null) next.set(URL_FILTER_PREFIX + col.key, enc);\n }\n // write sort\n const sortEnc = encodeSorts(sorts);\n if (sortEnc) next.set(URL_SORT_KEY, sortEnc);\n // write page size if non-default\n if (pageSize === Infinity) next.set(URL_PAGE_SIZE_KEY, \"all\");\n else if (pageSize !== defaultPageSize) next.set(URL_PAGE_SIZE_KEY, String(pageSize));\n // write page if not first\n if (page > 0) next.set(URL_PAGE_KEY, String(page + 1));\n return next;\n },\n { replace: true },\n );\n}\n\n/**\n * Where a table's view lives: what it is sorted and filtered by, which page, how wide\n * the columns are and which are hidden — plus the two places that outlives a render.\n *\n * Lifted out of `DataTable`, which was 984 lines and twenty hooks in one function. This\n * is the part that is genuinely about STATE rather than about drawing, and the three\n * rules it encodes are easy to lose among the markup:\n *\n * * **The URL is read once, on mount.** A shared or deep link populates the initial view;\n * after that the state is local, or the browser's own history would fight the user's\n * next click.\n * * **Sorting and filtering are optionally CONTROLLED.** A server-driven table passes\n * state and a callback and owns them; everything else is self-owned. That is the\n * `sortsProp ?? internalSorts` pair, and it is why the setters are exposed separately.\n * * **Persistence writes on every change, the URL only when asked.** `storageKey` is the\n * per-table identity; `urlSync` is opt-in because only some tables want their view in\n * a shareable address.\n * * **A controlled filter or sort that changes sends the table back to page 1.** See\n * the note at the reset below.\n */\nexport function useTableState<T>({\n columns,\n storageKey,\n storageKeyPrefix,\n urlSync,\n defaultPageSize,\n sortsProp,\n filtersProp,\n}: {\n columns: DataTableColumn<T>[];\n storageKey?: string;\n storageKeyPrefix: string;\n urlSync?: boolean;\n defaultPageSize: number;\n sortsProp?: SortState[];\n filtersProp?: FilterState;\n}) {\n // Called unconditionally (a Router is required either way — see src/data-table.ts),\n // and the SAME pair is used to read and to write; see `readUrlState`.\n const [searchParams, setSearchParams] = useSearchParams();\n // Read URL once on mount so URL-encoded views (e.g. shared links, deep links from\n // other pages) populate initial state. After mount, state is local.\n const [urlInitial] = useState<UrlState>(() =>\n urlSync ? readUrlState(searchParams, columns) : {},\n );\n const initial = useMemo(\n () => loadPersisted(storageKey, storageKeyPrefix),\n [storageKey, storageKeyPrefix],\n );\n const [internalSorts, setInternalSorts] = useState<SortState[]>(() =>\n urlInitial.sorts !== undefined ? urlInitial.sorts : normalizeSorts(initial.sort),\n );\n const [internalFilters, setInternalFilters] = useState<FilterState>(\n () => urlInitial.filters ?? initial.filters ?? {},\n );\n // Controlled when the owner passes state + callback (server-driven tables);\n // self-owned otherwise.\n const sorts = sortsProp ?? internalSorts;\n const filters = filtersProp ?? internalFilters;\n const [page, setPage] = useState(() => urlInitial.page ?? 0);\n\n // ---- Controlled filters/sorts reset the page ----\n //\n // A self-owned table resets to page 1 in the filter handlers. A CONTROLLED one could\n // not: the handlers hand the change to the owner and return, and `page` lives here,\n // where the owner has no way to reach it — so narrowing a filter from outside (a\n // saved view, a chip dismissed above the table) left a client-side table on page 4\n // of what was now two pages, clamped to the last one instead of the first.\n //\n // So the table does it: whenever the controlled VALUE changes, back to the first\n // page. Compared by value, because a controlled prop is a fresh object on every\n // parent render. Adjusted during render rather than in an effect, so the stale page\n // is never painted and never written to the URL. Not on mount: a deep link's `p=3`\n // must survive the owner's first render. (In `serverPagination` mode this state is\n // unused — the owner's `page` is the page, and resetting it stays the owner's job.)\n const controlledSig =\n sortsProp !== undefined || filtersProp !== undefined\n ? JSON.stringify([sortsProp ?? null, filtersProp ?? null])\n : null;\n const [seenControlledSig, setSeenControlledSig] = useState(controlledSig);\n if (seenControlledSig !== controlledSig) {\n setSeenControlledSig(controlledSig);\n setPage(0);\n }\n const [pageSize, setPageSize] = useState<number>(() => {\n if (urlInitial.pageSize !== undefined) return urlInitial.pageSize;\n if (initial.pageSize === \"all\") return Infinity;\n if (typeof initial.pageSize === \"number\" && initial.pageSize > 0) return initial.pageSize;\n return defaultPageSize;\n });\n const [widths, setWidths] = useState<Record<string, number>>(() => initial.widths ?? {});\n const [hiddenCols, setHiddenCols] = useState<Set<string>>(() => new Set(initial.hidden ?? []));\n const [showSettings, setShowSettings] = useState(false);\n const headRefs = useMemo(() => new Map<string, HTMLTableCellElement>(), []);\n\n // ---- Writing out: both of these compare by VALUE ----\n //\n // A CONTROLLED table (`sorts`/`filters` props plus callbacks — every server-driven\n // one) receives a freshly-built object on every render of the page around it, and\n // `{}` is never `===` the `{}` before it. Keyed on identity, both effects below\n // therefore fired on every unrelated parent render: persistence wrote the same JSON\n // into `localStorage` each time — a synchronous main-thread write, on a page whose\n // other half may be a form being typed into — and the URL one handed react-router a\n // `replace` it answers with a render, which is the loop the audit records. A `ref`\n // holding what was last written is what makes \"changed\" mean changed.\n const lastPersisted = useRef<string | null>(null);\n const persisted = !storageKey\n ? \"\"\n : serializePersisted({\n sort: sorts,\n filters,\n pageSize: pageSize === Infinity ? \"all\" : pageSize,\n widths,\n hidden: Array.from(hiddenCols),\n });\n useEffect(() => {\n if (!storageKey) return;\n // The destination is part of the signature: two tables can hold identical state,\n // and a table that swaps `storageKey` has to write under the new one even though\n // nothing about the view changed.\n const target = storageKeyPrefix + storageKey;\n const sig = `${target}\\u0000${persisted}`;\n if (lastPersisted.current === sig) return;\n lastPersisted.current = sig;\n writeStored(target, persisted);\n }, [storageKey, storageKeyPrefix, persisted]);\n\n const lastUrl = useRef<string | null>(null);\n const urlSig = urlSync\n ? urlSignature(columns, sorts, filters, pageSize, page, defaultPageSize)\n : \"\";\n useEffect(() => {\n if (!urlSync) return;\n if (lastUrl.current === urlSig) return;\n lastUrl.current = urlSig;\n // `columns` is deliberately not a dependency and does not need to be: the\n // signature above is computed from it, so a column set that would produce a\n // different address produces a different signature first.\n writeUrlState(setSearchParams, columns, sorts, filters, pageSize, page, defaultPageSize);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [urlSync, urlSig]);\n\n return {\n sorts,\n filters,\n setInternalSorts,\n setInternalFilters,\n page,\n setPage,\n pageSize,\n setPageSize,\n widths,\n setWidths,\n hiddenCols,\n setHiddenCols,\n showSettings,\n setShowSettings,\n headRefs,\n };\n}\n"],"mappings":";AAAA,SAAS,WAAW,SAAS,QAAQ,gBAAgB;AACrD,SAAS,uBAAuB;AAChC,SAAS,YAAY,mBAAmB;AACxC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,aAAa,aAAa,sBAAsC;AAkBlE,MAAM,yBAAyB;AAEtC,SAAS,cAAc,YAAgC,QAAyC;AAC9F,MAAI,CAAC,WAAY,QAAO,CAAC;AACzB,QAAM,MAAM,WAAW,SAAS,UAAU;AAC1C,MAAI,CAAC,IAAK,QAAO,CAAC;AAClB,MAAI;AACF,UAAM,SAAS,KAAK,MAAM,GAAG;AAC7B,WAAO,UAAU,OAAO,WAAW,WAAW,SAAS,CAAC;AAAA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B,MAAM,IAAI,IAAI,QAAQ,UAAU,CAAC,CAAC,CAAC;AAC7F,QAAM,CAAC,cAAc,eAAe,IAAI,SAAS,KAAK;AACtD,QAAM,WAAW,QAAQ,MAAM,oBAAI,IAAkC,GAAG,CAAC,CAAC;AAY1E,QAAM,gBAAgB,OAAsB,IAAI;AAChD,QAAM,YAAY,CAAC,aACf,KACA,mBAAmB;AAAA,IACjB,MAAM;AAAA,IACN;AAAA,IACA,UAAU,aAAa,WAAW,QAAQ;AAAA,IAC1C;AAAA,IACA,QAAQ,MAAM,KAAK,UAAU;AAAA,EAC/B,CAAC;AACL,YAAU,MAAM;AACd,QAAI,CAAC,WAAY;AAIjB,UAAM,SAAS,mBAAmB;AAClC,UAAM,MAAM,GAAG,MAAM,KAAS,SAAS;AACvC,QAAI,cAAc,YAAY,IAAK;AACnC,kBAAc,UAAU;AACxB,gBAAY,QAAQ,SAAS;AAAA,EAC/B,GAAG,CAAC,YAAY,kBAAkB,SAAS,CAAC;AAE5C,QAAM,UAAU,OAAsB,IAAI;AAC1C,QAAM,SAAS,UACX,aAAa,SAAS,OAAO,SAAS,UAAU,MAAM,eAAe,IACrE;AACJ,YAAU,MAAM;AACd,QAAI,CAAC,QAAS;AACd,QAAI,QAAQ,YAAY,OAAQ;AAChC,YAAQ,UAAU;AAIlB,kBAAc,iBAAiB,SAAS,OAAO,SAAS,UAAU,MAAM,eAAe;AAAA,EAEzF,GAAG,CAAC,SAAS,MAAM,CAAC;AAEpB,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/components/use-table-state.ts"],"sourcesContent":["import { useEffect, useMemo, useRef, useState } from \"react\";\nimport { useLocation, useSearchParams } from \"react-router\";\nimport { readStored, writeStored } from \"../lib/safe-storage\";\nimport {\n decodeFilterValue,\n encodeFilterValue,\n isFilterActive,\n resolveFilter,\n} from \"./data-table-filters\";\nimport { decodeSorts, encodeSorts, normalizeSorts, type SortState } from \"./data-table-sort\";\nimport type { DataTableColumn, FilterState, ServerPagination } from \"./data-table\";\n\n// ---------- Persisted + URL-encoded view state ----------\n//\n// Moved here with `useTableState` when `DataTable` was split: these are what the hook\n// reads and writes, and nothing else in the table ever called them.\n\ninterface PersistedState {\n // Multi-sort array; blobs from before the upgrade hold a single {key, dir}\n // object (or null) — read back through normalizeSorts.\n sort: SortState[] | { key: string; dir: string } | null;\n filters: FilterState;\n pageSize: number | \"all\";\n widths?: Record<string, number>;\n hidden?: string[];\n}\n\nexport const DEFAULT_PERSIST_PREFIX = \"hbui-table:\";\n\nfunction loadPersisted(storageKey: string | undefined, prefix: string): Partial<PersistedState> {\n if (!storageKey) return {};\n const raw = readStored(prefix + storageKey);\n if (!raw) return {};\n try {\n const parsed = JSON.parse(raw) as Partial<PersistedState>;\n return parsed && typeof parsed === \"object\" ? parsed : {};\n } catch {\n return {}; // corrupt JSON — the storage access itself is guarded by readStored\n }\n}\n\n/** The blob that would be stored — also the value the effect below compares by, so\n * the comparison and the write can never disagree about what \"unchanged\" means. */\nfunction serializePersisted(state: PersistedState): string {\n return JSON.stringify(state);\n}\n\n// ---------- URL sync helpers ----------\n\nconst URL_FILTER_PREFIX = \"f.\";\nconst URL_SORT_KEY = \"sort\";\nconst URL_PAGE_KEY = \"p\";\nconst URL_PAGE_SIZE_KEY = \"ps\";\n/** The free-text search term — managed only by {@link useTableUrlState}, and only when\n * it is asked to (`search: true`); a plain `urlSync` table leaves a `q` alone. */\nconst URL_SEARCH_KEY = \"q\";\n\n/**\n * How a table is mirrored into the URL: `true`, or `{ prefix }` for a table that shares\n * its page with another URL-synced one. The prefix is put verbatim in front of EVERY key\n * the table writes and reads — `{ prefix: \"inv.\" }` gives `inv.f.<column>`, `inv.sort`,\n * `inv.p`, `inv.ps` (and `inv.q`) — so two tables on one page stop sharing a sort and a\n * page. Without one the keys are unprefixed, as they always were.\n */\nexport type TableUrlSync = boolean | { prefix?: string };\n\n/** The query keys of one table, with its prefix applied. */\ninterface UrlKeys {\n filter: string;\n sort: string;\n page: string;\n pageSize: string;\n search: string;\n}\n\nfunction urlKeys(prefix = \"\"): UrlKeys {\n return {\n filter: prefix + URL_FILTER_PREFIX,\n sort: prefix + URL_SORT_KEY,\n page: prefix + URL_PAGE_KEY,\n pageSize: prefix + URL_PAGE_SIZE_KEY,\n search: prefix + URL_SEARCH_KEY,\n };\n}\n\n/** `urlSync` split into \"is it on\" and \"under which prefix\". */\nfunction resolveTableUrlSync(urlSync: TableUrlSync | undefined): { enabled: boolean; prefix: string } {\n if (!urlSync) return { enabled: false, prefix: \"\" };\n return { enabled: true, prefix: urlSync === true ? \"\" : (urlSync.prefix ?? \"\") };\n}\n\n/** What {@link readTableUrlState} found in a query string. */\nexport interface TableUrlState {\n sorts?: SortState[];\n filters?: FilterState;\n /** `Infinity` for `ps=all`. */\n pageSize?: number;\n /** 0-based (the URL's `p` is 1-based). */\n page?: number;\n}\n\n/**\n * What a table's URL says, read out of a query string: the column filters (`f.<key>`),\n * the sort, the page size and the 0-based page. Absent keys are absent here too, so a\n * caller can tell \"not in the link\" from \"the default\". The same reader `urlSync` uses\n * on mount, exported for an owner that keeps the state itself — see\n * {@link useTableUrlState}.\n *\n * Pass the ROUTER's query string — the one `setSearchParams` writes — and the table's\n * `prefix` when it has one (see {@link TableUrlSync}).\n *\n * This read `window.location.search` until 0.7.0, which is the same string only under a\n * BrowserRouter. Under a HashRouter the router's query lives after the `#`\n * (`/#/tx?f.payee=Rewe`) and `window.location.search` is empty: a shared link opened\n * unfiltered, and the table's first write then replaced the link's filter with its own\n * empty state. Reading and writing through `useSearchParams` is one source for both\n * directions under every router, MemoryRouter included.\n */\nexport function readTableUrlState<T>(\n sp: URLSearchParams,\n columns: DataTableColumn<T>[],\n prefix?: string,\n): TableUrlState {\n const keys = urlKeys(prefix);\n const out: TableUrlState = {};\n\n const filters: FilterState = {};\n for (const col of columns) {\n const filter = resolveFilter(col);\n if (!filter) continue;\n const raw = sp.get(keys.filter + col.key);\n if (raw == null) continue;\n filters[col.key] = decodeFilterValue(filter, raw);\n }\n if (Object.keys(filters).length) out.filters = filters;\n\n const sortRaw = sp.get(keys.sort);\n if (sortRaw) {\n const decoded = decodeSorts(sortRaw, new Set(columns.map((c) => c.key)));\n if (decoded.length) out.sorts = decoded;\n }\n\n const psRaw = sp.get(keys.pageSize);\n if (psRaw === \"all\") out.pageSize = Infinity;\n else if (psRaw && Number(psRaw) > 0) out.pageSize = Number(psRaw);\n\n const pRaw = sp.get(keys.page);\n if (pRaw && Number(pRaw) >= 1) out.page = Number(pRaw) - 1;\n\n return out;\n}\n\n/**\n * The managed part of the query string, as a string, for comparing by VALUE.\n *\n * Everything the table puts in the address and nothing else, in a fixed order.\n * `columns` is walked for its keys only, which is why it can be left out of the\n * effect's dependencies without lying: a new column ARRAY carrying the same keys\n * produces the same signature, and a genuinely different set of filterable columns\n * produces a different one.\n */\nfunction urlSignature<T>(\n columns: DataTableColumn<T>[],\n sorts: SortState[],\n filters: FilterState,\n pageSize: number,\n page: number,\n defaultPageSize: number,\n keys: UrlKeys,\n): string {\n const parts: string[] = [];\n for (const col of columns) {\n const state = filters[col.key];\n if (!state || !isFilterActive(state)) continue;\n const enc = encodeFilterValue(state);\n if (enc != null) parts.push(`${keys.filter}${col.key}=${enc}`);\n }\n parts.push(`${keys.sort}=${encodeSorts(sorts)}`);\n parts.push(\n `${keys.pageSize}=${\n pageSize === Infinity ? \"all\" : pageSize === defaultPageSize ? \"\" : String(pageSize)\n }`,\n );\n parts.push(`${keys.page}=${page > 0 ? String(page + 1) : \"\"}`);\n return parts.join(\"&\");\n}\n\nfunction writeUrlState<T>(\n setSearchParams: ReturnType<typeof useSearchParams>[1],\n columns: DataTableColumn<T>[],\n sorts: SortState[],\n filters: FilterState,\n pageSize: number,\n page: number,\n defaultPageSize: number,\n // `undefined`: the search term is not ours to manage, and a `q` is left as it is.\n search: string | undefined,\n // The current entry's route state, carried over the replace. A query rewrite is not\n // a navigation, and dropping the state would, for one, lose the mark a URL-bound\n // dialog's opener leaves there (see useDialogParam).\n state: unknown,\n keys: UrlKeys,\n): void {\n setSearchParams(\n (prev) => {\n const next = new URLSearchParams(prev);\n // clear managed keys\n for (const col of columns) next.delete(keys.filter + col.key);\n next.delete(keys.sort);\n next.delete(keys.page);\n next.delete(keys.pageSize);\n if (search !== undefined) {\n next.delete(keys.search);\n if (search.trim()) next.set(keys.search, search);\n }\n // write filters\n for (const col of columns) {\n const state = filters[col.key];\n if (!state || !isFilterActive(state)) continue;\n const enc = encodeFilterValue(state);\n if (enc != null) next.set(keys.filter + col.key, enc);\n }\n // write sort\n const sortEnc = encodeSorts(sorts);\n if (sortEnc) next.set(keys.sort, sortEnc);\n // write page size if non-default\n if (pageSize === Infinity) next.set(keys.pageSize, \"all\");\n else if (pageSize !== defaultPageSize) next.set(keys.pageSize, String(pageSize));\n // write page if not first\n if (page > 0) next.set(keys.page, String(page + 1));\n return next;\n },\n { replace: true, state },\n );\n}\n\n/**\n * Where a table's view lives: what it is sorted and filtered by, which page, how wide\n * the columns are and which are hidden — plus the two places that outlives a render.\n *\n * Lifted out of `DataTable`, which was 984 lines and twenty hooks in one function. This\n * is the part that is genuinely about STATE rather than about drawing, and the three\n * rules it encodes are easy to lose among the markup:\n *\n * * **The URL is read once, on mount.** A shared or deep link populates the initial view;\n * after that the state is local, or the browser's own history would fight the user's\n * next click.\n * * **Sorting and filtering are optionally CONTROLLED.** A server-driven table passes\n * state and a callback and owns them; everything else is self-owned. That is the\n * `sortsProp ?? internalSorts` pair, and it is why the setters are exposed separately.\n * * **Persistence writes on every change, the URL only when asked.** `storageKey` is the\n * per-table identity; `urlSync` is opt-in because only some tables want their view in\n * a shareable address.\n * * **A controlled filter or sort that changes sends the table back to page 1.** See\n * the note at the reset below.\n */\nexport function useTableState<T>({\n columns,\n storageKey,\n storageKeyPrefix,\n urlSync: urlSyncOption,\n defaultPageSize,\n sortsProp,\n filtersProp,\n}: {\n columns: DataTableColumn<T>[];\n storageKey?: string;\n storageKeyPrefix: string;\n urlSync?: TableUrlSync;\n defaultPageSize: number;\n sortsProp?: SortState[];\n filtersProp?: FilterState;\n}) {\n const { enabled: urlSync, prefix: urlPrefix } = resolveTableUrlSync(urlSyncOption);\n const keys = useMemo(() => urlKeys(urlPrefix), [urlPrefix]);\n // Called unconditionally (a Router is required either way — see src/data-table.ts),\n // and the SAME pair is used to read and to write; see `readTableUrlState`.\n const [searchParams, setSearchParams] = useSearchParams();\n const location = useLocation();\n // Read URL once on mount so URL-encoded views (e.g. shared links, deep links from\n // other pages) populate initial state. After mount, state is local.\n const [urlInitial] = useState<TableUrlState>(() =>\n urlSync ? readTableUrlState(searchParams, columns, urlPrefix) : {},\n );\n const initial = useMemo(\n () => loadPersisted(storageKey, storageKeyPrefix),\n [storageKey, storageKeyPrefix],\n );\n const [internalSorts, setInternalSorts] = useState<SortState[]>(() =>\n urlInitial.sorts !== undefined ? urlInitial.sorts : normalizeSorts(initial.sort),\n );\n const [internalFilters, setInternalFilters] = useState<FilterState>(\n () => urlInitial.filters ?? initial.filters ?? {},\n );\n // Controlled when the owner passes state + callback (server-driven tables);\n // self-owned otherwise.\n const sorts = sortsProp ?? internalSorts;\n const filters = filtersProp ?? internalFilters;\n const [page, setPage] = useState(() => urlInitial.page ?? 0);\n\n // ---- Controlled filters/sorts reset the page ----\n //\n // A self-owned table resets to page 1 in the filter handlers. A CONTROLLED one could\n // not: the handlers hand the change to the owner and return, and `page` lives here,\n // where the owner has no way to reach it — so narrowing a filter from outside (a\n // saved view, a chip dismissed above the table) left a client-side table on page 4\n // of what was now two pages, clamped to the last one instead of the first.\n //\n // So the table does it: whenever the controlled VALUE changes, back to the first\n // page. Compared by value, because a controlled prop is a fresh object on every\n // parent render. Adjusted during render rather than in an effect, so the stale page\n // is never painted and never written to the URL. Not on mount: a deep link's `p=3`\n // must survive the owner's first render. (In `serverPagination` mode this state is\n // unused — the owner's `page` is the page, and resetting it stays the owner's job.)\n const controlledSig =\n sortsProp !== undefined || filtersProp !== undefined\n ? JSON.stringify([sortsProp ?? null, filtersProp ?? null])\n : null;\n const [seenControlledSig, setSeenControlledSig] = useState(controlledSig);\n if (seenControlledSig !== controlledSig) {\n setSeenControlledSig(controlledSig);\n setPage(0);\n }\n const [pageSize, setPageSize] = useState<number>(() => {\n if (urlInitial.pageSize !== undefined) return urlInitial.pageSize;\n if (initial.pageSize === \"all\") return Infinity;\n if (typeof initial.pageSize === \"number\" && initial.pageSize > 0) return initial.pageSize;\n return defaultPageSize;\n });\n const [widths, setWidths] = useState<Record<string, number>>(() => initial.widths ?? {});\n const [hiddenCols, setHiddenCols] = useState<Set<string>>(() => new Set(initial.hidden ?? []));\n const [showSettings, setShowSettings] = useState(false);\n const headRefs = useMemo(() => new Map<string, HTMLTableCellElement>(), []);\n\n // ---- Writing out: both of these compare by VALUE ----\n //\n // A CONTROLLED table (`sorts`/`filters` props plus callbacks — every server-driven\n // one) receives a freshly-built object on every render of the page around it, and\n // `{}` is never `===` the `{}` before it. Keyed on identity, both effects below\n // therefore fired on every unrelated parent render: persistence wrote the same JSON\n // into `localStorage` each time — a synchronous main-thread write, on a page whose\n // other half may be a form being typed into — and the URL one handed react-router a\n // `replace` it answers with a render, which is the loop the audit records. A `ref`\n // holding what was last written is what makes \"changed\" mean changed.\n const lastPersisted = useRef<string | null>(null);\n const persisted = !storageKey\n ? \"\"\n : serializePersisted({\n sort: sorts,\n filters,\n pageSize: pageSize === Infinity ? \"all\" : pageSize,\n widths,\n hidden: Array.from(hiddenCols),\n });\n useEffect(() => {\n if (!storageKey) return;\n // The destination is part of the signature: two tables can hold identical state,\n // and a table that swaps `storageKey` has to write under the new one even though\n // nothing about the view changed.\n const target = storageKeyPrefix + storageKey;\n const sig = `${target}\\u0000${persisted}`;\n if (lastPersisted.current === sig) return;\n lastPersisted.current = sig;\n writeStored(target, persisted);\n }, [storageKey, storageKeyPrefix, persisted]);\n\n const lastUrl = useRef<string | null>(null);\n const urlSig = urlSync\n ? urlSignature(columns, sorts, filters, pageSize, page, defaultPageSize, keys)\n : \"\";\n useEffect(() => {\n if (!urlSync) return;\n if (lastUrl.current === urlSig) return;\n lastUrl.current = urlSig;\n // `columns` is deliberately not a dependency and does not need to be: the\n // signature above is computed from it, so a column set that would produce a\n // different address produces a different signature first.\n writeUrlState(setSearchParams, columns, sorts, filters, pageSize, page, defaultPageSize, undefined, location.state, keys);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [urlSync, urlSig]);\n\n return {\n sorts,\n filters,\n setInternalSorts,\n setInternalFilters,\n page,\n setPage,\n pageSize,\n setPageSize,\n widths,\n setWidths,\n hiddenCols,\n setHiddenCols,\n showSettings,\n setShowSettings,\n headRefs,\n };\n}\n\n// ---------- Owner-held table state, mirrored to the URL ----------\n\nexport interface UseTableUrlStateOptions<T> {\n /** The table's columns — read for their keys and filter types only. */\n columns: DataTableColumn<T>[];\n /** Default 25. A page size equal to it is left out of the URL. */\n defaultPageSize?: number;\n /** Mirror the state into the URL and seed it from there on mount. Default true.\n * `{ prefix }` puts a prefix in front of every key, for a page with two URL-synced\n * tables — see {@link TableUrlSync}. */\n urlSync?: TableUrlSync;\n /** Shorthand for `urlSync: { prefix }`; wins over a prefix given there. */\n urlPrefix?: string;\n /** Also hold a free-text search term, under `q`. Off by default, so a `q` that\n * belongs to someone else on the page is never touched. */\n search?: boolean;\n}\n\n/** The part of {@link DataTableProps} a server-driven table takes from its owner. */\nexport interface TableUrlStateProps {\n serverPagination: ServerPagination;\n filters: FilterState;\n onFiltersChange: (next: FilterState) => void;\n sorts: SortState[];\n onSortsChange: (next: SortState[]) => void;\n}\n\nexport interface UseTableUrlStateReturn {\n /** 0-based. */\n page: number;\n setPage: (page: number) => void;\n pageSize: number;\n /** Also back to the first page. */\n setPageSize: (pageSize: number) => void;\n filters: FilterState;\n /** Also back to the first page. */\n setFilters: (next: FilterState) => void;\n sorts: SortState[];\n /** Also back to the first page. */\n setSorts: (next: SortState[]) => void;\n /** The search term (`\"\"` unless `search: true`). */\n search: string;\n /** Also back to the first page. */\n setSearch: (next: string) => void;\n /**\n * Everything the table needs, to spread onto it:\n * `<DataTable {...table.tableProps(data?.total ?? 0, { isLoading })} rows={…} … />`.\n */\n tableProps: (total: number, options?: { isLoading?: boolean }) => TableUrlStateProps;\n}\n\ninterface OwnedState {\n sorts: SortState[];\n filters: FilterState;\n pageSize: number;\n page: number;\n search: string;\n}\n\n/**\n * The controlled state of a `serverPagination` table — filters, sorts, page, page size\n * and optionally a search term — kept by the OWNER and mirrored into the URL in the\n * table's own scheme (`f.<key>`, `sort`, `p`, `ps`, and `q`).\n *\n * A server-driven table owns none of this: the owner has to hold it to turn it into\n * the query that fetches `rows`, and until now it also had to restate the table's URL\n * codec to keep the view bookmarkable (kastlan's use-server-table.ts copied\n * `readUrlState` / `writeUrlState` to do it). Same rules as `urlSync`:\n *\n * * **The URL is read once, on mount** — a shared or deep link (see {@link filterHref})\n * seeds the view; after that the state is local and written out with `replace`.\n * * **Any change but the page itself goes back to page 1** — a narrower filter must not\n * leave the user on page 7 of 2.\n * * **Written by value**: an unchanged view writes nothing, however often the owner\n * renders.\n *\n * Mapping the state onto the backend's query parameters stays the owner's: that is the\n * part the kit cannot know.\n */\nexport function useTableUrlState<T>({\n columns,\n defaultPageSize = 25,\n urlSync: urlSyncOption = true,\n urlPrefix: urlPrefixOption,\n search: manageSearch = false,\n}: UseTableUrlStateOptions<T>): UseTableUrlStateReturn {\n const resolved = resolveTableUrlSync(urlSyncOption);\n const urlSync = resolved.enabled;\n const urlPrefix = urlPrefixOption ?? resolved.prefix;\n const keys = useMemo(() => urlKeys(urlPrefix), [urlPrefix]);\n const [searchParams, setSearchParams] = useSearchParams();\n const location = useLocation();\n const [state, setState] = useState<OwnedState>(() => {\n const url = urlSync ? readTableUrlState(searchParams, columns, urlPrefix) : {};\n return {\n sorts: url.sorts ?? [],\n filters: url.filters ?? {},\n pageSize: url.pageSize ?? defaultPageSize,\n page: url.page ?? 0,\n search: urlSync && manageSearch ? (searchParams.get(keys.search) ?? \"\") : \"\",\n };\n });\n\n const lastUrl = useRef<string | null>(null);\n const urlSig = urlSync\n ? urlSignature(columns, state.sorts, state.filters, state.pageSize, state.page, defaultPageSize, keys) +\n (manageSearch ? `&${keys.search}=${state.search.trim() ? state.search : \"\"}` : \"\")\n : \"\";\n useEffect(() => {\n if (!urlSync) return;\n // First run included: a link that arrives with `p=1` or a default `ps` is\n // normalised to the table's own spelling, as `urlSync` does.\n if (lastUrl.current === urlSig) return;\n lastUrl.current = urlSig;\n writeUrlState(\n setSearchParams,\n columns,\n state.sorts,\n state.filters,\n state.pageSize,\n state.page,\n defaultPageSize,\n manageSearch ? state.search : undefined,\n location.state,\n keys,\n );\n // Keyed on the signature, which is computed from everything the write reads — see\n // the same effect in useTableState.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [urlSync, urlSig]);\n\n const setPage = (page: number) => setState((s) => ({ ...s, page }));\n const setPageSize = (pageSize: number) => setState((s) => ({ ...s, pageSize, page: 0 }));\n const setFilters = (filters: FilterState) => setState((s) => ({ ...s, filters, page: 0 }));\n const setSorts = (sorts: SortState[]) => setState((s) => ({ ...s, sorts, page: 0 }));\n const setSearch = (search: string) => setState((s) => ({ ...s, search, page: 0 }));\n\n return {\n page: state.page,\n setPage,\n pageSize: state.pageSize,\n setPageSize,\n filters: state.filters,\n setFilters,\n sorts: state.sorts,\n setSorts,\n search: state.search,\n setSearch,\n tableProps: (total, options) => ({\n serverPagination: {\n page: state.page,\n pageSize: state.pageSize,\n total,\n onPageChange: setPage,\n onPageSizeChange: setPageSize,\n isLoading: options?.isLoading,\n },\n filters: state.filters,\n onFiltersChange: setFilters,\n sorts: state.sorts,\n onSortsChange: setSorts,\n }),\n };\n}\n"],"mappings":";AAAA,SAAS,WAA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