@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,894 @@
|
|
|
1
|
+
import { Localize } from "./utilities/localize.js";
|
|
2
|
+
import { t as __decorate } from "./decorate-DcF3lt7P.js";
|
|
3
|
+
import "./color-picker-adwOmtRl.js";
|
|
4
|
+
import { css, html } from "lit";
|
|
5
|
+
import { property, query, state } from "lit/decorators.js";
|
|
6
|
+
import hostStyles from "@mcp-b/wc-support/styles/host.styles";
|
|
7
|
+
import { SigveloFormControlElement } from "@mcp-b/wc-support/base/sigvelo-element";
|
|
8
|
+
import { classMap } from "lit/directives/class-map.js";
|
|
9
|
+
import { animateWithClass } from "@mcp-b/wc-support/utilities/animate";
|
|
10
|
+
import { ifDefined } from "lit/directives/if-defined.js";
|
|
11
|
+
import { SigveloBlurEvent, SigveloChangeEvent, SigveloFocusEvent, SigveloInputEvent } from "@mcp-b/wc-support/events/form";
|
|
12
|
+
import { live } from "lit/directives/live.js";
|
|
13
|
+
import formControlStyles from "@mcp-b/wc-support/styles/form-control.styles";
|
|
14
|
+
import { autoUpdate, computePosition, flip, offset, shift } from "@floating-ui/dom";
|
|
15
|
+
//#region src/components/color-input/color-input.styles.ts
|
|
16
|
+
var color_input_styles_default = css`
|
|
17
|
+
:host {
|
|
18
|
+
--show-duration: var(--sigvelo-motion-duration-interaction);
|
|
19
|
+
--preview-size: 1.5em;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/* Pills */
|
|
23
|
+
#visual-box.pill {
|
|
24
|
+
padding: 0 0.5em;
|
|
25
|
+
border-radius: var(--sigvelo-radius-full);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
:host(:state(open):not(:state(disabled)) #visual-box:is(.normal, .filled)) {
|
|
29
|
+
outline: var(--sigvelo-border-style) calc(var(--sigvelo-border-width) + 1px)
|
|
30
|
+
var(--sigvelo-color-focus);
|
|
31
|
+
outline-offset: calc(-1 * var(--sigvelo-border-width));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
#preview {
|
|
35
|
+
position: relative;
|
|
36
|
+
aspect-ratio: 1;
|
|
37
|
+
width: var(--preview-size);
|
|
38
|
+
height: var(--preview-size);
|
|
39
|
+
border-radius: var(--sigvelo-radius-circle);
|
|
40
|
+
background-image:
|
|
41
|
+
linear-gradient(45deg, var(--sigvelo-color-neutral-bg-muted) 25%, transparent 25%),
|
|
42
|
+
linear-gradient(45deg, transparent 75%, var(--sigvelo-color-neutral-bg-muted) 75%),
|
|
43
|
+
linear-gradient(45deg, transparent 75%, var(--sigvelo-color-neutral-bg-muted) 75%),
|
|
44
|
+
linear-gradient(45deg, var(--sigvelo-color-neutral-bg-muted) 25%, transparent 25%);
|
|
45
|
+
background-position:
|
|
46
|
+
0 0,
|
|
47
|
+
0 0,
|
|
48
|
+
-0.25em -0.25em,
|
|
49
|
+
0.25em 0.25em;
|
|
50
|
+
background-size: 0.5em 0.5em;
|
|
51
|
+
background-color: var(--current-color, transparent);
|
|
52
|
+
box-shadow: inset 0 0 0 1px color-mix(in oklab, light-dark(black, white), transparent 90%);
|
|
53
|
+
pointer-events: none;
|
|
54
|
+
|
|
55
|
+
&::after {
|
|
56
|
+
position: absolute;
|
|
57
|
+
top: 0;
|
|
58
|
+
right: 0;
|
|
59
|
+
bottom: 0;
|
|
60
|
+
left: 0;
|
|
61
|
+
width: var(--preview-size);
|
|
62
|
+
height: var(--preview-size);
|
|
63
|
+
border-radius: inherit;
|
|
64
|
+
background-color: var(--current-color);
|
|
65
|
+
box-shadow: inset 0 0 0 1px color-mix(in oklab, light-dark(black, white), transparent 90%);
|
|
66
|
+
content: '';
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
#color-picker {
|
|
71
|
+
position: absolute;
|
|
72
|
+
top: 0;
|
|
73
|
+
left: 0;
|
|
74
|
+
margin: 0;
|
|
75
|
+
padding: 0;
|
|
76
|
+
border: none;
|
|
77
|
+
background: none;
|
|
78
|
+
box-shadow: var(--sigvelo-elevation-floating);
|
|
79
|
+
cursor: default;
|
|
80
|
+
|
|
81
|
+
&::part(picker) {
|
|
82
|
+
border-color: var(--sigvelo-color-neutral-border-muted);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
&.show {
|
|
86
|
+
animation: show var(--show-duration) ease;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
&.hide {
|
|
90
|
+
animation: show var(--show-duration) ease reverse;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
:host([data-placement^='top']) #color-picker {
|
|
95
|
+
transform-origin: bottom;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
:host([data-placement^='bottom']) #color-picker {
|
|
99
|
+
transform-origin: top;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
:host([data-placement^='left']) #color-picker {
|
|
103
|
+
transform-origin: right;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
:host([data-placement^='right']) #color-picker {
|
|
107
|
+
transform-origin: left;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
:host([data-placement='left-start']) #color-picker {
|
|
111
|
+
transform-origin: right top;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
:host([data-placement='left-end']) #color-picker {
|
|
115
|
+
transform-origin: right bottom;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
:host([data-placement='right-start']) #color-picker {
|
|
119
|
+
transform-origin: left top;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
:host([data-placement='right-end']) #color-picker {
|
|
123
|
+
transform-origin: left bottom;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
@keyframes show {
|
|
127
|
+
from {
|
|
128
|
+
scale: 0.9;
|
|
129
|
+
opacity: 0;
|
|
130
|
+
}
|
|
131
|
+
to {
|
|
132
|
+
scale: 1;
|
|
133
|
+
opacity: 1;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
`;
|
|
137
|
+
//#endregion
|
|
138
|
+
//#region src/components/color-input/color-input.ts
|
|
139
|
+
const openColorPickers = /* @__PURE__ */ new Set();
|
|
140
|
+
/**
|
|
141
|
+
* <sigvelo-color-input>
|
|
142
|
+
*
|
|
143
|
+
* @summary Allows users to enter or select a color and submit it with a form.
|
|
144
|
+
* @tag sigvelo-color-input
|
|
145
|
+
* @documentation https://design-system.sigvelo.com/docs/components/color-input
|
|
146
|
+
* @status stable
|
|
147
|
+
* @since 1.0
|
|
148
|
+
*
|
|
149
|
+
* @dependency - sigvelo-color-picker
|
|
150
|
+
*
|
|
151
|
+
* @slot label - The color input's label. For plain-text labels, you can use the `label` attribute instead.
|
|
152
|
+
* @slot description - The color input's description. For plain-text descriptions, you can use the `description`
|
|
153
|
+
* attribute instead.
|
|
154
|
+
*
|
|
155
|
+
* @event sigvelo-blur - Emitted when the color input loses focus. This event does not bubble.
|
|
156
|
+
* @event sigvelo-change - Emitted when the user commits changes to the color input's value.
|
|
157
|
+
* @event sigvelo-focus - Emitted when the color input receives focus. This event does not bubble.
|
|
158
|
+
* @event sigvelo-input - Emitted when the color input receives input.
|
|
159
|
+
*
|
|
160
|
+
* @csspart label - The element that contains the color input's label.
|
|
161
|
+
* @csspart description - The element that contains the color input's description.
|
|
162
|
+
* @csspart visual-box - The element that wraps the internal text box.
|
|
163
|
+
* @csspart text-box - The internal text box, an `<input>` element.
|
|
164
|
+
* @csspart clear-button - The clear button, a `<button>` element.
|
|
165
|
+
*
|
|
166
|
+
* @cssproperty [--show-duration=50ms] - The duration of the show/hide animation.
|
|
167
|
+
* @cssproperty [--preview-size=1.6em] - The size of the color preview.
|
|
168
|
+
*
|
|
169
|
+
* @cssstate disabled - Applied when the color input is disabled.
|
|
170
|
+
* @cssstate blank - Applied when the color input has a blank value.
|
|
171
|
+
* @cssstate focused - Applied when the color input has focus.
|
|
172
|
+
* @cssstate open - Applied when the color picker is open.
|
|
173
|
+
* @cssstate user-valid - Applied when the color input is valid and the user has sufficiently interacted with it.
|
|
174
|
+
* @cssstate user-invalid - Applied when the color input is invalid and the user has sufficiently interacted with it.
|
|
175
|
+
*
|
|
176
|
+
* @example Default
|
|
177
|
+
* ```html
|
|
178
|
+
* <sigvelo-color-input
|
|
179
|
+
* label="Select a color"
|
|
180
|
+
* description="The cats like violet, but any color works"
|
|
181
|
+
* name="color"
|
|
182
|
+
* value="#f0803a"
|
|
183
|
+
* swatches="
|
|
184
|
+
* #09090b; #71717a; #ef4444; #f97316;
|
|
185
|
+
* #f59e0b; #eab308; #84cc16; #22c55e;
|
|
186
|
+
* #10b981; #14b8a6; #06b6d4; #3b82f6;
|
|
187
|
+
* #6366f1; #a855f7; #d946ef; #ec4899
|
|
188
|
+
* "
|
|
189
|
+
* with-input
|
|
190
|
+
* with-alpha
|
|
191
|
+
* with-eye-dropper
|
|
192
|
+
* with-clear
|
|
193
|
+
* ></sigvelo-color-input>
|
|
194
|
+
* ```
|
|
195
|
+
*
|
|
196
|
+
* @example Labels and descriptions
|
|
197
|
+
* You can use the `label` and `description` attributes to provide plain text labels and descriptions for the color input. If you want to provide HTML, use the `label` and `description` slots instead.
|
|
198
|
+
*
|
|
199
|
+
* ```html
|
|
200
|
+
* <sigvelo-color-input
|
|
201
|
+
* label="Select a color"
|
|
202
|
+
* name="color"
|
|
203
|
+
* >
|
|
204
|
+
* <span slot="description">
|
|
205
|
+
* For our cafe branding guidelines, <a href="https://example.com/" target="_blank">visit our style guide</a>.
|
|
206
|
+
* </span>
|
|
207
|
+
* </sigvelo-color-input>
|
|
208
|
+
* ```
|
|
209
|
+
*
|
|
210
|
+
* @example Providing an initial value
|
|
211
|
+
* Use the `value` attribute to provide an initial value for the color input.
|
|
212
|
+
*
|
|
213
|
+
* ```html
|
|
214
|
+
* <sigvelo-color-input
|
|
215
|
+
* label="Select a color"
|
|
216
|
+
* value="#7578c5"
|
|
217
|
+
* ></sigvelo-color-input>
|
|
218
|
+
* ```
|
|
219
|
+
*
|
|
220
|
+
* @example Enabling alpha
|
|
221
|
+
* Add the `with-alpha` attribute to allow users to adjust opacity. Hex colors will become the eight-value syntax, e.g. `#rrggbbaa`, and other formats will include alpha as well.
|
|
222
|
+
*
|
|
223
|
+
* ```html
|
|
224
|
+
* <sigvelo-color-input
|
|
225
|
+
* label="Select a color"
|
|
226
|
+
* value="#ce238088"
|
|
227
|
+
* with-alpha
|
|
228
|
+
* ></sigvelo-color-input>
|
|
229
|
+
* ```
|
|
230
|
+
*
|
|
231
|
+
* @example Adding a clear button
|
|
232
|
+
* To add a clear button to the color input, use the `with-clear` attribute. The `sigvelo-input` event will be emitted when the clear button is activated.
|
|
233
|
+
*
|
|
234
|
+
* ```html
|
|
235
|
+
* <sigvelo-color-input
|
|
236
|
+
* label="Select a color"
|
|
237
|
+
* name="color"
|
|
238
|
+
* value="#21b8bc"
|
|
239
|
+
* with-clear
|
|
240
|
+
* ></sigvelo-color-input>
|
|
241
|
+
* ```
|
|
242
|
+
*
|
|
243
|
+
* @example Setting the format
|
|
244
|
+
* Use the `format` attribute to set the format of the value. Valid options include `hex` (default), `rgb,` and `hsl`.
|
|
245
|
+
*
|
|
246
|
+
* ```html
|
|
247
|
+
* <sigvelo-color-input
|
|
248
|
+
* label="Select a color (RGB)"
|
|
249
|
+
* value="rgb(255, 204, 0)"
|
|
250
|
+
* format="rgb"
|
|
251
|
+
* ></sigvelo-color-input>
|
|
252
|
+
* ```
|
|
253
|
+
*
|
|
254
|
+
* @example Filled and unstyled color inputs
|
|
255
|
+
* Color inputs support multiple visual styles through the `variant` attribute.
|
|
256
|
+
*
|
|
257
|
+
* ```html
|
|
258
|
+
* <sigvelo-color-input
|
|
259
|
+
* label="Normal"
|
|
260
|
+
* variant="normal"
|
|
261
|
+
* value="#6366f1"
|
|
262
|
+
* ></sigvelo-color-input>
|
|
263
|
+
*
|
|
264
|
+
* <br>
|
|
265
|
+
*
|
|
266
|
+
* <sigvelo-color-input
|
|
267
|
+
* label="Filled"
|
|
268
|
+
* variant="filled"
|
|
269
|
+
* value="#6366f1"
|
|
270
|
+
* ></sigvelo-color-input>
|
|
271
|
+
*
|
|
272
|
+
* <br>
|
|
273
|
+
*
|
|
274
|
+
* <sigvelo-color-input
|
|
275
|
+
* label="Unstyled"
|
|
276
|
+
* variant="unstyled"
|
|
277
|
+
* value="#6366f1"
|
|
278
|
+
* ></sigvelo-color-input>
|
|
279
|
+
* ```
|
|
280
|
+
*
|
|
281
|
+
* @example Pill-shaped color inputs
|
|
282
|
+
* Color inputs can be rendered with pill-shaped edges by adding the `pill` attribute.
|
|
283
|
+
*
|
|
284
|
+
* ```html
|
|
285
|
+
* <sigvelo-color-input pill label="Pill-shaped"></sigvelo-color-input>
|
|
286
|
+
* ```
|
|
287
|
+
*
|
|
288
|
+
* @example Sizes
|
|
289
|
+
* Use the `size` attribute to change the color input's size.
|
|
290
|
+
*
|
|
291
|
+
* ```html
|
|
292
|
+
* <sigvelo-color-input size="xs" label="Extra small"></sigvelo-color-input><br>
|
|
293
|
+
* <sigvelo-color-input size="sm" label="Small"></sigvelo-color-input><br>
|
|
294
|
+
* <sigvelo-color-input size="md" label="Medium"></sigvelo-color-input><br>
|
|
295
|
+
* <sigvelo-color-input size="lg" label="Large"></sigvelo-color-input><br>
|
|
296
|
+
* <sigvelo-color-input size="xl" label="Extra large"></sigvelo-color-input>
|
|
297
|
+
* ```
|
|
298
|
+
*
|
|
299
|
+
* @example Disabling
|
|
300
|
+
* Use the `disabled` attribute to disable the color input.
|
|
301
|
+
*
|
|
302
|
+
* ```html
|
|
303
|
+
* <sigvelo-color-input
|
|
304
|
+
* label="Disabled color input"
|
|
305
|
+
* disabled
|
|
306
|
+
* value="#6366f1"
|
|
307
|
+
* ></sigvelo-color-input>
|
|
308
|
+
* ```
|
|
309
|
+
*
|
|
310
|
+
* @example Showing swatches
|
|
311
|
+
* Set the `swatches` attribute to one or more semicolon-delimited colors to show as preset swatches below the color picker. You can use any valid CSS color format including hex colors, RGB, HSL, named colors, and more. This is useful for providing users with access to recent colors or a predefined color palette.
|
|
312
|
+
*
|
|
313
|
+
* ```html
|
|
314
|
+
* <sigvelo-color-input
|
|
315
|
+
* label="Select a color"
|
|
316
|
+
* swatches="
|
|
317
|
+
* #09090b; #71717a; #ef4444; #f97316;
|
|
318
|
+
* #f59e0b; #eab308; #84cc16; #22c55e;
|
|
319
|
+
* #10b981; #14b8a6; #06b6d4; #3b82f6;
|
|
320
|
+
* #6366f1; #a855f7; #d946ef; #ec4899
|
|
321
|
+
* "
|
|
322
|
+
* ></sigvelo-color-input>
|
|
323
|
+
* ```
|
|
324
|
+
*
|
|
325
|
+
* You can also mix different color formats in the swatches:
|
|
326
|
+
*
|
|
327
|
+
* ```html
|
|
328
|
+
* <sigvelo-color-input
|
|
329
|
+
* label="Select a color"
|
|
330
|
+
* swatches="
|
|
331
|
+
* rgb(255 0 0);
|
|
332
|
+
* hsl(120, 100%, 50%);
|
|
333
|
+
* rgb(0 0 255 / 0.5);
|
|
334
|
+
* lightblue;
|
|
335
|
+
* #ff00ff
|
|
336
|
+
* "
|
|
337
|
+
* ></sigvelo-color-input>
|
|
338
|
+
* ```
|
|
339
|
+
*
|
|
340
|
+
* @example Showing labels on the side
|
|
341
|
+
* With the `sigvelo-side-label` utility, you can show labels on the side instead of on top of the color input. You can control the width of the label by setting the `--label-width` custom property.
|
|
342
|
+
*
|
|
343
|
+
* ```html
|
|
344
|
+
* <sigvelo-color-input
|
|
345
|
+
* class="sigvelo-side-label"
|
|
346
|
+
* style="--label-width: 10ch;"
|
|
347
|
+
* name="color"
|
|
348
|
+
* label="Brand color"
|
|
349
|
+
* description="Make it pop"
|
|
350
|
+
* ></sigvelo-color-input>
|
|
351
|
+
* <br>
|
|
352
|
+
* <sigvelo-color-input
|
|
353
|
+
* class="sigvelo-side-label"
|
|
354
|
+
* style="--label-width: 10ch;"
|
|
355
|
+
* name="color"
|
|
356
|
+
* label="Accent color"
|
|
357
|
+
* description="Complementary colors work well here"
|
|
358
|
+
* ></sigvelo-color-input>
|
|
359
|
+
* ```
|
|
360
|
+
*
|
|
361
|
+
* @example Validation
|
|
362
|
+
* The `required` attribute can be applied to enable validation using the Constraint Validation API. This will prevent form submission when the color input is missing a value.
|
|
363
|
+
*
|
|
364
|
+
* ```html
|
|
365
|
+
* <form action="about:blank" target="_blank">
|
|
366
|
+
* <sigvelo-color-input
|
|
367
|
+
* name="color"
|
|
368
|
+
* label="Select a color"
|
|
369
|
+
* required
|
|
370
|
+
* style="margin-block-end: 1rem;"
|
|
371
|
+
* ></sigvelo-color-input>
|
|
372
|
+
* <sigvelo-button type="submit">Submit</sigvelo-button>
|
|
373
|
+
* </form>
|
|
374
|
+
* ```
|
|
375
|
+
*
|
|
376
|
+
* @example Using custom validation
|
|
377
|
+
* Use the `setCustomValidity()` method to make the color input 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.
|
|
378
|
+
*
|
|
379
|
+
* ```html
|
|
380
|
+
* <form action="about:blank" method="get" target="_blank" id="color-input__custom">
|
|
381
|
+
* <sigvelo-color-input
|
|
382
|
+
* name="color"
|
|
383
|
+
* label="Select a color"
|
|
384
|
+
* description="This field will be invalid until custom validation is removed"
|
|
385
|
+
* ></sigvelo-color-input>
|
|
386
|
+
* <br>
|
|
387
|
+
* <sigvelo-button type="submit" color="primary">Submit</sigvelo-button>
|
|
388
|
+
* </form>
|
|
389
|
+
*
|
|
390
|
+
* <script type="module">
|
|
391
|
+
* import { allDefined } from '/dist/sigvelo.js';
|
|
392
|
+
*
|
|
393
|
+
* await allDefined();
|
|
394
|
+
*
|
|
395
|
+
* const form = document.getElementById('color-input__custom');
|
|
396
|
+
* const colorInput = form.querySelector('sigvelo-color-input');
|
|
397
|
+
*
|
|
398
|
+
* colorInput.setCustomValidity('Please select a different color!');
|
|
399
|
+
* <\/script>
|
|
400
|
+
* ```
|
|
401
|
+
*
|
|
402
|
+
* @example Styling validation
|
|
403
|
+
* You can style valid and invalid color inputs using the `:valid` and `:invalid` pseudo classes.
|
|
404
|
+
*
|
|
405
|
+
* ```html
|
|
406
|
+
* <form action="about:blank" method="get" target="_blank" class="field__validation-pseudo">
|
|
407
|
+
* <sigvelo-color-input
|
|
408
|
+
* name="color"
|
|
409
|
+
* label="Select a color"
|
|
410
|
+
* description="This field is required"
|
|
411
|
+
* required
|
|
412
|
+
* ></sigvelo-color-input>
|
|
413
|
+
* <br>
|
|
414
|
+
* <sigvelo-button type="submit" color="primary">Submit</sigvelo-button>
|
|
415
|
+
* <sigvelo-button type="reset">Reset</sigvelo-button>
|
|
416
|
+
* </form>
|
|
417
|
+
*
|
|
418
|
+
* <style>
|
|
419
|
+
* .field__validation-pseudo {
|
|
420
|
+
* sigvelo-color-input:valid {
|
|
421
|
+
* outline: solid 2px var(--sigvelo-color-success-border);
|
|
422
|
+
* outline-offset: .5rem;
|
|
423
|
+
* }
|
|
424
|
+
*
|
|
425
|
+
* sigvelo-color-input:invalid {
|
|
426
|
+
* outline: solid 2px var(--sigvelo-color-danger-border);
|
|
427
|
+
* outline-offset: .5rem;
|
|
428
|
+
* }
|
|
429
|
+
* }
|
|
430
|
+
* </style>
|
|
431
|
+
* ```
|
|
432
|
+
*
|
|
433
|
+
* 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.
|
|
434
|
+
*
|
|
435
|
+
* ```html
|
|
436
|
+
* <form action="about:blank" method="get" target="_blank" class="field__validation-custom">
|
|
437
|
+
* <sigvelo-color-input
|
|
438
|
+
* name="color"
|
|
439
|
+
* label="Select a color"
|
|
440
|
+
* description="This field is required"
|
|
441
|
+
* required
|
|
442
|
+
* ></sigvelo-color-input>
|
|
443
|
+
* <br>
|
|
444
|
+
* <sigvelo-button type="submit" color="primary">Submit</sigvelo-button>
|
|
445
|
+
* <sigvelo-button type="reset">Reset</sigvelo-button>
|
|
446
|
+
* </form>
|
|
447
|
+
*
|
|
448
|
+
* <style>
|
|
449
|
+
* .field__validation-custom {
|
|
450
|
+
* sigvelo-color-input:state(user-valid) {
|
|
451
|
+
* outline: solid 2px var(--sigvelo-color-success-border);
|
|
452
|
+
* outline-offset: .5rem;
|
|
453
|
+
* }
|
|
454
|
+
*
|
|
455
|
+
* sigvelo-color-input:state(user-invalid) {
|
|
456
|
+
* outline: solid 2px var(--sigvelo-color-danger-border);
|
|
457
|
+
* outline-offset: .5rem;
|
|
458
|
+
* }
|
|
459
|
+
* }
|
|
460
|
+
* </style>
|
|
461
|
+
* ```
|
|
462
|
+
*/
|
|
463
|
+
var SigveloColorInput = class extends SigveloFormControlElement {
|
|
464
|
+
constructor(..._args) {
|
|
465
|
+
super(..._args);
|
|
466
|
+
this.localize = new Localize(this);
|
|
467
|
+
this.isOpen = false;
|
|
468
|
+
this.isInvalid = false;
|
|
469
|
+
this.hadUserInteraction = false;
|
|
470
|
+
this.wasSubmitted = false;
|
|
471
|
+
this.value = "";
|
|
472
|
+
this.disabled = false;
|
|
473
|
+
this.readonly = false;
|
|
474
|
+
this.withClear = false;
|
|
475
|
+
this.variant = "normal";
|
|
476
|
+
this.size = "md";
|
|
477
|
+
this.pill = false;
|
|
478
|
+
this.format = "hex";
|
|
479
|
+
this.swatches = "";
|
|
480
|
+
this.withAlpha = false;
|
|
481
|
+
this.withEyeDropper = false;
|
|
482
|
+
this.placement = "bottom-start";
|
|
483
|
+
this.distance = 0;
|
|
484
|
+
this.offset = 0;
|
|
485
|
+
this.required = false;
|
|
486
|
+
this.handleDocumentFocusIn = (event) => {
|
|
487
|
+
const path = event.composedPath();
|
|
488
|
+
if (!path.includes(this) && !path.includes(this.colorPicker)) this.isOpen = false;
|
|
489
|
+
};
|
|
490
|
+
this.handleDocumentKeyDown = (event) => {
|
|
491
|
+
if (event.key === "Escape") {
|
|
492
|
+
event.preventDefault();
|
|
493
|
+
event.stopPropagation();
|
|
494
|
+
this.focus();
|
|
495
|
+
this.hidePicker();
|
|
496
|
+
}
|
|
497
|
+
};
|
|
498
|
+
this.handleDocumentPointerDown = (event) => {
|
|
499
|
+
const path = event.composedPath();
|
|
500
|
+
if (!path.includes(this.visualBox) && !path.includes(this.colorPicker)) this.hidePicker();
|
|
501
|
+
};
|
|
502
|
+
}
|
|
503
|
+
static {
|
|
504
|
+
this.formAssociated = true;
|
|
505
|
+
}
|
|
506
|
+
static {
|
|
507
|
+
this.observeSlots = true;
|
|
508
|
+
}
|
|
509
|
+
static {
|
|
510
|
+
this.styles = [
|
|
511
|
+
hostStyles,
|
|
512
|
+
formControlStyles,
|
|
513
|
+
color_input_styles_default
|
|
514
|
+
];
|
|
515
|
+
}
|
|
516
|
+
get focusableAnchor() {
|
|
517
|
+
return this.textBox;
|
|
518
|
+
}
|
|
519
|
+
connectedCallback() {
|
|
520
|
+
super.connectedCallback();
|
|
521
|
+
this.addEventListener("invalid", this.handleHostInvalid);
|
|
522
|
+
}
|
|
523
|
+
disconnectedCallback() {
|
|
524
|
+
super.disconnectedCallback();
|
|
525
|
+
this.removeEventListener("invalid", this.handleHostInvalid);
|
|
526
|
+
}
|
|
527
|
+
async updated(changedProperties) {
|
|
528
|
+
this.updateValidity();
|
|
529
|
+
if (changedProperties.has("isOpen")) {
|
|
530
|
+
if (this.disabled) this.isOpen = false;
|
|
531
|
+
this.customStates.set("open", this.isOpen);
|
|
532
|
+
if (this.isOpen) this.showPicker();
|
|
533
|
+
else this.hidePicker();
|
|
534
|
+
}
|
|
535
|
+
if (changedProperties.has("value")) {
|
|
536
|
+
this.customStates.set("blank", this.value === "");
|
|
537
|
+
this.internals.setFormValue(this.value);
|
|
538
|
+
this.preview.style.setProperty("--current-color", this.value);
|
|
539
|
+
}
|
|
540
|
+
if (changedProperties.has("disabled")) {
|
|
541
|
+
if (this.disabled) this.isOpen = false;
|
|
542
|
+
this.customStates.set("disabled", this.disabled);
|
|
543
|
+
}
|
|
544
|
+
if (changedProperties.has("format")) {
|
|
545
|
+
if (this.value !== "") {
|
|
546
|
+
await this.colorPicker.updateComplete;
|
|
547
|
+
this.value = this.colorPicker.value;
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
if (this.hadUserInteraction || this.wasSubmitted) {
|
|
551
|
+
this.customStates.set("user-invalid", this.isInvalid);
|
|
552
|
+
this.customStates.set("user-valid", !this.isInvalid);
|
|
553
|
+
} else {
|
|
554
|
+
this.customStates.set("user-invalid", false);
|
|
555
|
+
this.customStates.set("user-valid", false);
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
/** @internal Called when a containing fieldset is disabled. */
|
|
559
|
+
formDisabledCallback(isDisabled) {
|
|
560
|
+
this.disabled = isDisabled;
|
|
561
|
+
}
|
|
562
|
+
/** @internal Called when the form is reset. */
|
|
563
|
+
formResetCallback() {
|
|
564
|
+
this.isInvalid = false;
|
|
565
|
+
this.hadUserInteraction = false;
|
|
566
|
+
this.wasSubmitted = false;
|
|
567
|
+
this.value = this.getAttribute("value") ?? "";
|
|
568
|
+
}
|
|
569
|
+
handleBlur() {
|
|
570
|
+
this.customStates.set("focused", false);
|
|
571
|
+
this.dispatchEvent(new SigveloBlurEvent());
|
|
572
|
+
if (this.value !== "") this.value = this.colorPicker.value;
|
|
573
|
+
}
|
|
574
|
+
handleChange() {
|
|
575
|
+
this.hadUserInteraction = true;
|
|
576
|
+
this.dispatchEvent(new SigveloChangeEvent());
|
|
577
|
+
this.dispatchEvent(new Event("change", {
|
|
578
|
+
bubbles: true,
|
|
579
|
+
composed: true
|
|
580
|
+
}));
|
|
581
|
+
}
|
|
582
|
+
handleFocus() {
|
|
583
|
+
this.customStates.set("focused", true);
|
|
584
|
+
this.dispatchEvent(new SigveloFocusEvent());
|
|
585
|
+
}
|
|
586
|
+
handleHostInvalid() {
|
|
587
|
+
this.wasSubmitted = true;
|
|
588
|
+
}
|
|
589
|
+
handleClearClick() {
|
|
590
|
+
this.hadUserInteraction = true;
|
|
591
|
+
this.value = "";
|
|
592
|
+
this.textBox.focus();
|
|
593
|
+
this.dispatchEvent(new SigveloInputEvent());
|
|
594
|
+
this.dispatchEvent(new InputEvent("input", {
|
|
595
|
+
bubbles: true,
|
|
596
|
+
composed: true,
|
|
597
|
+
cancelable: false
|
|
598
|
+
}));
|
|
599
|
+
}
|
|
600
|
+
handleColorPickerChange() {
|
|
601
|
+
this.hadUserInteraction = true;
|
|
602
|
+
}
|
|
603
|
+
handleColorPickerInput() {
|
|
604
|
+
this.value = this.colorPicker.value;
|
|
605
|
+
this.dispatchEvent(new SigveloInputEvent());
|
|
606
|
+
this.dispatchEvent(new InputEvent("input", {
|
|
607
|
+
bubbles: true,
|
|
608
|
+
composed: true,
|
|
609
|
+
cancelable: false
|
|
610
|
+
}));
|
|
611
|
+
}
|
|
612
|
+
async handleInput() {
|
|
613
|
+
this.value = this.textBox.value;
|
|
614
|
+
this.colorPicker.value = this.value;
|
|
615
|
+
await this.updateComplete;
|
|
616
|
+
this.dispatchEvent(new SigveloInputEvent());
|
|
617
|
+
}
|
|
618
|
+
handleTextBoxButtonPointerDown(event) {
|
|
619
|
+
event.preventDefault();
|
|
620
|
+
}
|
|
621
|
+
handleTextBoxKeyDown(event) {
|
|
622
|
+
if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
|
623
|
+
event.preventDefault();
|
|
624
|
+
event.stopPropagation();
|
|
625
|
+
this.isOpen = true;
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
handleVisualBoxPointerDown(event) {
|
|
629
|
+
const target = event.target;
|
|
630
|
+
const isBox = target?.id === "visual-box";
|
|
631
|
+
const isSlot = target.hasAttribute("slot");
|
|
632
|
+
if (this.disabled) return;
|
|
633
|
+
if (isBox || isSlot) event.preventDefault();
|
|
634
|
+
if (!this.isOpen && !event.composedPath().includes(this.colorPicker)) {
|
|
635
|
+
if (event.pointerType === "touch") event.preventDefault();
|
|
636
|
+
else this.textBox.focus();
|
|
637
|
+
this.isOpen = true;
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
/** Repositions the dropdown menu */
|
|
641
|
+
reposition() {
|
|
642
|
+
const anchor = this.visualBox;
|
|
643
|
+
computePosition(anchor, this.colorPicker, {
|
|
644
|
+
placement: this.placement,
|
|
645
|
+
middleware: [
|
|
646
|
+
offset({
|
|
647
|
+
mainAxis: this.distance,
|
|
648
|
+
crossAxis: this.offset
|
|
649
|
+
}),
|
|
650
|
+
flip(),
|
|
651
|
+
shift()
|
|
652
|
+
]
|
|
653
|
+
}).then(({ x, y, placement }) => {
|
|
654
|
+
this.setAttribute("data-placement", placement);
|
|
655
|
+
Object.assign(this.colorPicker.style, {
|
|
656
|
+
left: `${x}px`,
|
|
657
|
+
top: `${y}px`
|
|
658
|
+
});
|
|
659
|
+
});
|
|
660
|
+
}
|
|
661
|
+
/** Sets the form control's validity */
|
|
662
|
+
async updateValidity() {
|
|
663
|
+
await this.updateComplete;
|
|
664
|
+
const hasCustomValidity = this.getCustomValidity().length > 0;
|
|
665
|
+
const validationMessage = hasCustomValidity ? this.getCustomValidity() : this.textBox.validationMessage;
|
|
666
|
+
const flags = {
|
|
667
|
+
badInput: this.textBox.validity.badInput,
|
|
668
|
+
customError: hasCustomValidity,
|
|
669
|
+
patternMismatch: this.textBox.validity.patternMismatch,
|
|
670
|
+
rangeOverflow: this.textBox.validity.rangeOverflow,
|
|
671
|
+
rangeUnderflow: this.textBox.validity.rangeUnderflow,
|
|
672
|
+
stepMismatch: this.textBox.validity.stepMismatch,
|
|
673
|
+
tooLong: this.textBox.validity.tooLong,
|
|
674
|
+
tooShort: this.textBox.validity.tooShort,
|
|
675
|
+
typeMismatch: this.textBox.validity.typeMismatch,
|
|
676
|
+
valueMissing: this.textBox.validity.valueMissing
|
|
677
|
+
};
|
|
678
|
+
this.isInvalid = hasCustomValidity ? true : !this.textBox.validity.valid;
|
|
679
|
+
this.internals.setValidity(flags, validationMessage, this.focusableAnchor);
|
|
680
|
+
}
|
|
681
|
+
/** Removes focus from the color input. */
|
|
682
|
+
blur() {
|
|
683
|
+
this.textBox.blur();
|
|
684
|
+
}
|
|
685
|
+
/** Sets focus to the color input. */
|
|
686
|
+
focus() {
|
|
687
|
+
this.textBox.focus();
|
|
688
|
+
this.isOpen = true;
|
|
689
|
+
}
|
|
690
|
+
/**
|
|
691
|
+
* Gets the current value as a hex string, a hex8 string, an RGB object, or an HSL object. RBG objects have `r`, `g`,
|
|
692
|
+
* and `b` properties ranging from 0–255 and an `a` property (representing opacity) that ranges from 0-1. HSL objects
|
|
693
|
+
* have an `h` property ranging from `0-359` and `s`, `l`, and `a` properties ranging from 0–1.
|
|
694
|
+
*/
|
|
695
|
+
getValueAs(format = "rgb") {
|
|
696
|
+
return this.colorPicker.getValueAs(format);
|
|
697
|
+
}
|
|
698
|
+
/** Selects all text in the color input. */
|
|
699
|
+
select() {
|
|
700
|
+
this.textBox.select();
|
|
701
|
+
}
|
|
702
|
+
/** Sets the start and end positions of the current text selection in the color input. */
|
|
703
|
+
setSelectionRange(start, end, direction = "none") {
|
|
704
|
+
this.textBox.setSelectionRange(start, end, direction);
|
|
705
|
+
}
|
|
706
|
+
/** Replaces a range of text in the color input with a new string. */
|
|
707
|
+
setRangeText(replacement, start, end, selectMode) {
|
|
708
|
+
this.textBox.setRangeText(replacement, start ?? this.textBox.selectionStart, end ?? this.textBox.selectionEnd, selectMode);
|
|
709
|
+
this.value = this.textBox.value;
|
|
710
|
+
}
|
|
711
|
+
/** Shows the color picker. */
|
|
712
|
+
async showPicker() {
|
|
713
|
+
if (this.disabled) return;
|
|
714
|
+
openColorPickers.forEach((picker) => picker.isOpen = false);
|
|
715
|
+
this.colorPicker.showPopover();
|
|
716
|
+
this.isOpen = true;
|
|
717
|
+
this.reposition();
|
|
718
|
+
openColorPickers.add(this);
|
|
719
|
+
document.addEventListener("keydown", this.handleDocumentKeyDown);
|
|
720
|
+
document.addEventListener("pointerdown", this.handleDocumentPointerDown);
|
|
721
|
+
document.addEventListener("focusin", this.handleDocumentFocusIn);
|
|
722
|
+
this.colorPicker.hidden = false;
|
|
723
|
+
this.cleanup = autoUpdate(this.visualBox, this.colorPicker, () => this.reposition());
|
|
724
|
+
await animateWithClass(this.colorPicker, "show");
|
|
725
|
+
}
|
|
726
|
+
/** Hides the color picker. */
|
|
727
|
+
async hidePicker() {
|
|
728
|
+
if (this.disabled) return;
|
|
729
|
+
this.isOpen = false;
|
|
730
|
+
openColorPickers.delete(this);
|
|
731
|
+
document.removeEventListener("keydown", this.handleDocumentKeyDown);
|
|
732
|
+
document.removeEventListener("pointerdown", this.handleDocumentPointerDown);
|
|
733
|
+
document.removeEventListener("focusin", this.handleDocumentFocusIn);
|
|
734
|
+
if (!this.colorPicker.hidden) {
|
|
735
|
+
await animateWithClass(this.colorPicker, "hide");
|
|
736
|
+
this.colorPicker.hidden = true;
|
|
737
|
+
this.colorPicker.hidePopover();
|
|
738
|
+
}
|
|
739
|
+
if (this.cleanup) {
|
|
740
|
+
this.cleanup();
|
|
741
|
+
this.cleanup = void 0;
|
|
742
|
+
this.removeAttribute("data-placement");
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
render() {
|
|
746
|
+
const hasLabel = this.label || this.slotsWithContent.has("label");
|
|
747
|
+
const hasDescription = this.description || this.slotsWithContent.has("description");
|
|
748
|
+
return html`
|
|
749
|
+
<label id="label" part="label" for="text-box" class=${classMap({ vh: !hasLabel })}>
|
|
750
|
+
<slot name="label">${this.label}</slot>
|
|
751
|
+
</label>
|
|
752
|
+
|
|
753
|
+
<div id="description" part="description" class=${classMap({ vh: !hasDescription })}>
|
|
754
|
+
<slot name="description">${this.description}</slot>
|
|
755
|
+
</div>
|
|
756
|
+
|
|
757
|
+
<div
|
|
758
|
+
id="visual-box"
|
|
759
|
+
part="visual-box"
|
|
760
|
+
class=${classMap({
|
|
761
|
+
normal: this.variant === "normal",
|
|
762
|
+
filled: this.variant === "filled",
|
|
763
|
+
unstyled: this.variant === "unstyled",
|
|
764
|
+
xs: this.size === "xs",
|
|
765
|
+
sm: this.size === "sm",
|
|
766
|
+
md: this.size === "md",
|
|
767
|
+
lg: this.size === "lg",
|
|
768
|
+
xl: this.size === "xl",
|
|
769
|
+
pill: this.pill,
|
|
770
|
+
disabled: this.disabled
|
|
771
|
+
})}
|
|
772
|
+
@pointerdown=${this.handleVisualBoxPointerDown}
|
|
773
|
+
>
|
|
774
|
+
<div id="preview"></div>
|
|
775
|
+
<input
|
|
776
|
+
id="text-box"
|
|
777
|
+
part="text-box"
|
|
778
|
+
type="text"
|
|
779
|
+
?autofocus=${this.autofocus}
|
|
780
|
+
?disabled=${this.disabled}
|
|
781
|
+
?readonly=${this.readonly}
|
|
782
|
+
?required=${this.required}
|
|
783
|
+
placeholder=${ifDefined(this.placeholder)}
|
|
784
|
+
.value=${live(this.value)}
|
|
785
|
+
autocapitalize="off"
|
|
786
|
+
autocomplete=${ifDefined(this.autocomplete)}
|
|
787
|
+
autocorrect="off"
|
|
788
|
+
enterkeyhint=${ifDefined(this.enterkeyhint)}
|
|
789
|
+
inputmode=${ifDefined(this.inputmode)}
|
|
790
|
+
aria-describedby="description"
|
|
791
|
+
aria-invalid=${this.isInvalid ? "true" : "false"}
|
|
792
|
+
aria-haspopup="dialog"
|
|
793
|
+
aria-expanded=${this.isOpen ? "true" : "false"}
|
|
794
|
+
aria-controls="color-picker"
|
|
795
|
+
role="combobox"
|
|
796
|
+
@change=${this.handleChange}
|
|
797
|
+
@input=${this.handleInput}
|
|
798
|
+
@focus=${this.handleFocus}
|
|
799
|
+
@blur=${this.handleBlur}
|
|
800
|
+
@keydown=${this.handleTextBoxKeyDown}
|
|
801
|
+
/>
|
|
802
|
+
|
|
803
|
+
${this.withClear && this.value?.length > 0 && !this.disabled && !this.readonly ? html`
|
|
804
|
+
<button
|
|
805
|
+
id="clear-button"
|
|
806
|
+
part="clear-button"
|
|
807
|
+
class="text-box-button"
|
|
808
|
+
type="button"
|
|
809
|
+
aria-label=${this.localize.term("clearEntry")}
|
|
810
|
+
tabindex="-1"
|
|
811
|
+
@pointerdown=${this.handleTextBoxButtonPointerDown}
|
|
812
|
+
@click=${this.handleClearClick}
|
|
813
|
+
>
|
|
814
|
+
<sigvelo-icon library="system" name="circle-x"></sigvelo-icon>
|
|
815
|
+
</button>
|
|
816
|
+
` : ""}
|
|
817
|
+
</div>
|
|
818
|
+
|
|
819
|
+
<sigvelo-color-picker
|
|
820
|
+
id="color-picker"
|
|
821
|
+
popover="manual"
|
|
822
|
+
value=${this.value}
|
|
823
|
+
size=${this.size}
|
|
824
|
+
format=${this.format}
|
|
825
|
+
swatches=${ifDefined(this.swatches)}
|
|
826
|
+
?with-alpha=${this.withAlpha}
|
|
827
|
+
?with-eye-dropper=${this.withEyeDropper}
|
|
828
|
+
hidden
|
|
829
|
+
role="dialog"
|
|
830
|
+
@sigvelo-change=${this.handleColorPickerChange}
|
|
831
|
+
@sigvelo-input=${this.handleColorPickerInput}
|
|
832
|
+
></sigvelo-color-picker>
|
|
833
|
+
`;
|
|
834
|
+
}
|
|
835
|
+
};
|
|
836
|
+
__decorate([query("#color-picker")], SigveloColorInput.prototype, "colorPicker", void 0);
|
|
837
|
+
__decorate([query("input")], SigveloColorInput.prototype, "textBox", void 0);
|
|
838
|
+
__decorate([query("#preview")], SigveloColorInput.prototype, "preview", void 0);
|
|
839
|
+
__decorate([query("#visual-box")], SigveloColorInput.prototype, "visualBox", void 0);
|
|
840
|
+
__decorate([state()], SigveloColorInput.prototype, "isOpen", void 0);
|
|
841
|
+
__decorate([state()], SigveloColorInput.prototype, "isInvalid", void 0);
|
|
842
|
+
__decorate([state()], SigveloColorInput.prototype, "hadUserInteraction", void 0);
|
|
843
|
+
__decorate([state()], SigveloColorInput.prototype, "wasSubmitted", void 0);
|
|
844
|
+
__decorate([property()], SigveloColorInput.prototype, "label", void 0);
|
|
845
|
+
__decorate([property()], SigveloColorInput.prototype, "description", void 0);
|
|
846
|
+
__decorate([property({ reflect: true })], SigveloColorInput.prototype, "name", void 0);
|
|
847
|
+
__decorate([property()], SigveloColorInput.prototype, "value", void 0);
|
|
848
|
+
__decorate([property()], SigveloColorInput.prototype, "placeholder", void 0);
|
|
849
|
+
__decorate([property({
|
|
850
|
+
type: Boolean,
|
|
851
|
+
reflect: true
|
|
852
|
+
})], SigveloColorInput.prototype, "disabled", void 0);
|
|
853
|
+
__decorate([property({
|
|
854
|
+
type: Boolean,
|
|
855
|
+
reflect: true
|
|
856
|
+
})], SigveloColorInput.prototype, "readonly", void 0);
|
|
857
|
+
__decorate([property({
|
|
858
|
+
attribute: "with-clear",
|
|
859
|
+
type: Boolean,
|
|
860
|
+
reflect: true
|
|
861
|
+
})], SigveloColorInput.prototype, "withClear", void 0);
|
|
862
|
+
__decorate([property({ reflect: true })], SigveloColorInput.prototype, "variant", void 0);
|
|
863
|
+
__decorate([property({ reflect: true })], SigveloColorInput.prototype, "size", void 0);
|
|
864
|
+
__decorate([property({
|
|
865
|
+
type: Boolean,
|
|
866
|
+
reflect: true
|
|
867
|
+
})], SigveloColorInput.prototype, "pill", void 0);
|
|
868
|
+
__decorate([property()], SigveloColorInput.prototype, "format", void 0);
|
|
869
|
+
__decorate([property()], SigveloColorInput.prototype, "swatches", void 0);
|
|
870
|
+
__decorate([property({
|
|
871
|
+
attribute: "with-alpha",
|
|
872
|
+
type: Boolean,
|
|
873
|
+
reflect: true
|
|
874
|
+
})], SigveloColorInput.prototype, "withAlpha", void 0);
|
|
875
|
+
__decorate([property({
|
|
876
|
+
attribute: "with-eye-dropper",
|
|
877
|
+
type: Boolean,
|
|
878
|
+
reflect: true
|
|
879
|
+
})], SigveloColorInput.prototype, "withEyeDropper", void 0);
|
|
880
|
+
__decorate([property({ reflect: true })], SigveloColorInput.prototype, "placement", void 0);
|
|
881
|
+
__decorate([property({ type: Number })], SigveloColorInput.prototype, "distance", void 0);
|
|
882
|
+
__decorate([property({ type: Number })], SigveloColorInput.prototype, "offset", void 0);
|
|
883
|
+
__decorate([property()], SigveloColorInput.prototype, "form", void 0);
|
|
884
|
+
__decorate([property({
|
|
885
|
+
type: Boolean,
|
|
886
|
+
reflect: true
|
|
887
|
+
})], SigveloColorInput.prototype, "required", void 0);
|
|
888
|
+
__decorate([property()], SigveloColorInput.prototype, "autocomplete", void 0);
|
|
889
|
+
__decorate([property({ type: Boolean })], SigveloColorInput.prototype, "autofocus", void 0);
|
|
890
|
+
__decorate([property()], SigveloColorInput.prototype, "enterkeyhint", void 0);
|
|
891
|
+
__decorate([property()], SigveloColorInput.prototype, "inputmode", void 0);
|
|
892
|
+
customElements.define("sigvelo-color-input", SigveloColorInput);
|
|
893
|
+
//#endregion
|
|
894
|
+
export { SigveloColorInput as t };
|