@krak-stack/registry 0.10.19 → 0.11.1
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 +105 -0
- package/README.md +28 -7
- package/dist/components/agent/index.d.ts +454 -0
- package/dist/components/agent/react.d.ts +55 -0
- package/dist/components/agent/react.js +2594 -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/animated-list/react.js +711 -0
- 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 +278 -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 +378 -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} +2195 -918
- 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/code-block/react.js +493 -0
- 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 +388 -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/copy-value/react.js +682 -0
- 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/danger-confirmation/react.js +550 -0
- 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} +2189 -906
- 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 +499 -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} +70 -17
- 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} +309 -83
- 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/email-composer/react.js +1354 -0
- 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 -19
- 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} +1057 -712
- 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/error-component/react.js +744 -0
- 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} +4 -4
- package/dist/components/{ui/form.js → form/react.js} +314 -84
- 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} +459 -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 +802 -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} +502 -141
- 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 +546 -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} +130 -30
- 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 +293 -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 +679 -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/rich-text-editor/react.js +1175 -0
- 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} +290 -31
- 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} +134 -29
- 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} +353 -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 +1252 -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} +493 -106
- 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 -70
- package/dist/components/ui/search-menu.d.ts +1 -36
- package/dist/components/ui/select.js +159 -0
- 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} +2475 -956
- 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 +358 -73
- package/dist/lib/docs.js +861 -293
- package/dist/lib/docs.server.js +342 -57
- package/dist/lib/documentation-toolkit.d.ts +4 -4
- package/dist/lib/documentation-toolkit.js +354 -69
- 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/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/index.js +110 -0
- package/dist/lib/email-composer/schema.d.ts +14 -0
- package/dist/lib/email-composer/schema.js +13 -0
- package/dist/lib/email-document/legacy-rich-text/editor.d.ts +70 -0
- package/dist/lib/email-document/legacy-rich-text/model.d.ts +19 -0
- package/dist/lib/email-document/legacy-rich-text/schema.d.ts +65 -0
- package/dist/lib/email-document/legacy-rich-text/tiptap.d.ts +39 -0
- package/dist/lib/email-document/model.d.ts +1 -1
- package/dist/lib/email-document/model.js +2 -2
- package/dist/lib/email-document/render.js +2 -2
- package/dist/lib/email-document/schema.js +1 -1
- 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 -19
- package/dist/lib/rich-text/model.js +79 -111
- package/dist/lib/rich-text/schema.d.ts +5 -55
- package/dist/lib/rich-text/schema.js +17 -36
- package/dist/lib/rich-text/tiptap.d.ts +12 -0
- package/dist/lib/webfetch-toolkit.d.ts +1 -1
- package/dist/services/agent/client/index.js +695 -179
- 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 +199 -137
- package/dist/components/support-dialog.js +0 -881
- package/dist/components/support.js +0 -881
- package/dist/components/ui/animated-list.js +0 -414
- 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/code-block.js +0 -221
- 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/copy-value.js +0 -352
- 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/danger-confirmation.js +0 -398
- 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/error-component.js +0 -387
- 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/rich-text-editor.js +0 -1135
- 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/lib/rich-text/dom.d.ts +0 -40
- package/dist/services/notification/persistence/drizzle.d.ts +0 -868
- package/dist/services/notification/persistence/drizzle.js +0 -214
- package/dist/services/notification/persistence/index.d.ts +0 -2
- package/dist/services/notification/persistence/index.js +0 -227
- package/dist/services/notification/persistence/schema.d.ts +0 -143
- package/dist/services/notification/persistence/schema.js +0 -118
- package/dist/services/webhooks/client/delivery-table.d.ts +0 -62
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
// ../../src/components/
|
|
2
|
-
import { useAtom, useAtomSet } from "@effect/atom-react";
|
|
1
|
+
// ../../src/components/data-table/react.tsx
|
|
3
2
|
import { ScrollArea as ScrollAreaPrimitive2 } from "@base-ui/react/scroll-area";
|
|
4
|
-
import { BrowserKeyValueStore } from "@effect/platform-browser";
|
|
5
3
|
import { useVirtualizer, useWindowVirtualizer } from "@tanstack/react-virtual";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { AsyncResult, Atom } from "effect/reactivity";
|
|
4
|
+
import { Formatter, Option as Option4, Schema as Schema6 } from "effect";
|
|
5
|
+
import { Component as Component3, View as View2 } from "effect/ui";
|
|
9
6
|
import {
|
|
10
7
|
ArrowDown,
|
|
11
8
|
ArrowUp,
|
|
@@ -30,15 +27,17 @@ import {
|
|
|
30
27
|
X
|
|
31
28
|
} from "lucide-react";
|
|
32
29
|
import {
|
|
33
|
-
createContext,
|
|
30
|
+
createContext as createContext2,
|
|
34
31
|
isValidElement,
|
|
35
|
-
useCallback,
|
|
36
|
-
useContext,
|
|
32
|
+
useCallback as useCallback2,
|
|
33
|
+
useContext as useContext2,
|
|
34
|
+
useEffect as useEffect2,
|
|
37
35
|
useId as useId2,
|
|
38
|
-
useLayoutEffect,
|
|
36
|
+
useLayoutEffect as useLayoutEffect2,
|
|
39
37
|
useMemo as useMemo2,
|
|
40
|
-
useRef,
|
|
41
|
-
useState
|
|
38
|
+
useRef as useRef2,
|
|
39
|
+
useState as useState2,
|
|
40
|
+
useSyncExternalStore as useSyncExternalStore2
|
|
42
41
|
} from "react";
|
|
43
42
|
import { createPortal } from "react-dom";
|
|
44
43
|
|
|
@@ -410,7 +409,7 @@ function SelectTrigger({
|
|
|
410
409
|
return /* @__PURE__ */ jsxs3(SelectPrimitive.Trigger, {
|
|
411
410
|
"data-slot": "select-trigger",
|
|
412
411
|
"data-size": size,
|
|
413
|
-
className: cn("flex w-fit items-center justify-between gap-1.5 rounded-md border
|
|
412
|
+
className: cn("border-input focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-placeholder:text-muted-foreground dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 flex w-fit items-center justify-between gap-1.5 rounded-md border bg-transparent py-2 pr-2 pl-2.5 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-3 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:ring-3 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", className),
|
|
414
413
|
...props,
|
|
415
414
|
children: [
|
|
416
415
|
children,
|
|
@@ -427,9 +426,9 @@ function SelectContent({
|
|
|
427
426
|
children,
|
|
428
427
|
side = "bottom",
|
|
429
428
|
sideOffset = 4,
|
|
430
|
-
align = "
|
|
429
|
+
align = "start",
|
|
431
430
|
alignOffset = 0,
|
|
432
|
-
alignItemWithTrigger =
|
|
431
|
+
alignItemWithTrigger = false,
|
|
433
432
|
...props
|
|
434
433
|
}) {
|
|
435
434
|
return /* @__PURE__ */ jsx8(SelectPrimitive.Portal, {
|
|
@@ -443,7 +442,7 @@ function SelectContent({
|
|
|
443
442
|
children: /* @__PURE__ */ jsxs3(SelectPrimitive.Popup, {
|
|
444
443
|
"data-slot": "select-content",
|
|
445
444
|
"data-align-trigger": alignItemWithTrigger,
|
|
446
|
-
className: cn("
|
|
445
|
+
className: cn("bg-popover text-popover-foreground ring-foreground/10 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 relative isolate z-50 max-h-(--available-height) w-(--anchor-width) max-w-(--available-width) min-w-0 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-md shadow-md ring-1 duration-100 data-[align-trigger=true]:animate-none", className),
|
|
447
446
|
...props,
|
|
448
447
|
children: [
|
|
449
448
|
/* @__PURE__ */ jsx8(SelectScrollUpButton, {}),
|
|
@@ -463,7 +462,7 @@ function SelectItem({
|
|
|
463
462
|
}) {
|
|
464
463
|
return /* @__PURE__ */ jsxs3(SelectPrimitive.Item, {
|
|
465
464
|
"data-slot": "select-item",
|
|
466
|
-
className: cn("relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none
|
|
465
|
+
className: cn("focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2", className),
|
|
467
466
|
...props,
|
|
468
467
|
children: [
|
|
469
468
|
/* @__PURE__ */ jsx8(SelectPrimitive.ItemText, {
|
|
@@ -487,7 +486,7 @@ function SelectScrollUpButton({
|
|
|
487
486
|
}) {
|
|
488
487
|
return /* @__PURE__ */ jsx8(SelectPrimitive.ScrollUpArrow, {
|
|
489
488
|
"data-slot": "select-scroll-up-button",
|
|
490
|
-
className: cn("top-0 z-10 flex w-full cursor-default items-center justify-center
|
|
489
|
+
className: cn("bg-popover top-0 z-10 flex w-full cursor-default items-center justify-center py-1 [&_svg:not([class*='size-'])]:size-4", className),
|
|
491
490
|
...props,
|
|
492
491
|
children: /* @__PURE__ */ jsx8(ChevronUpIcon, {})
|
|
493
492
|
});
|
|
@@ -498,44 +497,57 @@ function SelectScrollDownButton({
|
|
|
498
497
|
}) {
|
|
499
498
|
return /* @__PURE__ */ jsx8(SelectPrimitive.ScrollDownArrow, {
|
|
500
499
|
"data-slot": "select-scroll-down-button",
|
|
501
|
-
className: cn("bottom-0 z-10 flex w-full cursor-default items-center justify-center
|
|
500
|
+
className: cn("bg-popover bottom-0 z-10 flex w-full cursor-default items-center justify-center py-1 [&_svg:not([class*='size-'])]:size-4", className),
|
|
502
501
|
...props,
|
|
503
502
|
children: /* @__PURE__ */ jsx8(ChevronDownIcon, {})
|
|
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,104 +1228,1556 @@ 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
|
|
1250
|
+
}),
|
|
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
|
|
1267
|
+
}),
|
|
1268
|
+
Schema3.Struct({
|
|
1269
|
+
id: Schema3.NonEmptyString,
|
|
1270
|
+
kind: Schema3.Literal("values"),
|
|
1271
|
+
values: Schema3.NonEmptyArray(Schema3.String)
|
|
1272
|
+
})
|
|
1273
|
+
]).annotate({ identifier: "ColumnFilter" });
|
|
1274
|
+
var ColumnFiltersArray = Schema3.Array(ColumnFilter);
|
|
1275
|
+
var ColumnFilters = Schema3.declare(Schema3.is(ColumnFiltersArray), {
|
|
1276
|
+
identifier: "ColumnFilters",
|
|
1277
|
+
toCodec: () => Schema3.link()(ColumnFiltersArray, SchemaTransformation.passthrough()),
|
|
1278
|
+
toCodecStringTree: () => Schema3.link()(Schema3.fromJsonString(ColumnFiltersArray), SchemaTransformation.passthrough())
|
|
1279
|
+
});
|
|
1280
|
+
var DEFAULT_PAGE_SIZE = 100;
|
|
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)), {
|
|
1283
|
+
decode: SchemaGetter.withDefault(Effect.succeed(0)),
|
|
1284
|
+
encode: SchemaGetter.transformOptional(Option.filter((page) => page !== 0))
|
|
1285
|
+
})),
|
|
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 })), {
|
|
1287
|
+
decode: SchemaGetter.withDefault(Effect.succeed(DEFAULT_PAGE_SIZE)),
|
|
1288
|
+
encode: SchemaGetter.transformOptional(Option.filter((pageSize) => pageSize !== DEFAULT_PAGE_SIZE))
|
|
1289
|
+
})),
|
|
1290
|
+
globalFilter: Schema3.optional(Schema3.String),
|
|
1291
|
+
sort: Schema3.optional(SortParams),
|
|
1292
|
+
filters: Schema3.optional(ColumnFilters)
|
|
1293
|
+
}).annotate({
|
|
1294
|
+
identifier: "Query",
|
|
1295
|
+
title: "Query",
|
|
1296
|
+
description: "Zero-based page request parameters with optional filtering and sorting for list endpoints.",
|
|
1297
|
+
examples: [
|
|
1298
|
+
{
|
|
1299
|
+
page: 0,
|
|
1300
|
+
pageSize: DEFAULT_PAGE_SIZE,
|
|
1301
|
+
globalFilter: "housing",
|
|
1302
|
+
sort: [
|
|
1303
|
+
{ id: "publicName", direction: "desc" },
|
|
1304
|
+
{ id: "createdAt", direction: "asc" }
|
|
1305
|
+
]
|
|
1306
|
+
}
|
|
1307
|
+
]
|
|
1308
|
+
});
|
|
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({
|
|
1316
|
+
identifier: "PaginationMeta",
|
|
1317
|
+
title: "Pagination Metadata",
|
|
1318
|
+
description: "Pagination metadata returned with a paginated list response.",
|
|
1319
|
+
examples: [{ page: 0, pageSize: 20, total: 125, pageCount: 7 }]
|
|
1320
|
+
}));
|
|
1321
|
+
|
|
1322
|
+
// ../../src/lib/effect-ui-adapter/use-model.ts
|
|
1323
|
+
import { MessageLog as MessageLog2 } from "effect/ui";
|
|
1324
|
+
import {
|
|
1325
|
+
createContext,
|
|
1326
|
+
useCallback,
|
|
1327
|
+
useContext,
|
|
1328
|
+
useEffect,
|
|
1329
|
+
useLayoutEffect,
|
|
1330
|
+
useRef,
|
|
1331
|
+
useState,
|
|
1332
|
+
useSyncExternalStore
|
|
1333
|
+
} from "react";
|
|
1334
|
+
|
|
1335
|
+
// ../../src/lib/effect-ui-adapter/model-runtime.ts
|
|
1336
|
+
import { MessageLog, Renderer, View } from "effect/ui";
|
|
1337
|
+
import { BrowserHost, Html } from "effect/ui/html";
|
|
1338
|
+
import { Cause, Effect as Effect2, Fiber } from "effect";
|
|
1339
|
+
var node = () => ({ children: [] });
|
|
1340
|
+
var modelHost = (commit) => {
|
|
1341
|
+
const remove = (child) => {
|
|
1342
|
+
if (!child.parent)
|
|
1343
|
+
return;
|
|
1344
|
+
child.parent.children.splice(child.parent.children.indexOf(child), 1);
|
|
1345
|
+
delete child.parent;
|
|
1346
|
+
};
|
|
1347
|
+
return {
|
|
1348
|
+
createElement: node,
|
|
1349
|
+
createText: node,
|
|
1350
|
+
setText: () => {},
|
|
1351
|
+
setAttr: () => {},
|
|
1352
|
+
setProp: () => {},
|
|
1353
|
+
setEvents: () => {},
|
|
1354
|
+
insertBefore: (parent, child, before) => {
|
|
1355
|
+
if (child === before)
|
|
1356
|
+
return;
|
|
1357
|
+
remove(child);
|
|
1358
|
+
const index = before ? parent.children.indexOf(before) : parent.children.length;
|
|
1359
|
+
parent.children.splice(index, 0, child);
|
|
1360
|
+
child.parent = parent;
|
|
1361
|
+
},
|
|
1362
|
+
remove,
|
|
1363
|
+
parentOf: (child) => child.parent,
|
|
1364
|
+
nextOf: (child) => child.parent?.children[child.parent.children.indexOf(child) + 1],
|
|
1365
|
+
elements: ["html"],
|
|
1366
|
+
controlled: new Set,
|
|
1367
|
+
runsMounts: false,
|
|
1368
|
+
commit
|
|
1369
|
+
};
|
|
1370
|
+
};
|
|
1371
|
+
var mountModel = (component, props, publishSnapshot, messageLog, onEmit) => {
|
|
1372
|
+
let currentProps = props;
|
|
1373
|
+
let root;
|
|
1374
|
+
let active = true;
|
|
1375
|
+
let failure;
|
|
1376
|
+
const publish = () => {
|
|
1377
|
+
if (!active)
|
|
1378
|
+
return;
|
|
1379
|
+
if (failure) {
|
|
1380
|
+
publishSnapshot({ error: failure });
|
|
1381
|
+
return;
|
|
1382
|
+
}
|
|
1383
|
+
const current = root?.model();
|
|
1384
|
+
if (current !== undefined)
|
|
1385
|
+
publishSnapshot({ model: current });
|
|
1386
|
+
};
|
|
1387
|
+
const fiber = Effect2.runFork(Effect2.scoped(Effect2.gen(function* () {
|
|
1388
|
+
const mounted = yield* Renderer.mount(component, Effect2.succeed(props), node(), {
|
|
1389
|
+
head: false,
|
|
1390
|
+
onEmit,
|
|
1391
|
+
fallback: ({ cause }) => {
|
|
1392
|
+
failure = new Error("Effect UI root failed", {
|
|
1393
|
+
cause: Cause.squash(cause)
|
|
1394
|
+
});
|
|
1395
|
+
return View.text("");
|
|
1396
|
+
}
|
|
1397
|
+
});
|
|
1398
|
+
if (!active)
|
|
1399
|
+
return;
|
|
1400
|
+
root = mounted;
|
|
1401
|
+
if (props !== currentProps)
|
|
1402
|
+
mounted.setProps(currentProps);
|
|
1403
|
+
publish();
|
|
1404
|
+
return yield* Effect2.never;
|
|
1405
|
+
}).pipe(Effect2.provide(Renderer.layer(modelHost(publish))), Effect2.provideService(Html.Host, BrowserHost.htmlHost), Effect2.provideService(MessageLog.MessageLog, messageLog))));
|
|
1406
|
+
return {
|
|
1407
|
+
send: (message) => {
|
|
1408
|
+
root?.send(message);
|
|
1409
|
+
publish();
|
|
1410
|
+
},
|
|
1411
|
+
setProps: (next) => {
|
|
1412
|
+
currentProps = next;
|
|
1413
|
+
root?.setProps(next);
|
|
1414
|
+
},
|
|
1415
|
+
dispose: () => {
|
|
1416
|
+
active = false;
|
|
1417
|
+
root = undefined;
|
|
1418
|
+
Effect2.runFork(Fiber.interrupt(fiber));
|
|
1419
|
+
}
|
|
1420
|
+
};
|
|
1421
|
+
};
|
|
1422
|
+
|
|
1423
|
+
// ../../src/lib/effect-ui-adapter/use-model.ts
|
|
1424
|
+
"use client";
|
|
1425
|
+
var ModelMessageLogContext = createContext(undefined);
|
|
1426
|
+
var useModel = (component, props, options = {}) => {
|
|
1427
|
+
const contextLog = useContext(ModelMessageLogContext);
|
|
1428
|
+
const messageLog = options.messageLog ?? (contextLog === undefined ? MessageLog2.noop : contextLog);
|
|
1429
|
+
const [store] = useState(() => {
|
|
1430
|
+
const initial = { model: component.init(props).model };
|
|
1431
|
+
let snapshot = initial;
|
|
1432
|
+
const listeners = new Set;
|
|
1433
|
+
return {
|
|
1434
|
+
subscribe: (listener) => {
|
|
1435
|
+
listeners.add(listener);
|
|
1436
|
+
return () => {
|
|
1437
|
+
listeners.delete(listener);
|
|
1438
|
+
};
|
|
1439
|
+
},
|
|
1440
|
+
getSnapshot: () => snapshot,
|
|
1441
|
+
getServerSnapshot: () => initial,
|
|
1442
|
+
publish: (next) => {
|
|
1443
|
+
if ("model" in snapshot && "model" in next && Object.is(snapshot.model, next.model))
|
|
1444
|
+
return;
|
|
1445
|
+
if ("error" in snapshot && "error" in next && snapshot.error === next.error)
|
|
1446
|
+
return;
|
|
1447
|
+
snapshot = next;
|
|
1448
|
+
listeners.forEach((listener) => listener());
|
|
1449
|
+
}
|
|
1450
|
+
};
|
|
1451
|
+
});
|
|
1452
|
+
const snapshot = useSyncExternalStore(store.subscribe, store.getSnapshot, store.getServerSnapshot);
|
|
1453
|
+
const committed = useRef(props);
|
|
1454
|
+
const onEmit = useRef(options.onEmit);
|
|
1455
|
+
const runtime = useRef(undefined);
|
|
1456
|
+
const send = useCallback((message) => runtime.current?.send(message), []);
|
|
1457
|
+
useLayoutEffect(() => {
|
|
1458
|
+
onEmit.current = options.onEmit;
|
|
1459
|
+
committed.current = props;
|
|
1460
|
+
runtime.current?.setProps(props);
|
|
1461
|
+
}, [props, options.onEmit]);
|
|
1462
|
+
useEffect(() => {
|
|
1463
|
+
if (messageLog === null)
|
|
1464
|
+
return;
|
|
1465
|
+
const mounted = mountModel(component, committed.current, store.publish, messageLog, (event) => onEmit.current?.(event));
|
|
1466
|
+
runtime.current = mounted;
|
|
1467
|
+
return () => {
|
|
1468
|
+
runtime.current = undefined;
|
|
1469
|
+
mounted.dispose();
|
|
1470
|
+
};
|
|
1471
|
+
}, [component, messageLog, store]);
|
|
1472
|
+
if ("error" in snapshot)
|
|
1473
|
+
throw snapshot.error;
|
|
1474
|
+
return { model: snapshot.model, send };
|
|
1475
|
+
};
|
|
1476
|
+
|
|
1477
|
+
// ../../src/components/data-table/react.tsx
|
|
1478
|
+
import { useKrakstackLocale as useKrakstackLocale3 } from "@krak-stack/registry/krakstack-provider/react";
|
|
1479
|
+
|
|
1480
|
+
// ../../src/components/data-table/classes.ts
|
|
1481
|
+
var tableClasses = {
|
|
1482
|
+
selectionCell: "w-10 p-0 align-middle",
|
|
1483
|
+
selectionCenter: "grid place-items-center",
|
|
1484
|
+
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",
|
|
1485
|
+
selectedTrigger: "bg-primary text-primary-foreground hover:bg-primary/90 hover:text-primary-foreground",
|
|
1486
|
+
toolbar: "flex min-w-0 shrink-0 flex-wrap items-center gap-2",
|
|
1487
|
+
toolbarSearch: "relative min-w-0 flex-[1_1_12rem]",
|
|
1488
|
+
toolbarMenus: "w-max min-w-0 max-w-full",
|
|
1489
|
+
menubar: "h-auto w-full flex-wrap justify-start border border-input bg-transparent",
|
|
1490
|
+
cell: "overflow-hidden",
|
|
1491
|
+
cellContent: "min-w-0 wrap-anywhere",
|
|
1492
|
+
actionTrigger: "size-8 focus-visible:ring-inset",
|
|
1493
|
+
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))]",
|
|
1494
|
+
actionsAlign: "flex min-h-12 items-center justify-end pe-1",
|
|
1495
|
+
header: "relative h-12 p-0",
|
|
1496
|
+
stickyHeader: "sticky top-0 z-30 bg-background",
|
|
1497
|
+
stickyHeaderRule: "after:border-border after:pointer-events-none after:absolute after:inset-x-0 after:bottom-0 after:border-b",
|
|
1498
|
+
headerTrigger: "absolute inset-0 h-full w-full min-w-0 justify-start rounded-none px-2 pe-4 focus-visible:ring-inset",
|
|
1499
|
+
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",
|
|
1500
|
+
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",
|
|
1501
|
+
relationshipTrigger: "h-full w-full min-w-0 justify-between rounded-none px-2 text-start focus-visible:ring-inset",
|
|
1502
|
+
reference: "flex min-w-0 items-center gap-2",
|
|
1503
|
+
referenceAvatar: "relative grid size-8 shrink-0 place-items-center overflow-hidden bg-muted text-xs font-medium",
|
|
1504
|
+
referenceText: "flex min-w-0 flex-col leading-tight",
|
|
1505
|
+
group: "bg-muted/40 hover:bg-accent!",
|
|
1506
|
+
groupContent: "flex min-w-0 items-center gap-2 py-2 pe-1 ps-2",
|
|
1507
|
+
groupSticky: "sticky start-0 w-[100cqw] max-w-full",
|
|
1508
|
+
groupTrigger: "flex min-w-0 flex-1 cursor-pointer items-center gap-2 text-start font-medium",
|
|
1509
|
+
referenceName: "truncate font-medium",
|
|
1510
|
+
referenceDescription: "text-muted-foreground truncate text-xs"
|
|
1511
|
+
};
|
|
1512
|
+
var resolveTableClasses = (overrides) => ({
|
|
1513
|
+
...tableClasses,
|
|
1514
|
+
...overrides
|
|
1515
|
+
});
|
|
1516
|
+
|
|
1517
|
+
// ../../src/components/data-table/index.ts
|
|
1518
|
+
import { DateTime as DateTime3, Effect as Effect3, Option as Option3, Redacted, Schema as Schema5, Stream } from "effect";
|
|
1519
|
+
import { Csv } from "effect/encoding";
|
|
1520
|
+
import { Command, Component as Component2, Subscription, UiSchema as UiSchema2 } from "effect/ui";
|
|
1521
|
+
|
|
1522
|
+
// ../../src/components/data-table/schema.ts
|
|
1523
|
+
import { DateTime as DateTime2, Option as Option2, Schema as Schema4, Struct as Struct2, Tuple } from "effect";
|
|
1524
|
+
var TableClassesOverridesSchema = Schema4.Record(Schema4.Literals(Struct2.keys(tableClasses)), Schema4.optionalKey(Schema4.String)).annotate({ identifier: "TableClassesOverrides" });
|
|
1525
|
+
var DataTableCommonPropsSchema = Schema4.Struct({
|
|
1526
|
+
classes: Schema4.optional(TableClassesOverridesSchema),
|
|
1527
|
+
className: Schema4.optionalKey(Schema4.String),
|
|
1528
|
+
locale: Schema4.optionalKey(Schema4.String)
|
|
1529
|
+
}).annotate({ identifier: "DataTableCommonProps" });
|
|
1530
|
+
var DataTableSortSchema = Schema4.Struct({
|
|
1531
|
+
id: Schema4.NonEmptyString,
|
|
1532
|
+
direction: Schema4.Literals(["asc", "desc"])
|
|
1533
|
+
}).annotate({ identifier: "DataTableSort" });
|
|
1534
|
+
var queryFields = {
|
|
1535
|
+
page: Schema4.Int.check(Schema4.isGreaterThanOrEqualTo(0)),
|
|
1536
|
+
pageSize: Schema4.Int.check(Schema4.isBetween({ minimum: 1, maximum: 100 })),
|
|
1537
|
+
globalFilter: Schema4.optional(Schema4.String),
|
|
1538
|
+
sort: Schema4.optional(Schema4.Array(DataTableSortSchema)),
|
|
1539
|
+
filters: Schema4.optional(Schema4.Array(ColumnFilter))
|
|
1540
|
+
};
|
|
1541
|
+
var DataTableQuerySchema = Schema4.Struct(queryFields).annotate({
|
|
1542
|
+
identifier: "DataTableQuery"
|
|
1543
|
+
});
|
|
1544
|
+
var PageSizes = Schema4.NonEmptyArray(Schema4.Int.check(Schema4.isBetween({ minimum: 1, maximum: 100 })));
|
|
1545
|
+
var DataTableCommonFeaturesSchema = Schema4.Struct({
|
|
1546
|
+
search: Schema4.optionalKey(Schema4.Boolean),
|
|
1547
|
+
filtering: Schema4.optionalKey(Schema4.Boolean),
|
|
1548
|
+
sorting: Schema4.optionalKey(Schema4.Boolean),
|
|
1549
|
+
columnVisibility: Schema4.optionalKey(Schema4.Boolean)
|
|
1550
|
+
});
|
|
1551
|
+
var PaginationSchema = Schema4.Union([
|
|
1552
|
+
Schema4.Struct({
|
|
1553
|
+
mode: Schema4.optionalKey(Schema4.Literal("client")),
|
|
1554
|
+
pageSizes: Schema4.optionalKey(PageSizes)
|
|
1555
|
+
}).annotate({ identifier: "DataTableClientPagination" }),
|
|
1556
|
+
Schema4.Struct({
|
|
1557
|
+
mode: Schema4.Literal("server"),
|
|
1558
|
+
rowCount: Schema4.Int.check(Schema4.isGreaterThanOrEqualTo(0)),
|
|
1559
|
+
pageSizes: Schema4.optionalKey(PageSizes)
|
|
1560
|
+
}).annotate({ identifier: "DataTableServerPagination" })
|
|
1561
|
+
]);
|
|
1562
|
+
var DataTableItemSchema = Schema4.Struct({
|
|
1563
|
+
value: Schema4.NonEmptyString,
|
|
1564
|
+
label: Schema4.String
|
|
1565
|
+
}).annotate({ identifier: "DataTableItem" });
|
|
1566
|
+
var DataTableReferenceSchema = Schema4.Struct({
|
|
1567
|
+
label: Schema4.String,
|
|
1568
|
+
description: Schema4.optionalKey(Schema4.String),
|
|
1569
|
+
imageSrc: Schema4.optionalKey(Schema4.NullOr(Schema4.String))
|
|
1570
|
+
}).annotate({ identifier: "DataTableReference" });
|
|
1571
|
+
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" });
|
|
1572
|
+
var isCalendarDate = Schema4.is(CalendarDate);
|
|
1573
|
+
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" });
|
|
1574
|
+
var DataTableDateInputSchema = Schema4.Union([
|
|
1575
|
+
Schema4.Date,
|
|
1576
|
+
Schema4.Int,
|
|
1577
|
+
CalendarDate,
|
|
1578
|
+
InstantString
|
|
1579
|
+
]).annotate({ identifier: "DataTableDateInput" });
|
|
1580
|
+
var DateStyle = Schema4.Literals(["full", "long", "medium", "short"]);
|
|
1581
|
+
var DataTableDateFormatSchema = Schema4.Struct({
|
|
1582
|
+
locale: Schema4.optionalKey(Schema4.String),
|
|
1583
|
+
timeZone: Schema4.optionalKey(Schema4.String),
|
|
1584
|
+
dateStyle: Schema4.optionalKey(DateStyle),
|
|
1585
|
+
exportFormat: Schema4.optionalKey(Schema4.Literals(["iso", "formatted"]))
|
|
1586
|
+
}).annotate({ identifier: "DataTableDateFormat" });
|
|
1587
|
+
var DataTableDateTimeFormatSchema = Schema4.Struct({
|
|
1588
|
+
...DataTableDateFormatSchema.fields,
|
|
1589
|
+
timeStyle: Schema4.optionalKey(DateStyle),
|
|
1590
|
+
hour12: Schema4.optionalKey(Schema4.Boolean)
|
|
1591
|
+
}).annotate({ identifier: "DataTableDateTimeFormat" });
|
|
1592
|
+
var DataTableCellValueSchema = Schema4.NullOr(Schema4.Union([
|
|
1593
|
+
Schema4.String,
|
|
1594
|
+
Schema4.Boolean,
|
|
1595
|
+
Schema4.Finite,
|
|
1596
|
+
Schema4.Array(DataTableItemSchema),
|
|
1597
|
+
DataTableReferenceSchema
|
|
1598
|
+
])).annotate({ identifier: "DataTableCellValue" });
|
|
1599
|
+
var DataTableActionSchema = Schema4.Struct({
|
|
1600
|
+
id: Schema4.NonEmptyString,
|
|
1601
|
+
name: Schema4.String,
|
|
1602
|
+
variant: Schema4.optionalKey(Schema4.Literals(["default", "destructive"])),
|
|
1603
|
+
disabled: Schema4.optionalKey(Schema4.Boolean)
|
|
1604
|
+
}).annotate({ identifier: "DataTableAction" });
|
|
1605
|
+
var DataTableRowSchema = Schema4.Struct({
|
|
1606
|
+
id: Schema4.NonEmptyString,
|
|
1607
|
+
label: Schema4.String,
|
|
1608
|
+
cells: Schema4.Record(Schema4.String, DataTableCellValueSchema),
|
|
1609
|
+
actions: Schema4.optionalKey(Schema4.Array(DataTableActionSchema)),
|
|
1610
|
+
primaryActionId: Schema4.optionalKey(Schema4.String),
|
|
1611
|
+
groups: Schema4.optionalKey(Schema4.Record(Schema4.String, Schema4.Array(Schema4.String))),
|
|
1612
|
+
selectable: Schema4.optionalKey(Schema4.Boolean),
|
|
1613
|
+
disabledColumnIds: Schema4.optionalKey(Schema4.Array(Schema4.String))
|
|
1614
|
+
}).annotate({ identifier: "DataTableRow" });
|
|
1615
|
+
var column = {
|
|
1616
|
+
id: Schema4.NonEmptyString,
|
|
1617
|
+
headerName: Schema4.String,
|
|
1618
|
+
sortable: Schema4.optionalKey(Schema4.Boolean),
|
|
1619
|
+
hideable: Schema4.optionalKey(Schema4.Boolean),
|
|
1620
|
+
export: Schema4.optionalKey(Schema4.Boolean),
|
|
1621
|
+
width: Schema4.optionalKey(Schema4.Number),
|
|
1622
|
+
minWidth: Schema4.optionalKey(Schema4.Number),
|
|
1623
|
+
maxWidth: Schema4.optionalKey(Schema4.Number),
|
|
1624
|
+
resizable: Schema4.optionalKey(Schema4.Boolean),
|
|
1625
|
+
truncate: Schema4.optionalKey(Schema4.Boolean),
|
|
1626
|
+
searchable: Schema4.optionalKey(Schema4.Boolean),
|
|
1627
|
+
filterable: Schema4.optionalKey(Schema4.Boolean),
|
|
1628
|
+
emptyLabel: Schema4.optionalKey(Schema4.String),
|
|
1629
|
+
nulls: Schema4.optionalKey(Schema4.Literals(["first", "last"]))
|
|
1630
|
+
};
|
|
1631
|
+
var DataTableFieldSchema = Schema4.Union([
|
|
1632
|
+
Schema4.Struct({ ...column, type: Schema4.Literal("text") }),
|
|
1633
|
+
Schema4.Struct({
|
|
1634
|
+
...column,
|
|
1635
|
+
type: Schema4.Literal("number"),
|
|
1636
|
+
typeOptions: Schema4.optionalKey(Schema4.Struct({
|
|
1637
|
+
locale: Schema4.optionalKey(Schema4.String),
|
|
1638
|
+
style: Schema4.optionalKey(Schema4.Literals(["decimal", "percent", "currency", "unit"])),
|
|
1639
|
+
currency: Schema4.optionalKey(Schema4.String),
|
|
1640
|
+
unit: Schema4.optionalKey(Schema4.String),
|
|
1641
|
+
notation: Schema4.optionalKey(Schema4.Literals(["standard", "scientific", "engineering", "compact"])),
|
|
1642
|
+
minimumFractionDigits: Schema4.optionalKey(Schema4.Int.check(Schema4.isBetween({ minimum: 0, maximum: 20 }))),
|
|
1643
|
+
maximumFractionDigits: Schema4.optionalKey(Schema4.Int.check(Schema4.isBetween({ minimum: 0, maximum: 20 }))),
|
|
1644
|
+
exportFormat: Schema4.optionalKey(Schema4.Literals(["raw", "formatted"]))
|
|
1645
|
+
}).annotate({ identifier: "DataTableNumberFormat" }))
|
|
1646
|
+
}),
|
|
1647
|
+
Schema4.Struct({ ...column, type: Schema4.Literal("reference") }),
|
|
1648
|
+
Schema4.Struct({
|
|
1649
|
+
...column,
|
|
1650
|
+
type: Schema4.Literal("date"),
|
|
1651
|
+
typeOptions: Schema4.optionalKey(DataTableDateFormatSchema)
|
|
1652
|
+
}),
|
|
1653
|
+
Schema4.Struct({
|
|
1654
|
+
...column,
|
|
1655
|
+
type: Schema4.Literal("dateTime"),
|
|
1656
|
+
typeOptions: Schema4.optionalKey(DataTableDateTimeFormatSchema)
|
|
1657
|
+
}),
|
|
1658
|
+
Schema4.Struct({
|
|
1659
|
+
...column,
|
|
1660
|
+
type: Schema4.Literal("boolean"),
|
|
1661
|
+
editable: Schema4.optionalKey(Schema4.Boolean),
|
|
1662
|
+
typeOptions: Schema4.optionalKey(Schema4.Struct({
|
|
1663
|
+
trueLabel: Schema4.optionalKey(Schema4.String),
|
|
1664
|
+
falseLabel: Schema4.optionalKey(Schema4.String),
|
|
1665
|
+
exportFormat: Schema4.optionalKey(Schema4.Literals(["raw", "formatted"]))
|
|
1666
|
+
}).annotate({ identifier: "DataTableBooleanFormat" }))
|
|
1667
|
+
}),
|
|
1668
|
+
Schema4.Struct({
|
|
1669
|
+
...column,
|
|
1670
|
+
type: Schema4.Literal("list"),
|
|
1671
|
+
filterOptions: Schema4.optionalKey(Schema4.Array(DataTableItemSchema)),
|
|
1672
|
+
options: Schema4.optionalKey(Schema4.Array(DataTableItemSchema)),
|
|
1673
|
+
allowRemove: Schema4.optionalKey(Schema4.Boolean),
|
|
1674
|
+
itemActions: Schema4.optionalKey(Schema4.Array(DataTableActionSchema)),
|
|
1675
|
+
display: Schema4.optionalKey(Schema4.Literals(["list", "icon"])),
|
|
1676
|
+
visibleCount: Schema4.optionalKey(Schema4.Int.check(Schema4.isGreaterThanOrEqualTo(0))),
|
|
1677
|
+
actionsLabel: Schema4.optionalKey(Schema4.String),
|
|
1678
|
+
manageLabel: Schema4.optionalKey(Schema4.String)
|
|
1679
|
+
})
|
|
1680
|
+
]).annotate({ identifier: "DataTableField" });
|
|
1681
|
+
var DataTableColumnSchema = DataTableFieldSchema.mapMembers(Tuple.map(Schema4.fieldsAssign({
|
|
1682
|
+
fields: Schema4.optionalKey(Schema4.Array(DataTableFieldSchema))
|
|
1683
|
+
}))).annotate({ identifier: "DataTableColumn" });
|
|
1684
|
+
var DataTableLabelsSchema = Schema4.Struct({
|
|
1685
|
+
actions: Schema4.optionalKey(Schema4.String),
|
|
1686
|
+
addItem: Schema4.optionalKey(Schema4.String),
|
|
1687
|
+
listDetails: Schema4.optionalKey(Schema4.String),
|
|
1688
|
+
empty: Schema4.optionalKey(Schema4.String),
|
|
1689
|
+
filters: Schema4.optionalKey(Schema4.String),
|
|
1690
|
+
filtersClear: Schema4.optionalKey(Schema4.String),
|
|
1691
|
+
filterColumn: Schema4.optionalKey(Schema4.String),
|
|
1692
|
+
filterClear: Schema4.optionalKey(Schema4.String),
|
|
1693
|
+
filterApply: Schema4.optionalKey(Schema4.String),
|
|
1694
|
+
filterValue: Schema4.optionalKey(Schema4.String),
|
|
1695
|
+
filterOperator: Schema4.optionalKey(Schema4.String),
|
|
1696
|
+
filterContains: Schema4.optionalKey(Schema4.String),
|
|
1697
|
+
filterEquals: Schema4.optionalKey(Schema4.String),
|
|
1698
|
+
filterStartsWith: Schema4.optionalKey(Schema4.String),
|
|
1699
|
+
filterEndsWith: Schema4.optionalKey(Schema4.String),
|
|
1700
|
+
filterMin: Schema4.optionalKey(Schema4.String),
|
|
1701
|
+
filterMax: Schema4.optionalKey(Schema4.String),
|
|
1702
|
+
filterFrom: Schema4.optionalKey(Schema4.String),
|
|
1703
|
+
filterTo: Schema4.optionalKey(Schema4.String),
|
|
1704
|
+
filterTrue: Schema4.optionalKey(Schema4.String),
|
|
1705
|
+
filterFalse: Schema4.optionalKey(Schema4.String),
|
|
1706
|
+
filterInvalid: Schema4.optionalKey(Schema4.String),
|
|
1707
|
+
columns: Schema4.optionalKey(Schema4.String),
|
|
1708
|
+
sortBy: Schema4.optionalKey(Schema4.String),
|
|
1709
|
+
hideColumn: Schema4.optionalKey(Schema4.String),
|
|
1710
|
+
loading: Schema4.optionalKey(Schema4.String),
|
|
1711
|
+
removeItem: Schema4.optionalKey(Schema4.String),
|
|
1712
|
+
search: Schema4.optionalKey(Schema4.String),
|
|
1713
|
+
selectAllRows: Schema4.optionalKey(Schema4.String),
|
|
1714
|
+
selectRow: Schema4.optionalKey(Schema4.String),
|
|
1715
|
+
selected: Schema4.optionalKey(Schema4.String),
|
|
1716
|
+
sortAsc: Schema4.optionalKey(Schema4.String),
|
|
1717
|
+
sortDesc: Schema4.optionalKey(Schema4.String),
|
|
1718
|
+
sortClear: Schema4.optionalKey(Schema4.String),
|
|
1719
|
+
view: Schema4.optionalKey(Schema4.String),
|
|
1720
|
+
tableView: Schema4.optionalKey(Schema4.String),
|
|
1721
|
+
galleryView: Schema4.optionalKey(Schema4.String),
|
|
1722
|
+
groupBy: Schema4.optionalKey(Schema4.String),
|
|
1723
|
+
export: Schema4.optionalKey(Schema4.String),
|
|
1724
|
+
exportFailed: Schema4.optionalKey(Schema4.String),
|
|
1725
|
+
moveUp: Schema4.optionalKey(Schema4.String),
|
|
1726
|
+
moveDown: Schema4.optionalKey(Schema4.String),
|
|
1727
|
+
reorder: Schema4.optionalKey(Schema4.String),
|
|
1728
|
+
refresh: Schema4.optionalKey(Schema4.String),
|
|
1729
|
+
resize: Schema4.optionalKey(Schema4.String)
|
|
1730
|
+
}).annotate({ identifier: "DataTableLabels" });
|
|
1731
|
+
var DataTableViewSchema = Schema4.Literals(["table", "gallery"]);
|
|
1732
|
+
var DataTablePreferencesSchema = Schema4.Struct({
|
|
1733
|
+
columnVisibility: Schema4.Record(Schema4.String, Schema4.Boolean),
|
|
1734
|
+
columnSizing: Schema4.Record(Schema4.String, Schema4.Finite),
|
|
1735
|
+
grouping: Schema4.optionalKey(Schema4.Array(Schema4.String)),
|
|
1736
|
+
view: DataTableViewSchema
|
|
1737
|
+
}).annotate({ identifier: "DataTablePersistedUiState" });
|
|
1738
|
+
var GroupField = Schema4.Struct({
|
|
1739
|
+
id: Schema4.NonEmptyString,
|
|
1740
|
+
label: Schema4.String,
|
|
1741
|
+
actionsLabel: Schema4.optionalKey(Schema4.String),
|
|
1742
|
+
groups: Schema4.optionalKey(Schema4.Array(Schema4.Struct({
|
|
1743
|
+
id: Schema4.String,
|
|
1744
|
+
label: Schema4.String,
|
|
1745
|
+
empty: Schema4.optionalKey(Schema4.String)
|
|
1746
|
+
}).annotate({ identifier: "DataTableGroupLabel" }))),
|
|
1747
|
+
actions: Schema4.optionalKey(Schema4.Array(DataTableActionSchema)),
|
|
1748
|
+
movable: Schema4.optionalKey(Schema4.Boolean)
|
|
1749
|
+
}).annotate({ identifier: "DataTableGroupField" });
|
|
1750
|
+
var DataTablePropsSchema = Schema4.Struct({
|
|
1751
|
+
...DataTableCommonPropsSchema.fields,
|
|
1752
|
+
label: Schema4.String,
|
|
1753
|
+
rowData: Schema4.Array(DataTableRowSchema),
|
|
1754
|
+
rowActivation: Schema4.optionalKey(Schema4.Boolean),
|
|
1755
|
+
columnDefs: Schema4.Array(DataTableColumnSchema),
|
|
1756
|
+
status: Schema4.optionalKey(Schema4.Struct({
|
|
1757
|
+
loading: Schema4.optionalKey(Schema4.Boolean),
|
|
1758
|
+
empty: Schema4.optionalKey(Schema4.String),
|
|
1759
|
+
error: Schema4.optionalKey(Schema4.String)
|
|
1760
|
+
})),
|
|
1761
|
+
sort: Schema4.optionalKey(Schema4.Array(DataTableSortSchema)),
|
|
1762
|
+
sortMode: Schema4.optionalKey(Schema4.Literals(["client", "server"])),
|
|
1763
|
+
search: Schema4.optionalKey(Schema4.Boolean),
|
|
1764
|
+
columnFilters: Schema4.optionalKey(Schema4.Boolean),
|
|
1765
|
+
state: Schema4.optionalKey(DataTableQuerySchema),
|
|
1766
|
+
features: Schema4.optionalKey(Schema4.Struct({
|
|
1767
|
+
...DataTableCommonFeaturesSchema.fields,
|
|
1768
|
+
pagination: Schema4.optionalKey(Schema4.Union([Schema4.Literal(false), PaginationSchema])),
|
|
1769
|
+
grouping: Schema4.optionalKey(Schema4.Struct({
|
|
1770
|
+
initial: Schema4.optionalKey(Schema4.Array(Schema4.String)),
|
|
1771
|
+
fields: Schema4.Array(GroupField)
|
|
1772
|
+
}).annotate({ identifier: "DataTableGrouping" })),
|
|
1773
|
+
gallery: Schema4.optionalKey(Schema4.Struct({
|
|
1774
|
+
name: Schema4.String,
|
|
1775
|
+
description: Schema4.optionalKey(Schema4.String),
|
|
1776
|
+
image: Schema4.optionalKey(Schema4.String),
|
|
1777
|
+
tags: Schema4.optionalKey(Schema4.Array(Schema4.String))
|
|
1778
|
+
}).annotate({ identifier: "DataTableGallery" })),
|
|
1779
|
+
reordering: Schema4.optionalKey(Schema4.Boolean),
|
|
1780
|
+
export: Schema4.optionalKey(Schema4.Struct({
|
|
1781
|
+
baseName: Schema4.String,
|
|
1782
|
+
scope: Schema4.optionalKey(Schema4.Literals(["filteredRows", "currentPage"])),
|
|
1783
|
+
builtIn: Schema4.optionalKey(Schema4.Boolean),
|
|
1784
|
+
actions: Schema4.optionalKey(Schema4.Array(DataTableActionSchema)),
|
|
1785
|
+
pending: Schema4.optionalKey(Schema4.Boolean),
|
|
1786
|
+
failed: Schema4.optionalKey(Schema4.Boolean)
|
|
1787
|
+
}).annotate({ identifier: "DataTableExport" })),
|
|
1788
|
+
refresh: Schema4.optionalKey(Schema4.Boolean),
|
|
1789
|
+
virtualization: Schema4.optionalKey(Schema4.Union([
|
|
1790
|
+
Schema4.Boolean,
|
|
1791
|
+
Schema4.Struct({
|
|
1792
|
+
scroll: Schema4.optionalKey(Schema4.Literals(["table", "internal", "page"])),
|
|
1793
|
+
height: Schema4.optionalKey(Schema4.Int.check(Schema4.isGreaterThan(0))),
|
|
1794
|
+
estimateRowHeight: Schema4.optionalKey(Schema4.Int.check(Schema4.isGreaterThan(0))),
|
|
1795
|
+
overscan: Schema4.optionalKey(Schema4.Int.check(Schema4.isGreaterThanOrEqualTo(0)))
|
|
1796
|
+
}).annotate({ identifier: "DataTableVirtualization" })
|
|
1797
|
+
]))
|
|
1798
|
+
}).annotate({ identifier: "DataTableHtmlFeatures" })),
|
|
1799
|
+
initialState: Schema4.optionalKey(Schema4.Struct({
|
|
1800
|
+
...queryFields,
|
|
1801
|
+
page: Schema4.optional(queryFields.page),
|
|
1802
|
+
pageSize: Schema4.optional(queryFields.pageSize),
|
|
1803
|
+
columnVisibility: Schema4.optionalKey(Schema4.Record(Schema4.String, Schema4.Boolean)),
|
|
1804
|
+
view: Schema4.optionalKey(DataTableViewSchema)
|
|
1805
|
+
}).annotate({ identifier: "DataTableInitialQuery" })),
|
|
1806
|
+
pagination: Schema4.optionalKey(PaginationSchema),
|
|
1807
|
+
selection: Schema4.optionalKey(Schema4.Struct({
|
|
1808
|
+
selectedRowIds: Schema4.optionalKey(Schema4.Array(Schema4.String)),
|
|
1809
|
+
bulkActionsLabel: Schema4.optionalKey(Schema4.String),
|
|
1810
|
+
bulkActions: Schema4.optionalKey(Schema4.Array(DataTableActionSchema))
|
|
1811
|
+
})),
|
|
1812
|
+
messages: Schema4.optionalKey(Schema4.Record(Schema4.String, DataTableLabelsSchema))
|
|
1813
|
+
}).annotate({ identifier: "DataTableProps" });
|
|
1814
|
+
var DataTableFilterDraftSchema = Schema4.Struct({
|
|
1815
|
+
id: Schema4.String,
|
|
1816
|
+
primary: Schema4.String,
|
|
1817
|
+
secondary: Schema4.String,
|
|
1818
|
+
operator: TextFilterOperator,
|
|
1819
|
+
values: Schema4.Array(Schema4.String)
|
|
1820
|
+
}).annotate({ identifier: "DataTableFilterDraft" });
|
|
1821
|
+
|
|
1822
|
+
// ../../src/components/data-table/index.ts
|
|
1823
|
+
var defaultMessages = {
|
|
1824
|
+
en: {
|
|
1825
|
+
actions: "Actions",
|
|
1826
|
+
addItem: "Add item...",
|
|
1827
|
+
listDetails: "View all items",
|
|
1828
|
+
empty: "No results.",
|
|
1829
|
+
filters: "Filters",
|
|
1830
|
+
filtersClear: "Clear all filters",
|
|
1831
|
+
filterColumn: "Column",
|
|
1832
|
+
filterClear: "Clear filter",
|
|
1833
|
+
filterApply: "Apply filter",
|
|
1834
|
+
filterValue: "Value",
|
|
1835
|
+
filterOperator: "Operator",
|
|
1836
|
+
filterContains: "Contains",
|
|
1837
|
+
filterEquals: "Equals",
|
|
1838
|
+
filterStartsWith: "Starts with",
|
|
1839
|
+
filterEndsWith: "Ends with",
|
|
1840
|
+
filterMin: "Minimum",
|
|
1841
|
+
filterMax: "Maximum",
|
|
1842
|
+
filterFrom: "From (UTC)",
|
|
1843
|
+
filterTo: "To (UTC)",
|
|
1844
|
+
filterTrue: "True",
|
|
1845
|
+
filterFalse: "False",
|
|
1846
|
+
filterInvalid: "Enter a valid filter. Ranges must be in ascending order.",
|
|
1847
|
+
columns: "Columns",
|
|
1848
|
+
sortBy: "Sort by",
|
|
1849
|
+
hideColumn: "Hide column",
|
|
1850
|
+
loading: "Loading...",
|
|
1851
|
+
removeItem: "Remove",
|
|
1852
|
+
search: "Search",
|
|
1853
|
+
selectAllRows: "Select all rows on this page",
|
|
1854
|
+
selectRow: "Select row",
|
|
1855
|
+
selected: "Selected",
|
|
1856
|
+
sortAsc: "Ascending",
|
|
1857
|
+
sortDesc: "Descending",
|
|
1858
|
+
sortClear: "Clear sorting",
|
|
1859
|
+
view: "View",
|
|
1860
|
+
tableView: "Table",
|
|
1861
|
+
galleryView: "Gallery",
|
|
1862
|
+
groupBy: "Group by",
|
|
1863
|
+
export: "Export",
|
|
1864
|
+
exportFailed: "Export failed. Please try again.",
|
|
1865
|
+
refresh: "Refresh",
|
|
1866
|
+
moveUp: "Move up",
|
|
1867
|
+
moveDown: "Move down",
|
|
1868
|
+
reorder: "Drag to reorder",
|
|
1869
|
+
resize: "Resize column"
|
|
1870
|
+
},
|
|
1871
|
+
fr: {
|
|
1872
|
+
actions: "Actions",
|
|
1873
|
+
addItem: "Ajouter un élément...",
|
|
1874
|
+
listDetails: "Afficher tous les éléments",
|
|
1875
|
+
empty: "Aucun résultat.",
|
|
1876
|
+
filters: "Filtres",
|
|
1877
|
+
filtersClear: "Effacer tous les filtres",
|
|
1878
|
+
filterColumn: "Colonne",
|
|
1879
|
+
filterClear: "Effacer le filtre",
|
|
1880
|
+
filterApply: "Appliquer le filtre",
|
|
1881
|
+
filterValue: "Valeur",
|
|
1882
|
+
filterOperator: "Opérateur",
|
|
1883
|
+
filterContains: "Contient",
|
|
1884
|
+
filterEquals: "Égal à",
|
|
1885
|
+
filterStartsWith: "Commence par",
|
|
1886
|
+
filterEndsWith: "Se termine par",
|
|
1887
|
+
filterMin: "Minimum",
|
|
1888
|
+
filterMax: "Maximum",
|
|
1889
|
+
filterFrom: "Du (UTC)",
|
|
1890
|
+
filterTo: "Au (UTC)",
|
|
1891
|
+
filterTrue: "Vrai",
|
|
1892
|
+
filterFalse: "Faux",
|
|
1893
|
+
filterInvalid: "Saisissez un filtre valide. Les bornes doivent être dans l’ordre croissant.",
|
|
1894
|
+
columns: "Colonnes",
|
|
1895
|
+
sortBy: "Trier par",
|
|
1896
|
+
hideColumn: "Masquer la colonne",
|
|
1897
|
+
loading: "Chargement...",
|
|
1898
|
+
removeItem: "Retirer",
|
|
1899
|
+
search: "Rechercher",
|
|
1900
|
+
selectAllRows: "Sélectionner toutes les lignes de cette page",
|
|
1901
|
+
selectRow: "Sélectionner la ligne",
|
|
1902
|
+
selected: "Sélectionnés",
|
|
1903
|
+
sortAsc: "Croissant",
|
|
1904
|
+
sortDesc: "Décroissant",
|
|
1905
|
+
sortClear: "Effacer le tri",
|
|
1906
|
+
view: "Affichage",
|
|
1907
|
+
tableView: "Tableau",
|
|
1908
|
+
galleryView: "Galerie",
|
|
1909
|
+
groupBy: "Grouper par",
|
|
1910
|
+
export: "Exporter",
|
|
1911
|
+
exportFailed: "L’exportation a échoué. Veuillez réessayer.",
|
|
1912
|
+
refresh: "Rafraîchir",
|
|
1913
|
+
moveUp: "Déplacer vers le haut",
|
|
1914
|
+
moveDown: "Déplacer vers le bas",
|
|
1915
|
+
reorder: "Glisser pour réorganiser",
|
|
1916
|
+
resize: "Redimensionner la colonne"
|
|
1917
|
+
}
|
|
1918
|
+
};
|
|
1919
|
+
var compareTableText = (left, right, locale) => left.localeCompare(right, locale, { numeric: true, sensitivity: "base" });
|
|
1920
|
+
var isTableText = Schema5.is(Schema5.String);
|
|
1921
|
+
var isTableNumber = Schema5.is(Schema5.Finite);
|
|
1922
|
+
var isTableBoolean = Schema5.is(Schema5.Boolean);
|
|
1923
|
+
var isTableReference = Schema5.is(DataTableReferenceSchema);
|
|
1924
|
+
var isTableList = Schema5.is(Schema5.Array(DataTableItemSchema));
|
|
1925
|
+
var tableInitials = (label) => label.trim().split(/\s+/).slice(0, 2).map((word) => word.slice(0, 1)).join("").toLocaleUpperCase();
|
|
1926
|
+
var formatNumberValue = (value, options, defaultLocale = "en") => {
|
|
1927
|
+
const { locale, ...format } = options ?? {};
|
|
1928
|
+
return new Intl.NumberFormat(locale ?? defaultLocale, format).format(value);
|
|
1929
|
+
};
|
|
1930
|
+
var tableBooleanLabel = (value, options) => (value ? options?.trueLabel : options?.falseLabel) ?? String(value);
|
|
1931
|
+
var decodeDateInput = Schema5.decodeUnknownOption(DataTableDateInputSchema);
|
|
1932
|
+
var resolveDate = (value, type) => Option3.getOrUndefined(Option3.flatMap(decodeDateInput(value), (input) => {
|
|
1933
|
+
const calendarOnly = isCalendarDate(input);
|
|
1934
|
+
if (calendarOnly && type === "dateTime")
|
|
1935
|
+
return Option3.none();
|
|
1936
|
+
return Option3.map(DateTime3.make(input), (instant) => ({
|
|
1937
|
+
instant,
|
|
1938
|
+
calendarOnly
|
|
1939
|
+
}));
|
|
1940
|
+
}));
|
|
1941
|
+
var formatDateValue = (date, column, locale = "en") => DateTime3.format(date.instant, {
|
|
1942
|
+
locale: column.typeOptions?.locale ?? locale,
|
|
1943
|
+
timeZone: date.calendarOnly ? "UTC" : column.typeOptions?.timeZone ?? "UTC",
|
|
1944
|
+
dateStyle: column.typeOptions?.dateStyle ?? "medium",
|
|
1945
|
+
timeStyle: column.type === "dateTime" ? column.typeOptions?.timeStyle ?? "short" : undefined,
|
|
1946
|
+
hour12: column.type === "dateTime" ? column.typeOptions?.hour12 : undefined
|
|
1947
|
+
});
|
|
1948
|
+
var dateIsoValue = (date) => date.calendarOnly ? DateTime3.formatIsoDateUtc(date.instant) : DateTime3.formatIso(date.instant);
|
|
1949
|
+
var matchesDateFilter = (date, filter) => {
|
|
1950
|
+
if (!date)
|
|
1951
|
+
return false;
|
|
1952
|
+
const day = DateTime3.formatIsoDateUtc(date.instant);
|
|
1953
|
+
return (filter.from === undefined || day >= filter.from) && (filter.to === undefined || day <= filter.to);
|
|
1954
|
+
};
|
|
1955
|
+
var matchesFilterText = (value, filter) => {
|
|
1956
|
+
const text = value.toLocaleLowerCase();
|
|
1957
|
+
const query = filter.value.toLocaleLowerCase();
|
|
1958
|
+
switch (filter.operator) {
|
|
1959
|
+
case "contains":
|
|
1960
|
+
return text.includes(query);
|
|
1961
|
+
case "equals":
|
|
1962
|
+
return text === query;
|
|
1963
|
+
case "startsWith":
|
|
1964
|
+
return text.startsWith(query);
|
|
1965
|
+
case "endsWith":
|
|
1966
|
+
return text.endsWith(query);
|
|
1967
|
+
}
|
|
1968
|
+
};
|
|
1969
|
+
var tableFilterKind = (column, hasOptions = false) => hasOptions || column.type === "list" ? "values" : column.type === "reference" ? "text" : column.type === "dateTime" ? "date" : column.type ?? "text";
|
|
1970
|
+
var matchesTableFilter = (filter, value, type, text, values) => {
|
|
1971
|
+
switch (filter.kind) {
|
|
1972
|
+
case "text":
|
|
1973
|
+
return matchesFilterText(text(), filter);
|
|
1974
|
+
case "number":
|
|
1975
|
+
return isTableNumber(value) && (filter.min === undefined || value >= filter.min) && (filter.max === undefined || value <= filter.max);
|
|
1976
|
+
case "boolean":
|
|
1977
|
+
return value === filter.value;
|
|
1978
|
+
case "values":
|
|
1979
|
+
return values().some((value) => filter.values.includes(value));
|
|
1980
|
+
case "date":
|
|
1981
|
+
return matchesDateFilter(resolveDate(value, type === "dateTime" ? "dateTime" : "date"), filter);
|
|
1982
|
+
}
|
|
1983
|
+
};
|
|
1984
|
+
var tableDataColumns = (columns) => columns.flatMap((column) => column.fields?.length ? column.fields.map((field) => ({
|
|
1985
|
+
...field,
|
|
1986
|
+
id: `${column.id}.${field.id}`,
|
|
1987
|
+
headerName: `${column.headerName} / ${field.headerName}`,
|
|
1988
|
+
sortable: column.sortable === false ? false : field.sortable,
|
|
1989
|
+
searchable: column.searchable === false ? false : field.searchable,
|
|
1990
|
+
filterable: column.filterable === false ? false : field.filterable,
|
|
1991
|
+
export: column.export === false ? false : field.export
|
|
1992
|
+
})) : [column]);
|
|
1993
|
+
var filterTableColumns = (rows, columns, filters) => {
|
|
1994
|
+
const byId = new Map(columns.filter(({ filterable }) => filterable !== false).map((column) => [column.id, column]));
|
|
1995
|
+
const active = filters.filter((filter) => {
|
|
1996
|
+
const column = byId.get(filter.id);
|
|
1997
|
+
return column && tableFilterKind(column) === filter.kind;
|
|
1998
|
+
});
|
|
1999
|
+
if (!active.length)
|
|
2000
|
+
return rows;
|
|
2001
|
+
return rows.filter((row) => active.every((filter) => {
|
|
2002
|
+
const value = row.cells[filter.id];
|
|
2003
|
+
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) : []);
|
|
2004
|
+
}));
|
|
2005
|
+
};
|
|
2006
|
+
var columnValue = (column, value) => {
|
|
2007
|
+
switch (column.type) {
|
|
2008
|
+
case "text":
|
|
2009
|
+
return isTableText(value) ? value : null;
|
|
2010
|
+
case "number":
|
|
2011
|
+
case "boolean":
|
|
2012
|
+
case "date":
|
|
2013
|
+
case "dateTime":
|
|
2014
|
+
return tableSortScalar(column.type, value);
|
|
2015
|
+
case "reference":
|
|
2016
|
+
return isTableReference(value) ? value.label : null;
|
|
2017
|
+
case "list":
|
|
2018
|
+
return isTableList(value) ? value.map(({ label }) => label).join(", ") : null;
|
|
2019
|
+
}
|
|
2020
|
+
};
|
|
2021
|
+
var tableSortScalar = (type, value) => {
|
|
2022
|
+
if (type === "number")
|
|
2023
|
+
return isTableNumber(value) ? value : null;
|
|
2024
|
+
if (type === "boolean")
|
|
2025
|
+
return isTableBoolean(value) ? Number(value) : null;
|
|
2026
|
+
const date = resolveDate(value, type);
|
|
2027
|
+
return date ? DateTime3.toEpochMillis(date.instant) : null;
|
|
2028
|
+
};
|
|
2029
|
+
var compareTableSortValues = (left, right, direction, nulls, locale) => {
|
|
2030
|
+
if (left === right)
|
|
2031
|
+
return 0;
|
|
2032
|
+
const nullOrder = nulls === "first" ? -1 : 1;
|
|
2033
|
+
if (left === null)
|
|
2034
|
+
return nullOrder;
|
|
2035
|
+
if (right === null)
|
|
2036
|
+
return -nullOrder;
|
|
2037
|
+
const comparison = isTableNumber(left) && isTableNumber(right) ? left - right : compareTableText(String(left), String(right), locale);
|
|
2038
|
+
return direction === "asc" ? comparison : -comparison;
|
|
2039
|
+
};
|
|
2040
|
+
var sortTableRows = (rows, columns, sort, locale) => {
|
|
2041
|
+
const byId = new Map(columns.map((column) => [column.id, column]));
|
|
2042
|
+
return rows.slice().sort((leftRow, rightRow) => {
|
|
2043
|
+
for (const { id, direction } of sort) {
|
|
2044
|
+
const column = byId.get(id);
|
|
2045
|
+
if (!column || column.sortable === false)
|
|
2046
|
+
continue;
|
|
2047
|
+
const left = columnValue(column, leftRow.cells[id]);
|
|
2048
|
+
const right = columnValue(column, rightRow.cells[id]);
|
|
2049
|
+
const comparison = compareTableSortValues(left, right, direction, column.nulls, locale);
|
|
2050
|
+
if (comparison !== 0)
|
|
2051
|
+
return comparison;
|
|
2052
|
+
}
|
|
2053
|
+
return 0;
|
|
2054
|
+
});
|
|
2055
|
+
};
|
|
2056
|
+
var filterTableRows = (rows, columns, search, locale) => {
|
|
2057
|
+
const query = search.trim().toLocaleLowerCase(locale);
|
|
2058
|
+
if (!query)
|
|
2059
|
+
return rows;
|
|
2060
|
+
const searchable = columns.filter(({ searchable }) => searchable !== false);
|
|
2061
|
+
return rows.filter((row) => searchable.some((column) => {
|
|
2062
|
+
const value = row.cells[column.id];
|
|
2063
|
+
if (column.type === "date" || column.type === "dateTime") {
|
|
2064
|
+
const date = resolveDate(value, column.type);
|
|
2065
|
+
return !!date && `${formatDateValue(date, column, locale)} ${dateIsoValue(date)}`.toLocaleLowerCase(locale).includes(query);
|
|
2066
|
+
}
|
|
2067
|
+
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) ?? "");
|
|
2068
|
+
return text.toLocaleLowerCase(locale).includes(query);
|
|
2069
|
+
}));
|
|
2070
|
+
};
|
|
2071
|
+
var updateSelectedRows = (selected, targets, checked) => {
|
|
2072
|
+
const next = new Set(selected);
|
|
2073
|
+
for (const id of targets) {
|
|
2074
|
+
if (checked)
|
|
2075
|
+
next.add(id);
|
|
2076
|
+
else
|
|
2077
|
+
next.delete(id);
|
|
2078
|
+
}
|
|
2079
|
+
return Array.from(next);
|
|
2080
|
+
};
|
|
2081
|
+
var resolveTablePage = (rowCount, query) => {
|
|
2082
|
+
const pageSize = Math.max(1, query.pageSize);
|
|
2083
|
+
const pageCount = Math.max(1, Math.ceil(rowCount / pageSize));
|
|
2084
|
+
const page = Math.min(pageCount - 1, Math.max(0, query.page));
|
|
2085
|
+
const start = page * pageSize;
|
|
2086
|
+
return { page, pageCount, start, end: start + pageSize };
|
|
2087
|
+
};
|
|
2088
|
+
var edit = UiSchema2.TaggedEnum({
|
|
2089
|
+
SetBoolean: { value: Schema5.Boolean },
|
|
2090
|
+
AddItem: { itemId: Schema5.String },
|
|
2091
|
+
RemoveItem: { itemId: Schema5.String }
|
|
2092
|
+
}).annotate({ identifier: "DataTableEdit" });
|
|
2093
|
+
var eventFields = {
|
|
2094
|
+
RowActivated: { rowId: Schema5.String },
|
|
2095
|
+
ItemActionRequested: {
|
|
2096
|
+
rowId: Schema5.String,
|
|
2097
|
+
columnId: Schema5.String,
|
|
2098
|
+
itemId: Schema5.String,
|
|
2099
|
+
actionId: Schema5.String
|
|
2100
|
+
},
|
|
2101
|
+
RefreshRequested: {},
|
|
2102
|
+
ExportRequested: { actionId: Schema5.String },
|
|
2103
|
+
GroupActionRequested: {
|
|
2104
|
+
fieldId: Schema5.String,
|
|
2105
|
+
groupId: Schema5.String,
|
|
2106
|
+
actionId: Schema5.String
|
|
2107
|
+
},
|
|
2108
|
+
GroupMoveRequested: {
|
|
2109
|
+
rowId: Schema5.String,
|
|
2110
|
+
fieldId: Schema5.String,
|
|
2111
|
+
groupId: Schema5.String
|
|
2112
|
+
},
|
|
2113
|
+
RowsReordered: { rowIds: Schema5.Array(Schema5.String) },
|
|
2114
|
+
StateChanged: { state: DataTableQuerySchema },
|
|
2115
|
+
SortChanged: { sort: Schema5.Array(DataTableSortSchema) },
|
|
2116
|
+
SelectionChanged: { selectedRowIds: Schema5.Array(Schema5.String) },
|
|
2117
|
+
CellEditRequested: { rowId: Schema5.String, columnId: Schema5.String, edit },
|
|
2118
|
+
RowActionRequested: { rowId: Schema5.String, actionId: Schema5.String },
|
|
2119
|
+
BulkActionRequested: {
|
|
2120
|
+
rowIds: Schema5.Array(Schema5.String),
|
|
2121
|
+
actionId: Schema5.String
|
|
2122
|
+
}
|
|
2123
|
+
};
|
|
2124
|
+
var DataTableEvents = UiSchema2.TaggedEnum(eventFields).annotate({
|
|
2125
|
+
identifier: "DataTableEvents"
|
|
2126
|
+
});
|
|
2127
|
+
var DataTableMessage = UiSchema2.TaggedEnum({
|
|
2128
|
+
ReferenceImageFailed: { src: Schema5.String },
|
|
2129
|
+
RowActivated: eventFields.RowActivated,
|
|
2130
|
+
PreferencesLoaded: { preferences: Schema5.NullOr(DataTablePreferencesSchema) },
|
|
2131
|
+
ItemActionRequested: eventFields.ItemActionRequested,
|
|
2132
|
+
BuiltInExportRequested: {
|
|
2133
|
+
format: Schema5.Literals(["csv", "json"]),
|
|
2134
|
+
locale: Schema5.optionalKey(Schema5.String)
|
|
2135
|
+
},
|
|
2136
|
+
ExportStarted: {},
|
|
2137
|
+
ExportFinished: { failed: Schema5.Boolean },
|
|
2138
|
+
RefreshRequested: {},
|
|
2139
|
+
ExportRequested: eventFields.ExportRequested,
|
|
2140
|
+
GroupActionRequested: eventFields.GroupActionRequested,
|
|
2141
|
+
GroupMoveRequested: eventFields.GroupMoveRequested,
|
|
2142
|
+
ReorderRequested: {
|
|
2143
|
+
rowId: Schema5.String,
|
|
2144
|
+
targetId: Schema5.String,
|
|
2145
|
+
after: Schema5.Boolean
|
|
2146
|
+
},
|
|
2147
|
+
DragStarted: { rowId: Schema5.String },
|
|
2148
|
+
DragEnded: {},
|
|
2149
|
+
DragDropped: { targetId: Schema5.String },
|
|
2150
|
+
GroupDropped: { fieldId: Schema5.String, groupId: Schema5.String },
|
|
2151
|
+
ViewPicked: { view: DataTableViewSchema },
|
|
2152
|
+
GroupingToggled: { fieldId: Schema5.String },
|
|
2153
|
+
GroupToggled: { key: Schema5.String },
|
|
2154
|
+
ColumnResized: { id: Schema5.String, delta: Schema5.Finite },
|
|
2155
|
+
ColumnResizeReset: { id: Schema5.String },
|
|
2156
|
+
ResizeStarted: { id: Schema5.String, x: Schema5.Finite, pointerId: Schema5.Int },
|
|
2157
|
+
ResizeMoved: { x: Schema5.Finite, pointerId: Schema5.Int },
|
|
2158
|
+
ResizeEnded: { pointerId: Schema5.Int },
|
|
2159
|
+
ColumnFiltersCleared: { id: Schema5.String },
|
|
2160
|
+
ColumnSortCleared: { id: Schema5.String },
|
|
2161
|
+
CellEditRequested: eventFields.CellEditRequested,
|
|
2162
|
+
RowActionRequested: eventFields.RowActionRequested,
|
|
2163
|
+
MenuOpened: { key: Schema5.String },
|
|
2164
|
+
MenuClosed: { key: Schema5.String },
|
|
2165
|
+
MenuQueryChanged: { key: Schema5.String, query: Schema5.String },
|
|
2166
|
+
SubmenuOpened: {
|
|
2167
|
+
key: Schema5.String,
|
|
2168
|
+
filterColumnId: Schema5.optionalKey(Schema5.String)
|
|
2169
|
+
},
|
|
2170
|
+
SubmenuClosed: { key: Schema5.String },
|
|
2171
|
+
SearchChanged: { value: Schema5.String },
|
|
2172
|
+
FilterInputChanged: {
|
|
2173
|
+
field: Schema5.Literals(["primary", "secondary"]),
|
|
2174
|
+
value: Schema5.String
|
|
2175
|
+
},
|
|
2176
|
+
FilterOperatorChanged: { operator: TextFilterOperator },
|
|
2177
|
+
FilterValueToggled: { value: Schema5.String, checked: Schema5.Boolean },
|
|
2178
|
+
FilterApplied: {},
|
|
2179
|
+
ColumnFilterChanged: {
|
|
2180
|
+
id: Schema5.String,
|
|
2181
|
+
filter: Schema5.NullOr(ColumnFilter)
|
|
2182
|
+
},
|
|
2183
|
+
FilterCleared: {},
|
|
2184
|
+
FiltersCleared: {},
|
|
2185
|
+
PageRequested: { page: Schema5.Int },
|
|
2186
|
+
ServerPageInvalidated: {},
|
|
2187
|
+
PageSizeRequested: { pageSize: Schema5.Int },
|
|
2188
|
+
SortRequested: {
|
|
2189
|
+
columnId: Schema5.String,
|
|
2190
|
+
direction: Schema5.NullOr(DataTableSortSchema.fields.direction)
|
|
2191
|
+
},
|
|
2192
|
+
ColumnVisibilityChanged: { id: Schema5.String, visible: Schema5.Boolean },
|
|
2193
|
+
SelectionRequested: {
|
|
2194
|
+
rowIds: Schema5.Array(Schema5.String),
|
|
2195
|
+
checked: Schema5.Boolean
|
|
2196
|
+
},
|
|
2197
|
+
BulkActionRequested: { actionId: Schema5.String }
|
|
2198
|
+
}).annotate({ identifier: "DataTableMessage" });
|
|
2199
|
+
var dataTableOptions = {
|
|
2200
|
+
name: "DataTable",
|
|
2201
|
+
props: DataTablePropsSchema,
|
|
2202
|
+
model: Schema5.Struct({
|
|
2203
|
+
menu: Schema5.NullOr(Schema5.String),
|
|
2204
|
+
submenu: Schema5.NullOr(Schema5.String),
|
|
2205
|
+
menuQuery: Schema5.String,
|
|
2206
|
+
failedImages: Schema5.Array(Schema5.String),
|
|
2207
|
+
selectedRowIds: Schema5.Array(Schema5.String),
|
|
2208
|
+
query: DataTableQuerySchema,
|
|
2209
|
+
preferencesLoaded: Schema5.Boolean,
|
|
2210
|
+
columnVisibility: Schema5.Record(Schema5.String, Schema5.Boolean),
|
|
2211
|
+
columnSizing: Schema5.Record(Schema5.String, Schema5.Finite),
|
|
2212
|
+
view: DataTableViewSchema,
|
|
2213
|
+
grouping: Schema5.Array(Schema5.String),
|
|
2214
|
+
collapsedGroups: Schema5.Record(Schema5.String, Schema5.Boolean),
|
|
2215
|
+
dragging: Schema5.NullOr(Schema5.String),
|
|
2216
|
+
exporting: Schema5.Boolean,
|
|
2217
|
+
exportFailed: Schema5.Boolean,
|
|
2218
|
+
resizing: Schema5.NullOr(Schema5.Struct({
|
|
2219
|
+
id: Schema5.String,
|
|
2220
|
+
x: Schema5.Finite,
|
|
2221
|
+
width: Schema5.Finite,
|
|
2222
|
+
pointerId: Schema5.Int
|
|
2223
|
+
}).annotate({ identifier: "DataTableResizeSession" })),
|
|
2224
|
+
filterDraft: Schema5.NullOr(DataTableFilterDraftSchema),
|
|
2225
|
+
invalidFilter: Schema5.Boolean
|
|
2226
|
+
}).annotate({ identifier: "DataTableModel" }),
|
|
2227
|
+
message: DataTableMessage,
|
|
2228
|
+
events: DataTableEvents,
|
|
2229
|
+
restore: false
|
|
2230
|
+
};
|
|
2231
|
+
var available = (props) => props.status?.error === undefined && (!props.status?.loading || props.rowData.length > 0);
|
|
2232
|
+
var tableQuery = (props, model) => props.state ?? { ...model.query, sort: props.sort ?? model.query.sort };
|
|
2233
|
+
var tableFeatures = (props) => ({
|
|
2234
|
+
...props.features,
|
|
2235
|
+
search: props.features?.search ?? props.search ?? true,
|
|
2236
|
+
filtering: props.features?.filtering ?? props.columnFilters ?? true,
|
|
2237
|
+
sorting: props.features?.sorting ?? true,
|
|
2238
|
+
columnVisibility: props.features?.columnVisibility ?? true,
|
|
2239
|
+
pagination: props.features?.pagination ?? props.pagination
|
|
2240
|
+
});
|
|
2241
|
+
var tableSelectedRowIds = (props, model) => {
|
|
2242
|
+
const supplied = new Set(props.rowData.map(({ id }) => id));
|
|
2243
|
+
return [
|
|
2244
|
+
...new Set(props.selection?.selectedRowIds ?? model.selectedRowIds)
|
|
2245
|
+
].filter((id) => supplied.has(id));
|
|
2246
|
+
};
|
|
2247
|
+
var serverPageCorrection = (props, model) => {
|
|
2248
|
+
const pagination = tableFeatures(props).pagination;
|
|
2249
|
+
if (!pagination || pagination.mode !== "server")
|
|
2250
|
+
return;
|
|
2251
|
+
const query = tableQuery(props, model);
|
|
2252
|
+
const { page } = resolveTablePage(pagination.rowCount, query);
|
|
2253
|
+
if (query.page !== page)
|
|
2254
|
+
return { requested: query.page, page, size: query.pageSize };
|
|
2255
|
+
};
|
|
2256
|
+
var tablePreferencesKey = (pathname, columns, gallery) => `data-table:${pathname}:${columns.join(",")}:${gallery ? "gallery" : "table"}:ui`;
|
|
2257
|
+
var preferencesJson = Schema5.fromJsonString(DataTablePreferencesSchema);
|
|
2258
|
+
var decodePreferences = Schema5.decodeUnknownOption(preferencesJson);
|
|
2259
|
+
var encodePreferences = Schema5.encodeSync(preferencesJson);
|
|
2260
|
+
var readTablePreferences = (key, host = globalThis.window) => {
|
|
2261
|
+
try {
|
|
2262
|
+
return Option3.getOrNull(decodePreferences(host?.localStorage.getItem(key)));
|
|
2263
|
+
} catch {
|
|
2264
|
+
return null;
|
|
2265
|
+
}
|
|
2266
|
+
};
|
|
2267
|
+
var writeTablePreferences = (key, preferences, host = globalThis.window) => {
|
|
2268
|
+
try {
|
|
2269
|
+
host?.localStorage.setItem(key, encodePreferences(preferences));
|
|
2270
|
+
} catch {}
|
|
2271
|
+
};
|
|
2272
|
+
var tablePreferences = (model) => model.preferencesLoaded ? {
|
|
2273
|
+
columnVisibility: model.columnVisibility,
|
|
2274
|
+
columnSizing: model.columnSizing,
|
|
2275
|
+
grouping: model.grouping,
|
|
2276
|
+
view: model.view
|
|
2277
|
+
} : null;
|
|
2278
|
+
var tableColumnLimits = (column) => {
|
|
2279
|
+
const min = column.minWidth ?? 96;
|
|
2280
|
+
return { min, max: Math.max(min, column.maxWidth ?? 640) };
|
|
2281
|
+
};
|
|
2282
|
+
var clampTableWidth = (column, width = column.width ?? 208) => {
|
|
2283
|
+
const { min, max } = tableColumnLimits(column);
|
|
2284
|
+
return Math.min(max, Math.max(min, width));
|
|
2285
|
+
};
|
|
2286
|
+
var tableColumnWidth = (column, sizing) => clampTableWidth(column, sizing[column.id]);
|
|
2287
|
+
var tableLayoutWidth = (widths, utilityColumns) => widths.reduce((total, width) => total + width, utilityColumns * 40);
|
|
2288
|
+
var tableResizeStep = (key) => key === "ArrowLeft" ? -8 : key === "ArrowRight" ? 8 : 0;
|
|
2289
|
+
var activeTableGroups = (grouping, fields) => grouping.flatMap((id) => fields.find((field) => field.id === id) ?? []);
|
|
2290
|
+
var tableGrouping = (props, model) => activeTableGroups(model.grouping, props.features?.grouping?.fields ?? []);
|
|
2291
|
+
var canReorderTableRows = (props, model) => !!props.features?.reordering && !tableGrouping(props, model).length && !tableQuery(props, model).sort?.length;
|
|
2292
|
+
var partitionTableGroups = (rows, known, memberships) => {
|
|
2293
|
+
const groups = new Map(known.map((id) => [id, []]));
|
|
2294
|
+
for (const row of rows) {
|
|
2295
|
+
for (const id of new Set(memberships(row))) {
|
|
2296
|
+
const group = groups.get(id);
|
|
2297
|
+
if (group)
|
|
2298
|
+
group.push(row);
|
|
2299
|
+
else
|
|
2300
|
+
groups.set(id, [row]);
|
|
2301
|
+
}
|
|
2302
|
+
}
|
|
2303
|
+
return groups;
|
|
2304
|
+
};
|
|
2305
|
+
var tableGroupKey = (parent, fieldId, groupId) => `${parent ? `${parent}/` : ""}${encodeURIComponent(fieldId)}:${encodeURIComponent(groupId)}`;
|
|
2306
|
+
var reorderRows = ($, rowId, targetId, after) => {
|
|
2307
|
+
const rowIds = $.props.rowData.map(({ id }) => id);
|
|
2308
|
+
const next = $.evolve({ dragging: null });
|
|
2309
|
+
if (!available($.props) || !canReorderTableRows($.props, $.model) || rowId === targetId || !rowIds.includes(rowId) || !rowIds.includes(targetId))
|
|
2310
|
+
return next;
|
|
2311
|
+
const reordered = rowIds.filter((id) => id !== rowId);
|
|
2312
|
+
reordered.splice(reordered.indexOf(targetId) + Number(after), 0, rowId);
|
|
2313
|
+
return next.emit(DataTableEvents.RowsReordered({ rowIds: reordered }));
|
|
2314
|
+
};
|
|
2315
|
+
var moveGroup = ($, rowId, fieldId, groupId) => {
|
|
2316
|
+
const field = tableGrouping($.props, $.model).find(({ id }) => id === fieldId);
|
|
2317
|
+
const row = $.props.rowData.find(({ id }) => id === rowId);
|
|
2318
|
+
const next = $.evolve({ dragging: null });
|
|
2319
|
+
if (!available($.props) || !field?.movable || !row || row.groups?.[fieldId]?.includes(groupId))
|
|
2320
|
+
return next;
|
|
2321
|
+
if (!field.groups?.some(({ id }) => id === groupId) && !$.props.rowData.some((row) => row.groups?.[fieldId]?.includes(groupId)))
|
|
2322
|
+
return next;
|
|
2323
|
+
return next.emit(DataTableEvents.GroupMoveRequested({ rowId, fieldId, groupId }));
|
|
2324
|
+
};
|
|
2325
|
+
var changeQuery = ($, patch, ui = {}, legacy) => {
|
|
2326
|
+
const current = tableQuery($.props, $.model);
|
|
2327
|
+
const state = { ...current, ...patch };
|
|
2328
|
+
if (state.page === current.page && state.pageSize === current.pageSize && state.globalFilter === current.globalFilter && state.filters === current.filters && state.sort === current.sort)
|
|
2329
|
+
return $.evolve(ui);
|
|
2330
|
+
const step = $.evolve({
|
|
2331
|
+
...ui,
|
|
2332
|
+
query: $.props.state ? $.model.query : { ...state, sort: $.props.sort ? $.model.query.sort : state.sort }
|
|
2333
|
+
}).emit(DataTableEvents.StateChanged({ state }));
|
|
2334
|
+
return legacy ? step.emit(legacy) : step;
|
|
2335
|
+
};
|
|
2336
|
+
var tableFilterDraft = (id, current) => ({
|
|
2337
|
+
id,
|
|
2338
|
+
primary: current?.kind === "text" || current?.kind === "boolean" ? String(current.value) : current?.kind === "number" ? String(current.min ?? "") : current?.kind === "date" ? current.from ?? "" : "",
|
|
2339
|
+
secondary: current?.kind === "number" ? String(current.max ?? "") : current?.kind === "date" ? current.to ?? "" : "",
|
|
2340
|
+
operator: current?.kind === "text" ? current.operator : "contains",
|
|
2341
|
+
values: current?.kind === "values" ? current.values : []
|
|
2342
|
+
});
|
|
2343
|
+
var decodeFilter = Schema5.decodeUnknownOption(ColumnFilter);
|
|
2344
|
+
var decodeBound = Schema5.decodeOption(Schema5.FiniteFromString);
|
|
2345
|
+
var parseTableFilterDraft = (kind, {
|
|
2346
|
+
id,
|
|
2347
|
+
primary,
|
|
2348
|
+
secondary,
|
|
2349
|
+
operator,
|
|
2350
|
+
values
|
|
2351
|
+
}) => {
|
|
2352
|
+
switch (kind) {
|
|
2353
|
+
case "number": {
|
|
2354
|
+
const min = primary.trim() ? decodeBound(primary) : Option3.some(undefined);
|
|
2355
|
+
const max = secondary.trim() ? decodeBound(secondary) : Option3.some(undefined);
|
|
2356
|
+
return Option3.isNone(min) || Option3.isNone(max) ? Option3.none() : decodeFilter({ id, kind, min: min.value, max: max.value });
|
|
2357
|
+
}
|
|
2358
|
+
case "boolean":
|
|
2359
|
+
return decodeFilter({
|
|
2360
|
+
id,
|
|
2361
|
+
kind,
|
|
2362
|
+
value: primary === "true" ? true : primary === "false" ? false : undefined
|
|
2363
|
+
});
|
|
2364
|
+
case "values":
|
|
2365
|
+
return decodeFilter({ id, kind, values });
|
|
2366
|
+
case "date":
|
|
2367
|
+
return decodeFilter({
|
|
2368
|
+
id,
|
|
2369
|
+
kind,
|
|
2370
|
+
from: primary || undefined,
|
|
2371
|
+
to: secondary || undefined
|
|
2372
|
+
});
|
|
2373
|
+
case "text":
|
|
2374
|
+
return decodeFilter({ id, kind, operator, value: primary.trim() });
|
|
2375
|
+
}
|
|
2376
|
+
};
|
|
2377
|
+
var changeColumnFilter = ($, id, filter, ui) => {
|
|
2378
|
+
const filters = (tableQuery($.props, $.model).filters ?? []).filter((current) => current.id !== id);
|
|
2379
|
+
if (filter)
|
|
2380
|
+
filters.push(filter);
|
|
2381
|
+
return changeQuery($, { filters: filters.length ? filters : undefined, page: 0 }, ui);
|
|
2382
|
+
};
|
|
2383
|
+
var projectDataTableRows = (source, query, {
|
|
2384
|
+
pagination,
|
|
2385
|
+
grouped,
|
|
2386
|
+
sortMode,
|
|
2387
|
+
search,
|
|
2388
|
+
filter,
|
|
2389
|
+
sort
|
|
2390
|
+
}) => {
|
|
2391
|
+
const server = pagination && pagination.mode === "server";
|
|
2392
|
+
const filtered = server ? source : filter(search(source, query.globalFilter ?? ""), query.filters ?? []);
|
|
2393
|
+
const ordered = !server && sortMode !== "server" && query.sort?.length ? sort(filtered, query.sort) : filtered;
|
|
2394
|
+
const { pageSize } = query;
|
|
2395
|
+
const totalRows = server ? pagination.rowCount : ordered.length;
|
|
2396
|
+
const { page, pageCount, start, end } = resolveTablePage(totalRows, query);
|
|
2397
|
+
const paginationVisible = !!pagination && (server || !grouped);
|
|
2398
|
+
const rows = paginationVisible && !server ? ordered.slice(start, end) : ordered;
|
|
2399
|
+
return {
|
|
2400
|
+
rows,
|
|
2401
|
+
filtered,
|
|
2402
|
+
ordered,
|
|
2403
|
+
pageSize,
|
|
2404
|
+
totalRows,
|
|
2405
|
+
pageCount,
|
|
2406
|
+
page,
|
|
2407
|
+
paginationVisible
|
|
2408
|
+
};
|
|
2409
|
+
};
|
|
2410
|
+
var dataTablePage = (props, model, locale) => {
|
|
2411
|
+
const pagination = tableFeatures(props).pagination;
|
|
2412
|
+
const columns = tableDataColumns(props.columnDefs);
|
|
2413
|
+
return {
|
|
2414
|
+
...projectDataTableRows(props.rowData, tableQuery(props, model), {
|
|
2415
|
+
pagination,
|
|
2416
|
+
grouped: tableGrouping(props, model).length > 0,
|
|
2417
|
+
sortMode: props.sortMode,
|
|
2418
|
+
search: (rows, value) => filterTableRows(rows, columns, value, locale),
|
|
2419
|
+
filter: (rows, filters) => filterTableColumns(rows, columns, filters),
|
|
2420
|
+
sort: (rows, sorting) => sortTableRows(rows, columns, sorting, locale)
|
|
2421
|
+
}),
|
|
2422
|
+
pageSizes: pagination && pagination.pageSizes || defaultPageSizes
|
|
2423
|
+
};
|
|
2424
|
+
};
|
|
2425
|
+
var encodeTableCsv = (headers, data) => Effect3.runSync(Stream.fromIterable([headers, ...data]).pipe(Stream.map((row) => row.map((value) => value == null ? "" : String(value))), Stream.pipeThroughChannel(Csv.encodeString({ newline: `
|
|
2426
|
+
` })), Stream.runCollect, Effect3.map((parts) => parts.join("").slice(0, -1))));
|
|
2427
|
+
var tableExportFilename = (name, extension) => name.includes(".") ? name.replace(/\.[^/.]+$/, `.${extension}`) : `${name}.${extension}`;
|
|
2428
|
+
var downloadTableBlob = (content, type, filename) => {
|
|
2429
|
+
const url = window.URL.createObjectURL(new Blob([content], { type }));
|
|
2430
|
+
const link = document.createElement("a");
|
|
2431
|
+
link.href = url;
|
|
2432
|
+
link.download = filename;
|
|
2433
|
+
document.body.appendChild(link);
|
|
2434
|
+
try {
|
|
2435
|
+
link.click();
|
|
2436
|
+
} finally {
|
|
2437
|
+
link.remove();
|
|
2438
|
+
requestAnimationFrame(() => window.URL.revokeObjectURL(url));
|
|
2439
|
+
}
|
|
2440
|
+
};
|
|
2441
|
+
var tableExportValue = (column, row, locale) => {
|
|
2442
|
+
const value = row.cells[column.id];
|
|
2443
|
+
switch (column.type) {
|
|
2444
|
+
case "date":
|
|
2445
|
+
case "dateTime": {
|
|
2446
|
+
const date = resolveDate(value, column.type);
|
|
2447
|
+
return !date ? null : column.typeOptions?.exportFormat === "formatted" ? formatDateValue(date, column, locale) : dateIsoValue(date);
|
|
2448
|
+
}
|
|
2449
|
+
case "reference":
|
|
2450
|
+
return isTableReference(value) ? [value.label, value.description].filter(Boolean).join(" — ") : "";
|
|
2451
|
+
case "list":
|
|
2452
|
+
return isTableList(value) ? value.map(({ label }) => label).join(", ") : "";
|
|
2453
|
+
case "boolean":
|
|
2454
|
+
return !isTableBoolean(value) ? null : column.typeOptions?.exportFormat === "formatted" ? tableBooleanLabel(value, column.typeOptions) : value;
|
|
2455
|
+
case "number":
|
|
2456
|
+
return !isTableNumber(value) ? null : column.typeOptions?.exportFormat === "formatted" ? formatNumberValue(value, column.typeOptions, locale) : value;
|
|
2457
|
+
default:
|
|
2458
|
+
return columnValue(column, value);
|
|
2459
|
+
}
|
|
2460
|
+
};
|
|
2461
|
+
var DownloadTable = Command.make("DataTable/Download", {
|
|
2462
|
+
args: {
|
|
2463
|
+
filename: Schema5.String,
|
|
2464
|
+
content: Schema5.Redacted(Schema5.String, { disallowJsonEncode: true }),
|
|
2465
|
+
type: Schema5.String
|
|
2466
|
+
}
|
|
2467
|
+
}, ({ filename, content, type }) => Effect3.try(() => downloadTableBlob(Redacted.value(content), type, filename)).pipe(Effect3.match({
|
|
2468
|
+
onSuccess: () => DataTableMessage.ExportFinished({ failed: false }),
|
|
2469
|
+
onFailure: () => DataTableMessage.ExportFinished({ failed: true })
|
|
2470
|
+
})));
|
|
2471
|
+
var update2 = Component2.define(dataTableOptions).update({
|
|
2472
|
+
ReferenceImageFailed: ($, { src }) => $.model.failedImages.includes(src) ? $.model : $.evolve({ failedImages: [...$.model.failedImages, src] }),
|
|
2473
|
+
RowActivated: ($, { rowId }) => $.props.rowActivation && available($.props) && $.props.rowData.some(({ id }) => id === rowId) ? $.emit(DataTableEvents.RowActivated({ rowId })) : $.model,
|
|
2474
|
+
PreferencesLoaded: ($, { preferences }) => $.model.preferencesLoaded ? $.model : $.evolve({
|
|
2475
|
+
preferencesLoaded: true,
|
|
2476
|
+
columnVisibility: {
|
|
2477
|
+
...$.model.columnVisibility,
|
|
2478
|
+
...preferences?.columnVisibility
|
|
2479
|
+
},
|
|
2480
|
+
columnSizing: preferences?.columnSizing ?? $.model.columnSizing,
|
|
2481
|
+
grouping: preferences?.grouping ?? $.model.grouping,
|
|
2482
|
+
view: $.props.features?.gallery ? preferences?.view ?? $.model.view : "table"
|
|
2483
|
+
}),
|
|
2484
|
+
ItemActionRequested: ($, request) => {
|
|
2485
|
+
const row = $.props.rowData.find(({ id }) => id === request.rowId);
|
|
2486
|
+
const column = $.props.columnDefs.find(({ id }) => id === request.columnId);
|
|
2487
|
+
const items = row?.cells[request.columnId];
|
|
2488
|
+
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;
|
|
2489
|
+
},
|
|
2490
|
+
ExportStarted: ($) => $.evolve({ exporting: true, exportFailed: false }),
|
|
2491
|
+
ExportFinished: ($, { failed }) => $.evolve({ exporting: false, exportFailed: failed }),
|
|
2492
|
+
BuiltInExportRequested: ($, { format, locale = $.props.locale ?? "en" }) => {
|
|
2493
|
+
const feature = $.props.features?.export;
|
|
2494
|
+
if (!feature || feature.pending || $.model.exporting || feature.builtIn === false || !available($.props))
|
|
2495
|
+
return $.model;
|
|
2496
|
+
const projection = dataTablePage($.props, $.model, locale);
|
|
2497
|
+
const rows = feature.scope === "currentPage" ? projection.rows : projection.ordered;
|
|
2498
|
+
if (!rows.length)
|
|
2499
|
+
return $.model;
|
|
2500
|
+
const columns = tableDataColumns($.props.columnDefs.filter(({ id, export: enabled }) => enabled !== false && $.model.columnVisibility[id] !== false)).filter(({ export: enabled }) => enabled !== false);
|
|
2501
|
+
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) => [
|
|
2502
|
+
column.id,
|
|
2503
|
+
tableExportValue(column, row, locale)
|
|
2504
|
+
]))), null, 2);
|
|
2505
|
+
return $.evolve({ menu: null, exporting: true, exportFailed: false }).run(DownloadTable.make({
|
|
2506
|
+
content: Redacted.make(content),
|
|
2507
|
+
filename: tableExportFilename(feature.baseName, format),
|
|
2508
|
+
type: format === "csv" ? "text/csv;charset=utf-8" : "application/json;charset=utf-8"
|
|
2509
|
+
}));
|
|
2510
|
+
},
|
|
2511
|
+
RefreshRequested: ($) => $.props.features?.refresh ? $.emit(DataTableEvents.RefreshRequested()) : $.model,
|
|
2512
|
+
ExportRequested: ($, { actionId }) => !$.props.features?.export?.pending && $.props.features?.export?.actions?.some(({ id, disabled }) => id === actionId && !disabled) ? $.emit(DataTableEvents.ExportRequested({ actionId })) : $.model,
|
|
2513
|
+
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,
|
|
2514
|
+
GroupMoveRequested: ($, { rowId, fieldId, groupId }) => moveGroup($, rowId, fieldId, groupId),
|
|
2515
|
+
ReorderRequested: ($, { rowId, targetId, after }) => reorderRows($, rowId, targetId, after),
|
|
2516
|
+
DragStarted: ($, { rowId }) => $.evolve({ dragging: rowId }),
|
|
2517
|
+
DragEnded: ($) => $.evolve({ dragging: null }),
|
|
2518
|
+
DragDropped: ($, { targetId }) => $.model.dragging === null ? $.model : reorderRows($, $.model.dragging, targetId, $.props.rowData.findIndex(({ id }) => id === $.model.dragging) < $.props.rowData.findIndex(({ id }) => id === targetId)),
|
|
2519
|
+
GroupDropped: ($, { fieldId, groupId }) => $.model.dragging === null ? $.model : moveGroup($, $.model.dragging, fieldId, groupId),
|
|
2520
|
+
ViewPicked: ($, { view }) => view === "table" || $.props.features?.gallery ? $.evolve({ view, menu: null }) : $.model,
|
|
2521
|
+
GroupingToggled: ($, { fieldId }) => $.props.features?.grouping?.fields.some(({ id }) => id === fieldId) ? $.evolve({
|
|
2522
|
+
grouping: updateSelectedRows($.model.grouping, [fieldId], !$.model.grouping.includes(fieldId))
|
|
2523
|
+
}) : $.model,
|
|
2524
|
+
GroupToggled: ($, { key }) => $.evolve({
|
|
2525
|
+
collapsedGroups: {
|
|
2526
|
+
...$.model.collapsedGroups,
|
|
2527
|
+
[key]: !$.model.collapsedGroups[key]
|
|
2528
|
+
}
|
|
2529
|
+
}),
|
|
2530
|
+
ColumnResized: ($, { id, delta }) => {
|
|
2531
|
+
const column = $.props.columnDefs.find((column) => column.id === id);
|
|
2532
|
+
if (!column || column.resizable === false)
|
|
2533
|
+
return $.model;
|
|
2534
|
+
const sizing = {
|
|
2535
|
+
...$.model.columnSizing,
|
|
2536
|
+
[id]: tableColumnWidth(column, $.model.columnSizing) + delta
|
|
2537
|
+
};
|
|
2538
|
+
return $.evolve({
|
|
2539
|
+
columnSizing: { ...sizing, [id]: tableColumnWidth(column, sizing) }
|
|
2540
|
+
});
|
|
2541
|
+
},
|
|
2542
|
+
ColumnResizeReset: ($, { id }) => {
|
|
2543
|
+
const column = $.props.columnDefs.find((column) => column.id === id);
|
|
2544
|
+
if (!column || column.resizable === false)
|
|
2545
|
+
return $.model;
|
|
2546
|
+
return $.evolve({
|
|
2547
|
+
columnSizing: {
|
|
2548
|
+
...$.model.columnSizing,
|
|
2549
|
+
[id]: clampTableWidth(column)
|
|
2550
|
+
}
|
|
2551
|
+
});
|
|
2552
|
+
},
|
|
2553
|
+
ResizeStarted: ($, { id, x, pointerId }) => {
|
|
2554
|
+
const column = $.props.columnDefs.find((column) => column.id === id);
|
|
2555
|
+
return column && column.resizable !== false ? $.evolve({
|
|
2556
|
+
resizing: {
|
|
2557
|
+
id,
|
|
2558
|
+
x,
|
|
2559
|
+
pointerId,
|
|
2560
|
+
width: tableColumnWidth(column, $.model.columnSizing)
|
|
2561
|
+
}
|
|
2562
|
+
}) : $.model;
|
|
2563
|
+
},
|
|
2564
|
+
ResizeMoved: ($, { x, pointerId }) => {
|
|
2565
|
+
const resize = $.model.resizing;
|
|
2566
|
+
const column = resize && $.props.columnDefs.find(({ id }) => id === resize.id);
|
|
2567
|
+
if (!resize || resize.pointerId !== pointerId || !column || column.resizable === false)
|
|
2568
|
+
return $.model;
|
|
2569
|
+
return $.evolve({
|
|
2570
|
+
columnSizing: {
|
|
2571
|
+
...$.model.columnSizing,
|
|
2572
|
+
[resize.id]: tableColumnWidth(column, {
|
|
2573
|
+
[resize.id]: resize.width + x - resize.x
|
|
2574
|
+
})
|
|
2575
|
+
}
|
|
2576
|
+
});
|
|
2577
|
+
},
|
|
2578
|
+
ResizeEnded: ($, { pointerId }) => $.model.resizing?.pointerId === pointerId ? $.evolve({ resizing: null }) : $.model,
|
|
2579
|
+
ColumnFiltersCleared: ($, { id }) => {
|
|
2580
|
+
const column = $.props.columnDefs.find((column) => column.id === id);
|
|
2581
|
+
if (!column || !tableFeatures($.props).filtering)
|
|
2582
|
+
return $.model;
|
|
2583
|
+
const owned = new Set([
|
|
2584
|
+
id,
|
|
2585
|
+
...tableDataColumns([column]).map(({ id }) => id)
|
|
2586
|
+
]);
|
|
2587
|
+
const filters = tableQuery($.props, $.model).filters?.filter(({ id }) => !owned.has(id));
|
|
2588
|
+
return changeQuery($, { filters: filters?.length ? filters : undefined, page: 0 }, { filterDraft: null, invalidFilter: false });
|
|
2589
|
+
},
|
|
2590
|
+
ColumnSortCleared: ($, { id }) => {
|
|
2591
|
+
const column = $.props.columnDefs.find((column) => column.id === id);
|
|
2592
|
+
if (!column || !tableFeatures($.props).sorting)
|
|
2593
|
+
return $.model;
|
|
2594
|
+
const owned = new Set([
|
|
2595
|
+
id,
|
|
2596
|
+
...tableDataColumns([column]).map(({ id }) => id)
|
|
2597
|
+
]);
|
|
2598
|
+
const sort = (tableQuery($.props, $.model).sort ?? []).filter(({ id }) => !owned.has(id));
|
|
2599
|
+
return changeQuery($, { sort }, {}, DataTableEvents.SortChanged({ sort }));
|
|
2600
|
+
},
|
|
2601
|
+
MenuOpened: ($, { key }) => $.evolve({ menu: key, submenu: null, menuQuery: "" }),
|
|
2602
|
+
MenuQueryChanged: ($, { key, query }) => $.model.menu === key ? $.evolve({ menuQuery: query }) : $.model,
|
|
2603
|
+
MenuClosed: ($, { key }) => $.model.menu === key ? $.evolve({ menu: null, submenu: null }) : $.model,
|
|
2604
|
+
SubmenuOpened: ($, { key, filterColumnId }) => $.evolve({
|
|
2605
|
+
submenu: key,
|
|
2606
|
+
menuQuery: "",
|
|
2607
|
+
...filterColumnId === undefined ? {} : {
|
|
2608
|
+
filterDraft: tableFilterDraft(filterColumnId, tableQuery($.props, $.model).filters?.find(({ id }) => id === filterColumnId)),
|
|
2609
|
+
invalidFilter: false
|
|
2610
|
+
}
|
|
1139
2611
|
}),
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
2612
|
+
SubmenuClosed: ($, { key }) => $.model.submenu === key ? $.evolve({ submenu: null }) : $.model,
|
|
2613
|
+
SearchChanged: ($, { value }) => tableFeatures($.props).search ? changeQuery($, { globalFilter: value || undefined, page: 0 }, { menu: null }) : $.model,
|
|
2614
|
+
FilterInputChanged: ($, { field, value }) => {
|
|
2615
|
+
const draft = $.model.filterDraft;
|
|
2616
|
+
return draft ? $.evolve({
|
|
2617
|
+
filterDraft: { ...draft, [field]: value },
|
|
2618
|
+
invalidFilter: false
|
|
2619
|
+
}) : $.model;
|
|
2620
|
+
},
|
|
2621
|
+
FilterOperatorChanged: ($, { operator }) => {
|
|
2622
|
+
const draft = $.model.filterDraft;
|
|
2623
|
+
return draft ? $.evolve({
|
|
2624
|
+
filterDraft: { ...draft, operator },
|
|
2625
|
+
invalidFilter: false
|
|
2626
|
+
}) : $.model;
|
|
2627
|
+
},
|
|
2628
|
+
FilterValueToggled: ($, { value, checked }) => {
|
|
2629
|
+
const draft = $.model.filterDraft;
|
|
2630
|
+
return draft ? $.evolve({
|
|
2631
|
+
filterDraft: {
|
|
2632
|
+
...draft,
|
|
2633
|
+
values: updateSelectedRows(draft.values, [value], checked)
|
|
2634
|
+
},
|
|
2635
|
+
invalidFilter: false
|
|
2636
|
+
}) : $.model;
|
|
2637
|
+
},
|
|
2638
|
+
FilterApplied: ($) => {
|
|
2639
|
+
const draft = $.model.filterDraft;
|
|
2640
|
+
if (!tableFeatures($.props).filtering || !draft)
|
|
2641
|
+
return $.model;
|
|
2642
|
+
const column = tableDataColumns($.props.columnDefs).find(({ id, filterable }) => id === draft.id && filterable !== false);
|
|
2643
|
+
if (!column)
|
|
2644
|
+
return $.model;
|
|
2645
|
+
const decoded = parseTableFilterDraft(tableFilterKind(column), draft);
|
|
2646
|
+
return Option3.isNone(decoded) ? $.evolve({ invalidFilter: true }) : changeColumnFilter($, draft.id, decoded.value, {
|
|
2647
|
+
invalidFilter: false
|
|
2648
|
+
});
|
|
2649
|
+
},
|
|
2650
|
+
FilterCleared: ($) => {
|
|
2651
|
+
const draft = $.model.filterDraft;
|
|
2652
|
+
if (!draft)
|
|
2653
|
+
return $.model;
|
|
2654
|
+
return changeColumnFilter($, draft.id, null, {
|
|
2655
|
+
filterDraft: tableFilterDraft(draft.id),
|
|
2656
|
+
invalidFilter: false
|
|
2657
|
+
});
|
|
2658
|
+
},
|
|
2659
|
+
ColumnFilterChanged: ($, { id, filter }) => {
|
|
2660
|
+
if (!tableFeatures($.props).filtering || !tableDataColumns($.props.columnDefs).some((column) => column.id === id && column.filterable !== false) || filter && filter.id !== id)
|
|
2661
|
+
return $.model;
|
|
2662
|
+
return changeColumnFilter($, id, filter);
|
|
2663
|
+
},
|
|
2664
|
+
FiltersCleared: ($) => changeQuery($, { filters: undefined, page: 0 }, {
|
|
2665
|
+
filterDraft: null,
|
|
2666
|
+
invalidFilter: false
|
|
1156
2667
|
}),
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
}
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
})
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
2668
|
+
PageRequested: ($, { page }) => tableFeatures($.props).pagination && page >= 0 ? changeQuery($, { page }, { menu: null }) : $.model,
|
|
2669
|
+
ServerPageInvalidated: ($) => {
|
|
2670
|
+
const correction = serverPageCorrection($.props, $.model);
|
|
2671
|
+
return correction ? changeQuery($, { page: correction.page }) : $.model;
|
|
2672
|
+
},
|
|
2673
|
+
PageSizeRequested: ($, { pageSize }) => {
|
|
2674
|
+
const pagination = tableFeatures($.props).pagination;
|
|
2675
|
+
return pagination && (pagination.pageSizes ?? defaultPageSizes).includes(pageSize) ? changeQuery($, { pageSize, page: 0 }, { menu: null }) : $.model;
|
|
2676
|
+
},
|
|
2677
|
+
SortRequested: ($, { columnId, direction }) => {
|
|
2678
|
+
if (!tableFeatures($.props).sorting || !tableDataColumns($.props.columnDefs).some(({ id, sortable }) => id === columnId && sortable !== false))
|
|
2679
|
+
return $.model;
|
|
2680
|
+
const sort = direction === null ? (tableQuery($.props, $.model).sort ?? []).filter(({ id }) => id !== columnId) : [{ id: columnId, direction }];
|
|
2681
|
+
return changeQuery($, { sort: sort.length ? sort : undefined, page: 0 }, {}, DataTableEvents.SortChanged({ sort }));
|
|
2682
|
+
},
|
|
2683
|
+
ColumnVisibilityChanged: ($, { id, visible }) => tableFeatures($.props).columnVisibility && $.props.columnDefs.some((column) => column.id === id && column.hideable !== false) ? $.evolve({
|
|
2684
|
+
columnVisibility: { ...$.model.columnVisibility, [id]: visible }
|
|
2685
|
+
}) : $.model,
|
|
2686
|
+
SelectionRequested: ($, { rowIds, checked }) => {
|
|
2687
|
+
if (!available($.props) || !$.props.selection)
|
|
2688
|
+
return $.model;
|
|
2689
|
+
const requested = new Set(rowIds);
|
|
2690
|
+
const targets = $.props.rowData.filter((row) => row.selectable !== false && requested.has(row.id)).map(({ id }) => id);
|
|
2691
|
+
if (targets.length === 0)
|
|
2692
|
+
return $.model;
|
|
2693
|
+
const controlled = $.props.selection.selectedRowIds;
|
|
2694
|
+
const selectedRowIds = updateSelectedRows(controlled ?? $.model.selectedRowIds, targets, checked);
|
|
2695
|
+
return $.evolve(controlled ? {} : { selectedRowIds }).emit(DataTableEvents.SelectionChanged({ selectedRowIds }));
|
|
2696
|
+
},
|
|
2697
|
+
CellEditRequested: ($, { rowId, columnId, edit }) => {
|
|
2698
|
+
if (!available($.props))
|
|
2699
|
+
return $.model;
|
|
2700
|
+
const row = $.props.rowData.find(({ id }) => id === rowId);
|
|
2701
|
+
const column = $.props.columnDefs.find(({ id }) => id === columnId);
|
|
2702
|
+
if (!row || !column || row.disabledColumnIds?.includes(columnId))
|
|
2703
|
+
return $.model;
|
|
2704
|
+
const value = row.cells[columnId];
|
|
2705
|
+
if (edit._tag === "SetBoolean") {
|
|
2706
|
+
if (column.type !== "boolean" || !column.editable || !isTableBoolean(value) || edit.value === value)
|
|
2707
|
+
return $.model;
|
|
2708
|
+
} else {
|
|
2709
|
+
if (column.type !== "list")
|
|
2710
|
+
return $.model;
|
|
2711
|
+
const items = isTableList(value) ? value : [];
|
|
2712
|
+
const contains = items.some(({ value }) => value === edit.itemId);
|
|
2713
|
+
if (edit._tag === "AddItem") {
|
|
2714
|
+
if (contains || !column.options?.some(({ value }) => value === edit.itemId))
|
|
2715
|
+
return $.model;
|
|
2716
|
+
} else if (!contains || !column.allowRemove)
|
|
2717
|
+
return $.model;
|
|
1195
2718
|
}
|
|
1196
|
-
|
|
2719
|
+
return $.emit(DataTableEvents.CellEditRequested({ rowId, columnId, edit }));
|
|
2720
|
+
},
|
|
2721
|
+
RowActionRequested: ($, { rowId, actionId }) => {
|
|
2722
|
+
const row = $.props.rowData.find(({ id }) => id === rowId);
|
|
2723
|
+
if (!available($.props) || !row?.actions?.some(({ id, disabled }) => id === actionId && !disabled))
|
|
2724
|
+
return $.model;
|
|
2725
|
+
return $.emit(DataTableEvents.RowActionRequested({ rowId, actionId }));
|
|
2726
|
+
},
|
|
2727
|
+
BulkActionRequested: ($, { actionId }) => {
|
|
2728
|
+
const selection = $.props.selection;
|
|
2729
|
+
if (!available($.props) || !selection?.bulkActions?.some(({ id, disabled }) => id === actionId && !disabled))
|
|
2730
|
+
return $.model;
|
|
2731
|
+
const rowIds = tableSelectedRowIds($.props, $.model);
|
|
2732
|
+
return rowIds.length > 0 ? $.emit(DataTableEvents.BulkActionRequested({ actionId, rowIds })) : $.model;
|
|
2733
|
+
}
|
|
1197
2734
|
});
|
|
1198
|
-
var
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
2735
|
+
var dataTableBehaviours = {
|
|
2736
|
+
subscriptions: ({
|
|
2737
|
+
props,
|
|
2738
|
+
model
|
|
2739
|
+
}) => {
|
|
2740
|
+
const correction = serverPageCorrection(props, model);
|
|
2741
|
+
return correction ? [
|
|
2742
|
+
Subscription.make("reconcile-server-page", [correction.requested, correction.page, correction.size], () => Stream.make(DataTableMessage.ServerPageInvalidated()))
|
|
2743
|
+
] : [];
|
|
2744
|
+
},
|
|
2745
|
+
init: ({ props }) => ({
|
|
2746
|
+
menu: null,
|
|
2747
|
+
submenu: null,
|
|
2748
|
+
menuQuery: "",
|
|
2749
|
+
failedImages: [],
|
|
2750
|
+
selectedRowIds: [],
|
|
2751
|
+
query: {
|
|
2752
|
+
globalFilter: props.initialState?.globalFilter,
|
|
2753
|
+
filters: props.initialState?.filters,
|
|
2754
|
+
sort: props.initialState?.sort,
|
|
2755
|
+
page: props.initialState?.page ?? 0,
|
|
2756
|
+
pageSize: props.initialState?.pageSize ?? (props.pagination?.mode === undefined ? props.pagination?.pageSizes?.[0] : undefined) ?? DEFAULT_PAGE_SIZE
|
|
2757
|
+
},
|
|
2758
|
+
columnVisibility: props.initialState?.columnVisibility ?? {},
|
|
2759
|
+
preferencesLoaded: false,
|
|
2760
|
+
columnSizing: {},
|
|
2761
|
+
view: props.initialState?.view ?? "table",
|
|
2762
|
+
grouping: props.features?.grouping?.initial ?? [],
|
|
2763
|
+
collapsedGroups: {},
|
|
2764
|
+
dragging: null,
|
|
2765
|
+
exporting: false,
|
|
2766
|
+
exportFailed: false,
|
|
2767
|
+
resizing: null,
|
|
2768
|
+
filterDraft: null,
|
|
2769
|
+
invalidFilter: false
|
|
2770
|
+
}),
|
|
2771
|
+
update: update2
|
|
2772
|
+
};
|
|
1210
2773
|
|
|
1211
|
-
// ../../src/components/
|
|
1212
|
-
import { useKrakstackLocale as useKrakstackLocale3 } from "@krak-stack/registry/krakstack-provider";
|
|
2774
|
+
// ../../src/components/data-table/react.tsx
|
|
1213
2775
|
import { jsx as jsx15, jsxs as jsxs9, Fragment } from "react/jsx-runtime";
|
|
1214
|
-
var DataTableStylesContext =
|
|
2776
|
+
var DataTableStylesContext = createContext2(undefined);
|
|
2777
|
+
var DataTableSlotClassesContext = createContext2(resolveTableClasses());
|
|
1215
2778
|
var styledTablePart = (Part, slot, style) => {
|
|
1216
2779
|
const StyledPart = (props) => {
|
|
1217
|
-
const styles =
|
|
2780
|
+
const styles = useContext2(DataTableStylesContext);
|
|
1218
2781
|
const className = cn(props.className, style(styles));
|
|
1219
2782
|
return /* @__PURE__ */ jsx15(Part, {
|
|
1220
2783
|
"data-table-slot": slot,
|
|
@@ -1250,27 +2813,21 @@ var DropdownMenuLabel2 = styledTablePart(DropdownMenuLabel, "row-menu-label", (s
|
|
|
1250
2813
|
var DropdownMenuSeparator2 = styledTablePart(DropdownMenuSeparator, "row-menu-separator", (s) => s?.menu?.separator);
|
|
1251
2814
|
var SelectContent2 = styledTablePart(SelectContent, "select-popup", (s) => s?.popup?.select);
|
|
1252
2815
|
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
2816
|
var DataTableReferenceCell = ({
|
|
1261
2817
|
item,
|
|
1262
2818
|
emptyLabel = "—",
|
|
1263
2819
|
imageVariant = "circle"
|
|
1264
2820
|
}) => {
|
|
1265
|
-
const
|
|
2821
|
+
const tableClasses = useContext2(DataTableSlotClassesContext);
|
|
2822
|
+
const [failedImage, setFailedImage] = useState2();
|
|
1266
2823
|
if (!item)
|
|
1267
2824
|
return emptyLabel;
|
|
1268
|
-
const initials = item.label
|
|
2825
|
+
const initials = tableInitials(item.label);
|
|
1269
2826
|
return /* @__PURE__ */ jsxs9("div", {
|
|
1270
|
-
className:
|
|
2827
|
+
className: tableClasses.reference,
|
|
1271
2828
|
children: [
|
|
1272
2829
|
/* @__PURE__ */ jsx15("div", {
|
|
1273
|
-
className: cn(
|
|
2830
|
+
className: cn(tableClasses.referenceAvatar, imageVariant === "circle" ? "rounded-full" : "rounded-md", item.iconClassName),
|
|
1274
2831
|
children: item.icon ? /* @__PURE__ */ jsx15("span", {
|
|
1275
2832
|
"aria-hidden": "true",
|
|
1276
2833
|
className: "[&_svg]:size-4",
|
|
@@ -1286,14 +2843,14 @@ var DataTableReferenceCell = ({
|
|
|
1286
2843
|
})
|
|
1287
2844
|
}),
|
|
1288
2845
|
/* @__PURE__ */ jsxs9("div", {
|
|
1289
|
-
className:
|
|
2846
|
+
className: tableClasses.referenceText,
|
|
1290
2847
|
children: [
|
|
1291
2848
|
/* @__PURE__ */ jsx15("span", {
|
|
1292
|
-
className:
|
|
2849
|
+
className: tableClasses.referenceName,
|
|
1293
2850
|
children: item.label
|
|
1294
2851
|
}),
|
|
1295
2852
|
item.description ? /* @__PURE__ */ jsx15("span", {
|
|
1296
|
-
className:
|
|
2853
|
+
className: tableClasses.referenceDescription,
|
|
1297
2854
|
children: item.description
|
|
1298
2855
|
}) : null
|
|
1299
2856
|
]
|
|
@@ -1305,28 +2862,10 @@ var referenceText = (item) => item ? [item.label, item.description].filter(Boole
|
|
|
1305
2862
|
var messages2 = {
|
|
1306
2863
|
en: {
|
|
1307
2864
|
...paginationMessages("en"),
|
|
1308
|
-
|
|
1309
|
-
addItem: "Add item...",
|
|
1310
|
-
empty: "No results.",
|
|
1311
|
-
loading: "Loading...",
|
|
2865
|
+
...defaultMessages.en,
|
|
1312
2866
|
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
2867
|
filterFrom: "From (UTC)",
|
|
1326
2868
|
filterTo: "To (UTC)",
|
|
1327
|
-
filterTrue: "True",
|
|
1328
|
-
filterFalse: "False",
|
|
1329
|
-
filterInvalid: "Enter a valid filter. Ranges must be in ascending order.",
|
|
1330
2869
|
export: "Export",
|
|
1331
2870
|
exportCsv: "CSV",
|
|
1332
2871
|
exportJson: "JSON",
|
|
@@ -1337,45 +2876,20 @@ var messages2 = {
|
|
|
1337
2876
|
galleryView: "Gallery",
|
|
1338
2877
|
columns: "Columns",
|
|
1339
2878
|
groupBy: "Group by",
|
|
1340
|
-
sortAsc: "Ascending",
|
|
1341
|
-
sortDesc: "Descending",
|
|
1342
|
-
sortClear: "Clear sorting",
|
|
1343
2879
|
sortBy: "Sort by",
|
|
1344
2880
|
hideColumn: "Hide column",
|
|
1345
2881
|
reorder: "Drag to reorder",
|
|
1346
|
-
removeItem: "Remove",
|
|
1347
2882
|
moveUp: "Move up",
|
|
1348
2883
|
moveDown: "Move down",
|
|
1349
2884
|
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"
|
|
2885
|
+
listDetails: "View all items"
|
|
1354
2886
|
},
|
|
1355
2887
|
fr: {
|
|
1356
2888
|
...paginationMessages("fr"),
|
|
1357
|
-
|
|
1358
|
-
addItem: "Ajouter un élément...",
|
|
1359
|
-
empty: "Aucun résultat.",
|
|
1360
|
-
loading: "Chargement...",
|
|
2889
|
+
...defaultMessages.fr,
|
|
1361
2890
|
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
2891
|
filterFrom: "Du (UTC)",
|
|
1375
2892
|
filterTo: "Au (UTC)",
|
|
1376
|
-
filterTrue: "Vrai",
|
|
1377
|
-
filterFalse: "Faux",
|
|
1378
|
-
filterInvalid: "Saisissez un filtre valide. Les bornes doivent être dans l’ordre croissant.",
|
|
1379
2893
|
export: "Exporter",
|
|
1380
2894
|
exportCsv: "CSV",
|
|
1381
2895
|
exportJson: "JSON",
|
|
@@ -1386,20 +2900,13 @@ var messages2 = {
|
|
|
1386
2900
|
galleryView: "Galerie",
|
|
1387
2901
|
columns: "Colonnes",
|
|
1388
2902
|
groupBy: "Grouper par",
|
|
1389
|
-
sortAsc: "Croissant",
|
|
1390
|
-
sortDesc: "Décroissant",
|
|
1391
|
-
sortClear: "Effacer le tri",
|
|
1392
2903
|
sortBy: "Trier par",
|
|
1393
2904
|
hideColumn: "Masquer la colonne",
|
|
1394
2905
|
reorder: "Glisser pour réordonner",
|
|
1395
|
-
removeItem: "Retirer",
|
|
1396
2906
|
moveUp: "Déplacer vers le haut",
|
|
1397
2907
|
moveDown: "Déplacer vers le bas",
|
|
1398
2908
|
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"
|
|
2909
|
+
listDetails: "Afficher tous les éléments"
|
|
1403
2910
|
}
|
|
1404
2911
|
};
|
|
1405
2912
|
var dataTableMessages = (locale = "en", translations) => ({
|
|
@@ -1407,32 +2914,6 @@ var dataTableMessages = (locale = "en", translations) => ({
|
|
|
1407
2914
|
...translations?.[locale.split("-")[0] ?? locale],
|
|
1408
2915
|
...translations?.[locale]
|
|
1409
2916
|
});
|
|
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
2917
|
var normalizeDataTableColumns = (columnDefs, columnSizing = {}) => {
|
|
1437
2918
|
const ids = new Set;
|
|
1438
2919
|
const columns = columnDefs.map((colDef) => {
|
|
@@ -1447,7 +2928,7 @@ var normalizeDataTableColumns = (columnDefs, columnSizing = {}) => {
|
|
|
1447
2928
|
return {
|
|
1448
2929
|
id,
|
|
1449
2930
|
colDef,
|
|
1450
|
-
width:
|
|
2931
|
+
width: clampTableWidth(colDef, columnSizing[id])
|
|
1451
2932
|
};
|
|
1452
2933
|
});
|
|
1453
2934
|
for (const column of columns) {
|
|
@@ -1468,7 +2949,7 @@ var getDataTableFieldColumns = (column) => (column.colDef.fields ?? []).map(({ i
|
|
|
1468
2949
|
}));
|
|
1469
2950
|
var getDataTableSortColumns = (columns) => columns.flatMap((column) => column.colDef.sortable === false ? [] : ((column.colDef.fields?.length) ? getDataTableFieldColumns(column) : [column]).filter(({ colDef }) => colDef.sortable !== false));
|
|
1470
2951
|
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.
|
|
2952
|
+
var getDataTableWidth = (columns, utilityColumns = 0) => tableLayoutWidth(columns.map(({ width }) => width), utilityColumns);
|
|
1472
2953
|
var buildDataTableRows = (rowData, columns, getRowId) => {
|
|
1473
2954
|
const ids = new Set;
|
|
1474
2955
|
return rowData.map((data, index) => {
|
|
@@ -1488,58 +2969,20 @@ var buildDataTableRows = (rowData, columns, getRowId) => {
|
|
|
1488
2969
|
};
|
|
1489
2970
|
});
|
|
1490
2971
|
};
|
|
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({
|
|
2972
|
+
var NumberValue = Schema6.Finite.annotate({
|
|
1520
2973
|
identifier: "DataTableNumberValue"
|
|
1521
2974
|
});
|
|
1522
|
-
var BooleanValue =
|
|
2975
|
+
var BooleanValue = Schema6.Boolean.annotate({
|
|
1523
2976
|
identifier: "DataTableBooleanValue"
|
|
1524
2977
|
});
|
|
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
|
|
2978
|
+
var decodeNumberValue = Schema6.decodeUnknownOption(NumberValue);
|
|
2979
|
+
var decodeBooleanValue = Schema6.decodeUnknownOption(BooleanValue);
|
|
2980
|
+
var scalarText = Schema6.is(Schema6.Union([
|
|
2981
|
+
Schema6.String,
|
|
2982
|
+
Schema6.Finite,
|
|
2983
|
+
Schema6.Boolean,
|
|
2984
|
+
Schema6.BigInt,
|
|
2985
|
+
Schema6.Symbol
|
|
1543
2986
|
]));
|
|
1544
2987
|
var dataTableValueText = (value) => value == null ? "" : scalarText(value) ? String(value) : Formatter.format(value);
|
|
1545
2988
|
var booleanLabel = (value, options) => value ? options?.trueLabel : options?.falseLabel;
|
|
@@ -1547,13 +2990,13 @@ var getDataTableExportValue = (row, column, locale = "en") => {
|
|
|
1547
2990
|
const value = row.values.get(column.id);
|
|
1548
2991
|
const colDef = column.colDef;
|
|
1549
2992
|
if (colDef.type === "number") {
|
|
1550
|
-
const number =
|
|
2993
|
+
const number = Option4.getOrUndefined(decodeNumberValue(value));
|
|
1551
2994
|
if (number === undefined)
|
|
1552
2995
|
return null;
|
|
1553
2996
|
return colDef.typeOptions?.exportFormat === "formatted" ? formatNumberValue(number, colDef.typeOptions, locale) : number;
|
|
1554
2997
|
}
|
|
1555
2998
|
if (colDef.type === "boolean") {
|
|
1556
|
-
const boolean =
|
|
2999
|
+
const boolean = Option4.getOrUndefined(decodeBooleanValue(value));
|
|
1557
3000
|
if (boolean === undefined)
|
|
1558
3001
|
return null;
|
|
1559
3002
|
return colDef.typeOptions?.exportFormat === "formatted" ? booleanLabel(boolean, colDef.typeOptions) ?? String(boolean) : boolean;
|
|
@@ -1578,10 +3021,10 @@ var filterDataTableRows = (rows, columns, globalFilter, locale = "en") => {
|
|
|
1578
3021
|
const date = resolveDate(value, colDef.type);
|
|
1579
3022
|
text = date ? `${formatDateValue(date, colDef, locale)} ${dateIsoValue(date)}` : "";
|
|
1580
3023
|
} else if (colDef.type === "number") {
|
|
1581
|
-
const number =
|
|
3024
|
+
const number = Option4.getOrUndefined(decodeNumberValue(value));
|
|
1582
3025
|
text = number === undefined ? "" : `${formatNumberValue(number, colDef.typeOptions, locale)} ${number}`;
|
|
1583
3026
|
} else if (colDef.type === "boolean") {
|
|
1584
|
-
const boolean =
|
|
3027
|
+
const boolean = Option4.getOrUndefined(decodeBooleanValue(value));
|
|
1585
3028
|
text = boolean === undefined ? "" : `${booleanLabel(boolean, colDef.typeOptions) ?? ""} ${boolean}`;
|
|
1586
3029
|
}
|
|
1587
3030
|
return text.toLocaleLowerCase().includes(query);
|
|
@@ -1590,7 +3033,7 @@ var filterDataTableRows = (rows, columns, globalFilter, locale = "en") => {
|
|
|
1590
3033
|
var getDataTableFilterColumns = (columns) => columns.flatMap((column) => column.colDef.filterable === false ? [] : ((column.colDef.fields?.length) ? getDataTableFieldColumns(column) : [column]).filter(({ colDef }) => colDef.filterable !== false));
|
|
1591
3034
|
var getDataTableFilterKind = ({
|
|
1592
3035
|
colDef
|
|
1593
|
-
}) => colDef
|
|
3036
|
+
}) => tableFilterKind(colDef, !!colDef.filterOptions);
|
|
1594
3037
|
var getDataTableFilterOptions = (rows, column) => {
|
|
1595
3038
|
const { colDef } = column;
|
|
1596
3039
|
if (colDef.filterOptions)
|
|
@@ -1618,39 +3061,8 @@ var filterDataTableColumnRows = (rows, columns, filters) => {
|
|
|
1618
3061
|
rowIndex: row.index,
|
|
1619
3062
|
colDef: column.colDef
|
|
1620
3063
|
}) : 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
|
-
}
|
|
3064
|
+
const { colDef } = column;
|
|
3065
|
+
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
3066
|
}));
|
|
1655
3067
|
};
|
|
1656
3068
|
var sortDataTableRows = (rows, columns, sorting) => {
|
|
@@ -1666,35 +3078,13 @@ var sortDataTableRows = (rows, columns, sorting) => {
|
|
|
1666
3078
|
const leftValue = left.row.values.get(sort.id);
|
|
1667
3079
|
const rightValue = right.row.values.get(sort.id);
|
|
1668
3080
|
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);
|
|
3081
|
+
if (!colDef.comparator && (colDef.type === "number" || colDef.type === "boolean" || colDef.type === "date" || colDef.type === "dateTime")) {
|
|
3082
|
+
const comparison = compareTableSortValues(tableSortScalar(colDef.type, leftValue), tableSortScalar(colDef.type, rightValue), sort.direction, colDef.typeOptions?.nulls);
|
|
1693
3083
|
if (comparison !== 0)
|
|
1694
|
-
return
|
|
3084
|
+
return comparison;
|
|
1695
3085
|
continue;
|
|
1696
3086
|
}
|
|
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 :
|
|
3087
|
+
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
3088
|
if (comparison !== 0)
|
|
1699
3089
|
return sort.direction === "desc" ? -comparison : comparison;
|
|
1700
3090
|
}
|
|
@@ -1702,13 +3092,9 @@ var sortDataTableRows = (rows, columns, sorting) => {
|
|
|
1702
3092
|
}).map(({ row }) => row);
|
|
1703
3093
|
};
|
|
1704
3094
|
var paginateDataTableRows = (rows, pagination) => {
|
|
1705
|
-
const
|
|
1706
|
-
|
|
1707
|
-
const pageIndex = Math.min(lastPageIndex, Math.max(0, pagination.page));
|
|
1708
|
-
const start = pageIndex * pageSize;
|
|
1709
|
-
return rows.slice(start, start + pageSize);
|
|
3095
|
+
const { start, end } = resolveTablePage(rows.length, pagination);
|
|
3096
|
+
return rows.slice(start, end);
|
|
1710
3097
|
};
|
|
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
3098
|
var reorderDataTableRows = (rows, sourceRowId, targetRowId) => {
|
|
1713
3099
|
const sourceIndex = rows.findIndex((row) => row.id === sourceRowId);
|
|
1714
3100
|
const targetIndex = rows.findIndex((row) => row.id === targetRowId);
|
|
@@ -1721,10 +3107,10 @@ var reorderDataTableRows = (rows, sourceRowId, targetRowId) => {
|
|
|
1721
3107
|
reordered.splice(targetIndex, 0, source);
|
|
1722
3108
|
return reordered;
|
|
1723
3109
|
};
|
|
1724
|
-
var RowIdContext =
|
|
1725
|
-
var ColumnIdContext =
|
|
3110
|
+
var RowIdContext = createContext2(null);
|
|
3111
|
+
var ColumnIdContext = createContext2(null);
|
|
1726
3112
|
var useRequiredId = (context) => {
|
|
1727
|
-
const id =
|
|
3113
|
+
const id = useContext2(context);
|
|
1728
3114
|
if (!id)
|
|
1729
3115
|
throw new Error("DataTable internal ID context is missing");
|
|
1730
3116
|
return id;
|
|
@@ -1754,7 +3140,7 @@ var clearDragPresentation = (root) => {
|
|
|
1754
3140
|
element.removeAttribute("data-drop-position");
|
|
1755
3141
|
});
|
|
1756
3142
|
};
|
|
1757
|
-
var resolveConfig = (props
|
|
3143
|
+
var resolveConfig = (props) => {
|
|
1758
3144
|
const features = props.features ?? {};
|
|
1759
3145
|
const selection = features.selection;
|
|
1760
3146
|
const getRowId = selection && selection.getRowId || props.getRowId || undefined;
|
|
@@ -1763,8 +3149,6 @@ var resolveConfig = (props, onUiStateChange) => {
|
|
|
1763
3149
|
}
|
|
1764
3150
|
return {
|
|
1765
3151
|
getRowId,
|
|
1766
|
-
onStateChange: props.onStateChange,
|
|
1767
|
-
onUiStateChange,
|
|
1768
3152
|
status: props.status ?? {},
|
|
1769
3153
|
features,
|
|
1770
3154
|
onRowClicked: props.onRowClicked,
|
|
@@ -1779,83 +3163,39 @@ var queryFromState = (state) => ({
|
|
|
1779
3163
|
filters: state.filters,
|
|
1780
3164
|
sort: state.sort
|
|
1781
3165
|
});
|
|
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
3166
|
var buildDataTableModel = (store) => {
|
|
1797
3167
|
const columns = normalizeDataTableColumns(store.columnDefs, store.state.columnSizing);
|
|
1798
3168
|
const selection = store.config.features.selection;
|
|
1799
3169
|
const rowId = selection && selection.getRowId || store.config.getRowId || undefined;
|
|
1800
3170
|
const rows = buildDataTableRows(store.rowData, columns, rowId);
|
|
1801
|
-
const
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
3171
|
+
const page = projectDataTableRows(rows, store.state, {
|
|
3172
|
+
pagination: store.config.features.pagination,
|
|
3173
|
+
grouped: getActiveGrouping(store).length > 0,
|
|
3174
|
+
search: (rows, value) => filterDataTableRows(rows, columns, value, store.config.locale),
|
|
3175
|
+
filter: (rows, filters) => filterDataTableColumnRows(rows, columns, filters),
|
|
3176
|
+
sort: (rows, sorting) => sortDataTableRows(rows, columns, sorting)
|
|
3177
|
+
});
|
|
1807
3178
|
return {
|
|
1808
3179
|
columns,
|
|
1809
3180
|
visibleColumns: columns.filter(({ id }) => store.state.columnVisibility[id] !== false),
|
|
1810
3181
|
rows,
|
|
1811
|
-
filteredRows,
|
|
1812
|
-
sortedRows,
|
|
1813
|
-
pageRows,
|
|
1814
|
-
|
|
1815
|
-
|
|
3182
|
+
filteredRows: page.filtered,
|
|
3183
|
+
sortedRows: page.ordered,
|
|
3184
|
+
pageRows: page.rows,
|
|
3185
|
+
page: page.page,
|
|
3186
|
+
pageCount: page.pageCount,
|
|
3187
|
+
paginationVisible: page.paginationVisible,
|
|
3188
|
+
totalRows: page.totalRows
|
|
1816
3189
|
};
|
|
1817
3190
|
};
|
|
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
3191
|
var deriveModel = (store) => store.model;
|
|
1838
3192
|
var groupDataTableRows = (rows, fields, depth = 0, parentKey = "") => {
|
|
1839
3193
|
const field = fields[0];
|
|
1840
3194
|
if (!field)
|
|
1841
3195
|
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
|
-
});
|
|
3196
|
+
const groups = partitionTableGroups(rows, field.getGroupIds?.() ?? [], (row) => field.getRowGroupIds?.(row.data) ?? [field.getGroupId(row.data)]);
|
|
1856
3197
|
return Array.from(groups, ([groupId, groupRows]) => {
|
|
1857
|
-
const
|
|
1858
|
-
const key = `${parentKey}${parentKey ? "/" : ""}${segment}`;
|
|
3198
|
+
const key = tableGroupKey(parentKey, field.id, groupId);
|
|
1859
3199
|
return {
|
|
1860
3200
|
key,
|
|
1861
3201
|
groupId,
|
|
@@ -1869,12 +3209,7 @@ var groupDataTableRows = (rows, fields, depth = 0, parentKey = "") => {
|
|
|
1869
3209
|
var getDataTableSelectableRows = (model, grouped, isRowSelectable) => (grouped ? model.sortedRows : model.pageRows).filter((row) => isRowSelectable?.(row.data) ?? true);
|
|
1870
3210
|
var getActiveGrouping = (store) => {
|
|
1871
3211
|
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
|
-
});
|
|
3212
|
+
return activeTableGroups(store.state.grouping, grouping && grouping.fields || []);
|
|
1878
3213
|
};
|
|
1879
3214
|
var canReorderRows = (store) => {
|
|
1880
3215
|
const pagination = store.config.features.pagination;
|
|
@@ -1911,7 +3246,7 @@ var renderCell = (row, column, locale = "en", labels = dataTableMessages(locale)
|
|
|
1911
3246
|
if (colDef.type === "number") {
|
|
1912
3247
|
if (colDef.valueFormatter)
|
|
1913
3248
|
return colDef.valueFormatter(params);
|
|
1914
|
-
const number =
|
|
3249
|
+
const number = Option4.getOrUndefined(decodeNumberValue(value));
|
|
1915
3250
|
return /* @__PURE__ */ jsx15("span", {
|
|
1916
3251
|
className: "block text-left tabular-nums",
|
|
1917
3252
|
children: number === undefined ? colDef.typeOptions?.emptyLabel ?? "—" : formatNumberValue(number, colDef.typeOptions, locale)
|
|
@@ -1920,7 +3255,7 @@ var renderCell = (row, column, locale = "en", labels = dataTableMessages(locale)
|
|
|
1920
3255
|
if (colDef.type === "boolean") {
|
|
1921
3256
|
if (colDef.valueFormatter)
|
|
1922
3257
|
return colDef.valueFormatter(params);
|
|
1923
|
-
const boolean =
|
|
3258
|
+
const boolean = Option4.getOrUndefined(decodeBooleanValue(value));
|
|
1924
3259
|
if (boolean === undefined)
|
|
1925
3260
|
return colDef.typeOptions?.emptyLabel ?? "—";
|
|
1926
3261
|
const options = colDef.typeOptions;
|
|
@@ -1983,37 +3318,25 @@ var renderCell = (row, column, locale = "en", labels = dataTableMessages(locale)
|
|
|
1983
3318
|
return column.colDef.valueFormatter?.(params) ?? (value === null || value === undefined ? null : dataTableValueText(value));
|
|
1984
3319
|
};
|
|
1985
3320
|
var nodeText = (node) => {
|
|
1986
|
-
if (
|
|
3321
|
+
if (Schema6.is(Schema6.String)(node) || Schema6.is(Schema6.Finite)(node))
|
|
1987
3322
|
return String(node);
|
|
1988
3323
|
if (!isValidElement(node))
|
|
1989
3324
|
return "";
|
|
1990
|
-
if (
|
|
3325
|
+
if (Schema6.is(Schema6.String)(node.props.title))
|
|
1991
3326
|
return node.props.title;
|
|
1992
3327
|
return nodeText(node.props.children);
|
|
1993
3328
|
};
|
|
1994
3329
|
var columnLabel = (column) => nodeText(column.colDef.headerName) || column.id;
|
|
1995
|
-
var withExtension = (fileName, extension) => fileName.includes(".") ? fileName.replace(/\.[^/.]+$/, `.${extension}`) : `${fileName}.${extension}`;
|
|
1996
3330
|
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));
|
|
3331
|
+
downloadTableBlob(encodeTableCsv(headers, data), "text/csv;charset=utf-8", tableExportFilename(fileName, "csv"));
|
|
2011
3332
|
};
|
|
3333
|
+
var downloadJson = (data, fileName = "data.json") => downloadTableBlob(JSON.stringify(data, null, 2), "application/json;charset=utf-8", tableExportFilename(fileName, "json"));
|
|
2012
3334
|
var DataTableRowActions = ({
|
|
2013
3335
|
actions,
|
|
2014
3336
|
row,
|
|
2015
3337
|
title
|
|
2016
3338
|
}) => {
|
|
3339
|
+
const tableClasses = useContext2(DataTableSlotClassesContext);
|
|
2017
3340
|
const visible = actions.filter((action) => !action.visible || action.visible(row));
|
|
2018
3341
|
if (!visible.length)
|
|
2019
3342
|
return null;
|
|
@@ -2022,7 +3345,7 @@ var DataTableRowActions = ({
|
|
|
2022
3345
|
/* @__PURE__ */ jsx15(DropdownMenuTrigger2, {
|
|
2023
3346
|
onClick: (event) => event.stopPropagation(),
|
|
2024
3347
|
render: /* @__PURE__ */ jsxs9(Button, {
|
|
2025
|
-
className: "
|
|
3348
|
+
className: cn(tableClasses.actionTrigger, "[&_svg:not([class*='size-'])]:size-4"),
|
|
2026
3349
|
size: "icon",
|
|
2027
3350
|
variant: "ghost",
|
|
2028
3351
|
children: [
|
|
@@ -2061,10 +3384,10 @@ var DataTableRowActions = ({
|
|
|
2061
3384
|
});
|
|
2062
3385
|
};
|
|
2063
3386
|
var DataTableRowActionMenu = ({
|
|
2064
|
-
|
|
3387
|
+
table,
|
|
2065
3388
|
row
|
|
2066
3389
|
}) => {
|
|
2067
|
-
const [store] =
|
|
3390
|
+
const [store] = table;
|
|
2068
3391
|
const rowId = row.id;
|
|
2069
3392
|
const rowActions = store.config.features.rowActions || undefined;
|
|
2070
3393
|
const reordering = store.config.features.reordering;
|
|
@@ -2098,12 +3421,12 @@ var DataTableRowActionMenu = ({
|
|
|
2098
3421
|
});
|
|
2099
3422
|
};
|
|
2100
3423
|
var DataTableToolbar = ({
|
|
2101
|
-
|
|
3424
|
+
table
|
|
2102
3425
|
}) => {
|
|
2103
|
-
const
|
|
2104
|
-
const
|
|
2105
|
-
const
|
|
2106
|
-
const
|
|
3426
|
+
const tableClasses = useContext2(DataTableSlotClassesContext);
|
|
3427
|
+
const [store, send] = table;
|
|
3428
|
+
const exportPending = useRef2(false);
|
|
3429
|
+
const { exporting, exportFailed } = store.ui;
|
|
2107
3430
|
const { features, labels } = store.config;
|
|
2108
3431
|
const model = deriveModel(store);
|
|
2109
3432
|
const selectedRows = getSelectedRows(store, model);
|
|
@@ -2113,7 +3436,6 @@ var DataTableToolbar = ({
|
|
|
2113
3436
|
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
3437
|
if (!hasToolbar)
|
|
2115
3438
|
return null;
|
|
2116
|
-
const update = (next) => changeState(setStore, next);
|
|
2117
3439
|
const visibleBulkActions = bulkActions ? bulkActions.items.filter((action) => !action.visible || action.visible(selectedRows)) : [];
|
|
2118
3440
|
const exportRows = features.export && features.export.scope === "currentPage" ? model.pageRows : model.sortedRows;
|
|
2119
3441
|
const exportColumns = getDataTableExportColumns(model.visibleColumns);
|
|
@@ -2125,46 +3447,38 @@ var DataTableToolbar = ({
|
|
|
2125
3447
|
if (exportPending.current || action.disabled)
|
|
2126
3448
|
return;
|
|
2127
3449
|
exportPending.current = true;
|
|
2128
|
-
|
|
2129
|
-
|
|
3450
|
+
send(DataTableMessage.ExportStarted());
|
|
3451
|
+
let failed = false;
|
|
2130
3452
|
try {
|
|
2131
3453
|
await action.onExport();
|
|
2132
3454
|
} catch (error) {
|
|
2133
|
-
|
|
3455
|
+
failed = true;
|
|
2134
3456
|
if (exportFeature)
|
|
2135
3457
|
exportFeature.onError?.(error, action);
|
|
2136
3458
|
} finally {
|
|
2137
3459
|
exportPending.current = false;
|
|
2138
|
-
|
|
3460
|
+
send(DataTableMessage.ExportFinished({ failed }));
|
|
2139
3461
|
}
|
|
2140
3462
|
};
|
|
2141
3463
|
return /* @__PURE__ */ jsxs9("div", {
|
|
2142
|
-
className: cn("
|
|
3464
|
+
className: cn(tableClasses.toolbar, "pb-4"),
|
|
2143
3465
|
children: [
|
|
2144
3466
|
features.search !== false ? /* @__PURE__ */ jsxs9("div", {
|
|
2145
|
-
className:
|
|
3467
|
+
className: tableClasses.toolbarSearch,
|
|
2146
3468
|
children: [
|
|
2147
3469
|
/* @__PURE__ */ jsx15(Search, {
|
|
2148
3470
|
className: "text-muted-foreground pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2"
|
|
2149
3471
|
}),
|
|
2150
3472
|
/* @__PURE__ */ jsx15(Input2, {
|
|
2151
3473
|
className: "px-9",
|
|
2152
|
-
onChange: (event) =>
|
|
2153
|
-
...state,
|
|
2154
|
-
globalFilter: event.target.value,
|
|
2155
|
-
page: 0
|
|
2156
|
-
})),
|
|
3474
|
+
onChange: (event) => send(DataTableMessage.SearchChanged({ value: event.target.value })),
|
|
2157
3475
|
placeholder: labels.filter,
|
|
2158
3476
|
value: store.state.globalFilter ?? ""
|
|
2159
3477
|
}),
|
|
2160
3478
|
store.state.globalFilter ? /* @__PURE__ */ jsx15(Button, {
|
|
2161
3479
|
"aria-label": labels.filter,
|
|
2162
3480
|
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
|
-
})),
|
|
3481
|
+
onClick: () => send(DataTableMessage.SearchChanged({ value: "" })),
|
|
2168
3482
|
size: "icon",
|
|
2169
3483
|
variant: "ghost",
|
|
2170
3484
|
children: /* @__PURE__ */ jsx15(X, {})
|
|
@@ -2172,19 +3486,19 @@ var DataTableToolbar = ({
|
|
|
2172
3486
|
]
|
|
2173
3487
|
}) : null,
|
|
2174
3488
|
/* @__PURE__ */ jsx15("div", {
|
|
2175
|
-
className:
|
|
3489
|
+
className: tableClasses.toolbarMenus,
|
|
2176
3490
|
children: /* @__PURE__ */ jsxs9(Menubar2, {
|
|
2177
3491
|
modal: false,
|
|
2178
|
-
className: "
|
|
3492
|
+
className: cn(tableClasses.menubar, "[&_[data-slot=menubar-trigger]]:gap-2 [&_[data-slot=menubar-trigger]_svg]:size-4"),
|
|
2179
3493
|
children: [
|
|
2180
3494
|
visibleBulkActions.length ? /* @__PURE__ */ jsxs9(MenubarMenu, {
|
|
2181
3495
|
children: [
|
|
2182
3496
|
/* @__PURE__ */ jsxs9(MenubarTrigger2, {
|
|
2183
|
-
className: "
|
|
3497
|
+
className: cn(tableClasses.selectedTrigger, "aria-expanded:bg-primary/90"),
|
|
2184
3498
|
children: [
|
|
2185
3499
|
labels.selected,
|
|
2186
|
-
/* @__PURE__ */ jsx15(
|
|
2187
|
-
|
|
3500
|
+
/* @__PURE__ */ jsx15("span", {
|
|
3501
|
+
className: tableClasses.count,
|
|
2188
3502
|
children: selectedRows.length
|
|
2189
3503
|
}),
|
|
2190
3504
|
/* @__PURE__ */ jsx15(ChevronDown, {})
|
|
@@ -2214,7 +3528,7 @@ var DataTableToolbar = ({
|
|
|
2214
3528
|
}) : null,
|
|
2215
3529
|
toolbar && toolbar.items,
|
|
2216
3530
|
features.filtering !== false ? /* @__PURE__ */ jsx15(FilterMenu, {
|
|
2217
|
-
|
|
3531
|
+
table
|
|
2218
3532
|
}) : null,
|
|
2219
3533
|
grouping ? /* @__PURE__ */ jsxs9(MenubarMenu, {
|
|
2220
3534
|
children: [
|
|
@@ -2238,10 +3552,7 @@ var DataTableToolbar = ({
|
|
|
2238
3552
|
/* @__PURE__ */ jsx15(MenubarSeparator2, {}),
|
|
2239
3553
|
grouping.fields.map((field) => /* @__PURE__ */ jsx15(MenubarCheckboxItem2, {
|
|
2240
3554
|
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
|
-
})),
|
|
3555
|
+
onCheckedChange: () => send(DataTableMessage.GroupingToggled({ fieldId: field.id })),
|
|
2245
3556
|
children: field.label
|
|
2246
3557
|
}, field.id))
|
|
2247
3558
|
]
|
|
@@ -2250,13 +3561,13 @@ var DataTableToolbar = ({
|
|
|
2250
3561
|
]
|
|
2251
3562
|
}) : null,
|
|
2252
3563
|
features.sorting !== false ? /* @__PURE__ */ jsx15(SortMenu, {
|
|
2253
|
-
|
|
3564
|
+
table
|
|
2254
3565
|
}) : null,
|
|
2255
3566
|
features.gallery ? /* @__PURE__ */ jsx15(ViewMenu, {
|
|
2256
|
-
|
|
3567
|
+
table
|
|
2257
3568
|
}) : null,
|
|
2258
3569
|
features.columnVisibility !== false ? /* @__PURE__ */ jsx15(ColumnMenu, {
|
|
2259
|
-
|
|
3570
|
+
table
|
|
2260
3571
|
}) : null,
|
|
2261
3572
|
features.refresh ? /* @__PURE__ */ jsx15(MenubarMenu, {
|
|
2262
3573
|
children: /* @__PURE__ */ jsxs9(MenubarTrigger2, {
|
|
@@ -2337,18 +3648,12 @@ var DataTableToolbar = ({
|
|
|
2337
3648
|
}),
|
|
2338
3649
|
exportFeature && exportFailed ? /* @__PURE__ */ jsx15("p", {
|
|
2339
3650
|
role: "alert",
|
|
2340
|
-
className: "text-destructive
|
|
3651
|
+
className: "text-destructive basis-full text-sm",
|
|
2341
3652
|
children: labels.exportFailed ?? dataTableMessages(store.config.locale).exportFailed
|
|
2342
3653
|
}) : null
|
|
2343
3654
|
]
|
|
2344
3655
|
});
|
|
2345
3656
|
};
|
|
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
3657
|
var FilterEditor = ({
|
|
2353
3658
|
column,
|
|
2354
3659
|
rows,
|
|
@@ -2358,20 +3663,19 @@ var FilterEditor = ({
|
|
|
2358
3663
|
}) => {
|
|
2359
3664
|
const inputId = useId2();
|
|
2360
3665
|
const kind = getDataTableFilterKind(column);
|
|
2361
|
-
const [
|
|
2362
|
-
const
|
|
2363
|
-
const [operator, setOperator] = useState(current?.kind === "text" ? current.operator : "contains");
|
|
3666
|
+
const [draft, setDraft] = useState2(() => tableFilterDraft(column.id, current));
|
|
3667
|
+
const { primary, secondary, operator } = draft;
|
|
2364
3668
|
const operatorOptions = [
|
|
2365
3669
|
{ value: "contains", label: labels.filterContains },
|
|
2366
3670
|
{ value: "equals", label: labels.filterEquals },
|
|
2367
3671
|
{ value: "startsWith", label: labels.filterStartsWith },
|
|
2368
3672
|
{ value: "endsWith", label: labels.filterEndsWith }
|
|
2369
3673
|
];
|
|
2370
|
-
const [invalid, setInvalid] =
|
|
2371
|
-
const [optionSearch, setOptionSearch] =
|
|
3674
|
+
const [invalid, setInvalid] = useState2(false);
|
|
3675
|
+
const [optionSearch, setOptionSearch] = useState2("");
|
|
2372
3676
|
const apply = (candidate) => {
|
|
2373
|
-
const decoded =
|
|
2374
|
-
if (
|
|
3677
|
+
const decoded = parseTableFilterDraft(kind, candidate);
|
|
3678
|
+
if (Option4.isNone(decoded)) {
|
|
2375
3679
|
setInvalid(true);
|
|
2376
3680
|
return;
|
|
2377
3681
|
}
|
|
@@ -2383,7 +3687,7 @@ var FilterEditor = ({
|
|
|
2383
3687
|
children: [
|
|
2384
3688
|
/* @__PURE__ */ jsxs9(MenubarRadioGroup, {
|
|
2385
3689
|
value: current?.kind === "boolean" ? String(current.value) : "",
|
|
2386
|
-
onValueChange: (value) => apply({
|
|
3690
|
+
onValueChange: (value) => apply({ ...draft, primary: value }),
|
|
2387
3691
|
children: [
|
|
2388
3692
|
/* @__PURE__ */ jsx15(MenubarRadioItem2, {
|
|
2389
3693
|
value: "true",
|
|
@@ -2429,9 +3733,9 @@ var FilterEditor = ({
|
|
|
2429
3733
|
checked: selected.includes(option.value),
|
|
2430
3734
|
closeOnClick: false,
|
|
2431
3735
|
onCheckedChange: (checked) => {
|
|
2432
|
-
const values =
|
|
3736
|
+
const values = updateSelectedRows(selected, [option.value], checked);
|
|
2433
3737
|
if (values.length)
|
|
2434
|
-
apply({
|
|
3738
|
+
apply({ ...draft, values });
|
|
2435
3739
|
else
|
|
2436
3740
|
onChange(undefined);
|
|
2437
3741
|
},
|
|
@@ -2468,29 +3772,7 @@ var FilterEditor = ({
|
|
|
2468
3772
|
},
|
|
2469
3773
|
onSubmit: (event) => {
|
|
2470
3774
|
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
|
-
}
|
|
3775
|
+
apply(draft);
|
|
2494
3776
|
},
|
|
2495
3777
|
children: [
|
|
2496
3778
|
/* @__PURE__ */ jsxs9(FieldGroup, {
|
|
@@ -2505,9 +3787,9 @@ var FilterEditor = ({
|
|
|
2505
3787
|
items: operatorOptions,
|
|
2506
3788
|
value: operator,
|
|
2507
3789
|
onValueChange: (value) => {
|
|
2508
|
-
const decoded =
|
|
2509
|
-
if (
|
|
2510
|
-
|
|
3790
|
+
const decoded = Schema6.decodeUnknownOption(TextFilterOperator)(value);
|
|
3791
|
+
if (Option4.isSome(decoded))
|
|
3792
|
+
setDraft({ ...draft, operator: decoded.value });
|
|
2511
3793
|
},
|
|
2512
3794
|
children: [
|
|
2513
3795
|
/* @__PURE__ */ jsx15(SelectTrigger, {
|
|
@@ -2540,7 +3822,7 @@ var FilterEditor = ({
|
|
|
2540
3822
|
value: primary,
|
|
2541
3823
|
"aria-invalid": invalid || undefined,
|
|
2542
3824
|
onChange: (event) => {
|
|
2543
|
-
|
|
3825
|
+
setDraft({ ...draft, primary: event.target.value });
|
|
2544
3826
|
setInvalid(false);
|
|
2545
3827
|
}
|
|
2546
3828
|
})
|
|
@@ -2560,7 +3842,7 @@ var FilterEditor = ({
|
|
|
2560
3842
|
value: secondary,
|
|
2561
3843
|
"aria-invalid": invalid || undefined,
|
|
2562
3844
|
onChange: (event) => {
|
|
2563
|
-
|
|
3845
|
+
setDraft({ ...draft, secondary: event.target.value });
|
|
2564
3846
|
setInvalid(false);
|
|
2565
3847
|
}
|
|
2566
3848
|
})
|
|
@@ -2586,8 +3868,7 @@ var FilterEditor = ({
|
|
|
2586
3868
|
size: "sm",
|
|
2587
3869
|
variant: "outline",
|
|
2588
3870
|
onClick: () => {
|
|
2589
|
-
|
|
2590
|
-
setSecondary("");
|
|
3871
|
+
setDraft({ ...draft, primary: "", secondary: "" });
|
|
2591
3872
|
setInvalid(false);
|
|
2592
3873
|
onChange(undefined);
|
|
2593
3874
|
},
|
|
@@ -2599,9 +3880,9 @@ var FilterEditor = ({
|
|
|
2599
3880
|
});
|
|
2600
3881
|
};
|
|
2601
3882
|
var FilterMenu = ({
|
|
2602
|
-
|
|
3883
|
+
table
|
|
2603
3884
|
}) => {
|
|
2604
|
-
const [store,
|
|
3885
|
+
const [store, send] = table;
|
|
2605
3886
|
const model = deriveModel(store);
|
|
2606
3887
|
const columns = model.columns.flatMap((parent) => getDataTableFilterColumns([parent]).map((column) => ({
|
|
2607
3888
|
column,
|
|
@@ -2610,7 +3891,7 @@ var FilterMenu = ({
|
|
|
2610
3891
|
if (!columns.length)
|
|
2611
3892
|
return null;
|
|
2612
3893
|
const filters = store.state.filters ?? [];
|
|
2613
|
-
const update = (id, filter) =>
|
|
3894
|
+
const update = (id, filter) => send(DataTableMessage.ColumnFilterChanged({ id, filter: filter ?? null }));
|
|
2614
3895
|
return /* @__PURE__ */ jsxs9(MenubarMenu, {
|
|
2615
3896
|
children: [
|
|
2616
3897
|
/* @__PURE__ */ jsxs9(MenubarTrigger2, {
|
|
@@ -2663,11 +3944,7 @@ var FilterMenu = ({
|
|
|
2663
3944
|
children: [
|
|
2664
3945
|
/* @__PURE__ */ jsx15(MenubarSeparator2, {}),
|
|
2665
3946
|
/* @__PURE__ */ jsxs9(MenubarItem2, {
|
|
2666
|
-
onClick: () =>
|
|
2667
|
-
...state,
|
|
2668
|
-
page: 0,
|
|
2669
|
-
filters: undefined
|
|
2670
|
-
})),
|
|
3947
|
+
onClick: () => send(DataTableMessage.FiltersCleared()),
|
|
2671
3948
|
children: [
|
|
2672
3949
|
/* @__PURE__ */ jsx15(X, {}),
|
|
2673
3950
|
store.config.labels.filtersClear
|
|
@@ -2682,9 +3959,9 @@ var FilterMenu = ({
|
|
|
2682
3959
|
});
|
|
2683
3960
|
};
|
|
2684
3961
|
var SortMenu = ({
|
|
2685
|
-
|
|
3962
|
+
table
|
|
2686
3963
|
}) => {
|
|
2687
|
-
const [store,
|
|
3964
|
+
const [store, send] = table;
|
|
2688
3965
|
const columns = deriveModel(store).columns.flatMap((column) => getDataTableSortColumns([column]).map((field) => field.id === column.id ? field : {
|
|
2689
3966
|
...field,
|
|
2690
3967
|
colDef: {
|
|
@@ -2695,11 +3972,7 @@ var SortMenu = ({
|
|
|
2695
3972
|
if (!columns.length)
|
|
2696
3973
|
return null;
|
|
2697
3974
|
const current = store.state.sort?.[0];
|
|
2698
|
-
const sort = (id, direction) =>
|
|
2699
|
-
...state,
|
|
2700
|
-
sort: [{ id, direction }],
|
|
2701
|
-
page: 0
|
|
2702
|
-
}));
|
|
3975
|
+
const sort = (id, direction) => send(DataTableMessage.SortRequested({ columnId: id, direction }));
|
|
2703
3976
|
return /* @__PURE__ */ jsxs9(MenubarMenu, {
|
|
2704
3977
|
children: [
|
|
2705
3978
|
/* @__PURE__ */ jsxs9(MenubarTrigger2, {
|
|
@@ -2753,9 +4026,9 @@ var SortMenu = ({
|
|
|
2753
4026
|
children: [
|
|
2754
4027
|
/* @__PURE__ */ jsx15(MenubarSeparator2, {}),
|
|
2755
4028
|
/* @__PURE__ */ jsxs9(MenubarItem2, {
|
|
2756
|
-
onClick: () =>
|
|
2757
|
-
|
|
2758
|
-
|
|
4029
|
+
onClick: () => send(DataTableMessage.SortRequested({
|
|
4030
|
+
columnId: column.id,
|
|
4031
|
+
direction: null
|
|
2759
4032
|
})),
|
|
2760
4033
|
children: [
|
|
2761
4034
|
/* @__PURE__ */ jsx15(X, {}),
|
|
@@ -2777,9 +4050,9 @@ var SortMenu = ({
|
|
|
2777
4050
|
});
|
|
2778
4051
|
};
|
|
2779
4052
|
var ViewMenu = ({
|
|
2780
|
-
|
|
4053
|
+
table
|
|
2781
4054
|
}) => {
|
|
2782
|
-
const [store,
|
|
4055
|
+
const [store, send] = table;
|
|
2783
4056
|
return /* @__PURE__ */ jsxs9(MenubarMenu, {
|
|
2784
4057
|
children: [
|
|
2785
4058
|
/* @__PURE__ */ jsxs9(MenubarTrigger2, {
|
|
@@ -2801,9 +4074,10 @@ var ViewMenu = ({
|
|
|
2801
4074
|
}),
|
|
2802
4075
|
/* @__PURE__ */ jsx15(MenubarSeparator2, {}),
|
|
2803
4076
|
/* @__PURE__ */ jsxs9(MenubarRadioGroup, {
|
|
2804
|
-
onValueChange: (
|
|
2805
|
-
|
|
2806
|
-
|
|
4077
|
+
onValueChange: (input) => {
|
|
4078
|
+
const view = Schema6.decodeUnknownOption(DataTableViewSchema)(input);
|
|
4079
|
+
if (Option4.isSome(view)) {
|
|
4080
|
+
send(DataTableMessage.ViewPicked({ view: view.value }));
|
|
2807
4081
|
}
|
|
2808
4082
|
},
|
|
2809
4083
|
value: store.state.view,
|
|
@@ -2833,9 +4107,9 @@ var ViewMenu = ({
|
|
|
2833
4107
|
});
|
|
2834
4108
|
};
|
|
2835
4109
|
var ColumnMenu = ({
|
|
2836
|
-
|
|
4110
|
+
table
|
|
2837
4111
|
}) => {
|
|
2838
|
-
const [store,
|
|
4112
|
+
const [store, send] = table;
|
|
2839
4113
|
const columns = deriveModel(store).columns.filter(({ colDef }) => colDef.hideable !== false);
|
|
2840
4114
|
if (!columns.length)
|
|
2841
4115
|
return null;
|
|
@@ -2861,13 +4135,7 @@ var ColumnMenu = ({
|
|
|
2861
4135
|
/* @__PURE__ */ jsx15(MenubarSeparator2, {}),
|
|
2862
4136
|
columns.map((column) => /* @__PURE__ */ jsx15(MenubarCheckboxItem2, {
|
|
2863
4137
|
checked: store.state.columnVisibility[column.id] !== false,
|
|
2864
|
-
onCheckedChange: (visible) =>
|
|
2865
|
-
...state,
|
|
2866
|
-
columnVisibility: {
|
|
2867
|
-
...state.columnVisibility,
|
|
2868
|
-
[column.id]: visible
|
|
2869
|
-
}
|
|
2870
|
-
})),
|
|
4138
|
+
onCheckedChange: (visible) => send(DataTableMessage.ColumnVisibilityChanged({ id: column.id, visible })),
|
|
2871
4139
|
children: columnLabel(column)
|
|
2872
4140
|
}, column.id))
|
|
2873
4141
|
]
|
|
@@ -2877,54 +4145,43 @@ var ColumnMenu = ({
|
|
|
2877
4145
|
});
|
|
2878
4146
|
};
|
|
2879
4147
|
var ResizeHandle = ({
|
|
2880
|
-
|
|
4148
|
+
table
|
|
2881
4149
|
}) => {
|
|
2882
|
-
const
|
|
4150
|
+
const tableClasses = useContext2(DataTableSlotClassesContext);
|
|
4151
|
+
const [store, send] = table;
|
|
2883
4152
|
const columnId = useRequiredId(ColumnIdContext);
|
|
2884
|
-
const resizeRef = useRef(null);
|
|
2885
4153
|
const column = deriveModel(store).columns.find(({ id }) => id === columnId);
|
|
2886
4154
|
if (!column || column.colDef.resizable === false)
|
|
2887
4155
|
return null;
|
|
2888
|
-
const
|
|
2889
|
-
...state,
|
|
2890
|
-
columnSizing: {
|
|
2891
|
-
...state.columnSizing,
|
|
2892
|
-
[column.id]: clampWidth(column.colDef, width)
|
|
2893
|
-
}
|
|
2894
|
-
}));
|
|
4156
|
+
const { min, max } = tableColumnLimits(column.colDef);
|
|
2895
4157
|
const onPointerDown = (event) => {
|
|
2896
4158
|
if (event.button !== 0)
|
|
2897
4159
|
return;
|
|
2898
4160
|
event.preventDefault();
|
|
2899
4161
|
event.currentTarget.setPointerCapture(event.pointerId);
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
};
|
|
4162
|
+
send(DataTableMessage.ResizeStarted({
|
|
4163
|
+
id: column.id,
|
|
4164
|
+
x: event.clientX,
|
|
4165
|
+
pointerId: event.pointerId
|
|
4166
|
+
}));
|
|
2905
4167
|
};
|
|
2906
4168
|
const onPointerMove = (event) => {
|
|
2907
|
-
|
|
2908
|
-
if (!drag || drag.pointerId !== event.pointerId)
|
|
2909
|
-
return;
|
|
2910
|
-
resize(drag.startWidth + event.clientX - drag.startX);
|
|
2911
|
-
};
|
|
2912
|
-
const reset = () => {
|
|
2913
|
-
resizeRef.current = null;
|
|
4169
|
+
send(DataTableMessage.ResizeMoved({ x: event.clientX, pointerId: event.pointerId }));
|
|
2914
4170
|
};
|
|
4171
|
+
const reset = (event) => send(DataTableMessage.ResizeEnded({ pointerId: event.pointerId }));
|
|
2915
4172
|
return /* @__PURE__ */ jsx15("button", {
|
|
2916
4173
|
"aria-label": store.config.labels.resizeColumn(columnLabel(column)),
|
|
2917
4174
|
"aria-orientation": "vertical",
|
|
2918
|
-
"aria-valuemax":
|
|
2919
|
-
"aria-valuemin":
|
|
4175
|
+
"aria-valuemax": max,
|
|
4176
|
+
"aria-valuemin": min,
|
|
2920
4177
|
"aria-valuenow": column.width,
|
|
2921
|
-
className:
|
|
2922
|
-
onDoubleClick: () =>
|
|
4178
|
+
className: tableClasses.resizeHandle,
|
|
4179
|
+
onDoubleClick: () => send(DataTableMessage.ColumnResizeReset({ id: column.id })),
|
|
2923
4180
|
onKeyDown: (event) => {
|
|
2924
|
-
const delta = event.key
|
|
4181
|
+
const delta = tableResizeStep(event.key);
|
|
2925
4182
|
if (delta) {
|
|
2926
4183
|
event.preventDefault();
|
|
2927
|
-
|
|
4184
|
+
send(DataTableMessage.ColumnResized({ id: column.id, delta }));
|
|
2928
4185
|
}
|
|
2929
4186
|
},
|
|
2930
4187
|
onPointerDown,
|
|
@@ -2937,12 +4194,12 @@ var ResizeHandle = ({
|
|
|
2937
4194
|
});
|
|
2938
4195
|
};
|
|
2939
4196
|
var DragHandle = ({
|
|
2940
|
-
|
|
4197
|
+
table
|
|
2941
4198
|
}) => {
|
|
2942
|
-
const [store
|
|
4199
|
+
const [store] = table;
|
|
2943
4200
|
const rowId = useRequiredId(RowIdContext);
|
|
2944
|
-
const dragRef =
|
|
2945
|
-
const [overlay, setOverlay] =
|
|
4201
|
+
const dragRef = useRef2(null);
|
|
4202
|
+
const [overlay, setOverlay] = useState2(null);
|
|
2946
4203
|
const reset = (element) => {
|
|
2947
4204
|
clearDragPresentation(element.closest("[data-table-root]"));
|
|
2948
4205
|
dragRef.current = null;
|
|
@@ -2997,7 +4254,8 @@ var DragHandle = ({
|
|
|
2997
4254
|
const elements = document.elementsFromPoint(event.clientX, event.clientY);
|
|
2998
4255
|
const rowTarget = findTableDragTarget(elements, "[data-table-row]", root);
|
|
2999
4256
|
const groupTarget = findTableDragTarget(elements, "[data-table-group]", root);
|
|
3000
|
-
|
|
4257
|
+
if (drag.active) {
|
|
4258
|
+
const current = store;
|
|
3001
4259
|
const targetRowId = rowTarget?.dataset.tableRow;
|
|
3002
4260
|
const targetGroupKey = groupTarget?.dataset.tableGroup;
|
|
3003
4261
|
const model = deriveModel(current);
|
|
@@ -3013,8 +4271,7 @@ var DragHandle = ({
|
|
|
3013
4271
|
} else if (drag.active && source && targetRowId && reordering && canReorderRows(current) && source.id !== targetRowId) {
|
|
3014
4272
|
reordering.onReorder(reorderDataTableRows(model.rows, source.id, targetRowId));
|
|
3015
4273
|
}
|
|
3016
|
-
|
|
3017
|
-
});
|
|
4274
|
+
}
|
|
3018
4275
|
reset(event.currentTarget);
|
|
3019
4276
|
};
|
|
3020
4277
|
const cancel = (event) => {
|
|
@@ -3065,22 +4322,15 @@ var DragHandle = ({
|
|
|
3065
4322
|
]
|
|
3066
4323
|
});
|
|
3067
4324
|
};
|
|
3068
|
-
var toggleRow = (
|
|
3069
|
-
const rowSelection = { ...state.rowSelection, [rowId]: selected };
|
|
3070
|
-
const selection = store.config.features.selection;
|
|
3071
|
-
if (selection) {
|
|
3072
|
-
const model = deriveModel(store);
|
|
3073
|
-
selection.onSelectionChange?.(model.rows.filter((row) => rowSelection[row.id]).map((row) => row.data));
|
|
3074
|
-
}
|
|
3075
|
-
return { ...state, rowSelection };
|
|
3076
|
-
});
|
|
4325
|
+
var toggleRow = (send, rowId, checked) => send(DataTableMessage.SelectionRequested({ rowIds: [rowId], checked }));
|
|
3077
4326
|
var TableDataRow = ({
|
|
3078
|
-
|
|
4327
|
+
table,
|
|
3079
4328
|
row,
|
|
3080
4329
|
virtualIndex,
|
|
3081
4330
|
measureRef
|
|
3082
4331
|
}) => {
|
|
3083
|
-
const
|
|
4332
|
+
const tableClasses = useContext2(DataTableSlotClassesContext);
|
|
4333
|
+
const [store, send] = table;
|
|
3084
4334
|
const model = deriveModel(store);
|
|
3085
4335
|
const selection = store.config.features.selection;
|
|
3086
4336
|
const selectable = !!selection && (selection.isRowSelectable?.(row.data) ?? true);
|
|
@@ -3102,37 +4352,40 @@ var TableDataRow = ({
|
|
|
3102
4352
|
tabIndex: store.config.onRowClicked ? 0 : undefined,
|
|
3103
4353
|
children: [
|
|
3104
4354
|
selection ? /* @__PURE__ */ jsx15(TableCell2, {
|
|
3105
|
-
className:
|
|
4355
|
+
className: tableClasses.selectionCell,
|
|
3106
4356
|
onClick: (event) => event.stopPropagation(),
|
|
3107
|
-
children: /* @__PURE__ */ jsx15(
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
4357
|
+
children: /* @__PURE__ */ jsx15("div", {
|
|
4358
|
+
className: tableClasses.selectionCenter,
|
|
4359
|
+
children: /* @__PURE__ */ jsx15(Checkbox, {
|
|
4360
|
+
"aria-label": store.config.labels.selectRow,
|
|
4361
|
+
checked: !!store.state.rowSelection[row.id],
|
|
4362
|
+
disabled: !selectable,
|
|
4363
|
+
onCheckedChange: (checked) => toggleRow(send, row.id, checked)
|
|
4364
|
+
})
|
|
3112
4365
|
})
|
|
3113
4366
|
}) : null,
|
|
3114
4367
|
draggable ? /* @__PURE__ */ jsx15(TableCell2, {
|
|
3115
4368
|
className: "w-10 pr-0",
|
|
3116
4369
|
children: /* @__PURE__ */ jsx15(DragHandle, {
|
|
3117
|
-
|
|
4370
|
+
table
|
|
3118
4371
|
})
|
|
3119
4372
|
}) : null,
|
|
3120
4373
|
model.visibleColumns.map((column) => /* @__PURE__ */ jsx15(TableCell2, {
|
|
3121
|
-
className: cn("min-w-24
|
|
4374
|
+
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"),
|
|
3122
4375
|
style: { width: column.width },
|
|
3123
4376
|
children: /* @__PURE__ */ jsx15("div", {
|
|
3124
|
-
className: cn(
|
|
4377
|
+
className: cn(tableClasses.cellContent, column.colDef.truncate && "truncate"),
|
|
3125
4378
|
children: renderCell(row, column, store.config.locale, store.config.labels)
|
|
3126
4379
|
})
|
|
3127
4380
|
}, column.id)),
|
|
3128
4381
|
hasRowActionMenu(store) ? /* @__PURE__ */ jsx15(TableCell2, {
|
|
3129
|
-
className: "
|
|
4382
|
+
className: cn(tableClasses.actionsCell, "group-data-[state=selected]/row:bg-muted"),
|
|
3130
4383
|
onClick: (event) => event.stopPropagation(),
|
|
3131
4384
|
children: /* @__PURE__ */ jsx15("div", {
|
|
3132
|
-
className:
|
|
4385
|
+
className: tableClasses.actionsAlign,
|
|
3133
4386
|
children: /* @__PURE__ */ jsx15(DataTableRowActionMenu, {
|
|
3134
4387
|
row,
|
|
3135
|
-
|
|
4388
|
+
table
|
|
3136
4389
|
})
|
|
3137
4390
|
})
|
|
3138
4391
|
}) : null
|
|
@@ -3182,35 +4435,30 @@ var GroupActions = ({
|
|
|
3182
4435
|
});
|
|
3183
4436
|
};
|
|
3184
4437
|
var GroupHeaderRow = ({
|
|
3185
|
-
|
|
4438
|
+
table,
|
|
3186
4439
|
section,
|
|
3187
4440
|
colSpan,
|
|
3188
4441
|
virtualIndex,
|
|
3189
4442
|
measureRef
|
|
3190
4443
|
}) => {
|
|
3191
|
-
const
|
|
4444
|
+
const tableClasses = useContext2(DataTableSlotClassesContext);
|
|
4445
|
+
const [store, send] = table;
|
|
3192
4446
|
const collapsed = !!store.state.collapsedGroups[section.key];
|
|
3193
4447
|
return /* @__PURE__ */ jsx15(TableRow2, {
|
|
3194
4448
|
ref: measureRef,
|
|
3195
4449
|
"data-index": virtualIndex,
|
|
3196
4450
|
"aria-rowindex": virtualIndex === undefined ? undefined : virtualIndex + 2,
|
|
3197
|
-
className: "
|
|
3198
|
-
onClick: () =>
|
|
3199
|
-
...state,
|
|
3200
|
-
collapsedGroups: {
|
|
3201
|
-
...state.collapsedGroups,
|
|
3202
|
-
[section.key]: !collapsed
|
|
3203
|
-
}
|
|
3204
|
-
})),
|
|
4451
|
+
className: cn(tableClasses.group, "cursor-pointer"),
|
|
4452
|
+
onClick: () => send(DataTableMessage.GroupToggled({ key: section.key })),
|
|
3205
4453
|
children: /* @__PURE__ */ jsx15(TableCell2, {
|
|
3206
4454
|
className: "p-0",
|
|
3207
4455
|
colSpan,
|
|
3208
4456
|
children: /* @__PURE__ */ jsxs9("div", {
|
|
3209
|
-
className:
|
|
4457
|
+
className: cn(tableClasses.groupContent, tableClasses.groupSticky),
|
|
3210
4458
|
children: [
|
|
3211
4459
|
/* @__PURE__ */ jsxs9("button", {
|
|
3212
4460
|
"aria-expanded": !collapsed,
|
|
3213
|
-
className:
|
|
4461
|
+
className: tableClasses.groupTrigger,
|
|
3214
4462
|
style: { paddingLeft: section.depth * 20 },
|
|
3215
4463
|
type: "button",
|
|
3216
4464
|
children: [
|
|
@@ -3225,9 +4473,8 @@ var GroupHeaderRow = ({
|
|
|
3225
4473
|
})
|
|
3226
4474
|
]
|
|
3227
4475
|
}),
|
|
3228
|
-
/* @__PURE__ */ jsx15(
|
|
3229
|
-
className:
|
|
3230
|
-
variant: "secondary",
|
|
4476
|
+
/* @__PURE__ */ jsx15("span", {
|
|
4477
|
+
className: tableClasses.count,
|
|
3231
4478
|
children: section.rows.length
|
|
3232
4479
|
}),
|
|
3233
4480
|
/* @__PURE__ */ jsx15(GroupActions, {
|
|
@@ -3241,10 +4488,10 @@ var GroupHeaderRow = ({
|
|
|
3241
4488
|
});
|
|
3242
4489
|
};
|
|
3243
4490
|
var GroupedTable = ({
|
|
3244
|
-
|
|
4491
|
+
table,
|
|
3245
4492
|
sections
|
|
3246
4493
|
}) => {
|
|
3247
|
-
const [store] =
|
|
4494
|
+
const [store] = table;
|
|
3248
4495
|
const model = deriveModel(store);
|
|
3249
4496
|
const extra = (store.config.features.selection ? 1 : 0) + (hasRowActionMenu(store) ? 1 : 0) + (canDragRows(store) ? 1 : 0);
|
|
3250
4497
|
const renderSections = (items) => items.flatMap((section) => {
|
|
@@ -3255,7 +4502,7 @@ var GroupedTable = ({
|
|
|
3255
4502
|
"data-table-group": section.field.onMoveToGroup ? targetKey : undefined,
|
|
3256
4503
|
children: [
|
|
3257
4504
|
/* @__PURE__ */ jsx15(GroupHeaderRow, {
|
|
3258
|
-
|
|
4505
|
+
table,
|
|
3259
4506
|
section,
|
|
3260
4507
|
colSpan: model.visibleColumns.length + extra
|
|
3261
4508
|
}),
|
|
@@ -3263,7 +4510,7 @@ var GroupedTable = ({
|
|
|
3263
4510
|
value: row.id,
|
|
3264
4511
|
children: /* @__PURE__ */ jsx15(TableDataRow, {
|
|
3265
4512
|
row,
|
|
3266
|
-
|
|
4513
|
+
table
|
|
3267
4514
|
})
|
|
3268
4515
|
}, `${section.key}:${row.id}`)) : [
|
|
3269
4516
|
/* @__PURE__ */ jsx15(TableRow2, {
|
|
@@ -3283,9 +4530,10 @@ var GroupedTable = ({
|
|
|
3283
4530
|
});
|
|
3284
4531
|
};
|
|
3285
4532
|
var ColumnHeaderMenu = ({
|
|
3286
|
-
|
|
4533
|
+
table
|
|
3287
4534
|
}) => {
|
|
3288
|
-
const
|
|
4535
|
+
const tableClasses = useContext2(DataTableSlotClassesContext);
|
|
4536
|
+
const [store, send] = table;
|
|
3289
4537
|
const columnId = useRequiredId(ColumnIdContext);
|
|
3290
4538
|
const model = deriveModel(store);
|
|
3291
4539
|
const column = model.columns.find(({ id }) => id === columnId);
|
|
@@ -3301,18 +4549,13 @@ var ColumnHeaderMenu = ({
|
|
|
3301
4549
|
rows: model.rows,
|
|
3302
4550
|
current: store.state.filters?.find((filter) => filter.id === field.id),
|
|
3303
4551
|
labels: store.config.labels,
|
|
3304
|
-
onChange: (filter) =>
|
|
4552
|
+
onChange: (filter) => send(DataTableMessage.ColumnFilterChanged({ id: field.id, filter: filter ?? null }))
|
|
3305
4553
|
});
|
|
3306
4554
|
const sortingEnabled = store.config.features.sorting !== false && sortColumns.length > 0;
|
|
3307
4555
|
const hidingEnabled = store.config.features.columnVisibility !== false && column.colDef.hideable !== false;
|
|
3308
4556
|
const ownsSort = (id) => id === column.id || sortColumns.some((field) => field.id === id);
|
|
3309
4557
|
const sort = store.state.sort?.find(({ id }) => ownsSort(id));
|
|
3310
|
-
const
|
|
3311
|
-
const setSort = (id, direction) => update((state) => ({
|
|
3312
|
-
...state,
|
|
3313
|
-
sort: [{ id, direction }],
|
|
3314
|
-
page: 0
|
|
3315
|
-
}));
|
|
4558
|
+
const setSort = (id, direction) => send(DataTableMessage.SortRequested({ columnId: id, direction }));
|
|
3316
4559
|
const label = columnLabel(column);
|
|
3317
4560
|
const sortItems = (field) => /* @__PURE__ */ jsxs9(Fragment, {
|
|
3318
4561
|
children: [
|
|
@@ -3346,7 +4589,7 @@ var ColumnHeaderMenu = ({
|
|
|
3346
4589
|
render: /* @__PURE__ */ jsxs9(Button, {
|
|
3347
4590
|
"aria-label": label,
|
|
3348
4591
|
"aria-description": activeFilters.length ? `${store.config.labels.filters}: ${activeFilters.length}` : undefined,
|
|
3349
|
-
className:
|
|
4592
|
+
className: tableClasses.headerTrigger,
|
|
3350
4593
|
variant: "ghost",
|
|
3351
4594
|
children: [
|
|
3352
4595
|
/* @__PURE__ */ jsx15("span", {
|
|
@@ -3378,10 +4621,7 @@ var ColumnHeaderMenu = ({
|
|
|
3378
4621
|
]
|
|
3379
4622
|
}, field.id)) : sortItems(column),
|
|
3380
4623
|
sort ? /* @__PURE__ */ jsxs9(DropdownMenuItem2, {
|
|
3381
|
-
onClick: () =>
|
|
3382
|
-
...state,
|
|
3383
|
-
sort: state.sort?.filter(({ id }) => !ownsSort(id))
|
|
3384
|
-
})),
|
|
4624
|
+
onClick: () => send(DataTableMessage.ColumnSortCleared({ id: column.id })),
|
|
3385
4625
|
children: [
|
|
3386
4626
|
/* @__PURE__ */ jsx15(X, {}),
|
|
3387
4627
|
" ",
|
|
@@ -3423,14 +4663,7 @@ var ColumnHeaderMenu = ({
|
|
|
3423
4663
|
]
|
|
3424
4664
|
}),
|
|
3425
4665
|
activeFilters.length ? /* @__PURE__ */ jsxs9(DropdownMenuItem2, {
|
|
3426
|
-
onClick: () =>
|
|
3427
|
-
const filters = state.filters?.filter(({ id }) => !ownsFilter(id));
|
|
3428
|
-
return {
|
|
3429
|
-
...state,
|
|
3430
|
-
page: 0,
|
|
3431
|
-
filters: filters?.length ? filters : undefined
|
|
3432
|
-
};
|
|
3433
|
-
}),
|
|
4666
|
+
onClick: () => send(DataTableMessage.ColumnFiltersCleared({ id: column.id })),
|
|
3434
4667
|
children: [
|
|
3435
4668
|
/* @__PURE__ */ jsx15(X, {}),
|
|
3436
4669
|
store.config.labels.filterClear
|
|
@@ -3440,12 +4673,9 @@ var ColumnHeaderMenu = ({
|
|
|
3440
4673
|
}) : null,
|
|
3441
4674
|
(sortingEnabled || filteringEnabled) && hidingEnabled ? /* @__PURE__ */ jsx15(DropdownMenuSeparator2, {}) : null,
|
|
3442
4675
|
hidingEnabled ? /* @__PURE__ */ jsxs9(DropdownMenuItem2, {
|
|
3443
|
-
onClick: () =>
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
...state.columnVisibility,
|
|
3447
|
-
[column.id]: false
|
|
3448
|
-
}
|
|
4676
|
+
onClick: () => send(DataTableMessage.ColumnVisibilityChanged({
|
|
4677
|
+
id: column.id,
|
|
4678
|
+
visible: false
|
|
3449
4679
|
})),
|
|
3450
4680
|
children: [
|
|
3451
4681
|
/* @__PURE__ */ jsx15(EyeOff, {}),
|
|
@@ -3460,36 +4690,37 @@ var ColumnHeaderMenu = ({
|
|
|
3460
4690
|
});
|
|
3461
4691
|
};
|
|
3462
4692
|
var DataTableHeader = ({
|
|
3463
|
-
|
|
4693
|
+
table,
|
|
3464
4694
|
sticky
|
|
3465
4695
|
}) => {
|
|
3466
|
-
const
|
|
4696
|
+
const tableClasses = useContext2(DataTableSlotClassesContext);
|
|
4697
|
+
const [store, send] = table;
|
|
3467
4698
|
const model = deriveModel(store);
|
|
3468
4699
|
const selection = store.config.features.selection;
|
|
3469
|
-
const grouped = getActiveGrouping(store).length > 0;
|
|
3470
4700
|
const draggable = canDragRows(store);
|
|
3471
|
-
const selectableRows =
|
|
4701
|
+
const selectableRows = model.pageRows.filter((row) => !selection || (selection.isRowSelectable?.(row.data) ?? true));
|
|
3472
4702
|
const allSelected = selectableRows.length > 0 && selectableRows.every((row) => store.state.rowSelection[row.id]);
|
|
3473
4703
|
const someSelected = selectableRows.some((row) => store.state.rowSelection[row.id]);
|
|
3474
4704
|
return /* @__PURE__ */ jsx15(TableHeader2, {
|
|
3475
|
-
className: sticky ?
|
|
4705
|
+
className: sticky ? cn(tableClasses.stickyHeader, tableClasses.stickyHeaderRule, "[&_tr]:border-b-0") : undefined,
|
|
3476
4706
|
children: /* @__PURE__ */ jsxs9(TableRow2, {
|
|
3477
4707
|
"aria-rowindex": sticky ? 1 : undefined,
|
|
3478
4708
|
children: [
|
|
3479
4709
|
selection ? /* @__PURE__ */ jsx15(TableHead2, {
|
|
3480
|
-
className:
|
|
3481
|
-
children: /* @__PURE__ */ jsx15(
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
|
|
3492
|
-
|
|
4710
|
+
className: tableClasses.selectionCell,
|
|
4711
|
+
children: /* @__PURE__ */ jsx15("div", {
|
|
4712
|
+
className: tableClasses.selectionCenter,
|
|
4713
|
+
children: /* @__PURE__ */ jsx15(Checkbox, {
|
|
4714
|
+
"aria-label": store.config.labels.selectAllRows,
|
|
4715
|
+
checked: allSelected,
|
|
4716
|
+
indeterminate: someSelected && !allSelected,
|
|
4717
|
+
onCheckedChange: (checked) => {
|
|
4718
|
+
send(DataTableMessage.SelectionRequested({
|
|
4719
|
+
rowIds: selectableRows.map(({ id }) => id),
|
|
4720
|
+
checked
|
|
4721
|
+
}));
|
|
4722
|
+
}
|
|
4723
|
+
})
|
|
3493
4724
|
})
|
|
3494
4725
|
}) : null,
|
|
3495
4726
|
draggable ? /* @__PURE__ */ jsx15(TableHead2, {
|
|
@@ -3499,17 +4730,17 @@ var DataTableHeader = ({
|
|
|
3499
4730
|
const direction = store.state.sort?.find(({ id }) => id === column.id)?.direction;
|
|
3500
4731
|
return /* @__PURE__ */ jsx15(TableHead2, {
|
|
3501
4732
|
"aria-sort": direction === "asc" ? "ascending" : direction === "desc" ? "descending" : undefined,
|
|
3502
|
-
className:
|
|
4733
|
+
className: tableClasses.header,
|
|
3503
4734
|
scope: "col",
|
|
3504
4735
|
style: { width: column.width },
|
|
3505
4736
|
children: /* @__PURE__ */ jsxs9(ColumnIdContext.Provider, {
|
|
3506
4737
|
value: column.id,
|
|
3507
4738
|
children: [
|
|
3508
4739
|
/* @__PURE__ */ jsx15(ColumnHeaderMenu, {
|
|
3509
|
-
|
|
4740
|
+
table
|
|
3510
4741
|
}),
|
|
3511
4742
|
/* @__PURE__ */ jsx15(ResizeHandle, {
|
|
3512
|
-
|
|
4743
|
+
table
|
|
3513
4744
|
})
|
|
3514
4745
|
]
|
|
3515
4746
|
})
|
|
@@ -3523,13 +4754,13 @@ var DataTableHeader = ({
|
|
|
3523
4754
|
});
|
|
3524
4755
|
};
|
|
3525
4756
|
var VirtualTableRows = ({
|
|
3526
|
-
|
|
4757
|
+
table,
|
|
3527
4758
|
rows,
|
|
3528
4759
|
sections,
|
|
3529
4760
|
viewport,
|
|
3530
4761
|
colSpan
|
|
3531
4762
|
}) => {
|
|
3532
|
-
const [{ state, config }] =
|
|
4763
|
+
const [{ state, config }] = table;
|
|
3533
4764
|
const { element: scrollElement, headerHeight } = viewport;
|
|
3534
4765
|
const pageScroll = viewport.options.scroll === "page";
|
|
3535
4766
|
const scrollMargin = viewport.pageOffset ?? headerHeight;
|
|
@@ -3561,7 +4792,7 @@ var VirtualTableRows = ({
|
|
|
3561
4792
|
result.push({ key: `row:${row.id}`, kind: "data", row });
|
|
3562
4793
|
return result;
|
|
3563
4794
|
}, [rows, sections, state.collapsedGroups]);
|
|
3564
|
-
|
|
4795
|
+
useLayoutEffect2(() => {
|
|
3565
4796
|
if (!pageScroll && scrollElement)
|
|
3566
4797
|
scrollElement.scrollTop = 0;
|
|
3567
4798
|
}, [
|
|
@@ -3576,7 +4807,7 @@ var VirtualTableRows = ({
|
|
|
3576
4807
|
]);
|
|
3577
4808
|
const options = {
|
|
3578
4809
|
count: entries.length,
|
|
3579
|
-
getItemKey:
|
|
4810
|
+
getItemKey: useCallback2((index) => entries[index].key, [entries]),
|
|
3580
4811
|
estimateSize: () => viewport.options.estimateRowHeight ?? 64,
|
|
3581
4812
|
overscan: viewport.options.overscan ?? 5,
|
|
3582
4813
|
scrollMargin
|
|
@@ -3614,7 +4845,7 @@ var VirtualTableRows = ({
|
|
|
3614
4845
|
return /* @__PURE__ */ jsx15(TableDataRow, {
|
|
3615
4846
|
measureRef: virtualizer.measureElement,
|
|
3616
4847
|
row: entry.row,
|
|
3617
|
-
|
|
4848
|
+
table,
|
|
3618
4849
|
virtualIndex: index
|
|
3619
4850
|
}, key);
|
|
3620
4851
|
if (entry.kind === "header")
|
|
@@ -3622,7 +4853,7 @@ var VirtualTableRows = ({
|
|
|
3622
4853
|
measureRef: virtualizer.measureElement,
|
|
3623
4854
|
section: entry.section,
|
|
3624
4855
|
colSpan,
|
|
3625
|
-
|
|
4856
|
+
table,
|
|
3626
4857
|
virtualIndex: index
|
|
3627
4858
|
}, key);
|
|
3628
4859
|
return /* @__PURE__ */ jsx15(TableRow2, {
|
|
@@ -3641,21 +4872,20 @@ var VirtualTableRows = ({
|
|
|
3641
4872
|
});
|
|
3642
4873
|
};
|
|
3643
4874
|
var DataTableBody = ({
|
|
3644
|
-
|
|
4875
|
+
table,
|
|
3645
4876
|
viewport
|
|
3646
4877
|
}) => {
|
|
3647
|
-
const styles =
|
|
3648
|
-
const [store] =
|
|
4878
|
+
const styles = useContext2(DataTableStylesContext);
|
|
4879
|
+
const [store] = table;
|
|
3649
4880
|
const model = deriveModel(store);
|
|
3650
4881
|
const fields = getActiveGrouping(store);
|
|
3651
|
-
const
|
|
3652
|
-
const rows = grouped ? model.sortedRows : model.pageRows;
|
|
4882
|
+
const rows = model.pageRows;
|
|
3653
4883
|
const sections = useMemo2(() => groupDataTableRows(rows, fields), [rows, fields]);
|
|
3654
4884
|
const colSpan = model.visibleColumns.length + (store.config.features.selection ? 1 : 0) + (hasRowActionMenu(store) ? 1 : 0) + (canDragRows(store) ? 1 : 0);
|
|
3655
4885
|
const showGroups = sections.length && (rows.length || !store.config.status.loading) && !store.config.status.error;
|
|
3656
4886
|
if (showGroups && !viewport) {
|
|
3657
4887
|
return /* @__PURE__ */ jsx15(GroupedTable, {
|
|
3658
|
-
|
|
4888
|
+
table,
|
|
3659
4889
|
sections
|
|
3660
4890
|
});
|
|
3661
4891
|
}
|
|
@@ -3681,30 +4911,17 @@ var DataTableBody = ({
|
|
|
3681
4911
|
colSpan,
|
|
3682
4912
|
rows,
|
|
3683
4913
|
sections,
|
|
3684
|
-
|
|
4914
|
+
table,
|
|
3685
4915
|
viewport
|
|
3686
4916
|
}) : rows.map((row) => /* @__PURE__ */ jsx15(RowIdContext.Provider, {
|
|
3687
4917
|
value: row.id,
|
|
3688
4918
|
children: /* @__PURE__ */ jsx15(TableDataRow, {
|
|
3689
4919
|
row,
|
|
3690
|
-
|
|
4920
|
+
table
|
|
3691
4921
|
})
|
|
3692
4922
|
}, row.id))
|
|
3693
4923
|
});
|
|
3694
4924
|
};
|
|
3695
|
-
var GalleryImage = ({ src, alt }) => {
|
|
3696
|
-
const [failed, setFailed] = useState(false);
|
|
3697
|
-
if (failed)
|
|
3698
|
-
return null;
|
|
3699
|
-
return /* @__PURE__ */ jsx15("img", {
|
|
3700
|
-
src,
|
|
3701
|
-
alt,
|
|
3702
|
-
loading: "lazy",
|
|
3703
|
-
decoding: "async",
|
|
3704
|
-
className: "aspect-video w-full object-cover",
|
|
3705
|
-
onError: () => setFailed(true)
|
|
3706
|
-
});
|
|
3707
|
-
};
|
|
3708
4925
|
var GalleryTag = ({
|
|
3709
4926
|
row,
|
|
3710
4927
|
column,
|
|
@@ -3731,9 +4948,9 @@ var GalleryTag = ({
|
|
|
3731
4948
|
});
|
|
3732
4949
|
};
|
|
3733
4950
|
var GalleryCard = ({
|
|
3734
|
-
|
|
4951
|
+
table
|
|
3735
4952
|
}) => {
|
|
3736
|
-
const [store,
|
|
4953
|
+
const [store, send] = table;
|
|
3737
4954
|
const rowId = useRequiredId(RowIdContext);
|
|
3738
4955
|
const model = deriveModel(store);
|
|
3739
4956
|
const row = model.sortedRows.find((candidate) => candidate.id === rowId);
|
|
@@ -3762,10 +4979,14 @@ var GalleryCard = ({
|
|
|
3762
4979
|
},
|
|
3763
4980
|
tabIndex: store.config.onRowClicked ? 0 : undefined,
|
|
3764
4981
|
children: [
|
|
3765
|
-
imageSrc ? /* @__PURE__ */ jsx15(
|
|
4982
|
+
imageSrc && !store.ui.failedImages.includes(imageSrc) ? /* @__PURE__ */ jsx15("img", {
|
|
3766
4983
|
src: imageSrc,
|
|
3767
|
-
alt: gallery.image?.getAlt?.(row.data) ?? ""
|
|
3768
|
-
|
|
4984
|
+
alt: gallery.image?.getAlt?.(row.data) ?? "",
|
|
4985
|
+
loading: "lazy",
|
|
4986
|
+
decoding: "async",
|
|
4987
|
+
className: "aspect-video w-full object-cover",
|
|
4988
|
+
onError: () => send(DataTableMessage.ReferenceImageFailed({ src: imageSrc }))
|
|
4989
|
+
}) : null,
|
|
3769
4990
|
/* @__PURE__ */ jsxs9(CardHeader, {
|
|
3770
4991
|
className: cn("relative", hasRowActionMenu(store) && "pr-12"),
|
|
3771
4992
|
children: [
|
|
@@ -3776,11 +4997,11 @@ var GalleryCard = ({
|
|
|
3776
4997
|
"aria-label": store.config.labels.selectRow,
|
|
3777
4998
|
checked: !!store.state.rowSelection[row.id],
|
|
3778
4999
|
disabled: !selectable,
|
|
3779
|
-
onCheckedChange: (checked) => toggleRow(
|
|
5000
|
+
onCheckedChange: (checked) => toggleRow(send, row.id, checked),
|
|
3780
5001
|
onClick: (event) => event.stopPropagation()
|
|
3781
5002
|
}) : null,
|
|
3782
5003
|
draggable ? /* @__PURE__ */ jsx15(DragHandle, {
|
|
3783
|
-
|
|
5004
|
+
table
|
|
3784
5005
|
}) : null
|
|
3785
5006
|
]
|
|
3786
5007
|
}) : null,
|
|
@@ -3809,7 +5030,7 @@ var GalleryCard = ({
|
|
|
3809
5030
|
onClick: (event) => event.stopPropagation(),
|
|
3810
5031
|
children: /* @__PURE__ */ jsx15(DataTableRowActionMenu, {
|
|
3811
5032
|
row,
|
|
3812
|
-
|
|
5033
|
+
table
|
|
3813
5034
|
})
|
|
3814
5035
|
}) : null
|
|
3815
5036
|
]
|
|
@@ -3818,13 +5039,13 @@ var GalleryCard = ({
|
|
|
3818
5039
|
});
|
|
3819
5040
|
};
|
|
3820
5041
|
var DataTableGallery = ({
|
|
3821
|
-
|
|
5042
|
+
table
|
|
3822
5043
|
}) => {
|
|
3823
|
-
const styles =
|
|
3824
|
-
const [store,
|
|
5044
|
+
const styles = useContext2(DataTableStylesContext);
|
|
5045
|
+
const [store, send] = table;
|
|
3825
5046
|
const model = deriveModel(store);
|
|
3826
5047
|
const fields = getActiveGrouping(store);
|
|
3827
|
-
const rows =
|
|
5048
|
+
const rows = model.pageRows;
|
|
3828
5049
|
const sections = groupDataTableRows(rows, fields);
|
|
3829
5050
|
if (store.config.status.error) {
|
|
3830
5051
|
return /* @__PURE__ */ jsx15("div", {
|
|
@@ -3856,7 +5077,7 @@ var DataTableGallery = ({
|
|
|
3856
5077
|
children: rows.map((row) => /* @__PURE__ */ jsx15(RowIdContext.Provider, {
|
|
3857
5078
|
value: row.id,
|
|
3858
5079
|
children: /* @__PURE__ */ jsx15(GalleryCard, {
|
|
3859
|
-
|
|
5080
|
+
table
|
|
3860
5081
|
})
|
|
3861
5082
|
}, row.id))
|
|
3862
5083
|
});
|
|
@@ -3864,13 +5085,7 @@ var DataTableGallery = ({
|
|
|
3864
5085
|
const renderSections = (sections) => sections.map((section) => {
|
|
3865
5086
|
const collapsed = !!store.state.collapsedGroups[section.key];
|
|
3866
5087
|
const targetKey = getGroupDropKey(section.field.id, section.groupId);
|
|
3867
|
-
const toggleCollapsed = () =>
|
|
3868
|
-
...state,
|
|
3869
|
-
collapsedGroups: {
|
|
3870
|
-
...state.collapsedGroups,
|
|
3871
|
-
[section.key]: !collapsed
|
|
3872
|
-
}
|
|
3873
|
-
}));
|
|
5088
|
+
const toggleCollapsed = () => send(DataTableMessage.GroupToggled({ key: section.key }));
|
|
3874
5089
|
return /* @__PURE__ */ jsxs9("section", {
|
|
3875
5090
|
className: "data-[drop-target=true]:ring-primary space-y-3 rounded-lg transition-shadow data-[drop-target=true]:ring-2",
|
|
3876
5091
|
"data-table-group": section.field.onMoveToGroup ? targetKey : undefined,
|
|
@@ -3912,7 +5127,7 @@ var DataTableGallery = ({
|
|
|
3912
5127
|
children: section.rows.map((row) => /* @__PURE__ */ jsx15(RowIdContext.Provider, {
|
|
3913
5128
|
value: row.id,
|
|
3914
5129
|
children: /* @__PURE__ */ jsx15(GalleryCard, {
|
|
3915
|
-
|
|
5130
|
+
table
|
|
3916
5131
|
})
|
|
3917
5132
|
}, `${section.key}:${row.id}`))
|
|
3918
5133
|
}) : /* @__PURE__ */ jsx15("div", {
|
|
@@ -3928,38 +5143,32 @@ var DataTableGallery = ({
|
|
|
3928
5143
|
});
|
|
3929
5144
|
};
|
|
3930
5145
|
var DataTablePagination = ({
|
|
3931
|
-
|
|
5146
|
+
table
|
|
3932
5147
|
}) => {
|
|
3933
|
-
const styles =
|
|
3934
|
-
const [store,
|
|
5148
|
+
const styles = useContext2(DataTableStylesContext);
|
|
5149
|
+
const [store, send] = table;
|
|
3935
5150
|
const model = deriveModel(store);
|
|
3936
5151
|
const pagination = store.config.features.pagination ?? false;
|
|
3937
|
-
const
|
|
3938
|
-
const paginationVisible = pagination !== false && !clientGrouping;
|
|
5152
|
+
const { paginationVisible, page } = model;
|
|
3939
5153
|
const pageIndex = store.state.page;
|
|
3940
|
-
|
|
3941
|
-
|
|
3942
|
-
|
|
3943
|
-
changeState(setStore, (state) => ({
|
|
3944
|
-
...state,
|
|
3945
|
-
page: maxPageIndex
|
|
3946
|
-
}));
|
|
5154
|
+
useLayoutEffect2(() => {
|
|
5155
|
+
if (paginationVisible && pagination && pagination.mode === "client" && pageIndex > page) {
|
|
5156
|
+
send(DataTableMessage.PageRequested({ page }));
|
|
3947
5157
|
}
|
|
3948
|
-
}, [
|
|
3949
|
-
if (!paginationVisible)
|
|
5158
|
+
}, [page, pageIndex, pagination, paginationVisible, send]);
|
|
5159
|
+
if (!paginationVisible || !pagination)
|
|
3950
5160
|
return null;
|
|
3951
5161
|
const selected = model.rows.filter((row) => store.state.rowSelection[row.id]).length;
|
|
3952
|
-
const setPagination = (next) => changeState(setStore, (state) => ({ ...state, ...next }));
|
|
3953
5162
|
return /* @__PURE__ */ jsx15("div", {
|
|
3954
5163
|
"data-table-slot": "pagination",
|
|
3955
|
-
className: cn("pt-4", styles?.pagination),
|
|
5164
|
+
className: cn("shrink-0 pt-4", styles?.pagination),
|
|
3956
5165
|
children: /* @__PURE__ */ jsx15(Pagination, {
|
|
3957
5166
|
pageSizeContentClassName: styles?.popup?.select,
|
|
3958
5167
|
locale: store.config.locale,
|
|
3959
5168
|
messages: { [store.config.locale]: store.config.labels },
|
|
3960
|
-
onPageChange: (page) =>
|
|
3961
|
-
onPageSizeChange: (pageSize) =>
|
|
3962
|
-
page
|
|
5169
|
+
onPageChange: (page) => send(DataTableMessage.PageRequested({ page })),
|
|
5170
|
+
onPageSizeChange: (pageSize) => send(DataTableMessage.PageSizeRequested({ pageSize })),
|
|
5171
|
+
page,
|
|
3963
5172
|
pageCount: model.pageCount,
|
|
3964
5173
|
pageSize: store.state.pageSize,
|
|
3965
5174
|
pageSizes: pagination.pageSizes,
|
|
@@ -3968,155 +5177,226 @@ var DataTablePagination = ({
|
|
|
3968
5177
|
})
|
|
3969
5178
|
});
|
|
3970
5179
|
};
|
|
3971
|
-
var
|
|
3972
|
-
|
|
3973
|
-
|
|
3974
|
-
|
|
3975
|
-
|
|
3976
|
-
const
|
|
3977
|
-
|
|
3978
|
-
|
|
3979
|
-
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
|
|
3983
|
-
|
|
3984
|
-
|
|
3985
|
-
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
|
|
3990
|
-
|
|
3991
|
-
|
|
3992
|
-
|
|
3993
|
-
|
|
3994
|
-
|
|
3995
|
-
|
|
3996
|
-
|
|
3997
|
-
|
|
3998
|
-
|
|
5180
|
+
var ReactTableModel = Component3.define(dataTableOptions).make({
|
|
5181
|
+
...dataTableBehaviours,
|
|
5182
|
+
view: () => View2.text("")
|
|
5183
|
+
});
|
|
5184
|
+
var modelField = (id, definition) => {
|
|
5185
|
+
const field = {
|
|
5186
|
+
id,
|
|
5187
|
+
headerName: id,
|
|
5188
|
+
type: definition.type ?? "text"
|
|
5189
|
+
};
|
|
5190
|
+
if (definition.sortable !== undefined)
|
|
5191
|
+
field.sortable = definition.sortable;
|
|
5192
|
+
if (definition.filterable !== undefined)
|
|
5193
|
+
field.filterable = definition.filterable;
|
|
5194
|
+
return field;
|
|
5195
|
+
};
|
|
5196
|
+
var modelColumns = (definitions) => normalizeDataTableColumns(definitions).map(({ id, colDef }) => {
|
|
5197
|
+
const column = modelField(id, colDef);
|
|
5198
|
+
if (colDef.width !== undefined)
|
|
5199
|
+
column.width = colDef.width;
|
|
5200
|
+
if (colDef.minWidth !== undefined)
|
|
5201
|
+
column.minWidth = colDef.minWidth;
|
|
5202
|
+
if (colDef.maxWidth !== undefined)
|
|
5203
|
+
column.maxWidth = colDef.maxWidth;
|
|
5204
|
+
if (colDef.hideable !== undefined)
|
|
5205
|
+
column.hideable = colDef.hideable;
|
|
5206
|
+
if (colDef.resizable !== undefined)
|
|
5207
|
+
column.resizable = colDef.resizable;
|
|
5208
|
+
if (colDef.fields)
|
|
5209
|
+
column.fields = colDef.fields.map((field) => modelField(field.id, field));
|
|
5210
|
+
return column;
|
|
5211
|
+
});
|
|
5212
|
+
var getTableLayoutClass = (virtualization) => virtualization && virtualization !== true && virtualization.scroll === "internal" ? "flex min-h-0 flex-1 flex-col" : undefined;
|
|
5213
|
+
var HydratedDataTable = (props) => {
|
|
5214
|
+
const config = useMemo2(() => resolveConfig(props), [props]);
|
|
5215
|
+
const columns = useMemo2(() => modelColumns(props.columnDefs), [props.columnDefs]);
|
|
5216
|
+
const selection = config.features.selection;
|
|
5217
|
+
const modelProps = useMemo2(() => {
|
|
5218
|
+
const { features } = config;
|
|
5219
|
+
const grouping = features.grouping;
|
|
5220
|
+
const pagination = features.pagination;
|
|
5221
|
+
const [firstSize, ...otherSizes] = pagination && pagination.pageSizes || [];
|
|
5222
|
+
const modelFeatures = {
|
|
5223
|
+
search: features.search !== false,
|
|
5224
|
+
filtering: features.filtering !== false,
|
|
5225
|
+
sorting: features.sorting !== false,
|
|
5226
|
+
columnVisibility: features.columnVisibility !== false,
|
|
5227
|
+
pagination: pagination ? {
|
|
5228
|
+
...pagination,
|
|
5229
|
+
pageSizes: firstSize === undefined ? undefined : [firstSize, ...otherSizes]
|
|
5230
|
+
} : false
|
|
3999
5231
|
};
|
|
4000
|
-
|
|
4001
|
-
|
|
4002
|
-
|
|
4003
|
-
|
|
4004
|
-
|
|
4005
|
-
|
|
4006
|
-
useLayoutEffect(() => {
|
|
4007
|
-
setStore((store) => {
|
|
4008
|
-
const features = props.features ?? {};
|
|
4009
|
-
const selection = features.selection;
|
|
4010
|
-
const config = {
|
|
4011
|
-
getRowId: selection && selection.getRowId || props.getRowId || undefined,
|
|
4012
|
-
onStateChange: props.onStateChange,
|
|
4013
|
-
onUiStateChange: (state) => setUiState(state),
|
|
4014
|
-
status: props.status ?? {},
|
|
4015
|
-
features,
|
|
4016
|
-
onRowClicked: props.onRowClicked,
|
|
4017
|
-
labels: dataTableMessages(props.locale, props.messages),
|
|
4018
|
-
locale: props.locale ?? "en"
|
|
4019
|
-
};
|
|
4020
|
-
const state = {
|
|
4021
|
-
...store.state,
|
|
4022
|
-
...uiState,
|
|
4023
|
-
...queryFromState(props.state ?? store.state)
|
|
5232
|
+
if (features.gallery)
|
|
5233
|
+
modelFeatures.gallery = { name: features.gallery.name };
|
|
5234
|
+
if (grouping) {
|
|
5235
|
+
modelFeatures.grouping = {
|
|
5236
|
+
initial: grouping.initial ?? [],
|
|
5237
|
+
fields: grouping.fields.map(({ id }) => ({ id, label: id }))
|
|
4024
5238
|
};
|
|
4025
|
-
|
|
4026
|
-
|
|
4027
|
-
|
|
4028
|
-
|
|
4029
|
-
|
|
4030
|
-
config,
|
|
4031
|
-
|
|
4032
|
-
|
|
4033
|
-
|
|
4034
|
-
|
|
4035
|
-
|
|
5239
|
+
}
|
|
5240
|
+
const input = {
|
|
5241
|
+
label: "",
|
|
5242
|
+
columnDefs: columns,
|
|
5243
|
+
rowData: selection ? props.rowData.map((row, index) => ({
|
|
5244
|
+
id: config.getRowId?.(row) ?? String(index),
|
|
5245
|
+
label: "",
|
|
5246
|
+
cells: {},
|
|
5247
|
+
selectable: selection.isRowSelectable?.(row) ?? true
|
|
5248
|
+
})) : [],
|
|
5249
|
+
features: modelFeatures
|
|
5250
|
+
};
|
|
5251
|
+
if (selection)
|
|
5252
|
+
input.selection = {};
|
|
5253
|
+
if (props.state)
|
|
5254
|
+
input.state = props.state;
|
|
5255
|
+
if (props.initialState)
|
|
5256
|
+
input.initialState = props.initialState;
|
|
5257
|
+
return input;
|
|
4036
5258
|
}, [
|
|
4037
|
-
|
|
4038
|
-
|
|
4039
|
-
props.
|
|
4040
|
-
props.locale,
|
|
4041
|
-
props.messages,
|
|
4042
|
-
props.onRowClicked,
|
|
4043
|
-
props.onStateChange,
|
|
5259
|
+
columns,
|
|
5260
|
+
config,
|
|
5261
|
+
props.initialState,
|
|
4044
5262
|
props.rowData,
|
|
4045
5263
|
props.state,
|
|
4046
|
-
|
|
4047
|
-
|
|
4048
|
-
|
|
4049
|
-
|
|
5264
|
+
selection
|
|
5265
|
+
]);
|
|
5266
|
+
const { model, send } = useModel(ReactTableModel, modelProps, {
|
|
5267
|
+
onEmit: (event) => {
|
|
5268
|
+
if (event._tag === "StateChanged") {
|
|
5269
|
+
props.onStateChange?.(queryFromState(event.state));
|
|
5270
|
+
} else if (event._tag === "SelectionChanged" && selection) {
|
|
5271
|
+
const selected = new Set(event.selectedRowIds);
|
|
5272
|
+
selection.onSelectionChange?.(props.rowData.filter((_, index) => {
|
|
5273
|
+
const id = modelProps.rowData[index]?.id;
|
|
5274
|
+
return id !== undefined && selected.has(id);
|
|
5275
|
+
}));
|
|
5276
|
+
}
|
|
5277
|
+
}
|
|
5278
|
+
});
|
|
5279
|
+
const [storageKey] = useState2(() => tablePreferencesKey(globalThis.window?.location.pathname ?? "/", columns.map(({ id }) => id), !!props.features?.gallery));
|
|
5280
|
+
useEffect2(() => {
|
|
5281
|
+
if (!model.preferencesLoaded) {
|
|
5282
|
+
send(DataTableMessage.PreferencesLoaded({
|
|
5283
|
+
preferences: readTablePreferences(storageKey)
|
|
5284
|
+
}));
|
|
5285
|
+
}
|
|
5286
|
+
}, [model, send, storageKey]);
|
|
5287
|
+
const { columnVisibility, columnSizing, grouping, view, preferencesLoaded } = model;
|
|
5288
|
+
const loadedPreferences = useRef2(false);
|
|
5289
|
+
useEffect2(() => {
|
|
5290
|
+
const preferences = tablePreferences({
|
|
5291
|
+
columnVisibility,
|
|
5292
|
+
columnSizing,
|
|
5293
|
+
grouping,
|
|
5294
|
+
view,
|
|
5295
|
+
preferencesLoaded
|
|
5296
|
+
});
|
|
5297
|
+
if (!preferences)
|
|
5298
|
+
return;
|
|
5299
|
+
if (!loadedPreferences.current) {
|
|
5300
|
+
loadedPreferences.current = true;
|
|
5301
|
+
return;
|
|
5302
|
+
}
|
|
5303
|
+
writeTablePreferences(storageKey, preferences);
|
|
5304
|
+
}, [
|
|
5305
|
+
columnVisibility,
|
|
5306
|
+
columnSizing,
|
|
5307
|
+
grouping,
|
|
5308
|
+
view,
|
|
5309
|
+
preferencesLoaded,
|
|
5310
|
+
storageKey
|
|
4050
5311
|
]);
|
|
5312
|
+
const query = modelProps.state ?? model.query;
|
|
5313
|
+
const { collapsedGroups, selectedRowIds } = model;
|
|
5314
|
+
const galleryEnabled = !!props.features?.gallery;
|
|
5315
|
+
const state = useMemo2(() => ({
|
|
5316
|
+
...query,
|
|
5317
|
+
columnVisibility,
|
|
5318
|
+
columnSizing,
|
|
5319
|
+
grouping,
|
|
5320
|
+
view: galleryEnabled ? view : "table",
|
|
5321
|
+
collapsedGroups,
|
|
5322
|
+
rowSelection: Object.fromEntries(selectedRowIds.map((id) => [id, true]))
|
|
5323
|
+
}), [
|
|
5324
|
+
query,
|
|
5325
|
+
columnVisibility,
|
|
5326
|
+
columnSizing,
|
|
5327
|
+
grouping,
|
|
5328
|
+
view,
|
|
5329
|
+
galleryEnabled,
|
|
5330
|
+
collapsedGroups,
|
|
5331
|
+
selectedRowIds
|
|
5332
|
+
]);
|
|
5333
|
+
const store = useMemo2(() => {
|
|
5334
|
+
const source = {
|
|
5335
|
+
rowData: props.rowData,
|
|
5336
|
+
columnDefs: props.columnDefs,
|
|
5337
|
+
config,
|
|
5338
|
+
state
|
|
5339
|
+
};
|
|
5340
|
+
return { ...source, model: buildDataTableModel(source) };
|
|
5341
|
+
}, [props.rowData, props.columnDefs, config, state]);
|
|
5342
|
+
const table = [{ ...store, ui: model }, send];
|
|
5343
|
+
if (!preferencesLoaded)
|
|
5344
|
+
return /* @__PURE__ */ jsx15(TablePlaceholder, {
|
|
5345
|
+
props
|
|
5346
|
+
});
|
|
4051
5347
|
return /* @__PURE__ */ jsxs9("div", {
|
|
4052
|
-
className: cn("w-full max-w-full min-w-0 rounded-md", props.className),
|
|
5348
|
+
className: cn("w-full max-w-full min-w-0 rounded-md", getTableLayoutClass(props.features?.virtualization), props.className),
|
|
4053
5349
|
"data-table-root": "",
|
|
4054
5350
|
children: [
|
|
4055
5351
|
/* @__PURE__ */ jsx15(DataTableToolbar, {
|
|
4056
|
-
|
|
5352
|
+
table
|
|
4057
5353
|
}),
|
|
4058
5354
|
/* @__PURE__ */ jsx15(DataTableContent, {
|
|
4059
|
-
|
|
5355
|
+
table
|
|
4060
5356
|
}),
|
|
4061
5357
|
/* @__PURE__ */ jsx15(DataTablePagination, {
|
|
4062
|
-
|
|
5358
|
+
table
|
|
4063
5359
|
})
|
|
4064
5360
|
]
|
|
4065
5361
|
});
|
|
4066
5362
|
};
|
|
5363
|
+
var subscribeToHydration = () => () => {};
|
|
5364
|
+
var clientSnapshot = () => true;
|
|
5365
|
+
var serverSnapshot = () => false;
|
|
5366
|
+
var TablePlaceholder = ({
|
|
5367
|
+
props
|
|
5368
|
+
}) => /* @__PURE__ */ jsx15("div", {
|
|
5369
|
+
"aria-busy": "true",
|
|
5370
|
+
className: cn("invisible w-full max-w-full min-w-0 rounded-md", getTableLayoutClass(props.features?.virtualization), props.className),
|
|
5371
|
+
"data-table-root": ""
|
|
5372
|
+
});
|
|
4067
5373
|
var DataTable = (props) => {
|
|
4068
5374
|
const locale = useKrakstackLocale3(props.locale);
|
|
4069
|
-
const
|
|
4070
|
-
|
|
4071
|
-
|
|
4072
|
-
|
|
4073
|
-
const viewCapability = props.features?.gallery ? "gallery" : "table";
|
|
4074
|
-
return Atom.kvs({
|
|
4075
|
-
mode: "async",
|
|
4076
|
-
runtime: dataTableStorageRuntime,
|
|
4077
|
-
key: `data-table:${pathname}:${columnIds}:${viewCapability}:ui`,
|
|
4078
|
-
schema: DataTablePersistedUiStateSchema,
|
|
4079
|
-
defaultValue: () => ({
|
|
4080
|
-
...persistedUiFromState(DEFAULT_UI_STATE),
|
|
4081
|
-
view: props.features?.gallery ? props.initialState?.view ?? "table" : "table",
|
|
4082
|
-
grouping: props.features?.grouping ? props.features.grouping.initial ?? [] : []
|
|
4083
|
-
})
|
|
4084
|
-
});
|
|
4085
|
-
});
|
|
4086
|
-
const [persistedUiResult, setPersistedUiState] = useAtom(persistedUiAtom);
|
|
4087
|
-
const persistedUiState = useMemo2(() => AsyncResult.isSuccess(persistedUiResult) ? {
|
|
4088
|
-
...persistedUiResult.value,
|
|
4089
|
-
columnVisibility: {
|
|
4090
|
-
...initialColumnVisibility,
|
|
4091
|
-
...persistedUiResult.value.columnVisibility
|
|
4092
|
-
}
|
|
4093
|
-
} : undefined, [initialColumnVisibility, persistedUiResult]);
|
|
4094
|
-
if (!persistedUiState || AsyncResult.isWaiting(persistedUiResult)) {
|
|
4095
|
-
return /* @__PURE__ */ jsx15("div", {
|
|
4096
|
-
"aria-busy": "true",
|
|
4097
|
-
className: cn("invisible w-full max-w-full min-w-0 rounded-md", props.className),
|
|
4098
|
-
"data-table-root": ""
|
|
5375
|
+
const hydrated = useSyncExternalStore2(subscribeToHydration, clientSnapshot, serverSnapshot);
|
|
5376
|
+
if (!hydrated)
|
|
5377
|
+
return /* @__PURE__ */ jsx15(TablePlaceholder, {
|
|
5378
|
+
props
|
|
4099
5379
|
});
|
|
4100
|
-
}
|
|
4101
5380
|
return /* @__PURE__ */ jsx15(DataTableStylesContext.Provider, {
|
|
4102
5381
|
value: props.classNames,
|
|
4103
|
-
children: /* @__PURE__ */ jsx15(
|
|
4104
|
-
|
|
4105
|
-
|
|
4106
|
-
|
|
4107
|
-
|
|
5382
|
+
children: /* @__PURE__ */ jsx15(DataTableSlotClassesContext.Provider, {
|
|
5383
|
+
value: resolveTableClasses(props.classes),
|
|
5384
|
+
children: /* @__PURE__ */ jsx15(HydratedDataTable, {
|
|
5385
|
+
...props,
|
|
5386
|
+
locale
|
|
5387
|
+
})
|
|
4108
5388
|
})
|
|
4109
5389
|
});
|
|
4110
5390
|
};
|
|
4111
5391
|
var DataTableContent = ({
|
|
4112
|
-
|
|
5392
|
+
table
|
|
4113
5393
|
}) => {
|
|
4114
|
-
const [store] =
|
|
4115
|
-
const [scrollElement, setScrollElement] =
|
|
4116
|
-
const [headerHeight, setHeaderHeight] =
|
|
4117
|
-
const [pageTable, setPageTable] =
|
|
4118
|
-
const [pageOffset, setPageOffset] =
|
|
4119
|
-
|
|
5394
|
+
const [store] = table;
|
|
5395
|
+
const [scrollElement, setScrollElement] = useState2(null);
|
|
5396
|
+
const [headerHeight, setHeaderHeight] = useState2(48);
|
|
5397
|
+
const [pageTable, setPageTable] = useState2(null);
|
|
5398
|
+
const [pageOffset, setPageOffset] = useState2();
|
|
5399
|
+
useLayoutEffect2(() => {
|
|
4120
5400
|
const header = pageTable?.querySelector("thead");
|
|
4121
5401
|
if (!pageTable || !header)
|
|
4122
5402
|
return;
|
|
@@ -4131,7 +5411,7 @@ var DataTableContent = ({
|
|
|
4131
5411
|
observer?.disconnect();
|
|
4132
5412
|
};
|
|
4133
5413
|
}, [pageTable]);
|
|
4134
|
-
|
|
5414
|
+
useLayoutEffect2(() => {
|
|
4135
5415
|
const header = scrollElement?.querySelector("thead");
|
|
4136
5416
|
if (!header)
|
|
4137
5417
|
return;
|
|
@@ -4145,7 +5425,7 @@ var DataTableContent = ({
|
|
|
4145
5425
|
}, [scrollElement]);
|
|
4146
5426
|
if (store.config.features.gallery && store.state.view === "gallery") {
|
|
4147
5427
|
return /* @__PURE__ */ jsx15(DataTableGallery, {
|
|
4148
|
-
|
|
5428
|
+
table
|
|
4149
5429
|
});
|
|
4150
5430
|
}
|
|
4151
5431
|
const model = deriveModel(store);
|
|
@@ -4171,10 +5451,10 @@ var DataTableContent = ({
|
|
|
4171
5451
|
style: { width: `max(100%, ${width}px)` },
|
|
4172
5452
|
children: [
|
|
4173
5453
|
/* @__PURE__ */ jsx15(DataTableHeader, {
|
|
4174
|
-
|
|
5454
|
+
table
|
|
4175
5455
|
}),
|
|
4176
5456
|
/* @__PURE__ */ jsx15(DataTableBody, {
|
|
4177
|
-
|
|
5457
|
+
table,
|
|
4178
5458
|
viewport: {
|
|
4179
5459
|
element: null,
|
|
4180
5460
|
headerHeight: 0,
|
|
@@ -4191,15 +5471,16 @@ var DataTableContent = ({
|
|
|
4191
5471
|
})
|
|
4192
5472
|
});
|
|
4193
5473
|
}
|
|
5474
|
+
const fillHeight = options.scroll === "internal";
|
|
4194
5475
|
return /* @__PURE__ */ jsxs9(ScrollAreaPrimitive2.Root, {
|
|
4195
|
-
className: "relative isolate max-w-full min-w-0",
|
|
5476
|
+
className: cn("relative isolate max-w-full min-w-0", fillHeight && "flex min-h-0 flex-1 flex-col"),
|
|
4196
5477
|
children: [
|
|
4197
5478
|
/* @__PURE__ */ jsx15(ScrollAreaPrimitive2.Viewport, {
|
|
4198
5479
|
ref: setScrollElement,
|
|
4199
5480
|
"data-table-virtual-viewport": "",
|
|
4200
|
-
className: "@container [overflow-anchor:none] data-has-overflow-y:me-2.5 [&_[data-slot=table-container]]:overflow-visible",
|
|
5481
|
+
className: cn("@container [overflow-anchor:none] data-has-overflow-y:me-2.5 [&_[data-slot=table-container]]:overflow-visible", fillHeight && "min-h-0 flex-1"),
|
|
4201
5482
|
style: {
|
|
4202
|
-
maxHeight: options.height ?? 480,
|
|
5483
|
+
maxHeight: fillHeight ? undefined : options.height ?? 480,
|
|
4203
5484
|
scrollPaddingTop: headerHeight
|
|
4204
5485
|
},
|
|
4205
5486
|
children: /* @__PURE__ */ jsx15(ScrollAreaPrimitive2.Content, {
|
|
@@ -4210,10 +5491,10 @@ var DataTableContent = ({
|
|
|
4210
5491
|
children: [
|
|
4211
5492
|
/* @__PURE__ */ jsx15(DataTableHeader, {
|
|
4212
5493
|
sticky: true,
|
|
4213
|
-
|
|
5494
|
+
table
|
|
4214
5495
|
}),
|
|
4215
5496
|
/* @__PURE__ */ jsx15(DataTableBody, {
|
|
4216
|
-
|
|
5497
|
+
table,
|
|
4217
5498
|
viewport: { element: scrollElement, headerHeight, options }
|
|
4218
5499
|
})
|
|
4219
5500
|
]
|
|
@@ -4239,10 +5520,10 @@ var DataTableContent = ({
|
|
|
4239
5520
|
style: { width: `max(100%, ${width}px)` },
|
|
4240
5521
|
children: [
|
|
4241
5522
|
/* @__PURE__ */ jsx15(DataTableHeader, {
|
|
4242
|
-
|
|
5523
|
+
table
|
|
4243
5524
|
}),
|
|
4244
5525
|
/* @__PURE__ */ jsx15(DataTableBody, {
|
|
4245
|
-
|
|
5526
|
+
table
|
|
4246
5527
|
})
|
|
4247
5528
|
]
|
|
4248
5529
|
}),
|
|
@@ -4253,6 +5534,7 @@ var DataTableContent = ({
|
|
|
4253
5534
|
});
|
|
4254
5535
|
};
|
|
4255
5536
|
var DataTableListCell = (props) => {
|
|
5537
|
+
const tableClasses = useContext2(DataTableSlotClassesContext);
|
|
4256
5538
|
const locale = useKrakstackLocale3(props.locale);
|
|
4257
5539
|
const resolvedProps = { ...props, locale };
|
|
4258
5540
|
if (resolvedProps.options && (resolvedProps.onAdd || resolvedProps.onRemove)) {
|
|
@@ -4270,7 +5552,7 @@ var DataTableListCell = (props) => {
|
|
|
4270
5552
|
}
|
|
4271
5553
|
const menuLabel = actionsLabel ?? (itemActions?.length ? labels.actions : labels.listDetails);
|
|
4272
5554
|
return /* @__PURE__ */ jsx15("div", {
|
|
4273
|
-
className:
|
|
5555
|
+
className: tableClasses.relationshipCell,
|
|
4274
5556
|
"data-slot": "data-table-list-cell",
|
|
4275
5557
|
onClick: (event) => event.stopPropagation(),
|
|
4276
5558
|
onPointerDown: (event) => event.stopPropagation(),
|
|
@@ -4285,7 +5567,7 @@ var DataTableListCell = (props) => {
|
|
|
4285
5567
|
onItemClick,
|
|
4286
5568
|
trigger: /* @__PURE__ */ jsxs9(Button, {
|
|
4287
5569
|
"aria-label": menuLabel,
|
|
4288
|
-
className:
|
|
5570
|
+
className: tableClasses.relationshipTrigger,
|
|
4289
5571
|
variant: "ghost",
|
|
4290
5572
|
children: [
|
|
4291
5573
|
/* @__PURE__ */ jsx15(DataTableListSummaryContent, {
|
|
@@ -4314,8 +5596,9 @@ var EditableDataTableListCell = ({
|
|
|
4314
5596
|
locale = "en",
|
|
4315
5597
|
messages
|
|
4316
5598
|
}) => {
|
|
4317
|
-
const
|
|
4318
|
-
const [
|
|
5599
|
+
const tableClasses = useContext2(DataTableSlotClassesContext);
|
|
5600
|
+
const [selected, setSelected] = useState2([...items]);
|
|
5601
|
+
const [previousItems, setPreviousItems] = useState2(items);
|
|
4319
5602
|
if (previousItems !== items) {
|
|
4320
5603
|
setPreviousItems(items);
|
|
4321
5604
|
setSelected([...items]);
|
|
@@ -4345,7 +5628,7 @@ var EditableDataTableListCell = ({
|
|
|
4345
5628
|
];
|
|
4346
5629
|
return /* @__PURE__ */ jsx15("div", {
|
|
4347
5630
|
"data-slot": "data-table-list-cell",
|
|
4348
|
-
className:
|
|
5631
|
+
className: tableClasses.relationshipCell,
|
|
4349
5632
|
onClick: (event) => event.stopPropagation(),
|
|
4350
5633
|
onPointerDown: (event) => event.stopPropagation(),
|
|
4351
5634
|
children: /* @__PURE__ */ jsx15(DataTableListMenu, {
|
|
@@ -4402,7 +5685,7 @@ var DataTableListMenu = ({
|
|
|
4402
5685
|
trigger
|
|
4403
5686
|
}) => {
|
|
4404
5687
|
const entries = items.map((item) => {
|
|
4405
|
-
const normalized =
|
|
5688
|
+
const normalized = Schema6.is(Schema6.String)(item) ? { label: item } : item;
|
|
4406
5689
|
const visibleActions = actions.filter((action) => action.visible?.(normalized) ?? true);
|
|
4407
5690
|
return { item: normalized, visibleActions };
|
|
4408
5691
|
});
|
|
@@ -4503,8 +5786,8 @@ var DataTableListAddMenu = ({
|
|
|
4503
5786
|
options,
|
|
4504
5787
|
searchLabel
|
|
4505
5788
|
}) => {
|
|
4506
|
-
const [search, setSearch] =
|
|
4507
|
-
const focusSearch =
|
|
5789
|
+
const [search, setSearch] = useState2("");
|
|
5790
|
+
const focusSearch = useCallback2((input) => {
|
|
4508
5791
|
input?.focus({ preventScroll: true });
|
|
4509
5792
|
}, []);
|
|
4510
5793
|
const labels = dataTableMessages(locale, messages);
|
|
@@ -4572,7 +5855,7 @@ var DataTableListSummaryContent = ({
|
|
|
4572
5855
|
showMenu,
|
|
4573
5856
|
visibleCount = 3
|
|
4574
5857
|
}) => {
|
|
4575
|
-
const normalized = items.map((item) =>
|
|
5858
|
+
const normalized = items.map((item) => Schema6.is(Schema6.String)(item) ? { label: item } : item);
|
|
4576
5859
|
if (!normalized.length)
|
|
4577
5860
|
return /* @__PURE__ */ jsx15("span", {
|
|
4578
5861
|
className: "text-muted-foreground",
|