@krak-stack/registry 0.10.20 → 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 +83 -3
- package/README.md +11 -8
- package/dist/components/agent/index.d.ts +454 -0
- package/dist/components/agent/react.d.ts +55 -0
- package/dist/components/agent/react.js +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} +2180 -909
- 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} +2174 -897
- 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} +63 -10
- package/dist/components/editing-locale-switcher/schema.d.ts +16 -0
- package/dist/components/{ui/effect-form.d.ts → effect-form/react.d.ts} +2 -2
- package/dist/components/{ui/effect-form.js → effect-form/react.js} +302 -76
- package/dist/components/effectcn/alert-dialog.d.ts +13 -0
- package/dist/components/effectcn/button.d.ts +31 -0
- package/dist/components/effectcn/calendar.d.ts +12 -0
- package/dist/components/effectcn/checkbox.d.ts +10 -0
- package/dist/components/effectcn/combobox.d.ts +25 -0
- package/dist/components/effectcn/dialog.d.ts +19 -0
- package/dist/components/effectcn/field.d.ts +11 -0
- package/dist/components/effectcn/file-drop.d.ts +8 -0
- package/dist/components/effectcn/input.d.ts +26 -0
- package/dist/components/effectcn/menu.d.ts +85 -0
- package/dist/components/effectcn/menubar.d.ts +8 -0
- package/dist/components/effectcn/popover.d.ts +18 -0
- package/dist/components/effectcn/scroll-area.d.ts +12 -0
- package/dist/components/effectcn/select.d.ts +68 -0
- package/dist/components/effectcn/toast.d.ts +29 -0
- package/dist/components/email-composer/index.d.ts +229 -0
- package/dist/components/email-composer/labels.d.ts +12 -0
- package/dist/components/email-composer/react.d.ts +5 -0
- package/dist/components/{ui/email-composer.js → email-composer/react.js} +618 -135
- package/dist/components/email-composer/schema.d.ts +42 -0
- package/dist/components/email-editor/classes.d.ts +21 -0
- package/dist/components/email-editor/html.d.ts +360 -0
- package/dist/components/email-editor/html.js +1706 -0
- package/dist/components/email-editor/index.d.ts +693 -0
- package/dist/components/{ui/email-editor.d.ts → email-editor/labels.d.ts} +1 -21
- package/dist/components/email-editor/legacy-editor.html.d.ts +160 -0
- package/dist/components/email-editor/react.d.ts +11 -0
- package/dist/components/{ui/email-editor.js → email-editor/react.js} +778 -256
- 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} +7 -7
- package/dist/components/{ui/form.js → form/react.js} +300 -74
- package/dist/components/icon-input/html.d.ts +55 -0
- package/dist/components/icon-input/html.js +538 -0
- package/dist/components/icon-input/index.d.ts +143 -0
- package/dist/components/icon-input/react.d.ts +6 -0
- package/dist/components/{ui/icon-input.js → icon-input/react.js} +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} +321 -83
- package/dist/components/map-menu/schema.d.ts +132 -0
- package/dist/components/markdown/classes.d.ts +1 -0
- package/dist/components/markdown/html.d.ts +23 -0
- package/dist/components/markdown/html.js +510 -0
- package/dist/components/markdown/index.d.ts +6 -0
- package/dist/components/markdown/react.d.ts +3 -0
- package/dist/components/markdown/react.js +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} +123 -23
- package/dist/components/pagination/schema.d.ts +36 -0
- package/dist/components/phone-number-input/classes.d.ts +17 -0
- package/dist/components/phone-number-input/html.d.ts +52 -0
- package/dist/components/phone-number-input/html.js +655 -0
- package/dist/components/phone-number-input/index.d.ts +59 -0
- package/dist/components/phone-number-input/react.d.ts +11 -0
- package/dist/components/{ui/phone-number-input.js → phone-number-input/react.js} +368 -138
- package/dist/components/phone-number-input/schema.d.ts +31 -0
- package/dist/components/presence-transition/html.d.ts +13 -0
- package/dist/components/presence-transition/html.js +128 -0
- package/dist/components/presence-transition/index.d.ts +57 -0
- package/dist/components/{ui/presence-transition.d.ts → presence-transition/react.d.ts} +3 -5
- package/dist/components/presence-transition/react.js +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/{ui/rich-text-editor.js → rich-text-editor/react.js} +521 -100
- 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} +127 -22
- package/dist/components/select-with-custom-input/schema.d.ts +54 -0
- package/dist/components/sidebar-layout/classes.d.ts +21 -0
- package/dist/components/sidebar-layout/html.d.ts +97 -0
- package/dist/components/sidebar-layout/html.js +361 -0
- package/dist/components/sidebar-layout/index.d.ts +57 -0
- package/dist/components/sidebar-layout/react.d.ts +30 -0
- package/dist/components/{ui/sidebar-layout.js → sidebar-layout/react.js} +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 -72
- package/dist/components/ui/search-menu.d.ts +1 -36
- package/dist/components/ui/sidebar-layout.d.ts +1 -40
- package/dist/components/ui/virtualized-combobox.d.ts +1 -59
- package/dist/components/unsaved-changes-guard/html.d.ts +34 -0
- package/dist/components/unsaved-changes-guard/html.js +172 -0
- package/dist/components/unsaved-changes-guard/index.d.ts +56 -0
- package/dist/components/unsaved-changes-guard/react.d.ts +4 -0
- package/dist/components/{ui/unsaved-changes-guard.js → unsaved-changes-guard/react.js} +74 -11
- package/dist/components/unsaved-changes-guard/schema.d.ts +37 -0
- package/dist/components/upload-attachment/classes.d.ts +11 -0
- package/dist/components/upload-attachment/html.d.ts +84 -0
- package/dist/components/upload-attachment/html.js +312 -0
- package/dist/components/upload-attachment/index.d.ts +72 -0
- package/dist/components/upload-attachment/react.d.ts +9 -0
- package/dist/components/{ui/upload-attachment.js → upload-attachment/react.js} +114 -17
- package/dist/components/upload-attachment/schema.d.ts +53 -0
- package/dist/components/virtualized-combobox/classes.d.ts +7 -0
- package/dist/components/virtualized-combobox/html.d.ts +97 -0
- package/dist/components/virtualized-combobox/html.js +310 -0
- package/dist/components/virtualized-combobox/index.d.ts +182 -0
- package/dist/components/virtualized-combobox/react.d.ts +31 -0
- package/dist/components/{ui/virtualized-combobox.js → virtualized-combobox/react.js} +160 -40
- package/dist/components/virtualized-combobox/schema.d.ts +92 -0
- package/dist/components/webhook-delivery-table/html.d.ts +216 -0
- package/dist/components/webhook-delivery-table/html.js +3008 -0
- package/dist/components/webhook-delivery-table/index.d.ts +405 -0
- package/dist/components/webhook-delivery-table/react.d.ts +13 -0
- package/dist/{services/webhooks/client/delivery-table.js → components/webhook-delivery-table/react.js} +2461 -948
- 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 +863 -295
- 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/schema.d.ts +14 -0
- package/dist/lib/httpapi-toolkit.d.ts +1 -1
- package/dist/lib/lucide-effect.d.ts +39 -0
- package/dist/lib/markdown/content.d.ts +1 -12
- package/dist/lib/rich-text/model.d.ts +5 -0
- package/dist/lib/webfetch-toolkit.d.ts +1 -1
- package/dist/services/agent/client/index.js +697 -181
- 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 +181 -142
- 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/select-with-custom-input.d.ts +0 -36
- package/dist/components/ui/stats-card.d.ts +0 -12
- package/dist/components/ui/stepper.d.ts +0 -37
- package/dist/components/ui/time-picker.d.ts +0 -50
- package/dist/components/ui/time-picker.schema.d.ts +0 -28
- package/dist/components/ui/timezone-select.d.ts +0 -57
- package/dist/components/ui/timezone-select.schema.d.ts +0 -9
- package/dist/components/ui/toast.d.ts +0 -18
- package/dist/components/ui/unsaved-changes-guard.d.ts +0 -16
- package/dist/components/ui/upload-attachment.d.ts +0 -39
- package/dist/services/notification/persistence/drizzle.d.ts +0 -868
- package/dist/services/notification/persistence/drizzle.js +0 -214
- package/dist/services/notification/persistence/index.d.ts +0 -2
- package/dist/services/notification/persistence/index.js +0 -227
- package/dist/services/notification/persistence/schema.d.ts +0 -143
- package/dist/services/notification/persistence/schema.js +0 -118
- package/dist/services/webhooks/client/delivery-table.d.ts +0 -62
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
// ../../src/
|
|
2
|
-
import {
|
|
1
|
+
// ../../src/components/webhook-delivery-table/react.tsx
|
|
2
|
+
import { Component as Component7, View as View4 } from "effect/ui";
|
|
3
3
|
import { Check as Check3, Clock, FileJson as FileJson2, X as X2 } from "lucide-react";
|
|
4
4
|
|
|
5
|
-
// ../../src/components/
|
|
6
|
-
import { useAtom, useAtomSet } from "@effect/atom-react";
|
|
5
|
+
// ../../src/components/data-table/react.tsx
|
|
7
6
|
import { ScrollArea as ScrollAreaPrimitive2 } from "@base-ui/react/scroll-area";
|
|
8
|
-
import { BrowserKeyValueStore } from "@effect/platform-browser";
|
|
9
7
|
import { useVirtualizer, useWindowVirtualizer } from "@tanstack/react-virtual";
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import { AsyncResult, Atom } from "effect/reactivity";
|
|
8
|
+
import { Formatter, Option as Option4, Schema as Schema6 } from "effect";
|
|
9
|
+
import { Component as Component3, View as View2 } from "effect/ui";
|
|
13
10
|
import {
|
|
14
11
|
ArrowDown,
|
|
15
12
|
ArrowUp,
|
|
@@ -34,15 +31,17 @@ import {
|
|
|
34
31
|
X
|
|
35
32
|
} from "lucide-react";
|
|
36
33
|
import {
|
|
37
|
-
createContext,
|
|
34
|
+
createContext as createContext2,
|
|
38
35
|
isValidElement,
|
|
39
|
-
useCallback,
|
|
40
|
-
useContext,
|
|
36
|
+
useCallback as useCallback2,
|
|
37
|
+
useContext as useContext2,
|
|
38
|
+
useEffect as useEffect2,
|
|
41
39
|
useId as useId2,
|
|
42
|
-
useLayoutEffect,
|
|
40
|
+
useLayoutEffect as useLayoutEffect2,
|
|
43
41
|
useMemo as useMemo2,
|
|
44
|
-
useRef,
|
|
45
|
-
useState
|
|
42
|
+
useRef as useRef2,
|
|
43
|
+
useState as useState2,
|
|
44
|
+
useSyncExternalStore as useSyncExternalStore2
|
|
46
45
|
} from "react";
|
|
47
46
|
import { createPortal } from "react-dom";
|
|
48
47
|
|
|
@@ -508,38 +507,51 @@ function SelectScrollDownButton({
|
|
|
508
507
|
});
|
|
509
508
|
}
|
|
510
509
|
|
|
511
|
-
// ../../src/components/
|
|
510
|
+
// ../../src/components/loading/react.tsx
|
|
512
511
|
import { Loader2 } from "lucide-react";
|
|
513
|
-
import { useKrakstackLocale } from "@krak-stack/registry/krakstack-provider";
|
|
514
|
-
|
|
512
|
+
import { useKrakstackLocale } from "@krak-stack/registry/krakstack-provider/react";
|
|
513
|
+
|
|
514
|
+
// ../../src/components/loading/classes.ts
|
|
515
|
+
var resolveLoadingClasses = ({
|
|
516
|
+
classes,
|
|
517
|
+
variant,
|
|
518
|
+
className
|
|
519
|
+
}) => ({
|
|
520
|
+
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),
|
|
521
|
+
icon: classes?.icon ?? "size-4 motion-safe:animate-spin"
|
|
522
|
+
});
|
|
523
|
+
|
|
524
|
+
// ../../src/components/loading/index.ts
|
|
515
525
|
var labels = {
|
|
516
|
-
en:
|
|
517
|
-
|
|
518
|
-
},
|
|
519
|
-
fr: {
|
|
520
|
-
loading: "Chargement..."
|
|
521
|
-
}
|
|
526
|
+
en: "Loading...",
|
|
527
|
+
fr: "Chargement..."
|
|
522
528
|
};
|
|
523
|
-
var loadingLabel = (locale, messages) => messages?.[locale]?.loading ?? messages?.[locale.split("-")[0] ?? locale]?.loading ?? (locale.startsWith("fr") ? labels.fr
|
|
529
|
+
var loadingLabel = (locale, messages) => messages?.[locale]?.loading ?? messages?.[locale.split("-")[0] ?? locale]?.loading ?? (locale.startsWith("fr") ? labels.fr : labels.en);
|
|
530
|
+
|
|
531
|
+
// ../../src/components/loading/react.tsx
|
|
532
|
+
import { jsx as jsx9, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
524
533
|
function Loading({
|
|
525
534
|
className,
|
|
535
|
+
classes,
|
|
526
536
|
label,
|
|
527
537
|
locale: localeOverride,
|
|
528
538
|
messages,
|
|
529
539
|
variant = "inline"
|
|
530
540
|
}) {
|
|
531
541
|
const locale = useKrakstackLocale(localeOverride);
|
|
542
|
+
const slots = resolveLoadingClasses({ classes, variant, className });
|
|
532
543
|
return /* @__PURE__ */ jsxs4("div", {
|
|
533
|
-
|
|
544
|
+
role: "status",
|
|
545
|
+
className: slots.root,
|
|
534
546
|
children: [
|
|
535
547
|
/* @__PURE__ */ jsx9(Loader2, {
|
|
536
|
-
|
|
548
|
+
"aria-hidden": "true",
|
|
549
|
+
className: slots.icon
|
|
537
550
|
}),
|
|
538
551
|
label ?? loadingLabel(locale, messages)
|
|
539
552
|
]
|
|
540
553
|
});
|
|
541
554
|
}
|
|
542
|
-
|
|
543
555
|
// ../../src/components/ui/menubar.tsx
|
|
544
556
|
import { Menu as MenuPrimitive2 } from "@base-ui/react/menu";
|
|
545
557
|
import { Menubar as MenubarPrimitive } from "@base-ui/react/menubar";
|
|
@@ -714,7 +726,7 @@ function MenubarSubContent({
|
|
|
714
726
|
});
|
|
715
727
|
}
|
|
716
728
|
|
|
717
|
-
// ../../src/components/
|
|
729
|
+
// ../../src/components/pagination/react.tsx
|
|
718
730
|
import {
|
|
719
731
|
ChevronLeft,
|
|
720
732
|
ChevronRight,
|
|
@@ -722,8 +734,79 @@ import {
|
|
|
722
734
|
ChevronsRight
|
|
723
735
|
} from "lucide-react";
|
|
724
736
|
import { useId } from "react";
|
|
725
|
-
import { useKrakstackLocale as useKrakstackLocale2 } from "@krak-stack/registry/krakstack-provider";
|
|
726
|
-
|
|
737
|
+
import { useKrakstackLocale as useKrakstackLocale2 } from "@krak-stack/registry/krakstack-provider/react";
|
|
738
|
+
|
|
739
|
+
// ../../src/components/pagination/classes.ts
|
|
740
|
+
var paginationClasses = {
|
|
741
|
+
root: "flex flex-col gap-3 px-2 sm:flex-row sm:items-center sm:justify-between",
|
|
742
|
+
summary: "text-muted-foreground flex flex-wrap items-center gap-x-3 gap-y-1 text-sm",
|
|
743
|
+
controls: "flex items-center gap-4 sm:justify-end",
|
|
744
|
+
controlGroup: "flex items-center gap-2",
|
|
745
|
+
navigation: "flex items-center gap-1",
|
|
746
|
+
compactRoot: "gap-2 px-0 sm:flex-col sm:items-stretch",
|
|
747
|
+
compactControls: "flex-wrap justify-between gap-2 sm:justify-between"
|
|
748
|
+
};
|
|
749
|
+
var resolvePaginationClasses = (overrides) => ({
|
|
750
|
+
...paginationClasses,
|
|
751
|
+
...overrides
|
|
752
|
+
});
|
|
753
|
+
|
|
754
|
+
// ../../src/components/pagination/index.ts
|
|
755
|
+
import { Schema as Schema2 } from "effect";
|
|
756
|
+
import { Component, UiSchema } from "effect/ui";
|
|
757
|
+
|
|
758
|
+
// ../../src/components/pagination/schema.ts
|
|
759
|
+
import { Schema, Struct } from "effect";
|
|
760
|
+
var Labels = Schema.Struct({
|
|
761
|
+
pageSize: Schema.optional(Schema.String),
|
|
762
|
+
goToFirstPage: Schema.optional(Schema.String),
|
|
763
|
+
goToPreviousPage: Schema.optional(Schema.String),
|
|
764
|
+
goToNextPage: Schema.optional(Schema.String),
|
|
765
|
+
goToLastPage: Schema.optional(Schema.String)
|
|
766
|
+
}).annotate({ identifier: "PaginationLabelOverrides" });
|
|
767
|
+
var Translations = Schema.Record(Schema.String, Schema.UndefinedOr(Labels));
|
|
768
|
+
var PaginationClassesOverridesSchema = Schema.Record(Schema.Literals(Struct.keys(paginationClasses)), Schema.optionalKey(Schema.String)).annotate({ identifier: "PaginationClassesOverrides" });
|
|
769
|
+
var PaginationPropsSchema = Schema.Struct({
|
|
770
|
+
classes: Schema.optional(PaginationClassesOverridesSchema),
|
|
771
|
+
className: Schema.optional(Schema.String),
|
|
772
|
+
pageSizeContentClassName: Schema.optional(Schema.String),
|
|
773
|
+
compact: Schema.optional(Schema.Boolean),
|
|
774
|
+
locale: Schema.optional(Schema.String),
|
|
775
|
+
messages: Schema.optional(Translations),
|
|
776
|
+
page: Schema.Int,
|
|
777
|
+
pageCount: Schema.Int,
|
|
778
|
+
pageSize: Schema.Int,
|
|
779
|
+
pageSizes: Schema.optional(Schema.Array(Schema.Int)),
|
|
780
|
+
selectedRows: Schema.optional(Schema.Int),
|
|
781
|
+
showResults: Schema.optional(Schema.Boolean),
|
|
782
|
+
totalRows: Schema.Int
|
|
783
|
+
}).annotate({ identifier: "PaginationProps" });
|
|
784
|
+
|
|
785
|
+
// ../../src/components/pagination/index.ts
|
|
786
|
+
var PaginationMessage = UiSchema.TaggedEnum({
|
|
787
|
+
Opened: {},
|
|
788
|
+
Closed: {},
|
|
789
|
+
PageRequested: { page: Schema2.Int },
|
|
790
|
+
SizeRequested: { pageSize: Schema2.Int }
|
|
791
|
+
}).annotate({ identifier: "PaginationMessage" });
|
|
792
|
+
var PaginationEvents = UiSchema.TaggedEnum({
|
|
793
|
+
PageChanged: { page: Schema2.Int },
|
|
794
|
+
PageSizeChanged: { pageSize: Schema2.Int }
|
|
795
|
+
}).annotate({ identifier: "PaginationEvents" });
|
|
796
|
+
var paginationOptions = {
|
|
797
|
+
name: "Pagination",
|
|
798
|
+
props: PaginationPropsSchema,
|
|
799
|
+
model: Schema2.Boolean,
|
|
800
|
+
message: PaginationMessage,
|
|
801
|
+
events: PaginationEvents,
|
|
802
|
+
restore: false
|
|
803
|
+
};
|
|
804
|
+
var update = Component.define(paginationOptions).update({
|
|
805
|
+
Opened: () => true,
|
|
806
|
+
Closed: () => false,
|
|
807
|
+
PageRequested: ($, { page }) => $.set($.model).emit(PaginationEvents.PageChanged({ page })),
|
|
808
|
+
SizeRequested: ($, { pageSize }) => $.set(false).emit(PaginationEvents.PageSizeChanged({ pageSize }))
|
|
809
|
+
});
|
|
727
810
|
var messages = {
|
|
728
811
|
en: {
|
|
729
812
|
pageSize: "Page size",
|
|
@@ -751,7 +834,35 @@ var paginationMessages = (locale = "en", translations) => ({
|
|
|
751
834
|
...translations?.[locale.split("-")[0] ?? locale],
|
|
752
835
|
...translations?.[locale]
|
|
753
836
|
});
|
|
837
|
+
var defaultPageSizes = [20, 50, 100];
|
|
838
|
+
var paginationPageLabel = (page, pageCount, pageOf) => pageCount > 0 ? pageOf(page + 1, pageCount) : undefined;
|
|
839
|
+
var paginationNavigation = (page, pageCount) => ({
|
|
840
|
+
goToFirstPage: {
|
|
841
|
+
page: 0,
|
|
842
|
+
disabled: pageCount <= 0 || page <= 0,
|
|
843
|
+
edge: true
|
|
844
|
+
},
|
|
845
|
+
goToPreviousPage: {
|
|
846
|
+
page: page - 1,
|
|
847
|
+
disabled: pageCount <= 0 || page <= 0,
|
|
848
|
+
edge: false
|
|
849
|
+
},
|
|
850
|
+
goToNextPage: {
|
|
851
|
+
page: page + 1,
|
|
852
|
+
disabled: pageCount <= 0 || page + 1 >= pageCount,
|
|
853
|
+
edge: false
|
|
854
|
+
},
|
|
855
|
+
goToLastPage: {
|
|
856
|
+
page: pageCount - 1,
|
|
857
|
+
disabled: pageCount <= 0 || page + 1 >= pageCount,
|
|
858
|
+
edge: true
|
|
859
|
+
}
|
|
860
|
+
});
|
|
861
|
+
|
|
862
|
+
// ../../src/components/pagination/react.tsx
|
|
863
|
+
import { jsx as jsx11, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
754
864
|
function Pagination({
|
|
865
|
+
classes: classOverrides,
|
|
755
866
|
className,
|
|
756
867
|
pageSizeContentClassName,
|
|
757
868
|
compact = false,
|
|
@@ -762,22 +873,23 @@ function Pagination({
|
|
|
762
873
|
page,
|
|
763
874
|
pageCount,
|
|
764
875
|
pageSize,
|
|
765
|
-
pageSizes =
|
|
876
|
+
pageSizes = defaultPageSizes,
|
|
766
877
|
selectedRows = 0,
|
|
767
878
|
showResults = true,
|
|
768
879
|
totalRows
|
|
769
880
|
}) {
|
|
881
|
+
const paginationClasses = resolvePaginationClasses(classOverrides);
|
|
770
882
|
const locale = useKrakstackLocale2(localeOverride);
|
|
771
883
|
const labels = paginationMessages(locale, messageOverrides);
|
|
772
884
|
const pageSizeId = useId();
|
|
773
|
-
const
|
|
774
|
-
const
|
|
885
|
+
const navigation = paginationNavigation(page, pageCount);
|
|
886
|
+
const pageLabel = paginationPageLabel(page, pageCount, labels.pageOf);
|
|
775
887
|
return /* @__PURE__ */ jsxs6("div", {
|
|
776
888
|
"data-slot": "pagination",
|
|
777
|
-
className: cn(
|
|
889
|
+
className: cn(paginationClasses.root, compact && paginationClasses.compactRoot, className),
|
|
778
890
|
children: [
|
|
779
891
|
showResults ? /* @__PURE__ */ jsxs6("div", {
|
|
780
|
-
className:
|
|
892
|
+
className: paginationClasses.summary,
|
|
781
893
|
children: [
|
|
782
894
|
/* @__PURE__ */ jsx11("span", {
|
|
783
895
|
children: labels.results(totalRows)
|
|
@@ -788,10 +900,10 @@ function Pagination({
|
|
|
788
900
|
]
|
|
789
901
|
}) : null,
|
|
790
902
|
/* @__PURE__ */ jsxs6("div", {
|
|
791
|
-
className: cn(
|
|
903
|
+
className: cn(paginationClasses.controls, compact && paginationClasses.compactControls),
|
|
792
904
|
children: [
|
|
793
905
|
/* @__PURE__ */ jsxs6("div", {
|
|
794
|
-
className:
|
|
906
|
+
className: paginationClasses.controlGroup,
|
|
795
907
|
children: [
|
|
796
908
|
/* @__PURE__ */ jsx11(Label, {
|
|
797
909
|
htmlFor: pageSizeId,
|
|
@@ -826,19 +938,19 @@ function Pagination({
|
|
|
826
938
|
]
|
|
827
939
|
}),
|
|
828
940
|
/* @__PURE__ */ jsxs6("div", {
|
|
829
|
-
className:
|
|
941
|
+
className: paginationClasses.controlGroup,
|
|
830
942
|
children: [
|
|
831
|
-
/* @__PURE__ */ jsx11("div", {
|
|
943
|
+
pageLabel !== undefined && /* @__PURE__ */ jsx11("div", {
|
|
832
944
|
className: "flex items-center justify-center text-sm font-medium sm:block",
|
|
833
|
-
children:
|
|
945
|
+
children: pageLabel
|
|
834
946
|
}),
|
|
835
947
|
/* @__PURE__ */ jsxs6("div", {
|
|
836
|
-
className:
|
|
948
|
+
className: paginationClasses.navigation,
|
|
837
949
|
children: [
|
|
838
950
|
/* @__PURE__ */ jsxs6(Button, {
|
|
839
951
|
className: cn("hidden h-8 w-8 p-0 lg:flex", compact && "!hidden"),
|
|
840
|
-
disabled:
|
|
841
|
-
onClick: () => onPageChange(
|
|
952
|
+
disabled: navigation.goToFirstPage.disabled,
|
|
953
|
+
onClick: () => onPageChange(navigation.goToFirstPage.page),
|
|
842
954
|
type: "button",
|
|
843
955
|
children: [
|
|
844
956
|
/* @__PURE__ */ jsx11("span", {
|
|
@@ -850,8 +962,8 @@ function Pagination({
|
|
|
850
962
|
}),
|
|
851
963
|
/* @__PURE__ */ jsxs6(Button, {
|
|
852
964
|
className: "h-8 w-8 p-0",
|
|
853
|
-
disabled:
|
|
854
|
-
onClick: () => onPageChange(page
|
|
965
|
+
disabled: navigation.goToPreviousPage.disabled,
|
|
966
|
+
onClick: () => onPageChange(navigation.goToPreviousPage.page),
|
|
855
967
|
type: "button",
|
|
856
968
|
children: [
|
|
857
969
|
/* @__PURE__ */ jsx11("span", {
|
|
@@ -863,8 +975,8 @@ function Pagination({
|
|
|
863
975
|
}),
|
|
864
976
|
/* @__PURE__ */ jsxs6(Button, {
|
|
865
977
|
className: "h-8 w-8 p-0",
|
|
866
|
-
disabled:
|
|
867
|
-
onClick: () => onPageChange(page
|
|
978
|
+
disabled: navigation.goToNextPage.disabled,
|
|
979
|
+
onClick: () => onPageChange(navigation.goToNextPage.page),
|
|
868
980
|
type: "button",
|
|
869
981
|
children: [
|
|
870
982
|
/* @__PURE__ */ jsx11("span", {
|
|
@@ -876,8 +988,8 @@ function Pagination({
|
|
|
876
988
|
}),
|
|
877
989
|
/* @__PURE__ */ jsxs6(Button, {
|
|
878
990
|
className: cn("hidden h-8 w-8 p-0 lg:flex", compact && "!hidden"),
|
|
879
|
-
disabled:
|
|
880
|
-
onClick: () => onPageChange(
|
|
991
|
+
disabled: navigation.goToLastPage.disabled,
|
|
992
|
+
onClick: () => onPageChange(navigation.goToLastPage.page),
|
|
881
993
|
type: "button",
|
|
882
994
|
children: [
|
|
883
995
|
/* @__PURE__ */ jsx11("span", {
|
|
@@ -896,7 +1008,6 @@ function Pagination({
|
|
|
896
1008
|
]
|
|
897
1009
|
});
|
|
898
1010
|
}
|
|
899
|
-
|
|
900
1011
|
// ../../src/components/ui/scroll-area.tsx
|
|
901
1012
|
import { ScrollArea as ScrollAreaPrimitive } from "@base-ui/react/scroll-area";
|
|
902
1013
|
import { jsx as jsx12, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
@@ -1049,7 +1160,7 @@ import {
|
|
|
1049
1160
|
DateTime,
|
|
1050
1161
|
Effect,
|
|
1051
1162
|
Option,
|
|
1052
|
-
Schema,
|
|
1163
|
+
Schema as Schema3,
|
|
1053
1164
|
SchemaGetter,
|
|
1054
1165
|
SchemaIssue,
|
|
1055
1166
|
SchemaTransformation
|
|
@@ -1061,25 +1172,25 @@ var parseSortParam = (sort) => {
|
|
|
1061
1172
|
}
|
|
1062
1173
|
return { id, direction: sort.startsWith("-") ? "desc" : "asc" };
|
|
1063
1174
|
};
|
|
1064
|
-
var SortDirection =
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
]).pipe(
|
|
1175
|
+
var SortDirection = Schema3.Union([
|
|
1176
|
+
Schema3.Literal("asc"),
|
|
1177
|
+
Schema3.Literal("desc")
|
|
1178
|
+
]).pipe(Schema3.annotate({
|
|
1068
1179
|
identifier: "SortDirection",
|
|
1069
1180
|
title: "Sort Direction",
|
|
1070
1181
|
description: "Sort direction for list query results.",
|
|
1071
1182
|
examples: ["asc", "desc"]
|
|
1072
1183
|
}));
|
|
1073
|
-
var SortParam =
|
|
1074
|
-
id:
|
|
1184
|
+
var SortParam = Schema3.Struct({
|
|
1185
|
+
id: Schema3.NonEmptyString,
|
|
1075
1186
|
direction: SortDirection
|
|
1076
|
-
}).pipe(
|
|
1187
|
+
}).pipe(Schema3.annotate({
|
|
1077
1188
|
identifier: "SortParam",
|
|
1078
1189
|
title: "Sort Parameter",
|
|
1079
1190
|
description: "Decoded sort parameter with a field id and direction.",
|
|
1080
1191
|
examples: [{ id: "publicName", direction: "asc" }]
|
|
1081
1192
|
}));
|
|
1082
|
-
var SortParamFromString =
|
|
1193
|
+
var SortParamFromString = Schema3.String.pipe(Schema3.decodeTo(SortParam, SchemaTransformation.transformEffect({
|
|
1083
1194
|
decode: (sort) => {
|
|
1084
1195
|
const sortParam = parseSortParam(sort);
|
|
1085
1196
|
if (!sortParam) {
|
|
@@ -1088,13 +1199,13 @@ var SortParamFromString = Schema.String.pipe(Schema.decodeTo(SortParam, SchemaTr
|
|
|
1088
1199
|
return Effect.succeed(sortParam);
|
|
1089
1200
|
},
|
|
1090
1201
|
encode: (sort) => Effect.succeed(sort.direction === "desc" ? `-${sort.id}` : sort.id)
|
|
1091
|
-
})),
|
|
1202
|
+
})), Schema3.annotate({
|
|
1092
1203
|
identifier: "SortParamFromString",
|
|
1093
1204
|
title: "Sort Parameter From String",
|
|
1094
1205
|
description: 'URL encoded single sort parameter where descending fields are prefixed with "-".',
|
|
1095
1206
|
examples: [{ id: "publicName", direction: "asc" }]
|
|
1096
1207
|
}));
|
|
1097
|
-
var SortParamsFromString =
|
|
1208
|
+
var SortParamsFromString = Schema3.String.pipe(Schema3.decodeTo(Schema3.Array(SortParam), SchemaTransformation.transformEffect({
|
|
1098
1209
|
decode: (sort) => {
|
|
1099
1210
|
if (sort === "")
|
|
1100
1211
|
return Effect.succeed([]);
|
|
@@ -1109,8 +1220,8 @@ var SortParamsFromString = Schema.String.pipe(Schema.decodeTo(Schema.Array(SortP
|
|
|
1109
1220
|
}
|
|
1110
1221
|
return Effect.succeed(sortParams);
|
|
1111
1222
|
},
|
|
1112
|
-
encode: (sort) => Effect.succeed(sort.map((part) =>
|
|
1113
|
-
})),
|
|
1223
|
+
encode: (sort) => Effect.succeed(sort.map((part) => Schema3.encodeSync(SortParamFromString)(part)).join(","))
|
|
1224
|
+
})), Schema3.annotate({
|
|
1114
1225
|
identifier: "SortParamsFromString",
|
|
1115
1226
|
title: "Sort Parameters From String",
|
|
1116
1227
|
description: 'URL encoded sort parameters where descending fields are prefixed with "-" and multiple fields are comma-separated.',
|
|
@@ -1121,68 +1232,68 @@ var SortParamsFromString = Schema.String.pipe(Schema.decodeTo(Schema.Array(SortP
|
|
|
1121
1232
|
]
|
|
1122
1233
|
]
|
|
1123
1234
|
}));
|
|
1124
|
-
var SortParamsArray =
|
|
1125
|
-
var SortParams =
|
|
1235
|
+
var SortParamsArray = Schema3.Array(SortParam);
|
|
1236
|
+
var SortParams = Schema3.declare(Schema3.is(SortParamsArray), {
|
|
1126
1237
|
identifier: "SortParams",
|
|
1127
|
-
toCodec: () =>
|
|
1128
|
-
toCodecStringTree: () =>
|
|
1238
|
+
toCodec: () => Schema3.link()(SortParamsArray, SchemaTransformation.passthrough()),
|
|
1239
|
+
toCodecStringTree: () => Schema3.link()(SortParamsFromString, SchemaTransformation.passthrough())
|
|
1129
1240
|
});
|
|
1130
|
-
var TextFilterOperator =
|
|
1241
|
+
var TextFilterOperator = Schema3.Literals([
|
|
1131
1242
|
"contains",
|
|
1132
1243
|
"equals",
|
|
1133
1244
|
"startsWith",
|
|
1134
1245
|
"endsWith"
|
|
1135
1246
|
]).annotate({ identifier: "TextFilterOperator" });
|
|
1136
|
-
var FilterCalendarDate =
|
|
1137
|
-
var ColumnFilter =
|
|
1138
|
-
|
|
1139
|
-
id:
|
|
1140
|
-
kind:
|
|
1247
|
+
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" });
|
|
1248
|
+
var ColumnFilter = Schema3.Union([
|
|
1249
|
+
Schema3.Struct({
|
|
1250
|
+
id: Schema3.NonEmptyString,
|
|
1251
|
+
kind: Schema3.Literal("text"),
|
|
1141
1252
|
operator: TextFilterOperator,
|
|
1142
|
-
value:
|
|
1253
|
+
value: Schema3.NonEmptyString
|
|
1143
1254
|
}),
|
|
1144
|
-
|
|
1145
|
-
id:
|
|
1146
|
-
kind:
|
|
1147
|
-
min:
|
|
1148
|
-
max:
|
|
1149
|
-
}).check(
|
|
1150
|
-
|
|
1151
|
-
id:
|
|
1152
|
-
kind:
|
|
1153
|
-
from:
|
|
1154
|
-
to:
|
|
1155
|
-
}).check(
|
|
1156
|
-
|
|
1157
|
-
id:
|
|
1158
|
-
kind:
|
|
1159
|
-
value:
|
|
1255
|
+
Schema3.Struct({
|
|
1256
|
+
id: Schema3.NonEmptyString,
|
|
1257
|
+
kind: Schema3.Literal("number"),
|
|
1258
|
+
min: Schema3.optional(Schema3.Finite),
|
|
1259
|
+
max: Schema3.optional(Schema3.Finite)
|
|
1260
|
+
}).check(Schema3.makeFilter((range) => (range.min !== undefined || range.max !== undefined) && (range.min === undefined || range.max === undefined || range.min <= range.max))),
|
|
1261
|
+
Schema3.Struct({
|
|
1262
|
+
id: Schema3.NonEmptyString,
|
|
1263
|
+
kind: Schema3.Literal("date"),
|
|
1264
|
+
from: Schema3.optional(FilterCalendarDate),
|
|
1265
|
+
to: Schema3.optional(FilterCalendarDate)
|
|
1266
|
+
}).check(Schema3.makeFilter((range) => (range.from !== undefined || range.to !== undefined) && (range.from === undefined || range.to === undefined || range.from <= range.to))),
|
|
1267
|
+
Schema3.Struct({
|
|
1268
|
+
id: Schema3.NonEmptyString,
|
|
1269
|
+
kind: Schema3.Literal("boolean"),
|
|
1270
|
+
value: Schema3.Boolean
|
|
1160
1271
|
}),
|
|
1161
|
-
|
|
1162
|
-
id:
|
|
1163
|
-
kind:
|
|
1164
|
-
values:
|
|
1272
|
+
Schema3.Struct({
|
|
1273
|
+
id: Schema3.NonEmptyString,
|
|
1274
|
+
kind: Schema3.Literal("values"),
|
|
1275
|
+
values: Schema3.NonEmptyArray(Schema3.String)
|
|
1165
1276
|
})
|
|
1166
1277
|
]).annotate({ identifier: "ColumnFilter" });
|
|
1167
|
-
var ColumnFiltersArray =
|
|
1168
|
-
var ColumnFilters =
|
|
1278
|
+
var ColumnFiltersArray = Schema3.Array(ColumnFilter);
|
|
1279
|
+
var ColumnFilters = Schema3.declare(Schema3.is(ColumnFiltersArray), {
|
|
1169
1280
|
identifier: "ColumnFilters",
|
|
1170
|
-
toCodec: () =>
|
|
1171
|
-
toCodecStringTree: () =>
|
|
1281
|
+
toCodec: () => Schema3.link()(ColumnFiltersArray, SchemaTransformation.passthrough()),
|
|
1282
|
+
toCodecStringTree: () => Schema3.link()(Schema3.fromJsonString(ColumnFiltersArray), SchemaTransformation.passthrough())
|
|
1172
1283
|
});
|
|
1173
1284
|
var DEFAULT_PAGE_SIZE = 100;
|
|
1174
|
-
var Query =
|
|
1175
|
-
page:
|
|
1285
|
+
var Query = Schema3.Struct({
|
|
1286
|
+
page: Schema3.optional(Schema3.Union([Schema3.Finite, Schema3.FiniteFromString]).check(Schema3.isInt(), Schema3.isGreaterThanOrEqualTo(0))).pipe(Schema3.decodeTo(Schema3.Int.check(Schema3.isGreaterThanOrEqualTo(0)), {
|
|
1176
1287
|
decode: SchemaGetter.withDefault(Effect.succeed(0)),
|
|
1177
1288
|
encode: SchemaGetter.transformOptional(Option.filter((page) => page !== 0))
|
|
1178
1289
|
})),
|
|
1179
|
-
pageSize:
|
|
1290
|
+
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 })), {
|
|
1180
1291
|
decode: SchemaGetter.withDefault(Effect.succeed(DEFAULT_PAGE_SIZE)),
|
|
1181
1292
|
encode: SchemaGetter.transformOptional(Option.filter((pageSize) => pageSize !== DEFAULT_PAGE_SIZE))
|
|
1182
1293
|
})),
|
|
1183
|
-
globalFilter:
|
|
1184
|
-
sort:
|
|
1185
|
-
filters:
|
|
1294
|
+
globalFilter: Schema3.optional(Schema3.String),
|
|
1295
|
+
sort: Schema3.optional(SortParams),
|
|
1296
|
+
filters: Schema3.optional(ColumnFilters)
|
|
1186
1297
|
}).annotate({
|
|
1187
1298
|
identifier: "Query",
|
|
1188
1299
|
title: "Query",
|
|
@@ -1199,26 +1310,1478 @@ var Query = Schema.Struct({
|
|
|
1199
1310
|
}
|
|
1200
1311
|
]
|
|
1201
1312
|
});
|
|
1202
|
-
var QueryStandard =
|
|
1203
|
-
var PaginationMeta =
|
|
1204
|
-
page:
|
|
1205
|
-
pageSize:
|
|
1206
|
-
total:
|
|
1207
|
-
pageCount:
|
|
1208
|
-
}).pipe(
|
|
1313
|
+
var QueryStandard = Schema3.toStandardSchemaV1(Query);
|
|
1314
|
+
var PaginationMeta = Schema3.Struct({
|
|
1315
|
+
page: Schema3.Int,
|
|
1316
|
+
pageSize: Schema3.Int,
|
|
1317
|
+
total: Schema3.Int,
|
|
1318
|
+
pageCount: Schema3.Int
|
|
1319
|
+
}).pipe(Schema3.annotate({
|
|
1209
1320
|
identifier: "PaginationMeta",
|
|
1210
1321
|
title: "Pagination Metadata",
|
|
1211
1322
|
description: "Pagination metadata returned with a paginated list response.",
|
|
1212
1323
|
examples: [{ page: 0, pageSize: 20, total: 125, pageCount: 7 }]
|
|
1213
1324
|
}));
|
|
1214
1325
|
|
|
1215
|
-
// ../../src/
|
|
1216
|
-
import {
|
|
1326
|
+
// ../../src/lib/effect-ui-adapter/use-model.ts
|
|
1327
|
+
import { MessageLog as MessageLog2 } from "effect/ui";
|
|
1328
|
+
import {
|
|
1329
|
+
createContext,
|
|
1330
|
+
useCallback,
|
|
1331
|
+
useContext,
|
|
1332
|
+
useEffect,
|
|
1333
|
+
useLayoutEffect,
|
|
1334
|
+
useRef,
|
|
1335
|
+
useState,
|
|
1336
|
+
useSyncExternalStore
|
|
1337
|
+
} from "react";
|
|
1338
|
+
|
|
1339
|
+
// ../../src/lib/effect-ui-adapter/model-runtime.ts
|
|
1340
|
+
import { MessageLog, Renderer, View } from "effect/ui";
|
|
1341
|
+
import { BrowserHost, Html } from "effect/ui/html";
|
|
1342
|
+
import { Cause, Effect as Effect2, Fiber } from "effect";
|
|
1343
|
+
var node = () => ({ children: [] });
|
|
1344
|
+
var modelHost = (commit) => {
|
|
1345
|
+
const remove = (child) => {
|
|
1346
|
+
if (!child.parent)
|
|
1347
|
+
return;
|
|
1348
|
+
child.parent.children.splice(child.parent.children.indexOf(child), 1);
|
|
1349
|
+
delete child.parent;
|
|
1350
|
+
};
|
|
1351
|
+
return {
|
|
1352
|
+
createElement: node,
|
|
1353
|
+
createText: node,
|
|
1354
|
+
setText: () => {},
|
|
1355
|
+
setAttr: () => {},
|
|
1356
|
+
setProp: () => {},
|
|
1357
|
+
setEvents: () => {},
|
|
1358
|
+
insertBefore: (parent, child, before) => {
|
|
1359
|
+
if (child === before)
|
|
1360
|
+
return;
|
|
1361
|
+
remove(child);
|
|
1362
|
+
const index = before ? parent.children.indexOf(before) : parent.children.length;
|
|
1363
|
+
parent.children.splice(index, 0, child);
|
|
1364
|
+
child.parent = parent;
|
|
1365
|
+
},
|
|
1366
|
+
remove,
|
|
1367
|
+
parentOf: (child) => child.parent,
|
|
1368
|
+
nextOf: (child) => child.parent?.children[child.parent.children.indexOf(child) + 1],
|
|
1369
|
+
elements: ["html"],
|
|
1370
|
+
controlled: new Set,
|
|
1371
|
+
runsMounts: false,
|
|
1372
|
+
commit
|
|
1373
|
+
};
|
|
1374
|
+
};
|
|
1375
|
+
var mountModel = (component, props, publishSnapshot, messageLog, onEmit) => {
|
|
1376
|
+
let currentProps = props;
|
|
1377
|
+
let root;
|
|
1378
|
+
let active = true;
|
|
1379
|
+
let failure;
|
|
1380
|
+
const publish = () => {
|
|
1381
|
+
if (!active)
|
|
1382
|
+
return;
|
|
1383
|
+
if (failure) {
|
|
1384
|
+
publishSnapshot({ error: failure });
|
|
1385
|
+
return;
|
|
1386
|
+
}
|
|
1387
|
+
const current = root?.model();
|
|
1388
|
+
if (current !== undefined)
|
|
1389
|
+
publishSnapshot({ model: current });
|
|
1390
|
+
};
|
|
1391
|
+
const fiber = Effect2.runFork(Effect2.scoped(Effect2.gen(function* () {
|
|
1392
|
+
const mounted = yield* Renderer.mount(component, Effect2.succeed(props), node(), {
|
|
1393
|
+
head: false,
|
|
1394
|
+
onEmit,
|
|
1395
|
+
fallback: ({ cause }) => {
|
|
1396
|
+
failure = new Error("Effect UI root failed", {
|
|
1397
|
+
cause: Cause.squash(cause)
|
|
1398
|
+
});
|
|
1399
|
+
return View.text("");
|
|
1400
|
+
}
|
|
1401
|
+
});
|
|
1402
|
+
if (!active)
|
|
1403
|
+
return;
|
|
1404
|
+
root = mounted;
|
|
1405
|
+
if (props !== currentProps)
|
|
1406
|
+
mounted.setProps(currentProps);
|
|
1407
|
+
publish();
|
|
1408
|
+
return yield* Effect2.never;
|
|
1409
|
+
}).pipe(Effect2.provide(Renderer.layer(modelHost(publish))), Effect2.provideService(Html.Host, BrowserHost.htmlHost), Effect2.provideService(MessageLog.MessageLog, messageLog))));
|
|
1410
|
+
return {
|
|
1411
|
+
send: (message) => {
|
|
1412
|
+
root?.send(message);
|
|
1413
|
+
publish();
|
|
1414
|
+
},
|
|
1415
|
+
setProps: (next) => {
|
|
1416
|
+
currentProps = next;
|
|
1417
|
+
root?.setProps(next);
|
|
1418
|
+
},
|
|
1419
|
+
dispose: () => {
|
|
1420
|
+
active = false;
|
|
1421
|
+
root = undefined;
|
|
1422
|
+
Effect2.runFork(Fiber.interrupt(fiber));
|
|
1423
|
+
}
|
|
1424
|
+
};
|
|
1425
|
+
};
|
|
1426
|
+
|
|
1427
|
+
// ../../src/lib/effect-ui-adapter/use-model.ts
|
|
1428
|
+
"use client";
|
|
1429
|
+
var ModelMessageLogContext = createContext(undefined);
|
|
1430
|
+
var useModel = (component, props, options = {}) => {
|
|
1431
|
+
const contextLog = useContext(ModelMessageLogContext);
|
|
1432
|
+
const messageLog = options.messageLog ?? (contextLog === undefined ? MessageLog2.noop : contextLog);
|
|
1433
|
+
const [store] = useState(() => {
|
|
1434
|
+
const initial = { model: component.init(props).model };
|
|
1435
|
+
let snapshot = initial;
|
|
1436
|
+
const listeners = new Set;
|
|
1437
|
+
return {
|
|
1438
|
+
subscribe: (listener) => {
|
|
1439
|
+
listeners.add(listener);
|
|
1440
|
+
return () => {
|
|
1441
|
+
listeners.delete(listener);
|
|
1442
|
+
};
|
|
1443
|
+
},
|
|
1444
|
+
getSnapshot: () => snapshot,
|
|
1445
|
+
getServerSnapshot: () => initial,
|
|
1446
|
+
publish: (next) => {
|
|
1447
|
+
if ("model" in snapshot && "model" in next && Object.is(snapshot.model, next.model))
|
|
1448
|
+
return;
|
|
1449
|
+
if ("error" in snapshot && "error" in next && snapshot.error === next.error)
|
|
1450
|
+
return;
|
|
1451
|
+
snapshot = next;
|
|
1452
|
+
listeners.forEach((listener) => listener());
|
|
1453
|
+
}
|
|
1454
|
+
};
|
|
1455
|
+
});
|
|
1456
|
+
const snapshot = useSyncExternalStore(store.subscribe, store.getSnapshot, store.getServerSnapshot);
|
|
1457
|
+
const committed = useRef(props);
|
|
1458
|
+
const onEmit = useRef(options.onEmit);
|
|
1459
|
+
const runtime = useRef(undefined);
|
|
1460
|
+
const send = useCallback((message) => runtime.current?.send(message), []);
|
|
1461
|
+
useLayoutEffect(() => {
|
|
1462
|
+
onEmit.current = options.onEmit;
|
|
1463
|
+
committed.current = props;
|
|
1464
|
+
runtime.current?.setProps(props);
|
|
1465
|
+
}, [props, options.onEmit]);
|
|
1466
|
+
useEffect(() => {
|
|
1467
|
+
if (messageLog === null)
|
|
1468
|
+
return;
|
|
1469
|
+
const mounted = mountModel(component, committed.current, store.publish, messageLog, (event) => onEmit.current?.(event));
|
|
1470
|
+
runtime.current = mounted;
|
|
1471
|
+
return () => {
|
|
1472
|
+
runtime.current = undefined;
|
|
1473
|
+
mounted.dispose();
|
|
1474
|
+
};
|
|
1475
|
+
}, [component, messageLog, store]);
|
|
1476
|
+
if ("error" in snapshot)
|
|
1477
|
+
throw snapshot.error;
|
|
1478
|
+
return { model: snapshot.model, send };
|
|
1479
|
+
};
|
|
1480
|
+
|
|
1481
|
+
// ../../src/components/data-table/react.tsx
|
|
1482
|
+
import { useKrakstackLocale as useKrakstackLocale3 } from "@krak-stack/registry/krakstack-provider/react";
|
|
1483
|
+
|
|
1484
|
+
// ../../src/components/data-table/classes.ts
|
|
1485
|
+
var tableClasses = {
|
|
1486
|
+
selectionCell: "w-10 p-0 align-middle",
|
|
1487
|
+
selectionCenter: "grid place-items-center",
|
|
1488
|
+
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",
|
|
1489
|
+
selectedTrigger: "bg-primary text-primary-foreground hover:bg-primary/90 hover:text-primary-foreground",
|
|
1490
|
+
toolbar: "flex min-w-0 shrink-0 flex-wrap items-center gap-2",
|
|
1491
|
+
toolbarSearch: "relative min-w-0 flex-[1_1_12rem]",
|
|
1492
|
+
toolbarMenus: "w-max min-w-0 max-w-full",
|
|
1493
|
+
menubar: "h-auto w-full flex-wrap justify-start border border-input bg-transparent",
|
|
1494
|
+
cell: "overflow-hidden",
|
|
1495
|
+
cellContent: "min-w-0 wrap-anywhere",
|
|
1496
|
+
actionTrigger: "size-8 focus-visible:ring-inset",
|
|
1497
|
+
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))]",
|
|
1498
|
+
actionsAlign: "flex min-h-12 items-center justify-end pe-1",
|
|
1499
|
+
header: "relative h-12 p-0",
|
|
1500
|
+
stickyHeader: "sticky top-0 z-30 bg-background",
|
|
1501
|
+
stickyHeaderRule: "after:border-border after:pointer-events-none after:absolute after:inset-x-0 after:bottom-0 after:border-b",
|
|
1502
|
+
headerTrigger: "absolute inset-0 h-full w-full min-w-0 justify-start rounded-none px-2 pe-4 focus-visible:ring-inset",
|
|
1503
|
+
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",
|
|
1504
|
+
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",
|
|
1505
|
+
relationshipTrigger: "h-full w-full min-w-0 justify-between rounded-none px-2 text-start focus-visible:ring-inset",
|
|
1506
|
+
reference: "flex min-w-0 items-center gap-2",
|
|
1507
|
+
referenceAvatar: "relative grid size-8 shrink-0 place-items-center overflow-hidden bg-muted text-xs font-medium",
|
|
1508
|
+
referenceText: "flex min-w-0 flex-col leading-tight",
|
|
1509
|
+
group: "bg-muted/40 hover:bg-accent!",
|
|
1510
|
+
groupContent: "flex min-w-0 items-center gap-2 py-2 pe-1 ps-2",
|
|
1511
|
+
groupSticky: "sticky start-0 w-[100cqw] max-w-full",
|
|
1512
|
+
groupTrigger: "flex min-w-0 flex-1 cursor-pointer items-center gap-2 text-start font-medium",
|
|
1513
|
+
referenceName: "truncate font-medium",
|
|
1514
|
+
referenceDescription: "text-muted-foreground truncate text-xs"
|
|
1515
|
+
};
|
|
1516
|
+
var resolveTableClasses = (overrides) => ({
|
|
1517
|
+
...tableClasses,
|
|
1518
|
+
...overrides
|
|
1519
|
+
});
|
|
1520
|
+
|
|
1521
|
+
// ../../src/components/data-table/index.ts
|
|
1522
|
+
import { DateTime as DateTime3, Effect as Effect3, Option as Option3, Redacted, Schema as Schema5, Stream } from "effect";
|
|
1523
|
+
import { Csv } from "effect/encoding";
|
|
1524
|
+
import { Command, Component as Component2, Subscription, UiSchema as UiSchema2 } from "effect/ui";
|
|
1525
|
+
|
|
1526
|
+
// ../../src/components/data-table/schema.ts
|
|
1527
|
+
import { DateTime as DateTime2, Option as Option2, Schema as Schema4, Struct as Struct2, Tuple } from "effect";
|
|
1528
|
+
var TableClassesOverridesSchema = Schema4.Record(Schema4.Literals(Struct2.keys(tableClasses)), Schema4.optionalKey(Schema4.String)).annotate({ identifier: "TableClassesOverrides" });
|
|
1529
|
+
var DataTableCommonPropsSchema = Schema4.Struct({
|
|
1530
|
+
classes: Schema4.optional(TableClassesOverridesSchema),
|
|
1531
|
+
className: Schema4.optionalKey(Schema4.String),
|
|
1532
|
+
locale: Schema4.optionalKey(Schema4.String)
|
|
1533
|
+
}).annotate({ identifier: "DataTableCommonProps" });
|
|
1534
|
+
var DataTableSortSchema = Schema4.Struct({
|
|
1535
|
+
id: Schema4.NonEmptyString,
|
|
1536
|
+
direction: Schema4.Literals(["asc", "desc"])
|
|
1537
|
+
}).annotate({ identifier: "DataTableSort" });
|
|
1538
|
+
var queryFields = {
|
|
1539
|
+
page: Schema4.Int.check(Schema4.isGreaterThanOrEqualTo(0)),
|
|
1540
|
+
pageSize: Schema4.Int.check(Schema4.isBetween({ minimum: 1, maximum: 100 })),
|
|
1541
|
+
globalFilter: Schema4.optional(Schema4.String),
|
|
1542
|
+
sort: Schema4.optional(Schema4.Array(DataTableSortSchema)),
|
|
1543
|
+
filters: Schema4.optional(Schema4.Array(ColumnFilter))
|
|
1544
|
+
};
|
|
1545
|
+
var DataTableQuerySchema = Schema4.Struct(queryFields).annotate({
|
|
1546
|
+
identifier: "DataTableQuery"
|
|
1547
|
+
});
|
|
1548
|
+
var PageSizes = Schema4.NonEmptyArray(Schema4.Int.check(Schema4.isBetween({ minimum: 1, maximum: 100 })));
|
|
1549
|
+
var DataTableCommonFeaturesSchema = Schema4.Struct({
|
|
1550
|
+
search: Schema4.optionalKey(Schema4.Boolean),
|
|
1551
|
+
filtering: Schema4.optionalKey(Schema4.Boolean),
|
|
1552
|
+
sorting: Schema4.optionalKey(Schema4.Boolean),
|
|
1553
|
+
columnVisibility: Schema4.optionalKey(Schema4.Boolean)
|
|
1554
|
+
});
|
|
1555
|
+
var PaginationSchema = Schema4.Union([
|
|
1556
|
+
Schema4.Struct({
|
|
1557
|
+
mode: Schema4.optionalKey(Schema4.Literal("client")),
|
|
1558
|
+
pageSizes: Schema4.optionalKey(PageSizes)
|
|
1559
|
+
}).annotate({ identifier: "DataTableClientPagination" }),
|
|
1560
|
+
Schema4.Struct({
|
|
1561
|
+
mode: Schema4.Literal("server"),
|
|
1562
|
+
rowCount: Schema4.Int.check(Schema4.isGreaterThanOrEqualTo(0)),
|
|
1563
|
+
pageSizes: Schema4.optionalKey(PageSizes)
|
|
1564
|
+
}).annotate({ identifier: "DataTableServerPagination" })
|
|
1565
|
+
]);
|
|
1566
|
+
var DataTableItemSchema = Schema4.Struct({
|
|
1567
|
+
value: Schema4.NonEmptyString,
|
|
1568
|
+
label: Schema4.String
|
|
1569
|
+
}).annotate({ identifier: "DataTableItem" });
|
|
1570
|
+
var DataTableReferenceSchema = Schema4.Struct({
|
|
1571
|
+
label: Schema4.String,
|
|
1572
|
+
description: Schema4.optionalKey(Schema4.String),
|
|
1573
|
+
imageSrc: Schema4.optionalKey(Schema4.NullOr(Schema4.String))
|
|
1574
|
+
}).annotate({ identifier: "DataTableReference" });
|
|
1575
|
+
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" });
|
|
1576
|
+
var isCalendarDate = Schema4.is(CalendarDate);
|
|
1577
|
+
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" });
|
|
1578
|
+
var DataTableDateInputSchema = Schema4.Union([
|
|
1579
|
+
Schema4.Date,
|
|
1580
|
+
Schema4.Int,
|
|
1581
|
+
CalendarDate,
|
|
1582
|
+
InstantString
|
|
1583
|
+
]).annotate({ identifier: "DataTableDateInput" });
|
|
1584
|
+
var DateStyle = Schema4.Literals(["full", "long", "medium", "short"]);
|
|
1585
|
+
var DataTableDateFormatSchema = Schema4.Struct({
|
|
1586
|
+
locale: Schema4.optionalKey(Schema4.String),
|
|
1587
|
+
timeZone: Schema4.optionalKey(Schema4.String),
|
|
1588
|
+
dateStyle: Schema4.optionalKey(DateStyle),
|
|
1589
|
+
exportFormat: Schema4.optionalKey(Schema4.Literals(["iso", "formatted"]))
|
|
1590
|
+
}).annotate({ identifier: "DataTableDateFormat" });
|
|
1591
|
+
var DataTableDateTimeFormatSchema = Schema4.Struct({
|
|
1592
|
+
...DataTableDateFormatSchema.fields,
|
|
1593
|
+
timeStyle: Schema4.optionalKey(DateStyle),
|
|
1594
|
+
hour12: Schema4.optionalKey(Schema4.Boolean)
|
|
1595
|
+
}).annotate({ identifier: "DataTableDateTimeFormat" });
|
|
1596
|
+
var DataTableCellValueSchema = Schema4.NullOr(Schema4.Union([
|
|
1597
|
+
Schema4.String,
|
|
1598
|
+
Schema4.Boolean,
|
|
1599
|
+
Schema4.Finite,
|
|
1600
|
+
Schema4.Array(DataTableItemSchema),
|
|
1601
|
+
DataTableReferenceSchema
|
|
1602
|
+
])).annotate({ identifier: "DataTableCellValue" });
|
|
1603
|
+
var DataTableActionSchema = Schema4.Struct({
|
|
1604
|
+
id: Schema4.NonEmptyString,
|
|
1605
|
+
name: Schema4.String,
|
|
1606
|
+
variant: Schema4.optionalKey(Schema4.Literals(["default", "destructive"])),
|
|
1607
|
+
disabled: Schema4.optionalKey(Schema4.Boolean)
|
|
1608
|
+
}).annotate({ identifier: "DataTableAction" });
|
|
1609
|
+
var DataTableRowSchema = Schema4.Struct({
|
|
1610
|
+
id: Schema4.NonEmptyString,
|
|
1611
|
+
label: Schema4.String,
|
|
1612
|
+
cells: Schema4.Record(Schema4.String, DataTableCellValueSchema),
|
|
1613
|
+
actions: Schema4.optionalKey(Schema4.Array(DataTableActionSchema)),
|
|
1614
|
+
primaryActionId: Schema4.optionalKey(Schema4.String),
|
|
1615
|
+
groups: Schema4.optionalKey(Schema4.Record(Schema4.String, Schema4.Array(Schema4.String))),
|
|
1616
|
+
selectable: Schema4.optionalKey(Schema4.Boolean),
|
|
1617
|
+
disabledColumnIds: Schema4.optionalKey(Schema4.Array(Schema4.String))
|
|
1618
|
+
}).annotate({ identifier: "DataTableRow" });
|
|
1619
|
+
var column = {
|
|
1620
|
+
id: Schema4.NonEmptyString,
|
|
1621
|
+
headerName: Schema4.String,
|
|
1622
|
+
sortable: Schema4.optionalKey(Schema4.Boolean),
|
|
1623
|
+
hideable: Schema4.optionalKey(Schema4.Boolean),
|
|
1624
|
+
export: Schema4.optionalKey(Schema4.Boolean),
|
|
1625
|
+
width: Schema4.optionalKey(Schema4.Number),
|
|
1626
|
+
minWidth: Schema4.optionalKey(Schema4.Number),
|
|
1627
|
+
maxWidth: Schema4.optionalKey(Schema4.Number),
|
|
1628
|
+
resizable: Schema4.optionalKey(Schema4.Boolean),
|
|
1629
|
+
truncate: Schema4.optionalKey(Schema4.Boolean),
|
|
1630
|
+
searchable: Schema4.optionalKey(Schema4.Boolean),
|
|
1631
|
+
filterable: Schema4.optionalKey(Schema4.Boolean),
|
|
1632
|
+
emptyLabel: Schema4.optionalKey(Schema4.String),
|
|
1633
|
+
nulls: Schema4.optionalKey(Schema4.Literals(["first", "last"]))
|
|
1634
|
+
};
|
|
1635
|
+
var DataTableFieldSchema = Schema4.Union([
|
|
1636
|
+
Schema4.Struct({ ...column, type: Schema4.Literal("text") }),
|
|
1637
|
+
Schema4.Struct({
|
|
1638
|
+
...column,
|
|
1639
|
+
type: Schema4.Literal("number"),
|
|
1640
|
+
typeOptions: Schema4.optionalKey(Schema4.Struct({
|
|
1641
|
+
locale: Schema4.optionalKey(Schema4.String),
|
|
1642
|
+
style: Schema4.optionalKey(Schema4.Literals(["decimal", "percent", "currency", "unit"])),
|
|
1643
|
+
currency: Schema4.optionalKey(Schema4.String),
|
|
1644
|
+
unit: Schema4.optionalKey(Schema4.String),
|
|
1645
|
+
notation: Schema4.optionalKey(Schema4.Literals(["standard", "scientific", "engineering", "compact"])),
|
|
1646
|
+
minimumFractionDigits: Schema4.optionalKey(Schema4.Int.check(Schema4.isBetween({ minimum: 0, maximum: 20 }))),
|
|
1647
|
+
maximumFractionDigits: Schema4.optionalKey(Schema4.Int.check(Schema4.isBetween({ minimum: 0, maximum: 20 }))),
|
|
1648
|
+
exportFormat: Schema4.optionalKey(Schema4.Literals(["raw", "formatted"]))
|
|
1649
|
+
}).annotate({ identifier: "DataTableNumberFormat" }))
|
|
1650
|
+
}),
|
|
1651
|
+
Schema4.Struct({ ...column, type: Schema4.Literal("reference") }),
|
|
1652
|
+
Schema4.Struct({
|
|
1653
|
+
...column,
|
|
1654
|
+
type: Schema4.Literal("date"),
|
|
1655
|
+
typeOptions: Schema4.optionalKey(DataTableDateFormatSchema)
|
|
1656
|
+
}),
|
|
1657
|
+
Schema4.Struct({
|
|
1658
|
+
...column,
|
|
1659
|
+
type: Schema4.Literal("dateTime"),
|
|
1660
|
+
typeOptions: Schema4.optionalKey(DataTableDateTimeFormatSchema)
|
|
1661
|
+
}),
|
|
1662
|
+
Schema4.Struct({
|
|
1663
|
+
...column,
|
|
1664
|
+
type: Schema4.Literal("boolean"),
|
|
1665
|
+
editable: Schema4.optionalKey(Schema4.Boolean),
|
|
1666
|
+
typeOptions: Schema4.optionalKey(Schema4.Struct({
|
|
1667
|
+
trueLabel: Schema4.optionalKey(Schema4.String),
|
|
1668
|
+
falseLabel: Schema4.optionalKey(Schema4.String),
|
|
1669
|
+
exportFormat: Schema4.optionalKey(Schema4.Literals(["raw", "formatted"]))
|
|
1670
|
+
}).annotate({ identifier: "DataTableBooleanFormat" }))
|
|
1671
|
+
}),
|
|
1672
|
+
Schema4.Struct({
|
|
1673
|
+
...column,
|
|
1674
|
+
type: Schema4.Literal("list"),
|
|
1675
|
+
filterOptions: Schema4.optionalKey(Schema4.Array(DataTableItemSchema)),
|
|
1676
|
+
options: Schema4.optionalKey(Schema4.Array(DataTableItemSchema)),
|
|
1677
|
+
allowRemove: Schema4.optionalKey(Schema4.Boolean),
|
|
1678
|
+
itemActions: Schema4.optionalKey(Schema4.Array(DataTableActionSchema)),
|
|
1679
|
+
display: Schema4.optionalKey(Schema4.Literals(["list", "icon"])),
|
|
1680
|
+
visibleCount: Schema4.optionalKey(Schema4.Int.check(Schema4.isGreaterThanOrEqualTo(0))),
|
|
1681
|
+
actionsLabel: Schema4.optionalKey(Schema4.String),
|
|
1682
|
+
manageLabel: Schema4.optionalKey(Schema4.String)
|
|
1683
|
+
})
|
|
1684
|
+
]).annotate({ identifier: "DataTableField" });
|
|
1685
|
+
var DataTableColumnSchema = DataTableFieldSchema.mapMembers(Tuple.map(Schema4.fieldsAssign({
|
|
1686
|
+
fields: Schema4.optionalKey(Schema4.Array(DataTableFieldSchema))
|
|
1687
|
+
}))).annotate({ identifier: "DataTableColumn" });
|
|
1688
|
+
var DataTableLabelsSchema = Schema4.Struct({
|
|
1689
|
+
actions: Schema4.optionalKey(Schema4.String),
|
|
1690
|
+
addItem: Schema4.optionalKey(Schema4.String),
|
|
1691
|
+
listDetails: Schema4.optionalKey(Schema4.String),
|
|
1692
|
+
empty: Schema4.optionalKey(Schema4.String),
|
|
1693
|
+
filters: Schema4.optionalKey(Schema4.String),
|
|
1694
|
+
filtersClear: Schema4.optionalKey(Schema4.String),
|
|
1695
|
+
filterColumn: Schema4.optionalKey(Schema4.String),
|
|
1696
|
+
filterClear: Schema4.optionalKey(Schema4.String),
|
|
1697
|
+
filterApply: Schema4.optionalKey(Schema4.String),
|
|
1698
|
+
filterValue: Schema4.optionalKey(Schema4.String),
|
|
1699
|
+
filterOperator: Schema4.optionalKey(Schema4.String),
|
|
1700
|
+
filterContains: Schema4.optionalKey(Schema4.String),
|
|
1701
|
+
filterEquals: Schema4.optionalKey(Schema4.String),
|
|
1702
|
+
filterStartsWith: Schema4.optionalKey(Schema4.String),
|
|
1703
|
+
filterEndsWith: Schema4.optionalKey(Schema4.String),
|
|
1704
|
+
filterMin: Schema4.optionalKey(Schema4.String),
|
|
1705
|
+
filterMax: Schema4.optionalKey(Schema4.String),
|
|
1706
|
+
filterFrom: Schema4.optionalKey(Schema4.String),
|
|
1707
|
+
filterTo: Schema4.optionalKey(Schema4.String),
|
|
1708
|
+
filterTrue: Schema4.optionalKey(Schema4.String),
|
|
1709
|
+
filterFalse: Schema4.optionalKey(Schema4.String),
|
|
1710
|
+
filterInvalid: Schema4.optionalKey(Schema4.String),
|
|
1711
|
+
columns: Schema4.optionalKey(Schema4.String),
|
|
1712
|
+
sortBy: Schema4.optionalKey(Schema4.String),
|
|
1713
|
+
hideColumn: Schema4.optionalKey(Schema4.String),
|
|
1714
|
+
loading: Schema4.optionalKey(Schema4.String),
|
|
1715
|
+
removeItem: Schema4.optionalKey(Schema4.String),
|
|
1716
|
+
search: Schema4.optionalKey(Schema4.String),
|
|
1717
|
+
selectAllRows: Schema4.optionalKey(Schema4.String),
|
|
1718
|
+
selectRow: Schema4.optionalKey(Schema4.String),
|
|
1719
|
+
selected: Schema4.optionalKey(Schema4.String),
|
|
1720
|
+
sortAsc: Schema4.optionalKey(Schema4.String),
|
|
1721
|
+
sortDesc: Schema4.optionalKey(Schema4.String),
|
|
1722
|
+
sortClear: Schema4.optionalKey(Schema4.String),
|
|
1723
|
+
view: Schema4.optionalKey(Schema4.String),
|
|
1724
|
+
tableView: Schema4.optionalKey(Schema4.String),
|
|
1725
|
+
galleryView: Schema4.optionalKey(Schema4.String),
|
|
1726
|
+
groupBy: Schema4.optionalKey(Schema4.String),
|
|
1727
|
+
export: Schema4.optionalKey(Schema4.String),
|
|
1728
|
+
exportFailed: Schema4.optionalKey(Schema4.String),
|
|
1729
|
+
moveUp: Schema4.optionalKey(Schema4.String),
|
|
1730
|
+
moveDown: Schema4.optionalKey(Schema4.String),
|
|
1731
|
+
reorder: Schema4.optionalKey(Schema4.String),
|
|
1732
|
+
refresh: Schema4.optionalKey(Schema4.String),
|
|
1733
|
+
resize: Schema4.optionalKey(Schema4.String)
|
|
1734
|
+
}).annotate({ identifier: "DataTableLabels" });
|
|
1735
|
+
var DataTableViewSchema = Schema4.Literals(["table", "gallery"]);
|
|
1736
|
+
var DataTablePreferencesSchema = Schema4.Struct({
|
|
1737
|
+
columnVisibility: Schema4.Record(Schema4.String, Schema4.Boolean),
|
|
1738
|
+
columnSizing: Schema4.Record(Schema4.String, Schema4.Finite),
|
|
1739
|
+
grouping: Schema4.optionalKey(Schema4.Array(Schema4.String)),
|
|
1740
|
+
view: DataTableViewSchema
|
|
1741
|
+
}).annotate({ identifier: "DataTablePersistedUiState" });
|
|
1742
|
+
var GroupField = Schema4.Struct({
|
|
1743
|
+
id: Schema4.NonEmptyString,
|
|
1744
|
+
label: Schema4.String,
|
|
1745
|
+
actionsLabel: Schema4.optionalKey(Schema4.String),
|
|
1746
|
+
groups: Schema4.optionalKey(Schema4.Array(Schema4.Struct({
|
|
1747
|
+
id: Schema4.String,
|
|
1748
|
+
label: Schema4.String,
|
|
1749
|
+
empty: Schema4.optionalKey(Schema4.String)
|
|
1750
|
+
}).annotate({ identifier: "DataTableGroupLabel" }))),
|
|
1751
|
+
actions: Schema4.optionalKey(Schema4.Array(DataTableActionSchema)),
|
|
1752
|
+
movable: Schema4.optionalKey(Schema4.Boolean)
|
|
1753
|
+
}).annotate({ identifier: "DataTableGroupField" });
|
|
1754
|
+
var DataTablePropsSchema = Schema4.Struct({
|
|
1755
|
+
...DataTableCommonPropsSchema.fields,
|
|
1756
|
+
label: Schema4.String,
|
|
1757
|
+
rowData: Schema4.Array(DataTableRowSchema),
|
|
1758
|
+
rowActivation: Schema4.optionalKey(Schema4.Boolean),
|
|
1759
|
+
columnDefs: Schema4.Array(DataTableColumnSchema),
|
|
1760
|
+
status: Schema4.optionalKey(Schema4.Struct({
|
|
1761
|
+
loading: Schema4.optionalKey(Schema4.Boolean),
|
|
1762
|
+
empty: Schema4.optionalKey(Schema4.String),
|
|
1763
|
+
error: Schema4.optionalKey(Schema4.String)
|
|
1764
|
+
})),
|
|
1765
|
+
sort: Schema4.optionalKey(Schema4.Array(DataTableSortSchema)),
|
|
1766
|
+
sortMode: Schema4.optionalKey(Schema4.Literals(["client", "server"])),
|
|
1767
|
+
search: Schema4.optionalKey(Schema4.Boolean),
|
|
1768
|
+
columnFilters: Schema4.optionalKey(Schema4.Boolean),
|
|
1769
|
+
state: Schema4.optionalKey(DataTableQuerySchema),
|
|
1770
|
+
features: Schema4.optionalKey(Schema4.Struct({
|
|
1771
|
+
...DataTableCommonFeaturesSchema.fields,
|
|
1772
|
+
pagination: Schema4.optionalKey(Schema4.Union([Schema4.Literal(false), PaginationSchema])),
|
|
1773
|
+
grouping: Schema4.optionalKey(Schema4.Struct({
|
|
1774
|
+
initial: Schema4.optionalKey(Schema4.Array(Schema4.String)),
|
|
1775
|
+
fields: Schema4.Array(GroupField)
|
|
1776
|
+
}).annotate({ identifier: "DataTableGrouping" })),
|
|
1777
|
+
gallery: Schema4.optionalKey(Schema4.Struct({
|
|
1778
|
+
name: Schema4.String,
|
|
1779
|
+
description: Schema4.optionalKey(Schema4.String),
|
|
1780
|
+
image: Schema4.optionalKey(Schema4.String),
|
|
1781
|
+
tags: Schema4.optionalKey(Schema4.Array(Schema4.String))
|
|
1782
|
+
}).annotate({ identifier: "DataTableGallery" })),
|
|
1783
|
+
reordering: Schema4.optionalKey(Schema4.Boolean),
|
|
1784
|
+
export: Schema4.optionalKey(Schema4.Struct({
|
|
1785
|
+
baseName: Schema4.String,
|
|
1786
|
+
scope: Schema4.optionalKey(Schema4.Literals(["filteredRows", "currentPage"])),
|
|
1787
|
+
builtIn: Schema4.optionalKey(Schema4.Boolean),
|
|
1788
|
+
actions: Schema4.optionalKey(Schema4.Array(DataTableActionSchema)),
|
|
1789
|
+
pending: Schema4.optionalKey(Schema4.Boolean),
|
|
1790
|
+
failed: Schema4.optionalKey(Schema4.Boolean)
|
|
1791
|
+
}).annotate({ identifier: "DataTableExport" })),
|
|
1792
|
+
refresh: Schema4.optionalKey(Schema4.Boolean),
|
|
1793
|
+
virtualization: Schema4.optionalKey(Schema4.Union([
|
|
1794
|
+
Schema4.Boolean,
|
|
1795
|
+
Schema4.Struct({
|
|
1796
|
+
scroll: Schema4.optionalKey(Schema4.Literals(["table", "internal", "page"])),
|
|
1797
|
+
height: Schema4.optionalKey(Schema4.Int.check(Schema4.isGreaterThan(0))),
|
|
1798
|
+
estimateRowHeight: Schema4.optionalKey(Schema4.Int.check(Schema4.isGreaterThan(0))),
|
|
1799
|
+
overscan: Schema4.optionalKey(Schema4.Int.check(Schema4.isGreaterThanOrEqualTo(0)))
|
|
1800
|
+
}).annotate({ identifier: "DataTableVirtualization" })
|
|
1801
|
+
]))
|
|
1802
|
+
}).annotate({ identifier: "DataTableHtmlFeatures" })),
|
|
1803
|
+
initialState: Schema4.optionalKey(Schema4.Struct({
|
|
1804
|
+
...queryFields,
|
|
1805
|
+
page: Schema4.optional(queryFields.page),
|
|
1806
|
+
pageSize: Schema4.optional(queryFields.pageSize),
|
|
1807
|
+
columnVisibility: Schema4.optionalKey(Schema4.Record(Schema4.String, Schema4.Boolean)),
|
|
1808
|
+
view: Schema4.optionalKey(DataTableViewSchema)
|
|
1809
|
+
}).annotate({ identifier: "DataTableInitialQuery" })),
|
|
1810
|
+
pagination: Schema4.optionalKey(PaginationSchema),
|
|
1811
|
+
selection: Schema4.optionalKey(Schema4.Struct({
|
|
1812
|
+
selectedRowIds: Schema4.optionalKey(Schema4.Array(Schema4.String)),
|
|
1813
|
+
bulkActionsLabel: Schema4.optionalKey(Schema4.String),
|
|
1814
|
+
bulkActions: Schema4.optionalKey(Schema4.Array(DataTableActionSchema))
|
|
1815
|
+
})),
|
|
1816
|
+
messages: Schema4.optionalKey(Schema4.Record(Schema4.String, DataTableLabelsSchema))
|
|
1817
|
+
}).annotate({ identifier: "DataTableProps" });
|
|
1818
|
+
var DataTableFilterDraftSchema = Schema4.Struct({
|
|
1819
|
+
id: Schema4.String,
|
|
1820
|
+
primary: Schema4.String,
|
|
1821
|
+
secondary: Schema4.String,
|
|
1822
|
+
operator: TextFilterOperator,
|
|
1823
|
+
values: Schema4.Array(Schema4.String)
|
|
1824
|
+
}).annotate({ identifier: "DataTableFilterDraft" });
|
|
1825
|
+
|
|
1826
|
+
// ../../src/components/data-table/index.ts
|
|
1827
|
+
var defaultMessages = {
|
|
1828
|
+
en: {
|
|
1829
|
+
actions: "Actions",
|
|
1830
|
+
addItem: "Add item...",
|
|
1831
|
+
listDetails: "View all items",
|
|
1832
|
+
empty: "No results.",
|
|
1833
|
+
filters: "Filters",
|
|
1834
|
+
filtersClear: "Clear all filters",
|
|
1835
|
+
filterColumn: "Column",
|
|
1836
|
+
filterClear: "Clear filter",
|
|
1837
|
+
filterApply: "Apply filter",
|
|
1838
|
+
filterValue: "Value",
|
|
1839
|
+
filterOperator: "Operator",
|
|
1840
|
+
filterContains: "Contains",
|
|
1841
|
+
filterEquals: "Equals",
|
|
1842
|
+
filterStartsWith: "Starts with",
|
|
1843
|
+
filterEndsWith: "Ends with",
|
|
1844
|
+
filterMin: "Minimum",
|
|
1845
|
+
filterMax: "Maximum",
|
|
1846
|
+
filterFrom: "From (UTC)",
|
|
1847
|
+
filterTo: "To (UTC)",
|
|
1848
|
+
filterTrue: "True",
|
|
1849
|
+
filterFalse: "False",
|
|
1850
|
+
filterInvalid: "Enter a valid filter. Ranges must be in ascending order.",
|
|
1851
|
+
columns: "Columns",
|
|
1852
|
+
sortBy: "Sort by",
|
|
1853
|
+
hideColumn: "Hide column",
|
|
1854
|
+
loading: "Loading...",
|
|
1855
|
+
removeItem: "Remove",
|
|
1856
|
+
search: "Search",
|
|
1857
|
+
selectAllRows: "Select all rows on this page",
|
|
1858
|
+
selectRow: "Select row",
|
|
1859
|
+
selected: "Selected",
|
|
1860
|
+
sortAsc: "Ascending",
|
|
1861
|
+
sortDesc: "Descending",
|
|
1862
|
+
sortClear: "Clear sorting",
|
|
1863
|
+
view: "View",
|
|
1864
|
+
tableView: "Table",
|
|
1865
|
+
galleryView: "Gallery",
|
|
1866
|
+
groupBy: "Group by",
|
|
1867
|
+
export: "Export",
|
|
1868
|
+
exportFailed: "Export failed. Please try again.",
|
|
1869
|
+
refresh: "Refresh",
|
|
1870
|
+
moveUp: "Move up",
|
|
1871
|
+
moveDown: "Move down",
|
|
1872
|
+
reorder: "Drag to reorder",
|
|
1873
|
+
resize: "Resize column"
|
|
1874
|
+
},
|
|
1875
|
+
fr: {
|
|
1876
|
+
actions: "Actions",
|
|
1877
|
+
addItem: "Ajouter un élément...",
|
|
1878
|
+
listDetails: "Afficher tous les éléments",
|
|
1879
|
+
empty: "Aucun résultat.",
|
|
1880
|
+
filters: "Filtres",
|
|
1881
|
+
filtersClear: "Effacer tous les filtres",
|
|
1882
|
+
filterColumn: "Colonne",
|
|
1883
|
+
filterClear: "Effacer le filtre",
|
|
1884
|
+
filterApply: "Appliquer le filtre",
|
|
1885
|
+
filterValue: "Valeur",
|
|
1886
|
+
filterOperator: "Opérateur",
|
|
1887
|
+
filterContains: "Contient",
|
|
1888
|
+
filterEquals: "Égal à",
|
|
1889
|
+
filterStartsWith: "Commence par",
|
|
1890
|
+
filterEndsWith: "Se termine par",
|
|
1891
|
+
filterMin: "Minimum",
|
|
1892
|
+
filterMax: "Maximum",
|
|
1893
|
+
filterFrom: "Du (UTC)",
|
|
1894
|
+
filterTo: "Au (UTC)",
|
|
1895
|
+
filterTrue: "Vrai",
|
|
1896
|
+
filterFalse: "Faux",
|
|
1897
|
+
filterInvalid: "Saisissez un filtre valide. Les bornes doivent être dans l’ordre croissant.",
|
|
1898
|
+
columns: "Colonnes",
|
|
1899
|
+
sortBy: "Trier par",
|
|
1900
|
+
hideColumn: "Masquer la colonne",
|
|
1901
|
+
loading: "Chargement...",
|
|
1902
|
+
removeItem: "Retirer",
|
|
1903
|
+
search: "Rechercher",
|
|
1904
|
+
selectAllRows: "Sélectionner toutes les lignes de cette page",
|
|
1905
|
+
selectRow: "Sélectionner la ligne",
|
|
1906
|
+
selected: "Sélectionnés",
|
|
1907
|
+
sortAsc: "Croissant",
|
|
1908
|
+
sortDesc: "Décroissant",
|
|
1909
|
+
sortClear: "Effacer le tri",
|
|
1910
|
+
view: "Affichage",
|
|
1911
|
+
tableView: "Tableau",
|
|
1912
|
+
galleryView: "Galerie",
|
|
1913
|
+
groupBy: "Grouper par",
|
|
1914
|
+
export: "Exporter",
|
|
1915
|
+
exportFailed: "L’exportation a échoué. Veuillez réessayer.",
|
|
1916
|
+
refresh: "Rafraîchir",
|
|
1917
|
+
moveUp: "Déplacer vers le haut",
|
|
1918
|
+
moveDown: "Déplacer vers le bas",
|
|
1919
|
+
reorder: "Glisser pour réorganiser",
|
|
1920
|
+
resize: "Redimensionner la colonne"
|
|
1921
|
+
}
|
|
1922
|
+
};
|
|
1923
|
+
var compareTableText = (left, right, locale) => left.localeCompare(right, locale, { numeric: true, sensitivity: "base" });
|
|
1924
|
+
var isTableText = Schema5.is(Schema5.String);
|
|
1925
|
+
var isTableNumber = Schema5.is(Schema5.Finite);
|
|
1926
|
+
var isTableBoolean = Schema5.is(Schema5.Boolean);
|
|
1927
|
+
var isTableReference = Schema5.is(DataTableReferenceSchema);
|
|
1928
|
+
var isTableList = Schema5.is(Schema5.Array(DataTableItemSchema));
|
|
1929
|
+
var tableInitials = (label) => label.trim().split(/\s+/).slice(0, 2).map((word) => word.slice(0, 1)).join("").toLocaleUpperCase();
|
|
1930
|
+
var formatNumberValue = (value, options, defaultLocale = "en") => {
|
|
1931
|
+
const { locale, ...format } = options ?? {};
|
|
1932
|
+
return new Intl.NumberFormat(locale ?? defaultLocale, format).format(value);
|
|
1933
|
+
};
|
|
1934
|
+
var tableBooleanLabel = (value, options) => (value ? options?.trueLabel : options?.falseLabel) ?? String(value);
|
|
1935
|
+
var decodeDateInput = Schema5.decodeUnknownOption(DataTableDateInputSchema);
|
|
1936
|
+
var resolveDate = (value, type) => Option3.getOrUndefined(Option3.flatMap(decodeDateInput(value), (input) => {
|
|
1937
|
+
const calendarOnly = isCalendarDate(input);
|
|
1938
|
+
if (calendarOnly && type === "dateTime")
|
|
1939
|
+
return Option3.none();
|
|
1940
|
+
return Option3.map(DateTime3.make(input), (instant) => ({
|
|
1941
|
+
instant,
|
|
1942
|
+
calendarOnly
|
|
1943
|
+
}));
|
|
1944
|
+
}));
|
|
1945
|
+
var formatDateValue = (date, column, locale = "en") => DateTime3.format(date.instant, {
|
|
1946
|
+
locale: column.typeOptions?.locale ?? locale,
|
|
1947
|
+
timeZone: date.calendarOnly ? "UTC" : column.typeOptions?.timeZone ?? "UTC",
|
|
1948
|
+
dateStyle: column.typeOptions?.dateStyle ?? "medium",
|
|
1949
|
+
timeStyle: column.type === "dateTime" ? column.typeOptions?.timeStyle ?? "short" : undefined,
|
|
1950
|
+
hour12: column.type === "dateTime" ? column.typeOptions?.hour12 : undefined
|
|
1951
|
+
});
|
|
1952
|
+
var dateIsoValue = (date) => date.calendarOnly ? DateTime3.formatIsoDateUtc(date.instant) : DateTime3.formatIso(date.instant);
|
|
1953
|
+
var matchesDateFilter = (date, filter) => {
|
|
1954
|
+
if (!date)
|
|
1955
|
+
return false;
|
|
1956
|
+
const day = DateTime3.formatIsoDateUtc(date.instant);
|
|
1957
|
+
return (filter.from === undefined || day >= filter.from) && (filter.to === undefined || day <= filter.to);
|
|
1958
|
+
};
|
|
1959
|
+
var matchesFilterText = (value, filter) => {
|
|
1960
|
+
const text = value.toLocaleLowerCase();
|
|
1961
|
+
const query = filter.value.toLocaleLowerCase();
|
|
1962
|
+
switch (filter.operator) {
|
|
1963
|
+
case "contains":
|
|
1964
|
+
return text.includes(query);
|
|
1965
|
+
case "equals":
|
|
1966
|
+
return text === query;
|
|
1967
|
+
case "startsWith":
|
|
1968
|
+
return text.startsWith(query);
|
|
1969
|
+
case "endsWith":
|
|
1970
|
+
return text.endsWith(query);
|
|
1971
|
+
}
|
|
1972
|
+
};
|
|
1973
|
+
var tableFilterKind = (column, hasOptions = false) => hasOptions || column.type === "list" ? "values" : column.type === "reference" ? "text" : column.type === "dateTime" ? "date" : column.type ?? "text";
|
|
1974
|
+
var matchesTableFilter = (filter, value, type, text, values) => {
|
|
1975
|
+
switch (filter.kind) {
|
|
1976
|
+
case "text":
|
|
1977
|
+
return matchesFilterText(text(), filter);
|
|
1978
|
+
case "number":
|
|
1979
|
+
return isTableNumber(value) && (filter.min === undefined || value >= filter.min) && (filter.max === undefined || value <= filter.max);
|
|
1980
|
+
case "boolean":
|
|
1981
|
+
return value === filter.value;
|
|
1982
|
+
case "values":
|
|
1983
|
+
return values().some((value) => filter.values.includes(value));
|
|
1984
|
+
case "date":
|
|
1985
|
+
return matchesDateFilter(resolveDate(value, type === "dateTime" ? "dateTime" : "date"), filter);
|
|
1986
|
+
}
|
|
1987
|
+
};
|
|
1988
|
+
var tableDataColumns = (columns) => columns.flatMap((column) => column.fields?.length ? column.fields.map((field) => ({
|
|
1989
|
+
...field,
|
|
1990
|
+
id: `${column.id}.${field.id}`,
|
|
1991
|
+
headerName: `${column.headerName} / ${field.headerName}`,
|
|
1992
|
+
sortable: column.sortable === false ? false : field.sortable,
|
|
1993
|
+
searchable: column.searchable === false ? false : field.searchable,
|
|
1994
|
+
filterable: column.filterable === false ? false : field.filterable,
|
|
1995
|
+
export: column.export === false ? false : field.export
|
|
1996
|
+
})) : [column]);
|
|
1997
|
+
var filterTableColumns = (rows, columns, filters) => {
|
|
1998
|
+
const byId = new Map(columns.filter(({ filterable }) => filterable !== false).map((column) => [column.id, column]));
|
|
1999
|
+
const active = filters.filter((filter) => {
|
|
2000
|
+
const column = byId.get(filter.id);
|
|
2001
|
+
return column && tableFilterKind(column) === filter.kind;
|
|
2002
|
+
});
|
|
2003
|
+
if (!active.length)
|
|
2004
|
+
return rows;
|
|
2005
|
+
return rows.filter((row) => active.every((filter) => {
|
|
2006
|
+
const value = row.cells[filter.id];
|
|
2007
|
+
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) : []);
|
|
2008
|
+
}));
|
|
2009
|
+
};
|
|
2010
|
+
var columnValue = (column, value) => {
|
|
2011
|
+
switch (column.type) {
|
|
2012
|
+
case "text":
|
|
2013
|
+
return isTableText(value) ? value : null;
|
|
2014
|
+
case "number":
|
|
2015
|
+
case "boolean":
|
|
2016
|
+
case "date":
|
|
2017
|
+
case "dateTime":
|
|
2018
|
+
return tableSortScalar(column.type, value);
|
|
2019
|
+
case "reference":
|
|
2020
|
+
return isTableReference(value) ? value.label : null;
|
|
2021
|
+
case "list":
|
|
2022
|
+
return isTableList(value) ? value.map(({ label }) => label).join(", ") : null;
|
|
2023
|
+
}
|
|
2024
|
+
};
|
|
2025
|
+
var tableSortScalar = (type, value) => {
|
|
2026
|
+
if (type === "number")
|
|
2027
|
+
return isTableNumber(value) ? value : null;
|
|
2028
|
+
if (type === "boolean")
|
|
2029
|
+
return isTableBoolean(value) ? Number(value) : null;
|
|
2030
|
+
const date = resolveDate(value, type);
|
|
2031
|
+
return date ? DateTime3.toEpochMillis(date.instant) : null;
|
|
2032
|
+
};
|
|
2033
|
+
var compareTableSortValues = (left, right, direction, nulls, locale) => {
|
|
2034
|
+
if (left === right)
|
|
2035
|
+
return 0;
|
|
2036
|
+
const nullOrder = nulls === "first" ? -1 : 1;
|
|
2037
|
+
if (left === null)
|
|
2038
|
+
return nullOrder;
|
|
2039
|
+
if (right === null)
|
|
2040
|
+
return -nullOrder;
|
|
2041
|
+
const comparison = isTableNumber(left) && isTableNumber(right) ? left - right : compareTableText(String(left), String(right), locale);
|
|
2042
|
+
return direction === "asc" ? comparison : -comparison;
|
|
2043
|
+
};
|
|
2044
|
+
var sortTableRows = (rows, columns, sort, locale) => {
|
|
2045
|
+
const byId = new Map(columns.map((column) => [column.id, column]));
|
|
2046
|
+
return rows.slice().sort((leftRow, rightRow) => {
|
|
2047
|
+
for (const { id, direction } of sort) {
|
|
2048
|
+
const column = byId.get(id);
|
|
2049
|
+
if (!column || column.sortable === false)
|
|
2050
|
+
continue;
|
|
2051
|
+
const left = columnValue(column, leftRow.cells[id]);
|
|
2052
|
+
const right = columnValue(column, rightRow.cells[id]);
|
|
2053
|
+
const comparison = compareTableSortValues(left, right, direction, column.nulls, locale);
|
|
2054
|
+
if (comparison !== 0)
|
|
2055
|
+
return comparison;
|
|
2056
|
+
}
|
|
2057
|
+
return 0;
|
|
2058
|
+
});
|
|
2059
|
+
};
|
|
2060
|
+
var filterTableRows = (rows, columns, search, locale) => {
|
|
2061
|
+
const query = search.trim().toLocaleLowerCase(locale);
|
|
2062
|
+
if (!query)
|
|
2063
|
+
return rows;
|
|
2064
|
+
const searchable = columns.filter(({ searchable }) => searchable !== false);
|
|
2065
|
+
return rows.filter((row) => searchable.some((column) => {
|
|
2066
|
+
const value = row.cells[column.id];
|
|
2067
|
+
if (column.type === "date" || column.type === "dateTime") {
|
|
2068
|
+
const date = resolveDate(value, column.type);
|
|
2069
|
+
return !!date && `${formatDateValue(date, column, locale)} ${dateIsoValue(date)}`.toLocaleLowerCase(locale).includes(query);
|
|
2070
|
+
}
|
|
2071
|
+
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) ?? "");
|
|
2072
|
+
return text.toLocaleLowerCase(locale).includes(query);
|
|
2073
|
+
}));
|
|
2074
|
+
};
|
|
2075
|
+
var updateSelectedRows = (selected, targets, checked) => {
|
|
2076
|
+
const next = new Set(selected);
|
|
2077
|
+
for (const id of targets) {
|
|
2078
|
+
if (checked)
|
|
2079
|
+
next.add(id);
|
|
2080
|
+
else
|
|
2081
|
+
next.delete(id);
|
|
2082
|
+
}
|
|
2083
|
+
return Array.from(next);
|
|
2084
|
+
};
|
|
2085
|
+
var resolveTablePage = (rowCount, query) => {
|
|
2086
|
+
const pageSize = Math.max(1, query.pageSize);
|
|
2087
|
+
const pageCount = Math.max(1, Math.ceil(rowCount / pageSize));
|
|
2088
|
+
const page = Math.min(pageCount - 1, Math.max(0, query.page));
|
|
2089
|
+
const start = page * pageSize;
|
|
2090
|
+
return { page, pageCount, start, end: start + pageSize };
|
|
2091
|
+
};
|
|
2092
|
+
var edit = UiSchema2.TaggedEnum({
|
|
2093
|
+
SetBoolean: { value: Schema5.Boolean },
|
|
2094
|
+
AddItem: { itemId: Schema5.String },
|
|
2095
|
+
RemoveItem: { itemId: Schema5.String }
|
|
2096
|
+
}).annotate({ identifier: "DataTableEdit" });
|
|
2097
|
+
var eventFields = {
|
|
2098
|
+
RowActivated: { rowId: Schema5.String },
|
|
2099
|
+
ItemActionRequested: {
|
|
2100
|
+
rowId: Schema5.String,
|
|
2101
|
+
columnId: Schema5.String,
|
|
2102
|
+
itemId: Schema5.String,
|
|
2103
|
+
actionId: Schema5.String
|
|
2104
|
+
},
|
|
2105
|
+
RefreshRequested: {},
|
|
2106
|
+
ExportRequested: { actionId: Schema5.String },
|
|
2107
|
+
GroupActionRequested: {
|
|
2108
|
+
fieldId: Schema5.String,
|
|
2109
|
+
groupId: Schema5.String,
|
|
2110
|
+
actionId: Schema5.String
|
|
2111
|
+
},
|
|
2112
|
+
GroupMoveRequested: {
|
|
2113
|
+
rowId: Schema5.String,
|
|
2114
|
+
fieldId: Schema5.String,
|
|
2115
|
+
groupId: Schema5.String
|
|
2116
|
+
},
|
|
2117
|
+
RowsReordered: { rowIds: Schema5.Array(Schema5.String) },
|
|
2118
|
+
StateChanged: { state: DataTableQuerySchema },
|
|
2119
|
+
SortChanged: { sort: Schema5.Array(DataTableSortSchema) },
|
|
2120
|
+
SelectionChanged: { selectedRowIds: Schema5.Array(Schema5.String) },
|
|
2121
|
+
CellEditRequested: { rowId: Schema5.String, columnId: Schema5.String, edit },
|
|
2122
|
+
RowActionRequested: { rowId: Schema5.String, actionId: Schema5.String },
|
|
2123
|
+
BulkActionRequested: {
|
|
2124
|
+
rowIds: Schema5.Array(Schema5.String),
|
|
2125
|
+
actionId: Schema5.String
|
|
2126
|
+
}
|
|
2127
|
+
};
|
|
2128
|
+
var DataTableEvents = UiSchema2.TaggedEnum(eventFields).annotate({
|
|
2129
|
+
identifier: "DataTableEvents"
|
|
2130
|
+
});
|
|
2131
|
+
var DataTableMessage = UiSchema2.TaggedEnum({
|
|
2132
|
+
ReferenceImageFailed: { src: Schema5.String },
|
|
2133
|
+
RowActivated: eventFields.RowActivated,
|
|
2134
|
+
PreferencesLoaded: { preferences: Schema5.NullOr(DataTablePreferencesSchema) },
|
|
2135
|
+
ItemActionRequested: eventFields.ItemActionRequested,
|
|
2136
|
+
BuiltInExportRequested: {
|
|
2137
|
+
format: Schema5.Literals(["csv", "json"]),
|
|
2138
|
+
locale: Schema5.optionalKey(Schema5.String)
|
|
2139
|
+
},
|
|
2140
|
+
ExportStarted: {},
|
|
2141
|
+
ExportFinished: { failed: Schema5.Boolean },
|
|
2142
|
+
RefreshRequested: {},
|
|
2143
|
+
ExportRequested: eventFields.ExportRequested,
|
|
2144
|
+
GroupActionRequested: eventFields.GroupActionRequested,
|
|
2145
|
+
GroupMoveRequested: eventFields.GroupMoveRequested,
|
|
2146
|
+
ReorderRequested: {
|
|
2147
|
+
rowId: Schema5.String,
|
|
2148
|
+
targetId: Schema5.String,
|
|
2149
|
+
after: Schema5.Boolean
|
|
2150
|
+
},
|
|
2151
|
+
DragStarted: { rowId: Schema5.String },
|
|
2152
|
+
DragEnded: {},
|
|
2153
|
+
DragDropped: { targetId: Schema5.String },
|
|
2154
|
+
GroupDropped: { fieldId: Schema5.String, groupId: Schema5.String },
|
|
2155
|
+
ViewPicked: { view: DataTableViewSchema },
|
|
2156
|
+
GroupingToggled: { fieldId: Schema5.String },
|
|
2157
|
+
GroupToggled: { key: Schema5.String },
|
|
2158
|
+
ColumnResized: { id: Schema5.String, delta: Schema5.Finite },
|
|
2159
|
+
ColumnResizeReset: { id: Schema5.String },
|
|
2160
|
+
ResizeStarted: { id: Schema5.String, x: Schema5.Finite, pointerId: Schema5.Int },
|
|
2161
|
+
ResizeMoved: { x: Schema5.Finite, pointerId: Schema5.Int },
|
|
2162
|
+
ResizeEnded: { pointerId: Schema5.Int },
|
|
2163
|
+
ColumnFiltersCleared: { id: Schema5.String },
|
|
2164
|
+
ColumnSortCleared: { id: Schema5.String },
|
|
2165
|
+
CellEditRequested: eventFields.CellEditRequested,
|
|
2166
|
+
RowActionRequested: eventFields.RowActionRequested,
|
|
2167
|
+
MenuOpened: { key: Schema5.String },
|
|
2168
|
+
MenuClosed: { key: Schema5.String },
|
|
2169
|
+
MenuQueryChanged: { key: Schema5.String, query: Schema5.String },
|
|
2170
|
+
SubmenuOpened: {
|
|
2171
|
+
key: Schema5.String,
|
|
2172
|
+
filterColumnId: Schema5.optionalKey(Schema5.String)
|
|
2173
|
+
},
|
|
2174
|
+
SubmenuClosed: { key: Schema5.String },
|
|
2175
|
+
SearchChanged: { value: Schema5.String },
|
|
2176
|
+
FilterInputChanged: {
|
|
2177
|
+
field: Schema5.Literals(["primary", "secondary"]),
|
|
2178
|
+
value: Schema5.String
|
|
2179
|
+
},
|
|
2180
|
+
FilterOperatorChanged: { operator: TextFilterOperator },
|
|
2181
|
+
FilterValueToggled: { value: Schema5.String, checked: Schema5.Boolean },
|
|
2182
|
+
FilterApplied: {},
|
|
2183
|
+
ColumnFilterChanged: {
|
|
2184
|
+
id: Schema5.String,
|
|
2185
|
+
filter: Schema5.NullOr(ColumnFilter)
|
|
2186
|
+
},
|
|
2187
|
+
FilterCleared: {},
|
|
2188
|
+
FiltersCleared: {},
|
|
2189
|
+
PageRequested: { page: Schema5.Int },
|
|
2190
|
+
ServerPageInvalidated: {},
|
|
2191
|
+
PageSizeRequested: { pageSize: Schema5.Int },
|
|
2192
|
+
SortRequested: {
|
|
2193
|
+
columnId: Schema5.String,
|
|
2194
|
+
direction: Schema5.NullOr(DataTableSortSchema.fields.direction)
|
|
2195
|
+
},
|
|
2196
|
+
ColumnVisibilityChanged: { id: Schema5.String, visible: Schema5.Boolean },
|
|
2197
|
+
SelectionRequested: {
|
|
2198
|
+
rowIds: Schema5.Array(Schema5.String),
|
|
2199
|
+
checked: Schema5.Boolean
|
|
2200
|
+
},
|
|
2201
|
+
BulkActionRequested: { actionId: Schema5.String }
|
|
2202
|
+
}).annotate({ identifier: "DataTableMessage" });
|
|
2203
|
+
var dataTableOptions = {
|
|
2204
|
+
name: "DataTable",
|
|
2205
|
+
props: DataTablePropsSchema,
|
|
2206
|
+
model: Schema5.Struct({
|
|
2207
|
+
menu: Schema5.NullOr(Schema5.String),
|
|
2208
|
+
submenu: Schema5.NullOr(Schema5.String),
|
|
2209
|
+
menuQuery: Schema5.String,
|
|
2210
|
+
failedImages: Schema5.Array(Schema5.String),
|
|
2211
|
+
selectedRowIds: Schema5.Array(Schema5.String),
|
|
2212
|
+
query: DataTableQuerySchema,
|
|
2213
|
+
preferencesLoaded: Schema5.Boolean,
|
|
2214
|
+
columnVisibility: Schema5.Record(Schema5.String, Schema5.Boolean),
|
|
2215
|
+
columnSizing: Schema5.Record(Schema5.String, Schema5.Finite),
|
|
2216
|
+
view: DataTableViewSchema,
|
|
2217
|
+
grouping: Schema5.Array(Schema5.String),
|
|
2218
|
+
collapsedGroups: Schema5.Record(Schema5.String, Schema5.Boolean),
|
|
2219
|
+
dragging: Schema5.NullOr(Schema5.String),
|
|
2220
|
+
exporting: Schema5.Boolean,
|
|
2221
|
+
exportFailed: Schema5.Boolean,
|
|
2222
|
+
resizing: Schema5.NullOr(Schema5.Struct({
|
|
2223
|
+
id: Schema5.String,
|
|
2224
|
+
x: Schema5.Finite,
|
|
2225
|
+
width: Schema5.Finite,
|
|
2226
|
+
pointerId: Schema5.Int
|
|
2227
|
+
}).annotate({ identifier: "DataTableResizeSession" })),
|
|
2228
|
+
filterDraft: Schema5.NullOr(DataTableFilterDraftSchema),
|
|
2229
|
+
invalidFilter: Schema5.Boolean
|
|
2230
|
+
}).annotate({ identifier: "DataTableModel" }),
|
|
2231
|
+
message: DataTableMessage,
|
|
2232
|
+
events: DataTableEvents,
|
|
2233
|
+
restore: false
|
|
2234
|
+
};
|
|
2235
|
+
var available = (props) => props.status?.error === undefined && (!props.status?.loading || props.rowData.length > 0);
|
|
2236
|
+
var tableQuery = (props, model) => props.state ?? { ...model.query, sort: props.sort ?? model.query.sort };
|
|
2237
|
+
var tableFeatures = (props) => ({
|
|
2238
|
+
...props.features,
|
|
2239
|
+
search: props.features?.search ?? props.search ?? true,
|
|
2240
|
+
filtering: props.features?.filtering ?? props.columnFilters ?? true,
|
|
2241
|
+
sorting: props.features?.sorting ?? true,
|
|
2242
|
+
columnVisibility: props.features?.columnVisibility ?? true,
|
|
2243
|
+
pagination: props.features?.pagination ?? props.pagination
|
|
2244
|
+
});
|
|
2245
|
+
var tableSelectedRowIds = (props, model) => {
|
|
2246
|
+
const supplied = new Set(props.rowData.map(({ id }) => id));
|
|
2247
|
+
return [
|
|
2248
|
+
...new Set(props.selection?.selectedRowIds ?? model.selectedRowIds)
|
|
2249
|
+
].filter((id) => supplied.has(id));
|
|
2250
|
+
};
|
|
2251
|
+
var serverPageCorrection = (props, model) => {
|
|
2252
|
+
const pagination = tableFeatures(props).pagination;
|
|
2253
|
+
if (!pagination || pagination.mode !== "server")
|
|
2254
|
+
return;
|
|
2255
|
+
const query = tableQuery(props, model);
|
|
2256
|
+
const { page } = resolveTablePage(pagination.rowCount, query);
|
|
2257
|
+
if (query.page !== page)
|
|
2258
|
+
return { requested: query.page, page, size: query.pageSize };
|
|
2259
|
+
};
|
|
2260
|
+
var tablePreferencesKey = (pathname, columns, gallery) => `data-table:${pathname}:${columns.join(",")}:${gallery ? "gallery" : "table"}:ui`;
|
|
2261
|
+
var preferencesJson = Schema5.fromJsonString(DataTablePreferencesSchema);
|
|
2262
|
+
var decodePreferences = Schema5.decodeUnknownOption(preferencesJson);
|
|
2263
|
+
var encodePreferences = Schema5.encodeSync(preferencesJson);
|
|
2264
|
+
var readTablePreferences = (key, host = globalThis.window) => {
|
|
2265
|
+
try {
|
|
2266
|
+
return Option3.getOrNull(decodePreferences(host?.localStorage.getItem(key)));
|
|
2267
|
+
} catch {
|
|
2268
|
+
return null;
|
|
2269
|
+
}
|
|
2270
|
+
};
|
|
2271
|
+
var writeTablePreferences = (key, preferences, host = globalThis.window) => {
|
|
2272
|
+
try {
|
|
2273
|
+
host?.localStorage.setItem(key, encodePreferences(preferences));
|
|
2274
|
+
} catch {}
|
|
2275
|
+
};
|
|
2276
|
+
var tablePreferences = (model) => model.preferencesLoaded ? {
|
|
2277
|
+
columnVisibility: model.columnVisibility,
|
|
2278
|
+
columnSizing: model.columnSizing,
|
|
2279
|
+
grouping: model.grouping,
|
|
2280
|
+
view: model.view
|
|
2281
|
+
} : null;
|
|
2282
|
+
var tableColumnLimits = (column) => {
|
|
2283
|
+
const min = column.minWidth ?? 96;
|
|
2284
|
+
return { min, max: Math.max(min, column.maxWidth ?? 640) };
|
|
2285
|
+
};
|
|
2286
|
+
var clampTableWidth = (column, width = column.width ?? 208) => {
|
|
2287
|
+
const { min, max } = tableColumnLimits(column);
|
|
2288
|
+
return Math.min(max, Math.max(min, width));
|
|
2289
|
+
};
|
|
2290
|
+
var tableColumnWidth = (column, sizing) => clampTableWidth(column, sizing[column.id]);
|
|
2291
|
+
var tableLayoutWidth = (widths, utilityColumns) => widths.reduce((total, width) => total + width, utilityColumns * 40);
|
|
2292
|
+
var tableResizeStep = (key) => key === "ArrowLeft" ? -8 : key === "ArrowRight" ? 8 : 0;
|
|
2293
|
+
var activeTableGroups = (grouping, fields) => grouping.flatMap((id) => fields.find((field) => field.id === id) ?? []);
|
|
2294
|
+
var tableGrouping = (props, model) => activeTableGroups(model.grouping, props.features?.grouping?.fields ?? []);
|
|
2295
|
+
var canReorderTableRows = (props, model) => !!props.features?.reordering && !tableGrouping(props, model).length && !tableQuery(props, model).sort?.length;
|
|
2296
|
+
var partitionTableGroups = (rows, known, memberships) => {
|
|
2297
|
+
const groups = new Map(known.map((id) => [id, []]));
|
|
2298
|
+
for (const row of rows) {
|
|
2299
|
+
for (const id of new Set(memberships(row))) {
|
|
2300
|
+
const group = groups.get(id);
|
|
2301
|
+
if (group)
|
|
2302
|
+
group.push(row);
|
|
2303
|
+
else
|
|
2304
|
+
groups.set(id, [row]);
|
|
2305
|
+
}
|
|
2306
|
+
}
|
|
2307
|
+
return groups;
|
|
2308
|
+
};
|
|
2309
|
+
var tableGroupKey = (parent, fieldId, groupId) => `${parent ? `${parent}/` : ""}${encodeURIComponent(fieldId)}:${encodeURIComponent(groupId)}`;
|
|
2310
|
+
var reorderRows = ($, rowId, targetId, after) => {
|
|
2311
|
+
const rowIds = $.props.rowData.map(({ id }) => id);
|
|
2312
|
+
const next = $.evolve({ dragging: null });
|
|
2313
|
+
if (!available($.props) || !canReorderTableRows($.props, $.model) || rowId === targetId || !rowIds.includes(rowId) || !rowIds.includes(targetId))
|
|
2314
|
+
return next;
|
|
2315
|
+
const reordered = rowIds.filter((id) => id !== rowId);
|
|
2316
|
+
reordered.splice(reordered.indexOf(targetId) + Number(after), 0, rowId);
|
|
2317
|
+
return next.emit(DataTableEvents.RowsReordered({ rowIds: reordered }));
|
|
2318
|
+
};
|
|
2319
|
+
var moveGroup = ($, rowId, fieldId, groupId) => {
|
|
2320
|
+
const field = tableGrouping($.props, $.model).find(({ id }) => id === fieldId);
|
|
2321
|
+
const row = $.props.rowData.find(({ id }) => id === rowId);
|
|
2322
|
+
const next = $.evolve({ dragging: null });
|
|
2323
|
+
if (!available($.props) || !field?.movable || !row || row.groups?.[fieldId]?.includes(groupId))
|
|
2324
|
+
return next;
|
|
2325
|
+
if (!field.groups?.some(({ id }) => id === groupId) && !$.props.rowData.some((row) => row.groups?.[fieldId]?.includes(groupId)))
|
|
2326
|
+
return next;
|
|
2327
|
+
return next.emit(DataTableEvents.GroupMoveRequested({ rowId, fieldId, groupId }));
|
|
2328
|
+
};
|
|
2329
|
+
var changeQuery = ($, patch, ui = {}, legacy) => {
|
|
2330
|
+
const current = tableQuery($.props, $.model);
|
|
2331
|
+
const state = { ...current, ...patch };
|
|
2332
|
+
if (state.page === current.page && state.pageSize === current.pageSize && state.globalFilter === current.globalFilter && state.filters === current.filters && state.sort === current.sort)
|
|
2333
|
+
return $.evolve(ui);
|
|
2334
|
+
const step = $.evolve({
|
|
2335
|
+
...ui,
|
|
2336
|
+
query: $.props.state ? $.model.query : { ...state, sort: $.props.sort ? $.model.query.sort : state.sort }
|
|
2337
|
+
}).emit(DataTableEvents.StateChanged({ state }));
|
|
2338
|
+
return legacy ? step.emit(legacy) : step;
|
|
2339
|
+
};
|
|
2340
|
+
var tableFilterDraft = (id, current) => ({
|
|
2341
|
+
id,
|
|
2342
|
+
primary: current?.kind === "text" || current?.kind === "boolean" ? String(current.value) : current?.kind === "number" ? String(current.min ?? "") : current?.kind === "date" ? current.from ?? "" : "",
|
|
2343
|
+
secondary: current?.kind === "number" ? String(current.max ?? "") : current?.kind === "date" ? current.to ?? "" : "",
|
|
2344
|
+
operator: current?.kind === "text" ? current.operator : "contains",
|
|
2345
|
+
values: current?.kind === "values" ? current.values : []
|
|
2346
|
+
});
|
|
2347
|
+
var decodeFilter = Schema5.decodeUnknownOption(ColumnFilter);
|
|
2348
|
+
var decodeBound = Schema5.decodeOption(Schema5.FiniteFromString);
|
|
2349
|
+
var parseTableFilterDraft = (kind, {
|
|
2350
|
+
id,
|
|
2351
|
+
primary,
|
|
2352
|
+
secondary,
|
|
2353
|
+
operator,
|
|
2354
|
+
values
|
|
2355
|
+
}) => {
|
|
2356
|
+
switch (kind) {
|
|
2357
|
+
case "number": {
|
|
2358
|
+
const min = primary.trim() ? decodeBound(primary) : Option3.some(undefined);
|
|
2359
|
+
const max = secondary.trim() ? decodeBound(secondary) : Option3.some(undefined);
|
|
2360
|
+
return Option3.isNone(min) || Option3.isNone(max) ? Option3.none() : decodeFilter({ id, kind, min: min.value, max: max.value });
|
|
2361
|
+
}
|
|
2362
|
+
case "boolean":
|
|
2363
|
+
return decodeFilter({
|
|
2364
|
+
id,
|
|
2365
|
+
kind,
|
|
2366
|
+
value: primary === "true" ? true : primary === "false" ? false : undefined
|
|
2367
|
+
});
|
|
2368
|
+
case "values":
|
|
2369
|
+
return decodeFilter({ id, kind, values });
|
|
2370
|
+
case "date":
|
|
2371
|
+
return decodeFilter({
|
|
2372
|
+
id,
|
|
2373
|
+
kind,
|
|
2374
|
+
from: primary || undefined,
|
|
2375
|
+
to: secondary || undefined
|
|
2376
|
+
});
|
|
2377
|
+
case "text":
|
|
2378
|
+
return decodeFilter({ id, kind, operator, value: primary.trim() });
|
|
2379
|
+
}
|
|
2380
|
+
};
|
|
2381
|
+
var changeColumnFilter = ($, id, filter, ui) => {
|
|
2382
|
+
const filters = (tableQuery($.props, $.model).filters ?? []).filter((current) => current.id !== id);
|
|
2383
|
+
if (filter)
|
|
2384
|
+
filters.push(filter);
|
|
2385
|
+
return changeQuery($, { filters: filters.length ? filters : undefined, page: 0 }, ui);
|
|
2386
|
+
};
|
|
2387
|
+
var projectDataTableRows = (source, query, {
|
|
2388
|
+
pagination,
|
|
2389
|
+
grouped,
|
|
2390
|
+
sortMode,
|
|
2391
|
+
search,
|
|
2392
|
+
filter,
|
|
2393
|
+
sort
|
|
2394
|
+
}) => {
|
|
2395
|
+
const server = pagination && pagination.mode === "server";
|
|
2396
|
+
const filtered = server ? source : filter(search(source, query.globalFilter ?? ""), query.filters ?? []);
|
|
2397
|
+
const ordered = !server && sortMode !== "server" && query.sort?.length ? sort(filtered, query.sort) : filtered;
|
|
2398
|
+
const { pageSize } = query;
|
|
2399
|
+
const totalRows = server ? pagination.rowCount : ordered.length;
|
|
2400
|
+
const { page, pageCount, start, end } = resolveTablePage(totalRows, query);
|
|
2401
|
+
const paginationVisible = !!pagination && (server || !grouped);
|
|
2402
|
+
const rows = paginationVisible && !server ? ordered.slice(start, end) : ordered;
|
|
2403
|
+
return {
|
|
2404
|
+
rows,
|
|
2405
|
+
filtered,
|
|
2406
|
+
ordered,
|
|
2407
|
+
pageSize,
|
|
2408
|
+
totalRows,
|
|
2409
|
+
pageCount,
|
|
2410
|
+
page,
|
|
2411
|
+
paginationVisible
|
|
2412
|
+
};
|
|
2413
|
+
};
|
|
2414
|
+
var dataTablePage = (props, model, locale) => {
|
|
2415
|
+
const pagination = tableFeatures(props).pagination;
|
|
2416
|
+
const columns = tableDataColumns(props.columnDefs);
|
|
2417
|
+
return {
|
|
2418
|
+
...projectDataTableRows(props.rowData, tableQuery(props, model), {
|
|
2419
|
+
pagination,
|
|
2420
|
+
grouped: tableGrouping(props, model).length > 0,
|
|
2421
|
+
sortMode: props.sortMode,
|
|
2422
|
+
search: (rows, value) => filterTableRows(rows, columns, value, locale),
|
|
2423
|
+
filter: (rows, filters) => filterTableColumns(rows, columns, filters),
|
|
2424
|
+
sort: (rows, sorting) => sortTableRows(rows, columns, sorting, locale)
|
|
2425
|
+
}),
|
|
2426
|
+
pageSizes: pagination && pagination.pageSizes || defaultPageSizes
|
|
2427
|
+
};
|
|
2428
|
+
};
|
|
2429
|
+
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: `
|
|
2430
|
+
` })), Stream.runCollect, Effect3.map((parts) => parts.join("").slice(0, -1))));
|
|
2431
|
+
var tableExportFilename = (name, extension) => name.includes(".") ? name.replace(/\.[^/.]+$/, `.${extension}`) : `${name}.${extension}`;
|
|
2432
|
+
var downloadTableBlob = (content, type, filename) => {
|
|
2433
|
+
const url = window.URL.createObjectURL(new Blob([content], { type }));
|
|
2434
|
+
const link = document.createElement("a");
|
|
2435
|
+
link.href = url;
|
|
2436
|
+
link.download = filename;
|
|
2437
|
+
document.body.appendChild(link);
|
|
2438
|
+
try {
|
|
2439
|
+
link.click();
|
|
2440
|
+
} finally {
|
|
2441
|
+
link.remove();
|
|
2442
|
+
requestAnimationFrame(() => window.URL.revokeObjectURL(url));
|
|
2443
|
+
}
|
|
2444
|
+
};
|
|
2445
|
+
var tableExportValue = (column, row, locale) => {
|
|
2446
|
+
const value = row.cells[column.id];
|
|
2447
|
+
switch (column.type) {
|
|
2448
|
+
case "date":
|
|
2449
|
+
case "dateTime": {
|
|
2450
|
+
const date = resolveDate(value, column.type);
|
|
2451
|
+
return !date ? null : column.typeOptions?.exportFormat === "formatted" ? formatDateValue(date, column, locale) : dateIsoValue(date);
|
|
2452
|
+
}
|
|
2453
|
+
case "reference":
|
|
2454
|
+
return isTableReference(value) ? [value.label, value.description].filter(Boolean).join(" — ") : "";
|
|
2455
|
+
case "list":
|
|
2456
|
+
return isTableList(value) ? value.map(({ label }) => label).join(", ") : "";
|
|
2457
|
+
case "boolean":
|
|
2458
|
+
return !isTableBoolean(value) ? null : column.typeOptions?.exportFormat === "formatted" ? tableBooleanLabel(value, column.typeOptions) : value;
|
|
2459
|
+
case "number":
|
|
2460
|
+
return !isTableNumber(value) ? null : column.typeOptions?.exportFormat === "formatted" ? formatNumberValue(value, column.typeOptions, locale) : value;
|
|
2461
|
+
default:
|
|
2462
|
+
return columnValue(column, value);
|
|
2463
|
+
}
|
|
2464
|
+
};
|
|
2465
|
+
var DownloadTable = Command.make("DataTable/Download", {
|
|
2466
|
+
args: {
|
|
2467
|
+
filename: Schema5.String,
|
|
2468
|
+
content: Schema5.Redacted(Schema5.String, { disallowJsonEncode: true }),
|
|
2469
|
+
type: Schema5.String
|
|
2470
|
+
}
|
|
2471
|
+
}, ({ filename, content, type }) => Effect3.try(() => downloadTableBlob(Redacted.value(content), type, filename)).pipe(Effect3.match({
|
|
2472
|
+
onSuccess: () => DataTableMessage.ExportFinished({ failed: false }),
|
|
2473
|
+
onFailure: () => DataTableMessage.ExportFinished({ failed: true })
|
|
2474
|
+
})));
|
|
2475
|
+
var update2 = Component2.define(dataTableOptions).update({
|
|
2476
|
+
ReferenceImageFailed: ($, { src }) => $.model.failedImages.includes(src) ? $.model : $.evolve({ failedImages: [...$.model.failedImages, src] }),
|
|
2477
|
+
RowActivated: ($, { rowId }) => $.props.rowActivation && available($.props) && $.props.rowData.some(({ id }) => id === rowId) ? $.emit(DataTableEvents.RowActivated({ rowId })) : $.model,
|
|
2478
|
+
PreferencesLoaded: ($, { preferences }) => $.model.preferencesLoaded ? $.model : $.evolve({
|
|
2479
|
+
preferencesLoaded: true,
|
|
2480
|
+
columnVisibility: {
|
|
2481
|
+
...$.model.columnVisibility,
|
|
2482
|
+
...preferences?.columnVisibility
|
|
2483
|
+
},
|
|
2484
|
+
columnSizing: preferences?.columnSizing ?? $.model.columnSizing,
|
|
2485
|
+
grouping: preferences?.grouping ?? $.model.grouping,
|
|
2486
|
+
view: $.props.features?.gallery ? preferences?.view ?? $.model.view : "table"
|
|
2487
|
+
}),
|
|
2488
|
+
ItemActionRequested: ($, request) => {
|
|
2489
|
+
const row = $.props.rowData.find(({ id }) => id === request.rowId);
|
|
2490
|
+
const column = $.props.columnDefs.find(({ id }) => id === request.columnId);
|
|
2491
|
+
const items = row?.cells[request.columnId];
|
|
2492
|
+
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;
|
|
2493
|
+
},
|
|
2494
|
+
ExportStarted: ($) => $.evolve({ exporting: true, exportFailed: false }),
|
|
2495
|
+
ExportFinished: ($, { failed }) => $.evolve({ exporting: false, exportFailed: failed }),
|
|
2496
|
+
BuiltInExportRequested: ($, { format, locale = $.props.locale ?? "en" }) => {
|
|
2497
|
+
const feature = $.props.features?.export;
|
|
2498
|
+
if (!feature || feature.pending || $.model.exporting || feature.builtIn === false || !available($.props))
|
|
2499
|
+
return $.model;
|
|
2500
|
+
const projection = dataTablePage($.props, $.model, locale);
|
|
2501
|
+
const rows = feature.scope === "currentPage" ? projection.rows : projection.ordered;
|
|
2502
|
+
if (!rows.length)
|
|
2503
|
+
return $.model;
|
|
2504
|
+
const columns = tableDataColumns($.props.columnDefs.filter(({ id, export: enabled }) => enabled !== false && $.model.columnVisibility[id] !== false)).filter(({ export: enabled }) => enabled !== false);
|
|
2505
|
+
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) => [
|
|
2506
|
+
column.id,
|
|
2507
|
+
tableExportValue(column, row, locale)
|
|
2508
|
+
]))), null, 2);
|
|
2509
|
+
return $.evolve({ menu: null, exporting: true, exportFailed: false }).run(DownloadTable.make({
|
|
2510
|
+
content: Redacted.make(content),
|
|
2511
|
+
filename: tableExportFilename(feature.baseName, format),
|
|
2512
|
+
type: format === "csv" ? "text/csv;charset=utf-8" : "application/json;charset=utf-8"
|
|
2513
|
+
}));
|
|
2514
|
+
},
|
|
2515
|
+
RefreshRequested: ($) => $.props.features?.refresh ? $.emit(DataTableEvents.RefreshRequested()) : $.model,
|
|
2516
|
+
ExportRequested: ($, { actionId }) => !$.props.features?.export?.pending && $.props.features?.export?.actions?.some(({ id, disabled }) => id === actionId && !disabled) ? $.emit(DataTableEvents.ExportRequested({ actionId })) : $.model,
|
|
2517
|
+
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,
|
|
2518
|
+
GroupMoveRequested: ($, { rowId, fieldId, groupId }) => moveGroup($, rowId, fieldId, groupId),
|
|
2519
|
+
ReorderRequested: ($, { rowId, targetId, after }) => reorderRows($, rowId, targetId, after),
|
|
2520
|
+
DragStarted: ($, { rowId }) => $.evolve({ dragging: rowId }),
|
|
2521
|
+
DragEnded: ($) => $.evolve({ dragging: null }),
|
|
2522
|
+
DragDropped: ($, { targetId }) => $.model.dragging === null ? $.model : reorderRows($, $.model.dragging, targetId, $.props.rowData.findIndex(({ id }) => id === $.model.dragging) < $.props.rowData.findIndex(({ id }) => id === targetId)),
|
|
2523
|
+
GroupDropped: ($, { fieldId, groupId }) => $.model.dragging === null ? $.model : moveGroup($, $.model.dragging, fieldId, groupId),
|
|
2524
|
+
ViewPicked: ($, { view }) => view === "table" || $.props.features?.gallery ? $.evolve({ view, menu: null }) : $.model,
|
|
2525
|
+
GroupingToggled: ($, { fieldId }) => $.props.features?.grouping?.fields.some(({ id }) => id === fieldId) ? $.evolve({
|
|
2526
|
+
grouping: updateSelectedRows($.model.grouping, [fieldId], !$.model.grouping.includes(fieldId))
|
|
2527
|
+
}) : $.model,
|
|
2528
|
+
GroupToggled: ($, { key }) => $.evolve({
|
|
2529
|
+
collapsedGroups: {
|
|
2530
|
+
...$.model.collapsedGroups,
|
|
2531
|
+
[key]: !$.model.collapsedGroups[key]
|
|
2532
|
+
}
|
|
2533
|
+
}),
|
|
2534
|
+
ColumnResized: ($, { id, delta }) => {
|
|
2535
|
+
const column = $.props.columnDefs.find((column) => column.id === id);
|
|
2536
|
+
if (!column || column.resizable === false)
|
|
2537
|
+
return $.model;
|
|
2538
|
+
const sizing = {
|
|
2539
|
+
...$.model.columnSizing,
|
|
2540
|
+
[id]: tableColumnWidth(column, $.model.columnSizing) + delta
|
|
2541
|
+
};
|
|
2542
|
+
return $.evolve({
|
|
2543
|
+
columnSizing: { ...sizing, [id]: tableColumnWidth(column, sizing) }
|
|
2544
|
+
});
|
|
2545
|
+
},
|
|
2546
|
+
ColumnResizeReset: ($, { id }) => {
|
|
2547
|
+
const column = $.props.columnDefs.find((column) => column.id === id);
|
|
2548
|
+
if (!column || column.resizable === false)
|
|
2549
|
+
return $.model;
|
|
2550
|
+
return $.evolve({
|
|
2551
|
+
columnSizing: {
|
|
2552
|
+
...$.model.columnSizing,
|
|
2553
|
+
[id]: clampTableWidth(column)
|
|
2554
|
+
}
|
|
2555
|
+
});
|
|
2556
|
+
},
|
|
2557
|
+
ResizeStarted: ($, { id, x, pointerId }) => {
|
|
2558
|
+
const column = $.props.columnDefs.find((column) => column.id === id);
|
|
2559
|
+
return column && column.resizable !== false ? $.evolve({
|
|
2560
|
+
resizing: {
|
|
2561
|
+
id,
|
|
2562
|
+
x,
|
|
2563
|
+
pointerId,
|
|
2564
|
+
width: tableColumnWidth(column, $.model.columnSizing)
|
|
2565
|
+
}
|
|
2566
|
+
}) : $.model;
|
|
2567
|
+
},
|
|
2568
|
+
ResizeMoved: ($, { x, pointerId }) => {
|
|
2569
|
+
const resize = $.model.resizing;
|
|
2570
|
+
const column = resize && $.props.columnDefs.find(({ id }) => id === resize.id);
|
|
2571
|
+
if (!resize || resize.pointerId !== pointerId || !column || column.resizable === false)
|
|
2572
|
+
return $.model;
|
|
2573
|
+
return $.evolve({
|
|
2574
|
+
columnSizing: {
|
|
2575
|
+
...$.model.columnSizing,
|
|
2576
|
+
[resize.id]: tableColumnWidth(column, {
|
|
2577
|
+
[resize.id]: resize.width + x - resize.x
|
|
2578
|
+
})
|
|
2579
|
+
}
|
|
2580
|
+
});
|
|
2581
|
+
},
|
|
2582
|
+
ResizeEnded: ($, { pointerId }) => $.model.resizing?.pointerId === pointerId ? $.evolve({ resizing: null }) : $.model,
|
|
2583
|
+
ColumnFiltersCleared: ($, { id }) => {
|
|
2584
|
+
const column = $.props.columnDefs.find((column) => column.id === id);
|
|
2585
|
+
if (!column || !tableFeatures($.props).filtering)
|
|
2586
|
+
return $.model;
|
|
2587
|
+
const owned = new Set([
|
|
2588
|
+
id,
|
|
2589
|
+
...tableDataColumns([column]).map(({ id }) => id)
|
|
2590
|
+
]);
|
|
2591
|
+
const filters = tableQuery($.props, $.model).filters?.filter(({ id }) => !owned.has(id));
|
|
2592
|
+
return changeQuery($, { filters: filters?.length ? filters : undefined, page: 0 }, { filterDraft: null, invalidFilter: false });
|
|
2593
|
+
},
|
|
2594
|
+
ColumnSortCleared: ($, { id }) => {
|
|
2595
|
+
const column = $.props.columnDefs.find((column) => column.id === id);
|
|
2596
|
+
if (!column || !tableFeatures($.props).sorting)
|
|
2597
|
+
return $.model;
|
|
2598
|
+
const owned = new Set([
|
|
2599
|
+
id,
|
|
2600
|
+
...tableDataColumns([column]).map(({ id }) => id)
|
|
2601
|
+
]);
|
|
2602
|
+
const sort = (tableQuery($.props, $.model).sort ?? []).filter(({ id }) => !owned.has(id));
|
|
2603
|
+
return changeQuery($, { sort }, {}, DataTableEvents.SortChanged({ sort }));
|
|
2604
|
+
},
|
|
2605
|
+
MenuOpened: ($, { key }) => $.evolve({ menu: key, submenu: null, menuQuery: "" }),
|
|
2606
|
+
MenuQueryChanged: ($, { key, query }) => $.model.menu === key ? $.evolve({ menuQuery: query }) : $.model,
|
|
2607
|
+
MenuClosed: ($, { key }) => $.model.menu === key ? $.evolve({ menu: null, submenu: null }) : $.model,
|
|
2608
|
+
SubmenuOpened: ($, { key, filterColumnId }) => $.evolve({
|
|
2609
|
+
submenu: key,
|
|
2610
|
+
menuQuery: "",
|
|
2611
|
+
...filterColumnId === undefined ? {} : {
|
|
2612
|
+
filterDraft: tableFilterDraft(filterColumnId, tableQuery($.props, $.model).filters?.find(({ id }) => id === filterColumnId)),
|
|
2613
|
+
invalidFilter: false
|
|
2614
|
+
}
|
|
2615
|
+
}),
|
|
2616
|
+
SubmenuClosed: ($, { key }) => $.model.submenu === key ? $.evolve({ submenu: null }) : $.model,
|
|
2617
|
+
SearchChanged: ($, { value }) => tableFeatures($.props).search ? changeQuery($, { globalFilter: value || undefined, page: 0 }, { menu: null }) : $.model,
|
|
2618
|
+
FilterInputChanged: ($, { field, value }) => {
|
|
2619
|
+
const draft = $.model.filterDraft;
|
|
2620
|
+
return draft ? $.evolve({
|
|
2621
|
+
filterDraft: { ...draft, [field]: value },
|
|
2622
|
+
invalidFilter: false
|
|
2623
|
+
}) : $.model;
|
|
2624
|
+
},
|
|
2625
|
+
FilterOperatorChanged: ($, { operator }) => {
|
|
2626
|
+
const draft = $.model.filterDraft;
|
|
2627
|
+
return draft ? $.evolve({
|
|
2628
|
+
filterDraft: { ...draft, operator },
|
|
2629
|
+
invalidFilter: false
|
|
2630
|
+
}) : $.model;
|
|
2631
|
+
},
|
|
2632
|
+
FilterValueToggled: ($, { value, checked }) => {
|
|
2633
|
+
const draft = $.model.filterDraft;
|
|
2634
|
+
return draft ? $.evolve({
|
|
2635
|
+
filterDraft: {
|
|
2636
|
+
...draft,
|
|
2637
|
+
values: updateSelectedRows(draft.values, [value], checked)
|
|
2638
|
+
},
|
|
2639
|
+
invalidFilter: false
|
|
2640
|
+
}) : $.model;
|
|
2641
|
+
},
|
|
2642
|
+
FilterApplied: ($) => {
|
|
2643
|
+
const draft = $.model.filterDraft;
|
|
2644
|
+
if (!tableFeatures($.props).filtering || !draft)
|
|
2645
|
+
return $.model;
|
|
2646
|
+
const column = tableDataColumns($.props.columnDefs).find(({ id, filterable }) => id === draft.id && filterable !== false);
|
|
2647
|
+
if (!column)
|
|
2648
|
+
return $.model;
|
|
2649
|
+
const decoded = parseTableFilterDraft(tableFilterKind(column), draft);
|
|
2650
|
+
return Option3.isNone(decoded) ? $.evolve({ invalidFilter: true }) : changeColumnFilter($, draft.id, decoded.value, {
|
|
2651
|
+
invalidFilter: false
|
|
2652
|
+
});
|
|
2653
|
+
},
|
|
2654
|
+
FilterCleared: ($) => {
|
|
2655
|
+
const draft = $.model.filterDraft;
|
|
2656
|
+
if (!draft)
|
|
2657
|
+
return $.model;
|
|
2658
|
+
return changeColumnFilter($, draft.id, null, {
|
|
2659
|
+
filterDraft: tableFilterDraft(draft.id),
|
|
2660
|
+
invalidFilter: false
|
|
2661
|
+
});
|
|
2662
|
+
},
|
|
2663
|
+
ColumnFilterChanged: ($, { id, filter }) => {
|
|
2664
|
+
if (!tableFeatures($.props).filtering || !tableDataColumns($.props.columnDefs).some((column) => column.id === id && column.filterable !== false) || filter && filter.id !== id)
|
|
2665
|
+
return $.model;
|
|
2666
|
+
return changeColumnFilter($, id, filter);
|
|
2667
|
+
},
|
|
2668
|
+
FiltersCleared: ($) => changeQuery($, { filters: undefined, page: 0 }, {
|
|
2669
|
+
filterDraft: null,
|
|
2670
|
+
invalidFilter: false
|
|
2671
|
+
}),
|
|
2672
|
+
PageRequested: ($, { page }) => tableFeatures($.props).pagination && page >= 0 ? changeQuery($, { page }, { menu: null }) : $.model,
|
|
2673
|
+
ServerPageInvalidated: ($) => {
|
|
2674
|
+
const correction = serverPageCorrection($.props, $.model);
|
|
2675
|
+
return correction ? changeQuery($, { page: correction.page }) : $.model;
|
|
2676
|
+
},
|
|
2677
|
+
PageSizeRequested: ($, { pageSize }) => {
|
|
2678
|
+
const pagination = tableFeatures($.props).pagination;
|
|
2679
|
+
return pagination && (pagination.pageSizes ?? defaultPageSizes).includes(pageSize) ? changeQuery($, { pageSize, page: 0 }, { menu: null }) : $.model;
|
|
2680
|
+
},
|
|
2681
|
+
SortRequested: ($, { columnId, direction }) => {
|
|
2682
|
+
if (!tableFeatures($.props).sorting || !tableDataColumns($.props.columnDefs).some(({ id, sortable }) => id === columnId && sortable !== false))
|
|
2683
|
+
return $.model;
|
|
2684
|
+
const sort = direction === null ? (tableQuery($.props, $.model).sort ?? []).filter(({ id }) => id !== columnId) : [{ id: columnId, direction }];
|
|
2685
|
+
return changeQuery($, { sort: sort.length ? sort : undefined, page: 0 }, {}, DataTableEvents.SortChanged({ sort }));
|
|
2686
|
+
},
|
|
2687
|
+
ColumnVisibilityChanged: ($, { id, visible }) => tableFeatures($.props).columnVisibility && $.props.columnDefs.some((column) => column.id === id && column.hideable !== false) ? $.evolve({
|
|
2688
|
+
columnVisibility: { ...$.model.columnVisibility, [id]: visible }
|
|
2689
|
+
}) : $.model,
|
|
2690
|
+
SelectionRequested: ($, { rowIds, checked }) => {
|
|
2691
|
+
if (!available($.props) || !$.props.selection)
|
|
2692
|
+
return $.model;
|
|
2693
|
+
const requested = new Set(rowIds);
|
|
2694
|
+
const targets = $.props.rowData.filter((row) => row.selectable !== false && requested.has(row.id)).map(({ id }) => id);
|
|
2695
|
+
if (targets.length === 0)
|
|
2696
|
+
return $.model;
|
|
2697
|
+
const controlled = $.props.selection.selectedRowIds;
|
|
2698
|
+
const selectedRowIds = updateSelectedRows(controlled ?? $.model.selectedRowIds, targets, checked);
|
|
2699
|
+
return $.evolve(controlled ? {} : { selectedRowIds }).emit(DataTableEvents.SelectionChanged({ selectedRowIds }));
|
|
2700
|
+
},
|
|
2701
|
+
CellEditRequested: ($, { rowId, columnId, edit }) => {
|
|
2702
|
+
if (!available($.props))
|
|
2703
|
+
return $.model;
|
|
2704
|
+
const row = $.props.rowData.find(({ id }) => id === rowId);
|
|
2705
|
+
const column = $.props.columnDefs.find(({ id }) => id === columnId);
|
|
2706
|
+
if (!row || !column || row.disabledColumnIds?.includes(columnId))
|
|
2707
|
+
return $.model;
|
|
2708
|
+
const value = row.cells[columnId];
|
|
2709
|
+
if (edit._tag === "SetBoolean") {
|
|
2710
|
+
if (column.type !== "boolean" || !column.editable || !isTableBoolean(value) || edit.value === value)
|
|
2711
|
+
return $.model;
|
|
2712
|
+
} else {
|
|
2713
|
+
if (column.type !== "list")
|
|
2714
|
+
return $.model;
|
|
2715
|
+
const items = isTableList(value) ? value : [];
|
|
2716
|
+
const contains = items.some(({ value }) => value === edit.itemId);
|
|
2717
|
+
if (edit._tag === "AddItem") {
|
|
2718
|
+
if (contains || !column.options?.some(({ value }) => value === edit.itemId))
|
|
2719
|
+
return $.model;
|
|
2720
|
+
} else if (!contains || !column.allowRemove)
|
|
2721
|
+
return $.model;
|
|
2722
|
+
}
|
|
2723
|
+
return $.emit(DataTableEvents.CellEditRequested({ rowId, columnId, edit }));
|
|
2724
|
+
},
|
|
2725
|
+
RowActionRequested: ($, { rowId, actionId }) => {
|
|
2726
|
+
const row = $.props.rowData.find(({ id }) => id === rowId);
|
|
2727
|
+
if (!available($.props) || !row?.actions?.some(({ id, disabled }) => id === actionId && !disabled))
|
|
2728
|
+
return $.model;
|
|
2729
|
+
return $.emit(DataTableEvents.RowActionRequested({ rowId, actionId }));
|
|
2730
|
+
},
|
|
2731
|
+
BulkActionRequested: ($, { actionId }) => {
|
|
2732
|
+
const selection = $.props.selection;
|
|
2733
|
+
if (!available($.props) || !selection?.bulkActions?.some(({ id, disabled }) => id === actionId && !disabled))
|
|
2734
|
+
return $.model;
|
|
2735
|
+
const rowIds = tableSelectedRowIds($.props, $.model);
|
|
2736
|
+
return rowIds.length > 0 ? $.emit(DataTableEvents.BulkActionRequested({ actionId, rowIds })) : $.model;
|
|
2737
|
+
}
|
|
2738
|
+
});
|
|
2739
|
+
var dataTableBehaviours = {
|
|
2740
|
+
subscriptions: ({
|
|
2741
|
+
props,
|
|
2742
|
+
model
|
|
2743
|
+
}) => {
|
|
2744
|
+
const correction = serverPageCorrection(props, model);
|
|
2745
|
+
return correction ? [
|
|
2746
|
+
Subscription.make("reconcile-server-page", [correction.requested, correction.page, correction.size], () => Stream.make(DataTableMessage.ServerPageInvalidated()))
|
|
2747
|
+
] : [];
|
|
2748
|
+
},
|
|
2749
|
+
init: ({ props }) => ({
|
|
2750
|
+
menu: null,
|
|
2751
|
+
submenu: null,
|
|
2752
|
+
menuQuery: "",
|
|
2753
|
+
failedImages: [],
|
|
2754
|
+
selectedRowIds: [],
|
|
2755
|
+
query: {
|
|
2756
|
+
globalFilter: props.initialState?.globalFilter,
|
|
2757
|
+
filters: props.initialState?.filters,
|
|
2758
|
+
sort: props.initialState?.sort,
|
|
2759
|
+
page: props.initialState?.page ?? 0,
|
|
2760
|
+
pageSize: props.initialState?.pageSize ?? (props.pagination?.mode === undefined ? props.pagination?.pageSizes?.[0] : undefined) ?? DEFAULT_PAGE_SIZE
|
|
2761
|
+
},
|
|
2762
|
+
columnVisibility: props.initialState?.columnVisibility ?? {},
|
|
2763
|
+
preferencesLoaded: false,
|
|
2764
|
+
columnSizing: {},
|
|
2765
|
+
view: props.initialState?.view ?? "table",
|
|
2766
|
+
grouping: props.features?.grouping?.initial ?? [],
|
|
2767
|
+
collapsedGroups: {},
|
|
2768
|
+
dragging: null,
|
|
2769
|
+
exporting: false,
|
|
2770
|
+
exportFailed: false,
|
|
2771
|
+
resizing: null,
|
|
2772
|
+
filterDraft: null,
|
|
2773
|
+
invalidFilter: false
|
|
2774
|
+
}),
|
|
2775
|
+
update: update2
|
|
2776
|
+
};
|
|
2777
|
+
|
|
2778
|
+
// ../../src/components/data-table/react.tsx
|
|
1217
2779
|
import { jsx as jsx15, jsxs as jsxs9, Fragment } from "react/jsx-runtime";
|
|
1218
|
-
var DataTableStylesContext =
|
|
2780
|
+
var DataTableStylesContext = createContext2(undefined);
|
|
2781
|
+
var DataTableSlotClassesContext = createContext2(resolveTableClasses());
|
|
1219
2782
|
var styledTablePart = (Part, slot, style) => {
|
|
1220
2783
|
const StyledPart = (props) => {
|
|
1221
|
-
const styles =
|
|
2784
|
+
const styles = useContext2(DataTableStylesContext);
|
|
1222
2785
|
const className = cn(props.className, style(styles));
|
|
1223
2786
|
return /* @__PURE__ */ jsx15(Part, {
|
|
1224
2787
|
"data-table-slot": slot,
|
|
@@ -1254,27 +2817,21 @@ var DropdownMenuLabel2 = styledTablePart(DropdownMenuLabel, "row-menu-label", (s
|
|
|
1254
2817
|
var DropdownMenuSeparator2 = styledTablePart(DropdownMenuSeparator, "row-menu-separator", (s) => s?.menu?.separator);
|
|
1255
2818
|
var SelectContent2 = styledTablePart(SelectContent, "select-popup", (s) => s?.popup?.select);
|
|
1256
2819
|
var TooltipContent2 = styledTablePart(TooltipContent, "tooltip", (s) => s?.popup?.tooltip);
|
|
1257
|
-
var DataTablePersistedUiStateSchema = Schema2.Struct({
|
|
1258
|
-
columnVisibility: Schema2.Record(Schema2.String, Schema2.Boolean),
|
|
1259
|
-
columnSizing: Schema2.Record(Schema2.String, Schema2.Finite),
|
|
1260
|
-
grouping: Schema2.optionalKey(Schema2.Array(Schema2.String)),
|
|
1261
|
-
view: Schema2.Literals(["table", "gallery"])
|
|
1262
|
-
}).annotate({ identifier: "DataTablePersistedUiState" });
|
|
1263
|
-
var dataTableStorageRuntime = Atom.runtime(BrowserKeyValueStore.layerLocalStorage);
|
|
1264
2820
|
var DataTableReferenceCell = ({
|
|
1265
2821
|
item,
|
|
1266
2822
|
emptyLabel = "—",
|
|
1267
2823
|
imageVariant = "circle"
|
|
1268
2824
|
}) => {
|
|
1269
|
-
const
|
|
2825
|
+
const tableClasses = useContext2(DataTableSlotClassesContext);
|
|
2826
|
+
const [failedImage, setFailedImage] = useState2();
|
|
1270
2827
|
if (!item)
|
|
1271
2828
|
return emptyLabel;
|
|
1272
|
-
const initials = item.label
|
|
2829
|
+
const initials = tableInitials(item.label);
|
|
1273
2830
|
return /* @__PURE__ */ jsxs9("div", {
|
|
1274
|
-
className:
|
|
2831
|
+
className: tableClasses.reference,
|
|
1275
2832
|
children: [
|
|
1276
2833
|
/* @__PURE__ */ jsx15("div", {
|
|
1277
|
-
className: cn(
|
|
2834
|
+
className: cn(tableClasses.referenceAvatar, imageVariant === "circle" ? "rounded-full" : "rounded-md", item.iconClassName),
|
|
1278
2835
|
children: item.icon ? /* @__PURE__ */ jsx15("span", {
|
|
1279
2836
|
"aria-hidden": "true",
|
|
1280
2837
|
className: "[&_svg]:size-4",
|
|
@@ -1290,14 +2847,14 @@ var DataTableReferenceCell = ({
|
|
|
1290
2847
|
})
|
|
1291
2848
|
}),
|
|
1292
2849
|
/* @__PURE__ */ jsxs9("div", {
|
|
1293
|
-
className:
|
|
2850
|
+
className: tableClasses.referenceText,
|
|
1294
2851
|
children: [
|
|
1295
2852
|
/* @__PURE__ */ jsx15("span", {
|
|
1296
|
-
className:
|
|
2853
|
+
className: tableClasses.referenceName,
|
|
1297
2854
|
children: item.label
|
|
1298
2855
|
}),
|
|
1299
2856
|
item.description ? /* @__PURE__ */ jsx15("span", {
|
|
1300
|
-
className:
|
|
2857
|
+
className: tableClasses.referenceDescription,
|
|
1301
2858
|
children: item.description
|
|
1302
2859
|
}) : null
|
|
1303
2860
|
]
|
|
@@ -1309,28 +2866,10 @@ var referenceText = (item) => item ? [item.label, item.description].filter(Boole
|
|
|
1309
2866
|
var messages2 = {
|
|
1310
2867
|
en: {
|
|
1311
2868
|
...paginationMessages("en"),
|
|
1312
|
-
|
|
1313
|
-
addItem: "Add item...",
|
|
1314
|
-
empty: "No results.",
|
|
1315
|
-
loading: "Loading...",
|
|
2869
|
+
...defaultMessages.en,
|
|
1316
2870
|
filter: "Filter results...",
|
|
1317
|
-
filters: "Filters",
|
|
1318
|
-
filtersClear: "Clear all filters",
|
|
1319
|
-
filterClear: "Clear filter",
|
|
1320
|
-
filterApply: "Apply filter",
|
|
1321
|
-
filterValue: "Value",
|
|
1322
|
-
filterOperator: "Operator",
|
|
1323
|
-
filterContains: "Contains",
|
|
1324
|
-
filterEquals: "Equals",
|
|
1325
|
-
filterStartsWith: "Starts with",
|
|
1326
|
-
filterEndsWith: "Ends with",
|
|
1327
|
-
filterMin: "Minimum",
|
|
1328
|
-
filterMax: "Maximum",
|
|
1329
2871
|
filterFrom: "From (UTC)",
|
|
1330
2872
|
filterTo: "To (UTC)",
|
|
1331
|
-
filterTrue: "True",
|
|
1332
|
-
filterFalse: "False",
|
|
1333
|
-
filterInvalid: "Enter a valid filter. Ranges must be in ascending order.",
|
|
1334
2873
|
export: "Export",
|
|
1335
2874
|
exportCsv: "CSV",
|
|
1336
2875
|
exportJson: "JSON",
|
|
@@ -1341,45 +2880,20 @@ var messages2 = {
|
|
|
1341
2880
|
galleryView: "Gallery",
|
|
1342
2881
|
columns: "Columns",
|
|
1343
2882
|
groupBy: "Group by",
|
|
1344
|
-
sortAsc: "Ascending",
|
|
1345
|
-
sortDesc: "Descending",
|
|
1346
|
-
sortClear: "Clear sorting",
|
|
1347
2883
|
sortBy: "Sort by",
|
|
1348
2884
|
hideColumn: "Hide column",
|
|
1349
2885
|
reorder: "Drag to reorder",
|
|
1350
|
-
removeItem: "Remove",
|
|
1351
2886
|
moveUp: "Move up",
|
|
1352
2887
|
moveDown: "Move down",
|
|
1353
2888
|
resizeColumn: (column) => `Resize ${column} column`,
|
|
1354
|
-
listDetails: "View all items"
|
|
1355
|
-
selectAllRows: "Select all rows on this page",
|
|
1356
|
-
selectRow: "Select row",
|
|
1357
|
-
selected: "Selected"
|
|
2889
|
+
listDetails: "View all items"
|
|
1358
2890
|
},
|
|
1359
2891
|
fr: {
|
|
1360
2892
|
...paginationMessages("fr"),
|
|
1361
|
-
|
|
1362
|
-
addItem: "Ajouter un élément...",
|
|
1363
|
-
empty: "Aucun résultat.",
|
|
1364
|
-
loading: "Chargement...",
|
|
2893
|
+
...defaultMessages.fr,
|
|
1365
2894
|
filter: "Filtrer les résultats...",
|
|
1366
|
-
filters: "Filtres",
|
|
1367
|
-
filtersClear: "Effacer tous les filtres",
|
|
1368
|
-
filterClear: "Effacer le filtre",
|
|
1369
|
-
filterApply: "Appliquer le filtre",
|
|
1370
|
-
filterValue: "Valeur",
|
|
1371
|
-
filterOperator: "Opérateur",
|
|
1372
|
-
filterContains: "Contient",
|
|
1373
|
-
filterEquals: "Égal à",
|
|
1374
|
-
filterStartsWith: "Commence par",
|
|
1375
|
-
filterEndsWith: "Se termine par",
|
|
1376
|
-
filterMin: "Minimum",
|
|
1377
|
-
filterMax: "Maximum",
|
|
1378
2895
|
filterFrom: "Du (UTC)",
|
|
1379
2896
|
filterTo: "Au (UTC)",
|
|
1380
|
-
filterTrue: "Vrai",
|
|
1381
|
-
filterFalse: "Faux",
|
|
1382
|
-
filterInvalid: "Saisissez un filtre valide. Les bornes doivent être dans l’ordre croissant.",
|
|
1383
2897
|
export: "Exporter",
|
|
1384
2898
|
exportCsv: "CSV",
|
|
1385
2899
|
exportJson: "JSON",
|
|
@@ -1390,20 +2904,13 @@ var messages2 = {
|
|
|
1390
2904
|
galleryView: "Galerie",
|
|
1391
2905
|
columns: "Colonnes",
|
|
1392
2906
|
groupBy: "Grouper par",
|
|
1393
|
-
sortAsc: "Croissant",
|
|
1394
|
-
sortDesc: "Décroissant",
|
|
1395
|
-
sortClear: "Effacer le tri",
|
|
1396
2907
|
sortBy: "Trier par",
|
|
1397
2908
|
hideColumn: "Masquer la colonne",
|
|
1398
2909
|
reorder: "Glisser pour réordonner",
|
|
1399
|
-
removeItem: "Retirer",
|
|
1400
2910
|
moveUp: "Déplacer vers le haut",
|
|
1401
2911
|
moveDown: "Déplacer vers le bas",
|
|
1402
2912
|
resizeColumn: (column) => `Redimensionner la colonne ${column}`,
|
|
1403
|
-
listDetails: "Afficher tous les éléments"
|
|
1404
|
-
selectAllRows: "Sélectionner toutes les lignes de cette page",
|
|
1405
|
-
selectRow: "Sélectionner la ligne",
|
|
1406
|
-
selected: "Sélectionnés"
|
|
2913
|
+
listDetails: "Afficher tous les éléments"
|
|
1407
2914
|
}
|
|
1408
2915
|
};
|
|
1409
2916
|
var dataTableMessages = (locale = "en", translations) => ({
|
|
@@ -1411,32 +2918,6 @@ var dataTableMessages = (locale = "en", translations) => ({
|
|
|
1411
2918
|
...translations?.[locale.split("-")[0] ?? locale],
|
|
1412
2919
|
...translations?.[locale]
|
|
1413
2920
|
});
|
|
1414
|
-
var DEFAULT_MIN_WIDTH = 96;
|
|
1415
|
-
var DEFAULT_WIDTH = 208;
|
|
1416
|
-
var DEFAULT_MAX_WIDTH = 640;
|
|
1417
|
-
var DEFAULT_QUERY = {
|
|
1418
|
-
page: 0,
|
|
1419
|
-
pageSize: DEFAULT_PAGE_SIZE
|
|
1420
|
-
};
|
|
1421
|
-
var DEFAULT_UI_STATE = {
|
|
1422
|
-
columnVisibility: {},
|
|
1423
|
-
columnSizing: {},
|
|
1424
|
-
rowSelection: {},
|
|
1425
|
-
grouping: [],
|
|
1426
|
-
collapsedGroups: {},
|
|
1427
|
-
view: "table"
|
|
1428
|
-
};
|
|
1429
|
-
var persistedUiFromState = (state) => ({
|
|
1430
|
-
columnVisibility: state.columnVisibility,
|
|
1431
|
-
columnSizing: state.columnSizing,
|
|
1432
|
-
grouping: state.grouping,
|
|
1433
|
-
view: state.view
|
|
1434
|
-
});
|
|
1435
|
-
var transientUiFromState = (state) => ({
|
|
1436
|
-
rowSelection: state.rowSelection,
|
|
1437
|
-
collapsedGroups: state.collapsedGroups
|
|
1438
|
-
});
|
|
1439
|
-
var clampWidth = (column, width) => Math.min(column.maxWidth ?? DEFAULT_MAX_WIDTH, Math.max(column.minWidth ?? DEFAULT_MIN_WIDTH, width));
|
|
1440
2921
|
var normalizeDataTableColumns = (columnDefs, columnSizing = {}) => {
|
|
1441
2922
|
const ids = new Set;
|
|
1442
2923
|
const columns = columnDefs.map((colDef) => {
|
|
@@ -1451,7 +2932,7 @@ var normalizeDataTableColumns = (columnDefs, columnSizing = {}) => {
|
|
|
1451
2932
|
return {
|
|
1452
2933
|
id,
|
|
1453
2934
|
colDef,
|
|
1454
|
-
width:
|
|
2935
|
+
width: clampTableWidth(colDef, columnSizing[id])
|
|
1455
2936
|
};
|
|
1456
2937
|
});
|
|
1457
2938
|
for (const column of columns) {
|
|
@@ -1472,7 +2953,7 @@ var getDataTableFieldColumns = (column) => (column.colDef.fields ?? []).map(({ i
|
|
|
1472
2953
|
}));
|
|
1473
2954
|
var getDataTableSortColumns = (columns) => columns.flatMap((column) => column.colDef.sortable === false ? [] : ((column.colDef.fields?.length) ? getDataTableFieldColumns(column) : [column]).filter(({ colDef }) => colDef.sortable !== false));
|
|
1474
2955
|
var getDataTableExportColumns = (visibleColumns) => visibleColumns.flatMap((column) => column.colDef.fields?.length ? getDataTableFieldColumns(column).filter((_field, index) => column.colDef.fields?.[index]?.export !== false) : [column]);
|
|
1475
|
-
var getDataTableWidth = (columns, utilityColumns = 0) => columns.
|
|
2956
|
+
var getDataTableWidth = (columns, utilityColumns = 0) => tableLayoutWidth(columns.map(({ width }) => width), utilityColumns);
|
|
1476
2957
|
var buildDataTableRows = (rowData, columns, getRowId) => {
|
|
1477
2958
|
const ids = new Set;
|
|
1478
2959
|
return rowData.map((data, index) => {
|
|
@@ -1492,58 +2973,20 @@ var buildDataTableRows = (rowData, columns, getRowId) => {
|
|
|
1492
2973
|
};
|
|
1493
2974
|
});
|
|
1494
2975
|
};
|
|
1495
|
-
var
|
|
1496
|
-
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" });
|
|
1497
|
-
var DateInput = Schema2.Union([
|
|
1498
|
-
Schema2.Date,
|
|
1499
|
-
Schema2.Int,
|
|
1500
|
-
CalendarDate,
|
|
1501
|
-
InstantString
|
|
1502
|
-
]).annotate({
|
|
1503
|
-
identifier: "DataTableDateInput"
|
|
1504
|
-
});
|
|
1505
|
-
var decodeDateInput = Schema2.decodeUnknownOption(DateInput);
|
|
1506
|
-
var resolveDate = (value, type) => Option2.getOrUndefined(Option2.flatMap(decodeDateInput(value), (input) => {
|
|
1507
|
-
const calendarOnly = Schema2.is(CalendarDate)(input);
|
|
1508
|
-
if (calendarOnly && type === "dateTime")
|
|
1509
|
-
return Option2.none();
|
|
1510
|
-
return Option2.map(DateTime2.make(input), (instant) => ({
|
|
1511
|
-
instant,
|
|
1512
|
-
calendarOnly
|
|
1513
|
-
}));
|
|
1514
|
-
}));
|
|
1515
|
-
var formatDateValue = (date, column, locale = "en") => DateTime2.format(date.instant, {
|
|
1516
|
-
locale: column.typeOptions?.locale ?? locale,
|
|
1517
|
-
timeZone: date.calendarOnly ? "UTC" : column.typeOptions?.timeZone ?? "UTC",
|
|
1518
|
-
dateStyle: column.typeOptions?.dateStyle ?? "medium",
|
|
1519
|
-
timeStyle: column.type === "dateTime" ? column.typeOptions?.timeStyle ?? "short" : undefined,
|
|
1520
|
-
hour12: column.type === "dateTime" ? column.typeOptions?.hour12 : undefined
|
|
1521
|
-
});
|
|
1522
|
-
var dateIsoValue = (date) => date.calendarOnly ? DateTime2.formatIsoDateUtc(date.instant) : DateTime2.formatIso(date.instant);
|
|
1523
|
-
var NumberValue = Schema2.Finite.annotate({
|
|
2976
|
+
var NumberValue = Schema6.Finite.annotate({
|
|
1524
2977
|
identifier: "DataTableNumberValue"
|
|
1525
2978
|
});
|
|
1526
|
-
var BooleanValue =
|
|
2979
|
+
var BooleanValue = Schema6.Boolean.annotate({
|
|
1527
2980
|
identifier: "DataTableBooleanValue"
|
|
1528
2981
|
});
|
|
1529
|
-
var decodeNumberValue =
|
|
1530
|
-
var decodeBooleanValue =
|
|
1531
|
-
var
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
...format
|
|
1538
|
-
} = options;
|
|
1539
|
-
return new Intl.NumberFormat(locale ?? defaultLocale, format).format(value);
|
|
1540
|
-
};
|
|
1541
|
-
var scalarText = Schema2.is(Schema2.Union([
|
|
1542
|
-
Schema2.String,
|
|
1543
|
-
Schema2.Finite,
|
|
1544
|
-
Schema2.Boolean,
|
|
1545
|
-
Schema2.BigInt,
|
|
1546
|
-
Schema2.Symbol
|
|
2982
|
+
var decodeNumberValue = Schema6.decodeUnknownOption(NumberValue);
|
|
2983
|
+
var decodeBooleanValue = Schema6.decodeUnknownOption(BooleanValue);
|
|
2984
|
+
var scalarText = Schema6.is(Schema6.Union([
|
|
2985
|
+
Schema6.String,
|
|
2986
|
+
Schema6.Finite,
|
|
2987
|
+
Schema6.Boolean,
|
|
2988
|
+
Schema6.BigInt,
|
|
2989
|
+
Schema6.Symbol
|
|
1547
2990
|
]));
|
|
1548
2991
|
var dataTableValueText = (value) => value == null ? "" : scalarText(value) ? String(value) : Formatter.format(value);
|
|
1549
2992
|
var booleanLabel = (value, options) => value ? options?.trueLabel : options?.falseLabel;
|
|
@@ -1551,13 +2994,13 @@ var getDataTableExportValue = (row, column, locale = "en") => {
|
|
|
1551
2994
|
const value = row.values.get(column.id);
|
|
1552
2995
|
const colDef = column.colDef;
|
|
1553
2996
|
if (colDef.type === "number") {
|
|
1554
|
-
const number =
|
|
2997
|
+
const number = Option4.getOrUndefined(decodeNumberValue(value));
|
|
1555
2998
|
if (number === undefined)
|
|
1556
2999
|
return null;
|
|
1557
3000
|
return colDef.typeOptions?.exportFormat === "formatted" ? formatNumberValue(number, colDef.typeOptions, locale) : number;
|
|
1558
3001
|
}
|
|
1559
3002
|
if (colDef.type === "boolean") {
|
|
1560
|
-
const boolean =
|
|
3003
|
+
const boolean = Option4.getOrUndefined(decodeBooleanValue(value));
|
|
1561
3004
|
if (boolean === undefined)
|
|
1562
3005
|
return null;
|
|
1563
3006
|
return colDef.typeOptions?.exportFormat === "formatted" ? booleanLabel(boolean, colDef.typeOptions) ?? String(boolean) : boolean;
|
|
@@ -1582,10 +3025,10 @@ var filterDataTableRows = (rows, columns, globalFilter, locale = "en") => {
|
|
|
1582
3025
|
const date = resolveDate(value, colDef.type);
|
|
1583
3026
|
text = date ? `${formatDateValue(date, colDef, locale)} ${dateIsoValue(date)}` : "";
|
|
1584
3027
|
} else if (colDef.type === "number") {
|
|
1585
|
-
const number =
|
|
3028
|
+
const number = Option4.getOrUndefined(decodeNumberValue(value));
|
|
1586
3029
|
text = number === undefined ? "" : `${formatNumberValue(number, colDef.typeOptions, locale)} ${number}`;
|
|
1587
3030
|
} else if (colDef.type === "boolean") {
|
|
1588
|
-
const boolean =
|
|
3031
|
+
const boolean = Option4.getOrUndefined(decodeBooleanValue(value));
|
|
1589
3032
|
text = boolean === undefined ? "" : `${booleanLabel(boolean, colDef.typeOptions) ?? ""} ${boolean}`;
|
|
1590
3033
|
}
|
|
1591
3034
|
return text.toLocaleLowerCase().includes(query);
|
|
@@ -1594,7 +3037,7 @@ var filterDataTableRows = (rows, columns, globalFilter, locale = "en") => {
|
|
|
1594
3037
|
var getDataTableFilterColumns = (columns) => columns.flatMap((column) => column.colDef.filterable === false ? [] : ((column.colDef.fields?.length) ? getDataTableFieldColumns(column) : [column]).filter(({ colDef }) => colDef.filterable !== false));
|
|
1595
3038
|
var getDataTableFilterKind = ({
|
|
1596
3039
|
colDef
|
|
1597
|
-
}) => colDef
|
|
3040
|
+
}) => tableFilterKind(colDef, !!colDef.filterOptions);
|
|
1598
3041
|
var getDataTableFilterOptions = (rows, column) => {
|
|
1599
3042
|
const { colDef } = column;
|
|
1600
3043
|
if (colDef.filterOptions)
|
|
@@ -1622,39 +3065,8 @@ var filterDataTableColumnRows = (rows, columns, filters) => {
|
|
|
1622
3065
|
rowIndex: row.index,
|
|
1623
3066
|
colDef: column.colDef
|
|
1624
3067
|
}) : row.values.get(column.id);
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
const text = dataTableValueText(value).toLocaleLowerCase();
|
|
1628
|
-
const query = filter.value.toLocaleLowerCase();
|
|
1629
|
-
switch (filter.operator) {
|
|
1630
|
-
case "contains":
|
|
1631
|
-
return text.includes(query);
|
|
1632
|
-
case "equals":
|
|
1633
|
-
return text === query;
|
|
1634
|
-
case "startsWith":
|
|
1635
|
-
return text.startsWith(query);
|
|
1636
|
-
case "endsWith":
|
|
1637
|
-
return text.endsWith(query);
|
|
1638
|
-
}
|
|
1639
|
-
}
|
|
1640
|
-
case "number": {
|
|
1641
|
-
const number = Option2.getOrUndefined(decodeNumberValue(value));
|
|
1642
|
-
return number !== undefined && (filter.min === undefined || number >= filter.min) && (filter.max === undefined || number <= filter.max);
|
|
1643
|
-
}
|
|
1644
|
-
case "date": {
|
|
1645
|
-
const date = resolveDate(value, column.colDef.type === "dateTime" ? "dateTime" : "date");
|
|
1646
|
-
if (!date)
|
|
1647
|
-
return false;
|
|
1648
|
-
const day = DateTime2.formatIsoDateUtc(date.instant);
|
|
1649
|
-
return (filter.from === undefined || day >= filter.from) && (filter.to === undefined || day <= filter.to);
|
|
1650
|
-
}
|
|
1651
|
-
case "boolean":
|
|
1652
|
-
return Option2.getOrUndefined(decodeBooleanValue(value)) === filter.value;
|
|
1653
|
-
case "values": {
|
|
1654
|
-
const values = column.colDef.type === "list" ? column.colDef.typeOptions.getItems(row.data).map((item) => item.value ?? item.label) : [dataTableValueText(value)];
|
|
1655
|
-
return filter.values.some((selected) => values.includes(selected));
|
|
1656
|
-
}
|
|
1657
|
-
}
|
|
3068
|
+
const { colDef } = column;
|
|
3069
|
+
return matchesTableFilter(filter, value, colDef.type, () => dataTableValueText(value), () => colDef.type === "list" ? colDef.typeOptions.getItems(row.data).map((item) => item.value ?? item.label) : [dataTableValueText(value)]);
|
|
1658
3070
|
}));
|
|
1659
3071
|
};
|
|
1660
3072
|
var sortDataTableRows = (rows, columns, sorting) => {
|
|
@@ -1670,49 +3082,19 @@ var sortDataTableRows = (rows, columns, sorting) => {
|
|
|
1670
3082
|
const leftValue = left.row.values.get(sort.id);
|
|
1671
3083
|
const rightValue = right.row.values.get(sort.id);
|
|
1672
3084
|
const colDef = column.colDef;
|
|
1673
|
-
if (!colDef.comparator && (colDef.type === "number" || colDef.type === "boolean")) {
|
|
1674
|
-
const
|
|
1675
|
-
const rightScalar = colDef.type === "number" ? Option2.getOrUndefined(decodeNumberValue(rightValue)) : Option2.getOrUndefined(Option2.map(decodeBooleanValue(rightValue), Number));
|
|
1676
|
-
if (leftScalar === undefined || rightScalar === undefined) {
|
|
1677
|
-
if (leftScalar === undefined && rightScalar === undefined)
|
|
1678
|
-
continue;
|
|
1679
|
-
const nullOrder = colDef.typeOptions?.nulls === "first" ? -1 : 1;
|
|
1680
|
-
return leftScalar === undefined ? nullOrder : -nullOrder;
|
|
1681
|
-
}
|
|
1682
|
-
const comparison = leftScalar - rightScalar;
|
|
1683
|
-
if (comparison !== 0)
|
|
1684
|
-
return sort.direction === "desc" ? -comparison : comparison;
|
|
1685
|
-
continue;
|
|
1686
|
-
}
|
|
1687
|
-
if (!colDef.comparator && (colDef.type === "date" || colDef.type === "dateTime")) {
|
|
1688
|
-
const leftDate = resolveDate(leftValue, colDef.type);
|
|
1689
|
-
const rightDate = resolveDate(rightValue, colDef.type);
|
|
1690
|
-
if (!leftDate || !rightDate) {
|
|
1691
|
-
if (!leftDate && !rightDate)
|
|
1692
|
-
continue;
|
|
1693
|
-
const nullOrder = colDef.typeOptions?.nulls === "first" ? -1 : 1;
|
|
1694
|
-
return !leftDate ? nullOrder : -nullOrder;
|
|
1695
|
-
}
|
|
1696
|
-
const comparison = DateTime2.toEpochMillis(leftDate.instant) - DateTime2.toEpochMillis(rightDate.instant);
|
|
3085
|
+
if (!colDef.comparator && (colDef.type === "number" || colDef.type === "boolean" || colDef.type === "date" || colDef.type === "dateTime")) {
|
|
3086
|
+
const comparison = compareTableSortValues(tableSortScalar(colDef.type, leftValue), tableSortScalar(colDef.type, rightValue), sort.direction, colDef.typeOptions?.nulls);
|
|
1697
3087
|
if (comparison !== 0)
|
|
1698
|
-
return
|
|
3088
|
+
return comparison;
|
|
1699
3089
|
continue;
|
|
1700
3090
|
}
|
|
1701
|
-
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 :
|
|
3091
|
+
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));
|
|
1702
3092
|
if (comparison !== 0)
|
|
1703
3093
|
return sort.direction === "desc" ? -comparison : comparison;
|
|
1704
3094
|
}
|
|
1705
3095
|
return left.stableIndex - right.stableIndex;
|
|
1706
3096
|
}).map(({ row }) => row);
|
|
1707
3097
|
};
|
|
1708
|
-
var paginateDataTableRows = (rows, pagination) => {
|
|
1709
|
-
const pageSize = Math.max(1, pagination.pageSize);
|
|
1710
|
-
const lastPageIndex = Math.max(0, Math.ceil(rows.length / pageSize) - 1);
|
|
1711
|
-
const pageIndex = Math.min(lastPageIndex, Math.max(0, pagination.page));
|
|
1712
|
-
const start = pageIndex * pageSize;
|
|
1713
|
-
return rows.slice(start, start + pageSize);
|
|
1714
|
-
};
|
|
1715
|
-
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;
|
|
1716
3098
|
var reorderDataTableRows = (rows, sourceRowId, targetRowId) => {
|
|
1717
3099
|
const sourceIndex = rows.findIndex((row) => row.id === sourceRowId);
|
|
1718
3100
|
const targetIndex = rows.findIndex((row) => row.id === targetRowId);
|
|
@@ -1725,10 +3107,10 @@ var reorderDataTableRows = (rows, sourceRowId, targetRowId) => {
|
|
|
1725
3107
|
reordered.splice(targetIndex, 0, source);
|
|
1726
3108
|
return reordered;
|
|
1727
3109
|
};
|
|
1728
|
-
var RowIdContext =
|
|
1729
|
-
var ColumnIdContext =
|
|
3110
|
+
var RowIdContext = createContext2(null);
|
|
3111
|
+
var ColumnIdContext = createContext2(null);
|
|
1730
3112
|
var useRequiredId = (context) => {
|
|
1731
|
-
const id =
|
|
3113
|
+
const id = useContext2(context);
|
|
1732
3114
|
if (!id)
|
|
1733
3115
|
throw new Error("DataTable internal ID context is missing");
|
|
1734
3116
|
return id;
|
|
@@ -1758,7 +3140,7 @@ var clearDragPresentation = (root) => {
|
|
|
1758
3140
|
element.removeAttribute("data-drop-position");
|
|
1759
3141
|
});
|
|
1760
3142
|
};
|
|
1761
|
-
var resolveConfig = (props
|
|
3143
|
+
var resolveConfig = (props) => {
|
|
1762
3144
|
const features = props.features ?? {};
|
|
1763
3145
|
const selection = features.selection;
|
|
1764
3146
|
const getRowId = selection && selection.getRowId || props.getRowId || undefined;
|
|
@@ -1767,8 +3149,6 @@ var resolveConfig = (props, onUiStateChange) => {
|
|
|
1767
3149
|
}
|
|
1768
3150
|
return {
|
|
1769
3151
|
getRowId,
|
|
1770
|
-
onStateChange: props.onStateChange,
|
|
1771
|
-
onUiStateChange,
|
|
1772
3152
|
status: props.status ?? {},
|
|
1773
3153
|
features,
|
|
1774
3154
|
onRowClicked: props.onRowClicked,
|
|
@@ -1783,83 +3163,39 @@ var queryFromState = (state) => ({
|
|
|
1783
3163
|
filters: state.filters,
|
|
1784
3164
|
sort: state.sort
|
|
1785
3165
|
});
|
|
1786
|
-
var uiFromState = (state) => ({
|
|
1787
|
-
columnVisibility: state.columnVisibility,
|
|
1788
|
-
columnSizing: state.columnSizing,
|
|
1789
|
-
rowSelection: state.rowSelection,
|
|
1790
|
-
grouping: state.grouping,
|
|
1791
|
-
collapsedGroups: state.collapsedGroups,
|
|
1792
|
-
view: state.view
|
|
1793
|
-
});
|
|
1794
|
-
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;
|
|
1795
|
-
var sameQueryState = (left, right) => left.page === right.page && left.pageSize === right.pageSize && left.globalFilter === right.globalFilter && left.filters === right.filters && left.sort === right.sort;
|
|
1796
|
-
var initialPublicState = (props, uiState) => ({
|
|
1797
|
-
...queryFromState(props.state ?? { ...DEFAULT_QUERY, ...props.initialState }),
|
|
1798
|
-
...uiState
|
|
1799
|
-
});
|
|
1800
3166
|
var buildDataTableModel = (store) => {
|
|
1801
3167
|
const columns = normalizeDataTableColumns(store.columnDefs, store.state.columnSizing);
|
|
1802
3168
|
const selection = store.config.features.selection;
|
|
1803
3169
|
const rowId = selection && selection.getRowId || store.config.getRowId || undefined;
|
|
1804
3170
|
const rows = buildDataTableRows(store.rowData, columns, rowId);
|
|
1805
|
-
const
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
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
|
+
});
|
|
1811
3178
|
return {
|
|
1812
3179
|
columns,
|
|
1813
3180
|
visibleColumns: columns.filter(({ id }) => store.state.columnVisibility[id] !== false),
|
|
1814
3181
|
rows,
|
|
1815
|
-
filteredRows,
|
|
1816
|
-
sortedRows,
|
|
1817
|
-
pageRows,
|
|
1818
|
-
|
|
1819
|
-
|
|
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
|
|
1820
3189
|
};
|
|
1821
3190
|
};
|
|
1822
|
-
var useTableAtom = (tableAtom) => useAtom(tableAtom);
|
|
1823
|
-
var changeState = (setStore, update) => {
|
|
1824
|
-
setStore((store) => {
|
|
1825
|
-
const proposed = update(store.state);
|
|
1826
|
-
const query = queryFromState(proposed);
|
|
1827
|
-
if (!sameQueryState(query, store.state)) {
|
|
1828
|
-
store.config.onStateChange?.(query);
|
|
1829
|
-
}
|
|
1830
|
-
const uiState = uiFromState(proposed);
|
|
1831
|
-
if (!sameUiState(uiState, store.state)) {
|
|
1832
|
-
store.config.onUiStateChange(uiState);
|
|
1833
|
-
}
|
|
1834
|
-
const state = store.controlledState ? { ...proposed, ...queryFromState(store.controlledState) } : proposed;
|
|
1835
|
-
if (sameDataTableState(state, store.state))
|
|
1836
|
-
return store;
|
|
1837
|
-
const next = { ...store, state };
|
|
1838
|
-
return { ...next, model: buildDataTableModel(next) };
|
|
1839
|
-
});
|
|
1840
|
-
};
|
|
1841
3191
|
var deriveModel = (store) => store.model;
|
|
1842
3192
|
var groupDataTableRows = (rows, fields, depth = 0, parentKey = "") => {
|
|
1843
3193
|
const field = fields[0];
|
|
1844
3194
|
if (!field)
|
|
1845
3195
|
return [];
|
|
1846
|
-
const groups =
|
|
1847
|
-
field.getGroupIds?.().forEach((id) => groups.set(id, []));
|
|
1848
|
-
rows.forEach((row) => {
|
|
1849
|
-
const ids = field.getRowGroupIds?.(row.data) ?? [
|
|
1850
|
-
field.getGroupId(row.data)
|
|
1851
|
-
];
|
|
1852
|
-
ids.forEach((id) => {
|
|
1853
|
-
const group = groups.get(id);
|
|
1854
|
-
if (group)
|
|
1855
|
-
group.push(row);
|
|
1856
|
-
else
|
|
1857
|
-
groups.set(id, [row]);
|
|
1858
|
-
});
|
|
1859
|
-
});
|
|
3196
|
+
const groups = partitionTableGroups(rows, field.getGroupIds?.() ?? [], (row) => field.getRowGroupIds?.(row.data) ?? [field.getGroupId(row.data)]);
|
|
1860
3197
|
return Array.from(groups, ([groupId, groupRows]) => {
|
|
1861
|
-
const
|
|
1862
|
-
const key = `${parentKey}${parentKey ? "/" : ""}${segment}`;
|
|
3198
|
+
const key = tableGroupKey(parentKey, field.id, groupId);
|
|
1863
3199
|
return {
|
|
1864
3200
|
key,
|
|
1865
3201
|
groupId,
|
|
@@ -1870,15 +3206,9 @@ var groupDataTableRows = (rows, fields, depth = 0, parentKey = "") => {
|
|
|
1870
3206
|
};
|
|
1871
3207
|
});
|
|
1872
3208
|
};
|
|
1873
|
-
var getDataTableSelectableRows = (model, grouped, isRowSelectable) => (grouped ? model.sortedRows : model.pageRows).filter((row) => isRowSelectable?.(row.data) ?? true);
|
|
1874
3209
|
var getActiveGrouping = (store) => {
|
|
1875
3210
|
const grouping = store.config.features.grouping;
|
|
1876
|
-
|
|
1877
|
-
return [];
|
|
1878
|
-
return store.state.grouping.flatMap((id) => {
|
|
1879
|
-
const field = grouping.fields.find((candidate) => candidate.id === id);
|
|
1880
|
-
return field ? [field] : [];
|
|
1881
|
-
});
|
|
3211
|
+
return activeTableGroups(store.state.grouping, grouping && grouping.fields || []);
|
|
1882
3212
|
};
|
|
1883
3213
|
var canReorderRows = (store) => {
|
|
1884
3214
|
const pagination = store.config.features.pagination;
|
|
@@ -1915,7 +3245,7 @@ var renderCell = (row, column, locale = "en", labels = dataTableMessages(locale)
|
|
|
1915
3245
|
if (colDef.type === "number") {
|
|
1916
3246
|
if (colDef.valueFormatter)
|
|
1917
3247
|
return colDef.valueFormatter(params);
|
|
1918
|
-
const number =
|
|
3248
|
+
const number = Option4.getOrUndefined(decodeNumberValue(value));
|
|
1919
3249
|
return /* @__PURE__ */ jsx15("span", {
|
|
1920
3250
|
className: "block text-left tabular-nums",
|
|
1921
3251
|
children: number === undefined ? colDef.typeOptions?.emptyLabel ?? "—" : formatNumberValue(number, colDef.typeOptions, locale)
|
|
@@ -1924,7 +3254,7 @@ var renderCell = (row, column, locale = "en", labels = dataTableMessages(locale)
|
|
|
1924
3254
|
if (colDef.type === "boolean") {
|
|
1925
3255
|
if (colDef.valueFormatter)
|
|
1926
3256
|
return colDef.valueFormatter(params);
|
|
1927
|
-
const boolean =
|
|
3257
|
+
const boolean = Option4.getOrUndefined(decodeBooleanValue(value));
|
|
1928
3258
|
if (boolean === undefined)
|
|
1929
3259
|
return colDef.typeOptions?.emptyLabel ?? "—";
|
|
1930
3260
|
const options = colDef.typeOptions;
|
|
@@ -1987,37 +3317,25 @@ var renderCell = (row, column, locale = "en", labels = dataTableMessages(locale)
|
|
|
1987
3317
|
return column.colDef.valueFormatter?.(params) ?? (value === null || value === undefined ? null : dataTableValueText(value));
|
|
1988
3318
|
};
|
|
1989
3319
|
var nodeText = (node) => {
|
|
1990
|
-
if (
|
|
3320
|
+
if (Schema6.is(Schema6.String)(node) || Schema6.is(Schema6.Finite)(node))
|
|
1991
3321
|
return String(node);
|
|
1992
3322
|
if (!isValidElement(node))
|
|
1993
3323
|
return "";
|
|
1994
|
-
if (
|
|
3324
|
+
if (Schema6.is(Schema6.String)(node.props.title))
|
|
1995
3325
|
return node.props.title;
|
|
1996
3326
|
return nodeText(node.props.children);
|
|
1997
3327
|
};
|
|
1998
3328
|
var columnLabel = (column) => nodeText(column.colDef.headerName) || column.id;
|
|
1999
|
-
var withExtension = (fileName, extension) => fileName.includes(".") ? fileName.replace(/\.[^/.]+$/, `.${extension}`) : `${fileName}.${extension}`;
|
|
2000
3329
|
var downloadCsv = (headers, data, fileName = "data.csv") => {
|
|
2001
|
-
|
|
2002
|
-
` })), Stream.runCollect, Effect2.map((parts) => parts.join("").slice(0, -1))));
|
|
2003
|
-
downloadBlob(content, "text/csv;charset=utf-8", withExtension(fileName, "csv"));
|
|
2004
|
-
};
|
|
2005
|
-
var downloadJson = (data, fileName = "data.json") => downloadBlob(JSON.stringify(data, null, 2), "application/json;charset=utf-8", withExtension(fileName, "json"));
|
|
2006
|
-
var downloadBlob = (content, type, fileName) => {
|
|
2007
|
-
const url = window.URL.createObjectURL(new Blob([content], { type }));
|
|
2008
|
-
const link = document.createElement("a");
|
|
2009
|
-
link.href = url;
|
|
2010
|
-
link.download = fileName;
|
|
2011
|
-
document.body.appendChild(link);
|
|
2012
|
-
link.click();
|
|
2013
|
-
link.remove();
|
|
2014
|
-
requestAnimationFrame(() => window.URL.revokeObjectURL(url));
|
|
3330
|
+
downloadTableBlob(encodeTableCsv(headers, data), "text/csv;charset=utf-8", tableExportFilename(fileName, "csv"));
|
|
2015
3331
|
};
|
|
3332
|
+
var downloadJson = (data, fileName = "data.json") => downloadTableBlob(JSON.stringify(data, null, 2), "application/json;charset=utf-8", tableExportFilename(fileName, "json"));
|
|
2016
3333
|
var DataTableRowActions = ({
|
|
2017
3334
|
actions,
|
|
2018
3335
|
row,
|
|
2019
3336
|
title
|
|
2020
3337
|
}) => {
|
|
3338
|
+
const tableClasses = useContext2(DataTableSlotClassesContext);
|
|
2021
3339
|
const visible = actions.filter((action) => !action.visible || action.visible(row));
|
|
2022
3340
|
if (!visible.length)
|
|
2023
3341
|
return null;
|
|
@@ -2026,7 +3344,7 @@ var DataTableRowActions = ({
|
|
|
2026
3344
|
/* @__PURE__ */ jsx15(DropdownMenuTrigger2, {
|
|
2027
3345
|
onClick: (event) => event.stopPropagation(),
|
|
2028
3346
|
render: /* @__PURE__ */ jsxs9(Button, {
|
|
2029
|
-
className: "
|
|
3347
|
+
className: cn(tableClasses.actionTrigger, "[&_svg:not([class*='size-'])]:size-4"),
|
|
2030
3348
|
size: "icon",
|
|
2031
3349
|
variant: "ghost",
|
|
2032
3350
|
children: [
|
|
@@ -2065,10 +3383,10 @@ var DataTableRowActions = ({
|
|
|
2065
3383
|
});
|
|
2066
3384
|
};
|
|
2067
3385
|
var DataTableRowActionMenu = ({
|
|
2068
|
-
|
|
3386
|
+
table,
|
|
2069
3387
|
row
|
|
2070
3388
|
}) => {
|
|
2071
|
-
const [store] =
|
|
3389
|
+
const [store] = table;
|
|
2072
3390
|
const rowId = row.id;
|
|
2073
3391
|
const rowActions = store.config.features.rowActions || undefined;
|
|
2074
3392
|
const reordering = store.config.features.reordering;
|
|
@@ -2102,12 +3420,12 @@ var DataTableRowActionMenu = ({
|
|
|
2102
3420
|
});
|
|
2103
3421
|
};
|
|
2104
3422
|
var DataTableToolbar = ({
|
|
2105
|
-
|
|
3423
|
+
table
|
|
2106
3424
|
}) => {
|
|
2107
|
-
const
|
|
2108
|
-
const
|
|
2109
|
-
const
|
|
2110
|
-
const
|
|
3425
|
+
const tableClasses = useContext2(DataTableSlotClassesContext);
|
|
3426
|
+
const [store, send] = table;
|
|
3427
|
+
const exportPending = useRef2(false);
|
|
3428
|
+
const { exporting, exportFailed } = store.ui;
|
|
2111
3429
|
const { features, labels } = store.config;
|
|
2112
3430
|
const model = deriveModel(store);
|
|
2113
3431
|
const selectedRows = getSelectedRows(store, model);
|
|
@@ -2117,7 +3435,6 @@ var DataTableToolbar = ({
|
|
|
2117
3435
|
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;
|
|
2118
3436
|
if (!hasToolbar)
|
|
2119
3437
|
return null;
|
|
2120
|
-
const update = (next) => changeState(setStore, next);
|
|
2121
3438
|
const visibleBulkActions = bulkActions ? bulkActions.items.filter((action) => !action.visible || action.visible(selectedRows)) : [];
|
|
2122
3439
|
const exportRows = features.export && features.export.scope === "currentPage" ? model.pageRows : model.sortedRows;
|
|
2123
3440
|
const exportColumns = getDataTableExportColumns(model.visibleColumns);
|
|
@@ -2129,46 +3446,38 @@ var DataTableToolbar = ({
|
|
|
2129
3446
|
if (exportPending.current || action.disabled)
|
|
2130
3447
|
return;
|
|
2131
3448
|
exportPending.current = true;
|
|
2132
|
-
|
|
2133
|
-
|
|
3449
|
+
send(DataTableMessage.ExportStarted());
|
|
3450
|
+
let failed = false;
|
|
2134
3451
|
try {
|
|
2135
3452
|
await action.onExport();
|
|
2136
3453
|
} catch (error) {
|
|
2137
|
-
|
|
3454
|
+
failed = true;
|
|
2138
3455
|
if (exportFeature)
|
|
2139
3456
|
exportFeature.onError?.(error, action);
|
|
2140
3457
|
} finally {
|
|
2141
3458
|
exportPending.current = false;
|
|
2142
|
-
|
|
3459
|
+
send(DataTableMessage.ExportFinished({ failed }));
|
|
2143
3460
|
}
|
|
2144
3461
|
};
|
|
2145
3462
|
return /* @__PURE__ */ jsxs9("div", {
|
|
2146
|
-
className: cn("
|
|
3463
|
+
className: cn(tableClasses.toolbar, "pb-4"),
|
|
2147
3464
|
children: [
|
|
2148
3465
|
features.search !== false ? /* @__PURE__ */ jsxs9("div", {
|
|
2149
|
-
className:
|
|
3466
|
+
className: tableClasses.toolbarSearch,
|
|
2150
3467
|
children: [
|
|
2151
3468
|
/* @__PURE__ */ jsx15(Search, {
|
|
2152
3469
|
className: "text-muted-foreground pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2"
|
|
2153
3470
|
}),
|
|
2154
3471
|
/* @__PURE__ */ jsx15(Input2, {
|
|
2155
3472
|
className: "px-9",
|
|
2156
|
-
onChange: (event) =>
|
|
2157
|
-
...state,
|
|
2158
|
-
globalFilter: event.target.value,
|
|
2159
|
-
page: 0
|
|
2160
|
-
})),
|
|
3473
|
+
onChange: (event) => send(DataTableMessage.SearchChanged({ value: event.target.value })),
|
|
2161
3474
|
placeholder: labels.filter,
|
|
2162
3475
|
value: store.state.globalFilter ?? ""
|
|
2163
3476
|
}),
|
|
2164
3477
|
store.state.globalFilter ? /* @__PURE__ */ jsx15(Button, {
|
|
2165
3478
|
"aria-label": labels.filter,
|
|
2166
3479
|
className: "absolute top-1/2 right-1 size-7 -translate-y-1/2 active:not-aria-[haspopup]:-translate-y-1/2",
|
|
2167
|
-
onClick: () =>
|
|
2168
|
-
...state,
|
|
2169
|
-
globalFilter: undefined,
|
|
2170
|
-
page: 0
|
|
2171
|
-
})),
|
|
3480
|
+
onClick: () => send(DataTableMessage.SearchChanged({ value: "" })),
|
|
2172
3481
|
size: "icon",
|
|
2173
3482
|
variant: "ghost",
|
|
2174
3483
|
children: /* @__PURE__ */ jsx15(X, {})
|
|
@@ -2176,19 +3485,19 @@ var DataTableToolbar = ({
|
|
|
2176
3485
|
]
|
|
2177
3486
|
}) : null,
|
|
2178
3487
|
/* @__PURE__ */ jsx15("div", {
|
|
2179
|
-
className:
|
|
3488
|
+
className: tableClasses.toolbarMenus,
|
|
2180
3489
|
children: /* @__PURE__ */ jsxs9(Menubar2, {
|
|
2181
3490
|
modal: false,
|
|
2182
|
-
className: "
|
|
3491
|
+
className: cn(tableClasses.menubar, "[&_[data-slot=menubar-trigger]]:gap-2 [&_[data-slot=menubar-trigger]_svg]:size-4"),
|
|
2183
3492
|
children: [
|
|
2184
3493
|
visibleBulkActions.length ? /* @__PURE__ */ jsxs9(MenubarMenu, {
|
|
2185
3494
|
children: [
|
|
2186
3495
|
/* @__PURE__ */ jsxs9(MenubarTrigger2, {
|
|
2187
|
-
className: "
|
|
3496
|
+
className: cn(tableClasses.selectedTrigger, "aria-expanded:bg-primary/90"),
|
|
2188
3497
|
children: [
|
|
2189
3498
|
labels.selected,
|
|
2190
|
-
/* @__PURE__ */ jsx15(
|
|
2191
|
-
|
|
3499
|
+
/* @__PURE__ */ jsx15("span", {
|
|
3500
|
+
className: tableClasses.count,
|
|
2192
3501
|
children: selectedRows.length
|
|
2193
3502
|
}),
|
|
2194
3503
|
/* @__PURE__ */ jsx15(ChevronDown, {})
|
|
@@ -2218,7 +3527,7 @@ var DataTableToolbar = ({
|
|
|
2218
3527
|
}) : null,
|
|
2219
3528
|
toolbar && toolbar.items,
|
|
2220
3529
|
features.filtering !== false ? /* @__PURE__ */ jsx15(FilterMenu, {
|
|
2221
|
-
|
|
3530
|
+
table
|
|
2222
3531
|
}) : null,
|
|
2223
3532
|
grouping ? /* @__PURE__ */ jsxs9(MenubarMenu, {
|
|
2224
3533
|
children: [
|
|
@@ -2242,10 +3551,7 @@ var DataTableToolbar = ({
|
|
|
2242
3551
|
/* @__PURE__ */ jsx15(MenubarSeparator2, {}),
|
|
2243
3552
|
grouping.fields.map((field) => /* @__PURE__ */ jsx15(MenubarCheckboxItem2, {
|
|
2244
3553
|
checked: store.state.grouping.includes(field.id),
|
|
2245
|
-
onCheckedChange: (
|
|
2246
|
-
...state,
|
|
2247
|
-
grouping: checked ? [...state.grouping, field.id] : state.grouping.filter((id) => id !== field.id)
|
|
2248
|
-
})),
|
|
3554
|
+
onCheckedChange: () => send(DataTableMessage.GroupingToggled({ fieldId: field.id })),
|
|
2249
3555
|
children: field.label
|
|
2250
3556
|
}, field.id))
|
|
2251
3557
|
]
|
|
@@ -2254,13 +3560,13 @@ var DataTableToolbar = ({
|
|
|
2254
3560
|
]
|
|
2255
3561
|
}) : null,
|
|
2256
3562
|
features.sorting !== false ? /* @__PURE__ */ jsx15(SortMenu, {
|
|
2257
|
-
|
|
3563
|
+
table
|
|
2258
3564
|
}) : null,
|
|
2259
3565
|
features.gallery ? /* @__PURE__ */ jsx15(ViewMenu, {
|
|
2260
|
-
|
|
3566
|
+
table
|
|
2261
3567
|
}) : null,
|
|
2262
3568
|
features.columnVisibility !== false ? /* @__PURE__ */ jsx15(ColumnMenu, {
|
|
2263
|
-
|
|
3569
|
+
table
|
|
2264
3570
|
}) : null,
|
|
2265
3571
|
features.refresh ? /* @__PURE__ */ jsx15(MenubarMenu, {
|
|
2266
3572
|
children: /* @__PURE__ */ jsxs9(MenubarTrigger2, {
|
|
@@ -2341,18 +3647,12 @@ var DataTableToolbar = ({
|
|
|
2341
3647
|
}),
|
|
2342
3648
|
exportFeature && exportFailed ? /* @__PURE__ */ jsx15("p", {
|
|
2343
3649
|
role: "alert",
|
|
2344
|
-
className: "text-destructive
|
|
3650
|
+
className: "text-destructive basis-full text-sm",
|
|
2345
3651
|
children: labels.exportFailed ?? dataTableMessages(store.config.locale).exportFailed
|
|
2346
3652
|
}) : null
|
|
2347
3653
|
]
|
|
2348
3654
|
});
|
|
2349
3655
|
};
|
|
2350
|
-
var withColumnFilter = (state, id, filter) => {
|
|
2351
|
-
const filters = (state.filters ?? []).filter((current) => current.id !== id);
|
|
2352
|
-
if (filter)
|
|
2353
|
-
filters.push(filter);
|
|
2354
|
-
return { ...state, page: 0, filters: filters.length ? filters : undefined };
|
|
2355
|
-
};
|
|
2356
3656
|
var FilterEditor = ({
|
|
2357
3657
|
column,
|
|
2358
3658
|
rows,
|
|
@@ -2362,20 +3662,19 @@ var FilterEditor = ({
|
|
|
2362
3662
|
}) => {
|
|
2363
3663
|
const inputId = useId2();
|
|
2364
3664
|
const kind = getDataTableFilterKind(column);
|
|
2365
|
-
const [
|
|
2366
|
-
const
|
|
2367
|
-
const [operator, setOperator] = useState(current?.kind === "text" ? current.operator : "contains");
|
|
3665
|
+
const [draft, setDraft] = useState2(() => tableFilterDraft(column.id, current));
|
|
3666
|
+
const { primary, secondary, operator } = draft;
|
|
2368
3667
|
const operatorOptions = [
|
|
2369
3668
|
{ value: "contains", label: labels.filterContains },
|
|
2370
3669
|
{ value: "equals", label: labels.filterEquals },
|
|
2371
3670
|
{ value: "startsWith", label: labels.filterStartsWith },
|
|
2372
3671
|
{ value: "endsWith", label: labels.filterEndsWith }
|
|
2373
3672
|
];
|
|
2374
|
-
const [invalid, setInvalid] =
|
|
2375
|
-
const [optionSearch, setOptionSearch] =
|
|
3673
|
+
const [invalid, setInvalid] = useState2(false);
|
|
3674
|
+
const [optionSearch, setOptionSearch] = useState2("");
|
|
2376
3675
|
const apply = (candidate) => {
|
|
2377
|
-
const decoded =
|
|
2378
|
-
if (
|
|
3676
|
+
const decoded = parseTableFilterDraft(kind, candidate);
|
|
3677
|
+
if (Option4.isNone(decoded)) {
|
|
2379
3678
|
setInvalid(true);
|
|
2380
3679
|
return;
|
|
2381
3680
|
}
|
|
@@ -2387,7 +3686,7 @@ var FilterEditor = ({
|
|
|
2387
3686
|
children: [
|
|
2388
3687
|
/* @__PURE__ */ jsxs9(MenubarRadioGroup, {
|
|
2389
3688
|
value: current?.kind === "boolean" ? String(current.value) : "",
|
|
2390
|
-
onValueChange: (value) => apply({
|
|
3689
|
+
onValueChange: (value) => apply({ ...draft, primary: value }),
|
|
2391
3690
|
children: [
|
|
2392
3691
|
/* @__PURE__ */ jsx15(MenubarRadioItem2, {
|
|
2393
3692
|
value: "true",
|
|
@@ -2433,9 +3732,9 @@ var FilterEditor = ({
|
|
|
2433
3732
|
checked: selected.includes(option.value),
|
|
2434
3733
|
closeOnClick: false,
|
|
2435
3734
|
onCheckedChange: (checked) => {
|
|
2436
|
-
const values =
|
|
3735
|
+
const values = updateSelectedRows(selected, [option.value], checked);
|
|
2437
3736
|
if (values.length)
|
|
2438
|
-
apply({
|
|
3737
|
+
apply({ ...draft, values });
|
|
2439
3738
|
else
|
|
2440
3739
|
onChange(undefined);
|
|
2441
3740
|
},
|
|
@@ -2472,29 +3771,7 @@ var FilterEditor = ({
|
|
|
2472
3771
|
},
|
|
2473
3772
|
onSubmit: (event) => {
|
|
2474
3773
|
event.preventDefault();
|
|
2475
|
-
|
|
2476
|
-
apply({ id: column.id, kind, operator, value: primary.trim() });
|
|
2477
|
-
else if (kind === "date") {
|
|
2478
|
-
const draft = { id: column.id, kind };
|
|
2479
|
-
if (primary)
|
|
2480
|
-
draft.from = primary;
|
|
2481
|
-
if (secondary)
|
|
2482
|
-
draft.to = secondary;
|
|
2483
|
-
apply(draft);
|
|
2484
|
-
} else {
|
|
2485
|
-
const min = primary ? Schema2.decodeOption(Schema2.FiniteFromString)(primary) : Option2.some(undefined);
|
|
2486
|
-
const max = secondary ? Schema2.decodeOption(Schema2.FiniteFromString)(secondary) : Option2.some(undefined);
|
|
2487
|
-
if (Option2.isNone(min) || Option2.isNone(max)) {
|
|
2488
|
-
setInvalid(true);
|
|
2489
|
-
return;
|
|
2490
|
-
}
|
|
2491
|
-
const draft = { id: column.id, kind };
|
|
2492
|
-
if (min.value !== undefined)
|
|
2493
|
-
draft.min = min.value;
|
|
2494
|
-
if (max.value !== undefined)
|
|
2495
|
-
draft.max = max.value;
|
|
2496
|
-
apply(draft);
|
|
2497
|
-
}
|
|
3774
|
+
apply(draft);
|
|
2498
3775
|
},
|
|
2499
3776
|
children: [
|
|
2500
3777
|
/* @__PURE__ */ jsxs9(FieldGroup, {
|
|
@@ -2509,9 +3786,9 @@ var FilterEditor = ({
|
|
|
2509
3786
|
items: operatorOptions,
|
|
2510
3787
|
value: operator,
|
|
2511
3788
|
onValueChange: (value) => {
|
|
2512
|
-
const decoded =
|
|
2513
|
-
if (
|
|
2514
|
-
|
|
3789
|
+
const decoded = Schema6.decodeUnknownOption(TextFilterOperator)(value);
|
|
3790
|
+
if (Option4.isSome(decoded))
|
|
3791
|
+
setDraft({ ...draft, operator: decoded.value });
|
|
2515
3792
|
},
|
|
2516
3793
|
children: [
|
|
2517
3794
|
/* @__PURE__ */ jsx15(SelectTrigger, {
|
|
@@ -2544,7 +3821,7 @@ var FilterEditor = ({
|
|
|
2544
3821
|
value: primary,
|
|
2545
3822
|
"aria-invalid": invalid || undefined,
|
|
2546
3823
|
onChange: (event) => {
|
|
2547
|
-
|
|
3824
|
+
setDraft({ ...draft, primary: event.target.value });
|
|
2548
3825
|
setInvalid(false);
|
|
2549
3826
|
}
|
|
2550
3827
|
})
|
|
@@ -2564,7 +3841,7 @@ var FilterEditor = ({
|
|
|
2564
3841
|
value: secondary,
|
|
2565
3842
|
"aria-invalid": invalid || undefined,
|
|
2566
3843
|
onChange: (event) => {
|
|
2567
|
-
|
|
3844
|
+
setDraft({ ...draft, secondary: event.target.value });
|
|
2568
3845
|
setInvalid(false);
|
|
2569
3846
|
}
|
|
2570
3847
|
})
|
|
@@ -2590,8 +3867,7 @@ var FilterEditor = ({
|
|
|
2590
3867
|
size: "sm",
|
|
2591
3868
|
variant: "outline",
|
|
2592
3869
|
onClick: () => {
|
|
2593
|
-
|
|
2594
|
-
setSecondary("");
|
|
3870
|
+
setDraft({ ...draft, primary: "", secondary: "" });
|
|
2595
3871
|
setInvalid(false);
|
|
2596
3872
|
onChange(undefined);
|
|
2597
3873
|
},
|
|
@@ -2603,9 +3879,9 @@ var FilterEditor = ({
|
|
|
2603
3879
|
});
|
|
2604
3880
|
};
|
|
2605
3881
|
var FilterMenu = ({
|
|
2606
|
-
|
|
3882
|
+
table
|
|
2607
3883
|
}) => {
|
|
2608
|
-
const [store,
|
|
3884
|
+
const [store, send] = table;
|
|
2609
3885
|
const model = deriveModel(store);
|
|
2610
3886
|
const columns = model.columns.flatMap((parent) => getDataTableFilterColumns([parent]).map((column) => ({
|
|
2611
3887
|
column,
|
|
@@ -2614,7 +3890,7 @@ var FilterMenu = ({
|
|
|
2614
3890
|
if (!columns.length)
|
|
2615
3891
|
return null;
|
|
2616
3892
|
const filters = store.state.filters ?? [];
|
|
2617
|
-
const update = (id, filter) =>
|
|
3893
|
+
const update = (id, filter) => send(DataTableMessage.ColumnFilterChanged({ id, filter: filter ?? null }));
|
|
2618
3894
|
return /* @__PURE__ */ jsxs9(MenubarMenu, {
|
|
2619
3895
|
children: [
|
|
2620
3896
|
/* @__PURE__ */ jsxs9(MenubarTrigger2, {
|
|
@@ -2667,11 +3943,7 @@ var FilterMenu = ({
|
|
|
2667
3943
|
children: [
|
|
2668
3944
|
/* @__PURE__ */ jsx15(MenubarSeparator2, {}),
|
|
2669
3945
|
/* @__PURE__ */ jsxs9(MenubarItem2, {
|
|
2670
|
-
onClick: () =>
|
|
2671
|
-
...state,
|
|
2672
|
-
page: 0,
|
|
2673
|
-
filters: undefined
|
|
2674
|
-
})),
|
|
3946
|
+
onClick: () => send(DataTableMessage.FiltersCleared()),
|
|
2675
3947
|
children: [
|
|
2676
3948
|
/* @__PURE__ */ jsx15(X, {}),
|
|
2677
3949
|
store.config.labels.filtersClear
|
|
@@ -2686,9 +3958,9 @@ var FilterMenu = ({
|
|
|
2686
3958
|
});
|
|
2687
3959
|
};
|
|
2688
3960
|
var SortMenu = ({
|
|
2689
|
-
|
|
3961
|
+
table
|
|
2690
3962
|
}) => {
|
|
2691
|
-
const [store,
|
|
3963
|
+
const [store, send] = table;
|
|
2692
3964
|
const columns = deriveModel(store).columns.flatMap((column) => getDataTableSortColumns([column]).map((field) => field.id === column.id ? field : {
|
|
2693
3965
|
...field,
|
|
2694
3966
|
colDef: {
|
|
@@ -2699,11 +3971,7 @@ var SortMenu = ({
|
|
|
2699
3971
|
if (!columns.length)
|
|
2700
3972
|
return null;
|
|
2701
3973
|
const current = store.state.sort?.[0];
|
|
2702
|
-
const sort = (id, direction) =>
|
|
2703
|
-
...state,
|
|
2704
|
-
sort: [{ id, direction }],
|
|
2705
|
-
page: 0
|
|
2706
|
-
}));
|
|
3974
|
+
const sort = (id, direction) => send(DataTableMessage.SortRequested({ columnId: id, direction }));
|
|
2707
3975
|
return /* @__PURE__ */ jsxs9(MenubarMenu, {
|
|
2708
3976
|
children: [
|
|
2709
3977
|
/* @__PURE__ */ jsxs9(MenubarTrigger2, {
|
|
@@ -2757,9 +4025,9 @@ var SortMenu = ({
|
|
|
2757
4025
|
children: [
|
|
2758
4026
|
/* @__PURE__ */ jsx15(MenubarSeparator2, {}),
|
|
2759
4027
|
/* @__PURE__ */ jsxs9(MenubarItem2, {
|
|
2760
|
-
onClick: () =>
|
|
2761
|
-
|
|
2762
|
-
|
|
4028
|
+
onClick: () => send(DataTableMessage.SortRequested({
|
|
4029
|
+
columnId: column.id,
|
|
4030
|
+
direction: null
|
|
2763
4031
|
})),
|
|
2764
4032
|
children: [
|
|
2765
4033
|
/* @__PURE__ */ jsx15(X, {}),
|
|
@@ -2781,9 +4049,9 @@ var SortMenu = ({
|
|
|
2781
4049
|
});
|
|
2782
4050
|
};
|
|
2783
4051
|
var ViewMenu = ({
|
|
2784
|
-
|
|
4052
|
+
table
|
|
2785
4053
|
}) => {
|
|
2786
|
-
const [store,
|
|
4054
|
+
const [store, send] = table;
|
|
2787
4055
|
return /* @__PURE__ */ jsxs9(MenubarMenu, {
|
|
2788
4056
|
children: [
|
|
2789
4057
|
/* @__PURE__ */ jsxs9(MenubarTrigger2, {
|
|
@@ -2806,12 +4074,9 @@ var ViewMenu = ({
|
|
|
2806
4074
|
/* @__PURE__ */ jsx15(MenubarSeparator2, {}),
|
|
2807
4075
|
/* @__PURE__ */ jsxs9(MenubarRadioGroup, {
|
|
2808
4076
|
onValueChange: (input) => {
|
|
2809
|
-
const view =
|
|
2810
|
-
if (
|
|
2811
|
-
|
|
2812
|
-
...state,
|
|
2813
|
-
view: view.value
|
|
2814
|
-
}));
|
|
4077
|
+
const view = Schema6.decodeUnknownOption(DataTableViewSchema)(input);
|
|
4078
|
+
if (Option4.isSome(view)) {
|
|
4079
|
+
send(DataTableMessage.ViewPicked({ view: view.value }));
|
|
2815
4080
|
}
|
|
2816
4081
|
},
|
|
2817
4082
|
value: store.state.view,
|
|
@@ -2841,9 +4106,9 @@ var ViewMenu = ({
|
|
|
2841
4106
|
});
|
|
2842
4107
|
};
|
|
2843
4108
|
var ColumnMenu = ({
|
|
2844
|
-
|
|
4109
|
+
table
|
|
2845
4110
|
}) => {
|
|
2846
|
-
const [store,
|
|
4111
|
+
const [store, send] = table;
|
|
2847
4112
|
const columns = deriveModel(store).columns.filter(({ colDef }) => colDef.hideable !== false);
|
|
2848
4113
|
if (!columns.length)
|
|
2849
4114
|
return null;
|
|
@@ -2869,13 +4134,7 @@ var ColumnMenu = ({
|
|
|
2869
4134
|
/* @__PURE__ */ jsx15(MenubarSeparator2, {}),
|
|
2870
4135
|
columns.map((column) => /* @__PURE__ */ jsx15(MenubarCheckboxItem2, {
|
|
2871
4136
|
checked: store.state.columnVisibility[column.id] !== false,
|
|
2872
|
-
onCheckedChange: (visible) =>
|
|
2873
|
-
...state,
|
|
2874
|
-
columnVisibility: {
|
|
2875
|
-
...state.columnVisibility,
|
|
2876
|
-
[column.id]: visible
|
|
2877
|
-
}
|
|
2878
|
-
})),
|
|
4137
|
+
onCheckedChange: (visible) => send(DataTableMessage.ColumnVisibilityChanged({ id: column.id, visible })),
|
|
2879
4138
|
children: columnLabel(column)
|
|
2880
4139
|
}, column.id))
|
|
2881
4140
|
]
|
|
@@ -2885,54 +4144,43 @@ var ColumnMenu = ({
|
|
|
2885
4144
|
});
|
|
2886
4145
|
};
|
|
2887
4146
|
var ResizeHandle = ({
|
|
2888
|
-
|
|
4147
|
+
table
|
|
2889
4148
|
}) => {
|
|
2890
|
-
const
|
|
4149
|
+
const tableClasses = useContext2(DataTableSlotClassesContext);
|
|
4150
|
+
const [store, send] = table;
|
|
2891
4151
|
const columnId = useRequiredId(ColumnIdContext);
|
|
2892
|
-
const resizeRef = useRef(null);
|
|
2893
4152
|
const column = deriveModel(store).columns.find(({ id }) => id === columnId);
|
|
2894
4153
|
if (!column || column.colDef.resizable === false)
|
|
2895
4154
|
return null;
|
|
2896
|
-
const
|
|
2897
|
-
...state,
|
|
2898
|
-
columnSizing: {
|
|
2899
|
-
...state.columnSizing,
|
|
2900
|
-
[column.id]: clampWidth(column.colDef, width)
|
|
2901
|
-
}
|
|
2902
|
-
}));
|
|
4155
|
+
const { min, max } = tableColumnLimits(column.colDef);
|
|
2903
4156
|
const onPointerDown = (event) => {
|
|
2904
4157
|
if (event.button !== 0)
|
|
2905
4158
|
return;
|
|
2906
4159
|
event.preventDefault();
|
|
2907
4160
|
event.currentTarget.setPointerCapture(event.pointerId);
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
};
|
|
4161
|
+
send(DataTableMessage.ResizeStarted({
|
|
4162
|
+
id: column.id,
|
|
4163
|
+
x: event.clientX,
|
|
4164
|
+
pointerId: event.pointerId
|
|
4165
|
+
}));
|
|
2913
4166
|
};
|
|
2914
4167
|
const onPointerMove = (event) => {
|
|
2915
|
-
|
|
2916
|
-
if (!drag || drag.pointerId !== event.pointerId)
|
|
2917
|
-
return;
|
|
2918
|
-
resize(drag.startWidth + event.clientX - drag.startX);
|
|
2919
|
-
};
|
|
2920
|
-
const reset = () => {
|
|
2921
|
-
resizeRef.current = null;
|
|
4168
|
+
send(DataTableMessage.ResizeMoved({ x: event.clientX, pointerId: event.pointerId }));
|
|
2922
4169
|
};
|
|
4170
|
+
const reset = (event) => send(DataTableMessage.ResizeEnded({ pointerId: event.pointerId }));
|
|
2923
4171
|
return /* @__PURE__ */ jsx15("button", {
|
|
2924
4172
|
"aria-label": store.config.labels.resizeColumn(columnLabel(column)),
|
|
2925
4173
|
"aria-orientation": "vertical",
|
|
2926
|
-
"aria-valuemax":
|
|
2927
|
-
"aria-valuemin":
|
|
4174
|
+
"aria-valuemax": max,
|
|
4175
|
+
"aria-valuemin": min,
|
|
2928
4176
|
"aria-valuenow": column.width,
|
|
2929
|
-
className:
|
|
2930
|
-
onDoubleClick: () =>
|
|
4177
|
+
className: tableClasses.resizeHandle,
|
|
4178
|
+
onDoubleClick: () => send(DataTableMessage.ColumnResizeReset({ id: column.id })),
|
|
2931
4179
|
onKeyDown: (event) => {
|
|
2932
|
-
const delta = event.key
|
|
4180
|
+
const delta = tableResizeStep(event.key);
|
|
2933
4181
|
if (delta) {
|
|
2934
4182
|
event.preventDefault();
|
|
2935
|
-
|
|
4183
|
+
send(DataTableMessage.ColumnResized({ id: column.id, delta }));
|
|
2936
4184
|
}
|
|
2937
4185
|
},
|
|
2938
4186
|
onPointerDown,
|
|
@@ -2945,12 +4193,12 @@ var ResizeHandle = ({
|
|
|
2945
4193
|
});
|
|
2946
4194
|
};
|
|
2947
4195
|
var DragHandle = ({
|
|
2948
|
-
|
|
4196
|
+
table
|
|
2949
4197
|
}) => {
|
|
2950
|
-
const [store
|
|
4198
|
+
const [store] = table;
|
|
2951
4199
|
const rowId = useRequiredId(RowIdContext);
|
|
2952
|
-
const dragRef =
|
|
2953
|
-
const [overlay, setOverlay] =
|
|
4200
|
+
const dragRef = useRef2(null);
|
|
4201
|
+
const [overlay, setOverlay] = useState2(null);
|
|
2954
4202
|
const reset = (element) => {
|
|
2955
4203
|
clearDragPresentation(element.closest("[data-table-root]"));
|
|
2956
4204
|
dragRef.current = null;
|
|
@@ -3005,7 +4253,8 @@ var DragHandle = ({
|
|
|
3005
4253
|
const elements = document.elementsFromPoint(event.clientX, event.clientY);
|
|
3006
4254
|
const rowTarget = findTableDragTarget(elements, "[data-table-row]", root);
|
|
3007
4255
|
const groupTarget = findTableDragTarget(elements, "[data-table-group]", root);
|
|
3008
|
-
|
|
4256
|
+
if (drag.active) {
|
|
4257
|
+
const current = store;
|
|
3009
4258
|
const targetRowId = rowTarget?.dataset.tableRow;
|
|
3010
4259
|
const targetGroupKey = groupTarget?.dataset.tableGroup;
|
|
3011
4260
|
const model = deriveModel(current);
|
|
@@ -3021,8 +4270,7 @@ var DragHandle = ({
|
|
|
3021
4270
|
} else if (drag.active && source && targetRowId && reordering && canReorderRows(current) && source.id !== targetRowId) {
|
|
3022
4271
|
reordering.onReorder(reorderDataTableRows(model.rows, source.id, targetRowId));
|
|
3023
4272
|
}
|
|
3024
|
-
|
|
3025
|
-
});
|
|
4273
|
+
}
|
|
3026
4274
|
reset(event.currentTarget);
|
|
3027
4275
|
};
|
|
3028
4276
|
const cancel = (event) => {
|
|
@@ -3073,22 +4321,15 @@ var DragHandle = ({
|
|
|
3073
4321
|
]
|
|
3074
4322
|
});
|
|
3075
4323
|
};
|
|
3076
|
-
var toggleRow = (
|
|
3077
|
-
const rowSelection = { ...state.rowSelection, [rowId]: selected };
|
|
3078
|
-
const selection = store.config.features.selection;
|
|
3079
|
-
if (selection) {
|
|
3080
|
-
const model = deriveModel(store);
|
|
3081
|
-
selection.onSelectionChange?.(model.rows.filter((row) => rowSelection[row.id]).map((row) => row.data));
|
|
3082
|
-
}
|
|
3083
|
-
return { ...state, rowSelection };
|
|
3084
|
-
});
|
|
4324
|
+
var toggleRow = (send, rowId, checked) => send(DataTableMessage.SelectionRequested({ rowIds: [rowId], checked }));
|
|
3085
4325
|
var TableDataRow = ({
|
|
3086
|
-
|
|
4326
|
+
table,
|
|
3087
4327
|
row,
|
|
3088
4328
|
virtualIndex,
|
|
3089
4329
|
measureRef
|
|
3090
4330
|
}) => {
|
|
3091
|
-
const
|
|
4331
|
+
const tableClasses = useContext2(DataTableSlotClassesContext);
|
|
4332
|
+
const [store, send] = table;
|
|
3092
4333
|
const model = deriveModel(store);
|
|
3093
4334
|
const selection = store.config.features.selection;
|
|
3094
4335
|
const selectable = !!selection && (selection.isRowSelectable?.(row.data) ?? true);
|
|
@@ -3110,37 +4351,40 @@ var TableDataRow = ({
|
|
|
3110
4351
|
tabIndex: store.config.onRowClicked ? 0 : undefined,
|
|
3111
4352
|
children: [
|
|
3112
4353
|
selection ? /* @__PURE__ */ jsx15(TableCell2, {
|
|
3113
|
-
className:
|
|
4354
|
+
className: tableClasses.selectionCell,
|
|
3114
4355
|
onClick: (event) => event.stopPropagation(),
|
|
3115
|
-
children: /* @__PURE__ */ jsx15(
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
4356
|
+
children: /* @__PURE__ */ jsx15("div", {
|
|
4357
|
+
className: tableClasses.selectionCenter,
|
|
4358
|
+
children: /* @__PURE__ */ jsx15(Checkbox, {
|
|
4359
|
+
"aria-label": store.config.labels.selectRow,
|
|
4360
|
+
checked: !!store.state.rowSelection[row.id],
|
|
4361
|
+
disabled: !selectable,
|
|
4362
|
+
onCheckedChange: (checked) => toggleRow(send, row.id, checked)
|
|
4363
|
+
})
|
|
3120
4364
|
})
|
|
3121
4365
|
}) : null,
|
|
3122
4366
|
draggable ? /* @__PURE__ */ jsx15(TableCell2, {
|
|
3123
4367
|
className: "w-10 pr-0",
|
|
3124
4368
|
children: /* @__PURE__ */ jsx15(DragHandle, {
|
|
3125
|
-
|
|
4369
|
+
table
|
|
3126
4370
|
})
|
|
3127
4371
|
}) : null,
|
|
3128
4372
|
model.visibleColumns.map((column) => /* @__PURE__ */ jsx15(TableCell2, {
|
|
3129
|
-
className: cn("min-w-24
|
|
4373
|
+
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"),
|
|
3130
4374
|
style: { width: column.width },
|
|
3131
4375
|
children: /* @__PURE__ */ jsx15("div", {
|
|
3132
|
-
className: cn(
|
|
4376
|
+
className: cn(tableClasses.cellContent, column.colDef.truncate && "truncate"),
|
|
3133
4377
|
children: renderCell(row, column, store.config.locale, store.config.labels)
|
|
3134
4378
|
})
|
|
3135
4379
|
}, column.id)),
|
|
3136
4380
|
hasRowActionMenu(store) ? /* @__PURE__ */ jsx15(TableCell2, {
|
|
3137
|
-
className: "
|
|
4381
|
+
className: cn(tableClasses.actionsCell, "group-data-[state=selected]/row:bg-muted"),
|
|
3138
4382
|
onClick: (event) => event.stopPropagation(),
|
|
3139
4383
|
children: /* @__PURE__ */ jsx15("div", {
|
|
3140
|
-
className:
|
|
4384
|
+
className: tableClasses.actionsAlign,
|
|
3141
4385
|
children: /* @__PURE__ */ jsx15(DataTableRowActionMenu, {
|
|
3142
4386
|
row,
|
|
3143
|
-
|
|
4387
|
+
table
|
|
3144
4388
|
})
|
|
3145
4389
|
})
|
|
3146
4390
|
}) : null
|
|
@@ -3190,35 +4434,30 @@ var GroupActions = ({
|
|
|
3190
4434
|
});
|
|
3191
4435
|
};
|
|
3192
4436
|
var GroupHeaderRow = ({
|
|
3193
|
-
|
|
4437
|
+
table,
|
|
3194
4438
|
section,
|
|
3195
4439
|
colSpan,
|
|
3196
4440
|
virtualIndex,
|
|
3197
4441
|
measureRef
|
|
3198
4442
|
}) => {
|
|
3199
|
-
const
|
|
4443
|
+
const tableClasses = useContext2(DataTableSlotClassesContext);
|
|
4444
|
+
const [store, send] = table;
|
|
3200
4445
|
const collapsed = !!store.state.collapsedGroups[section.key];
|
|
3201
4446
|
return /* @__PURE__ */ jsx15(TableRow2, {
|
|
3202
4447
|
ref: measureRef,
|
|
3203
4448
|
"data-index": virtualIndex,
|
|
3204
4449
|
"aria-rowindex": virtualIndex === undefined ? undefined : virtualIndex + 2,
|
|
3205
|
-
className: "
|
|
3206
|
-
onClick: () =>
|
|
3207
|
-
...state,
|
|
3208
|
-
collapsedGroups: {
|
|
3209
|
-
...state.collapsedGroups,
|
|
3210
|
-
[section.key]: !collapsed
|
|
3211
|
-
}
|
|
3212
|
-
})),
|
|
4450
|
+
className: cn(tableClasses.group, "cursor-pointer"),
|
|
4451
|
+
onClick: () => send(DataTableMessage.GroupToggled({ key: section.key })),
|
|
3213
4452
|
children: /* @__PURE__ */ jsx15(TableCell2, {
|
|
3214
4453
|
className: "p-0",
|
|
3215
4454
|
colSpan,
|
|
3216
4455
|
children: /* @__PURE__ */ jsxs9("div", {
|
|
3217
|
-
className:
|
|
4456
|
+
className: cn(tableClasses.groupContent, tableClasses.groupSticky),
|
|
3218
4457
|
children: [
|
|
3219
4458
|
/* @__PURE__ */ jsxs9("button", {
|
|
3220
4459
|
"aria-expanded": !collapsed,
|
|
3221
|
-
className:
|
|
4460
|
+
className: tableClasses.groupTrigger,
|
|
3222
4461
|
style: { paddingLeft: section.depth * 20 },
|
|
3223
4462
|
type: "button",
|
|
3224
4463
|
children: [
|
|
@@ -3233,9 +4472,8 @@ var GroupHeaderRow = ({
|
|
|
3233
4472
|
})
|
|
3234
4473
|
]
|
|
3235
4474
|
}),
|
|
3236
|
-
/* @__PURE__ */ jsx15(
|
|
3237
|
-
className:
|
|
3238
|
-
variant: "secondary",
|
|
4475
|
+
/* @__PURE__ */ jsx15("span", {
|
|
4476
|
+
className: tableClasses.count,
|
|
3239
4477
|
children: section.rows.length
|
|
3240
4478
|
}),
|
|
3241
4479
|
/* @__PURE__ */ jsx15(GroupActions, {
|
|
@@ -3249,10 +4487,10 @@ var GroupHeaderRow = ({
|
|
|
3249
4487
|
});
|
|
3250
4488
|
};
|
|
3251
4489
|
var GroupedTable = ({
|
|
3252
|
-
|
|
4490
|
+
table,
|
|
3253
4491
|
sections
|
|
3254
4492
|
}) => {
|
|
3255
|
-
const [store] =
|
|
4493
|
+
const [store] = table;
|
|
3256
4494
|
const model = deriveModel(store);
|
|
3257
4495
|
const extra = (store.config.features.selection ? 1 : 0) + (hasRowActionMenu(store) ? 1 : 0) + (canDragRows(store) ? 1 : 0);
|
|
3258
4496
|
const renderSections = (items) => items.flatMap((section) => {
|
|
@@ -3263,7 +4501,7 @@ var GroupedTable = ({
|
|
|
3263
4501
|
"data-table-group": section.field.onMoveToGroup ? targetKey : undefined,
|
|
3264
4502
|
children: [
|
|
3265
4503
|
/* @__PURE__ */ jsx15(GroupHeaderRow, {
|
|
3266
|
-
|
|
4504
|
+
table,
|
|
3267
4505
|
section,
|
|
3268
4506
|
colSpan: model.visibleColumns.length + extra
|
|
3269
4507
|
}),
|
|
@@ -3271,7 +4509,7 @@ var GroupedTable = ({
|
|
|
3271
4509
|
value: row.id,
|
|
3272
4510
|
children: /* @__PURE__ */ jsx15(TableDataRow, {
|
|
3273
4511
|
row,
|
|
3274
|
-
|
|
4512
|
+
table
|
|
3275
4513
|
})
|
|
3276
4514
|
}, `${section.key}:${row.id}`)) : [
|
|
3277
4515
|
/* @__PURE__ */ jsx15(TableRow2, {
|
|
@@ -3291,9 +4529,10 @@ var GroupedTable = ({
|
|
|
3291
4529
|
});
|
|
3292
4530
|
};
|
|
3293
4531
|
var ColumnHeaderMenu = ({
|
|
3294
|
-
|
|
4532
|
+
table
|
|
3295
4533
|
}) => {
|
|
3296
|
-
const
|
|
4534
|
+
const tableClasses = useContext2(DataTableSlotClassesContext);
|
|
4535
|
+
const [store, send] = table;
|
|
3297
4536
|
const columnId = useRequiredId(ColumnIdContext);
|
|
3298
4537
|
const model = deriveModel(store);
|
|
3299
4538
|
const column = model.columns.find(({ id }) => id === columnId);
|
|
@@ -3309,18 +4548,13 @@ var ColumnHeaderMenu = ({
|
|
|
3309
4548
|
rows: model.rows,
|
|
3310
4549
|
current: store.state.filters?.find((filter) => filter.id === field.id),
|
|
3311
4550
|
labels: store.config.labels,
|
|
3312
|
-
onChange: (filter) =>
|
|
4551
|
+
onChange: (filter) => send(DataTableMessage.ColumnFilterChanged({ id: field.id, filter: filter ?? null }))
|
|
3313
4552
|
});
|
|
3314
4553
|
const sortingEnabled = store.config.features.sorting !== false && sortColumns.length > 0;
|
|
3315
4554
|
const hidingEnabled = store.config.features.columnVisibility !== false && column.colDef.hideable !== false;
|
|
3316
4555
|
const ownsSort = (id) => id === column.id || sortColumns.some((field) => field.id === id);
|
|
3317
4556
|
const sort = store.state.sort?.find(({ id }) => ownsSort(id));
|
|
3318
|
-
const
|
|
3319
|
-
const setSort = (id, direction) => update((state) => ({
|
|
3320
|
-
...state,
|
|
3321
|
-
sort: [{ id, direction }],
|
|
3322
|
-
page: 0
|
|
3323
|
-
}));
|
|
4557
|
+
const setSort = (id, direction) => send(DataTableMessage.SortRequested({ columnId: id, direction }));
|
|
3324
4558
|
const label = columnLabel(column);
|
|
3325
4559
|
const sortItems = (field) => /* @__PURE__ */ jsxs9(Fragment, {
|
|
3326
4560
|
children: [
|
|
@@ -3354,7 +4588,7 @@ var ColumnHeaderMenu = ({
|
|
|
3354
4588
|
render: /* @__PURE__ */ jsxs9(Button, {
|
|
3355
4589
|
"aria-label": label,
|
|
3356
4590
|
"aria-description": activeFilters.length ? `${store.config.labels.filters}: ${activeFilters.length}` : undefined,
|
|
3357
|
-
className:
|
|
4591
|
+
className: tableClasses.headerTrigger,
|
|
3358
4592
|
variant: "ghost",
|
|
3359
4593
|
children: [
|
|
3360
4594
|
/* @__PURE__ */ jsx15("span", {
|
|
@@ -3386,10 +4620,7 @@ var ColumnHeaderMenu = ({
|
|
|
3386
4620
|
]
|
|
3387
4621
|
}, field.id)) : sortItems(column),
|
|
3388
4622
|
sort ? /* @__PURE__ */ jsxs9(DropdownMenuItem2, {
|
|
3389
|
-
onClick: () =>
|
|
3390
|
-
...state,
|
|
3391
|
-
sort: state.sort?.filter(({ id }) => !ownsSort(id))
|
|
3392
|
-
})),
|
|
4623
|
+
onClick: () => send(DataTableMessage.ColumnSortCleared({ id: column.id })),
|
|
3393
4624
|
children: [
|
|
3394
4625
|
/* @__PURE__ */ jsx15(X, {}),
|
|
3395
4626
|
" ",
|
|
@@ -3431,14 +4662,7 @@ var ColumnHeaderMenu = ({
|
|
|
3431
4662
|
]
|
|
3432
4663
|
}),
|
|
3433
4664
|
activeFilters.length ? /* @__PURE__ */ jsxs9(DropdownMenuItem2, {
|
|
3434
|
-
onClick: () =>
|
|
3435
|
-
const filters = state.filters?.filter(({ id }) => !ownsFilter(id));
|
|
3436
|
-
return {
|
|
3437
|
-
...state,
|
|
3438
|
-
page: 0,
|
|
3439
|
-
filters: filters?.length ? filters : undefined
|
|
3440
|
-
};
|
|
3441
|
-
}),
|
|
4665
|
+
onClick: () => send(DataTableMessage.ColumnFiltersCleared({ id: column.id })),
|
|
3442
4666
|
children: [
|
|
3443
4667
|
/* @__PURE__ */ jsx15(X, {}),
|
|
3444
4668
|
store.config.labels.filterClear
|
|
@@ -3448,12 +4672,9 @@ var ColumnHeaderMenu = ({
|
|
|
3448
4672
|
}) : null,
|
|
3449
4673
|
(sortingEnabled || filteringEnabled) && hidingEnabled ? /* @__PURE__ */ jsx15(DropdownMenuSeparator2, {}) : null,
|
|
3450
4674
|
hidingEnabled ? /* @__PURE__ */ jsxs9(DropdownMenuItem2, {
|
|
3451
|
-
onClick: () =>
|
|
3452
|
-
|
|
3453
|
-
|
|
3454
|
-
...state.columnVisibility,
|
|
3455
|
-
[column.id]: false
|
|
3456
|
-
}
|
|
4675
|
+
onClick: () => send(DataTableMessage.ColumnVisibilityChanged({
|
|
4676
|
+
id: column.id,
|
|
4677
|
+
visible: false
|
|
3457
4678
|
})),
|
|
3458
4679
|
children: [
|
|
3459
4680
|
/* @__PURE__ */ jsx15(EyeOff, {}),
|
|
@@ -3468,36 +4689,37 @@ var ColumnHeaderMenu = ({
|
|
|
3468
4689
|
});
|
|
3469
4690
|
};
|
|
3470
4691
|
var DataTableHeader = ({
|
|
3471
|
-
|
|
4692
|
+
table,
|
|
3472
4693
|
sticky
|
|
3473
4694
|
}) => {
|
|
3474
|
-
const
|
|
4695
|
+
const tableClasses = useContext2(DataTableSlotClassesContext);
|
|
4696
|
+
const [store, send] = table;
|
|
3475
4697
|
const model = deriveModel(store);
|
|
3476
4698
|
const selection = store.config.features.selection;
|
|
3477
|
-
const grouped = getActiveGrouping(store).length > 0;
|
|
3478
4699
|
const draggable = canDragRows(store);
|
|
3479
|
-
const selectableRows =
|
|
4700
|
+
const selectableRows = model.pageRows.filter((row) => !selection || (selection.isRowSelectable?.(row.data) ?? true));
|
|
3480
4701
|
const allSelected = selectableRows.length > 0 && selectableRows.every((row) => store.state.rowSelection[row.id]);
|
|
3481
4702
|
const someSelected = selectableRows.some((row) => store.state.rowSelection[row.id]);
|
|
3482
4703
|
return /* @__PURE__ */ jsx15(TableHeader2, {
|
|
3483
|
-
className: sticky ?
|
|
4704
|
+
className: sticky ? cn(tableClasses.stickyHeader, tableClasses.stickyHeaderRule, "[&_tr]:border-b-0") : undefined,
|
|
3484
4705
|
children: /* @__PURE__ */ jsxs9(TableRow2, {
|
|
3485
4706
|
"aria-rowindex": sticky ? 1 : undefined,
|
|
3486
4707
|
children: [
|
|
3487
4708
|
selection ? /* @__PURE__ */ jsx15(TableHead2, {
|
|
3488
|
-
className:
|
|
3489
|
-
children: /* @__PURE__ */ jsx15(
|
|
3490
|
-
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
|
|
3497
|
-
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
4709
|
+
className: tableClasses.selectionCell,
|
|
4710
|
+
children: /* @__PURE__ */ jsx15("div", {
|
|
4711
|
+
className: tableClasses.selectionCenter,
|
|
4712
|
+
children: /* @__PURE__ */ jsx15(Checkbox, {
|
|
4713
|
+
"aria-label": store.config.labels.selectAllRows,
|
|
4714
|
+
checked: allSelected,
|
|
4715
|
+
indeterminate: someSelected && !allSelected,
|
|
4716
|
+
onCheckedChange: (checked) => {
|
|
4717
|
+
send(DataTableMessage.SelectionRequested({
|
|
4718
|
+
rowIds: selectableRows.map(({ id }) => id),
|
|
4719
|
+
checked
|
|
4720
|
+
}));
|
|
4721
|
+
}
|
|
4722
|
+
})
|
|
3501
4723
|
})
|
|
3502
4724
|
}) : null,
|
|
3503
4725
|
draggable ? /* @__PURE__ */ jsx15(TableHead2, {
|
|
@@ -3507,17 +4729,17 @@ var DataTableHeader = ({
|
|
|
3507
4729
|
const direction = store.state.sort?.find(({ id }) => id === column.id)?.direction;
|
|
3508
4730
|
return /* @__PURE__ */ jsx15(TableHead2, {
|
|
3509
4731
|
"aria-sort": direction === "asc" ? "ascending" : direction === "desc" ? "descending" : undefined,
|
|
3510
|
-
className:
|
|
4732
|
+
className: tableClasses.header,
|
|
3511
4733
|
scope: "col",
|
|
3512
4734
|
style: { width: column.width },
|
|
3513
4735
|
children: /* @__PURE__ */ jsxs9(ColumnIdContext.Provider, {
|
|
3514
4736
|
value: column.id,
|
|
3515
4737
|
children: [
|
|
3516
4738
|
/* @__PURE__ */ jsx15(ColumnHeaderMenu, {
|
|
3517
|
-
|
|
4739
|
+
table
|
|
3518
4740
|
}),
|
|
3519
4741
|
/* @__PURE__ */ jsx15(ResizeHandle, {
|
|
3520
|
-
|
|
4742
|
+
table
|
|
3521
4743
|
})
|
|
3522
4744
|
]
|
|
3523
4745
|
})
|
|
@@ -3531,13 +4753,13 @@ var DataTableHeader = ({
|
|
|
3531
4753
|
});
|
|
3532
4754
|
};
|
|
3533
4755
|
var VirtualTableRows = ({
|
|
3534
|
-
|
|
4756
|
+
table,
|
|
3535
4757
|
rows,
|
|
3536
4758
|
sections,
|
|
3537
4759
|
viewport,
|
|
3538
4760
|
colSpan
|
|
3539
4761
|
}) => {
|
|
3540
|
-
const [{ state, config }] =
|
|
4762
|
+
const [{ state, config }] = table;
|
|
3541
4763
|
const { element: scrollElement, headerHeight } = viewport;
|
|
3542
4764
|
const pageScroll = viewport.options.scroll === "page";
|
|
3543
4765
|
const scrollMargin = viewport.pageOffset ?? headerHeight;
|
|
@@ -3569,7 +4791,7 @@ var VirtualTableRows = ({
|
|
|
3569
4791
|
result.push({ key: `row:${row.id}`, kind: "data", row });
|
|
3570
4792
|
return result;
|
|
3571
4793
|
}, [rows, sections, state.collapsedGroups]);
|
|
3572
|
-
|
|
4794
|
+
useLayoutEffect2(() => {
|
|
3573
4795
|
if (!pageScroll && scrollElement)
|
|
3574
4796
|
scrollElement.scrollTop = 0;
|
|
3575
4797
|
}, [
|
|
@@ -3584,7 +4806,7 @@ var VirtualTableRows = ({
|
|
|
3584
4806
|
]);
|
|
3585
4807
|
const options = {
|
|
3586
4808
|
count: entries.length,
|
|
3587
|
-
getItemKey:
|
|
4809
|
+
getItemKey: useCallback2((index) => entries[index].key, [entries]),
|
|
3588
4810
|
estimateSize: () => viewport.options.estimateRowHeight ?? 64,
|
|
3589
4811
|
overscan: viewport.options.overscan ?? 5,
|
|
3590
4812
|
scrollMargin
|
|
@@ -3622,7 +4844,7 @@ var VirtualTableRows = ({
|
|
|
3622
4844
|
return /* @__PURE__ */ jsx15(TableDataRow, {
|
|
3623
4845
|
measureRef: virtualizer.measureElement,
|
|
3624
4846
|
row: entry.row,
|
|
3625
|
-
|
|
4847
|
+
table,
|
|
3626
4848
|
virtualIndex: index
|
|
3627
4849
|
}, key);
|
|
3628
4850
|
if (entry.kind === "header")
|
|
@@ -3630,7 +4852,7 @@ var VirtualTableRows = ({
|
|
|
3630
4852
|
measureRef: virtualizer.measureElement,
|
|
3631
4853
|
section: entry.section,
|
|
3632
4854
|
colSpan,
|
|
3633
|
-
|
|
4855
|
+
table,
|
|
3634
4856
|
virtualIndex: index
|
|
3635
4857
|
}, key);
|
|
3636
4858
|
return /* @__PURE__ */ jsx15(TableRow2, {
|
|
@@ -3649,21 +4871,20 @@ var VirtualTableRows = ({
|
|
|
3649
4871
|
});
|
|
3650
4872
|
};
|
|
3651
4873
|
var DataTableBody = ({
|
|
3652
|
-
|
|
4874
|
+
table,
|
|
3653
4875
|
viewport
|
|
3654
4876
|
}) => {
|
|
3655
|
-
const styles =
|
|
3656
|
-
const [store] =
|
|
4877
|
+
const styles = useContext2(DataTableStylesContext);
|
|
4878
|
+
const [store] = table;
|
|
3657
4879
|
const model = deriveModel(store);
|
|
3658
4880
|
const fields = getActiveGrouping(store);
|
|
3659
|
-
const
|
|
3660
|
-
const rows = grouped ? model.sortedRows : model.pageRows;
|
|
4881
|
+
const rows = model.pageRows;
|
|
3661
4882
|
const sections = useMemo2(() => groupDataTableRows(rows, fields), [rows, fields]);
|
|
3662
4883
|
const colSpan = model.visibleColumns.length + (store.config.features.selection ? 1 : 0) + (hasRowActionMenu(store) ? 1 : 0) + (canDragRows(store) ? 1 : 0);
|
|
3663
4884
|
const showGroups = sections.length && (rows.length || !store.config.status.loading) && !store.config.status.error;
|
|
3664
4885
|
if (showGroups && !viewport) {
|
|
3665
4886
|
return /* @__PURE__ */ jsx15(GroupedTable, {
|
|
3666
|
-
|
|
4887
|
+
table,
|
|
3667
4888
|
sections
|
|
3668
4889
|
});
|
|
3669
4890
|
}
|
|
@@ -3689,30 +4910,17 @@ var DataTableBody = ({
|
|
|
3689
4910
|
colSpan,
|
|
3690
4911
|
rows,
|
|
3691
4912
|
sections,
|
|
3692
|
-
|
|
4913
|
+
table,
|
|
3693
4914
|
viewport
|
|
3694
4915
|
}) : rows.map((row) => /* @__PURE__ */ jsx15(RowIdContext.Provider, {
|
|
3695
4916
|
value: row.id,
|
|
3696
4917
|
children: /* @__PURE__ */ jsx15(TableDataRow, {
|
|
3697
4918
|
row,
|
|
3698
|
-
|
|
4919
|
+
table
|
|
3699
4920
|
})
|
|
3700
4921
|
}, row.id))
|
|
3701
4922
|
});
|
|
3702
4923
|
};
|
|
3703
|
-
var GalleryImage = ({ src, alt }) => {
|
|
3704
|
-
const [failed, setFailed] = useState(false);
|
|
3705
|
-
if (failed)
|
|
3706
|
-
return null;
|
|
3707
|
-
return /* @__PURE__ */ jsx15("img", {
|
|
3708
|
-
src,
|
|
3709
|
-
alt,
|
|
3710
|
-
loading: "lazy",
|
|
3711
|
-
decoding: "async",
|
|
3712
|
-
className: "aspect-video w-full object-cover",
|
|
3713
|
-
onError: () => setFailed(true)
|
|
3714
|
-
});
|
|
3715
|
-
};
|
|
3716
4924
|
var GalleryTag = ({
|
|
3717
4925
|
row,
|
|
3718
4926
|
column,
|
|
@@ -3739,9 +4947,9 @@ var GalleryTag = ({
|
|
|
3739
4947
|
});
|
|
3740
4948
|
};
|
|
3741
4949
|
var GalleryCard = ({
|
|
3742
|
-
|
|
4950
|
+
table
|
|
3743
4951
|
}) => {
|
|
3744
|
-
const [store,
|
|
4952
|
+
const [store, send] = table;
|
|
3745
4953
|
const rowId = useRequiredId(RowIdContext);
|
|
3746
4954
|
const model = deriveModel(store);
|
|
3747
4955
|
const row = model.sortedRows.find((candidate) => candidate.id === rowId);
|
|
@@ -3770,10 +4978,14 @@ var GalleryCard = ({
|
|
|
3770
4978
|
},
|
|
3771
4979
|
tabIndex: store.config.onRowClicked ? 0 : undefined,
|
|
3772
4980
|
children: [
|
|
3773
|
-
imageSrc ? /* @__PURE__ */ jsx15(
|
|
4981
|
+
imageSrc && !store.ui.failedImages.includes(imageSrc) ? /* @__PURE__ */ jsx15("img", {
|
|
3774
4982
|
src: imageSrc,
|
|
3775
|
-
alt: gallery.image?.getAlt?.(row.data) ?? ""
|
|
3776
|
-
|
|
4983
|
+
alt: gallery.image?.getAlt?.(row.data) ?? "",
|
|
4984
|
+
loading: "lazy",
|
|
4985
|
+
decoding: "async",
|
|
4986
|
+
className: "aspect-video w-full object-cover",
|
|
4987
|
+
onError: () => send(DataTableMessage.ReferenceImageFailed({ src: imageSrc }))
|
|
4988
|
+
}) : null,
|
|
3777
4989
|
/* @__PURE__ */ jsxs9(CardHeader, {
|
|
3778
4990
|
className: cn("relative", hasRowActionMenu(store) && "pr-12"),
|
|
3779
4991
|
children: [
|
|
@@ -3784,11 +4996,11 @@ var GalleryCard = ({
|
|
|
3784
4996
|
"aria-label": store.config.labels.selectRow,
|
|
3785
4997
|
checked: !!store.state.rowSelection[row.id],
|
|
3786
4998
|
disabled: !selectable,
|
|
3787
|
-
onCheckedChange: (checked) => toggleRow(
|
|
4999
|
+
onCheckedChange: (checked) => toggleRow(send, row.id, checked),
|
|
3788
5000
|
onClick: (event) => event.stopPropagation()
|
|
3789
5001
|
}) : null,
|
|
3790
5002
|
draggable ? /* @__PURE__ */ jsx15(DragHandle, {
|
|
3791
|
-
|
|
5003
|
+
table
|
|
3792
5004
|
}) : null
|
|
3793
5005
|
]
|
|
3794
5006
|
}) : null,
|
|
@@ -3817,7 +5029,7 @@ var GalleryCard = ({
|
|
|
3817
5029
|
onClick: (event) => event.stopPropagation(),
|
|
3818
5030
|
children: /* @__PURE__ */ jsx15(DataTableRowActionMenu, {
|
|
3819
5031
|
row,
|
|
3820
|
-
|
|
5032
|
+
table
|
|
3821
5033
|
})
|
|
3822
5034
|
}) : null
|
|
3823
5035
|
]
|
|
@@ -3826,13 +5038,13 @@ var GalleryCard = ({
|
|
|
3826
5038
|
});
|
|
3827
5039
|
};
|
|
3828
5040
|
var DataTableGallery = ({
|
|
3829
|
-
|
|
5041
|
+
table
|
|
3830
5042
|
}) => {
|
|
3831
|
-
const styles =
|
|
3832
|
-
const [store,
|
|
5043
|
+
const styles = useContext2(DataTableStylesContext);
|
|
5044
|
+
const [store, send] = table;
|
|
3833
5045
|
const model = deriveModel(store);
|
|
3834
5046
|
const fields = getActiveGrouping(store);
|
|
3835
|
-
const rows =
|
|
5047
|
+
const rows = model.pageRows;
|
|
3836
5048
|
const sections = groupDataTableRows(rows, fields);
|
|
3837
5049
|
if (store.config.status.error) {
|
|
3838
5050
|
return /* @__PURE__ */ jsx15("div", {
|
|
@@ -3864,7 +5076,7 @@ var DataTableGallery = ({
|
|
|
3864
5076
|
children: rows.map((row) => /* @__PURE__ */ jsx15(RowIdContext.Provider, {
|
|
3865
5077
|
value: row.id,
|
|
3866
5078
|
children: /* @__PURE__ */ jsx15(GalleryCard, {
|
|
3867
|
-
|
|
5079
|
+
table
|
|
3868
5080
|
})
|
|
3869
5081
|
}, row.id))
|
|
3870
5082
|
});
|
|
@@ -3872,13 +5084,7 @@ var DataTableGallery = ({
|
|
|
3872
5084
|
const renderSections = (sections) => sections.map((section) => {
|
|
3873
5085
|
const collapsed = !!store.state.collapsedGroups[section.key];
|
|
3874
5086
|
const targetKey = getGroupDropKey(section.field.id, section.groupId);
|
|
3875
|
-
const toggleCollapsed = () =>
|
|
3876
|
-
...state,
|
|
3877
|
-
collapsedGroups: {
|
|
3878
|
-
...state.collapsedGroups,
|
|
3879
|
-
[section.key]: !collapsed
|
|
3880
|
-
}
|
|
3881
|
-
}));
|
|
5087
|
+
const toggleCollapsed = () => send(DataTableMessage.GroupToggled({ key: section.key }));
|
|
3882
5088
|
return /* @__PURE__ */ jsxs9("section", {
|
|
3883
5089
|
className: "data-[drop-target=true]:ring-primary space-y-3 rounded-lg transition-shadow data-[drop-target=true]:ring-2",
|
|
3884
5090
|
"data-table-group": section.field.onMoveToGroup ? targetKey : undefined,
|
|
@@ -3920,7 +5126,7 @@ var DataTableGallery = ({
|
|
|
3920
5126
|
children: section.rows.map((row) => /* @__PURE__ */ jsx15(RowIdContext.Provider, {
|
|
3921
5127
|
value: row.id,
|
|
3922
5128
|
children: /* @__PURE__ */ jsx15(GalleryCard, {
|
|
3923
|
-
|
|
5129
|
+
table
|
|
3924
5130
|
})
|
|
3925
5131
|
}, `${section.key}:${row.id}`))
|
|
3926
5132
|
}) : /* @__PURE__ */ jsx15("div", {
|
|
@@ -3936,28 +5142,22 @@ var DataTableGallery = ({
|
|
|
3936
5142
|
});
|
|
3937
5143
|
};
|
|
3938
5144
|
var DataTablePagination = ({
|
|
3939
|
-
|
|
5145
|
+
table
|
|
3940
5146
|
}) => {
|
|
3941
|
-
const styles =
|
|
3942
|
-
const [store,
|
|
5147
|
+
const styles = useContext2(DataTableStylesContext);
|
|
5148
|
+
const [store, send] = table;
|
|
3943
5149
|
const model = deriveModel(store);
|
|
3944
5150
|
const pagination = store.config.features.pagination ?? false;
|
|
3945
|
-
const
|
|
3946
|
-
const paginationVisible = pagination !== false && !clientGrouping;
|
|
5151
|
+
const { paginationVisible, page } = model;
|
|
3947
5152
|
const pageIndex = store.state.page;
|
|
3948
|
-
|
|
3949
|
-
|
|
3950
|
-
|
|
3951
|
-
changeState(setStore, (state) => ({
|
|
3952
|
-
...state,
|
|
3953
|
-
page: maxPageIndex
|
|
3954
|
-
}));
|
|
5153
|
+
useLayoutEffect2(() => {
|
|
5154
|
+
if (paginationVisible && pagination && pagination.mode === "client" && pageIndex > page) {
|
|
5155
|
+
send(DataTableMessage.PageRequested({ page }));
|
|
3955
5156
|
}
|
|
3956
|
-
}, [
|
|
3957
|
-
if (!paginationVisible)
|
|
5157
|
+
}, [page, pageIndex, pagination, paginationVisible, send]);
|
|
5158
|
+
if (!paginationVisible || !pagination)
|
|
3958
5159
|
return null;
|
|
3959
5160
|
const selected = model.rows.filter((row) => store.state.rowSelection[row.id]).length;
|
|
3960
|
-
const setPagination = (next) => changeState(setStore, (state) => ({ ...state, ...next }));
|
|
3961
5161
|
return /* @__PURE__ */ jsx15("div", {
|
|
3962
5162
|
"data-table-slot": "pagination",
|
|
3963
5163
|
className: cn("shrink-0 pt-4", styles?.pagination),
|
|
@@ -3965,9 +5165,9 @@ var DataTablePagination = ({
|
|
|
3965
5165
|
pageSizeContentClassName: styles?.popup?.select,
|
|
3966
5166
|
locale: store.config.locale,
|
|
3967
5167
|
messages: { [store.config.locale]: store.config.labels },
|
|
3968
|
-
onPageChange: (page) =>
|
|
3969
|
-
onPageSizeChange: (pageSize) =>
|
|
3970
|
-
page
|
|
5168
|
+
onPageChange: (page) => send(DataTableMessage.PageRequested({ page })),
|
|
5169
|
+
onPageSizeChange: (pageSize) => send(DataTableMessage.PageSizeRequested({ pageSize })),
|
|
5170
|
+
page,
|
|
3971
5171
|
pageCount: model.pageCount,
|
|
3972
5172
|
pageSize: store.state.pageSize,
|
|
3973
5173
|
pageSizes: pagination.pageSizes,
|
|
@@ -3976,156 +5176,226 @@ var DataTablePagination = ({
|
|
|
3976
5176
|
})
|
|
3977
5177
|
});
|
|
3978
5178
|
};
|
|
5179
|
+
var ReactTableModel = Component3.define(dataTableOptions).make({
|
|
5180
|
+
...dataTableBehaviours,
|
|
5181
|
+
view: () => View2.text("")
|
|
5182
|
+
});
|
|
5183
|
+
var modelField = (id, definition) => {
|
|
5184
|
+
const field = {
|
|
5185
|
+
id,
|
|
5186
|
+
headerName: id,
|
|
5187
|
+
type: definition.type ?? "text"
|
|
5188
|
+
};
|
|
5189
|
+
if (definition.sortable !== undefined)
|
|
5190
|
+
field.sortable = definition.sortable;
|
|
5191
|
+
if (definition.filterable !== undefined)
|
|
5192
|
+
field.filterable = definition.filterable;
|
|
5193
|
+
return field;
|
|
5194
|
+
};
|
|
5195
|
+
var modelColumns = (definitions) => normalizeDataTableColumns(definitions).map(({ id, colDef }) => {
|
|
5196
|
+
const column = modelField(id, colDef);
|
|
5197
|
+
if (colDef.width !== undefined)
|
|
5198
|
+
column.width = colDef.width;
|
|
5199
|
+
if (colDef.minWidth !== undefined)
|
|
5200
|
+
column.minWidth = colDef.minWidth;
|
|
5201
|
+
if (colDef.maxWidth !== undefined)
|
|
5202
|
+
column.maxWidth = colDef.maxWidth;
|
|
5203
|
+
if (colDef.hideable !== undefined)
|
|
5204
|
+
column.hideable = colDef.hideable;
|
|
5205
|
+
if (colDef.resizable !== undefined)
|
|
5206
|
+
column.resizable = colDef.resizable;
|
|
5207
|
+
if (colDef.fields)
|
|
5208
|
+
column.fields = colDef.fields.map((field) => modelField(field.id, field));
|
|
5209
|
+
return column;
|
|
5210
|
+
});
|
|
3979
5211
|
var getTableLayoutClass = (virtualization) => virtualization && virtualization !== true && virtualization.scroll === "internal" ? "flex min-h-0 flex-1 flex-col" : undefined;
|
|
3980
|
-
var HydratedDataTable = ({
|
|
3981
|
-
|
|
3982
|
-
|
|
3983
|
-
|
|
3984
|
-
|
|
3985
|
-
|
|
3986
|
-
const grouping =
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
|
|
3990
|
-
|
|
3991
|
-
|
|
3992
|
-
|
|
3993
|
-
|
|
3994
|
-
|
|
3995
|
-
|
|
3996
|
-
|
|
3997
|
-
|
|
3998
|
-
setTransientUiState(transientUiFromState(state));
|
|
3999
|
-
}, [setPersistedUiState, setTransientUiState]);
|
|
4000
|
-
const validatedConfig = resolveConfig(props, (state) => setUiState(state));
|
|
4001
|
-
const [tableAtom] = useState(() => {
|
|
4002
|
-
const initial = {
|
|
4003
|
-
rowData: props.rowData,
|
|
4004
|
-
columnDefs: props.columnDefs,
|
|
4005
|
-
config: validatedConfig,
|
|
4006
|
-
state: initialPublicState(props, uiState),
|
|
4007
|
-
controlledState: props.state
|
|
5212
|
+
var HydratedDataTable = (props) => {
|
|
5213
|
+
const config = useMemo2(() => resolveConfig(props), [props]);
|
|
5214
|
+
const columns = useMemo2(() => modelColumns(props.columnDefs), [props.columnDefs]);
|
|
5215
|
+
const selection = config.features.selection;
|
|
5216
|
+
const modelProps = useMemo2(() => {
|
|
5217
|
+
const { features } = config;
|
|
5218
|
+
const grouping = features.grouping;
|
|
5219
|
+
const pagination = features.pagination;
|
|
5220
|
+
const [firstSize, ...otherSizes] = pagination && pagination.pageSizes || [];
|
|
5221
|
+
const modelFeatures = {
|
|
5222
|
+
search: features.search !== false,
|
|
5223
|
+
filtering: features.filtering !== false,
|
|
5224
|
+
sorting: features.sorting !== false,
|
|
5225
|
+
columnVisibility: features.columnVisibility !== false,
|
|
5226
|
+
pagination: pagination ? {
|
|
5227
|
+
...pagination,
|
|
5228
|
+
pageSizes: firstSize === undefined ? undefined : [firstSize, ...otherSizes]
|
|
5229
|
+
} : false
|
|
4008
5230
|
};
|
|
4009
|
-
|
|
4010
|
-
|
|
4011
|
-
|
|
4012
|
-
|
|
4013
|
-
|
|
4014
|
-
|
|
4015
|
-
useLayoutEffect(() => {
|
|
4016
|
-
setStore((store) => {
|
|
4017
|
-
const features = props.features ?? {};
|
|
4018
|
-
const selection = features.selection;
|
|
4019
|
-
const config = {
|
|
4020
|
-
getRowId: selection && selection.getRowId || props.getRowId || undefined,
|
|
4021
|
-
onStateChange: props.onStateChange,
|
|
4022
|
-
onUiStateChange: (state) => setUiState(state),
|
|
4023
|
-
status: props.status ?? {},
|
|
4024
|
-
features,
|
|
4025
|
-
onRowClicked: props.onRowClicked,
|
|
4026
|
-
labels: dataTableMessages(props.locale, props.messages),
|
|
4027
|
-
locale: props.locale ?? "en"
|
|
4028
|
-
};
|
|
4029
|
-
const state = {
|
|
4030
|
-
...store.state,
|
|
4031
|
-
...uiState,
|
|
4032
|
-
...queryFromState(props.state ?? store.state)
|
|
5231
|
+
if (features.gallery)
|
|
5232
|
+
modelFeatures.gallery = { name: features.gallery.name };
|
|
5233
|
+
if (grouping) {
|
|
5234
|
+
modelFeatures.grouping = {
|
|
5235
|
+
initial: grouping.initial ?? [],
|
|
5236
|
+
fields: grouping.fields.map(({ id }) => ({ id, label: id }))
|
|
4033
5237
|
};
|
|
4034
|
-
|
|
4035
|
-
|
|
4036
|
-
|
|
4037
|
-
|
|
4038
|
-
|
|
4039
|
-
config,
|
|
4040
|
-
|
|
4041
|
-
|
|
4042
|
-
|
|
4043
|
-
|
|
4044
|
-
|
|
5238
|
+
}
|
|
5239
|
+
const input = {
|
|
5240
|
+
label: "",
|
|
5241
|
+
columnDefs: columns,
|
|
5242
|
+
rowData: selection ? props.rowData.map((row, index) => ({
|
|
5243
|
+
id: config.getRowId?.(row) ?? String(index),
|
|
5244
|
+
label: "",
|
|
5245
|
+
cells: {},
|
|
5246
|
+
selectable: selection.isRowSelectable?.(row) ?? true
|
|
5247
|
+
})) : [],
|
|
5248
|
+
features: modelFeatures
|
|
5249
|
+
};
|
|
5250
|
+
if (selection)
|
|
5251
|
+
input.selection = {};
|
|
5252
|
+
if (props.state)
|
|
5253
|
+
input.state = props.state;
|
|
5254
|
+
if (props.initialState)
|
|
5255
|
+
input.initialState = props.initialState;
|
|
5256
|
+
return input;
|
|
4045
5257
|
}, [
|
|
4046
|
-
|
|
4047
|
-
|
|
4048
|
-
props.
|
|
4049
|
-
props.locale,
|
|
4050
|
-
props.messages,
|
|
4051
|
-
props.onRowClicked,
|
|
4052
|
-
props.onStateChange,
|
|
5258
|
+
columns,
|
|
5259
|
+
config,
|
|
5260
|
+
props.initialState,
|
|
4053
5261
|
props.rowData,
|
|
4054
5262
|
props.state,
|
|
4055
|
-
|
|
4056
|
-
|
|
4057
|
-
|
|
4058
|
-
|
|
5263
|
+
selection
|
|
5264
|
+
]);
|
|
5265
|
+
const { model, send } = useModel(ReactTableModel, modelProps, {
|
|
5266
|
+
onEmit: (event) => {
|
|
5267
|
+
if (event._tag === "StateChanged") {
|
|
5268
|
+
props.onStateChange?.(queryFromState(event.state));
|
|
5269
|
+
} else if (event._tag === "SelectionChanged" && selection) {
|
|
5270
|
+
const selected = new Set(event.selectedRowIds);
|
|
5271
|
+
selection.onSelectionChange?.(props.rowData.filter((_, index) => {
|
|
5272
|
+
const id = modelProps.rowData[index]?.id;
|
|
5273
|
+
return id !== undefined && selected.has(id);
|
|
5274
|
+
}));
|
|
5275
|
+
}
|
|
5276
|
+
}
|
|
5277
|
+
});
|
|
5278
|
+
const [storageKey] = useState2(() => tablePreferencesKey(globalThis.window?.location.pathname ?? "/", columns.map(({ id }) => id), !!props.features?.gallery));
|
|
5279
|
+
useEffect2(() => {
|
|
5280
|
+
if (!model.preferencesLoaded) {
|
|
5281
|
+
send(DataTableMessage.PreferencesLoaded({
|
|
5282
|
+
preferences: readTablePreferences(storageKey)
|
|
5283
|
+
}));
|
|
5284
|
+
}
|
|
5285
|
+
}, [model, send, storageKey]);
|
|
5286
|
+
const { columnVisibility, columnSizing, grouping, view, preferencesLoaded } = model;
|
|
5287
|
+
const loadedPreferences = useRef2(false);
|
|
5288
|
+
useEffect2(() => {
|
|
5289
|
+
const preferences = tablePreferences({
|
|
5290
|
+
columnVisibility,
|
|
5291
|
+
columnSizing,
|
|
5292
|
+
grouping,
|
|
5293
|
+
view,
|
|
5294
|
+
preferencesLoaded
|
|
5295
|
+
});
|
|
5296
|
+
if (!preferences)
|
|
5297
|
+
return;
|
|
5298
|
+
if (!loadedPreferences.current) {
|
|
5299
|
+
loadedPreferences.current = true;
|
|
5300
|
+
return;
|
|
5301
|
+
}
|
|
5302
|
+
writeTablePreferences(storageKey, preferences);
|
|
5303
|
+
}, [
|
|
5304
|
+
columnVisibility,
|
|
5305
|
+
columnSizing,
|
|
5306
|
+
grouping,
|
|
5307
|
+
view,
|
|
5308
|
+
preferencesLoaded,
|
|
5309
|
+
storageKey
|
|
4059
5310
|
]);
|
|
5311
|
+
const query = modelProps.state ?? model.query;
|
|
5312
|
+
const { collapsedGroups, selectedRowIds } = model;
|
|
5313
|
+
const galleryEnabled = !!props.features?.gallery;
|
|
5314
|
+
const state = useMemo2(() => ({
|
|
5315
|
+
...query,
|
|
5316
|
+
columnVisibility,
|
|
5317
|
+
columnSizing,
|
|
5318
|
+
grouping,
|
|
5319
|
+
view: galleryEnabled ? view : "table",
|
|
5320
|
+
collapsedGroups,
|
|
5321
|
+
rowSelection: Object.fromEntries(selectedRowIds.map((id) => [id, true]))
|
|
5322
|
+
}), [
|
|
5323
|
+
query,
|
|
5324
|
+
columnVisibility,
|
|
5325
|
+
columnSizing,
|
|
5326
|
+
grouping,
|
|
5327
|
+
view,
|
|
5328
|
+
galleryEnabled,
|
|
5329
|
+
collapsedGroups,
|
|
5330
|
+
selectedRowIds
|
|
5331
|
+
]);
|
|
5332
|
+
const store = useMemo2(() => {
|
|
5333
|
+
const source = {
|
|
5334
|
+
rowData: props.rowData,
|
|
5335
|
+
columnDefs: props.columnDefs,
|
|
5336
|
+
config,
|
|
5337
|
+
state
|
|
5338
|
+
};
|
|
5339
|
+
return { ...source, model: buildDataTableModel(source) };
|
|
5340
|
+
}, [props.rowData, props.columnDefs, config, state]);
|
|
5341
|
+
const table = [{ ...store, ui: model }, send];
|
|
5342
|
+
if (!preferencesLoaded)
|
|
5343
|
+
return /* @__PURE__ */ jsx15(TablePlaceholder, {
|
|
5344
|
+
props
|
|
5345
|
+
});
|
|
4060
5346
|
return /* @__PURE__ */ jsxs9("div", {
|
|
4061
5347
|
className: cn("w-full max-w-full min-w-0 rounded-md", getTableLayoutClass(props.features?.virtualization), props.className),
|
|
4062
5348
|
"data-table-root": "",
|
|
4063
5349
|
children: [
|
|
4064
5350
|
/* @__PURE__ */ jsx15(DataTableToolbar, {
|
|
4065
|
-
|
|
5351
|
+
table
|
|
4066
5352
|
}),
|
|
4067
5353
|
/* @__PURE__ */ jsx15(DataTableContent, {
|
|
4068
|
-
|
|
5354
|
+
table
|
|
4069
5355
|
}),
|
|
4070
5356
|
/* @__PURE__ */ jsx15(DataTablePagination, {
|
|
4071
|
-
|
|
5357
|
+
table
|
|
4072
5358
|
})
|
|
4073
5359
|
]
|
|
4074
5360
|
});
|
|
4075
5361
|
};
|
|
5362
|
+
var subscribeToHydration = () => () => {};
|
|
5363
|
+
var clientSnapshot = () => true;
|
|
5364
|
+
var serverSnapshot = () => false;
|
|
5365
|
+
var TablePlaceholder = ({
|
|
5366
|
+
props
|
|
5367
|
+
}) => /* @__PURE__ */ jsx15("div", {
|
|
5368
|
+
"aria-busy": "true",
|
|
5369
|
+
className: cn("invisible w-full max-w-full min-w-0 rounded-md", getTableLayoutClass(props.features?.virtualization), props.className),
|
|
5370
|
+
"data-table-root": ""
|
|
5371
|
+
});
|
|
4076
5372
|
var DataTable = (props) => {
|
|
4077
5373
|
const locale = useKrakstackLocale3(props.locale);
|
|
4078
|
-
const
|
|
4079
|
-
|
|
4080
|
-
|
|
4081
|
-
|
|
4082
|
-
const viewCapability = props.features?.gallery ? "gallery" : "table";
|
|
4083
|
-
return Atom.kvs({
|
|
4084
|
-
mode: "async",
|
|
4085
|
-
runtime: dataTableStorageRuntime,
|
|
4086
|
-
key: `data-table:${pathname}:${columnIds}:${viewCapability}:ui`,
|
|
4087
|
-
schema: DataTablePersistedUiStateSchema,
|
|
4088
|
-
defaultValue: () => ({
|
|
4089
|
-
...persistedUiFromState(DEFAULT_UI_STATE),
|
|
4090
|
-
view: props.features?.gallery ? props.initialState?.view ?? "table" : "table",
|
|
4091
|
-
grouping: props.features?.grouping ? props.features.grouping.initial ?? [] : []
|
|
4092
|
-
})
|
|
4093
|
-
});
|
|
4094
|
-
});
|
|
4095
|
-
const [persistedUiResult, setPersistedUiState] = useAtom(persistedUiAtom);
|
|
4096
|
-
const persistedUiState = useMemo2(() => AsyncResult.isSuccess(persistedUiResult) ? {
|
|
4097
|
-
...persistedUiResult.value,
|
|
4098
|
-
columnVisibility: {
|
|
4099
|
-
...initialColumnVisibility,
|
|
4100
|
-
...persistedUiResult.value.columnVisibility
|
|
4101
|
-
}
|
|
4102
|
-
} : undefined, [initialColumnVisibility, persistedUiResult]);
|
|
4103
|
-
if (!persistedUiState || AsyncResult.isWaiting(persistedUiResult)) {
|
|
4104
|
-
return /* @__PURE__ */ jsx15("div", {
|
|
4105
|
-
"aria-busy": "true",
|
|
4106
|
-
className: cn("invisible w-full max-w-full min-w-0 rounded-md", getTableLayoutClass(props.features?.virtualization), props.className),
|
|
4107
|
-
"data-table-root": ""
|
|
5374
|
+
const hydrated = useSyncExternalStore2(subscribeToHydration, clientSnapshot, serverSnapshot);
|
|
5375
|
+
if (!hydrated)
|
|
5376
|
+
return /* @__PURE__ */ jsx15(TablePlaceholder, {
|
|
5377
|
+
props
|
|
4108
5378
|
});
|
|
4109
|
-
}
|
|
4110
5379
|
return /* @__PURE__ */ jsx15(DataTableStylesContext.Provider, {
|
|
4111
5380
|
value: props.classNames,
|
|
4112
|
-
children: /* @__PURE__ */ jsx15(
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
|
|
4116
|
-
|
|
5381
|
+
children: /* @__PURE__ */ jsx15(DataTableSlotClassesContext.Provider, {
|
|
5382
|
+
value: resolveTableClasses(props.classes),
|
|
5383
|
+
children: /* @__PURE__ */ jsx15(HydratedDataTable, {
|
|
5384
|
+
...props,
|
|
5385
|
+
locale
|
|
5386
|
+
})
|
|
4117
5387
|
})
|
|
4118
5388
|
});
|
|
4119
5389
|
};
|
|
4120
5390
|
var DataTableContent = ({
|
|
4121
|
-
|
|
5391
|
+
table
|
|
4122
5392
|
}) => {
|
|
4123
|
-
const [store] =
|
|
4124
|
-
const [scrollElement, setScrollElement] =
|
|
4125
|
-
const [headerHeight, setHeaderHeight] =
|
|
4126
|
-
const [pageTable, setPageTable] =
|
|
4127
|
-
const [pageOffset, setPageOffset] =
|
|
4128
|
-
|
|
5393
|
+
const [store] = table;
|
|
5394
|
+
const [scrollElement, setScrollElement] = useState2(null);
|
|
5395
|
+
const [headerHeight, setHeaderHeight] = useState2(48);
|
|
5396
|
+
const [pageTable, setPageTable] = useState2(null);
|
|
5397
|
+
const [pageOffset, setPageOffset] = useState2();
|
|
5398
|
+
useLayoutEffect2(() => {
|
|
4129
5399
|
const header = pageTable?.querySelector("thead");
|
|
4130
5400
|
if (!pageTable || !header)
|
|
4131
5401
|
return;
|
|
@@ -4140,7 +5410,7 @@ var DataTableContent = ({
|
|
|
4140
5410
|
observer?.disconnect();
|
|
4141
5411
|
};
|
|
4142
5412
|
}, [pageTable]);
|
|
4143
|
-
|
|
5413
|
+
useLayoutEffect2(() => {
|
|
4144
5414
|
const header = scrollElement?.querySelector("thead");
|
|
4145
5415
|
if (!header)
|
|
4146
5416
|
return;
|
|
@@ -4154,7 +5424,7 @@ var DataTableContent = ({
|
|
|
4154
5424
|
}, [scrollElement]);
|
|
4155
5425
|
if (store.config.features.gallery && store.state.view === "gallery") {
|
|
4156
5426
|
return /* @__PURE__ */ jsx15(DataTableGallery, {
|
|
4157
|
-
|
|
5427
|
+
table
|
|
4158
5428
|
});
|
|
4159
5429
|
}
|
|
4160
5430
|
const model = deriveModel(store);
|
|
@@ -4180,10 +5450,10 @@ var DataTableContent = ({
|
|
|
4180
5450
|
style: { width: `max(100%, ${width}px)` },
|
|
4181
5451
|
children: [
|
|
4182
5452
|
/* @__PURE__ */ jsx15(DataTableHeader, {
|
|
4183
|
-
|
|
5453
|
+
table
|
|
4184
5454
|
}),
|
|
4185
5455
|
/* @__PURE__ */ jsx15(DataTableBody, {
|
|
4186
|
-
|
|
5456
|
+
table,
|
|
4187
5457
|
viewport: {
|
|
4188
5458
|
element: null,
|
|
4189
5459
|
headerHeight: 0,
|
|
@@ -4220,10 +5490,10 @@ var DataTableContent = ({
|
|
|
4220
5490
|
children: [
|
|
4221
5491
|
/* @__PURE__ */ jsx15(DataTableHeader, {
|
|
4222
5492
|
sticky: true,
|
|
4223
|
-
|
|
5493
|
+
table
|
|
4224
5494
|
}),
|
|
4225
5495
|
/* @__PURE__ */ jsx15(DataTableBody, {
|
|
4226
|
-
|
|
5496
|
+
table,
|
|
4227
5497
|
viewport: { element: scrollElement, headerHeight, options }
|
|
4228
5498
|
})
|
|
4229
5499
|
]
|
|
@@ -4249,10 +5519,10 @@ var DataTableContent = ({
|
|
|
4249
5519
|
style: { width: `max(100%, ${width}px)` },
|
|
4250
5520
|
children: [
|
|
4251
5521
|
/* @__PURE__ */ jsx15(DataTableHeader, {
|
|
4252
|
-
|
|
5522
|
+
table
|
|
4253
5523
|
}),
|
|
4254
5524
|
/* @__PURE__ */ jsx15(DataTableBody, {
|
|
4255
|
-
|
|
5525
|
+
table
|
|
4256
5526
|
})
|
|
4257
5527
|
]
|
|
4258
5528
|
}),
|
|
@@ -4263,6 +5533,7 @@ var DataTableContent = ({
|
|
|
4263
5533
|
});
|
|
4264
5534
|
};
|
|
4265
5535
|
var DataTableListCell = (props) => {
|
|
5536
|
+
const tableClasses = useContext2(DataTableSlotClassesContext);
|
|
4266
5537
|
const locale = useKrakstackLocale3(props.locale);
|
|
4267
5538
|
const resolvedProps = { ...props, locale };
|
|
4268
5539
|
if (resolvedProps.options && (resolvedProps.onAdd || resolvedProps.onRemove)) {
|
|
@@ -4280,7 +5551,7 @@ var DataTableListCell = (props) => {
|
|
|
4280
5551
|
}
|
|
4281
5552
|
const menuLabel = actionsLabel ?? (itemActions?.length ? labels.actions : labels.listDetails);
|
|
4282
5553
|
return /* @__PURE__ */ jsx15("div", {
|
|
4283
|
-
className:
|
|
5554
|
+
className: tableClasses.relationshipCell,
|
|
4284
5555
|
"data-slot": "data-table-list-cell",
|
|
4285
5556
|
onClick: (event) => event.stopPropagation(),
|
|
4286
5557
|
onPointerDown: (event) => event.stopPropagation(),
|
|
@@ -4295,7 +5566,7 @@ var DataTableListCell = (props) => {
|
|
|
4295
5566
|
onItemClick,
|
|
4296
5567
|
trigger: /* @__PURE__ */ jsxs9(Button, {
|
|
4297
5568
|
"aria-label": menuLabel,
|
|
4298
|
-
className:
|
|
5569
|
+
className: tableClasses.relationshipTrigger,
|
|
4299
5570
|
variant: "ghost",
|
|
4300
5571
|
children: [
|
|
4301
5572
|
/* @__PURE__ */ jsx15(DataTableListSummaryContent, {
|
|
@@ -4324,8 +5595,9 @@ var EditableDataTableListCell = ({
|
|
|
4324
5595
|
locale = "en",
|
|
4325
5596
|
messages
|
|
4326
5597
|
}) => {
|
|
4327
|
-
const
|
|
4328
|
-
const [
|
|
5598
|
+
const tableClasses = useContext2(DataTableSlotClassesContext);
|
|
5599
|
+
const [selected, setSelected] = useState2([...items]);
|
|
5600
|
+
const [previousItems, setPreviousItems] = useState2(items);
|
|
4329
5601
|
if (previousItems !== items) {
|
|
4330
5602
|
setPreviousItems(items);
|
|
4331
5603
|
setSelected([...items]);
|
|
@@ -4355,7 +5627,7 @@ var EditableDataTableListCell = ({
|
|
|
4355
5627
|
];
|
|
4356
5628
|
return /* @__PURE__ */ jsx15("div", {
|
|
4357
5629
|
"data-slot": "data-table-list-cell",
|
|
4358
|
-
className:
|
|
5630
|
+
className: tableClasses.relationshipCell,
|
|
4359
5631
|
onClick: (event) => event.stopPropagation(),
|
|
4360
5632
|
onPointerDown: (event) => event.stopPropagation(),
|
|
4361
5633
|
children: /* @__PURE__ */ jsx15(DataTableListMenu, {
|
|
@@ -4412,7 +5684,7 @@ var DataTableListMenu = ({
|
|
|
4412
5684
|
trigger
|
|
4413
5685
|
}) => {
|
|
4414
5686
|
const entries = items.map((item) => {
|
|
4415
|
-
const normalized =
|
|
5687
|
+
const normalized = Schema6.is(Schema6.String)(item) ? { label: item } : item;
|
|
4416
5688
|
const visibleActions = actions.filter((action) => action.visible?.(normalized) ?? true);
|
|
4417
5689
|
return { item: normalized, visibleActions };
|
|
4418
5690
|
});
|
|
@@ -4513,8 +5785,8 @@ var DataTableListAddMenu = ({
|
|
|
4513
5785
|
options,
|
|
4514
5786
|
searchLabel
|
|
4515
5787
|
}) => {
|
|
4516
|
-
const [search, setSearch] =
|
|
4517
|
-
const focusSearch =
|
|
5788
|
+
const [search, setSearch] = useState2("");
|
|
5789
|
+
const focusSearch = useCallback2((input) => {
|
|
4518
5790
|
input?.focus({ preventScroll: true });
|
|
4519
5791
|
}, []);
|
|
4520
5792
|
const labels = dataTableMessages(locale, messages);
|
|
@@ -4582,7 +5854,7 @@ var DataTableListSummaryContent = ({
|
|
|
4582
5854
|
showMenu,
|
|
4583
5855
|
visibleCount = 3
|
|
4584
5856
|
}) => {
|
|
4585
|
-
const normalized = items.map((item) =>
|
|
5857
|
+
const normalized = items.map((item) => Schema6.is(Schema6.String)(item) ? { label: item } : item);
|
|
4586
5858
|
if (!normalized.length)
|
|
4587
5859
|
return /* @__PURE__ */ jsx15("span", {
|
|
4588
5860
|
className: "text-muted-foreground",
|
|
@@ -4687,21 +5959,110 @@ var DataTableListEntry = ({
|
|
|
4687
5959
|
]
|
|
4688
5960
|
});
|
|
4689
5961
|
};
|
|
4690
|
-
|
|
4691
|
-
// ../../src/components/ui/copy-button.tsx
|
|
5962
|
+
// ../../src/components/copy-button/react.tsx
|
|
4692
5963
|
import { Check as Check2, Copy, TriangleAlert } from "lucide-react";
|
|
4693
|
-
import {
|
|
4694
|
-
import {
|
|
4695
|
-
import {
|
|
4696
|
-
|
|
5964
|
+
import { Redacted as Redacted3 } from "effect";
|
|
5965
|
+
import { Component as Component5 } from "effect/ui";
|
|
5966
|
+
import { useLayoutEffect as useLayoutEffect3, useRef as useRef3, useState as useState3 } from "react";
|
|
5967
|
+
import { useKrakstackLocale as useKrakstackLocale4 } from "@krak-stack/registry/krakstack-provider/react";
|
|
5968
|
+
|
|
5969
|
+
// ../../src/components/copy-button/index.ts
|
|
5970
|
+
import { Effect as Effect4, Redacted as Redacted2, Schema as Schema8 } from "effect";
|
|
5971
|
+
import { Command as Command2, Component as Component4, UiSchema as UiSchema3, View as View3 } from "effect/ui";
|
|
5972
|
+
|
|
5973
|
+
// ../../src/components/copy-button/schema.ts
|
|
5974
|
+
import { Schema as Schema7 } from "effect";
|
|
5975
|
+
var MessageOverrides = Schema7.Struct({
|
|
5976
|
+
copy: Schema7.optional(Schema7.String),
|
|
5977
|
+
copied: Schema7.optional(Schema7.String),
|
|
5978
|
+
copyFailed: Schema7.optional(Schema7.String)
|
|
5979
|
+
}).annotate({ identifier: "CopyButtonMessageOverrides" });
|
|
5980
|
+
var CopyButtonTranslations = Schema7.Record(Schema7.String, Schema7.UndefinedOr(MessageOverrides));
|
|
5981
|
+
var copyButtonVariants = [
|
|
5982
|
+
"default",
|
|
5983
|
+
"secondary",
|
|
5984
|
+
"outline",
|
|
5985
|
+
"ghost",
|
|
5986
|
+
"destructive",
|
|
5987
|
+
"link"
|
|
5988
|
+
];
|
|
5989
|
+
var CopyButtonModelProps = Schema7.Struct({
|
|
5990
|
+
value: Schema7.Redacted(Schema7.String, { disallowJsonEncode: true }),
|
|
5991
|
+
disabled: Schema7.optional(Schema7.Boolean),
|
|
5992
|
+
resetDelay: Schema7.optional(Schema7.Finite)
|
|
5993
|
+
}).annotate({ identifier: "CopyButtonModelProps" });
|
|
5994
|
+
var copyButtonSharedProps = Schema7.Struct({
|
|
5995
|
+
...CopyButtonModelProps.fields,
|
|
5996
|
+
valueDescription: Schema7.optional(Schema7.String),
|
|
5997
|
+
copyVariant: Schema7.optional(Schema7.Literals(["default", "sm", "large"])),
|
|
5998
|
+
variant: Schema7.optional(Schema7.Literals(copyButtonVariants)),
|
|
5999
|
+
locale: Schema7.optional(Schema7.String),
|
|
6000
|
+
messages: Schema7.optional(CopyButtonTranslations)
|
|
6001
|
+
}).annotate({ identifier: "CopyButtonSharedProps" });
|
|
6002
|
+
|
|
6003
|
+
// ../../src/components/copy-button/index.ts
|
|
6004
|
+
var labels2 = {
|
|
4697
6005
|
en: { copy: "Copy", copied: "Copied", copyFailed: "Copy failed" },
|
|
4698
6006
|
fr: { copy: "Copier", copied: "Copié", copyFailed: "Échec de la copie" }
|
|
4699
6007
|
};
|
|
4700
6008
|
var copyButtonMessages = (locale = "en", translations) => ({
|
|
4701
|
-
...locale.startsWith("fr") ?
|
|
6009
|
+
...locale.startsWith("fr") ? labels2.fr : labels2.en,
|
|
4702
6010
|
...translations?.[locale.split("-")[0] ?? locale],
|
|
4703
6011
|
...translations?.[locale]
|
|
4704
6012
|
});
|
|
6013
|
+
var copyButtonLabel = (copy, description) => description ? `${copy} ${description}` : copy;
|
|
6014
|
+
var CopyButtonMessage = UiSchema3.TaggedEnum({
|
|
6015
|
+
Pressed: {},
|
|
6016
|
+
Finished: { success: Schema8.Boolean },
|
|
6017
|
+
Reset: {}
|
|
6018
|
+
}).annotate({ identifier: "CopyButtonMessage" });
|
|
6019
|
+
|
|
6020
|
+
class WriteClipboard extends Command2.Service()("copy-button/WriteClipboard", {
|
|
6021
|
+
args: {
|
|
6022
|
+
value: Schema8.Redacted(Schema8.String, { disallowJsonEncode: true })
|
|
6023
|
+
},
|
|
6024
|
+
success: CopyButtonMessage
|
|
6025
|
+
}) {
|
|
6026
|
+
static layerFromWrite = (write) => WriteClipboard.toLayer(({ value }) => Effect4.tryPromise(() => write(Redacted2.value(value))).pipe(Effect4.match({
|
|
6027
|
+
onSuccess: () => CopyButtonMessage.Finished({ success: true }),
|
|
6028
|
+
onFailure: () => CopyButtonMessage.Finished({ success: false })
|
|
6029
|
+
})));
|
|
6030
|
+
static browser = WriteClipboard.layerFromWrite((value) => navigator.clipboard.writeText(value));
|
|
6031
|
+
}
|
|
6032
|
+
var ResetClipboardFeedback = Command2.make("copy-button/ResetFeedback", { args: { delay: Schema8.Number }, mode: "switch" }, ({ delay }) => Effect4.sleep(Math.max(0, delay)).pipe(Effect4.as(CopyButtonMessage.Reset())));
|
|
6033
|
+
var copyButtonOptions = {
|
|
6034
|
+
name: "CopyButton",
|
|
6035
|
+
props: CopyButtonModelProps,
|
|
6036
|
+
model: Schema8.Struct({
|
|
6037
|
+
status: Schema8.Literals(["idle", "copied", "failed"])
|
|
6038
|
+
}).annotate({ identifier: "CopyButtonModel" }),
|
|
6039
|
+
message: CopyButtonMessage,
|
|
6040
|
+
restore: false
|
|
6041
|
+
};
|
|
6042
|
+
var Definition = Component4.define(copyButtonOptions);
|
|
6043
|
+
var update3 = Definition.update({
|
|
6044
|
+
Pressed: ($) => $.props.disabled ? $.model : $.run(WriteClipboard.make({ value: $.props.value })),
|
|
6045
|
+
Finished: ($, { success }) => $.evolve({ status: success ? "copied" : "failed" }).run(ResetClipboardFeedback.make({ delay: $.props.resetDelay ?? 1500 })),
|
|
6046
|
+
Reset: ($) => $.evolve({ status: "idle" })
|
|
6047
|
+
});
|
|
6048
|
+
var copyButtonBehaviours = {
|
|
6049
|
+
init: () => ({ status: "idle" }),
|
|
6050
|
+
update: update3
|
|
6051
|
+
};
|
|
6052
|
+
var CopyButtonModel = Definition.make({
|
|
6053
|
+
...copyButtonBehaviours,
|
|
6054
|
+
view: () => View3.text("")
|
|
6055
|
+
});
|
|
6056
|
+
var copyButtonStatus = (status, copy, description) => {
|
|
6057
|
+
if (status === "idle")
|
|
6058
|
+
return "";
|
|
6059
|
+
const text = status === "copied" ? copy.copied : copy.copyFailed;
|
|
6060
|
+
return description ? `${text}: ${description}` : text;
|
|
6061
|
+
};
|
|
6062
|
+
|
|
6063
|
+
// ../../src/components/copy-button/react.tsx
|
|
6064
|
+
import { jsx as jsx16, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
6065
|
+
"use client";
|
|
4705
6066
|
function CopyButton({
|
|
4706
6067
|
value,
|
|
4707
6068
|
valueDescription,
|
|
@@ -4717,39 +6078,44 @@ function CopyButton({
|
|
|
4717
6078
|
...props
|
|
4718
6079
|
}) {
|
|
4719
6080
|
const locale = useKrakstackLocale4(localeOverride);
|
|
4720
|
-
const [copyState, setCopyState] = useState2("idle");
|
|
4721
|
-
const copyTimeout = useRef2(undefined);
|
|
4722
6081
|
const labels = copyButtonMessages(locale, messages);
|
|
4723
|
-
const
|
|
4724
|
-
|
|
4725
|
-
|
|
4726
|
-
|
|
4727
|
-
|
|
4728
|
-
|
|
4729
|
-
|
|
6082
|
+
const callbacks = useRef3({
|
|
6083
|
+
onCopied,
|
|
6084
|
+
onCopyError,
|
|
6085
|
+
failureLabel: labels.copyFailed
|
|
6086
|
+
});
|
|
6087
|
+
useLayoutEffect3(() => {
|
|
6088
|
+
callbacks.current = {
|
|
6089
|
+
onCopied,
|
|
6090
|
+
onCopyError,
|
|
6091
|
+
failureLabel: labels.copyFailed
|
|
4730
6092
|
};
|
|
4731
|
-
}, []);
|
|
4732
|
-
const
|
|
4733
|
-
|
|
4734
|
-
|
|
4735
|
-
|
|
4736
|
-
};
|
|
4737
|
-
const copy = () => {
|
|
4738
|
-
Promise.resolve().then(() => navigator.clipboard.writeText(value)).then(() => {
|
|
4739
|
-
setCopyState("copied");
|
|
6093
|
+
}, [onCopied, onCopyError, labels.copyFailed]);
|
|
6094
|
+
const [component] = useState3(() => CopyButtonModel.pipe(Component5.provide(WriteClipboard.layerFromWrite(async (text) => {
|
|
6095
|
+
const { onCopied, onCopyError, failureLabel } = callbacks.current;
|
|
6096
|
+
try {
|
|
6097
|
+
await navigator.clipboard.writeText(text);
|
|
4740
6098
|
onCopied?.();
|
|
4741
|
-
|
|
4742
|
-
|
|
4743
|
-
|
|
4744
|
-
|
|
4745
|
-
|
|
4746
|
-
|
|
4747
|
-
|
|
4748
|
-
|
|
6099
|
+
} catch (cause) {
|
|
6100
|
+
onCopyError?.(cause instanceof Error ? cause : new Error(failureLabel, { cause }));
|
|
6101
|
+
throw cause;
|
|
6102
|
+
}
|
|
6103
|
+
}))));
|
|
6104
|
+
const {
|
|
6105
|
+
model: { status },
|
|
6106
|
+
send
|
|
6107
|
+
} = useModel(component, {
|
|
6108
|
+
value: Redacted3.make(value),
|
|
6109
|
+
disabled: disabled ?? false,
|
|
6110
|
+
resetDelay
|
|
6111
|
+
});
|
|
6112
|
+
const accessibleLabel = ariaLabel ?? copyButtonLabel(labels.copy, valueDescription);
|
|
6113
|
+
const isLarge = copyVariant === "large";
|
|
6114
|
+
const defaultSize = copyVariant === "sm" ? "icon-xs" : isLarge ? "sm" : "icon-sm";
|
|
4749
6115
|
return /* @__PURE__ */ jsxs10(Button, {
|
|
4750
6116
|
"aria-label": accessibleLabel,
|
|
4751
6117
|
disabled,
|
|
4752
|
-
onClick:
|
|
6118
|
+
onClick: () => send(CopyButtonMessage.Pressed()),
|
|
4753
6119
|
size: size ?? defaultSize,
|
|
4754
6120
|
...props,
|
|
4755
6121
|
children: [
|
|
@@ -4757,15 +6123,15 @@ function CopyButton({
|
|
|
4757
6123
|
"aria-live": "polite",
|
|
4758
6124
|
className: "sr-only",
|
|
4759
6125
|
role: "status",
|
|
4760
|
-
children: status
|
|
6126
|
+
children: copyButtonStatus(status, labels, valueDescription)
|
|
4761
6127
|
}),
|
|
4762
|
-
|
|
6128
|
+
status === "copied" ? /* @__PURE__ */ jsx16(Check2, {
|
|
4763
6129
|
"aria-hidden": "true"
|
|
4764
6130
|
}) : null,
|
|
4765
|
-
|
|
6131
|
+
status === "failed" ? /* @__PURE__ */ jsx16(TriangleAlert, {
|
|
4766
6132
|
"aria-hidden": "true"
|
|
4767
6133
|
}) : null,
|
|
4768
|
-
|
|
6134
|
+
status === "idle" ? /* @__PURE__ */ jsx16(Copy, {
|
|
4769
6135
|
"aria-hidden": "true"
|
|
4770
6136
|
}) : null,
|
|
4771
6137
|
isLarge ? /* @__PURE__ */ jsx16("span", {
|
|
@@ -4775,14 +6141,30 @@ function CopyButton({
|
|
|
4775
6141
|
});
|
|
4776
6142
|
}
|
|
4777
6143
|
|
|
4778
|
-
// ../../src/components/ui/
|
|
6144
|
+
// ../../src/components/ui/copy-button.tsx
|
|
6145
|
+
"use client";
|
|
6146
|
+
|
|
6147
|
+
// ../../src/components/code-block/react.tsx
|
|
4779
6148
|
import { highlight } from "@tanstack/highlight";
|
|
6149
|
+
import { useKrakstackLocale as useKrakstackLocale5 } from "@krak-stack/registry/krakstack-provider/react";
|
|
6150
|
+
|
|
6151
|
+
// ../../src/components/code-block/classes.ts
|
|
6152
|
+
var codeBlockClasses = {
|
|
6153
|
+
root: "not-prose bg-muted overflow-hidden rounded-md border text-[var(--th-token)]",
|
|
6154
|
+
header: "bg-background border-border/60 flex items-center justify-between border-b px-3 py-2",
|
|
6155
|
+
language: "text-muted-foreground font-mono text-xs",
|
|
6156
|
+
viewport: "max-h-full overflow-auto font-mono text-[0.875rem] leading-[1.625]"
|
|
6157
|
+
};
|
|
6158
|
+
var resolveCodeBlockClasses = (overrides) => ({
|
|
6159
|
+
...codeBlockClasses,
|
|
6160
|
+
...overrides
|
|
6161
|
+
});
|
|
6162
|
+
|
|
6163
|
+
// ../../src/components/code-block/index.ts
|
|
4780
6164
|
import { createThemeCss } from "@tanstack/highlight/theme";
|
|
4781
6165
|
import { githubDarkTheme } from "@tanstack/highlight/themes/github-dark";
|
|
4782
6166
|
import { githubLightTheme } from "@tanstack/highlight/themes/github-light";
|
|
4783
|
-
|
|
4784
|
-
import { jsx as jsx17, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
4785
|
-
var themeCss = `${createThemeCss({
|
|
6167
|
+
var codeThemeCss = `${createThemeCss({
|
|
4786
6168
|
light: githubLightTheme,
|
|
4787
6169
|
dark: githubDarkTheme,
|
|
4788
6170
|
lightSelector: "[data-code-theme]",
|
|
@@ -4798,7 +6180,7 @@ var themeCss = `${createThemeCss({
|
|
|
4798
6180
|
color: inherit;
|
|
4799
6181
|
}
|
|
4800
6182
|
[data-code-theme] pre.th-code code { font: inherit; }`;
|
|
4801
|
-
var
|
|
6183
|
+
var messages3 = {
|
|
4802
6184
|
en: {
|
|
4803
6185
|
codeDescription: (language) => `${language} code`,
|
|
4804
6186
|
copy: "Copy",
|
|
@@ -4813,51 +6195,56 @@ var messages4 = {
|
|
|
4813
6195
|
}
|
|
4814
6196
|
};
|
|
4815
6197
|
var codeBlockMessages = (locale = "en", translations) => ({
|
|
4816
|
-
...locale.startsWith("fr") ?
|
|
6198
|
+
...locale.startsWith("fr") ? messages3.fr : messages3.en,
|
|
4817
6199
|
...translations?.[locale.split("-")[0] ?? locale],
|
|
4818
6200
|
...translations?.[locale]
|
|
4819
6201
|
});
|
|
6202
|
+
var codeLanguage = (language = "text") => language.toLowerCase() || "text";
|
|
6203
|
+
|
|
6204
|
+
// ../../src/components/code-block/react.tsx
|
|
6205
|
+
import { jsx as jsx17, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
4820
6206
|
function CodeBlock({
|
|
6207
|
+
classes: classOverrides,
|
|
4821
6208
|
code,
|
|
4822
6209
|
language = "text",
|
|
4823
6210
|
locale: localeOverride,
|
|
4824
6211
|
messages
|
|
4825
6212
|
}) {
|
|
6213
|
+
const codeBlockClasses = resolveCodeBlockClasses(classOverrides);
|
|
4826
6214
|
const locale = useKrakstackLocale5(localeOverride);
|
|
4827
|
-
const normalizedLanguage = language
|
|
6215
|
+
const normalizedLanguage = codeLanguage(language);
|
|
4828
6216
|
const highlighted = highlight(code, { lang: normalizedLanguage });
|
|
4829
6217
|
const labels = codeBlockMessages(locale, messages);
|
|
4830
6218
|
return /* @__PURE__ */ jsxs11("div", {
|
|
4831
|
-
className:
|
|
6219
|
+
className: codeBlockClasses.root,
|
|
4832
6220
|
"data-code-theme": true,
|
|
4833
6221
|
children: [
|
|
4834
6222
|
/* @__PURE__ */ jsx17("style", {
|
|
4835
|
-
children:
|
|
6223
|
+
children: codeThemeCss
|
|
4836
6224
|
}),
|
|
4837
6225
|
/* @__PURE__ */ jsxs11("div", {
|
|
4838
|
-
className:
|
|
6226
|
+
className: codeBlockClasses.header,
|
|
4839
6227
|
children: [
|
|
4840
6228
|
/* @__PURE__ */ jsx17("span", {
|
|
4841
|
-
className:
|
|
6229
|
+
className: codeBlockClasses.language,
|
|
4842
6230
|
children: highlighted.lang
|
|
4843
6231
|
}),
|
|
4844
6232
|
/* @__PURE__ */ jsx17(CopyButton, {
|
|
4845
6233
|
value: code,
|
|
4846
6234
|
valueDescription: labels.codeDescription(highlighted.lang),
|
|
4847
|
-
variant: "
|
|
6235
|
+
variant: "ghost",
|
|
4848
6236
|
locale,
|
|
4849
6237
|
messages: { [locale]: labels }
|
|
4850
6238
|
})
|
|
4851
6239
|
]
|
|
4852
6240
|
}),
|
|
4853
6241
|
/* @__PURE__ */ jsx17("div", {
|
|
4854
|
-
className:
|
|
6242
|
+
className: codeBlockClasses.viewport,
|
|
4855
6243
|
dangerouslySetInnerHTML: { __html: highlighted.html }
|
|
4856
6244
|
})
|
|
4857
6245
|
]
|
|
4858
6246
|
});
|
|
4859
6247
|
}
|
|
4860
|
-
|
|
4861
6248
|
// ../../src/components/ui/dialog.tsx
|
|
4862
6249
|
import { Dialog as DialogPrimitive } from "@base-ui/react/dialog";
|
|
4863
6250
|
import { cn as cn2 } from "cn";
|
|
@@ -4935,9 +6322,75 @@ function DialogTitle({ className, ...props }) {
|
|
|
4935
6322
|
});
|
|
4936
6323
|
}
|
|
4937
6324
|
|
|
4938
|
-
// ../../src/
|
|
4939
|
-
import { useKrakstackLocale as useKrakstackLocale6 } from "@krak-stack/registry/krakstack-provider";
|
|
4940
|
-
|
|
6325
|
+
// ../../src/components/webhook-delivery-table/react.tsx
|
|
6326
|
+
import { useKrakstackLocale as useKrakstackLocale6 } from "@krak-stack/registry/krakstack-provider/react";
|
|
6327
|
+
|
|
6328
|
+
// ../../src/components/webhook-delivery-table/index.ts
|
|
6329
|
+
import { Schema as Schema10 } from "effect";
|
|
6330
|
+
import { Component as Component6, UiSchema as UiSchema4 } from "effect/ui";
|
|
6331
|
+
|
|
6332
|
+
// ../../src/components/webhook-delivery-table/schema.ts
|
|
6333
|
+
import { Schema as Schema9 } from "effect";
|
|
6334
|
+
var WebhookDeliveryRowSchema = Schema9.Struct({
|
|
6335
|
+
id: Schema9.String,
|
|
6336
|
+
event: Schema9.String,
|
|
6337
|
+
status: Schema9.Literals(["pending", "success", "failed"]),
|
|
6338
|
+
retries: Schema9.Number,
|
|
6339
|
+
error: Schema9.NullOr(Schema9.String),
|
|
6340
|
+
retryAt: Schema9.Date,
|
|
6341
|
+
createdAt: Schema9.Date,
|
|
6342
|
+
completedAt: Schema9.NullOr(Schema9.Date),
|
|
6343
|
+
data: Schema9.Json
|
|
6344
|
+
}).annotate({ identifier: "WebhookDeliveryRow" });
|
|
6345
|
+
var Label2 = Schema9.Literals([
|
|
6346
|
+
"identifier",
|
|
6347
|
+
"event",
|
|
6348
|
+
"status",
|
|
6349
|
+
"pending",
|
|
6350
|
+
"success",
|
|
6351
|
+
"failed",
|
|
6352
|
+
"retries",
|
|
6353
|
+
"retryAt",
|
|
6354
|
+
"errorUnavailable",
|
|
6355
|
+
"payload",
|
|
6356
|
+
"viewPayload",
|
|
6357
|
+
"createdAt",
|
|
6358
|
+
"completedAt",
|
|
6359
|
+
"search",
|
|
6360
|
+
"allEvents",
|
|
6361
|
+
"allStatuses",
|
|
6362
|
+
"loading",
|
|
6363
|
+
"empty",
|
|
6364
|
+
"error",
|
|
6365
|
+
"close",
|
|
6366
|
+
"export",
|
|
6367
|
+
"links"
|
|
6368
|
+
]);
|
|
6369
|
+
var WebhookDeliverySharedPropsSchema = Schema9.Struct({
|
|
6370
|
+
entries: Schema9.Array(WebhookDeliveryRowSchema),
|
|
6371
|
+
rowCount: Schema9.Number,
|
|
6372
|
+
locale: Schema9.optional(Schema9.String),
|
|
6373
|
+
messages: Schema9.optional(Schema9.Record(Schema9.String, Schema9.Record(Label2, Schema9.optionalKey(Schema9.String)))),
|
|
6374
|
+
events: Schema9.optional(Schema9.Array(Schema9.Struct({ value: Schema9.String, label: Schema9.String })))
|
|
6375
|
+
}).annotate({ identifier: "WebhookDeliverySharedProps" });
|
|
6376
|
+
var WebhookDeliveryQuerySchema = Schema9.Struct({
|
|
6377
|
+
...DataTableQuerySchema.fields,
|
|
6378
|
+
search: Schema9.optional(Schema9.String),
|
|
6379
|
+
event: Schema9.optional(Schema9.String),
|
|
6380
|
+
status: Schema9.optional(WebhookDeliveryRowSchema.fields.status)
|
|
6381
|
+
}).annotate({ identifier: "WebhookDeliveryQuery" });
|
|
6382
|
+
var WebhookDeliveryTableHtmlPropsSchema = Schema9.Struct({
|
|
6383
|
+
...WebhookDeliverySharedPropsSchema.fields,
|
|
6384
|
+
query: WebhookDeliveryQuerySchema,
|
|
6385
|
+
status: Schema9.optional(Schema9.Literals(["loading", "error", "ready"])),
|
|
6386
|
+
canExport: Schema9.optional(Schema9.Boolean),
|
|
6387
|
+
links: Schema9.optional(Schema9.Record(Schema9.String, Schema9.Array(Schema9.Struct({
|
|
6388
|
+
label: Schema9.String,
|
|
6389
|
+
href: Schema9.String
|
|
6390
|
+
}))))
|
|
6391
|
+
}).annotate({ identifier: "WebhookDeliveryTableHtmlProps" });
|
|
6392
|
+
|
|
6393
|
+
// ../../src/components/webhook-delivery-table/index.ts
|
|
4941
6394
|
var translations = {
|
|
4942
6395
|
en: {
|
|
4943
6396
|
identifier: "ID",
|
|
@@ -4952,7 +6405,16 @@ var translations = {
|
|
|
4952
6405
|
payload: "Payload",
|
|
4953
6406
|
viewPayload: "View JSON",
|
|
4954
6407
|
createdAt: "Created",
|
|
4955
|
-
completedAt: "Completed"
|
|
6408
|
+
completedAt: "Completed",
|
|
6409
|
+
search: "Search",
|
|
6410
|
+
allEvents: "All events",
|
|
6411
|
+
allStatuses: "All statuses",
|
|
6412
|
+
loading: "Loading deliveries…",
|
|
6413
|
+
empty: "No deliveries",
|
|
6414
|
+
error: "Deliveries could not be loaded.",
|
|
6415
|
+
close: "Close",
|
|
6416
|
+
export: "Export CSV",
|
|
6417
|
+
links: "Links"
|
|
4956
6418
|
},
|
|
4957
6419
|
fr: {
|
|
4958
6420
|
identifier: "Identifiant",
|
|
@@ -4967,10 +6429,69 @@ var translations = {
|
|
|
4967
6429
|
payload: "Données",
|
|
4968
6430
|
viewPayload: "Voir le JSON",
|
|
4969
6431
|
createdAt: "Créé",
|
|
4970
|
-
completedAt: "Terminé"
|
|
6432
|
+
completedAt: "Terminé",
|
|
6433
|
+
search: "Rechercher",
|
|
6434
|
+
allEvents: "Tous les événements",
|
|
6435
|
+
allStatuses: "Tous les statuts",
|
|
6436
|
+
loading: "Chargement des livraisons…",
|
|
6437
|
+
empty: "Aucune livraison",
|
|
6438
|
+
error: "Impossible de charger les livraisons.",
|
|
6439
|
+
close: "Fermer",
|
|
6440
|
+
export: "Exporter en CSV",
|
|
6441
|
+
links: "Liens"
|
|
4971
6442
|
}
|
|
4972
6443
|
};
|
|
6444
|
+
var webhookDeliveryMessages = (locale, messages) => {
|
|
6445
|
+
const base = locale.split("-")[0] ?? locale;
|
|
6446
|
+
return {
|
|
6447
|
+
...base === "fr" ? translations.fr : translations.en,
|
|
6448
|
+
...messages?.[base],
|
|
6449
|
+
...messages?.[locale]
|
|
6450
|
+
};
|
|
6451
|
+
};
|
|
4973
6452
|
var webhookDeliveryStatus = (delivery) => delivery.status === "pending" && delivery.retries > 0 ? "failed" : delivery.status;
|
|
6453
|
+
var webhookDeliveryStatusDetails = (delivery, labels, dates) => webhookDeliveryStatus(delivery) === "failed" ? [
|
|
6454
|
+
delivery.error ?? labels.errorUnavailable,
|
|
6455
|
+
`${labels.retries}: ${delivery.retries}`,
|
|
6456
|
+
...delivery.status === "pending" ? [`${labels.retryAt}: ${dates.format(delivery.retryAt)}`] : []
|
|
6457
|
+
].join(" · ") : undefined;
|
|
6458
|
+
var WebhookDeliveryTableMessage = UiSchema4.TaggedEnum({
|
|
6459
|
+
OpenPayload: { id: Schema10.String },
|
|
6460
|
+
ClosePayload: {},
|
|
6461
|
+
QueryChanged: { query: WebhookDeliveryQuerySchema },
|
|
6462
|
+
ExportRequested: {}
|
|
6463
|
+
});
|
|
6464
|
+
var Events = UiSchema4.TaggedEnum({
|
|
6465
|
+
QueryChanged: { query: WebhookDeliveryQuerySchema },
|
|
6466
|
+
ExportRequested: { query: WebhookDeliveryQuerySchema }
|
|
6467
|
+
});
|
|
6468
|
+
var webhookDeliveryTableOptions = {
|
|
6469
|
+
name: "WebhookDeliveryTable",
|
|
6470
|
+
props: WebhookDeliveryTableHtmlPropsSchema,
|
|
6471
|
+
model: Schema10.Struct({
|
|
6472
|
+
selectedId: Schema10.NullOr(Schema10.String)
|
|
6473
|
+
}),
|
|
6474
|
+
message: WebhookDeliveryTableMessage,
|
|
6475
|
+
events: Events,
|
|
6476
|
+
restore: false
|
|
6477
|
+
};
|
|
6478
|
+
var update4 = Component6.define(webhookDeliveryTableOptions).update({
|
|
6479
|
+
OpenPayload: ($, { id }) => $.props.entries.some((row) => row.id === id) ? $.evolve({ selectedId: id }) : $.model,
|
|
6480
|
+
ClosePayload: ($) => $.evolve({ selectedId: null }),
|
|
6481
|
+
QueryChanged: ($, { query }) => $.emit(Events.QueryChanged({ query })),
|
|
6482
|
+
ExportRequested: ($) => $.props.canExport ? $.emit(Events.ExportRequested({ query: $.props.query })) : $.model
|
|
6483
|
+
});
|
|
6484
|
+
var webhookDeliveryTableBehaviours = {
|
|
6485
|
+
init: () => ({ selectedId: null }),
|
|
6486
|
+
update: update4
|
|
6487
|
+
};
|
|
6488
|
+
|
|
6489
|
+
// ../../src/components/webhook-delivery-table/react.tsx
|
|
6490
|
+
import { jsx as jsx19, jsxs as jsxs13, Fragment as Fragment2 } from "react/jsx-runtime";
|
|
6491
|
+
var DeliveryTableModel = Component7.define(webhookDeliveryTableOptions).make({
|
|
6492
|
+
...webhookDeliveryTableBehaviours,
|
|
6493
|
+
view: () => View4.text("")
|
|
6494
|
+
});
|
|
4974
6495
|
var WebhookDeliveryTable = ({
|
|
4975
6496
|
entries,
|
|
4976
6497
|
rowCount,
|
|
@@ -4983,14 +6504,13 @@ var WebhookDeliveryTable = ({
|
|
|
4983
6504
|
status
|
|
4984
6505
|
}) => {
|
|
4985
6506
|
const locale = useKrakstackLocale6(localeOverride);
|
|
4986
|
-
const
|
|
4987
|
-
const
|
|
4988
|
-
|
|
4989
|
-
|
|
4990
|
-
|
|
4991
|
-
|
|
4992
|
-
};
|
|
4993
|
-
const [selected, setSelected] = useState3(null);
|
|
6507
|
+
const labels = webhookDeliveryMessages(locale, messages);
|
|
6508
|
+
const { model, send } = useModel(DeliveryTableModel, {
|
|
6509
|
+
entries,
|
|
6510
|
+
rowCount,
|
|
6511
|
+
query: { page: state?.page ?? 0, pageSize: state?.pageSize ?? 20 }
|
|
6512
|
+
});
|
|
6513
|
+
const selected = entries.find(({ id }) => id === model.selectedId);
|
|
4994
6514
|
const dateFormatter = new Intl.DateTimeFormat(locale, {
|
|
4995
6515
|
dateStyle: "medium",
|
|
4996
6516
|
timeStyle: "short"
|
|
@@ -5024,16 +6544,9 @@ var WebhookDeliveryTable = ({
|
|
|
5024
6544
|
imageVariant: "square",
|
|
5025
6545
|
getItem: (delivery) => {
|
|
5026
6546
|
const displayStatus = webhookDeliveryStatus(delivery);
|
|
5027
|
-
const details = displayStatus === "failed" ? [
|
|
5028
|
-
delivery.error ?? labels.errorUnavailable,
|
|
5029
|
-
`${labels.retries}: ${delivery.retries}`,
|
|
5030
|
-
...delivery.status === "pending" ? [
|
|
5031
|
-
`${labels.retryAt}: ${dateFormatter.format(delivery.retryAt)}`
|
|
5032
|
-
] : []
|
|
5033
|
-
] : [];
|
|
5034
6547
|
return {
|
|
5035
6548
|
label: statusLabels[displayStatus],
|
|
5036
|
-
description:
|
|
6549
|
+
description: webhookDeliveryStatusDetails(delivery, labels, dateFormatter),
|
|
5037
6550
|
icon: displayStatus === "failed" ? /* @__PURE__ */ jsx19(X2, {}) : displayStatus === "success" ? /* @__PURE__ */ jsx19(Check3, {}) : /* @__PURE__ */ jsx19(Clock, {}),
|
|
5038
6551
|
iconClassName: displayStatus === "failed" ? "bg-destructive/10 text-destructive" : displayStatus === "success" ? "bg-success/10 text-success" : "bg-primary/10 text-primary"
|
|
5039
6552
|
};
|
|
@@ -5051,7 +6564,7 @@ var WebhookDeliveryTable = ({
|
|
|
5051
6564
|
size: "sm",
|
|
5052
6565
|
onClick: (event) => {
|
|
5053
6566
|
event.stopPropagation();
|
|
5054
|
-
|
|
6567
|
+
send(WebhookDeliveryTableMessage.OpenPayload({ id: data.id }));
|
|
5055
6568
|
},
|
|
5056
6569
|
children: [
|
|
5057
6570
|
/* @__PURE__ */ jsx19(FileJson2, {
|
|
@@ -5082,10 +6595,10 @@ var WebhookDeliveryTable = ({
|
|
|
5082
6595
|
}
|
|
5083
6596
|
}),
|
|
5084
6597
|
/* @__PURE__ */ jsx19(Dialog, {
|
|
5085
|
-
open: selected !==
|
|
6598
|
+
open: selected !== undefined,
|
|
5086
6599
|
onOpenChange: (open) => {
|
|
5087
6600
|
if (!open)
|
|
5088
|
-
|
|
6601
|
+
send(WebhookDeliveryTableMessage.ClosePayload());
|
|
5089
6602
|
},
|
|
5090
6603
|
children: /* @__PURE__ */ jsxs13(DialogContent, {
|
|
5091
6604
|
className: "grid max-h-[calc(100svh-2rem)] grid-rows-[auto_minmax(0,1fr)] overflow-hidden sm:max-w-4xl",
|