snice 2.1.4 → 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 +16 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.cjs.min.map +1 -1
- package/dist/index.esm.js +16 -20
- package/dist/index.esm.js.map +1 -1
- package/dist/index.esm.min.js +3 -3
- package/dist/index.esm.min.js.map +1 -1
- package/dist/index.iife.js +16 -20
- package/dist/index.iife.js.map +1 -1
- package/dist/index.iife.min.js +3 -3
- package/dist/index.iife.min.js.map +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,210 +0,0 @@
|
|
|
1
|
-
import { element, property, watch, ready, query } from 'snice';
|
|
2
|
-
import css from './snice-cell.css?inline';
|
|
3
|
-
import type { DateFormat, SniceCellElement, ColumnType, ColumnAlign, ColumnDefinition } from './snice-table.types';
|
|
4
|
-
|
|
5
|
-
@element('snice-cell-date')
|
|
6
|
-
export class SniceCellDate extends HTMLElement implements SniceCellElement {
|
|
7
|
-
@property({ reflect: true })
|
|
8
|
-
align: ColumnAlign = 'left';
|
|
9
|
-
|
|
10
|
-
@property({ reflect: true })
|
|
11
|
-
type: ColumnType = 'date';
|
|
12
|
-
|
|
13
|
-
@property({ reflect: true })
|
|
14
|
-
value: any = '';
|
|
15
|
-
|
|
16
|
-
@property({ type: Object })
|
|
17
|
-
column: ColumnDefinition = {
|
|
18
|
-
key: '',
|
|
19
|
-
label: '',
|
|
20
|
-
type: 'date',
|
|
21
|
-
align: 'left'
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
@property({ type: Object })
|
|
25
|
-
rowData: any = null;
|
|
26
|
-
|
|
27
|
-
@query('.cell-content')
|
|
28
|
-
contentElement?: HTMLElement;
|
|
29
|
-
@property({ reflect: true, attribute: 'date-format' })
|
|
30
|
-
dateFormat: 'short' | 'medium' | 'long' | 'full' | 'custom' = 'short';
|
|
31
|
-
|
|
32
|
-
@property({ reflect: true, attribute: 'custom-format' })
|
|
33
|
-
customFormat?: string;
|
|
34
|
-
|
|
35
|
-
@property({ reflect: true })
|
|
36
|
-
locale: string = 'en-US';
|
|
37
|
-
|
|
38
|
-
@property({ type: Boolean, reflect: true, attribute: 'relative-time' })
|
|
39
|
-
relativeTime: boolean = false;
|
|
40
|
-
|
|
41
|
-
@property({ type: Boolean, reflect: true, attribute: 'show-time' })
|
|
42
|
-
showTime: boolean = false;
|
|
43
|
-
|
|
44
|
-
html() {
|
|
45
|
-
const formattedValue = this.formatDateValue();
|
|
46
|
-
const styles = this.getDateStyles();
|
|
47
|
-
|
|
48
|
-
return `
|
|
49
|
-
<div class="cell-content cell-content--date" part="content" style="${styles}">
|
|
50
|
-
${formattedValue}
|
|
51
|
-
</div>
|
|
52
|
-
`;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
css() {
|
|
56
|
-
return css;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
@ready()
|
|
60
|
-
init() {
|
|
61
|
-
this.applyAlignment();
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
private applyAlignment() {
|
|
65
|
-
this.style.textAlign = this.align;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
@watch('align')
|
|
69
|
-
updateAlignment() {
|
|
70
|
-
this.applyAlignment();
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
@watch('value', 'column')
|
|
74
|
-
updateContent() {
|
|
75
|
-
if (this.contentElement) {
|
|
76
|
-
const formattedValue = this.formatDateValue();
|
|
77
|
-
const styles = this.getDateStyles();
|
|
78
|
-
this.contentElement.innerHTML = formattedValue;
|
|
79
|
-
this.contentElement.setAttribute('style', styles);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
private formatDateValue(): string {
|
|
84
|
-
if (this.value === null || this.value === undefined || this.value === '') {
|
|
85
|
-
return '';
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// Use custom formatter if provided
|
|
89
|
-
if (this.column.formatter) {
|
|
90
|
-
return this.column.formatter(this.value, this.rowData);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
const date = new Date(this.value);
|
|
94
|
-
|
|
95
|
-
if (isNaN(date.getTime())) {
|
|
96
|
-
return String(this.value);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
// Show relative time if enabled
|
|
100
|
-
if (this.relativeTime) {
|
|
101
|
-
return this.formatRelativeTime(date);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// Use column date format or component properties
|
|
105
|
-
const format: DateFormat = this.column.dateFormat || {
|
|
106
|
-
format: this.dateFormat,
|
|
107
|
-
customFormat: this.customFormat,
|
|
108
|
-
locale: this.locale
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
// Handle custom format
|
|
112
|
-
if (format.customFormat || this.customFormat) {
|
|
113
|
-
return this.formatCustomDate(date, format.customFormat || this.customFormat!);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
// Use Intl.DateTimeFormat
|
|
117
|
-
const options: Intl.DateTimeFormatOptions = {};
|
|
118
|
-
const formatType = format.format ?? this.dateFormat;
|
|
119
|
-
|
|
120
|
-
switch (formatType) {
|
|
121
|
-
case 'short':
|
|
122
|
-
options.dateStyle = 'short';
|
|
123
|
-
break;
|
|
124
|
-
case 'medium':
|
|
125
|
-
options.dateStyle = 'medium';
|
|
126
|
-
break;
|
|
127
|
-
case 'long':
|
|
128
|
-
options.dateStyle = 'long';
|
|
129
|
-
break;
|
|
130
|
-
case 'full':
|
|
131
|
-
options.dateStyle = 'full';
|
|
132
|
-
break;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
// Add time if requested
|
|
136
|
-
if (this.showTime) {
|
|
137
|
-
options.timeStyle = 'short';
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
const locale = format.locale ?? this.locale;
|
|
141
|
-
return new Intl.DateTimeFormat(locale, options).format(date);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
private formatCustomDate(date: Date, format: string): string {
|
|
145
|
-
const tokens: Record<string, string> = {
|
|
146
|
-
'YYYY': date.getFullYear().toString(),
|
|
147
|
-
'YY': date.getFullYear().toString().slice(-2),
|
|
148
|
-
'MM': (date.getMonth() + 1).toString().padStart(2, '0'),
|
|
149
|
-
'M': (date.getMonth() + 1).toString(),
|
|
150
|
-
'DD': date.getDate().toString().padStart(2, '0'),
|
|
151
|
-
'D': date.getDate().toString(),
|
|
152
|
-
'HH': date.getHours().toString().padStart(2, '0'),
|
|
153
|
-
'H': date.getHours().toString(),
|
|
154
|
-
'mm': date.getMinutes().toString().padStart(2, '0'),
|
|
155
|
-
'm': date.getMinutes().toString(),
|
|
156
|
-
'ss': date.getSeconds().toString().padStart(2, '0'),
|
|
157
|
-
's': date.getSeconds().toString()
|
|
158
|
-
};
|
|
159
|
-
|
|
160
|
-
let formatted = format;
|
|
161
|
-
for (const [token, value] of Object.entries(tokens)) {
|
|
162
|
-
formatted = formatted.replace(new RegExp(token, 'g'), value);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
return formatted;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
private formatRelativeTime(date: Date): string {
|
|
169
|
-
const now = new Date();
|
|
170
|
-
const diffMs = now.getTime() - date.getTime();
|
|
171
|
-
const diffSecs = Math.floor(diffMs / 1000);
|
|
172
|
-
const diffMins = Math.floor(diffSecs / 60);
|
|
173
|
-
const diffHours = Math.floor(diffMins / 60);
|
|
174
|
-
const diffDays = Math.floor(diffHours / 24);
|
|
175
|
-
|
|
176
|
-
if (diffSecs < 60) {
|
|
177
|
-
return 'Just now';
|
|
178
|
-
} else if (diffMins < 60) {
|
|
179
|
-
return `${diffMins} minute${diffMins === 1 ? '' : 's'} ago`;
|
|
180
|
-
} else if (diffHours < 24) {
|
|
181
|
-
return `${diffHours} hour${diffHours === 1 ? '' : 's'} ago`;
|
|
182
|
-
} else if (diffDays < 7) {
|
|
183
|
-
return `${diffDays} day${diffDays === 1 ? '' : 's'} ago`;
|
|
184
|
-
} else {
|
|
185
|
-
// Fall back to formatted date for older dates
|
|
186
|
-
return new Intl.DateTimeFormat(this.locale, { dateStyle: 'short' }).format(date);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
private getDateStyles(): string {
|
|
191
|
-
const date = new Date(this.value);
|
|
192
|
-
const now = new Date();
|
|
193
|
-
const isToday = date.toDateString() === now.toDateString();
|
|
194
|
-
const isPast = date < now;
|
|
195
|
-
const isFuture = date > now;
|
|
196
|
-
|
|
197
|
-
// Apply CSS classes instead of direct styles
|
|
198
|
-
this.classList.remove('date--today', 'date--past', 'date--future');
|
|
199
|
-
|
|
200
|
-
if (isToday) {
|
|
201
|
-
this.classList.add('date--today');
|
|
202
|
-
} else if (isPast) {
|
|
203
|
-
this.classList.add('date--past');
|
|
204
|
-
} else if (isFuture) {
|
|
205
|
-
this.classList.add('date--future');
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
return '';
|
|
209
|
-
}
|
|
210
|
-
}
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { element, property, watch, ready, query } from 'snice';
|
|
2
|
-
import css from './snice-cell.css?inline';
|
|
3
|
-
import type { SniceCellElement, ColumnType, ColumnAlign, ColumnDefinition } from './snice-table.types';
|
|
4
|
-
|
|
5
|
-
@element('snice-cell-duration')
|
|
6
|
-
export class SniceCellDuration extends HTMLElement implements SniceCellElement {
|
|
7
|
-
@property({ reflect: true })
|
|
8
|
-
align: ColumnAlign = 'right';
|
|
9
|
-
|
|
10
|
-
@property({ reflect: true })
|
|
11
|
-
type: ColumnType = 'duration';
|
|
12
|
-
|
|
13
|
-
@property({ reflect: true })
|
|
14
|
-
value: any = 0;
|
|
15
|
-
|
|
16
|
-
@property({ type: Object })
|
|
17
|
-
column: ColumnDefinition = {
|
|
18
|
-
key: '',
|
|
19
|
-
label: '',
|
|
20
|
-
type: 'duration',
|
|
21
|
-
align: 'right'
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
@property({ type: Object })
|
|
25
|
-
rowData: any = null;
|
|
26
|
-
|
|
27
|
-
@query('.cell-content')
|
|
28
|
-
contentElement?: HTMLElement;
|
|
29
|
-
|
|
30
|
-
html() {
|
|
31
|
-
const content = this.formatDuration();
|
|
32
|
-
|
|
33
|
-
return `
|
|
34
|
-
<div class="cell-content cell-content--duration" part="content">
|
|
35
|
-
${content}
|
|
36
|
-
</div>
|
|
37
|
-
`;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
css() {
|
|
41
|
-
return css;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
@ready()
|
|
45
|
-
init() {
|
|
46
|
-
this.applyAlignment();
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
private applyAlignment() {
|
|
50
|
-
this.style.textAlign = this.align;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
@watch('align')
|
|
54
|
-
updateAlignment() {
|
|
55
|
-
this.applyAlignment();
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
@watch('value', 'column')
|
|
59
|
-
updateContent() {
|
|
60
|
-
if (this.contentElement) {
|
|
61
|
-
const content = this.formatDuration();
|
|
62
|
-
this.contentElement.innerHTML = content;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
private formatDuration(): string {
|
|
67
|
-
if (this.value === null || this.value === undefined) {
|
|
68
|
-
return '';
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// Use custom formatter if provided
|
|
72
|
-
if (this.column.formatter) {
|
|
73
|
-
return this.column.formatter(this.value, this.rowData);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const seconds = Number(this.value);
|
|
77
|
-
if (isNaN(seconds)) return String(this.value);
|
|
78
|
-
|
|
79
|
-
const hours = Math.floor(seconds / 3600);
|
|
80
|
-
const minutes = Math.floor((seconds % 3600) / 60);
|
|
81
|
-
const secs = Math.floor(seconds % 60);
|
|
82
|
-
|
|
83
|
-
if (hours > 0) {
|
|
84
|
-
return `${hours}h ${minutes}m ${secs}s`;
|
|
85
|
-
} else if (minutes > 0) {
|
|
86
|
-
return `${minutes}m ${secs}s`;
|
|
87
|
-
} else {
|
|
88
|
-
return `${secs}s`;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { element, property, watch, ready, query } from 'snice';
|
|
2
|
-
import css from './snice-cell.css?inline';
|
|
3
|
-
import type { SniceCellElement, ColumnType, ColumnAlign, ColumnDefinition } from './snice-table.types';
|
|
4
|
-
|
|
5
|
-
@element('snice-cell-filesize')
|
|
6
|
-
export class SniceCellFilesize extends HTMLElement implements SniceCellElement {
|
|
7
|
-
@property({ reflect: true })
|
|
8
|
-
align: ColumnAlign = 'right';
|
|
9
|
-
|
|
10
|
-
@property({ reflect: true })
|
|
11
|
-
type: ColumnType = 'filesize';
|
|
12
|
-
|
|
13
|
-
@property({ reflect: true })
|
|
14
|
-
value: any = 0;
|
|
15
|
-
|
|
16
|
-
@property({ type: Object })
|
|
17
|
-
column: ColumnDefinition = {
|
|
18
|
-
key: '',
|
|
19
|
-
label: '',
|
|
20
|
-
type: 'filesize',
|
|
21
|
-
align: 'right'
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
@property({ type: Object })
|
|
25
|
-
rowData: any = null;
|
|
26
|
-
|
|
27
|
-
@query('.cell-content')
|
|
28
|
-
contentElement?: HTMLElement;
|
|
29
|
-
|
|
30
|
-
html() {
|
|
31
|
-
const content = this.formatFileSize();
|
|
32
|
-
|
|
33
|
-
return `
|
|
34
|
-
<div class="cell-content cell-content--filesize" part="content">
|
|
35
|
-
${content}
|
|
36
|
-
</div>
|
|
37
|
-
`;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
css() {
|
|
41
|
-
return css;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
@ready()
|
|
45
|
-
init() {
|
|
46
|
-
this.applyAlignment();
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
private applyAlignment() {
|
|
50
|
-
this.style.textAlign = this.align;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
@watch('align')
|
|
54
|
-
updateAlignment() {
|
|
55
|
-
this.applyAlignment();
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
@watch('value', 'column')
|
|
59
|
-
updateContent() {
|
|
60
|
-
if (this.contentElement) {
|
|
61
|
-
const content = this.formatFileSize();
|
|
62
|
-
this.contentElement.innerHTML = content;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
private formatFileSize(): string {
|
|
67
|
-
if (this.value === null || this.value === undefined) {
|
|
68
|
-
return '';
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// Use custom formatter if provided
|
|
72
|
-
if (this.column.formatter) {
|
|
73
|
-
return this.column.formatter(this.value, this.rowData);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const bytes = Number(this.value);
|
|
77
|
-
if (isNaN(bytes)) return String(this.value);
|
|
78
|
-
|
|
79
|
-
const units = ['B', 'KB', 'MB', 'GB', 'TB'];
|
|
80
|
-
let size = bytes;
|
|
81
|
-
let unitIndex = 0;
|
|
82
|
-
|
|
83
|
-
while (size >= 1024 && unitIndex < units.length - 1) {
|
|
84
|
-
size /= 1024;
|
|
85
|
-
unitIndex++;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
return `${size.toFixed(1)} ${units[unitIndex]}`;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
import { element, property, watch, ready, query } from 'snice';
|
|
2
|
-
import css from './snice-cell.css?inline';
|
|
3
|
-
import type { NumberFormat, SniceCellElement, ColumnType, ColumnAlign, ColumnDefinition } from './snice-table.types';
|
|
4
|
-
|
|
5
|
-
@element('snice-cell-number')
|
|
6
|
-
export class SniceCellNumber extends HTMLElement implements SniceCellElement {
|
|
7
|
-
@property({ reflect: true })
|
|
8
|
-
align: ColumnAlign = 'right';
|
|
9
|
-
|
|
10
|
-
@property({ reflect: true })
|
|
11
|
-
type: ColumnType = 'number';
|
|
12
|
-
|
|
13
|
-
@property({ reflect: true })
|
|
14
|
-
value: any = '';
|
|
15
|
-
|
|
16
|
-
@property({ type: Object })
|
|
17
|
-
column: ColumnDefinition = {
|
|
18
|
-
key: '',
|
|
19
|
-
label: '',
|
|
20
|
-
type: 'number',
|
|
21
|
-
align: 'right'
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
@property({ type: Object })
|
|
25
|
-
rowData: any = null;
|
|
26
|
-
|
|
27
|
-
@query('.cell-content')
|
|
28
|
-
contentElement?: HTMLElement;
|
|
29
|
-
@property({ type: Number, reflect: true })
|
|
30
|
-
decimals: number = 0;
|
|
31
|
-
|
|
32
|
-
@property({ type: Boolean, reflect: true, attribute: 'thousands-separator' })
|
|
33
|
-
thousandsSeparator: boolean = false;
|
|
34
|
-
|
|
35
|
-
@property({ reflect: true })
|
|
36
|
-
prefix: string = '';
|
|
37
|
-
|
|
38
|
-
@property({ reflect: true })
|
|
39
|
-
suffix: string = '';
|
|
40
|
-
|
|
41
|
-
@property({ reflect: true, attribute: 'negative-style' })
|
|
42
|
-
negativeStyle: 'parentheses' | 'red' | 'minus' = 'minus';
|
|
43
|
-
|
|
44
|
-
@property({ type: Boolean, reflect: true })
|
|
45
|
-
highlight: boolean = false;
|
|
46
|
-
|
|
47
|
-
html() {
|
|
48
|
-
const formattedValue = this.formatNumberValue();
|
|
49
|
-
const styles = this.getNumberStyles();
|
|
50
|
-
|
|
51
|
-
return `
|
|
52
|
-
<div class="cell-content cell-content--number" part="content" style="${styles}">
|
|
53
|
-
${formattedValue}
|
|
54
|
-
</div>
|
|
55
|
-
`;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
css() {
|
|
59
|
-
return css;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
@ready()
|
|
63
|
-
init() {
|
|
64
|
-
this.applyAlignment();
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
private applyAlignment() {
|
|
68
|
-
this.style.textAlign = this.align;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
@watch('align')
|
|
72
|
-
updateAlignment() {
|
|
73
|
-
this.applyAlignment();
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
@watch('value', 'column')
|
|
77
|
-
updateContent() {
|
|
78
|
-
if (this.contentElement) {
|
|
79
|
-
const formattedValue = this.formatNumberValue();
|
|
80
|
-
const styles = this.getNumberStyles();
|
|
81
|
-
this.contentElement.innerHTML = formattedValue;
|
|
82
|
-
this.contentElement.setAttribute('style', styles);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
private formatNumberValue(): string {
|
|
87
|
-
if (this.value === null || this.value === undefined || this.value === '') {
|
|
88
|
-
return '';
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// Use custom formatter if provided
|
|
92
|
-
if (this.column.formatter) {
|
|
93
|
-
return this.column.formatter(this.value, this.rowData);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
// Use column number format or component properties
|
|
97
|
-
const format: NumberFormat = this.column.numberFormat || {
|
|
98
|
-
decimals: this.decimals,
|
|
99
|
-
thousandsSeparator: this.thousandsSeparator,
|
|
100
|
-
prefix: this.prefix,
|
|
101
|
-
suffix: this.suffix,
|
|
102
|
-
negativeStyle: this.negativeStyle
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
const num = Number(this.value);
|
|
106
|
-
|
|
107
|
-
if (isNaN(num)) {
|
|
108
|
-
return String(this.value);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
let formatted = num.toFixed(format.decimals ?? this.decimals);
|
|
112
|
-
|
|
113
|
-
// Add thousands separator
|
|
114
|
-
if (format.thousandsSeparator ?? this.thousandsSeparator) {
|
|
115
|
-
const parts = formatted.split('.');
|
|
116
|
-
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
|
117
|
-
formatted = parts.join('.');
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
// Handle negative numbers
|
|
121
|
-
if (num < 0) {
|
|
122
|
-
const negStyle = format.negativeStyle ?? this.negativeStyle;
|
|
123
|
-
if (negStyle === 'parentheses') {
|
|
124
|
-
formatted = `(${formatted.replace('-', '')})`;
|
|
125
|
-
} else if (negStyle === 'red') {
|
|
126
|
-
// Color will be handled in styles
|
|
127
|
-
formatted = formatted.replace('-', '');
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
// Add prefix and suffix
|
|
132
|
-
const prefix = format.prefix ?? this.prefix;
|
|
133
|
-
const suffix = format.suffix ?? this.suffix;
|
|
134
|
-
|
|
135
|
-
if (prefix) formatted = prefix + formatted;
|
|
136
|
-
if (suffix) formatted = formatted + suffix;
|
|
137
|
-
|
|
138
|
-
return formatted;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
private getNumberStyles(): string {
|
|
142
|
-
const num = Number(this.value);
|
|
143
|
-
|
|
144
|
-
// Remove existing number classes
|
|
145
|
-
this.classList.remove('number--negative', 'number--positive', 'number--zero', 'number--highlighted');
|
|
146
|
-
|
|
147
|
-
// Apply CSS classes instead of direct styles
|
|
148
|
-
if (num < 0) {
|
|
149
|
-
this.classList.add('number--negative');
|
|
150
|
-
const negStyle = this.column.numberFormat?.negativeStyle ?? this.negativeStyle;
|
|
151
|
-
if (negStyle === 'red') {
|
|
152
|
-
this.classList.add('number--negative-red');
|
|
153
|
-
}
|
|
154
|
-
} else if (num > 0) {
|
|
155
|
-
this.classList.add('number--positive');
|
|
156
|
-
if (this.highlight) {
|
|
157
|
-
this.classList.add('number--highlighted');
|
|
158
|
-
}
|
|
159
|
-
} else if (num === 0) {
|
|
160
|
-
this.classList.add('number--zero');
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
return 'text-align: right'; // Keep text alignment as style for now
|
|
164
|
-
}
|
|
165
|
-
}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { element, property, watch, ready, query } from 'snice';
|
|
2
|
-
import css from './snice-cell.css?inline';
|
|
3
|
-
import type { ProgressFormat, SniceCellElement, ColumnType, ColumnAlign, ColumnDefinition } from './snice-table.types';
|
|
4
|
-
import './snice-progress';
|
|
5
|
-
|
|
6
|
-
@element('snice-cell-progress')
|
|
7
|
-
export class SniceCellProgress extends HTMLElement implements SniceCellElement {
|
|
8
|
-
@property({ reflect: true })
|
|
9
|
-
align: ColumnAlign = 'left';
|
|
10
|
-
|
|
11
|
-
@property({ reflect: true })
|
|
12
|
-
type: ColumnType = 'progress';
|
|
13
|
-
|
|
14
|
-
@property({ reflect: true })
|
|
15
|
-
value: any = 0;
|
|
16
|
-
|
|
17
|
-
@property({ type: Object })
|
|
18
|
-
column: ColumnDefinition = {
|
|
19
|
-
key: '',
|
|
20
|
-
label: '',
|
|
21
|
-
type: 'progress',
|
|
22
|
-
align: 'left'
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
@property({ type: Object })
|
|
26
|
-
rowData: any = null;
|
|
27
|
-
|
|
28
|
-
@query('.cell-content')
|
|
29
|
-
contentElement?: HTMLElement;
|
|
30
|
-
|
|
31
|
-
html() {
|
|
32
|
-
return `
|
|
33
|
-
<div class="cell-content cell-content--progress" part="content">
|
|
34
|
-
<!-- Progress component will be created here -->
|
|
35
|
-
</div>
|
|
36
|
-
`;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
css() {
|
|
40
|
-
return css;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
@ready()
|
|
44
|
-
init() {
|
|
45
|
-
this.applyAlignment();
|
|
46
|
-
this.createProgressElement();
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
private applyAlignment() {
|
|
50
|
-
this.style.textAlign = this.align;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
@watch('align')
|
|
54
|
-
updateAlignment() {
|
|
55
|
-
this.applyAlignment();
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
@watch('value', 'column')
|
|
59
|
-
updateContent() {
|
|
60
|
-
this.createProgressElement();
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
private createProgressElement() {
|
|
64
|
-
if (!this.contentElement) return;
|
|
65
|
-
|
|
66
|
-
// Clear existing content
|
|
67
|
-
this.contentElement.innerHTML = '';
|
|
68
|
-
|
|
69
|
-
// Create progress element
|
|
70
|
-
const progress = document.createElement('snice-progress') as any;
|
|
71
|
-
progress.value = Number(this.value) || 0;
|
|
72
|
-
|
|
73
|
-
// Apply format from column
|
|
74
|
-
const format: ProgressFormat = this.column.progressFormat || {};
|
|
75
|
-
progress.max = format.max ?? 100;
|
|
76
|
-
progress.color = format.color ?? '#3b82f6';
|
|
77
|
-
progress.backgroundColor = format.backgroundColor ?? '#e5e7eb';
|
|
78
|
-
progress.height = format.height ?? '0.5rem';
|
|
79
|
-
progress.showPercentage = format.showPercentage ?? false;
|
|
80
|
-
|
|
81
|
-
this.contentElement.appendChild(progress);
|
|
82
|
-
}
|
|
83
|
-
}
|