@krak-stack/registry 0.10.19 → 0.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +105 -0
- package/README.md +28 -7
- package/dist/components/agent/index.d.ts +454 -0
- package/dist/components/agent/react.d.ts +55 -0
- package/dist/components/agent/react.js +2594 -0
- package/dist/components/agent/schema.d.ts +55 -0
- package/dist/components/animated-list/classes.d.ts +9 -0
- package/dist/components/animated-list/html.d.ts +11 -0
- package/dist/components/animated-list/html.js +533 -0
- package/dist/components/animated-list/index.d.ts +205 -0
- package/dist/components/animated-list/react.d.ts +11 -0
- package/dist/components/animated-list/react.js +711 -0
- package/dist/components/animated-list/schema.d.ts +44 -0
- package/dist/components/animated-number/html.d.ts +19 -0
- package/dist/components/animated-number/html.js +101 -0
- package/dist/components/animated-number/index.d.ts +80 -0
- package/dist/components/{ui/animated-number.d.ts → animated-number/react.d.ts} +2 -7
- package/dist/components/animated-number/react.js +278 -0
- package/dist/components/animated-number/schema.d.ts +9 -0
- package/dist/components/app-brand/classes.d.ts +11 -0
- package/dist/components/app-brand/html.d.ts +26 -0
- package/dist/components/app-brand/html.js +78 -0
- package/dist/components/app-brand/react.d.ts +12 -0
- package/dist/components/app-brand/react.js +86 -0
- package/dist/components/app-brand/schema.d.ts +36 -0
- package/dist/components/app-switcher/classes.d.ts +15 -0
- package/dist/components/app-switcher/html.d.ts +72 -0
- package/dist/components/app-switcher/html.js +327 -0
- package/dist/components/app-switcher/index.d.ts +47 -0
- package/dist/components/app-switcher/react.d.ts +12 -0
- package/dist/components/{ui/app-switcher.js → app-switcher/react.js} +84 -15
- package/dist/components/app-switcher/schema.d.ts +39 -0
- package/dist/components/async-action-button/classes.d.ts +11 -0
- package/dist/components/async-action-button/html.d.ts +46 -0
- package/dist/components/async-action-button/html.js +266 -0
- package/dist/components/async-action-button/index.d.ts +73 -0
- package/dist/components/async-action-button/react.d.ts +10 -0
- package/dist/components/async-action-button/react.js +378 -0
- package/dist/components/async-action-button/schema.d.ts +28 -0
- package/dist/{services/events/client/audit-log-table.d.ts → components/audit-log-table/react.d.ts} +2 -2
- package/dist/{services/events/client/audit-log-table.js → components/audit-log-table/react.js} +2195 -918
- package/dist/components/auto-height/html.d.ts +8 -0
- package/dist/components/auto-height/html.js +81 -0
- package/dist/components/auto-height/index.d.ts +2 -0
- package/dist/components/{ui/auto-height.d.ts → auto-height/react.d.ts} +2 -4
- package/dist/components/auto-height/react.js +75 -0
- package/dist/components/auto-height/schema.d.ts +7 -0
- package/dist/components/bulk-list-input/classes.d.ts +7 -0
- package/dist/components/bulk-list-input/html.d.ts +41 -0
- package/dist/components/bulk-list-input/html.js +265 -0
- package/dist/components/bulk-list-input/index.d.ts +76 -0
- package/dist/components/bulk-list-input/react.d.ts +12 -0
- package/dist/components/{ui/bulk-list-input.js → bulk-list-input/react.js} +71 -4
- package/dist/components/bulk-list-input/schema.d.ts +33 -0
- package/dist/components/choice-cards/classes.d.ts +19 -0
- package/dist/components/choice-cards/html.d.ts +76 -0
- package/dist/components/choice-cards/html.js +237 -0
- package/dist/components/choice-cards/index.d.ts +1 -0
- package/dist/components/choice-cards/react.d.ts +21 -0
- package/dist/components/{ui/choice-cards.js → choice-cards/react.js} +29 -10
- package/dist/components/choice-cards/schema.d.ts +100 -0
- package/dist/components/code-block/classes.d.ts +13 -0
- package/dist/components/code-block/html.d.ts +21 -0
- package/dist/components/code-block/html.js +381 -0
- package/dist/components/code-block/index.d.ts +4 -0
- package/dist/components/code-block/react.d.ts +4 -0
- package/dist/components/code-block/react.js +493 -0
- package/dist/components/code-block/schema.d.ts +29 -0
- package/dist/components/color-input/classes.d.ts +9 -0
- package/dist/components/color-input/html.d.ts +48 -0
- package/dist/components/color-input/html.js +187 -0
- package/dist/components/color-input/index.d.ts +88 -0
- package/dist/components/color-input/react.d.ts +7 -0
- package/dist/components/{ui/color-picker.js → color-input/react.js} +165 -233
- package/dist/components/color-input/schema.d.ts +40 -0
- package/dist/components/copy-button/html.d.ts +48 -0
- package/dist/components/copy-button/html.js +266 -0
- package/dist/components/copy-button/index.d.ts +73 -0
- package/dist/components/copy-button/react.d.ts +12 -0
- package/dist/components/copy-button/react.js +388 -0
- package/dist/components/copy-button/schema.d.ts +37 -0
- package/dist/components/copy-value/html.d.ts +37 -0
- package/dist/components/copy-value/html.js +426 -0
- package/dist/components/copy-value/index.d.ts +57 -0
- package/dist/components/copy-value/react.d.ts +9 -0
- package/dist/components/copy-value/react.js +682 -0
- package/dist/components/copy-value/schema.d.ts +45 -0
- package/dist/components/cron-input/classes.d.ts +25 -0
- package/dist/components/cron-input/html.d.ts +36 -0
- package/dist/components/cron-input/html.js +204 -0
- package/dist/components/cron-input/index.d.ts +59 -0
- package/dist/components/cron-input/react.d.ts +7 -0
- package/dist/components/{ui/cron-expression-editor.js → cron-input/react.js} +126 -54
- package/dist/components/cron-input/schema.d.ts +24 -0
- package/dist/components/danger-confirmation/classes.d.ts +7 -0
- package/dist/components/danger-confirmation/html.d.ts +39 -0
- package/dist/components/danger-confirmation/html.js +227 -0
- package/dist/components/danger-confirmation/index.d.ts +113 -0
- package/dist/components/{ui/danger-confirmation.d.ts → danger-confirmation/react.d.ts} +3 -12
- package/dist/components/danger-confirmation/react.js +550 -0
- package/dist/components/danger-confirmation/schema.d.ts +34 -0
- package/dist/components/data-table/classes.d.ts +63 -0
- package/dist/components/data-table/html.d.ts +1938 -0
- package/dist/components/data-table/html.js +2682 -0
- package/dist/components/data-table/index.d.ts +2686 -0
- package/dist/components/data-table/react.d.ts +578 -0
- package/dist/components/{ui/data-table.js → data-table/react.js} +2189 -906
- package/dist/components/data-table/schema.d.ts +3012 -0
- package/dist/components/date-input/classes.d.ts +17 -0
- package/dist/components/date-input/html.d.ts +60 -0
- package/dist/components/date-input/html.js +418 -0
- package/dist/components/date-input/index.d.ts +91 -0
- package/dist/components/date-input/react.d.ts +10 -0
- package/dist/components/{ui/date-picker.js → date-input/react.js} +233 -79
- package/dist/components/date-input/schema.d.ts +41 -0
- package/dist/components/editable-text/classes.d.ts +17 -0
- package/dist/components/editable-text/html.d.ts +51 -0
- package/dist/components/editable-text/html.js +370 -0
- package/dist/components/editable-text/index.d.ts +143 -0
- package/dist/components/editable-text/react.d.ts +6 -0
- package/dist/components/editable-text/react.js +499 -0
- package/dist/components/editable-text/schema.d.ts +31 -0
- package/dist/components/editing-locale-switcher/classes.d.ts +7 -0
- package/dist/components/editing-locale-switcher/html.d.ts +27 -0
- package/dist/components/editing-locale-switcher/html.js +250 -0
- package/dist/components/editing-locale-switcher/index.d.ts +52 -0
- package/dist/components/editing-locale-switcher/react.d.ts +7 -0
- package/dist/components/{ui/editing-locale-switcher.js → editing-locale-switcher/react.js} +70 -17
- package/dist/components/editing-locale-switcher/schema.d.ts +16 -0
- package/dist/components/{ui/effect-form.d.ts → effect-form/react.d.ts} +2 -2
- package/dist/components/{ui/effect-form.js → effect-form/react.js} +309 -83
- package/dist/components/effectcn/alert-dialog.d.ts +13 -0
- package/dist/components/effectcn/button.d.ts +31 -0
- package/dist/components/effectcn/calendar.d.ts +12 -0
- package/dist/components/effectcn/checkbox.d.ts +10 -0
- package/dist/components/effectcn/combobox.d.ts +25 -0
- package/dist/components/effectcn/dialog.d.ts +19 -0
- package/dist/components/effectcn/field.d.ts +11 -0
- package/dist/components/effectcn/file-drop.d.ts +8 -0
- package/dist/components/effectcn/input.d.ts +26 -0
- package/dist/components/effectcn/menu.d.ts +85 -0
- package/dist/components/effectcn/menubar.d.ts +8 -0
- package/dist/components/effectcn/popover.d.ts +18 -0
- package/dist/components/effectcn/scroll-area.d.ts +12 -0
- package/dist/components/effectcn/select.d.ts +68 -0
- package/dist/components/effectcn/toast.d.ts +29 -0
- package/dist/components/email-composer/index.d.ts +229 -0
- package/dist/components/email-composer/labels.d.ts +12 -0
- package/dist/components/email-composer/react.d.ts +5 -0
- package/dist/components/email-composer/react.js +1354 -0
- package/dist/components/email-composer/schema.d.ts +42 -0
- package/dist/components/email-editor/classes.d.ts +21 -0
- package/dist/components/email-editor/html.d.ts +360 -0
- package/dist/components/email-editor/html.js +1706 -0
- package/dist/components/email-editor/index.d.ts +693 -0
- package/dist/components/{ui/email-editor.d.ts → email-editor/labels.d.ts} +1 -19
- package/dist/components/email-editor/legacy-editor.html.d.ts +160 -0
- package/dist/components/email-editor/react.d.ts +11 -0
- package/dist/components/{ui/email-editor.js → email-editor/react.js} +1057 -712
- package/dist/components/email-editor/schema.d.ts +162 -0
- package/dist/components/error-component/classes.d.ts +7 -0
- package/dist/components/error-component/html.d.ts +120 -0
- package/dist/components/error-component/html.js +346 -0
- package/dist/components/error-component/index.d.ts +69 -0
- package/dist/components/error-component/react.d.ts +8 -0
- package/dist/components/error-component/react.js +744 -0
- package/dist/components/error-component/schema.d.ts +56 -0
- package/dist/components/file-input/classes.d.ts +7 -0
- package/dist/components/file-input/html.d.ts +95 -0
- package/dist/components/file-input/html.js +368 -0
- package/dist/components/file-input/index.d.ts +99 -0
- package/dist/components/file-input/react.d.ts +11 -0
- package/dist/components/{ui/file-picker.js → file-input/react.js} +122 -19
- package/dist/components/file-input/schema.d.ts +37 -0
- package/dist/components/{ui/form.d.ts → form/react.d.ts} +4 -4
- package/dist/components/{ui/form.js → form/react.js} +314 -84
- package/dist/components/icon-input/html.d.ts +55 -0
- package/dist/components/icon-input/html.js +538 -0
- package/dist/components/icon-input/index.d.ts +143 -0
- package/dist/components/icon-input/react.d.ts +6 -0
- package/dist/components/{ui/icon-input.js → icon-input/react.js} +459 -89
- package/dist/components/icon-input/schema.d.ts +23 -0
- package/dist/components/image-crop-editor/classes.d.ts +19 -0
- package/dist/components/image-crop-editor/html.d.ts +66 -0
- package/dist/components/image-crop-editor/html.js +561 -0
- package/dist/components/image-crop-editor/index.d.ts +183 -0
- package/dist/components/image-crop-editor/react.d.ts +8 -0
- package/dist/components/image-crop-editor/react.js +802 -0
- package/dist/components/image-crop-editor/schema.d.ts +54 -0
- package/dist/components/krakstack-provider/html.d.ts +17 -0
- package/dist/components/krakstack-provider/html.js +37 -0
- package/dist/components/krakstack-provider/index.d.ts +7 -0
- package/dist/components/krakstack-provider/react.d.ts +8 -0
- package/dist/components/{ui/krakstack-provider.js → krakstack-provider/react.js} +14 -5
- package/dist/components/krakstack-provider/schema.d.ts +6 -0
- package/dist/components/loading/classes.d.ts +5 -0
- package/dist/components/loading/html.d.ts +18 -0
- package/dist/components/loading/html.js +166 -0
- package/dist/components/loading/index.d.ts +6 -0
- package/dist/components/loading/react.d.ts +4 -0
- package/dist/components/loading/react.js +51 -0
- package/dist/components/loading/schema.d.ts +23 -0
- package/dist/components/locale-switcher/html.d.ts +22 -0
- package/dist/components/locale-switcher/html.js +264 -0
- package/dist/components/locale-switcher/index.d.ts +50 -0
- package/dist/components/locale-switcher/react.d.ts +7 -0
- package/dist/components/{ui/locale-switcher.js → locale-switcher/react.js} +55 -22
- package/dist/components/locale-switcher/schema.d.ts +12 -0
- package/dist/components/map-menu/classes.d.ts +13 -0
- package/dist/components/map-menu/google-maps.d.ts +80 -0
- package/dist/components/map-menu/google-viewport.d.ts +7 -0
- package/dist/components/map-menu/html.d.ts +274 -0
- package/dist/components/map-menu/html.js +934 -0
- package/dist/components/map-menu/index.d.ts +246 -0
- package/dist/components/map-menu/map.d.ts +47 -0
- package/dist/components/map-menu/react.d.ts +40 -0
- package/dist/components/{ui/map-menu.js → map-menu/react.js} +502 -141
- package/dist/components/map-menu/schema.d.ts +132 -0
- package/dist/components/markdown/classes.d.ts +1 -0
- package/dist/components/markdown/html.d.ts +23 -0
- package/dist/components/markdown/html.js +510 -0
- package/dist/components/markdown/index.d.ts +6 -0
- package/dist/components/markdown/react.d.ts +3 -0
- package/dist/components/markdown/react.js +546 -0
- package/dist/components/markdown/schema.d.ts +20 -0
- package/dist/components/notification-menu/classes.d.ts +11 -0
- package/dist/components/notification-menu/html.d.ts +67 -0
- package/dist/components/notification-menu/html.js +425 -0
- package/dist/components/notification-menu/index.d.ts +132 -0
- package/dist/components/notification-menu/react.d.ts +57 -0
- package/dist/components/notification-menu/react.js +829 -0
- package/dist/components/notification-menu/schema.d.ts +59 -0
- package/dist/components/pagination/classes.d.ts +19 -0
- package/dist/components/pagination/html.d.ts +49 -0
- package/dist/components/pagination/html.js +387 -0
- package/dist/components/pagination/index.d.ts +109 -0
- package/dist/components/pagination/react.d.ts +9 -0
- package/dist/components/{ui/pagination.js → pagination/react.js} +130 -30
- package/dist/components/pagination/schema.d.ts +36 -0
- package/dist/components/phone-number-input/classes.d.ts +17 -0
- package/dist/components/phone-number-input/html.d.ts +52 -0
- package/dist/components/phone-number-input/html.js +655 -0
- package/dist/components/phone-number-input/index.d.ts +59 -0
- package/dist/components/phone-number-input/react.d.ts +11 -0
- package/dist/components/{ui/phone-number-input.js → phone-number-input/react.js} +368 -138
- package/dist/components/phone-number-input/schema.d.ts +31 -0
- package/dist/components/presence-transition/html.d.ts +13 -0
- package/dist/components/presence-transition/html.js +128 -0
- package/dist/components/presence-transition/index.d.ts +57 -0
- package/dist/components/{ui/presence-transition.d.ts → presence-transition/react.d.ts} +3 -5
- package/dist/components/presence-transition/react.js +293 -0
- package/dist/components/presence-transition/schema.d.ts +7 -0
- package/dist/components/registry-previews/component-example.d.ts +31 -0
- package/dist/components/registry-previews/component-example.js +679 -0
- package/dist/components/registry-previews/html-preview.d.ts +17 -0
- package/dist/components/registry-previews/html-preview.js +83 -0
- package/dist/components/rich-text-editor/classes.d.ts +15 -0
- package/dist/components/rich-text-editor/engine.d.ts +9 -0
- package/dist/components/rich-text-editor/html.d.ts +246 -0
- package/dist/components/rich-text-editor/html.js +830 -0
- package/dist/components/rich-text-editor/index.d.ts +453 -0
- package/dist/components/rich-text-editor/labels.d.ts +42 -0
- package/dist/components/rich-text-editor/react.d.ts +19 -0
- package/dist/components/rich-text-editor/react.js +1175 -0
- package/dist/components/rich-text-editor/schema.d.ts +116 -0
- package/dist/components/search-menu/classes.d.ts +9 -0
- package/dist/components/search-menu/html.d.ts +127 -0
- package/dist/components/search-menu/html.js +432 -0
- package/dist/components/search-menu/index.d.ts +85 -0
- package/dist/components/search-menu/react.d.ts +18 -0
- package/dist/components/{ui/search-menu.js → search-menu/react.js} +290 -31
- package/dist/components/search-menu/schema.d.ts +78 -0
- package/dist/components/select-with-custom-input/classes.d.ts +17 -0
- package/dist/components/select-with-custom-input/html.d.ts +60 -0
- package/dist/components/select-with-custom-input/html.js +238 -0
- package/dist/components/select-with-custom-input/index.d.ts +114 -0
- package/dist/components/select-with-custom-input/react.d.ts +7 -0
- package/dist/components/{ui/select-with-custom-input.js → select-with-custom-input/react.js} +134 -29
- package/dist/components/select-with-custom-input/schema.d.ts +54 -0
- package/dist/components/sidebar-layout/classes.d.ts +21 -0
- package/dist/components/sidebar-layout/html.d.ts +97 -0
- package/dist/components/sidebar-layout/html.js +361 -0
- package/dist/components/sidebar-layout/index.d.ts +57 -0
- package/dist/components/sidebar-layout/react.d.ts +30 -0
- package/dist/components/{ui/sidebar-layout.js → sidebar-layout/react.js} +353 -39
- package/dist/components/sidebar-layout/schema.d.ts +54 -0
- package/dist/components/stats-card/classes.d.ts +11 -0
- package/dist/components/stats-card/html.d.ts +15 -0
- package/dist/components/stats-card/html.js +55 -0
- package/dist/components/stats-card/react.d.ts +7 -0
- package/dist/components/{ui/stats-card.js → stats-card/react.js} +19 -15
- package/dist/components/stats-card/schema.d.ts +14 -0
- package/dist/components/stepper/classes.d.ts +39 -0
- package/dist/components/stepper/html.d.ts +107 -0
- package/dist/components/stepper/html.js +397 -0
- package/dist/components/stepper/index.d.ts +83 -0
- package/dist/components/stepper/react.d.ts +17 -0
- package/dist/components/{ui/stepper.js → stepper/react.js} +120 -21
- package/dist/components/stepper/schema.d.ts +52 -0
- package/dist/components/support/classes.d.ts +55 -0
- package/dist/components/support/form.d.ts +19 -0
- package/dist/components/support/html.d.ts +266 -0
- package/dist/components/support/html.js +604 -0
- package/dist/components/support/index.d.ts +226 -0
- package/dist/components/support/multipart.d.ts +21 -0
- package/dist/components/support/react.d.ts +54 -0
- package/dist/components/support/react.js +1252 -0
- package/dist/components/support/schema.d.ts +69 -0
- package/dist/components/support.d.ts +1 -66
- package/dist/components/theme-switcher/html.d.ts +28 -0
- package/dist/components/theme-switcher/html.js +288 -0
- package/dist/components/theme-switcher/index.d.ts +59 -0
- package/dist/components/{ui/theme-switcher.d.ts → theme-switcher/react.d.ts} +4 -12
- package/dist/components/{ui/theme-switcher.js → theme-switcher/react.js} +69 -35
- package/dist/components/theme-switcher/schema.d.ts +33 -0
- package/dist/components/time-input/classes.d.ts +23 -0
- package/dist/components/time-input/html.d.ts +75 -0
- package/dist/components/time-input/html.js +571 -0
- package/dist/components/time-input/index.d.ts +164 -0
- package/dist/components/time-input/react.d.ts +7 -0
- package/dist/components/{ui/time-picker.js → time-input/react.js} +286 -114
- package/dist/components/time-input/schema.d.ts +96 -0
- package/dist/components/timezone-input/classes.d.ts +13 -0
- package/dist/components/timezone-input/html.d.ts +58 -0
- package/dist/components/timezone-input/html.js +804 -0
- package/dist/components/timezone-input/index.d.ts +170 -0
- package/dist/components/timezone-input/react.d.ts +9 -0
- package/dist/components/{ui/timezone-select.js → timezone-input/react.js} +493 -106
- package/dist/components/timezone-input/schema.d.ts +43 -0
- package/dist/components/toast/classes.d.ts +7 -0
- package/dist/components/toast/html.d.ts +34 -0
- package/dist/components/toast/html.js +280 -0
- package/dist/components/toast/index.d.ts +10 -0
- package/dist/components/toast/react.d.ts +9 -0
- package/dist/components/{ui/toast.js → toast/react.js} +35 -15
- package/dist/components/toast/schema.d.ts +24 -0
- package/dist/{services/events/client/tracking-notice.d.ts → components/tracking-notice/react.d.ts} +7 -1
- package/dist/{services/events/client/tracking-notice.js → components/tracking-notice/react.js} +13 -7
- package/dist/components/ui/animated-list.d.ts +1 -21
- package/dist/components/ui/app-brand.d.ts +1 -33
- package/dist/components/ui/async-action-button.d.ts +1 -17
- package/dist/components/ui/code-block.d.ts +1 -14
- package/dist/components/ui/copy-button.d.ts +1 -21
- package/dist/components/ui/data-table.d.ts +1 -584
- package/dist/components/ui/krakstack-provider.d.ts +1 -9
- package/dist/components/ui/loading.d.ts +1 -13
- package/dist/components/ui/pagination.d.ts +1 -47
- package/dist/components/ui/rich-text-editor.d.ts +1 -70
- package/dist/components/ui/search-menu.d.ts +1 -36
- package/dist/components/ui/select.js +159 -0
- package/dist/components/ui/sidebar-layout.d.ts +1 -40
- package/dist/components/ui/virtualized-combobox.d.ts +1 -59
- package/dist/components/unsaved-changes-guard/html.d.ts +34 -0
- package/dist/components/unsaved-changes-guard/html.js +172 -0
- package/dist/components/unsaved-changes-guard/index.d.ts +56 -0
- package/dist/components/unsaved-changes-guard/react.d.ts +4 -0
- package/dist/components/{ui/unsaved-changes-guard.js → unsaved-changes-guard/react.js} +74 -11
- package/dist/components/unsaved-changes-guard/schema.d.ts +37 -0
- package/dist/components/upload-attachment/classes.d.ts +11 -0
- package/dist/components/upload-attachment/html.d.ts +84 -0
- package/dist/components/upload-attachment/html.js +312 -0
- package/dist/components/upload-attachment/index.d.ts +72 -0
- package/dist/components/upload-attachment/react.d.ts +9 -0
- package/dist/components/{ui/upload-attachment.js → upload-attachment/react.js} +114 -17
- package/dist/components/upload-attachment/schema.d.ts +53 -0
- package/dist/components/virtualized-combobox/classes.d.ts +7 -0
- package/dist/components/virtualized-combobox/html.d.ts +97 -0
- package/dist/components/virtualized-combobox/html.js +310 -0
- package/dist/components/virtualized-combobox/index.d.ts +182 -0
- package/dist/components/virtualized-combobox/react.d.ts +31 -0
- package/dist/components/{ui/virtualized-combobox.js → virtualized-combobox/react.js} +160 -40
- package/dist/components/virtualized-combobox/schema.d.ts +92 -0
- package/dist/components/webhook-delivery-table/html.d.ts +216 -0
- package/dist/components/webhook-delivery-table/html.js +3008 -0
- package/dist/components/webhook-delivery-table/index.d.ts +405 -0
- package/dist/components/webhook-delivery-table/react.d.ts +13 -0
- package/dist/{services/webhooks/client/delivery-table.js → components/webhook-delivery-table/react.js} +2475 -956
- package/dist/components/webhook-delivery-table/schema.d.ts +134 -0
- package/dist/lib/docs.d.ts +17 -1
- package/dist/lib/docs.integrations.server.js +358 -73
- package/dist/lib/docs.js +861 -293
- package/dist/lib/docs.server.js +342 -57
- package/dist/lib/documentation-toolkit.d.ts +4 -4
- package/dist/lib/documentation-toolkit.js +354 -69
- package/dist/lib/effect-ui-adapter/model-runtime.d.ts +17 -0
- package/dist/lib/effect-ui-adapter/use-model.d.ts +9 -0
- package/dist/lib/effectcn-form.d.ts +3 -0
- package/dist/lib/effectcn-form.js +54 -0
- package/dist/lib/email-composer/index.d.ts +12 -0
- package/dist/lib/email-composer/index.js +110 -0
- package/dist/lib/email-composer/schema.d.ts +14 -0
- package/dist/lib/email-composer/schema.js +13 -0
- package/dist/lib/email-document/legacy-rich-text/editor.d.ts +70 -0
- package/dist/lib/email-document/legacy-rich-text/model.d.ts +19 -0
- package/dist/lib/email-document/legacy-rich-text/schema.d.ts +65 -0
- package/dist/lib/email-document/legacy-rich-text/tiptap.d.ts +39 -0
- package/dist/lib/email-document/model.d.ts +1 -1
- package/dist/lib/email-document/model.js +2 -2
- package/dist/lib/email-document/render.js +2 -2
- package/dist/lib/email-document/schema.js +1 -1
- package/dist/lib/httpapi-toolkit.d.ts +1 -1
- package/dist/lib/lucide-effect.d.ts +39 -0
- package/dist/lib/markdown/content.d.ts +1 -12
- package/dist/lib/rich-text/model.d.ts +5 -19
- package/dist/lib/rich-text/model.js +79 -111
- package/dist/lib/rich-text/schema.d.ts +5 -55
- package/dist/lib/rich-text/schema.js +17 -36
- package/dist/lib/rich-text/tiptap.d.ts +12 -0
- package/dist/lib/webfetch-toolkit.d.ts +1 -1
- package/dist/services/agent/client/index.js +695 -179
- package/dist/services/agent/client/widget.d.ts +1 -55
- package/dist/services/notification/client/index.js +138 -27
- package/dist/services/notification/client/notification-menu.d.ts +1 -85
- package/dist/services/notification/public.js +138 -27
- package/dist/services/opentelemetry/browser.js +15 -9
- package/dist/services/webhooks/index.d.ts +4 -3
- package/package.json +199 -137
- package/dist/components/support-dialog.js +0 -881
- package/dist/components/support.js +0 -881
- package/dist/components/ui/animated-list.js +0 -414
- package/dist/components/ui/animated-number.js +0 -75
- package/dist/components/ui/app-brand.js +0 -126
- package/dist/components/ui/app-switcher.d.ts +0 -26
- package/dist/components/ui/async-action-button.js +0 -149
- package/dist/components/ui/auto-height.js +0 -86
- package/dist/components/ui/bulk-list-input.d.ts +0 -25
- package/dist/components/ui/choice-cards.d.ts +0 -33
- package/dist/components/ui/code-block.js +0 -221
- package/dist/components/ui/color-picker.d.ts +0 -31
- package/dist/components/ui/copy-button.js +0 -138
- package/dist/components/ui/copy-value.d.ts +0 -24
- package/dist/components/ui/copy-value.js +0 -352
- package/dist/components/ui/cron-expression-editor.d.ts +0 -16
- package/dist/components/ui/cron-expression-editor.schema.d.ts +0 -7
- package/dist/components/ui/danger-confirmation.js +0 -398
- package/dist/components/ui/date-picker.d.ts +0 -33
- package/dist/components/ui/date-picker.schema.d.ts +0 -9
- package/dist/components/ui/editable-text.d.ts +0 -19
- package/dist/components/ui/editable-text.js +0 -341
- package/dist/components/ui/editing-locale-switcher.d.ts +0 -11
- package/dist/components/ui/error-component.d.ts +0 -34
- package/dist/components/ui/error-component.js +0 -387
- package/dist/components/ui/file-picker.d.ts +0 -37
- package/dist/components/ui/icon-input.d.ts +0 -58
- package/dist/components/ui/image-crop-editor.d.ts +0 -41
- package/dist/components/ui/image-crop-editor.js +0 -417
- package/dist/components/ui/loading.js +0 -39
- package/dist/components/ui/locale-switcher.d.ts +0 -11
- package/dist/components/ui/map-menu-map.d.ts +0 -115
- package/dist/components/ui/map-menu.d.ts +0 -87
- package/dist/components/ui/phone-number-input.d.ts +0 -22
- package/dist/components/ui/phone-number-input.schema.d.ts +0 -7
- package/dist/components/ui/presence-transition.js +0 -94
- package/dist/components/ui/rich-text-editor.js +0 -1135
- package/dist/components/ui/select-with-custom-input.d.ts +0 -36
- package/dist/components/ui/stats-card.d.ts +0 -12
- package/dist/components/ui/stepper.d.ts +0 -37
- package/dist/components/ui/time-picker.d.ts +0 -50
- package/dist/components/ui/time-picker.schema.d.ts +0 -28
- package/dist/components/ui/timezone-select.d.ts +0 -57
- package/dist/components/ui/timezone-select.schema.d.ts +0 -9
- package/dist/components/ui/toast.d.ts +0 -18
- package/dist/components/ui/unsaved-changes-guard.d.ts +0 -16
- package/dist/components/ui/upload-attachment.d.ts +0 -39
- package/dist/lib/rich-text/dom.d.ts +0 -40
- package/dist/services/notification/persistence/drizzle.d.ts +0 -868
- package/dist/services/notification/persistence/drizzle.js +0 -214
- package/dist/services/notification/persistence/index.d.ts +0 -2
- package/dist/services/notification/persistence/index.js +0 -227
- package/dist/services/notification/persistence/schema.d.ts +0 -143
- package/dist/services/notification/persistence/schema.js +0 -118
- package/dist/services/webhooks/client/delivery-table.d.ts +0 -62
|
@@ -1,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
|
|
|
@@ -414,7 +413,7 @@ function SelectTrigger({
|
|
|
414
413
|
return /* @__PURE__ */ jsxs3(SelectPrimitive.Trigger, {
|
|
415
414
|
"data-slot": "select-trigger",
|
|
416
415
|
"data-size": size,
|
|
417
|
-
className: cn("flex w-fit items-center justify-between gap-1.5 rounded-md border
|
|
416
|
+
className: cn("border-input focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-placeholder:text-muted-foreground dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 flex w-fit items-center justify-between gap-1.5 rounded-md border bg-transparent py-2 pr-2 pl-2.5 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-3 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:ring-3 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", className),
|
|
418
417
|
...props,
|
|
419
418
|
children: [
|
|
420
419
|
children,
|
|
@@ -431,9 +430,9 @@ function SelectContent({
|
|
|
431
430
|
children,
|
|
432
431
|
side = "bottom",
|
|
433
432
|
sideOffset = 4,
|
|
434
|
-
align = "
|
|
433
|
+
align = "start",
|
|
435
434
|
alignOffset = 0,
|
|
436
|
-
alignItemWithTrigger =
|
|
435
|
+
alignItemWithTrigger = false,
|
|
437
436
|
...props
|
|
438
437
|
}) {
|
|
439
438
|
return /* @__PURE__ */ jsx8(SelectPrimitive.Portal, {
|
|
@@ -447,7 +446,7 @@ function SelectContent({
|
|
|
447
446
|
children: /* @__PURE__ */ jsxs3(SelectPrimitive.Popup, {
|
|
448
447
|
"data-slot": "select-content",
|
|
449
448
|
"data-align-trigger": alignItemWithTrigger,
|
|
450
|
-
className: cn("
|
|
449
|
+
className: cn("bg-popover text-popover-foreground ring-foreground/10 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 relative isolate z-50 max-h-(--available-height) w-(--anchor-width) max-w-(--available-width) min-w-0 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-md shadow-md ring-1 duration-100 data-[align-trigger=true]:animate-none", className),
|
|
451
450
|
...props,
|
|
452
451
|
children: [
|
|
453
452
|
/* @__PURE__ */ jsx8(SelectScrollUpButton, {}),
|
|
@@ -467,7 +466,7 @@ function SelectItem({
|
|
|
467
466
|
}) {
|
|
468
467
|
return /* @__PURE__ */ jsxs3(SelectPrimitive.Item, {
|
|
469
468
|
"data-slot": "select-item",
|
|
470
|
-
className: cn("relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none
|
|
469
|
+
className: cn("focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2", className),
|
|
471
470
|
...props,
|
|
472
471
|
children: [
|
|
473
472
|
/* @__PURE__ */ jsx8(SelectPrimitive.ItemText, {
|
|
@@ -491,7 +490,7 @@ function SelectScrollUpButton({
|
|
|
491
490
|
}) {
|
|
492
491
|
return /* @__PURE__ */ jsx8(SelectPrimitive.ScrollUpArrow, {
|
|
493
492
|
"data-slot": "select-scroll-up-button",
|
|
494
|
-
className: cn("top-0 z-10 flex w-full cursor-default items-center justify-center
|
|
493
|
+
className: cn("bg-popover top-0 z-10 flex w-full cursor-default items-center justify-center py-1 [&_svg:not([class*='size-'])]:size-4", className),
|
|
495
494
|
...props,
|
|
496
495
|
children: /* @__PURE__ */ jsx8(ChevronUpIcon, {})
|
|
497
496
|
});
|
|
@@ -502,44 +501,57 @@ function SelectScrollDownButton({
|
|
|
502
501
|
}) {
|
|
503
502
|
return /* @__PURE__ */ jsx8(SelectPrimitive.ScrollDownArrow, {
|
|
504
503
|
"data-slot": "select-scroll-down-button",
|
|
505
|
-
className: cn("bottom-0 z-10 flex w-full cursor-default items-center justify-center
|
|
504
|
+
className: cn("bg-popover bottom-0 z-10 flex w-full cursor-default items-center justify-center py-1 [&_svg:not([class*='size-'])]:size-4", className),
|
|
506
505
|
...props,
|
|
507
506
|
children: /* @__PURE__ */ jsx8(ChevronDownIcon, {})
|
|
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",
|
|
@@ -1340,46 +2879,21 @@ var messages2 = {
|
|
|
1340
2879
|
tableView: "Table",
|
|
1341
2880
|
galleryView: "Gallery",
|
|
1342
2881
|
columns: "Columns",
|
|
1343
|
-
groupBy: "Group by",
|
|
1344
|
-
sortAsc: "Ascending",
|
|
1345
|
-
sortDesc: "Descending",
|
|
1346
|
-
sortClear: "Clear sorting",
|
|
2882
|
+
groupBy: "Group by",
|
|
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, {
|
|
@@ -2805,9 +4073,10 @@ var ViewMenu = ({
|
|
|
2805
4073
|
}),
|
|
2806
4074
|
/* @__PURE__ */ jsx15(MenubarSeparator2, {}),
|
|
2807
4075
|
/* @__PURE__ */ jsxs9(MenubarRadioGroup, {
|
|
2808
|
-
onValueChange: (
|
|
2809
|
-
|
|
2810
|
-
|
|
4076
|
+
onValueChange: (input) => {
|
|
4077
|
+
const view = Schema6.decodeUnknownOption(DataTableViewSchema)(input);
|
|
4078
|
+
if (Option4.isSome(view)) {
|
|
4079
|
+
send(DataTableMessage.ViewPicked({ view: view.value }));
|
|
2811
4080
|
}
|
|
2812
4081
|
},
|
|
2813
4082
|
value: store.state.view,
|
|
@@ -2837,9 +4106,9 @@ var ViewMenu = ({
|
|
|
2837
4106
|
});
|
|
2838
4107
|
};
|
|
2839
4108
|
var ColumnMenu = ({
|
|
2840
|
-
|
|
4109
|
+
table
|
|
2841
4110
|
}) => {
|
|
2842
|
-
const [store,
|
|
4111
|
+
const [store, send] = table;
|
|
2843
4112
|
const columns = deriveModel(store).columns.filter(({ colDef }) => colDef.hideable !== false);
|
|
2844
4113
|
if (!columns.length)
|
|
2845
4114
|
return null;
|
|
@@ -2865,13 +4134,7 @@ var ColumnMenu = ({
|
|
|
2865
4134
|
/* @__PURE__ */ jsx15(MenubarSeparator2, {}),
|
|
2866
4135
|
columns.map((column) => /* @__PURE__ */ jsx15(MenubarCheckboxItem2, {
|
|
2867
4136
|
checked: store.state.columnVisibility[column.id] !== false,
|
|
2868
|
-
onCheckedChange: (visible) =>
|
|
2869
|
-
...state,
|
|
2870
|
-
columnVisibility: {
|
|
2871
|
-
...state.columnVisibility,
|
|
2872
|
-
[column.id]: visible
|
|
2873
|
-
}
|
|
2874
|
-
})),
|
|
4137
|
+
onCheckedChange: (visible) => send(DataTableMessage.ColumnVisibilityChanged({ id: column.id, visible })),
|
|
2875
4138
|
children: columnLabel(column)
|
|
2876
4139
|
}, column.id))
|
|
2877
4140
|
]
|
|
@@ -2881,54 +4144,43 @@ var ColumnMenu = ({
|
|
|
2881
4144
|
});
|
|
2882
4145
|
};
|
|
2883
4146
|
var ResizeHandle = ({
|
|
2884
|
-
|
|
4147
|
+
table
|
|
2885
4148
|
}) => {
|
|
2886
|
-
const
|
|
4149
|
+
const tableClasses = useContext2(DataTableSlotClassesContext);
|
|
4150
|
+
const [store, send] = table;
|
|
2887
4151
|
const columnId = useRequiredId(ColumnIdContext);
|
|
2888
|
-
const resizeRef = useRef(null);
|
|
2889
4152
|
const column = deriveModel(store).columns.find(({ id }) => id === columnId);
|
|
2890
4153
|
if (!column || column.colDef.resizable === false)
|
|
2891
4154
|
return null;
|
|
2892
|
-
const
|
|
2893
|
-
...state,
|
|
2894
|
-
columnSizing: {
|
|
2895
|
-
...state.columnSizing,
|
|
2896
|
-
[column.id]: clampWidth(column.colDef, width)
|
|
2897
|
-
}
|
|
2898
|
-
}));
|
|
4155
|
+
const { min, max } = tableColumnLimits(column.colDef);
|
|
2899
4156
|
const onPointerDown = (event) => {
|
|
2900
4157
|
if (event.button !== 0)
|
|
2901
4158
|
return;
|
|
2902
4159
|
event.preventDefault();
|
|
2903
4160
|
event.currentTarget.setPointerCapture(event.pointerId);
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
};
|
|
4161
|
+
send(DataTableMessage.ResizeStarted({
|
|
4162
|
+
id: column.id,
|
|
4163
|
+
x: event.clientX,
|
|
4164
|
+
pointerId: event.pointerId
|
|
4165
|
+
}));
|
|
2909
4166
|
};
|
|
2910
4167
|
const onPointerMove = (event) => {
|
|
2911
|
-
|
|
2912
|
-
if (!drag || drag.pointerId !== event.pointerId)
|
|
2913
|
-
return;
|
|
2914
|
-
resize(drag.startWidth + event.clientX - drag.startX);
|
|
2915
|
-
};
|
|
2916
|
-
const reset = () => {
|
|
2917
|
-
resizeRef.current = null;
|
|
4168
|
+
send(DataTableMessage.ResizeMoved({ x: event.clientX, pointerId: event.pointerId }));
|
|
2918
4169
|
};
|
|
4170
|
+
const reset = (event) => send(DataTableMessage.ResizeEnded({ pointerId: event.pointerId }));
|
|
2919
4171
|
return /* @__PURE__ */ jsx15("button", {
|
|
2920
4172
|
"aria-label": store.config.labels.resizeColumn(columnLabel(column)),
|
|
2921
4173
|
"aria-orientation": "vertical",
|
|
2922
|
-
"aria-valuemax":
|
|
2923
|
-
"aria-valuemin":
|
|
4174
|
+
"aria-valuemax": max,
|
|
4175
|
+
"aria-valuemin": min,
|
|
2924
4176
|
"aria-valuenow": column.width,
|
|
2925
|
-
className:
|
|
2926
|
-
onDoubleClick: () =>
|
|
4177
|
+
className: tableClasses.resizeHandle,
|
|
4178
|
+
onDoubleClick: () => send(DataTableMessage.ColumnResizeReset({ id: column.id })),
|
|
2927
4179
|
onKeyDown: (event) => {
|
|
2928
|
-
const delta = event.key
|
|
4180
|
+
const delta = tableResizeStep(event.key);
|
|
2929
4181
|
if (delta) {
|
|
2930
4182
|
event.preventDefault();
|
|
2931
|
-
|
|
4183
|
+
send(DataTableMessage.ColumnResized({ id: column.id, delta }));
|
|
2932
4184
|
}
|
|
2933
4185
|
},
|
|
2934
4186
|
onPointerDown,
|
|
@@ -2941,12 +4193,12 @@ var ResizeHandle = ({
|
|
|
2941
4193
|
});
|
|
2942
4194
|
};
|
|
2943
4195
|
var DragHandle = ({
|
|
2944
|
-
|
|
4196
|
+
table
|
|
2945
4197
|
}) => {
|
|
2946
|
-
const [store
|
|
4198
|
+
const [store] = table;
|
|
2947
4199
|
const rowId = useRequiredId(RowIdContext);
|
|
2948
|
-
const dragRef =
|
|
2949
|
-
const [overlay, setOverlay] =
|
|
4200
|
+
const dragRef = useRef2(null);
|
|
4201
|
+
const [overlay, setOverlay] = useState2(null);
|
|
2950
4202
|
const reset = (element) => {
|
|
2951
4203
|
clearDragPresentation(element.closest("[data-table-root]"));
|
|
2952
4204
|
dragRef.current = null;
|
|
@@ -3001,7 +4253,8 @@ var DragHandle = ({
|
|
|
3001
4253
|
const elements = document.elementsFromPoint(event.clientX, event.clientY);
|
|
3002
4254
|
const rowTarget = findTableDragTarget(elements, "[data-table-row]", root);
|
|
3003
4255
|
const groupTarget = findTableDragTarget(elements, "[data-table-group]", root);
|
|
3004
|
-
|
|
4256
|
+
if (drag.active) {
|
|
4257
|
+
const current = store;
|
|
3005
4258
|
const targetRowId = rowTarget?.dataset.tableRow;
|
|
3006
4259
|
const targetGroupKey = groupTarget?.dataset.tableGroup;
|
|
3007
4260
|
const model = deriveModel(current);
|
|
@@ -3017,8 +4270,7 @@ var DragHandle = ({
|
|
|
3017
4270
|
} else if (drag.active && source && targetRowId && reordering && canReorderRows(current) && source.id !== targetRowId) {
|
|
3018
4271
|
reordering.onReorder(reorderDataTableRows(model.rows, source.id, targetRowId));
|
|
3019
4272
|
}
|
|
3020
|
-
|
|
3021
|
-
});
|
|
4273
|
+
}
|
|
3022
4274
|
reset(event.currentTarget);
|
|
3023
4275
|
};
|
|
3024
4276
|
const cancel = (event) => {
|
|
@@ -3069,22 +4321,15 @@ var DragHandle = ({
|
|
|
3069
4321
|
]
|
|
3070
4322
|
});
|
|
3071
4323
|
};
|
|
3072
|
-
var toggleRow = (
|
|
3073
|
-
const rowSelection = { ...state.rowSelection, [rowId]: selected };
|
|
3074
|
-
const selection = store.config.features.selection;
|
|
3075
|
-
if (selection) {
|
|
3076
|
-
const model = deriveModel(store);
|
|
3077
|
-
selection.onSelectionChange?.(model.rows.filter((row) => rowSelection[row.id]).map((row) => row.data));
|
|
3078
|
-
}
|
|
3079
|
-
return { ...state, rowSelection };
|
|
3080
|
-
});
|
|
4324
|
+
var toggleRow = (send, rowId, checked) => send(DataTableMessage.SelectionRequested({ rowIds: [rowId], checked }));
|
|
3081
4325
|
var TableDataRow = ({
|
|
3082
|
-
|
|
4326
|
+
table,
|
|
3083
4327
|
row,
|
|
3084
4328
|
virtualIndex,
|
|
3085
4329
|
measureRef
|
|
3086
4330
|
}) => {
|
|
3087
|
-
const
|
|
4331
|
+
const tableClasses = useContext2(DataTableSlotClassesContext);
|
|
4332
|
+
const [store, send] = table;
|
|
3088
4333
|
const model = deriveModel(store);
|
|
3089
4334
|
const selection = store.config.features.selection;
|
|
3090
4335
|
const selectable = !!selection && (selection.isRowSelectable?.(row.data) ?? true);
|
|
@@ -3106,37 +4351,40 @@ var TableDataRow = ({
|
|
|
3106
4351
|
tabIndex: store.config.onRowClicked ? 0 : undefined,
|
|
3107
4352
|
children: [
|
|
3108
4353
|
selection ? /* @__PURE__ */ jsx15(TableCell2, {
|
|
3109
|
-
className:
|
|
4354
|
+
className: tableClasses.selectionCell,
|
|
3110
4355
|
onClick: (event) => event.stopPropagation(),
|
|
3111
|
-
children: /* @__PURE__ */ jsx15(
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
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
|
+
})
|
|
3116
4364
|
})
|
|
3117
4365
|
}) : null,
|
|
3118
4366
|
draggable ? /* @__PURE__ */ jsx15(TableCell2, {
|
|
3119
4367
|
className: "w-10 pr-0",
|
|
3120
4368
|
children: /* @__PURE__ */ jsx15(DragHandle, {
|
|
3121
|
-
|
|
4369
|
+
table
|
|
3122
4370
|
})
|
|
3123
4371
|
}) : null,
|
|
3124
4372
|
model.visibleColumns.map((column) => /* @__PURE__ */ jsx15(TableCell2, {
|
|
3125
|
-
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"),
|
|
3126
4374
|
style: { width: column.width },
|
|
3127
4375
|
children: /* @__PURE__ */ jsx15("div", {
|
|
3128
|
-
className: cn(
|
|
4376
|
+
className: cn(tableClasses.cellContent, column.colDef.truncate && "truncate"),
|
|
3129
4377
|
children: renderCell(row, column, store.config.locale, store.config.labels)
|
|
3130
4378
|
})
|
|
3131
4379
|
}, column.id)),
|
|
3132
4380
|
hasRowActionMenu(store) ? /* @__PURE__ */ jsx15(TableCell2, {
|
|
3133
|
-
className: "
|
|
4381
|
+
className: cn(tableClasses.actionsCell, "group-data-[state=selected]/row:bg-muted"),
|
|
3134
4382
|
onClick: (event) => event.stopPropagation(),
|
|
3135
4383
|
children: /* @__PURE__ */ jsx15("div", {
|
|
3136
|
-
className:
|
|
4384
|
+
className: tableClasses.actionsAlign,
|
|
3137
4385
|
children: /* @__PURE__ */ jsx15(DataTableRowActionMenu, {
|
|
3138
4386
|
row,
|
|
3139
|
-
|
|
4387
|
+
table
|
|
3140
4388
|
})
|
|
3141
4389
|
})
|
|
3142
4390
|
}) : null
|
|
@@ -3186,35 +4434,30 @@ var GroupActions = ({
|
|
|
3186
4434
|
});
|
|
3187
4435
|
};
|
|
3188
4436
|
var GroupHeaderRow = ({
|
|
3189
|
-
|
|
4437
|
+
table,
|
|
3190
4438
|
section,
|
|
3191
4439
|
colSpan,
|
|
3192
4440
|
virtualIndex,
|
|
3193
4441
|
measureRef
|
|
3194
4442
|
}) => {
|
|
3195
|
-
const
|
|
4443
|
+
const tableClasses = useContext2(DataTableSlotClassesContext);
|
|
4444
|
+
const [store, send] = table;
|
|
3196
4445
|
const collapsed = !!store.state.collapsedGroups[section.key];
|
|
3197
4446
|
return /* @__PURE__ */ jsx15(TableRow2, {
|
|
3198
4447
|
ref: measureRef,
|
|
3199
4448
|
"data-index": virtualIndex,
|
|
3200
4449
|
"aria-rowindex": virtualIndex === undefined ? undefined : virtualIndex + 2,
|
|
3201
|
-
className: "
|
|
3202
|
-
onClick: () =>
|
|
3203
|
-
...state,
|
|
3204
|
-
collapsedGroups: {
|
|
3205
|
-
...state.collapsedGroups,
|
|
3206
|
-
[section.key]: !collapsed
|
|
3207
|
-
}
|
|
3208
|
-
})),
|
|
4450
|
+
className: cn(tableClasses.group, "cursor-pointer"),
|
|
4451
|
+
onClick: () => send(DataTableMessage.GroupToggled({ key: section.key })),
|
|
3209
4452
|
children: /* @__PURE__ */ jsx15(TableCell2, {
|
|
3210
4453
|
className: "p-0",
|
|
3211
4454
|
colSpan,
|
|
3212
4455
|
children: /* @__PURE__ */ jsxs9("div", {
|
|
3213
|
-
className:
|
|
4456
|
+
className: cn(tableClasses.groupContent, tableClasses.groupSticky),
|
|
3214
4457
|
children: [
|
|
3215
4458
|
/* @__PURE__ */ jsxs9("button", {
|
|
3216
4459
|
"aria-expanded": !collapsed,
|
|
3217
|
-
className:
|
|
4460
|
+
className: tableClasses.groupTrigger,
|
|
3218
4461
|
style: { paddingLeft: section.depth * 20 },
|
|
3219
4462
|
type: "button",
|
|
3220
4463
|
children: [
|
|
@@ -3229,9 +4472,8 @@ var GroupHeaderRow = ({
|
|
|
3229
4472
|
})
|
|
3230
4473
|
]
|
|
3231
4474
|
}),
|
|
3232
|
-
/* @__PURE__ */ jsx15(
|
|
3233
|
-
className:
|
|
3234
|
-
variant: "secondary",
|
|
4475
|
+
/* @__PURE__ */ jsx15("span", {
|
|
4476
|
+
className: tableClasses.count,
|
|
3235
4477
|
children: section.rows.length
|
|
3236
4478
|
}),
|
|
3237
4479
|
/* @__PURE__ */ jsx15(GroupActions, {
|
|
@@ -3245,10 +4487,10 @@ var GroupHeaderRow = ({
|
|
|
3245
4487
|
});
|
|
3246
4488
|
};
|
|
3247
4489
|
var GroupedTable = ({
|
|
3248
|
-
|
|
4490
|
+
table,
|
|
3249
4491
|
sections
|
|
3250
4492
|
}) => {
|
|
3251
|
-
const [store] =
|
|
4493
|
+
const [store] = table;
|
|
3252
4494
|
const model = deriveModel(store);
|
|
3253
4495
|
const extra = (store.config.features.selection ? 1 : 0) + (hasRowActionMenu(store) ? 1 : 0) + (canDragRows(store) ? 1 : 0);
|
|
3254
4496
|
const renderSections = (items) => items.flatMap((section) => {
|
|
@@ -3259,7 +4501,7 @@ var GroupedTable = ({
|
|
|
3259
4501
|
"data-table-group": section.field.onMoveToGroup ? targetKey : undefined,
|
|
3260
4502
|
children: [
|
|
3261
4503
|
/* @__PURE__ */ jsx15(GroupHeaderRow, {
|
|
3262
|
-
|
|
4504
|
+
table,
|
|
3263
4505
|
section,
|
|
3264
4506
|
colSpan: model.visibleColumns.length + extra
|
|
3265
4507
|
}),
|
|
@@ -3267,7 +4509,7 @@ var GroupedTable = ({
|
|
|
3267
4509
|
value: row.id,
|
|
3268
4510
|
children: /* @__PURE__ */ jsx15(TableDataRow, {
|
|
3269
4511
|
row,
|
|
3270
|
-
|
|
4512
|
+
table
|
|
3271
4513
|
})
|
|
3272
4514
|
}, `${section.key}:${row.id}`)) : [
|
|
3273
4515
|
/* @__PURE__ */ jsx15(TableRow2, {
|
|
@@ -3287,9 +4529,10 @@ var GroupedTable = ({
|
|
|
3287
4529
|
});
|
|
3288
4530
|
};
|
|
3289
4531
|
var ColumnHeaderMenu = ({
|
|
3290
|
-
|
|
4532
|
+
table
|
|
3291
4533
|
}) => {
|
|
3292
|
-
const
|
|
4534
|
+
const tableClasses = useContext2(DataTableSlotClassesContext);
|
|
4535
|
+
const [store, send] = table;
|
|
3293
4536
|
const columnId = useRequiredId(ColumnIdContext);
|
|
3294
4537
|
const model = deriveModel(store);
|
|
3295
4538
|
const column = model.columns.find(({ id }) => id === columnId);
|
|
@@ -3305,18 +4548,13 @@ var ColumnHeaderMenu = ({
|
|
|
3305
4548
|
rows: model.rows,
|
|
3306
4549
|
current: store.state.filters?.find((filter) => filter.id === field.id),
|
|
3307
4550
|
labels: store.config.labels,
|
|
3308
|
-
onChange: (filter) =>
|
|
4551
|
+
onChange: (filter) => send(DataTableMessage.ColumnFilterChanged({ id: field.id, filter: filter ?? null }))
|
|
3309
4552
|
});
|
|
3310
4553
|
const sortingEnabled = store.config.features.sorting !== false && sortColumns.length > 0;
|
|
3311
4554
|
const hidingEnabled = store.config.features.columnVisibility !== false && column.colDef.hideable !== false;
|
|
3312
4555
|
const ownsSort = (id) => id === column.id || sortColumns.some((field) => field.id === id);
|
|
3313
4556
|
const sort = store.state.sort?.find(({ id }) => ownsSort(id));
|
|
3314
|
-
const
|
|
3315
|
-
const setSort = (id, direction) => update((state) => ({
|
|
3316
|
-
...state,
|
|
3317
|
-
sort: [{ id, direction }],
|
|
3318
|
-
page: 0
|
|
3319
|
-
}));
|
|
4557
|
+
const setSort = (id, direction) => send(DataTableMessage.SortRequested({ columnId: id, direction }));
|
|
3320
4558
|
const label = columnLabel(column);
|
|
3321
4559
|
const sortItems = (field) => /* @__PURE__ */ jsxs9(Fragment, {
|
|
3322
4560
|
children: [
|
|
@@ -3350,7 +4588,7 @@ var ColumnHeaderMenu = ({
|
|
|
3350
4588
|
render: /* @__PURE__ */ jsxs9(Button, {
|
|
3351
4589
|
"aria-label": label,
|
|
3352
4590
|
"aria-description": activeFilters.length ? `${store.config.labels.filters}: ${activeFilters.length}` : undefined,
|
|
3353
|
-
className:
|
|
4591
|
+
className: tableClasses.headerTrigger,
|
|
3354
4592
|
variant: "ghost",
|
|
3355
4593
|
children: [
|
|
3356
4594
|
/* @__PURE__ */ jsx15("span", {
|
|
@@ -3382,10 +4620,7 @@ var ColumnHeaderMenu = ({
|
|
|
3382
4620
|
]
|
|
3383
4621
|
}, field.id)) : sortItems(column),
|
|
3384
4622
|
sort ? /* @__PURE__ */ jsxs9(DropdownMenuItem2, {
|
|
3385
|
-
onClick: () =>
|
|
3386
|
-
...state,
|
|
3387
|
-
sort: state.sort?.filter(({ id }) => !ownsSort(id))
|
|
3388
|
-
})),
|
|
4623
|
+
onClick: () => send(DataTableMessage.ColumnSortCleared({ id: column.id })),
|
|
3389
4624
|
children: [
|
|
3390
4625
|
/* @__PURE__ */ jsx15(X, {}),
|
|
3391
4626
|
" ",
|
|
@@ -3427,14 +4662,7 @@ var ColumnHeaderMenu = ({
|
|
|
3427
4662
|
]
|
|
3428
4663
|
}),
|
|
3429
4664
|
activeFilters.length ? /* @__PURE__ */ jsxs9(DropdownMenuItem2, {
|
|
3430
|
-
onClick: () =>
|
|
3431
|
-
const filters = state.filters?.filter(({ id }) => !ownsFilter(id));
|
|
3432
|
-
return {
|
|
3433
|
-
...state,
|
|
3434
|
-
page: 0,
|
|
3435
|
-
filters: filters?.length ? filters : undefined
|
|
3436
|
-
};
|
|
3437
|
-
}),
|
|
4665
|
+
onClick: () => send(DataTableMessage.ColumnFiltersCleared({ id: column.id })),
|
|
3438
4666
|
children: [
|
|
3439
4667
|
/* @__PURE__ */ jsx15(X, {}),
|
|
3440
4668
|
store.config.labels.filterClear
|
|
@@ -3444,12 +4672,9 @@ var ColumnHeaderMenu = ({
|
|
|
3444
4672
|
}) : null,
|
|
3445
4673
|
(sortingEnabled || filteringEnabled) && hidingEnabled ? /* @__PURE__ */ jsx15(DropdownMenuSeparator2, {}) : null,
|
|
3446
4674
|
hidingEnabled ? /* @__PURE__ */ jsxs9(DropdownMenuItem2, {
|
|
3447
|
-
onClick: () =>
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
...state.columnVisibility,
|
|
3451
|
-
[column.id]: false
|
|
3452
|
-
}
|
|
4675
|
+
onClick: () => send(DataTableMessage.ColumnVisibilityChanged({
|
|
4676
|
+
id: column.id,
|
|
4677
|
+
visible: false
|
|
3453
4678
|
})),
|
|
3454
4679
|
children: [
|
|
3455
4680
|
/* @__PURE__ */ jsx15(EyeOff, {}),
|
|
@@ -3464,36 +4689,37 @@ var ColumnHeaderMenu = ({
|
|
|
3464
4689
|
});
|
|
3465
4690
|
};
|
|
3466
4691
|
var DataTableHeader = ({
|
|
3467
|
-
|
|
4692
|
+
table,
|
|
3468
4693
|
sticky
|
|
3469
4694
|
}) => {
|
|
3470
|
-
const
|
|
4695
|
+
const tableClasses = useContext2(DataTableSlotClassesContext);
|
|
4696
|
+
const [store, send] = table;
|
|
3471
4697
|
const model = deriveModel(store);
|
|
3472
4698
|
const selection = store.config.features.selection;
|
|
3473
|
-
const grouped = getActiveGrouping(store).length > 0;
|
|
3474
4699
|
const draggable = canDragRows(store);
|
|
3475
|
-
const selectableRows =
|
|
4700
|
+
const selectableRows = model.pageRows.filter((row) => !selection || (selection.isRowSelectable?.(row.data) ?? true));
|
|
3476
4701
|
const allSelected = selectableRows.length > 0 && selectableRows.every((row) => store.state.rowSelection[row.id]);
|
|
3477
4702
|
const someSelected = selectableRows.some((row) => store.state.rowSelection[row.id]);
|
|
3478
4703
|
return /* @__PURE__ */ jsx15(TableHeader2, {
|
|
3479
|
-
className: sticky ?
|
|
4704
|
+
className: sticky ? cn(tableClasses.stickyHeader, tableClasses.stickyHeaderRule, "[&_tr]:border-b-0") : undefined,
|
|
3480
4705
|
children: /* @__PURE__ */ jsxs9(TableRow2, {
|
|
3481
4706
|
"aria-rowindex": sticky ? 1 : undefined,
|
|
3482
4707
|
children: [
|
|
3483
4708
|
selection ? /* @__PURE__ */ jsx15(TableHead2, {
|
|
3484
|
-
className:
|
|
3485
|
-
children: /* @__PURE__ */ jsx15(
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
|
|
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
|
+
})
|
|
3497
4723
|
})
|
|
3498
4724
|
}) : null,
|
|
3499
4725
|
draggable ? /* @__PURE__ */ jsx15(TableHead2, {
|
|
@@ -3503,17 +4729,17 @@ var DataTableHeader = ({
|
|
|
3503
4729
|
const direction = store.state.sort?.find(({ id }) => id === column.id)?.direction;
|
|
3504
4730
|
return /* @__PURE__ */ jsx15(TableHead2, {
|
|
3505
4731
|
"aria-sort": direction === "asc" ? "ascending" : direction === "desc" ? "descending" : undefined,
|
|
3506
|
-
className:
|
|
4732
|
+
className: tableClasses.header,
|
|
3507
4733
|
scope: "col",
|
|
3508
4734
|
style: { width: column.width },
|
|
3509
4735
|
children: /* @__PURE__ */ jsxs9(ColumnIdContext.Provider, {
|
|
3510
4736
|
value: column.id,
|
|
3511
4737
|
children: [
|
|
3512
4738
|
/* @__PURE__ */ jsx15(ColumnHeaderMenu, {
|
|
3513
|
-
|
|
4739
|
+
table
|
|
3514
4740
|
}),
|
|
3515
4741
|
/* @__PURE__ */ jsx15(ResizeHandle, {
|
|
3516
|
-
|
|
4742
|
+
table
|
|
3517
4743
|
})
|
|
3518
4744
|
]
|
|
3519
4745
|
})
|
|
@@ -3527,13 +4753,13 @@ var DataTableHeader = ({
|
|
|
3527
4753
|
});
|
|
3528
4754
|
};
|
|
3529
4755
|
var VirtualTableRows = ({
|
|
3530
|
-
|
|
4756
|
+
table,
|
|
3531
4757
|
rows,
|
|
3532
4758
|
sections,
|
|
3533
4759
|
viewport,
|
|
3534
4760
|
colSpan
|
|
3535
4761
|
}) => {
|
|
3536
|
-
const [{ state, config }] =
|
|
4762
|
+
const [{ state, config }] = table;
|
|
3537
4763
|
const { element: scrollElement, headerHeight } = viewport;
|
|
3538
4764
|
const pageScroll = viewport.options.scroll === "page";
|
|
3539
4765
|
const scrollMargin = viewport.pageOffset ?? headerHeight;
|
|
@@ -3565,7 +4791,7 @@ var VirtualTableRows = ({
|
|
|
3565
4791
|
result.push({ key: `row:${row.id}`, kind: "data", row });
|
|
3566
4792
|
return result;
|
|
3567
4793
|
}, [rows, sections, state.collapsedGroups]);
|
|
3568
|
-
|
|
4794
|
+
useLayoutEffect2(() => {
|
|
3569
4795
|
if (!pageScroll && scrollElement)
|
|
3570
4796
|
scrollElement.scrollTop = 0;
|
|
3571
4797
|
}, [
|
|
@@ -3580,7 +4806,7 @@ var VirtualTableRows = ({
|
|
|
3580
4806
|
]);
|
|
3581
4807
|
const options = {
|
|
3582
4808
|
count: entries.length,
|
|
3583
|
-
getItemKey:
|
|
4809
|
+
getItemKey: useCallback2((index) => entries[index].key, [entries]),
|
|
3584
4810
|
estimateSize: () => viewport.options.estimateRowHeight ?? 64,
|
|
3585
4811
|
overscan: viewport.options.overscan ?? 5,
|
|
3586
4812
|
scrollMargin
|
|
@@ -3618,7 +4844,7 @@ var VirtualTableRows = ({
|
|
|
3618
4844
|
return /* @__PURE__ */ jsx15(TableDataRow, {
|
|
3619
4845
|
measureRef: virtualizer.measureElement,
|
|
3620
4846
|
row: entry.row,
|
|
3621
|
-
|
|
4847
|
+
table,
|
|
3622
4848
|
virtualIndex: index
|
|
3623
4849
|
}, key);
|
|
3624
4850
|
if (entry.kind === "header")
|
|
@@ -3626,7 +4852,7 @@ var VirtualTableRows = ({
|
|
|
3626
4852
|
measureRef: virtualizer.measureElement,
|
|
3627
4853
|
section: entry.section,
|
|
3628
4854
|
colSpan,
|
|
3629
|
-
|
|
4855
|
+
table,
|
|
3630
4856
|
virtualIndex: index
|
|
3631
4857
|
}, key);
|
|
3632
4858
|
return /* @__PURE__ */ jsx15(TableRow2, {
|
|
@@ -3645,21 +4871,20 @@ var VirtualTableRows = ({
|
|
|
3645
4871
|
});
|
|
3646
4872
|
};
|
|
3647
4873
|
var DataTableBody = ({
|
|
3648
|
-
|
|
4874
|
+
table,
|
|
3649
4875
|
viewport
|
|
3650
4876
|
}) => {
|
|
3651
|
-
const styles =
|
|
3652
|
-
const [store] =
|
|
4877
|
+
const styles = useContext2(DataTableStylesContext);
|
|
4878
|
+
const [store] = table;
|
|
3653
4879
|
const model = deriveModel(store);
|
|
3654
4880
|
const fields = getActiveGrouping(store);
|
|
3655
|
-
const
|
|
3656
|
-
const rows = grouped ? model.sortedRows : model.pageRows;
|
|
4881
|
+
const rows = model.pageRows;
|
|
3657
4882
|
const sections = useMemo2(() => groupDataTableRows(rows, fields), [rows, fields]);
|
|
3658
4883
|
const colSpan = model.visibleColumns.length + (store.config.features.selection ? 1 : 0) + (hasRowActionMenu(store) ? 1 : 0) + (canDragRows(store) ? 1 : 0);
|
|
3659
4884
|
const showGroups = sections.length && (rows.length || !store.config.status.loading) && !store.config.status.error;
|
|
3660
4885
|
if (showGroups && !viewport) {
|
|
3661
4886
|
return /* @__PURE__ */ jsx15(GroupedTable, {
|
|
3662
|
-
|
|
4887
|
+
table,
|
|
3663
4888
|
sections
|
|
3664
4889
|
});
|
|
3665
4890
|
}
|
|
@@ -3685,30 +4910,17 @@ var DataTableBody = ({
|
|
|
3685
4910
|
colSpan,
|
|
3686
4911
|
rows,
|
|
3687
4912
|
sections,
|
|
3688
|
-
|
|
4913
|
+
table,
|
|
3689
4914
|
viewport
|
|
3690
4915
|
}) : rows.map((row) => /* @__PURE__ */ jsx15(RowIdContext.Provider, {
|
|
3691
4916
|
value: row.id,
|
|
3692
4917
|
children: /* @__PURE__ */ jsx15(TableDataRow, {
|
|
3693
4918
|
row,
|
|
3694
|
-
|
|
4919
|
+
table
|
|
3695
4920
|
})
|
|
3696
4921
|
}, row.id))
|
|
3697
4922
|
});
|
|
3698
4923
|
};
|
|
3699
|
-
var GalleryImage = ({ src, alt }) => {
|
|
3700
|
-
const [failed, setFailed] = useState(false);
|
|
3701
|
-
if (failed)
|
|
3702
|
-
return null;
|
|
3703
|
-
return /* @__PURE__ */ jsx15("img", {
|
|
3704
|
-
src,
|
|
3705
|
-
alt,
|
|
3706
|
-
loading: "lazy",
|
|
3707
|
-
decoding: "async",
|
|
3708
|
-
className: "aspect-video w-full object-cover",
|
|
3709
|
-
onError: () => setFailed(true)
|
|
3710
|
-
});
|
|
3711
|
-
};
|
|
3712
4924
|
var GalleryTag = ({
|
|
3713
4925
|
row,
|
|
3714
4926
|
column,
|
|
@@ -3735,9 +4947,9 @@ var GalleryTag = ({
|
|
|
3735
4947
|
});
|
|
3736
4948
|
};
|
|
3737
4949
|
var GalleryCard = ({
|
|
3738
|
-
|
|
4950
|
+
table
|
|
3739
4951
|
}) => {
|
|
3740
|
-
const [store,
|
|
4952
|
+
const [store, send] = table;
|
|
3741
4953
|
const rowId = useRequiredId(RowIdContext);
|
|
3742
4954
|
const model = deriveModel(store);
|
|
3743
4955
|
const row = model.sortedRows.find((candidate) => candidate.id === rowId);
|
|
@@ -3766,10 +4978,14 @@ var GalleryCard = ({
|
|
|
3766
4978
|
},
|
|
3767
4979
|
tabIndex: store.config.onRowClicked ? 0 : undefined,
|
|
3768
4980
|
children: [
|
|
3769
|
-
imageSrc ? /* @__PURE__ */ jsx15(
|
|
4981
|
+
imageSrc && !store.ui.failedImages.includes(imageSrc) ? /* @__PURE__ */ jsx15("img", {
|
|
3770
4982
|
src: imageSrc,
|
|
3771
|
-
alt: gallery.image?.getAlt?.(row.data) ?? ""
|
|
3772
|
-
|
|
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,
|
|
3773
4989
|
/* @__PURE__ */ jsxs9(CardHeader, {
|
|
3774
4990
|
className: cn("relative", hasRowActionMenu(store) && "pr-12"),
|
|
3775
4991
|
children: [
|
|
@@ -3780,11 +4996,11 @@ var GalleryCard = ({
|
|
|
3780
4996
|
"aria-label": store.config.labels.selectRow,
|
|
3781
4997
|
checked: !!store.state.rowSelection[row.id],
|
|
3782
4998
|
disabled: !selectable,
|
|
3783
|
-
onCheckedChange: (checked) => toggleRow(
|
|
4999
|
+
onCheckedChange: (checked) => toggleRow(send, row.id, checked),
|
|
3784
5000
|
onClick: (event) => event.stopPropagation()
|
|
3785
5001
|
}) : null,
|
|
3786
5002
|
draggable ? /* @__PURE__ */ jsx15(DragHandle, {
|
|
3787
|
-
|
|
5003
|
+
table
|
|
3788
5004
|
}) : null
|
|
3789
5005
|
]
|
|
3790
5006
|
}) : null,
|
|
@@ -3813,7 +5029,7 @@ var GalleryCard = ({
|
|
|
3813
5029
|
onClick: (event) => event.stopPropagation(),
|
|
3814
5030
|
children: /* @__PURE__ */ jsx15(DataTableRowActionMenu, {
|
|
3815
5031
|
row,
|
|
3816
|
-
|
|
5032
|
+
table
|
|
3817
5033
|
})
|
|
3818
5034
|
}) : null
|
|
3819
5035
|
]
|
|
@@ -3822,13 +5038,13 @@ var GalleryCard = ({
|
|
|
3822
5038
|
});
|
|
3823
5039
|
};
|
|
3824
5040
|
var DataTableGallery = ({
|
|
3825
|
-
|
|
5041
|
+
table
|
|
3826
5042
|
}) => {
|
|
3827
|
-
const styles =
|
|
3828
|
-
const [store,
|
|
5043
|
+
const styles = useContext2(DataTableStylesContext);
|
|
5044
|
+
const [store, send] = table;
|
|
3829
5045
|
const model = deriveModel(store);
|
|
3830
5046
|
const fields = getActiveGrouping(store);
|
|
3831
|
-
const rows =
|
|
5047
|
+
const rows = model.pageRows;
|
|
3832
5048
|
const sections = groupDataTableRows(rows, fields);
|
|
3833
5049
|
if (store.config.status.error) {
|
|
3834
5050
|
return /* @__PURE__ */ jsx15("div", {
|
|
@@ -3860,7 +5076,7 @@ var DataTableGallery = ({
|
|
|
3860
5076
|
children: rows.map((row) => /* @__PURE__ */ jsx15(RowIdContext.Provider, {
|
|
3861
5077
|
value: row.id,
|
|
3862
5078
|
children: /* @__PURE__ */ jsx15(GalleryCard, {
|
|
3863
|
-
|
|
5079
|
+
table
|
|
3864
5080
|
})
|
|
3865
5081
|
}, row.id))
|
|
3866
5082
|
});
|
|
@@ -3868,13 +5084,7 @@ var DataTableGallery = ({
|
|
|
3868
5084
|
const renderSections = (sections) => sections.map((section) => {
|
|
3869
5085
|
const collapsed = !!store.state.collapsedGroups[section.key];
|
|
3870
5086
|
const targetKey = getGroupDropKey(section.field.id, section.groupId);
|
|
3871
|
-
const toggleCollapsed = () =>
|
|
3872
|
-
...state,
|
|
3873
|
-
collapsedGroups: {
|
|
3874
|
-
...state.collapsedGroups,
|
|
3875
|
-
[section.key]: !collapsed
|
|
3876
|
-
}
|
|
3877
|
-
}));
|
|
5087
|
+
const toggleCollapsed = () => send(DataTableMessage.GroupToggled({ key: section.key }));
|
|
3878
5088
|
return /* @__PURE__ */ jsxs9("section", {
|
|
3879
5089
|
className: "data-[drop-target=true]:ring-primary space-y-3 rounded-lg transition-shadow data-[drop-target=true]:ring-2",
|
|
3880
5090
|
"data-table-group": section.field.onMoveToGroup ? targetKey : undefined,
|
|
@@ -3916,7 +5126,7 @@ var DataTableGallery = ({
|
|
|
3916
5126
|
children: section.rows.map((row) => /* @__PURE__ */ jsx15(RowIdContext.Provider, {
|
|
3917
5127
|
value: row.id,
|
|
3918
5128
|
children: /* @__PURE__ */ jsx15(GalleryCard, {
|
|
3919
|
-
|
|
5129
|
+
table
|
|
3920
5130
|
})
|
|
3921
5131
|
}, `${section.key}:${row.id}`))
|
|
3922
5132
|
}) : /* @__PURE__ */ jsx15("div", {
|
|
@@ -3932,38 +5142,32 @@ var DataTableGallery = ({
|
|
|
3932
5142
|
});
|
|
3933
5143
|
};
|
|
3934
5144
|
var DataTablePagination = ({
|
|
3935
|
-
|
|
5145
|
+
table
|
|
3936
5146
|
}) => {
|
|
3937
|
-
const styles =
|
|
3938
|
-
const [store,
|
|
5147
|
+
const styles = useContext2(DataTableStylesContext);
|
|
5148
|
+
const [store, send] = table;
|
|
3939
5149
|
const model = deriveModel(store);
|
|
3940
5150
|
const pagination = store.config.features.pagination ?? false;
|
|
3941
|
-
const
|
|
3942
|
-
const paginationVisible = pagination !== false && !clientGrouping;
|
|
5151
|
+
const { paginationVisible, page } = model;
|
|
3943
5152
|
const pageIndex = store.state.page;
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
changeState(setStore, (state) => ({
|
|
3948
|
-
...state,
|
|
3949
|
-
page: maxPageIndex
|
|
3950
|
-
}));
|
|
5153
|
+
useLayoutEffect2(() => {
|
|
5154
|
+
if (paginationVisible && pagination && pagination.mode === "client" && pageIndex > page) {
|
|
5155
|
+
send(DataTableMessage.PageRequested({ page }));
|
|
3951
5156
|
}
|
|
3952
|
-
}, [
|
|
3953
|
-
if (!paginationVisible)
|
|
5157
|
+
}, [page, pageIndex, pagination, paginationVisible, send]);
|
|
5158
|
+
if (!paginationVisible || !pagination)
|
|
3954
5159
|
return null;
|
|
3955
5160
|
const selected = model.rows.filter((row) => store.state.rowSelection[row.id]).length;
|
|
3956
|
-
const setPagination = (next) => changeState(setStore, (state) => ({ ...state, ...next }));
|
|
3957
5161
|
return /* @__PURE__ */ jsx15("div", {
|
|
3958
5162
|
"data-table-slot": "pagination",
|
|
3959
|
-
className: cn("pt-4", styles?.pagination),
|
|
5163
|
+
className: cn("shrink-0 pt-4", styles?.pagination),
|
|
3960
5164
|
children: /* @__PURE__ */ jsx15(Pagination, {
|
|
3961
5165
|
pageSizeContentClassName: styles?.popup?.select,
|
|
3962
5166
|
locale: store.config.locale,
|
|
3963
5167
|
messages: { [store.config.locale]: store.config.labels },
|
|
3964
|
-
onPageChange: (page) =>
|
|
3965
|
-
onPageSizeChange: (pageSize) =>
|
|
3966
|
-
page
|
|
5168
|
+
onPageChange: (page) => send(DataTableMessage.PageRequested({ page })),
|
|
5169
|
+
onPageSizeChange: (pageSize) => send(DataTableMessage.PageSizeRequested({ pageSize })),
|
|
5170
|
+
page,
|
|
3967
5171
|
pageCount: model.pageCount,
|
|
3968
5172
|
pageSize: store.state.pageSize,
|
|
3969
5173
|
pageSizes: pagination.pageSizes,
|
|
@@ -3972,155 +5176,226 @@ var DataTablePagination = ({
|
|
|
3972
5176
|
})
|
|
3973
5177
|
});
|
|
3974
5178
|
};
|
|
3975
|
-
var
|
|
3976
|
-
|
|
3977
|
-
|
|
3978
|
-
|
|
3979
|
-
|
|
3980
|
-
const
|
|
3981
|
-
|
|
3982
|
-
|
|
3983
|
-
|
|
3984
|
-
|
|
3985
|
-
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
|
|
3990
|
-
|
|
3991
|
-
|
|
3992
|
-
|
|
3993
|
-
|
|
3994
|
-
|
|
3995
|
-
|
|
3996
|
-
|
|
3997
|
-
|
|
3998
|
-
|
|
3999
|
-
|
|
4000
|
-
|
|
4001
|
-
|
|
4002
|
-
|
|
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
|
+
});
|
|
5211
|
+
var getTableLayoutClass = (virtualization) => virtualization && virtualization !== true && virtualization.scroll === "internal" ? "flex min-h-0 flex-1 flex-col" : undefined;
|
|
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
|
|
4003
5230
|
};
|
|
4004
|
-
|
|
4005
|
-
|
|
4006
|
-
|
|
4007
|
-
|
|
4008
|
-
|
|
4009
|
-
|
|
4010
|
-
useLayoutEffect(() => {
|
|
4011
|
-
setStore((store) => {
|
|
4012
|
-
const features = props.features ?? {};
|
|
4013
|
-
const selection = features.selection;
|
|
4014
|
-
const config = {
|
|
4015
|
-
getRowId: selection && selection.getRowId || props.getRowId || undefined,
|
|
4016
|
-
onStateChange: props.onStateChange,
|
|
4017
|
-
onUiStateChange: (state) => setUiState(state),
|
|
4018
|
-
status: props.status ?? {},
|
|
4019
|
-
features,
|
|
4020
|
-
onRowClicked: props.onRowClicked,
|
|
4021
|
-
labels: dataTableMessages(props.locale, props.messages),
|
|
4022
|
-
locale: props.locale ?? "en"
|
|
4023
|
-
};
|
|
4024
|
-
const state = {
|
|
4025
|
-
...store.state,
|
|
4026
|
-
...uiState,
|
|
4027
|
-
...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 }))
|
|
4028
5237
|
};
|
|
4029
|
-
|
|
4030
|
-
|
|
4031
|
-
|
|
4032
|
-
|
|
4033
|
-
|
|
4034
|
-
config,
|
|
4035
|
-
|
|
4036
|
-
|
|
4037
|
-
|
|
4038
|
-
|
|
4039
|
-
|
|
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;
|
|
4040
5257
|
}, [
|
|
4041
|
-
|
|
4042
|
-
|
|
4043
|
-
props.
|
|
4044
|
-
props.locale,
|
|
4045
|
-
props.messages,
|
|
4046
|
-
props.onRowClicked,
|
|
4047
|
-
props.onStateChange,
|
|
5258
|
+
columns,
|
|
5259
|
+
config,
|
|
5260
|
+
props.initialState,
|
|
4048
5261
|
props.rowData,
|
|
4049
5262
|
props.state,
|
|
4050
|
-
|
|
4051
|
-
|
|
4052
|
-
|
|
4053
|
-
|
|
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
|
|
4054
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
|
+
});
|
|
4055
5346
|
return /* @__PURE__ */ jsxs9("div", {
|
|
4056
|
-
className: cn("w-full max-w-full min-w-0 rounded-md", props.className),
|
|
5347
|
+
className: cn("w-full max-w-full min-w-0 rounded-md", getTableLayoutClass(props.features?.virtualization), props.className),
|
|
4057
5348
|
"data-table-root": "",
|
|
4058
5349
|
children: [
|
|
4059
5350
|
/* @__PURE__ */ jsx15(DataTableToolbar, {
|
|
4060
|
-
|
|
5351
|
+
table
|
|
4061
5352
|
}),
|
|
4062
5353
|
/* @__PURE__ */ jsx15(DataTableContent, {
|
|
4063
|
-
|
|
5354
|
+
table
|
|
4064
5355
|
}),
|
|
4065
5356
|
/* @__PURE__ */ jsx15(DataTablePagination, {
|
|
4066
|
-
|
|
5357
|
+
table
|
|
4067
5358
|
})
|
|
4068
5359
|
]
|
|
4069
5360
|
});
|
|
4070
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
|
+
});
|
|
4071
5372
|
var DataTable = (props) => {
|
|
4072
5373
|
const locale = useKrakstackLocale3(props.locale);
|
|
4073
|
-
const
|
|
4074
|
-
|
|
4075
|
-
|
|
4076
|
-
|
|
4077
|
-
const viewCapability = props.features?.gallery ? "gallery" : "table";
|
|
4078
|
-
return Atom.kvs({
|
|
4079
|
-
mode: "async",
|
|
4080
|
-
runtime: dataTableStorageRuntime,
|
|
4081
|
-
key: `data-table:${pathname}:${columnIds}:${viewCapability}:ui`,
|
|
4082
|
-
schema: DataTablePersistedUiStateSchema,
|
|
4083
|
-
defaultValue: () => ({
|
|
4084
|
-
...persistedUiFromState(DEFAULT_UI_STATE),
|
|
4085
|
-
view: props.features?.gallery ? props.initialState?.view ?? "table" : "table",
|
|
4086
|
-
grouping: props.features?.grouping ? props.features.grouping.initial ?? [] : []
|
|
4087
|
-
})
|
|
4088
|
-
});
|
|
4089
|
-
});
|
|
4090
|
-
const [persistedUiResult, setPersistedUiState] = useAtom(persistedUiAtom);
|
|
4091
|
-
const persistedUiState = useMemo2(() => AsyncResult.isSuccess(persistedUiResult) ? {
|
|
4092
|
-
...persistedUiResult.value,
|
|
4093
|
-
columnVisibility: {
|
|
4094
|
-
...initialColumnVisibility,
|
|
4095
|
-
...persistedUiResult.value.columnVisibility
|
|
4096
|
-
}
|
|
4097
|
-
} : undefined, [initialColumnVisibility, persistedUiResult]);
|
|
4098
|
-
if (!persistedUiState || AsyncResult.isWaiting(persistedUiResult)) {
|
|
4099
|
-
return /* @__PURE__ */ jsx15("div", {
|
|
4100
|
-
"aria-busy": "true",
|
|
4101
|
-
className: cn("invisible w-full max-w-full min-w-0 rounded-md", props.className),
|
|
4102
|
-
"data-table-root": ""
|
|
5374
|
+
const hydrated = useSyncExternalStore2(subscribeToHydration, clientSnapshot, serverSnapshot);
|
|
5375
|
+
if (!hydrated)
|
|
5376
|
+
return /* @__PURE__ */ jsx15(TablePlaceholder, {
|
|
5377
|
+
props
|
|
4103
5378
|
});
|
|
4104
|
-
}
|
|
4105
5379
|
return /* @__PURE__ */ jsx15(DataTableStylesContext.Provider, {
|
|
4106
5380
|
value: props.classNames,
|
|
4107
|
-
children: /* @__PURE__ */ jsx15(
|
|
4108
|
-
|
|
4109
|
-
|
|
4110
|
-
|
|
4111
|
-
|
|
5381
|
+
children: /* @__PURE__ */ jsx15(DataTableSlotClassesContext.Provider, {
|
|
5382
|
+
value: resolveTableClasses(props.classes),
|
|
5383
|
+
children: /* @__PURE__ */ jsx15(HydratedDataTable, {
|
|
5384
|
+
...props,
|
|
5385
|
+
locale
|
|
5386
|
+
})
|
|
4112
5387
|
})
|
|
4113
5388
|
});
|
|
4114
5389
|
};
|
|
4115
5390
|
var DataTableContent = ({
|
|
4116
|
-
|
|
5391
|
+
table
|
|
4117
5392
|
}) => {
|
|
4118
|
-
const [store] =
|
|
4119
|
-
const [scrollElement, setScrollElement] =
|
|
4120
|
-
const [headerHeight, setHeaderHeight] =
|
|
4121
|
-
const [pageTable, setPageTable] =
|
|
4122
|
-
const [pageOffset, setPageOffset] =
|
|
4123
|
-
|
|
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(() => {
|
|
4124
5399
|
const header = pageTable?.querySelector("thead");
|
|
4125
5400
|
if (!pageTable || !header)
|
|
4126
5401
|
return;
|
|
@@ -4135,7 +5410,7 @@ var DataTableContent = ({
|
|
|
4135
5410
|
observer?.disconnect();
|
|
4136
5411
|
};
|
|
4137
5412
|
}, [pageTable]);
|
|
4138
|
-
|
|
5413
|
+
useLayoutEffect2(() => {
|
|
4139
5414
|
const header = scrollElement?.querySelector("thead");
|
|
4140
5415
|
if (!header)
|
|
4141
5416
|
return;
|
|
@@ -4149,7 +5424,7 @@ var DataTableContent = ({
|
|
|
4149
5424
|
}, [scrollElement]);
|
|
4150
5425
|
if (store.config.features.gallery && store.state.view === "gallery") {
|
|
4151
5426
|
return /* @__PURE__ */ jsx15(DataTableGallery, {
|
|
4152
|
-
|
|
5427
|
+
table
|
|
4153
5428
|
});
|
|
4154
5429
|
}
|
|
4155
5430
|
const model = deriveModel(store);
|
|
@@ -4175,10 +5450,10 @@ var DataTableContent = ({
|
|
|
4175
5450
|
style: { width: `max(100%, ${width}px)` },
|
|
4176
5451
|
children: [
|
|
4177
5452
|
/* @__PURE__ */ jsx15(DataTableHeader, {
|
|
4178
|
-
|
|
5453
|
+
table
|
|
4179
5454
|
}),
|
|
4180
5455
|
/* @__PURE__ */ jsx15(DataTableBody, {
|
|
4181
|
-
|
|
5456
|
+
table,
|
|
4182
5457
|
viewport: {
|
|
4183
5458
|
element: null,
|
|
4184
5459
|
headerHeight: 0,
|
|
@@ -4195,15 +5470,16 @@ var DataTableContent = ({
|
|
|
4195
5470
|
})
|
|
4196
5471
|
});
|
|
4197
5472
|
}
|
|
5473
|
+
const fillHeight = options.scroll === "internal";
|
|
4198
5474
|
return /* @__PURE__ */ jsxs9(ScrollAreaPrimitive2.Root, {
|
|
4199
|
-
className: "relative isolate max-w-full min-w-0",
|
|
5475
|
+
className: cn("relative isolate max-w-full min-w-0", fillHeight && "flex min-h-0 flex-1 flex-col"),
|
|
4200
5476
|
children: [
|
|
4201
5477
|
/* @__PURE__ */ jsx15(ScrollAreaPrimitive2.Viewport, {
|
|
4202
5478
|
ref: setScrollElement,
|
|
4203
5479
|
"data-table-virtual-viewport": "",
|
|
4204
|
-
className: "@container [overflow-anchor:none] data-has-overflow-y:me-2.5 [&_[data-slot=table-container]]:overflow-visible",
|
|
5480
|
+
className: cn("@container [overflow-anchor:none] data-has-overflow-y:me-2.5 [&_[data-slot=table-container]]:overflow-visible", fillHeight && "min-h-0 flex-1"),
|
|
4205
5481
|
style: {
|
|
4206
|
-
maxHeight: options.height ?? 480,
|
|
5482
|
+
maxHeight: fillHeight ? undefined : options.height ?? 480,
|
|
4207
5483
|
scrollPaddingTop: headerHeight
|
|
4208
5484
|
},
|
|
4209
5485
|
children: /* @__PURE__ */ jsx15(ScrollAreaPrimitive2.Content, {
|
|
@@ -4214,10 +5490,10 @@ var DataTableContent = ({
|
|
|
4214
5490
|
children: [
|
|
4215
5491
|
/* @__PURE__ */ jsx15(DataTableHeader, {
|
|
4216
5492
|
sticky: true,
|
|
4217
|
-
|
|
5493
|
+
table
|
|
4218
5494
|
}),
|
|
4219
5495
|
/* @__PURE__ */ jsx15(DataTableBody, {
|
|
4220
|
-
|
|
5496
|
+
table,
|
|
4221
5497
|
viewport: { element: scrollElement, headerHeight, options }
|
|
4222
5498
|
})
|
|
4223
5499
|
]
|
|
@@ -4243,10 +5519,10 @@ var DataTableContent = ({
|
|
|
4243
5519
|
style: { width: `max(100%, ${width}px)` },
|
|
4244
5520
|
children: [
|
|
4245
5521
|
/* @__PURE__ */ jsx15(DataTableHeader, {
|
|
4246
|
-
|
|
5522
|
+
table
|
|
4247
5523
|
}),
|
|
4248
5524
|
/* @__PURE__ */ jsx15(DataTableBody, {
|
|
4249
|
-
|
|
5525
|
+
table
|
|
4250
5526
|
})
|
|
4251
5527
|
]
|
|
4252
5528
|
}),
|
|
@@ -4257,6 +5533,7 @@ var DataTableContent = ({
|
|
|
4257
5533
|
});
|
|
4258
5534
|
};
|
|
4259
5535
|
var DataTableListCell = (props) => {
|
|
5536
|
+
const tableClasses = useContext2(DataTableSlotClassesContext);
|
|
4260
5537
|
const locale = useKrakstackLocale3(props.locale);
|
|
4261
5538
|
const resolvedProps = { ...props, locale };
|
|
4262
5539
|
if (resolvedProps.options && (resolvedProps.onAdd || resolvedProps.onRemove)) {
|
|
@@ -4274,7 +5551,7 @@ var DataTableListCell = (props) => {
|
|
|
4274
5551
|
}
|
|
4275
5552
|
const menuLabel = actionsLabel ?? (itemActions?.length ? labels.actions : labels.listDetails);
|
|
4276
5553
|
return /* @__PURE__ */ jsx15("div", {
|
|
4277
|
-
className:
|
|
5554
|
+
className: tableClasses.relationshipCell,
|
|
4278
5555
|
"data-slot": "data-table-list-cell",
|
|
4279
5556
|
onClick: (event) => event.stopPropagation(),
|
|
4280
5557
|
onPointerDown: (event) => event.stopPropagation(),
|
|
@@ -4289,7 +5566,7 @@ var DataTableListCell = (props) => {
|
|
|
4289
5566
|
onItemClick,
|
|
4290
5567
|
trigger: /* @__PURE__ */ jsxs9(Button, {
|
|
4291
5568
|
"aria-label": menuLabel,
|
|
4292
|
-
className:
|
|
5569
|
+
className: tableClasses.relationshipTrigger,
|
|
4293
5570
|
variant: "ghost",
|
|
4294
5571
|
children: [
|
|
4295
5572
|
/* @__PURE__ */ jsx15(DataTableListSummaryContent, {
|
|
@@ -4318,8 +5595,9 @@ var EditableDataTableListCell = ({
|
|
|
4318
5595
|
locale = "en",
|
|
4319
5596
|
messages
|
|
4320
5597
|
}) => {
|
|
4321
|
-
const
|
|
4322
|
-
const [
|
|
5598
|
+
const tableClasses = useContext2(DataTableSlotClassesContext);
|
|
5599
|
+
const [selected, setSelected] = useState2([...items]);
|
|
5600
|
+
const [previousItems, setPreviousItems] = useState2(items);
|
|
4323
5601
|
if (previousItems !== items) {
|
|
4324
5602
|
setPreviousItems(items);
|
|
4325
5603
|
setSelected([...items]);
|
|
@@ -4349,7 +5627,7 @@ var EditableDataTableListCell = ({
|
|
|
4349
5627
|
];
|
|
4350
5628
|
return /* @__PURE__ */ jsx15("div", {
|
|
4351
5629
|
"data-slot": "data-table-list-cell",
|
|
4352
|
-
className:
|
|
5630
|
+
className: tableClasses.relationshipCell,
|
|
4353
5631
|
onClick: (event) => event.stopPropagation(),
|
|
4354
5632
|
onPointerDown: (event) => event.stopPropagation(),
|
|
4355
5633
|
children: /* @__PURE__ */ jsx15(DataTableListMenu, {
|
|
@@ -4406,7 +5684,7 @@ var DataTableListMenu = ({
|
|
|
4406
5684
|
trigger
|
|
4407
5685
|
}) => {
|
|
4408
5686
|
const entries = items.map((item) => {
|
|
4409
|
-
const normalized =
|
|
5687
|
+
const normalized = Schema6.is(Schema6.String)(item) ? { label: item } : item;
|
|
4410
5688
|
const visibleActions = actions.filter((action) => action.visible?.(normalized) ?? true);
|
|
4411
5689
|
return { item: normalized, visibleActions };
|
|
4412
5690
|
});
|
|
@@ -4507,8 +5785,8 @@ var DataTableListAddMenu = ({
|
|
|
4507
5785
|
options,
|
|
4508
5786
|
searchLabel
|
|
4509
5787
|
}) => {
|
|
4510
|
-
const [search, setSearch] =
|
|
4511
|
-
const focusSearch =
|
|
5788
|
+
const [search, setSearch] = useState2("");
|
|
5789
|
+
const focusSearch = useCallback2((input) => {
|
|
4512
5790
|
input?.focus({ preventScroll: true });
|
|
4513
5791
|
}, []);
|
|
4514
5792
|
const labels = dataTableMessages(locale, messages);
|
|
@@ -4576,7 +5854,7 @@ var DataTableListSummaryContent = ({
|
|
|
4576
5854
|
showMenu,
|
|
4577
5855
|
visibleCount = 3
|
|
4578
5856
|
}) => {
|
|
4579
|
-
const normalized = items.map((item) =>
|
|
5857
|
+
const normalized = items.map((item) => Schema6.is(Schema6.String)(item) ? { label: item } : item);
|
|
4580
5858
|
if (!normalized.length)
|
|
4581
5859
|
return /* @__PURE__ */ jsx15("span", {
|
|
4582
5860
|
className: "text-muted-foreground",
|
|
@@ -4681,21 +5959,110 @@ var DataTableListEntry = ({
|
|
|
4681
5959
|
]
|
|
4682
5960
|
});
|
|
4683
5961
|
};
|
|
4684
|
-
|
|
4685
|
-
// ../../src/components/ui/copy-button.tsx
|
|
5962
|
+
// ../../src/components/copy-button/react.tsx
|
|
4686
5963
|
import { Check as Check2, Copy, TriangleAlert } from "lucide-react";
|
|
4687
|
-
import {
|
|
4688
|
-
import {
|
|
4689
|
-
import {
|
|
4690
|
-
|
|
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 = {
|
|
4691
6005
|
en: { copy: "Copy", copied: "Copied", copyFailed: "Copy failed" },
|
|
4692
6006
|
fr: { copy: "Copier", copied: "Copié", copyFailed: "Échec de la copie" }
|
|
4693
6007
|
};
|
|
4694
6008
|
var copyButtonMessages = (locale = "en", translations) => ({
|
|
4695
|
-
...locale.startsWith("fr") ?
|
|
6009
|
+
...locale.startsWith("fr") ? labels2.fr : labels2.en,
|
|
4696
6010
|
...translations?.[locale.split("-")[0] ?? locale],
|
|
4697
6011
|
...translations?.[locale]
|
|
4698
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";
|
|
4699
6066
|
function CopyButton({
|
|
4700
6067
|
value,
|
|
4701
6068
|
valueDescription,
|
|
@@ -4711,39 +6078,44 @@ function CopyButton({
|
|
|
4711
6078
|
...props
|
|
4712
6079
|
}) {
|
|
4713
6080
|
const locale = useKrakstackLocale4(localeOverride);
|
|
4714
|
-
const [copyState, setCopyState] = useState2("idle");
|
|
4715
|
-
const copyTimeout = useRef2(undefined);
|
|
4716
6081
|
const labels = copyButtonMessages(locale, messages);
|
|
4717
|
-
const
|
|
4718
|
-
|
|
4719
|
-
|
|
4720
|
-
|
|
4721
|
-
|
|
4722
|
-
|
|
4723
|
-
|
|
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
|
|
4724
6092
|
};
|
|
4725
|
-
}, []);
|
|
4726
|
-
const
|
|
4727
|
-
|
|
4728
|
-
clearTimeout(copyTimeout.current);
|
|
4729
|
-
copyTimeout.current = setTimeout(() => setCopyState("idle"), resetDelay);
|
|
4730
|
-
};
|
|
4731
|
-
const copy = async () => {
|
|
6093
|
+
}, [onCopied, onCopyError, labels.copyFailed]);
|
|
6094
|
+
const [component] = useState3(() => CopyButtonModel.pipe(Component5.provide(WriteClipboard.layerFromWrite(async (text) => {
|
|
6095
|
+
const { onCopied, onCopyError, failureLabel } = callbacks.current;
|
|
4732
6096
|
try {
|
|
4733
|
-
await navigator.clipboard.writeText(
|
|
4734
|
-
setCopyState("copied");
|
|
6097
|
+
await navigator.clipboard.writeText(text);
|
|
4735
6098
|
onCopied?.();
|
|
4736
|
-
} catch (
|
|
4737
|
-
|
|
4738
|
-
|
|
6099
|
+
} catch (cause) {
|
|
6100
|
+
onCopyError?.(cause instanceof Error ? cause : new Error(failureLabel, { cause }));
|
|
6101
|
+
throw cause;
|
|
4739
6102
|
}
|
|
4740
|
-
|
|
4741
|
-
|
|
4742
|
-
|
|
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";
|
|
4743
6115
|
return /* @__PURE__ */ jsxs10(Button, {
|
|
4744
6116
|
"aria-label": accessibleLabel,
|
|
4745
6117
|
disabled,
|
|
4746
|
-
onClick:
|
|
6118
|
+
onClick: () => send(CopyButtonMessage.Pressed()),
|
|
4747
6119
|
size: size ?? defaultSize,
|
|
4748
6120
|
...props,
|
|
4749
6121
|
children: [
|
|
@@ -4751,15 +6123,15 @@ function CopyButton({
|
|
|
4751
6123
|
"aria-live": "polite",
|
|
4752
6124
|
className: "sr-only",
|
|
4753
6125
|
role: "status",
|
|
4754
|
-
children: status
|
|
6126
|
+
children: copyButtonStatus(status, labels, valueDescription)
|
|
4755
6127
|
}),
|
|
4756
|
-
|
|
6128
|
+
status === "copied" ? /* @__PURE__ */ jsx16(Check2, {
|
|
4757
6129
|
"aria-hidden": "true"
|
|
4758
6130
|
}) : null,
|
|
4759
|
-
|
|
6131
|
+
status === "failed" ? /* @__PURE__ */ jsx16(TriangleAlert, {
|
|
4760
6132
|
"aria-hidden": "true"
|
|
4761
6133
|
}) : null,
|
|
4762
|
-
|
|
6134
|
+
status === "idle" ? /* @__PURE__ */ jsx16(Copy, {
|
|
4763
6135
|
"aria-hidden": "true"
|
|
4764
6136
|
}) : null,
|
|
4765
6137
|
isLarge ? /* @__PURE__ */ jsx16("span", {
|
|
@@ -4769,14 +6141,30 @@ function CopyButton({
|
|
|
4769
6141
|
});
|
|
4770
6142
|
}
|
|
4771
6143
|
|
|
4772
|
-
// ../../src/components/ui/
|
|
6144
|
+
// ../../src/components/ui/copy-button.tsx
|
|
6145
|
+
"use client";
|
|
6146
|
+
|
|
6147
|
+
// ../../src/components/code-block/react.tsx
|
|
4773
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
|
|
4774
6164
|
import { createThemeCss } from "@tanstack/highlight/theme";
|
|
4775
6165
|
import { githubDarkTheme } from "@tanstack/highlight/themes/github-dark";
|
|
4776
6166
|
import { githubLightTheme } from "@tanstack/highlight/themes/github-light";
|
|
4777
|
-
|
|
4778
|
-
import { jsx as jsx17, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
4779
|
-
var themeCss = `${createThemeCss({
|
|
6167
|
+
var codeThemeCss = `${createThemeCss({
|
|
4780
6168
|
light: githubLightTheme,
|
|
4781
6169
|
dark: githubDarkTheme,
|
|
4782
6170
|
lightSelector: "[data-code-theme]",
|
|
@@ -4792,7 +6180,7 @@ var themeCss = `${createThemeCss({
|
|
|
4792
6180
|
color: inherit;
|
|
4793
6181
|
}
|
|
4794
6182
|
[data-code-theme] pre.th-code code { font: inherit; }`;
|
|
4795
|
-
var
|
|
6183
|
+
var messages3 = {
|
|
4796
6184
|
en: {
|
|
4797
6185
|
codeDescription: (language) => `${language} code`,
|
|
4798
6186
|
copy: "Copy",
|
|
@@ -4807,51 +6195,56 @@ var messages4 = {
|
|
|
4807
6195
|
}
|
|
4808
6196
|
};
|
|
4809
6197
|
var codeBlockMessages = (locale = "en", translations) => ({
|
|
4810
|
-
...locale.startsWith("fr") ?
|
|
6198
|
+
...locale.startsWith("fr") ? messages3.fr : messages3.en,
|
|
4811
6199
|
...translations?.[locale.split("-")[0] ?? locale],
|
|
4812
6200
|
...translations?.[locale]
|
|
4813
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";
|
|
4814
6206
|
function CodeBlock({
|
|
6207
|
+
classes: classOverrides,
|
|
4815
6208
|
code,
|
|
4816
6209
|
language = "text",
|
|
4817
6210
|
locale: localeOverride,
|
|
4818
6211
|
messages
|
|
4819
6212
|
}) {
|
|
6213
|
+
const codeBlockClasses = resolveCodeBlockClasses(classOverrides);
|
|
4820
6214
|
const locale = useKrakstackLocale5(localeOverride);
|
|
4821
|
-
const normalizedLanguage = language
|
|
6215
|
+
const normalizedLanguage = codeLanguage(language);
|
|
4822
6216
|
const highlighted = highlight(code, { lang: normalizedLanguage });
|
|
4823
6217
|
const labels = codeBlockMessages(locale, messages);
|
|
4824
6218
|
return /* @__PURE__ */ jsxs11("div", {
|
|
4825
|
-
className:
|
|
6219
|
+
className: codeBlockClasses.root,
|
|
4826
6220
|
"data-code-theme": true,
|
|
4827
6221
|
children: [
|
|
4828
6222
|
/* @__PURE__ */ jsx17("style", {
|
|
4829
|
-
children:
|
|
6223
|
+
children: codeThemeCss
|
|
4830
6224
|
}),
|
|
4831
6225
|
/* @__PURE__ */ jsxs11("div", {
|
|
4832
|
-
className:
|
|
6226
|
+
className: codeBlockClasses.header,
|
|
4833
6227
|
children: [
|
|
4834
6228
|
/* @__PURE__ */ jsx17("span", {
|
|
4835
|
-
className:
|
|
6229
|
+
className: codeBlockClasses.language,
|
|
4836
6230
|
children: highlighted.lang
|
|
4837
6231
|
}),
|
|
4838
6232
|
/* @__PURE__ */ jsx17(CopyButton, {
|
|
4839
6233
|
value: code,
|
|
4840
6234
|
valueDescription: labels.codeDescription(highlighted.lang),
|
|
4841
|
-
variant: "
|
|
6235
|
+
variant: "ghost",
|
|
4842
6236
|
locale,
|
|
4843
6237
|
messages: { [locale]: labels }
|
|
4844
6238
|
})
|
|
4845
6239
|
]
|
|
4846
6240
|
}),
|
|
4847
6241
|
/* @__PURE__ */ jsx17("div", {
|
|
4848
|
-
className:
|
|
6242
|
+
className: codeBlockClasses.viewport,
|
|
4849
6243
|
dangerouslySetInnerHTML: { __html: highlighted.html }
|
|
4850
6244
|
})
|
|
4851
6245
|
]
|
|
4852
6246
|
});
|
|
4853
6247
|
}
|
|
4854
|
-
|
|
4855
6248
|
// ../../src/components/ui/dialog.tsx
|
|
4856
6249
|
import { Dialog as DialogPrimitive } from "@base-ui/react/dialog";
|
|
4857
6250
|
import { cn as cn2 } from "cn";
|
|
@@ -4929,9 +6322,75 @@ function DialogTitle({ className, ...props }) {
|
|
|
4929
6322
|
});
|
|
4930
6323
|
}
|
|
4931
6324
|
|
|
4932
|
-
// ../../src/
|
|
4933
|
-
import { useKrakstackLocale as useKrakstackLocale6 } from "@krak-stack/registry/krakstack-provider";
|
|
4934
|
-
|
|
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
|
|
4935
6394
|
var translations = {
|
|
4936
6395
|
en: {
|
|
4937
6396
|
identifier: "ID",
|
|
@@ -4946,7 +6405,16 @@ var translations = {
|
|
|
4946
6405
|
payload: "Payload",
|
|
4947
6406
|
viewPayload: "View JSON",
|
|
4948
6407
|
createdAt: "Created",
|
|
4949
|
-
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"
|
|
4950
6418
|
},
|
|
4951
6419
|
fr: {
|
|
4952
6420
|
identifier: "Identifiant",
|
|
@@ -4961,10 +6429,69 @@ var translations = {
|
|
|
4961
6429
|
payload: "Données",
|
|
4962
6430
|
viewPayload: "Voir le JSON",
|
|
4963
6431
|
createdAt: "Créé",
|
|
4964
|
-
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"
|
|
4965
6442
|
}
|
|
4966
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
|
+
};
|
|
4967
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
|
+
});
|
|
4968
6495
|
var WebhookDeliveryTable = ({
|
|
4969
6496
|
entries,
|
|
4970
6497
|
rowCount,
|
|
@@ -4977,14 +6504,13 @@ var WebhookDeliveryTable = ({
|
|
|
4977
6504
|
status
|
|
4978
6505
|
}) => {
|
|
4979
6506
|
const locale = useKrakstackLocale6(localeOverride);
|
|
4980
|
-
const
|
|
4981
|
-
const
|
|
4982
|
-
|
|
4983
|
-
|
|
4984
|
-
|
|
4985
|
-
|
|
4986
|
-
};
|
|
4987
|
-
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);
|
|
4988
6514
|
const dateFormatter = new Intl.DateTimeFormat(locale, {
|
|
4989
6515
|
dateStyle: "medium",
|
|
4990
6516
|
timeStyle: "short"
|
|
@@ -5018,16 +6544,9 @@ var WebhookDeliveryTable = ({
|
|
|
5018
6544
|
imageVariant: "square",
|
|
5019
6545
|
getItem: (delivery) => {
|
|
5020
6546
|
const displayStatus = webhookDeliveryStatus(delivery);
|
|
5021
|
-
const details = displayStatus === "failed" ? [
|
|
5022
|
-
delivery.error ?? labels.errorUnavailable,
|
|
5023
|
-
`${labels.retries}: ${delivery.retries}`,
|
|
5024
|
-
...delivery.status === "pending" ? [
|
|
5025
|
-
`${labels.retryAt}: ${dateFormatter.format(delivery.retryAt)}`
|
|
5026
|
-
] : []
|
|
5027
|
-
] : [];
|
|
5028
6547
|
return {
|
|
5029
6548
|
label: statusLabels[displayStatus],
|
|
5030
|
-
description:
|
|
6549
|
+
description: webhookDeliveryStatusDetails(delivery, labels, dateFormatter),
|
|
5031
6550
|
icon: displayStatus === "failed" ? /* @__PURE__ */ jsx19(X2, {}) : displayStatus === "success" ? /* @__PURE__ */ jsx19(Check3, {}) : /* @__PURE__ */ jsx19(Clock, {}),
|
|
5032
6551
|
iconClassName: displayStatus === "failed" ? "bg-destructive/10 text-destructive" : displayStatus === "success" ? "bg-success/10 text-success" : "bg-primary/10 text-primary"
|
|
5033
6552
|
};
|
|
@@ -5045,7 +6564,7 @@ var WebhookDeliveryTable = ({
|
|
|
5045
6564
|
size: "sm",
|
|
5046
6565
|
onClick: (event) => {
|
|
5047
6566
|
event.stopPropagation();
|
|
5048
|
-
|
|
6567
|
+
send(WebhookDeliveryTableMessage.OpenPayload({ id: data.id }));
|
|
5049
6568
|
},
|
|
5050
6569
|
children: [
|
|
5051
6570
|
/* @__PURE__ */ jsx19(FileJson2, {
|
|
@@ -5076,10 +6595,10 @@ var WebhookDeliveryTable = ({
|
|
|
5076
6595
|
}
|
|
5077
6596
|
}),
|
|
5078
6597
|
/* @__PURE__ */ jsx19(Dialog, {
|
|
5079
|
-
open: selected !==
|
|
6598
|
+
open: selected !== undefined,
|
|
5080
6599
|
onOpenChange: (open) => {
|
|
5081
6600
|
if (!open)
|
|
5082
|
-
|
|
6601
|
+
send(WebhookDeliveryTableMessage.ClosePayload());
|
|
5083
6602
|
},
|
|
5084
6603
|
children: /* @__PURE__ */ jsxs13(DialogContent, {
|
|
5085
6604
|
className: "grid max-h-[calc(100svh-2rem)] grid-rows-[auto_minmax(0,1fr)] overflow-hidden sm:max-w-4xl",
|