@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
package/dist/{services/events/client/audit-log-table.js → components/audit-log-table/react.js}
RENAMED
|
@@ -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,49 +2924,19 @@ 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
|
}
|
|
1701
2937
|
return left.stableIndex - right.stableIndex;
|
|
1702
2938
|
}).map(({ row }) => row);
|
|
1703
2939
|
};
|
|
1704
|
-
var paginateDataTableRows = (rows, pagination) => {
|
|
1705
|
-
const pageSize = Math.max(1, pagination.pageSize);
|
|
1706
|
-
const lastPageIndex = Math.max(0, Math.ceil(rows.length / pageSize) - 1);
|
|
1707
|
-
const pageIndex = Math.min(lastPageIndex, Math.max(0, pagination.page));
|
|
1708
|
-
const start = pageIndex * pageSize;
|
|
1709
|
-
return rows.slice(start, start + pageSize);
|
|
1710
|
-
};
|
|
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
2940
|
var reorderDataTableRows = (rows, sourceRowId, targetRowId) => {
|
|
1713
2941
|
const sourceIndex = rows.findIndex((row) => row.id === sourceRowId);
|
|
1714
2942
|
const targetIndex = rows.findIndex((row) => row.id === targetRowId);
|
|
@@ -1754,7 +2982,7 @@ var clearDragPresentation = (root) => {
|
|
|
1754
2982
|
element.removeAttribute("data-drop-position");
|
|
1755
2983
|
});
|
|
1756
2984
|
};
|
|
1757
|
-
var resolveConfig = (props
|
|
2985
|
+
var resolveConfig = (props) => {
|
|
1758
2986
|
const features = props.features ?? {};
|
|
1759
2987
|
const selection = features.selection;
|
|
1760
2988
|
const getRowId = selection && selection.getRowId || props.getRowId || undefined;
|
|
@@ -1763,8 +2991,6 @@ var resolveConfig = (props, onUiStateChange) => {
|
|
|
1763
2991
|
}
|
|
1764
2992
|
return {
|
|
1765
2993
|
getRowId,
|
|
1766
|
-
onStateChange: props.onStateChange,
|
|
1767
|
-
onUiStateChange,
|
|
1768
2994
|
status: props.status ?? {},
|
|
1769
2995
|
features,
|
|
1770
2996
|
onRowClicked: props.onRowClicked,
|
|
@@ -1779,83 +3005,39 @@ var queryFromState = (state) => ({
|
|
|
1779
3005
|
filters: state.filters,
|
|
1780
3006
|
sort: state.sort
|
|
1781
3007
|
});
|
|
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
3008
|
var buildDataTableModel = (store) => {
|
|
1797
3009
|
const columns = normalizeDataTableColumns(store.columnDefs, store.state.columnSizing);
|
|
1798
3010
|
const selection = store.config.features.selection;
|
|
1799
3011
|
const rowId = selection && selection.getRowId || store.config.getRowId || undefined;
|
|
1800
3012
|
const rows = buildDataTableRows(store.rowData, columns, rowId);
|
|
1801
|
-
const
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
3013
|
+
const page = projectDataTableRows(rows, store.state, {
|
|
3014
|
+
pagination: store.config.features.pagination,
|
|
3015
|
+
grouped: getActiveGrouping(store).length > 0,
|
|
3016
|
+
search: (rows, value) => filterDataTableRows(rows, columns, value, store.config.locale),
|
|
3017
|
+
filter: (rows, filters) => filterDataTableColumnRows(rows, columns, filters),
|
|
3018
|
+
sort: (rows, sorting) => sortDataTableRows(rows, columns, sorting)
|
|
3019
|
+
});
|
|
1807
3020
|
return {
|
|
1808
3021
|
columns,
|
|
1809
3022
|
visibleColumns: columns.filter(({ id }) => store.state.columnVisibility[id] !== false),
|
|
1810
3023
|
rows,
|
|
1811
|
-
filteredRows,
|
|
1812
|
-
sortedRows,
|
|
1813
|
-
pageRows,
|
|
1814
|
-
|
|
1815
|
-
|
|
3024
|
+
filteredRows: page.filtered,
|
|
3025
|
+
sortedRows: page.ordered,
|
|
3026
|
+
pageRows: page.rows,
|
|
3027
|
+
page: page.page,
|
|
3028
|
+
pageCount: page.pageCount,
|
|
3029
|
+
paginationVisible: page.paginationVisible,
|
|
3030
|
+
totalRows: page.totalRows
|
|
1816
3031
|
};
|
|
1817
3032
|
};
|
|
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
3033
|
var deriveModel = (store) => store.model;
|
|
1838
3034
|
var groupDataTableRows = (rows, fields, depth = 0, parentKey = "") => {
|
|
1839
3035
|
const field = fields[0];
|
|
1840
3036
|
if (!field)
|
|
1841
3037
|
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
|
-
});
|
|
3038
|
+
const groups = partitionTableGroups(rows, field.getGroupIds?.() ?? [], (row) => field.getRowGroupIds?.(row.data) ?? [field.getGroupId(row.data)]);
|
|
1856
3039
|
return Array.from(groups, ([groupId, groupRows]) => {
|
|
1857
|
-
const
|
|
1858
|
-
const key = `${parentKey}${parentKey ? "/" : ""}${segment}`;
|
|
3040
|
+
const key = tableGroupKey(parentKey, field.id, groupId);
|
|
1859
3041
|
return {
|
|
1860
3042
|
key,
|
|
1861
3043
|
groupId,
|
|
@@ -1866,15 +3048,9 @@ var groupDataTableRows = (rows, fields, depth = 0, parentKey = "") => {
|
|
|
1866
3048
|
};
|
|
1867
3049
|
});
|
|
1868
3050
|
};
|
|
1869
|
-
var getDataTableSelectableRows = (model, grouped, isRowSelectable) => (grouped ? model.sortedRows : model.pageRows).filter((row) => isRowSelectable?.(row.data) ?? true);
|
|
1870
3051
|
var getActiveGrouping = (store) => {
|
|
1871
3052
|
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
|
-
});
|
|
3053
|
+
return activeTableGroups(store.state.grouping, grouping && grouping.fields || []);
|
|
1878
3054
|
};
|
|
1879
3055
|
var canReorderRows = (store) => {
|
|
1880
3056
|
const pagination = store.config.features.pagination;
|
|
@@ -1911,7 +3087,7 @@ var renderCell = (row, column, locale = "en", labels = dataTableMessages(locale)
|
|
|
1911
3087
|
if (colDef.type === "number") {
|
|
1912
3088
|
if (colDef.valueFormatter)
|
|
1913
3089
|
return colDef.valueFormatter(params);
|
|
1914
|
-
const number =
|
|
3090
|
+
const number = Option4.getOrUndefined(decodeNumberValue(value));
|
|
1915
3091
|
return /* @__PURE__ */ jsx15("span", {
|
|
1916
3092
|
className: "block text-left tabular-nums",
|
|
1917
3093
|
children: number === undefined ? colDef.typeOptions?.emptyLabel ?? "—" : formatNumberValue(number, colDef.typeOptions, locale)
|
|
@@ -1920,7 +3096,7 @@ var renderCell = (row, column, locale = "en", labels = dataTableMessages(locale)
|
|
|
1920
3096
|
if (colDef.type === "boolean") {
|
|
1921
3097
|
if (colDef.valueFormatter)
|
|
1922
3098
|
return colDef.valueFormatter(params);
|
|
1923
|
-
const boolean =
|
|
3099
|
+
const boolean = Option4.getOrUndefined(decodeBooleanValue(value));
|
|
1924
3100
|
if (boolean === undefined)
|
|
1925
3101
|
return colDef.typeOptions?.emptyLabel ?? "—";
|
|
1926
3102
|
const options = colDef.typeOptions;
|
|
@@ -1983,37 +3159,25 @@ var renderCell = (row, column, locale = "en", labels = dataTableMessages(locale)
|
|
|
1983
3159
|
return column.colDef.valueFormatter?.(params) ?? (value === null || value === undefined ? null : dataTableValueText(value));
|
|
1984
3160
|
};
|
|
1985
3161
|
var nodeText = (node) => {
|
|
1986
|
-
if (
|
|
3162
|
+
if (Schema6.is(Schema6.String)(node) || Schema6.is(Schema6.Finite)(node))
|
|
1987
3163
|
return String(node);
|
|
1988
3164
|
if (!isValidElement(node))
|
|
1989
3165
|
return "";
|
|
1990
|
-
if (
|
|
3166
|
+
if (Schema6.is(Schema6.String)(node.props.title))
|
|
1991
3167
|
return node.props.title;
|
|
1992
3168
|
return nodeText(node.props.children);
|
|
1993
3169
|
};
|
|
1994
3170
|
var columnLabel = (column) => nodeText(column.colDef.headerName) || column.id;
|
|
1995
|
-
var withExtension = (fileName, extension) => fileName.includes(".") ? fileName.replace(/\.[^/.]+$/, `.${extension}`) : `${fileName}.${extension}`;
|
|
1996
3171
|
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));
|
|
3172
|
+
downloadTableBlob(encodeTableCsv(headers, data), "text/csv;charset=utf-8", tableExportFilename(fileName, "csv"));
|
|
2011
3173
|
};
|
|
3174
|
+
var downloadJson = (data, fileName = "data.json") => downloadTableBlob(JSON.stringify(data, null, 2), "application/json;charset=utf-8", tableExportFilename(fileName, "json"));
|
|
2012
3175
|
var DataTableRowActions = ({
|
|
2013
3176
|
actions,
|
|
2014
3177
|
row,
|
|
2015
3178
|
title
|
|
2016
3179
|
}) => {
|
|
3180
|
+
const tableClasses = useContext(DataTableSlotClassesContext);
|
|
2017
3181
|
const visible = actions.filter((action) => !action.visible || action.visible(row));
|
|
2018
3182
|
if (!visible.length)
|
|
2019
3183
|
return null;
|
|
@@ -2022,7 +3186,7 @@ var DataTableRowActions = ({
|
|
|
2022
3186
|
/* @__PURE__ */ jsx15(DropdownMenuTrigger2, {
|
|
2023
3187
|
onClick: (event) => event.stopPropagation(),
|
|
2024
3188
|
render: /* @__PURE__ */ jsxs9(Button, {
|
|
2025
|
-
className: "
|
|
3189
|
+
className: cn(tableClasses.actionTrigger, "[&_svg:not([class*='size-'])]:size-4"),
|
|
2026
3190
|
size: "icon",
|
|
2027
3191
|
variant: "ghost",
|
|
2028
3192
|
children: [
|
|
@@ -2061,10 +3225,10 @@ var DataTableRowActions = ({
|
|
|
2061
3225
|
});
|
|
2062
3226
|
};
|
|
2063
3227
|
var DataTableRowActionMenu = ({
|
|
2064
|
-
|
|
3228
|
+
table,
|
|
2065
3229
|
row
|
|
2066
3230
|
}) => {
|
|
2067
|
-
const [store] =
|
|
3231
|
+
const [store] = table;
|
|
2068
3232
|
const rowId = row.id;
|
|
2069
3233
|
const rowActions = store.config.features.rowActions || undefined;
|
|
2070
3234
|
const reordering = store.config.features.reordering;
|
|
@@ -2098,12 +3262,12 @@ var DataTableRowActionMenu = ({
|
|
|
2098
3262
|
});
|
|
2099
3263
|
};
|
|
2100
3264
|
var DataTableToolbar = ({
|
|
2101
|
-
|
|
3265
|
+
table
|
|
2102
3266
|
}) => {
|
|
2103
|
-
const
|
|
3267
|
+
const tableClasses = useContext(DataTableSlotClassesContext);
|
|
3268
|
+
const [store, send] = table;
|
|
2104
3269
|
const exportPending = useRef(false);
|
|
2105
|
-
const
|
|
2106
|
-
const [exportFailed, setExportFailed] = useState(false);
|
|
3270
|
+
const { exporting, exportFailed } = store.ui;
|
|
2107
3271
|
const { features, labels } = store.config;
|
|
2108
3272
|
const model = deriveModel(store);
|
|
2109
3273
|
const selectedRows = getSelectedRows(store, model);
|
|
@@ -2113,7 +3277,6 @@ var DataTableToolbar = ({
|
|
|
2113
3277
|
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
3278
|
if (!hasToolbar)
|
|
2115
3279
|
return null;
|
|
2116
|
-
const update = (next) => changeState(setStore, next);
|
|
2117
3280
|
const visibleBulkActions = bulkActions ? bulkActions.items.filter((action) => !action.visible || action.visible(selectedRows)) : [];
|
|
2118
3281
|
const exportRows = features.export && features.export.scope === "currentPage" ? model.pageRows : model.sortedRows;
|
|
2119
3282
|
const exportColumns = getDataTableExportColumns(model.visibleColumns);
|
|
@@ -2125,46 +3288,38 @@ var DataTableToolbar = ({
|
|
|
2125
3288
|
if (exportPending.current || action.disabled)
|
|
2126
3289
|
return;
|
|
2127
3290
|
exportPending.current = true;
|
|
2128
|
-
|
|
2129
|
-
|
|
3291
|
+
send(DataTableMessage.ExportStarted());
|
|
3292
|
+
let failed = false;
|
|
2130
3293
|
try {
|
|
2131
3294
|
await action.onExport();
|
|
2132
3295
|
} catch (error) {
|
|
2133
|
-
|
|
3296
|
+
failed = true;
|
|
2134
3297
|
if (exportFeature)
|
|
2135
3298
|
exportFeature.onError?.(error, action);
|
|
2136
3299
|
} finally {
|
|
2137
3300
|
exportPending.current = false;
|
|
2138
|
-
|
|
3301
|
+
send(DataTableMessage.ExportFinished({ failed }));
|
|
2139
3302
|
}
|
|
2140
3303
|
};
|
|
2141
3304
|
return /* @__PURE__ */ jsxs9("div", {
|
|
2142
|
-
className: cn("
|
|
3305
|
+
className: cn(tableClasses.toolbar, "pb-4"),
|
|
2143
3306
|
children: [
|
|
2144
3307
|
features.search !== false ? /* @__PURE__ */ jsxs9("div", {
|
|
2145
|
-
className:
|
|
3308
|
+
className: tableClasses.toolbarSearch,
|
|
2146
3309
|
children: [
|
|
2147
3310
|
/* @__PURE__ */ jsx15(Search, {
|
|
2148
3311
|
className: "text-muted-foreground pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2"
|
|
2149
3312
|
}),
|
|
2150
3313
|
/* @__PURE__ */ jsx15(Input2, {
|
|
2151
3314
|
className: "px-9",
|
|
2152
|
-
onChange: (event) =>
|
|
2153
|
-
...state,
|
|
2154
|
-
globalFilter: event.target.value,
|
|
2155
|
-
page: 0
|
|
2156
|
-
})),
|
|
3315
|
+
onChange: (event) => send(DataTableMessage.SearchChanged({ value: event.target.value })),
|
|
2157
3316
|
placeholder: labels.filter,
|
|
2158
3317
|
value: store.state.globalFilter ?? ""
|
|
2159
3318
|
}),
|
|
2160
3319
|
store.state.globalFilter ? /* @__PURE__ */ jsx15(Button, {
|
|
2161
3320
|
"aria-label": labels.filter,
|
|
2162
3321
|
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
|
-
})),
|
|
3322
|
+
onClick: () => send(DataTableMessage.SearchChanged({ value: "" })),
|
|
2168
3323
|
size: "icon",
|
|
2169
3324
|
variant: "ghost",
|
|
2170
3325
|
children: /* @__PURE__ */ jsx15(X, {})
|
|
@@ -2172,19 +3327,19 @@ var DataTableToolbar = ({
|
|
|
2172
3327
|
]
|
|
2173
3328
|
}) : null,
|
|
2174
3329
|
/* @__PURE__ */ jsx15("div", {
|
|
2175
|
-
className:
|
|
3330
|
+
className: tableClasses.toolbarMenus,
|
|
2176
3331
|
children: /* @__PURE__ */ jsxs9(Menubar2, {
|
|
2177
3332
|
modal: false,
|
|
2178
|
-
className: "
|
|
3333
|
+
className: cn(tableClasses.menubar, "[&_[data-slot=menubar-trigger]]:gap-2 [&_[data-slot=menubar-trigger]_svg]:size-4"),
|
|
2179
3334
|
children: [
|
|
2180
3335
|
visibleBulkActions.length ? /* @__PURE__ */ jsxs9(MenubarMenu, {
|
|
2181
3336
|
children: [
|
|
2182
3337
|
/* @__PURE__ */ jsxs9(MenubarTrigger2, {
|
|
2183
|
-
className: "
|
|
3338
|
+
className: cn(tableClasses.selectedTrigger, "aria-expanded:bg-primary/90"),
|
|
2184
3339
|
children: [
|
|
2185
3340
|
labels.selected,
|
|
2186
|
-
/* @__PURE__ */ jsx15(
|
|
2187
|
-
|
|
3341
|
+
/* @__PURE__ */ jsx15("span", {
|
|
3342
|
+
className: tableClasses.count,
|
|
2188
3343
|
children: selectedRows.length
|
|
2189
3344
|
}),
|
|
2190
3345
|
/* @__PURE__ */ jsx15(ChevronDown, {})
|
|
@@ -2214,7 +3369,7 @@ var DataTableToolbar = ({
|
|
|
2214
3369
|
}) : null,
|
|
2215
3370
|
toolbar && toolbar.items,
|
|
2216
3371
|
features.filtering !== false ? /* @__PURE__ */ jsx15(FilterMenu, {
|
|
2217
|
-
|
|
3372
|
+
table
|
|
2218
3373
|
}) : null,
|
|
2219
3374
|
grouping ? /* @__PURE__ */ jsxs9(MenubarMenu, {
|
|
2220
3375
|
children: [
|
|
@@ -2238,10 +3393,7 @@ var DataTableToolbar = ({
|
|
|
2238
3393
|
/* @__PURE__ */ jsx15(MenubarSeparator2, {}),
|
|
2239
3394
|
grouping.fields.map((field) => /* @__PURE__ */ jsx15(MenubarCheckboxItem2, {
|
|
2240
3395
|
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
|
-
})),
|
|
3396
|
+
onCheckedChange: () => send(DataTableMessage.GroupingToggled({ fieldId: field.id })),
|
|
2245
3397
|
children: field.label
|
|
2246
3398
|
}, field.id))
|
|
2247
3399
|
]
|
|
@@ -2250,13 +3402,13 @@ var DataTableToolbar = ({
|
|
|
2250
3402
|
]
|
|
2251
3403
|
}) : null,
|
|
2252
3404
|
features.sorting !== false ? /* @__PURE__ */ jsx15(SortMenu, {
|
|
2253
|
-
|
|
3405
|
+
table
|
|
2254
3406
|
}) : null,
|
|
2255
3407
|
features.gallery ? /* @__PURE__ */ jsx15(ViewMenu, {
|
|
2256
|
-
|
|
3408
|
+
table
|
|
2257
3409
|
}) : null,
|
|
2258
3410
|
features.columnVisibility !== false ? /* @__PURE__ */ jsx15(ColumnMenu, {
|
|
2259
|
-
|
|
3411
|
+
table
|
|
2260
3412
|
}) : null,
|
|
2261
3413
|
features.refresh ? /* @__PURE__ */ jsx15(MenubarMenu, {
|
|
2262
3414
|
children: /* @__PURE__ */ jsxs9(MenubarTrigger2, {
|
|
@@ -2337,18 +3489,12 @@ var DataTableToolbar = ({
|
|
|
2337
3489
|
}),
|
|
2338
3490
|
exportFeature && exportFailed ? /* @__PURE__ */ jsx15("p", {
|
|
2339
3491
|
role: "alert",
|
|
2340
|
-
className: "text-destructive
|
|
3492
|
+
className: "text-destructive basis-full text-sm",
|
|
2341
3493
|
children: labels.exportFailed ?? dataTableMessages(store.config.locale).exportFailed
|
|
2342
3494
|
}) : null
|
|
2343
3495
|
]
|
|
2344
3496
|
});
|
|
2345
3497
|
};
|
|
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
3498
|
var FilterEditor = ({
|
|
2353
3499
|
column,
|
|
2354
3500
|
rows,
|
|
@@ -2358,9 +3504,8 @@ var FilterEditor = ({
|
|
|
2358
3504
|
}) => {
|
|
2359
3505
|
const inputId = useId2();
|
|
2360
3506
|
const kind = getDataTableFilterKind(column);
|
|
2361
|
-
const [
|
|
2362
|
-
const
|
|
2363
|
-
const [operator, setOperator] = useState(current?.kind === "text" ? current.operator : "contains");
|
|
3507
|
+
const [draft, setDraft] = useState(() => tableFilterDraft(column.id, current));
|
|
3508
|
+
const { primary, secondary, operator } = draft;
|
|
2364
3509
|
const operatorOptions = [
|
|
2365
3510
|
{ value: "contains", label: labels.filterContains },
|
|
2366
3511
|
{ value: "equals", label: labels.filterEquals },
|
|
@@ -2370,8 +3515,8 @@ var FilterEditor = ({
|
|
|
2370
3515
|
const [invalid, setInvalid] = useState(false);
|
|
2371
3516
|
const [optionSearch, setOptionSearch] = useState("");
|
|
2372
3517
|
const apply = (candidate) => {
|
|
2373
|
-
const decoded =
|
|
2374
|
-
if (
|
|
3518
|
+
const decoded = parseTableFilterDraft(kind, candidate);
|
|
3519
|
+
if (Option4.isNone(decoded)) {
|
|
2375
3520
|
setInvalid(true);
|
|
2376
3521
|
return;
|
|
2377
3522
|
}
|
|
@@ -2383,7 +3528,7 @@ var FilterEditor = ({
|
|
|
2383
3528
|
children: [
|
|
2384
3529
|
/* @__PURE__ */ jsxs9(MenubarRadioGroup, {
|
|
2385
3530
|
value: current?.kind === "boolean" ? String(current.value) : "",
|
|
2386
|
-
onValueChange: (value) => apply({
|
|
3531
|
+
onValueChange: (value) => apply({ ...draft, primary: value }),
|
|
2387
3532
|
children: [
|
|
2388
3533
|
/* @__PURE__ */ jsx15(MenubarRadioItem2, {
|
|
2389
3534
|
value: "true",
|
|
@@ -2429,9 +3574,9 @@ var FilterEditor = ({
|
|
|
2429
3574
|
checked: selected.includes(option.value),
|
|
2430
3575
|
closeOnClick: false,
|
|
2431
3576
|
onCheckedChange: (checked) => {
|
|
2432
|
-
const values =
|
|
3577
|
+
const values = updateSelectedRows(selected, [option.value], checked);
|
|
2433
3578
|
if (values.length)
|
|
2434
|
-
apply({
|
|
3579
|
+
apply({ ...draft, values });
|
|
2435
3580
|
else
|
|
2436
3581
|
onChange(undefined);
|
|
2437
3582
|
},
|
|
@@ -2468,29 +3613,7 @@ var FilterEditor = ({
|
|
|
2468
3613
|
},
|
|
2469
3614
|
onSubmit: (event) => {
|
|
2470
3615
|
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
|
-
}
|
|
3616
|
+
apply(draft);
|
|
2494
3617
|
},
|
|
2495
3618
|
children: [
|
|
2496
3619
|
/* @__PURE__ */ jsxs9(FieldGroup, {
|
|
@@ -2505,9 +3628,9 @@ var FilterEditor = ({
|
|
|
2505
3628
|
items: operatorOptions,
|
|
2506
3629
|
value: operator,
|
|
2507
3630
|
onValueChange: (value) => {
|
|
2508
|
-
const decoded =
|
|
2509
|
-
if (
|
|
2510
|
-
|
|
3631
|
+
const decoded = Schema6.decodeUnknownOption(TextFilterOperator)(value);
|
|
3632
|
+
if (Option4.isSome(decoded))
|
|
3633
|
+
setDraft({ ...draft, operator: decoded.value });
|
|
2511
3634
|
},
|
|
2512
3635
|
children: [
|
|
2513
3636
|
/* @__PURE__ */ jsx15(SelectTrigger, {
|
|
@@ -2540,7 +3663,7 @@ var FilterEditor = ({
|
|
|
2540
3663
|
value: primary,
|
|
2541
3664
|
"aria-invalid": invalid || undefined,
|
|
2542
3665
|
onChange: (event) => {
|
|
2543
|
-
|
|
3666
|
+
setDraft({ ...draft, primary: event.target.value });
|
|
2544
3667
|
setInvalid(false);
|
|
2545
3668
|
}
|
|
2546
3669
|
})
|
|
@@ -2560,7 +3683,7 @@ var FilterEditor = ({
|
|
|
2560
3683
|
value: secondary,
|
|
2561
3684
|
"aria-invalid": invalid || undefined,
|
|
2562
3685
|
onChange: (event) => {
|
|
2563
|
-
|
|
3686
|
+
setDraft({ ...draft, secondary: event.target.value });
|
|
2564
3687
|
setInvalid(false);
|
|
2565
3688
|
}
|
|
2566
3689
|
})
|
|
@@ -2586,8 +3709,7 @@ var FilterEditor = ({
|
|
|
2586
3709
|
size: "sm",
|
|
2587
3710
|
variant: "outline",
|
|
2588
3711
|
onClick: () => {
|
|
2589
|
-
|
|
2590
|
-
setSecondary("");
|
|
3712
|
+
setDraft({ ...draft, primary: "", secondary: "" });
|
|
2591
3713
|
setInvalid(false);
|
|
2592
3714
|
onChange(undefined);
|
|
2593
3715
|
},
|
|
@@ -2599,9 +3721,9 @@ var FilterEditor = ({
|
|
|
2599
3721
|
});
|
|
2600
3722
|
};
|
|
2601
3723
|
var FilterMenu = ({
|
|
2602
|
-
|
|
3724
|
+
table
|
|
2603
3725
|
}) => {
|
|
2604
|
-
const [store,
|
|
3726
|
+
const [store, send] = table;
|
|
2605
3727
|
const model = deriveModel(store);
|
|
2606
3728
|
const columns = model.columns.flatMap((parent) => getDataTableFilterColumns([parent]).map((column) => ({
|
|
2607
3729
|
column,
|
|
@@ -2610,7 +3732,7 @@ var FilterMenu = ({
|
|
|
2610
3732
|
if (!columns.length)
|
|
2611
3733
|
return null;
|
|
2612
3734
|
const filters = store.state.filters ?? [];
|
|
2613
|
-
const update = (id, filter) =>
|
|
3735
|
+
const update = (id, filter) => send(DataTableMessage.ColumnFilterChanged({ id, filter: filter ?? null }));
|
|
2614
3736
|
return /* @__PURE__ */ jsxs9(MenubarMenu, {
|
|
2615
3737
|
children: [
|
|
2616
3738
|
/* @__PURE__ */ jsxs9(MenubarTrigger2, {
|
|
@@ -2663,11 +3785,7 @@ var FilterMenu = ({
|
|
|
2663
3785
|
children: [
|
|
2664
3786
|
/* @__PURE__ */ jsx15(MenubarSeparator2, {}),
|
|
2665
3787
|
/* @__PURE__ */ jsxs9(MenubarItem2, {
|
|
2666
|
-
onClick: () =>
|
|
2667
|
-
...state,
|
|
2668
|
-
page: 0,
|
|
2669
|
-
filters: undefined
|
|
2670
|
-
})),
|
|
3788
|
+
onClick: () => send(DataTableMessage.FiltersCleared()),
|
|
2671
3789
|
children: [
|
|
2672
3790
|
/* @__PURE__ */ jsx15(X, {}),
|
|
2673
3791
|
store.config.labels.filtersClear
|
|
@@ -2682,9 +3800,9 @@ var FilterMenu = ({
|
|
|
2682
3800
|
});
|
|
2683
3801
|
};
|
|
2684
3802
|
var SortMenu = ({
|
|
2685
|
-
|
|
3803
|
+
table
|
|
2686
3804
|
}) => {
|
|
2687
|
-
const [store,
|
|
3805
|
+
const [store, send] = table;
|
|
2688
3806
|
const columns = deriveModel(store).columns.flatMap((column) => getDataTableSortColumns([column]).map((field) => field.id === column.id ? field : {
|
|
2689
3807
|
...field,
|
|
2690
3808
|
colDef: {
|
|
@@ -2695,11 +3813,7 @@ var SortMenu = ({
|
|
|
2695
3813
|
if (!columns.length)
|
|
2696
3814
|
return null;
|
|
2697
3815
|
const current = store.state.sort?.[0];
|
|
2698
|
-
const sort = (id, direction) =>
|
|
2699
|
-
...state,
|
|
2700
|
-
sort: [{ id, direction }],
|
|
2701
|
-
page: 0
|
|
2702
|
-
}));
|
|
3816
|
+
const sort = (id, direction) => send(DataTableMessage.SortRequested({ columnId: id, direction }));
|
|
2703
3817
|
return /* @__PURE__ */ jsxs9(MenubarMenu, {
|
|
2704
3818
|
children: [
|
|
2705
3819
|
/* @__PURE__ */ jsxs9(MenubarTrigger2, {
|
|
@@ -2753,9 +3867,9 @@ var SortMenu = ({
|
|
|
2753
3867
|
children: [
|
|
2754
3868
|
/* @__PURE__ */ jsx15(MenubarSeparator2, {}),
|
|
2755
3869
|
/* @__PURE__ */ jsxs9(MenubarItem2, {
|
|
2756
|
-
onClick: () =>
|
|
2757
|
-
|
|
2758
|
-
|
|
3870
|
+
onClick: () => send(DataTableMessage.SortRequested({
|
|
3871
|
+
columnId: column.id,
|
|
3872
|
+
direction: null
|
|
2759
3873
|
})),
|
|
2760
3874
|
children: [
|
|
2761
3875
|
/* @__PURE__ */ jsx15(X, {}),
|
|
@@ -2777,9 +3891,9 @@ var SortMenu = ({
|
|
|
2777
3891
|
});
|
|
2778
3892
|
};
|
|
2779
3893
|
var ViewMenu = ({
|
|
2780
|
-
|
|
3894
|
+
table
|
|
2781
3895
|
}) => {
|
|
2782
|
-
const [store,
|
|
3896
|
+
const [store, send] = table;
|
|
2783
3897
|
return /* @__PURE__ */ jsxs9(MenubarMenu, {
|
|
2784
3898
|
children: [
|
|
2785
3899
|
/* @__PURE__ */ jsxs9(MenubarTrigger2, {
|
|
@@ -2802,12 +3916,9 @@ var ViewMenu = ({
|
|
|
2802
3916
|
/* @__PURE__ */ jsx15(MenubarSeparator2, {}),
|
|
2803
3917
|
/* @__PURE__ */ jsxs9(MenubarRadioGroup, {
|
|
2804
3918
|
onValueChange: (input) => {
|
|
2805
|
-
const view =
|
|
2806
|
-
if (
|
|
2807
|
-
|
|
2808
|
-
...state,
|
|
2809
|
-
view: view.value
|
|
2810
|
-
}));
|
|
3919
|
+
const view = Schema6.decodeUnknownOption(DataTableViewSchema)(input);
|
|
3920
|
+
if (Option4.isSome(view)) {
|
|
3921
|
+
send(DataTableMessage.ViewPicked({ view: view.value }));
|
|
2811
3922
|
}
|
|
2812
3923
|
},
|
|
2813
3924
|
value: store.state.view,
|
|
@@ -2837,9 +3948,9 @@ var ViewMenu = ({
|
|
|
2837
3948
|
});
|
|
2838
3949
|
};
|
|
2839
3950
|
var ColumnMenu = ({
|
|
2840
|
-
|
|
3951
|
+
table
|
|
2841
3952
|
}) => {
|
|
2842
|
-
const [store,
|
|
3953
|
+
const [store, send] = table;
|
|
2843
3954
|
const columns = deriveModel(store).columns.filter(({ colDef }) => colDef.hideable !== false);
|
|
2844
3955
|
if (!columns.length)
|
|
2845
3956
|
return null;
|
|
@@ -2865,13 +3976,7 @@ var ColumnMenu = ({
|
|
|
2865
3976
|
/* @__PURE__ */ jsx15(MenubarSeparator2, {}),
|
|
2866
3977
|
columns.map((column) => /* @__PURE__ */ jsx15(MenubarCheckboxItem2, {
|
|
2867
3978
|
checked: store.state.columnVisibility[column.id] !== false,
|
|
2868
|
-
onCheckedChange: (visible) =>
|
|
2869
|
-
...state,
|
|
2870
|
-
columnVisibility: {
|
|
2871
|
-
...state.columnVisibility,
|
|
2872
|
-
[column.id]: visible
|
|
2873
|
-
}
|
|
2874
|
-
})),
|
|
3979
|
+
onCheckedChange: (visible) => send(DataTableMessage.ColumnVisibilityChanged({ id: column.id, visible })),
|
|
2875
3980
|
children: columnLabel(column)
|
|
2876
3981
|
}, column.id))
|
|
2877
3982
|
]
|
|
@@ -2881,54 +3986,43 @@ var ColumnMenu = ({
|
|
|
2881
3986
|
});
|
|
2882
3987
|
};
|
|
2883
3988
|
var ResizeHandle = ({
|
|
2884
|
-
|
|
3989
|
+
table
|
|
2885
3990
|
}) => {
|
|
2886
|
-
const
|
|
3991
|
+
const tableClasses = useContext(DataTableSlotClassesContext);
|
|
3992
|
+
const [store, send] = table;
|
|
2887
3993
|
const columnId = useRequiredId(ColumnIdContext);
|
|
2888
|
-
const resizeRef = useRef(null);
|
|
2889
3994
|
const column = deriveModel(store).columns.find(({ id }) => id === columnId);
|
|
2890
3995
|
if (!column || column.colDef.resizable === false)
|
|
2891
3996
|
return null;
|
|
2892
|
-
const
|
|
2893
|
-
...state,
|
|
2894
|
-
columnSizing: {
|
|
2895
|
-
...state.columnSizing,
|
|
2896
|
-
[column.id]: clampWidth(column.colDef, width)
|
|
2897
|
-
}
|
|
2898
|
-
}));
|
|
3997
|
+
const { min, max } = tableColumnLimits(column.colDef);
|
|
2899
3998
|
const onPointerDown = (event) => {
|
|
2900
3999
|
if (event.button !== 0)
|
|
2901
4000
|
return;
|
|
2902
4001
|
event.preventDefault();
|
|
2903
4002
|
event.currentTarget.setPointerCapture(event.pointerId);
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
};
|
|
4003
|
+
send(DataTableMessage.ResizeStarted({
|
|
4004
|
+
id: column.id,
|
|
4005
|
+
x: event.clientX,
|
|
4006
|
+
pointerId: event.pointerId
|
|
4007
|
+
}));
|
|
2909
4008
|
};
|
|
2910
4009
|
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;
|
|
4010
|
+
send(DataTableMessage.ResizeMoved({ x: event.clientX, pointerId: event.pointerId }));
|
|
2918
4011
|
};
|
|
4012
|
+
const reset = (event) => send(DataTableMessage.ResizeEnded({ pointerId: event.pointerId }));
|
|
2919
4013
|
return /* @__PURE__ */ jsx15("button", {
|
|
2920
4014
|
"aria-label": store.config.labels.resizeColumn(columnLabel(column)),
|
|
2921
4015
|
"aria-orientation": "vertical",
|
|
2922
|
-
"aria-valuemax":
|
|
2923
|
-
"aria-valuemin":
|
|
4016
|
+
"aria-valuemax": max,
|
|
4017
|
+
"aria-valuemin": min,
|
|
2924
4018
|
"aria-valuenow": column.width,
|
|
2925
|
-
className:
|
|
2926
|
-
onDoubleClick: () =>
|
|
4019
|
+
className: tableClasses.resizeHandle,
|
|
4020
|
+
onDoubleClick: () => send(DataTableMessage.ColumnResizeReset({ id: column.id })),
|
|
2927
4021
|
onKeyDown: (event) => {
|
|
2928
|
-
const delta = event.key
|
|
4022
|
+
const delta = tableResizeStep(event.key);
|
|
2929
4023
|
if (delta) {
|
|
2930
4024
|
event.preventDefault();
|
|
2931
|
-
|
|
4025
|
+
send(DataTableMessage.ColumnResized({ id: column.id, delta }));
|
|
2932
4026
|
}
|
|
2933
4027
|
},
|
|
2934
4028
|
onPointerDown,
|
|
@@ -2941,9 +4035,9 @@ var ResizeHandle = ({
|
|
|
2941
4035
|
});
|
|
2942
4036
|
};
|
|
2943
4037
|
var DragHandle = ({
|
|
2944
|
-
|
|
4038
|
+
table
|
|
2945
4039
|
}) => {
|
|
2946
|
-
const [store
|
|
4040
|
+
const [store] = table;
|
|
2947
4041
|
const rowId = useRequiredId(RowIdContext);
|
|
2948
4042
|
const dragRef = useRef(null);
|
|
2949
4043
|
const [overlay, setOverlay] = useState(null);
|
|
@@ -3001,7 +4095,8 @@ var DragHandle = ({
|
|
|
3001
4095
|
const elements = document.elementsFromPoint(event.clientX, event.clientY);
|
|
3002
4096
|
const rowTarget = findTableDragTarget(elements, "[data-table-row]", root);
|
|
3003
4097
|
const groupTarget = findTableDragTarget(elements, "[data-table-group]", root);
|
|
3004
|
-
|
|
4098
|
+
if (drag.active) {
|
|
4099
|
+
const current = store;
|
|
3005
4100
|
const targetRowId = rowTarget?.dataset.tableRow;
|
|
3006
4101
|
const targetGroupKey = groupTarget?.dataset.tableGroup;
|
|
3007
4102
|
const model = deriveModel(current);
|
|
@@ -3017,8 +4112,7 @@ var DragHandle = ({
|
|
|
3017
4112
|
} else if (drag.active && source && targetRowId && reordering && canReorderRows(current) && source.id !== targetRowId) {
|
|
3018
4113
|
reordering.onReorder(reorderDataTableRows(model.rows, source.id, targetRowId));
|
|
3019
4114
|
}
|
|
3020
|
-
|
|
3021
|
-
});
|
|
4115
|
+
}
|
|
3022
4116
|
reset(event.currentTarget);
|
|
3023
4117
|
};
|
|
3024
4118
|
const cancel = (event) => {
|
|
@@ -3069,22 +4163,15 @@ var DragHandle = ({
|
|
|
3069
4163
|
]
|
|
3070
4164
|
});
|
|
3071
4165
|
};
|
|
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
|
-
});
|
|
4166
|
+
var toggleRow = (send, rowId, checked) => send(DataTableMessage.SelectionRequested({ rowIds: [rowId], checked }));
|
|
3081
4167
|
var TableDataRow = ({
|
|
3082
|
-
|
|
4168
|
+
table,
|
|
3083
4169
|
row,
|
|
3084
4170
|
virtualIndex,
|
|
3085
4171
|
measureRef
|
|
3086
4172
|
}) => {
|
|
3087
|
-
const
|
|
4173
|
+
const tableClasses = useContext(DataTableSlotClassesContext);
|
|
4174
|
+
const [store, send] = table;
|
|
3088
4175
|
const model = deriveModel(store);
|
|
3089
4176
|
const selection = store.config.features.selection;
|
|
3090
4177
|
const selectable = !!selection && (selection.isRowSelectable?.(row.data) ?? true);
|
|
@@ -3106,37 +4193,40 @@ var TableDataRow = ({
|
|
|
3106
4193
|
tabIndex: store.config.onRowClicked ? 0 : undefined,
|
|
3107
4194
|
children: [
|
|
3108
4195
|
selection ? /* @__PURE__ */ jsx15(TableCell2, {
|
|
3109
|
-
className:
|
|
4196
|
+
className: tableClasses.selectionCell,
|
|
3110
4197
|
onClick: (event) => event.stopPropagation(),
|
|
3111
|
-
children: /* @__PURE__ */ jsx15(
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
4198
|
+
children: /* @__PURE__ */ jsx15("div", {
|
|
4199
|
+
className: tableClasses.selectionCenter,
|
|
4200
|
+
children: /* @__PURE__ */ jsx15(Checkbox, {
|
|
4201
|
+
"aria-label": store.config.labels.selectRow,
|
|
4202
|
+
checked: !!store.state.rowSelection[row.id],
|
|
4203
|
+
disabled: !selectable,
|
|
4204
|
+
onCheckedChange: (checked) => toggleRow(send, row.id, checked)
|
|
4205
|
+
})
|
|
3116
4206
|
})
|
|
3117
4207
|
}) : null,
|
|
3118
4208
|
draggable ? /* @__PURE__ */ jsx15(TableCell2, {
|
|
3119
4209
|
className: "w-10 pr-0",
|
|
3120
4210
|
children: /* @__PURE__ */ jsx15(DragHandle, {
|
|
3121
|
-
|
|
4211
|
+
table
|
|
3122
4212
|
})
|
|
3123
4213
|
}) : null,
|
|
3124
4214
|
model.visibleColumns.map((column) => /* @__PURE__ */ jsx15(TableCell2, {
|
|
3125
|
-
className: cn("min-w-24
|
|
4215
|
+
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
4216
|
style: { width: column.width },
|
|
3127
4217
|
children: /* @__PURE__ */ jsx15("div", {
|
|
3128
|
-
className: cn(
|
|
4218
|
+
className: cn(tableClasses.cellContent, column.colDef.truncate && "truncate"),
|
|
3129
4219
|
children: renderCell(row, column, store.config.locale, store.config.labels)
|
|
3130
4220
|
})
|
|
3131
4221
|
}, column.id)),
|
|
3132
4222
|
hasRowActionMenu(store) ? /* @__PURE__ */ jsx15(TableCell2, {
|
|
3133
|
-
className: "
|
|
4223
|
+
className: cn(tableClasses.actionsCell, "group-data-[state=selected]/row:bg-muted"),
|
|
3134
4224
|
onClick: (event) => event.stopPropagation(),
|
|
3135
4225
|
children: /* @__PURE__ */ jsx15("div", {
|
|
3136
|
-
className:
|
|
4226
|
+
className: tableClasses.actionsAlign,
|
|
3137
4227
|
children: /* @__PURE__ */ jsx15(DataTableRowActionMenu, {
|
|
3138
4228
|
row,
|
|
3139
|
-
|
|
4229
|
+
table
|
|
3140
4230
|
})
|
|
3141
4231
|
})
|
|
3142
4232
|
}) : null
|
|
@@ -3186,35 +4276,30 @@ var GroupActions = ({
|
|
|
3186
4276
|
});
|
|
3187
4277
|
};
|
|
3188
4278
|
var GroupHeaderRow = ({
|
|
3189
|
-
|
|
4279
|
+
table,
|
|
3190
4280
|
section,
|
|
3191
4281
|
colSpan,
|
|
3192
4282
|
virtualIndex,
|
|
3193
4283
|
measureRef
|
|
3194
4284
|
}) => {
|
|
3195
|
-
const
|
|
4285
|
+
const tableClasses = useContext(DataTableSlotClassesContext);
|
|
4286
|
+
const [store, send] = table;
|
|
3196
4287
|
const collapsed = !!store.state.collapsedGroups[section.key];
|
|
3197
4288
|
return /* @__PURE__ */ jsx15(TableRow2, {
|
|
3198
4289
|
ref: measureRef,
|
|
3199
4290
|
"data-index": virtualIndex,
|
|
3200
4291
|
"aria-rowindex": virtualIndex === undefined ? undefined : virtualIndex + 2,
|
|
3201
|
-
className: "
|
|
3202
|
-
onClick: () =>
|
|
3203
|
-
...state,
|
|
3204
|
-
collapsedGroups: {
|
|
3205
|
-
...state.collapsedGroups,
|
|
3206
|
-
[section.key]: !collapsed
|
|
3207
|
-
}
|
|
3208
|
-
})),
|
|
4292
|
+
className: cn(tableClasses.group, "cursor-pointer"),
|
|
4293
|
+
onClick: () => send(DataTableMessage.GroupToggled({ key: section.key })),
|
|
3209
4294
|
children: /* @__PURE__ */ jsx15(TableCell2, {
|
|
3210
4295
|
className: "p-0",
|
|
3211
4296
|
colSpan,
|
|
3212
4297
|
children: /* @__PURE__ */ jsxs9("div", {
|
|
3213
|
-
className:
|
|
4298
|
+
className: cn(tableClasses.groupContent, tableClasses.groupSticky),
|
|
3214
4299
|
children: [
|
|
3215
4300
|
/* @__PURE__ */ jsxs9("button", {
|
|
3216
4301
|
"aria-expanded": !collapsed,
|
|
3217
|
-
className:
|
|
4302
|
+
className: tableClasses.groupTrigger,
|
|
3218
4303
|
style: { paddingLeft: section.depth * 20 },
|
|
3219
4304
|
type: "button",
|
|
3220
4305
|
children: [
|
|
@@ -3229,9 +4314,8 @@ var GroupHeaderRow = ({
|
|
|
3229
4314
|
})
|
|
3230
4315
|
]
|
|
3231
4316
|
}),
|
|
3232
|
-
/* @__PURE__ */ jsx15(
|
|
3233
|
-
className:
|
|
3234
|
-
variant: "secondary",
|
|
4317
|
+
/* @__PURE__ */ jsx15("span", {
|
|
4318
|
+
className: tableClasses.count,
|
|
3235
4319
|
children: section.rows.length
|
|
3236
4320
|
}),
|
|
3237
4321
|
/* @__PURE__ */ jsx15(GroupActions, {
|
|
@@ -3245,10 +4329,10 @@ var GroupHeaderRow = ({
|
|
|
3245
4329
|
});
|
|
3246
4330
|
};
|
|
3247
4331
|
var GroupedTable = ({
|
|
3248
|
-
|
|
4332
|
+
table,
|
|
3249
4333
|
sections
|
|
3250
4334
|
}) => {
|
|
3251
|
-
const [store] =
|
|
4335
|
+
const [store] = table;
|
|
3252
4336
|
const model = deriveModel(store);
|
|
3253
4337
|
const extra = (store.config.features.selection ? 1 : 0) + (hasRowActionMenu(store) ? 1 : 0) + (canDragRows(store) ? 1 : 0);
|
|
3254
4338
|
const renderSections = (items) => items.flatMap((section) => {
|
|
@@ -3259,7 +4343,7 @@ var GroupedTable = ({
|
|
|
3259
4343
|
"data-table-group": section.field.onMoveToGroup ? targetKey : undefined,
|
|
3260
4344
|
children: [
|
|
3261
4345
|
/* @__PURE__ */ jsx15(GroupHeaderRow, {
|
|
3262
|
-
|
|
4346
|
+
table,
|
|
3263
4347
|
section,
|
|
3264
4348
|
colSpan: model.visibleColumns.length + extra
|
|
3265
4349
|
}),
|
|
@@ -3267,7 +4351,7 @@ var GroupedTable = ({
|
|
|
3267
4351
|
value: row.id,
|
|
3268
4352
|
children: /* @__PURE__ */ jsx15(TableDataRow, {
|
|
3269
4353
|
row,
|
|
3270
|
-
|
|
4354
|
+
table
|
|
3271
4355
|
})
|
|
3272
4356
|
}, `${section.key}:${row.id}`)) : [
|
|
3273
4357
|
/* @__PURE__ */ jsx15(TableRow2, {
|
|
@@ -3287,9 +4371,10 @@ var GroupedTable = ({
|
|
|
3287
4371
|
});
|
|
3288
4372
|
};
|
|
3289
4373
|
var ColumnHeaderMenu = ({
|
|
3290
|
-
|
|
4374
|
+
table
|
|
3291
4375
|
}) => {
|
|
3292
|
-
const
|
|
4376
|
+
const tableClasses = useContext(DataTableSlotClassesContext);
|
|
4377
|
+
const [store, send] = table;
|
|
3293
4378
|
const columnId = useRequiredId(ColumnIdContext);
|
|
3294
4379
|
const model = deriveModel(store);
|
|
3295
4380
|
const column = model.columns.find(({ id }) => id === columnId);
|
|
@@ -3305,18 +4390,13 @@ var ColumnHeaderMenu = ({
|
|
|
3305
4390
|
rows: model.rows,
|
|
3306
4391
|
current: store.state.filters?.find((filter) => filter.id === field.id),
|
|
3307
4392
|
labels: store.config.labels,
|
|
3308
|
-
onChange: (filter) =>
|
|
4393
|
+
onChange: (filter) => send(DataTableMessage.ColumnFilterChanged({ id: field.id, filter: filter ?? null }))
|
|
3309
4394
|
});
|
|
3310
4395
|
const sortingEnabled = store.config.features.sorting !== false && sortColumns.length > 0;
|
|
3311
4396
|
const hidingEnabled = store.config.features.columnVisibility !== false && column.colDef.hideable !== false;
|
|
3312
4397
|
const ownsSort = (id) => id === column.id || sortColumns.some((field) => field.id === id);
|
|
3313
4398
|
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
|
-
}));
|
|
4399
|
+
const setSort = (id, direction) => send(DataTableMessage.SortRequested({ columnId: id, direction }));
|
|
3320
4400
|
const label = columnLabel(column);
|
|
3321
4401
|
const sortItems = (field) => /* @__PURE__ */ jsxs9(Fragment, {
|
|
3322
4402
|
children: [
|
|
@@ -3350,7 +4430,7 @@ var ColumnHeaderMenu = ({
|
|
|
3350
4430
|
render: /* @__PURE__ */ jsxs9(Button, {
|
|
3351
4431
|
"aria-label": label,
|
|
3352
4432
|
"aria-description": activeFilters.length ? `${store.config.labels.filters}: ${activeFilters.length}` : undefined,
|
|
3353
|
-
className:
|
|
4433
|
+
className: tableClasses.headerTrigger,
|
|
3354
4434
|
variant: "ghost",
|
|
3355
4435
|
children: [
|
|
3356
4436
|
/* @__PURE__ */ jsx15("span", {
|
|
@@ -3382,10 +4462,7 @@ var ColumnHeaderMenu = ({
|
|
|
3382
4462
|
]
|
|
3383
4463
|
}, field.id)) : sortItems(column),
|
|
3384
4464
|
sort ? /* @__PURE__ */ jsxs9(DropdownMenuItem2, {
|
|
3385
|
-
onClick: () =>
|
|
3386
|
-
...state,
|
|
3387
|
-
sort: state.sort?.filter(({ id }) => !ownsSort(id))
|
|
3388
|
-
})),
|
|
4465
|
+
onClick: () => send(DataTableMessage.ColumnSortCleared({ id: column.id })),
|
|
3389
4466
|
children: [
|
|
3390
4467
|
/* @__PURE__ */ jsx15(X, {}),
|
|
3391
4468
|
" ",
|
|
@@ -3427,14 +4504,7 @@ var ColumnHeaderMenu = ({
|
|
|
3427
4504
|
]
|
|
3428
4505
|
}),
|
|
3429
4506
|
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
|
-
}),
|
|
4507
|
+
onClick: () => send(DataTableMessage.ColumnFiltersCleared({ id: column.id })),
|
|
3438
4508
|
children: [
|
|
3439
4509
|
/* @__PURE__ */ jsx15(X, {}),
|
|
3440
4510
|
store.config.labels.filterClear
|
|
@@ -3444,12 +4514,9 @@ var ColumnHeaderMenu = ({
|
|
|
3444
4514
|
}) : null,
|
|
3445
4515
|
(sortingEnabled || filteringEnabled) && hidingEnabled ? /* @__PURE__ */ jsx15(DropdownMenuSeparator2, {}) : null,
|
|
3446
4516
|
hidingEnabled ? /* @__PURE__ */ jsxs9(DropdownMenuItem2, {
|
|
3447
|
-
onClick: () =>
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
...state.columnVisibility,
|
|
3451
|
-
[column.id]: false
|
|
3452
|
-
}
|
|
4517
|
+
onClick: () => send(DataTableMessage.ColumnVisibilityChanged({
|
|
4518
|
+
id: column.id,
|
|
4519
|
+
visible: false
|
|
3453
4520
|
})),
|
|
3454
4521
|
children: [
|
|
3455
4522
|
/* @__PURE__ */ jsx15(EyeOff, {}),
|
|
@@ -3464,36 +4531,37 @@ var ColumnHeaderMenu = ({
|
|
|
3464
4531
|
});
|
|
3465
4532
|
};
|
|
3466
4533
|
var DataTableHeader = ({
|
|
3467
|
-
|
|
4534
|
+
table,
|
|
3468
4535
|
sticky
|
|
3469
4536
|
}) => {
|
|
3470
|
-
const
|
|
4537
|
+
const tableClasses = useContext(DataTableSlotClassesContext);
|
|
4538
|
+
const [store, send] = table;
|
|
3471
4539
|
const model = deriveModel(store);
|
|
3472
4540
|
const selection = store.config.features.selection;
|
|
3473
|
-
const grouped = getActiveGrouping(store).length > 0;
|
|
3474
4541
|
const draggable = canDragRows(store);
|
|
3475
|
-
const selectableRows =
|
|
4542
|
+
const selectableRows = model.pageRows.filter((row) => !selection || (selection.isRowSelectable?.(row.data) ?? true));
|
|
3476
4543
|
const allSelected = selectableRows.length > 0 && selectableRows.every((row) => store.state.rowSelection[row.id]);
|
|
3477
4544
|
const someSelected = selectableRows.some((row) => store.state.rowSelection[row.id]);
|
|
3478
4545
|
return /* @__PURE__ */ jsx15(TableHeader2, {
|
|
3479
|
-
className: sticky ?
|
|
4546
|
+
className: sticky ? cn(tableClasses.stickyHeader, tableClasses.stickyHeaderRule, "[&_tr]:border-b-0") : undefined,
|
|
3480
4547
|
children: /* @__PURE__ */ jsxs9(TableRow2, {
|
|
3481
4548
|
"aria-rowindex": sticky ? 1 : undefined,
|
|
3482
4549
|
children: [
|
|
3483
4550
|
selection ? /* @__PURE__ */ jsx15(TableHead2, {
|
|
3484
|
-
className:
|
|
3485
|
-
children: /* @__PURE__ */ jsx15(
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
|
|
4551
|
+
className: tableClasses.selectionCell,
|
|
4552
|
+
children: /* @__PURE__ */ jsx15("div", {
|
|
4553
|
+
className: tableClasses.selectionCenter,
|
|
4554
|
+
children: /* @__PURE__ */ jsx15(Checkbox, {
|
|
4555
|
+
"aria-label": store.config.labels.selectAllRows,
|
|
4556
|
+
checked: allSelected,
|
|
4557
|
+
indeterminate: someSelected && !allSelected,
|
|
4558
|
+
onCheckedChange: (checked) => {
|
|
4559
|
+
send(DataTableMessage.SelectionRequested({
|
|
4560
|
+
rowIds: selectableRows.map(({ id }) => id),
|
|
4561
|
+
checked
|
|
4562
|
+
}));
|
|
4563
|
+
}
|
|
4564
|
+
})
|
|
3497
4565
|
})
|
|
3498
4566
|
}) : null,
|
|
3499
4567
|
draggable ? /* @__PURE__ */ jsx15(TableHead2, {
|
|
@@ -3503,17 +4571,17 @@ var DataTableHeader = ({
|
|
|
3503
4571
|
const direction = store.state.sort?.find(({ id }) => id === column.id)?.direction;
|
|
3504
4572
|
return /* @__PURE__ */ jsx15(TableHead2, {
|
|
3505
4573
|
"aria-sort": direction === "asc" ? "ascending" : direction === "desc" ? "descending" : undefined,
|
|
3506
|
-
className:
|
|
4574
|
+
className: tableClasses.header,
|
|
3507
4575
|
scope: "col",
|
|
3508
4576
|
style: { width: column.width },
|
|
3509
4577
|
children: /* @__PURE__ */ jsxs9(ColumnIdContext.Provider, {
|
|
3510
4578
|
value: column.id,
|
|
3511
4579
|
children: [
|
|
3512
4580
|
/* @__PURE__ */ jsx15(ColumnHeaderMenu, {
|
|
3513
|
-
|
|
4581
|
+
table
|
|
3514
4582
|
}),
|
|
3515
4583
|
/* @__PURE__ */ jsx15(ResizeHandle, {
|
|
3516
|
-
|
|
4584
|
+
table
|
|
3517
4585
|
})
|
|
3518
4586
|
]
|
|
3519
4587
|
})
|
|
@@ -3527,13 +4595,13 @@ var DataTableHeader = ({
|
|
|
3527
4595
|
});
|
|
3528
4596
|
};
|
|
3529
4597
|
var VirtualTableRows = ({
|
|
3530
|
-
|
|
4598
|
+
table,
|
|
3531
4599
|
rows,
|
|
3532
4600
|
sections,
|
|
3533
4601
|
viewport,
|
|
3534
4602
|
colSpan
|
|
3535
4603
|
}) => {
|
|
3536
|
-
const [{ state, config }] =
|
|
4604
|
+
const [{ state, config }] = table;
|
|
3537
4605
|
const { element: scrollElement, headerHeight } = viewport;
|
|
3538
4606
|
const pageScroll = viewport.options.scroll === "page";
|
|
3539
4607
|
const scrollMargin = viewport.pageOffset ?? headerHeight;
|
|
@@ -3618,7 +4686,7 @@ var VirtualTableRows = ({
|
|
|
3618
4686
|
return /* @__PURE__ */ jsx15(TableDataRow, {
|
|
3619
4687
|
measureRef: virtualizer.measureElement,
|
|
3620
4688
|
row: entry.row,
|
|
3621
|
-
|
|
4689
|
+
table,
|
|
3622
4690
|
virtualIndex: index
|
|
3623
4691
|
}, key);
|
|
3624
4692
|
if (entry.kind === "header")
|
|
@@ -3626,7 +4694,7 @@ var VirtualTableRows = ({
|
|
|
3626
4694
|
measureRef: virtualizer.measureElement,
|
|
3627
4695
|
section: entry.section,
|
|
3628
4696
|
colSpan,
|
|
3629
|
-
|
|
4697
|
+
table,
|
|
3630
4698
|
virtualIndex: index
|
|
3631
4699
|
}, key);
|
|
3632
4700
|
return /* @__PURE__ */ jsx15(TableRow2, {
|
|
@@ -3645,21 +4713,20 @@ var VirtualTableRows = ({
|
|
|
3645
4713
|
});
|
|
3646
4714
|
};
|
|
3647
4715
|
var DataTableBody = ({
|
|
3648
|
-
|
|
4716
|
+
table,
|
|
3649
4717
|
viewport
|
|
3650
4718
|
}) => {
|
|
3651
4719
|
const styles = useContext(DataTableStylesContext);
|
|
3652
|
-
const [store] =
|
|
4720
|
+
const [store] = table;
|
|
3653
4721
|
const model = deriveModel(store);
|
|
3654
4722
|
const fields = getActiveGrouping(store);
|
|
3655
|
-
const
|
|
3656
|
-
const rows = grouped ? model.sortedRows : model.pageRows;
|
|
4723
|
+
const rows = model.pageRows;
|
|
3657
4724
|
const sections = useMemo2(() => groupDataTableRows(rows, fields), [rows, fields]);
|
|
3658
4725
|
const colSpan = model.visibleColumns.length + (store.config.features.selection ? 1 : 0) + (hasRowActionMenu(store) ? 1 : 0) + (canDragRows(store) ? 1 : 0);
|
|
3659
4726
|
const showGroups = sections.length && (rows.length || !store.config.status.loading) && !store.config.status.error;
|
|
3660
4727
|
if (showGroups && !viewport) {
|
|
3661
4728
|
return /* @__PURE__ */ jsx15(GroupedTable, {
|
|
3662
|
-
|
|
4729
|
+
table,
|
|
3663
4730
|
sections
|
|
3664
4731
|
});
|
|
3665
4732
|
}
|
|
@@ -3685,30 +4752,17 @@ var DataTableBody = ({
|
|
|
3685
4752
|
colSpan,
|
|
3686
4753
|
rows,
|
|
3687
4754
|
sections,
|
|
3688
|
-
|
|
4755
|
+
table,
|
|
3689
4756
|
viewport
|
|
3690
4757
|
}) : rows.map((row) => /* @__PURE__ */ jsx15(RowIdContext.Provider, {
|
|
3691
4758
|
value: row.id,
|
|
3692
4759
|
children: /* @__PURE__ */ jsx15(TableDataRow, {
|
|
3693
4760
|
row,
|
|
3694
|
-
|
|
4761
|
+
table
|
|
3695
4762
|
})
|
|
3696
4763
|
}, row.id))
|
|
3697
4764
|
});
|
|
3698
4765
|
};
|
|
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
4766
|
var GalleryTag = ({
|
|
3713
4767
|
row,
|
|
3714
4768
|
column,
|
|
@@ -3735,9 +4789,9 @@ var GalleryTag = ({
|
|
|
3735
4789
|
});
|
|
3736
4790
|
};
|
|
3737
4791
|
var GalleryCard = ({
|
|
3738
|
-
|
|
4792
|
+
table
|
|
3739
4793
|
}) => {
|
|
3740
|
-
const [store,
|
|
4794
|
+
const [store, send] = table;
|
|
3741
4795
|
const rowId = useRequiredId(RowIdContext);
|
|
3742
4796
|
const model = deriveModel(store);
|
|
3743
4797
|
const row = model.sortedRows.find((candidate) => candidate.id === rowId);
|
|
@@ -3766,10 +4820,14 @@ var GalleryCard = ({
|
|
|
3766
4820
|
},
|
|
3767
4821
|
tabIndex: store.config.onRowClicked ? 0 : undefined,
|
|
3768
4822
|
children: [
|
|
3769
|
-
imageSrc ? /* @__PURE__ */ jsx15(
|
|
4823
|
+
imageSrc && !store.ui.failedImages.includes(imageSrc) ? /* @__PURE__ */ jsx15("img", {
|
|
3770
4824
|
src: imageSrc,
|
|
3771
|
-
alt: gallery.image?.getAlt?.(row.data) ?? ""
|
|
3772
|
-
|
|
4825
|
+
alt: gallery.image?.getAlt?.(row.data) ?? "",
|
|
4826
|
+
loading: "lazy",
|
|
4827
|
+
decoding: "async",
|
|
4828
|
+
className: "aspect-video w-full object-cover",
|
|
4829
|
+
onError: () => send(DataTableMessage.ReferenceImageFailed({ src: imageSrc }))
|
|
4830
|
+
}) : null,
|
|
3773
4831
|
/* @__PURE__ */ jsxs9(CardHeader, {
|
|
3774
4832
|
className: cn("relative", hasRowActionMenu(store) && "pr-12"),
|
|
3775
4833
|
children: [
|
|
@@ -3780,11 +4838,11 @@ var GalleryCard = ({
|
|
|
3780
4838
|
"aria-label": store.config.labels.selectRow,
|
|
3781
4839
|
checked: !!store.state.rowSelection[row.id],
|
|
3782
4840
|
disabled: !selectable,
|
|
3783
|
-
onCheckedChange: (checked) => toggleRow(
|
|
4841
|
+
onCheckedChange: (checked) => toggleRow(send, row.id, checked),
|
|
3784
4842
|
onClick: (event) => event.stopPropagation()
|
|
3785
4843
|
}) : null,
|
|
3786
4844
|
draggable ? /* @__PURE__ */ jsx15(DragHandle, {
|
|
3787
|
-
|
|
4845
|
+
table
|
|
3788
4846
|
}) : null
|
|
3789
4847
|
]
|
|
3790
4848
|
}) : null,
|
|
@@ -3813,7 +4871,7 @@ var GalleryCard = ({
|
|
|
3813
4871
|
onClick: (event) => event.stopPropagation(),
|
|
3814
4872
|
children: /* @__PURE__ */ jsx15(DataTableRowActionMenu, {
|
|
3815
4873
|
row,
|
|
3816
|
-
|
|
4874
|
+
table
|
|
3817
4875
|
})
|
|
3818
4876
|
}) : null
|
|
3819
4877
|
]
|
|
@@ -3822,13 +4880,13 @@ var GalleryCard = ({
|
|
|
3822
4880
|
});
|
|
3823
4881
|
};
|
|
3824
4882
|
var DataTableGallery = ({
|
|
3825
|
-
|
|
4883
|
+
table
|
|
3826
4884
|
}) => {
|
|
3827
4885
|
const styles = useContext(DataTableStylesContext);
|
|
3828
|
-
const [store,
|
|
4886
|
+
const [store, send] = table;
|
|
3829
4887
|
const model = deriveModel(store);
|
|
3830
4888
|
const fields = getActiveGrouping(store);
|
|
3831
|
-
const rows =
|
|
4889
|
+
const rows = model.pageRows;
|
|
3832
4890
|
const sections = groupDataTableRows(rows, fields);
|
|
3833
4891
|
if (store.config.status.error) {
|
|
3834
4892
|
return /* @__PURE__ */ jsx15("div", {
|
|
@@ -3860,7 +4918,7 @@ var DataTableGallery = ({
|
|
|
3860
4918
|
children: rows.map((row) => /* @__PURE__ */ jsx15(RowIdContext.Provider, {
|
|
3861
4919
|
value: row.id,
|
|
3862
4920
|
children: /* @__PURE__ */ jsx15(GalleryCard, {
|
|
3863
|
-
|
|
4921
|
+
table
|
|
3864
4922
|
})
|
|
3865
4923
|
}, row.id))
|
|
3866
4924
|
});
|
|
@@ -3868,13 +4926,7 @@ var DataTableGallery = ({
|
|
|
3868
4926
|
const renderSections = (sections) => sections.map((section) => {
|
|
3869
4927
|
const collapsed = !!store.state.collapsedGroups[section.key];
|
|
3870
4928
|
const targetKey = getGroupDropKey(section.field.id, section.groupId);
|
|
3871
|
-
const toggleCollapsed = () =>
|
|
3872
|
-
...state,
|
|
3873
|
-
collapsedGroups: {
|
|
3874
|
-
...state.collapsedGroups,
|
|
3875
|
-
[section.key]: !collapsed
|
|
3876
|
-
}
|
|
3877
|
-
}));
|
|
4929
|
+
const toggleCollapsed = () => send(DataTableMessage.GroupToggled({ key: section.key }));
|
|
3878
4930
|
return /* @__PURE__ */ jsxs9("section", {
|
|
3879
4931
|
className: "data-[drop-target=true]:ring-primary space-y-3 rounded-lg transition-shadow data-[drop-target=true]:ring-2",
|
|
3880
4932
|
"data-table-group": section.field.onMoveToGroup ? targetKey : undefined,
|
|
@@ -3916,7 +4968,7 @@ var DataTableGallery = ({
|
|
|
3916
4968
|
children: section.rows.map((row) => /* @__PURE__ */ jsx15(RowIdContext.Provider, {
|
|
3917
4969
|
value: row.id,
|
|
3918
4970
|
children: /* @__PURE__ */ jsx15(GalleryCard, {
|
|
3919
|
-
|
|
4971
|
+
table
|
|
3920
4972
|
})
|
|
3921
4973
|
}, `${section.key}:${row.id}`))
|
|
3922
4974
|
}) : /* @__PURE__ */ jsx15("div", {
|
|
@@ -3932,28 +4984,22 @@ var DataTableGallery = ({
|
|
|
3932
4984
|
});
|
|
3933
4985
|
};
|
|
3934
4986
|
var DataTablePagination = ({
|
|
3935
|
-
|
|
4987
|
+
table
|
|
3936
4988
|
}) => {
|
|
3937
4989
|
const styles = useContext(DataTableStylesContext);
|
|
3938
|
-
const [store,
|
|
4990
|
+
const [store, send] = table;
|
|
3939
4991
|
const model = deriveModel(store);
|
|
3940
4992
|
const pagination = store.config.features.pagination ?? false;
|
|
3941
|
-
const
|
|
3942
|
-
const paginationVisible = pagination !== false && !clientGrouping;
|
|
4993
|
+
const { paginationVisible, page } = model;
|
|
3943
4994
|
const pageIndex = store.state.page;
|
|
3944
|
-
const maxPageIndex = model.pageCount - 1;
|
|
3945
4995
|
useLayoutEffect(() => {
|
|
3946
|
-
if (paginationVisible && pageIndex >
|
|
3947
|
-
|
|
3948
|
-
...state,
|
|
3949
|
-
page: maxPageIndex
|
|
3950
|
-
}));
|
|
4996
|
+
if (paginationVisible && pagination && pagination.mode === "client" && pageIndex > page) {
|
|
4997
|
+
send(DataTableMessage.PageRequested({ page }));
|
|
3951
4998
|
}
|
|
3952
|
-
}, [
|
|
3953
|
-
if (!paginationVisible)
|
|
4999
|
+
}, [page, pageIndex, pagination, paginationVisible, send]);
|
|
5000
|
+
if (!paginationVisible || !pagination)
|
|
3954
5001
|
return null;
|
|
3955
5002
|
const selected = model.rows.filter((row) => store.state.rowSelection[row.id]).length;
|
|
3956
|
-
const setPagination = (next) => changeState(setStore, (state) => ({ ...state, ...next }));
|
|
3957
5003
|
return /* @__PURE__ */ jsx15("div", {
|
|
3958
5004
|
"data-table-slot": "pagination",
|
|
3959
5005
|
className: cn("shrink-0 pt-4", styles?.pagination),
|
|
@@ -3961,9 +5007,9 @@ var DataTablePagination = ({
|
|
|
3961
5007
|
pageSizeContentClassName: styles?.popup?.select,
|
|
3962
5008
|
locale: store.config.locale,
|
|
3963
5009
|
messages: { [store.config.locale]: store.config.labels },
|
|
3964
|
-
onPageChange: (page) =>
|
|
3965
|
-
onPageSizeChange: (pageSize) =>
|
|
3966
|
-
page
|
|
5010
|
+
onPageChange: (page) => send(DataTableMessage.PageRequested({ page })),
|
|
5011
|
+
onPageSizeChange: (pageSize) => send(DataTableMessage.PageSizeRequested({ pageSize })),
|
|
5012
|
+
page,
|
|
3967
5013
|
pageCount: model.pageCount,
|
|
3968
5014
|
pageSize: store.state.pageSize,
|
|
3969
5015
|
pageSizes: pagination.pageSizes,
|
|
@@ -3972,151 +5018,221 @@ var DataTablePagination = ({
|
|
|
3972
5018
|
})
|
|
3973
5019
|
});
|
|
3974
5020
|
};
|
|
5021
|
+
var ReactTableModel = Component3.define(dataTableOptions).make({
|
|
5022
|
+
...dataTableBehaviours,
|
|
5023
|
+
view: () => View.text("")
|
|
5024
|
+
});
|
|
5025
|
+
var modelField = (id, definition) => {
|
|
5026
|
+
const field = {
|
|
5027
|
+
id,
|
|
5028
|
+
headerName: id,
|
|
5029
|
+
type: definition.type ?? "text"
|
|
5030
|
+
};
|
|
5031
|
+
if (definition.sortable !== undefined)
|
|
5032
|
+
field.sortable = definition.sortable;
|
|
5033
|
+
if (definition.filterable !== undefined)
|
|
5034
|
+
field.filterable = definition.filterable;
|
|
5035
|
+
return field;
|
|
5036
|
+
};
|
|
5037
|
+
var modelColumns = (definitions) => normalizeDataTableColumns(definitions).map(({ id, colDef }) => {
|
|
5038
|
+
const column = modelField(id, colDef);
|
|
5039
|
+
if (colDef.width !== undefined)
|
|
5040
|
+
column.width = colDef.width;
|
|
5041
|
+
if (colDef.minWidth !== undefined)
|
|
5042
|
+
column.minWidth = colDef.minWidth;
|
|
5043
|
+
if (colDef.maxWidth !== undefined)
|
|
5044
|
+
column.maxWidth = colDef.maxWidth;
|
|
5045
|
+
if (colDef.hideable !== undefined)
|
|
5046
|
+
column.hideable = colDef.hideable;
|
|
5047
|
+
if (colDef.resizable !== undefined)
|
|
5048
|
+
column.resizable = colDef.resizable;
|
|
5049
|
+
if (colDef.fields)
|
|
5050
|
+
column.fields = colDef.fields.map((field) => modelField(field.id, field));
|
|
5051
|
+
return column;
|
|
5052
|
+
});
|
|
3975
5053
|
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
|
|
5054
|
+
var HydratedDataTable = (props) => {
|
|
5055
|
+
const config = useMemo2(() => resolveConfig(props), [props]);
|
|
5056
|
+
const columns = useMemo2(() => modelColumns(props.columnDefs), [props.columnDefs]);
|
|
5057
|
+
const selection = config.features.selection;
|
|
5058
|
+
const modelProps = useMemo2(() => {
|
|
5059
|
+
const { features } = config;
|
|
5060
|
+
const grouping = features.grouping;
|
|
5061
|
+
const pagination = features.pagination;
|
|
5062
|
+
const [firstSize, ...otherSizes] = pagination && pagination.pageSizes || [];
|
|
5063
|
+
const modelFeatures = {
|
|
5064
|
+
search: features.search !== false,
|
|
5065
|
+
filtering: features.filtering !== false,
|
|
5066
|
+
sorting: features.sorting !== false,
|
|
5067
|
+
columnVisibility: features.columnVisibility !== false,
|
|
5068
|
+
pagination: pagination ? {
|
|
5069
|
+
...pagination,
|
|
5070
|
+
pageSizes: firstSize === undefined ? undefined : [firstSize, ...otherSizes]
|
|
5071
|
+
} : false
|
|
4004
5072
|
};
|
|
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)
|
|
5073
|
+
if (features.gallery)
|
|
5074
|
+
modelFeatures.gallery = { name: features.gallery.name };
|
|
5075
|
+
if (grouping) {
|
|
5076
|
+
modelFeatures.grouping = {
|
|
5077
|
+
initial: grouping.initial ?? [],
|
|
5078
|
+
fields: grouping.fields.map(({ id }) => ({ id, label: id }))
|
|
4029
5079
|
};
|
|
4030
|
-
|
|
4031
|
-
|
|
4032
|
-
|
|
4033
|
-
|
|
4034
|
-
|
|
4035
|
-
config,
|
|
4036
|
-
|
|
4037
|
-
|
|
4038
|
-
|
|
4039
|
-
|
|
4040
|
-
|
|
5080
|
+
}
|
|
5081
|
+
const input = {
|
|
5082
|
+
label: "",
|
|
5083
|
+
columnDefs: columns,
|
|
5084
|
+
rowData: selection ? props.rowData.map((row, index) => ({
|
|
5085
|
+
id: config.getRowId?.(row) ?? String(index),
|
|
5086
|
+
label: "",
|
|
5087
|
+
cells: {},
|
|
5088
|
+
selectable: selection.isRowSelectable?.(row) ?? true
|
|
5089
|
+
})) : [],
|
|
5090
|
+
features: modelFeatures
|
|
5091
|
+
};
|
|
5092
|
+
if (selection)
|
|
5093
|
+
input.selection = {};
|
|
5094
|
+
if (props.state)
|
|
5095
|
+
input.state = props.state;
|
|
5096
|
+
if (props.initialState)
|
|
5097
|
+
input.initialState = props.initialState;
|
|
5098
|
+
return input;
|
|
4041
5099
|
}, [
|
|
4042
|
-
|
|
4043
|
-
|
|
4044
|
-
props.
|
|
4045
|
-
props.locale,
|
|
4046
|
-
props.messages,
|
|
4047
|
-
props.onRowClicked,
|
|
4048
|
-
props.onStateChange,
|
|
5100
|
+
columns,
|
|
5101
|
+
config,
|
|
5102
|
+
props.initialState,
|
|
4049
5103
|
props.rowData,
|
|
4050
5104
|
props.state,
|
|
4051
|
-
|
|
4052
|
-
|
|
4053
|
-
|
|
4054
|
-
|
|
5105
|
+
selection
|
|
5106
|
+
]);
|
|
5107
|
+
const { model, send } = useModel(ReactTableModel, modelProps, {
|
|
5108
|
+
onEmit: (event) => {
|
|
5109
|
+
if (event._tag === "StateChanged") {
|
|
5110
|
+
props.onStateChange?.(queryFromState(event.state));
|
|
5111
|
+
} else if (event._tag === "SelectionChanged" && selection) {
|
|
5112
|
+
const selected = new Set(event.selectedRowIds);
|
|
5113
|
+
selection.onSelectionChange?.(props.rowData.filter((_, index) => {
|
|
5114
|
+
const id = modelProps.rowData[index]?.id;
|
|
5115
|
+
return id !== undefined && selected.has(id);
|
|
5116
|
+
}));
|
|
5117
|
+
}
|
|
5118
|
+
}
|
|
5119
|
+
});
|
|
5120
|
+
const [storageKey] = useState(() => tablePreferencesKey(globalThis.window?.location.pathname ?? "/", columns.map(({ id }) => id), !!props.features?.gallery));
|
|
5121
|
+
useEffect(() => {
|
|
5122
|
+
if (!model.preferencesLoaded) {
|
|
5123
|
+
send(DataTableMessage.PreferencesLoaded({
|
|
5124
|
+
preferences: readTablePreferences(storageKey)
|
|
5125
|
+
}));
|
|
5126
|
+
}
|
|
5127
|
+
}, [model, send, storageKey]);
|
|
5128
|
+
const { columnVisibility, columnSizing, grouping, view, preferencesLoaded } = model;
|
|
5129
|
+
const loadedPreferences = useRef(false);
|
|
5130
|
+
useEffect(() => {
|
|
5131
|
+
const preferences = tablePreferences({
|
|
5132
|
+
columnVisibility,
|
|
5133
|
+
columnSizing,
|
|
5134
|
+
grouping,
|
|
5135
|
+
view,
|
|
5136
|
+
preferencesLoaded
|
|
5137
|
+
});
|
|
5138
|
+
if (!preferences)
|
|
5139
|
+
return;
|
|
5140
|
+
if (!loadedPreferences.current) {
|
|
5141
|
+
loadedPreferences.current = true;
|
|
5142
|
+
return;
|
|
5143
|
+
}
|
|
5144
|
+
writeTablePreferences(storageKey, preferences);
|
|
5145
|
+
}, [
|
|
5146
|
+
columnVisibility,
|
|
5147
|
+
columnSizing,
|
|
5148
|
+
grouping,
|
|
5149
|
+
view,
|
|
5150
|
+
preferencesLoaded,
|
|
5151
|
+
storageKey
|
|
4055
5152
|
]);
|
|
5153
|
+
const query = modelProps.state ?? model.query;
|
|
5154
|
+
const { collapsedGroups, selectedRowIds } = model;
|
|
5155
|
+
const galleryEnabled = !!props.features?.gallery;
|
|
5156
|
+
const state = useMemo2(() => ({
|
|
5157
|
+
...query,
|
|
5158
|
+
columnVisibility,
|
|
5159
|
+
columnSizing,
|
|
5160
|
+
grouping,
|
|
5161
|
+
view: galleryEnabled ? view : "table",
|
|
5162
|
+
collapsedGroups,
|
|
5163
|
+
rowSelection: Object.fromEntries(selectedRowIds.map((id) => [id, true]))
|
|
5164
|
+
}), [
|
|
5165
|
+
query,
|
|
5166
|
+
columnVisibility,
|
|
5167
|
+
columnSizing,
|
|
5168
|
+
grouping,
|
|
5169
|
+
view,
|
|
5170
|
+
galleryEnabled,
|
|
5171
|
+
collapsedGroups,
|
|
5172
|
+
selectedRowIds
|
|
5173
|
+
]);
|
|
5174
|
+
const store = useMemo2(() => {
|
|
5175
|
+
const source = {
|
|
5176
|
+
rowData: props.rowData,
|
|
5177
|
+
columnDefs: props.columnDefs,
|
|
5178
|
+
config,
|
|
5179
|
+
state
|
|
5180
|
+
};
|
|
5181
|
+
return { ...source, model: buildDataTableModel(source) };
|
|
5182
|
+
}, [props.rowData, props.columnDefs, config, state]);
|
|
5183
|
+
const table = [{ ...store, ui: model }, send];
|
|
5184
|
+
if (!preferencesLoaded)
|
|
5185
|
+
return /* @__PURE__ */ jsx15(TablePlaceholder, {
|
|
5186
|
+
props
|
|
5187
|
+
});
|
|
4056
5188
|
return /* @__PURE__ */ jsxs9("div", {
|
|
4057
5189
|
className: cn("w-full max-w-full min-w-0 rounded-md", getTableLayoutClass(props.features?.virtualization), props.className),
|
|
4058
5190
|
"data-table-root": "",
|
|
4059
5191
|
children: [
|
|
4060
5192
|
/* @__PURE__ */ jsx15(DataTableToolbar, {
|
|
4061
|
-
|
|
5193
|
+
table
|
|
4062
5194
|
}),
|
|
4063
5195
|
/* @__PURE__ */ jsx15(DataTableContent, {
|
|
4064
|
-
|
|
5196
|
+
table
|
|
4065
5197
|
}),
|
|
4066
5198
|
/* @__PURE__ */ jsx15(DataTablePagination, {
|
|
4067
|
-
|
|
5199
|
+
table
|
|
4068
5200
|
})
|
|
4069
5201
|
]
|
|
4070
5202
|
});
|
|
4071
5203
|
};
|
|
5204
|
+
var subscribeToHydration = () => () => {};
|
|
5205
|
+
var clientSnapshot = () => true;
|
|
5206
|
+
var serverSnapshot = () => false;
|
|
5207
|
+
var TablePlaceholder = ({
|
|
5208
|
+
props
|
|
5209
|
+
}) => /* @__PURE__ */ jsx15("div", {
|
|
5210
|
+
"aria-busy": "true",
|
|
5211
|
+
className: cn("invisible w-full max-w-full min-w-0 rounded-md", getTableLayoutClass(props.features?.virtualization), props.className),
|
|
5212
|
+
"data-table-root": ""
|
|
5213
|
+
});
|
|
4072
5214
|
var DataTable = (props) => {
|
|
4073
5215
|
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
|
-
})
|
|
4089
|
-
});
|
|
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": ""
|
|
5216
|
+
const hydrated = useSyncExternalStore(subscribeToHydration, clientSnapshot, serverSnapshot);
|
|
5217
|
+
if (!hydrated)
|
|
5218
|
+
return /* @__PURE__ */ jsx15(TablePlaceholder, {
|
|
5219
|
+
props
|
|
4104
5220
|
});
|
|
4105
|
-
}
|
|
4106
5221
|
return /* @__PURE__ */ jsx15(DataTableStylesContext.Provider, {
|
|
4107
5222
|
value: props.classNames,
|
|
4108
|
-
children: /* @__PURE__ */ jsx15(
|
|
4109
|
-
|
|
4110
|
-
|
|
4111
|
-
|
|
4112
|
-
|
|
5223
|
+
children: /* @__PURE__ */ jsx15(DataTableSlotClassesContext.Provider, {
|
|
5224
|
+
value: resolveTableClasses(props.classes),
|
|
5225
|
+
children: /* @__PURE__ */ jsx15(HydratedDataTable, {
|
|
5226
|
+
...props,
|
|
5227
|
+
locale
|
|
5228
|
+
})
|
|
4113
5229
|
})
|
|
4114
5230
|
});
|
|
4115
5231
|
};
|
|
4116
5232
|
var DataTableContent = ({
|
|
4117
|
-
|
|
5233
|
+
table
|
|
4118
5234
|
}) => {
|
|
4119
|
-
const [store] =
|
|
5235
|
+
const [store] = table;
|
|
4120
5236
|
const [scrollElement, setScrollElement] = useState(null);
|
|
4121
5237
|
const [headerHeight, setHeaderHeight] = useState(48);
|
|
4122
5238
|
const [pageTable, setPageTable] = useState(null);
|
|
@@ -4150,7 +5266,7 @@ var DataTableContent = ({
|
|
|
4150
5266
|
}, [scrollElement]);
|
|
4151
5267
|
if (store.config.features.gallery && store.state.view === "gallery") {
|
|
4152
5268
|
return /* @__PURE__ */ jsx15(DataTableGallery, {
|
|
4153
|
-
|
|
5269
|
+
table
|
|
4154
5270
|
});
|
|
4155
5271
|
}
|
|
4156
5272
|
const model = deriveModel(store);
|
|
@@ -4176,10 +5292,10 @@ var DataTableContent = ({
|
|
|
4176
5292
|
style: { width: `max(100%, ${width}px)` },
|
|
4177
5293
|
children: [
|
|
4178
5294
|
/* @__PURE__ */ jsx15(DataTableHeader, {
|
|
4179
|
-
|
|
5295
|
+
table
|
|
4180
5296
|
}),
|
|
4181
5297
|
/* @__PURE__ */ jsx15(DataTableBody, {
|
|
4182
|
-
|
|
5298
|
+
table,
|
|
4183
5299
|
viewport: {
|
|
4184
5300
|
element: null,
|
|
4185
5301
|
headerHeight: 0,
|
|
@@ -4216,10 +5332,10 @@ var DataTableContent = ({
|
|
|
4216
5332
|
children: [
|
|
4217
5333
|
/* @__PURE__ */ jsx15(DataTableHeader, {
|
|
4218
5334
|
sticky: true,
|
|
4219
|
-
|
|
5335
|
+
table
|
|
4220
5336
|
}),
|
|
4221
5337
|
/* @__PURE__ */ jsx15(DataTableBody, {
|
|
4222
|
-
|
|
5338
|
+
table,
|
|
4223
5339
|
viewport: { element: scrollElement, headerHeight, options }
|
|
4224
5340
|
})
|
|
4225
5341
|
]
|
|
@@ -4245,10 +5361,10 @@ var DataTableContent = ({
|
|
|
4245
5361
|
style: { width: `max(100%, ${width}px)` },
|
|
4246
5362
|
children: [
|
|
4247
5363
|
/* @__PURE__ */ jsx15(DataTableHeader, {
|
|
4248
|
-
|
|
5364
|
+
table
|
|
4249
5365
|
}),
|
|
4250
5366
|
/* @__PURE__ */ jsx15(DataTableBody, {
|
|
4251
|
-
|
|
5367
|
+
table
|
|
4252
5368
|
})
|
|
4253
5369
|
]
|
|
4254
5370
|
}),
|
|
@@ -4259,6 +5375,7 @@ var DataTableContent = ({
|
|
|
4259
5375
|
});
|
|
4260
5376
|
};
|
|
4261
5377
|
var DataTableListCell = (props) => {
|
|
5378
|
+
const tableClasses = useContext(DataTableSlotClassesContext);
|
|
4262
5379
|
const locale = useKrakstackLocale3(props.locale);
|
|
4263
5380
|
const resolvedProps = { ...props, locale };
|
|
4264
5381
|
if (resolvedProps.options && (resolvedProps.onAdd || resolvedProps.onRemove)) {
|
|
@@ -4276,7 +5393,7 @@ var DataTableListCell = (props) => {
|
|
|
4276
5393
|
}
|
|
4277
5394
|
const menuLabel = actionsLabel ?? (itemActions?.length ? labels.actions : labels.listDetails);
|
|
4278
5395
|
return /* @__PURE__ */ jsx15("div", {
|
|
4279
|
-
className:
|
|
5396
|
+
className: tableClasses.relationshipCell,
|
|
4280
5397
|
"data-slot": "data-table-list-cell",
|
|
4281
5398
|
onClick: (event) => event.stopPropagation(),
|
|
4282
5399
|
onPointerDown: (event) => event.stopPropagation(),
|
|
@@ -4291,7 +5408,7 @@ var DataTableListCell = (props) => {
|
|
|
4291
5408
|
onItemClick,
|
|
4292
5409
|
trigger: /* @__PURE__ */ jsxs9(Button, {
|
|
4293
5410
|
"aria-label": menuLabel,
|
|
4294
|
-
className:
|
|
5411
|
+
className: tableClasses.relationshipTrigger,
|
|
4295
5412
|
variant: "ghost",
|
|
4296
5413
|
children: [
|
|
4297
5414
|
/* @__PURE__ */ jsx15(DataTableListSummaryContent, {
|
|
@@ -4320,6 +5437,7 @@ var EditableDataTableListCell = ({
|
|
|
4320
5437
|
locale = "en",
|
|
4321
5438
|
messages
|
|
4322
5439
|
}) => {
|
|
5440
|
+
const tableClasses = useContext(DataTableSlotClassesContext);
|
|
4323
5441
|
const [selected, setSelected] = useState([...items]);
|
|
4324
5442
|
const [previousItems, setPreviousItems] = useState(items);
|
|
4325
5443
|
if (previousItems !== items) {
|
|
@@ -4351,7 +5469,7 @@ var EditableDataTableListCell = ({
|
|
|
4351
5469
|
];
|
|
4352
5470
|
return /* @__PURE__ */ jsx15("div", {
|
|
4353
5471
|
"data-slot": "data-table-list-cell",
|
|
4354
|
-
className:
|
|
5472
|
+
className: tableClasses.relationshipCell,
|
|
4355
5473
|
onClick: (event) => event.stopPropagation(),
|
|
4356
5474
|
onPointerDown: (event) => event.stopPropagation(),
|
|
4357
5475
|
children: /* @__PURE__ */ jsx15(DataTableListMenu, {
|
|
@@ -4408,7 +5526,7 @@ var DataTableListMenu = ({
|
|
|
4408
5526
|
trigger
|
|
4409
5527
|
}) => {
|
|
4410
5528
|
const entries = items.map((item) => {
|
|
4411
|
-
const normalized =
|
|
5529
|
+
const normalized = Schema6.is(Schema6.String)(item) ? { label: item } : item;
|
|
4412
5530
|
const visibleActions = actions.filter((action) => action.visible?.(normalized) ?? true);
|
|
4413
5531
|
return { item: normalized, visibleActions };
|
|
4414
5532
|
});
|
|
@@ -4578,7 +5696,7 @@ var DataTableListSummaryContent = ({
|
|
|
4578
5696
|
showMenu,
|
|
4579
5697
|
visibleCount = 3
|
|
4580
5698
|
}) => {
|
|
4581
|
-
const normalized = items.map((item) =>
|
|
5699
|
+
const normalized = items.map((item) => Schema6.is(Schema6.String)(item) ? { label: item } : item);
|
|
4582
5700
|
if (!normalized.length)
|
|
4583
5701
|
return /* @__PURE__ */ jsx15("span", {
|
|
4584
5702
|
className: "text-muted-foreground",
|
|
@@ -4683,21 +5801,20 @@ var DataTableListEntry = ({
|
|
|
4683
5801
|
]
|
|
4684
5802
|
});
|
|
4685
5803
|
};
|
|
4686
|
-
|
|
4687
|
-
|
|
4688
|
-
import { useKrakstackLocale as useKrakstackLocale4 } from "@krak-stack/registry/krakstack-provider";
|
|
5804
|
+
// ../../src/components/audit-log-table/react.tsx
|
|
5805
|
+
import { useKrakstackLocale as useKrakstackLocale4 } from "@krak-stack/registry/krakstack-provider/react";
|
|
4689
5806
|
|
|
4690
5807
|
// ../../src/services/events/record.ts
|
|
4691
|
-
import { Option as
|
|
4692
|
-
var TextValue =
|
|
5808
|
+
import { Option as Option5, Schema as Schema7 } from "effect";
|
|
5809
|
+
var TextValue = Schema7.Struct({ stringValue: Schema7.String }).annotate({
|
|
4693
5810
|
identifier: "EventTextValue"
|
|
4694
5811
|
});
|
|
4695
|
-
var TextArrayValue =
|
|
4696
|
-
arrayValue:
|
|
5812
|
+
var TextArrayValue = Schema7.Struct({
|
|
5813
|
+
arrayValue: Schema7.Struct({ values: Schema7.Array(TextValue) })
|
|
4697
5814
|
}).annotate({ identifier: "EventTextArrayValue" });
|
|
4698
|
-
var eventTextAttribute = (record, key) =>
|
|
5815
|
+
var eventTextAttribute = (record, key) => Schema7.decodeUnknownOption(TextValue)(record.attributes.find((attribute) => attribute.key === key)?.value).pipe(Option5.map((value) => value.stringValue), Option5.getOrNull);
|
|
4699
5816
|
|
|
4700
|
-
// ../../src/
|
|
5817
|
+
// ../../src/components/audit-log-table/react.tsx
|
|
4701
5818
|
import { jsx as jsx16, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
4702
5819
|
var translations = {
|
|
4703
5820
|
en: {
|