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,223 +0,0 @@
|
|
|
1
|
-
import { element, property, query, on, watch, dispatch, ready } from 'snice';
|
|
2
|
-
import css from './snice-checkbox.css?inline';
|
|
3
|
-
import type { CheckboxSize, SniceCheckboxElement } from './snice-checkbox.types';
|
|
4
|
-
|
|
5
|
-
@element('snice-checkbox')
|
|
6
|
-
export class SniceCheckbox extends HTMLElement implements SniceCheckboxElement {
|
|
7
|
-
@property({ type: Boolean, reflect: true })
|
|
8
|
-
checked = false;
|
|
9
|
-
|
|
10
|
-
@property({ type: Boolean, reflect: true })
|
|
11
|
-
indeterminate = false;
|
|
12
|
-
|
|
13
|
-
@property({ type: Boolean, reflect: true })
|
|
14
|
-
disabled = false;
|
|
15
|
-
|
|
16
|
-
@property({ type: Boolean, reflect: true })
|
|
17
|
-
required = false;
|
|
18
|
-
|
|
19
|
-
@property({ type: Boolean, reflect: true })
|
|
20
|
-
invalid = false;
|
|
21
|
-
|
|
22
|
-
@property({ reflect: true })
|
|
23
|
-
size: CheckboxSize = 'medium';
|
|
24
|
-
|
|
25
|
-
@property({ reflect: true })
|
|
26
|
-
name = '';
|
|
27
|
-
|
|
28
|
-
@property({ reflect: true })
|
|
29
|
-
value = 'on';
|
|
30
|
-
|
|
31
|
-
@property({ reflect: true })
|
|
32
|
-
label = '';
|
|
33
|
-
|
|
34
|
-
@query('.checkbox-input')
|
|
35
|
-
input?: HTMLInputElement;
|
|
36
|
-
|
|
37
|
-
@query('.checkbox')
|
|
38
|
-
checkbox?: HTMLElement;
|
|
39
|
-
|
|
40
|
-
@query('.checkbox-label')
|
|
41
|
-
labelElement?: HTMLElement;
|
|
42
|
-
|
|
43
|
-
@query('.checkbox-wrapper')
|
|
44
|
-
wrapper?: HTMLElement;
|
|
45
|
-
|
|
46
|
-
html() {
|
|
47
|
-
return /*html*/`
|
|
48
|
-
<label class="checkbox-wrapper ${this.disabled ? 'checkbox-wrapper--disabled' : ''}">
|
|
49
|
-
<input
|
|
50
|
-
type="checkbox"
|
|
51
|
-
class="checkbox-input"
|
|
52
|
-
${this.checked ? 'checked' : ''}
|
|
53
|
-
${this.disabled ? 'disabled' : ''}
|
|
54
|
-
${this.required ? 'required' : ''}
|
|
55
|
-
${this.name ? `name="${this.name}"` : ''}
|
|
56
|
-
${this.value ? `value="${this.value}"` : ''}
|
|
57
|
-
aria-invalid="${this.invalid}"
|
|
58
|
-
aria-checked="${this.indeterminate ? 'mixed' : this.checked}"
|
|
59
|
-
part="input"
|
|
60
|
-
/>
|
|
61
|
-
|
|
62
|
-
<span class="checkbox
|
|
63
|
-
checkbox--${this.size}
|
|
64
|
-
${this.invalid ? 'checkbox--invalid' : ''}
|
|
65
|
-
${this.indeterminate ? 'checkbox--indeterminate' : ''}"
|
|
66
|
-
part="checkbox">
|
|
67
|
-
|
|
68
|
-
<svg class="checkbox-icon checkbox-icon--check" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3">
|
|
69
|
-
<polyline points="20 6 9 17 4 12"></polyline>
|
|
70
|
-
</svg>
|
|
71
|
-
|
|
72
|
-
<svg class="checkbox-icon checkbox-icon--indeterminate" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3">
|
|
73
|
-
<line x1="5" y1="12" x2="19" y2="12"></line>
|
|
74
|
-
</svg>
|
|
75
|
-
</span>
|
|
76
|
-
|
|
77
|
-
${this.label ? /*html*/`
|
|
78
|
-
<span class="checkbox-label checkbox-label--${this.size} ${this.required ? 'checkbox-label--required' : ''}" part="label">
|
|
79
|
-
${this.label}
|
|
80
|
-
</span>
|
|
81
|
-
` : ''}
|
|
82
|
-
</label>
|
|
83
|
-
`;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
css() {
|
|
87
|
-
return css;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
@ready()
|
|
91
|
-
init() {
|
|
92
|
-
// Set initial states
|
|
93
|
-
if (this.input) {
|
|
94
|
-
this.input.checked = this.checked;
|
|
95
|
-
this.input.indeterminate = this.indeterminate;
|
|
96
|
-
|
|
97
|
-
// Set form value
|
|
98
|
-
if (this.name) {
|
|
99
|
-
this.input.name = this.name;
|
|
100
|
-
}
|
|
101
|
-
if (this.value) {
|
|
102
|
-
this.input.value = this.value;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
// Update visual state
|
|
107
|
-
this.updateCheckboxState();
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
@on('change', '.checkbox-input')
|
|
111
|
-
handleChange(e: Event) {
|
|
112
|
-
const target = e.target as HTMLInputElement;
|
|
113
|
-
this.checked = target.checked;
|
|
114
|
-
this.indeterminate = false; // Clear indeterminate on user interaction
|
|
115
|
-
this.dispatchChangeEvent();
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
@on('click', '.checkbox-input')
|
|
119
|
-
handleClick(e: Event) {
|
|
120
|
-
// Allow click to propagate for label association
|
|
121
|
-
e.stopPropagation();
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
@watch('checked')
|
|
125
|
-
handleCheckedChange() {
|
|
126
|
-
if (this.input) {
|
|
127
|
-
this.input.checked = this.checked;
|
|
128
|
-
}
|
|
129
|
-
this.updateCheckboxState();
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
@watch('indeterminate')
|
|
133
|
-
handleIndeterminateChange() {
|
|
134
|
-
if (this.input) {
|
|
135
|
-
this.input.indeterminate = this.indeterminate;
|
|
136
|
-
}
|
|
137
|
-
this.updateCheckboxState();
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
@watch('disabled')
|
|
141
|
-
handleDisabledChange() {
|
|
142
|
-
if (this.input) {
|
|
143
|
-
this.input.disabled = this.disabled;
|
|
144
|
-
}
|
|
145
|
-
if (this.wrapper) {
|
|
146
|
-
this.wrapper.classList.toggle('checkbox-wrapper--disabled', this.disabled);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
@watch('invalid')
|
|
151
|
-
handleInvalidChange() {
|
|
152
|
-
if (this.input) {
|
|
153
|
-
this.input.setAttribute('aria-invalid', String(this.invalid));
|
|
154
|
-
}
|
|
155
|
-
if (this.checkbox) {
|
|
156
|
-
this.checkbox.classList.toggle('checkbox--invalid', this.invalid);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
@watch('required')
|
|
161
|
-
handleRequiredChange() {
|
|
162
|
-
if (this.input) {
|
|
163
|
-
this.input.required = this.required;
|
|
164
|
-
}
|
|
165
|
-
if (this.labelElement) {
|
|
166
|
-
this.labelElement.classList.toggle('checkbox-label--required', this.required);
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
@watch('label')
|
|
171
|
-
handleLabelChange() {
|
|
172
|
-
if (this.labelElement) {
|
|
173
|
-
this.labelElement.textContent = this.label;
|
|
174
|
-
this.labelElement.style.display = this.label ? '' : 'none';
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
private updateCheckboxState() {
|
|
179
|
-
if (this.checkbox) {
|
|
180
|
-
// Update indeterminate state
|
|
181
|
-
this.checkbox.classList.toggle('checkbox--indeterminate', this.indeterminate);
|
|
182
|
-
|
|
183
|
-
// Update aria-checked
|
|
184
|
-
if (this.input) {
|
|
185
|
-
this.input.setAttribute('aria-checked', this.indeterminate ? 'mixed' : String(this.checked));
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
@dispatch('@snice/checkbox-change', { bubbles: true, composed: true })
|
|
191
|
-
private dispatchChangeEvent() {
|
|
192
|
-
return {
|
|
193
|
-
checked: this.checked,
|
|
194
|
-
indeterminate: this.indeterminate,
|
|
195
|
-
checkbox: this
|
|
196
|
-
};
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
// Public API
|
|
200
|
-
focus() {
|
|
201
|
-
this.input?.focus();
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
blur() {
|
|
205
|
-
this.input?.blur();
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
click() {
|
|
209
|
-
this.input?.click();
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
toggle() {
|
|
213
|
-
this.checked = !this.checked;
|
|
214
|
-
this.indeterminate = false;
|
|
215
|
-
this.dispatchChangeEvent();
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
setIndeterminate() {
|
|
219
|
-
this.indeterminate = true;
|
|
220
|
-
this.checked = false;
|
|
221
|
-
this.dispatchChangeEvent();
|
|
222
|
-
}
|
|
223
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export type CheckboxSize = 'small' | 'medium' | 'large';
|
|
2
|
-
|
|
3
|
-
export interface SniceCheckboxElement extends HTMLElement {
|
|
4
|
-
checked: boolean;
|
|
5
|
-
indeterminate: boolean;
|
|
6
|
-
disabled: boolean;
|
|
7
|
-
required: boolean;
|
|
8
|
-
invalid: boolean;
|
|
9
|
-
size: CheckboxSize;
|
|
10
|
-
name: string;
|
|
11
|
-
value: string;
|
|
12
|
-
label: string;
|
|
13
|
-
focus(): void;
|
|
14
|
-
blur(): void;
|
|
15
|
-
click(): void;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export interface CheckboxChangeDetail {
|
|
19
|
-
checked: boolean;
|
|
20
|
-
indeterminate: boolean;
|
|
21
|
-
checkbox: SniceCheckboxElement;
|
|
22
|
-
}
|
|
@@ -1,383 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8">
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
-
<title>Snice Chip Demo</title>
|
|
7
|
-
<link rel="stylesheet" href="../theme/theme.css">
|
|
8
|
-
<style>
|
|
9
|
-
body {
|
|
10
|
-
font-family: system-ui, -apple-system, sans-serif;
|
|
11
|
-
padding: 40px;
|
|
12
|
-
line-height: 1.6;
|
|
13
|
-
background: #f5f5f5;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
.container {
|
|
17
|
-
max-width: 900px;
|
|
18
|
-
margin: 0 auto;
|
|
19
|
-
background: white;
|
|
20
|
-
padding: 40px;
|
|
21
|
-
border-radius: 8px;
|
|
22
|
-
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
h1 {
|
|
26
|
-
color: #333;
|
|
27
|
-
border-bottom: 2px solid #e0e0e0;
|
|
28
|
-
padding-bottom: 10px;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
h2 {
|
|
32
|
-
color: #555;
|
|
33
|
-
margin-top: 30px;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
.demo-section {
|
|
37
|
-
margin: 30px 0;
|
|
38
|
-
padding: 20px;
|
|
39
|
-
background: #fafafa;
|
|
40
|
-
border-radius: 4px;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
.demo-label {
|
|
44
|
-
display: block;
|
|
45
|
-
margin-bottom: 12px;
|
|
46
|
-
font-weight: 500;
|
|
47
|
-
color: #666;
|
|
48
|
-
font-size: 14px;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
.chip-group {
|
|
52
|
-
display: flex;
|
|
53
|
-
flex-wrap: wrap;
|
|
54
|
-
gap: 8px;
|
|
55
|
-
margin: 16px 0;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
.controls {
|
|
59
|
-
display: flex;
|
|
60
|
-
gap: 10px;
|
|
61
|
-
margin: 20px 0;
|
|
62
|
-
flex-wrap: wrap;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
button {
|
|
66
|
-
padding: 8px 16px;
|
|
67
|
-
background: #f3f4f6;
|
|
68
|
-
border: 1px solid #d1d5db;
|
|
69
|
-
border-radius: 4px;
|
|
70
|
-
cursor: pointer;
|
|
71
|
-
font-size: 14px;
|
|
72
|
-
transition: background 0.2s;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
button:hover {
|
|
76
|
-
background: #e5e7eb;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
.selected-chips {
|
|
80
|
-
margin-top: 16px;
|
|
81
|
-
padding: 12px;
|
|
82
|
-
background: #f0f9ff;
|
|
83
|
-
border: 1px solid #0ea5e9;
|
|
84
|
-
border-radius: 4px;
|
|
85
|
-
min-height: 40px;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
.selected-chips:empty::after {
|
|
89
|
-
content: 'No chips selected';
|
|
90
|
-
color: #94a3b8;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
code {
|
|
94
|
-
background: #f0f0f0;
|
|
95
|
-
padding: 2px 6px;
|
|
96
|
-
border-radius: 3px;
|
|
97
|
-
font-size: 0.9em;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
.event-log {
|
|
101
|
-
margin-top: 16px;
|
|
102
|
-
padding: 12px;
|
|
103
|
-
background: #fef3c7;
|
|
104
|
-
border: 1px solid #fbbf24;
|
|
105
|
-
border-radius: 4px;
|
|
106
|
-
font-size: 14px;
|
|
107
|
-
font-family: monospace;
|
|
108
|
-
max-height: 200px;
|
|
109
|
-
overflow-y: auto;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
.input-group {
|
|
113
|
-
display: flex;
|
|
114
|
-
gap: 8px;
|
|
115
|
-
margin: 16px 0;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
input[type="text"] {
|
|
119
|
-
flex: 1;
|
|
120
|
-
padding: 8px 12px;
|
|
121
|
-
border: 1px solid #d1d5db;
|
|
122
|
-
border-radius: 4px;
|
|
123
|
-
font-size: 14px;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
.avatar-chip {
|
|
127
|
-
width: 20px;
|
|
128
|
-
height: 20px;
|
|
129
|
-
border-radius: 50%;
|
|
130
|
-
object-fit: cover;
|
|
131
|
-
}
|
|
132
|
-
</style>
|
|
133
|
-
</head>
|
|
134
|
-
<body>
|
|
135
|
-
<div class="container">
|
|
136
|
-
<h1>Snice Chip Component Demo</h1>
|
|
137
|
-
|
|
138
|
-
<div class="demo-section">
|
|
139
|
-
<h2>Basic Chips</h2>
|
|
140
|
-
|
|
141
|
-
<span class="demo-label">Default Chips</span>
|
|
142
|
-
<div class="chip-group">
|
|
143
|
-
<snice-chip label="JavaScript"></snice-chip>
|
|
144
|
-
<snice-chip label="TypeScript"></snice-chip>
|
|
145
|
-
<snice-chip label="React"></snice-chip>
|
|
146
|
-
<snice-chip label="Vue"></snice-chip>
|
|
147
|
-
<snice-chip label="Angular"></snice-chip>
|
|
148
|
-
</div>
|
|
149
|
-
|
|
150
|
-
<span class="demo-label">Selectable Chips</span>
|
|
151
|
-
<div class="chip-group">
|
|
152
|
-
<snice-chip label="Apple" selected></snice-chip>
|
|
153
|
-
<snice-chip label="Banana"></snice-chip>
|
|
154
|
-
<snice-chip label="Cherry"></snice-chip>
|
|
155
|
-
<snice-chip label="Date"></snice-chip>
|
|
156
|
-
<snice-chip label="Elderberry"></snice-chip>
|
|
157
|
-
</div>
|
|
158
|
-
</div>
|
|
159
|
-
|
|
160
|
-
<div class="demo-section">
|
|
161
|
-
<h2>Chip Variants</h2>
|
|
162
|
-
|
|
163
|
-
<div class="chip-group">
|
|
164
|
-
<snice-chip label="Default" variant="default"></snice-chip>
|
|
165
|
-
<snice-chip label="Primary" variant="primary"></snice-chip>
|
|
166
|
-
<snice-chip label="Success" variant="success"></snice-chip>
|
|
167
|
-
<snice-chip label="Warning" variant="warning"></snice-chip>
|
|
168
|
-
<snice-chip label="Error" variant="error"></snice-chip>
|
|
169
|
-
<snice-chip label="Info" variant="info"></snice-chip>
|
|
170
|
-
</div>
|
|
171
|
-
|
|
172
|
-
<span class="demo-label">Selected State in Different Variants</span>
|
|
173
|
-
<div class="chip-group">
|
|
174
|
-
<snice-chip label="Default" variant="default" selected></snice-chip>
|
|
175
|
-
<snice-chip label="Primary" variant="primary" selected></snice-chip>
|
|
176
|
-
<snice-chip label="Success" variant="success" selected></snice-chip>
|
|
177
|
-
<snice-chip label="Warning" variant="warning" selected></snice-chip>
|
|
178
|
-
<snice-chip label="Error" variant="error" selected></snice-chip>
|
|
179
|
-
<snice-chip label="Info" variant="info" selected></snice-chip>
|
|
180
|
-
</div>
|
|
181
|
-
</div>
|
|
182
|
-
|
|
183
|
-
<div class="demo-section">
|
|
184
|
-
<h2>Chip Sizes</h2>
|
|
185
|
-
|
|
186
|
-
<div class="chip-group">
|
|
187
|
-
<snice-chip label="Small Chip" size="small"></snice-chip>
|
|
188
|
-
<snice-chip label="Medium Chip" size="medium"></snice-chip>
|
|
189
|
-
<snice-chip label="Large Chip" size="large"></snice-chip>
|
|
190
|
-
</div>
|
|
191
|
-
</div>
|
|
192
|
-
|
|
193
|
-
<div class="demo-section">
|
|
194
|
-
<h2>Removable Chips</h2>
|
|
195
|
-
|
|
196
|
-
<span class="demo-label">Click the X to remove</span>
|
|
197
|
-
<div class="chip-group" id="removable-chips">
|
|
198
|
-
<snice-chip label="Remove me" removable></snice-chip>
|
|
199
|
-
<snice-chip label="Delete this" removable variant="primary"></snice-chip>
|
|
200
|
-
<snice-chip label="Clear me" removable variant="success"></snice-chip>
|
|
201
|
-
<snice-chip label="Dismiss" removable variant="warning"></snice-chip>
|
|
202
|
-
<snice-chip label="Close" removable variant="error"></snice-chip>
|
|
203
|
-
</div>
|
|
204
|
-
</div>
|
|
205
|
-
|
|
206
|
-
<div class="demo-section">
|
|
207
|
-
<h2>Chips with Icons</h2>
|
|
208
|
-
|
|
209
|
-
<div class="chip-group">
|
|
210
|
-
<snice-chip label="Star" icon="⭐"></snice-chip>
|
|
211
|
-
<snice-chip label="Heart" icon="❤️" variant="error"></snice-chip>
|
|
212
|
-
<snice-chip label="Check" icon="✓" variant="success"></snice-chip>
|
|
213
|
-
<snice-chip label="Warning" icon="⚠️" variant="warning"></snice-chip>
|
|
214
|
-
<snice-chip label="Info" icon="ℹ️" variant="info"></snice-chip>
|
|
215
|
-
<snice-chip label="Removable" icon="📁" removable></snice-chip>
|
|
216
|
-
</div>
|
|
217
|
-
</div>
|
|
218
|
-
|
|
219
|
-
<div class="demo-section">
|
|
220
|
-
<h2>Chips with Avatars</h2>
|
|
221
|
-
|
|
222
|
-
<div class="chip-group">
|
|
223
|
-
<snice-chip label="John Doe" avatar="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Ccircle cx='50' cy='50' r='50' fill='%234f46e5'/%3E%3Ctext x='50' y='50' text-anchor='middle' dy='0.35em' fill='white' font-size='40' font-family='sans-serif'%3EJD%3C/text%3E%3C/svg%3E"></snice-chip>
|
|
224
|
-
<snice-chip label="Jane Smith" avatar="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Ccircle cx='50' cy='50' r='50' fill='%23ec4899'/%3E%3Ctext x='50' y='50' text-anchor='middle' dy='0.35em' fill='white' font-size='40' font-family='sans-serif'%3EJS%3C/text%3E%3C/svg%3E" removable></snice-chip>
|
|
225
|
-
<snice-chip label="Alex Brown" avatar="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Ccircle cx='50' cy='50' r='50' fill='%2310b981'/%3E%3Ctext x='50' y='50' text-anchor='middle' dy='0.35em' fill='white' font-size='40' font-family='sans-serif'%3EAB%3C/text%3E%3C/svg%3E"></snice-chip>
|
|
226
|
-
</div>
|
|
227
|
-
</div>
|
|
228
|
-
|
|
229
|
-
<div class="demo-section">
|
|
230
|
-
<h2>Disabled State</h2>
|
|
231
|
-
|
|
232
|
-
<div class="chip-group">
|
|
233
|
-
<snice-chip label="Disabled" disabled></snice-chip>
|
|
234
|
-
<snice-chip label="Disabled Primary" variant="primary" disabled></snice-chip>
|
|
235
|
-
<snice-chip label="Disabled Removable" removable disabled></snice-chip>
|
|
236
|
-
<snice-chip label="Disabled Selected" selected disabled></snice-chip>
|
|
237
|
-
</div>
|
|
238
|
-
</div>
|
|
239
|
-
|
|
240
|
-
<div class="demo-section">
|
|
241
|
-
<h2>Interactive Filter Example</h2>
|
|
242
|
-
|
|
243
|
-
<span class="demo-label">Select categories:</span>
|
|
244
|
-
<div class="chip-group" id="filter-chips">
|
|
245
|
-
<snice-chip label="Electronics"></snice-chip>
|
|
246
|
-
<snice-chip label="Clothing"></snice-chip>
|
|
247
|
-
<snice-chip label="Books"></snice-chip>
|
|
248
|
-
<snice-chip label="Home & Garden"></snice-chip>
|
|
249
|
-
<snice-chip label="Sports"></snice-chip>
|
|
250
|
-
<snice-chip label="Toys"></snice-chip>
|
|
251
|
-
<snice-chip label="Food"></snice-chip>
|
|
252
|
-
<snice-chip label="Beauty"></snice-chip>
|
|
253
|
-
</div>
|
|
254
|
-
<div class="selected-chips" id="selected-filters"></div>
|
|
255
|
-
</div>
|
|
256
|
-
|
|
257
|
-
<div class="demo-section">
|
|
258
|
-
<h2>Dynamic Chip Creation</h2>
|
|
259
|
-
|
|
260
|
-
<div class="input-group">
|
|
261
|
-
<input type="text" id="chip-input" placeholder="Type and press Enter to add chip">
|
|
262
|
-
<button onclick="addChip()">Add Chip</button>
|
|
263
|
-
</div>
|
|
264
|
-
<div class="chip-group" id="dynamic-chips"></div>
|
|
265
|
-
</div>
|
|
266
|
-
|
|
267
|
-
<div class="demo-section">
|
|
268
|
-
<h2>Events</h2>
|
|
269
|
-
|
|
270
|
-
<span class="demo-label">Interact with these chips and watch the event log:</span>
|
|
271
|
-
<div class="chip-group" id="event-chips">
|
|
272
|
-
<snice-chip label="Click me"></snice-chip>
|
|
273
|
-
<snice-chip label="Remove me" removable></snice-chip>
|
|
274
|
-
<snice-chip label="Select me"></snice-chip>
|
|
275
|
-
</div>
|
|
276
|
-
<div class="event-log" id="event-log">Event log will appear here...</div>
|
|
277
|
-
</div>
|
|
278
|
-
|
|
279
|
-
<div class="demo-section">
|
|
280
|
-
<h2>Real-world Examples</h2>
|
|
281
|
-
|
|
282
|
-
<span class="demo-label">Email Recipients</span>
|
|
283
|
-
<div class="chip-group">
|
|
284
|
-
<snice-chip label="john@example.com" removable variant="primary" avatar="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Ccircle cx='50' cy='50' r='50' fill='%234f46e5'/%3E%3Ctext x='50' y='50' text-anchor='middle' dy='0.35em' fill='white' font-size='40' font-family='sans-serif'%3EJ%3C/text%3E%3C/svg%3E"></snice-chip>
|
|
285
|
-
<snice-chip label="sarah@company.com" removable variant="primary" avatar="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Ccircle cx='50' cy='50' r='50' fill='%23ec4899'/%3E%3Ctext x='50' y='50' text-anchor='middle' dy='0.35em' fill='white' font-size='40' font-family='sans-serif'%3ES%3C/text%3E%3C/svg%3E"></snice-chip>
|
|
286
|
-
<snice-chip label="team@startup.io" removable variant="primary" icon="👥"></snice-chip>
|
|
287
|
-
</div>
|
|
288
|
-
|
|
289
|
-
<span class="demo-label">Skills</span>
|
|
290
|
-
<div class="chip-group">
|
|
291
|
-
<snice-chip label="JavaScript" icon="💛" variant="warning"></snice-chip>
|
|
292
|
-
<snice-chip label="Python" icon="🐍" variant="info"></snice-chip>
|
|
293
|
-
<snice-chip label="React" icon="⚛️" variant="info"></snice-chip>
|
|
294
|
-
<snice-chip label="Node.js" icon="🟢" variant="success"></snice-chip>
|
|
295
|
-
<snice-chip label="Docker" icon="🐳" variant="primary"></snice-chip>
|
|
296
|
-
</div>
|
|
297
|
-
|
|
298
|
-
<span class="demo-label">Tags</span>
|
|
299
|
-
<div class="chip-group">
|
|
300
|
-
<snice-chip label="New" variant="success" size="small"></snice-chip>
|
|
301
|
-
<snice-chip label="Hot" variant="error" size="small"></snice-chip>
|
|
302
|
-
<snice-chip label="Sale" variant="warning" size="small"></snice-chip>
|
|
303
|
-
<snice-chip label="Limited" variant="info" size="small"></snice-chip>
|
|
304
|
-
</div>
|
|
305
|
-
</div>
|
|
306
|
-
</div>
|
|
307
|
-
|
|
308
|
-
<script type="module">
|
|
309
|
-
import './snice-chip.ts';
|
|
310
|
-
|
|
311
|
-
// Handle removable chips
|
|
312
|
-
document.getElementById('removable-chips').addEventListener('chip-remove', (e) => {
|
|
313
|
-
e.target.remove();
|
|
314
|
-
});
|
|
315
|
-
|
|
316
|
-
// Handle filter chips
|
|
317
|
-
const filterChips = document.querySelectorAll('#filter-chips snice-chip');
|
|
318
|
-
const selectedFilters = document.getElementById('selected-filters');
|
|
319
|
-
|
|
320
|
-
filterChips.forEach(chip => {
|
|
321
|
-
chip.addEventListener('chip-click', (e) => {
|
|
322
|
-
updateSelectedFilters();
|
|
323
|
-
});
|
|
324
|
-
});
|
|
325
|
-
|
|
326
|
-
function updateSelectedFilters() {
|
|
327
|
-
const selected = Array.from(filterChips)
|
|
328
|
-
.filter(chip => chip.selected)
|
|
329
|
-
.map(chip => chip.label);
|
|
330
|
-
|
|
331
|
-
selectedFilters.textContent = selected.length > 0
|
|
332
|
-
? 'Selected: ' + selected.join(', ')
|
|
333
|
-
: '';
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
// Dynamic chip creation
|
|
337
|
-
const chipInput = document.getElementById('chip-input');
|
|
338
|
-
const dynamicChips = document.getElementById('dynamic-chips');
|
|
339
|
-
|
|
340
|
-
window.addChip = function() {
|
|
341
|
-
const value = chipInput.value.trim();
|
|
342
|
-
if (value) {
|
|
343
|
-
const chip = document.createElement('snice-chip');
|
|
344
|
-
chip.label = value;
|
|
345
|
-
chip.removable = true;
|
|
346
|
-
chip.variant = ['default', 'primary', 'success', 'warning', 'error', 'info'][Math.floor(Math.random() * 6)];
|
|
347
|
-
chip.addEventListener('chip-remove', (e) => {
|
|
348
|
-
e.target.remove();
|
|
349
|
-
});
|
|
350
|
-
dynamicChips.appendChild(chip);
|
|
351
|
-
chipInput.value = '';
|
|
352
|
-
}
|
|
353
|
-
};
|
|
354
|
-
|
|
355
|
-
chipInput.addEventListener('keypress', (e) => {
|
|
356
|
-
if (e.key === 'Enter') {
|
|
357
|
-
addChip();
|
|
358
|
-
}
|
|
359
|
-
});
|
|
360
|
-
|
|
361
|
-
// Event logging
|
|
362
|
-
const eventChips = document.getElementById('event-chips');
|
|
363
|
-
const eventLog = document.getElementById('event-log');
|
|
364
|
-
let logEntries = [];
|
|
365
|
-
|
|
366
|
-
eventChips.addEventListener('chip-click', (e) => {
|
|
367
|
-
addLogEntry(`Click: "${e.detail.label}" (selected: ${e.detail.selected})`);
|
|
368
|
-
});
|
|
369
|
-
|
|
370
|
-
eventChips.addEventListener('chip-remove', (e) => {
|
|
371
|
-
addLogEntry(`Remove: "${e.detail.label}"`);
|
|
372
|
-
e.target.remove();
|
|
373
|
-
});
|
|
374
|
-
|
|
375
|
-
function addLogEntry(message) {
|
|
376
|
-
const timestamp = new Date().toLocaleTimeString();
|
|
377
|
-
logEntries.unshift(`[${timestamp}] ${message}`);
|
|
378
|
-
logEntries = logEntries.slice(0, 10); // Keep last 10 entries
|
|
379
|
-
eventLog.innerHTML = logEntries.join('<br>');
|
|
380
|
-
}
|
|
381
|
-
</script>
|
|
382
|
-
</body>
|
|
383
|
-
</html>
|