@neumorphism-ui/elements 1.0.0-next.1 → 1.0.0-next.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -1
- package/cdn/neu.min.js +184 -51
- package/custom-elements.json +2232 -282
- package/dist/all.d.ts +8 -0
- package/dist/all.js +8 -0
- package/dist/checkbox.d.ts +3 -0
- package/dist/checkbox.js +4 -0
- package/dist/components/button/button.d.ts +0 -2
- package/dist/components/button/button.js +3 -36
- package/dist/components/checkbox/checkbox.d.ts +44 -0
- package/dist/components/checkbox/checkbox.def.d.ts +31 -0
- package/dist/components/checkbox/checkbox.def.js +37 -0
- package/dist/components/checkbox/checkbox.js +40 -0
- package/dist/components/checkbox/checkbox.styles.d.ts +1 -0
- package/dist/components/checkbox/checkbox.styles.js +28 -0
- package/dist/components/icon/system-icons.d.ts +10 -0
- package/dist/components/icon/system-icons.js +22 -11
- package/dist/components/number-field/number-field.d.ts +84 -0
- package/dist/components/number-field/number-field.def.d.ts +125 -0
- package/dist/components/number-field/number-field.def.js +62 -0
- package/dist/components/number-field/number-field.js +121 -0
- package/dist/components/number-field/number-field.styles.d.ts +1 -0
- package/dist/components/number-field/number-field.styles.js +15 -0
- package/dist/components/option/option-data.d.ts +8 -0
- package/dist/components/option/option-data.js +12 -0
- package/dist/components/option/option.d.ts +19 -0
- package/dist/components/option/option.def.d.ts +10 -0
- package/dist/components/option/option.def.js +19 -0
- package/dist/components/option/option.js +17 -0
- package/dist/components/option/option.styles.d.ts +2 -0
- package/dist/components/option/option.styles.js +5 -0
- package/dist/components/radio/radio-link.d.ts +11 -0
- package/dist/components/radio/radio-link.js +5 -0
- package/dist/components/radio/radio.d.ts +29 -0
- package/dist/components/radio/radio.def.d.ts +11 -0
- package/dist/components/radio/radio.def.js +25 -0
- package/dist/components/radio/radio.js +43 -0
- package/dist/components/radio/radio.styles.d.ts +1 -0
- package/dist/components/radio/radio.styles.js +21 -0
- package/dist/components/radio-group/radio-group.d.ts +77 -0
- package/dist/components/radio-group/radio-group.def.d.ts +40 -0
- package/dist/components/radio-group/radio-group.def.js +55 -0
- package/dist/components/radio-group/radio-group.js +184 -0
- package/dist/components/radio-group/radio-group.styles.d.ts +1 -0
- package/dist/components/radio-group/radio-group.styles.js +15 -0
- package/dist/components/select/select.d.ts +119 -0
- package/dist/components/select/select.def.d.ts +38 -0
- package/dist/components/select/select.def.js +59 -0
- package/dist/components/select/select.js +385 -0
- package/dist/components/select/select.styles.d.ts +1 -0
- package/dist/components/select/select.styles.js +39 -0
- package/dist/components/shared/checkable.d.ts +45 -0
- package/dist/components/shared/checkable.js +108 -0
- package/dist/components/shared/field.styles.d.ts +1 -0
- package/dist/components/shared/field.styles.js +36 -0
- package/dist/components/shared/press.d.ts +7 -0
- package/dist/components/shared/press.js +42 -0
- package/dist/components/shared/step.d.ts +2 -0
- package/dist/components/shared/step.js +2 -0
- package/dist/components/shared/text-control.d.ts +72 -0
- package/dist/components/shared/text-control.js +191 -0
- package/dist/components/slider/slider.d.ts +69 -0
- package/dist/components/slider/slider.def.d.ts +39 -0
- package/dist/components/slider/slider.def.js +76 -0
- package/dist/components/slider/slider.js +170 -0
- package/dist/components/slider/slider.styles.d.ts +1 -0
- package/dist/components/slider/slider.styles.js +16 -0
- package/dist/components/switch/switch.d.ts +4 -30
- package/dist/components/switch/switch.js +5 -117
- package/dist/components/text-field/implicit-submit.d.ts +5 -0
- package/dist/components/text-field/implicit-submit.js +8 -3
- package/dist/components/text-field/text-field.d.ts +9 -36
- package/dist/components/text-field/text-field.js +21 -178
- package/dist/components/text-field/text-field.styles.d.ts +1 -1
- package/dist/components/text-field/text-field.styles.js +2 -35
- package/dist/components/textarea/textarea.d.ts +98 -0
- package/dist/components/textarea/textarea.def.d.ts +139 -0
- package/dist/components/textarea/textarea.def.js +65 -0
- package/dist/components/textarea/textarea.js +101 -0
- package/dist/components/textarea/textarea.styles.d.ts +1 -0
- package/dist/components/textarea/textarea.styles.js +9 -0
- package/dist/core/define.d.ts +16 -1
- package/dist/core/form-control.js +3 -1
- package/dist/core/validation.d.ts +6 -2
- package/dist/core/validation.js +15 -8
- package/dist/number-field.d.ts +3 -0
- package/dist/number-field.js +4 -0
- package/dist/option.d.ts +3 -0
- package/dist/option.js +4 -0
- package/dist/radio-group.d.ts +4 -0
- package/dist/radio-group.js +6 -0
- package/dist/radio.d.ts +3 -0
- package/dist/radio.js +4 -0
- package/dist/select.d.ts +3 -0
- package/dist/select.js +4 -0
- package/dist/slider.d.ts +3 -0
- package/dist/slider.js +4 -0
- package/dist/ssr.d.ts +9 -5
- package/dist/ssr.js +25 -5
- package/dist/textarea.d.ts +3 -0
- package/dist/textarea.js +4 -0
- package/package.json +41 -1
package/cdn/neu.min.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function
|
|
1
|
+
function h(r,e){r&&r.textContent!==e&&(r.textContent=e)}function u(r,e,t){r&&(t===""?r.removeAttribute(e):r.getAttribute(e)!==t&&r.setAttribute(e,t))}function Ue(r){return r.getRootNode().activeElement===r}function m(r,e){r.dispatchEvent(new Event(e,{bubbles:!0,composed:!0}))}function g(r,e){let t=!1,i=()=>{t||(t=!0,window.removeEventListener(r.type,n),clearTimeout(s),e())},n=a=>{a===r&&i()};window.addEventListener(r.type,n);let s=setTimeout(i,0)}function C(r,e){return e.attribute??r.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}function I(r,e){switch(r.type){case"boolean":return e!==null;case"number":{if(e===null||e.trim()==="")return r.default;let t=Number(e);return Number.isFinite(t)?t:r.default}case"string":{let t=r.default??"";return e===null||r.values&&!r.values.includes(e)?t:e}}}function We(r,e){return r.type==="boolean"?!!e:r.type==="number"&&typeof e=="number"?Number.isFinite(e)?e:r.default:I(r,e==null?null:String(e))}function je(r,e){switch(r.type){case"boolean":return e?"":null;case"number":return String(e);case"string":return e===""?null:String(e)}}function Ge(r,e){let t={};for(let[i,n]of Object.entries(r))t[i]=I(n,e(C(i,n)));return t}var Ft=globalThis.HTMLElement??class{},Ye=new WeakMap,Xe=new WeakSet;function Ht(r){let e=Ye.get(r);return e||(e=new CSSStyleSheet,e.replaceSync(r.styles),Ye.set(r,e)),e}var p=class r extends Ft{static extraProperties=[];static get observedAttributes(){return Object.entries(this.def.props).map(([e,t])=>C(e,t))}static define(){let e=this.def;for(let[i,n]of Object.entries(e.props)){if(this.definesAccessor(i))continue;let s=function(){return this.props[i]};Xe.add(s),Object.defineProperty(this.prototype,i,{configurable:!0,enumerable:!0,get:s,set(a){this.setProp(i,We(n,a))}})}let t=globalThis.customElements;t&&!t.get(e.tag)&&t.define(e.tag,this)}static definesAccessor(e){if(Object.prototype.hasOwnProperty.call(this.prototype,e))return!0;let t=Object.getPrototypeOf(this.prototype);for(;t!==null&&t!==r.prototype;t=Object.getPrototypeOf(t)){let i=Object.getOwnPropertyDescriptor(t,e);if(i)return!(i.get&&Xe.has(i.get))}return!1}internals;props;root=null;refs=new Map;reflecting=!1;hasConnected=!1;formDisabled=!1;authorTabIndex=null;writtenTabIndex;constructor(){super(),this.internals=this.attachInternals(),this.props=Ge(this.def.props,e=>this.getAttribute(e)),this.addEventListener("click",e=>{this.isDisabled&&(e.preventDefault(),e.stopImmediatePropagation())},{capture:!0})}connectedCallback(){this.hasConnected||(this.hasConnected=!0,this.upgradeProperties(),this.update(this.allKeys()),this.ensureRoot()),this.connected()}disconnectedCallback(){this.disconnected()}attributeChangedCallback(e,t,i){if(!this.reflecting){for(let[n,s]of Object.entries(this.def.props))if(C(n,s)===e){this.setProp(n,I(s,i),!0);return}}}formDisabledCallback(e){this.formDisabled=e,this.propChanged("disabled")}get def(){return this.constructor.def}get isDisabled(){return this.props.disabled===!0||this.formDisabled}ref(e){if(!this.root)return null;let t=this.refs.get(e);if(!t){let i=this.root.querySelector(`[data-ref="${e}"]`);if(!i)return null;this.refs.set(e,i),t=i}return t}setProp(e,t,i=!1){let n=this.def.props[e];!n||Object.is(this.props[e],t)||(this.props[e]=t,!i&&n.reflect&&this.reflect(e,n,t),this.propChanged(e))}toggleState(e,t){t?this.internals.states.add(e):this.internals.states.delete(e)}syncFocusable(e){let t=this.getAttribute("tabindex");t!==this.writtenTabIndex&&(this.authorTabIndex=t);let i=e?this.authorTabIndex??"0":null;i===null?this.removeAttribute("tabindex"):t!==i&&this.setAttribute("tabindex",i),this.writtenTabIndex=i}syncDisabledState(){this.internals.ariaDisabled=this.isDisabled?"true":null,this.syncFocusable(!this.isDisabled)}willUpdate(e){}update(e){}rendered(){}connected(){}disconnected(){}allKeys(){return new Set(Object.keys(this.def.props))}propChanged(e){let t=new Set([e]);this.willUpdate(t),this.hasConnected&&this.update(t)}reflect(e,t,i){let n=je(t,i),s=C(e,t);this.reflecting=!0;try{n===null?this.removeAttribute(s):this.setAttribute(s,n)}finally{this.reflecting=!1}}upgradeProperties(){let e=this.constructor,t=this;for(let i of[...Object.keys(e.def.props),...e.extraProperties]){if(!Object.prototype.hasOwnProperty.call(this,i))continue;let n=t[i];delete t[i],t[i]=n}}ensureRoot(e){if(this.root)return;let t=this.internals.shadowRoot,i=t?this.def.template(this.props).value.split('data-ref="').length-1:0;if(!e&&document.readyState==="loading"&&this.parsing(t,i)){this.waitForParser(t,i);return}(!t||this.parsing(t,i))&&(t??=this.attachShadow({mode:"open",delegatesFocus:this.def.delegatesFocus??!1}),t.innerHTML=this.def.template(this.props).value),this.adoptRoot(t)}parsing(e,t){if(e)return e.querySelectorAll("[data-ref]").length<t;if(this.firstChild!==null||this.nextSibling!==null)return!1;for(let i=this.parentNode;i!==null;i=i.parentNode)if(i.nextSibling!==null)return!1;return!0}waitForParser(e,t){let i=s=>{n.disconnect(),document.removeEventListener("DOMContentLoaded",i),this.ensureRoot(s)},n=new MutationObserver(()=>{this.parsing(e,t)||i()});n.observe(e??document,{childList:!0,subtree:!0}),document.addEventListener("DOMContentLoaded",i)}adoptRoot(e){this.root=e,e.adoptedStyleSheets=[Ht(this.def)],e.querySelector("style[data-neu-ssr]")?.remove(),this.rendered(),this.update(this.allKeys())}};var Ze=Symbol("neu.raw"),Vt={"&":"&","<":"<",">":">",'"':""","'":"'"};function Nt(r){return r.replace(/[&<>"']/g,e=>Vt[e]??e)}function f(r){return{[Ze]:!0,value:r}}function Bt(r){return typeof r=="object"&&r!==null&&Ze in r}function Je(r){return r==null||r===!1?"":Array.isArray(r)?r.map(Je).join(""):Bt(r)?r.value:Nt(String(r))}function o(r,...e){let t=r[0]??"";return e.forEach((i,n)=>{t+=Je(i)+(r[n+1]??"")}),f(t)}var c=`
|
|
2
2
|
:host {
|
|
3
3
|
--_neu-bg: var(--neu-bg, #e0e5ec);
|
|
4
4
|
--_neu-accent-c: var(--neu-accent, #6d5dfc);
|
|
@@ -25,7 +25,7 @@ function p(t,e){t&&t.textContent!==e&&(t.textContent=e)}function m(t,e,r){t&&(r=
|
|
|
25
25
|
:host([hidden]) { display: none !important; }
|
|
26
26
|
:host(:focus) { outline: none; }
|
|
27
27
|
*, *::before, *::after { box-sizing: border-box; }
|
|
28
|
-
`,
|
|
28
|
+
`,d=[{name:"--neu-bg",description:"Surface colour; shadows and text are derived from it."},{name:"--neu-accent",description:"Accent colour."},{name:"--neu-distance",description:"Shadow distance for the md size."},{name:"--neu-intensity",description:"Shadow strength multiplier."},{name:"--neu-radius",description:"Corner radius for the md size."}];var ae='<path d="M5 12.5l4.5 4.5L19 7.5"/>',le='<path d="M6 9l6 6 6-6"/>',qt='<path d="M6 15l6-6 6 6"/>',de='<path d="M12 5v14M5 12h14"/>',A='<path d="M5 12h14"/>',Kt='<path d="M6 6l12 12M18 6L6 18"/>',Ut='<circle cx="12" cy="12" r="9"/><path d="M12 7.5v5.5M12 16.5h.01"/>',Wt='<circle cx="12" cy="8" r="4"/><path d="M4 20c0-4 3.6-6 8-6s8 2 8 6"/>',Qe={check:ae,"chevron-down":le,"chevron-up":qt,plus:de,minus:A,x:Kt,"alert-circle":Ut,user:Wt};function x(r){return`<svg part="svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false">${r}</svg>`}function w(r){let e=Object.hasOwn(Qe,r)?Qe[r]:void 0;return e===void 0?void 0:x(e)}var et=`${c}
|
|
29
29
|
:host { display: inline-block; vertical-align: middle; --_neu-s: 2.5rem; inline-size: var(--_neu-s); block-size: var(--_neu-s); }
|
|
30
30
|
:host([size='sm']) { --_neu-s: 2rem; }
|
|
31
31
|
:host([size='lg']) { --_neu-s: 3.5rem; }
|
|
@@ -36,7 +36,7 @@ function p(t,e){t&&t.textContent!==e&&(t.textContent=e)}function m(t,e,r){t&&(r=
|
|
|
36
36
|
.base[data-show='image'] .image, .base[data-show='initials'] .initials { display: block; }
|
|
37
37
|
.base[data-show='icon'] .icon { display: flex; inline-size: 60%; block-size: 60%; }
|
|
38
38
|
.icon svg { inline-size: 100%; block-size: 100%; }
|
|
39
|
-
`;var
|
|
39
|
+
`;var ce={tag:"neu-avatar",props:{src:{type:"string",reflect:!0},label:{type:"string"},initials:{type:"string"},size:{type:"string",default:"md",values:["sm","md","lg"],reflect:!0},shape:{type:"string",default:"circle",values:["circle","rounded"],reflect:!0}},styles:et,template:r=>{let e=r.src?"image":r.initials?"initials":"icon";return o`<span part="base" class="base" data-ref="base" data-show="${e}"><img part="image" class="image" data-ref="image" alt=""${r.src?o` src="${r.src}"`:""}><span part="initials" class="initials" data-ref="initials">${r.initials}</span><span part="icon" class="icon">${f(w("user")??"")}</span></span>`},docs:{summary:"A user picture that falls back to initials, then to a generic user icon. With `label` it is an image named by it; without, it is decorative and hidden from assistive technology.",events:[],slots:[],parts:[{name:"base",description:"The sized, raised wrapper."},{name:"image",description:"The picture."},{name:"initials",description:"The initials shown when there is no picture."},{name:"icon",description:"Wrapper around the fallback user icon."},{name:"svg",description:"The rendered fallback SVG element."}],cssProperties:d}};var R=class extends p{static def=ce;broken=!1;willUpdate(e){e.has("src")&&this.setBroken(!1)}rendered(){let e=this.ref("image");e&&(e.addEventListener("error",()=>this.setBroken(!0)),e.hasAttribute("src")&&e.complete&&e.naturalWidth===0&&(this.broken=!0),this.toggleState("image-error",this.broken))}update(e){if(e.has("label")){let a=String(this.props.label);this.internals.role=a?"img":null,this.internals.ariaLabel=a||null,this.internals.ariaHidden=a?null:"true"}e.has("initials")&&h(this.ref("initials"),String(this.props.initials));let t=this.ref("image");if(!t)return;let i=String(this.props.src);e.has("src")&&(t.getAttribute("src")??"")!==i&&(i?t.setAttribute("src",i):t.removeAttribute("src"));let n=this.ref("base"),s=this.showing();n.dataset.show!==s&&(n.dataset.show=s)}showing(){return this.props.src&&!this.broken?"image":this.props.initials?"initials":"icon"}setBroken(e){this.broken!==e&&(this.broken=e,this.toggleState("image-error",e),this.ref("base")&&this.update(new Set))}};R.define();var tt=`${c}
|
|
40
40
|
:host { display: inline-block; vertical-align: middle; --_neu-success: var(--neu-success, #3bb273); --_neu-warning: var(--neu-warning, #e6a23c); }
|
|
41
41
|
.base { display: inline-flex; align-items: center; min-block-size: 1.25rem; padding-inline: 0.5rem; font-size: 0.75rem; font-weight: 600; border-radius: calc(var(--_neu-r) * 0.5); box-shadow: var(--_neu-raised-sm); background: var(--_neu-bg); color: var(--_neu-fg-muted); }
|
|
42
42
|
:host([pill]) .base { border-radius: 999px; }
|
|
@@ -44,9 +44,9 @@ function p(t,e){t&&t.textContent!==e&&(t.textContent=e)}function m(t,e,r){t&&(r=
|
|
|
44
44
|
:host([variant='success']) .base { color: var(--_neu-success); }
|
|
45
45
|
:host([variant='warning']) .base { color: var(--_neu-warning); }
|
|
46
46
|
:host([variant='danger']) .base { color: var(--_neu-danger); }
|
|
47
|
-
`;var
|
|
47
|
+
`;var pe={tag:"neu-badge",props:{variant:{type:"string",default:"neutral",values:["neutral","accent","success","warning","danger"],reflect:!0},pill:{type:"boolean",reflect:!0}},styles:tt,template:()=>o`<span part="base" class="base"><slot></slot></span>`,docs:{summary:"A small raised label for status or counts.",events:[],slots:[{name:"",description:"The badge text."}],parts:[{name:"base",description:"The badge itself."}],cssProperties:[...d,{name:"--neu-success",description:"Colour of the success variant."},{name:"--neu-warning",description:"Colour of the warning variant."}]}};var O=class extends p{static def=pe};O.define();var ue=new WeakSet,rt=!1;function S(r){ue.add(r),setTimeout(()=>ue.delete(r),0)}var me=Symbol.for("neu-ui.submits");function he(r){return r instanceof HTMLButtonElement?r.type==="submit":r instanceof HTMLInputElement?r.type==="submit"||r.type==="image":r.constructor[me]===!0&&r.type==="submit"}function it(r){let e=r.form;return e instanceof HTMLFormElement?e:null}function jt(){rt||typeof document>"u"||(rt=!0,document.addEventListener("click",r=>{for(let e of r.composedPath()){if(!(e instanceof Element)||!he(e))continue;let t=it(e);t&&S(t);return}},{capture:!0}),document.addEventListener("keydown",r=>{if(!(r.key!=="Enter"||!(r.composedPath()[0]instanceof HTMLInputElement)))for(let e of r.composedPath()){if(!(e instanceof Element))continue;let t=it(e);if(t){S(t);return}}},{capture:!0}))}var b=class extends p{static formAssociated=!0;interacted=!1;constructor(){super(),jt(),this.addEventListener("invalid",()=>{let e=this.internals.form;e&&ue.has(e)&&this.markInteracted()})}get form(){return this.internals.form}get validity(){return this.internals.validity}get validationMessage(){return this.internals.validationMessage}get willValidate(){return this.internals.willValidate}checkValidity(){return this.internals.checkValidity()}reportValidity(){let e=this.internals.reportValidity();return e||this.markInteracted(),e}formResetCallback(){this.interacted=!1,this.resetToDefault(),this.commit()}formStateRestoreCallback(e){typeof e=="string"&&(this.restoreState(e),this.commit())}formState(){return this.formValue()??""}commit(){this.internals.setFormValue(this.formValue(),this.formState()),this.validate(),this.syncUserInvalid()}markInteracted(){this.interacted=!0,this.syncUserInvalid()}syncUserInvalid(){this.toggleState("user-invalid",this.interacted&&!this.internals.validity.valid)}};function F(r,e,t,i){let n=a=>a?e.add("pressed"):e.delete("pressed"),s=a=>g(a,()=>{!a.defaultPrevented&&!i()&&r.click()});r.addEventListener("keydown",a=>{if(!i())if(a.key===" "){if(a.defaultPrevented)return;a.preventDefault(),n(!0)}else a.key==="Enter"&&(t==="repeat"||t==="once"&&!a.repeat)&&s(a)}),r.addEventListener("keyup",a=>{a.key!==" "||!e.has("pressed")||(n(!1),s(a))}),r.addEventListener("blur",()=>{Ue(r)||n(!1)}),r.addEventListener("focus",()=>n(!1))}var nt=r=>`${c}
|
|
48
48
|
:host { display: inline-block; vertical-align: middle; cursor: pointer; user-select: none; }
|
|
49
|
-
:host(:disabled), :host([disabled])${
|
|
49
|
+
:host(:disabled), :host([disabled])${r?", :host([loading])":""} { cursor: not-allowed; }
|
|
50
50
|
.base {
|
|
51
51
|
display: inline-flex; flex: auto; align-items: center; justify-content: center;
|
|
52
52
|
border-start-start-radius: var(--_neu-grp-ss, var(--_neu-rr, var(--_neu-r))); border-start-end-radius: var(--_neu-grp-se, var(--_neu-rr, var(--_neu-r)));
|
|
@@ -60,10 +60,10 @@ function p(t,e){t&&t.textContent!==e&&(t.textContent=e)}function m(t,e,r){t&&(r=
|
|
|
60
60
|
:host([variant='primary']) .base { color: var(--_neu-accent-c); }
|
|
61
61
|
:host([variant='flat']) .base { box-shadow: none; }
|
|
62
62
|
:host([variant='flat']:hover:not(:disabled):not([disabled])) .base { box-shadow: var(--_neu-grp-shadow, var(--_neu-raised-sm)); }
|
|
63
|
-
:host(:active:not(:disabled):not([disabled])${
|
|
63
|
+
:host(:active:not(:disabled):not([disabled])${r?":not([loading])":""}) .base, :host(:state(pressed)) .base { box-shadow: var(--_neu-inset-sm); }
|
|
64
64
|
:host(:focus-visible) .base { box-shadow: var(--_neu-grp-shadow, var(--_neu-raised)), var(--_neu-focus); }
|
|
65
65
|
:host(:disabled) .base, :host([disabled]) .base { box-shadow: none; color: var(--_neu-fg-muted); }
|
|
66
|
-
`,
|
|
66
|
+
`,st=nt(!1),ot=`${nt(!0)}
|
|
67
67
|
.base { min-block-size: 2.5rem; padding-inline: 1.125rem; font: inherit; font-weight: 600; font-size: 0.9375rem; line-height: 1; }
|
|
68
68
|
:host([size='sm']) .base { min-block-size: 2rem; padding-inline: 0.875rem; font-size: 0.8125rem; }
|
|
69
69
|
:host([size='lg']) .base { min-block-size: 3rem; padding-inline: 1.5rem; font-size: 1.0625rem; }
|
|
@@ -78,7 +78,7 @@ function p(t,e){t&&t.textContent!==e&&(t.textContent=e)}function m(t,e,r){t&&(r=
|
|
|
78
78
|
:host([loading]) .spinner { display: inline-block; }
|
|
79
79
|
@keyframes neu-spin { to { transform: rotate(360deg); } }
|
|
80
80
|
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }
|
|
81
|
-
`;var
|
|
81
|
+
`;var fe={tag:"neu-button",props:{variant:{type:"string",default:"default",values:["default","primary","flat"],reflect:!0},size:{type:"string",default:"md",values:["sm","md","lg"],reflect:!0},disabled:{type:"boolean",reflect:!0},loading:{type:"boolean",reflect:!0},type:{type:"string",default:"button",values:["button","submit","reset"],reflect:!0}},styles:ot,template:()=>o`<span part="base" class="base"><span part="prefix" class="prefix"><slot name="prefix"></slot></span><span part="label" class="label"><slot></slot></span><span part="suffix" class="suffix"><slot name="suffix"></slot></span><span part="spinner" class="spinner" aria-hidden="true"></span></span>`,docs:{summary:'A raised button. Use variant="primary" for the main action of a view.',events:[{name:"click",description:"Fired on activation; never while disabled or loading."}],slots:[{name:"",description:"Button label."},{name:"prefix",description:"Content before the label, such as an icon."},{name:"suffix",description:"Content after the label."}],parts:[{name:"base",description:"The raised surface."},{name:"label",description:"Wrapper around the default slot."},{name:"prefix",description:"Wrapper around the prefix slot."},{name:"suffix",description:"Wrapper around the suffix slot."},{name:"spinner",description:"Spinner shown while loading."}],cssProperties:d}};var E=class extends p{static def=fe;static formAssociated=!0;static[me]=!0;constructor(){super(),this.internals.role="button",this.addEventListener("click",e=>this.onClickCapture(e),{capture:!0}),this.addEventListener("click",e=>this.onClick(e)),F(this,this.internals.states,"repeat",()=>this.inactive)}get form(){return this.internals.form}get inactive(){return this.isDisabled||this.props.loading===!0}onClickCapture(e){this.props.loading===!0&&(e.preventDefault(),e.stopImmediatePropagation())}onClick(e){g(e,()=>{let t=this.internals.form;e.defaultPrevented||!t||(this.props.type==="submit"?(S(t),t.requestSubmit()):this.props.type==="reset"&&t.reset())})}update(e){(e.has("disabled")||e.has("loading"))&&(this.syncDisabledState(),this.internals.ariaBusy=this.props.loading===!0?"true":null)}};E.define();var at=`${c}
|
|
82
82
|
:host { display: inline-flex; vertical-align: middle; }
|
|
83
83
|
.base { display: inline-flex; border-radius: var(--_neu-r); box-shadow: var(--_neu-raised); }
|
|
84
84
|
:host([orientation='vertical']) .base { flex-direction: column; }
|
|
@@ -89,20 +89,46 @@ function p(t,e){t&&t.textContent!==e&&(t.textContent=e)}function m(t,e,r){t&&(r=
|
|
|
89
89
|
:host(:not([orientation='vertical'])) ::slotted(:nth-last-child(1 of :not([hidden], template, script, style))) { --_neu-grp-se: var(--_neu-r); --_neu-grp-ee: var(--_neu-r); }
|
|
90
90
|
:host([orientation='vertical']) ::slotted(:nth-child(1 of :not([hidden], template, script, style))) { --_neu-grp-ss: var(--_neu-r); --_neu-grp-se: var(--_neu-r); }
|
|
91
91
|
:host([orientation='vertical']) ::slotted(:nth-last-child(1 of :not([hidden], template, script, style))) { --_neu-grp-es: var(--_neu-r); --_neu-grp-ee: var(--_neu-r); }
|
|
92
|
-
`;var
|
|
92
|
+
`;var be={tag:"neu-button-group",props:{label:{type:"string",reflect:!0},orientation:{type:"string",default:"horizontal",values:["horizontal","vertical"],reflect:!0}},styles:at,template:()=>o`<span part="base" class="base"><slot></slot></span>`,docs:{summary:"Merges adjacent buttons into one raised block.",events:[],slots:[{name:"",description:"neu-button and neu-icon-button elements."}],parts:[{name:"base",description:"The raised wrapper around the buttons."}],cssProperties:d}};var H=class extends p{static def=be;constructor(){super(),this.internals.role="group"}update(e){e.has("label")&&(this.internals.ariaLabel=String(this.props.label)||null)}};H.define();var lt=new Map;function L(r,e){let t=lt.get(r);if(t===void 0){let i=r==="select"?document.createElement("select"):Object.assign(document.createElement("input"),{type:r});i.required=!0,t=i.validationMessage||e,lt.set(r,t)}return t}function dt(r){return{badInput:r.badInput,customError:r.customError,patternMismatch:r.patternMismatch,rangeOverflow:r.rangeOverflow,rangeUnderflow:r.rangeUnderflow,stepMismatch:r.stepMismatch,tooLong:r.tooLong,tooShort:r.tooShort,typeMismatch:r.typeMismatch,valueMissing:r.valueMissing}}var D=class extends b{static extraProperties=["defaultChecked"];static enter="once";current;dirty=!1;constructor(){super(),this.current=this.props.checked===!0,this.addEventListener("click",e=>this.onClick(e)),F(this,this.internals.states,this.constructor.enter,()=>this.isDisabled)}get checked(){return this.current}set checked(e){this.dirty=!0,this.setCurrent(!!e)}get defaultChecked(){return this.props.checked===!0}set defaultChecked(e){this.toggleAttribute("checked",!!e)}ariaCheckedValue(){return this.current?"true":"false"}flip(){let e=this.current;return this.setCurrent(!e),()=>this.setCurrent(e)}onClick(e){this.dirty=!0;let t=this.flip(),i=this.ariaCheckedValue();g(e,()=>{e.defaultPrevented?t():this.isConnected&&this.ariaCheckedValue()===i&&(this.markInteracted(),m(this,"input"),m(this,"change"))})}sync(){this.toggleState("checked",this.current),this.internals.ariaChecked=this.ariaCheckedValue(),this.paint()}setCurrent(e){this.current=e,this.sync(),this.commit()}willUpdate(e){e.has("checked")&&!this.dirty&&(this.current=this.props.checked===!0)}update(e){e.has("disabled")&&this.syncDisabledState(),e.has("checked")?this.setCurrent(this.current):(e.has("required")||e.has("value"))&&this.commit()}formValue(){return this.current?String(this.props.value):null}formState(){return this.current?"checked":"unchecked"}validate(){this.props.required===!0&&!this.current?this.internals.setValidity({valueMissing:!0},L("checkbox","Please check this box if you want to proceed."),this.ref(this.anchor)??void 0):this.internals.setValidity({})}resetToDefault(){this.dirty=!1,this.setCurrent(this.props.checked===!0)}restoreState(e){this.dirty=!0,this.setCurrent(e==="checked")}};var ct=`${c}
|
|
93
|
+
:host {
|
|
94
|
+
display: inline-flex; vertical-align: middle; cursor: pointer; user-select: none;
|
|
95
|
+
--_neu-box: 1.25rem;
|
|
96
|
+
}
|
|
97
|
+
:host([size='sm']) { --_neu-box: 1rem; }
|
|
98
|
+
:host([size='lg']) { --_neu-box: 1.5rem; }
|
|
99
|
+
:host(:disabled), :host([disabled]) { cursor: not-allowed; }
|
|
100
|
+
.base { display: inline-flex; align-items: center; gap: 0.625rem; }
|
|
101
|
+
.control {
|
|
102
|
+
display: inline-flex; align-items: center; justify-content: center; flex: none;
|
|
103
|
+
inline-size: var(--_neu-box); block-size: var(--_neu-box);
|
|
104
|
+
border-radius: calc(var(--_neu-r) * 0.4); background: var(--_neu-bg); box-shadow: var(--_neu-inset-sm);
|
|
105
|
+
color: var(--_neu-accent-c);
|
|
106
|
+
transition: background-color var(--_neu-dur) ease, box-shadow var(--_neu-dur) ease;
|
|
107
|
+
}
|
|
108
|
+
.control.on, .control.mixed { background: var(--_neu-accent-soft); }
|
|
109
|
+
.indicator { display: inline-flex; inline-size: 80%; block-size: 80%; opacity: 0; }
|
|
110
|
+
.control.on .indicator, .control.mixed .indicator { opacity: 1; }
|
|
111
|
+
.indicator svg { inline-size: 100%; block-size: 100%; }
|
|
112
|
+
.indicator svg:last-child, .control.mixed .indicator svg:first-child { display: none; }
|
|
113
|
+
.control.mixed .indicator svg:last-child { display: block; }
|
|
114
|
+
:host(:focus-visible) .control { box-shadow: var(--_neu-inset-sm), var(--_neu-focus); }
|
|
115
|
+
:host(:disabled) .base, :host([disabled]) .base { opacity: 0.55; }
|
|
116
|
+
:host(:state(user-invalid)) .control { box-shadow: var(--_neu-inset-sm), 0 0 0 2px color-mix(in oklab, var(--_neu-danger) 55%, transparent); }
|
|
117
|
+
.label { color: var(--_neu-fg); }
|
|
118
|
+
`;var Gt=f(x(ae)),Yt=f(x(A)),ve={tag:"neu-checkbox",props:{checked:{type:"boolean"},indeterminate:{type:"boolean"},name:{type:"string",reflect:!0},value:{type:"string",default:"on",reflect:!0},disabled:{type:"boolean",reflect:!0},required:{type:"boolean",reflect:!0},size:{type:"string",default:"md",values:["sm","md","lg"],reflect:!0}},form:{valueProp:"checked"},styles:ct,template:r=>o`<span part="base" class="base"><span part="control" class="control${r.checked?" on":""}${r.indeterminate?" mixed":""}" data-ref="control"><span part="indicator" class="indicator">${Gt}${Yt}</span></span><span part="label" class="label"><slot></slot></span></span>`,docs:{summary:"A checkbox. The checked attribute is the default state; indeterminate is a property whose attribute only sets the initial state.",events:[{name:"input",description:"Fired when the user toggles the checkbox."},{name:"change",description:"Fired after input when the user toggles the checkbox."}],slots:[{name:"",description:"Label; also the accessible name."}],parts:[{name:"base",description:"Wrapper around control and label."},{name:"control",description:"The inset box."},{name:"indicator",description:"The check or minus mark."},{name:"label",description:"Wrapper around the default slot."}],cssProperties:d}};var V=class extends D{static def=ve;static enter="none";anchor="control";constructor(){super(),this.internals.role="checkbox"}ariaCheckedValue(){return this.props.indeterminate===!0?"mixed":super.ariaCheckedValue()}flip(){if(!(this.props.indeterminate===!0))return super.flip();let t=this.checked;return this.setProp("indeterminate",!1),this.checked=!t,()=>{this.setProp("indeterminate",!0),this.checked=t}}paint(){let e=this.props.indeterminate===!0,t=this.ref("control");t?.classList.toggle("on",this.checked),t?.classList.toggle("mixed",e),this.toggleState("indeterminate",e)}update(e){super.update(e),e.has("indeterminate")&&this.sync()}};V.define();var pt=`${c}
|
|
93
119
|
:host { display: block; margin-block: 0.75rem; }
|
|
94
120
|
.base { display: block; border-block-start: 1px solid var(--_neu-sd); border-block-end: 1px solid var(--_neu-sl); }
|
|
95
121
|
:host([orientation='vertical']) { display: inline-block; align-self: stretch; min-block-size: 1em; margin-block: 0; margin-inline: 0.75rem; }
|
|
96
122
|
:host([orientation='vertical']) .base { block-size: 100%; min-block-size: 1em; border-block: 0; border-inline-start: 1px solid var(--_neu-sd); border-inline-end: 1px solid var(--_neu-sl); }
|
|
97
|
-
`;var
|
|
98
|
-
${
|
|
99
|
-
${
|
|
123
|
+
`;var ge={tag:"neu-divider",props:{orientation:{type:"string",default:"horizontal",values:["horizontal","vertical"],reflect:!0}},styles:pt,template:()=>o`<span part="base" class="base"></span>`,docs:{summary:"A thin engraved line that separates content.",events:[],slots:[],parts:[{name:"base",description:"The engraved line."}],cssProperties:d}};var N=class extends p{static def=ge;constructor(){super(),this.internals.role="separator"}update(e){e.has("orientation")&&(this.internals.ariaOrientation=this.orientation)}};N.define();var ut=new Map,mt=new Map,ye=new Set;function Xt(r,e){if(r!=="system"){ut.set(r,e),mt.set(r,xe(r)+1);for(let t of[...ye])t(r)}}function ht(r){return ut.get(r)}function xe(r){return mt.get(r)??0}function ft(r){return ye.add(r),()=>ye.delete(r)}var ke="http://www.w3.org/2000/svg",Zt=new Set("svg g path circle ellipse line polyline polygon rect defs title desc symbol linearGradient radialGradient stop clipPath mask use".split(" ")),we=new Map,bt=new WeakMap,vt,Jt=0,Qt=/^on|^style=|href=(?!#)|\\|(?:image-set|src)\(|url\((?![\s'"]*#)/i;function gt(r){for(let{name:e,value:t}of[...r.attributes])Qt.test(`${e}=${t}`)&&r.removeAttribute(e);for(let e of[...r.childNodes])if(e.nodeType!==3){if(e.nodeType!==1||e.namespaceURI!==ke||!Zt.has(e.localName)){e.remove();continue}gt(e)}}function yt(r){vt??=new DOMParser;let e=r.replace(/<svg\b(?![^>]*\sxmlns\s*=)/,`<svg xmlns="${ke}"`),t=vt.parseFromString(e,"image/svg+xml").documentElement;return t.namespaceURI!==ke||t.localName!=="svg"||t.querySelector("parsererror")?null:(gt(t),t.removeAttribute("xmlns:xlink"),t.setAttribute("part","svg"),t.setAttribute("aria-hidden","true"),t.setAttribute("focusable","false"),t)}function er(r){let e=we.get(r);return e||(e=(async()=>{try{let t=await fetch(r);return t.ok?yt((await t.text()).trim()):null}catch{return null}})(),we.set(r,e),e.then(t=>t===null&&we.delete(r))),e}function xt(r,e,t){let i=++Jt;bt.set(r,i);let n=s=>{bt.get(r)===i&&r.replaceChildren(...s?[r.ownerDocument.importNode(s,!0)]:[])};if(e==="system"){r.innerHTML=w(t)??"";return}try{let s=t?String(ht(e)?.resolve(t)??"").trim():"";s.startsWith("<")?n(yt(s)):s?er(s).then(n):n(null)}catch{n(null)}}function B(r,e,t){let i,n,s=()=>`${e()}
|
|
124
|
+
${t()}
|
|
125
|
+
${xe(e())}`,a=()=>{let l=r();l&&(i===void 0&&e()==="system"&&(i=s()),s()!==i&&(i=s(),xt(l,e(),t())))};return{draw:a,connected:()=>{n??=ft(a),a()},disconnected:()=>{n?.(),n=void 0}}}var wt=`
|
|
100
126
|
:host { display: inline-block; inline-size: 1em; block-size: 1em; vertical-align: -0.125em; color: inherit; }
|
|
101
127
|
:host(:not(:defined)) { visibility: inherit !important; min-block-size: auto !important; }
|
|
102
128
|
:host([hidden]) { display: none !important; }
|
|
103
129
|
.box, svg { display: block; inline-size: 100%; block-size: 100%; }
|
|
104
130
|
.box { contain: paint; }
|
|
105
|
-
`;var
|
|
131
|
+
`;var _e={tag:"neu-icon",props:{name:{type:"string",reflect:!0},library:{type:"string",default:"system",reflect:!0},label:{type:"string",reflect:!0}},styles:wt,template:r=>{let e=r.library==="system"?w(r.name):void 0;return o`<span class="box" data-ref="box">${e===void 0?"":f(e)}</span>`},docs:{summary:"A vector icon from the built-in set or a registered icon library.",events:[],slots:[],parts:[{name:"svg",description:"The rendered SVG element."}],cssProperties:[]}};var q=class extends p{static def=_e;drawer=B(()=>this.ref("box"),()=>String(this.props.library),()=>String(this.props.name));update(e){if(e.has("label")){let t=String(this.props.label);this.internals.role=t?"img":null,this.internals.ariaLabel=t||null,this.internals.ariaHidden=t?null:"true"}(e.has("name")||e.has("library"))&&this.drawer.draw()}connected(){this.drawer.connected()}disconnected(){this.drawer.disconnected()}};q.define();var kt=`${st}
|
|
106
132
|
:host { inline-size: 2.5rem; block-size: 2.5rem; }
|
|
107
133
|
:host([size='sm']) { inline-size: 2rem; block-size: 2rem; }
|
|
108
134
|
:host([size='lg']) { inline-size: 3rem; block-size: 3rem; }
|
|
@@ -112,7 +138,139 @@ ${q(e())}`,c=()=>{let X=t();X&&(n===void 0&&e()==="system"&&(n=o()),o()!==n&&(n=
|
|
|
112
138
|
:host([size='sm']) .icon { inline-size: 1rem; block-size: 1rem; }
|
|
113
139
|
:host([size='lg']) .icon { inline-size: 1.375rem; block-size: 1.375rem; }
|
|
114
140
|
.icon svg { display: block; inline-size: 100%; block-size: 100%; }
|
|
115
|
-
`;var
|
|
141
|
+
`;var Se={tag:"neu-icon-button",props:{icon:{type:"string"},library:{type:"string",default:"system"},label:{type:"string"},shape:{type:"string",default:"circle",values:["circle","square"],reflect:!0},variant:{type:"string",default:"default",values:["default","primary","flat"],reflect:!0},size:{type:"string",default:"md",values:["sm","md","lg"],reflect:!0},disabled:{type:"boolean",reflect:!0},type:{type:"string",default:"button",values:["button","submit","reset"],reflect:!0}},styles:kt,template:r=>{let e=r.library==="system"?w(r.icon):void 0;return o`<span part="base" class="base"><span part="icon" class="icon" data-ref="icon">${e===void 0?"":f(e)}</span></span>`},docs:{summary:"A raised button that shows an icon instead of a label. Name it with label.",events:[{name:"click",description:"Fired on activation; never while disabled."}],slots:[],parts:[{name:"base",description:"The raised surface."},{name:"icon",description:"Wrapper around the icon."},{name:"svg",description:"The rendered SVG element."}],cssProperties:d}};var K=class extends E{static def=Se;drawer=B(()=>this.ref("icon"),()=>String(this.props.library),()=>String(this.props.icon));update(e){super.update(e),(e.has("label")||e.has("icon"))&&(this.internals.ariaLabel=String(this.props.label||this.props.icon)||null),(e.has("icon")||e.has("library"))&&this.drawer.draw()}connected(){this.drawer.connected()}disconnected(){this.drawer.disconnected()}};K.define();var z=["value","required","disabled","readOnly","minLength","maxLength","errorText","autocomplete"];function _t(r){return(r??"").trim().toLowerCase()==="off"}var k=class extends b{dirty=!1;pendingValue=null;get value(){return this.input?.value??this.pendingValue??this.p.value}set value(e){let t=e==null?"":String(e);this.dirty=!0;let i=this.input;i?i.value=t:this.pendingValue=t,this.commit()}get defaultValue(){return this.p.value}set defaultValue(e){this.setAttribute("value",String(e))}focus(e){let t=this.input;t?t.focus(e):super.focus(e)}select(){this.input?.select()}setSelectionRange(e,t,i){this.input?.setSelectionRange(e,t,i)}get p(){return this.props}get input(){return this.ref("input")}controlKeyDown(e){}needsCommit(e){return this.commitProps.some(t=>e.has(t))}validityProbe(){let e=this.p,t=this.probe(this.value);return t.required=e.required,t.readOnly=e.readOnly,t.disabled=this.isDisabled,e.minLength>=0&&t.setAttribute("minlength",String(e.minLength)),e.maxLength>=0&&t.setAttribute("maxlength",String(e.maxLength)),t}rendered(){let e=this.input;e&&(e.value!==this.probe(this.p.value).value&&(this.dirty=!0),this.pendingValue!==null&&(e.value=this.pendingValue,this.pendingValue=null),e.addEventListener("input",()=>{this.dirty=!0,this.commit()}),e.addEventListener("change",()=>{this.markInteracted(),m(this,"change")}),e.addEventListener("keydown",t=>this.controlKeyDown(t)))}update(e){let t=this.p,i=this.input;i&&(e.has("value")&&(i.defaultValue!==t.value&&(i.defaultValue=t.value),this.dirty||(i.value=t.value)),e.has("placeholder")&&u(i,"placeholder",t.placeholder),e.has("required")&&(i.required=t.required),e.has("disabled")&&(i.disabled=this.isDisabled),e.has("readOnly")&&(i.readOnly=t.readOnly),e.has("minLength")&&u(i,"minlength",t.minLength>=0?String(t.minLength):""),e.has("maxLength")&&u(i,"maxlength",t.maxLength>=0?String(t.maxLength):""),e.has("autocomplete")&&u(i,"autocomplete",t.autocomplete),e.has("enterKeyHint")&&u(i,"enterkeyhint",t.enterKeyHint)),e.has("label")&&h(this.ref("label-text"),t.label),e.has("helpText")&&h(this.ref("help-text"),t.helpText),this.needsCommit(e)&&this.commit()}willUpdate(e){!this.isConnected&&!this.input&&this.needsCommit(e)&&this.commit()}formValue(){return this.value}formState(){let e=this.p.autocomplete?.trim();return _t(e||this.internals.form?.getAttribute("autocomplete"))?null:this.value}validate(){let e=this.input,t=e??this.validityProbe();!t.willValidate||t.validity.valid?this.internals.setValidity({}):this.internals.setValidity(dt(t.validity),t.validationMessage,e??void 0),h(this.ref("error-text"),this.p.errorText||e?.validationMessage||"")}resetToDefault(){this.dirty=!1,this.pendingValue=null;let e=this.input;e&&(e.value=this.p.value)}restoreState(e){this.dirty=!0;let t=this.input;t?t.value=e:this.pendingValue=e}};var tr=new Set(["text","search","url","tel","email","password","date","month","week","time","datetime-local","number"]),M=Symbol.for("neu-ui.blocks-implicit-submit"),rr=r=>r instanceof HTMLInputElement&&tr.has(r.type)||r.constructor[M]===!0;function U(r){if(!r)return;let e=[...r.elements],t=e.find(he);if(t){if(t.matches(":disabled")||t.hasAttribute("disabled"))return;S(r),t.click();return}e.filter(rr).length===1&&(S(r),r.requestSubmit())}var y=r=>r>0?r:1;var _=`${c}
|
|
142
|
+
:host { display: block; }
|
|
143
|
+
:host(:disabled), :host([disabled]) { cursor: not-allowed; }
|
|
144
|
+
.base { display: flex; flex-direction: column; }
|
|
145
|
+
.label-text, ::slotted([slot='label']) {
|
|
146
|
+
display: block; margin-block-end: 0.375rem;
|
|
147
|
+
font-size: 0.8125rem; font-weight: 600; line-height: 1rem; color: var(--_neu-fg-muted);
|
|
148
|
+
}
|
|
149
|
+
.label-text:empty { display: none; }
|
|
150
|
+
.control {
|
|
151
|
+
display: flex; align-items: center; min-block-size: 2.75rem; padding-inline: 0.875rem;
|
|
152
|
+
border-radius: var(--_neu-r); background: var(--_neu-bg); box-shadow: var(--_neu-inset);
|
|
153
|
+
transition: box-shadow var(--_neu-dur) ease;
|
|
154
|
+
}
|
|
155
|
+
:host([size='sm']) .control { min-block-size: 2.25rem; padding-inline: 0.75rem; box-shadow: var(--_neu-inset-sm); }
|
|
156
|
+
:host([size='lg']) .control { min-block-size: 3.25rem; padding-inline: 1rem; }
|
|
157
|
+
:host(:focus-within) .control { box-shadow: var(--_neu-inset), var(--_neu-focus); }
|
|
158
|
+
:host(:state(user-invalid)) .control {
|
|
159
|
+
box-shadow:
|
|
160
|
+
inset var(--_neu-d) var(--_neu-d) calc(var(--_neu-d) * 2) color-mix(in oklab, var(--_neu-danger) 35%, var(--_neu-sd)),
|
|
161
|
+
inset calc(var(--_neu-d) * -1) calc(var(--_neu-d) * -1) calc(var(--_neu-d) * 2) var(--_neu-sl);
|
|
162
|
+
}
|
|
163
|
+
:host(:disabled) .control, :host([disabled]) .control { box-shadow: var(--_neu-inset-sm); opacity: 0.6; }
|
|
164
|
+
.input {
|
|
165
|
+
flex: 1; min-inline-size: 0; align-self: stretch; padding: 0; border: none; outline: none;
|
|
166
|
+
background: transparent; color: inherit; font: inherit; font-size: 0.9375rem;
|
|
167
|
+
}
|
|
168
|
+
.input::placeholder { color: var(--_neu-fg-muted); opacity: 1; }
|
|
169
|
+
.help { font-size: 0.75rem; color: var(--_neu-fg-muted); }
|
|
170
|
+
.help-text, ::slotted([slot='help-text']) { display: block; margin-block-start: 0.375rem; }
|
|
171
|
+
.help-text:empty { display: none; }
|
|
172
|
+
.error-text { display: none; margin-block-start: 0.375rem; color: var(--_neu-danger); }
|
|
173
|
+
:host(:state(user-invalid)) slot[name='help-text'] { display: none; }
|
|
174
|
+
:host(:state(user-invalid)) .error-text:not(:empty) { display: block; }
|
|
175
|
+
`;var St=`${_}
|
|
176
|
+
.input { appearance: textfield; text-align: center; }
|
|
177
|
+
.input::-webkit-inner-spin-button, .input::-webkit-outer-spin-button { appearance: none; margin: 0; }
|
|
178
|
+
.step {
|
|
179
|
+
display: inline-flex; flex: none; align-items: center; justify-content: center;
|
|
180
|
+
inline-size: 1.75rem; block-size: 1.75rem; padding: 0; border: none; border-radius: 50%;
|
|
181
|
+
background: var(--_neu-bg); color: var(--_neu-fg); box-shadow: var(--_neu-raised-sm);
|
|
182
|
+
font: inherit; cursor: pointer;
|
|
183
|
+
transition: box-shadow var(--_neu-dur) ease;
|
|
184
|
+
}
|
|
185
|
+
.step:active:not(:disabled) { box-shadow: var(--_neu-inset-sm); }
|
|
186
|
+
.step:disabled { box-shadow: none; color: var(--_neu-fg-muted); cursor: not-allowed; }
|
|
187
|
+
.step svg { inline-size: 1rem; block-size: 1rem; }
|
|
188
|
+
`;var ir={value:{type:"string"},min:{type:"number",default:Number.NaN},max:{type:"number",default:Number.NaN},step:{type:"number",default:1},name:{type:"string",reflect:!0},label:{type:"string"},placeholder:{type:"string"},helpText:{type:"string"},errorText:{type:"string"},required:{type:"boolean",reflect:!0},disabled:{type:"boolean",reflect:!0},readOnly:{type:"boolean",reflect:!0,attribute:"readonly"},size:{type:"string",default:"md",values:["sm","md","lg"],reflect:!0},incrementLabel:{type:"string",default:"Increase"},decrementLabel:{type:"string",default:"Decrease"}},Te=r=>Number.isFinite(r)&&r>=0;function nr(r){return o`${Te(r.min)?o` inputmode="decimal"`:""}${Number.isFinite(r.min)?o` min="${r.min}"`:""}${Number.isFinite(r.max)?o` max="${r.max}"`:""}${r.placeholder?o` placeholder="${r.placeholder}"`:""}${r.required?o` required`:""}${r.disabled?o` disabled`:""}${r.readOnly?o` readonly`:""}`}var Tt=r=>f(x(r)),Ee={tag:"neu-number-field",props:ir,delegatesFocus:!0,form:{valueProp:"value"},styles:St,template:r=>{let e=r.disabled||r.readOnly?o` disabled`:"";return o`<div part="base" class="base"><label part="label" class="label" for="input"><slot name="label"><span class="label-text" data-ref="label-text">${r.label}</span></slot></label><div part="control" class="control"><button part="decrement" class="step" type="button" tabindex="-1" aria-label="${r.decrementLabel}" data-ref="decrement"${e}>${Tt(A)}</button><input part="input" class="input" id="input" data-ref="input" type="number" value="${r.value}" step="${y(r.step)}" aria-describedby="help"${nr(r)}><button part="increment" class="step" type="button" tabindex="-1" aria-label="${r.incrementLabel}" data-ref="increment"${e}>${Tt(de)}</button></div><div part="help-text" class="help" id="help"><slot name="help-text"><span class="help-text" data-ref="help-text">${r.helpText}</span></slot><span class="error-text" data-ref="error-text">${r.errorText}</span></div></div>`},docs:{summary:"A numeric input with an inset field and stepper buttons. The value attribute is the default value.",events:[{name:"input",description:"Fired on every edit and every step (composed)."},{name:"change",description:"Fired when an edit is committed, or after each step."}],slots:[{name:"label",description:"Rich label; replaces the label attribute."},{name:"help-text",description:"Rich help text; replaces the help-text attribute."}],parts:[{name:"base",description:"Outer wrapper."},{name:"label",description:"The <label> element."},{name:"control",description:"The inset field around the input and buttons."},{name:"input",description:'The native <input type="number">.'},{name:"decrement",description:"The button that lowers the value."},{name:"increment",description:"The button that raises the value."},{name:"help-text",description:"Help or error text area."}],cssProperties:d}};var W=class extends k{static def=Ee;static[M]=!0;static extraProperties=["defaultValue","valueAsNumber"];commitProps=[...z,"min","max","step"];get np(){return this.props}get valueAsNumber(){let e=this.input;return e?e.valueAsNumber:this.probe(this.value).valueAsNumber}set valueAsNumber(e){this.value=Number.isFinite(e)?String(e):""}constrain(e){let t=this.np;u(e,"min",Number.isFinite(t.min)?String(t.min):""),u(e,"max",Number.isFinite(t.max)?String(t.max):""),e.step=String(y(t.step)),u(e,"inputmode",Te(t.min)?"decimal":"")}probe(e){let t=document.createElement("input");return t.type="number",this.constrain(t),t.value=e,t}move(e){let t=this.input;if(!t||t.disabled||t.readOnly)return;let i=t.value;try{e(t)}catch{}t.value!==i&&(t.dispatchEvent(new Event("input",{bubbles:!0,composed:!0})),t.dispatchEvent(new Event("change",{bubbles:!0})))}rendered(){super.rendered();let e=[["decrement",t=>t.stepDown()],["increment",t=>t.stepUp()]];for(let[t,i]of e){let n=this.ref(t);n?.addEventListener("pointerdown",s=>{s.preventDefault(),!n.disabled&&s.pointerType!=="touch"&&this.input?.focus()}),n?.addEventListener("click",()=>this.move(i))}}controlKeyDown(e){if(e.isComposing)return;if(e.key==="Enter"){g(e,()=>{e.defaultPrevented||U(this.internals.form)});return}if(e.ctrlKey||e.metaKey||e.altKey)return;let{min:t,max:i}=this.np,n;e.key==="PageUp"?n=s=>s.stepUp(10):e.key==="PageDown"?n=s=>s.stepDown(10):e.key==="Home"&&Number.isFinite(t)?n=s=>s.value=`${t}`:e.key==="End"&&Number.isFinite(i)&&(n=s=>s.value=`${i}`),n&&(e.preventDefault(),this.move(n))}update(e){let t=this.input;if(t){["min","max","step"].some(s=>e.has(s))&&this.constrain(t);let i=this.isDisabled||this.np.readOnly,n=[["decrement","decrementLabel"],["increment","incrementLabel"]];for(let[s,a]of n){let l=this.ref(s);l&&((e.has("disabled")||e.has("readOnly"))&&(l.disabled=i),e.has(a)&&l.setAttribute("aria-label",this.np[a]))}}super.update(e)}};W.define();var Et=`${c}
|
|
189
|
+
:host { display: none !important; }
|
|
190
|
+
`;var Le={tag:"neu-option",props:{value:{type:"string",reflect:!0},disabled:{type:"boolean",reflect:!0}},styles:Et,template:()=>o`<slot></slot>`,docs:{summary:"One choice of a neu-select. It is data only and never rendered: the select reads its value (the value attribute, or the label when there is none), its text as the label, and disabled.",events:[],slots:[{name:"",description:"The label, as plain text."}],parts:[],cssProperties:[]}};function De(r){return r.replace(/[\t\n\f\r ]+/g," ").replace(/^ | $/g,"")}function j(r){let e=De(r.textContent??"");return{value:r.getAttribute("value")??e,label:e,disabled:r.hasAttribute("disabled")}}var G=class extends p{static def=Le;get value(){return j(this).value}set value(e){this.setAttribute("value",e==null?"":String(e))}get label(){return De(this.textContent??"")}};G.define();var Lt=`${c}
|
|
191
|
+
:host { display: inline-flex; vertical-align: middle; cursor: pointer; user-select: none; }
|
|
192
|
+
:host(:disabled), :host([disabled]) { cursor: not-allowed; }
|
|
193
|
+
:host(:state(checked)) { --_neu-radio-on: 1; }
|
|
194
|
+
.base { display: inline-flex; align-items: center; gap: 0.625rem; }
|
|
195
|
+
.control {
|
|
196
|
+
display: inline-flex; align-items: center; justify-content: center; flex: none;
|
|
197
|
+
inline-size: 1.25rem; block-size: 1.25rem; border-radius: 50%;
|
|
198
|
+
background: var(--_neu-bg); box-shadow: var(--_neu-inset-sm);
|
|
199
|
+
transition: box-shadow var(--_neu-dur) ease;
|
|
200
|
+
}
|
|
201
|
+
.indicator {
|
|
202
|
+
display: block; inline-size: 50%; block-size: 50%; border-radius: 50%;
|
|
203
|
+
background: var(--_neu-accent-c); transform: scale(var(--_neu-radio-on, 0));
|
|
204
|
+
transition: transform var(--_neu-dur) ease;
|
|
205
|
+
}
|
|
206
|
+
:host(:focus-visible) .control { box-shadow: var(--_neu-inset-sm), var(--_neu-focus); }
|
|
207
|
+
:host([disabled]) .base { opacity: 0.55; }
|
|
208
|
+
.label { color: var(--_neu-fg); }
|
|
209
|
+
`;var ze={tag:"neu-radio",props:{value:{type:"string",default:"on",reflect:!0},disabled:{type:"boolean",reflect:!0}},styles:Lt,template:()=>o`<span part="base" class="base"><span part="control" class="control"><span part="indicator" class="indicator"></span></span><span part="label" class="label"><slot></slot></span></span>`,docs:{summary:"One choice inside a neu-radio-group, which owns the value, the keyboard and the form. On its own it does nothing.",events:[],slots:[{name:"",description:"Label; also the accessible name."}],parts:[{name:"base",description:"Wrapper around control and label."},{name:"control",description:"The inset ring."},{name:"indicator",description:"The dot shown when selected."},{name:"label",description:"Wrapper around the default slot."}],cssProperties:d}};var P=Symbol.for("neu-ui.radio.setChecked"),$=Symbol.for("neu-ui.radio.setGroupDisabled"),Y=Symbol.for("neu-ui.radioGroup.resync");var X=class extends p{static def=ze;on=!1;groupOff=!1;constructor(){super(),this.internals.role="radio",this.internals.ariaChecked="false"}get checked(){return this.on}[P](e){this.on=e,this.toggleState("checked",e),this.internals.ariaChecked=e?"true":"false"}[$](e){e!==this.groupOff&&(this.groupOff=e,this.syncDisabledState())}get isDisabled(){return super.isDisabled||this.groupOff}update(e){e.has("disabled")&&this.syncDisabledState()}connected(){this.closest("neu-radio-group")?.[Y]?.()}disconnected(){this[P](!1),this[$](!1)}};X.define();var Dt=`${c}
|
|
210
|
+
:host { display: block; }
|
|
211
|
+
:host(:disabled), :host([disabled]) { cursor: not-allowed; }
|
|
212
|
+
.base { display: flex; flex-direction: column; }
|
|
213
|
+
.label {
|
|
214
|
+
display: block; margin-block-end: 0.5rem;
|
|
215
|
+
font-size: 0.8125rem; font-weight: 600; color: var(--_neu-fg-muted);
|
|
216
|
+
}
|
|
217
|
+
.label:empty { display: none; }
|
|
218
|
+
.items { display: flex; flex-direction: column; align-items: flex-start; gap: 0.75rem; }
|
|
219
|
+
:host([orientation='horizontal']) .items { flex-direction: row; flex-wrap: wrap; align-items: center; }
|
|
220
|
+
:host(:disabled) .items, :host([disabled]) .items { opacity: 0.55; cursor: not-allowed; }
|
|
221
|
+
:host(:state(user-invalid)) .label { color: var(--_neu-danger); }
|
|
222
|
+
`;function sr(r){return r.replace(/[\\"'&<>\r\n\f]/g,e=>`\\${e.charCodeAt(0).toString(16)} `)}function Pe(r){return r===""?"":o`::slotted(neu-radio:not(:defined)[value="${sr(r)}"]){--_neu-radio-on:1}`}var Ce={tag:"neu-radio-group",props:{label:{type:"string"},name:{type:"string",reflect:!0},value:{type:"string"},required:{type:"boolean",reflect:!0},disabled:{type:"boolean",reflect:!0},orientation:{type:"string",default:"vertical",values:["vertical","horizontal"],reflect:!0}},form:{valueProp:"value"},styles:Dt,template:r=>o`<div part="base" class="base"><span part="label" class="label" data-ref="label">${r.label}</span><span class="items"><slot></slot></span><style data-ref="mark">${Pe(r.value)}</style></div>`,docs:{summary:"A group of neu-radio elements with one selected value, arrow-key navigation and form support. The value attribute is the default value.",events:[{name:"input",description:"Fired when the user selects a radio."},{name:"change",description:"Fired after input when the user selects a radio."}],slots:[{name:"",description:"neu-radio elements."}],parts:[{name:"base",description:"Outer wrapper."},{name:"label",description:"The group label."}],cssProperties:d}};var or={ArrowDown:1,ArrowRight:1,ArrowUp:-1,ArrowLeft:-1},zt=r=>r.getAttribute("value")??"on",Z=class extends b{static def=Ce;static extraProperties=["defaultValue"];current;dirty=!1;stop;picked;observer;constructor(){super(),this.current=this.getAttribute("value"),this.internals.role="radiogroup",this.addEventListener("click",e=>{let t=this.radioAt(e);t&&!this.isDisabled&&!t.hasAttribute("disabled")&&this.choose(t)}),this.addEventListener("keydown",e=>this.onKey(e))}get value(){return this.selected()?this.current:""}set value(e){this.dirty=!0,this.current=e==null?null:String(e),this.sync()}get defaultValue(){return String(this.props.value)}set defaultValue(e){this.setAttribute("value",String(e))}radios(){return[...this.querySelectorAll("neu-radio")].filter(e=>e.closest("neu-radio-group")===this)}selected(e=this.radios()){return this.current===null?void 0:e.find(t=>zt(t)===this.current)}radioAt(e){let t=e.target instanceof Element?e.target.closest("neu-radio"):null;return t&&t.closest("neu-radio-group")===this?t:null}onKey(e){if(e.defaultPrevented||e.altKey||e.ctrlKey||e.metaKey)return;let t=this.radioAt(e);if(!t||this.isDisabled||t.hasAttribute("disabled"))return;if(e.key===" "){e.preventDefault(),this.choose(t);return}let i=or[e.key];if(!i)return;(e.key==="ArrowLeft"||e.key==="ArrowRight")&&this.matches(":dir(rtl)")&&(i=-i);let n=this.radios().filter(a=>!a.hasAttribute("disabled")),s=n[(n.indexOf(t)+i+n.length)%n.length];s&&(e.preventDefault(),s.focus(),this.choose(s))}choose(e){let t=zt(e);t===this.current&&this.selected()||(this.dirty=!0,this.current=t,this.sync(),this.markInteracted(),m(this,"input"),m(this,"change"))}[Y](){this.sync()}sync(){let e=this.radios(),t=this.picked=this.selected(e),i=this.isDisabled,n=e.filter(l=>P in l);for(let l of n)l[$](i),l[P](l===t);let s=i?[]:n.filter(l=>!l.disabled);this.stop=s.find(l=>l===t)??s[0];for(let l of s){let v=l===this.stop?"0":"-1";l.getAttribute("tabindex")!==v&&l.setAttribute("tabindex",v)}let a=Pe(this.current??"");h(this.ref("mark"),a===""?"":a.value),this.commit()}willUpdate(e){e.has("value")&&!this.dirty&&(this.current=this.getAttribute("value"))}update(e){e.has("label")&&(h(this.ref("label"),String(this.props.label)),this.internals.ariaLabel=String(this.props.label)||null),e.has("required")&&(this.internals.ariaRequired=this.props.required?"true":null),e.has("disabled")&&(this.internals.ariaDisabled=this.isDisabled?"true":null),(e.has("value")||e.has("required")||e.has("disabled"))&&this.sync()}connected(){this.observer??=new MutationObserver(()=>this.sync()),this.observer.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["disabled","value"]}),this.sync()}disconnected(){this.observer?.disconnect()}formValue(){return this.picked?this.current:null}formState(){return this.formValue()}validate(){this.props.required===!0&&!this.picked?this.internals.setValidity({valueMissing:!0},L("radio","Please select one of these options."),this.stop):this.internals.setValidity({})}resetToDefault(){this.dirty=!1,this.current=this.getAttribute("value"),this.sync()}restoreState(e){this.dirty=!0,this.current=e,this.sync()}};Z.define();var Pt=`${_}
|
|
223
|
+
.label {
|
|
224
|
+
display: block; margin-block-end: 0.375rem;
|
|
225
|
+
font-size: 0.8125rem; font-weight: 600; line-height: 1rem; color: var(--_neu-fg-muted);
|
|
226
|
+
}
|
|
227
|
+
.label:empty { display: none; }
|
|
228
|
+
.combobox {
|
|
229
|
+
display: flex; align-items: center; gap: 0.5rem; min-block-size: 2.75rem; padding-inline: 0.875rem 0.75rem;
|
|
230
|
+
border-radius: var(--_neu-r); background: var(--_neu-bg); box-shadow: var(--_neu-raised-sm);
|
|
231
|
+
font-size: 0.9375rem; cursor: pointer; user-select: none; outline: none;
|
|
232
|
+
transition: box-shadow var(--_neu-dur) ease;
|
|
233
|
+
}
|
|
234
|
+
:host([size='sm']) .combobox { min-block-size: 2.25rem; padding-inline: 0.75rem 0.625rem; font-size: 0.875rem; }
|
|
235
|
+
:host([size='lg']) .combobox { min-block-size: 3.25rem; padding-inline: 1rem 0.875rem; font-size: 1rem; }
|
|
236
|
+
.combobox[aria-expanded='true'] { box-shadow: var(--_neu-inset-sm); }
|
|
237
|
+
.combobox:focus-visible { box-shadow: var(--_neu-raised-sm), var(--_neu-focus); }
|
|
238
|
+
.combobox[aria-expanded='true']:focus-visible { box-shadow: var(--_neu-inset-sm), var(--_neu-focus); }
|
|
239
|
+
:host(:state(user-invalid)) .combobox {
|
|
240
|
+
box-shadow:
|
|
241
|
+
calc(var(--_neu-d) * 0.5) calc(var(--_neu-d) * 0.5) var(--_neu-d) color-mix(in oklab, var(--_neu-danger) 45%, var(--_neu-sd)),
|
|
242
|
+
calc(var(--_neu-d) * -0.5) calc(var(--_neu-d) * -0.5) var(--_neu-d) var(--_neu-sl);
|
|
243
|
+
}
|
|
244
|
+
:host(:disabled) .combobox, :host([disabled]) .combobox { opacity: 0.6; cursor: not-allowed; }
|
|
245
|
+
.display { flex: 1; min-inline-size: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
|
|
246
|
+
.placeholder { color: var(--_neu-fg-muted); }
|
|
247
|
+
.chevron { display: inline-flex; flex: none; color: var(--_neu-fg-muted); transition: transform var(--_neu-dur) ease; }
|
|
248
|
+
.chevron svg { inline-size: 1rem; block-size: 1rem; }
|
|
249
|
+
.combobox[aria-expanded='true'] .chevron { transform: rotate(180deg); }
|
|
250
|
+
.listbox {
|
|
251
|
+
position: fixed; inset: auto; margin: 0; max-block-size: 16rem; overflow: auto;
|
|
252
|
+
padding: 0.375rem; border: none; border-radius: var(--_neu-r);
|
|
253
|
+
background: var(--_neu-bg); color: var(--_neu-fg); box-shadow: var(--_neu-raised); font-size: 0.9375rem;
|
|
254
|
+
}
|
|
255
|
+
.option { padding: 0.5rem 0.625rem; border-radius: calc(var(--_neu-r) * 0.75); cursor: pointer; user-select: none; }
|
|
256
|
+
.option.active { box-shadow: var(--_neu-inset-sm); }
|
|
257
|
+
.option[aria-selected='true'] { color: var(--_neu-accent-c); font-weight: 600; }
|
|
258
|
+
.option[aria-disabled='true'] { color: var(--_neu-fg-muted); cursor: not-allowed; }
|
|
259
|
+
`;function T(r,e){return r?.find(t=>t.value===e)}var ar=f(x(le)),Ae={tag:"neu-select",props:{value:{type:"string"},name:{type:"string",reflect:!0},label:{type:"string"},placeholder:{type:"string"},helpText:{type:"string"},errorText:{type:"string"},required:{type:"boolean",reflect:!0},disabled:{type:"boolean",reflect:!0},size:{type:"string",default:"md",values:["sm","md","lg"],reflect:!0}},delegatesFocus:!0,form:{valueProp:"value"},optionsFrom:"neu-option",styles:Pt,template:(r,e)=>{let t=T(e?.options,r.value),i=!t&&r.value!==""&&e?.options?.length===0;return o`<div part="base" class="base"><span part="label" class="label" id="label" data-ref="label">${r.label}</span><div part="combobox" class="combobox" id="combobox" role="combobox"${r.disabled?o` aria-disabled="true"`:o` tabindex="0"`} aria-haspopup="listbox" aria-expanded="false" aria-controls="listbox" aria-labelledby="label" aria-describedby="help"${r.required?o` aria-required="true"`:""} data-ref="combobox"><span part="display" class="display${t||i?"":" placeholder"}" data-ref="display">${t?t.label:i?"":r.placeholder}</span><span part="chevron" class="chevron">${ar}</span></div><div part="listbox" class="listbox" id="listbox" role="listbox" aria-labelledby="label" popover="auto" data-ref="listbox"></div><div part="help-text" class="help" id="help"><slot name="help-text"><span class="help-text" data-ref="help-text">${r.helpText}</span></slot><span class="error-text" data-ref="error-text">${r.errorText}</span></div></div>`},docs:{summary:"A single-value select (the APG select-only combobox): a raised trigger and a popover listbox built from the neu-option children, which are data only. The value attribute is the default value.",events:[{name:"input",description:"Fired when the user chooses an option with a new value."},{name:"change",description:"Fired after input when the user chooses a new value."},{name:"neu-open",description:"Fired when the listbox opens."},{name:"neu-close",description:"Fired when the listbox closes."}],slots:[{name:"help-text",description:"Rich help text; replaces the help-text attribute."}],parts:[{name:"base",description:"Outer wrapper."},{name:"label",description:"The label text."},{name:"combobox",description:"The raised trigger that holds focus."},{name:"display",description:"The selected label, or the placeholder."},{name:"chevron",description:"The chevron icon."},{name:"listbox",description:"The popover list of options."},{name:"option",description:"One option in the listbox."},{name:"help-text",description:"Help or error text area."}],cssProperties:d}};var J=4,lr=500,Q=class extends b{static def=Ae;static extraProperties=["defaultValue"];current;dirty=!1;opts=[];observer;opened=!1;activeSource;pressedOpen;typed="";typedTimer;constructor(){super(),this.current=String(this.props.value)}get value(){return T(this.read(),this.current)?this.current:""}set value(e){this.dirty=!0,this.current=e==null?"":String(e),this.sync()}get defaultValue(){return String(this.props.value)}set defaultValue(e){this.setAttribute("value",String(e))}read(){return[...this.querySelectorAll("neu-option")].map(e=>({...j(e),source:e}))}chosen(){return T(this.opts,this.current)?this.current:""}sync(){this.opts=this.read();let e=T(this.opts,this.current),t=this.ref("display");h(t,e?e.label:String(this.props.placeholder)),t?.classList.toggle("placeholder",!e),this.opened&&this.render(),this.commit()}step(e,t){for(let i=e;i>=0&&i<this.opts.length;i+=t)if(!this.opts[i].disabled)return i;return-1}near(e,t){let i=Math.min(Math.max(e,0),this.opts.length-1),n=this.step(i,t);return n<0?this.step(i,-t):n}activeIndex(){return this.opts.findIndex(e=>e.source===this.activeSource)}render(){let e=this.ref("listbox"),t=T(this.opts,this.current);e.replaceChildren(...this.opts.map((s,a)=>{let l=document.createElement("div");return l.className="option",l.id=`option-${a}`,l.setAttribute("part","option"),l.setAttribute("role","option"),l.setAttribute("aria-selected",String(s===t)),s.disabled&&l.setAttribute("aria-disabled","true"),l.textContent=s.label,l})),this.place();let i=this.activeIndex(),n=t?this.opts.indexOf(t):-1;this.activate(i>=0&&!this.opts[i].disabled?i:n>=0?n:this.step(0,1))}activate(e){let t=this.ref("listbox");this.activeSource=this.opts[e]?.source;let i=[...t.children];i.forEach((l,v)=>l.classList.toggle("active",v===e));let n=i[e];if(u(this.ref("combobox"),"aria-activedescendant",n?n.id:""),!n)return;let s=i[0].offsetTop,a=n.offsetTop+n.offsetHeight+s;n.offsetTop-s<t.scrollTop?t.scrollTop=n.offsetTop-s:a>t.scrollTop+t.clientHeight&&(t.scrollTop=a-t.clientHeight)}place=()=>{let e=this.ref("listbox"),t=this.ref("combobox")?.getBoundingClientRect();if(!e||!t)return;e.style.left=`${t.left}px`,e.style.width=`${t.width}px`;let i=e.offsetHeight,n=innerHeight-t.bottom-J,s=t.top-J,a=i>n&&s>n;e.style.top=`${a?t.top-J-i:t.bottom+J}px`};open(){let e=this.ref("listbox");this.opened||this.isDisabled||!e||(this.opened=!0,this.activeSource=void 0,e.matches(":popover-open")||e.showPopover(),this.render(),this.ref("combobox").setAttribute("aria-expanded","true"),window.addEventListener("scroll",this.place,{capture:!0,passive:!0}),window.addEventListener("resize",this.place,{passive:!0}),this.ownerDocument.addEventListener("focusin",this.focusLanded,!0),m(this,"neu-open"))}focusLanded=()=>{this.shadowRoot.activeElement||this.close()};close(){if(!this.opened)return;this.opened=!1;let e=this.ref("listbox");e.matches(":popover-open")&&e.hidePopover();let t=this.ref("combobox");t.setAttribute("aria-expanded","false"),t.removeAttribute("aria-activedescendant"),window.removeEventListener("scroll",this.place,{capture:!0}),window.removeEventListener("resize",this.place),this.ownerDocument.removeEventListener("focusin",this.focusLanded,!0),m(this,"neu-close")}choose(e){let t=this.opts[e];if(!t||t.disabled)return;let i=this.chosen();this.dirty=!0,this.current=t.value,this.sync(),t.value!==i&&(this.markInteracted(),m(this,"input"),m(this,"change"))}typeahead(e){clearTimeout(this.typedTimer),this.typedTimer=setTimeout(()=>this.typed="",lr);let t=this.typed+=e.toLowerCase(),i=this.activeIndex(),n=this.opts.length,s=(l,v)=>{for(let oe=0;oe<n;oe++){let qe=(v+oe)%n,Ke=this.opts[qe];if(!Ke.disabled&&Ke.label.toLowerCase().startsWith(l))return qe}return-1},a=[...t].every(l=>l===t[0])?s(t[0],i+1):s(t,Math.max(i,0));a>=0&&this.activate(a)}onKey(e){if(this.isDisabled||e.ctrlKey||e.metaKey)return;let{key:t,altKey:i}=e,n=t.length===1&&t!==" "&&!i,s=this.activeIndex(),a=this.opts.length-1,l={ArrowDown:[s+1,1],ArrowUp:[s-1,-1],Home:[0,1],End:[a,-1],PageDown:[s+10,1],PageUp:[s-10,-1]};if(!this.opened){if(!n&&!["ArrowDown","ArrowUp","Enter"," ","Home","End"].includes(t))return;e.preventDefault(),this.open(),t==="Home"||t==="End"?this.activate(this.near(...l[t])):n&&this.typeahead(t);return}if(t==="Tab"){this.choose(s),this.close();return}if(t==="Enter"||t===" "||t==="ArrowUp"&&i)this.choose(s),this.close();else if(t==="Escape")this.close();else if(n)this.typeahead(t);else if(l[t])this.activate(this.near(...l[t]));else return;e.preventDefault()}optionAt(e){let t=e.target.closest(".option");return t?Number(t.id.slice(7)):-1}rendered(){let e=this.ref("combobox"),t=this.ref("listbox");e.addEventListener("keydown",i=>this.onKey(i)),e.addEventListener("pointerdown",()=>this.pressedOpen=this.opened),e.addEventListener("click",()=>{let i=this.pressedOpen??this.opened;this.pressedOpen=void 0,i?this.close():this.open()}),this.ref("label").addEventListener("click",()=>e.focus()),t.addEventListener("pointerdown",i=>i.preventDefault()),t.addEventListener("pointermove",i=>{let n=this.optionAt(i);n>=0&&n!==this.activeIndex()&&!this.opts[n]?.disabled&&this.activate(n)}),t.addEventListener("click",i=>{let n=this.optionAt(i);n<0||this.opts[n]?.disabled||(this.choose(n),this.close())}),t.addEventListener("toggle",()=>{t.matches(":popover-open")||this.close()}),e.addEventListener("focusout",i=>{let n=i.relatedTarget;(n?!this.shadowRoot.contains(n):document.hasFocus())&&this.close()})}willUpdate(e){e.has("value")&&!this.dirty&&(this.current=String(this.props.value))}update(e){let t=this.ref("combobox");if(e.has("label")&&h(this.ref("label"),String(this.props.label)),e.has("helpText")&&h(this.ref("help-text"),String(this.props.helpText)),e.has("required")&&u(t,"aria-required",this.props.required?"true":""),e.has("disabled")){let i=this.isDisabled;u(t,"aria-disabled",i?"true":""),u(t,"tabindex",i?"":"0"),i&&this.close()}e.has("value")||e.has("placeholder")?this.sync():(e.has("required")||e.has("errorText"))&&this.commit()}connected(){this.observer??=new MutationObserver(()=>this.sync()),this.observer.observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["value","disabled"]}),this.sync()}disconnected(){this.observer?.disconnect(),this.close()}formValue(){return T(this.opts,this.current)?this.current:null}validate(){this.props.required===!0&&this.chosen()===""?this.internals.setValidity({valueMissing:!0},L("select","Please select an item in the list."),this.ref("combobox")??void 0):this.internals.setValidity({}),h(this.ref("error-text"),String(this.props.errorText)||this.internals.validationMessage)}resetToDefault(){this.dirty=!1,this.current=String(this.props.value),this.sync()}restoreState(e){this.dirty=!0,this.current=e,this.sync()}};Q.define();var Ct=`${c}
|
|
260
|
+
:host { display: block; min-block-size: 1.25rem; touch-action: pan-y; cursor: pointer; user-select: none; }
|
|
261
|
+
:host(:disabled), :host([disabled]) { cursor: not-allowed; }
|
|
262
|
+
.base { position: relative; display: flex; align-items: center; block-size: 1.25rem; padding-inline: 0.625rem; }
|
|
263
|
+
.track { position: relative; flex: 1; block-size: 0.5rem; border-radius: 999px; background: var(--_neu-bg); box-shadow: var(--_neu-inset-sm); }
|
|
264
|
+
.fill { position: absolute; inset-block: 0; inset-inline-start: 0; inline-size: calc(var(--_neu-pos) * 100%); border-radius: inherit; background: var(--_neu-accent-soft); }
|
|
265
|
+
.thumb {
|
|
266
|
+
position: absolute; inset-block-start: 50%; inset-inline-start: calc(var(--_neu-pos) * 100%);
|
|
267
|
+
inline-size: 1.25rem; block-size: 1.25rem; margin-block-start: -0.625rem; margin-inline-start: -0.625rem;
|
|
268
|
+
border-radius: 50%; background: var(--_neu-bg); box-shadow: var(--_neu-raised-sm);
|
|
269
|
+
transition: box-shadow var(--_neu-dur) ease;
|
|
270
|
+
}
|
|
271
|
+
:host(:focus-visible) .thumb { box-shadow: var(--_neu-raised-sm), var(--_neu-focus); }
|
|
272
|
+
:host(:disabled) .base, :host([disabled]) .base { opacity: 0.55; }
|
|
273
|
+
`;function Me(r){let[,e="",t="0"]=/(?:\.(\d+))?(?:e([+-]\d+))?$/.exec(String(r))??[];return Math.min(100,Math.max(0,e.length-Number(t)))}function $e(r,e,t,i){let n=Math.max(e,t),s=y(i),a=Number.isNaN(r)?e+(n-e)/2:r,l=Math.round((a-e)/s);e+l*s>n&&(l=Math.floor((n-e)/s+1e-9));let v=e+Math.max(0,l)*s;return Number(Math.min(v,n).toFixed(Math.max(Me(s),Me(e))))}function At(r,e,t){let i=y(t),n=Math.round((Math.max(r,e)-r)/10/i)*i;return Number(Math.max(i,n).toFixed(Me(i)))}function Ie(r,e,t){let i=Math.max(e,t)-e;return`--_neu-pos:${i>0?Math.round((r-e)/i*1e4)/1e4:0}`}var Re={tag:"neu-slider",props:{value:{type:"number",default:Number.NaN},min:{type:"number",default:0},max:{type:"number",default:100},step:{type:"number",default:1},name:{type:"string",reflect:!0},label:{type:"string"},disabled:{type:"boolean",reflect:!0}},form:{valueProp:"value"},properties:{valueFormatter:"(value: number) => string"},styles:Ct,template:r=>o`<span part="base" class="base" data-ref="base" style="${Ie($e(r.value,r.min,r.max,r.step),r.min,r.max)}"><span part="track" class="track" data-ref="track"><span part="fill" class="fill"></span><span part="thumb" class="thumb"></span></span></span>`,docs:{summary:"A horizontal slider for a number. The value attribute is the default; the value property is the current value. The valueFormatter property turns the value into the text a screen reader announces.",events:[{name:"input",description:"Fired on every change while the user drags or presses a key."},{name:"change",description:"Fired after the user commits a change: on release, or per key."}],slots:[],parts:[{name:"base",description:"Wrapper around the track."},{name:"track",description:"The inset groove."},{name:"fill",description:"The part of the track up to the thumb."},{name:"thumb",description:"The raised handle."}],cssProperties:d}};var ee=class extends b{static def=Re;static extraProperties=["defaultValue","valueFormatter"];current;dirty=!1;dragging=!1;startValue=0;formatter;constructor(){super(),this.internals.role="slider",this.internals.ariaOrientation="horizontal",this.current=this.snap(this.props.value),this.addEventListener("keydown",e=>this.onKey(e)),this.addEventListener("pointerdown",e=>this.onDown(e)),this.addEventListener("pointermove",e=>this.onMove(e)),this.addEventListener("pointerup",()=>this.endDrag()),this.addEventListener("pointercancel",()=>this.endDrag()),this.addEventListener("lostpointercapture",()=>this.endDrag())}disconnected(){super.disconnected(),this.dragging=!1}get value(){return this.current}set value(e){this.dirty=!0,this.setCurrent(this.snap(Number(e)))}get defaultValue(){return this.snap(this.props.value)}set defaultValue(e){this.setAttribute("value",String(e))}get valueFormatter(){return this.formatter}set valueFormatter(e){this.formatter=typeof e=="function"?e:void 0,this.sync()}snap(e){return $e(e,this.props.min,this.props.max,this.props.step)}sync(){let{min:e,max:t}=this.props,i=this.internals;i.ariaLabel=this.props.label===""?null:String(this.props.label),i.ariaValueMin=String(e),i.ariaValueMax=String(Math.max(e,t)),i.ariaValueNow=String(this.current),i.ariaValueText=this.formatter?this.formatter(this.current):null;let n=this.ref("base"),s=Ie(this.current,e,t);n&&n.getAttribute("style")!==s&&n.setAttribute("style",s)}setCurrent(e){this.current=e,this.sync(),this.commit()}userSet(e){return e===this.current?!1:(this.markInteracted(),this.setCurrent(e),m(this,"input"),!0)}onKey(e){if(this.isDisabled||e.altKey||e.ctrlKey||e.metaKey)return;let{min:t,max:i}=this.props,n=y(this.props.step),s=this.matches(":dir(rtl)")?-1:1,a=At(t,i,n),v={ArrowRight:this.current+n*s,ArrowLeft:this.current-n*s,ArrowUp:this.current+n,ArrowDown:this.current-n,PageUp:this.current+a,PageDown:this.current-a,Home:Number.NEGATIVE_INFINITY,End:Number.POSITIVE_INFINITY}[e.key];v!==void 0&&(e.preventDefault(),this.userSet(this.snap(v))&&m(this,"change"))}onDown(e){if(!(this.isDisabled||e.button!==0)){this.dragging=!0,this.startValue=this.current,this.focus();try{this.setPointerCapture(e.pointerId)}catch{}this.moveTo(e)}}onMove(e){this.dragging&&this.moveTo(e)}moveTo(e){let t=this.ref("track");if(!t)return;let i=t.getBoundingClientRect(),n=i.width>0?(e.clientX-i.left)/i.width:0;this.matches(":dir(rtl)")&&(n=1-n);let{min:s,max:a}=this.props,l=Math.min(1,Math.max(0,n));this.userSet(this.snap(s+l*(Math.max(s,a)-s)))}endDrag(){this.dragging&&(this.dragging=!1,this.current!==this.startValue&&m(this,"change"))}willUpdate(e){(e.has("value")||e.has("min")||e.has("max")||e.has("step"))&&(this.current=this.snap(this.dirty?this.current:this.props.value))}update(e){e.has("disabled")&&this.syncDisabledState(),this.sync(),this.commit()}formValue(){return String(this.current)}validate(){this.internals.setValidity({})}resetToDefault(){this.dirty=!1,this.setCurrent(this.snap(this.props.value))}restoreState(e){this.dirty=!0,this.setCurrent(this.snap(Number(e)))}};ee.define();var Mt=`${c}
|
|
116
274
|
:host { display: inline-block; vertical-align: middle; inline-size: 1.5rem; block-size: 1.5rem; }
|
|
117
275
|
:host([size='sm']) { inline-size: 1rem; block-size: 1rem; }
|
|
118
276
|
:host([size='lg']) { inline-size: 2.25rem; block-size: 2.25rem; }
|
|
@@ -123,7 +281,7 @@ ${q(e())}`,c=()=>{let X=t();X&&(n===void 0&&e()==="system"&&(n=o()),o()!==n&&(n=
|
|
|
123
281
|
.indicator { border: 3px solid transparent; border-block-start-color: var(--_neu-accent-c); animation: neu-spinner-rotate 0.9s linear infinite; }
|
|
124
282
|
@keyframes neu-spinner-rotate { to { transform: rotate(360deg); } }
|
|
125
283
|
@media (prefers-reduced-motion: reduce) { .indicator { animation-duration: 2.7s; } }
|
|
126
|
-
`;var
|
|
284
|
+
`;var Oe={tag:"neu-spinner",props:{label:{type:"string",default:"Loading"},size:{type:"string",default:"md",values:["sm","md","lg"],reflect:!0}},styles:Mt,template:r=>o`<span part="base" class="base"><span part="track" class="track"></span><span part="indicator" class="indicator"></span><span class="label" data-ref="label">${r.label}</span></span>`,docs:{summary:"A rotating indicator for work in progress.",events:[],slots:[],parts:[{name:"base",description:"The sized wrapper."},{name:"track",description:"The inset ring behind the indicator."},{name:"indicator",description:"The rotating arc."}],cssProperties:d}};var te=class extends p{static def=Oe;constructor(){super(),this.internals.role="status"}update(e){if(!e.has("label"))return;let t=String(this.props.label);this.internals.ariaLabel=t||null,h(this.ref("label"),t)}};te.define();var $t=`${c}
|
|
127
285
|
:host { display: block; --_neu-raised-lg: calc(var(--_neu-d) * 2) calc(var(--_neu-d) * 2) calc(var(--_neu-d) * 4) var(--_neu-sd), calc(var(--_neu-d) * -2) calc(var(--_neu-d) * -2) calc(var(--_neu-d) * 4) var(--_neu-sl); --_neu-inset-lg: inset calc(var(--_neu-d) * 2) calc(var(--_neu-d) * 2) calc(var(--_neu-d) * 4) var(--_neu-sd), inset calc(var(--_neu-d) * -2) calc(var(--_neu-d) * -2) calc(var(--_neu-d) * 4) var(--_neu-sl); --_neu-up: var(--_neu-raised); --_neu-down: var(--_neu-inset); --_neu-hi: color-mix(in oklab, var(--_neu-bg), white 8%); --_neu-lo: color-mix(in oklab, var(--_neu-bg), black 6%); }
|
|
128
286
|
:host([elevation='sm']) { --_neu-up: var(--_neu-raised-sm); --_neu-down: var(--_neu-inset-sm); }
|
|
129
287
|
:host([elevation='lg']) { --_neu-up: var(--_neu-raised-lg); --_neu-down: var(--_neu-inset-lg); }
|
|
@@ -138,7 +296,7 @@ ${q(e())}`,c=()=>{let X=t();X&&(n===void 0&&e()==="system"&&(n=o()),o()!==n&&(n=
|
|
|
138
296
|
:host([padding='none']) .base { padding: 0; }
|
|
139
297
|
:host([padding='sm']) .base { padding: 0.75rem; }
|
|
140
298
|
:host([padding='lg']) .base { padding: 2rem; }
|
|
141
|
-
`;var
|
|
299
|
+
`;var Fe={tag:"neu-surface",props:{shape:{type:"string",default:"raised",values:["raised","inset","flat","convex","concave"],reflect:!0},elevation:{type:"string",default:"md",values:["sm","md","lg"],reflect:!0},radius:{type:"string",default:"md",values:["sm","md","lg","full"],reflect:!0},padding:{type:"string",default:"md",values:["none","sm","md","lg"],reflect:!0}},styles:$t,template:()=>o`<div part="base" class="base"><slot></slot></div>`,docs:{summary:"A neumorphic container with its own shape, elevation, radius and padding.",events:[],slots:[{name:"",description:"The content of the surface."}],parts:[{name:"base",description:"The surface itself."}],cssProperties:d}};var re=class extends p{static def=Fe};re.define();var It=`${c}
|
|
142
300
|
:host {
|
|
143
301
|
display: inline-flex; vertical-align: middle; cursor: pointer; user-select: none;
|
|
144
302
|
--_neu-track-w: 2.875rem; --_neu-track-h: 1.625rem; --_neu-thumb: 1.25rem;
|
|
@@ -165,41 +323,16 @@ ${q(e())}`,c=()=>{let X=t();X&&(n===void 0&&e()==="system"&&(n=o()),o()!==n&&(n=
|
|
|
165
323
|
:host(:disabled) .base, :host([disabled]) .base { opacity: 0.55; }
|
|
166
324
|
:host(:state(user-invalid)) .track { box-shadow: var(--_neu-inset-sm), 0 0 0 2px color-mix(in oklab, var(--_neu-danger) 55%, transparent); }
|
|
167
325
|
.label { color: var(--_neu-fg); }
|
|
168
|
-
`;var
|
|
169
|
-
:host { display: block; }
|
|
170
|
-
:host(:disabled), :host([disabled]) { cursor: not-allowed; }
|
|
171
|
-
.base { display: flex; flex-direction: column; }
|
|
172
|
-
.label-text, ::slotted([slot='label']) {
|
|
173
|
-
display: block; margin-block-end: 0.375rem;
|
|
174
|
-
font-size: 0.8125rem; font-weight: 600; color: var(--_neu-fg-muted);
|
|
175
|
-
}
|
|
176
|
-
.label-text:empty { display: none; }
|
|
177
|
-
.control {
|
|
178
|
-
display: flex; align-items: center; min-block-size: 2.75rem; padding-inline: 0.875rem;
|
|
179
|
-
border-radius: var(--_neu-r); background: var(--_neu-bg); box-shadow: var(--_neu-inset);
|
|
180
|
-
transition: box-shadow var(--_neu-dur) ease;
|
|
181
|
-
}
|
|
182
|
-
:host([size='sm']) .control { min-block-size: 2.25rem; padding-inline: 0.75rem; box-shadow: var(--_neu-inset-sm); }
|
|
183
|
-
:host([size='lg']) .control { min-block-size: 3.25rem; padding-inline: 1rem; }
|
|
184
|
-
:host(:focus-within) .control { box-shadow: var(--_neu-inset), var(--_neu-focus); }
|
|
185
|
-
:host(:state(user-invalid)) .control {
|
|
186
|
-
box-shadow:
|
|
187
|
-
inset var(--_neu-d) var(--_neu-d) calc(var(--_neu-d) * 2) color-mix(in oklab, var(--_neu-danger) 35%, var(--_neu-sd)),
|
|
188
|
-
inset calc(var(--_neu-d) * -1) calc(var(--_neu-d) * -1) calc(var(--_neu-d) * 2) var(--_neu-sl);
|
|
189
|
-
}
|
|
190
|
-
:host(:disabled) .control, :host([disabled]) .control { box-shadow: var(--_neu-inset-sm); opacity: 0.6; }
|
|
191
|
-
.input {
|
|
192
|
-
flex: 1; min-inline-size: 0; align-self: stretch; padding: 0; border: none; outline: none;
|
|
193
|
-
background: transparent; color: inherit; font: inherit; font-size: 0.9375rem;
|
|
194
|
-
}
|
|
195
|
-
.input::placeholder { color: var(--_neu-fg-muted); opacity: 1; }
|
|
326
|
+
`;var He={tag:"neu-switch",props:{checked:{type:"boolean"},name:{type:"string",reflect:!0},value:{type:"string",default:"on",reflect:!0},disabled:{type:"boolean",reflect:!0},required:{type:"boolean",reflect:!0},size:{type:"string",default:"md",values:["sm","md","lg"],reflect:!0}},form:{valueProp:"checked"},styles:It,template:r=>o`<span part="base" class="base"><span part="track" class="track${r.checked?" on":""}" data-ref="track"><span part="thumb" class="thumb"></span></span><span part="label" class="label"><slot></slot></span></span>`,docs:{summary:"An on/off switch. The checked attribute is the default state.",events:[{name:"input",description:"Fired when the user toggles the switch."},{name:"change",description:"Fired after input when the user toggles the switch."}],slots:[{name:"",description:"Label; also the accessible name."}],parts:[{name:"base",description:"Wrapper around track and label."},{name:"track",description:"The inset track."},{name:"thumb",description:"The raised thumb."},{name:"label",description:"Wrapper around the default slot."}],cssProperties:d}};var ie=class extends D{static def=He;anchor="track";constructor(){super(),this.internals.role="switch"}paint(){this.ref("track")?.classList.toggle("on",this.checked)}};ie.define();var Rt=`${_}
|
|
196
327
|
.prefix, .suffix { display: inline-flex; }
|
|
197
328
|
::slotted([slot='prefix']) { margin-inline-end: 0.5rem; }
|
|
198
329
|
::slotted([slot='suffix']) { margin-inline-start: 0.5rem; }
|
|
199
|
-
.help {
|
|
200
|
-
.
|
|
201
|
-
.
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
:host(
|
|
205
|
-
|
|
330
|
+
`;var dr={type:{type:"string",default:"text",values:["text","email","password","search","tel","url"],reflect:!0},value:{type:"string"},name:{type:"string",reflect:!0},label:{type:"string"},placeholder:{type:"string"},helpText:{type:"string"},errorText:{type:"string"},required:{type:"boolean",reflect:!0},disabled:{type:"boolean",reflect:!0},readOnly:{type:"boolean",reflect:!0,attribute:"readonly"},minLength:{type:"number",default:-1,attribute:"minlength"},maxLength:{type:"number",default:-1,attribute:"maxlength"},pattern:{type:"string"},autocomplete:{type:"string"},inputMode:{type:"string",attribute:"inputmode"},enterKeyHint:{type:"string",attribute:"enterkeyhint"},size:{type:"string",default:"md",values:["sm","md","lg"],reflect:!0}};function cr(r){return o`${r.placeholder?o` placeholder="${r.placeholder}"`:""}${r.required?o` required`:""}${r.disabled?o` disabled`:""}${r.readOnly?o` readonly`:""}${r.minLength>=0?o` minlength="${r.minLength}"`:""}${r.maxLength>=0?o` maxlength="${r.maxLength}"`:""}${r.pattern?o` pattern="${r.pattern}"`:""}${r.autocomplete?o` autocomplete="${r.autocomplete}"`:""}${r.inputMode?o` inputmode="${r.inputMode}"`:""}${r.enterKeyHint?o` enterkeyhint="${r.enterKeyHint}"`:""}`}var Ve={tag:"neu-text-field",props:dr,delegatesFocus:!0,form:{valueProp:"value"},styles:Rt,template:r=>o`<div part="base" class="base"><label part="label" class="label" for="input"><slot name="label"><span class="label-text" data-ref="label-text">${r.label}</span></slot></label><div part="control" class="control"><span part="prefix" class="prefix"><slot name="prefix"></slot></span><input part="input" class="input" id="input" data-ref="input" type="${r.type}" value="${r.value}" aria-describedby="help"${cr(r)}><span part="suffix" class="suffix"><slot name="suffix"></slot></span></div><div part="help-text" class="help" id="help"><slot name="help-text"><span class="help-text" data-ref="help-text">${r.helpText}</span></slot><span class="error-text" data-ref="error-text">${r.errorText}</span></div></div>`,docs:{summary:"A single-line text input with an inset field. The value attribute is the default value.",events:[{name:"input",description:"Fired on every edit (the native input event, composed)."},{name:"change",description:"Fired when an edit is committed, usually on blur."}],slots:[{name:"label",description:"Rich label; replaces the label attribute."},{name:"prefix",description:"Content before the input, such as an icon."},{name:"suffix",description:"Content after the input."},{name:"help-text",description:"Rich help text; replaces the help-text attribute."}],parts:[{name:"base",description:"Outer wrapper."},{name:"label",description:"The <label> element."},{name:"control",description:"The inset field around the input."},{name:"input",description:"The native <input>."},{name:"prefix",description:"Wrapper around the prefix slot."},{name:"suffix",description:"Wrapper around the suffix slot."},{name:"help-text",description:"Help or error text area."}],cssProperties:d}};var ne=class extends k{static def=Ve;static[M]=!0;static extraProperties=["defaultValue"];commitProps=[...z,"type","pattern"];get tp(){return this.props}probe(e){let t=document.createElement("input");return t.type=this.tp.type,t.value=e,this.tp.pattern&&t.setAttribute("pattern",this.tp.pattern),t}controlKeyDown(e){e.key!=="Enter"||e.isComposing||g(e,()=>{e.defaultPrevented||U(this.internals.form)})}update(e){let t=this.tp,i=this.input;i&&(e.has("type")&&i.type!==t.type&&(i.type=t.type),e.has("pattern")&&u(i,"pattern",t.pattern),e.has("inputMode")&&u(i,"inputmode",t.inputMode)),super.update(e)}formState(){return this.tp.type==="password"?null:super.formState()}};ne.define();var Ot=`${_}
|
|
331
|
+
.control { align-items: stretch; }
|
|
332
|
+
.input {
|
|
333
|
+
display: block; box-sizing: border-box; padding-block: 0.625rem; line-height: 1.4; resize: vertical;
|
|
334
|
+
}
|
|
335
|
+
:host([resize='none']) .input { resize: none; }
|
|
336
|
+
:host([resize='auto']) .input { resize: none; overflow: hidden; }
|
|
337
|
+
`;var pr={value:{type:"string"},name:{type:"string",reflect:!0},label:{type:"string"},placeholder:{type:"string"},helpText:{type:"string"},errorText:{type:"string"},required:{type:"boolean",reflect:!0},disabled:{type:"boolean",reflect:!0},readOnly:{type:"boolean",reflect:!0,attribute:"readonly"},minLength:{type:"number",default:-1,attribute:"minlength"},maxLength:{type:"number",default:-1,attribute:"maxlength"},autocomplete:{type:"string"},enterKeyHint:{type:"string",attribute:"enterkeyhint"},rows:{type:"number",default:3},resize:{type:"string",default:"vertical",values:["none","vertical","auto"],reflect:!0},size:{type:"string",default:"md",values:["sm","md","lg"],reflect:!0}};function Ne(r){return Number.isInteger(r)&&r>=1?r:3}function ur(r){return o`${r.placeholder?o` placeholder="${r.placeholder}"`:""}${r.required?o` required`:""}${r.disabled?o` disabled`:""}${r.readOnly?o` readonly`:""}${r.minLength>=0?o` minlength="${r.minLength}"`:""}${r.maxLength>=0?o` maxlength="${r.maxLength}"`:""}${r.autocomplete?o` autocomplete="${r.autocomplete}"`:""}${r.enterKeyHint?o` enterkeyhint="${r.enterKeyHint}"`:""}`}var Be={tag:"neu-textarea",props:pr,delegatesFocus:!0,form:{valueProp:"value"},styles:Ot,template:r=>o`<div part="base" class="base"><label part="label" class="label" for="input"><slot name="label"><span class="label-text" data-ref="label-text">${r.label}</span></slot></label><div part="control" class="control"><textarea part="textarea" class="input" id="input" data-ref="input" rows="${Ne(r.rows)}" aria-describedby="help"${ur(r)}>
|
|
338
|
+
${r.value}</textarea></div><div part="help-text" class="help" id="help"><slot name="help-text"><span class="help-text" data-ref="help-text">${r.helpText}</span></slot><span class="error-text" data-ref="error-text">${r.errorText}</span></div></div>`,docs:{summary:'A multi-line text input with an inset field. The value attribute is the default value; resize="auto" grows the field with its content.',events:[{name:"input",description:"Fired on every edit (the native input event, composed)."},{name:"change",description:"Fired when an edit is committed, usually on blur."}],slots:[{name:"label",description:"Rich label; replaces the label attribute."},{name:"help-text",description:"Rich help text; replaces the help-text attribute."}],parts:[{name:"base",description:"Outer wrapper."},{name:"label",description:"The <label> element."},{name:"control",description:"The inset field around the textarea."},{name:"textarea",description:"The native <textarea>."},{name:"help-text",description:"Help or error text area."}],cssProperties:d}};var se=class extends k{static def=Be;static extraProperties=["defaultValue"];commitProps=z;get tp(){return this.props}get value(){return super.value}set value(e){super.value=e,this.grow()}probe(e){let t=document.createElement("textarea");return t.value=e,t}sizeWatch;sizeFrame=0;lastWidth=-1;watchSize(e,t){if(!t){this.stopWatch();return}this.sizeWatch||(this.lastWidth=-1,this.sizeWatch=new ResizeObserver(([i])=>{let n=i?.contentRect.width??0;n!==this.lastWidth&&(this.lastWidth=n,cancelAnimationFrame(this.sizeFrame),this.sizeFrame=requestAnimationFrame(()=>this.grow()))}),this.sizeWatch.observe(e))}stopWatch(){cancelAnimationFrame(this.sizeFrame),this.sizeWatch?.disconnect(),this.sizeWatch=void 0}grow(){let e=this.input;if(!e)return;if(this.watchSize(e,this.isConnected&&this.tp.resize==="auto"),this.tp.resize!=="auto"){e.style.blockSize="";return}e.style.blockSize="auto";let t=e.scrollHeight;t&&(e.style.blockSize=`${t}px`)}connected(){super.connected(),this.grow()}disconnected(){super.disconnected(),this.stopWatch()}rendered(){super.rendered(),this.input?.addEventListener("input",()=>this.grow())}update(e){let t=this.input;t&&e.has("rows")&&(t.rows=Ne(this.tp.rows)),super.update(e),["value","rows","resize","size"].some(i=>e.has(i))&&this.grow()}resetToDefault(){super.resetToDefault(),this.grow()}restoreState(e){super.restoreState(e),this.grow()}};se.define();export{R as NeuAvatar,O as NeuBadge,E as NeuButton,H as NeuButtonGroup,V as NeuCheckbox,N as NeuDivider,q as NeuIcon,K as NeuIconButton,W as NeuNumberField,G as NeuOption,X as NeuRadio,Z as NeuRadioGroup,Q as NeuSelect,ee as NeuSlider,te as NeuSpinner,re as NeuSurface,ie as NeuSwitch,ne as NeuTextField,se as NeuTextarea,ce as avatarDef,pe as badgeDef,fe as buttonDef,be as buttonGroupDef,ve as checkboxDef,ge as dividerDef,Se as iconButtonDef,_e as iconDef,Ee as numberFieldDef,Le as optionDef,ze as radioDef,Ce as radioGroupDef,Xt as registerIconLibrary,Ae as selectDef,Re as sliderDef,Oe as spinnerDef,Fe as surfaceDef,He as switchDef,Ve as textFieldDef,Be as textareaDef};
|