@krak-stack/registry 0.10.20 → 0.11.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +89 -3
- package/README.md +11 -8
- package/dist/components/agent/index.d.ts +454 -0
- package/dist/components/agent/react.d.ts +55 -0
- package/dist/components/agent/react.js +2440 -0
- package/dist/components/agent/schema.d.ts +55 -0
- package/dist/components/animated-list/classes.d.ts +9 -0
- package/dist/components/animated-list/html.d.ts +11 -0
- package/dist/components/animated-list/html.js +533 -0
- package/dist/components/animated-list/index.d.ts +205 -0
- package/dist/components/animated-list/react.d.ts +11 -0
- package/dist/components/{ui/animated-list.js → animated-list/react.js} +199 -54
- package/dist/components/animated-list/schema.d.ts +44 -0
- package/dist/components/animated-number/html.d.ts +19 -0
- package/dist/components/animated-number/html.js +101 -0
- package/dist/components/animated-number/index.d.ts +80 -0
- package/dist/components/{ui/animated-number.d.ts → animated-number/react.d.ts} +2 -7
- package/dist/components/animated-number/react.js +124 -0
- package/dist/components/animated-number/schema.d.ts +9 -0
- package/dist/components/app-brand/classes.d.ts +11 -0
- package/dist/components/app-brand/html.d.ts +26 -0
- package/dist/components/app-brand/html.js +78 -0
- package/dist/components/app-brand/react.d.ts +12 -0
- package/dist/components/app-brand/react.js +86 -0
- package/dist/components/app-brand/schema.d.ts +36 -0
- package/dist/components/app-switcher/classes.d.ts +15 -0
- package/dist/components/app-switcher/html.d.ts +72 -0
- package/dist/components/app-switcher/html.js +327 -0
- package/dist/components/app-switcher/index.d.ts +47 -0
- package/dist/components/app-switcher/react.d.ts +12 -0
- package/dist/components/{ui/app-switcher.js → app-switcher/react.js} +84 -15
- package/dist/components/app-switcher/schema.d.ts +39 -0
- package/dist/components/async-action-button/classes.d.ts +11 -0
- package/dist/components/async-action-button/html.d.ts +46 -0
- package/dist/components/async-action-button/html.js +266 -0
- package/dist/components/async-action-button/index.d.ts +73 -0
- package/dist/components/async-action-button/react.d.ts +10 -0
- package/dist/components/async-action-button/react.js +224 -0
- package/dist/components/async-action-button/schema.d.ts +28 -0
- package/dist/{services/events/client/audit-log-table.d.ts → components/audit-log-table/react.d.ts} +2 -2
- package/dist/{services/events/client/audit-log-table.js → components/audit-log-table/react.js} +1964 -847
- package/dist/components/auto-height/html.d.ts +8 -0
- package/dist/components/auto-height/html.js +81 -0
- package/dist/components/auto-height/index.d.ts +2 -0
- package/dist/components/{ui/auto-height.d.ts → auto-height/react.d.ts} +2 -4
- package/dist/components/auto-height/react.js +75 -0
- package/dist/components/auto-height/schema.d.ts +7 -0
- package/dist/components/bulk-list-input/classes.d.ts +7 -0
- package/dist/components/bulk-list-input/html.d.ts +41 -0
- package/dist/components/bulk-list-input/html.js +265 -0
- package/dist/components/bulk-list-input/index.d.ts +76 -0
- package/dist/components/bulk-list-input/react.d.ts +12 -0
- package/dist/components/{ui/bulk-list-input.js → bulk-list-input/react.js} +71 -4
- package/dist/components/bulk-list-input/schema.d.ts +33 -0
- package/dist/components/choice-cards/classes.d.ts +19 -0
- package/dist/components/choice-cards/html.d.ts +76 -0
- package/dist/components/choice-cards/html.js +237 -0
- package/dist/components/choice-cards/index.d.ts +1 -0
- package/dist/components/choice-cards/react.d.ts +21 -0
- package/dist/components/{ui/choice-cards.js → choice-cards/react.js} +29 -10
- package/dist/components/choice-cards/schema.d.ts +100 -0
- package/dist/components/code-block/classes.d.ts +13 -0
- package/dist/components/code-block/html.d.ts +21 -0
- package/dist/components/code-block/html.js +381 -0
- package/dist/components/code-block/index.d.ts +4 -0
- package/dist/components/code-block/react.d.ts +4 -0
- package/dist/components/{ui/code-block.js → code-block/react.js} +168 -50
- package/dist/components/code-block/schema.d.ts +29 -0
- package/dist/components/color-input/classes.d.ts +9 -0
- package/dist/components/color-input/html.d.ts +48 -0
- package/dist/components/color-input/html.js +187 -0
- package/dist/components/color-input/index.d.ts +88 -0
- package/dist/components/color-input/react.d.ts +7 -0
- package/dist/components/{ui/color-picker.js → color-input/react.js} +165 -233
- package/dist/components/color-input/schema.d.ts +40 -0
- package/dist/components/copy-button/html.d.ts +48 -0
- package/dist/components/copy-button/html.js +266 -0
- package/dist/components/copy-button/index.d.ts +73 -0
- package/dist/components/copy-button/react.d.ts +12 -0
- package/dist/components/copy-button/react.js +234 -0
- package/dist/components/copy-button/schema.d.ts +37 -0
- package/dist/components/copy-value/html.d.ts +37 -0
- package/dist/components/copy-value/html.js +426 -0
- package/dist/components/copy-value/index.d.ts +57 -0
- package/dist/components/copy-value/react.d.ts +9 -0
- package/dist/components/{ui/copy-value.js → copy-value/react.js} +243 -65
- package/dist/components/copy-value/schema.d.ts +45 -0
- package/dist/components/cron-input/classes.d.ts +25 -0
- package/dist/components/cron-input/html.d.ts +36 -0
- package/dist/components/cron-input/html.js +204 -0
- package/dist/components/cron-input/index.d.ts +59 -0
- package/dist/components/cron-input/react.d.ts +7 -0
- package/dist/components/{ui/cron-expression-editor.js → cron-input/react.js} +126 -54
- package/dist/components/cron-input/schema.d.ts +24 -0
- package/dist/components/danger-confirmation/classes.d.ts +7 -0
- package/dist/components/danger-confirmation/html.d.ts +39 -0
- package/dist/components/danger-confirmation/html.js +227 -0
- package/dist/components/danger-confirmation/index.d.ts +113 -0
- package/dist/components/{ui/danger-confirmation.d.ts → danger-confirmation/react.d.ts} +3 -12
- package/dist/components/{ui/danger-confirmation.js → danger-confirmation/react.js} +203 -205
- package/dist/components/danger-confirmation/schema.d.ts +34 -0
- package/dist/components/data-table/classes.d.ts +63 -0
- package/dist/components/data-table/html.d.ts +1938 -0
- package/dist/components/data-table/html.js +2682 -0
- package/dist/components/data-table/index.d.ts +2686 -0
- package/dist/components/data-table/react.d.ts +578 -0
- package/dist/components/{ui/data-table.js → data-table/react.js} +1958 -835
- package/dist/components/data-table/schema.d.ts +3012 -0
- package/dist/components/date-input/classes.d.ts +17 -0
- package/dist/components/date-input/html.d.ts +60 -0
- package/dist/components/date-input/html.js +418 -0
- package/dist/components/date-input/index.d.ts +91 -0
- package/dist/components/date-input/react.d.ts +10 -0
- package/dist/components/{ui/date-picker.js → date-input/react.js} +233 -79
- package/dist/components/date-input/schema.d.ts +41 -0
- package/dist/components/editable-text/classes.d.ts +17 -0
- package/dist/components/editable-text/html.d.ts +51 -0
- package/dist/components/editable-text/html.js +370 -0
- package/dist/components/editable-text/index.d.ts +143 -0
- package/dist/components/editable-text/react.d.ts +6 -0
- package/dist/components/editable-text/react.js +345 -0
- package/dist/components/editable-text/schema.d.ts +31 -0
- package/dist/components/editing-locale-switcher/classes.d.ts +7 -0
- package/dist/components/editing-locale-switcher/html.d.ts +27 -0
- package/dist/components/editing-locale-switcher/html.js +250 -0
- package/dist/components/editing-locale-switcher/index.d.ts +52 -0
- package/dist/components/editing-locale-switcher/react.d.ts +7 -0
- package/dist/components/{ui/editing-locale-switcher.js → editing-locale-switcher/react.js} +63 -10
- package/dist/components/editing-locale-switcher/schema.d.ts +16 -0
- package/dist/components/{ui/effect-form.d.ts → effect-form/react.d.ts} +2 -2
- package/dist/components/{ui/effect-form.js → effect-form/react.js} +302 -76
- package/dist/components/effectcn/alert-dialog.d.ts +13 -0
- package/dist/components/effectcn/button.d.ts +31 -0
- package/dist/components/effectcn/calendar.d.ts +12 -0
- package/dist/components/effectcn/checkbox.d.ts +10 -0
- package/dist/components/effectcn/combobox.d.ts +25 -0
- package/dist/components/effectcn/dialog.d.ts +19 -0
- package/dist/components/effectcn/field.d.ts +11 -0
- package/dist/components/effectcn/file-drop.d.ts +8 -0
- package/dist/components/effectcn/input.d.ts +26 -0
- package/dist/components/effectcn/menu.d.ts +85 -0
- package/dist/components/effectcn/menubar.d.ts +8 -0
- package/dist/components/effectcn/popover.d.ts +18 -0
- package/dist/components/effectcn/scroll-area.d.ts +12 -0
- package/dist/components/effectcn/select.d.ts +68 -0
- package/dist/components/effectcn/toast.d.ts +29 -0
- package/dist/components/email-composer/index.d.ts +229 -0
- package/dist/components/email-composer/labels.d.ts +12 -0
- package/dist/components/email-composer/react.d.ts +5 -0
- package/dist/components/{ui/email-composer.js → email-composer/react.js} +461 -127
- package/dist/components/email-composer/schema.d.ts +42 -0
- package/dist/components/email-editor/classes.d.ts +21 -0
- package/dist/components/email-editor/html.d.ts +360 -0
- package/dist/components/email-editor/html.js +1706 -0
- package/dist/components/email-editor/index.d.ts +693 -0
- package/dist/components/{ui/email-editor.d.ts → email-editor/labels.d.ts} +1 -21
- package/dist/components/email-editor/legacy-editor.html.d.ts +160 -0
- package/dist/components/email-editor/react.d.ts +11 -0
- package/dist/components/{ui/email-editor.js → email-editor/react.js} +600 -230
- package/dist/components/email-editor/schema.d.ts +162 -0
- package/dist/components/error-component/classes.d.ts +7 -0
- package/dist/components/error-component/html.d.ts +120 -0
- package/dist/components/error-component/html.js +346 -0
- package/dist/components/error-component/index.d.ts +69 -0
- package/dist/components/error-component/react.d.ts +8 -0
- package/dist/components/{ui/error-component.js → error-component/react.js} +281 -78
- package/dist/components/error-component/schema.d.ts +56 -0
- package/dist/components/file-input/classes.d.ts +7 -0
- package/dist/components/file-input/html.d.ts +95 -0
- package/dist/components/file-input/html.js +368 -0
- package/dist/components/file-input/index.d.ts +99 -0
- package/dist/components/file-input/react.d.ts +11 -0
- package/dist/components/{ui/file-picker.js → file-input/react.js} +122 -19
- package/dist/components/file-input/schema.d.ts +37 -0
- package/dist/components/{ui/form.d.ts → form/react.d.ts} +7 -7
- package/dist/components/{ui/form.js → form/react.js} +300 -74
- package/dist/components/icon-input/html.d.ts +55 -0
- package/dist/components/icon-input/html.js +538 -0
- package/dist/components/icon-input/index.d.ts +143 -0
- package/dist/components/icon-input/react.d.ts +6 -0
- package/dist/components/{ui/icon-input.js → icon-input/react.js} +305 -89
- package/dist/components/icon-input/schema.d.ts +23 -0
- package/dist/components/image-crop-editor/classes.d.ts +19 -0
- package/dist/components/image-crop-editor/html.d.ts +66 -0
- package/dist/components/image-crop-editor/html.js +561 -0
- package/dist/components/image-crop-editor/index.d.ts +183 -0
- package/dist/components/image-crop-editor/react.d.ts +8 -0
- package/dist/components/image-crop-editor/react.js +648 -0
- package/dist/components/image-crop-editor/schema.d.ts +54 -0
- package/dist/components/krakstack-provider/html.d.ts +17 -0
- package/dist/components/krakstack-provider/html.js +37 -0
- package/dist/components/krakstack-provider/index.d.ts +7 -0
- package/dist/components/krakstack-provider/react.d.ts +8 -0
- package/dist/components/{ui/krakstack-provider.js → krakstack-provider/react.js} +14 -5
- package/dist/components/krakstack-provider/schema.d.ts +6 -0
- package/dist/components/loading/classes.d.ts +5 -0
- package/dist/components/loading/html.d.ts +18 -0
- package/dist/components/loading/html.js +166 -0
- package/dist/components/loading/index.d.ts +6 -0
- package/dist/components/loading/react.d.ts +4 -0
- package/dist/components/loading/react.js +51 -0
- package/dist/components/loading/schema.d.ts +23 -0
- package/dist/components/locale-switcher/html.d.ts +22 -0
- package/dist/components/locale-switcher/html.js +264 -0
- package/dist/components/locale-switcher/index.d.ts +50 -0
- package/dist/components/locale-switcher/react.d.ts +7 -0
- package/dist/components/{ui/locale-switcher.js → locale-switcher/react.js} +55 -22
- package/dist/components/locale-switcher/schema.d.ts +12 -0
- package/dist/components/map-menu/classes.d.ts +13 -0
- package/dist/components/map-menu/google-maps.d.ts +80 -0
- package/dist/components/map-menu/google-viewport.d.ts +7 -0
- package/dist/components/map-menu/html.d.ts +274 -0
- package/dist/components/map-menu/html.js +934 -0
- package/dist/components/map-menu/index.d.ts +246 -0
- package/dist/components/map-menu/map.d.ts +47 -0
- package/dist/components/map-menu/react.d.ts +40 -0
- package/dist/components/{ui/map-menu.js → map-menu/react.js} +321 -83
- package/dist/components/map-menu/schema.d.ts +132 -0
- package/dist/components/markdown/classes.d.ts +1 -0
- package/dist/components/markdown/html.d.ts +23 -0
- package/dist/components/markdown/html.js +510 -0
- package/dist/components/markdown/index.d.ts +6 -0
- package/dist/components/markdown/react.d.ts +3 -0
- package/dist/components/markdown/react.js +392 -0
- package/dist/components/markdown/schema.d.ts +20 -0
- package/dist/components/notification-menu/classes.d.ts +11 -0
- package/dist/components/notification-menu/html.d.ts +67 -0
- package/dist/components/notification-menu/html.js +425 -0
- package/dist/components/notification-menu/index.d.ts +132 -0
- package/dist/components/notification-menu/react.d.ts +57 -0
- package/dist/components/notification-menu/react.js +829 -0
- package/dist/components/notification-menu/schema.d.ts +59 -0
- package/dist/components/pagination/classes.d.ts +19 -0
- package/dist/components/pagination/html.d.ts +49 -0
- package/dist/components/pagination/html.js +387 -0
- package/dist/components/pagination/index.d.ts +109 -0
- package/dist/components/pagination/react.d.ts +9 -0
- package/dist/components/{ui/pagination.js → pagination/react.js} +123 -23
- package/dist/components/pagination/schema.d.ts +36 -0
- package/dist/components/phone-number-input/classes.d.ts +17 -0
- package/dist/components/phone-number-input/html.d.ts +52 -0
- package/dist/components/phone-number-input/html.js +655 -0
- package/dist/components/phone-number-input/index.d.ts +59 -0
- package/dist/components/phone-number-input/react.d.ts +11 -0
- package/dist/components/{ui/phone-number-input.js → phone-number-input/react.js} +368 -138
- package/dist/components/phone-number-input/schema.d.ts +31 -0
- package/dist/components/presence-transition/html.d.ts +13 -0
- package/dist/components/presence-transition/html.js +128 -0
- package/dist/components/presence-transition/index.d.ts +57 -0
- package/dist/components/{ui/presence-transition.d.ts → presence-transition/react.d.ts} +3 -5
- package/dist/components/presence-transition/react.js +139 -0
- package/dist/components/presence-transition/schema.d.ts +7 -0
- package/dist/components/registry-previews/component-example.d.ts +31 -0
- package/dist/components/registry-previews/component-example.js +525 -0
- package/dist/components/registry-previews/html-preview.d.ts +17 -0
- package/dist/components/registry-previews/html-preview.js +83 -0
- package/dist/components/rich-text-editor/classes.d.ts +15 -0
- package/dist/components/rich-text-editor/engine.d.ts +9 -0
- package/dist/components/rich-text-editor/html.d.ts +246 -0
- package/dist/components/rich-text-editor/html.js +830 -0
- package/dist/components/rich-text-editor/index.d.ts +453 -0
- package/dist/components/rich-text-editor/labels.d.ts +42 -0
- package/dist/components/rich-text-editor/react.d.ts +19 -0
- package/dist/components/{ui/rich-text-editor.js → rich-text-editor/react.js} +365 -96
- package/dist/components/rich-text-editor/schema.d.ts +116 -0
- package/dist/components/search-menu/classes.d.ts +9 -0
- package/dist/components/search-menu/html.d.ts +127 -0
- package/dist/components/search-menu/html.js +432 -0
- package/dist/components/search-menu/index.d.ts +85 -0
- package/dist/components/search-menu/react.d.ts +18 -0
- package/dist/components/{ui/search-menu.js → search-menu/react.js} +128 -23
- package/dist/components/search-menu/schema.d.ts +78 -0
- package/dist/components/select-with-custom-input/classes.d.ts +17 -0
- package/dist/components/select-with-custom-input/html.d.ts +60 -0
- package/dist/components/select-with-custom-input/html.js +238 -0
- package/dist/components/select-with-custom-input/index.d.ts +114 -0
- package/dist/components/select-with-custom-input/react.d.ts +7 -0
- package/dist/components/{ui/select-with-custom-input.js → select-with-custom-input/react.js} +127 -22
- package/dist/components/select-with-custom-input/schema.d.ts +54 -0
- package/dist/components/sidebar-layout/classes.d.ts +21 -0
- package/dist/components/sidebar-layout/html.d.ts +97 -0
- package/dist/components/sidebar-layout/html.js +361 -0
- package/dist/components/sidebar-layout/index.d.ts +57 -0
- package/dist/components/sidebar-layout/react.d.ts +30 -0
- package/dist/components/{ui/sidebar-layout.js → sidebar-layout/react.js} +199 -39
- package/dist/components/sidebar-layout/schema.d.ts +54 -0
- package/dist/components/stats-card/classes.d.ts +11 -0
- package/dist/components/stats-card/html.d.ts +15 -0
- package/dist/components/stats-card/html.js +55 -0
- package/dist/components/stats-card/react.d.ts +7 -0
- package/dist/components/{ui/stats-card.js → stats-card/react.js} +19 -15
- package/dist/components/stats-card/schema.d.ts +14 -0
- package/dist/components/stepper/classes.d.ts +39 -0
- package/dist/components/stepper/html.d.ts +107 -0
- package/dist/components/stepper/html.js +397 -0
- package/dist/components/stepper/index.d.ts +83 -0
- package/dist/components/stepper/react.d.ts +17 -0
- package/dist/components/{ui/stepper.js → stepper/react.js} +120 -21
- package/dist/components/stepper/schema.d.ts +52 -0
- package/dist/components/support/classes.d.ts +55 -0
- package/dist/components/support/form.d.ts +19 -0
- package/dist/components/support/html.d.ts +266 -0
- package/dist/components/support/html.js +604 -0
- package/dist/components/support/index.d.ts +226 -0
- package/dist/components/support/multipart.d.ts +21 -0
- package/dist/components/support/react.d.ts +54 -0
- package/dist/components/support/react.js +1098 -0
- package/dist/components/support/schema.d.ts +69 -0
- package/dist/components/support.d.ts +1 -66
- package/dist/components/theme-switcher/html.d.ts +28 -0
- package/dist/components/theme-switcher/html.js +288 -0
- package/dist/components/theme-switcher/index.d.ts +59 -0
- package/dist/components/{ui/theme-switcher.d.ts → theme-switcher/react.d.ts} +4 -12
- package/dist/components/{ui/theme-switcher.js → theme-switcher/react.js} +69 -35
- package/dist/components/theme-switcher/schema.d.ts +33 -0
- package/dist/components/time-input/classes.d.ts +23 -0
- package/dist/components/time-input/html.d.ts +75 -0
- package/dist/components/time-input/html.js +571 -0
- package/dist/components/time-input/index.d.ts +164 -0
- package/dist/components/time-input/react.d.ts +7 -0
- package/dist/components/{ui/time-picker.js → time-input/react.js} +286 -114
- package/dist/components/time-input/schema.d.ts +96 -0
- package/dist/components/timezone-input/classes.d.ts +13 -0
- package/dist/components/timezone-input/html.d.ts +58 -0
- package/dist/components/timezone-input/html.js +804 -0
- package/dist/components/timezone-input/index.d.ts +170 -0
- package/dist/components/timezone-input/react.d.ts +9 -0
- package/dist/components/{ui/timezone-select.js → timezone-input/react.js} +337 -104
- package/dist/components/timezone-input/schema.d.ts +43 -0
- package/dist/components/toast/classes.d.ts +7 -0
- package/dist/components/toast/html.d.ts +34 -0
- package/dist/components/toast/html.js +280 -0
- package/dist/components/toast/index.d.ts +10 -0
- package/dist/components/toast/react.d.ts +9 -0
- package/dist/components/{ui/toast.js → toast/react.js} +35 -15
- package/dist/components/toast/schema.d.ts +24 -0
- package/dist/{services/events/client/tracking-notice.d.ts → components/tracking-notice/react.d.ts} +7 -1
- package/dist/{services/events/client/tracking-notice.js → components/tracking-notice/react.js} +13 -7
- package/dist/components/ui/animated-list.d.ts +1 -21
- package/dist/components/ui/app-brand.d.ts +1 -33
- package/dist/components/ui/async-action-button.d.ts +1 -17
- package/dist/components/ui/code-block.d.ts +1 -14
- package/dist/components/ui/copy-button.d.ts +1 -21
- package/dist/components/ui/data-table.d.ts +1 -584
- package/dist/components/ui/krakstack-provider.d.ts +1 -9
- package/dist/components/ui/loading.d.ts +1 -13
- package/dist/components/ui/pagination.d.ts +1 -47
- package/dist/components/ui/rich-text-editor.d.ts +1 -72
- package/dist/components/ui/search-menu.d.ts +1 -36
- package/dist/components/ui/sidebar-layout.d.ts +1 -40
- package/dist/components/ui/virtualized-combobox.d.ts +1 -59
- package/dist/components/unsaved-changes-guard/html.d.ts +34 -0
- package/dist/components/unsaved-changes-guard/html.js +172 -0
- package/dist/components/unsaved-changes-guard/index.d.ts +56 -0
- package/dist/components/unsaved-changes-guard/react.d.ts +4 -0
- package/dist/components/{ui/unsaved-changes-guard.js → unsaved-changes-guard/react.js} +74 -11
- package/dist/components/unsaved-changes-guard/schema.d.ts +37 -0
- package/dist/components/upload-attachment/classes.d.ts +11 -0
- package/dist/components/upload-attachment/html.d.ts +84 -0
- package/dist/components/upload-attachment/html.js +312 -0
- package/dist/components/upload-attachment/index.d.ts +72 -0
- package/dist/components/upload-attachment/react.d.ts +9 -0
- package/dist/components/{ui/upload-attachment.js → upload-attachment/react.js} +114 -17
- package/dist/components/upload-attachment/schema.d.ts +53 -0
- package/dist/components/virtualized-combobox/classes.d.ts +7 -0
- package/dist/components/virtualized-combobox/html.d.ts +97 -0
- package/dist/components/virtualized-combobox/html.js +310 -0
- package/dist/components/virtualized-combobox/index.d.ts +182 -0
- package/dist/components/virtualized-combobox/react.d.ts +31 -0
- package/dist/components/{ui/virtualized-combobox.js → virtualized-combobox/react.js} +160 -40
- package/dist/components/virtualized-combobox/schema.d.ts +92 -0
- package/dist/components/webhook-delivery-table/html.d.ts +216 -0
- package/dist/components/webhook-delivery-table/html.js +3008 -0
- package/dist/components/webhook-delivery-table/index.d.ts +405 -0
- package/dist/components/webhook-delivery-table/react.d.ts +13 -0
- package/dist/{services/webhooks/client/delivery-table.js → components/webhook-delivery-table/react.js} +2278 -917
- package/dist/components/webhook-delivery-table/schema.d.ts +134 -0
- package/dist/lib/docs.d.ts +17 -1
- package/dist/lib/docs.integrations.server.js +341 -75
- package/dist/lib/docs.js +715 -299
- package/dist/lib/docs.server.js +325 -59
- package/dist/lib/documentation-toolkit.d.ts +4 -4
- package/dist/lib/documentation-toolkit.js +337 -71
- package/dist/lib/effect-ui-adapter/model-runtime.d.ts +17 -0
- package/dist/lib/effect-ui-adapter/use-model.d.ts +9 -0
- package/dist/lib/effect-ui-adapter/use-model.js +158 -0
- package/dist/lib/effectcn-form.d.ts +3 -0
- package/dist/lib/effectcn-form.js +54 -0
- package/dist/lib/email-composer/index.d.ts +12 -0
- package/dist/lib/email-composer/schema.d.ts +14 -0
- package/dist/lib/httpapi-toolkit.d.ts +1 -1
- package/dist/lib/lucide-effect.d.ts +39 -0
- package/dist/lib/markdown/content.d.ts +1 -12
- package/dist/lib/rich-text/model.d.ts +5 -0
- package/dist/lib/webfetch-toolkit.d.ts +1 -1
- package/dist/services/agent/client/index.js +530 -168
- package/dist/services/agent/client/widget.d.ts +1 -55
- package/dist/services/notification/client/index.js +138 -27
- package/dist/services/notification/client/notification-menu.d.ts +1 -85
- package/dist/services/notification/public.js +138 -27
- package/dist/services/opentelemetry/browser.js +15 -9
- package/dist/services/webhooks/index.d.ts +4 -3
- package/package.json +185 -142
- package/dist/components/support-dialog.js +0 -881
- package/dist/components/support.js +0 -881
- package/dist/components/ui/animated-number.js +0 -75
- package/dist/components/ui/app-brand.js +0 -126
- package/dist/components/ui/app-switcher.d.ts +0 -26
- package/dist/components/ui/async-action-button.js +0 -149
- package/dist/components/ui/auto-height.js +0 -86
- package/dist/components/ui/bulk-list-input.d.ts +0 -25
- package/dist/components/ui/choice-cards.d.ts +0 -33
- package/dist/components/ui/color-picker.d.ts +0 -31
- package/dist/components/ui/copy-button.js +0 -138
- package/dist/components/ui/copy-value.d.ts +0 -24
- package/dist/components/ui/cron-expression-editor.d.ts +0 -16
- package/dist/components/ui/cron-expression-editor.schema.d.ts +0 -7
- package/dist/components/ui/date-picker.d.ts +0 -33
- package/dist/components/ui/date-picker.schema.d.ts +0 -9
- package/dist/components/ui/editable-text.d.ts +0 -19
- package/dist/components/ui/editable-text.js +0 -341
- package/dist/components/ui/editing-locale-switcher.d.ts +0 -11
- package/dist/components/ui/error-component.d.ts +0 -34
- package/dist/components/ui/file-picker.d.ts +0 -37
- package/dist/components/ui/icon-input.d.ts +0 -58
- package/dist/components/ui/image-crop-editor.d.ts +0 -41
- package/dist/components/ui/image-crop-editor.js +0 -417
- package/dist/components/ui/loading.js +0 -39
- package/dist/components/ui/locale-switcher.d.ts +0 -11
- package/dist/components/ui/map-menu-map.d.ts +0 -115
- package/dist/components/ui/map-menu.d.ts +0 -87
- package/dist/components/ui/phone-number-input.d.ts +0 -22
- package/dist/components/ui/phone-number-input.schema.d.ts +0 -7
- package/dist/components/ui/presence-transition.js +0 -94
- package/dist/components/ui/select-with-custom-input.d.ts +0 -36
- package/dist/components/ui/stats-card.d.ts +0 -12
- package/dist/components/ui/stepper.d.ts +0 -37
- package/dist/components/ui/time-picker.d.ts +0 -50
- package/dist/components/ui/time-picker.schema.d.ts +0 -28
- package/dist/components/ui/timezone-select.d.ts +0 -57
- package/dist/components/ui/timezone-select.schema.d.ts +0 -9
- package/dist/components/ui/toast.d.ts +0 -18
- package/dist/components/ui/unsaved-changes-guard.d.ts +0 -16
- package/dist/components/ui/upload-attachment.d.ts +0 -39
- package/dist/services/notification/persistence/drizzle.d.ts +0 -868
- package/dist/services/notification/persistence/drizzle.js +0 -214
- package/dist/services/notification/persistence/index.d.ts +0 -2
- package/dist/services/notification/persistence/index.js +0 -227
- package/dist/services/notification/persistence/schema.d.ts +0 -143
- package/dist/services/notification/persistence/schema.js +0 -118
- package/dist/services/webhooks/client/delivery-table.d.ts +0 -62
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
// ../../src/components/
|
|
2
|
-
import { useAtom, useAtomSet } from "@effect/atom-react";
|
|
1
|
+
// ../../src/components/data-table/react.tsx
|
|
3
2
|
import { ScrollArea as ScrollAreaPrimitive2 } from "@base-ui/react/scroll-area";
|
|
4
|
-
import { BrowserKeyValueStore } from "@effect/platform-browser";
|
|
5
3
|
import { useVirtualizer, useWindowVirtualizer } from "@tanstack/react-virtual";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { AsyncResult, Atom } from "effect/reactivity";
|
|
4
|
+
import { Formatter, Option as Option4, Schema as Schema6 } from "effect";
|
|
5
|
+
import { Component as Component3, View } from "effect/ui";
|
|
9
6
|
import {
|
|
10
7
|
ArrowDown,
|
|
11
8
|
ArrowUp,
|
|
@@ -34,11 +31,13 @@ import {
|
|
|
34
31
|
isValidElement,
|
|
35
32
|
useCallback,
|
|
36
33
|
useContext,
|
|
34
|
+
useEffect,
|
|
37
35
|
useId as useId2,
|
|
38
36
|
useLayoutEffect,
|
|
39
37
|
useMemo as useMemo2,
|
|
40
38
|
useRef,
|
|
41
|
-
useState
|
|
39
|
+
useState,
|
|
40
|
+
useSyncExternalStore
|
|
42
41
|
} from "react";
|
|
43
42
|
import { createPortal } from "react-dom";
|
|
44
43
|
|
|
@@ -504,38 +503,51 @@ function SelectScrollDownButton({
|
|
|
504
503
|
});
|
|
505
504
|
}
|
|
506
505
|
|
|
507
|
-
// ../../src/components/
|
|
506
|
+
// ../../src/components/loading/react.tsx
|
|
508
507
|
import { Loader2 } from "lucide-react";
|
|
509
|
-
import { useKrakstackLocale } from "@krak-stack/registry/krakstack-provider";
|
|
510
|
-
|
|
508
|
+
import { useKrakstackLocale } from "@krak-stack/registry/krakstack-provider/react";
|
|
509
|
+
|
|
510
|
+
// ../../src/components/loading/classes.ts
|
|
511
|
+
var resolveLoadingClasses = ({
|
|
512
|
+
classes,
|
|
513
|
+
variant,
|
|
514
|
+
className
|
|
515
|
+
}) => ({
|
|
516
|
+
root: cn(classes?.root ?? "text-muted-foreground flex items-center justify-center gap-2 text-sm", variant === "centered" && (classes?.centered ?? "min-h-[50svh] w-full"), className),
|
|
517
|
+
icon: classes?.icon ?? "size-4 motion-safe:animate-spin"
|
|
518
|
+
});
|
|
519
|
+
|
|
520
|
+
// ../../src/components/loading/index.ts
|
|
511
521
|
var labels = {
|
|
512
|
-
en:
|
|
513
|
-
|
|
514
|
-
},
|
|
515
|
-
fr: {
|
|
516
|
-
loading: "Chargement..."
|
|
517
|
-
}
|
|
522
|
+
en: "Loading...",
|
|
523
|
+
fr: "Chargement..."
|
|
518
524
|
};
|
|
519
|
-
var loadingLabel = (locale, messages) => messages?.[locale]?.loading ?? messages?.[locale.split("-")[0] ?? locale]?.loading ?? (locale.startsWith("fr") ? labels.fr
|
|
525
|
+
var loadingLabel = (locale, messages) => messages?.[locale]?.loading ?? messages?.[locale.split("-")[0] ?? locale]?.loading ?? (locale.startsWith("fr") ? labels.fr : labels.en);
|
|
526
|
+
|
|
527
|
+
// ../../src/components/loading/react.tsx
|
|
528
|
+
import { jsx as jsx9, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
520
529
|
function Loading({
|
|
521
530
|
className,
|
|
531
|
+
classes,
|
|
522
532
|
label,
|
|
523
533
|
locale: localeOverride,
|
|
524
534
|
messages,
|
|
525
535
|
variant = "inline"
|
|
526
536
|
}) {
|
|
527
537
|
const locale = useKrakstackLocale(localeOverride);
|
|
538
|
+
const slots = resolveLoadingClasses({ classes, variant, className });
|
|
528
539
|
return /* @__PURE__ */ jsxs4("div", {
|
|
529
|
-
|
|
540
|
+
role: "status",
|
|
541
|
+
className: slots.root,
|
|
530
542
|
children: [
|
|
531
543
|
/* @__PURE__ */ jsx9(Loader2, {
|
|
532
|
-
|
|
544
|
+
"aria-hidden": "true",
|
|
545
|
+
className: slots.icon
|
|
533
546
|
}),
|
|
534
547
|
label ?? loadingLabel(locale, messages)
|
|
535
548
|
]
|
|
536
549
|
});
|
|
537
550
|
}
|
|
538
|
-
|
|
539
551
|
// ../../src/components/ui/menubar.tsx
|
|
540
552
|
import { Menu as MenuPrimitive2 } from "@base-ui/react/menu";
|
|
541
553
|
import { Menubar as MenubarPrimitive } from "@base-ui/react/menubar";
|
|
@@ -710,7 +722,7 @@ function MenubarSubContent({
|
|
|
710
722
|
});
|
|
711
723
|
}
|
|
712
724
|
|
|
713
|
-
// ../../src/components/
|
|
725
|
+
// ../../src/components/pagination/react.tsx
|
|
714
726
|
import {
|
|
715
727
|
ChevronLeft,
|
|
716
728
|
ChevronRight,
|
|
@@ -718,8 +730,79 @@ import {
|
|
|
718
730
|
ChevronsRight
|
|
719
731
|
} from "lucide-react";
|
|
720
732
|
import { useId } from "react";
|
|
721
|
-
import { useKrakstackLocale as useKrakstackLocale2 } from "@krak-stack/registry/krakstack-provider";
|
|
722
|
-
|
|
733
|
+
import { useKrakstackLocale as useKrakstackLocale2 } from "@krak-stack/registry/krakstack-provider/react";
|
|
734
|
+
|
|
735
|
+
// ../../src/components/pagination/classes.ts
|
|
736
|
+
var paginationClasses = {
|
|
737
|
+
root: "flex flex-col gap-3 px-2 sm:flex-row sm:items-center sm:justify-between",
|
|
738
|
+
summary: "text-muted-foreground flex flex-wrap items-center gap-x-3 gap-y-1 text-sm",
|
|
739
|
+
controls: "flex items-center gap-4 sm:justify-end",
|
|
740
|
+
controlGroup: "flex items-center gap-2",
|
|
741
|
+
navigation: "flex items-center gap-1",
|
|
742
|
+
compactRoot: "gap-2 px-0 sm:flex-col sm:items-stretch",
|
|
743
|
+
compactControls: "flex-wrap justify-between gap-2 sm:justify-between"
|
|
744
|
+
};
|
|
745
|
+
var resolvePaginationClasses = (overrides) => ({
|
|
746
|
+
...paginationClasses,
|
|
747
|
+
...overrides
|
|
748
|
+
});
|
|
749
|
+
|
|
750
|
+
// ../../src/components/pagination/index.ts
|
|
751
|
+
import { Schema as Schema2 } from "effect";
|
|
752
|
+
import { Component, UiSchema } from "effect/ui";
|
|
753
|
+
|
|
754
|
+
// ../../src/components/pagination/schema.ts
|
|
755
|
+
import { Schema, Struct } from "effect";
|
|
756
|
+
var Labels = Schema.Struct({
|
|
757
|
+
pageSize: Schema.optional(Schema.String),
|
|
758
|
+
goToFirstPage: Schema.optional(Schema.String),
|
|
759
|
+
goToPreviousPage: Schema.optional(Schema.String),
|
|
760
|
+
goToNextPage: Schema.optional(Schema.String),
|
|
761
|
+
goToLastPage: Schema.optional(Schema.String)
|
|
762
|
+
}).annotate({ identifier: "PaginationLabelOverrides" });
|
|
763
|
+
var Translations = Schema.Record(Schema.String, Schema.UndefinedOr(Labels));
|
|
764
|
+
var PaginationClassesOverridesSchema = Schema.Record(Schema.Literals(Struct.keys(paginationClasses)), Schema.optionalKey(Schema.String)).annotate({ identifier: "PaginationClassesOverrides" });
|
|
765
|
+
var PaginationPropsSchema = Schema.Struct({
|
|
766
|
+
classes: Schema.optional(PaginationClassesOverridesSchema),
|
|
767
|
+
className: Schema.optional(Schema.String),
|
|
768
|
+
pageSizeContentClassName: Schema.optional(Schema.String),
|
|
769
|
+
compact: Schema.optional(Schema.Boolean),
|
|
770
|
+
locale: Schema.optional(Schema.String),
|
|
771
|
+
messages: Schema.optional(Translations),
|
|
772
|
+
page: Schema.Int,
|
|
773
|
+
pageCount: Schema.Int,
|
|
774
|
+
pageSize: Schema.Int,
|
|
775
|
+
pageSizes: Schema.optional(Schema.Array(Schema.Int)),
|
|
776
|
+
selectedRows: Schema.optional(Schema.Int),
|
|
777
|
+
showResults: Schema.optional(Schema.Boolean),
|
|
778
|
+
totalRows: Schema.Int
|
|
779
|
+
}).annotate({ identifier: "PaginationProps" });
|
|
780
|
+
|
|
781
|
+
// ../../src/components/pagination/index.ts
|
|
782
|
+
var PaginationMessage = UiSchema.TaggedEnum({
|
|
783
|
+
Opened: {},
|
|
784
|
+
Closed: {},
|
|
785
|
+
PageRequested: { page: Schema2.Int },
|
|
786
|
+
SizeRequested: { pageSize: Schema2.Int }
|
|
787
|
+
}).annotate({ identifier: "PaginationMessage" });
|
|
788
|
+
var PaginationEvents = UiSchema.TaggedEnum({
|
|
789
|
+
PageChanged: { page: Schema2.Int },
|
|
790
|
+
PageSizeChanged: { pageSize: Schema2.Int }
|
|
791
|
+
}).annotate({ identifier: "PaginationEvents" });
|
|
792
|
+
var paginationOptions = {
|
|
793
|
+
name: "Pagination",
|
|
794
|
+
props: PaginationPropsSchema,
|
|
795
|
+
model: Schema2.Boolean,
|
|
796
|
+
message: PaginationMessage,
|
|
797
|
+
events: PaginationEvents,
|
|
798
|
+
restore: false
|
|
799
|
+
};
|
|
800
|
+
var update = Component.define(paginationOptions).update({
|
|
801
|
+
Opened: () => true,
|
|
802
|
+
Closed: () => false,
|
|
803
|
+
PageRequested: ($, { page }) => $.set($.model).emit(PaginationEvents.PageChanged({ page })),
|
|
804
|
+
SizeRequested: ($, { pageSize }) => $.set(false).emit(PaginationEvents.PageSizeChanged({ pageSize }))
|
|
805
|
+
});
|
|
723
806
|
var messages = {
|
|
724
807
|
en: {
|
|
725
808
|
pageSize: "Page size",
|
|
@@ -747,7 +830,35 @@ var paginationMessages = (locale = "en", translations) => ({
|
|
|
747
830
|
...translations?.[locale.split("-")[0] ?? locale],
|
|
748
831
|
...translations?.[locale]
|
|
749
832
|
});
|
|
833
|
+
var defaultPageSizes = [20, 50, 100];
|
|
834
|
+
var paginationPageLabel = (page, pageCount, pageOf) => pageCount > 0 ? pageOf(page + 1, pageCount) : undefined;
|
|
835
|
+
var paginationNavigation = (page, pageCount) => ({
|
|
836
|
+
goToFirstPage: {
|
|
837
|
+
page: 0,
|
|
838
|
+
disabled: pageCount <= 0 || page <= 0,
|
|
839
|
+
edge: true
|
|
840
|
+
},
|
|
841
|
+
goToPreviousPage: {
|
|
842
|
+
page: page - 1,
|
|
843
|
+
disabled: pageCount <= 0 || page <= 0,
|
|
844
|
+
edge: false
|
|
845
|
+
},
|
|
846
|
+
goToNextPage: {
|
|
847
|
+
page: page + 1,
|
|
848
|
+
disabled: pageCount <= 0 || page + 1 >= pageCount,
|
|
849
|
+
edge: false
|
|
850
|
+
},
|
|
851
|
+
goToLastPage: {
|
|
852
|
+
page: pageCount - 1,
|
|
853
|
+
disabled: pageCount <= 0 || page + 1 >= pageCount,
|
|
854
|
+
edge: true
|
|
855
|
+
}
|
|
856
|
+
});
|
|
857
|
+
|
|
858
|
+
// ../../src/components/pagination/react.tsx
|
|
859
|
+
import { jsx as jsx11, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
750
860
|
function Pagination({
|
|
861
|
+
classes: classOverrides,
|
|
751
862
|
className,
|
|
752
863
|
pageSizeContentClassName,
|
|
753
864
|
compact = false,
|
|
@@ -758,22 +869,23 @@ function Pagination({
|
|
|
758
869
|
page,
|
|
759
870
|
pageCount,
|
|
760
871
|
pageSize,
|
|
761
|
-
pageSizes =
|
|
872
|
+
pageSizes = defaultPageSizes,
|
|
762
873
|
selectedRows = 0,
|
|
763
874
|
showResults = true,
|
|
764
875
|
totalRows
|
|
765
876
|
}) {
|
|
877
|
+
const paginationClasses = resolvePaginationClasses(classOverrides);
|
|
766
878
|
const locale = useKrakstackLocale2(localeOverride);
|
|
767
879
|
const labels = paginationMessages(locale, messageOverrides);
|
|
768
880
|
const pageSizeId = useId();
|
|
769
|
-
const
|
|
770
|
-
const
|
|
881
|
+
const navigation = paginationNavigation(page, pageCount);
|
|
882
|
+
const pageLabel = paginationPageLabel(page, pageCount, labels.pageOf);
|
|
771
883
|
return /* @__PURE__ */ jsxs6("div", {
|
|
772
884
|
"data-slot": "pagination",
|
|
773
|
-
className: cn(
|
|
885
|
+
className: cn(paginationClasses.root, compact && paginationClasses.compactRoot, className),
|
|
774
886
|
children: [
|
|
775
887
|
showResults ? /* @__PURE__ */ jsxs6("div", {
|
|
776
|
-
className:
|
|
888
|
+
className: paginationClasses.summary,
|
|
777
889
|
children: [
|
|
778
890
|
/* @__PURE__ */ jsx11("span", {
|
|
779
891
|
children: labels.results(totalRows)
|
|
@@ -784,10 +896,10 @@ function Pagination({
|
|
|
784
896
|
]
|
|
785
897
|
}) : null,
|
|
786
898
|
/* @__PURE__ */ jsxs6("div", {
|
|
787
|
-
className: cn(
|
|
899
|
+
className: cn(paginationClasses.controls, compact && paginationClasses.compactControls),
|
|
788
900
|
children: [
|
|
789
901
|
/* @__PURE__ */ jsxs6("div", {
|
|
790
|
-
className:
|
|
902
|
+
className: paginationClasses.controlGroup,
|
|
791
903
|
children: [
|
|
792
904
|
/* @__PURE__ */ jsx11(Label, {
|
|
793
905
|
htmlFor: pageSizeId,
|
|
@@ -822,19 +934,19 @@ function Pagination({
|
|
|
822
934
|
]
|
|
823
935
|
}),
|
|
824
936
|
/* @__PURE__ */ jsxs6("div", {
|
|
825
|
-
className:
|
|
937
|
+
className: paginationClasses.controlGroup,
|
|
826
938
|
children: [
|
|
827
|
-
/* @__PURE__ */ jsx11("div", {
|
|
939
|
+
pageLabel !== undefined && /* @__PURE__ */ jsx11("div", {
|
|
828
940
|
className: "flex items-center justify-center text-sm font-medium sm:block",
|
|
829
|
-
children:
|
|
941
|
+
children: pageLabel
|
|
830
942
|
}),
|
|
831
943
|
/* @__PURE__ */ jsxs6("div", {
|
|
832
|
-
className:
|
|
944
|
+
className: paginationClasses.navigation,
|
|
833
945
|
children: [
|
|
834
946
|
/* @__PURE__ */ jsxs6(Button, {
|
|
835
947
|
className: cn("hidden h-8 w-8 p-0 lg:flex", compact && "!hidden"),
|
|
836
|
-
disabled:
|
|
837
|
-
onClick: () => onPageChange(
|
|
948
|
+
disabled: navigation.goToFirstPage.disabled,
|
|
949
|
+
onClick: () => onPageChange(navigation.goToFirstPage.page),
|
|
838
950
|
type: "button",
|
|
839
951
|
children: [
|
|
840
952
|
/* @__PURE__ */ jsx11("span", {
|
|
@@ -846,8 +958,8 @@ function Pagination({
|
|
|
846
958
|
}),
|
|
847
959
|
/* @__PURE__ */ jsxs6(Button, {
|
|
848
960
|
className: "h-8 w-8 p-0",
|
|
849
|
-
disabled:
|
|
850
|
-
onClick: () => onPageChange(page
|
|
961
|
+
disabled: navigation.goToPreviousPage.disabled,
|
|
962
|
+
onClick: () => onPageChange(navigation.goToPreviousPage.page),
|
|
851
963
|
type: "button",
|
|
852
964
|
children: [
|
|
853
965
|
/* @__PURE__ */ jsx11("span", {
|
|
@@ -859,8 +971,8 @@ function Pagination({
|
|
|
859
971
|
}),
|
|
860
972
|
/* @__PURE__ */ jsxs6(Button, {
|
|
861
973
|
className: "h-8 w-8 p-0",
|
|
862
|
-
disabled:
|
|
863
|
-
onClick: () => onPageChange(page
|
|
974
|
+
disabled: navigation.goToNextPage.disabled,
|
|
975
|
+
onClick: () => onPageChange(navigation.goToNextPage.page),
|
|
864
976
|
type: "button",
|
|
865
977
|
children: [
|
|
866
978
|
/* @__PURE__ */ jsx11("span", {
|
|
@@ -872,8 +984,8 @@ function Pagination({
|
|
|
872
984
|
}),
|
|
873
985
|
/* @__PURE__ */ jsxs6(Button, {
|
|
874
986
|
className: cn("hidden h-8 w-8 p-0 lg:flex", compact && "!hidden"),
|
|
875
|
-
disabled:
|
|
876
|
-
onClick: () => onPageChange(
|
|
987
|
+
disabled: navigation.goToLastPage.disabled,
|
|
988
|
+
onClick: () => onPageChange(navigation.goToLastPage.page),
|
|
877
989
|
type: "button",
|
|
878
990
|
children: [
|
|
879
991
|
/* @__PURE__ */ jsx11("span", {
|
|
@@ -892,7 +1004,6 @@ function Pagination({
|
|
|
892
1004
|
]
|
|
893
1005
|
});
|
|
894
1006
|
}
|
|
895
|
-
|
|
896
1007
|
// ../../src/components/ui/scroll-area.tsx
|
|
897
1008
|
import { ScrollArea as ScrollAreaPrimitive } from "@base-ui/react/scroll-area";
|
|
898
1009
|
import { jsx as jsx12, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
@@ -1045,7 +1156,7 @@ import {
|
|
|
1045
1156
|
DateTime,
|
|
1046
1157
|
Effect,
|
|
1047
1158
|
Option,
|
|
1048
|
-
Schema,
|
|
1159
|
+
Schema as Schema3,
|
|
1049
1160
|
SchemaGetter,
|
|
1050
1161
|
SchemaIssue,
|
|
1051
1162
|
SchemaTransformation
|
|
@@ -1057,25 +1168,25 @@ var parseSortParam = (sort) => {
|
|
|
1057
1168
|
}
|
|
1058
1169
|
return { id, direction: sort.startsWith("-") ? "desc" : "asc" };
|
|
1059
1170
|
};
|
|
1060
|
-
var SortDirection =
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
]).pipe(
|
|
1171
|
+
var SortDirection = Schema3.Union([
|
|
1172
|
+
Schema3.Literal("asc"),
|
|
1173
|
+
Schema3.Literal("desc")
|
|
1174
|
+
]).pipe(Schema3.annotate({
|
|
1064
1175
|
identifier: "SortDirection",
|
|
1065
1176
|
title: "Sort Direction",
|
|
1066
1177
|
description: "Sort direction for list query results.",
|
|
1067
1178
|
examples: ["asc", "desc"]
|
|
1068
1179
|
}));
|
|
1069
|
-
var SortParam =
|
|
1070
|
-
id:
|
|
1180
|
+
var SortParam = Schema3.Struct({
|
|
1181
|
+
id: Schema3.NonEmptyString,
|
|
1071
1182
|
direction: SortDirection
|
|
1072
|
-
}).pipe(
|
|
1183
|
+
}).pipe(Schema3.annotate({
|
|
1073
1184
|
identifier: "SortParam",
|
|
1074
1185
|
title: "Sort Parameter",
|
|
1075
1186
|
description: "Decoded sort parameter with a field id and direction.",
|
|
1076
1187
|
examples: [{ id: "publicName", direction: "asc" }]
|
|
1077
1188
|
}));
|
|
1078
|
-
var SortParamFromString =
|
|
1189
|
+
var SortParamFromString = Schema3.String.pipe(Schema3.decodeTo(SortParam, SchemaTransformation.transformEffect({
|
|
1079
1190
|
decode: (sort) => {
|
|
1080
1191
|
const sortParam = parseSortParam(sort);
|
|
1081
1192
|
if (!sortParam) {
|
|
@@ -1084,13 +1195,13 @@ var SortParamFromString = Schema.String.pipe(Schema.decodeTo(SortParam, SchemaTr
|
|
|
1084
1195
|
return Effect.succeed(sortParam);
|
|
1085
1196
|
},
|
|
1086
1197
|
encode: (sort) => Effect.succeed(sort.direction === "desc" ? `-${sort.id}` : sort.id)
|
|
1087
|
-
})),
|
|
1198
|
+
})), Schema3.annotate({
|
|
1088
1199
|
identifier: "SortParamFromString",
|
|
1089
1200
|
title: "Sort Parameter From String",
|
|
1090
1201
|
description: 'URL encoded single sort parameter where descending fields are prefixed with "-".',
|
|
1091
1202
|
examples: [{ id: "publicName", direction: "asc" }]
|
|
1092
1203
|
}));
|
|
1093
|
-
var SortParamsFromString =
|
|
1204
|
+
var SortParamsFromString = Schema3.String.pipe(Schema3.decodeTo(Schema3.Array(SortParam), SchemaTransformation.transformEffect({
|
|
1094
1205
|
decode: (sort) => {
|
|
1095
1206
|
if (sort === "")
|
|
1096
1207
|
return Effect.succeed([]);
|
|
@@ -1105,8 +1216,8 @@ var SortParamsFromString = Schema.String.pipe(Schema.decodeTo(Schema.Array(SortP
|
|
|
1105
1216
|
}
|
|
1106
1217
|
return Effect.succeed(sortParams);
|
|
1107
1218
|
},
|
|
1108
|
-
encode: (sort) => Effect.succeed(sort.map((part) =>
|
|
1109
|
-
})),
|
|
1219
|
+
encode: (sort) => Effect.succeed(sort.map((part) => Schema3.encodeSync(SortParamFromString)(part)).join(","))
|
|
1220
|
+
})), Schema3.annotate({
|
|
1110
1221
|
identifier: "SortParamsFromString",
|
|
1111
1222
|
title: "Sort Parameters From String",
|
|
1112
1223
|
description: 'URL encoded sort parameters where descending fields are prefixed with "-" and multiple fields are comma-separated.',
|
|
@@ -1117,68 +1228,68 @@ var SortParamsFromString = Schema.String.pipe(Schema.decodeTo(Schema.Array(SortP
|
|
|
1117
1228
|
]
|
|
1118
1229
|
]
|
|
1119
1230
|
}));
|
|
1120
|
-
var SortParamsArray =
|
|
1121
|
-
var SortParams =
|
|
1231
|
+
var SortParamsArray = Schema3.Array(SortParam);
|
|
1232
|
+
var SortParams = Schema3.declare(Schema3.is(SortParamsArray), {
|
|
1122
1233
|
identifier: "SortParams",
|
|
1123
|
-
toCodec: () =>
|
|
1124
|
-
toCodecStringTree: () =>
|
|
1234
|
+
toCodec: () => Schema3.link()(SortParamsArray, SchemaTransformation.passthrough()),
|
|
1235
|
+
toCodecStringTree: () => Schema3.link()(SortParamsFromString, SchemaTransformation.passthrough())
|
|
1125
1236
|
});
|
|
1126
|
-
var TextFilterOperator =
|
|
1237
|
+
var TextFilterOperator = Schema3.Literals([
|
|
1127
1238
|
"contains",
|
|
1128
1239
|
"equals",
|
|
1129
1240
|
"startsWith",
|
|
1130
1241
|
"endsWith"
|
|
1131
1242
|
]).annotate({ identifier: "TextFilterOperator" });
|
|
1132
|
-
var FilterCalendarDate =
|
|
1133
|
-
var ColumnFilter =
|
|
1134
|
-
|
|
1135
|
-
id:
|
|
1136
|
-
kind:
|
|
1243
|
+
var FilterCalendarDate = Schema3.String.check(Schema3.isPattern(/^\d{4}-\d{2}-\d{2}$/), Schema3.makeFilter((value) => Option.exists(DateTime.make(value), (date) => DateTime.formatIsoDateUtc(date) === value))).annotate({ identifier: "FilterCalendarDate" });
|
|
1244
|
+
var ColumnFilter = Schema3.Union([
|
|
1245
|
+
Schema3.Struct({
|
|
1246
|
+
id: Schema3.NonEmptyString,
|
|
1247
|
+
kind: Schema3.Literal("text"),
|
|
1137
1248
|
operator: TextFilterOperator,
|
|
1138
|
-
value:
|
|
1249
|
+
value: Schema3.NonEmptyString
|
|
1139
1250
|
}),
|
|
1140
|
-
|
|
1141
|
-
id:
|
|
1142
|
-
kind:
|
|
1143
|
-
min:
|
|
1144
|
-
max:
|
|
1145
|
-
}).check(
|
|
1146
|
-
|
|
1147
|
-
id:
|
|
1148
|
-
kind:
|
|
1149
|
-
from:
|
|
1150
|
-
to:
|
|
1151
|
-
}).check(
|
|
1152
|
-
|
|
1153
|
-
id:
|
|
1154
|
-
kind:
|
|
1155
|
-
value:
|
|
1251
|
+
Schema3.Struct({
|
|
1252
|
+
id: Schema3.NonEmptyString,
|
|
1253
|
+
kind: Schema3.Literal("number"),
|
|
1254
|
+
min: Schema3.optional(Schema3.Finite),
|
|
1255
|
+
max: Schema3.optional(Schema3.Finite)
|
|
1256
|
+
}).check(Schema3.makeFilter((range) => (range.min !== undefined || range.max !== undefined) && (range.min === undefined || range.max === undefined || range.min <= range.max))),
|
|
1257
|
+
Schema3.Struct({
|
|
1258
|
+
id: Schema3.NonEmptyString,
|
|
1259
|
+
kind: Schema3.Literal("date"),
|
|
1260
|
+
from: Schema3.optional(FilterCalendarDate),
|
|
1261
|
+
to: Schema3.optional(FilterCalendarDate)
|
|
1262
|
+
}).check(Schema3.makeFilter((range) => (range.from !== undefined || range.to !== undefined) && (range.from === undefined || range.to === undefined || range.from <= range.to))),
|
|
1263
|
+
Schema3.Struct({
|
|
1264
|
+
id: Schema3.NonEmptyString,
|
|
1265
|
+
kind: Schema3.Literal("boolean"),
|
|
1266
|
+
value: Schema3.Boolean
|
|
1156
1267
|
}),
|
|
1157
|
-
|
|
1158
|
-
id:
|
|
1159
|
-
kind:
|
|
1160
|
-
values:
|
|
1268
|
+
Schema3.Struct({
|
|
1269
|
+
id: Schema3.NonEmptyString,
|
|
1270
|
+
kind: Schema3.Literal("values"),
|
|
1271
|
+
values: Schema3.NonEmptyArray(Schema3.String)
|
|
1161
1272
|
})
|
|
1162
1273
|
]).annotate({ identifier: "ColumnFilter" });
|
|
1163
|
-
var ColumnFiltersArray =
|
|
1164
|
-
var ColumnFilters =
|
|
1274
|
+
var ColumnFiltersArray = Schema3.Array(ColumnFilter);
|
|
1275
|
+
var ColumnFilters = Schema3.declare(Schema3.is(ColumnFiltersArray), {
|
|
1165
1276
|
identifier: "ColumnFilters",
|
|
1166
|
-
toCodec: () =>
|
|
1167
|
-
toCodecStringTree: () =>
|
|
1277
|
+
toCodec: () => Schema3.link()(ColumnFiltersArray, SchemaTransformation.passthrough()),
|
|
1278
|
+
toCodecStringTree: () => Schema3.link()(Schema3.fromJsonString(ColumnFiltersArray), SchemaTransformation.passthrough())
|
|
1168
1279
|
});
|
|
1169
1280
|
var DEFAULT_PAGE_SIZE = 100;
|
|
1170
|
-
var Query =
|
|
1171
|
-
page:
|
|
1281
|
+
var Query = Schema3.Struct({
|
|
1282
|
+
page: Schema3.optional(Schema3.Union([Schema3.Finite, Schema3.FiniteFromString]).check(Schema3.isInt(), Schema3.isGreaterThanOrEqualTo(0))).pipe(Schema3.decodeTo(Schema3.Int.check(Schema3.isGreaterThanOrEqualTo(0)), {
|
|
1172
1283
|
decode: SchemaGetter.withDefault(Effect.succeed(0)),
|
|
1173
1284
|
encode: SchemaGetter.transformOptional(Option.filter((page) => page !== 0))
|
|
1174
1285
|
})),
|
|
1175
|
-
pageSize:
|
|
1286
|
+
pageSize: Schema3.optional(Schema3.Union([Schema3.Finite, Schema3.FiniteFromString]).check(Schema3.isInt(), Schema3.isBetween({ minimum: 1, maximum: 100 }))).pipe(Schema3.decodeTo(Schema3.Int.check(Schema3.isBetween({ minimum: 1, maximum: 100 })), {
|
|
1176
1287
|
decode: SchemaGetter.withDefault(Effect.succeed(DEFAULT_PAGE_SIZE)),
|
|
1177
1288
|
encode: SchemaGetter.transformOptional(Option.filter((pageSize) => pageSize !== DEFAULT_PAGE_SIZE))
|
|
1178
1289
|
})),
|
|
1179
|
-
globalFilter:
|
|
1180
|
-
sort:
|
|
1181
|
-
filters:
|
|
1290
|
+
globalFilter: Schema3.optional(Schema3.String),
|
|
1291
|
+
sort: Schema3.optional(SortParams),
|
|
1292
|
+
filters: Schema3.optional(ColumnFilters)
|
|
1182
1293
|
}).annotate({
|
|
1183
1294
|
identifier: "Query",
|
|
1184
1295
|
title: "Query",
|
|
@@ -1195,23 +1306,1321 @@ var Query = Schema.Struct({
|
|
|
1195
1306
|
}
|
|
1196
1307
|
]
|
|
1197
1308
|
});
|
|
1198
|
-
var QueryStandard =
|
|
1199
|
-
var PaginationMeta =
|
|
1200
|
-
page:
|
|
1201
|
-
pageSize:
|
|
1202
|
-
total:
|
|
1203
|
-
pageCount:
|
|
1204
|
-
}).pipe(
|
|
1309
|
+
var QueryStandard = Schema3.toStandardSchemaV1(Query);
|
|
1310
|
+
var PaginationMeta = Schema3.Struct({
|
|
1311
|
+
page: Schema3.Int,
|
|
1312
|
+
pageSize: Schema3.Int,
|
|
1313
|
+
total: Schema3.Int,
|
|
1314
|
+
pageCount: Schema3.Int
|
|
1315
|
+
}).pipe(Schema3.annotate({
|
|
1205
1316
|
identifier: "PaginationMeta",
|
|
1206
1317
|
title: "Pagination Metadata",
|
|
1207
1318
|
description: "Pagination metadata returned with a paginated list response.",
|
|
1208
1319
|
examples: [{ page: 0, pageSize: 20, total: 125, pageCount: 7 }]
|
|
1209
1320
|
}));
|
|
1210
1321
|
|
|
1211
|
-
// ../../src/components/
|
|
1212
|
-
import {
|
|
1322
|
+
// ../../src/components/data-table/react.tsx
|
|
1323
|
+
import { useModel } from "@krak-stack/registry/effect-ui-adapter/react";
|
|
1324
|
+
import { useKrakstackLocale as useKrakstackLocale3 } from "@krak-stack/registry/krakstack-provider/react";
|
|
1325
|
+
|
|
1326
|
+
// ../../src/components/data-table/classes.ts
|
|
1327
|
+
var tableClasses = {
|
|
1328
|
+
selectionCell: "w-10 p-0 align-middle",
|
|
1329
|
+
selectionCenter: "grid place-items-center",
|
|
1330
|
+
count: "inline-flex min-w-5 shrink-0 items-center justify-center rounded-full bg-secondary px-1.5 py-0.5 text-xs font-medium tabular-nums text-secondary-foreground",
|
|
1331
|
+
selectedTrigger: "bg-primary text-primary-foreground hover:bg-primary/90 hover:text-primary-foreground",
|
|
1332
|
+
toolbar: "flex min-w-0 shrink-0 flex-wrap items-center gap-2",
|
|
1333
|
+
toolbarSearch: "relative min-w-0 flex-[1_1_12rem]",
|
|
1334
|
+
toolbarMenus: "w-max min-w-0 max-w-full",
|
|
1335
|
+
menubar: "h-auto w-full flex-wrap justify-start border border-input bg-transparent",
|
|
1336
|
+
cell: "overflow-hidden",
|
|
1337
|
+
cellContent: "min-w-0 wrap-anywhere",
|
|
1338
|
+
actionTrigger: "size-8 focus-visible:ring-inset",
|
|
1339
|
+
actionsCell: "sticky right-0 z-20 w-10 min-w-10 cursor-default bg-background p-0 transition-colors group-hover/row:bg-[color-mix(in_oklab,var(--muted)_50%,var(--background))]",
|
|
1340
|
+
actionsAlign: "flex min-h-12 items-center justify-end pe-1",
|
|
1341
|
+
header: "relative h-12 p-0",
|
|
1342
|
+
stickyHeader: "sticky top-0 z-30 bg-background",
|
|
1343
|
+
stickyHeaderRule: "after:border-border after:pointer-events-none after:absolute after:inset-x-0 after:bottom-0 after:border-b",
|
|
1344
|
+
headerTrigger: "absolute inset-0 h-full w-full min-w-0 justify-start rounded-none px-2 pe-4 focus-visible:ring-inset",
|
|
1345
|
+
resizeHandle: "absolute inset-y-0 right-0 z-10 w-2 cursor-col-resize touch-none outline-none after:absolute after:inset-y-3 after:right-0 after:w-px after:bg-border hover:after:w-0.5 hover:after:bg-primary/60 focus-visible:after:w-0.5 focus-visible:after:bg-ring",
|
|
1346
|
+
relationshipCell: "grid min-h-16 in-[[data-slot=table-cell]]:absolute in-[[data-slot=table-cell]]:inset-0 in-[[data-slot=table-cell]]:min-h-0",
|
|
1347
|
+
relationshipTrigger: "h-full w-full min-w-0 justify-between rounded-none px-2 text-start focus-visible:ring-inset",
|
|
1348
|
+
reference: "flex min-w-0 items-center gap-2",
|
|
1349
|
+
referenceAvatar: "relative grid size-8 shrink-0 place-items-center overflow-hidden bg-muted text-xs font-medium",
|
|
1350
|
+
referenceText: "flex min-w-0 flex-col leading-tight",
|
|
1351
|
+
group: "bg-muted/40 hover:bg-accent!",
|
|
1352
|
+
groupContent: "flex min-w-0 items-center gap-2 py-2 pe-1 ps-2",
|
|
1353
|
+
groupSticky: "sticky start-0 w-[100cqw] max-w-full",
|
|
1354
|
+
groupTrigger: "flex min-w-0 flex-1 cursor-pointer items-center gap-2 text-start font-medium",
|
|
1355
|
+
referenceName: "truncate font-medium",
|
|
1356
|
+
referenceDescription: "text-muted-foreground truncate text-xs"
|
|
1357
|
+
};
|
|
1358
|
+
var resolveTableClasses = (overrides) => ({
|
|
1359
|
+
...tableClasses,
|
|
1360
|
+
...overrides
|
|
1361
|
+
});
|
|
1362
|
+
|
|
1363
|
+
// ../../src/components/data-table/index.ts
|
|
1364
|
+
import { DateTime as DateTime3, Effect as Effect2, Option as Option3, Redacted, Schema as Schema5, Stream } from "effect";
|
|
1365
|
+
import { Csv } from "effect/encoding";
|
|
1366
|
+
import { Command, Component as Component2, Subscription, UiSchema as UiSchema2 } from "effect/ui";
|
|
1367
|
+
|
|
1368
|
+
// ../../src/components/data-table/schema.ts
|
|
1369
|
+
import { DateTime as DateTime2, Option as Option2, Schema as Schema4, Struct as Struct2, Tuple } from "effect";
|
|
1370
|
+
var TableClassesOverridesSchema = Schema4.Record(Schema4.Literals(Struct2.keys(tableClasses)), Schema4.optionalKey(Schema4.String)).annotate({ identifier: "TableClassesOverrides" });
|
|
1371
|
+
var DataTableCommonPropsSchema = Schema4.Struct({
|
|
1372
|
+
classes: Schema4.optional(TableClassesOverridesSchema),
|
|
1373
|
+
className: Schema4.optionalKey(Schema4.String),
|
|
1374
|
+
locale: Schema4.optionalKey(Schema4.String)
|
|
1375
|
+
}).annotate({ identifier: "DataTableCommonProps" });
|
|
1376
|
+
var DataTableSortSchema = Schema4.Struct({
|
|
1377
|
+
id: Schema4.NonEmptyString,
|
|
1378
|
+
direction: Schema4.Literals(["asc", "desc"])
|
|
1379
|
+
}).annotate({ identifier: "DataTableSort" });
|
|
1380
|
+
var queryFields = {
|
|
1381
|
+
page: Schema4.Int.check(Schema4.isGreaterThanOrEqualTo(0)),
|
|
1382
|
+
pageSize: Schema4.Int.check(Schema4.isBetween({ minimum: 1, maximum: 100 })),
|
|
1383
|
+
globalFilter: Schema4.optional(Schema4.String),
|
|
1384
|
+
sort: Schema4.optional(Schema4.Array(DataTableSortSchema)),
|
|
1385
|
+
filters: Schema4.optional(Schema4.Array(ColumnFilter))
|
|
1386
|
+
};
|
|
1387
|
+
var DataTableQuerySchema = Schema4.Struct(queryFields).annotate({
|
|
1388
|
+
identifier: "DataTableQuery"
|
|
1389
|
+
});
|
|
1390
|
+
var PageSizes = Schema4.NonEmptyArray(Schema4.Int.check(Schema4.isBetween({ minimum: 1, maximum: 100 })));
|
|
1391
|
+
var DataTableCommonFeaturesSchema = Schema4.Struct({
|
|
1392
|
+
search: Schema4.optionalKey(Schema4.Boolean),
|
|
1393
|
+
filtering: Schema4.optionalKey(Schema4.Boolean),
|
|
1394
|
+
sorting: Schema4.optionalKey(Schema4.Boolean),
|
|
1395
|
+
columnVisibility: Schema4.optionalKey(Schema4.Boolean)
|
|
1396
|
+
});
|
|
1397
|
+
var PaginationSchema = Schema4.Union([
|
|
1398
|
+
Schema4.Struct({
|
|
1399
|
+
mode: Schema4.optionalKey(Schema4.Literal("client")),
|
|
1400
|
+
pageSizes: Schema4.optionalKey(PageSizes)
|
|
1401
|
+
}).annotate({ identifier: "DataTableClientPagination" }),
|
|
1402
|
+
Schema4.Struct({
|
|
1403
|
+
mode: Schema4.Literal("server"),
|
|
1404
|
+
rowCount: Schema4.Int.check(Schema4.isGreaterThanOrEqualTo(0)),
|
|
1405
|
+
pageSizes: Schema4.optionalKey(PageSizes)
|
|
1406
|
+
}).annotate({ identifier: "DataTableServerPagination" })
|
|
1407
|
+
]);
|
|
1408
|
+
var DataTableItemSchema = Schema4.Struct({
|
|
1409
|
+
value: Schema4.NonEmptyString,
|
|
1410
|
+
label: Schema4.String
|
|
1411
|
+
}).annotate({ identifier: "DataTableItem" });
|
|
1412
|
+
var DataTableReferenceSchema = Schema4.Struct({
|
|
1413
|
+
label: Schema4.String,
|
|
1414
|
+
description: Schema4.optionalKey(Schema4.String),
|
|
1415
|
+
imageSrc: Schema4.optionalKey(Schema4.NullOr(Schema4.String))
|
|
1416
|
+
}).annotate({ identifier: "DataTableReference" });
|
|
1417
|
+
var CalendarDate = Schema4.String.check(Schema4.isPattern(/^\d{4}-\d{2}-\d{2}$/), Schema4.makeFilter((value) => Option2.exists(DateTime2.make(value), (date) => DateTime2.formatIsoDateUtc(date) === value))).annotate({ identifier: "DataTableCalendarDate" });
|
|
1418
|
+
var isCalendarDate = Schema4.is(CalendarDate);
|
|
1419
|
+
var InstantString = Schema4.String.check(Schema4.isPattern(/^\d{4}-\d{2}-\d{2}T(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/), Schema4.makeFilter((value) => isCalendarDate(value.slice(0, 10)))).annotate({ identifier: "DataTableInstantString" });
|
|
1420
|
+
var DataTableDateInputSchema = Schema4.Union([
|
|
1421
|
+
Schema4.Date,
|
|
1422
|
+
Schema4.Int,
|
|
1423
|
+
CalendarDate,
|
|
1424
|
+
InstantString
|
|
1425
|
+
]).annotate({ identifier: "DataTableDateInput" });
|
|
1426
|
+
var DateStyle = Schema4.Literals(["full", "long", "medium", "short"]);
|
|
1427
|
+
var DataTableDateFormatSchema = Schema4.Struct({
|
|
1428
|
+
locale: Schema4.optionalKey(Schema4.String),
|
|
1429
|
+
timeZone: Schema4.optionalKey(Schema4.String),
|
|
1430
|
+
dateStyle: Schema4.optionalKey(DateStyle),
|
|
1431
|
+
exportFormat: Schema4.optionalKey(Schema4.Literals(["iso", "formatted"]))
|
|
1432
|
+
}).annotate({ identifier: "DataTableDateFormat" });
|
|
1433
|
+
var DataTableDateTimeFormatSchema = Schema4.Struct({
|
|
1434
|
+
...DataTableDateFormatSchema.fields,
|
|
1435
|
+
timeStyle: Schema4.optionalKey(DateStyle),
|
|
1436
|
+
hour12: Schema4.optionalKey(Schema4.Boolean)
|
|
1437
|
+
}).annotate({ identifier: "DataTableDateTimeFormat" });
|
|
1438
|
+
var DataTableCellValueSchema = Schema4.NullOr(Schema4.Union([
|
|
1439
|
+
Schema4.String,
|
|
1440
|
+
Schema4.Boolean,
|
|
1441
|
+
Schema4.Finite,
|
|
1442
|
+
Schema4.Array(DataTableItemSchema),
|
|
1443
|
+
DataTableReferenceSchema
|
|
1444
|
+
])).annotate({ identifier: "DataTableCellValue" });
|
|
1445
|
+
var DataTableActionSchema = Schema4.Struct({
|
|
1446
|
+
id: Schema4.NonEmptyString,
|
|
1447
|
+
name: Schema4.String,
|
|
1448
|
+
variant: Schema4.optionalKey(Schema4.Literals(["default", "destructive"])),
|
|
1449
|
+
disabled: Schema4.optionalKey(Schema4.Boolean)
|
|
1450
|
+
}).annotate({ identifier: "DataTableAction" });
|
|
1451
|
+
var DataTableRowSchema = Schema4.Struct({
|
|
1452
|
+
id: Schema4.NonEmptyString,
|
|
1453
|
+
label: Schema4.String,
|
|
1454
|
+
cells: Schema4.Record(Schema4.String, DataTableCellValueSchema),
|
|
1455
|
+
actions: Schema4.optionalKey(Schema4.Array(DataTableActionSchema)),
|
|
1456
|
+
primaryActionId: Schema4.optionalKey(Schema4.String),
|
|
1457
|
+
groups: Schema4.optionalKey(Schema4.Record(Schema4.String, Schema4.Array(Schema4.String))),
|
|
1458
|
+
selectable: Schema4.optionalKey(Schema4.Boolean),
|
|
1459
|
+
disabledColumnIds: Schema4.optionalKey(Schema4.Array(Schema4.String))
|
|
1460
|
+
}).annotate({ identifier: "DataTableRow" });
|
|
1461
|
+
var column = {
|
|
1462
|
+
id: Schema4.NonEmptyString,
|
|
1463
|
+
headerName: Schema4.String,
|
|
1464
|
+
sortable: Schema4.optionalKey(Schema4.Boolean),
|
|
1465
|
+
hideable: Schema4.optionalKey(Schema4.Boolean),
|
|
1466
|
+
export: Schema4.optionalKey(Schema4.Boolean),
|
|
1467
|
+
width: Schema4.optionalKey(Schema4.Number),
|
|
1468
|
+
minWidth: Schema4.optionalKey(Schema4.Number),
|
|
1469
|
+
maxWidth: Schema4.optionalKey(Schema4.Number),
|
|
1470
|
+
resizable: Schema4.optionalKey(Schema4.Boolean),
|
|
1471
|
+
truncate: Schema4.optionalKey(Schema4.Boolean),
|
|
1472
|
+
searchable: Schema4.optionalKey(Schema4.Boolean),
|
|
1473
|
+
filterable: Schema4.optionalKey(Schema4.Boolean),
|
|
1474
|
+
emptyLabel: Schema4.optionalKey(Schema4.String),
|
|
1475
|
+
nulls: Schema4.optionalKey(Schema4.Literals(["first", "last"]))
|
|
1476
|
+
};
|
|
1477
|
+
var DataTableFieldSchema = Schema4.Union([
|
|
1478
|
+
Schema4.Struct({ ...column, type: Schema4.Literal("text") }),
|
|
1479
|
+
Schema4.Struct({
|
|
1480
|
+
...column,
|
|
1481
|
+
type: Schema4.Literal("number"),
|
|
1482
|
+
typeOptions: Schema4.optionalKey(Schema4.Struct({
|
|
1483
|
+
locale: Schema4.optionalKey(Schema4.String),
|
|
1484
|
+
style: Schema4.optionalKey(Schema4.Literals(["decimal", "percent", "currency", "unit"])),
|
|
1485
|
+
currency: Schema4.optionalKey(Schema4.String),
|
|
1486
|
+
unit: Schema4.optionalKey(Schema4.String),
|
|
1487
|
+
notation: Schema4.optionalKey(Schema4.Literals(["standard", "scientific", "engineering", "compact"])),
|
|
1488
|
+
minimumFractionDigits: Schema4.optionalKey(Schema4.Int.check(Schema4.isBetween({ minimum: 0, maximum: 20 }))),
|
|
1489
|
+
maximumFractionDigits: Schema4.optionalKey(Schema4.Int.check(Schema4.isBetween({ minimum: 0, maximum: 20 }))),
|
|
1490
|
+
exportFormat: Schema4.optionalKey(Schema4.Literals(["raw", "formatted"]))
|
|
1491
|
+
}).annotate({ identifier: "DataTableNumberFormat" }))
|
|
1492
|
+
}),
|
|
1493
|
+
Schema4.Struct({ ...column, type: Schema4.Literal("reference") }),
|
|
1494
|
+
Schema4.Struct({
|
|
1495
|
+
...column,
|
|
1496
|
+
type: Schema4.Literal("date"),
|
|
1497
|
+
typeOptions: Schema4.optionalKey(DataTableDateFormatSchema)
|
|
1498
|
+
}),
|
|
1499
|
+
Schema4.Struct({
|
|
1500
|
+
...column,
|
|
1501
|
+
type: Schema4.Literal("dateTime"),
|
|
1502
|
+
typeOptions: Schema4.optionalKey(DataTableDateTimeFormatSchema)
|
|
1503
|
+
}),
|
|
1504
|
+
Schema4.Struct({
|
|
1505
|
+
...column,
|
|
1506
|
+
type: Schema4.Literal("boolean"),
|
|
1507
|
+
editable: Schema4.optionalKey(Schema4.Boolean),
|
|
1508
|
+
typeOptions: Schema4.optionalKey(Schema4.Struct({
|
|
1509
|
+
trueLabel: Schema4.optionalKey(Schema4.String),
|
|
1510
|
+
falseLabel: Schema4.optionalKey(Schema4.String),
|
|
1511
|
+
exportFormat: Schema4.optionalKey(Schema4.Literals(["raw", "formatted"]))
|
|
1512
|
+
}).annotate({ identifier: "DataTableBooleanFormat" }))
|
|
1513
|
+
}),
|
|
1514
|
+
Schema4.Struct({
|
|
1515
|
+
...column,
|
|
1516
|
+
type: Schema4.Literal("list"),
|
|
1517
|
+
filterOptions: Schema4.optionalKey(Schema4.Array(DataTableItemSchema)),
|
|
1518
|
+
options: Schema4.optionalKey(Schema4.Array(DataTableItemSchema)),
|
|
1519
|
+
allowRemove: Schema4.optionalKey(Schema4.Boolean),
|
|
1520
|
+
itemActions: Schema4.optionalKey(Schema4.Array(DataTableActionSchema)),
|
|
1521
|
+
display: Schema4.optionalKey(Schema4.Literals(["list", "icon"])),
|
|
1522
|
+
visibleCount: Schema4.optionalKey(Schema4.Int.check(Schema4.isGreaterThanOrEqualTo(0))),
|
|
1523
|
+
actionsLabel: Schema4.optionalKey(Schema4.String),
|
|
1524
|
+
manageLabel: Schema4.optionalKey(Schema4.String)
|
|
1525
|
+
})
|
|
1526
|
+
]).annotate({ identifier: "DataTableField" });
|
|
1527
|
+
var DataTableColumnSchema = DataTableFieldSchema.mapMembers(Tuple.map(Schema4.fieldsAssign({
|
|
1528
|
+
fields: Schema4.optionalKey(Schema4.Array(DataTableFieldSchema))
|
|
1529
|
+
}))).annotate({ identifier: "DataTableColumn" });
|
|
1530
|
+
var DataTableLabelsSchema = Schema4.Struct({
|
|
1531
|
+
actions: Schema4.optionalKey(Schema4.String),
|
|
1532
|
+
addItem: Schema4.optionalKey(Schema4.String),
|
|
1533
|
+
listDetails: Schema4.optionalKey(Schema4.String),
|
|
1534
|
+
empty: Schema4.optionalKey(Schema4.String),
|
|
1535
|
+
filters: Schema4.optionalKey(Schema4.String),
|
|
1536
|
+
filtersClear: Schema4.optionalKey(Schema4.String),
|
|
1537
|
+
filterColumn: Schema4.optionalKey(Schema4.String),
|
|
1538
|
+
filterClear: Schema4.optionalKey(Schema4.String),
|
|
1539
|
+
filterApply: Schema4.optionalKey(Schema4.String),
|
|
1540
|
+
filterValue: Schema4.optionalKey(Schema4.String),
|
|
1541
|
+
filterOperator: Schema4.optionalKey(Schema4.String),
|
|
1542
|
+
filterContains: Schema4.optionalKey(Schema4.String),
|
|
1543
|
+
filterEquals: Schema4.optionalKey(Schema4.String),
|
|
1544
|
+
filterStartsWith: Schema4.optionalKey(Schema4.String),
|
|
1545
|
+
filterEndsWith: Schema4.optionalKey(Schema4.String),
|
|
1546
|
+
filterMin: Schema4.optionalKey(Schema4.String),
|
|
1547
|
+
filterMax: Schema4.optionalKey(Schema4.String),
|
|
1548
|
+
filterFrom: Schema4.optionalKey(Schema4.String),
|
|
1549
|
+
filterTo: Schema4.optionalKey(Schema4.String),
|
|
1550
|
+
filterTrue: Schema4.optionalKey(Schema4.String),
|
|
1551
|
+
filterFalse: Schema4.optionalKey(Schema4.String),
|
|
1552
|
+
filterInvalid: Schema4.optionalKey(Schema4.String),
|
|
1553
|
+
columns: Schema4.optionalKey(Schema4.String),
|
|
1554
|
+
sortBy: Schema4.optionalKey(Schema4.String),
|
|
1555
|
+
hideColumn: Schema4.optionalKey(Schema4.String),
|
|
1556
|
+
loading: Schema4.optionalKey(Schema4.String),
|
|
1557
|
+
removeItem: Schema4.optionalKey(Schema4.String),
|
|
1558
|
+
search: Schema4.optionalKey(Schema4.String),
|
|
1559
|
+
selectAllRows: Schema4.optionalKey(Schema4.String),
|
|
1560
|
+
selectRow: Schema4.optionalKey(Schema4.String),
|
|
1561
|
+
selected: Schema4.optionalKey(Schema4.String),
|
|
1562
|
+
sortAsc: Schema4.optionalKey(Schema4.String),
|
|
1563
|
+
sortDesc: Schema4.optionalKey(Schema4.String),
|
|
1564
|
+
sortClear: Schema4.optionalKey(Schema4.String),
|
|
1565
|
+
view: Schema4.optionalKey(Schema4.String),
|
|
1566
|
+
tableView: Schema4.optionalKey(Schema4.String),
|
|
1567
|
+
galleryView: Schema4.optionalKey(Schema4.String),
|
|
1568
|
+
groupBy: Schema4.optionalKey(Schema4.String),
|
|
1569
|
+
export: Schema4.optionalKey(Schema4.String),
|
|
1570
|
+
exportFailed: Schema4.optionalKey(Schema4.String),
|
|
1571
|
+
moveUp: Schema4.optionalKey(Schema4.String),
|
|
1572
|
+
moveDown: Schema4.optionalKey(Schema4.String),
|
|
1573
|
+
reorder: Schema4.optionalKey(Schema4.String),
|
|
1574
|
+
refresh: Schema4.optionalKey(Schema4.String),
|
|
1575
|
+
resize: Schema4.optionalKey(Schema4.String)
|
|
1576
|
+
}).annotate({ identifier: "DataTableLabels" });
|
|
1577
|
+
var DataTableViewSchema = Schema4.Literals(["table", "gallery"]);
|
|
1578
|
+
var DataTablePreferencesSchema = Schema4.Struct({
|
|
1579
|
+
columnVisibility: Schema4.Record(Schema4.String, Schema4.Boolean),
|
|
1580
|
+
columnSizing: Schema4.Record(Schema4.String, Schema4.Finite),
|
|
1581
|
+
grouping: Schema4.optionalKey(Schema4.Array(Schema4.String)),
|
|
1582
|
+
view: DataTableViewSchema
|
|
1583
|
+
}).annotate({ identifier: "DataTablePersistedUiState" });
|
|
1584
|
+
var GroupField = Schema4.Struct({
|
|
1585
|
+
id: Schema4.NonEmptyString,
|
|
1586
|
+
label: Schema4.String,
|
|
1587
|
+
actionsLabel: Schema4.optionalKey(Schema4.String),
|
|
1588
|
+
groups: Schema4.optionalKey(Schema4.Array(Schema4.Struct({
|
|
1589
|
+
id: Schema4.String,
|
|
1590
|
+
label: Schema4.String,
|
|
1591
|
+
empty: Schema4.optionalKey(Schema4.String)
|
|
1592
|
+
}).annotate({ identifier: "DataTableGroupLabel" }))),
|
|
1593
|
+
actions: Schema4.optionalKey(Schema4.Array(DataTableActionSchema)),
|
|
1594
|
+
movable: Schema4.optionalKey(Schema4.Boolean)
|
|
1595
|
+
}).annotate({ identifier: "DataTableGroupField" });
|
|
1596
|
+
var DataTablePropsSchema = Schema4.Struct({
|
|
1597
|
+
...DataTableCommonPropsSchema.fields,
|
|
1598
|
+
label: Schema4.String,
|
|
1599
|
+
rowData: Schema4.Array(DataTableRowSchema),
|
|
1600
|
+
rowActivation: Schema4.optionalKey(Schema4.Boolean),
|
|
1601
|
+
columnDefs: Schema4.Array(DataTableColumnSchema),
|
|
1602
|
+
status: Schema4.optionalKey(Schema4.Struct({
|
|
1603
|
+
loading: Schema4.optionalKey(Schema4.Boolean),
|
|
1604
|
+
empty: Schema4.optionalKey(Schema4.String),
|
|
1605
|
+
error: Schema4.optionalKey(Schema4.String)
|
|
1606
|
+
})),
|
|
1607
|
+
sort: Schema4.optionalKey(Schema4.Array(DataTableSortSchema)),
|
|
1608
|
+
sortMode: Schema4.optionalKey(Schema4.Literals(["client", "server"])),
|
|
1609
|
+
search: Schema4.optionalKey(Schema4.Boolean),
|
|
1610
|
+
columnFilters: Schema4.optionalKey(Schema4.Boolean),
|
|
1611
|
+
state: Schema4.optionalKey(DataTableQuerySchema),
|
|
1612
|
+
features: Schema4.optionalKey(Schema4.Struct({
|
|
1613
|
+
...DataTableCommonFeaturesSchema.fields,
|
|
1614
|
+
pagination: Schema4.optionalKey(Schema4.Union([Schema4.Literal(false), PaginationSchema])),
|
|
1615
|
+
grouping: Schema4.optionalKey(Schema4.Struct({
|
|
1616
|
+
initial: Schema4.optionalKey(Schema4.Array(Schema4.String)),
|
|
1617
|
+
fields: Schema4.Array(GroupField)
|
|
1618
|
+
}).annotate({ identifier: "DataTableGrouping" })),
|
|
1619
|
+
gallery: Schema4.optionalKey(Schema4.Struct({
|
|
1620
|
+
name: Schema4.String,
|
|
1621
|
+
description: Schema4.optionalKey(Schema4.String),
|
|
1622
|
+
image: Schema4.optionalKey(Schema4.String),
|
|
1623
|
+
tags: Schema4.optionalKey(Schema4.Array(Schema4.String))
|
|
1624
|
+
}).annotate({ identifier: "DataTableGallery" })),
|
|
1625
|
+
reordering: Schema4.optionalKey(Schema4.Boolean),
|
|
1626
|
+
export: Schema4.optionalKey(Schema4.Struct({
|
|
1627
|
+
baseName: Schema4.String,
|
|
1628
|
+
scope: Schema4.optionalKey(Schema4.Literals(["filteredRows", "currentPage"])),
|
|
1629
|
+
builtIn: Schema4.optionalKey(Schema4.Boolean),
|
|
1630
|
+
actions: Schema4.optionalKey(Schema4.Array(DataTableActionSchema)),
|
|
1631
|
+
pending: Schema4.optionalKey(Schema4.Boolean),
|
|
1632
|
+
failed: Schema4.optionalKey(Schema4.Boolean)
|
|
1633
|
+
}).annotate({ identifier: "DataTableExport" })),
|
|
1634
|
+
refresh: Schema4.optionalKey(Schema4.Boolean),
|
|
1635
|
+
virtualization: Schema4.optionalKey(Schema4.Union([
|
|
1636
|
+
Schema4.Boolean,
|
|
1637
|
+
Schema4.Struct({
|
|
1638
|
+
scroll: Schema4.optionalKey(Schema4.Literals(["table", "internal", "page"])),
|
|
1639
|
+
height: Schema4.optionalKey(Schema4.Int.check(Schema4.isGreaterThan(0))),
|
|
1640
|
+
estimateRowHeight: Schema4.optionalKey(Schema4.Int.check(Schema4.isGreaterThan(0))),
|
|
1641
|
+
overscan: Schema4.optionalKey(Schema4.Int.check(Schema4.isGreaterThanOrEqualTo(0)))
|
|
1642
|
+
}).annotate({ identifier: "DataTableVirtualization" })
|
|
1643
|
+
]))
|
|
1644
|
+
}).annotate({ identifier: "DataTableHtmlFeatures" })),
|
|
1645
|
+
initialState: Schema4.optionalKey(Schema4.Struct({
|
|
1646
|
+
...queryFields,
|
|
1647
|
+
page: Schema4.optional(queryFields.page),
|
|
1648
|
+
pageSize: Schema4.optional(queryFields.pageSize),
|
|
1649
|
+
columnVisibility: Schema4.optionalKey(Schema4.Record(Schema4.String, Schema4.Boolean)),
|
|
1650
|
+
view: Schema4.optionalKey(DataTableViewSchema)
|
|
1651
|
+
}).annotate({ identifier: "DataTableInitialQuery" })),
|
|
1652
|
+
pagination: Schema4.optionalKey(PaginationSchema),
|
|
1653
|
+
selection: Schema4.optionalKey(Schema4.Struct({
|
|
1654
|
+
selectedRowIds: Schema4.optionalKey(Schema4.Array(Schema4.String)),
|
|
1655
|
+
bulkActionsLabel: Schema4.optionalKey(Schema4.String),
|
|
1656
|
+
bulkActions: Schema4.optionalKey(Schema4.Array(DataTableActionSchema))
|
|
1657
|
+
})),
|
|
1658
|
+
messages: Schema4.optionalKey(Schema4.Record(Schema4.String, DataTableLabelsSchema))
|
|
1659
|
+
}).annotate({ identifier: "DataTableProps" });
|
|
1660
|
+
var DataTableFilterDraftSchema = Schema4.Struct({
|
|
1661
|
+
id: Schema4.String,
|
|
1662
|
+
primary: Schema4.String,
|
|
1663
|
+
secondary: Schema4.String,
|
|
1664
|
+
operator: TextFilterOperator,
|
|
1665
|
+
values: Schema4.Array(Schema4.String)
|
|
1666
|
+
}).annotate({ identifier: "DataTableFilterDraft" });
|
|
1667
|
+
|
|
1668
|
+
// ../../src/components/data-table/index.ts
|
|
1669
|
+
var defaultMessages = {
|
|
1670
|
+
en: {
|
|
1671
|
+
actions: "Actions",
|
|
1672
|
+
addItem: "Add item...",
|
|
1673
|
+
listDetails: "View all items",
|
|
1674
|
+
empty: "No results.",
|
|
1675
|
+
filters: "Filters",
|
|
1676
|
+
filtersClear: "Clear all filters",
|
|
1677
|
+
filterColumn: "Column",
|
|
1678
|
+
filterClear: "Clear filter",
|
|
1679
|
+
filterApply: "Apply filter",
|
|
1680
|
+
filterValue: "Value",
|
|
1681
|
+
filterOperator: "Operator",
|
|
1682
|
+
filterContains: "Contains",
|
|
1683
|
+
filterEquals: "Equals",
|
|
1684
|
+
filterStartsWith: "Starts with",
|
|
1685
|
+
filterEndsWith: "Ends with",
|
|
1686
|
+
filterMin: "Minimum",
|
|
1687
|
+
filterMax: "Maximum",
|
|
1688
|
+
filterFrom: "From (UTC)",
|
|
1689
|
+
filterTo: "To (UTC)",
|
|
1690
|
+
filterTrue: "True",
|
|
1691
|
+
filterFalse: "False",
|
|
1692
|
+
filterInvalid: "Enter a valid filter. Ranges must be in ascending order.",
|
|
1693
|
+
columns: "Columns",
|
|
1694
|
+
sortBy: "Sort by",
|
|
1695
|
+
hideColumn: "Hide column",
|
|
1696
|
+
loading: "Loading...",
|
|
1697
|
+
removeItem: "Remove",
|
|
1698
|
+
search: "Search",
|
|
1699
|
+
selectAllRows: "Select all rows on this page",
|
|
1700
|
+
selectRow: "Select row",
|
|
1701
|
+
selected: "Selected",
|
|
1702
|
+
sortAsc: "Ascending",
|
|
1703
|
+
sortDesc: "Descending",
|
|
1704
|
+
sortClear: "Clear sorting",
|
|
1705
|
+
view: "View",
|
|
1706
|
+
tableView: "Table",
|
|
1707
|
+
galleryView: "Gallery",
|
|
1708
|
+
groupBy: "Group by",
|
|
1709
|
+
export: "Export",
|
|
1710
|
+
exportFailed: "Export failed. Please try again.",
|
|
1711
|
+
refresh: "Refresh",
|
|
1712
|
+
moveUp: "Move up",
|
|
1713
|
+
moveDown: "Move down",
|
|
1714
|
+
reorder: "Drag to reorder",
|
|
1715
|
+
resize: "Resize column"
|
|
1716
|
+
},
|
|
1717
|
+
fr: {
|
|
1718
|
+
actions: "Actions",
|
|
1719
|
+
addItem: "Ajouter un élément...",
|
|
1720
|
+
listDetails: "Afficher tous les éléments",
|
|
1721
|
+
empty: "Aucun résultat.",
|
|
1722
|
+
filters: "Filtres",
|
|
1723
|
+
filtersClear: "Effacer tous les filtres",
|
|
1724
|
+
filterColumn: "Colonne",
|
|
1725
|
+
filterClear: "Effacer le filtre",
|
|
1726
|
+
filterApply: "Appliquer le filtre",
|
|
1727
|
+
filterValue: "Valeur",
|
|
1728
|
+
filterOperator: "Opérateur",
|
|
1729
|
+
filterContains: "Contient",
|
|
1730
|
+
filterEquals: "Égal à",
|
|
1731
|
+
filterStartsWith: "Commence par",
|
|
1732
|
+
filterEndsWith: "Se termine par",
|
|
1733
|
+
filterMin: "Minimum",
|
|
1734
|
+
filterMax: "Maximum",
|
|
1735
|
+
filterFrom: "Du (UTC)",
|
|
1736
|
+
filterTo: "Au (UTC)",
|
|
1737
|
+
filterTrue: "Vrai",
|
|
1738
|
+
filterFalse: "Faux",
|
|
1739
|
+
filterInvalid: "Saisissez un filtre valide. Les bornes doivent être dans l’ordre croissant.",
|
|
1740
|
+
columns: "Colonnes",
|
|
1741
|
+
sortBy: "Trier par",
|
|
1742
|
+
hideColumn: "Masquer la colonne",
|
|
1743
|
+
loading: "Chargement...",
|
|
1744
|
+
removeItem: "Retirer",
|
|
1745
|
+
search: "Rechercher",
|
|
1746
|
+
selectAllRows: "Sélectionner toutes les lignes de cette page",
|
|
1747
|
+
selectRow: "Sélectionner la ligne",
|
|
1748
|
+
selected: "Sélectionnés",
|
|
1749
|
+
sortAsc: "Croissant",
|
|
1750
|
+
sortDesc: "Décroissant",
|
|
1751
|
+
sortClear: "Effacer le tri",
|
|
1752
|
+
view: "Affichage",
|
|
1753
|
+
tableView: "Tableau",
|
|
1754
|
+
galleryView: "Galerie",
|
|
1755
|
+
groupBy: "Grouper par",
|
|
1756
|
+
export: "Exporter",
|
|
1757
|
+
exportFailed: "L’exportation a échoué. Veuillez réessayer.",
|
|
1758
|
+
refresh: "Rafraîchir",
|
|
1759
|
+
moveUp: "Déplacer vers le haut",
|
|
1760
|
+
moveDown: "Déplacer vers le bas",
|
|
1761
|
+
reorder: "Glisser pour réorganiser",
|
|
1762
|
+
resize: "Redimensionner la colonne"
|
|
1763
|
+
}
|
|
1764
|
+
};
|
|
1765
|
+
var compareTableText = (left, right, locale) => left.localeCompare(right, locale, { numeric: true, sensitivity: "base" });
|
|
1766
|
+
var isTableText = Schema5.is(Schema5.String);
|
|
1767
|
+
var isTableNumber = Schema5.is(Schema5.Finite);
|
|
1768
|
+
var isTableBoolean = Schema5.is(Schema5.Boolean);
|
|
1769
|
+
var isTableReference = Schema5.is(DataTableReferenceSchema);
|
|
1770
|
+
var isTableList = Schema5.is(Schema5.Array(DataTableItemSchema));
|
|
1771
|
+
var tableInitials = (label) => label.trim().split(/\s+/).slice(0, 2).map((word) => word.slice(0, 1)).join("").toLocaleUpperCase();
|
|
1772
|
+
var formatNumberValue = (value, options, defaultLocale = "en") => {
|
|
1773
|
+
const { locale, ...format } = options ?? {};
|
|
1774
|
+
return new Intl.NumberFormat(locale ?? defaultLocale, format).format(value);
|
|
1775
|
+
};
|
|
1776
|
+
var tableBooleanLabel = (value, options) => (value ? options?.trueLabel : options?.falseLabel) ?? String(value);
|
|
1777
|
+
var decodeDateInput = Schema5.decodeUnknownOption(DataTableDateInputSchema);
|
|
1778
|
+
var resolveDate = (value, type) => Option3.getOrUndefined(Option3.flatMap(decodeDateInput(value), (input) => {
|
|
1779
|
+
const calendarOnly = isCalendarDate(input);
|
|
1780
|
+
if (calendarOnly && type === "dateTime")
|
|
1781
|
+
return Option3.none();
|
|
1782
|
+
return Option3.map(DateTime3.make(input), (instant) => ({
|
|
1783
|
+
instant,
|
|
1784
|
+
calendarOnly
|
|
1785
|
+
}));
|
|
1786
|
+
}));
|
|
1787
|
+
var formatDateValue = (date, column, locale = "en") => DateTime3.format(date.instant, {
|
|
1788
|
+
locale: column.typeOptions?.locale ?? locale,
|
|
1789
|
+
timeZone: date.calendarOnly ? "UTC" : column.typeOptions?.timeZone ?? "UTC",
|
|
1790
|
+
dateStyle: column.typeOptions?.dateStyle ?? "medium",
|
|
1791
|
+
timeStyle: column.type === "dateTime" ? column.typeOptions?.timeStyle ?? "short" : undefined,
|
|
1792
|
+
hour12: column.type === "dateTime" ? column.typeOptions?.hour12 : undefined
|
|
1793
|
+
});
|
|
1794
|
+
var dateIsoValue = (date) => date.calendarOnly ? DateTime3.formatIsoDateUtc(date.instant) : DateTime3.formatIso(date.instant);
|
|
1795
|
+
var matchesDateFilter = (date, filter) => {
|
|
1796
|
+
if (!date)
|
|
1797
|
+
return false;
|
|
1798
|
+
const day = DateTime3.formatIsoDateUtc(date.instant);
|
|
1799
|
+
return (filter.from === undefined || day >= filter.from) && (filter.to === undefined || day <= filter.to);
|
|
1800
|
+
};
|
|
1801
|
+
var matchesFilterText = (value, filter) => {
|
|
1802
|
+
const text = value.toLocaleLowerCase();
|
|
1803
|
+
const query = filter.value.toLocaleLowerCase();
|
|
1804
|
+
switch (filter.operator) {
|
|
1805
|
+
case "contains":
|
|
1806
|
+
return text.includes(query);
|
|
1807
|
+
case "equals":
|
|
1808
|
+
return text === query;
|
|
1809
|
+
case "startsWith":
|
|
1810
|
+
return text.startsWith(query);
|
|
1811
|
+
case "endsWith":
|
|
1812
|
+
return text.endsWith(query);
|
|
1813
|
+
}
|
|
1814
|
+
};
|
|
1815
|
+
var tableFilterKind = (column, hasOptions = false) => hasOptions || column.type === "list" ? "values" : column.type === "reference" ? "text" : column.type === "dateTime" ? "date" : column.type ?? "text";
|
|
1816
|
+
var matchesTableFilter = (filter, value, type, text, values) => {
|
|
1817
|
+
switch (filter.kind) {
|
|
1818
|
+
case "text":
|
|
1819
|
+
return matchesFilterText(text(), filter);
|
|
1820
|
+
case "number":
|
|
1821
|
+
return isTableNumber(value) && (filter.min === undefined || value >= filter.min) && (filter.max === undefined || value <= filter.max);
|
|
1822
|
+
case "boolean":
|
|
1823
|
+
return value === filter.value;
|
|
1824
|
+
case "values":
|
|
1825
|
+
return values().some((value) => filter.values.includes(value));
|
|
1826
|
+
case "date":
|
|
1827
|
+
return matchesDateFilter(resolveDate(value, type === "dateTime" ? "dateTime" : "date"), filter);
|
|
1828
|
+
}
|
|
1829
|
+
};
|
|
1830
|
+
var tableDataColumns = (columns) => columns.flatMap((column) => column.fields?.length ? column.fields.map((field) => ({
|
|
1831
|
+
...field,
|
|
1832
|
+
id: `${column.id}.${field.id}`,
|
|
1833
|
+
headerName: `${column.headerName} / ${field.headerName}`,
|
|
1834
|
+
sortable: column.sortable === false ? false : field.sortable,
|
|
1835
|
+
searchable: column.searchable === false ? false : field.searchable,
|
|
1836
|
+
filterable: column.filterable === false ? false : field.filterable,
|
|
1837
|
+
export: column.export === false ? false : field.export
|
|
1838
|
+
})) : [column]);
|
|
1839
|
+
var filterTableColumns = (rows, columns, filters) => {
|
|
1840
|
+
const byId = new Map(columns.filter(({ filterable }) => filterable !== false).map((column) => [column.id, column]));
|
|
1841
|
+
const active = filters.filter((filter) => {
|
|
1842
|
+
const column = byId.get(filter.id);
|
|
1843
|
+
return column && tableFilterKind(column) === filter.kind;
|
|
1844
|
+
});
|
|
1845
|
+
if (!active.length)
|
|
1846
|
+
return rows;
|
|
1847
|
+
return rows.filter((row) => active.every((filter) => {
|
|
1848
|
+
const value = row.cells[filter.id];
|
|
1849
|
+
return matchesTableFilter(filter, value, byId.get(filter.id)?.type, () => isTableText(value) ? value : isTableReference(value) ? `${value.label} ${value.description ?? ""}`.trim() : "", () => isTableList(value) ? value.map(({ value }) => value) : []);
|
|
1850
|
+
}));
|
|
1851
|
+
};
|
|
1852
|
+
var columnValue = (column, value) => {
|
|
1853
|
+
switch (column.type) {
|
|
1854
|
+
case "text":
|
|
1855
|
+
return isTableText(value) ? value : null;
|
|
1856
|
+
case "number":
|
|
1857
|
+
case "boolean":
|
|
1858
|
+
case "date":
|
|
1859
|
+
case "dateTime":
|
|
1860
|
+
return tableSortScalar(column.type, value);
|
|
1861
|
+
case "reference":
|
|
1862
|
+
return isTableReference(value) ? value.label : null;
|
|
1863
|
+
case "list":
|
|
1864
|
+
return isTableList(value) ? value.map(({ label }) => label).join(", ") : null;
|
|
1865
|
+
}
|
|
1866
|
+
};
|
|
1867
|
+
var tableSortScalar = (type, value) => {
|
|
1868
|
+
if (type === "number")
|
|
1869
|
+
return isTableNumber(value) ? value : null;
|
|
1870
|
+
if (type === "boolean")
|
|
1871
|
+
return isTableBoolean(value) ? Number(value) : null;
|
|
1872
|
+
const date = resolveDate(value, type);
|
|
1873
|
+
return date ? DateTime3.toEpochMillis(date.instant) : null;
|
|
1874
|
+
};
|
|
1875
|
+
var compareTableSortValues = (left, right, direction, nulls, locale) => {
|
|
1876
|
+
if (left === right)
|
|
1877
|
+
return 0;
|
|
1878
|
+
const nullOrder = nulls === "first" ? -1 : 1;
|
|
1879
|
+
if (left === null)
|
|
1880
|
+
return nullOrder;
|
|
1881
|
+
if (right === null)
|
|
1882
|
+
return -nullOrder;
|
|
1883
|
+
const comparison = isTableNumber(left) && isTableNumber(right) ? left - right : compareTableText(String(left), String(right), locale);
|
|
1884
|
+
return direction === "asc" ? comparison : -comparison;
|
|
1885
|
+
};
|
|
1886
|
+
var sortTableRows = (rows, columns, sort, locale) => {
|
|
1887
|
+
const byId = new Map(columns.map((column) => [column.id, column]));
|
|
1888
|
+
return rows.slice().sort((leftRow, rightRow) => {
|
|
1889
|
+
for (const { id, direction } of sort) {
|
|
1890
|
+
const column = byId.get(id);
|
|
1891
|
+
if (!column || column.sortable === false)
|
|
1892
|
+
continue;
|
|
1893
|
+
const left = columnValue(column, leftRow.cells[id]);
|
|
1894
|
+
const right = columnValue(column, rightRow.cells[id]);
|
|
1895
|
+
const comparison = compareTableSortValues(left, right, direction, column.nulls, locale);
|
|
1896
|
+
if (comparison !== 0)
|
|
1897
|
+
return comparison;
|
|
1898
|
+
}
|
|
1899
|
+
return 0;
|
|
1900
|
+
});
|
|
1901
|
+
};
|
|
1902
|
+
var filterTableRows = (rows, columns, search, locale) => {
|
|
1903
|
+
const query = search.trim().toLocaleLowerCase(locale);
|
|
1904
|
+
if (!query)
|
|
1905
|
+
return rows;
|
|
1906
|
+
const searchable = columns.filter(({ searchable }) => searchable !== false);
|
|
1907
|
+
return rows.filter((row) => searchable.some((column) => {
|
|
1908
|
+
const value = row.cells[column.id];
|
|
1909
|
+
if (column.type === "date" || column.type === "dateTime") {
|
|
1910
|
+
const date = resolveDate(value, column.type);
|
|
1911
|
+
return !!date && `${formatDateValue(date, column, locale)} ${dateIsoValue(date)}`.toLocaleLowerCase(locale).includes(query);
|
|
1912
|
+
}
|
|
1913
|
+
const text = column.type === "reference" && isTableReference(value) ? `${value.label} ${value.description ?? ""}` : column.type === "number" && isTableNumber(value) ? `${formatNumberValue(value, column.typeOptions, locale)} ${value}` : column.type === "boolean" && isTableBoolean(value) ? `${tableBooleanLabel(value, column.typeOptions)} ${value}` : String(columnValue(column, value) ?? "");
|
|
1914
|
+
return text.toLocaleLowerCase(locale).includes(query);
|
|
1915
|
+
}));
|
|
1916
|
+
};
|
|
1917
|
+
var updateSelectedRows = (selected, targets, checked) => {
|
|
1918
|
+
const next = new Set(selected);
|
|
1919
|
+
for (const id of targets) {
|
|
1920
|
+
if (checked)
|
|
1921
|
+
next.add(id);
|
|
1922
|
+
else
|
|
1923
|
+
next.delete(id);
|
|
1924
|
+
}
|
|
1925
|
+
return Array.from(next);
|
|
1926
|
+
};
|
|
1927
|
+
var resolveTablePage = (rowCount, query) => {
|
|
1928
|
+
const pageSize = Math.max(1, query.pageSize);
|
|
1929
|
+
const pageCount = Math.max(1, Math.ceil(rowCount / pageSize));
|
|
1930
|
+
const page = Math.min(pageCount - 1, Math.max(0, query.page));
|
|
1931
|
+
const start = page * pageSize;
|
|
1932
|
+
return { page, pageCount, start, end: start + pageSize };
|
|
1933
|
+
};
|
|
1934
|
+
var edit = UiSchema2.TaggedEnum({
|
|
1935
|
+
SetBoolean: { value: Schema5.Boolean },
|
|
1936
|
+
AddItem: { itemId: Schema5.String },
|
|
1937
|
+
RemoveItem: { itemId: Schema5.String }
|
|
1938
|
+
}).annotate({ identifier: "DataTableEdit" });
|
|
1939
|
+
var eventFields = {
|
|
1940
|
+
RowActivated: { rowId: Schema5.String },
|
|
1941
|
+
ItemActionRequested: {
|
|
1942
|
+
rowId: Schema5.String,
|
|
1943
|
+
columnId: Schema5.String,
|
|
1944
|
+
itemId: Schema5.String,
|
|
1945
|
+
actionId: Schema5.String
|
|
1946
|
+
},
|
|
1947
|
+
RefreshRequested: {},
|
|
1948
|
+
ExportRequested: { actionId: Schema5.String },
|
|
1949
|
+
GroupActionRequested: {
|
|
1950
|
+
fieldId: Schema5.String,
|
|
1951
|
+
groupId: Schema5.String,
|
|
1952
|
+
actionId: Schema5.String
|
|
1953
|
+
},
|
|
1954
|
+
GroupMoveRequested: {
|
|
1955
|
+
rowId: Schema5.String,
|
|
1956
|
+
fieldId: Schema5.String,
|
|
1957
|
+
groupId: Schema5.String
|
|
1958
|
+
},
|
|
1959
|
+
RowsReordered: { rowIds: Schema5.Array(Schema5.String) },
|
|
1960
|
+
StateChanged: { state: DataTableQuerySchema },
|
|
1961
|
+
SortChanged: { sort: Schema5.Array(DataTableSortSchema) },
|
|
1962
|
+
SelectionChanged: { selectedRowIds: Schema5.Array(Schema5.String) },
|
|
1963
|
+
CellEditRequested: { rowId: Schema5.String, columnId: Schema5.String, edit },
|
|
1964
|
+
RowActionRequested: { rowId: Schema5.String, actionId: Schema5.String },
|
|
1965
|
+
BulkActionRequested: {
|
|
1966
|
+
rowIds: Schema5.Array(Schema5.String),
|
|
1967
|
+
actionId: Schema5.String
|
|
1968
|
+
}
|
|
1969
|
+
};
|
|
1970
|
+
var DataTableEvents = UiSchema2.TaggedEnum(eventFields).annotate({
|
|
1971
|
+
identifier: "DataTableEvents"
|
|
1972
|
+
});
|
|
1973
|
+
var DataTableMessage = UiSchema2.TaggedEnum({
|
|
1974
|
+
ReferenceImageFailed: { src: Schema5.String },
|
|
1975
|
+
RowActivated: eventFields.RowActivated,
|
|
1976
|
+
PreferencesLoaded: { preferences: Schema5.NullOr(DataTablePreferencesSchema) },
|
|
1977
|
+
ItemActionRequested: eventFields.ItemActionRequested,
|
|
1978
|
+
BuiltInExportRequested: {
|
|
1979
|
+
format: Schema5.Literals(["csv", "json"]),
|
|
1980
|
+
locale: Schema5.optionalKey(Schema5.String)
|
|
1981
|
+
},
|
|
1982
|
+
ExportStarted: {},
|
|
1983
|
+
ExportFinished: { failed: Schema5.Boolean },
|
|
1984
|
+
RefreshRequested: {},
|
|
1985
|
+
ExportRequested: eventFields.ExportRequested,
|
|
1986
|
+
GroupActionRequested: eventFields.GroupActionRequested,
|
|
1987
|
+
GroupMoveRequested: eventFields.GroupMoveRequested,
|
|
1988
|
+
ReorderRequested: {
|
|
1989
|
+
rowId: Schema5.String,
|
|
1990
|
+
targetId: Schema5.String,
|
|
1991
|
+
after: Schema5.Boolean
|
|
1992
|
+
},
|
|
1993
|
+
DragStarted: { rowId: Schema5.String },
|
|
1994
|
+
DragEnded: {},
|
|
1995
|
+
DragDropped: { targetId: Schema5.String },
|
|
1996
|
+
GroupDropped: { fieldId: Schema5.String, groupId: Schema5.String },
|
|
1997
|
+
ViewPicked: { view: DataTableViewSchema },
|
|
1998
|
+
GroupingToggled: { fieldId: Schema5.String },
|
|
1999
|
+
GroupToggled: { key: Schema5.String },
|
|
2000
|
+
ColumnResized: { id: Schema5.String, delta: Schema5.Finite },
|
|
2001
|
+
ColumnResizeReset: { id: Schema5.String },
|
|
2002
|
+
ResizeStarted: { id: Schema5.String, x: Schema5.Finite, pointerId: Schema5.Int },
|
|
2003
|
+
ResizeMoved: { x: Schema5.Finite, pointerId: Schema5.Int },
|
|
2004
|
+
ResizeEnded: { pointerId: Schema5.Int },
|
|
2005
|
+
ColumnFiltersCleared: { id: Schema5.String },
|
|
2006
|
+
ColumnSortCleared: { id: Schema5.String },
|
|
2007
|
+
CellEditRequested: eventFields.CellEditRequested,
|
|
2008
|
+
RowActionRequested: eventFields.RowActionRequested,
|
|
2009
|
+
MenuOpened: { key: Schema5.String },
|
|
2010
|
+
MenuClosed: { key: Schema5.String },
|
|
2011
|
+
MenuQueryChanged: { key: Schema5.String, query: Schema5.String },
|
|
2012
|
+
SubmenuOpened: {
|
|
2013
|
+
key: Schema5.String,
|
|
2014
|
+
filterColumnId: Schema5.optionalKey(Schema5.String)
|
|
2015
|
+
},
|
|
2016
|
+
SubmenuClosed: { key: Schema5.String },
|
|
2017
|
+
SearchChanged: { value: Schema5.String },
|
|
2018
|
+
FilterInputChanged: {
|
|
2019
|
+
field: Schema5.Literals(["primary", "secondary"]),
|
|
2020
|
+
value: Schema5.String
|
|
2021
|
+
},
|
|
2022
|
+
FilterOperatorChanged: { operator: TextFilterOperator },
|
|
2023
|
+
FilterValueToggled: { value: Schema5.String, checked: Schema5.Boolean },
|
|
2024
|
+
FilterApplied: {},
|
|
2025
|
+
ColumnFilterChanged: {
|
|
2026
|
+
id: Schema5.String,
|
|
2027
|
+
filter: Schema5.NullOr(ColumnFilter)
|
|
2028
|
+
},
|
|
2029
|
+
FilterCleared: {},
|
|
2030
|
+
FiltersCleared: {},
|
|
2031
|
+
PageRequested: { page: Schema5.Int },
|
|
2032
|
+
ServerPageInvalidated: {},
|
|
2033
|
+
PageSizeRequested: { pageSize: Schema5.Int },
|
|
2034
|
+
SortRequested: {
|
|
2035
|
+
columnId: Schema5.String,
|
|
2036
|
+
direction: Schema5.NullOr(DataTableSortSchema.fields.direction)
|
|
2037
|
+
},
|
|
2038
|
+
ColumnVisibilityChanged: { id: Schema5.String, visible: Schema5.Boolean },
|
|
2039
|
+
SelectionRequested: {
|
|
2040
|
+
rowIds: Schema5.Array(Schema5.String),
|
|
2041
|
+
checked: Schema5.Boolean
|
|
2042
|
+
},
|
|
2043
|
+
BulkActionRequested: { actionId: Schema5.String }
|
|
2044
|
+
}).annotate({ identifier: "DataTableMessage" });
|
|
2045
|
+
var dataTableOptions = {
|
|
2046
|
+
name: "DataTable",
|
|
2047
|
+
props: DataTablePropsSchema,
|
|
2048
|
+
model: Schema5.Struct({
|
|
2049
|
+
menu: Schema5.NullOr(Schema5.String),
|
|
2050
|
+
submenu: Schema5.NullOr(Schema5.String),
|
|
2051
|
+
menuQuery: Schema5.String,
|
|
2052
|
+
failedImages: Schema5.Array(Schema5.String),
|
|
2053
|
+
selectedRowIds: Schema5.Array(Schema5.String),
|
|
2054
|
+
query: DataTableQuerySchema,
|
|
2055
|
+
preferencesLoaded: Schema5.Boolean,
|
|
2056
|
+
columnVisibility: Schema5.Record(Schema5.String, Schema5.Boolean),
|
|
2057
|
+
columnSizing: Schema5.Record(Schema5.String, Schema5.Finite),
|
|
2058
|
+
view: DataTableViewSchema,
|
|
2059
|
+
grouping: Schema5.Array(Schema5.String),
|
|
2060
|
+
collapsedGroups: Schema5.Record(Schema5.String, Schema5.Boolean),
|
|
2061
|
+
dragging: Schema5.NullOr(Schema5.String),
|
|
2062
|
+
exporting: Schema5.Boolean,
|
|
2063
|
+
exportFailed: Schema5.Boolean,
|
|
2064
|
+
resizing: Schema5.NullOr(Schema5.Struct({
|
|
2065
|
+
id: Schema5.String,
|
|
2066
|
+
x: Schema5.Finite,
|
|
2067
|
+
width: Schema5.Finite,
|
|
2068
|
+
pointerId: Schema5.Int
|
|
2069
|
+
}).annotate({ identifier: "DataTableResizeSession" })),
|
|
2070
|
+
filterDraft: Schema5.NullOr(DataTableFilterDraftSchema),
|
|
2071
|
+
invalidFilter: Schema5.Boolean
|
|
2072
|
+
}).annotate({ identifier: "DataTableModel" }),
|
|
2073
|
+
message: DataTableMessage,
|
|
2074
|
+
events: DataTableEvents,
|
|
2075
|
+
restore: false
|
|
2076
|
+
};
|
|
2077
|
+
var available = (props) => props.status?.error === undefined && (!props.status?.loading || props.rowData.length > 0);
|
|
2078
|
+
var tableQuery = (props, model) => props.state ?? { ...model.query, sort: props.sort ?? model.query.sort };
|
|
2079
|
+
var tableFeatures = (props) => ({
|
|
2080
|
+
...props.features,
|
|
2081
|
+
search: props.features?.search ?? props.search ?? true,
|
|
2082
|
+
filtering: props.features?.filtering ?? props.columnFilters ?? true,
|
|
2083
|
+
sorting: props.features?.sorting ?? true,
|
|
2084
|
+
columnVisibility: props.features?.columnVisibility ?? true,
|
|
2085
|
+
pagination: props.features?.pagination ?? props.pagination
|
|
2086
|
+
});
|
|
2087
|
+
var tableSelectedRowIds = (props, model) => {
|
|
2088
|
+
const supplied = new Set(props.rowData.map(({ id }) => id));
|
|
2089
|
+
return [
|
|
2090
|
+
...new Set(props.selection?.selectedRowIds ?? model.selectedRowIds)
|
|
2091
|
+
].filter((id) => supplied.has(id));
|
|
2092
|
+
};
|
|
2093
|
+
var serverPageCorrection = (props, model) => {
|
|
2094
|
+
const pagination = tableFeatures(props).pagination;
|
|
2095
|
+
if (!pagination || pagination.mode !== "server")
|
|
2096
|
+
return;
|
|
2097
|
+
const query = tableQuery(props, model);
|
|
2098
|
+
const { page } = resolveTablePage(pagination.rowCount, query);
|
|
2099
|
+
if (query.page !== page)
|
|
2100
|
+
return { requested: query.page, page, size: query.pageSize };
|
|
2101
|
+
};
|
|
2102
|
+
var tablePreferencesKey = (pathname, columns, gallery) => `data-table:${pathname}:${columns.join(",")}:${gallery ? "gallery" : "table"}:ui`;
|
|
2103
|
+
var preferencesJson = Schema5.fromJsonString(DataTablePreferencesSchema);
|
|
2104
|
+
var decodePreferences = Schema5.decodeUnknownOption(preferencesJson);
|
|
2105
|
+
var encodePreferences = Schema5.encodeSync(preferencesJson);
|
|
2106
|
+
var readTablePreferences = (key, host = globalThis.window) => {
|
|
2107
|
+
try {
|
|
2108
|
+
return Option3.getOrNull(decodePreferences(host?.localStorage.getItem(key)));
|
|
2109
|
+
} catch {
|
|
2110
|
+
return null;
|
|
2111
|
+
}
|
|
2112
|
+
};
|
|
2113
|
+
var writeTablePreferences = (key, preferences, host = globalThis.window) => {
|
|
2114
|
+
try {
|
|
2115
|
+
host?.localStorage.setItem(key, encodePreferences(preferences));
|
|
2116
|
+
} catch {}
|
|
2117
|
+
};
|
|
2118
|
+
var tablePreferences = (model) => model.preferencesLoaded ? {
|
|
2119
|
+
columnVisibility: model.columnVisibility,
|
|
2120
|
+
columnSizing: model.columnSizing,
|
|
2121
|
+
grouping: model.grouping,
|
|
2122
|
+
view: model.view
|
|
2123
|
+
} : null;
|
|
2124
|
+
var tableColumnLimits = (column) => {
|
|
2125
|
+
const min = column.minWidth ?? 96;
|
|
2126
|
+
return { min, max: Math.max(min, column.maxWidth ?? 640) };
|
|
2127
|
+
};
|
|
2128
|
+
var clampTableWidth = (column, width = column.width ?? 208) => {
|
|
2129
|
+
const { min, max } = tableColumnLimits(column);
|
|
2130
|
+
return Math.min(max, Math.max(min, width));
|
|
2131
|
+
};
|
|
2132
|
+
var tableColumnWidth = (column, sizing) => clampTableWidth(column, sizing[column.id]);
|
|
2133
|
+
var tableLayoutWidth = (widths, utilityColumns) => widths.reduce((total, width) => total + width, utilityColumns * 40);
|
|
2134
|
+
var tableResizeStep = (key) => key === "ArrowLeft" ? -8 : key === "ArrowRight" ? 8 : 0;
|
|
2135
|
+
var activeTableGroups = (grouping, fields) => grouping.flatMap((id) => fields.find((field) => field.id === id) ?? []);
|
|
2136
|
+
var tableGrouping = (props, model) => activeTableGroups(model.grouping, props.features?.grouping?.fields ?? []);
|
|
2137
|
+
var canReorderTableRows = (props, model) => !!props.features?.reordering && !tableGrouping(props, model).length && !tableQuery(props, model).sort?.length;
|
|
2138
|
+
var partitionTableGroups = (rows, known, memberships) => {
|
|
2139
|
+
const groups = new Map(known.map((id) => [id, []]));
|
|
2140
|
+
for (const row of rows) {
|
|
2141
|
+
for (const id of new Set(memberships(row))) {
|
|
2142
|
+
const group = groups.get(id);
|
|
2143
|
+
if (group)
|
|
2144
|
+
group.push(row);
|
|
2145
|
+
else
|
|
2146
|
+
groups.set(id, [row]);
|
|
2147
|
+
}
|
|
2148
|
+
}
|
|
2149
|
+
return groups;
|
|
2150
|
+
};
|
|
2151
|
+
var tableGroupKey = (parent, fieldId, groupId) => `${parent ? `${parent}/` : ""}${encodeURIComponent(fieldId)}:${encodeURIComponent(groupId)}`;
|
|
2152
|
+
var reorderRows = ($, rowId, targetId, after) => {
|
|
2153
|
+
const rowIds = $.props.rowData.map(({ id }) => id);
|
|
2154
|
+
const next = $.evolve({ dragging: null });
|
|
2155
|
+
if (!available($.props) || !canReorderTableRows($.props, $.model) || rowId === targetId || !rowIds.includes(rowId) || !rowIds.includes(targetId))
|
|
2156
|
+
return next;
|
|
2157
|
+
const reordered = rowIds.filter((id) => id !== rowId);
|
|
2158
|
+
reordered.splice(reordered.indexOf(targetId) + Number(after), 0, rowId);
|
|
2159
|
+
return next.emit(DataTableEvents.RowsReordered({ rowIds: reordered }));
|
|
2160
|
+
};
|
|
2161
|
+
var moveGroup = ($, rowId, fieldId, groupId) => {
|
|
2162
|
+
const field = tableGrouping($.props, $.model).find(({ id }) => id === fieldId);
|
|
2163
|
+
const row = $.props.rowData.find(({ id }) => id === rowId);
|
|
2164
|
+
const next = $.evolve({ dragging: null });
|
|
2165
|
+
if (!available($.props) || !field?.movable || !row || row.groups?.[fieldId]?.includes(groupId))
|
|
2166
|
+
return next;
|
|
2167
|
+
if (!field.groups?.some(({ id }) => id === groupId) && !$.props.rowData.some((row) => row.groups?.[fieldId]?.includes(groupId)))
|
|
2168
|
+
return next;
|
|
2169
|
+
return next.emit(DataTableEvents.GroupMoveRequested({ rowId, fieldId, groupId }));
|
|
2170
|
+
};
|
|
2171
|
+
var changeQuery = ($, patch, ui = {}, legacy) => {
|
|
2172
|
+
const current = tableQuery($.props, $.model);
|
|
2173
|
+
const state = { ...current, ...patch };
|
|
2174
|
+
if (state.page === current.page && state.pageSize === current.pageSize && state.globalFilter === current.globalFilter && state.filters === current.filters && state.sort === current.sort)
|
|
2175
|
+
return $.evolve(ui);
|
|
2176
|
+
const step = $.evolve({
|
|
2177
|
+
...ui,
|
|
2178
|
+
query: $.props.state ? $.model.query : { ...state, sort: $.props.sort ? $.model.query.sort : state.sort }
|
|
2179
|
+
}).emit(DataTableEvents.StateChanged({ state }));
|
|
2180
|
+
return legacy ? step.emit(legacy) : step;
|
|
2181
|
+
};
|
|
2182
|
+
var tableFilterDraft = (id, current) => ({
|
|
2183
|
+
id,
|
|
2184
|
+
primary: current?.kind === "text" || current?.kind === "boolean" ? String(current.value) : current?.kind === "number" ? String(current.min ?? "") : current?.kind === "date" ? current.from ?? "" : "",
|
|
2185
|
+
secondary: current?.kind === "number" ? String(current.max ?? "") : current?.kind === "date" ? current.to ?? "" : "",
|
|
2186
|
+
operator: current?.kind === "text" ? current.operator : "contains",
|
|
2187
|
+
values: current?.kind === "values" ? current.values : []
|
|
2188
|
+
});
|
|
2189
|
+
var decodeFilter = Schema5.decodeUnknownOption(ColumnFilter);
|
|
2190
|
+
var decodeBound = Schema5.decodeOption(Schema5.FiniteFromString);
|
|
2191
|
+
var parseTableFilterDraft = (kind, {
|
|
2192
|
+
id,
|
|
2193
|
+
primary,
|
|
2194
|
+
secondary,
|
|
2195
|
+
operator,
|
|
2196
|
+
values
|
|
2197
|
+
}) => {
|
|
2198
|
+
switch (kind) {
|
|
2199
|
+
case "number": {
|
|
2200
|
+
const min = primary.trim() ? decodeBound(primary) : Option3.some(undefined);
|
|
2201
|
+
const max = secondary.trim() ? decodeBound(secondary) : Option3.some(undefined);
|
|
2202
|
+
return Option3.isNone(min) || Option3.isNone(max) ? Option3.none() : decodeFilter({ id, kind, min: min.value, max: max.value });
|
|
2203
|
+
}
|
|
2204
|
+
case "boolean":
|
|
2205
|
+
return decodeFilter({
|
|
2206
|
+
id,
|
|
2207
|
+
kind,
|
|
2208
|
+
value: primary === "true" ? true : primary === "false" ? false : undefined
|
|
2209
|
+
});
|
|
2210
|
+
case "values":
|
|
2211
|
+
return decodeFilter({ id, kind, values });
|
|
2212
|
+
case "date":
|
|
2213
|
+
return decodeFilter({
|
|
2214
|
+
id,
|
|
2215
|
+
kind,
|
|
2216
|
+
from: primary || undefined,
|
|
2217
|
+
to: secondary || undefined
|
|
2218
|
+
});
|
|
2219
|
+
case "text":
|
|
2220
|
+
return decodeFilter({ id, kind, operator, value: primary.trim() });
|
|
2221
|
+
}
|
|
2222
|
+
};
|
|
2223
|
+
var changeColumnFilter = ($, id, filter, ui) => {
|
|
2224
|
+
const filters = (tableQuery($.props, $.model).filters ?? []).filter((current) => current.id !== id);
|
|
2225
|
+
if (filter)
|
|
2226
|
+
filters.push(filter);
|
|
2227
|
+
return changeQuery($, { filters: filters.length ? filters : undefined, page: 0 }, ui);
|
|
2228
|
+
};
|
|
2229
|
+
var projectDataTableRows = (source, query, {
|
|
2230
|
+
pagination,
|
|
2231
|
+
grouped,
|
|
2232
|
+
sortMode,
|
|
2233
|
+
search,
|
|
2234
|
+
filter,
|
|
2235
|
+
sort
|
|
2236
|
+
}) => {
|
|
2237
|
+
const server = pagination && pagination.mode === "server";
|
|
2238
|
+
const filtered = server ? source : filter(search(source, query.globalFilter ?? ""), query.filters ?? []);
|
|
2239
|
+
const ordered = !server && sortMode !== "server" && query.sort?.length ? sort(filtered, query.sort) : filtered;
|
|
2240
|
+
const { pageSize } = query;
|
|
2241
|
+
const totalRows = server ? pagination.rowCount : ordered.length;
|
|
2242
|
+
const { page, pageCount, start, end } = resolveTablePage(totalRows, query);
|
|
2243
|
+
const paginationVisible = !!pagination && (server || !grouped);
|
|
2244
|
+
const rows = paginationVisible && !server ? ordered.slice(start, end) : ordered;
|
|
2245
|
+
return {
|
|
2246
|
+
rows,
|
|
2247
|
+
filtered,
|
|
2248
|
+
ordered,
|
|
2249
|
+
pageSize,
|
|
2250
|
+
totalRows,
|
|
2251
|
+
pageCount,
|
|
2252
|
+
page,
|
|
2253
|
+
paginationVisible
|
|
2254
|
+
};
|
|
2255
|
+
};
|
|
2256
|
+
var dataTablePage = (props, model, locale) => {
|
|
2257
|
+
const pagination = tableFeatures(props).pagination;
|
|
2258
|
+
const columns = tableDataColumns(props.columnDefs);
|
|
2259
|
+
return {
|
|
2260
|
+
...projectDataTableRows(props.rowData, tableQuery(props, model), {
|
|
2261
|
+
pagination,
|
|
2262
|
+
grouped: tableGrouping(props, model).length > 0,
|
|
2263
|
+
sortMode: props.sortMode,
|
|
2264
|
+
search: (rows, value) => filterTableRows(rows, columns, value, locale),
|
|
2265
|
+
filter: (rows, filters) => filterTableColumns(rows, columns, filters),
|
|
2266
|
+
sort: (rows, sorting) => sortTableRows(rows, columns, sorting, locale)
|
|
2267
|
+
}),
|
|
2268
|
+
pageSizes: pagination && pagination.pageSizes || defaultPageSizes
|
|
2269
|
+
};
|
|
2270
|
+
};
|
|
2271
|
+
var encodeTableCsv = (headers, data) => Effect2.runSync(Stream.fromIterable([headers, ...data]).pipe(Stream.map((row) => row.map((value) => value == null ? "" : String(value))), Stream.pipeThroughChannel(Csv.encodeString({ newline: `
|
|
2272
|
+
` })), Stream.runCollect, Effect2.map((parts) => parts.join("").slice(0, -1))));
|
|
2273
|
+
var tableExportFilename = (name, extension) => name.includes(".") ? name.replace(/\.[^/.]+$/, `.${extension}`) : `${name}.${extension}`;
|
|
2274
|
+
var downloadTableBlob = (content, type, filename) => {
|
|
2275
|
+
const url = window.URL.createObjectURL(new Blob([content], { type }));
|
|
2276
|
+
const link = document.createElement("a");
|
|
2277
|
+
link.href = url;
|
|
2278
|
+
link.download = filename;
|
|
2279
|
+
document.body.appendChild(link);
|
|
2280
|
+
try {
|
|
2281
|
+
link.click();
|
|
2282
|
+
} finally {
|
|
2283
|
+
link.remove();
|
|
2284
|
+
requestAnimationFrame(() => window.URL.revokeObjectURL(url));
|
|
2285
|
+
}
|
|
2286
|
+
};
|
|
2287
|
+
var tableExportValue = (column, row, locale) => {
|
|
2288
|
+
const value = row.cells[column.id];
|
|
2289
|
+
switch (column.type) {
|
|
2290
|
+
case "date":
|
|
2291
|
+
case "dateTime": {
|
|
2292
|
+
const date = resolveDate(value, column.type);
|
|
2293
|
+
return !date ? null : column.typeOptions?.exportFormat === "formatted" ? formatDateValue(date, column, locale) : dateIsoValue(date);
|
|
2294
|
+
}
|
|
2295
|
+
case "reference":
|
|
2296
|
+
return isTableReference(value) ? [value.label, value.description].filter(Boolean).join(" — ") : "";
|
|
2297
|
+
case "list":
|
|
2298
|
+
return isTableList(value) ? value.map(({ label }) => label).join(", ") : "";
|
|
2299
|
+
case "boolean":
|
|
2300
|
+
return !isTableBoolean(value) ? null : column.typeOptions?.exportFormat === "formatted" ? tableBooleanLabel(value, column.typeOptions) : value;
|
|
2301
|
+
case "number":
|
|
2302
|
+
return !isTableNumber(value) ? null : column.typeOptions?.exportFormat === "formatted" ? formatNumberValue(value, column.typeOptions, locale) : value;
|
|
2303
|
+
default:
|
|
2304
|
+
return columnValue(column, value);
|
|
2305
|
+
}
|
|
2306
|
+
};
|
|
2307
|
+
var DownloadTable = Command.make("DataTable/Download", {
|
|
2308
|
+
args: {
|
|
2309
|
+
filename: Schema5.String,
|
|
2310
|
+
content: Schema5.Redacted(Schema5.String, { disallowJsonEncode: true }),
|
|
2311
|
+
type: Schema5.String
|
|
2312
|
+
}
|
|
2313
|
+
}, ({ filename, content, type }) => Effect2.try(() => downloadTableBlob(Redacted.value(content), type, filename)).pipe(Effect2.match({
|
|
2314
|
+
onSuccess: () => DataTableMessage.ExportFinished({ failed: false }),
|
|
2315
|
+
onFailure: () => DataTableMessage.ExportFinished({ failed: true })
|
|
2316
|
+
})));
|
|
2317
|
+
var update2 = Component2.define(dataTableOptions).update({
|
|
2318
|
+
ReferenceImageFailed: ($, { src }) => $.model.failedImages.includes(src) ? $.model : $.evolve({ failedImages: [...$.model.failedImages, src] }),
|
|
2319
|
+
RowActivated: ($, { rowId }) => $.props.rowActivation && available($.props) && $.props.rowData.some(({ id }) => id === rowId) ? $.emit(DataTableEvents.RowActivated({ rowId })) : $.model,
|
|
2320
|
+
PreferencesLoaded: ($, { preferences }) => $.model.preferencesLoaded ? $.model : $.evolve({
|
|
2321
|
+
preferencesLoaded: true,
|
|
2322
|
+
columnVisibility: {
|
|
2323
|
+
...$.model.columnVisibility,
|
|
2324
|
+
...preferences?.columnVisibility
|
|
2325
|
+
},
|
|
2326
|
+
columnSizing: preferences?.columnSizing ?? $.model.columnSizing,
|
|
2327
|
+
grouping: preferences?.grouping ?? $.model.grouping,
|
|
2328
|
+
view: $.props.features?.gallery ? preferences?.view ?? $.model.view : "table"
|
|
2329
|
+
}),
|
|
2330
|
+
ItemActionRequested: ($, request) => {
|
|
2331
|
+
const row = $.props.rowData.find(({ id }) => id === request.rowId);
|
|
2332
|
+
const column = $.props.columnDefs.find(({ id }) => id === request.columnId);
|
|
2333
|
+
const items = row?.cells[request.columnId];
|
|
2334
|
+
return available($.props) && column?.type === "list" && isTableList(items) && items.some(({ value }) => value === request.itemId) && column.itemActions?.some(({ id, disabled }) => id === request.actionId && !disabled) ? $.emit(DataTableEvents.ItemActionRequested(request)) : $.model;
|
|
2335
|
+
},
|
|
2336
|
+
ExportStarted: ($) => $.evolve({ exporting: true, exportFailed: false }),
|
|
2337
|
+
ExportFinished: ($, { failed }) => $.evolve({ exporting: false, exportFailed: failed }),
|
|
2338
|
+
BuiltInExportRequested: ($, { format, locale = $.props.locale ?? "en" }) => {
|
|
2339
|
+
const feature = $.props.features?.export;
|
|
2340
|
+
if (!feature || feature.pending || $.model.exporting || feature.builtIn === false || !available($.props))
|
|
2341
|
+
return $.model;
|
|
2342
|
+
const projection = dataTablePage($.props, $.model, locale);
|
|
2343
|
+
const rows = feature.scope === "currentPage" ? projection.rows : projection.ordered;
|
|
2344
|
+
if (!rows.length)
|
|
2345
|
+
return $.model;
|
|
2346
|
+
const columns = tableDataColumns($.props.columnDefs.filter(({ id, export: enabled }) => enabled !== false && $.model.columnVisibility[id] !== false)).filter(({ export: enabled }) => enabled !== false);
|
|
2347
|
+
const content = format === "csv" ? encodeTableCsv(columns.map(({ headerName }) => headerName), rows.map((row) => columns.map((column) => tableExportValue(column, row, locale)))) : JSON.stringify(rows.map((row) => Object.fromEntries(columns.map((column) => [
|
|
2348
|
+
column.id,
|
|
2349
|
+
tableExportValue(column, row, locale)
|
|
2350
|
+
]))), null, 2);
|
|
2351
|
+
return $.evolve({ menu: null, exporting: true, exportFailed: false }).run(DownloadTable.make({
|
|
2352
|
+
content: Redacted.make(content),
|
|
2353
|
+
filename: tableExportFilename(feature.baseName, format),
|
|
2354
|
+
type: format === "csv" ? "text/csv;charset=utf-8" : "application/json;charset=utf-8"
|
|
2355
|
+
}));
|
|
2356
|
+
},
|
|
2357
|
+
RefreshRequested: ($) => $.props.features?.refresh ? $.emit(DataTableEvents.RefreshRequested()) : $.model,
|
|
2358
|
+
ExportRequested: ($, { actionId }) => !$.props.features?.export?.pending && $.props.features?.export?.actions?.some(({ id, disabled }) => id === actionId && !disabled) ? $.emit(DataTableEvents.ExportRequested({ actionId })) : $.model,
|
|
2359
|
+
GroupActionRequested: ($, request) => available($.props) && $.props.features?.grouping?.fields.some(({ id, actions }) => id === request.fieldId && actions?.some(({ id, disabled }) => id === request.actionId && !disabled)) ? $.emit(DataTableEvents.GroupActionRequested(request)) : $.model,
|
|
2360
|
+
GroupMoveRequested: ($, { rowId, fieldId, groupId }) => moveGroup($, rowId, fieldId, groupId),
|
|
2361
|
+
ReorderRequested: ($, { rowId, targetId, after }) => reorderRows($, rowId, targetId, after),
|
|
2362
|
+
DragStarted: ($, { rowId }) => $.evolve({ dragging: rowId }),
|
|
2363
|
+
DragEnded: ($) => $.evolve({ dragging: null }),
|
|
2364
|
+
DragDropped: ($, { targetId }) => $.model.dragging === null ? $.model : reorderRows($, $.model.dragging, targetId, $.props.rowData.findIndex(({ id }) => id === $.model.dragging) < $.props.rowData.findIndex(({ id }) => id === targetId)),
|
|
2365
|
+
GroupDropped: ($, { fieldId, groupId }) => $.model.dragging === null ? $.model : moveGroup($, $.model.dragging, fieldId, groupId),
|
|
2366
|
+
ViewPicked: ($, { view }) => view === "table" || $.props.features?.gallery ? $.evolve({ view, menu: null }) : $.model,
|
|
2367
|
+
GroupingToggled: ($, { fieldId }) => $.props.features?.grouping?.fields.some(({ id }) => id === fieldId) ? $.evolve({
|
|
2368
|
+
grouping: updateSelectedRows($.model.grouping, [fieldId], !$.model.grouping.includes(fieldId))
|
|
2369
|
+
}) : $.model,
|
|
2370
|
+
GroupToggled: ($, { key }) => $.evolve({
|
|
2371
|
+
collapsedGroups: {
|
|
2372
|
+
...$.model.collapsedGroups,
|
|
2373
|
+
[key]: !$.model.collapsedGroups[key]
|
|
2374
|
+
}
|
|
2375
|
+
}),
|
|
2376
|
+
ColumnResized: ($, { id, delta }) => {
|
|
2377
|
+
const column = $.props.columnDefs.find((column) => column.id === id);
|
|
2378
|
+
if (!column || column.resizable === false)
|
|
2379
|
+
return $.model;
|
|
2380
|
+
const sizing = {
|
|
2381
|
+
...$.model.columnSizing,
|
|
2382
|
+
[id]: tableColumnWidth(column, $.model.columnSizing) + delta
|
|
2383
|
+
};
|
|
2384
|
+
return $.evolve({
|
|
2385
|
+
columnSizing: { ...sizing, [id]: tableColumnWidth(column, sizing) }
|
|
2386
|
+
});
|
|
2387
|
+
},
|
|
2388
|
+
ColumnResizeReset: ($, { id }) => {
|
|
2389
|
+
const column = $.props.columnDefs.find((column) => column.id === id);
|
|
2390
|
+
if (!column || column.resizable === false)
|
|
2391
|
+
return $.model;
|
|
2392
|
+
return $.evolve({
|
|
2393
|
+
columnSizing: {
|
|
2394
|
+
...$.model.columnSizing,
|
|
2395
|
+
[id]: clampTableWidth(column)
|
|
2396
|
+
}
|
|
2397
|
+
});
|
|
2398
|
+
},
|
|
2399
|
+
ResizeStarted: ($, { id, x, pointerId }) => {
|
|
2400
|
+
const column = $.props.columnDefs.find((column) => column.id === id);
|
|
2401
|
+
return column && column.resizable !== false ? $.evolve({
|
|
2402
|
+
resizing: {
|
|
2403
|
+
id,
|
|
2404
|
+
x,
|
|
2405
|
+
pointerId,
|
|
2406
|
+
width: tableColumnWidth(column, $.model.columnSizing)
|
|
2407
|
+
}
|
|
2408
|
+
}) : $.model;
|
|
2409
|
+
},
|
|
2410
|
+
ResizeMoved: ($, { x, pointerId }) => {
|
|
2411
|
+
const resize = $.model.resizing;
|
|
2412
|
+
const column = resize && $.props.columnDefs.find(({ id }) => id === resize.id);
|
|
2413
|
+
if (!resize || resize.pointerId !== pointerId || !column || column.resizable === false)
|
|
2414
|
+
return $.model;
|
|
2415
|
+
return $.evolve({
|
|
2416
|
+
columnSizing: {
|
|
2417
|
+
...$.model.columnSizing,
|
|
2418
|
+
[resize.id]: tableColumnWidth(column, {
|
|
2419
|
+
[resize.id]: resize.width + x - resize.x
|
|
2420
|
+
})
|
|
2421
|
+
}
|
|
2422
|
+
});
|
|
2423
|
+
},
|
|
2424
|
+
ResizeEnded: ($, { pointerId }) => $.model.resizing?.pointerId === pointerId ? $.evolve({ resizing: null }) : $.model,
|
|
2425
|
+
ColumnFiltersCleared: ($, { id }) => {
|
|
2426
|
+
const column = $.props.columnDefs.find((column) => column.id === id);
|
|
2427
|
+
if (!column || !tableFeatures($.props).filtering)
|
|
2428
|
+
return $.model;
|
|
2429
|
+
const owned = new Set([
|
|
2430
|
+
id,
|
|
2431
|
+
...tableDataColumns([column]).map(({ id }) => id)
|
|
2432
|
+
]);
|
|
2433
|
+
const filters = tableQuery($.props, $.model).filters?.filter(({ id }) => !owned.has(id));
|
|
2434
|
+
return changeQuery($, { filters: filters?.length ? filters : undefined, page: 0 }, { filterDraft: null, invalidFilter: false });
|
|
2435
|
+
},
|
|
2436
|
+
ColumnSortCleared: ($, { id }) => {
|
|
2437
|
+
const column = $.props.columnDefs.find((column) => column.id === id);
|
|
2438
|
+
if (!column || !tableFeatures($.props).sorting)
|
|
2439
|
+
return $.model;
|
|
2440
|
+
const owned = new Set([
|
|
2441
|
+
id,
|
|
2442
|
+
...tableDataColumns([column]).map(({ id }) => id)
|
|
2443
|
+
]);
|
|
2444
|
+
const sort = (tableQuery($.props, $.model).sort ?? []).filter(({ id }) => !owned.has(id));
|
|
2445
|
+
return changeQuery($, { sort }, {}, DataTableEvents.SortChanged({ sort }));
|
|
2446
|
+
},
|
|
2447
|
+
MenuOpened: ($, { key }) => $.evolve({ menu: key, submenu: null, menuQuery: "" }),
|
|
2448
|
+
MenuQueryChanged: ($, { key, query }) => $.model.menu === key ? $.evolve({ menuQuery: query }) : $.model,
|
|
2449
|
+
MenuClosed: ($, { key }) => $.model.menu === key ? $.evolve({ menu: null, submenu: null }) : $.model,
|
|
2450
|
+
SubmenuOpened: ($, { key, filterColumnId }) => $.evolve({
|
|
2451
|
+
submenu: key,
|
|
2452
|
+
menuQuery: "",
|
|
2453
|
+
...filterColumnId === undefined ? {} : {
|
|
2454
|
+
filterDraft: tableFilterDraft(filterColumnId, tableQuery($.props, $.model).filters?.find(({ id }) => id === filterColumnId)),
|
|
2455
|
+
invalidFilter: false
|
|
2456
|
+
}
|
|
2457
|
+
}),
|
|
2458
|
+
SubmenuClosed: ($, { key }) => $.model.submenu === key ? $.evolve({ submenu: null }) : $.model,
|
|
2459
|
+
SearchChanged: ($, { value }) => tableFeatures($.props).search ? changeQuery($, { globalFilter: value || undefined, page: 0 }, { menu: null }) : $.model,
|
|
2460
|
+
FilterInputChanged: ($, { field, value }) => {
|
|
2461
|
+
const draft = $.model.filterDraft;
|
|
2462
|
+
return draft ? $.evolve({
|
|
2463
|
+
filterDraft: { ...draft, [field]: value },
|
|
2464
|
+
invalidFilter: false
|
|
2465
|
+
}) : $.model;
|
|
2466
|
+
},
|
|
2467
|
+
FilterOperatorChanged: ($, { operator }) => {
|
|
2468
|
+
const draft = $.model.filterDraft;
|
|
2469
|
+
return draft ? $.evolve({
|
|
2470
|
+
filterDraft: { ...draft, operator },
|
|
2471
|
+
invalidFilter: false
|
|
2472
|
+
}) : $.model;
|
|
2473
|
+
},
|
|
2474
|
+
FilterValueToggled: ($, { value, checked }) => {
|
|
2475
|
+
const draft = $.model.filterDraft;
|
|
2476
|
+
return draft ? $.evolve({
|
|
2477
|
+
filterDraft: {
|
|
2478
|
+
...draft,
|
|
2479
|
+
values: updateSelectedRows(draft.values, [value], checked)
|
|
2480
|
+
},
|
|
2481
|
+
invalidFilter: false
|
|
2482
|
+
}) : $.model;
|
|
2483
|
+
},
|
|
2484
|
+
FilterApplied: ($) => {
|
|
2485
|
+
const draft = $.model.filterDraft;
|
|
2486
|
+
if (!tableFeatures($.props).filtering || !draft)
|
|
2487
|
+
return $.model;
|
|
2488
|
+
const column = tableDataColumns($.props.columnDefs).find(({ id, filterable }) => id === draft.id && filterable !== false);
|
|
2489
|
+
if (!column)
|
|
2490
|
+
return $.model;
|
|
2491
|
+
const decoded = parseTableFilterDraft(tableFilterKind(column), draft);
|
|
2492
|
+
return Option3.isNone(decoded) ? $.evolve({ invalidFilter: true }) : changeColumnFilter($, draft.id, decoded.value, {
|
|
2493
|
+
invalidFilter: false
|
|
2494
|
+
});
|
|
2495
|
+
},
|
|
2496
|
+
FilterCleared: ($) => {
|
|
2497
|
+
const draft = $.model.filterDraft;
|
|
2498
|
+
if (!draft)
|
|
2499
|
+
return $.model;
|
|
2500
|
+
return changeColumnFilter($, draft.id, null, {
|
|
2501
|
+
filterDraft: tableFilterDraft(draft.id),
|
|
2502
|
+
invalidFilter: false
|
|
2503
|
+
});
|
|
2504
|
+
},
|
|
2505
|
+
ColumnFilterChanged: ($, { id, filter }) => {
|
|
2506
|
+
if (!tableFeatures($.props).filtering || !tableDataColumns($.props.columnDefs).some((column) => column.id === id && column.filterable !== false) || filter && filter.id !== id)
|
|
2507
|
+
return $.model;
|
|
2508
|
+
return changeColumnFilter($, id, filter);
|
|
2509
|
+
},
|
|
2510
|
+
FiltersCleared: ($) => changeQuery($, { filters: undefined, page: 0 }, {
|
|
2511
|
+
filterDraft: null,
|
|
2512
|
+
invalidFilter: false
|
|
2513
|
+
}),
|
|
2514
|
+
PageRequested: ($, { page }) => tableFeatures($.props).pagination && page >= 0 ? changeQuery($, { page }, { menu: null }) : $.model,
|
|
2515
|
+
ServerPageInvalidated: ($) => {
|
|
2516
|
+
const correction = serverPageCorrection($.props, $.model);
|
|
2517
|
+
return correction ? changeQuery($, { page: correction.page }) : $.model;
|
|
2518
|
+
},
|
|
2519
|
+
PageSizeRequested: ($, { pageSize }) => {
|
|
2520
|
+
const pagination = tableFeatures($.props).pagination;
|
|
2521
|
+
return pagination && (pagination.pageSizes ?? defaultPageSizes).includes(pageSize) ? changeQuery($, { pageSize, page: 0 }, { menu: null }) : $.model;
|
|
2522
|
+
},
|
|
2523
|
+
SortRequested: ($, { columnId, direction }) => {
|
|
2524
|
+
if (!tableFeatures($.props).sorting || !tableDataColumns($.props.columnDefs).some(({ id, sortable }) => id === columnId && sortable !== false))
|
|
2525
|
+
return $.model;
|
|
2526
|
+
const sort = direction === null ? (tableQuery($.props, $.model).sort ?? []).filter(({ id }) => id !== columnId) : [{ id: columnId, direction }];
|
|
2527
|
+
return changeQuery($, { sort: sort.length ? sort : undefined, page: 0 }, {}, DataTableEvents.SortChanged({ sort }));
|
|
2528
|
+
},
|
|
2529
|
+
ColumnVisibilityChanged: ($, { id, visible }) => tableFeatures($.props).columnVisibility && $.props.columnDefs.some((column) => column.id === id && column.hideable !== false) ? $.evolve({
|
|
2530
|
+
columnVisibility: { ...$.model.columnVisibility, [id]: visible }
|
|
2531
|
+
}) : $.model,
|
|
2532
|
+
SelectionRequested: ($, { rowIds, checked }) => {
|
|
2533
|
+
if (!available($.props) || !$.props.selection)
|
|
2534
|
+
return $.model;
|
|
2535
|
+
const requested = new Set(rowIds);
|
|
2536
|
+
const targets = $.props.rowData.filter((row) => row.selectable !== false && requested.has(row.id)).map(({ id }) => id);
|
|
2537
|
+
if (targets.length === 0)
|
|
2538
|
+
return $.model;
|
|
2539
|
+
const controlled = $.props.selection.selectedRowIds;
|
|
2540
|
+
const selectedRowIds = updateSelectedRows(controlled ?? $.model.selectedRowIds, targets, checked);
|
|
2541
|
+
return $.evolve(controlled ? {} : { selectedRowIds }).emit(DataTableEvents.SelectionChanged({ selectedRowIds }));
|
|
2542
|
+
},
|
|
2543
|
+
CellEditRequested: ($, { rowId, columnId, edit }) => {
|
|
2544
|
+
if (!available($.props))
|
|
2545
|
+
return $.model;
|
|
2546
|
+
const row = $.props.rowData.find(({ id }) => id === rowId);
|
|
2547
|
+
const column = $.props.columnDefs.find(({ id }) => id === columnId);
|
|
2548
|
+
if (!row || !column || row.disabledColumnIds?.includes(columnId))
|
|
2549
|
+
return $.model;
|
|
2550
|
+
const value = row.cells[columnId];
|
|
2551
|
+
if (edit._tag === "SetBoolean") {
|
|
2552
|
+
if (column.type !== "boolean" || !column.editable || !isTableBoolean(value) || edit.value === value)
|
|
2553
|
+
return $.model;
|
|
2554
|
+
} else {
|
|
2555
|
+
if (column.type !== "list")
|
|
2556
|
+
return $.model;
|
|
2557
|
+
const items = isTableList(value) ? value : [];
|
|
2558
|
+
const contains = items.some(({ value }) => value === edit.itemId);
|
|
2559
|
+
if (edit._tag === "AddItem") {
|
|
2560
|
+
if (contains || !column.options?.some(({ value }) => value === edit.itemId))
|
|
2561
|
+
return $.model;
|
|
2562
|
+
} else if (!contains || !column.allowRemove)
|
|
2563
|
+
return $.model;
|
|
2564
|
+
}
|
|
2565
|
+
return $.emit(DataTableEvents.CellEditRequested({ rowId, columnId, edit }));
|
|
2566
|
+
},
|
|
2567
|
+
RowActionRequested: ($, { rowId, actionId }) => {
|
|
2568
|
+
const row = $.props.rowData.find(({ id }) => id === rowId);
|
|
2569
|
+
if (!available($.props) || !row?.actions?.some(({ id, disabled }) => id === actionId && !disabled))
|
|
2570
|
+
return $.model;
|
|
2571
|
+
return $.emit(DataTableEvents.RowActionRequested({ rowId, actionId }));
|
|
2572
|
+
},
|
|
2573
|
+
BulkActionRequested: ($, { actionId }) => {
|
|
2574
|
+
const selection = $.props.selection;
|
|
2575
|
+
if (!available($.props) || !selection?.bulkActions?.some(({ id, disabled }) => id === actionId && !disabled))
|
|
2576
|
+
return $.model;
|
|
2577
|
+
const rowIds = tableSelectedRowIds($.props, $.model);
|
|
2578
|
+
return rowIds.length > 0 ? $.emit(DataTableEvents.BulkActionRequested({ actionId, rowIds })) : $.model;
|
|
2579
|
+
}
|
|
2580
|
+
});
|
|
2581
|
+
var dataTableBehaviours = {
|
|
2582
|
+
subscriptions: ({
|
|
2583
|
+
props,
|
|
2584
|
+
model
|
|
2585
|
+
}) => {
|
|
2586
|
+
const correction = serverPageCorrection(props, model);
|
|
2587
|
+
return correction ? [
|
|
2588
|
+
Subscription.make("reconcile-server-page", [correction.requested, correction.page, correction.size], () => Stream.make(DataTableMessage.ServerPageInvalidated()))
|
|
2589
|
+
] : [];
|
|
2590
|
+
},
|
|
2591
|
+
init: ({ props }) => ({
|
|
2592
|
+
menu: null,
|
|
2593
|
+
submenu: null,
|
|
2594
|
+
menuQuery: "",
|
|
2595
|
+
failedImages: [],
|
|
2596
|
+
selectedRowIds: [],
|
|
2597
|
+
query: {
|
|
2598
|
+
globalFilter: props.initialState?.globalFilter,
|
|
2599
|
+
filters: props.initialState?.filters,
|
|
2600
|
+
sort: props.initialState?.sort,
|
|
2601
|
+
page: props.initialState?.page ?? 0,
|
|
2602
|
+
pageSize: props.initialState?.pageSize ?? (props.pagination?.mode === undefined ? props.pagination?.pageSizes?.[0] : undefined) ?? DEFAULT_PAGE_SIZE
|
|
2603
|
+
},
|
|
2604
|
+
columnVisibility: props.initialState?.columnVisibility ?? {},
|
|
2605
|
+
preferencesLoaded: false,
|
|
2606
|
+
columnSizing: {},
|
|
2607
|
+
view: props.initialState?.view ?? "table",
|
|
2608
|
+
grouping: props.features?.grouping?.initial ?? [],
|
|
2609
|
+
collapsedGroups: {},
|
|
2610
|
+
dragging: null,
|
|
2611
|
+
exporting: false,
|
|
2612
|
+
exportFailed: false,
|
|
2613
|
+
resizing: null,
|
|
2614
|
+
filterDraft: null,
|
|
2615
|
+
invalidFilter: false
|
|
2616
|
+
}),
|
|
2617
|
+
update: update2
|
|
2618
|
+
};
|
|
2619
|
+
|
|
2620
|
+
// ../../src/components/data-table/react.tsx
|
|
1213
2621
|
import { jsx as jsx15, jsxs as jsxs9, Fragment } from "react/jsx-runtime";
|
|
1214
2622
|
var DataTableStylesContext = createContext(undefined);
|
|
2623
|
+
var DataTableSlotClassesContext = createContext(resolveTableClasses());
|
|
1215
2624
|
var styledTablePart = (Part, slot, style) => {
|
|
1216
2625
|
const StyledPart = (props) => {
|
|
1217
2626
|
const styles = useContext(DataTableStylesContext);
|
|
@@ -1250,27 +2659,21 @@ var DropdownMenuLabel2 = styledTablePart(DropdownMenuLabel, "row-menu-label", (s
|
|
|
1250
2659
|
var DropdownMenuSeparator2 = styledTablePart(DropdownMenuSeparator, "row-menu-separator", (s) => s?.menu?.separator);
|
|
1251
2660
|
var SelectContent2 = styledTablePart(SelectContent, "select-popup", (s) => s?.popup?.select);
|
|
1252
2661
|
var TooltipContent2 = styledTablePart(TooltipContent, "tooltip", (s) => s?.popup?.tooltip);
|
|
1253
|
-
var DataTablePersistedUiStateSchema = Schema2.Struct({
|
|
1254
|
-
columnVisibility: Schema2.Record(Schema2.String, Schema2.Boolean),
|
|
1255
|
-
columnSizing: Schema2.Record(Schema2.String, Schema2.Finite),
|
|
1256
|
-
grouping: Schema2.optionalKey(Schema2.Array(Schema2.String)),
|
|
1257
|
-
view: Schema2.Literals(["table", "gallery"])
|
|
1258
|
-
}).annotate({ identifier: "DataTablePersistedUiState" });
|
|
1259
|
-
var dataTableStorageRuntime = Atom.runtime(BrowserKeyValueStore.layerLocalStorage);
|
|
1260
2662
|
var DataTableReferenceCell = ({
|
|
1261
2663
|
item,
|
|
1262
2664
|
emptyLabel = "—",
|
|
1263
2665
|
imageVariant = "circle"
|
|
1264
2666
|
}) => {
|
|
2667
|
+
const tableClasses = useContext(DataTableSlotClassesContext);
|
|
1265
2668
|
const [failedImage, setFailedImage] = useState();
|
|
1266
2669
|
if (!item)
|
|
1267
2670
|
return emptyLabel;
|
|
1268
|
-
const initials = item.label
|
|
2671
|
+
const initials = tableInitials(item.label);
|
|
1269
2672
|
return /* @__PURE__ */ jsxs9("div", {
|
|
1270
|
-
className:
|
|
2673
|
+
className: tableClasses.reference,
|
|
1271
2674
|
children: [
|
|
1272
2675
|
/* @__PURE__ */ jsx15("div", {
|
|
1273
|
-
className: cn(
|
|
2676
|
+
className: cn(tableClasses.referenceAvatar, imageVariant === "circle" ? "rounded-full" : "rounded-md", item.iconClassName),
|
|
1274
2677
|
children: item.icon ? /* @__PURE__ */ jsx15("span", {
|
|
1275
2678
|
"aria-hidden": "true",
|
|
1276
2679
|
className: "[&_svg]:size-4",
|
|
@@ -1286,14 +2689,14 @@ var DataTableReferenceCell = ({
|
|
|
1286
2689
|
})
|
|
1287
2690
|
}),
|
|
1288
2691
|
/* @__PURE__ */ jsxs9("div", {
|
|
1289
|
-
className:
|
|
2692
|
+
className: tableClasses.referenceText,
|
|
1290
2693
|
children: [
|
|
1291
2694
|
/* @__PURE__ */ jsx15("span", {
|
|
1292
|
-
className:
|
|
2695
|
+
className: tableClasses.referenceName,
|
|
1293
2696
|
children: item.label
|
|
1294
2697
|
}),
|
|
1295
2698
|
item.description ? /* @__PURE__ */ jsx15("span", {
|
|
1296
|
-
className:
|
|
2699
|
+
className: tableClasses.referenceDescription,
|
|
1297
2700
|
children: item.description
|
|
1298
2701
|
}) : null
|
|
1299
2702
|
]
|
|
@@ -1305,28 +2708,10 @@ var referenceText = (item) => item ? [item.label, item.description].filter(Boole
|
|
|
1305
2708
|
var messages2 = {
|
|
1306
2709
|
en: {
|
|
1307
2710
|
...paginationMessages("en"),
|
|
1308
|
-
|
|
1309
|
-
addItem: "Add item...",
|
|
1310
|
-
empty: "No results.",
|
|
1311
|
-
loading: "Loading...",
|
|
2711
|
+
...defaultMessages.en,
|
|
1312
2712
|
filter: "Filter results...",
|
|
1313
|
-
filters: "Filters",
|
|
1314
|
-
filtersClear: "Clear all filters",
|
|
1315
|
-
filterClear: "Clear filter",
|
|
1316
|
-
filterApply: "Apply filter",
|
|
1317
|
-
filterValue: "Value",
|
|
1318
|
-
filterOperator: "Operator",
|
|
1319
|
-
filterContains: "Contains",
|
|
1320
|
-
filterEquals: "Equals",
|
|
1321
|
-
filterStartsWith: "Starts with",
|
|
1322
|
-
filterEndsWith: "Ends with",
|
|
1323
|
-
filterMin: "Minimum",
|
|
1324
|
-
filterMax: "Maximum",
|
|
1325
2713
|
filterFrom: "From (UTC)",
|
|
1326
2714
|
filterTo: "To (UTC)",
|
|
1327
|
-
filterTrue: "True",
|
|
1328
|
-
filterFalse: "False",
|
|
1329
|
-
filterInvalid: "Enter a valid filter. Ranges must be in ascending order.",
|
|
1330
2715
|
export: "Export",
|
|
1331
2716
|
exportCsv: "CSV",
|
|
1332
2717
|
exportJson: "JSON",
|
|
@@ -1337,45 +2722,20 @@ var messages2 = {
|
|
|
1337
2722
|
galleryView: "Gallery",
|
|
1338
2723
|
columns: "Columns",
|
|
1339
2724
|
groupBy: "Group by",
|
|
1340
|
-
sortAsc: "Ascending",
|
|
1341
|
-
sortDesc: "Descending",
|
|
1342
|
-
sortClear: "Clear sorting",
|
|
1343
2725
|
sortBy: "Sort by",
|
|
1344
2726
|
hideColumn: "Hide column",
|
|
1345
2727
|
reorder: "Drag to reorder",
|
|
1346
|
-
removeItem: "Remove",
|
|
1347
2728
|
moveUp: "Move up",
|
|
1348
2729
|
moveDown: "Move down",
|
|
1349
2730
|
resizeColumn: (column) => `Resize ${column} column`,
|
|
1350
|
-
listDetails: "View all items"
|
|
1351
|
-
selectAllRows: "Select all rows on this page",
|
|
1352
|
-
selectRow: "Select row",
|
|
1353
|
-
selected: "Selected"
|
|
2731
|
+
listDetails: "View all items"
|
|
1354
2732
|
},
|
|
1355
2733
|
fr: {
|
|
1356
2734
|
...paginationMessages("fr"),
|
|
1357
|
-
|
|
1358
|
-
addItem: "Ajouter un élément...",
|
|
1359
|
-
empty: "Aucun résultat.",
|
|
1360
|
-
loading: "Chargement...",
|
|
2735
|
+
...defaultMessages.fr,
|
|
1361
2736
|
filter: "Filtrer les résultats...",
|
|
1362
|
-
filters: "Filtres",
|
|
1363
|
-
filtersClear: "Effacer tous les filtres",
|
|
1364
|
-
filterClear: "Effacer le filtre",
|
|
1365
|
-
filterApply: "Appliquer le filtre",
|
|
1366
|
-
filterValue: "Valeur",
|
|
1367
|
-
filterOperator: "Opérateur",
|
|
1368
|
-
filterContains: "Contient",
|
|
1369
|
-
filterEquals: "Égal à",
|
|
1370
|
-
filterStartsWith: "Commence par",
|
|
1371
|
-
filterEndsWith: "Se termine par",
|
|
1372
|
-
filterMin: "Minimum",
|
|
1373
|
-
filterMax: "Maximum",
|
|
1374
2737
|
filterFrom: "Du (UTC)",
|
|
1375
2738
|
filterTo: "Au (UTC)",
|
|
1376
|
-
filterTrue: "Vrai",
|
|
1377
|
-
filterFalse: "Faux",
|
|
1378
|
-
filterInvalid: "Saisissez un filtre valide. Les bornes doivent être dans l’ordre croissant.",
|
|
1379
2739
|
export: "Exporter",
|
|
1380
2740
|
exportCsv: "CSV",
|
|
1381
2741
|
exportJson: "JSON",
|
|
@@ -1386,20 +2746,13 @@ var messages2 = {
|
|
|
1386
2746
|
galleryView: "Galerie",
|
|
1387
2747
|
columns: "Colonnes",
|
|
1388
2748
|
groupBy: "Grouper par",
|
|
1389
|
-
sortAsc: "Croissant",
|
|
1390
|
-
sortDesc: "Décroissant",
|
|
1391
|
-
sortClear: "Effacer le tri",
|
|
1392
2749
|
sortBy: "Trier par",
|
|
1393
2750
|
hideColumn: "Masquer la colonne",
|
|
1394
2751
|
reorder: "Glisser pour réordonner",
|
|
1395
|
-
removeItem: "Retirer",
|
|
1396
2752
|
moveUp: "Déplacer vers le haut",
|
|
1397
2753
|
moveDown: "Déplacer vers le bas",
|
|
1398
2754
|
resizeColumn: (column) => `Redimensionner la colonne ${column}`,
|
|
1399
|
-
listDetails: "Afficher tous les éléments"
|
|
1400
|
-
selectAllRows: "Sélectionner toutes les lignes de cette page",
|
|
1401
|
-
selectRow: "Sélectionner la ligne",
|
|
1402
|
-
selected: "Sélectionnés"
|
|
2755
|
+
listDetails: "Afficher tous les éléments"
|
|
1403
2756
|
}
|
|
1404
2757
|
};
|
|
1405
2758
|
var dataTableMessages = (locale = "en", translations) => ({
|
|
@@ -1407,32 +2760,6 @@ var dataTableMessages = (locale = "en", translations) => ({
|
|
|
1407
2760
|
...translations?.[locale.split("-")[0] ?? locale],
|
|
1408
2761
|
...translations?.[locale]
|
|
1409
2762
|
});
|
|
1410
|
-
var DEFAULT_MIN_WIDTH = 96;
|
|
1411
|
-
var DEFAULT_WIDTH = 208;
|
|
1412
|
-
var DEFAULT_MAX_WIDTH = 640;
|
|
1413
|
-
var DEFAULT_QUERY = {
|
|
1414
|
-
page: 0,
|
|
1415
|
-
pageSize: DEFAULT_PAGE_SIZE
|
|
1416
|
-
};
|
|
1417
|
-
var DEFAULT_UI_STATE = {
|
|
1418
|
-
columnVisibility: {},
|
|
1419
|
-
columnSizing: {},
|
|
1420
|
-
rowSelection: {},
|
|
1421
|
-
grouping: [],
|
|
1422
|
-
collapsedGroups: {},
|
|
1423
|
-
view: "table"
|
|
1424
|
-
};
|
|
1425
|
-
var persistedUiFromState = (state) => ({
|
|
1426
|
-
columnVisibility: state.columnVisibility,
|
|
1427
|
-
columnSizing: state.columnSizing,
|
|
1428
|
-
grouping: state.grouping,
|
|
1429
|
-
view: state.view
|
|
1430
|
-
});
|
|
1431
|
-
var transientUiFromState = (state) => ({
|
|
1432
|
-
rowSelection: state.rowSelection,
|
|
1433
|
-
collapsedGroups: state.collapsedGroups
|
|
1434
|
-
});
|
|
1435
|
-
var clampWidth = (column, width) => Math.min(column.maxWidth ?? DEFAULT_MAX_WIDTH, Math.max(column.minWidth ?? DEFAULT_MIN_WIDTH, width));
|
|
1436
2763
|
var normalizeDataTableColumns = (columnDefs, columnSizing = {}) => {
|
|
1437
2764
|
const ids = new Set;
|
|
1438
2765
|
const columns = columnDefs.map((colDef) => {
|
|
@@ -1447,7 +2774,7 @@ var normalizeDataTableColumns = (columnDefs, columnSizing = {}) => {
|
|
|
1447
2774
|
return {
|
|
1448
2775
|
id,
|
|
1449
2776
|
colDef,
|
|
1450
|
-
width:
|
|
2777
|
+
width: clampTableWidth(colDef, columnSizing[id])
|
|
1451
2778
|
};
|
|
1452
2779
|
});
|
|
1453
2780
|
for (const column of columns) {
|
|
@@ -1468,7 +2795,7 @@ var getDataTableFieldColumns = (column) => (column.colDef.fields ?? []).map(({ i
|
|
|
1468
2795
|
}));
|
|
1469
2796
|
var getDataTableSortColumns = (columns) => columns.flatMap((column) => column.colDef.sortable === false ? [] : ((column.colDef.fields?.length) ? getDataTableFieldColumns(column) : [column]).filter(({ colDef }) => colDef.sortable !== false));
|
|
1470
2797
|
var getDataTableExportColumns = (visibleColumns) => visibleColumns.flatMap((column) => column.colDef.fields?.length ? getDataTableFieldColumns(column).filter((_field, index) => column.colDef.fields?.[index]?.export !== false) : [column]);
|
|
1471
|
-
var getDataTableWidth = (columns, utilityColumns = 0) => columns.
|
|
2798
|
+
var getDataTableWidth = (columns, utilityColumns = 0) => tableLayoutWidth(columns.map(({ width }) => width), utilityColumns);
|
|
1472
2799
|
var buildDataTableRows = (rowData, columns, getRowId) => {
|
|
1473
2800
|
const ids = new Set;
|
|
1474
2801
|
return rowData.map((data, index) => {
|
|
@@ -1488,58 +2815,20 @@ var buildDataTableRows = (rowData, columns, getRowId) => {
|
|
|
1488
2815
|
};
|
|
1489
2816
|
});
|
|
1490
2817
|
};
|
|
1491
|
-
var
|
|
1492
|
-
var InstantString = Schema2.String.check(Schema2.isPattern(/^\d{4}-\d{2}-\d{2}T(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/), Schema2.makeFilter((value) => Schema2.is(CalendarDate)(value.slice(0, 10)))).annotate({ identifier: "DataTableInstantString" });
|
|
1493
|
-
var DateInput = Schema2.Union([
|
|
1494
|
-
Schema2.Date,
|
|
1495
|
-
Schema2.Int,
|
|
1496
|
-
CalendarDate,
|
|
1497
|
-
InstantString
|
|
1498
|
-
]).annotate({
|
|
1499
|
-
identifier: "DataTableDateInput"
|
|
1500
|
-
});
|
|
1501
|
-
var decodeDateInput = Schema2.decodeUnknownOption(DateInput);
|
|
1502
|
-
var resolveDate = (value, type) => Option2.getOrUndefined(Option2.flatMap(decodeDateInput(value), (input) => {
|
|
1503
|
-
const calendarOnly = Schema2.is(CalendarDate)(input);
|
|
1504
|
-
if (calendarOnly && type === "dateTime")
|
|
1505
|
-
return Option2.none();
|
|
1506
|
-
return Option2.map(DateTime2.make(input), (instant) => ({
|
|
1507
|
-
instant,
|
|
1508
|
-
calendarOnly
|
|
1509
|
-
}));
|
|
1510
|
-
}));
|
|
1511
|
-
var formatDateValue = (date, column, locale = "en") => DateTime2.format(date.instant, {
|
|
1512
|
-
locale: column.typeOptions?.locale ?? locale,
|
|
1513
|
-
timeZone: date.calendarOnly ? "UTC" : column.typeOptions?.timeZone ?? "UTC",
|
|
1514
|
-
dateStyle: column.typeOptions?.dateStyle ?? "medium",
|
|
1515
|
-
timeStyle: column.type === "dateTime" ? column.typeOptions?.timeStyle ?? "short" : undefined,
|
|
1516
|
-
hour12: column.type === "dateTime" ? column.typeOptions?.hour12 : undefined
|
|
1517
|
-
});
|
|
1518
|
-
var dateIsoValue = (date) => date.calendarOnly ? DateTime2.formatIsoDateUtc(date.instant) : DateTime2.formatIso(date.instant);
|
|
1519
|
-
var NumberValue = Schema2.Finite.annotate({
|
|
2818
|
+
var NumberValue = Schema6.Finite.annotate({
|
|
1520
2819
|
identifier: "DataTableNumberValue"
|
|
1521
2820
|
});
|
|
1522
|
-
var BooleanValue =
|
|
2821
|
+
var BooleanValue = Schema6.Boolean.annotate({
|
|
1523
2822
|
identifier: "DataTableBooleanValue"
|
|
1524
2823
|
});
|
|
1525
|
-
var decodeNumberValue =
|
|
1526
|
-
var decodeBooleanValue =
|
|
1527
|
-
var
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
...format
|
|
1534
|
-
} = options;
|
|
1535
|
-
return new Intl.NumberFormat(locale ?? defaultLocale, format).format(value);
|
|
1536
|
-
};
|
|
1537
|
-
var scalarText = Schema2.is(Schema2.Union([
|
|
1538
|
-
Schema2.String,
|
|
1539
|
-
Schema2.Finite,
|
|
1540
|
-
Schema2.Boolean,
|
|
1541
|
-
Schema2.BigInt,
|
|
1542
|
-
Schema2.Symbol
|
|
2824
|
+
var decodeNumberValue = Schema6.decodeUnknownOption(NumberValue);
|
|
2825
|
+
var decodeBooleanValue = Schema6.decodeUnknownOption(BooleanValue);
|
|
2826
|
+
var scalarText = Schema6.is(Schema6.Union([
|
|
2827
|
+
Schema6.String,
|
|
2828
|
+
Schema6.Finite,
|
|
2829
|
+
Schema6.Boolean,
|
|
2830
|
+
Schema6.BigInt,
|
|
2831
|
+
Schema6.Symbol
|
|
1543
2832
|
]));
|
|
1544
2833
|
var dataTableValueText = (value) => value == null ? "" : scalarText(value) ? String(value) : Formatter.format(value);
|
|
1545
2834
|
var booleanLabel = (value, options) => value ? options?.trueLabel : options?.falseLabel;
|
|
@@ -1547,13 +2836,13 @@ var getDataTableExportValue = (row, column, locale = "en") => {
|
|
|
1547
2836
|
const value = row.values.get(column.id);
|
|
1548
2837
|
const colDef = column.colDef;
|
|
1549
2838
|
if (colDef.type === "number") {
|
|
1550
|
-
const number =
|
|
2839
|
+
const number = Option4.getOrUndefined(decodeNumberValue(value));
|
|
1551
2840
|
if (number === undefined)
|
|
1552
2841
|
return null;
|
|
1553
2842
|
return colDef.typeOptions?.exportFormat === "formatted" ? formatNumberValue(number, colDef.typeOptions, locale) : number;
|
|
1554
2843
|
}
|
|
1555
2844
|
if (colDef.type === "boolean") {
|
|
1556
|
-
const boolean =
|
|
2845
|
+
const boolean = Option4.getOrUndefined(decodeBooleanValue(value));
|
|
1557
2846
|
if (boolean === undefined)
|
|
1558
2847
|
return null;
|
|
1559
2848
|
return colDef.typeOptions?.exportFormat === "formatted" ? booleanLabel(boolean, colDef.typeOptions) ?? String(boolean) : boolean;
|
|
@@ -1578,10 +2867,10 @@ var filterDataTableRows = (rows, columns, globalFilter, locale = "en") => {
|
|
|
1578
2867
|
const date = resolveDate(value, colDef.type);
|
|
1579
2868
|
text = date ? `${formatDateValue(date, colDef, locale)} ${dateIsoValue(date)}` : "";
|
|
1580
2869
|
} else if (colDef.type === "number") {
|
|
1581
|
-
const number =
|
|
2870
|
+
const number = Option4.getOrUndefined(decodeNumberValue(value));
|
|
1582
2871
|
text = number === undefined ? "" : `${formatNumberValue(number, colDef.typeOptions, locale)} ${number}`;
|
|
1583
2872
|
} else if (colDef.type === "boolean") {
|
|
1584
|
-
const boolean =
|
|
2873
|
+
const boolean = Option4.getOrUndefined(decodeBooleanValue(value));
|
|
1585
2874
|
text = boolean === undefined ? "" : `${booleanLabel(boolean, colDef.typeOptions) ?? ""} ${boolean}`;
|
|
1586
2875
|
}
|
|
1587
2876
|
return text.toLocaleLowerCase().includes(query);
|
|
@@ -1590,7 +2879,7 @@ var filterDataTableRows = (rows, columns, globalFilter, locale = "en") => {
|
|
|
1590
2879
|
var getDataTableFilterColumns = (columns) => columns.flatMap((column) => column.colDef.filterable === false ? [] : ((column.colDef.fields?.length) ? getDataTableFieldColumns(column) : [column]).filter(({ colDef }) => colDef.filterable !== false));
|
|
1591
2880
|
var getDataTableFilterKind = ({
|
|
1592
2881
|
colDef
|
|
1593
|
-
}) => colDef
|
|
2882
|
+
}) => tableFilterKind(colDef, !!colDef.filterOptions);
|
|
1594
2883
|
var getDataTableFilterOptions = (rows, column) => {
|
|
1595
2884
|
const { colDef } = column;
|
|
1596
2885
|
if (colDef.filterOptions)
|
|
@@ -1618,39 +2907,8 @@ var filterDataTableColumnRows = (rows, columns, filters) => {
|
|
|
1618
2907
|
rowIndex: row.index,
|
|
1619
2908
|
colDef: column.colDef
|
|
1620
2909
|
}) : row.values.get(column.id);
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
const text = dataTableValueText(value).toLocaleLowerCase();
|
|
1624
|
-
const query = filter.value.toLocaleLowerCase();
|
|
1625
|
-
switch (filter.operator) {
|
|
1626
|
-
case "contains":
|
|
1627
|
-
return text.includes(query);
|
|
1628
|
-
case "equals":
|
|
1629
|
-
return text === query;
|
|
1630
|
-
case "startsWith":
|
|
1631
|
-
return text.startsWith(query);
|
|
1632
|
-
case "endsWith":
|
|
1633
|
-
return text.endsWith(query);
|
|
1634
|
-
}
|
|
1635
|
-
}
|
|
1636
|
-
case "number": {
|
|
1637
|
-
const number = Option2.getOrUndefined(decodeNumberValue(value));
|
|
1638
|
-
return number !== undefined && (filter.min === undefined || number >= filter.min) && (filter.max === undefined || number <= filter.max);
|
|
1639
|
-
}
|
|
1640
|
-
case "date": {
|
|
1641
|
-
const date = resolveDate(value, column.colDef.type === "dateTime" ? "dateTime" : "date");
|
|
1642
|
-
if (!date)
|
|
1643
|
-
return false;
|
|
1644
|
-
const day = DateTime2.formatIsoDateUtc(date.instant);
|
|
1645
|
-
return (filter.from === undefined || day >= filter.from) && (filter.to === undefined || day <= filter.to);
|
|
1646
|
-
}
|
|
1647
|
-
case "boolean":
|
|
1648
|
-
return Option2.getOrUndefined(decodeBooleanValue(value)) === filter.value;
|
|
1649
|
-
case "values": {
|
|
1650
|
-
const values = column.colDef.type === "list" ? column.colDef.typeOptions.getItems(row.data).map((item) => item.value ?? item.label) : [dataTableValueText(value)];
|
|
1651
|
-
return filter.values.some((selected) => values.includes(selected));
|
|
1652
|
-
}
|
|
1653
|
-
}
|
|
2910
|
+
const { colDef } = column;
|
|
2911
|
+
return matchesTableFilter(filter, value, colDef.type, () => dataTableValueText(value), () => colDef.type === "list" ? colDef.typeOptions.getItems(row.data).map((item) => item.value ?? item.label) : [dataTableValueText(value)]);
|
|
1654
2912
|
}));
|
|
1655
2913
|
};
|
|
1656
2914
|
var sortDataTableRows = (rows, columns, sorting) => {
|
|
@@ -1666,35 +2924,13 @@ var sortDataTableRows = (rows, columns, sorting) => {
|
|
|
1666
2924
|
const leftValue = left.row.values.get(sort.id);
|
|
1667
2925
|
const rightValue = right.row.values.get(sort.id);
|
|
1668
2926
|
const colDef = column.colDef;
|
|
1669
|
-
if (!colDef.comparator && (colDef.type === "number" || colDef.type === "boolean")) {
|
|
1670
|
-
const
|
|
1671
|
-
const rightScalar = colDef.type === "number" ? Option2.getOrUndefined(decodeNumberValue(rightValue)) : Option2.getOrUndefined(Option2.map(decodeBooleanValue(rightValue), Number));
|
|
1672
|
-
if (leftScalar === undefined || rightScalar === undefined) {
|
|
1673
|
-
if (leftScalar === undefined && rightScalar === undefined)
|
|
1674
|
-
continue;
|
|
1675
|
-
const nullOrder = colDef.typeOptions?.nulls === "first" ? -1 : 1;
|
|
1676
|
-
return leftScalar === undefined ? nullOrder : -nullOrder;
|
|
1677
|
-
}
|
|
1678
|
-
const comparison = leftScalar - rightScalar;
|
|
1679
|
-
if (comparison !== 0)
|
|
1680
|
-
return sort.direction === "desc" ? -comparison : comparison;
|
|
1681
|
-
continue;
|
|
1682
|
-
}
|
|
1683
|
-
if (!colDef.comparator && (colDef.type === "date" || colDef.type === "dateTime")) {
|
|
1684
|
-
const leftDate = resolveDate(leftValue, colDef.type);
|
|
1685
|
-
const rightDate = resolveDate(rightValue, colDef.type);
|
|
1686
|
-
if (!leftDate || !rightDate) {
|
|
1687
|
-
if (!leftDate && !rightDate)
|
|
1688
|
-
continue;
|
|
1689
|
-
const nullOrder = colDef.typeOptions?.nulls === "first" ? -1 : 1;
|
|
1690
|
-
return !leftDate ? nullOrder : -nullOrder;
|
|
1691
|
-
}
|
|
1692
|
-
const comparison = DateTime2.toEpochMillis(leftDate.instant) - DateTime2.toEpochMillis(rightDate.instant);
|
|
2927
|
+
if (!colDef.comparator && (colDef.type === "number" || colDef.type === "boolean" || colDef.type === "date" || colDef.type === "dateTime")) {
|
|
2928
|
+
const comparison = compareTableSortValues(tableSortScalar(colDef.type, leftValue), tableSortScalar(colDef.type, rightValue), sort.direction, colDef.typeOptions?.nulls);
|
|
1693
2929
|
if (comparison !== 0)
|
|
1694
|
-
return
|
|
2930
|
+
return comparison;
|
|
1695
2931
|
continue;
|
|
1696
2932
|
}
|
|
1697
|
-
const comparison = column.colDef.comparator ? column.colDef.comparator(leftValue, rightValue, left.row.data, right.row.data) : Object.is(leftValue, rightValue) ? 0 : leftValue === null || leftValue === undefined ? 1 : rightValue === null || rightValue === undefined ? -1 :
|
|
2933
|
+
const comparison = column.colDef.comparator ? column.colDef.comparator(leftValue, rightValue, left.row.data, right.row.data) : Object.is(leftValue, rightValue) ? 0 : leftValue === null || leftValue === undefined ? 1 : rightValue === null || rightValue === undefined ? -1 : Schema6.is(Schema6.Finite)(leftValue) && Schema6.is(Schema6.Finite)(rightValue) ? leftValue - rightValue : compareTableText(dataTableValueText(leftValue), dataTableValueText(rightValue));
|
|
1698
2934
|
if (comparison !== 0)
|
|
1699
2935
|
return sort.direction === "desc" ? -comparison : comparison;
|
|
1700
2936
|
}
|
|
@@ -1702,13 +2938,9 @@ var sortDataTableRows = (rows, columns, sorting) => {
|
|
|
1702
2938
|
}).map(({ row }) => row);
|
|
1703
2939
|
};
|
|
1704
2940
|
var paginateDataTableRows = (rows, pagination) => {
|
|
1705
|
-
const
|
|
1706
|
-
|
|
1707
|
-
const pageIndex = Math.min(lastPageIndex, Math.max(0, pagination.page));
|
|
1708
|
-
const start = pageIndex * pageSize;
|
|
1709
|
-
return rows.slice(start, start + pageSize);
|
|
2941
|
+
const { start, end } = resolveTablePage(rows.length, pagination);
|
|
2942
|
+
return rows.slice(start, end);
|
|
1710
2943
|
};
|
|
1711
|
-
var sameDataTableState = (left, right) => left.page === right.page && left.pageSize === right.pageSize && left.globalFilter === right.globalFilter && left.filters === right.filters && left.sort === right.sort && left.columnVisibility === right.columnVisibility && left.columnSizing === right.columnSizing && left.rowSelection === right.rowSelection && left.grouping === right.grouping && left.collapsedGroups === right.collapsedGroups && left.view === right.view;
|
|
1712
2944
|
var reorderDataTableRows = (rows, sourceRowId, targetRowId) => {
|
|
1713
2945
|
const sourceIndex = rows.findIndex((row) => row.id === sourceRowId);
|
|
1714
2946
|
const targetIndex = rows.findIndex((row) => row.id === targetRowId);
|
|
@@ -1754,7 +2986,7 @@ var clearDragPresentation = (root) => {
|
|
|
1754
2986
|
element.removeAttribute("data-drop-position");
|
|
1755
2987
|
});
|
|
1756
2988
|
};
|
|
1757
|
-
var resolveConfig = (props
|
|
2989
|
+
var resolveConfig = (props) => {
|
|
1758
2990
|
const features = props.features ?? {};
|
|
1759
2991
|
const selection = features.selection;
|
|
1760
2992
|
const getRowId = selection && selection.getRowId || props.getRowId || undefined;
|
|
@@ -1763,8 +2995,6 @@ var resolveConfig = (props, onUiStateChange) => {
|
|
|
1763
2995
|
}
|
|
1764
2996
|
return {
|
|
1765
2997
|
getRowId,
|
|
1766
|
-
onStateChange: props.onStateChange,
|
|
1767
|
-
onUiStateChange,
|
|
1768
2998
|
status: props.status ?? {},
|
|
1769
2999
|
features,
|
|
1770
3000
|
onRowClicked: props.onRowClicked,
|
|
@@ -1779,83 +3009,39 @@ var queryFromState = (state) => ({
|
|
|
1779
3009
|
filters: state.filters,
|
|
1780
3010
|
sort: state.sort
|
|
1781
3011
|
});
|
|
1782
|
-
var uiFromState = (state) => ({
|
|
1783
|
-
columnVisibility: state.columnVisibility,
|
|
1784
|
-
columnSizing: state.columnSizing,
|
|
1785
|
-
rowSelection: state.rowSelection,
|
|
1786
|
-
grouping: state.grouping,
|
|
1787
|
-
collapsedGroups: state.collapsedGroups,
|
|
1788
|
-
view: state.view
|
|
1789
|
-
});
|
|
1790
|
-
var sameUiState = (left, right) => left.columnVisibility === right.columnVisibility && left.columnSizing === right.columnSizing && left.rowSelection === right.rowSelection && left.grouping === right.grouping && left.collapsedGroups === right.collapsedGroups && left.view === right.view;
|
|
1791
|
-
var sameQueryState = (left, right) => left.page === right.page && left.pageSize === right.pageSize && left.globalFilter === right.globalFilter && left.filters === right.filters && left.sort === right.sort;
|
|
1792
|
-
var initialPublicState = (props, uiState) => ({
|
|
1793
|
-
...queryFromState(props.state ?? { ...DEFAULT_QUERY, ...props.initialState }),
|
|
1794
|
-
...uiState
|
|
1795
|
-
});
|
|
1796
3012
|
var buildDataTableModel = (store) => {
|
|
1797
3013
|
const columns = normalizeDataTableColumns(store.columnDefs, store.state.columnSizing);
|
|
1798
3014
|
const selection = store.config.features.selection;
|
|
1799
3015
|
const rowId = selection && selection.getRowId || store.config.getRowId || undefined;
|
|
1800
3016
|
const rows = buildDataTableRows(store.rowData, columns, rowId);
|
|
1801
|
-
const
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
3017
|
+
const page = projectDataTableRows(rows, store.state, {
|
|
3018
|
+
pagination: store.config.features.pagination,
|
|
3019
|
+
grouped: getActiveGrouping(store).length > 0,
|
|
3020
|
+
search: (rows, value) => filterDataTableRows(rows, columns, value, store.config.locale),
|
|
3021
|
+
filter: (rows, filters) => filterDataTableColumnRows(rows, columns, filters),
|
|
3022
|
+
sort: (rows, sorting) => sortDataTableRows(rows, columns, sorting)
|
|
3023
|
+
});
|
|
1807
3024
|
return {
|
|
1808
3025
|
columns,
|
|
1809
3026
|
visibleColumns: columns.filter(({ id }) => store.state.columnVisibility[id] !== false),
|
|
1810
3027
|
rows,
|
|
1811
|
-
filteredRows,
|
|
1812
|
-
sortedRows,
|
|
1813
|
-
pageRows,
|
|
1814
|
-
|
|
1815
|
-
|
|
3028
|
+
filteredRows: page.filtered,
|
|
3029
|
+
sortedRows: page.ordered,
|
|
3030
|
+
pageRows: page.rows,
|
|
3031
|
+
page: page.page,
|
|
3032
|
+
pageCount: page.pageCount,
|
|
3033
|
+
paginationVisible: page.paginationVisible,
|
|
3034
|
+
totalRows: page.totalRows
|
|
1816
3035
|
};
|
|
1817
3036
|
};
|
|
1818
|
-
var useTableAtom = (tableAtom) => useAtom(tableAtom);
|
|
1819
|
-
var changeState = (setStore, update) => {
|
|
1820
|
-
setStore((store) => {
|
|
1821
|
-
const proposed = update(store.state);
|
|
1822
|
-
const query = queryFromState(proposed);
|
|
1823
|
-
if (!sameQueryState(query, store.state)) {
|
|
1824
|
-
store.config.onStateChange?.(query);
|
|
1825
|
-
}
|
|
1826
|
-
const uiState = uiFromState(proposed);
|
|
1827
|
-
if (!sameUiState(uiState, store.state)) {
|
|
1828
|
-
store.config.onUiStateChange(uiState);
|
|
1829
|
-
}
|
|
1830
|
-
const state = store.controlledState ? { ...proposed, ...queryFromState(store.controlledState) } : proposed;
|
|
1831
|
-
if (sameDataTableState(state, store.state))
|
|
1832
|
-
return store;
|
|
1833
|
-
const next = { ...store, state };
|
|
1834
|
-
return { ...next, model: buildDataTableModel(next) };
|
|
1835
|
-
});
|
|
1836
|
-
};
|
|
1837
3037
|
var deriveModel = (store) => store.model;
|
|
1838
3038
|
var groupDataTableRows = (rows, fields, depth = 0, parentKey = "") => {
|
|
1839
3039
|
const field = fields[0];
|
|
1840
3040
|
if (!field)
|
|
1841
3041
|
return [];
|
|
1842
|
-
const groups =
|
|
1843
|
-
field.getGroupIds?.().forEach((id) => groups.set(id, []));
|
|
1844
|
-
rows.forEach((row) => {
|
|
1845
|
-
const ids = field.getRowGroupIds?.(row.data) ?? [
|
|
1846
|
-
field.getGroupId(row.data)
|
|
1847
|
-
];
|
|
1848
|
-
ids.forEach((id) => {
|
|
1849
|
-
const group = groups.get(id);
|
|
1850
|
-
if (group)
|
|
1851
|
-
group.push(row);
|
|
1852
|
-
else
|
|
1853
|
-
groups.set(id, [row]);
|
|
1854
|
-
});
|
|
1855
|
-
});
|
|
3042
|
+
const groups = partitionTableGroups(rows, field.getGroupIds?.() ?? [], (row) => field.getRowGroupIds?.(row.data) ?? [field.getGroupId(row.data)]);
|
|
1856
3043
|
return Array.from(groups, ([groupId, groupRows]) => {
|
|
1857
|
-
const
|
|
1858
|
-
const key = `${parentKey}${parentKey ? "/" : ""}${segment}`;
|
|
3044
|
+
const key = tableGroupKey(parentKey, field.id, groupId);
|
|
1859
3045
|
return {
|
|
1860
3046
|
key,
|
|
1861
3047
|
groupId,
|
|
@@ -1869,12 +3055,7 @@ var groupDataTableRows = (rows, fields, depth = 0, parentKey = "") => {
|
|
|
1869
3055
|
var getDataTableSelectableRows = (model, grouped, isRowSelectable) => (grouped ? model.sortedRows : model.pageRows).filter((row) => isRowSelectable?.(row.data) ?? true);
|
|
1870
3056
|
var getActiveGrouping = (store) => {
|
|
1871
3057
|
const grouping = store.config.features.grouping;
|
|
1872
|
-
|
|
1873
|
-
return [];
|
|
1874
|
-
return store.state.grouping.flatMap((id) => {
|
|
1875
|
-
const field = grouping.fields.find((candidate) => candidate.id === id);
|
|
1876
|
-
return field ? [field] : [];
|
|
1877
|
-
});
|
|
3058
|
+
return activeTableGroups(store.state.grouping, grouping && grouping.fields || []);
|
|
1878
3059
|
};
|
|
1879
3060
|
var canReorderRows = (store) => {
|
|
1880
3061
|
const pagination = store.config.features.pagination;
|
|
@@ -1911,7 +3092,7 @@ var renderCell = (row, column, locale = "en", labels = dataTableMessages(locale)
|
|
|
1911
3092
|
if (colDef.type === "number") {
|
|
1912
3093
|
if (colDef.valueFormatter)
|
|
1913
3094
|
return colDef.valueFormatter(params);
|
|
1914
|
-
const number =
|
|
3095
|
+
const number = Option4.getOrUndefined(decodeNumberValue(value));
|
|
1915
3096
|
return /* @__PURE__ */ jsx15("span", {
|
|
1916
3097
|
className: "block text-left tabular-nums",
|
|
1917
3098
|
children: number === undefined ? colDef.typeOptions?.emptyLabel ?? "—" : formatNumberValue(number, colDef.typeOptions, locale)
|
|
@@ -1920,7 +3101,7 @@ var renderCell = (row, column, locale = "en", labels = dataTableMessages(locale)
|
|
|
1920
3101
|
if (colDef.type === "boolean") {
|
|
1921
3102
|
if (colDef.valueFormatter)
|
|
1922
3103
|
return colDef.valueFormatter(params);
|
|
1923
|
-
const boolean =
|
|
3104
|
+
const boolean = Option4.getOrUndefined(decodeBooleanValue(value));
|
|
1924
3105
|
if (boolean === undefined)
|
|
1925
3106
|
return colDef.typeOptions?.emptyLabel ?? "—";
|
|
1926
3107
|
const options = colDef.typeOptions;
|
|
@@ -1983,37 +3164,25 @@ var renderCell = (row, column, locale = "en", labels = dataTableMessages(locale)
|
|
|
1983
3164
|
return column.colDef.valueFormatter?.(params) ?? (value === null || value === undefined ? null : dataTableValueText(value));
|
|
1984
3165
|
};
|
|
1985
3166
|
var nodeText = (node) => {
|
|
1986
|
-
if (
|
|
3167
|
+
if (Schema6.is(Schema6.String)(node) || Schema6.is(Schema6.Finite)(node))
|
|
1987
3168
|
return String(node);
|
|
1988
3169
|
if (!isValidElement(node))
|
|
1989
3170
|
return "";
|
|
1990
|
-
if (
|
|
3171
|
+
if (Schema6.is(Schema6.String)(node.props.title))
|
|
1991
3172
|
return node.props.title;
|
|
1992
3173
|
return nodeText(node.props.children);
|
|
1993
3174
|
};
|
|
1994
3175
|
var columnLabel = (column) => nodeText(column.colDef.headerName) || column.id;
|
|
1995
|
-
var withExtension = (fileName, extension) => fileName.includes(".") ? fileName.replace(/\.[^/.]+$/, `.${extension}`) : `${fileName}.${extension}`;
|
|
1996
3176
|
var downloadCsv = (headers, data, fileName = "data.csv") => {
|
|
1997
|
-
|
|
1998
|
-
` })), Stream.runCollect, Effect2.map((parts) => parts.join("").slice(0, -1))));
|
|
1999
|
-
downloadBlob(content, "text/csv;charset=utf-8", withExtension(fileName, "csv"));
|
|
2000
|
-
};
|
|
2001
|
-
var downloadJson = (data, fileName = "data.json") => downloadBlob(JSON.stringify(data, null, 2), "application/json;charset=utf-8", withExtension(fileName, "json"));
|
|
2002
|
-
var downloadBlob = (content, type, fileName) => {
|
|
2003
|
-
const url = window.URL.createObjectURL(new Blob([content], { type }));
|
|
2004
|
-
const link = document.createElement("a");
|
|
2005
|
-
link.href = url;
|
|
2006
|
-
link.download = fileName;
|
|
2007
|
-
document.body.appendChild(link);
|
|
2008
|
-
link.click();
|
|
2009
|
-
link.remove();
|
|
2010
|
-
requestAnimationFrame(() => window.URL.revokeObjectURL(url));
|
|
3177
|
+
downloadTableBlob(encodeTableCsv(headers, data), "text/csv;charset=utf-8", tableExportFilename(fileName, "csv"));
|
|
2011
3178
|
};
|
|
3179
|
+
var downloadJson = (data, fileName = "data.json") => downloadTableBlob(JSON.stringify(data, null, 2), "application/json;charset=utf-8", tableExportFilename(fileName, "json"));
|
|
2012
3180
|
var DataTableRowActions = ({
|
|
2013
3181
|
actions,
|
|
2014
3182
|
row,
|
|
2015
3183
|
title
|
|
2016
3184
|
}) => {
|
|
3185
|
+
const tableClasses = useContext(DataTableSlotClassesContext);
|
|
2017
3186
|
const visible = actions.filter((action) => !action.visible || action.visible(row));
|
|
2018
3187
|
if (!visible.length)
|
|
2019
3188
|
return null;
|
|
@@ -2022,7 +3191,7 @@ var DataTableRowActions = ({
|
|
|
2022
3191
|
/* @__PURE__ */ jsx15(DropdownMenuTrigger2, {
|
|
2023
3192
|
onClick: (event) => event.stopPropagation(),
|
|
2024
3193
|
render: /* @__PURE__ */ jsxs9(Button, {
|
|
2025
|
-
className: "
|
|
3194
|
+
className: cn(tableClasses.actionTrigger, "[&_svg:not([class*='size-'])]:size-4"),
|
|
2026
3195
|
size: "icon",
|
|
2027
3196
|
variant: "ghost",
|
|
2028
3197
|
children: [
|
|
@@ -2061,10 +3230,10 @@ var DataTableRowActions = ({
|
|
|
2061
3230
|
});
|
|
2062
3231
|
};
|
|
2063
3232
|
var DataTableRowActionMenu = ({
|
|
2064
|
-
|
|
3233
|
+
table,
|
|
2065
3234
|
row
|
|
2066
3235
|
}) => {
|
|
2067
|
-
const [store] =
|
|
3236
|
+
const [store] = table;
|
|
2068
3237
|
const rowId = row.id;
|
|
2069
3238
|
const rowActions = store.config.features.rowActions || undefined;
|
|
2070
3239
|
const reordering = store.config.features.reordering;
|
|
@@ -2098,12 +3267,12 @@ var DataTableRowActionMenu = ({
|
|
|
2098
3267
|
});
|
|
2099
3268
|
};
|
|
2100
3269
|
var DataTableToolbar = ({
|
|
2101
|
-
|
|
3270
|
+
table
|
|
2102
3271
|
}) => {
|
|
2103
|
-
const
|
|
3272
|
+
const tableClasses = useContext(DataTableSlotClassesContext);
|
|
3273
|
+
const [store, send] = table;
|
|
2104
3274
|
const exportPending = useRef(false);
|
|
2105
|
-
const
|
|
2106
|
-
const [exportFailed, setExportFailed] = useState(false);
|
|
3275
|
+
const { exporting, exportFailed } = store.ui;
|
|
2107
3276
|
const { features, labels } = store.config;
|
|
2108
3277
|
const model = deriveModel(store);
|
|
2109
3278
|
const selectedRows = getSelectedRows(store, model);
|
|
@@ -2113,7 +3282,6 @@ var DataTableToolbar = ({
|
|
|
2113
3282
|
const hasToolbar = !!toolbar || features.search !== false || features.filtering !== false || features.sorting !== false || features.columnVisibility !== false || !!features.export || !!features.gallery || !!grouping || !!features.refresh || !!bulkActions && selectedRows.length > 0;
|
|
2114
3283
|
if (!hasToolbar)
|
|
2115
3284
|
return null;
|
|
2116
|
-
const update = (next) => changeState(setStore, next);
|
|
2117
3285
|
const visibleBulkActions = bulkActions ? bulkActions.items.filter((action) => !action.visible || action.visible(selectedRows)) : [];
|
|
2118
3286
|
const exportRows = features.export && features.export.scope === "currentPage" ? model.pageRows : model.sortedRows;
|
|
2119
3287
|
const exportColumns = getDataTableExportColumns(model.visibleColumns);
|
|
@@ -2125,46 +3293,38 @@ var DataTableToolbar = ({
|
|
|
2125
3293
|
if (exportPending.current || action.disabled)
|
|
2126
3294
|
return;
|
|
2127
3295
|
exportPending.current = true;
|
|
2128
|
-
|
|
2129
|
-
|
|
3296
|
+
send(DataTableMessage.ExportStarted());
|
|
3297
|
+
let failed = false;
|
|
2130
3298
|
try {
|
|
2131
3299
|
await action.onExport();
|
|
2132
3300
|
} catch (error) {
|
|
2133
|
-
|
|
3301
|
+
failed = true;
|
|
2134
3302
|
if (exportFeature)
|
|
2135
3303
|
exportFeature.onError?.(error, action);
|
|
2136
3304
|
} finally {
|
|
2137
3305
|
exportPending.current = false;
|
|
2138
|
-
|
|
3306
|
+
send(DataTableMessage.ExportFinished({ failed }));
|
|
2139
3307
|
}
|
|
2140
3308
|
};
|
|
2141
3309
|
return /* @__PURE__ */ jsxs9("div", {
|
|
2142
|
-
className: cn("
|
|
3310
|
+
className: cn(tableClasses.toolbar, "pb-4"),
|
|
2143
3311
|
children: [
|
|
2144
3312
|
features.search !== false ? /* @__PURE__ */ jsxs9("div", {
|
|
2145
|
-
className:
|
|
3313
|
+
className: tableClasses.toolbarSearch,
|
|
2146
3314
|
children: [
|
|
2147
3315
|
/* @__PURE__ */ jsx15(Search, {
|
|
2148
3316
|
className: "text-muted-foreground pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2"
|
|
2149
3317
|
}),
|
|
2150
3318
|
/* @__PURE__ */ jsx15(Input2, {
|
|
2151
3319
|
className: "px-9",
|
|
2152
|
-
onChange: (event) =>
|
|
2153
|
-
...state,
|
|
2154
|
-
globalFilter: event.target.value,
|
|
2155
|
-
page: 0
|
|
2156
|
-
})),
|
|
3320
|
+
onChange: (event) => send(DataTableMessage.SearchChanged({ value: event.target.value })),
|
|
2157
3321
|
placeholder: labels.filter,
|
|
2158
3322
|
value: store.state.globalFilter ?? ""
|
|
2159
3323
|
}),
|
|
2160
3324
|
store.state.globalFilter ? /* @__PURE__ */ jsx15(Button, {
|
|
2161
3325
|
"aria-label": labels.filter,
|
|
2162
3326
|
className: "absolute top-1/2 right-1 size-7 -translate-y-1/2 active:not-aria-[haspopup]:-translate-y-1/2",
|
|
2163
|
-
onClick: () =>
|
|
2164
|
-
...state,
|
|
2165
|
-
globalFilter: undefined,
|
|
2166
|
-
page: 0
|
|
2167
|
-
})),
|
|
3327
|
+
onClick: () => send(DataTableMessage.SearchChanged({ value: "" })),
|
|
2168
3328
|
size: "icon",
|
|
2169
3329
|
variant: "ghost",
|
|
2170
3330
|
children: /* @__PURE__ */ jsx15(X, {})
|
|
@@ -2172,19 +3332,19 @@ var DataTableToolbar = ({
|
|
|
2172
3332
|
]
|
|
2173
3333
|
}) : null,
|
|
2174
3334
|
/* @__PURE__ */ jsx15("div", {
|
|
2175
|
-
className:
|
|
3335
|
+
className: tableClasses.toolbarMenus,
|
|
2176
3336
|
children: /* @__PURE__ */ jsxs9(Menubar2, {
|
|
2177
3337
|
modal: false,
|
|
2178
|
-
className: "
|
|
3338
|
+
className: cn(tableClasses.menubar, "[&_[data-slot=menubar-trigger]]:gap-2 [&_[data-slot=menubar-trigger]_svg]:size-4"),
|
|
2179
3339
|
children: [
|
|
2180
3340
|
visibleBulkActions.length ? /* @__PURE__ */ jsxs9(MenubarMenu, {
|
|
2181
3341
|
children: [
|
|
2182
3342
|
/* @__PURE__ */ jsxs9(MenubarTrigger2, {
|
|
2183
|
-
className: "
|
|
3343
|
+
className: cn(tableClasses.selectedTrigger, "aria-expanded:bg-primary/90"),
|
|
2184
3344
|
children: [
|
|
2185
3345
|
labels.selected,
|
|
2186
|
-
/* @__PURE__ */ jsx15(
|
|
2187
|
-
|
|
3346
|
+
/* @__PURE__ */ jsx15("span", {
|
|
3347
|
+
className: tableClasses.count,
|
|
2188
3348
|
children: selectedRows.length
|
|
2189
3349
|
}),
|
|
2190
3350
|
/* @__PURE__ */ jsx15(ChevronDown, {})
|
|
@@ -2214,7 +3374,7 @@ var DataTableToolbar = ({
|
|
|
2214
3374
|
}) : null,
|
|
2215
3375
|
toolbar && toolbar.items,
|
|
2216
3376
|
features.filtering !== false ? /* @__PURE__ */ jsx15(FilterMenu, {
|
|
2217
|
-
|
|
3377
|
+
table
|
|
2218
3378
|
}) : null,
|
|
2219
3379
|
grouping ? /* @__PURE__ */ jsxs9(MenubarMenu, {
|
|
2220
3380
|
children: [
|
|
@@ -2238,10 +3398,7 @@ var DataTableToolbar = ({
|
|
|
2238
3398
|
/* @__PURE__ */ jsx15(MenubarSeparator2, {}),
|
|
2239
3399
|
grouping.fields.map((field) => /* @__PURE__ */ jsx15(MenubarCheckboxItem2, {
|
|
2240
3400
|
checked: store.state.grouping.includes(field.id),
|
|
2241
|
-
onCheckedChange: (
|
|
2242
|
-
...state,
|
|
2243
|
-
grouping: checked ? [...state.grouping, field.id] : state.grouping.filter((id) => id !== field.id)
|
|
2244
|
-
})),
|
|
3401
|
+
onCheckedChange: () => send(DataTableMessage.GroupingToggled({ fieldId: field.id })),
|
|
2245
3402
|
children: field.label
|
|
2246
3403
|
}, field.id))
|
|
2247
3404
|
]
|
|
@@ -2250,13 +3407,13 @@ var DataTableToolbar = ({
|
|
|
2250
3407
|
]
|
|
2251
3408
|
}) : null,
|
|
2252
3409
|
features.sorting !== false ? /* @__PURE__ */ jsx15(SortMenu, {
|
|
2253
|
-
|
|
3410
|
+
table
|
|
2254
3411
|
}) : null,
|
|
2255
3412
|
features.gallery ? /* @__PURE__ */ jsx15(ViewMenu, {
|
|
2256
|
-
|
|
3413
|
+
table
|
|
2257
3414
|
}) : null,
|
|
2258
3415
|
features.columnVisibility !== false ? /* @__PURE__ */ jsx15(ColumnMenu, {
|
|
2259
|
-
|
|
3416
|
+
table
|
|
2260
3417
|
}) : null,
|
|
2261
3418
|
features.refresh ? /* @__PURE__ */ jsx15(MenubarMenu, {
|
|
2262
3419
|
children: /* @__PURE__ */ jsxs9(MenubarTrigger2, {
|
|
@@ -2337,18 +3494,12 @@ var DataTableToolbar = ({
|
|
|
2337
3494
|
}),
|
|
2338
3495
|
exportFeature && exportFailed ? /* @__PURE__ */ jsx15("p", {
|
|
2339
3496
|
role: "alert",
|
|
2340
|
-
className: "text-destructive
|
|
3497
|
+
className: "text-destructive basis-full text-sm",
|
|
2341
3498
|
children: labels.exportFailed ?? dataTableMessages(store.config.locale).exportFailed
|
|
2342
3499
|
}) : null
|
|
2343
3500
|
]
|
|
2344
3501
|
});
|
|
2345
3502
|
};
|
|
2346
|
-
var withColumnFilter = (state, id, filter) => {
|
|
2347
|
-
const filters = (state.filters ?? []).filter((current) => current.id !== id);
|
|
2348
|
-
if (filter)
|
|
2349
|
-
filters.push(filter);
|
|
2350
|
-
return { ...state, page: 0, filters: filters.length ? filters : undefined };
|
|
2351
|
-
};
|
|
2352
3503
|
var FilterEditor = ({
|
|
2353
3504
|
column,
|
|
2354
3505
|
rows,
|
|
@@ -2358,9 +3509,8 @@ var FilterEditor = ({
|
|
|
2358
3509
|
}) => {
|
|
2359
3510
|
const inputId = useId2();
|
|
2360
3511
|
const kind = getDataTableFilterKind(column);
|
|
2361
|
-
const [
|
|
2362
|
-
const
|
|
2363
|
-
const [operator, setOperator] = useState(current?.kind === "text" ? current.operator : "contains");
|
|
3512
|
+
const [draft, setDraft] = useState(() => tableFilterDraft(column.id, current));
|
|
3513
|
+
const { primary, secondary, operator } = draft;
|
|
2364
3514
|
const operatorOptions = [
|
|
2365
3515
|
{ value: "contains", label: labels.filterContains },
|
|
2366
3516
|
{ value: "equals", label: labels.filterEquals },
|
|
@@ -2370,8 +3520,8 @@ var FilterEditor = ({
|
|
|
2370
3520
|
const [invalid, setInvalid] = useState(false);
|
|
2371
3521
|
const [optionSearch, setOptionSearch] = useState("");
|
|
2372
3522
|
const apply = (candidate) => {
|
|
2373
|
-
const decoded =
|
|
2374
|
-
if (
|
|
3523
|
+
const decoded = parseTableFilterDraft(kind, candidate);
|
|
3524
|
+
if (Option4.isNone(decoded)) {
|
|
2375
3525
|
setInvalid(true);
|
|
2376
3526
|
return;
|
|
2377
3527
|
}
|
|
@@ -2383,7 +3533,7 @@ var FilterEditor = ({
|
|
|
2383
3533
|
children: [
|
|
2384
3534
|
/* @__PURE__ */ jsxs9(MenubarRadioGroup, {
|
|
2385
3535
|
value: current?.kind === "boolean" ? String(current.value) : "",
|
|
2386
|
-
onValueChange: (value) => apply({
|
|
3536
|
+
onValueChange: (value) => apply({ ...draft, primary: value }),
|
|
2387
3537
|
children: [
|
|
2388
3538
|
/* @__PURE__ */ jsx15(MenubarRadioItem2, {
|
|
2389
3539
|
value: "true",
|
|
@@ -2429,9 +3579,9 @@ var FilterEditor = ({
|
|
|
2429
3579
|
checked: selected.includes(option.value),
|
|
2430
3580
|
closeOnClick: false,
|
|
2431
3581
|
onCheckedChange: (checked) => {
|
|
2432
|
-
const values =
|
|
3582
|
+
const values = updateSelectedRows(selected, [option.value], checked);
|
|
2433
3583
|
if (values.length)
|
|
2434
|
-
apply({
|
|
3584
|
+
apply({ ...draft, values });
|
|
2435
3585
|
else
|
|
2436
3586
|
onChange(undefined);
|
|
2437
3587
|
},
|
|
@@ -2468,29 +3618,7 @@ var FilterEditor = ({
|
|
|
2468
3618
|
},
|
|
2469
3619
|
onSubmit: (event) => {
|
|
2470
3620
|
event.preventDefault();
|
|
2471
|
-
|
|
2472
|
-
apply({ id: column.id, kind, operator, value: primary.trim() });
|
|
2473
|
-
else if (kind === "date") {
|
|
2474
|
-
const draft = { id: column.id, kind };
|
|
2475
|
-
if (primary)
|
|
2476
|
-
draft.from = primary;
|
|
2477
|
-
if (secondary)
|
|
2478
|
-
draft.to = secondary;
|
|
2479
|
-
apply(draft);
|
|
2480
|
-
} else {
|
|
2481
|
-
const min = primary ? Schema2.decodeOption(Schema2.FiniteFromString)(primary) : Option2.some(undefined);
|
|
2482
|
-
const max = secondary ? Schema2.decodeOption(Schema2.FiniteFromString)(secondary) : Option2.some(undefined);
|
|
2483
|
-
if (Option2.isNone(min) || Option2.isNone(max)) {
|
|
2484
|
-
setInvalid(true);
|
|
2485
|
-
return;
|
|
2486
|
-
}
|
|
2487
|
-
const draft = { id: column.id, kind };
|
|
2488
|
-
if (min.value !== undefined)
|
|
2489
|
-
draft.min = min.value;
|
|
2490
|
-
if (max.value !== undefined)
|
|
2491
|
-
draft.max = max.value;
|
|
2492
|
-
apply(draft);
|
|
2493
|
-
}
|
|
3621
|
+
apply(draft);
|
|
2494
3622
|
},
|
|
2495
3623
|
children: [
|
|
2496
3624
|
/* @__PURE__ */ jsxs9(FieldGroup, {
|
|
@@ -2505,9 +3633,9 @@ var FilterEditor = ({
|
|
|
2505
3633
|
items: operatorOptions,
|
|
2506
3634
|
value: operator,
|
|
2507
3635
|
onValueChange: (value) => {
|
|
2508
|
-
const decoded =
|
|
2509
|
-
if (
|
|
2510
|
-
|
|
3636
|
+
const decoded = Schema6.decodeUnknownOption(TextFilterOperator)(value);
|
|
3637
|
+
if (Option4.isSome(decoded))
|
|
3638
|
+
setDraft({ ...draft, operator: decoded.value });
|
|
2511
3639
|
},
|
|
2512
3640
|
children: [
|
|
2513
3641
|
/* @__PURE__ */ jsx15(SelectTrigger, {
|
|
@@ -2540,7 +3668,7 @@ var FilterEditor = ({
|
|
|
2540
3668
|
value: primary,
|
|
2541
3669
|
"aria-invalid": invalid || undefined,
|
|
2542
3670
|
onChange: (event) => {
|
|
2543
|
-
|
|
3671
|
+
setDraft({ ...draft, primary: event.target.value });
|
|
2544
3672
|
setInvalid(false);
|
|
2545
3673
|
}
|
|
2546
3674
|
})
|
|
@@ -2560,7 +3688,7 @@ var FilterEditor = ({
|
|
|
2560
3688
|
value: secondary,
|
|
2561
3689
|
"aria-invalid": invalid || undefined,
|
|
2562
3690
|
onChange: (event) => {
|
|
2563
|
-
|
|
3691
|
+
setDraft({ ...draft, secondary: event.target.value });
|
|
2564
3692
|
setInvalid(false);
|
|
2565
3693
|
}
|
|
2566
3694
|
})
|
|
@@ -2586,8 +3714,7 @@ var FilterEditor = ({
|
|
|
2586
3714
|
size: "sm",
|
|
2587
3715
|
variant: "outline",
|
|
2588
3716
|
onClick: () => {
|
|
2589
|
-
|
|
2590
|
-
setSecondary("");
|
|
3717
|
+
setDraft({ ...draft, primary: "", secondary: "" });
|
|
2591
3718
|
setInvalid(false);
|
|
2592
3719
|
onChange(undefined);
|
|
2593
3720
|
},
|
|
@@ -2599,9 +3726,9 @@ var FilterEditor = ({
|
|
|
2599
3726
|
});
|
|
2600
3727
|
};
|
|
2601
3728
|
var FilterMenu = ({
|
|
2602
|
-
|
|
3729
|
+
table
|
|
2603
3730
|
}) => {
|
|
2604
|
-
const [store,
|
|
3731
|
+
const [store, send] = table;
|
|
2605
3732
|
const model = deriveModel(store);
|
|
2606
3733
|
const columns = model.columns.flatMap((parent) => getDataTableFilterColumns([parent]).map((column) => ({
|
|
2607
3734
|
column,
|
|
@@ -2610,7 +3737,7 @@ var FilterMenu = ({
|
|
|
2610
3737
|
if (!columns.length)
|
|
2611
3738
|
return null;
|
|
2612
3739
|
const filters = store.state.filters ?? [];
|
|
2613
|
-
const update = (id, filter) =>
|
|
3740
|
+
const update = (id, filter) => send(DataTableMessage.ColumnFilterChanged({ id, filter: filter ?? null }));
|
|
2614
3741
|
return /* @__PURE__ */ jsxs9(MenubarMenu, {
|
|
2615
3742
|
children: [
|
|
2616
3743
|
/* @__PURE__ */ jsxs9(MenubarTrigger2, {
|
|
@@ -2663,11 +3790,7 @@ var FilterMenu = ({
|
|
|
2663
3790
|
children: [
|
|
2664
3791
|
/* @__PURE__ */ jsx15(MenubarSeparator2, {}),
|
|
2665
3792
|
/* @__PURE__ */ jsxs9(MenubarItem2, {
|
|
2666
|
-
onClick: () =>
|
|
2667
|
-
...state,
|
|
2668
|
-
page: 0,
|
|
2669
|
-
filters: undefined
|
|
2670
|
-
})),
|
|
3793
|
+
onClick: () => send(DataTableMessage.FiltersCleared()),
|
|
2671
3794
|
children: [
|
|
2672
3795
|
/* @__PURE__ */ jsx15(X, {}),
|
|
2673
3796
|
store.config.labels.filtersClear
|
|
@@ -2682,9 +3805,9 @@ var FilterMenu = ({
|
|
|
2682
3805
|
});
|
|
2683
3806
|
};
|
|
2684
3807
|
var SortMenu = ({
|
|
2685
|
-
|
|
3808
|
+
table
|
|
2686
3809
|
}) => {
|
|
2687
|
-
const [store,
|
|
3810
|
+
const [store, send] = table;
|
|
2688
3811
|
const columns = deriveModel(store).columns.flatMap((column) => getDataTableSortColumns([column]).map((field) => field.id === column.id ? field : {
|
|
2689
3812
|
...field,
|
|
2690
3813
|
colDef: {
|
|
@@ -2695,11 +3818,7 @@ var SortMenu = ({
|
|
|
2695
3818
|
if (!columns.length)
|
|
2696
3819
|
return null;
|
|
2697
3820
|
const current = store.state.sort?.[0];
|
|
2698
|
-
const sort = (id, direction) =>
|
|
2699
|
-
...state,
|
|
2700
|
-
sort: [{ id, direction }],
|
|
2701
|
-
page: 0
|
|
2702
|
-
}));
|
|
3821
|
+
const sort = (id, direction) => send(DataTableMessage.SortRequested({ columnId: id, direction }));
|
|
2703
3822
|
return /* @__PURE__ */ jsxs9(MenubarMenu, {
|
|
2704
3823
|
children: [
|
|
2705
3824
|
/* @__PURE__ */ jsxs9(MenubarTrigger2, {
|
|
@@ -2753,9 +3872,9 @@ var SortMenu = ({
|
|
|
2753
3872
|
children: [
|
|
2754
3873
|
/* @__PURE__ */ jsx15(MenubarSeparator2, {}),
|
|
2755
3874
|
/* @__PURE__ */ jsxs9(MenubarItem2, {
|
|
2756
|
-
onClick: () =>
|
|
2757
|
-
|
|
2758
|
-
|
|
3875
|
+
onClick: () => send(DataTableMessage.SortRequested({
|
|
3876
|
+
columnId: column.id,
|
|
3877
|
+
direction: null
|
|
2759
3878
|
})),
|
|
2760
3879
|
children: [
|
|
2761
3880
|
/* @__PURE__ */ jsx15(X, {}),
|
|
@@ -2777,9 +3896,9 @@ var SortMenu = ({
|
|
|
2777
3896
|
});
|
|
2778
3897
|
};
|
|
2779
3898
|
var ViewMenu = ({
|
|
2780
|
-
|
|
3899
|
+
table
|
|
2781
3900
|
}) => {
|
|
2782
|
-
const [store,
|
|
3901
|
+
const [store, send] = table;
|
|
2783
3902
|
return /* @__PURE__ */ jsxs9(MenubarMenu, {
|
|
2784
3903
|
children: [
|
|
2785
3904
|
/* @__PURE__ */ jsxs9(MenubarTrigger2, {
|
|
@@ -2802,12 +3921,9 @@ var ViewMenu = ({
|
|
|
2802
3921
|
/* @__PURE__ */ jsx15(MenubarSeparator2, {}),
|
|
2803
3922
|
/* @__PURE__ */ jsxs9(MenubarRadioGroup, {
|
|
2804
3923
|
onValueChange: (input) => {
|
|
2805
|
-
const view =
|
|
2806
|
-
if (
|
|
2807
|
-
|
|
2808
|
-
...state,
|
|
2809
|
-
view: view.value
|
|
2810
|
-
}));
|
|
3924
|
+
const view = Schema6.decodeUnknownOption(DataTableViewSchema)(input);
|
|
3925
|
+
if (Option4.isSome(view)) {
|
|
3926
|
+
send(DataTableMessage.ViewPicked({ view: view.value }));
|
|
2811
3927
|
}
|
|
2812
3928
|
},
|
|
2813
3929
|
value: store.state.view,
|
|
@@ -2837,9 +3953,9 @@ var ViewMenu = ({
|
|
|
2837
3953
|
});
|
|
2838
3954
|
};
|
|
2839
3955
|
var ColumnMenu = ({
|
|
2840
|
-
|
|
3956
|
+
table
|
|
2841
3957
|
}) => {
|
|
2842
|
-
const [store,
|
|
3958
|
+
const [store, send] = table;
|
|
2843
3959
|
const columns = deriveModel(store).columns.filter(({ colDef }) => colDef.hideable !== false);
|
|
2844
3960
|
if (!columns.length)
|
|
2845
3961
|
return null;
|
|
@@ -2865,13 +3981,7 @@ var ColumnMenu = ({
|
|
|
2865
3981
|
/* @__PURE__ */ jsx15(MenubarSeparator2, {}),
|
|
2866
3982
|
columns.map((column) => /* @__PURE__ */ jsx15(MenubarCheckboxItem2, {
|
|
2867
3983
|
checked: store.state.columnVisibility[column.id] !== false,
|
|
2868
|
-
onCheckedChange: (visible) =>
|
|
2869
|
-
...state,
|
|
2870
|
-
columnVisibility: {
|
|
2871
|
-
...state.columnVisibility,
|
|
2872
|
-
[column.id]: visible
|
|
2873
|
-
}
|
|
2874
|
-
})),
|
|
3984
|
+
onCheckedChange: (visible) => send(DataTableMessage.ColumnVisibilityChanged({ id: column.id, visible })),
|
|
2875
3985
|
children: columnLabel(column)
|
|
2876
3986
|
}, column.id))
|
|
2877
3987
|
]
|
|
@@ -2881,54 +3991,43 @@ var ColumnMenu = ({
|
|
|
2881
3991
|
});
|
|
2882
3992
|
};
|
|
2883
3993
|
var ResizeHandle = ({
|
|
2884
|
-
|
|
3994
|
+
table
|
|
2885
3995
|
}) => {
|
|
2886
|
-
const
|
|
3996
|
+
const tableClasses = useContext(DataTableSlotClassesContext);
|
|
3997
|
+
const [store, send] = table;
|
|
2887
3998
|
const columnId = useRequiredId(ColumnIdContext);
|
|
2888
|
-
const resizeRef = useRef(null);
|
|
2889
3999
|
const column = deriveModel(store).columns.find(({ id }) => id === columnId);
|
|
2890
4000
|
if (!column || column.colDef.resizable === false)
|
|
2891
4001
|
return null;
|
|
2892
|
-
const
|
|
2893
|
-
...state,
|
|
2894
|
-
columnSizing: {
|
|
2895
|
-
...state.columnSizing,
|
|
2896
|
-
[column.id]: clampWidth(column.colDef, width)
|
|
2897
|
-
}
|
|
2898
|
-
}));
|
|
4002
|
+
const { min, max } = tableColumnLimits(column.colDef);
|
|
2899
4003
|
const onPointerDown = (event) => {
|
|
2900
4004
|
if (event.button !== 0)
|
|
2901
4005
|
return;
|
|
2902
4006
|
event.preventDefault();
|
|
2903
4007
|
event.currentTarget.setPointerCapture(event.pointerId);
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
};
|
|
4008
|
+
send(DataTableMessage.ResizeStarted({
|
|
4009
|
+
id: column.id,
|
|
4010
|
+
x: event.clientX,
|
|
4011
|
+
pointerId: event.pointerId
|
|
4012
|
+
}));
|
|
2909
4013
|
};
|
|
2910
4014
|
const onPointerMove = (event) => {
|
|
2911
|
-
|
|
2912
|
-
if (!drag || drag.pointerId !== event.pointerId)
|
|
2913
|
-
return;
|
|
2914
|
-
resize(drag.startWidth + event.clientX - drag.startX);
|
|
2915
|
-
};
|
|
2916
|
-
const reset = () => {
|
|
2917
|
-
resizeRef.current = null;
|
|
4015
|
+
send(DataTableMessage.ResizeMoved({ x: event.clientX, pointerId: event.pointerId }));
|
|
2918
4016
|
};
|
|
4017
|
+
const reset = (event) => send(DataTableMessage.ResizeEnded({ pointerId: event.pointerId }));
|
|
2919
4018
|
return /* @__PURE__ */ jsx15("button", {
|
|
2920
4019
|
"aria-label": store.config.labels.resizeColumn(columnLabel(column)),
|
|
2921
4020
|
"aria-orientation": "vertical",
|
|
2922
|
-
"aria-valuemax":
|
|
2923
|
-
"aria-valuemin":
|
|
4021
|
+
"aria-valuemax": max,
|
|
4022
|
+
"aria-valuemin": min,
|
|
2924
4023
|
"aria-valuenow": column.width,
|
|
2925
|
-
className:
|
|
2926
|
-
onDoubleClick: () =>
|
|
4024
|
+
className: tableClasses.resizeHandle,
|
|
4025
|
+
onDoubleClick: () => send(DataTableMessage.ColumnResizeReset({ id: column.id })),
|
|
2927
4026
|
onKeyDown: (event) => {
|
|
2928
|
-
const delta = event.key
|
|
4027
|
+
const delta = tableResizeStep(event.key);
|
|
2929
4028
|
if (delta) {
|
|
2930
4029
|
event.preventDefault();
|
|
2931
|
-
|
|
4030
|
+
send(DataTableMessage.ColumnResized({ id: column.id, delta }));
|
|
2932
4031
|
}
|
|
2933
4032
|
},
|
|
2934
4033
|
onPointerDown,
|
|
@@ -2941,9 +4040,9 @@ var ResizeHandle = ({
|
|
|
2941
4040
|
});
|
|
2942
4041
|
};
|
|
2943
4042
|
var DragHandle = ({
|
|
2944
|
-
|
|
4043
|
+
table
|
|
2945
4044
|
}) => {
|
|
2946
|
-
const [store
|
|
4045
|
+
const [store] = table;
|
|
2947
4046
|
const rowId = useRequiredId(RowIdContext);
|
|
2948
4047
|
const dragRef = useRef(null);
|
|
2949
4048
|
const [overlay, setOverlay] = useState(null);
|
|
@@ -3001,7 +4100,8 @@ var DragHandle = ({
|
|
|
3001
4100
|
const elements = document.elementsFromPoint(event.clientX, event.clientY);
|
|
3002
4101
|
const rowTarget = findTableDragTarget(elements, "[data-table-row]", root);
|
|
3003
4102
|
const groupTarget = findTableDragTarget(elements, "[data-table-group]", root);
|
|
3004
|
-
|
|
4103
|
+
if (drag.active) {
|
|
4104
|
+
const current = store;
|
|
3005
4105
|
const targetRowId = rowTarget?.dataset.tableRow;
|
|
3006
4106
|
const targetGroupKey = groupTarget?.dataset.tableGroup;
|
|
3007
4107
|
const model = deriveModel(current);
|
|
@@ -3017,8 +4117,7 @@ var DragHandle = ({
|
|
|
3017
4117
|
} else if (drag.active && source && targetRowId && reordering && canReorderRows(current) && source.id !== targetRowId) {
|
|
3018
4118
|
reordering.onReorder(reorderDataTableRows(model.rows, source.id, targetRowId));
|
|
3019
4119
|
}
|
|
3020
|
-
|
|
3021
|
-
});
|
|
4120
|
+
}
|
|
3022
4121
|
reset(event.currentTarget);
|
|
3023
4122
|
};
|
|
3024
4123
|
const cancel = (event) => {
|
|
@@ -3069,22 +4168,15 @@ var DragHandle = ({
|
|
|
3069
4168
|
]
|
|
3070
4169
|
});
|
|
3071
4170
|
};
|
|
3072
|
-
var toggleRow = (
|
|
3073
|
-
const rowSelection = { ...state.rowSelection, [rowId]: selected };
|
|
3074
|
-
const selection = store.config.features.selection;
|
|
3075
|
-
if (selection) {
|
|
3076
|
-
const model = deriveModel(store);
|
|
3077
|
-
selection.onSelectionChange?.(model.rows.filter((row) => rowSelection[row.id]).map((row) => row.data));
|
|
3078
|
-
}
|
|
3079
|
-
return { ...state, rowSelection };
|
|
3080
|
-
});
|
|
4171
|
+
var toggleRow = (send, rowId, checked) => send(DataTableMessage.SelectionRequested({ rowIds: [rowId], checked }));
|
|
3081
4172
|
var TableDataRow = ({
|
|
3082
|
-
|
|
4173
|
+
table,
|
|
3083
4174
|
row,
|
|
3084
4175
|
virtualIndex,
|
|
3085
4176
|
measureRef
|
|
3086
4177
|
}) => {
|
|
3087
|
-
const
|
|
4178
|
+
const tableClasses = useContext(DataTableSlotClassesContext);
|
|
4179
|
+
const [store, send] = table;
|
|
3088
4180
|
const model = deriveModel(store);
|
|
3089
4181
|
const selection = store.config.features.selection;
|
|
3090
4182
|
const selectable = !!selection && (selection.isRowSelectable?.(row.data) ?? true);
|
|
@@ -3106,37 +4198,40 @@ var TableDataRow = ({
|
|
|
3106
4198
|
tabIndex: store.config.onRowClicked ? 0 : undefined,
|
|
3107
4199
|
children: [
|
|
3108
4200
|
selection ? /* @__PURE__ */ jsx15(TableCell2, {
|
|
3109
|
-
className:
|
|
4201
|
+
className: tableClasses.selectionCell,
|
|
3110
4202
|
onClick: (event) => event.stopPropagation(),
|
|
3111
|
-
children: /* @__PURE__ */ jsx15(
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
4203
|
+
children: /* @__PURE__ */ jsx15("div", {
|
|
4204
|
+
className: tableClasses.selectionCenter,
|
|
4205
|
+
children: /* @__PURE__ */ jsx15(Checkbox, {
|
|
4206
|
+
"aria-label": store.config.labels.selectRow,
|
|
4207
|
+
checked: !!store.state.rowSelection[row.id],
|
|
4208
|
+
disabled: !selectable,
|
|
4209
|
+
onCheckedChange: (checked) => toggleRow(send, row.id, checked)
|
|
4210
|
+
})
|
|
3116
4211
|
})
|
|
3117
4212
|
}) : null,
|
|
3118
4213
|
draggable ? /* @__PURE__ */ jsx15(TableCell2, {
|
|
3119
4214
|
className: "w-10 pr-0",
|
|
3120
4215
|
children: /* @__PURE__ */ jsx15(DragHandle, {
|
|
3121
|
-
|
|
4216
|
+
table
|
|
3122
4217
|
})
|
|
3123
4218
|
}) : null,
|
|
3124
4219
|
model.visibleColumns.map((column) => /* @__PURE__ */ jsx15(TableCell2, {
|
|
3125
|
-
className: cn("min-w-24
|
|
4220
|
+
className: cn(tableClasses.cell, "min-w-24 has-[[data-slot=data-table-boolean-cell]]:relative has-[[data-slot=data-table-boolean-cell]]:p-0 has-[[data-slot=data-table-list-cell]]:relative has-[[data-slot=data-table-list-cell]]:p-0", column.colDef.truncate ? "whitespace-nowrap" : "whitespace-normal"),
|
|
3126
4221
|
style: { width: column.width },
|
|
3127
4222
|
children: /* @__PURE__ */ jsx15("div", {
|
|
3128
|
-
className: cn(
|
|
4223
|
+
className: cn(tableClasses.cellContent, column.colDef.truncate && "truncate"),
|
|
3129
4224
|
children: renderCell(row, column, store.config.locale, store.config.labels)
|
|
3130
4225
|
})
|
|
3131
4226
|
}, column.id)),
|
|
3132
4227
|
hasRowActionMenu(store) ? /* @__PURE__ */ jsx15(TableCell2, {
|
|
3133
|
-
className: "
|
|
4228
|
+
className: cn(tableClasses.actionsCell, "group-data-[state=selected]/row:bg-muted"),
|
|
3134
4229
|
onClick: (event) => event.stopPropagation(),
|
|
3135
4230
|
children: /* @__PURE__ */ jsx15("div", {
|
|
3136
|
-
className:
|
|
4231
|
+
className: tableClasses.actionsAlign,
|
|
3137
4232
|
children: /* @__PURE__ */ jsx15(DataTableRowActionMenu, {
|
|
3138
4233
|
row,
|
|
3139
|
-
|
|
4234
|
+
table
|
|
3140
4235
|
})
|
|
3141
4236
|
})
|
|
3142
4237
|
}) : null
|
|
@@ -3186,35 +4281,30 @@ var GroupActions = ({
|
|
|
3186
4281
|
});
|
|
3187
4282
|
};
|
|
3188
4283
|
var GroupHeaderRow = ({
|
|
3189
|
-
|
|
4284
|
+
table,
|
|
3190
4285
|
section,
|
|
3191
4286
|
colSpan,
|
|
3192
4287
|
virtualIndex,
|
|
3193
4288
|
measureRef
|
|
3194
4289
|
}) => {
|
|
3195
|
-
const
|
|
4290
|
+
const tableClasses = useContext(DataTableSlotClassesContext);
|
|
4291
|
+
const [store, send] = table;
|
|
3196
4292
|
const collapsed = !!store.state.collapsedGroups[section.key];
|
|
3197
4293
|
return /* @__PURE__ */ jsx15(TableRow2, {
|
|
3198
4294
|
ref: measureRef,
|
|
3199
4295
|
"data-index": virtualIndex,
|
|
3200
4296
|
"aria-rowindex": virtualIndex === undefined ? undefined : virtualIndex + 2,
|
|
3201
|
-
className: "
|
|
3202
|
-
onClick: () =>
|
|
3203
|
-
...state,
|
|
3204
|
-
collapsedGroups: {
|
|
3205
|
-
...state.collapsedGroups,
|
|
3206
|
-
[section.key]: !collapsed
|
|
3207
|
-
}
|
|
3208
|
-
})),
|
|
4297
|
+
className: cn(tableClasses.group, "cursor-pointer"),
|
|
4298
|
+
onClick: () => send(DataTableMessage.GroupToggled({ key: section.key })),
|
|
3209
4299
|
children: /* @__PURE__ */ jsx15(TableCell2, {
|
|
3210
4300
|
className: "p-0",
|
|
3211
4301
|
colSpan,
|
|
3212
4302
|
children: /* @__PURE__ */ jsxs9("div", {
|
|
3213
|
-
className:
|
|
4303
|
+
className: cn(tableClasses.groupContent, tableClasses.groupSticky),
|
|
3214
4304
|
children: [
|
|
3215
4305
|
/* @__PURE__ */ jsxs9("button", {
|
|
3216
4306
|
"aria-expanded": !collapsed,
|
|
3217
|
-
className:
|
|
4307
|
+
className: tableClasses.groupTrigger,
|
|
3218
4308
|
style: { paddingLeft: section.depth * 20 },
|
|
3219
4309
|
type: "button",
|
|
3220
4310
|
children: [
|
|
@@ -3229,9 +4319,8 @@ var GroupHeaderRow = ({
|
|
|
3229
4319
|
})
|
|
3230
4320
|
]
|
|
3231
4321
|
}),
|
|
3232
|
-
/* @__PURE__ */ jsx15(
|
|
3233
|
-
className:
|
|
3234
|
-
variant: "secondary",
|
|
4322
|
+
/* @__PURE__ */ jsx15("span", {
|
|
4323
|
+
className: tableClasses.count,
|
|
3235
4324
|
children: section.rows.length
|
|
3236
4325
|
}),
|
|
3237
4326
|
/* @__PURE__ */ jsx15(GroupActions, {
|
|
@@ -3245,10 +4334,10 @@ var GroupHeaderRow = ({
|
|
|
3245
4334
|
});
|
|
3246
4335
|
};
|
|
3247
4336
|
var GroupedTable = ({
|
|
3248
|
-
|
|
4337
|
+
table,
|
|
3249
4338
|
sections
|
|
3250
4339
|
}) => {
|
|
3251
|
-
const [store] =
|
|
4340
|
+
const [store] = table;
|
|
3252
4341
|
const model = deriveModel(store);
|
|
3253
4342
|
const extra = (store.config.features.selection ? 1 : 0) + (hasRowActionMenu(store) ? 1 : 0) + (canDragRows(store) ? 1 : 0);
|
|
3254
4343
|
const renderSections = (items) => items.flatMap((section) => {
|
|
@@ -3259,7 +4348,7 @@ var GroupedTable = ({
|
|
|
3259
4348
|
"data-table-group": section.field.onMoveToGroup ? targetKey : undefined,
|
|
3260
4349
|
children: [
|
|
3261
4350
|
/* @__PURE__ */ jsx15(GroupHeaderRow, {
|
|
3262
|
-
|
|
4351
|
+
table,
|
|
3263
4352
|
section,
|
|
3264
4353
|
colSpan: model.visibleColumns.length + extra
|
|
3265
4354
|
}),
|
|
@@ -3267,7 +4356,7 @@ var GroupedTable = ({
|
|
|
3267
4356
|
value: row.id,
|
|
3268
4357
|
children: /* @__PURE__ */ jsx15(TableDataRow, {
|
|
3269
4358
|
row,
|
|
3270
|
-
|
|
4359
|
+
table
|
|
3271
4360
|
})
|
|
3272
4361
|
}, `${section.key}:${row.id}`)) : [
|
|
3273
4362
|
/* @__PURE__ */ jsx15(TableRow2, {
|
|
@@ -3287,9 +4376,10 @@ var GroupedTable = ({
|
|
|
3287
4376
|
});
|
|
3288
4377
|
};
|
|
3289
4378
|
var ColumnHeaderMenu = ({
|
|
3290
|
-
|
|
4379
|
+
table
|
|
3291
4380
|
}) => {
|
|
3292
|
-
const
|
|
4381
|
+
const tableClasses = useContext(DataTableSlotClassesContext);
|
|
4382
|
+
const [store, send] = table;
|
|
3293
4383
|
const columnId = useRequiredId(ColumnIdContext);
|
|
3294
4384
|
const model = deriveModel(store);
|
|
3295
4385
|
const column = model.columns.find(({ id }) => id === columnId);
|
|
@@ -3305,18 +4395,13 @@ var ColumnHeaderMenu = ({
|
|
|
3305
4395
|
rows: model.rows,
|
|
3306
4396
|
current: store.state.filters?.find((filter) => filter.id === field.id),
|
|
3307
4397
|
labels: store.config.labels,
|
|
3308
|
-
onChange: (filter) =>
|
|
4398
|
+
onChange: (filter) => send(DataTableMessage.ColumnFilterChanged({ id: field.id, filter: filter ?? null }))
|
|
3309
4399
|
});
|
|
3310
4400
|
const sortingEnabled = store.config.features.sorting !== false && sortColumns.length > 0;
|
|
3311
4401
|
const hidingEnabled = store.config.features.columnVisibility !== false && column.colDef.hideable !== false;
|
|
3312
4402
|
const ownsSort = (id) => id === column.id || sortColumns.some((field) => field.id === id);
|
|
3313
4403
|
const sort = store.state.sort?.find(({ id }) => ownsSort(id));
|
|
3314
|
-
const
|
|
3315
|
-
const setSort = (id, direction) => update((state) => ({
|
|
3316
|
-
...state,
|
|
3317
|
-
sort: [{ id, direction }],
|
|
3318
|
-
page: 0
|
|
3319
|
-
}));
|
|
4404
|
+
const setSort = (id, direction) => send(DataTableMessage.SortRequested({ columnId: id, direction }));
|
|
3320
4405
|
const label = columnLabel(column);
|
|
3321
4406
|
const sortItems = (field) => /* @__PURE__ */ jsxs9(Fragment, {
|
|
3322
4407
|
children: [
|
|
@@ -3350,7 +4435,7 @@ var ColumnHeaderMenu = ({
|
|
|
3350
4435
|
render: /* @__PURE__ */ jsxs9(Button, {
|
|
3351
4436
|
"aria-label": label,
|
|
3352
4437
|
"aria-description": activeFilters.length ? `${store.config.labels.filters}: ${activeFilters.length}` : undefined,
|
|
3353
|
-
className:
|
|
4438
|
+
className: tableClasses.headerTrigger,
|
|
3354
4439
|
variant: "ghost",
|
|
3355
4440
|
children: [
|
|
3356
4441
|
/* @__PURE__ */ jsx15("span", {
|
|
@@ -3382,10 +4467,7 @@ var ColumnHeaderMenu = ({
|
|
|
3382
4467
|
]
|
|
3383
4468
|
}, field.id)) : sortItems(column),
|
|
3384
4469
|
sort ? /* @__PURE__ */ jsxs9(DropdownMenuItem2, {
|
|
3385
|
-
onClick: () =>
|
|
3386
|
-
...state,
|
|
3387
|
-
sort: state.sort?.filter(({ id }) => !ownsSort(id))
|
|
3388
|
-
})),
|
|
4470
|
+
onClick: () => send(DataTableMessage.ColumnSortCleared({ id: column.id })),
|
|
3389
4471
|
children: [
|
|
3390
4472
|
/* @__PURE__ */ jsx15(X, {}),
|
|
3391
4473
|
" ",
|
|
@@ -3427,14 +4509,7 @@ var ColumnHeaderMenu = ({
|
|
|
3427
4509
|
]
|
|
3428
4510
|
}),
|
|
3429
4511
|
activeFilters.length ? /* @__PURE__ */ jsxs9(DropdownMenuItem2, {
|
|
3430
|
-
onClick: () =>
|
|
3431
|
-
const filters = state.filters?.filter(({ id }) => !ownsFilter(id));
|
|
3432
|
-
return {
|
|
3433
|
-
...state,
|
|
3434
|
-
page: 0,
|
|
3435
|
-
filters: filters?.length ? filters : undefined
|
|
3436
|
-
};
|
|
3437
|
-
}),
|
|
4512
|
+
onClick: () => send(DataTableMessage.ColumnFiltersCleared({ id: column.id })),
|
|
3438
4513
|
children: [
|
|
3439
4514
|
/* @__PURE__ */ jsx15(X, {}),
|
|
3440
4515
|
store.config.labels.filterClear
|
|
@@ -3444,12 +4519,9 @@ var ColumnHeaderMenu = ({
|
|
|
3444
4519
|
}) : null,
|
|
3445
4520
|
(sortingEnabled || filteringEnabled) && hidingEnabled ? /* @__PURE__ */ jsx15(DropdownMenuSeparator2, {}) : null,
|
|
3446
4521
|
hidingEnabled ? /* @__PURE__ */ jsxs9(DropdownMenuItem2, {
|
|
3447
|
-
onClick: () =>
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
...state.columnVisibility,
|
|
3451
|
-
[column.id]: false
|
|
3452
|
-
}
|
|
4522
|
+
onClick: () => send(DataTableMessage.ColumnVisibilityChanged({
|
|
4523
|
+
id: column.id,
|
|
4524
|
+
visible: false
|
|
3453
4525
|
})),
|
|
3454
4526
|
children: [
|
|
3455
4527
|
/* @__PURE__ */ jsx15(EyeOff, {}),
|
|
@@ -3464,36 +4536,37 @@ var ColumnHeaderMenu = ({
|
|
|
3464
4536
|
});
|
|
3465
4537
|
};
|
|
3466
4538
|
var DataTableHeader = ({
|
|
3467
|
-
|
|
4539
|
+
table,
|
|
3468
4540
|
sticky
|
|
3469
4541
|
}) => {
|
|
3470
|
-
const
|
|
4542
|
+
const tableClasses = useContext(DataTableSlotClassesContext);
|
|
4543
|
+
const [store, send] = table;
|
|
3471
4544
|
const model = deriveModel(store);
|
|
3472
4545
|
const selection = store.config.features.selection;
|
|
3473
|
-
const grouped = getActiveGrouping(store).length > 0;
|
|
3474
4546
|
const draggable = canDragRows(store);
|
|
3475
|
-
const selectableRows =
|
|
4547
|
+
const selectableRows = model.pageRows.filter((row) => !selection || (selection.isRowSelectable?.(row.data) ?? true));
|
|
3476
4548
|
const allSelected = selectableRows.length > 0 && selectableRows.every((row) => store.state.rowSelection[row.id]);
|
|
3477
4549
|
const someSelected = selectableRows.some((row) => store.state.rowSelection[row.id]);
|
|
3478
4550
|
return /* @__PURE__ */ jsx15(TableHeader2, {
|
|
3479
|
-
className: sticky ?
|
|
4551
|
+
className: sticky ? cn(tableClasses.stickyHeader, tableClasses.stickyHeaderRule, "[&_tr]:border-b-0") : undefined,
|
|
3480
4552
|
children: /* @__PURE__ */ jsxs9(TableRow2, {
|
|
3481
4553
|
"aria-rowindex": sticky ? 1 : undefined,
|
|
3482
4554
|
children: [
|
|
3483
4555
|
selection ? /* @__PURE__ */ jsx15(TableHead2, {
|
|
3484
|
-
className:
|
|
3485
|
-
children: /* @__PURE__ */ jsx15(
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
|
|
4556
|
+
className: tableClasses.selectionCell,
|
|
4557
|
+
children: /* @__PURE__ */ jsx15("div", {
|
|
4558
|
+
className: tableClasses.selectionCenter,
|
|
4559
|
+
children: /* @__PURE__ */ jsx15(Checkbox, {
|
|
4560
|
+
"aria-label": store.config.labels.selectAllRows,
|
|
4561
|
+
checked: allSelected,
|
|
4562
|
+
indeterminate: someSelected && !allSelected,
|
|
4563
|
+
onCheckedChange: (checked) => {
|
|
4564
|
+
send(DataTableMessage.SelectionRequested({
|
|
4565
|
+
rowIds: selectableRows.map(({ id }) => id),
|
|
4566
|
+
checked
|
|
4567
|
+
}));
|
|
4568
|
+
}
|
|
4569
|
+
})
|
|
3497
4570
|
})
|
|
3498
4571
|
}) : null,
|
|
3499
4572
|
draggable ? /* @__PURE__ */ jsx15(TableHead2, {
|
|
@@ -3503,17 +4576,17 @@ var DataTableHeader = ({
|
|
|
3503
4576
|
const direction = store.state.sort?.find(({ id }) => id === column.id)?.direction;
|
|
3504
4577
|
return /* @__PURE__ */ jsx15(TableHead2, {
|
|
3505
4578
|
"aria-sort": direction === "asc" ? "ascending" : direction === "desc" ? "descending" : undefined,
|
|
3506
|
-
className:
|
|
4579
|
+
className: tableClasses.header,
|
|
3507
4580
|
scope: "col",
|
|
3508
4581
|
style: { width: column.width },
|
|
3509
4582
|
children: /* @__PURE__ */ jsxs9(ColumnIdContext.Provider, {
|
|
3510
4583
|
value: column.id,
|
|
3511
4584
|
children: [
|
|
3512
4585
|
/* @__PURE__ */ jsx15(ColumnHeaderMenu, {
|
|
3513
|
-
|
|
4586
|
+
table
|
|
3514
4587
|
}),
|
|
3515
4588
|
/* @__PURE__ */ jsx15(ResizeHandle, {
|
|
3516
|
-
|
|
4589
|
+
table
|
|
3517
4590
|
})
|
|
3518
4591
|
]
|
|
3519
4592
|
})
|
|
@@ -3527,13 +4600,13 @@ var DataTableHeader = ({
|
|
|
3527
4600
|
});
|
|
3528
4601
|
};
|
|
3529
4602
|
var VirtualTableRows = ({
|
|
3530
|
-
|
|
4603
|
+
table,
|
|
3531
4604
|
rows,
|
|
3532
4605
|
sections,
|
|
3533
4606
|
viewport,
|
|
3534
4607
|
colSpan
|
|
3535
4608
|
}) => {
|
|
3536
|
-
const [{ state, config }] =
|
|
4609
|
+
const [{ state, config }] = table;
|
|
3537
4610
|
const { element: scrollElement, headerHeight } = viewport;
|
|
3538
4611
|
const pageScroll = viewport.options.scroll === "page";
|
|
3539
4612
|
const scrollMargin = viewport.pageOffset ?? headerHeight;
|
|
@@ -3618,7 +4691,7 @@ var VirtualTableRows = ({
|
|
|
3618
4691
|
return /* @__PURE__ */ jsx15(TableDataRow, {
|
|
3619
4692
|
measureRef: virtualizer.measureElement,
|
|
3620
4693
|
row: entry.row,
|
|
3621
|
-
|
|
4694
|
+
table,
|
|
3622
4695
|
virtualIndex: index
|
|
3623
4696
|
}, key);
|
|
3624
4697
|
if (entry.kind === "header")
|
|
@@ -3626,7 +4699,7 @@ var VirtualTableRows = ({
|
|
|
3626
4699
|
measureRef: virtualizer.measureElement,
|
|
3627
4700
|
section: entry.section,
|
|
3628
4701
|
colSpan,
|
|
3629
|
-
|
|
4702
|
+
table,
|
|
3630
4703
|
virtualIndex: index
|
|
3631
4704
|
}, key);
|
|
3632
4705
|
return /* @__PURE__ */ jsx15(TableRow2, {
|
|
@@ -3645,21 +4718,20 @@ var VirtualTableRows = ({
|
|
|
3645
4718
|
});
|
|
3646
4719
|
};
|
|
3647
4720
|
var DataTableBody = ({
|
|
3648
|
-
|
|
4721
|
+
table,
|
|
3649
4722
|
viewport
|
|
3650
4723
|
}) => {
|
|
3651
4724
|
const styles = useContext(DataTableStylesContext);
|
|
3652
|
-
const [store] =
|
|
4725
|
+
const [store] = table;
|
|
3653
4726
|
const model = deriveModel(store);
|
|
3654
4727
|
const fields = getActiveGrouping(store);
|
|
3655
|
-
const
|
|
3656
|
-
const rows = grouped ? model.sortedRows : model.pageRows;
|
|
4728
|
+
const rows = model.pageRows;
|
|
3657
4729
|
const sections = useMemo2(() => groupDataTableRows(rows, fields), [rows, fields]);
|
|
3658
4730
|
const colSpan = model.visibleColumns.length + (store.config.features.selection ? 1 : 0) + (hasRowActionMenu(store) ? 1 : 0) + (canDragRows(store) ? 1 : 0);
|
|
3659
4731
|
const showGroups = sections.length && (rows.length || !store.config.status.loading) && !store.config.status.error;
|
|
3660
4732
|
if (showGroups && !viewport) {
|
|
3661
4733
|
return /* @__PURE__ */ jsx15(GroupedTable, {
|
|
3662
|
-
|
|
4734
|
+
table,
|
|
3663
4735
|
sections
|
|
3664
4736
|
});
|
|
3665
4737
|
}
|
|
@@ -3685,30 +4757,17 @@ var DataTableBody = ({
|
|
|
3685
4757
|
colSpan,
|
|
3686
4758
|
rows,
|
|
3687
4759
|
sections,
|
|
3688
|
-
|
|
4760
|
+
table,
|
|
3689
4761
|
viewport
|
|
3690
4762
|
}) : rows.map((row) => /* @__PURE__ */ jsx15(RowIdContext.Provider, {
|
|
3691
4763
|
value: row.id,
|
|
3692
4764
|
children: /* @__PURE__ */ jsx15(TableDataRow, {
|
|
3693
4765
|
row,
|
|
3694
|
-
|
|
4766
|
+
table
|
|
3695
4767
|
})
|
|
3696
4768
|
}, row.id))
|
|
3697
4769
|
});
|
|
3698
4770
|
};
|
|
3699
|
-
var GalleryImage = ({ src, alt }) => {
|
|
3700
|
-
const [failed, setFailed] = useState(false);
|
|
3701
|
-
if (failed)
|
|
3702
|
-
return null;
|
|
3703
|
-
return /* @__PURE__ */ jsx15("img", {
|
|
3704
|
-
src,
|
|
3705
|
-
alt,
|
|
3706
|
-
loading: "lazy",
|
|
3707
|
-
decoding: "async",
|
|
3708
|
-
className: "aspect-video w-full object-cover",
|
|
3709
|
-
onError: () => setFailed(true)
|
|
3710
|
-
});
|
|
3711
|
-
};
|
|
3712
4771
|
var GalleryTag = ({
|
|
3713
4772
|
row,
|
|
3714
4773
|
column,
|
|
@@ -3735,9 +4794,9 @@ var GalleryTag = ({
|
|
|
3735
4794
|
});
|
|
3736
4795
|
};
|
|
3737
4796
|
var GalleryCard = ({
|
|
3738
|
-
|
|
4797
|
+
table
|
|
3739
4798
|
}) => {
|
|
3740
|
-
const [store,
|
|
4799
|
+
const [store, send] = table;
|
|
3741
4800
|
const rowId = useRequiredId(RowIdContext);
|
|
3742
4801
|
const model = deriveModel(store);
|
|
3743
4802
|
const row = model.sortedRows.find((candidate) => candidate.id === rowId);
|
|
@@ -3766,10 +4825,14 @@ var GalleryCard = ({
|
|
|
3766
4825
|
},
|
|
3767
4826
|
tabIndex: store.config.onRowClicked ? 0 : undefined,
|
|
3768
4827
|
children: [
|
|
3769
|
-
imageSrc ? /* @__PURE__ */ jsx15(
|
|
4828
|
+
imageSrc && !store.ui.failedImages.includes(imageSrc) ? /* @__PURE__ */ jsx15("img", {
|
|
3770
4829
|
src: imageSrc,
|
|
3771
|
-
alt: gallery.image?.getAlt?.(row.data) ?? ""
|
|
3772
|
-
|
|
4830
|
+
alt: gallery.image?.getAlt?.(row.data) ?? "",
|
|
4831
|
+
loading: "lazy",
|
|
4832
|
+
decoding: "async",
|
|
4833
|
+
className: "aspect-video w-full object-cover",
|
|
4834
|
+
onError: () => send(DataTableMessage.ReferenceImageFailed({ src: imageSrc }))
|
|
4835
|
+
}) : null,
|
|
3773
4836
|
/* @__PURE__ */ jsxs9(CardHeader, {
|
|
3774
4837
|
className: cn("relative", hasRowActionMenu(store) && "pr-12"),
|
|
3775
4838
|
children: [
|
|
@@ -3780,11 +4843,11 @@ var GalleryCard = ({
|
|
|
3780
4843
|
"aria-label": store.config.labels.selectRow,
|
|
3781
4844
|
checked: !!store.state.rowSelection[row.id],
|
|
3782
4845
|
disabled: !selectable,
|
|
3783
|
-
onCheckedChange: (checked) => toggleRow(
|
|
4846
|
+
onCheckedChange: (checked) => toggleRow(send, row.id, checked),
|
|
3784
4847
|
onClick: (event) => event.stopPropagation()
|
|
3785
4848
|
}) : null,
|
|
3786
4849
|
draggable ? /* @__PURE__ */ jsx15(DragHandle, {
|
|
3787
|
-
|
|
4850
|
+
table
|
|
3788
4851
|
}) : null
|
|
3789
4852
|
]
|
|
3790
4853
|
}) : null,
|
|
@@ -3813,7 +4876,7 @@ var GalleryCard = ({
|
|
|
3813
4876
|
onClick: (event) => event.stopPropagation(),
|
|
3814
4877
|
children: /* @__PURE__ */ jsx15(DataTableRowActionMenu, {
|
|
3815
4878
|
row,
|
|
3816
|
-
|
|
4879
|
+
table
|
|
3817
4880
|
})
|
|
3818
4881
|
}) : null
|
|
3819
4882
|
]
|
|
@@ -3822,13 +4885,13 @@ var GalleryCard = ({
|
|
|
3822
4885
|
});
|
|
3823
4886
|
};
|
|
3824
4887
|
var DataTableGallery = ({
|
|
3825
|
-
|
|
4888
|
+
table
|
|
3826
4889
|
}) => {
|
|
3827
4890
|
const styles = useContext(DataTableStylesContext);
|
|
3828
|
-
const [store,
|
|
4891
|
+
const [store, send] = table;
|
|
3829
4892
|
const model = deriveModel(store);
|
|
3830
4893
|
const fields = getActiveGrouping(store);
|
|
3831
|
-
const rows =
|
|
4894
|
+
const rows = model.pageRows;
|
|
3832
4895
|
const sections = groupDataTableRows(rows, fields);
|
|
3833
4896
|
if (store.config.status.error) {
|
|
3834
4897
|
return /* @__PURE__ */ jsx15("div", {
|
|
@@ -3860,7 +4923,7 @@ var DataTableGallery = ({
|
|
|
3860
4923
|
children: rows.map((row) => /* @__PURE__ */ jsx15(RowIdContext.Provider, {
|
|
3861
4924
|
value: row.id,
|
|
3862
4925
|
children: /* @__PURE__ */ jsx15(GalleryCard, {
|
|
3863
|
-
|
|
4926
|
+
table
|
|
3864
4927
|
})
|
|
3865
4928
|
}, row.id))
|
|
3866
4929
|
});
|
|
@@ -3868,13 +4931,7 @@ var DataTableGallery = ({
|
|
|
3868
4931
|
const renderSections = (sections) => sections.map((section) => {
|
|
3869
4932
|
const collapsed = !!store.state.collapsedGroups[section.key];
|
|
3870
4933
|
const targetKey = getGroupDropKey(section.field.id, section.groupId);
|
|
3871
|
-
const toggleCollapsed = () =>
|
|
3872
|
-
...state,
|
|
3873
|
-
collapsedGroups: {
|
|
3874
|
-
...state.collapsedGroups,
|
|
3875
|
-
[section.key]: !collapsed
|
|
3876
|
-
}
|
|
3877
|
-
}));
|
|
4934
|
+
const toggleCollapsed = () => send(DataTableMessage.GroupToggled({ key: section.key }));
|
|
3878
4935
|
return /* @__PURE__ */ jsxs9("section", {
|
|
3879
4936
|
className: "data-[drop-target=true]:ring-primary space-y-3 rounded-lg transition-shadow data-[drop-target=true]:ring-2",
|
|
3880
4937
|
"data-table-group": section.field.onMoveToGroup ? targetKey : undefined,
|
|
@@ -3916,7 +4973,7 @@ var DataTableGallery = ({
|
|
|
3916
4973
|
children: section.rows.map((row) => /* @__PURE__ */ jsx15(RowIdContext.Provider, {
|
|
3917
4974
|
value: row.id,
|
|
3918
4975
|
children: /* @__PURE__ */ jsx15(GalleryCard, {
|
|
3919
|
-
|
|
4976
|
+
table
|
|
3920
4977
|
})
|
|
3921
4978
|
}, `${section.key}:${row.id}`))
|
|
3922
4979
|
}) : /* @__PURE__ */ jsx15("div", {
|
|
@@ -3932,28 +4989,22 @@ var DataTableGallery = ({
|
|
|
3932
4989
|
});
|
|
3933
4990
|
};
|
|
3934
4991
|
var DataTablePagination = ({
|
|
3935
|
-
|
|
4992
|
+
table
|
|
3936
4993
|
}) => {
|
|
3937
4994
|
const styles = useContext(DataTableStylesContext);
|
|
3938
|
-
const [store,
|
|
4995
|
+
const [store, send] = table;
|
|
3939
4996
|
const model = deriveModel(store);
|
|
3940
4997
|
const pagination = store.config.features.pagination ?? false;
|
|
3941
|
-
const
|
|
3942
|
-
const paginationVisible = pagination !== false && !clientGrouping;
|
|
4998
|
+
const { paginationVisible, page } = model;
|
|
3943
4999
|
const pageIndex = store.state.page;
|
|
3944
|
-
const maxPageIndex = model.pageCount - 1;
|
|
3945
5000
|
useLayoutEffect(() => {
|
|
3946
|
-
if (paginationVisible && pageIndex >
|
|
3947
|
-
|
|
3948
|
-
...state,
|
|
3949
|
-
page: maxPageIndex
|
|
3950
|
-
}));
|
|
5001
|
+
if (paginationVisible && pagination && pagination.mode === "client" && pageIndex > page) {
|
|
5002
|
+
send(DataTableMessage.PageRequested({ page }));
|
|
3951
5003
|
}
|
|
3952
|
-
}, [
|
|
3953
|
-
if (!paginationVisible)
|
|
5004
|
+
}, [page, pageIndex, pagination, paginationVisible, send]);
|
|
5005
|
+
if (!paginationVisible || !pagination)
|
|
3954
5006
|
return null;
|
|
3955
5007
|
const selected = model.rows.filter((row) => store.state.rowSelection[row.id]).length;
|
|
3956
|
-
const setPagination = (next) => changeState(setStore, (state) => ({ ...state, ...next }));
|
|
3957
5008
|
return /* @__PURE__ */ jsx15("div", {
|
|
3958
5009
|
"data-table-slot": "pagination",
|
|
3959
5010
|
className: cn("shrink-0 pt-4", styles?.pagination),
|
|
@@ -3961,9 +5012,9 @@ var DataTablePagination = ({
|
|
|
3961
5012
|
pageSizeContentClassName: styles?.popup?.select,
|
|
3962
5013
|
locale: store.config.locale,
|
|
3963
5014
|
messages: { [store.config.locale]: store.config.labels },
|
|
3964
|
-
onPageChange: (page) =>
|
|
3965
|
-
onPageSizeChange: (pageSize) =>
|
|
3966
|
-
page
|
|
5015
|
+
onPageChange: (page) => send(DataTableMessage.PageRequested({ page })),
|
|
5016
|
+
onPageSizeChange: (pageSize) => send(DataTableMessage.PageSizeRequested({ pageSize })),
|
|
5017
|
+
page,
|
|
3967
5018
|
pageCount: model.pageCount,
|
|
3968
5019
|
pageSize: store.state.pageSize,
|
|
3969
5020
|
pageSizes: pagination.pageSizes,
|
|
@@ -3972,151 +5023,221 @@ var DataTablePagination = ({
|
|
|
3972
5023
|
})
|
|
3973
5024
|
});
|
|
3974
5025
|
};
|
|
5026
|
+
var ReactTableModel = Component3.define(dataTableOptions).make({
|
|
5027
|
+
...dataTableBehaviours,
|
|
5028
|
+
view: () => View.text("")
|
|
5029
|
+
});
|
|
5030
|
+
var modelField = (id, definition) => {
|
|
5031
|
+
const field = {
|
|
5032
|
+
id,
|
|
5033
|
+
headerName: id,
|
|
5034
|
+
type: definition.type ?? "text"
|
|
5035
|
+
};
|
|
5036
|
+
if (definition.sortable !== undefined)
|
|
5037
|
+
field.sortable = definition.sortable;
|
|
5038
|
+
if (definition.filterable !== undefined)
|
|
5039
|
+
field.filterable = definition.filterable;
|
|
5040
|
+
return field;
|
|
5041
|
+
};
|
|
5042
|
+
var modelColumns = (definitions) => normalizeDataTableColumns(definitions).map(({ id, colDef }) => {
|
|
5043
|
+
const column = modelField(id, colDef);
|
|
5044
|
+
if (colDef.width !== undefined)
|
|
5045
|
+
column.width = colDef.width;
|
|
5046
|
+
if (colDef.minWidth !== undefined)
|
|
5047
|
+
column.minWidth = colDef.minWidth;
|
|
5048
|
+
if (colDef.maxWidth !== undefined)
|
|
5049
|
+
column.maxWidth = colDef.maxWidth;
|
|
5050
|
+
if (colDef.hideable !== undefined)
|
|
5051
|
+
column.hideable = colDef.hideable;
|
|
5052
|
+
if (colDef.resizable !== undefined)
|
|
5053
|
+
column.resizable = colDef.resizable;
|
|
5054
|
+
if (colDef.fields)
|
|
5055
|
+
column.fields = colDef.fields.map((field) => modelField(field.id, field));
|
|
5056
|
+
return column;
|
|
5057
|
+
});
|
|
3975
5058
|
var getTableLayoutClass = (virtualization) => virtualization && virtualization !== true && virtualization.scroll === "internal" ? "flex min-h-0 flex-1 flex-col" : undefined;
|
|
3976
|
-
var HydratedDataTable = ({
|
|
3977
|
-
|
|
3978
|
-
|
|
3979
|
-
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
const grouping =
|
|
3983
|
-
|
|
3984
|
-
|
|
3985
|
-
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
|
|
3990
|
-
|
|
3991
|
-
|
|
3992
|
-
|
|
3993
|
-
|
|
3994
|
-
setTransientUiState(transientUiFromState(state));
|
|
3995
|
-
}, [setPersistedUiState, setTransientUiState]);
|
|
3996
|
-
const validatedConfig = resolveConfig(props, (state) => setUiState(state));
|
|
3997
|
-
const [tableAtom] = useState(() => {
|
|
3998
|
-
const initial = {
|
|
3999
|
-
rowData: props.rowData,
|
|
4000
|
-
columnDefs: props.columnDefs,
|
|
4001
|
-
config: validatedConfig,
|
|
4002
|
-
state: initialPublicState(props, uiState),
|
|
4003
|
-
controlledState: props.state
|
|
5059
|
+
var HydratedDataTable = (props) => {
|
|
5060
|
+
const config = useMemo2(() => resolveConfig(props), [props]);
|
|
5061
|
+
const columns = useMemo2(() => modelColumns(props.columnDefs), [props.columnDefs]);
|
|
5062
|
+
const selection = config.features.selection;
|
|
5063
|
+
const modelProps = useMemo2(() => {
|
|
5064
|
+
const { features } = config;
|
|
5065
|
+
const grouping = features.grouping;
|
|
5066
|
+
const pagination = features.pagination;
|
|
5067
|
+
const [firstSize, ...otherSizes] = pagination && pagination.pageSizes || [];
|
|
5068
|
+
const modelFeatures = {
|
|
5069
|
+
search: features.search !== false,
|
|
5070
|
+
filtering: features.filtering !== false,
|
|
5071
|
+
sorting: features.sorting !== false,
|
|
5072
|
+
columnVisibility: features.columnVisibility !== false,
|
|
5073
|
+
pagination: pagination ? {
|
|
5074
|
+
...pagination,
|
|
5075
|
+
pageSizes: firstSize === undefined ? undefined : [firstSize, ...otherSizes]
|
|
5076
|
+
} : false
|
|
4004
5077
|
};
|
|
4005
|
-
|
|
4006
|
-
|
|
4007
|
-
|
|
4008
|
-
|
|
4009
|
-
|
|
4010
|
-
|
|
4011
|
-
useLayoutEffect(() => {
|
|
4012
|
-
setStore((store) => {
|
|
4013
|
-
const features = props.features ?? {};
|
|
4014
|
-
const selection = features.selection;
|
|
4015
|
-
const config = {
|
|
4016
|
-
getRowId: selection && selection.getRowId || props.getRowId || undefined,
|
|
4017
|
-
onStateChange: props.onStateChange,
|
|
4018
|
-
onUiStateChange: (state) => setUiState(state),
|
|
4019
|
-
status: props.status ?? {},
|
|
4020
|
-
features,
|
|
4021
|
-
onRowClicked: props.onRowClicked,
|
|
4022
|
-
labels: dataTableMessages(props.locale, props.messages),
|
|
4023
|
-
locale: props.locale ?? "en"
|
|
4024
|
-
};
|
|
4025
|
-
const state = {
|
|
4026
|
-
...store.state,
|
|
4027
|
-
...uiState,
|
|
4028
|
-
...queryFromState(props.state ?? store.state)
|
|
4029
|
-
};
|
|
4030
|
-
const modelChanged = store.rowData !== props.rowData || store.columnDefs !== props.columnDefs || !sameDataTableState(store.state, state) || store.config.getRowId !== config.getRowId || store.config.features.pagination !== config.features.pagination;
|
|
4031
|
-
const next = {
|
|
4032
|
-
...store,
|
|
4033
|
-
rowData: props.rowData,
|
|
4034
|
-
columnDefs: props.columnDefs,
|
|
4035
|
-
config,
|
|
4036
|
-
controlledState: props.state,
|
|
4037
|
-
state
|
|
5078
|
+
if (features.gallery)
|
|
5079
|
+
modelFeatures.gallery = { name: features.gallery.name };
|
|
5080
|
+
if (grouping) {
|
|
5081
|
+
modelFeatures.grouping = {
|
|
5082
|
+
initial: grouping.initial ?? [],
|
|
5083
|
+
fields: grouping.fields.map(({ id }) => ({ id, label: id }))
|
|
4038
5084
|
};
|
|
4039
|
-
|
|
4040
|
-
|
|
5085
|
+
}
|
|
5086
|
+
const input = {
|
|
5087
|
+
label: "",
|
|
5088
|
+
columnDefs: columns,
|
|
5089
|
+
rowData: selection ? props.rowData.map((row, index) => ({
|
|
5090
|
+
id: config.getRowId?.(row) ?? String(index),
|
|
5091
|
+
label: "",
|
|
5092
|
+
cells: {},
|
|
5093
|
+
selectable: selection.isRowSelectable?.(row) ?? true
|
|
5094
|
+
})) : [],
|
|
5095
|
+
features: modelFeatures
|
|
5096
|
+
};
|
|
5097
|
+
if (selection)
|
|
5098
|
+
input.selection = {};
|
|
5099
|
+
if (props.state)
|
|
5100
|
+
input.state = props.state;
|
|
5101
|
+
if (props.initialState)
|
|
5102
|
+
input.initialState = props.initialState;
|
|
5103
|
+
return input;
|
|
4041
5104
|
}, [
|
|
4042
|
-
|
|
4043
|
-
|
|
4044
|
-
props.
|
|
4045
|
-
props.locale,
|
|
4046
|
-
props.messages,
|
|
4047
|
-
props.onRowClicked,
|
|
4048
|
-
props.onStateChange,
|
|
5105
|
+
columns,
|
|
5106
|
+
config,
|
|
5107
|
+
props.initialState,
|
|
4049
5108
|
props.rowData,
|
|
4050
5109
|
props.state,
|
|
4051
|
-
|
|
4052
|
-
setStore,
|
|
4053
|
-
setUiState,
|
|
4054
|
-
uiState
|
|
5110
|
+
selection
|
|
4055
5111
|
]);
|
|
5112
|
+
const { model, send } = useModel(ReactTableModel, modelProps, {
|
|
5113
|
+
onEmit: (event) => {
|
|
5114
|
+
if (event._tag === "StateChanged") {
|
|
5115
|
+
props.onStateChange?.(queryFromState(event.state));
|
|
5116
|
+
} else if (event._tag === "SelectionChanged" && selection) {
|
|
5117
|
+
const selected = new Set(event.selectedRowIds);
|
|
5118
|
+
selection.onSelectionChange?.(props.rowData.filter((_, index) => {
|
|
5119
|
+
const id = modelProps.rowData[index]?.id;
|
|
5120
|
+
return id !== undefined && selected.has(id);
|
|
5121
|
+
}));
|
|
5122
|
+
}
|
|
5123
|
+
}
|
|
5124
|
+
});
|
|
5125
|
+
const [storageKey] = useState(() => tablePreferencesKey(globalThis.window?.location.pathname ?? "/", columns.map(({ id }) => id), !!props.features?.gallery));
|
|
5126
|
+
useEffect(() => {
|
|
5127
|
+
if (!model.preferencesLoaded) {
|
|
5128
|
+
send(DataTableMessage.PreferencesLoaded({
|
|
5129
|
+
preferences: readTablePreferences(storageKey)
|
|
5130
|
+
}));
|
|
5131
|
+
}
|
|
5132
|
+
}, [model, send, storageKey]);
|
|
5133
|
+
const { columnVisibility, columnSizing, grouping, view, preferencesLoaded } = model;
|
|
5134
|
+
const loadedPreferences = useRef(false);
|
|
5135
|
+
useEffect(() => {
|
|
5136
|
+
const preferences = tablePreferences({
|
|
5137
|
+
columnVisibility,
|
|
5138
|
+
columnSizing,
|
|
5139
|
+
grouping,
|
|
5140
|
+
view,
|
|
5141
|
+
preferencesLoaded
|
|
5142
|
+
});
|
|
5143
|
+
if (!preferences)
|
|
5144
|
+
return;
|
|
5145
|
+
if (!loadedPreferences.current) {
|
|
5146
|
+
loadedPreferences.current = true;
|
|
5147
|
+
return;
|
|
5148
|
+
}
|
|
5149
|
+
writeTablePreferences(storageKey, preferences);
|
|
5150
|
+
}, [
|
|
5151
|
+
columnVisibility,
|
|
5152
|
+
columnSizing,
|
|
5153
|
+
grouping,
|
|
5154
|
+
view,
|
|
5155
|
+
preferencesLoaded,
|
|
5156
|
+
storageKey
|
|
5157
|
+
]);
|
|
5158
|
+
const query = modelProps.state ?? model.query;
|
|
5159
|
+
const { collapsedGroups, selectedRowIds } = model;
|
|
5160
|
+
const galleryEnabled = !!props.features?.gallery;
|
|
5161
|
+
const state = useMemo2(() => ({
|
|
5162
|
+
...query,
|
|
5163
|
+
columnVisibility,
|
|
5164
|
+
columnSizing,
|
|
5165
|
+
grouping,
|
|
5166
|
+
view: galleryEnabled ? view : "table",
|
|
5167
|
+
collapsedGroups,
|
|
5168
|
+
rowSelection: Object.fromEntries(selectedRowIds.map((id) => [id, true]))
|
|
5169
|
+
}), [
|
|
5170
|
+
query,
|
|
5171
|
+
columnVisibility,
|
|
5172
|
+
columnSizing,
|
|
5173
|
+
grouping,
|
|
5174
|
+
view,
|
|
5175
|
+
galleryEnabled,
|
|
5176
|
+
collapsedGroups,
|
|
5177
|
+
selectedRowIds
|
|
5178
|
+
]);
|
|
5179
|
+
const store = useMemo2(() => {
|
|
5180
|
+
const source = {
|
|
5181
|
+
rowData: props.rowData,
|
|
5182
|
+
columnDefs: props.columnDefs,
|
|
5183
|
+
config,
|
|
5184
|
+
state
|
|
5185
|
+
};
|
|
5186
|
+
return { ...source, model: buildDataTableModel(source) };
|
|
5187
|
+
}, [props.rowData, props.columnDefs, config, state]);
|
|
5188
|
+
const table = [{ ...store, ui: model }, send];
|
|
5189
|
+
if (!preferencesLoaded)
|
|
5190
|
+
return /* @__PURE__ */ jsx15(TablePlaceholder, {
|
|
5191
|
+
props
|
|
5192
|
+
});
|
|
4056
5193
|
return /* @__PURE__ */ jsxs9("div", {
|
|
4057
5194
|
className: cn("w-full max-w-full min-w-0 rounded-md", getTableLayoutClass(props.features?.virtualization), props.className),
|
|
4058
5195
|
"data-table-root": "",
|
|
4059
5196
|
children: [
|
|
4060
5197
|
/* @__PURE__ */ jsx15(DataTableToolbar, {
|
|
4061
|
-
|
|
5198
|
+
table
|
|
4062
5199
|
}),
|
|
4063
5200
|
/* @__PURE__ */ jsx15(DataTableContent, {
|
|
4064
|
-
|
|
5201
|
+
table
|
|
4065
5202
|
}),
|
|
4066
5203
|
/* @__PURE__ */ jsx15(DataTablePagination, {
|
|
4067
|
-
|
|
5204
|
+
table
|
|
4068
5205
|
})
|
|
4069
5206
|
]
|
|
4070
5207
|
});
|
|
4071
5208
|
};
|
|
5209
|
+
var subscribeToHydration = () => () => {};
|
|
5210
|
+
var clientSnapshot = () => true;
|
|
5211
|
+
var serverSnapshot = () => false;
|
|
5212
|
+
var TablePlaceholder = ({
|
|
5213
|
+
props
|
|
5214
|
+
}) => /* @__PURE__ */ jsx15("div", {
|
|
5215
|
+
"aria-busy": "true",
|
|
5216
|
+
className: cn("invisible w-full max-w-full min-w-0 rounded-md", getTableLayoutClass(props.features?.virtualization), props.className),
|
|
5217
|
+
"data-table-root": ""
|
|
5218
|
+
});
|
|
4072
5219
|
var DataTable = (props) => {
|
|
4073
5220
|
const locale = useKrakstackLocale3(props.locale);
|
|
4074
|
-
const
|
|
4075
|
-
|
|
4076
|
-
|
|
4077
|
-
|
|
4078
|
-
const viewCapability = props.features?.gallery ? "gallery" : "table";
|
|
4079
|
-
return Atom.kvs({
|
|
4080
|
-
mode: "async",
|
|
4081
|
-
runtime: dataTableStorageRuntime,
|
|
4082
|
-
key: `data-table:${pathname}:${columnIds}:${viewCapability}:ui`,
|
|
4083
|
-
schema: DataTablePersistedUiStateSchema,
|
|
4084
|
-
defaultValue: () => ({
|
|
4085
|
-
...persistedUiFromState(DEFAULT_UI_STATE),
|
|
4086
|
-
view: props.features?.gallery ? props.initialState?.view ?? "table" : "table",
|
|
4087
|
-
grouping: props.features?.grouping ? props.features.grouping.initial ?? [] : []
|
|
4088
|
-
})
|
|
5221
|
+
const hydrated = useSyncExternalStore(subscribeToHydration, clientSnapshot, serverSnapshot);
|
|
5222
|
+
if (!hydrated)
|
|
5223
|
+
return /* @__PURE__ */ jsx15(TablePlaceholder, {
|
|
5224
|
+
props
|
|
4089
5225
|
});
|
|
4090
|
-
});
|
|
4091
|
-
const [persistedUiResult, setPersistedUiState] = useAtom(persistedUiAtom);
|
|
4092
|
-
const persistedUiState = useMemo2(() => AsyncResult.isSuccess(persistedUiResult) ? {
|
|
4093
|
-
...persistedUiResult.value,
|
|
4094
|
-
columnVisibility: {
|
|
4095
|
-
...initialColumnVisibility,
|
|
4096
|
-
...persistedUiResult.value.columnVisibility
|
|
4097
|
-
}
|
|
4098
|
-
} : undefined, [initialColumnVisibility, persistedUiResult]);
|
|
4099
|
-
if (!persistedUiState || AsyncResult.isWaiting(persistedUiResult)) {
|
|
4100
|
-
return /* @__PURE__ */ jsx15("div", {
|
|
4101
|
-
"aria-busy": "true",
|
|
4102
|
-
className: cn("invisible w-full max-w-full min-w-0 rounded-md", getTableLayoutClass(props.features?.virtualization), props.className),
|
|
4103
|
-
"data-table-root": ""
|
|
4104
|
-
});
|
|
4105
|
-
}
|
|
4106
5226
|
return /* @__PURE__ */ jsx15(DataTableStylesContext.Provider, {
|
|
4107
5227
|
value: props.classNames,
|
|
4108
|
-
children: /* @__PURE__ */ jsx15(
|
|
4109
|
-
|
|
4110
|
-
|
|
4111
|
-
|
|
4112
|
-
|
|
5228
|
+
children: /* @__PURE__ */ jsx15(DataTableSlotClassesContext.Provider, {
|
|
5229
|
+
value: resolveTableClasses(props.classes),
|
|
5230
|
+
children: /* @__PURE__ */ jsx15(HydratedDataTable, {
|
|
5231
|
+
...props,
|
|
5232
|
+
locale
|
|
5233
|
+
})
|
|
4113
5234
|
})
|
|
4114
5235
|
});
|
|
4115
5236
|
};
|
|
4116
5237
|
var DataTableContent = ({
|
|
4117
|
-
|
|
5238
|
+
table
|
|
4118
5239
|
}) => {
|
|
4119
|
-
const [store] =
|
|
5240
|
+
const [store] = table;
|
|
4120
5241
|
const [scrollElement, setScrollElement] = useState(null);
|
|
4121
5242
|
const [headerHeight, setHeaderHeight] = useState(48);
|
|
4122
5243
|
const [pageTable, setPageTable] = useState(null);
|
|
@@ -4150,7 +5271,7 @@ var DataTableContent = ({
|
|
|
4150
5271
|
}, [scrollElement]);
|
|
4151
5272
|
if (store.config.features.gallery && store.state.view === "gallery") {
|
|
4152
5273
|
return /* @__PURE__ */ jsx15(DataTableGallery, {
|
|
4153
|
-
|
|
5274
|
+
table
|
|
4154
5275
|
});
|
|
4155
5276
|
}
|
|
4156
5277
|
const model = deriveModel(store);
|
|
@@ -4176,10 +5297,10 @@ var DataTableContent = ({
|
|
|
4176
5297
|
style: { width: `max(100%, ${width}px)` },
|
|
4177
5298
|
children: [
|
|
4178
5299
|
/* @__PURE__ */ jsx15(DataTableHeader, {
|
|
4179
|
-
|
|
5300
|
+
table
|
|
4180
5301
|
}),
|
|
4181
5302
|
/* @__PURE__ */ jsx15(DataTableBody, {
|
|
4182
|
-
|
|
5303
|
+
table,
|
|
4183
5304
|
viewport: {
|
|
4184
5305
|
element: null,
|
|
4185
5306
|
headerHeight: 0,
|
|
@@ -4216,10 +5337,10 @@ var DataTableContent = ({
|
|
|
4216
5337
|
children: [
|
|
4217
5338
|
/* @__PURE__ */ jsx15(DataTableHeader, {
|
|
4218
5339
|
sticky: true,
|
|
4219
|
-
|
|
5340
|
+
table
|
|
4220
5341
|
}),
|
|
4221
5342
|
/* @__PURE__ */ jsx15(DataTableBody, {
|
|
4222
|
-
|
|
5343
|
+
table,
|
|
4223
5344
|
viewport: { element: scrollElement, headerHeight, options }
|
|
4224
5345
|
})
|
|
4225
5346
|
]
|
|
@@ -4245,10 +5366,10 @@ var DataTableContent = ({
|
|
|
4245
5366
|
style: { width: `max(100%, ${width}px)` },
|
|
4246
5367
|
children: [
|
|
4247
5368
|
/* @__PURE__ */ jsx15(DataTableHeader, {
|
|
4248
|
-
|
|
5369
|
+
table
|
|
4249
5370
|
}),
|
|
4250
5371
|
/* @__PURE__ */ jsx15(DataTableBody, {
|
|
4251
|
-
|
|
5372
|
+
table
|
|
4252
5373
|
})
|
|
4253
5374
|
]
|
|
4254
5375
|
}),
|
|
@@ -4259,6 +5380,7 @@ var DataTableContent = ({
|
|
|
4259
5380
|
});
|
|
4260
5381
|
};
|
|
4261
5382
|
var DataTableListCell = (props) => {
|
|
5383
|
+
const tableClasses = useContext(DataTableSlotClassesContext);
|
|
4262
5384
|
const locale = useKrakstackLocale3(props.locale);
|
|
4263
5385
|
const resolvedProps = { ...props, locale };
|
|
4264
5386
|
if (resolvedProps.options && (resolvedProps.onAdd || resolvedProps.onRemove)) {
|
|
@@ -4276,7 +5398,7 @@ var DataTableListCell = (props) => {
|
|
|
4276
5398
|
}
|
|
4277
5399
|
const menuLabel = actionsLabel ?? (itemActions?.length ? labels.actions : labels.listDetails);
|
|
4278
5400
|
return /* @__PURE__ */ jsx15("div", {
|
|
4279
|
-
className:
|
|
5401
|
+
className: tableClasses.relationshipCell,
|
|
4280
5402
|
"data-slot": "data-table-list-cell",
|
|
4281
5403
|
onClick: (event) => event.stopPropagation(),
|
|
4282
5404
|
onPointerDown: (event) => event.stopPropagation(),
|
|
@@ -4291,7 +5413,7 @@ var DataTableListCell = (props) => {
|
|
|
4291
5413
|
onItemClick,
|
|
4292
5414
|
trigger: /* @__PURE__ */ jsxs9(Button, {
|
|
4293
5415
|
"aria-label": menuLabel,
|
|
4294
|
-
className:
|
|
5416
|
+
className: tableClasses.relationshipTrigger,
|
|
4295
5417
|
variant: "ghost",
|
|
4296
5418
|
children: [
|
|
4297
5419
|
/* @__PURE__ */ jsx15(DataTableListSummaryContent, {
|
|
@@ -4320,6 +5442,7 @@ var EditableDataTableListCell = ({
|
|
|
4320
5442
|
locale = "en",
|
|
4321
5443
|
messages
|
|
4322
5444
|
}) => {
|
|
5445
|
+
const tableClasses = useContext(DataTableSlotClassesContext);
|
|
4323
5446
|
const [selected, setSelected] = useState([...items]);
|
|
4324
5447
|
const [previousItems, setPreviousItems] = useState(items);
|
|
4325
5448
|
if (previousItems !== items) {
|
|
@@ -4351,7 +5474,7 @@ var EditableDataTableListCell = ({
|
|
|
4351
5474
|
];
|
|
4352
5475
|
return /* @__PURE__ */ jsx15("div", {
|
|
4353
5476
|
"data-slot": "data-table-list-cell",
|
|
4354
|
-
className:
|
|
5477
|
+
className: tableClasses.relationshipCell,
|
|
4355
5478
|
onClick: (event) => event.stopPropagation(),
|
|
4356
5479
|
onPointerDown: (event) => event.stopPropagation(),
|
|
4357
5480
|
children: /* @__PURE__ */ jsx15(DataTableListMenu, {
|
|
@@ -4408,7 +5531,7 @@ var DataTableListMenu = ({
|
|
|
4408
5531
|
trigger
|
|
4409
5532
|
}) => {
|
|
4410
5533
|
const entries = items.map((item) => {
|
|
4411
|
-
const normalized =
|
|
5534
|
+
const normalized = Schema6.is(Schema6.String)(item) ? { label: item } : item;
|
|
4412
5535
|
const visibleActions = actions.filter((action) => action.visible?.(normalized) ?? true);
|
|
4413
5536
|
return { item: normalized, visibleActions };
|
|
4414
5537
|
});
|
|
@@ -4578,7 +5701,7 @@ var DataTableListSummaryContent = ({
|
|
|
4578
5701
|
showMenu,
|
|
4579
5702
|
visibleCount = 3
|
|
4580
5703
|
}) => {
|
|
4581
|
-
const normalized = items.map((item) =>
|
|
5704
|
+
const normalized = items.map((item) => Schema6.is(Schema6.String)(item) ? { label: item } : item);
|
|
4582
5705
|
if (!normalized.length)
|
|
4583
5706
|
return /* @__PURE__ */ jsx15("span", {
|
|
4584
5707
|
className: "text-muted-foreground",
|