@solid-design-system/components 1.21.1 → 1.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/es/carousel.js +3 -3
- package/dist/components/es/checkbox-group.js +1 -0
- package/dist/components/es/checkbox.js +11 -0
- package/dist/components/es/event.js +1 -1
- package/dist/components/es/icon.js +4 -4
- package/dist/components/es/interactive.js +1 -0
- package/dist/components/es/radio-group.js +1 -1
- package/dist/components/es/radio.js +1 -1
- package/dist/components/es/solid-components2.js +1 -1
- package/dist/components/es/solid-element.js +1 -1
- package/dist/components/es/tooltip.js +4 -0
- package/dist/components/umd/solid-components.js +29 -16
- package/dist/custom-elements.json +1 -1
- package/dist/package/components/checkbox/checkbox.d.ts +40 -0
- package/dist/package/components/checkbox/checkbox.js +179 -0
- package/dist/package/components/checkbox-group/checkbox-group.d.ts +20 -0
- package/dist/package/components/checkbox-group/checkbox-group.js +102 -0
- package/dist/package/components/icon/library.system.d.ts +3 -0
- package/dist/package/components/icon/library.system.js +11 -0
- package/dist/package/components/radio/radio.js +1 -3
- package/dist/package/components/radio-group/radio-group.js +7 -8
- package/dist/package/components/tooltip/tooltip.d.ts +39 -0
- package/dist/package/components/tooltip/tooltip.js +233 -0
- package/dist/package/internal/animate.js +11 -0
- package/dist/package/internal/default-value.d.ts +2 -0
- package/dist/package/internal/default-value.js +21 -0
- package/dist/package/solid-components.d.ts +3 -0
- package/dist/package/solid-components.js +34 -28
- package/dist/package/styles/tailwind.css.js +1 -1
- package/dist/versioned-components/es/accordion-group.js +1 -1
- package/dist/versioned-components/es/accordion.js +1 -1
- package/dist/versioned-components/es/badge.js +1 -1
- package/dist/versioned-components/es/brandshape.js +1 -1
- package/dist/versioned-components/es/button.js +1 -1
- package/dist/versioned-components/es/carousel-item.js +1 -1
- package/dist/versioned-components/es/carousel.js +3 -3
- package/dist/versioned-components/es/checkbox-group.js +1 -0
- package/dist/versioned-components/es/checkbox.js +11 -0
- package/dist/versioned-components/es/divider.js +1 -1
- package/dist/versioned-components/es/drawer.js +1 -1
- package/dist/versioned-components/es/dropdown.js +1 -1
- package/dist/versioned-components/es/event.js +1 -1
- package/dist/versioned-components/es/form.js +1 -1
- package/dist/versioned-components/es/icon.js +4 -4
- package/dist/versioned-components/es/include.js +1 -1
- package/dist/versioned-components/es/interactive.js +1 -0
- package/dist/versioned-components/es/link.js +1 -1
- package/dist/versioned-components/es/navigation-item.js +1 -1
- package/dist/versioned-components/es/popup.js +1 -1
- package/dist/versioned-components/es/radio-group.js +1 -1
- package/dist/versioned-components/es/radio.js +1 -1
- package/dist/versioned-components/es/solid-components2.js +1 -1
- package/dist/versioned-components/es/solid-element.js +1 -1
- package/dist/versioned-components/es/spinner.js +1 -1
- package/dist/versioned-components/es/tag.js +1 -1
- package/dist/versioned-components/es/teaser.js +1 -1
- package/dist/versioned-components/es/tooltip.js +4 -0
- package/dist/versioned-components/es/video.js +1 -1
- package/dist/versioned-package/_components/button-group/button-group.d.ts +1 -1
- package/dist/versioned-package/_components/button-group/button-group.js +11 -11
- package/dist/versioned-package/components/accordion/accordion.d.ts +1 -1
- package/dist/versioned-package/components/accordion/accordion.js +2 -2
- package/dist/versioned-package/components/accordion-group/accordion-group.d.ts +1 -1
- package/dist/versioned-package/components/accordion-group/accordion-group.js +3 -3
- package/dist/versioned-package/components/badge/badge.d.ts +1 -1
- package/dist/versioned-package/components/badge/badge.js +1 -1
- package/dist/versioned-package/components/brandshape/brandshape.d.ts +1 -1
- package/dist/versioned-package/components/brandshape/brandshape.js +1 -1
- package/dist/versioned-package/components/button/button.d.ts +1 -1
- package/dist/versioned-package/components/button/button.js +4 -4
- package/dist/versioned-package/components/carousel/carousel.d.ts +1 -1
- package/dist/versioned-package/components/carousel/carousel.js +6 -6
- package/dist/versioned-package/components/carousel-item/carousel-item.d.ts +1 -1
- package/dist/versioned-package/components/carousel-item/carousel-item.js +1 -1
- package/dist/versioned-package/components/checkbox/checkbox.d.ts +40 -0
- package/dist/versioned-package/components/checkbox/checkbox.js +179 -0
- package/dist/versioned-package/components/checkbox-group/checkbox-group.d.ts +20 -0
- package/dist/versioned-package/components/checkbox-group/checkbox-group.js +102 -0
- package/dist/versioned-package/components/divider/divider.d.ts +1 -1
- package/dist/versioned-package/components/divider/divider.js +2 -2
- package/dist/versioned-package/components/drawer/drawer.d.ts +1 -1
- package/dist/versioned-package/components/drawer/drawer.js +2 -2
- package/dist/versioned-package/components/dropdown/dropdown.d.ts +1 -1
- package/dist/versioned-package/components/dropdown/dropdown.js +6 -6
- package/dist/versioned-package/components/icon/icon.d.ts +1 -1
- package/dist/versioned-package/components/icon/icon.js +1 -1
- package/dist/versioned-package/components/icon/library.system.d.ts +3 -0
- package/dist/versioned-package/components/icon/library.system.js +11 -0
- package/dist/versioned-package/components/include/include.d.ts +1 -1
- package/dist/versioned-package/components/include/include.js +1 -1
- package/dist/versioned-package/components/link/link.d.ts +1 -1
- package/dist/versioned-package/components/link/link.js +2 -2
- package/dist/versioned-package/components/navigation-item/navigation-item.d.ts +1 -1
- package/dist/versioned-package/components/navigation-item/navigation-item.js +3 -3
- package/dist/versioned-package/components/popup/popup.d.ts +1 -1
- package/dist/versioned-package/components/popup/popup.js +1 -1
- package/dist/versioned-package/components/radio/radio.d.ts +1 -1
- package/dist/versioned-package/components/radio/radio.js +3 -5
- package/dist/versioned-package/components/radio-group/radio-group.d.ts +2 -2
- package/dist/versioned-package/components/radio-group/radio-group.js +18 -19
- package/dist/versioned-package/components/spinner/spinner.d.ts +1 -1
- package/dist/versioned-package/components/spinner/spinner.js +1 -1
- package/dist/versioned-package/components/tag/tag.d.ts +1 -1
- package/dist/versioned-package/components/tag/tag.js +2 -2
- package/dist/versioned-package/components/teaser/teaser.js +1 -1
- package/dist/versioned-package/components/tooltip/tooltip.d.ts +39 -0
- package/dist/versioned-package/components/tooltip/tooltip.js +233 -0
- package/dist/versioned-package/components/video/video.d.ts +1 -1
- package/dist/versioned-package/components/video/video.js +2 -2
- package/dist/versioned-package/internal/animate.js +11 -0
- package/dist/versioned-package/internal/default-value.d.ts +2 -0
- package/dist/versioned-package/internal/default-value.js +21 -0
- package/dist/versioned-package/internal/form.js +1 -1
- package/dist/versioned-package/solid-components.d.ts +3 -0
- package/dist/versioned-package/solid-components.js +34 -28
- package/dist/versioned-package/styles/tailwind.css.js +1 -1
- package/dist/versioned-styles/solid-styles.css +1 -1
- package/dist/vscode.html-custom-data.json +345 -21
- package/dist/web-types.json +504 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
import{x as t,i as e}from"./lit-element.js";import{c as s}from"./register-custom-element.js";import{c as r}from"./component.styles.js";import{S as o}from"./solid-element.js";Object.defineProperty,Object.getOwnPropertyDescriptor;let i=class extends o{static isCarouselItem(t){return t instanceof Element&&"slide"===t.getAttribute("aria-roledescription")}connectedCallback(){super.connectedCallback(),this.setAttribute("role","group")}render(){return t`<slot></slot>`}};i.styles=[o.styles,e`${r}:host{display:flex;align-items:center;justify-content:center;flex-direction:column;width:100%;height:100%;aspect-ratio:var(--aspect-ratio);scroll-snap-align:start;scroll-snap-stop:always}::slotted(img){width:100%;height:100%;object-fit:cover}`],i=((t,e,s,r)=>{for(var o,i=e,l=t.length-1;l>=0;l--)(o=t[l])&&(i=o(i)||i);return i})([s("sd-1-
|
|
1
|
+
import{x as t,i as e}from"./lit-element.js";import{c as s}from"./register-custom-element.js";import{c as r}from"./component.styles.js";import{S as o}from"./solid-element.js";Object.defineProperty,Object.getOwnPropertyDescriptor;let i=class extends o{static isCarouselItem(t){return t instanceof Element&&"slide"===t.getAttribute("aria-roledescription")}connectedCallback(){super.connectedCallback(),this.setAttribute("role","group")}render(){return t`<slot></slot>`}};i.styles=[o.styles,e`${r}:host{display:flex;align-items:center;justify-content:center;flex-direction:column;width:100%;height:100%;aspect-ratio:var(--aspect-ratio);scroll-snap-align:start;scroll-snap-stop:always}::slotted(img){width:100%;height:100%;object-fit:cover}`],i=((t,e,s,r)=>{for(var o,i=e,l=t.length-1;l>=0;l--)(o=t[l])&&(i=o(i)||i);return i})([s("sd-1-23-0-carousel-item")],i);export{i as default};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import"./icon.js";import{AutoplayController as e}from"./autoplay-controller.js";import{x as t,r as i,i as s}from"./lit-element.js";import{c as o}from"./register-custom-element.js";import{L as r}from"./solid-components2.js";import{p as a}from"./event.js";import{S as l,n}from"./solid-element.js";import{r as
|
|
1
|
+
import"./icon.js";import{AutoplayController as e}from"./autoplay-controller.js";import{x as t,r as i,i as s}from"./lit-element.js";import{c as o}from"./register-custom-element.js";import{L as r}from"./solid-components2.js";import{p as a}from"./event.js";import{S as l,n}from"./solid-element.js";import{r as c}from"./state.js";import{e as d}from"./query.js";import{ScrollController as p}from"./scroll-controller.js";import{w as h}from"./watch.js";import{c as u}from"./component.styles.js";import{t as g}from"./classix.js";import{I as v}from"./interactive.js";import m from"./carousel-item.js";import"./request.js";import"./request2.js";var b=Object.defineProperty,y=Object.getOwnPropertyDescriptor,f=(e,t,i,s)=>{for(var o,r=s>1?void 0:s?y(t,i):t,a=e.length-1;a>=0;a--)(o=e[a])&&(r=(s?o(t,i,r):o(r))||r);return s&&r&&b(t,i,r),r};let w=class extends l{constructor(){super(...arguments),this.variant="number",this.inverted=!1,this.loop=!1,this.autoplay=!1,this.slidesPerPage=1,this.slidesPerMove=1,this.activeSlide=0,this.pausedAutoplay=!1,this.autoplayController=new e(this,(()=>this.next())),this.scrollController=new p(this),this.slides=this.getElementsByTagName("sd-1-23-0-carousel-item"),this.intersectionObserverEntries=new Map,this.localize=new r(this),this.handleSlotChange=e=>{e.some((e=>[...e.addedNodes,...e.removedNodes].some((e=>m.isCarouselItem(e)&&!e.hasAttribute("data-clone")))))&&this.initializeSlides(),this.requestUpdate()}}connectedCallback(){super.connectedCallback(),this.setAttribute("role","region"),this.setAttribute("aria-label",this.localize.term("carousel"));const e=new IntersectionObserver((e=>{e.forEach((e=>{this.intersectionObserverEntries.set(e.target,e);const t=e.target;t.toggleAttribute("inert",!e.isIntersecting),t.classList.toggle("--in-view",e.isIntersecting),t.setAttribute("aria-hidden",e.isIntersecting?"false":"true")}))}),{root:this,threshold:.6});this.intersectionObserver=e,e.takeRecords().forEach((e=>{this.intersectionObserverEntries.set(e.target,e)}))}disconnectedCallback(){super.disconnectedCallback(),this.intersectionObserver.disconnect(),this.mutationObserver.disconnect()}firstUpdated(){this.initializeSlides(),this.mutationObserver=new MutationObserver(this.handleSlotChange),this.mutationObserver.observe(this,{childList:!0,subtree:!1})}getPageCount(){return Math.ceil(this.getSlides().length/this.slidesPerPage)}getCurrentPage(){return Math.ceil(this.activeSlide/this.slidesPerPage)}getSlides({excludeClones:e=!0}={}){return[...this.slides].filter((t=>!e||!t.hasAttribute("data-clone")))}handleKeyDown(e){if(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(e.key)){const t=e.target,i="rtl"===this.localize.dir(),s=null!==t.closest('[part~="pagination-item"]'),o="ArrowDown"===e.key||!i&&"ArrowRight"===e.key||i&&"ArrowLeft"===e.key,r="ArrowUp"===e.key||!i&&"ArrowLeft"===e.key||i&&"ArrowRight"===e.key;e.preventDefault(),r&&this.previous(),o&&this.next(),"Home"===e.key&&this.goToSlide(0),"End"===e.key&&this.goToSlide(this.getSlides().length-1),s&&this.updateComplete.then((()=>{var e;const t=null==(e=this.shadowRoot)?void 0:e.querySelector('[part~="pagination-item--active"]');t&&t.focus()}))}}handleScrollEnd(){const e=this.getSlides(),t=[...this.intersectionObserverEntries.values()].find((e=>e.isIntersecting));if(this.loop&&null!=t&&t.target.hasAttribute("data-clone")){const e=Number(t.target.getAttribute("data-clone"));this.goToSlide(e,"auto")}else t&&(this.activeSlide=e.indexOf(t.target))}handlePausedAutoplay(){this.pausedAutoplay?this.autoplayController.controlledPause():this.autoplay&&this.autoplayController.controlledResume()}initializeSlides(){const e=this.getSlides(),t=this.intersectionObserver;if(this.intersectionObserverEntries.clear(),this.getSlides({excludeClones:!1}).forEach(((e,i)=>{t.unobserve(e),e.classList.remove("--in-view"),e.classList.remove("--is-active"),e.setAttribute("aria-label",this.localize.term("slideNum",i+1)),e.hasAttribute("data-clone")&&e.remove()})),this.loop){const t=this.slidesPerPage,i=e.slice(-t),s=e.slice(0,t);i.reverse().forEach(((t,i)=>{const s=t.cloneNode(!0);s.setAttribute("data-clone",String(e.length-i-1)),this.prepend(s)})),s.forEach(((e,t)=>{const i=e.cloneNode(!0);i.setAttribute("data-clone",String(t)),this.append(i)}))}this.getSlides({excludeClones:!1}).forEach((e=>{t.observe(e)})),this.goToSlide(this.activeSlide,"auto")}handelSlideChange(){const e=this.getSlides();e.forEach(((e,t)=>{e.classList.toggle("--is-active",t===this.activeSlide)})),this.hasUpdated&&this.emit("sd-slide-change",{detail:{index:this.activeSlide,slide:e[this.activeSlide]}})}handleSlidesPerMoveChange(){const e=this.getSlides({excludeClones:!1}),t=this.slidesPerMove;e.forEach(((e,i)=>{Math.abs(i-t)%t==0?e.style.removeProperty("scroll-snap-align"):e.style.setProperty("scroll-snap-align","none")}))}handleAutoplayChange(){this.autoplayController.stop(),this.autoplay&&!this.pausedAutoplay&&this.autoplayController.start(3e3)}previous(e="smooth"){let t=this.activeSlide||this.activeSlide-this.slidesPerMove,i=!1;for(;!i&&t>0;)t-=1,i=Math.abs(t-this.slidesPerMove)%this.slidesPerMove==0;this.goToSlide(t,e)}next(e="smooth"){this.goToSlide(this.activeSlide+this.slidesPerMove,e)}goToSlide(e,t="smooth"){const{slidesPerPage:i,loop:s,scrollContainer:o}=this,r=this.getSlides(),l=this.getSlides({excludeClones:!1}),n=(e+r.length)%r.length;this.activeSlide=n;const c=function(e,t,i){return(e=>Object.is(e,-0)?0:e)(e<0?0:e>i?i:e)}
|
|
2
2
|
/**
|
|
3
3
|
* @license
|
|
4
4
|
* Copyright 2021 Google LLC
|
|
5
5
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
6
|
-
*/(e+(s?i:0),0,l.length-1),
|
|
6
|
+
*/(e+(s?i:0),0,l.length-1),d=l[c],p=o.getBoundingClientRect(),h=d.getBoundingClientRect();o.scrollTo({left:h.left-p.left+o.scrollLeft,top:h.top-p.top+o.scrollTop,behavior:a()?"auto":t})}render(){const{scrollController:e,slidesPerPage:i}=this,s=this.getPageCount(),o=this.getCurrentPage(),r=this.loop||o>0,a=this.loop||o<s-1,l="ltr"===this.localize.dir();return t`<div part="base" class="${g("carousel h-full w-full")}"><div id="scroll-container" part="scroll-container" class="${g("carousel__slides mb-6\n grid max-h-full w-full items-center justify-items-center overflow-auto",this.inverted?"focus-visible:focus-outline-inverted":"focus-visible:focus-outline","overscroll-x-contain grid-flow-col auto-rows-[100%]\n snap-x snap-mandatory overflow-y-hidden")}" style="--slides-per-page:${this.slidesPerPage}" aria-busy="${e.scrolling?"true":"false"}" aria-atomic="true" tabindex="0" @keydown="${this.handleKeyDown}" @scrollend="${this.handleScrollEnd}"><slot></slot></div><div part="controls" class="${g("w-full flex items-center justify-center relative")}"><div part="navigation" class="${g("carousel__navigation flex items-center justify-center")}"><button part="navigation-button navigation-button--previous" id="carousel__navigation-button--previous" ?disabled="${!r}" class="${g("!mr-6 !rounded-sm sd-interactive",!r&&"sd-interactive--disabled",this.inverted?"sd-interactive--inverted":"sd-interactive--reset")}" aria-label="${this.localize.term("previousSlide")}" aria-controls="scroll-container" aria-disabled="${r?"false":"true"}" @click="${r?()=>this.previous():null}"><slot name="previous-icon"><sd-1-23-0-icon class="${g("h-6 w-6 rotate-90 grid place-items-center")}" library="system" name="${l?"chevron-down":"chevron-up"}"></sd-1-23-0-icon></slot></button> ${"dot"===this.variant?t`<div part="pagination-dot" role="tablist" class="${g("carousel__pagination dot flex wrap items-center gap-2")}" aria-controls="scroll-container">${function*(e,t){if(void 0!==e){let i=0;for(const s of e)yield t(s,i++)}}
|
|
7
7
|
/**
|
|
8
8
|
* @license
|
|
9
9
|
* Copyright 2021 Google LLC
|
|
10
10
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
11
|
-
*/(function*(e,t,i=1){const s=void 0===t?0:e;t??(t=e);for(let e=s;i>0?e<t:t<e;e+=i)yield e}(s),(e=>{const r=e===o;return t`<button part="pagination-item ${r?"pagination-item--active":""}" class="${
|
|
11
|
+
*/(function*(e,t,i=1){const s=void 0===t?0:e;t??(t=e);for(let e=s;i>0?e<t:t<e;e+=i)yield e}(s),(e=>{const r=e===o;return t`<button part="pagination-item ${r?"pagination-item--active":""}" class="${g("carousel__pagination-item","block cursor-pointer bg-none border-0 rounded-full",r?"bg-accent":"",this.inverted?"focus-within:focus-outline-inverted":"focus-within:focus-outline")}" role="tab" tabindex="0" aria-selected="${r?"true":"false"}" aria-label="${this.localize.term("goToSlide",e+1,s)}" @click="${()=>this.goToSlide(e*i)}" @keydown="${this.handleKeyDown}"><span class="${g("h-4 w-4 block border hover:border-primary-500 rounded-full",this.inverted?"border-white hover:border-primary-500":"border-primary",r&&"bg-accent border-none",r?this.inverted?"hover:bg-accent-300":"hover:bg-accent-550":"")}"></span></button>`}))}</div>`:t`<span part="pagination-number" class="carousel__pagination number flex gap-0.5 cursor-default select-none" aria-controls="scroll-container"><span part="pagination-item" class="${g("w-5 text-center border-b-2 border-accent",this.inverted?"text-white":"text-black")}">${o+1}</span> <span part="pagination-divider" class="${g("scale-y-[1.5]","text-center",this.inverted?"text-white":"text-black")}">/</span> <span part="pagination-item" class="${g("w-5 text-center",this.inverted?"text-white":"text-black")}">${s}</span></span>`} <button part="navigation-button navigation-button--next" id="carousel__navigation-button--next" ?disabled="${!a}" class="${g("!ml-6 !rounded-sm sd-interactive ",!a&&"sd-interactive--disabled",this.inverted?"sd-interactive--inverted":"sd-interactive--reset")}" aria-label="${this.localize.term("nextSlide")}" aria-controls="scroll-container" aria-disabled="${a?"false":"true"}" @click="${a?()=>{console.log("click-next"),this.next()}:null}"><slot name="next-icon"><sd-1-23-0-icon class="${g("h-6 w-6 rotate-90 grid place-items-center")}" library="system" name="${l?"chevron-up":"chevron-down"}"></sd-1-23-0-icon></slot></button></div><button class="${g("ml-6 !rounded-sm","!absolute !right-0 sd-interactive",this.inverted?"sd-interactive--inverted":"sd-interactive--reset",!this.autoplay&&"!hidden")}" part="autoplay-controls" @click="${()=>this.pausedAutoplay=!this.pausedAutoplay}"><slot name="autoplay-start" class="${g(this.pausedAutoplay?"":"hidden")}"><sd-1-23-0-icon class="h-6 w-6 grid place-items-center" library="system" name="start"></sd-1-23-0-icon></slot><slot name="autoplay-pause" class="${g(this.pausedAutoplay?"hidden":"")}"><sd-1-23-0-icon class="h-6 w-6 grid place-items-center" library="system" name="pause"></sd-1-23-0-icon></slot></button></div></div>`}};w.styles=[l.styles,i(v),s`${u}:host{--slide-gap:var(--sl-spacing-medium, 1rem);--scroll-hint:0px;display:flex}.carousel{grid-template-areas:'. slides .' '. pagination .'}.carousel__pagination{grid-area:pagination}.carousel__slides{grid-area:slides;scrollbar-width:none;--slide-size:calc((100% - (var(--slides-per-page) - 1) * var(--slide-gap)) / var(--slides-per-page));grid-auto-columns:var(--slide-size);column-gap:var(--slide-gap);scroll-padding-inline:var(--scroll-hint);padding-inline:var(--scroll-hint)}@media (prefers-reduced-motion){:where(.carousel__slides){scroll-behavior:auto}}.carousel__slides--dragging,.carousel__slides--dropping{scroll-snap-type:unset}.carousel__slides::-webkit-scrollbar{display:none}.carousel__navigation{grid-area:navigation}sd-1-23-0-button::part(label){display:flex;flex:1 1 auto;align-items:center;pointer-events:none}`],f([n({type:String,reflect:!0})],w.prototype,"variant",2),f([n({type:Boolean,reflect:!0})],w.prototype,"inverted",2),f([n({type:Boolean,reflect:!0})],w.prototype,"loop",2),f([n({type:Boolean,reflect:!0})],w.prototype,"autoplay",2),f([n({type:Number,attribute:"slides-per-page"})],w.prototype,"slidesPerPage",2),f([n({type:Number,attribute:"slides-per-move"})],w.prototype,"slidesPerMove",2),f([d("slot:not([name])")],w.prototype,"defaultSlot",2),f([d(".carousel__slides")],w.prototype,"scrollContainer",2),f([d(".carousel__pagination")],w.prototype,"paginationContainer",2),f([c()],w.prototype,"activeSlide",2),f([c()],w.prototype,"pausedAutoplay",2),f([h("pausedAutoplay")],w.prototype,"handlePausedAutoplay",1),f([h("loop",{waitUntilFirstUpdate:!0}),h("slidesPerPage",{waitUntilFirstUpdate:!0})],w.prototype,"initializeSlides",1),f([h("activeSlide")],w.prototype,"handelSlideChange",1),f([h("slidesPerMove")],w.prototype,"handleSlidesPerMoveChange",1),f([h("autoplay")],w.prototype,"handleAutoplayChange",1),w=f([o("sd-1-23-0-carousel")],w);export{w as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./icon.js";import{x as t,i as e}from"./lit-element.js";import{c as o}from"./register-custom-element.js";import{H as s}from"./slot.js";import{S as l,n as i}from"./solid-element.js";import{w as r}from"./watch.js";import{c as a}from"./component.styles.js";import{t as n}from"./classix.js";import"./solid-components2.js";import"./state.js";import"./request.js";import"./request2.js";var c=Object.defineProperty,h=Object.getOwnPropertyDescriptor,m=(t,e,o,s)=>{for(var l,i=s>1?void 0:s?h(e,o):e,r=t.length-1;r>=0;r--)(l=t[r])&&(i=(s?l(e,o,i):l(i))||i);return s&&i&&c(e,o,i),i};let d=class extends l{constructor(){super(...arguments),this.hasSlotController=new s(this,"label"),this.label="",this.size="lg",this.orientation="vertical"}getAllCheckboxes(){return[...this.querySelectorAll("sd-1-23-0-checkbox")]}async syncCheckboxElements(){const t=this.getAllCheckboxes();await Promise.all(t.map((async t=>{await t.updateComplete,t.size=this.size}))),t.some((t=>t.checked))||(t[0].tabIndex=0)}syncCheckboxes(){customElements.get("sd-1-23-0-checkbox")?this.syncCheckboxElements():customElements.whenDefined("sd-1-23-0-checkbox").then((()=>this.syncCheckboxes()))}handleSizeChange(){this.syncCheckboxes()}handleInvalid(){this.syncCheckboxes()}render(){const e=this.hasSlotController.test("label"),o=!!this.label||e,s=t`<slot @slotchange="${this.syncCheckboxes}"></slot>`;return t`<fieldset part="form-control" class="${n("border-0 p-0 m-0",{sm:"text-sm",lg:"text-base"}[this.size])}" role="group" aria-labelledby="label"><label part="form-control-label" id="label" class="${n("mb-2 p-0 font-bold leading-normal text-black",o?"flex":"hidden")}" aria-hidden="${!o}"><slot name="label">${this.label}</slot></label><div part="form-control-input" class="${n({vertical:"flex flex-col",horizontal:"flex flex-row"}[this.orientation])}">${s}</div></fieldset>`}};d.styles=[a,l.styles,e`:host{display:block}:host([orientation=vertical]) ::slotted(sd-1-23-0-checkbox){margin-bottom:8px;display:flex}:host([orientation=vertical]) ::slotted(sd-1-23-0-checkbox:last-of-type){margin-bottom:0}:host([orientation=horizontal]) ::slotted(sd-1-23-0-checkbox){margin-right:24px}:host([size=sm]):host([orientation=horizontal]) ::slotted(sd-1-23-0-checkbox){margin-right:16px}:host([orientation=horizontal]) ::slotted(sd-1-23-0-checkbox:last-of-type){margin-right:0}`],m([i()],d.prototype,"label",2),m([i({reflect:!0})],d.prototype,"size",2),m([i({reflect:!0})],d.prototype,"orientation",2),m([r("size",{waitUntilFirstUpdate:!0})],d.prototype,"handleSizeChange",1),m([r("invalid",{waitUntilFirstUpdate:!0})],d.prototype,"handleInvalid",1),d=m([o("sd-1-23-0-checkbox-group")],d);export{d as default};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import{e,i as t,t as i}from"./icon.js";import{u as r,w as s,T as o,x as n,i as l}from"./lit-element.js";import{c as a}from"./register-custom-element.js";import{F as d}from"./form.js";import{o as c}from"./if-defined.js";import{S as h,n as u}from"./solid-element.js";import{e as p}from"./query.js";import{w as m}from"./watch.js";import{t as b}from"./classix.js";import"./solid-components2.js";import"./state.js";import"./request.js";import"./request2.js";import"./component.styles.js";const f={},y=e(class extends t{constructor(e){if(super(e),e.type!==i.PROPERTY&&e.type!==i.ATTRIBUTE&&e.type!==i.BOOLEAN_ATTRIBUTE)throw Error("The `live` directive is not allowed on child or event bindings");if(!(e=>void 0===e.strings)(e))throw Error("`live` bindings can only contain a single expression")}render(e){return e}update(e,[t]){if(t===s||t===o)return t;const r=e.element,n=e.name;if(e.type===i.PROPERTY){if(t===r[n])return s}else if(e.type===i.BOOLEAN_ATTRIBUTE){if(!!t===r.hasAttribute(n))return s}else if(e.type===i.ATTRIBUTE&&r.getAttribute(n)===t+"")return s;return((e,t=f)=>{e._$AH=t;
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright 2020 Google LLC
|
|
5
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
6
|
+
*/})(e),t}});
|
|
7
|
+
/**
|
|
8
|
+
* @license
|
|
9
|
+
* Copyright 2020 Google LLC
|
|
10
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
11
|
+
*/var k=Object.defineProperty,v=Object.getOwnPropertyDescriptor,g=(e,t,i,r)=>{for(var s,o=r>1?void 0:r?v(t,i):t,n=e.length-1;n>=0;n--)(s=e[n])&&(o=(r?s(t,i,o):s(o))||o);return r&&o&&k(t,i,o),o};let C=class extends h{constructor(){super(...arguments),this.formControlController=new d(this,{value:e=>e.checked?e.value||"on":void 0,defaultValue:e=>e.defaultChecked,setValue:(e,t)=>e.checked=t}),this.title="",this.name="",this.size="lg",this.disabled=!1,this.checked=!1,this.indeterminate=!1,this.defaultChecked=!1,this.form="",this.required=!1}get validity(){return this.input.validity}firstUpdated(){this.formControlController.updateValidity()}handleClick(){this.checked=!this.checked,this.indeterminate=!1,this.emit("sd-change")}handleBlur(){this.emit("sd-blur")}handleInput(){this.emit("sd-input")}handleInvalid(e){this.formControlController.setValidity(!1),this.formControlController.emitInvalidEvent(e)}handleFocus(){this.emit("sd-focus")}handleDisabledChange(){this.setAttribute("aria-disabled",this.disabled?"true":"false"),this.formControlController.setValidity(this.disabled)}handleStateChange(){this.input.checked=this.checked,this.input.indeterminate=this.indeterminate,this.formControlController.updateValidity()}click(){this.input.click()}focus(e){this.input.focus(e)}blur(){this.input.blur()}checkValidity(){return this.input.checkValidity()}getForm(){return this.formControlController.getForm()}reportValidity(){return this.input.reportValidity()}setCustomValidity(e){this.input.setCustomValidity(e),this.formControlController.updateValidity()}render(){return n`<label part="base" class="${b("sd-1-23-0-checkbox group flex items-start text-base leading-normal text-black cursor-pointer",this.disabled&&"hover:cursor-not-allowed",{sm:"text-sm",lg:"text-base"}[this.size])}"><input class="peer absolute opacity-0 p-0 m-0 pointer-events-none" type="checkbox" title="${this.title}" name="${this.name}" value="${c(this.value)}" .indeterminate="${y(this.indeterminate)}" .checked="${y(this.checked)}" .disabled="${this.disabled}" .required="${this.required}" aria-checked="${this.checked?"true":"false"}" @click="${this.handleClick}" @input="${this.handleInput}" @invalid="${this.handleInvalid}" @blur="${this.handleBlur}" @focus="${this.handleFocus}"> <span id="control" part="control ${this.checked?" control--checked":"control--unchecked"} ${this.indeterminate?" control--indeterminate":""}" class="${b("relative flex flex-initial items-center justify-center border rounded-sm h-4 w-4 \n peer-focus-visible:outline peer-focus-visible:outline-2 peer-focus-visible:outline-offset-2 \n peer-focus-visible:outline-primary",{sm:"mt-[2px]",lg:"mt-[3px]"}[this.size],(this.disabled&&this.indeterminate||this.disabled&&this.checked?"border-neutral-500 bg-neutral-500":this.disabled&&"border-neutral-500")||(this.checked||this.indeterminate)&&"border-accent hover:border-accent-550 group-hover:border-accent-550 bg-accent group-hover:bg-accent-550"||"border-neutral-800 hover:bg-neutral-200 group-hover:bg-neutral-200 bg-white")}">${this.checked?n`<sd-1-23-0-icon part="checked-icon" class="text-white w-3 h-3" library="system" name="status-hook"></sd-1-23-0-icon>`:""} ${!this.checked&&this.indeterminate?n`<sd-1-23-0-icon part="indeterminate-icon" class="text-white w-3 h-3" library="system" name="status-minus"></sd-1-23-0-icon>`:""} </span><span part="label" id="label" class="${b("select-none inline-block ml-2 text-black",this.disabled?"text-neutral-500":"text-neutral-800")}"><slot></slot></span></label>`}};C.styles=[h.styles,l`:host{display:block}:host(:focus-visible){outline:0}:host([required]) #label::after{content:' *'}:host([data-user-invalid]) #label{color:rgb(var(--sd-color-error,204 25 55))}:host([data-user-invalid]) #control{border-color:rgb(var(--sd-color-error,204 25 55))}:host([data-user-invalid]):host([indeterminate]) #control{background-color:rgb(var(--sd-color-error,204 25 55))}`],g([p('input[type="checkbox"]')],C.prototype,"input",2),g([u()],C.prototype,"title",2),g([u()],C.prototype,"name",2),g([u()],C.prototype,"value",2),g([u({reflect:!0})],C.prototype,"size",2),g([u({type:Boolean,reflect:!0})],C.prototype,"disabled",2),g([u({type:Boolean,reflect:!0})],C.prototype,"checked",2),g([u({type:Boolean,reflect:!0})],C.prototype,"indeterminate",2),g([((e="value")=>(t,i)=>{const s=t.constructor,o=s.prototype.attributeChangedCallback;s.prototype.attributeChangedCallback=function(t,n,l){const a=s.getPropertyOptions(e);if(t===("string"==typeof a.attribute?a.attribute:e)){const t=a.converter||r,s=("function"==typeof t?t:(null==t?void 0:t.fromAttribute)??r.fromAttribute)(l,a.type);this[e]!==s&&(this[i]=s)}o.call(this,t,n,l)}})("checked")],C.prototype,"defaultChecked",2),g([u({reflect:!0})],C.prototype,"form",2),g([u({type:Boolean,reflect:!0})],C.prototype,"required",2),g([m("disabled",{waitUntilFirstUpdate:!0})],C.prototype,"handleDisabledChange",1),g([m(["checked","indeterminate"],{waitUntilFirstUpdate:!0})],C.prototype,"handleStateChange",1),C=g([a("sd-1-23-0-checkbox")],C);export{C as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{x as t,i as e}from"./lit-element.js";import{c as r}from"./register-custom-element.js";import{S as o,n as i}from"./solid-element.js";import{c as s}from"./component.styles.js";import{t as n}from"./classix.js";var a=Object.defineProperty,l=Object.getOwnPropertyDescriptor,d=(t,e,r,o)=>{for(var i,s=o>1?void 0:o?l(e,r):e,n=t.length-1;n>=0;n--)(i=t[n])&&(s=(o?i(e,r,s):i(s))||s);return o&&s&&a(e,r,s),s};let c=class extends o{constructor(){super(...arguments),this.orientation="horizontal",this.inverted=!1}connectedCallback(){super.connectedCallback(),this.setAttribute("role","separator")}render(){return t`<hr part="main" class="${n(this.inverted?"border-primary-400":"border-neutral-400","horizontal"===this.orientation?"border-t w-full":" border-l h-full")}">`}};c.styles=[s,o.styles,e`:host{margin:0}:host(sd-1-
|
|
1
|
+
import{x as t,i as e}from"./lit-element.js";import{c as r}from"./register-custom-element.js";import{S as o,n as i}from"./solid-element.js";import{c as s}from"./component.styles.js";import{t as n}from"./classix.js";var a=Object.defineProperty,l=Object.getOwnPropertyDescriptor,d=(t,e,r,o)=>{for(var i,s=o>1?void 0:o?l(e,r):e,n=t.length-1;n>=0;n--)(i=t[n])&&(s=(o?i(e,r,s):i(s))||s);return o&&s&&a(e,r,s),s};let c=class extends o{constructor(){super(...arguments),this.orientation="horizontal",this.inverted=!1}connectedCallback(){super.connectedCallback(),this.setAttribute("role","separator")}render(){return t`<hr part="main" class="${n(this.inverted?"border-primary-400":"border-neutral-400","horizontal"===this.orientation?"border-t w-full":" border-l h-full")}">`}};c.styles=[s,o.styles,e`:host{margin:0}:host(sd-1-23-0-divider[orientation=horizontal]){display:block}:host(sd-1-23-0-divider[orientation=vertical]){display:inline-block}`],d([i({reflect:!0})],c.prototype,"orientation",2),d([i({type:Boolean,reflect:!0})],c.prototype,"inverted",2),c=d([r("sd-1-23-0-divider")],c);export{c as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./button.js";import"./icon.js";import{a as e,s as t,w as s}from"./event.js";import{x as i,i as a}from"./lit-element.js";import{c as o}from"./register-custom-element.js";import{g as r,s as n}from"./animation-registry.js";import{H as l}from"./slot.js";import{o as d}from"./if-defined.js";import{L as h}from"./solid-components2.js";import{g as c,l as p,u as m}from"./tabbable.js";import{S as u,n as y}from"./solid-element.js";import{e as f}from"./query.js";import{w}from"./watch.js";import{c as v}from"./component.styles.js";import{t as b}from"./classix.js";import"./spinner.js";import"./form.js";import"./static.js";import"./state.js";import"./query-assigned-elements.js";import"./request.js";import"./request2.js";function k(e){return e.charAt(0).toUpperCase()+e.slice(1)}let g=[];class x{constructor(e){this.tabDirection="forward",this.element=e,this.handleFocusIn=this.handleFocusIn.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleKeyUp=this.handleKeyUp.bind(this)}activate(){g.push(this.element),document.addEventListener("focusin",this.handleFocusIn),document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keyup",this.handleKeyUp)}deactivate(){g=g.filter((e=>e!==this.element)),document.removeEventListener("focusin",this.handleFocusIn),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp)}isActive(){return g[g.length-1]===this.element}checkFocus(){if(this.isActive()&&!this.element.matches(":focus-within")){const{start:e,end:t}=c(this.element),s="forward"===this.tabDirection?e:t;"function"==typeof(null==s?void 0:s.focus)&&s.focus({preventScroll:!0})}}handleFocusIn(){this.checkFocus()}handleKeyDown(e){"Tab"===e.key&&e.shiftKey&&(this.tabDirection="backward",requestAnimationFrame((()=>this.checkFocus())))}handleKeyUp(){this.tabDirection="forward"}}var j=Object.defineProperty,K=Object.getOwnPropertyDescriptor,D=(e,t,s,i)=>{for(var a,o=i>1?void 0:i?K(t,s):t,r=e.length-1;r>=0;r--)(a=e[r])&&(o=(i?a(t,s,o):a(o))||o);return i&&o&&j(t,s,o),o};let C=class extends u{constructor(){super(...arguments),this.hasSlotController=new l(this,"footer"),this.localize=new h(this),this.modal=new x(this),this.open=!1,this.label="",this.placement="end",this.contained=!1,this.noHeader=!1,this.handleDocumentKeyDown=e=>{this.open&&"Escape"===e.key&&(e.stopPropagation(),this.requestClose("keyboard"))}}firstUpdated(){this.drawer.hidden=!this.open,this.open&&(this.addOpenListeners(),this.contained||(this.modal.activate(),p(this)))}disconnectedCallback(){super.disconnectedCallback(),m(this)}requestClose(t){if(this.emit("sd-request-close",{cancelable:!0,detail:{source:t}}).defaultPrevented){const t=r(this,"drawer.denyClose",{dir:this.localize.dir()});e(this.panel,t.keyframes,t.options)}else this.hide()}addOpenListeners(){document.addEventListener("keydown",this.handleDocumentKeyDown)}removeOpenListeners(){document.removeEventListener("keydown",this.handleDocumentKeyDown)}async handleOpenChange(){if(this.open){this.emit("sd-show"),this.addOpenListeners(),this.originalTrigger=document.activeElement,this.contained||(this.modal.activate(),p(this));const s=this.querySelector("[autofocus]");s&&s.removeAttribute("autofocus"),await Promise.all([t(this.drawer),t(this.overlay)]),this.drawer.hidden=!1,requestAnimationFrame((()=>{this.emit("sd-initial-focus",{cancelable:!0}).defaultPrevented||(s?s.focus({preventScroll:!0}):this.panel.focus({preventScroll:!0})),s&&s.setAttribute("autofocus","")}));const i=r(this,`drawer.show${k(this.placement)}`,{dir:this.localize.dir()}),a=r(this,"drawer.overlay.show",{dir:this.localize.dir()});await Promise.all([e(this.panel,i.keyframes,i.options),e(this.overlay,a.keyframes,a.options)]),this.emit("sd-after-show")}else{this.emit("sd-hide"),this.removeOpenListeners(),this.contained||(this.modal.deactivate(),m(this)),await Promise.all([t(this.drawer),t(this.overlay)]);const s=r(this,`drawer.hide${k(this.placement)}`,{dir:this.localize.dir()}),i=r(this,"drawer.overlay.hide",{dir:this.localize.dir()});await Promise.all([e(this.overlay,i.keyframes,i.options).then((()=>{this.overlay.hidden=!0})),e(this.panel,s.keyframes,s.options).then((()=>{this.panel.hidden=!0}))]),this.drawer.hidden=!0,this.overlay.hidden=!1,this.panel.hidden=!1;const a=this.originalTrigger;"function"==typeof(null==a?void 0:a.focus)&&setTimeout((()=>a.focus())),this.emit("sd-after-hide")}}handleNoModalChange(){this.open&&!this.contained&&(this.modal.activate(),p(this)),this.open&&this.contained&&(this.modal.deactivate(),m(this))}async show(){if(!this.open)return this.open=!0,s(this,"sd-after-show")}async hide(){if(this.open)return this.open=!1,s(this,"sd-after-hide")}render(){return i`<div part="base" class="${b("top-0 start-0 w-full h-full pointer-events-none overflow-hidden",this.contained?"absolute":"fixed")}"><div part="overlay" class="${b("block top-0 left-0 right-0 bottom-0 bg-neutral-800/75 pointer-events-auto",this.contained?"absolute":"fixed")}" @click="${()=>this.requestClose("overlay")}" tabindex="-1"></div><div part="panel" class="${b("absolute flex flex-col z-10 max-w-full max-h-full bg-white shadow-lg overflow-auto pointer-events-auto focus:outline-none",{end:"top-0 end-0 bottom-auto start-auto w-[--width] h-full",start:"top-0 end-auto bottom-auto start-0 w-[--width] h-full"}[this.placement])}" role="dialog" aria-modal="true" aria-hidden="${this.open?"false":"true"}" aria-label="${this.label}" aria-labelledby="${d(this.noHeader?void 0:"title")}" tabindex="0">${this.noHeader?"":i`<header part="header" class="flex justify-between py-2 px-4 items-center flex-shrink-0" style="min-height:56px"><div part="title"><slot name="header" part="title" class="flex-auto text-xl m-0" id="title"></slot></div><div class="shrink-0 flex flex-wrap justify-end gap-1 ml-4 absolute top-2 right-2"><sd-1-
|
|
1
|
+
import"./button.js";import"./icon.js";import{a as e,s as t,w as s}from"./event.js";import{x as i,i as a}from"./lit-element.js";import{c as o}from"./register-custom-element.js";import{g as r,s as n}from"./animation-registry.js";import{H as l}from"./slot.js";import{o as d}from"./if-defined.js";import{L as h}from"./solid-components2.js";import{g as c,l as p,u as m}from"./tabbable.js";import{S as u,n as y}from"./solid-element.js";import{e as f}from"./query.js";import{w}from"./watch.js";import{c as v}from"./component.styles.js";import{t as b}from"./classix.js";import"./spinner.js";import"./form.js";import"./static.js";import"./state.js";import"./query-assigned-elements.js";import"./request.js";import"./request2.js";function k(e){return e.charAt(0).toUpperCase()+e.slice(1)}let g=[];class x{constructor(e){this.tabDirection="forward",this.element=e,this.handleFocusIn=this.handleFocusIn.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleKeyUp=this.handleKeyUp.bind(this)}activate(){g.push(this.element),document.addEventListener("focusin",this.handleFocusIn),document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keyup",this.handleKeyUp)}deactivate(){g=g.filter((e=>e!==this.element)),document.removeEventListener("focusin",this.handleFocusIn),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp)}isActive(){return g[g.length-1]===this.element}checkFocus(){if(this.isActive()&&!this.element.matches(":focus-within")){const{start:e,end:t}=c(this.element),s="forward"===this.tabDirection?e:t;"function"==typeof(null==s?void 0:s.focus)&&s.focus({preventScroll:!0})}}handleFocusIn(){this.checkFocus()}handleKeyDown(e){"Tab"===e.key&&e.shiftKey&&(this.tabDirection="backward",requestAnimationFrame((()=>this.checkFocus())))}handleKeyUp(){this.tabDirection="forward"}}var j=Object.defineProperty,K=Object.getOwnPropertyDescriptor,D=(e,t,s,i)=>{for(var a,o=i>1?void 0:i?K(t,s):t,r=e.length-1;r>=0;r--)(a=e[r])&&(o=(i?a(t,s,o):a(o))||o);return i&&o&&j(t,s,o),o};let C=class extends u{constructor(){super(...arguments),this.hasSlotController=new l(this,"footer"),this.localize=new h(this),this.modal=new x(this),this.open=!1,this.label="",this.placement="end",this.contained=!1,this.noHeader=!1,this.handleDocumentKeyDown=e=>{this.open&&"Escape"===e.key&&(e.stopPropagation(),this.requestClose("keyboard"))}}firstUpdated(){this.drawer.hidden=!this.open,this.open&&(this.addOpenListeners(),this.contained||(this.modal.activate(),p(this)))}disconnectedCallback(){super.disconnectedCallback(),m(this)}requestClose(t){if(this.emit("sd-request-close",{cancelable:!0,detail:{source:t}}).defaultPrevented){const t=r(this,"drawer.denyClose",{dir:this.localize.dir()});e(this.panel,t.keyframes,t.options)}else this.hide()}addOpenListeners(){document.addEventListener("keydown",this.handleDocumentKeyDown)}removeOpenListeners(){document.removeEventListener("keydown",this.handleDocumentKeyDown)}async handleOpenChange(){if(this.open){this.emit("sd-show"),this.addOpenListeners(),this.originalTrigger=document.activeElement,this.contained||(this.modal.activate(),p(this));const s=this.querySelector("[autofocus]");s&&s.removeAttribute("autofocus"),await Promise.all([t(this.drawer),t(this.overlay)]),this.drawer.hidden=!1,requestAnimationFrame((()=>{this.emit("sd-initial-focus",{cancelable:!0}).defaultPrevented||(s?s.focus({preventScroll:!0}):this.panel.focus({preventScroll:!0})),s&&s.setAttribute("autofocus","")}));const i=r(this,`drawer.show${k(this.placement)}`,{dir:this.localize.dir()}),a=r(this,"drawer.overlay.show",{dir:this.localize.dir()});await Promise.all([e(this.panel,i.keyframes,i.options),e(this.overlay,a.keyframes,a.options)]),this.emit("sd-after-show")}else{this.emit("sd-hide"),this.removeOpenListeners(),this.contained||(this.modal.deactivate(),m(this)),await Promise.all([t(this.drawer),t(this.overlay)]);const s=r(this,`drawer.hide${k(this.placement)}`,{dir:this.localize.dir()}),i=r(this,"drawer.overlay.hide",{dir:this.localize.dir()});await Promise.all([e(this.overlay,i.keyframes,i.options).then((()=>{this.overlay.hidden=!0})),e(this.panel,s.keyframes,s.options).then((()=>{this.panel.hidden=!0}))]),this.drawer.hidden=!0,this.overlay.hidden=!1,this.panel.hidden=!1;const a=this.originalTrigger;"function"==typeof(null==a?void 0:a.focus)&&setTimeout((()=>a.focus())),this.emit("sd-after-hide")}}handleNoModalChange(){this.open&&!this.contained&&(this.modal.activate(),p(this)),this.open&&this.contained&&(this.modal.deactivate(),m(this))}async show(){if(!this.open)return this.open=!0,s(this,"sd-after-show")}async hide(){if(this.open)return this.open=!1,s(this,"sd-after-hide")}render(){return i`<div part="base" class="${b("top-0 start-0 w-full h-full pointer-events-none overflow-hidden",this.contained?"absolute":"fixed")}"><div part="overlay" class="${b("block top-0 left-0 right-0 bottom-0 bg-neutral-800/75 pointer-events-auto",this.contained?"absolute":"fixed")}" @click="${()=>this.requestClose("overlay")}" tabindex="-1"></div><div part="panel" class="${b("absolute flex flex-col z-10 max-w-full max-h-full bg-white shadow-lg overflow-auto pointer-events-auto focus:outline-none",{end:"top-0 end-0 bottom-auto start-auto w-[--width] h-full",start:"top-0 end-auto bottom-auto start-0 w-[--width] h-full"}[this.placement])}" role="dialog" aria-modal="true" aria-hidden="${this.open?"false":"true"}" aria-label="${this.label}" aria-labelledby="${d(this.noHeader?void 0:"title")}" tabindex="0">${this.noHeader?"":i`<header part="header" class="flex justify-between py-2 px-4 items-center flex-shrink-0" style="min-height:56px"><div part="title"><slot name="header" part="title" class="flex-auto text-xl m-0" id="title"></slot></div><div class="shrink-0 flex flex-wrap justify-end gap-1 ml-4 absolute top-2 right-2"><sd-1-23-0-button variant="tertiary" size="lg" part="close-button" @click="${()=>this.requestClose("close-button")}"><sd-1-23-0-icon name="close" library="system"></sd-1-23-0-icon></sd-1-23-0-button></div></header>`}<div part="body" class="flex-auto block px-4"><slot></slot></div><footer part="footer" class="${b(this.hasSlotController.test("footer")?"text-left p-4":"hidden")}"><slot name="footer"></slot></footer></div></div>`}};C.styles=[u.styles,a`${v}:host{--width:25rem;display:contents}:host([contained]){z-index:initial}:host(:not([contained])){z-index:var(--sd-z-index-drawer)}[part=body]{-webkit-overflow-scrolling:touch;overflow-y:scroll;scrollbar-width:none}[part=body]::-webkit-scrollbar{width:0;height:0}`],D([f("[part=base]")],C.prototype,"drawer",2),D([f("[part=panel]")],C.prototype,"panel",2),D([f("[part=overlay]")],C.prototype,"overlay",2),D([y({type:Boolean,reflect:!0})],C.prototype,"open",2),D([y({attribute:"label",reflect:!0})],C.prototype,"label",2),D([y({reflect:!0})],C.prototype,"placement",2),D([y({type:Boolean,reflect:!0})],C.prototype,"contained",2),D([y({attribute:"no-header",type:Boolean})],C.prototype,"noHeader",2),D([w("open",{waitUntilFirstUpdate:!0})],C.prototype,"handleOpenChange",1),D([w("contained",{waitUntilFirstUpdate:!0})],C.prototype,"handleNoModalChange",1),C=D([o("sd-1-23-0-drawer")],C),n("drawer.showStart",{keyframes:[{opacity:0,translate:"-100%"},{opacity:1,translate:"0"}],rtlKeyframes:[{opacity:0,translate:"100%"},{opacity:1,translate:"0"}],options:{duration:250,easing:"ease"}}),n("drawer.hideStart",{keyframes:[{opacity:1,translate:"0"},{opacity:0,translate:"-100%"}],rtlKeyframes:[{opacity:1,translate:"0"},{opacity:0,translate:"100%"}],options:{duration:250,easing:"ease"}}),n("drawer.showEnd",{keyframes:[{opacity:0,translate:"100%"},{opacity:1,translate:"0"}],rtlKeyframes:[{opacity:0,translate:"-100%"},{opacity:1,translate:"0"}],options:{duration:250,easing:"ease"}}),n("drawer.hideEnd",{keyframes:[{opacity:1,translate:"0"},{opacity:0,translate:"100%"}],rtlKeyframes:[{opacity:1,translate:"0"},{opacity:0,translate:"-100%"}],options:{duration:250,easing:"ease"}}),n("drawer.denyClose",{keyframes:[{scale:1},{scale:1.01},{scale:1}],options:{duration:250}}),n("drawer.overlay.show",{keyframes:[{opacity:0},{opacity:1}],options:{duration:250}}),n("drawer.overlay.hide",{keyframes:[{opacity:1},{opacity:0}],options:{duration:250}});export{C as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./popup.js";import{w as e,s as t,a as n}from"./event.js";import{x as i,i as o}from"./lit-element.js";import{c as s}from"./register-custom-element.js";import{g as a,s as r}from"./animation-registry.js";import{s as d,g as p}from"./tabbable.js";import{L as h}from"./solid-components2.js";import{S as l,n as c}from"./solid-element.js";import{e as u}from"./query.js";import{w as m}from"./watch.js";import{c as g}from"./component.styles.js";import{t as y}from"./classix.js";var f=Object.defineProperty,w=Object.getOwnPropertyDescriptor,v=(e,t,n,i)=>{for(var o,s=i>1?void 0:i?w(t,n):t,a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i?o(t,n,s):o(s))||s);return i&&s&&f(t,n,s),s};let b=class extends l{constructor(){super(...arguments),this.localize=new h(this),this.open=!1,this.rounded=!1,this.placement="bottom-start",this.disabled=!1,this.stayOpenOnSelect=!1,this.distance=0,this.skidding=0,this.noAutoSize=!1,this.noFlip=!1,this.hoist=!1}connectedCallback(){super.connectedCallback(),this.handleMenuItemActivate=this.handleMenuItemActivate.bind(this),this.handlePanelSelect=this.handlePanelSelect.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleDocumentKeyDown=this.handleDocumentKeyDown.bind(this),this.handleDocumentMouseDown=this.handleDocumentMouseDown.bind(this),this.containingElement||(this.containingElement=this)}firstUpdated(){this.panel.hidden=!this.open,this.open&&(this.addOpenListeners(),this.popup.active=!0)}disconnectedCallback(){super.disconnectedCallback(),this.removeOpenListeners(),this.hide()}focusOnTrigger(){const e=this.trigger.assignedElements({flatten:!0})[0];"function"==typeof(null==e?void 0:e.focus)&&e.focus()}getMenu(){return this.panel.assignedElements({flatten:!0}).find((e=>"sd-menu"===e.tagName.toLowerCase()))}handleKeyDown(e){this.open&&"Escape"===e.key&&(e.stopPropagation(),this.hide(),this.focusOnTrigger())}handleDocumentKeyDown(e){var t;if("Tab"===e.key){if(this.open&&"sd-menu-item"===(null==(t=document.activeElement)?void 0:t.tagName.toLowerCase()))return e.preventDefault(),this.hide(),void this.focusOnTrigger();setTimeout((()=>{var e,t,n;const i=(null==(e=this.containingElement)?void 0:e.getRootNode())instanceof ShadowRoot?null==(n=null==(t=document.activeElement)?void 0:t.shadowRoot)?void 0:n.activeElement:document.activeElement;(!this.containingElement||(null==i?void 0:i.closest(this.containingElement.tagName.toLowerCase()))!==this.containingElement)&&this.hide()}))}}handleDocumentMouseDown(e){const t=e.composedPath();this.containingElement&&!t.includes(this.containingElement)&&this.hide()}handleMenuItemActivate(e){const t=e.target;d(t,this.panel)}handlePanelSelect(e){const t=e.target;!this.stayOpenOnSelect&&"sd-menu"===t.tagName.toLowerCase()&&(this.hide(),this.focusOnTrigger())}handleTriggerClick(){this.open?this.hide():this.show()}handleTriggerKeyDown(e){if("Escape"===e.key&&this.open)return e.stopPropagation(),this.focusOnTrigger(),void this.hide();if([" ","Enter"].includes(e.key))return e.preventDefault(),void this.handleTriggerClick();const t=this.getMenu();if(t){const n=t.defaultSlot.assignedElements({flatten:!0}),i=n[0],o=n[n.length-1];["ArrowDown","ArrowUp","Home","End"].includes(e.key)&&(e.preventDefault(),this.open||this.show(),n.length>0&&requestAnimationFrame((()=>{("ArrowDown"===e.key||"Home"===e.key)&&(t.setCurrentItem(i),i.focus()),("ArrowUp"===e.key||"End"===e.key)&&(t.setCurrentItem(o),o.focus())})))}}handleTriggerKeyUp(e){" "===e.key&&e.preventDefault()}handleTriggerSlotChange(){this.updateAccessibleTrigger()}updateAccessibleTrigger(){const e=this.trigger.assignedElements({flatten:!0}).find((e=>p(e).start));let t;if(e){switch(e.tagName.toLowerCase()){case"sd-1-
|
|
1
|
+
import"./popup.js";import{w as e,s as t,a as n}from"./event.js";import{x as i,i as o}from"./lit-element.js";import{c as s}from"./register-custom-element.js";import{g as a,s as r}from"./animation-registry.js";import{s as d,g as p}from"./tabbable.js";import{L as h}from"./solid-components2.js";import{S as l,n as c}from"./solid-element.js";import{e as u}from"./query.js";import{w as m}from"./watch.js";import{c as g}from"./component.styles.js";import{t as y}from"./classix.js";var f=Object.defineProperty,w=Object.getOwnPropertyDescriptor,v=(e,t,n,i)=>{for(var o,s=i>1?void 0:i?w(t,n):t,a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i?o(t,n,s):o(s))||s);return i&&s&&f(t,n,s),s};let b=class extends l{constructor(){super(...arguments),this.localize=new h(this),this.open=!1,this.rounded=!1,this.placement="bottom-start",this.disabled=!1,this.stayOpenOnSelect=!1,this.distance=0,this.skidding=0,this.noAutoSize=!1,this.noFlip=!1,this.hoist=!1}connectedCallback(){super.connectedCallback(),this.handleMenuItemActivate=this.handleMenuItemActivate.bind(this),this.handlePanelSelect=this.handlePanelSelect.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleDocumentKeyDown=this.handleDocumentKeyDown.bind(this),this.handleDocumentMouseDown=this.handleDocumentMouseDown.bind(this),this.containingElement||(this.containingElement=this)}firstUpdated(){this.panel.hidden=!this.open,this.open&&(this.addOpenListeners(),this.popup.active=!0)}disconnectedCallback(){super.disconnectedCallback(),this.removeOpenListeners(),this.hide()}focusOnTrigger(){const e=this.trigger.assignedElements({flatten:!0})[0];"function"==typeof(null==e?void 0:e.focus)&&e.focus()}getMenu(){return this.panel.assignedElements({flatten:!0}).find((e=>"sd-menu"===e.tagName.toLowerCase()))}handleKeyDown(e){this.open&&"Escape"===e.key&&(e.stopPropagation(),this.hide(),this.focusOnTrigger())}handleDocumentKeyDown(e){var t;if("Tab"===e.key){if(this.open&&"sd-menu-item"===(null==(t=document.activeElement)?void 0:t.tagName.toLowerCase()))return e.preventDefault(),this.hide(),void this.focusOnTrigger();setTimeout((()=>{var e,t,n;const i=(null==(e=this.containingElement)?void 0:e.getRootNode())instanceof ShadowRoot?null==(n=null==(t=document.activeElement)?void 0:t.shadowRoot)?void 0:n.activeElement:document.activeElement;(!this.containingElement||(null==i?void 0:i.closest(this.containingElement.tagName.toLowerCase()))!==this.containingElement)&&this.hide()}))}}handleDocumentMouseDown(e){const t=e.composedPath();this.containingElement&&!t.includes(this.containingElement)&&this.hide()}handleMenuItemActivate(e){const t=e.target;d(t,this.panel)}handlePanelSelect(e){const t=e.target;!this.stayOpenOnSelect&&"sd-menu"===t.tagName.toLowerCase()&&(this.hide(),this.focusOnTrigger())}handleTriggerClick(){this.open?this.hide():this.show()}handleTriggerKeyDown(e){if("Escape"===e.key&&this.open)return e.stopPropagation(),this.focusOnTrigger(),void this.hide();if([" ","Enter"].includes(e.key))return e.preventDefault(),void this.handleTriggerClick();const t=this.getMenu();if(t){const n=t.defaultSlot.assignedElements({flatten:!0}),i=n[0],o=n[n.length-1];["ArrowDown","ArrowUp","Home","End"].includes(e.key)&&(e.preventDefault(),this.open||this.show(),n.length>0&&requestAnimationFrame((()=>{("ArrowDown"===e.key||"Home"===e.key)&&(t.setCurrentItem(i),i.focus()),("ArrowUp"===e.key||"End"===e.key)&&(t.setCurrentItem(o),o.focus())})))}}handleTriggerKeyUp(e){" "===e.key&&e.preventDefault()}handleTriggerSlotChange(){this.updateAccessibleTrigger()}updateAccessibleTrigger(){const e=this.trigger.assignedElements({flatten:!0}).find((e=>p(e).start));let t;if(e){switch(e.tagName.toLowerCase()){case"sd-1-23-0-button":case"sd-1-23-0-icon-button":t=e.button;break;default:t=e}t.setAttribute("aria-haspopup","true"),t.setAttribute("aria-expanded",this.open?"true":"false")}}async show(){if(!this.open)return this.open=!0,e(this,"sd-after-show")}async hide(){if(this.open)return this.open=!1,e(this,"sd-after-hide")}reposition(){this.popup.reposition()}addOpenListeners(){this.panel.addEventListener("sd-activate",this.handleMenuItemActivate),this.panel.addEventListener("sd-select",this.handlePanelSelect),this.panel.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keydown",this.handleDocumentKeyDown),document.addEventListener("mousedown",this.handleDocumentMouseDown)}removeOpenListeners(){this.panel&&(this.panel.removeEventListener("sd-activate",this.handleMenuItemActivate),this.panel.removeEventListener("sd-select",this.handlePanelSelect),this.panel.removeEventListener("keydown",this.handleKeyDown)),document.removeEventListener("keydown",this.handleDocumentKeyDown),document.removeEventListener("mousedown",this.handleDocumentMouseDown)}async handleOpenChange(){if(this.disabled)this.open=!1;else if(this.updateAccessibleTrigger(),this.open){this.emit("sd-show"),this.addOpenListeners(),await t(this),this.panel.hidden=!1,this.popup.active=!0;const{keyframes:e,options:i}=a(this,"dropdown.show",{dir:this.localize.dir()});await n(this.popup.popup,e,i),this.emit("sd-after-show")}else{this.emit("sd-hide"),this.removeOpenListeners(),await t(this);const{keyframes:e,options:i}=a(this,"dropdown.hide",{dir:this.localize.dir()});await n(this.popup.popup,e,i),this.panel.hidden=!0,this.popup.active=!1,this.emit("sd-after-hide")}}render(){return i`<sd-1-23-0-popup part="base" id="dropdown" placement="${this.placement}" distance="${this.rounded&&this.distance<1?1:this.distance}" skidding="${this.skidding}" strategy="${this.hoist?"fixed":"absolute"}" ?flip="${!this.noFlip}" shift auto-size="vertical" auto-size-padding="10" ?active="${this.open}"><slot name="trigger" slot="anchor" part="trigger" class="block" @click="${this.handleTriggerClick}" @keydown="${this.handleTriggerKeyDown}" @keyup="${this.handleTriggerKeyUp}" @slotchange="${this.handleTriggerSlotChange}"></slot><slot part="panel" class="${y("shadow bg-white",this.open?"block pointer-events-auto":"pointer-events-none",this.rounded&&"rounded-md")}" aria-hidden="${this.open?"false":"true"}" aria-labelledby="dropdown"></slot></sd-1-23-0-popup>`}};b.styles=[l.styles,g,o`:host{display:inline-block}#dropdown::part(popup){z-index:var(--sd-z-index-dropdown)}#dropdown[data-current-placement^=top]::part(popup){transform-origin:bottom}#dropdown[data-current-placement^=bottom]::part(popup){transform-origin:top}#dropdown[data-current-placement^=left]::part(popup){transform-origin:right}#dropdown[data-current-placement^=right]::part(popup){transform-origin:left}:host(:not([no-auto-size])) ::slotted(:not([slot=trigger])){overflow:auto;max-width:var(--auto-size-available-width)!important;max-height:var(--auto-size-available-height)!important}`],v([u("#dropdown")],b.prototype,"popup",2),v([u("[part=trigger]")],b.prototype,"trigger",2),v([u("[part=panel]")],b.prototype,"panel",2),v([c({type:Boolean,reflect:!0})],b.prototype,"open",2),v([c({type:Boolean,reflect:!0})],b.prototype,"rounded",2),v([c({reflect:!0})],b.prototype,"placement",2),v([c({type:Boolean,reflect:!0})],b.prototype,"disabled",2),v([c({attribute:"stay-open-on-select",type:Boolean,reflect:!0})],b.prototype,"stayOpenOnSelect",2),v([c({attribute:!1})],b.prototype,"containingElement",2),v([c({type:Number})],b.prototype,"distance",2),v([c({type:Number})],b.prototype,"skidding",2),v([c({type:Boolean,reflect:!0,attribute:"no-auto-size"})],b.prototype,"noAutoSize",2),v([c({type:Boolean,reflect:!0,attribute:"no-flip"})],b.prototype,"noFlip",2),v([c({type:Boolean})],b.prototype,"hoist",2),v([m("open",{waitUntilFirstUpdate:!0})],b.prototype,"handleOpenChange",1),b=v([s("sd-1-23-0-dropdown")],b),r("dropdown.show",{keyframes:[{opacity:0,scale:.9},{opacity:1,scale:1}],options:{duration:100,easing:"ease"}}),r("dropdown.hide",{keyframes:[{opacity:1,scale:1},{opacity:0,scale:.9}],options:{duration:100,easing:"ease"}});export{b as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function e(e,
|
|
1
|
+
function e(e,n,i){return new Promise((r=>{if((null==i?void 0:i.duration)===1/0)throw new Error("Promise-based animations must be finite.");const a=e.animate(n,{...i,duration:t()?0:i.duration});a.addEventListener("cancel",r,{once:!0}),a.addEventListener("finish",r,{once:!0})}))}function n(e){return(e=e.toString().toLowerCase()).indexOf("ms")>-1?parseFloat(e):e.indexOf("s")>-1?1e3*parseFloat(e):parseFloat(e)}function t(){return window.matchMedia("(prefers-reduced-motion: reduce)").matches}function i(e){return Promise.all(e.getAnimations().map((e=>new Promise((n=>{const t=requestAnimationFrame(n);e.addEventListener("cancel",(()=>t),{once:!0}),e.addEventListener("finish",(()=>t),{once:!0}),e.cancel()})))))}function r(e,n){return e.map((e=>({...e,height:"auto"===e.height?`${n}px`:e.height})))}function a(e,n){return new Promise((t=>{e.addEventListener(n,(function i(r){r.target===e&&(e.removeEventListener(n,i),t())}))}))}export{e as a,r as b,n as c,t as p,i as s,a as w};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const t=new WeakMap,e=new WeakMap,i=new WeakMap,s=new WeakMap;class o{constructor(e,i){this.handleFormData=t=>{const e=this.options.disabled(this.host),i=this.options.name(this.host),s=this.options.value(this.host),o="sd-1-
|
|
1
|
+
const t=new WeakMap,e=new WeakMap,i=new WeakMap,s=new WeakMap;class o{constructor(e,i){this.handleFormData=t=>{const e=this.options.disabled(this.host),i=this.options.name(this.host),s=this.options.value(this.host),o="sd-1-23-0-button"===this.host.tagName.toLowerCase();!e&&!o&&"string"==typeof i&&i.length>0&&typeof s<"u"&&(Array.isArray(s)?s.forEach((e=>{t.formData.append(i,e.toString())})):t.formData.append(i,s.toString()))},this.handleFormSubmit=e=>{var i;const s=this.options.disabled(this.host),o=this.options.reportValidity;this.form&&!this.form.noValidate&&(null==(i=t.get(this.form))||i.forEach((t=>{this.setUserInteracted(t,!0)}))),this.form&&!this.form.noValidate&&!s&&!o(this.host)&&(e.preventDefault(),e.stopImmediatePropagation())},this.handleFormReset=()=>{this.options.setValue(this.host,this.options.defaultValue(this.host)),this.setUserInteracted(this.host,!1),s.set(this.host,[])},this.handleInteraction=t=>{const e=s.get(this.host);e.includes(t.type)||e.push(t.type),e.length===this.options.assumeInteractionOn.length&&this.setUserInteracted(this.host,!0)},(this.host=e).addController(this),this.options={form:t=>{if(t.hasAttribute("form")&&""!==t.getAttribute("form")){const e=t.getRootNode(),i=t.getAttribute("form");if(i)return e.getElementById(i)}return t.closest("form")},name:t=>t.name,value:t=>t.value,defaultValue:t=>t.defaultValue,disabled:t=>t.disabled??!1,reportValidity:t=>"function"!=typeof t.reportValidity||t.reportValidity(),setValue:(t,e)=>t.value=e,assumeInteractionOn:["sd-input"],...i}}hostConnected(){const t=this.options.form(this.host);t&&this.attachForm(t),s.set(this.host,[]),this.options.assumeInteractionOn.forEach((t=>{this.host.addEventListener(t,this.handleInteraction)}))}hostDisconnected(){this.detachForm(),s.delete(this.host),this.options.assumeInteractionOn.forEach((t=>{this.host.removeEventListener(t,this.handleInteraction)}))}hostUpdated(){var t;const e=this.options.form(this.host);e||this.detachForm(),e&&this.form!==e&&(this.detachForm(),this.attachForm(e)),this.host.hasUpdated&&this.setValidity(null==(t=this.host)?void 0:t.validity.valid)}attachForm(i){i?(this.form=i,t.has(this.form)?t.get(this.form).add(this.host):t.set(this.form,new Set([this.host])),this.form.addEventListener("formdata",this.handleFormData),this.form.addEventListener("submit",this.handleFormSubmit),this.form.addEventListener("reset",this.handleFormReset),e.has(this.form)||(e.set(this.form,this.form.reportValidity),this.form.reportValidity=()=>this.reportFormValidity())):this.form=void 0}detachForm(){var i;this.form&&(null==(i=t.get(this.form))||i.delete(this.host),this.form.removeEventListener("formdata",this.handleFormData),this.form.removeEventListener("submit",this.handleFormSubmit),this.form.removeEventListener("reset",this.handleFormReset),e.has(this.form)&&(this.form.reportValidity=e.get(this.form),e.delete(this.form))),this.form=void 0}reportFormValidity(){if(this.form&&!this.form.noValidate){const t=this.form.querySelectorAll("*");for(const e of t)if("function"==typeof e.reportValidity&&!e.reportValidity())return!1}return!0}setUserInteracted(t,e){i.set(t,e),t.requestUpdate()}doAction(t,e){if(this.form){const i=document.createElement("button");i.type=t,i.style.position="absolute",i.style.width="0",i.style.height="0",i.style.clipPath="inset(50%)",i.style.overflow="hidden",i.style.whiteSpace="nowrap",e&&(i.name=e.name,i.value=e.value,["formaction","formenctype","formmethod","formnovalidate","formtarget"].forEach((t=>{e.hasAttribute(t)&&i.setAttribute(t,e.getAttribute(t))}))),this.form.append(i),i.click(),i.remove()}}getForm(){return this.form??null}reset(t){this.doAction("reset",t)}submit(t){this.doAction("submit",t)}setValidity(t){var e;const s=this.host,o=!!i.get(s),r=!!s.required;null!=(e=this.form)&&e.noValidate?(s.removeAttribute("data-required"),s.removeAttribute("data-optional"),s.removeAttribute("data-invalid"),s.removeAttribute("data-valid"),s.removeAttribute("data-user-invalid"),s.removeAttribute("data-user-valid")):(s.toggleAttribute("data-required",r),s.toggleAttribute("data-optional",!r),s.toggleAttribute("data-invalid",!t),s.toggleAttribute("data-valid",t),s.toggleAttribute("data-user-invalid",!t&&o),s.toggleAttribute("data-user-valid",t&&o))}updateValidity(){const t=this.host;this.setValidity(null==t?void 0:t.validity.valid)}emitInvalidEvent(t){const e=new CustomEvent("sd-invalid",{bubbles:!1,composed:!1,cancelable:!0,detail:{}});t||e.preventDefault(),this.host.dispatchEvent(e)||null==t||t.preventDefault()}}const r=Object.freeze({badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:!0,valueMissing:!1}),a=Object.freeze({...r,valid:!1,valueMissing:!0}),h=Object.freeze({...r,valid:!1,customError:!0});export{o as F,a,h as c,r as v};
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import{T as t,w as e,x as r,i as s}from"./lit-element.js";import{c as i}from"./register-custom-element.js";import{w as o,u as
|
|
1
|
+
import{T as t,w as e,x as r,i as s}from"./lit-element.js";import{c as i}from"./register-custom-element.js";import{w as o,u as a,g as l}from"./solid-components2.js";import{S as n,n as c}from"./solid-element.js";import{r as h}from"./state.js";import{requestIcon as u}from"./request.js";import{w as p}from"./watch.js";import{c as d}from"./component.styles.js";
|
|
2
2
|
/**
|
|
3
3
|
* @license
|
|
4
4
|
* Copyright 2017 Google LLC
|
|
5
5
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
6
|
-
*/
|
|
6
|
+
*/const m={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},g=t=>(...e)=>({_$litDirective$:t,values:e});class b{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,r){this._$Ct=t,this._$AM=e,this._$Ci=r}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}}
|
|
7
7
|
/**
|
|
8
8
|
* @license
|
|
9
9
|
* Copyright 2017 Google LLC
|
|
10
10
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
11
|
-
*/class v extends
|
|
11
|
+
*/class v extends b{constructor(e){if(super(e),this.et=t,e.type!==m.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(r){if(r===t||null==r)return this.vt=void 0,this.et=r;if(r===e)return r;if("string"!=typeof r)throw Error(this.constructor.directiveName+"() called with a non-string value");if(r===this.et)return this.vt;this.et=r;const s=[r];return s.raw=s,this.vt={_$litType$:this.constructor.resultType,strings:s,values:[]}}}v.directiveName="unsafeHTML",v.resultType=1;
|
|
12
12
|
/**
|
|
13
13
|
* @license
|
|
14
14
|
* Copyright 2017 Google LLC
|
|
15
15
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
16
16
|
*/
|
|
17
|
-
class
|
|
17
|
+
class y extends v{}y.directiveName="unsafeSVG",y.resultType=2;const f=g(y);var T=Object.defineProperty,w=Object.getOwnPropertyDescriptor,A=(t,e,r,s)=>{for(var i,o=s>1?void 0:s?w(e,r):e,a=t.length-1;a>=0;a--)(i=t[a])&&(o=(s?i(e,r,o):i(o))||o);return s&&o&&T(e,r,o),o};let _,$=class extends n{constructor(){super(...arguments),this.svg="",this.label="",this.library="default",this.color="currentColor"}connectedCallback(){super.connectedCallback(),o(this)}firstUpdated(){this.setIcon()}disconnectedCallback(){super.disconnectedCallback(),a(this)}getUrl(){const t=l(this.library);return this.name&&t?t.resolver(this.name):this.src}handleLabelChange(){"string"==typeof this.label&&this.label.length>0?(this.setAttribute("role","img"),this.setAttribute("aria-label",this.label),this.removeAttribute("aria-hidden")):(this.removeAttribute("role"),this.removeAttribute("aria-label"),this.setAttribute("aria-hidden","true"))}async setIcon(){var t;const e=l(this.library),r=this.getUrl();if(_||(_=new DOMParser),r)try{const s=await u(r);if(r===this.getUrl())if(s.ok){const r=_.parseFromString(s.svg,"text/html").body.querySelector("svg");null!==r?(null==(t=null==e?void 0:e.mutator)||t.call(e,r),this.svg=r.outerHTML,this.emit("sd-load")):(this.svg="",this.emit("sd-error"))}else this.svg="",this.emit("sd-error")}catch{this.emit("sd-error")}else this.svg.length>0&&(this.svg="")}render(){return r`${f(this.svg)}`}};$.styles=[d,s`:host{display:inline-block;width:1em;height:1em;box-sizing:content-box!important}svg{display:block;height:100%;width:100%}:host([color=primary]) svg{color:rgb(var(--sd-color-primary,0 53 142) / var(--tw-text-opacity,1))}// text-primary :host([color=white]) svg{color:rgb(var(--sd-color-white,255 255 255) / var(--tw-text-opacity,1))}`],A([h()],$.prototype,"svg",2),A([c({reflect:!0})],$.prototype,"name",2),A([c()],$.prototype,"src",2),A([c()],$.prototype,"label",2),A([c({reflect:!0})],$.prototype,"library",2),A([c({reflect:!0})],$.prototype,"color",2),A([p("label")],$.prototype,"handleLabelChange",1),A([p(["name","src","library"])],$.prototype,"setIcon",1),$=A([i("sd-1-23-0-icon")],$);const j=Object.freeze(Object.defineProperty({__proto__:null,get default(){return $}},Symbol.toStringTag,{value:"Module"}));export{j as a,g as e,b as i,m as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as t}from"./register-custom-element.js";import{x as e}from"./lit-element.js";import{S as r,n as s}from"./solid-element.js";import{requestInclude as o}from"./request2.js";import{w as i}from"./watch.js";import c from"./include.styles.js";import"./component.styles.js";var a=Object.defineProperty,l=Object.getOwnPropertyDescriptor,n=(t,e,r,s)=>{for(var o,i=s>1?void 0:s?l(e,r):e,c=t.length-1;c>=0;c--)(o=t[c])&&(i=(s?o(e,r,i):o(i))||i);return s&&i&&a(e,r,i),i};let p=class extends r{constructor(){super(...arguments),this.mode="cors",this.allowScripts=!1}executeScript(t){const e=document.createElement("script");[...t.attributes].forEach((t=>e.setAttribute(t.name,t.value))),e.textContent=t.textContent,t.parentNode.replaceChild(e,t)}async handleSrcChange(){try{const t=this.src,e=await o(t,this.mode);if(t!==this.src)return;if(!e.ok)return void this.emit("sd-error",{detail:{status:e.status}});this.innerHTML=e.html,this.allowScripts&&[...this.querySelectorAll("script")].forEach((t=>this.executeScript(t))),this.emit("sd-load")}catch{this.emit("sd-error",{detail:{status:-1}})}}render(){return e`<slot></slot>`}};p.styles=c,n([s()],p.prototype,"src",2),n([s()],p.prototype,"mode",2),n([s({attribute:"allow-scripts",type:Boolean})],p.prototype,"allowScripts",2),n([i("src")],p.prototype,"handleSrcChange",1),p=n([t("sd-1-
|
|
1
|
+
import{c as t}from"./register-custom-element.js";import{x as e}from"./lit-element.js";import{S as r,n as s}from"./solid-element.js";import{requestInclude as o}from"./request2.js";import{w as i}from"./watch.js";import c from"./include.styles.js";import"./component.styles.js";var a=Object.defineProperty,l=Object.getOwnPropertyDescriptor,n=(t,e,r,s)=>{for(var o,i=s>1?void 0:s?l(e,r):e,c=t.length-1;c>=0;c--)(o=t[c])&&(i=(s?o(e,r,i):o(i))||i);return s&&i&&a(e,r,i),i};let p=class extends r{constructor(){super(...arguments),this.mode="cors",this.allowScripts=!1}executeScript(t){const e=document.createElement("script");[...t.attributes].forEach((t=>e.setAttribute(t.name,t.value))),e.textContent=t.textContent,t.parentNode.replaceChild(e,t)}async handleSrcChange(){try{const t=this.src,e=await o(t,this.mode);if(t!==this.src)return;if(!e.ok)return void this.emit("sd-error",{detail:{status:e.status}});this.innerHTML=e.html,this.allowScripts&&[...this.querySelectorAll("script")].forEach((t=>this.executeScript(t))),this.emit("sd-load")}catch{this.emit("sd-error",{detail:{status:-1}})}}render(){return e`<slot></slot>`}};p.styles=c,n([s()],p.prototype,"src",2),n([s()],p.prototype,"mode",2),n([s({attribute:"allow-scripts",type:Boolean})],p.prototype,"allowScripts",2),n([i("src")],p.prototype,"handleSrcChange",1),p=n([t("sd-1-23-0-include")],p);export{p as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const t=".sd-interactive--reset{all:unset;outline:revert}.sd-interactive{--tw-text-opacity:1;color:rgb(var(--sd-color-primary,0 53 142)/var(--tw-text-opacity));cursor:pointer;text-decoration-line:none;transition-duration:.15s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1)}.sd-interactive:hover:not([disabled]){--tw-text-opacity:1;color:rgb(var(--sd-color-primary-500,70 109 175)/var(--tw-text-opacity))}.sd-interactive:active:not([disabled]){--tw-text-opacity:1;color:rgb(var(--sd-color-primary-800,5 21 48)/var(--tw-text-opacity))}.sd-interactive:focus-visible{outline-color:rgb(var(--sd-color-primary,0 53 142)/1);outline-offset:2px;outline-style:solid;outline-width:2px}.sd-interactive--inverted{--tw-text-opacity:1;color:rgb(var(--sd-color-white,255 255 255)/var(--tw-text-opacity))}.sd-interactive--inverted:hover:not([disabled]){--tw-text-opacity:1;color:rgb(var(--sd-color-primary-200,224 233 243)/var(--tw-text-opacity))}.sd-interactive--inverted:active:not([disabled]){--tw-text-opacity:1;color:rgb(var(--sd-color-primary-400,153 171 208)/var(--tw-text-opacity))}.sd-interactive--inverted:focus-visible{outline-color:rgb(var(--sd-color-white,255 255 255)/1);outline-offset:2px;outline-style:solid;outline-width:2px}.sd-interactive--disabled,.sd-interactive[disabled]{cursor:not-allowed}.sd-interactive--disabled,.sd-interactive--disabled:active:not([disabled]),.sd-interactive--disabled:hover:not([disabled]),.sd-interactive[disabled],.sd-interactive[disabled]:active:not([disabled]),.sd-interactive[disabled]:hover:not([disabled]){--tw-text-opacity:1;color:rgb(var(--sd-color-neutral-600,136 136 136)/var(--tw-text-opacity))}\n";export{t as I};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{x as t,i as e}from"./lit-element.js";import{c as s}from"./register-custom-element.js";import{H as i}from"./slot.js";import{o}from"./if-defined.js";import{S as r,n as l}from"./solid-element.js";import{e as n}from"./query.js";import{t as a}from"./classix.js";var h=Object.defineProperty,d=Object.getOwnPropertyDescriptor,m=(t,e,s,i)=>{for(var o,r=i>1?void 0:i?d(e,s):e,l=t.length-1;l>=0;l--)(o=t[l])&&(r=(i?o(e,s,r):o(r))||r);return i&&r&&h(e,s,r),r};let f=class extends r{constructor(){super(...arguments),this.hasSlotController=new i(this,"[default]","icon-left","icon-right"),this.size="inherit",this.inverted=!1,this.standalone=!1,this.href=""}handleBlur(){this.emit("sd-blur")}handleFocus(){this.emit("sd-focus")}focus(t){this.button.focus(t)}blur(){this.button.blur()}render(){const e={label:this.hasSlotController.test("[default]"),"icon-left":this.hasSlotController.test("icon-left"),"icon-right":this.hasSlotController.test("icon-right")};return t`<a part="base" class="${a("inline",this.href?"cursor-pointer":"",{sm:"text-sm",lg:"text-base",inherit:""}[this.size],{disabled:this.inverted?"text-neutral-600":"text-neutral-500",enabled:this.inverted?"text-white hover:text-primary-200 active:text-primary-400 focus-visible:focus-outline-inverted":" text-primary hover:text-primary-500 active:text-primary-800 focus-visible:focus-outline"}[this.href?"enabled":"disabled"],this.standalone&&"flex items-start")}" href="${o(this.href||void 0)}" target="${o(this.target||void 0)}" download="${o(this.download||void 0)}" rel="${o(this.target?"noreferrer noopener":void 0)}" aria-disabled="${this.href?"false":"true"}" tabindex="${this.href?"0":"-1"}" @blur="${this.handleBlur}" @focus="${this.handleFocus}"><slot name="icon-left" part="icon-left" class="${a("inline",e["icon-left"]&&(this.standalone?{sm:"mr-1",lg:"mr-2",inherit:"mr-[0.5em]"}[this.size]:"mr-[0.25em]"))}"></slot><span part="label" class="inline underline underline-offset-2"><slot></slot></span><slot name="icon-right" part="icon-right" class="${a("inline",e["icon-right"]&&(this.standalone?{sm:"ml-1",lg:"ml-2",inherit:"ml-[0.5em]"}[this.size]:"ml-[0.25em]"))}"></slot></a>`}};f.styles=[r.styles,e`::slotted(sd-1-
|
|
1
|
+
import{x as t,i as e}from"./lit-element.js";import{c as s}from"./register-custom-element.js";import{H as i}from"./slot.js";import{o}from"./if-defined.js";import{S as r,n as l}from"./solid-element.js";import{e as n}from"./query.js";import{t as a}from"./classix.js";var h=Object.defineProperty,d=Object.getOwnPropertyDescriptor,m=(t,e,s,i)=>{for(var o,r=i>1?void 0:i?d(e,s):e,l=t.length-1;l>=0;l--)(o=t[l])&&(r=(i?o(e,s,r):o(r))||r);return i&&r&&h(e,s,r),r};let f=class extends r{constructor(){super(...arguments),this.hasSlotController=new i(this,"[default]","icon-left","icon-right"),this.size="inherit",this.inverted=!1,this.standalone=!1,this.href=""}handleBlur(){this.emit("sd-blur")}handleFocus(){this.emit("sd-focus")}focus(t){this.button.focus(t)}blur(){this.button.blur()}render(){const e={label:this.hasSlotController.test("[default]"),"icon-left":this.hasSlotController.test("icon-left"),"icon-right":this.hasSlotController.test("icon-right")};return t`<a part="base" class="${a("inline",this.href?"cursor-pointer":"",{sm:"text-sm",lg:"text-base",inherit:""}[this.size],{disabled:this.inverted?"text-neutral-600":"text-neutral-500",enabled:this.inverted?"text-white hover:text-primary-200 active:text-primary-400 focus-visible:focus-outline-inverted":" text-primary hover:text-primary-500 active:text-primary-800 focus-visible:focus-outline"}[this.href?"enabled":"disabled"],this.standalone&&"flex items-start")}" href="${o(this.href||void 0)}" target="${o(this.target||void 0)}" download="${o(this.download||void 0)}" rel="${o(this.target?"noreferrer noopener":void 0)}" aria-disabled="${this.href?"false":"true"}" tabindex="${this.href?"0":"-1"}" @blur="${this.handleBlur}" @focus="${this.handleFocus}"><slot name="icon-left" part="icon-left" class="${a("inline",e["icon-left"]&&(this.standalone?{sm:"mr-1",lg:"mr-2",inherit:"mr-[0.5em]"}[this.size]:"mr-[0.25em]"))}"></slot><span part="label" class="inline underline underline-offset-2"><slot></slot></span><slot name="icon-right" part="icon-right" class="${a("inline",e["icon-right"]&&(this.standalone?{sm:"ml-1",lg:"ml-2",inherit:"ml-[0.5em]"}[this.size]:"ml-[0.25em]"))}"></slot></a>`}};f.styles=[r.styles,e`::slotted(sd-1-23-0-icon){font-size:1.25em;margin-bottom:-.25em}:host([size=sm][standalone]) ::slotted(sd-1-23-0-icon){font-size:1rem}:host([size=lg][standalone]) ::slotted(sd-1-23-0-icon){font-size:1.5rem}`],m([n("a")],f.prototype,"button",2),m([l({reflect:!0})],f.prototype,"size",2),m([l({type:Boolean,reflect:!0})],f.prototype,"inverted",2),m([l({type:Boolean,reflect:!0})],f.prototype,"standalone",2),m([l()],f.prototype,"href",2),m([l()],f.prototype,"target",2),m([l()],f.prototype,"download",2),f=m([s("sd-1-23-0-link")],f);export{f as default};
|
|
@@ -3,4 +3,4 @@ import{i as t}from"./lit-element.js";import{H as e}from"./slot.js";import{s as i
|
|
|
3
3
|
* @license
|
|
4
4
|
* Copyright 2017 Google LLC
|
|
5
5
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
6
|
-
*/var d=Object.defineProperty,h=Object.getOwnPropertyDescriptor,p=(t,e,i,s)=>{for(var r,o=s>1?void 0:s?h(e,i):e,l=t.length-1;l>=0;l--)(r=t[l])&&(o=(s?r(e,i,o):r(o))||o);return s&&o&&d(e,i,o),o};let c=class extends o{constructor(){super(...arguments),this.hasSlotController=new e(this,"[default]","description","children"),this.href="",this.current=!1,this.disabled=!1,this.size="base",this.vertical=!1,this.chevron=!1,this.indented=!1,this.relaxed=!1,this.divider=!1,this.open=!1}isButton(){return!this.href&&!this.hasSlotController.test("children")}isLink(){return!!this.href}isAccordion(){return!this.href&&this.hasSlotController.test("children")}handleClickButton(t){this.disabled&&(t.preventDefault(),t.stopPropagation())}handleClickSummary(t){t.preventDefault(),t.stopPropagation(),this.disabled||(this.open?this.hideDetails():this.showDetails())}hideDetails(){this.open=!1,this.emit("sd-hide",{cancelable:!0})}showDetails(){this.open=!0,this.emit("sd-show",{cancelable:!0})}calculatePaddingX(){return this.relaxed&&this.indented?"pl-8 pr-4":this.relaxed?"px-4":this.indented?"pl-4":""}render(){const t=this.isLink(),e=this.isButton(),o=this.isAccordion(),l=(this.hasSlotController.test("[default]"),this.hasSlotController.test("main"),this.hasSlotController.test("description")),a=this.hasSlotController.test("children"),d=t?i`a`:o?i`summary`:i`button`,h=this.vertical?"pb-3":"pb-2",p=s`<${d} part="base" class="${n("hover:bg-neutral-200 group transition-all min-h-[48px] cursor-pointer relative focus-visible:focus-outline",{base:"text-base",lg:"text-lg",sm:"text-[14px]"}[this.size],this.disabled?"text-neutral-500 pointer-events-none":"text-primary",o?"flex flex-col":"inline-block w-full",this.divider&&this.vertical&&"mt-[1px]",this.vertical?"px-8":"px-4")}" aria-controls="${r(o?"navigation-item-details":void 0)}" aria-current="${r(this.current?"page":void 0)}" aria-disabled="${this.disabled}" ?disabled="${r(e?this.disabled:void 0)}" href="${r(this.href||void 0)}" target="${r(t?this.target:void 0)}" download="${r(t?this.download:void 0)}" rel="${r(t&&this.target?"noreferrer noopener":void 0)}" role="${t?"link":"button"}" tabindex="${this.disabled?"-1":"0"}" @click="${o?this.handleClickSummary:e?this.handleClickButton:void 0}"><div class="${n("absolute w-full left-0 top-0 pointer-events-none transition-all duration-150",this.vertical?"border-l-4 h-[calc(100%-8px)] top-1 group-hover:h-full group-hover:top-0":"border-b-4 h-full",this.current?"border-accent":"border-transparent",this.disabled&&"border-neutral-500")}"></div><span class="${n("relative pt-3 inline-flex justify-between items-center",o?"grow":"w-full",l?"pb-1":h,this.calculatePaddingX())}">${this.divider&&this.vertical?s`<sd-1-
|
|
6
|
+
*/var d=Object.defineProperty,h=Object.getOwnPropertyDescriptor,p=(t,e,i,s)=>{for(var r,o=s>1?void 0:s?h(e,i):e,l=t.length-1;l>=0;l--)(r=t[l])&&(o=(s?r(e,i,o):r(o))||o);return s&&o&&d(e,i,o),o};let c=class extends o{constructor(){super(...arguments),this.hasSlotController=new e(this,"[default]","description","children"),this.href="",this.current=!1,this.disabled=!1,this.size="base",this.vertical=!1,this.chevron=!1,this.indented=!1,this.relaxed=!1,this.divider=!1,this.open=!1}isButton(){return!this.href&&!this.hasSlotController.test("children")}isLink(){return!!this.href}isAccordion(){return!this.href&&this.hasSlotController.test("children")}handleClickButton(t){this.disabled&&(t.preventDefault(),t.stopPropagation())}handleClickSummary(t){t.preventDefault(),t.stopPropagation(),this.disabled||(this.open?this.hideDetails():this.showDetails())}hideDetails(){this.open=!1,this.emit("sd-hide",{cancelable:!0})}showDetails(){this.open=!0,this.emit("sd-show",{cancelable:!0})}calculatePaddingX(){return this.relaxed&&this.indented?"pl-8 pr-4":this.relaxed?"px-4":this.indented?"pl-4":""}render(){const t=this.isLink(),e=this.isButton(),o=this.isAccordion(),l=(this.hasSlotController.test("[default]"),this.hasSlotController.test("main"),this.hasSlotController.test("description")),a=this.hasSlotController.test("children"),d=t?i`a`:o?i`summary`:i`button`,h=this.vertical?"pb-3":"pb-2",p=s`<${d} part="base" class="${n("hover:bg-neutral-200 group transition-all min-h-[48px] cursor-pointer relative focus-visible:focus-outline",{base:"text-base",lg:"text-lg",sm:"text-[14px]"}[this.size],this.disabled?"text-neutral-500 pointer-events-none":"text-primary",o?"flex flex-col":"inline-block w-full",this.divider&&this.vertical&&"mt-[1px]",this.vertical?"px-8":"px-4")}" aria-controls="${r(o?"navigation-item-details":void 0)}" aria-current="${r(this.current?"page":void 0)}" aria-disabled="${this.disabled}" ?disabled="${r(e?this.disabled:void 0)}" href="${r(this.href||void 0)}" target="${r(t?this.target:void 0)}" download="${r(t?this.download:void 0)}" rel="${r(t&&this.target?"noreferrer noopener":void 0)}" role="${t?"link":"button"}" tabindex="${this.disabled?"-1":"0"}" @click="${o?this.handleClickSummary:e?this.handleClickButton:void 0}"><div class="${n("absolute w-full left-0 top-0 pointer-events-none transition-all duration-150",this.vertical?"border-l-4 h-[calc(100%-8px)] top-1 group-hover:h-full group-hover:top-0":"border-b-4 h-full",this.current?"border-accent":"border-transparent",this.disabled&&"border-neutral-500")}"></div><span class="${n("relative pt-3 inline-flex justify-between items-center",o?"grow":"w-full",l?"pb-1":h,this.calculatePaddingX())}">${this.divider&&this.vertical?s`<sd-1-23-0-divider part="divider" class="${n("w-full transition-all absolute -top-[1px] left-0",this.calculatePaddingX())}"></sd-1-23-0-divider>`:""} <span class="inline-flex items-center flex-auto"><slot part="content" class="inline"></slot></span>${(this.chevron||a)&&this.vertical?s`<sd-1-23-0-icon name="chevron-down" part="chevron" library="system" color="currentColor" class="${n("h-6 w-6 ml-2 transition-all",o?this.open?"rotate-180":"rotate-0":"rotate-[270deg]")}"></sd-1-23-0-icon>`:""} </span>${l&&this.vertical?s`<slot name="description" part="description" class="${n("inline-block text-sm text-left text-black",o?"grow":"w-full",h,this.calculatePaddingX())}"></slot>`:""}</${d}>`;return o?s`<details id="navigation-item-details" ?open="${this.open}" class="relative flex">${p}<slot name="children"></slot></details>`:s`${p}`}};var u;c.styles=[a,o.styles,t`:host{box-sizing:border-box;position:relative;display:inline-block}:host([vertical]){display:block}details summary::-webkit-details-marker{display:none}`],p([l({reflect:!0})],c.prototype,"href",2),p([l()],c.prototype,"target",2),p([l()],c.prototype,"download",2),p([l({type:Boolean,reflect:!0})],c.prototype,"current",2),p([l({type:Boolean,reflect:!0})],c.prototype,"disabled",2),p([l({reflect:!0})],c.prototype,"size",2),p([l({type:Boolean,reflect:!0})],c.prototype,"vertical",2),p([l({type:Boolean,reflect:!0})],c.prototype,"chevron",2),p([l({type:Boolean,reflect:!0})],c.prototype,"indented",2),p([l({type:Boolean,reflect:!0})],c.prototype,"relaxed",2),p([l({type:Boolean,reflect:!0})],c.prototype,"divider",2),p([l({type:Boolean,reflect:!0})],c.prototype,"open",2),c=p([(u="sd-1-23-0-navigation-item",(t,e)=>{void 0!==e?e.addInitializer((()=>{customElements.define(u,t)})):customElements.define(u,t)})],c);export{c as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{x as t,i as e}from"./lit-element.js";import{c as n}from"./register-custom-element.js";import{S as o,n as i}from"./solid-element.js";import{e as r}from"./query.js";import{c as a}from"./component.styles.js";import{t as s}from"./classix.js";const l=Math.min,c=Math.max,f=Math.round,p=Math.floor,h=t=>({x:t,y:t}),u={left:"right",right:"left",bottom:"top",top:"bottom"},d={start:"end",end:"start"};function m(t,e,n){return c(t,l(e,n))}function y(t,e){return"function"==typeof t?t(e):t}function g(t){return t.split("-")[0]}function w(t){return t.split("-")[1]}function b(t){return"x"===t?"y":"x"}function v(t){return"y"===t?"height":"width"}function x(t){return["top","bottom"].includes(g(t))?"y":"x"}function P(t){return b(x(t))}function E(t){return t.replace(/start|end/g,(t=>d[t]))}function z(t){return t.replace(/left|right|bottom|top/g,(t=>u[t]))}function R(t){return"number"!=typeof t?function(t){return{top:0,right:0,bottom:0,left:0,...t}}(t):{top:t,right:t,bottom:t,left:t}}function S(t){return{...t,top:t.y,left:t.x,right:t.x+t.width,bottom:t.y+t.height}}function T(t,e,n){let{reference:o,floating:i}=t;const r=x(e),a=P(e),s=v(a),l=g(e),c="y"===r,f=o.x+o.width/2-i.width/2,p=o.y+o.height/2-i.height/2,h=o[s]/2-i[s]/2;let u;switch(l){case"top":u={x:f,y:o.y-i.height};break;case"bottom":u={x:f,y:o.y+o.height};break;case"right":u={x:o.x+o.width,y:p};break;case"left":u={x:o.x-i.width,y:p};break;default:u={x:o.x,y:o.y}}switch(w(e)){case"start":u[a]-=h*(n&&c?-1:1);break;case"end":u[a]+=h*(n&&c?-1:1)}return u}async function L(t,e){var n;void 0===e&&(e={});const{x:o,y:i,platform:r,rects:a,elements:s,strategy:l}=t,{boundary:c="clippingAncestors",rootBoundary:f="viewport",elementContext:p="floating",altBoundary:h=!1,padding:u=0}=y(e,t),d=R(u),m=s[h?"floating"===p?"reference":"floating":p],g=S(await r.getClippingRect({element:null==(n=await(null==r.isElement?void 0:r.isElement(m)))||n?m:m.contextElement||await(null==r.getDocumentElement?void 0:r.getDocumentElement(s.floating)),boundary:c,rootBoundary:f,strategy:l})),w="floating"===p?{...a.floating,x:o,y:i}:a.reference,b=await(null==r.getOffsetParent?void 0:r.getOffsetParent(s.floating)),v=await(null==r.isElement?void 0:r.isElement(b))&&await(null==r.getScale?void 0:r.getScale(b))||{x:1,y:1},x=S(r.convertOffsetParentRelativeRectToViewportRelativeRect?await r.convertOffsetParentRelativeRectToViewportRelativeRect({rect:w,offsetParent:b,strategy:l}):w);return{top:(g.top-x.top+d.top)/v.y,bottom:(x.bottom-g.bottom+d.bottom)/v.y,left:(g.left-x.left+d.left)/v.x,right:(x.right-g.right+d.right)/v.x}}const A=function(t){return void 0===t&&(t=0),{name:"offset",options:t,async fn(e){const{x:n,y:o}=e,i=await async function(t,e){const{placement:n,platform:o,elements:i}=t,r=await(null==o.isRTL?void 0:o.isRTL(i.floating)),a=g(n),s=w(n),l="y"===x(n),c=["left","top"].includes(a)?-1:1,f=r&&l?-1:1,p=y(e,t);let{mainAxis:h,crossAxis:u,alignmentAxis:d}="number"==typeof p?{mainAxis:p,crossAxis:0,alignmentAxis:null}:{mainAxis:0,crossAxis:0,alignmentAxis:null,...p};return s&&"number"==typeof d&&(u="end"===s?-1*d:d),l?{x:u*f,y:h*c}:{x:h*c,y:u*f}}(e,t);return{x:n+i.x,y:o+i.y,data:i}}}},k=function(t){return void 0===t&&(t={}),{name:"size",options:t,async fn(e){const{placement:n,rects:o,platform:i,elements:r}=e,{apply:a=(()=>{}),...s}=y(t,e),f=await L(e,s),p=g(n),h=w(n),u="y"===x(n),{width:d,height:m}=o.floating;let b,v;"top"===p||"bottom"===p?(b=p,v=h===(await(null==i.isRTL?void 0:i.isRTL(r.floating))?"start":"end")?"left":"right"):(v=p,b="end"===h?"top":"bottom");const P=m-f[b],E=d-f[v],z=!e.middlewareData.shift;let R=P,S=E;if(u){const t=d-f.left-f.right;S=h||z?l(E,t):t}else{const t=m-f.top-f.bottom;R=h||z?l(P,t):t}if(z&&!h){const t=c(f.left,0),e=c(f.right,0),n=c(f.top,0),o=c(f.bottom,0);u?S=d-2*(0!==t||0!==e?t+e:c(f.left,f.right)):R=m-2*(0!==n||0!==o?n+o:c(f.top,f.bottom))}await a({...e,availableWidth:S,availableHeight:R});const T=await i.getDimensions(r.floating);return d!==T.width||m!==T.height?{reset:{rects:!0}}:{}}}};function O(t){return D(t)?(t.nodeName||"").toLowerCase():"#document"}function C(t){var e;return(null==t||null==(e=t.ownerDocument)?void 0:e.defaultView)||window}function F(t){var e;return null==(e=(D(t)?t.ownerDocument:t.document)||window.document)?void 0:e.documentElement}function D(t){return t instanceof Node||t instanceof C(t).Node}function B(t){return t instanceof Element||t instanceof C(t).Element}function $(t){return t instanceof HTMLElement||t instanceof C(t).HTMLElement}function j(t){return!(typeof ShadowRoot>"u")&&(t instanceof ShadowRoot||t instanceof C(t).ShadowRoot)}function H(t){const{overflow:e,overflowX:n,overflowY:o,display:i}=q(t);return/auto|scroll|overlay|hidden|clip/.test(e+o+n)&&!["inline","contents"].includes(i)}function N(t){return["table","td","th"].includes(O(t))}function W(t){const e=M(),n=q(t);return"none"!==n.transform||"none"!==n.perspective||!!n.containerType&&"normal"!==n.containerType||!e&&!!n.backdropFilter&&"none"!==n.backdropFilter||!e&&!!n.filter&&"none"!==n.filter||["transform","perspective","filter"].some((t=>(n.willChange||"").includes(t)))||["paint","layout","strict","content"].some((t=>(n.contain||"").includes(t)))}function M(){return!(typeof CSS>"u"||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}function V(t){return["html","body","#document"].includes(O(t))}function q(t){return C(t).getComputedStyle(t)}function I(t){return B(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.pageXOffset,scrollTop:t.pageYOffset}}function X(t){if("html"===O(t))return t;const e=t.assignedSlot||t.parentNode||j(t)&&t.host||F(t);return j(e)?e.host:e}function Y(t){const e=X(t);return V(e)?t.ownerDocument?t.ownerDocument.body:t.body:$(e)&&H(e)?e:Y(e)}function _(t,e,n){var o;void 0===e&&(e=[]),void 0===n&&(n=!0);const i=Y(t),r=i===(null==(o=t.ownerDocument)?void 0:o.body),a=C(i);return r?e.concat(a,a.visualViewport||[],H(i)?i:[],a.frameElement&&n?_(a.frameElement):[]):e.concat(i,_(i,[],n))}function G(t){const e=q(t);let n=parseFloat(e.width)||0,o=parseFloat(e.height)||0;const i=$(t),r=i?t.offsetWidth:n,a=i?t.offsetHeight:o,s=f(n)!==r||f(o)!==a;return s&&(n=r,o=a),{width:n,height:o,$:s}}function J(t){return B(t)?t:t.contextElement}function K(t){const e=J(t);if(!$(e))return h(1);const n=e.getBoundingClientRect(),{width:o,height:i,$:r}=G(e);let a=(r?f(n.width):n.width)/o,s=(r?f(n.height):n.height)/i;return(!a||!Number.isFinite(a))&&(a=1),(!s||!Number.isFinite(s))&&(s=1),{x:a,y:s}}const Q=h(0);function U(t){const e=C(t);return M()&&e.visualViewport?{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}:Q}function Z(t,e,n,o){void 0===e&&(e=!1),void 0===n&&(n=!1);const i=t.getBoundingClientRect(),r=J(t);let a=h(1);e&&(o?B(o)&&(a=K(o)):a=K(t));const s=function(t,e,n){return void 0===e&&(e=!1),!(!n||e&&n!==C(t))&&e}(r,n,o)?U(r):h(0);let l=(i.left+s.x)/a.x,c=(i.top+s.y)/a.y,f=i.width/a.x,p=i.height/a.y;if(r){const t=C(r),e=o&&B(o)?C(o):o;let n=t.frameElement;for(;n&&o&&e!==t;){const t=K(n),e=n.getBoundingClientRect(),o=q(n),i=e.left+(n.clientLeft+parseFloat(o.paddingLeft))*t.x,r=e.top+(n.clientTop+parseFloat(o.paddingTop))*t.y;l*=t.x,c*=t.y,f*=t.x,p*=t.y,l+=i,c+=r,n=C(n).frameElement}}return S({width:f,height:p,x:l,y:c})}function tt(t){return Z(F(t)).left+I(t).scrollLeft}function et(t,e,n){let o;if("viewport"===e)o=function(t,e){const n=C(t),o=F(t),i=n.visualViewport;let r=o.clientWidth,a=o.clientHeight,s=0,l=0;if(i){r=i.width,a=i.height;const t=M();(!t||t&&"fixed"===e)&&(s=i.offsetLeft,l=i.offsetTop)}return{width:r,height:a,x:s,y:l}}(t,n);else if("document"===e)o=function(t){const e=F(t),n=I(t),o=t.ownerDocument.body,i=c(e.scrollWidth,e.clientWidth,o.scrollWidth,o.clientWidth),r=c(e.scrollHeight,e.clientHeight,o.scrollHeight,o.clientHeight);let a=-n.scrollLeft+tt(t);const s=-n.scrollTop;return"rtl"===q(o).direction&&(a+=c(e.clientWidth,o.clientWidth)-i),{width:i,height:r,x:a,y:s}}(F(t));else if(B(e))o=function(t,e){const n=Z(t,!0,"fixed"===e),o=n.top+t.clientTop,i=n.left+t.clientLeft,r=$(t)?K(t):h(1);return{width:t.clientWidth*r.x,height:t.clientHeight*r.y,x:i*r.x,y:o*r.y}}(e,n);else{const n=U(t);o={...e,x:e.x-n.x,y:e.y-n.y}}return S(o)}function nt(t,e){const n=X(t);return!(n===e||!B(n)||V(n))&&("fixed"===q(n).position||nt(n,e))}function ot(t,e){const n=e.get(t);if(n)return n;let o=_(t,[],!1).filter((t=>B(t)&&"body"!==O(t))),i=null;const r="fixed"===q(t).position;let a=r?X(t):t;for(;B(a)&&!V(a);){const e=q(a),n=W(a);!n&&"fixed"===e.position&&(i=null),(r?!n&&!i:!n&&"static"===e.position&&i&&["absolute","fixed"].includes(i.position)||H(a)&&!n&&nt(t,a))?o=o.filter((t=>t!==a)):i=e,a=X(a)}return e.set(t,o),o}function it(t,e,n){const o=$(e),i=F(e),r="fixed"===n,a=Z(t,!0,r,e);let s={scrollLeft:0,scrollTop:0};const l=h(0);if(o||!o&&!r)if(("body"!==O(e)||H(i))&&(s=I(e)),o){const t=Z(e,!0,r,e);l.x=t.x+e.clientLeft,l.y=t.y+e.clientTop}else i&&(l.x=tt(i));return{x:a.left+s.scrollLeft-l.x,y:a.top+s.scrollTop-l.y,width:a.width,height:a.height}}function rt(t,e){return $(t)&&"fixed"!==q(t).position?e?e(t):t.offsetParent:null}function at(t,e){const n=C(t);if(!$(t))return n;let o=rt(t,e);for(;o&&N(o)&&"static"===q(o).position;)o=rt(o,e);return o&&("html"===O(o)||"body"===O(o)&&"static"===q(o).position&&!W(o))?n:o||function(t){let e=X(t);for(;$(e)&&!V(e);){if(W(e))return e;e=X(e)}return null}(t)||n}const st={convertOffsetParentRelativeRectToViewportRelativeRect:function(t){let{rect:e,offsetParent:n,strategy:o}=t;const i=$(n),r=F(n);if(n===r)return e;let a={scrollLeft:0,scrollTop:0},s=h(1);const l=h(0);if((i||!i&&"fixed"!==o)&&(("body"!==O(n)||H(r))&&(a=I(n)),$(n))){const t=Z(n);s=K(n),l.x=t.x+n.clientLeft,l.y=t.y+n.clientTop}return{width:e.width*s.x,height:e.height*s.y,x:e.x*s.x-a.scrollLeft*s.x+l.x,y:e.y*s.y-a.scrollTop*s.y+l.y}},getDocumentElement:F,getClippingRect:function(t){let{element:e,boundary:n,rootBoundary:o,strategy:i}=t;const r=[..."clippingAncestors"===n?ot(e,this._c):[].concat(n),o],a=r[0],s=r.reduce(((t,n)=>{const o=et(e,n,i);return t.top=c(o.top,t.top),t.right=l(o.right,t.right),t.bottom=l(o.bottom,t.bottom),t.left=c(o.left,t.left),t}),et(e,a,i));return{width:s.right-s.left,height:s.bottom-s.top,x:s.left,y:s.top}},getOffsetParent:at,getElementRects:async function(t){let{reference:e,floating:n,strategy:o}=t;const i=this.getOffsetParent||at,r=this.getDimensions;return{reference:it(e,await i(n),o),floating:{x:0,y:0,...await r(n)}}},getClientRects:function(t){return Array.from(t.getClientRects())},getDimensions:function(t){return G(t)},getScale:K,isElement:B,isRTL:function(t){return"rtl"===q(t).direction}};var lt=Object.defineProperty,ct=Object.getOwnPropertyDescriptor,ft=(t,e,n,o)=>{for(var i,r=o>1?void 0:o?ct(e,n):e,a=t.length-1;a>=0;a--)(i=t[a])&&(r=(o?i(e,n,r):i(r))||r);return o&&r&<(e,n,r),r};let pt=class extends o{constructor(){super(...arguments),this.active=!1,this.placement="top",this.strategy="absolute",this.distance=0,this.skidding=0,this.arrow=!1,this.arrowPlacement="anchor",this.arrowPadding=10,this.flip=!1,this.flipFallbackPlacements="",this.flipFallbackStrategy="best-fit",this.flipPadding=0,this.shift=!1,this.shiftPadding=0,this.autoSizePadding=0}async connectedCallback(){super.connectedCallback(),await this.updateComplete,this.start()}disconnectedCallback(){this.stop()}async updated(t){super.updated(t),t.has("active")&&(this.active?this.start():this.stop()),t.has("anchor")&&this.handleAnchorChange(),this.active&&(await this.updateComplete,this.reposition())}async handleAnchorChange(){if(await this.stop(),this.anchor&&"string"==typeof this.anchor){const t=this.getRootNode();this.anchorEl=t.getElementById(this.anchor)}else this.anchor instanceof HTMLElement?this.anchorEl=this.anchor:this.anchorEl=this.querySelector('[slot="anchor"]');if(this.anchorEl instanceof HTMLSlotElement&&(this.anchorEl=this.anchorEl.assignedElements({flatten:!0})[0]),!this.anchorEl)throw new Error("Invalid anchor element: no anchor could be found using the anchor slot or the anchor attribute.");this.start()}start(){this.anchorEl&&(this.cleanup=function(t,e,n,o){void 0===o&&(o={});const{ancestorScroll:i=!0,ancestorResize:r=!0,elementResize:a="function"==typeof ResizeObserver,layoutShift:s="function"==typeof IntersectionObserver,animationFrame:f=!1}=o,h=J(t),u=i||r?[...h?_(h):[],..._(e)]:[];u.forEach((t=>{i&&t.addEventListener("scroll",n,{passive:!0}),r&&t.addEventListener("resize",n)}));const d=h&&s?function(t,e){let n,o=null;const i=F(t);function r(){clearTimeout(n),o&&o.disconnect(),o=null}return function a(s,f){void 0===s&&(s=!1),void 0===f&&(f=1),r();const{left:h,top:u,width:d,height:m}=t.getBoundingClientRect();if(s||e(),!d||!m)return;const y={rootMargin:-p(u)+"px "+-p(i.clientWidth-(h+d))+"px "+-p(i.clientHeight-(u+m))+"px "+-p(h)+"px",threshold:c(0,l(1,f))||1};let g=!0;function w(t){const e=t[0].intersectionRatio;if(e!==f){if(!g)return a();e?a(!1,e):n=setTimeout((()=>{a(!1,1e-7)}),100)}g=!1}try{o=new IntersectionObserver(w,{...y,root:i.ownerDocument})}catch{o=new IntersectionObserver(w,y)}o.observe(t)}(!0),r}(h,n):null;let m=-1,y=null;a&&(y=new ResizeObserver((t=>{let[o]=t;o&&o.target===h&&y&&(y.unobserve(e),cancelAnimationFrame(m),m=requestAnimationFrame((()=>{y&&y.observe(e)}))),n()})),h&&!f&&y.observe(h),y.observe(e));let g,w=f?Z(t):null;return f&&function e(){const o=Z(t);w&&(o.x!==w.x||o.y!==w.y||o.width!==w.width||o.height!==w.height)&&n(),w=o,g=requestAnimationFrame(e)}(),n(),()=>{u.forEach((t=>{i&&t.removeEventListener("scroll",n),r&&t.removeEventListener("resize",n)})),d&&d(),y&&y.disconnect(),y=null,f&&cancelAnimationFrame(g)}}(this.anchorEl,this.popup,(()=>{this.reposition()})))}async stop(){return new Promise((t=>{this.cleanup?(this.cleanup(),this.cleanup=void 0,this.removeAttribute("data-current-placement"),this.style.removeProperty("--auto-size-available-width"),this.style.removeProperty("--auto-size-available-height"),requestAnimationFrame((()=>t()))):t()}))}reposition(){if(!this.active||!this.anchorEl)return;const t=[A({mainAxis:this.distance,crossAxis:this.skidding})];this.sync?t.push(k({apply:({rects:t})=>{const e="width"===this.sync||"both"===this.sync,n="height"===this.sync||"both"===this.sync;this.popup.style.width=e?`${t.reference.width}px`:"",this.popup.style.height=n?`${t.reference.height}px`:""}})):(this.popup.style.width="",this.popup.style.height=""),this.flip&&t.push(function(t){return void 0===t&&(t={}),{name:"flip",options:t,async fn(e){var n,o;const{placement:i,middlewareData:r,rects:a,initialPlacement:s,platform:l,elements:c}=e,{mainAxis:f=!0,crossAxis:p=!0,fallbackPlacements:h,fallbackStrategy:u="bestFit",fallbackAxisSideDirection:d="none",flipAlignment:m=!0,...b}=y(t,e);if(null!=(n=r.arrow)&&n.alignmentOffset)return{};const x=g(i),R=g(s)===s,S=await(null==l.isRTL?void 0:l.isRTL(c.floating)),T=h||(R||!m?[z(s)]:function(t){const e=z(t);return[E(t),e,E(e)]}(s));!h&&"none"!==d&&T.push(...function(t,e,n,o){const i=w(t);let r=function(t,e,n){const o=["left","right"],i=["right","left"],r=["top","bottom"],a=["bottom","top"];switch(t){case"top":case"bottom":return n?e?i:o:e?o:i;case"left":case"right":return e?r:a;default:return[]}}(g(t),"start"===n,o);return i&&(r=r.map((t=>t+"-"+i)),e&&(r=r.concat(r.map(E)))),r}(s,m,d,S));const A=[s,...T],k=await L(e,b),O=[];let C=(null==(o=r.flip)?void 0:o.overflows)||[];if(f&&O.push(k[x]),p){const t=function(t,e,n){void 0===n&&(n=!1);const o=w(t),i=P(t),r=v(i);let a="x"===i?o===(n?"end":"start")?"right":"left":"start"===o?"bottom":"top";return e.reference[r]>e.floating[r]&&(a=z(a)),[a,z(a)]}(i,a,S);O.push(k[t[0]],k[t[1]])}if(C=[...C,{placement:i,overflows:O}],!O.every((t=>t<=0))){var F,D;const t=((null==(F=r.flip)?void 0:F.index)||0)+1,e=A[t];if(e)return{data:{index:t,overflows:C},reset:{placement:e}};let n=null==(D=C.filter((t=>t.overflows[0]<=0)).sort(((t,e)=>t.overflows[1]-e.overflows[1]))[0])?void 0:D.placement;if(!n)switch(u){case"bestFit":{var B;const t=null==(B=C.map((t=>[t.placement,t.overflows.filter((t=>t>0)).reduce(((t,e)=>t+e),0)])).sort(((t,e)=>t[1]-e[1]))[0])?void 0:B[0];t&&(n=t);break}case"initialPlacement":n=s}if(i!==n)return{reset:{placement:n}}}return{}}}}({boundary:this.flipBoundary,fallbackPlacements:this.flipFallbackPlacements,fallbackStrategy:"best-fit"===this.flipFallbackStrategy?"bestFit":"initialPlacement",padding:this.flipPadding})),this.shift&&t.push(function(t){return void 0===t&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:o,placement:i}=e,{mainAxis:r=!0,crossAxis:a=!1,limiter:s={fn:t=>{let{x:e,y:n}=t;return{x:e,y:n}}},...l}=y(t,e),c={x:n,y:o},f=await L(e,l),p=x(g(i)),h=b(p);let u=c[h],d=c[p];if(r){const t="y"===h?"bottom":"right";u=m(u+f["y"===h?"top":"left"],u,u-f[t])}if(a){const t="y"===p?"bottom":"right";d=m(d+f["y"===p?"top":"left"],d,d-f[t])}const w=s.fn({...e,[h]:u,[p]:d});return{...w,data:{x:w.x-n,y:w.y-o}}}}}({boundary:this.shiftBoundary,padding:this.shiftPadding})),this.autoSize?t.push(k({boundary:this.autoSizeBoundary,padding:this.autoSizePadding,apply:({availableWidth:t,availableHeight:e})=>{"vertical"===this.autoSize||"both"===this.autoSize?this.style.setProperty("--auto-size-available-height",`${e}px`):this.style.removeProperty("--auto-size-available-height"),"horizontal"===this.autoSize||"both"===this.autoSize?this.style.setProperty("--auto-size-available-width",`${t}px`):this.style.removeProperty("--auto-size-available-width")}})):(this.style.removeProperty("--auto-size-available-width"),this.style.removeProperty("--auto-size-available-height")),this.arrow&&t.push((t=>({name:"arrow",options:t,async fn(e){const{x:n,y:o,placement:i,rects:r,platform:a,elements:s,middlewareData:c}=e,{element:f,padding:p=0}=y(t,e)||{};if(null==f)return{};const h=R(p),u={x:n,y:o},d=P(i),g=v(d),b=await a.getDimensions(f),x="y"===d,E=x?"top":"left",z=x?"bottom":"right",S=x?"clientHeight":"clientWidth",T=r.reference[g]+r.reference[d]-u[d]-r.floating[g],L=u[d]-r.reference[d],A=await(null==a.getOffsetParent?void 0:a.getOffsetParent(f));let k=A?A[S]:0;(!k||!await(null==a.isElement?void 0:a.isElement(A)))&&(k=s.floating[S]||r.floating[g]);const O=T/2-L/2,C=k/2-b[g]/2-1,F=l(h[E],C),D=l(h[z],C),B=F,$=k-b[g]-D,j=k/2-b[g]/2+O,H=m(B,j,$),N=!c.arrow&&null!=w(i)&&j!=H&&r.reference[g]/2-(j<B?F:D)-b[g]/2<0,W=N?j<B?j-B:j-$:0;return{[d]:u[d]+W,data:{[d]:H,centerOffset:j-H-W,...N&&{alignmentOffset:W}},reset:N}}}))({element:this.arrowEl,padding:this.arrowPadding})),((t,e,n)=>{const o=new Map,i={platform:st,...n},r={...i.platform,_c:o};return(async(t,e,n)=>{const{placement:o="bottom",strategy:i="absolute",middleware:r=[],platform:a}=n,s=r.filter(Boolean),l=await(null==a.isRTL?void 0:a.isRTL(e));let c=await a.getElementRects({reference:t,floating:e,strategy:i}),{x:f,y:p}=T(c,o,l),h=o,u={},d=0;for(let n=0;n<s.length;n++){const{name:r,fn:m}=s[n],{x:y,y:g,data:w,reset:b}=await m({x:f,y:p,initialPlacement:o,placement:h,strategy:i,middlewareData:u,rects:c,platform:a,elements:{reference:t,floating:e}});f=y??f,p=g??p,u={...u,[r]:{...u[r],...w}},b&&d<=50&&(d++,"object"==typeof b&&(b.placement&&(h=b.placement),b.rects&&(c=!0===b.rects?await a.getElementRects({reference:t,floating:e,strategy:i}):b.rects),({x:f,y:p}=T(c,h,l))),n=-1)}return{x:f,y:p,placement:h,strategy:i,middlewareData:u}})(t,e,{...i,platform:r})})(this.anchorEl,this.popup,{placement:this.placement,middleware:t,strategy:this.strategy}).then((({x:t,y:e,middlewareData:n,placement:o})=>{const i="rtl"===getComputedStyle(this).direction,r={top:"bottom",right:"left",bottom:"top",left:"right"}[o.split("-")[0]];if(this.setAttribute("data-current-placement",o),Object.assign(this.popup.style,{left:`${t}px`,top:`${e}px`}),this.arrow){const t=n.arrow.x,e=n.arrow.y;let o="",a="",s="",l="";if("start"===this.arrowPlacement){const n="number"==typeof t?`calc(${this.arrowPadding}px - var(--arrow-padding-offset))`:"";o="number"==typeof e?`calc(${this.arrowPadding}px - var(--arrow-padding-offset))`:"",a=i?n:"",l=i?"":n}else if("end"===this.arrowPlacement){const n="number"==typeof t?`calc(${this.arrowPadding}px - var(--arrow-padding-offset))`:"";a=i?"":n,l=i?n:"",s="number"==typeof e?`calc(${this.arrowPadding}px - var(--arrow-padding-offset))`:""}else"center"===this.arrowPlacement?(l="number"==typeof t?"calc(50% - var(--arrow-size-diagonal))":"",o="number"==typeof e?"calc(50% - var(--arrow-size-diagonal))":""):(l="number"==typeof t?`${t}px`:"",o="number"==typeof e?`${e}px`:"");Object.assign(this.arrowEl.style,{top:o,right:a,bottom:s,left:l,[r]:"calc(var(--arrow-size-diagonal) * -1)"})}})),this.emit("sd-reposition")}render(){return t`<slot name="anchor" @slotchange="${this.handleAnchorChange}"></slot><div part="popup" class="${s("isolate","fixed"!==this.strategy?"absolute":"fixed",!this.active&&"hidden")}"><slot></slot>${this.arrow?t`<div part="arrow" class="absolute rotate-45 -z-10" role="presentation"></div>`:""}</div>`}};pt.styles=[o.styles,a,e`:host{--arrow-color:var(--sd-color-neutral-1000);--arrow-size:6px;--arrow-size-diagonal:calc(var(--arrow-size) * 0.7071);--arrow-padding-offset:calc(var(--arrow-size-diagonal) - var(--arrow-size));display:contents}[part=popup]{max-width:var(--auto-size-available-width,none);max-height:var(--auto-size-available-height,none)}[part=arrow]{width:calc(var(--arrow-size-diagonal) * 2);height:calc(var(--arrow-size-diagonal) * 2);background:var(--arrow-color)}`],ft([r('[part="popup"]')],pt.prototype,"popup",2),ft([r('[part="arrow"]')],pt.prototype,"arrowEl",2),ft([i()],pt.prototype,"anchor",2),ft([i({type:Boolean,reflect:!0})],pt.prototype,"active",2),ft([i({reflect:!0})],pt.prototype,"placement",2),ft([i({reflect:!0})],pt.prototype,"strategy",2),ft([i({type:Number})],pt.prototype,"distance",2),ft([i({type:Number})],pt.prototype,"skidding",2),ft([i({type:Boolean})],pt.prototype,"arrow",2),ft([i({attribute:"arrow-placement"})],pt.prototype,"arrowPlacement",2),ft([i({attribute:"arrow-padding",type:Number})],pt.prototype,"arrowPadding",2),ft([i({type:Boolean})],pt.prototype,"flip",2),ft([i({attribute:"flip-fallback-placements",converter:{fromAttribute:t=>t.split(" ").map((t=>t.trim())).filter((t=>""!==t)),toAttribute:t=>t.join(" ")}})],pt.prototype,"flipFallbackPlacements",2),ft([i({attribute:"flip-fallback-strategy"})],pt.prototype,"flipFallbackStrategy",2),ft([i({type:Object})],pt.prototype,"flipBoundary",2),ft([i({attribute:"flip-padding",type:Number})],pt.prototype,"flipPadding",2),ft([i({type:Boolean})],pt.prototype,"shift",2),ft([i({type:Object})],pt.prototype,"shiftBoundary",2),ft([i({attribute:"shift-padding",type:Number})],pt.prototype,"shiftPadding",2),ft([i({attribute:"auto-size"})],pt.prototype,"autoSize",2),ft([i()],pt.prototype,"sync",2),ft([i({type:Object})],pt.prototype,"autoSizeBoundary",2),ft([i({attribute:"auto-size-padding",type:Number})],pt.prototype,"autoSizePadding",2),pt=ft([n("sd-1-21-1-popup")],pt);export{pt as default};
|
|
1
|
+
import{x as t,i as e}from"./lit-element.js";import{c as n}from"./register-custom-element.js";import{S as o,n as i}from"./solid-element.js";import{e as r}from"./query.js";import{c as a}from"./component.styles.js";import{t as s}from"./classix.js";const l=Math.min,c=Math.max,f=Math.round,p=Math.floor,h=t=>({x:t,y:t}),u={left:"right",right:"left",bottom:"top",top:"bottom"},d={start:"end",end:"start"};function m(t,e,n){return c(t,l(e,n))}function y(t,e){return"function"==typeof t?t(e):t}function g(t){return t.split("-")[0]}function w(t){return t.split("-")[1]}function b(t){return"x"===t?"y":"x"}function v(t){return"y"===t?"height":"width"}function x(t){return["top","bottom"].includes(g(t))?"y":"x"}function P(t){return b(x(t))}function E(t){return t.replace(/start|end/g,(t=>d[t]))}function z(t){return t.replace(/left|right|bottom|top/g,(t=>u[t]))}function R(t){return"number"!=typeof t?function(t){return{top:0,right:0,bottom:0,left:0,...t}}(t):{top:t,right:t,bottom:t,left:t}}function S(t){return{...t,top:t.y,left:t.x,right:t.x+t.width,bottom:t.y+t.height}}function T(t,e,n){let{reference:o,floating:i}=t;const r=x(e),a=P(e),s=v(a),l=g(e),c="y"===r,f=o.x+o.width/2-i.width/2,p=o.y+o.height/2-i.height/2,h=o[s]/2-i[s]/2;let u;switch(l){case"top":u={x:f,y:o.y-i.height};break;case"bottom":u={x:f,y:o.y+o.height};break;case"right":u={x:o.x+o.width,y:p};break;case"left":u={x:o.x-i.width,y:p};break;default:u={x:o.x,y:o.y}}switch(w(e)){case"start":u[a]-=h*(n&&c?-1:1);break;case"end":u[a]+=h*(n&&c?-1:1)}return u}async function L(t,e){var n;void 0===e&&(e={});const{x:o,y:i,platform:r,rects:a,elements:s,strategy:l}=t,{boundary:c="clippingAncestors",rootBoundary:f="viewport",elementContext:p="floating",altBoundary:h=!1,padding:u=0}=y(e,t),d=R(u),m=s[h?"floating"===p?"reference":"floating":p],g=S(await r.getClippingRect({element:null==(n=await(null==r.isElement?void 0:r.isElement(m)))||n?m:m.contextElement||await(null==r.getDocumentElement?void 0:r.getDocumentElement(s.floating)),boundary:c,rootBoundary:f,strategy:l})),w="floating"===p?{...a.floating,x:o,y:i}:a.reference,b=await(null==r.getOffsetParent?void 0:r.getOffsetParent(s.floating)),v=await(null==r.isElement?void 0:r.isElement(b))&&await(null==r.getScale?void 0:r.getScale(b))||{x:1,y:1},x=S(r.convertOffsetParentRelativeRectToViewportRelativeRect?await r.convertOffsetParentRelativeRectToViewportRelativeRect({rect:w,offsetParent:b,strategy:l}):w);return{top:(g.top-x.top+d.top)/v.y,bottom:(x.bottom-g.bottom+d.bottom)/v.y,left:(g.left-x.left+d.left)/v.x,right:(x.right-g.right+d.right)/v.x}}const A=function(t){return void 0===t&&(t=0),{name:"offset",options:t,async fn(e){const{x:n,y:o}=e,i=await async function(t,e){const{placement:n,platform:o,elements:i}=t,r=await(null==o.isRTL?void 0:o.isRTL(i.floating)),a=g(n),s=w(n),l="y"===x(n),c=["left","top"].includes(a)?-1:1,f=r&&l?-1:1,p=y(e,t);let{mainAxis:h,crossAxis:u,alignmentAxis:d}="number"==typeof p?{mainAxis:p,crossAxis:0,alignmentAxis:null}:{mainAxis:0,crossAxis:0,alignmentAxis:null,...p};return s&&"number"==typeof d&&(u="end"===s?-1*d:d),l?{x:u*f,y:h*c}:{x:h*c,y:u*f}}(e,t);return{x:n+i.x,y:o+i.y,data:i}}}},k=function(t){return void 0===t&&(t={}),{name:"size",options:t,async fn(e){const{placement:n,rects:o,platform:i,elements:r}=e,{apply:a=(()=>{}),...s}=y(t,e),f=await L(e,s),p=g(n),h=w(n),u="y"===x(n),{width:d,height:m}=o.floating;let b,v;"top"===p||"bottom"===p?(b=p,v=h===(await(null==i.isRTL?void 0:i.isRTL(r.floating))?"start":"end")?"left":"right"):(v=p,b="end"===h?"top":"bottom");const P=m-f[b],E=d-f[v],z=!e.middlewareData.shift;let R=P,S=E;if(u){const t=d-f.left-f.right;S=h||z?l(E,t):t}else{const t=m-f.top-f.bottom;R=h||z?l(P,t):t}if(z&&!h){const t=c(f.left,0),e=c(f.right,0),n=c(f.top,0),o=c(f.bottom,0);u?S=d-2*(0!==t||0!==e?t+e:c(f.left,f.right)):R=m-2*(0!==n||0!==o?n+o:c(f.top,f.bottom))}await a({...e,availableWidth:S,availableHeight:R});const T=await i.getDimensions(r.floating);return d!==T.width||m!==T.height?{reset:{rects:!0}}:{}}}};function O(t){return D(t)?(t.nodeName||"").toLowerCase():"#document"}function C(t){var e;return(null==t||null==(e=t.ownerDocument)?void 0:e.defaultView)||window}function F(t){var e;return null==(e=(D(t)?t.ownerDocument:t.document)||window.document)?void 0:e.documentElement}function D(t){return t instanceof Node||t instanceof C(t).Node}function B(t){return t instanceof Element||t instanceof C(t).Element}function $(t){return t instanceof HTMLElement||t instanceof C(t).HTMLElement}function j(t){return!(typeof ShadowRoot>"u")&&(t instanceof ShadowRoot||t instanceof C(t).ShadowRoot)}function H(t){const{overflow:e,overflowX:n,overflowY:o,display:i}=q(t);return/auto|scroll|overlay|hidden|clip/.test(e+o+n)&&!["inline","contents"].includes(i)}function N(t){return["table","td","th"].includes(O(t))}function W(t){const e=M(),n=q(t);return"none"!==n.transform||"none"!==n.perspective||!!n.containerType&&"normal"!==n.containerType||!e&&!!n.backdropFilter&&"none"!==n.backdropFilter||!e&&!!n.filter&&"none"!==n.filter||["transform","perspective","filter"].some((t=>(n.willChange||"").includes(t)))||["paint","layout","strict","content"].some((t=>(n.contain||"").includes(t)))}function M(){return!(typeof CSS>"u"||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}function V(t){return["html","body","#document"].includes(O(t))}function q(t){return C(t).getComputedStyle(t)}function I(t){return B(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.pageXOffset,scrollTop:t.pageYOffset}}function X(t){if("html"===O(t))return t;const e=t.assignedSlot||t.parentNode||j(t)&&t.host||F(t);return j(e)?e.host:e}function Y(t){const e=X(t);return V(e)?t.ownerDocument?t.ownerDocument.body:t.body:$(e)&&H(e)?e:Y(e)}function _(t,e,n){var o;void 0===e&&(e=[]),void 0===n&&(n=!0);const i=Y(t),r=i===(null==(o=t.ownerDocument)?void 0:o.body),a=C(i);return r?e.concat(a,a.visualViewport||[],H(i)?i:[],a.frameElement&&n?_(a.frameElement):[]):e.concat(i,_(i,[],n))}function G(t){const e=q(t);let n=parseFloat(e.width)||0,o=parseFloat(e.height)||0;const i=$(t),r=i?t.offsetWidth:n,a=i?t.offsetHeight:o,s=f(n)!==r||f(o)!==a;return s&&(n=r,o=a),{width:n,height:o,$:s}}function J(t){return B(t)?t:t.contextElement}function K(t){const e=J(t);if(!$(e))return h(1);const n=e.getBoundingClientRect(),{width:o,height:i,$:r}=G(e);let a=(r?f(n.width):n.width)/o,s=(r?f(n.height):n.height)/i;return(!a||!Number.isFinite(a))&&(a=1),(!s||!Number.isFinite(s))&&(s=1),{x:a,y:s}}const Q=h(0);function U(t){const e=C(t);return M()&&e.visualViewport?{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}:Q}function Z(t,e,n,o){void 0===e&&(e=!1),void 0===n&&(n=!1);const i=t.getBoundingClientRect(),r=J(t);let a=h(1);e&&(o?B(o)&&(a=K(o)):a=K(t));const s=function(t,e,n){return void 0===e&&(e=!1),!(!n||e&&n!==C(t))&&e}(r,n,o)?U(r):h(0);let l=(i.left+s.x)/a.x,c=(i.top+s.y)/a.y,f=i.width/a.x,p=i.height/a.y;if(r){const t=C(r),e=o&&B(o)?C(o):o;let n=t.frameElement;for(;n&&o&&e!==t;){const t=K(n),e=n.getBoundingClientRect(),o=q(n),i=e.left+(n.clientLeft+parseFloat(o.paddingLeft))*t.x,r=e.top+(n.clientTop+parseFloat(o.paddingTop))*t.y;l*=t.x,c*=t.y,f*=t.x,p*=t.y,l+=i,c+=r,n=C(n).frameElement}}return S({width:f,height:p,x:l,y:c})}function tt(t){return Z(F(t)).left+I(t).scrollLeft}function et(t,e,n){let o;if("viewport"===e)o=function(t,e){const n=C(t),o=F(t),i=n.visualViewport;let r=o.clientWidth,a=o.clientHeight,s=0,l=0;if(i){r=i.width,a=i.height;const t=M();(!t||t&&"fixed"===e)&&(s=i.offsetLeft,l=i.offsetTop)}return{width:r,height:a,x:s,y:l}}(t,n);else if("document"===e)o=function(t){const e=F(t),n=I(t),o=t.ownerDocument.body,i=c(e.scrollWidth,e.clientWidth,o.scrollWidth,o.clientWidth),r=c(e.scrollHeight,e.clientHeight,o.scrollHeight,o.clientHeight);let a=-n.scrollLeft+tt(t);const s=-n.scrollTop;return"rtl"===q(o).direction&&(a+=c(e.clientWidth,o.clientWidth)-i),{width:i,height:r,x:a,y:s}}(F(t));else if(B(e))o=function(t,e){const n=Z(t,!0,"fixed"===e),o=n.top+t.clientTop,i=n.left+t.clientLeft,r=$(t)?K(t):h(1);return{width:t.clientWidth*r.x,height:t.clientHeight*r.y,x:i*r.x,y:o*r.y}}(e,n);else{const n=U(t);o={...e,x:e.x-n.x,y:e.y-n.y}}return S(o)}function nt(t,e){const n=X(t);return!(n===e||!B(n)||V(n))&&("fixed"===q(n).position||nt(n,e))}function ot(t,e){const n=e.get(t);if(n)return n;let o=_(t,[],!1).filter((t=>B(t)&&"body"!==O(t))),i=null;const r="fixed"===q(t).position;let a=r?X(t):t;for(;B(a)&&!V(a);){const e=q(a),n=W(a);!n&&"fixed"===e.position&&(i=null),(r?!n&&!i:!n&&"static"===e.position&&i&&["absolute","fixed"].includes(i.position)||H(a)&&!n&&nt(t,a))?o=o.filter((t=>t!==a)):i=e,a=X(a)}return e.set(t,o),o}function it(t,e,n){const o=$(e),i=F(e),r="fixed"===n,a=Z(t,!0,r,e);let s={scrollLeft:0,scrollTop:0};const l=h(0);if(o||!o&&!r)if(("body"!==O(e)||H(i))&&(s=I(e)),o){const t=Z(e,!0,r,e);l.x=t.x+e.clientLeft,l.y=t.y+e.clientTop}else i&&(l.x=tt(i));return{x:a.left+s.scrollLeft-l.x,y:a.top+s.scrollTop-l.y,width:a.width,height:a.height}}function rt(t,e){return $(t)&&"fixed"!==q(t).position?e?e(t):t.offsetParent:null}function at(t,e){const n=C(t);if(!$(t))return n;let o=rt(t,e);for(;o&&N(o)&&"static"===q(o).position;)o=rt(o,e);return o&&("html"===O(o)||"body"===O(o)&&"static"===q(o).position&&!W(o))?n:o||function(t){let e=X(t);for(;$(e)&&!V(e);){if(W(e))return e;e=X(e)}return null}(t)||n}const st={convertOffsetParentRelativeRectToViewportRelativeRect:function(t){let{rect:e,offsetParent:n,strategy:o}=t;const i=$(n),r=F(n);if(n===r)return e;let a={scrollLeft:0,scrollTop:0},s=h(1);const l=h(0);if((i||!i&&"fixed"!==o)&&(("body"!==O(n)||H(r))&&(a=I(n)),$(n))){const t=Z(n);s=K(n),l.x=t.x+n.clientLeft,l.y=t.y+n.clientTop}return{width:e.width*s.x,height:e.height*s.y,x:e.x*s.x-a.scrollLeft*s.x+l.x,y:e.y*s.y-a.scrollTop*s.y+l.y}},getDocumentElement:F,getClippingRect:function(t){let{element:e,boundary:n,rootBoundary:o,strategy:i}=t;const r=[..."clippingAncestors"===n?ot(e,this._c):[].concat(n),o],a=r[0],s=r.reduce(((t,n)=>{const o=et(e,n,i);return t.top=c(o.top,t.top),t.right=l(o.right,t.right),t.bottom=l(o.bottom,t.bottom),t.left=c(o.left,t.left),t}),et(e,a,i));return{width:s.right-s.left,height:s.bottom-s.top,x:s.left,y:s.top}},getOffsetParent:at,getElementRects:async function(t){let{reference:e,floating:n,strategy:o}=t;const i=this.getOffsetParent||at,r=this.getDimensions;return{reference:it(e,await i(n),o),floating:{x:0,y:0,...await r(n)}}},getClientRects:function(t){return Array.from(t.getClientRects())},getDimensions:function(t){return G(t)},getScale:K,isElement:B,isRTL:function(t){return"rtl"===q(t).direction}};var lt=Object.defineProperty,ct=Object.getOwnPropertyDescriptor,ft=(t,e,n,o)=>{for(var i,r=o>1?void 0:o?ct(e,n):e,a=t.length-1;a>=0;a--)(i=t[a])&&(r=(o?i(e,n,r):i(r))||r);return o&&r&<(e,n,r),r};let pt=class extends o{constructor(){super(...arguments),this.active=!1,this.placement="top",this.strategy="absolute",this.distance=0,this.skidding=0,this.arrow=!1,this.arrowPlacement="anchor",this.arrowPadding=10,this.flip=!1,this.flipFallbackPlacements="",this.flipFallbackStrategy="best-fit",this.flipPadding=0,this.shift=!1,this.shiftPadding=0,this.autoSizePadding=0}async connectedCallback(){super.connectedCallback(),await this.updateComplete,this.start()}disconnectedCallback(){this.stop()}async updated(t){super.updated(t),t.has("active")&&(this.active?this.start():this.stop()),t.has("anchor")&&this.handleAnchorChange(),this.active&&(await this.updateComplete,this.reposition())}async handleAnchorChange(){if(await this.stop(),this.anchor&&"string"==typeof this.anchor){const t=this.getRootNode();this.anchorEl=t.getElementById(this.anchor)}else this.anchor instanceof HTMLElement?this.anchorEl=this.anchor:this.anchorEl=this.querySelector('[slot="anchor"]');if(this.anchorEl instanceof HTMLSlotElement&&(this.anchorEl=this.anchorEl.assignedElements({flatten:!0})[0]),!this.anchorEl)throw new Error("Invalid anchor element: no anchor could be found using the anchor slot or the anchor attribute.");this.start()}start(){this.anchorEl&&(this.cleanup=function(t,e,n,o){void 0===o&&(o={});const{ancestorScroll:i=!0,ancestorResize:r=!0,elementResize:a="function"==typeof ResizeObserver,layoutShift:s="function"==typeof IntersectionObserver,animationFrame:f=!1}=o,h=J(t),u=i||r?[...h?_(h):[],..._(e)]:[];u.forEach((t=>{i&&t.addEventListener("scroll",n,{passive:!0}),r&&t.addEventListener("resize",n)}));const d=h&&s?function(t,e){let n,o=null;const i=F(t);function r(){clearTimeout(n),o&&o.disconnect(),o=null}return function a(s,f){void 0===s&&(s=!1),void 0===f&&(f=1),r();const{left:h,top:u,width:d,height:m}=t.getBoundingClientRect();if(s||e(),!d||!m)return;const y={rootMargin:-p(u)+"px "+-p(i.clientWidth-(h+d))+"px "+-p(i.clientHeight-(u+m))+"px "+-p(h)+"px",threshold:c(0,l(1,f))||1};let g=!0;function w(t){const e=t[0].intersectionRatio;if(e!==f){if(!g)return a();e?a(!1,e):n=setTimeout((()=>{a(!1,1e-7)}),100)}g=!1}try{o=new IntersectionObserver(w,{...y,root:i.ownerDocument})}catch{o=new IntersectionObserver(w,y)}o.observe(t)}(!0),r}(h,n):null;let m=-1,y=null;a&&(y=new ResizeObserver((t=>{let[o]=t;o&&o.target===h&&y&&(y.unobserve(e),cancelAnimationFrame(m),m=requestAnimationFrame((()=>{y&&y.observe(e)}))),n()})),h&&!f&&y.observe(h),y.observe(e));let g,w=f?Z(t):null;return f&&function e(){const o=Z(t);w&&(o.x!==w.x||o.y!==w.y||o.width!==w.width||o.height!==w.height)&&n(),w=o,g=requestAnimationFrame(e)}(),n(),()=>{u.forEach((t=>{i&&t.removeEventListener("scroll",n),r&&t.removeEventListener("resize",n)})),d&&d(),y&&y.disconnect(),y=null,f&&cancelAnimationFrame(g)}}(this.anchorEl,this.popup,(()=>{this.reposition()})))}async stop(){return new Promise((t=>{this.cleanup?(this.cleanup(),this.cleanup=void 0,this.removeAttribute("data-current-placement"),this.style.removeProperty("--auto-size-available-width"),this.style.removeProperty("--auto-size-available-height"),requestAnimationFrame((()=>t()))):t()}))}reposition(){if(!this.active||!this.anchorEl)return;const t=[A({mainAxis:this.distance,crossAxis:this.skidding})];this.sync?t.push(k({apply:({rects:t})=>{const e="width"===this.sync||"both"===this.sync,n="height"===this.sync||"both"===this.sync;this.popup.style.width=e?`${t.reference.width}px`:"",this.popup.style.height=n?`${t.reference.height}px`:""}})):(this.popup.style.width="",this.popup.style.height=""),this.flip&&t.push(function(t){return void 0===t&&(t={}),{name:"flip",options:t,async fn(e){var n,o;const{placement:i,middlewareData:r,rects:a,initialPlacement:s,platform:l,elements:c}=e,{mainAxis:f=!0,crossAxis:p=!0,fallbackPlacements:h,fallbackStrategy:u="bestFit",fallbackAxisSideDirection:d="none",flipAlignment:m=!0,...b}=y(t,e);if(null!=(n=r.arrow)&&n.alignmentOffset)return{};const x=g(i),R=g(s)===s,S=await(null==l.isRTL?void 0:l.isRTL(c.floating)),T=h||(R||!m?[z(s)]:function(t){const e=z(t);return[E(t),e,E(e)]}(s));!h&&"none"!==d&&T.push(...function(t,e,n,o){const i=w(t);let r=function(t,e,n){const o=["left","right"],i=["right","left"],r=["top","bottom"],a=["bottom","top"];switch(t){case"top":case"bottom":return n?e?i:o:e?o:i;case"left":case"right":return e?r:a;default:return[]}}(g(t),"start"===n,o);return i&&(r=r.map((t=>t+"-"+i)),e&&(r=r.concat(r.map(E)))),r}(s,m,d,S));const A=[s,...T],k=await L(e,b),O=[];let C=(null==(o=r.flip)?void 0:o.overflows)||[];if(f&&O.push(k[x]),p){const t=function(t,e,n){void 0===n&&(n=!1);const o=w(t),i=P(t),r=v(i);let a="x"===i?o===(n?"end":"start")?"right":"left":"start"===o?"bottom":"top";return e.reference[r]>e.floating[r]&&(a=z(a)),[a,z(a)]}(i,a,S);O.push(k[t[0]],k[t[1]])}if(C=[...C,{placement:i,overflows:O}],!O.every((t=>t<=0))){var F,D;const t=((null==(F=r.flip)?void 0:F.index)||0)+1,e=A[t];if(e)return{data:{index:t,overflows:C},reset:{placement:e}};let n=null==(D=C.filter((t=>t.overflows[0]<=0)).sort(((t,e)=>t.overflows[1]-e.overflows[1]))[0])?void 0:D.placement;if(!n)switch(u){case"bestFit":{var B;const t=null==(B=C.map((t=>[t.placement,t.overflows.filter((t=>t>0)).reduce(((t,e)=>t+e),0)])).sort(((t,e)=>t[1]-e[1]))[0])?void 0:B[0];t&&(n=t);break}case"initialPlacement":n=s}if(i!==n)return{reset:{placement:n}}}return{}}}}({boundary:this.flipBoundary,fallbackPlacements:this.flipFallbackPlacements,fallbackStrategy:"best-fit"===this.flipFallbackStrategy?"bestFit":"initialPlacement",padding:this.flipPadding})),this.shift&&t.push(function(t){return void 0===t&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:o,placement:i}=e,{mainAxis:r=!0,crossAxis:a=!1,limiter:s={fn:t=>{let{x:e,y:n}=t;return{x:e,y:n}}},...l}=y(t,e),c={x:n,y:o},f=await L(e,l),p=x(g(i)),h=b(p);let u=c[h],d=c[p];if(r){const t="y"===h?"bottom":"right";u=m(u+f["y"===h?"top":"left"],u,u-f[t])}if(a){const t="y"===p?"bottom":"right";d=m(d+f["y"===p?"top":"left"],d,d-f[t])}const w=s.fn({...e,[h]:u,[p]:d});return{...w,data:{x:w.x-n,y:w.y-o}}}}}({boundary:this.shiftBoundary,padding:this.shiftPadding})),this.autoSize?t.push(k({boundary:this.autoSizeBoundary,padding:this.autoSizePadding,apply:({availableWidth:t,availableHeight:e})=>{"vertical"===this.autoSize||"both"===this.autoSize?this.style.setProperty("--auto-size-available-height",`${e}px`):this.style.removeProperty("--auto-size-available-height"),"horizontal"===this.autoSize||"both"===this.autoSize?this.style.setProperty("--auto-size-available-width",`${t}px`):this.style.removeProperty("--auto-size-available-width")}})):(this.style.removeProperty("--auto-size-available-width"),this.style.removeProperty("--auto-size-available-height")),this.arrow&&t.push((t=>({name:"arrow",options:t,async fn(e){const{x:n,y:o,placement:i,rects:r,platform:a,elements:s,middlewareData:c}=e,{element:f,padding:p=0}=y(t,e)||{};if(null==f)return{};const h=R(p),u={x:n,y:o},d=P(i),g=v(d),b=await a.getDimensions(f),x="y"===d,E=x?"top":"left",z=x?"bottom":"right",S=x?"clientHeight":"clientWidth",T=r.reference[g]+r.reference[d]-u[d]-r.floating[g],L=u[d]-r.reference[d],A=await(null==a.getOffsetParent?void 0:a.getOffsetParent(f));let k=A?A[S]:0;(!k||!await(null==a.isElement?void 0:a.isElement(A)))&&(k=s.floating[S]||r.floating[g]);const O=T/2-L/2,C=k/2-b[g]/2-1,F=l(h[E],C),D=l(h[z],C),B=F,$=k-b[g]-D,j=k/2-b[g]/2+O,H=m(B,j,$),N=!c.arrow&&null!=w(i)&&j!=H&&r.reference[g]/2-(j<B?F:D)-b[g]/2<0,W=N?j<B?j-B:j-$:0;return{[d]:u[d]+W,data:{[d]:H,centerOffset:j-H-W,...N&&{alignmentOffset:W}},reset:N}}}))({element:this.arrowEl,padding:this.arrowPadding})),((t,e,n)=>{const o=new Map,i={platform:st,...n},r={...i.platform,_c:o};return(async(t,e,n)=>{const{placement:o="bottom",strategy:i="absolute",middleware:r=[],platform:a}=n,s=r.filter(Boolean),l=await(null==a.isRTL?void 0:a.isRTL(e));let c=await a.getElementRects({reference:t,floating:e,strategy:i}),{x:f,y:p}=T(c,o,l),h=o,u={},d=0;for(let n=0;n<s.length;n++){const{name:r,fn:m}=s[n],{x:y,y:g,data:w,reset:b}=await m({x:f,y:p,initialPlacement:o,placement:h,strategy:i,middlewareData:u,rects:c,platform:a,elements:{reference:t,floating:e}});f=y??f,p=g??p,u={...u,[r]:{...u[r],...w}},b&&d<=50&&(d++,"object"==typeof b&&(b.placement&&(h=b.placement),b.rects&&(c=!0===b.rects?await a.getElementRects({reference:t,floating:e,strategy:i}):b.rects),({x:f,y:p}=T(c,h,l))),n=-1)}return{x:f,y:p,placement:h,strategy:i,middlewareData:u}})(t,e,{...i,platform:r})})(this.anchorEl,this.popup,{placement:this.placement,middleware:t,strategy:this.strategy}).then((({x:t,y:e,middlewareData:n,placement:o})=>{const i="rtl"===getComputedStyle(this).direction,r={top:"bottom",right:"left",bottom:"top",left:"right"}[o.split("-")[0]];if(this.setAttribute("data-current-placement",o),Object.assign(this.popup.style,{left:`${t}px`,top:`${e}px`}),this.arrow){const t=n.arrow.x,e=n.arrow.y;let o="",a="",s="",l="";if("start"===this.arrowPlacement){const n="number"==typeof t?`calc(${this.arrowPadding}px - var(--arrow-padding-offset))`:"";o="number"==typeof e?`calc(${this.arrowPadding}px - var(--arrow-padding-offset))`:"",a=i?n:"",l=i?"":n}else if("end"===this.arrowPlacement){const n="number"==typeof t?`calc(${this.arrowPadding}px - var(--arrow-padding-offset))`:"";a=i?"":n,l=i?n:"",s="number"==typeof e?`calc(${this.arrowPadding}px - var(--arrow-padding-offset))`:""}else"center"===this.arrowPlacement?(l="number"==typeof t?"calc(50% - var(--arrow-size-diagonal))":"",o="number"==typeof e?"calc(50% - var(--arrow-size-diagonal))":""):(l="number"==typeof t?`${t}px`:"",o="number"==typeof e?`${e}px`:"");Object.assign(this.arrowEl.style,{top:o,right:a,bottom:s,left:l,[r]:"calc(var(--arrow-size-diagonal) * -1)"})}})),this.emit("sd-reposition")}render(){return t`<slot name="anchor" @slotchange="${this.handleAnchorChange}"></slot><div part="popup" class="${s("isolate","fixed"!==this.strategy?"absolute":"fixed",!this.active&&"hidden")}"><slot></slot>${this.arrow?t`<div part="arrow" class="absolute rotate-45 -z-10" role="presentation"></div>`:""}</div>`}};pt.styles=[o.styles,a,e`:host{--arrow-color:var(--sd-color-neutral-1000);--arrow-size:6px;--arrow-size-diagonal:calc(var(--arrow-size) * 0.7071);--arrow-padding-offset:calc(var(--arrow-size-diagonal) - var(--arrow-size));display:contents}[part=popup]{max-width:var(--auto-size-available-width,none);max-height:var(--auto-size-available-height,none)}[part=arrow]{width:calc(var(--arrow-size-diagonal) * 2);height:calc(var(--arrow-size-diagonal) * 2);background:var(--arrow-color)}`],ft([r('[part="popup"]')],pt.prototype,"popup",2),ft([r('[part="arrow"]')],pt.prototype,"arrowEl",2),ft([i()],pt.prototype,"anchor",2),ft([i({type:Boolean,reflect:!0})],pt.prototype,"active",2),ft([i({reflect:!0})],pt.prototype,"placement",2),ft([i({reflect:!0})],pt.prototype,"strategy",2),ft([i({type:Number})],pt.prototype,"distance",2),ft([i({type:Number})],pt.prototype,"skidding",2),ft([i({type:Boolean})],pt.prototype,"arrow",2),ft([i({attribute:"arrow-placement"})],pt.prototype,"arrowPlacement",2),ft([i({attribute:"arrow-padding",type:Number})],pt.prototype,"arrowPadding",2),ft([i({type:Boolean})],pt.prototype,"flip",2),ft([i({attribute:"flip-fallback-placements",converter:{fromAttribute:t=>t.split(" ").map((t=>t.trim())).filter((t=>""!==t)),toAttribute:t=>t.join(" ")}})],pt.prototype,"flipFallbackPlacements",2),ft([i({attribute:"flip-fallback-strategy"})],pt.prototype,"flipFallbackStrategy",2),ft([i({type:Object})],pt.prototype,"flipBoundary",2),ft([i({attribute:"flip-padding",type:Number})],pt.prototype,"flipPadding",2),ft([i({type:Boolean})],pt.prototype,"shift",2),ft([i({type:Object})],pt.prototype,"shiftBoundary",2),ft([i({attribute:"shift-padding",type:Number})],pt.prototype,"shiftPadding",2),ft([i({attribute:"auto-size"})],pt.prototype,"autoSize",2),ft([i()],pt.prototype,"sync",2),ft([i({type:Object})],pt.prototype,"autoSizeBoundary",2),ft([i({attribute:"auto-size-padding",type:Number})],pt.prototype,"autoSizePadding",2),pt=ft([n("sd-1-23-0-popup")],pt);export{pt as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as t,x as e}from"./lit-element.js";import{c as o}from"./register-custom-element.js";import{F as s,c as i,a
|
|
1
|
+
import{i as t,x as e}from"./lit-element.js";import{c as o}from"./register-custom-element.js";import{F as s,c as i,a,v as l}from"./form.js";import{H as r}from"./slot.js";import{n,S as d}from"./solid-element.js";import{r as h}from"./state.js";import{e as u}from"./query.js";import{w as c}from"./watch.js";import{c as p}from"./component.styles.js";import{t as m}from"./classix.js";const g=t`${p}:host{display:inline-block}.button-group{display:flex;flex-wrap:nowrap}`;var v=Object.defineProperty,b=Object.getOwnPropertyDescriptor,f=(t,e,o,s)=>{for(var i,a=s>1?void 0:s?b(e,o):e,l=t.length-1;l>=0;l--)(i=t[l])&&(a=(s?i(e,o,a):i(a))||a);return s&&a&&v(e,o,a),a};let y=class extends d{constructor(){super(...arguments),this.disableRole=!1,this.label=""}handleFocus(t){const e=C(t.target);null==e||e.classList.add("sd-1-23-0-button-group__button--focus")}handleBlur(t){const e=C(t.target);null==e||e.classList.remove("sd-1-23-0-button-group__button--focus")}handleMouseOver(t){const e=C(t.target);null==e||e.classList.add("sd-1-23-0-button-group__button--hover")}handleMouseOut(t){const e=C(t.target);null==e||e.classList.remove("sd-1-23-0-button-group__button--hover")}handleSlotChange(){const t=[...this.defaultSlot.assignedElements({flatten:!0})];t.forEach((e=>{const o=t.indexOf(e),s=C(e);null!==s&&(s.classList.add("sd-1-23-0-button-group__button"),s.classList.toggle("sd-1-23-0-button-group__button--first",0===o),s.classList.toggle("sd-1-23-0-button-group__button--inner",o>0&&o<t.length-1),s.classList.toggle("sd-1-23-0-button-group__button--last",o===t.length-1),s.classList.toggle("sd-1-23-0-button-group__button--radio","sd-1-23-0-radio-button"===s.tagName.toLowerCase()))}))}render(){return e`<slot part="base" class="button-group" role="${this.disableRole?"presentation":"group"}" aria-label="${this.label}" @focusout="${this.handleBlur}" @focusin="${this.handleFocus}" @mouseover="${this.handleMouseOver}" @mouseout="${this.handleMouseOut}" @slotchange="${this.handleSlotChange}"></slot>`}};function C(t){const e="sd-1-23-0-button, sd-1-23-0-radio-button";return t.closest(e)??t.querySelector(e)}y.styles=g,f([u("slot")],y.prototype,"defaultSlot",2),f([h()],y.prototype,"disableRole",2),f([n()],y.prototype,"label",2),y=f([o("sd-1-23-0-button-group")],y);var x=Object.defineProperty,w=Object.getOwnPropertyDescriptor,R=(t,e,o,s)=>{for(var i,a=s>1?void 0:s?w(e,o):e,l=t.length-1;l>=0;l--)(i=t[l])&&(a=(s?i(e,o,a):i(a))||a);return s&&a&&x(e,o,a),a};let k=class extends d{constructor(){super(...arguments),this.formControlController=new s(this),this.hasSlotController=new r(this,"label","error-text"),this.customValidityMessage="",this.hasButtonGroup=!1,this.defaultValue="",this.invalid=!1,this.errorText="",this.label="",this.name="option",this.value="",this.size="lg",this.form="",this.required=!1,this.orientation="vertical"}get validity(){const t=this.required&&!this.value;return""!==this.customValidityMessage?(this.invalid=!0,i):t?(this.invalid=!0,a):(this.invalid=!1,l)}get validationMessage(){const t=this.required&&!this.value;return""!==this.customValidityMessage?(console.log("this.customValidityMessage",this.customValidityMessage),this.customValidityMessage):t?(console.log("this.validationInput.validationMessage",this.validationInput),this.validationInput.validationMessage):""}connectedCallback(){super.connectedCallback(),this.defaultValue=this.value}firstUpdated(){this.formControlController.updateValidity()}getAllRadios(){return[...this.querySelectorAll("sd-1-23-0-radio, sd-1-23-0-radio-button")]}handleRadioClick(t){const e=t.target.closest("sd-1-23-0-radio, sd-1-23-0-radio-button"),o=this.getAllRadios(),s=this.value;e.disabled||(this.value=e.value,o.forEach((t=>t.checked=t===e)),this.value!==s&&(this.emit("sd-change"),this.emit("sd-input")))}handleKeyDown(t){if(!["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"," "].includes(t.key))return;const e=this.getAllRadios().filter((t=>!t.disabled)),o=e.find((t=>t.checked))??e[0],s=" "===t.key?0:["ArrowUp","ArrowLeft"].includes(t.key)?-1:1,i=this.value;let a=e.indexOf(o)+s;a<0&&(a=e.length-1),a>e.length-1&&(a=0),this.getAllRadios().forEach((t=>{t.checked=!1,this.hasButtonGroup||(t.tabIndex=-1)})),this.value=e[a].value,e[a].checked=!0,this.hasButtonGroup?e[a].shadowRoot.querySelector("button").focus():(e[a].tabIndex=0,e[a].focus()),this.value!==i&&(this.emit("sd-change"),this.emit("sd-input")),t.preventDefault()}handleLabelClick(){const t=this.getAllRadios(),e=t.find((t=>t.checked))||t[0];e&&e.focus()}handleInvalid(t){this.formControlController.setValidity(!1),this.formControlController.emitInvalidEvent(t)}async syncRadioElements(){var t,e;const o=this.getAllRadios();if(await Promise.all(o.map((async t=>{await t.updateComplete,t.checked=t.value===this.value,t.size=this.size,t.invalid=this.invalid}))),this.hasButtonGroup=o.some((t=>"sd-1-23-0-radio-button"===t.tagName.toLowerCase())),!o.some((t=>t.checked)))if(this.hasButtonGroup){const e=null==(t=o[0].shadowRoot)?void 0:t.querySelector("button");e&&(e.tabIndex=0)}else o[0].tabIndex=0;if(this.hasButtonGroup){const t=null==(e=this.shadowRoot)?void 0:e.querySelector("sd-1-23-0-button-group");t&&(t.disableRole=!0)}}syncRadios(){customElements.get("sd-1-23-0-radio")&&customElements.get("sd-1-23-0-radio-button")?this.syncRadioElements():(customElements.get("sd-1-23-0-radio")?this.syncRadioElements():customElements.whenDefined("sd-1-23-0-radio").then((()=>this.syncRadios())),customElements.get("sd-1-23-0-radio-button")?this.syncRadioElements():customElements.whenDefined("sd-1-23-0-radio-button").then((()=>this.syncRadios())))}updateCheckedRadio(){this.getAllRadios().forEach((t=>t.checked=t.value===this.value)),this.formControlController.setValidity(this.validity.valid)}handleSizeChange(){this.syncRadios()}handleInvalidChange(){this.syncRadios()}handleValueChange(){this.hasUpdated&&(this.updateCheckedRadio(),this.reportValidity())}checkValidity(){const t=this.required&&!this.value,e=""!==this.customValidityMessage;return!t&&!e||(this.formControlController.emitInvalidEvent(),!1)}getForm(){return this.formControlController.getForm()}reportValidity(){const t=this.validity.valid;return this.errorText=this.customValidityMessage||t?"":this.validationInput.validationMessage,this.formControlController.setValidity(t),this.validationInput.hidden=!0,clearTimeout(this.validationTimeout),t||(this.validationInput.hidden=!1,this.validationInput.reportValidity(),this.validationTimeout=setTimeout((()=>this.validationInput.hidden=!0),1e4)),t}setCustomValidity(t=""){this.customValidityMessage=t,this.errorText=t,this.validationInput.setCustomValidity(t),this.formControlController.updateValidity()}render(){const t=this.hasSlotController.test("label"),o=this.hasSlotController.test("error-text"),s=!!this.label||!!t,i=!!this.errorText||!!o,a=e`<slot @slotchange="${this.syncRadios}" @click="${this.handleRadioClick}" @keydown="${this.handleKeyDown}"></slot>`;return e`<fieldset part="form-control" class="${m("border-0 p-0 m-0",i&&"text-error",{sm:"text-sm",lg:"text-base"}[this.size])}" role="radiogroup" aria-labelledby="label" aria-errormessage="error-text"><label part="form-control-label" id="label" class="${m("mb-2 p-0 font-bold leading-normal text-black",s?"has-label flex":"hidden")}" aria-hidden="${!s}" @click="${this.handleLabelClick}"><slot name="label">${this.label}</slot></label><div part="form-control-input" class="${m("form-control-input flex",this.invalid&&"form-control-input--invalid text-error",{vertical:"flex-col",horizontal:"flex-row"}[this.orientation])}"><div class="sr-only"><div id="error-message" aria-live="assertive">${this.errorText}</div><label><input id="validation-input" type="text" ?required="${this.required}" tabindex="-1" hidden @invalid="${this.handleInvalid}"></label></div>${a}</div></fieldset>`}};k.dependencies={"sd-1-23-0-button-group":y},k.styles=[p,d.styles,t`:host{display:block}:host([orientation=vertical]) ::slotted(sd-1-23-0-radio){margin-bottom:8px;display:flex}:host([orientation=vertical]) ::slotted(sd-1-23-0-radio:last-of-type){margin-bottom:0}:host([orientation=horizontal]) ::slotted(sd-1-23-0-radio){margin-right:24px}:host([size=sm]):host([orientation=horizontal]) ::slotted(sd-1-23-0-radio){margin-right:16px}:host([orientation=horizontal]) ::slotted(sd-1-23-0-radio:last-of-type){margin-right:0}:host([required]) #label.has-label::after{content:'*';margin-left:2px}`],R([u("slot:not([name])")],k.prototype,"defaultSlot",2),R([u("#validation-input")],k.prototype,"validationInput",2),R([h()],k.prototype,"hasButtonGroup",2),R([h()],k.prototype,"defaultValue",2),R([h()],k.prototype,"invalid",2),R([h()],k.prototype,"errorText",2),R([n()],k.prototype,"label",2),R([n()],k.prototype,"name",2),R([n({reflect:!0})],k.prototype,"value",2),R([n({reflect:!0})],k.prototype,"size",2),R([n({reflect:!0})],k.prototype,"form",2),R([n({type:Boolean,reflect:!0})],k.prototype,"required",2),R([n({reflect:!0})],k.prototype,"orientation",2),R([c("size",{waitUntilFirstUpdate:!0})],k.prototype,"handleSizeChange",1),R([c("invalid",{waitUntilFirstUpdate:!0})],k.prototype,"handleInvalidChange",1),R([c("value")],k.prototype,"handleValueChange",1),k=R([o("sd-1-23-0-radio-group")],k);export{k as default};
|