@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
|
@@ -0,0 +1,2682 @@
|
|
|
1
|
+
// ../../src/components/data-table/html.ts
|
|
2
|
+
import { Schema as Schema6, Stream as Stream2 } from "effect";
|
|
3
|
+
import { Mount } from "effect/ui";
|
|
4
|
+
import { Html as Html2 } from "effect/ui/html";
|
|
5
|
+
import { Checkbox, Menu, Menubar, VirtualList } from "effect/ui/kit";
|
|
6
|
+
|
|
7
|
+
// ../../src/components/effectcn/button.ts
|
|
8
|
+
import {
|
|
9
|
+
Button as KitButton
|
|
10
|
+
} from "effect/ui/kit";
|
|
11
|
+
|
|
12
|
+
// ../../src/lib/utils.ts
|
|
13
|
+
import { cn } from "cn";
|
|
14
|
+
|
|
15
|
+
// ../../src/components/effectcn/button.ts
|
|
16
|
+
var base = "inline-flex h-8.5 shrink-0 items-center justify-center gap-1.5 rounded-md border border-transparent px-3.5 text-[13px] leading-none font-medium whitespace-nowrap no-underline select-none transition-[background-color,border-color,color,opacity] duration-150 active:translate-y-px data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50 [&_svg]:size-[15px] [&_svg]:shrink-0 data-[loading]:before:size-3 data-[loading]:before:animate-spin data-[loading]:before:rounded-full data-[loading]:before:border-2 data-[loading]:before:border-current data-[loading]:before:border-r-transparent";
|
|
17
|
+
var variants = {
|
|
18
|
+
default: "bg-primary text-primary-foreground hover:bg-primary/85",
|
|
19
|
+
secondary: "bg-secondary text-secondary-foreground hover:bg-accent",
|
|
20
|
+
outline: "border-input bg-background text-foreground shadow-sm hover:bg-accent hover:text-accent-foreground",
|
|
21
|
+
ghost: "text-foreground hover:bg-accent hover:text-accent-foreground",
|
|
22
|
+
brand: "bg-brand-soft text-brand-soft-foreground hover:bg-brand-soft/85",
|
|
23
|
+
destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/85",
|
|
24
|
+
link: "h-auto px-0 text-foreground underline decoration-transparent underline-offset-4 hover:decoration-current"
|
|
25
|
+
};
|
|
26
|
+
var sizes = {
|
|
27
|
+
default: "",
|
|
28
|
+
sm: "h-7 rounded-sm px-2.5 text-xs",
|
|
29
|
+
lg: "h-10 px-5 text-sm",
|
|
30
|
+
icon: "w-8.5 px-0",
|
|
31
|
+
"icon-sm": "h-7 w-7 rounded-sm px-0"
|
|
32
|
+
};
|
|
33
|
+
var buttonVariants = (options = {}) => cn(base, variants[options.variant ?? "default"], sizes[options.size ?? "default"], options.class);
|
|
34
|
+
var Button = (h, options = {}) => KitButton(h, {
|
|
35
|
+
element: options.element,
|
|
36
|
+
onPress: options.onPress,
|
|
37
|
+
props: options.loading ? { ...options.props, disabled: true, focusableWhenDisabled: true } : options.props
|
|
38
|
+
}).class(buttonVariants(options)).attr("data-loading", options.loading ? "" : undefined);
|
|
39
|
+
|
|
40
|
+
// ../../src/components/effectcn/checkbox.ts
|
|
41
|
+
var CheckboxRoot = (h, checkbox, options = {}) => checkbox.root(h.button.class(cn("border-input bg-background inline-grid size-4 shrink-0 place-items-center rounded-xs border p-0 " + "text-brand-foreground hover:border-muted-foreground shadow-sm transition-colors duration-150 " + "data-[checked]:border-brand data-[checked]:bg-brand " + "data-[indeterminate]:border-brand data-[indeterminate]:bg-brand " + "data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50 data-[readonly]:cursor-default", options.class)));
|
|
42
|
+
var CheckboxIndicator = (h, checkbox, options = {}) => checkbox.indicator(h.span.class(cn("-mt-0.5 h-[5px] w-[9px] -rotate-45 border-b-[1.5px] border-l-[1.5px] border-current " + "data-[unchecked]:hidden " + "data-[indeterminate]:mt-0 data-[indeterminate]:h-0 data-[indeterminate]:w-2 " + "data-[indeterminate]:rotate-0 data-[indeterminate]:border-l-0", options.class)));
|
|
43
|
+
|
|
44
|
+
// ../../src/components/effectcn/input.ts
|
|
45
|
+
import {
|
|
46
|
+
Input as KitInput
|
|
47
|
+
} from "effect/ui/kit";
|
|
48
|
+
var base2 = "block h-8.5 w-full min-w-0 rounded-md border border-input bg-background px-3 text-[13px] text-foreground shadow-sm outline-none " + "transition-[border-color,box-shadow] duration-150 placeholder:text-muted-foreground " + "focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/20 " + "aria-invalid:border-destructive aria-invalid:focus-visible:ring-destructive/20 " + "data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50 " + "[&[readonly]]:bg-muted [&[readonly]]:text-muted-foreground [&[readonly]]:shadow-none " + "[&[type=file]]:cursor-pointer [&[type=file]]:pl-0 [&[type=file]]:leading-8 [&[type=file]]:text-muted-foreground " + "file:mr-3 file:h-8 file:cursor-pointer file:border-0 file:border-r file:border-solid file:border-input file:bg-muted file:px-3 " + "file:text-[13px] file:font-medium file:text-foreground";
|
|
49
|
+
var sizes2 = {
|
|
50
|
+
default: "",
|
|
51
|
+
sm: "h-7 rounded-sm px-2.5 text-xs",
|
|
52
|
+
lg: "h-10 px-3.5 text-sm"
|
|
53
|
+
};
|
|
54
|
+
var inputVariants = (options = {}) => cn(base2, sizes2[options.size ?? "default"], options.class);
|
|
55
|
+
var Input = (h, options) => KitInput(h, options).class(inputVariants(options));
|
|
56
|
+
|
|
57
|
+
// ../../src/components/effectcn/menu.ts
|
|
58
|
+
var popup = "max-h-[var(--available-height)] max-w-[min(320px,var(--available-width))] min-w-[200px] origin-[var(--transform-origin)] " + "overflow-y-auto rounded-lg border bg-popover p-1 text-[13px] leading-snug text-foreground shadow-float outline-none " + "transition-[opacity,scale] duration-150 ease-out data-[nested]:min-w-[150px] " + "data-[starting-style]:scale-95 data-[starting-style]:opacity-0 " + "data-[ending-style]:scale-95 data-[ending-style]:opacity-0 data-[ending-style]:duration-100 " + "data-[instant]:transition-none";
|
|
59
|
+
var item = "relative flex min-h-[30px] cursor-default items-center gap-2 rounded-sm px-2 whitespace-nowrap text-foreground " + "no-underline outline-none select-none data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground " + "data-[popup-open]:bg-accent data-[disabled]:opacity-45 " + "[&_svg]:size-[15px] [&_svg]:shrink-0 [&_svg]:text-muted-foreground";
|
|
60
|
+
var itemVariants = {
|
|
61
|
+
default: "",
|
|
62
|
+
destructive: "text-destructive data-[highlighted]:bg-destructive/10 data-[highlighted]:text-destructive [&_svg]:text-destructive"
|
|
63
|
+
};
|
|
64
|
+
var inset = "pl-[30px]";
|
|
65
|
+
var tick = "before:absolute before:top-1/2 before:left-[10px] before:h-[5px] before:w-[9px] before:-translate-y-[70%] " + "before:-rotate-45 before:border-b-2 before:border-l-2 before:border-brand before:opacity-0 before:content-[''] " + "data-[checked]:before:opacity-100";
|
|
66
|
+
var dot = "before:absolute before:top-1/2 before:left-[12px] before:size-1.5 before:-translate-y-1/2 before:rounded-full " + "before:bg-brand before:opacity-0 before:content-[''] data-[checked]:before:opacity-100";
|
|
67
|
+
var submenuArrow = "after:ml-auto after:size-1.5 after:-translate-x-0.5 after:rotate-45 after:border-t-[1.5px] after:border-r-[1.5px] " + "after:border-muted-foreground after:content-['']";
|
|
68
|
+
var MenuPositioner = (h, menu, options = {}) => menu.positioner(h.div.class(cn("overflow-visible border-0 bg-transparent p-0 text-inherit outline-none", options.class)));
|
|
69
|
+
var MenuPopup = (h, menu, options = {}) => menu.popup(h.div.class(cn(popup, options.class)));
|
|
70
|
+
var MenuItem = (h, menu, options) => menu.item({
|
|
71
|
+
element: h.div.class(cn(item, itemVariants[options.variant ?? "default"], options.inset === true && inset, options.class)),
|
|
72
|
+
value: options.value,
|
|
73
|
+
closeOnClick: options.closeOnClick
|
|
74
|
+
});
|
|
75
|
+
var MenuSubTrigger = (h, menu, submenu, options) => menu.item({
|
|
76
|
+
element: submenu.submenuTrigger(h.div.class(cn(item, submenuArrow, options.inset === true && inset, options.class))),
|
|
77
|
+
value: options.value
|
|
78
|
+
});
|
|
79
|
+
var MenuSeparator = (h, menu, options = {}) => menu.separator(h.div.class(cn("bg-border -mx-1 my-1 h-px", options.class)));
|
|
80
|
+
var MenuInput = (h, menu, options = {}) => menu.input(h.input.class(cn("-mx-1 -mt-1 mb-1 block h-[34px] w-[calc(100%+0.5rem)] border-b bg-transparent px-3 outline-none", "placeholder:text-muted-foreground", options.class)).attrs({
|
|
81
|
+
placeholder: options.placeholder,
|
|
82
|
+
"aria-label": options.label ?? options.placeholder
|
|
83
|
+
}));
|
|
84
|
+
var MenuEmpty = (h, menu, options = {}) => menu.empty(h.div.class(cn("text-muted-foreground px-2 py-3.5 text-center", options.class)));
|
|
85
|
+
|
|
86
|
+
// ../../src/components/effectcn/menubar.ts
|
|
87
|
+
var MenubarRoot = (h, menubar, className) => menubar.root(h.div.class(cn("group/menubar bg-background inline-flex items-center gap-0.5 rounded-md border p-[3px] shadow-sm", "data-[orientation=vertical]:min-w-40 data-[orientation=vertical]:flex-col data-[orientation=vertical]:items-stretch", className)));
|
|
88
|
+
var MenubarTrigger = (h, menu, label, className) => menu.trigger({
|
|
89
|
+
element: h.button.class(cn("text-foreground hover:bg-accent hover:text-accent-foreground data-[popup-open]:bg-accent data-[popup-open]:text-accent-foreground flex h-7 cursor-default items-center gap-2 rounded-sm px-2.5 text-[13px] font-medium transition-colors duration-150 select-none focus-visible:outline-offset-0 data-[disabled]:pointer-events-none data-[disabled]:opacity-45", className)).attr("aria-label", label)
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
// ../../src/components/data-table/html.ts
|
|
93
|
+
import { krakstackLocaleRead as krakstackLocaleRead2 } from "@krak-stack/registry/krakstack-provider/html";
|
|
94
|
+
|
|
95
|
+
// ../../src/components/pagination/html.ts
|
|
96
|
+
import { Html } from "effect/ui/html";
|
|
97
|
+
import { Select } from "effect/ui/kit";
|
|
98
|
+
|
|
99
|
+
// ../../src/components/effectcn/select.ts
|
|
100
|
+
var triggerSizes = {
|
|
101
|
+
sm: "h-7 min-w-36 gap-1.5 rounded-sm pr-2 pl-2.5 text-xs",
|
|
102
|
+
default: "h-8.5 min-w-48 pr-2.5 pl-3 text-[13px]",
|
|
103
|
+
lg: "h-10 min-w-56 pr-3 pl-3.5 text-sm"
|
|
104
|
+
};
|
|
105
|
+
var popupSizes = {
|
|
106
|
+
sm: "text-xs [&_[role=option]]:min-h-6.5 [&_[role=option]]:px-1.5 [&_[role=option]]:py-0.5",
|
|
107
|
+
default: "text-[13px]",
|
|
108
|
+
lg: "text-sm [&_[role=option]]:min-h-8.5 [&_[role=option]]:px-2.5"
|
|
109
|
+
};
|
|
110
|
+
var SelectLabel = (h, select, options = {}) => select.label(h.div.class(cn("mb-1.5 cursor-default text-[13px] leading-snug font-medium", options.class)));
|
|
111
|
+
var SelectTrigger = (h, select, options = {}) => select.trigger(h.button.on("mousedown", () => {
|
|
112
|
+
return;
|
|
113
|
+
}, { preventDefault: "always" }).class(cn("border-input bg-background inline-flex items-center justify-between gap-2 rounded-md border text-start", "text-foreground leading-none whitespace-nowrap shadow-sm select-none", "hover:bg-accent data-[popup-open]:bg-accent transition-colors duration-150", "data-[disabled]:hover:bg-background data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50", "data-[readonly]:bg-muted data-[readonly]:cursor-default", triggerSizes[options.size ?? "default"], options.class)));
|
|
114
|
+
var SelectValue = (h, select, options = {}) => select.value(h.span.class(cn("data-[placeholder]:text-muted-foreground min-w-0 truncate leading-snug", options.class)));
|
|
115
|
+
var SelectIcon = (h, select, options = {}) => select.icon(h.span.class(cn("border-muted-foreground mx-1 mb-[3px] size-[7px] shrink-0 rotate-45 border-r-[1.5px] border-b-[1.5px]", options.class)));
|
|
116
|
+
var SelectPositioner = (h, select, options = {}) => select.positioner(h.div.class(cn("outline-none data-[side=none]:my-2.5", options.class)));
|
|
117
|
+
var SelectPopup = (h, select, options = {}) => select.popup(h.div.class(cn("relative box-border max-w-[var(--available-width)] min-w-[max(var(--anchor-width),10rem)] overflow-y-auto", "bg-popover text-foreground shadow-float rounded-lg border p-1 outline-none", "max-h-[min(var(--available-height),20rem)] data-[side=none]:max-h-none", "origin-[var(--transform-origin)] transition-[opacity,scale] duration-150", "data-[ending-style]:opacity-0 data-[starting-style]:opacity-0", "not-data-[side=none]:data-[ending-style]:scale-95 not-data-[side=none]:data-[starting-style]:scale-95", "data-[side=none]:[scrollbar-width:none]", "has-[>[data-slot=select-list]]:flex has-[>[data-slot=select-list]]:flex-col", "has-[>[data-slot=select-list]]:overflow-hidden has-[>[data-slot=select-list]]:p-0", popupSizes[options.size ?? "default"], options.class)));
|
|
118
|
+
var SelectList = (h, select, options = {}) => select.list(h.div.attr("data-slot", "select-list").class(cn("min-h-0 flex-1 [scrollbar-width:none] overflow-y-auto p-1 outline-none", options.class)));
|
|
119
|
+
var SelectItem = (h, select, options) => select.item({
|
|
120
|
+
element: h.div.class(cn("flex min-h-7.5 cursor-default scroll-my-1 items-center gap-2 rounded-sm px-2 py-1 leading-snug outline-none", "data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground select-none", "data-[disabled]:text-muted-foreground data-[disabled]:opacity-60 data-[selected]:font-medium", "[&_svg]:text-muted-foreground [&_svg]:size-[15px] [&_svg]:shrink-0", options.class)),
|
|
121
|
+
value: options.value
|
|
122
|
+
});
|
|
123
|
+
var SelectItemText = (h, select, options = {}) => select.itemText(h.div.class(cn("min-w-0 flex-1 whitespace-nowrap", options.class)));
|
|
124
|
+
var SelectItemIndicator = (h, select, options) => select.itemIndicator({
|
|
125
|
+
element: h.span.class(cn("border-brand mr-1.5 mb-0.5 ml-2.5 h-[9px] w-[5px] shrink-0 rotate-45 border-r-[1.5px] border-b-[1.5px]", options.class)),
|
|
126
|
+
value: options.value
|
|
127
|
+
});
|
|
128
|
+
var scrollArrow = "inset-x-0 z-10 hidden h-6 cursor-default place-items-center rounded-lg bg-popover data-[visible]:grid " + "before:size-1.5 before:rotate-45 before:border-muted-foreground";
|
|
129
|
+
var SelectScrollUpArrow = (h, select, options = {}) => select.scrollUpArrow({
|
|
130
|
+
keepMounted: true,
|
|
131
|
+
element: h.div.class(cn(scrollArrow, "top-0 before:translate-y-0.5 before:border-t-[1.5px] before:border-l-[1.5px]", options.class))
|
|
132
|
+
});
|
|
133
|
+
var SelectScrollDownArrow = (h, select, options = {}) => select.scrollDownArrow({
|
|
134
|
+
keepMounted: true,
|
|
135
|
+
element: h.div.class(cn(scrollArrow, "bottom-0 before:-translate-y-0.5 before:border-r-[1.5px] before:border-b-[1.5px]", options.class))
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
// ../../src/components/pagination/html.ts
|
|
139
|
+
import { krakstackLocaleRead } from "@krak-stack/registry/krakstack-provider/html";
|
|
140
|
+
|
|
141
|
+
// ../../src/lib/lucide-effect.ts
|
|
142
|
+
import {
|
|
143
|
+
ArrowDown as arrowDown,
|
|
144
|
+
ArrowUp as arrowUp,
|
|
145
|
+
ListFilter as listFilter,
|
|
146
|
+
Check as check,
|
|
147
|
+
ChevronLeft as chevronLeft,
|
|
148
|
+
ChevronDown as chevronDown,
|
|
149
|
+
ChevronRight as chevronRight,
|
|
150
|
+
ChevronsLeft as chevronsLeft,
|
|
151
|
+
ChevronsRight as chevronsRight,
|
|
152
|
+
ChevronsUpDown as chevronsUpDown,
|
|
153
|
+
Copy as copy,
|
|
154
|
+
Download as download,
|
|
155
|
+
Eye as eye,
|
|
156
|
+
EyeOff as eyeOff,
|
|
157
|
+
Ellipsis as ellipsis,
|
|
158
|
+
FileJson as fileJson,
|
|
159
|
+
FileText as fileText,
|
|
160
|
+
GripVertical as gripVertical,
|
|
161
|
+
Image as image,
|
|
162
|
+
LayoutGrid as layoutGrid,
|
|
163
|
+
LoaderCircle as loaderCircle,
|
|
164
|
+
Mail as mail,
|
|
165
|
+
Paperclip as paperclip,
|
|
166
|
+
RefreshCw as refreshCw,
|
|
167
|
+
RotateCcw as rotateCcw,
|
|
168
|
+
Rows3 as rows3,
|
|
169
|
+
Search as search,
|
|
170
|
+
Settings2 as settings2,
|
|
171
|
+
TriangleAlert as triangleAlert,
|
|
172
|
+
X as x
|
|
173
|
+
} from "lucide";
|
|
174
|
+
var createLucideIcon = (icon) => (h, {
|
|
175
|
+
size = 24,
|
|
176
|
+
color = "currentColor",
|
|
177
|
+
strokeWidth = 2,
|
|
178
|
+
className
|
|
179
|
+
} = {}) => h.svg.attrs({
|
|
180
|
+
class: className,
|
|
181
|
+
width: String(size),
|
|
182
|
+
height: String(size),
|
|
183
|
+
viewBox: "0 0 24 24",
|
|
184
|
+
fill: "none",
|
|
185
|
+
stroke: color,
|
|
186
|
+
"stroke-width": String(strokeWidth),
|
|
187
|
+
"stroke-linecap": "round",
|
|
188
|
+
"stroke-linejoin": "round",
|
|
189
|
+
"aria-hidden": "true"
|
|
190
|
+
}).children(...icon.map(([tag, attributes]) => {
|
|
191
|
+
const attrs = Object.fromEntries(Object.entries(attributes).flatMap(([name, value]) => value === undefined ? [] : [[name, String(value)]]));
|
|
192
|
+
switch (tag) {
|
|
193
|
+
case "path":
|
|
194
|
+
return h.path.attrs(attrs);
|
|
195
|
+
case "circle":
|
|
196
|
+
return h.circle.attrs(attrs);
|
|
197
|
+
case "ellipse":
|
|
198
|
+
return h.ellipse.attrs(attrs);
|
|
199
|
+
case "line":
|
|
200
|
+
return h.line.attrs(attrs);
|
|
201
|
+
case "polyline":
|
|
202
|
+
return h.polyline.attrs(attrs);
|
|
203
|
+
case "polygon":
|
|
204
|
+
return h.polygon.attrs(attrs);
|
|
205
|
+
case "rect":
|
|
206
|
+
return h.rect.attrs(attrs);
|
|
207
|
+
default:
|
|
208
|
+
throw new Error(`Unsupported Lucide SVG element: ${tag}`);
|
|
209
|
+
}
|
|
210
|
+
}));
|
|
211
|
+
var Check = createLucideIcon(check);
|
|
212
|
+
var ArrowDown = createLucideIcon(arrowDown);
|
|
213
|
+
var ArrowUp = createLucideIcon(arrowUp);
|
|
214
|
+
var ListFilter = createLucideIcon(listFilter);
|
|
215
|
+
var ChevronLeft = createLucideIcon(chevronLeft);
|
|
216
|
+
var ChevronDown = createLucideIcon(chevronDown);
|
|
217
|
+
var ChevronRight = createLucideIcon(chevronRight);
|
|
218
|
+
var ChevronsLeft = createLucideIcon(chevronsLeft);
|
|
219
|
+
var ChevronsRight = createLucideIcon(chevronsRight);
|
|
220
|
+
var ChevronsUpDown = createLucideIcon(chevronsUpDown);
|
|
221
|
+
var Copy = createLucideIcon(copy);
|
|
222
|
+
var Download = createLucideIcon(download);
|
|
223
|
+
var Eye = createLucideIcon(eye);
|
|
224
|
+
var EyeOff = createLucideIcon(eyeOff);
|
|
225
|
+
var Ellipsis = createLucideIcon(ellipsis);
|
|
226
|
+
var FileJson = createLucideIcon(fileJson);
|
|
227
|
+
var FileText = createLucideIcon(fileText);
|
|
228
|
+
var GripVertical = createLucideIcon(gripVertical);
|
|
229
|
+
var Image = createLucideIcon(image);
|
|
230
|
+
var LayoutGrid = createLucideIcon(layoutGrid);
|
|
231
|
+
var LoaderCircle = createLucideIcon(loaderCircle);
|
|
232
|
+
var Mail = createLucideIcon(mail);
|
|
233
|
+
var Paperclip = createLucideIcon(paperclip);
|
|
234
|
+
var RefreshCw = createLucideIcon(refreshCw);
|
|
235
|
+
var RotateCcw = createLucideIcon(rotateCcw);
|
|
236
|
+
var Rows3 = createLucideIcon(rows3);
|
|
237
|
+
var Search = createLucideIcon(search);
|
|
238
|
+
var Settings2 = createLucideIcon(settings2);
|
|
239
|
+
var TriangleAlert = createLucideIcon(triangleAlert);
|
|
240
|
+
var X = createLucideIcon(x);
|
|
241
|
+
|
|
242
|
+
// ../../src/components/pagination/classes.ts
|
|
243
|
+
var paginationClasses = {
|
|
244
|
+
root: "flex flex-col gap-3 px-2 sm:flex-row sm:items-center sm:justify-between",
|
|
245
|
+
summary: "text-muted-foreground flex flex-wrap items-center gap-x-3 gap-y-1 text-sm",
|
|
246
|
+
controls: "flex items-center gap-4 sm:justify-end",
|
|
247
|
+
controlGroup: "flex items-center gap-2",
|
|
248
|
+
navigation: "flex items-center gap-1",
|
|
249
|
+
compactRoot: "gap-2 px-0 sm:flex-col sm:items-stretch",
|
|
250
|
+
compactControls: "flex-wrap justify-between gap-2 sm:justify-between"
|
|
251
|
+
};
|
|
252
|
+
var resolvePaginationClasses = (overrides) => ({
|
|
253
|
+
...paginationClasses,
|
|
254
|
+
...overrides
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
// ../../src/components/pagination/index.ts
|
|
258
|
+
import { Schema as Schema2 } from "effect";
|
|
259
|
+
import { Component, UiSchema } from "effect/ui";
|
|
260
|
+
|
|
261
|
+
// ../../src/components/pagination/schema.ts
|
|
262
|
+
import { Schema, Struct } from "effect";
|
|
263
|
+
var Labels = Schema.Struct({
|
|
264
|
+
pageSize: Schema.optional(Schema.String),
|
|
265
|
+
goToFirstPage: Schema.optional(Schema.String),
|
|
266
|
+
goToPreviousPage: Schema.optional(Schema.String),
|
|
267
|
+
goToNextPage: Schema.optional(Schema.String),
|
|
268
|
+
goToLastPage: Schema.optional(Schema.String)
|
|
269
|
+
}).annotate({ identifier: "PaginationLabelOverrides" });
|
|
270
|
+
var Translations = Schema.Record(Schema.String, Schema.UndefinedOr(Labels));
|
|
271
|
+
var PaginationClassesOverridesSchema = Schema.Record(Schema.Literals(Struct.keys(paginationClasses)), Schema.optionalKey(Schema.String)).annotate({ identifier: "PaginationClassesOverrides" });
|
|
272
|
+
var PaginationPropsSchema = Schema.Struct({
|
|
273
|
+
classes: Schema.optional(PaginationClassesOverridesSchema),
|
|
274
|
+
className: Schema.optional(Schema.String),
|
|
275
|
+
pageSizeContentClassName: Schema.optional(Schema.String),
|
|
276
|
+
compact: Schema.optional(Schema.Boolean),
|
|
277
|
+
locale: Schema.optional(Schema.String),
|
|
278
|
+
messages: Schema.optional(Translations),
|
|
279
|
+
page: Schema.Int,
|
|
280
|
+
pageCount: Schema.Int,
|
|
281
|
+
pageSize: Schema.Int,
|
|
282
|
+
pageSizes: Schema.optional(Schema.Array(Schema.Int)),
|
|
283
|
+
selectedRows: Schema.optional(Schema.Int),
|
|
284
|
+
showResults: Schema.optional(Schema.Boolean),
|
|
285
|
+
totalRows: Schema.Int
|
|
286
|
+
}).annotate({ identifier: "PaginationProps" });
|
|
287
|
+
|
|
288
|
+
// ../../src/components/pagination/index.ts
|
|
289
|
+
var PaginationMessage = UiSchema.TaggedEnum({
|
|
290
|
+
Opened: {},
|
|
291
|
+
Closed: {},
|
|
292
|
+
PageRequested: { page: Schema2.Int },
|
|
293
|
+
SizeRequested: { pageSize: Schema2.Int }
|
|
294
|
+
}).annotate({ identifier: "PaginationMessage" });
|
|
295
|
+
var PaginationEvents = UiSchema.TaggedEnum({
|
|
296
|
+
PageChanged: { page: Schema2.Int },
|
|
297
|
+
PageSizeChanged: { pageSize: Schema2.Int }
|
|
298
|
+
}).annotate({ identifier: "PaginationEvents" });
|
|
299
|
+
var paginationOptions = {
|
|
300
|
+
name: "Pagination",
|
|
301
|
+
props: PaginationPropsSchema,
|
|
302
|
+
model: Schema2.Boolean,
|
|
303
|
+
message: PaginationMessage,
|
|
304
|
+
events: PaginationEvents,
|
|
305
|
+
restore: false
|
|
306
|
+
};
|
|
307
|
+
var update = Component.define(paginationOptions).update({
|
|
308
|
+
Opened: () => true,
|
|
309
|
+
Closed: () => false,
|
|
310
|
+
PageRequested: ($, { page }) => $.set($.model).emit(PaginationEvents.PageChanged({ page })),
|
|
311
|
+
SizeRequested: ($, { pageSize }) => $.set(false).emit(PaginationEvents.PageSizeChanged({ pageSize }))
|
|
312
|
+
});
|
|
313
|
+
var paginationBehaviours = {
|
|
314
|
+
init: () => false,
|
|
315
|
+
update
|
|
316
|
+
};
|
|
317
|
+
var messages = {
|
|
318
|
+
en: {
|
|
319
|
+
pageSize: "Page size",
|
|
320
|
+
results: (count) => `${count} results`,
|
|
321
|
+
selectedOf: (selected, total) => `${selected} of ${total}`,
|
|
322
|
+
pageOf: (page, total) => `Page ${page} of ${total}`,
|
|
323
|
+
goToFirstPage: "Go to first page",
|
|
324
|
+
goToPreviousPage: "Go to previous page",
|
|
325
|
+
goToNextPage: "Go to next page",
|
|
326
|
+
goToLastPage: "Go to last page"
|
|
327
|
+
},
|
|
328
|
+
fr: {
|
|
329
|
+
pageSize: "Taille de la page",
|
|
330
|
+
results: (count) => `${count} résultats`,
|
|
331
|
+
selectedOf: (selected, total) => `${selected} sur ${total}`,
|
|
332
|
+
pageOf: (page, total) => `Page ${page} sur ${total}`,
|
|
333
|
+
goToFirstPage: "Aller à la première page",
|
|
334
|
+
goToPreviousPage: "Aller à la page précédente",
|
|
335
|
+
goToNextPage: "Aller à la page suivante",
|
|
336
|
+
goToLastPage: "Aller à la dernière page"
|
|
337
|
+
}
|
|
338
|
+
};
|
|
339
|
+
var paginationMessages = (locale = "en", translations) => ({
|
|
340
|
+
...locale.startsWith("fr") ? messages.fr : messages.en,
|
|
341
|
+
...translations?.[locale.split("-")[0] ?? locale],
|
|
342
|
+
...translations?.[locale]
|
|
343
|
+
});
|
|
344
|
+
var defaultPageSizes = [20, 50, 100];
|
|
345
|
+
var paginationPageLabel = (page, pageCount, pageOf) => pageCount > 0 ? pageOf(page + 1, pageCount) : undefined;
|
|
346
|
+
var paginationNavigation = (page, pageCount) => ({
|
|
347
|
+
goToFirstPage: {
|
|
348
|
+
page: 0,
|
|
349
|
+
disabled: pageCount <= 0 || page <= 0,
|
|
350
|
+
edge: true
|
|
351
|
+
},
|
|
352
|
+
goToPreviousPage: {
|
|
353
|
+
page: page - 1,
|
|
354
|
+
disabled: pageCount <= 0 || page <= 0,
|
|
355
|
+
edge: false
|
|
356
|
+
},
|
|
357
|
+
goToNextPage: {
|
|
358
|
+
page: page + 1,
|
|
359
|
+
disabled: pageCount <= 0 || page + 1 >= pageCount,
|
|
360
|
+
edge: false
|
|
361
|
+
},
|
|
362
|
+
goToLastPage: {
|
|
363
|
+
page: pageCount - 1,
|
|
364
|
+
disabled: pageCount <= 0 || page + 1 >= pageCount,
|
|
365
|
+
edge: true
|
|
366
|
+
}
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
// ../../src/components/pagination/html.ts
|
|
370
|
+
var icons = {
|
|
371
|
+
goToFirstPage: ChevronsLeft,
|
|
372
|
+
goToPreviousPage: ChevronLeft,
|
|
373
|
+
goToNextPage: ChevronRight,
|
|
374
|
+
goToLastPage: ChevronsRight
|
|
375
|
+
};
|
|
376
|
+
var Pagination = Html.component({
|
|
377
|
+
...paginationOptions,
|
|
378
|
+
reads: { localeConfig: krakstackLocaleRead }
|
|
379
|
+
}).make({
|
|
380
|
+
...paginationBehaviours,
|
|
381
|
+
view: (h, open) => {
|
|
382
|
+
const paginationClasses = resolvePaginationClasses(h.props.classes);
|
|
383
|
+
const {
|
|
384
|
+
compact,
|
|
385
|
+
page,
|
|
386
|
+
pageCount,
|
|
387
|
+
pageSize,
|
|
388
|
+
pageSizes = defaultPageSizes,
|
|
389
|
+
selectedRows = 0,
|
|
390
|
+
showResults = true,
|
|
391
|
+
totalRows
|
|
392
|
+
} = h.props;
|
|
393
|
+
const labels = paginationMessages(h.props.locale ?? h.reads.localeConfig?.locale, h.props.messages);
|
|
394
|
+
const navigation = paginationNavigation(page, pageCount);
|
|
395
|
+
const pageLabel = paginationPageLabel(page, pageCount, labels.pageOf);
|
|
396
|
+
const items = pageSizes.map((size) => ({
|
|
397
|
+
value: String(size),
|
|
398
|
+
label: String(size)
|
|
399
|
+
}));
|
|
400
|
+
return h.div.attr("data-slot", "pagination").class(cn(paginationClasses.root, compact && paginationClasses.compactRoot, h.props.className)).children(showResults && h.div.class(paginationClasses.summary).children(h.span.children(labels.results(totalRows)), selectedRows > 0 && h.span.children(labels.selectedOf(selectedRows, totalRows))), h.div.class(cn(paginationClasses.controls, compact && paginationClasses.compactControls)).children(Select(h, {
|
|
401
|
+
props: {
|
|
402
|
+
open,
|
|
403
|
+
items,
|
|
404
|
+
value: items.some(({ value }) => value === String(pageSize)) ? String(pageSize) : null,
|
|
405
|
+
placeholder: String(pageSize),
|
|
406
|
+
side: "top",
|
|
407
|
+
alignItemWithTrigger: false
|
|
408
|
+
},
|
|
409
|
+
onEmit: {
|
|
410
|
+
RequestedOpen: () => PaginationMessage.Opened(),
|
|
411
|
+
RequestedClose: () => PaginationMessage.Closed(),
|
|
412
|
+
Picked: ({ value }) => {
|
|
413
|
+
const selected = pageSizes.find((size) => String(size) === value);
|
|
414
|
+
return selected === undefined ? undefined : PaginationMessage.SizeRequested({ pageSize: selected });
|
|
415
|
+
},
|
|
416
|
+
Settled: () => {
|
|
417
|
+
return;
|
|
418
|
+
}
|
|
419
|
+
},
|
|
420
|
+
view: (select) => h.div.class(paginationClasses.controlGroup).children(SelectLabel(h, select, {
|
|
421
|
+
class: cn("mb-0", !compact && "sr-only sm:not-sr-only")
|
|
422
|
+
}).children(labels.pageSize), SelectTrigger(h, select, {
|
|
423
|
+
size: "sm",
|
|
424
|
+
class: "min-w-0"
|
|
425
|
+
}).children(SelectValue(h, select), SelectIcon(h, select)), SelectPositioner(h, select).children(SelectPopup(h, select, {
|
|
426
|
+
size: "sm",
|
|
427
|
+
class: h.props.pageSizeContentClassName
|
|
428
|
+
}).children(SelectScrollUpArrow(h, select), SelectList(h, select).children(...items.map(({ value, label }) => SelectItem(h, select, { value }).children(SelectItemText(h, select).children(label), SelectItemIndicator(h, select, { value })))), SelectScrollDownArrow(h, select))))
|
|
429
|
+
}), h.div.class(paginationClasses.controlGroup).children(pageLabel !== undefined && h.div.class("text-sm font-medium").children(pageLabel), h.div.class(paginationClasses.navigation).children(...[
|
|
430
|
+
"goToFirstPage",
|
|
431
|
+
"goToPreviousPage",
|
|
432
|
+
"goToNextPage",
|
|
433
|
+
"goToLastPage"
|
|
434
|
+
].map((key) => {
|
|
435
|
+
const Icon = icons[key];
|
|
436
|
+
const control = navigation[key];
|
|
437
|
+
return Button(h, {
|
|
438
|
+
size: "icon-sm",
|
|
439
|
+
class: control.edge ? compact ? "hidden" : "hidden lg:inline-flex" : undefined,
|
|
440
|
+
props: { type: "button", disabled: control.disabled },
|
|
441
|
+
onPress: PaginationMessage.PageRequested({ page: control.page })
|
|
442
|
+
}).key(key).attr("aria-label", labels[key]).children(Icon(h));
|
|
443
|
+
})))));
|
|
444
|
+
}
|
|
445
|
+
});
|
|
446
|
+
|
|
447
|
+
// ../../src/lib/query.ts
|
|
448
|
+
import {
|
|
449
|
+
DateTime,
|
|
450
|
+
Effect,
|
|
451
|
+
Option,
|
|
452
|
+
Schema as Schema3,
|
|
453
|
+
SchemaGetter,
|
|
454
|
+
SchemaIssue,
|
|
455
|
+
SchemaTransformation
|
|
456
|
+
} from "effect";
|
|
457
|
+
var parseSortParam = (sort) => {
|
|
458
|
+
const id = sort.startsWith("-") ? sort.slice(1) : sort;
|
|
459
|
+
if (!id || id.includes(",") || id.includes(":")) {
|
|
460
|
+
return null;
|
|
461
|
+
}
|
|
462
|
+
return { id, direction: sort.startsWith("-") ? "desc" : "asc" };
|
|
463
|
+
};
|
|
464
|
+
var SortDirection = Schema3.Union([
|
|
465
|
+
Schema3.Literal("asc"),
|
|
466
|
+
Schema3.Literal("desc")
|
|
467
|
+
]).pipe(Schema3.annotate({
|
|
468
|
+
identifier: "SortDirection",
|
|
469
|
+
title: "Sort Direction",
|
|
470
|
+
description: "Sort direction for list query results.",
|
|
471
|
+
examples: ["asc", "desc"]
|
|
472
|
+
}));
|
|
473
|
+
var SortParam = Schema3.Struct({
|
|
474
|
+
id: Schema3.NonEmptyString,
|
|
475
|
+
direction: SortDirection
|
|
476
|
+
}).pipe(Schema3.annotate({
|
|
477
|
+
identifier: "SortParam",
|
|
478
|
+
title: "Sort Parameter",
|
|
479
|
+
description: "Decoded sort parameter with a field id and direction.",
|
|
480
|
+
examples: [{ id: "publicName", direction: "asc" }]
|
|
481
|
+
}));
|
|
482
|
+
var SortParamFromString = Schema3.String.pipe(Schema3.decodeTo(SortParam, SchemaTransformation.transformEffect({
|
|
483
|
+
decode: (sort) => {
|
|
484
|
+
const sortParam = parseSortParam(sort);
|
|
485
|
+
if (!sortParam) {
|
|
486
|
+
return Effect.fail(new SchemaIssue.InvalidValue({ message: 'Expected sort in the format "field" or "-field"' }, sort));
|
|
487
|
+
}
|
|
488
|
+
return Effect.succeed(sortParam);
|
|
489
|
+
},
|
|
490
|
+
encode: (sort) => Effect.succeed(sort.direction === "desc" ? `-${sort.id}` : sort.id)
|
|
491
|
+
})), Schema3.annotate({
|
|
492
|
+
identifier: "SortParamFromString",
|
|
493
|
+
title: "Sort Parameter From String",
|
|
494
|
+
description: 'URL encoded single sort parameter where descending fields are prefixed with "-".',
|
|
495
|
+
examples: [{ id: "publicName", direction: "asc" }]
|
|
496
|
+
}));
|
|
497
|
+
var SortParamsFromString = Schema3.String.pipe(Schema3.decodeTo(Schema3.Array(SortParam), SchemaTransformation.transformEffect({
|
|
498
|
+
decode: (sort) => {
|
|
499
|
+
if (sort === "")
|
|
500
|
+
return Effect.succeed([]);
|
|
501
|
+
const parts = sort.split(",");
|
|
502
|
+
const sortParams = [];
|
|
503
|
+
for (const part of parts) {
|
|
504
|
+
const sortParam = parseSortParam(part);
|
|
505
|
+
if (!sortParam) {
|
|
506
|
+
return Effect.fail(new SchemaIssue.InvalidValue({ message: 'Expected sort in the format "field,-otherField"' }, sort));
|
|
507
|
+
}
|
|
508
|
+
sortParams.push(sortParam);
|
|
509
|
+
}
|
|
510
|
+
return Effect.succeed(sortParams);
|
|
511
|
+
},
|
|
512
|
+
encode: (sort) => Effect.succeed(sort.map((part) => Schema3.encodeSync(SortParamFromString)(part)).join(","))
|
|
513
|
+
})), Schema3.annotate({
|
|
514
|
+
identifier: "SortParamsFromString",
|
|
515
|
+
title: "Sort Parameters From String",
|
|
516
|
+
description: 'URL encoded sort parameters where descending fields are prefixed with "-" and multiple fields are comma-separated.',
|
|
517
|
+
examples: [
|
|
518
|
+
[
|
|
519
|
+
{ id: "name", direction: "desc" },
|
|
520
|
+
{ id: "age", direction: "asc" }
|
|
521
|
+
]
|
|
522
|
+
]
|
|
523
|
+
}));
|
|
524
|
+
var SortParamsArray = Schema3.Array(SortParam);
|
|
525
|
+
var SortParams = Schema3.declare(Schema3.is(SortParamsArray), {
|
|
526
|
+
identifier: "SortParams",
|
|
527
|
+
toCodec: () => Schema3.link()(SortParamsArray, SchemaTransformation.passthrough()),
|
|
528
|
+
toCodecStringTree: () => Schema3.link()(SortParamsFromString, SchemaTransformation.passthrough())
|
|
529
|
+
});
|
|
530
|
+
var TextFilterOperator = Schema3.Literals([
|
|
531
|
+
"contains",
|
|
532
|
+
"equals",
|
|
533
|
+
"startsWith",
|
|
534
|
+
"endsWith"
|
|
535
|
+
]).annotate({ identifier: "TextFilterOperator" });
|
|
536
|
+
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" });
|
|
537
|
+
var ColumnFilter = Schema3.Union([
|
|
538
|
+
Schema3.Struct({
|
|
539
|
+
id: Schema3.NonEmptyString,
|
|
540
|
+
kind: Schema3.Literal("text"),
|
|
541
|
+
operator: TextFilterOperator,
|
|
542
|
+
value: Schema3.NonEmptyString
|
|
543
|
+
}),
|
|
544
|
+
Schema3.Struct({
|
|
545
|
+
id: Schema3.NonEmptyString,
|
|
546
|
+
kind: Schema3.Literal("number"),
|
|
547
|
+
min: Schema3.optional(Schema3.Finite),
|
|
548
|
+
max: Schema3.optional(Schema3.Finite)
|
|
549
|
+
}).check(Schema3.makeFilter((range) => (range.min !== undefined || range.max !== undefined) && (range.min === undefined || range.max === undefined || range.min <= range.max))),
|
|
550
|
+
Schema3.Struct({
|
|
551
|
+
id: Schema3.NonEmptyString,
|
|
552
|
+
kind: Schema3.Literal("date"),
|
|
553
|
+
from: Schema3.optional(FilterCalendarDate),
|
|
554
|
+
to: Schema3.optional(FilterCalendarDate)
|
|
555
|
+
}).check(Schema3.makeFilter((range) => (range.from !== undefined || range.to !== undefined) && (range.from === undefined || range.to === undefined || range.from <= range.to))),
|
|
556
|
+
Schema3.Struct({
|
|
557
|
+
id: Schema3.NonEmptyString,
|
|
558
|
+
kind: Schema3.Literal("boolean"),
|
|
559
|
+
value: Schema3.Boolean
|
|
560
|
+
}),
|
|
561
|
+
Schema3.Struct({
|
|
562
|
+
id: Schema3.NonEmptyString,
|
|
563
|
+
kind: Schema3.Literal("values"),
|
|
564
|
+
values: Schema3.NonEmptyArray(Schema3.String)
|
|
565
|
+
})
|
|
566
|
+
]).annotate({ identifier: "ColumnFilter" });
|
|
567
|
+
var ColumnFiltersArray = Schema3.Array(ColumnFilter);
|
|
568
|
+
var ColumnFilters = Schema3.declare(Schema3.is(ColumnFiltersArray), {
|
|
569
|
+
identifier: "ColumnFilters",
|
|
570
|
+
toCodec: () => Schema3.link()(ColumnFiltersArray, SchemaTransformation.passthrough()),
|
|
571
|
+
toCodecStringTree: () => Schema3.link()(Schema3.fromJsonString(ColumnFiltersArray), SchemaTransformation.passthrough())
|
|
572
|
+
});
|
|
573
|
+
var DEFAULT_PAGE_SIZE = 100;
|
|
574
|
+
var Query = Schema3.Struct({
|
|
575
|
+
page: Schema3.optional(Schema3.Union([Schema3.Finite, Schema3.FiniteFromString]).check(Schema3.isInt(), Schema3.isGreaterThanOrEqualTo(0))).pipe(Schema3.decodeTo(Schema3.Int.check(Schema3.isGreaterThanOrEqualTo(0)), {
|
|
576
|
+
decode: SchemaGetter.withDefault(Effect.succeed(0)),
|
|
577
|
+
encode: SchemaGetter.transformOptional(Option.filter((page) => page !== 0))
|
|
578
|
+
})),
|
|
579
|
+
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 })), {
|
|
580
|
+
decode: SchemaGetter.withDefault(Effect.succeed(DEFAULT_PAGE_SIZE)),
|
|
581
|
+
encode: SchemaGetter.transformOptional(Option.filter((pageSize) => pageSize !== DEFAULT_PAGE_SIZE))
|
|
582
|
+
})),
|
|
583
|
+
globalFilter: Schema3.optional(Schema3.String),
|
|
584
|
+
sort: Schema3.optional(SortParams),
|
|
585
|
+
filters: Schema3.optional(ColumnFilters)
|
|
586
|
+
}).annotate({
|
|
587
|
+
identifier: "Query",
|
|
588
|
+
title: "Query",
|
|
589
|
+
description: "Zero-based page request parameters with optional filtering and sorting for list endpoints.",
|
|
590
|
+
examples: [
|
|
591
|
+
{
|
|
592
|
+
page: 0,
|
|
593
|
+
pageSize: DEFAULT_PAGE_SIZE,
|
|
594
|
+
globalFilter: "housing",
|
|
595
|
+
sort: [
|
|
596
|
+
{ id: "publicName", direction: "desc" },
|
|
597
|
+
{ id: "createdAt", direction: "asc" }
|
|
598
|
+
]
|
|
599
|
+
}
|
|
600
|
+
]
|
|
601
|
+
});
|
|
602
|
+
var QueryStandard = Schema3.toStandardSchemaV1(Query);
|
|
603
|
+
var PaginationMeta = Schema3.Struct({
|
|
604
|
+
page: Schema3.Int,
|
|
605
|
+
pageSize: Schema3.Int,
|
|
606
|
+
total: Schema3.Int,
|
|
607
|
+
pageCount: Schema3.Int
|
|
608
|
+
}).pipe(Schema3.annotate({
|
|
609
|
+
identifier: "PaginationMeta",
|
|
610
|
+
title: "Pagination Metadata",
|
|
611
|
+
description: "Pagination metadata returned with a paginated list response.",
|
|
612
|
+
examples: [{ page: 0, pageSize: 20, total: 125, pageCount: 7 }]
|
|
613
|
+
}));
|
|
614
|
+
|
|
615
|
+
// ../../src/components/data-table/index.ts
|
|
616
|
+
import { DateTime as DateTime3, Effect as Effect2, Option as Option3, Redacted, Schema as Schema5, Stream } from "effect";
|
|
617
|
+
import { Csv } from "effect/encoding";
|
|
618
|
+
import { Command, Component as Component2, Subscription, UiSchema as UiSchema2 } from "effect/ui";
|
|
619
|
+
|
|
620
|
+
// ../../src/components/data-table/schema.ts
|
|
621
|
+
import { DateTime as DateTime2, Option as Option2, Schema as Schema4, Struct as Struct2, Tuple } from "effect";
|
|
622
|
+
|
|
623
|
+
// ../../src/components/data-table/classes.ts
|
|
624
|
+
var tableClasses = {
|
|
625
|
+
selectionCell: "w-10 p-0 align-middle",
|
|
626
|
+
selectionCenter: "grid place-items-center",
|
|
627
|
+
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",
|
|
628
|
+
selectedTrigger: "bg-primary text-primary-foreground hover:bg-primary/90 hover:text-primary-foreground",
|
|
629
|
+
toolbar: "flex min-w-0 shrink-0 flex-wrap items-center gap-2",
|
|
630
|
+
toolbarSearch: "relative min-w-0 flex-[1_1_12rem]",
|
|
631
|
+
toolbarMenus: "w-max min-w-0 max-w-full",
|
|
632
|
+
menubar: "h-auto w-full flex-wrap justify-start border border-input bg-transparent",
|
|
633
|
+
cell: "overflow-hidden",
|
|
634
|
+
cellContent: "min-w-0 wrap-anywhere",
|
|
635
|
+
actionTrigger: "size-8 focus-visible:ring-inset",
|
|
636
|
+
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))]",
|
|
637
|
+
actionsAlign: "flex min-h-12 items-center justify-end pe-1",
|
|
638
|
+
header: "relative h-12 p-0",
|
|
639
|
+
stickyHeader: "sticky top-0 z-30 bg-background",
|
|
640
|
+
stickyHeaderRule: "after:border-border after:pointer-events-none after:absolute after:inset-x-0 after:bottom-0 after:border-b",
|
|
641
|
+
headerTrigger: "absolute inset-0 h-full w-full min-w-0 justify-start rounded-none px-2 pe-4 focus-visible:ring-inset",
|
|
642
|
+
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",
|
|
643
|
+
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",
|
|
644
|
+
relationshipTrigger: "h-full w-full min-w-0 justify-between rounded-none px-2 text-start focus-visible:ring-inset",
|
|
645
|
+
reference: "flex min-w-0 items-center gap-2",
|
|
646
|
+
referenceAvatar: "relative grid size-8 shrink-0 place-items-center overflow-hidden bg-muted text-xs font-medium",
|
|
647
|
+
referenceText: "flex min-w-0 flex-col leading-tight",
|
|
648
|
+
group: "bg-muted/40 hover:bg-accent!",
|
|
649
|
+
groupContent: "flex min-w-0 items-center gap-2 py-2 pe-1 ps-2",
|
|
650
|
+
groupSticky: "sticky start-0 w-[100cqw] max-w-full",
|
|
651
|
+
groupTrigger: "flex min-w-0 flex-1 cursor-pointer items-center gap-2 text-start font-medium",
|
|
652
|
+
referenceName: "truncate font-medium",
|
|
653
|
+
referenceDescription: "text-muted-foreground truncate text-xs"
|
|
654
|
+
};
|
|
655
|
+
var resolveTableClasses = (overrides) => ({
|
|
656
|
+
...tableClasses,
|
|
657
|
+
...overrides
|
|
658
|
+
});
|
|
659
|
+
|
|
660
|
+
// ../../src/components/data-table/schema.ts
|
|
661
|
+
var TableClassesOverridesSchema = Schema4.Record(Schema4.Literals(Struct2.keys(tableClasses)), Schema4.optionalKey(Schema4.String)).annotate({ identifier: "TableClassesOverrides" });
|
|
662
|
+
var DataTableCommonPropsSchema = Schema4.Struct({
|
|
663
|
+
classes: Schema4.optional(TableClassesOverridesSchema),
|
|
664
|
+
className: Schema4.optionalKey(Schema4.String),
|
|
665
|
+
locale: Schema4.optionalKey(Schema4.String)
|
|
666
|
+
}).annotate({ identifier: "DataTableCommonProps" });
|
|
667
|
+
var DataTableSortSchema = Schema4.Struct({
|
|
668
|
+
id: Schema4.NonEmptyString,
|
|
669
|
+
direction: Schema4.Literals(["asc", "desc"])
|
|
670
|
+
}).annotate({ identifier: "DataTableSort" });
|
|
671
|
+
var queryFields = {
|
|
672
|
+
page: Schema4.Int.check(Schema4.isGreaterThanOrEqualTo(0)),
|
|
673
|
+
pageSize: Schema4.Int.check(Schema4.isBetween({ minimum: 1, maximum: 100 })),
|
|
674
|
+
globalFilter: Schema4.optional(Schema4.String),
|
|
675
|
+
sort: Schema4.optional(Schema4.Array(DataTableSortSchema)),
|
|
676
|
+
filters: Schema4.optional(Schema4.Array(ColumnFilter))
|
|
677
|
+
};
|
|
678
|
+
var DataTableQuerySchema = Schema4.Struct(queryFields).annotate({
|
|
679
|
+
identifier: "DataTableQuery"
|
|
680
|
+
});
|
|
681
|
+
var PageSizes = Schema4.NonEmptyArray(Schema4.Int.check(Schema4.isBetween({ minimum: 1, maximum: 100 })));
|
|
682
|
+
var DataTableCommonFeaturesSchema = Schema4.Struct({
|
|
683
|
+
search: Schema4.optionalKey(Schema4.Boolean),
|
|
684
|
+
filtering: Schema4.optionalKey(Schema4.Boolean),
|
|
685
|
+
sorting: Schema4.optionalKey(Schema4.Boolean),
|
|
686
|
+
columnVisibility: Schema4.optionalKey(Schema4.Boolean)
|
|
687
|
+
});
|
|
688
|
+
var PaginationSchema = Schema4.Union([
|
|
689
|
+
Schema4.Struct({
|
|
690
|
+
mode: Schema4.optionalKey(Schema4.Literal("client")),
|
|
691
|
+
pageSizes: Schema4.optionalKey(PageSizes)
|
|
692
|
+
}).annotate({ identifier: "DataTableClientPagination" }),
|
|
693
|
+
Schema4.Struct({
|
|
694
|
+
mode: Schema4.Literal("server"),
|
|
695
|
+
rowCount: Schema4.Int.check(Schema4.isGreaterThanOrEqualTo(0)),
|
|
696
|
+
pageSizes: Schema4.optionalKey(PageSizes)
|
|
697
|
+
}).annotate({ identifier: "DataTableServerPagination" })
|
|
698
|
+
]);
|
|
699
|
+
var DataTableItemSchema = Schema4.Struct({
|
|
700
|
+
value: Schema4.NonEmptyString,
|
|
701
|
+
label: Schema4.String
|
|
702
|
+
}).annotate({ identifier: "DataTableItem" });
|
|
703
|
+
var DataTableReferenceSchema = Schema4.Struct({
|
|
704
|
+
label: Schema4.String,
|
|
705
|
+
description: Schema4.optionalKey(Schema4.String),
|
|
706
|
+
imageSrc: Schema4.optionalKey(Schema4.NullOr(Schema4.String))
|
|
707
|
+
}).annotate({ identifier: "DataTableReference" });
|
|
708
|
+
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" });
|
|
709
|
+
var isCalendarDate = Schema4.is(CalendarDate);
|
|
710
|
+
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" });
|
|
711
|
+
var DataTableDateInputSchema = Schema4.Union([
|
|
712
|
+
Schema4.Date,
|
|
713
|
+
Schema4.Int,
|
|
714
|
+
CalendarDate,
|
|
715
|
+
InstantString
|
|
716
|
+
]).annotate({ identifier: "DataTableDateInput" });
|
|
717
|
+
var DateStyle = Schema4.Literals(["full", "long", "medium", "short"]);
|
|
718
|
+
var DataTableDateFormatSchema = Schema4.Struct({
|
|
719
|
+
locale: Schema4.optionalKey(Schema4.String),
|
|
720
|
+
timeZone: Schema4.optionalKey(Schema4.String),
|
|
721
|
+
dateStyle: Schema4.optionalKey(DateStyle),
|
|
722
|
+
exportFormat: Schema4.optionalKey(Schema4.Literals(["iso", "formatted"]))
|
|
723
|
+
}).annotate({ identifier: "DataTableDateFormat" });
|
|
724
|
+
var DataTableDateTimeFormatSchema = Schema4.Struct({
|
|
725
|
+
...DataTableDateFormatSchema.fields,
|
|
726
|
+
timeStyle: Schema4.optionalKey(DateStyle),
|
|
727
|
+
hour12: Schema4.optionalKey(Schema4.Boolean)
|
|
728
|
+
}).annotate({ identifier: "DataTableDateTimeFormat" });
|
|
729
|
+
var DataTableCellValueSchema = Schema4.NullOr(Schema4.Union([
|
|
730
|
+
Schema4.String,
|
|
731
|
+
Schema4.Boolean,
|
|
732
|
+
Schema4.Finite,
|
|
733
|
+
Schema4.Array(DataTableItemSchema),
|
|
734
|
+
DataTableReferenceSchema
|
|
735
|
+
])).annotate({ identifier: "DataTableCellValue" });
|
|
736
|
+
var DataTableActionSchema = Schema4.Struct({
|
|
737
|
+
id: Schema4.NonEmptyString,
|
|
738
|
+
name: Schema4.String,
|
|
739
|
+
variant: Schema4.optionalKey(Schema4.Literals(["default", "destructive"])),
|
|
740
|
+
disabled: Schema4.optionalKey(Schema4.Boolean)
|
|
741
|
+
}).annotate({ identifier: "DataTableAction" });
|
|
742
|
+
var DataTableRowSchema = Schema4.Struct({
|
|
743
|
+
id: Schema4.NonEmptyString,
|
|
744
|
+
label: Schema4.String,
|
|
745
|
+
cells: Schema4.Record(Schema4.String, DataTableCellValueSchema),
|
|
746
|
+
actions: Schema4.optionalKey(Schema4.Array(DataTableActionSchema)),
|
|
747
|
+
primaryActionId: Schema4.optionalKey(Schema4.String),
|
|
748
|
+
groups: Schema4.optionalKey(Schema4.Record(Schema4.String, Schema4.Array(Schema4.String))),
|
|
749
|
+
selectable: Schema4.optionalKey(Schema4.Boolean),
|
|
750
|
+
disabledColumnIds: Schema4.optionalKey(Schema4.Array(Schema4.String))
|
|
751
|
+
}).annotate({ identifier: "DataTableRow" });
|
|
752
|
+
var column = {
|
|
753
|
+
id: Schema4.NonEmptyString,
|
|
754
|
+
headerName: Schema4.String,
|
|
755
|
+
sortable: Schema4.optionalKey(Schema4.Boolean),
|
|
756
|
+
hideable: Schema4.optionalKey(Schema4.Boolean),
|
|
757
|
+
export: Schema4.optionalKey(Schema4.Boolean),
|
|
758
|
+
width: Schema4.optionalKey(Schema4.Number),
|
|
759
|
+
minWidth: Schema4.optionalKey(Schema4.Number),
|
|
760
|
+
maxWidth: Schema4.optionalKey(Schema4.Number),
|
|
761
|
+
resizable: Schema4.optionalKey(Schema4.Boolean),
|
|
762
|
+
truncate: Schema4.optionalKey(Schema4.Boolean),
|
|
763
|
+
searchable: Schema4.optionalKey(Schema4.Boolean),
|
|
764
|
+
filterable: Schema4.optionalKey(Schema4.Boolean),
|
|
765
|
+
emptyLabel: Schema4.optionalKey(Schema4.String),
|
|
766
|
+
nulls: Schema4.optionalKey(Schema4.Literals(["first", "last"]))
|
|
767
|
+
};
|
|
768
|
+
var DataTableFieldSchema = Schema4.Union([
|
|
769
|
+
Schema4.Struct({ ...column, type: Schema4.Literal("text") }),
|
|
770
|
+
Schema4.Struct({
|
|
771
|
+
...column,
|
|
772
|
+
type: Schema4.Literal("number"),
|
|
773
|
+
typeOptions: Schema4.optionalKey(Schema4.Struct({
|
|
774
|
+
locale: Schema4.optionalKey(Schema4.String),
|
|
775
|
+
style: Schema4.optionalKey(Schema4.Literals(["decimal", "percent", "currency", "unit"])),
|
|
776
|
+
currency: Schema4.optionalKey(Schema4.String),
|
|
777
|
+
unit: Schema4.optionalKey(Schema4.String),
|
|
778
|
+
notation: Schema4.optionalKey(Schema4.Literals(["standard", "scientific", "engineering", "compact"])),
|
|
779
|
+
minimumFractionDigits: Schema4.optionalKey(Schema4.Int.check(Schema4.isBetween({ minimum: 0, maximum: 20 }))),
|
|
780
|
+
maximumFractionDigits: Schema4.optionalKey(Schema4.Int.check(Schema4.isBetween({ minimum: 0, maximum: 20 }))),
|
|
781
|
+
exportFormat: Schema4.optionalKey(Schema4.Literals(["raw", "formatted"]))
|
|
782
|
+
}).annotate({ identifier: "DataTableNumberFormat" }))
|
|
783
|
+
}),
|
|
784
|
+
Schema4.Struct({ ...column, type: Schema4.Literal("reference") }),
|
|
785
|
+
Schema4.Struct({
|
|
786
|
+
...column,
|
|
787
|
+
type: Schema4.Literal("date"),
|
|
788
|
+
typeOptions: Schema4.optionalKey(DataTableDateFormatSchema)
|
|
789
|
+
}),
|
|
790
|
+
Schema4.Struct({
|
|
791
|
+
...column,
|
|
792
|
+
type: Schema4.Literal("dateTime"),
|
|
793
|
+
typeOptions: Schema4.optionalKey(DataTableDateTimeFormatSchema)
|
|
794
|
+
}),
|
|
795
|
+
Schema4.Struct({
|
|
796
|
+
...column,
|
|
797
|
+
type: Schema4.Literal("boolean"),
|
|
798
|
+
editable: Schema4.optionalKey(Schema4.Boolean),
|
|
799
|
+
typeOptions: Schema4.optionalKey(Schema4.Struct({
|
|
800
|
+
trueLabel: Schema4.optionalKey(Schema4.String),
|
|
801
|
+
falseLabel: Schema4.optionalKey(Schema4.String),
|
|
802
|
+
exportFormat: Schema4.optionalKey(Schema4.Literals(["raw", "formatted"]))
|
|
803
|
+
}).annotate({ identifier: "DataTableBooleanFormat" }))
|
|
804
|
+
}),
|
|
805
|
+
Schema4.Struct({
|
|
806
|
+
...column,
|
|
807
|
+
type: Schema4.Literal("list"),
|
|
808
|
+
filterOptions: Schema4.optionalKey(Schema4.Array(DataTableItemSchema)),
|
|
809
|
+
options: Schema4.optionalKey(Schema4.Array(DataTableItemSchema)),
|
|
810
|
+
allowRemove: Schema4.optionalKey(Schema4.Boolean),
|
|
811
|
+
itemActions: Schema4.optionalKey(Schema4.Array(DataTableActionSchema)),
|
|
812
|
+
display: Schema4.optionalKey(Schema4.Literals(["list", "icon"])),
|
|
813
|
+
visibleCount: Schema4.optionalKey(Schema4.Int.check(Schema4.isGreaterThanOrEqualTo(0))),
|
|
814
|
+
actionsLabel: Schema4.optionalKey(Schema4.String),
|
|
815
|
+
manageLabel: Schema4.optionalKey(Schema4.String)
|
|
816
|
+
})
|
|
817
|
+
]).annotate({ identifier: "DataTableField" });
|
|
818
|
+
var DataTableColumnSchema = DataTableFieldSchema.mapMembers(Tuple.map(Schema4.fieldsAssign({
|
|
819
|
+
fields: Schema4.optionalKey(Schema4.Array(DataTableFieldSchema))
|
|
820
|
+
}))).annotate({ identifier: "DataTableColumn" });
|
|
821
|
+
var DataTableLabelsSchema = Schema4.Struct({
|
|
822
|
+
actions: Schema4.optionalKey(Schema4.String),
|
|
823
|
+
addItem: Schema4.optionalKey(Schema4.String),
|
|
824
|
+
listDetails: Schema4.optionalKey(Schema4.String),
|
|
825
|
+
empty: Schema4.optionalKey(Schema4.String),
|
|
826
|
+
filters: Schema4.optionalKey(Schema4.String),
|
|
827
|
+
filtersClear: Schema4.optionalKey(Schema4.String),
|
|
828
|
+
filterColumn: Schema4.optionalKey(Schema4.String),
|
|
829
|
+
filterClear: Schema4.optionalKey(Schema4.String),
|
|
830
|
+
filterApply: Schema4.optionalKey(Schema4.String),
|
|
831
|
+
filterValue: Schema4.optionalKey(Schema4.String),
|
|
832
|
+
filterOperator: Schema4.optionalKey(Schema4.String),
|
|
833
|
+
filterContains: Schema4.optionalKey(Schema4.String),
|
|
834
|
+
filterEquals: Schema4.optionalKey(Schema4.String),
|
|
835
|
+
filterStartsWith: Schema4.optionalKey(Schema4.String),
|
|
836
|
+
filterEndsWith: Schema4.optionalKey(Schema4.String),
|
|
837
|
+
filterMin: Schema4.optionalKey(Schema4.String),
|
|
838
|
+
filterMax: Schema4.optionalKey(Schema4.String),
|
|
839
|
+
filterFrom: Schema4.optionalKey(Schema4.String),
|
|
840
|
+
filterTo: Schema4.optionalKey(Schema4.String),
|
|
841
|
+
filterTrue: Schema4.optionalKey(Schema4.String),
|
|
842
|
+
filterFalse: Schema4.optionalKey(Schema4.String),
|
|
843
|
+
filterInvalid: Schema4.optionalKey(Schema4.String),
|
|
844
|
+
columns: Schema4.optionalKey(Schema4.String),
|
|
845
|
+
sortBy: Schema4.optionalKey(Schema4.String),
|
|
846
|
+
hideColumn: Schema4.optionalKey(Schema4.String),
|
|
847
|
+
loading: Schema4.optionalKey(Schema4.String),
|
|
848
|
+
removeItem: Schema4.optionalKey(Schema4.String),
|
|
849
|
+
search: Schema4.optionalKey(Schema4.String),
|
|
850
|
+
selectAllRows: Schema4.optionalKey(Schema4.String),
|
|
851
|
+
selectRow: Schema4.optionalKey(Schema4.String),
|
|
852
|
+
selected: Schema4.optionalKey(Schema4.String),
|
|
853
|
+
sortAsc: Schema4.optionalKey(Schema4.String),
|
|
854
|
+
sortDesc: Schema4.optionalKey(Schema4.String),
|
|
855
|
+
sortClear: Schema4.optionalKey(Schema4.String),
|
|
856
|
+
view: Schema4.optionalKey(Schema4.String),
|
|
857
|
+
tableView: Schema4.optionalKey(Schema4.String),
|
|
858
|
+
galleryView: Schema4.optionalKey(Schema4.String),
|
|
859
|
+
groupBy: Schema4.optionalKey(Schema4.String),
|
|
860
|
+
export: Schema4.optionalKey(Schema4.String),
|
|
861
|
+
exportFailed: Schema4.optionalKey(Schema4.String),
|
|
862
|
+
moveUp: Schema4.optionalKey(Schema4.String),
|
|
863
|
+
moveDown: Schema4.optionalKey(Schema4.String),
|
|
864
|
+
reorder: Schema4.optionalKey(Schema4.String),
|
|
865
|
+
refresh: Schema4.optionalKey(Schema4.String),
|
|
866
|
+
resize: Schema4.optionalKey(Schema4.String)
|
|
867
|
+
}).annotate({ identifier: "DataTableLabels" });
|
|
868
|
+
var DataTableViewSchema = Schema4.Literals(["table", "gallery"]);
|
|
869
|
+
var DataTablePreferencesSchema = Schema4.Struct({
|
|
870
|
+
columnVisibility: Schema4.Record(Schema4.String, Schema4.Boolean),
|
|
871
|
+
columnSizing: Schema4.Record(Schema4.String, Schema4.Finite),
|
|
872
|
+
grouping: Schema4.optionalKey(Schema4.Array(Schema4.String)),
|
|
873
|
+
view: DataTableViewSchema
|
|
874
|
+
}).annotate({ identifier: "DataTablePersistedUiState" });
|
|
875
|
+
var GroupField = Schema4.Struct({
|
|
876
|
+
id: Schema4.NonEmptyString,
|
|
877
|
+
label: Schema4.String,
|
|
878
|
+
actionsLabel: Schema4.optionalKey(Schema4.String),
|
|
879
|
+
groups: Schema4.optionalKey(Schema4.Array(Schema4.Struct({
|
|
880
|
+
id: Schema4.String,
|
|
881
|
+
label: Schema4.String,
|
|
882
|
+
empty: Schema4.optionalKey(Schema4.String)
|
|
883
|
+
}).annotate({ identifier: "DataTableGroupLabel" }))),
|
|
884
|
+
actions: Schema4.optionalKey(Schema4.Array(DataTableActionSchema)),
|
|
885
|
+
movable: Schema4.optionalKey(Schema4.Boolean)
|
|
886
|
+
}).annotate({ identifier: "DataTableGroupField" });
|
|
887
|
+
var DataTablePropsSchema = Schema4.Struct({
|
|
888
|
+
...DataTableCommonPropsSchema.fields,
|
|
889
|
+
label: Schema4.String,
|
|
890
|
+
rowData: Schema4.Array(DataTableRowSchema),
|
|
891
|
+
rowActivation: Schema4.optionalKey(Schema4.Boolean),
|
|
892
|
+
columnDefs: Schema4.Array(DataTableColumnSchema),
|
|
893
|
+
status: Schema4.optionalKey(Schema4.Struct({
|
|
894
|
+
loading: Schema4.optionalKey(Schema4.Boolean),
|
|
895
|
+
empty: Schema4.optionalKey(Schema4.String),
|
|
896
|
+
error: Schema4.optionalKey(Schema4.String)
|
|
897
|
+
})),
|
|
898
|
+
sort: Schema4.optionalKey(Schema4.Array(DataTableSortSchema)),
|
|
899
|
+
sortMode: Schema4.optionalKey(Schema4.Literals(["client", "server"])),
|
|
900
|
+
search: Schema4.optionalKey(Schema4.Boolean),
|
|
901
|
+
columnFilters: Schema4.optionalKey(Schema4.Boolean),
|
|
902
|
+
state: Schema4.optionalKey(DataTableQuerySchema),
|
|
903
|
+
features: Schema4.optionalKey(Schema4.Struct({
|
|
904
|
+
...DataTableCommonFeaturesSchema.fields,
|
|
905
|
+
pagination: Schema4.optionalKey(Schema4.Union([Schema4.Literal(false), PaginationSchema])),
|
|
906
|
+
grouping: Schema4.optionalKey(Schema4.Struct({
|
|
907
|
+
initial: Schema4.optionalKey(Schema4.Array(Schema4.String)),
|
|
908
|
+
fields: Schema4.Array(GroupField)
|
|
909
|
+
}).annotate({ identifier: "DataTableGrouping" })),
|
|
910
|
+
gallery: Schema4.optionalKey(Schema4.Struct({
|
|
911
|
+
name: Schema4.String,
|
|
912
|
+
description: Schema4.optionalKey(Schema4.String),
|
|
913
|
+
image: Schema4.optionalKey(Schema4.String),
|
|
914
|
+
tags: Schema4.optionalKey(Schema4.Array(Schema4.String))
|
|
915
|
+
}).annotate({ identifier: "DataTableGallery" })),
|
|
916
|
+
reordering: Schema4.optionalKey(Schema4.Boolean),
|
|
917
|
+
export: Schema4.optionalKey(Schema4.Struct({
|
|
918
|
+
baseName: Schema4.String,
|
|
919
|
+
scope: Schema4.optionalKey(Schema4.Literals(["filteredRows", "currentPage"])),
|
|
920
|
+
builtIn: Schema4.optionalKey(Schema4.Boolean),
|
|
921
|
+
actions: Schema4.optionalKey(Schema4.Array(DataTableActionSchema)),
|
|
922
|
+
pending: Schema4.optionalKey(Schema4.Boolean),
|
|
923
|
+
failed: Schema4.optionalKey(Schema4.Boolean)
|
|
924
|
+
}).annotate({ identifier: "DataTableExport" })),
|
|
925
|
+
refresh: Schema4.optionalKey(Schema4.Boolean),
|
|
926
|
+
virtualization: Schema4.optionalKey(Schema4.Union([
|
|
927
|
+
Schema4.Boolean,
|
|
928
|
+
Schema4.Struct({
|
|
929
|
+
scroll: Schema4.optionalKey(Schema4.Literals(["table", "internal", "page"])),
|
|
930
|
+
height: Schema4.optionalKey(Schema4.Int.check(Schema4.isGreaterThan(0))),
|
|
931
|
+
estimateRowHeight: Schema4.optionalKey(Schema4.Int.check(Schema4.isGreaterThan(0))),
|
|
932
|
+
overscan: Schema4.optionalKey(Schema4.Int.check(Schema4.isGreaterThanOrEqualTo(0)))
|
|
933
|
+
}).annotate({ identifier: "DataTableVirtualization" })
|
|
934
|
+
]))
|
|
935
|
+
}).annotate({ identifier: "DataTableHtmlFeatures" })),
|
|
936
|
+
initialState: Schema4.optionalKey(Schema4.Struct({
|
|
937
|
+
...queryFields,
|
|
938
|
+
page: Schema4.optional(queryFields.page),
|
|
939
|
+
pageSize: Schema4.optional(queryFields.pageSize),
|
|
940
|
+
columnVisibility: Schema4.optionalKey(Schema4.Record(Schema4.String, Schema4.Boolean)),
|
|
941
|
+
view: Schema4.optionalKey(DataTableViewSchema)
|
|
942
|
+
}).annotate({ identifier: "DataTableInitialQuery" })),
|
|
943
|
+
pagination: Schema4.optionalKey(PaginationSchema),
|
|
944
|
+
selection: Schema4.optionalKey(Schema4.Struct({
|
|
945
|
+
selectedRowIds: Schema4.optionalKey(Schema4.Array(Schema4.String)),
|
|
946
|
+
bulkActionsLabel: Schema4.optionalKey(Schema4.String),
|
|
947
|
+
bulkActions: Schema4.optionalKey(Schema4.Array(DataTableActionSchema))
|
|
948
|
+
})),
|
|
949
|
+
messages: Schema4.optionalKey(Schema4.Record(Schema4.String, DataTableLabelsSchema))
|
|
950
|
+
}).annotate({ identifier: "DataTableProps" });
|
|
951
|
+
var DataTableFilterDraftSchema = Schema4.Struct({
|
|
952
|
+
id: Schema4.String,
|
|
953
|
+
primary: Schema4.String,
|
|
954
|
+
secondary: Schema4.String,
|
|
955
|
+
operator: TextFilterOperator,
|
|
956
|
+
values: Schema4.Array(Schema4.String)
|
|
957
|
+
}).annotate({ identifier: "DataTableFilterDraft" });
|
|
958
|
+
|
|
959
|
+
// ../../src/components/data-table/index.ts
|
|
960
|
+
var defaultMessages = {
|
|
961
|
+
en: {
|
|
962
|
+
actions: "Actions",
|
|
963
|
+
addItem: "Add item...",
|
|
964
|
+
listDetails: "View all items",
|
|
965
|
+
empty: "No results.",
|
|
966
|
+
filters: "Filters",
|
|
967
|
+
filtersClear: "Clear all filters",
|
|
968
|
+
filterColumn: "Column",
|
|
969
|
+
filterClear: "Clear filter",
|
|
970
|
+
filterApply: "Apply filter",
|
|
971
|
+
filterValue: "Value",
|
|
972
|
+
filterOperator: "Operator",
|
|
973
|
+
filterContains: "Contains",
|
|
974
|
+
filterEquals: "Equals",
|
|
975
|
+
filterStartsWith: "Starts with",
|
|
976
|
+
filterEndsWith: "Ends with",
|
|
977
|
+
filterMin: "Minimum",
|
|
978
|
+
filterMax: "Maximum",
|
|
979
|
+
filterFrom: "From (UTC)",
|
|
980
|
+
filterTo: "To (UTC)",
|
|
981
|
+
filterTrue: "True",
|
|
982
|
+
filterFalse: "False",
|
|
983
|
+
filterInvalid: "Enter a valid filter. Ranges must be in ascending order.",
|
|
984
|
+
columns: "Columns",
|
|
985
|
+
sortBy: "Sort by",
|
|
986
|
+
hideColumn: "Hide column",
|
|
987
|
+
loading: "Loading...",
|
|
988
|
+
removeItem: "Remove",
|
|
989
|
+
search: "Search",
|
|
990
|
+
selectAllRows: "Select all rows on this page",
|
|
991
|
+
selectRow: "Select row",
|
|
992
|
+
selected: "Selected",
|
|
993
|
+
sortAsc: "Ascending",
|
|
994
|
+
sortDesc: "Descending",
|
|
995
|
+
sortClear: "Clear sorting",
|
|
996
|
+
view: "View",
|
|
997
|
+
tableView: "Table",
|
|
998
|
+
galleryView: "Gallery",
|
|
999
|
+
groupBy: "Group by",
|
|
1000
|
+
export: "Export",
|
|
1001
|
+
exportFailed: "Export failed. Please try again.",
|
|
1002
|
+
refresh: "Refresh",
|
|
1003
|
+
moveUp: "Move up",
|
|
1004
|
+
moveDown: "Move down",
|
|
1005
|
+
reorder: "Drag to reorder",
|
|
1006
|
+
resize: "Resize column"
|
|
1007
|
+
},
|
|
1008
|
+
fr: {
|
|
1009
|
+
actions: "Actions",
|
|
1010
|
+
addItem: "Ajouter un élément...",
|
|
1011
|
+
listDetails: "Afficher tous les éléments",
|
|
1012
|
+
empty: "Aucun résultat.",
|
|
1013
|
+
filters: "Filtres",
|
|
1014
|
+
filtersClear: "Effacer tous les filtres",
|
|
1015
|
+
filterColumn: "Colonne",
|
|
1016
|
+
filterClear: "Effacer le filtre",
|
|
1017
|
+
filterApply: "Appliquer le filtre",
|
|
1018
|
+
filterValue: "Valeur",
|
|
1019
|
+
filterOperator: "Opérateur",
|
|
1020
|
+
filterContains: "Contient",
|
|
1021
|
+
filterEquals: "Égal à",
|
|
1022
|
+
filterStartsWith: "Commence par",
|
|
1023
|
+
filterEndsWith: "Se termine par",
|
|
1024
|
+
filterMin: "Minimum",
|
|
1025
|
+
filterMax: "Maximum",
|
|
1026
|
+
filterFrom: "Du (UTC)",
|
|
1027
|
+
filterTo: "Au (UTC)",
|
|
1028
|
+
filterTrue: "Vrai",
|
|
1029
|
+
filterFalse: "Faux",
|
|
1030
|
+
filterInvalid: "Saisissez un filtre valide. Les bornes doivent être dans l’ordre croissant.",
|
|
1031
|
+
columns: "Colonnes",
|
|
1032
|
+
sortBy: "Trier par",
|
|
1033
|
+
hideColumn: "Masquer la colonne",
|
|
1034
|
+
loading: "Chargement...",
|
|
1035
|
+
removeItem: "Retirer",
|
|
1036
|
+
search: "Rechercher",
|
|
1037
|
+
selectAllRows: "Sélectionner toutes les lignes de cette page",
|
|
1038
|
+
selectRow: "Sélectionner la ligne",
|
|
1039
|
+
selected: "Sélectionnés",
|
|
1040
|
+
sortAsc: "Croissant",
|
|
1041
|
+
sortDesc: "Décroissant",
|
|
1042
|
+
sortClear: "Effacer le tri",
|
|
1043
|
+
view: "Affichage",
|
|
1044
|
+
tableView: "Tableau",
|
|
1045
|
+
galleryView: "Galerie",
|
|
1046
|
+
groupBy: "Grouper par",
|
|
1047
|
+
export: "Exporter",
|
|
1048
|
+
exportFailed: "L’exportation a échoué. Veuillez réessayer.",
|
|
1049
|
+
refresh: "Rafraîchir",
|
|
1050
|
+
moveUp: "Déplacer vers le haut",
|
|
1051
|
+
moveDown: "Déplacer vers le bas",
|
|
1052
|
+
reorder: "Glisser pour réorganiser",
|
|
1053
|
+
resize: "Redimensionner la colonne"
|
|
1054
|
+
}
|
|
1055
|
+
};
|
|
1056
|
+
var htmlDataTableMessages = (locale, messages) => {
|
|
1057
|
+
const base = locale.split("-")[0] ?? "en";
|
|
1058
|
+
return {
|
|
1059
|
+
...defaultMessages[base === "fr" ? "fr" : "en"],
|
|
1060
|
+
...messages?.[base],
|
|
1061
|
+
...messages?.[locale]
|
|
1062
|
+
};
|
|
1063
|
+
};
|
|
1064
|
+
var compareTableText = (left, right, locale) => left.localeCompare(right, locale, { numeric: true, sensitivity: "base" });
|
|
1065
|
+
var isTableText = Schema5.is(Schema5.String);
|
|
1066
|
+
var isTableNumber = Schema5.is(Schema5.Finite);
|
|
1067
|
+
var isTableBoolean = Schema5.is(Schema5.Boolean);
|
|
1068
|
+
var isTableReference = Schema5.is(DataTableReferenceSchema);
|
|
1069
|
+
var isTableList = Schema5.is(Schema5.Array(DataTableItemSchema));
|
|
1070
|
+
var tableInitials = (label) => label.trim().split(/\s+/).slice(0, 2).map((word) => word.slice(0, 1)).join("").toLocaleUpperCase();
|
|
1071
|
+
var formatNumberValue = (value, options, defaultLocale = "en") => {
|
|
1072
|
+
const { locale, ...format } = options ?? {};
|
|
1073
|
+
return new Intl.NumberFormat(locale ?? defaultLocale, format).format(value);
|
|
1074
|
+
};
|
|
1075
|
+
var tableBooleanLabel = (value, options) => (value ? options?.trueLabel : options?.falseLabel) ?? String(value);
|
|
1076
|
+
var decodeDateInput = Schema5.decodeUnknownOption(DataTableDateInputSchema);
|
|
1077
|
+
var resolveDate = (value, type) => Option3.getOrUndefined(Option3.flatMap(decodeDateInput(value), (input) => {
|
|
1078
|
+
const calendarOnly = isCalendarDate(input);
|
|
1079
|
+
if (calendarOnly && type === "dateTime")
|
|
1080
|
+
return Option3.none();
|
|
1081
|
+
return Option3.map(DateTime3.make(input), (instant) => ({
|
|
1082
|
+
instant,
|
|
1083
|
+
calendarOnly
|
|
1084
|
+
}));
|
|
1085
|
+
}));
|
|
1086
|
+
var formatDateValue = (date, column, locale = "en") => DateTime3.format(date.instant, {
|
|
1087
|
+
locale: column.typeOptions?.locale ?? locale,
|
|
1088
|
+
timeZone: date.calendarOnly ? "UTC" : column.typeOptions?.timeZone ?? "UTC",
|
|
1089
|
+
dateStyle: column.typeOptions?.dateStyle ?? "medium",
|
|
1090
|
+
timeStyle: column.type === "dateTime" ? column.typeOptions?.timeStyle ?? "short" : undefined,
|
|
1091
|
+
hour12: column.type === "dateTime" ? column.typeOptions?.hour12 : undefined
|
|
1092
|
+
});
|
|
1093
|
+
var dateIsoValue = (date) => date.calendarOnly ? DateTime3.formatIsoDateUtc(date.instant) : DateTime3.formatIso(date.instant);
|
|
1094
|
+
var matchesDateFilter = (date, filter) => {
|
|
1095
|
+
if (!date)
|
|
1096
|
+
return false;
|
|
1097
|
+
const day = DateTime3.formatIsoDateUtc(date.instant);
|
|
1098
|
+
return (filter.from === undefined || day >= filter.from) && (filter.to === undefined || day <= filter.to);
|
|
1099
|
+
};
|
|
1100
|
+
var matchesFilterText = (value, filter) => {
|
|
1101
|
+
const text = value.toLocaleLowerCase();
|
|
1102
|
+
const query = filter.value.toLocaleLowerCase();
|
|
1103
|
+
switch (filter.operator) {
|
|
1104
|
+
case "contains":
|
|
1105
|
+
return text.includes(query);
|
|
1106
|
+
case "equals":
|
|
1107
|
+
return text === query;
|
|
1108
|
+
case "startsWith":
|
|
1109
|
+
return text.startsWith(query);
|
|
1110
|
+
case "endsWith":
|
|
1111
|
+
return text.endsWith(query);
|
|
1112
|
+
}
|
|
1113
|
+
};
|
|
1114
|
+
var tableFilterKind = (column, hasOptions = false) => hasOptions || column.type === "list" ? "values" : column.type === "reference" ? "text" : column.type === "dateTime" ? "date" : column.type ?? "text";
|
|
1115
|
+
var matchesTableFilter = (filter, value, type, text, values) => {
|
|
1116
|
+
switch (filter.kind) {
|
|
1117
|
+
case "text":
|
|
1118
|
+
return matchesFilterText(text(), filter);
|
|
1119
|
+
case "number":
|
|
1120
|
+
return isTableNumber(value) && (filter.min === undefined || value >= filter.min) && (filter.max === undefined || value <= filter.max);
|
|
1121
|
+
case "boolean":
|
|
1122
|
+
return value === filter.value;
|
|
1123
|
+
case "values":
|
|
1124
|
+
return values().some((value) => filter.values.includes(value));
|
|
1125
|
+
case "date":
|
|
1126
|
+
return matchesDateFilter(resolveDate(value, type === "dateTime" ? "dateTime" : "date"), filter);
|
|
1127
|
+
}
|
|
1128
|
+
};
|
|
1129
|
+
var tableDataColumns = (columns) => columns.flatMap((column) => column.fields?.length ? column.fields.map((field) => ({
|
|
1130
|
+
...field,
|
|
1131
|
+
id: `${column.id}.${field.id}`,
|
|
1132
|
+
headerName: `${column.headerName} / ${field.headerName}`,
|
|
1133
|
+
sortable: column.sortable === false ? false : field.sortable,
|
|
1134
|
+
searchable: column.searchable === false ? false : field.searchable,
|
|
1135
|
+
filterable: column.filterable === false ? false : field.filterable,
|
|
1136
|
+
export: column.export === false ? false : field.export
|
|
1137
|
+
})) : [column]);
|
|
1138
|
+
var tableFilterOptions = (rows, columnId, locale) => {
|
|
1139
|
+
const options = new Map;
|
|
1140
|
+
for (const row of rows) {
|
|
1141
|
+
const items = row.cells[columnId];
|
|
1142
|
+
if (isTableList(items)) {
|
|
1143
|
+
for (const item of items)
|
|
1144
|
+
options.set(item.value, item);
|
|
1145
|
+
}
|
|
1146
|
+
}
|
|
1147
|
+
return [...options.values()].sort((a, b) => compareTableText(a.label, b.label, locale));
|
|
1148
|
+
};
|
|
1149
|
+
var filterTableColumns = (rows, columns, filters) => {
|
|
1150
|
+
const byId = new Map(columns.filter(({ filterable }) => filterable !== false).map((column) => [column.id, column]));
|
|
1151
|
+
const active = filters.filter((filter) => {
|
|
1152
|
+
const column = byId.get(filter.id);
|
|
1153
|
+
return column && tableFilterKind(column) === filter.kind;
|
|
1154
|
+
});
|
|
1155
|
+
if (!active.length)
|
|
1156
|
+
return rows;
|
|
1157
|
+
return rows.filter((row) => active.every((filter) => {
|
|
1158
|
+
const value = row.cells[filter.id];
|
|
1159
|
+
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) : []);
|
|
1160
|
+
}));
|
|
1161
|
+
};
|
|
1162
|
+
var columnValue = (column, value) => {
|
|
1163
|
+
switch (column.type) {
|
|
1164
|
+
case "text":
|
|
1165
|
+
return isTableText(value) ? value : null;
|
|
1166
|
+
case "number":
|
|
1167
|
+
case "boolean":
|
|
1168
|
+
case "date":
|
|
1169
|
+
case "dateTime":
|
|
1170
|
+
return tableSortScalar(column.type, value);
|
|
1171
|
+
case "reference":
|
|
1172
|
+
return isTableReference(value) ? value.label : null;
|
|
1173
|
+
case "list":
|
|
1174
|
+
return isTableList(value) ? value.map(({ label }) => label).join(", ") : null;
|
|
1175
|
+
}
|
|
1176
|
+
};
|
|
1177
|
+
var tableSortScalar = (type, value) => {
|
|
1178
|
+
if (type === "number")
|
|
1179
|
+
return isTableNumber(value) ? value : null;
|
|
1180
|
+
if (type === "boolean")
|
|
1181
|
+
return isTableBoolean(value) ? Number(value) : null;
|
|
1182
|
+
const date = resolveDate(value, type);
|
|
1183
|
+
return date ? DateTime3.toEpochMillis(date.instant) : null;
|
|
1184
|
+
};
|
|
1185
|
+
var compareTableSortValues = (left, right, direction, nulls, locale) => {
|
|
1186
|
+
if (left === right)
|
|
1187
|
+
return 0;
|
|
1188
|
+
const nullOrder = nulls === "first" ? -1 : 1;
|
|
1189
|
+
if (left === null)
|
|
1190
|
+
return nullOrder;
|
|
1191
|
+
if (right === null)
|
|
1192
|
+
return -nullOrder;
|
|
1193
|
+
const comparison = isTableNumber(left) && isTableNumber(right) ? left - right : compareTableText(String(left), String(right), locale);
|
|
1194
|
+
return direction === "asc" ? comparison : -comparison;
|
|
1195
|
+
};
|
|
1196
|
+
var sortTableRows = (rows, columns, sort, locale) => {
|
|
1197
|
+
const byId = new Map(columns.map((column) => [column.id, column]));
|
|
1198
|
+
return rows.slice().sort((leftRow, rightRow) => {
|
|
1199
|
+
for (const { id, direction } of sort) {
|
|
1200
|
+
const column = byId.get(id);
|
|
1201
|
+
if (!column || column.sortable === false)
|
|
1202
|
+
continue;
|
|
1203
|
+
const left = columnValue(column, leftRow.cells[id]);
|
|
1204
|
+
const right = columnValue(column, rightRow.cells[id]);
|
|
1205
|
+
const comparison = compareTableSortValues(left, right, direction, column.nulls, locale);
|
|
1206
|
+
if (comparison !== 0)
|
|
1207
|
+
return comparison;
|
|
1208
|
+
}
|
|
1209
|
+
return 0;
|
|
1210
|
+
});
|
|
1211
|
+
};
|
|
1212
|
+
var filterTableRows = (rows, columns, search, locale) => {
|
|
1213
|
+
const query = search.trim().toLocaleLowerCase(locale);
|
|
1214
|
+
if (!query)
|
|
1215
|
+
return rows;
|
|
1216
|
+
const searchable = columns.filter(({ searchable }) => searchable !== false);
|
|
1217
|
+
return rows.filter((row) => searchable.some((column) => {
|
|
1218
|
+
const value = row.cells[column.id];
|
|
1219
|
+
if (column.type === "date" || column.type === "dateTime") {
|
|
1220
|
+
const date = resolveDate(value, column.type);
|
|
1221
|
+
return !!date && `${formatDateValue(date, column, locale)} ${dateIsoValue(date)}`.toLocaleLowerCase(locale).includes(query);
|
|
1222
|
+
}
|
|
1223
|
+
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) ?? "");
|
|
1224
|
+
return text.toLocaleLowerCase(locale).includes(query);
|
|
1225
|
+
}));
|
|
1226
|
+
};
|
|
1227
|
+
var updateSelectedRows = (selected, targets, checked) => {
|
|
1228
|
+
const next = new Set(selected);
|
|
1229
|
+
for (const id of targets) {
|
|
1230
|
+
if (checked)
|
|
1231
|
+
next.add(id);
|
|
1232
|
+
else
|
|
1233
|
+
next.delete(id);
|
|
1234
|
+
}
|
|
1235
|
+
return Array.from(next);
|
|
1236
|
+
};
|
|
1237
|
+
var resolveTablePage = (rowCount, query) => {
|
|
1238
|
+
const pageSize = Math.max(1, query.pageSize);
|
|
1239
|
+
const pageCount = Math.max(1, Math.ceil(rowCount / pageSize));
|
|
1240
|
+
const page = Math.min(pageCount - 1, Math.max(0, query.page));
|
|
1241
|
+
const start = page * pageSize;
|
|
1242
|
+
return { page, pageCount, start, end: start + pageSize };
|
|
1243
|
+
};
|
|
1244
|
+
var edit = UiSchema2.TaggedEnum({
|
|
1245
|
+
SetBoolean: { value: Schema5.Boolean },
|
|
1246
|
+
AddItem: { itemId: Schema5.String },
|
|
1247
|
+
RemoveItem: { itemId: Schema5.String }
|
|
1248
|
+
}).annotate({ identifier: "DataTableEdit" });
|
|
1249
|
+
var DataTableEdit = edit;
|
|
1250
|
+
var eventFields = {
|
|
1251
|
+
RowActivated: { rowId: Schema5.String },
|
|
1252
|
+
ItemActionRequested: {
|
|
1253
|
+
rowId: Schema5.String,
|
|
1254
|
+
columnId: Schema5.String,
|
|
1255
|
+
itemId: Schema5.String,
|
|
1256
|
+
actionId: Schema5.String
|
|
1257
|
+
},
|
|
1258
|
+
RefreshRequested: {},
|
|
1259
|
+
ExportRequested: { actionId: Schema5.String },
|
|
1260
|
+
GroupActionRequested: {
|
|
1261
|
+
fieldId: Schema5.String,
|
|
1262
|
+
groupId: Schema5.String,
|
|
1263
|
+
actionId: Schema5.String
|
|
1264
|
+
},
|
|
1265
|
+
GroupMoveRequested: {
|
|
1266
|
+
rowId: Schema5.String,
|
|
1267
|
+
fieldId: Schema5.String,
|
|
1268
|
+
groupId: Schema5.String
|
|
1269
|
+
},
|
|
1270
|
+
RowsReordered: { rowIds: Schema5.Array(Schema5.String) },
|
|
1271
|
+
StateChanged: { state: DataTableQuerySchema },
|
|
1272
|
+
SortChanged: { sort: Schema5.Array(DataTableSortSchema) },
|
|
1273
|
+
SelectionChanged: { selectedRowIds: Schema5.Array(Schema5.String) },
|
|
1274
|
+
CellEditRequested: { rowId: Schema5.String, columnId: Schema5.String, edit },
|
|
1275
|
+
RowActionRequested: { rowId: Schema5.String, actionId: Schema5.String },
|
|
1276
|
+
BulkActionRequested: {
|
|
1277
|
+
rowIds: Schema5.Array(Schema5.String),
|
|
1278
|
+
actionId: Schema5.String
|
|
1279
|
+
}
|
|
1280
|
+
};
|
|
1281
|
+
var DataTableEvents = UiSchema2.TaggedEnum(eventFields).annotate({
|
|
1282
|
+
identifier: "DataTableEvents"
|
|
1283
|
+
});
|
|
1284
|
+
var DataTableMessage = UiSchema2.TaggedEnum({
|
|
1285
|
+
ReferenceImageFailed: { src: Schema5.String },
|
|
1286
|
+
RowActivated: eventFields.RowActivated,
|
|
1287
|
+
PreferencesLoaded: { preferences: Schema5.NullOr(DataTablePreferencesSchema) },
|
|
1288
|
+
ItemActionRequested: eventFields.ItemActionRequested,
|
|
1289
|
+
BuiltInExportRequested: {
|
|
1290
|
+
format: Schema5.Literals(["csv", "json"]),
|
|
1291
|
+
locale: Schema5.optionalKey(Schema5.String)
|
|
1292
|
+
},
|
|
1293
|
+
ExportStarted: {},
|
|
1294
|
+
ExportFinished: { failed: Schema5.Boolean },
|
|
1295
|
+
RefreshRequested: {},
|
|
1296
|
+
ExportRequested: eventFields.ExportRequested,
|
|
1297
|
+
GroupActionRequested: eventFields.GroupActionRequested,
|
|
1298
|
+
GroupMoveRequested: eventFields.GroupMoveRequested,
|
|
1299
|
+
ReorderRequested: {
|
|
1300
|
+
rowId: Schema5.String,
|
|
1301
|
+
targetId: Schema5.String,
|
|
1302
|
+
after: Schema5.Boolean
|
|
1303
|
+
},
|
|
1304
|
+
DragStarted: { rowId: Schema5.String },
|
|
1305
|
+
DragEnded: {},
|
|
1306
|
+
DragDropped: { targetId: Schema5.String },
|
|
1307
|
+
GroupDropped: { fieldId: Schema5.String, groupId: Schema5.String },
|
|
1308
|
+
ViewPicked: { view: DataTableViewSchema },
|
|
1309
|
+
GroupingToggled: { fieldId: Schema5.String },
|
|
1310
|
+
GroupToggled: { key: Schema5.String },
|
|
1311
|
+
ColumnResized: { id: Schema5.String, delta: Schema5.Finite },
|
|
1312
|
+
ColumnResizeReset: { id: Schema5.String },
|
|
1313
|
+
ResizeStarted: { id: Schema5.String, x: Schema5.Finite, pointerId: Schema5.Int },
|
|
1314
|
+
ResizeMoved: { x: Schema5.Finite, pointerId: Schema5.Int },
|
|
1315
|
+
ResizeEnded: { pointerId: Schema5.Int },
|
|
1316
|
+
ColumnFiltersCleared: { id: Schema5.String },
|
|
1317
|
+
ColumnSortCleared: { id: Schema5.String },
|
|
1318
|
+
CellEditRequested: eventFields.CellEditRequested,
|
|
1319
|
+
RowActionRequested: eventFields.RowActionRequested,
|
|
1320
|
+
MenuOpened: { key: Schema5.String },
|
|
1321
|
+
MenuClosed: { key: Schema5.String },
|
|
1322
|
+
MenuQueryChanged: { key: Schema5.String, query: Schema5.String },
|
|
1323
|
+
SubmenuOpened: {
|
|
1324
|
+
key: Schema5.String,
|
|
1325
|
+
filterColumnId: Schema5.optionalKey(Schema5.String)
|
|
1326
|
+
},
|
|
1327
|
+
SubmenuClosed: { key: Schema5.String },
|
|
1328
|
+
SearchChanged: { value: Schema5.String },
|
|
1329
|
+
FilterInputChanged: {
|
|
1330
|
+
field: Schema5.Literals(["primary", "secondary"]),
|
|
1331
|
+
value: Schema5.String
|
|
1332
|
+
},
|
|
1333
|
+
FilterOperatorChanged: { operator: TextFilterOperator },
|
|
1334
|
+
FilterValueToggled: { value: Schema5.String, checked: Schema5.Boolean },
|
|
1335
|
+
FilterApplied: {},
|
|
1336
|
+
ColumnFilterChanged: {
|
|
1337
|
+
id: Schema5.String,
|
|
1338
|
+
filter: Schema5.NullOr(ColumnFilter)
|
|
1339
|
+
},
|
|
1340
|
+
FilterCleared: {},
|
|
1341
|
+
FiltersCleared: {},
|
|
1342
|
+
PageRequested: { page: Schema5.Int },
|
|
1343
|
+
ServerPageInvalidated: {},
|
|
1344
|
+
PageSizeRequested: { pageSize: Schema5.Int },
|
|
1345
|
+
SortRequested: {
|
|
1346
|
+
columnId: Schema5.String,
|
|
1347
|
+
direction: Schema5.NullOr(DataTableSortSchema.fields.direction)
|
|
1348
|
+
},
|
|
1349
|
+
ColumnVisibilityChanged: { id: Schema5.String, visible: Schema5.Boolean },
|
|
1350
|
+
SelectionRequested: {
|
|
1351
|
+
rowIds: Schema5.Array(Schema5.String),
|
|
1352
|
+
checked: Schema5.Boolean
|
|
1353
|
+
},
|
|
1354
|
+
BulkActionRequested: { actionId: Schema5.String }
|
|
1355
|
+
}).annotate({ identifier: "DataTableMessage" });
|
|
1356
|
+
var dataTableOptions = {
|
|
1357
|
+
name: "DataTable",
|
|
1358
|
+
props: DataTablePropsSchema,
|
|
1359
|
+
model: Schema5.Struct({
|
|
1360
|
+
menu: Schema5.NullOr(Schema5.String),
|
|
1361
|
+
submenu: Schema5.NullOr(Schema5.String),
|
|
1362
|
+
menuQuery: Schema5.String,
|
|
1363
|
+
failedImages: Schema5.Array(Schema5.String),
|
|
1364
|
+
selectedRowIds: Schema5.Array(Schema5.String),
|
|
1365
|
+
query: DataTableQuerySchema,
|
|
1366
|
+
preferencesLoaded: Schema5.Boolean,
|
|
1367
|
+
columnVisibility: Schema5.Record(Schema5.String, Schema5.Boolean),
|
|
1368
|
+
columnSizing: Schema5.Record(Schema5.String, Schema5.Finite),
|
|
1369
|
+
view: DataTableViewSchema,
|
|
1370
|
+
grouping: Schema5.Array(Schema5.String),
|
|
1371
|
+
collapsedGroups: Schema5.Record(Schema5.String, Schema5.Boolean),
|
|
1372
|
+
dragging: Schema5.NullOr(Schema5.String),
|
|
1373
|
+
exporting: Schema5.Boolean,
|
|
1374
|
+
exportFailed: Schema5.Boolean,
|
|
1375
|
+
resizing: Schema5.NullOr(Schema5.Struct({
|
|
1376
|
+
id: Schema5.String,
|
|
1377
|
+
x: Schema5.Finite,
|
|
1378
|
+
width: Schema5.Finite,
|
|
1379
|
+
pointerId: Schema5.Int
|
|
1380
|
+
}).annotate({ identifier: "DataTableResizeSession" })),
|
|
1381
|
+
filterDraft: Schema5.NullOr(DataTableFilterDraftSchema),
|
|
1382
|
+
invalidFilter: Schema5.Boolean
|
|
1383
|
+
}).annotate({ identifier: "DataTableModel" }),
|
|
1384
|
+
message: DataTableMessage,
|
|
1385
|
+
events: DataTableEvents,
|
|
1386
|
+
restore: false
|
|
1387
|
+
};
|
|
1388
|
+
var available = (props) => props.status?.error === undefined && (!props.status?.loading || props.rowData.length > 0);
|
|
1389
|
+
var tableQuery = (props, model) => props.state ?? { ...model.query, sort: props.sort ?? model.query.sort };
|
|
1390
|
+
var tableFeatures = (props) => ({
|
|
1391
|
+
...props.features,
|
|
1392
|
+
search: props.features?.search ?? props.search ?? true,
|
|
1393
|
+
filtering: props.features?.filtering ?? props.columnFilters ?? true,
|
|
1394
|
+
sorting: props.features?.sorting ?? true,
|
|
1395
|
+
columnVisibility: props.features?.columnVisibility ?? true,
|
|
1396
|
+
pagination: props.features?.pagination ?? props.pagination
|
|
1397
|
+
});
|
|
1398
|
+
var tableSelectedRowIds = (props, model) => {
|
|
1399
|
+
const supplied = new Set(props.rowData.map(({ id }) => id));
|
|
1400
|
+
return [
|
|
1401
|
+
...new Set(props.selection?.selectedRowIds ?? model.selectedRowIds)
|
|
1402
|
+
].filter((id) => supplied.has(id));
|
|
1403
|
+
};
|
|
1404
|
+
var serverPageCorrection = (props, model) => {
|
|
1405
|
+
const pagination = tableFeatures(props).pagination;
|
|
1406
|
+
if (!pagination || pagination.mode !== "server")
|
|
1407
|
+
return;
|
|
1408
|
+
const query = tableQuery(props, model);
|
|
1409
|
+
const { page } = resolveTablePage(pagination.rowCount, query);
|
|
1410
|
+
if (query.page !== page)
|
|
1411
|
+
return { requested: query.page, page, size: query.pageSize };
|
|
1412
|
+
};
|
|
1413
|
+
var tablePreferencesKey = (pathname, columns, gallery) => `data-table:${pathname}:${columns.join(",")}:${gallery ? "gallery" : "table"}:ui`;
|
|
1414
|
+
var preferencesJson = Schema5.fromJsonString(DataTablePreferencesSchema);
|
|
1415
|
+
var decodePreferences = Schema5.decodeUnknownOption(preferencesJson);
|
|
1416
|
+
var encodePreferences = Schema5.encodeSync(preferencesJson);
|
|
1417
|
+
var readTablePreferences = (key, host = globalThis.window) => {
|
|
1418
|
+
try {
|
|
1419
|
+
return Option3.getOrNull(decodePreferences(host?.localStorage.getItem(key)));
|
|
1420
|
+
} catch {
|
|
1421
|
+
return null;
|
|
1422
|
+
}
|
|
1423
|
+
};
|
|
1424
|
+
var writeTablePreferences = (key, preferences, host = globalThis.window) => {
|
|
1425
|
+
try {
|
|
1426
|
+
host?.localStorage.setItem(key, encodePreferences(preferences));
|
|
1427
|
+
} catch {}
|
|
1428
|
+
};
|
|
1429
|
+
var tablePreferences = (model) => model.preferencesLoaded ? {
|
|
1430
|
+
columnVisibility: model.columnVisibility,
|
|
1431
|
+
columnSizing: model.columnSizing,
|
|
1432
|
+
grouping: model.grouping,
|
|
1433
|
+
view: model.view
|
|
1434
|
+
} : null;
|
|
1435
|
+
var tableVirtualization = (count, options, flat) => {
|
|
1436
|
+
if (!flat || (options === undefined ? count < 100 : !options))
|
|
1437
|
+
return;
|
|
1438
|
+
const config = typeof options === "object" ? options : undefined;
|
|
1439
|
+
const height = config?.height ?? 480;
|
|
1440
|
+
const itemSize = config?.estimateRowHeight ?? 64;
|
|
1441
|
+
const overscan = config?.overscan ?? 5;
|
|
1442
|
+
return {
|
|
1443
|
+
height,
|
|
1444
|
+
itemSize,
|
|
1445
|
+
overscan,
|
|
1446
|
+
initialCount: Math.min(count, Math.ceil(height / itemSize) + overscan),
|
|
1447
|
+
scroll: config?.scroll ?? "table"
|
|
1448
|
+
};
|
|
1449
|
+
};
|
|
1450
|
+
var tableRowActions = (row, siblings, reorder, labels) => {
|
|
1451
|
+
const index = siblings.findIndex(({ id }) => id === row.id);
|
|
1452
|
+
const actions = (row.actions ?? []).map((action) => ({
|
|
1453
|
+
...action,
|
|
1454
|
+
message: DataTableMessage.RowActionRequested({
|
|
1455
|
+
rowId: row.id,
|
|
1456
|
+
actionId: action.id
|
|
1457
|
+
})
|
|
1458
|
+
}));
|
|
1459
|
+
const moves = reorder && index >= 0 ? [
|
|
1460
|
+
{ target: siblings[index - 1], after: false, name: labels.moveUp },
|
|
1461
|
+
{ target: siblings[index + 1], after: true, name: labels.moveDown }
|
|
1462
|
+
].flatMap(({ target, after, name }) => target ? [
|
|
1463
|
+
{
|
|
1464
|
+
id: JSON.stringify(["move", after]),
|
|
1465
|
+
name,
|
|
1466
|
+
message: DataTableMessage.ReorderRequested({
|
|
1467
|
+
rowId: row.id,
|
|
1468
|
+
targetId: target.id,
|
|
1469
|
+
after
|
|
1470
|
+
})
|
|
1471
|
+
}
|
|
1472
|
+
] : []) : [];
|
|
1473
|
+
return [...moves, ...actions];
|
|
1474
|
+
};
|
|
1475
|
+
var tableColumnLimits = (column) => {
|
|
1476
|
+
const min = column.minWidth ?? 96;
|
|
1477
|
+
return { min, max: Math.max(min, column.maxWidth ?? 640) };
|
|
1478
|
+
};
|
|
1479
|
+
var clampTableWidth = (column, width = column.width ?? 208) => {
|
|
1480
|
+
const { min, max } = tableColumnLimits(column);
|
|
1481
|
+
return Math.min(max, Math.max(min, width));
|
|
1482
|
+
};
|
|
1483
|
+
var tableColumnWidth = (column, sizing) => clampTableWidth(column, sizing[column.id]);
|
|
1484
|
+
var tableLayoutWidth = (widths, utilityColumns) => widths.reduce((total, width) => total + width, utilityColumns * 40);
|
|
1485
|
+
var tableResizeStep = (key) => key === "ArrowLeft" ? -8 : key === "ArrowRight" ? 8 : 0;
|
|
1486
|
+
var activeTableGroups = (grouping, fields) => grouping.flatMap((id) => fields.find((field) => field.id === id) ?? []);
|
|
1487
|
+
var tableGrouping = (props, model) => activeTableGroups(model.grouping, props.features?.grouping?.fields ?? []);
|
|
1488
|
+
var canReorderTableRows = (props, model) => !!props.features?.reordering && !tableGrouping(props, model).length && !tableQuery(props, model).sort?.length;
|
|
1489
|
+
var partitionTableGroups = (rows, known, memberships) => {
|
|
1490
|
+
const groups = new Map(known.map((id) => [id, []]));
|
|
1491
|
+
for (const row of rows) {
|
|
1492
|
+
for (const id of new Set(memberships(row))) {
|
|
1493
|
+
const group = groups.get(id);
|
|
1494
|
+
if (group)
|
|
1495
|
+
group.push(row);
|
|
1496
|
+
else
|
|
1497
|
+
groups.set(id, [row]);
|
|
1498
|
+
}
|
|
1499
|
+
}
|
|
1500
|
+
return groups;
|
|
1501
|
+
};
|
|
1502
|
+
var tableGroupKey = (parent, fieldId, groupId) => `${parent ? `${parent}/` : ""}${encodeURIComponent(fieldId)}:${encodeURIComponent(groupId)}`;
|
|
1503
|
+
var reorderRows = ($, rowId, targetId, after) => {
|
|
1504
|
+
const rowIds = $.props.rowData.map(({ id }) => id);
|
|
1505
|
+
const next = $.evolve({ dragging: null });
|
|
1506
|
+
if (!available($.props) || !canReorderTableRows($.props, $.model) || rowId === targetId || !rowIds.includes(rowId) || !rowIds.includes(targetId))
|
|
1507
|
+
return next;
|
|
1508
|
+
const reordered = rowIds.filter((id) => id !== rowId);
|
|
1509
|
+
reordered.splice(reordered.indexOf(targetId) + Number(after), 0, rowId);
|
|
1510
|
+
return next.emit(DataTableEvents.RowsReordered({ rowIds: reordered }));
|
|
1511
|
+
};
|
|
1512
|
+
var moveGroup = ($, rowId, fieldId, groupId) => {
|
|
1513
|
+
const field = tableGrouping($.props, $.model).find(({ id }) => id === fieldId);
|
|
1514
|
+
const row = $.props.rowData.find(({ id }) => id === rowId);
|
|
1515
|
+
const next = $.evolve({ dragging: null });
|
|
1516
|
+
if (!available($.props) || !field?.movable || !row || row.groups?.[fieldId]?.includes(groupId))
|
|
1517
|
+
return next;
|
|
1518
|
+
if (!field.groups?.some(({ id }) => id === groupId) && !$.props.rowData.some((row) => row.groups?.[fieldId]?.includes(groupId)))
|
|
1519
|
+
return next;
|
|
1520
|
+
return next.emit(DataTableEvents.GroupMoveRequested({ rowId, fieldId, groupId }));
|
|
1521
|
+
};
|
|
1522
|
+
var changeQuery = ($, patch, ui = {}, legacy) => {
|
|
1523
|
+
const current = tableQuery($.props, $.model);
|
|
1524
|
+
const state = { ...current, ...patch };
|
|
1525
|
+
if (state.page === current.page && state.pageSize === current.pageSize && state.globalFilter === current.globalFilter && state.filters === current.filters && state.sort === current.sort)
|
|
1526
|
+
return $.evolve(ui);
|
|
1527
|
+
const step = $.evolve({
|
|
1528
|
+
...ui,
|
|
1529
|
+
query: $.props.state ? $.model.query : { ...state, sort: $.props.sort ? $.model.query.sort : state.sort }
|
|
1530
|
+
}).emit(DataTableEvents.StateChanged({ state }));
|
|
1531
|
+
return legacy ? step.emit(legacy) : step;
|
|
1532
|
+
};
|
|
1533
|
+
var tableFilterDraft = (id, current) => ({
|
|
1534
|
+
id,
|
|
1535
|
+
primary: current?.kind === "text" || current?.kind === "boolean" ? String(current.value) : current?.kind === "number" ? String(current.min ?? "") : current?.kind === "date" ? current.from ?? "" : "",
|
|
1536
|
+
secondary: current?.kind === "number" ? String(current.max ?? "") : current?.kind === "date" ? current.to ?? "" : "",
|
|
1537
|
+
operator: current?.kind === "text" ? current.operator : "contains",
|
|
1538
|
+
values: current?.kind === "values" ? current.values : []
|
|
1539
|
+
});
|
|
1540
|
+
var decodeFilter = Schema5.decodeUnknownOption(ColumnFilter);
|
|
1541
|
+
var decodeBound = Schema5.decodeOption(Schema5.FiniteFromString);
|
|
1542
|
+
var parseTableFilterDraft = (kind, {
|
|
1543
|
+
id,
|
|
1544
|
+
primary,
|
|
1545
|
+
secondary,
|
|
1546
|
+
operator,
|
|
1547
|
+
values
|
|
1548
|
+
}) => {
|
|
1549
|
+
switch (kind) {
|
|
1550
|
+
case "number": {
|
|
1551
|
+
const min = primary.trim() ? decodeBound(primary) : Option3.some(undefined);
|
|
1552
|
+
const max = secondary.trim() ? decodeBound(secondary) : Option3.some(undefined);
|
|
1553
|
+
return Option3.isNone(min) || Option3.isNone(max) ? Option3.none() : decodeFilter({ id, kind, min: min.value, max: max.value });
|
|
1554
|
+
}
|
|
1555
|
+
case "boolean":
|
|
1556
|
+
return decodeFilter({
|
|
1557
|
+
id,
|
|
1558
|
+
kind,
|
|
1559
|
+
value: primary === "true" ? true : primary === "false" ? false : undefined
|
|
1560
|
+
});
|
|
1561
|
+
case "values":
|
|
1562
|
+
return decodeFilter({ id, kind, values });
|
|
1563
|
+
case "date":
|
|
1564
|
+
return decodeFilter({
|
|
1565
|
+
id,
|
|
1566
|
+
kind,
|
|
1567
|
+
from: primary || undefined,
|
|
1568
|
+
to: secondary || undefined
|
|
1569
|
+
});
|
|
1570
|
+
case "text":
|
|
1571
|
+
return decodeFilter({ id, kind, operator, value: primary.trim() });
|
|
1572
|
+
}
|
|
1573
|
+
};
|
|
1574
|
+
var changeColumnFilter = ($, id, filter, ui) => {
|
|
1575
|
+
const filters = (tableQuery($.props, $.model).filters ?? []).filter((current) => current.id !== id);
|
|
1576
|
+
if (filter)
|
|
1577
|
+
filters.push(filter);
|
|
1578
|
+
return changeQuery($, { filters: filters.length ? filters : undefined, page: 0 }, ui);
|
|
1579
|
+
};
|
|
1580
|
+
var projectDataTableRows = (source, query, {
|
|
1581
|
+
pagination,
|
|
1582
|
+
grouped,
|
|
1583
|
+
sortMode,
|
|
1584
|
+
search,
|
|
1585
|
+
filter,
|
|
1586
|
+
sort
|
|
1587
|
+
}) => {
|
|
1588
|
+
const server = pagination && pagination.mode === "server";
|
|
1589
|
+
const filtered = server ? source : filter(search(source, query.globalFilter ?? ""), query.filters ?? []);
|
|
1590
|
+
const ordered = !server && sortMode !== "server" && query.sort?.length ? sort(filtered, query.sort) : filtered;
|
|
1591
|
+
const { pageSize } = query;
|
|
1592
|
+
const totalRows = server ? pagination.rowCount : ordered.length;
|
|
1593
|
+
const { page, pageCount, start, end } = resolveTablePage(totalRows, query);
|
|
1594
|
+
const paginationVisible = !!pagination && (server || !grouped);
|
|
1595
|
+
const rows = paginationVisible && !server ? ordered.slice(start, end) : ordered;
|
|
1596
|
+
return {
|
|
1597
|
+
rows,
|
|
1598
|
+
filtered,
|
|
1599
|
+
ordered,
|
|
1600
|
+
pageSize,
|
|
1601
|
+
totalRows,
|
|
1602
|
+
pageCount,
|
|
1603
|
+
page,
|
|
1604
|
+
paginationVisible
|
|
1605
|
+
};
|
|
1606
|
+
};
|
|
1607
|
+
var dataTablePage = (props, model, locale) => {
|
|
1608
|
+
const pagination = tableFeatures(props).pagination;
|
|
1609
|
+
const columns = tableDataColumns(props.columnDefs);
|
|
1610
|
+
return {
|
|
1611
|
+
...projectDataTableRows(props.rowData, tableQuery(props, model), {
|
|
1612
|
+
pagination,
|
|
1613
|
+
grouped: tableGrouping(props, model).length > 0,
|
|
1614
|
+
sortMode: props.sortMode,
|
|
1615
|
+
search: (rows, value) => filterTableRows(rows, columns, value, locale),
|
|
1616
|
+
filter: (rows, filters) => filterTableColumns(rows, columns, filters),
|
|
1617
|
+
sort: (rows, sorting) => sortTableRows(rows, columns, sorting, locale)
|
|
1618
|
+
}),
|
|
1619
|
+
pageSizes: pagination && pagination.pageSizes || defaultPageSizes
|
|
1620
|
+
};
|
|
1621
|
+
};
|
|
1622
|
+
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: `
|
|
1623
|
+
` })), Stream.runCollect, Effect2.map((parts) => parts.join("").slice(0, -1))));
|
|
1624
|
+
var tableExportFilename = (name, extension) => name.includes(".") ? name.replace(/\.[^/.]+$/, `.${extension}`) : `${name}.${extension}`;
|
|
1625
|
+
var downloadTableBlob = (content, type, filename) => {
|
|
1626
|
+
const url = window.URL.createObjectURL(new Blob([content], { type }));
|
|
1627
|
+
const link = document.createElement("a");
|
|
1628
|
+
link.href = url;
|
|
1629
|
+
link.download = filename;
|
|
1630
|
+
document.body.appendChild(link);
|
|
1631
|
+
try {
|
|
1632
|
+
link.click();
|
|
1633
|
+
} finally {
|
|
1634
|
+
link.remove();
|
|
1635
|
+
requestAnimationFrame(() => window.URL.revokeObjectURL(url));
|
|
1636
|
+
}
|
|
1637
|
+
};
|
|
1638
|
+
var tableExportValue = (column, row, locale) => {
|
|
1639
|
+
const value = row.cells[column.id];
|
|
1640
|
+
switch (column.type) {
|
|
1641
|
+
case "date":
|
|
1642
|
+
case "dateTime": {
|
|
1643
|
+
const date = resolveDate(value, column.type);
|
|
1644
|
+
return !date ? null : column.typeOptions?.exportFormat === "formatted" ? formatDateValue(date, column, locale) : dateIsoValue(date);
|
|
1645
|
+
}
|
|
1646
|
+
case "reference":
|
|
1647
|
+
return isTableReference(value) ? [value.label, value.description].filter(Boolean).join(" — ") : "";
|
|
1648
|
+
case "list":
|
|
1649
|
+
return isTableList(value) ? value.map(({ label }) => label).join(", ") : "";
|
|
1650
|
+
case "boolean":
|
|
1651
|
+
return !isTableBoolean(value) ? null : column.typeOptions?.exportFormat === "formatted" ? tableBooleanLabel(value, column.typeOptions) : value;
|
|
1652
|
+
case "number":
|
|
1653
|
+
return !isTableNumber(value) ? null : column.typeOptions?.exportFormat === "formatted" ? formatNumberValue(value, column.typeOptions, locale) : value;
|
|
1654
|
+
default:
|
|
1655
|
+
return columnValue(column, value);
|
|
1656
|
+
}
|
|
1657
|
+
};
|
|
1658
|
+
var DownloadTable = Command.make("DataTable/Download", {
|
|
1659
|
+
args: {
|
|
1660
|
+
filename: Schema5.String,
|
|
1661
|
+
content: Schema5.Redacted(Schema5.String, { disallowJsonEncode: true }),
|
|
1662
|
+
type: Schema5.String
|
|
1663
|
+
}
|
|
1664
|
+
}, ({ filename, content, type }) => Effect2.try(() => downloadTableBlob(Redacted.value(content), type, filename)).pipe(Effect2.match({
|
|
1665
|
+
onSuccess: () => DataTableMessage.ExportFinished({ failed: false }),
|
|
1666
|
+
onFailure: () => DataTableMessage.ExportFinished({ failed: true })
|
|
1667
|
+
})));
|
|
1668
|
+
var update2 = Component2.define(dataTableOptions).update({
|
|
1669
|
+
ReferenceImageFailed: ($, { src }) => $.model.failedImages.includes(src) ? $.model : $.evolve({ failedImages: [...$.model.failedImages, src] }),
|
|
1670
|
+
RowActivated: ($, { rowId }) => $.props.rowActivation && available($.props) && $.props.rowData.some(({ id }) => id === rowId) ? $.emit(DataTableEvents.RowActivated({ rowId })) : $.model,
|
|
1671
|
+
PreferencesLoaded: ($, { preferences }) => $.model.preferencesLoaded ? $.model : $.evolve({
|
|
1672
|
+
preferencesLoaded: true,
|
|
1673
|
+
columnVisibility: {
|
|
1674
|
+
...$.model.columnVisibility,
|
|
1675
|
+
...preferences?.columnVisibility
|
|
1676
|
+
},
|
|
1677
|
+
columnSizing: preferences?.columnSizing ?? $.model.columnSizing,
|
|
1678
|
+
grouping: preferences?.grouping ?? $.model.grouping,
|
|
1679
|
+
view: $.props.features?.gallery ? preferences?.view ?? $.model.view : "table"
|
|
1680
|
+
}),
|
|
1681
|
+
ItemActionRequested: ($, request) => {
|
|
1682
|
+
const row = $.props.rowData.find(({ id }) => id === request.rowId);
|
|
1683
|
+
const column = $.props.columnDefs.find(({ id }) => id === request.columnId);
|
|
1684
|
+
const items = row?.cells[request.columnId];
|
|
1685
|
+
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;
|
|
1686
|
+
},
|
|
1687
|
+
ExportStarted: ($) => $.evolve({ exporting: true, exportFailed: false }),
|
|
1688
|
+
ExportFinished: ($, { failed }) => $.evolve({ exporting: false, exportFailed: failed }),
|
|
1689
|
+
BuiltInExportRequested: ($, { format, locale = $.props.locale ?? "en" }) => {
|
|
1690
|
+
const feature = $.props.features?.export;
|
|
1691
|
+
if (!feature || feature.pending || $.model.exporting || feature.builtIn === false || !available($.props))
|
|
1692
|
+
return $.model;
|
|
1693
|
+
const projection = dataTablePage($.props, $.model, locale);
|
|
1694
|
+
const rows = feature.scope === "currentPage" ? projection.rows : projection.ordered;
|
|
1695
|
+
if (!rows.length)
|
|
1696
|
+
return $.model;
|
|
1697
|
+
const columns = tableDataColumns($.props.columnDefs.filter(({ id, export: enabled }) => enabled !== false && $.model.columnVisibility[id] !== false)).filter(({ export: enabled }) => enabled !== false);
|
|
1698
|
+
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) => [
|
|
1699
|
+
column.id,
|
|
1700
|
+
tableExportValue(column, row, locale)
|
|
1701
|
+
]))), null, 2);
|
|
1702
|
+
return $.evolve({ menu: null, exporting: true, exportFailed: false }).run(DownloadTable.make({
|
|
1703
|
+
content: Redacted.make(content),
|
|
1704
|
+
filename: tableExportFilename(feature.baseName, format),
|
|
1705
|
+
type: format === "csv" ? "text/csv;charset=utf-8" : "application/json;charset=utf-8"
|
|
1706
|
+
}));
|
|
1707
|
+
},
|
|
1708
|
+
RefreshRequested: ($) => $.props.features?.refresh ? $.emit(DataTableEvents.RefreshRequested()) : $.model,
|
|
1709
|
+
ExportRequested: ($, { actionId }) => !$.props.features?.export?.pending && $.props.features?.export?.actions?.some(({ id, disabled }) => id === actionId && !disabled) ? $.emit(DataTableEvents.ExportRequested({ actionId })) : $.model,
|
|
1710
|
+
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,
|
|
1711
|
+
GroupMoveRequested: ($, { rowId, fieldId, groupId }) => moveGroup($, rowId, fieldId, groupId),
|
|
1712
|
+
ReorderRequested: ($, { rowId, targetId, after }) => reorderRows($, rowId, targetId, after),
|
|
1713
|
+
DragStarted: ($, { rowId }) => $.evolve({ dragging: rowId }),
|
|
1714
|
+
DragEnded: ($) => $.evolve({ dragging: null }),
|
|
1715
|
+
DragDropped: ($, { targetId }) => $.model.dragging === null ? $.model : reorderRows($, $.model.dragging, targetId, $.props.rowData.findIndex(({ id }) => id === $.model.dragging) < $.props.rowData.findIndex(({ id }) => id === targetId)),
|
|
1716
|
+
GroupDropped: ($, { fieldId, groupId }) => $.model.dragging === null ? $.model : moveGroup($, $.model.dragging, fieldId, groupId),
|
|
1717
|
+
ViewPicked: ($, { view }) => view === "table" || $.props.features?.gallery ? $.evolve({ view, menu: null }) : $.model,
|
|
1718
|
+
GroupingToggled: ($, { fieldId }) => $.props.features?.grouping?.fields.some(({ id }) => id === fieldId) ? $.evolve({
|
|
1719
|
+
grouping: updateSelectedRows($.model.grouping, [fieldId], !$.model.grouping.includes(fieldId))
|
|
1720
|
+
}) : $.model,
|
|
1721
|
+
GroupToggled: ($, { key }) => $.evolve({
|
|
1722
|
+
collapsedGroups: {
|
|
1723
|
+
...$.model.collapsedGroups,
|
|
1724
|
+
[key]: !$.model.collapsedGroups[key]
|
|
1725
|
+
}
|
|
1726
|
+
}),
|
|
1727
|
+
ColumnResized: ($, { id, delta }) => {
|
|
1728
|
+
const column = $.props.columnDefs.find((column) => column.id === id);
|
|
1729
|
+
if (!column || column.resizable === false)
|
|
1730
|
+
return $.model;
|
|
1731
|
+
const sizing = {
|
|
1732
|
+
...$.model.columnSizing,
|
|
1733
|
+
[id]: tableColumnWidth(column, $.model.columnSizing) + delta
|
|
1734
|
+
};
|
|
1735
|
+
return $.evolve({
|
|
1736
|
+
columnSizing: { ...sizing, [id]: tableColumnWidth(column, sizing) }
|
|
1737
|
+
});
|
|
1738
|
+
},
|
|
1739
|
+
ColumnResizeReset: ($, { id }) => {
|
|
1740
|
+
const column = $.props.columnDefs.find((column) => column.id === id);
|
|
1741
|
+
if (!column || column.resizable === false)
|
|
1742
|
+
return $.model;
|
|
1743
|
+
return $.evolve({
|
|
1744
|
+
columnSizing: {
|
|
1745
|
+
...$.model.columnSizing,
|
|
1746
|
+
[id]: clampTableWidth(column)
|
|
1747
|
+
}
|
|
1748
|
+
});
|
|
1749
|
+
},
|
|
1750
|
+
ResizeStarted: ($, { id, x, pointerId }) => {
|
|
1751
|
+
const column = $.props.columnDefs.find((column) => column.id === id);
|
|
1752
|
+
return column && column.resizable !== false ? $.evolve({
|
|
1753
|
+
resizing: {
|
|
1754
|
+
id,
|
|
1755
|
+
x,
|
|
1756
|
+
pointerId,
|
|
1757
|
+
width: tableColumnWidth(column, $.model.columnSizing)
|
|
1758
|
+
}
|
|
1759
|
+
}) : $.model;
|
|
1760
|
+
},
|
|
1761
|
+
ResizeMoved: ($, { x, pointerId }) => {
|
|
1762
|
+
const resize = $.model.resizing;
|
|
1763
|
+
const column = resize && $.props.columnDefs.find(({ id }) => id === resize.id);
|
|
1764
|
+
if (!resize || resize.pointerId !== pointerId || !column || column.resizable === false)
|
|
1765
|
+
return $.model;
|
|
1766
|
+
return $.evolve({
|
|
1767
|
+
columnSizing: {
|
|
1768
|
+
...$.model.columnSizing,
|
|
1769
|
+
[resize.id]: tableColumnWidth(column, {
|
|
1770
|
+
[resize.id]: resize.width + x - resize.x
|
|
1771
|
+
})
|
|
1772
|
+
}
|
|
1773
|
+
});
|
|
1774
|
+
},
|
|
1775
|
+
ResizeEnded: ($, { pointerId }) => $.model.resizing?.pointerId === pointerId ? $.evolve({ resizing: null }) : $.model,
|
|
1776
|
+
ColumnFiltersCleared: ($, { id }) => {
|
|
1777
|
+
const column = $.props.columnDefs.find((column) => column.id === id);
|
|
1778
|
+
if (!column || !tableFeatures($.props).filtering)
|
|
1779
|
+
return $.model;
|
|
1780
|
+
const owned = new Set([
|
|
1781
|
+
id,
|
|
1782
|
+
...tableDataColumns([column]).map(({ id }) => id)
|
|
1783
|
+
]);
|
|
1784
|
+
const filters = tableQuery($.props, $.model).filters?.filter(({ id }) => !owned.has(id));
|
|
1785
|
+
return changeQuery($, { filters: filters?.length ? filters : undefined, page: 0 }, { filterDraft: null, invalidFilter: false });
|
|
1786
|
+
},
|
|
1787
|
+
ColumnSortCleared: ($, { id }) => {
|
|
1788
|
+
const column = $.props.columnDefs.find((column) => column.id === id);
|
|
1789
|
+
if (!column || !tableFeatures($.props).sorting)
|
|
1790
|
+
return $.model;
|
|
1791
|
+
const owned = new Set([
|
|
1792
|
+
id,
|
|
1793
|
+
...tableDataColumns([column]).map(({ id }) => id)
|
|
1794
|
+
]);
|
|
1795
|
+
const sort = (tableQuery($.props, $.model).sort ?? []).filter(({ id }) => !owned.has(id));
|
|
1796
|
+
return changeQuery($, { sort }, {}, DataTableEvents.SortChanged({ sort }));
|
|
1797
|
+
},
|
|
1798
|
+
MenuOpened: ($, { key }) => $.evolve({ menu: key, submenu: null, menuQuery: "" }),
|
|
1799
|
+
MenuQueryChanged: ($, { key, query }) => $.model.menu === key ? $.evolve({ menuQuery: query }) : $.model,
|
|
1800
|
+
MenuClosed: ($, { key }) => $.model.menu === key ? $.evolve({ menu: null, submenu: null }) : $.model,
|
|
1801
|
+
SubmenuOpened: ($, { key, filterColumnId }) => $.evolve({
|
|
1802
|
+
submenu: key,
|
|
1803
|
+
menuQuery: "",
|
|
1804
|
+
...filterColumnId === undefined ? {} : {
|
|
1805
|
+
filterDraft: tableFilterDraft(filterColumnId, tableQuery($.props, $.model).filters?.find(({ id }) => id === filterColumnId)),
|
|
1806
|
+
invalidFilter: false
|
|
1807
|
+
}
|
|
1808
|
+
}),
|
|
1809
|
+
SubmenuClosed: ($, { key }) => $.model.submenu === key ? $.evolve({ submenu: null }) : $.model,
|
|
1810
|
+
SearchChanged: ($, { value }) => tableFeatures($.props).search ? changeQuery($, { globalFilter: value || undefined, page: 0 }, { menu: null }) : $.model,
|
|
1811
|
+
FilterInputChanged: ($, { field, value }) => {
|
|
1812
|
+
const draft = $.model.filterDraft;
|
|
1813
|
+
return draft ? $.evolve({
|
|
1814
|
+
filterDraft: { ...draft, [field]: value },
|
|
1815
|
+
invalidFilter: false
|
|
1816
|
+
}) : $.model;
|
|
1817
|
+
},
|
|
1818
|
+
FilterOperatorChanged: ($, { operator }) => {
|
|
1819
|
+
const draft = $.model.filterDraft;
|
|
1820
|
+
return draft ? $.evolve({
|
|
1821
|
+
filterDraft: { ...draft, operator },
|
|
1822
|
+
invalidFilter: false
|
|
1823
|
+
}) : $.model;
|
|
1824
|
+
},
|
|
1825
|
+
FilterValueToggled: ($, { value, checked }) => {
|
|
1826
|
+
const draft = $.model.filterDraft;
|
|
1827
|
+
return draft ? $.evolve({
|
|
1828
|
+
filterDraft: {
|
|
1829
|
+
...draft,
|
|
1830
|
+
values: updateSelectedRows(draft.values, [value], checked)
|
|
1831
|
+
},
|
|
1832
|
+
invalidFilter: false
|
|
1833
|
+
}) : $.model;
|
|
1834
|
+
},
|
|
1835
|
+
FilterApplied: ($) => {
|
|
1836
|
+
const draft = $.model.filterDraft;
|
|
1837
|
+
if (!tableFeatures($.props).filtering || !draft)
|
|
1838
|
+
return $.model;
|
|
1839
|
+
const column = tableDataColumns($.props.columnDefs).find(({ id, filterable }) => id === draft.id && filterable !== false);
|
|
1840
|
+
if (!column)
|
|
1841
|
+
return $.model;
|
|
1842
|
+
const decoded = parseTableFilterDraft(tableFilterKind(column), draft);
|
|
1843
|
+
return Option3.isNone(decoded) ? $.evolve({ invalidFilter: true }) : changeColumnFilter($, draft.id, decoded.value, {
|
|
1844
|
+
invalidFilter: false
|
|
1845
|
+
});
|
|
1846
|
+
},
|
|
1847
|
+
FilterCleared: ($) => {
|
|
1848
|
+
const draft = $.model.filterDraft;
|
|
1849
|
+
if (!draft)
|
|
1850
|
+
return $.model;
|
|
1851
|
+
return changeColumnFilter($, draft.id, null, {
|
|
1852
|
+
filterDraft: tableFilterDraft(draft.id),
|
|
1853
|
+
invalidFilter: false
|
|
1854
|
+
});
|
|
1855
|
+
},
|
|
1856
|
+
ColumnFilterChanged: ($, { id, filter }) => {
|
|
1857
|
+
if (!tableFeatures($.props).filtering || !tableDataColumns($.props.columnDefs).some((column) => column.id === id && column.filterable !== false) || filter && filter.id !== id)
|
|
1858
|
+
return $.model;
|
|
1859
|
+
return changeColumnFilter($, id, filter);
|
|
1860
|
+
},
|
|
1861
|
+
FiltersCleared: ($) => changeQuery($, { filters: undefined, page: 0 }, {
|
|
1862
|
+
filterDraft: null,
|
|
1863
|
+
invalidFilter: false
|
|
1864
|
+
}),
|
|
1865
|
+
PageRequested: ($, { page }) => tableFeatures($.props).pagination && page >= 0 ? changeQuery($, { page }, { menu: null }) : $.model,
|
|
1866
|
+
ServerPageInvalidated: ($) => {
|
|
1867
|
+
const correction = serverPageCorrection($.props, $.model);
|
|
1868
|
+
return correction ? changeQuery($, { page: correction.page }) : $.model;
|
|
1869
|
+
},
|
|
1870
|
+
PageSizeRequested: ($, { pageSize }) => {
|
|
1871
|
+
const pagination = tableFeatures($.props).pagination;
|
|
1872
|
+
return pagination && (pagination.pageSizes ?? defaultPageSizes).includes(pageSize) ? changeQuery($, { pageSize, page: 0 }, { menu: null }) : $.model;
|
|
1873
|
+
},
|
|
1874
|
+
SortRequested: ($, { columnId, direction }) => {
|
|
1875
|
+
if (!tableFeatures($.props).sorting || !tableDataColumns($.props.columnDefs).some(({ id, sortable }) => id === columnId && sortable !== false))
|
|
1876
|
+
return $.model;
|
|
1877
|
+
const sort = direction === null ? (tableQuery($.props, $.model).sort ?? []).filter(({ id }) => id !== columnId) : [{ id: columnId, direction }];
|
|
1878
|
+
return changeQuery($, { sort: sort.length ? sort : undefined, page: 0 }, {}, DataTableEvents.SortChanged({ sort }));
|
|
1879
|
+
},
|
|
1880
|
+
ColumnVisibilityChanged: ($, { id, visible }) => tableFeatures($.props).columnVisibility && $.props.columnDefs.some((column) => column.id === id && column.hideable !== false) ? $.evolve({
|
|
1881
|
+
columnVisibility: { ...$.model.columnVisibility, [id]: visible }
|
|
1882
|
+
}) : $.model,
|
|
1883
|
+
SelectionRequested: ($, { rowIds, checked }) => {
|
|
1884
|
+
if (!available($.props) || !$.props.selection)
|
|
1885
|
+
return $.model;
|
|
1886
|
+
const requested = new Set(rowIds);
|
|
1887
|
+
const targets = $.props.rowData.filter((row) => row.selectable !== false && requested.has(row.id)).map(({ id }) => id);
|
|
1888
|
+
if (targets.length === 0)
|
|
1889
|
+
return $.model;
|
|
1890
|
+
const controlled = $.props.selection.selectedRowIds;
|
|
1891
|
+
const selectedRowIds = updateSelectedRows(controlled ?? $.model.selectedRowIds, targets, checked);
|
|
1892
|
+
return $.evolve(controlled ? {} : { selectedRowIds }).emit(DataTableEvents.SelectionChanged({ selectedRowIds }));
|
|
1893
|
+
},
|
|
1894
|
+
CellEditRequested: ($, { rowId, columnId, edit }) => {
|
|
1895
|
+
if (!available($.props))
|
|
1896
|
+
return $.model;
|
|
1897
|
+
const row = $.props.rowData.find(({ id }) => id === rowId);
|
|
1898
|
+
const column = $.props.columnDefs.find(({ id }) => id === columnId);
|
|
1899
|
+
if (!row || !column || row.disabledColumnIds?.includes(columnId))
|
|
1900
|
+
return $.model;
|
|
1901
|
+
const value = row.cells[columnId];
|
|
1902
|
+
if (edit._tag === "SetBoolean") {
|
|
1903
|
+
if (column.type !== "boolean" || !column.editable || !isTableBoolean(value) || edit.value === value)
|
|
1904
|
+
return $.model;
|
|
1905
|
+
} else {
|
|
1906
|
+
if (column.type !== "list")
|
|
1907
|
+
return $.model;
|
|
1908
|
+
const items = isTableList(value) ? value : [];
|
|
1909
|
+
const contains = items.some(({ value }) => value === edit.itemId);
|
|
1910
|
+
if (edit._tag === "AddItem") {
|
|
1911
|
+
if (contains || !column.options?.some(({ value }) => value === edit.itemId))
|
|
1912
|
+
return $.model;
|
|
1913
|
+
} else if (!contains || !column.allowRemove)
|
|
1914
|
+
return $.model;
|
|
1915
|
+
}
|
|
1916
|
+
return $.emit(DataTableEvents.CellEditRequested({ rowId, columnId, edit }));
|
|
1917
|
+
},
|
|
1918
|
+
RowActionRequested: ($, { rowId, actionId }) => {
|
|
1919
|
+
const row = $.props.rowData.find(({ id }) => id === rowId);
|
|
1920
|
+
if (!available($.props) || !row?.actions?.some(({ id, disabled }) => id === actionId && !disabled))
|
|
1921
|
+
return $.model;
|
|
1922
|
+
return $.emit(DataTableEvents.RowActionRequested({ rowId, actionId }));
|
|
1923
|
+
},
|
|
1924
|
+
BulkActionRequested: ($, { actionId }) => {
|
|
1925
|
+
const selection = $.props.selection;
|
|
1926
|
+
if (!available($.props) || !selection?.bulkActions?.some(({ id, disabled }) => id === actionId && !disabled))
|
|
1927
|
+
return $.model;
|
|
1928
|
+
const rowIds = tableSelectedRowIds($.props, $.model);
|
|
1929
|
+
return rowIds.length > 0 ? $.emit(DataTableEvents.BulkActionRequested({ actionId, rowIds })) : $.model;
|
|
1930
|
+
}
|
|
1931
|
+
});
|
|
1932
|
+
var dataTableBehaviours = {
|
|
1933
|
+
subscriptions: ({
|
|
1934
|
+
props,
|
|
1935
|
+
model
|
|
1936
|
+
}) => {
|
|
1937
|
+
const correction = serverPageCorrection(props, model);
|
|
1938
|
+
return correction ? [
|
|
1939
|
+
Subscription.make("reconcile-server-page", [correction.requested, correction.page, correction.size], () => Stream.make(DataTableMessage.ServerPageInvalidated()))
|
|
1940
|
+
] : [];
|
|
1941
|
+
},
|
|
1942
|
+
init: ({ props }) => ({
|
|
1943
|
+
menu: null,
|
|
1944
|
+
submenu: null,
|
|
1945
|
+
menuQuery: "",
|
|
1946
|
+
failedImages: [],
|
|
1947
|
+
selectedRowIds: [],
|
|
1948
|
+
query: {
|
|
1949
|
+
globalFilter: props.initialState?.globalFilter,
|
|
1950
|
+
filters: props.initialState?.filters,
|
|
1951
|
+
sort: props.initialState?.sort,
|
|
1952
|
+
page: props.initialState?.page ?? 0,
|
|
1953
|
+
pageSize: props.initialState?.pageSize ?? (props.pagination?.mode === undefined ? props.pagination?.pageSizes?.[0] : undefined) ?? DEFAULT_PAGE_SIZE
|
|
1954
|
+
},
|
|
1955
|
+
columnVisibility: props.initialState?.columnVisibility ?? {},
|
|
1956
|
+
preferencesLoaded: false,
|
|
1957
|
+
columnSizing: {},
|
|
1958
|
+
view: props.initialState?.view ?? "table",
|
|
1959
|
+
grouping: props.features?.grouping?.initial ?? [],
|
|
1960
|
+
collapsedGroups: {},
|
|
1961
|
+
dragging: null,
|
|
1962
|
+
exporting: false,
|
|
1963
|
+
exportFailed: false,
|
|
1964
|
+
resizing: null,
|
|
1965
|
+
filterDraft: null,
|
|
1966
|
+
invalidFilter: false
|
|
1967
|
+
}),
|
|
1968
|
+
update: update2
|
|
1969
|
+
};
|
|
1970
|
+
|
|
1971
|
+
// ../../src/components/data-table/html.ts
|
|
1972
|
+
var keyOf = (...parts) => JSON.stringify(parts);
|
|
1973
|
+
var cellClass = "px-3 py-2 align-middle";
|
|
1974
|
+
var isTextFilterOperator = Schema6.is(TextFilterOperator);
|
|
1975
|
+
var RowDrag = "application/x-krakstack-table-row";
|
|
1976
|
+
var PersistPreferences = Mount.makeStream("DataTable/PersistPreferences", {
|
|
1977
|
+
args: {
|
|
1978
|
+
columns: Schema6.Array(Schema6.String),
|
|
1979
|
+
gallery: Schema6.Boolean,
|
|
1980
|
+
preferences: Schema6.NullOr(DataTablePreferencesSchema)
|
|
1981
|
+
}
|
|
1982
|
+
}, (element, initial, changes) => Stream2.make(initial).pipe(Stream2.concat(changes), Stream2.map(({ columns, gallery, preferences }) => {
|
|
1983
|
+
const host = element.ownerDocument.defaultView;
|
|
1984
|
+
const storageKey = tablePreferencesKey(host?.location.pathname ?? "/", columns, gallery);
|
|
1985
|
+
if (preferences) {
|
|
1986
|
+
writeTablePreferences(storageKey, preferences, host);
|
|
1987
|
+
return;
|
|
1988
|
+
}
|
|
1989
|
+
return DataTableMessage.PreferencesLoaded({
|
|
1990
|
+
preferences: readTablePreferences(storageKey, host)
|
|
1991
|
+
});
|
|
1992
|
+
}), Stream2.filter((message) => message !== undefined)));
|
|
1993
|
+
var DataTable = Html2.component({
|
|
1994
|
+
...dataTableOptions,
|
|
1995
|
+
reads: { localeConfig: krakstackLocaleRead2 }
|
|
1996
|
+
}).make({
|
|
1997
|
+
...dataTableBehaviours,
|
|
1998
|
+
view: (h, model) => {
|
|
1999
|
+
const tableClasses = resolveTableClasses(h.props.classes);
|
|
2000
|
+
const props = h.props;
|
|
2001
|
+
const locale = props.locale ?? h.reads.localeConfig?.locale ?? "en";
|
|
2002
|
+
const copy = htmlDataTableMessages(locale, props.messages);
|
|
2003
|
+
const query = tableQuery(props, model);
|
|
2004
|
+
const features = tableFeatures(props);
|
|
2005
|
+
const columns = props.columnDefs.filter(({ id }) => model.columnVisibility[id] !== false);
|
|
2006
|
+
const dataColumns = tableDataColumns(props.columnDefs);
|
|
2007
|
+
const sortableColumns = dataColumns.filter(({ sortable }) => sortable !== false);
|
|
2008
|
+
const hideableColumns = props.columnDefs.filter(({ hideable }) => hideable !== false);
|
|
2009
|
+
const sort = query.sort ?? [];
|
|
2010
|
+
const selection = props.selection;
|
|
2011
|
+
const selected = new Set(tableSelectedRowIds(props, model));
|
|
2012
|
+
const selectedCount = selected.size;
|
|
2013
|
+
const {
|
|
2014
|
+
rows,
|
|
2015
|
+
page,
|
|
2016
|
+
pageSize,
|
|
2017
|
+
pageSizes,
|
|
2018
|
+
pageCount,
|
|
2019
|
+
totalRows,
|
|
2020
|
+
paginationVisible
|
|
2021
|
+
} = dataTablePage(props, model, locale);
|
|
2022
|
+
const grouping = tableGrouping(props, model);
|
|
2023
|
+
const gallery = model.view === "gallery" && features.gallery;
|
|
2024
|
+
const reorder = canReorderTableRows(props, model);
|
|
2025
|
+
const draggable = reorder || grouping.some(({ movable }) => movable);
|
|
2026
|
+
const dropOnRow = (rowId, group) => group ? DataTableMessage.GroupDropped(group) : reorder ? DataTableMessage.DragDropped({ targetId: rowId }) : undefined;
|
|
2027
|
+
const rowActions = reorder || props.rowData.some(({ actions }) => actions?.length);
|
|
2028
|
+
const span = Math.max(1, columns.length + Number(!!selection) + Number(rowActions) + Number(draggable));
|
|
2029
|
+
const virtual = tableVirtualization(rows.length, features.virtualization, !grouping.length && !gallery && !features.reordering && props.status?.error === undefined && rows.length > 0);
|
|
2030
|
+
const ids = rows.filter(({ selectable }) => selectable !== false).map(({ id }) => id);
|
|
2031
|
+
const selectedHere = ids.filter((id) => selected.has(id)).length;
|
|
2032
|
+
const status = props.status;
|
|
2033
|
+
const blocked = status?.error !== undefined || status?.loading === true && rows.length === 0;
|
|
2034
|
+
const widths = columns.map((column) => tableColumnWidth(column, model.columnSizing));
|
|
2035
|
+
const layoutWidth = tableLayoutWidth(widths, Number(!!selection) + Number(rowActions) + Number(draggable));
|
|
2036
|
+
const icons = {
|
|
2037
|
+
asc: ArrowUp,
|
|
2038
|
+
desc: ArrowDown,
|
|
2039
|
+
clear: X,
|
|
2040
|
+
filter: ListFilter,
|
|
2041
|
+
hide: EyeOff,
|
|
2042
|
+
sort: ChevronsUpDown,
|
|
2043
|
+
columns: Settings2,
|
|
2044
|
+
refresh: RefreshCw,
|
|
2045
|
+
table: Rows3,
|
|
2046
|
+
gallery: LayoutGrid,
|
|
2047
|
+
export: Download,
|
|
2048
|
+
csv: FileText,
|
|
2049
|
+
json: FileJson
|
|
2050
|
+
};
|
|
2051
|
+
const indicator = (icon) => icon ? icons[icon](h, { size: 16, className: "shrink-0" }) : undefined;
|
|
2052
|
+
const menu = (key, label, accessibleLabel, items, inBar = false, searchLabel, pending = false, presentation) => Menu(h, {
|
|
2053
|
+
key,
|
|
2054
|
+
props: {
|
|
2055
|
+
disabled: pending,
|
|
2056
|
+
open: model.menu === key,
|
|
2057
|
+
query: searchLabel ? model.menu === key ? model.menuQuery : "" : undefined,
|
|
2058
|
+
filter: searchLabel ? "contains" : undefined,
|
|
2059
|
+
items: items.map(({ id, name, disabled, checked }) => ({
|
|
2060
|
+
value: id,
|
|
2061
|
+
label: name,
|
|
2062
|
+
disabled,
|
|
2063
|
+
checked
|
|
2064
|
+
})),
|
|
2065
|
+
modal: false,
|
|
2066
|
+
align: presentation === "actions" || presentation && "selectedCount" in presentation ? "end" : "start",
|
|
2067
|
+
sideOffset: 4,
|
|
2068
|
+
locale
|
|
2069
|
+
},
|
|
2070
|
+
onEmit: {
|
|
2071
|
+
RequestedOpen: () => DataTableMessage.MenuOpened({ key }),
|
|
2072
|
+
RequestedClose: () => DataTableMessage.MenuClosed({ key }),
|
|
2073
|
+
Picked: ({ value }) => items.find(({ id, disabled }) => id === value && !disabled)?.message,
|
|
2074
|
+
Highlighted: () => {
|
|
2075
|
+
return;
|
|
2076
|
+
},
|
|
2077
|
+
RequestedQuery: ({ query }) => searchLabel ? DataTableMessage.MenuQueryChanged({ key, query }) : undefined,
|
|
2078
|
+
Settled: () => {
|
|
2079
|
+
return;
|
|
2080
|
+
}
|
|
2081
|
+
},
|
|
2082
|
+
view: (menu) => {
|
|
2083
|
+
const relationship = presentation && presentation !== "actions" && "relationship" in presentation;
|
|
2084
|
+
const showTitle = relationship || presentation === "actions" || presentation && "selectedCount" in presentation;
|
|
2085
|
+
return h.div.attr("data-slot", relationship ? "data-table-list-cell" : undefined).class(relationship ? tableClasses.relationshipCell : "").children((inBar ? MenubarTrigger(h, menu, accessibleLabel, presentation && presentation !== "actions" && "selectedCount" in presentation ? cn(tableClasses.selectedTrigger, "data-[popup-open]:bg-primary/90 data-[popup-open]:text-primary-foreground") : undefined) : menu.trigger({
|
|
2086
|
+
element: h.button.class(cn(buttonVariants({
|
|
2087
|
+
variant: "ghost",
|
|
2088
|
+
size: presentation === "actions" ? "icon" : "sm"
|
|
2089
|
+
}), presentation === "actions" && tableClasses.actionTrigger, presentation && presentation !== "actions" && "filtered" in presentation && tableClasses.headerTrigger, presentation && presentation !== "actions" && "relationship" in presentation && tableClasses.relationshipTrigger)).attrs({
|
|
2090
|
+
"aria-label": accessibleLabel,
|
|
2091
|
+
"aria-description": presentation && presentation !== "actions" && "filtered" in presentation && presentation.filtered ? `${copy.filters}: ${presentation.filtered}` : undefined
|
|
2092
|
+
})
|
|
2093
|
+
})).attr("aria-busy", pending ? "true" : undefined).children(presentation === "actions" ? Ellipsis(h, { size: 16 }) : presentation && ("selectedCount" in presentation) ? [
|
|
2094
|
+
copy.selected,
|
|
2095
|
+
h.span.class(tableClasses.count).children(String(presentation.selectedCount)),
|
|
2096
|
+
ChevronDown(h, { size: 16 })
|
|
2097
|
+
] : presentation && ("relationship" in presentation) ? [
|
|
2098
|
+
presentation.relationship,
|
|
2099
|
+
ChevronDown(h, { size: 16, className: "shrink-0" })
|
|
2100
|
+
] : presentation && ("toolbarIcon" in presentation) ? [indicator(presentation.toolbarIcon), label] : presentation ? [
|
|
2101
|
+
h.span.class("truncate").children(label),
|
|
2102
|
+
presentation.filtered > 0 && indicator("filter"),
|
|
2103
|
+
indicator(presentation.sort)
|
|
2104
|
+
] : label), MenuPositioner(h, menu).children(MenuPopup(h, menu, {
|
|
2105
|
+
class: presentation === "actions" || presentation && "selectedCount" in presentation ? "w-max min-w-36" : presentation && ("filtered" in presentation) ? "w-48 min-w-0" : undefined
|
|
2106
|
+
}).children(showTitle && h.div.class("px-2 py-1.5 text-xs font-medium text-muted-foreground").children(label), showTitle && MenuSeparator(h, menu), searchLabel && MenuInput(h, menu, { placeholder: searchLabel }), searchLabel && MenuEmpty(h, menu)?.children(copy.empty), menu.list(h.div.class("outline-none")).children(items.map(({
|
|
2107
|
+
id,
|
|
2108
|
+
name,
|
|
2109
|
+
variant,
|
|
2110
|
+
checked,
|
|
2111
|
+
radio,
|
|
2112
|
+
children,
|
|
2113
|
+
filterEditor,
|
|
2114
|
+
filterColumnId,
|
|
2115
|
+
childSearch,
|
|
2116
|
+
icon,
|
|
2117
|
+
separatorBefore
|
|
2118
|
+
}) => {
|
|
2119
|
+
if (children || filterEditor) {
|
|
2120
|
+
const subitems = children ?? [];
|
|
2121
|
+
const subkey = keyOf(key, id);
|
|
2122
|
+
return Menu(h, {
|
|
2123
|
+
key: subkey,
|
|
2124
|
+
props: {
|
|
2125
|
+
parentItem: id,
|
|
2126
|
+
query: childSearch ? model.menuQuery : undefined,
|
|
2127
|
+
filter: childSearch ? "contains" : undefined,
|
|
2128
|
+
open: model.menu === key && model.submenu === subkey,
|
|
2129
|
+
items: subitems.map(({ id, name, disabled }) => ({
|
|
2130
|
+
value: id,
|
|
2131
|
+
label: name,
|
|
2132
|
+
disabled
|
|
2133
|
+
})),
|
|
2134
|
+
locale
|
|
2135
|
+
},
|
|
2136
|
+
onEmit: {
|
|
2137
|
+
RequestedOpen: () => DataTableMessage.SubmenuOpened({
|
|
2138
|
+
key: subkey,
|
|
2139
|
+
...filterEditor ? { filterColumnId: filterColumnId ?? id } : {}
|
|
2140
|
+
}),
|
|
2141
|
+
RequestedClose: () => DataTableMessage.SubmenuClosed({ key: subkey }),
|
|
2142
|
+
Picked: ({ value }) => subitems.find(({ id, disabled }) => id === value && !disabled)?.message,
|
|
2143
|
+
Highlighted: () => {
|
|
2144
|
+
return;
|
|
2145
|
+
},
|
|
2146
|
+
RequestedQuery: ({ query }) => childSearch ? DataTableMessage.MenuQueryChanged({ key, query }) : undefined,
|
|
2147
|
+
Settled: () => {
|
|
2148
|
+
return;
|
|
2149
|
+
}
|
|
2150
|
+
},
|
|
2151
|
+
view: (submenu) => h.div.children(separatorBefore && MenuSeparator(h, menu), MenuSubTrigger(h, menu, submenu, {
|
|
2152
|
+
value: id
|
|
2153
|
+
}).children(indicator(icon), name), MenuPositioner(h, submenu).children(MenuPopup(h, submenu).children(childSearch && MenuInput(h, submenu, {
|
|
2154
|
+
placeholder: copy.addItem
|
|
2155
|
+
}), childSearch && MenuEmpty(h, submenu)?.children(copy.empty), filterEditor && model.submenu === subkey && filterEditor(), submenu.list(h.div).children(subitems.map(({
|
|
2156
|
+
id,
|
|
2157
|
+
name,
|
|
2158
|
+
variant,
|
|
2159
|
+
keepOpen,
|
|
2160
|
+
icon
|
|
2161
|
+
}) => MenuItem(h, submenu, {
|
|
2162
|
+
value: id,
|
|
2163
|
+
variant,
|
|
2164
|
+
closeOnClick: keepOpen ? false : undefined
|
|
2165
|
+
}).children(indicator(icon), name))))))
|
|
2166
|
+
});
|
|
2167
|
+
}
|
|
2168
|
+
const element = h.div.class(cn("data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground relative flex min-h-[30px] cursor-default items-center gap-2 rounded-sm px-2 whitespace-nowrap outline-none select-none data-[disabled]:opacity-45", variant === "destructive" && "text-destructive data-[highlighted]:bg-destructive/10 data-[highlighted]:text-destructive"));
|
|
2169
|
+
const part = radio ? menu.radioItem({ element, value: id }) : checked !== undefined ? menu.checkboxItem({
|
|
2170
|
+
element,
|
|
2171
|
+
value: id,
|
|
2172
|
+
closeOnClick: false
|
|
2173
|
+
}) : menu.item({
|
|
2174
|
+
element,
|
|
2175
|
+
value: id,
|
|
2176
|
+
closeOnClick: !searchLabel
|
|
2177
|
+
});
|
|
2178
|
+
const content = part.children(checked !== undefined && h.span.attr("aria-hidden", "true").class("w-3").children(checked ? "✓" : ""), indicator(icon), name);
|
|
2179
|
+
return separatorBefore ? h.div.children(MenuSeparator(h, menu), content) : content;
|
|
2180
|
+
})))));
|
|
2181
|
+
}
|
|
2182
|
+
});
|
|
2183
|
+
const check = (key, label, checked, onToggle, options) => Checkbox(h, {
|
|
2184
|
+
key,
|
|
2185
|
+
props: { checked, ...options },
|
|
2186
|
+
onEmit: { Toggled: ({ checked }) => onToggle(checked) },
|
|
2187
|
+
view: (checkbox) => h.span.class("grid size-4 shrink-0 place-items-center").children(CheckboxRoot(h, checkbox).attr("aria-label", label).children(CheckboxIndicator(h, checkbox, {
|
|
2188
|
+
class: "pointer-events-none"
|
|
2189
|
+
})))
|
|
2190
|
+
});
|
|
2191
|
+
const filterColumns = dataColumns.filter(({ filterable }) => filterable !== false);
|
|
2192
|
+
const draft = model.filterDraft;
|
|
2193
|
+
const filterColumn = draft && filterColumns.find(({ id }) => id === draft.id);
|
|
2194
|
+
const filterKind = filterColumn && tableFilterKind(filterColumn);
|
|
2195
|
+
const activeFilters = (query.filters ?? []).filter((filter) => filterColumns.some((column) => column.id === filter.id && tableFilterKind(column) === filter.kind));
|
|
2196
|
+
const selectFilter = (label, value, options, change) => h.label.class("grid gap-1 text-sm").children(label, h.select.class("border-input bg-background rounded-md border px-2 py-1").value(value).on("change", ({ value }) => change(value)).children(options.map(({ value, label }) => h.option.key(value).attr("value", value).children(label))));
|
|
2197
|
+
const filterInput = (label, field, value, type = "text") => h.label.class("grid gap-1 text-sm").children(label, Input(h, {
|
|
2198
|
+
element: type === "number" ? h.input.attrs({ type: "number", step: "any" }) : h.input.attr("type", type),
|
|
2199
|
+
props: { value },
|
|
2200
|
+
onUpdate: ({ value }) => DataTableMessage.FilterInputChanged({ field, value })
|
|
2201
|
+
}));
|
|
2202
|
+
const filterPanel = () => h.div.class("grid w-64 max-w-[80vw] gap-2 p-2").children(draft && filterColumn && h.div.key(filterColumn.id).class("grid gap-2").children(filterKind === "text" && [
|
|
2203
|
+
selectFilter(copy.filterOperator, draft.operator, [
|
|
2204
|
+
{ value: "contains", label: copy.filterContains },
|
|
2205
|
+
{ value: "equals", label: copy.filterEquals },
|
|
2206
|
+
{ value: "startsWith", label: copy.filterStartsWith },
|
|
2207
|
+
{ value: "endsWith", label: copy.filterEndsWith }
|
|
2208
|
+
], (operator) => isTextFilterOperator(operator) ? DataTableMessage.FilterOperatorChanged({ operator }) : undefined),
|
|
2209
|
+
filterInput(copy.filterValue, "primary", draft.primary)
|
|
2210
|
+
], filterKind === "number" && [
|
|
2211
|
+
filterInput(copy.filterMin, "primary", draft.primary, "number"),
|
|
2212
|
+
filterInput(copy.filterMax, "secondary", draft.secondary, "number")
|
|
2213
|
+
], filterKind === "date" && [
|
|
2214
|
+
filterInput(copy.filterFrom, "primary", draft.primary, "date"),
|
|
2215
|
+
filterInput(copy.filterTo, "secondary", draft.secondary, "date")
|
|
2216
|
+
], filterKind === "boolean" && selectFilter(copy.filterValue, draft.primary, [
|
|
2217
|
+
{ value: "", label: "—" },
|
|
2218
|
+
{ value: "true", label: copy.filterTrue },
|
|
2219
|
+
{ value: "false", label: copy.filterFalse }
|
|
2220
|
+
], (value) => DataTableMessage.FilterInputChanged({ field: "primary", value })), filterKind === "values" && h.fieldset.class("grid gap-1").children(h.legend.class("text-sm").children(copy.filterValue), (filterColumn.type === "list" && filterColumn.filterOptions ? filterColumn.filterOptions : tableFilterOptions(props.rowData, filterColumn.id, locale)).map(({ value, label }) => h.label.key(value).class("flex items-center gap-2 text-sm").children(h.input.attr("type", "checkbox").checked(draft.values.includes(value)).on("change", ({ checked }) => DataTableMessage.FilterValueToggled({ value, checked })), label))), model.invalidFilter && h.p.attr("role", "alert").class("text-destructive text-sm").children(copy.filterInvalid), h.div.class("flex flex-wrap gap-2").children(Button(h, {
|
|
2221
|
+
size: "sm",
|
|
2222
|
+
onPress: DataTableMessage.FilterApplied()
|
|
2223
|
+
}).children(copy.filterApply), Button(h, {
|
|
2224
|
+
size: "sm",
|
|
2225
|
+
variant: "outline",
|
|
2226
|
+
onPress: DataTableMessage.FilterCleared()
|
|
2227
|
+
}).children(copy.filterClear))), activeFilters.length > 0 && Button(h, {
|
|
2228
|
+
size: "sm",
|
|
2229
|
+
variant: "ghost",
|
|
2230
|
+
onPress: DataTableMessage.FiltersCleared()
|
|
2231
|
+
}).children(copy.filtersClear));
|
|
2232
|
+
const cell = (column, row) => {
|
|
2233
|
+
const value = row.cells[column.id];
|
|
2234
|
+
const empty = column.emptyLabel ?? "—";
|
|
2235
|
+
const disabled = row.disabledColumnIds?.includes(column.id);
|
|
2236
|
+
const edit = (edit) => DataTableMessage.CellEditRequested({ rowId: row.id, columnId: column.id, edit });
|
|
2237
|
+
switch (column.type) {
|
|
2238
|
+
case "number":
|
|
2239
|
+
return isTableNumber(value) ? formatNumberValue(value, column.typeOptions, locale) : empty;
|
|
2240
|
+
case "date":
|
|
2241
|
+
case "dateTime": {
|
|
2242
|
+
const date = resolveDate(value, column.type);
|
|
2243
|
+
return date ? h.time.attr("datetime", dateIsoValue(date)).children(formatDateValue(date, column, locale)) : empty;
|
|
2244
|
+
}
|
|
2245
|
+
case "boolean":
|
|
2246
|
+
return isTableBoolean(value) ? check(keyOf("edit", row.id, column.id), `${column.headerName}: ${row.label}`, value, (value) => edit(DataTableEdit.SetBoolean({ value })), { readOnly: !column.editable || disabled }) : empty;
|
|
2247
|
+
case "reference":
|
|
2248
|
+
return isTableReference(value) ? h.div.class(tableClasses.reference).children(h.span.class(cn(tableClasses.referenceAvatar, "rounded-full")).children(h.span.attr("aria-hidden", "true").children(tableInitials(value.label)), value.imageSrc && !model.failedImages.includes(value.imageSrc) && h.img.attrs({
|
|
2249
|
+
src: value.imageSrc,
|
|
2250
|
+
alt: "",
|
|
2251
|
+
loading: "lazy"
|
|
2252
|
+
}).class("absolute inset-0 size-full object-cover").on("error", DataTableMessage.ReferenceImageFailed({ src: value.imageSrc }))), h.div.class(tableClasses.referenceText).children(h.span.class(tableClasses.referenceName).children(value.label), value.description && h.span.class(tableClasses.referenceDescription).children(value.description))) : empty;
|
|
2253
|
+
case "list": {
|
|
2254
|
+
const current = isTableList(value) ? value : [];
|
|
2255
|
+
if (column.manageLabel && !disabled && (column.options || column.allowRemove)) {
|
|
2256
|
+
const used = new Set(current.map(({ value }) => value));
|
|
2257
|
+
const available = (column.options ?? []).filter(({ value }) => !used.has(value));
|
|
2258
|
+
const items = current.map(({ value, label }) => ({
|
|
2259
|
+
id: keyOf("member", value),
|
|
2260
|
+
name: label,
|
|
2261
|
+
disabled: !column.allowRemove,
|
|
2262
|
+
...column.allowRemove ? {
|
|
2263
|
+
children: [
|
|
2264
|
+
{
|
|
2265
|
+
id: "remove",
|
|
2266
|
+
name: copy.removeItem,
|
|
2267
|
+
keepOpen: true,
|
|
2268
|
+
message: edit(DataTableEdit.RemoveItem({ itemId: value }))
|
|
2269
|
+
}
|
|
2270
|
+
]
|
|
2271
|
+
} : {}
|
|
2272
|
+
}));
|
|
2273
|
+
return h.div.class("min-w-0").children(menu(keyOf("manage", row.id, column.id), column.manageLabel, `${column.manageLabel}: ${row.label}`, [
|
|
2274
|
+
...items,
|
|
2275
|
+
...available.length ? [
|
|
2276
|
+
{
|
|
2277
|
+
id: "add",
|
|
2278
|
+
name: copy.addItem,
|
|
2279
|
+
childSearch: true,
|
|
2280
|
+
separatorBefore: items.length > 0,
|
|
2281
|
+
children: available.map(({ value, label }) => ({
|
|
2282
|
+
id: value,
|
|
2283
|
+
name: label,
|
|
2284
|
+
keepOpen: true,
|
|
2285
|
+
message: edit(DataTableEdit.AddItem({ itemId: value }))
|
|
2286
|
+
}))
|
|
2287
|
+
}
|
|
2288
|
+
] : []
|
|
2289
|
+
], false, undefined, false, {
|
|
2290
|
+
relationship: h.span.class("min-w-0 truncate").children(current.length ? `${current.slice(0, column.visibleCount ?? 3).map(({ label }) => label).join(", ")}${current.length > (column.visibleCount ?? 3) ? ` +${current.length - (column.visibleCount ?? 3)}` : ""}` : empty)
|
|
2291
|
+
}));
|
|
2292
|
+
}
|
|
2293
|
+
if (column.display && !column.options && !column.allowRemove) {
|
|
2294
|
+
const visible = current.slice(0, column.visibleCount ?? 3);
|
|
2295
|
+
const overflow = current.length - visible.length;
|
|
2296
|
+
const label = column.actionsLabel ?? (column.itemActions?.length ? copy.actions : copy.listDetails);
|
|
2297
|
+
const summary = column.display === "icon" ? h.span.class("flex min-w-0 items-center gap-1 overflow-hidden").children(visible.map(({ value, label }) => h.span.key(value).attr("title", label).class("inline-grid size-7 place-items-center rounded-full bg-muted text-xs").children(tableInitials(label))), overflow > 0 && `+${overflow}`) : h.span.class("min-w-0 truncate").children(`${visible.map(({ label }) => label).join(", ")}${overflow > 0 ? ` +${overflow}` : ""}`);
|
|
2298
|
+
return !current.length ? empty : overflow > 0 || column.itemActions?.length ? h.div.class("min-w-0").children(menu(keyOf("items", row.id, column.id), label, `${label}: ${row.label}`, current.map(({ value, label }) => ({
|
|
2299
|
+
id: value,
|
|
2300
|
+
name: label,
|
|
2301
|
+
...column.itemActions?.length ? {
|
|
2302
|
+
children: column.itemActions.map((action) => ({
|
|
2303
|
+
...action,
|
|
2304
|
+
message: DataTableMessage.ItemActionRequested({
|
|
2305
|
+
rowId: row.id,
|
|
2306
|
+
columnId: column.id,
|
|
2307
|
+
itemId: value,
|
|
2308
|
+
actionId: action.id
|
|
2309
|
+
})
|
|
2310
|
+
}))
|
|
2311
|
+
} : { disabled: true }
|
|
2312
|
+
})), false, undefined, false, { relationship: summary })) : summary;
|
|
2313
|
+
}
|
|
2314
|
+
const used = new Set(current.map(({ value }) => value));
|
|
2315
|
+
const add = (column.options ?? []).filter(({ value }) => !used.has(value));
|
|
2316
|
+
return h.div.class("grid gap-1").children(current.length > 0 ? h.ul.class("flex flex-wrap gap-1").children(current.map(({ value, label }) => h.li.key(value).class("bg-muted rounded-sm ps-2 inline-flex items-center gap-1").children(label, !!column.itemActions?.length && menu(keyOf("item", row.id, column.id, value), copy.actions, `${copy.actions}: ${label} — ${row.label}`, column.itemActions.map((action) => ({
|
|
2317
|
+
...action,
|
|
2318
|
+
message: DataTableMessage.ItemActionRequested({
|
|
2319
|
+
rowId: row.id,
|
|
2320
|
+
columnId: column.id,
|
|
2321
|
+
itemId: value,
|
|
2322
|
+
actionId: action.id
|
|
2323
|
+
})
|
|
2324
|
+
}))), column.allowRemove && !disabled && Button(h, {
|
|
2325
|
+
variant: "ghost",
|
|
2326
|
+
size: "sm",
|
|
2327
|
+
onPress: edit(DataTableEdit.RemoveItem({ itemId: value }))
|
|
2328
|
+
}).attr("aria-label", `${copy.removeItem}: ${label} — ${row.label}`).children("×")))) : empty, !disabled && add.length > 0 && menu(keyOf("add", row.id, column.id), copy.addItem, `${copy.addItem} ${column.headerName}: ${row.label}`, add.map(({ value, label }) => ({
|
|
2329
|
+
id: value,
|
|
2330
|
+
name: label,
|
|
2331
|
+
message: edit(DataTableEdit.AddItem({ itemId: value }))
|
|
2332
|
+
})), false, copy.addItem));
|
|
2333
|
+
}
|
|
2334
|
+
case "text":
|
|
2335
|
+
return isTableText(value) ? value : empty;
|
|
2336
|
+
}
|
|
2337
|
+
};
|
|
2338
|
+
const dragHandle = (row) => draggable && h.span.attr("aria-hidden", "true").class("inline-flex size-8 cursor-grab items-center justify-center text-muted-foreground").draggable({ [RowDrag]: row.id }, { effectAllowed: "move" }).on("dragstart", DataTableMessage.DragStarted({ rowId: row.id })).on("dragend", DataTableMessage.DragEnded()).children(GripVertical(h, { size: 16 }));
|
|
2339
|
+
const rowControls = (row, siblings, key) => {
|
|
2340
|
+
const items = tableRowActions(row, siblings, reorder, copy);
|
|
2341
|
+
return items.length > 0 && menu(keyOf("row", key, row.id), copy.actions, `${copy.actions}: ${row.label}`, items, false, undefined, false, "actions");
|
|
2342
|
+
};
|
|
2343
|
+
const renderRow = (row, siblings, key, group) => {
|
|
2344
|
+
const primary = row.actions?.find(({ id, disabled }) => id === row.primaryActionId && !disabled);
|
|
2345
|
+
const activate = props.rowActivation ? DataTableMessage.RowActivated({ rowId: row.id }) : primary && DataTableMessage.RowActionRequested({ rowId: row.id, actionId: primary.id });
|
|
2346
|
+
const activationColumn = columns.find(({ type }) => type !== "list" && type !== "boolean");
|
|
2347
|
+
const tr = h.tr.key(keyOf(key, row.id)).class("group/row border-b last:border-0 hover:bg-muted/50 data-[selected]:bg-muted/40").attr("data-selected", selected.has(row.id) ? "" : undefined);
|
|
2348
|
+
const drop = dropOnRow(row.id, group);
|
|
2349
|
+
return (drop ? tr.dropTarget({ accepts: [RowDrag], dropEffect: "move" }).on("drop", drop) : tr).children(selection && h.td.class(tableClasses.selectionCell).children(h.div.class(tableClasses.selectionCenter).children(check(keyOf("select", key, row.id), `${copy.selectRow}: ${row.label}`, selected.has(row.id), (checked) => DataTableMessage.SelectionRequested({ rowIds: [row.id], checked }), { disabled: row.selectable === false }))), draggable && h.td.class("w-10 ps-1").children(dragHandle(row)), columns.map((column) => {
|
|
2350
|
+
const td = h.td.key(column.id).attr("data-slot", "table-cell").class(cn(cellClass, tableClasses.cell, column.truncate ? "whitespace-nowrap" : "whitespace-normal", column.type === "list" && "p-0", "has-[[data-slot=data-table-list-cell]]:relative has-[[data-slot=data-table-list-cell]]:h-16"));
|
|
2351
|
+
const content = () => h.div.class(cn(tableClasses.cellContent, column.truncate && "truncate")).children(cell(column, row));
|
|
2352
|
+
if (props.rowActivation && activate && column === activationColumn) {
|
|
2353
|
+
return td.children(Button(h, { variant: "ghost", onPress: activate }).attr("aria-label", row.label).class("w-full min-w-0 justify-start px-0").children(content()));
|
|
2354
|
+
}
|
|
2355
|
+
return (activate && column.type !== "list" && column.type !== "boolean" ? td.class("cursor-pointer").on("click", activate) : td).children(content());
|
|
2356
|
+
}), rowActions && h.td.class(cn(tableClasses.actionsCell, "group-data-[selected]/row:bg-muted")).children(h.div.class(tableClasses.actionsAlign).children(primary && activate && Button(h, {
|
|
2357
|
+
variant: primary.variant === "destructive" ? "destructive" : "ghost",
|
|
2358
|
+
size: "sm",
|
|
2359
|
+
onPress: activate
|
|
2360
|
+
}).attr("aria-label", `${primary.name}: ${row.label}`).children(primary.name), rowControls(row, siblings, key))));
|
|
2361
|
+
};
|
|
2362
|
+
const galleryValue = (id, row) => {
|
|
2363
|
+
const column = props.columnDefs.find((column) => column.id === id);
|
|
2364
|
+
return column ? cell(column, row) : "";
|
|
2365
|
+
};
|
|
2366
|
+
const renderCard = (row, siblings, key, group) => {
|
|
2367
|
+
if (!gallery)
|
|
2368
|
+
return h.div;
|
|
2369
|
+
const image = gallery.image && row.cells[gallery.image];
|
|
2370
|
+
const primary = row.actions?.find(({ id, disabled }) => row.primaryActionId === id && !disabled);
|
|
2371
|
+
const name = galleryValue(gallery.name, row) || row.label;
|
|
2372
|
+
const activate = props.rowActivation ? DataTableMessage.RowActivated({ rowId: row.id }) : primary && DataTableMessage.RowActionRequested({ rowId: row.id, actionId: primary.id });
|
|
2373
|
+
const card = h.article.key(keyOf(key, row.id)).class("grid content-start gap-2 rounded-lg border p-3");
|
|
2374
|
+
const drop = dropOnRow(row.id, group);
|
|
2375
|
+
return (drop ? card.dropTarget({ accepts: [RowDrag], dropEffect: "move" }).on("drop", drop) : card).children(isTableText(image) && h.img.attrs({ src: image, alt: "", loading: "lazy" }).class("aspect-video w-full rounded object-cover"), h.h3.class("font-medium").children(activate ? Button(h, {
|
|
2376
|
+
variant: "ghost",
|
|
2377
|
+
onPress: activate
|
|
2378
|
+
}).children(name) : name), gallery.description && h.div.class("text-muted-foreground text-sm").children(galleryValue(gallery.description, row)), h.div.class("flex flex-wrap gap-2").children(gallery.tags?.map((id) => h.span.key(id).class("bg-muted rounded px-2 py-1 text-xs").children(galleryValue(id, row)))), selection && check(keyOf("select", key, row.id), `${copy.selectRow}: ${row.label}`, selected.has(row.id), (checked) => DataTableMessage.SelectionRequested({ rowIds: [row.id], checked }), { disabled: row.selectable === false }), h.div.class("flex items-center justify-end gap-1").children(dragHandle(row), rowControls(row, siblings, key)));
|
|
2379
|
+
};
|
|
2380
|
+
const renderGroups = (members, depth, parent, parentTarget) => {
|
|
2381
|
+
const field = grouping[depth];
|
|
2382
|
+
if (!field)
|
|
2383
|
+
return members.map((row) => gallery ? renderCard(row, members, parent, parentTarget) : renderRow(row, members, parent, parentTarget));
|
|
2384
|
+
const groups = partitionTableGroups(members, field.groups?.map(({ id }) => id) ?? [], (row) => row.groups?.[field.id] ?? []);
|
|
2385
|
+
return [...groups].flatMap(([groupId, children]) => {
|
|
2386
|
+
const key = tableGroupKey(parent, field.id, groupId);
|
|
2387
|
+
const definition = field.groups?.find(({ id }) => id === groupId);
|
|
2388
|
+
const label = definition?.label ?? groupId;
|
|
2389
|
+
const open = !model.collapsedGroups[key];
|
|
2390
|
+
const title = h.div.class(cn(tableClasses.groupContent, !gallery && tableClasses.groupSticky)).children(h.button.attr("type", "button").class(tableClasses.groupTrigger).style({ paddingInlineStart: `${depth * 20}px` }).on("click", DataTableMessage.GroupToggled({ key })).attr("aria-expanded", open ? "true" : "false").attr("aria-label", label).children((open ? ChevronDown : ChevronRight)(h, {
|
|
2391
|
+
size: 16,
|
|
2392
|
+
className: "shrink-0"
|
|
2393
|
+
}), h.span.class("min-w-0 flex-1 truncate").children(label), h.span.class(tableClasses.count).children(String(children.length))), !!field.actions?.length && menu(keyOf("group", key), field.actionsLabel ?? copy.actions, `${field.actionsLabel ?? copy.actions}: ${label}`, field.actions.map((action) => ({
|
|
2394
|
+
...action,
|
|
2395
|
+
message: DataTableMessage.GroupActionRequested({
|
|
2396
|
+
fieldId: field.id,
|
|
2397
|
+
groupId,
|
|
2398
|
+
actionId: action.id
|
|
2399
|
+
})
|
|
2400
|
+
})), false, undefined, false, "actions"));
|
|
2401
|
+
const header = gallery ? h.div.key(key).class(cn("col-span-full rounded-md border", tableClasses.group)).children(title) : h.tr.key(key).class(tableClasses.group).children(h.td.class("p-0").attr("colspan", String(span)).children(title));
|
|
2402
|
+
const groupTarget = field.movable ? { fieldId: field.id, groupId } : parentTarget;
|
|
2403
|
+
const target = groupTarget ? header.dropTarget({ accepts: [RowDrag], dropEffect: "move" }).on("drop", DataTableMessage.GroupDropped(groupTarget)) : header;
|
|
2404
|
+
const empty = definition?.empty ?? copy.empty;
|
|
2405
|
+
return [
|
|
2406
|
+
target,
|
|
2407
|
+
...open ? children.length ? renderGroups(children, depth + 1, key, groupTarget) : [
|
|
2408
|
+
gallery ? h.p.key(keyOf(key, "empty")).class("col-span-full text-sm").children(empty) : h.tr.key(keyOf(key, "empty")).children(h.td.attr("colspan", String(span)).class("p-3").children(empty))
|
|
2409
|
+
] : []
|
|
2410
|
+
];
|
|
2411
|
+
});
|
|
2412
|
+
};
|
|
2413
|
+
return h.section.class(cn("grid min-w-0 gap-2", props.className)).onMount(PersistPreferences({
|
|
2414
|
+
columns: props.columnDefs.map(({ id }) => id),
|
|
2415
|
+
gallery: !!features.gallery,
|
|
2416
|
+
preferences: tablePreferences(model)
|
|
2417
|
+
})).children(h.div.class(tableClasses.toolbar).children(features.search && h.div.class(tableClasses.toolbarSearch).children(Search(h, {
|
|
2418
|
+
size: 16,
|
|
2419
|
+
className: "text-muted-foreground pointer-events-none absolute top-1/2 start-3 -translate-y-1/2"
|
|
2420
|
+
}), Input(h, {
|
|
2421
|
+
class: cn("ps-9", query.globalFilter && "pe-10"),
|
|
2422
|
+
element: h.input.attrs({
|
|
2423
|
+
type: "search",
|
|
2424
|
+
placeholder: copy.search
|
|
2425
|
+
}),
|
|
2426
|
+
props: { value: query.globalFilter ?? "" },
|
|
2427
|
+
onUpdate: ({ value }) => DataTableMessage.SearchChanged({ value })
|
|
2428
|
+
}).attr("aria-label", copy.search), !!query.globalFilter && Button(h, {
|
|
2429
|
+
class: "absolute end-1 top-1/2 -translate-y-1/2",
|
|
2430
|
+
size: "icon-sm",
|
|
2431
|
+
variant: "ghost",
|
|
2432
|
+
onPress: DataTableMessage.SearchChanged({ value: "" })
|
|
2433
|
+
}).attr("aria-label", copy.search).children(X(h, { size: 16 }))), (features.filtering && filterColumns.length > 0 || features.sorting && sortableColumns.length > 0 || features.columnVisibility && hideableColumns.length > 0 || !blocked && selectedCount > 0 && !!selection?.bulkActions?.length || features.refresh || !!features.grouping?.fields.length || !!features.gallery || !!features.export) && Menubar(h, {
|
|
2434
|
+
props: { modal: false },
|
|
2435
|
+
view: (bar) => h.div.class(tableClasses.toolbarMenus).children(MenubarRoot(h, bar, tableClasses.menubar).children(!blocked && selectedCount > 0 && selection && selection.bulkActions && selection.bulkActions.length > 0 && menu(keyOf("bulk"), selection.bulkActionsLabel ?? copy.actions, `${copy.selected} ${selectedCount}`, selection.bulkActions.map((action) => ({
|
|
2436
|
+
...action,
|
|
2437
|
+
message: DataTableMessage.BulkActionRequested({
|
|
2438
|
+
actionId: action.id
|
|
2439
|
+
})
|
|
2440
|
+
})), true, undefined, false, { selectedCount }), features.filtering && filterColumns.length > 0 && menu(keyOf("filters"), activeFilters.length ? `${copy.filters} (${activeFilters.length})` : copy.filters, copy.filters, [
|
|
2441
|
+
...filterColumns.map(({ id, headerName }) => ({
|
|
2442
|
+
id,
|
|
2443
|
+
name: headerName,
|
|
2444
|
+
filterEditor: filterPanel
|
|
2445
|
+
})),
|
|
2446
|
+
...activeFilters.length > 0 ? [
|
|
2447
|
+
{
|
|
2448
|
+
id: keyOf("clear-filters"),
|
|
2449
|
+
name: copy.filtersClear,
|
|
2450
|
+
icon: "clear",
|
|
2451
|
+
message: DataTableMessage.FiltersCleared()
|
|
2452
|
+
}
|
|
2453
|
+
] : []
|
|
2454
|
+
], true, undefined, false, { toolbarIcon: "filter" }), features.sorting && sortableColumns.length > 0 && menu(keyOf("sort-toolbar"), copy.sortBy, copy.sortBy, sortableColumns.map((column) => ({
|
|
2455
|
+
id: column.id,
|
|
2456
|
+
name: column.headerName,
|
|
2457
|
+
children: ["asc", "desc", null].filter((direction) => direction !== null || sort.some(({ id }) => id === column.id)).map((direction) => ({
|
|
2458
|
+
id: keyOf(column.id, direction ?? "clear"),
|
|
2459
|
+
name: direction === "asc" ? copy.sortAsc : direction === "desc" ? copy.sortDesc : copy.sortClear,
|
|
2460
|
+
icon: direction ?? "clear",
|
|
2461
|
+
message: DataTableMessage.SortRequested({
|
|
2462
|
+
columnId: column.id,
|
|
2463
|
+
direction
|
|
2464
|
+
})
|
|
2465
|
+
}))
|
|
2466
|
+
})), true, undefined, false, { toolbarIcon: sort[0]?.direction ?? "sort" }), features.columnVisibility && hideableColumns.length > 0 && menu(keyOf("columns"), copy.columns, copy.columns, hideableColumns.map(({ id, headerName }) => ({
|
|
2467
|
+
id,
|
|
2468
|
+
name: headerName,
|
|
2469
|
+
checked: model.columnVisibility[id] !== false,
|
|
2470
|
+
message: DataTableMessage.ColumnVisibilityChanged({
|
|
2471
|
+
id,
|
|
2472
|
+
visible: model.columnVisibility[id] === false
|
|
2473
|
+
})
|
|
2474
|
+
})), true, undefined, false, { toolbarIcon: "columns" }), features.refresh && menu(keyOf("refresh"), copy.refresh, copy.refresh, [
|
|
2475
|
+
{
|
|
2476
|
+
id: "refresh",
|
|
2477
|
+
name: copy.refresh,
|
|
2478
|
+
icon: "refresh",
|
|
2479
|
+
message: DataTableMessage.RefreshRequested()
|
|
2480
|
+
}
|
|
2481
|
+
], true, undefined, false, { toolbarIcon: "refresh" }), features.grouping && features.grouping.fields.length > 0 && menu(keyOf("group-by"), copy.groupBy, copy.groupBy, features.grouping.fields.map(({ id, label }) => ({
|
|
2482
|
+
id,
|
|
2483
|
+
name: label,
|
|
2484
|
+
checked: model.grouping.includes(id),
|
|
2485
|
+
message: DataTableMessage.GroupingToggled({ fieldId: id })
|
|
2486
|
+
})), true, undefined, false, { toolbarIcon: "table" }), features.gallery && menu(keyOf("view"), copy.view, copy.view, [
|
|
2487
|
+
{
|
|
2488
|
+
id: "table",
|
|
2489
|
+
name: copy.tableView,
|
|
2490
|
+
icon: "table",
|
|
2491
|
+
checked: !gallery,
|
|
2492
|
+
radio: true,
|
|
2493
|
+
message: DataTableMessage.ViewPicked({ view: "table" })
|
|
2494
|
+
},
|
|
2495
|
+
{
|
|
2496
|
+
id: "gallery",
|
|
2497
|
+
name: copy.galleryView,
|
|
2498
|
+
icon: "gallery",
|
|
2499
|
+
checked: !!gallery,
|
|
2500
|
+
radio: true,
|
|
2501
|
+
message: DataTableMessage.ViewPicked({ view: "gallery" })
|
|
2502
|
+
}
|
|
2503
|
+
], true, undefined, false, { toolbarIcon: gallery ? "gallery" : "table" }), features.export && menu(keyOf("export"), copy.export, copy.export, [
|
|
2504
|
+
...features.export.builtIn === false ? [] : ["csv", "json"].map((format) => ({
|
|
2505
|
+
id: keyOf("built-in", format),
|
|
2506
|
+
name: format.toUpperCase(),
|
|
2507
|
+
icon: format,
|
|
2508
|
+
disabled: blocked || !rows.length,
|
|
2509
|
+
message: DataTableMessage.BuiltInExportRequested({
|
|
2510
|
+
format,
|
|
2511
|
+
locale
|
|
2512
|
+
})
|
|
2513
|
+
})),
|
|
2514
|
+
...(features.export.actions ?? []).map((action) => ({
|
|
2515
|
+
...action,
|
|
2516
|
+
id: keyOf("custom", action.id),
|
|
2517
|
+
message: DataTableMessage.ExportRequested({
|
|
2518
|
+
actionId: action.id
|
|
2519
|
+
})
|
|
2520
|
+
}))
|
|
2521
|
+
], true, undefined, features.export.pending || model.exporting, { toolbarIcon: "export" })))
|
|
2522
|
+
})), (model.exportFailed || features.export?.failed) && h.p.attr("role", "alert").class("text-destructive text-sm").children(copy.exportFailed), gallery ? h.div.class("grid grid-cols-1 gap-3 sm:grid-cols-2 xl:grid-cols-3").children(blocked ? h.p.attr("role", status?.error !== undefined ? "alert" : "status").children(status?.error ?? copy.loading) : !rows.length && !grouping.length ? h.p.attr("role", "status").children(status?.empty ?? copy.empty) : renderGroups(rows, 0, "")) : (() => {
|
|
2523
|
+
const renderTable = (list) => {
|
|
2524
|
+
const table = h.table.class("table-fixed border-separate border-spacing-0 text-start text-sm").style({ width: "100%", minWidth: `${layoutWidth}px` }).attr("aria-busy", status?.loading ? "true" : undefined);
|
|
2525
|
+
return (list ? list.table(table) : table).children(h.caption.class("sr-only").children(props.label), h.thead.class(list ? cn(tableClasses.stickyHeader, tableClasses.stickyHeaderRule) : "[&_th]:border-b").children(h.tr.children(selection && h.th.attr("scope", "col").class(tableClasses.selectionCell).children(h.div.class(tableClasses.selectionCenter).children(check(keyOf("select-all"), copy.selectAllRows, selectedHere > 0 && selectedHere === ids.length, (checked) => DataTableMessage.SelectionRequested({
|
|
2526
|
+
rowIds: ids,
|
|
2527
|
+
checked
|
|
2528
|
+
}), {
|
|
2529
|
+
disabled: blocked || ids.length === 0,
|
|
2530
|
+
indeterminate: selectedHere > 0 && selectedHere < ids.length
|
|
2531
|
+
}))), draggable && h.th.attr("scope", "col").class("w-10"), columns.map((column, index) => {
|
|
2532
|
+
const fields = tableDataColumns([column]);
|
|
2533
|
+
const owns = (id) => id === column.id || fields.some((field) => field.id === id);
|
|
2534
|
+
const active = sort.find(({ id }) => owns(id))?.direction;
|
|
2535
|
+
const filtered = activeFilters.filter(({ id }) => owns(id)).length;
|
|
2536
|
+
const sorting = features.sorting && fields.some(({ sortable }) => sortable !== false);
|
|
2537
|
+
const filtering = features.filtering && fields.some(({ filterable }) => filterable !== false);
|
|
2538
|
+
const hiding = features.columnVisibility && column.hideable !== false;
|
|
2539
|
+
const width = widths[index] ?? tableColumnWidth(column, model.columnSizing);
|
|
2540
|
+
const { min, max } = tableColumnLimits(column);
|
|
2541
|
+
return h.th.key(column.id).class(cn(tableClasses.header, "text-start font-medium")).style({
|
|
2542
|
+
width: `${width}px`
|
|
2543
|
+
}).attrs({
|
|
2544
|
+
scope: "col",
|
|
2545
|
+
"aria-label": column.headerName,
|
|
2546
|
+
"aria-sort": active === "asc" ? "ascending" : active === "desc" ? "descending" : undefined
|
|
2547
|
+
}).children(!sorting && !filtering && !hiding ? h.div.class("truncate px-2 pe-4").children(column.headerName) : menu(keyOf("sort", column.id), column.headerName, column.headerName, [
|
|
2548
|
+
...sorting && column.fields?.length ? tableDataColumns([column]).filter(({ sortable }) => sortable !== false).map((field) => ({
|
|
2549
|
+
id: keyOf("sort", field.id),
|
|
2550
|
+
name: field.headerName,
|
|
2551
|
+
children: ["asc", "desc"].map((direction) => ({
|
|
2552
|
+
id: direction,
|
|
2553
|
+
name: direction === "asc" ? copy.sortAsc : direction === "desc" ? copy.sortDesc : copy.sortDesc,
|
|
2554
|
+
message: DataTableMessage.SortRequested({
|
|
2555
|
+
columnId: field.id,
|
|
2556
|
+
direction
|
|
2557
|
+
})
|
|
2558
|
+
}))
|
|
2559
|
+
})) : sorting ? [
|
|
2560
|
+
{
|
|
2561
|
+
id: "asc",
|
|
2562
|
+
name: copy.sortAsc,
|
|
2563
|
+
icon: "asc",
|
|
2564
|
+
message: DataTableMessage.SortRequested({
|
|
2565
|
+
columnId: column.id,
|
|
2566
|
+
direction: "asc"
|
|
2567
|
+
})
|
|
2568
|
+
},
|
|
2569
|
+
{
|
|
2570
|
+
id: "desc",
|
|
2571
|
+
name: copy.sortDesc,
|
|
2572
|
+
icon: "desc",
|
|
2573
|
+
message: DataTableMessage.SortRequested({
|
|
2574
|
+
columnId: column.id,
|
|
2575
|
+
direction: "desc"
|
|
2576
|
+
})
|
|
2577
|
+
}
|
|
2578
|
+
] : [],
|
|
2579
|
+
...sorting && active ? [
|
|
2580
|
+
{
|
|
2581
|
+
id: "clear-sort",
|
|
2582
|
+
name: copy.sortClear,
|
|
2583
|
+
icon: "clear",
|
|
2584
|
+
message: DataTableMessage.ColumnSortCleared({
|
|
2585
|
+
id: column.id
|
|
2586
|
+
})
|
|
2587
|
+
}
|
|
2588
|
+
] : [],
|
|
2589
|
+
...filtering ? tableDataColumns([column]).filter(({ filterable }) => filterable !== false).map((field, index) => ({
|
|
2590
|
+
id: keyOf("filter", field.id),
|
|
2591
|
+
name: column.fields?.length ? `${copy.filters}: ${field.headerName}` : copy.filters,
|
|
2592
|
+
filterColumnId: field.id,
|
|
2593
|
+
filterEditor: filterPanel,
|
|
2594
|
+
icon: "filter",
|
|
2595
|
+
separatorBefore: sorting && index === 0
|
|
2596
|
+
})) : [],
|
|
2597
|
+
...filtering && filtered ? [
|
|
2598
|
+
{
|
|
2599
|
+
id: "clear-filter",
|
|
2600
|
+
name: copy.filterClear,
|
|
2601
|
+
icon: "clear",
|
|
2602
|
+
message: DataTableMessage.ColumnFiltersCleared({
|
|
2603
|
+
id: column.id
|
|
2604
|
+
})
|
|
2605
|
+
}
|
|
2606
|
+
] : [],
|
|
2607
|
+
...hiding ? [
|
|
2608
|
+
{
|
|
2609
|
+
id: "hide",
|
|
2610
|
+
name: copy.hideColumn,
|
|
2611
|
+
icon: "hide",
|
|
2612
|
+
separatorBefore: sorting || filtering,
|
|
2613
|
+
message: DataTableMessage.ColumnVisibilityChanged({
|
|
2614
|
+
id: column.id,
|
|
2615
|
+
visible: false
|
|
2616
|
+
})
|
|
2617
|
+
}
|
|
2618
|
+
] : []
|
|
2619
|
+
], false, undefined, false, { filtered, sort: active }), column.resizable !== false && h.button.attr("type", "button").attr("role", "separator").attr("aria-orientation", "vertical").attr("aria-valuemin", String(min)).attr("aria-valuemax", String(max)).attr("aria-valuenow", String(width)).attr("aria-label", `${copy.resize}: ${column.headerName}`).class(tableClasses.resizeHandle).on("pointerdown", ({ x, button, pointerId }) => button === 0 ? DataTableMessage.ResizeStarted({
|
|
2620
|
+
id: column.id,
|
|
2621
|
+
x,
|
|
2622
|
+
pointerId
|
|
2623
|
+
}) : undefined, {
|
|
2624
|
+
capturePointer: true,
|
|
2625
|
+
preventDefault: true
|
|
2626
|
+
}).on("pointermove", ({ x, pointerId }) => model.resizing?.id === column.id ? DataTableMessage.ResizeMoved({ x, pointerId }) : undefined).on("pointerup", ({ pointerId }) => DataTableMessage.ResizeEnded({ pointerId })).on("pointercancel", ({ pointerId }) => DataTableMessage.ResizeEnded({ pointerId })).on("dblclick", DataTableMessage.ColumnResizeReset({
|
|
2627
|
+
id: column.id
|
|
2628
|
+
})).on("keydown", ({ key }) => {
|
|
2629
|
+
const delta = tableResizeStep(key);
|
|
2630
|
+
return delta ? DataTableMessage.ColumnResized({
|
|
2631
|
+
id: column.id,
|
|
2632
|
+
delta
|
|
2633
|
+
}) : undefined;
|
|
2634
|
+
}, { preventDefault: true }));
|
|
2635
|
+
}), rowActions && h.th.attr("scope", "col").class("w-10").attr("aria-label", copy.actions))), (list ? list.list(h.tbody) : h.tbody).children(blocked || rows.length === 0 && grouping.length === 0 ? h.tr.children(h.td.attr("colspan", String(span)).class("py-8 text-center").children(status?.error !== undefined ? h.p.attr("role", "alert").class("text-destructive").children(status.error) : h.p.attr("role", "status").children(status?.loading ? copy.loading : status?.empty ?? copy.empty))) : list ? list.items.flatMap((index) => {
|
|
2636
|
+
const row = rows[index];
|
|
2637
|
+
return row ? [
|
|
2638
|
+
list.item({
|
|
2639
|
+
element: renderRow(row, rows, ""),
|
|
2640
|
+
index
|
|
2641
|
+
})
|
|
2642
|
+
] : [];
|
|
2643
|
+
}) : renderGroups(rows, 0, "")));
|
|
2644
|
+
};
|
|
2645
|
+
const viewport = () => h.div.class("@container overflow-auto");
|
|
2646
|
+
if (!virtual)
|
|
2647
|
+
return viewport().children(renderTable());
|
|
2648
|
+
return VirtualList(h, {
|
|
2649
|
+
props: {
|
|
2650
|
+
keys: rows.map(({ id }) => id),
|
|
2651
|
+
count: rows.length,
|
|
2652
|
+
itemSize: virtual.itemSize,
|
|
2653
|
+
measure: true,
|
|
2654
|
+
overscan: virtual.overscan,
|
|
2655
|
+
initialCount: virtual.initialCount
|
|
2656
|
+
},
|
|
2657
|
+
view: (list) => virtual.scroll === "page" ? h.div.children(renderTable(list)) : list.viewport(viewport().style({
|
|
2658
|
+
maxHeight: `${virtual.height}px`
|
|
2659
|
+
})).children(renderTable(list))
|
|
2660
|
+
});
|
|
2661
|
+
})(), paginationVisible && Pagination(h, {
|
|
2662
|
+
props: {
|
|
2663
|
+
locale,
|
|
2664
|
+
page,
|
|
2665
|
+
pageSize,
|
|
2666
|
+
pageSizes,
|
|
2667
|
+
pageCount,
|
|
2668
|
+
totalRows,
|
|
2669
|
+
selectedRows: selectedCount
|
|
2670
|
+
},
|
|
2671
|
+
onEmit: {
|
|
2672
|
+
PageChanged: ({ page }) => DataTableMessage.PageRequested({ page }),
|
|
2673
|
+
PageSizeChanged: ({ pageSize }) => DataTableMessage.PageSizeRequested({ pageSize })
|
|
2674
|
+
}
|
|
2675
|
+
}));
|
|
2676
|
+
}
|
|
2677
|
+
});
|
|
2678
|
+
export {
|
|
2679
|
+
DataTable,
|
|
2680
|
+
DataTableEdit,
|
|
2681
|
+
DataTableEvents
|
|
2682
|
+
};
|