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,191 +0,0 @@
|
|
|
1
|
-
import { element, property, watch, query, dispatch, on, ready } from 'snice';
|
|
2
|
-
import css from './snice-breadcrumbs.css?inline';
|
|
3
|
-
import type { BreadcrumbItem, BreadcrumbSeparator, BreadcrumbSize, SniceBreadcrumbsElement } from './snice-breadcrumbs.types';
|
|
4
|
-
import type { SniceCrumbElement } from './snice-breadcrumbs.types';
|
|
5
|
-
|
|
6
|
-
@element('snice-breadcrumbs')
|
|
7
|
-
export class SniceBreadcrumbs extends HTMLElement implements SniceBreadcrumbsElement {
|
|
8
|
-
@property({ type: Array })
|
|
9
|
-
items: BreadcrumbItem[] = [];
|
|
10
|
-
|
|
11
|
-
@property({ reflect: true })
|
|
12
|
-
separator: BreadcrumbSeparator = '/';
|
|
13
|
-
|
|
14
|
-
@property({ reflect: true })
|
|
15
|
-
size: BreadcrumbSize = 'medium';
|
|
16
|
-
|
|
17
|
-
@property({ type: Number, reflect: true })
|
|
18
|
-
maxItems = 0;
|
|
19
|
-
|
|
20
|
-
@query('.breadcrumb')
|
|
21
|
-
breadcrumbElement?: HTMLElement;
|
|
22
|
-
|
|
23
|
-
private collapsed = true;
|
|
24
|
-
private slotItems: BreadcrumbItem[] = [];
|
|
25
|
-
|
|
26
|
-
html() {
|
|
27
|
-
const allItems = this.getAllItems();
|
|
28
|
-
const visibleItems = this.getVisibleItems(allItems);
|
|
29
|
-
const hasCollapsed = this.maxItems > 0 && allItems.length > this.maxItems && this.collapsed;
|
|
30
|
-
|
|
31
|
-
return /*html*/`
|
|
32
|
-
<slot style="display: none"></slot>
|
|
33
|
-
<nav aria-label="Breadcrumb">
|
|
34
|
-
<ol class="breadcrumb ${hasCollapsed ? 'breadcrumb--collapsed' : ''}">
|
|
35
|
-
${visibleItems.map((item, index) => {
|
|
36
|
-
const isLast = index === visibleItems.length - 1;
|
|
37
|
-
const isActive = item.active || isLast;
|
|
38
|
-
const isHidden = hasCollapsed && index > 0 && index < visibleItems.length - 2;
|
|
39
|
-
|
|
40
|
-
return /*html*/`
|
|
41
|
-
<li class="breadcrumb-item ${isActive ? 'breadcrumb-item--active' : ''} ${isHidden ? 'breadcrumb-item--hidden' : ''}">
|
|
42
|
-
${item.href && !isActive ? /*html*/`
|
|
43
|
-
<a href="${item.href}"
|
|
44
|
-
class="breadcrumb-link"
|
|
45
|
-
aria-current="${isActive ? 'page' : ''}"
|
|
46
|
-
tabindex="0">
|
|
47
|
-
${this.renderIcon(item)}
|
|
48
|
-
${item.label}
|
|
49
|
-
</a>
|
|
50
|
-
` : /*html*/`
|
|
51
|
-
<span class="breadcrumb-text"
|
|
52
|
-
aria-current="${isActive ? 'page' : ''}">
|
|
53
|
-
${this.renderIcon(item)}
|
|
54
|
-
${item.label}
|
|
55
|
-
</span>
|
|
56
|
-
`}
|
|
57
|
-
${!isLast ? /*html*/`
|
|
58
|
-
<span class="breadcrumb-separator" aria-hidden="true">
|
|
59
|
-
${this.separator}
|
|
60
|
-
</span>
|
|
61
|
-
` : ''}
|
|
62
|
-
</li>
|
|
63
|
-
${hasCollapsed && index === 0 && allItems.length > this.maxItems ? /*html*/`
|
|
64
|
-
<li class="breadcrumb-item">
|
|
65
|
-
<button class="breadcrumb-ellipsis"
|
|
66
|
-
aria-label="Show all breadcrumbs"
|
|
67
|
-
tabindex="0">
|
|
68
|
-
•••
|
|
69
|
-
</button>
|
|
70
|
-
<span class="breadcrumb-separator" aria-hidden="true">
|
|
71
|
-
${this.separator}
|
|
72
|
-
</span>
|
|
73
|
-
</li>
|
|
74
|
-
` : ''}
|
|
75
|
-
`;
|
|
76
|
-
}).join('')}
|
|
77
|
-
</ol>
|
|
78
|
-
</nav>
|
|
79
|
-
`;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
css() {
|
|
83
|
-
return css;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
private getAllItems(): BreadcrumbItem[] {
|
|
87
|
-
// Prefer slot items if available, otherwise use items property
|
|
88
|
-
return this.slotItems.length > 0 ? this.slotItems : this.items;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
private getVisibleItems(allItems: BreadcrumbItem[]): BreadcrumbItem[] {
|
|
92
|
-
if (this.maxItems <= 0 || allItems.length <= this.maxItems || !this.collapsed) {
|
|
93
|
-
return allItems;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
// Show first item and last (maxItems - 1) items
|
|
97
|
-
const firstItem = allItems[0];
|
|
98
|
-
const lastItems = allItems.slice(-(this.maxItems - 1));
|
|
99
|
-
return [firstItem, ...lastItems];
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
@on('click', '.breadcrumb-ellipsis')
|
|
103
|
-
handleEllipsisClick() {
|
|
104
|
-
this.collapsed = false;
|
|
105
|
-
this.render();
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
@on('click', '.breadcrumb-link')
|
|
109
|
-
@dispatch('breadcrumb-click')
|
|
110
|
-
handleLinkClick(event: MouseEvent) {
|
|
111
|
-
const target = event.target as HTMLAnchorElement;
|
|
112
|
-
const label = target.textContent?.trim() || '';
|
|
113
|
-
const href = target.getAttribute('href') || '';
|
|
114
|
-
|
|
115
|
-
// Find the item index
|
|
116
|
-
const allItems = this.getAllItems();
|
|
117
|
-
const index = allItems.findIndex(item => item.label === label);
|
|
118
|
-
|
|
119
|
-
return {
|
|
120
|
-
item: allItems[index],
|
|
121
|
-
index,
|
|
122
|
-
href,
|
|
123
|
-
label
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
private handleSlotChange() {
|
|
128
|
-
const slot = this.shadowRoot?.querySelector('slot');
|
|
129
|
-
if (!slot) return;
|
|
130
|
-
|
|
131
|
-
const crumbs = slot.assignedElements().filter(
|
|
132
|
-
el => el.tagName.toLowerCase() === 'snice-crumb'
|
|
133
|
-
) as SniceCrumbElement[];
|
|
134
|
-
|
|
135
|
-
this.slotItems = crumbs.map(crumb => ({
|
|
136
|
-
label: crumb.label || crumb.textContent?.trim() || '',
|
|
137
|
-
href: crumb.href || undefined,
|
|
138
|
-
icon: crumb.icon || undefined,
|
|
139
|
-
iconImage: crumb.iconImage || undefined,
|
|
140
|
-
active: crumb.active || false
|
|
141
|
-
}));
|
|
142
|
-
|
|
143
|
-
this.render();
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
@ready()
|
|
147
|
-
init() {
|
|
148
|
-
// Setup slot change handling
|
|
149
|
-
const slot = this.shadowRoot?.querySelector('slot');
|
|
150
|
-
if (slot) {
|
|
151
|
-
slot.addEventListener('slotchange', () => this.handleSlotChange());
|
|
152
|
-
// Initial check for slotted content
|
|
153
|
-
this.handleSlotChange();
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
@watch('items', 'separator', 'maxItems')
|
|
158
|
-
updateBreadcrumb() {
|
|
159
|
-
this.collapsed = true;
|
|
160
|
-
// Only render if not using slot items, otherwise slot change will handle it
|
|
161
|
-
if (!this.slotItems || this.slotItems.length === 0) {
|
|
162
|
-
this.render();
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
setItems(items: BreadcrumbItem[]) {
|
|
167
|
-
this.items = items;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
private renderIcon(item: BreadcrumbItem): string {
|
|
171
|
-
return /*html*/`
|
|
172
|
-
<img class="breadcrumb-icon-image" src="${item.iconImage || ''}" alt="" ${item.iconImage ? '' : 'hidden'}>
|
|
173
|
-
<span class="breadcrumb-icon" ${item.icon ? '' : 'hidden'}>${item.icon || ''}</span>
|
|
174
|
-
`;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
private render() {
|
|
178
|
-
const shadow = this.shadowRoot;
|
|
179
|
-
if (shadow) {
|
|
180
|
-
shadow.innerHTML = '';
|
|
181
|
-
if (this.css) {
|
|
182
|
-
const style = document.createElement('style');
|
|
183
|
-
style.textContent = this.css();
|
|
184
|
-
shadow.appendChild(style);
|
|
185
|
-
}
|
|
186
|
-
const template = document.createElement('template');
|
|
187
|
-
template.innerHTML = this.html();
|
|
188
|
-
shadow.appendChild(template.content.cloneNode(true));
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
export type BreadcrumbSeparator = '/' | '>' | '»' | '•' | '|';
|
|
2
|
-
export type BreadcrumbSize = 'small' | 'medium' | 'large';
|
|
3
|
-
|
|
4
|
-
export interface BreadcrumbItem {
|
|
5
|
-
label: string;
|
|
6
|
-
href?: string;
|
|
7
|
-
icon?: string;
|
|
8
|
-
iconImage?: string;
|
|
9
|
-
active?: boolean;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export interface SniceBreadcrumbsElement extends HTMLElement {
|
|
13
|
-
items: BreadcrumbItem[];
|
|
14
|
-
separator: BreadcrumbSeparator;
|
|
15
|
-
size: BreadcrumbSize;
|
|
16
|
-
maxItems: number;
|
|
17
|
-
setItems(items: BreadcrumbItem[]): void;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export interface SniceCrumbElement extends HTMLElement {
|
|
21
|
-
label: string;
|
|
22
|
-
href: string;
|
|
23
|
-
icon: string;
|
|
24
|
-
iconImage: string;
|
|
25
|
-
active: boolean;
|
|
26
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { element, property } from 'snice';
|
|
2
|
-
import type { SniceCrumbElement } from './snice-breadcrumbs.types';
|
|
3
|
-
|
|
4
|
-
@element('snice-crumb')
|
|
5
|
-
export class SniceCrumb extends HTMLElement implements SniceCrumbElement {
|
|
6
|
-
@property({ reflect: true })
|
|
7
|
-
label = '';
|
|
8
|
-
|
|
9
|
-
@property({ reflect: true })
|
|
10
|
-
href = '';
|
|
11
|
-
|
|
12
|
-
@property({ reflect: true })
|
|
13
|
-
icon = '';
|
|
14
|
-
|
|
15
|
-
@property({ attribute: 'icon-image', reflect: true })
|
|
16
|
-
iconImage = '';
|
|
17
|
-
|
|
18
|
-
@property({ type: Boolean, reflect: true })
|
|
19
|
-
active = false;
|
|
20
|
-
|
|
21
|
-
// No shadow DOM - this is a data element
|
|
22
|
-
connectedCallback() {
|
|
23
|
-
// Hide the element as it's only for data
|
|
24
|
-
this.style.display = 'none';
|
|
25
|
-
}
|
|
26
|
-
}
|
|
@@ -1,42 +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>Button Demo</title>
|
|
7
|
-
<link rel="stylesheet" href="../theme/theme.css">
|
|
8
|
-
<style>
|
|
9
|
-
body {
|
|
10
|
-
padding: 40px;
|
|
11
|
-
font-family: var(--snice-font-family);
|
|
12
|
-
background: var(--snice-color-background);
|
|
13
|
-
color: var(--snice-color-text);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
.row {
|
|
17
|
-
margin-bottom: 20px;
|
|
18
|
-
display: flex;
|
|
19
|
-
gap: 10px;
|
|
20
|
-
align-items: center;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
h2 {
|
|
24
|
-
color: var(--snice-color-text);
|
|
25
|
-
margin-bottom: 20px;
|
|
26
|
-
}
|
|
27
|
-
</style>
|
|
28
|
-
</head>
|
|
29
|
-
<body>
|
|
30
|
-
<h2>Button Variants</h2>
|
|
31
|
-
<div class="row">
|
|
32
|
-
<snice-button variant="default">Default</snice-button>
|
|
33
|
-
<snice-button variant="primary">Primary</snice-button>
|
|
34
|
-
<snice-button variant="success">Success</snice-button>
|
|
35
|
-
<snice-button variant="warning">Warning</snice-button>
|
|
36
|
-
<snice-button variant="danger">Danger</snice-button>
|
|
37
|
-
<snice-button variant="text">Text</snice-button>
|
|
38
|
-
</div>
|
|
39
|
-
|
|
40
|
-
<script type="module" src="./snice-button.ts"></script>
|
|
41
|
-
</body>
|
|
42
|
-
</html>
|
|
@@ -1,230 +0,0 @@
|
|
|
1
|
-
:host {
|
|
2
|
-
display: inline-block;
|
|
3
|
-
position: relative;
|
|
4
|
-
width: auto;
|
|
5
|
-
cursor: pointer;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
:host([disabled]) {
|
|
9
|
-
cursor: not-allowed;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
.button {
|
|
13
|
-
display: inline-flex;
|
|
14
|
-
align-items: center;
|
|
15
|
-
justify-content: center;
|
|
16
|
-
width: 100%;
|
|
17
|
-
border: 1px solid;
|
|
18
|
-
font-family: var(--snice-font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif);
|
|
19
|
-
font-weight: var(--snice-font-weight-medium, 500);
|
|
20
|
-
text-decoration: none;
|
|
21
|
-
user-select: none;
|
|
22
|
-
white-space: nowrap;
|
|
23
|
-
vertical-align: middle;
|
|
24
|
-
padding: 0;
|
|
25
|
-
transition:
|
|
26
|
-
color var(--snice-transition-fast, 150ms) ease,
|
|
27
|
-
background-color var(--snice-transition-fast, 150ms) ease,
|
|
28
|
-
border-color var(--snice-transition-fast, 150ms) ease,
|
|
29
|
-
box-shadow var(--snice-transition-fast, 150ms) ease;
|
|
30
|
-
cursor: inherit;
|
|
31
|
-
position: relative;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
.button:focus-visible {
|
|
35
|
-
outline: none;
|
|
36
|
-
box-shadow: 0 0 0 var(--snice-focus-ring-width, 2px) var(--snice-focus-ring-color, rgb(59 130 246 / 0.5));
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
.button--disabled {
|
|
40
|
-
opacity: 0.5;
|
|
41
|
-
cursor: not-allowed;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/* Sizes */
|
|
45
|
-
.button--small {
|
|
46
|
-
font-size: var(--snice-font-size-sm, 0.875rem);
|
|
47
|
-
height: 1.875rem; /* 30px */
|
|
48
|
-
padding: 0 var(--snice-spacing-sm, 0.75rem);
|
|
49
|
-
border-radius: var(--snice-border-radius-md, 0.25rem);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
.button--medium {
|
|
53
|
-
font-size: var(--snice-font-size-md, 1rem);
|
|
54
|
-
height: 2.5rem; /* 40px */
|
|
55
|
-
padding: 0 var(--snice-spacing-md, 1rem);
|
|
56
|
-
border-radius: var(--snice-border-radius-md, 0.25rem);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
.button--large {
|
|
60
|
-
font-size: var(--snice-font-size-lg, 1.125rem);
|
|
61
|
-
height: 3.125rem; /* 50px */
|
|
62
|
-
padding: 0 var(--snice-spacing-lg, 1.5rem);
|
|
63
|
-
border-radius: var(--snice-border-radius-md, 0.25rem);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/* Variants - Default */
|
|
67
|
-
.button--default {
|
|
68
|
-
background-color: var(--snice-color-background, rgb(255 255 255));
|
|
69
|
-
color: var(--snice-color-text, rgb(23 23 23));
|
|
70
|
-
border-color: var(--snice-color-border, rgb(226 226 226));
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
.button--default:hover:not(.button--disabled) {
|
|
74
|
-
background-color: var(--snice-color-background-secondary, rgb(250 250 250));
|
|
75
|
-
border-color: var(--snice-color-border-hover, rgb(204 204 204));
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
.button--default:active:not(.button--disabled) {
|
|
79
|
-
background-color: var(--snice-color-background-tertiary, rgb(241 241 241));
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/* Variants - Primary */
|
|
83
|
-
.button--primary {
|
|
84
|
-
background-color: var(--snice-color-primary, rgb(37 99 235));
|
|
85
|
-
color: var(--snice-color-text-inverse, rgb(250 250 250));
|
|
86
|
-
border-color: var(--snice-color-primary, rgb(37 99 235));
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
.button--primary:hover:not(.button--disabled) {
|
|
90
|
-
background-color: var(--snice-color-primary-hover, rgb(29 78 216));
|
|
91
|
-
border-color: var(--snice-color-primary-hover, rgb(29 78 216));
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
.button--primary:active:not(.button--disabled) {
|
|
95
|
-
background-color: var(--snice-color-primary-hover, rgb(29 78 216));
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/* Variants - Success */
|
|
99
|
-
.button--success {
|
|
100
|
-
background-color: var(--snice-color-success, rgb(22 163 74));
|
|
101
|
-
color: var(--snice-color-text-inverse, rgb(250 250 250));
|
|
102
|
-
border-color: var(--snice-color-success, rgb(22 163 74));
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
.button--success:hover:not(.button--disabled) {
|
|
106
|
-
background-color: var(--snice-color-success-hover, rgb(21 128 61));
|
|
107
|
-
border-color: var(--snice-color-success-hover, rgb(21 128 61));
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/* Variants - Warning */
|
|
111
|
-
.button--warning {
|
|
112
|
-
background-color: var(--snice-color-warning, rgb(202 138 4));
|
|
113
|
-
color: var(--snice-color-text-inverse, rgb(250 250 250));
|
|
114
|
-
border-color: var(--snice-color-warning, rgb(202 138 4));
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
.button--warning:hover:not(.button--disabled) {
|
|
118
|
-
background-color: var(--snice-color-warning-hover, rgb(161 98 7));
|
|
119
|
-
border-color: var(--snice-color-warning-hover, rgb(161 98 7));
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/* Variants - Danger */
|
|
123
|
-
.button--danger {
|
|
124
|
-
background-color: var(--snice-color-danger, rgb(220 38 38));
|
|
125
|
-
color: var(--snice-color-text-inverse, rgb(250 250 250));
|
|
126
|
-
border-color: var(--snice-color-danger, rgb(220 38 38));
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
.button--danger:hover:not(.button--disabled) {
|
|
130
|
-
background-color: var(--snice-color-danger-hover, rgb(185 28 28));
|
|
131
|
-
border-color: var(--snice-color-danger-hover, rgb(185 28 28));
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
/* Variants - Text */
|
|
135
|
-
.button--text {
|
|
136
|
-
background-color: transparent;
|
|
137
|
-
color: var(--snice-color-primary, rgb(37 99 235));
|
|
138
|
-
border-color: transparent;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
.button--text:hover:not(.button--disabled) {
|
|
142
|
-
background-color: rgb(59 130 246 / 0.1);
|
|
143
|
-
color: var(--snice-color-primary-hover, rgb(29 78 216));
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
/* Outline modifier */
|
|
147
|
-
.button--outline.button--default {
|
|
148
|
-
background-color: transparent;
|
|
149
|
-
color: var(--snice-color-text, rgb(23 23 23));
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
.button--outline.button--primary {
|
|
153
|
-
background-color: transparent;
|
|
154
|
-
color: var(--snice-color-primary, rgb(37 99 235));
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
.button--outline.button--success {
|
|
158
|
-
background-color: transparent;
|
|
159
|
-
color: var(--snice-color-success, rgb(22 163 74));
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
.button--outline.button--warning {
|
|
163
|
-
background-color: transparent;
|
|
164
|
-
color: var(--snice-color-warning, rgb(202 138 4));
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
.button--outline.button--danger {
|
|
168
|
-
background-color: transparent;
|
|
169
|
-
color: var(--snice-color-danger, rgb(220 38 38));
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
.button--outline:hover:not(.button--disabled) {
|
|
173
|
-
background-color: rgb(115 115 115 / 0.1);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
/* Shape modifiers */
|
|
177
|
-
.button--pill {
|
|
178
|
-
border-radius: var(--snice-border-radius-pill, 9999px);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
.button--circle {
|
|
182
|
-
border-radius: var(--snice-border-radius-circle, 50%);
|
|
183
|
-
width: var(--size);
|
|
184
|
-
padding: 0;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
.button--small.button--circle { --size: 1.875rem; /* 30px */ }
|
|
188
|
-
.button--medium.button--circle { --size: 2.5rem; /* 40px */ }
|
|
189
|
-
.button--large.button--circle { --size: 3.125rem; /* 50px */ }
|
|
190
|
-
|
|
191
|
-
/* Loading state */
|
|
192
|
-
.button--loading {
|
|
193
|
-
position: relative;
|
|
194
|
-
cursor: wait;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
.button--loading .label {
|
|
198
|
-
visibility: hidden;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
.spinner {
|
|
202
|
-
display: none;
|
|
203
|
-
position: absolute;
|
|
204
|
-
top: 50%;
|
|
205
|
-
left: 50%;
|
|
206
|
-
transform: translate(-50%, -50%);
|
|
207
|
-
width: 1em;
|
|
208
|
-
height: 1em;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
.button--loading .spinner {
|
|
212
|
-
display: block;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
.spinner::after {
|
|
216
|
-
content: '';
|
|
217
|
-
display: block;
|
|
218
|
-
width: 100%;
|
|
219
|
-
height: 100%;
|
|
220
|
-
border: 2px solid currentColor;
|
|
221
|
-
border-right-color: transparent;
|
|
222
|
-
border-radius: 50%;
|
|
223
|
-
animation: spin 0.6s linear infinite;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
@keyframes spin {
|
|
227
|
-
to {
|
|
228
|
-
transform: rotate(360deg);
|
|
229
|
-
}
|
|
230
|
-
}
|
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
import { element, property, query, on, dispatch, watch } from 'snice';
|
|
2
|
-
import css from './snice-button.css?inline';
|
|
3
|
-
import type { ButtonVariant, ButtonSize, IconPlacement, SniceButtonElement } from './snice-button.types';
|
|
4
|
-
|
|
5
|
-
@element('snice-button')
|
|
6
|
-
export class SniceButton extends HTMLElement implements SniceButtonElement {
|
|
7
|
-
@property({ reflect: true })
|
|
8
|
-
variant: ButtonVariant = 'default';
|
|
9
|
-
|
|
10
|
-
@property({ reflect: true })
|
|
11
|
-
size: ButtonSize = 'medium';
|
|
12
|
-
|
|
13
|
-
@property({ type: Boolean, reflect: true })
|
|
14
|
-
disabled = false;
|
|
15
|
-
|
|
16
|
-
@property({ type: Boolean, reflect: true })
|
|
17
|
-
loading = false;
|
|
18
|
-
|
|
19
|
-
@property({ type: Boolean, reflect: true })
|
|
20
|
-
outline = false;
|
|
21
|
-
|
|
22
|
-
@property({ type: Boolean, reflect: true })
|
|
23
|
-
pill = false;
|
|
24
|
-
|
|
25
|
-
@property({ type: Boolean, reflect: true })
|
|
26
|
-
circle = false;
|
|
27
|
-
|
|
28
|
-
@property({ type: String, reflect: true })
|
|
29
|
-
href = '';
|
|
30
|
-
|
|
31
|
-
@property({ type: String, reflect: true })
|
|
32
|
-
target = '';
|
|
33
|
-
|
|
34
|
-
@property({ type: String, reflect: true })
|
|
35
|
-
download = '';
|
|
36
|
-
|
|
37
|
-
@property({ type: String, reflect: true })
|
|
38
|
-
icon = '';
|
|
39
|
-
|
|
40
|
-
@property({ attribute: 'icon-placement', reflect: true })
|
|
41
|
-
iconPlacement: IconPlacement = 'start';
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
@query('.button')
|
|
45
|
-
button?: HTMLButtonElement;
|
|
46
|
-
|
|
47
|
-
@query('.spinner')
|
|
48
|
-
spinner?: HTMLElement;
|
|
49
|
-
|
|
50
|
-
@query('.label')
|
|
51
|
-
label?: HTMLElement;
|
|
52
|
-
|
|
53
|
-
@query('.icon')
|
|
54
|
-
iconElement?: HTMLImageElement;
|
|
55
|
-
|
|
56
|
-
html() {
|
|
57
|
-
const classes = [
|
|
58
|
-
'button',
|
|
59
|
-
`button--${this.variant || 'default'}`,
|
|
60
|
-
`button--${this.size || 'medium'}`,
|
|
61
|
-
this.outline ? 'button--outline' : '',
|
|
62
|
-
this.pill ? 'button--pill' : '',
|
|
63
|
-
this.circle ? 'button--circle' : '',
|
|
64
|
-
this.loading ? 'button--loading' : '',
|
|
65
|
-
this.disabled ? 'button--disabled' : '',
|
|
66
|
-
this.icon ? `button--has-icon` : '',
|
|
67
|
-
this.icon ? `button--icon-${this.iconPlacement}` : ''
|
|
68
|
-
].filter(Boolean).join(' ');
|
|
69
|
-
|
|
70
|
-
const iconElement = this.icon ? /*html*/`
|
|
71
|
-
<img class="icon" src="${this.icon}" alt="" part="icon" />
|
|
72
|
-
` : '';
|
|
73
|
-
|
|
74
|
-
return /*html*/`
|
|
75
|
-
<button class="${classes}" type="button" ${this.disabled ? 'disabled' : ''} part="base">
|
|
76
|
-
<span class="spinner" part="spinner"></span>
|
|
77
|
-
${this.iconPlacement === 'start' ? iconElement : ''}
|
|
78
|
-
<span class="label" part="label">
|
|
79
|
-
<slot></slot>
|
|
80
|
-
</span>
|
|
81
|
-
${this.iconPlacement === 'end' ? iconElement : ''}
|
|
82
|
-
</button>
|
|
83
|
-
`;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
css() {
|
|
87
|
-
return css;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
@watch('*')
|
|
91
|
-
updateButtonClasses() {
|
|
92
|
-
if (!this.button) return;
|
|
93
|
-
|
|
94
|
-
// Rebuild all classes based on current state
|
|
95
|
-
const classes = [
|
|
96
|
-
'button',
|
|
97
|
-
`button--${this.variant}`,
|
|
98
|
-
`button--${this.size}`,
|
|
99
|
-
this.outline ? 'button--outline' : '',
|
|
100
|
-
this.pill ? 'button--pill' : '',
|
|
101
|
-
this.circle ? 'button--circle' : '',
|
|
102
|
-
this.loading ? 'button--loading' : '',
|
|
103
|
-
this.disabled ? 'button--disabled' : '',
|
|
104
|
-
this.icon ? `button--has-icon` : '',
|
|
105
|
-
this.icon ? `button--icon-${this.iconPlacement}` : ''
|
|
106
|
-
].filter(Boolean);
|
|
107
|
-
|
|
108
|
-
// Set the className directly to avoid class manipulation issues
|
|
109
|
-
this.button.className = classes.join(' ');
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
@watch('disabled')
|
|
113
|
-
updateDisabledState() {
|
|
114
|
-
if (this.button) {
|
|
115
|
-
this.button.disabled = this.disabled;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
// Keep these methods for backwards compatibility if needed
|
|
120
|
-
setLoading(loading: boolean) {
|
|
121
|
-
this.loading = loading;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
setDisabled(disabled: boolean) {
|
|
125
|
-
this.disabled = disabled;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
setVariant(variant: typeof this.variant) {
|
|
129
|
-
this.variant = variant;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
@on('click')
|
|
133
|
-
@dispatch('@snice/click')
|
|
134
|
-
handleClick(event: MouseEvent) {
|
|
135
|
-
if (this.disabled || this.loading) {
|
|
136
|
-
event.preventDefault();
|
|
137
|
-
event.stopPropagation();
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
// Handle navigation if href is set
|
|
142
|
-
if (this.href) {
|
|
143
|
-
if (this.download) {
|
|
144
|
-
const a = document.createElement('a');
|
|
145
|
-
a.href = this.href;
|
|
146
|
-
a.download = this.download;
|
|
147
|
-
a.click();
|
|
148
|
-
} else if (this.target) {
|
|
149
|
-
window.open(this.href, this.target);
|
|
150
|
-
} else {
|
|
151
|
-
window.location.href = this.href;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
return { originalEvent: event };
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
focus(options?: FocusOptions) {
|
|
159
|
-
this.button?.focus(options);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
blur() {
|
|
163
|
-
this.button?.blur();
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
click() {
|
|
167
|
-
this.button?.click();
|
|
168
|
-
}
|
|
169
|
-
}
|