@solid-design-system/components 3.22.2 → 3.22.3
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/components/es/checkbox.js +1 -1
- package/dist/components/es/radio-group.js +1 -1
- package/dist/components/es/select.js +1 -1
- package/dist/components/es/switch.js +1 -1
- package/dist/components/es/textarea.js +1 -1
- package/dist/components/umd/solid-components.js +3 -3
- package/dist/custom-elements.json +1 -1
- package/dist/package/components/checkbox/checkbox.js +1 -1
- package/dist/package/components/radio-group/radio-group.js +1 -1
- package/dist/package/components/select/select.js +1 -1
- package/dist/package/components/switch/switch.js +1 -1
- package/dist/package/components/textarea/textarea.js +1 -1
- package/dist/versioned-components/es/accordion-group.js +1 -1
- package/dist/versioned-components/es/accordion.js +1 -1
- package/dist/versioned-components/es/audio.js +1 -1
- package/dist/versioned-components/es/badge.js +1 -1
- package/dist/versioned-components/es/brandshape.js +1 -1
- package/dist/versioned-components/es/button.js +1 -1
- package/dist/versioned-components/es/carousel-item.js +1 -1
- package/dist/versioned-components/es/carousel.js +3 -3
- package/dist/versioned-components/es/checkbox-group.js +1 -1
- package/dist/versioned-components/es/checkbox.js +1 -1
- package/dist/versioned-components/es/dialog.js +1 -1
- package/dist/versioned-components/es/divider.js +1 -1
- package/dist/versioned-components/es/drawer.js +1 -1
- package/dist/versioned-components/es/dropdown.js +1 -1
- package/dist/versioned-components/es/expandable.js +1 -1
- package/dist/versioned-components/es/flipcard.js +1 -1
- package/dist/versioned-components/es/form.js +1 -1
- package/dist/versioned-components/es/header.js +1 -1
- package/dist/versioned-components/es/icon.js +1 -1
- package/dist/versioned-components/es/include.js +1 -1
- package/dist/versioned-components/es/input.js +1 -1
- package/dist/versioned-components/es/link.js +1 -1
- package/dist/versioned-components/es/map-marker.js +1 -1
- package/dist/versioned-components/es/navigation-item.js +1 -1
- package/dist/versioned-components/es/notification.js +1 -1
- package/dist/versioned-components/es/option.js +1 -1
- package/dist/versioned-components/es/quickfact.js +1 -1
- package/dist/versioned-components/es/radio-button.js +1 -1
- package/dist/versioned-components/es/radio-group.js +1 -1
- package/dist/versioned-components/es/radio.js +1 -1
- package/dist/versioned-components/es/scrollable.js +1 -1
- package/dist/versioned-components/es/select.js +3 -3
- package/dist/versioned-components/es/solid-components2.js +1 -1
- package/dist/versioned-components/es/spinner.js +1 -1
- package/dist/versioned-components/es/step-group.js +1 -1
- package/dist/versioned-components/es/step.js +1 -1
- package/dist/versioned-components/es/switch.js +1 -1
- package/dist/versioned-components/es/tab-group.js +1 -1
- package/dist/versioned-components/es/tab-panel.js +1 -1
- package/dist/versioned-components/es/tab.js +1 -1
- package/dist/versioned-components/es/tag.js +1 -1
- package/dist/versioned-components/es/teaser-media.js +1 -1
- package/dist/versioned-components/es/teaser.js +1 -1
- package/dist/versioned-components/es/textarea.js +1 -1
- package/dist/versioned-components/es/tooltip.js +2 -2
- package/dist/versioned-components/es/video.js +1 -1
- package/dist/versioned-package/_components/button-group/button-group.d.ts +1 -1
- package/dist/versioned-package/_components/button-group/button-group.js +11 -11
- package/dist/versioned-package/components/accordion/accordion.d.ts +1 -1
- package/dist/versioned-package/components/accordion/accordion.js +2 -2
- package/dist/versioned-package/components/accordion-group/accordion-group.d.ts +1 -1
- package/dist/versioned-package/components/accordion-group/accordion-group.js +3 -3
- package/dist/versioned-package/components/audio/audio.d.ts +1 -1
- package/dist/versioned-package/components/audio/audio.js +6 -6
- package/dist/versioned-package/components/badge/badge.d.ts +1 -1
- package/dist/versioned-package/components/badge/badge.js +1 -1
- package/dist/versioned-package/components/brandshape/brandshape.d.ts +1 -1
- package/dist/versioned-package/components/brandshape/brandshape.js +1 -1
- package/dist/versioned-package/components/button/button.d.ts +1 -1
- package/dist/versioned-package/components/button/button.js +4 -4
- package/dist/versioned-package/components/carousel/carousel.d.ts +1 -1
- package/dist/versioned-package/components/carousel/carousel.js +6 -6
- package/dist/versioned-package/components/carousel-item/carousel-item.d.ts +1 -1
- package/dist/versioned-package/components/carousel-item/carousel-item.js +1 -1
- package/dist/versioned-package/components/checkbox/checkbox.d.ts +1 -1
- package/dist/versioned-package/components/checkbox/checkbox.js +4 -4
- package/dist/versioned-package/components/checkbox-group/checkbox-group.d.ts +1 -1
- package/dist/versioned-package/components/checkbox-group/checkbox-group.js +5 -5
- package/dist/versioned-package/components/dialog/dialog.d.ts +1 -1
- package/dist/versioned-package/components/dialog/dialog.js +2 -2
- package/dist/versioned-package/components/divider/divider.d.ts +1 -1
- package/dist/versioned-package/components/divider/divider.js +2 -2
- package/dist/versioned-package/components/drawer/drawer.d.ts +1 -1
- package/dist/versioned-package/components/drawer/drawer.js +2 -2
- package/dist/versioned-package/components/dropdown/dropdown.d.ts +1 -1
- package/dist/versioned-package/components/dropdown/dropdown.js +8 -8
- package/dist/versioned-package/components/expandable/expandable.d.ts +1 -1
- package/dist/versioned-package/components/expandable/expandable.js +2 -2
- package/dist/versioned-package/components/flipcard/flipcard.d.ts +1 -1
- package/dist/versioned-package/components/flipcard/flipcard.js +1 -1
- package/dist/versioned-package/components/header/header.d.ts +1 -1
- package/dist/versioned-package/components/header/header.js +4 -4
- package/dist/versioned-package/components/icon/icon.d.ts +1 -1
- package/dist/versioned-package/components/icon/icon.js +1 -1
- package/dist/versioned-package/components/include/include.d.ts +1 -1
- package/dist/versioned-package/components/include/include.js +1 -1
- package/dist/versioned-package/components/input/input.d.ts +1 -1
- package/dist/versioned-package/components/input/input.js +3 -3
- package/dist/versioned-package/components/link/link.d.ts +1 -1
- package/dist/versioned-package/components/link/link.js +2 -2
- package/dist/versioned-package/components/map-marker/map-marker.d.ts +1 -1
- package/dist/versioned-package/components/map-marker/map-marker.js +1 -1
- package/dist/versioned-package/components/navigation-item/navigation-item.d.ts +1 -1
- package/dist/versioned-package/components/navigation-item/navigation-item.js +5 -5
- package/dist/versioned-package/components/notification/notification.d.ts +1 -1
- package/dist/versioned-package/components/notification/notification.js +5 -5
- package/dist/versioned-package/components/option/option.d.ts +1 -1
- package/dist/versioned-package/components/option/option.js +2 -2
- package/dist/versioned-package/components/popup/popup.d.ts +1 -1
- package/dist/versioned-package/components/popup/popup.js +1 -1
- package/dist/versioned-package/components/quickfact/quickfact.d.ts +1 -1
- package/dist/versioned-package/components/quickfact/quickfact.js +2 -2
- package/dist/versioned-package/components/radio/radio.d.ts +1 -1
- package/dist/versioned-package/components/radio/radio.js +2 -2
- package/dist/versioned-package/components/radio-button/radio-button.d.ts +1 -1
- package/dist/versioned-package/components/radio-button/radio-button.js +2 -2
- package/dist/versioned-package/components/radio-group/radio-group.d.ts +2 -2
- package/dist/versioned-package/components/radio-group/radio-group.js +14 -14
- package/dist/versioned-package/components/scrollable/scrollable.d.ts +1 -1
- package/dist/versioned-package/components/scrollable/scrollable.js +3 -3
- package/dist/versioned-package/components/select/select.d.ts +4 -4
- package/dist/versioned-package/components/select/select.js +25 -25
- package/dist/versioned-package/components/spinner/spinner.d.ts +1 -1
- package/dist/versioned-package/components/spinner/spinner.js +1 -1
- package/dist/versioned-package/components/step/step.d.ts +1 -1
- package/dist/versioned-package/components/step/step.js +2 -2
- package/dist/versioned-package/components/step-group/step-group.d.ts +1 -1
- package/dist/versioned-package/components/step-group/step-group.js +2 -2
- package/dist/versioned-package/components/switch/switch.d.ts +1 -1
- package/dist/versioned-package/components/switch/switch.js +2 -2
- package/dist/versioned-package/components/tab/tab.d.ts +1 -1
- package/dist/versioned-package/components/tab/tab.js +2 -2
- package/dist/versioned-package/components/tab-group/tab-group.d.ts +1 -1
- package/dist/versioned-package/components/tab-group/tab-group.js +13 -13
- package/dist/versioned-package/components/tab-panel/tab-panel.d.ts +1 -1
- package/dist/versioned-package/components/tab-panel/tab-panel.js +2 -2
- package/dist/versioned-package/components/tag/tag.d.ts +1 -1
- package/dist/versioned-package/components/tag/tag.js +2 -2
- package/dist/versioned-package/components/teaser/teaser.js +1 -1
- package/dist/versioned-package/components/teaser-media/teaser-media.js +1 -1
- package/dist/versioned-package/components/textarea/textarea.d.ts +1 -1
- package/dist/versioned-package/components/textarea/textarea.js +2 -2
- package/dist/versioned-package/components/tooltip/tooltip.d.ts +1 -1
- package/dist/versioned-package/components/tooltip/tooltip.js +5 -5
- package/dist/versioned-package/components/video/video.d.ts +1 -1
- package/dist/versioned-package/components/video/video.js +2 -2
- package/dist/versioned-package/internal/form.js +3 -3
- package/dist/versioned-package/styles/headline/headline.css.js +1 -1
- package/dist/versioned-package/utilities/autocomplete-config.js +4 -4
- package/dist/versioned-styles/solid-styles.css +1 -1
- package/dist/vscode.html-custom-data.json +45 -45
- package/dist/web-types.json +46 -46
- package/package.json +1 -1
@@ -1 +1 @@
|
|
1
|
-
import"./icon.js";import{S as e,x as t,t as i,i as r,e as s,n as o,a as l}from"./solid-components2.js";import{d as a}from"./default-value.js";import{F as n}from"./form.js";import{o as d}from"./if-defined.js";import{l as h}from"./live.js";import{r as c}from"./state.js";import{w as p}from"./watch.js";var u=Object.defineProperty,m=Object.getOwnPropertyDescriptor,b=(e,t,i,r)=>{for(var s,o=r>1?void 0:r?m(t,i):t,l=e.length-1;l>=0;l--)(s=e[l])&&(o=(r?s(t,i,o):s(o))||o);return r&&o&&u(t,i,o),o};let f=class extends e{constructor(){super(...arguments),this.formControlController=new n(this,{value:e=>e.checked?e.value||"on":void 0,defaultValue:e=>e.defaultChecked,setValue:(e,t)=>e.checked=t}),this.title="",this.name="",this.size="lg",this.disabled=!1,this.checked=!1,this.indeterminate=!1,this.defaultChecked=!1,this.form="",this.required=!1,this.showInvalidStyle=!1}get validity(){return this.input.validity}firstUpdated(){this.formControlController.updateValidity()}handleClick(){this.checked=!this.checked,this.indeterminate=!1,this.emit("sd-change")}handleBlur(){this.emit("sd-blur")}handleInput(){this.emit("sd-input")}handleInvalid(e){this.formControlController.setValidity(!1),this.formControlController.emitInvalidEvent(e),this.invalidMessage.textContent=e.target.validationMessage}handleFocus(){this.emit("sd-focus")}handleDisabledChange(){this.setAttribute("aria-disabled",this.disabled?"true":"false"),this.formControlController.setValidity(this.disabled)}handleStateChange(){this.input.checked=this.checked,this.input.indeterminate=this.indeterminate,this.formControlController.updateValidity()}click(){this.input.click()}focus(e){this.input.focus(e)}blur(){this.input.blur()}checkValidity(){return this.input.checkValidity()}getForm(){return this.formControlController.getForm()}reportValidity(){return this.formControlController.fakeUserInteraction(),this.input.reportValidity()}setCustomValidity(e){this.input.setCustomValidity(e),this.formControlController.updateValidity()}render(){const e=this.disabled&&this.indeterminate?"disabledIndeterminate":this.disabled&&this.checked?"disabledChecked":this.disabled?"disabled":this.showInvalidStyle&&this.indeterminate?"invalidIndeterminate":this.showInvalidStyle?"invalid":this.checked||this.indeterminate?"filled":"default";return t`<label part="base" class="${i("sd-checkbox group flex items-start text-base leading-normal text-black cursor-pointer",this.disabled&&"hover:cursor-not-allowed",{sm:"text-sm",md:"text-base",lg:"text-base"}[this.size])}"><input class="peer absolute opacity-0 p-0 m-0 pointer-events-none" type="checkbox" title="${this.title}" name="${this.name}" value="${d(this.value)}" .indeterminate="${h(this.indeterminate)}" .checked="${h(this.checked)}" .disabled="${this.disabled}" .required="${this.required}" aria-checked="${this.checked?"true":"false"}" @click="${this.handleClick}" @input="${this.handleInput}" @invalid="${this.handleInvalid}" @blur="${this.handleBlur}" @focus="${this.handleFocus}"> <span id="control" part="control ${this.checked?" control--checked":"control--unchecked"} ${this.indeterminate?" control--indeterminate":""}" class="${i("relative flex flex-shrink-0 items-center justify-center border rounded-sm h-4 w-4\n peer-focus-visible:outline peer-focus-visible:outline-2 peer-focus-visible:outline-offset-2\n peer-focus-visible:outline-primary",{sm:"mt-[2px]",md:"mt-[3px]",lg:"mt-[3px]"}[this.size],{disabledIndeterminate:"border-neutral-500 bg-neutral-500",disabledChecked:"border-neutral-500 bg-neutral-500",disabled:"border-neutral-500",invalidIndeterminate:"border-error bg-error group-hover:bg-error-400",invalid:"border-error group-hover:bg-neutral-200",filled:"border-accent hover:border-accent-550 group-hover:border-accent-550 bg-accent group-hover:bg-accent-550",default:"border-neutral-800 hover:bg-neutral-200 group-hover:bg-neutral-200 bg-white"}[e])}">${this.checked?t`<sd-icon part="checked-icon" class="text-white w-3 h-3" library="system" name="status-check"></sd-icon>`:""} ${!this.checked&&this.indeterminate?t`<sd-icon part="indeterminate-icon" class="text-white w-3 h-3" library="system" name="status-minus"></sd-icon>`:""} </span><span part="label" id="label" class="${i("select-none inline-block ml-2",this.disabled?"text-neutral-500":this.showInvalidStyle?"text-error":"text-black")}"><slot></slot></span></label> ${this.formControlController.renderInvalidMessage()}`}};f.styles=[e.styles,r`:host{display:block;width:-moz-max-content;width:max-content}:host(:focus-visible){outline-width:0}:host([required]) #label::after{content:' *'}`],b([s('input[type="checkbox"]')],f.prototype,"input",2),b([s("#invalid-message")],f.prototype,"invalidMessage",2),b([o()],f.prototype,"title",2),b([o()],f.prototype,"name",2),b([o()],f.prototype,"value",2),b([o({reflect:!0})],f.prototype,"size",2),b([o({type:Boolean,reflect:!0})],f.prototype,"disabled",2),b([o({type:Boolean,reflect:!0})],f.prototype,"checked",2),b([o({type:Boolean,reflect:!0})],f.prototype,"indeterminate",2),b([a("checked")],f.prototype,"defaultChecked",2),b([o({reflect:!0})],f.prototype,"form",2),b([o({type:Boolean,reflect:!0})],f.prototype,"required",2),b([c()],f.prototype,"showInvalidStyle",2),b([p("disabled",{waitUntilFirstUpdate:!0})],f.prototype,"handleDisabledChange",1),b([p(["checked","indeterminate"],{waitUntilFirstUpdate:!0})],f.prototype,"handleStateChange",1),f=b([l("sd-checkbox")],f);export{f as default};
|
1
|
+
import"./icon.js";import{S as e,x as t,t as i,i as r,e as s,n as o,a as l}from"./solid-components2.js";import{d as a}from"./default-value.js";import{F as n}from"./form.js";import{o as d}from"./if-defined.js";import{l as h}from"./live.js";import{r as c}from"./state.js";import{w as p}from"./watch.js";var u=Object.defineProperty,m=Object.getOwnPropertyDescriptor,b=(e,t,i,r)=>{for(var s,o=r>1?void 0:r?m(t,i):t,l=e.length-1;l>=0;l--)(s=e[l])&&(o=(r?s(t,i,o):s(o))||o);return r&&o&&u(t,i,o),o};let f=class extends e{constructor(){super(...arguments),this.formControlController=new n(this,{value:e=>e.checked?e.value||"on":void 0,defaultValue:e=>e.defaultChecked,setValue:(e,t)=>e.checked=t}),this.title="",this.name="",this.size="lg",this.disabled=!1,this.checked=!1,this.indeterminate=!1,this.defaultChecked=!1,this.form="",this.required=!1,this.showInvalidStyle=!1}get validity(){return this.input.validity}firstUpdated(){this.formControlController.updateValidity()}handleClick(){this.checked=!this.checked,this.indeterminate=!1,this.emit("sd-change")}handleBlur(){this.emit("sd-blur")}handleInput(){this.emit("sd-input")}handleInvalid(e){this.formControlController.setValidity(!1),this.formControlController.emitInvalidEvent(e),this.invalidMessage.textContent=e.target.validationMessage}handleFocus(){this.emit("sd-focus")}handleDisabledChange(){this.setAttribute("aria-disabled",this.disabled?"true":"false"),this.formControlController.setValidity(this.disabled)}handleStateChange(){this.input.checked=this.checked,this.input.indeterminate=this.indeterminate,this.formControlController.updateValidity()}click(){this.input.click()}focus(e){this.input.focus(e)}blur(){this.input.blur()}checkValidity(){return this.input.checkValidity()}getForm(){return this.formControlController.getForm()}reportValidity(){return this.formControlController.fakeUserInteraction(),this.input.reportValidity()}setCustomValidity(e){this.input.setCustomValidity(e),this.formControlController.updateValidity()}render(){const e=this.disabled&&this.indeterminate?"disabledIndeterminate":this.disabled&&this.checked?"disabledChecked":this.disabled?"disabled":this.showInvalidStyle&&this.indeterminate?"invalidIndeterminate":this.showInvalidStyle?"invalid":this.checked||this.indeterminate?"filled":"default";return t`<label part="base" class="${i("sd-checkbox group flex items-start text-base leading-normal text-black cursor-pointer",this.disabled&&"hover:cursor-not-allowed",{sm:"text-sm",md:"text-base",lg:"text-base"}[this.size])}"><input class="peer absolute opacity-0 p-0 m-0 pointer-events-none" type="checkbox" title="${this.title}" name="${this.name}" value="${d(this.value)}" .indeterminate="${h(this.indeterminate)}" .checked="${h(this.checked)}" .disabled="${this.disabled}" .required="${this.required}" aria-checked="${this.checked?"true":"false"}" aria-describedby="invalid-message" @click="${this.handleClick}" @input="${this.handleInput}" @invalid="${this.handleInvalid}" @blur="${this.handleBlur}" @focus="${this.handleFocus}"> <span id="control" part="control ${this.checked?" control--checked":"control--unchecked"} ${this.indeterminate?" control--indeterminate":""}" class="${i("relative flex flex-shrink-0 items-center justify-center border rounded-sm h-4 w-4\n peer-focus-visible:outline peer-focus-visible:outline-2 peer-focus-visible:outline-offset-2\n peer-focus-visible:outline-primary",{sm:"mt-[2px]",md:"mt-[3px]",lg:"mt-[3px]"}[this.size],{disabledIndeterminate:"border-neutral-500 bg-neutral-500",disabledChecked:"border-neutral-500 bg-neutral-500",disabled:"border-neutral-500",invalidIndeterminate:"border-error bg-error group-hover:bg-error-400",invalid:"border-error group-hover:bg-neutral-200",filled:"border-accent hover:border-accent-550 group-hover:border-accent-550 bg-accent group-hover:bg-accent-550",default:"border-neutral-800 hover:bg-neutral-200 group-hover:bg-neutral-200 bg-white"}[e])}">${this.checked?t`<sd-icon part="checked-icon" class="text-white w-3 h-3" library="system" name="status-check"></sd-icon>`:""} ${!this.checked&&this.indeterminate?t`<sd-icon part="indeterminate-icon" class="text-white w-3 h-3" library="system" name="status-minus"></sd-icon>`:""} </span><span part="label" id="label" class="${i("select-none inline-block ml-2",this.disabled?"text-neutral-500":this.showInvalidStyle?"text-error":"text-black")}"><slot></slot></span></label> ${this.formControlController.renderInvalidMessage()}`}};f.styles=[e.styles,r`:host{display:block;width:-moz-max-content;width:max-content}:host(:focus-visible){outline-width:0}:host([required]) #label::after{content:' *'}`],b([s('input[type="checkbox"]')],f.prototype,"input",2),b([s("#invalid-message")],f.prototype,"invalidMessage",2),b([o()],f.prototype,"title",2),b([o()],f.prototype,"name",2),b([o()],f.prototype,"value",2),b([o({reflect:!0})],f.prototype,"size",2),b([o({type:Boolean,reflect:!0})],f.prototype,"disabled",2),b([o({type:Boolean,reflect:!0})],f.prototype,"checked",2),b([o({type:Boolean,reflect:!0})],f.prototype,"indeterminate",2),b([a("checked")],f.prototype,"defaultChecked",2),b([o({reflect:!0})],f.prototype,"form",2),b([o({type:Boolean,reflect:!0})],f.prototype,"required",2),b([c()],f.prototype,"showInvalidStyle",2),b([p("disabled",{waitUntilFirstUpdate:!0})],f.prototype,"handleDisabledChange",1),b([p(["checked","indeterminate"],{waitUntilFirstUpdate:!0})],f.prototype,"handleStateChange",1),f=b([l("sd-checkbox")],f);export{f as default};
|
@@ -1 +1 @@
|
|
1
|
-
import{i as t,c as e,e as o,n as s,S as i,x as a,a as l,t as r}from"./solid-components2.js";import{F as n,c as d,a as h,v as u}from"./form.js";import{H as c}from"./slot.js";import{r as p}from"./state.js";import{w as g}from"./watch.js";import m from"./radio.js";const b=t`${e}: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 i{constructor(){super(...arguments),this.disableRole=!1,this.label=""}handleFocus(t){const e=w(t.target);null==e||e.classList.add("sd-button-group__button--focus")}handleBlur(t){const e=w(t.target);null==e||e.classList.remove("sd-button-group__button--focus")}handleMouseOver(t){const e=w(t.target);null==e||e.classList.add("sd-button-group__button--hover")}handleMouseOut(t){const e=w(t.target);null==e||e.classList.remove("sd-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-button-group__button"),s.classList.toggle("sd-button-group__button--first",0===o),s.classList.toggle("sd-button-group__button--inner",o>0&&o<t.length-1),s.classList.toggle("sd-button-group__button--last",o===t.length-1),s.classList.toggle("sd-button-group__button--radio","sd-radio-button"===s.tagName.toLowerCase()))}))}render(){return a`<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-button, sd-radio-button";return t.closest(e)??t.querySelector(e)}C.styles=b,y([o("slot")],C.prototype,"defaultSlot",2),y([p()],C.prototype,"disableRole",2),y([s()],C.prototype,"label",2),C=y([l("sd-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 i{constructor(){super(...arguments),this.formControlController=new n(this),this.hasSlotController=new c(this,"label","error-text"),this.customValidityMessage="",this.hasButtonGroup=!1,this.defaultValue="",this.showInvalidStyle=!1,this.size="lg",this.required=!1,this.orientation="vertical",this.label="",this.boldLabel=!1,this.name="option",this.value="",this.form=""}get validity(){const t=this.required&&!this.value;return""!==this.customValidityMessage?d:t?h:u}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-radio, sd-radio-button")]}handleRadioClick(t){const e=t.target.closest("sd-radio, sd-radio-button"),o=this.getAllRadios(),s=this.value;e.disabled||(this.value=e.value,o.forEach((t=>t.checked=t===e)),this.value!==s&&(this.emit("sd-change"),this.emit("sd-input")))}handleKeyDown(t){if(!["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"," "].includes(t.key))return;const e=this.getAllRadios().filter((t=>!t.disabled)),o=e.find((t=>t.checked))??e[0],s=" "===t.key?0:["ArrowUp","ArrowLeft"].includes(t.key)?-1:1,i=this.value;let a=e.indexOf(o)+s;a<0&&(a=e.length-1),a>e.length-1&&(a=0),this.getAllRadios().forEach((t=>{t.checked=!1,this.hasButtonGroup||(t.tabIndex=-1)})),this.value=e[a].value,e[a].checked=!0,this.hasButtonGroup?e[a].shadowRoot.querySelector("button").focus():(e[a].tabIndex=0,e[a].focus()),this.value!==i&&(this.emit("sd-change"),this.emit("sd-input")),t.preventDefault()}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 m&&(t.invalid=this.showInvalidStyle)}))),this.hasButtonGroup=o.some((t=>"sd-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-button-group");t&&(t.disableRole=!0)}}syncRadios(){customElements.get("sd-radio")&&customElements.get("sd-radio-button")?this.syncRadioElements():(customElements.get("sd-radio")?this.syncRadioElements():customElements.whenDefined("sd-radio").then((()=>this.syncRadios())),customElements.get("sd-radio-button")?this.syncRadioElements():customElements.whenDefined("sd-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=a`<slot @slotchange="${this.syncRadios}" @click="${this.handleRadioClick}" @keydown="${this.handleKeyDown}"></slot>`;return a`<fieldset part="form-control" class="${r("border-0 p-0 m-0 flex flex-col",{sm:"text-sm",md:"text-base",lg:"text-base"}[this.size])}" role="radiogroup" aria-
|
1
|
+
import{i as t,c as e,e as o,n as s,S as i,x as a,a as l,t as r}from"./solid-components2.js";import{F as n,c as d,a as h,v as u}from"./form.js";import{H as c}from"./slot.js";import{r as p}from"./state.js";import{w as g}from"./watch.js";import m from"./radio.js";const b=t`${e}: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 i{constructor(){super(...arguments),this.disableRole=!1,this.label=""}handleFocus(t){const e=w(t.target);null==e||e.classList.add("sd-button-group__button--focus")}handleBlur(t){const e=w(t.target);null==e||e.classList.remove("sd-button-group__button--focus")}handleMouseOver(t){const e=w(t.target);null==e||e.classList.add("sd-button-group__button--hover")}handleMouseOut(t){const e=w(t.target);null==e||e.classList.remove("sd-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-button-group__button"),s.classList.toggle("sd-button-group__button--first",0===o),s.classList.toggle("sd-button-group__button--inner",o>0&&o<t.length-1),s.classList.toggle("sd-button-group__button--last",o===t.length-1),s.classList.toggle("sd-button-group__button--radio","sd-radio-button"===s.tagName.toLowerCase()))}))}render(){return a`<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-button, sd-radio-button";return t.closest(e)??t.querySelector(e)}C.styles=b,y([o("slot")],C.prototype,"defaultSlot",2),y([p()],C.prototype,"disableRole",2),y([s()],C.prototype,"label",2),C=y([l("sd-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 i{constructor(){super(...arguments),this.formControlController=new n(this),this.hasSlotController=new c(this,"label","error-text"),this.customValidityMessage="",this.hasButtonGroup=!1,this.defaultValue="",this.showInvalidStyle=!1,this.size="lg",this.required=!1,this.orientation="vertical",this.label="",this.boldLabel=!1,this.name="option",this.value="",this.form=""}get validity(){const t=this.required&&!this.value;return""!==this.customValidityMessage?d:t?h:u}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-radio, sd-radio-button")]}handleRadioClick(t){const e=t.target.closest("sd-radio, sd-radio-button"),o=this.getAllRadios(),s=this.value;e.disabled||(this.value=e.value,o.forEach((t=>t.checked=t===e)),this.value!==s&&(this.emit("sd-change"),this.emit("sd-input")))}handleKeyDown(t){if(!["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"," "].includes(t.key))return;const e=this.getAllRadios().filter((t=>!t.disabled)),o=e.find((t=>t.checked))??e[0],s=" "===t.key?0:["ArrowUp","ArrowLeft"].includes(t.key)?-1:1,i=this.value;let a=e.indexOf(o)+s;a<0&&(a=e.length-1),a>e.length-1&&(a=0),this.getAllRadios().forEach((t=>{t.checked=!1,this.hasButtonGroup||(t.tabIndex=-1)})),this.value=e[a].value,e[a].checked=!0,this.hasButtonGroup?e[a].shadowRoot.querySelector("button").focus():(e[a].tabIndex=0,e[a].focus()),this.value!==i&&(this.emit("sd-change"),this.emit("sd-input")),t.preventDefault()}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 m&&(t.invalid=this.showInvalidStyle)}))),this.hasButtonGroup=o.some((t=>"sd-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-button-group");t&&(t.disableRole=!0)}}syncRadios(){customElements.get("sd-radio")&&customElements.get("sd-radio-button")?this.syncRadioElements():(customElements.get("sd-radio")?this.syncRadioElements():customElements.whenDefined("sd-radio").then((()=>this.syncRadios())),customElements.get("sd-radio-button")?this.syncRadioElements():customElements.whenDefined("sd-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=a`<slot @slotchange="${this.syncRadios}" @click="${this.handleRadioClick}" @keydown="${this.handleKeyDown}"></slot>`;return a`<fieldset part="form-control" class="${r("border-0 p-0 m-0 flex flex-col",{sm:"text-sm",md:"text-base",lg:"text-base"}[this.size])}" role="radiogroup" aria-describedby="invalid-message"><div class="flex items-center gap-1 mb-2"><legend part="form-control-label" id="label" class="${r("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></legend><slot name="tooltip"></slot></div><div part="form-control-input" class="${r("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?a`<sd-button-group part="button-group" exportparts="base:button-group__base" role="presentation">${o}</sd-button-group>`:o}</div></fieldset>${this.formControlController.renderInvalidMessage()}`}};I.dependencies={"sd-button-group":C},I.styles=[e,i.styles,t`:host{display:block}:host([orientation=vertical]) ::slotted(sd-radio){margin-bottom:var(--sd-spacing-2,.5rem);display:flex}:host([orientation=vertical]) ::slotted(sd-radio:last-of-type){margin-bottom:var(--sd-spacing-0,0)}:host([orientation=horizontal]) ::slotted(sd-radio){margin-right:var(--sd-spacing-6,1.5rem)}:host([orientation=horizontal]) ::slotted(sd-radio:last-of-type){margin-right:var(--sd-spacing-0,0)}:host([orientation=horizontal]):host([size=sm]) ::slotted(sd-radio){margin-right:var(--sd-spacing-4,1rem)}:host([orientation=horizontal]):host([size=sm]) ::slotted(sd-radio:last-of-type){margin-right:var(--sd-spacing-0,0)}:host([required]) #label::after{content:' *'}`],k([o("slot:not([name])")],I.prototype,"defaultSlot",2),k([o("#validation-input")],I.prototype,"validationInput",2),k([o("#invalid-message")],I.prototype,"invalidMessage",2),k([p()],I.prototype,"hasButtonGroup",2),k([p()],I.prototype,"defaultValue",2),k([p()],I.prototype,"showInvalidStyle",2),k([s({reflect:!0})],I.prototype,"size",2),k([s({type:Boolean,reflect:!0})],I.prototype,"required",2),k([s({reflect:!0})],I.prototype,"orientation",2),k([s()],I.prototype,"label",2),k([s({type:Boolean,reflect:!0})],I.prototype,"boldLabel",2),k([s()],I.prototype,"name",2),k([s({reflect:!0})],I.prototype,"value",2),k([s({reflect:!0})],I.prototype,"form",2),k([g("size",{waitUntilFirstUpdate:!0})],I.prototype,"handleSizeChange",1),k([g("showInvalidStyle",{waitUntilFirstUpdate:!0})],I.prototype,"handleInvalidChange",1),k([g("value")],I.prototype,"handleValueChange",1),I=k([l("sd-radio-group")],I);export{I as default};
|
@@ -4,4 +4,4 @@ import{s as t,a as e}from"./animate.js";import{S as s,L as i,x as o,t as l,j as
|
|
4
4
|
removable-indicator:tag__removable-indicator,
|
5
5
|
" size="${"sm"===this.size?"sm":"lg"}" removable @sd-remove="${e=>this.handleTagRemove(e,t)}">${t.getTextLabel()}</sd-tag>`,this.handleDocumentFocusIn=t=>{const e=t.composedPath();this&&!e.includes(this)&&this.hide()},this.handleDocumentKeyDown=t=>{const e=t.target,s=null!==e.closest(".select__clear"),i=null!==e.closest("sd-icon-button");if(!s&&!i){if("Escape"===t.key&&this.open&&(t.preventDefault(),t.stopPropagation(),this.hide(),this.displayInput.focus({preventScroll:!0})),"Enter"===t.key||" "===t.key&&""===this.typeToSelectString)return t.preventDefault(),t.stopImmediatePropagation(),this.open?void(this.currentOption&&!this.currentOption.disabled&&(this.multiple?this.toggleOptionSelection(this.currentOption):this.setSelectedOptions(this.currentOption),this.updateComplete.then((()=>{this.emit("sd-input"),this.emit("sd-change")})),this.multiple||(this.hide(),this.displayInput.focus({preventScroll:!0})))):void this.show();if(["ArrowUp","ArrowDown","Home","End"].includes(t.key)){const e=this.getAllOptions(),s=e.indexOf(this.currentOption);let i=Math.max(0,s);if(t.preventDefault(),!this.open&&(this.show(),this.currentOption))return;"ArrowDown"===t.key?(i=s+1,i>e.length-1&&(i=0)):"ArrowUp"===t.key?(i=s-1,i<0&&(i=e.length-1)):"Home"===t.key?i=0:"End"===t.key&&(i=e.length-1),this.setCurrentOption(e[i])}if(1===t.key.length||"Backspace"===t.key){const e=this.getAllOptions();if(t.metaKey||t.ctrlKey||t.altKey)return;if(!this.open){if("Backspace"===t.key)return;this.show()}t.stopPropagation(),t.preventDefault(),clearTimeout(this.typeToSelectTimeout),this.typeToSelectTimeout=window.setTimeout((()=>this.typeToSelectString=""),1e3),"Backspace"===t.key?this.typeToSelectString=this.typeToSelectString.slice(0,-1):this.typeToSelectString+=t.key.toLowerCase();for(const t of e)if(t.getTextLabel().toLowerCase().startsWith(this.typeToSelectString)){this.setCurrentOption(t);break}}}},this.handleDocumentMouseDown=t=>{const e=t.composedPath();this&&!e.includes(this)&&this.hide()}}get validity(){return this.valueInput.validity}get validationMessage(){return this.valueInput.validationMessage}connectedCallback(){super.connectedCallback(),this.applySizeToOptions(),this.open=!1}addOpenListeners(){document.addEventListener("focusin",this.handleDocumentFocusIn),document.addEventListener("keydown",this.handleDocumentKeyDown),document.addEventListener("mousedown",this.handleDocumentMouseDown)}removeOpenListeners(){document.removeEventListener("focusin",this.handleDocumentFocusIn),document.removeEventListener("keydown",this.handleDocumentKeyDown),document.removeEventListener("mousedown",this.handleDocumentMouseDown)}handleFocus(){this.hasFocus=!0,this.displayInput.setSelectionRange(0,0),this.emit("sd-focus")}handleBlur(){this.hasFocus=!1,this.emit("sd-blur")}handleLabelClick(){this.displayInput.focus()}handleComboboxMouseDown(t){const e=t.composedPath().some((t=>t instanceof HTMLSlotElement&&"removable-indicator"===t.name));this.disabled||e||(t.preventDefault(),this.displayInput.focus({preventScroll:!0}),this.open=!this.open)}handleComboboxKeyDown(t){t.stopPropagation(),this.handleDocumentKeyDown(t)}handleClearClick(t){t.stopPropagation(),""!==this.value&&(this.setSelectedOptions([]),this.displayInput.focus({preventScroll:!0}),this.updateComplete.then((()=>{this.emit("sd-clear"),this.emit("sd-input"),this.emit("sd-change")})))}handleClearMouseDown(t){t.stopPropagation(),t.preventDefault()}handleOptionClick(t){const e=t.target.closest("sd-option"),s=this.value;e&&!e.disabled&&(this.multiple?this.toggleOptionSelection(e):this.setSelectedOptions(e),this.updateComplete.then((()=>this.displayInput.focus({preventScroll:!0}))),this.value!==s&&this.updateComplete.then((()=>{this.emit("sd-input"),this.emit("sd-change")})),this.multiple||(this.hide(),this.displayInput.focus({preventScroll:!0})))}handleDefaultSlotChange(){const t=this.getAllOptions(),e=Array.isArray(this.value)?this.value:[this.value],s=[];customElements.get("sd-option")?(t.forEach((t=>{this.multiple&&(t.checkbox=!0),s.push(t.value)})),this.setSelectedOptions(t.filter((t=>e.includes(t.value))))):customElements.whenDefined("sd-option").then((()=>this.handleDefaultSlotChange()))}handleTagRemove(t,e){t.stopPropagation(),this.disabled||(this.toggleOptionSelection(e,!1),this.updateComplete.then((()=>{this.emit("sd-input"),this.emit("sd-change")})))}getAllOptions(){return[...this.querySelectorAll("sd-option")]}getFirstOption(){return this.querySelector("sd-option")}setCurrentOption(t){this.getAllOptions().forEach((t=>{t.current=!1,t.tabIndex=-1})),t&&(this.currentOption=t,t.current=!0,t.tabIndex=0,t.focus())}setSelectedOptions(t){const e=this.getAllOptions(),s=Array.isArray(t)?t:[t];e.forEach((t=>t.selected=!1)),s.length&&s.forEach((t=>t.selected=!0)),this.selectionChanged()}toggleOptionSelection(t,e){t.selected=!0===e||!1===e?e:!t.selected,this.selectionChanged()}selectionChanged(){var t,e;this.selectedOptions=this.getAllOptions().filter((t=>t.selected)),this.multiple?(this.value=this.selectedOptions.map((t=>t.value)),this.useTags||0===this.value.length?this.displayLabel="":this.displayLabel=this.localize.term("numOptionsSelected",this.selectedOptions.length)):(this.value=(null==(t=this.selectedOptions[0])?void 0:t.value)??"",this.displayLabel=(null==(e=this.selectedOptions[0])?void 0:e.getTextLabel())??""),this.updateComplete.then((()=>{this.formControlController.updateValidity()}))}get tags(){return this.selectedOptions.map(((t,e)=>{if(e<this.maxOptionsVisible||this.maxOptionsVisible<=0){const s=this.getTag(t,e);return o`<div @sd-remove="${e=>this.handleTagRemove(e,t)}">${"string"==typeof s?x(s):s}</div>`}return e===this.maxOptionsVisible?o`<sd-tag size="${"sm"===this.size?"sm":"lg"}" ?disabled="${this.disabled}">+${this.selectedOptions.length-e}</sd-tag>`:o``}))}handleInvalid(t){this.formControlController.setValidity(!1),this.formControlController.emitInvalidEvent(t),this.invalidMessage.textContent=t.target.validationMessage}handleMouseEnter(){this.hasHover=!0}handleMouseLeave(){this.hasHover=!1}handleCurrentPlacement(t){const e=t.detail;e&&(this.currentPlacement=e)}handleUseTagsChange(){const t=this.getAllOptions();customElements.get("sd-option")&&t.forEach((t=>{t.checkbox=this.multiple}))}handleDisabledChange(){this.disabled&&(this.open=!1,this.handleOpenChange())}async handleOpenChange(){if(this.open&&!this.disabled){this.setCurrentOption(this.selectedOptions[0]||this.getFirstOption()),this.emit("sd-show"),this.addOpenListeners(),await t(this),this.listbox.hidden=!1,this.popup.active=!0,requestAnimationFrame((()=>{this.setCurrentOption(this.currentOption)}));const{keyframes:s,options:i}=m(this,"select.show",{dir:this.localize.dir()});await e(this.popup.popup,s,i),this.currentOption&&g(this.currentOption,this.listbox,"vertical","auto"),this.emit("sd-after-show")}else{this.emit("sd-hide"),this.removeOpenListeners(),await t(this);const{keyframes:s,options:i}=m(this,"select.hide",{dir:this.localize.dir()});await e(this.popup.popup,s,i),this.listbox.hidden=!0,this.popup.active=!1,this.emit("sd-after-hide")}}applySizeToOptions(){this._optionsInDefaultSlot.forEach((t=>{t.size=this.size}))}handleValueChange(){const t=this.getAllOptions(),e=Array.isArray(this.value)?this.value:[this.value];this.setSelectedOptions(t.filter((t=>e.includes(t.value))))}async show(){if(!this.open&&!this.disabled)return this.open=!0,O(this,"sd-after-show");this.open=!1}async hide(){if(this.open&&!this.disabled)return this.open=!1,O(this,"sd-after-hide");this.open=!1}checkValidity(){var t;return null==(t=this.valueInput)?void 0:t.checkValidity()}getForm(){return this.formControlController.getForm()}reportValidity(){return this.formControlController.fakeUserInteraction(),this.valueInput.reportValidity()}setCustomValidity(t){this.valueInput.setCustomValidity(t),this.formControlController.updateValidity()}focus(t){this.displayInput.focus(t)}blur(){this.displayInput.blur()}render(){this.hasSlotController.test("[default]");const t=this.hasSlotController.test("label"),e=(this.hasSlotController.test("clear-icon"),this.hasSlotController.test("expand-icon"),this.hasSlotController.test("help-text")),s=!!this.label||!!t,i=!!this.helpText||!!e,a=this.clearable&&!this.disabled&&this.value.length>0,n=this.disabled?"disabled":this.hasFocus&&this.showInvalidStyle?"activeInvalid":this.hasFocus&&this.styleOnValid&&this.showValidStyle?"activeValid":this.hasFocus||this.open?"active":this.showInvalidStyle?"invalid":this.styleOnValid&&this.showValidStyle?"valid":"default",r=this.disabled?"cursor-not-allowed":"cursor-pointer",h={sm:"ml-1",md:"ml-2",lg:"ml-2"}[this.size],p={sm:"text-base",md:"text-lg",lg:"text-xl"}[this.size];return o`<div part="form-control" class="${l("relative text-left",r,"sm"===this.size?"text-sm":"text-base",this.open&&"z-50")}"><div class="flex items-center gap-1 mb-2"><label id="label" part="form-control-label" class="${s&&"inline-block"}" aria-hidden="${s?"false":"true"}" @click="${this.handleLabelClick}"><slot name="label">${this.label}</slot></label><slot name="tooltip"></slot></div><div part="form-control-input" class="${l("relative w-full bg-white","disabled"===n?"text-neutral-500":"text-black")}"><div part="border" class="${l("absolute top-0 w-full h-full pointer-events-none border rounded-default",this.hasHover&&"bg-neutral-200",{disabled:"border-neutral-500",readonly:"border-neutral-800",activeInvalid:"border-error border-2",activeValid:"border-success border-2",active:"border-primary border-2",invalid:"border-error",valid:"border-success",default:"border-neutral-800"}[n],this.open&&("bottom"===this.currentPlacement?"rounded-bl-none rounded-br-none":"rounded-tl-none rounded-tr-none"))}"></div><sd-popup @sd-current-placement="${this.handleCurrentPlacement}" class="${l("inline-flex relative w-full","bottom"===this.currentPlacement?"origin-top":"origin-bottom")}" placement="${this.placement}" strategy="${this.hoist?"fixed":"absolute"}" flip shift sync="width" auto-size="vertical" auto-size-padding="10" exportparts="
|
6
6
|
popup:popup__content,
|
7
|
-
"><div part="combobox" class="${l("relative w-full px-4 flex flex-row items-center rounded-default",this.open&&"shadow",{sm:"py-1 min-h-[32px]",md:"py-1 min-h-[40px]",lg:"py-2 min-h-[48px]"}[this.size])}" slot="anchor" @keydown="${this.handleComboboxKeyDown}" @mousedown="${this.handleComboboxMouseDown}" @mouseenter="${this.handleMouseEnter}" @mouseleave="${this.handleMouseLeave}"><input name="${this.name}" form="${this.form}" part="display-input" class="${l("appearance-none outline-none flex-grow bg-transparent w-full",r,this.multiple&&this.useTags&&this.value.length>0?"hidden":"")}" type="text" placeholder="${this.placeholder}" .disabled="${this.disabled}" .value="${this.displayLabel}" autocomplete="off" spellcheck="false" autocapitalize="off" readonly="readonly" aria-controls="listbox" aria-expanded="${this.open?"true":"false"}" aria-haspopup="listbox" aria-labelledby="label" aria-disabled="${this.disabled?"true":"false"}" aria-describedby="help-text" role="combobox" tabindex="0" @focus="${this.handleFocus}" @blur="${this.handleBlur}"> ${this.multiple&&this.useTags?o`<div part="tags" class="flex-grow flex flex-wrap items-center gap-1">${this.tags}</div>`:""} <input class="${l("value-input absolute top-0 left-0 w-full h-full opacity-0 -z-10",r)}" type="text" ?disabled="${this.disabled}" ?required="${this.required}" .value="${Array.isArray(this.value)?this.value.join(", "):this.value}" tabindex="-1" aria-hidden="true" @focus="${()=>this.focus()}" @invalid="${this.handleInvalid}"> ${a?o`<button part="clear-button" class="${l("select__clear flex justify-center",h)}" type="button" aria-label="${this.localize.term("clearEntry")}" @mousedown="${this.handleClearMouseDown}" @click="${this.handleClearClick}" tabindex="-1"><slot name="clear-icon"><sd-icon class="${l("text-icon-fill-neutral-800",p)}" library="system" name="closing-round"></sd-icon></slot></button>`:""} ${this.showInvalidStyle?o`<sd-icon part="invalid-icon" class="${l(h,p,"text-error")}" library="system" name="risk"></sd-icon>`:""} ${this.styleOnValid&&this.showValidStyle?o`<sd-icon part="valid-icon" class="${l("flex-shrink-0 text-success",h,p)}" library="system" name="status-check"></sd-icon>`:""}<slot name="expand-icon" part="expand-icon" class="${l("inline-flex ml-2 transition-all",this.open?"rotate-180":"rotate-0",this.disabled?"text-neutral-500":"text-primary",p)}"><sd-icon name="chevron-down" part="chevron" library="system" color="currentColor"></sd-icon></slot></div><div id="listbox" role="listbox" aria-expanded="${this.open?"true":"false"}" aria-multiselectable="${this.multiple?"true":"false"}" aria-labelledby="label" part="listbox" class="${l("bg-white px-2 py-3 relative border-primary overflow-y-auto",this.open&&"shadow","bottom"===this.currentPlacement?"border-r-2 border-b-2 border-l-2 rounded-br-default rounded-bl-default":"border-r-2 border-t-2 border-l-2 rounded-tr-default rounded-tl-default")}" tabindex="-1" @mouseup="${this.handleOptionClick}" @slotchange="${this.handleDefaultSlotChange}"><slot></slot></div></sd-popup></div><div class="text-sm text-neutral-700" part="form-control-help-text" id="help-text" aria-hidden="${i?"false":"true"}"><slot name="help-text">${this.helpText}</slot></div></div>${this.formControlController.renderInvalidMessage()}`}};I.dependencies={"sd-icon":w,"sd-popup":a,"sd-tag":S},I.styles=[n,s.styles,r`:host{position:relative;display:block;width:100%}:host([required]) #label::after{content:' *'}[part=listbox]{max-height:var(--auto-size-available-height,auto)}sd-popup::part(popup){z-index:var(--sd-z-index-dropdown,900);overflow-y:scroll}sd-tag::part(base){border-radius:var(--sd-border-radius-default,.25rem);padding-left:var(--sd-spacing-1,.25rem);padding-right:var(--sd-spacing-1,.25rem)}sd-tag[size=lg]::part(base){padding-left:var(--sd-spacing-2,.5rem);padding-right:var(--sd-spacing-2,.5rem)}sd-tag[disabled=false]::part(base):hover{--tw-bg-opacity:1;background-color:rgb(var(--sd-color-primary-100,236 240 249) / var(--tw-bg-opacity))}`],D([f({selector:"sd-option"})],I.prototype,"_optionsInDefaultSlot",2),D([h("sd-popup")],I.prototype,"popup",2),D([h('[part="combobox"]')],I.prototype,"combobox",2),D([h('[part="display-input"]')],I.prototype,"displayInput",2),D([h(".value-input")],I.prototype,"valueInput",2),D([h('[part="listbox"]')],I.prototype,"listbox",2),D([h("#invalid-message")],I.prototype,"invalidMessage",2),D([v()],I.prototype,"hasHover",2),D([v()],I.prototype,"displayLabel",2),D([v()],I.prototype,"hasFocus",2),D([v()],I.prototype,"currentOption",2),D([v()],I.prototype,"selectedOptions",2),D([v()],I.prototype,"showValidStyle",2),D([v()],I.prototype,"showInvalidStyle",2),D([c()],I.prototype,"defaultValue",2),D([p({type:Boolean,reflect:!0})],I.prototype,"open",2),D([p({reflect:!0})],I.prototype,"size",2),D([p({reflect:!0})],I.prototype,"placement",2),D([p()],I.prototype,"label",2),D([p()],I.prototype,"placeholder",2),D([p({type:Boolean,reflect:!0})],I.prototype,"disabled",2),D([p({attribute:"help-text"})],I.prototype,"helpText",2),D([v()],I.prototype,"currentPlacement",2),D([p({type:Boolean})],I.prototype,"clearable",2),D([p({type:Boolean,reflect:!0})],I.prototype,"multiple",2),D([p({type:Boolean,reflect:!0})],I.prototype,"useTags",2),D([p({attribute:"max-options-visible",type:Number})],I.prototype,"maxOptionsVisible",2),D([p({reflect:!0})],I.prototype,"form",2),D([p()],I.prototype,"name",2),D([p({converter:{fromAttribute:t=>t.split(" "),toAttribute:t=>t.join(" ")}})],I.prototype,"value",2),D([p({type:Boolean,reflect:!0})],I.prototype,"required",2),D([p({type:Boolean,reflect:!0,attribute:"style-on-valid"})],I.prototype,"styleOnValid",2),D([p({type:Boolean})],I.prototype,"hoist",2),D([p()],I.prototype,"getTag",2),D([C("useTags",{waitUntilFirstUpdate:!0})],I.prototype,"handleUseTagsChange",1),D([C("disabled",{waitUntilFirstUpdate:!0})],I.prototype,"handleDisabledChange",1),D([C("open",{waitUntilFirstUpdate:!0})],I.prototype,"handleOpenChange",1),D([C("size",{waitUntilFirstUpdate:!0})],I.prototype,"applySizeToOptions",1),D([C("value",{waitUntilFirstUpdate:!0})],I.prototype,"handleValueChange",1),I=D([d("sd-select")],I),y("select.show",{keyframes:[{opacity:0,scale:.9},{opacity:1,scale:1}],options:{duration:100,easing:"ease"}}),y("select.hide",{keyframes:[{opacity:1,scale:1},{opacity:0,scale:.9}],options:{duration:100,easing:"ease"}});export{I as default};
|
7
|
+
"><div part="combobox" class="${l("relative w-full px-4 flex flex-row items-center rounded-default",this.open&&"shadow",{sm:"py-1 min-h-[32px]",md:"py-1 min-h-[40px]",lg:"py-2 min-h-[48px]"}[this.size])}" slot="anchor" @keydown="${this.handleComboboxKeyDown}" @mousedown="${this.handleComboboxMouseDown}" @mouseenter="${this.handleMouseEnter}" @mouseleave="${this.handleMouseLeave}"><input name="${this.name}" form="${this.form}" part="display-input" class="${l("appearance-none outline-none flex-grow bg-transparent w-full",r,this.multiple&&this.useTags&&this.value.length>0?"hidden":"")}" type="text" placeholder="${this.placeholder}" .disabled="${this.disabled}" .value="${this.displayLabel}" autocomplete="off" spellcheck="false" autocapitalize="off" readonly="readonly" aria-controls="listbox" aria-expanded="${this.open?"true":"false"}" aria-haspopup="listbox" aria-labelledby="label" aria-disabled="${this.disabled?"true":"false"}" aria-describedby="help-text invalid-message" role="combobox" tabindex="0" @focus="${this.handleFocus}" @blur="${this.handleBlur}"> ${this.multiple&&this.useTags?o`<div part="tags" class="flex-grow flex flex-wrap items-center gap-1">${this.tags}</div>`:""} <input class="${l("value-input absolute top-0 left-0 w-full h-full opacity-0 -z-10",r)}" type="text" ?disabled="${this.disabled}" ?required="${this.required}" .value="${Array.isArray(this.value)?this.value.join(", "):this.value}" tabindex="-1" aria-hidden="true" @focus="${()=>this.focus()}" @invalid="${this.handleInvalid}"> ${a?o`<button part="clear-button" class="${l("select__clear flex justify-center",h)}" type="button" aria-label="${this.localize.term("clearEntry")}" @mousedown="${this.handleClearMouseDown}" @click="${this.handleClearClick}" tabindex="-1"><slot name="clear-icon"><sd-icon class="${l("text-icon-fill-neutral-800",p)}" library="system" name="closing-round"></sd-icon></slot></button>`:""} ${this.showInvalidStyle?o`<sd-icon part="invalid-icon" class="${l(h,p,"text-error")}" library="system" name="risk"></sd-icon>`:""} ${this.styleOnValid&&this.showValidStyle?o`<sd-icon part="valid-icon" class="${l("flex-shrink-0 text-success",h,p)}" library="system" name="status-check"></sd-icon>`:""}<slot name="expand-icon" part="expand-icon" class="${l("inline-flex ml-2 transition-all",this.open?"rotate-180":"rotate-0",this.disabled?"text-neutral-500":"text-primary",p)}"><sd-icon name="chevron-down" part="chevron" library="system" color="currentColor"></sd-icon></slot></div><div id="listbox" role="listbox" aria-expanded="${this.open?"true":"false"}" aria-multiselectable="${this.multiple?"true":"false"}" aria-labelledby="label" part="listbox" class="${l("bg-white px-2 py-3 relative border-primary overflow-y-auto",this.open&&"shadow","bottom"===this.currentPlacement?"border-r-2 border-b-2 border-l-2 rounded-br-default rounded-bl-default":"border-r-2 border-t-2 border-l-2 rounded-tr-default rounded-tl-default")}" tabindex="-1" @mouseup="${this.handleOptionClick}" @slotchange="${this.handleDefaultSlotChange}"><slot></slot></div></sd-popup></div><div class="text-sm text-neutral-700" part="form-control-help-text" id="help-text" aria-hidden="${i?"false":"true"}"><slot name="help-text">${this.helpText}</slot></div></div>${this.formControlController.renderInvalidMessage()}`}};I.dependencies={"sd-icon":w,"sd-popup":a,"sd-tag":S},I.styles=[n,s.styles,r`:host{position:relative;display:block;width:100%}:host([required]) #label::after{content:' *'}[part=listbox]{max-height:var(--auto-size-available-height,auto)}sd-popup::part(popup){z-index:var(--sd-z-index-dropdown,900);overflow-y:scroll}sd-tag::part(base){border-radius:var(--sd-border-radius-default,.25rem);padding-left:var(--sd-spacing-1,.25rem);padding-right:var(--sd-spacing-1,.25rem)}sd-tag[size=lg]::part(base){padding-left:var(--sd-spacing-2,.5rem);padding-right:var(--sd-spacing-2,.5rem)}sd-tag[disabled=false]::part(base):hover{--tw-bg-opacity:1;background-color:rgb(var(--sd-color-primary-100,236 240 249) / var(--tw-bg-opacity))}`],D([f({selector:"sd-option"})],I.prototype,"_optionsInDefaultSlot",2),D([h("sd-popup")],I.prototype,"popup",2),D([h('[part="combobox"]')],I.prototype,"combobox",2),D([h('[part="display-input"]')],I.prototype,"displayInput",2),D([h(".value-input")],I.prototype,"valueInput",2),D([h('[part="listbox"]')],I.prototype,"listbox",2),D([h("#invalid-message")],I.prototype,"invalidMessage",2),D([v()],I.prototype,"hasHover",2),D([v()],I.prototype,"displayLabel",2),D([v()],I.prototype,"hasFocus",2),D([v()],I.prototype,"currentOption",2),D([v()],I.prototype,"selectedOptions",2),D([v()],I.prototype,"showValidStyle",2),D([v()],I.prototype,"showInvalidStyle",2),D([c()],I.prototype,"defaultValue",2),D([p({type:Boolean,reflect:!0})],I.prototype,"open",2),D([p({reflect:!0})],I.prototype,"size",2),D([p({reflect:!0})],I.prototype,"placement",2),D([p()],I.prototype,"label",2),D([p()],I.prototype,"placeholder",2),D([p({type:Boolean,reflect:!0})],I.prototype,"disabled",2),D([p({attribute:"help-text"})],I.prototype,"helpText",2),D([v()],I.prototype,"currentPlacement",2),D([p({type:Boolean})],I.prototype,"clearable",2),D([p({type:Boolean,reflect:!0})],I.prototype,"multiple",2),D([p({type:Boolean,reflect:!0})],I.prototype,"useTags",2),D([p({attribute:"max-options-visible",type:Number})],I.prototype,"maxOptionsVisible",2),D([p({reflect:!0})],I.prototype,"form",2),D([p()],I.prototype,"name",2),D([p({converter:{fromAttribute:t=>t.split(" "),toAttribute:t=>t.join(" ")}})],I.prototype,"value",2),D([p({type:Boolean,reflect:!0})],I.prototype,"required",2),D([p({type:Boolean,reflect:!0,attribute:"style-on-valid"})],I.prototype,"styleOnValid",2),D([p({type:Boolean})],I.prototype,"hoist",2),D([p()],I.prototype,"getTag",2),D([C("useTags",{waitUntilFirstUpdate:!0})],I.prototype,"handleUseTagsChange",1),D([C("disabled",{waitUntilFirstUpdate:!0})],I.prototype,"handleDisabledChange",1),D([C("open",{waitUntilFirstUpdate:!0})],I.prototype,"handleOpenChange",1),D([C("size",{waitUntilFirstUpdate:!0})],I.prototype,"applySizeToOptions",1),D([C("value",{waitUntilFirstUpdate:!0})],I.prototype,"handleValueChange",1),I=D([d("sd-select")],I),y("select.show",{keyframes:[{opacity:0,scale:.9},{opacity:1,scale:1}],options:{duration:100,easing:"ease"}}),y("select.hide",{keyframes:[{opacity:1,scale:1},{opacity:0,scale:.9}],options:{duration:100,easing:"ease"}});export{I as default};
|
@@ -1 +1 @@
|
|
1
|
-
import{S as e,x as t,t as i,i as r,e as s,n as l,a as o}from"./solid-components2.js";import{d as a}from"./default-value.js";import{F as n}from"./form.js";import{o as d}from"./if-defined.js";import{l as h}from"./live.js";import{r as c}from"./state.js";import{w as u}from"./watch.js";var p=Object.defineProperty,b=Object.getOwnPropertyDescriptor,f=(e,t,i,r)=>{for(var s,l=r>1?void 0:r?b(t,i):t,o=e.length-1;o>=0;o--)(s=e[o])&&(l=(r?s(t,i,l):s(l))||l);return r&&l&&p(t,i,l),l};let m=class extends e{constructor(){super(...arguments),this.formControlController=new n(this,{value:e=>e.checked?e.value||"on":void 0,defaultValue:e=>e.defaultChecked,setValue:(e,t)=>e.checked=t}),this.showInvalidStyle=!1,this.title="",this.name="",this.disabled=!1,this.checked=!1,this.defaultChecked=!1,this.form="",this.required=!1}get validity(){return this.input.validity}firstUpdated(){this.formControlController.updateValidity()}handleClick(){this.checked=!this.checked,this.emit("sd-change")}handleBlur(){this.emit("sd-blur")}handleInput(){this.emit("sd-input")}handleInvalid(e){this.formControlController.setValidity(!1),this.formControlController.emitInvalidEvent(e),this.invalidMessage.textContent=e.target.validationMessage}handleFocus(){this.emit("sd-focus")}handleDisabledChange(){this.setAttribute("aria-disabled",this.disabled?"true":"false"),this.formControlController.setValidity(this.disabled)}handleStateChange(){this.input.checked=this.checked,this.formControlController.updateValidity()}click(){this.input.click()}focus(e){this.input.focus(e)}blur(){this.input.blur()}checkValidity(){return this.input.checkValidity()}getForm(){return this.formControlController.getForm()}reportValidity(){return this.input.reportValidity()}setCustomValidity(e){this.input.setCustomValidity(e),this.formControlController.updateValidity()}render(){return t`<label part="base" class="${i("group flex items-center text-base leading-normal text-black cursor-pointer",this.disabled&&"hover:cursor-not-allowed")}"><input id="input" class="peer absolute opacity-0 p-0 m-0 pointer-events-none" type="checkbox" title="${this.title}" name="${this.name}" value="${d(this.value)}" .checked="${h(this.checked)}" .disabled="${this.disabled}" .required="${this.required}" aria-checked="${this.checked?"true":"false"}" @click="${this.handleClick}" @input="${this.handleInput}" @invalid="${this.handleInvalid}" @blur="${this.handleBlur}" @focus="${this.handleFocus}"> <span id="control" part="control ${this.checked?" control--checked":"control--unchecked"}" class="${i("relative flex flex-initial items-center justify-center border rounded-full h-4 w-8 transition-colors ease duration-100\n peer-focus-visible:outline peer-focus-visible:outline-2 peer-focus-visible:outline-offset-2\n peer-focus-visible:outline-primary",this.disabled&&this.checked?"border-neutral-500 bg-neutral-500":this.disabled?"border-neutral-500":this.showInvalidStyle?"border-error bg-error hover:bg-error-400":this.checked?"border-accent bg-accent hover:bg-accent-550 group-hover:bg-accent-550":"border-neutral-800 bg-white hover:bg-neutral-200 group-hover:bg-neutral-200")}"><span id="thumb" part="thumb" class="${i("w-2.5 h-2.5 rounded-full transition-transform ease-in-out duration-200",this.disabled&&this.checked?"bg-white":this.disabled?"-translate-x-2 bg-neutral-500":this.showInvalidStyle?"bg-white -translate-x-2":this.checked?"translate-x-2 bg-white":"bg-neutral-800 -translate-x-2")}"></span> </span><span part="label" id="label" class="${i("select-none inline-block ml-2",this.disabled?"text-neutral-500":this.showInvalidStyle?"text-error":"text-black")}"><slot></slot></span></label> ${this.formControlController.renderInvalidMessage()}`}};m.styles=[e.styles,r`:host{display:block;width:-moz-max-content;width:max-content}:host(:focus-visible){outline:2px solid transparent;outline-offset:2px}:host([required]) #label::after{content:' *'}`],f([s("input")],m.prototype,"input",2),f([s("#invalid-message")],m.prototype,"invalidMessage",2),f([c()],m.prototype,"showInvalidStyle",2),f([l()],m.prototype,"title",2),f([l()],m.prototype,"name",2),f([l()],m.prototype,"value",2),f([l({type:Boolean,reflect:!0})],m.prototype,"disabled",2),f([l({type:Boolean,reflect:!0})],m.prototype,"checked",2),f([a("checked")],m.prototype,"defaultChecked",2),f([l({reflect:!0})],m.prototype,"form",2),f([l({type:Boolean,reflect:!0})],m.prototype,"required",2),f([u("disabled",{waitUntilFirstUpdate:!0})],m.prototype,"handleDisabledChange",1),f([u(["checked"],{waitUntilFirstUpdate:!0})],m.prototype,"handleStateChange",1),m=f([o("sd-switch")],m);export{m as default};
|
1
|
+
import{S as e,x as t,t as i,i as r,e as s,n as l,a as o}from"./solid-components2.js";import{d as a}from"./default-value.js";import{F as n}from"./form.js";import{o as d}from"./if-defined.js";import{l as h}from"./live.js";import{r as c}from"./state.js";import{w as u}from"./watch.js";var p=Object.defineProperty,b=Object.getOwnPropertyDescriptor,f=(e,t,i,r)=>{for(var s,l=r>1?void 0:r?b(t,i):t,o=e.length-1;o>=0;o--)(s=e[o])&&(l=(r?s(t,i,l):s(l))||l);return r&&l&&p(t,i,l),l};let m=class extends e{constructor(){super(...arguments),this.formControlController=new n(this,{value:e=>e.checked?e.value||"on":void 0,defaultValue:e=>e.defaultChecked,setValue:(e,t)=>e.checked=t}),this.showInvalidStyle=!1,this.title="",this.name="",this.disabled=!1,this.checked=!1,this.defaultChecked=!1,this.form="",this.required=!1}get validity(){return this.input.validity}firstUpdated(){this.formControlController.updateValidity()}handleClick(){this.checked=!this.checked,this.emit("sd-change")}handleBlur(){this.emit("sd-blur")}handleInput(){this.emit("sd-input")}handleInvalid(e){this.formControlController.setValidity(!1),this.formControlController.emitInvalidEvent(e),this.invalidMessage.textContent=e.target.validationMessage}handleFocus(){this.emit("sd-focus")}handleDisabledChange(){this.setAttribute("aria-disabled",this.disabled?"true":"false"),this.formControlController.setValidity(this.disabled)}handleStateChange(){this.input.checked=this.checked,this.formControlController.updateValidity()}click(){this.input.click()}focus(e){this.input.focus(e)}blur(){this.input.blur()}checkValidity(){return this.input.checkValidity()}getForm(){return this.formControlController.getForm()}reportValidity(){return this.input.reportValidity()}setCustomValidity(e){this.input.setCustomValidity(e),this.formControlController.updateValidity()}render(){return t`<label part="base" class="${i("group flex items-center text-base leading-normal text-black cursor-pointer",this.disabled&&"hover:cursor-not-allowed")}"><input id="input" class="peer absolute opacity-0 p-0 m-0 pointer-events-none" type="checkbox" title="${this.title}" name="${this.name}" value="${d(this.value)}" .checked="${h(this.checked)}" .disabled="${this.disabled}" .required="${this.required}" aria-checked="${this.checked?"true":"false"}" aria-describedby="invalid-message" @click="${this.handleClick}" @input="${this.handleInput}" @invalid="${this.handleInvalid}" @blur="${this.handleBlur}" @focus="${this.handleFocus}"> <span id="control" part="control ${this.checked?" control--checked":"control--unchecked"}" class="${i("relative flex flex-initial items-center justify-center border rounded-full h-4 w-8 transition-colors ease duration-100\n peer-focus-visible:outline peer-focus-visible:outline-2 peer-focus-visible:outline-offset-2\n peer-focus-visible:outline-primary",this.disabled&&this.checked?"border-neutral-500 bg-neutral-500":this.disabled?"border-neutral-500":this.showInvalidStyle?"border-error bg-error hover:bg-error-400":this.checked?"border-accent bg-accent hover:bg-accent-550 group-hover:bg-accent-550":"border-neutral-800 bg-white hover:bg-neutral-200 group-hover:bg-neutral-200")}"><span id="thumb" part="thumb" class="${i("w-2.5 h-2.5 rounded-full transition-transform ease-in-out duration-200",this.disabled&&this.checked?"bg-white":this.disabled?"-translate-x-2 bg-neutral-500":this.showInvalidStyle?"bg-white -translate-x-2":this.checked?"translate-x-2 bg-white":"bg-neutral-800 -translate-x-2")}"></span> </span><span part="label" id="label" class="${i("select-none inline-block ml-2",this.disabled?"text-neutral-500":this.showInvalidStyle?"text-error":"text-black")}"><slot></slot></span></label> ${this.formControlController.renderInvalidMessage()}`}};m.styles=[e.styles,r`:host{display:block;width:-moz-max-content;width:max-content}:host(:focus-visible){outline:2px solid transparent;outline-offset:2px}:host([required]) #label::after{content:' *'}`],f([s("input")],m.prototype,"input",2),f([s("#invalid-message")],m.prototype,"invalidMessage",2),f([c()],m.prototype,"showInvalidStyle",2),f([l()],m.prototype,"title",2),f([l()],m.prototype,"name",2),f([l()],m.prototype,"value",2),f([l({type:Boolean,reflect:!0})],m.prototype,"disabled",2),f([l({type:Boolean,reflect:!0})],m.prototype,"checked",2),f([a("checked")],m.prototype,"defaultChecked",2),f([l({reflect:!0})],m.prototype,"form",2),f([l({type:Boolean,reflect:!0})],m.prototype,"required",2),f([u("disabled",{waitUntilFirstUpdate:!0})],m.prototype,"handleDisabledChange",1),f([u(["checked"],{waitUntilFirstUpdate:!0})],m.prototype,"handleStateChange",1),m=f([o("sd-switch")],m);export{m as default};
|
@@ -1 +1 @@
|
|
1
|
-
import{S as t,x as e,t as a,c as l,i as s,e as i,n as o,a as r}from"./solid-components2.js";import{d as h}from"./default-value.js";import{F as n}from"./form.js";import{H as d}from"./slot.js";import{o as p}from"./if-defined.js";import{l as u}from"./live.js";import{r as c}from"./state.js";import{w as y}from"./watch.js";var m=Object.defineProperty,b=Object.getOwnPropertyDescriptor,f=(t,e,a,l)=>{for(var s,i=l>1?void 0:l?b(e,a):e,o=t.length-1;o>=0;o--)(s=t[o])&&(i=(l?s(e,a,i):s(i))||i);return l&&i&&m(e,a,i),i};let v=class extends t{constructor(){super(...arguments),this.formControlController=new n(this),this.hasSlotController=new d(this,"help-text","label"),this.hasFocus=!1,this.showValidStyle=!1,this.showInvalidStyle=!1,this.title="",this.name="",this.value="",this.size="lg",this.label="",this.helpText="",this.placeholder="",this.rows=4,this.disabled=!1,this.readonly=!1,this.form="",this.required=!1,this.styleOnValid=!1,this.spellcheck=!0,this.defaultValue=""}get validity(){return this.textarea.validity}get validationMessage(){return this.textarea.validationMessage}connectedCallback(){super.connectedCallback(),this.updateComplete.then((()=>{this.setTextareaHeight()}))}firstUpdated(){this.formControlController.updateValidity()}disconnectedCallback(){super.disconnectedCallback()}handleBlur(){this.hasFocus=!1,this.emit("sd-blur")}handleChange(){this.value=this.textarea.value,this.setTextareaHeight(),this.emit("sd-change")}handleFocus(){this.hasFocus=!0,this.emit("sd-focus")}handleInput(){this.value=this.textarea.value,this.formControlController.updateValidity(),this.emit("sd-input")}handleInvalid(t){this.formControlController.setValidity(!1),this.formControlController.emitInvalidEvent(t),this.invalidMessage.textContent=t.target.validationMessage}setTextareaHeight(){this.textarea.style.height=void 0}handleDisabledChange(){this.formControlController.setValidity(this.disabled)}handleRowsChange(){this.setTextareaHeight()}async handleValueChange(){await this.updateComplete,this.formControlController.updateValidity(),this.setTextareaHeight()}focus(t){this.textarea.focus(t)}blur(){this.textarea.blur()}select(){this.textarea.select()}scrollPosition(t){return t?("number"==typeof t.top&&(this.textarea.scrollTop=t.top),void("number"==typeof t.left&&(this.textarea.scrollLeft=t.left))):{top:this.textarea.scrollTop,left:this.textarea.scrollTop}}setSelectionRange(t,e,a="none"){this.textarea.setSelectionRange(t,e,a)}setRangeText(t,e,a,l){this.textarea.setRangeText(t,e,a,l),this.value!==this.textarea.value&&(this.value=this.textarea.value),this.value!==this.textarea.value&&(this.value=this.textarea.value,this.setTextareaHeight())}checkValidity(){var t;return null==(t=this.textarea)?void 0:t.checkValidity()}getForm(){return this.formControlController.getForm()}reportValidity(){return this.formControlController.fakeUserInteraction(),this.textarea.reportValidity()}setCustomValidity(t){this.textarea.setCustomValidity(t),this.formControlController.updateValidity()}render(){const t=this.hasSlotController.test("label"),l=this.hasSlotController.test("help-text"),s=!!this.label||!!t,i=!!this.helpText||!!l,o=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",r="sm"===this.size?"text-sm":"text-base",h={sm:"text-base ml-1",md:"text-lg ml-2",lg:"text-xl ml-2"}[this.size];return e`<div part="form-control" class="flex flex-col h-full text-left"><div class="flex items-center gap-1 mb-2"><label part="form-control-label" id="label" class="${a(s?"inline-block":"hidden",r)}" for="input" aria-hidden="${s?"false":"true"}"><slot name="label">${this.label}</slot></label><slot name="tooltip"></slot></div><div part="form-control-input" class="${a("relative h-full w-full",this.disabled&&"cursor-not-allowed")}"><div part="border" class="${a("absolute w-full h-full pointer-events-none border rounded-default",{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"}[o])}"></div><div part="base" class="${a("textarea h-full px-4 flex items-top rounded-default group",{sm:"textarea-sm py-1",md:"textarea-md py-1",lg:"textarea-lg py-2"}[this.size],this.disabled||this.readonly?"":"hover:bg-neutral-200",this.readonly?"bg-neutral-100":"bg-white","disabled"===o?"text-neutral-500":"text-black")}"><textarea part="textarea" id="input" class="${a("flex-grow focus:outline-none bg-transparent placeholder-neutral-700 resize-none",this.disabled&&"cursor-not-allowed",r)}" title="${this.title}" name="${p(this.name)}" .value="${u(this.value)}" ?disabled="${this.disabled}" ?readonly="${this.readonly}" ?required="${this.required}" placeholder="${p(this.placeholder)}" minlength="${p(this.minlength)}" maxlength="${p(this.maxlength)}" rows="${p(this.rows)}" autocapitalize="${p(this.autocapitalize)}" autocorrect="${p(this.autocorrect)}" ?autofocus="${this.autofocus}" spellcheck="${p(this.spellcheck)}" enterkeyhint="${p(this.enterkeyhint)}" inputmode="${p(this.inputmode)}" aria-describedby="help-text" @change="${this.handleChange}" @input="${this.handleInput}" @invalid="${this.handleInvalid}" @focus="${this.handleFocus}" @blur="${this.handleBlur}"></textarea> ${this.showInvalidStyle?e`<sd-icon class="${a("text-error absolute right-4 bg-white group-hover:bg-neutral-200",h)}" library="system" name="risk" part="invalid-icon"></sd-icon>`:""} ${this.styleOnValid&&this.showValidStyle?e`<sd-icon class="${a("text-success absolute right-4 bg-white group-hover:bg-neutral-200",h)}" library="system" name="status-check" part="valid-icon"></sd-icon>`:""}</div></div><slot name="help-text" part="form-control-help-text" id="help-text" class="${a("text-sm text-neutral-700",i?"block":"hidden")}" aria-hidden="${i?"false":"true"}">${this.helpText}</slot></div>${this.formControlController.renderInvalidMessage()}`}};v.styles=[l,t.styles,s`:host{display:block;height:100%}:host([required]) #label::after{content:' *'}.no-scrollbar::-webkit-scrollbar{display:none}`],f([i("#input")],v.prototype,"textarea",2),f([i("#invalid-message")],v.prototype,"invalidMessage",2),f([c()],v.prototype,"hasFocus",2),f([c()],v.prototype,"showValidStyle",2),f([c()],v.prototype,"showInvalidStyle",2),f([o()],v.prototype,"title",2),f([o()],v.prototype,"name",2),f([o()],v.prototype,"value",2),f([o({reflect:!0})],v.prototype,"size",2),f([o()],v.prototype,"label",2),f([o({attribute:"help-text"})],v.prototype,"helpText",2),f([o()],v.prototype,"placeholder",2),f([o({type:Number})],v.prototype,"rows",2),f([o({type:Boolean,reflect:!0})],v.prototype,"disabled",2),f([o({type:Boolean,reflect:!0})],v.prototype,"readonly",2),f([o({reflect:!0})],v.prototype,"form",2),f([o({type:Boolean,reflect:!0})],v.prototype,"required",2),f([o({type:Number})],v.prototype,"minlength",2),f([o({type:Number})],v.prototype,"maxlength",2),f([o()],v.prototype,"autocapitalize",2),f([o()],v.prototype,"autocorrect",2),f([o()],v.prototype,"autocomplete",2),f([o({type:Boolean})],v.prototype,"autofocus",2),f([o()],v.prototype,"enterkeyhint",2),f([o({type:Boolean,reflect:!0,attribute:"style-on-valid"})],v.prototype,"styleOnValid",2),f([o({type:Boolean,converter:{fromAttribute:t=>!(!t||"false"===t),toAttribute:t=>t?"true":"false"}})],v.prototype,"spellcheck",2),f([o()],v.prototype,"inputmode",2),f([h()],v.prototype,"defaultValue",2),f([y("disabled",{waitUntilFirstUpdate:!0})],v.prototype,"handleDisabledChange",1),f([y("rows",{waitUntilFirstUpdate:!0})],v.prototype,"handleRowsChange",1),f([y("value",{waitUntilFirstUpdate:!0})],v.prototype,"handleValueChange",1),v=f([r("sd-textarea")],v);export{v as default};
|
1
|
+
import{S as t,x as e,t as a,c as l,i as s,e as i,n as o,a as r}from"./solid-components2.js";import{d as h}from"./default-value.js";import{F as n}from"./form.js";import{H as d}from"./slot.js";import{o as p}from"./if-defined.js";import{l as u}from"./live.js";import{r as c}from"./state.js";import{w as y}from"./watch.js";var m=Object.defineProperty,b=Object.getOwnPropertyDescriptor,f=(t,e,a,l)=>{for(var s,i=l>1?void 0:l?b(e,a):e,o=t.length-1;o>=0;o--)(s=t[o])&&(i=(l?s(e,a,i):s(i))||i);return l&&i&&m(e,a,i),i};let v=class extends t{constructor(){super(...arguments),this.formControlController=new n(this),this.hasSlotController=new d(this,"help-text","label"),this.hasFocus=!1,this.showValidStyle=!1,this.showInvalidStyle=!1,this.title="",this.name="",this.value="",this.size="lg",this.label="",this.helpText="",this.placeholder="",this.rows=4,this.disabled=!1,this.readonly=!1,this.form="",this.required=!1,this.styleOnValid=!1,this.spellcheck=!0,this.defaultValue=""}get validity(){return this.textarea.validity}get validationMessage(){return this.textarea.validationMessage}connectedCallback(){super.connectedCallback(),this.updateComplete.then((()=>{this.setTextareaHeight()}))}firstUpdated(){this.formControlController.updateValidity()}disconnectedCallback(){super.disconnectedCallback()}handleBlur(){this.hasFocus=!1,this.emit("sd-blur")}handleChange(){this.value=this.textarea.value,this.setTextareaHeight(),this.emit("sd-change")}handleFocus(){this.hasFocus=!0,this.emit("sd-focus")}handleInput(){this.value=this.textarea.value,this.formControlController.updateValidity(),this.emit("sd-input")}handleInvalid(t){this.formControlController.setValidity(!1),this.formControlController.emitInvalidEvent(t),this.invalidMessage.textContent=t.target.validationMessage}setTextareaHeight(){this.textarea.style.height=void 0}handleDisabledChange(){this.formControlController.setValidity(this.disabled)}handleRowsChange(){this.setTextareaHeight()}async handleValueChange(){await this.updateComplete,this.formControlController.updateValidity(),this.setTextareaHeight()}focus(t){this.textarea.focus(t)}blur(){this.textarea.blur()}select(){this.textarea.select()}scrollPosition(t){return t?("number"==typeof t.top&&(this.textarea.scrollTop=t.top),void("number"==typeof t.left&&(this.textarea.scrollLeft=t.left))):{top:this.textarea.scrollTop,left:this.textarea.scrollTop}}setSelectionRange(t,e,a="none"){this.textarea.setSelectionRange(t,e,a)}setRangeText(t,e,a,l){this.textarea.setRangeText(t,e,a,l),this.value!==this.textarea.value&&(this.value=this.textarea.value),this.value!==this.textarea.value&&(this.value=this.textarea.value,this.setTextareaHeight())}checkValidity(){var t;return null==(t=this.textarea)?void 0:t.checkValidity()}getForm(){return this.formControlController.getForm()}reportValidity(){return this.formControlController.fakeUserInteraction(),this.textarea.reportValidity()}setCustomValidity(t){this.textarea.setCustomValidity(t),this.formControlController.updateValidity()}render(){const t=this.hasSlotController.test("label"),l=this.hasSlotController.test("help-text"),s=!!this.label||!!t,i=!!this.helpText||!!l,o=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",r="sm"===this.size?"text-sm":"text-base",h={sm:"text-base ml-1",md:"text-lg ml-2",lg:"text-xl ml-2"}[this.size];return e`<div part="form-control" class="flex flex-col h-full text-left"><div class="flex items-center gap-1 mb-2"><label part="form-control-label" id="label" class="${a(s?"inline-block":"hidden",r)}" for="input" aria-hidden="${s?"false":"true"}"><slot name="label">${this.label}</slot></label><slot name="tooltip"></slot></div><div part="form-control-input" class="${a("relative h-full w-full",this.disabled&&"cursor-not-allowed")}"><div part="border" class="${a("absolute w-full h-full pointer-events-none border rounded-default",{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"}[o])}"></div><div part="base" class="${a("textarea h-full px-4 flex items-top rounded-default group",{sm:"textarea-sm py-1",md:"textarea-md py-1",lg:"textarea-lg py-2"}[this.size],this.disabled||this.readonly?"":"hover:bg-neutral-200",this.readonly?"bg-neutral-100":"bg-white","disabled"===o?"text-neutral-500":"text-black")}"><textarea part="textarea" id="input" class="${a("flex-grow focus:outline-none bg-transparent placeholder-neutral-700 resize-none",this.disabled&&"cursor-not-allowed",r)}" title="${this.title}" name="${p(this.name)}" .value="${u(this.value)}" ?disabled="${this.disabled}" ?readonly="${this.readonly}" ?required="${this.required}" placeholder="${p(this.placeholder)}" minlength="${p(this.minlength)}" maxlength="${p(this.maxlength)}" rows="${p(this.rows)}" autocapitalize="${p(this.autocapitalize)}" autocorrect="${p(this.autocorrect)}" ?autofocus="${this.autofocus}" spellcheck="${p(this.spellcheck)}" enterkeyhint="${p(this.enterkeyhint)}" inputmode="${p(this.inputmode)}" aria-describedby="help-text invalid-message" @change="${this.handleChange}" @input="${this.handleInput}" @invalid="${this.handleInvalid}" @focus="${this.handleFocus}" @blur="${this.handleBlur}"></textarea> ${this.showInvalidStyle?e`<sd-icon class="${a("text-error absolute right-4 bg-white group-hover:bg-neutral-200",h)}" library="system" name="risk" part="invalid-icon"></sd-icon>`:""} ${this.styleOnValid&&this.showValidStyle?e`<sd-icon class="${a("text-success absolute right-4 bg-white group-hover:bg-neutral-200",h)}" library="system" name="status-check" part="valid-icon"></sd-icon>`:""}</div></div><slot name="help-text" part="form-control-help-text" id="help-text" class="${a("text-sm text-neutral-700",i?"block":"hidden")}" aria-hidden="${i?"false":"true"}">${this.helpText}</slot></div>${this.formControlController.renderInvalidMessage()}`}};v.styles=[l,t.styles,s`:host{display:block;height:100%}:host([required]) #label::after{content:' *'}.no-scrollbar::-webkit-scrollbar{display:none}`],f([i("#input")],v.prototype,"textarea",2),f([i("#invalid-message")],v.prototype,"invalidMessage",2),f([c()],v.prototype,"hasFocus",2),f([c()],v.prototype,"showValidStyle",2),f([c()],v.prototype,"showInvalidStyle",2),f([o()],v.prototype,"title",2),f([o()],v.prototype,"name",2),f([o()],v.prototype,"value",2),f([o({reflect:!0})],v.prototype,"size",2),f([o()],v.prototype,"label",2),f([o({attribute:"help-text"})],v.prototype,"helpText",2),f([o()],v.prototype,"placeholder",2),f([o({type:Number})],v.prototype,"rows",2),f([o({type:Boolean,reflect:!0})],v.prototype,"disabled",2),f([o({type:Boolean,reflect:!0})],v.prototype,"readonly",2),f([o({reflect:!0})],v.prototype,"form",2),f([o({type:Boolean,reflect:!0})],v.prototype,"required",2),f([o({type:Number})],v.prototype,"minlength",2),f([o({type:Number})],v.prototype,"maxlength",2),f([o()],v.prototype,"autocapitalize",2),f([o()],v.prototype,"autocorrect",2),f([o()],v.prototype,"autocomplete",2),f([o({type:Boolean})],v.prototype,"autofocus",2),f([o()],v.prototype,"enterkeyhint",2),f([o({type:Boolean,reflect:!0,attribute:"style-on-valid"})],v.prototype,"styleOnValid",2),f([o({type:Boolean,converter:{fromAttribute:t=>!(!t||"false"===t),toAttribute:t=>t?"true":"false"}})],v.prototype,"spellcheck",2),f([o()],v.prototype,"inputmode",2),f([h()],v.prototype,"defaultValue",2),f([y("disabled",{waitUntilFirstUpdate:!0})],v.prototype,"handleDisabledChange",1),f([y("rows",{waitUntilFirstUpdate:!0})],v.prototype,"handleRowsChange",1),f([y("value",{waitUntilFirstUpdate:!0})],v.prototype,"handleValueChange",1),v=f([r("sd-textarea")],v);export{v as default};
|