@krak-stack/registry 0.10.20 → 0.11.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +89 -3
- package/README.md +11 -8
- package/dist/components/agent/index.d.ts +454 -0
- package/dist/components/agent/react.d.ts +55 -0
- package/dist/components/agent/react.js +2440 -0
- package/dist/components/agent/schema.d.ts +55 -0
- package/dist/components/animated-list/classes.d.ts +9 -0
- package/dist/components/animated-list/html.d.ts +11 -0
- package/dist/components/animated-list/html.js +533 -0
- package/dist/components/animated-list/index.d.ts +205 -0
- package/dist/components/animated-list/react.d.ts +11 -0
- package/dist/components/{ui/animated-list.js → animated-list/react.js} +199 -54
- package/dist/components/animated-list/schema.d.ts +44 -0
- package/dist/components/animated-number/html.d.ts +19 -0
- package/dist/components/animated-number/html.js +101 -0
- package/dist/components/animated-number/index.d.ts +80 -0
- package/dist/components/{ui/animated-number.d.ts → animated-number/react.d.ts} +2 -7
- package/dist/components/animated-number/react.js +124 -0
- package/dist/components/animated-number/schema.d.ts +9 -0
- package/dist/components/app-brand/classes.d.ts +11 -0
- package/dist/components/app-brand/html.d.ts +26 -0
- package/dist/components/app-brand/html.js +78 -0
- package/dist/components/app-brand/react.d.ts +12 -0
- package/dist/components/app-brand/react.js +86 -0
- package/dist/components/app-brand/schema.d.ts +36 -0
- package/dist/components/app-switcher/classes.d.ts +15 -0
- package/dist/components/app-switcher/html.d.ts +72 -0
- package/dist/components/app-switcher/html.js +327 -0
- package/dist/components/app-switcher/index.d.ts +47 -0
- package/dist/components/app-switcher/react.d.ts +12 -0
- package/dist/components/{ui/app-switcher.js → app-switcher/react.js} +84 -15
- package/dist/components/app-switcher/schema.d.ts +39 -0
- package/dist/components/async-action-button/classes.d.ts +11 -0
- package/dist/components/async-action-button/html.d.ts +46 -0
- package/dist/components/async-action-button/html.js +266 -0
- package/dist/components/async-action-button/index.d.ts +73 -0
- package/dist/components/async-action-button/react.d.ts +10 -0
- package/dist/components/async-action-button/react.js +224 -0
- package/dist/components/async-action-button/schema.d.ts +28 -0
- package/dist/{services/events/client/audit-log-table.d.ts → components/audit-log-table/react.d.ts} +2 -2
- package/dist/{services/events/client/audit-log-table.js → components/audit-log-table/react.js} +1964 -847
- package/dist/components/auto-height/html.d.ts +8 -0
- package/dist/components/auto-height/html.js +81 -0
- package/dist/components/auto-height/index.d.ts +2 -0
- package/dist/components/{ui/auto-height.d.ts → auto-height/react.d.ts} +2 -4
- package/dist/components/auto-height/react.js +75 -0
- package/dist/components/auto-height/schema.d.ts +7 -0
- package/dist/components/bulk-list-input/classes.d.ts +7 -0
- package/dist/components/bulk-list-input/html.d.ts +41 -0
- package/dist/components/bulk-list-input/html.js +265 -0
- package/dist/components/bulk-list-input/index.d.ts +76 -0
- package/dist/components/bulk-list-input/react.d.ts +12 -0
- package/dist/components/{ui/bulk-list-input.js → bulk-list-input/react.js} +71 -4
- package/dist/components/bulk-list-input/schema.d.ts +33 -0
- package/dist/components/choice-cards/classes.d.ts +19 -0
- package/dist/components/choice-cards/html.d.ts +76 -0
- package/dist/components/choice-cards/html.js +237 -0
- package/dist/components/choice-cards/index.d.ts +1 -0
- package/dist/components/choice-cards/react.d.ts +21 -0
- package/dist/components/{ui/choice-cards.js → choice-cards/react.js} +29 -10
- package/dist/components/choice-cards/schema.d.ts +100 -0
- package/dist/components/code-block/classes.d.ts +13 -0
- package/dist/components/code-block/html.d.ts +21 -0
- package/dist/components/code-block/html.js +381 -0
- package/dist/components/code-block/index.d.ts +4 -0
- package/dist/components/code-block/react.d.ts +4 -0
- package/dist/components/{ui/code-block.js → code-block/react.js} +168 -50
- package/dist/components/code-block/schema.d.ts +29 -0
- package/dist/components/color-input/classes.d.ts +9 -0
- package/dist/components/color-input/html.d.ts +48 -0
- package/dist/components/color-input/html.js +187 -0
- package/dist/components/color-input/index.d.ts +88 -0
- package/dist/components/color-input/react.d.ts +7 -0
- package/dist/components/{ui/color-picker.js → color-input/react.js} +165 -233
- package/dist/components/color-input/schema.d.ts +40 -0
- package/dist/components/copy-button/html.d.ts +48 -0
- package/dist/components/copy-button/html.js +266 -0
- package/dist/components/copy-button/index.d.ts +73 -0
- package/dist/components/copy-button/react.d.ts +12 -0
- package/dist/components/copy-button/react.js +234 -0
- package/dist/components/copy-button/schema.d.ts +37 -0
- package/dist/components/copy-value/html.d.ts +37 -0
- package/dist/components/copy-value/html.js +426 -0
- package/dist/components/copy-value/index.d.ts +57 -0
- package/dist/components/copy-value/react.d.ts +9 -0
- package/dist/components/{ui/copy-value.js → copy-value/react.js} +243 -65
- package/dist/components/copy-value/schema.d.ts +45 -0
- package/dist/components/cron-input/classes.d.ts +25 -0
- package/dist/components/cron-input/html.d.ts +36 -0
- package/dist/components/cron-input/html.js +204 -0
- package/dist/components/cron-input/index.d.ts +59 -0
- package/dist/components/cron-input/react.d.ts +7 -0
- package/dist/components/{ui/cron-expression-editor.js → cron-input/react.js} +126 -54
- package/dist/components/cron-input/schema.d.ts +24 -0
- package/dist/components/danger-confirmation/classes.d.ts +7 -0
- package/dist/components/danger-confirmation/html.d.ts +39 -0
- package/dist/components/danger-confirmation/html.js +227 -0
- package/dist/components/danger-confirmation/index.d.ts +113 -0
- package/dist/components/{ui/danger-confirmation.d.ts → danger-confirmation/react.d.ts} +3 -12
- package/dist/components/{ui/danger-confirmation.js → danger-confirmation/react.js} +203 -205
- package/dist/components/danger-confirmation/schema.d.ts +34 -0
- package/dist/components/data-table/classes.d.ts +63 -0
- package/dist/components/data-table/html.d.ts +1938 -0
- package/dist/components/data-table/html.js +2682 -0
- package/dist/components/data-table/index.d.ts +2686 -0
- package/dist/components/data-table/react.d.ts +578 -0
- package/dist/components/{ui/data-table.js → data-table/react.js} +1958 -835
- package/dist/components/data-table/schema.d.ts +3012 -0
- package/dist/components/date-input/classes.d.ts +17 -0
- package/dist/components/date-input/html.d.ts +60 -0
- package/dist/components/date-input/html.js +418 -0
- package/dist/components/date-input/index.d.ts +91 -0
- package/dist/components/date-input/react.d.ts +10 -0
- package/dist/components/{ui/date-picker.js → date-input/react.js} +233 -79
- package/dist/components/date-input/schema.d.ts +41 -0
- package/dist/components/editable-text/classes.d.ts +17 -0
- package/dist/components/editable-text/html.d.ts +51 -0
- package/dist/components/editable-text/html.js +370 -0
- package/dist/components/editable-text/index.d.ts +143 -0
- package/dist/components/editable-text/react.d.ts +6 -0
- package/dist/components/editable-text/react.js +345 -0
- package/dist/components/editable-text/schema.d.ts +31 -0
- package/dist/components/editing-locale-switcher/classes.d.ts +7 -0
- package/dist/components/editing-locale-switcher/html.d.ts +27 -0
- package/dist/components/editing-locale-switcher/html.js +250 -0
- package/dist/components/editing-locale-switcher/index.d.ts +52 -0
- package/dist/components/editing-locale-switcher/react.d.ts +7 -0
- package/dist/components/{ui/editing-locale-switcher.js → editing-locale-switcher/react.js} +63 -10
- package/dist/components/editing-locale-switcher/schema.d.ts +16 -0
- package/dist/components/{ui/effect-form.d.ts → effect-form/react.d.ts} +2 -2
- package/dist/components/{ui/effect-form.js → effect-form/react.js} +302 -76
- package/dist/components/effectcn/alert-dialog.d.ts +13 -0
- package/dist/components/effectcn/button.d.ts +31 -0
- package/dist/components/effectcn/calendar.d.ts +12 -0
- package/dist/components/effectcn/checkbox.d.ts +10 -0
- package/dist/components/effectcn/combobox.d.ts +25 -0
- package/dist/components/effectcn/dialog.d.ts +19 -0
- package/dist/components/effectcn/field.d.ts +11 -0
- package/dist/components/effectcn/file-drop.d.ts +8 -0
- package/dist/components/effectcn/input.d.ts +26 -0
- package/dist/components/effectcn/menu.d.ts +85 -0
- package/dist/components/effectcn/menubar.d.ts +8 -0
- package/dist/components/effectcn/popover.d.ts +18 -0
- package/dist/components/effectcn/scroll-area.d.ts +12 -0
- package/dist/components/effectcn/select.d.ts +68 -0
- package/dist/components/effectcn/toast.d.ts +29 -0
- package/dist/components/email-composer/index.d.ts +229 -0
- package/dist/components/email-composer/labels.d.ts +12 -0
- package/dist/components/email-composer/react.d.ts +5 -0
- package/dist/components/{ui/email-composer.js → email-composer/react.js} +461 -127
- package/dist/components/email-composer/schema.d.ts +42 -0
- package/dist/components/email-editor/classes.d.ts +21 -0
- package/dist/components/email-editor/html.d.ts +360 -0
- package/dist/components/email-editor/html.js +1706 -0
- package/dist/components/email-editor/index.d.ts +693 -0
- package/dist/components/{ui/email-editor.d.ts → email-editor/labels.d.ts} +1 -21
- package/dist/components/email-editor/legacy-editor.html.d.ts +160 -0
- package/dist/components/email-editor/react.d.ts +11 -0
- package/dist/components/{ui/email-editor.js → email-editor/react.js} +600 -230
- package/dist/components/email-editor/schema.d.ts +162 -0
- package/dist/components/error-component/classes.d.ts +7 -0
- package/dist/components/error-component/html.d.ts +120 -0
- package/dist/components/error-component/html.js +346 -0
- package/dist/components/error-component/index.d.ts +69 -0
- package/dist/components/error-component/react.d.ts +8 -0
- package/dist/components/{ui/error-component.js → error-component/react.js} +281 -78
- package/dist/components/error-component/schema.d.ts +56 -0
- package/dist/components/file-input/classes.d.ts +7 -0
- package/dist/components/file-input/html.d.ts +95 -0
- package/dist/components/file-input/html.js +368 -0
- package/dist/components/file-input/index.d.ts +99 -0
- package/dist/components/file-input/react.d.ts +11 -0
- package/dist/components/{ui/file-picker.js → file-input/react.js} +122 -19
- package/dist/components/file-input/schema.d.ts +37 -0
- package/dist/components/{ui/form.d.ts → form/react.d.ts} +7 -7
- package/dist/components/{ui/form.js → form/react.js} +300 -74
- package/dist/components/icon-input/html.d.ts +55 -0
- package/dist/components/icon-input/html.js +538 -0
- package/dist/components/icon-input/index.d.ts +143 -0
- package/dist/components/icon-input/react.d.ts +6 -0
- package/dist/components/{ui/icon-input.js → icon-input/react.js} +305 -89
- package/dist/components/icon-input/schema.d.ts +23 -0
- package/dist/components/image-crop-editor/classes.d.ts +19 -0
- package/dist/components/image-crop-editor/html.d.ts +66 -0
- package/dist/components/image-crop-editor/html.js +561 -0
- package/dist/components/image-crop-editor/index.d.ts +183 -0
- package/dist/components/image-crop-editor/react.d.ts +8 -0
- package/dist/components/image-crop-editor/react.js +648 -0
- package/dist/components/image-crop-editor/schema.d.ts +54 -0
- package/dist/components/krakstack-provider/html.d.ts +17 -0
- package/dist/components/krakstack-provider/html.js +37 -0
- package/dist/components/krakstack-provider/index.d.ts +7 -0
- package/dist/components/krakstack-provider/react.d.ts +8 -0
- package/dist/components/{ui/krakstack-provider.js → krakstack-provider/react.js} +14 -5
- package/dist/components/krakstack-provider/schema.d.ts +6 -0
- package/dist/components/loading/classes.d.ts +5 -0
- package/dist/components/loading/html.d.ts +18 -0
- package/dist/components/loading/html.js +166 -0
- package/dist/components/loading/index.d.ts +6 -0
- package/dist/components/loading/react.d.ts +4 -0
- package/dist/components/loading/react.js +51 -0
- package/dist/components/loading/schema.d.ts +23 -0
- package/dist/components/locale-switcher/html.d.ts +22 -0
- package/dist/components/locale-switcher/html.js +264 -0
- package/dist/components/locale-switcher/index.d.ts +50 -0
- package/dist/components/locale-switcher/react.d.ts +7 -0
- package/dist/components/{ui/locale-switcher.js → locale-switcher/react.js} +55 -22
- package/dist/components/locale-switcher/schema.d.ts +12 -0
- package/dist/components/map-menu/classes.d.ts +13 -0
- package/dist/components/map-menu/google-maps.d.ts +80 -0
- package/dist/components/map-menu/google-viewport.d.ts +7 -0
- package/dist/components/map-menu/html.d.ts +274 -0
- package/dist/components/map-menu/html.js +934 -0
- package/dist/components/map-menu/index.d.ts +246 -0
- package/dist/components/map-menu/map.d.ts +47 -0
- package/dist/components/map-menu/react.d.ts +40 -0
- package/dist/components/{ui/map-menu.js → map-menu/react.js} +321 -83
- package/dist/components/map-menu/schema.d.ts +132 -0
- package/dist/components/markdown/classes.d.ts +1 -0
- package/dist/components/markdown/html.d.ts +23 -0
- package/dist/components/markdown/html.js +510 -0
- package/dist/components/markdown/index.d.ts +6 -0
- package/dist/components/markdown/react.d.ts +3 -0
- package/dist/components/markdown/react.js +392 -0
- package/dist/components/markdown/schema.d.ts +20 -0
- package/dist/components/notification-menu/classes.d.ts +11 -0
- package/dist/components/notification-menu/html.d.ts +67 -0
- package/dist/components/notification-menu/html.js +425 -0
- package/dist/components/notification-menu/index.d.ts +132 -0
- package/dist/components/notification-menu/react.d.ts +57 -0
- package/dist/components/notification-menu/react.js +829 -0
- package/dist/components/notification-menu/schema.d.ts +59 -0
- package/dist/components/pagination/classes.d.ts +19 -0
- package/dist/components/pagination/html.d.ts +49 -0
- package/dist/components/pagination/html.js +387 -0
- package/dist/components/pagination/index.d.ts +109 -0
- package/dist/components/pagination/react.d.ts +9 -0
- package/dist/components/{ui/pagination.js → pagination/react.js} +123 -23
- package/dist/components/pagination/schema.d.ts +36 -0
- package/dist/components/phone-number-input/classes.d.ts +17 -0
- package/dist/components/phone-number-input/html.d.ts +52 -0
- package/dist/components/phone-number-input/html.js +655 -0
- package/dist/components/phone-number-input/index.d.ts +59 -0
- package/dist/components/phone-number-input/react.d.ts +11 -0
- package/dist/components/{ui/phone-number-input.js → phone-number-input/react.js} +368 -138
- package/dist/components/phone-number-input/schema.d.ts +31 -0
- package/dist/components/presence-transition/html.d.ts +13 -0
- package/dist/components/presence-transition/html.js +128 -0
- package/dist/components/presence-transition/index.d.ts +57 -0
- package/dist/components/{ui/presence-transition.d.ts → presence-transition/react.d.ts} +3 -5
- package/dist/components/presence-transition/react.js +139 -0
- package/dist/components/presence-transition/schema.d.ts +7 -0
- package/dist/components/registry-previews/component-example.d.ts +31 -0
- package/dist/components/registry-previews/component-example.js +525 -0
- package/dist/components/registry-previews/html-preview.d.ts +17 -0
- package/dist/components/registry-previews/html-preview.js +83 -0
- package/dist/components/rich-text-editor/classes.d.ts +15 -0
- package/dist/components/rich-text-editor/engine.d.ts +9 -0
- package/dist/components/rich-text-editor/html.d.ts +246 -0
- package/dist/components/rich-text-editor/html.js +830 -0
- package/dist/components/rich-text-editor/index.d.ts +453 -0
- package/dist/components/rich-text-editor/labels.d.ts +42 -0
- package/dist/components/rich-text-editor/react.d.ts +19 -0
- package/dist/components/{ui/rich-text-editor.js → rich-text-editor/react.js} +365 -96
- package/dist/components/rich-text-editor/schema.d.ts +116 -0
- package/dist/components/search-menu/classes.d.ts +9 -0
- package/dist/components/search-menu/html.d.ts +127 -0
- package/dist/components/search-menu/html.js +432 -0
- package/dist/components/search-menu/index.d.ts +85 -0
- package/dist/components/search-menu/react.d.ts +18 -0
- package/dist/components/{ui/search-menu.js → search-menu/react.js} +128 -23
- package/dist/components/search-menu/schema.d.ts +78 -0
- package/dist/components/select-with-custom-input/classes.d.ts +17 -0
- package/dist/components/select-with-custom-input/html.d.ts +60 -0
- package/dist/components/select-with-custom-input/html.js +238 -0
- package/dist/components/select-with-custom-input/index.d.ts +114 -0
- package/dist/components/select-with-custom-input/react.d.ts +7 -0
- package/dist/components/{ui/select-with-custom-input.js → select-with-custom-input/react.js} +127 -22
- package/dist/components/select-with-custom-input/schema.d.ts +54 -0
- package/dist/components/sidebar-layout/classes.d.ts +21 -0
- package/dist/components/sidebar-layout/html.d.ts +97 -0
- package/dist/components/sidebar-layout/html.js +361 -0
- package/dist/components/sidebar-layout/index.d.ts +57 -0
- package/dist/components/sidebar-layout/react.d.ts +30 -0
- package/dist/components/{ui/sidebar-layout.js → sidebar-layout/react.js} +199 -39
- package/dist/components/sidebar-layout/schema.d.ts +54 -0
- package/dist/components/stats-card/classes.d.ts +11 -0
- package/dist/components/stats-card/html.d.ts +15 -0
- package/dist/components/stats-card/html.js +55 -0
- package/dist/components/stats-card/react.d.ts +7 -0
- package/dist/components/{ui/stats-card.js → stats-card/react.js} +19 -15
- package/dist/components/stats-card/schema.d.ts +14 -0
- package/dist/components/stepper/classes.d.ts +39 -0
- package/dist/components/stepper/html.d.ts +107 -0
- package/dist/components/stepper/html.js +397 -0
- package/dist/components/stepper/index.d.ts +83 -0
- package/dist/components/stepper/react.d.ts +17 -0
- package/dist/components/{ui/stepper.js → stepper/react.js} +120 -21
- package/dist/components/stepper/schema.d.ts +52 -0
- package/dist/components/support/classes.d.ts +55 -0
- package/dist/components/support/form.d.ts +19 -0
- package/dist/components/support/html.d.ts +266 -0
- package/dist/components/support/html.js +604 -0
- package/dist/components/support/index.d.ts +226 -0
- package/dist/components/support/multipart.d.ts +21 -0
- package/dist/components/support/react.d.ts +54 -0
- package/dist/components/support/react.js +1098 -0
- package/dist/components/support/schema.d.ts +69 -0
- package/dist/components/support.d.ts +1 -66
- package/dist/components/theme-switcher/html.d.ts +28 -0
- package/dist/components/theme-switcher/html.js +288 -0
- package/dist/components/theme-switcher/index.d.ts +59 -0
- package/dist/components/{ui/theme-switcher.d.ts → theme-switcher/react.d.ts} +4 -12
- package/dist/components/{ui/theme-switcher.js → theme-switcher/react.js} +69 -35
- package/dist/components/theme-switcher/schema.d.ts +33 -0
- package/dist/components/time-input/classes.d.ts +23 -0
- package/dist/components/time-input/html.d.ts +75 -0
- package/dist/components/time-input/html.js +571 -0
- package/dist/components/time-input/index.d.ts +164 -0
- package/dist/components/time-input/react.d.ts +7 -0
- package/dist/components/{ui/time-picker.js → time-input/react.js} +286 -114
- package/dist/components/time-input/schema.d.ts +96 -0
- package/dist/components/timezone-input/classes.d.ts +13 -0
- package/dist/components/timezone-input/html.d.ts +58 -0
- package/dist/components/timezone-input/html.js +804 -0
- package/dist/components/timezone-input/index.d.ts +170 -0
- package/dist/components/timezone-input/react.d.ts +9 -0
- package/dist/components/{ui/timezone-select.js → timezone-input/react.js} +337 -104
- package/dist/components/timezone-input/schema.d.ts +43 -0
- package/dist/components/toast/classes.d.ts +7 -0
- package/dist/components/toast/html.d.ts +34 -0
- package/dist/components/toast/html.js +280 -0
- package/dist/components/toast/index.d.ts +10 -0
- package/dist/components/toast/react.d.ts +9 -0
- package/dist/components/{ui/toast.js → toast/react.js} +35 -15
- package/dist/components/toast/schema.d.ts +24 -0
- package/dist/{services/events/client/tracking-notice.d.ts → components/tracking-notice/react.d.ts} +7 -1
- package/dist/{services/events/client/tracking-notice.js → components/tracking-notice/react.js} +13 -7
- package/dist/components/ui/animated-list.d.ts +1 -21
- package/dist/components/ui/app-brand.d.ts +1 -33
- package/dist/components/ui/async-action-button.d.ts +1 -17
- package/dist/components/ui/code-block.d.ts +1 -14
- package/dist/components/ui/copy-button.d.ts +1 -21
- package/dist/components/ui/data-table.d.ts +1 -584
- package/dist/components/ui/krakstack-provider.d.ts +1 -9
- package/dist/components/ui/loading.d.ts +1 -13
- package/dist/components/ui/pagination.d.ts +1 -47
- package/dist/components/ui/rich-text-editor.d.ts +1 -72
- package/dist/components/ui/search-menu.d.ts +1 -36
- package/dist/components/ui/sidebar-layout.d.ts +1 -40
- package/dist/components/ui/virtualized-combobox.d.ts +1 -59
- package/dist/components/unsaved-changes-guard/html.d.ts +34 -0
- package/dist/components/unsaved-changes-guard/html.js +172 -0
- package/dist/components/unsaved-changes-guard/index.d.ts +56 -0
- package/dist/components/unsaved-changes-guard/react.d.ts +4 -0
- package/dist/components/{ui/unsaved-changes-guard.js → unsaved-changes-guard/react.js} +74 -11
- package/dist/components/unsaved-changes-guard/schema.d.ts +37 -0
- package/dist/components/upload-attachment/classes.d.ts +11 -0
- package/dist/components/upload-attachment/html.d.ts +84 -0
- package/dist/components/upload-attachment/html.js +312 -0
- package/dist/components/upload-attachment/index.d.ts +72 -0
- package/dist/components/upload-attachment/react.d.ts +9 -0
- package/dist/components/{ui/upload-attachment.js → upload-attachment/react.js} +114 -17
- package/dist/components/upload-attachment/schema.d.ts +53 -0
- package/dist/components/virtualized-combobox/classes.d.ts +7 -0
- package/dist/components/virtualized-combobox/html.d.ts +97 -0
- package/dist/components/virtualized-combobox/html.js +310 -0
- package/dist/components/virtualized-combobox/index.d.ts +182 -0
- package/dist/components/virtualized-combobox/react.d.ts +31 -0
- package/dist/components/{ui/virtualized-combobox.js → virtualized-combobox/react.js} +160 -40
- package/dist/components/virtualized-combobox/schema.d.ts +92 -0
- package/dist/components/webhook-delivery-table/html.d.ts +216 -0
- package/dist/components/webhook-delivery-table/html.js +3008 -0
- package/dist/components/webhook-delivery-table/index.d.ts +405 -0
- package/dist/components/webhook-delivery-table/react.d.ts +13 -0
- package/dist/{services/webhooks/client/delivery-table.js → components/webhook-delivery-table/react.js} +2278 -917
- package/dist/components/webhook-delivery-table/schema.d.ts +134 -0
- package/dist/lib/docs.d.ts +17 -1
- package/dist/lib/docs.integrations.server.js +341 -75
- package/dist/lib/docs.js +715 -299
- package/dist/lib/docs.server.js +325 -59
- package/dist/lib/documentation-toolkit.d.ts +4 -4
- package/dist/lib/documentation-toolkit.js +337 -71
- package/dist/lib/effect-ui-adapter/model-runtime.d.ts +17 -0
- package/dist/lib/effect-ui-adapter/use-model.d.ts +9 -0
- package/dist/lib/effect-ui-adapter/use-model.js +158 -0
- package/dist/lib/effectcn-form.d.ts +3 -0
- package/dist/lib/effectcn-form.js +54 -0
- package/dist/lib/email-composer/index.d.ts +12 -0
- package/dist/lib/email-composer/schema.d.ts +14 -0
- package/dist/lib/httpapi-toolkit.d.ts +1 -1
- package/dist/lib/lucide-effect.d.ts +39 -0
- package/dist/lib/markdown/content.d.ts +1 -12
- package/dist/lib/rich-text/model.d.ts +5 -0
- package/dist/lib/webfetch-toolkit.d.ts +1 -1
- package/dist/services/agent/client/index.js +530 -168
- package/dist/services/agent/client/widget.d.ts +1 -55
- package/dist/services/notification/client/index.js +138 -27
- package/dist/services/notification/client/notification-menu.d.ts +1 -85
- package/dist/services/notification/public.js +138 -27
- package/dist/services/opentelemetry/browser.js +15 -9
- package/dist/services/webhooks/index.d.ts +4 -3
- package/package.json +185 -142
- package/dist/components/support-dialog.js +0 -881
- package/dist/components/support.js +0 -881
- package/dist/components/ui/animated-number.js +0 -75
- package/dist/components/ui/app-brand.js +0 -126
- package/dist/components/ui/app-switcher.d.ts +0 -26
- package/dist/components/ui/async-action-button.js +0 -149
- package/dist/components/ui/auto-height.js +0 -86
- package/dist/components/ui/bulk-list-input.d.ts +0 -25
- package/dist/components/ui/choice-cards.d.ts +0 -33
- package/dist/components/ui/color-picker.d.ts +0 -31
- package/dist/components/ui/copy-button.js +0 -138
- package/dist/components/ui/copy-value.d.ts +0 -24
- package/dist/components/ui/cron-expression-editor.d.ts +0 -16
- package/dist/components/ui/cron-expression-editor.schema.d.ts +0 -7
- package/dist/components/ui/date-picker.d.ts +0 -33
- package/dist/components/ui/date-picker.schema.d.ts +0 -9
- package/dist/components/ui/editable-text.d.ts +0 -19
- package/dist/components/ui/editable-text.js +0 -341
- package/dist/components/ui/editing-locale-switcher.d.ts +0 -11
- package/dist/components/ui/error-component.d.ts +0 -34
- package/dist/components/ui/file-picker.d.ts +0 -37
- package/dist/components/ui/icon-input.d.ts +0 -58
- package/dist/components/ui/image-crop-editor.d.ts +0 -41
- package/dist/components/ui/image-crop-editor.js +0 -417
- package/dist/components/ui/loading.js +0 -39
- package/dist/components/ui/locale-switcher.d.ts +0 -11
- package/dist/components/ui/map-menu-map.d.ts +0 -115
- package/dist/components/ui/map-menu.d.ts +0 -87
- package/dist/components/ui/phone-number-input.d.ts +0 -22
- package/dist/components/ui/phone-number-input.schema.d.ts +0 -7
- package/dist/components/ui/presence-transition.js +0 -94
- package/dist/components/ui/select-with-custom-input.d.ts +0 -36
- package/dist/components/ui/stats-card.d.ts +0 -12
- package/dist/components/ui/stepper.d.ts +0 -37
- package/dist/components/ui/time-picker.d.ts +0 -50
- package/dist/components/ui/time-picker.schema.d.ts +0 -28
- package/dist/components/ui/timezone-select.d.ts +0 -57
- package/dist/components/ui/timezone-select.schema.d.ts +0 -9
- package/dist/components/ui/toast.d.ts +0 -18
- package/dist/components/ui/unsaved-changes-guard.d.ts +0 -16
- package/dist/components/ui/upload-attachment.d.ts +0 -39
- package/dist/services/notification/persistence/drizzle.d.ts +0 -868
- package/dist/services/notification/persistence/drizzle.js +0 -214
- package/dist/services/notification/persistence/index.d.ts +0 -2
- package/dist/services/notification/persistence/index.js +0 -227
- package/dist/services/notification/persistence/schema.d.ts +0 -143
- package/dist/services/notification/persistence/schema.js +0 -118
- package/dist/services/webhooks/client/delivery-table.d.ts +0 -62
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
// ../../src/
|
|
2
|
-
import {
|
|
1
|
+
// ../../src/components/webhook-delivery-table/react.tsx
|
|
2
|
+
import { Component as Component7, View as View3 } 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 } from "effect/ui";
|
|
13
10
|
import {
|
|
14
11
|
ArrowDown,
|
|
15
12
|
ArrowUp,
|
|
@@ -38,11 +35,13 @@ import {
|
|
|
38
35
|
isValidElement,
|
|
39
36
|
useCallback,
|
|
40
37
|
useContext,
|
|
38
|
+
useEffect,
|
|
41
39
|
useId as useId2,
|
|
42
40
|
useLayoutEffect,
|
|
43
41
|
useMemo as useMemo2,
|
|
44
42
|
useRef,
|
|
45
|
-
useState
|
|
43
|
+
useState,
|
|
44
|
+
useSyncExternalStore
|
|
46
45
|
} from "react";
|
|
47
46
|
import { createPortal } from "react-dom";
|
|
48
47
|
|
|
@@ -508,38 +507,51 @@ function SelectScrollDownButton({
|
|
|
508
507
|
});
|
|
509
508
|
}
|
|
510
509
|
|
|
511
|
-
// ../../src/components/
|
|
510
|
+
// ../../src/components/loading/react.tsx
|
|
512
511
|
import { Loader2 } from "lucide-react";
|
|
513
|
-
import { useKrakstackLocale } from "@krak-stack/registry/krakstack-provider";
|
|
514
|
-
|
|
512
|
+
import { useKrakstackLocale } from "@krak-stack/registry/krakstack-provider/react";
|
|
513
|
+
|
|
514
|
+
// ../../src/components/loading/classes.ts
|
|
515
|
+
var resolveLoadingClasses = ({
|
|
516
|
+
classes,
|
|
517
|
+
variant,
|
|
518
|
+
className
|
|
519
|
+
}) => ({
|
|
520
|
+
root: cn(classes?.root ?? "text-muted-foreground flex items-center justify-center gap-2 text-sm", variant === "centered" && (classes?.centered ?? "min-h-[50svh] w-full"), className),
|
|
521
|
+
icon: classes?.icon ?? "size-4 motion-safe:animate-spin"
|
|
522
|
+
});
|
|
523
|
+
|
|
524
|
+
// ../../src/components/loading/index.ts
|
|
515
525
|
var labels = {
|
|
516
|
-
en:
|
|
517
|
-
|
|
518
|
-
},
|
|
519
|
-
fr: {
|
|
520
|
-
loading: "Chargement..."
|
|
521
|
-
}
|
|
526
|
+
en: "Loading...",
|
|
527
|
+
fr: "Chargement..."
|
|
522
528
|
};
|
|
523
|
-
var loadingLabel = (locale, messages) => messages?.[locale]?.loading ?? messages?.[locale.split("-")[0] ?? locale]?.loading ?? (locale.startsWith("fr") ? labels.fr
|
|
529
|
+
var loadingLabel = (locale, messages) => messages?.[locale]?.loading ?? messages?.[locale.split("-")[0] ?? locale]?.loading ?? (locale.startsWith("fr") ? labels.fr : labels.en);
|
|
530
|
+
|
|
531
|
+
// ../../src/components/loading/react.tsx
|
|
532
|
+
import { jsx as jsx9, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
524
533
|
function Loading({
|
|
525
534
|
className,
|
|
535
|
+
classes,
|
|
526
536
|
label,
|
|
527
537
|
locale: localeOverride,
|
|
528
538
|
messages,
|
|
529
539
|
variant = "inline"
|
|
530
540
|
}) {
|
|
531
541
|
const locale = useKrakstackLocale(localeOverride);
|
|
542
|
+
const slots = resolveLoadingClasses({ classes, variant, className });
|
|
532
543
|
return /* @__PURE__ */ jsxs4("div", {
|
|
533
|
-
|
|
544
|
+
role: "status",
|
|
545
|
+
className: slots.root,
|
|
534
546
|
children: [
|
|
535
547
|
/* @__PURE__ */ jsx9(Loader2, {
|
|
536
|
-
|
|
548
|
+
"aria-hidden": "true",
|
|
549
|
+
className: slots.icon
|
|
537
550
|
}),
|
|
538
551
|
label ?? loadingLabel(locale, messages)
|
|
539
552
|
]
|
|
540
553
|
});
|
|
541
554
|
}
|
|
542
|
-
|
|
543
555
|
// ../../src/components/ui/menubar.tsx
|
|
544
556
|
import { Menu as MenuPrimitive2 } from "@base-ui/react/menu";
|
|
545
557
|
import { Menubar as MenubarPrimitive } from "@base-ui/react/menubar";
|
|
@@ -714,7 +726,7 @@ function MenubarSubContent({
|
|
|
714
726
|
});
|
|
715
727
|
}
|
|
716
728
|
|
|
717
|
-
// ../../src/components/
|
|
729
|
+
// ../../src/components/pagination/react.tsx
|
|
718
730
|
import {
|
|
719
731
|
ChevronLeft,
|
|
720
732
|
ChevronRight,
|
|
@@ -722,8 +734,79 @@ import {
|
|
|
722
734
|
ChevronsRight
|
|
723
735
|
} from "lucide-react";
|
|
724
736
|
import { useId } from "react";
|
|
725
|
-
import { useKrakstackLocale as useKrakstackLocale2 } from "@krak-stack/registry/krakstack-provider";
|
|
726
|
-
|
|
737
|
+
import { useKrakstackLocale as useKrakstackLocale2 } from "@krak-stack/registry/krakstack-provider/react";
|
|
738
|
+
|
|
739
|
+
// ../../src/components/pagination/classes.ts
|
|
740
|
+
var paginationClasses = {
|
|
741
|
+
root: "flex flex-col gap-3 px-2 sm:flex-row sm:items-center sm:justify-between",
|
|
742
|
+
summary: "text-muted-foreground flex flex-wrap items-center gap-x-3 gap-y-1 text-sm",
|
|
743
|
+
controls: "flex items-center gap-4 sm:justify-end",
|
|
744
|
+
controlGroup: "flex items-center gap-2",
|
|
745
|
+
navigation: "flex items-center gap-1",
|
|
746
|
+
compactRoot: "gap-2 px-0 sm:flex-col sm:items-stretch",
|
|
747
|
+
compactControls: "flex-wrap justify-between gap-2 sm:justify-between"
|
|
748
|
+
};
|
|
749
|
+
var resolvePaginationClasses = (overrides) => ({
|
|
750
|
+
...paginationClasses,
|
|
751
|
+
...overrides
|
|
752
|
+
});
|
|
753
|
+
|
|
754
|
+
// ../../src/components/pagination/index.ts
|
|
755
|
+
import { Schema as Schema2 } from "effect";
|
|
756
|
+
import { Component, UiSchema } from "effect/ui";
|
|
757
|
+
|
|
758
|
+
// ../../src/components/pagination/schema.ts
|
|
759
|
+
import { Schema, Struct } from "effect";
|
|
760
|
+
var Labels = Schema.Struct({
|
|
761
|
+
pageSize: Schema.optional(Schema.String),
|
|
762
|
+
goToFirstPage: Schema.optional(Schema.String),
|
|
763
|
+
goToPreviousPage: Schema.optional(Schema.String),
|
|
764
|
+
goToNextPage: Schema.optional(Schema.String),
|
|
765
|
+
goToLastPage: Schema.optional(Schema.String)
|
|
766
|
+
}).annotate({ identifier: "PaginationLabelOverrides" });
|
|
767
|
+
var Translations = Schema.Record(Schema.String, Schema.UndefinedOr(Labels));
|
|
768
|
+
var PaginationClassesOverridesSchema = Schema.Record(Schema.Literals(Struct.keys(paginationClasses)), Schema.optionalKey(Schema.String)).annotate({ identifier: "PaginationClassesOverrides" });
|
|
769
|
+
var PaginationPropsSchema = Schema.Struct({
|
|
770
|
+
classes: Schema.optional(PaginationClassesOverridesSchema),
|
|
771
|
+
className: Schema.optional(Schema.String),
|
|
772
|
+
pageSizeContentClassName: Schema.optional(Schema.String),
|
|
773
|
+
compact: Schema.optional(Schema.Boolean),
|
|
774
|
+
locale: Schema.optional(Schema.String),
|
|
775
|
+
messages: Schema.optional(Translations),
|
|
776
|
+
page: Schema.Int,
|
|
777
|
+
pageCount: Schema.Int,
|
|
778
|
+
pageSize: Schema.Int,
|
|
779
|
+
pageSizes: Schema.optional(Schema.Array(Schema.Int)),
|
|
780
|
+
selectedRows: Schema.optional(Schema.Int),
|
|
781
|
+
showResults: Schema.optional(Schema.Boolean),
|
|
782
|
+
totalRows: Schema.Int
|
|
783
|
+
}).annotate({ identifier: "PaginationProps" });
|
|
784
|
+
|
|
785
|
+
// ../../src/components/pagination/index.ts
|
|
786
|
+
var PaginationMessage = UiSchema.TaggedEnum({
|
|
787
|
+
Opened: {},
|
|
788
|
+
Closed: {},
|
|
789
|
+
PageRequested: { page: Schema2.Int },
|
|
790
|
+
SizeRequested: { pageSize: Schema2.Int }
|
|
791
|
+
}).annotate({ identifier: "PaginationMessage" });
|
|
792
|
+
var PaginationEvents = UiSchema.TaggedEnum({
|
|
793
|
+
PageChanged: { page: Schema2.Int },
|
|
794
|
+
PageSizeChanged: { pageSize: Schema2.Int }
|
|
795
|
+
}).annotate({ identifier: "PaginationEvents" });
|
|
796
|
+
var paginationOptions = {
|
|
797
|
+
name: "Pagination",
|
|
798
|
+
props: PaginationPropsSchema,
|
|
799
|
+
model: Schema2.Boolean,
|
|
800
|
+
message: PaginationMessage,
|
|
801
|
+
events: PaginationEvents,
|
|
802
|
+
restore: false
|
|
803
|
+
};
|
|
804
|
+
var update = Component.define(paginationOptions).update({
|
|
805
|
+
Opened: () => true,
|
|
806
|
+
Closed: () => false,
|
|
807
|
+
PageRequested: ($, { page }) => $.set($.model).emit(PaginationEvents.PageChanged({ page })),
|
|
808
|
+
SizeRequested: ($, { pageSize }) => $.set(false).emit(PaginationEvents.PageSizeChanged({ pageSize }))
|
|
809
|
+
});
|
|
727
810
|
var messages = {
|
|
728
811
|
en: {
|
|
729
812
|
pageSize: "Page size",
|
|
@@ -751,7 +834,35 @@ var paginationMessages = (locale = "en", translations) => ({
|
|
|
751
834
|
...translations?.[locale.split("-")[0] ?? locale],
|
|
752
835
|
...translations?.[locale]
|
|
753
836
|
});
|
|
837
|
+
var defaultPageSizes = [20, 50, 100];
|
|
838
|
+
var paginationPageLabel = (page, pageCount, pageOf) => pageCount > 0 ? pageOf(page + 1, pageCount) : undefined;
|
|
839
|
+
var paginationNavigation = (page, pageCount) => ({
|
|
840
|
+
goToFirstPage: {
|
|
841
|
+
page: 0,
|
|
842
|
+
disabled: pageCount <= 0 || page <= 0,
|
|
843
|
+
edge: true
|
|
844
|
+
},
|
|
845
|
+
goToPreviousPage: {
|
|
846
|
+
page: page - 1,
|
|
847
|
+
disabled: pageCount <= 0 || page <= 0,
|
|
848
|
+
edge: false
|
|
849
|
+
},
|
|
850
|
+
goToNextPage: {
|
|
851
|
+
page: page + 1,
|
|
852
|
+
disabled: pageCount <= 0 || page + 1 >= pageCount,
|
|
853
|
+
edge: false
|
|
854
|
+
},
|
|
855
|
+
goToLastPage: {
|
|
856
|
+
page: pageCount - 1,
|
|
857
|
+
disabled: pageCount <= 0 || page + 1 >= pageCount,
|
|
858
|
+
edge: true
|
|
859
|
+
}
|
|
860
|
+
});
|
|
861
|
+
|
|
862
|
+
// ../../src/components/pagination/react.tsx
|
|
863
|
+
import { jsx as jsx11, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
754
864
|
function Pagination({
|
|
865
|
+
classes: classOverrides,
|
|
755
866
|
className,
|
|
756
867
|
pageSizeContentClassName,
|
|
757
868
|
compact = false,
|
|
@@ -762,22 +873,23 @@ function Pagination({
|
|
|
762
873
|
page,
|
|
763
874
|
pageCount,
|
|
764
875
|
pageSize,
|
|
765
|
-
pageSizes =
|
|
876
|
+
pageSizes = defaultPageSizes,
|
|
766
877
|
selectedRows = 0,
|
|
767
878
|
showResults = true,
|
|
768
879
|
totalRows
|
|
769
880
|
}) {
|
|
881
|
+
const paginationClasses = resolvePaginationClasses(classOverrides);
|
|
770
882
|
const locale = useKrakstackLocale2(localeOverride);
|
|
771
883
|
const labels = paginationMessages(locale, messageOverrides);
|
|
772
884
|
const pageSizeId = useId();
|
|
773
|
-
const
|
|
774
|
-
const
|
|
885
|
+
const navigation = paginationNavigation(page, pageCount);
|
|
886
|
+
const pageLabel = paginationPageLabel(page, pageCount, labels.pageOf);
|
|
775
887
|
return /* @__PURE__ */ jsxs6("div", {
|
|
776
888
|
"data-slot": "pagination",
|
|
777
|
-
className: cn(
|
|
889
|
+
className: cn(paginationClasses.root, compact && paginationClasses.compactRoot, className),
|
|
778
890
|
children: [
|
|
779
891
|
showResults ? /* @__PURE__ */ jsxs6("div", {
|
|
780
|
-
className:
|
|
892
|
+
className: paginationClasses.summary,
|
|
781
893
|
children: [
|
|
782
894
|
/* @__PURE__ */ jsx11("span", {
|
|
783
895
|
children: labels.results(totalRows)
|
|
@@ -788,10 +900,10 @@ function Pagination({
|
|
|
788
900
|
]
|
|
789
901
|
}) : null,
|
|
790
902
|
/* @__PURE__ */ jsxs6("div", {
|
|
791
|
-
className: cn(
|
|
903
|
+
className: cn(paginationClasses.controls, compact && paginationClasses.compactControls),
|
|
792
904
|
children: [
|
|
793
905
|
/* @__PURE__ */ jsxs6("div", {
|
|
794
|
-
className:
|
|
906
|
+
className: paginationClasses.controlGroup,
|
|
795
907
|
children: [
|
|
796
908
|
/* @__PURE__ */ jsx11(Label, {
|
|
797
909
|
htmlFor: pageSizeId,
|
|
@@ -826,19 +938,19 @@ function Pagination({
|
|
|
826
938
|
]
|
|
827
939
|
}),
|
|
828
940
|
/* @__PURE__ */ jsxs6("div", {
|
|
829
|
-
className:
|
|
941
|
+
className: paginationClasses.controlGroup,
|
|
830
942
|
children: [
|
|
831
|
-
/* @__PURE__ */ jsx11("div", {
|
|
943
|
+
pageLabel !== undefined && /* @__PURE__ */ jsx11("div", {
|
|
832
944
|
className: "flex items-center justify-center text-sm font-medium sm:block",
|
|
833
|
-
children:
|
|
945
|
+
children: pageLabel
|
|
834
946
|
}),
|
|
835
947
|
/* @__PURE__ */ jsxs6("div", {
|
|
836
|
-
className:
|
|
948
|
+
className: paginationClasses.navigation,
|
|
837
949
|
children: [
|
|
838
950
|
/* @__PURE__ */ jsxs6(Button, {
|
|
839
951
|
className: cn("hidden h-8 w-8 p-0 lg:flex", compact && "!hidden"),
|
|
840
|
-
disabled:
|
|
841
|
-
onClick: () => onPageChange(
|
|
952
|
+
disabled: navigation.goToFirstPage.disabled,
|
|
953
|
+
onClick: () => onPageChange(navigation.goToFirstPage.page),
|
|
842
954
|
type: "button",
|
|
843
955
|
children: [
|
|
844
956
|
/* @__PURE__ */ jsx11("span", {
|
|
@@ -850,8 +962,8 @@ function Pagination({
|
|
|
850
962
|
}),
|
|
851
963
|
/* @__PURE__ */ jsxs6(Button, {
|
|
852
964
|
className: "h-8 w-8 p-0",
|
|
853
|
-
disabled:
|
|
854
|
-
onClick: () => onPageChange(page
|
|
965
|
+
disabled: navigation.goToPreviousPage.disabled,
|
|
966
|
+
onClick: () => onPageChange(navigation.goToPreviousPage.page),
|
|
855
967
|
type: "button",
|
|
856
968
|
children: [
|
|
857
969
|
/* @__PURE__ */ jsx11("span", {
|
|
@@ -863,8 +975,8 @@ function Pagination({
|
|
|
863
975
|
}),
|
|
864
976
|
/* @__PURE__ */ jsxs6(Button, {
|
|
865
977
|
className: "h-8 w-8 p-0",
|
|
866
|
-
disabled:
|
|
867
|
-
onClick: () => onPageChange(page
|
|
978
|
+
disabled: navigation.goToNextPage.disabled,
|
|
979
|
+
onClick: () => onPageChange(navigation.goToNextPage.page),
|
|
868
980
|
type: "button",
|
|
869
981
|
children: [
|
|
870
982
|
/* @__PURE__ */ jsx11("span", {
|
|
@@ -876,8 +988,8 @@ function Pagination({
|
|
|
876
988
|
}),
|
|
877
989
|
/* @__PURE__ */ jsxs6(Button, {
|
|
878
990
|
className: cn("hidden h-8 w-8 p-0 lg:flex", compact && "!hidden"),
|
|
879
|
-
disabled:
|
|
880
|
-
onClick: () => onPageChange(
|
|
991
|
+
disabled: navigation.goToLastPage.disabled,
|
|
992
|
+
onClick: () => onPageChange(navigation.goToLastPage.page),
|
|
881
993
|
type: "button",
|
|
882
994
|
children: [
|
|
883
995
|
/* @__PURE__ */ jsx11("span", {
|
|
@@ -896,7 +1008,6 @@ function Pagination({
|
|
|
896
1008
|
]
|
|
897
1009
|
});
|
|
898
1010
|
}
|
|
899
|
-
|
|
900
1011
|
// ../../src/components/ui/scroll-area.tsx
|
|
901
1012
|
import { ScrollArea as ScrollAreaPrimitive } from "@base-ui/react/scroll-area";
|
|
902
1013
|
import { jsx as jsx12, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
@@ -1049,7 +1160,7 @@ import {
|
|
|
1049
1160
|
DateTime,
|
|
1050
1161
|
Effect,
|
|
1051
1162
|
Option,
|
|
1052
|
-
Schema,
|
|
1163
|
+
Schema as Schema3,
|
|
1053
1164
|
SchemaGetter,
|
|
1054
1165
|
SchemaIssue,
|
|
1055
1166
|
SchemaTransformation
|
|
@@ -1061,25 +1172,25 @@ var parseSortParam = (sort) => {
|
|
|
1061
1172
|
}
|
|
1062
1173
|
return { id, direction: sort.startsWith("-") ? "desc" : "asc" };
|
|
1063
1174
|
};
|
|
1064
|
-
var SortDirection =
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
]).pipe(
|
|
1175
|
+
var SortDirection = Schema3.Union([
|
|
1176
|
+
Schema3.Literal("asc"),
|
|
1177
|
+
Schema3.Literal("desc")
|
|
1178
|
+
]).pipe(Schema3.annotate({
|
|
1068
1179
|
identifier: "SortDirection",
|
|
1069
1180
|
title: "Sort Direction",
|
|
1070
1181
|
description: "Sort direction for list query results.",
|
|
1071
1182
|
examples: ["asc", "desc"]
|
|
1072
1183
|
}));
|
|
1073
|
-
var SortParam =
|
|
1074
|
-
id:
|
|
1184
|
+
var SortParam = Schema3.Struct({
|
|
1185
|
+
id: Schema3.NonEmptyString,
|
|
1075
1186
|
direction: SortDirection
|
|
1076
|
-
}).pipe(
|
|
1187
|
+
}).pipe(Schema3.annotate({
|
|
1077
1188
|
identifier: "SortParam",
|
|
1078
1189
|
title: "Sort Parameter",
|
|
1079
1190
|
description: "Decoded sort parameter with a field id and direction.",
|
|
1080
1191
|
examples: [{ id: "publicName", direction: "asc" }]
|
|
1081
1192
|
}));
|
|
1082
|
-
var SortParamFromString =
|
|
1193
|
+
var SortParamFromString = Schema3.String.pipe(Schema3.decodeTo(SortParam, SchemaTransformation.transformEffect({
|
|
1083
1194
|
decode: (sort) => {
|
|
1084
1195
|
const sortParam = parseSortParam(sort);
|
|
1085
1196
|
if (!sortParam) {
|
|
@@ -1088,13 +1199,13 @@ var SortParamFromString = Schema.String.pipe(Schema.decodeTo(SortParam, SchemaTr
|
|
|
1088
1199
|
return Effect.succeed(sortParam);
|
|
1089
1200
|
},
|
|
1090
1201
|
encode: (sort) => Effect.succeed(sort.direction === "desc" ? `-${sort.id}` : sort.id)
|
|
1091
|
-
})),
|
|
1202
|
+
})), Schema3.annotate({
|
|
1092
1203
|
identifier: "SortParamFromString",
|
|
1093
1204
|
title: "Sort Parameter From String",
|
|
1094
1205
|
description: 'URL encoded single sort parameter where descending fields are prefixed with "-".',
|
|
1095
1206
|
examples: [{ id: "publicName", direction: "asc" }]
|
|
1096
1207
|
}));
|
|
1097
|
-
var SortParamsFromString =
|
|
1208
|
+
var SortParamsFromString = Schema3.String.pipe(Schema3.decodeTo(Schema3.Array(SortParam), SchemaTransformation.transformEffect({
|
|
1098
1209
|
decode: (sort) => {
|
|
1099
1210
|
if (sort === "")
|
|
1100
1211
|
return Effect.succeed([]);
|
|
@@ -1109,8 +1220,8 @@ var SortParamsFromString = Schema.String.pipe(Schema.decodeTo(Schema.Array(SortP
|
|
|
1109
1220
|
}
|
|
1110
1221
|
return Effect.succeed(sortParams);
|
|
1111
1222
|
},
|
|
1112
|
-
encode: (sort) => Effect.succeed(sort.map((part) =>
|
|
1113
|
-
})),
|
|
1223
|
+
encode: (sort) => Effect.succeed(sort.map((part) => Schema3.encodeSync(SortParamFromString)(part)).join(","))
|
|
1224
|
+
})), Schema3.annotate({
|
|
1114
1225
|
identifier: "SortParamsFromString",
|
|
1115
1226
|
title: "Sort Parameters From String",
|
|
1116
1227
|
description: 'URL encoded sort parameters where descending fields are prefixed with "-" and multiple fields are comma-separated.',
|
|
@@ -1121,68 +1232,68 @@ var SortParamsFromString = Schema.String.pipe(Schema.decodeTo(Schema.Array(SortP
|
|
|
1121
1232
|
]
|
|
1122
1233
|
]
|
|
1123
1234
|
}));
|
|
1124
|
-
var SortParamsArray =
|
|
1125
|
-
var SortParams =
|
|
1235
|
+
var SortParamsArray = Schema3.Array(SortParam);
|
|
1236
|
+
var SortParams = Schema3.declare(Schema3.is(SortParamsArray), {
|
|
1126
1237
|
identifier: "SortParams",
|
|
1127
|
-
toCodec: () =>
|
|
1128
|
-
toCodecStringTree: () =>
|
|
1238
|
+
toCodec: () => Schema3.link()(SortParamsArray, SchemaTransformation.passthrough()),
|
|
1239
|
+
toCodecStringTree: () => Schema3.link()(SortParamsFromString, SchemaTransformation.passthrough())
|
|
1129
1240
|
});
|
|
1130
|
-
var TextFilterOperator =
|
|
1241
|
+
var TextFilterOperator = Schema3.Literals([
|
|
1131
1242
|
"contains",
|
|
1132
1243
|
"equals",
|
|
1133
1244
|
"startsWith",
|
|
1134
1245
|
"endsWith"
|
|
1135
1246
|
]).annotate({ identifier: "TextFilterOperator" });
|
|
1136
|
-
var FilterCalendarDate =
|
|
1137
|
-
var ColumnFilter =
|
|
1138
|
-
|
|
1139
|
-
id:
|
|
1140
|
-
kind:
|
|
1247
|
+
var FilterCalendarDate = Schema3.String.check(Schema3.isPattern(/^\d{4}-\d{2}-\d{2}$/), Schema3.makeFilter((value) => Option.exists(DateTime.make(value), (date) => DateTime.formatIsoDateUtc(date) === value))).annotate({ identifier: "FilterCalendarDate" });
|
|
1248
|
+
var ColumnFilter = Schema3.Union([
|
|
1249
|
+
Schema3.Struct({
|
|
1250
|
+
id: Schema3.NonEmptyString,
|
|
1251
|
+
kind: Schema3.Literal("text"),
|
|
1141
1252
|
operator: TextFilterOperator,
|
|
1142
|
-
value:
|
|
1253
|
+
value: Schema3.NonEmptyString
|
|
1143
1254
|
}),
|
|
1144
|
-
|
|
1145
|
-
id:
|
|
1146
|
-
kind:
|
|
1147
|
-
min:
|
|
1148
|
-
max:
|
|
1149
|
-
}).check(
|
|
1150
|
-
|
|
1151
|
-
id:
|
|
1152
|
-
kind:
|
|
1153
|
-
from:
|
|
1154
|
-
to:
|
|
1155
|
-
}).check(
|
|
1156
|
-
|
|
1157
|
-
id:
|
|
1158
|
-
kind:
|
|
1159
|
-
value:
|
|
1255
|
+
Schema3.Struct({
|
|
1256
|
+
id: Schema3.NonEmptyString,
|
|
1257
|
+
kind: Schema3.Literal("number"),
|
|
1258
|
+
min: Schema3.optional(Schema3.Finite),
|
|
1259
|
+
max: Schema3.optional(Schema3.Finite)
|
|
1260
|
+
}).check(Schema3.makeFilter((range) => (range.min !== undefined || range.max !== undefined) && (range.min === undefined || range.max === undefined || range.min <= range.max))),
|
|
1261
|
+
Schema3.Struct({
|
|
1262
|
+
id: Schema3.NonEmptyString,
|
|
1263
|
+
kind: Schema3.Literal("date"),
|
|
1264
|
+
from: Schema3.optional(FilterCalendarDate),
|
|
1265
|
+
to: Schema3.optional(FilterCalendarDate)
|
|
1266
|
+
}).check(Schema3.makeFilter((range) => (range.from !== undefined || range.to !== undefined) && (range.from === undefined || range.to === undefined || range.from <= range.to))),
|
|
1267
|
+
Schema3.Struct({
|
|
1268
|
+
id: Schema3.NonEmptyString,
|
|
1269
|
+
kind: Schema3.Literal("boolean"),
|
|
1270
|
+
value: Schema3.Boolean
|
|
1160
1271
|
}),
|
|
1161
|
-
|
|
1162
|
-
id:
|
|
1163
|
-
kind:
|
|
1164
|
-
values:
|
|
1272
|
+
Schema3.Struct({
|
|
1273
|
+
id: Schema3.NonEmptyString,
|
|
1274
|
+
kind: Schema3.Literal("values"),
|
|
1275
|
+
values: Schema3.NonEmptyArray(Schema3.String)
|
|
1165
1276
|
})
|
|
1166
1277
|
]).annotate({ identifier: "ColumnFilter" });
|
|
1167
|
-
var ColumnFiltersArray =
|
|
1168
|
-
var ColumnFilters =
|
|
1278
|
+
var ColumnFiltersArray = Schema3.Array(ColumnFilter);
|
|
1279
|
+
var ColumnFilters = Schema3.declare(Schema3.is(ColumnFiltersArray), {
|
|
1169
1280
|
identifier: "ColumnFilters",
|
|
1170
|
-
toCodec: () =>
|
|
1171
|
-
toCodecStringTree: () =>
|
|
1281
|
+
toCodec: () => Schema3.link()(ColumnFiltersArray, SchemaTransformation.passthrough()),
|
|
1282
|
+
toCodecStringTree: () => Schema3.link()(Schema3.fromJsonString(ColumnFiltersArray), SchemaTransformation.passthrough())
|
|
1172
1283
|
});
|
|
1173
1284
|
var DEFAULT_PAGE_SIZE = 100;
|
|
1174
|
-
var Query =
|
|
1175
|
-
page:
|
|
1285
|
+
var Query = Schema3.Struct({
|
|
1286
|
+
page: Schema3.optional(Schema3.Union([Schema3.Finite, Schema3.FiniteFromString]).check(Schema3.isInt(), Schema3.isGreaterThanOrEqualTo(0))).pipe(Schema3.decodeTo(Schema3.Int.check(Schema3.isGreaterThanOrEqualTo(0)), {
|
|
1176
1287
|
decode: SchemaGetter.withDefault(Effect.succeed(0)),
|
|
1177
1288
|
encode: SchemaGetter.transformOptional(Option.filter((page) => page !== 0))
|
|
1178
1289
|
})),
|
|
1179
|
-
pageSize:
|
|
1290
|
+
pageSize: Schema3.optional(Schema3.Union([Schema3.Finite, Schema3.FiniteFromString]).check(Schema3.isInt(), Schema3.isBetween({ minimum: 1, maximum: 100 }))).pipe(Schema3.decodeTo(Schema3.Int.check(Schema3.isBetween({ minimum: 1, maximum: 100 })), {
|
|
1180
1291
|
decode: SchemaGetter.withDefault(Effect.succeed(DEFAULT_PAGE_SIZE)),
|
|
1181
1292
|
encode: SchemaGetter.transformOptional(Option.filter((pageSize) => pageSize !== DEFAULT_PAGE_SIZE))
|
|
1182
1293
|
})),
|
|
1183
|
-
globalFilter:
|
|
1184
|
-
sort:
|
|
1185
|
-
filters:
|
|
1294
|
+
globalFilter: Schema3.optional(Schema3.String),
|
|
1295
|
+
sort: Schema3.optional(SortParams),
|
|
1296
|
+
filters: Schema3.optional(ColumnFilters)
|
|
1186
1297
|
}).annotate({
|
|
1187
1298
|
identifier: "Query",
|
|
1188
1299
|
title: "Query",
|
|
@@ -1199,23 +1310,1321 @@ 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/components/
|
|
1216
|
-
import {
|
|
1326
|
+
// ../../src/components/data-table/react.tsx
|
|
1327
|
+
import { useModel } from "@krak-stack/registry/effect-ui-adapter/react";
|
|
1328
|
+
import { useKrakstackLocale as useKrakstackLocale3 } from "@krak-stack/registry/krakstack-provider/react";
|
|
1329
|
+
|
|
1330
|
+
// ../../src/components/data-table/classes.ts
|
|
1331
|
+
var tableClasses = {
|
|
1332
|
+
selectionCell: "w-10 p-0 align-middle",
|
|
1333
|
+
selectionCenter: "grid place-items-center",
|
|
1334
|
+
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",
|
|
1335
|
+
selectedTrigger: "bg-primary text-primary-foreground hover:bg-primary/90 hover:text-primary-foreground",
|
|
1336
|
+
toolbar: "flex min-w-0 shrink-0 flex-wrap items-center gap-2",
|
|
1337
|
+
toolbarSearch: "relative min-w-0 flex-[1_1_12rem]",
|
|
1338
|
+
toolbarMenus: "w-max min-w-0 max-w-full",
|
|
1339
|
+
menubar: "h-auto w-full flex-wrap justify-start border border-input bg-transparent",
|
|
1340
|
+
cell: "overflow-hidden",
|
|
1341
|
+
cellContent: "min-w-0 wrap-anywhere",
|
|
1342
|
+
actionTrigger: "size-8 focus-visible:ring-inset",
|
|
1343
|
+
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))]",
|
|
1344
|
+
actionsAlign: "flex min-h-12 items-center justify-end pe-1",
|
|
1345
|
+
header: "relative h-12 p-0",
|
|
1346
|
+
stickyHeader: "sticky top-0 z-30 bg-background",
|
|
1347
|
+
stickyHeaderRule: "after:border-border after:pointer-events-none after:absolute after:inset-x-0 after:bottom-0 after:border-b",
|
|
1348
|
+
headerTrigger: "absolute inset-0 h-full w-full min-w-0 justify-start rounded-none px-2 pe-4 focus-visible:ring-inset",
|
|
1349
|
+
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",
|
|
1350
|
+
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",
|
|
1351
|
+
relationshipTrigger: "h-full w-full min-w-0 justify-between rounded-none px-2 text-start focus-visible:ring-inset",
|
|
1352
|
+
reference: "flex min-w-0 items-center gap-2",
|
|
1353
|
+
referenceAvatar: "relative grid size-8 shrink-0 place-items-center overflow-hidden bg-muted text-xs font-medium",
|
|
1354
|
+
referenceText: "flex min-w-0 flex-col leading-tight",
|
|
1355
|
+
group: "bg-muted/40 hover:bg-accent!",
|
|
1356
|
+
groupContent: "flex min-w-0 items-center gap-2 py-2 pe-1 ps-2",
|
|
1357
|
+
groupSticky: "sticky start-0 w-[100cqw] max-w-full",
|
|
1358
|
+
groupTrigger: "flex min-w-0 flex-1 cursor-pointer items-center gap-2 text-start font-medium",
|
|
1359
|
+
referenceName: "truncate font-medium",
|
|
1360
|
+
referenceDescription: "text-muted-foreground truncate text-xs"
|
|
1361
|
+
};
|
|
1362
|
+
var resolveTableClasses = (overrides) => ({
|
|
1363
|
+
...tableClasses,
|
|
1364
|
+
...overrides
|
|
1365
|
+
});
|
|
1366
|
+
|
|
1367
|
+
// ../../src/components/data-table/index.ts
|
|
1368
|
+
import { DateTime as DateTime3, Effect as Effect2, Option as Option3, Redacted, Schema as Schema5, Stream } from "effect";
|
|
1369
|
+
import { Csv } from "effect/encoding";
|
|
1370
|
+
import { Command, Component as Component2, Subscription, UiSchema as UiSchema2 } from "effect/ui";
|
|
1371
|
+
|
|
1372
|
+
// ../../src/components/data-table/schema.ts
|
|
1373
|
+
import { DateTime as DateTime2, Option as Option2, Schema as Schema4, Struct as Struct2, Tuple } from "effect";
|
|
1374
|
+
var TableClassesOverridesSchema = Schema4.Record(Schema4.Literals(Struct2.keys(tableClasses)), Schema4.optionalKey(Schema4.String)).annotate({ identifier: "TableClassesOverrides" });
|
|
1375
|
+
var DataTableCommonPropsSchema = Schema4.Struct({
|
|
1376
|
+
classes: Schema4.optional(TableClassesOverridesSchema),
|
|
1377
|
+
className: Schema4.optionalKey(Schema4.String),
|
|
1378
|
+
locale: Schema4.optionalKey(Schema4.String)
|
|
1379
|
+
}).annotate({ identifier: "DataTableCommonProps" });
|
|
1380
|
+
var DataTableSortSchema = Schema4.Struct({
|
|
1381
|
+
id: Schema4.NonEmptyString,
|
|
1382
|
+
direction: Schema4.Literals(["asc", "desc"])
|
|
1383
|
+
}).annotate({ identifier: "DataTableSort" });
|
|
1384
|
+
var queryFields = {
|
|
1385
|
+
page: Schema4.Int.check(Schema4.isGreaterThanOrEqualTo(0)),
|
|
1386
|
+
pageSize: Schema4.Int.check(Schema4.isBetween({ minimum: 1, maximum: 100 })),
|
|
1387
|
+
globalFilter: Schema4.optional(Schema4.String),
|
|
1388
|
+
sort: Schema4.optional(Schema4.Array(DataTableSortSchema)),
|
|
1389
|
+
filters: Schema4.optional(Schema4.Array(ColumnFilter))
|
|
1390
|
+
};
|
|
1391
|
+
var DataTableQuerySchema = Schema4.Struct(queryFields).annotate({
|
|
1392
|
+
identifier: "DataTableQuery"
|
|
1393
|
+
});
|
|
1394
|
+
var PageSizes = Schema4.NonEmptyArray(Schema4.Int.check(Schema4.isBetween({ minimum: 1, maximum: 100 })));
|
|
1395
|
+
var DataTableCommonFeaturesSchema = Schema4.Struct({
|
|
1396
|
+
search: Schema4.optionalKey(Schema4.Boolean),
|
|
1397
|
+
filtering: Schema4.optionalKey(Schema4.Boolean),
|
|
1398
|
+
sorting: Schema4.optionalKey(Schema4.Boolean),
|
|
1399
|
+
columnVisibility: Schema4.optionalKey(Schema4.Boolean)
|
|
1400
|
+
});
|
|
1401
|
+
var PaginationSchema = Schema4.Union([
|
|
1402
|
+
Schema4.Struct({
|
|
1403
|
+
mode: Schema4.optionalKey(Schema4.Literal("client")),
|
|
1404
|
+
pageSizes: Schema4.optionalKey(PageSizes)
|
|
1405
|
+
}).annotate({ identifier: "DataTableClientPagination" }),
|
|
1406
|
+
Schema4.Struct({
|
|
1407
|
+
mode: Schema4.Literal("server"),
|
|
1408
|
+
rowCount: Schema4.Int.check(Schema4.isGreaterThanOrEqualTo(0)),
|
|
1409
|
+
pageSizes: Schema4.optionalKey(PageSizes)
|
|
1410
|
+
}).annotate({ identifier: "DataTableServerPagination" })
|
|
1411
|
+
]);
|
|
1412
|
+
var DataTableItemSchema = Schema4.Struct({
|
|
1413
|
+
value: Schema4.NonEmptyString,
|
|
1414
|
+
label: Schema4.String
|
|
1415
|
+
}).annotate({ identifier: "DataTableItem" });
|
|
1416
|
+
var DataTableReferenceSchema = Schema4.Struct({
|
|
1417
|
+
label: Schema4.String,
|
|
1418
|
+
description: Schema4.optionalKey(Schema4.String),
|
|
1419
|
+
imageSrc: Schema4.optionalKey(Schema4.NullOr(Schema4.String))
|
|
1420
|
+
}).annotate({ identifier: "DataTableReference" });
|
|
1421
|
+
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" });
|
|
1422
|
+
var isCalendarDate = Schema4.is(CalendarDate);
|
|
1423
|
+
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" });
|
|
1424
|
+
var DataTableDateInputSchema = Schema4.Union([
|
|
1425
|
+
Schema4.Date,
|
|
1426
|
+
Schema4.Int,
|
|
1427
|
+
CalendarDate,
|
|
1428
|
+
InstantString
|
|
1429
|
+
]).annotate({ identifier: "DataTableDateInput" });
|
|
1430
|
+
var DateStyle = Schema4.Literals(["full", "long", "medium", "short"]);
|
|
1431
|
+
var DataTableDateFormatSchema = Schema4.Struct({
|
|
1432
|
+
locale: Schema4.optionalKey(Schema4.String),
|
|
1433
|
+
timeZone: Schema4.optionalKey(Schema4.String),
|
|
1434
|
+
dateStyle: Schema4.optionalKey(DateStyle),
|
|
1435
|
+
exportFormat: Schema4.optionalKey(Schema4.Literals(["iso", "formatted"]))
|
|
1436
|
+
}).annotate({ identifier: "DataTableDateFormat" });
|
|
1437
|
+
var DataTableDateTimeFormatSchema = Schema4.Struct({
|
|
1438
|
+
...DataTableDateFormatSchema.fields,
|
|
1439
|
+
timeStyle: Schema4.optionalKey(DateStyle),
|
|
1440
|
+
hour12: Schema4.optionalKey(Schema4.Boolean)
|
|
1441
|
+
}).annotate({ identifier: "DataTableDateTimeFormat" });
|
|
1442
|
+
var DataTableCellValueSchema = Schema4.NullOr(Schema4.Union([
|
|
1443
|
+
Schema4.String,
|
|
1444
|
+
Schema4.Boolean,
|
|
1445
|
+
Schema4.Finite,
|
|
1446
|
+
Schema4.Array(DataTableItemSchema),
|
|
1447
|
+
DataTableReferenceSchema
|
|
1448
|
+
])).annotate({ identifier: "DataTableCellValue" });
|
|
1449
|
+
var DataTableActionSchema = Schema4.Struct({
|
|
1450
|
+
id: Schema4.NonEmptyString,
|
|
1451
|
+
name: Schema4.String,
|
|
1452
|
+
variant: Schema4.optionalKey(Schema4.Literals(["default", "destructive"])),
|
|
1453
|
+
disabled: Schema4.optionalKey(Schema4.Boolean)
|
|
1454
|
+
}).annotate({ identifier: "DataTableAction" });
|
|
1455
|
+
var DataTableRowSchema = Schema4.Struct({
|
|
1456
|
+
id: Schema4.NonEmptyString,
|
|
1457
|
+
label: Schema4.String,
|
|
1458
|
+
cells: Schema4.Record(Schema4.String, DataTableCellValueSchema),
|
|
1459
|
+
actions: Schema4.optionalKey(Schema4.Array(DataTableActionSchema)),
|
|
1460
|
+
primaryActionId: Schema4.optionalKey(Schema4.String),
|
|
1461
|
+
groups: Schema4.optionalKey(Schema4.Record(Schema4.String, Schema4.Array(Schema4.String))),
|
|
1462
|
+
selectable: Schema4.optionalKey(Schema4.Boolean),
|
|
1463
|
+
disabledColumnIds: Schema4.optionalKey(Schema4.Array(Schema4.String))
|
|
1464
|
+
}).annotate({ identifier: "DataTableRow" });
|
|
1465
|
+
var column = {
|
|
1466
|
+
id: Schema4.NonEmptyString,
|
|
1467
|
+
headerName: Schema4.String,
|
|
1468
|
+
sortable: Schema4.optionalKey(Schema4.Boolean),
|
|
1469
|
+
hideable: Schema4.optionalKey(Schema4.Boolean),
|
|
1470
|
+
export: Schema4.optionalKey(Schema4.Boolean),
|
|
1471
|
+
width: Schema4.optionalKey(Schema4.Number),
|
|
1472
|
+
minWidth: Schema4.optionalKey(Schema4.Number),
|
|
1473
|
+
maxWidth: Schema4.optionalKey(Schema4.Number),
|
|
1474
|
+
resizable: Schema4.optionalKey(Schema4.Boolean),
|
|
1475
|
+
truncate: Schema4.optionalKey(Schema4.Boolean),
|
|
1476
|
+
searchable: Schema4.optionalKey(Schema4.Boolean),
|
|
1477
|
+
filterable: Schema4.optionalKey(Schema4.Boolean),
|
|
1478
|
+
emptyLabel: Schema4.optionalKey(Schema4.String),
|
|
1479
|
+
nulls: Schema4.optionalKey(Schema4.Literals(["first", "last"]))
|
|
1480
|
+
};
|
|
1481
|
+
var DataTableFieldSchema = Schema4.Union([
|
|
1482
|
+
Schema4.Struct({ ...column, type: Schema4.Literal("text") }),
|
|
1483
|
+
Schema4.Struct({
|
|
1484
|
+
...column,
|
|
1485
|
+
type: Schema4.Literal("number"),
|
|
1486
|
+
typeOptions: Schema4.optionalKey(Schema4.Struct({
|
|
1487
|
+
locale: Schema4.optionalKey(Schema4.String),
|
|
1488
|
+
style: Schema4.optionalKey(Schema4.Literals(["decimal", "percent", "currency", "unit"])),
|
|
1489
|
+
currency: Schema4.optionalKey(Schema4.String),
|
|
1490
|
+
unit: Schema4.optionalKey(Schema4.String),
|
|
1491
|
+
notation: Schema4.optionalKey(Schema4.Literals(["standard", "scientific", "engineering", "compact"])),
|
|
1492
|
+
minimumFractionDigits: Schema4.optionalKey(Schema4.Int.check(Schema4.isBetween({ minimum: 0, maximum: 20 }))),
|
|
1493
|
+
maximumFractionDigits: Schema4.optionalKey(Schema4.Int.check(Schema4.isBetween({ minimum: 0, maximum: 20 }))),
|
|
1494
|
+
exportFormat: Schema4.optionalKey(Schema4.Literals(["raw", "formatted"]))
|
|
1495
|
+
}).annotate({ identifier: "DataTableNumberFormat" }))
|
|
1496
|
+
}),
|
|
1497
|
+
Schema4.Struct({ ...column, type: Schema4.Literal("reference") }),
|
|
1498
|
+
Schema4.Struct({
|
|
1499
|
+
...column,
|
|
1500
|
+
type: Schema4.Literal("date"),
|
|
1501
|
+
typeOptions: Schema4.optionalKey(DataTableDateFormatSchema)
|
|
1502
|
+
}),
|
|
1503
|
+
Schema4.Struct({
|
|
1504
|
+
...column,
|
|
1505
|
+
type: Schema4.Literal("dateTime"),
|
|
1506
|
+
typeOptions: Schema4.optionalKey(DataTableDateTimeFormatSchema)
|
|
1507
|
+
}),
|
|
1508
|
+
Schema4.Struct({
|
|
1509
|
+
...column,
|
|
1510
|
+
type: Schema4.Literal("boolean"),
|
|
1511
|
+
editable: Schema4.optionalKey(Schema4.Boolean),
|
|
1512
|
+
typeOptions: Schema4.optionalKey(Schema4.Struct({
|
|
1513
|
+
trueLabel: Schema4.optionalKey(Schema4.String),
|
|
1514
|
+
falseLabel: Schema4.optionalKey(Schema4.String),
|
|
1515
|
+
exportFormat: Schema4.optionalKey(Schema4.Literals(["raw", "formatted"]))
|
|
1516
|
+
}).annotate({ identifier: "DataTableBooleanFormat" }))
|
|
1517
|
+
}),
|
|
1518
|
+
Schema4.Struct({
|
|
1519
|
+
...column,
|
|
1520
|
+
type: Schema4.Literal("list"),
|
|
1521
|
+
filterOptions: Schema4.optionalKey(Schema4.Array(DataTableItemSchema)),
|
|
1522
|
+
options: Schema4.optionalKey(Schema4.Array(DataTableItemSchema)),
|
|
1523
|
+
allowRemove: Schema4.optionalKey(Schema4.Boolean),
|
|
1524
|
+
itemActions: Schema4.optionalKey(Schema4.Array(DataTableActionSchema)),
|
|
1525
|
+
display: Schema4.optionalKey(Schema4.Literals(["list", "icon"])),
|
|
1526
|
+
visibleCount: Schema4.optionalKey(Schema4.Int.check(Schema4.isGreaterThanOrEqualTo(0))),
|
|
1527
|
+
actionsLabel: Schema4.optionalKey(Schema4.String),
|
|
1528
|
+
manageLabel: Schema4.optionalKey(Schema4.String)
|
|
1529
|
+
})
|
|
1530
|
+
]).annotate({ identifier: "DataTableField" });
|
|
1531
|
+
var DataTableColumnSchema = DataTableFieldSchema.mapMembers(Tuple.map(Schema4.fieldsAssign({
|
|
1532
|
+
fields: Schema4.optionalKey(Schema4.Array(DataTableFieldSchema))
|
|
1533
|
+
}))).annotate({ identifier: "DataTableColumn" });
|
|
1534
|
+
var DataTableLabelsSchema = Schema4.Struct({
|
|
1535
|
+
actions: Schema4.optionalKey(Schema4.String),
|
|
1536
|
+
addItem: Schema4.optionalKey(Schema4.String),
|
|
1537
|
+
listDetails: Schema4.optionalKey(Schema4.String),
|
|
1538
|
+
empty: Schema4.optionalKey(Schema4.String),
|
|
1539
|
+
filters: Schema4.optionalKey(Schema4.String),
|
|
1540
|
+
filtersClear: Schema4.optionalKey(Schema4.String),
|
|
1541
|
+
filterColumn: Schema4.optionalKey(Schema4.String),
|
|
1542
|
+
filterClear: Schema4.optionalKey(Schema4.String),
|
|
1543
|
+
filterApply: Schema4.optionalKey(Schema4.String),
|
|
1544
|
+
filterValue: Schema4.optionalKey(Schema4.String),
|
|
1545
|
+
filterOperator: Schema4.optionalKey(Schema4.String),
|
|
1546
|
+
filterContains: Schema4.optionalKey(Schema4.String),
|
|
1547
|
+
filterEquals: Schema4.optionalKey(Schema4.String),
|
|
1548
|
+
filterStartsWith: Schema4.optionalKey(Schema4.String),
|
|
1549
|
+
filterEndsWith: Schema4.optionalKey(Schema4.String),
|
|
1550
|
+
filterMin: Schema4.optionalKey(Schema4.String),
|
|
1551
|
+
filterMax: Schema4.optionalKey(Schema4.String),
|
|
1552
|
+
filterFrom: Schema4.optionalKey(Schema4.String),
|
|
1553
|
+
filterTo: Schema4.optionalKey(Schema4.String),
|
|
1554
|
+
filterTrue: Schema4.optionalKey(Schema4.String),
|
|
1555
|
+
filterFalse: Schema4.optionalKey(Schema4.String),
|
|
1556
|
+
filterInvalid: Schema4.optionalKey(Schema4.String),
|
|
1557
|
+
columns: Schema4.optionalKey(Schema4.String),
|
|
1558
|
+
sortBy: Schema4.optionalKey(Schema4.String),
|
|
1559
|
+
hideColumn: Schema4.optionalKey(Schema4.String),
|
|
1560
|
+
loading: Schema4.optionalKey(Schema4.String),
|
|
1561
|
+
removeItem: Schema4.optionalKey(Schema4.String),
|
|
1562
|
+
search: Schema4.optionalKey(Schema4.String),
|
|
1563
|
+
selectAllRows: Schema4.optionalKey(Schema4.String),
|
|
1564
|
+
selectRow: Schema4.optionalKey(Schema4.String),
|
|
1565
|
+
selected: Schema4.optionalKey(Schema4.String),
|
|
1566
|
+
sortAsc: Schema4.optionalKey(Schema4.String),
|
|
1567
|
+
sortDesc: Schema4.optionalKey(Schema4.String),
|
|
1568
|
+
sortClear: Schema4.optionalKey(Schema4.String),
|
|
1569
|
+
view: Schema4.optionalKey(Schema4.String),
|
|
1570
|
+
tableView: Schema4.optionalKey(Schema4.String),
|
|
1571
|
+
galleryView: Schema4.optionalKey(Schema4.String),
|
|
1572
|
+
groupBy: Schema4.optionalKey(Schema4.String),
|
|
1573
|
+
export: Schema4.optionalKey(Schema4.String),
|
|
1574
|
+
exportFailed: Schema4.optionalKey(Schema4.String),
|
|
1575
|
+
moveUp: Schema4.optionalKey(Schema4.String),
|
|
1576
|
+
moveDown: Schema4.optionalKey(Schema4.String),
|
|
1577
|
+
reorder: Schema4.optionalKey(Schema4.String),
|
|
1578
|
+
refresh: Schema4.optionalKey(Schema4.String),
|
|
1579
|
+
resize: Schema4.optionalKey(Schema4.String)
|
|
1580
|
+
}).annotate({ identifier: "DataTableLabels" });
|
|
1581
|
+
var DataTableViewSchema = Schema4.Literals(["table", "gallery"]);
|
|
1582
|
+
var DataTablePreferencesSchema = Schema4.Struct({
|
|
1583
|
+
columnVisibility: Schema4.Record(Schema4.String, Schema4.Boolean),
|
|
1584
|
+
columnSizing: Schema4.Record(Schema4.String, Schema4.Finite),
|
|
1585
|
+
grouping: Schema4.optionalKey(Schema4.Array(Schema4.String)),
|
|
1586
|
+
view: DataTableViewSchema
|
|
1587
|
+
}).annotate({ identifier: "DataTablePersistedUiState" });
|
|
1588
|
+
var GroupField = Schema4.Struct({
|
|
1589
|
+
id: Schema4.NonEmptyString,
|
|
1590
|
+
label: Schema4.String,
|
|
1591
|
+
actionsLabel: Schema4.optionalKey(Schema4.String),
|
|
1592
|
+
groups: Schema4.optionalKey(Schema4.Array(Schema4.Struct({
|
|
1593
|
+
id: Schema4.String,
|
|
1594
|
+
label: Schema4.String,
|
|
1595
|
+
empty: Schema4.optionalKey(Schema4.String)
|
|
1596
|
+
}).annotate({ identifier: "DataTableGroupLabel" }))),
|
|
1597
|
+
actions: Schema4.optionalKey(Schema4.Array(DataTableActionSchema)),
|
|
1598
|
+
movable: Schema4.optionalKey(Schema4.Boolean)
|
|
1599
|
+
}).annotate({ identifier: "DataTableGroupField" });
|
|
1600
|
+
var DataTablePropsSchema = Schema4.Struct({
|
|
1601
|
+
...DataTableCommonPropsSchema.fields,
|
|
1602
|
+
label: Schema4.String,
|
|
1603
|
+
rowData: Schema4.Array(DataTableRowSchema),
|
|
1604
|
+
rowActivation: Schema4.optionalKey(Schema4.Boolean),
|
|
1605
|
+
columnDefs: Schema4.Array(DataTableColumnSchema),
|
|
1606
|
+
status: Schema4.optionalKey(Schema4.Struct({
|
|
1607
|
+
loading: Schema4.optionalKey(Schema4.Boolean),
|
|
1608
|
+
empty: Schema4.optionalKey(Schema4.String),
|
|
1609
|
+
error: Schema4.optionalKey(Schema4.String)
|
|
1610
|
+
})),
|
|
1611
|
+
sort: Schema4.optionalKey(Schema4.Array(DataTableSortSchema)),
|
|
1612
|
+
sortMode: Schema4.optionalKey(Schema4.Literals(["client", "server"])),
|
|
1613
|
+
search: Schema4.optionalKey(Schema4.Boolean),
|
|
1614
|
+
columnFilters: Schema4.optionalKey(Schema4.Boolean),
|
|
1615
|
+
state: Schema4.optionalKey(DataTableQuerySchema),
|
|
1616
|
+
features: Schema4.optionalKey(Schema4.Struct({
|
|
1617
|
+
...DataTableCommonFeaturesSchema.fields,
|
|
1618
|
+
pagination: Schema4.optionalKey(Schema4.Union([Schema4.Literal(false), PaginationSchema])),
|
|
1619
|
+
grouping: Schema4.optionalKey(Schema4.Struct({
|
|
1620
|
+
initial: Schema4.optionalKey(Schema4.Array(Schema4.String)),
|
|
1621
|
+
fields: Schema4.Array(GroupField)
|
|
1622
|
+
}).annotate({ identifier: "DataTableGrouping" })),
|
|
1623
|
+
gallery: Schema4.optionalKey(Schema4.Struct({
|
|
1624
|
+
name: Schema4.String,
|
|
1625
|
+
description: Schema4.optionalKey(Schema4.String),
|
|
1626
|
+
image: Schema4.optionalKey(Schema4.String),
|
|
1627
|
+
tags: Schema4.optionalKey(Schema4.Array(Schema4.String))
|
|
1628
|
+
}).annotate({ identifier: "DataTableGallery" })),
|
|
1629
|
+
reordering: Schema4.optionalKey(Schema4.Boolean),
|
|
1630
|
+
export: Schema4.optionalKey(Schema4.Struct({
|
|
1631
|
+
baseName: Schema4.String,
|
|
1632
|
+
scope: Schema4.optionalKey(Schema4.Literals(["filteredRows", "currentPage"])),
|
|
1633
|
+
builtIn: Schema4.optionalKey(Schema4.Boolean),
|
|
1634
|
+
actions: Schema4.optionalKey(Schema4.Array(DataTableActionSchema)),
|
|
1635
|
+
pending: Schema4.optionalKey(Schema4.Boolean),
|
|
1636
|
+
failed: Schema4.optionalKey(Schema4.Boolean)
|
|
1637
|
+
}).annotate({ identifier: "DataTableExport" })),
|
|
1638
|
+
refresh: Schema4.optionalKey(Schema4.Boolean),
|
|
1639
|
+
virtualization: Schema4.optionalKey(Schema4.Union([
|
|
1640
|
+
Schema4.Boolean,
|
|
1641
|
+
Schema4.Struct({
|
|
1642
|
+
scroll: Schema4.optionalKey(Schema4.Literals(["table", "internal", "page"])),
|
|
1643
|
+
height: Schema4.optionalKey(Schema4.Int.check(Schema4.isGreaterThan(0))),
|
|
1644
|
+
estimateRowHeight: Schema4.optionalKey(Schema4.Int.check(Schema4.isGreaterThan(0))),
|
|
1645
|
+
overscan: Schema4.optionalKey(Schema4.Int.check(Schema4.isGreaterThanOrEqualTo(0)))
|
|
1646
|
+
}).annotate({ identifier: "DataTableVirtualization" })
|
|
1647
|
+
]))
|
|
1648
|
+
}).annotate({ identifier: "DataTableHtmlFeatures" })),
|
|
1649
|
+
initialState: Schema4.optionalKey(Schema4.Struct({
|
|
1650
|
+
...queryFields,
|
|
1651
|
+
page: Schema4.optional(queryFields.page),
|
|
1652
|
+
pageSize: Schema4.optional(queryFields.pageSize),
|
|
1653
|
+
columnVisibility: Schema4.optionalKey(Schema4.Record(Schema4.String, Schema4.Boolean)),
|
|
1654
|
+
view: Schema4.optionalKey(DataTableViewSchema)
|
|
1655
|
+
}).annotate({ identifier: "DataTableInitialQuery" })),
|
|
1656
|
+
pagination: Schema4.optionalKey(PaginationSchema),
|
|
1657
|
+
selection: Schema4.optionalKey(Schema4.Struct({
|
|
1658
|
+
selectedRowIds: Schema4.optionalKey(Schema4.Array(Schema4.String)),
|
|
1659
|
+
bulkActionsLabel: Schema4.optionalKey(Schema4.String),
|
|
1660
|
+
bulkActions: Schema4.optionalKey(Schema4.Array(DataTableActionSchema))
|
|
1661
|
+
})),
|
|
1662
|
+
messages: Schema4.optionalKey(Schema4.Record(Schema4.String, DataTableLabelsSchema))
|
|
1663
|
+
}).annotate({ identifier: "DataTableProps" });
|
|
1664
|
+
var DataTableFilterDraftSchema = Schema4.Struct({
|
|
1665
|
+
id: Schema4.String,
|
|
1666
|
+
primary: Schema4.String,
|
|
1667
|
+
secondary: Schema4.String,
|
|
1668
|
+
operator: TextFilterOperator,
|
|
1669
|
+
values: Schema4.Array(Schema4.String)
|
|
1670
|
+
}).annotate({ identifier: "DataTableFilterDraft" });
|
|
1671
|
+
|
|
1672
|
+
// ../../src/components/data-table/index.ts
|
|
1673
|
+
var defaultMessages = {
|
|
1674
|
+
en: {
|
|
1675
|
+
actions: "Actions",
|
|
1676
|
+
addItem: "Add item...",
|
|
1677
|
+
listDetails: "View all items",
|
|
1678
|
+
empty: "No results.",
|
|
1679
|
+
filters: "Filters",
|
|
1680
|
+
filtersClear: "Clear all filters",
|
|
1681
|
+
filterColumn: "Column",
|
|
1682
|
+
filterClear: "Clear filter",
|
|
1683
|
+
filterApply: "Apply filter",
|
|
1684
|
+
filterValue: "Value",
|
|
1685
|
+
filterOperator: "Operator",
|
|
1686
|
+
filterContains: "Contains",
|
|
1687
|
+
filterEquals: "Equals",
|
|
1688
|
+
filterStartsWith: "Starts with",
|
|
1689
|
+
filterEndsWith: "Ends with",
|
|
1690
|
+
filterMin: "Minimum",
|
|
1691
|
+
filterMax: "Maximum",
|
|
1692
|
+
filterFrom: "From (UTC)",
|
|
1693
|
+
filterTo: "To (UTC)",
|
|
1694
|
+
filterTrue: "True",
|
|
1695
|
+
filterFalse: "False",
|
|
1696
|
+
filterInvalid: "Enter a valid filter. Ranges must be in ascending order.",
|
|
1697
|
+
columns: "Columns",
|
|
1698
|
+
sortBy: "Sort by",
|
|
1699
|
+
hideColumn: "Hide column",
|
|
1700
|
+
loading: "Loading...",
|
|
1701
|
+
removeItem: "Remove",
|
|
1702
|
+
search: "Search",
|
|
1703
|
+
selectAllRows: "Select all rows on this page",
|
|
1704
|
+
selectRow: "Select row",
|
|
1705
|
+
selected: "Selected",
|
|
1706
|
+
sortAsc: "Ascending",
|
|
1707
|
+
sortDesc: "Descending",
|
|
1708
|
+
sortClear: "Clear sorting",
|
|
1709
|
+
view: "View",
|
|
1710
|
+
tableView: "Table",
|
|
1711
|
+
galleryView: "Gallery",
|
|
1712
|
+
groupBy: "Group by",
|
|
1713
|
+
export: "Export",
|
|
1714
|
+
exportFailed: "Export failed. Please try again.",
|
|
1715
|
+
refresh: "Refresh",
|
|
1716
|
+
moveUp: "Move up",
|
|
1717
|
+
moveDown: "Move down",
|
|
1718
|
+
reorder: "Drag to reorder",
|
|
1719
|
+
resize: "Resize column"
|
|
1720
|
+
},
|
|
1721
|
+
fr: {
|
|
1722
|
+
actions: "Actions",
|
|
1723
|
+
addItem: "Ajouter un élément...",
|
|
1724
|
+
listDetails: "Afficher tous les éléments",
|
|
1725
|
+
empty: "Aucun résultat.",
|
|
1726
|
+
filters: "Filtres",
|
|
1727
|
+
filtersClear: "Effacer tous les filtres",
|
|
1728
|
+
filterColumn: "Colonne",
|
|
1729
|
+
filterClear: "Effacer le filtre",
|
|
1730
|
+
filterApply: "Appliquer le filtre",
|
|
1731
|
+
filterValue: "Valeur",
|
|
1732
|
+
filterOperator: "Opérateur",
|
|
1733
|
+
filterContains: "Contient",
|
|
1734
|
+
filterEquals: "Égal à",
|
|
1735
|
+
filterStartsWith: "Commence par",
|
|
1736
|
+
filterEndsWith: "Se termine par",
|
|
1737
|
+
filterMin: "Minimum",
|
|
1738
|
+
filterMax: "Maximum",
|
|
1739
|
+
filterFrom: "Du (UTC)",
|
|
1740
|
+
filterTo: "Au (UTC)",
|
|
1741
|
+
filterTrue: "Vrai",
|
|
1742
|
+
filterFalse: "Faux",
|
|
1743
|
+
filterInvalid: "Saisissez un filtre valide. Les bornes doivent être dans l’ordre croissant.",
|
|
1744
|
+
columns: "Colonnes",
|
|
1745
|
+
sortBy: "Trier par",
|
|
1746
|
+
hideColumn: "Masquer la colonne",
|
|
1747
|
+
loading: "Chargement...",
|
|
1748
|
+
removeItem: "Retirer",
|
|
1749
|
+
search: "Rechercher",
|
|
1750
|
+
selectAllRows: "Sélectionner toutes les lignes de cette page",
|
|
1751
|
+
selectRow: "Sélectionner la ligne",
|
|
1752
|
+
selected: "Sélectionnés",
|
|
1753
|
+
sortAsc: "Croissant",
|
|
1754
|
+
sortDesc: "Décroissant",
|
|
1755
|
+
sortClear: "Effacer le tri",
|
|
1756
|
+
view: "Affichage",
|
|
1757
|
+
tableView: "Tableau",
|
|
1758
|
+
galleryView: "Galerie",
|
|
1759
|
+
groupBy: "Grouper par",
|
|
1760
|
+
export: "Exporter",
|
|
1761
|
+
exportFailed: "L’exportation a échoué. Veuillez réessayer.",
|
|
1762
|
+
refresh: "Rafraîchir",
|
|
1763
|
+
moveUp: "Déplacer vers le haut",
|
|
1764
|
+
moveDown: "Déplacer vers le bas",
|
|
1765
|
+
reorder: "Glisser pour réorganiser",
|
|
1766
|
+
resize: "Redimensionner la colonne"
|
|
1767
|
+
}
|
|
1768
|
+
};
|
|
1769
|
+
var compareTableText = (left, right, locale) => left.localeCompare(right, locale, { numeric: true, sensitivity: "base" });
|
|
1770
|
+
var isTableText = Schema5.is(Schema5.String);
|
|
1771
|
+
var isTableNumber = Schema5.is(Schema5.Finite);
|
|
1772
|
+
var isTableBoolean = Schema5.is(Schema5.Boolean);
|
|
1773
|
+
var isTableReference = Schema5.is(DataTableReferenceSchema);
|
|
1774
|
+
var isTableList = Schema5.is(Schema5.Array(DataTableItemSchema));
|
|
1775
|
+
var tableInitials = (label) => label.trim().split(/\s+/).slice(0, 2).map((word) => word.slice(0, 1)).join("").toLocaleUpperCase();
|
|
1776
|
+
var formatNumberValue = (value, options, defaultLocale = "en") => {
|
|
1777
|
+
const { locale, ...format } = options ?? {};
|
|
1778
|
+
return new Intl.NumberFormat(locale ?? defaultLocale, format).format(value);
|
|
1779
|
+
};
|
|
1780
|
+
var tableBooleanLabel = (value, options) => (value ? options?.trueLabel : options?.falseLabel) ?? String(value);
|
|
1781
|
+
var decodeDateInput = Schema5.decodeUnknownOption(DataTableDateInputSchema);
|
|
1782
|
+
var resolveDate = (value, type) => Option3.getOrUndefined(Option3.flatMap(decodeDateInput(value), (input) => {
|
|
1783
|
+
const calendarOnly = isCalendarDate(input);
|
|
1784
|
+
if (calendarOnly && type === "dateTime")
|
|
1785
|
+
return Option3.none();
|
|
1786
|
+
return Option3.map(DateTime3.make(input), (instant) => ({
|
|
1787
|
+
instant,
|
|
1788
|
+
calendarOnly
|
|
1789
|
+
}));
|
|
1790
|
+
}));
|
|
1791
|
+
var formatDateValue = (date, column, locale = "en") => DateTime3.format(date.instant, {
|
|
1792
|
+
locale: column.typeOptions?.locale ?? locale,
|
|
1793
|
+
timeZone: date.calendarOnly ? "UTC" : column.typeOptions?.timeZone ?? "UTC",
|
|
1794
|
+
dateStyle: column.typeOptions?.dateStyle ?? "medium",
|
|
1795
|
+
timeStyle: column.type === "dateTime" ? column.typeOptions?.timeStyle ?? "short" : undefined,
|
|
1796
|
+
hour12: column.type === "dateTime" ? column.typeOptions?.hour12 : undefined
|
|
1797
|
+
});
|
|
1798
|
+
var dateIsoValue = (date) => date.calendarOnly ? DateTime3.formatIsoDateUtc(date.instant) : DateTime3.formatIso(date.instant);
|
|
1799
|
+
var matchesDateFilter = (date, filter) => {
|
|
1800
|
+
if (!date)
|
|
1801
|
+
return false;
|
|
1802
|
+
const day = DateTime3.formatIsoDateUtc(date.instant);
|
|
1803
|
+
return (filter.from === undefined || day >= filter.from) && (filter.to === undefined || day <= filter.to);
|
|
1804
|
+
};
|
|
1805
|
+
var matchesFilterText = (value, filter) => {
|
|
1806
|
+
const text = value.toLocaleLowerCase();
|
|
1807
|
+
const query = filter.value.toLocaleLowerCase();
|
|
1808
|
+
switch (filter.operator) {
|
|
1809
|
+
case "contains":
|
|
1810
|
+
return text.includes(query);
|
|
1811
|
+
case "equals":
|
|
1812
|
+
return text === query;
|
|
1813
|
+
case "startsWith":
|
|
1814
|
+
return text.startsWith(query);
|
|
1815
|
+
case "endsWith":
|
|
1816
|
+
return text.endsWith(query);
|
|
1817
|
+
}
|
|
1818
|
+
};
|
|
1819
|
+
var tableFilterKind = (column, hasOptions = false) => hasOptions || column.type === "list" ? "values" : column.type === "reference" ? "text" : column.type === "dateTime" ? "date" : column.type ?? "text";
|
|
1820
|
+
var matchesTableFilter = (filter, value, type, text, values) => {
|
|
1821
|
+
switch (filter.kind) {
|
|
1822
|
+
case "text":
|
|
1823
|
+
return matchesFilterText(text(), filter);
|
|
1824
|
+
case "number":
|
|
1825
|
+
return isTableNumber(value) && (filter.min === undefined || value >= filter.min) && (filter.max === undefined || value <= filter.max);
|
|
1826
|
+
case "boolean":
|
|
1827
|
+
return value === filter.value;
|
|
1828
|
+
case "values":
|
|
1829
|
+
return values().some((value) => filter.values.includes(value));
|
|
1830
|
+
case "date":
|
|
1831
|
+
return matchesDateFilter(resolveDate(value, type === "dateTime" ? "dateTime" : "date"), filter);
|
|
1832
|
+
}
|
|
1833
|
+
};
|
|
1834
|
+
var tableDataColumns = (columns) => columns.flatMap((column) => column.fields?.length ? column.fields.map((field) => ({
|
|
1835
|
+
...field,
|
|
1836
|
+
id: `${column.id}.${field.id}`,
|
|
1837
|
+
headerName: `${column.headerName} / ${field.headerName}`,
|
|
1838
|
+
sortable: column.sortable === false ? false : field.sortable,
|
|
1839
|
+
searchable: column.searchable === false ? false : field.searchable,
|
|
1840
|
+
filterable: column.filterable === false ? false : field.filterable,
|
|
1841
|
+
export: column.export === false ? false : field.export
|
|
1842
|
+
})) : [column]);
|
|
1843
|
+
var filterTableColumns = (rows, columns, filters) => {
|
|
1844
|
+
const byId = new Map(columns.filter(({ filterable }) => filterable !== false).map((column) => [column.id, column]));
|
|
1845
|
+
const active = filters.filter((filter) => {
|
|
1846
|
+
const column = byId.get(filter.id);
|
|
1847
|
+
return column && tableFilterKind(column) === filter.kind;
|
|
1848
|
+
});
|
|
1849
|
+
if (!active.length)
|
|
1850
|
+
return rows;
|
|
1851
|
+
return rows.filter((row) => active.every((filter) => {
|
|
1852
|
+
const value = row.cells[filter.id];
|
|
1853
|
+
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) : []);
|
|
1854
|
+
}));
|
|
1855
|
+
};
|
|
1856
|
+
var columnValue = (column, value) => {
|
|
1857
|
+
switch (column.type) {
|
|
1858
|
+
case "text":
|
|
1859
|
+
return isTableText(value) ? value : null;
|
|
1860
|
+
case "number":
|
|
1861
|
+
case "boolean":
|
|
1862
|
+
case "date":
|
|
1863
|
+
case "dateTime":
|
|
1864
|
+
return tableSortScalar(column.type, value);
|
|
1865
|
+
case "reference":
|
|
1866
|
+
return isTableReference(value) ? value.label : null;
|
|
1867
|
+
case "list":
|
|
1868
|
+
return isTableList(value) ? value.map(({ label }) => label).join(", ") : null;
|
|
1869
|
+
}
|
|
1870
|
+
};
|
|
1871
|
+
var tableSortScalar = (type, value) => {
|
|
1872
|
+
if (type === "number")
|
|
1873
|
+
return isTableNumber(value) ? value : null;
|
|
1874
|
+
if (type === "boolean")
|
|
1875
|
+
return isTableBoolean(value) ? Number(value) : null;
|
|
1876
|
+
const date = resolveDate(value, type);
|
|
1877
|
+
return date ? DateTime3.toEpochMillis(date.instant) : null;
|
|
1878
|
+
};
|
|
1879
|
+
var compareTableSortValues = (left, right, direction, nulls, locale) => {
|
|
1880
|
+
if (left === right)
|
|
1881
|
+
return 0;
|
|
1882
|
+
const nullOrder = nulls === "first" ? -1 : 1;
|
|
1883
|
+
if (left === null)
|
|
1884
|
+
return nullOrder;
|
|
1885
|
+
if (right === null)
|
|
1886
|
+
return -nullOrder;
|
|
1887
|
+
const comparison = isTableNumber(left) && isTableNumber(right) ? left - right : compareTableText(String(left), String(right), locale);
|
|
1888
|
+
return direction === "asc" ? comparison : -comparison;
|
|
1889
|
+
};
|
|
1890
|
+
var sortTableRows = (rows, columns, sort, locale) => {
|
|
1891
|
+
const byId = new Map(columns.map((column) => [column.id, column]));
|
|
1892
|
+
return rows.slice().sort((leftRow, rightRow) => {
|
|
1893
|
+
for (const { id, direction } of sort) {
|
|
1894
|
+
const column = byId.get(id);
|
|
1895
|
+
if (!column || column.sortable === false)
|
|
1896
|
+
continue;
|
|
1897
|
+
const left = columnValue(column, leftRow.cells[id]);
|
|
1898
|
+
const right = columnValue(column, rightRow.cells[id]);
|
|
1899
|
+
const comparison = compareTableSortValues(left, right, direction, column.nulls, locale);
|
|
1900
|
+
if (comparison !== 0)
|
|
1901
|
+
return comparison;
|
|
1902
|
+
}
|
|
1903
|
+
return 0;
|
|
1904
|
+
});
|
|
1905
|
+
};
|
|
1906
|
+
var filterTableRows = (rows, columns, search, locale) => {
|
|
1907
|
+
const query = search.trim().toLocaleLowerCase(locale);
|
|
1908
|
+
if (!query)
|
|
1909
|
+
return rows;
|
|
1910
|
+
const searchable = columns.filter(({ searchable }) => searchable !== false);
|
|
1911
|
+
return rows.filter((row) => searchable.some((column) => {
|
|
1912
|
+
const value = row.cells[column.id];
|
|
1913
|
+
if (column.type === "date" || column.type === "dateTime") {
|
|
1914
|
+
const date = resolveDate(value, column.type);
|
|
1915
|
+
return !!date && `${formatDateValue(date, column, locale)} ${dateIsoValue(date)}`.toLocaleLowerCase(locale).includes(query);
|
|
1916
|
+
}
|
|
1917
|
+
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) ?? "");
|
|
1918
|
+
return text.toLocaleLowerCase(locale).includes(query);
|
|
1919
|
+
}));
|
|
1920
|
+
};
|
|
1921
|
+
var updateSelectedRows = (selected, targets, checked) => {
|
|
1922
|
+
const next = new Set(selected);
|
|
1923
|
+
for (const id of targets) {
|
|
1924
|
+
if (checked)
|
|
1925
|
+
next.add(id);
|
|
1926
|
+
else
|
|
1927
|
+
next.delete(id);
|
|
1928
|
+
}
|
|
1929
|
+
return Array.from(next);
|
|
1930
|
+
};
|
|
1931
|
+
var resolveTablePage = (rowCount, query) => {
|
|
1932
|
+
const pageSize = Math.max(1, query.pageSize);
|
|
1933
|
+
const pageCount = Math.max(1, Math.ceil(rowCount / pageSize));
|
|
1934
|
+
const page = Math.min(pageCount - 1, Math.max(0, query.page));
|
|
1935
|
+
const start = page * pageSize;
|
|
1936
|
+
return { page, pageCount, start, end: start + pageSize };
|
|
1937
|
+
};
|
|
1938
|
+
var edit = UiSchema2.TaggedEnum({
|
|
1939
|
+
SetBoolean: { value: Schema5.Boolean },
|
|
1940
|
+
AddItem: { itemId: Schema5.String },
|
|
1941
|
+
RemoveItem: { itemId: Schema5.String }
|
|
1942
|
+
}).annotate({ identifier: "DataTableEdit" });
|
|
1943
|
+
var eventFields = {
|
|
1944
|
+
RowActivated: { rowId: Schema5.String },
|
|
1945
|
+
ItemActionRequested: {
|
|
1946
|
+
rowId: Schema5.String,
|
|
1947
|
+
columnId: Schema5.String,
|
|
1948
|
+
itemId: Schema5.String,
|
|
1949
|
+
actionId: Schema5.String
|
|
1950
|
+
},
|
|
1951
|
+
RefreshRequested: {},
|
|
1952
|
+
ExportRequested: { actionId: Schema5.String },
|
|
1953
|
+
GroupActionRequested: {
|
|
1954
|
+
fieldId: Schema5.String,
|
|
1955
|
+
groupId: Schema5.String,
|
|
1956
|
+
actionId: Schema5.String
|
|
1957
|
+
},
|
|
1958
|
+
GroupMoveRequested: {
|
|
1959
|
+
rowId: Schema5.String,
|
|
1960
|
+
fieldId: Schema5.String,
|
|
1961
|
+
groupId: Schema5.String
|
|
1962
|
+
},
|
|
1963
|
+
RowsReordered: { rowIds: Schema5.Array(Schema5.String) },
|
|
1964
|
+
StateChanged: { state: DataTableQuerySchema },
|
|
1965
|
+
SortChanged: { sort: Schema5.Array(DataTableSortSchema) },
|
|
1966
|
+
SelectionChanged: { selectedRowIds: Schema5.Array(Schema5.String) },
|
|
1967
|
+
CellEditRequested: { rowId: Schema5.String, columnId: Schema5.String, edit },
|
|
1968
|
+
RowActionRequested: { rowId: Schema5.String, actionId: Schema5.String },
|
|
1969
|
+
BulkActionRequested: {
|
|
1970
|
+
rowIds: Schema5.Array(Schema5.String),
|
|
1971
|
+
actionId: Schema5.String
|
|
1972
|
+
}
|
|
1973
|
+
};
|
|
1974
|
+
var DataTableEvents = UiSchema2.TaggedEnum(eventFields).annotate({
|
|
1975
|
+
identifier: "DataTableEvents"
|
|
1976
|
+
});
|
|
1977
|
+
var DataTableMessage = UiSchema2.TaggedEnum({
|
|
1978
|
+
ReferenceImageFailed: { src: Schema5.String },
|
|
1979
|
+
RowActivated: eventFields.RowActivated,
|
|
1980
|
+
PreferencesLoaded: { preferences: Schema5.NullOr(DataTablePreferencesSchema) },
|
|
1981
|
+
ItemActionRequested: eventFields.ItemActionRequested,
|
|
1982
|
+
BuiltInExportRequested: {
|
|
1983
|
+
format: Schema5.Literals(["csv", "json"]),
|
|
1984
|
+
locale: Schema5.optionalKey(Schema5.String)
|
|
1985
|
+
},
|
|
1986
|
+
ExportStarted: {},
|
|
1987
|
+
ExportFinished: { failed: Schema5.Boolean },
|
|
1988
|
+
RefreshRequested: {},
|
|
1989
|
+
ExportRequested: eventFields.ExportRequested,
|
|
1990
|
+
GroupActionRequested: eventFields.GroupActionRequested,
|
|
1991
|
+
GroupMoveRequested: eventFields.GroupMoveRequested,
|
|
1992
|
+
ReorderRequested: {
|
|
1993
|
+
rowId: Schema5.String,
|
|
1994
|
+
targetId: Schema5.String,
|
|
1995
|
+
after: Schema5.Boolean
|
|
1996
|
+
},
|
|
1997
|
+
DragStarted: { rowId: Schema5.String },
|
|
1998
|
+
DragEnded: {},
|
|
1999
|
+
DragDropped: { targetId: Schema5.String },
|
|
2000
|
+
GroupDropped: { fieldId: Schema5.String, groupId: Schema5.String },
|
|
2001
|
+
ViewPicked: { view: DataTableViewSchema },
|
|
2002
|
+
GroupingToggled: { fieldId: Schema5.String },
|
|
2003
|
+
GroupToggled: { key: Schema5.String },
|
|
2004
|
+
ColumnResized: { id: Schema5.String, delta: Schema5.Finite },
|
|
2005
|
+
ColumnResizeReset: { id: Schema5.String },
|
|
2006
|
+
ResizeStarted: { id: Schema5.String, x: Schema5.Finite, pointerId: Schema5.Int },
|
|
2007
|
+
ResizeMoved: { x: Schema5.Finite, pointerId: Schema5.Int },
|
|
2008
|
+
ResizeEnded: { pointerId: Schema5.Int },
|
|
2009
|
+
ColumnFiltersCleared: { id: Schema5.String },
|
|
2010
|
+
ColumnSortCleared: { id: Schema5.String },
|
|
2011
|
+
CellEditRequested: eventFields.CellEditRequested,
|
|
2012
|
+
RowActionRequested: eventFields.RowActionRequested,
|
|
2013
|
+
MenuOpened: { key: Schema5.String },
|
|
2014
|
+
MenuClosed: { key: Schema5.String },
|
|
2015
|
+
MenuQueryChanged: { key: Schema5.String, query: Schema5.String },
|
|
2016
|
+
SubmenuOpened: {
|
|
2017
|
+
key: Schema5.String,
|
|
2018
|
+
filterColumnId: Schema5.optionalKey(Schema5.String)
|
|
2019
|
+
},
|
|
2020
|
+
SubmenuClosed: { key: Schema5.String },
|
|
2021
|
+
SearchChanged: { value: Schema5.String },
|
|
2022
|
+
FilterInputChanged: {
|
|
2023
|
+
field: Schema5.Literals(["primary", "secondary"]),
|
|
2024
|
+
value: Schema5.String
|
|
2025
|
+
},
|
|
2026
|
+
FilterOperatorChanged: { operator: TextFilterOperator },
|
|
2027
|
+
FilterValueToggled: { value: Schema5.String, checked: Schema5.Boolean },
|
|
2028
|
+
FilterApplied: {},
|
|
2029
|
+
ColumnFilterChanged: {
|
|
2030
|
+
id: Schema5.String,
|
|
2031
|
+
filter: Schema5.NullOr(ColumnFilter)
|
|
2032
|
+
},
|
|
2033
|
+
FilterCleared: {},
|
|
2034
|
+
FiltersCleared: {},
|
|
2035
|
+
PageRequested: { page: Schema5.Int },
|
|
2036
|
+
ServerPageInvalidated: {},
|
|
2037
|
+
PageSizeRequested: { pageSize: Schema5.Int },
|
|
2038
|
+
SortRequested: {
|
|
2039
|
+
columnId: Schema5.String,
|
|
2040
|
+
direction: Schema5.NullOr(DataTableSortSchema.fields.direction)
|
|
2041
|
+
},
|
|
2042
|
+
ColumnVisibilityChanged: { id: Schema5.String, visible: Schema5.Boolean },
|
|
2043
|
+
SelectionRequested: {
|
|
2044
|
+
rowIds: Schema5.Array(Schema5.String),
|
|
2045
|
+
checked: Schema5.Boolean
|
|
2046
|
+
},
|
|
2047
|
+
BulkActionRequested: { actionId: Schema5.String }
|
|
2048
|
+
}).annotate({ identifier: "DataTableMessage" });
|
|
2049
|
+
var dataTableOptions = {
|
|
2050
|
+
name: "DataTable",
|
|
2051
|
+
props: DataTablePropsSchema,
|
|
2052
|
+
model: Schema5.Struct({
|
|
2053
|
+
menu: Schema5.NullOr(Schema5.String),
|
|
2054
|
+
submenu: Schema5.NullOr(Schema5.String),
|
|
2055
|
+
menuQuery: Schema5.String,
|
|
2056
|
+
failedImages: Schema5.Array(Schema5.String),
|
|
2057
|
+
selectedRowIds: Schema5.Array(Schema5.String),
|
|
2058
|
+
query: DataTableQuerySchema,
|
|
2059
|
+
preferencesLoaded: Schema5.Boolean,
|
|
2060
|
+
columnVisibility: Schema5.Record(Schema5.String, Schema5.Boolean),
|
|
2061
|
+
columnSizing: Schema5.Record(Schema5.String, Schema5.Finite),
|
|
2062
|
+
view: DataTableViewSchema,
|
|
2063
|
+
grouping: Schema5.Array(Schema5.String),
|
|
2064
|
+
collapsedGroups: Schema5.Record(Schema5.String, Schema5.Boolean),
|
|
2065
|
+
dragging: Schema5.NullOr(Schema5.String),
|
|
2066
|
+
exporting: Schema5.Boolean,
|
|
2067
|
+
exportFailed: Schema5.Boolean,
|
|
2068
|
+
resizing: Schema5.NullOr(Schema5.Struct({
|
|
2069
|
+
id: Schema5.String,
|
|
2070
|
+
x: Schema5.Finite,
|
|
2071
|
+
width: Schema5.Finite,
|
|
2072
|
+
pointerId: Schema5.Int
|
|
2073
|
+
}).annotate({ identifier: "DataTableResizeSession" })),
|
|
2074
|
+
filterDraft: Schema5.NullOr(DataTableFilterDraftSchema),
|
|
2075
|
+
invalidFilter: Schema5.Boolean
|
|
2076
|
+
}).annotate({ identifier: "DataTableModel" }),
|
|
2077
|
+
message: DataTableMessage,
|
|
2078
|
+
events: DataTableEvents,
|
|
2079
|
+
restore: false
|
|
2080
|
+
};
|
|
2081
|
+
var available = (props) => props.status?.error === undefined && (!props.status?.loading || props.rowData.length > 0);
|
|
2082
|
+
var tableQuery = (props, model) => props.state ?? { ...model.query, sort: props.sort ?? model.query.sort };
|
|
2083
|
+
var tableFeatures = (props) => ({
|
|
2084
|
+
...props.features,
|
|
2085
|
+
search: props.features?.search ?? props.search ?? true,
|
|
2086
|
+
filtering: props.features?.filtering ?? props.columnFilters ?? true,
|
|
2087
|
+
sorting: props.features?.sorting ?? true,
|
|
2088
|
+
columnVisibility: props.features?.columnVisibility ?? true,
|
|
2089
|
+
pagination: props.features?.pagination ?? props.pagination
|
|
2090
|
+
});
|
|
2091
|
+
var tableSelectedRowIds = (props, model) => {
|
|
2092
|
+
const supplied = new Set(props.rowData.map(({ id }) => id));
|
|
2093
|
+
return [
|
|
2094
|
+
...new Set(props.selection?.selectedRowIds ?? model.selectedRowIds)
|
|
2095
|
+
].filter((id) => supplied.has(id));
|
|
2096
|
+
};
|
|
2097
|
+
var serverPageCorrection = (props, model) => {
|
|
2098
|
+
const pagination = tableFeatures(props).pagination;
|
|
2099
|
+
if (!pagination || pagination.mode !== "server")
|
|
2100
|
+
return;
|
|
2101
|
+
const query = tableQuery(props, model);
|
|
2102
|
+
const { page } = resolveTablePage(pagination.rowCount, query);
|
|
2103
|
+
if (query.page !== page)
|
|
2104
|
+
return { requested: query.page, page, size: query.pageSize };
|
|
2105
|
+
};
|
|
2106
|
+
var tablePreferencesKey = (pathname, columns, gallery) => `data-table:${pathname}:${columns.join(",")}:${gallery ? "gallery" : "table"}:ui`;
|
|
2107
|
+
var preferencesJson = Schema5.fromJsonString(DataTablePreferencesSchema);
|
|
2108
|
+
var decodePreferences = Schema5.decodeUnknownOption(preferencesJson);
|
|
2109
|
+
var encodePreferences = Schema5.encodeSync(preferencesJson);
|
|
2110
|
+
var readTablePreferences = (key, host = globalThis.window) => {
|
|
2111
|
+
try {
|
|
2112
|
+
return Option3.getOrNull(decodePreferences(host?.localStorage.getItem(key)));
|
|
2113
|
+
} catch {
|
|
2114
|
+
return null;
|
|
2115
|
+
}
|
|
2116
|
+
};
|
|
2117
|
+
var writeTablePreferences = (key, preferences, host = globalThis.window) => {
|
|
2118
|
+
try {
|
|
2119
|
+
host?.localStorage.setItem(key, encodePreferences(preferences));
|
|
2120
|
+
} catch {}
|
|
2121
|
+
};
|
|
2122
|
+
var tablePreferences = (model) => model.preferencesLoaded ? {
|
|
2123
|
+
columnVisibility: model.columnVisibility,
|
|
2124
|
+
columnSizing: model.columnSizing,
|
|
2125
|
+
grouping: model.grouping,
|
|
2126
|
+
view: model.view
|
|
2127
|
+
} : null;
|
|
2128
|
+
var tableColumnLimits = (column) => {
|
|
2129
|
+
const min = column.minWidth ?? 96;
|
|
2130
|
+
return { min, max: Math.max(min, column.maxWidth ?? 640) };
|
|
2131
|
+
};
|
|
2132
|
+
var clampTableWidth = (column, width = column.width ?? 208) => {
|
|
2133
|
+
const { min, max } = tableColumnLimits(column);
|
|
2134
|
+
return Math.min(max, Math.max(min, width));
|
|
2135
|
+
};
|
|
2136
|
+
var tableColumnWidth = (column, sizing) => clampTableWidth(column, sizing[column.id]);
|
|
2137
|
+
var tableLayoutWidth = (widths, utilityColumns) => widths.reduce((total, width) => total + width, utilityColumns * 40);
|
|
2138
|
+
var tableResizeStep = (key) => key === "ArrowLeft" ? -8 : key === "ArrowRight" ? 8 : 0;
|
|
2139
|
+
var activeTableGroups = (grouping, fields) => grouping.flatMap((id) => fields.find((field) => field.id === id) ?? []);
|
|
2140
|
+
var tableGrouping = (props, model) => activeTableGroups(model.grouping, props.features?.grouping?.fields ?? []);
|
|
2141
|
+
var canReorderTableRows = (props, model) => !!props.features?.reordering && !tableGrouping(props, model).length && !tableQuery(props, model).sort?.length;
|
|
2142
|
+
var partitionTableGroups = (rows, known, memberships) => {
|
|
2143
|
+
const groups = new Map(known.map((id) => [id, []]));
|
|
2144
|
+
for (const row of rows) {
|
|
2145
|
+
for (const id of new Set(memberships(row))) {
|
|
2146
|
+
const group = groups.get(id);
|
|
2147
|
+
if (group)
|
|
2148
|
+
group.push(row);
|
|
2149
|
+
else
|
|
2150
|
+
groups.set(id, [row]);
|
|
2151
|
+
}
|
|
2152
|
+
}
|
|
2153
|
+
return groups;
|
|
2154
|
+
};
|
|
2155
|
+
var tableGroupKey = (parent, fieldId, groupId) => `${parent ? `${parent}/` : ""}${encodeURIComponent(fieldId)}:${encodeURIComponent(groupId)}`;
|
|
2156
|
+
var reorderRows = ($, rowId, targetId, after) => {
|
|
2157
|
+
const rowIds = $.props.rowData.map(({ id }) => id);
|
|
2158
|
+
const next = $.evolve({ dragging: null });
|
|
2159
|
+
if (!available($.props) || !canReorderTableRows($.props, $.model) || rowId === targetId || !rowIds.includes(rowId) || !rowIds.includes(targetId))
|
|
2160
|
+
return next;
|
|
2161
|
+
const reordered = rowIds.filter((id) => id !== rowId);
|
|
2162
|
+
reordered.splice(reordered.indexOf(targetId) + Number(after), 0, rowId);
|
|
2163
|
+
return next.emit(DataTableEvents.RowsReordered({ rowIds: reordered }));
|
|
2164
|
+
};
|
|
2165
|
+
var moveGroup = ($, rowId, fieldId, groupId) => {
|
|
2166
|
+
const field = tableGrouping($.props, $.model).find(({ id }) => id === fieldId);
|
|
2167
|
+
const row = $.props.rowData.find(({ id }) => id === rowId);
|
|
2168
|
+
const next = $.evolve({ dragging: null });
|
|
2169
|
+
if (!available($.props) || !field?.movable || !row || row.groups?.[fieldId]?.includes(groupId))
|
|
2170
|
+
return next;
|
|
2171
|
+
if (!field.groups?.some(({ id }) => id === groupId) && !$.props.rowData.some((row) => row.groups?.[fieldId]?.includes(groupId)))
|
|
2172
|
+
return next;
|
|
2173
|
+
return next.emit(DataTableEvents.GroupMoveRequested({ rowId, fieldId, groupId }));
|
|
2174
|
+
};
|
|
2175
|
+
var changeQuery = ($, patch, ui = {}, legacy) => {
|
|
2176
|
+
const current = tableQuery($.props, $.model);
|
|
2177
|
+
const state = { ...current, ...patch };
|
|
2178
|
+
if (state.page === current.page && state.pageSize === current.pageSize && state.globalFilter === current.globalFilter && state.filters === current.filters && state.sort === current.sort)
|
|
2179
|
+
return $.evolve(ui);
|
|
2180
|
+
const step = $.evolve({
|
|
2181
|
+
...ui,
|
|
2182
|
+
query: $.props.state ? $.model.query : { ...state, sort: $.props.sort ? $.model.query.sort : state.sort }
|
|
2183
|
+
}).emit(DataTableEvents.StateChanged({ state }));
|
|
2184
|
+
return legacy ? step.emit(legacy) : step;
|
|
2185
|
+
};
|
|
2186
|
+
var tableFilterDraft = (id, current) => ({
|
|
2187
|
+
id,
|
|
2188
|
+
primary: current?.kind === "text" || current?.kind === "boolean" ? String(current.value) : current?.kind === "number" ? String(current.min ?? "") : current?.kind === "date" ? current.from ?? "" : "",
|
|
2189
|
+
secondary: current?.kind === "number" ? String(current.max ?? "") : current?.kind === "date" ? current.to ?? "" : "",
|
|
2190
|
+
operator: current?.kind === "text" ? current.operator : "contains",
|
|
2191
|
+
values: current?.kind === "values" ? current.values : []
|
|
2192
|
+
});
|
|
2193
|
+
var decodeFilter = Schema5.decodeUnknownOption(ColumnFilter);
|
|
2194
|
+
var decodeBound = Schema5.decodeOption(Schema5.FiniteFromString);
|
|
2195
|
+
var parseTableFilterDraft = (kind, {
|
|
2196
|
+
id,
|
|
2197
|
+
primary,
|
|
2198
|
+
secondary,
|
|
2199
|
+
operator,
|
|
2200
|
+
values
|
|
2201
|
+
}) => {
|
|
2202
|
+
switch (kind) {
|
|
2203
|
+
case "number": {
|
|
2204
|
+
const min = primary.trim() ? decodeBound(primary) : Option3.some(undefined);
|
|
2205
|
+
const max = secondary.trim() ? decodeBound(secondary) : Option3.some(undefined);
|
|
2206
|
+
return Option3.isNone(min) || Option3.isNone(max) ? Option3.none() : decodeFilter({ id, kind, min: min.value, max: max.value });
|
|
2207
|
+
}
|
|
2208
|
+
case "boolean":
|
|
2209
|
+
return decodeFilter({
|
|
2210
|
+
id,
|
|
2211
|
+
kind,
|
|
2212
|
+
value: primary === "true" ? true : primary === "false" ? false : undefined
|
|
2213
|
+
});
|
|
2214
|
+
case "values":
|
|
2215
|
+
return decodeFilter({ id, kind, values });
|
|
2216
|
+
case "date":
|
|
2217
|
+
return decodeFilter({
|
|
2218
|
+
id,
|
|
2219
|
+
kind,
|
|
2220
|
+
from: primary || undefined,
|
|
2221
|
+
to: secondary || undefined
|
|
2222
|
+
});
|
|
2223
|
+
case "text":
|
|
2224
|
+
return decodeFilter({ id, kind, operator, value: primary.trim() });
|
|
2225
|
+
}
|
|
2226
|
+
};
|
|
2227
|
+
var changeColumnFilter = ($, id, filter, ui) => {
|
|
2228
|
+
const filters = (tableQuery($.props, $.model).filters ?? []).filter((current) => current.id !== id);
|
|
2229
|
+
if (filter)
|
|
2230
|
+
filters.push(filter);
|
|
2231
|
+
return changeQuery($, { filters: filters.length ? filters : undefined, page: 0 }, ui);
|
|
2232
|
+
};
|
|
2233
|
+
var projectDataTableRows = (source, query, {
|
|
2234
|
+
pagination,
|
|
2235
|
+
grouped,
|
|
2236
|
+
sortMode,
|
|
2237
|
+
search,
|
|
2238
|
+
filter,
|
|
2239
|
+
sort
|
|
2240
|
+
}) => {
|
|
2241
|
+
const server = pagination && pagination.mode === "server";
|
|
2242
|
+
const filtered = server ? source : filter(search(source, query.globalFilter ?? ""), query.filters ?? []);
|
|
2243
|
+
const ordered = !server && sortMode !== "server" && query.sort?.length ? sort(filtered, query.sort) : filtered;
|
|
2244
|
+
const { pageSize } = query;
|
|
2245
|
+
const totalRows = server ? pagination.rowCount : ordered.length;
|
|
2246
|
+
const { page, pageCount, start, end } = resolveTablePage(totalRows, query);
|
|
2247
|
+
const paginationVisible = !!pagination && (server || !grouped);
|
|
2248
|
+
const rows = paginationVisible && !server ? ordered.slice(start, end) : ordered;
|
|
2249
|
+
return {
|
|
2250
|
+
rows,
|
|
2251
|
+
filtered,
|
|
2252
|
+
ordered,
|
|
2253
|
+
pageSize,
|
|
2254
|
+
totalRows,
|
|
2255
|
+
pageCount,
|
|
2256
|
+
page,
|
|
2257
|
+
paginationVisible
|
|
2258
|
+
};
|
|
2259
|
+
};
|
|
2260
|
+
var dataTablePage = (props, model, locale) => {
|
|
2261
|
+
const pagination = tableFeatures(props).pagination;
|
|
2262
|
+
const columns = tableDataColumns(props.columnDefs);
|
|
2263
|
+
return {
|
|
2264
|
+
...projectDataTableRows(props.rowData, tableQuery(props, model), {
|
|
2265
|
+
pagination,
|
|
2266
|
+
grouped: tableGrouping(props, model).length > 0,
|
|
2267
|
+
sortMode: props.sortMode,
|
|
2268
|
+
search: (rows, value) => filterTableRows(rows, columns, value, locale),
|
|
2269
|
+
filter: (rows, filters) => filterTableColumns(rows, columns, filters),
|
|
2270
|
+
sort: (rows, sorting) => sortTableRows(rows, columns, sorting, locale)
|
|
2271
|
+
}),
|
|
2272
|
+
pageSizes: pagination && pagination.pageSizes || defaultPageSizes
|
|
2273
|
+
};
|
|
2274
|
+
};
|
|
2275
|
+
var encodeTableCsv = (headers, data) => Effect2.runSync(Stream.fromIterable([headers, ...data]).pipe(Stream.map((row) => row.map((value) => value == null ? "" : String(value))), Stream.pipeThroughChannel(Csv.encodeString({ newline: `
|
|
2276
|
+
` })), Stream.runCollect, Effect2.map((parts) => parts.join("").slice(0, -1))));
|
|
2277
|
+
var tableExportFilename = (name, extension) => name.includes(".") ? name.replace(/\.[^/.]+$/, `.${extension}`) : `${name}.${extension}`;
|
|
2278
|
+
var downloadTableBlob = (content, type, filename) => {
|
|
2279
|
+
const url = window.URL.createObjectURL(new Blob([content], { type }));
|
|
2280
|
+
const link = document.createElement("a");
|
|
2281
|
+
link.href = url;
|
|
2282
|
+
link.download = filename;
|
|
2283
|
+
document.body.appendChild(link);
|
|
2284
|
+
try {
|
|
2285
|
+
link.click();
|
|
2286
|
+
} finally {
|
|
2287
|
+
link.remove();
|
|
2288
|
+
requestAnimationFrame(() => window.URL.revokeObjectURL(url));
|
|
2289
|
+
}
|
|
2290
|
+
};
|
|
2291
|
+
var tableExportValue = (column, row, locale) => {
|
|
2292
|
+
const value = row.cells[column.id];
|
|
2293
|
+
switch (column.type) {
|
|
2294
|
+
case "date":
|
|
2295
|
+
case "dateTime": {
|
|
2296
|
+
const date = resolveDate(value, column.type);
|
|
2297
|
+
return !date ? null : column.typeOptions?.exportFormat === "formatted" ? formatDateValue(date, column, locale) : dateIsoValue(date);
|
|
2298
|
+
}
|
|
2299
|
+
case "reference":
|
|
2300
|
+
return isTableReference(value) ? [value.label, value.description].filter(Boolean).join(" — ") : "";
|
|
2301
|
+
case "list":
|
|
2302
|
+
return isTableList(value) ? value.map(({ label }) => label).join(", ") : "";
|
|
2303
|
+
case "boolean":
|
|
2304
|
+
return !isTableBoolean(value) ? null : column.typeOptions?.exportFormat === "formatted" ? tableBooleanLabel(value, column.typeOptions) : value;
|
|
2305
|
+
case "number":
|
|
2306
|
+
return !isTableNumber(value) ? null : column.typeOptions?.exportFormat === "formatted" ? formatNumberValue(value, column.typeOptions, locale) : value;
|
|
2307
|
+
default:
|
|
2308
|
+
return columnValue(column, value);
|
|
2309
|
+
}
|
|
2310
|
+
};
|
|
2311
|
+
var DownloadTable = Command.make("DataTable/Download", {
|
|
2312
|
+
args: {
|
|
2313
|
+
filename: Schema5.String,
|
|
2314
|
+
content: Schema5.Redacted(Schema5.String, { disallowJsonEncode: true }),
|
|
2315
|
+
type: Schema5.String
|
|
2316
|
+
}
|
|
2317
|
+
}, ({ filename, content, type }) => Effect2.try(() => downloadTableBlob(Redacted.value(content), type, filename)).pipe(Effect2.match({
|
|
2318
|
+
onSuccess: () => DataTableMessage.ExportFinished({ failed: false }),
|
|
2319
|
+
onFailure: () => DataTableMessage.ExportFinished({ failed: true })
|
|
2320
|
+
})));
|
|
2321
|
+
var update2 = Component2.define(dataTableOptions).update({
|
|
2322
|
+
ReferenceImageFailed: ($, { src }) => $.model.failedImages.includes(src) ? $.model : $.evolve({ failedImages: [...$.model.failedImages, src] }),
|
|
2323
|
+
RowActivated: ($, { rowId }) => $.props.rowActivation && available($.props) && $.props.rowData.some(({ id }) => id === rowId) ? $.emit(DataTableEvents.RowActivated({ rowId })) : $.model,
|
|
2324
|
+
PreferencesLoaded: ($, { preferences }) => $.model.preferencesLoaded ? $.model : $.evolve({
|
|
2325
|
+
preferencesLoaded: true,
|
|
2326
|
+
columnVisibility: {
|
|
2327
|
+
...$.model.columnVisibility,
|
|
2328
|
+
...preferences?.columnVisibility
|
|
2329
|
+
},
|
|
2330
|
+
columnSizing: preferences?.columnSizing ?? $.model.columnSizing,
|
|
2331
|
+
grouping: preferences?.grouping ?? $.model.grouping,
|
|
2332
|
+
view: $.props.features?.gallery ? preferences?.view ?? $.model.view : "table"
|
|
2333
|
+
}),
|
|
2334
|
+
ItemActionRequested: ($, request) => {
|
|
2335
|
+
const row = $.props.rowData.find(({ id }) => id === request.rowId);
|
|
2336
|
+
const column = $.props.columnDefs.find(({ id }) => id === request.columnId);
|
|
2337
|
+
const items = row?.cells[request.columnId];
|
|
2338
|
+
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;
|
|
2339
|
+
},
|
|
2340
|
+
ExportStarted: ($) => $.evolve({ exporting: true, exportFailed: false }),
|
|
2341
|
+
ExportFinished: ($, { failed }) => $.evolve({ exporting: false, exportFailed: failed }),
|
|
2342
|
+
BuiltInExportRequested: ($, { format, locale = $.props.locale ?? "en" }) => {
|
|
2343
|
+
const feature = $.props.features?.export;
|
|
2344
|
+
if (!feature || feature.pending || $.model.exporting || feature.builtIn === false || !available($.props))
|
|
2345
|
+
return $.model;
|
|
2346
|
+
const projection = dataTablePage($.props, $.model, locale);
|
|
2347
|
+
const rows = feature.scope === "currentPage" ? projection.rows : projection.ordered;
|
|
2348
|
+
if (!rows.length)
|
|
2349
|
+
return $.model;
|
|
2350
|
+
const columns = tableDataColumns($.props.columnDefs.filter(({ id, export: enabled }) => enabled !== false && $.model.columnVisibility[id] !== false)).filter(({ export: enabled }) => enabled !== false);
|
|
2351
|
+
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) => [
|
|
2352
|
+
column.id,
|
|
2353
|
+
tableExportValue(column, row, locale)
|
|
2354
|
+
]))), null, 2);
|
|
2355
|
+
return $.evolve({ menu: null, exporting: true, exportFailed: false }).run(DownloadTable.make({
|
|
2356
|
+
content: Redacted.make(content),
|
|
2357
|
+
filename: tableExportFilename(feature.baseName, format),
|
|
2358
|
+
type: format === "csv" ? "text/csv;charset=utf-8" : "application/json;charset=utf-8"
|
|
2359
|
+
}));
|
|
2360
|
+
},
|
|
2361
|
+
RefreshRequested: ($) => $.props.features?.refresh ? $.emit(DataTableEvents.RefreshRequested()) : $.model,
|
|
2362
|
+
ExportRequested: ($, { actionId }) => !$.props.features?.export?.pending && $.props.features?.export?.actions?.some(({ id, disabled }) => id === actionId && !disabled) ? $.emit(DataTableEvents.ExportRequested({ actionId })) : $.model,
|
|
2363
|
+
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,
|
|
2364
|
+
GroupMoveRequested: ($, { rowId, fieldId, groupId }) => moveGroup($, rowId, fieldId, groupId),
|
|
2365
|
+
ReorderRequested: ($, { rowId, targetId, after }) => reorderRows($, rowId, targetId, after),
|
|
2366
|
+
DragStarted: ($, { rowId }) => $.evolve({ dragging: rowId }),
|
|
2367
|
+
DragEnded: ($) => $.evolve({ dragging: null }),
|
|
2368
|
+
DragDropped: ($, { targetId }) => $.model.dragging === null ? $.model : reorderRows($, $.model.dragging, targetId, $.props.rowData.findIndex(({ id }) => id === $.model.dragging) < $.props.rowData.findIndex(({ id }) => id === targetId)),
|
|
2369
|
+
GroupDropped: ($, { fieldId, groupId }) => $.model.dragging === null ? $.model : moveGroup($, $.model.dragging, fieldId, groupId),
|
|
2370
|
+
ViewPicked: ($, { view }) => view === "table" || $.props.features?.gallery ? $.evolve({ view, menu: null }) : $.model,
|
|
2371
|
+
GroupingToggled: ($, { fieldId }) => $.props.features?.grouping?.fields.some(({ id }) => id === fieldId) ? $.evolve({
|
|
2372
|
+
grouping: updateSelectedRows($.model.grouping, [fieldId], !$.model.grouping.includes(fieldId))
|
|
2373
|
+
}) : $.model,
|
|
2374
|
+
GroupToggled: ($, { key }) => $.evolve({
|
|
2375
|
+
collapsedGroups: {
|
|
2376
|
+
...$.model.collapsedGroups,
|
|
2377
|
+
[key]: !$.model.collapsedGroups[key]
|
|
2378
|
+
}
|
|
2379
|
+
}),
|
|
2380
|
+
ColumnResized: ($, { id, delta }) => {
|
|
2381
|
+
const column = $.props.columnDefs.find((column) => column.id === id);
|
|
2382
|
+
if (!column || column.resizable === false)
|
|
2383
|
+
return $.model;
|
|
2384
|
+
const sizing = {
|
|
2385
|
+
...$.model.columnSizing,
|
|
2386
|
+
[id]: tableColumnWidth(column, $.model.columnSizing) + delta
|
|
2387
|
+
};
|
|
2388
|
+
return $.evolve({
|
|
2389
|
+
columnSizing: { ...sizing, [id]: tableColumnWidth(column, sizing) }
|
|
2390
|
+
});
|
|
2391
|
+
},
|
|
2392
|
+
ColumnResizeReset: ($, { id }) => {
|
|
2393
|
+
const column = $.props.columnDefs.find((column) => column.id === id);
|
|
2394
|
+
if (!column || column.resizable === false)
|
|
2395
|
+
return $.model;
|
|
2396
|
+
return $.evolve({
|
|
2397
|
+
columnSizing: {
|
|
2398
|
+
...$.model.columnSizing,
|
|
2399
|
+
[id]: clampTableWidth(column)
|
|
2400
|
+
}
|
|
2401
|
+
});
|
|
2402
|
+
},
|
|
2403
|
+
ResizeStarted: ($, { id, x, pointerId }) => {
|
|
2404
|
+
const column = $.props.columnDefs.find((column) => column.id === id);
|
|
2405
|
+
return column && column.resizable !== false ? $.evolve({
|
|
2406
|
+
resizing: {
|
|
2407
|
+
id,
|
|
2408
|
+
x,
|
|
2409
|
+
pointerId,
|
|
2410
|
+
width: tableColumnWidth(column, $.model.columnSizing)
|
|
2411
|
+
}
|
|
2412
|
+
}) : $.model;
|
|
2413
|
+
},
|
|
2414
|
+
ResizeMoved: ($, { x, pointerId }) => {
|
|
2415
|
+
const resize = $.model.resizing;
|
|
2416
|
+
const column = resize && $.props.columnDefs.find(({ id }) => id === resize.id);
|
|
2417
|
+
if (!resize || resize.pointerId !== pointerId || !column || column.resizable === false)
|
|
2418
|
+
return $.model;
|
|
2419
|
+
return $.evolve({
|
|
2420
|
+
columnSizing: {
|
|
2421
|
+
...$.model.columnSizing,
|
|
2422
|
+
[resize.id]: tableColumnWidth(column, {
|
|
2423
|
+
[resize.id]: resize.width + x - resize.x
|
|
2424
|
+
})
|
|
2425
|
+
}
|
|
2426
|
+
});
|
|
2427
|
+
},
|
|
2428
|
+
ResizeEnded: ($, { pointerId }) => $.model.resizing?.pointerId === pointerId ? $.evolve({ resizing: null }) : $.model,
|
|
2429
|
+
ColumnFiltersCleared: ($, { id }) => {
|
|
2430
|
+
const column = $.props.columnDefs.find((column) => column.id === id);
|
|
2431
|
+
if (!column || !tableFeatures($.props).filtering)
|
|
2432
|
+
return $.model;
|
|
2433
|
+
const owned = new Set([
|
|
2434
|
+
id,
|
|
2435
|
+
...tableDataColumns([column]).map(({ id }) => id)
|
|
2436
|
+
]);
|
|
2437
|
+
const filters = tableQuery($.props, $.model).filters?.filter(({ id }) => !owned.has(id));
|
|
2438
|
+
return changeQuery($, { filters: filters?.length ? filters : undefined, page: 0 }, { filterDraft: null, invalidFilter: false });
|
|
2439
|
+
},
|
|
2440
|
+
ColumnSortCleared: ($, { id }) => {
|
|
2441
|
+
const column = $.props.columnDefs.find((column) => column.id === id);
|
|
2442
|
+
if (!column || !tableFeatures($.props).sorting)
|
|
2443
|
+
return $.model;
|
|
2444
|
+
const owned = new Set([
|
|
2445
|
+
id,
|
|
2446
|
+
...tableDataColumns([column]).map(({ id }) => id)
|
|
2447
|
+
]);
|
|
2448
|
+
const sort = (tableQuery($.props, $.model).sort ?? []).filter(({ id }) => !owned.has(id));
|
|
2449
|
+
return changeQuery($, { sort }, {}, DataTableEvents.SortChanged({ sort }));
|
|
2450
|
+
},
|
|
2451
|
+
MenuOpened: ($, { key }) => $.evolve({ menu: key, submenu: null, menuQuery: "" }),
|
|
2452
|
+
MenuQueryChanged: ($, { key, query }) => $.model.menu === key ? $.evolve({ menuQuery: query }) : $.model,
|
|
2453
|
+
MenuClosed: ($, { key }) => $.model.menu === key ? $.evolve({ menu: null, submenu: null }) : $.model,
|
|
2454
|
+
SubmenuOpened: ($, { key, filterColumnId }) => $.evolve({
|
|
2455
|
+
submenu: key,
|
|
2456
|
+
menuQuery: "",
|
|
2457
|
+
...filterColumnId === undefined ? {} : {
|
|
2458
|
+
filterDraft: tableFilterDraft(filterColumnId, tableQuery($.props, $.model).filters?.find(({ id }) => id === filterColumnId)),
|
|
2459
|
+
invalidFilter: false
|
|
2460
|
+
}
|
|
2461
|
+
}),
|
|
2462
|
+
SubmenuClosed: ($, { key }) => $.model.submenu === key ? $.evolve({ submenu: null }) : $.model,
|
|
2463
|
+
SearchChanged: ($, { value }) => tableFeatures($.props).search ? changeQuery($, { globalFilter: value || undefined, page: 0 }, { menu: null }) : $.model,
|
|
2464
|
+
FilterInputChanged: ($, { field, value }) => {
|
|
2465
|
+
const draft = $.model.filterDraft;
|
|
2466
|
+
return draft ? $.evolve({
|
|
2467
|
+
filterDraft: { ...draft, [field]: value },
|
|
2468
|
+
invalidFilter: false
|
|
2469
|
+
}) : $.model;
|
|
2470
|
+
},
|
|
2471
|
+
FilterOperatorChanged: ($, { operator }) => {
|
|
2472
|
+
const draft = $.model.filterDraft;
|
|
2473
|
+
return draft ? $.evolve({
|
|
2474
|
+
filterDraft: { ...draft, operator },
|
|
2475
|
+
invalidFilter: false
|
|
2476
|
+
}) : $.model;
|
|
2477
|
+
},
|
|
2478
|
+
FilterValueToggled: ($, { value, checked }) => {
|
|
2479
|
+
const draft = $.model.filterDraft;
|
|
2480
|
+
return draft ? $.evolve({
|
|
2481
|
+
filterDraft: {
|
|
2482
|
+
...draft,
|
|
2483
|
+
values: updateSelectedRows(draft.values, [value], checked)
|
|
2484
|
+
},
|
|
2485
|
+
invalidFilter: false
|
|
2486
|
+
}) : $.model;
|
|
2487
|
+
},
|
|
2488
|
+
FilterApplied: ($) => {
|
|
2489
|
+
const draft = $.model.filterDraft;
|
|
2490
|
+
if (!tableFeatures($.props).filtering || !draft)
|
|
2491
|
+
return $.model;
|
|
2492
|
+
const column = tableDataColumns($.props.columnDefs).find(({ id, filterable }) => id === draft.id && filterable !== false);
|
|
2493
|
+
if (!column)
|
|
2494
|
+
return $.model;
|
|
2495
|
+
const decoded = parseTableFilterDraft(tableFilterKind(column), draft);
|
|
2496
|
+
return Option3.isNone(decoded) ? $.evolve({ invalidFilter: true }) : changeColumnFilter($, draft.id, decoded.value, {
|
|
2497
|
+
invalidFilter: false
|
|
2498
|
+
});
|
|
2499
|
+
},
|
|
2500
|
+
FilterCleared: ($) => {
|
|
2501
|
+
const draft = $.model.filterDraft;
|
|
2502
|
+
if (!draft)
|
|
2503
|
+
return $.model;
|
|
2504
|
+
return changeColumnFilter($, draft.id, null, {
|
|
2505
|
+
filterDraft: tableFilterDraft(draft.id),
|
|
2506
|
+
invalidFilter: false
|
|
2507
|
+
});
|
|
2508
|
+
},
|
|
2509
|
+
ColumnFilterChanged: ($, { id, filter }) => {
|
|
2510
|
+
if (!tableFeatures($.props).filtering || !tableDataColumns($.props.columnDefs).some((column) => column.id === id && column.filterable !== false) || filter && filter.id !== id)
|
|
2511
|
+
return $.model;
|
|
2512
|
+
return changeColumnFilter($, id, filter);
|
|
2513
|
+
},
|
|
2514
|
+
FiltersCleared: ($) => changeQuery($, { filters: undefined, page: 0 }, {
|
|
2515
|
+
filterDraft: null,
|
|
2516
|
+
invalidFilter: false
|
|
2517
|
+
}),
|
|
2518
|
+
PageRequested: ($, { page }) => tableFeatures($.props).pagination && page >= 0 ? changeQuery($, { page }, { menu: null }) : $.model,
|
|
2519
|
+
ServerPageInvalidated: ($) => {
|
|
2520
|
+
const correction = serverPageCorrection($.props, $.model);
|
|
2521
|
+
return correction ? changeQuery($, { page: correction.page }) : $.model;
|
|
2522
|
+
},
|
|
2523
|
+
PageSizeRequested: ($, { pageSize }) => {
|
|
2524
|
+
const pagination = tableFeatures($.props).pagination;
|
|
2525
|
+
return pagination && (pagination.pageSizes ?? defaultPageSizes).includes(pageSize) ? changeQuery($, { pageSize, page: 0 }, { menu: null }) : $.model;
|
|
2526
|
+
},
|
|
2527
|
+
SortRequested: ($, { columnId, direction }) => {
|
|
2528
|
+
if (!tableFeatures($.props).sorting || !tableDataColumns($.props.columnDefs).some(({ id, sortable }) => id === columnId && sortable !== false))
|
|
2529
|
+
return $.model;
|
|
2530
|
+
const sort = direction === null ? (tableQuery($.props, $.model).sort ?? []).filter(({ id }) => id !== columnId) : [{ id: columnId, direction }];
|
|
2531
|
+
return changeQuery($, { sort: sort.length ? sort : undefined, page: 0 }, {}, DataTableEvents.SortChanged({ sort }));
|
|
2532
|
+
},
|
|
2533
|
+
ColumnVisibilityChanged: ($, { id, visible }) => tableFeatures($.props).columnVisibility && $.props.columnDefs.some((column) => column.id === id && column.hideable !== false) ? $.evolve({
|
|
2534
|
+
columnVisibility: { ...$.model.columnVisibility, [id]: visible }
|
|
2535
|
+
}) : $.model,
|
|
2536
|
+
SelectionRequested: ($, { rowIds, checked }) => {
|
|
2537
|
+
if (!available($.props) || !$.props.selection)
|
|
2538
|
+
return $.model;
|
|
2539
|
+
const requested = new Set(rowIds);
|
|
2540
|
+
const targets = $.props.rowData.filter((row) => row.selectable !== false && requested.has(row.id)).map(({ id }) => id);
|
|
2541
|
+
if (targets.length === 0)
|
|
2542
|
+
return $.model;
|
|
2543
|
+
const controlled = $.props.selection.selectedRowIds;
|
|
2544
|
+
const selectedRowIds = updateSelectedRows(controlled ?? $.model.selectedRowIds, targets, checked);
|
|
2545
|
+
return $.evolve(controlled ? {} : { selectedRowIds }).emit(DataTableEvents.SelectionChanged({ selectedRowIds }));
|
|
2546
|
+
},
|
|
2547
|
+
CellEditRequested: ($, { rowId, columnId, edit }) => {
|
|
2548
|
+
if (!available($.props))
|
|
2549
|
+
return $.model;
|
|
2550
|
+
const row = $.props.rowData.find(({ id }) => id === rowId);
|
|
2551
|
+
const column = $.props.columnDefs.find(({ id }) => id === columnId);
|
|
2552
|
+
if (!row || !column || row.disabledColumnIds?.includes(columnId))
|
|
2553
|
+
return $.model;
|
|
2554
|
+
const value = row.cells[columnId];
|
|
2555
|
+
if (edit._tag === "SetBoolean") {
|
|
2556
|
+
if (column.type !== "boolean" || !column.editable || !isTableBoolean(value) || edit.value === value)
|
|
2557
|
+
return $.model;
|
|
2558
|
+
} else {
|
|
2559
|
+
if (column.type !== "list")
|
|
2560
|
+
return $.model;
|
|
2561
|
+
const items = isTableList(value) ? value : [];
|
|
2562
|
+
const contains = items.some(({ value }) => value === edit.itemId);
|
|
2563
|
+
if (edit._tag === "AddItem") {
|
|
2564
|
+
if (contains || !column.options?.some(({ value }) => value === edit.itemId))
|
|
2565
|
+
return $.model;
|
|
2566
|
+
} else if (!contains || !column.allowRemove)
|
|
2567
|
+
return $.model;
|
|
2568
|
+
}
|
|
2569
|
+
return $.emit(DataTableEvents.CellEditRequested({ rowId, columnId, edit }));
|
|
2570
|
+
},
|
|
2571
|
+
RowActionRequested: ($, { rowId, actionId }) => {
|
|
2572
|
+
const row = $.props.rowData.find(({ id }) => id === rowId);
|
|
2573
|
+
if (!available($.props) || !row?.actions?.some(({ id, disabled }) => id === actionId && !disabled))
|
|
2574
|
+
return $.model;
|
|
2575
|
+
return $.emit(DataTableEvents.RowActionRequested({ rowId, actionId }));
|
|
2576
|
+
},
|
|
2577
|
+
BulkActionRequested: ($, { actionId }) => {
|
|
2578
|
+
const selection = $.props.selection;
|
|
2579
|
+
if (!available($.props) || !selection?.bulkActions?.some(({ id, disabled }) => id === actionId && !disabled))
|
|
2580
|
+
return $.model;
|
|
2581
|
+
const rowIds = tableSelectedRowIds($.props, $.model);
|
|
2582
|
+
return rowIds.length > 0 ? $.emit(DataTableEvents.BulkActionRequested({ actionId, rowIds })) : $.model;
|
|
2583
|
+
}
|
|
2584
|
+
});
|
|
2585
|
+
var dataTableBehaviours = {
|
|
2586
|
+
subscriptions: ({
|
|
2587
|
+
props,
|
|
2588
|
+
model
|
|
2589
|
+
}) => {
|
|
2590
|
+
const correction = serverPageCorrection(props, model);
|
|
2591
|
+
return correction ? [
|
|
2592
|
+
Subscription.make("reconcile-server-page", [correction.requested, correction.page, correction.size], () => Stream.make(DataTableMessage.ServerPageInvalidated()))
|
|
2593
|
+
] : [];
|
|
2594
|
+
},
|
|
2595
|
+
init: ({ props }) => ({
|
|
2596
|
+
menu: null,
|
|
2597
|
+
submenu: null,
|
|
2598
|
+
menuQuery: "",
|
|
2599
|
+
failedImages: [],
|
|
2600
|
+
selectedRowIds: [],
|
|
2601
|
+
query: {
|
|
2602
|
+
globalFilter: props.initialState?.globalFilter,
|
|
2603
|
+
filters: props.initialState?.filters,
|
|
2604
|
+
sort: props.initialState?.sort,
|
|
2605
|
+
page: props.initialState?.page ?? 0,
|
|
2606
|
+
pageSize: props.initialState?.pageSize ?? (props.pagination?.mode === undefined ? props.pagination?.pageSizes?.[0] : undefined) ?? DEFAULT_PAGE_SIZE
|
|
2607
|
+
},
|
|
2608
|
+
columnVisibility: props.initialState?.columnVisibility ?? {},
|
|
2609
|
+
preferencesLoaded: false,
|
|
2610
|
+
columnSizing: {},
|
|
2611
|
+
view: props.initialState?.view ?? "table",
|
|
2612
|
+
grouping: props.features?.grouping?.initial ?? [],
|
|
2613
|
+
collapsedGroups: {},
|
|
2614
|
+
dragging: null,
|
|
2615
|
+
exporting: false,
|
|
2616
|
+
exportFailed: false,
|
|
2617
|
+
resizing: null,
|
|
2618
|
+
filterDraft: null,
|
|
2619
|
+
invalidFilter: false
|
|
2620
|
+
}),
|
|
2621
|
+
update: update2
|
|
2622
|
+
};
|
|
2623
|
+
|
|
2624
|
+
// ../../src/components/data-table/react.tsx
|
|
1217
2625
|
import { jsx as jsx15, jsxs as jsxs9, Fragment } from "react/jsx-runtime";
|
|
1218
2626
|
var DataTableStylesContext = createContext(undefined);
|
|
2627
|
+
var DataTableSlotClassesContext = createContext(resolveTableClasses());
|
|
1219
2628
|
var styledTablePart = (Part, slot, style) => {
|
|
1220
2629
|
const StyledPart = (props) => {
|
|
1221
2630
|
const styles = useContext(DataTableStylesContext);
|
|
@@ -1254,27 +2663,21 @@ var DropdownMenuLabel2 = styledTablePart(DropdownMenuLabel, "row-menu-label", (s
|
|
|
1254
2663
|
var DropdownMenuSeparator2 = styledTablePart(DropdownMenuSeparator, "row-menu-separator", (s) => s?.menu?.separator);
|
|
1255
2664
|
var SelectContent2 = styledTablePart(SelectContent, "select-popup", (s) => s?.popup?.select);
|
|
1256
2665
|
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
2666
|
var DataTableReferenceCell = ({
|
|
1265
2667
|
item,
|
|
1266
2668
|
emptyLabel = "—",
|
|
1267
2669
|
imageVariant = "circle"
|
|
1268
2670
|
}) => {
|
|
2671
|
+
const tableClasses = useContext(DataTableSlotClassesContext);
|
|
1269
2672
|
const [failedImage, setFailedImage] = useState();
|
|
1270
2673
|
if (!item)
|
|
1271
2674
|
return emptyLabel;
|
|
1272
|
-
const initials = item.label
|
|
2675
|
+
const initials = tableInitials(item.label);
|
|
1273
2676
|
return /* @__PURE__ */ jsxs9("div", {
|
|
1274
|
-
className:
|
|
2677
|
+
className: tableClasses.reference,
|
|
1275
2678
|
children: [
|
|
1276
2679
|
/* @__PURE__ */ jsx15("div", {
|
|
1277
|
-
className: cn(
|
|
2680
|
+
className: cn(tableClasses.referenceAvatar, imageVariant === "circle" ? "rounded-full" : "rounded-md", item.iconClassName),
|
|
1278
2681
|
children: item.icon ? /* @__PURE__ */ jsx15("span", {
|
|
1279
2682
|
"aria-hidden": "true",
|
|
1280
2683
|
className: "[&_svg]:size-4",
|
|
@@ -1290,14 +2693,14 @@ var DataTableReferenceCell = ({
|
|
|
1290
2693
|
})
|
|
1291
2694
|
}),
|
|
1292
2695
|
/* @__PURE__ */ jsxs9("div", {
|
|
1293
|
-
className:
|
|
2696
|
+
className: tableClasses.referenceText,
|
|
1294
2697
|
children: [
|
|
1295
2698
|
/* @__PURE__ */ jsx15("span", {
|
|
1296
|
-
className:
|
|
2699
|
+
className: tableClasses.referenceName,
|
|
1297
2700
|
children: item.label
|
|
1298
2701
|
}),
|
|
1299
2702
|
item.description ? /* @__PURE__ */ jsx15("span", {
|
|
1300
|
-
className:
|
|
2703
|
+
className: tableClasses.referenceDescription,
|
|
1301
2704
|
children: item.description
|
|
1302
2705
|
}) : null
|
|
1303
2706
|
]
|
|
@@ -1309,28 +2712,10 @@ var referenceText = (item) => item ? [item.label, item.description].filter(Boole
|
|
|
1309
2712
|
var messages2 = {
|
|
1310
2713
|
en: {
|
|
1311
2714
|
...paginationMessages("en"),
|
|
1312
|
-
|
|
1313
|
-
addItem: "Add item...",
|
|
1314
|
-
empty: "No results.",
|
|
1315
|
-
loading: "Loading...",
|
|
2715
|
+
...defaultMessages.en,
|
|
1316
2716
|
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
2717
|
filterFrom: "From (UTC)",
|
|
1330
2718
|
filterTo: "To (UTC)",
|
|
1331
|
-
filterTrue: "True",
|
|
1332
|
-
filterFalse: "False",
|
|
1333
|
-
filterInvalid: "Enter a valid filter. Ranges must be in ascending order.",
|
|
1334
2719
|
export: "Export",
|
|
1335
2720
|
exportCsv: "CSV",
|
|
1336
2721
|
exportJson: "JSON",
|
|
@@ -1340,46 +2725,21 @@ var messages2 = {
|
|
|
1340
2725
|
tableView: "Table",
|
|
1341
2726
|
galleryView: "Gallery",
|
|
1342
2727
|
columns: "Columns",
|
|
1343
|
-
groupBy: "Group by",
|
|
1344
|
-
sortAsc: "Ascending",
|
|
1345
|
-
sortDesc: "Descending",
|
|
1346
|
-
sortClear: "Clear sorting",
|
|
2728
|
+
groupBy: "Group by",
|
|
1347
2729
|
sortBy: "Sort by",
|
|
1348
2730
|
hideColumn: "Hide column",
|
|
1349
2731
|
reorder: "Drag to reorder",
|
|
1350
|
-
removeItem: "Remove",
|
|
1351
2732
|
moveUp: "Move up",
|
|
1352
2733
|
moveDown: "Move down",
|
|
1353
2734
|
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"
|
|
2735
|
+
listDetails: "View all items"
|
|
1358
2736
|
},
|
|
1359
2737
|
fr: {
|
|
1360
2738
|
...paginationMessages("fr"),
|
|
1361
|
-
|
|
1362
|
-
addItem: "Ajouter un élément...",
|
|
1363
|
-
empty: "Aucun résultat.",
|
|
1364
|
-
loading: "Chargement...",
|
|
2739
|
+
...defaultMessages.fr,
|
|
1365
2740
|
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
2741
|
filterFrom: "Du (UTC)",
|
|
1379
2742
|
filterTo: "Au (UTC)",
|
|
1380
|
-
filterTrue: "Vrai",
|
|
1381
|
-
filterFalse: "Faux",
|
|
1382
|
-
filterInvalid: "Saisissez un filtre valide. Les bornes doivent être dans l’ordre croissant.",
|
|
1383
2743
|
export: "Exporter",
|
|
1384
2744
|
exportCsv: "CSV",
|
|
1385
2745
|
exportJson: "JSON",
|
|
@@ -1390,20 +2750,13 @@ var messages2 = {
|
|
|
1390
2750
|
galleryView: "Galerie",
|
|
1391
2751
|
columns: "Colonnes",
|
|
1392
2752
|
groupBy: "Grouper par",
|
|
1393
|
-
sortAsc: "Croissant",
|
|
1394
|
-
sortDesc: "Décroissant",
|
|
1395
|
-
sortClear: "Effacer le tri",
|
|
1396
2753
|
sortBy: "Trier par",
|
|
1397
2754
|
hideColumn: "Masquer la colonne",
|
|
1398
2755
|
reorder: "Glisser pour réordonner",
|
|
1399
|
-
removeItem: "Retirer",
|
|
1400
2756
|
moveUp: "Déplacer vers le haut",
|
|
1401
2757
|
moveDown: "Déplacer vers le bas",
|
|
1402
2758
|
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"
|
|
2759
|
+
listDetails: "Afficher tous les éléments"
|
|
1407
2760
|
}
|
|
1408
2761
|
};
|
|
1409
2762
|
var dataTableMessages = (locale = "en", translations) => ({
|
|
@@ -1411,32 +2764,6 @@ var dataTableMessages = (locale = "en", translations) => ({
|
|
|
1411
2764
|
...translations?.[locale.split("-")[0] ?? locale],
|
|
1412
2765
|
...translations?.[locale]
|
|
1413
2766
|
});
|
|
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
2767
|
var normalizeDataTableColumns = (columnDefs, columnSizing = {}) => {
|
|
1441
2768
|
const ids = new Set;
|
|
1442
2769
|
const columns = columnDefs.map((colDef) => {
|
|
@@ -1451,7 +2778,7 @@ var normalizeDataTableColumns = (columnDefs, columnSizing = {}) => {
|
|
|
1451
2778
|
return {
|
|
1452
2779
|
id,
|
|
1453
2780
|
colDef,
|
|
1454
|
-
width:
|
|
2781
|
+
width: clampTableWidth(colDef, columnSizing[id])
|
|
1455
2782
|
};
|
|
1456
2783
|
});
|
|
1457
2784
|
for (const column of columns) {
|
|
@@ -1472,7 +2799,7 @@ var getDataTableFieldColumns = (column) => (column.colDef.fields ?? []).map(({ i
|
|
|
1472
2799
|
}));
|
|
1473
2800
|
var getDataTableSortColumns = (columns) => columns.flatMap((column) => column.colDef.sortable === false ? [] : ((column.colDef.fields?.length) ? getDataTableFieldColumns(column) : [column]).filter(({ colDef }) => colDef.sortable !== false));
|
|
1474
2801
|
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.
|
|
2802
|
+
var getDataTableWidth = (columns, utilityColumns = 0) => tableLayoutWidth(columns.map(({ width }) => width), utilityColumns);
|
|
1476
2803
|
var buildDataTableRows = (rowData, columns, getRowId) => {
|
|
1477
2804
|
const ids = new Set;
|
|
1478
2805
|
return rowData.map((data, index) => {
|
|
@@ -1492,58 +2819,20 @@ var buildDataTableRows = (rowData, columns, getRowId) => {
|
|
|
1492
2819
|
};
|
|
1493
2820
|
});
|
|
1494
2821
|
};
|
|
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({
|
|
2822
|
+
var NumberValue = Schema6.Finite.annotate({
|
|
1524
2823
|
identifier: "DataTableNumberValue"
|
|
1525
2824
|
});
|
|
1526
|
-
var BooleanValue =
|
|
2825
|
+
var BooleanValue = Schema6.Boolean.annotate({
|
|
1527
2826
|
identifier: "DataTableBooleanValue"
|
|
1528
2827
|
});
|
|
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
|
|
2828
|
+
var decodeNumberValue = Schema6.decodeUnknownOption(NumberValue);
|
|
2829
|
+
var decodeBooleanValue = Schema6.decodeUnknownOption(BooleanValue);
|
|
2830
|
+
var scalarText = Schema6.is(Schema6.Union([
|
|
2831
|
+
Schema6.String,
|
|
2832
|
+
Schema6.Finite,
|
|
2833
|
+
Schema6.Boolean,
|
|
2834
|
+
Schema6.BigInt,
|
|
2835
|
+
Schema6.Symbol
|
|
1547
2836
|
]));
|
|
1548
2837
|
var dataTableValueText = (value) => value == null ? "" : scalarText(value) ? String(value) : Formatter.format(value);
|
|
1549
2838
|
var booleanLabel = (value, options) => value ? options?.trueLabel : options?.falseLabel;
|
|
@@ -1551,13 +2840,13 @@ var getDataTableExportValue = (row, column, locale = "en") => {
|
|
|
1551
2840
|
const value = row.values.get(column.id);
|
|
1552
2841
|
const colDef = column.colDef;
|
|
1553
2842
|
if (colDef.type === "number") {
|
|
1554
|
-
const number =
|
|
2843
|
+
const number = Option4.getOrUndefined(decodeNumberValue(value));
|
|
1555
2844
|
if (number === undefined)
|
|
1556
2845
|
return null;
|
|
1557
2846
|
return colDef.typeOptions?.exportFormat === "formatted" ? formatNumberValue(number, colDef.typeOptions, locale) : number;
|
|
1558
2847
|
}
|
|
1559
2848
|
if (colDef.type === "boolean") {
|
|
1560
|
-
const boolean =
|
|
2849
|
+
const boolean = Option4.getOrUndefined(decodeBooleanValue(value));
|
|
1561
2850
|
if (boolean === undefined)
|
|
1562
2851
|
return null;
|
|
1563
2852
|
return colDef.typeOptions?.exportFormat === "formatted" ? booleanLabel(boolean, colDef.typeOptions) ?? String(boolean) : boolean;
|
|
@@ -1582,10 +2871,10 @@ var filterDataTableRows = (rows, columns, globalFilter, locale = "en") => {
|
|
|
1582
2871
|
const date = resolveDate(value, colDef.type);
|
|
1583
2872
|
text = date ? `${formatDateValue(date, colDef, locale)} ${dateIsoValue(date)}` : "";
|
|
1584
2873
|
} else if (colDef.type === "number") {
|
|
1585
|
-
const number =
|
|
2874
|
+
const number = Option4.getOrUndefined(decodeNumberValue(value));
|
|
1586
2875
|
text = number === undefined ? "" : `${formatNumberValue(number, colDef.typeOptions, locale)} ${number}`;
|
|
1587
2876
|
} else if (colDef.type === "boolean") {
|
|
1588
|
-
const boolean =
|
|
2877
|
+
const boolean = Option4.getOrUndefined(decodeBooleanValue(value));
|
|
1589
2878
|
text = boolean === undefined ? "" : `${booleanLabel(boolean, colDef.typeOptions) ?? ""} ${boolean}`;
|
|
1590
2879
|
}
|
|
1591
2880
|
return text.toLocaleLowerCase().includes(query);
|
|
@@ -1594,7 +2883,7 @@ var filterDataTableRows = (rows, columns, globalFilter, locale = "en") => {
|
|
|
1594
2883
|
var getDataTableFilterColumns = (columns) => columns.flatMap((column) => column.colDef.filterable === false ? [] : ((column.colDef.fields?.length) ? getDataTableFieldColumns(column) : [column]).filter(({ colDef }) => colDef.filterable !== false));
|
|
1595
2884
|
var getDataTableFilterKind = ({
|
|
1596
2885
|
colDef
|
|
1597
|
-
}) => colDef
|
|
2886
|
+
}) => tableFilterKind(colDef, !!colDef.filterOptions);
|
|
1598
2887
|
var getDataTableFilterOptions = (rows, column) => {
|
|
1599
2888
|
const { colDef } = column;
|
|
1600
2889
|
if (colDef.filterOptions)
|
|
@@ -1622,39 +2911,8 @@ var filterDataTableColumnRows = (rows, columns, filters) => {
|
|
|
1622
2911
|
rowIndex: row.index,
|
|
1623
2912
|
colDef: column.colDef
|
|
1624
2913
|
}) : 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
|
-
}
|
|
2914
|
+
const { colDef } = column;
|
|
2915
|
+
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
2916
|
}));
|
|
1659
2917
|
};
|
|
1660
2918
|
var sortDataTableRows = (rows, columns, sorting) => {
|
|
@@ -1670,49 +2928,19 @@ var sortDataTableRows = (rows, columns, sorting) => {
|
|
|
1670
2928
|
const leftValue = left.row.values.get(sort.id);
|
|
1671
2929
|
const rightValue = right.row.values.get(sort.id);
|
|
1672
2930
|
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);
|
|
2931
|
+
if (!colDef.comparator && (colDef.type === "number" || colDef.type === "boolean" || colDef.type === "date" || colDef.type === "dateTime")) {
|
|
2932
|
+
const comparison = compareTableSortValues(tableSortScalar(colDef.type, leftValue), tableSortScalar(colDef.type, rightValue), sort.direction, colDef.typeOptions?.nulls);
|
|
1697
2933
|
if (comparison !== 0)
|
|
1698
|
-
return
|
|
2934
|
+
return comparison;
|
|
1699
2935
|
continue;
|
|
1700
2936
|
}
|
|
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 :
|
|
2937
|
+
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
2938
|
if (comparison !== 0)
|
|
1703
2939
|
return sort.direction === "desc" ? -comparison : comparison;
|
|
1704
2940
|
}
|
|
1705
2941
|
return left.stableIndex - right.stableIndex;
|
|
1706
2942
|
}).map(({ row }) => row);
|
|
1707
2943
|
};
|
|
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
2944
|
var reorderDataTableRows = (rows, sourceRowId, targetRowId) => {
|
|
1717
2945
|
const sourceIndex = rows.findIndex((row) => row.id === sourceRowId);
|
|
1718
2946
|
const targetIndex = rows.findIndex((row) => row.id === targetRowId);
|
|
@@ -1758,7 +2986,7 @@ var clearDragPresentation = (root) => {
|
|
|
1758
2986
|
element.removeAttribute("data-drop-position");
|
|
1759
2987
|
});
|
|
1760
2988
|
};
|
|
1761
|
-
var resolveConfig = (props
|
|
2989
|
+
var resolveConfig = (props) => {
|
|
1762
2990
|
const features = props.features ?? {};
|
|
1763
2991
|
const selection = features.selection;
|
|
1764
2992
|
const getRowId = selection && selection.getRowId || props.getRowId || undefined;
|
|
@@ -1767,8 +2995,6 @@ var resolveConfig = (props, onUiStateChange) => {
|
|
|
1767
2995
|
}
|
|
1768
2996
|
return {
|
|
1769
2997
|
getRowId,
|
|
1770
|
-
onStateChange: props.onStateChange,
|
|
1771
|
-
onUiStateChange,
|
|
1772
2998
|
status: props.status ?? {},
|
|
1773
2999
|
features,
|
|
1774
3000
|
onRowClicked: props.onRowClicked,
|
|
@@ -1783,83 +3009,39 @@ var queryFromState = (state) => ({
|
|
|
1783
3009
|
filters: state.filters,
|
|
1784
3010
|
sort: state.sort
|
|
1785
3011
|
});
|
|
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
3012
|
var buildDataTableModel = (store) => {
|
|
1801
3013
|
const columns = normalizeDataTableColumns(store.columnDefs, store.state.columnSizing);
|
|
1802
3014
|
const selection = store.config.features.selection;
|
|
1803
3015
|
const rowId = selection && selection.getRowId || store.config.getRowId || undefined;
|
|
1804
3016
|
const rows = buildDataTableRows(store.rowData, columns, rowId);
|
|
1805
|
-
const
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
3017
|
+
const page = projectDataTableRows(rows, store.state, {
|
|
3018
|
+
pagination: store.config.features.pagination,
|
|
3019
|
+
grouped: getActiveGrouping(store).length > 0,
|
|
3020
|
+
search: (rows, value) => filterDataTableRows(rows, columns, value, store.config.locale),
|
|
3021
|
+
filter: (rows, filters) => filterDataTableColumnRows(rows, columns, filters),
|
|
3022
|
+
sort: (rows, sorting) => sortDataTableRows(rows, columns, sorting)
|
|
3023
|
+
});
|
|
1811
3024
|
return {
|
|
1812
3025
|
columns,
|
|
1813
3026
|
visibleColumns: columns.filter(({ id }) => store.state.columnVisibility[id] !== false),
|
|
1814
3027
|
rows,
|
|
1815
|
-
filteredRows,
|
|
1816
|
-
sortedRows,
|
|
1817
|
-
pageRows,
|
|
1818
|
-
|
|
1819
|
-
|
|
3028
|
+
filteredRows: page.filtered,
|
|
3029
|
+
sortedRows: page.ordered,
|
|
3030
|
+
pageRows: page.rows,
|
|
3031
|
+
page: page.page,
|
|
3032
|
+
pageCount: page.pageCount,
|
|
3033
|
+
paginationVisible: page.paginationVisible,
|
|
3034
|
+
totalRows: page.totalRows
|
|
1820
3035
|
};
|
|
1821
3036
|
};
|
|
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
3037
|
var deriveModel = (store) => store.model;
|
|
1842
3038
|
var groupDataTableRows = (rows, fields, depth = 0, parentKey = "") => {
|
|
1843
3039
|
const field = fields[0];
|
|
1844
3040
|
if (!field)
|
|
1845
3041
|
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
|
-
});
|
|
3042
|
+
const groups = partitionTableGroups(rows, field.getGroupIds?.() ?? [], (row) => field.getRowGroupIds?.(row.data) ?? [field.getGroupId(row.data)]);
|
|
1860
3043
|
return Array.from(groups, ([groupId, groupRows]) => {
|
|
1861
|
-
const
|
|
1862
|
-
const key = `${parentKey}${parentKey ? "/" : ""}${segment}`;
|
|
3044
|
+
const key = tableGroupKey(parentKey, field.id, groupId);
|
|
1863
3045
|
return {
|
|
1864
3046
|
key,
|
|
1865
3047
|
groupId,
|
|
@@ -1870,15 +3052,9 @@ var groupDataTableRows = (rows, fields, depth = 0, parentKey = "") => {
|
|
|
1870
3052
|
};
|
|
1871
3053
|
});
|
|
1872
3054
|
};
|
|
1873
|
-
var getDataTableSelectableRows = (model, grouped, isRowSelectable) => (grouped ? model.sortedRows : model.pageRows).filter((row) => isRowSelectable?.(row.data) ?? true);
|
|
1874
3055
|
var getActiveGrouping = (store) => {
|
|
1875
3056
|
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
|
-
});
|
|
3057
|
+
return activeTableGroups(store.state.grouping, grouping && grouping.fields || []);
|
|
1882
3058
|
};
|
|
1883
3059
|
var canReorderRows = (store) => {
|
|
1884
3060
|
const pagination = store.config.features.pagination;
|
|
@@ -1915,7 +3091,7 @@ var renderCell = (row, column, locale = "en", labels = dataTableMessages(locale)
|
|
|
1915
3091
|
if (colDef.type === "number") {
|
|
1916
3092
|
if (colDef.valueFormatter)
|
|
1917
3093
|
return colDef.valueFormatter(params);
|
|
1918
|
-
const number =
|
|
3094
|
+
const number = Option4.getOrUndefined(decodeNumberValue(value));
|
|
1919
3095
|
return /* @__PURE__ */ jsx15("span", {
|
|
1920
3096
|
className: "block text-left tabular-nums",
|
|
1921
3097
|
children: number === undefined ? colDef.typeOptions?.emptyLabel ?? "—" : formatNumberValue(number, colDef.typeOptions, locale)
|
|
@@ -1924,7 +3100,7 @@ var renderCell = (row, column, locale = "en", labels = dataTableMessages(locale)
|
|
|
1924
3100
|
if (colDef.type === "boolean") {
|
|
1925
3101
|
if (colDef.valueFormatter)
|
|
1926
3102
|
return colDef.valueFormatter(params);
|
|
1927
|
-
const boolean =
|
|
3103
|
+
const boolean = Option4.getOrUndefined(decodeBooleanValue(value));
|
|
1928
3104
|
if (boolean === undefined)
|
|
1929
3105
|
return colDef.typeOptions?.emptyLabel ?? "—";
|
|
1930
3106
|
const options = colDef.typeOptions;
|
|
@@ -1987,37 +3163,25 @@ var renderCell = (row, column, locale = "en", labels = dataTableMessages(locale)
|
|
|
1987
3163
|
return column.colDef.valueFormatter?.(params) ?? (value === null || value === undefined ? null : dataTableValueText(value));
|
|
1988
3164
|
};
|
|
1989
3165
|
var nodeText = (node) => {
|
|
1990
|
-
if (
|
|
3166
|
+
if (Schema6.is(Schema6.String)(node) || Schema6.is(Schema6.Finite)(node))
|
|
1991
3167
|
return String(node);
|
|
1992
3168
|
if (!isValidElement(node))
|
|
1993
3169
|
return "";
|
|
1994
|
-
if (
|
|
3170
|
+
if (Schema6.is(Schema6.String)(node.props.title))
|
|
1995
3171
|
return node.props.title;
|
|
1996
3172
|
return nodeText(node.props.children);
|
|
1997
3173
|
};
|
|
1998
3174
|
var columnLabel = (column) => nodeText(column.colDef.headerName) || column.id;
|
|
1999
|
-
var withExtension = (fileName, extension) => fileName.includes(".") ? fileName.replace(/\.[^/.]+$/, `.${extension}`) : `${fileName}.${extension}`;
|
|
2000
3175
|
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));
|
|
3176
|
+
downloadTableBlob(encodeTableCsv(headers, data), "text/csv;charset=utf-8", tableExportFilename(fileName, "csv"));
|
|
2015
3177
|
};
|
|
3178
|
+
var downloadJson = (data, fileName = "data.json") => downloadTableBlob(JSON.stringify(data, null, 2), "application/json;charset=utf-8", tableExportFilename(fileName, "json"));
|
|
2016
3179
|
var DataTableRowActions = ({
|
|
2017
3180
|
actions,
|
|
2018
3181
|
row,
|
|
2019
3182
|
title
|
|
2020
3183
|
}) => {
|
|
3184
|
+
const tableClasses = useContext(DataTableSlotClassesContext);
|
|
2021
3185
|
const visible = actions.filter((action) => !action.visible || action.visible(row));
|
|
2022
3186
|
if (!visible.length)
|
|
2023
3187
|
return null;
|
|
@@ -2026,7 +3190,7 @@ var DataTableRowActions = ({
|
|
|
2026
3190
|
/* @__PURE__ */ jsx15(DropdownMenuTrigger2, {
|
|
2027
3191
|
onClick: (event) => event.stopPropagation(),
|
|
2028
3192
|
render: /* @__PURE__ */ jsxs9(Button, {
|
|
2029
|
-
className: "
|
|
3193
|
+
className: cn(tableClasses.actionTrigger, "[&_svg:not([class*='size-'])]:size-4"),
|
|
2030
3194
|
size: "icon",
|
|
2031
3195
|
variant: "ghost",
|
|
2032
3196
|
children: [
|
|
@@ -2065,10 +3229,10 @@ var DataTableRowActions = ({
|
|
|
2065
3229
|
});
|
|
2066
3230
|
};
|
|
2067
3231
|
var DataTableRowActionMenu = ({
|
|
2068
|
-
|
|
3232
|
+
table,
|
|
2069
3233
|
row
|
|
2070
3234
|
}) => {
|
|
2071
|
-
const [store] =
|
|
3235
|
+
const [store] = table;
|
|
2072
3236
|
const rowId = row.id;
|
|
2073
3237
|
const rowActions = store.config.features.rowActions || undefined;
|
|
2074
3238
|
const reordering = store.config.features.reordering;
|
|
@@ -2102,12 +3266,12 @@ var DataTableRowActionMenu = ({
|
|
|
2102
3266
|
});
|
|
2103
3267
|
};
|
|
2104
3268
|
var DataTableToolbar = ({
|
|
2105
|
-
|
|
3269
|
+
table
|
|
2106
3270
|
}) => {
|
|
2107
|
-
const
|
|
3271
|
+
const tableClasses = useContext(DataTableSlotClassesContext);
|
|
3272
|
+
const [store, send] = table;
|
|
2108
3273
|
const exportPending = useRef(false);
|
|
2109
|
-
const
|
|
2110
|
-
const [exportFailed, setExportFailed] = useState(false);
|
|
3274
|
+
const { exporting, exportFailed } = store.ui;
|
|
2111
3275
|
const { features, labels } = store.config;
|
|
2112
3276
|
const model = deriveModel(store);
|
|
2113
3277
|
const selectedRows = getSelectedRows(store, model);
|
|
@@ -2117,7 +3281,6 @@ var DataTableToolbar = ({
|
|
|
2117
3281
|
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
3282
|
if (!hasToolbar)
|
|
2119
3283
|
return null;
|
|
2120
|
-
const update = (next) => changeState(setStore, next);
|
|
2121
3284
|
const visibleBulkActions = bulkActions ? bulkActions.items.filter((action) => !action.visible || action.visible(selectedRows)) : [];
|
|
2122
3285
|
const exportRows = features.export && features.export.scope === "currentPage" ? model.pageRows : model.sortedRows;
|
|
2123
3286
|
const exportColumns = getDataTableExportColumns(model.visibleColumns);
|
|
@@ -2129,46 +3292,38 @@ var DataTableToolbar = ({
|
|
|
2129
3292
|
if (exportPending.current || action.disabled)
|
|
2130
3293
|
return;
|
|
2131
3294
|
exportPending.current = true;
|
|
2132
|
-
|
|
2133
|
-
|
|
3295
|
+
send(DataTableMessage.ExportStarted());
|
|
3296
|
+
let failed = false;
|
|
2134
3297
|
try {
|
|
2135
3298
|
await action.onExport();
|
|
2136
3299
|
} catch (error) {
|
|
2137
|
-
|
|
3300
|
+
failed = true;
|
|
2138
3301
|
if (exportFeature)
|
|
2139
3302
|
exportFeature.onError?.(error, action);
|
|
2140
3303
|
} finally {
|
|
2141
3304
|
exportPending.current = false;
|
|
2142
|
-
|
|
3305
|
+
send(DataTableMessage.ExportFinished({ failed }));
|
|
2143
3306
|
}
|
|
2144
3307
|
};
|
|
2145
3308
|
return /* @__PURE__ */ jsxs9("div", {
|
|
2146
|
-
className: cn("
|
|
3309
|
+
className: cn(tableClasses.toolbar, "pb-4"),
|
|
2147
3310
|
children: [
|
|
2148
3311
|
features.search !== false ? /* @__PURE__ */ jsxs9("div", {
|
|
2149
|
-
className:
|
|
3312
|
+
className: tableClasses.toolbarSearch,
|
|
2150
3313
|
children: [
|
|
2151
3314
|
/* @__PURE__ */ jsx15(Search, {
|
|
2152
3315
|
className: "text-muted-foreground pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2"
|
|
2153
3316
|
}),
|
|
2154
3317
|
/* @__PURE__ */ jsx15(Input2, {
|
|
2155
3318
|
className: "px-9",
|
|
2156
|
-
onChange: (event) =>
|
|
2157
|
-
...state,
|
|
2158
|
-
globalFilter: event.target.value,
|
|
2159
|
-
page: 0
|
|
2160
|
-
})),
|
|
3319
|
+
onChange: (event) => send(DataTableMessage.SearchChanged({ value: event.target.value })),
|
|
2161
3320
|
placeholder: labels.filter,
|
|
2162
3321
|
value: store.state.globalFilter ?? ""
|
|
2163
3322
|
}),
|
|
2164
3323
|
store.state.globalFilter ? /* @__PURE__ */ jsx15(Button, {
|
|
2165
3324
|
"aria-label": labels.filter,
|
|
2166
3325
|
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
|
-
})),
|
|
3326
|
+
onClick: () => send(DataTableMessage.SearchChanged({ value: "" })),
|
|
2172
3327
|
size: "icon",
|
|
2173
3328
|
variant: "ghost",
|
|
2174
3329
|
children: /* @__PURE__ */ jsx15(X, {})
|
|
@@ -2176,19 +3331,19 @@ var DataTableToolbar = ({
|
|
|
2176
3331
|
]
|
|
2177
3332
|
}) : null,
|
|
2178
3333
|
/* @__PURE__ */ jsx15("div", {
|
|
2179
|
-
className:
|
|
3334
|
+
className: tableClasses.toolbarMenus,
|
|
2180
3335
|
children: /* @__PURE__ */ jsxs9(Menubar2, {
|
|
2181
3336
|
modal: false,
|
|
2182
|
-
className: "
|
|
3337
|
+
className: cn(tableClasses.menubar, "[&_[data-slot=menubar-trigger]]:gap-2 [&_[data-slot=menubar-trigger]_svg]:size-4"),
|
|
2183
3338
|
children: [
|
|
2184
3339
|
visibleBulkActions.length ? /* @__PURE__ */ jsxs9(MenubarMenu, {
|
|
2185
3340
|
children: [
|
|
2186
3341
|
/* @__PURE__ */ jsxs9(MenubarTrigger2, {
|
|
2187
|
-
className: "
|
|
3342
|
+
className: cn(tableClasses.selectedTrigger, "aria-expanded:bg-primary/90"),
|
|
2188
3343
|
children: [
|
|
2189
3344
|
labels.selected,
|
|
2190
|
-
/* @__PURE__ */ jsx15(
|
|
2191
|
-
|
|
3345
|
+
/* @__PURE__ */ jsx15("span", {
|
|
3346
|
+
className: tableClasses.count,
|
|
2192
3347
|
children: selectedRows.length
|
|
2193
3348
|
}),
|
|
2194
3349
|
/* @__PURE__ */ jsx15(ChevronDown, {})
|
|
@@ -2218,7 +3373,7 @@ var DataTableToolbar = ({
|
|
|
2218
3373
|
}) : null,
|
|
2219
3374
|
toolbar && toolbar.items,
|
|
2220
3375
|
features.filtering !== false ? /* @__PURE__ */ jsx15(FilterMenu, {
|
|
2221
|
-
|
|
3376
|
+
table
|
|
2222
3377
|
}) : null,
|
|
2223
3378
|
grouping ? /* @__PURE__ */ jsxs9(MenubarMenu, {
|
|
2224
3379
|
children: [
|
|
@@ -2242,10 +3397,7 @@ var DataTableToolbar = ({
|
|
|
2242
3397
|
/* @__PURE__ */ jsx15(MenubarSeparator2, {}),
|
|
2243
3398
|
grouping.fields.map((field) => /* @__PURE__ */ jsx15(MenubarCheckboxItem2, {
|
|
2244
3399
|
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
|
-
})),
|
|
3400
|
+
onCheckedChange: () => send(DataTableMessage.GroupingToggled({ fieldId: field.id })),
|
|
2249
3401
|
children: field.label
|
|
2250
3402
|
}, field.id))
|
|
2251
3403
|
]
|
|
@@ -2254,13 +3406,13 @@ var DataTableToolbar = ({
|
|
|
2254
3406
|
]
|
|
2255
3407
|
}) : null,
|
|
2256
3408
|
features.sorting !== false ? /* @__PURE__ */ jsx15(SortMenu, {
|
|
2257
|
-
|
|
3409
|
+
table
|
|
2258
3410
|
}) : null,
|
|
2259
3411
|
features.gallery ? /* @__PURE__ */ jsx15(ViewMenu, {
|
|
2260
|
-
|
|
3412
|
+
table
|
|
2261
3413
|
}) : null,
|
|
2262
3414
|
features.columnVisibility !== false ? /* @__PURE__ */ jsx15(ColumnMenu, {
|
|
2263
|
-
|
|
3415
|
+
table
|
|
2264
3416
|
}) : null,
|
|
2265
3417
|
features.refresh ? /* @__PURE__ */ jsx15(MenubarMenu, {
|
|
2266
3418
|
children: /* @__PURE__ */ jsxs9(MenubarTrigger2, {
|
|
@@ -2341,18 +3493,12 @@ var DataTableToolbar = ({
|
|
|
2341
3493
|
}),
|
|
2342
3494
|
exportFeature && exportFailed ? /* @__PURE__ */ jsx15("p", {
|
|
2343
3495
|
role: "alert",
|
|
2344
|
-
className: "text-destructive
|
|
3496
|
+
className: "text-destructive basis-full text-sm",
|
|
2345
3497
|
children: labels.exportFailed ?? dataTableMessages(store.config.locale).exportFailed
|
|
2346
3498
|
}) : null
|
|
2347
3499
|
]
|
|
2348
3500
|
});
|
|
2349
3501
|
};
|
|
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
3502
|
var FilterEditor = ({
|
|
2357
3503
|
column,
|
|
2358
3504
|
rows,
|
|
@@ -2362,9 +3508,8 @@ var FilterEditor = ({
|
|
|
2362
3508
|
}) => {
|
|
2363
3509
|
const inputId = useId2();
|
|
2364
3510
|
const kind = getDataTableFilterKind(column);
|
|
2365
|
-
const [
|
|
2366
|
-
const
|
|
2367
|
-
const [operator, setOperator] = useState(current?.kind === "text" ? current.operator : "contains");
|
|
3511
|
+
const [draft, setDraft] = useState(() => tableFilterDraft(column.id, current));
|
|
3512
|
+
const { primary, secondary, operator } = draft;
|
|
2368
3513
|
const operatorOptions = [
|
|
2369
3514
|
{ value: "contains", label: labels.filterContains },
|
|
2370
3515
|
{ value: "equals", label: labels.filterEquals },
|
|
@@ -2374,8 +3519,8 @@ var FilterEditor = ({
|
|
|
2374
3519
|
const [invalid, setInvalid] = useState(false);
|
|
2375
3520
|
const [optionSearch, setOptionSearch] = useState("");
|
|
2376
3521
|
const apply = (candidate) => {
|
|
2377
|
-
const decoded =
|
|
2378
|
-
if (
|
|
3522
|
+
const decoded = parseTableFilterDraft(kind, candidate);
|
|
3523
|
+
if (Option4.isNone(decoded)) {
|
|
2379
3524
|
setInvalid(true);
|
|
2380
3525
|
return;
|
|
2381
3526
|
}
|
|
@@ -2387,7 +3532,7 @@ var FilterEditor = ({
|
|
|
2387
3532
|
children: [
|
|
2388
3533
|
/* @__PURE__ */ jsxs9(MenubarRadioGroup, {
|
|
2389
3534
|
value: current?.kind === "boolean" ? String(current.value) : "",
|
|
2390
|
-
onValueChange: (value) => apply({
|
|
3535
|
+
onValueChange: (value) => apply({ ...draft, primary: value }),
|
|
2391
3536
|
children: [
|
|
2392
3537
|
/* @__PURE__ */ jsx15(MenubarRadioItem2, {
|
|
2393
3538
|
value: "true",
|
|
@@ -2433,9 +3578,9 @@ var FilterEditor = ({
|
|
|
2433
3578
|
checked: selected.includes(option.value),
|
|
2434
3579
|
closeOnClick: false,
|
|
2435
3580
|
onCheckedChange: (checked) => {
|
|
2436
|
-
const values =
|
|
3581
|
+
const values = updateSelectedRows(selected, [option.value], checked);
|
|
2437
3582
|
if (values.length)
|
|
2438
|
-
apply({
|
|
3583
|
+
apply({ ...draft, values });
|
|
2439
3584
|
else
|
|
2440
3585
|
onChange(undefined);
|
|
2441
3586
|
},
|
|
@@ -2472,29 +3617,7 @@ var FilterEditor = ({
|
|
|
2472
3617
|
},
|
|
2473
3618
|
onSubmit: (event) => {
|
|
2474
3619
|
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
|
-
}
|
|
3620
|
+
apply(draft);
|
|
2498
3621
|
},
|
|
2499
3622
|
children: [
|
|
2500
3623
|
/* @__PURE__ */ jsxs9(FieldGroup, {
|
|
@@ -2509,9 +3632,9 @@ var FilterEditor = ({
|
|
|
2509
3632
|
items: operatorOptions,
|
|
2510
3633
|
value: operator,
|
|
2511
3634
|
onValueChange: (value) => {
|
|
2512
|
-
const decoded =
|
|
2513
|
-
if (
|
|
2514
|
-
|
|
3635
|
+
const decoded = Schema6.decodeUnknownOption(TextFilterOperator)(value);
|
|
3636
|
+
if (Option4.isSome(decoded))
|
|
3637
|
+
setDraft({ ...draft, operator: decoded.value });
|
|
2515
3638
|
},
|
|
2516
3639
|
children: [
|
|
2517
3640
|
/* @__PURE__ */ jsx15(SelectTrigger, {
|
|
@@ -2544,7 +3667,7 @@ var FilterEditor = ({
|
|
|
2544
3667
|
value: primary,
|
|
2545
3668
|
"aria-invalid": invalid || undefined,
|
|
2546
3669
|
onChange: (event) => {
|
|
2547
|
-
|
|
3670
|
+
setDraft({ ...draft, primary: event.target.value });
|
|
2548
3671
|
setInvalid(false);
|
|
2549
3672
|
}
|
|
2550
3673
|
})
|
|
@@ -2564,7 +3687,7 @@ var FilterEditor = ({
|
|
|
2564
3687
|
value: secondary,
|
|
2565
3688
|
"aria-invalid": invalid || undefined,
|
|
2566
3689
|
onChange: (event) => {
|
|
2567
|
-
|
|
3690
|
+
setDraft({ ...draft, secondary: event.target.value });
|
|
2568
3691
|
setInvalid(false);
|
|
2569
3692
|
}
|
|
2570
3693
|
})
|
|
@@ -2590,8 +3713,7 @@ var FilterEditor = ({
|
|
|
2590
3713
|
size: "sm",
|
|
2591
3714
|
variant: "outline",
|
|
2592
3715
|
onClick: () => {
|
|
2593
|
-
|
|
2594
|
-
setSecondary("");
|
|
3716
|
+
setDraft({ ...draft, primary: "", secondary: "" });
|
|
2595
3717
|
setInvalid(false);
|
|
2596
3718
|
onChange(undefined);
|
|
2597
3719
|
},
|
|
@@ -2603,9 +3725,9 @@ var FilterEditor = ({
|
|
|
2603
3725
|
});
|
|
2604
3726
|
};
|
|
2605
3727
|
var FilterMenu = ({
|
|
2606
|
-
|
|
3728
|
+
table
|
|
2607
3729
|
}) => {
|
|
2608
|
-
const [store,
|
|
3730
|
+
const [store, send] = table;
|
|
2609
3731
|
const model = deriveModel(store);
|
|
2610
3732
|
const columns = model.columns.flatMap((parent) => getDataTableFilterColumns([parent]).map((column) => ({
|
|
2611
3733
|
column,
|
|
@@ -2614,7 +3736,7 @@ var FilterMenu = ({
|
|
|
2614
3736
|
if (!columns.length)
|
|
2615
3737
|
return null;
|
|
2616
3738
|
const filters = store.state.filters ?? [];
|
|
2617
|
-
const update = (id, filter) =>
|
|
3739
|
+
const update = (id, filter) => send(DataTableMessage.ColumnFilterChanged({ id, filter: filter ?? null }));
|
|
2618
3740
|
return /* @__PURE__ */ jsxs9(MenubarMenu, {
|
|
2619
3741
|
children: [
|
|
2620
3742
|
/* @__PURE__ */ jsxs9(MenubarTrigger2, {
|
|
@@ -2667,11 +3789,7 @@ var FilterMenu = ({
|
|
|
2667
3789
|
children: [
|
|
2668
3790
|
/* @__PURE__ */ jsx15(MenubarSeparator2, {}),
|
|
2669
3791
|
/* @__PURE__ */ jsxs9(MenubarItem2, {
|
|
2670
|
-
onClick: () =>
|
|
2671
|
-
...state,
|
|
2672
|
-
page: 0,
|
|
2673
|
-
filters: undefined
|
|
2674
|
-
})),
|
|
3792
|
+
onClick: () => send(DataTableMessage.FiltersCleared()),
|
|
2675
3793
|
children: [
|
|
2676
3794
|
/* @__PURE__ */ jsx15(X, {}),
|
|
2677
3795
|
store.config.labels.filtersClear
|
|
@@ -2686,9 +3804,9 @@ var FilterMenu = ({
|
|
|
2686
3804
|
});
|
|
2687
3805
|
};
|
|
2688
3806
|
var SortMenu = ({
|
|
2689
|
-
|
|
3807
|
+
table
|
|
2690
3808
|
}) => {
|
|
2691
|
-
const [store,
|
|
3809
|
+
const [store, send] = table;
|
|
2692
3810
|
const columns = deriveModel(store).columns.flatMap((column) => getDataTableSortColumns([column]).map((field) => field.id === column.id ? field : {
|
|
2693
3811
|
...field,
|
|
2694
3812
|
colDef: {
|
|
@@ -2699,11 +3817,7 @@ var SortMenu = ({
|
|
|
2699
3817
|
if (!columns.length)
|
|
2700
3818
|
return null;
|
|
2701
3819
|
const current = store.state.sort?.[0];
|
|
2702
|
-
const sort = (id, direction) =>
|
|
2703
|
-
...state,
|
|
2704
|
-
sort: [{ id, direction }],
|
|
2705
|
-
page: 0
|
|
2706
|
-
}));
|
|
3820
|
+
const sort = (id, direction) => send(DataTableMessage.SortRequested({ columnId: id, direction }));
|
|
2707
3821
|
return /* @__PURE__ */ jsxs9(MenubarMenu, {
|
|
2708
3822
|
children: [
|
|
2709
3823
|
/* @__PURE__ */ jsxs9(MenubarTrigger2, {
|
|
@@ -2757,9 +3871,9 @@ var SortMenu = ({
|
|
|
2757
3871
|
children: [
|
|
2758
3872
|
/* @__PURE__ */ jsx15(MenubarSeparator2, {}),
|
|
2759
3873
|
/* @__PURE__ */ jsxs9(MenubarItem2, {
|
|
2760
|
-
onClick: () =>
|
|
2761
|
-
|
|
2762
|
-
|
|
3874
|
+
onClick: () => send(DataTableMessage.SortRequested({
|
|
3875
|
+
columnId: column.id,
|
|
3876
|
+
direction: null
|
|
2763
3877
|
})),
|
|
2764
3878
|
children: [
|
|
2765
3879
|
/* @__PURE__ */ jsx15(X, {}),
|
|
@@ -2781,9 +3895,9 @@ var SortMenu = ({
|
|
|
2781
3895
|
});
|
|
2782
3896
|
};
|
|
2783
3897
|
var ViewMenu = ({
|
|
2784
|
-
|
|
3898
|
+
table
|
|
2785
3899
|
}) => {
|
|
2786
|
-
const [store,
|
|
3900
|
+
const [store, send] = table;
|
|
2787
3901
|
return /* @__PURE__ */ jsxs9(MenubarMenu, {
|
|
2788
3902
|
children: [
|
|
2789
3903
|
/* @__PURE__ */ jsxs9(MenubarTrigger2, {
|
|
@@ -2806,12 +3920,9 @@ var ViewMenu = ({
|
|
|
2806
3920
|
/* @__PURE__ */ jsx15(MenubarSeparator2, {}),
|
|
2807
3921
|
/* @__PURE__ */ jsxs9(MenubarRadioGroup, {
|
|
2808
3922
|
onValueChange: (input) => {
|
|
2809
|
-
const view =
|
|
2810
|
-
if (
|
|
2811
|
-
|
|
2812
|
-
...state,
|
|
2813
|
-
view: view.value
|
|
2814
|
-
}));
|
|
3923
|
+
const view = Schema6.decodeUnknownOption(DataTableViewSchema)(input);
|
|
3924
|
+
if (Option4.isSome(view)) {
|
|
3925
|
+
send(DataTableMessage.ViewPicked({ view: view.value }));
|
|
2815
3926
|
}
|
|
2816
3927
|
},
|
|
2817
3928
|
value: store.state.view,
|
|
@@ -2841,9 +3952,9 @@ var ViewMenu = ({
|
|
|
2841
3952
|
});
|
|
2842
3953
|
};
|
|
2843
3954
|
var ColumnMenu = ({
|
|
2844
|
-
|
|
3955
|
+
table
|
|
2845
3956
|
}) => {
|
|
2846
|
-
const [store,
|
|
3957
|
+
const [store, send] = table;
|
|
2847
3958
|
const columns = deriveModel(store).columns.filter(({ colDef }) => colDef.hideable !== false);
|
|
2848
3959
|
if (!columns.length)
|
|
2849
3960
|
return null;
|
|
@@ -2869,13 +3980,7 @@ var ColumnMenu = ({
|
|
|
2869
3980
|
/* @__PURE__ */ jsx15(MenubarSeparator2, {}),
|
|
2870
3981
|
columns.map((column) => /* @__PURE__ */ jsx15(MenubarCheckboxItem2, {
|
|
2871
3982
|
checked: store.state.columnVisibility[column.id] !== false,
|
|
2872
|
-
onCheckedChange: (visible) =>
|
|
2873
|
-
...state,
|
|
2874
|
-
columnVisibility: {
|
|
2875
|
-
...state.columnVisibility,
|
|
2876
|
-
[column.id]: visible
|
|
2877
|
-
}
|
|
2878
|
-
})),
|
|
3983
|
+
onCheckedChange: (visible) => send(DataTableMessage.ColumnVisibilityChanged({ id: column.id, visible })),
|
|
2879
3984
|
children: columnLabel(column)
|
|
2880
3985
|
}, column.id))
|
|
2881
3986
|
]
|
|
@@ -2885,54 +3990,43 @@ var ColumnMenu = ({
|
|
|
2885
3990
|
});
|
|
2886
3991
|
};
|
|
2887
3992
|
var ResizeHandle = ({
|
|
2888
|
-
|
|
3993
|
+
table
|
|
2889
3994
|
}) => {
|
|
2890
|
-
const
|
|
3995
|
+
const tableClasses = useContext(DataTableSlotClassesContext);
|
|
3996
|
+
const [store, send] = table;
|
|
2891
3997
|
const columnId = useRequiredId(ColumnIdContext);
|
|
2892
|
-
const resizeRef = useRef(null);
|
|
2893
3998
|
const column = deriveModel(store).columns.find(({ id }) => id === columnId);
|
|
2894
3999
|
if (!column || column.colDef.resizable === false)
|
|
2895
4000
|
return null;
|
|
2896
|
-
const
|
|
2897
|
-
...state,
|
|
2898
|
-
columnSizing: {
|
|
2899
|
-
...state.columnSizing,
|
|
2900
|
-
[column.id]: clampWidth(column.colDef, width)
|
|
2901
|
-
}
|
|
2902
|
-
}));
|
|
4001
|
+
const { min, max } = tableColumnLimits(column.colDef);
|
|
2903
4002
|
const onPointerDown = (event) => {
|
|
2904
4003
|
if (event.button !== 0)
|
|
2905
4004
|
return;
|
|
2906
4005
|
event.preventDefault();
|
|
2907
4006
|
event.currentTarget.setPointerCapture(event.pointerId);
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
};
|
|
4007
|
+
send(DataTableMessage.ResizeStarted({
|
|
4008
|
+
id: column.id,
|
|
4009
|
+
x: event.clientX,
|
|
4010
|
+
pointerId: event.pointerId
|
|
4011
|
+
}));
|
|
2913
4012
|
};
|
|
2914
4013
|
const onPointerMove = (event) => {
|
|
2915
|
-
|
|
2916
|
-
if (!drag || drag.pointerId !== event.pointerId)
|
|
2917
|
-
return;
|
|
2918
|
-
resize(drag.startWidth + event.clientX - drag.startX);
|
|
2919
|
-
};
|
|
2920
|
-
const reset = () => {
|
|
2921
|
-
resizeRef.current = null;
|
|
4014
|
+
send(DataTableMessage.ResizeMoved({ x: event.clientX, pointerId: event.pointerId }));
|
|
2922
4015
|
};
|
|
4016
|
+
const reset = (event) => send(DataTableMessage.ResizeEnded({ pointerId: event.pointerId }));
|
|
2923
4017
|
return /* @__PURE__ */ jsx15("button", {
|
|
2924
4018
|
"aria-label": store.config.labels.resizeColumn(columnLabel(column)),
|
|
2925
4019
|
"aria-orientation": "vertical",
|
|
2926
|
-
"aria-valuemax":
|
|
2927
|
-
"aria-valuemin":
|
|
4020
|
+
"aria-valuemax": max,
|
|
4021
|
+
"aria-valuemin": min,
|
|
2928
4022
|
"aria-valuenow": column.width,
|
|
2929
|
-
className:
|
|
2930
|
-
onDoubleClick: () =>
|
|
4023
|
+
className: tableClasses.resizeHandle,
|
|
4024
|
+
onDoubleClick: () => send(DataTableMessage.ColumnResizeReset({ id: column.id })),
|
|
2931
4025
|
onKeyDown: (event) => {
|
|
2932
|
-
const delta = event.key
|
|
4026
|
+
const delta = tableResizeStep(event.key);
|
|
2933
4027
|
if (delta) {
|
|
2934
4028
|
event.preventDefault();
|
|
2935
|
-
|
|
4029
|
+
send(DataTableMessage.ColumnResized({ id: column.id, delta }));
|
|
2936
4030
|
}
|
|
2937
4031
|
},
|
|
2938
4032
|
onPointerDown,
|
|
@@ -2945,9 +4039,9 @@ var ResizeHandle = ({
|
|
|
2945
4039
|
});
|
|
2946
4040
|
};
|
|
2947
4041
|
var DragHandle = ({
|
|
2948
|
-
|
|
4042
|
+
table
|
|
2949
4043
|
}) => {
|
|
2950
|
-
const [store
|
|
4044
|
+
const [store] = table;
|
|
2951
4045
|
const rowId = useRequiredId(RowIdContext);
|
|
2952
4046
|
const dragRef = useRef(null);
|
|
2953
4047
|
const [overlay, setOverlay] = useState(null);
|
|
@@ -3005,7 +4099,8 @@ var DragHandle = ({
|
|
|
3005
4099
|
const elements = document.elementsFromPoint(event.clientX, event.clientY);
|
|
3006
4100
|
const rowTarget = findTableDragTarget(elements, "[data-table-row]", root);
|
|
3007
4101
|
const groupTarget = findTableDragTarget(elements, "[data-table-group]", root);
|
|
3008
|
-
|
|
4102
|
+
if (drag.active) {
|
|
4103
|
+
const current = store;
|
|
3009
4104
|
const targetRowId = rowTarget?.dataset.tableRow;
|
|
3010
4105
|
const targetGroupKey = groupTarget?.dataset.tableGroup;
|
|
3011
4106
|
const model = deriveModel(current);
|
|
@@ -3021,8 +4116,7 @@ var DragHandle = ({
|
|
|
3021
4116
|
} else if (drag.active && source && targetRowId && reordering && canReorderRows(current) && source.id !== targetRowId) {
|
|
3022
4117
|
reordering.onReorder(reorderDataTableRows(model.rows, source.id, targetRowId));
|
|
3023
4118
|
}
|
|
3024
|
-
|
|
3025
|
-
});
|
|
4119
|
+
}
|
|
3026
4120
|
reset(event.currentTarget);
|
|
3027
4121
|
};
|
|
3028
4122
|
const cancel = (event) => {
|
|
@@ -3073,22 +4167,15 @@ var DragHandle = ({
|
|
|
3073
4167
|
]
|
|
3074
4168
|
});
|
|
3075
4169
|
};
|
|
3076
|
-
var toggleRow = (
|
|
3077
|
-
const rowSelection = { ...state.rowSelection, [rowId]: selected };
|
|
3078
|
-
const selection = store.config.features.selection;
|
|
3079
|
-
if (selection) {
|
|
3080
|
-
const model = deriveModel(store);
|
|
3081
|
-
selection.onSelectionChange?.(model.rows.filter((row) => rowSelection[row.id]).map((row) => row.data));
|
|
3082
|
-
}
|
|
3083
|
-
return { ...state, rowSelection };
|
|
3084
|
-
});
|
|
4170
|
+
var toggleRow = (send, rowId, checked) => send(DataTableMessage.SelectionRequested({ rowIds: [rowId], checked }));
|
|
3085
4171
|
var TableDataRow = ({
|
|
3086
|
-
|
|
4172
|
+
table,
|
|
3087
4173
|
row,
|
|
3088
4174
|
virtualIndex,
|
|
3089
4175
|
measureRef
|
|
3090
4176
|
}) => {
|
|
3091
|
-
const
|
|
4177
|
+
const tableClasses = useContext(DataTableSlotClassesContext);
|
|
4178
|
+
const [store, send] = table;
|
|
3092
4179
|
const model = deriveModel(store);
|
|
3093
4180
|
const selection = store.config.features.selection;
|
|
3094
4181
|
const selectable = !!selection && (selection.isRowSelectable?.(row.data) ?? true);
|
|
@@ -3110,37 +4197,40 @@ var TableDataRow = ({
|
|
|
3110
4197
|
tabIndex: store.config.onRowClicked ? 0 : undefined,
|
|
3111
4198
|
children: [
|
|
3112
4199
|
selection ? /* @__PURE__ */ jsx15(TableCell2, {
|
|
3113
|
-
className:
|
|
4200
|
+
className: tableClasses.selectionCell,
|
|
3114
4201
|
onClick: (event) => event.stopPropagation(),
|
|
3115
|
-
children: /* @__PURE__ */ jsx15(
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
4202
|
+
children: /* @__PURE__ */ jsx15("div", {
|
|
4203
|
+
className: tableClasses.selectionCenter,
|
|
4204
|
+
children: /* @__PURE__ */ jsx15(Checkbox, {
|
|
4205
|
+
"aria-label": store.config.labels.selectRow,
|
|
4206
|
+
checked: !!store.state.rowSelection[row.id],
|
|
4207
|
+
disabled: !selectable,
|
|
4208
|
+
onCheckedChange: (checked) => toggleRow(send, row.id, checked)
|
|
4209
|
+
})
|
|
3120
4210
|
})
|
|
3121
4211
|
}) : null,
|
|
3122
4212
|
draggable ? /* @__PURE__ */ jsx15(TableCell2, {
|
|
3123
4213
|
className: "w-10 pr-0",
|
|
3124
4214
|
children: /* @__PURE__ */ jsx15(DragHandle, {
|
|
3125
|
-
|
|
4215
|
+
table
|
|
3126
4216
|
})
|
|
3127
4217
|
}) : null,
|
|
3128
4218
|
model.visibleColumns.map((column) => /* @__PURE__ */ jsx15(TableCell2, {
|
|
3129
|
-
className: cn("min-w-24
|
|
4219
|
+
className: cn(tableClasses.cell, "min-w-24 has-[[data-slot=data-table-boolean-cell]]:relative has-[[data-slot=data-table-boolean-cell]]:p-0 has-[[data-slot=data-table-list-cell]]:relative has-[[data-slot=data-table-list-cell]]:p-0", column.colDef.truncate ? "whitespace-nowrap" : "whitespace-normal"),
|
|
3130
4220
|
style: { width: column.width },
|
|
3131
4221
|
children: /* @__PURE__ */ jsx15("div", {
|
|
3132
|
-
className: cn(
|
|
4222
|
+
className: cn(tableClasses.cellContent, column.colDef.truncate && "truncate"),
|
|
3133
4223
|
children: renderCell(row, column, store.config.locale, store.config.labels)
|
|
3134
4224
|
})
|
|
3135
4225
|
}, column.id)),
|
|
3136
4226
|
hasRowActionMenu(store) ? /* @__PURE__ */ jsx15(TableCell2, {
|
|
3137
|
-
className: "
|
|
4227
|
+
className: cn(tableClasses.actionsCell, "group-data-[state=selected]/row:bg-muted"),
|
|
3138
4228
|
onClick: (event) => event.stopPropagation(),
|
|
3139
4229
|
children: /* @__PURE__ */ jsx15("div", {
|
|
3140
|
-
className:
|
|
4230
|
+
className: tableClasses.actionsAlign,
|
|
3141
4231
|
children: /* @__PURE__ */ jsx15(DataTableRowActionMenu, {
|
|
3142
4232
|
row,
|
|
3143
|
-
|
|
4233
|
+
table
|
|
3144
4234
|
})
|
|
3145
4235
|
})
|
|
3146
4236
|
}) : null
|
|
@@ -3190,35 +4280,30 @@ var GroupActions = ({
|
|
|
3190
4280
|
});
|
|
3191
4281
|
};
|
|
3192
4282
|
var GroupHeaderRow = ({
|
|
3193
|
-
|
|
4283
|
+
table,
|
|
3194
4284
|
section,
|
|
3195
4285
|
colSpan,
|
|
3196
4286
|
virtualIndex,
|
|
3197
4287
|
measureRef
|
|
3198
4288
|
}) => {
|
|
3199
|
-
const
|
|
4289
|
+
const tableClasses = useContext(DataTableSlotClassesContext);
|
|
4290
|
+
const [store, send] = table;
|
|
3200
4291
|
const collapsed = !!store.state.collapsedGroups[section.key];
|
|
3201
4292
|
return /* @__PURE__ */ jsx15(TableRow2, {
|
|
3202
4293
|
ref: measureRef,
|
|
3203
4294
|
"data-index": virtualIndex,
|
|
3204
4295
|
"aria-rowindex": virtualIndex === undefined ? undefined : virtualIndex + 2,
|
|
3205
|
-
className: "
|
|
3206
|
-
onClick: () =>
|
|
3207
|
-
...state,
|
|
3208
|
-
collapsedGroups: {
|
|
3209
|
-
...state.collapsedGroups,
|
|
3210
|
-
[section.key]: !collapsed
|
|
3211
|
-
}
|
|
3212
|
-
})),
|
|
4296
|
+
className: cn(tableClasses.group, "cursor-pointer"),
|
|
4297
|
+
onClick: () => send(DataTableMessage.GroupToggled({ key: section.key })),
|
|
3213
4298
|
children: /* @__PURE__ */ jsx15(TableCell2, {
|
|
3214
4299
|
className: "p-0",
|
|
3215
4300
|
colSpan,
|
|
3216
4301
|
children: /* @__PURE__ */ jsxs9("div", {
|
|
3217
|
-
className:
|
|
4302
|
+
className: cn(tableClasses.groupContent, tableClasses.groupSticky),
|
|
3218
4303
|
children: [
|
|
3219
4304
|
/* @__PURE__ */ jsxs9("button", {
|
|
3220
4305
|
"aria-expanded": !collapsed,
|
|
3221
|
-
className:
|
|
4306
|
+
className: tableClasses.groupTrigger,
|
|
3222
4307
|
style: { paddingLeft: section.depth * 20 },
|
|
3223
4308
|
type: "button",
|
|
3224
4309
|
children: [
|
|
@@ -3233,9 +4318,8 @@ var GroupHeaderRow = ({
|
|
|
3233
4318
|
})
|
|
3234
4319
|
]
|
|
3235
4320
|
}),
|
|
3236
|
-
/* @__PURE__ */ jsx15(
|
|
3237
|
-
className:
|
|
3238
|
-
variant: "secondary",
|
|
4321
|
+
/* @__PURE__ */ jsx15("span", {
|
|
4322
|
+
className: tableClasses.count,
|
|
3239
4323
|
children: section.rows.length
|
|
3240
4324
|
}),
|
|
3241
4325
|
/* @__PURE__ */ jsx15(GroupActions, {
|
|
@@ -3249,10 +4333,10 @@ var GroupHeaderRow = ({
|
|
|
3249
4333
|
});
|
|
3250
4334
|
};
|
|
3251
4335
|
var GroupedTable = ({
|
|
3252
|
-
|
|
4336
|
+
table,
|
|
3253
4337
|
sections
|
|
3254
4338
|
}) => {
|
|
3255
|
-
const [store] =
|
|
4339
|
+
const [store] = table;
|
|
3256
4340
|
const model = deriveModel(store);
|
|
3257
4341
|
const extra = (store.config.features.selection ? 1 : 0) + (hasRowActionMenu(store) ? 1 : 0) + (canDragRows(store) ? 1 : 0);
|
|
3258
4342
|
const renderSections = (items) => items.flatMap((section) => {
|
|
@@ -3263,7 +4347,7 @@ var GroupedTable = ({
|
|
|
3263
4347
|
"data-table-group": section.field.onMoveToGroup ? targetKey : undefined,
|
|
3264
4348
|
children: [
|
|
3265
4349
|
/* @__PURE__ */ jsx15(GroupHeaderRow, {
|
|
3266
|
-
|
|
4350
|
+
table,
|
|
3267
4351
|
section,
|
|
3268
4352
|
colSpan: model.visibleColumns.length + extra
|
|
3269
4353
|
}),
|
|
@@ -3271,7 +4355,7 @@ var GroupedTable = ({
|
|
|
3271
4355
|
value: row.id,
|
|
3272
4356
|
children: /* @__PURE__ */ jsx15(TableDataRow, {
|
|
3273
4357
|
row,
|
|
3274
|
-
|
|
4358
|
+
table
|
|
3275
4359
|
})
|
|
3276
4360
|
}, `${section.key}:${row.id}`)) : [
|
|
3277
4361
|
/* @__PURE__ */ jsx15(TableRow2, {
|
|
@@ -3291,9 +4375,10 @@ var GroupedTable = ({
|
|
|
3291
4375
|
});
|
|
3292
4376
|
};
|
|
3293
4377
|
var ColumnHeaderMenu = ({
|
|
3294
|
-
|
|
4378
|
+
table
|
|
3295
4379
|
}) => {
|
|
3296
|
-
const
|
|
4380
|
+
const tableClasses = useContext(DataTableSlotClassesContext);
|
|
4381
|
+
const [store, send] = table;
|
|
3297
4382
|
const columnId = useRequiredId(ColumnIdContext);
|
|
3298
4383
|
const model = deriveModel(store);
|
|
3299
4384
|
const column = model.columns.find(({ id }) => id === columnId);
|
|
@@ -3309,18 +4394,13 @@ var ColumnHeaderMenu = ({
|
|
|
3309
4394
|
rows: model.rows,
|
|
3310
4395
|
current: store.state.filters?.find((filter) => filter.id === field.id),
|
|
3311
4396
|
labels: store.config.labels,
|
|
3312
|
-
onChange: (filter) =>
|
|
4397
|
+
onChange: (filter) => send(DataTableMessage.ColumnFilterChanged({ id: field.id, filter: filter ?? null }))
|
|
3313
4398
|
});
|
|
3314
4399
|
const sortingEnabled = store.config.features.sorting !== false && sortColumns.length > 0;
|
|
3315
4400
|
const hidingEnabled = store.config.features.columnVisibility !== false && column.colDef.hideable !== false;
|
|
3316
4401
|
const ownsSort = (id) => id === column.id || sortColumns.some((field) => field.id === id);
|
|
3317
4402
|
const sort = store.state.sort?.find(({ id }) => ownsSort(id));
|
|
3318
|
-
const
|
|
3319
|
-
const setSort = (id, direction) => update((state) => ({
|
|
3320
|
-
...state,
|
|
3321
|
-
sort: [{ id, direction }],
|
|
3322
|
-
page: 0
|
|
3323
|
-
}));
|
|
4403
|
+
const setSort = (id, direction) => send(DataTableMessage.SortRequested({ columnId: id, direction }));
|
|
3324
4404
|
const label = columnLabel(column);
|
|
3325
4405
|
const sortItems = (field) => /* @__PURE__ */ jsxs9(Fragment, {
|
|
3326
4406
|
children: [
|
|
@@ -3354,7 +4434,7 @@ var ColumnHeaderMenu = ({
|
|
|
3354
4434
|
render: /* @__PURE__ */ jsxs9(Button, {
|
|
3355
4435
|
"aria-label": label,
|
|
3356
4436
|
"aria-description": activeFilters.length ? `${store.config.labels.filters}: ${activeFilters.length}` : undefined,
|
|
3357
|
-
className:
|
|
4437
|
+
className: tableClasses.headerTrigger,
|
|
3358
4438
|
variant: "ghost",
|
|
3359
4439
|
children: [
|
|
3360
4440
|
/* @__PURE__ */ jsx15("span", {
|
|
@@ -3386,10 +4466,7 @@ var ColumnHeaderMenu = ({
|
|
|
3386
4466
|
]
|
|
3387
4467
|
}, field.id)) : sortItems(column),
|
|
3388
4468
|
sort ? /* @__PURE__ */ jsxs9(DropdownMenuItem2, {
|
|
3389
|
-
onClick: () =>
|
|
3390
|
-
...state,
|
|
3391
|
-
sort: state.sort?.filter(({ id }) => !ownsSort(id))
|
|
3392
|
-
})),
|
|
4469
|
+
onClick: () => send(DataTableMessage.ColumnSortCleared({ id: column.id })),
|
|
3393
4470
|
children: [
|
|
3394
4471
|
/* @__PURE__ */ jsx15(X, {}),
|
|
3395
4472
|
" ",
|
|
@@ -3431,14 +4508,7 @@ var ColumnHeaderMenu = ({
|
|
|
3431
4508
|
]
|
|
3432
4509
|
}),
|
|
3433
4510
|
activeFilters.length ? /* @__PURE__ */ jsxs9(DropdownMenuItem2, {
|
|
3434
|
-
onClick: () =>
|
|
3435
|
-
const filters = state.filters?.filter(({ id }) => !ownsFilter(id));
|
|
3436
|
-
return {
|
|
3437
|
-
...state,
|
|
3438
|
-
page: 0,
|
|
3439
|
-
filters: filters?.length ? filters : undefined
|
|
3440
|
-
};
|
|
3441
|
-
}),
|
|
4511
|
+
onClick: () => send(DataTableMessage.ColumnFiltersCleared({ id: column.id })),
|
|
3442
4512
|
children: [
|
|
3443
4513
|
/* @__PURE__ */ jsx15(X, {}),
|
|
3444
4514
|
store.config.labels.filterClear
|
|
@@ -3448,12 +4518,9 @@ var ColumnHeaderMenu = ({
|
|
|
3448
4518
|
}) : null,
|
|
3449
4519
|
(sortingEnabled || filteringEnabled) && hidingEnabled ? /* @__PURE__ */ jsx15(DropdownMenuSeparator2, {}) : null,
|
|
3450
4520
|
hidingEnabled ? /* @__PURE__ */ jsxs9(DropdownMenuItem2, {
|
|
3451
|
-
onClick: () =>
|
|
3452
|
-
|
|
3453
|
-
|
|
3454
|
-
...state.columnVisibility,
|
|
3455
|
-
[column.id]: false
|
|
3456
|
-
}
|
|
4521
|
+
onClick: () => send(DataTableMessage.ColumnVisibilityChanged({
|
|
4522
|
+
id: column.id,
|
|
4523
|
+
visible: false
|
|
3457
4524
|
})),
|
|
3458
4525
|
children: [
|
|
3459
4526
|
/* @__PURE__ */ jsx15(EyeOff, {}),
|
|
@@ -3468,36 +4535,37 @@ var ColumnHeaderMenu = ({
|
|
|
3468
4535
|
});
|
|
3469
4536
|
};
|
|
3470
4537
|
var DataTableHeader = ({
|
|
3471
|
-
|
|
4538
|
+
table,
|
|
3472
4539
|
sticky
|
|
3473
4540
|
}) => {
|
|
3474
|
-
const
|
|
4541
|
+
const tableClasses = useContext(DataTableSlotClassesContext);
|
|
4542
|
+
const [store, send] = table;
|
|
3475
4543
|
const model = deriveModel(store);
|
|
3476
4544
|
const selection = store.config.features.selection;
|
|
3477
|
-
const grouped = getActiveGrouping(store).length > 0;
|
|
3478
4545
|
const draggable = canDragRows(store);
|
|
3479
|
-
const selectableRows =
|
|
4546
|
+
const selectableRows = model.pageRows.filter((row) => !selection || (selection.isRowSelectable?.(row.data) ?? true));
|
|
3480
4547
|
const allSelected = selectableRows.length > 0 && selectableRows.every((row) => store.state.rowSelection[row.id]);
|
|
3481
4548
|
const someSelected = selectableRows.some((row) => store.state.rowSelection[row.id]);
|
|
3482
4549
|
return /* @__PURE__ */ jsx15(TableHeader2, {
|
|
3483
|
-
className: sticky ?
|
|
4550
|
+
className: sticky ? cn(tableClasses.stickyHeader, tableClasses.stickyHeaderRule, "[&_tr]:border-b-0") : undefined,
|
|
3484
4551
|
children: /* @__PURE__ */ jsxs9(TableRow2, {
|
|
3485
4552
|
"aria-rowindex": sticky ? 1 : undefined,
|
|
3486
4553
|
children: [
|
|
3487
4554
|
selection ? /* @__PURE__ */ jsx15(TableHead2, {
|
|
3488
|
-
className:
|
|
3489
|
-
children: /* @__PURE__ */ jsx15(
|
|
3490
|
-
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
|
|
3497
|
-
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
4555
|
+
className: tableClasses.selectionCell,
|
|
4556
|
+
children: /* @__PURE__ */ jsx15("div", {
|
|
4557
|
+
className: tableClasses.selectionCenter,
|
|
4558
|
+
children: /* @__PURE__ */ jsx15(Checkbox, {
|
|
4559
|
+
"aria-label": store.config.labels.selectAllRows,
|
|
4560
|
+
checked: allSelected,
|
|
4561
|
+
indeterminate: someSelected && !allSelected,
|
|
4562
|
+
onCheckedChange: (checked) => {
|
|
4563
|
+
send(DataTableMessage.SelectionRequested({
|
|
4564
|
+
rowIds: selectableRows.map(({ id }) => id),
|
|
4565
|
+
checked
|
|
4566
|
+
}));
|
|
4567
|
+
}
|
|
4568
|
+
})
|
|
3501
4569
|
})
|
|
3502
4570
|
}) : null,
|
|
3503
4571
|
draggable ? /* @__PURE__ */ jsx15(TableHead2, {
|
|
@@ -3507,17 +4575,17 @@ var DataTableHeader = ({
|
|
|
3507
4575
|
const direction = store.state.sort?.find(({ id }) => id === column.id)?.direction;
|
|
3508
4576
|
return /* @__PURE__ */ jsx15(TableHead2, {
|
|
3509
4577
|
"aria-sort": direction === "asc" ? "ascending" : direction === "desc" ? "descending" : undefined,
|
|
3510
|
-
className:
|
|
4578
|
+
className: tableClasses.header,
|
|
3511
4579
|
scope: "col",
|
|
3512
4580
|
style: { width: column.width },
|
|
3513
4581
|
children: /* @__PURE__ */ jsxs9(ColumnIdContext.Provider, {
|
|
3514
4582
|
value: column.id,
|
|
3515
4583
|
children: [
|
|
3516
4584
|
/* @__PURE__ */ jsx15(ColumnHeaderMenu, {
|
|
3517
|
-
|
|
4585
|
+
table
|
|
3518
4586
|
}),
|
|
3519
4587
|
/* @__PURE__ */ jsx15(ResizeHandle, {
|
|
3520
|
-
|
|
4588
|
+
table
|
|
3521
4589
|
})
|
|
3522
4590
|
]
|
|
3523
4591
|
})
|
|
@@ -3531,13 +4599,13 @@ var DataTableHeader = ({
|
|
|
3531
4599
|
});
|
|
3532
4600
|
};
|
|
3533
4601
|
var VirtualTableRows = ({
|
|
3534
|
-
|
|
4602
|
+
table,
|
|
3535
4603
|
rows,
|
|
3536
4604
|
sections,
|
|
3537
4605
|
viewport,
|
|
3538
4606
|
colSpan
|
|
3539
4607
|
}) => {
|
|
3540
|
-
const [{ state, config }] =
|
|
4608
|
+
const [{ state, config }] = table;
|
|
3541
4609
|
const { element: scrollElement, headerHeight } = viewport;
|
|
3542
4610
|
const pageScroll = viewport.options.scroll === "page";
|
|
3543
4611
|
const scrollMargin = viewport.pageOffset ?? headerHeight;
|
|
@@ -3622,7 +4690,7 @@ var VirtualTableRows = ({
|
|
|
3622
4690
|
return /* @__PURE__ */ jsx15(TableDataRow, {
|
|
3623
4691
|
measureRef: virtualizer.measureElement,
|
|
3624
4692
|
row: entry.row,
|
|
3625
|
-
|
|
4693
|
+
table,
|
|
3626
4694
|
virtualIndex: index
|
|
3627
4695
|
}, key);
|
|
3628
4696
|
if (entry.kind === "header")
|
|
@@ -3630,7 +4698,7 @@ var VirtualTableRows = ({
|
|
|
3630
4698
|
measureRef: virtualizer.measureElement,
|
|
3631
4699
|
section: entry.section,
|
|
3632
4700
|
colSpan,
|
|
3633
|
-
|
|
4701
|
+
table,
|
|
3634
4702
|
virtualIndex: index
|
|
3635
4703
|
}, key);
|
|
3636
4704
|
return /* @__PURE__ */ jsx15(TableRow2, {
|
|
@@ -3649,21 +4717,20 @@ var VirtualTableRows = ({
|
|
|
3649
4717
|
});
|
|
3650
4718
|
};
|
|
3651
4719
|
var DataTableBody = ({
|
|
3652
|
-
|
|
4720
|
+
table,
|
|
3653
4721
|
viewport
|
|
3654
4722
|
}) => {
|
|
3655
4723
|
const styles = useContext(DataTableStylesContext);
|
|
3656
|
-
const [store] =
|
|
4724
|
+
const [store] = table;
|
|
3657
4725
|
const model = deriveModel(store);
|
|
3658
4726
|
const fields = getActiveGrouping(store);
|
|
3659
|
-
const
|
|
3660
|
-
const rows = grouped ? model.sortedRows : model.pageRows;
|
|
4727
|
+
const rows = model.pageRows;
|
|
3661
4728
|
const sections = useMemo2(() => groupDataTableRows(rows, fields), [rows, fields]);
|
|
3662
4729
|
const colSpan = model.visibleColumns.length + (store.config.features.selection ? 1 : 0) + (hasRowActionMenu(store) ? 1 : 0) + (canDragRows(store) ? 1 : 0);
|
|
3663
4730
|
const showGroups = sections.length && (rows.length || !store.config.status.loading) && !store.config.status.error;
|
|
3664
4731
|
if (showGroups && !viewport) {
|
|
3665
4732
|
return /* @__PURE__ */ jsx15(GroupedTable, {
|
|
3666
|
-
|
|
4733
|
+
table,
|
|
3667
4734
|
sections
|
|
3668
4735
|
});
|
|
3669
4736
|
}
|
|
@@ -3689,30 +4756,17 @@ var DataTableBody = ({
|
|
|
3689
4756
|
colSpan,
|
|
3690
4757
|
rows,
|
|
3691
4758
|
sections,
|
|
3692
|
-
|
|
4759
|
+
table,
|
|
3693
4760
|
viewport
|
|
3694
4761
|
}) : rows.map((row) => /* @__PURE__ */ jsx15(RowIdContext.Provider, {
|
|
3695
4762
|
value: row.id,
|
|
3696
4763
|
children: /* @__PURE__ */ jsx15(TableDataRow, {
|
|
3697
4764
|
row,
|
|
3698
|
-
|
|
4765
|
+
table
|
|
3699
4766
|
})
|
|
3700
4767
|
}, row.id))
|
|
3701
4768
|
});
|
|
3702
4769
|
};
|
|
3703
|
-
var GalleryImage = ({ src, alt }) => {
|
|
3704
|
-
const [failed, setFailed] = useState(false);
|
|
3705
|
-
if (failed)
|
|
3706
|
-
return null;
|
|
3707
|
-
return /* @__PURE__ */ jsx15("img", {
|
|
3708
|
-
src,
|
|
3709
|
-
alt,
|
|
3710
|
-
loading: "lazy",
|
|
3711
|
-
decoding: "async",
|
|
3712
|
-
className: "aspect-video w-full object-cover",
|
|
3713
|
-
onError: () => setFailed(true)
|
|
3714
|
-
});
|
|
3715
|
-
};
|
|
3716
4770
|
var GalleryTag = ({
|
|
3717
4771
|
row,
|
|
3718
4772
|
column,
|
|
@@ -3739,9 +4793,9 @@ var GalleryTag = ({
|
|
|
3739
4793
|
});
|
|
3740
4794
|
};
|
|
3741
4795
|
var GalleryCard = ({
|
|
3742
|
-
|
|
4796
|
+
table
|
|
3743
4797
|
}) => {
|
|
3744
|
-
const [store,
|
|
4798
|
+
const [store, send] = table;
|
|
3745
4799
|
const rowId = useRequiredId(RowIdContext);
|
|
3746
4800
|
const model = deriveModel(store);
|
|
3747
4801
|
const row = model.sortedRows.find((candidate) => candidate.id === rowId);
|
|
@@ -3770,10 +4824,14 @@ var GalleryCard = ({
|
|
|
3770
4824
|
},
|
|
3771
4825
|
tabIndex: store.config.onRowClicked ? 0 : undefined,
|
|
3772
4826
|
children: [
|
|
3773
|
-
imageSrc ? /* @__PURE__ */ jsx15(
|
|
4827
|
+
imageSrc && !store.ui.failedImages.includes(imageSrc) ? /* @__PURE__ */ jsx15("img", {
|
|
3774
4828
|
src: imageSrc,
|
|
3775
|
-
alt: gallery.image?.getAlt?.(row.data) ?? ""
|
|
3776
|
-
|
|
4829
|
+
alt: gallery.image?.getAlt?.(row.data) ?? "",
|
|
4830
|
+
loading: "lazy",
|
|
4831
|
+
decoding: "async",
|
|
4832
|
+
className: "aspect-video w-full object-cover",
|
|
4833
|
+
onError: () => send(DataTableMessage.ReferenceImageFailed({ src: imageSrc }))
|
|
4834
|
+
}) : null,
|
|
3777
4835
|
/* @__PURE__ */ jsxs9(CardHeader, {
|
|
3778
4836
|
className: cn("relative", hasRowActionMenu(store) && "pr-12"),
|
|
3779
4837
|
children: [
|
|
@@ -3784,11 +4842,11 @@ var GalleryCard = ({
|
|
|
3784
4842
|
"aria-label": store.config.labels.selectRow,
|
|
3785
4843
|
checked: !!store.state.rowSelection[row.id],
|
|
3786
4844
|
disabled: !selectable,
|
|
3787
|
-
onCheckedChange: (checked) => toggleRow(
|
|
4845
|
+
onCheckedChange: (checked) => toggleRow(send, row.id, checked),
|
|
3788
4846
|
onClick: (event) => event.stopPropagation()
|
|
3789
4847
|
}) : null,
|
|
3790
4848
|
draggable ? /* @__PURE__ */ jsx15(DragHandle, {
|
|
3791
|
-
|
|
4849
|
+
table
|
|
3792
4850
|
}) : null
|
|
3793
4851
|
]
|
|
3794
4852
|
}) : null,
|
|
@@ -3817,7 +4875,7 @@ var GalleryCard = ({
|
|
|
3817
4875
|
onClick: (event) => event.stopPropagation(),
|
|
3818
4876
|
children: /* @__PURE__ */ jsx15(DataTableRowActionMenu, {
|
|
3819
4877
|
row,
|
|
3820
|
-
|
|
4878
|
+
table
|
|
3821
4879
|
})
|
|
3822
4880
|
}) : null
|
|
3823
4881
|
]
|
|
@@ -3826,13 +4884,13 @@ var GalleryCard = ({
|
|
|
3826
4884
|
});
|
|
3827
4885
|
};
|
|
3828
4886
|
var DataTableGallery = ({
|
|
3829
|
-
|
|
4887
|
+
table
|
|
3830
4888
|
}) => {
|
|
3831
4889
|
const styles = useContext(DataTableStylesContext);
|
|
3832
|
-
const [store,
|
|
4890
|
+
const [store, send] = table;
|
|
3833
4891
|
const model = deriveModel(store);
|
|
3834
4892
|
const fields = getActiveGrouping(store);
|
|
3835
|
-
const rows =
|
|
4893
|
+
const rows = model.pageRows;
|
|
3836
4894
|
const sections = groupDataTableRows(rows, fields);
|
|
3837
4895
|
if (store.config.status.error) {
|
|
3838
4896
|
return /* @__PURE__ */ jsx15("div", {
|
|
@@ -3864,7 +4922,7 @@ var DataTableGallery = ({
|
|
|
3864
4922
|
children: rows.map((row) => /* @__PURE__ */ jsx15(RowIdContext.Provider, {
|
|
3865
4923
|
value: row.id,
|
|
3866
4924
|
children: /* @__PURE__ */ jsx15(GalleryCard, {
|
|
3867
|
-
|
|
4925
|
+
table
|
|
3868
4926
|
})
|
|
3869
4927
|
}, row.id))
|
|
3870
4928
|
});
|
|
@@ -3872,13 +4930,7 @@ var DataTableGallery = ({
|
|
|
3872
4930
|
const renderSections = (sections) => sections.map((section) => {
|
|
3873
4931
|
const collapsed = !!store.state.collapsedGroups[section.key];
|
|
3874
4932
|
const targetKey = getGroupDropKey(section.field.id, section.groupId);
|
|
3875
|
-
const toggleCollapsed = () =>
|
|
3876
|
-
...state,
|
|
3877
|
-
collapsedGroups: {
|
|
3878
|
-
...state.collapsedGroups,
|
|
3879
|
-
[section.key]: !collapsed
|
|
3880
|
-
}
|
|
3881
|
-
}));
|
|
4933
|
+
const toggleCollapsed = () => send(DataTableMessage.GroupToggled({ key: section.key }));
|
|
3882
4934
|
return /* @__PURE__ */ jsxs9("section", {
|
|
3883
4935
|
className: "data-[drop-target=true]:ring-primary space-y-3 rounded-lg transition-shadow data-[drop-target=true]:ring-2",
|
|
3884
4936
|
"data-table-group": section.field.onMoveToGroup ? targetKey : undefined,
|
|
@@ -3920,7 +4972,7 @@ var DataTableGallery = ({
|
|
|
3920
4972
|
children: section.rows.map((row) => /* @__PURE__ */ jsx15(RowIdContext.Provider, {
|
|
3921
4973
|
value: row.id,
|
|
3922
4974
|
children: /* @__PURE__ */ jsx15(GalleryCard, {
|
|
3923
|
-
|
|
4975
|
+
table
|
|
3924
4976
|
})
|
|
3925
4977
|
}, `${section.key}:${row.id}`))
|
|
3926
4978
|
}) : /* @__PURE__ */ jsx15("div", {
|
|
@@ -3936,28 +4988,22 @@ var DataTableGallery = ({
|
|
|
3936
4988
|
});
|
|
3937
4989
|
};
|
|
3938
4990
|
var DataTablePagination = ({
|
|
3939
|
-
|
|
4991
|
+
table
|
|
3940
4992
|
}) => {
|
|
3941
4993
|
const styles = useContext(DataTableStylesContext);
|
|
3942
|
-
const [store,
|
|
4994
|
+
const [store, send] = table;
|
|
3943
4995
|
const model = deriveModel(store);
|
|
3944
4996
|
const pagination = store.config.features.pagination ?? false;
|
|
3945
|
-
const
|
|
3946
|
-
const paginationVisible = pagination !== false && !clientGrouping;
|
|
4997
|
+
const { paginationVisible, page } = model;
|
|
3947
4998
|
const pageIndex = store.state.page;
|
|
3948
|
-
const maxPageIndex = model.pageCount - 1;
|
|
3949
4999
|
useLayoutEffect(() => {
|
|
3950
|
-
if (paginationVisible && pageIndex >
|
|
3951
|
-
|
|
3952
|
-
...state,
|
|
3953
|
-
page: maxPageIndex
|
|
3954
|
-
}));
|
|
5000
|
+
if (paginationVisible && pagination && pagination.mode === "client" && pageIndex > page) {
|
|
5001
|
+
send(DataTableMessage.PageRequested({ page }));
|
|
3955
5002
|
}
|
|
3956
|
-
}, [
|
|
3957
|
-
if (!paginationVisible)
|
|
5003
|
+
}, [page, pageIndex, pagination, paginationVisible, send]);
|
|
5004
|
+
if (!paginationVisible || !pagination)
|
|
3958
5005
|
return null;
|
|
3959
5006
|
const selected = model.rows.filter((row) => store.state.rowSelection[row.id]).length;
|
|
3960
|
-
const setPagination = (next) => changeState(setStore, (state) => ({ ...state, ...next }));
|
|
3961
5007
|
return /* @__PURE__ */ jsx15("div", {
|
|
3962
5008
|
"data-table-slot": "pagination",
|
|
3963
5009
|
className: cn("shrink-0 pt-4", styles?.pagination),
|
|
@@ -3965,9 +5011,9 @@ var DataTablePagination = ({
|
|
|
3965
5011
|
pageSizeContentClassName: styles?.popup?.select,
|
|
3966
5012
|
locale: store.config.locale,
|
|
3967
5013
|
messages: { [store.config.locale]: store.config.labels },
|
|
3968
|
-
onPageChange: (page) =>
|
|
3969
|
-
onPageSizeChange: (pageSize) =>
|
|
3970
|
-
page
|
|
5014
|
+
onPageChange: (page) => send(DataTableMessage.PageRequested({ page })),
|
|
5015
|
+
onPageSizeChange: (pageSize) => send(DataTableMessage.PageSizeRequested({ pageSize })),
|
|
5016
|
+
page,
|
|
3971
5017
|
pageCount: model.pageCount,
|
|
3972
5018
|
pageSize: store.state.pageSize,
|
|
3973
5019
|
pageSizes: pagination.pageSizes,
|
|
@@ -3976,151 +5022,221 @@ var DataTablePagination = ({
|
|
|
3976
5022
|
})
|
|
3977
5023
|
});
|
|
3978
5024
|
};
|
|
5025
|
+
var ReactTableModel = Component3.define(dataTableOptions).make({
|
|
5026
|
+
...dataTableBehaviours,
|
|
5027
|
+
view: () => View.text("")
|
|
5028
|
+
});
|
|
5029
|
+
var modelField = (id, definition) => {
|
|
5030
|
+
const field = {
|
|
5031
|
+
id,
|
|
5032
|
+
headerName: id,
|
|
5033
|
+
type: definition.type ?? "text"
|
|
5034
|
+
};
|
|
5035
|
+
if (definition.sortable !== undefined)
|
|
5036
|
+
field.sortable = definition.sortable;
|
|
5037
|
+
if (definition.filterable !== undefined)
|
|
5038
|
+
field.filterable = definition.filterable;
|
|
5039
|
+
return field;
|
|
5040
|
+
};
|
|
5041
|
+
var modelColumns = (definitions) => normalizeDataTableColumns(definitions).map(({ id, colDef }) => {
|
|
5042
|
+
const column = modelField(id, colDef);
|
|
5043
|
+
if (colDef.width !== undefined)
|
|
5044
|
+
column.width = colDef.width;
|
|
5045
|
+
if (colDef.minWidth !== undefined)
|
|
5046
|
+
column.minWidth = colDef.minWidth;
|
|
5047
|
+
if (colDef.maxWidth !== undefined)
|
|
5048
|
+
column.maxWidth = colDef.maxWidth;
|
|
5049
|
+
if (colDef.hideable !== undefined)
|
|
5050
|
+
column.hideable = colDef.hideable;
|
|
5051
|
+
if (colDef.resizable !== undefined)
|
|
5052
|
+
column.resizable = colDef.resizable;
|
|
5053
|
+
if (colDef.fields)
|
|
5054
|
+
column.fields = colDef.fields.map((field) => modelField(field.id, field));
|
|
5055
|
+
return column;
|
|
5056
|
+
});
|
|
3979
5057
|
var getTableLayoutClass = (virtualization) => virtualization && virtualization !== true && virtualization.scroll === "internal" ? "flex min-h-0 flex-1 flex-col" : undefined;
|
|
3980
|
-
var HydratedDataTable = ({
|
|
3981
|
-
|
|
3982
|
-
|
|
3983
|
-
|
|
3984
|
-
|
|
3985
|
-
|
|
3986
|
-
const grouping =
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
|
|
3990
|
-
|
|
3991
|
-
|
|
3992
|
-
|
|
3993
|
-
|
|
3994
|
-
|
|
3995
|
-
|
|
3996
|
-
|
|
3997
|
-
|
|
3998
|
-
setTransientUiState(transientUiFromState(state));
|
|
3999
|
-
}, [setPersistedUiState, setTransientUiState]);
|
|
4000
|
-
const validatedConfig = resolveConfig(props, (state) => setUiState(state));
|
|
4001
|
-
const [tableAtom] = useState(() => {
|
|
4002
|
-
const initial = {
|
|
4003
|
-
rowData: props.rowData,
|
|
4004
|
-
columnDefs: props.columnDefs,
|
|
4005
|
-
config: validatedConfig,
|
|
4006
|
-
state: initialPublicState(props, uiState),
|
|
4007
|
-
controlledState: props.state
|
|
5058
|
+
var HydratedDataTable = (props) => {
|
|
5059
|
+
const config = useMemo2(() => resolveConfig(props), [props]);
|
|
5060
|
+
const columns = useMemo2(() => modelColumns(props.columnDefs), [props.columnDefs]);
|
|
5061
|
+
const selection = config.features.selection;
|
|
5062
|
+
const modelProps = useMemo2(() => {
|
|
5063
|
+
const { features } = config;
|
|
5064
|
+
const grouping = features.grouping;
|
|
5065
|
+
const pagination = features.pagination;
|
|
5066
|
+
const [firstSize, ...otherSizes] = pagination && pagination.pageSizes || [];
|
|
5067
|
+
const modelFeatures = {
|
|
5068
|
+
search: features.search !== false,
|
|
5069
|
+
filtering: features.filtering !== false,
|
|
5070
|
+
sorting: features.sorting !== false,
|
|
5071
|
+
columnVisibility: features.columnVisibility !== false,
|
|
5072
|
+
pagination: pagination ? {
|
|
5073
|
+
...pagination,
|
|
5074
|
+
pageSizes: firstSize === undefined ? undefined : [firstSize, ...otherSizes]
|
|
5075
|
+
} : false
|
|
4008
5076
|
};
|
|
4009
|
-
|
|
4010
|
-
|
|
4011
|
-
|
|
4012
|
-
|
|
4013
|
-
|
|
4014
|
-
|
|
4015
|
-
useLayoutEffect(() => {
|
|
4016
|
-
setStore((store) => {
|
|
4017
|
-
const features = props.features ?? {};
|
|
4018
|
-
const selection = features.selection;
|
|
4019
|
-
const config = {
|
|
4020
|
-
getRowId: selection && selection.getRowId || props.getRowId || undefined,
|
|
4021
|
-
onStateChange: props.onStateChange,
|
|
4022
|
-
onUiStateChange: (state) => setUiState(state),
|
|
4023
|
-
status: props.status ?? {},
|
|
4024
|
-
features,
|
|
4025
|
-
onRowClicked: props.onRowClicked,
|
|
4026
|
-
labels: dataTableMessages(props.locale, props.messages),
|
|
4027
|
-
locale: props.locale ?? "en"
|
|
4028
|
-
};
|
|
4029
|
-
const state = {
|
|
4030
|
-
...store.state,
|
|
4031
|
-
...uiState,
|
|
4032
|
-
...queryFromState(props.state ?? store.state)
|
|
5077
|
+
if (features.gallery)
|
|
5078
|
+
modelFeatures.gallery = { name: features.gallery.name };
|
|
5079
|
+
if (grouping) {
|
|
5080
|
+
modelFeatures.grouping = {
|
|
5081
|
+
initial: grouping.initial ?? [],
|
|
5082
|
+
fields: grouping.fields.map(({ id }) => ({ id, label: id }))
|
|
4033
5083
|
};
|
|
4034
|
-
|
|
4035
|
-
|
|
4036
|
-
|
|
4037
|
-
|
|
4038
|
-
|
|
4039
|
-
config,
|
|
4040
|
-
|
|
4041
|
-
|
|
4042
|
-
|
|
4043
|
-
|
|
4044
|
-
|
|
5084
|
+
}
|
|
5085
|
+
const input = {
|
|
5086
|
+
label: "",
|
|
5087
|
+
columnDefs: columns,
|
|
5088
|
+
rowData: selection ? props.rowData.map((row, index) => ({
|
|
5089
|
+
id: config.getRowId?.(row) ?? String(index),
|
|
5090
|
+
label: "",
|
|
5091
|
+
cells: {},
|
|
5092
|
+
selectable: selection.isRowSelectable?.(row) ?? true
|
|
5093
|
+
})) : [],
|
|
5094
|
+
features: modelFeatures
|
|
5095
|
+
};
|
|
5096
|
+
if (selection)
|
|
5097
|
+
input.selection = {};
|
|
5098
|
+
if (props.state)
|
|
5099
|
+
input.state = props.state;
|
|
5100
|
+
if (props.initialState)
|
|
5101
|
+
input.initialState = props.initialState;
|
|
5102
|
+
return input;
|
|
4045
5103
|
}, [
|
|
4046
|
-
|
|
4047
|
-
|
|
4048
|
-
props.
|
|
4049
|
-
props.locale,
|
|
4050
|
-
props.messages,
|
|
4051
|
-
props.onRowClicked,
|
|
4052
|
-
props.onStateChange,
|
|
5104
|
+
columns,
|
|
5105
|
+
config,
|
|
5106
|
+
props.initialState,
|
|
4053
5107
|
props.rowData,
|
|
4054
5108
|
props.state,
|
|
4055
|
-
|
|
4056
|
-
|
|
4057
|
-
|
|
4058
|
-
|
|
5109
|
+
selection
|
|
5110
|
+
]);
|
|
5111
|
+
const { model, send } = useModel(ReactTableModel, modelProps, {
|
|
5112
|
+
onEmit: (event) => {
|
|
5113
|
+
if (event._tag === "StateChanged") {
|
|
5114
|
+
props.onStateChange?.(queryFromState(event.state));
|
|
5115
|
+
} else if (event._tag === "SelectionChanged" && selection) {
|
|
5116
|
+
const selected = new Set(event.selectedRowIds);
|
|
5117
|
+
selection.onSelectionChange?.(props.rowData.filter((_, index) => {
|
|
5118
|
+
const id = modelProps.rowData[index]?.id;
|
|
5119
|
+
return id !== undefined && selected.has(id);
|
|
5120
|
+
}));
|
|
5121
|
+
}
|
|
5122
|
+
}
|
|
5123
|
+
});
|
|
5124
|
+
const [storageKey] = useState(() => tablePreferencesKey(globalThis.window?.location.pathname ?? "/", columns.map(({ id }) => id), !!props.features?.gallery));
|
|
5125
|
+
useEffect(() => {
|
|
5126
|
+
if (!model.preferencesLoaded) {
|
|
5127
|
+
send(DataTableMessage.PreferencesLoaded({
|
|
5128
|
+
preferences: readTablePreferences(storageKey)
|
|
5129
|
+
}));
|
|
5130
|
+
}
|
|
5131
|
+
}, [model, send, storageKey]);
|
|
5132
|
+
const { columnVisibility, columnSizing, grouping, view, preferencesLoaded } = model;
|
|
5133
|
+
const loadedPreferences = useRef(false);
|
|
5134
|
+
useEffect(() => {
|
|
5135
|
+
const preferences = tablePreferences({
|
|
5136
|
+
columnVisibility,
|
|
5137
|
+
columnSizing,
|
|
5138
|
+
grouping,
|
|
5139
|
+
view,
|
|
5140
|
+
preferencesLoaded
|
|
5141
|
+
});
|
|
5142
|
+
if (!preferences)
|
|
5143
|
+
return;
|
|
5144
|
+
if (!loadedPreferences.current) {
|
|
5145
|
+
loadedPreferences.current = true;
|
|
5146
|
+
return;
|
|
5147
|
+
}
|
|
5148
|
+
writeTablePreferences(storageKey, preferences);
|
|
5149
|
+
}, [
|
|
5150
|
+
columnVisibility,
|
|
5151
|
+
columnSizing,
|
|
5152
|
+
grouping,
|
|
5153
|
+
view,
|
|
5154
|
+
preferencesLoaded,
|
|
5155
|
+
storageKey
|
|
4059
5156
|
]);
|
|
5157
|
+
const query = modelProps.state ?? model.query;
|
|
5158
|
+
const { collapsedGroups, selectedRowIds } = model;
|
|
5159
|
+
const galleryEnabled = !!props.features?.gallery;
|
|
5160
|
+
const state = useMemo2(() => ({
|
|
5161
|
+
...query,
|
|
5162
|
+
columnVisibility,
|
|
5163
|
+
columnSizing,
|
|
5164
|
+
grouping,
|
|
5165
|
+
view: galleryEnabled ? view : "table",
|
|
5166
|
+
collapsedGroups,
|
|
5167
|
+
rowSelection: Object.fromEntries(selectedRowIds.map((id) => [id, true]))
|
|
5168
|
+
}), [
|
|
5169
|
+
query,
|
|
5170
|
+
columnVisibility,
|
|
5171
|
+
columnSizing,
|
|
5172
|
+
grouping,
|
|
5173
|
+
view,
|
|
5174
|
+
galleryEnabled,
|
|
5175
|
+
collapsedGroups,
|
|
5176
|
+
selectedRowIds
|
|
5177
|
+
]);
|
|
5178
|
+
const store = useMemo2(() => {
|
|
5179
|
+
const source = {
|
|
5180
|
+
rowData: props.rowData,
|
|
5181
|
+
columnDefs: props.columnDefs,
|
|
5182
|
+
config,
|
|
5183
|
+
state
|
|
5184
|
+
};
|
|
5185
|
+
return { ...source, model: buildDataTableModel(source) };
|
|
5186
|
+
}, [props.rowData, props.columnDefs, config, state]);
|
|
5187
|
+
const table = [{ ...store, ui: model }, send];
|
|
5188
|
+
if (!preferencesLoaded)
|
|
5189
|
+
return /* @__PURE__ */ jsx15(TablePlaceholder, {
|
|
5190
|
+
props
|
|
5191
|
+
});
|
|
4060
5192
|
return /* @__PURE__ */ jsxs9("div", {
|
|
4061
5193
|
className: cn("w-full max-w-full min-w-0 rounded-md", getTableLayoutClass(props.features?.virtualization), props.className),
|
|
4062
5194
|
"data-table-root": "",
|
|
4063
5195
|
children: [
|
|
4064
5196
|
/* @__PURE__ */ jsx15(DataTableToolbar, {
|
|
4065
|
-
|
|
5197
|
+
table
|
|
4066
5198
|
}),
|
|
4067
5199
|
/* @__PURE__ */ jsx15(DataTableContent, {
|
|
4068
|
-
|
|
5200
|
+
table
|
|
4069
5201
|
}),
|
|
4070
5202
|
/* @__PURE__ */ jsx15(DataTablePagination, {
|
|
4071
|
-
|
|
5203
|
+
table
|
|
4072
5204
|
})
|
|
4073
5205
|
]
|
|
4074
5206
|
});
|
|
4075
5207
|
};
|
|
5208
|
+
var subscribeToHydration = () => () => {};
|
|
5209
|
+
var clientSnapshot = () => true;
|
|
5210
|
+
var serverSnapshot = () => false;
|
|
5211
|
+
var TablePlaceholder = ({
|
|
5212
|
+
props
|
|
5213
|
+
}) => /* @__PURE__ */ jsx15("div", {
|
|
5214
|
+
"aria-busy": "true",
|
|
5215
|
+
className: cn("invisible w-full max-w-full min-w-0 rounded-md", getTableLayoutClass(props.features?.virtualization), props.className),
|
|
5216
|
+
"data-table-root": ""
|
|
5217
|
+
});
|
|
4076
5218
|
var DataTable = (props) => {
|
|
4077
5219
|
const locale = useKrakstackLocale3(props.locale);
|
|
4078
|
-
const
|
|
4079
|
-
|
|
4080
|
-
|
|
4081
|
-
|
|
4082
|
-
const viewCapability = props.features?.gallery ? "gallery" : "table";
|
|
4083
|
-
return Atom.kvs({
|
|
4084
|
-
mode: "async",
|
|
4085
|
-
runtime: dataTableStorageRuntime,
|
|
4086
|
-
key: `data-table:${pathname}:${columnIds}:${viewCapability}:ui`,
|
|
4087
|
-
schema: DataTablePersistedUiStateSchema,
|
|
4088
|
-
defaultValue: () => ({
|
|
4089
|
-
...persistedUiFromState(DEFAULT_UI_STATE),
|
|
4090
|
-
view: props.features?.gallery ? props.initialState?.view ?? "table" : "table",
|
|
4091
|
-
grouping: props.features?.grouping ? props.features.grouping.initial ?? [] : []
|
|
4092
|
-
})
|
|
4093
|
-
});
|
|
4094
|
-
});
|
|
4095
|
-
const [persistedUiResult, setPersistedUiState] = useAtom(persistedUiAtom);
|
|
4096
|
-
const persistedUiState = useMemo2(() => AsyncResult.isSuccess(persistedUiResult) ? {
|
|
4097
|
-
...persistedUiResult.value,
|
|
4098
|
-
columnVisibility: {
|
|
4099
|
-
...initialColumnVisibility,
|
|
4100
|
-
...persistedUiResult.value.columnVisibility
|
|
4101
|
-
}
|
|
4102
|
-
} : undefined, [initialColumnVisibility, persistedUiResult]);
|
|
4103
|
-
if (!persistedUiState || AsyncResult.isWaiting(persistedUiResult)) {
|
|
4104
|
-
return /* @__PURE__ */ jsx15("div", {
|
|
4105
|
-
"aria-busy": "true",
|
|
4106
|
-
className: cn("invisible w-full max-w-full min-w-0 rounded-md", getTableLayoutClass(props.features?.virtualization), props.className),
|
|
4107
|
-
"data-table-root": ""
|
|
5220
|
+
const hydrated = useSyncExternalStore(subscribeToHydration, clientSnapshot, serverSnapshot);
|
|
5221
|
+
if (!hydrated)
|
|
5222
|
+
return /* @__PURE__ */ jsx15(TablePlaceholder, {
|
|
5223
|
+
props
|
|
4108
5224
|
});
|
|
4109
|
-
}
|
|
4110
5225
|
return /* @__PURE__ */ jsx15(DataTableStylesContext.Provider, {
|
|
4111
5226
|
value: props.classNames,
|
|
4112
|
-
children: /* @__PURE__ */ jsx15(
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
|
|
4116
|
-
|
|
5227
|
+
children: /* @__PURE__ */ jsx15(DataTableSlotClassesContext.Provider, {
|
|
5228
|
+
value: resolveTableClasses(props.classes),
|
|
5229
|
+
children: /* @__PURE__ */ jsx15(HydratedDataTable, {
|
|
5230
|
+
...props,
|
|
5231
|
+
locale
|
|
5232
|
+
})
|
|
4117
5233
|
})
|
|
4118
5234
|
});
|
|
4119
5235
|
};
|
|
4120
5236
|
var DataTableContent = ({
|
|
4121
|
-
|
|
5237
|
+
table
|
|
4122
5238
|
}) => {
|
|
4123
|
-
const [store] =
|
|
5239
|
+
const [store] = table;
|
|
4124
5240
|
const [scrollElement, setScrollElement] = useState(null);
|
|
4125
5241
|
const [headerHeight, setHeaderHeight] = useState(48);
|
|
4126
5242
|
const [pageTable, setPageTable] = useState(null);
|
|
@@ -4154,7 +5270,7 @@ var DataTableContent = ({
|
|
|
4154
5270
|
}, [scrollElement]);
|
|
4155
5271
|
if (store.config.features.gallery && store.state.view === "gallery") {
|
|
4156
5272
|
return /* @__PURE__ */ jsx15(DataTableGallery, {
|
|
4157
|
-
|
|
5273
|
+
table
|
|
4158
5274
|
});
|
|
4159
5275
|
}
|
|
4160
5276
|
const model = deriveModel(store);
|
|
@@ -4180,10 +5296,10 @@ var DataTableContent = ({
|
|
|
4180
5296
|
style: { width: `max(100%, ${width}px)` },
|
|
4181
5297
|
children: [
|
|
4182
5298
|
/* @__PURE__ */ jsx15(DataTableHeader, {
|
|
4183
|
-
|
|
5299
|
+
table
|
|
4184
5300
|
}),
|
|
4185
5301
|
/* @__PURE__ */ jsx15(DataTableBody, {
|
|
4186
|
-
|
|
5302
|
+
table,
|
|
4187
5303
|
viewport: {
|
|
4188
5304
|
element: null,
|
|
4189
5305
|
headerHeight: 0,
|
|
@@ -4220,10 +5336,10 @@ var DataTableContent = ({
|
|
|
4220
5336
|
children: [
|
|
4221
5337
|
/* @__PURE__ */ jsx15(DataTableHeader, {
|
|
4222
5338
|
sticky: true,
|
|
4223
|
-
|
|
5339
|
+
table
|
|
4224
5340
|
}),
|
|
4225
5341
|
/* @__PURE__ */ jsx15(DataTableBody, {
|
|
4226
|
-
|
|
5342
|
+
table,
|
|
4227
5343
|
viewport: { element: scrollElement, headerHeight, options }
|
|
4228
5344
|
})
|
|
4229
5345
|
]
|
|
@@ -4249,10 +5365,10 @@ var DataTableContent = ({
|
|
|
4249
5365
|
style: { width: `max(100%, ${width}px)` },
|
|
4250
5366
|
children: [
|
|
4251
5367
|
/* @__PURE__ */ jsx15(DataTableHeader, {
|
|
4252
|
-
|
|
5368
|
+
table
|
|
4253
5369
|
}),
|
|
4254
5370
|
/* @__PURE__ */ jsx15(DataTableBody, {
|
|
4255
|
-
|
|
5371
|
+
table
|
|
4256
5372
|
})
|
|
4257
5373
|
]
|
|
4258
5374
|
}),
|
|
@@ -4263,6 +5379,7 @@ var DataTableContent = ({
|
|
|
4263
5379
|
});
|
|
4264
5380
|
};
|
|
4265
5381
|
var DataTableListCell = (props) => {
|
|
5382
|
+
const tableClasses = useContext(DataTableSlotClassesContext);
|
|
4266
5383
|
const locale = useKrakstackLocale3(props.locale);
|
|
4267
5384
|
const resolvedProps = { ...props, locale };
|
|
4268
5385
|
if (resolvedProps.options && (resolvedProps.onAdd || resolvedProps.onRemove)) {
|
|
@@ -4280,7 +5397,7 @@ var DataTableListCell = (props) => {
|
|
|
4280
5397
|
}
|
|
4281
5398
|
const menuLabel = actionsLabel ?? (itemActions?.length ? labels.actions : labels.listDetails);
|
|
4282
5399
|
return /* @__PURE__ */ jsx15("div", {
|
|
4283
|
-
className:
|
|
5400
|
+
className: tableClasses.relationshipCell,
|
|
4284
5401
|
"data-slot": "data-table-list-cell",
|
|
4285
5402
|
onClick: (event) => event.stopPropagation(),
|
|
4286
5403
|
onPointerDown: (event) => event.stopPropagation(),
|
|
@@ -4295,7 +5412,7 @@ var DataTableListCell = (props) => {
|
|
|
4295
5412
|
onItemClick,
|
|
4296
5413
|
trigger: /* @__PURE__ */ jsxs9(Button, {
|
|
4297
5414
|
"aria-label": menuLabel,
|
|
4298
|
-
className:
|
|
5415
|
+
className: tableClasses.relationshipTrigger,
|
|
4299
5416
|
variant: "ghost",
|
|
4300
5417
|
children: [
|
|
4301
5418
|
/* @__PURE__ */ jsx15(DataTableListSummaryContent, {
|
|
@@ -4324,6 +5441,7 @@ var EditableDataTableListCell = ({
|
|
|
4324
5441
|
locale = "en",
|
|
4325
5442
|
messages
|
|
4326
5443
|
}) => {
|
|
5444
|
+
const tableClasses = useContext(DataTableSlotClassesContext);
|
|
4327
5445
|
const [selected, setSelected] = useState([...items]);
|
|
4328
5446
|
const [previousItems, setPreviousItems] = useState(items);
|
|
4329
5447
|
if (previousItems !== items) {
|
|
@@ -4355,7 +5473,7 @@ var EditableDataTableListCell = ({
|
|
|
4355
5473
|
];
|
|
4356
5474
|
return /* @__PURE__ */ jsx15("div", {
|
|
4357
5475
|
"data-slot": "data-table-list-cell",
|
|
4358
|
-
className:
|
|
5476
|
+
className: tableClasses.relationshipCell,
|
|
4359
5477
|
onClick: (event) => event.stopPropagation(),
|
|
4360
5478
|
onPointerDown: (event) => event.stopPropagation(),
|
|
4361
5479
|
children: /* @__PURE__ */ jsx15(DataTableListMenu, {
|
|
@@ -4412,7 +5530,7 @@ var DataTableListMenu = ({
|
|
|
4412
5530
|
trigger
|
|
4413
5531
|
}) => {
|
|
4414
5532
|
const entries = items.map((item) => {
|
|
4415
|
-
const normalized =
|
|
5533
|
+
const normalized = Schema6.is(Schema6.String)(item) ? { label: item } : item;
|
|
4416
5534
|
const visibleActions = actions.filter((action) => action.visible?.(normalized) ?? true);
|
|
4417
5535
|
return { item: normalized, visibleActions };
|
|
4418
5536
|
});
|
|
@@ -4582,7 +5700,7 @@ var DataTableListSummaryContent = ({
|
|
|
4582
5700
|
showMenu,
|
|
4583
5701
|
visibleCount = 3
|
|
4584
5702
|
}) => {
|
|
4585
|
-
const normalized = items.map((item) =>
|
|
5703
|
+
const normalized = items.map((item) => Schema6.is(Schema6.String)(item) ? { label: item } : item);
|
|
4586
5704
|
if (!normalized.length)
|
|
4587
5705
|
return /* @__PURE__ */ jsx15("span", {
|
|
4588
5706
|
className: "text-muted-foreground",
|
|
@@ -4687,21 +5805,111 @@ var DataTableListEntry = ({
|
|
|
4687
5805
|
]
|
|
4688
5806
|
});
|
|
4689
5807
|
};
|
|
4690
|
-
|
|
4691
|
-
// ../../src/components/ui/copy-button.tsx
|
|
5808
|
+
// ../../src/components/copy-button/react.tsx
|
|
4692
5809
|
import { Check as Check2, Copy, TriangleAlert } from "lucide-react";
|
|
4693
|
-
import {
|
|
4694
|
-
import {
|
|
4695
|
-
import {
|
|
4696
|
-
|
|
5810
|
+
import { Redacted as Redacted3 } from "effect";
|
|
5811
|
+
import { Component as Component5 } from "effect/ui";
|
|
5812
|
+
import { useLayoutEffect as useLayoutEffect2, useRef as useRef2, useState as useState2 } from "react";
|
|
5813
|
+
import { useKrakstackLocale as useKrakstackLocale4 } from "@krak-stack/registry/krakstack-provider/react";
|
|
5814
|
+
import { useModel as useModel2 } from "@krak-stack/registry/effect-ui-adapter/react";
|
|
5815
|
+
|
|
5816
|
+
// ../../src/components/copy-button/index.ts
|
|
5817
|
+
import { Effect as Effect3, Redacted as Redacted2, Schema as Schema8 } from "effect";
|
|
5818
|
+
import { Command as Command2, Component as Component4, UiSchema as UiSchema3, View as View2 } from "effect/ui";
|
|
5819
|
+
|
|
5820
|
+
// ../../src/components/copy-button/schema.ts
|
|
5821
|
+
import { Schema as Schema7 } from "effect";
|
|
5822
|
+
var MessageOverrides = Schema7.Struct({
|
|
5823
|
+
copy: Schema7.optional(Schema7.String),
|
|
5824
|
+
copied: Schema7.optional(Schema7.String),
|
|
5825
|
+
copyFailed: Schema7.optional(Schema7.String)
|
|
5826
|
+
}).annotate({ identifier: "CopyButtonMessageOverrides" });
|
|
5827
|
+
var CopyButtonTranslations = Schema7.Record(Schema7.String, Schema7.UndefinedOr(MessageOverrides));
|
|
5828
|
+
var copyButtonVariants = [
|
|
5829
|
+
"default",
|
|
5830
|
+
"secondary",
|
|
5831
|
+
"outline",
|
|
5832
|
+
"ghost",
|
|
5833
|
+
"destructive",
|
|
5834
|
+
"link"
|
|
5835
|
+
];
|
|
5836
|
+
var CopyButtonModelProps = Schema7.Struct({
|
|
5837
|
+
value: Schema7.Redacted(Schema7.String, { disallowJsonEncode: true }),
|
|
5838
|
+
disabled: Schema7.optional(Schema7.Boolean),
|
|
5839
|
+
resetDelay: Schema7.optional(Schema7.Finite)
|
|
5840
|
+
}).annotate({ identifier: "CopyButtonModelProps" });
|
|
5841
|
+
var copyButtonSharedProps = Schema7.Struct({
|
|
5842
|
+
...CopyButtonModelProps.fields,
|
|
5843
|
+
valueDescription: Schema7.optional(Schema7.String),
|
|
5844
|
+
copyVariant: Schema7.optional(Schema7.Literals(["default", "sm", "large"])),
|
|
5845
|
+
variant: Schema7.optional(Schema7.Literals(copyButtonVariants)),
|
|
5846
|
+
locale: Schema7.optional(Schema7.String),
|
|
5847
|
+
messages: Schema7.optional(CopyButtonTranslations)
|
|
5848
|
+
}).annotate({ identifier: "CopyButtonSharedProps" });
|
|
5849
|
+
|
|
5850
|
+
// ../../src/components/copy-button/index.ts
|
|
5851
|
+
var labels2 = {
|
|
4697
5852
|
en: { copy: "Copy", copied: "Copied", copyFailed: "Copy failed" },
|
|
4698
5853
|
fr: { copy: "Copier", copied: "Copié", copyFailed: "Échec de la copie" }
|
|
4699
5854
|
};
|
|
4700
5855
|
var copyButtonMessages = (locale = "en", translations) => ({
|
|
4701
|
-
...locale.startsWith("fr") ?
|
|
5856
|
+
...locale.startsWith("fr") ? labels2.fr : labels2.en,
|
|
4702
5857
|
...translations?.[locale.split("-")[0] ?? locale],
|
|
4703
5858
|
...translations?.[locale]
|
|
4704
5859
|
});
|
|
5860
|
+
var copyButtonLabel = (copy, description) => description ? `${copy} ${description}` : copy;
|
|
5861
|
+
var CopyButtonMessage = UiSchema3.TaggedEnum({
|
|
5862
|
+
Pressed: {},
|
|
5863
|
+
Finished: { success: Schema8.Boolean },
|
|
5864
|
+
Reset: {}
|
|
5865
|
+
}).annotate({ identifier: "CopyButtonMessage" });
|
|
5866
|
+
|
|
5867
|
+
class WriteClipboard extends Command2.Service()("copy-button/WriteClipboard", {
|
|
5868
|
+
args: {
|
|
5869
|
+
value: Schema8.Redacted(Schema8.String, { disallowJsonEncode: true })
|
|
5870
|
+
},
|
|
5871
|
+
success: CopyButtonMessage
|
|
5872
|
+
}) {
|
|
5873
|
+
static layerFromWrite = (write) => WriteClipboard.toLayer(({ value }) => Effect3.tryPromise(() => write(Redacted2.value(value))).pipe(Effect3.match({
|
|
5874
|
+
onSuccess: () => CopyButtonMessage.Finished({ success: true }),
|
|
5875
|
+
onFailure: () => CopyButtonMessage.Finished({ success: false })
|
|
5876
|
+
})));
|
|
5877
|
+
static browser = WriteClipboard.layerFromWrite((value) => navigator.clipboard.writeText(value));
|
|
5878
|
+
}
|
|
5879
|
+
var ResetClipboardFeedback = Command2.make("copy-button/ResetFeedback", { args: { delay: Schema8.Number }, mode: "switch" }, ({ delay }) => Effect3.sleep(Math.max(0, delay)).pipe(Effect3.as(CopyButtonMessage.Reset())));
|
|
5880
|
+
var copyButtonOptions = {
|
|
5881
|
+
name: "CopyButton",
|
|
5882
|
+
props: CopyButtonModelProps,
|
|
5883
|
+
model: Schema8.Struct({
|
|
5884
|
+
status: Schema8.Literals(["idle", "copied", "failed"])
|
|
5885
|
+
}).annotate({ identifier: "CopyButtonModel" }),
|
|
5886
|
+
message: CopyButtonMessage,
|
|
5887
|
+
restore: false
|
|
5888
|
+
};
|
|
5889
|
+
var Definition = Component4.define(copyButtonOptions);
|
|
5890
|
+
var update3 = Definition.update({
|
|
5891
|
+
Pressed: ($) => $.props.disabled ? $.model : $.run(WriteClipboard.make({ value: $.props.value })),
|
|
5892
|
+
Finished: ($, { success }) => $.evolve({ status: success ? "copied" : "failed" }).run(ResetClipboardFeedback.make({ delay: $.props.resetDelay ?? 1500 })),
|
|
5893
|
+
Reset: ($) => $.evolve({ status: "idle" })
|
|
5894
|
+
});
|
|
5895
|
+
var copyButtonBehaviours = {
|
|
5896
|
+
init: () => ({ status: "idle" }),
|
|
5897
|
+
update: update3
|
|
5898
|
+
};
|
|
5899
|
+
var CopyButtonModel = Definition.make({
|
|
5900
|
+
...copyButtonBehaviours,
|
|
5901
|
+
view: () => View2.text("")
|
|
5902
|
+
});
|
|
5903
|
+
var copyButtonStatus = (status, copy, description) => {
|
|
5904
|
+
if (status === "idle")
|
|
5905
|
+
return "";
|
|
5906
|
+
const text = status === "copied" ? copy.copied : copy.copyFailed;
|
|
5907
|
+
return description ? `${text}: ${description}` : text;
|
|
5908
|
+
};
|
|
5909
|
+
|
|
5910
|
+
// ../../src/components/copy-button/react.tsx
|
|
5911
|
+
import { jsx as jsx16, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
5912
|
+
"use client";
|
|
4705
5913
|
function CopyButton({
|
|
4706
5914
|
value,
|
|
4707
5915
|
valueDescription,
|
|
@@ -4717,39 +5925,44 @@ function CopyButton({
|
|
|
4717
5925
|
...props
|
|
4718
5926
|
}) {
|
|
4719
5927
|
const locale = useKrakstackLocale4(localeOverride);
|
|
4720
|
-
const [copyState, setCopyState] = useState2("idle");
|
|
4721
|
-
const copyTimeout = useRef2(undefined);
|
|
4722
5928
|
const labels = copyButtonMessages(locale, messages);
|
|
4723
|
-
const
|
|
4724
|
-
|
|
4725
|
-
|
|
4726
|
-
|
|
4727
|
-
|
|
4728
|
-
|
|
4729
|
-
|
|
5929
|
+
const callbacks = useRef2({
|
|
5930
|
+
onCopied,
|
|
5931
|
+
onCopyError,
|
|
5932
|
+
failureLabel: labels.copyFailed
|
|
5933
|
+
});
|
|
5934
|
+
useLayoutEffect2(() => {
|
|
5935
|
+
callbacks.current = {
|
|
5936
|
+
onCopied,
|
|
5937
|
+
onCopyError,
|
|
5938
|
+
failureLabel: labels.copyFailed
|
|
4730
5939
|
};
|
|
4731
|
-
}, []);
|
|
4732
|
-
const
|
|
4733
|
-
|
|
4734
|
-
|
|
4735
|
-
|
|
4736
|
-
};
|
|
4737
|
-
const copy = () => {
|
|
4738
|
-
Promise.resolve().then(() => navigator.clipboard.writeText(value)).then(() => {
|
|
4739
|
-
setCopyState("copied");
|
|
5940
|
+
}, [onCopied, onCopyError, labels.copyFailed]);
|
|
5941
|
+
const [component] = useState2(() => CopyButtonModel.pipe(Component5.provide(WriteClipboard.layerFromWrite(async (text) => {
|
|
5942
|
+
const { onCopied, onCopyError, failureLabel } = callbacks.current;
|
|
5943
|
+
try {
|
|
5944
|
+
await navigator.clipboard.writeText(text);
|
|
4740
5945
|
onCopied?.();
|
|
4741
|
-
|
|
4742
|
-
|
|
4743
|
-
|
|
4744
|
-
|
|
4745
|
-
|
|
4746
|
-
|
|
4747
|
-
|
|
4748
|
-
|
|
5946
|
+
} catch (cause) {
|
|
5947
|
+
onCopyError?.(cause instanceof Error ? cause : new Error(failureLabel, { cause }));
|
|
5948
|
+
throw cause;
|
|
5949
|
+
}
|
|
5950
|
+
}))));
|
|
5951
|
+
const {
|
|
5952
|
+
model: { status },
|
|
5953
|
+
send
|
|
5954
|
+
} = useModel2(component, {
|
|
5955
|
+
value: Redacted3.make(value),
|
|
5956
|
+
disabled: disabled ?? false,
|
|
5957
|
+
resetDelay
|
|
5958
|
+
});
|
|
5959
|
+
const accessibleLabel = ariaLabel ?? copyButtonLabel(labels.copy, valueDescription);
|
|
5960
|
+
const isLarge = copyVariant === "large";
|
|
5961
|
+
const defaultSize = copyVariant === "sm" ? "icon-xs" : isLarge ? "sm" : "icon-sm";
|
|
4749
5962
|
return /* @__PURE__ */ jsxs10(Button, {
|
|
4750
5963
|
"aria-label": accessibleLabel,
|
|
4751
5964
|
disabled,
|
|
4752
|
-
onClick:
|
|
5965
|
+
onClick: () => send(CopyButtonMessage.Pressed()),
|
|
4753
5966
|
size: size ?? defaultSize,
|
|
4754
5967
|
...props,
|
|
4755
5968
|
children: [
|
|
@@ -4757,15 +5970,15 @@ function CopyButton({
|
|
|
4757
5970
|
"aria-live": "polite",
|
|
4758
5971
|
className: "sr-only",
|
|
4759
5972
|
role: "status",
|
|
4760
|
-
children: status
|
|
5973
|
+
children: copyButtonStatus(status, labels, valueDescription)
|
|
4761
5974
|
}),
|
|
4762
|
-
|
|
5975
|
+
status === "copied" ? /* @__PURE__ */ jsx16(Check2, {
|
|
4763
5976
|
"aria-hidden": "true"
|
|
4764
5977
|
}) : null,
|
|
4765
|
-
|
|
5978
|
+
status === "failed" ? /* @__PURE__ */ jsx16(TriangleAlert, {
|
|
4766
5979
|
"aria-hidden": "true"
|
|
4767
5980
|
}) : null,
|
|
4768
|
-
|
|
5981
|
+
status === "idle" ? /* @__PURE__ */ jsx16(Copy, {
|
|
4769
5982
|
"aria-hidden": "true"
|
|
4770
5983
|
}) : null,
|
|
4771
5984
|
isLarge ? /* @__PURE__ */ jsx16("span", {
|
|
@@ -4775,14 +5988,30 @@ function CopyButton({
|
|
|
4775
5988
|
});
|
|
4776
5989
|
}
|
|
4777
5990
|
|
|
4778
|
-
// ../../src/components/ui/
|
|
5991
|
+
// ../../src/components/ui/copy-button.tsx
|
|
5992
|
+
"use client";
|
|
5993
|
+
|
|
5994
|
+
// ../../src/components/code-block/react.tsx
|
|
4779
5995
|
import { highlight } from "@tanstack/highlight";
|
|
5996
|
+
import { useKrakstackLocale as useKrakstackLocale5 } from "@krak-stack/registry/krakstack-provider/react";
|
|
5997
|
+
|
|
5998
|
+
// ../../src/components/code-block/classes.ts
|
|
5999
|
+
var codeBlockClasses = {
|
|
6000
|
+
root: "not-prose bg-muted overflow-hidden rounded-md border text-[var(--th-token)]",
|
|
6001
|
+
header: "bg-background border-border/60 flex items-center justify-between border-b px-3 py-2",
|
|
6002
|
+
language: "text-muted-foreground font-mono text-xs",
|
|
6003
|
+
viewport: "max-h-full overflow-auto font-mono text-[0.875rem] leading-[1.625]"
|
|
6004
|
+
};
|
|
6005
|
+
var resolveCodeBlockClasses = (overrides) => ({
|
|
6006
|
+
...codeBlockClasses,
|
|
6007
|
+
...overrides
|
|
6008
|
+
});
|
|
6009
|
+
|
|
6010
|
+
// ../../src/components/code-block/index.ts
|
|
4780
6011
|
import { createThemeCss } from "@tanstack/highlight/theme";
|
|
4781
6012
|
import { githubDarkTheme } from "@tanstack/highlight/themes/github-dark";
|
|
4782
6013
|
import { githubLightTheme } from "@tanstack/highlight/themes/github-light";
|
|
4783
|
-
|
|
4784
|
-
import { jsx as jsx17, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
4785
|
-
var themeCss = `${createThemeCss({
|
|
6014
|
+
var codeThemeCss = `${createThemeCss({
|
|
4786
6015
|
light: githubLightTheme,
|
|
4787
6016
|
dark: githubDarkTheme,
|
|
4788
6017
|
lightSelector: "[data-code-theme]",
|
|
@@ -4798,7 +6027,7 @@ var themeCss = `${createThemeCss({
|
|
|
4798
6027
|
color: inherit;
|
|
4799
6028
|
}
|
|
4800
6029
|
[data-code-theme] pre.th-code code { font: inherit; }`;
|
|
4801
|
-
var
|
|
6030
|
+
var messages3 = {
|
|
4802
6031
|
en: {
|
|
4803
6032
|
codeDescription: (language) => `${language} code`,
|
|
4804
6033
|
copy: "Copy",
|
|
@@ -4813,51 +6042,56 @@ var messages4 = {
|
|
|
4813
6042
|
}
|
|
4814
6043
|
};
|
|
4815
6044
|
var codeBlockMessages = (locale = "en", translations) => ({
|
|
4816
|
-
...locale.startsWith("fr") ?
|
|
6045
|
+
...locale.startsWith("fr") ? messages3.fr : messages3.en,
|
|
4817
6046
|
...translations?.[locale.split("-")[0] ?? locale],
|
|
4818
6047
|
...translations?.[locale]
|
|
4819
6048
|
});
|
|
6049
|
+
var codeLanguage = (language = "text") => language.toLowerCase() || "text";
|
|
6050
|
+
|
|
6051
|
+
// ../../src/components/code-block/react.tsx
|
|
6052
|
+
import { jsx as jsx17, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
4820
6053
|
function CodeBlock({
|
|
6054
|
+
classes: classOverrides,
|
|
4821
6055
|
code,
|
|
4822
6056
|
language = "text",
|
|
4823
6057
|
locale: localeOverride,
|
|
4824
6058
|
messages
|
|
4825
6059
|
}) {
|
|
6060
|
+
const codeBlockClasses = resolveCodeBlockClasses(classOverrides);
|
|
4826
6061
|
const locale = useKrakstackLocale5(localeOverride);
|
|
4827
|
-
const normalizedLanguage = language
|
|
6062
|
+
const normalizedLanguage = codeLanguage(language);
|
|
4828
6063
|
const highlighted = highlight(code, { lang: normalizedLanguage });
|
|
4829
6064
|
const labels = codeBlockMessages(locale, messages);
|
|
4830
6065
|
return /* @__PURE__ */ jsxs11("div", {
|
|
4831
|
-
className:
|
|
6066
|
+
className: codeBlockClasses.root,
|
|
4832
6067
|
"data-code-theme": true,
|
|
4833
6068
|
children: [
|
|
4834
6069
|
/* @__PURE__ */ jsx17("style", {
|
|
4835
|
-
children:
|
|
6070
|
+
children: codeThemeCss
|
|
4836
6071
|
}),
|
|
4837
6072
|
/* @__PURE__ */ jsxs11("div", {
|
|
4838
|
-
className:
|
|
6073
|
+
className: codeBlockClasses.header,
|
|
4839
6074
|
children: [
|
|
4840
6075
|
/* @__PURE__ */ jsx17("span", {
|
|
4841
|
-
className:
|
|
6076
|
+
className: codeBlockClasses.language,
|
|
4842
6077
|
children: highlighted.lang
|
|
4843
6078
|
}),
|
|
4844
6079
|
/* @__PURE__ */ jsx17(CopyButton, {
|
|
4845
6080
|
value: code,
|
|
4846
6081
|
valueDescription: labels.codeDescription(highlighted.lang),
|
|
4847
|
-
variant: "
|
|
6082
|
+
variant: "ghost",
|
|
4848
6083
|
locale,
|
|
4849
6084
|
messages: { [locale]: labels }
|
|
4850
6085
|
})
|
|
4851
6086
|
]
|
|
4852
6087
|
}),
|
|
4853
6088
|
/* @__PURE__ */ jsx17("div", {
|
|
4854
|
-
className:
|
|
6089
|
+
className: codeBlockClasses.viewport,
|
|
4855
6090
|
dangerouslySetInnerHTML: { __html: highlighted.html }
|
|
4856
6091
|
})
|
|
4857
6092
|
]
|
|
4858
6093
|
});
|
|
4859
6094
|
}
|
|
4860
|
-
|
|
4861
6095
|
// ../../src/components/ui/dialog.tsx
|
|
4862
6096
|
import { Dialog as DialogPrimitive } from "@base-ui/react/dialog";
|
|
4863
6097
|
import { cn as cn2 } from "cn";
|
|
@@ -4935,9 +6169,76 @@ function DialogTitle({ className, ...props }) {
|
|
|
4935
6169
|
});
|
|
4936
6170
|
}
|
|
4937
6171
|
|
|
4938
|
-
// ../../src/
|
|
4939
|
-
import { useKrakstackLocale as useKrakstackLocale6 } from "@krak-stack/registry/krakstack-provider";
|
|
4940
|
-
import {
|
|
6172
|
+
// ../../src/components/webhook-delivery-table/react.tsx
|
|
6173
|
+
import { useKrakstackLocale as useKrakstackLocale6 } from "@krak-stack/registry/krakstack-provider/react";
|
|
6174
|
+
import { useModel as useModel3 } from "@krak-stack/registry/effect-ui-adapter/react";
|
|
6175
|
+
|
|
6176
|
+
// ../../src/components/webhook-delivery-table/index.ts
|
|
6177
|
+
import { Schema as Schema10 } from "effect";
|
|
6178
|
+
import { Component as Component6, UiSchema as UiSchema4 } from "effect/ui";
|
|
6179
|
+
|
|
6180
|
+
// ../../src/components/webhook-delivery-table/schema.ts
|
|
6181
|
+
import { Schema as Schema9 } from "effect";
|
|
6182
|
+
var WebhookDeliveryRowSchema = Schema9.Struct({
|
|
6183
|
+
id: Schema9.String,
|
|
6184
|
+
event: Schema9.String,
|
|
6185
|
+
status: Schema9.Literals(["pending", "success", "failed"]),
|
|
6186
|
+
retries: Schema9.Number,
|
|
6187
|
+
error: Schema9.NullOr(Schema9.String),
|
|
6188
|
+
retryAt: Schema9.Date,
|
|
6189
|
+
createdAt: Schema9.Date,
|
|
6190
|
+
completedAt: Schema9.NullOr(Schema9.Date),
|
|
6191
|
+
data: Schema9.Json
|
|
6192
|
+
}).annotate({ identifier: "WebhookDeliveryRow" });
|
|
6193
|
+
var Label2 = Schema9.Literals([
|
|
6194
|
+
"identifier",
|
|
6195
|
+
"event",
|
|
6196
|
+
"status",
|
|
6197
|
+
"pending",
|
|
6198
|
+
"success",
|
|
6199
|
+
"failed",
|
|
6200
|
+
"retries",
|
|
6201
|
+
"retryAt",
|
|
6202
|
+
"errorUnavailable",
|
|
6203
|
+
"payload",
|
|
6204
|
+
"viewPayload",
|
|
6205
|
+
"createdAt",
|
|
6206
|
+
"completedAt",
|
|
6207
|
+
"search",
|
|
6208
|
+
"allEvents",
|
|
6209
|
+
"allStatuses",
|
|
6210
|
+
"loading",
|
|
6211
|
+
"empty",
|
|
6212
|
+
"error",
|
|
6213
|
+
"close",
|
|
6214
|
+
"export",
|
|
6215
|
+
"links"
|
|
6216
|
+
]);
|
|
6217
|
+
var WebhookDeliverySharedPropsSchema = Schema9.Struct({
|
|
6218
|
+
entries: Schema9.Array(WebhookDeliveryRowSchema),
|
|
6219
|
+
rowCount: Schema9.Number,
|
|
6220
|
+
locale: Schema9.optional(Schema9.String),
|
|
6221
|
+
messages: Schema9.optional(Schema9.Record(Schema9.String, Schema9.Record(Label2, Schema9.optionalKey(Schema9.String)))),
|
|
6222
|
+
events: Schema9.optional(Schema9.Array(Schema9.Struct({ value: Schema9.String, label: Schema9.String })))
|
|
6223
|
+
}).annotate({ identifier: "WebhookDeliverySharedProps" });
|
|
6224
|
+
var WebhookDeliveryQuerySchema = Schema9.Struct({
|
|
6225
|
+
...DataTableQuerySchema.fields,
|
|
6226
|
+
search: Schema9.optional(Schema9.String),
|
|
6227
|
+
event: Schema9.optional(Schema9.String),
|
|
6228
|
+
status: Schema9.optional(WebhookDeliveryRowSchema.fields.status)
|
|
6229
|
+
}).annotate({ identifier: "WebhookDeliveryQuery" });
|
|
6230
|
+
var WebhookDeliveryTableHtmlPropsSchema = Schema9.Struct({
|
|
6231
|
+
...WebhookDeliverySharedPropsSchema.fields,
|
|
6232
|
+
query: WebhookDeliveryQuerySchema,
|
|
6233
|
+
status: Schema9.optional(Schema9.Literals(["loading", "error", "ready"])),
|
|
6234
|
+
canExport: Schema9.optional(Schema9.Boolean),
|
|
6235
|
+
links: Schema9.optional(Schema9.Record(Schema9.String, Schema9.Array(Schema9.Struct({
|
|
6236
|
+
label: Schema9.String,
|
|
6237
|
+
href: Schema9.String
|
|
6238
|
+
}))))
|
|
6239
|
+
}).annotate({ identifier: "WebhookDeliveryTableHtmlProps" });
|
|
6240
|
+
|
|
6241
|
+
// ../../src/components/webhook-delivery-table/index.ts
|
|
4941
6242
|
var translations = {
|
|
4942
6243
|
en: {
|
|
4943
6244
|
identifier: "ID",
|
|
@@ -4952,7 +6253,16 @@ var translations = {
|
|
|
4952
6253
|
payload: "Payload",
|
|
4953
6254
|
viewPayload: "View JSON",
|
|
4954
6255
|
createdAt: "Created",
|
|
4955
|
-
completedAt: "Completed"
|
|
6256
|
+
completedAt: "Completed",
|
|
6257
|
+
search: "Search",
|
|
6258
|
+
allEvents: "All events",
|
|
6259
|
+
allStatuses: "All statuses",
|
|
6260
|
+
loading: "Loading deliveries…",
|
|
6261
|
+
empty: "No deliveries",
|
|
6262
|
+
error: "Deliveries could not be loaded.",
|
|
6263
|
+
close: "Close",
|
|
6264
|
+
export: "Export CSV",
|
|
6265
|
+
links: "Links"
|
|
4956
6266
|
},
|
|
4957
6267
|
fr: {
|
|
4958
6268
|
identifier: "Identifiant",
|
|
@@ -4967,10 +6277,69 @@ var translations = {
|
|
|
4967
6277
|
payload: "Données",
|
|
4968
6278
|
viewPayload: "Voir le JSON",
|
|
4969
6279
|
createdAt: "Créé",
|
|
4970
|
-
completedAt: "Terminé"
|
|
6280
|
+
completedAt: "Terminé",
|
|
6281
|
+
search: "Rechercher",
|
|
6282
|
+
allEvents: "Tous les événements",
|
|
6283
|
+
allStatuses: "Tous les statuts",
|
|
6284
|
+
loading: "Chargement des livraisons…",
|
|
6285
|
+
empty: "Aucune livraison",
|
|
6286
|
+
error: "Impossible de charger les livraisons.",
|
|
6287
|
+
close: "Fermer",
|
|
6288
|
+
export: "Exporter en CSV",
|
|
6289
|
+
links: "Liens"
|
|
4971
6290
|
}
|
|
4972
6291
|
};
|
|
6292
|
+
var webhookDeliveryMessages = (locale, messages) => {
|
|
6293
|
+
const base = locale.split("-")[0] ?? locale;
|
|
6294
|
+
return {
|
|
6295
|
+
...base === "fr" ? translations.fr : translations.en,
|
|
6296
|
+
...messages?.[base],
|
|
6297
|
+
...messages?.[locale]
|
|
6298
|
+
};
|
|
6299
|
+
};
|
|
4973
6300
|
var webhookDeliveryStatus = (delivery) => delivery.status === "pending" && delivery.retries > 0 ? "failed" : delivery.status;
|
|
6301
|
+
var webhookDeliveryStatusDetails = (delivery, labels, dates) => webhookDeliveryStatus(delivery) === "failed" ? [
|
|
6302
|
+
delivery.error ?? labels.errorUnavailable,
|
|
6303
|
+
`${labels.retries}: ${delivery.retries}`,
|
|
6304
|
+
...delivery.status === "pending" ? [`${labels.retryAt}: ${dates.format(delivery.retryAt)}`] : []
|
|
6305
|
+
].join(" · ") : undefined;
|
|
6306
|
+
var WebhookDeliveryTableMessage = UiSchema4.TaggedEnum({
|
|
6307
|
+
OpenPayload: { id: Schema10.String },
|
|
6308
|
+
ClosePayload: {},
|
|
6309
|
+
QueryChanged: { query: WebhookDeliveryQuerySchema },
|
|
6310
|
+
ExportRequested: {}
|
|
6311
|
+
});
|
|
6312
|
+
var Events = UiSchema4.TaggedEnum({
|
|
6313
|
+
QueryChanged: { query: WebhookDeliveryQuerySchema },
|
|
6314
|
+
ExportRequested: { query: WebhookDeliveryQuerySchema }
|
|
6315
|
+
});
|
|
6316
|
+
var webhookDeliveryTableOptions = {
|
|
6317
|
+
name: "WebhookDeliveryTable",
|
|
6318
|
+
props: WebhookDeliveryTableHtmlPropsSchema,
|
|
6319
|
+
model: Schema10.Struct({
|
|
6320
|
+
selectedId: Schema10.NullOr(Schema10.String)
|
|
6321
|
+
}),
|
|
6322
|
+
message: WebhookDeliveryTableMessage,
|
|
6323
|
+
events: Events,
|
|
6324
|
+
restore: false
|
|
6325
|
+
};
|
|
6326
|
+
var update4 = Component6.define(webhookDeliveryTableOptions).update({
|
|
6327
|
+
OpenPayload: ($, { id }) => $.props.entries.some((row) => row.id === id) ? $.evolve({ selectedId: id }) : $.model,
|
|
6328
|
+
ClosePayload: ($) => $.evolve({ selectedId: null }),
|
|
6329
|
+
QueryChanged: ($, { query }) => $.emit(Events.QueryChanged({ query })),
|
|
6330
|
+
ExportRequested: ($) => $.props.canExport ? $.emit(Events.ExportRequested({ query: $.props.query })) : $.model
|
|
6331
|
+
});
|
|
6332
|
+
var webhookDeliveryTableBehaviours = {
|
|
6333
|
+
init: () => ({ selectedId: null }),
|
|
6334
|
+
update: update4
|
|
6335
|
+
};
|
|
6336
|
+
|
|
6337
|
+
// ../../src/components/webhook-delivery-table/react.tsx
|
|
6338
|
+
import { jsx as jsx19, jsxs as jsxs13, Fragment as Fragment2 } from "react/jsx-runtime";
|
|
6339
|
+
var DeliveryTableModel = Component7.define(webhookDeliveryTableOptions).make({
|
|
6340
|
+
...webhookDeliveryTableBehaviours,
|
|
6341
|
+
view: () => View3.text("")
|
|
6342
|
+
});
|
|
4974
6343
|
var WebhookDeliveryTable = ({
|
|
4975
6344
|
entries,
|
|
4976
6345
|
rowCount,
|
|
@@ -4983,14 +6352,13 @@ var WebhookDeliveryTable = ({
|
|
|
4983
6352
|
status
|
|
4984
6353
|
}) => {
|
|
4985
6354
|
const locale = useKrakstackLocale6(localeOverride);
|
|
4986
|
-
const
|
|
4987
|
-
const
|
|
4988
|
-
|
|
4989
|
-
|
|
4990
|
-
|
|
4991
|
-
|
|
4992
|
-
};
|
|
4993
|
-
const [selected, setSelected] = useState3(null);
|
|
6355
|
+
const labels = webhookDeliveryMessages(locale, messages);
|
|
6356
|
+
const { model, send } = useModel3(DeliveryTableModel, {
|
|
6357
|
+
entries,
|
|
6358
|
+
rowCount,
|
|
6359
|
+
query: { page: state?.page ?? 0, pageSize: state?.pageSize ?? 20 }
|
|
6360
|
+
});
|
|
6361
|
+
const selected = entries.find(({ id }) => id === model.selectedId);
|
|
4994
6362
|
const dateFormatter = new Intl.DateTimeFormat(locale, {
|
|
4995
6363
|
dateStyle: "medium",
|
|
4996
6364
|
timeStyle: "short"
|
|
@@ -5024,16 +6392,9 @@ var WebhookDeliveryTable = ({
|
|
|
5024
6392
|
imageVariant: "square",
|
|
5025
6393
|
getItem: (delivery) => {
|
|
5026
6394
|
const displayStatus = webhookDeliveryStatus(delivery);
|
|
5027
|
-
const details = displayStatus === "failed" ? [
|
|
5028
|
-
delivery.error ?? labels.errorUnavailable,
|
|
5029
|
-
`${labels.retries}: ${delivery.retries}`,
|
|
5030
|
-
...delivery.status === "pending" ? [
|
|
5031
|
-
`${labels.retryAt}: ${dateFormatter.format(delivery.retryAt)}`
|
|
5032
|
-
] : []
|
|
5033
|
-
] : [];
|
|
5034
6395
|
return {
|
|
5035
6396
|
label: statusLabels[displayStatus],
|
|
5036
|
-
description:
|
|
6397
|
+
description: webhookDeliveryStatusDetails(delivery, labels, dateFormatter),
|
|
5037
6398
|
icon: displayStatus === "failed" ? /* @__PURE__ */ jsx19(X2, {}) : displayStatus === "success" ? /* @__PURE__ */ jsx19(Check3, {}) : /* @__PURE__ */ jsx19(Clock, {}),
|
|
5038
6399
|
iconClassName: displayStatus === "failed" ? "bg-destructive/10 text-destructive" : displayStatus === "success" ? "bg-success/10 text-success" : "bg-primary/10 text-primary"
|
|
5039
6400
|
};
|
|
@@ -5051,7 +6412,7 @@ var WebhookDeliveryTable = ({
|
|
|
5051
6412
|
size: "sm",
|
|
5052
6413
|
onClick: (event) => {
|
|
5053
6414
|
event.stopPropagation();
|
|
5054
|
-
|
|
6415
|
+
send(WebhookDeliveryTableMessage.OpenPayload({ id: data.id }));
|
|
5055
6416
|
},
|
|
5056
6417
|
children: [
|
|
5057
6418
|
/* @__PURE__ */ jsx19(FileJson2, {
|
|
@@ -5082,10 +6443,10 @@ var WebhookDeliveryTable = ({
|
|
|
5082
6443
|
}
|
|
5083
6444
|
}),
|
|
5084
6445
|
/* @__PURE__ */ jsx19(Dialog, {
|
|
5085
|
-
open: selected !==
|
|
6446
|
+
open: selected !== undefined,
|
|
5086
6447
|
onOpenChange: (open) => {
|
|
5087
6448
|
if (!open)
|
|
5088
|
-
|
|
6449
|
+
send(WebhookDeliveryTableMessage.ClosePayload());
|
|
5089
6450
|
},
|
|
5090
6451
|
children: /* @__PURE__ */ jsxs13(DialogContent, {
|
|
5091
6452
|
className: "grid max-h-[calc(100svh-2rem)] grid-rows-[auto_minmax(0,1fr)] overflow-hidden sm:max-w-4xl",
|