snice 2.1.5 → 2.2.0
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/dist/components/accordion/snice-accordion-item.d.ts +25 -0
- package/dist/components/accordion/snice-accordion-item.js +255 -0
- package/dist/components/accordion/snice-accordion-item.js.map +1 -0
- package/dist/components/accordion/snice-accordion.d.ts +28 -0
- package/dist/components/accordion/snice-accordion.js +206 -0
- package/dist/components/accordion/snice-accordion.js.map +1 -0
- package/dist/components/accordion/snice-accordion.types.d.ts +29 -0
- package/dist/components/alert/snice-alert.d.ts +26 -0
- package/dist/components/alert/snice-alert.js +180 -0
- package/dist/components/alert/snice-alert.js.map +1 -0
- package/{components/alert/snice-alert.types.ts → dist/components/alert/snice-alert.types.d.ts} +8 -9
- package/dist/components/avatar/snice-avatar.d.ts +24 -0
- package/dist/components/avatar/snice-avatar.js +180 -0
- package/dist/components/avatar/snice-avatar.js.map +1 -0
- package/dist/components/avatar/snice-avatar.types.d.ts +12 -0
- package/dist/components/badge/snice-badge.d.ts +25 -0
- package/dist/components/badge/snice-badge.js +169 -0
- package/dist/components/badge/snice-badge.js.map +1 -0
- package/{components/badge/snice-badge.types.ts → dist/components/badge/snice-badge.types.d.ts} +11 -12
- package/dist/components/breadcrumbs/snice-breadcrumbs.d.ts +27 -0
- package/dist/components/breadcrumbs/snice-breadcrumbs.js +214 -0
- package/dist/components/breadcrumbs/snice-breadcrumbs.js.map +1 -0
- package/dist/components/breadcrumbs/snice-breadcrumbs.types.d.ts +23 -0
- package/dist/components/breadcrumbs/snice-crumb.d.ts +9 -0
- package/dist/components/breadcrumbs/snice-crumb.js +63 -0
- package/dist/components/breadcrumbs/snice-crumb.js.map +1 -0
- package/dist/components/button/snice-button.d.ts +32 -0
- package/dist/components/button/snice-button.js +232 -0
- package/dist/components/button/snice-button.js.map +1 -0
- package/dist/components/button/snice-button.types.d.ts +23 -0
- package/dist/components/card/snice-card.d.ts +19 -0
- package/dist/components/card/snice-card.js +136 -0
- package/dist/components/card/snice-card.js.map +1 -0
- package/{components/card/snice-card.types.ts → dist/components/card/snice-card.types.d.ts} +6 -7
- package/dist/components/checkbox/snice-checkbox.d.ts +34 -0
- package/dist/components/checkbox/snice-checkbox.js +286 -0
- package/dist/components/checkbox/snice-checkbox.js.map +1 -0
- package/dist/components/checkbox/snice-checkbox.types.d.ts +20 -0
- package/dist/components/chip/snice-chip.d.ts +28 -0
- package/dist/components/chip/snice-chip.js +199 -0
- package/dist/components/chip/snice-chip.js.map +1 -0
- package/dist/components/chip/snice-chip.types.d.ts +14 -0
- package/dist/components/date-picker/snice-date-picker.d.ts +82 -0
- package/dist/components/date-picker/snice-date-picker.js +847 -0
- package/dist/components/date-picker/snice-date-picker.js.map +1 -0
- package/dist/components/date-picker/snice-date-picker.types.d.ts +71 -0
- package/dist/components/divider/snice-divider.d.ts +17 -0
- package/dist/components/divider/snice-divider.js +122 -0
- package/dist/components/divider/snice-divider.js.map +1 -0
- package/{components/divider/snice-divider.types.ts → dist/components/divider/snice-divider.types.d.ts} +9 -10
- package/dist/components/drawer/snice-drawer.d.ts +37 -0
- package/dist/components/drawer/snice-drawer.js +337 -0
- package/dist/components/drawer/snice-drawer.js.map +1 -0
- package/dist/components/drawer/snice-drawer.types.d.ts +16 -0
- package/dist/components/input/snice-input.d.ts +65 -0
- package/dist/components/input/snice-input.js +567 -0
- package/dist/components/input/snice-input.js.map +1 -0
- package/dist/components/input/snice-input.types.d.ts +53 -0
- package/dist/components/layout/snice-layout-blog.d.ts +4 -0
- package/dist/components/layout/snice-layout-blog.js +67 -0
- package/dist/components/layout/snice-layout-blog.js.map +1 -0
- package/dist/components/layout/snice-layout-card.d.ts +6 -0
- package/dist/components/layout/snice-layout-card.js +64 -0
- package/dist/components/layout/snice-layout-card.js.map +1 -0
- package/dist/components/layout/snice-layout-centered.d.ts +5 -0
- package/dist/components/layout/snice-layout-centered.js +48 -0
- package/dist/components/layout/snice-layout-centered.js.map +1 -0
- package/dist/components/layout/snice-layout-dashboard.d.ts +4 -0
- package/dist/components/layout/snice-layout-dashboard.js +64 -0
- package/dist/components/layout/snice-layout-dashboard.js.map +1 -0
- package/dist/components/layout/snice-layout-fullscreen.d.ts +5 -0
- package/dist/components/layout/snice-layout-fullscreen.js +60 -0
- package/dist/components/layout/snice-layout-fullscreen.js.map +1 -0
- package/dist/components/layout/snice-layout-landing.d.ts +4 -0
- package/dist/components/layout/snice-layout-landing.js +66 -0
- package/dist/components/layout/snice-layout-landing.js.map +1 -0
- package/dist/components/layout/snice-layout-minimal.d.ts +4 -0
- package/dist/components/layout/snice-layout-minimal.js +38 -0
- package/dist/components/layout/snice-layout-minimal.js.map +1 -0
- package/dist/components/layout/snice-layout-sidebar.d.ts +5 -0
- package/dist/components/layout/snice-layout-sidebar.js +74 -0
- package/dist/components/layout/snice-layout-sidebar.js.map +1 -0
- package/dist/components/layout/snice-layout-split.d.ts +6 -0
- package/dist/components/layout/snice-layout-split.js +58 -0
- package/dist/components/layout/snice-layout-split.js.map +1 -0
- package/dist/components/layout/snice-layout.d.ts +4 -0
- package/dist/components/layout/snice-layout.js +54 -0
- package/dist/components/layout/snice-layout.js.map +1 -0
- package/{components/layout/snice-layout.types.ts → dist/components/layout/snice-layout.types.d.ts} +1 -3
- package/dist/components/login/snice-login.d.ts +44 -0
- package/dist/components/login/snice-login.js +382 -0
- package/dist/components/login/snice-login.js.map +1 -0
- package/dist/components/login/snice-login.types.d.ts +26 -0
- package/dist/components/modal/snice-modal.d.ts +32 -0
- package/dist/components/modal/snice-modal.js +280 -0
- package/dist/components/modal/snice-modal.js.map +1 -0
- package/dist/components/modal/snice-modal.types.d.ts +18 -0
- package/dist/components/pagination/snice-pagination.d.ts +26 -0
- package/dist/components/pagination/snice-pagination.js +373 -0
- package/dist/components/pagination/snice-pagination.js.map +1 -0
- package/dist/components/pagination/snice-pagination.types.d.ts +18 -0
- package/dist/components/progress/snice-progress.d.ts +35 -0
- package/dist/components/progress/snice-progress.js +305 -0
- package/dist/components/progress/snice-progress.js.map +1 -0
- package/dist/components/progress/snice-progress.types.d.ts +18 -0
- package/dist/components/radio/snice-radio.d.ts +33 -0
- package/dist/components/radio/snice-radio.js +279 -0
- package/dist/components/radio/snice-radio.js.map +1 -0
- package/dist/components/radio/snice-radio.types.d.ts +19 -0
- package/dist/components/select/snice-option.d.ts +17 -0
- package/dist/components/select/snice-option.js +88 -0
- package/dist/components/select/snice-option.js.map +1 -0
- package/{components/select/snice-option.types.ts → dist/components/select/snice-option.types.d.ts} +8 -8
- package/dist/components/select/snice-select.d.ts +89 -0
- package/dist/components/select/snice-select.js +864 -0
- package/dist/components/select/snice-select.js.map +1 -0
- package/dist/components/select/snice-select.types.d.ts +49 -0
- package/dist/components/skeleton/snice-skeleton.d.ts +16 -0
- package/dist/components/skeleton/snice-skeleton.js +166 -0
- package/dist/components/skeleton/snice-skeleton.js.map +1 -0
- package/{components/skeleton/snice-skeleton.types.ts → dist/components/skeleton/snice-skeleton.types.d.ts} +7 -8
- package/dist/components/snice-cell-C8aBfN72.js +4 -0
- package/dist/components/snice-cell-C8aBfN72.js.map +1 -0
- package/dist/components/switch/snice-switch.d.ts +38 -0
- package/dist/components/switch/snice-switch.js +305 -0
- package/dist/components/switch/snice-switch.js.map +1 -0
- package/dist/components/switch/snice-switch.types.d.ts +21 -0
- package/dist/components/symbols.d.ts +1 -0
- package/dist/components/symbols.js +22 -0
- package/dist/components/symbols.js.map +1 -0
- package/dist/components/table/snice-cell-boolean.d.ts +21 -0
- package/dist/components/table/snice-cell-boolean.js +164 -0
- package/dist/components/table/snice-cell-boolean.js.map +1 -0
- package/dist/components/table/snice-cell-date.d.ts +24 -0
- package/dist/components/table/snice-cell-date.js +253 -0
- package/dist/components/table/snice-cell-date.js.map +1 -0
- package/dist/components/table/snice-cell-duration.d.ts +16 -0
- package/dist/components/table/snice-cell-duration.js +130 -0
- package/dist/components/table/snice-cell-duration.js.map +1 -0
- package/dist/components/table/snice-cell-filesize.d.ts +16 -0
- package/dist/components/table/snice-cell-filesize.js +126 -0
- package/dist/components/table/snice-cell-filesize.js.map +1 -0
- package/dist/components/table/snice-cell-number.d.ts +23 -0
- package/dist/components/table/snice-cell-number.js +215 -0
- package/dist/components/table/snice-cell-number.js.map +1 -0
- package/dist/components/table/snice-cell-progress.d.ts +17 -0
- package/dist/components/table/snice-cell-progress.js +121 -0
- package/dist/components/table/snice-cell-progress.js.map +1 -0
- package/dist/components/table/snice-cell-rating.d.ts +17 -0
- package/dist/components/table/snice-cell-rating.js +120 -0
- package/dist/components/table/snice-cell-rating.js.map +1 -0
- package/dist/components/table/snice-cell-sparkline.d.ts +29 -0
- package/dist/components/table/snice-cell-sparkline.js +306 -0
- package/dist/components/table/snice-cell-sparkline.js.map +1 -0
- package/dist/components/table/snice-cell-text.d.ts +19 -0
- package/dist/components/table/snice-cell-text.js +161 -0
- package/dist/components/table/snice-cell-text.js.map +1 -0
- package/dist/components/table/snice-cell.d.ts +32 -0
- package/dist/components/table/snice-cell.js +458 -0
- package/dist/components/table/snice-cell.js.map +1 -0
- package/dist/components/table/snice-column.d.ts +62 -0
- package/dist/components/table/snice-column.js +506 -0
- package/dist/components/table/snice-column.js.map +1 -0
- package/dist/components/table/snice-header.d.ts +33 -0
- package/dist/components/table/snice-header.js +289 -0
- package/dist/components/table/snice-header.js.map +1 -0
- package/dist/components/table/snice-progress.d.ts +10 -0
- package/dist/components/table/snice-progress.js +105 -0
- package/dist/components/table/snice-progress.js.map +1 -0
- package/dist/components/table/snice-rating.d.ts +9 -0
- package/dist/components/table/snice-rating.js +81 -0
- package/dist/components/table/snice-rating.js.map +1 -0
- package/dist/components/table/snice-row.d.ts +43 -0
- package/dist/components/table/snice-row.js +353 -0
- package/dist/components/table/snice-row.js.map +1 -0
- package/dist/components/table/snice-table.d.ts +69 -0
- package/dist/components/table/snice-table.js +792 -0
- package/dist/components/table/snice-table.js.map +1 -0
- package/dist/components/table/snice-table.types.d.ts +137 -0
- package/dist/components/tabs/snice-tab-panel.d.ts +12 -0
- package/dist/components/tabs/snice-tab-panel.js +87 -0
- package/dist/components/tabs/snice-tab-panel.js.map +1 -0
- package/dist/components/tabs/snice-tab.d.ts +13 -0
- package/dist/components/tabs/snice-tab.js +98 -0
- package/dist/components/tabs/snice-tab.js.map +1 -0
- package/dist/components/tabs/snice-tabs.d.ts +34 -0
- package/dist/components/tabs/snice-tabs.js +375 -0
- package/dist/components/tabs/snice-tabs.js.map +1 -0
- package/dist/components/tabs/snice-tabs.types.d.ts +23 -0
- package/dist/components/toast/snice-toast-container.d.ts +25 -0
- package/dist/components/toast/snice-toast-container.js +252 -0
- package/dist/components/toast/snice-toast-container.js.map +1 -0
- package/dist/components/toast/snice-toast.d.ts +23 -0
- package/dist/components/toast/snice-toast.js +321 -0
- package/dist/components/toast/snice-toast.js.map +1 -0
- package/dist/components/toast/snice-toast.types.d.ts +30 -0
- package/dist/components/tooltip/snice-tooltip.d.ts +50 -0
- package/dist/components/tooltip/snice-tooltip.js +644 -0
- package/dist/components/tooltip/snice-tooltip.js.map +1 -0
- package/dist/components/tooltip/snice-tooltip.types.d.ts +18 -0
- package/dist/components/transitions.d.ts +11 -0
- package/dist/components/transitions.js +72 -0
- package/dist/components/transitions.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.min.js +1 -1
- package/dist/index.iife.js +1 -1
- package/dist/index.iife.min.js +1 -1
- package/dist/symbols.esm.js +1 -1
- package/dist/transitions.esm.js +1 -1
- package/package.json +10 -6
- package/components/accordion/demo.html +0 -403
- package/components/accordion/snice-accordion-item.css +0 -85
- package/components/accordion/snice-accordion-item.ts +0 -226
- package/components/accordion/snice-accordion.css +0 -31
- package/components/accordion/snice-accordion.ts +0 -182
- package/components/accordion/snice-accordion.types.ts +0 -32
- package/components/alert/demo.html +0 -445
- package/components/alert/snice-alert.css +0 -195
- package/components/alert/snice-alert.ts +0 -141
- package/components/avatar/demo.html +0 -598
- package/components/avatar/snice-avatar.css +0 -131
- package/components/avatar/snice-avatar.ts +0 -136
- package/components/avatar/snice-avatar.types.ts +0 -13
- package/components/badge/demo.html +0 -523
- package/components/badge/snice-badge.css +0 -161
- package/components/badge/snice-badge.ts +0 -117
- package/components/breadcrumbs/demo.html +0 -404
- package/components/breadcrumbs/snice-breadcrumbs.css +0 -133
- package/components/breadcrumbs/snice-breadcrumbs.ts +0 -191
- package/components/breadcrumbs/snice-breadcrumbs.types.ts +0 -26
- package/components/breadcrumbs/snice-crumb.ts +0 -26
- package/components/button/demo.html +0 -42
- package/components/button/snice-button.css +0 -230
- package/components/button/snice-button.ts +0 -169
- package/components/button/snice-button.types.ts +0 -25
- package/components/card/demo.html +0 -525
- package/components/card/snice-card.css +0 -140
- package/components/card/snice-card.ts +0 -102
- package/components/checkbox/demo.html +0 -253
- package/components/checkbox/snice-checkbox.css +0 -164
- package/components/checkbox/snice-checkbox.ts +0 -223
- package/components/checkbox/snice-checkbox.types.ts +0 -22
- package/components/chip/demo.html +0 -383
- package/components/chip/snice-chip.css +0 -195
- package/components/chip/snice-chip.ts +0 -139
- package/components/chip/snice-chip.types.ts +0 -15
- package/components/date-picker/README.md +0 -233
- package/components/date-picker/demo.html +0 -191
- package/components/date-picker/snice-date-picker.css +0 -330
- package/components/date-picker/snice-date-picker.ts +0 -777
- package/components/date-picker/snice-date-picker.types.ts +0 -83
- package/components/divider/demo.html +0 -233
- package/components/divider/snice-divider.css +0 -155
- package/components/divider/snice-divider.ts +0 -69
- package/components/drawer/demo.html +0 -328
- package/components/drawer/snice-drawer.css +0 -476
- package/components/drawer/snice-drawer.ts +0 -287
- package/components/drawer/snice-drawer.types.ts +0 -17
- package/components/global.d.ts +0 -14
- package/components/input/demo.html +0 -303
- package/components/input/snice-input.css +0 -257
- package/components/input/snice-input.ts +0 -442
- package/components/input/snice-input.types.ts +0 -59
- package/components/input/test.html +0 -77
- package/components/layout/README.md +0 -260
- package/components/layout/demo.html +0 -538
- package/components/layout/snice-layout-blog.css +0 -129
- package/components/layout/snice-layout-blog.ts +0 -48
- package/components/layout/snice-layout-card.css +0 -104
- package/components/layout/snice-layout-card.ts +0 -35
- package/components/layout/snice-layout-centered.css +0 -51
- package/components/layout/snice-layout-centered.ts +0 -22
- package/components/layout/snice-layout-dashboard.css +0 -98
- package/components/layout/snice-layout-dashboard.ts +0 -45
- package/components/layout/snice-layout-fullscreen.css +0 -72
- package/components/layout/snice-layout-fullscreen.ts +0 -34
- package/components/layout/snice-layout-landing.css +0 -92
- package/components/layout/snice-layout-landing.ts +0 -47
- package/components/layout/snice-layout-minimal.css +0 -16
- package/components/layout/snice-layout-minimal.ts +0 -19
- package/components/layout/snice-layout-sidebar.css +0 -117
- package/components/layout/snice-layout-sidebar.ts +0 -48
- package/components/layout/snice-layout-split.css +0 -103
- package/components/layout/snice-layout-split.ts +0 -29
- package/components/layout/snice-layout.css +0 -72
- package/components/layout/snice-layout.ts +0 -35
- package/components/login/demo-auth-controller.ts +0 -185
- package/components/login/demo.html +0 -470
- package/components/login/snice-login.css +0 -204
- package/components/login/snice-login.ts +0 -326
- package/components/login/snice-login.types.ts +0 -29
- package/components/modal/demo.html +0 -291
- package/components/modal/snice-modal.css +0 -203
- package/components/modal/snice-modal.ts +0 -233
- package/components/modal/snice-modal.types.ts +0 -21
- package/components/pagination/demo.html +0 -395
- package/components/pagination/snice-pagination.ts +0 -333
- package/components/pagination/snice-pagination.types.ts +0 -21
- package/components/progress/demo.html +0 -510
- package/components/progress/snice-progress.css +0 -267
- package/components/progress/snice-progress.ts +0 -247
- package/components/progress/snice-progress.types.ts +0 -19
- package/components/radio/demo.html +0 -287
- package/components/radio/snice-radio.css +0 -171
- package/components/radio/snice-radio.ts +0 -218
- package/components/radio/snice-radio.types.ts +0 -21
- package/components/select/demo.html +0 -511
- package/components/select/snice-option.ts +0 -52
- package/components/select/snice-select.css +0 -392
- package/components/select/snice-select.ts +0 -796
- package/components/select/snice-select.types.ts +0 -55
- package/components/skeleton/demo.html +0 -514
- package/components/skeleton/snice-skeleton.css +0 -109
- package/components/skeleton/snice-skeleton.ts +0 -126
- package/components/switch/demo.html +0 -284
- package/components/switch/snice-switch.css +0 -221
- package/components/switch/snice-switch.ts +0 -229
- package/components/switch/snice-switch.types.ts +0 -23
- package/components/symbols.ts +0 -23
- package/components/table/demo-table-controller.ts +0 -100
- package/components/table/demo.html +0 -480
- package/components/table/snice-cell-boolean.ts +0 -112
- package/components/table/snice-cell-date.ts +0 -210
- package/components/table/snice-cell-duration.ts +0 -91
- package/components/table/snice-cell-filesize.ts +0 -90
- package/components/table/snice-cell-number.ts +0 -165
- package/components/table/snice-cell-progress.ts +0 -83
- package/components/table/snice-cell-rating.ts +0 -82
- package/components/table/snice-cell-sparkline.ts +0 -253
- package/components/table/snice-cell-text.ts +0 -125
- package/components/table/snice-cell.css +0 -296
- package/components/table/snice-cell.ts +0 -473
- package/components/table/snice-column.ts +0 -353
- package/components/table/snice-header.css +0 -243
- package/components/table/snice-header.ts +0 -261
- package/components/table/snice-progress.ts +0 -66
- package/components/table/snice-rating.ts +0 -45
- package/components/table/snice-row.css +0 -255
- package/components/table/snice-row.ts +0 -331
- package/components/table/snice-table.css +0 -241
- package/components/table/snice-table.ts +0 -737
- package/components/table/snice-table.types.ts +0 -158
- package/components/tabs/demo.html +0 -487
- package/components/tabs/snice-tab-panel.css +0 -264
- package/components/tabs/snice-tab-panel.ts +0 -47
- package/components/tabs/snice-tab.css +0 -96
- package/components/tabs/snice-tab.ts +0 -65
- package/components/tabs/snice-tabs.css +0 -189
- package/components/tabs/snice-tabs.ts +0 -332
- package/components/tabs/snice-tabs.types.ts +0 -28
- package/components/theme/theme.css +0 -234
- package/components/toast/demo.html +0 -329
- package/components/toast/snice-toast-container.ts +0 -256
- package/components/toast/snice-toast.css +0 -213
- package/components/toast/snice-toast.ts +0 -276
- package/components/toast/snice-toast.types.ts +0 -35
- package/components/tooltip/demo.html +0 -350
- package/components/tooltip/snice-tooltip-portal.css +0 -79
- package/components/tooltip/snice-tooltip.css +0 -117
- package/components/tooltip/snice-tooltip.ts +0 -612
- package/components/tooltip/snice-tooltip.types.ts +0 -32
- package/components/transitions.ts +0 -94
- package/components/tsconfig.json +0 -18
|
@@ -1,737 +0,0 @@
|
|
|
1
|
-
import { element, on, property, query, request, dispatch, watch } from 'snice';
|
|
2
|
-
import '../input/snice-input';
|
|
3
|
-
import '../select/snice-select';
|
|
4
|
-
import './snice-cell.ts';
|
|
5
|
-
import './snice-cell-text.ts';
|
|
6
|
-
import './snice-cell-number.ts';
|
|
7
|
-
import './snice-cell-date.ts';
|
|
8
|
-
import './snice-cell-boolean.ts';
|
|
9
|
-
import './snice-cell-rating.ts';
|
|
10
|
-
import './snice-cell-progress.ts';
|
|
11
|
-
import './snice-cell-duration.ts';
|
|
12
|
-
import './snice-cell-filesize.ts';
|
|
13
|
-
import './snice-cell-sparkline.ts';
|
|
14
|
-
|
|
15
|
-
@element('snice-table')
|
|
16
|
-
export class SniceTable extends HTMLElement {
|
|
17
|
-
|
|
18
|
-
@property({ type: Boolean, reflect: true, attribute: 'striped' })
|
|
19
|
-
striped = false;
|
|
20
|
-
|
|
21
|
-
@property({ type: Boolean, reflect: true, attribute: 'searchable' })
|
|
22
|
-
searchable = false;
|
|
23
|
-
|
|
24
|
-
@property({ type: Boolean, reflect: true, attribute: 'sortable' })
|
|
25
|
-
sortable = false;
|
|
26
|
-
|
|
27
|
-
@property({ type: Boolean, reflect: true, attribute: 'selectable' })
|
|
28
|
-
selectable = false;
|
|
29
|
-
|
|
30
|
-
@property({ type: Boolean, reflect: true, attribute: 'hoverable' })
|
|
31
|
-
hoverable = true;
|
|
32
|
-
|
|
33
|
-
@property({ type: Boolean, reflect: true, attribute: 'clickable' })
|
|
34
|
-
clickable = false;
|
|
35
|
-
|
|
36
|
-
@property({ type: Array, attribute: 'columns' })
|
|
37
|
-
columns: any[] = [];
|
|
38
|
-
|
|
39
|
-
@property({ type: Array, attribute: 'data' })
|
|
40
|
-
data: any[] = [];
|
|
41
|
-
|
|
42
|
-
@property({ type: Array, attribute: 'current-sort' })
|
|
43
|
-
currentSort: Array<{ column: string, direction: 'asc' | 'desc' }> = [];
|
|
44
|
-
|
|
45
|
-
@property({ type: String, attribute: 'search-text' })
|
|
46
|
-
searchText: string = '';
|
|
47
|
-
|
|
48
|
-
@property({ type: String, attribute: 'selector' })
|
|
49
|
-
selector: string = '';
|
|
50
|
-
|
|
51
|
-
@property({ type: Array, attribute: 'selector-options' })
|
|
52
|
-
selectorOptions: Array<{value: string, label: string}> = [];
|
|
53
|
-
|
|
54
|
-
@property({ type: Boolean, reflect: true, attribute: 'loading' })
|
|
55
|
-
loading: boolean = false;
|
|
56
|
-
|
|
57
|
-
@property({ type: Array, attribute: 'selected-rows' })
|
|
58
|
-
selectedRows: number[] = [];
|
|
59
|
-
|
|
60
|
-
@query('table')
|
|
61
|
-
table!: HTMLTableElement;
|
|
62
|
-
|
|
63
|
-
@query('thead')
|
|
64
|
-
thead!: HTMLTableSectionElement;
|
|
65
|
-
|
|
66
|
-
@query('tbody')
|
|
67
|
-
tbody!: HTMLTableSectionElement;
|
|
68
|
-
|
|
69
|
-
@request('@snice/table/config')
|
|
70
|
-
async *getTableConfig(): any {
|
|
71
|
-
const config = await (yield {});
|
|
72
|
-
this.columns = config.columns || [];
|
|
73
|
-
this.selectorOptions = config.selectorOptions || [];
|
|
74
|
-
this.render();
|
|
75
|
-
return config;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
@request('@snice/table/data')
|
|
79
|
-
async *getTableData(): any {
|
|
80
|
-
this.loading = true;
|
|
81
|
-
this.selectedRows = []; // Clear selections when loading new data
|
|
82
|
-
|
|
83
|
-
try {
|
|
84
|
-
const params = {
|
|
85
|
-
search: this.searchText,
|
|
86
|
-
sort: this.currentSort,
|
|
87
|
-
selector: this.selector
|
|
88
|
-
};
|
|
89
|
-
console.log('Requesting table data with params:', params);
|
|
90
|
-
const response = await (yield params);
|
|
91
|
-
console.log('Received table data response:', response);
|
|
92
|
-
this.data = response.data || [];
|
|
93
|
-
this.loading = false;
|
|
94
|
-
this.render();
|
|
95
|
-
return response;
|
|
96
|
-
} catch (error) {
|
|
97
|
-
console.error('Error loading table data:', error);
|
|
98
|
-
this.data = [];
|
|
99
|
-
this.loading = false;
|
|
100
|
-
this.render();
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
private dataRequestTimeout: any = null;
|
|
105
|
-
|
|
106
|
-
private debouncedDataRequest() {
|
|
107
|
-
// Set loading immediately for instant feedback
|
|
108
|
-
if (!this.loading) {
|
|
109
|
-
this.loading = true;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
if (this.dataRequestTimeout) {
|
|
113
|
-
clearTimeout(this.dataRequestTimeout);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
this.dataRequestTimeout = setTimeout(() => {
|
|
117
|
-
this.getTableData();
|
|
118
|
-
this.dataRequestTimeout = null;
|
|
119
|
-
}, 500);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
css() {
|
|
123
|
-
return /*css*/`
|
|
124
|
-
:host {
|
|
125
|
-
display: block;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
.snice-table {
|
|
129
|
-
border-collapse: collapse;
|
|
130
|
-
width: 100%;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
table {
|
|
134
|
-
width: 100%;
|
|
135
|
-
border-collapse: separate;
|
|
136
|
-
border-spacing: 0;
|
|
137
|
-
border-radius: var(--snice-border-radius-lg);
|
|
138
|
-
overflow: hidden;
|
|
139
|
-
border: 1px solid var(--snice-color-border);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
th, td {
|
|
143
|
-
padding: var(--snice-spacing-sm);
|
|
144
|
-
border: 1px solid var(--snice-color-border);
|
|
145
|
-
text-align: left;
|
|
146
|
-
color: var(--snice-color-text);
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
th {
|
|
150
|
-
background-color: var(--snice-color-background-secondary);
|
|
151
|
-
color: var(--snice-color-text);
|
|
152
|
-
font-weight: var(--snice-font-weight-semibold);
|
|
153
|
-
border-bottom: 2px solid var(--snice-color-border);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
th.sortable {
|
|
157
|
-
cursor: pointer;
|
|
158
|
-
user-select: none;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
th.sortable:hover {
|
|
162
|
-
background-color: var(--snice-color-background-tertiary);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
/* Row styling */
|
|
166
|
-
:host([striped]) tbody tr:nth-child(even) {
|
|
167
|
-
background-color: var(--snice-color-background-secondary);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
:host([hoverable]) tbody tr:hover {
|
|
171
|
-
background-color: var(--snice-color-background-tertiary);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
:host([clickable]) tbody tr {
|
|
175
|
-
cursor: pointer;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
:host([selectable]) tbody tr {
|
|
179
|
-
cursor: pointer;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
tbody tr[data-selected="true"] {
|
|
183
|
-
background-color: var(--snice-color-background-tertiary);
|
|
184
|
-
border-left: 3px solid var(--snice-color-primary);
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
tbody tr[data-selected="true"]:hover {
|
|
188
|
-
background-color: var(--snice-color-background-tertiary);
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
[part="header"] {
|
|
192
|
-
background-color: var(--snice-color-background);
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
[part="body"] {
|
|
196
|
-
background-color: var(--snice-table-body-bg, --snice-color-background);
|
|
197
|
-
display: block;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
.table-controls {
|
|
201
|
-
display: flex;
|
|
202
|
-
gap: var(--snice-spacing-md);
|
|
203
|
-
align-items: center;
|
|
204
|
-
flex-wrap: wrap;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
:host(:not([searchable])) .search-input {
|
|
208
|
-
display: none;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
:host(.selector-options-empty) .selector-input {
|
|
212
|
-
display: none;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
.search-input {
|
|
216
|
-
min-width: 200px;
|
|
217
|
-
flex: 1;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
.selector-input {
|
|
221
|
-
min-width: 150px;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
/* Sort indicators */
|
|
225
|
-
.sort-header {
|
|
226
|
-
display: flex;
|
|
227
|
-
align-items: center;
|
|
228
|
-
gap: var(--snice-spacing-xs);
|
|
229
|
-
justify-content: space-between;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
.sort-indicator {
|
|
234
|
-
display: flex;
|
|
235
|
-
flex-direction: column;
|
|
236
|
-
font-size: 0.7em;
|
|
237
|
-
line-height: 1;
|
|
238
|
-
opacity: 0.3;
|
|
239
|
-
transition: opacity var(--snice-transition-fast);
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
.sort-indicator.active {
|
|
243
|
-
opacity: 1;
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
.sort-order {
|
|
247
|
-
font-size: 0.6em;
|
|
248
|
-
background: var(--snice-color-primary);
|
|
249
|
-
color: var(--snice-color-text-inverse);
|
|
250
|
-
border-radius: var(--snice-border-radius-sm);
|
|
251
|
-
padding: 1px 3px;
|
|
252
|
-
min-width: 12px;
|
|
253
|
-
text-align: center;
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
/* Loading fade */
|
|
257
|
-
tbody {
|
|
258
|
-
transition: opacity var(--snice-transition-normal);
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
:host([loading]) tbody {
|
|
262
|
-
opacity: 0.5;
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
.no-data {
|
|
266
|
-
text-align: center;
|
|
267
|
-
padding: var(--snice-spacing-lg);
|
|
268
|
-
color: var(--snice-color-text-secondary);
|
|
269
|
-
}
|
|
270
|
-
`;
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
html() {
|
|
274
|
-
return /*html*/`
|
|
275
|
-
<div class="snice-table">
|
|
276
|
-
${this.renderControls()}
|
|
277
|
-
<table>
|
|
278
|
-
<thead></thead>
|
|
279
|
-
<tbody></tbody>
|
|
280
|
-
</table>
|
|
281
|
-
</div>
|
|
282
|
-
`;
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
renderControls() {
|
|
286
|
-
return /*html*/`
|
|
287
|
-
<div class="table-controls" part="controls">
|
|
288
|
-
<snice-input
|
|
289
|
-
class="search-input"
|
|
290
|
-
type="search"
|
|
291
|
-
placeholder="Search..."
|
|
292
|
-
value="${this.searchText}"
|
|
293
|
-
size="medium"
|
|
294
|
-
></snice-input>
|
|
295
|
-
<snice-select
|
|
296
|
-
class="selector-input"
|
|
297
|
-
multiple
|
|
298
|
-
searchable
|
|
299
|
-
clearable
|
|
300
|
-
placeholder="Filter..."
|
|
301
|
-
size="medium"
|
|
302
|
-
>
|
|
303
|
-
${this.selectorOptions.map(opt =>
|
|
304
|
-
`<snice-option value="${opt.value}">${opt.label}</snice-option>`
|
|
305
|
-
).join('')}
|
|
306
|
-
</snice-select>
|
|
307
|
-
</div>
|
|
308
|
-
`;
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
render() {
|
|
312
|
-
console.log('render() called');
|
|
313
|
-
this.renderHeader();
|
|
314
|
-
this.renderBody();
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
@watch('selector-options')
|
|
318
|
-
handleSelectorOptionsChange() {
|
|
319
|
-
// Update CSS class to show/hide selector
|
|
320
|
-
if (this.selectorOptions.length === 0) {
|
|
321
|
-
this.classList.add('selector-options-empty');
|
|
322
|
-
} else {
|
|
323
|
-
this.classList.remove('selector-options-empty');
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
@watch('sortable')
|
|
328
|
-
handleSortableChange() {
|
|
329
|
-
this.renderHeader(); // Re-render header to show/hide sort indicators
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
@watch('selectable')
|
|
333
|
-
handleSelectableChange() {
|
|
334
|
-
this.render(); // Re-render both header and body for checkbox columns
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
@watch('columns')
|
|
338
|
-
handleColumnsChange() {
|
|
339
|
-
this.renderHeader();
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
@watch('data', 'loading')
|
|
343
|
-
handleDataChange() {
|
|
344
|
-
this.renderBody();
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
@watch('selected-rows')
|
|
348
|
-
handleSelectedRowsChange() {
|
|
349
|
-
this.updateRowSelectionState();
|
|
350
|
-
this.updateSelectAllState();
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
@watch('current-sort')
|
|
354
|
-
handleSortChange() {
|
|
355
|
-
this.renderHeader();
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
renderHeader() {
|
|
359
|
-
if (!this.thead) return;
|
|
360
|
-
|
|
361
|
-
const headerRow = document.createElement('tr');
|
|
362
|
-
|
|
363
|
-
if (this.selectable) {
|
|
364
|
-
const selectCell = document.createElement('th');
|
|
365
|
-
const allSelected = this.selectedRows.length === this.data.length && this.data.length > 0;
|
|
366
|
-
const someSelected = this.selectedRows.length > 0 && this.selectedRows.length < this.data.length;
|
|
367
|
-
selectCell.innerHTML = `<input type="checkbox" class="select-all" ${allSelected ? 'checked' : ''} />`;
|
|
368
|
-
headerRow.appendChild(selectCell);
|
|
369
|
-
|
|
370
|
-
// Set indeterminate after insertion
|
|
371
|
-
setTimeout(() => {
|
|
372
|
-
const checkbox = selectCell.querySelector('.select-all') as HTMLInputElement;
|
|
373
|
-
if (checkbox) {
|
|
374
|
-
checkbox.indeterminate = someSelected;
|
|
375
|
-
}
|
|
376
|
-
}, 0);
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
this.columns.forEach(column => {
|
|
380
|
-
const th = document.createElement('th');
|
|
381
|
-
th.setAttribute('data-key', column.key);
|
|
382
|
-
|
|
383
|
-
if (this.sortable && column.sortable !== false) {
|
|
384
|
-
th.classList.add('sortable');
|
|
385
|
-
th.setAttribute('role', 'button');
|
|
386
|
-
th.innerHTML = this.renderSortableHeader(column);
|
|
387
|
-
} else {
|
|
388
|
-
th.textContent = column.label;
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
headerRow.appendChild(th);
|
|
392
|
-
});
|
|
393
|
-
|
|
394
|
-
this.thead.innerHTML = '';
|
|
395
|
-
this.thead.appendChild(headerRow);
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
renderSortableHeader(column: any): string {
|
|
399
|
-
const sortItem = this.currentSort.find(s => s.column === column.key);
|
|
400
|
-
const sortIndex = this.currentSort.findIndex(s => s.column === column.key);
|
|
401
|
-
const isActive = !!sortItem;
|
|
402
|
-
|
|
403
|
-
let indicator = '▲▼'; // Default unsorted state
|
|
404
|
-
let orderNumber = '';
|
|
405
|
-
|
|
406
|
-
if (sortItem) {
|
|
407
|
-
if (sortItem.direction === 'asc') {
|
|
408
|
-
indicator = '▲';
|
|
409
|
-
} else if (sortItem.direction === 'desc') {
|
|
410
|
-
indicator = '▼';
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
if (this.currentSort.length > 1) {
|
|
414
|
-
orderNumber = `<span class="sort-order">${sortIndex + 1}</span>`;
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
return `
|
|
419
|
-
<div class="sort-header">
|
|
420
|
-
<span>${column.label}</span>
|
|
421
|
-
<div class="sort-indicator ${isActive ? 'active' : ''}">
|
|
422
|
-
${indicator}
|
|
423
|
-
${orderNumber}
|
|
424
|
-
</div>
|
|
425
|
-
</div>
|
|
426
|
-
`;
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
renderBody() {
|
|
431
|
-
if (!this.tbody) return;
|
|
432
|
-
|
|
433
|
-
console.log('renderBody called with data:', this.data.length, 'columns:', this.columns.length, 'loading:', this.loading);
|
|
434
|
-
|
|
435
|
-
this.tbody.innerHTML = '';
|
|
436
|
-
|
|
437
|
-
if (this.data.length === 0 && this.columns.length > 0) {
|
|
438
|
-
if (this.loading) {
|
|
439
|
-
// Show loading spinner
|
|
440
|
-
const tr = document.createElement('tr');
|
|
441
|
-
const td = document.createElement('td');
|
|
442
|
-
const colSpan = this.columns.length + (this.selectable ? 1 : 0);
|
|
443
|
-
td.colSpan = colSpan;
|
|
444
|
-
td.className = 'no-data';
|
|
445
|
-
td.innerHTML = '<snice-progress variant="circular" indeterminate size="small"></snice-progress>';
|
|
446
|
-
tr.appendChild(td);
|
|
447
|
-
this.tbody.appendChild(tr);
|
|
448
|
-
return;
|
|
449
|
-
} else {
|
|
450
|
-
// Show "No Data" message
|
|
451
|
-
const tr = document.createElement('tr');
|
|
452
|
-
const td = document.createElement('td');
|
|
453
|
-
const colSpan = this.columns.length + (this.selectable ? 1 : 0);
|
|
454
|
-
td.colSpan = colSpan;
|
|
455
|
-
td.className = 'no-data';
|
|
456
|
-
td.textContent = 'No Data';
|
|
457
|
-
tr.appendChild(td);
|
|
458
|
-
this.tbody.appendChild(tr);
|
|
459
|
-
return;
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
this.data.forEach((rowData, index) => {
|
|
464
|
-
const tr = document.createElement('tr');
|
|
465
|
-
tr.setAttribute('data-index', String(index));
|
|
466
|
-
|
|
467
|
-
// Set row selection state
|
|
468
|
-
const isSelected = this.selectedRows.includes(index);
|
|
469
|
-
tr.setAttribute('data-selected', String(isSelected));
|
|
470
|
-
|
|
471
|
-
if (this.selectable) {
|
|
472
|
-
const selectCell = document.createElement('td');
|
|
473
|
-
selectCell.innerHTML = `<input type="checkbox" class="row-select" ${isSelected ? 'checked' : ''} data-row-index="${index}" />`;
|
|
474
|
-
tr.appendChild(selectCell);
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
this.columns.forEach(column => {
|
|
478
|
-
const td = document.createElement('td');
|
|
479
|
-
const value = rowData[column.key];
|
|
480
|
-
|
|
481
|
-
// Create cell component as HTML string
|
|
482
|
-
const cellTagName = this.getCellTagName(column.type);
|
|
483
|
-
const attributes = this.getCellAttributes(column, value);
|
|
484
|
-
td.innerHTML = `<${cellTagName} ${attributes}></${cellTagName}>`;
|
|
485
|
-
|
|
486
|
-
tr.appendChild(td);
|
|
487
|
-
});
|
|
488
|
-
|
|
489
|
-
this.tbody.appendChild(tr);
|
|
490
|
-
});
|
|
491
|
-
}
|
|
492
|
-
|
|
493
|
-
getCellAttributes(column: any, value: any): string {
|
|
494
|
-
const attributes = [
|
|
495
|
-
`type="${column.type}"`,
|
|
496
|
-
`align="${column.align || 'left'}"`,
|
|
497
|
-
`value="${String(value || '').replace(/"/g, '"')}"`,
|
|
498
|
-
`in-table="true"`
|
|
499
|
-
];
|
|
500
|
-
|
|
501
|
-
// Add type-specific attributes
|
|
502
|
-
if (column.type === 'number' || column.type === 'currency') {
|
|
503
|
-
if (column.decimals !== undefined) attributes.push(`decimals="${column.decimals}"`);
|
|
504
|
-
if (column.thousandsSeparator) attributes.push(`thousands-separator="true"`);
|
|
505
|
-
if (column.prefix) attributes.push(`prefix="${column.prefix}"`);
|
|
506
|
-
if (column.suffix) attributes.push(`suffix="${column.suffix}"`);
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
if (column.type === 'date') {
|
|
510
|
-
if (column.dateFormat) attributes.push(`date-format="${column.dateFormat}"`);
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
if (column.type === 'boolean') {
|
|
514
|
-
if (column.useSymbols) attributes.push(`use-symbols="true"`);
|
|
515
|
-
if (column.trueSymbol) attributes.push(`true-symbol="${column.trueSymbol}"`);
|
|
516
|
-
if (column.falseSymbol) attributes.push(`false-symbol="${column.falseSymbol}"`);
|
|
517
|
-
if (column.trueValue) attributes.push(`true-value="${column.trueValue}"`);
|
|
518
|
-
if (column.falseValue) attributes.push(`false-value="${column.falseValue}"`);
|
|
519
|
-
}
|
|
520
|
-
|
|
521
|
-
return attributes.join(' ');
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
getCellTagName(type: string): string {
|
|
525
|
-
switch (type) {
|
|
526
|
-
case 'text':
|
|
527
|
-
return 'snice-cell-text';
|
|
528
|
-
case 'number':
|
|
529
|
-
case 'currency':
|
|
530
|
-
return 'snice-cell-number';
|
|
531
|
-
case 'date':
|
|
532
|
-
return 'snice-cell-date';
|
|
533
|
-
case 'boolean':
|
|
534
|
-
return 'snice-cell-boolean';
|
|
535
|
-
case 'rating':
|
|
536
|
-
return 'snice-cell-rating';
|
|
537
|
-
case 'progress':
|
|
538
|
-
return 'snice-cell-progress';
|
|
539
|
-
case 'duration':
|
|
540
|
-
return 'snice-cell-duration';
|
|
541
|
-
case 'filesize':
|
|
542
|
-
return 'snice-cell-filesize';
|
|
543
|
-
case 'sparkline':
|
|
544
|
-
return 'snice-cell-sparkline';
|
|
545
|
-
default:
|
|
546
|
-
return 'snice-cell';
|
|
547
|
-
}
|
|
548
|
-
}
|
|
549
|
-
|
|
550
|
-
@on('click', 'th.sortable')
|
|
551
|
-
handleSort(e: MouseEvent) {
|
|
552
|
-
const th = (e.target as HTMLElement).closest('th.sortable');
|
|
553
|
-
if (!th) return;
|
|
554
|
-
|
|
555
|
-
const columnKey = th.getAttribute('data-key');
|
|
556
|
-
if (columnKey) {
|
|
557
|
-
console.log('Sorting column:', columnKey);
|
|
558
|
-
this.toggleSort(columnKey, true); // Always multi-sort
|
|
559
|
-
}
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
@on('change', '.row-select')
|
|
564
|
-
handleRowSelect(e: Event) {
|
|
565
|
-
const checkbox = e.target as HTMLInputElement;
|
|
566
|
-
const rowIndex = parseInt(checkbox.getAttribute('data-row-index') || '0');
|
|
567
|
-
|
|
568
|
-
if (checkbox.checked) {
|
|
569
|
-
if (!this.selectedRows.includes(rowIndex)) {
|
|
570
|
-
this.selectedRows = [...this.selectedRows, rowIndex];
|
|
571
|
-
}
|
|
572
|
-
} else {
|
|
573
|
-
this.selectedRows = this.selectedRows.filter(i => i !== rowIndex);
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
this.updateRowSelectionState();
|
|
577
|
-
this.updateSelectAllState();
|
|
578
|
-
this.dispatchRowSelectionChanged(rowIndex, checkbox.checked);
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
@on('change', '.select-all')
|
|
582
|
-
handleSelectAll(e: Event) {
|
|
583
|
-
const checkbox = e.target as HTMLInputElement;
|
|
584
|
-
|
|
585
|
-
if (checkbox.checked) {
|
|
586
|
-
this.selectedRows = this.data.map((_, index) => index);
|
|
587
|
-
} else {
|
|
588
|
-
this.selectedRows = [];
|
|
589
|
-
}
|
|
590
|
-
|
|
591
|
-
this.updateRowSelectionState();
|
|
592
|
-
this.dispatchSelectAllChanged(checkbox.checked);
|
|
593
|
-
}
|
|
594
|
-
|
|
595
|
-
@on('click', 'tbody tr')
|
|
596
|
-
handleRowClick(e: Event) {
|
|
597
|
-
const tr = (e.target as HTMLElement).closest('tr');
|
|
598
|
-
if (!tr) return;
|
|
599
|
-
|
|
600
|
-
const target = e.target as HTMLElement;
|
|
601
|
-
|
|
602
|
-
// Don't trigger if clicking on checkbox or other interactive elements
|
|
603
|
-
if (target.matches('input[type="checkbox"], button, a, .interactive')) {
|
|
604
|
-
return;
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
const rowIndex = parseInt(tr.getAttribute('data-index') || '0');
|
|
608
|
-
const rowData = this.data[rowIndex];
|
|
609
|
-
|
|
610
|
-
// Handle row selection if selectable
|
|
611
|
-
if (this.selectable) {
|
|
612
|
-
const isCurrentlySelected = this.selectedRows.includes(rowIndex);
|
|
613
|
-
|
|
614
|
-
if (isCurrentlySelected) {
|
|
615
|
-
this.selectedRows = this.selectedRows.filter(i => i !== rowIndex);
|
|
616
|
-
} else {
|
|
617
|
-
this.selectedRows = [...this.selectedRows, rowIndex];
|
|
618
|
-
}
|
|
619
|
-
|
|
620
|
-
this.updateRowSelectionState();
|
|
621
|
-
this.updateSelectAllState();
|
|
622
|
-
this.dispatchRowSelectionChanged(rowIndex, !isCurrentlySelected);
|
|
623
|
-
}
|
|
624
|
-
|
|
625
|
-
// Handle clickable row event
|
|
626
|
-
if (this.clickable) {
|
|
627
|
-
this.dispatchEvent(new CustomEvent('row-clicked', {
|
|
628
|
-
detail: { rowData, rowIndex }
|
|
629
|
-
}));
|
|
630
|
-
}
|
|
631
|
-
}
|
|
632
|
-
|
|
633
|
-
@on('@snice/controller-attached')
|
|
634
|
-
onAttached() {
|
|
635
|
-
console.log('Controller attached, loading config and data...');
|
|
636
|
-
this.getTableConfig();
|
|
637
|
-
this.getTableData();
|
|
638
|
-
}
|
|
639
|
-
|
|
640
|
-
@on('input', '.search-input', { debounce: 500 })
|
|
641
|
-
handleSearchChange(e: Event) {
|
|
642
|
-
const input = e.target as HTMLInputElement;
|
|
643
|
-
this.searchText = input.value;
|
|
644
|
-
this.debouncedDataRequest();
|
|
645
|
-
}
|
|
646
|
-
|
|
647
|
-
@on('@snice/select/change', '.selector-input', { debounce: 150 })
|
|
648
|
-
handleSelectorChange(e: CustomEvent) {
|
|
649
|
-
this.selector = Array.isArray(e.detail.value) ? e.detail.value.join(',') : e.detail.value;
|
|
650
|
-
this.debouncedDataRequest();
|
|
651
|
-
}
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
updateRowSelectionState() {
|
|
655
|
-
if (!this.tbody) return;
|
|
656
|
-
|
|
657
|
-
const rows = this.tbody.querySelectorAll('tr');
|
|
658
|
-
rows.forEach((row, index) => {
|
|
659
|
-
const isSelected = this.selectedRows.includes(index);
|
|
660
|
-
row.setAttribute('data-selected', String(isSelected));
|
|
661
|
-
|
|
662
|
-
const checkbox = row.querySelector('.row-select') as HTMLInputElement;
|
|
663
|
-
if (checkbox) {
|
|
664
|
-
checkbox.checked = isSelected;
|
|
665
|
-
}
|
|
666
|
-
});
|
|
667
|
-
}
|
|
668
|
-
|
|
669
|
-
updateSelectAllState() {
|
|
670
|
-
const selectAllCheckbox = this.thead?.querySelector('.select-all') as HTMLInputElement;
|
|
671
|
-
if (!selectAllCheckbox) return;
|
|
672
|
-
|
|
673
|
-
const allSelected = this.selectedRows.length === this.data.length;
|
|
674
|
-
const someSelected = this.selectedRows.length > 0 && this.selectedRows.length < this.data.length;
|
|
675
|
-
|
|
676
|
-
selectAllCheckbox.checked = allSelected;
|
|
677
|
-
selectAllCheckbox.indeterminate = someSelected;
|
|
678
|
-
}
|
|
679
|
-
|
|
680
|
-
toggleSort(columnKey: string, multiSort: boolean = false) {
|
|
681
|
-
console.log('toggleSort called:', { columnKey, multiSort, currentSort: this.currentSort });
|
|
682
|
-
|
|
683
|
-
if (!multiSort) {
|
|
684
|
-
// Single column sort - clear all other sorts
|
|
685
|
-
const existingSort = this.currentSort.find(s => s.column === columnKey);
|
|
686
|
-
|
|
687
|
-
if (!existingSort) {
|
|
688
|
-
this.currentSort = [{ column: columnKey, direction: 'asc' }];
|
|
689
|
-
} else if (existingSort.direction === 'asc') {
|
|
690
|
-
this.currentSort = [{ column: columnKey, direction: 'desc' }];
|
|
691
|
-
} else {
|
|
692
|
-
this.currentSort = [];
|
|
693
|
-
}
|
|
694
|
-
} else {
|
|
695
|
-
// Multi column sort - modify existing or add new
|
|
696
|
-
const existingSortIndex = this.currentSort.findIndex(s => s.column === columnKey);
|
|
697
|
-
|
|
698
|
-
if (existingSortIndex === -1) {
|
|
699
|
-
// Add new sort
|
|
700
|
-
this.currentSort = [...this.currentSort, { column: columnKey, direction: 'asc' }];
|
|
701
|
-
} else {
|
|
702
|
-
const existingSort = this.currentSort[existingSortIndex];
|
|
703
|
-
if (existingSort.direction === 'asc') {
|
|
704
|
-
// Change to desc - create new array to trigger reactivity
|
|
705
|
-
this.currentSort = this.currentSort.map((sort, index) =>
|
|
706
|
-
index === existingSortIndex ? { ...sort, direction: 'desc' as const } : sort
|
|
707
|
-
);
|
|
708
|
-
} else {
|
|
709
|
-
// Remove this sort
|
|
710
|
-
this.currentSort = this.currentSort.filter(s => s.column !== columnKey);
|
|
711
|
-
}
|
|
712
|
-
}
|
|
713
|
-
}
|
|
714
|
-
|
|
715
|
-
console.log('New sort state:', this.currentSort);
|
|
716
|
-
this.renderHeader(); // Update sort indicators immediately
|
|
717
|
-
this.debouncedDataRequest(); // Show loading immediately, debounce the actual request
|
|
718
|
-
}
|
|
719
|
-
|
|
720
|
-
@dispatch('@snice/table/row-selection-changed', { bubbles: true, composed: true })
|
|
721
|
-
private dispatchRowSelectionChanged(rowIndex: number, selected: boolean) {
|
|
722
|
-
return {
|
|
723
|
-
selectedRows: this.selectedRows,
|
|
724
|
-
rowIndex,
|
|
725
|
-
selected
|
|
726
|
-
};
|
|
727
|
-
}
|
|
728
|
-
|
|
729
|
-
@dispatch('@snice/table/select-all-changed', { bubbles: true, composed: true })
|
|
730
|
-
private dispatchSelectAllChanged(allSelected: boolean) {
|
|
731
|
-
return {
|
|
732
|
-
selectedRows: this.selectedRows,
|
|
733
|
-
allSelected
|
|
734
|
-
};
|
|
735
|
-
}
|
|
736
|
-
|
|
737
|
-
}
|