snice 7.5.0 → 7.7.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/adapters/react/SniceProvider.js +1 -1
- package/adapters/react/SniceRouter.js +1 -1
- package/adapters/react/avatar.d.ts +1 -0
- package/adapters/react/avatar.d.ts.map +1 -1
- package/adapters/react/avatar.js +1 -1
- package/adapters/react/avatar.js.map +1 -1
- package/adapters/react/avatar.tsx +2 -1
- package/adapters/react/calendar.d.ts +4 -0
- package/adapters/react/calendar.d.ts.map +1 -1
- package/adapters/react/calendar.js +1 -1
- package/adapters/react/calendar.js.map +1 -1
- package/adapters/react/calendar.tsx +5 -1
- package/adapters/react/matchRoute.js +68 -2
- package/adapters/react/matchRoute.js.map +1 -1
- package/adapters/react/route-match.d.ts +7 -0
- package/adapters/react/useRequestHandler.js +1 -1
- package/bin/analyzer-contracts.js +60 -2
- package/bin/project-analyzer.js +1262 -118
- package/bin/snice.js +95 -5
- package/custom-elements.json +112 -0
- package/dist/cdn/accordion/snice-accordion.js +1 -1
- package/dist/cdn/action-bar/snice-action-bar.js +1 -1
- package/dist/cdn/activity-feed/snice-activity-feed.js +1 -1
- package/dist/cdn/alert/snice-alert.js +1 -1
- package/dist/cdn/app-tiles/snice-app-tiles.js +1 -1
- package/dist/cdn/approval-flow/snice-approval-flow.js +1 -1
- package/dist/cdn/audio-recorder/snice-audio-recorder.js +1 -1
- package/dist/cdn/availability/snice-availability.js +1 -1
- package/dist/cdn/avatar/README.md +1 -1
- package/dist/cdn/avatar/snice-avatar.js +9 -3
- package/dist/cdn/avatar/snice-avatar.js.map +1 -1
- package/dist/cdn/avatar/snice-avatar.min.js +2 -2
- package/dist/cdn/avatar/snice-avatar.min.js.map +1 -1
- package/dist/cdn/avatar-group/snice-avatar-group.js +1 -1
- package/dist/cdn/badge/snice-badge.js +1 -1
- package/dist/cdn/banner/snice-banner.js +1 -1
- package/dist/cdn/binpack/snice-binpack.js +1 -1
- package/dist/cdn/book/snice-book.js +1 -1
- package/dist/cdn/booking/snice-booking.js +1 -1
- package/dist/cdn/breadcrumbs/snice-breadcrumbs.js +1 -1
- package/dist/cdn/button/snice-button.js +2 -2
- package/dist/cdn/button/snice-button.js.map +1 -1
- package/dist/cdn/button/snice-button.min.js +1 -1
- package/dist/cdn/button/snice-button.min.js.map +1 -1
- package/dist/cdn/calendar/README.md +2 -2
- package/dist/cdn/calendar/snice-calendar.js +562 -40
- package/dist/cdn/calendar/snice-calendar.js.map +1 -1
- package/dist/cdn/calendar/snice-calendar.min.js +28 -1
- package/dist/cdn/calendar/snice-calendar.min.js.map +1 -1
- package/dist/cdn/camera/snice-camera.js +1 -1
- package/dist/cdn/camera-annotate/snice-camera-annotate.js +1 -1
- package/dist/cdn/candlestick/snice-candlestick.js +1 -1
- package/dist/cdn/card/snice-card.js +1 -1
- package/dist/cdn/carousel/snice-carousel.js +1 -1
- package/dist/cdn/cart/snice-cart.js +1 -1
- package/dist/cdn/chart/snice-chart.js +1 -1
- package/dist/cdn/chat/snice-chat.js +1 -1
- package/dist/cdn/checkbox/snice-checkbox.js +1 -1
- package/dist/cdn/chip/snice-chip.js +1 -1
- package/dist/cdn/code-block/snice-code-block.js +1 -1
- package/dist/cdn/color-display/snice-color-display.js +1 -1
- package/dist/cdn/color-picker/snice-color-picker.js +1 -1
- package/dist/cdn/command-palette/snice-command-palette.js +1 -1
- package/dist/cdn/comments/snice-comments.js +1 -1
- package/dist/cdn/countdown/snice-countdown.js +1 -1
- package/dist/cdn/cropper/snice-cropper.js +1 -1
- package/dist/cdn/data-card/snice-data-card.js +1 -1
- package/dist/cdn/date-picker/snice-date-picker.js +1 -1
- package/dist/cdn/date-range-picker/snice-date-range-picker.js +1 -1
- package/dist/cdn/date-time-picker/snice-date-time-picker.js +1 -1
- package/dist/cdn/diff/snice-diff.js +1 -1
- package/dist/cdn/divider/snice-divider.js +1 -1
- package/dist/cdn/doc/snice-doc.js +1 -1
- package/dist/cdn/draw/snice-draw.js +1 -1
- package/dist/cdn/drawer/snice-drawer.js +1 -1
- package/dist/cdn/empty-state/snice-empty-state.js +1 -1
- package/dist/cdn/estimate/snice-estimate.js +1 -1
- package/dist/cdn/file-gallery/snice-file-gallery.js +1 -1
- package/dist/cdn/file-upload/snice-file-upload.js +1 -1
- package/dist/cdn/flip-card/snice-flip-card.js +1 -1
- package/dist/cdn/flow/snice-flow.js +1 -1
- package/dist/cdn/form-layout/snice-form-layout.js +1 -1
- package/dist/cdn/funnel/snice-funnel.js +1 -1
- package/dist/cdn/gantt/snice-gantt.js +1 -1
- package/dist/cdn/gauge/snice-gauge.js +1 -1
- package/dist/cdn/grid/snice-grid.js +1 -1
- package/dist/cdn/heatmap/snice-heatmap.js +1 -1
- package/dist/cdn/image/snice-image.js +1 -1
- package/dist/cdn/input/snice-input.js +1 -1
- package/dist/cdn/invoice/snice-invoice.js +1 -1
- package/dist/cdn/kanban/snice-kanban.js +1 -1
- package/dist/cdn/key-value/snice-key-value.js +1 -1
- package/dist/cdn/kpi/snice-kpi.js +1 -1
- package/dist/cdn/layout/snice-layout.js +1 -1
- package/dist/cdn/leaderboard/snice-leaderboard.js +1 -1
- package/dist/cdn/link/snice-link.js +1 -1
- package/dist/cdn/link-preview/snice-link-preview.js +1 -1
- package/dist/cdn/list/snice-list.js +1 -1
- package/dist/cdn/location/snice-location.js +1 -1
- package/dist/cdn/login/README.md +1 -1
- package/dist/cdn/login/snice-login.js +2 -2
- package/dist/cdn/login/snice-login.js.map +1 -1
- package/dist/cdn/login/snice-login.min.js +1 -1
- package/dist/cdn/login/snice-login.min.js.map +1 -1
- package/dist/cdn/map/snice-map.js +1 -1
- package/dist/cdn/markdown/snice-markdown.js +1 -1
- package/dist/cdn/masonry/snice-masonry.js +1 -1
- package/dist/cdn/menu/snice-menu.js +1 -1
- package/dist/cdn/message-strip/snice-message-strip.js +1 -1
- package/dist/cdn/modal/snice-modal.js +1 -1
- package/dist/cdn/music-player/snice-music-player.js +1 -1
- package/dist/cdn/nav/snice-nav.js +1 -1
- package/dist/cdn/network-graph/snice-network-graph.js +1 -1
- package/dist/cdn/notification-center/snice-notification-center.js +1 -1
- package/dist/cdn/order-tracker/snice-order-tracker.js +1 -1
- package/dist/cdn/org-chart/snice-org-chart.js +1 -1
- package/dist/cdn/pagination/snice-pagination.js +1 -1
- package/dist/cdn/paint/snice-paint.js +1 -1
- package/dist/cdn/pdf-viewer/snice-pdf-viewer.js +1 -1
- package/dist/cdn/permission-matrix/snice-permission-matrix.js +1 -1
- package/dist/cdn/podcast-player/snice-podcast-player.js +1 -1
- package/dist/cdn/popover/snice-popover.js +1 -1
- package/dist/cdn/pricing-table/snice-pricing-table.js +1 -1
- package/dist/cdn/product-card/snice-product-card.js +1 -1
- package/dist/cdn/progress/snice-progress.js +1 -1
- package/dist/cdn/progress-ring/snice-progress-ring.js +1 -1
- package/dist/cdn/qr-code/snice-qr-code.js +1 -1
- package/dist/cdn/qr-reader/snice-qr-reader.js +1 -1
- package/dist/cdn/radio/snice-radio.js +1 -1
- package/dist/cdn/range-slider/snice-range-slider.js +1 -1
- package/dist/cdn/rating/snice-rating.js +1 -1
- package/dist/cdn/receipt/snice-receipt.js +1 -1
- package/dist/cdn/recipe/snice-recipe.js +1 -1
- package/dist/cdn/runtime/README.md +2 -2
- package/dist/cdn/runtime/snice-runtime.esm.js +706 -267
- package/dist/cdn/runtime/snice-runtime.esm.js.map +1 -1
- package/dist/cdn/runtime/snice-runtime.esm.min.js +1 -1
- package/dist/cdn/runtime/snice-runtime.esm.min.js.map +1 -1
- package/dist/cdn/runtime/snice-runtime.js +706 -267
- package/dist/cdn/runtime/snice-runtime.js.map +1 -1
- package/dist/cdn/runtime/snice-runtime.min.js +1 -1
- package/dist/cdn/runtime/snice-runtime.min.js.map +1 -1
- package/dist/cdn/sankey/snice-sankey.js +1 -1
- package/dist/cdn/segmented-control/snice-segmented-control.js +1 -1
- package/dist/cdn/select/snice-select.js +3 -1
- package/dist/cdn/select/snice-select.js.map +1 -1
- package/dist/cdn/select/snice-select.min.js +2 -2
- package/dist/cdn/select/snice-select.min.js.map +1 -1
- package/dist/cdn/skeleton/snice-skeleton.js +1 -1
- package/dist/cdn/slider/snice-slider.js +1 -1
- package/dist/cdn/sortable/snice-sortable.js +1 -1
- package/dist/cdn/sparkline/snice-sparkline.js +1 -1
- package/dist/cdn/spinner/snice-spinner.js +1 -1
- package/dist/cdn/split-button/snice-split-button.js +1 -1
- package/dist/cdn/split-pane/snice-split-pane.js +1 -1
- package/dist/cdn/spotlight/snice-spotlight.js +1 -1
- package/dist/cdn/stat-group/snice-stat-group.js +1 -1
- package/dist/cdn/step-input/snice-step-input.js +1 -1
- package/dist/cdn/stepper/snice-stepper.js +1 -1
- package/dist/cdn/switch/README.md +1 -1
- package/dist/cdn/switch/snice-switch.js +8 -4
- package/dist/cdn/switch/snice-switch.js.map +1 -1
- package/dist/cdn/switch/snice-switch.min.js +8 -4
- package/dist/cdn/switch/snice-switch.min.js.map +1 -1
- package/dist/cdn/table/README.md +2 -2
- package/dist/cdn/table/snice-table.esm.js +77 -5
- package/dist/cdn/table/snice-table.esm.js.map +1 -1
- package/dist/cdn/table/snice-table.esm.min.js +68 -47
- package/dist/cdn/table/snice-table.esm.min.js.map +1 -1
- package/dist/cdn/table/snice-table.js +76 -4
- package/dist/cdn/table/snice-table.js.map +1 -1
- package/dist/cdn/table/snice-table.min.js +53 -32
- package/dist/cdn/table/snice-table.min.js.map +1 -1
- package/dist/cdn/tabs/snice-tabs.js +1 -1
- package/dist/cdn/tag/snice-tag.js +1 -1
- package/dist/cdn/tag-input/snice-tag-input.js +1 -1
- package/dist/cdn/terminal/snice-terminal.js +1 -1
- package/dist/cdn/testimonial/snice-testimonial.js +1 -1
- package/dist/cdn/textarea/snice-textarea.js +1 -1
- package/dist/cdn/time-picker/snice-time-picker.js +1 -1
- package/dist/cdn/time-range-picker/snice-time-range-picker.js +1 -1
- package/dist/cdn/timeline/snice-timeline.js +1 -1
- package/dist/cdn/timer/snice-timer.js +1 -1
- package/dist/cdn/toast/snice-toast.js +1 -1
- package/dist/cdn/tooltip/snice-tooltip.js +1 -1
- package/dist/cdn/tree/snice-tree.js +1 -1
- package/dist/cdn/treemap/snice-treemap.js +1 -1
- package/dist/cdn/user-card/snice-user-card.js +1 -1
- package/dist/cdn/video-player/snice-video-player.js +1 -1
- package/dist/cdn/virtual-scroller/snice-virtual-scroller.js +1 -1
- package/dist/cdn/waterfall/snice-waterfall.js +1 -1
- package/dist/cdn/weather/snice-weather.js +1 -1
- package/dist/cdn/work-order/snice-work-order.js +1 -1
- package/dist/components/avatar/snice-avatar.d.ts +1 -0
- package/dist/components/avatar/snice-avatar.js +8 -2
- package/dist/components/avatar/snice-avatar.js.map +1 -1
- package/dist/components/avatar/snice-avatar.types.d.ts +2 -0
- package/dist/components/button/snice-button.js +1 -1
- package/dist/components/button/snice-button.js.map +1 -1
- package/dist/components/calendar/snice-calendar.d.ts +38 -1
- package/dist/components/calendar/snice-calendar.js +390 -40
- package/dist/components/calendar/snice-calendar.js.map +1 -1
- package/dist/components/calendar/snice-calendar.types.d.ts +63 -0
- package/dist/components/select/snice-select.js +2 -0
- package/dist/components/select/snice-select.js.map +1 -1
- package/dist/components/switch/snice-switch.js +7 -3
- package/dist/components/switch/snice-switch.js.map +1 -1
- package/dist/components/table/snice-table.d.ts +9 -0
- package/dist/components/table/snice-table.js +72 -2
- package/dist/components/table/snice-table.js.map +1 -1
- package/dist/components/table/table-keyboard.js +1 -1
- package/dist/components/table/table-keyboard.js.map +1 -1
- package/dist/index.cjs +703 -264
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.esm.js +703 -264
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +703 -264
- package/dist/index.iife.js.map +1 -1
- package/dist/parts.d.ts +14 -4
- package/dist/react/SniceProvider.js +1 -1
- package/dist/react/SniceRouter.js +1 -1
- package/dist/react/index.js +1 -1
- package/dist/react/matchRoute.js +68 -2
- package/dist/react/matchRoute.js.map +1 -1
- package/dist/react/route-match.d.ts +7 -0
- package/dist/react/useRequestHandler.js +1 -1
- package/dist/render-errors.d.ts +9 -0
- package/dist/route-match.d.ts +7 -0
- package/dist/symbols.cjs +1 -1
- package/dist/symbols.esm.js +1 -1
- package/dist/template-marker.d.ts +5 -0
- package/dist/testing-dom.cjs +1 -1
- package/dist/testing-dom.esm.js +1 -1
- package/dist/testing.d.ts +3 -0
- package/dist/transitions.cjs +1 -1
- package/dist/transitions.esm.js +1 -1
- package/dist/types/dispatch-options.d.ts +5 -4
- package/dist/types/event-timing.d.ts +7 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/on-options.d.ts +21 -6
- package/dist/utils.d.ts +3 -0
- package/docs/ai/DEVELOPMENT.md +1 -1
- package/docs/ai/api.md +7 -2
- package/docs/ai/cli.md +14 -0
- package/docs/ai/components/avatar.md +1 -0
- package/docs/ai/components/calendar.md +24 -1
- package/docs/ai/components/switch.md +3 -0
- package/docs/ai/components/table.md +1 -1
- package/docs/ai/decorators.md +3 -2
- package/docs/ai/events.md +45 -8
- package/docs/ai/rendering.md +7 -0
- package/docs/ai/routing.md +6 -1
- package/docs/ai/testing.md +17 -0
- package/docs/cli.md +19 -0
- package/docs/components/avatar.md +1 -0
- package/docs/components/calendar.md +112 -2
- package/docs/components/switch.md +7 -1
- package/docs/components/table.md +2 -1
- package/docs/events.md +90 -10
- package/docs/rendering.md +10 -0
- package/docs/routing.md +22 -1
- package/docs/testing.md +19 -0
- package/package.json +2 -2
- package/vscode.html-custom-data.json +28 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
void 0===globalThis.Snice&&console.warn("[snice] snice-runtime.min.js must be loaded before snice-select.min.js"),function(e){"use strict";function t(e,t,i,s,a,n){function l(e){if(void 0!==e&&"function"!=typeof e)throw new TypeError("Function expected");return e}for(var r,o=s.kind,c="getter"===o?"get":"setter"===o?"set":"value",d=!t&&e?s.static?e:e.prototype:null,h=t||(d?Object.getOwnPropertyDescriptor(d,s.name):{}),u=!1,p=i.length-1;p>=0;p--){var m={};for(var b in s)m[b]="access"===b?{}:s[b];for(var b in s.access)m.access[b]=s.access[b];m.addInitializer=function(e){if(u)throw new TypeError("Cannot add initializers after decoration has completed");n.push(l(e||null))};var g=(0,i[p])("accessor"===o?{get:h.get,set:h.set}:h[c],m);if("accessor"===o){if(void 0===g)continue;if(null===g||"object"!=typeof g)throw new TypeError("Object expected");(r=l(g.get))&&(h.get=r),(r=l(g.set))&&(h.set=r),(r=l(g.init))&&a.unshift(r)}else(r=l(g))&&("field"===o?a.unshift(r):h[c]=r)}d&&Object.defineProperty(d,s.name,h),u=!0}function i(e,t,i){for(var s=arguments.length>2,a=0;a<t.length;a++)i=s?t[a].call(e,i):t[a].call(e);return s?i:void 0}"function"==typeof SuppressedError&&SuppressedError;const s=new WeakMap;function a(e){return e.replace(/\s+/gu," ").trim()}function n(e,t){return e===t||e.nodeType===Node.ELEMENT_NODE&&e.contains(t)}function l(e,t){const i=e.getRootNode();return"getElementById"in i?i.getElementById(t):null}function r(e,t){if(e===t)return"";if(e.nodeType===Node.TEXT_NODE)return e.nodeValue||"";if(e.nodeType!==Node.ELEMENT_NODE)return"";const i=e;return i.hidden||"true"===i.getAttribute("aria-hidden")||["script","style","template"].includes(i.localName)?"":"br"===i.localName?" ":"img"===i.localName?i.getAttribute("alt")||"":Array.from(i.childNodes).map(e=>r(e,t)).join(" ")}function o(e,t){const i=e.getAttribute("aria-labelledby");if(i){const s=a(i.split(/\s+/u).map(t=>l(e,t)).filter(t=>Boolean(t)&&t!==e).map(e=>r(e,t)).join(" "));if(s)return s}return e.hasAttribute("aria-label")?a(e.getAttribute("aria-label")||""):a(r(e,t))||a(e.getAttribute("title")||"")}class c{constructor(e,t,i,s,a){this.host=e,this.getInternals=t,this.getTarget=i,this.getFallbackName=s,this.syncRelatedNames=a,this.connected=!1,this.currentLabels=[],this.currentNamingNodes=[],this.referencedIds=new Set,this.handleHostActivation=e=>{if(e.composedPath()[0]!==this.host)return;if(this.currentLabels=this.resolveLabels(),0===this.currentLabels.length)return;const t=this.getTarget();t?t.focus():e.preventDefault()},this.handleLabelActivation=e=>{const t=e.composedPath(),i=e.target;if(i===this.host||i instanceof Node&&this.host.contains(i))return;const s=e.currentTarget;if(t.some(e=>e instanceof HTMLElement&&e!==s&&e.matches('a[href], button, input, select, textarea, [contenteditable]:not([contenteditable="false"]), [role="button"], [role="link"]')))return;const a=this.getTarget();a?(a.focus(),setTimeout(()=>{const e=this.getTarget();this.connected&&e?.isConnected&&this.currentLabels.includes(s)&&e.focus()},0)):e.preventDefault()}}get labels(){const e=this.host.getRootNode();if(this.host.id&&"querySelectorAll"in e)try{const t=CSS.escape(this.host.id),i=CSS.escape(this.host.localName);return e.querySelectorAll(`label[for="${t}"], label:not([for]):has(${i}#${t})`)}catch{}return this.getInternals()?.labels??null}get accessibleName(){const e=this.resolveLabels();return a(e.length>0?e.map(e=>o(e,this.host)).join(" "):this.getFallbackName())}connect(){this.connected||(this.connected=!0,this.host.addEventListener("click",this.handleHostActivation),this.bindRegistry(),this.sync())}disconnect(){this.connected&&(this.connected=!1,this.host.removeEventListener("click",this.handleHostActivation),this.unbindLabelActivation(),this.releaseRegistry(),this.currentLabels=[],this.currentNamingNodes=[],this.referencedIds.clear())}sync(){if(this.connected&&this.bindRegistry(),this.unbindLabelActivation(),this.currentLabels=this.resolveLabels(),this.connected)for(const e of this.currentLabels)e.addEventListener("click",this.handleLabelActivation);this.currentNamingNodes=[...this.currentLabels],this.referencedIds.clear();for(const e of this.currentLabels)for(const t of(e.getAttribute("aria-labelledby")||"").split(/\s+/u).filter(Boolean)){this.referencedIds.add(t);const i=l(e,t);i&&i!==e&&this.currentNamingNodes.push(i)}const e=a(this.currentLabels.length>0?this.currentLabels.map(e=>o(e,this.host)).join(" "):this.getFallbackName());this.getTarget()?.setAttribute("aria-label",e),this.syncRelatedNames?.(e)}isAffectedBy(e){if("attributes"===e.type){if(e.target===this.host&&"id"===e.attributeName)return!0;const t=e.target;return"label"===t.localName&&"for"===e.attributeName?this.currentLabels.includes(t)||Boolean(this.host.id)&&t.htmlFor===this.host.id:!("id"!==e.attributeName||!this.referencedIds.has(t.id))||this.currentNamingNodes.some(e=>e===t||e.contains(t))}return!!this.currentNamingNodes.some(t=>t===e.target||t.contains(e.target))||"childList"===e.type&&[...e.addedNodes,...e.removedNodes].some(e=>{if(n(e,this.host)||n(this.host,e))return!0;if(this.currentNamingNodes.some(t=>n(e,t)))return!0;if(e.nodeType!==Node.ELEMENT_NODE)return!1;const t=e;return!!("label"===t.localName?[t]:Array.from(t.querySelectorAll("label"))).some(e=>e.hasAttribute("for")?Boolean(this.host.id)&&e.htmlFor===this.host.id:e.contains(this.host))||[t,...Array.from(t.querySelectorAll("[id]"))].some(e=>this.referencedIds.has(e.id))})}unbindLabelActivation(){for(const e of this.currentLabels)e.removeEventListener("click",this.handleLabelActivation)}bindRegistry(){const e=function(e){const t=e.getRootNode();return t.nodeType===Node.DOCUMENT_NODE||"undefined"!=typeof ShadowRoot&&t instanceof ShadowRoot?t:null}(this.host);e!==this.registryRoot&&(this.releaseRegistry(),e&&(this.registryRoot=e,this.registry=function(e){const t=e.nodeType===Node.DOCUMENT_NODE?e.documentElement:e;if(!t||"undefined"==typeof MutationObserver)return null;const i=s.get(e);if(i)return i;const a=new Set,n=new MutationObserver(e=>{for(const t of a)e.some(e=>t.isAffectedBy(e))&&t.sync()});n.observe(t,{subtree:!0,childList:!0,characterData:!0,attributes:!0,attributeFilter:["for","id","aria-label","aria-labelledby","aria-hidden","hidden","alt","title"]});const l={associations:a,observer:n};return s.set(e,l),l}(e)||void 0,this.registry?.associations.add(this)))}releaseRegistry(){this.registry?.associations.delete(this),this.registry&&0===this.registry.associations.size&&this.registryRoot&&(this.registry.observer.disconnect(),s.delete(this.registryRoot)),this.registry=void 0,this.registryRoot=void 0}resolveLabels(){const e=this.host.getRootNode();return"querySelectorAll"in e?Array.from(e.querySelectorAll("label")).filter(e=>e.hasAttribute("for")?Boolean(this.host.id)&&e.htmlFor===this.host.id:e.contains(this.host)):Array.from(this.getInternals()?.labels||[])}}const d=["badInput","customError","patternMismatch","rangeOverflow","rangeUnderflow","stepMismatch","tooLong","tooShort","typeMismatch","valueMissing"];function h(e){return d.some(t=>Boolean(e[t]))}(()=>{let s,a,n,l,r,o,c,d,h,u,p=[e.element("snice-option")],m=[],b=HTMLElement,g=[],v=[],f=[],y=[],w=[],x=[],k=[],O=[],C=[],I=[],D=[];(class extends b{static{a=this}static{const E="function"==typeof Symbol&&Symbol.metadata?Object.create(b[Symbol.metadata]??null):void 0;n=[e.property({})],l=[e.property({})],r=[e.property({type:Boolean})],o=[e.property({type:Boolean})],c=[e.property({})],d=[e.render()],h=[e.styles()],u=[e.ready()],t(this,null,d,{kind:"method",name:"render",static:!1,private:!1,access:{has:e=>"render"in e,get:e=>e.render},metadata:E},null,g),t(this,null,h,{kind:"method",name:"styles",static:!1,private:!1,access:{has:e=>"styles"in e,get:e=>e.styles},metadata:E},null,g),t(this,null,u,{kind:"method",name:"init",static:!1,private:!1,access:{has:e=>"init"in e,get:e=>e.init},metadata:E},null,g),t(null,null,n,{kind:"field",name:"value",static:!1,private:!1,access:{has:e=>"value"in e,get:e=>e.value,set:(e,t)=>{e.value=t}},metadata:E},v,f),t(null,null,l,{kind:"field",name:"label",static:!1,private:!1,access:{has:e=>"label"in e,get:e=>e.label,set:(e,t)=>{e.label=t}},metadata:E},y,w),t(null,null,r,{kind:"field",name:"disabled",static:!1,private:!1,access:{has:e=>"disabled"in e,get:e=>e.disabled,set:(e,t)=>{e.disabled=t}},metadata:E},x,k),t(null,null,o,{kind:"field",name:"selected",static:!1,private:!1,access:{has:e=>"selected"in e,get:e=>e.selected,set:(e,t)=>{e.selected=t}},metadata:E},O,C),t(null,null,c,{kind:"field",name:"icon",static:!1,private:!1,access:{has:e=>"icon"in e,get:e=>e.icon,set:(e,t)=>{e.icon=t}},metadata:E},I,D),t(null,s={value:a},p,{kind:"class",name:a.name,metadata:E},null,m),a=s.value,E&&Object.defineProperty(a,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:E}),i(a,m)}render(){return e.html``}styles(){return e.css`:host { display: none; }`}init(){!this.label&&this.textContent&&(this.label=this.textContent.trim()),this.hasAttribute("value")||this.value||!this.label||(this.value=this.label)}get optionData(){return{value:this.value,label:this.label||this.textContent?.trim()||this.value,disabled:this.disabled,selected:this.selected,icon:this.icon}}constructor(){super(...arguments),this.value=(i(this,g),i(this,v,"")),this.label=(i(this,f),i(this,y,"")),this.disabled=(i(this,w),i(this,x,!1)),this.selected=(i(this,k),i(this,O,!1)),this.icon=(i(this,C),i(this,I,"")),i(this,D)}})})(),(()=>{let s,a,n,l,r,o,d,u,p,m,b,g,v,f,y,w,x,k,O,C,I,D,E,V,S,L,A,N,T,$,B,z,R,F,q,M,P,j,H,K,U,Y,_,G,W,X,Z,J,Q,ee,te,ie,se,ae,ne,le=[e.element("snice-select",{formAssociated:!0,delegatesFocus:!0})],re=[],oe=HTMLElement,ce=[],de=[],he=[],ue=[],pe=[],me=[],be=[],ge=[],ve=[],fe=[],ye=[],we=[],xe=[],ke=[],Oe=[],Ce=[],Ie=[],De=[],Ee=[],Ve=[],Se=[],Le=[],Ae=[],Ne=[],Te=[],$e=[],Be=[],ze=[],Re=[],Fe=[],qe=[],Me=[],Pe=[],je=[],He=[],Ke=[],Ue=[],Ye=[],_e=[],Ge=[],We=[],Xe=[],Ze=[],Je=[],Qe=[],et=[],tt=[],it=[],st=[],at=[],nt=[],lt=[],rt=[],ot=[],ct=[],dt=[],ht=[],ut=[],pt=[],mt=[],bt=[],gt=[],vt=[],ft=[],yt=[],wt=[],xt=[],kt=[],Ot=[],Ct=[],It=[],Dt=[],Et=[];(class extends oe{static{a=this}static{const c="function"==typeof Symbol&&Symbol.metadata?Object.create(oe[Symbol.metadata]??null):void 0;n=[e.state()],l=[e.state()],r=[e.state()],o=[e.property({attribute:"value"})],d=[e.property({type:Boolean})],u=[e.property({type:Boolean})],p=[e.property({type:Boolean})],m=[e.property({type:Boolean})],b=[e.property({type:Boolean})],g=[e.property({type:Boolean})],v=[e.property({type:Boolean})],f=[e.property({type:Boolean})],y=[e.property({type:Boolean,attribute:"allow-free-text"})],w=[e.property({type:Boolean})],x=[e.property({type:Boolean})],k=[e.property({type:Number,attribute:"search-debounce"})],O=[e.property({type:Boolean})],C=[e.property({})],I=[e.property({})],D=[e.property({})],E=[e.property({attribute:"helper-text"})],V=[e.property({attribute:"error-text"})],S=[e.property({})],L=[e.property({attribute:"max-height"})],A=[e.property({type:Array,attribute:!1})],N=[e.query(".select-trigger")],T=[e.query(".select-dropdown")],$=[e.query(".select-value")],B=[e.query(".select-label")],z=[e.query(".select-search-input")],R=[e.query(".select-options")],F=[e.query(".select-clear")],q=[e.query(".select-arrow")],M=[e.query(".select-search")],P=[e.query(".select-editable-input")],j=[e.queryAll(".select-option")],H=[e.request("select/search")],K=[e.render()],U=[e.styles()],Y=[e.ready()],_=[e.reconnect()],G=[e.dispose()],W=[e.watch("valueState")],X=[e.watch("defaultValue")],Z=[e.watch("options")],J=[e.watch("disabled","loading","formDisabled")],Q=[e.watch("required","readonly","multiple")],ee=[e.watch("editable")],te=[e.watch("invalid")],ie=[e.watch("open")],se=[e.dispatch("select-change",{bubbles:!0,composed:!0})],ae=[e.dispatch("select-open",{bubbles:!0,composed:!0})],ne=[e.dispatch("select-close",{bubbles:!0,composed:!0})],t(this,null,H,{kind:"method",name:"performRemoteSearch",static:!1,private:!1,access:{has:e=>"performRemoteSearch"in e,get:e=>e.performRemoteSearch},metadata:c},null,ce),t(this,null,K,{kind:"method",name:"render",static:!1,private:!1,access:{has:e=>"render"in e,get:e=>e.render},metadata:c},null,ce),t(this,null,U,{kind:"method",name:"styles",static:!1,private:!1,access:{has:e=>"styles"in e,get:e=>e.styles},metadata:c},null,ce),t(this,null,Y,{kind:"method",name:"init",static:!1,private:!1,access:{has:e=>"init"in e,get:e=>e.init},metadata:c},null,ce),t(this,null,_,{kind:"method",name:"onReconnect",static:!1,private:!1,access:{has:e=>"onReconnect"in e,get:e=>e.onReconnect},metadata:c},null,ce),t(this,null,G,{kind:"method",name:"cleanup",static:!1,private:!1,access:{has:e=>"cleanup"in e,get:e=>e.cleanup},metadata:c},null,ce),t(this,null,W,{kind:"method",name:"handleValueChange",static:!1,private:!1,access:{has:e=>"handleValueChange"in e,get:e=>e.handleValueChange},metadata:c},null,ce),t(this,null,X,{kind:"method",name:"handleDefaultValueChange",static:!1,private:!1,access:{has:e=>"handleDefaultValueChange"in e,get:e=>e.handleDefaultValueChange},metadata:c},null,ce),t(this,null,Z,{kind:"method",name:"handleOptionsPropertyChange",static:!1,private:!1,access:{has:e=>"handleOptionsPropertyChange"in e,get:e=>e.handleOptionsPropertyChange},metadata:c},null,ce),t(this,null,J,{kind:"method",name:"handleDisabledChange",static:!1,private:!1,access:{has:e=>"handleDisabledChange"in e,get:e=>e.handleDisabledChange},metadata:c},null,ce),t(this,null,Q,{kind:"method",name:"handleValidationConfigurationChange",static:!1,private:!1,access:{has:e=>"handleValidationConfigurationChange"in e,get:e=>e.handleValidationConfigurationChange},metadata:c},null,ce),t(this,null,ee,{kind:"method",name:"handleValidationAnchorChange",static:!1,private:!1,access:{has:e=>"handleValidationAnchorChange"in e,get:e=>e.handleValidationAnchorChange},metadata:c},null,ce),t(this,null,te,{kind:"method",name:"handleInvalidChange",static:!1,private:!1,access:{has:e=>"handleInvalidChange"in e,get:e=>e.handleInvalidChange},metadata:c},null,ce),t(this,null,ie,{kind:"method",name:"handleOpenChange",static:!1,private:!1,access:{has:e=>"handleOpenChange"in e,get:e=>e.handleOpenChange},metadata:c},null,ce),t(this,null,se,{kind:"method",name:"dispatchChangeEvent",static:!1,private:!1,access:{has:e=>"dispatchChangeEvent"in e,get:e=>e.dispatchChangeEvent},metadata:c},null,ce),t(this,null,ae,{kind:"method",name:"dispatchOpenEvent",static:!1,private:!1,access:{has:e=>"dispatchOpenEvent"in e,get:e=>e.dispatchOpenEvent},metadata:c},null,ce),t(this,null,ne,{kind:"method",name:"dispatchCloseEvent",static:!1,private:!1,access:{has:e=>"dispatchCloseEvent"in e,get:e=>e.dispatchCloseEvent},metadata:c},null,ce),t(null,null,n,{kind:"field",name:"valueState",static:!1,private:!1,access:{has:e=>"valueState"in e,get:e=>e.valueState,set:(e,t)=>{e.valueState=t}},metadata:c},de,he),t(null,null,l,{kind:"field",name:"formDisabled",static:!1,private:!1,access:{has:e=>"formDisabled"in e,get:e=>e.formDisabled,set:(e,t)=>{e.formDisabled=t}},metadata:c},ue,pe),t(null,null,r,{kind:"field",name:"constraintInvalid",static:!1,private:!1,access:{has:e=>"constraintInvalid"in e,get:e=>e.constraintInvalid,set:(e,t)=>{e.constraintInvalid=t}},metadata:c},me,be),t(null,null,o,{kind:"field",name:"defaultValue",static:!1,private:!1,access:{has:e=>"defaultValue"in e,get:e=>e.defaultValue,set:(e,t)=>{e.defaultValue=t}},metadata:c},ge,ve),t(null,null,d,{kind:"field",name:"disabled",static:!1,private:!1,access:{has:e=>"disabled"in e,get:e=>e.disabled,set:(e,t)=>{e.disabled=t}},metadata:c},fe,ye),t(null,null,u,{kind:"field",name:"required",static:!1,private:!1,access:{has:e=>"required"in e,get:e=>e.required,set:(e,t)=>{e.required=t}},metadata:c},we,xe),t(null,null,p,{kind:"field",name:"invalid",static:!1,private:!1,access:{has:e=>"invalid"in e,get:e=>e.invalid,set:(e,t)=>{e.invalid=t}},metadata:c},ke,Oe),t(null,null,m,{kind:"field",name:"readonly",static:!1,private:!1,access:{has:e=>"readonly"in e,get:e=>e.readonly,set:(e,t)=>{e.readonly=t}},metadata:c},Ce,Ie),t(null,null,b,{kind:"field",name:"loading",static:!1,private:!1,access:{has:e=>"loading"in e,get:e=>e.loading,set:(e,t)=>{e.loading=t}},metadata:c},De,Ee),t(null,null,g,{kind:"field",name:"multiple",static:!1,private:!1,access:{has:e=>"multiple"in e,get:e=>e.multiple,set:(e,t)=>{e.multiple=t}},metadata:c},Ve,Se),t(null,null,v,{kind:"field",name:"searchable",static:!1,private:!1,access:{has:e=>"searchable"in e,get:e=>e.searchable,set:(e,t)=>{e.searchable=t}},metadata:c},Le,Ae),t(null,null,f,{kind:"field",name:"clearable",static:!1,private:!1,access:{has:e=>"clearable"in e,get:e=>e.clearable,set:(e,t)=>{e.clearable=t}},metadata:c},Ne,Te),t(null,null,y,{kind:"field",name:"allowFreeText",static:!1,private:!1,access:{has:e=>"allowFreeText"in e,get:e=>e.allowFreeText,set:(e,t)=>{e.allowFreeText=t}},metadata:c},$e,Be),t(null,null,w,{kind:"field",name:"editable",static:!1,private:!1,access:{has:e=>"editable"in e,get:e=>e.editable,set:(e,t)=>{e.editable=t}},metadata:c},ze,Re),t(null,null,x,{kind:"field",name:"remote",static:!1,private:!1,access:{has:e=>"remote"in e,get:e=>e.remote,set:(e,t)=>{e.remote=t}},metadata:c},Fe,qe),t(null,null,k,{kind:"field",name:"searchDebounce",static:!1,private:!1,access:{has:e=>"searchDebounce"in e,get:e=>e.searchDebounce,set:(e,t)=>{e.searchDebounce=t}},metadata:c},Me,Pe),t(null,null,O,{kind:"field",name:"open",static:!1,private:!1,access:{has:e=>"open"in e,get:e=>e.open,set:(e,t)=>{e.open=t}},metadata:c},je,He),t(null,null,C,{kind:"field",name:"size",static:!1,private:!1,access:{has:e=>"size"in e,get:e=>e.size,set:(e,t)=>{e.size=t}},metadata:c},Ke,Ue),t(null,null,I,{kind:"field",name:"name",static:!1,private:!1,access:{has:e=>"name"in e,get:e=>e.name,set:(e,t)=>{e.name=t}},metadata:c},Ye,_e),t(null,null,D,{kind:"field",name:"label",static:!1,private:!1,access:{has:e=>"label"in e,get:e=>e.label,set:(e,t)=>{e.label=t}},metadata:c},Ge,We),t(null,null,E,{kind:"field",name:"helperText",static:!1,private:!1,access:{has:e=>"helperText"in e,get:e=>e.helperText,set:(e,t)=>{e.helperText=t}},metadata:c},Xe,Ze),t(null,null,V,{kind:"field",name:"errorText",static:!1,private:!1,access:{has:e=>"errorText"in e,get:e=>e.errorText,set:(e,t)=>{e.errorText=t}},metadata:c},Je,Qe),t(null,null,S,{kind:"field",name:"placeholder",static:!1,private:!1,access:{has:e=>"placeholder"in e,get:e=>e.placeholder,set:(e,t)=>{e.placeholder=t}},metadata:c},et,tt),t(null,null,L,{kind:"field",name:"maxHeight",static:!1,private:!1,access:{has:e=>"maxHeight"in e,get:e=>e.maxHeight,set:(e,t)=>{e.maxHeight=t}},metadata:c},it,st),t(null,null,A,{kind:"field",name:"options",static:!1,private:!1,access:{has:e=>"options"in e,get:e=>e.options,set:(e,t)=>{e.options=t}},metadata:c},at,nt),t(null,null,N,{kind:"field",name:"trigger",static:!1,private:!1,access:{has:e=>"trigger"in e,get:e=>e.trigger,set:(e,t)=>{e.trigger=t}},metadata:c},lt,rt),t(null,null,T,{kind:"field",name:"dropdown",static:!1,private:!1,access:{has:e=>"dropdown"in e,get:e=>e.dropdown,set:(e,t)=>{e.dropdown=t}},metadata:c},ot,ct),t(null,null,$,{kind:"field",name:"valueDisplay",static:!1,private:!1,access:{has:e=>"valueDisplay"in e,get:e=>e.valueDisplay,set:(e,t)=>{e.valueDisplay=t}},metadata:c},dt,ht),t(null,null,B,{kind:"field",name:"labelElement",static:!1,private:!1,access:{has:e=>"labelElement"in e,get:e=>e.labelElement,set:(e,t)=>{e.labelElement=t}},metadata:c},ut,pt),t(null,null,z,{kind:"field",name:"searchInput",static:!1,private:!1,access:{has:e=>"searchInput"in e,get:e=>e.searchInput,set:(e,t)=>{e.searchInput=t}},metadata:c},mt,bt),t(null,null,R,{kind:"field",name:"optionsList",static:!1,private:!1,access:{has:e=>"optionsList"in e,get:e=>e.optionsList,set:(e,t)=>{e.optionsList=t}},metadata:c},gt,vt),t(null,null,F,{kind:"field",name:"clearButton",static:!1,private:!1,access:{has:e=>"clearButton"in e,get:e=>e.clearButton,set:(e,t)=>{e.clearButton=t}},metadata:c},ft,yt),t(null,null,q,{kind:"field",name:"arrow",static:!1,private:!1,access:{has:e=>"arrow"in e,get:e=>e.arrow,set:(e,t)=>{e.arrow=t}},metadata:c},wt,xt),t(null,null,M,{kind:"field",name:"searchContainer",static:!1,private:!1,access:{has:e=>"searchContainer"in e,get:e=>e.searchContainer,set:(e,t)=>{e.searchContainer=t}},metadata:c},kt,Ot),t(null,null,P,{kind:"field",name:"editableInput",static:!1,private:!1,access:{has:e=>"editableInput"in e,get:e=>e.editableInput,set:(e,t)=>{e.editableInput=t}},metadata:c},Ct,It),t(null,null,j,{kind:"field",name:"optionElements",static:!1,private:!1,access:{has:e=>"optionElements"in e,get:e=>e.optionElements,set:(e,t)=>{e.optionElements=t}},metadata:c},Dt,Et),t(null,s={value:a},le,{kind:"class",name:a.name,metadata:c},null,re),a=s.value,c&&Object.defineProperty(a,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:c}),i(a,re)}constructor(){super(),this.internals=i(this,ce),this.dirtyValue=!1,this.valueState=i(this,de,""),this.formDisabled=(i(this,he),i(this,ue,!1)),this.constraintInvalid=(i(this,pe),i(this,me,!1)),this.customValidationMessage=(i(this,be),""),this.defaultValue=i(this,ge,""),this.disabled=(i(this,ve),i(this,fe,!1)),this.required=(i(this,ye),i(this,we,!1)),this.invalid=(i(this,xe),i(this,ke,!1)),this.readonly=(i(this,Oe),i(this,Ce,!1)),this.loading=(i(this,Ie),i(this,De,!1)),this.multiple=(i(this,Ee),i(this,Ve,!1)),this.searchable=(i(this,Se),i(this,Le,!1)),this.clearable=(i(this,Ae),i(this,Ne,!1)),this.allowFreeText=(i(this,Te),i(this,$e,!1)),this.editable=(i(this,Be),i(this,ze,!1)),this.remote=(i(this,Re),i(this,Fe,!1)),this.searchDebounce=(i(this,qe),i(this,Me,300)),this.open=(i(this,Pe),i(this,je,!1)),this.size=(i(this,He),i(this,Ke,"medium")),this.name=(i(this,Ue),i(this,Ye,"")),this.label=(i(this,_e),i(this,Ge,"")),this.helperText=(i(this,We),i(this,Xe,"")),this.errorText=(i(this,Ze),i(this,Je,"")),this.placeholder=(i(this,Qe),i(this,et,"Select an option")),this.descId=(i(this,tt),`snice-select-desc-${Math.random().toString(36).slice(2,10)}`),this.maxHeight=i(this,it,"200px"),this.options=(i(this,st),i(this,at,[])),this.childOptions=(i(this,nt),[]),this.trigger=i(this,lt,void 0),this.dropdown=(i(this,rt),i(this,ot,void 0)),this.valueDisplay=(i(this,ct),i(this,dt,void 0)),this.labelElement=(i(this,ht),i(this,ut,void 0)),this.searchInput=(i(this,pt),i(this,mt,void 0)),this.optionsList=(i(this,bt),i(this,gt,void 0)),this.clearButton=(i(this,vt),i(this,ft,void 0)),this.arrow=(i(this,yt),i(this,wt,void 0)),this.searchContainer=(i(this,xt),i(this,kt,void 0)),this.editableInput=(i(this,Ot),i(this,Ct,void 0)),this.optionElements=(i(this,It),i(this,Dt,void 0)),this.filteredOptions=(i(this,Et),[]),this.selectedValues=new Set,this.focusedIndex=-1,this.editableInputValue="",this.remoteSearchTimeout=0,this.remoteSearching=!1,"function"==typeof this.attachInternals&&(this.internals=this.attachInternals()),this.labelAssociation=new c(this,()=>this.internals,()=>this.editable?this.editableInput:this.trigger,()=>this.label||"Select")}get value(){return this.valueState}set value(e){this.setValue(e,!0)}formAssociatedCallback(){this.syncFormState()}formResetCallback(){this.dirtyValue=!1,this.applyDefaultValue(),this.resetTransientState()}formDisabledCallback(e){this.formDisabled=e,e&&this.isOpen&&this.closeDropdown(),this.syncValidity()}formStateRestoreCallback(e){"string"==typeof e&&(this.setValue(e,!0),this.resetTransientState())}get isOpen(){return this.open}get interactionDisabled(){return this.disabled||this.formDisabled||this.loading}get mergedOptions(){if(this.childOptions.length>0&&this.options.length>0){const e=new Set(this.childOptions.map(e=>e.value));return[...this.childOptions,...this.options.filter(t=>!e.has(t.value))]}return this.childOptions.length>0?this.childOptions:this.options}get resolvableOptions(){if(!this.remote)return this.mergedOptions;const e=this.mergedOptions,t=new Set(e.map(e=>e.value));return[...this.filteredOptions.filter(e=>!t.has(e.value)),...e]}async*performRemoteSearch(e){this.remoteSearching=!0,this.updateDropdownContent();try{const t={query:e,select:this},i=await(yield t);this.remoteSearching=!1,this.filteredOptions=i||[],this.focusedIndex=-1,this.updateDropdownContent()}catch{this.remoteSearching=!1,this.filteredOptions=[],this.updateDropdownContent()}}scheduleRemoteSearch(e){clearTimeout(this.remoteSearchTimeout),this.remoteSearchTimeout=window.setTimeout(()=>{this.performRemoteSearch(e)},this.searchDebounce)}render(){const t=this.invalid||this.constraintInvalid,i=this.labelAssociation.accessibleName;return e.html`
|
|
1
|
+
void 0===globalThis.Snice&&console.warn("[snice] snice-runtime.min.js must be loaded before snice-select.min.js"),function(e){"use strict";function t(e,t,i,s,a,n){function l(e){if(void 0!==e&&"function"!=typeof e)throw new TypeError("Function expected");return e}for(var r,o=s.kind,c="getter"===o?"get":"setter"===o?"set":"value",d=!t&&e?s.static?e:e.prototype:null,h=t||(d?Object.getOwnPropertyDescriptor(d,s.name):{}),u=!1,p=i.length-1;p>=0;p--){var m={};for(var b in s)m[b]="access"===b?{}:s[b];for(var b in s.access)m.access[b]=s.access[b];m.addInitializer=function(e){if(u)throw new TypeError("Cannot add initializers after decoration has completed");n.push(l(e||null))};var g=(0,i[p])("accessor"===o?{get:h.get,set:h.set}:h[c],m);if("accessor"===o){if(void 0===g)continue;if(null===g||"object"!=typeof g)throw new TypeError("Object expected");(r=l(g.get))&&(h.get=r),(r=l(g.set))&&(h.set=r),(r=l(g.init))&&a.unshift(r)}else(r=l(g))&&("field"===o?a.unshift(r):h[c]=r)}d&&Object.defineProperty(d,s.name,h),u=!0}function i(e,t,i){for(var s=arguments.length>2,a=0;a<t.length;a++)i=s?t[a].call(e,i):t[a].call(e);return s?i:void 0}"function"==typeof SuppressedError&&SuppressedError;const s=new WeakMap;function a(e){return e.replace(/\s+/gu," ").trim()}function n(e,t){return e===t||e.nodeType===Node.ELEMENT_NODE&&e.contains(t)}function l(e,t){const i=e.getRootNode();return"getElementById"in i?i.getElementById(t):null}function r(e,t){if(e===t)return"";if(e.nodeType===Node.TEXT_NODE)return e.nodeValue||"";if(e.nodeType!==Node.ELEMENT_NODE)return"";const i=e;return i.hidden||"true"===i.getAttribute("aria-hidden")||["script","style","template"].includes(i.localName)?"":"br"===i.localName?" ":"img"===i.localName?i.getAttribute("alt")||"":Array.from(i.childNodes).map(e=>r(e,t)).join(" ")}function o(e,t){const i=e.getAttribute("aria-labelledby");if(i){const s=a(i.split(/\s+/u).map(t=>l(e,t)).filter(t=>Boolean(t)&&t!==e).map(e=>r(e,t)).join(" "));if(s)return s}return e.hasAttribute("aria-label")?a(e.getAttribute("aria-label")||""):a(r(e,t))||a(e.getAttribute("title")||"")}class c{constructor(e,t,i,s,a){this.host=e,this.getInternals=t,this.getTarget=i,this.getFallbackName=s,this.syncRelatedNames=a,this.connected=!1,this.currentLabels=[],this.currentNamingNodes=[],this.referencedIds=new Set,this.handleHostActivation=e=>{if(e.composedPath()[0]!==this.host)return;if(this.currentLabels=this.resolveLabels(),0===this.currentLabels.length)return;const t=this.getTarget();t?t.focus():e.preventDefault()},this.handleLabelActivation=e=>{const t=e.composedPath(),i=e.target;if(i===this.host||i instanceof Node&&this.host.contains(i))return;const s=e.currentTarget;if(t.some(e=>e instanceof HTMLElement&&e!==s&&e.matches('a[href], button, input, select, textarea, [contenteditable]:not([contenteditable="false"]), [role="button"], [role="link"]')))return;const a=this.getTarget();a?(a.focus(),setTimeout(()=>{const e=this.getTarget();this.connected&&e?.isConnected&&this.currentLabels.includes(s)&&e.focus()},0)):e.preventDefault()}}get labels(){const e=this.host.getRootNode();if(this.host.id&&"querySelectorAll"in e)try{const t=CSS.escape(this.host.id),i=CSS.escape(this.host.localName);return e.querySelectorAll(`label[for="${t}"], label:not([for]):has(${i}#${t})`)}catch{}return this.getInternals()?.labels??null}get accessibleName(){const e=this.resolveLabels();return a(e.length>0?e.map(e=>o(e,this.host)).join(" "):this.getFallbackName())}connect(){this.connected||(this.connected=!0,this.host.addEventListener("click",this.handleHostActivation),this.bindRegistry(),this.sync())}disconnect(){this.connected&&(this.connected=!1,this.host.removeEventListener("click",this.handleHostActivation),this.unbindLabelActivation(),this.releaseRegistry(),this.currentLabels=[],this.currentNamingNodes=[],this.referencedIds.clear())}sync(){if(this.connected&&this.bindRegistry(),this.unbindLabelActivation(),this.currentLabels=this.resolveLabels(),this.connected)for(const e of this.currentLabels)e.addEventListener("click",this.handleLabelActivation);this.currentNamingNodes=[...this.currentLabels],this.referencedIds.clear();for(const e of this.currentLabels)for(const t of(e.getAttribute("aria-labelledby")||"").split(/\s+/u).filter(Boolean)){this.referencedIds.add(t);const i=l(e,t);i&&i!==e&&this.currentNamingNodes.push(i)}const e=a(this.currentLabels.length>0?this.currentLabels.map(e=>o(e,this.host)).join(" "):this.getFallbackName());this.getTarget()?.setAttribute("aria-label",e),this.syncRelatedNames?.(e)}isAffectedBy(e){if("attributes"===e.type){if(e.target===this.host&&"id"===e.attributeName)return!0;const t=e.target;return"label"===t.localName&&"for"===e.attributeName?this.currentLabels.includes(t)||Boolean(this.host.id)&&t.htmlFor===this.host.id:!("id"!==e.attributeName||!this.referencedIds.has(t.id))||this.currentNamingNodes.some(e=>e===t||e.contains(t))}return!!this.currentNamingNodes.some(t=>t===e.target||t.contains(e.target))||"childList"===e.type&&[...e.addedNodes,...e.removedNodes].some(e=>{if(n(e,this.host)||n(this.host,e))return!0;if(this.currentNamingNodes.some(t=>n(e,t)))return!0;if(e.nodeType!==Node.ELEMENT_NODE)return!1;const t=e;return!!("label"===t.localName?[t]:Array.from(t.querySelectorAll("label"))).some(e=>e.hasAttribute("for")?Boolean(this.host.id)&&e.htmlFor===this.host.id:e.contains(this.host))||[t,...Array.from(t.querySelectorAll("[id]"))].some(e=>this.referencedIds.has(e.id))})}unbindLabelActivation(){for(const e of this.currentLabels)e.removeEventListener("click",this.handleLabelActivation)}bindRegistry(){const e=function(e){const t=e.getRootNode();return t.nodeType===Node.DOCUMENT_NODE||"undefined"!=typeof ShadowRoot&&t instanceof ShadowRoot?t:null}(this.host);e!==this.registryRoot&&(this.releaseRegistry(),e&&(this.registryRoot=e,this.registry=function(e){const t=e.nodeType===Node.DOCUMENT_NODE?e.documentElement:e;if(!t||"undefined"==typeof MutationObserver)return null;const i=s.get(e);if(i)return i;const a=new Set,n=new MutationObserver(e=>{for(const t of a)e.some(e=>t.isAffectedBy(e))&&t.sync()});n.observe(t,{subtree:!0,childList:!0,characterData:!0,attributes:!0,attributeFilter:["for","id","aria-label","aria-labelledby","aria-hidden","hidden","alt","title"]});const l={associations:a,observer:n};return s.set(e,l),l}(e)||void 0,this.registry?.associations.add(this)))}releaseRegistry(){this.registry?.associations.delete(this),this.registry&&0===this.registry.associations.size&&this.registryRoot&&(this.registry.observer.disconnect(),s.delete(this.registryRoot)),this.registry=void 0,this.registryRoot=void 0}resolveLabels(){const e=this.host.getRootNode();return"querySelectorAll"in e?Array.from(e.querySelectorAll("label")).filter(e=>e.hasAttribute("for")?Boolean(this.host.id)&&e.htmlFor===this.host.id:e.contains(this.host)):Array.from(this.getInternals()?.labels||[])}}const d=["badInput","customError","patternMismatch","rangeOverflow","rangeUnderflow","stepMismatch","tooLong","tooShort","typeMismatch","valueMissing"];function h(e){return d.some(t=>Boolean(e[t]))}(()=>{let s,a,n,l,r,o,c,d,h,u,p=[e.element("snice-option")],m=[],b=HTMLElement,g=[],v=[],f=[],y=[],w=[],x=[],k=[],O=[],C=[],D=[],I=[];(class extends b{static{a=this}static{const E="function"==typeof Symbol&&Symbol.metadata?Object.create(b[Symbol.metadata]??null):void 0;n=[e.property({})],l=[e.property({})],r=[e.property({type:Boolean})],o=[e.property({type:Boolean})],c=[e.property({})],d=[e.render()],h=[e.styles()],u=[e.ready()],t(this,null,d,{kind:"method",name:"render",static:!1,private:!1,access:{has:e=>"render"in e,get:e=>e.render},metadata:E},null,g),t(this,null,h,{kind:"method",name:"styles",static:!1,private:!1,access:{has:e=>"styles"in e,get:e=>e.styles},metadata:E},null,g),t(this,null,u,{kind:"method",name:"init",static:!1,private:!1,access:{has:e=>"init"in e,get:e=>e.init},metadata:E},null,g),t(null,null,n,{kind:"field",name:"value",static:!1,private:!1,access:{has:e=>"value"in e,get:e=>e.value,set:(e,t)=>{e.value=t}},metadata:E},v,f),t(null,null,l,{kind:"field",name:"label",static:!1,private:!1,access:{has:e=>"label"in e,get:e=>e.label,set:(e,t)=>{e.label=t}},metadata:E},y,w),t(null,null,r,{kind:"field",name:"disabled",static:!1,private:!1,access:{has:e=>"disabled"in e,get:e=>e.disabled,set:(e,t)=>{e.disabled=t}},metadata:E},x,k),t(null,null,o,{kind:"field",name:"selected",static:!1,private:!1,access:{has:e=>"selected"in e,get:e=>e.selected,set:(e,t)=>{e.selected=t}},metadata:E},O,C),t(null,null,c,{kind:"field",name:"icon",static:!1,private:!1,access:{has:e=>"icon"in e,get:e=>e.icon,set:(e,t)=>{e.icon=t}},metadata:E},D,I),t(null,s={value:a},p,{kind:"class",name:a.name,metadata:E},null,m),a=s.value,E&&Object.defineProperty(a,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:E}),i(a,m)}render(){return e.html``}styles(){return e.css`:host { display: none; }`}init(){!this.label&&this.textContent&&(this.label=this.textContent.trim()),this.hasAttribute("value")||this.value||!this.label||(this.value=this.label)}get optionData(){return{value:this.value,label:this.label||this.textContent?.trim()||this.value,disabled:this.disabled,selected:this.selected,icon:this.icon}}constructor(){super(...arguments),this.value=(i(this,g),i(this,v,"")),this.label=(i(this,f),i(this,y,"")),this.disabled=(i(this,w),i(this,x,!1)),this.selected=(i(this,k),i(this,O,!1)),this.icon=(i(this,C),i(this,D,"")),i(this,I)}})})(),(()=>{let s,a,n,l,r,o,d,u,p,m,b,g,v,f,y,w,x,k,O,C,D,I,E,V,S,L,A,N,T,$,B,z,R,F,q,M,P,j,H,K,U,Y,_,G,W,X,Z,J,Q,ee,te,ie,se,ae,ne,le=[e.element("snice-select",{formAssociated:!0,delegatesFocus:!0})],re=[],oe=HTMLElement,ce=[],de=[],he=[],ue=[],pe=[],me=[],be=[],ge=[],ve=[],fe=[],ye=[],we=[],xe=[],ke=[],Oe=[],Ce=[],De=[],Ie=[],Ee=[],Ve=[],Se=[],Le=[],Ae=[],Ne=[],Te=[],$e=[],Be=[],ze=[],Re=[],Fe=[],qe=[],Me=[],Pe=[],je=[],He=[],Ke=[],Ue=[],Ye=[],_e=[],Ge=[],We=[],Xe=[],Ze=[],Je=[],Qe=[],et=[],tt=[],it=[],st=[],at=[],nt=[],lt=[],rt=[],ot=[],ct=[],dt=[],ht=[],ut=[],pt=[],mt=[],bt=[],gt=[],vt=[],ft=[],yt=[],wt=[],xt=[],kt=[],Ot=[],Ct=[],Dt=[],It=[],Et=[];(class extends oe{static{a=this}static{const c="function"==typeof Symbol&&Symbol.metadata?Object.create(oe[Symbol.metadata]??null):void 0;n=[e.state()],l=[e.state()],r=[e.state()],o=[e.property({attribute:"value"})],d=[e.property({type:Boolean})],u=[e.property({type:Boolean})],p=[e.property({type:Boolean})],m=[e.property({type:Boolean})],b=[e.property({type:Boolean})],g=[e.property({type:Boolean})],v=[e.property({type:Boolean})],f=[e.property({type:Boolean})],y=[e.property({type:Boolean,attribute:"allow-free-text"})],w=[e.property({type:Boolean})],x=[e.property({type:Boolean})],k=[e.property({type:Number,attribute:"search-debounce"})],O=[e.property({type:Boolean})],C=[e.property({})],D=[e.property({})],I=[e.property({})],E=[e.property({attribute:"helper-text"})],V=[e.property({attribute:"error-text"})],S=[e.property({})],L=[e.property({attribute:"max-height"})],A=[e.property({type:Array,attribute:!1})],N=[e.query(".select-trigger")],T=[e.query(".select-dropdown")],$=[e.query(".select-value")],B=[e.query(".select-label")],z=[e.query(".select-search-input")],R=[e.query(".select-options")],F=[e.query(".select-clear")],q=[e.query(".select-arrow")],M=[e.query(".select-search")],P=[e.query(".select-editable-input")],j=[e.queryAll(".select-option")],H=[e.request("select/search")],K=[e.render()],U=[e.styles()],Y=[e.ready()],_=[e.reconnect()],G=[e.dispose()],W=[e.watch("valueState")],X=[e.watch("defaultValue")],Z=[e.watch("options")],J=[e.watch("disabled","loading","formDisabled")],Q=[e.watch("required","readonly","multiple")],ee=[e.watch("editable")],te=[e.watch("invalid")],ie=[e.watch("open")],se=[e.dispatch("select-change",{bubbles:!0,composed:!0})],ae=[e.dispatch("select-open",{bubbles:!0,composed:!0})],ne=[e.dispatch("select-close",{bubbles:!0,composed:!0})],t(this,null,H,{kind:"method",name:"performRemoteSearch",static:!1,private:!1,access:{has:e=>"performRemoteSearch"in e,get:e=>e.performRemoteSearch},metadata:c},null,ce),t(this,null,K,{kind:"method",name:"render",static:!1,private:!1,access:{has:e=>"render"in e,get:e=>e.render},metadata:c},null,ce),t(this,null,U,{kind:"method",name:"styles",static:!1,private:!1,access:{has:e=>"styles"in e,get:e=>e.styles},metadata:c},null,ce),t(this,null,Y,{kind:"method",name:"init",static:!1,private:!1,access:{has:e=>"init"in e,get:e=>e.init},metadata:c},null,ce),t(this,null,_,{kind:"method",name:"onReconnect",static:!1,private:!1,access:{has:e=>"onReconnect"in e,get:e=>e.onReconnect},metadata:c},null,ce),t(this,null,G,{kind:"method",name:"cleanup",static:!1,private:!1,access:{has:e=>"cleanup"in e,get:e=>e.cleanup},metadata:c},null,ce),t(this,null,W,{kind:"method",name:"handleValueChange",static:!1,private:!1,access:{has:e=>"handleValueChange"in e,get:e=>e.handleValueChange},metadata:c},null,ce),t(this,null,X,{kind:"method",name:"handleDefaultValueChange",static:!1,private:!1,access:{has:e=>"handleDefaultValueChange"in e,get:e=>e.handleDefaultValueChange},metadata:c},null,ce),t(this,null,Z,{kind:"method",name:"handleOptionsPropertyChange",static:!1,private:!1,access:{has:e=>"handleOptionsPropertyChange"in e,get:e=>e.handleOptionsPropertyChange},metadata:c},null,ce),t(this,null,J,{kind:"method",name:"handleDisabledChange",static:!1,private:!1,access:{has:e=>"handleDisabledChange"in e,get:e=>e.handleDisabledChange},metadata:c},null,ce),t(this,null,Q,{kind:"method",name:"handleValidationConfigurationChange",static:!1,private:!1,access:{has:e=>"handleValidationConfigurationChange"in e,get:e=>e.handleValidationConfigurationChange},metadata:c},null,ce),t(this,null,ee,{kind:"method",name:"handleValidationAnchorChange",static:!1,private:!1,access:{has:e=>"handleValidationAnchorChange"in e,get:e=>e.handleValidationAnchorChange},metadata:c},null,ce),t(this,null,te,{kind:"method",name:"handleInvalidChange",static:!1,private:!1,access:{has:e=>"handleInvalidChange"in e,get:e=>e.handleInvalidChange},metadata:c},null,ce),t(this,null,ie,{kind:"method",name:"handleOpenChange",static:!1,private:!1,access:{has:e=>"handleOpenChange"in e,get:e=>e.handleOpenChange},metadata:c},null,ce),t(this,null,se,{kind:"method",name:"dispatchChangeEvent",static:!1,private:!1,access:{has:e=>"dispatchChangeEvent"in e,get:e=>e.dispatchChangeEvent},metadata:c},null,ce),t(this,null,ae,{kind:"method",name:"dispatchOpenEvent",static:!1,private:!1,access:{has:e=>"dispatchOpenEvent"in e,get:e=>e.dispatchOpenEvent},metadata:c},null,ce),t(this,null,ne,{kind:"method",name:"dispatchCloseEvent",static:!1,private:!1,access:{has:e=>"dispatchCloseEvent"in e,get:e=>e.dispatchCloseEvent},metadata:c},null,ce),t(null,null,n,{kind:"field",name:"valueState",static:!1,private:!1,access:{has:e=>"valueState"in e,get:e=>e.valueState,set:(e,t)=>{e.valueState=t}},metadata:c},de,he),t(null,null,l,{kind:"field",name:"formDisabled",static:!1,private:!1,access:{has:e=>"formDisabled"in e,get:e=>e.formDisabled,set:(e,t)=>{e.formDisabled=t}},metadata:c},ue,pe),t(null,null,r,{kind:"field",name:"constraintInvalid",static:!1,private:!1,access:{has:e=>"constraintInvalid"in e,get:e=>e.constraintInvalid,set:(e,t)=>{e.constraintInvalid=t}},metadata:c},me,be),t(null,null,o,{kind:"field",name:"defaultValue",static:!1,private:!1,access:{has:e=>"defaultValue"in e,get:e=>e.defaultValue,set:(e,t)=>{e.defaultValue=t}},metadata:c},ge,ve),t(null,null,d,{kind:"field",name:"disabled",static:!1,private:!1,access:{has:e=>"disabled"in e,get:e=>e.disabled,set:(e,t)=>{e.disabled=t}},metadata:c},fe,ye),t(null,null,u,{kind:"field",name:"required",static:!1,private:!1,access:{has:e=>"required"in e,get:e=>e.required,set:(e,t)=>{e.required=t}},metadata:c},we,xe),t(null,null,p,{kind:"field",name:"invalid",static:!1,private:!1,access:{has:e=>"invalid"in e,get:e=>e.invalid,set:(e,t)=>{e.invalid=t}},metadata:c},ke,Oe),t(null,null,m,{kind:"field",name:"readonly",static:!1,private:!1,access:{has:e=>"readonly"in e,get:e=>e.readonly,set:(e,t)=>{e.readonly=t}},metadata:c},Ce,De),t(null,null,b,{kind:"field",name:"loading",static:!1,private:!1,access:{has:e=>"loading"in e,get:e=>e.loading,set:(e,t)=>{e.loading=t}},metadata:c},Ie,Ee),t(null,null,g,{kind:"field",name:"multiple",static:!1,private:!1,access:{has:e=>"multiple"in e,get:e=>e.multiple,set:(e,t)=>{e.multiple=t}},metadata:c},Ve,Se),t(null,null,v,{kind:"field",name:"searchable",static:!1,private:!1,access:{has:e=>"searchable"in e,get:e=>e.searchable,set:(e,t)=>{e.searchable=t}},metadata:c},Le,Ae),t(null,null,f,{kind:"field",name:"clearable",static:!1,private:!1,access:{has:e=>"clearable"in e,get:e=>e.clearable,set:(e,t)=>{e.clearable=t}},metadata:c},Ne,Te),t(null,null,y,{kind:"field",name:"allowFreeText",static:!1,private:!1,access:{has:e=>"allowFreeText"in e,get:e=>e.allowFreeText,set:(e,t)=>{e.allowFreeText=t}},metadata:c},$e,Be),t(null,null,w,{kind:"field",name:"editable",static:!1,private:!1,access:{has:e=>"editable"in e,get:e=>e.editable,set:(e,t)=>{e.editable=t}},metadata:c},ze,Re),t(null,null,x,{kind:"field",name:"remote",static:!1,private:!1,access:{has:e=>"remote"in e,get:e=>e.remote,set:(e,t)=>{e.remote=t}},metadata:c},Fe,qe),t(null,null,k,{kind:"field",name:"searchDebounce",static:!1,private:!1,access:{has:e=>"searchDebounce"in e,get:e=>e.searchDebounce,set:(e,t)=>{e.searchDebounce=t}},metadata:c},Me,Pe),t(null,null,O,{kind:"field",name:"open",static:!1,private:!1,access:{has:e=>"open"in e,get:e=>e.open,set:(e,t)=>{e.open=t}},metadata:c},je,He),t(null,null,C,{kind:"field",name:"size",static:!1,private:!1,access:{has:e=>"size"in e,get:e=>e.size,set:(e,t)=>{e.size=t}},metadata:c},Ke,Ue),t(null,null,D,{kind:"field",name:"name",static:!1,private:!1,access:{has:e=>"name"in e,get:e=>e.name,set:(e,t)=>{e.name=t}},metadata:c},Ye,_e),t(null,null,I,{kind:"field",name:"label",static:!1,private:!1,access:{has:e=>"label"in e,get:e=>e.label,set:(e,t)=>{e.label=t}},metadata:c},Ge,We),t(null,null,E,{kind:"field",name:"helperText",static:!1,private:!1,access:{has:e=>"helperText"in e,get:e=>e.helperText,set:(e,t)=>{e.helperText=t}},metadata:c},Xe,Ze),t(null,null,V,{kind:"field",name:"errorText",static:!1,private:!1,access:{has:e=>"errorText"in e,get:e=>e.errorText,set:(e,t)=>{e.errorText=t}},metadata:c},Je,Qe),t(null,null,S,{kind:"field",name:"placeholder",static:!1,private:!1,access:{has:e=>"placeholder"in e,get:e=>e.placeholder,set:(e,t)=>{e.placeholder=t}},metadata:c},et,tt),t(null,null,L,{kind:"field",name:"maxHeight",static:!1,private:!1,access:{has:e=>"maxHeight"in e,get:e=>e.maxHeight,set:(e,t)=>{e.maxHeight=t}},metadata:c},it,st),t(null,null,A,{kind:"field",name:"options",static:!1,private:!1,access:{has:e=>"options"in e,get:e=>e.options,set:(e,t)=>{e.options=t}},metadata:c},at,nt),t(null,null,N,{kind:"field",name:"trigger",static:!1,private:!1,access:{has:e=>"trigger"in e,get:e=>e.trigger,set:(e,t)=>{e.trigger=t}},metadata:c},lt,rt),t(null,null,T,{kind:"field",name:"dropdown",static:!1,private:!1,access:{has:e=>"dropdown"in e,get:e=>e.dropdown,set:(e,t)=>{e.dropdown=t}},metadata:c},ot,ct),t(null,null,$,{kind:"field",name:"valueDisplay",static:!1,private:!1,access:{has:e=>"valueDisplay"in e,get:e=>e.valueDisplay,set:(e,t)=>{e.valueDisplay=t}},metadata:c},dt,ht),t(null,null,B,{kind:"field",name:"labelElement",static:!1,private:!1,access:{has:e=>"labelElement"in e,get:e=>e.labelElement,set:(e,t)=>{e.labelElement=t}},metadata:c},ut,pt),t(null,null,z,{kind:"field",name:"searchInput",static:!1,private:!1,access:{has:e=>"searchInput"in e,get:e=>e.searchInput,set:(e,t)=>{e.searchInput=t}},metadata:c},mt,bt),t(null,null,R,{kind:"field",name:"optionsList",static:!1,private:!1,access:{has:e=>"optionsList"in e,get:e=>e.optionsList,set:(e,t)=>{e.optionsList=t}},metadata:c},gt,vt),t(null,null,F,{kind:"field",name:"clearButton",static:!1,private:!1,access:{has:e=>"clearButton"in e,get:e=>e.clearButton,set:(e,t)=>{e.clearButton=t}},metadata:c},ft,yt),t(null,null,q,{kind:"field",name:"arrow",static:!1,private:!1,access:{has:e=>"arrow"in e,get:e=>e.arrow,set:(e,t)=>{e.arrow=t}},metadata:c},wt,xt),t(null,null,M,{kind:"field",name:"searchContainer",static:!1,private:!1,access:{has:e=>"searchContainer"in e,get:e=>e.searchContainer,set:(e,t)=>{e.searchContainer=t}},metadata:c},kt,Ot),t(null,null,P,{kind:"field",name:"editableInput",static:!1,private:!1,access:{has:e=>"editableInput"in e,get:e=>e.editableInput,set:(e,t)=>{e.editableInput=t}},metadata:c},Ct,Dt),t(null,null,j,{kind:"field",name:"optionElements",static:!1,private:!1,access:{has:e=>"optionElements"in e,get:e=>e.optionElements,set:(e,t)=>{e.optionElements=t}},metadata:c},It,Et),t(null,s={value:a},le,{kind:"class",name:a.name,metadata:c},null,re),a=s.value,c&&Object.defineProperty(a,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:c}),i(a,re)}constructor(){super(),this.internals=i(this,ce),this.dirtyValue=!1,this.valueState=i(this,de,""),this.formDisabled=(i(this,he),i(this,ue,!1)),this.constraintInvalid=(i(this,pe),i(this,me,!1)),this.customValidationMessage=(i(this,be),""),this.defaultValue=i(this,ge,""),this.disabled=(i(this,ve),i(this,fe,!1)),this.required=(i(this,ye),i(this,we,!1)),this.invalid=(i(this,xe),i(this,ke,!1)),this.readonly=(i(this,Oe),i(this,Ce,!1)),this.loading=(i(this,De),i(this,Ie,!1)),this.multiple=(i(this,Ee),i(this,Ve,!1)),this.searchable=(i(this,Se),i(this,Le,!1)),this.clearable=(i(this,Ae),i(this,Ne,!1)),this.allowFreeText=(i(this,Te),i(this,$e,!1)),this.editable=(i(this,Be),i(this,ze,!1)),this.remote=(i(this,Re),i(this,Fe,!1)),this.searchDebounce=(i(this,qe),i(this,Me,300)),this.open=(i(this,Pe),i(this,je,!1)),this.size=(i(this,He),i(this,Ke,"medium")),this.name=(i(this,Ue),i(this,Ye,"")),this.label=(i(this,_e),i(this,Ge,"")),this.helperText=(i(this,We),i(this,Xe,"")),this.errorText=(i(this,Ze),i(this,Je,"")),this.placeholder=(i(this,Qe),i(this,et,"Select an option")),this.descId=(i(this,tt),`snice-select-desc-${Math.random().toString(36).slice(2,10)}`),this.maxHeight=i(this,it,"200px"),this.options=(i(this,st),i(this,at,[])),this.childOptions=(i(this,nt),[]),this.trigger=i(this,lt,void 0),this.dropdown=(i(this,rt),i(this,ot,void 0)),this.valueDisplay=(i(this,ct),i(this,dt,void 0)),this.labelElement=(i(this,ht),i(this,ut,void 0)),this.searchInput=(i(this,pt),i(this,mt,void 0)),this.optionsList=(i(this,bt),i(this,gt,void 0)),this.clearButton=(i(this,vt),i(this,ft,void 0)),this.arrow=(i(this,yt),i(this,wt,void 0)),this.searchContainer=(i(this,xt),i(this,kt,void 0)),this.editableInput=(i(this,Ot),i(this,Ct,void 0)),this.optionElements=(i(this,Dt),i(this,It,void 0)),this.filteredOptions=(i(this,Et),[]),this.selectedValues=new Set,this.focusedIndex=-1,this.editableInputValue="",this.remoteSearchTimeout=0,this.remoteSearching=!1,"function"==typeof this.attachInternals&&(this.internals=this.attachInternals()),this.labelAssociation=new c(this,()=>this.internals,()=>this.editable?this.editableInput:this.trigger,()=>this.label||"Select")}get value(){return this.valueState}set value(e){this.setValue(e,!0)}formAssociatedCallback(){this.syncFormState()}formResetCallback(){this.dirtyValue=!1,this.applyDefaultValue(),this.resetTransientState()}formDisabledCallback(e){this.formDisabled=e,e&&this.isOpen&&this.closeDropdown(),this.syncValidity()}formStateRestoreCallback(e){"string"==typeof e&&(this.setValue(e,!0),this.resetTransientState())}get isOpen(){return this.open}get interactionDisabled(){return this.disabled||this.formDisabled||this.loading}get mergedOptions(){if(this.childOptions.length>0&&this.options.length>0){const e=new Set(this.childOptions.map(e=>e.value));return[...this.childOptions,...this.options.filter(t=>!e.has(t.value))]}return this.childOptions.length>0?this.childOptions:this.options}get resolvableOptions(){if(!this.remote)return this.mergedOptions;const e=this.mergedOptions,t=new Set(e.map(e=>e.value));return[...this.filteredOptions.filter(e=>!t.has(e.value)),...e]}async*performRemoteSearch(e){this.remoteSearching=!0,this.updateDropdownContent();try{const t={query:e,select:this},i=await(yield t);this.remoteSearching=!1,this.filteredOptions=i||[],this.focusedIndex=-1,this.updateDropdownContent()}catch{this.remoteSearching=!1,this.filteredOptions=[],this.updateDropdownContent()}}scheduleRemoteSearch(e){clearTimeout(this.remoteSearchTimeout),this.remoteSearchTimeout=window.setTimeout(()=>{this.performRemoteSearch(e)},this.searchDebounce)}render(){const t=this.invalid||this.constraintInvalid,i=this.labelAssociation.accessibleName;return e.html`
|
|
2
2
|
<div class="select-wrapper">
|
|
3
3
|
<label class="${`select-label select-label--${this.size} ${this.required?"select-label--required":""}`}" part="label" ?hidden="${!this.label}" @click="${()=>this.focus()}">
|
|
4
4
|
${this.label}
|
|
@@ -107,5 +107,5 @@ void 0===globalThis.Snice&&console.warn("[snice] snice-runtime.min.js must be lo
|
|
|
107
107
|
<default></default>
|
|
108
108
|
</case>
|
|
109
109
|
</div>
|
|
110
|
-
`}createIcon(e,t){const i=document.createElement("img");return i.className=e,i.setAttribute("src",t||""),i.setAttribute("alt",""),i.hidden=!t,i}renderOptions(){const e=document.createDocumentFragment();if(this.remoteSearching){const t=document.createElement("div");t.className="select-loading-indicator";const i=document.createElement("span");i.className="select-loading-spinner";const s=document.createElement("span");return s.textContent="Searching...",t.append(i,s),e.append(t),e}const t=this.searchable||this.editable||this.remote?this.filteredOptions:this.mergedOptions;if(0===t.length){const t=document.createElement("div");t.className="select-no-options";const i=document.createElement("span");i.className="select-no-options-text",i.dataset.search="true",i.hidden=!(this.searchable||this.editable||this.remote)||this.filteredOptions.length>0,i.textContent="No matches found";const s=document.createElement("span");return s.className="select-no-options-text",s.dataset.search="false",s.hidden=(this.searchable||this.editable||this.remote)&&0===this.filteredOptions.length,s.textContent="No options available",t.append(i,s),e.append(t),e}return t.forEach((t,i)=>{const s=this.multiple?this.selectedValues.has(t.value):t.value===this.value,a=document.createElement("div");a.className="select-option",a.classList.toggle("select-option--selected",s),a.classList.toggle("select-option--disabled",Boolean(t.disabled)),a.classList.toggle("select-option--focused",i===this.focusedIndex),a.classList.toggle("select-option--has-icon",Boolean(t.icon)),a.setAttribute("data-value",t.value),a.setAttribute("role","option"),a.setAttribute("aria-selected",String(s)),a.setAttribute("aria-disabled",String(t.disabled)),a.setAttribute("part","option");const n=document.createElement("span");n.className="select-option-check",n.setAttribute("aria-hidden","true"),n.hidden=!this.multiple;const l=document.createElement("span");l.className="select-option-check-mark",l.hidden=!s,l.textContent="✓",n.append(l);const r=document.createElement("span");r.className="select-option-label",r.textContent=t.label,a.append(n,this.createIcon("select-option-icon",t.icon),r),e.append(a)}),e}styles(){return e.css`${":host([hidden]){display:none}:host{display:inline-block;font-family:var(--snice-font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif);position:relative;width:100%;max-width:18.75rem}[hidden]{display:none!important}img[src=\"\"]{display:none}.select-wrapper{position:relative;width:100%}.select-label{display:block;margin-bottom:.25rem;font-size:var(--snice-font-size-sm, .875rem);font-weight:var(--snice-font-weight-medium,500);line-height:var(--snice-line-height-normal, 1.5);color:var(--snice-color-text,rgb(23 23 23));text-align:left}.select-label--required::after{content:' *';color:var(--snice-color-danger,rgb(220 38 38))}.select-error-text,.select-helper-text{display:block;margin-top:var(--snice-spacing-2xs,.25rem);font-size:var(--snice-font-size-xs, .75rem);font-weight:var(--snice-font-weight-normal,400);line-height:var(--snice-line-height-normal, 1.5)}.select-helper-text{color:var(--snice-color-text-secondary,rgb(82 82 82))}.select-error-text{color:var(--snice-color-danger,rgb(220 38 38))}.select-trigger{box-sizing:border-box;min-width:0;width:100%;display:flex;align-items:center;justify-content:space-between;background:var(--snice-color-surface-container-lowest,rgb(248 247 245));border:1px solid var(--snice-color-border,rgb(226 226 226));border-radius:var(--snice-border-radius-md,.25rem);cursor:pointer;transition:all var(--snice-transition-fast, 150ms) ease;position:relative;text-align:left;font-family:inherit;color:var(--snice-color-text,rgb(23 23 23))}.select-trigger--small{padding:.375rem 2rem .375rem .625rem;font-size:var(--snice-font-size-sm, .875rem);min-height:2rem}.select-trigger--medium{padding:.5rem 2.25rem .5rem .75rem;font-size:var(--snice-font-size-md, 1rem);min-height:var(--snice-select-min-height,2.5rem)}.select-trigger--large{padding:.625rem 2.5rem .625rem .875rem;font-size:var(--snice-font-size-lg, 1.125rem);min-height:3rem}.select-trigger:hover:not(.select-trigger--disabled){border-color:var(--snice-color-border-hover,rgb(180 180 180))}.select-trigger:focus-visible{outline:2px solid var(--snice-color-primary,rgb(37 99 235));outline-offset:2px;border-color:var(--snice-color-primary,rgb(37 99 235))}.select-trigger--open{border-color:var(--snice-color-primary,rgb(37 99 235))}.select-trigger--disabled{background:var(--snice-color-surface-container-low,rgb(245 245 245));cursor:not-allowed;opacity:.6}.select-trigger--readonly{background:var(--snice-color-surface-container-low,rgb(245 245 245));cursor:default}.select-trigger--invalid{border-color:var(--snice-color-danger,rgb(220 38 38))}.select-placeholder{color:var(--snice-color-text-secondary,rgb(82 82 82))}.select-value{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.select-value--single{display:flex;align-items:center;gap:.5rem}.select-value-icon{width:1rem;height:1rem;object-fit:contain;flex-shrink:0}.select-value--multiple{display:flex;gap:.25rem;flex-wrap:wrap}.select-tag{display:inline-flex;align-items:center;gap:.25rem;padding:.125rem .375rem;background:var(--snice-color-primary-subtle,rgb(219 234 254));color:var(--snice-color-primary,rgb(37 99 235));border-radius:var(--snice-border-radius-sm,.125rem);font-size:var(--snice-font-size-xs, .75rem)}.select-tag-icon{width:.75rem;height:.75rem;object-fit:contain;flex-shrink:0}.select-tag-remove{cursor:pointer;padding:0;background:0 0;border:none;color:inherit;font-size:.75rem;line-height:1}.select-tag-remove:hover{opacity:.7}.select-icons{position:absolute;right:.5rem;top:50%;transform:translateY(-50%);display:flex;align-items:center;gap:.25rem;pointer-events:none;z-index:1}.select-clear{padding:.125rem;background:0 0;border:none;cursor:pointer;color:var(--snice-color-text-secondary,rgb(82 82 82));display:flex;align-items:center;justify-content:center;border-radius:var(--snice-border-radius-sm,.125rem);pointer-events:auto}.select-clear:hover{background:var(--snice-color-surface-container-low,rgb(245 245 245));color:var(--snice-color-text,rgb(23 23 23))}.select-arrow{transition:transform var(--snice-transition-fast, 150ms) ease;color:var(--snice-color-text-secondary,rgb(82 82 82));pointer-events:none}.select-arrow--open{transform:rotate(180deg)}.select-dropdown{position:absolute;top:100%;margin-top:.25rem;left:0;right:0;background:var(--snice-color-surface-container-high,rgb(252 251 249));border:1px solid var(--snice-color-border,rgb(226 226 226));border-radius:var(--snice-border-radius-md,.25rem);box-shadow:var(--snice-shadow-lg,0 10px 15px -3px rgb(0 0 0 / .1),0 4px 6px -4px rgb(0 0 0 / .1));z-index:1000;opacity:0;transform:translateY(-8px) scaleY(.95);transform-origin:top;pointer-events:none;transition:opacity var(--snice-transition-fast, 150ms) ease,transform var(--snice-transition-fast, 150ms) ease;display:flex;flex-direction:column;overflow:hidden}.select-dropdown--open{opacity:1;transform:translateY(0) scaleY(1);pointer-events:auto}.select-search{padding:.5rem;border-bottom:1px solid var(--snice-color-border,rgb(226 226 226));flex-shrink:0}.select-search-input{width:100%;padding:.375rem .625rem;background:var(--snice-color-surface-container-lowest,rgb(248 247 245));border:1px solid var(--snice-color-border,rgb(226 226 226));border-radius:var(--snice-border-radius-sm,.125rem);font-size:var(--snice-font-size-sm, .875rem);font-family:inherit;color:var(--snice-color-text,rgb(23 23 23));box-sizing:border-box}.select-search-input:focus-visible{outline:0;border-color:var(--snice-color-primary,rgb(37 99 235))}.select-options{max-height:12.5rem;overflow-y:auto;overflow-x:hidden;padding:.25rem;scrollbar-gutter:stable;scrollbar-width:thin;scrollbar-color:var(--snice-color-border,rgb(226 226 226)) var(--snice-color-surface-container-low,rgb(245 245 245))}.select-options::-webkit-scrollbar-track{background:var(--snice-color-surface-container-low,rgb(245 245 245));border-radius:var(--snice-border-radius-md,.25rem);margin:.25rem 0}.select-options::-webkit-scrollbar-thumb{background:var(--snice-color-border,rgb(226 226 226));border-radius:var(--snice-border-radius-md,.25rem);border:2px solid var(--snice-color-surface,rgb(255 255 255))}.select-option{padding:.5rem .75rem;cursor:pointer;border-radius:var(--snice-border-radius-sm,.125rem);transition:background var(--snice-transition-fast, 150ms) ease;display:flex;align-items:center;gap:.5rem}.select-option:hover:not(.select-option--disabled){background:var(--snice-color-surface-container-low,rgb(245 245 245))}.select-option--selected{background:var(--snice-color-primary-subtle,rgb(219 234 254));color:var(--snice-color-primary,rgb(37 99 235));font-weight:var(--snice-font-weight-medium,500)}.select-option--focused{background:var(--snice-color-surface-container-low,rgb(245 245 245));outline:2px solid var(--snice-color-primary,rgb(37 99 235));outline-offset:-2px}.select-option--disabled{opacity:.5;cursor:not-allowed}.select-option-icon{width:1rem;height:1rem;object-fit:contain;flex-shrink:0}.select-option-check{width:1rem;height:1rem;display:flex;align-items:center;justify-content:center;flex-shrink:0}.select-option-label{flex:1}.select-no-options{padding:1rem;text-align:center;color:var(--snice-color-text-secondary,rgb(82 82 82));font-size:var(--snice-font-size-sm, .875rem)}.select-native{position:absolute;opacity:0;pointer-events:none;width:0;height:0}.select-options::-webkit-scrollbar{width:6px}.select-options::-webkit-scrollbar-track{background:var(--snice-color-surface-container-low,rgb(245 245 245));border-radius:3px}.select-options::-webkit-scrollbar-thumb{background:var(--snice-color-border,rgb(226 226 226));border-radius:3px}.select-options::-webkit-scrollbar-thumb:hover{background:var(--snice-color-border-hover,rgb(180 180 180))}.select-trigger--loading{cursor:wait;opacity:.7}.select-spinner{display:inline-block;width:.875rem;height:.875rem;margin-right:.25rem}.select-spinner::after{content:'';display:block;width:100%;height:100%;border:2px solid currentColor;border-right-color:transparent;border-radius:50%;animation:.6s linear infinite spin}@keyframes spin{to{transform:rotate(360deg)}}.select-freetext-input{flex:1;border:none;outline:0;background:0 0;font-family:inherit;font-size:inherit;color:var(--snice-color-text,rgb(23 23 23));padding:0;min-width:0;width:100%}.select-freetext-input::placeholder{color:var(--snice-color-text-secondary,rgb(82 82 82))}.select-editable-container{position:relative;display:flex;align-items:center;width:100%}.select-editable-input{width:100%;box-sizing:border-box;font-family:inherit;background:var(--snice-color-surface-container-lowest,rgb(248 247 245));color:var(--snice-color-text,rgb(23 23 23));border:1px solid var(--snice-color-border,rgb(226 226 226));border-radius:var(--snice-border-radius-md,.25rem);transition:all var(--snice-transition-fast, 150ms) ease;outline:0;-webkit-appearance:none;-moz-appearance:none;appearance:none}.select-editable-input--small{padding:.375rem 2rem .375rem .625rem;font-size:var(--snice-font-size-sm, .875rem);min-height:2rem}.select-editable-input--medium{padding:.5rem 2.25rem .5rem .75rem;font-size:var(--snice-font-size-md, 1rem);min-height:2.5rem}.select-editable-input--large{padding:.625rem 2.5rem .625rem .875rem;font-size:var(--snice-font-size-lg, 1.125rem);min-height:3rem}.select-editable-input:hover:not(:disabled){border-color:var(--snice-color-border-hover,rgb(180 180 180))}.select-editable-input:focus-visible{border-color:var(--snice-color-primary,rgb(37 99 235));box-shadow:0 0 0 var(--snice-focus-ring-width,2px) var(--snice-focus-ring-color,rgb(59 130 246 / .5))}.select-editable-input--open{border-color:var(--snice-color-primary,rgb(37 99 235))}.select-editable-input--invalid{border-color:var(--snice-color-danger,rgb(220 38 38))}.select-editable-input:disabled{background:var(--snice-color-surface-container-low,rgb(245 245 245));color:var(--snice-color-text-secondary,rgb(82 82 82));cursor:not-allowed;opacity:.6}.select-editable-input:read-only{background:var(--snice-color-surface-container-low,rgb(245 245 245));cursor:default}.select-editable-input::placeholder{color:var(--snice-color-text-secondary,rgb(82 82 82));opacity:.7}.select-editable-arrow{position:absolute;right:.5rem;top:50%;transform:translateY(-50%);display:flex;align-items:center;justify-content:center;color:var(--snice-color-text-secondary,rgb(82 82 82));pointer-events:none;transition:transform var(--snice-transition-fast, 150ms) ease}.select-editable-arrow--open{transform:translateY(-50%) rotate(180deg)}.select-loading-indicator{display:flex;align-items:center;justify-content:center;gap:.5rem;padding:.75rem 1rem;color:var(--snice-color-text-secondary,rgb(82 82 82));font-size:var(--snice-font-size-sm, .875rem)}.select-loading-spinner{display:inline-block;width:1rem;height:1rem;flex-shrink:0}.select-loading-spinner::after{content:'';display:block;width:100%;height:100%;border:2px solid var(--snice-color-border,rgb(226 226 226));border-top-color:var(--snice-color-primary,rgb(37 99 235));border-radius:50%;animation:.6s linear infinite spin}@media (prefers-reduced-motion:reduce){*{transition-duration:0s!important;animation-duration:0s!important}}"}`}init(){if(this.readOptionsFromChildren(),Object.prototype.hasOwnProperty.call(this,"value")){const e=this.value;delete this.value,this.value=String(e??"")}else this.dirtyValue||this.applyDefaultValue();this.multiple&&this.value&&(this.selectedValues=new Set(this.value.split(",").map(e=>e.trim()))),this.filteredOptions=[...this.mergedOptions],this.syncFormState(),this.editable?(this.syncEditableInputToValue(),this.updateEditableState()):(this.updateTriggerState(),this.updateValueDisplay(),this.updateClearButton()),this.updateDropdownState(),this.updateDropdownContent(),this.observeChildren(),this.setupGlobalListeners(),this.labelAssociation.connect()}applyDefaultValue(){this.setValue(this.defaultValue,!1)}setValue(e,t){t&&(this.dirtyValue=!0),this.valueState=String(e??""),this.syncRenderedValue(),this.syncFormState()}syncRenderedValue(){this.multiple&&(this.selectedValues=new Set(this.value?this.value.split(",").map(e=>e.trim()):[])),this.editable?this.syncEditableInputToValue():(this.updateValueDisplay(),this.updateClearButton())}resetTransientState(){clearTimeout(this.remoteSearchTimeout),this.open=!1,this.focusedIndex=-1,this.filteredOptions=[...this.mergedOptions],this.searchInput&&(this.searchInput.value=""),this.syncRenderedValue(),this.updateDropdownContent()}syncFormValue(){var e,t,i;t=this.value,i=this.value,(e=this.internals)&&"function"==typeof e.setFormValue&&(void 0===i?e.setFormValue(t):e.setFormValue(t,i))}get validationProxy(){return this.validationInput||(this.validationInput=document.createElement("input")),this.validationInput}syncFormState(){this.syncFormValue(),this.syncValidity()}syncValidity(){const e=this.interactionDisabled||this.readonly,t=!e&&this.required&&(this.multiple?0===this.selectedValues.size:""===this.value),i=e?{}:{customError:Boolean(this.customValidationMessage),valueMissing:t},s=h(i),a=this.customValidationMessage||(t?"Please select an option.":"")||(s?"Please select a valid option.":"");this.constraintInvalid=s;const n=this.invalid||s,l=this.editable?this.editableInput:this.trigger;this.validationProxy.setCustomValidity(s?a:""),this.trigger?.setAttribute("aria-invalid",String(n)),this.trigger?.classList.toggle("select-trigger--invalid",n),this.editableInput?.setAttribute("aria-invalid",String(n)),this.editableInput?.classList.toggle("select-editable-input--invalid",n),function(e,t,i,s){e&&"function"==typeof e.setValidity&&(h(t)?s?e.setValidity(t,i,s):e.setValidity(t,i):e.setValidity({}))}(this.internals,i,a,l)}onReconnect(){this.setupGlobalListeners(),this.observeChildren(),this.labelAssociation.connect()}cleanup(){this.removeGlobalListeners(),this.childObserver?.disconnect(),this.labelAssociation.disconnect()}setupGlobalListeners(){this.outsideClickHandler=e=>{if(!this.isOpen)return;const t=e.composedPath(),i=Array.from(this.labels||[]).some(e=>t.includes(e));t.includes(this)||i||(this.editable&&this.commitEditableValue(),this.closeDropdown())},this.globalKeyHandler=e=>{if(!this.isOpen||this.editable)return;const t=e.composedPath()[0]===this.searchInput;switch(e.key){case"Escape":this.closeDropdown(),this.trigger?.focus();break;case"ArrowDown":e.preventDefault(),this.focusNextOption();break;case"ArrowUp":e.preventDefault(),this.focusPreviousOption();break;case"Enter":case" ":if(" "===e.key&&t)return;if(e.preventDefault(),this.focusedIndex>=0){const e=(this.searchable?this.filteredOptions:this.mergedOptions)[this.focusedIndex];e&&!e.disabled&&this.handleOptionSelect(e)}}},document.addEventListener("click",this.outsideClickHandler),document.addEventListener("keydown",this.globalKeyHandler)}removeGlobalListeners(){this.outsideClickHandler&&document.removeEventListener("click",this.outsideClickHandler),this.globalKeyHandler&&document.removeEventListener("keydown",this.globalKeyHandler)}observeChildren(){const e=new MutationObserver(e=>{this.handleChildrenChange(e)});e.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value","label","disabled","selected"]}),this.childObserver=e}handleChildrenChange(e){e.some(e=>"childList"===e.type||!("attributes"!==e.type||!["value","label","disabled","selected"].includes(e.attributeName))&&"SNICE-OPTION"===e.target.nodeName)&&(this.readOptionsFromChildren(),this.filteredOptions=[...this.mergedOptions],this.editable||(this.updateValueDisplay(),this.updateClearButton()),this.updateDropdownContent())}readOptionsFromChildren(){const e=Array.from(this.querySelectorAll("snice-option"));this.childOptions=e.map(e=>e.optionData?e.optionData:{value:e.getAttribute("value")||"",label:e.getAttribute("label")||e.textContent?.trim()||"",disabled:e.hasAttribute("disabled"),selected:e.hasAttribute("selected")})}handleEditableInput(e){this.editableInputValue=e.target.value,this.filterEditableOptions(this.editableInputValue),this.isOpen||this.openDropdown()}handleEditableFocus(){this.isOpen||this.readonly||this.openDropdown()}handleEditableBlur(e){setTimeout(()=>{this.isOpen&&(this.commitEditableValue(),this.closeDropdown())},200)}handleEditableClick(){this.isOpen||this.interactionDisabled||this.readonly||this.openDropdown()}handleEditableArrowClick(e){e.preventDefault(),e.stopPropagation(),this.interactionDisabled||this.readonly||(this.isOpen?this.closeDropdown():(this.openDropdown(),this.editableInput?.focus()))}handleEditableKeydown(e){switch(e.key){case"ArrowDown":e.preventDefault(),this.isOpen?this.focusNextOption():this.openDropdown();break;case"ArrowUp":e.preventDefault(),this.isOpen&&this.focusPreviousOption();break;case"Enter":if(e.preventDefault(),this.isOpen&&this.focusedIndex>=0){const e=this.filteredOptions[this.focusedIndex];e&&!e.disabled&&this.handleEditableOptionSelect(e)}else this.isOpen&&(this.commitEditableValue(),this.closeDropdown());break;case"Escape":this.isOpen&&(this.closeDropdown(),this.syncEditableInputToValue());break;case"Tab":this.isOpen&&(this.commitEditableValue(),this.closeDropdown())}}handleEditableOptionSelect(e){this.value=e.value,this.editableInputValue=e.label,this.editableInput&&(this.editableInput.value=e.label),this.closeDropdown(),this.dispatchChangeEvent(e),this.editableInput?.focus()}commitEditableValue(){if(!this.editableInput)return;const e=this.editableInput.value.trim(),t=this.mergedOptions.find(t=>t.label.toLowerCase()===e.toLowerCase());t?(this.value=t.value,this.editableInputValue=t.label,this.editableInput.value=t.label,this.dispatchChangeEvent(t)):this.allowFreeText&&e?(this.value=e,this.editableInputValue=e,this.dispatchChangeEvent()):this.syncEditableInputToValue()}filterEditableOptions(e){if(this.remote)return void this.scheduleRemoteSearch(e);const t=this.mergedOptions;if(e){const i=e.toLowerCase();this.filteredOptions=t.filter(e=>e.label.toLowerCase().includes(i))}else this.filteredOptions=[...t];this.focusedIndex=-1,this.updateDropdownContent()}syncEditableInputToValue(){if(this.editableInput)if(this.value){const e=this.resolvableOptions.find(e=>e.value===this.value);e?(this.editableInput.value=e.label,this.editableInputValue=e.label):this.allowFreeText?(this.editableInput.value=this.value,this.editableInputValue=this.value):(this.editableInput.value="",this.editableInputValue="")}else this.editableInput.value="",this.editableInputValue=""}updateEditableState(){if(!this.editableInput)return;this.editableInput.setAttribute("aria-expanded",String(this.isOpen)),this.editableInput.classList.toggle("select-editable-input--open",this.isOpen);const e=this.invalid||this.constraintInvalid;this.editableInput.setAttribute("aria-invalid",String(e)),this.editableInput.classList.toggle("select-editable-input--invalid",e)}handleDropdownMousedown(e){this.editable&&e.preventDefault()}handleTriggerOpen(e){["Enter"," ","ArrowDown","ArrowUp"].includes(e.key)&&(e.preventDefault(),this.isOpen||this.openDropdown())}handleSearchKeydown(e){switch(e.key){case"Escape":this.closeDropdown(),this.trigger?.focus();break;case"ArrowDown":e.preventDefault(),this.focusNextOption();break;case"ArrowUp":e.preventDefault(),this.focusPreviousOption();break;case"Enter":if(e.preventDefault(),this.focusedIndex>=0){const e=(this.searchable?this.filteredOptions:this.mergedOptions)[this.focusedIndex];e&&!e.disabled&&this.handleOptionSelect(e)}}}focusNextOption(){const e=this.searchable||this.editable?this.filteredOptions:this.mergedOptions;if(0!==e.filter(e=>!e.disabled).length){for(this.focusedIndex++,this.focusedIndex>=e.length&&(this.focusedIndex=0);e[this.focusedIndex]?.disabled;)this.focusedIndex++,this.focusedIndex>=e.length&&(this.focusedIndex=0);this.updateOptionFocus()}}focusPreviousOption(){const e=this.searchable||this.editable?this.filteredOptions:this.mergedOptions;if(0!==e.filter(e=>!e.disabled).length){for(this.focusedIndex--,this.focusedIndex<0&&(this.focusedIndex=e.length-1);e[this.focusedIndex]?.disabled;)this.focusedIndex--,this.focusedIndex<0&&(this.focusedIndex=e.length-1);this.updateOptionFocus()}}updateOptionFocus(){if(this.optionElements){this.optionElements.forEach((e,t)=>{e.classList.toggle("select-option--focused",t===this.focusedIndex)});const e=this.optionElements?.[this.focusedIndex];e&&e.scrollIntoView({block:"nearest"})}}handleClearClick(e){this.interactionDisabled||this.readonly||(e.preventDefault(),e.stopPropagation(),this.clear())}handleTriggerClick(e){e.target.closest(".select-clear")||(e.stopPropagation(),this.interactionDisabled||this.readonly||this.toggleDropdown())}handleOptionsClick(e){if(this.interactionDisabled||this.readonly)return;const t=e.target;if(t.closest(".select-tag-remove")){e.stopPropagation();const i=t.closest(".select-tag-remove").getAttribute("data-value");return void(i&&this.multiple&&(this.selectedValues.delete(i),this.value=Array.from(this.selectedValues).join(","),this.updateValueDisplay(),this.updateClearButton(),this.dispatchChangeEvent()))}const i=t.closest(".select-option");if(!i)return;e.stopPropagation();const s=i.getAttribute("data-value");if(!s)return;const a=this.resolvableOptions.find(e=>e.value===s);a&&!a.disabled&&(this.editable?this.handleEditableOptionSelect(a):this.handleOptionSelect(a))}handleSearchInput(e){const t=e.target.value;if(this.remote)return void this.scheduleRemoteSearch(t);const i=t.toLowerCase();this.filteredOptions=i?this.mergedOptions.filter(e=>e.label.toLowerCase().includes(i)):[...this.mergedOptions],this.focusedIndex=-1,this.updateDropdownContent()}handleOptionSelect(e){this.multiple?(this.selectedValues.has(e.value)?this.selectedValues.delete(e.value):this.selectedValues.add(e.value),this.value=Array.from(this.selectedValues).join(","),this.updateDropdownContent()):(this.value=e.value,this.closeDropdown()),this.updateValueDisplay(),this.updateClearButton(),this.dispatchChangeEvent(e)}handleValueChange(){this.syncRenderedValue(),this.syncFormState()}handleDefaultValueChange(){this.dirtyValue||this.applyDefaultValue()}handleOptionsPropertyChange(){this.filteredOptions=[...this.mergedOptions],this.updateDropdownContent(),this.editable&&this.syncEditableInputToValue()}handleDisabledChange(){this.editable||(this.updateTriggerState(),this.updateClearButton()),this.interactionDisabled&&this.isOpen&&!this.remote&&this.closeDropdown(),this.syncValidity()}handleValidationConfigurationChange(){this.syncRenderedValue(),this.syncValidity()}handleValidationAnchorChange(){queueMicrotask(()=>{this.rendered.then(()=>{this.isConnected&&(this.syncRenderedValue(),this.syncValidity(),this.labelAssociation.sync())})})}handleInvalidChange(){const e=this.invalid||this.constraintInvalid;this.trigger?.setAttribute("aria-invalid",String(e)),this.trigger?.classList.toggle("select-trigger--invalid",e),this.editableInput?.setAttribute("aria-invalid",String(e)),this.editableInput?.classList.toggle("select-editable-input--invalid",e)}handleOpenChange(){this.updateDropdownState(),this.editable?(this.updateEditableState(),this.isOpen&&(this.remote?this.scheduleRemoteSearch(this.editableInput?.value||""):(this.filteredOptions=[...this.mergedOptions],this.focusedIndex=-1,this.updateDropdownContent())),this.isOpen||(this.focusedIndex=-1)):(this.updateTriggerState(),this.isOpen&&this.searchable&&this.searchInput&&setTimeout(()=>this.searchInput?.focus(),100),this.isOpen&&this.remote&&this.searchable&&this.scheduleRemoteSearch(this.searchInput?.value||""),this.isOpen||(this.focusedIndex=-1,this.searchInput&&(this.searchInput.value="",this.filteredOptions=[...this.mergedOptions],this.updateDropdownContent())))}updateValueDisplay(){if(!this.valueDisplay)return;const e=this.resolvableOptions.filter(e=>this.multiple?this.selectedValues.has(e.value):e.value===this.value);if(this.multiple&&e.length>0){const t=document.createElement("div");t.className="select-value--multiple",e.forEach(e=>{const i=document.createElement("span");i.className="select-tag";const s=document.createElement("span");s.className="select-tag-remove",s.setAttribute("data-value",e.value),s.setAttribute("aria-label",`Remove ${e.label}`),s.hidden=this.interactionDisabled||this.readonly,s.textContent="×",i.append(this.createIcon("select-tag-icon",e.icon),document.createTextNode(e.label),s),t.append(i)}),this.valueDisplay.replaceChildren(t)}else if(e.length>0){const t=e[0],i=document.createElement("div");i.className="select-value--single";const s=document.createElement("span");s.textContent=t.label,i.append(this.createIcon("select-value-icon",t.icon),s),this.valueDisplay.replaceChildren(i)}else{const e=document.createElement("span");e.className="select-placeholder",e.textContent=this.placeholder,this.valueDisplay.replaceChildren(e)}}updateClearButton(){if(!this.clearButton)return;const e=this.resolvableOptions.filter(e=>this.multiple?this.selectedValues.has(e.value):e.value===this.value);this.clearButton.style.display=this.clearable&&e.length>0&&!this.interactionDisabled&&!this.readonly?"":"none"}updateDropdownContent(){this.optionsList&&this.optionsList.replaceChildren(this.renderOptions())}dispatchChangeEvent(e){return{value:this.multiple?Array.from(this.selectedValues):this.value,option:e,select:this}}dispatchOpenEvent(){return{select:this}}dispatchCloseEvent(){return{select:this}}focus(){this.editable?this.editableInput?.focus():this.trigger?.focus()}get type(){return this.multiple?"select-multiple":"select-one"}get form(){return function(e,t){if(t?.form)return t.form;const i=e.getAttribute("form");if(null!==i){const t=e.getRootNode();return"querySelectorAll"in t?Array.from(t.querySelectorAll("form[id]")).find(e=>e instanceof HTMLFormElement&&e.id===i)??null:null}return e.closest("form")}(this,this.internals)}get validity(){return this.internals?.validity??this.validationProxy.validity}get validationMessage(){return this.internals?.validationMessage??this.validationProxy.validationMessage}get willValidate(){return!this.interactionDisabled&&!this.readonly&&(this.internals?.willValidate??!0)}get labels(){return this.labelAssociation.labels}blur(){this.editable?this.editableInput?.blur():this.trigger?.blur(),this.isOpen&&this.closeDropdown()}checkValidity(){return this.syncValidity(),this.internals?.checkValidity()??this.validationProxy.checkValidity()}reportValidity(){return this.syncValidity(),this.internals?.reportValidity()??this.validationProxy.reportValidity()}setCustomValidity(e){this.customValidationMessage=String(e),this.syncValidity()}clear(){this.multiple?(this.selectedValues.clear(),this.value=""):this.value="",this.editable?this.syncEditableInputToValue():(this.updateValueDisplay(),this.updateClearButton()),this.dispatchChangeEvent()}openDropdown(){this.isOpen||this.interactionDisabled||this.readonly||(this.open=!0,this.dispatchOpenEvent())}closeDropdown(){this.isOpen&&(this.open=!1,this.dispatchCloseEvent())}toggleDropdown(){this.isOpen?this.closeDropdown():this.openDropdown()}selectOption(e){const t=this.resolvableOptions.find(t=>t.value===e);t&&!t.disabled&&(this.editable?this.handleEditableOptionSelect(t):this.handleOptionSelect(t))}updateTriggerState(){if(!this.trigger)return;this.trigger.classList.toggle("select-trigger--open",this.isOpen),this.trigger.classList.toggle("select-trigger--disabled",this.interactionDisabled),this.trigger.classList.toggle("select-trigger--readonly",this.readonly);const e=this.invalid||this.constraintInvalid;this.trigger.classList.toggle("select-trigger--invalid",e),this.trigger.setAttribute("aria-invalid",String(e)),this.trigger.classList.toggle("select-trigger--loading",this.loading),this.trigger.setAttribute("aria-expanded",String(this.isOpen)),this.trigger.disabled=this.interactionDisabled}updateDropdownState(){this.dropdown&&(this.dropdown.classList.toggle("select-dropdown--open",this.isOpen),this.arrow&&this.arrow.classList.toggle("select-arrow--open",this.isOpen))}})})()}(Snice);
|
|
110
|
+
`}createIcon(e,t){const i=document.createElement("img");return i.className=e,i.setAttribute("src",t||""),i.setAttribute("alt",""),i.hidden=!t,i}renderOptions(){const e=document.createDocumentFragment();if(this.remoteSearching){const t=document.createElement("div");t.className="select-loading-indicator";const i=document.createElement("span");i.className="select-loading-spinner";const s=document.createElement("span");return s.textContent="Searching...",t.append(i,s),e.append(t),e}const t=this.searchable||this.editable||this.remote?this.filteredOptions:this.mergedOptions;if(0===t.length){const t=document.createElement("div");t.className="select-no-options";const i=document.createElement("span");i.className="select-no-options-text",i.dataset.search="true",i.hidden=!(this.searchable||this.editable||this.remote)||this.filteredOptions.length>0,i.textContent="No matches found";const s=document.createElement("span");return s.className="select-no-options-text",s.dataset.search="false",s.hidden=(this.searchable||this.editable||this.remote)&&0===this.filteredOptions.length,s.textContent="No options available",t.append(i,s),e.append(t),e}return t.forEach((t,i)=>{const s=this.multiple?this.selectedValues.has(t.value):t.value===this.value,a=document.createElement("div");a.className="select-option",a.classList.toggle("select-option--selected",s),a.classList.toggle("select-option--disabled",Boolean(t.disabled)),a.classList.toggle("select-option--focused",i===this.focusedIndex),a.classList.toggle("select-option--has-icon",Boolean(t.icon)),a.setAttribute("data-value",t.value),a.setAttribute("role","option"),a.setAttribute("aria-selected",String(s)),a.setAttribute("aria-disabled",String(t.disabled)),a.setAttribute("part","option");const n=document.createElement("span");n.className="select-option-check",n.setAttribute("aria-hidden","true"),n.hidden=!this.multiple;const l=document.createElement("span");l.className="select-option-check-mark",l.hidden=!s,l.textContent="✓",n.append(l);const r=document.createElement("span");r.className="select-option-label",r.textContent=t.label,a.append(n,this.createIcon("select-option-icon",t.icon),r),e.append(a)}),e}styles(){return e.css`${":host([hidden]){display:none}:host{display:inline-block;font-family:var(--snice-font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif);position:relative;width:100%;max-width:18.75rem}[hidden]{display:none!important}img[src=\"\"]{display:none}.select-wrapper{position:relative;width:100%}.select-label{display:block;margin-bottom:.25rem;font-size:var(--snice-font-size-sm, .875rem);font-weight:var(--snice-font-weight-medium,500);line-height:var(--snice-line-height-normal, 1.5);color:var(--snice-color-text,rgb(23 23 23));text-align:left}.select-label--required::after{content:' *';color:var(--snice-color-danger,rgb(220 38 38))}.select-error-text,.select-helper-text{display:block;margin-top:var(--snice-spacing-2xs,.25rem);font-size:var(--snice-font-size-xs, .75rem);font-weight:var(--snice-font-weight-normal,400);line-height:var(--snice-line-height-normal, 1.5)}.select-helper-text{color:var(--snice-color-text-secondary,rgb(82 82 82))}.select-error-text{color:var(--snice-color-danger,rgb(220 38 38))}.select-trigger{box-sizing:border-box;min-width:0;width:100%;display:flex;align-items:center;justify-content:space-between;background:var(--snice-color-surface-container-lowest,rgb(248 247 245));border:1px solid var(--snice-color-border,rgb(226 226 226));border-radius:var(--snice-border-radius-md,.25rem);cursor:pointer;transition:all var(--snice-transition-fast, 150ms) ease;position:relative;text-align:left;font-family:inherit;color:var(--snice-color-text,rgb(23 23 23))}.select-trigger--small{padding:.375rem 2rem .375rem .625rem;font-size:var(--snice-font-size-sm, .875rem);min-height:2rem}.select-trigger--medium{padding:.5rem 2.25rem .5rem .75rem;font-size:var(--snice-font-size-md, 1rem);min-height:var(--snice-select-min-height,2.5rem)}.select-trigger--large{padding:.625rem 2.5rem .625rem .875rem;font-size:var(--snice-font-size-lg, 1.125rem);min-height:3rem}.select-trigger:hover:not(.select-trigger--disabled){border-color:var(--snice-color-border-hover,rgb(180 180 180))}.select-trigger:focus-visible{outline:2px solid var(--snice-color-primary,rgb(37 99 235));outline-offset:2px;border-color:var(--snice-color-primary,rgb(37 99 235))}.select-trigger--open{border-color:var(--snice-color-primary,rgb(37 99 235))}.select-trigger--disabled{background:var(--snice-color-surface-container-low,rgb(245 245 245));cursor:not-allowed;opacity:.6}.select-trigger--readonly{background:var(--snice-color-surface-container-low,rgb(245 245 245));cursor:default}.select-trigger--invalid{border-color:var(--snice-color-danger,rgb(220 38 38))}.select-placeholder{color:var(--snice-color-text-secondary,rgb(82 82 82))}.select-value{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.select-value--single{display:flex;align-items:center;gap:.5rem}.select-value-icon{width:1rem;height:1rem;object-fit:contain;flex-shrink:0}.select-value--multiple{display:flex;gap:.25rem;flex-wrap:wrap}.select-tag{display:inline-flex;align-items:center;gap:.25rem;padding:.125rem .375rem;background:var(--snice-color-primary-subtle,rgb(219 234 254));color:var(--snice-color-primary,rgb(37 99 235));border-radius:var(--snice-border-radius-sm,.125rem);font-size:var(--snice-font-size-xs, .75rem)}.select-tag-icon{width:.75rem;height:.75rem;object-fit:contain;flex-shrink:0}.select-tag-remove{cursor:pointer;padding:0;background:0 0;border:none;color:inherit;font-size:.75rem;line-height:1}.select-tag-remove:hover{opacity:.7}.select-icons{position:absolute;right:.5rem;top:50%;transform:translateY(-50%);display:flex;align-items:center;gap:.25rem;pointer-events:none;z-index:1}.select-clear{padding:.125rem;background:0 0;border:none;cursor:pointer;color:var(--snice-color-text-secondary,rgb(82 82 82));display:flex;align-items:center;justify-content:center;border-radius:var(--snice-border-radius-sm,.125rem);pointer-events:auto}.select-clear:hover{background:var(--snice-color-surface-container-low,rgb(245 245 245));color:var(--snice-color-text,rgb(23 23 23))}.select-arrow{transition:transform var(--snice-transition-fast, 150ms) ease;color:var(--snice-color-text-secondary,rgb(82 82 82));pointer-events:none}.select-arrow--open{transform:rotate(180deg)}.select-dropdown{position:absolute;top:100%;margin-top:.25rem;left:0;right:0;background:var(--snice-color-surface-container-high,rgb(252 251 249));border:1px solid var(--snice-color-border,rgb(226 226 226));border-radius:var(--snice-border-radius-md,.25rem);box-shadow:var(--snice-shadow-lg,0 10px 15px -3px rgb(0 0 0 / .1),0 4px 6px -4px rgb(0 0 0 / .1));z-index:1000;opacity:0;transform:translateY(-8px) scaleY(.95);transform-origin:top;pointer-events:none;transition:opacity var(--snice-transition-fast, 150ms) ease,transform var(--snice-transition-fast, 150ms) ease;display:flex;flex-direction:column;overflow:hidden}.select-dropdown--open{opacity:1;transform:translateY(0) scaleY(1);pointer-events:auto}.select-search{padding:.5rem;border-bottom:1px solid var(--snice-color-border,rgb(226 226 226));flex-shrink:0}.select-search-input{width:100%;padding:.375rem .625rem;background:var(--snice-color-surface-container-lowest,rgb(248 247 245));border:1px solid var(--snice-color-border,rgb(226 226 226));border-radius:var(--snice-border-radius-sm,.125rem);font-size:var(--snice-font-size-sm, .875rem);font-family:inherit;color:var(--snice-color-text,rgb(23 23 23));box-sizing:border-box}.select-search-input:focus-visible{outline:0;border-color:var(--snice-color-primary,rgb(37 99 235))}.select-options{max-height:12.5rem;overflow-y:auto;overflow-x:hidden;padding:.25rem;scrollbar-gutter:stable;scrollbar-width:thin;scrollbar-color:var(--snice-color-border,rgb(226 226 226)) var(--snice-color-surface-container-low,rgb(245 245 245))}.select-options::-webkit-scrollbar-track{background:var(--snice-color-surface-container-low,rgb(245 245 245));border-radius:var(--snice-border-radius-md,.25rem);margin:.25rem 0}.select-options::-webkit-scrollbar-thumb{background:var(--snice-color-border,rgb(226 226 226));border-radius:var(--snice-border-radius-md,.25rem);border:2px solid var(--snice-color-surface,rgb(255 255 255))}.select-option{padding:.5rem .75rem;cursor:pointer;border-radius:var(--snice-border-radius-sm,.125rem);transition:background var(--snice-transition-fast, 150ms) ease;display:flex;align-items:center;gap:.5rem}.select-option:hover:not(.select-option--disabled){background:var(--snice-color-surface-container-low,rgb(245 245 245))}.select-option--selected{background:var(--snice-color-primary-subtle,rgb(219 234 254));color:var(--snice-color-primary,rgb(37 99 235));font-weight:var(--snice-font-weight-medium,500)}.select-option--focused{background:var(--snice-color-surface-container-low,rgb(245 245 245));outline:2px solid var(--snice-color-primary,rgb(37 99 235));outline-offset:-2px}.select-option--disabled{opacity:.5;cursor:not-allowed}.select-option-icon{width:1rem;height:1rem;object-fit:contain;flex-shrink:0}.select-option-check{width:1rem;height:1rem;display:flex;align-items:center;justify-content:center;flex-shrink:0}.select-option-label{flex:1}.select-no-options{padding:1rem;text-align:center;color:var(--snice-color-text-secondary,rgb(82 82 82));font-size:var(--snice-font-size-sm, .875rem)}.select-native{position:absolute;opacity:0;pointer-events:none;width:0;height:0}.select-options::-webkit-scrollbar{width:6px}.select-options::-webkit-scrollbar-track{background:var(--snice-color-surface-container-low,rgb(245 245 245));border-radius:3px}.select-options::-webkit-scrollbar-thumb{background:var(--snice-color-border,rgb(226 226 226));border-radius:3px}.select-options::-webkit-scrollbar-thumb:hover{background:var(--snice-color-border-hover,rgb(180 180 180))}.select-trigger--loading{cursor:wait;opacity:.7}.select-spinner{display:inline-block;width:.875rem;height:.875rem;margin-right:.25rem}.select-spinner::after{content:'';display:block;width:100%;height:100%;border:2px solid currentColor;border-right-color:transparent;border-radius:50%;animation:.6s linear infinite spin}@keyframes spin{to{transform:rotate(360deg)}}.select-freetext-input{flex:1;border:none;outline:0;background:0 0;font-family:inherit;font-size:inherit;color:var(--snice-color-text,rgb(23 23 23));padding:0;min-width:0;width:100%}.select-freetext-input::placeholder{color:var(--snice-color-text-secondary,rgb(82 82 82))}.select-editable-container{position:relative;display:flex;align-items:center;width:100%}.select-editable-input{width:100%;box-sizing:border-box;font-family:inherit;background:var(--snice-color-surface-container-lowest,rgb(248 247 245));color:var(--snice-color-text,rgb(23 23 23));border:1px solid var(--snice-color-border,rgb(226 226 226));border-radius:var(--snice-border-radius-md,.25rem);transition:all var(--snice-transition-fast, 150ms) ease;outline:0;-webkit-appearance:none;-moz-appearance:none;appearance:none}.select-editable-input--small{padding:.375rem 2rem .375rem .625rem;font-size:var(--snice-font-size-sm, .875rem);min-height:2rem}.select-editable-input--medium{padding:.5rem 2.25rem .5rem .75rem;font-size:var(--snice-font-size-md, 1rem);min-height:2.5rem}.select-editable-input--large{padding:.625rem 2.5rem .625rem .875rem;font-size:var(--snice-font-size-lg, 1.125rem);min-height:3rem}.select-editable-input:hover:not(:disabled){border-color:var(--snice-color-border-hover,rgb(180 180 180))}.select-editable-input:focus-visible{border-color:var(--snice-color-primary,rgb(37 99 235));box-shadow:0 0 0 var(--snice-focus-ring-width,2px) var(--snice-focus-ring-color,rgb(59 130 246 / .5))}.select-editable-input--open{border-color:var(--snice-color-primary,rgb(37 99 235))}.select-editable-input--invalid{border-color:var(--snice-color-danger,rgb(220 38 38))}.select-editable-input:disabled{background:var(--snice-color-surface-container-low,rgb(245 245 245));color:var(--snice-color-text-secondary,rgb(82 82 82));cursor:not-allowed;opacity:.6}.select-editable-input:read-only{background:var(--snice-color-surface-container-low,rgb(245 245 245));cursor:default}.select-editable-input::placeholder{color:var(--snice-color-text-secondary,rgb(82 82 82));opacity:.7}.select-editable-arrow{position:absolute;right:.5rem;top:50%;transform:translateY(-50%);display:flex;align-items:center;justify-content:center;color:var(--snice-color-text-secondary,rgb(82 82 82));pointer-events:none;transition:transform var(--snice-transition-fast, 150ms) ease}.select-editable-arrow--open{transform:translateY(-50%) rotate(180deg)}.select-loading-indicator{display:flex;align-items:center;justify-content:center;gap:.5rem;padding:.75rem 1rem;color:var(--snice-color-text-secondary,rgb(82 82 82));font-size:var(--snice-font-size-sm, .875rem)}.select-loading-spinner{display:inline-block;width:1rem;height:1rem;flex-shrink:0}.select-loading-spinner::after{content:'';display:block;width:100%;height:100%;border:2px solid var(--snice-color-border,rgb(226 226 226));border-top-color:var(--snice-color-primary,rgb(37 99 235));border-radius:50%;animation:.6s linear infinite spin}@media (prefers-reduced-motion:reduce){*{transition-duration:0s!important;animation-duration:0s!important}}"}`}init(){if(this.readOptionsFromChildren(),Object.prototype.hasOwnProperty.call(this,"value")){const e=this.value;delete this.value,this.value=String(e??"")}else this.dirtyValue||this.applyDefaultValue();this.multiple&&this.value&&(this.selectedValues=new Set(this.value.split(",").map(e=>e.trim()))),this.filteredOptions=[...this.mergedOptions],this.syncFormState(),this.editable?(this.syncEditableInputToValue(),this.updateEditableState()):(this.updateTriggerState(),this.updateValueDisplay(),this.updateClearButton()),this.updateDropdownState(),this.updateDropdownContent(),this.observeChildren(),this.setupGlobalListeners(),this.labelAssociation.connect()}applyDefaultValue(){this.setValue(this.defaultValue,!1)}setValue(e,t){t&&(this.dirtyValue=!0),this.valueState=String(e??""),this.syncRenderedValue(),this.syncFormState()}syncRenderedValue(){this.multiple&&(this.selectedValues=new Set(this.value?this.value.split(",").map(e=>e.trim()):[])),this.editable?this.syncEditableInputToValue():(this.updateValueDisplay(),this.updateClearButton())}resetTransientState(){clearTimeout(this.remoteSearchTimeout),this.open=!1,this.focusedIndex=-1,this.filteredOptions=[...this.mergedOptions],this.searchInput&&(this.searchInput.value=""),this.syncRenderedValue(),this.updateDropdownContent()}syncFormValue(){var e,t,i;t=this.value,i=this.value,(e=this.internals)&&"function"==typeof e.setFormValue&&(void 0===i?e.setFormValue(t):e.setFormValue(t,i))}get validationProxy(){return this.validationInput||(this.validationInput=document.createElement("input")),this.validationInput}syncFormState(){this.syncFormValue(),this.syncValidity()}syncValidity(){const e=this.interactionDisabled||this.readonly,t=!e&&this.required&&(this.multiple?0===this.selectedValues.size:""===this.value),i=e?{}:{customError:Boolean(this.customValidationMessage),valueMissing:t},s=h(i),a=this.customValidationMessage||(t?"Please select an option.":"")||(s?"Please select a valid option.":"");this.constraintInvalid=s;const n=this.invalid||s,l=this.editable?this.editableInput:this.trigger;this.validationProxy.setCustomValidity(s?a:""),this.trigger?.setAttribute("aria-invalid",String(n)),this.trigger?.classList.toggle("select-trigger--invalid",n),this.editableInput?.setAttribute("aria-invalid",String(n)),this.editableInput?.classList.toggle("select-editable-input--invalid",n),function(e,t,i,s){e&&"function"==typeof e.setValidity&&(h(t)?s?e.setValidity(t,i,s):e.setValidity(t,i):e.setValidity({}))}(this.internals,i,a,l)}onReconnect(){this.setupGlobalListeners(),this.observeChildren(),this.labelAssociation.connect()}cleanup(){this.removeGlobalListeners(),this.childObserver?.disconnect(),this.labelAssociation.disconnect()}setupGlobalListeners(){this.outsideClickHandler=e=>{if(!this.isOpen)return;const t=e.composedPath(),i=Array.from(this.labels||[]).some(e=>t.includes(e));t.includes(this)||i||(this.editable&&this.commitEditableValue(),this.closeDropdown())},this.globalKeyHandler=e=>{if(!this.isOpen||this.editable)return;const t=e.composedPath()[0]===this.searchInput;switch(e.key){case"Escape":this.closeDropdown(),this.trigger?.focus();break;case"ArrowDown":e.preventDefault(),this.focusNextOption();break;case"ArrowUp":e.preventDefault(),this.focusPreviousOption();break;case"Enter":case" ":if(" "===e.key&&t)return;if(e.preventDefault(),this.focusedIndex>=0){const e=(this.searchable?this.filteredOptions:this.mergedOptions)[this.focusedIndex];e&&!e.disabled&&this.handleOptionSelect(e)}}},document.addEventListener("click",this.outsideClickHandler),document.addEventListener("keydown",this.globalKeyHandler)}removeGlobalListeners(){this.outsideClickHandler&&document.removeEventListener("click",this.outsideClickHandler),this.globalKeyHandler&&document.removeEventListener("keydown",this.globalKeyHandler)}observeChildren(){const e=new MutationObserver(e=>{this.handleChildrenChange(e)});e.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value","label","disabled","selected"]}),this.childObserver=e}handleChildrenChange(e){e.some(e=>"childList"===e.type||!("attributes"!==e.type||!["value","label","disabled","selected"].includes(e.attributeName))&&"SNICE-OPTION"===e.target.nodeName)&&(this.readOptionsFromChildren(),this.filteredOptions=[...this.mergedOptions],this.editable||(this.updateValueDisplay(),this.updateClearButton()),this.updateDropdownContent())}readOptionsFromChildren(){const e=Array.from(this.querySelectorAll("snice-option"));this.childOptions=e.map(e=>e.optionData?e.optionData:{value:e.getAttribute("value")||"",label:e.getAttribute("label")||e.textContent?.trim()||"",disabled:e.hasAttribute("disabled"),selected:e.hasAttribute("selected")})}handleEditableInput(e){this.interactionDisabled||this.readonly||(this.editableInputValue=e.target.value,this.filterEditableOptions(this.editableInputValue),this.isOpen||this.openDropdown())}handleEditableFocus(){this.isOpen||this.readonly||this.openDropdown()}handleEditableBlur(e){setTimeout(()=>{this.isOpen&&(this.commitEditableValue(),this.closeDropdown())},200)}handleEditableClick(){this.isOpen||this.interactionDisabled||this.readonly||this.openDropdown()}handleEditableArrowClick(e){e.preventDefault(),e.stopPropagation(),this.interactionDisabled||this.readonly||(this.isOpen?this.closeDropdown():(this.openDropdown(),this.editableInput?.focus()))}handleEditableKeydown(e){switch(e.key){case"ArrowDown":e.preventDefault(),this.isOpen?this.focusNextOption():this.openDropdown();break;case"ArrowUp":e.preventDefault(),this.isOpen&&this.focusPreviousOption();break;case"Enter":if(e.preventDefault(),this.isOpen&&this.focusedIndex>=0){const e=this.filteredOptions[this.focusedIndex];e&&!e.disabled&&this.handleEditableOptionSelect(e)}else this.isOpen&&(this.commitEditableValue(),this.closeDropdown());break;case"Escape":this.isOpen&&(this.closeDropdown(),this.syncEditableInputToValue());break;case"Tab":this.isOpen&&(this.commitEditableValue(),this.closeDropdown())}}handleEditableOptionSelect(e){this.value=e.value,this.editableInputValue=e.label,this.editableInput&&(this.editableInput.value=e.label),this.closeDropdown(),this.dispatchChangeEvent(e),this.editableInput?.focus()}commitEditableValue(){if(!this.editableInput)return;const e=this.editableInput.value.trim(),t=this.mergedOptions.find(t=>t.label.toLowerCase()===e.toLowerCase());t?(this.value=t.value,this.editableInputValue=t.label,this.editableInput.value=t.label,this.dispatchChangeEvent(t)):this.allowFreeText&&e?(this.value=e,this.editableInputValue=e,this.dispatchChangeEvent()):this.syncEditableInputToValue()}filterEditableOptions(e){if(this.remote)return void this.scheduleRemoteSearch(e);const t=this.mergedOptions;if(e){const i=e.toLowerCase();this.filteredOptions=t.filter(e=>e.label.toLowerCase().includes(i))}else this.filteredOptions=[...t];this.focusedIndex=-1,this.updateDropdownContent()}syncEditableInputToValue(){if(this.editableInput)if(this.value){const e=this.resolvableOptions.find(e=>e.value===this.value);e?(this.editableInput.value=e.label,this.editableInputValue=e.label):this.allowFreeText?(this.editableInput.value=this.value,this.editableInputValue=this.value):(this.editableInput.value="",this.editableInputValue="")}else this.editableInput.value="",this.editableInputValue=""}updateEditableState(){if(!this.editableInput)return;this.editableInput.setAttribute("aria-expanded",String(this.isOpen)),this.editableInput.classList.toggle("select-editable-input--open",this.isOpen);const e=this.invalid||this.constraintInvalid;this.editableInput.setAttribute("aria-invalid",String(e)),this.editableInput.classList.toggle("select-editable-input--invalid",e)}handleDropdownMousedown(e){this.editable&&e.preventDefault()}handleTriggerOpen(e){["Enter"," ","ArrowDown","ArrowUp"].includes(e.key)&&(e.preventDefault(),this.isOpen||this.openDropdown())}handleSearchKeydown(e){switch(e.key){case"Escape":this.closeDropdown(),this.trigger?.focus();break;case"ArrowDown":e.preventDefault(),this.focusNextOption();break;case"ArrowUp":e.preventDefault(),this.focusPreviousOption();break;case"Enter":if(e.preventDefault(),this.focusedIndex>=0){const e=(this.searchable?this.filteredOptions:this.mergedOptions)[this.focusedIndex];e&&!e.disabled&&this.handleOptionSelect(e)}}}focusNextOption(){const e=this.searchable||this.editable?this.filteredOptions:this.mergedOptions;if(0!==e.filter(e=>!e.disabled).length){for(this.focusedIndex++,this.focusedIndex>=e.length&&(this.focusedIndex=0);e[this.focusedIndex]?.disabled;)this.focusedIndex++,this.focusedIndex>=e.length&&(this.focusedIndex=0);this.updateOptionFocus()}}focusPreviousOption(){const e=this.searchable||this.editable?this.filteredOptions:this.mergedOptions;if(0!==e.filter(e=>!e.disabled).length){for(this.focusedIndex--,this.focusedIndex<0&&(this.focusedIndex=e.length-1);e[this.focusedIndex]?.disabled;)this.focusedIndex--,this.focusedIndex<0&&(this.focusedIndex=e.length-1);this.updateOptionFocus()}}updateOptionFocus(){if(this.optionElements){this.optionElements.forEach((e,t)=>{e.classList.toggle("select-option--focused",t===this.focusedIndex)});const e=this.optionElements?.[this.focusedIndex];e&&e.scrollIntoView({block:"nearest"})}}handleClearClick(e){this.interactionDisabled||this.readonly||(e.preventDefault(),e.stopPropagation(),this.clear())}handleTriggerClick(e){e.target.closest(".select-clear")||(e.stopPropagation(),this.interactionDisabled||this.readonly||this.toggleDropdown())}handleOptionsClick(e){if(this.interactionDisabled||this.readonly)return;const t=e.target;if(t.closest(".select-tag-remove")){e.stopPropagation();const i=t.closest(".select-tag-remove").getAttribute("data-value");return void(i&&this.multiple&&(this.selectedValues.delete(i),this.value=Array.from(this.selectedValues).join(","),this.updateValueDisplay(),this.updateClearButton(),this.dispatchChangeEvent()))}const i=t.closest(".select-option");if(!i)return;e.stopPropagation();const s=i.getAttribute("data-value");if(!s)return;const a=this.resolvableOptions.find(e=>e.value===s);a&&!a.disabled&&(this.editable?this.handleEditableOptionSelect(a):this.handleOptionSelect(a))}handleSearchInput(e){const t=e.target.value;if(this.remote)return void this.scheduleRemoteSearch(t);const i=t.toLowerCase();this.filteredOptions=i?this.mergedOptions.filter(e=>e.label.toLowerCase().includes(i)):[...this.mergedOptions],this.focusedIndex=-1,this.updateDropdownContent()}handleOptionSelect(e){this.multiple?(this.selectedValues.has(e.value)?this.selectedValues.delete(e.value):this.selectedValues.add(e.value),this.value=Array.from(this.selectedValues).join(","),this.updateDropdownContent()):(this.value=e.value,this.closeDropdown()),this.updateValueDisplay(),this.updateClearButton(),this.dispatchChangeEvent(e)}handleValueChange(){this.syncRenderedValue(),this.syncFormState()}handleDefaultValueChange(){this.dirtyValue||this.applyDefaultValue()}handleOptionsPropertyChange(){this.filteredOptions=[...this.mergedOptions],this.updateDropdownContent(),this.editable&&this.syncEditableInputToValue()}handleDisabledChange(){this.editable||(this.updateTriggerState(),this.updateClearButton()),this.interactionDisabled&&this.isOpen&&!this.remote&&this.closeDropdown(),this.syncValidity()}handleValidationConfigurationChange(){this.syncRenderedValue(),this.syncValidity()}handleValidationAnchorChange(){queueMicrotask(()=>{this.rendered.then(()=>{this.isConnected&&(this.syncRenderedValue(),this.syncValidity(),this.labelAssociation.sync())})})}handleInvalidChange(){const e=this.invalid||this.constraintInvalid;this.trigger?.setAttribute("aria-invalid",String(e)),this.trigger?.classList.toggle("select-trigger--invalid",e),this.editableInput?.setAttribute("aria-invalid",String(e)),this.editableInput?.classList.toggle("select-editable-input--invalid",e)}handleOpenChange(){this.updateDropdownState(),this.editable?(this.updateEditableState(),this.isOpen&&(this.remote?this.scheduleRemoteSearch(this.editableInput?.value||""):(this.filteredOptions=[...this.mergedOptions],this.focusedIndex=-1,this.updateDropdownContent())),this.isOpen||(this.focusedIndex=-1)):(this.updateTriggerState(),this.isOpen&&this.searchable&&this.searchInput&&setTimeout(()=>this.searchInput?.focus(),100),this.isOpen&&this.remote&&this.searchable&&this.scheduleRemoteSearch(this.searchInput?.value||""),this.isOpen||(this.focusedIndex=-1,this.searchInput&&(this.searchInput.value="",this.filteredOptions=[...this.mergedOptions],this.updateDropdownContent())))}updateValueDisplay(){if(!this.valueDisplay)return;const e=this.resolvableOptions.filter(e=>this.multiple?this.selectedValues.has(e.value):e.value===this.value);if(this.multiple&&e.length>0){const t=document.createElement("div");t.className="select-value--multiple",e.forEach(e=>{const i=document.createElement("span");i.className="select-tag";const s=document.createElement("span");s.className="select-tag-remove",s.setAttribute("data-value",e.value),s.setAttribute("aria-label",`Remove ${e.label}`),s.hidden=this.interactionDisabled||this.readonly,s.textContent="×",i.append(this.createIcon("select-tag-icon",e.icon),document.createTextNode(e.label),s),t.append(i)}),this.valueDisplay.replaceChildren(t)}else if(e.length>0){const t=e[0],i=document.createElement("div");i.className="select-value--single";const s=document.createElement("span");s.textContent=t.label,i.append(this.createIcon("select-value-icon",t.icon),s),this.valueDisplay.replaceChildren(i)}else{const e=document.createElement("span");e.className="select-placeholder",e.textContent=this.placeholder,this.valueDisplay.replaceChildren(e)}}updateClearButton(){if(!this.clearButton)return;const e=this.resolvableOptions.filter(e=>this.multiple?this.selectedValues.has(e.value):e.value===this.value);this.clearButton.style.display=this.clearable&&e.length>0&&!this.interactionDisabled&&!this.readonly?"":"none"}updateDropdownContent(){this.optionsList&&this.optionsList.replaceChildren(this.renderOptions())}dispatchChangeEvent(e){return{value:this.multiple?Array.from(this.selectedValues):this.value,option:e,select:this}}dispatchOpenEvent(){return{select:this}}dispatchCloseEvent(){return{select:this}}focus(){this.editable?this.editableInput?.focus():this.trigger?.focus()}get type(){return this.multiple?"select-multiple":"select-one"}get form(){return function(e,t){if(t?.form)return t.form;const i=e.getAttribute("form");if(null!==i){const t=e.getRootNode();return"querySelectorAll"in t?Array.from(t.querySelectorAll("form[id]")).find(e=>e instanceof HTMLFormElement&&e.id===i)??null:null}return e.closest("form")}(this,this.internals)}get validity(){return this.internals?.validity??this.validationProxy.validity}get validationMessage(){return this.internals?.validationMessage??this.validationProxy.validationMessage}get willValidate(){return!this.interactionDisabled&&!this.readonly&&(this.internals?.willValidate??!0)}get labels(){return this.labelAssociation.labels}blur(){this.editable?this.editableInput?.blur():this.trigger?.blur(),this.isOpen&&this.closeDropdown()}checkValidity(){return this.syncValidity(),this.internals?.checkValidity()??this.validationProxy.checkValidity()}reportValidity(){return this.syncValidity(),this.internals?.reportValidity()??this.validationProxy.reportValidity()}setCustomValidity(e){this.customValidationMessage=String(e),this.syncValidity()}clear(){this.multiple?(this.selectedValues.clear(),this.value=""):this.value="",this.editable?this.syncEditableInputToValue():(this.updateValueDisplay(),this.updateClearButton()),this.dispatchChangeEvent()}openDropdown(){this.isOpen||this.interactionDisabled||this.readonly||(this.open=!0,this.dispatchOpenEvent())}closeDropdown(){this.isOpen&&(this.open=!1,this.dispatchCloseEvent())}toggleDropdown(){this.isOpen?this.closeDropdown():this.openDropdown()}selectOption(e){const t=this.resolvableOptions.find(t=>t.value===e);t&&!t.disabled&&(this.editable?this.handleEditableOptionSelect(t):this.handleOptionSelect(t))}updateTriggerState(){if(!this.trigger)return;this.trigger.classList.toggle("select-trigger--open",this.isOpen),this.trigger.classList.toggle("select-trigger--disabled",this.interactionDisabled),this.trigger.classList.toggle("select-trigger--readonly",this.readonly);const e=this.invalid||this.constraintInvalid;this.trigger.classList.toggle("select-trigger--invalid",e),this.trigger.setAttribute("aria-invalid",String(e)),this.trigger.classList.toggle("select-trigger--loading",this.loading),this.trigger.setAttribute("aria-expanded",String(this.isOpen)),this.trigger.disabled=this.interactionDisabled}updateDropdownState(){this.dropdown&&(this.dropdown.classList.toggle("select-dropdown--open",this.isOpen),this.arrow&&this.arrow.classList.toggle("select-arrow--open",this.isOpen))}})})()}(Snice);
|
|
111
111
|
//# sourceMappingURL=snice-select.min.js.map
|