@mcp-b/web-components 0.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/LICENSE +21 -0
- package/README.md +49 -0
- package/dist/accordion-B1Q3kuP_.d.ts +373 -0
- package/dist/accordion-item-DvPfhpm8.js +307 -0
- package/dist/accordion-item-bPRIahNn.d.ts +63 -0
- package/dist/accordion-zDr-Br4V.js +483 -0
- package/dist/action-bar-CYsjmhwP.d.ts +29 -0
- package/dist/action-bar-CjN_UcnP.js +56 -0
- package/dist/alert-dialog-4CnO3Nb5.d.ts +60 -0
- package/dist/alert-dialog-D25Oi_TS.js +126 -0
- package/dist/avatar-Bje_KpZo.d.ts +141 -0
- package/dist/avatar-CRP0kW3x.js +224 -0
- package/dist/badge-Ct95U4UO.js +301 -0
- package/dist/badge-D1DNQrWn.d.ts +106 -0
- package/dist/breadcrumb-BxZ-nQE5.d.ts +365 -0
- package/dist/breadcrumb-item-BC454oQe.d.ts +59 -0
- package/dist/breadcrumb-item-P5pdq_gE.js +151 -0
- package/dist/breadcrumb-uURhiqWJ.js +384 -0
- package/dist/button-5k_aL_gD.js +802 -0
- package/dist/button-BQofnUt4.d.ts +354 -0
- package/dist/button-group-BydvJTQy.js +197 -0
- package/dist/button-group-COodHeuB.d.ts +155 -0
- package/dist/callout-B8zTf8Go.js +188 -0
- package/dist/callout-DFwPao36.d.ts +103 -0
- package/dist/card-BYDzdMAU.d.ts +177 -0
- package/dist/card-DIg1-X2G.js +332 -0
- package/dist/carousel-Bktu7wrD.js +843 -0
- package/dist/carousel-DQITCtEY.d.ts +423 -0
- package/dist/carousel-item-B5-X31Ha.js +79 -0
- package/dist/carousel-item-BB3jL2tk.d.ts +34 -0
- package/dist/cdn/loader.js +530 -0
- package/dist/checkbox-D6r7PVPj.js +641 -0
- package/dist/checkbox-DoFcDEKB.d.ts +354 -0
- package/dist/checkbox-group-CLvNAO_F.js +201 -0
- package/dist/checkbox-group-Cnh8rAn4.d.ts +152 -0
- package/dist/color-input-Bky89xg_.d.ts +470 -0
- package/dist/color-input-DPIxi9wR.js +894 -0
- package/dist/color-picker-adwOmtRl.js +1240 -0
- package/dist/color-picker-wQw8bPsq.d.ts +360 -0
- package/dist/combobox-B6al50UG.js +1693 -0
- package/dist/combobox-item-D2H1CMxC.d.ts +714 -0
- package/dist/combobox-item-yM6tDrGG.js +225 -0
- package/dist/comparison-B1-nMwmp.d.ts +134 -0
- package/dist/comparison-CyqKrCN-.js +435 -0
- package/dist/components/accordion/accordion.d.ts +2 -0
- package/dist/components/accordion/accordion.js +2 -0
- package/dist/components/accordion-item/accordion-item.d.ts +2 -0
- package/dist/components/accordion-item/accordion-item.js +2 -0
- package/dist/components/action-bar/action-bar.d.ts +2 -0
- package/dist/components/action-bar/action-bar.js +2 -0
- package/dist/components/alert-dialog/alert-dialog.d.ts +2 -0
- package/dist/components/alert-dialog/alert-dialog.js +2 -0
- package/dist/components/avatar/avatar.d.ts +2 -0
- package/dist/components/avatar/avatar.js +2 -0
- package/dist/components/badge/badge.d.ts +2 -0
- package/dist/components/badge/badge.js +2 -0
- package/dist/components/breadcrumb/breadcrumb.d.ts +2 -0
- package/dist/components/breadcrumb/breadcrumb.js +2 -0
- package/dist/components/breadcrumb-item/breadcrumb-item.d.ts +2 -0
- package/dist/components/breadcrumb-item/breadcrumb-item.js +2 -0
- package/dist/components/button/button.d.ts +2 -0
- package/dist/components/button/button.js +2 -0
- package/dist/components/button-group/button-group.d.ts +2 -0
- package/dist/components/button-group/button-group.js +2 -0
- package/dist/components/callout/callout.d.ts +2 -0
- package/dist/components/callout/callout.js +2 -0
- package/dist/components/card/card.d.ts +2 -0
- package/dist/components/card/card.js +2 -0
- package/dist/components/carousel/carousel.d.ts +2 -0
- package/dist/components/carousel/carousel.js +2 -0
- package/dist/components/carousel-item/carousel-item.d.ts +2 -0
- package/dist/components/carousel-item/carousel-item.js +2 -0
- package/dist/components/checkbox/checkbox.d.ts +2 -0
- package/dist/components/checkbox/checkbox.js +2 -0
- package/dist/components/checkbox-group/checkbox-group.d.ts +2 -0
- package/dist/components/checkbox-group/checkbox-group.js +2 -0
- package/dist/components/color-input/color-input.d.ts +2 -0
- package/dist/components/color-input/color-input.js +2 -0
- package/dist/components/color-picker/color-picker.d.ts +2 -0
- package/dist/components/color-picker/color-picker.js +2 -0
- package/dist/components/combobox/combobox.d.ts +2 -0
- package/dist/components/combobox/combobox.js +2 -0
- package/dist/components/combobox-item/combobox-item.d.ts +2 -0
- package/dist/components/combobox-item/combobox-item.js +2 -0
- package/dist/components/comparison/comparison.d.ts +2 -0
- package/dist/components/comparison/comparison.js +2 -0
- package/dist/components/copy/copy.d.ts +2 -0
- package/dist/components/copy/copy.js +291 -0
- package/dist/components/data-table/data-table.d.ts +2 -0
- package/dist/components/data-table/data-table.js +2 -0
- package/dist/components/date/date.d.ts +2 -0
- package/dist/components/date/date.js +2 -0
- package/dist/components/dialog/dialog.d.ts +2 -0
- package/dist/components/dialog/dialog.js +2 -0
- package/dist/components/divider/divider.d.ts +2 -0
- package/dist/components/divider/divider.js +2 -0
- package/dist/components/dropdown/dropdown.d.ts +2 -0
- package/dist/components/dropdown/dropdown.js +2 -0
- package/dist/components/dropdown-item/dropdown-item.d.ts +2 -0
- package/dist/components/dropdown-item/dropdown-item.js +2 -0
- package/dist/components/empty-result/empty-result.d.ts +2 -0
- package/dist/components/empty-result/empty-result.js +2 -0
- package/dist/components/empty-state/empty-state.d.ts +2 -0
- package/dist/components/empty-state/empty-state.js +2 -0
- package/dist/components/expander/expander.d.ts +2 -0
- package/dist/components/expander/expander.js +2 -0
- package/dist/components/field/field.d.ts +2 -0
- package/dist/components/field/field.js +2 -0
- package/dist/components/file-input/file-input.d.ts +2 -0
- package/dist/components/file-input/file-input.js +2 -0
- package/dist/components/filter-bar/filter-bar.d.ts +2 -0
- package/dist/components/filter-bar/filter-bar.js +2 -0
- package/dist/components/form-section/form-section.d.ts +2 -0
- package/dist/components/form-section/form-section.js +2 -0
- package/dist/components/icon/icon.d.ts +2 -0
- package/dist/components/icon/icon.js +2 -0
- package/dist/components/include/include.d.ts +2 -0
- package/dist/components/include/include.js +2 -0
- package/dist/components/index.d.ts +85 -0
- package/dist/components/index.js +86 -0
- package/dist/components/infinite-scroller/infinite-scroller.d.ts +2 -0
- package/dist/components/infinite-scroller/infinite-scroller.js +2 -0
- package/dist/components/intersection-observer/intersection-observer.d.ts +2 -0
- package/dist/components/intersection-observer/intersection-observer.js +2 -0
- package/dist/components/listbox/listbox.d.ts +2 -0
- package/dist/components/listbox/listbox.js +2 -0
- package/dist/components/listbox-item/listbox-item.d.ts +2 -0
- package/dist/components/listbox-item/listbox-item.js +2 -0
- package/dist/components/lorem-ipsum/lorem-ipsum.d.ts +2 -0
- package/dist/components/lorem-ipsum/lorem-ipsum.js +2 -0
- package/dist/components/meter/meter.d.ts +2 -0
- package/dist/components/meter/meter.js +2 -0
- package/dist/components/metric/metric.d.ts +2 -0
- package/dist/components/metric/metric.js +2 -0
- package/dist/components/metric-grid/metric-grid.d.ts +2 -0
- package/dist/components/metric-grid/metric-grid.js +2 -0
- package/dist/components/mutation-observer/mutation-observer.d.ts +2 -0
- package/dist/components/mutation-observer/mutation-observer.js +2 -0
- package/dist/components/navicon/navicon.d.ts +2 -0
- package/dist/components/navicon/navicon.js +2 -0
- package/dist/components/number/number.d.ts +2 -0
- package/dist/components/number/number.js +2 -0
- package/dist/components/number-field/number-field.d.ts +2 -0
- package/dist/components/number-field/number-field.js +2 -0
- package/dist/components/pagination/pagination.d.ts +2 -0
- package/dist/components/pagination/pagination.js +2 -0
- package/dist/components/popover/popover.d.ts +2 -0
- package/dist/components/popover/popover.js +2 -0
- package/dist/components/preview-card/preview-card.d.ts +2 -0
- package/dist/components/preview-card/preview-card.js +2 -0
- package/dist/components/progress/progress.d.ts +2 -0
- package/dist/components/progress/progress.js +2 -0
- package/dist/components/radio/radio.d.ts +2 -0
- package/dist/components/radio/radio.js +2 -0
- package/dist/components/radio-item/radio-item.d.ts +2 -0
- package/dist/components/radio-item/radio-item.js +2 -0
- package/dist/components/random-content/random-content.d.ts +2 -0
- package/dist/components/random-content/random-content.js +2 -0
- package/dist/components/rating/rating.d.ts +2 -0
- package/dist/components/rating/rating.js +2 -0
- package/dist/components/resize-observer/resize-observer.d.ts +2 -0
- package/dist/components/resize-observer/resize-observer.js +2 -0
- package/dist/components/scroll-area/scroll-area.d.ts +2 -0
- package/dist/components/scroll-area/scroll-area.js +2 -0
- package/dist/components/scroller/scroller.d.ts +2 -0
- package/dist/components/scroller/scroller.js +2 -0
- package/dist/components/search-list/search-list.d.ts +2 -0
- package/dist/components/search-list/search-list.js +2 -0
- package/dist/components/select/select.d.ts +2 -0
- package/dist/components/select/select.js +2 -0
- package/dist/components/selection-summary/selection-summary.d.ts +2 -0
- package/dist/components/selection-summary/selection-summary.js +2 -0
- package/dist/components/share/share.d.ts +2 -0
- package/dist/components/share/share.js +2 -0
- package/dist/components/slide-activator/slide-activator.d.ts +2 -0
- package/dist/components/slide-activator/slide-activator.js +2 -0
- package/dist/components/slider/slider.d.ts +2 -0
- package/dist/components/slider/slider.js +2 -0
- package/dist/components/sparkline/sparkline.d.ts +2 -0
- package/dist/components/sparkline/sparkline.js +2 -0
- package/dist/components/spinner/spinner.d.ts +2 -0
- package/dist/components/spinner/spinner.js +2 -0
- package/dist/components/splitter/splitter.d.ts +2 -0
- package/dist/components/splitter/splitter.js +2 -0
- package/dist/components/switch/switch.d.ts +2 -0
- package/dist/components/switch/switch.js +2 -0
- package/dist/components/tab/tab.d.ts +2 -0
- package/dist/components/tab/tab.js +2 -0
- package/dist/components/tab-list/tab-list.d.ts +2 -0
- package/dist/components/tab-list/tab-list.js +2 -0
- package/dist/components/tab-panel/tab-panel.d.ts +2 -0
- package/dist/components/tab-panel/tab-panel.js +2 -0
- package/dist/components/text-area/text-area.d.ts +2 -0
- package/dist/components/text-area/text-area.js +2 -0
- package/dist/components/text-field/text-field.d.ts +2 -0
- package/dist/components/text-field/text-field.js +2 -0
- package/dist/components/text-mask/text-mask.d.ts +2 -0
- package/dist/components/text-mask/text-mask.js +2 -0
- package/dist/components/timed-content/timed-content.d.ts +2 -0
- package/dist/components/timed-content/timed-content.js +2 -0
- package/dist/components/toast/toast.d.ts +2 -0
- package/dist/components/toast/toast.js +2 -0
- package/dist/components/toast-item/toast-item.d.ts +2 -0
- package/dist/components/toast-item/toast-item.js +2 -0
- package/dist/components/toggle-icon/toggle-icon.d.ts +2 -0
- package/dist/components/toggle-icon/toggle-icon.js +2 -0
- package/dist/components/toggle-tag/toggle-tag.d.ts +2 -0
- package/dist/components/toggle-tag/toggle-tag.js +2 -0
- package/dist/components/toolbar/toolbar.d.ts +2 -0
- package/dist/components/toolbar/toolbar.js +2 -0
- package/dist/components/tooltip/tooltip.d.ts +2 -0
- package/dist/components/tooltip/tooltip.js +2 -0
- package/dist/components/transition-group/transition-group.d.ts +2 -0
- package/dist/components/transition-group/transition-group.js +2 -0
- package/dist/components/zoomable-frame/zoomable-frame.d.ts +2 -0
- package/dist/components/zoomable-frame/zoomable-frame.js +2 -0
- package/dist/copy-CvC9vaGw.d.ts +206 -0
- package/dist/copy.styles-DWGvGNTP.js +100 -0
- package/dist/data-table-CITa8DSn.js +247 -0
- package/dist/data-table-DL5RhE0d.d.ts +89 -0
- package/dist/date-CJPmOdi9.js +146 -0
- package/dist/date-DtaTBM71.d.ts +142 -0
- package/dist/decorate-DcF3lt7P.js +9 -0
- package/dist/dialog-Cx46HMaZ.js +983 -0
- package/dist/dialog-N-v0woIy.d.ts +414 -0
- package/dist/divider-9vNsfHW8.js +169 -0
- package/dist/divider-DWuAxcXv.d.ts +79 -0
- package/dist/docs/custom-elements.json +29301 -0
- package/dist/dropdown-BXSKpVX9.js +1123 -0
- package/dist/dropdown-Bo00Vlr5.d.ts +537 -0
- package/dist/dropdown-item-_lIs-Tfd.d.ts +111 -0
- package/dist/dropdown-item-i77cRuN6.js +504 -0
- package/dist/empty-result-B2ln1yFL.js +65 -0
- package/dist/empty-result-B54x_Ab2.d.ts +31 -0
- package/dist/empty-state-BLWjtKUo.js +186 -0
- package/dist/empty-state-SGKjpwp3.d.ts +117 -0
- package/dist/expander-BUev0BmM.d.ts +174 -0
- package/dist/expander-Bwvxj6Oa.js +342 -0
- package/dist/field-BEyS909F.js +163 -0
- package/dist/field-ITx0jVw-.d.ts +69 -0
- package/dist/file-input-BEumLJjg.js +841 -0
- package/dist/file-input-D2D6YC0B.d.ts +378 -0
- package/dist/filter-bar-Bj2QzEn9.d.ts +35 -0
- package/dist/filter-bar-Dcs67aXo.js +66 -0
- package/dist/form-section-BchPetkj.js +83 -0
- package/dist/form-section-xFBTBULQ.d.ts +34 -0
- package/dist/icon-BPVkNsY4.js +165 -0
- package/dist/icon-Ci9CPZJV.d.ts +72 -0
- package/dist/icon-library-D_if7p2h.d.ts +2 -0
- package/dist/include-CQHVVtNs.d.ts +103 -0
- package/dist/include-qNUh_6kT.js +155 -0
- package/dist/index.d.ts +89 -0
- package/dist/index.js +92 -0
- package/dist/infinite-scroller-BmmtnWNt.js +285 -0
- package/dist/infinite-scroller-CuUEAlB9.d.ts +174 -0
- package/dist/intersection-observer-B6TciOAQ.js +503 -0
- package/dist/intersection-observer-B7nmP7Zz.d.ts +418 -0
- package/dist/listbox-C3XXRWGX.js +1257 -0
- package/dist/listbox-DD4ujIJe.d.ts +682 -0
- package/dist/listbox-item-CwD9s3VY.js +135 -0
- package/dist/listbox-item-DQEJWp4Z.d.ts +53 -0
- package/dist/localize-322EtXNX.d.ts +66 -0
- package/dist/lorem-ipsum-B2x3V-v8.js +198 -0
- package/dist/lorem-ipsum-CR82CSuJ.d.ts +130 -0
- package/dist/meter-BC7uaJWf.d.ts +73 -0
- package/dist/meter-BIDyjwFp.js +155 -0
- package/dist/metric-CjlLq_VA.d.ts +36 -0
- package/dist/metric-DbuOcDp_.js +86 -0
- package/dist/metric-grid-C2Pb0Zl3.js +37 -0
- package/dist/metric-grid-C5Xbb1_0.d.ts +27 -0
- package/dist/mutation-observer-BmrZ-GER.d.ts +326 -0
- package/dist/mutation-observer-DS8EBuOp.js +388 -0
- package/dist/navicon-Dic5Qjzb.d.ts +159 -0
- package/dist/navicon-_yMHY27-.js +486 -0
- package/dist/number-BNtNXNF3.js +162 -0
- package/dist/number-BwbnErlB.d.ts +143 -0
- package/dist/number-field-BQHB7UYo.js +726 -0
- package/dist/number-field-odk4lKXM.d.ts +422 -0
- package/dist/pagination-6z2qcf3U.d.ts +322 -0
- package/dist/pagination-DuKPuzdb.js +679 -0
- package/dist/popover-D0sxTU6o.d.ts +259 -0
- package/dist/popover-DJBrJ0za.js +556 -0
- package/dist/preview-card-C7H1FPfd.js +287 -0
- package/dist/preview-card-DitOCZTD.d.ts +86 -0
- package/dist/progress-Db0_axHQ.d.ts +181 -0
- package/dist/progress-DzVk260j.js +494 -0
- package/dist/radio-BtDG9xJM.js +658 -0
- package/dist/radio-CieMa4zU.d.ts +460 -0
- package/dist/radio-item-DIrUStAX.js +264 -0
- package/dist/radio-item-Xq2U3cMu.d.ts +69 -0
- package/dist/random-content-BhSeJFKz.d.ts +380 -0
- package/dist/random-content-BwiirXdG.js +450 -0
- package/dist/rating-4xNsWumY.d.ts +369 -0
- package/dist/rating-C1BcJDIO.js +722 -0
- package/dist/resize-observer-BseSbVWP.d.ts +187 -0
- package/dist/resize-observer-DcrLhddo.js +236 -0
- package/dist/scroll-area-COc1857S.js +127 -0
- package/dist/scroll-area-CVYDf5qY.d.ts +61 -0
- package/dist/scroller-LYgBVyfY.js +590 -0
- package/dist/scroller-bB2rGs7b.d.ts +374 -0
- package/dist/search-list-Clmrg8EV.js +884 -0
- package/dist/search-list-n0GYO7rh.d.ts +777 -0
- package/dist/select-CkZK2jJn.d.ts +506 -0
- package/dist/select-DLIaRnA4.js +690 -0
- package/dist/selection-summary-BVnNJ8Lw.js +48 -0
- package/dist/selection-summary-DmFkGyZI.d.ts +34 -0
- package/dist/share-DPlqP2dc.d.ts +162 -0
- package/dist/share-bsgXZCl7.js +250 -0
- package/dist/sigvelo.d.ts +5 -0
- package/dist/sigvelo.js +5 -0
- package/dist/sigvelo.loader.d.ts +3 -0
- package/dist/sigvelo.loader.js +102 -0
- package/dist/slide-activator-D7bBz69E.d.ts +429 -0
- package/dist/slide-activator-DlxQt9R9.js +798 -0
- package/dist/slider-B0FVsV1o.d.ts +921 -0
- package/dist/slider-B90Il7x3.js +1744 -0
- package/dist/sparkline-CcpTaJ_Z.js +358 -0
- package/dist/sparkline-DlCIt81-.d.ts +235 -0
- package/dist/spinner-C04Dmc0H.js +188 -0
- package/dist/spinner-CZ19x_dC.d.ts +99 -0
- package/dist/splitter-DBDJAzsp.d.ts +325 -0
- package/dist/splitter-MnD4In9H.js +638 -0
- package/dist/switch-CPaEKbog.js +581 -0
- package/dist/switch-Cief9M59.d.ts +248 -0
- package/dist/tab-BcqYGsuW.d.ts +44 -0
- package/dist/tab-C-FtuNmh.js +102 -0
- package/dist/tab-list-B_Ye_Oj9.js +691 -0
- package/dist/tab-list-DDvS8qHr.d.ts +450 -0
- package/dist/tab-panel-BaBl6eep.js +60 -0
- package/dist/tab-panel-BzSJlSfd.d.ts +38 -0
- package/dist/text-area-B_mjCE9W.d.ts +327 -0
- package/dist/text-area-Czixaz-_.js +556 -0
- package/dist/text-field-BClWMp6q.d.ts +424 -0
- package/dist/text-field-inpJfp0A.js +687 -0
- package/dist/text-mask-CNKVKSFp.d.ts +336 -0
- package/dist/text-mask-DDEurj90.js +370 -0
- package/dist/themes/sigvelo.css +10 -0
- package/dist/themes/utilities.css +9 -0
- package/dist/timed-content-D2mGFamc.d.ts +181 -0
- package/dist/timed-content-pvEP4l5V.js +226 -0
- package/dist/toast-BnZaIg6Z.js +636 -0
- package/dist/toast-cEBVK9NQ.d.ts +487 -0
- package/dist/toast-item-BPpJT6vD.d.ts +159 -0
- package/dist/toast-item-IS8IFUEg.js +372 -0
- package/dist/toggle-icon-4oLDeEt4.js +752 -0
- package/dist/toggle-icon-DlwMMWZL.d.ts +359 -0
- package/dist/toggle-tag-1sfTFJtg.js +434 -0
- package/dist/toggle-tag-IVvMGT4R.d.ts +245 -0
- package/dist/toolbar-CABq0ZL1.d.ts +122 -0
- package/dist/toolbar-CEZ0-F-X.js +196 -0
- package/dist/tooltip-DbyoPFNe.js +521 -0
- package/dist/tooltip-ahFthek8.d.ts +192 -0
- package/dist/transition-group-3hnAnwSd.js +801 -0
- package/dist/transition-group-DD_CjSNC.d.ts +608 -0
- package/dist/translations/en.d.ts +6 -0
- package/dist/translations/en.js +75 -0
- package/dist/translations/es.d.ts +6 -0
- package/dist/translations/es.js +75 -0
- package/dist/types/custom-element-jsx.d.ts +13723 -0
- package/dist/utilities/icon-library.d.ts +3 -0
- package/dist/utilities/icon-library.js +93 -0
- package/dist/utilities/localize.d.ts +2 -0
- package/dist/utilities/localize.js +6 -0
- package/dist/zoomable-frame-Cldvj5sE.js +398 -0
- package/dist/zoomable-frame-r6S6587z.d.ts +162 -0
- package/package.json +83 -0
|
@@ -0,0 +1,581 @@
|
|
|
1
|
+
import "./icon-BPVkNsY4.js";
|
|
2
|
+
import { t as __decorate } from "./decorate-DcF3lt7P.js";
|
|
3
|
+
import { css, html } from "lit";
|
|
4
|
+
import { property, query, state } from "lit/decorators.js";
|
|
5
|
+
import hostStyles from "@mcp-b/wc-support/styles/host.styles";
|
|
6
|
+
import { SigveloFormControlElement } from "@mcp-b/wc-support/base/sigvelo-element";
|
|
7
|
+
import { classMap } from "lit/directives/class-map.js";
|
|
8
|
+
import { ifDefined } from "lit/directives/if-defined.js";
|
|
9
|
+
import { SigveloBlurEvent, SigveloChangeEvent, SigveloFocusEvent, SigveloInputEvent } from "@mcp-b/wc-support/events/form";
|
|
10
|
+
import { live } from "lit/directives/live.js";
|
|
11
|
+
//#region src/components/switch/switch.styles.ts
|
|
12
|
+
var switch_styles_default = css`
|
|
13
|
+
:host {
|
|
14
|
+
display: inline-grid;
|
|
15
|
+
grid-template-columns: auto 1fr;
|
|
16
|
+
align-items: start;
|
|
17
|
+
gap: 0.5em;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/* Sizes */
|
|
21
|
+
:host([size="xs"]) {
|
|
22
|
+
font-size: var(--sigvelo-control-text-xs);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
:host([size="sm"]) {
|
|
26
|
+
font-size: var(--sigvelo-control-text-sm);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
:host([size="md"]) {
|
|
30
|
+
font-size: var(--sigvelo-control-text-md);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
:host([size="lg"]) {
|
|
34
|
+
font-size: var(--sigvelo-control-text-lg);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
:host([size="xl"]) {
|
|
38
|
+
font-size: var(--sigvelo-control-text-xl);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/* The switch's label */
|
|
42
|
+
#label {
|
|
43
|
+
display: contents; /* Makes children participate in the grid */
|
|
44
|
+
cursor: pointer;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
:host(:state(disabled)) #label {
|
|
48
|
+
cursor: not-allowed;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
#visual-box {
|
|
52
|
+
--height: 1.5em;
|
|
53
|
+
--width: calc(var(--height) * 2);
|
|
54
|
+
--thumb-size: calc(var(--height) - 0.25em);
|
|
55
|
+
--thumb-padding: calc((var(--height) - var(--thumb-size)) / 2);
|
|
56
|
+
display: flex;
|
|
57
|
+
position: relative;
|
|
58
|
+
grid-row: 1;
|
|
59
|
+
grid-column: 1;
|
|
60
|
+
flex: 0 0 auto;
|
|
61
|
+
align-items: center;
|
|
62
|
+
align-self: center; /* Vertically center with label text */
|
|
63
|
+
width: var(--width);
|
|
64
|
+
height: var(--height);
|
|
65
|
+
border-radius: var(--sigvelo-radius-full);
|
|
66
|
+
background-color: var(--sigvelo-color-neutral-bg-subtle);
|
|
67
|
+
transition:
|
|
68
|
+
var(--sigvelo-motion-duration-interaction) background-color ease,
|
|
69
|
+
var(--sigvelo-motion-duration-interaction) border-color ease;
|
|
70
|
+
|
|
71
|
+
&.checked {
|
|
72
|
+
border-color: transparent;
|
|
73
|
+
background-color: var(--sigvelo-color-primary-bg);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
&:has(:focus-visible) {
|
|
77
|
+
outline: var(--sigvelo-border-style) calc(var(--sigvelo-border-width) + 1px)
|
|
78
|
+
var(--sigvelo-color-focus);
|
|
79
|
+
outline-offset: var(--sigvelo-border-width);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/* Thumb */
|
|
83
|
+
#thumb {
|
|
84
|
+
position: absolute;
|
|
85
|
+
top: calc(50% - (var(--thumb-size) / 2));
|
|
86
|
+
width: var(--thumb-size);
|
|
87
|
+
height: var(--thumb-size);
|
|
88
|
+
border-radius: var(--sigvelo-radius-full);
|
|
89
|
+
background-color: var(--sigvelo-color-canvas);
|
|
90
|
+
transition:
|
|
91
|
+
var(--sigvelo-motion-duration-interaction) width ease,
|
|
92
|
+
var(--sigvelo-motion-duration-interaction) left ease,
|
|
93
|
+
var(--sigvelo-motion-duration-interaction) right ease;
|
|
94
|
+
|
|
95
|
+
&:dir(ltr) {
|
|
96
|
+
left: var(--thumb-padding);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
&:dir(rtl) {
|
|
100
|
+
right: var(--thumb-padding);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
&.checked #thumb {
|
|
105
|
+
&:dir(ltr) {
|
|
106
|
+
left: calc(100% - var(--thumb-size) - var(--thumb-padding));
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
&:dir(rtl) {
|
|
110
|
+
right: calc(100% - var(--thumb-size) - var(--thumb-padding));
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/* Stretch the thumb when active */
|
|
115
|
+
&:active:not(.disabled) #thumb {
|
|
116
|
+
width: calc(var(--thumb-size) * 1.25);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
&.checked:not(.disabled):active #thumb {
|
|
120
|
+
&:dir(ltr) {
|
|
121
|
+
left: calc(100% - calc(var(--thumb-size) * 1.25) - var(--thumb-padding));
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
&:dir(rtl) {
|
|
125
|
+
right: calc(100% - calc(var(--thumb-size) * 1.25) - var(--thumb-padding));
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/* Inner labels */
|
|
130
|
+
#on-label,
|
|
131
|
+
#off-label {
|
|
132
|
+
display: flex;
|
|
133
|
+
align-items: center;
|
|
134
|
+
justify-content: center;
|
|
135
|
+
width: 50%;
|
|
136
|
+
overflow: hidden;
|
|
137
|
+
font-weight: var(--sigvelo-font-weight-semibold);
|
|
138
|
+
font-size: 0.625em;
|
|
139
|
+
text-transform: uppercase;
|
|
140
|
+
white-space: nowrap;
|
|
141
|
+
transition:
|
|
142
|
+
var(--sigvelo-motion-duration-interaction) opacity ease,
|
|
143
|
+
var(--sigvelo-motion-duration-interaction) translate ease;
|
|
144
|
+
|
|
145
|
+
::slotted(sigvelo-icon) {
|
|
146
|
+
font-size: 1.75em;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
#on-label {
|
|
151
|
+
margin-inline-start: calc(var(--thumb-padding) * 2);
|
|
152
|
+
color: var(--sigvelo-color-primary-text-on-bg);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
#off-label {
|
|
156
|
+
margin-inline-end: calc(var(--thumb-padding) * 2);
|
|
157
|
+
color: var(--sigvelo-color-primary-text-on-subtle);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
&:not(.checked) #on-label {
|
|
161
|
+
opacity: 0;
|
|
162
|
+
|
|
163
|
+
&:dir(ltr) {
|
|
164
|
+
translate: 50%;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
&:dir(rtl) {
|
|
168
|
+
translate: -50%;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
&.checked #off-label {
|
|
173
|
+
opacity: 0;
|
|
174
|
+
|
|
175
|
+
&:dir(ltr) {
|
|
176
|
+
translate: -50%;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
&:dir(rtl) {
|
|
180
|
+
translate: 50%;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/* The actual checkbox control */
|
|
185
|
+
#switch {
|
|
186
|
+
appearance: none;
|
|
187
|
+
z-index: 1;
|
|
188
|
+
position: absolute;
|
|
189
|
+
top: 0;
|
|
190
|
+
left: 0;
|
|
191
|
+
width: 100%;
|
|
192
|
+
height: 100%;
|
|
193
|
+
margin: 0;
|
|
194
|
+
padding: 0;
|
|
195
|
+
border: none;
|
|
196
|
+
background: none;
|
|
197
|
+
cursor: inherit;
|
|
198
|
+
|
|
199
|
+
&:focus {
|
|
200
|
+
outline: none;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/* Label slot content */
|
|
206
|
+
#label > slot {
|
|
207
|
+
grid-row: 1;
|
|
208
|
+
grid-column: 2;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
:host(:state(disabled)) {
|
|
212
|
+
cursor: not-allowed;
|
|
213
|
+
opacity: 0.5;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
#description {
|
|
217
|
+
display: block;
|
|
218
|
+
grid-row: 2;
|
|
219
|
+
grid-column: 2;
|
|
220
|
+
margin-block-start: -0.5em;
|
|
221
|
+
color: var(--sigvelo-color-text-muted);
|
|
222
|
+
font-size: max(12px, 0.875em); /* never smaller than 12px */
|
|
223
|
+
}
|
|
224
|
+
`;
|
|
225
|
+
//#endregion
|
|
226
|
+
//#region src/components/switch/switch.ts
|
|
227
|
+
/**
|
|
228
|
+
* <sigvelo-switch>
|
|
229
|
+
*
|
|
230
|
+
* @summary Allows the user to toggle between two mutually exclusive states, such as on and off.
|
|
231
|
+
* @tag sigvelo-switch
|
|
232
|
+
* @documentation https://design-system.sigvelo.com/docs/components/switch
|
|
233
|
+
* @status stable
|
|
234
|
+
* @since 1.0
|
|
235
|
+
*
|
|
236
|
+
* @dependency sigvelo-icon
|
|
237
|
+
*
|
|
238
|
+
* @slot - The switch's label. For plain-text labels, you can use the `label` attribute instead.
|
|
239
|
+
* @slot description - The switch's description. For plain-text descriptions, you can use the `description` attribute
|
|
240
|
+
* instead.
|
|
241
|
+
* @slot off-label - The label to show when the switch is off.
|
|
242
|
+
* @slot on-label - The label to show when the switch is on.
|
|
243
|
+
*
|
|
244
|
+
* @event sigvelo-blur - Emitted when the switch loses focus. This event does not bubble.
|
|
245
|
+
* @event sigvelo-change - Emitted when the user commits changes to the switch's value.
|
|
246
|
+
* @event sigvelo-focus - Emitted when the switch receives focus. This event does not bubble.
|
|
247
|
+
* @event sigvelo-input - Emitted when the switch receives input.
|
|
248
|
+
*
|
|
249
|
+
* @csspart label - The `<label>` that wraps the entire control.
|
|
250
|
+
* @csspart description - The element that contains the switch's description.
|
|
251
|
+
* @csspart visual-box - The element that wraps the internal switch.
|
|
252
|
+
* @csspart switch - The internal switch, an `<input type="checkbox" role="switch">` element.
|
|
253
|
+
* @csspart thumb - The switch's thumb.
|
|
254
|
+
* @csspart on-label - The container wrapping the `on-label`.
|
|
255
|
+
* @csspart off-label - The container wrapping the `off-label`.
|
|
256
|
+
*
|
|
257
|
+
* @cssstate disabled - Applied when the switch is disabled.
|
|
258
|
+
* @cssstate focused - Applied when the switch has focus.
|
|
259
|
+
* @cssstate user-valid - Applied when the switch is valid and the user has sufficiently interacted with it.
|
|
260
|
+
* @cssstate user-invalid - Applied when the switch is invalid and the user has sufficiently interacted with it.
|
|
261
|
+
*
|
|
262
|
+
* @example Default
|
|
263
|
+
* ```html
|
|
264
|
+
* <sigvelo-switch name="mode" value="kitten">Kitten mode</sigvelo-switch>
|
|
265
|
+
* ```
|
|
266
|
+
*
|
|
267
|
+
* @example Labels and descriptions
|
|
268
|
+
* The switch's label is provided via its default slot. You can use the `description` attribute to provide a plain text description. If you want to provide HTML, use the `description` slot instead.
|
|
269
|
+
*
|
|
270
|
+
* ```html
|
|
271
|
+
* <sigvelo-switch name="notifications" value="enabled">
|
|
272
|
+
* Enable notifications
|
|
273
|
+
* <span slot="description">
|
|
274
|
+
* Get updates when your cat takes a nap. <a href="#">Learn more</a>
|
|
275
|
+
* </span>
|
|
276
|
+
* </sigvelo-switch>
|
|
277
|
+
* ```
|
|
278
|
+
*
|
|
279
|
+
* @example Checked initially
|
|
280
|
+
* Add the `checked` attribute to check the switch initially.
|
|
281
|
+
*
|
|
282
|
+
* ```html
|
|
283
|
+
* <sigvelo-switch name="mode" value="kitten" checked>Kitten mode</sigvelo-switch>
|
|
284
|
+
* ```
|
|
285
|
+
*
|
|
286
|
+
*
|
|
287
|
+
* Use the `on` and `off` slots to show inner labels or icons that align with the switch's checked state. Space is very limited, so make sure the labels are short enough to fit.
|
|
288
|
+
*
|
|
289
|
+
* ```html
|
|
290
|
+
* <sigvelo-switch name="mode" value="kitten">
|
|
291
|
+
* Kitten mode
|
|
292
|
+
* <span slot="on-label">on</span>
|
|
293
|
+
* <span slot="off-label">off</span>
|
|
294
|
+
* </sigvelo-switch>
|
|
295
|
+
*
|
|
296
|
+
* <sigvelo-switch name="mode" value="kitten">
|
|
297
|
+
* Kitten mode
|
|
298
|
+
* <sigvelo-icon slot="on-label" name="check" label="On"></sigvelo-icon>
|
|
299
|
+
* <sigvelo-icon slot="off-label" name="x" label="Off"></sigvelo-icon>
|
|
300
|
+
* </sigvelo-switch>
|
|
301
|
+
* ```
|
|
302
|
+
*
|
|
303
|
+
* @example Changing the size
|
|
304
|
+
* Use the `size` attribute to change the text field's size.
|
|
305
|
+
*
|
|
306
|
+
* ```html
|
|
307
|
+
* <sigvelo-switch size="xs">Extra small</sigvelo-switch>
|
|
308
|
+
* <sigvelo-switch size="sm">Small</sigvelo-switch>
|
|
309
|
+
* <sigvelo-switch size="md">Medium</sigvelo-switch>
|
|
310
|
+
* <sigvelo-switch size="lg">Large</sigvelo-switch>
|
|
311
|
+
* <sigvelo-switch size="xl">Extra large</sigvelo-switch>
|
|
312
|
+
* ```
|
|
313
|
+
*
|
|
314
|
+
* @example Disabling
|
|
315
|
+
* Use the `disabled` attribute to disable the switch.
|
|
316
|
+
*
|
|
317
|
+
* ```html
|
|
318
|
+
* <sigvelo-switch disabled>Unchecked and disabled</sigvelo-switch><br>
|
|
319
|
+
* <sigvelo-switch checked disabled>Checked and disabled</sigvelo-switch>
|
|
320
|
+
* ```
|
|
321
|
+
*
|
|
322
|
+
* @example Validation
|
|
323
|
+
* The `required` attribute can be applied to enable validation using the Constraint Validation API. This will prevent form submission until the switch is checked.
|
|
324
|
+
*
|
|
325
|
+
* ```html
|
|
326
|
+
* <form action="about:blank" method="get" target="_blank">
|
|
327
|
+
* <sigvelo-switch name="sleep" value="zzz" required>Sleep mode</sigvelo-switch>
|
|
328
|
+
* <br><br>
|
|
329
|
+
* <sigvelo-button type="submit" color="primary">Submit</sigvelo-button>
|
|
330
|
+
* <sigvelo-button type="reset">Reset</sigvelo-button>
|
|
331
|
+
* </form>
|
|
332
|
+
* ```
|
|
333
|
+
*
|
|
334
|
+
* @example Using custom validation
|
|
335
|
+
* Use the `setCustomValidity()` method to make the switch invalid and show a custom error message on submit. This will override all other validation parameters. To clear the error, remove the attribute or set it to an empty string.
|
|
336
|
+
*
|
|
337
|
+
* ```html
|
|
338
|
+
* <form action="about:blank" method="get" target="_blank" id="switch__custom-validation">
|
|
339
|
+
* <sigvelo-switch name="sleep" value="zzz" required>Sleep mode</sigvelo-switch>
|
|
340
|
+
* <br><br>
|
|
341
|
+
* <sigvelo-button type="submit" color="primary">Submit</sigvelo-button>
|
|
342
|
+
* <sigvelo-button type="reset">Reset</sigvelo-button>
|
|
343
|
+
* </form>
|
|
344
|
+
*
|
|
345
|
+
* <script type="module">
|
|
346
|
+
* import { allDefined } from '/dist/sigvelo.js';
|
|
347
|
+
*
|
|
348
|
+
* await allDefined();
|
|
349
|
+
*
|
|
350
|
+
* const form = document.getElementById('switch__custom-validation');
|
|
351
|
+
* const toggle = form.querySelector('sigvelo-switch');
|
|
352
|
+
*
|
|
353
|
+
* toggle.setCustomValidity('Have you taken a nap first?');
|
|
354
|
+
* <\/script>
|
|
355
|
+
* ```
|
|
356
|
+
*
|
|
357
|
+
* @example Styling validation
|
|
358
|
+
* You can style valid and invalid switches using the `:valid` and `:invalid` pseudo classes.
|
|
359
|
+
*
|
|
360
|
+
* ```html
|
|
361
|
+
* <form action="about:blank" method="get" target="_blank" class="switch__validation-pseudo">
|
|
362
|
+
* <sigvelo-switch name="sleep" value="zzz" required>Sleep mode</sigvelo-switch>
|
|
363
|
+
* <br><br>
|
|
364
|
+
* <sigvelo-button type="submit" color="primary">Submit</sigvelo-button>
|
|
365
|
+
* <sigvelo-button type="reset">Reset</sigvelo-button>
|
|
366
|
+
* </form>
|
|
367
|
+
*
|
|
368
|
+
* <style>
|
|
369
|
+
* .switch__validation-pseudo {
|
|
370
|
+
* sigvelo-switch:valid {
|
|
371
|
+
* outline: solid 2px var(--sigvelo-color-success-border);
|
|
372
|
+
* outline-offset: .5rem;
|
|
373
|
+
* }
|
|
374
|
+
*
|
|
375
|
+
* sigvelo-switch:invalid {
|
|
376
|
+
* outline: solid 2px var(--sigvelo-color-danger-border);
|
|
377
|
+
* outline-offset: .5rem;
|
|
378
|
+
* }
|
|
379
|
+
* }
|
|
380
|
+
* </style>
|
|
381
|
+
* ```
|
|
382
|
+
*
|
|
383
|
+
* However, these selectors will match even before the user has had a chance to fill out the form. More often than not, you'll want to use the `user-valid` and `user-invalid` custom states instead. This way, validation styles are only shown _after_ the user interacts with the form control or when the form is submitted.
|
|
384
|
+
*
|
|
385
|
+
* ```html
|
|
386
|
+
* <form action="about:blank" method="get" target="_blank" class="switch__validation-custom">
|
|
387
|
+
* <sigvelo-switch name="sleep" value="zzz" required>Sleep mode</sigvelo-switch>
|
|
388
|
+
* <br><br>
|
|
389
|
+
* <sigvelo-button type="submit" color="primary">Submit</sigvelo-button>
|
|
390
|
+
* <sigvelo-button type="reset">Reset</sigvelo-button>
|
|
391
|
+
* </form>
|
|
392
|
+
*
|
|
393
|
+
* <style>
|
|
394
|
+
* .switch__validation-custom {
|
|
395
|
+
* sigvelo-switch:state(user-valid) {
|
|
396
|
+
* outline: solid 2px var(--sigvelo-color-success-border);
|
|
397
|
+
* outline-offset: .5rem;
|
|
398
|
+
* }
|
|
399
|
+
*
|
|
400
|
+
* sigvelo-switch:state(user-invalid) {
|
|
401
|
+
* outline: solid 2px var(--sigvelo-color-danger-border);
|
|
402
|
+
* outline-offset: .5rem;
|
|
403
|
+
* }
|
|
404
|
+
* }
|
|
405
|
+
* </style>
|
|
406
|
+
* ```
|
|
407
|
+
*/
|
|
408
|
+
var SigveloSwitch = class extends SigveloFormControlElement {
|
|
409
|
+
constructor(..._args) {
|
|
410
|
+
super(..._args);
|
|
411
|
+
this.isInvalid = false;
|
|
412
|
+
this.hadUserInteraction = false;
|
|
413
|
+
this.wasSubmitted = false;
|
|
414
|
+
this.value = "";
|
|
415
|
+
this.checked = false;
|
|
416
|
+
this.disabled = false;
|
|
417
|
+
this.size = "md";
|
|
418
|
+
this.required = false;
|
|
419
|
+
}
|
|
420
|
+
static {
|
|
421
|
+
this.formAssociated = true;
|
|
422
|
+
}
|
|
423
|
+
static {
|
|
424
|
+
this.observeSlots = true;
|
|
425
|
+
}
|
|
426
|
+
static {
|
|
427
|
+
this.styles = [hostStyles, switch_styles_default];
|
|
428
|
+
}
|
|
429
|
+
get focusableAnchor() {
|
|
430
|
+
return this.switch;
|
|
431
|
+
}
|
|
432
|
+
connectedCallback() {
|
|
433
|
+
super.connectedCallback();
|
|
434
|
+
this.addEventListener("invalid", this.handleHostInvalid);
|
|
435
|
+
}
|
|
436
|
+
disconnectedCallback() {
|
|
437
|
+
super.disconnectedCallback();
|
|
438
|
+
this.removeEventListener("invalid", this.handleHostInvalid);
|
|
439
|
+
}
|
|
440
|
+
updated(changedProperties) {
|
|
441
|
+
this.updateValidity();
|
|
442
|
+
if (changedProperties.has("checked") || changedProperties.has("value")) this.internals.setFormValue(this.checked ? this.value : null);
|
|
443
|
+
if (changedProperties.has("disabled")) this.customStates.set("disabled", this.disabled);
|
|
444
|
+
if (this.hadUserInteraction || this.wasSubmitted) {
|
|
445
|
+
this.customStates.set("user-invalid", this.isInvalid);
|
|
446
|
+
this.customStates.set("user-valid", !this.isInvalid);
|
|
447
|
+
} else {
|
|
448
|
+
this.customStates.set("user-invalid", false);
|
|
449
|
+
this.customStates.set("user-valid", false);
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
/** @internal Called when a containing fieldset is disabled. */
|
|
453
|
+
formDisabledCallback(isDisabled) {
|
|
454
|
+
this.disabled = isDisabled;
|
|
455
|
+
}
|
|
456
|
+
/** @internal Called when the form is reset. */
|
|
457
|
+
formResetCallback() {
|
|
458
|
+
this.isInvalid = false;
|
|
459
|
+
this.hadUserInteraction = false;
|
|
460
|
+
this.wasSubmitted = false;
|
|
461
|
+
this.checked = this.hasAttribute("checked");
|
|
462
|
+
}
|
|
463
|
+
handleClick() {
|
|
464
|
+
this.checked = !this.checked;
|
|
465
|
+
}
|
|
466
|
+
handleBlur() {
|
|
467
|
+
this.customStates.set("focused", false);
|
|
468
|
+
this.dispatchEvent(new SigveloBlurEvent());
|
|
469
|
+
}
|
|
470
|
+
handleChange() {
|
|
471
|
+
this.hadUserInteraction = true;
|
|
472
|
+
this.dispatchEvent(new SigveloChangeEvent());
|
|
473
|
+
this.dispatchEvent(new Event("change", {
|
|
474
|
+
bubbles: true,
|
|
475
|
+
composed: true
|
|
476
|
+
}));
|
|
477
|
+
}
|
|
478
|
+
handleInput() {
|
|
479
|
+
this.dispatchEvent(new SigveloInputEvent());
|
|
480
|
+
}
|
|
481
|
+
handleKeyUp(event) {
|
|
482
|
+
if (event.key === "Enter" && !this.disabled) this.handleClick();
|
|
483
|
+
}
|
|
484
|
+
handleFocus() {
|
|
485
|
+
this.customStates.set("focused", true);
|
|
486
|
+
this.dispatchEvent(new SigveloFocusEvent());
|
|
487
|
+
}
|
|
488
|
+
handleHostInvalid() {
|
|
489
|
+
this.wasSubmitted = true;
|
|
490
|
+
}
|
|
491
|
+
/** Sets the form control's validity */
|
|
492
|
+
async updateValidity() {
|
|
493
|
+
await this.updateComplete;
|
|
494
|
+
const hasCustomValidity = this.getCustomValidity().length > 0;
|
|
495
|
+
const validationMessage = hasCustomValidity ? this.getCustomValidity() : this.switch.validationMessage;
|
|
496
|
+
const flags = {
|
|
497
|
+
customError: hasCustomValidity,
|
|
498
|
+
valueMissing: this.switch.validity.valueMissing
|
|
499
|
+
};
|
|
500
|
+
this.isInvalid = hasCustomValidity ? true : !this.switch.validity.valid;
|
|
501
|
+
this.internals.setValidity(flags, validationMessage, this.focusableAnchor);
|
|
502
|
+
}
|
|
503
|
+
/** Sets focus to the switch. */
|
|
504
|
+
focus() {
|
|
505
|
+
this.switch.focus();
|
|
506
|
+
}
|
|
507
|
+
/** Removes focus from the switch. */
|
|
508
|
+
blur() {
|
|
509
|
+
this.switch.blur();
|
|
510
|
+
}
|
|
511
|
+
render() {
|
|
512
|
+
const hasDescription = this.description || this.slotsWithContent.has("description");
|
|
513
|
+
return html`
|
|
514
|
+
<label part="label" id="label">
|
|
515
|
+
<div
|
|
516
|
+
id="visual-box"
|
|
517
|
+
part="visual-box"
|
|
518
|
+
class=${classMap({
|
|
519
|
+
xs: this.size === "xs",
|
|
520
|
+
sm: this.size === "sm",
|
|
521
|
+
md: this.size === "md",
|
|
522
|
+
lg: this.size === "lg",
|
|
523
|
+
xl: this.size === "xl",
|
|
524
|
+
checked: this.checked,
|
|
525
|
+
disabled: this.disabled,
|
|
526
|
+
required: this.required
|
|
527
|
+
})}
|
|
528
|
+
>
|
|
529
|
+
<input
|
|
530
|
+
id="switch"
|
|
531
|
+
part="switch"
|
|
532
|
+
type="checkbox"
|
|
533
|
+
value=${ifDefined(this.value)}
|
|
534
|
+
role="switch"
|
|
535
|
+
aria-checked=${this.checked ? "true" : "false"}
|
|
536
|
+
aria-describedby="description"
|
|
537
|
+
.checked=${live(this.checked)}
|
|
538
|
+
.disabled=${this.disabled}
|
|
539
|
+
.required=${this.required}
|
|
540
|
+
@change=${this.handleChange}
|
|
541
|
+
@click=${this.handleClick}
|
|
542
|
+
@input=${this.handleInput}
|
|
543
|
+
@keyup=${this.handleKeyUp}
|
|
544
|
+
@focus=${this.handleFocus}
|
|
545
|
+
@blur=${this.handleBlur}
|
|
546
|
+
/>
|
|
547
|
+
<span id="on-label" part="on-label"><slot name="on-label"></slot></span>
|
|
548
|
+
<span id="off-label" part="off-label"><slot name="off-label"></slot></span>
|
|
549
|
+
<span id="thumb" part="thumb"></span>
|
|
550
|
+
</div>
|
|
551
|
+
<slot>${this.label}</slot>
|
|
552
|
+
</label>
|
|
553
|
+
|
|
554
|
+
<div id="description" part="description" class=${classMap({ vh: !hasDescription })}>
|
|
555
|
+
<slot name="description">${this.description}</slot>
|
|
556
|
+
</div>
|
|
557
|
+
`;
|
|
558
|
+
}
|
|
559
|
+
};
|
|
560
|
+
__decorate([query("input[type=\"checkbox\"]")], SigveloSwitch.prototype, "switch", void 0);
|
|
561
|
+
__decorate([state()], SigveloSwitch.prototype, "isInvalid", void 0);
|
|
562
|
+
__decorate([state()], SigveloSwitch.prototype, "hadUserInteraction", void 0);
|
|
563
|
+
__decorate([state()], SigveloSwitch.prototype, "wasSubmitted", void 0);
|
|
564
|
+
__decorate([property()], SigveloSwitch.prototype, "label", void 0);
|
|
565
|
+
__decorate([property()], SigveloSwitch.prototype, "description", void 0);
|
|
566
|
+
__decorate([property({ reflect: true })], SigveloSwitch.prototype, "name", void 0);
|
|
567
|
+
__decorate([property()], SigveloSwitch.prototype, "value", void 0);
|
|
568
|
+
__decorate([property({ type: Boolean })], SigveloSwitch.prototype, "checked", void 0);
|
|
569
|
+
__decorate([property({
|
|
570
|
+
type: Boolean,
|
|
571
|
+
reflect: true
|
|
572
|
+
})], SigveloSwitch.prototype, "disabled", void 0);
|
|
573
|
+
__decorate([property()], SigveloSwitch.prototype, "size", void 0);
|
|
574
|
+
__decorate([property()], SigveloSwitch.prototype, "form", void 0);
|
|
575
|
+
__decorate([property({
|
|
576
|
+
type: Boolean,
|
|
577
|
+
reflect: true
|
|
578
|
+
})], SigveloSwitch.prototype, "required", void 0);
|
|
579
|
+
customElements.define("sigvelo-switch", SigveloSwitch);
|
|
580
|
+
//#endregion
|
|
581
|
+
export { SigveloSwitch as t };
|