@solid-design-system/components 2.4.2 → 2.4.4

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.
Files changed (152) hide show
  1. package/dist/components/es/accordion-group.js +1 -1
  2. package/dist/components/es/accordion.js +1 -1
  3. package/dist/components/es/badge.js +1 -1
  4. package/dist/components/es/brandshape.js +1 -1
  5. package/dist/components/es/button.js +1 -1
  6. package/dist/components/es/carousel-item.js +1 -1
  7. package/dist/components/es/carousel.js +1 -1
  8. package/dist/components/es/checkbox-group.js +1 -1
  9. package/dist/components/es/checkbox.js +1 -1
  10. package/dist/components/es/dialog.js +1 -1
  11. package/dist/components/es/divider.js +1 -1
  12. package/dist/components/es/drawer.js +1 -1
  13. package/dist/components/es/dropdown.js +1 -1
  14. package/dist/components/es/header.js +1 -1
  15. package/dist/components/es/icon.js +3 -3
  16. package/dist/components/es/include.js +1 -1
  17. package/dist/components/es/input.js +1 -1
  18. package/dist/components/es/link.js +1 -1
  19. package/dist/components/es/navigation-item.js +1 -6
  20. package/dist/components/es/notification.js +1 -1
  21. package/dist/components/es/option.js +1 -1
  22. package/dist/components/es/popup.js +1 -1
  23. package/dist/components/es/radio-button.js +1 -1
  24. package/dist/components/es/radio-group.js +1 -1
  25. package/dist/components/es/radio.js +1 -1
  26. package/dist/components/es/select.js +3 -3
  27. package/dist/components/es/solid-element.js +5 -6
  28. package/dist/components/es/spinner.js +1 -1
  29. package/dist/components/es/switch.js +1 -1
  30. package/dist/components/es/tag.js +1 -1
  31. package/dist/components/es/teaser-media.js +1 -1
  32. package/dist/components/es/teaser.js +1 -1
  33. package/dist/components/es/textarea.js +1 -1
  34. package/dist/components/es/tooltip.js +2 -2
  35. package/dist/components/es/video.js +1 -1
  36. package/dist/components/umd/solid-components.js +10 -15
  37. package/dist/custom-elements.json +1 -1
  38. package/dist/package/components/input/input.js +1 -1
  39. package/dist/package/components/navigation-item/navigation-item.js +1 -1
  40. package/dist/package/components/select/select.js +2 -2
  41. package/dist/versioned-components/es/accordion-group.js +1 -1
  42. package/dist/versioned-components/es/accordion.js +1 -1
  43. package/dist/versioned-components/es/badge.js +1 -1
  44. package/dist/versioned-components/es/brandshape.js +1 -1
  45. package/dist/versioned-components/es/button.js +1 -1
  46. package/dist/versioned-components/es/carousel-item.js +1 -1
  47. package/dist/versioned-components/es/carousel.js +3 -3
  48. package/dist/versioned-components/es/checkbox-group.js +1 -1
  49. package/dist/versioned-components/es/checkbox.js +1 -1
  50. package/dist/versioned-components/es/dialog.js +1 -1
  51. package/dist/versioned-components/es/divider.js +1 -1
  52. package/dist/versioned-components/es/drawer.js +1 -1
  53. package/dist/versioned-components/es/dropdown.js +1 -1
  54. package/dist/versioned-components/es/form.js +1 -1
  55. package/dist/versioned-components/es/header.js +1 -1
  56. package/dist/versioned-components/es/icon.js +3 -3
  57. package/dist/versioned-components/es/include.js +1 -1
  58. package/dist/versioned-components/es/input.js +1 -1
  59. package/dist/versioned-components/es/link.js +1 -1
  60. package/dist/versioned-components/es/navigation-item.js +1 -6
  61. package/dist/versioned-components/es/notification.js +1 -1
  62. package/dist/versioned-components/es/option.js +1 -1
  63. package/dist/versioned-components/es/popup.js +1 -1
  64. package/dist/versioned-components/es/radio-button.js +1 -1
  65. package/dist/versioned-components/es/radio-group.js +1 -1
  66. package/dist/versioned-components/es/radio.js +1 -1
  67. package/dist/versioned-components/es/select.js +3 -3
  68. package/dist/versioned-components/es/solid-element.js +5 -6
  69. package/dist/versioned-components/es/spinner.js +1 -1
  70. package/dist/versioned-components/es/switch.js +1 -1
  71. package/dist/versioned-components/es/tag.js +1 -1
  72. package/dist/versioned-components/es/teaser-media.js +1 -1
  73. package/dist/versioned-components/es/teaser.js +1 -1
  74. package/dist/versioned-components/es/textarea.js +1 -1
  75. package/dist/versioned-components/es/tooltip.js +2 -2
  76. package/dist/versioned-components/es/video.js +1 -1
  77. package/dist/versioned-package/_components/button-group/button-group.d.ts +1 -1
  78. package/dist/versioned-package/_components/button-group/button-group.js +11 -11
  79. package/dist/versioned-package/components/accordion/accordion.d.ts +1 -1
  80. package/dist/versioned-package/components/accordion/accordion.js +2 -2
  81. package/dist/versioned-package/components/accordion-group/accordion-group.d.ts +1 -1
  82. package/dist/versioned-package/components/accordion-group/accordion-group.js +3 -3
  83. package/dist/versioned-package/components/badge/badge.d.ts +1 -1
  84. package/dist/versioned-package/components/badge/badge.js +1 -1
  85. package/dist/versioned-package/components/brandshape/brandshape.d.ts +1 -1
  86. package/dist/versioned-package/components/brandshape/brandshape.js +1 -1
  87. package/dist/versioned-package/components/button/button.d.ts +1 -1
  88. package/dist/versioned-package/components/button/button.js +4 -4
  89. package/dist/versioned-package/components/carousel/carousel.d.ts +1 -1
  90. package/dist/versioned-package/components/carousel/carousel.js +6 -6
  91. package/dist/versioned-package/components/carousel-item/carousel-item.d.ts +1 -1
  92. package/dist/versioned-package/components/carousel-item/carousel-item.js +1 -1
  93. package/dist/versioned-package/components/checkbox/checkbox.d.ts +1 -1
  94. package/dist/versioned-package/components/checkbox/checkbox.js +4 -4
  95. package/dist/versioned-package/components/checkbox-group/checkbox-group.d.ts +1 -1
  96. package/dist/versioned-package/components/checkbox-group/checkbox-group.js +5 -5
  97. package/dist/versioned-package/components/dialog/dialog.d.ts +1 -1
  98. package/dist/versioned-package/components/dialog/dialog.js +2 -2
  99. package/dist/versioned-package/components/divider/divider.d.ts +1 -1
  100. package/dist/versioned-package/components/divider/divider.js +2 -2
  101. package/dist/versioned-package/components/drawer/drawer.d.ts +1 -1
  102. package/dist/versioned-package/components/drawer/drawer.js +2 -2
  103. package/dist/versioned-package/components/dropdown/dropdown.d.ts +1 -1
  104. package/dist/versioned-package/components/dropdown/dropdown.js +8 -8
  105. package/dist/versioned-package/components/header/header.d.ts +1 -1
  106. package/dist/versioned-package/components/header/header.js +4 -4
  107. package/dist/versioned-package/components/icon/icon.d.ts +1 -1
  108. package/dist/versioned-package/components/icon/icon.js +1 -1
  109. package/dist/versioned-package/components/include/include.d.ts +1 -1
  110. package/dist/versioned-package/components/include/include.js +1 -1
  111. package/dist/versioned-package/components/input/input.d.ts +1 -1
  112. package/dist/versioned-package/components/input/input.js +4 -4
  113. package/dist/versioned-package/components/link/link.d.ts +1 -1
  114. package/dist/versioned-package/components/link/link.js +2 -2
  115. package/dist/versioned-package/components/navigation-item/navigation-item.d.ts +1 -1
  116. package/dist/versioned-package/components/navigation-item/navigation-item.js +4 -4
  117. package/dist/versioned-package/components/notification/notification.d.ts +1 -1
  118. package/dist/versioned-package/components/notification/notification.js +5 -5
  119. package/dist/versioned-package/components/option/option.d.ts +1 -1
  120. package/dist/versioned-package/components/option/option.js +2 -2
  121. package/dist/versioned-package/components/popup/popup.d.ts +1 -1
  122. package/dist/versioned-package/components/popup/popup.js +1 -1
  123. package/dist/versioned-package/components/radio/radio.d.ts +1 -1
  124. package/dist/versioned-package/components/radio/radio.js +2 -2
  125. package/dist/versioned-package/components/radio-button/radio-button.d.ts +1 -1
  126. package/dist/versioned-package/components/radio-button/radio-button.js +2 -2
  127. package/dist/versioned-package/components/radio-group/radio-group.d.ts +2 -2
  128. package/dist/versioned-package/components/radio-group/radio-group.js +15 -15
  129. package/dist/versioned-package/components/select/select.d.ts +4 -4
  130. package/dist/versioned-package/components/select/select.js +29 -29
  131. package/dist/versioned-package/components/spinner/spinner.d.ts +1 -1
  132. package/dist/versioned-package/components/spinner/spinner.js +1 -1
  133. package/dist/versioned-package/components/switch/switch.d.ts +1 -1
  134. package/dist/versioned-package/components/switch/switch.js +2 -2
  135. package/dist/versioned-package/components/tag/tag.d.ts +1 -1
  136. package/dist/versioned-package/components/tag/tag.js +2 -2
  137. package/dist/versioned-package/components/teaser/teaser.js +1 -1
  138. package/dist/versioned-package/components/teaser-media/teaser-media.js +1 -1
  139. package/dist/versioned-package/components/textarea/textarea.d.ts +1 -1
  140. package/dist/versioned-package/components/textarea/textarea.js +3 -3
  141. package/dist/versioned-package/components/tooltip/tooltip.d.ts +1 -1
  142. package/dist/versioned-package/components/tooltip/tooltip.js +5 -5
  143. package/dist/versioned-package/components/video/video.d.ts +1 -1
  144. package/dist/versioned-package/components/video/video.js +2 -2
  145. package/dist/versioned-package/internal/form.js +3 -3
  146. package/dist/versioned-package/styles/headline/headline.css.js +1 -1
  147. package/dist/versioned-styles/solid-styles.css +1 -1
  148. package/dist/vscode.html-custom-data.json +34 -34
  149. package/dist/web-types.json +35 -35
  150. package/package.json +2 -2
  151. package/dist/components/es/register-custom-element.js +0 -1
  152. package/dist/versioned-components/es/register-custom-element.js +0 -1
@@ -1,11 +1,11 @@
1
- import{T as t,w as e,S as r,x as s,i,n as o}from"./solid-element.js";import{c as a}from"./register-custom-element.js";import{w as l,u as n,g as c}from"./solid-components2.js";import{r as h}from"./state.js";import{requestIcon as p}from"./request.js";import{e as d,i as u,t as m}from"./directive.js";import{w as b}from"./watch.js";import{c as g}from"./component.styles.js";
1
+ import{T as t,w as e,S as r,x as s,i,n as o,c as a}from"./solid-element.js";import{w as l,u as n,g as c}from"./solid-components2.js";import{r as h}from"./state.js";import{requestIcon as p}from"./request.js";import{e as d,i as u,t as m}from"./directive.js";import{w as b}from"./watch.js";import{c as y}from"./component.styles.js";
2
2
  /**
3
3
  * @license
4
4
  * Copyright 2017 Google LLC
5
5
  * SPDX-License-Identifier: BSD-3-Clause
6
- */class y extends u{constructor(e){if(super(e),this.et=t,e.type!==m.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(r){if(r===t||null==r)return this.vt=void 0,this.et=r;if(r===e)return r;if("string"!=typeof r)throw Error(this.constructor.directiveName+"() called with a non-string value");if(r===this.et)return this.vt;this.et=r;const s=[r];return s.raw=s,this.vt={_$litType$:this.constructor.resultType,strings:s,values:[]}}}y.directiveName="unsafeHTML",y.resultType=1;const v=d(y);
6
+ */class g extends u{constructor(e){if(super(e),this.et=t,e.type!==m.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(r){if(r===t||null==r)return this.vt=void 0,this.et=r;if(r===e)return r;if("string"!=typeof r)throw Error(this.constructor.directiveName+"() called with a non-string value");if(r===this.et)return this.vt;this.et=r;const s=[r];return s.raw=s,this.vt={_$litType$:this.constructor.resultType,strings:s,values:[]}}}g.directiveName="unsafeHTML",g.resultType=1;const v=d(g);
7
7
  /**
8
8
  * @license
9
9
  * Copyright 2017 Google LLC
10
10
  * SPDX-License-Identifier: BSD-3-Clause
11
- */class f extends y{}f.directiveName="unsafeSVG",f.resultType=2;const w=d(f);var j=Object.defineProperty,x=Object.getOwnPropertyDescriptor,C=(t,e,r,s)=>{for(var i,o=s>1?void 0:s?x(e,r):e,a=t.length-1;a>=0;a--)(i=t[a])&&(o=(s?i(e,r,o):i(o))||o);return s&&o&&j(e,r,o),o};let T,k=class extends r{constructor(){super(...arguments),this.svg="",this.label="",this.library="default",this.color="currentColor"}connectedCallback(){super.connectedCallback(),l(this)}firstUpdated(){this.setIcon()}disconnectedCallback(){super.disconnectedCallback(),n(this)}getUrl(){const t=c(this.library);return this.name&&t?t.resolver(this.name):this.src}handleLabelChange(){"string"==typeof this.label&&this.label.length>0?(this.setAttribute("role","img"),this.setAttribute("aria-label",this.label),this.removeAttribute("aria-hidden")):(this.removeAttribute("role"),this.removeAttribute("aria-label"),this.setAttribute("aria-hidden","true"))}async setIcon(){var t;const e=c(this.library),r=this.getUrl();if(T||(T=new DOMParser),r)try{const s=await p(r);if(r===this.getUrl())if(s.ok){const r=T.parseFromString(s.svg,"text/html").body.querySelector("svg");null!==r?(null==(t=null==e?void 0:e.mutator)||t.call(e,r),this.svg=r.outerHTML,this.emit("sd-load")):(this.svg="",this.emit("sd-error"))}else this.svg="",this.emit("sd-error")}catch{this.emit("sd-error")}else this.svg.length>0&&(this.svg="")}render(){return s`${w(this.svg)}`}};k.styles=[g,i`:host{width:1em;height:1em;box-sizing:content-box!important;display:inline-block}svg{display:block;height:100%;width:100%}:host([color=primary]) svg{--tw-text-opacity:1;color:rgb(var(--sd-color-primary,0 53 142) / var(--tw-text-opacity))}:host([color=white]) svg{--tw-text-opacity:1;color:rgb(var(--sd-color-white,255 255 255) / var(--tw-text-opacity))}`],C([h()],k.prototype,"svg",2),C([o({reflect:!0})],k.prototype,"name",2),C([o()],k.prototype,"src",2),C([o()],k.prototype,"label",2),C([o({reflect:!0})],k.prototype,"library",2),C([o({reflect:!0})],k.prototype,"color",2),C([b("label")],k.prototype,"handleLabelChange",1),C([b(["name","src","library"])],k.prototype,"setIcon",1),k=C([a("sd-2-4-2-icon")],k);const S=Object.freeze(Object.defineProperty({__proto__:null,get default(){return k}},Symbol.toStringTag,{value:"Module"}));export{k as S,S as i,v as o};
11
+ */class f extends g{}f.directiveName="unsafeSVG",f.resultType=2;const w=d(f);var x=Object.defineProperty,j=Object.getOwnPropertyDescriptor,C=(t,e,r,s)=>{for(var i,o=s>1?void 0:s?j(e,r):e,a=t.length-1;a>=0;a--)(i=t[a])&&(o=(s?i(e,r,o):i(o))||o);return s&&o&&x(e,r,o),o};let T,k=class extends r{constructor(){super(...arguments),this.svg="",this.label="",this.library="default",this.color="currentColor"}connectedCallback(){super.connectedCallback(),l(this)}firstUpdated(){this.setIcon()}disconnectedCallback(){super.disconnectedCallback(),n(this)}getUrl(){const t=c(this.library);return this.name&&t?t.resolver(this.name):this.src}handleLabelChange(){"string"==typeof this.label&&this.label.length>0?(this.setAttribute("role","img"),this.setAttribute("aria-label",this.label),this.removeAttribute("aria-hidden")):(this.removeAttribute("role"),this.removeAttribute("aria-label"),this.setAttribute("aria-hidden","true"))}async setIcon(){var t;const e=c(this.library),r=this.getUrl();if(T||(T=new DOMParser),r)try{const s=await p(r);if(r===this.getUrl())if(s.ok){const r=T.parseFromString(s.svg,"text/html").body.querySelector("svg");null!==r?(null==(t=null==e?void 0:e.mutator)||t.call(e,r),this.svg=r.outerHTML,this.emit("sd-load")):(this.svg="",this.emit("sd-error"))}else this.svg="",this.emit("sd-error")}catch{this.emit("sd-error")}else this.svg.length>0&&(this.svg="")}render(){return s`${w(this.svg)}`}};k.styles=[y,i`:host{width:1em;height:1em;box-sizing:content-box!important;display:inline-block}svg{display:block;height:100%;width:100%}:host([color=primary]) svg{--tw-text-opacity:1;color:rgb(var(--sd-color-primary,0 53 142) / var(--tw-text-opacity))}:host([color=white]) svg{--tw-text-opacity:1;color:rgb(var(--sd-color-white,255 255 255) / var(--tw-text-opacity))}`],C([h()],k.prototype,"svg",2),C([o({reflect:!0})],k.prototype,"name",2),C([o()],k.prototype,"src",2),C([o()],k.prototype,"label",2),C([o({reflect:!0})],k.prototype,"library",2),C([o({reflect:!0})],k.prototype,"color",2),C([b("label")],k.prototype,"handleLabelChange",1),C([b(["name","src","library"])],k.prototype,"setIcon",1),k=C([a("sd-2-4-4-icon")],k);const S=Object.freeze(Object.defineProperty({__proto__:null,get default(){return k}},Symbol.toStringTag,{value:"Module"}));export{k as S,S as i,v as o};
@@ -1 +1 @@
1
- import{S as t,x as e,i as r,n as s}from"./solid-element.js";import{c as o}from"./register-custom-element.js";import{requestInclude as i}from"./request2.js";import{w as a}from"./watch.js";import{c}from"./component.styles.js";var l=Object.defineProperty,n=Object.getOwnPropertyDescriptor,p=(t,e,r,s)=>{for(var o,i=s>1?void 0:s?n(e,r):e,a=t.length-1;a>=0;a--)(o=t[a])&&(i=(s?o(e,r,i):o(i))||i);return s&&i&&l(e,r,i),i};let d=class extends t{constructor(){super(...arguments),this.mode="cors",this.allowScripts=!1}executeScript(t){const e=document.createElement("script");[...t.attributes].forEach((t=>e.setAttribute(t.name,t.value))),e.textContent=t.textContent,t.parentNode.replaceChild(e,t)}async handleSrcChange(){try{const t=this.src,e=await i(t,this.mode);if(t!==this.src)return;if(!e.ok)return void this.emit("sd-error",{detail:{status:e.status}});this.innerHTML=e.html,this.allowScripts&&[...this.querySelectorAll("script")].forEach((t=>this.executeScript(t))),this.emit("sd-load")}catch{this.emit("sd-error",{detail:{status:-1}})}}render(){return e`<slot></slot>`}};d.styles=[c,r`:host{display:block}`],p([s()],d.prototype,"src",2),p([s()],d.prototype,"mode",2),p([s({attribute:"allow-scripts",type:Boolean})],d.prototype,"allowScripts",2),p([a("src")],d.prototype,"handleSrcChange",1),d=p([o("sd-2-4-2-include")],d);export{d as default};
1
+ import{S as t,x as e,i as r,n as s,c as o}from"./solid-element.js";import{requestInclude as i}from"./request2.js";import{w as a}from"./watch.js";import{c}from"./component.styles.js";var l=Object.defineProperty,n=Object.getOwnPropertyDescriptor,p=(t,e,r,s)=>{for(var o,i=s>1?void 0:s?n(e,r):e,a=t.length-1;a>=0;a--)(o=t[a])&&(i=(s?o(e,r,i):o(i))||i);return s&&i&&l(e,r,i),i};let d=class extends t{constructor(){super(...arguments),this.mode="cors",this.allowScripts=!1}executeScript(t){const e=document.createElement("script");[...t.attributes].forEach((t=>e.setAttribute(t.name,t.value))),e.textContent=t.textContent,t.parentNode.replaceChild(e,t)}async handleSrcChange(){try{const t=this.src,e=await i(t,this.mode);if(t!==this.src)return;if(!e.ok)return void this.emit("sd-error",{detail:{status:e.status}});this.innerHTML=e.html,this.allowScripts&&[...this.querySelectorAll("script")].forEach((t=>this.executeScript(t))),this.emit("sd-load")}catch{this.emit("sd-error",{detail:{status:-1}})}}render(){return e`<slot></slot>`}};d.styles=[c,r`:host{display:block}`],p([s()],d.prototype,"src",2),p([s()],d.prototype,"mode",2),p([s({attribute:"allow-scripts",type:Boolean})],d.prototype,"allowScripts",2),p([a("src")],d.prototype,"handleSrcChange",1),d=p([o("sd-2-4-4-include")],d);export{d as default};
@@ -1 +1 @@
1
- import"./icon.js";import{S as t,x as e,i as s,n as i}from"./solid-element.js";import{c as l}from"./register-custom-element.js";import{d as a}from"./default-value.js";import{F as o}from"./form.js";import{H as r}from"./slot.js";import{o as n}from"./if-defined.js";import{l as p}from"./live.js";import{L as h}from"./solid-components2.js";import{r as d}from"./state.js";import{e as u}from"./query.js";import{w as c}from"./watch.js";import{c as m}from"./component.styles.js";import{t as y}from"./classix.js";import"./request.js";import"./request2.js";import"./directive.js";var b,v=Object.defineProperty,f=Object.getOwnPropertyDescriptor,g=(t,e,s,i)=>{for(var l,a=i>1?void 0:i?f(e,s):e,o=t.length-1;o>=0;o--)(l=t[o])&&(a=(i?l(e,s,a):l(a))||a);return i&&a&&v(e,s,a),a};const w=!(null==(b=navigator.userAgentData)?void 0:b.brands.some((t=>t.brand.includes("Chromium"))))&&navigator.userAgent.includes("Firefox");let x=class extends t{constructor(){super(...arguments),this.formControlController=new o(this),this.hasSlotController=new r(this,"help-text","label","left","right","message","placeholder"),this.localize=new h(this),this.hasFocus=!1,this.showValidStyle=!1,this.showInvalidStyle=!1,this.type="text",this.size="lg",this.value="",this.defaultValue="",this.placeholder="",this.label="",this.helpText="",this.clearable=!1,this.disabled=!1,this.readonly=!1,this.passwordToggle=!1,this.passwordVisible=!1,this.noSpinButtons=!1,this.form="",this.name="",this.title="",this.required=!1,this.styleOnValid=!1,this.spellcheck=!0}get valueAsDate(){var t;return(null==(t=this.input)?void 0:t.valueAsDate)??null}set valueAsDate(t){const e=document.createElement("input");e.type="date",e.valueAsDate=t,this.value=e.value}get valueAsNumber(){var t;return(null==(t=this.input)?void 0:t.valueAsNumber)??parseFloat(this.value)}set valueAsNumber(t){const e=document.createElement("input");e.type="number",e.valueAsNumber=t,this.value=e.value}get validity(){return this.input.validity}firstUpdated(){this.formControlController.updateValidity()}handleBlur(){this.hasFocus=!1,this.emit("sd-blur")}handleChange(){this.value=this.input.value,this.emit("sd-change")}handleClearClick(t){this.value="",this.emit("sd-clear"),this.emit("sd-2-4-2-input"),this.emit("sd-change"),this.input.focus(),t.stopPropagation()}handleFocus(){this.hasFocus=!0,this.emit("sd-focus")}handleInput(){this.value=this.input.value,this.formControlController.updateValidity(),this.emit("sd-2-4-2-input")}handleInvalid(t){this.formControlController.setValidity(!1),this.formControlController.emitInvalidEvent(t),this.invalidMessage.textContent=t.target.validationMessage}handleKeyDown(t){const e=t.metaKey||t.ctrlKey||t.shiftKey||t.altKey;"Enter"===t.key&&!e&&setTimeout((()=>{!t.defaultPrevented&&!t.isComposing&&this.formControlController.submit()}))}handlePasswordToggle(){this.passwordVisible=!this.passwordVisible}handleDisabledChange(){this.formControlController.setValidity(this.disabled)}handleStepChange(){this.input.step=String(this.step),this.formControlController.updateValidity()}async handleValueChange(){await this.updateComplete,this.formControlController.updateValidity()}focus(t){this.input.focus(t)}blur(){this.input.blur()}select(){this.input.select()}setSelectionRange(t,e,s="none"){this.input.setSelectionRange(t,e,s)}setRangeText(t,e,s,i){this.input.setRangeText(t,e,s,i),this.value!==this.input.value&&(this.value=this.input.value)}showPicker(){"showPicker"in HTMLInputElement.prototype&&this.input.showPicker()}stepUp(){this.input.stepUp(),this.value!==this.input.value&&(this.value=this.input.value)}stepDown(){this.input.stepDown(),this.value!==this.input.value&&(this.value=this.input.value)}checkValidity(){var t;return null==(t=this.input)?void 0:t.checkValidity()}reportValidity(){return this.formControlController.fakeUserInteraction(),this.input.reportValidity()}setCustomValidity(t){this.input.setCustomValidity(t),this.formControlController.updateValidity()}render(){const t=this.hasSlotController.test("label"),s=this.hasSlotController.test("help-text"),i=(this.hasSlotController.test("description"),this.hasSlotController.test("left")),l=this.hasSlotController.test("right"),a=!!this.label||!!t,o=!!this.helpText||!!s,r=this.clearable&&!this.readonly&&("number"==typeof this.value||this.value.length>0),h=this.disabled?"disabled":this.readonly?"readonly":this.hasFocus&&this.showInvalidStyle?"activeInvalid":this.hasFocus&&this.styleOnValid&&this.showValidStyle?"activeValid":this.hasFocus?"active":this.showInvalidStyle?"invalid":this.styleOnValid&&this.showValidStyle?"valid":"default",d="sm"===this.size?"text-sm":"text-base",u={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"}[h],c={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"}[h],m=this.disabled?"text-neutral-500":"text-primary",b={sm:"ml-1",md:"ml-2",lg:"ml-2"}[this.size],v={sm:"text-base",md:"text-lg",lg:"text-xl"}[this.size];return e`<div part="form-control" class="${y(this.disabled&&"pointer-events-none")}"><label part="form-control-label" id="label" class="${y("mb-2",a?"inline-block":"hidden",d)}" for="input" aria-hidden="${a?"false":"true"}"><slot name="label">${this.label}</slot></label><div part="form-control-input" class="relative w-full"><div part="border" class="${y("absolute w-full h-full pointer-events-none border rounded-default",c)}"></div><div part="base" class="${y("px-4 flex flex-row items-center rounded-default transition-all bg-white","lg"===this.size?"py-2":"py-1",this.disabled||this.readonly?"":"hover:bg-neutral-200",this.readonly&&"bg-neutral-100",u)}">${i?e`<slot name="left" part="left" class="${y("inline-flex","sm"===this.size?"mr-1":"mr-2",m,v)}"></slot>`:""} <input part="input" id="input" class="${y("min-w-0 flex-grow focus:outline-none bg-transparent placeholder-neutral-700","sm"===this.size?"h-6":"h-8",d)}" type="${"password"===this.type&&this.passwordVisible?"text":this.type}" title="${this.title}" name="${n(this.name)}" ?disabled="${this.disabled}" ?readonly="${this.readonly}" ?required="${this.required}" placeholder="${n(this.placeholder)}" minlength="${n(this.minlength)}" maxlength="${n(this.maxlength)}" min="${n(this.min)}" max="${n(this.max)}" step="${n(this.step)}" .value="${p(this.value)}" autocapitalize="${n("password"===this.type?"off":this.autocapitalize)}" autocomplete="${n("password"===this.type?"off":this.autocomplete)}" autocorrect="${n("password"===this.type?"off":this.autocorrect)}" ?autofocus="${this.autofocus}" spellcheck="${this.spellcheck}" pattern="${n(this.pattern)}" enterkeyhint="${n(this.enterkeyhint)}" inputmode="${n(this.inputmode)}" aria-describedby="help-text" @change="${this.handleChange}" @input="${this.handleInput}" @invalid="${this.handleInvalid}" @keydown="${this.handleKeyDown}" @focus="${this.handleFocus}" @blur="${this.handleBlur}"> ${r?e`<button part="clear-button" class="${y("flex justify-center ",b)}" type="button" aria-label="${this.localize.term("clearEntry")}" @click="${this.handleClearClick}" tabindex="-1"><slot name="clear-icon"><sd-2-4-2-icon class="${y("text-neutral-500",v)}" library="system" name="closing-round"></sd-2-4-2-icon></slot></button>`:""} ${this.passwordToggle&&"password"===this.type?e`<button aria-label="${this.localize.term(this.passwordVisible?"hidePassword":"showPassword")}" part="password-toggle-button" class="flex items-center" type="button" @click="${this.handlePasswordToggle}" tabindex="-1">${this.passwordVisible?e`<slot name="show-password-icon"><sd-2-4-2-icon class="${y(m,b,v)}" library="system" name="eye"></sd-2-4-2-icon></slot>`:e`<slot name="hide-password-icon"><sd-2-4-2-icon class="${y(m,b,v)}" library="system" name="eye-crossed-out"></sd-2-4-2-icon></slot>`}</button>`:""} ${"date"!==this.type&&"datetime-local"!==this.type||w?"":e`<sd-2-4-2-icon class="${y(m,b,v)}" library="system" name="calendar"></sd-2-4-2-icon>`} ${"time"===this.type?e`<sd-2-4-2-icon class="${y(m,b,v)}" library="system" name="clock"></sd-2-4-2-icon>`:""} ${this.showInvalidStyle?e`<sd-2-4-2-icon part="invalid-icon" class="${y("text-error",b,v)}" library="system" name="risk"></sd-2-4-2-icon>`:""} ${this.showValidStyle&&this.styleOnValid?e`<sd-2-4-2-icon class="${y("text-success",b,v)}" library="system" name="confirm" part="valid-icon"></sd-2-4-2-icon>`:""} ${l?e`<slot name="right" part="right" class="${y("inline-flex",m,b,v)}"></slot>`:""}</div></div><slot name="help-text" part="form-control-help-text" id="help-text" class="${y("text-sm text-neutral-700",o?"block":"hidden")}" aria-hidden="${!o}">${this.helpText}</slot></div>${this.formControlController.renderInvalidMessage()}`}};x.styles=[m,t.styles,s`:host{position:relative;box-sizing:border-box;display:inline-block;width:100%;text-align:left}:host([vertical]){display:block}:host([required]) #label::after{content:' *'}details summary::-webkit-details-marker{display:none}input::-webkit-inner-spin-button,input::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}input[type=number]{-moz-appearance:textfield}input[type=time]::-webkit-calendar-picker-indicator{background:0 0}details summary::-webkit-details-marker,input[type=date]::-webkit-calendar-picker-indicator,input[type=datetime-local]::-webkit-calendar-picker-indicator,input[type=search]::-webkit-search-cancel-button,input[type=search]::-webkit-search-decoration,input[type=search]::-webkit-search-results-button,input[type=search]::-webkit-search-results-decoration{display:none}`],g([u("#input")],x.prototype,"input",2),g([u("#invalid-message")],x.prototype,"invalidMessage",2),g([d()],x.prototype,"hasFocus",2),g([d()],x.prototype,"showValidStyle",2),g([d()],x.prototype,"showInvalidStyle",2),g([i({reflect:!0})],x.prototype,"type",2),g([i({reflect:!0})],x.prototype,"size",2),g([i()],x.prototype,"inputmode",2),g([i()],x.prototype,"value",2),g([a()],x.prototype,"defaultValue",2),g([i()],x.prototype,"placeholder",2),g([i()],x.prototype,"label",2),g([i({attribute:"help-text"})],x.prototype,"helpText",2),g([i({type:Boolean})],x.prototype,"clearable",2),g([i({type:Boolean,reflect:!0})],x.prototype,"disabled",2),g([i({type:Boolean,reflect:!0})],x.prototype,"readonly",2),g([i({attribute:"password-toggle",type:Boolean})],x.prototype,"passwordToggle",2),g([i({attribute:"password-visible",type:Boolean})],x.prototype,"passwordVisible",2),g([i({attribute:"no-spin-buttons",type:Boolean})],x.prototype,"noSpinButtons",2),g([i({type:Number})],x.prototype,"minlength",2),g([i({type:Number})],x.prototype,"maxlength",2),g([i({type:Number})],x.prototype,"min",2),g([i({type:Number})],x.prototype,"max",2),g([i({reflect:!0})],x.prototype,"form",2),g([i()],x.prototype,"name",2),g([i()],x.prototype,"title",2),g([i({type:Boolean,reflect:!0})],x.prototype,"required",2),g([i()],x.prototype,"pattern",2),g([i()],x.prototype,"step",2),g([i()],x.prototype,"autocapitalize",2),g([i()],x.prototype,"autocorrect",2),g([i()],x.prototype,"autocomplete",2),g([i({type:Boolean})],x.prototype,"autofocus",2),g([i()],x.prototype,"enterkeyhint",2),g([i({type:Boolean,reflect:!0,attribute:"style-on-valid"})],x.prototype,"styleOnValid",2),g([i({type:Boolean,converter:{fromAttribute:t=>!(!t||"false"===t),toAttribute:t=>t?"true":"false"}})],x.prototype,"spellcheck",2),g([c("disabled",{waitUntilFirstUpdate:!0})],x.prototype,"handleDisabledChange",1),g([c("step",{waitUntilFirstUpdate:!0})],x.prototype,"handleStepChange",1),g([c("value",{waitUntilFirstUpdate:!0})],x.prototype,"handleValueChange",1),x=g([l("sd-2-4-2-input")],x);export{x as default};
1
+ import"./icon.js";import{S as t,x as e,i as s,n as i,c as l}from"./solid-element.js";import{d as a}from"./default-value.js";import{F as o}from"./form.js";import{H as r}from"./slot.js";import{o as n}from"./if-defined.js";import{l as p}from"./live.js";import{L as h}from"./solid-components2.js";import{r as d}from"./state.js";import{e as u}from"./query.js";import{w as c}from"./watch.js";import{c as y}from"./component.styles.js";import{t as m}from"./classix.js";import"./request.js";import"./request2.js";import"./directive.js";var b,v=Object.defineProperty,f=Object.getOwnPropertyDescriptor,g=(t,e,s,i)=>{for(var l,a=i>1?void 0:i?f(e,s):e,o=t.length-1;o>=0;o--)(l=t[o])&&(a=(i?l(e,s,a):l(a))||a);return i&&a&&v(e,s,a),a};const w=!(null==(b=navigator.userAgentData)?void 0:b.brands.some((t=>t.brand.includes("Chromium"))))&&navigator.userAgent.includes("Firefox");let x=class extends t{constructor(){super(...arguments),this.formControlController=new o(this),this.hasSlotController=new r(this,"help-text","label","left","right","message","placeholder"),this.localize=new h(this),this.hasFocus=!1,this.showValidStyle=!1,this.showInvalidStyle=!1,this.type="text",this.size="lg",this.value="",this.defaultValue="",this.placeholder="",this.label="",this.helpText="",this.clearable=!1,this.disabled=!1,this.readonly=!1,this.passwordToggle=!1,this.passwordVisible=!1,this.noSpinButtons=!1,this.form="",this.name="",this.title="",this.required=!1,this.styleOnValid=!1,this.spellcheck=!0}get valueAsDate(){var t;return(null==(t=this.input)?void 0:t.valueAsDate)??null}set valueAsDate(t){const e=document.createElement("input");e.type="date",e.valueAsDate=t,this.value=e.value}get valueAsNumber(){var t;return(null==(t=this.input)?void 0:t.valueAsNumber)??parseFloat(this.value)}set valueAsNumber(t){const e=document.createElement("input");e.type="number",e.valueAsNumber=t,this.value=e.value}get validity(){return this.input.validity}firstUpdated(){this.formControlController.updateValidity()}handleBlur(){this.hasFocus=!1,this.emit("sd-blur")}handleChange(){this.value=this.input.value,this.emit("sd-change")}handleClearClick(t){this.value="",this.emit("sd-clear"),this.emit("sd-2-4-4-input"),this.emit("sd-change"),this.input.focus(),t.stopPropagation()}handleFocus(){this.hasFocus=!0,this.emit("sd-focus")}handleInput(){this.value=this.input.value,this.formControlController.updateValidity(),this.emit("sd-2-4-4-input")}handleInvalid(t){this.formControlController.setValidity(!1),this.formControlController.emitInvalidEvent(t),this.invalidMessage.textContent=t.target.validationMessage}handleKeyDown(t){const e=t.metaKey||t.ctrlKey||t.shiftKey||t.altKey;"Enter"===t.key&&!e&&setTimeout((()=>{!t.defaultPrevented&&!t.isComposing&&this.formControlController.submit()}))}handlePasswordToggle(){this.passwordVisible=!this.passwordVisible}handleDisabledChange(){this.formControlController.setValidity(this.disabled)}handleStepChange(){this.input.step=String(this.step),this.formControlController.updateValidity()}async handleValueChange(){await this.updateComplete,this.formControlController.updateValidity()}focus(t){this.input.focus(t)}blur(){this.input.blur()}select(){this.input.select()}setSelectionRange(t,e,s="none"){this.input.setSelectionRange(t,e,s)}setRangeText(t,e,s,i){this.input.setRangeText(t,e,s,i),this.value!==this.input.value&&(this.value=this.input.value)}showPicker(){"showPicker"in HTMLInputElement.prototype&&this.input.showPicker()}stepUp(){this.input.stepUp(),this.value!==this.input.value&&(this.value=this.input.value)}stepDown(){this.input.stepDown(),this.value!==this.input.value&&(this.value=this.input.value)}checkValidity(){var t;return null==(t=this.input)?void 0:t.checkValidity()}reportValidity(){return this.formControlController.fakeUserInteraction(),this.input.reportValidity()}setCustomValidity(t){this.input.setCustomValidity(t),this.formControlController.updateValidity()}render(){const t=this.hasSlotController.test("label"),s=this.hasSlotController.test("help-text"),i=(this.hasSlotController.test("description"),this.hasSlotController.test("left")),l=this.hasSlotController.test("right"),a=!!this.label||!!t,o=!!this.helpText||!!s,r=this.clearable&&!this.readonly&&("number"==typeof this.value||this.value.length>0),h=this.disabled?"disabled":this.readonly?"readonly":this.hasFocus&&this.showInvalidStyle?"activeInvalid":this.hasFocus&&this.styleOnValid&&this.showValidStyle?"activeValid":this.hasFocus?"active":this.showInvalidStyle?"invalid":this.styleOnValid&&this.showValidStyle?"valid":"default",d="sm"===this.size?"text-sm":"text-base",u={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"}[h],c={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"}[h],y=this.disabled?"text-neutral-500":"text-primary",b={sm:"ml-1",md:"ml-2",lg:"ml-2"}[this.size],v={sm:"text-base",md:"text-lg",lg:"text-xl"}[this.size];return e`<div part="form-control" class="${m(this.disabled&&"pointer-events-none")}"><label part="form-control-label" id="label" class="${m("mb-2",a?"inline-block":"hidden",d)}" for="input" aria-hidden="${a?"false":"true"}"><slot name="label">${this.label}</slot></label><div part="form-control-input" class="relative w-full"><div part="border" class="${m("absolute w-full h-full pointer-events-none border rounded-default",c)}"></div><div part="base" class="${m("px-4 flex flex-row items-center rounded-default transition-all bg-white","lg"===this.size?"py-2":"py-1",this.disabled||this.readonly?"":"hover:bg-neutral-200",this.readonly&&"bg-neutral-100",u)}">${i?e`<slot name="left" part="left" class="${m("inline-flex","sm"===this.size?"mr-1":"mr-2",y,v)}"></slot>`:""} <input part="input" id="input" class="${m("min-w-0 flex-grow focus:outline-none bg-transparent placeholder-neutral-700","sm"===this.size?"h-6":"h-8",d)}" type="${"password"===this.type&&this.passwordVisible?"text":this.type}" title="${this.title}" name="${n(this.name)}" ?disabled="${this.disabled}" ?readonly="${this.readonly}" ?required="${this.required}" placeholder="${n(this.placeholder)}" minlength="${n(this.minlength)}" maxlength="${n(this.maxlength)}" min="${n(this.min)}" max="${n(this.max)}" step="${n(this.step)}" .value="${p(this.value)}" autocapitalize="${n("password"===this.type?"off":this.autocapitalize)}" autocomplete="${n("password"===this.type?"off":this.autocomplete)}" autocorrect="${n("password"===this.type?"off":this.autocorrect)}" ?autofocus="${this.autofocus}" spellcheck="${this.spellcheck}" pattern="${n(this.pattern)}" enterkeyhint="${n(this.enterkeyhint)}" inputmode="${n(this.inputmode)}" aria-describedby="help-text" @change="${this.handleChange}" @input="${this.handleInput}" @invalid="${this.handleInvalid}" @keydown="${this.handleKeyDown}" @focus="${this.handleFocus}" @blur="${this.handleBlur}"> ${r?e`<button part="clear-button" class="${m("flex justify-center ",b)}" type="button" aria-label="${this.localize.term("clearEntry")}" @click="${this.handleClearClick}" tabindex="-1"><slot name="clear-icon"><sd-2-4-4-icon class="${m("text-neutral-500",v)}" library="system" name="closing-round"></sd-2-4-4-icon></slot></button>`:""} ${this.passwordToggle&&"password"===this.type?e`<button aria-label="${this.localize.term(this.passwordVisible?"hidePassword":"showPassword")}" part="password-toggle-button" class="flex items-center" type="button" @click="${this.handlePasswordToggle}" tabindex="-1">${this.passwordVisible?e`<slot name="show-password-icon"><sd-2-4-4-icon class="${m(y,b,v)}" library="system" name="eye"></sd-2-4-4-icon></slot>`:e`<slot name="hide-password-icon"><sd-2-4-4-icon class="${m(y,b,v)}" library="system" name="eye-crossed-out"></sd-2-4-4-icon></slot>`}</button>`:""} ${"date"!==this.type&&"datetime-local"!==this.type||w?"":e`<sd-2-4-4-icon class="${m(y,b,v)}" library="system" name="calendar"></sd-2-4-4-icon>`} ${"time"===this.type?e`<sd-2-4-4-icon class="${m(y,b,v)}" library="system" name="clock"></sd-2-4-4-icon>`:""} ${this.showInvalidStyle?e`<sd-2-4-4-icon part="invalid-icon" class="${m("text-error",b,v)}" library="system" name="risk"></sd-2-4-4-icon>`:""} ${this.showValidStyle&&this.styleOnValid?e`<sd-2-4-4-icon class="${m("text-success flex-shrink-0",b,v)}" library="system" name="confirm" part="valid-icon"></sd-2-4-4-icon>`:""} ${l?e`<slot name="right" part="right" class="${m("inline-flex",y,b,v)}"></slot>`:""}</div></div><slot name="help-text" part="form-control-help-text" id="help-text" class="${m("text-sm text-neutral-700",o?"block":"hidden")}" aria-hidden="${!o}">${this.helpText}</slot></div>${this.formControlController.renderInvalidMessage()}`}};x.styles=[y,t.styles,s`:host{position:relative;box-sizing:border-box;display:inline-block;width:100%;text-align:left}:host([vertical]){display:block}:host([required]) #label::after{content:' *'}details summary::-webkit-details-marker{display:none}input::-webkit-inner-spin-button,input::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}input[type=number]{-moz-appearance:textfield}input[type=time]::-webkit-calendar-picker-indicator{background:0 0}details summary::-webkit-details-marker,input[type=date]::-webkit-calendar-picker-indicator,input[type=datetime-local]::-webkit-calendar-picker-indicator,input[type=search]::-webkit-search-cancel-button,input[type=search]::-webkit-search-decoration,input[type=search]::-webkit-search-results-button,input[type=search]::-webkit-search-results-decoration{display:none}`],g([u("#input")],x.prototype,"input",2),g([u("#invalid-message")],x.prototype,"invalidMessage",2),g([d()],x.prototype,"hasFocus",2),g([d()],x.prototype,"showValidStyle",2),g([d()],x.prototype,"showInvalidStyle",2),g([i({reflect:!0})],x.prototype,"type",2),g([i({reflect:!0})],x.prototype,"size",2),g([i()],x.prototype,"inputmode",2),g([i()],x.prototype,"value",2),g([a()],x.prototype,"defaultValue",2),g([i()],x.prototype,"placeholder",2),g([i()],x.prototype,"label",2),g([i({attribute:"help-text"})],x.prototype,"helpText",2),g([i({type:Boolean})],x.prototype,"clearable",2),g([i({type:Boolean,reflect:!0})],x.prototype,"disabled",2),g([i({type:Boolean,reflect:!0})],x.prototype,"readonly",2),g([i({attribute:"password-toggle",type:Boolean})],x.prototype,"passwordToggle",2),g([i({attribute:"password-visible",type:Boolean})],x.prototype,"passwordVisible",2),g([i({attribute:"no-spin-buttons",type:Boolean})],x.prototype,"noSpinButtons",2),g([i({type:Number})],x.prototype,"minlength",2),g([i({type:Number})],x.prototype,"maxlength",2),g([i({type:Number})],x.prototype,"min",2),g([i({type:Number})],x.prototype,"max",2),g([i({reflect:!0})],x.prototype,"form",2),g([i()],x.prototype,"name",2),g([i()],x.prototype,"title",2),g([i({type:Boolean,reflect:!0})],x.prototype,"required",2),g([i()],x.prototype,"pattern",2),g([i()],x.prototype,"step",2),g([i()],x.prototype,"autocapitalize",2),g([i()],x.prototype,"autocorrect",2),g([i()],x.prototype,"autocomplete",2),g([i({type:Boolean})],x.prototype,"autofocus",2),g([i()],x.prototype,"enterkeyhint",2),g([i({type:Boolean,reflect:!0,attribute:"style-on-valid"})],x.prototype,"styleOnValid",2),g([i({type:Boolean,converter:{fromAttribute:t=>!(!t||"false"===t),toAttribute:t=>t?"true":"false"}})],x.prototype,"spellcheck",2),g([c("disabled",{waitUntilFirstUpdate:!0})],x.prototype,"handleDisabledChange",1),g([c("step",{waitUntilFirstUpdate:!0})],x.prototype,"handleStepChange",1),g([c("value",{waitUntilFirstUpdate:!0})],x.prototype,"handleValueChange",1),x=g([l("sd-2-4-4-input")],x);export{x as default};
@@ -1 +1 @@
1
- import{S as t,x as e,i as s,n as i}from"./solid-element.js";import{c as o}from"./register-custom-element.js";import{H as r}from"./slot.js";import{o as l}from"./if-defined.js";import{e as n}from"./query.js";import{t as a}from"./classix.js";var h=Object.defineProperty,d=Object.getOwnPropertyDescriptor,f=(t,e,s,i)=>{for(var o,r=i>1?void 0:i?d(e,s):e,l=t.length-1;l>=0;l--)(o=t[l])&&(r=(i?o(e,s,r):o(r))||r);return i&&r&&h(e,s,r),r};let m=class extends t{constructor(){super(...arguments),this.hasSlotController=new r(this,"[default]","icon-left","icon-right"),this.size="inherit",this.inverted=!1,this.standalone=!1,this.href=""}handleBlur(){this.emit("sd-blur")}handleFocus(){this.emit("sd-focus")}focus(t){this.button.focus(t)}blur(){this.button.blur()}render(){const t={label:this.hasSlotController.test("[default]"),"icon-left":this.hasSlotController.test("icon-left"),"icon-right":this.hasSlotController.test("icon-right")};return e`<a part="base" class="${a("inline",this.href?"cursor-pointer":"",{sm:"text-sm",lg:"text-base",inherit:""}[this.size],{disabled:this.inverted?"text-neutral-600":"text-neutral-500",enabled:this.inverted?"text-white hover:text-primary-200 active:text-primary-400 focus-visible:focus-outline-inverted":" text-primary hover:text-primary-500 active:text-primary-800 focus-visible:focus-outline"}[this.href?"enabled":"disabled"],this.standalone&&"flex items-start")}" href="${l(this.href||void 0)}" target="${l(this.target||void 0)}" download="${l(this.download||void 0)}" rel="${l(this.target?"noreferrer noopener":void 0)}" aria-disabled="${this.href?"false":"true"}" tabindex="${this.href?"0":"-1"}" @blur="${this.handleBlur}" @focus="${this.handleFocus}"><slot name="icon-left" part="icon-left" class="${a("inline",t["icon-left"]&&(this.standalone?{sm:"mr-1",lg:"mr-2",inherit:"mr-[0.5em]"}[this.size]:"mr-[0.25em]"))}"></slot><span part="label" class="inline underline underline-offset-2"><slot></slot></span><slot name="icon-right" part="icon-right" class="${a("inline",t["icon-right"]&&(this.standalone?{sm:"ml-1",lg:"ml-2",inherit:"ml-[0.5em]"}[this.size]:"ml-[0.25em]"))}"></slot></a>`}};m.styles=[t.styles,s`::slotted(sd-2-4-2-icon){font-size:1.25em;margin-bottom:-.25em}:host([size=sm][standalone]) ::slotted(sd-2-4-2-icon){font-size:var(--sd-font-size-base,1rem)}:host([size=lg][standalone]) ::slotted(sd-2-4-2-icon){font-size:var(--sd-font-size-xl,1.5rem)}`],f([n("a")],m.prototype,"button",2),f([i({reflect:!0})],m.prototype,"size",2),f([i({type:Boolean,reflect:!0})],m.prototype,"inverted",2),f([i({type:Boolean,reflect:!0})],m.prototype,"standalone",2),f([i()],m.prototype,"href",2),f([i()],m.prototype,"target",2),f([i()],m.prototype,"download",2),m=f([o("sd-2-4-2-link")],m);export{m as default};
1
+ import{S as t,x as e,i as s,n as i,c as o}from"./solid-element.js";import{H as r}from"./slot.js";import{o as l}from"./if-defined.js";import{e as n}from"./query.js";import{t as a}from"./classix.js";var h=Object.defineProperty,d=Object.getOwnPropertyDescriptor,f=(t,e,s,i)=>{for(var o,r=i>1?void 0:i?d(e,s):e,l=t.length-1;l>=0;l--)(o=t[l])&&(r=(i?o(e,s,r):o(r))||r);return i&&r&&h(e,s,r),r};let c=class extends t{constructor(){super(...arguments),this.hasSlotController=new r(this,"[default]","icon-left","icon-right"),this.size="inherit",this.inverted=!1,this.standalone=!1,this.href=""}handleBlur(){this.emit("sd-blur")}handleFocus(){this.emit("sd-focus")}focus(t){this.button.focus(t)}blur(){this.button.blur()}render(){const t={label:this.hasSlotController.test("[default]"),"icon-left":this.hasSlotController.test("icon-left"),"icon-right":this.hasSlotController.test("icon-right")};return e`<a part="base" class="${a("inline",this.href?"cursor-pointer":"",{sm:"text-sm",lg:"text-base",inherit:""}[this.size],{disabled:this.inverted?"text-neutral-600":"text-neutral-500",enabled:this.inverted?"text-white hover:text-primary-200 active:text-primary-400 focus-visible:focus-outline-inverted":" text-primary hover:text-primary-500 active:text-primary-800 focus-visible:focus-outline"}[this.href?"enabled":"disabled"],this.standalone&&"flex items-start")}" href="${l(this.href||void 0)}" target="${l(this.target||void 0)}" download="${l(this.download||void 0)}" rel="${l(this.target?"noreferrer noopener":void 0)}" aria-disabled="${this.href?"false":"true"}" tabindex="${this.href?"0":"-1"}" @blur="${this.handleBlur}" @focus="${this.handleFocus}"><slot name="icon-left" part="icon-left" class="${a("inline",t["icon-left"]&&(this.standalone?{sm:"mr-1",lg:"mr-2",inherit:"mr-[0.5em]"}[this.size]:"mr-[0.25em]"))}"></slot><span part="label" class="inline underline underline-offset-2"><slot></slot></span><slot name="icon-right" part="icon-right" class="${a("inline",t["icon-right"]&&(this.standalone?{sm:"ml-1",lg:"ml-2",inherit:"ml-[0.5em]"}[this.size]:"ml-[0.25em]"))}"></slot></a>`}};c.styles=[t.styles,s`::slotted(sd-2-4-4-icon){font-size:1.25em;margin-bottom:-.25em}:host([size=sm][standalone]) ::slotted(sd-2-4-4-icon){font-size:var(--sd-font-size-base,1rem)}:host([size=lg][standalone]) ::slotted(sd-2-4-4-icon){font-size:var(--sd-font-size-xl,1.5rem)}`],f([n("a")],c.prototype,"button",2),f([i({reflect:!0})],c.prototype,"size",2),f([i({type:Boolean,reflect:!0})],c.prototype,"inverted",2),f([i({type:Boolean,reflect:!0})],c.prototype,"standalone",2),f([i()],c.prototype,"href",2),f([i()],c.prototype,"target",2),f([i()],c.prototype,"download",2),c=f([o("sd-2-4-4-link")],c);export{c as default};
@@ -1,6 +1 @@
1
- import{S as t,i as e,n as i}from"./solid-element.js";import{H as s}from"./slot.js";import{s as o,n as r}from"./static.js";import{o as l}from"./if-defined.js";import{c as a}from"./component.styles.js";import{t as n}from"./classix.js";
2
- /**
3
- * @license
4
- * Copyright 2017 Google LLC
5
- * SPDX-License-Identifier: BSD-3-Clause
6
- */var d=Object.defineProperty,h=Object.getOwnPropertyDescriptor,c=(t,e,i,s)=>{for(var o,r=s>1?void 0:s?h(e,i):e,l=t.length-1;l>=0;l--)(o=t[l])&&(r=(s?o(e,i,r):o(r))||r);return s&&r&&d(e,i,r),r};let p=class extends t{constructor(){super(...arguments),this.hasSlotController=new s(this,"[default]","description","children"),this.href="",this.current=!1,this.disabled=!1,this.size="base",this.vertical=!1,this.chevron=!1,this.indented=!1,this.relaxed=!1,this.divider=!1,this.open=!1}isButton(){return!this.href&&!this.hasSlotController.test("children")}isLink(){return!!this.href}isAccordion(){return!this.href&&this.hasSlotController.test("children")}handleClickButton(t){this.disabled&&(t.preventDefault(),t.stopPropagation())}handleClickSummary(t){t.preventDefault(),t.stopPropagation(),this.disabled||(this.open?this.hideDetails():this.showDetails())}hideDetails(){this.open=!1,this.emit("sd-hide",{cancelable:!0})}showDetails(){this.open=!0,this.emit("sd-show",{cancelable:!0})}calculatePaddingX(){return this.relaxed&&this.indented?"pl-8 pr-4":this.relaxed?"px-4":this.indented?"pl-4":""}render(){const t=this.isLink(),e=this.isButton(),i=this.isAccordion(),s=(this.hasSlotController.test("[default]"),this.hasSlotController.test("main"),this.hasSlotController.test("description")),a=this.hasSlotController.test("children"),d=t?o`a`:i?o`summary`:o`button`,h=this.vertical?"pb-3":"pb-2",c=r`<${d} part="base" class="${n("hover:bg-neutral-200 group transition-all min-h-[48px] cursor-pointer relative focus-visible:focus-outline",{base:"text-base",lg:"text-lg",sm:"text-[14px]"}[this.size],this.disabled?"text-neutral-500 pointer-events-none":"text-primary",i?"flex flex-col":"inline-block w-full",this.divider&&this.vertical&&"mt-[1px]",this.vertical?"px-8":"px-4")}" aria-controls="${l(i?"navigation-item-details":void 0)}" aria-current="${l(this.current?"page":void 0)}" aria-disabled="${this.disabled}" ?disabled="${l(e?this.disabled:void 0)}" href="${l(this.href||void 0)}" target="${l(t?this.target:void 0)}" download="${l(t?this.download:void 0)}" rel="${l(t&&this.target?"noreferrer noopener":void 0)}" role="${t?"link":"button"}" tabindex="${this.disabled?"-1":"0"}" @click="${i?this.handleClickSummary:e?this.handleClickButton:void 0}"><div part="current-indicator" class="${n("absolute left-0 pointer-events-none transition-all duration-150",this.vertical?"w-1 h-[calc(100%-8px)] top-1 group-hover:h-full group-hover:top-0":"h-1 w-full bottom-0",this.current?"bg-accent":"bg-transparent",this.disabled&&"bg-neutral-500")}"></div><span part="content-area" class="${n("relative pt-3 inline-flex justify-between items-center",i?"grow":"w-full",s?"pb-1":h,this.calculatePaddingX())}">${this.divider&&this.vertical?r`<sd-2-4-2-divider part="divider" class="${n("w-full transition-all absolute -top-[1px] left-0",this.calculatePaddingX())}"></sd-2-4-2-divider>`:""} <span part="content-container" class="inline-flex items-center flex-auto"><slot part="content" class="inline"></slot></span>${(this.chevron||a)&&this.vertical?r`<sd-2-4-2-icon name="chevron-down" part="chevron" library="system" color="currentColor" class="${n("h-6 w-6 ml-2 transition-all",i?this.open?"rotate-180":"rotate-0":"rotate-[270deg]")}"></sd-2-4-2-icon>`:""} </span>${s&&this.vertical?r`<slot name="description" part="description" class="${n("inline-block text-sm text-left text-black",i?"grow":"w-full",h,this.calculatePaddingX())}"></slot>`:""}</${d}>`;return i?r`<details part="details" id="navigation-item-details" ?open="${this.open}" class="relative flex">${c}<slot name="children"></slot></details>`:r`${c}`}};var u;p.styles=[a,t.styles,e`:host{position:relative;box-sizing:border-box;display:inline-block}:host([vertical]){display:block}details summary::-webkit-details-marker{display:none}`],c([i({reflect:!0})],p.prototype,"href",2),c([i()],p.prototype,"target",2),c([i()],p.prototype,"download",2),c([i({type:Boolean,reflect:!0})],p.prototype,"current",2),c([i({type:Boolean,reflect:!0})],p.prototype,"disabled",2),c([i({reflect:!0})],p.prototype,"size",2),c([i({type:Boolean,reflect:!0})],p.prototype,"vertical",2),c([i({type:Boolean,reflect:!0})],p.prototype,"chevron",2),c([i({type:Boolean,reflect:!0})],p.prototype,"indented",2),c([i({type:Boolean,reflect:!0})],p.prototype,"relaxed",2),c([i({type:Boolean,reflect:!0})],p.prototype,"divider",2),c([i({type:Boolean,reflect:!0})],p.prototype,"open",2),p=c([(u="sd-2-4-2-navigation-item",(t,e)=>{void 0!==e?e.addInitializer((()=>{customElements.define(u,t)})):customElements.define(u,t)})],p);export{p as default};
1
+ import{S as t,i as e,n as i,c as s}from"./solid-element.js";import{H as r}from"./slot.js";import{s as o,n as l}from"./static.js";import{o as a}from"./if-defined.js";import{c as n}from"./component.styles.js";import{t as d}from"./classix.js";var h=Object.defineProperty,c=Object.getOwnPropertyDescriptor,p=(t,e,i,s)=>{for(var r,o=s>1?void 0:s?c(e,i):e,l=t.length-1;l>=0;l--)(r=t[l])&&(o=(s?r(e,i,o):r(o))||o);return s&&o&&h(e,i,o),o};let u=class extends t{constructor(){super(...arguments),this.hasSlotController=new r(this,"[default]","description","children"),this.href="",this.current=!1,this.disabled=!1,this.size="base",this.vertical=!1,this.chevron=!1,this.indented=!1,this.relaxed=!1,this.divider=!1,this.open=!1}isButton(){return!this.href&&!this.hasSlotController.test("children")}isLink(){return!!this.href}isAccordion(){return!this.href&&this.hasSlotController.test("children")}handleClickButton(t){this.disabled&&(t.preventDefault(),t.stopPropagation())}handleClickSummary(t){t.preventDefault(),t.stopPropagation(),this.disabled||(this.open?this.hideDetails():this.showDetails())}hideDetails(){this.open=!1,this.emit("sd-hide",{cancelable:!0})}showDetails(){this.open=!0,this.emit("sd-show",{cancelable:!0})}calculatePaddingX(){return this.relaxed&&this.indented?"pl-8 pr-4":this.relaxed?"px-4":this.indented?"pl-4":""}render(){const t=this.isLink(),e=this.isButton(),i=this.isAccordion(),s=(this.hasSlotController.test("[default]"),this.hasSlotController.test("main"),this.hasSlotController.test("description")),r=this.hasSlotController.test("children"),n=t?o`a`:i?o`summary`:o`button`,h=this.vertical?"pb-3":"pb-2",c=l`<${n} part="base" class="${d("hover:bg-neutral-200 group transition-all min-h-[48px] cursor-pointer relative focus-visible:focus-outline",{base:"text-base",lg:"text-lg",sm:"text-[14px]"}[this.size],this.disabled?"text-neutral-500 pointer-events-none":"text-primary",i?"flex flex-col":"inline-block w-full",this.divider&&this.vertical&&"mt-[1px]",this.vertical?"px-8":"px-4")}" aria-controls="${a(i?"navigation-item-details":void 0)}" aria-current="${a(this.current?"page":void 0)}" aria-disabled="${this.disabled}" ?disabled="${a(e?this.disabled:void 0)}" href="${a(this.href||void 0)}" target="${a(t?this.target:void 0)}" download="${a(t?this.download:void 0)}" rel="${a(t&&this.target?"noreferrer noopener":void 0)}" role="${t?"link":"button"}" tabindex="${this.disabled?"-1":"0"}" @click="${i?this.handleClickSummary:e?this.handleClickButton:void 0}"><div part="current-indicator" class="${d("absolute left-0 pointer-events-none transition-all duration-150",this.vertical?"w-1 h-[calc(100%-8px)] top-1 group-hover:h-full group-hover:top-0":"h-1 w-full bottom-0",this.current?"bg-accent":"bg-transparent",this.disabled&&"bg-neutral-500")}"></div><span part="content-area" class="${d("relative pt-3 inline-flex justify-between items-center",i?"grow":"w-full",s?"pb-1":h,this.calculatePaddingX())}">${this.divider&&this.vertical?l`<sd-2-4-4-divider part="divider" class="${d("w-full transition-all absolute -top-[1px] left-0",this.calculatePaddingX())}"></sd-2-4-4-divider>`:""} <span part="content-container" class="inline-flex items-center flex-auto"><slot part="content" class="inline"></slot></span>${(this.chevron||r)&&this.vertical?l`<sd-2-4-4-icon name="chevron-down" part="chevron" library="system" color="currentColor" class="${d("h-6 w-6 ml-2 transition-all",i?this.open?"rotate-180":"rotate-0":"rotate-[270deg]")}"></sd-2-4-4-icon>`:""} </span>${s&&this.vertical?l`<slot name="description" part="description" class="${d("inline-block text-sm text-left text-black",i?"grow":"w-full",h,this.calculatePaddingX())}"></slot>`:""}</${n}>`;return i?l`<details part="details" id="navigation-item-details" ?open="${this.open}" class="relative flex">${c}<slot name="children"></slot></details>`:l`${c}`}};u.styles=[n,t.styles,e`:host{position:relative;box-sizing:border-box;display:inline-block}:host([vertical]){display:block}details summary::-webkit-details-marker{display:none}`],p([i({reflect:!0})],u.prototype,"href",2),p([i()],u.prototype,"target",2),p([i()],u.prototype,"download",2),p([i({type:Boolean,reflect:!0})],u.prototype,"current",2),p([i({type:Boolean,reflect:!0})],u.prototype,"disabled",2),p([i({reflect:!0})],u.prototype,"size",2),p([i({type:Boolean,reflect:!0})],u.prototype,"vertical",2),p([i({type:Boolean,reflect:!0})],u.prototype,"chevron",2),p([i({type:Boolean,reflect:!0})],u.prototype,"indented",2),p([i({type:Boolean,reflect:!0})],u.prototype,"relaxed",2),p([i({type:Boolean,reflect:!0})],u.prototype,"divider",2),p([i({type:Boolean,reflect:!0})],u.prototype,"open",2),u=p([s("sd-2-4-4-navigation-item")],u);export{u as default};
@@ -1 +1 @@
1
- import{s as t,a as e,w as i}from"./event.js";import{S as s,x as o,i as a,n as r}from"./solid-element.js";import{c as n}from"./register-custom-element.js";import{g as d,s as l}from"./animation-registry.js";import{L as c}from"./solid-components2.js";import{e as h}from"./query.js";import{w as m}from"./watch.js";import{c as p}from"./component.styles.js";import{t as u}from"./classix.js";var f=Object.defineProperty,y=Object.getOwnPropertyDescriptor,b=(t,e,i,s)=>{for(var o,a=s>1?void 0:s?y(e,i):e,r=t.length-1;r>=0;r--)(o=t[r])&&(a=(s?o(e,i,a):o(a))||a);return s&&a&&f(e,i,a),a};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 s{constructor(){super(...arguments),this.localize=new c(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:i,options:s}=d(this,"notification.show",{dir:this.localize.dir()});await e(this.base,i,s),this.emit("sd-after-show")}else{this.emit("sd-hide"),clearTimeout(this.autoHideTimeout),await t(this.base);const{keyframes:i,options:s}=d(this,"notification.hide",{dir:this.localize.dir()});await e(this.base,i,s),this.base.hidden=!0,this.emit("sd-after-hide")}}handleDurationChange(){this.startAutoHide()}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")}async toast(){return new Promise((t=>{const e="bottom-center"===this.toastStack?g:w;null===e.parentElement&&document.body.append(e),e.appendChild(this),requestAnimationFrame((()=>{this.clientWidth,this.show()})),this.addEventListener("sd-after-hide",(()=>{e.removeChild(this),t(),null===e.querySelector("sd-2-4-2-notification")&&e.remove()}),{once:!0})}))}render(){return o`<div part="base" class="${u("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="${u("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-2-4-2-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-2-4-2-icon></slot><div part="content" class="${u("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?o`<sd-2-4-2-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-2-4-2-icon name="close" library="system" color="currentColor"></sd-2-4-2-icon></sd-2-4-2-button>`:""}</div>${this.durationIndicator?o`<div part="duration-indicator__elapsed" id="duration-indicator__elapsed" style="${`animation-duration: ${this.duration}ms`}" class="${u("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=[p,s.styles,a`:host{display:contents}#notification:hover #duration-indicator__elapsed{animation-play-state:paused!important}`],b([h('[part~="base"]')],v.prototype,"base",2),b([r({type:Boolean,reflect:!0})],v.prototype,"open",2),b([r({type:Boolean,reflect:!0})],v.prototype,"closable",2),b([r({reflect:!0})],v.prototype,"variant",2),b([r({reflect:!0,attribute:"toast-stack"})],v.prototype,"toastStack",2),b([r({type:Number})],v.prototype,"duration",2),b([r({type:Boolean,reflect:!0,attribute:"duration-indicator"})],v.prototype,"durationIndicator",2),b([m("open",{waitUntilFirstUpdate:!0})],v.prototype,"handleOpenChange",1),b([m("duration")],v.prototype,"handleDurationChange",1),v=b([n("sd-2-4-2-notification")],v),l("notification.show",{keyframes:[{opacity:0,scale:.8},{opacity:1,scale:1}],options:{duration:250,easing:"ease"}}),l("notification.hide",{keyframes:[{opacity:1,scale:1},{opacity:0,scale:.8}],options:{duration:250,easing:"ease"}});export{v as default};
1
+ import{s as t,a as i,w as e}from"./event.js";import{S as s,x as o,i as a,n as r,c as n}from"./solid-element.js";import{g as d,s as l}from"./animation-registry.js";import{L as c}from"./solid-components2.js";import{e as h}from"./query.js";import{w as p}from"./watch.js";import{c as m}from"./component.styles.js";import{t as u}from"./classix.js";var f=Object.defineProperty,y=Object.getOwnPropertyDescriptor,b=(t,i,e,s)=>{for(var o,a=s>1?void 0:s?y(i,e):i,r=t.length-1;r>=0;r--)(o=t[r])&&(a=(s?o(i,e,a):o(a))||a);return s&&a&&f(i,e,a),a};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 s{constructor(){super(...arguments),this.localize=new c(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}=d(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}=d(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,e(this,"sd-after-show")}async hide(){if(this.open)return this.open=!1,e(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-2-4-4-notification")&&i.remove()}),{once:!0})}))}render(){return o`<div part="base" class="${u("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="${u("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-2-4-4-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-2-4-4-icon></slot><div part="content" class="${u("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?o`<sd-2-4-4-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-2-4-4-icon name="close" library="system" color="currentColor"></sd-2-4-4-icon></sd-2-4-4-button>`:""}</div>${this.durationIndicator?o`<div part="duration-indicator__elapsed" id="duration-indicator__elapsed" style="${`animation-duration: ${this.duration}ms`}" class="${u("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=[m,s.styles,a`:host{display:contents}#notification:hover #duration-indicator__elapsed{animation-play-state:paused!important}`],b([h('[part~="base"]')],v.prototype,"base",2),b([r({type:Boolean,reflect:!0})],v.prototype,"open",2),b([r({type:Boolean,reflect:!0})],v.prototype,"closable",2),b([r({reflect:!0})],v.prototype,"variant",2),b([r({reflect:!0,attribute:"toast-stack"})],v.prototype,"toastStack",2),b([r({type:Number})],v.prototype,"duration",2),b([r({type:Boolean,reflect:!0,attribute:"duration-indicator"})],v.prototype,"durationIndicator",2),b([p("open",{waitUntilFirstUpdate:!0})],v.prototype,"handleOpenChange",1),b([p("duration")],v.prototype,"handleDurationChange",1),v=b([n("sd-2-4-4-notification")],v),l("notification.show",{keyframes:[{opacity:0,scale:.8},{opacity:1,scale:1}],options:{duration:250,easing:"ease"}}),l("notification.hide",{keyframes:[{opacity:1,scale:1},{opacity:0,scale:.8}],options:{duration:250,easing:"ease"}});export{v as default};
@@ -1 +1 @@
1
- import"./icon.js";import{S as e,x as t,i as s,n as l}from"./solid-element.js";import{c as a}from"./register-custom-element.js";import{H as o}from"./slot.js";import{L as r}from"./solid-components2.js";import{r as i}from"./state.js";import{e as n}from"./query.js";import{w as h}from"./watch.js";import{c}from"./component.styles.js";import{t as d}from"./classix.js";import"./request.js";import"./request2.js";import"./directive.js";var p=Object.defineProperty,u=Object.getOwnPropertyDescriptor,b=(e,t,s,l)=>{for(var a,o=l>1?void 0:l?u(t,s):t,r=e.length-1;r>=0;r--)(a=e[r])&&(o=(l?a(t,s,o):a(o))||o);return l&&o&&p(t,s,o),o};let m=class extends e{constructor(){super(...arguments),this.hasSlotController=new o(this,"default","left","right"),this.localize=new r(this),this.current=!1,this.selected=!1,this.hasHover=!1,this.size="lg",this.checkbox=!1,this.disabled=!1,this.value=""}connectedCallback(){super.connectedCallback(),this.setAttribute("role","option"),this.setAttribute("aria-selected","false")}handleDefaultSlotChange(){const e=this.getTextLabel();typeof this.cachedTextLabel>"u"?this.cachedTextLabel=e:e!==this.cachedTextLabel&&(this.cachedTextLabel=e,this.emit("slotchange",{bubbles:!0,composed:!1,cancelable:!1}))}handleMouseEnter(){this.hasHover=!0}handleMouseLeave(){this.hasHover=!1}handleDisabledChange(){this.setAttribute("aria-disabled",this.disabled?"true":"false")}handleSelectedChange(){this.setAttribute("aria-selected",this.selected?"true":"false")}handleValueChange(){this.value.includes(" ")&&(console.error("Option values cannot include a space. All spaces have been replaced with underscores.",this),this.value=this.value.replace(/ /g,"_"))}getTextLabel(){return(this.textContent??"").trim()}render(){this.hasSlotController.test("default");const e=this.hasSlotController.test("left"),s=this.hasSlotController.test("right");return t`<div part="base" class="${d("px-4 flex items-center w-full transition-all text-left text-base relative text-black",{sm:"text-sm py-1",md:"text-base py-2",lg:"text-base py-3"}[this.size],this.disabled?"text-neutral-500 cursor-not-allowed":"cursor-pointer",this.hasHover&&!this.disabled?"bg-neutral-200":"",this.current&&"bg-neutral-200")}" @mouseenter="${this.handleMouseEnter}" @mouseleave="${this.handleMouseLeave}"><span class="${d("absolute w-full left-0 top-0 pointer-events-none transition-all duration-150 border-l-4 h-[calc(100%-8px)]",this.selected&&!this.checkbox?"border-accent":"border-transparent",this.disabled&&"border-neutral-500 top-1",!this.disabled&&this.hasHover?"h-full top-0":"top-1")}"></span> ${this.checkbox?t`<span id="control" part="control ${this.selected?" control--checked":"control--unchecked"}" class="${d("relative flex flex-initial items-center justify-center border rounded-sm h-4 w-4 mr-2",this.disabled?"border-neutral-500":this.selected?"bg-accent border-accent":"border-neutral-800")}">${this.selected?t`<sd-2-4-2-icon part="checked-icon" class="text-white w-3 h-3" library="system" name="status-hook"></sd-2-4-2-icon>`:""}</span>`:""} ${e?t`<slot name="left" part="left" class="inline-flex mr-2"></slot>`:""}<slot part="label" class="inline-block flex-grow" @slotchange="${this.handleDefaultSlotChange}"></slot>${s?t`<slot name="right" part="right" class="inline-flex ml-2"></slot>`:""}</div>`}};m.styles=[c,e.styles,s`:host{position:relative;display:block;width:100%;outline:2px solid transparent!important;outline-offset:2px!important}`],b([n('[part="base"]')],m.prototype,"defaultSlot",2),b([i()],m.prototype,"current",2),b([i()],m.prototype,"selected",2),b([i()],m.prototype,"hasHover",2),b([l({reflect:!0})],m.prototype,"size",2),b([l({type:Boolean,reflect:!0})],m.prototype,"checkbox",2),b([l({type:Boolean,reflect:!0})],m.prototype,"disabled",2),b([l({reflect:!0})],m.prototype,"value",2),b([h("disabled")],m.prototype,"handleDisabledChange",1),b([h("selected")],m.prototype,"handleSelectedChange",1),b([h("value")],m.prototype,"handleValueChange",1),m=b([a("sd-2-4-2-option")],m);export{m as default};
1
+ import"./icon.js";import{S as e,x as t,i as s,n as l,c as a}from"./solid-element.js";import{H as o}from"./slot.js";import{L as r}from"./solid-components2.js";import{r as i}from"./state.js";import{e as n}from"./query.js";import{w as h}from"./watch.js";import{c}from"./component.styles.js";import{t as d}from"./classix.js";import"./request.js";import"./request2.js";import"./directive.js";var p=Object.defineProperty,u=Object.getOwnPropertyDescriptor,b=(e,t,s,l)=>{for(var a,o=l>1?void 0:l?u(t,s):t,r=e.length-1;r>=0;r--)(a=e[r])&&(o=(l?a(t,s,o):a(o))||o);return l&&o&&p(t,s,o),o};let m=class extends e{constructor(){super(...arguments),this.hasSlotController=new o(this,"default","left","right"),this.localize=new r(this),this.current=!1,this.selected=!1,this.hasHover=!1,this.size="lg",this.checkbox=!1,this.disabled=!1,this.value=""}connectedCallback(){super.connectedCallback(),this.setAttribute("role","option"),this.setAttribute("aria-selected","false")}handleDefaultSlotChange(){const e=this.getTextLabel();typeof this.cachedTextLabel>"u"?this.cachedTextLabel=e:e!==this.cachedTextLabel&&(this.cachedTextLabel=e,this.emit("slotchange",{bubbles:!0,composed:!1,cancelable:!1}))}handleMouseEnter(){this.hasHover=!0}handleMouseLeave(){this.hasHover=!1}handleDisabledChange(){this.setAttribute("aria-disabled",this.disabled?"true":"false")}handleSelectedChange(){this.setAttribute("aria-selected",this.selected?"true":"false")}handleValueChange(){this.value.includes(" ")&&(console.error("Option values cannot include a space. All spaces have been replaced with underscores.",this),this.value=this.value.replace(/ /g,"_"))}getTextLabel(){return(this.textContent??"").trim()}render(){this.hasSlotController.test("default");const e=this.hasSlotController.test("left"),s=this.hasSlotController.test("right");return t`<div part="base" class="${d("px-4 flex items-center w-full transition-all text-left text-base relative text-black",{sm:"text-sm py-1",md:"text-base py-2",lg:"text-base py-3"}[this.size],this.disabled?"text-neutral-500 cursor-not-allowed":"cursor-pointer",this.hasHover&&!this.disabled?"bg-neutral-200":"",this.current&&"bg-neutral-200")}" @mouseenter="${this.handleMouseEnter}" @mouseleave="${this.handleMouseLeave}"><span class="${d("absolute w-full left-0 top-0 pointer-events-none transition-all duration-150 border-l-4 h-[calc(100%-8px)]",this.selected&&!this.checkbox?"border-accent":"border-transparent",this.disabled&&"border-neutral-500 top-1",!this.disabled&&this.hasHover?"h-full top-0":"top-1")}"></span> ${this.checkbox?t`<span id="control" part="control ${this.selected?" control--checked":"control--unchecked"}" class="${d("relative flex flex-initial items-center justify-center border rounded-sm h-4 w-4 mr-2",this.disabled?"border-neutral-500":this.selected?"bg-accent border-accent":"border-neutral-800")}">${this.selected?t`<sd-2-4-4-icon part="checked-icon" class="text-white w-3 h-3" library="system" name="status-hook"></sd-2-4-4-icon>`:""}</span>`:""} ${e?t`<slot name="left" part="left" class="inline-flex mr-2"></slot>`:""}<slot part="label" class="inline-block flex-grow" @slotchange="${this.handleDefaultSlotChange}"></slot>${s?t`<slot name="right" part="right" class="inline-flex ml-2"></slot>`:""}</div>`}};m.styles=[c,e.styles,s`:host{position:relative;display:block;width:100%;outline:2px solid transparent!important;outline-offset:2px!important}`],b([n('[part="base"]')],m.prototype,"defaultSlot",2),b([i()],m.prototype,"current",2),b([i()],m.prototype,"selected",2),b([i()],m.prototype,"hasHover",2),b([l({reflect:!0})],m.prototype,"size",2),b([l({type:Boolean,reflect:!0})],m.prototype,"checkbox",2),b([l({type:Boolean,reflect:!0})],m.prototype,"disabled",2),b([l({reflect:!0})],m.prototype,"value",2),b([h("disabled")],m.prototype,"handleDisabledChange",1),b([h("selected")],m.prototype,"handleSelectedChange",1),b([h("value")],m.prototype,"handleValueChange",1),m=b([a("sd-2-4-4-option")],m);export{m as default};
@@ -1 +1 @@
1
- import{S as t,x as e,i as n,n as o}from"./solid-element.js";import{c as i}from"./register-custom-element.js";import{e as r}from"./query.js";import{c as a}from"./component.styles.js";import{t as s}from"./classix.js";const l=Math.min,c=Math.max,f=Math.round,u=Math.floor,p=t=>({x:t,y:t}),h={left:"right",right:"left",bottom:"top",top:"bottom"},d={start:"end",end:"start"};function m(t,e,n){return c(t,l(e,n))}function y(t,e){return"function"==typeof t?t(e):t}function g(t){return t.split("-")[0]}function w(t){return t.split("-")[1]}function b(t){return"x"===t?"y":"x"}function v(t){return"y"===t?"height":"width"}function x(t){return["top","bottom"].includes(g(t))?"y":"x"}function P(t){return b(x(t))}function E(t){return t.replace(/start|end/g,(t=>d[t]))}function z(t){return t.replace(/left|right|bottom|top/g,(t=>h[t]))}function R(t){return"number"!=typeof t?function(t){return{top:0,right:0,bottom:0,left:0,...t}}(t):{top:t,right:t,bottom:t,left:t}}function S(t){return{...t,top:t.y,left:t.x,right:t.x+t.width,bottom:t.y+t.height}}function T(t,e,n){let{reference:o,floating:i}=t;const r=x(e),a=P(e),s=v(a),l=g(e),c="y"===r,f=o.x+o.width/2-i.width/2,u=o.y+o.height/2-i.height/2,p=o[s]/2-i[s]/2;let h;switch(l){case"top":h={x:f,y:o.y-i.height};break;case"bottom":h={x:f,y:o.y+o.height};break;case"right":h={x:o.x+o.width,y:u};break;case"left":h={x:o.x-i.width,y:u};break;default:h={x:o.x,y:o.y}}switch(w(e)){case"start":h[a]-=p*(n&&c?-1:1);break;case"end":h[a]+=p*(n&&c?-1:1)}return h}async function L(t,e){var n;void 0===e&&(e={});const{x:o,y:i,platform:r,rects:a,elements:s,strategy:l}=t,{boundary:c="clippingAncestors",rootBoundary:f="viewport",elementContext:u="floating",altBoundary:p=!1,padding:h=0}=y(e,t),d=R(h),m=s[p?"floating"===u?"reference":"floating":u],g=S(await r.getClippingRect({element:null==(n=await(null==r.isElement?void 0:r.isElement(m)))||n?m:m.contextElement||await(null==r.getDocumentElement?void 0:r.getDocumentElement(s.floating)),boundary:c,rootBoundary:f,strategy:l})),w="floating"===u?{...a.floating,x:o,y:i}:a.reference,b=await(null==r.getOffsetParent?void 0:r.getOffsetParent(s.floating)),v=await(null==r.isElement?void 0:r.isElement(b))&&await(null==r.getScale?void 0:r.getScale(b))||{x:1,y:1},x=S(r.convertOffsetParentRelativeRectToViewportRelativeRect?await r.convertOffsetParentRelativeRectToViewportRelativeRect({rect:w,offsetParent:b,strategy:l}):w);return{top:(g.top-x.top+d.top)/v.y,bottom:(x.bottom-g.bottom+d.bottom)/v.y,left:(g.left-x.left+d.left)/v.x,right:(x.right-g.right+d.right)/v.x}}const O=function(t){return void 0===t&&(t=0),{name:"offset",options:t,async fn(e){const{x:n,y:o}=e,i=await async function(t,e){const{placement:n,platform:o,elements:i}=t,r=await(null==o.isRTL?void 0:o.isRTL(i.floating)),a=g(n),s=w(n),l="y"===x(n),c=["left","top"].includes(a)?-1:1,f=r&&l?-1:1,u=y(e,t);let{mainAxis:p,crossAxis:h,alignmentAxis:d}="number"==typeof u?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:0,crossAxis:0,alignmentAxis:null,...u};return s&&"number"==typeof d&&(h="end"===s?-1*d:d),l?{x:h*f,y:p*c}:{x:p*c,y:h*f}}(e,t);return{x:n+i.x,y:o+i.y,data:i}}}},A=function(t){return void 0===t&&(t={}),{name:"size",options:t,async fn(e){const{placement:n,rects:o,platform:i,elements:r}=e,{apply:a=(()=>{}),...s}=y(t,e),f=await L(e,s),u=g(n),p=w(n),h="y"===x(n),{width:d,height:m}=o.floating;let b,v;"top"===u||"bottom"===u?(b=u,v=p===(await(null==i.isRTL?void 0:i.isRTL(r.floating))?"start":"end")?"left":"right"):(v=u,b="end"===p?"top":"bottom");const P=m-f[b],E=d-f[v],z=!e.middlewareData.shift;let R=P,S=E;if(h){const t=d-f.left-f.right;S=p||z?l(E,t):t}else{const t=m-f.top-f.bottom;R=p||z?l(P,t):t}if(z&&!p){const t=c(f.left,0),e=c(f.right,0),n=c(f.top,0),o=c(f.bottom,0);h?S=d-2*(0!==t||0!==e?t+e:c(f.left,f.right)):R=m-2*(0!==n||0!==o?n+o:c(f.top,f.bottom))}await a({...e,availableWidth:S,availableHeight:R});const T=await i.getDimensions(r.floating);return d!==T.width||m!==T.height?{reset:{rects:!0}}:{}}}};function k(t){return D(t)?(t.nodeName||"").toLowerCase():"#document"}function C(t){var e;return(null==t||null==(e=t.ownerDocument)?void 0:e.defaultView)||window}function F(t){var e;return null==(e=(D(t)?t.ownerDocument:t.document)||window.document)?void 0:e.documentElement}function D(t){return t instanceof Node||t instanceof C(t).Node}function B(t){return t instanceof Element||t instanceof C(t).Element}function $(t){return t instanceof HTMLElement||t instanceof C(t).HTMLElement}function H(t){return!(typeof ShadowRoot>"u")&&(t instanceof ShadowRoot||t instanceof C(t).ShadowRoot)}function j(t){const{overflow:e,overflowX:n,overflowY:o,display:i}=q(t);return/auto|scroll|overlay|hidden|clip/.test(e+o+n)&&!["inline","contents"].includes(i)}function N(t){return["table","td","th"].includes(k(t))}function M(t){const e=W(),n=q(t);return"none"!==n.transform||"none"!==n.perspective||!!n.containerType&&"normal"!==n.containerType||!e&&!!n.backdropFilter&&"none"!==n.backdropFilter||!e&&!!n.filter&&"none"!==n.filter||["transform","perspective","filter"].some((t=>(n.willChange||"").includes(t)))||["paint","layout","strict","content"].some((t=>(n.contain||"").includes(t)))}function W(){return!(typeof CSS>"u"||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}function V(t){return["html","body","#document"].includes(k(t))}function q(t){return C(t).getComputedStyle(t)}function I(t){return B(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.pageXOffset,scrollTop:t.pageYOffset}}function X(t){if("html"===k(t))return t;const e=t.assignedSlot||t.parentNode||H(t)&&t.host||F(t);return H(e)?e.host:e}function Y(t){const e=X(t);return V(e)?t.ownerDocument?t.ownerDocument.body:t.body:$(e)&&j(e)?e:Y(e)}function _(t,e,n){var o;void 0===e&&(e=[]),void 0===n&&(n=!0);const i=Y(t),r=i===(null==(o=t.ownerDocument)?void 0:o.body),a=C(i);return r?e.concat(a,a.visualViewport||[],j(i)?i:[],a.frameElement&&n?_(a.frameElement):[]):e.concat(i,_(i,[],n))}function G(t){const e=q(t);let n=parseFloat(e.width)||0,o=parseFloat(e.height)||0;const i=$(t),r=i?t.offsetWidth:n,a=i?t.offsetHeight:o,s=f(n)!==r||f(o)!==a;return s&&(n=r,o=a),{width:n,height:o,$:s}}function J(t){return B(t)?t:t.contextElement}function K(t){const e=J(t);if(!$(e))return p(1);const n=e.getBoundingClientRect(),{width:o,height:i,$:r}=G(e);let a=(r?f(n.width):n.width)/o,s=(r?f(n.height):n.height)/i;return(!a||!Number.isFinite(a))&&(a=1),(!s||!Number.isFinite(s))&&(s=1),{x:a,y:s}}const Q=p(0);function U(t){const e=C(t);return W()&&e.visualViewport?{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}:Q}function Z(t,e,n,o){void 0===e&&(e=!1),void 0===n&&(n=!1);const i=t.getBoundingClientRect(),r=J(t);let a=p(1);e&&(o?B(o)&&(a=K(o)):a=K(t));const s=function(t,e,n){return void 0===e&&(e=!1),!(!n||e&&n!==C(t))&&e}(r,n,o)?U(r):p(0);let l=(i.left+s.x)/a.x,c=(i.top+s.y)/a.y,f=i.width/a.x,u=i.height/a.y;if(r){const t=C(r),e=o&&B(o)?C(o):o;let n=t.frameElement;for(;n&&o&&e!==t;){const t=K(n),e=n.getBoundingClientRect(),o=q(n),i=e.left+(n.clientLeft+parseFloat(o.paddingLeft))*t.x,r=e.top+(n.clientTop+parseFloat(o.paddingTop))*t.y;l*=t.x,c*=t.y,f*=t.x,u*=t.y,l+=i,c+=r,n=C(n).frameElement}}return S({width:f,height:u,x:l,y:c})}function tt(t){return Z(F(t)).left+I(t).scrollLeft}function et(t,e,n){let o;if("viewport"===e)o=function(t,e){const n=C(t),o=F(t),i=n.visualViewport;let r=o.clientWidth,a=o.clientHeight,s=0,l=0;if(i){r=i.width,a=i.height;const t=W();(!t||t&&"fixed"===e)&&(s=i.offsetLeft,l=i.offsetTop)}return{width:r,height:a,x:s,y:l}}(t,n);else if("document"===e)o=function(t){const e=F(t),n=I(t),o=t.ownerDocument.body,i=c(e.scrollWidth,e.clientWidth,o.scrollWidth,o.clientWidth),r=c(e.scrollHeight,e.clientHeight,o.scrollHeight,o.clientHeight);let a=-n.scrollLeft+tt(t);const s=-n.scrollTop;return"rtl"===q(o).direction&&(a+=c(e.clientWidth,o.clientWidth)-i),{width:i,height:r,x:a,y:s}}(F(t));else if(B(e))o=function(t,e){const n=Z(t,!0,"fixed"===e),o=n.top+t.clientTop,i=n.left+t.clientLeft,r=$(t)?K(t):p(1);return{width:t.clientWidth*r.x,height:t.clientHeight*r.y,x:i*r.x,y:o*r.y}}(e,n);else{const n=U(t);o={...e,x:e.x-n.x,y:e.y-n.y}}return S(o)}function nt(t,e){const n=X(t);return!(n===e||!B(n)||V(n))&&("fixed"===q(n).position||nt(n,e))}function ot(t,e){const n=e.get(t);if(n)return n;let o=_(t,[],!1).filter((t=>B(t)&&"body"!==k(t))),i=null;const r="fixed"===q(t).position;let a=r?X(t):t;for(;B(a)&&!V(a);){const e=q(a),n=M(a);!n&&"fixed"===e.position&&(i=null),(r?!n&&!i:!n&&"static"===e.position&&i&&["absolute","fixed"].includes(i.position)||j(a)&&!n&&nt(t,a))?o=o.filter((t=>t!==a)):i=e,a=X(a)}return e.set(t,o),o}function it(t,e,n){const o=$(e),i=F(e),r="fixed"===n,a=Z(t,!0,r,e);let s={scrollLeft:0,scrollTop:0};const l=p(0);if(o||!o&&!r)if(("body"!==k(e)||j(i))&&(s=I(e)),o){const t=Z(e,!0,r,e);l.x=t.x+e.clientLeft,l.y=t.y+e.clientTop}else i&&(l.x=tt(i));return{x:a.left+s.scrollLeft-l.x,y:a.top+s.scrollTop-l.y,width:a.width,height:a.height}}function rt(t,e){return $(t)&&"fixed"!==q(t).position?e?e(t):t.offsetParent:null}function at(t,e){const n=C(t);if(!$(t))return n;let o=rt(t,e);for(;o&&N(o)&&"static"===q(o).position;)o=rt(o,e);return o&&("html"===k(o)||"body"===k(o)&&"static"===q(o).position&&!M(o))?n:o||function(t){let e=X(t);for(;$(e)&&!V(e);){if(M(e))return e;e=X(e)}return null}(t)||n}const st={convertOffsetParentRelativeRectToViewportRelativeRect:function(t){let{rect:e,offsetParent:n,strategy:o}=t;const i=$(n),r=F(n);if(n===r)return e;let a={scrollLeft:0,scrollTop:0},s=p(1);const l=p(0);if((i||!i&&"fixed"!==o)&&(("body"!==k(n)||j(r))&&(a=I(n)),$(n))){const t=Z(n);s=K(n),l.x=t.x+n.clientLeft,l.y=t.y+n.clientTop}return{width:e.width*s.x,height:e.height*s.y,x:e.x*s.x-a.scrollLeft*s.x+l.x,y:e.y*s.y-a.scrollTop*s.y+l.y}},getDocumentElement:F,getClippingRect:function(t){let{element:e,boundary:n,rootBoundary:o,strategy:i}=t;const r=[..."clippingAncestors"===n?ot(e,this._c):[].concat(n),o],a=r[0],s=r.reduce(((t,n)=>{const o=et(e,n,i);return t.top=c(o.top,t.top),t.right=l(o.right,t.right),t.bottom=l(o.bottom,t.bottom),t.left=c(o.left,t.left),t}),et(e,a,i));return{width:s.right-s.left,height:s.bottom-s.top,x:s.left,y:s.top}},getOffsetParent:at,getElementRects:async function(t){let{reference:e,floating:n,strategy:o}=t;const i=this.getOffsetParent||at,r=this.getDimensions;return{reference:it(e,await i(n),o),floating:{x:0,y:0,...await r(n)}}},getClientRects:function(t){return Array.from(t.getClientRects())},getDimensions:function(t){return G(t)},getScale:K,isElement:B,isRTL:function(t){return"rtl"===q(t).direction}};var lt=Object.defineProperty,ct=Object.getOwnPropertyDescriptor,ft=(t,e,n,o)=>{for(var i,r=o>1?void 0:o?ct(e,n):e,a=t.length-1;a>=0;a--)(i=t[a])&&(r=(o?i(e,n,r):i(r))||r);return o&&r&&lt(e,n,r),r};let ut=class extends t{constructor(){super(...arguments),this.active=!1,this.placement="top",this.strategy="absolute",this.distance=0,this.skidding=0,this.arrow=!1,this.arrowPlacement="anchor",this.arrowPadding=10,this.flip=!1,this.flipFallbackPlacements="",this.flipFallbackStrategy="best-fit",this.flipPadding=0,this.shift=!1,this.shiftPadding=0,this.autoSizePadding=0}async connectedCallback(){super.connectedCallback(),await this.updateComplete,this.start(),this.setupMutationObserver()}disconnectedCallback(){this.stop(),this.mutationObserver&&this.mutationObserver.disconnect()}async updated(t){super.updated(t),t.has("active")&&(this.active?this.start():this.stop()),t.has("anchor")&&this.handleAnchorChange(),this.active&&(await this.updateComplete,this.reposition())}setupMutationObserver(){this.mutationObserver=new MutationObserver((t=>this.handleCurrentPlacementChange(t))),this.mutationObserver.observe(this,{attributes:!0})}handleCurrentPlacementChange(t){return t.forEach((t=>{if("data-current-placement"===t.attributeName){const t=this.getAttribute("data-current-placement");this.emit("sd-current-placement",{detail:t})}}))}async handleAnchorChange(){if(await this.stop(),this.anchor&&"string"==typeof this.anchor){const t=this.getRootNode();this.anchorEl=t.getElementById(this.anchor)}else this.anchor instanceof HTMLElement?this.anchorEl=this.anchor:this.anchorEl=this.querySelector('[slot="anchor"]');if(this.anchorEl instanceof HTMLSlotElement&&(this.anchorEl=this.anchorEl.assignedElements({flatten:!0})[0]),!this.anchorEl)throw new Error("Invalid anchor element: no anchor could be found using the anchor slot or the anchor attribute.");this.start()}start(){this.anchorEl&&(this.cleanup=function(t,e,n,o){void 0===o&&(o={});const{ancestorScroll:i=!0,ancestorResize:r=!0,elementResize:a="function"==typeof ResizeObserver,layoutShift:s="function"==typeof IntersectionObserver,animationFrame:f=!1}=o,p=J(t),h=i||r?[...p?_(p):[],..._(e)]:[];h.forEach((t=>{i&&t.addEventListener("scroll",n,{passive:!0}),r&&t.addEventListener("resize",n)}));const d=p&&s?function(t,e){let n,o=null;const i=F(t);function r(){clearTimeout(n),o&&o.disconnect(),o=null}return function a(s,f){void 0===s&&(s=!1),void 0===f&&(f=1),r();const{left:p,top:h,width:d,height:m}=t.getBoundingClientRect();if(s||e(),!d||!m)return;const y={rootMargin:-u(h)+"px "+-u(i.clientWidth-(p+d))+"px "+-u(i.clientHeight-(h+m))+"px "+-u(p)+"px",threshold:c(0,l(1,f))||1};let g=!0;function w(t){const e=t[0].intersectionRatio;if(e!==f){if(!g)return a();e?a(!1,e):n=setTimeout((()=>{a(!1,1e-7)}),100)}g=!1}try{o=new IntersectionObserver(w,{...y,root:i.ownerDocument})}catch{o=new IntersectionObserver(w,y)}o.observe(t)}(!0),r}(p,n):null;let m=-1,y=null;a&&(y=new ResizeObserver((t=>{let[o]=t;o&&o.target===p&&y&&(y.unobserve(e),cancelAnimationFrame(m),m=requestAnimationFrame((()=>{y&&y.observe(e)}))),n()})),p&&!f&&y.observe(p),y.observe(e));let g,w=f?Z(t):null;return f&&function e(){const o=Z(t);w&&(o.x!==w.x||o.y!==w.y||o.width!==w.width||o.height!==w.height)&&n(),w=o,g=requestAnimationFrame(e)}(),n(),()=>{h.forEach((t=>{i&&t.removeEventListener("scroll",n),r&&t.removeEventListener("resize",n)})),d&&d(),y&&y.disconnect(),y=null,f&&cancelAnimationFrame(g)}}(this.anchorEl,this.popup,(()=>{this.reposition()})))}async stop(){return new Promise((t=>{this.cleanup?(this.cleanup(),this.cleanup=void 0,this.removeAttribute("data-current-placement"),this.style.removeProperty("--auto-size-available-width"),this.style.removeProperty("--auto-size-available-height"),requestAnimationFrame((()=>t()))):t()}))}reposition(){if(!this.active||!this.anchorEl)return;const t=[O({mainAxis:this.distance,crossAxis:this.skidding})];this.sync?t.push(A({apply:({rects:t})=>{const e="width"===this.sync||"both"===this.sync,n="height"===this.sync||"both"===this.sync;this.popup.style.width=e?`${t.reference.width}px`:"",this.popup.style.height=n?`${t.reference.height}px`:""}})):(this.popup.style.width="",this.popup.style.height=""),this.flip&&t.push(function(t){return void 0===t&&(t={}),{name:"flip",options:t,async fn(e){var n,o;const{placement:i,middlewareData:r,rects:a,initialPlacement:s,platform:l,elements:c}=e,{mainAxis:f=!0,crossAxis:u=!0,fallbackPlacements:p,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:d="none",flipAlignment:m=!0,...b}=y(t,e);if(null!=(n=r.arrow)&&n.alignmentOffset)return{};const x=g(i),R=g(s)===s,S=await(null==l.isRTL?void 0:l.isRTL(c.floating)),T=p||(R||!m?[z(s)]:function(t){const e=z(t);return[E(t),e,E(e)]}(s));!p&&"none"!==d&&T.push(...function(t,e,n,o){const i=w(t);let r=function(t,e,n){const o=["left","right"],i=["right","left"],r=["top","bottom"],a=["bottom","top"];switch(t){case"top":case"bottom":return n?e?i:o:e?o:i;case"left":case"right":return e?r:a;default:return[]}}(g(t),"start"===n,o);return i&&(r=r.map((t=>t+"-"+i)),e&&(r=r.concat(r.map(E)))),r}(s,m,d,S));const O=[s,...T],A=await L(e,b),k=[];let C=(null==(o=r.flip)?void 0:o.overflows)||[];if(f&&k.push(A[x]),u){const t=function(t,e,n){void 0===n&&(n=!1);const o=w(t),i=P(t),r=v(i);let a="x"===i?o===(n?"end":"start")?"right":"left":"start"===o?"bottom":"top";return e.reference[r]>e.floating[r]&&(a=z(a)),[a,z(a)]}(i,a,S);k.push(A[t[0]],A[t[1]])}if(C=[...C,{placement:i,overflows:k}],!k.every((t=>t<=0))){var F,D;const t=((null==(F=r.flip)?void 0:F.index)||0)+1,e=O[t];if(e)return{data:{index:t,overflows:C},reset:{placement:e}};let n=null==(D=C.filter((t=>t.overflows[0]<=0)).sort(((t,e)=>t.overflows[1]-e.overflows[1]))[0])?void 0:D.placement;if(!n)switch(h){case"bestFit":{var B;const t=null==(B=C.map((t=>[t.placement,t.overflows.filter((t=>t>0)).reduce(((t,e)=>t+e),0)])).sort(((t,e)=>t[1]-e[1]))[0])?void 0:B[0];t&&(n=t);break}case"initialPlacement":n=s}if(i!==n)return{reset:{placement:n}}}return{}}}}({boundary:this.flipBoundary,fallbackPlacements:this.flipFallbackPlacements,fallbackStrategy:"best-fit"===this.flipFallbackStrategy?"bestFit":"initialPlacement",padding:this.flipPadding})),this.shift&&t.push(function(t){return void 0===t&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:o,placement:i}=e,{mainAxis:r=!0,crossAxis:a=!1,limiter:s={fn:t=>{let{x:e,y:n}=t;return{x:e,y:n}}},...l}=y(t,e),c={x:n,y:o},f=await L(e,l),u=x(g(i)),p=b(u);let h=c[p],d=c[u];if(r){const t="y"===p?"bottom":"right";h=m(h+f["y"===p?"top":"left"],h,h-f[t])}if(a){const t="y"===u?"bottom":"right";d=m(d+f["y"===u?"top":"left"],d,d-f[t])}const w=s.fn({...e,[p]:h,[u]:d});return{...w,data:{x:w.x-n,y:w.y-o}}}}}({boundary:this.shiftBoundary,padding:this.shiftPadding})),this.autoSize?t.push(A({boundary:this.autoSizeBoundary,padding:this.autoSizePadding,apply:({availableWidth:t,availableHeight:e})=>{"vertical"===this.autoSize||"both"===this.autoSize?this.style.setProperty("--auto-size-available-height",`${e}px`):this.style.removeProperty("--auto-size-available-height"),"horizontal"===this.autoSize||"both"===this.autoSize?this.style.setProperty("--auto-size-available-width",`${t}px`):this.style.removeProperty("--auto-size-available-width")}})):(this.style.removeProperty("--auto-size-available-width"),this.style.removeProperty("--auto-size-available-height")),this.arrow&&t.push((t=>({name:"arrow",options:t,async fn(e){const{x:n,y:o,placement:i,rects:r,platform:a,elements:s,middlewareData:c}=e,{element:f,padding:u=0}=y(t,e)||{};if(null==f)return{};const p=R(u),h={x:n,y:o},d=P(i),g=v(d),b=await a.getDimensions(f),x="y"===d,E=x?"top":"left",z=x?"bottom":"right",S=x?"clientHeight":"clientWidth",T=r.reference[g]+r.reference[d]-h[d]-r.floating[g],L=h[d]-r.reference[d],O=await(null==a.getOffsetParent?void 0:a.getOffsetParent(f));let A=O?O[S]:0;(!A||!await(null==a.isElement?void 0:a.isElement(O)))&&(A=s.floating[S]||r.floating[g]);const k=T/2-L/2,C=A/2-b[g]/2-1,F=l(p[E],C),D=l(p[z],C),B=F,$=A-b[g]-D,H=A/2-b[g]/2+k,j=m(B,H,$),N=!c.arrow&&null!=w(i)&&H!=j&&r.reference[g]/2-(H<B?F:D)-b[g]/2<0,M=N?H<B?H-B:H-$:0;return{[d]:h[d]+M,data:{[d]:j,centerOffset:H-j-M,...N&&{alignmentOffset:M}},reset:N}}}))({element:this.arrowEl,padding:this.arrowPadding})),((t,e,n)=>{const o=new Map,i={platform:st,...n},r={...i.platform,_c:o};return(async(t,e,n)=>{const{placement:o="bottom",strategy:i="absolute",middleware:r=[],platform:a}=n,s=r.filter(Boolean),l=await(null==a.isRTL?void 0:a.isRTL(e));let c=await a.getElementRects({reference:t,floating:e,strategy:i}),{x:f,y:u}=T(c,o,l),p=o,h={},d=0;for(let n=0;n<s.length;n++){const{name:r,fn:m}=s[n],{x:y,y:g,data:w,reset:b}=await m({x:f,y:u,initialPlacement:o,placement:p,strategy:i,middlewareData:h,rects:c,platform:a,elements:{reference:t,floating:e}});f=y??f,u=g??u,h={...h,[r]:{...h[r],...w}},b&&d<=50&&(d++,"object"==typeof b&&(b.placement&&(p=b.placement),b.rects&&(c=!0===b.rects?await a.getElementRects({reference:t,floating:e,strategy:i}):b.rects),({x:f,y:u}=T(c,p,l))),n=-1)}return{x:f,y:u,placement:p,strategy:i,middlewareData:h}})(t,e,{...i,platform:r})})(this.anchorEl,this.popup,{placement:this.placement,middleware:t,strategy:this.strategy}).then((({x:t,y:e,middlewareData:n,placement:o})=>{const i="rtl"===getComputedStyle(this).direction,r={top:"bottom",right:"left",bottom:"top",left:"right"}[o.split("-")[0]];if(this.setAttribute("data-current-placement",o),Object.assign(this.popup.style,{left:`${t}px`,top:`${e}px`}),this.arrow){const t=n.arrow.x,e=n.arrow.y;let o="",a="",s="",l="";if("start"===this.arrowPlacement){const n="number"==typeof t?`calc(${this.arrowPadding}px - var(--arrow-padding-offset))`:"";o="number"==typeof e?`calc(${this.arrowPadding}px - var(--arrow-padding-offset))`:"",a=i?n:"",l=i?"":n}else if("end"===this.arrowPlacement){const n="number"==typeof t?`calc(${this.arrowPadding}px - var(--arrow-padding-offset))`:"";a=i?"":n,l=i?n:"",s="number"==typeof e?`calc(${this.arrowPadding}px - var(--arrow-padding-offset))`:""}else"center"===this.arrowPlacement?(l="number"==typeof t?"calc(50% - var(--arrow-size-diagonal))":"",o="number"==typeof e?"calc(50% - var(--arrow-size-diagonal))":""):(l="number"==typeof t?`${t}px`:"",o="number"==typeof e?`${e}px`:"");Object.assign(this.arrowEl.style,{top:o,right:a,bottom:s,left:l,[r]:"calc(var(--arrow-size-diagonal) * -1)"})}})),this.emit("sd-reposition")}render(){return e`<slot name="anchor" @slotchange="${this.handleAnchorChange}"></slot><div part="popup" class="${s("isolate","fixed"!==this.strategy?"absolute":"fixed",!this.active&&"hidden")}"><slot></slot>${this.arrow?e`<div part="arrow" class="absolute rotate-45 -z-10" role="presentation"></div>`:""}</div>`}};ut.styles=[t.styles,a,n`:host{--arrow-color:var(--sd-color-neutral-1000);--arrow-size:6px;--arrow-size-diagonal:calc(var(--arrow-size) * 0.7071);--arrow-padding-offset:calc(var(--arrow-size-diagonal) - var(--arrow-size));display:contents}[part=popup]{max-width:var(--auto-size-available-width,none);max-height:var(--auto-size-available-height,none)}[part=arrow]{width:calc(var(--arrow-size-diagonal) * 2);height:calc(var(--arrow-size-diagonal) * 2);background:var(--arrow-color)}`],ft([r('[part="popup"]')],ut.prototype,"popup",2),ft([r('[part="arrow"]')],ut.prototype,"arrowEl",2),ft([o()],ut.prototype,"anchor",2),ft([o({type:Boolean,reflect:!0})],ut.prototype,"active",2),ft([o({reflect:!0})],ut.prototype,"placement",2),ft([o({reflect:!0})],ut.prototype,"strategy",2),ft([o({type:Number})],ut.prototype,"distance",2),ft([o({type:Number})],ut.prototype,"skidding",2),ft([o({type:Boolean})],ut.prototype,"arrow",2),ft([o({attribute:"arrow-placement"})],ut.prototype,"arrowPlacement",2),ft([o({attribute:"arrow-padding",type:Number})],ut.prototype,"arrowPadding",2),ft([o({type:Boolean})],ut.prototype,"flip",2),ft([o({attribute:"flip-fallback-placements",converter:{fromAttribute:t=>t.split(" ").map((t=>t.trim())).filter((t=>""!==t)),toAttribute:t=>t.join(" ")}})],ut.prototype,"flipFallbackPlacements",2),ft([o({attribute:"flip-fallback-strategy"})],ut.prototype,"flipFallbackStrategy",2),ft([o({type:Object})],ut.prototype,"flipBoundary",2),ft([o({attribute:"flip-padding",type:Number})],ut.prototype,"flipPadding",2),ft([o({type:Boolean})],ut.prototype,"shift",2),ft([o({type:Object})],ut.prototype,"shiftBoundary",2),ft([o({attribute:"shift-padding",type:Number})],ut.prototype,"shiftPadding",2),ft([o({attribute:"auto-size"})],ut.prototype,"autoSize",2),ft([o()],ut.prototype,"sync",2),ft([o({type:Object})],ut.prototype,"autoSizeBoundary",2),ft([o({attribute:"auto-size-padding",type:Number})],ut.prototype,"autoSizePadding",2),ut=ft([i("sd-2-4-2-popup")],ut);export{ut as default};
1
+ import{S as t,x as e,i as n,n as o,c as i}from"./solid-element.js";import{e as r}from"./query.js";import{c as a}from"./component.styles.js";import{t as s}from"./classix.js";const l=Math.min,c=Math.max,f=Math.round,u=Math.floor,p=t=>({x:t,y:t}),h={left:"right",right:"left",bottom:"top",top:"bottom"},d={start:"end",end:"start"};function m(t,e,n){return c(t,l(e,n))}function y(t,e){return"function"==typeof t?t(e):t}function g(t){return t.split("-")[0]}function w(t){return t.split("-")[1]}function b(t){return"x"===t?"y":"x"}function v(t){return"y"===t?"height":"width"}function x(t){return["top","bottom"].includes(g(t))?"y":"x"}function P(t){return b(x(t))}function E(t){return t.replace(/start|end/g,(t=>d[t]))}function z(t){return t.replace(/left|right|bottom|top/g,(t=>h[t]))}function R(t){return"number"!=typeof t?function(t){return{top:0,right:0,bottom:0,left:0,...t}}(t):{top:t,right:t,bottom:t,left:t}}function S(t){return{...t,top:t.y,left:t.x,right:t.x+t.width,bottom:t.y+t.height}}function T(t,e,n){let{reference:o,floating:i}=t;const r=x(e),a=P(e),s=v(a),l=g(e),c="y"===r,f=o.x+o.width/2-i.width/2,u=o.y+o.height/2-i.height/2,p=o[s]/2-i[s]/2;let h;switch(l){case"top":h={x:f,y:o.y-i.height};break;case"bottom":h={x:f,y:o.y+o.height};break;case"right":h={x:o.x+o.width,y:u};break;case"left":h={x:o.x-i.width,y:u};break;default:h={x:o.x,y:o.y}}switch(w(e)){case"start":h[a]-=p*(n&&c?-1:1);break;case"end":h[a]+=p*(n&&c?-1:1)}return h}async function L(t,e){var n;void 0===e&&(e={});const{x:o,y:i,platform:r,rects:a,elements:s,strategy:l}=t,{boundary:c="clippingAncestors",rootBoundary:f="viewport",elementContext:u="floating",altBoundary:p=!1,padding:h=0}=y(e,t),d=R(h),m=s[p?"floating"===u?"reference":"floating":u],g=S(await r.getClippingRect({element:null==(n=await(null==r.isElement?void 0:r.isElement(m)))||n?m:m.contextElement||await(null==r.getDocumentElement?void 0:r.getDocumentElement(s.floating)),boundary:c,rootBoundary:f,strategy:l})),w="floating"===u?{...a.floating,x:o,y:i}:a.reference,b=await(null==r.getOffsetParent?void 0:r.getOffsetParent(s.floating)),v=await(null==r.isElement?void 0:r.isElement(b))&&await(null==r.getScale?void 0:r.getScale(b))||{x:1,y:1},x=S(r.convertOffsetParentRelativeRectToViewportRelativeRect?await r.convertOffsetParentRelativeRectToViewportRelativeRect({rect:w,offsetParent:b,strategy:l}):w);return{top:(g.top-x.top+d.top)/v.y,bottom:(x.bottom-g.bottom+d.bottom)/v.y,left:(g.left-x.left+d.left)/v.x,right:(x.right-g.right+d.right)/v.x}}const O=function(t){return void 0===t&&(t=0),{name:"offset",options:t,async fn(e){const{x:n,y:o}=e,i=await async function(t,e){const{placement:n,platform:o,elements:i}=t,r=await(null==o.isRTL?void 0:o.isRTL(i.floating)),a=g(n),s=w(n),l="y"===x(n),c=["left","top"].includes(a)?-1:1,f=r&&l?-1:1,u=y(e,t);let{mainAxis:p,crossAxis:h,alignmentAxis:d}="number"==typeof u?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:0,crossAxis:0,alignmentAxis:null,...u};return s&&"number"==typeof d&&(h="end"===s?-1*d:d),l?{x:h*f,y:p*c}:{x:p*c,y:h*f}}(e,t);return{x:n+i.x,y:o+i.y,data:i}}}},A=function(t){return void 0===t&&(t={}),{name:"size",options:t,async fn(e){const{placement:n,rects:o,platform:i,elements:r}=e,{apply:a=(()=>{}),...s}=y(t,e),f=await L(e,s),u=g(n),p=w(n),h="y"===x(n),{width:d,height:m}=o.floating;let b,v;"top"===u||"bottom"===u?(b=u,v=p===(await(null==i.isRTL?void 0:i.isRTL(r.floating))?"start":"end")?"left":"right"):(v=u,b="end"===p?"top":"bottom");const P=m-f[b],E=d-f[v],z=!e.middlewareData.shift;let R=P,S=E;if(h){const t=d-f.left-f.right;S=p||z?l(E,t):t}else{const t=m-f.top-f.bottom;R=p||z?l(P,t):t}if(z&&!p){const t=c(f.left,0),e=c(f.right,0),n=c(f.top,0),o=c(f.bottom,0);h?S=d-2*(0!==t||0!==e?t+e:c(f.left,f.right)):R=m-2*(0!==n||0!==o?n+o:c(f.top,f.bottom))}await a({...e,availableWidth:S,availableHeight:R});const T=await i.getDimensions(r.floating);return d!==T.width||m!==T.height?{reset:{rects:!0}}:{}}}};function k(t){return D(t)?(t.nodeName||"").toLowerCase():"#document"}function C(t){var e;return(null==t||null==(e=t.ownerDocument)?void 0:e.defaultView)||window}function F(t){var e;return null==(e=(D(t)?t.ownerDocument:t.document)||window.document)?void 0:e.documentElement}function D(t){return t instanceof Node||t instanceof C(t).Node}function B(t){return t instanceof Element||t instanceof C(t).Element}function $(t){return t instanceof HTMLElement||t instanceof C(t).HTMLElement}function H(t){return!(typeof ShadowRoot>"u")&&(t instanceof ShadowRoot||t instanceof C(t).ShadowRoot)}function N(t){const{overflow:e,overflowX:n,overflowY:o,display:i}=q(t);return/auto|scroll|overlay|hidden|clip/.test(e+o+n)&&!["inline","contents"].includes(i)}function j(t){return["table","td","th"].includes(k(t))}function M(t){const e=W(),n=q(t);return"none"!==n.transform||"none"!==n.perspective||!!n.containerType&&"normal"!==n.containerType||!e&&!!n.backdropFilter&&"none"!==n.backdropFilter||!e&&!!n.filter&&"none"!==n.filter||["transform","perspective","filter"].some((t=>(n.willChange||"").includes(t)))||["paint","layout","strict","content"].some((t=>(n.contain||"").includes(t)))}function W(){return!(typeof CSS>"u"||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}function V(t){return["html","body","#document"].includes(k(t))}function q(t){return C(t).getComputedStyle(t)}function I(t){return B(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.pageXOffset,scrollTop:t.pageYOffset}}function X(t){if("html"===k(t))return t;const e=t.assignedSlot||t.parentNode||H(t)&&t.host||F(t);return H(e)?e.host:e}function Y(t){const e=X(t);return V(e)?t.ownerDocument?t.ownerDocument.body:t.body:$(e)&&N(e)?e:Y(e)}function _(t,e,n){var o;void 0===e&&(e=[]),void 0===n&&(n=!0);const i=Y(t),r=i===(null==(o=t.ownerDocument)?void 0:o.body),a=C(i);return r?e.concat(a,a.visualViewport||[],N(i)?i:[],a.frameElement&&n?_(a.frameElement):[]):e.concat(i,_(i,[],n))}function G(t){const e=q(t);let n=parseFloat(e.width)||0,o=parseFloat(e.height)||0;const i=$(t),r=i?t.offsetWidth:n,a=i?t.offsetHeight:o,s=f(n)!==r||f(o)!==a;return s&&(n=r,o=a),{width:n,height:o,$:s}}function J(t){return B(t)?t:t.contextElement}function K(t){const e=J(t);if(!$(e))return p(1);const n=e.getBoundingClientRect(),{width:o,height:i,$:r}=G(e);let a=(r?f(n.width):n.width)/o,s=(r?f(n.height):n.height)/i;return(!a||!Number.isFinite(a))&&(a=1),(!s||!Number.isFinite(s))&&(s=1),{x:a,y:s}}const Q=p(0);function U(t){const e=C(t);return W()&&e.visualViewport?{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}:Q}function Z(t,e,n,o){void 0===e&&(e=!1),void 0===n&&(n=!1);const i=t.getBoundingClientRect(),r=J(t);let a=p(1);e&&(o?B(o)&&(a=K(o)):a=K(t));const s=function(t,e,n){return void 0===e&&(e=!1),!(!n||e&&n!==C(t))&&e}(r,n,o)?U(r):p(0);let l=(i.left+s.x)/a.x,c=(i.top+s.y)/a.y,f=i.width/a.x,u=i.height/a.y;if(r){const t=C(r),e=o&&B(o)?C(o):o;let n=t.frameElement;for(;n&&o&&e!==t;){const t=K(n),e=n.getBoundingClientRect(),o=q(n),i=e.left+(n.clientLeft+parseFloat(o.paddingLeft))*t.x,r=e.top+(n.clientTop+parseFloat(o.paddingTop))*t.y;l*=t.x,c*=t.y,f*=t.x,u*=t.y,l+=i,c+=r,n=C(n).frameElement}}return S({width:f,height:u,x:l,y:c})}function tt(t){return Z(F(t)).left+I(t).scrollLeft}function et(t,e,n){let o;if("viewport"===e)o=function(t,e){const n=C(t),o=F(t),i=n.visualViewport;let r=o.clientWidth,a=o.clientHeight,s=0,l=0;if(i){r=i.width,a=i.height;const t=W();(!t||t&&"fixed"===e)&&(s=i.offsetLeft,l=i.offsetTop)}return{width:r,height:a,x:s,y:l}}(t,n);else if("document"===e)o=function(t){const e=F(t),n=I(t),o=t.ownerDocument.body,i=c(e.scrollWidth,e.clientWidth,o.scrollWidth,o.clientWidth),r=c(e.scrollHeight,e.clientHeight,o.scrollHeight,o.clientHeight);let a=-n.scrollLeft+tt(t);const s=-n.scrollTop;return"rtl"===q(o).direction&&(a+=c(e.clientWidth,o.clientWidth)-i),{width:i,height:r,x:a,y:s}}(F(t));else if(B(e))o=function(t,e){const n=Z(t,!0,"fixed"===e),o=n.top+t.clientTop,i=n.left+t.clientLeft,r=$(t)?K(t):p(1);return{width:t.clientWidth*r.x,height:t.clientHeight*r.y,x:i*r.x,y:o*r.y}}(e,n);else{const n=U(t);o={...e,x:e.x-n.x,y:e.y-n.y}}return S(o)}function nt(t,e){const n=X(t);return!(n===e||!B(n)||V(n))&&("fixed"===q(n).position||nt(n,e))}function ot(t,e){const n=e.get(t);if(n)return n;let o=_(t,[],!1).filter((t=>B(t)&&"body"!==k(t))),i=null;const r="fixed"===q(t).position;let a=r?X(t):t;for(;B(a)&&!V(a);){const e=q(a),n=M(a);!n&&"fixed"===e.position&&(i=null),(r?!n&&!i:!n&&"static"===e.position&&i&&["absolute","fixed"].includes(i.position)||N(a)&&!n&&nt(t,a))?o=o.filter((t=>t!==a)):i=e,a=X(a)}return e.set(t,o),o}function it(t,e,n){const o=$(e),i=F(e),r="fixed"===n,a=Z(t,!0,r,e);let s={scrollLeft:0,scrollTop:0};const l=p(0);if(o||!o&&!r)if(("body"!==k(e)||N(i))&&(s=I(e)),o){const t=Z(e,!0,r,e);l.x=t.x+e.clientLeft,l.y=t.y+e.clientTop}else i&&(l.x=tt(i));return{x:a.left+s.scrollLeft-l.x,y:a.top+s.scrollTop-l.y,width:a.width,height:a.height}}function rt(t,e){return $(t)&&"fixed"!==q(t).position?e?e(t):t.offsetParent:null}function at(t,e){const n=C(t);if(!$(t))return n;let o=rt(t,e);for(;o&&j(o)&&"static"===q(o).position;)o=rt(o,e);return o&&("html"===k(o)||"body"===k(o)&&"static"===q(o).position&&!M(o))?n:o||function(t){let e=X(t);for(;$(e)&&!V(e);){if(M(e))return e;e=X(e)}return null}(t)||n}const st={convertOffsetParentRelativeRectToViewportRelativeRect:function(t){let{rect:e,offsetParent:n,strategy:o}=t;const i=$(n),r=F(n);if(n===r)return e;let a={scrollLeft:0,scrollTop:0},s=p(1);const l=p(0);if((i||!i&&"fixed"!==o)&&(("body"!==k(n)||N(r))&&(a=I(n)),$(n))){const t=Z(n);s=K(n),l.x=t.x+n.clientLeft,l.y=t.y+n.clientTop}return{width:e.width*s.x,height:e.height*s.y,x:e.x*s.x-a.scrollLeft*s.x+l.x,y:e.y*s.y-a.scrollTop*s.y+l.y}},getDocumentElement:F,getClippingRect:function(t){let{element:e,boundary:n,rootBoundary:o,strategy:i}=t;const r=[..."clippingAncestors"===n?ot(e,this._c):[].concat(n),o],a=r[0],s=r.reduce(((t,n)=>{const o=et(e,n,i);return t.top=c(o.top,t.top),t.right=l(o.right,t.right),t.bottom=l(o.bottom,t.bottom),t.left=c(o.left,t.left),t}),et(e,a,i));return{width:s.right-s.left,height:s.bottom-s.top,x:s.left,y:s.top}},getOffsetParent:at,getElementRects:async function(t){let{reference:e,floating:n,strategy:o}=t;const i=this.getOffsetParent||at,r=this.getDimensions;return{reference:it(e,await i(n),o),floating:{x:0,y:0,...await r(n)}}},getClientRects:function(t){return Array.from(t.getClientRects())},getDimensions:function(t){return G(t)},getScale:K,isElement:B,isRTL:function(t){return"rtl"===q(t).direction}};var lt=Object.defineProperty,ct=Object.getOwnPropertyDescriptor,ft=(t,e,n,o)=>{for(var i,r=o>1?void 0:o?ct(e,n):e,a=t.length-1;a>=0;a--)(i=t[a])&&(r=(o?i(e,n,r):i(r))||r);return o&&r&&lt(e,n,r),r};let ut=class extends t{constructor(){super(...arguments),this.active=!1,this.placement="top",this.strategy="absolute",this.distance=0,this.skidding=0,this.arrow=!1,this.arrowPlacement="anchor",this.arrowPadding=10,this.flip=!1,this.flipFallbackPlacements="",this.flipFallbackStrategy="best-fit",this.flipPadding=0,this.shift=!1,this.shiftPadding=0,this.autoSizePadding=0}async connectedCallback(){super.connectedCallback(),await this.updateComplete,this.start(),this.setupMutationObserver()}disconnectedCallback(){this.stop(),this.mutationObserver&&this.mutationObserver.disconnect()}async updated(t){super.updated(t),t.has("active")&&(this.active?this.start():this.stop()),t.has("anchor")&&this.handleAnchorChange(),this.active&&(await this.updateComplete,this.reposition())}setupMutationObserver(){this.mutationObserver=new MutationObserver((t=>this.handleCurrentPlacementChange(t))),this.mutationObserver.observe(this,{attributes:!0})}handleCurrentPlacementChange(t){return t.forEach((t=>{if("data-current-placement"===t.attributeName){const t=this.getAttribute("data-current-placement");this.emit("sd-current-placement",{detail:t})}}))}async handleAnchorChange(){if(await this.stop(),this.anchor&&"string"==typeof this.anchor){const t=this.getRootNode();this.anchorEl=t.getElementById(this.anchor)}else this.anchor instanceof HTMLElement?this.anchorEl=this.anchor:this.anchorEl=this.querySelector('[slot="anchor"]');if(this.anchorEl instanceof HTMLSlotElement&&(this.anchorEl=this.anchorEl.assignedElements({flatten:!0})[0]),!this.anchorEl)throw new Error("Invalid anchor element: no anchor could be found using the anchor slot or the anchor attribute.");this.start()}start(){this.anchorEl&&(this.cleanup=function(t,e,n,o){void 0===o&&(o={});const{ancestorScroll:i=!0,ancestorResize:r=!0,elementResize:a="function"==typeof ResizeObserver,layoutShift:s="function"==typeof IntersectionObserver,animationFrame:f=!1}=o,p=J(t),h=i||r?[...p?_(p):[],..._(e)]:[];h.forEach((t=>{i&&t.addEventListener("scroll",n,{passive:!0}),r&&t.addEventListener("resize",n)}));const d=p&&s?function(t,e){let n,o=null;const i=F(t);function r(){clearTimeout(n),o&&o.disconnect(),o=null}return function a(s,f){void 0===s&&(s=!1),void 0===f&&(f=1),r();const{left:p,top:h,width:d,height:m}=t.getBoundingClientRect();if(s||e(),!d||!m)return;const y={rootMargin:-u(h)+"px "+-u(i.clientWidth-(p+d))+"px "+-u(i.clientHeight-(h+m))+"px "+-u(p)+"px",threshold:c(0,l(1,f))||1};let g=!0;function w(t){const e=t[0].intersectionRatio;if(e!==f){if(!g)return a();e?a(!1,e):n=setTimeout((()=>{a(!1,1e-7)}),100)}g=!1}try{o=new IntersectionObserver(w,{...y,root:i.ownerDocument})}catch{o=new IntersectionObserver(w,y)}o.observe(t)}(!0),r}(p,n):null;let m=-1,y=null;a&&(y=new ResizeObserver((t=>{let[o]=t;o&&o.target===p&&y&&(y.unobserve(e),cancelAnimationFrame(m),m=requestAnimationFrame((()=>{y&&y.observe(e)}))),n()})),p&&!f&&y.observe(p),y.observe(e));let g,w=f?Z(t):null;return f&&function e(){const o=Z(t);w&&(o.x!==w.x||o.y!==w.y||o.width!==w.width||o.height!==w.height)&&n(),w=o,g=requestAnimationFrame(e)}(),n(),()=>{h.forEach((t=>{i&&t.removeEventListener("scroll",n),r&&t.removeEventListener("resize",n)})),d&&d(),y&&y.disconnect(),y=null,f&&cancelAnimationFrame(g)}}(this.anchorEl,this.popup,(()=>{this.reposition()})))}async stop(){return new Promise((t=>{this.cleanup?(this.cleanup(),this.cleanup=void 0,this.removeAttribute("data-current-placement"),this.style.removeProperty("--auto-size-available-width"),this.style.removeProperty("--auto-size-available-height"),requestAnimationFrame((()=>t()))):t()}))}reposition(){if(!this.active||!this.anchorEl)return;const t=[O({mainAxis:this.distance,crossAxis:this.skidding})];this.sync?t.push(A({apply:({rects:t})=>{const e="width"===this.sync||"both"===this.sync,n="height"===this.sync||"both"===this.sync;this.popup.style.width=e?`${t.reference.width}px`:"",this.popup.style.height=n?`${t.reference.height}px`:""}})):(this.popup.style.width="",this.popup.style.height=""),this.flip&&t.push(function(t){return void 0===t&&(t={}),{name:"flip",options:t,async fn(e){var n,o;const{placement:i,middlewareData:r,rects:a,initialPlacement:s,platform:l,elements:c}=e,{mainAxis:f=!0,crossAxis:u=!0,fallbackPlacements:p,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:d="none",flipAlignment:m=!0,...b}=y(t,e);if(null!=(n=r.arrow)&&n.alignmentOffset)return{};const x=g(i),R=g(s)===s,S=await(null==l.isRTL?void 0:l.isRTL(c.floating)),T=p||(R||!m?[z(s)]:function(t){const e=z(t);return[E(t),e,E(e)]}(s));!p&&"none"!==d&&T.push(...function(t,e,n,o){const i=w(t);let r=function(t,e,n){const o=["left","right"],i=["right","left"],r=["top","bottom"],a=["bottom","top"];switch(t){case"top":case"bottom":return n?e?i:o:e?o:i;case"left":case"right":return e?r:a;default:return[]}}(g(t),"start"===n,o);return i&&(r=r.map((t=>t+"-"+i)),e&&(r=r.concat(r.map(E)))),r}(s,m,d,S));const O=[s,...T],A=await L(e,b),k=[];let C=(null==(o=r.flip)?void 0:o.overflows)||[];if(f&&k.push(A[x]),u){const t=function(t,e,n){void 0===n&&(n=!1);const o=w(t),i=P(t),r=v(i);let a="x"===i?o===(n?"end":"start")?"right":"left":"start"===o?"bottom":"top";return e.reference[r]>e.floating[r]&&(a=z(a)),[a,z(a)]}(i,a,S);k.push(A[t[0]],A[t[1]])}if(C=[...C,{placement:i,overflows:k}],!k.every((t=>t<=0))){var F,D;const t=((null==(F=r.flip)?void 0:F.index)||0)+1,e=O[t];if(e)return{data:{index:t,overflows:C},reset:{placement:e}};let n=null==(D=C.filter((t=>t.overflows[0]<=0)).sort(((t,e)=>t.overflows[1]-e.overflows[1]))[0])?void 0:D.placement;if(!n)switch(h){case"bestFit":{var B;const t=null==(B=C.map((t=>[t.placement,t.overflows.filter((t=>t>0)).reduce(((t,e)=>t+e),0)])).sort(((t,e)=>t[1]-e[1]))[0])?void 0:B[0];t&&(n=t);break}case"initialPlacement":n=s}if(i!==n)return{reset:{placement:n}}}return{}}}}({boundary:this.flipBoundary,fallbackPlacements:this.flipFallbackPlacements,fallbackStrategy:"best-fit"===this.flipFallbackStrategy?"bestFit":"initialPlacement",padding:this.flipPadding})),this.shift&&t.push(function(t){return void 0===t&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:o,placement:i}=e,{mainAxis:r=!0,crossAxis:a=!1,limiter:s={fn:t=>{let{x:e,y:n}=t;return{x:e,y:n}}},...l}=y(t,e),c={x:n,y:o},f=await L(e,l),u=x(g(i)),p=b(u);let h=c[p],d=c[u];if(r){const t="y"===p?"bottom":"right";h=m(h+f["y"===p?"top":"left"],h,h-f[t])}if(a){const t="y"===u?"bottom":"right";d=m(d+f["y"===u?"top":"left"],d,d-f[t])}const w=s.fn({...e,[p]:h,[u]:d});return{...w,data:{x:w.x-n,y:w.y-o}}}}}({boundary:this.shiftBoundary,padding:this.shiftPadding})),this.autoSize?t.push(A({boundary:this.autoSizeBoundary,padding:this.autoSizePadding,apply:({availableWidth:t,availableHeight:e})=>{"vertical"===this.autoSize||"both"===this.autoSize?this.style.setProperty("--auto-size-available-height",`${e}px`):this.style.removeProperty("--auto-size-available-height"),"horizontal"===this.autoSize||"both"===this.autoSize?this.style.setProperty("--auto-size-available-width",`${t}px`):this.style.removeProperty("--auto-size-available-width")}})):(this.style.removeProperty("--auto-size-available-width"),this.style.removeProperty("--auto-size-available-height")),this.arrow&&t.push((t=>({name:"arrow",options:t,async fn(e){const{x:n,y:o,placement:i,rects:r,platform:a,elements:s,middlewareData:c}=e,{element:f,padding:u=0}=y(t,e)||{};if(null==f)return{};const p=R(u),h={x:n,y:o},d=P(i),g=v(d),b=await a.getDimensions(f),x="y"===d,E=x?"top":"left",z=x?"bottom":"right",S=x?"clientHeight":"clientWidth",T=r.reference[g]+r.reference[d]-h[d]-r.floating[g],L=h[d]-r.reference[d],O=await(null==a.getOffsetParent?void 0:a.getOffsetParent(f));let A=O?O[S]:0;(!A||!await(null==a.isElement?void 0:a.isElement(O)))&&(A=s.floating[S]||r.floating[g]);const k=T/2-L/2,C=A/2-b[g]/2-1,F=l(p[E],C),D=l(p[z],C),B=F,$=A-b[g]-D,H=A/2-b[g]/2+k,N=m(B,H,$),j=!c.arrow&&null!=w(i)&&H!=N&&r.reference[g]/2-(H<B?F:D)-b[g]/2<0,M=j?H<B?H-B:H-$:0;return{[d]:h[d]+M,data:{[d]:N,centerOffset:H-N-M,...j&&{alignmentOffset:M}},reset:j}}}))({element:this.arrowEl,padding:this.arrowPadding})),((t,e,n)=>{const o=new Map,i={platform:st,...n},r={...i.platform,_c:o};return(async(t,e,n)=>{const{placement:o="bottom",strategy:i="absolute",middleware:r=[],platform:a}=n,s=r.filter(Boolean),l=await(null==a.isRTL?void 0:a.isRTL(e));let c=await a.getElementRects({reference:t,floating:e,strategy:i}),{x:f,y:u}=T(c,o,l),p=o,h={},d=0;for(let n=0;n<s.length;n++){const{name:r,fn:m}=s[n],{x:y,y:g,data:w,reset:b}=await m({x:f,y:u,initialPlacement:o,placement:p,strategy:i,middlewareData:h,rects:c,platform:a,elements:{reference:t,floating:e}});f=y??f,u=g??u,h={...h,[r]:{...h[r],...w}},b&&d<=50&&(d++,"object"==typeof b&&(b.placement&&(p=b.placement),b.rects&&(c=!0===b.rects?await a.getElementRects({reference:t,floating:e,strategy:i}):b.rects),({x:f,y:u}=T(c,p,l))),n=-1)}return{x:f,y:u,placement:p,strategy:i,middlewareData:h}})(t,e,{...i,platform:r})})(this.anchorEl,this.popup,{placement:this.placement,middleware:t,strategy:this.strategy}).then((({x:t,y:e,middlewareData:n,placement:o})=>{const i="rtl"===getComputedStyle(this).direction,r={top:"bottom",right:"left",bottom:"top",left:"right"}[o.split("-")[0]];if(this.setAttribute("data-current-placement",o),Object.assign(this.popup.style,{left:`${t}px`,top:`${e}px`}),this.arrow){const t=n.arrow.x,e=n.arrow.y;let o="",a="",s="",l="";if("start"===this.arrowPlacement){const n="number"==typeof t?`calc(${this.arrowPadding}px - var(--arrow-padding-offset))`:"";o="number"==typeof e?`calc(${this.arrowPadding}px - var(--arrow-padding-offset))`:"",a=i?n:"",l=i?"":n}else if("end"===this.arrowPlacement){const n="number"==typeof t?`calc(${this.arrowPadding}px - var(--arrow-padding-offset))`:"";a=i?"":n,l=i?n:"",s="number"==typeof e?`calc(${this.arrowPadding}px - var(--arrow-padding-offset))`:""}else"center"===this.arrowPlacement?(l="number"==typeof t?"calc(50% - var(--arrow-size-diagonal))":"",o="number"==typeof e?"calc(50% - var(--arrow-size-diagonal))":""):(l="number"==typeof t?`${t}px`:"",o="number"==typeof e?`${e}px`:"");Object.assign(this.arrowEl.style,{top:o,right:a,bottom:s,left:l,[r]:"calc(var(--arrow-size-diagonal) * -1)"})}})),this.emit("sd-reposition")}render(){return e`<slot name="anchor" @slotchange="${this.handleAnchorChange}"></slot><div part="popup" class="${s("isolate","fixed"!==this.strategy?"absolute":"fixed",!this.active&&"hidden")}"><slot></slot>${this.arrow?e`<div part="arrow" class="absolute rotate-45 -z-10" role="presentation"></div>`:""}</div>`}};ut.styles=[t.styles,a,n`:host{--arrow-color:var(--sd-color-neutral-1000);--arrow-size:6px;--arrow-size-diagonal:calc(var(--arrow-size) * 0.7071);--arrow-padding-offset:calc(var(--arrow-size-diagonal) - var(--arrow-size));display:contents}[part=popup]{max-width:var(--auto-size-available-width,none);max-height:var(--auto-size-available-height,none)}[part=arrow]{width:calc(var(--arrow-size-diagonal) * 2);height:calc(var(--arrow-size-diagonal) * 2);background:var(--arrow-color)}`],ft([r('[part="popup"]')],ut.prototype,"popup",2),ft([r('[part="arrow"]')],ut.prototype,"arrowEl",2),ft([o()],ut.prototype,"anchor",2),ft([o({type:Boolean,reflect:!0})],ut.prototype,"active",2),ft([o({reflect:!0})],ut.prototype,"placement",2),ft([o({reflect:!0})],ut.prototype,"strategy",2),ft([o({type:Number})],ut.prototype,"distance",2),ft([o({type:Number})],ut.prototype,"skidding",2),ft([o({type:Boolean})],ut.prototype,"arrow",2),ft([o({attribute:"arrow-placement"})],ut.prototype,"arrowPlacement",2),ft([o({attribute:"arrow-padding",type:Number})],ut.prototype,"arrowPadding",2),ft([o({type:Boolean})],ut.prototype,"flip",2),ft([o({attribute:"flip-fallback-placements",converter:{fromAttribute:t=>t.split(" ").map((t=>t.trim())).filter((t=>""!==t)),toAttribute:t=>t.join(" ")}})],ut.prototype,"flipFallbackPlacements",2),ft([o({attribute:"flip-fallback-strategy"})],ut.prototype,"flipFallbackStrategy",2),ft([o({type:Object})],ut.prototype,"flipBoundary",2),ft([o({attribute:"flip-padding",type:Number})],ut.prototype,"flipPadding",2),ft([o({type:Boolean})],ut.prototype,"shift",2),ft([o({type:Object})],ut.prototype,"shiftBoundary",2),ft([o({attribute:"shift-padding",type:Number})],ut.prototype,"shiftPadding",2),ft([o({attribute:"auto-size"})],ut.prototype,"autoSize",2),ft([o()],ut.prototype,"sync",2),ft([o({type:Object})],ut.prototype,"autoSizeBoundary",2),ft([o({attribute:"auto-size-padding",type:Number})],ut.prototype,"autoSizePadding",2),ut=ft([i("sd-2-4-4-popup")],ut);export{ut as default};
@@ -1 +1 @@
1
- import{S as t,x as e,i as s,n as r}from"./solid-element.js";import{c as o}from"./register-custom-element.js";import{H as i}from"./slot.js";import{o as a}from"./if-defined.js";import{r as n}from"./state.js";import{e as d}from"./query.js";import{w as l}from"./watch.js";import{c as u}from"./component.styles.js";import{t as h}from"./classix.js";var c=Object.defineProperty,b=Object.getOwnPropertyDescriptor,p=(t,e,s,r)=>{for(var o,i=r>1?void 0:r?b(e,s):e,a=t.length-1;a>=0;a--)(o=t[a])&&(i=(r?o(e,s,i):o(i))||i);return r&&i&&c(e,s,i),i};let m=class extends t{constructor(){super(...arguments),this.hasSlotController=new i(this,"[default]","icon"),this.hasFocus=!1,this.checked=!1,this.disabled=!1,this.size="lg"}connectedCallback(){super.connectedCallback(),this.setAttribute("role","presentation")}handleBlur(){this.hasFocus=!1,this.emit("sd-blur")}handleClick(t){if(this.disabled)return t.preventDefault(),void t.stopPropagation();this.checked=!0}handleFocus(){this.hasFocus=!0,this.emit("sd-focus")}handleDisabledChange(){this.setAttribute("aria-disabled",this.disabled?"true":"false")}focus(t){this.input.focus(t)}blur(){this.input.blur()}render(){const t=this.hasSlotController.test("[default]"),s=this.hasSlotController.test("icon"),r=`${this.size}-${t?"label":"no-label"}`;return e`<div part="base" role="presentation" class="relative"><button part="${"button"+(this.checked?" button--checked":"")}" role="radio" aria-checked="${this.checked}" class="${h("relative text-center border rounded-default transition-all ease-in-out duration-100 items-center justify-center focus-visible:focus-outline","sm"===this.size?"text-sm":"text-base",this.checked&&!this.disabled?"bg-primary border-primary text-white hover:bg-primary-500 hover:border-primary-500":this.disabled&&!this.checked?"border-neutral-500 text-neutral-500 hover:cursor-not-allowed":this.disabled&&this.checked?"bg-neutral-500 text-white hover:cursor-not-allowed":"bg-transparent text-primary border-primary hover:bg-primary-100 hover:border-primary-500 hover:text-primary-500 cursor-pointer",t&&"px-4",this.hasFocus&&"focused-class",t&&"button--has-label",s&&"button--has-icon flex gap-2",r)}" aria-disabled="${this.disabled}" type="button" value="${a(this.value)}" tabindex="${this.checked?"0":"-1"}" @blur="${this.handleBlur}" @focus="${this.handleFocus}" @click="${this.handleClick}"><slot name="icon" part="icon" class="${h(s&&"inline-flex relative items-center",{sm:"text-base",md:"text-lg",lg:"text-xl"}[this.size])}" ?hidden="${!s}"></slot>${t?e`<slot part="label" class="button__label inline-flex relative items-center whitespace-nowrap"></slot>`:null}</button></div>`}};m.styles=[t.styles,u,s`:host{display:block;width:-moz-min-content;width:min-content}.hidden-input{all:unset;position:absolute;inset:var(--sd-spacing-0,0);z-index:-10;opacity:var(--sd-opacity-0,0);outline-style:dotted;outline-width:1px;outline-color:rgb(var(--sd-color-error,204 25 55) / 1)}.lg-label{height:var(--sd-spacing-12,3rem)}.lg-no-label{height:var(--sd-spacing-12,3rem);width:var(--sd-spacing-12,3rem)}.md-label{height:var(--sd-spacing-10,2.5rem)}.md-no-label{height:var(--sd-spacing-10,2.5rem);width:var(--sd-spacing-10,2.5rem)}.sm-label{height:var(--sd-spacing-8,2rem)}.sm-no-label{height:var(--sd-spacing-8,2rem);width:var(--sd-spacing-8,2rem)}:host(.sd-2-4-2-button-group__button--first:not(.sd-2-4-2-button-group__button--last)) button{border-top-right-radius:var(--sd-border-radius-none,0);border-bottom-right-radius:var(--sd-border-radius-none,0)}:host(.sd-2-4-2-button-group__button--inner) button{border-radius:var(--sd-border-radius-none,0)}:host(.sd-2-4-2-button-group__button--last:not(.sd-2-4-2-button-group__button--first)) button{border-top-left-radius:var(--sd-border-radius-none,0);border-bottom-left-radius:var(--sd-border-radius-none,0)}:host(.sd-2-4-2-button-group__button:not(.sd-2-4-2-button-group__button--first)){margin-inline-start:-1px}:host(.sd-2-4-2-button-group__button--hover){z-index:10}:host(.sd-2-4-2-button-group__button--focus),:host(.sd-2-4-2-button-group__button[checked]){z-index:20}`],p([d(".button")],m.prototype,"input",2),p([d(".hidden-input")],m.prototype,"hiddenInput",2),p([n()],m.prototype,"hasFocus",2),p([r({type:Boolean,reflect:!0})],m.prototype,"checked",2),p([r()],m.prototype,"value",2),p([r({type:Boolean,reflect:!0})],m.prototype,"disabled",2),p([r({reflect:!0})],m.prototype,"size",2),p([l("disabled",{waitUntilFirstUpdate:!0})],m.prototype,"handleDisabledChange",1),m=p([o("sd-2-4-2-radio-button")],m);export{m as default};
1
+ import{S as t,x as e,i as s,n as r,c as o}from"./solid-element.js";import{H as i}from"./slot.js";import{o as a}from"./if-defined.js";import{r as n}from"./state.js";import{e as d}from"./query.js";import{w as l}from"./watch.js";import{c as u}from"./component.styles.js";import{t as h}from"./classix.js";var c=Object.defineProperty,b=Object.getOwnPropertyDescriptor,p=(t,e,s,r)=>{for(var o,i=r>1?void 0:r?b(e,s):e,a=t.length-1;a>=0;a--)(o=t[a])&&(i=(r?o(e,s,i):o(i))||i);return r&&i&&c(e,s,i),i};let m=class extends t{constructor(){super(...arguments),this.hasSlotController=new i(this,"[default]","icon"),this.hasFocus=!1,this.checked=!1,this.disabled=!1,this.size="lg"}connectedCallback(){super.connectedCallback(),this.setAttribute("role","presentation")}handleBlur(){this.hasFocus=!1,this.emit("sd-blur")}handleClick(t){if(this.disabled)return t.preventDefault(),void t.stopPropagation();this.checked=!0}handleFocus(){this.hasFocus=!0,this.emit("sd-focus")}handleDisabledChange(){this.setAttribute("aria-disabled",this.disabled?"true":"false")}focus(t){this.input.focus(t)}blur(){this.input.blur()}render(){const t=this.hasSlotController.test("[default]"),s=this.hasSlotController.test("icon"),r=`${this.size}-${t?"label":"no-label"}`;return e`<div part="base" role="presentation" class="relative"><button part="${"button"+(this.checked?" button--checked":"")}" role="radio" aria-checked="${this.checked}" class="${h("relative text-center border rounded-default transition-all ease-in-out duration-100 items-center justify-center focus-visible:focus-outline","sm"===this.size?"text-sm":"text-base",this.checked&&!this.disabled?"bg-primary border-primary text-white hover:bg-primary-500 hover:border-primary-500":this.disabled&&!this.checked?"border-neutral-500 text-neutral-500 hover:cursor-not-allowed":this.disabled&&this.checked?"bg-neutral-500 text-white hover:cursor-not-allowed":"bg-transparent text-primary border-primary hover:bg-primary-100 hover:border-primary-500 hover:text-primary-500 cursor-pointer",t&&"px-4",this.hasFocus&&"focused-class",t&&"button--has-label",s&&"button--has-icon flex gap-2",r)}" aria-disabled="${this.disabled}" type="button" value="${a(this.value)}" tabindex="${this.checked?"0":"-1"}" @blur="${this.handleBlur}" @focus="${this.handleFocus}" @click="${this.handleClick}"><slot name="icon" part="icon" class="${h(s&&"inline-flex relative items-center",{sm:"text-base",md:"text-lg",lg:"text-xl"}[this.size])}" ?hidden="${!s}"></slot>${t?e`<slot part="label" class="button__label inline-flex relative items-center whitespace-nowrap"></slot>`:null}</button></div>`}};m.styles=[t.styles,u,s`:host{display:block;width:-moz-min-content;width:min-content}.hidden-input{all:unset;position:absolute;inset:var(--sd-spacing-0,0);z-index:-10;opacity:var(--sd-opacity-0,0);outline-style:dotted;outline-width:1px;outline-color:rgb(var(--sd-color-error,204 25 55) / 1)}.lg-label{height:var(--sd-spacing-12,3rem)}.lg-no-label{height:var(--sd-spacing-12,3rem);width:var(--sd-spacing-12,3rem)}.md-label{height:var(--sd-spacing-10,2.5rem)}.md-no-label{height:var(--sd-spacing-10,2.5rem);width:var(--sd-spacing-10,2.5rem)}.sm-label{height:var(--sd-spacing-8,2rem)}.sm-no-label{height:var(--sd-spacing-8,2rem);width:var(--sd-spacing-8,2rem)}:host(.sd-2-4-4-button-group__button--first:not(.sd-2-4-4-button-group__button--last)) button{border-top-right-radius:var(--sd-border-radius-none,0);border-bottom-right-radius:var(--sd-border-radius-none,0)}:host(.sd-2-4-4-button-group__button--inner) button{border-radius:var(--sd-border-radius-none,0)}:host(.sd-2-4-4-button-group__button--last:not(.sd-2-4-4-button-group__button--first)) button{border-top-left-radius:var(--sd-border-radius-none,0);border-bottom-left-radius:var(--sd-border-radius-none,0)}:host(.sd-2-4-4-button-group__button:not(.sd-2-4-4-button-group__button--first)){margin-inline-start:-1px}:host(.sd-2-4-4-button-group__button--hover){z-index:10}:host(.sd-2-4-4-button-group__button--focus),:host(.sd-2-4-4-button-group__button[checked]){z-index:20}`],p([d(".button")],m.prototype,"input",2),p([d(".hidden-input")],m.prototype,"hiddenInput",2),p([n()],m.prototype,"hasFocus",2),p([r({type:Boolean,reflect:!0})],m.prototype,"checked",2),p([r()],m.prototype,"value",2),p([r({type:Boolean,reflect:!0})],m.prototype,"disabled",2),p([r({reflect:!0})],m.prototype,"size",2),p([l("disabled",{waitUntilFirstUpdate:!0})],m.prototype,"handleDisabledChange",1),m=p([o("sd-2-4-4-radio-button")],m);export{m as default};
@@ -1 +1 @@
1
- import{i as t,n as e,S as o,x as s}from"./solid-element.js";import{c as i}from"./register-custom-element.js";import{F as a,c as l,a as r,v as n}from"./form.js";import{H as d}from"./slot.js";import{r as h}from"./state.js";import{e as u}from"./query.js";import{w as c}from"./watch.js";import{c as p}from"./component.styles.js";import{t as m}from"./classix.js";import g from"./radio.js";import"./icon.js";import"./solid-components2.js";import"./request.js";import"./request2.js";import"./directive.js";const b=t`${p}:host{display:inline-block}.button-group{display:flex;flex-wrap:nowrap}`;var f=Object.defineProperty,v=Object.getOwnPropertyDescriptor,y=(t,e,o,s)=>{for(var i,a=s>1?void 0:s?v(e,o):e,l=t.length-1;l>=0;l--)(i=t[l])&&(a=(s?i(e,o,a):i(a))||a);return s&&a&&f(e,o,a),a};let C=class extends o{constructor(){super(...arguments),this.disableRole=!1,this.label=""}handleFocus(t){const e=w(t.target);null==e||e.classList.add("sd-2-4-2-button-group__button--focus")}handleBlur(t){const e=w(t.target);null==e||e.classList.remove("sd-2-4-2-button-group__button--focus")}handleMouseOver(t){const e=w(t.target);null==e||e.classList.add("sd-2-4-2-button-group__button--hover")}handleMouseOut(t){const e=w(t.target);null==e||e.classList.remove("sd-2-4-2-button-group__button--hover")}handleSlotChange(){const t=[...this.defaultSlot.assignedElements({flatten:!0})];t.forEach((e=>{const o=t.indexOf(e),s=w(e);null!==s&&(s.classList.add("sd-2-4-2-button-group__button"),s.classList.toggle("sd-2-4-2-button-group__button--first",0===o),s.classList.toggle("sd-2-4-2-button-group__button--inner",o>0&&o<t.length-1),s.classList.toggle("sd-2-4-2-button-group__button--last",o===t.length-1),s.classList.toggle("sd-2-4-2-button-group__button--radio","sd-2-4-2-radio-button"===s.tagName.toLowerCase()))}))}render(){return s`<slot part="base" class="button-group" role="${this.disableRole?"presentation":"group"}" aria-label="${this.label}" @focusout="${this.handleBlur}" @focusin="${this.handleFocus}" @mouseover="${this.handleMouseOver}" @mouseout="${this.handleMouseOut}" @slotchange="${this.handleSlotChange}"></slot>`}};function w(t){const e="sd-2-4-2-button, sd-2-4-2-radio-button";return t.closest(e)??t.querySelector(e)}C.styles=b,y([u("slot")],C.prototype,"defaultSlot",2),y([h()],C.prototype,"disableRole",2),y([e()],C.prototype,"label",2),C=y([i("sd-2-4-2-button-group")],C);var x=Object.defineProperty,R=Object.getOwnPropertyDescriptor,k=(t,e,o,s)=>{for(var i,a=s>1?void 0:s?R(e,o):e,l=t.length-1;l>=0;l--)(i=t[l])&&(a=(s?i(e,o,a):i(a))||a);return s&&a&&x(e,o,a),a};let I=class extends o{constructor(){super(...arguments),this.formControlController=new a(this),this.hasSlotController=new d(this,"label","error-text"),this.customValidityMessage="",this.hasButtonGroup=!1,this.defaultValue="",this.showInvalidStyle=!1,this.label="",this.boldLabel=!1,this.name="option",this.value="",this.size="lg",this.form="",this.required=!1,this.orientation="vertical"}get validity(){const t=this.required&&!this.value;return""!==this.customValidityMessage?l:t?r:n}get validationMessage(){const t=this.required&&!this.value;return""!==this.customValidityMessage?this.customValidityMessage:t?this.validationInput.validationMessage:""}connectedCallback(){super.connectedCallback(),this.defaultValue=this.value}firstUpdated(){this.formControlController.updateValidity()}getAllRadios(){return[...this.querySelectorAll("sd-2-4-2-radio, sd-2-4-2-radio-button")]}handleRadioClick(t){const e=t.target.closest("sd-2-4-2-radio, sd-2-4-2-radio-button"),o=this.getAllRadios(),s=this.value;e.disabled||(this.value=e.value,o.forEach((t=>t.checked=t===e)),this.value!==s&&(this.emit("sd-change"),this.emit("sd-2-4-2-input")))}handleKeyDown(t){if(!["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"," "].includes(t.key))return;const e=this.getAllRadios().filter((t=>!t.disabled)),o=e.find((t=>t.checked))??e[0],s=" "===t.key?0:["ArrowUp","ArrowLeft"].includes(t.key)?-1:1,i=this.value;let a=e.indexOf(o)+s;a<0&&(a=e.length-1),a>e.length-1&&(a=0),this.getAllRadios().forEach((t=>{t.checked=!1,this.hasButtonGroup||(t.tabIndex=-1)})),this.value=e[a].value,e[a].checked=!0,this.hasButtonGroup?e[a].shadowRoot.querySelector("button").focus():(e[a].tabIndex=0,e[a].focus()),this.value!==i&&(this.emit("sd-change"),this.emit("sd-2-4-2-input")),t.preventDefault()}focus(){const t=this.getAllRadios(),e=t.find((t=>t.checked))||t[0];e&&e.focus()}handleInvalid(t){this.formControlController.setValidity(!1),this.formControlController.emitInvalidEvent(t),this.invalidMessage.textContent=t.target.validationMessage}async syncRadioElements(){var t,e;const o=this.getAllRadios();if(await Promise.all(o.map((async t=>{await t.updateComplete,t.checked=t.value===this.value,t.size=this.size,t instanceof g&&(t.invalid=this.showInvalidStyle)}))),this.hasButtonGroup=o.some((t=>"sd-2-4-2-radio-button"===t.tagName.toLowerCase())),!o.some((t=>t.checked)))if(this.hasButtonGroup){const e=null==(t=o[0].shadowRoot)?void 0:t.querySelector("button");e&&(e.tabIndex=0)}else o[0].tabIndex=0;if(this.hasButtonGroup){const t=null==(e=this.shadowRoot)?void 0:e.querySelector("sd-2-4-2-button-group");t&&(t.disableRole=!0)}}syncRadios(){customElements.get("sd-2-4-2-radio")&&customElements.get("sd-2-4-2-radio-button")?this.syncRadioElements():(customElements.get("sd-2-4-2-radio")?this.syncRadioElements():customElements.whenDefined("sd-2-4-2-radio").then((()=>this.syncRadios())),customElements.get("sd-2-4-2-radio-button")?this.syncRadioElements():customElements.whenDefined("sd-2-4-2-radio-button").then((()=>this.syncRadios())))}updateCheckedRadio(){this.getAllRadios().forEach((t=>t.checked=t.value===this.value)),this.formControlController.setValidity(this.validity.valid)}handleSizeChange(){this.syncRadios()}handleInvalidChange(){this.syncRadios()}handleValueChange(){this.hasUpdated&&(this.updateCheckedRadio(),this.reportValidity())}checkValidity(){const t=this.required&&!this.value,e=""!==this.customValidityMessage;return!t&&!e||(this.formControlController.emitInvalidEvent(),!1)}getForm(){return this.formControlController.getForm()}reportValidity(){const t=this.validity.valid;return this.formControlController.setValidity(t),this.validationInput.hidden=!0,clearTimeout(this.validationTimeout),this.formControlController.fakeUserInteraction(),t||(this.validationInput.hidden=!1,this.validationInput.reportValidity(),this.validationTimeout=setTimeout((()=>this.validationInput.hidden=!0),1e4)),t}setCustomValidity(t=""){this.customValidityMessage=t,this.validationInput.setCustomValidity(t),this.formControlController.updateValidity()}render(){const t=this.hasSlotController.test("label"),e=!!this.label||!!t,o=s`<slot @slotchange="${this.syncRadios}" @click="${this.handleRadioClick}" @keydown="${this.handleKeyDown}"></slot>`;return s`<fieldset part="form-control" class="${m("border-0 p-0 m-0 flex flex-col",{sm:"text-sm",lg:"text-base"}[this.size])}" role="radiogroup" aria-labelledby="label" aria-errormessage="error-text"><label part="form-control-label" id="label" class="${m("mb-2 p-0 leading-normal text-black text-left",!e&&"hidden",this.boldLabel&&"font-bold")}" @click="${this.focus}" aria-hidden="${e?"false":"true"}"><slot name="label">${this.label}</slot></label><div part="form-control-input" class="${m("flex",{vertical:"flex-col",horizontal:"flex-row"}[this.orientation])}"><div class="sr-only"><label><input id="validation-input" type="text" ?required="${this.required}" tabindex="-1" hidden @invalid="${this.handleInvalid}"></label></div>${this.hasButtonGroup?s`<sd-2-4-2-button-group part="button-group" exportparts="base:button-group__base" role="presentation">${o}</sd-2-4-2-button-group>`:o}</div></fieldset>${this.formControlController.renderInvalidMessage()}`}};I.dependencies={"sd-2-4-2-button-group":C},I.styles=[p,o.styles,t`:host{display:block}:host([orientation=vertical]) ::slotted(sd-2-4-2-radio){margin-bottom:var(--sd-spacing-2,.5rem);display:flex}:host([orientation=vertical]) ::slotted(sd-2-4-2-radio:last-of-type){margin-bottom:var(--sd-spacing-0,0)}:host([orientation=horizontal]) ::slotted(sd-2-4-2-radio){margin-right:var(--sd-spacing-6,1.5rem)}:host([orientation=horizontal]) ::slotted(sd-2-4-2-radio:last-of-type){margin-right:var(--sd-spacing-0,0)}:host([orientation=horizontal]):host([size=sm]) ::slotted(sd-2-4-2-radio){margin-right:var(--sd-spacing-4,1rem)}:host([orientation=horizontal]):host([size=sm]) ::slotted(sd-2-4-2-radio:last-of-type){margin-right:var(--sd-spacing-0,0)}:host([required]) #label::after{content:' *'}`],k([u("slot:not([name])")],I.prototype,"defaultSlot",2),k([u("#validation-input")],I.prototype,"validationInput",2),k([u("#invalid-message")],I.prototype,"invalidMessage",2),k([h()],I.prototype,"hasButtonGroup",2),k([h()],I.prototype,"defaultValue",2),k([h()],I.prototype,"showInvalidStyle",2),k([e()],I.prototype,"label",2),k([e({type:Boolean,reflect:!0})],I.prototype,"boldLabel",2),k([e()],I.prototype,"name",2),k([e({reflect:!0})],I.prototype,"value",2),k([e({reflect:!0})],I.prototype,"size",2),k([e({reflect:!0})],I.prototype,"form",2),k([e({type:Boolean,reflect:!0})],I.prototype,"required",2),k([e({reflect:!0})],I.prototype,"orientation",2),k([c("size",{waitUntilFirstUpdate:!0})],I.prototype,"handleSizeChange",1),k([c("showInvalidStyle",{waitUntilFirstUpdate:!0})],I.prototype,"handleInvalidChange",1),k([c("value")],I.prototype,"handleValueChange",1),I=k([i("sd-2-4-2-radio-group")],I);export{I as default};
1
+ import{i as t,n as e,S as o,x as s,c as i}from"./solid-element.js";import{F as a,c as l,a as r,v as n}from"./form.js";import{H as d}from"./slot.js";import{r as h}from"./state.js";import{e as u}from"./query.js";import{w as c}from"./watch.js";import{c as p}from"./component.styles.js";import{t as m}from"./classix.js";import g from"./radio.js";import"./icon.js";import"./solid-components2.js";import"./request.js";import"./request2.js";import"./directive.js";const b=t`${p}:host{display:inline-block}.button-group{display:flex;flex-wrap:nowrap}`;var f=Object.defineProperty,v=Object.getOwnPropertyDescriptor,y=(t,e,o,s)=>{for(var i,a=s>1?void 0:s?v(e,o):e,l=t.length-1;l>=0;l--)(i=t[l])&&(a=(s?i(e,o,a):i(a))||a);return s&&a&&f(e,o,a),a};let C=class extends o{constructor(){super(...arguments),this.disableRole=!1,this.label=""}handleFocus(t){const e=w(t.target);null==e||e.classList.add("sd-2-4-4-button-group__button--focus")}handleBlur(t){const e=w(t.target);null==e||e.classList.remove("sd-2-4-4-button-group__button--focus")}handleMouseOver(t){const e=w(t.target);null==e||e.classList.add("sd-2-4-4-button-group__button--hover")}handleMouseOut(t){const e=w(t.target);null==e||e.classList.remove("sd-2-4-4-button-group__button--hover")}handleSlotChange(){const t=[...this.defaultSlot.assignedElements({flatten:!0})];t.forEach((e=>{const o=t.indexOf(e),s=w(e);null!==s&&(s.classList.add("sd-2-4-4-button-group__button"),s.classList.toggle("sd-2-4-4-button-group__button--first",0===o),s.classList.toggle("sd-2-4-4-button-group__button--inner",o>0&&o<t.length-1),s.classList.toggle("sd-2-4-4-button-group__button--last",o===t.length-1),s.classList.toggle("sd-2-4-4-button-group__button--radio","sd-2-4-4-radio-button"===s.tagName.toLowerCase()))}))}render(){return s`<slot part="base" class="button-group" role="${this.disableRole?"presentation":"group"}" aria-label="${this.label}" @focusout="${this.handleBlur}" @focusin="${this.handleFocus}" @mouseover="${this.handleMouseOver}" @mouseout="${this.handleMouseOut}" @slotchange="${this.handleSlotChange}"></slot>`}};function w(t){const e="sd-2-4-4-button, sd-2-4-4-radio-button";return t.closest(e)??t.querySelector(e)}C.styles=b,y([u("slot")],C.prototype,"defaultSlot",2),y([h()],C.prototype,"disableRole",2),y([e()],C.prototype,"label",2),C=y([i("sd-2-4-4-button-group")],C);var x=Object.defineProperty,R=Object.getOwnPropertyDescriptor,k=(t,e,o,s)=>{for(var i,a=s>1?void 0:s?R(e,o):e,l=t.length-1;l>=0;l--)(i=t[l])&&(a=(s?i(e,o,a):i(a))||a);return s&&a&&x(e,o,a),a};let I=class extends o{constructor(){super(...arguments),this.formControlController=new a(this),this.hasSlotController=new d(this,"label","error-text"),this.customValidityMessage="",this.hasButtonGroup=!1,this.defaultValue="",this.showInvalidStyle=!1,this.label="",this.boldLabel=!1,this.name="option",this.value="",this.size="lg",this.form="",this.required=!1,this.orientation="vertical"}get validity(){const t=this.required&&!this.value;return""!==this.customValidityMessage?l:t?r:n}get validationMessage(){const t=this.required&&!this.value;return""!==this.customValidityMessage?this.customValidityMessage:t?this.validationInput.validationMessage:""}connectedCallback(){super.connectedCallback(),this.defaultValue=this.value}firstUpdated(){this.formControlController.updateValidity()}getAllRadios(){return[...this.querySelectorAll("sd-2-4-4-radio, sd-2-4-4-radio-button")]}handleRadioClick(t){const e=t.target.closest("sd-2-4-4-radio, sd-2-4-4-radio-button"),o=this.getAllRadios(),s=this.value;e.disabled||(this.value=e.value,o.forEach((t=>t.checked=t===e)),this.value!==s&&(this.emit("sd-change"),this.emit("sd-2-4-4-input")))}handleKeyDown(t){if(!["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"," "].includes(t.key))return;const e=this.getAllRadios().filter((t=>!t.disabled)),o=e.find((t=>t.checked))??e[0],s=" "===t.key?0:["ArrowUp","ArrowLeft"].includes(t.key)?-1:1,i=this.value;let a=e.indexOf(o)+s;a<0&&(a=e.length-1),a>e.length-1&&(a=0),this.getAllRadios().forEach((t=>{t.checked=!1,this.hasButtonGroup||(t.tabIndex=-1)})),this.value=e[a].value,e[a].checked=!0,this.hasButtonGroup?e[a].shadowRoot.querySelector("button").focus():(e[a].tabIndex=0,e[a].focus()),this.value!==i&&(this.emit("sd-change"),this.emit("sd-2-4-4-input")),t.preventDefault()}focus(){const t=this.getAllRadios(),e=t.find((t=>t.checked))||t[0];e&&e.focus()}handleInvalid(t){this.formControlController.setValidity(!1),this.formControlController.emitInvalidEvent(t),this.invalidMessage.textContent=t.target.validationMessage}async syncRadioElements(){var t,e;const o=this.getAllRadios();if(await Promise.all(o.map((async t=>{await t.updateComplete,t.checked=t.value===this.value,t.size=this.size,t instanceof g&&(t.invalid=this.showInvalidStyle)}))),this.hasButtonGroup=o.some((t=>"sd-2-4-4-radio-button"===t.tagName.toLowerCase())),!o.some((t=>t.checked)))if(this.hasButtonGroup){const e=null==(t=o[0].shadowRoot)?void 0:t.querySelector("button");e&&(e.tabIndex=0)}else o[0].tabIndex=0;if(this.hasButtonGroup){const t=null==(e=this.shadowRoot)?void 0:e.querySelector("sd-2-4-4-button-group");t&&(t.disableRole=!0)}}syncRadios(){customElements.get("sd-2-4-4-radio")&&customElements.get("sd-2-4-4-radio-button")?this.syncRadioElements():(customElements.get("sd-2-4-4-radio")?this.syncRadioElements():customElements.whenDefined("sd-2-4-4-radio").then((()=>this.syncRadios())),customElements.get("sd-2-4-4-radio-button")?this.syncRadioElements():customElements.whenDefined("sd-2-4-4-radio-button").then((()=>this.syncRadios())))}updateCheckedRadio(){this.getAllRadios().forEach((t=>t.checked=t.value===this.value)),this.formControlController.setValidity(this.validity.valid)}handleSizeChange(){this.syncRadios()}handleInvalidChange(){this.syncRadios()}handleValueChange(){this.hasUpdated&&(this.updateCheckedRadio(),this.reportValidity())}checkValidity(){const t=this.required&&!this.value,e=""!==this.customValidityMessage;return!t&&!e||(this.formControlController.emitInvalidEvent(),!1)}getForm(){return this.formControlController.getForm()}reportValidity(){const t=this.validity.valid;return this.formControlController.setValidity(t),this.validationInput.hidden=!0,clearTimeout(this.validationTimeout),this.formControlController.fakeUserInteraction(),t||(this.validationInput.hidden=!1,this.validationInput.reportValidity(),this.validationTimeout=setTimeout((()=>this.validationInput.hidden=!0),1e4)),t}setCustomValidity(t=""){this.customValidityMessage=t,this.validationInput.setCustomValidity(t),this.formControlController.updateValidity()}render(){const t=this.hasSlotController.test("label"),e=!!this.label||!!t,o=s`<slot @slotchange="${this.syncRadios}" @click="${this.handleRadioClick}" @keydown="${this.handleKeyDown}"></slot>`;return s`<fieldset part="form-control" class="${m("border-0 p-0 m-0 flex flex-col",{sm:"text-sm",lg:"text-base"}[this.size])}" role="radiogroup" aria-labelledby="label" aria-errormessage="error-text"><label part="form-control-label" id="label" class="${m("mb-2 p-0 leading-normal text-black text-left",!e&&"hidden",this.boldLabel&&"font-bold")}" @click="${this.focus}" aria-hidden="${e?"false":"true"}"><slot name="label">${this.label}</slot></label><div part="form-control-input" class="${m("flex",{vertical:"flex-col",horizontal:"flex-row"}[this.orientation])}"><div class="sr-only"><label><input id="validation-input" type="text" ?required="${this.required}" tabindex="-1" hidden @invalid="${this.handleInvalid}"></label></div>${this.hasButtonGroup?s`<sd-2-4-4-button-group part="button-group" exportparts="base:button-group__base" role="presentation">${o}</sd-2-4-4-button-group>`:o}</div></fieldset>${this.formControlController.renderInvalidMessage()}`}};I.dependencies={"sd-2-4-4-button-group":C},I.styles=[p,o.styles,t`:host{display:block}:host([orientation=vertical]) ::slotted(sd-2-4-4-radio){margin-bottom:var(--sd-spacing-2,.5rem);display:flex}:host([orientation=vertical]) ::slotted(sd-2-4-4-radio:last-of-type){margin-bottom:var(--sd-spacing-0,0)}:host([orientation=horizontal]) ::slotted(sd-2-4-4-radio){margin-right:var(--sd-spacing-6,1.5rem)}:host([orientation=horizontal]) ::slotted(sd-2-4-4-radio:last-of-type){margin-right:var(--sd-spacing-0,0)}:host([orientation=horizontal]):host([size=sm]) ::slotted(sd-2-4-4-radio){margin-right:var(--sd-spacing-4,1rem)}:host([orientation=horizontal]):host([size=sm]) ::slotted(sd-2-4-4-radio:last-of-type){margin-right:var(--sd-spacing-0,0)}:host([required]) #label::after{content:' *'}`],k([u("slot:not([name])")],I.prototype,"defaultSlot",2),k([u("#validation-input")],I.prototype,"validationInput",2),k([u("#invalid-message")],I.prototype,"invalidMessage",2),k([h()],I.prototype,"hasButtonGroup",2),k([h()],I.prototype,"defaultValue",2),k([h()],I.prototype,"showInvalidStyle",2),k([e()],I.prototype,"label",2),k([e({type:Boolean,reflect:!0})],I.prototype,"boldLabel",2),k([e()],I.prototype,"name",2),k([e({reflect:!0})],I.prototype,"value",2),k([e({reflect:!0})],I.prototype,"size",2),k([e({reflect:!0})],I.prototype,"form",2),k([e({type:Boolean,reflect:!0})],I.prototype,"required",2),k([e({reflect:!0})],I.prototype,"orientation",2),k([c("size",{waitUntilFirstUpdate:!0})],I.prototype,"handleSizeChange",1),k([c("showInvalidStyle",{waitUntilFirstUpdate:!0})],I.prototype,"handleInvalidChange",1),k([c("value")],I.prototype,"handleValueChange",1),I=k([i("sd-2-4-4-radio-group")],I);export{I as default};
@@ -1 +1 @@
1
- import"./icon.js";import{S as e,x as t,i as s,n as i}from"./solid-element.js";import{c as r}from"./register-custom-element.js";import{r as o}from"./state.js";import{w as l}from"./watch.js";import{t as a}from"./classix.js";import"./solid-components2.js";import"./request.js";import"./request2.js";import"./directive.js";import"./component.styles.js";var n=Object.defineProperty,d=Object.getOwnPropertyDescriptor,h=(e,t,s,i)=>{for(var r,o=i>1?void 0:i?d(t,s):t,l=e.length-1;l>=0;l--)(r=e[l])&&(o=(i?r(t,s,o):r(o))||o);return i&&o&&n(t,s,o),o};let c=class extends e{constructor(){super(...arguments),this.checked=!1,this.hasFocus=!1,this.size="lg",this.invalid=!1,this.disabled=!1}connectedCallback(){super.connectedCallback(),this.handleBlur=this.handleBlur.bind(this),this.handleClick=this.handleClick.bind(this),this.handleFocus=this.handleFocus.bind(this),this.setInitialAttributes(),this.addEventListeners()}disconnectedCallback(){this.removeEventListeners()}addEventListeners(){this.addEventListener("blur",this.handleBlur),this.addEventListener("click",this.handleClick),this.addEventListener("focus",this.handleFocus)}removeEventListeners(){this.removeEventListener("blur",this.handleBlur),this.removeEventListener("click",this.handleClick),this.removeEventListener("focus",this.handleFocus)}handleBlur(){this.hasFocus=!1,this.emit("sd-blur")}handleClick(){this.disabled||(this.checked=!0)}handleFocus(){this.hasFocus=!0,this.emit("sd-focus")}setInitialAttributes(){this.setAttribute("role","radio"),this.setAttribute("tabindex","-1"),this.setAttribute("aria-disabled",this.disabled?"true":"false")}handleCheckedChange(){this.setAttribute("aria-checked",this.checked?"true":"false"),this.setAttribute("tabindex",this.checked?"0":"-1")}handleDisabledChange(){this.setAttribute("aria-disabled",this.disabled?"true":"false")}render(){return t`<span part="base" class="${a("sd-2-4-2-radio group inline-flex items-start items-center text-base leading-normal text-black cursor-pointer align-middle",this.disabled&&"hover:cursor-not-allowed",{sm:"small-size text-sm",lg:"text-base"}[this.size])}"><span part="${this.checked?"control--checked":"control--unchecked"}" class="${a("flex-initial shrink-0 relative inline-flex items-center justify-center border rounded-full bg-white h-4 w-4",this.disabled?"border-neutral-500":this.invalid?"border-error hover:border-error-400 group-hover:border-error-400":this.checked?"border-accent hover:border-accent-550 group-hover:border-accent-550":"border-neutral-800 hover:bg-neutral-200 group-hover:bg-neutral-200")}">${this.checked?t`<span part="checked" class="${a("rounded-full inline-flex text-white border bg-accent h-2.5 w-2.5",this.disabled?"bg-neutral-500":this.invalid?"bg-error hover:bg-error-400 group-hover:bg-error-400":this.checked?"bg-accent hover:bg-accent-550 group-hover:bg-accent-550":"bg-neutral-800")}"></span>`:""}</span><slot part="label" class="${a("ml-2 select-none inline-block",this.disabled?"text-neutral-500":this.invalid?"text-error":"text-black")}"></slot></span>`}};c.styles=[e.styles,s`:host{display:block}:host(:focus-visible){outline:2px solid transparent;outline-offset:2px}:host(:focus-visible) [part=control--checked],:host(:focus-visible) [part=control--unchecked]{outline-style:solid;outline-width:2px;outline-offset:2px;outline-color:rgb(var(--sd-color-primary,0 53 142) / 1)}`],h([o()],c.prototype,"checked",2),h([o()],c.prototype,"hasFocus",2),h([i({reflect:!0})],c.prototype,"size",2),h([i({type:Boolean,reflect:!0})],c.prototype,"invalid",2),h([i({type:Boolean,reflect:!0})],c.prototype,"disabled",2),h([i()],c.prototype,"value",2),h([l("checked")],c.prototype,"handleCheckedChange",1),h([l("disabled",{waitUntilFirstUpdate:!0})],c.prototype,"handleDisabledChange",1),c=h([r("sd-2-4-2-radio")],c);export{c as default};
1
+ import"./icon.js";import{S as e,x as t,i as s,n as i,c as r}from"./solid-element.js";import{r as o}from"./state.js";import{w as l}from"./watch.js";import{t as a}from"./classix.js";import"./solid-components2.js";import"./request.js";import"./request2.js";import"./directive.js";import"./component.styles.js";var n=Object.defineProperty,d=Object.getOwnPropertyDescriptor,h=(e,t,s,i)=>{for(var r,o=i>1?void 0:i?d(t,s):t,l=e.length-1;l>=0;l--)(r=e[l])&&(o=(i?r(t,s,o):r(o))||o);return i&&o&&n(t,s,o),o};let c=class extends e{constructor(){super(...arguments),this.checked=!1,this.hasFocus=!1,this.size="lg",this.invalid=!1,this.disabled=!1}connectedCallback(){super.connectedCallback(),this.handleBlur=this.handleBlur.bind(this),this.handleClick=this.handleClick.bind(this),this.handleFocus=this.handleFocus.bind(this),this.setInitialAttributes(),this.addEventListeners()}disconnectedCallback(){this.removeEventListeners()}addEventListeners(){this.addEventListener("blur",this.handleBlur),this.addEventListener("click",this.handleClick),this.addEventListener("focus",this.handleFocus)}removeEventListeners(){this.removeEventListener("blur",this.handleBlur),this.removeEventListener("click",this.handleClick),this.removeEventListener("focus",this.handleFocus)}handleBlur(){this.hasFocus=!1,this.emit("sd-blur")}handleClick(){this.disabled||(this.checked=!0)}handleFocus(){this.hasFocus=!0,this.emit("sd-focus")}setInitialAttributes(){this.setAttribute("role","radio"),this.setAttribute("tabindex","-1"),this.setAttribute("aria-disabled",this.disabled?"true":"false")}handleCheckedChange(){this.setAttribute("aria-checked",this.checked?"true":"false"),this.setAttribute("tabindex",this.checked?"0":"-1")}handleDisabledChange(){this.setAttribute("aria-disabled",this.disabled?"true":"false")}render(){return t`<span part="base" class="${a("sd-2-4-4-radio group inline-flex items-start items-center text-base leading-normal text-black cursor-pointer align-middle",this.disabled&&"hover:cursor-not-allowed",{sm:"small-size text-sm",lg:"text-base"}[this.size])}"><span part="${this.checked?"control--checked":"control--unchecked"}" class="${a("flex-initial shrink-0 relative inline-flex items-center justify-center border rounded-full bg-white h-4 w-4",this.disabled?"border-neutral-500":this.invalid?"border-error hover:border-error-400 group-hover:border-error-400":this.checked?"border-accent hover:border-accent-550 group-hover:border-accent-550":"border-neutral-800 hover:bg-neutral-200 group-hover:bg-neutral-200")}">${this.checked?t`<span part="checked" class="${a("rounded-full inline-flex text-white border bg-accent h-2.5 w-2.5",this.disabled?"bg-neutral-500":this.invalid?"bg-error hover:bg-error-400 group-hover:bg-error-400":this.checked?"bg-accent hover:bg-accent-550 group-hover:bg-accent-550":"bg-neutral-800")}"></span>`:""}</span><slot part="label" class="${a("ml-2 select-none inline-block",this.disabled?"text-neutral-500":this.invalid?"text-error":"text-black")}"></slot></span>`}};c.styles=[e.styles,s`:host{display:block}:host(:focus-visible){outline:2px solid transparent;outline-offset:2px}:host(:focus-visible) [part=control--checked],:host(:focus-visible) [part=control--unchecked]{outline-style:solid;outline-width:2px;outline-offset:2px;outline-color:rgb(var(--sd-color-primary,0 53 142) / 1)}`],h([o()],c.prototype,"checked",2),h([o()],c.prototype,"hasFocus",2),h([i({reflect:!0})],c.prototype,"size",2),h([i({type:Boolean,reflect:!0})],c.prototype,"invalid",2),h([i({type:Boolean,reflect:!0})],c.prototype,"disabled",2),h([i()],c.prototype,"value",2),h([l("checked")],c.prototype,"handleCheckedChange",1),h([l("disabled",{waitUntilFirstUpdate:!0})],c.prototype,"handleDisabledChange",1),c=h([r("sd-2-4-4-radio")],c);export{c as default};