@solid-design-system/components 3.10.3 → 3.11.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/accordion.js +1 -1
- package/dist/components/es/animate.js +1 -0
- package/dist/components/es/carousel.js +1 -1
- package/dist/components/es/dialog.js +1 -1
- package/dist/components/es/drawer.js +1 -1
- package/dist/components/es/dropdown.js +1 -1
- package/dist/components/es/event.js +1 -1
- package/dist/components/es/expandable.js +1 -0
- package/dist/components/es/notification.js +1 -1
- package/dist/components/es/scroll-controller.js +1 -1
- package/dist/components/es/select.js +3 -3
- package/dist/components/es/solid-components2.js +6 -6
- package/dist/components/es/tooltip.js +2 -2
- package/dist/components/umd/solid-components.js +5 -5
- package/dist/custom-elements.json +1 -1
- package/dist/package/components/expandable/expandable.d.ts +23 -0
- package/dist/package/components/expandable/expandable.js +116 -0
- package/dist/package/solid-components.d.ts +1 -0
- package/dist/package/solid-components.js +60 -58
- package/dist/package/styles/tailwind.css.js +1 -1
- package/dist/package/translations/de.js +3 -1
- package/dist/package/translations/en.js +3 -1
- package/dist/package/utilities/localize.d.ts +2 -0
- package/dist/versioned-components/es/accordion-group.js +1 -1
- package/dist/versioned-components/es/accordion.js +1 -1
- package/dist/versioned-components/es/animate.js +1 -0
- 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 -1
- package/dist/versioned-components/es/checkbox.js +1 -1
- package/dist/versioned-components/es/dialog.js +1 -1
- 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/expandable.js +1 -0
- package/dist/versioned-components/es/flipcard.js +1 -1
- package/dist/versioned-components/es/form.js +1 -1
- package/dist/versioned-components/es/header.js +1 -1
- package/dist/versioned-components/es/icon.js +1 -1
- package/dist/versioned-components/es/include.js +1 -1
- package/dist/versioned-components/es/input.js +1 -1
- package/dist/versioned-components/es/link.js +1 -1
- package/dist/versioned-components/es/map-marker.js +1 -1
- package/dist/versioned-components/es/navigation-item.js +1 -1
- package/dist/versioned-components/es/notification.js +1 -1
- package/dist/versioned-components/es/option.js +1 -1
- package/dist/versioned-components/es/radio-button.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/scroll-controller.js +1 -1
- package/dist/versioned-components/es/scrollable.js +1 -1
- package/dist/versioned-components/es/select.js +3 -3
- package/dist/versioned-components/es/solid-components2.js +6 -6
- package/dist/versioned-components/es/spinner.js +1 -1
- package/dist/versioned-components/es/step-group.js +1 -1
- package/dist/versioned-components/es/step.js +1 -1
- package/dist/versioned-components/es/switch.js +1 -1
- package/dist/versioned-components/es/tab-group.js +1 -1
- package/dist/versioned-components/es/tab-panel.js +1 -1
- package/dist/versioned-components/es/tab.js +1 -1
- package/dist/versioned-components/es/tag.js +1 -1
- package/dist/versioned-components/es/teaser-media.js +1 -1
- package/dist/versioned-components/es/teaser.js +1 -1
- package/dist/versioned-components/es/textarea.js +1 -1
- package/dist/versioned-components/es/tooltip.js +2 -2
- 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 +1 -1
- package/dist/versioned-package/components/checkbox/checkbox.js +3 -3
- package/dist/versioned-package/components/checkbox-group/checkbox-group.d.ts +1 -1
- package/dist/versioned-package/components/checkbox-group/checkbox-group.js +5 -5
- package/dist/versioned-package/components/dialog/dialog.d.ts +1 -1
- package/dist/versioned-package/components/dialog/dialog.js +2 -2
- 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 +8 -8
- package/dist/versioned-package/components/expandable/expandable.d.ts +23 -0
- package/dist/versioned-package/components/expandable/expandable.js +116 -0
- package/dist/versioned-package/components/flipcard/flipcard.d.ts +1 -1
- package/dist/versioned-package/components/flipcard/flipcard.js +1 -1
- package/dist/versioned-package/components/header/header.d.ts +1 -1
- package/dist/versioned-package/components/header/header.js +4 -4
- 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/include/include.d.ts +1 -1
- package/dist/versioned-package/components/include/include.js +1 -1
- package/dist/versioned-package/components/input/input.d.ts +1 -1
- package/dist/versioned-package/components/input/input.js +2 -2
- 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/map-marker/map-marker.d.ts +1 -1
- package/dist/versioned-package/components/map-marker/map-marker.js +1 -1
- 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/notification/notification.d.ts +1 -1
- package/dist/versioned-package/components/notification/notification.js +5 -5
- package/dist/versioned-package/components/option/option.d.ts +1 -1
- package/dist/versioned-package/components/option/option.js +2 -2
- 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 +2 -2
- package/dist/versioned-package/components/radio-button/radio-button.d.ts +1 -1
- package/dist/versioned-package/components/radio-button/radio-button.js +2 -2
- package/dist/versioned-package/components/radio-group/radio-group.d.ts +2 -2
- package/dist/versioned-package/components/radio-group/radio-group.js +13 -13
- package/dist/versioned-package/components/scrollable/scrollable.d.ts +1 -1
- package/dist/versioned-package/components/scrollable/scrollable.js +3 -3
- package/dist/versioned-package/components/select/select.d.ts +4 -4
- package/dist/versioned-package/components/select/select.js +25 -25
- 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/step/step.d.ts +1 -1
- package/dist/versioned-package/components/step/step.js +5 -5
- package/dist/versioned-package/components/step-group/step-group.d.ts +1 -1
- package/dist/versioned-package/components/step-group/step-group.js +2 -2
- package/dist/versioned-package/components/switch/switch.d.ts +1 -1
- package/dist/versioned-package/components/switch/switch.js +1 -1
- package/dist/versioned-package/components/tab/tab.d.ts +1 -1
- package/dist/versioned-package/components/tab/tab.js +2 -2
- package/dist/versioned-package/components/tab-group/tab-group.d.ts +1 -1
- package/dist/versioned-package/components/tab-group/tab-group.js +13 -13
- package/dist/versioned-package/components/tab-panel/tab-panel.d.ts +1 -1
- package/dist/versioned-package/components/tab-panel/tab-panel.js +2 -2
- 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/teaser-media/teaser-media.js +1 -1
- package/dist/versioned-package/components/textarea/textarea.d.ts +1 -1
- package/dist/versioned-package/components/textarea/textarea.js +2 -2
- package/dist/versioned-package/components/tooltip/tooltip.d.ts +1 -1
- package/dist/versioned-package/components/tooltip/tooltip.js +5 -5
- 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/form.js +3 -3
- package/dist/versioned-package/solid-components.d.ts +1 -0
- package/dist/versioned-package/solid-components.js +60 -58
- package/dist/versioned-package/styles/headline/headline.css.js +1 -1
- package/dist/versioned-package/styles/tailwind.css.js +1 -1
- package/dist/versioned-package/translations/de.js +3 -1
- package/dist/versioned-package/translations/en.js +3 -1
- package/dist/versioned-package/utilities/autocomplete-config.js +4 -4
- package/dist/versioned-package/utilities/localize.d.ts +2 -0
- package/dist/versioned-styles/solid-styles.css +1 -1
- package/dist/vscode.html-custom-data.json +76 -42
- package/dist/web-types.json +217 -43
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./icon.js";import{s as e,a as t,b as s
|
|
1
|
+
import"./icon.js";import{s as e,a as t,b as s}from"./animate.js";import{S as o,L as i,x as a,t as r,i as n,e as h,n as d,a as l}from"./solid-components2.js";import{g as p,s as c}from"./animation-registry.js";import{w as y}from"./event.js";import{w as m}from"./watch.js";var u=Object.defineProperty,f=Object.getOwnPropertyDescriptor,b=(e,t,s,o)=>{for(var i,a=o>1?void 0:o?f(t,s):t,r=e.length-1;r>=0;r--)(i=e[r])&&(a=(o?i(t,s,a):i(a))||a);return o&&a&&u(t,s,a),a};let w=class extends o{constructor(){super(...arguments),this.localize=new i(this),this.open=!1}firstUpdated(){this.body.hidden=!this.open,this.body.style.height=this.open?"auto":"0"}handleSummaryClick(){this.header.focus(),this.open?this.hide():this.show()}handleSummaryKeyDown(e){("Enter"===e.key||" "===e.key)&&(e.preventDefault(),this.open?this.hide():this.show()),("ArrowUp"===e.key||"ArrowLeft"===e.key)&&(e.preventDefault(),this.hide()),("ArrowDown"===e.key||"ArrowRight"===e.key)&&(e.preventDefault(),this.show())}async handleOpenChange(){if(this.open){if(this.emit("sd-show",{cancelable:!0}).defaultPrevented)return void(this.open=!1);await e(this.body),this.body.hidden=!1;const{keyframes:o,options:i}=p(this,"accordion.show",{dir:this.localize.dir()});await t(this.body,s(o,this.body.scrollHeight),i),this.body.style.height="auto",this.emit("sd-after-show")}else{if(this.emit("sd-hide",{cancelable:!0}).defaultPrevented)return void(this.open=!0);await e(this.body);const{keyframes:o,options:i}=p(this,"accordion.hide",{dir:this.localize.dir()});await t(this.body,s(o,this.body.scrollHeight),i),this.body.hidden=!0,this.body.style.height="auto",this.emit("sd-after-hide")}}async show(){if(!this.open)return this.open=!0,y(this,"sd-after-show")}async hide(){if(this.open)return this.open=!1,y(this,"sd-after-hide")}render(){return a`<div part="base" class="border-y border-neutral-400"><header part="header" id="header" class="${r("flex text-base gap-4 font-bold items-center cursor-pointer select-none px-4 py-3 focus-visible:focus-outline text-primary hover:bg-neutral-200 relative group")}" role="button" aria-expanded="${this.open?"true":"false"}" aria-controls="content" tabindex="0" @click="${this.handleSummaryClick}" @keydown="${this.handleSummaryKeyDown}"><div part="summary-border" class="${r(!this.open&&"opacity-0","w-1 bg-accent absolute left-0 transition-all h-[calc(100%-16px)] group-hover:h-full")}"></div><slot name="summary" part="summary" class="flex flex-auto items-center text-left">${this.summary}</slot><span part="summary-icon" class="${r("flex flex-grow-0 flex-shrink-0 flex-auto items-center transition-all ease-in-out duration-300 text-xl",this.open&&"rotate-180")}"><slot name="expand-icon" class="${r(this.open&&"hidden")}"><sd-icon library="system" name="chevron-down"></sd-icon></slot><slot name="collapse-icon" class="${r(!this.open&&"hidden")}"><sd-icon library="system" name="chevron-down"></sd-icon></slot></span></header><div part="content" id="content" class="overflow-hidden"><slot part="content__slot" class="block px-4 py-6" role="region" aria-labelledby="header"></slot></div></div>`}};w.styles=[o.styles,n`:host{display:block}`],b([h('[part="base"]')],w.prototype,"accordion",2),b([h('[part="header"]')],w.prototype,"header",2),b([h('[part="content"]')],w.prototype,"body",2),b([d({type:Boolean,reflect:!0})],w.prototype,"open",2),b([d()],w.prototype,"summary",2),b([m("open",{waitUntilFirstUpdate:!0})],w.prototype,"handleOpenChange",1),w=b([l("sd-accordion")],w),c("accordion.show",{keyframes:[{height:"0",opacity:"0"},{height:"auto",opacity:"1"}],options:{duration:300,easing:"ease"}}),c("accordion.hide",{keyframes:[{height:"auto",opacity:"1"},{height:"0",opacity:"0"}],options:{duration:300,easing:"ease"}});export{w as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(e,n,i){return new Promise((a=>{if((null==i?void 0:i.duration)===1/0)throw new Error("Promise-based animations must be finite.");const r=e.animate(n,{...i,duration:t()?0:i.duration});r.addEventListener("cancel",a,{once:!0}),r.addEventListener("finish",a,{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 a(e,n){return e.map((e=>({...e,height:"auto"===e.height?`${n}px`:e.height})))}export{e as a,a as b,n as c,t as p,i as s};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import"./icon.js";import{AutoplayController as e}from"./autoplay-controller.js";import{S as t,L as i,x as s,t as o,r as a,c as r,i as l,n,e as d,a as c}from"./solid-components2.js";import{p as h}from"./
|
|
1
|
+
import"./icon.js";import{AutoplayController as e}from"./autoplay-controller.js";import{S as t,L as i,x as s,t as o,r as a,c as r,i as l,n,e as d,a as c}from"./solid-components2.js";import{p as h}from"./animate.js";import{r as p}from"./state.js";import{ScrollController as u}from"./scroll-controller.js";import{w as g}from"./watch.js";import{I as v}from"./interactive.js";import b from"./carousel-item.js";var m=Object.defineProperty,y=Object.getOwnPropertyDescriptor,f=(e,t,i,s)=>{for(var o,a=s>1?void 0:s?y(t,i):t,r=e.length-1;r>=0;r--)(o=e[r])&&(a=(s?o(t,i,a):o(a))||a);return s&&a&&m(t,i,a),a};let w=class extends t{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 u(this),this.slides=this.getElementsByTagName("sd-carousel-item"),this.intersectionObserverEntries=new Map,this.localize=new i(this),this.handleSlotChange=e=>{e.some((e=>[...e.addedNodes,...e.removedNodes].some((e=>b.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,a="ArrowUp"===e.key||!i&&"ArrowLeft"===e.key||i&&"ArrowRight"===e.key;e.preventDefault(),a&&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,a=this.getSlides(),r=this.getSlides({excludeClones:!1}),l=(e+a.length)%a.length;this.activeSlide=l;const n=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
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./button.js";import"./icon.js";import{a as e,s,w as i}from"./event.js";import{S as h,L as d,x as a,t as n,c as o,r as t,i as l,e as r,n as p,a as c}from"./solid-components2.js";import{g as m,s as g}from"./animation-registry.js";import{H as f}from"./slot.js";import{l as y,u as v}from"./scroll.js";import{w as x}from"./watch.js";import{M as u}from"./modal.js";var z=Object.defineProperty,b=Object.getOwnPropertyDescriptor,w=(e,s,i,h)=>{for(var d,a=h>1?void 0:h?b(s,i):s,n=e.length-1;n>=0;n--)(d=e[n])&&(a=(h?d(s,i,a):d(a))||a);return h&&a&&z(s,i,a),a};let k=class extends h{constructor(){super(...arguments),this.hasSlotController=new f(this,"footer"),this.localize=new d(this),this.open=!1,this.headline="",this.noCloseButton=!1}connectedCallback(){super.connectedCallback(),this.handleDocumentKeyDown=this.handleDocumentKeyDown.bind(this),this.modal=new u(this)}firstUpdated(){this.dialog.hidden=!this.open,this.open&&(this.addOpenListeners(),this.modal.activate(),y(this))}disconnectedCallback(){super.disconnectedCallback(),v(this)}requestClose(s){if(this.emit("sd-request-close",{cancelable:!0,detail:{source:s}}).defaultPrevented){const s=m(this,"dialog.denyClose",{dir:this.localize.dir()});e(this.panel,s.keyframes,s.options)}else this.hide()}addOpenListeners(){document.addEventListener("keydown",this.handleDocumentKeyDown)}removeOpenListeners(){document.removeEventListener("keydown",this.handleDocumentKeyDown)}handleDocumentKeyDown(e){this.open&&"Escape"===e.key&&(e.stopPropagation(),this.requestClose("keyboard"))}async handleOpenChange(){if(this.open){this.emit("sd-show"),this.addOpenListeners(),this.originalTrigger=document.activeElement,this.modal.activate(),y(this);const i=this.querySelector("[autofocus]");i&&i.removeAttribute("autofocus"),await Promise.all([s(this.dialog),s(this.overlay)]),this.dialog.hidden=!1,requestAnimationFrame((()=>{this.emit("sd-initial-focus",{cancelable:!0}).defaultPrevented||(i?i.focus({preventScroll:!0}):this.panel.focus({preventScroll:!0})),i&&i.setAttribute("autofocus","")}));const h=m(this,"dialog.show",{dir:this.localize.dir()}),d=m(this,"dialog.overlay.show",{dir:this.localize.dir()});await Promise.all([e(this.panel,h.keyframes,h.options),e(this.overlay,d.keyframes,d.options)]),this.emit("sd-after-show")}else{this.emit("sd-hide"),this.removeOpenListeners(),this.modal.deactivate(),await Promise.all([s(this.dialog),s(this.overlay)]);const i=m(this,"dialog.hide",{dir:this.localize.dir()}),h=m(this,"dialog.overlay.hide",{dir:this.localize.dir()});await Promise.all([e(this.overlay,h.keyframes,h.options).then((()=>{this.overlay.hidden=!0})),e(this.panel,i.keyframes,i.options).then((()=>{this.panel.hidden=!0}))]),this.dialog.hidden=!0,this.overlay.hidden=!1,this.panel.hidden=!1,v(this);const d=this.originalTrigger;"function"==typeof(null==d?void 0:d.focus)&&setTimeout((()=>d.focus())),this.emit("sd-after-hide")}}async show(){if(!this.open)return this.open=!0,i(this,"sd-after-show")}async hide(){if(this.open)return this.open=!1,i(this,"sd-after-hide")}render(){return a`<div part="base" class="${n("flex items-center justify-center fixed inset-0 z-dialog",this.hasSlotController.test("footer")&&"dialog--has-footer")}"><div part="overlay" class="fixed inset-0 bg-primary-800 opacity-90" @click="${()=>this.requestClose("overlay")}" tabindex="-1"></div><div part="panel" class="${n("flex flex-col z-20 bg-white focus:outline-none py-4 sm:py-8 relative gap-6",this.open&&"flex opacity-100")}" role="dialog" aria-modal="true" aria-hidden="${this.open?"false":"true"}" aria-label="${this.headline}" aria-labelledby="title" tabindex="0"><header part="header" class="flex flex-grow-0 flex-shrink-0 basis-auto px-6 sm:px-10"><h2 part="title" class="flex-auto m-0" id="title">${this.headline.length>0?a`<h4 class="sd-headline sd-headline--size-3xl leading-tight">${this.headline}</h4>`:a`<slot name="headline"></slot>`}</h2>${this.noCloseButton?"":a`<sd-button part="close-button" variant="tertiary" exportparts="base:close-button__base" class="${n("absolute top-2 right-2")}" name="x-lg" @click="${()=>this.requestClose("close-button")}" type="button"><sd-icon name="close" library="system" color="currentColor"></sd-icon></sd-button>`}</header><main part="body" class="flex flex-auto overflow-auto w-full px-6 sm:px-10"><slot></slot></main><footer part="footer" class="flex flex-grow-0 flex-shrink-0 basis-auto ml-auto gap-4 px-6 sm:px-10"><slot name="footer"></slot></footer></div></div>`}};k.styles=[o,t(".sd-headline,.sd-prose :is(h1,h2,h3,h4,h5){display:flex;font-weight:700;--tw-text-opacity:1;color:rgb(var(--sd-color-primary,0 53 142)/var(--tw-text-opacity))}.sd-headline sd-icon,.sd-prose :is(h1,h2,h3,h4,h5) sd-icon{flex-shrink:0;font-size:3rem;--tw-text-opacity:1;color:rgb(var(--sd-color-primary,0 53 142)/var(--tw-text-opacity))}@media (min-width:640px){.sd-headline sd-icon,.sd-prose :is(h1,h2,h3,h4,h5) sd-icon{margin-top:var(--sd-spacing-2,.5rem)}}.sd-headline.sd-headline,.sd-headline:is(h1):not(.sd-headline),.sd-prose :is(h1,h2,h3,h4,h5).sd-headline,.sd-prose :is(h1,h2,h3,h4,h5):is(h1):not(.sd-headline){font-size:var(--sd-font-size-3xl,2rem);gap:var(--sd-spacing-4,1rem);line-height:var(--sd-line-height-tight,120%)}@media (min-width:640px){.sd-headline.sd-headline,.sd-headline:is(h1):not(.sd-headline),.sd-prose :is(h1,h2,h3,h4,h5).sd-headline,.sd-prose :is(h1,h2,h3,h4,h5):is(h1):not(.sd-headline){font-size:var(--sd-font-size-4xl,2.5rem)}}.sd-headline.sd-headline sd-icon,.sd-headline:is(h1):not(.sd-headline) sd-icon,.sd-prose :is(h1,h2,h3,h4,h5).sd-headline sd-icon,.sd-prose :is(h1,h2,h3,h4,h5):is(h1):not(.sd-headline) sd-icon{margin-top:calc(var(--sd-spacing-1, .25rem)*-1)}@media (min-width:640px){.sd-headline.sd-headline sd-icon,.sd-headline:is(h1):not(.sd-headline) sd-icon,.sd-prose :is(h1,h2,h3,h4,h5).sd-headline sd-icon,.sd-prose :is(h1,h2,h3,h4,h5):is(h1):not(.sd-headline) sd-icon{margin-top:var(--sd-spacing-0,0)}}.sd-headline.sd-headline--size-3xl,.sd-headline:is(h2):not(.sd-headline),.sd-prose :is(h1,h2,h3,h4,h5).sd-headline--size-3xl,.sd-prose :is(h1,h2,h3,h4,h5):is(h2):not(.sd-headline){font-size:var(--sd-font-size-2xl,1.75rem);gap:var(--sd-spacing-4,1rem);line-height:var(--sd-line-height-tight,120%)}@media (min-width:640px){.sd-headline.sd-headline--size-3xl,.sd-headline:is(h2):not(.sd-headline),.sd-prose :is(h1,h2,h3,h4,h5).sd-headline--size-3xl,.sd-prose :is(h1,h2,h3,h4,h5):is(h2):not(.sd-headline){font-size:var(--sd-font-size-3xl,2rem)}}.sd-headline.sd-headline--size-3xl sd-icon,.sd-headline:is(h2):not(.sd-headline) sd-icon,.sd-prose :is(h1,h2,h3,h4,h5).sd-headline--size-3xl sd-icon,.sd-prose :is(h1,h2,h3,h4,h5):is(h2):not(.sd-headline) sd-icon{margin-top:calc(var(--sd-spacing-1, .25rem)*-1)}@media (min-width:640px){.sd-headline.sd-headline--size-3xl sd-icon,.sd-headline:is(h2):not(.sd-headline) sd-icon,.sd-prose :is(h1,h2,h3,h4,h5).sd-headline--size-3xl sd-icon,.sd-prose :is(h1,h2,h3,h4,h5):is(h2):not(.sd-headline) sd-icon{margin-top:var(--sd-spacing-0,0)}}.sd-headline.sd-headline--size-base,.sd-headline.sd-headline--size-lg,.sd-headline.sd-headline--size-xl,.sd-headline:is(h3,h4,h5):not(.sd-headline),.sd-prose :is(h1,h2,h3,h4,h5).sd-headline--size-base,.sd-prose :is(h1,h2,h3,h4,h5).sd-headline--size-lg,.sd-prose :is(h1,h2,h3,h4,h5).sd-headline--size-xl,.sd-prose :is(h1,h2,h3,h4,h5):is(h3,h4,h5):not(.sd-headline){gap:var(--sd-spacing-2,.5rem);--tw-text-opacity:1;color:rgb(var(--sd-color-black,24 24 24)/var(--tw-text-opacity))}.sd-headline.sd-headline--size-base sd-icon,.sd-headline.sd-headline--size-lg sd-icon,.sd-headline.sd-headline--size-xl sd-icon,.sd-headline:is(h3,h4,h5):not(.sd-headline) sd-icon,.sd-prose :is(h1,h2,h3,h4,h5).sd-headline--size-base sd-icon,.sd-prose :is(h1,h2,h3,h4,h5).sd-headline--size-lg sd-icon,.sd-prose :is(h1,h2,h3,h4,h5).sd-headline--size-xl sd-icon,.sd-prose :is(h1,h2,h3,h4,h5):is(h3,h4,h5):not(.sd-headline) sd-icon{font-size:2rem}.sd-headline.sd-headline--size-xl,.sd-headline:is(h3):not(.sd-headline),.sd-prose :is(h1,h2,h3,h4,h5).sd-headline--size-xl,.sd-prose :is(h1,h2,h3,h4,h5):is(h3):not(.sd-headline){font-size:var(--sd-font-size-xl,1.5rem)}.sd-headline.sd-headline--size-xl sd-icon,.sd-headline:is(h3):not(.sd-headline) sd-icon,.sd-prose :is(h1,h2,h3,h4,h5).sd-headline--size-xl sd-icon,.sd-prose :is(h1,h2,h3,h4,h5):is(h3):not(.sd-headline) sd-icon{margin-top:var(--sd-spacing-0-5,.125rem)}@media (min-width:640px){.sd-headline.sd-headline--size-xl sd-icon,.sd-headline:is(h3):not(.sd-headline) sd-icon,.sd-prose :is(h1,h2,h3,h4,h5).sd-headline--size-xl sd-icon,.sd-prose :is(h1,h2,h3,h4,h5):is(h3):not(.sd-headline) sd-icon{margin-top:var(--sd-spacing-0-5,.125rem)}}.sd-headline.sd-headline--size-base,.sd-headline.sd-headline--size-lg,.sd-headline:is(h4,h5):not(.sd-headline),.sd-prose :is(h1,h2,h3,h4,h5).sd-headline--size-base,.sd-prose :is(h1,h2,h3,h4,h5).sd-headline--size-lg,.sd-prose :is(h1,h2,h3,h4,h5):is(h4,h5):not(.sd-headline){line-height:var(--sd-line-height-normal,150%)}.sd-headline.sd-headline--size-lg,.sd-headline:is(h4),.sd-prose :is(h1,h2,h3,h4,h5).sd-headline--size-lg,.sd-prose :is(h1,h2,h3,h4,h5):is(h4){font-size:var(--sd-font-size-lg,1.25rem)}.sd-headline.sd-headline--size-lg sd-icon,.sd-headline:is(h4) sd-icon,.sd-prose :is(h1,h2,h3,h4,h5).sd-headline--size-lg sd-icon,.sd-prose :is(h1,h2,h3,h4,h5):is(h4) sd-icon{margin-top:var(--sd-spacing-0,0)}@media (min-width:640px){.sd-headline.sd-headline--size-lg sd-icon,.sd-headline:is(h4) sd-icon,.sd-prose :is(h1,h2,h3,h4,h5).sd-headline--size-lg sd-icon,.sd-prose :is(h1,h2,h3,h4,h5):is(h4) sd-icon{margin-top:var(--sd-spacing-0,0)}}.sd-headline.sd-headline--size-base,.sd-headline:is(h5):not(.sd-headline),.sd-prose :is(h1,h2,h3,h4,h5).sd-headline--size-base,.sd-prose :is(h1,h2,h3,h4,h5):is(h5):not(.sd-headline){font-size:var(--sd-font-size-base,1rem)}.sd-headline.sd-headline--size-base sd-icon,.sd-headline:is(h5):not(.sd-headline) sd-icon,.sd-prose :is(h1,h2,h3,h4,h5).sd-headline--size-base sd-icon,.sd-prose :is(h1,h2,h3,h4,h5):is(h5):not(.sd-headline) sd-icon{margin-top:calc(var(--sd-spacing-1, .25rem)*-1)}.sd-headline.sd-headline--size-base mark,.sd-headline:is(h5):not(.sd-headline) mark,.sd-prose :is(h1,h2,h3,h4,h5).sd-headline--size-base mark,.sd-prose :is(h1,h2,h3,h4,h5):is(h5):not(.sd-headline) mark{color:inherit}.sd-headline--inline{display:inline-block}.sd-headline--inline sd-icon{margin-right:var(--sd-spacing-2,.5rem);margin-top:calc(var(--sd-spacing-1, .25rem)*-1);vertical-align:middle}.sd-headline--inline:is(.sd-headline--size-xl,.sd-headline--size-lg,.sd-headline--size-base) sd-icon{margin-right:var(--sd-spacing-0-5,.125rem)}.sd-headline--inverted:not(#\\\t),.sd-prose--inverted :is(h1,h2,h3,h4,h5):not(.sd-headline):not(#\\\t){--tw-text-opacity:1;color:rgb(var(--sd-color-white,255 255 255)/var(--tw-text-opacity))}.sd-headline--inverted:not(#\\\t) sd-icon,.sd-prose--inverted :is(h1,h2,h3,h4,h5):not(.sd-headline):not(#\\\t) sd-icon{--tw-text-opacity:1;color:rgb(var(--sd-color-white,255 255 255)/var(--tw-text-opacity))}"),h.styles,l`:host{--width:662px}[part=panel]{width:var(--width);max-height:80vh}[part=body]{-webkit-overflow-scrolling:touch}@media (max-width:414px){:host{--width:335px}[part=footer]{width:100%}}`],w([r('[part="base"]')],k.prototype,"dialog",2),w([r('[part="panel"]')],k.prototype,"panel",2),w([r('[part="overlay"]')],k.prototype,"overlay",2),w([p({type:Boolean,reflect:!0})],k.prototype,"open",2),w([p({reflect:!0})],k.prototype,"headline",2),w([p({attribute:"no-close-button",type:Boolean,reflect:!0})],k.prototype,"noCloseButton",2),w([x("open",{waitUntilFirstUpdate:!0})],k.prototype,"handleOpenChange",1),k=w([c("sd-dialog")],k),g("dialog.show",{keyframes:[{opacity:0,scale:.8},{opacity:1,scale:1}],options:{duration:250,easing:"ease"}}),g("dialog.hide",{keyframes:[{opacity:1,scale:1},{opacity:0,scale:.8}],options:{duration:250,easing:"ease"}}),g("dialog.denyClose",{keyframes:[{scale:1},{scale:1.02},{scale:1}],options:{duration:250}}),g("dialog.overlay.show",{keyframes:[{opacity:0},{opacity:1}],options:{duration:250}}),g("dialog.overlay.hide",{keyframes:[{opacity:1},{opacity:0}],options:{duration:250}});export{k as default};
|
|
1
|
+
import"./button.js";import"./icon.js";import{a as e,s}from"./animate.js";import{S as i,L as h,x as d,t as a,c as n,r as o,i as t,e as l,n as r,a as p}from"./solid-components2.js";import{g as c,s as m}from"./animation-registry.js";import{H as g}from"./slot.js";import{l as f,u as y}from"./scroll.js";import{w as v}from"./event.js";import{w as x}from"./watch.js";import{M as u}from"./modal.js";var z=Object.defineProperty,b=Object.getOwnPropertyDescriptor,w=(e,s,i,h)=>{for(var d,a=h>1?void 0:h?b(s,i):s,n=e.length-1;n>=0;n--)(d=e[n])&&(a=(h?d(s,i,a):d(a))||a);return h&&a&&z(s,i,a),a};let k=class extends i{constructor(){super(...arguments),this.hasSlotController=new g(this,"footer"),this.localize=new h(this),this.open=!1,this.headline="",this.noCloseButton=!1}connectedCallback(){super.connectedCallback(),this.handleDocumentKeyDown=this.handleDocumentKeyDown.bind(this),this.modal=new u(this)}firstUpdated(){this.dialog.hidden=!this.open,this.open&&(this.addOpenListeners(),this.modal.activate(),f(this))}disconnectedCallback(){super.disconnectedCallback(),y(this)}requestClose(s){if(this.emit("sd-request-close",{cancelable:!0,detail:{source:s}}).defaultPrevented){const s=c(this,"dialog.denyClose",{dir:this.localize.dir()});e(this.panel,s.keyframes,s.options)}else this.hide()}addOpenListeners(){document.addEventListener("keydown",this.handleDocumentKeyDown)}removeOpenListeners(){document.removeEventListener("keydown",this.handleDocumentKeyDown)}handleDocumentKeyDown(e){this.open&&"Escape"===e.key&&(e.stopPropagation(),this.requestClose("keyboard"))}async handleOpenChange(){if(this.open){this.emit("sd-show"),this.addOpenListeners(),this.originalTrigger=document.activeElement,this.modal.activate(),f(this);const i=this.querySelector("[autofocus]");i&&i.removeAttribute("autofocus"),await Promise.all([s(this.dialog),s(this.overlay)]),this.dialog.hidden=!1,requestAnimationFrame((()=>{this.emit("sd-initial-focus",{cancelable:!0}).defaultPrevented||(i?i.focus({preventScroll:!0}):this.panel.focus({preventScroll:!0})),i&&i.setAttribute("autofocus","")}));const h=c(this,"dialog.show",{dir:this.localize.dir()}),d=c(this,"dialog.overlay.show",{dir:this.localize.dir()});await Promise.all([e(this.panel,h.keyframes,h.options),e(this.overlay,d.keyframes,d.options)]),this.emit("sd-after-show")}else{this.emit("sd-hide"),this.removeOpenListeners(),this.modal.deactivate(),await Promise.all([s(this.dialog),s(this.overlay)]);const i=c(this,"dialog.hide",{dir:this.localize.dir()}),h=c(this,"dialog.overlay.hide",{dir:this.localize.dir()});await Promise.all([e(this.overlay,h.keyframes,h.options).then((()=>{this.overlay.hidden=!0})),e(this.panel,i.keyframes,i.options).then((()=>{this.panel.hidden=!0}))]),this.dialog.hidden=!0,this.overlay.hidden=!1,this.panel.hidden=!1,y(this);const d=this.originalTrigger;"function"==typeof(null==d?void 0:d.focus)&&setTimeout((()=>d.focus())),this.emit("sd-after-hide")}}async show(){if(!this.open)return this.open=!0,v(this,"sd-after-show")}async hide(){if(this.open)return this.open=!1,v(this,"sd-after-hide")}render(){return d`<div part="base" class="${a("flex items-center justify-center fixed inset-0 z-dialog",this.hasSlotController.test("footer")&&"dialog--has-footer")}"><div part="overlay" class="fixed inset-0 bg-primary-800 opacity-90" @click="${()=>this.requestClose("overlay")}" tabindex="-1"></div><div part="panel" class="${a("flex flex-col z-20 bg-white focus:outline-none py-4 sm:py-8 relative gap-6",this.open&&"flex opacity-100")}" role="dialog" aria-modal="true" aria-hidden="${this.open?"false":"true"}" aria-label="${this.headline}" aria-labelledby="title" tabindex="0"><header part="header" class="flex flex-grow-0 flex-shrink-0 basis-auto px-6 sm:px-10"><h2 part="title" class="flex-auto m-0" id="title">${this.headline.length>0?d`<h4 class="sd-headline sd-headline--size-3xl leading-tight">${this.headline}</h4>`:d`<slot name="headline"></slot>`}</h2>${this.noCloseButton?"":d`<sd-button part="close-button" variant="tertiary" exportparts="base:close-button__base" class="${a("absolute top-2 right-2")}" name="x-lg" @click="${()=>this.requestClose("close-button")}" type="button"><sd-icon name="close" library="system" color="currentColor"></sd-icon></sd-button>`}</header><main part="body" class="flex flex-auto overflow-auto w-full px-6 sm:px-10"><slot></slot></main><footer part="footer" class="flex flex-grow-0 flex-shrink-0 basis-auto ml-auto gap-4 px-6 sm:px-10"><slot name="footer"></slot></footer></div></div>`}};k.styles=[n,o(".sd-headline,.sd-prose :is(h1,h2,h3,h4,h5){display:flex;font-weight:700;--tw-text-opacity:1;color:rgb(var(--sd-color-primary,0 53 142)/var(--tw-text-opacity))}.sd-headline sd-icon,.sd-prose :is(h1,h2,h3,h4,h5) sd-icon{flex-shrink:0;font-size:3rem;--tw-text-opacity:1;color:rgb(var(--sd-color-primary,0 53 142)/var(--tw-text-opacity))}@media (min-width:640px){.sd-headline sd-icon,.sd-prose :is(h1,h2,h3,h4,h5) sd-icon{margin-top:var(--sd-spacing-2,.5rem)}}.sd-headline.sd-headline,.sd-headline:is(h1):not(.sd-headline),.sd-prose :is(h1,h2,h3,h4,h5).sd-headline,.sd-prose :is(h1,h2,h3,h4,h5):is(h1):not(.sd-headline){font-size:var(--sd-font-size-3xl,2rem);gap:var(--sd-spacing-4,1rem);line-height:var(--sd-line-height-tight,120%)}@media (min-width:640px){.sd-headline.sd-headline,.sd-headline:is(h1):not(.sd-headline),.sd-prose :is(h1,h2,h3,h4,h5).sd-headline,.sd-prose :is(h1,h2,h3,h4,h5):is(h1):not(.sd-headline){font-size:var(--sd-font-size-4xl,2.5rem)}}.sd-headline.sd-headline sd-icon,.sd-headline:is(h1):not(.sd-headline) sd-icon,.sd-prose :is(h1,h2,h3,h4,h5).sd-headline sd-icon,.sd-prose :is(h1,h2,h3,h4,h5):is(h1):not(.sd-headline) sd-icon{margin-top:calc(var(--sd-spacing-1, .25rem)*-1)}@media (min-width:640px){.sd-headline.sd-headline sd-icon,.sd-headline:is(h1):not(.sd-headline) sd-icon,.sd-prose :is(h1,h2,h3,h4,h5).sd-headline sd-icon,.sd-prose :is(h1,h2,h3,h4,h5):is(h1):not(.sd-headline) sd-icon{margin-top:var(--sd-spacing-0,0)}}.sd-headline.sd-headline--size-3xl,.sd-headline:is(h2):not(.sd-headline),.sd-prose :is(h1,h2,h3,h4,h5).sd-headline--size-3xl,.sd-prose :is(h1,h2,h3,h4,h5):is(h2):not(.sd-headline){font-size:var(--sd-font-size-2xl,1.75rem);gap:var(--sd-spacing-4,1rem);line-height:var(--sd-line-height-tight,120%)}@media (min-width:640px){.sd-headline.sd-headline--size-3xl,.sd-headline:is(h2):not(.sd-headline),.sd-prose :is(h1,h2,h3,h4,h5).sd-headline--size-3xl,.sd-prose :is(h1,h2,h3,h4,h5):is(h2):not(.sd-headline){font-size:var(--sd-font-size-3xl,2rem)}}.sd-headline.sd-headline--size-3xl sd-icon,.sd-headline:is(h2):not(.sd-headline) sd-icon,.sd-prose :is(h1,h2,h3,h4,h5).sd-headline--size-3xl sd-icon,.sd-prose :is(h1,h2,h3,h4,h5):is(h2):not(.sd-headline) sd-icon{margin-top:calc(var(--sd-spacing-1, .25rem)*-1)}@media (min-width:640px){.sd-headline.sd-headline--size-3xl sd-icon,.sd-headline:is(h2):not(.sd-headline) sd-icon,.sd-prose :is(h1,h2,h3,h4,h5).sd-headline--size-3xl sd-icon,.sd-prose :is(h1,h2,h3,h4,h5):is(h2):not(.sd-headline) sd-icon{margin-top:var(--sd-spacing-0,0)}}.sd-headline.sd-headline--size-base,.sd-headline.sd-headline--size-lg,.sd-headline.sd-headline--size-xl,.sd-headline:is(h3,h4,h5):not(.sd-headline),.sd-prose :is(h1,h2,h3,h4,h5).sd-headline--size-base,.sd-prose :is(h1,h2,h3,h4,h5).sd-headline--size-lg,.sd-prose :is(h1,h2,h3,h4,h5).sd-headline--size-xl,.sd-prose :is(h1,h2,h3,h4,h5):is(h3,h4,h5):not(.sd-headline){gap:var(--sd-spacing-2,.5rem);--tw-text-opacity:1;color:rgb(var(--sd-color-black,24 24 24)/var(--tw-text-opacity))}.sd-headline.sd-headline--size-base sd-icon,.sd-headline.sd-headline--size-lg sd-icon,.sd-headline.sd-headline--size-xl sd-icon,.sd-headline:is(h3,h4,h5):not(.sd-headline) sd-icon,.sd-prose :is(h1,h2,h3,h4,h5).sd-headline--size-base sd-icon,.sd-prose :is(h1,h2,h3,h4,h5).sd-headline--size-lg sd-icon,.sd-prose :is(h1,h2,h3,h4,h5).sd-headline--size-xl sd-icon,.sd-prose :is(h1,h2,h3,h4,h5):is(h3,h4,h5):not(.sd-headline) sd-icon{font-size:2rem}.sd-headline.sd-headline--size-xl,.sd-headline:is(h3):not(.sd-headline),.sd-prose :is(h1,h2,h3,h4,h5).sd-headline--size-xl,.sd-prose :is(h1,h2,h3,h4,h5):is(h3):not(.sd-headline){font-size:var(--sd-font-size-xl,1.5rem)}.sd-headline.sd-headline--size-xl sd-icon,.sd-headline:is(h3):not(.sd-headline) sd-icon,.sd-prose :is(h1,h2,h3,h4,h5).sd-headline--size-xl sd-icon,.sd-prose :is(h1,h2,h3,h4,h5):is(h3):not(.sd-headline) sd-icon{margin-top:var(--sd-spacing-0-5,.125rem)}@media (min-width:640px){.sd-headline.sd-headline--size-xl sd-icon,.sd-headline:is(h3):not(.sd-headline) sd-icon,.sd-prose :is(h1,h2,h3,h4,h5).sd-headline--size-xl sd-icon,.sd-prose :is(h1,h2,h3,h4,h5):is(h3):not(.sd-headline) sd-icon{margin-top:var(--sd-spacing-0-5,.125rem)}}.sd-headline.sd-headline--size-base,.sd-headline.sd-headline--size-lg,.sd-headline:is(h4,h5):not(.sd-headline),.sd-prose :is(h1,h2,h3,h4,h5).sd-headline--size-base,.sd-prose :is(h1,h2,h3,h4,h5).sd-headline--size-lg,.sd-prose :is(h1,h2,h3,h4,h5):is(h4,h5):not(.sd-headline){line-height:var(--sd-line-height-normal,150%)}.sd-headline.sd-headline--size-lg,.sd-headline:is(h4),.sd-prose :is(h1,h2,h3,h4,h5).sd-headline--size-lg,.sd-prose :is(h1,h2,h3,h4,h5):is(h4){font-size:var(--sd-font-size-lg,1.25rem)}.sd-headline.sd-headline--size-lg sd-icon,.sd-headline:is(h4) sd-icon,.sd-prose :is(h1,h2,h3,h4,h5).sd-headline--size-lg sd-icon,.sd-prose :is(h1,h2,h3,h4,h5):is(h4) sd-icon{margin-top:var(--sd-spacing-0,0)}@media (min-width:640px){.sd-headline.sd-headline--size-lg sd-icon,.sd-headline:is(h4) sd-icon,.sd-prose :is(h1,h2,h3,h4,h5).sd-headline--size-lg sd-icon,.sd-prose :is(h1,h2,h3,h4,h5):is(h4) sd-icon{margin-top:var(--sd-spacing-0,0)}}.sd-headline.sd-headline--size-base,.sd-headline:is(h5):not(.sd-headline),.sd-prose :is(h1,h2,h3,h4,h5).sd-headline--size-base,.sd-prose :is(h1,h2,h3,h4,h5):is(h5):not(.sd-headline){font-size:var(--sd-font-size-base,1rem)}.sd-headline.sd-headline--size-base sd-icon,.sd-headline:is(h5):not(.sd-headline) sd-icon,.sd-prose :is(h1,h2,h3,h4,h5).sd-headline--size-base sd-icon,.sd-prose :is(h1,h2,h3,h4,h5):is(h5):not(.sd-headline) sd-icon{margin-top:calc(var(--sd-spacing-1, .25rem)*-1)}.sd-headline.sd-headline--size-base mark,.sd-headline:is(h5):not(.sd-headline) mark,.sd-prose :is(h1,h2,h3,h4,h5).sd-headline--size-base mark,.sd-prose :is(h1,h2,h3,h4,h5):is(h5):not(.sd-headline) mark{color:inherit}.sd-headline--inline{display:inline-block}.sd-headline--inline sd-icon{margin-right:var(--sd-spacing-2,.5rem);margin-top:calc(var(--sd-spacing-1, .25rem)*-1);vertical-align:middle}.sd-headline--inline:is(.sd-headline--size-xl,.sd-headline--size-lg,.sd-headline--size-base) sd-icon{margin-right:var(--sd-spacing-0-5,.125rem)}.sd-headline--inverted:not(#\\\t),.sd-prose--inverted :is(h1,h2,h3,h4,h5):not(.sd-headline):not(#\\\t){--tw-text-opacity:1;color:rgb(var(--sd-color-white,255 255 255)/var(--tw-text-opacity))}.sd-headline--inverted:not(#\\\t) sd-icon,.sd-prose--inverted :is(h1,h2,h3,h4,h5):not(.sd-headline):not(#\\\t) sd-icon{--tw-text-opacity:1;color:rgb(var(--sd-color-white,255 255 255)/var(--tw-text-opacity))}"),i.styles,t`:host{--width:662px}[part=panel]{width:var(--width);max-height:80vh}[part=body]{-webkit-overflow-scrolling:touch}@media (max-width:414px){:host{--width:335px}[part=footer]{width:100%}}`],w([l('[part="base"]')],k.prototype,"dialog",2),w([l('[part="panel"]')],k.prototype,"panel",2),w([l('[part="overlay"]')],k.prototype,"overlay",2),w([r({type:Boolean,reflect:!0})],k.prototype,"open",2),w([r({reflect:!0})],k.prototype,"headline",2),w([r({attribute:"no-close-button",type:Boolean,reflect:!0})],k.prototype,"noCloseButton",2),w([x("open",{waitUntilFirstUpdate:!0})],k.prototype,"handleOpenChange",1),k=w([p("sd-dialog")],k),m("dialog.show",{keyframes:[{opacity:0,scale:.8},{opacity:1,scale:1}],options:{duration:250,easing:"ease"}}),m("dialog.hide",{keyframes:[{opacity:1,scale:1},{opacity:0,scale:.8}],options:{duration:250,easing:"ease"}}),m("dialog.denyClose",{keyframes:[{scale:1},{scale:1.02},{scale:1}],options:{duration:250}}),m("dialog.overlay.show",{keyframes:[{opacity:0},{opacity:1}],options:{duration:250}}),m("dialog.overlay.hide",{keyframes:[{opacity:1},{opacity:0}],options:{duration:250}});export{k as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./button.js";import"./icon.js";import{a as e,s as t
|
|
1
|
+
import"./button.js";import"./icon.js";import{a as e,s as t}from"./animate.js";import{S as a,L as s,x as o,t as i,c as r,i as n,e as l,n as d,a as h}from"./solid-components2.js";import{g as p,s as c}from"./animation-registry.js";import{H as y}from"./slot.js";import{o as m}from"./if-defined.js";import{l as f,u}from"./scroll.js";import{w}from"./event.js";import{w as v}from"./watch.js";import{M as b}from"./modal.js";function g(e){return e.charAt(0).toUpperCase()+e.slice(1)}var k=Object.defineProperty,x=Object.getOwnPropertyDescriptor,j=(e,t,a,s)=>{for(var o,i=s>1?void 0:s?x(t,a):t,r=e.length-1;r>=0;r--)(o=e[r])&&(i=(s?o(t,a,i):o(i))||i);return s&&i&&k(t,a,i),i};let C=class extends a{constructor(){super(...arguments),this.hasSlotController=new y(this,"footer"),this.localize=new s(this),this.modal=new b(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(),f(this)))}disconnectedCallback(){super.disconnectedCallback(),u(this)}requestClose(t){if(this.emit("sd-request-close",{cancelable:!0,detail:{source:t}}).defaultPrevented){const t=p(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(),f(this));const a=this.querySelector("[autofocus]");a&&a.removeAttribute("autofocus"),await Promise.all([t(this.drawer),t(this.overlay)]),this.drawer.hidden=!1,requestAnimationFrame((()=>{this.emit("sd-initial-focus",{cancelable:!0}).defaultPrevented||(a?a.focus({preventScroll:!0}):this.panel.focus({preventScroll:!0})),a&&a.setAttribute("autofocus","")}));const s=p(this,`drawer.show${g(this.placement)}`,{dir:this.localize.dir()}),o=p(this,"drawer.overlay.show",{dir:this.localize.dir()});await Promise.all([e(this.panel,s.keyframes,s.options),e(this.overlay,o.keyframes,o.options)]),this.emit("sd-after-show")}else{this.emit("sd-hide"),this.removeOpenListeners(),this.contained||(this.modal.deactivate(),u(this)),await Promise.all([t(this.drawer),t(this.overlay)]);const a=p(this,`drawer.hide${g(this.placement)}`,{dir:this.localize.dir()}),s=p(this,"drawer.overlay.hide",{dir:this.localize.dir()});await Promise.all([e(this.overlay,s.keyframes,s.options).then((()=>{this.overlay.hidden=!0})),e(this.panel,a.keyframes,a.options).then((()=>{this.panel.hidden=!0}))]),this.drawer.hidden=!0,this.overlay.hidden=!1,this.panel.hidden=!1;const o=this.originalTrigger;"function"==typeof(null==o?void 0:o.focus)&&setTimeout((()=>o.focus())),this.emit("sd-after-hide")}}handleNoModalChange(){this.open&&!this.contained&&(this.modal.activate(),f(this)),this.open&&this.contained&&(this.modal.deactivate(),u(this))}async show(){if(!this.open)return this.open=!0,w(this,"sd-after-show")}async hide(){if(this.open)return this.open=!1,w(this,"sd-after-hide")}render(){return o`<div part="base" class="${i("top-0 start-0 w-full h-full pointer-events-none overflow-hidden",this.contained?"absolute":"fixed")}"><div part="overlay" class="${i("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="${i("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="${m(this.noHeader?void 0:"title")}" tabindex="0">${this.noHeader?"":o`<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-button variant="tertiary" size="lg" part="close-button" @click="${()=>this.requestClose("close-button")}"><sd-icon name="close" library="system"></sd-icon></sd-button></div></header>`}<div part="body" class="flex-auto block px-4"><slot></slot></div><footer part="footer" class="${i(this.hasSlotController.test("footer")?"text-left p-4":"hidden")}"><slot name="footer"></slot></footer></div></div>`}};C.styles=[a.styles,r,n`:host{--width:25rem;display:contents}:host([contained]){z-index:initial}:host(:not([contained])){z-index:var(--sd-z-index-drawer,700)}[part=body]{-webkit-overflow-scrolling:touch;overflow-y:scroll;scrollbar-width:none}[part=body]::-webkit-scrollbar{height:var(--sd-spacing-0,0);width:var(--sd-spacing-0,0)}`],j([l("[part=base]")],C.prototype,"drawer",2),j([l("[part=panel]")],C.prototype,"panel",2),j([l("[part=overlay]")],C.prototype,"overlay",2),j([d({type:Boolean,reflect:!0})],C.prototype,"open",2),j([d({attribute:"label",reflect:!0})],C.prototype,"label",2),j([d({reflect:!0})],C.prototype,"placement",2),j([d({type:Boolean,reflect:!0})],C.prototype,"contained",2),j([d({attribute:"no-header",type:Boolean})],C.prototype,"noHeader",2),j([v("open",{waitUntilFirstUpdate:!0})],C.prototype,"handleOpenChange",1),j([v("contained",{waitUntilFirstUpdate:!0})],C.prototype,"handleNoModalChange",1),C=j([h("sd-drawer")],C),c("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"}}),c("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"}}),c("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"}}),c("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"}}),c("drawer.denyClose",{keyframes:[{scale:1},{scale:1.01},{scale:1}],options:{duration:250}}),c("drawer.overlay.show",{keyframes:[{opacity:0},{opacity:1}],options:{duration:250}}),c("drawer.overlay.hide",{keyframes:[{opacity:1},{opacity:0}],options:{duration:250}});export{C as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{S as e,L as t,x as n,t as i,c as o,i as s,e as a,n as r,a as d}from"./solid-components2.js";import{
|
|
1
|
+
import{S as e,L as t,x as n,t as i,c as o,i as s,e as a,n as r,a as d}from"./solid-components2.js";import{s as l,a as p}from"./animate.js";import{g as h,s as c}from"./animation-registry.js";import{g as u}from"./tabbable.js";import{s as m}from"./scroll.js";import{w as g}from"./event.js";import{w}from"./watch.js";var y=Object.defineProperty,v=Object.getOwnPropertyDescriptor,f=(e,t,n,i)=>{for(var o,s=i>1?void 0:i?v(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&&y(t,n,s),s};let b=class extends e{constructor(){super(...arguments),this.localize=new t(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,i,o,s,a,r,d,l,p,h;const c=(null==(o=null==(i=null==(n=null==(t=null==(e=document.activeElement)?void 0:e.shadowRoot)?void 0:t.activeElement)?void 0:n.shadowRoot)?void 0:i.activeElement)?void 0:o.getRootNode())instanceof ShadowRoot?null==(d=null==(r=null==(a=null==(s=document.activeElement)?void 0:s.shadowRoot)?void 0:a.activeElement)?void 0:r.shadowRoot)?void 0:d.activeElement:(null==(l=this.containingElement)?void 0:l.getRootNode())instanceof ShadowRoot?null==(h=null==(p=document.activeElement)?void 0:p.shadowRoot)?void 0:h.activeElement:document.activeElement;(!this.containingElement||(null==c?void 0:c.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;m(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=>u(e).start));let t;if(e){switch(e.tagName.toLowerCase()){case"sd-button":case"sd-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,g(this,"sd-after-show")}async hide(){if(this.open)return this.open=!1,g(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 l(this),this.panel.hidden=!1,this.popup.active=!0;const{keyframes:e,options:t}=h(this,"dropdown.show",{dir:this.localize.dir()});await p(this.popup.popup,e,t),this.emit("sd-after-show")}else{this.emit("sd-hide"),this.removeOpenListeners(),await l(this);const{keyframes:e,options:t}=h(this,"dropdown.hide",{dir:this.localize.dir()});await p(this.popup.popup,e,t),this.panel.hidden=!0,this.popup.active=!1,this.emit("sd-after-hide")}}render(){return n`<sd-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="${i("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-popup>`}};b.styles=[e.styles,o,s`:host{display:inline-block}#dropdown::part(popup){z-index:var(--sd-z-index-dropdown,900)}#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}`],f([a("#dropdown")],b.prototype,"popup",2),f([a("[part=trigger]")],b.prototype,"trigger",2),f([a("[part=panel]")],b.prototype,"panel",2),f([r({type:Boolean,reflect:!0})],b.prototype,"open",2),f([r({type:Boolean,reflect:!0})],b.prototype,"rounded",2),f([r({reflect:!0})],b.prototype,"placement",2),f([r({type:Boolean,reflect:!0})],b.prototype,"disabled",2),f([r({attribute:"stay-open-on-select",type:Boolean,reflect:!0})],b.prototype,"stayOpenOnSelect",2),f([r({attribute:!1})],b.prototype,"containingElement",2),f([r({type:Number})],b.prototype,"distance",2),f([r({type:Number})],b.prototype,"skidding",2),f([r({type:Boolean,reflect:!0,attribute:"no-auto-size"})],b.prototype,"noAutoSize",2),f([r({type:Boolean,reflect:!0,attribute:"no-flip"})],b.prototype,"noFlip",2),f([r({type:Boolean})],b.prototype,"hoist",2),f([w("open",{waitUntilFirstUpdate:!0})],b.prototype,"handleOpenChange",1),b=f([d("sd-dropdown")],b),c("dropdown.show",{keyframes:[{opacity:0,scale:.9},{opacity:1,scale:1}],options:{duration:100,easing:"ease"}}),c("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,n
|
|
1
|
+
function e(e,n){return new Promise((t=>{e.addEventListener(n,(function r(i){i.target===e&&(e.removeEventListener(n,r),t())}))}))}export{e as w};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{S as e,L as t,x as o,t as i,r as s,c as n,i as r,e as a,n as l,a as d}from"./solid-components2.js";import{w as c}from"./event.js";import{w as h}from"./watch.js";import{I as p}from"./interactive.js";var m=Object.defineProperty,g=Object.getOwnPropertyDescriptor,v=(e,t,o,i)=>{for(var s,n=i>1?void 0:i?g(t,o):t,r=e.length-1;r>=0;r--)(s=e[r])&&(n=(i?s(t,o,n):s(n))||n);return i&&n&&m(t,o,n),n};let u=class extends e{constructor(){super(...arguments),this.open=!1,this.inverted=!1,this.localize=new t(this)}updateMaxHeight(){var e;const t=null==(e=this.contentPreview)?void 0:e.scrollHeight.toString();this.style.setProperty("--max-height-pixel",`${t}px`),this.style.setProperty("--max-height",t)}onToggleClick(){this.updateMaxHeight(),this.open=!this.open}onOpenChange(){this.open?(this.emit("sd-show"),this.updateComplete.then((()=>{this.emit("sd-after-show")}))):(this.emit("sd-hide"),this.updateComplete.then((()=>{this.emit("sd-after-hide")}))),this.details.setAttribute("open",this.open.toString())}async show(){if(!this.open)return this.onToggleClick(),c(this,"sd-after-show")}async hide(){if(this.open)return this.onToggleClick(),c(this,"sd-after-hide")}render(){return o`<details part="details"><summary part="summary" aria-hidden="true" class="cursor-pointer overflow-hidden list-none"><slot name="clone"></slot></summary><div part="content" class="content content-preview overflow-hidden relative"><slot></slot></div></details><button part="toggle" class="${i("sd-interactive sd-interactive--reset !h-full !justify-center !w-full !text-base !flex !items-center !underline !underline-offset-2 !toggle",this.inverted&&"sd-interactive--inverted",this.inverted?"!focus-visible:focus-outline-inverted":"!focus-visible:focus-outline")}" @click="${this.onToggleClick}">${this.open?o`<slot name="toggle-open"><sd-icon class="mr-2 text-xl" library="system" name="chevron-up"></sd-icon>${this.localize.term("showLess")}</slot>`:o`<slot name="toggle-closed"><sd-icon class="mr-2 text-xl" library="system" name="chevron-down"></sd-icon>${this.localize.term("showMore")}</slot>`}</button>`}firstUpdated(){this.cloneContentToLightDOM(),this.details.setAttribute("open",this.open.toString())}cloneContentToLightDOM(){const e=document.createElement("div");e.setAttribute("slot","clone"),Array.from(this.childNodes).forEach((t=>{const o=t.cloneNode(!0);e.appendChild(o)})),this.appendChild(e)}};u.styles=[e.styles,s(p),n,r`:host{--gradient-color-start:rgba(255, 255, 255, 0);--gradient-color-end:rgba(255, 255, 255, 1);--component-expandable-max-block-size:90px;--gradient-height:24px;--gradient:var(--gradient-color-start) 0%,var(--gradient-color-end) 80%,var(--gradient-color-end) 100%;position:relative;display:inline-block;width:100%}.toggle::-moz-focus-inner{border-style:none;padding:var(--sd-spacing-0,0)}details>summary::-webkit-details-marker,details[open] summary{display:none}summary{max-block-size:var(--component-expandable-max-block-size)}:host([open]) summary{max-block-size:var(--max-height-pixel,1000vh)}.content{max-block-size:var(--component-expandable-max-block-size)}:host([open]) .content{max-block-size:var(--max-height-pixel,1000vh)}:host(:not([open])) .content::after{position:absolute;bottom:var(--sd-spacing-0,0);left:var(--sd-spacing-0,0);display:block;width:100%;content:' ';height:var(--gradient-height);background:linear-gradient(180deg,var(--gradient))}:host([inverted]:not([open])) .content::after{background:var(--gradient-vertical-transparent-primary,linear-gradient(180deg,rgba(0,53,142,0) 0,#00358e 80%,#00358e 100%))}`],v([a(".content-preview")],u.prototype,"contentPreview",2),v([a("details")],u.prototype,"details",2),v([l({type:Boolean,reflect:!0})],u.prototype,"open",2),v([l({type:Boolean,reflect:!0})],u.prototype,"inverted",2),v([h("open",{waitUntilFirstUpdate:!0})],u.prototype,"onOpenChange",1),u=v([d("sd-expandable")],u);export{u as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as t,a as i
|
|
1
|
+
import{s as t,a as i}from"./animate.js";import{S as e,L as s,x as a,t as o,c as n,i as r,e as d,n as l,a as c}from"./solid-components2.js";import{g as h,s as u}from"./animation-registry.js";import{w as p}from"./event.js";import{w as m}from"./watch.js";var f=Object.defineProperty,b=Object.getOwnPropertyDescriptor,y=(t,i,e,s)=>{for(var a,o=s>1?void 0:s?b(i,e):i,n=t.length-1;n>=0;n--)(a=t[n])&&(o=(s?a(i,e,o):a(o))||o);return s&&o&&f(i,e,o),o};const w=Object.assign(document.createElement("div"),{className:"sd-toast-stack sd-toast-stack--top-right"}),g=Object.assign(document.createElement("div"),{className:"sd-toast-stack sd-toast-stack--bottom-center"});let v=class extends e{constructor(){super(...arguments),this.localize=new s(this),this.open=!1,this.closable=!1,this.variant="info",this.toastStack="top-right",this.duration=1/0,this.durationIndicator=!1,this.remainingDuration=this.duration,this.startTime=Date.now()}firstUpdated(){this.base.hidden=!this.open}startAutoHide(){clearTimeout(this.autoHideTimeout),this.startTime=Date.now(),this.remainingDuration=this.duration,this.open&&this.duration<1/0&&(this.autoHideTimeout=window.setTimeout((()=>this.hide()),this.duration))}onHover(){clearTimeout(this.autoHideTimeout),this.duration<1/0&&(this.remainingDuration-=Date.now()-this.startTime)}onHoverEnd(){this.startTime=Date.now(),clearTimeout(this.autoHideTimeout),this.open&&this.duration<1/0&&(this.autoHideTimeout=window.setTimeout((()=>{this.hide()}),this.remainingDuration))}handleCloseClick(){this.hide()}async handleOpenChange(){if(this.open){this.emit("sd-show"),this.duration<1/0&&this.startAutoHide(),await t(this.base),this.base.hidden=!1;const{keyframes:e,options:s}=h(this,"notification.show",{dir:this.localize.dir()});await i(this.base,e,s),this.emit("sd-after-show")}else{this.emit("sd-hide"),clearTimeout(this.autoHideTimeout),await t(this.base);const{keyframes:e,options:s}=h(this,"notification.hide",{dir:this.localize.dir()});await i(this.base,e,s),this.base.hidden=!0,this.emit("sd-after-hide")}}handleDurationChange(){this.startAutoHide()}async show(){if(!this.open)return this.open=!0,p(this,"sd-after-show")}async hide(){if(this.open)return this.open=!1,p(this,"sd-after-hide")}async toast(){return new Promise((t=>{const i="bottom-center"===this.toastStack?g:w;null===i.parentElement&&document.body.append(i),i.appendChild(this),requestAnimationFrame((()=>{this.clientWidth,this.show()})),this.addEventListener("sd-after-hide",(()=>{i.removeChild(this),t(),null===i.querySelector("sd-notification")&&i.remove()}),{once:!0})}))}render(){return a`<div part="base" class="${o("w-full overflow-hidden flex items-stretch relative m-2")}" role="alert" id="notification" aria-hidden="${this.open?"false":"true"}" @mouseenter="${this.onHover}" @mouseleave="${this.onHoverEnd}"><slot name="icon" part="icon" class="${o("min-w-min flex items-center px-3 justify-center",{info:"bg-info",success:"bg-success",warning:"bg-warning",error:"bg-error"}[this.variant])}"><sd-icon name="${{info:"info-circle",success:"confirm-circle",warning:"exclamation-circle",error:"warning"}[this.variant]||""}" library="system" class="h-6 w-6 text-white"></sd-icon></slot><div part="content" class="${o("h-full w-full p-1 gap-2 flex items-center justify-stretch bg-white","border-solid border-[1px] border-l-0 border-neutral-400")}"><slot part="message" class="block w-full pl-3 py-2" aria-live="polite"></slot>${this.closable?a`<sd-button size="md" variant="tertiary" part="close-button" class="ml-auto flex flex-[0_0_auto] items-stretch" label="${this.localize.term("close")}" @click="${this.handleCloseClick}"><sd-icon name="close" library="system" color="currentColor"></sd-icon></sd-button>`:""}</div>${this.durationIndicator?a`<div part="duration-indicator__elapsed" id="duration-indicator__elapsed" style="${`animation-duration: ${this.duration}ms`}" class="${o("absolute w-0 h-[2px] bottom-0 bg-primary z-10 animate-grow")}"></div><div part="duration-indicator__total" class="w-full h-[2px] bottom-0 absolute bg-neutral-400"></div>`:""}</div>`}};v.styles=[n,e.styles,r`:host{display:contents}#notification:hover #duration-indicator__elapsed{animation-play-state:paused!important}`],y([d('[part~="base"]')],v.prototype,"base",2),y([l({type:Boolean,reflect:!0})],v.prototype,"open",2),y([l({type:Boolean,reflect:!0})],v.prototype,"closable",2),y([l({reflect:!0})],v.prototype,"variant",2),y([l({reflect:!0,attribute:"toast-stack"})],v.prototype,"toastStack",2),y([l({type:Number})],v.prototype,"duration",2),y([l({type:Boolean,reflect:!0,attribute:"duration-indicator"})],v.prototype,"durationIndicator",2),y([m("open",{waitUntilFirstUpdate:!0})],v.prototype,"handleOpenChange",1),y([m("duration")],v.prototype,"handleDurationChange",1),v=y([c("sd-notification")],v),u("notification.show",{keyframes:[{opacity:0,scale:.8},{opacity:1,scale:1}],options:{duration:250,easing:"ease"}}),u("notification.hide",{keyframes:[{opacity:1,scale:1},{opacity:0,scale:.8}],options:{duration:250,easing:"ease"}});export{v as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as t}from"./debounce.js";import{p as e
|
|
1
|
+
import{d as t}from"./debounce.js";import{p as e}from"./animate.js";import{w as o}from"./event.js";var n=Object.defineProperty,s=Object.getOwnPropertyDescriptor;class r{constructor(t){this.pointers=new Set,this.dragging=!1,this.scrolling=!1,this.mouseDragging=!1,this.handleScroll=()=>{this.scrolling||(this.scrolling=!0,this.host.requestUpdate()),this.handleScrollEnd()},this.handlePointerDown=t=>{"touch"!==t.pointerType&&(this.pointers.add(t.pointerId),this.mouseDragging&&!this.dragging&&0===t.button&&(t.preventDefault(),this.host.scrollContainer.addEventListener("pointermove",this.handlePointerMove)))},this.handlePointerMove=t=>{const e=this.host.scrollContainer,o=!!t.movementX||!!t.movementY;!this.dragging&&o?(e.setPointerCapture(t.pointerId),this.handleDragStart()):e.hasPointerCapture(t.pointerId)&&this.handleDrag(t)},this.handlePointerUp=t=>{this.pointers.delete(t.pointerId),this.host.scrollContainer.releasePointerCapture(t.pointerId),0===this.pointers.size&&this.handleDragEnd()},this.handleTouchEnd=t=>{for(const e of t.changedTouches)this.pointers.delete(e.identifier)},this.handleTouchStart=t=>{for(const e of t.touches)this.pointers.add(e.identifier)},this.host=t,t.addController(this)}async hostConnected(){const t=this.host;await t.updateComplete;const e=t.scrollContainer;e.addEventListener("scroll",this.handleScroll,{passive:!0}),e.addEventListener("pointerdown",this.handlePointerDown),e.addEventListener("pointerup",this.handlePointerUp),e.addEventListener("pointercancel",this.handlePointerUp),e.addEventListener("touchstart",this.handleTouchStart,{passive:!0}),e.addEventListener("touchend",this.handleTouchEnd)}hostDisconnected(){const t=this.host.scrollContainer;t.removeEventListener("scroll",this.handleScroll),t.removeEventListener("pointerdown",this.handlePointerDown),t.removeEventListener("pointerup",this.handlePointerUp),t.removeEventListener("pointercancel",this.handlePointerUp),t.removeEventListener("touchstart",this.handleTouchStart),t.removeEventListener("touchend",this.handleTouchEnd)}handleScrollEnd(){this.pointers.size?this.handleScrollEnd():(this.scrolling=!1,this.host.scrollContainer.dispatchEvent(new CustomEvent("scrollend",{bubbles:!1,cancelable:!1})),this.host.requestUpdate())}handleDragStart(){const t=this.host;this.dragging=!0,t.scrollContainer.style.setProperty("scroll-snap-type","unset"),t.requestUpdate()}handleDrag(t){this.host.scrollContainer.scrollBy({left:-t.movementX,top:-t.movementY})}async handleDragEnd(){const t=this.host,n=t.scrollContainer;n.removeEventListener("pointermove",this.handlePointerMove),this.dragging=!1;const s=n.scrollLeft,r=n.scrollTop;n.style.removeProperty("scroll-snap-type");const i=n.scrollLeft,l=n.scrollTop;n.style.setProperty("scroll-snap-type","unset"),n.scrollTo({left:s,top:r,behavior:"auto"}),n.scrollTo({left:i,top:l,behavior:e()?"auto":"smooth"}),this.scrolling&&await o(n,"scrollend"),n.style.removeProperty("scroll-snap-type"),t.requestUpdate()}}((t,e,o,r)=>{for(var i,l=s(e,o),h=t.length-1;h>=0;h--)(i=t[h])&&(l=i(e,o,l)||l);l&&n(e,o,l)})([t(100)],r.prototype,"handleScrollEnd");export{r as ScrollController};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{s as t,a as e
|
|
1
|
+
import{s as t,a as e}from"./animate.js";import{S as s,L as i,x as o,t as l,j as a,c as n,i as r,e as h,n as d,a as p}from"./solid-components2.js";import{d as c}from"./default-value.js";import{F as u}from"./form.js";import{g as m,s as y}from"./animation-registry.js";import{H as b}from"./slot.js";import{r as v}from"./state.js";import{o as f}from"./query-assigned-elements.js";import{s as g}from"./scroll.js";import{o as x,S as w}from"./icon.js";import{w as O}from"./event.js";import{w as C}from"./watch.js";import S from"./tag.js";var $=Object.defineProperty,k=Object.getOwnPropertyDescriptor,D=(t,e,s,i)=>{for(var o,l=i>1?void 0:i?k(e,s):e,a=t.length-1;a>=0;a--)(o=t[a])&&(l=(i?o(e,s,l):o(l))||l);return i&&l&&$(e,s,l),l};let I=class extends s{constructor(){super(...arguments),this.formControlController=new u(this,{assumeInteractionOn:["sd-blur","sd-input"]}),this.hasSlotController=new b(this,"help-text","label"),this.localize=new i(this),this.typeToSelectString="",this.hasHover=!1,this.displayLabel="",this.hasFocus=!1,this.selectedOptions=[],this.showValidStyle=!1,this.showInvalidStyle=!1,this.defaultValue="",this.open=!1,this.size="lg",this.label="",this.placeholder=this.localize.term("selectDefaultPlaceholder"),this.helpText="",this.placement="bottom",this.currentPlacement=this.placement,this.clearable=!1,this.disabled=!1,this.multiple=!1,this.useTags=!1,this.maxOptionsVisible=3,this.form="",this.name="",this.value="",this.required=!1,this.styleOnValid=!1,this.hoist=!1,this.getTag=t=>o`<sd-tag ?disabled="${this.disabled}" part="tag" exportparts="
|
|
2
2
|
base:tag__base,
|
|
3
3
|
content:tag__content,
|
|
4
4
|
removable-indicator:tag__removable-indicator,
|
|
5
|
-
" size="${"sm"===this.size?"sm":"lg"}" removable @sd-remove="${e=>this.handleTagRemove(e,t)}">${t.getTextLabel()}</sd-tag>`,this.handleDocumentFocusIn=t=>{const e=t.composedPath();this&&!e.includes(this)&&this.hide()},this.handleDocumentKeyDown=t=>{const e=t.target,s=null!==e.closest(".select__clear"),i=null!==e.closest("sd-icon-button");if(!s&&!i){if("Escape"===t.key&&this.open&&(t.preventDefault(),t.stopPropagation(),this.hide(),this.displayInput.focus({preventScroll:!0})),"Enter"===t.key||" "===t.key&&""===this.typeToSelectString)return t.preventDefault(),t.stopImmediatePropagation(),this.open?void(this.currentOption&&!this.currentOption.disabled&&(this.multiple?this.toggleOptionSelection(this.currentOption):this.setSelectedOptions(this.currentOption),this.updateComplete.then((()=>{this.emit("sd-input"),this.emit("sd-change")})),this.multiple||(this.hide(),this.displayInput.focus({preventScroll:!0})))):void this.show();if(["ArrowUp","ArrowDown","Home","End"].includes(t.key)){const e=this.getAllOptions(),s=e.indexOf(this.currentOption);let i=Math.max(0,s);if(t.preventDefault(),!this.open&&(this.show(),this.currentOption))return;"ArrowDown"===t.key?(i=s+1,i>e.length-1&&(i=0)):"ArrowUp"===t.key?(i=s-1,i<0&&(i=e.length-1)):"Home"===t.key?i=0:"End"===t.key&&(i=e.length-1),this.setCurrentOption(e[i])}if(1===t.key.length||"Backspace"===t.key){const e=this.getAllOptions();if(t.metaKey||t.ctrlKey||t.altKey)return;if(!this.open){if("Backspace"===t.key)return;this.show()}t.stopPropagation(),t.preventDefault(),clearTimeout(this.typeToSelectTimeout),this.typeToSelectTimeout=window.setTimeout((()=>this.typeToSelectString=""),1e3),"Backspace"===t.key?this.typeToSelectString=this.typeToSelectString.slice(0,-1):this.typeToSelectString+=t.key.toLowerCase();for(const t of e)if(t.getTextLabel().toLowerCase().startsWith(this.typeToSelectString)){this.setCurrentOption(t);break}}}},this.handleDocumentMouseDown=t=>{const e=t.composedPath();this&&!e.includes(this)&&this.hide()}}get validity(){return this.valueInput.validity}get validationMessage(){return this.valueInput.validationMessage}connectedCallback(){super.connectedCallback(),this.applySizeToOptions(),this.open=!1}addOpenListeners(){document.addEventListener("focusin",this.handleDocumentFocusIn),document.addEventListener("keydown",this.handleDocumentKeyDown),document.addEventListener("mousedown",this.handleDocumentMouseDown)}removeOpenListeners(){document.removeEventListener("focusin",this.handleDocumentFocusIn),document.removeEventListener("keydown",this.handleDocumentKeyDown),document.removeEventListener("mousedown",this.handleDocumentMouseDown)}handleFocus(){this.hasFocus=!0,this.displayInput.setSelectionRange(0,0),this.emit("sd-focus")}handleBlur(){this.hasFocus=!1,this.emit("sd-blur")}handleLabelClick(){this.displayInput.focus()}handleComboboxMouseDown(t){const e=t.composedPath().some((t=>t instanceof HTMLSlotElement&&"removable-indicator"===t.name));this.disabled||e||(t.preventDefault(),this.displayInput.focus({preventScroll:!0}),this.open=!this.open)}handleComboboxKeyDown(t){t.stopPropagation(),this.handleDocumentKeyDown(t)}handleClearClick(t){t.stopPropagation(),""!==this.value&&(this.setSelectedOptions([]),this.displayInput.focus({preventScroll:!0}),this.updateComplete.then((()=>{this.emit("sd-clear"),this.emit("sd-input"),this.emit("sd-change")})))}handleClearMouseDown(t){t.stopPropagation(),t.preventDefault()}handleOptionClick(t){const e=t.target.closest("sd-option"),s=this.value;e&&!e.disabled&&(this.multiple?this.toggleOptionSelection(e):this.setSelectedOptions(e),this.updateComplete.then((()=>this.displayInput.focus({preventScroll:!0}))),this.value!==s&&this.updateComplete.then((()=>{this.emit("sd-input"),this.emit("sd-change")})),this.multiple||(this.hide(),this.displayInput.focus({preventScroll:!0})))}handleDefaultSlotChange(){const t=this.getAllOptions(),e=Array.isArray(this.value)?this.value:[this.value],s=[];customElements.get("sd-option")?(t.forEach((t=>{this.multiple&&(t.checkbox=!0),s.push(t.value)})),this.setSelectedOptions(t.filter((t=>e.includes(t.value))))):customElements.whenDefined("sd-option").then((()=>this.handleDefaultSlotChange()))}handleTagRemove(t,e){t.stopPropagation(),this.disabled||(this.toggleOptionSelection(e,!1),this.updateComplete.then((()=>{this.emit("sd-input"),this.emit("sd-change")})))}getAllOptions(){return[...this.querySelectorAll("sd-option")]}getFirstOption(){return this.querySelector("sd-option")}setCurrentOption(t){this.getAllOptions().forEach((t=>{t.current=!1,t.tabIndex=-1})),t&&(this.currentOption=t,t.current=!0,t.tabIndex=0,t.focus())}setSelectedOptions(t){const e=this.getAllOptions(),s=Array.isArray(t)?t:[t];e.forEach((t=>t.selected=!1)),s.length&&s.forEach((t=>t.selected=!0)),this.selectionChanged()}toggleOptionSelection(t,e){t.selected=!0===e||!1===e?e:!t.selected,this.selectionChanged()}selectionChanged(){var t,e;this.selectedOptions=this.getAllOptions().filter((t=>t.selected)),this.multiple?(this.value=this.selectedOptions.map((t=>t.value)),this.useTags||0===this.value.length?this.displayLabel="":this.displayLabel=this.localize.term("numOptionsSelected",this.selectedOptions.length)):(this.value=(null==(t=this.selectedOptions[0])?void 0:t.value)??"",this.displayLabel=(null==(e=this.selectedOptions[0])?void 0:e.getTextLabel())??""),this.updateComplete.then((()=>{this.formControlController.updateValidity()}))}get tags(){return this.selectedOptions.map(((t,e)=>{if(e<this.maxOptionsVisible||this.maxOptionsVisible<=0){const s=this.getTag(t,e);return l`<div @sd-remove="${e=>this.handleTagRemove(e,t)}">${"string"==typeof s?w(s):s}</div>`}return e===this.maxOptionsVisible?l`<sd-tag size="${"sm"===this.size?"sm":"lg"}" ?disabled="${this.disabled}">+${this.selectedOptions.length-e}</sd-tag>`:l``}))}handleInvalid(t){this.formControlController.setValidity(!1),this.formControlController.emitInvalidEvent(t),this.invalidMessage.textContent=t.target.validationMessage}handleMouseEnter(){this.hasHover=!0}handleMouseLeave(){this.hasHover=!1}handleCurrentPlacement(t){const e=t.detail;e&&(this.currentPlacement=e)}handleUseTagsChange(){const t=this.getAllOptions();customElements.get("sd-option")&&t.forEach((t=>{t.checkbox=this.multiple}))}handleDisabledChange(){this.disabled&&(this.open=!1,this.handleOpenChange())}async handleOpenChange(){if(this.open&&!this.disabled){this.setCurrentOption(this.selectedOptions[0]||this.getFirstOption()),this.emit("sd-show"),this.addOpenListeners(),await t(this),this.listbox.hidden=!1,this.popup.active=!0,requestAnimationFrame((()=>{this.setCurrentOption(this.currentOption)}));const{keyframes:s,options:i}=y(this,"select.show",{dir:this.localize.dir()});await e(this.popup.popup,s,i),this.currentOption&&x(this.currentOption,this.listbox,"vertical","auto"),this.emit("sd-after-show")}else{this.emit("sd-hide"),this.removeOpenListeners(),await t(this);const{keyframes:s,options:i}=y(this,"select.hide",{dir:this.localize.dir()});await e(this.popup.popup,s,i),this.listbox.hidden=!0,this.popup.active=!1,this.emit("sd-after-hide")}}applySizeToOptions(){this._optionsInDefaultSlot.forEach((t=>{t.size=this.size}))}handleValueChange(){const t=this.getAllOptions(),e=Array.isArray(this.value)?this.value:[this.value];this.setSelectedOptions(t.filter((t=>e.includes(t.value))))}async show(){if(!this.open&&!this.disabled)return this.open=!0,s(this,"sd-after-show");this.open=!1}async hide(){if(this.open&&!this.disabled)return this.open=!1,s(this,"sd-after-hide");this.open=!1}checkValidity(){var t;return null==(t=this.valueInput)?void 0:t.checkValidity()}getForm(){return this.formControlController.getForm()}reportValidity(){return this.formControlController.fakeUserInteraction(),this.valueInput.reportValidity()}setCustomValidity(t){this.valueInput.setCustomValidity(t),this.formControlController.updateValidity()}focus(t){this.displayInput.focus(t)}blur(){this.displayInput.blur()}render(){this.hasSlotController.test("[default]");const t=this.hasSlotController.test("label"),e=(this.hasSlotController.test("clear-icon"),this.hasSlotController.test("expand-icon"),this.hasSlotController.test("help-text")),s=!!this.label||!!t,i=!!this.helpText||!!e,o=this.clearable&&!this.disabled&&this.value.length>0,n=this.disabled?"disabled":this.hasFocus&&this.showInvalidStyle?"activeInvalid":this.hasFocus&&this.styleOnValid&&this.showValidStyle?"activeValid":this.hasFocus||this.open?"active":this.showInvalidStyle?"invalid":this.styleOnValid&&this.showValidStyle?"valid":"default",r=this.disabled?"cursor-not-allowed":"cursor-pointer",h={sm:"ml-1",md:"ml-2",lg:"ml-2"}[this.size],d={sm:"text-base",md:"text-lg",lg:"text-xl"}[this.size];return l`<div part="form-control" class="${a("relative text-left",r,"sm"===this.size?"text-sm":"text-base",this.open&&"z-50")}"><label id="label" part="form-control-label" class="${s&&"inline-block mb-2"}" aria-hidden="${s?"false":"true"}" @click="${this.handleLabelClick}"><slot name="label">${this.label}</slot></label><div part="form-control-input" class="${a("relative w-full bg-white",{disabled:"text-neutral-500",readonly:"text-black",activeInvalid:"text-error",activeValid:"text-success",active:"text-black",invalid:"text-error",valid:"text-success",default:"text-black"}[n])}"><div part="border" class="${a("absolute top-0 w-full h-full pointer-events-none border rounded-default",this.hasHover&&"bg-neutral-200",{disabled:"border-neutral-500",readonly:"border-neutral-800",activeInvalid:"border-error border-2",activeValid:"border-success border-2",active:"border-primary border-2",invalid:"border-error",valid:"border-success",default:"border-neutral-800"}[n],this.open&&("bottom"===this.currentPlacement?"rounded-bl-none rounded-br-none":"rounded-tl-none rounded-tr-none"))}"></div><sd-popup @sd-current-placement="${this.handleCurrentPlacement}" class="${a("inline-flex relative w-full","bottom"===this.currentPlacement?"origin-top":"origin-bottom")}" placement="${this.placement}" strategy="${this.hoist?"fixed":"absolute"}" flip shift sync="width" auto-size="vertical" auto-size-padding="10" exportparts="
|
|
5
|
+
" size="${"sm"===this.size?"sm":"lg"}" removable @sd-remove="${e=>this.handleTagRemove(e,t)}">${t.getTextLabel()}</sd-tag>`,this.handleDocumentFocusIn=t=>{const e=t.composedPath();this&&!e.includes(this)&&this.hide()},this.handleDocumentKeyDown=t=>{const e=t.target,s=null!==e.closest(".select__clear"),i=null!==e.closest("sd-icon-button");if(!s&&!i){if("Escape"===t.key&&this.open&&(t.preventDefault(),t.stopPropagation(),this.hide(),this.displayInput.focus({preventScroll:!0})),"Enter"===t.key||" "===t.key&&""===this.typeToSelectString)return t.preventDefault(),t.stopImmediatePropagation(),this.open?void(this.currentOption&&!this.currentOption.disabled&&(this.multiple?this.toggleOptionSelection(this.currentOption):this.setSelectedOptions(this.currentOption),this.updateComplete.then((()=>{this.emit("sd-input"),this.emit("sd-change")})),this.multiple||(this.hide(),this.displayInput.focus({preventScroll:!0})))):void this.show();if(["ArrowUp","ArrowDown","Home","End"].includes(t.key)){const e=this.getAllOptions(),s=e.indexOf(this.currentOption);let i=Math.max(0,s);if(t.preventDefault(),!this.open&&(this.show(),this.currentOption))return;"ArrowDown"===t.key?(i=s+1,i>e.length-1&&(i=0)):"ArrowUp"===t.key?(i=s-1,i<0&&(i=e.length-1)):"Home"===t.key?i=0:"End"===t.key&&(i=e.length-1),this.setCurrentOption(e[i])}if(1===t.key.length||"Backspace"===t.key){const e=this.getAllOptions();if(t.metaKey||t.ctrlKey||t.altKey)return;if(!this.open){if("Backspace"===t.key)return;this.show()}t.stopPropagation(),t.preventDefault(),clearTimeout(this.typeToSelectTimeout),this.typeToSelectTimeout=window.setTimeout((()=>this.typeToSelectString=""),1e3),"Backspace"===t.key?this.typeToSelectString=this.typeToSelectString.slice(0,-1):this.typeToSelectString+=t.key.toLowerCase();for(const t of e)if(t.getTextLabel().toLowerCase().startsWith(this.typeToSelectString)){this.setCurrentOption(t);break}}}},this.handleDocumentMouseDown=t=>{const e=t.composedPath();this&&!e.includes(this)&&this.hide()}}get validity(){return this.valueInput.validity}get validationMessage(){return this.valueInput.validationMessage}connectedCallback(){super.connectedCallback(),this.applySizeToOptions(),this.open=!1}addOpenListeners(){document.addEventListener("focusin",this.handleDocumentFocusIn),document.addEventListener("keydown",this.handleDocumentKeyDown),document.addEventListener("mousedown",this.handleDocumentMouseDown)}removeOpenListeners(){document.removeEventListener("focusin",this.handleDocumentFocusIn),document.removeEventListener("keydown",this.handleDocumentKeyDown),document.removeEventListener("mousedown",this.handleDocumentMouseDown)}handleFocus(){this.hasFocus=!0,this.displayInput.setSelectionRange(0,0),this.emit("sd-focus")}handleBlur(){this.hasFocus=!1,this.emit("sd-blur")}handleLabelClick(){this.displayInput.focus()}handleComboboxMouseDown(t){const e=t.composedPath().some((t=>t instanceof HTMLSlotElement&&"removable-indicator"===t.name));this.disabled||e||(t.preventDefault(),this.displayInput.focus({preventScroll:!0}),this.open=!this.open)}handleComboboxKeyDown(t){t.stopPropagation(),this.handleDocumentKeyDown(t)}handleClearClick(t){t.stopPropagation(),""!==this.value&&(this.setSelectedOptions([]),this.displayInput.focus({preventScroll:!0}),this.updateComplete.then((()=>{this.emit("sd-clear"),this.emit("sd-input"),this.emit("sd-change")})))}handleClearMouseDown(t){t.stopPropagation(),t.preventDefault()}handleOptionClick(t){const e=t.target.closest("sd-option"),s=this.value;e&&!e.disabled&&(this.multiple?this.toggleOptionSelection(e):this.setSelectedOptions(e),this.updateComplete.then((()=>this.displayInput.focus({preventScroll:!0}))),this.value!==s&&this.updateComplete.then((()=>{this.emit("sd-input"),this.emit("sd-change")})),this.multiple||(this.hide(),this.displayInput.focus({preventScroll:!0})))}handleDefaultSlotChange(){const t=this.getAllOptions(),e=Array.isArray(this.value)?this.value:[this.value],s=[];customElements.get("sd-option")?(t.forEach((t=>{this.multiple&&(t.checkbox=!0),s.push(t.value)})),this.setSelectedOptions(t.filter((t=>e.includes(t.value))))):customElements.whenDefined("sd-option").then((()=>this.handleDefaultSlotChange()))}handleTagRemove(t,e){t.stopPropagation(),this.disabled||(this.toggleOptionSelection(e,!1),this.updateComplete.then((()=>{this.emit("sd-input"),this.emit("sd-change")})))}getAllOptions(){return[...this.querySelectorAll("sd-option")]}getFirstOption(){return this.querySelector("sd-option")}setCurrentOption(t){this.getAllOptions().forEach((t=>{t.current=!1,t.tabIndex=-1})),t&&(this.currentOption=t,t.current=!0,t.tabIndex=0,t.focus())}setSelectedOptions(t){const e=this.getAllOptions(),s=Array.isArray(t)?t:[t];e.forEach((t=>t.selected=!1)),s.length&&s.forEach((t=>t.selected=!0)),this.selectionChanged()}toggleOptionSelection(t,e){t.selected=!0===e||!1===e?e:!t.selected,this.selectionChanged()}selectionChanged(){var t,e;this.selectedOptions=this.getAllOptions().filter((t=>t.selected)),this.multiple?(this.value=this.selectedOptions.map((t=>t.value)),this.useTags||0===this.value.length?this.displayLabel="":this.displayLabel=this.localize.term("numOptionsSelected",this.selectedOptions.length)):(this.value=(null==(t=this.selectedOptions[0])?void 0:t.value)??"",this.displayLabel=(null==(e=this.selectedOptions[0])?void 0:e.getTextLabel())??""),this.updateComplete.then((()=>{this.formControlController.updateValidity()}))}get tags(){return this.selectedOptions.map(((t,e)=>{if(e<this.maxOptionsVisible||this.maxOptionsVisible<=0){const s=this.getTag(t,e);return o`<div @sd-remove="${e=>this.handleTagRemove(e,t)}">${"string"==typeof s?x(s):s}</div>`}return e===this.maxOptionsVisible?o`<sd-tag size="${"sm"===this.size?"sm":"lg"}" ?disabled="${this.disabled}">+${this.selectedOptions.length-e}</sd-tag>`:o``}))}handleInvalid(t){this.formControlController.setValidity(!1),this.formControlController.emitInvalidEvent(t),this.invalidMessage.textContent=t.target.validationMessage}handleMouseEnter(){this.hasHover=!0}handleMouseLeave(){this.hasHover=!1}handleCurrentPlacement(t){const e=t.detail;e&&(this.currentPlacement=e)}handleUseTagsChange(){const t=this.getAllOptions();customElements.get("sd-option")&&t.forEach((t=>{t.checkbox=this.multiple}))}handleDisabledChange(){this.disabled&&(this.open=!1,this.handleOpenChange())}async handleOpenChange(){if(this.open&&!this.disabled){this.setCurrentOption(this.selectedOptions[0]||this.getFirstOption()),this.emit("sd-show"),this.addOpenListeners(),await t(this),this.listbox.hidden=!1,this.popup.active=!0,requestAnimationFrame((()=>{this.setCurrentOption(this.currentOption)}));const{keyframes:s,options:i}=m(this,"select.show",{dir:this.localize.dir()});await e(this.popup.popup,s,i),this.currentOption&&g(this.currentOption,this.listbox,"vertical","auto"),this.emit("sd-after-show")}else{this.emit("sd-hide"),this.removeOpenListeners(),await t(this);const{keyframes:s,options:i}=m(this,"select.hide",{dir:this.localize.dir()});await e(this.popup.popup,s,i),this.listbox.hidden=!0,this.popup.active=!1,this.emit("sd-after-hide")}}applySizeToOptions(){this._optionsInDefaultSlot.forEach((t=>{t.size=this.size}))}handleValueChange(){const t=this.getAllOptions(),e=Array.isArray(this.value)?this.value:[this.value];this.setSelectedOptions(t.filter((t=>e.includes(t.value))))}async show(){if(!this.open&&!this.disabled)return this.open=!0,O(this,"sd-after-show");this.open=!1}async hide(){if(this.open&&!this.disabled)return this.open=!1,O(this,"sd-after-hide");this.open=!1}checkValidity(){var t;return null==(t=this.valueInput)?void 0:t.checkValidity()}getForm(){return this.formControlController.getForm()}reportValidity(){return this.formControlController.fakeUserInteraction(),this.valueInput.reportValidity()}setCustomValidity(t){this.valueInput.setCustomValidity(t),this.formControlController.updateValidity()}focus(t){this.displayInput.focus(t)}blur(){this.displayInput.blur()}render(){this.hasSlotController.test("[default]");const t=this.hasSlotController.test("label"),e=(this.hasSlotController.test("clear-icon"),this.hasSlotController.test("expand-icon"),this.hasSlotController.test("help-text")),s=!!this.label||!!t,i=!!this.helpText||!!e,a=this.clearable&&!this.disabled&&this.value.length>0,n=this.disabled?"disabled":this.hasFocus&&this.showInvalidStyle?"activeInvalid":this.hasFocus&&this.styleOnValid&&this.showValidStyle?"activeValid":this.hasFocus||this.open?"active":this.showInvalidStyle?"invalid":this.styleOnValid&&this.showValidStyle?"valid":"default",r=this.disabled?"cursor-not-allowed":"cursor-pointer",h={sm:"ml-1",md:"ml-2",lg:"ml-2"}[this.size],d={sm:"text-base",md:"text-lg",lg:"text-xl"}[this.size];return o`<div part="form-control" class="${l("relative text-left",r,"sm"===this.size?"text-sm":"text-base",this.open&&"z-50")}"><label id="label" part="form-control-label" class="${s&&"inline-block mb-2"}" aria-hidden="${s?"false":"true"}" @click="${this.handleLabelClick}"><slot name="label">${this.label}</slot></label><div part="form-control-input" class="${l("relative w-full bg-white",{disabled:"text-neutral-500",readonly:"text-black",activeInvalid:"text-error",activeValid:"text-success",active:"text-black",invalid:"text-error",valid:"text-success",default:"text-black"}[n])}"><div part="border" class="${l("absolute top-0 w-full h-full pointer-events-none border rounded-default",this.hasHover&&"bg-neutral-200",{disabled:"border-neutral-500",readonly:"border-neutral-800",activeInvalid:"border-error border-2",activeValid:"border-success border-2",active:"border-primary border-2",invalid:"border-error",valid:"border-success",default:"border-neutral-800"}[n],this.open&&("bottom"===this.currentPlacement?"rounded-bl-none rounded-br-none":"rounded-tl-none rounded-tr-none"))}"></div><sd-popup @sd-current-placement="${this.handleCurrentPlacement}" class="${l("inline-flex relative w-full","bottom"===this.currentPlacement?"origin-top":"origin-bottom")}" placement="${this.placement}" strategy="${this.hoist?"fixed":"absolute"}" flip shift sync="width" auto-size="vertical" auto-size-padding="10" exportparts="
|
|
6
6
|
popup:popup__content,
|
|
7
|
-
"><div part="combobox" class="${
|
|
7
|
+
"><div part="combobox" class="${l("relative w-full px-4 flex flex-row items-center rounded-default",this.open&&"shadow",{sm:"py-1 min-h-[32px]",md:"py-1 min-h-[40px]",lg:"py-2 min-h-[48px]"}[this.size])}" slot="anchor" @keydown="${this.handleComboboxKeyDown}" @mousedown="${this.handleComboboxMouseDown}" @mouseenter="${this.handleMouseEnter}" @mouseleave="${this.handleMouseLeave}"><input name="${this.name}" form="${this.form}" part="display-input" class="${l("appearance-none outline-none flex-grow bg-transparent w-full",r,this.multiple&&this.useTags&&this.value.length>0?"hidden":"")}" type="text" placeholder="${this.placeholder}" .disabled="${this.disabled}" .value="${this.displayLabel}" autocomplete="off" spellcheck="false" autocapitalize="off" readonly="readonly" aria-controls="listbox" aria-expanded="${this.open?"true":"false"}" aria-haspopup="listbox" aria-labelledby="label" aria-disabled="${this.disabled?"true":"false"}" aria-describedby="help-text" role="combobox" tabindex="0" @focus="${this.handleFocus}" @blur="${this.handleBlur}"> ${this.multiple&&this.useTags?o`<div part="tags" class="flex-grow flex flex-wrap items-center gap-1">${this.tags}</div>`:""} <input class="${l("value-input absolute top-0 left-0 w-full h-full opacity-0 -z-10",r)}" type="text" ?disabled="${this.disabled}" ?required="${this.required}" .value="${Array.isArray(this.value)?this.value.join(", "):this.value}" tabindex="-1" aria-hidden="true" @focus="${()=>this.focus()}" @invalid="${this.handleInvalid}"> ${a?o`<button part="clear-button" class="${l("select__clear flex justify-center",h)}" type="button" aria-label="${this.localize.term("clearEntry")}" @mousedown="${this.handleClearMouseDown}" @click="${this.handleClearClick}" tabindex="-1"><slot name="clear-icon"><sd-icon class="${l("text-icon-fill-neutral-800",d)}" library="system" name="closing-round"></sd-icon></slot></button>`:""} ${this.showInvalidStyle?o`<sd-icon part="invalid-icon" class="${l(h,d)}" library="system" name="risk"></sd-icon>`:""} ${this.styleOnValid&&this.showValidStyle?o`<sd-icon part="valid-icon" class="${l("flex-shrink-0",h,d)}" library="system" name="status-check"></sd-icon>`:""}<slot name="expand-icon" part="expand-icon" class="${l("inline-flex ml-2 transition-all",this.open?"rotate-180":"rotate-0",this.disabled?"text-neutral-500":"text-primary",d)}"><sd-icon name="chevron-down" part="chevron" library="system" color="currentColor"></sd-icon></slot></div><div id="listbox" role="listbox" aria-expanded="${this.open?"true":"false"}" aria-multiselectable="${this.multiple?"true":"false"}" aria-labelledby="label" part="listbox" class="${l("bg-white px-2 py-3 relative border-primary",this.open&&"shadow","bottom"===this.currentPlacement?"border-r-2 border-b-2 border-l-2 rounded-br-default rounded-bl-default":"border-r-2 border-t-2 border-l-2 rounded-tr-default rounded-tl-default")}" tabindex="-1" @mouseup="${this.handleOptionClick}" @slotchange="${this.handleDefaultSlotChange}"><slot></slot></div></sd-popup></div><div class="text-sm text-neutral-700" part="form-control-help-text" id="help-text" aria-hidden="${i?"false":"true"}"><slot name="help-text">${this.helpText}</slot></div></div>${this.formControlController.renderInvalidMessage()}`}};I.dependencies={"sd-icon":w,"sd-popup":a,"sd-tag":S},I.styles=[n,s.styles,r`:host{position:relative;display:block;width:100%}:host([required]) #label::after{content:' *'}sd-popup::part(popup){z-index:var(--sd-z-index-dropdown,900);overflow-y:scroll}sd-tag::part(base){border-radius:var(--sd-border-radius-default,.25rem);padding-left:var(--sd-spacing-1,.25rem);padding-right:var(--sd-spacing-1,.25rem)}sd-tag[size=lg]::part(base){padding-left:var(--sd-spacing-2,.5rem);padding-right:var(--sd-spacing-2,.5rem)}sd-tag[disabled=false]::part(base):hover{--tw-bg-opacity:1;background-color:rgb(var(--sd-color-primary-100,236 240 249) / var(--tw-bg-opacity))}`],D([f({selector:"sd-option"})],I.prototype,"_optionsInDefaultSlot",2),D([h("sd-popup")],I.prototype,"popup",2),D([h('[part="combobox"]')],I.prototype,"combobox",2),D([h('[part="display-input"]')],I.prototype,"displayInput",2),D([h(".value-input")],I.prototype,"valueInput",2),D([h('[part="listbox"]')],I.prototype,"listbox",2),D([h("#invalid-message")],I.prototype,"invalidMessage",2),D([v()],I.prototype,"hasHover",2),D([v()],I.prototype,"displayLabel",2),D([v()],I.prototype,"hasFocus",2),D([v()],I.prototype,"currentOption",2),D([v()],I.prototype,"selectedOptions",2),D([v()],I.prototype,"showValidStyle",2),D([v()],I.prototype,"showInvalidStyle",2),D([c()],I.prototype,"defaultValue",2),D([d({type:Boolean,reflect:!0})],I.prototype,"open",2),D([d({reflect:!0})],I.prototype,"size",2),D([d()],I.prototype,"label",2),D([d()],I.prototype,"placeholder",2),D([d({attribute:"help-text"})],I.prototype,"helpText",2),D([d({reflect:!0})],I.prototype,"placement",2),D([v()],I.prototype,"currentPlacement",2),D([d({type:Boolean})],I.prototype,"clearable",2),D([d({type:Boolean,reflect:!0})],I.prototype,"disabled",2),D([d({type:Boolean,reflect:!0})],I.prototype,"multiple",2),D([d({type:Boolean,reflect:!0})],I.prototype,"useTags",2),D([d({attribute:"max-options-visible",type:Number})],I.prototype,"maxOptionsVisible",2),D([d({reflect:!0})],I.prototype,"form",2),D([d()],I.prototype,"name",2),D([d({converter:{fromAttribute:t=>t.split(" "),toAttribute:t=>t.join(" ")}})],I.prototype,"value",2),D([d({type:Boolean,reflect:!0})],I.prototype,"required",2),D([d({type:Boolean,reflect:!0,attribute:"style-on-valid"})],I.prototype,"styleOnValid",2),D([d({type:Boolean})],I.prototype,"hoist",2),D([d()],I.prototype,"getTag",2),D([C("useTags",{waitUntilFirstUpdate:!0})],I.prototype,"handleUseTagsChange",1),D([C("disabled",{waitUntilFirstUpdate:!0})],I.prototype,"handleDisabledChange",1),D([C("open",{waitUntilFirstUpdate:!0})],I.prototype,"handleOpenChange",1),D([C("size",{waitUntilFirstUpdate:!0})],I.prototype,"applySizeToOptions",1),D([C("value",{waitUntilFirstUpdate:!0})],I.prototype,"handleValueChange",1),I=D([p("sd-select")],I),y("select.show",{keyframes:[{opacity:0,scale:.9},{opacity:1,scale:1}],options:{duration:100,easing:"ease"}}),y("select.hide",{keyframes:[{opacity:1,scale:1},{opacity:0,scale:.9}],options:{duration:100,easing:"ease"}});export{I as default};
|