@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,884 @@
|
|
|
1
|
+
import { Localize } from "./utilities/localize.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 { SigveloElement } from "@mcp-b/wc-support/base/sigvelo-element";
|
|
7
|
+
import { exactSearch, fuzzySearch } from "@mcp-b/wc-support/utilities/search";
|
|
8
|
+
//#region src/components/search-list/search-list.styles.ts
|
|
9
|
+
var search_list_styles_default = css`
|
|
10
|
+
:host {
|
|
11
|
+
display: block;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
slot[name="controller"]::slotted(input),
|
|
15
|
+
slot[name="controller"]::slotted(sigvelo-text-field) {
|
|
16
|
+
margin-block-end: 1em;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
#items {
|
|
20
|
+
display: flex;
|
|
21
|
+
flex-direction: column;
|
|
22
|
+
flex-wrap: wrap;
|
|
23
|
+
width: 100%;
|
|
24
|
+
gap: 1em;
|
|
25
|
+
}
|
|
26
|
+
`;
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region src/components/search-list/search-list.ts
|
|
29
|
+
/**
|
|
30
|
+
* <sigvelo-search-list>
|
|
31
|
+
*
|
|
32
|
+
* @summary Queries a collection of items based on their content and keywords.
|
|
33
|
+
* @tag sigvelo-search-list
|
|
34
|
+
* @documentation https://design-system.sigvelo.com/docs/components/search-list
|
|
35
|
+
* @status stable
|
|
36
|
+
* @since 1.0
|
|
37
|
+
*
|
|
38
|
+
* @slot - One or more elements to be searched. Each element must be a direct descendent of the host, i.e. do not wrap
|
|
39
|
+
* items in other containers. If desired, you can apply flex and grid styles to the `items` part to control how items
|
|
40
|
+
* appear in the list. By default, items will be displayed in a flex column.
|
|
41
|
+
* @slot controller - A `<sigvelo-text-field>` or `<input>` element that will control the search list.
|
|
42
|
+
* @slot initial - Optional content to display when no search query has been entered.
|
|
43
|
+
* @slot empty - Optional content to display when the search yields no results.
|
|
44
|
+
*
|
|
45
|
+
* @csspart items - The container that wraps the slotted items. Displays as a flex column by default.
|
|
46
|
+
*
|
|
47
|
+
* @cssstate empty - Applied when a query is entered and no matching results are found.
|
|
48
|
+
* @cssstate initial - Applied when the query is empty and the `initial` slot is showing.
|
|
49
|
+
*
|
|
50
|
+
* @example Default
|
|
51
|
+
* Search Lists provide real-time filtering of on-page content as the user types, supporting exact or fuzzy matching, custom keywords, and customizable empty states. The component works with just about any type of content and can be customized with different layouts and styling.
|
|
52
|
+
*
|
|
53
|
+
* ```html
|
|
54
|
+
* <sigvelo-search-list match="fuzzy" id="search-list__overview">
|
|
55
|
+
* <!-- Controller -->
|
|
56
|
+
* <sigvelo-text-field
|
|
57
|
+
* slot="controller"
|
|
58
|
+
* label="Search cats"
|
|
59
|
+
* description="Results will update as you type"
|
|
60
|
+
* type="search"
|
|
61
|
+
* with-clear
|
|
62
|
+
* pill
|
|
63
|
+
* >
|
|
64
|
+
* <sigvelo-icon slot="start" name="search"></sigvelo-icon>
|
|
65
|
+
* </sigvelo-text-field>
|
|
66
|
+
*
|
|
67
|
+
* <!-- Items -->
|
|
68
|
+
* <sigvelo-card orientation="horizontal">
|
|
69
|
+
* <sigvelo-avatar slot="header" image="https://images.unsplash.com/photo-1672487209629-4d52e0c043d0?q=80&w=256&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"></sigvelo-avatar>
|
|
70
|
+
* <div>
|
|
71
|
+
* <h4 class="name">Meowy McGee</h4>
|
|
72
|
+
* <div class="tagline">Freedom's just another word for nothing left to lose.</div>
|
|
73
|
+
* </div>
|
|
74
|
+
* <sigvelo-button slot="actions" icon-label="Settings" variant="ghost" pill>
|
|
75
|
+
* <sigvelo-icon name="dots"></sigvelo-icon>
|
|
76
|
+
* </sigvelo-button>
|
|
77
|
+
* </sigvelo-card>
|
|
78
|
+
*
|
|
79
|
+
* <sigvelo-card orientation="horizontal">
|
|
80
|
+
* <sigvelo-avatar slot="header" image="https://images.unsplash.com/photo-1529778873920-4da4926a72c2?q=80&w=256&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"></sigvelo-avatar>
|
|
81
|
+
* <div>
|
|
82
|
+
* <h4 class="name">Wonder Whiskers</h4>
|
|
83
|
+
* <div class="tagline">Living my best nine lives, one nap at a time.</div>
|
|
84
|
+
* </div>
|
|
85
|
+
* <sigvelo-button slot="actions" icon-label="Settings" variant="ghost" pill>
|
|
86
|
+
* <sigvelo-icon name="dots"></sigvelo-icon>
|
|
87
|
+
* </sigvelo-button>
|
|
88
|
+
* </sigvelo-card>
|
|
89
|
+
*
|
|
90
|
+
* <sigvelo-card orientation="horizontal">
|
|
91
|
+
* <sigvelo-avatar slot="header" image="https://images.unsplash.com/photo-1569591159212-b02ea8a9f239?q=80&w=256&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"></sigvelo-avatar>
|
|
92
|
+
* <div>
|
|
93
|
+
* <h4 class="name">Maine Attraction</h4>
|
|
94
|
+
* <div class="tagline">Big fluff, bigger personality.</div>
|
|
95
|
+
* </div>
|
|
96
|
+
* <sigvelo-button slot="actions" icon-label="Settings" variant="ghost" pill>
|
|
97
|
+
* <sigvelo-icon name="dots"></sigvelo-icon>
|
|
98
|
+
* </sigvelo-button>
|
|
99
|
+
* </sigvelo-card>
|
|
100
|
+
*
|
|
101
|
+
* <sigvelo-card orientation="horizontal">
|
|
102
|
+
* <sigvelo-avatar slot="header" image="https://images.unsplash.com/photo-1735820474275-dd0ff4f28d71?q=80&w=256&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"></sigvelo-avatar>
|
|
103
|
+
* <div>
|
|
104
|
+
* <h4 class="name">Sir Pounce-a-lot</h4>
|
|
105
|
+
* <div class="tagline">Professional sunbeam chaser and nap enthusiast.</div>
|
|
106
|
+
* </div>
|
|
107
|
+
* <sigvelo-button slot="actions" icon-label="Settings" variant="ghost" pill>
|
|
108
|
+
* <sigvelo-icon name="dots"></sigvelo-icon>
|
|
109
|
+
* </sigvelo-button>
|
|
110
|
+
* </sigvelo-card>
|
|
111
|
+
*
|
|
112
|
+
* <!-- Empty state -->
|
|
113
|
+
* <sigvelo-empty-state slot="empty">
|
|
114
|
+
* <sigvelo-icon slot="illustration" name="cat"></sigvelo-icon>
|
|
115
|
+
* <p>No matching results</p>
|
|
116
|
+
* </sigvelo-empty-state>
|
|
117
|
+
* </sigvelo-search-list>
|
|
118
|
+
*
|
|
119
|
+
* <style>
|
|
120
|
+
* #search-list__overview {
|
|
121
|
+
* sigvelo-card {
|
|
122
|
+
* --spacing: 1rem;
|
|
123
|
+
*
|
|
124
|
+
* sigvelo-avatar {
|
|
125
|
+
* --size: 3rem;
|
|
126
|
+
* }
|
|
127
|
+
*
|
|
128
|
+
* .name,
|
|
129
|
+
* .tagline {
|
|
130
|
+
* margin: 0;
|
|
131
|
+
* line-height: 1.2;
|
|
132
|
+
* display: inline;
|
|
133
|
+
* }
|
|
134
|
+
*
|
|
135
|
+
* .name {
|
|
136
|
+
* display: block;
|
|
137
|
+
* font-size: 1.125rem;
|
|
138
|
+
* }
|
|
139
|
+
*
|
|
140
|
+
* .tagline {
|
|
141
|
+
* color: var(--sigvelo-color-text-muted);
|
|
142
|
+
* font-size: 0.875rem;
|
|
143
|
+
* }
|
|
144
|
+
* }
|
|
145
|
+
*
|
|
146
|
+
* div[slot="empty"] {
|
|
147
|
+
* text-align: center;
|
|
148
|
+
* color: var(--sigvelo-color-text-muted);
|
|
149
|
+
* margin-block-start: 1rem;
|
|
150
|
+
*
|
|
151
|
+
* sigvelo-icon {
|
|
152
|
+
* font-size: 2.5rem;
|
|
153
|
+
* stroke-width: 1px;
|
|
154
|
+
* }
|
|
155
|
+
* }
|
|
156
|
+
* }
|
|
157
|
+
* </style>
|
|
158
|
+
* ```
|
|
159
|
+
*
|
|
160
|
+
* @example Providing a controller and items
|
|
161
|
+
* Every search list must have a search box, or _controller_, that maintains the query. Controllers can be `<sigvelo-text-field>` or native `<input>` elements. To link a controller, place it in the search list's `controller` slot or assign an external one. Make sure to add a label and description to ensure it's accessible.
|
|
162
|
+
*
|
|
163
|
+
* Searchable items can be just about any element, but they _must_ be direct descendants of the `<sigvelo-search-list>` element. By default, an item's text content will be used to determine a match, but you can also specify keywords. A case-insensitive search is performed by default, but basic fuzzy matching and custom matching are also available.
|
|
164
|
+
*
|
|
165
|
+
* As the user types in the controller, the search list will update and show the matching results. When no query is entered, all items are shown. An optional empty state can be provided to show a custom message when a query is entered and no matches are found.
|
|
166
|
+
*
|
|
167
|
+
* A minimal implementation looks something like this. Note the use of `label` and `description`, which are important for accessibility.
|
|
168
|
+
*
|
|
169
|
+
* ```html
|
|
170
|
+
* <sigvelo-search-list>
|
|
171
|
+
* <!-- Controller -->
|
|
172
|
+
* <sigvelo-text-field
|
|
173
|
+
* slot="controller"
|
|
174
|
+
* label="Search"
|
|
175
|
+
* description="Results will update as you type"
|
|
176
|
+
* ></sigvelo-text-field>
|
|
177
|
+
*
|
|
178
|
+
* <!-- Items -->
|
|
179
|
+
* <div>Item 1</div>
|
|
180
|
+
* <div>Item 2</div>
|
|
181
|
+
* <div>Item 3</div>
|
|
182
|
+
* </sigvelo-search-list>
|
|
183
|
+
* ```
|
|
184
|
+
*
|
|
185
|
+
* Here's an example using a native `<input>` element.
|
|
186
|
+
*
|
|
187
|
+
* ```html
|
|
188
|
+
* <sigvelo-search-list>
|
|
189
|
+
* <!-- Controller -->
|
|
190
|
+
* <label slot="controller" for="search">Search</label>
|
|
191
|
+
* <input slot="controller" id="search" aria-description="Results will update as you type">
|
|
192
|
+
*
|
|
193
|
+
* <!-- Items -->
|
|
194
|
+
* <div>Item 1</div>
|
|
195
|
+
* <div>Item 2</div>
|
|
196
|
+
* <div>Item 3</div>
|
|
197
|
+
* </sigvelo-search-list>
|
|
198
|
+
* ```
|
|
199
|
+
*
|
|
200
|
+
* Items aren't given any styles by the component — that part is up to you! The item's container, however, is styled as a flex column container by default. To change the layout, apply the desired CSS using the `::part(items)` selector. Both flex and grid layouts work really well here.
|
|
201
|
+
*
|
|
202
|
+
* Here is the example from above, modified with example styles.
|
|
203
|
+
*
|
|
204
|
+
* ```html
|
|
205
|
+
* <sigvelo-search-list id="search-list__search">
|
|
206
|
+
* <sigvelo-text-field
|
|
207
|
+
* slot="controller"
|
|
208
|
+
* label="Search"
|
|
209
|
+
* description="Results will update as you type"
|
|
210
|
+
* ></sigvelo-text-field>
|
|
211
|
+
*
|
|
212
|
+
* <div>Item 1</div>
|
|
213
|
+
* <div>Item 2</div>
|
|
214
|
+
* <div>Item 3</div>
|
|
215
|
+
* </sigvelo-search-list>
|
|
216
|
+
*
|
|
217
|
+
* <style>
|
|
218
|
+
* #search-list__search {
|
|
219
|
+
* &::part(items) {
|
|
220
|
+
* display: grid;
|
|
221
|
+
* grid-template-columns: repeat(auto-fill, minmax(min(180px, 100%), 1fr));
|
|
222
|
+
* }
|
|
223
|
+
*
|
|
224
|
+
* > div {
|
|
225
|
+
* border: var(--sigvelo-border-style) var(--sigvelo-border-width) var(--sigvelo-color-neutral-border-subtle);
|
|
226
|
+
* border-radius: var(--sigvelo-radius-md);
|
|
227
|
+
* background-color: var(--sigvelo-color-surface);
|
|
228
|
+
* box-shadow: var(--sigvelo-elevation-hairline);
|
|
229
|
+
* text-align: center;
|
|
230
|
+
* padding: 1rem;
|
|
231
|
+
* }
|
|
232
|
+
* }
|
|
233
|
+
* </style>
|
|
234
|
+
* ```
|
|
235
|
+
*
|
|
236
|
+
* **Note:** Search lists are designed to listen for user input dispatched by their controllers. As such, canceling the controller's `input` event or programmatically modifying its value will cause the search list to get out of sync. In that case, you can use the `setQuery()` method to programmatically update the search list.
|
|
237
|
+
*
|
|
238
|
+
* @example Fuzzy matching
|
|
239
|
+
* By default, the search list shows results based on case-insensitive, exact matches. For a more permissive search, add `match="fuzzy"` which is more forgiving to typos.
|
|
240
|
+
*
|
|
241
|
+
* ```html
|
|
242
|
+
* <sigvelo-search-list match="fuzzy" id="search-list__fuzzy">
|
|
243
|
+
* <!-- Controller -->
|
|
244
|
+
* <sigvelo-text-field
|
|
245
|
+
* slot="controller"
|
|
246
|
+
* label="Search for names"
|
|
247
|
+
* type="search"
|
|
248
|
+
* with-clear
|
|
249
|
+
* pill
|
|
250
|
+
* >
|
|
251
|
+
* <sigvelo-icon slot="start" name="search"></sigvelo-icon>
|
|
252
|
+
* </sigvelo-text-field>
|
|
253
|
+
*
|
|
254
|
+
* <!-- Items -->
|
|
255
|
+
* <div class="item">Luna</div>
|
|
256
|
+
* <div class="item">Oliver</div>
|
|
257
|
+
* <div class="item">Bella</div>
|
|
258
|
+
* <div class="item">Whiskers</div>
|
|
259
|
+
* <div class="item">Maple</div>
|
|
260
|
+
* <div class="item">Sushi</div>
|
|
261
|
+
* <div class="item">Pepper</div>
|
|
262
|
+
* <div class="item">Mittens</div>
|
|
263
|
+
* <div class="item">Shadow</div>
|
|
264
|
+
* <div class="item">Oreo</div>
|
|
265
|
+
* <div class="item">Mochi</div>
|
|
266
|
+
* <div class="item">Nova</div>
|
|
267
|
+
* <div class="item">Tiger</div>
|
|
268
|
+
* <div class="item">Ziggy</div>
|
|
269
|
+
* </sigvelo-search-list>
|
|
270
|
+
*
|
|
271
|
+
* <style>
|
|
272
|
+
* #search-list__fuzzy {
|
|
273
|
+
* <!-- Style the items in a flex row -->
|
|
274
|
+
* &::part(items) {
|
|
275
|
+
* flex-direction: row;
|
|
276
|
+
* gap: 0.5rem;
|
|
277
|
+
* }
|
|
278
|
+
*
|
|
279
|
+
* <!-- Custom item styles -->
|
|
280
|
+
* .item {
|
|
281
|
+
* border: var(--sigvelo-border-style) var(--sigvelo-border-width) var(--sigvelo-color-neutral-border-subtle);
|
|
282
|
+
* border-radius: var(--sigvelo-radius-full);
|
|
283
|
+
* background-color: var(--sigvelo-color-surface);
|
|
284
|
+
* box-shadow: var(--sigvelo-elevation-hairline);
|
|
285
|
+
* padding: 0.5rem 1rem;
|
|
286
|
+
* }
|
|
287
|
+
* }
|
|
288
|
+
* </style>
|
|
289
|
+
* ```
|
|
290
|
+
*
|
|
291
|
+
* **Note:** For even more control over the matching algorithm, you can specific a [custom match function](#using-a-custom-match-function).
|
|
292
|
+
*
|
|
293
|
+
* @example Adding keywords
|
|
294
|
+
* Add the `data-keywords` attribute to any item to include additional keywords the search list should match by. This is useful for adding terms you'd like the item to match on even when the term doesn't appear in regular content.
|
|
295
|
+
*
|
|
296
|
+
* ```html
|
|
297
|
+
* <sigvelo-search-list id="search-list__keywords">
|
|
298
|
+
* <!-- Controller -->
|
|
299
|
+
* <sigvelo-text-field
|
|
300
|
+
* slot="controller"
|
|
301
|
+
* label="Search by color"
|
|
302
|
+
* description="e.g. brown, orange, white, gray, black"
|
|
303
|
+
* type="search"
|
|
304
|
+
* with-clear
|
|
305
|
+
* pill
|
|
306
|
+
* >
|
|
307
|
+
* <sigvelo-icon slot="start" name="search"></sigvelo-icon>
|
|
308
|
+
* </sigvelo-text-field>
|
|
309
|
+
*
|
|
310
|
+
* <!-- Items -->
|
|
311
|
+
* <img
|
|
312
|
+
* data-keywords="orange"
|
|
313
|
+
* src="https://images.unsplash.com/photo-1628612380382-e6204e135307?q=80&w=500&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"
|
|
314
|
+
* alt="An orange kitten meows while perched on a stone wall"
|
|
315
|
+
* >
|
|
316
|
+
* <img
|
|
317
|
+
* data-keywords="white gray brown"
|
|
318
|
+
* src="https://images.unsplash.com/photo-1595252849939-1ec8070a354a?q=80&w=500&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"
|
|
319
|
+
* alt="A multicolored cat walking through the grass stops to look at the camera"
|
|
320
|
+
* >
|
|
321
|
+
* <img
|
|
322
|
+
* data-keywords="white gray"
|
|
323
|
+
* src="https://images.unsplash.com/photo-1583399704033-3db671c65f5c?q=80&w=500&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"
|
|
324
|
+
* alt="A white fluffy kitten lays comfortably on the arm of a chair"
|
|
325
|
+
* >
|
|
326
|
+
* <img
|
|
327
|
+
* data-keywords="gray black"
|
|
328
|
+
* src="https://images.unsplash.com/photo-1625060241508-22488e1e9264?q=80&w=500&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"
|
|
329
|
+
* alt="A gray tabby lays in a bed and looks out past the camera"
|
|
330
|
+
* >
|
|
331
|
+
* <img
|
|
332
|
+
* data-keywords="white black"
|
|
333
|
+
* src="https://images.unsplash.com/photo-1692901573513-41cda579d689?q=80&w=500&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"
|
|
334
|
+
* alt="A black and white kitten lays on its bed and looks at the camera"
|
|
335
|
+
* >
|
|
336
|
+
* <img
|
|
337
|
+
* data-keywords="gray black"
|
|
338
|
+
* src="https://images.unsplash.com/photo-1622273414093-27fd902ac078?q=80&w=500&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"
|
|
339
|
+
* alt="A young gray tabby lays on the steps and yawns"
|
|
340
|
+
* >
|
|
341
|
+
* <img
|
|
342
|
+
* data-keywords="white black brown"
|
|
343
|
+
* src="https://images.unsplash.com/photo-1601217155197-0419cd3fd698?q=80&w=500&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"
|
|
344
|
+
* alt="A multi-colored kitten poses for a picture"
|
|
345
|
+
* >
|
|
346
|
+
* <img
|
|
347
|
+
* data-keywords="gray brown"
|
|
348
|
+
* src="https://images.unsplash.com/photo-1622273509381-59a1e99afefd?q=80&w=500&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"
|
|
349
|
+
* alt="A young tabby rests its eyes while playfully putting its paw up"
|
|
350
|
+
* >
|
|
351
|
+
* <img
|
|
352
|
+
* data-keywords="brown"
|
|
353
|
+
* src="https://images.unsplash.com/photo-1644625986841-fdedeb19d37c?q=80&w=500&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"
|
|
354
|
+
* alt="A brown cat looks up at the camera"
|
|
355
|
+
* >
|
|
356
|
+
* </sigvelo-search-list>
|
|
357
|
+
*
|
|
358
|
+
* <style>
|
|
359
|
+
* #search-list__keywords {
|
|
360
|
+
* &::part(items) {
|
|
361
|
+
* display: grid;
|
|
362
|
+
* grid-template-columns: repeat(auto-fill, minmax(min(145px, 100%), 1fr));
|
|
363
|
+
* }
|
|
364
|
+
*
|
|
365
|
+
* img {
|
|
366
|
+
* height: 100%;
|
|
367
|
+
* object-fit: cover;
|
|
368
|
+
* }
|
|
369
|
+
* }
|
|
370
|
+
* </style>
|
|
371
|
+
* ```
|
|
372
|
+
*
|
|
373
|
+
* @example Providing an initial state
|
|
374
|
+
* To change what users see before they enter a query, use the `initial` slot. When provided, this content will appear instead of the items when no query is entered. Once the user starts typing, the matching items or the empty state will be shown.
|
|
375
|
+
*
|
|
376
|
+
* ```html
|
|
377
|
+
* <sigvelo-search-list id="search-list__initial">
|
|
378
|
+
* <!-- Controller -->
|
|
379
|
+
* <sigvelo-text-field
|
|
380
|
+
* slot="controller"
|
|
381
|
+
* label="Search cats"
|
|
382
|
+
* description="Find your perfect feline friend"
|
|
383
|
+
* type="search"
|
|
384
|
+
* with-clear
|
|
385
|
+
* pill
|
|
386
|
+
* >
|
|
387
|
+
* <sigvelo-icon slot="start" name="search"></sigvelo-icon>
|
|
388
|
+
* </sigvelo-text-field>
|
|
389
|
+
*
|
|
390
|
+
* <!-- Initial state -->
|
|
391
|
+
* <sigvelo-empty-state slot="initial">
|
|
392
|
+
* <sigvelo-icon slot="illustration" name="hearts"></sigvelo-icon>
|
|
393
|
+
* <h4>Ready to Meet Some Cats?</h4>
|
|
394
|
+
* <p><small>Start typing to discover our adorable cats</small></p>
|
|
395
|
+
* </sigvelo-empty-state>
|
|
396
|
+
*
|
|
397
|
+
* <!-- Items -->
|
|
398
|
+
* <sigvelo-card orientation="horizontal">
|
|
399
|
+
* <sigvelo-avatar slot="header" image="https://images.unsplash.com/photo-1672487209629-4d52e0c043d0?q=80&w=256&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"></sigvelo-avatar>
|
|
400
|
+
* <div>
|
|
401
|
+
* <h4 class="name">Meowy McGee</h4>
|
|
402
|
+
* <div class="tagline">Freedom's just another word for nothing left to lose.</div>
|
|
403
|
+
* </div>
|
|
404
|
+
* <sigvelo-button slot="actions" icon-label="Settings" variant="ghost" pill>
|
|
405
|
+
* <sigvelo-icon name="dots"></sigvelo-icon>
|
|
406
|
+
* </sigvelo-button>
|
|
407
|
+
* </sigvelo-card>
|
|
408
|
+
*
|
|
409
|
+
* <sigvelo-card orientation="horizontal">
|
|
410
|
+
* <sigvelo-avatar slot="header" image="https://images.unsplash.com/photo-1529778873920-4da4926a72c2?q=80&w=256&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"></sigvelo-avatar>
|
|
411
|
+
* <div>
|
|
412
|
+
* <h4 class="name">Wonder Whiskers</h4>
|
|
413
|
+
* <div class="tagline">Living my best nine lives, one nap at a time.</div>
|
|
414
|
+
* </div>
|
|
415
|
+
* <sigvelo-button slot="actions" icon-label="Settings" variant="ghost" pill>
|
|
416
|
+
* <sigvelo-icon name="dots"></sigvelo-icon>
|
|
417
|
+
* </sigvelo-button>
|
|
418
|
+
* </sigvelo-card>
|
|
419
|
+
*
|
|
420
|
+
* <sigvelo-card orientation="horizontal">
|
|
421
|
+
* <sigvelo-avatar slot="header" image="https://images.unsplash.com/photo-1569591159212-b02ea8a9f239?q=80&w=256&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"></sigvelo-avatar>
|
|
422
|
+
* <div>
|
|
423
|
+
* <h4 class="name">Maine Attraction</h4>
|
|
424
|
+
* <div class="tagline">Big fluff, bigger personality.</div>
|
|
425
|
+
* </div>
|
|
426
|
+
* <sigvelo-button slot="actions" icon-label="Settings" variant="ghost" pill>
|
|
427
|
+
* <sigvelo-icon name="dots"></sigvelo-icon>
|
|
428
|
+
* </sigvelo-button>
|
|
429
|
+
* </sigvelo-card>
|
|
430
|
+
*
|
|
431
|
+
* <sigvelo-card orientation="horizontal">
|
|
432
|
+
* <sigvelo-avatar slot="header" image="https://images.unsplash.com/photo-1735820474275-dd0ff4f28d71?q=80&w=256&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"></sigvelo-avatar>
|
|
433
|
+
* <div>
|
|
434
|
+
* <h4 class="name">Sir Pounce-a-lot</h4>
|
|
435
|
+
* <div class="tagline">Professional sunbeam chaser and nap enthusiast.</div>
|
|
436
|
+
* </div>
|
|
437
|
+
* <sigvelo-button slot="actions" icon-label="Settings" variant="ghost" pill>
|
|
438
|
+
* <sigvelo-icon name="dots"></sigvelo-icon>
|
|
439
|
+
* </sigvelo-button>
|
|
440
|
+
* </sigvelo-card>
|
|
441
|
+
*
|
|
442
|
+
* <!-- Empty state -->
|
|
443
|
+
* <sigvelo-empty-state slot="empty">
|
|
444
|
+
* <sigvelo-icon slot="illustration" name="cat"></sigvelo-icon>
|
|
445
|
+
* <h4>No Cats Found</h4>
|
|
446
|
+
* <p><small>Try different search terms to find your match</small></p>
|
|
447
|
+
* </sigvelo-empty-state>
|
|
448
|
+
* </sigvelo-search-list>
|
|
449
|
+
*
|
|
450
|
+
* <style>
|
|
451
|
+
* #search-list__initial {
|
|
452
|
+
* sigvelo-card {
|
|
453
|
+
* --spacing: 1rem;
|
|
454
|
+
*
|
|
455
|
+
* sigvelo-avatar {
|
|
456
|
+
* --size: 3rem;
|
|
457
|
+
* }
|
|
458
|
+
*
|
|
459
|
+
* .name,
|
|
460
|
+
* .tagline {
|
|
461
|
+
* margin: 0;
|
|
462
|
+
* line-height: 1.2;
|
|
463
|
+
* display: inline;
|
|
464
|
+
* }
|
|
465
|
+
*
|
|
466
|
+
* .name {
|
|
467
|
+
* display: block;
|
|
468
|
+
* font-size: 1.125rem;
|
|
469
|
+
* }
|
|
470
|
+
*
|
|
471
|
+
* .tagline {
|
|
472
|
+
* color: var(--sigvelo-color-text-muted);
|
|
473
|
+
* font-size: 0.875rem;
|
|
474
|
+
* }
|
|
475
|
+
* }
|
|
476
|
+
*
|
|
477
|
+
* div[slot="initial"],
|
|
478
|
+
* div[slot="empty"] {
|
|
479
|
+
* text-align: center;
|
|
480
|
+
* color: var(--sigvelo-color-text-muted);
|
|
481
|
+
* margin-block-start: 1rem;
|
|
482
|
+
*
|
|
483
|
+
* sigvelo-icon {
|
|
484
|
+
* font-size: 2.5rem;
|
|
485
|
+
* stroke-width: 1px;
|
|
486
|
+
* }
|
|
487
|
+
*
|
|
488
|
+
* h4 {
|
|
489
|
+
* margin: 0.5rem 0 0 0;
|
|
490
|
+
* }
|
|
491
|
+
*
|
|
492
|
+
* small {
|
|
493
|
+
* display: block;
|
|
494
|
+
* margin-top: 0.5rem;
|
|
495
|
+
* }
|
|
496
|
+
* }
|
|
497
|
+
* }
|
|
498
|
+
* </style>
|
|
499
|
+
* ```
|
|
500
|
+
*
|
|
501
|
+
* **Note:** The initial state will only be shown when the `initial` slot is provided and no query has been entered.
|
|
502
|
+
*
|
|
503
|
+
* @example Providing an empty state
|
|
504
|
+
* An optional empty state will be shown when no results are found. Use the `empty` slot to add text, icons, or illustrations to it. Empty state content is not styled by the component, so feel free to bring your own look to it.
|
|
505
|
+
*
|
|
506
|
+
* ```html
|
|
507
|
+
* <sigvelo-search-list id="search-list__empty">
|
|
508
|
+
* <!-- Controller -->
|
|
509
|
+
* <sigvelo-text-field
|
|
510
|
+
* slot="controller"
|
|
511
|
+
* label="Search"
|
|
512
|
+
* type="search"
|
|
513
|
+
* value="foo"
|
|
514
|
+
* with-clear
|
|
515
|
+
* pill
|
|
516
|
+
* >
|
|
517
|
+
* <sigvelo-icon slot="start" name="search"></sigvelo-icon>
|
|
518
|
+
* </sigvelo-text-field>
|
|
519
|
+
*
|
|
520
|
+
* <!-- Items -->
|
|
521
|
+
* <div class="item">Luna</div>
|
|
522
|
+
* <div class="item">Oliver</div>
|
|
523
|
+
* <div class="item">Bella</div>
|
|
524
|
+
* <div class="item">Whiskers</div>
|
|
525
|
+
* <div class="item">Maple</div>
|
|
526
|
+
* <div class="item">Sushi</div>
|
|
527
|
+
* <div class="item">Pepper</div>
|
|
528
|
+
* <div class="item">Mittens</div>
|
|
529
|
+
* <div class="item">Shadow</div>
|
|
530
|
+
* <div class="item">Oreo</div>
|
|
531
|
+
* <div class="item">Mochi</div>
|
|
532
|
+
* <div class="item">Nova</div>
|
|
533
|
+
* <div class="item">Tiger</div>
|
|
534
|
+
* <div class="item">Ziggy</div>
|
|
535
|
+
*
|
|
536
|
+
* <!-- The empty state -->
|
|
537
|
+
* <sigvelo-empty-state slot="empty">
|
|
538
|
+
* <sigvelo-icon slot="illustration" name="cat"></sigvelo-icon>
|
|
539
|
+
* No matching results
|
|
540
|
+
* </sigvelo-empty-state>
|
|
541
|
+
* </sigvelo-search-list>
|
|
542
|
+
*
|
|
543
|
+
* <style>
|
|
544
|
+
* #search-list__empty {
|
|
545
|
+
* &::part(items) {
|
|
546
|
+
* flex-direction: row;
|
|
547
|
+
* gap: 0.5rem;
|
|
548
|
+
* }
|
|
549
|
+
*
|
|
550
|
+
* .item {
|
|
551
|
+
* border: var(--sigvelo-border-style) var(--sigvelo-border-width) var(--sigvelo-color-neutral-border-subtle);
|
|
552
|
+
* border-radius: var(--sigvelo-radius-md);
|
|
553
|
+
* background-color: var(--sigvelo-color-surface);
|
|
554
|
+
* box-shadow: var(--sigvelo-elevation-hairline);
|
|
555
|
+
* padding: 0.5rem 1rem;
|
|
556
|
+
* }
|
|
557
|
+
*
|
|
558
|
+
* <!-- Empty state styles -->
|
|
559
|
+
* div[slot="empty"] {
|
|
560
|
+
* width: 100%;
|
|
561
|
+
* text-align: center;
|
|
562
|
+
* color: var(--sigvelo-color-text-muted);
|
|
563
|
+
* margin-block-start: 1rem;
|
|
564
|
+
*
|
|
565
|
+
* sigvelo-icon {
|
|
566
|
+
* font-size: 2.5rem;
|
|
567
|
+
* stroke-width: 1px;
|
|
568
|
+
* }
|
|
569
|
+
* }
|
|
570
|
+
* }
|
|
571
|
+
* </style>
|
|
572
|
+
* ```
|
|
573
|
+
*
|
|
574
|
+
* @example Using a custom match function
|
|
575
|
+
* For more control over the matching algorithm, set the `match` attribute to `custom` and provide a callback using the `isMatch` property. The function runs on each item whenever the search query changes.
|
|
576
|
+
*
|
|
577
|
+
* The callback receives three arguments: `query` (the current search term), `content` (the element's searchable content, including its `textContent` and `data-keywords`), and `el` (a reference to the element being searched). Return `true` if the element is a match and `false` otherwise.
|
|
578
|
+
*
|
|
579
|
+
* ```html
|
|
580
|
+
* <sigvelo-search-list match="custom" id="search-list__custom">
|
|
581
|
+
* <!-- Controller -->
|
|
582
|
+
* <sigvelo-text-field
|
|
583
|
+
* slot="controller"
|
|
584
|
+
* label="Search cats"
|
|
585
|
+
* description="Add @indoor or @outdoor to filter by environment"
|
|
586
|
+
* type="search"
|
|
587
|
+
* with-clear
|
|
588
|
+
* pill
|
|
589
|
+
* >
|
|
590
|
+
* <sigvelo-icon slot="start" name="search"></sigvelo-icon>
|
|
591
|
+
* </sigvelo-text-field>
|
|
592
|
+
*
|
|
593
|
+
* <!-- Items -->
|
|
594
|
+
* <div class="item" data-environment="indoor">
|
|
595
|
+
* <h4>Luna</h4>
|
|
596
|
+
* <p>Sweet and friendly, loves window watching</p>
|
|
597
|
+
* </div>
|
|
598
|
+
*
|
|
599
|
+
* <div class="item" data-environment="outdoor">
|
|
600
|
+
* <h4>Oliver</h4>
|
|
601
|
+
* <p>Adventurous explorer, loves the garden</p>
|
|
602
|
+
* </div>
|
|
603
|
+
*
|
|
604
|
+
* <div class="item" data-environment="indoor">
|
|
605
|
+
* <h4>Milo</h4>
|
|
606
|
+
* <p>Gentle soul who loves napping in sunbeams</p>
|
|
607
|
+
* </div>
|
|
608
|
+
*
|
|
609
|
+
* <div class="item" data-environment="outdoor">
|
|
610
|
+
* <h4>Bella</h4>
|
|
611
|
+
* <p>Free spirit, enjoys climbing trees</p>
|
|
612
|
+
* </div>
|
|
613
|
+
*
|
|
614
|
+
* <div class="item" data-environment="indoor">
|
|
615
|
+
* <h4>Charlie</h4>
|
|
616
|
+
* <p>Playful cat who chases laser pointers</p>
|
|
617
|
+
* </div>
|
|
618
|
+
*
|
|
619
|
+
* <div class="item" data-environment="outdoor">
|
|
620
|
+
* <h4>Lucy</h4>
|
|
621
|
+
* <p>Independent nature lover, great hunter</p>
|
|
622
|
+
* </div>
|
|
623
|
+
*
|
|
624
|
+
* <!-- Empty state -->
|
|
625
|
+
* <sigvelo-empty-state slot="empty">
|
|
626
|
+
* <sigvelo-icon slot="illustration" name="cat"></sigvelo-icon>
|
|
627
|
+
* <h4>No cats match your search</h4>
|
|
628
|
+
* <p><small>Try searching by name or using the @indoor or @outdoor tags</small></p>
|
|
629
|
+
* </sigvelo-empty-state>
|
|
630
|
+
* </sigvelo-search-list>
|
|
631
|
+
*
|
|
632
|
+
* <script>
|
|
633
|
+
* const searchList = document.getElementById('search-list__custom');
|
|
634
|
+
*
|
|
635
|
+
* // A very contrived custom match function
|
|
636
|
+
* searchList.isMatch = (query, content, el) => {
|
|
637
|
+
* query = query.toLowerCase().trim();
|
|
638
|
+
*
|
|
639
|
+
* // If no query, show all items
|
|
640
|
+
* if (!query) return true;
|
|
641
|
+
*
|
|
642
|
+
* const environment = el.getAttribute('data-environment');
|
|
643
|
+
* const envMatch = query.match(/@(indoor|outdoor)/);
|
|
644
|
+
*
|
|
645
|
+
* // Look for @indoor or @outdoor in the query
|
|
646
|
+
* if (envMatch) {
|
|
647
|
+
* // Remove the environment tag from the query for text search
|
|
648
|
+
* const searchEnvironment = envMatch[1];
|
|
649
|
+
* const textQuery = query.replace(/@(indoor|outdoor)/, '').trim();
|
|
650
|
+
*
|
|
651
|
+
* // Must match both environment and text (if any text remains)
|
|
652
|
+
* return environment === searchEnvironment && (!textQuery || content.toLowerCase().includes(textQuery));
|
|
653
|
+
* }
|
|
654
|
+
*
|
|
655
|
+
* // If no environment tag was found, fall back to text search
|
|
656
|
+
* return content.toLowerCase().includes(query);
|
|
657
|
+
* };
|
|
658
|
+
* <\/script>
|
|
659
|
+
*
|
|
660
|
+
* <style>
|
|
661
|
+
* #search-list__custom {
|
|
662
|
+
* &::part(items) {
|
|
663
|
+
* display: grid;
|
|
664
|
+
* grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr));
|
|
665
|
+
* gap: 1rem;
|
|
666
|
+
* }
|
|
667
|
+
*
|
|
668
|
+
* .item {
|
|
669
|
+
* border: var(--sigvelo-border-style) var(--sigvelo-border-width) var(--sigvelo-color-neutral-border-subtle);
|
|
670
|
+
* border-radius: var(--sigvelo-radius-md);
|
|
671
|
+
* background-color: var(--sigvelo-color-surface);
|
|
672
|
+
* box-shadow: var(--sigvelo-elevation-hairline);
|
|
673
|
+
* padding: 1rem;
|
|
674
|
+
*
|
|
675
|
+
* h4 {
|
|
676
|
+
* margin: 0;
|
|
677
|
+
* font-size: 1.125rem;
|
|
678
|
+
* }
|
|
679
|
+
*
|
|
680
|
+
* p {
|
|
681
|
+
* color: var(--sigvelo-color-text-muted);
|
|
682
|
+
* margin: 0.5rem 0;
|
|
683
|
+
* font-size: 0.875rem;
|
|
684
|
+
* margin-block-end: 0;
|
|
685
|
+
* }
|
|
686
|
+
* }
|
|
687
|
+
*
|
|
688
|
+
* div[slot="empty"] {
|
|
689
|
+
* text-align: center;
|
|
690
|
+
* color: var(--sigvelo-color-text-muted);
|
|
691
|
+
* margin-block-start: 1rem;
|
|
692
|
+
*
|
|
693
|
+
* sigvelo-icon {
|
|
694
|
+
* font-size: 2.5rem;
|
|
695
|
+
* stroke-width: 1px;
|
|
696
|
+
* }
|
|
697
|
+
*
|
|
698
|
+
* small {
|
|
699
|
+
* display: block;
|
|
700
|
+
* margin-top: 0.5rem;
|
|
701
|
+
* }
|
|
702
|
+
* }
|
|
703
|
+
* }
|
|
704
|
+
* </style>
|
|
705
|
+
* ```
|
|
706
|
+
*
|
|
707
|
+
* @example Using an external controller
|
|
708
|
+
* In some cases, the controller might need to exist outside of the component. In this case, give the controller an ID and set the search list's `controller` attribute to match.
|
|
709
|
+
*
|
|
710
|
+
* ```html
|
|
711
|
+
* <sigvelo-text-field
|
|
712
|
+
* id="external-controller"
|
|
713
|
+
* label="Search"
|
|
714
|
+
* description="Results will update as you type"
|
|
715
|
+
* ></sigvelo-text-field>
|
|
716
|
+
*
|
|
717
|
+
* <sigvelo-search-list controller="external-controller" id="search-list__external">
|
|
718
|
+
* <div>Item 1</div>
|
|
719
|
+
* <div>Item 2</div>
|
|
720
|
+
* <div>Item 3</div>
|
|
721
|
+
* </sigvelo-search-list>
|
|
722
|
+
*
|
|
723
|
+
* <style>
|
|
724
|
+
* #search-list__external {
|
|
725
|
+
* margin-block-start: 1rem;
|
|
726
|
+
*
|
|
727
|
+
* &::part(items) {
|
|
728
|
+
* display: grid;
|
|
729
|
+
* grid-template-columns: repeat(auto-fill, minmax(min(180px, 100%), 1fr));
|
|
730
|
+
* }
|
|
731
|
+
*
|
|
732
|
+
* > div {
|
|
733
|
+
* border: var(--sigvelo-border-style) var(--sigvelo-border-width) var(--sigvelo-color-neutral-border-subtle);
|
|
734
|
+
* border-radius: var(--sigvelo-radius-md);
|
|
735
|
+
* background-color: var(--sigvelo-color-surface);
|
|
736
|
+
* box-shadow: var(--sigvelo-elevation-hairline);
|
|
737
|
+
* text-align: center;
|
|
738
|
+
* padding: 1rem;
|
|
739
|
+
* }
|
|
740
|
+
* }
|
|
741
|
+
* </style>
|
|
742
|
+
* ```
|
|
743
|
+
*
|
|
744
|
+
* **Note:** When using an external controller, make sure the position of it makes sense in reference to the search list. It should usually come immediately before the search list to ensure all users can interact with it properly.
|
|
745
|
+
*/
|
|
746
|
+
var SigveloSearchList = class extends SigveloElement {
|
|
747
|
+
constructor(..._args) {
|
|
748
|
+
super(..._args);
|
|
749
|
+
this.items = [];
|
|
750
|
+
this.localize = new Localize(this);
|
|
751
|
+
this.query = "";
|
|
752
|
+
this.isEmpty = false;
|
|
753
|
+
this.isInitial = false;
|
|
754
|
+
this.resultsMessage = "";
|
|
755
|
+
this.match = "exact";
|
|
756
|
+
this.debounce = 300;
|
|
757
|
+
this.handleControllerInput = (event) => {
|
|
758
|
+
const target = event.target;
|
|
759
|
+
clearTimeout(this.debounceTimeout);
|
|
760
|
+
this.debounceTimeout = setTimeout(() => {
|
|
761
|
+
this.query = target.value;
|
|
762
|
+
this.updateResults();
|
|
763
|
+
}, this.debounce);
|
|
764
|
+
};
|
|
765
|
+
this.handleDocumentInput = (event) => {
|
|
766
|
+
if (event.target.id === this.controller) this.handleControllerInput(event);
|
|
767
|
+
};
|
|
768
|
+
}
|
|
769
|
+
static {
|
|
770
|
+
this.observeSlots = true;
|
|
771
|
+
}
|
|
772
|
+
static {
|
|
773
|
+
this.styles = [hostStyles, search_list_styles_default];
|
|
774
|
+
}
|
|
775
|
+
connectedCallback() {
|
|
776
|
+
super.connectedCallback();
|
|
777
|
+
document.addEventListener("input", this.handleDocumentInput);
|
|
778
|
+
}
|
|
779
|
+
disconnectedCallback() {
|
|
780
|
+
super.disconnectedCallback();
|
|
781
|
+
document.removeEventListener("input", this.handleDocumentInput);
|
|
782
|
+
window.clearTimeout(this.debounceTimeout);
|
|
783
|
+
}
|
|
784
|
+
updated(changedProperties) {
|
|
785
|
+
if (changedProperties.has("controller")) {
|
|
786
|
+
const controller = this.getController();
|
|
787
|
+
if (controller) {
|
|
788
|
+
this.query = controller.value || "";
|
|
789
|
+
this.updateResults();
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
if (changedProperties.has("match")) this.updateResults();
|
|
793
|
+
if (changedProperties.has("isEmpty")) this.customStates.set("empty", this.isEmpty);
|
|
794
|
+
if (changedProperties.has("isInitial")) this.customStates.set("initial", this.isInitial);
|
|
795
|
+
}
|
|
796
|
+
/** Gets the controller or returns `null` if one can't be found. */
|
|
797
|
+
getController() {
|
|
798
|
+
const root = this.getRootNode();
|
|
799
|
+
if (this.controller) return root.getElementById(this.controller);
|
|
800
|
+
else return this.querySelector("[slot=\"controller\"]");
|
|
801
|
+
}
|
|
802
|
+
handleDefaultSlotChange() {
|
|
803
|
+
this.items = [...this.children].filter((el) => !el.hasAttribute("slot"));
|
|
804
|
+
this.updateResults();
|
|
805
|
+
}
|
|
806
|
+
async handleControllerSlotChange() {
|
|
807
|
+
const controller = this.getController();
|
|
808
|
+
if (controller?.localName === "sigvelo-text-field") await customElements.whenDefined("sigvelo-text-field");
|
|
809
|
+
if (controller && controller.value !== this.query) {
|
|
810
|
+
this.query = controller.value;
|
|
811
|
+
this.updateResults();
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
updateResults() {
|
|
815
|
+
const hasQuery = this.query.length > 0;
|
|
816
|
+
let numResults = 0;
|
|
817
|
+
let wasWarned = false;
|
|
818
|
+
this.isInitial = !hasQuery && this.slotsWithContent.has("initial");
|
|
819
|
+
if (!this.isInitial) this.items.forEach((item) => {
|
|
820
|
+
const searchableContent = `${item.textContent || ""} ${item.dataset.keywords || ""}`;
|
|
821
|
+
if (hasQuery) {
|
|
822
|
+
let isMatch = false;
|
|
823
|
+
if (this.match === "exact") isMatch = exactSearch(this.query, searchableContent);
|
|
824
|
+
if (this.match === "fuzzy") isMatch = fuzzySearch(this.query, searchableContent);
|
|
825
|
+
if (this.match === "custom") if (typeof this.isMatch === "function") isMatch = this.isMatch(this.query, searchableContent, item);
|
|
826
|
+
else {
|
|
827
|
+
if (!wasWarned) {
|
|
828
|
+
console.warn(`A custom search type was specified but no isMatch function was provided.`, this);
|
|
829
|
+
wasWarned = true;
|
|
830
|
+
}
|
|
831
|
+
isMatch = exactSearch(this.query, searchableContent);
|
|
832
|
+
}
|
|
833
|
+
item.hidden = !isMatch;
|
|
834
|
+
if (isMatch) numResults++;
|
|
835
|
+
} else item.hidden = false;
|
|
836
|
+
});
|
|
837
|
+
this.isEmpty = this.isInitial ? true : this.items.some((item) => item.hidden !== true);
|
|
838
|
+
clearTimeout(this.resultsTimeout);
|
|
839
|
+
this.resultsTimeout = setTimeout(() => {
|
|
840
|
+
if (this.isInitial) this.resultsMessage = "";
|
|
841
|
+
else if (hasQuery) this.resultsMessage = this.localize.term("showingNumberOfTotalItems", numResults, this.items.length);
|
|
842
|
+
else this.resultsMessage = this.localize.term("showingAllNumberItems", this.items.length);
|
|
843
|
+
}, 1e3);
|
|
844
|
+
}
|
|
845
|
+
/** Sets the search query and updates the results. To clear the search, set this to an empty string. */
|
|
846
|
+
setQuery(searchQuery = "") {
|
|
847
|
+
this.query = searchQuery;
|
|
848
|
+
this.updateResults();
|
|
849
|
+
const controller = this.getController();
|
|
850
|
+
if (controller && "value" in controller) controller.value = this.query;
|
|
851
|
+
}
|
|
852
|
+
render() {
|
|
853
|
+
const showInitial = this.query === "" && this.slotsWithContent.has("initial");
|
|
854
|
+
return html`
|
|
855
|
+
<slot
|
|
856
|
+
name="controller"
|
|
857
|
+
@input=${this.handleControllerInput}
|
|
858
|
+
@slotchange=${this.handleControllerSlotChange}
|
|
859
|
+
></slot>
|
|
860
|
+
|
|
861
|
+
<div id="results" class="vh" role="region" aria-live="polite">${this.resultsMessage}</div>
|
|
862
|
+
|
|
863
|
+
<div id="items" part="items" ?hidden=${showInitial}>
|
|
864
|
+
<slot @slotchange=${this.handleDefaultSlotChange} ?hidden=${!this.isEmpty}></slot>
|
|
865
|
+
</div>
|
|
866
|
+
|
|
867
|
+
<slot name="empty" ?hidden=${this.isEmpty || showInitial}></slot>
|
|
868
|
+
<slot name="initial" ?hidden=${!showInitial}></slot>
|
|
869
|
+
`;
|
|
870
|
+
}
|
|
871
|
+
};
|
|
872
|
+
__decorate([query("#results")], SigveloSearchList.prototype, "results", void 0);
|
|
873
|
+
__decorate([state()], SigveloSearchList.prototype, "query", void 0);
|
|
874
|
+
__decorate([state()], SigveloSearchList.prototype, "isEmpty", void 0);
|
|
875
|
+
__decorate([state()], SigveloSearchList.prototype, "isInitial", void 0);
|
|
876
|
+
__decorate([state()], SigveloSearchList.prototype, "resultsMessage", void 0);
|
|
877
|
+
__decorate([property({ reflect: true })], SigveloSearchList.prototype, "controller", void 0);
|
|
878
|
+
__decorate([property()], SigveloSearchList.prototype, "match", void 0);
|
|
879
|
+
__decorate([property({ type: Number })], SigveloSearchList.prototype, "debounce", void 0);
|
|
880
|
+
__decorate([property({ attribute: false })], SigveloSearchList.prototype, "isMatch", void 0);
|
|
881
|
+
SigveloSearchList.disableWarning?.("change-in-update");
|
|
882
|
+
customElements.define("sigvelo-search-list", SigveloSearchList);
|
|
883
|
+
//#endregion
|
|
884
|
+
export { SigveloSearchList as t };
|