@pg-labs-incubator/cobweb 0.0.5 → 0.0.6
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/package.json +7 -4
- package/target/esbuild/action/action.css +1 -1
- package/target/esbuild/action/base.jsx +1 -1
- package/target/esbuild/action/button.jsx +3 -3
- package/target/esbuild/action/fab-menu-context.jsx +1 -1
- package/target/esbuild/action/fab-menu.jsx +3 -3
- package/target/esbuild/action/fab.jsx +3 -3
- package/target/esbuild/action/group.jsx +7 -7
- package/target/esbuild/action/icon-button.jsx +3 -3
- package/target/esbuild/action/index.jsx +1 -1
- package/target/esbuild/action/split-button.jsx +4 -4
- package/target/esbuild/color/contrast.jsx +1 -1
- package/target/esbuild/color/dynamic.jsx +1 -1
- package/target/esbuild/color/hct.jsx +1 -1
- package/target/esbuild/color/index.jsx +1 -1
- package/target/esbuild/color/palette.jsx +1 -1
- package/target/esbuild/color/scheme.jsx +1 -1
- package/target/esbuild/color/temperature.jsx +1 -1
- package/target/esbuild/container/card.jsx +1 -1
- package/target/esbuild/container/elevation-shadow.jsx +1 -1
- package/target/esbuild/container/index.jsx +1 -1
- package/target/esbuild/dom/client.jsx +1 -1
- package/target/esbuild/dom/index.jsx +1 -1
- package/target/esbuild/dom/server.jsx +1 -1
- package/target/esbuild/dom/types.jsx +1 -1
- package/target/esbuild/feedback/badge.jsx +6 -6
- package/target/esbuild/feedback/focus.jsx +1 -1
- package/target/esbuild/feedback/index.jsx +1 -1
- package/target/esbuild/feedback/loading.jsx +3 -3
- package/target/esbuild/feedback/observe.jsx +1 -1
- package/target/esbuild/feedback/progress.jsx +9 -9
- package/target/esbuild/feedback/snackbar.jsx +6 -6
- package/target/esbuild/feedback/tooltip.jsx +6 -6
- package/target/esbuild/icon/icon.jsx +1 -1
- package/target/esbuild/icon/index.jsx +1 -1
- package/target/esbuild/index.jsx +1 -1
- package/target/esbuild/input/autocomplete.jsx +2 -2
- package/target/esbuild/input/base.jsx +2 -2
- package/target/esbuild/input/date-picker.jsx +19 -19
- package/target/esbuild/input/date-time.jsx +3 -3
- package/target/esbuild/input/index.jsx +1 -1
- package/target/esbuild/input/paired-input.jsx +1 -1
- package/target/esbuild/input/picker-dialog.jsx +3 -3
- package/target/esbuild/input/select.jsx +4 -4
- package/target/esbuild/input/slider.jsx +7 -7
- package/target/esbuild/input/text-field.jsx +4 -4
- package/target/esbuild/input/time-picker.jsx +5 -5
- package/target/esbuild/motion/follow-height.jsx +1 -0
- package/target/esbuild/motion/frame.jsx +1 -1
- package/target/esbuild/motion/index.jsx +1 -1
- package/target/esbuild/motion/material.jsx +1 -1
- package/target/esbuild/motion/motion.jsx +1 -1
- package/target/esbuild/motion/spring.jsx +1 -1
- package/target/esbuild/motion/transition.jsx +1 -1
- package/target/esbuild/motion/velocity.jsx +1 -1
- package/target/esbuild/navigation/app-bar.jsx +8 -8
- package/target/esbuild/navigation/base.jsx +1 -1
- package/target/esbuild/navigation/drawer.jsx +7 -7
- package/target/esbuild/navigation/index.jsx +1 -1
- package/target/esbuild/navigation/navigation.jsx +12 -12
- package/target/esbuild/navigation/scroll.jsx +1 -1
- package/target/esbuild/navigation/search.jsx +4 -4
- package/target/esbuild/navigation/tabs.jsx +3 -3
- package/target/esbuild/navigation/toolbar.jsx +3 -3
- package/target/esbuild/selection/base.jsx +1 -1
- package/target/esbuild/selection/checkbox.jsx +4 -4
- package/target/esbuild/selection/chip.jsx +5 -5
- package/target/esbuild/selection/index.jsx +1 -1
- package/target/esbuild/selection/radio.jsx +3 -3
- package/target/esbuild/selection/segmented.jsx +4 -4
- package/target/esbuild/selection/switch.jsx +3 -3
- package/target/esbuild/shape/corner-rounding.jsx +1 -1
- package/target/esbuild/shape/cubic.jsx +1 -1
- package/target/esbuild/shape/index.jsx +1 -1
- package/target/esbuild/shape/material-shapes.jsx +1 -1
- package/target/esbuild/shape/morph.jsx +1 -1
- package/target/esbuild/shape/path.jsx +1 -1
- package/target/esbuild/shape/point.jsx +1 -1
- package/target/esbuild/shape/rounded-polygon.jsx +1 -1
- package/target/esbuild/shape/shapes.jsx +1 -1
- package/target/esbuild/spacing/index.jsx +1 -1
- package/target/esbuild/state/component.jsx +1 -1
- package/target/esbuild/state/controller.jsx +1 -1
- package/target/esbuild/state/index.jsx +1 -1
- package/target/esbuild/state/ripple.jsx +1 -1
- package/target/esbuild/state/state.jsx +1 -1
- package/target/esbuild/state/style.jsx +1 -1
- package/target/esbuild/surface/carousel-layout.jsx +1 -1
- package/target/esbuild/surface/carousel.jsx +2 -2
- package/target/esbuild/surface/dialog.jsx +5 -5
- package/target/esbuild/surface/divider.jsx +1 -1
- package/target/esbuild/surface/drag.jsx +1 -1
- package/target/esbuild/surface/gestures.jsx +3 -3
- package/target/esbuild/surface/index.jsx +1 -1
- package/target/esbuild/surface/interactive.jsx +1 -1
- package/target/esbuild/surface/list-patterns.jsx +3 -3
- package/target/esbuild/surface/list.jsx +2 -2
- package/target/esbuild/surface/menu.jsx +3 -3
- package/target/esbuild/surface/scaffold.jsx +7 -7
- package/target/esbuild/surface/sheet.jsx +5 -5
- package/target/esbuild/surface/side-sheet.jsx +2 -2
- package/target/esbuild/surface/slots.jsx +1 -1
- package/target/esbuild/surface/surface.jsx +1 -1
- package/target/esbuild/text/index.jsx +1 -1
- package/target/esbuild/text/text.jsx +2 -2
- package/target/esbuild/text/typography.jsx +1 -1
- package/target/esbuild/util/box-side.jsx +1 -1
- package/target/esbuild/util/debug.jsx +1 -1
- package/target/esbuild/util/dom.jsx +1 -1
- package/target/esbuild/util/environment.jsx +1 -0
- package/target/esbuild/util/event.jsx +1 -1
- package/target/esbuild/util/index.jsx +1 -1
- package/target/esbuild/util/preconditions.jsx +1 -1
- package/target/esbuild/util/reactive.jsx +1 -1
- package/target/node/color.js +1 -0
- package/target/node/shape.js +1 -0
- package/target/tsc/motion/follow-height.d.ts +51 -0
- package/target/tsc/motion/index.d.ts +7 -3
- package/target/tsc/motion/spring.d.ts +3 -3
- package/target/tsc/shape/index.d.ts +1 -1
- package/target/tsc/shape/material-shapes.d.ts +56 -0
- package/target/tsc/shape/path.d.ts +16 -0
- package/target/tsc/util/environment.d.ts +14 -0
- package/target/tsc/util/index.d.ts +2 -1
- package/target/tsc/util/preconditions.d.ts +0 -14
|
@@ -1 +1 @@
|
|
|
1
|
-
import{argbOfHct as W,hctOfArgb as A,labOfArgb as x,sanitizeDegrees as b}from"./hct";const l=361;function E(r){const[,t,e]=x(r),o=b(Math.atan2(e,t)*180/Math.PI),a=Math.sqrt(t*t+e*e);return
|
|
1
|
+
import{argbOfHct as W,hctOfArgb as A,labOfArgb as x,sanitizeDegrees as b}from"./hct";const l=361;function E(r){const[,t,e]=x(r),o=b(Math.atan2(e,t)*180/Math.PI),a=Math.sqrt(t*t+e*e);return-0.5+0.02*Math.pow(a,1.07)*Math.cos(b(o-50)*Math.PI/180);}function g(r){const t=new Uint32Array(l),e=new Float64Array(l+1);let o=0,a=0;for(let n=0;n<l;n++)t[n]=W(n,r.chroma,r.tone);for(let n=0;n<=l;n++){const c=E(n<l?t[n]:r.argb);e[n]=c,c<e[o]&&(o=n),c>=e[a]&&(a=n);}return{source:r,colors:t,temperatures:e,coldest:o,warmest:a};}function h(r,t){return t<l?A(r.colors[t]):r.source;}function m(r,t){const{temperatures:e,coldest:o,warmest:a}=r,n=e[a]-e[o];return n===0?0.5:(e[t]-e[o])/n;}function y(r,t,e){return t<e?t<=r&&r<=e:t<=r||r<=e;}function I(r){const t=g(r),e=Math.round(r.hue);let o=m(t,e),a=0;for(let s=1;s<360;s++){const u=m(t,(e+s)%360);a+=Math.abs(u-o),o=u;}const n=a/6;let c=0;o=m(t,e);for(let s=1;;s++){const u=(e+s)%360,f=m(t,u);if(c+=Math.abs(f-o),c>=n)return h(t,u);o=f;}}function U(r){const t=g(r),{temperatures:e,coldest:o,warmest:a}=t,n=h(t,o).hue,c=h(t,a).hue,s=y(r.hue,n,c),u=s?c:n,f=s?n:c,O=1-m(t,l);let p=Math.round(r.hue),H=1e3;for(let i=0;i<=360;i++){const d=b(u+i);if(!y(d,u,f))continue;const M=Math.round(d),w=Math.abs(O-(e[M]-e[o])/(e[a]-e[o]));w<H&&(H=w,p=M);}return h(t,p);}export{I as analogousColorOf,U as complementaryColorOf};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{insert as E}from"solid-js/web";import{DragState as m,FocusState as C,HoverState as v,PressState as g,defineInteractableComponent as S}from"../state";import{deferAfterDelegatedCancellation as a}from"../util";import"./elevation-shadow.css";import"./card.css";const L=C|v|g,u="cw-Card-disabled",i="_cw-Card-pressable",r
|
|
1
|
+
import{insert as E}from"solid-js/web";import{DragState as m,FocusState as C,HoverState as v,PressState as g,defineInteractableComponent as S}from"../state";import{deferAfterDelegatedCancellation as a}from"../util";import"./elevation-shadow.css";import"./card.css";const L=C|v|g,u="cw-Card-disabled",i="_cw-Card-pressable",r=/* @__PURE__ */new WeakSet();function s(t){return`_cw-Card-${t??"filled"}`;}function o(t){return t.matches(":focus")&&t.classList.contains(i);}function b(t){const e=t.currentTarget;t.target===e&&(t.key===" "?a(t,e,()=>{o(e)&&r.add(e);}):t.key==="Enter"&&!t.repeat&&a(t,e,()=>{o(e)&&e.click();}));}function c(t){const e=t.currentTarget;t.key!==" "||!r.delete(e)||t.target!==e||a(t,e,()=>{o(e)&&e.click();});}function p(t){r.delete(t.currentTarget);}function f(t){t.preventDefault(),t.stopImmediatePropagation();}function y(t,e){e?(t.addEventListener("keydown",b),t.addEventListener("keyup",c),t.addEventListener("blur",p)):(t.removeEventListener("keydown",b),t.removeEventListener("keyup",c),t.removeEventListener("blur",p),r.delete(t));}const x=/* @__PURE__ */S(()=>(t,e)=><div{...t}aria-disabled={e.disabled?"true":void 0}classList={{...t.classList,[u]:e.disabled,[i]:(e.pressable||e.button)&&!e.disabled,[s(e.design)]:!0,"cw-Card":!0,"cw-elevationShadow":!0}}role={e.button?"button":void 0}tabindex={e.button?e.disabled?void 0:e.tabIndex??0:e.tabIndex}/>,t=>class extends t{constructor(e){super(e,{baseInteractionCssClassName:"cw-Card",styleElementIsFunction:!0});}onEvent(e){this.props.disabled!==!0&&super.onEvent(e);}applyComponentProps(){const e=super.readProps(["button","design","disabled","draggable","pressable","tabIndex"]),n=this.functionElement;if(e.designChanged&&(super.setClass(s(e.designPrevious),!1),super.setClass(s(e.design),!0)),e.disabledChanged&&(super.setAttribute("aria-disabled",e.disabled?"true":void 0),super.setClass(u,e.disabled??!1),e.disabled?n.addEventListener("click",f,!0):n.removeEventListener("click",f,!0)),e.buttonChanged||e.disabledChanged||e.draggableChanged||e.pressableChanged){const d=!e.disabled,l=d&&(e.pressable||e.button)===!0;super.setClass(i,l),super.setAttribute("role",e.button?"button":void 0),super.setEnabledInteractionStates((l?L:0)|(d&&e.draggable?m:0)),y(n,d&&e.button===!0),e.tabIndexChanged=!0;}e.tabIndexChanged&&super.setAttribute("tabindex",e.button?e.disabled?void 0:e.tabIndex??0:e.tabIndex);}render(e){const n=<div class="cw-Card cw-elevationShadow"/>;return E(n,e),n;}});export{x as Card};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./elevation-shadow.css";const o="cw-elevationShadow";export{o as ELEVATION_SHADOW_CSS_CLASS};
|
|
1
|
+
import"./elevation-shadow.css";const o="cw-elevationShadow";export{o as ELEVATION_SHADOW_CSS_CLASS};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Card as p}from"./card";import{ELEVATION_SHADOW_CSS_CLASS as e}from"./elevation-shadow";export{p as Card,e as ELEVATION_SHADOW_CSS_CLASS};
|
|
1
|
+
import{Card as p}from"./card";import{ELEVATION_SHADOW_CSS_CLASS as e}from"./elevation-shadow";export{p as Card,e as ELEVATION_SHADOW_CSS_CLASS};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{$PROXY as A,createRenderEffect as m,getOwner as y,onCleanup as K,runWithOwner as L,untrack as P}from"solid-js";import{DelegatedEvents as O,assign as E,delegateEvents as I}from"solid-js/web";import{assertDebug as r,attributeValueOf as S,checkArgument as M,checkBrowser as x,checkState as N,consumeProps as a,isPropReactive as X,setAttribute as d}from"../util";import{elementPropsKeyOfEvent as J}from"./types";const p=Symbol(),u=Symbol(),j="http://www.w3.org/1999/xhtml",T="http://www.w3.org/1998/Math/MathML",R="http://www.w3.org/2000/svg",g=/[\t\n\f\r ]+/;function b(o){const t=[];if(o===void 0)return t;for(const[n,e]of Object.entries(o))typeof n=="string"&&n!==""&&e===!0&&t.push(n);return t}function v(o){return typeof o=="object"&&o!==null&&A in o}function C(o){return typeof o=="object"&&o!==null&&o.nodeType===Node.ELEMENT_NODE}function w(o){return o.namespaceURI===R}function H(o){return o.namespaceURI===j||o.namespaceURI===T||o.namespaceURI===R}function f(o,t,n){if(!g.test(t)){t!==""&&o.toggle(t,n);return}for(const e of t.split(g))e!==""&&o.toggle(e,n)}function U(o){return Object.keys(o).map(t=>t.slice(2).toLowerCase()).filter(t=>O.has(t))}function F(o){const t=this.ownerDocument;t!==document&&I([o.type],t)}function k(o,t,n,e){return Array.isArray(e)&&(e=e[e.length-1]),e===void 0?null:(M(o==="function"&&C(e)||o==="style"&&C(e)&&H(e),"not a valid element"),N(!t||n===null||n===e,`static ${o} element already resolved`),e)}class D{static _create(t,n){const e=a(n,["children"],["controllerRef"]),s=new t(n);y()!==null&&K(()=>s.onControllerCleanup()),s.#x(),e.controllerRef?.(s);const i=s.isFunctionElementStyle()?void 0:c=>s.#p(c),l=s.render("children"in e?e.children:()=>s.props.children,i);if(typeof l!="function")return s.#s|=4,i===void 0&&(s.#s|=2),s.#h(l),s.#d(),l;i===void 0&&(s.#s&=-3);let h=(()=>{const c=y();return()=>{s.#i!==null&&(h=void 0,L(c,()=>s.#d()))}})();return(
|
|
1
|
+
import{$PROXY as A,createRenderEffect as m,getOwner as y,onCleanup as K,runWithOwner as L,untrack as P}from"solid-js";import{DelegatedEvents as O,assign as E,delegateEvents as I}from"solid-js/web";import{assertDebug as r,attributeValueOf as S,checkArgument as M,checkBrowser as x,checkState as N,consumeProps as a,isPropReactive as X,setAttribute as d}from"../util";import{elementPropsKeyOfEvent as J}from"./types";const p=Symbol(),u=Symbol(),j="http://www.w3.org/1999/xhtml",T="http://www.w3.org/1998/Math/MathML",R="http://www.w3.org/2000/svg",g=/[\t\n\f\r ]+/;function b(o){const t=[];if(o===void 0)return t;for(const[n,e]of Object.entries(o))typeof n=="string"&&n!==""&&e===!0&&t.push(n);return t;}function v(o){return typeof o=="object"&&o!==null&&A in o;}function C(o){return typeof o=="object"&&o!==null&&o.nodeType===Node.ELEMENT_NODE;}function w(o){return o.namespaceURI===R;}function H(o){return o.namespaceURI===j||o.namespaceURI===T||o.namespaceURI===R;}function f(o,t,n){if(!g.test(t)){t!==""&&o.toggle(t,n);return;}for(const e of t.split(g))e!==""&&o.toggle(e,n);}function U(o){return Object.keys(o).map(t=>t.slice(2).toLowerCase()).filter(t=>O.has(t));}function F(o){const t=this.ownerDocument;t!==document&&I([o.type],t);}function k(o,t,n,e){return Array.isArray(e)&&(e=e[e.length-1]),e===void 0?null:(M(o==="function"&&C(e)||o==="style"&&C(e)&&H(e),"not a valid element"),N(!t||n===null||n===e,`static ${o} element already resolved`),e);}class D{static _create(t,n){const e=a(n,["children"],["controllerRef"]),s=new t(n);y()!==null&&K(()=>s.onControllerCleanup()),s.#x(),e.controllerRef?.(s);const i=s.isFunctionElementStyle()?void 0:c=>s.#p(c),l=s.render("children"in e?e.children:()=>s.props.children,i);if(typeof l!="function")return s.#s|=4,i===void 0&&(s.#s|=2),s.#h(l),s.#d(),l;i===void 0&&(s.#s&=-3);let h=(()=>{const c=y();return()=>{s.#i!==null&&(h=void 0,L(c,()=>s.#d()));};})();return()=>{const c=l();return s.#h(c),h?.(),c;};}props;#u;#s;#i;#e;#t;#o;#n;#c;#r;#f;#a;constructor(t,n){x(),this.props=t,this.#u=null,this.#s=0,this.#i=null,this.#e=null,this.#t=null,this.#o=null,this.#n=null,this.#c=null,this.#r=null,this.#f=null,this.#a=null,n?.styleElementIsFunction&&(this.#s|=1),n?.functionElementIsStatic&&(this.#s|=2);}onControllerCleanup(){}#m(t){const n=this.#u;if(n===null)return u;const e=n.get(t);return(e===void 0?u:e===u?void 0:e);}#y(t,n){const e=this.#u;n===void 0&&(n=u),e===null?this.#u=/* @__PURE__ */new Map([[t,n]]):e.set(t,n);}readProp(t,n){const e=this.#m(t);if(n)return[e===p?this.props[t]:e===u?void 0:e,!1];const s=this.props[t];return e===p||e!==u&&e===s?[s,!1]:(this.#y(t,e===u&&!X(this.props,t)?p:s),[s,!0,e===u?void 0:e]);}readProps(t,n){const e={};for(const s of t)[e[s],e[`${s}Changed`],e[`${s}Previous`]]=this.readProp(s,n);return e;}consumeProps(t,n){return a(this.props,t,n);}get styleElement(){return this.#i;}get functionElement(){return this.#o;}#l(t){return(this.#s&t)===t;}isFunctionElementStatic(){return this.#l(2);}isStyleElementStatic(){return this.#l(4);}isFunctionElementStyle(){return this.#l(1);}setStyle(t,n){typeof n=="number"&&(n=n.toString());const e=this.#i,s=this.#e;if(e===null){n===void 0?s?.delete(t):s===null?this.#e=/* @__PURE__ */new Map([[t,n]]):(r(s instanceof Map),s.set(t,n));return;}r(s===null||s instanceof Set),n===void 0?(e.style.removeProperty(t),s?.delete(t)):(this.isStyleElementStatic()?r(this.#e===null):s===null?this.#e=/* @__PURE__ */new Set([t]):s.add(t),e.style.setProperty(t,n));}setClass(t,n){const e=this.#i?.classList;let s,i;if(typeof n!="boolean")s=t,i=n,M(s!==i),i===""&&(i=void 0);else if(e===void 0||!this.isStyleElementStatic())s=t,i=n?t:void 0;else{f(e,t,n);return;}this.#t===null&&(this.#t=/* @__PURE__ */new Map());const l=this.#t.get(s);i!==void 0?(this.#t.set(s,i),e!==void 0&&(l!==void 0&&f(e,l,!1),f(e,i,!0))):l!==void 0&&(this.#t.delete(s),e!==void 0&&f(e,l,!1));}setAttribute(t,n){const e=this.#o,s=this.#n;if(e===null){if(n==null){s?.delete(t);return;}s===null?this.#n=/* @__PURE__ */new Map([[t,S(t,n)]]):(r(s instanceof Map),s.set(t,S(t,n)));return;}r(s===null||s instanceof Set),n==null?(s?.delete(t),e.removeAttribute(t)):(this.isFunctionElementStatic()?r(this.#n===null):s===null?this.#n=/* @__PURE__ */new Set([t]):s.add(t),d(e,t,n));}#P(){if(this.#l(16))return;const t=b(this.props.classList),n=new Set(this.#f);for(const e of t)n.delete(e)||this.setClass(e,!0);for(const e of n)this.setClass(e,!1);this.#f=t.length!==0?t:null;}#E(){if(this.#l(8))return;const t=this.props.style,n=this.#a,e=/* @__PURE__ */new Map();for(const s in t){const i=t[s];i!=null&&e.set(s,i.toString());}for(const s of n?.keys()??[])e.has(s)||this.setStyle(s);for(const[s,i]of e)n?.get(s)!==i&&this.setStyle(s,i);this.#a=e.size!==0?e:null;}#S(){this.#E(),this.#P();}#g(){const t=this.#c;if(t!==null)for(const n of t){const[e,s]=this.readProp(n);s&&this.setAttribute(n.slice(5),e);}}applyComponentProps(){}#d(){this.#l(24)||m(t=>(t.#S(),t),this),m(t=>(t.#g(),t.applyComponentProps(),t),this);}onStyleElementChanged(t){r(t!==this.styleElement);}onFunctionElementChanged(t){r(t!==this.functionElement);}#b(){"ref"in this.props&&P(()=>{const{ref:t}=this.isFunctionElementStatic()?a(this.props,[],["ref"]):this.props;typeof t=="function"&&t(this.#o);});}#v(t){const n=this.#r,e=this.#o;if(n===null)return;const s=U(n);if(t!==null){E(t,{},w(t),!0,{...n},!0);for(const i of s)t.removeEventListener(i,F);}if(e!==null){E(e,n,w(e),!0,{},!0);for(const i of s)e.addEventListener(i,F);}this.isFunctionElementStatic()&&(this.#r=null);}#C(t){const n=this.#n;if(n!==null){r(n instanceof Set),this.#n=/* @__PURE__ */new Map();for(const e of n)this.#n.set(e,t.getAttribute(e));}}#p(t){const n=this.#o,e=k("function",this.isFunctionElementStatic(),n,t);if(n===e)return;if(r(!this.isFunctionElementStyle()||this.#i===e),this.onFunctionElementChanged(e),this.#o=e,this.#b(),this.#v(n),e===null){this.#C(n);return;}const s=this.#n;if(s instanceof Set){r(n!==null);for(const i of s)d(e,i,n.getAttribute(i));}else if(s instanceof Map){r(n===null),this.#n=this.isFunctionElementStatic()?null:new Set(s.keys());for(const[i,l]of s.entries())d(e,i,l);}}#w(t){const n=this.#e;if(n!==null){r(n instanceof Set),this.#e=/* @__PURE__ */new Map();for(const e of n)this.#e.set(e,t.style.getPropertyValue(e));}}#h(t){const n=this.#i,e=k("style",this.isStyleElementStatic(),n,t);if(n===e)return;if(this.onStyleElementChanged(e),this.#i=e,this.isFunctionElementStyle()&&this.#p(t),e===null){this.#w(n);return;}if(this.#t!==null&&this.#t.size!==0){for(const i of this.#t.values())f(e.classList,i,!0);if(this.isStyleElementStatic()){for(const[i,l]of this.#t.entries())i===l&&this.#t.delete(i);this.#t.size===0&&(this.#t=null);}}const s=this.#e;if(s instanceof Set){r(n!==null);for(const i of s)e.style.setProperty(i,n.style.getPropertyValue(i));}else if(s instanceof Map){r(n===null),this.#e=null;for(const[i,l]of s.entries())this.setStyle(i,l);}}#F(t,n){if(n.length!==0){this.#r={};for(const e of n){const s=J(e);this.#r[s]=t[e];}}}#k(t,n){for(const e of n)e in t&&(n.delete(e),this.setAttribute(e.slice(5),t[e]));n.size!==0&&(this.#c=[...n.values()]);}#D(t){const n=[];(t.class??"")!==""&&n.push(t.class),"classList"in t&&!v(t.classList)&&(this.#s|=16,n.push(...b(t.classList))),n.length!==0&&(r(this.#t===null),this.#t=new Map(n.map(e=>[e,e])));}#M(t){if(!("style"in t))return;const n=t.style;if(!v(n)&&(this.#s|=8,n!==void 0)){r(this.#e===null),this.#e=/* @__PURE__ */new Map();for(const[e,s]of Object.entries(n))typeof e=="string"&&(typeof s=="string"||typeof s=="number")&&this.#e.set(e,s.toString());}}#x(){const[t,n]=P(()=>{const s=/* @__PURE__ */new Set(),i=[];for(const l in this.props)l.startsWith("attr:")?s.add(l):l.startsWith("event:")&&i.push(l);return[s,i];}),e=a(this.props,["classList","style",...t.values()],["class",...n.values()]);this.#M(e),this.#D(e),this.#k(e,t),this.#F(e,n);}}function G(o){return x(),D._create.bind(null,o(D));}export{D as DomController,G as defineClientDomComponent};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isServer as r}from"solid-js/web";import{defineClientDomComponent as t}from"./client";import{defineServerDomComponent as m}from"./server";const l=r?o=>m(o):(o,e)=>t(e);export{l as defineDomComponent};
|
|
1
|
+
import{isServer as r}from"solid-js/web";import{defineClientDomComponent as t}from"./client";import{defineServerDomComponent as m}from"./server";const l=r?o=>m(o):(o,e)=>t(e);export{l as defineDomComponent};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{untrack as u}from"solid-js";import{Properties as P}from"solid-js/web";import{attributeValueOf as l,checkServer as c}from"../util";import{elementPropsKeyOfEvent as d}from"./types";function a(e){if(typeof e=="string")return e.startsWith("attr:")?e.slice(5):e.startsWith("event:")?d(e):["children","class","classList","ref","style"].includes(e)?e:void 0}function D(e,n){const o=typeof n=="boolean"?l(e,n):n;return typeof n!="boolean"?n:o===null?void 0:o===""&&P.has(e)?!0:o}function p(e,n,o){let t=!1,r;Object.defineProperty(e,n,{configurable:!0,enumerable:!0,get(){return t||(r=o(),t=!0),r},set(s){r=s,t=!0}})}function x(e){c();const n=e();return o=>{const t={},r={};for(const s in o){const f=s,i=a(f),m=()=>u(()=>o[f]);i===void 0?p(r,s,m):s.startsWith("attr:")?p(t,i,()=>D(i,m())):p(t,i,m)}return n(t,r)}}export{x as defineServerDomComponent};
|
|
1
|
+
import{untrack as u}from"solid-js";import{Properties as P}from"solid-js/web";import{attributeValueOf as l,checkServer as c}from"../util";import{elementPropsKeyOfEvent as d}from"./types";function a(e){if(typeof e=="string")return e.startsWith("attr:")?e.slice(5):e.startsWith("event:")?d(e):["children","class","classList","ref","style"].includes(e)?e:void 0;}function D(e,n){const o=typeof n=="boolean"?l(e,n):n;return typeof n!="boolean"?n:o===null?void 0:o===""&&P.has(e)?!0:o;}function p(e,n,o){let t=!1,r;Object.defineProperty(e,n,{configurable:!0,enumerable:!0,get(){return t||(r=o(),t=!0),r;},set(s){r=s,t=!0;}});}function x(e){c();const n=e();return o=>{const t={},r={};for(const s in o){const f=s,i=a(f),m=()=>u(()=>o[f]);i===void 0?p(r,s,m):s.startsWith("attr:")?p(t,i,()=>D(i,m())):p(t,i,m);}return n(t,r);};}export{x as defineServerDomComponent};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function n(t){const e=t.slice(6);return`on${e.charAt(0).toUpperCase()}${e.slice(1)}
|
|
1
|
+
function n(t){const e=t.slice(6);return`on${e.charAt(0).toUpperCase()}${e.slice(1)}`;}export{n as elementPropsKeyOfEvent};
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import{Show as B,children as S}from"solid-js";import{insert as r}from"solid-js/web";import{defineDomComponent as p}from"..";import{FOCUSABLE_SELECTORS as E}from"./focus";import"./feedback.css";const o="cw-Badge",d="cw-Badge-small",C=E.map(t=>`.cw-BadgedBox-content ${t}`).join(","),x={attributeFilter:["contenteditable","disabled","href","tabindex","type"],attributes:!0,childList:!0,subtree:!0};let v=0;function a(t,e,n){return n||t===void 0?"":typeof t=="number"&&e!==void 0&&e>=0&&t>e?`${e}+`:String(t)}function l(t){return t===void 0?void 0:`_cw-Badge-${t}
|
|
1
|
+
import{Show as B,children as S}from"solid-js";import{insert as r}from"solid-js/web";import{defineDomComponent as p}from"..";import{FOCUSABLE_SELECTORS as E}from"./focus";import"./feedback.css";const o="cw-Badge",d="cw-Badge-small",C=E.map(t=>`.cw-BadgedBox-content ${t}`).join(","),x={attributeFilter:["contenteditable","disabled","href","tabindex","type"],attributes:!0,childList:!0,subtree:!0};let v=0;function a(t,e,n){return n||t===void 0?"":typeof t=="number"&&e!==void 0&&e>=0&&t>e?`${e}+`:String(t);}function l(t){return t===void 0?void 0:`_cw-Badge-${t}`;}function u(t,e){return{hidden:t===""&&!e?"true":void 0,role:t===""&&e?"img":void 0};}function c(t,e){return t!=null&&`${t}`!=""||e!=null&&`${e}`!="";}const L=/* @__PURE__ */p(()=>(t,e)=>{const n=a(e.value,e.max,e.small===!0),s=u(n,c(t["aria-label"],t["aria-labelledby"])),i=l(e.color);return<span aria-hidden={s.hidden}role={s.role}{...t}classList={{...t.classList,...(i===void 0?void 0:{[i]:!0}),[o]:!0,[d]:n===""}}>
|
|
2
2
|
<span class="cw-Badge-label">{n}</span>
|
|
3
|
-
</span
|
|
3
|
+
</span>;},t=>class extends t{#e;#n;#t;#s;#i;constructor(e){super(e,{styleElementIsFunction:!0}),this.#e=null,this.#n="attr:aria-hidden"in e,this.#t="attr:role"in e,this.#s=void 0,this.#i=!1;}applyComponentProps(){const e=super.readProps(["attr:aria-label","attr:aria-labelledby","color","max","small","value"]),n=a(e.value,e.max,e.small===!0),s=c(e["attr:aria-label"],e["attr:aria-labelledby"]);if(e.colorChanged&&super.setClass("color",l(e.color)),n!==this.#s&&(this.#e!==null&&this.#e.textContent!==n&&(this.#e.textContent=n),super.setClass(d,n==="")),n!==this.#s||s!==this.#i){const i=u(n,s);this.#n||super.setAttribute("aria-hidden",i.hidden),this.#t||super.setAttribute("role",i.role);}this.#s=n,this.#i=s;}render(){const e=<span class={o}>
|
|
4
4
|
<span class="cw-Badge-label"/>
|
|
5
|
-
</span>;return this.#e=e.firstElementChild,e}});function m(t){return<B when={t.value!==void 0||t.small===!0}>
|
|
5
|
+
</span>;return this.#e=e.firstElementChild,e;}});function m(t){return<B when={t.value!==void 0||t.small===!0}>
|
|
6
6
|
<L color={t.color}max={t.max}small={t.small}value={t.value}/>
|
|
7
|
-
</B
|
|
7
|
+
</B>;}const D=/* @__PURE__ */p(()=>(t,e)=><span{...t}classList={{...t.classList,"cw-BadgedBox":!0}}>
|
|
8
8
|
<span class="cw-BadgedBox-content">{t.children}</span>
|
|
9
9
|
<span class="cw-BadgedBox-badge">
|
|
10
10
|
{"badge"in e?e.badge:m(e)}
|
|
11
11
|
</span>
|
|
12
|
-
</span>,t=>class extends t{#e;#n;#t;constructor(e){super(e,{styleElementIsFunction:!0}),this.#e=`cw-BadgedBox-badge-${v++}`,this.#n=null,this.#t=void 0}onStyleElementChanged(e){super.onStyleElementChanged(e),this.#i(),this.#r(null),e!==null&&(e.ownerDocument.defaultView?.queueMicrotask??queueMicrotask)(()=>{this.styleElement===e&&this.#s(e)})}onControllerCleanup(){this.#i(),this.#r(null),super.onControllerCleanup()}#s(e){const n=e.ownerDocument.defaultView,s=()=>{this.#r(e.querySelector(C))};s(),n!==null&&(this.#t=new n.MutationObserver(s),this.#t.observe(e.firstElementChild,x))}#i(){this.#t?.disconnect(),this.#t=void 0}#r(e){const n=this.#n;if(n!==e){if(n!==null){const s=(n.getAttribute("aria-describedby")??"").split(/\s+/u).filter(i=>i!==""&&i!==this.#e);s.length===0?n.removeAttribute("aria-describedby"):n.setAttribute("aria-describedby",s.join(" "))}if(this.#n=e,e!==null){const s=(e.getAttribute("aria-describedby")??"").split(/\s+/u).filter(i=>i!=="");e.setAttribute("aria-describedby",[...s,this.#e].join(" "))}}}render(e){const n=<span class="cw-BadgedBox">
|
|
12
|
+
</span>,t=>class extends t{#e;#n;#t;constructor(e){super(e,{styleElementIsFunction:!0}),this.#e=`cw-BadgedBox-badge-${v++}`,this.#n=null,this.#t=void 0;}onStyleElementChanged(e){super.onStyleElementChanged(e),this.#i(),this.#r(null),e!==null&&(e.ownerDocument.defaultView?.queueMicrotask??queueMicrotask)(()=>{this.styleElement===e&&this.#s(e);});}onControllerCleanup(){this.#i(),this.#r(null),super.onControllerCleanup();}#s(e){const n=e.ownerDocument.defaultView,s=()=>{this.#r(e.querySelector(C));};s(),n!==null&&(this.#t=new n.MutationObserver(s),this.#t.observe(e.firstElementChild,x));}#i(){this.#t?.disconnect(),this.#t=void 0;}#r(e){const n=this.#n;if(n!==e){if(n!==null){const s=(n.getAttribute("aria-describedby")??"").split(/\s+/u).filter(i=>i!==""&&i!==this.#e);s.length===0?n.removeAttribute("aria-describedby"):n.setAttribute("aria-describedby",s.join(" "));}if(this.#n=e,e!==null){const s=(e.getAttribute("aria-describedby")??"").split(/\s+/u).filter(i=>i!=="");e.setAttribute("aria-describedby",[...s,this.#e].join(" "));}}}render(e){const n=<span class="cw-BadgedBox">
|
|
13
13
|
<span class="cw-BadgedBox-content"/>
|
|
14
14
|
<span class="cw-BadgedBox-badge"/>
|
|
15
|
-
</span>,s=n.lastElementChild;return r(n.firstElementChild,e),s.id=this.#e,r(s,"badge"in this.props?S(()=>this.props.badge):m(this.props)),n}});export{L as Badge,D as BadgedBox};
|
|
15
|
+
</span>,s=n.lastElementChild;return r(n.firstElementChild,e),s.id=this.#e,r(s,"badge"in this.props?S(()=>this.props.badge):m(this.props)),n;}});export{L as Badge,D as BadgedBox};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const n=["a[href]","button:not([disabled])","input:not([disabled]):not([type=hidden])","select:not([disabled])","textarea:not([disabled])","[contenteditable]:not([contenteditable=false])","[tabindex]:not([tabindex='-1'])"];function o(t){const e=t.getRootNode().activeElement??null;return e!==null&&t.contains(e)}export{n as FOCUSABLE_SELECTORS,o as isFocusWithin};
|
|
1
|
+
const n=["a[href]","button:not([disabled])","input:not([disabled]):not([type=hidden])","select:not([disabled])","textarea:not([disabled])","[contenteditable]:not([contenteditable=false])","[tabindex]:not([tabindex='-1'])"];function o(t){const e=t.getRootNode().activeElement??null;return e!==null&&t.contains(e);}export{n as FOCUSABLE_SELECTORS,o as isFocusWithin};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Badge as t,BadgedBox as e}from"./badge";import{ContainedLoadingIndicator as i,ContainedLoadingIndicatorController as s,LoadingIndicator as p,LoadingIndicatorController as c}from"./loading";import{CircularProgressIndicator as d,CircularWavyProgressIndicator as g,LinearProgressIndicator as P,LinearWavyProgressIndicator as C}from"./progress";import{Snackbar as b,SnackbarController as m,SnackbarHost as k,SnackbarHostController as x,SnackbarQueue as T,createSnackbarQueue as S}from"./snackbar";import{PlainTooltip as y,PlainTooltipController as L,RichTooltip as u,RichTooltipController as B,TooltipController as R}from"./tooltip";import"./feedback.css";export{t as Badge,e as BadgedBox,d as CircularProgressIndicator,g as CircularWavyProgressIndicator,i as ContainedLoadingIndicator,s as ContainedLoadingIndicatorController,P as LinearProgressIndicator,C as LinearWavyProgressIndicator,p as LoadingIndicator,c as LoadingIndicatorController,y as PlainTooltip,L as PlainTooltipController,u as RichTooltip,B as RichTooltipController,b as Snackbar,m as SnackbarController,k as SnackbarHost,x as SnackbarHostController,T as SnackbarQueue,R as TooltipController,S as createSnackbarQueue};
|
|
1
|
+
import{Badge as t,BadgedBox as e}from"./badge";import{ContainedLoadingIndicator as i,ContainedLoadingIndicatorController as s,LoadingIndicator as p,LoadingIndicatorController as c}from"./loading";import{CircularProgressIndicator as d,CircularWavyProgressIndicator as g,LinearProgressIndicator as P,LinearWavyProgressIndicator as C}from"./progress";import{Snackbar as b,SnackbarController as m,SnackbarHost as k,SnackbarHostController as x,SnackbarQueue as T,createSnackbarQueue as S}from"./snackbar";import{PlainTooltip as y,PlainTooltipController as L,RichTooltip as u,RichTooltipController as B,TooltipController as R}from"./tooltip";import"./feedback.css";export{t as Badge,e as BadgedBox,d as CircularProgressIndicator,g as CircularWavyProgressIndicator,i as ContainedLoadingIndicator,s as ContainedLoadingIndicatorController,P as LinearProgressIndicator,C as LinearWavyProgressIndicator,p as LoadingIndicator,c as LoadingIndicatorController,y as PlainTooltip,L as PlainTooltipController,u as RichTooltip,B as RichTooltipController,b as Snackbar,m as SnackbarController,k as SnackbarHost,x as SnackbarHostController,T as SnackbarQueue,R as TooltipController,S as createSnackbarQueue};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{defineDomComponent as v}from"..";import{DomController as G}from"../dom/client";import{applySpringMotion as V,subscribeMotionFrames as k}from"../motion";import{
|
|
1
|
+
import{defineDomComponent as v}from"..";import{DomController as G}from"../dom/client";import{applySpringMotion as V,subscribeMotionFrames as k}from"../motion";import{Morph as S,Path as E,Point as H,cubicsToPath as U,formatPathCoordinate as m}from"../shape";import{circleShape as B,cookie4SidedShape as X,cookie9SidedShape as z,ovalShape as J,pentagonShape as Y,pillShape as Q,softBurstShape as b,sunnyShape as W}from"../shape/material-shapes";import{checkArgument as j}from"../util";import{observeVisibility as K,whenInDocument as Z}from"./observe";import"./feedback.css";const ee=38/48,y=650,ne=297,p=0.6,te=200,ie=4666,C=90,oe=-180,re=50,ae=1,se=1e-3,de=250,f="Loading",ue="--_cw-LoadingIndicator-value",I="rotate",le="(prefers-reduced-motion: reduce)",u="cw-LoadingIndicator",P="cw-ContainedLoadingIndicator",ce=`${u} ${P}`,_=["error","primary","secondary","surface","tertiary"],he={},L=/* @__PURE__ */new WeakMap();function l(t,e){return t!==void 0&&Number.isFinite(t)?t:e;}function O(t){const e=l(t.min,0),n=Math.max(e,l(t.max,1)),i=Math.min(n,Math.max(e,l(t.value,e)));return{min:e,max:n,value:i,ratio:n===e?0:(i-e)/(n-e),indeterminate:t.indeterminate===!0||t.value===void 0};}function me(t){let e=1;for(const n of t){const i=n.calculateBounds(),o=n.calculateMaxBounds();e=Math.min(e,Math.max((i[2]-i[0])/(o[2]-o[0]),(i[3]-i[1])/(o[3]-o[1])));}return e*ee;}function M(t,e){const n=t.map(o=>o.normalized()),i=[];for(let o=1;o<n.length;o++)i.push(new S(n[o-1],n[o]));return e&&i.push(new S(n[n.length-1],n[0])),{morphs:i,scale:me(t)};}function A(t,e){let n=t===void 0?he:L.get(t);return n===void 0&&(j(t.length>=2,"a loading indicator requires at least two polygons"),n={},L.set(t,n)),e?(n.circular??=M(t??[b(),z(),Y(),Q(),W(),X(),J()],!0),n.circular):(n.open??=M(t??[B().transformed((i,o)=>new H(i,o).rotate(18)),b()],!1),n.open);}function pe(t){const e=Math.sqrt(te),n=e*Math.sqrt(1-p**2),i=t/1e3;return 1-Math.exp(-p*e*i)*(Math.cos(n*i)+p*e/n*Math.sin(n*i));}function c(t,e){const n=t.morphs,i=n.length*e;return{morph:n[Math.min(n.length-1,Math.floor(i))],progress:e===1?1:i%1,rotation:e*oe};}function g(t,e){const n=t.morphs,i=Math.floor(e/y),o=e-i*y,r=o<ne,s=r?i:i+1,d=r?pe(o):0;return{morph:n[s%n.length],progress:d,rotation:(s+1)*C+d*C+e/ie*360};}function x(t,e,n){const i=t.morph.asCubics(t.progress),o=m(e);let r=1/0,s=1/0,d=-1/0,h=-1/0;for(const $ of i){const a=$.points;r=Math.min(r,a[0],a[2],a[4],a[6]),s=Math.min(s,a[1],a[3],a[5],a[7]),d=Math.max(d,a[0],a[2],a[4],a[6]),h=Math.max(h,a[1],a[3],a[5],a[7]);}return{d:U(i,n).toSvgPathData(),transform:`matrix(${o} 0 0 ${o} ${m(0.5-e*(r+d)/2)} ${m(0.5-e*(s+h)/2)})`};}function D(t){return t!==void 0&&_.includes(t)?`_cw-ContainedLoadingIndicator-${t}`:void 0;}function R(t){return t===void 0||_.includes(t)?void 0:t;}function T(t){return typeof t=="number"?`${Math.max(0,l(t,0))}px`:t;}function w(t){return t!==void 0&&Number.isFinite(t)&&t>0?`${t}px`:void 0;}function N(t,e,n){return<svg aria-hidden="true"viewBox="0 0 1 1">
|
|
2
2
|
<g class="_cw-LoadingIndicator-rotation"style={n===void 0?void 0:{[I]:n}}>
|
|
3
3
|
<path class="cw-LoadingIndicator-shape"d={t}transform={e}/>
|
|
4
4
|
</g>
|
|
5
|
-
</svg
|
|
5
|
+
</svg>;}function q(t,e,n){const i=O(e),o=A(e.polygons,i.indeterminate),r=i.indeterminate?g(o,0):c(o,i.ratio),s=x(r,o.scale,new E()),d=n?D(e.containerColor):void 0;return<div role="progressbar"{...t}aria-label={"aria-label"in t?t["aria-label"]:e.label??f}aria-valuemax={i.indeterminate?void 0:i.max}aria-valuemin={i.indeterminate?void 0:i.min}aria-valuenow={i.indeterminate?void 0:i.value}classList={{...t.classList,...(d===void 0?void 0:{[d]:!0}),...(e.color===void 0?void 0:{[`_cw-LoadingIndicator-${e.color}`]:!0}),[P]:n,[u]:!0,[`${u}-determinate`]:!i.indeterminate,[`${u}-indeterminate`]:i.indeterminate}}style={{...t.style,"--_cw-ContainedLoadingIndicator-containerColor":n?R(e.containerColor):void 0,"--_cw-ContainedLoadingIndicator-containerShape":n?T(e.containerShape):void 0,"--cw-Feedback-loading-size":w(e.size)}}>{N(s.d,s.transform,`${r.rotation}deg`)}</div>;}class F extends G{#C;#L;#M;#m;#p;#f;#g;#a;#S;#i;#n;#s;#t;#d;#e;#u;#l;#o;#c;#b;constructor(e,n=!1){super(e,{styleElementIsFunction:!0}),this.#C=n,this.#L="attr:aria-label"in e,this.#M=new E(),this.#m=null,this.#p=null,this.#f="",this.#g="",this.#a=void 0,this.#S=0,this.#i=null,this.#n=null,this.#s=0,this.#t=void 0,this.#d=-1/0,this.#e=void 0,this.#u=!0,this.#l=!1,this.#o=void 0,this.#c=[],this.#b=!1;}applyComponentProps(){const e=super.readProps(["color","indeterminate","label","max","min","paused","polygons","size","value"]);e.colorChanged&&super.setClass("color",e.color===void 0?void 0:`_cw-LoadingIndicator-${e.color}`),e.sizeChanged&&super.setStyle("--cw-Feedback-loading-size",w(e.size)),e.labelChanged&&!this.#L&&super.setAttribute("aria-label",e.label??f),(e.indeterminateChanged||e.maxChanged||e.minChanged||e.polygonsChanged||e.valueChanged)&&this.#E(O(e),e.polygons,e.polygonsChanged),this.#r();}#E(e,n,i){const o=this.#i,r=this.#y();if(this.#i=e,super.setClass(`${u}-determinate`,!e.indeterminate),super.setClass(`${u}-indeterminate`,e.indeterminate),super.setAttribute("aria-valuemax",e.indeterminate?void 0:e.max),super.setAttribute("aria-valuemin",e.indeterminate?void 0:e.min),super.setAttribute("aria-valuenow",e.indeterminate?void 0:e.value),!i&&o?.indeterminate===e.indeterminate){e.indeterminate||this.#I(r,e.ratio);return;}this.#n=A(n,e.indeterminate),this.#a=void 0,this.#s=0,this.#t=void 0,this.#d=-1/0,this.#e?.cancel(),this.#e=void 0,this.#h(e.indeterminate?g(this.#n,0):c(this.#n,e.ratio));}#I(e,n){const i=this.styleElement;i!==null&&(this.#e===void 0?this.#e=V(i,ue,e,n,{damping:ae,stiffness:re,threshold:se}):this.#e.retarget(n));}#y(){return Math.min(1,Math.max(0,this.#e?.value??this.#i?.ratio??0));}#r(){const e=this.styleElement?.ownerDocument.defaultView??null,n=this.#i;if(e!==null&&this.#u&&(this.#e?.playState==="running"||n?.indeterminate===!0&&!this.#l&&super.readProp("paused",!0)[0]!==!0)){this.#o??=k(e,o=>this.#P(o));return;}this.#o?.(),this.#o=void 0,this.#t=void 0,n?.indeterminate===!1&&this.#n!==null&&this.#h(c(this.#n,this.#y()));}#P(e){const n=this.#i,i=this.#n;if(!(n===null||i===null)){if(!n.indeterminate){this.#h(c(i,this.#y())),this.#e?.playState!=="running"&&this.#r();return;}this.#t!==void 0&&e-this.#t<=de&&(this.#s+=Math.max(0,e-this.#t)),this.#t=e,this.#h(g(i,this.#s));}}#h(e){const n=this.#m,i=this.#p,o=this.#i?.indeterminate===!0?this.#d=Math.max(this.#d,e.rotation):e.rotation;if(n===null||i===null||(i.style.setProperty(I,`${o}deg`),e.morph===this.#a&&e.progress===this.#S))return;const r=x(e,this.#n.scale,this.#M);this.#a=e.morph,this.#S=e.progress,r.d!==this.#f&&(this.#f=r.d,n.setAttribute("d",r.d)),r.transform!==this.#g&&(this.#g=r.transform,n.setAttribute("transform",r.transform));}onStyleElementChanged(e){super.onStyleElementChanged(e),this.#v(),e!==null&&Z(e,n=>{!this.#b&&this.styleElement===e&&this.#_(e,n);});}onControllerCleanup(){this.#b=!0,this.#v(),this.#e?.cancel(),super.onControllerCleanup();}#_(e,n){const i=n.matchMedia(le),o=()=>{this.#l=i.matches,this.#r();},r=K(e,s=>{this.#u=s,this.#r();});this.#l=i.matches,this.#u=!0,i.addEventListener("change",o),this.#c.push(()=>i.removeEventListener("change",o)),r!==void 0&&this.#c.push(r),this.#r();}#v(){this.#o?.(),this.#o=void 0,this.#t=void 0;for(const e of this.#c.splice(0))e();}render(){const e=<div aria-label={f}class={this.#C?ce:u}role="progressbar">
|
|
6
6
|
{N()}
|
|
7
|
-
</div>;return this.#m=e.querySelector("path"),this.#p=e.querySelector("g"),e}}const
|
|
7
|
+
</div>;return this.#m=e.querySelector("path"),this.#p=e.querySelector("g"),e;}}const Ee=/* @__PURE__ */v(()=>(t,e)=>q(t,e,!1),()=>F);class fe extends F{constructor(e){super(e,!0);}applyComponentProps(){const e=super.readProps(["containerColor","containerShape"]);super.applyComponentProps(),e.containerColorChanged&&(super.setClass("containerColor",D(e.containerColor)),super.setStyle("--_cw-ContainedLoadingIndicator-containerColor",R(e.containerColor))),e.containerShapeChanged&&super.setStyle("--_cw-ContainedLoadingIndicator-containerShape",T(e.containerShape));}}const Ie=/* @__PURE__ */v(()=>(t,e)=>q(t,e,!0),()=>fe);export{Ie as ContainedLoadingIndicator,fe as ContainedLoadingIndicatorController,Ee as LoadingIndicator,F as LoadingIndicatorController};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const u
|
|
1
|
+
const u=/* @__PURE__ */new WeakMap(),v=/* @__PURE__ */new WeakMap(),f=/* @__PURE__ */new WeakMap(),l=["opacity","scale"];function O(t,r){const n=t.getAnimations().filter(e=>l.includes(e.transitionProperty));n.length===0?r():Promise.allSettled(n.map(e=>e.finished)).then(r);}function w(t,r){const n=t.ownerDocument.defaultView;if(n!==null){r(n);return;}queueMicrotask(()=>{const e=t.ownerDocument.defaultView;e!==null&&r(e);});}function p(t,r){const n=t.ownerDocument.defaultView;let e=n===null?void 0:u.get(n);if(!(n===null||typeof n.IntersectionObserver!="function")){if(e===void 0){const o=/* @__PURE__ */new Map();e={observer:new n.IntersectionObserver(i=>{for(const s of i)o.get(s.target)?.(s.isIntersecting);}),listeners:o},u.set(n,e);}return e.listeners.set(t,r),e.observer.observe(t),b(e,t,r);}}function E(t,r){const n=t.ownerDocument.defaultView;let e=n===null?void 0:v.get(n);if(!(n===null||typeof n.ResizeObserver!="function")){if(e===void 0){const o=/* @__PURE__ */new Map();e={observer:new n.ResizeObserver(i=>{for(const s of i)o.get(s.target)?.(s.contentBoxSize[0]?.inlineSize??s.contentRect.width);}),listeners:o},v.set(n,e);}return e.listeners.set(t,r),e.observer.observe(t),b(e,t,r);}}function M(t,r,n){const e=t.ownerDocument.defaultView;let o=e===null?void 0:f.get(e);if(!(e===null||typeof e.MutationObserver!="function")){if(o===void 0){const i=/* @__PURE__ */new Map();o={observer:new e.MutationObserver(s=>{const d=/* @__PURE__ */new Set();for(const a of s)d.add(c(i,a.target));for(const a of d)a?.();}),listeners:i,options:/* @__PURE__ */new Map()},f.set(e,o);}return o.listeners.set(t,n),o.options.set(t,r),o.observer.observe(t,r),()=>{const i=o;if(i.listeners.get(t)===n){i.listeners.delete(t),i.options.delete(t),i.observer.disconnect();for(const[s,d]of i.options)i.observer.observe(s,d);}};}}function c(t,r){for(let n=r;n!==null;n=n.parentNode){const e=t.get(n);if(e!==void 0)return e;}}function b(t,r,n){return()=>{t.listeners.get(r)===n&&(t.listeners.delete(r),t.observer.unobserve(r));};}export{E as observeInlineSize,M as observeMutations,p as observeVisibility,O as whenExitMotionFinished,w as whenInDocument};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import{defineDomComponent as P}from"..";import{DomController as re}from"../dom/client";import{CornerRounding as z,Morph as te,Path as ne,Shapes as x,morphToPath as se}from"../shape";import{observeInlineSize as oe,observeVisibility as ie,whenInDocument as ae}from"./observe";import"./feedback.css";const y=4,de=4,b=3,ce=40,ue=20,M=240,D=40,le=48,pe=4,me=4,ge=15,Pe=5,he=16,R=[.1
|
|
1
|
+
import{defineDomComponent as P}from"..";import{DomController as re}from"../dom/client";import{CornerRounding as z,Morph as te,Path as ne,Shapes as x,morphToPath as se}from"../shape";import{observeInlineSize as oe,observeVisibility as ie,whenInDocument as ae}from"./observe";import"./feedback.css";const y=4,de=4,b=3,ce=40,ue=20,M=240,D=40,le=48,pe=4,me=4,ge=15,Pe=5,he=16,R=[0.1,0.95],k=4,p="cw-Progress",fe="cw-Progress-determinate",ve="cw-Progress-indeterminate",Se="_cw-Progress-paused",h="_cw-Progress-waving",T="_cw-Progress-flattening",O="cw-LinearProgressIndicator",N="cw-LinearWavyProgressIndicator",G="cw-CircularProgressIndicator",V="cw-CircularWavyProgressIndicator",c=/* @__PURE__ */new Map();function d(r,e){return r!==void 0&&Number.isFinite(r)?r:e;}function a(r,e){return r!==void 0&&Number.isFinite(r)&&r>0?r:e;}function u(r){return`${r}px`;}function $(r){return r===void 0?void 0:`${r}s`;}function l(r){const e=d(r.min,0),t=Math.max(e,d(r.max,1)),n=Math.min(t,Math.max(e,d(r.value,e)));return{min:e,max:t,value:n,ratio:t===e?0:(n-e)/(t-e),indeterminate:r.indeterminate===!0||r.value===void 0};}function X(r){return r===void 0?void 0:`_cw-Progress-${r}`;}function H(r){return r.indeterminate?ve:fe;}function J(r,e){return r!==void 0?Math.min(1,Math.max(0,d(r,0))):e.indeterminate||e.ratio>R[0]&&e.ratio<R[1]?1:0;}function U(r,e,t){const n=e===void 0?t:d(e,0);return n>0?r/n:void 0;}function I(r,e){return Math.max(k,a(r,e.indeterminate?ue:ce));}function j(r,e,t,n){const s=e/2,o=Math.floor((Math.max(0,r)+2*e)/s),i=t/2+b,m=2*b*n,L=new ne().moveTo(0,i);for(let g=0;g<o;g++){const _=g*s,W=_+s,A=i+(g%2===0?m:-m)*2/3;L.cubicTo(_+s/3,A,W-s/3,A,W,i);}return{d:L.toSvgPathData(),length:o*s};}function f(r,e){const t=e/2/(r-e);return`${-t} ${-t} ${1+2*t} ${1+2*t}`;}function w(r,e){return Math.min(r/2,a(e,pe));}function E(r,e,t,n){return{"--_cw-Progress-circularGap":`${(Math.max(0,d(t,me))+e)/(Math.PI*(n?r-e:r))}`,"--_cw-Progress-size":u(r),"--_cw-Progress-strokeWidth":`${e/(r-e)}`};}function Ce(r,e,t){return Math.max(Pe,Math.round(Math.PI*(r-e)/t));}function be(r){let e=c.get(r);return e===void 0?(e=new te(x.circle(r).normalized(),x.star(r,1,0.75,new z(0.35,0.4),new z(0.5)).normalized()),c.size>=he&&c.delete(c.keys().next().value)):c.delete(r),c.set(r,e),e;}function B(r,e){return se(be(r),e,{repeatPath:!0,startAngle:270}).toSvgPathData();}function F(){return<div class="cw-Progress-track">
|
|
2
2
|
<span class="_cw-Progress-trackStart"/>
|
|
3
3
|
<span class="_cw-Progress-trackMiddle"/>
|
|
4
4
|
<span class="_cw-Progress-trackEnd"/>
|
|
5
5
|
<span class="cw-LinearProgressIndicator-secondaryIndicator"/>
|
|
6
6
|
<span class="cw-LinearProgressIndicator-indicator"/>
|
|
7
7
|
<span class="cw-Progress-stopIndicator"/>
|
|
8
|
-
</div
|
|
8
|
+
</div>;}function Z(r,e){return<div class="cw-Progress-track">
|
|
9
9
|
<span class="_cw-Progress-trackStart"/>
|
|
10
10
|
<span class="_cw-Progress-trackMiddle"/>
|
|
11
11
|
<span class="_cw-Progress-trackEnd"/>
|
|
@@ -14,22 +14,22 @@ import{defineDomComponent as P}from"..";import{DomController as re}from"../dom/c
|
|
|
14
14
|
<path class="cw-LinearWavyProgressIndicator-indicator"d={r}pathLength={e}/>
|
|
15
15
|
</svg>
|
|
16
16
|
<span class="cw-Progress-stopIndicator"/>
|
|
17
|
-
</div
|
|
17
|
+
</div>;}function q(r){return<svg aria-hidden="true"viewBox={r}>
|
|
18
18
|
<g class="_cw-Progress-rotation">
|
|
19
19
|
<circle class="cw-CircularProgressIndicator-track"cx="0.5"cy="0.5"pathLength="1"r="0.5"transform="rotate(-90 0.5 0.5)"/>
|
|
20
20
|
<circle class="cw-CircularProgressIndicator-indicator"cx="0.5"cy="0.5"pathLength="1"r="0.5"transform="rotate(-90 0.5 0.5)"/>
|
|
21
21
|
</g>
|
|
22
|
-
</svg
|
|
22
|
+
</svg>;}function Y(r,e){return<svg aria-hidden="true"viewBox={r}>
|
|
23
23
|
<g class="_cw-Progress-rotation">
|
|
24
24
|
<circle class="cw-CircularWavyProgressIndicator-track"cx="0.5"cy="0.5"pathLength="1"r="0.5"transform="rotate(-90 0.5 0.5)"/>
|
|
25
25
|
<path class="cw-CircularWavyProgressIndicator-indicator"d={e}pathLength="2"/>
|
|
26
26
|
</g>
|
|
27
|
-
</svg
|
|
27
|
+
</svg>;}function v(r,e,t,n,s){const o=l(e),i=X(e.color);return<div{...r}aria-label={e.label??r["aria-label"]}aria-valuemax={o.max}aria-valuemin={o.min}aria-valuenow={o.indeterminate?void 0:o.value}classList={{...r.classList,...t,...(i===void 0?void 0:{[i]:!0}),[p]:!0,[H(o)]:!0}}role="progressbar"style={{...r.style,...n,"--cw-Progress-value":o.indeterminate?void 0:`${o.ratio}`}}>{s()}</div>;}class S extends re{#e;#t;#n;constructor(e){super(e,{styleElementIsFunction:!0}),this.#e=null,this.#t=[],this.#n=!1;}get progressState(){return this.#e??l({});}applyComponentProps(){const e=super.readProps(["color","indeterminate","label","max","min","value"]),t=e.indeterminateChanged||e.maxChanged||e.minChanged||e.valueChanged;if(e.colorChanged&&super.setClass("color",X(e.color)),e.labelChanged&&(e.label!==void 0||e.labelPrevious!==void 0)&&super.setAttribute("aria-label",e.label),t){const n=l(e);this.#e=n,super.setClass("state",H(n)),super.setStyle("--cw-Progress-value",n.indeterminate?void 0:n.ratio),super.setAttribute("aria-valuemax",n.max),super.setAttribute("aria-valuemin",n.min),super.setAttribute("aria-valuenow",n.indeterminate?void 0:n.value);}this.applyIndicatorProps(this.progressState,t);}observe(e){const t=ie(e,n=>{super.setClass(Se,!n);});return t===void 0?[]:[t];}onStyleElementChanged(e){super.onStyleElementChanged(e),this.#r(),e!==null&&ae(e,()=>{!this.#n&&this.styleElement===e&&(this.#t=this.observe(e));});}onControllerCleanup(){this.#n=!0,this.#r(),super.onControllerCleanup();}#r(){for(const e of this.#t.splice(0))e();}}function C(r){const e=r.stopSize;return{"--_cw-Progress-gap":u(Math.max(0,d(r.gapSize,de))),"--_cw-Progress-thickness":u(a(r.size,y)),"--cw-Feedback-progress-stopSize":e===void 0?void 0:u(Math.max(0,d(e,0)))};}class ye extends S{applyIndicatorProps(){const e=super.readProps(["gapSize","size","stopSize"]);if(e.gapSizeChanged||e.sizeChanged||e.stopSizeChanged)for(const[t,n]of Object.entries(C(e)))super.setStyle(t,n);}render(){return<div class={`${p} ${O}`}role="progressbar">
|
|
28
28
|
{F()}
|
|
29
|
-
</div
|
|
29
|
+
</div>;}}const De=/* @__PURE__ */P(()=>(r,e)=>v(r,e,{[O]:!0},C(e),F),()=>ye);function K(r,e){const t=I(r.wavelength,e),n=U(t,r.waveSpeed,t);return{amplitude:J(r.amplitude,e),style:{"--_cw-LinearWavyProgressIndicator-amplitude":u(b),"--_cw-LinearWavyProgressIndicator-wavelength":u(t),"--_cw-Progress-phaseDuration":$(n)}};}class Ie extends S{#e;#t;#n;#r;constructor(e){super(e),this.#e=[],this.#t=void 0,this.#n="",this.#r=void 0;}applyIndicatorProps(e,t){const n=super.readProps(["amplitude","gapSize","size","stopSize","waveSpeed","wavelength"]);if(n.gapSizeChanged||n.sizeChanged||n.stopSizeChanged)for(const[s,o]of Object.entries(C(n)))super.setStyle(s,o);if(t||n.amplitudeChanged||n.sizeChanged||n.waveSpeedChanged||n.wavelengthChanged){const s=K(n,e);this.#r!==void 0&&s.amplitude!==this.#r&&super.setClass(T,s.amplitude<this.#r),this.#r=s.amplitude,super.setClass(h,s.amplitude>0);for(const[o,i]of Object.entries(s.style))super.setStyle(o,i);this.#s();}}observe(e){const t=oe(e,n=>{this.#t=n,this.#s();});return t===void 0?super.observe(e):[...super.observe(e),t];}#s(){const e=j(this.#t??M,I(super.readProp("wavelength",!0)[0],this.progressState),a(super.readProp("size",!0)[0],y),this.#r??0);if(e.d!==this.#n){this.#n=e.d;for(const t of this.#e)t.setAttribute("d",e.d),t.setAttribute("pathLength",`${e.length}`);}}render(){const e=<div class={`${p} ${N}`}role="progressbar">
|
|
30
30
|
{Z()}
|
|
31
|
-
</div>;return this.#e=Array.from(e.querySelectorAll("path")),e}}function we(r,e){const t=l(e),n=K(e,t),s=j(M,I(e.wavelength,t),a(e.size,y),n.amplitude);return v(r,e,{[N]:!0,[h]:n.amplitude>0},{...C(e),...n.style},()=>Z(s.d,s.length))}const ke
|
|
31
|
+
</div>;return this.#e=Array.from(e.querySelectorAll("path")),e;}}function we(r,e){const t=l(e),n=K(e,t),s=j(M,I(e.wavelength,t),a(e.size,y),n.amplitude);return v(r,e,{[N]:!0,[h]:n.amplitude>0},{...C(e),...n.style},()=>Z(s.d,s.length));}const ke=/* @__PURE__ */P(()=>we,()=>Ie);class Ee extends S{#e;constructor(e){super(e),this.#e=null;}applyIndicatorProps(){const e=super.readProps(["gapSize","size","strokeWidth"]);if(e.gapSizeChanged||e.sizeChanged||e.strokeWidthChanged){const t=a(e.size,D),n=w(t,e.strokeWidth),s=E(t,n,e.gapSize,!1);for(const[o,i]of Object.entries(s))super.setStyle(o,i);this.#e?.setAttribute("viewBox",f(t,n));}}render(){const e=<div class={`${p} ${G}`}role="progressbar">
|
|
32
32
|
{q()}
|
|
33
|
-
</div>;return this.#e=e.querySelector("svg"),e}}function Le(r,e){const t=a(e.size,D),n=w(t,e.strokeWidth);return v(r,e,{[G]:!0},E(t,n,e.gapSize,!1),()=>q(f(t,n)))}const Te
|
|
33
|
+
</div>;return this.#e=e.querySelector("svg"),e;}}function Le(r,e){const t=a(e.size,D),n=w(t,e.strokeWidth);return v(r,e,{[G]:!0},E(t,n,e.gapSize,!1),()=>q(f(t,n)));}const Te=/* @__PURE__ */P(()=>Le,()=>Ee);function Q(r,e){const t=a(r.size,le),n=w(t,r.strokeWidth),s=Math.max(k,a(r.wavelength,ge)),o=Ce(t,n,s);return{size:t,strokeWidth:n,amplitude:J(r.amplitude,e),vertexCount:o,cycle:U(o*s,r.waveSpeed,s)};}function ee(r,e){return{...E(r.size,r.strokeWidth,e,!0),"--_cw-Progress-phaseDuration":$(r.cycle)};}class _e extends S{#e;#t;#n;#r;constructor(e){super(e),this.#e=null,this.#t=null,this.#n="",this.#r=void 0;}applyIndicatorProps(e,t){const n=super.readProps(["amplitude","gapSize","size","strokeWidth","waveSpeed","wavelength"]);if(!t&&!n.amplitudeChanged&&!n.gapSizeChanged&&!n.sizeChanged&&!n.strokeWidthChanged&&!n.waveSpeedChanged&&!n.wavelengthChanged)return;const s=Q(n,e),o=B(s.vertexCount,s.amplitude);this.#r!==void 0&&s.amplitude!==this.#r&&super.setClass(T,s.amplitude<this.#r),this.#r=s.amplitude,super.setClass(h,s.amplitude>0);for(const[i,m]of Object.entries(ee(s,n.gapSize)))super.setStyle(i,m);this.#e?.setAttribute("viewBox",f(s.size,s.strokeWidth)),o!==this.#n&&(this.#n=o,this.#t?.setAttribute("d",o));}render(){const e=<div class={`${p} ${V}`}role="progressbar">
|
|
34
34
|
{Y()}
|
|
35
|
-
</div>;return this.#e=e.querySelector("svg"),this.#t=e.querySelector("path"),e}}function We(r,e){const t=Q(e,l(e));return v(r,e,{[V]:!0,[h]:t.amplitude>0},ee(t,e.gapSize),()=>Y(f(t.size,t.strokeWidth),B(t.vertexCount,t.amplitude)))}const Oe
|
|
35
|
+
</div>;return this.#e=e.querySelector("svg"),this.#t=e.querySelector("path"),e;}}function We(r,e){const t=Q(e,l(e));return v(r,e,{[V]:!0,[h]:t.amplitude>0},ee(t,e.gapSize),()=>Y(f(t.size,t.strokeWidth),B(t.vertexCount,t.amplitude)));}const Oe=/* @__PURE__ */P(()=>We,()=>_e);export{Te as CircularProgressIndicator,Oe as CircularWavyProgressIndicator,De as LinearProgressIndicator,ke as LinearWavyProgressIndicator};
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import{For as X,Show as S,createSignal as w,children as I,untrack as k}from"solid-js";import{insert as v}from"solid-js/web";import{defineDomComponent as D}from"..";import{Button as Q,IconButton as F}from"../action";import{ELEVATION_SHADOW_CSS_CLASS as A}from"../container/elevation-shadow";import{DomController as H}from"../dom/client";import{isFocusWithin as V}from"./focus";import{whenExitMotionFinished as O}from"./observe";import"../container/elevation-shadow.css";import"./feedback.css";const W=4e3,K=100,N="Dismiss",M="cw-Snackbar",R="cw-Snackbar-open",C="_cw-Snackbar-closing",_="_cw-Snackbar-actionOnNewLine",L
|
|
1
|
+
import{For as X,Show as S,createSignal as w,children as I,untrack as k}from"solid-js";import{insert as v}from"solid-js/web";import{defineDomComponent as D}from"..";import{Button as Q,IconButton as F}from"../action";import{ELEVATION_SHADOW_CSS_CLASS as A}from"../container/elevation-shadow";import{DomController as H}from"../dom/client";import{isFocusWithin as V}from"./focus";import{whenExitMotionFinished as O}from"./observe";import"../container/elevation-shadow.css";import"./feedback.css";const W=4e3,K=100,N="Dismiss",M="cw-Snackbar",R="cw-Snackbar-open",C="_cw-Snackbar-closing",_="_cw-Snackbar-actionOnNewLine",L=/* @__PURE__ */new WeakMap(),g=/* @__PURE__ */new WeakMap();function U(s,e){return s!==void 0&&Number.isFinite(s)?Math.max(0,s):e?0:W;}function B(s,e){let n=L.get(s);const t=s.defaultView,i={};t===null||s.body===null||e===""||(n===void 0&&(n=s.createElement("div"),n.className="_cw-Snackbar-announcer",n.setAttribute("aria-atomic","true"),n.setAttribute("aria-live","polite"),n.setAttribute("role","status"),L.set(s,n)),n.isConnected||s.body.append(n),n.textContent="",g.set(n,i),t.setTimeout(()=>{g.get(n)===i&&(n.textContent=e);},K));}function j(s){return Array.from(s.querySelectorAll(".cw-Snackbar-message, .cw-Snackbar-action"),e=>e.textContent?.trim()??"").filter(e=>e!=="").join(" ");}function $(s){return typeof s=="object"&&s!==null&&"message"in s;}class z{#s;#e;#n;#t;constructor(){this.#s=/* @__PURE__ */new Set(),this.#e=[],this.#n=null,this.#t=1;}get current(){return this.#n;}get pendingCount(){return this.#e.length;}subscribe(e){return this.#s.add(e),()=>this.#s.delete(e);}enqueue(e,n={}){const t=$(e)?e:{...n,message:e},i=t.id??`cw-snackbar-${this.#t++}`,o={...t,id:i},J=o.dedupeKey??i,E=(this.#n===null?this.#e:[this.#n,...this.#e]).find(y=>(y.dedupeKey??y.id)===J);return E!==void 0?E.id:(this.#n===null?this.#n=o:this.#e.push(o),this.#i(),o.id);}dismiss(e,n="programmatic"){const t=this.#e.findIndex(o=>o.id===e),i=this.#n;return i!==null&&(e===void 0||i.id===e)?(this.#n=this.#e.shift()??null,this.#i(n,i.id),!0):t<0?!1:(this.#e.splice(t,1),this.#i(n,e),!0);}clear(){const e=this.#n;e===null&&this.#e.length===0||(this.#n=null,this.#e.length=0,this.#i(e===null?void 0:"programmatic",e?.id));}#i(e,n){for(const t of this.#s)t(e,n);}}function le(){return new z();}function x(s){return[<S when={s.action()!==void 0||s.actionLabel()!==void 0}>
|
|
2
2
|
<Q class="cw-Snackbar-action"size="sm"variant="text"onClick={s.onAction}>{s.action()??s.actionLabel()}</Q>
|
|
3
3
|
</S>,<S when={s.dismissible()}>
|
|
4
4
|
<F attr:aria-label={s.dismissLabel()}class="cw-Snackbar-dismiss"name="close"size="sm"onClick={s.onDismiss}/>
|
|
5
|
-
</S>]}class G extends H{#s;#e;#n;#t;#i;#r;#a;#u;#d;#h;#p;#b;#m;#c;constructor(e){super(e,{styleElementIsFunction:!0}),this.#s="open"in e,this.#e=null,this.#n=!1,this.#t=!1,this.#i=!1,this.#r=!1,this.#a=0,this.#u=0,this.#d=void 0,this.#h=void 0,this.#p=0,this.#b=!1,this.#m=0,this.#c=!1}applyComponentProps(){const e=super.readProps(["actionLabel","actionOnNewLine","duration","open","pauseOnHover","request"]),n=e.request,t=this.#e?.()!==void 0||(n?.actionLabel??e.actionLabel)!==void 0,i=e.requestChanged&&e.requestPrevious!==void 0&&n!==void 0;if((e.actionOnNewLineChanged||e.requestChanged)&&super.setClass(_,(n?.actionOnNewLine??e.actionOnNewLine)===!0),i&&this.#t&&(this.#o(),k(()=>this.props.onDismiss?.("replacement",void 0,this))),e.durationChanged||e.requestChanged||t!==this.#n){const o=U(n?.duration??e.duration,t);this.#n=t,o!==this.#a&&(this.#o(),this.#a=o,this.#u=o,this.#l())}(e.pauseOnHoverChanged||e.requestChanged)&&!this.#S()&&this.#c&&(this.#c=!1,this.#l()),(e.openChanged||e.requestChanged)&&this.#f(this.#s?e.open!==!1:i||!this.#i,i)}dismiss(e,n="programmatic"){!this.#t||this.#i||this.#r||(this.#i=!0,this.#o(),this.#s||this.#f(!1,!1),k(()=>{this.props.onOpenChange?.(!1,e,n),this.props.onDismiss?.(n,e,this)}))}#f(e,n){const t=this.styleElement,i=!e&&this.#t&&t?.isConnected===!0;e===this.#t&&!n||(this.#t=e,e&&(this.#i=!1),this.#u=this.#a,this.#m++,super.setClass(C,i),super.setClass(R,e),super.setAttribute("hidden",!e),super.setAttribute("inert",!e),this.#o(),i&&this.#y(t),!(!e||t===null)&&(this.#l(),queueMicrotask(()=>{this.#t&&!this.#r&&this.styleElement===t&&B(t.ownerDocument,j(t))})))}#y(e){const n=this.#m;O(e,()=>{n===this.#m&&super.setClass(C,!1)})}#S(){return(super.readProp("request",!0)[0]?.pauseOnHover??super.readProp("pauseOnHover",!0)[0])!==!1}#l(){const e=this.styleElement?.ownerDocument.defaultView;this.#o(),!(this.#r||!this.#t||this.#i||this.#c||this.#a===0||e===null||e===void 0)&&(this.#h=e,this.#p=e.performance.now(),this.#d=e.setTimeout(()=>{this.#d=void 0,this.#u=0,this.dismiss(void 0,"timeout")},this.#u))}#o(){const e=this.#h;this.#d===void 0||e===void 0||(e.clearTimeout(this.#d),this.#u=Math.max(0,this.#u-(e.performance.now()-this.#p)),this.#d=void 0,this.#h=void 0)}#k(){const e=this.styleElement,n=this.#S()&&(this.#b||e!==null&&V(e));n!==this.#c&&(this.#c=n,n?this.#o():this.#l())}#C=e=>{(this.props.request?.onAction??this.props.onAction)?.(e,this),e.defaultPrevented||this.dismiss(e,"action")};#L=e=>this.dismiss(e,"dismiss");#g=e=>{e.key!=="Escape"||e.defaultPrevented||!this.#t||(e.preventDefault(),this.dismiss(e,"escape"))};#v=e=>{this.#b=e.type==="pointerenter",this.#k()};#E=()=>{(this.styleElement?.ownerDocument.defaultView?.queueMicrotask??queueMicrotask)(()=>this.#k())};onStyleElementChanged(e){super.onStyleElementChanged(e),this.#o(),e!==null&&(e.ownerDocument.defaultView?.queueMicrotask??queueMicrotask)(()=>{this.styleElement===e&&this.#l()})}onControllerCleanup(){this.#r=!0,this.#o(),super.onControllerCleanup()}render(e){const n=<div class={`${M} ${A}`}hidden inert>
|
|
5
|
+
</S>];}class G extends H{#s;#e;#n;#t;#i;#r;#a;#u;#d;#h;#p;#b;#m;#c;constructor(e){super(e,{styleElementIsFunction:!0}),this.#s="open"in e,this.#e=null,this.#n=!1,this.#t=!1,this.#i=!1,this.#r=!1,this.#a=0,this.#u=0,this.#d=void 0,this.#h=void 0,this.#p=0,this.#b=!1,this.#m=0,this.#c=!1;}applyComponentProps(){const e=super.readProps(["actionLabel","actionOnNewLine","duration","open","pauseOnHover","request"]),n=e.request,t=this.#e?.()!==void 0||(n?.actionLabel??e.actionLabel)!==void 0,i=e.requestChanged&&e.requestPrevious!==void 0&&n!==void 0;if((e.actionOnNewLineChanged||e.requestChanged)&&super.setClass(_,(n?.actionOnNewLine??e.actionOnNewLine)===!0),i&&this.#t&&(this.#o(),k(()=>this.props.onDismiss?.("replacement",void 0,this))),e.durationChanged||e.requestChanged||t!==this.#n){const o=U(n?.duration??e.duration,t);this.#n=t,o!==this.#a&&(this.#o(),this.#a=o,this.#u=o,this.#l());}(e.pauseOnHoverChanged||e.requestChanged)&&!this.#S()&&this.#c&&(this.#c=!1,this.#l()),(e.openChanged||e.requestChanged)&&this.#f(this.#s?e.open!==!1:i||!this.#i,i);}dismiss(e,n="programmatic"){!this.#t||this.#i||this.#r||(this.#i=!0,this.#o(),this.#s||this.#f(!1,!1),k(()=>{this.props.onOpenChange?.(!1,e,n),this.props.onDismiss?.(n,e,this);}));}#f(e,n){const t=this.styleElement,i=!e&&this.#t&&t?.isConnected===!0;e===this.#t&&!n||(this.#t=e,e&&(this.#i=!1),this.#u=this.#a,this.#m++,super.setClass(C,i),super.setClass(R,e),super.setAttribute("hidden",!e),super.setAttribute("inert",!e),this.#o(),i&&this.#y(t),!(!e||t===null)&&(this.#l(),queueMicrotask(()=>{this.#t&&!this.#r&&this.styleElement===t&&B(t.ownerDocument,j(t));})));}#y(e){const n=this.#m;O(e,()=>{n===this.#m&&super.setClass(C,!1);});}#S(){return(super.readProp("request",!0)[0]?.pauseOnHover??super.readProp("pauseOnHover",!0)[0])!==!1;}#l(){const e=this.styleElement?.ownerDocument.defaultView;this.#o(),!(this.#r||!this.#t||this.#i||this.#c||this.#a===0||e===null||e===void 0)&&(this.#h=e,this.#p=e.performance.now(),this.#d=e.setTimeout(()=>{this.#d=void 0,this.#u=0,this.dismiss(void 0,"timeout");},this.#u));}#o(){const e=this.#h;this.#d===void 0||e===void 0||(e.clearTimeout(this.#d),this.#u=Math.max(0,this.#u-(e.performance.now()-this.#p)),this.#d=void 0,this.#h=void 0);}#k(){const e=this.styleElement,n=this.#S()&&(this.#b||e!==null&&V(e));n!==this.#c&&(this.#c=n,n?this.#o():this.#l());}#C=e=>{(this.props.request?.onAction??this.props.onAction)?.(e,this),e.defaultPrevented||this.dismiss(e,"action");};#L=e=>this.dismiss(e,"dismiss");#g=e=>{e.key!=="Escape"||e.defaultPrevented||!this.#t||(e.preventDefault(),this.dismiss(e,"escape"));};#v=e=>{this.#b=e.type==="pointerenter",this.#k();};#E=()=>{(this.styleElement?.ownerDocument.defaultView?.queueMicrotask??queueMicrotask)(()=>this.#k());};onStyleElementChanged(e){super.onStyleElementChanged(e),this.#o(),e!==null&&(e.ownerDocument.defaultView?.queueMicrotask??queueMicrotask)(()=>{this.styleElement===e&&this.#l();});}onControllerCleanup(){this.#r=!0,this.#o(),super.onControllerCleanup();}render(e){const n=<div class={`${M} ${A}`}hidden inert>
|
|
6
6
|
<div class="cw-Snackbar-message"/>
|
|
7
7
|
<div class="cw-Snackbar-actions"/>
|
|
8
|
-
</div>,t=()=>this.props.request;return v(n.firstElementChild,()=>t()?.message??this.props.message??e),this.#e=I(()=>t()?.action??this.props.action),v(n.lastElementChild,x({action:this.#e,actionLabel:()=>t()?.actionLabel??this.props.actionLabel,dismissible:()=>(t()?.dismissible??this.props.dismissible)===!0,dismissLabel:()=>t()?.dismissLabel??this.props.dismissLabel??N,onAction:this.#C,onDismiss:this.#L})),n.addEventListener("keydown",this.#g),n.addEventListener("pointerenter",this.#v),n.addEventListener("pointerleave",this.#v),n.addEventListener("focusin",this.#E),n.addEventListener("focusout",this.#E),n}}function Y(s,e){const n=e.request,t=e.open!==!1,i=(n?.actionOnNewLine??e.actionOnNewLine)===!0;return<div{...s}classList={{...s.classList,[_]:i,[A]:!0,[R]:t,[M]:!0}}hidden={!t}inert={!t}>
|
|
8
|
+
</div>,t=()=>this.props.request;return v(n.firstElementChild,()=>t()?.message??this.props.message??e),this.#e=I(()=>t()?.action??this.props.action),v(n.lastElementChild,x({action:this.#e,actionLabel:()=>t()?.actionLabel??this.props.actionLabel,dismissible:()=>(t()?.dismissible??this.props.dismissible)===!0,dismissLabel:()=>t()?.dismissLabel??this.props.dismissLabel??N,onAction:this.#C,onDismiss:this.#L})),n.addEventListener("keydown",this.#g),n.addEventListener("pointerenter",this.#v),n.addEventListener("pointerleave",this.#v),n.addEventListener("focusin",this.#E),n.addEventListener("focusout",this.#E),n;}}function Y(s,e){const n=e.request,t=e.open!==!1,i=(n?.actionOnNewLine??e.actionOnNewLine)===!0;return<div{...s}classList={{...s.classList,[_]:i,[A]:!0,[R]:t,[M]:!0}}hidden={!t}inert={!t}>
|
|
9
9
|
<div class="cw-Snackbar-message">
|
|
10
10
|
{n?.message??e.message??s.children}
|
|
11
11
|
</div>
|
|
12
12
|
<div class="cw-Snackbar-actions">
|
|
13
13
|
{x({action:()=>n?.action??e.action,actionLabel:()=>n?.actionLabel??e.actionLabel,dismissible:()=>(n?.dismissible??e.dismissible)===!0,dismissLabel:()=>n?.dismissLabel??e.dismissLabel??N})}
|
|
14
14
|
</div>
|
|
15
|
-
</div
|
|
15
|
+
</div>;}const P=/* @__PURE__ */D(()=>Y,()=>G);function q(s){const[e,n]=w(!0);return{request:s,open:e,setOpen:n};}function T(s){return`_cw-SnackbarHost-${s??"bottom"}`;}class Z extends H{#s;#e;#n;#t;constructor(e){const n=k(()=>e.queue.current),[t,i]=w(n===null?[]:[q(n)]);super(e,{styleElementIsFunction:!0}),this.#s=t,this.#e=i,this.#n=null,this.#t=void 0;}applyComponentProps(){const e=super.readProps(["position","queue"]);e.positionChanged&&super.setClass("position",T(e.position)),e.queueChanged&&(this.#t?.(),this.#n=e.queue,this.#t=e.queue.subscribe(this.#a),this.#i(e.queue.current));}#i(e){const t=this.#s().at(-1);t?.request===e&&t.open()||(t?.open()===!0&&this.#r(t),e!==null&&this.#e([...this.#s(),q(e)]));}#r(e){const n=e.controller?.styleElement,t=()=>{e.open()||this.#e(this.#s().filter(i=>i!==e));};if(e.setOpen(!1),n==null){t();return;}(n.ownerDocument.defaultView?.queueMicrotask??queueMicrotask)(()=>{O(n,t);});}#a=(e,n)=>{const t=this.#s().at(-1);e!==void 0&&t!==void 0&&t.request.id===n&&t.controller?.dismiss(void 0,e),this.#i(this.#n?.current??null);};onControllerCleanup(){this.#t?.(),this.#t=void 0,super.onControllerCleanup();}render(){const e=<div class="cw-SnackbarHost">
|
|
16
16
|
<div class="cw-SnackbarHost-content"/>
|
|
17
|
-
</div>;return v(e.firstElementChild,<X each={this.#s()}>{n=><P controllerRef={t=>n.controller=t}open={n.open()}request={n.request}onDismiss={(t,i,o)=>{this.props.onDismiss?.(t,i,o),this.#n?.dismiss(n.request.id,t)}}/>}</X>),e}}const he
|
|
17
|
+
</div>;return v(e.firstElementChild,<X each={this.#s()}>{n=><P controllerRef={t=>n.controller=t}open={n.open()}request={n.request}onDismiss={(t,i,o)=>{this.props.onDismiss?.(t,i,o),this.#n?.dismiss(n.request.id,t);}}/>}</X>),e;}}const he=/* @__PURE__ */D(()=>(s,e)=><div{...s}classList={{...s.classList,[T(e.position)]:!0,"cw-SnackbarHost":!0}}>
|
|
18
18
|
<div class="cw-SnackbarHost-content">
|
|
19
19
|
<S when={e.queue.current}>
|
|
20
20
|
{n=><P open request={n()}/>}
|
|
21
21
|
</S>
|
|
22
22
|
</div>
|
|
23
|
-
</div>,()=>Z);export{P as Snackbar,G as SnackbarController,he as SnackbarHost,Z as SnackbarHostController,z as SnackbarQueue,le as createSnackbarQueue};
|
|
23
|
+
</div>,()=>Z);export{P as Snackbar,G as SnackbarController,he as SnackbarHost,Z as SnackbarHostController,z as SnackbarQueue,le as createSnackbarQueue};
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import{Show as V,children as j,createSignal as x,createUniqueId as M,getListener as O,untrack as a}from"solid-js";import{insert as T}from"solid-js/web";import{defineDomComponent as H}from"..";import{ELEVATION_SHADOW_CSS_CLASS as F}from"../container/elevation-shadow";import{DomController as G}from"../dom/client";import{resolveSurfaceSlots as _}from"../surface/slots";import{isLeaveWithin as U}from"../util/event";import{FOCUSABLE_SELECTORS as q,isFocusWithin as A}from"./focus";import{observeMutations as z,whenExitMotionFinished as Y,whenInDocument as K}from"./observe";import"../container/elevation-shadow.css";import"./feedback.css";const Q=500,Z=1500,ee=500,te=8,ie=4,g=8,X="Tooltip",W=["aria-controls","aria-describedby","aria-expanded","aria-haspopup"],ne=[...q,"[role=button]"].join(","),se={attributeFilter:["contenteditable","disabled","href","tabindex","type"],attributes:!0,childList:!0,subtree:!0},R="_cw-Tooltip-closing",w="_cw-Tooltip-caret",y=new WeakMap;function I(o,e){return o===void 0||!Number.isFinite(o)?e:Math.max(0,o)}function k(o){return W.includes(o)}function C(o,e,t){return Math.max(e,Math.min(o,t))}function D(o,e){return Number.parseFloat(o.getPropertyValue(e))||0}function S(o){return Array.isArray(o)?o.some(S):o!=null&&o!==!1&&o!==""}function L(o){return o==null?void 0:`${o}`}function E(o,e,t){t===null?o.removeAttribute(e):o.setAttribute(e,t)}function J(o,e,t){const i=Object.create(null);return Object.defineProperties(i,{open:{configurable:!0,enumerable:!1,get:e},popupId:{configurable:!0,enumerable:!1,get:t}}),Object.setPrototypeOf(o,i)}class N extends G{#n;#P;#q;#de;#z;#c;#le;#t;#i;#s;#f;#O;#x;#r;#b;#R;#m;#g;#v;#T;#Y;#K;#e;#y;#I;#o;#h;#D;#A;#a;#d;#Q;#Z;#E;#u;#w;#H;#F;#he;#ee;#ue;#_;#pe;constructor(e,t){const i=a(()=>e.id)??M(),n=a(()=>e.disabled===!0),s=a(()=>e.open===!0)&&!n,[d,r]=x(s),[c,l]=x(n),[p,h]=x(i),f=new Map;super(e);for(const u of Object.keys(e))if(u.startsWith("attr:aria-")){const m=u.slice(5);f.set(m,a(()=>e[u]))}this.#n=t,this.#P=i,this.#q="open"in e,this.#de="trigger"in e,this.#z="attr:tabindex"in e,this.#c=[...f.keys()],this.#le=f,this.#t=null,this.#i=null,this.#s=null,this.#f=a(()=>e.trigger!==void 0),this.#O=new Set,this.#x=new Map,this.#r=new Map,this.#b=null,this.#R=null,this.#m=void 0,this.#g=void 0,this.#v=void 0,this.#T=void 0,this.#Y=0,this.#K=0,this.#e=s,this.#y=!1,this.#I=0,this.#o=!1,this.#h=!1,this.#D=!1,this.#A=!1,this.#a=void 0,this.#d=!1,this.#Q=0,this.#Z=0,this.#E=void 0,this.#u=void 0,this.#w=void 0,this.#H=null,this.#F=c,this.#he=l,this.#ee=d,this.#ue=r,this.#_=p,this.#pe=h}get persistent(){return!1}applyComponentProps(){const e=super.readProps(["caret","disabled","id","open","placement","trigger"]);if(this.#f=e.trigger!==void 0,e.disabledChanged&&(this.#he(e.disabled===!0),e.disabled===!0&&this.#p()),e.caretChanged&&this.#i?.classList.toggle(w,e.caret===!0),e.idChanged){const t=e.id??this.#P;this.#pe(t),this.#i?.setAttribute("id",t)}(e.openChanged||e.disabledChanged)&&this.#ce(this.#q?e.open===!0:this.#e,!1),this.#i!==null&&this.applyPopupName(this.#i),this.#C(),this.#e&&e.placementChanged&&this.#ae()}applyPopupName(e){}onFunctionElementChanged(e){const t=e;super.onFunctionElementChanged(e),this.#t!==t&&this.#fe(this.#t),this.#t=t,this.#Ce(),this.#m?.(),this.#m=void 0,t!==null&&K(t,()=>{!this.#o&&this.#t===t&&(this.#m=z(t,se,()=>this.#C()))}),this.#C()}onStyleElementChanged(e){super.onStyleElementChanged(e),(e===null||this.#T!==e.ownerDocument.defaultView)&&this.#p()}onControllerCleanup(){this.#Oe(),super.onControllerCleanup()}#te(e){const t=`attr:${e}`;if(this.#c.includes(e))return L(t in this.props?this.props[t]:this.#le.get(e))}#ie(e){const t=this.#i?.id??this.#P;return this.#c.includes(e)?this.#te(e):a(()=>this.props.disabled===!0)?void 0:e==="aria-describedby"?t:this.#n?e==="aria-controls"?t:e==="aria-expanded"?`${this.#e}`:"dialog":void 0}#Le(){const e=n=>O()===this.#H?a(n):n(),t=(n,s)=>({enumerable:!0,get:()=>(e(s),e(this.#F),this.#ie(n))}),i={};Object.defineProperties(i,{"aria-controls":t("aria-controls",this.#_),"aria-describedby":t("aria-describedby",this.#_),"aria-expanded":t("aria-expanded",this.#ee),"aria-haspopup":t("aria-haspopup",this.#F),tabIndex:{enumerable:!0,get:()=>e(this.#F)?void 0:0}});for(const n of this.#c)k(n)||Object.defineProperty(i,n,{enumerable:!0,get:()=>this.#te(n)});return J(i,()=>e(this.#ee),()=>e(this.#_))}renderTrigger(e){const t=this.#Le();return j(()=>{const i=this.#de?this.props.trigger:void 0;if(i===void 0)return e;this.#H=O();try{return i(t)}finally{this.#H=null}})}setPopup(e){this.#i=e,e.id=a(()=>this.props.id)??this.#P,e.classList.toggle(w,a(()=>this.props.caret)===!0),e.addEventListener("pointerenter",this.#W),e.addEventListener("pointerleave",this.#J),e.addEventListener("focusin",this.#N),e.addEventListener("focusout",this.#$)}#ce(e,t){const i=this.#i,n=a(()=>this.props.disabled===!0),s=e&&!n,d=s&&this.#y,r=!s&&i!==null&&A(i);if(!this.#o){if(this.#y=!1,!s&&this.#e&&(this.#h=this.#oe()),this.#I++,this.#p(),this.#e=s,s&&this.#a!==void 0&&(this.#d=!0),this.#ue(s),super.setClass(`${this.#n?"cw-RichTooltip":"cw-PlainTooltip"}-open`,s),i!==null&&(i.classList.toggle(R,!s&&i.matches(":popover-open")),i.inert=!s,i.hidden=!s,s?i.removeAttribute("aria-hidden"):i.setAttribute("aria-hidden","true")),this.#C(),this.#re(),r&&this.#s?.focus({preventScroll:!0}),d&&i!==null)for(const c of y.get(i.ownerDocument)??[])c!==this.#l&&c();t&&a(()=>this.props.onOpenChange?.(s))}}#L(e){if(!(this.#o||e&&a(()=>this.props.disabled===!0))){if(e&&this.#e&&this.#a!==void 0&&(this.#d=!0),e===this.#e){e||(this.#y=!1);return}this.#y=e,this.#q?(this.#p(),a(()=>this.props.onOpenChange?.(e))):this.#ce(e,!0)}}#C(){const e=this.#t,t=e?.querySelector(ne)??null,i=t??e,n=this.#f||!this.#z;if(e===null){this.#se();return}if(t!==null){for(const s of W)e.getAttribute(s)===this.#ie(s)&&e.removeAttribute(s);n&&e.removeAttribute("tabindex")}else n&&(a(()=>this.props.disabled===!0)?this.#z||e.removeAttribute("tabindex"):e.getAttribute("tabindex")!=="0"&&(e.tabIndex=0));i!==this.#s&&(this.#se(),this.#s=i),this.#Se(i),this.#Pe(),this.#Ae()}#Se(e){if(!this.#f||e===this.#t){this.#ne();return}if(e!==this.#b){const t=e.getAttribute("tabindex");this.#ne(),this.#b=e,this.#R=t==="0"?null:t}a(()=>this.props.disabled===!0)?e.removeAttribute("tabindex"):e.getAttribute("tabindex")!=="0"&&e.setAttribute("tabindex","0")}#ne(){this.#b!==null&&E(this.#b,"tabindex",this.#R),this.#b=null,this.#R=null}#Pe(){const e=this.#t,t=this.#s;if(!(e===null||t===null))for(const i of this.#c){const n=this.#te(i);if(t===e){n===void 0?e.removeAttribute(i):e.setAttribute(i,n);continue}e.removeAttribute(i),this.#xe(t,i,n)}}#xe(e,t,i){if(i===void 0){this.#r.has(t)&&(E(e,t,this.#r.get(t)),this.#r.delete(t));return}if(!this.#r.has(t)){const n=e.getAttribute(t);this.#r.set(t,this.#f&&k(t)&&n===this.#ie(t)?null:n)}e.setAttribute(t,i)}#Ae(){const e=this.#s,t=this.#i?.id??this.#P;if(e!==null){if(a(()=>this.props.disabled===!0)){for(const[i,n]of this.#x)E(e,i,n);return}this.#n&&(this.#X(e,"aria-controls",t),this.#X(e,"aria-expanded",`${this.#e}`),this.#X(e,"aria-haspopup","dialog")),this.#X(e,"aria-describedby",t)}}#X(e,t,i){if(!this.#c.includes(t)){if(!this.#O.has(t)){if(!this.#f&&e.hasAttribute(t))return;this.#O.add(t),this.#x.set(t,e.getAttribute(t))}e.setAttribute(t,i)}}#se(){const e=this.#s;if(e!==null){for(const[t,i]of this.#x)E(e,t,i);for(const[t,i]of this.#r)E(e,t,i)}this.#O.clear(),this.#x.clear(),this.#r.clear(),this.#ne(),this.#s=null}#Ce(){const e=this.#t;e!==null&&(e.addEventListener("pointerenter",this.#W),e.addEventListener("pointerleave",this.#J),e.addEventListener("focusin",this.#N),e.addEventListener("focusout",this.#$),e.addEventListener("pointerdown",this.#ge),e.addEventListener("pointermove",this.#ve),e.addEventListener("pointerup",this.#S),e.addEventListener("pointercancel",this.#S),e.addEventListener("click",this.#Te,!0),e.addEventListener("contextmenu",this.#ye))}#fe(e){e!==null&&(e.removeEventListener("pointerenter",this.#W),e.removeEventListener("pointerleave",this.#J),e.removeEventListener("focusin",this.#N),e.removeEventListener("focusout",this.#$),e.removeEventListener("pointerdown",this.#ge),e.removeEventListener("pointermove",this.#ve),e.removeEventListener("pointerup",this.#S),e.removeEventListener("pointercancel",this.#S),e.removeEventListener("click",this.#Te,!0),e.removeEventListener("contextmenu",this.#ye))}#W=e=>{e.pointerType!=="touch"&&(e.currentTarget===this.#t?this.#D=!0:this.#A=!0,this.#h=!1,this.#U(),this.#e||this.#V())};#J=e=>{if(e.pointerType==="touch"){this.#S(e);return}U(e,e.currentTarget)||(e.currentTarget===this.#t?this.#D=!1:this.#A=!1,this.#B()||this.#j())};#N=e=>{const i=e.target?.matches(":focus-visible")===!0;this.#h||(this.#C(),this.#U(),!this.#e&&e.currentTarget===this.#t&&i&&this.#V())};#$=()=>{(this.#M()?.queueMicrotask??queueMicrotask)(()=>{this.#o||(this.#oe()||(this.#h=!1),this.#B()||this.#j())})};#be=e=>{const t=this.#i?.ownerDocument,i=t===void 0?void 0:y.get(t);e.key!=="Escape"||!this.#e||i!==void 0&&[...i].at(-1)!==this.#l||(e.preventDefault(),e.stopImmediatePropagation(),this.#l())};#l=()=>{this.#p(),this.#L(!1)};#me=e=>{const t=e.composedPath();!t.includes(this.#t)&&!t.includes(this.#i)&&this.#l()};#B(){return this.persistent||this.#D||this.#A||this.#a!==void 0||!this.#h&&this.#oe()}#oe(){return this.#t!==null&&A(this.#t)||this.#i!==null&&A(this.#i)}#ge=e=>{this.#d=!1,!(e.pointerType!=="touch"||!e.isPrimary||a(()=>this.props.disabled===!0))&&(this.#h=!0,this.#a=e.pointerId,this.#Q=e.clientX,this.#Z=e.clientY,this.#V(ee))};#ve=e=>{e.pointerId===this.#a&&Math.hypot(e.clientX-this.#Q,e.clientY-this.#Z)>te&&this.#S(e)};#S=e=>{e.pointerId===this.#a&&(this.#a=void 0,this.#G(),e.type==="pointerup"?this.#e&&this.#j():(this.#d=!1,this.#l()))};#Te=e=>{const t=this.#d;if(this.#d=!1,t&&(e.detail>0||e.pointerType==="touch")){e.preventDefault(),e.stopImmediatePropagation();return}if(this.persistent&&!this.#e){this.#p(),this.#L(!0);return}this.#l()};#ye=e=>{this.#d&&e.preventDefault()};#re(){const e=this.#i,t=e?.ownerDocument.defaultView??null;if(e!==null){if(!this.#e){this.#ke(),this.#Me(e);return}if(!e.isConnected){queueMicrotask(()=>{this.#e&&e.isConnected&&this.#re()});return}if(!e.matches(":popover-open"))try{e.showPopover()}catch{return}if(this.#E===void 0&&t!==null){const i=y.get(t.document)??new Set;this.#E=t,i.add(this.#l),y.set(t.document,i),t.addEventListener("resize",this.#k),t.document.addEventListener("scroll",this.#k,!0),t.document.addEventListener("keydown",this.#be,!0),t.document.addEventListener("pointerdown",this.#me,!0),this.#w=new t.ResizeObserver(this.#k),this.#w.observe(e),this.#s!==null&&this.#w.observe(this.#s)}this.#ae()}}#ke(){const e=this.#E;e!==void 0&&(e.removeEventListener("resize",this.#k),e.document.removeEventListener("scroll",this.#k,!0),e.document.removeEventListener("keydown",this.#be,!0),e.document.removeEventListener("pointerdown",this.#me,!0),y.get(e.document)?.delete(this.#l),this.#u!==void 0&&e.cancelAnimationFrame(this.#u)),this.#u=void 0,this.#E=void 0,this.#A=!1,this.#w?.disconnect(),this.#w=void 0}#Me(e){const t=++this.#I,i=()=>{if(!(t!==this.#I||this.#e)){e.classList.remove(R);try{e.matches(":popover-open")&&e.hidePopover()}catch{}}};this.#o?i():Y(e,i)}#k=()=>{const e=this.#E;this.#u!==void 0||e===void 0||(this.#u=e.requestAnimationFrame(()=>{this.#u=void 0,this.#ae()}))};#ae(){const e=this.#i,t=this.#s??this.#t,i=e?.ownerDocument.defaultView??null;if(!this.#e||e===null||t===null||i===null)return;const n=t.getBoundingClientRect(),s={height:e.offsetHeight,width:e.offsetWidth},d=i.getComputedStyle(e),r=e.classList.contains(w),c=r?D(d,"--cw-Feedback-tooltip-caretHeight"):0,l=ie+c,p=a(()=>this.props.placement)??"top",h=p==="top"||p==="bottom";let f,u,m;if(h){const v=n.top-s.height-l,b=n.bottom+l,P=b+s.height>i.innerHeight-g;f=p==="top"&&v<g?"bottom":p==="bottom"&&P?"top":p,u=n.left+(n.width-s.width)/2,m=f==="top"?v:b}else{const v=i.getComputedStyle(t).direction==="rtl";let b=p==="end"!==v;u=b?n.right+l:n.left-s.width-l,(u<g||u+s.width>i.innerWidth-g)&&(b=!b,u=b?n.right+l:n.left-s.width-l),f=b?"right":"left",m=n.top+(n.height-s.height)/2}if(u=C(u,g,i.innerWidth-s.width-g),m=C(m,g,i.innerHeight-s.height-g),e.dataset.placement=f,e.style.left=`${u}px`,e.style.top=`${m}px`,r){const v=D(d,"--cw-Feedback-tooltip-caretWidth")/2,b=h?n.left+n.width/2-u:n.top+n.height/2-m,P=h?s.width:s.height;e.style.setProperty("--_cw-Tooltip-caretOffset",`${C(b,v,P-v)}px`)}}#V(e){const t=this.#M(),i=e??I(a(()=>this.props.showDelay),Q);if(!(this.#o||a(()=>this.props.disabled===!0))){if(this.#G(),i===0||t===void 0){this.#L(!0);return}this.#Ee(t,i),this.#g=t.setTimeout(()=>{const n=this.#we(t);if(this.#g=void 0,this.#M()!==t){this.#V(n);return}this.#L(!0)},i)}}#j(e){const t=this.#M(),i=e??I(a(()=>this.props.hideDelay),Z);if(this.#G(),this.#U(),this.#y=!1,!(this.#o||!this.#e||this.#B())){if(i===0||t===void 0){this.#L(!1);return}this.#Ee(t,i),this.#v=t.setTimeout(()=>{const n=this.#we(t);if(this.#v=void 0,this.#M()!==t){this.#j(n);return}this.#B()||this.#L(!1)},i)}}#Ee(e,t){this.#T=e,this.#Y=e.performance.now(),this.#K=t}#we(e){return Math.max(0,this.#K-(e.performance.now()-this.#Y))}#G(){this.#g!==void 0&&(this.#T?.clearTimeout(this.#g),this.#g=void 0)}#U(){this.#v!==void 0&&(this.#T?.clearTimeout(this.#v),this.#v=void 0)}#p(){this.#G(),this.#U(),this.#T=void 0}#M(){return(this.#t?.ownerDocument??this.#i?.ownerDocument??this.styleElement?.ownerDocument)?.defaultView??void 0}#Oe(){const e=this.#i;this.#o=!0,this.#e=!1,this.#re(),this.#p(),this.#m?.(),this.#m=void 0,this.#se(),this.#fe(this.#t),e!==null&&(e.removeEventListener("pointerenter",this.#W),e.removeEventListener("pointerleave",this.#J),e.removeEventListener("focusin",this.#N),e.removeEventListener("focusout",this.#$))}}function oe(o,e,t,i,n){const s=(r,c)=>r in i?L(i[r]):n?void 0:c,d={"aria-controls":s("aria-controls",t?o:void 0),"aria-describedby":s("aria-describedby",o),"aria-expanded":s("aria-expanded",t?`${e}`:void 0),"aria-haspopup":s("aria-haspopup",t?"dialog":void 0),tabIndex:n?void 0:0};for(const r of Object.keys(i))r.startsWith("aria-")&&!k(r)&&(d[r]=L(i[r]));return J(d,()=>e,()=>o)}function $(o,e,t,i,n){const s=e.disabled===!0,d=e.trigger,r=o,c=d===void 0&&!s&&!("tabindex"in r),l=(h,f)=>d!==void 0?void 0:h in r?L(r[h]):s?void 0:f,p={};for(const h of Object.keys(r))!["children","class","classList","ref","style"].includes(h)&&(d===void 0||!h.startsWith("aria-"))&&(p[h]=r[h]);return{attributes:{...p,"aria-controls":n?l("aria-controls",t):void 0,"aria-describedby":l("aria-describedby",t),"aria-expanded":n?l("aria-expanded",`${i}`):void 0,"aria-haspopup":n?l("aria-haspopup","dialog"):void 0,class:n?"cw-RichTooltip-trigger":"cw-PlainTooltip-trigger",tabIndex:c?0:void 0},content:()=>d===void 0?o.children:d(oe(t,i,n,r,s))}}function B(o){return<V when={S(o())}>
|
|
1
|
+
import{Show as V,children as j,createSignal as x,createUniqueId as M,getListener as O,untrack as a}from"solid-js";import{insert as T}from"solid-js/web";import{defineDomComponent as H}from"..";import{ELEVATION_SHADOW_CSS_CLASS as F}from"../container/elevation-shadow";import{DomController as G}from"../dom/client";import{resolveSurfaceSlots as _}from"../surface/slots";import{isLeaveWithin as U}from"../util/event";import{FOCUSABLE_SELECTORS as q,isFocusWithin as A}from"./focus";import{observeMutations as z,whenExitMotionFinished as Y,whenInDocument as K}from"./observe";import"../container/elevation-shadow.css";import"./feedback.css";const Q=500,Z=1500,ee=500,te=8,ie=4,g=8,X="Tooltip",W=["aria-controls","aria-describedby","aria-expanded","aria-haspopup"],ne=[...q,"[role=button]"].join(","),se={attributeFilter:["contenteditable","disabled","href","tabindex","type"],attributes:!0,childList:!0,subtree:!0},R="_cw-Tooltip-closing",w="_cw-Tooltip-caret",y=/* @__PURE__ */new WeakMap();function I(o,e){return o===void 0||!Number.isFinite(o)?e:Math.max(0,o);}function k(o){return W.includes(o);}function C(o,e,t){return Math.max(e,Math.min(o,t));}function D(o,e){return Number.parseFloat(o.getPropertyValue(e))||0;}function S(o){return Array.isArray(o)?o.some(S):o!=null&&o!==!1&&o!=="";}function L(o){return o==null?void 0:`${o}`;}function E(o,e,t){t===null?o.removeAttribute(e):o.setAttribute(e,t);}function J(o,e,t){const i=/* @__PURE__ */Object.create(null);return Object.defineProperties(i,{open:{configurable:!0,enumerable:!1,get:e},popupId:{configurable:!0,enumerable:!1,get:t}}),Object.setPrototypeOf(o,i);}class N extends G{#n;#P;#q;#de;#z;#c;#le;#t;#i;#s;#f;#O;#x;#r;#b;#R;#m;#g;#v;#T;#Y;#K;#e;#y;#I;#o;#h;#D;#A;#a;#d;#Q;#Z;#E;#u;#w;#H;#F;#he;#ee;#ue;#_;#pe;constructor(e,t){const i=a(()=>e.id)??M(),n=a(()=>e.disabled===!0),s=a(()=>e.open===!0)&&!n,[d,r]=x(s),[c,l]=x(n),[p,h]=x(i),f=/* @__PURE__ */new Map();super(e);for(const u of Object.keys(e))if(u.startsWith("attr:aria-")){const m=u.slice(5);f.set(m,a(()=>e[u]));}this.#n=t,this.#P=i,this.#q="open"in e,this.#de="trigger"in e,this.#z="attr:tabindex"in e,this.#c=[...f.keys()],this.#le=f,this.#t=null,this.#i=null,this.#s=null,this.#f=a(()=>e.trigger!==void 0),this.#O=/* @__PURE__ */new Set(),this.#x=/* @__PURE__ */new Map(),this.#r=/* @__PURE__ */new Map(),this.#b=null,this.#R=null,this.#m=void 0,this.#g=void 0,this.#v=void 0,this.#T=void 0,this.#Y=0,this.#K=0,this.#e=s,this.#y=!1,this.#I=0,this.#o=!1,this.#h=!1,this.#D=!1,this.#A=!1,this.#a=void 0,this.#d=!1,this.#Q=0,this.#Z=0,this.#E=void 0,this.#u=void 0,this.#w=void 0,this.#H=null,this.#F=c,this.#he=l,this.#ee=d,this.#ue=r,this.#_=p,this.#pe=h;}get persistent(){return!1;}applyComponentProps(){const e=super.readProps(["caret","disabled","id","open","placement","trigger"]);if(this.#f=e.trigger!==void 0,e.disabledChanged&&(this.#he(e.disabled===!0),e.disabled===!0&&this.#p()),e.caretChanged&&this.#i?.classList.toggle(w,e.caret===!0),e.idChanged){const t=e.id??this.#P;this.#pe(t),this.#i?.setAttribute("id",t);}(e.openChanged||e.disabledChanged)&&this.#ce(this.#q?e.open===!0:this.#e,!1),this.#i!==null&&this.applyPopupName(this.#i),this.#C(),this.#e&&e.placementChanged&&this.#ae();}applyPopupName(e){}onFunctionElementChanged(e){const t=e;super.onFunctionElementChanged(e),this.#t!==t&&this.#fe(this.#t),this.#t=t,this.#Ce(),this.#m?.(),this.#m=void 0,t!==null&&K(t,()=>{!this.#o&&this.#t===t&&(this.#m=z(t,se,()=>this.#C()));}),this.#C();}onStyleElementChanged(e){super.onStyleElementChanged(e),(e===null||this.#T!==e.ownerDocument.defaultView)&&this.#p();}onControllerCleanup(){this.#Oe(),super.onControllerCleanup();}#te(e){const t=`attr:${e}`;if(this.#c.includes(e))return L(t in this.props?this.props[t]:this.#le.get(e));}#ie(e){const t=this.#i?.id??this.#P;return this.#c.includes(e)?this.#te(e):a(()=>this.props.disabled===!0)?void 0:e==="aria-describedby"?t:this.#n?e==="aria-controls"?t:e==="aria-expanded"?`${this.#e}`:"dialog":void 0;}#Le(){const e=n=>O()===this.#H?a(n):n(),t=(n,s)=>({enumerable:!0,get:()=>(e(s),e(this.#F),this.#ie(n))}),i={};Object.defineProperties(i,{"aria-controls":t("aria-controls",this.#_),"aria-describedby":t("aria-describedby",this.#_),"aria-expanded":t("aria-expanded",this.#ee),"aria-haspopup":t("aria-haspopup",this.#F),tabIndex:{enumerable:!0,get:()=>e(this.#F)?void 0:0}});for(const n of this.#c)k(n)||Object.defineProperty(i,n,{enumerable:!0,get:()=>this.#te(n)});return J(i,()=>e(this.#ee),()=>e(this.#_));}renderTrigger(e){const t=this.#Le();return j(()=>{const i=this.#de?this.props.trigger:void 0;if(i===void 0)return e;this.#H=O();try{return i(t);}finally{this.#H=null;}});}setPopup(e){this.#i=e,e.id=a(()=>this.props.id)??this.#P,e.classList.toggle(w,a(()=>this.props.caret)===!0),e.addEventListener("pointerenter",this.#W),e.addEventListener("pointerleave",this.#J),e.addEventListener("focusin",this.#N),e.addEventListener("focusout",this.#$);}#ce(e,t){const i=this.#i,n=a(()=>this.props.disabled===!0),s=e&&!n,d=s&&this.#y,r=!s&&i!==null&&A(i);if(!this.#o){if(this.#y=!1,!s&&this.#e&&(this.#h=this.#oe()),this.#I++,this.#p(),this.#e=s,s&&this.#a!==void 0&&(this.#d=!0),this.#ue(s),super.setClass(`${this.#n?"cw-RichTooltip":"cw-PlainTooltip"}-open`,s),i!==null&&(i.classList.toggle(R,!s&&i.matches(":popover-open")),i.inert=!s,i.hidden=!s,s?i.removeAttribute("aria-hidden"):i.setAttribute("aria-hidden","true")),this.#C(),this.#re(),r&&this.#s?.focus({preventScroll:!0}),d&&i!==null)for(const c of y.get(i.ownerDocument)??[])c!==this.#l&&c();t&&a(()=>this.props.onOpenChange?.(s));}}#L(e){if(!(this.#o||e&&a(()=>this.props.disabled===!0))){if(e&&this.#e&&this.#a!==void 0&&(this.#d=!0),e===this.#e){e||(this.#y=!1);return;}this.#y=e,this.#q?(this.#p(),a(()=>this.props.onOpenChange?.(e))):this.#ce(e,!0);}}#C(){const e=this.#t,t=e?.querySelector(ne)??null,i=t??e,n=this.#f||!this.#z;if(e===null){this.#se();return;}if(t!==null){for(const s of W)e.getAttribute(s)===this.#ie(s)&&e.removeAttribute(s);n&&e.removeAttribute("tabindex");}else n&&(a(()=>this.props.disabled===!0)?this.#z||e.removeAttribute("tabindex"):e.getAttribute("tabindex")!=="0"&&(e.tabIndex=0));i!==this.#s&&(this.#se(),this.#s=i),this.#Se(i),this.#Pe(),this.#Ae();}#Se(e){if(!this.#f||e===this.#t){this.#ne();return;}if(e!==this.#b){const t=e.getAttribute("tabindex");this.#ne(),this.#b=e,this.#R=t==="0"?null:t;}a(()=>this.props.disabled===!0)?e.removeAttribute("tabindex"):e.getAttribute("tabindex")!=="0"&&e.setAttribute("tabindex","0");}#ne(){this.#b!==null&&E(this.#b,"tabindex",this.#R),this.#b=null,this.#R=null;}#Pe(){const e=this.#t,t=this.#s;if(!(e===null||t===null))for(const i of this.#c){const n=this.#te(i);if(t===e){n===void 0?e.removeAttribute(i):e.setAttribute(i,n);continue;}e.removeAttribute(i),this.#xe(t,i,n);}}#xe(e,t,i){if(i===void 0){this.#r.has(t)&&(E(e,t,this.#r.get(t)),this.#r.delete(t));return;}if(!this.#r.has(t)){const n=e.getAttribute(t);this.#r.set(t,this.#f&&k(t)&&n===this.#ie(t)?null:n);}e.setAttribute(t,i);}#Ae(){const e=this.#s,t=this.#i?.id??this.#P;if(e!==null){if(a(()=>this.props.disabled===!0)){for(const[i,n]of this.#x)E(e,i,n);return;}this.#n&&(this.#X(e,"aria-controls",t),this.#X(e,"aria-expanded",`${this.#e}`),this.#X(e,"aria-haspopup","dialog")),this.#X(e,"aria-describedby",t);}}#X(e,t,i){if(!this.#c.includes(t)){if(!this.#O.has(t)){if(!this.#f&&e.hasAttribute(t))return;this.#O.add(t),this.#x.set(t,e.getAttribute(t));}e.setAttribute(t,i);}}#se(){const e=this.#s;if(e!==null){for(const[t,i]of this.#x)E(e,t,i);for(const[t,i]of this.#r)E(e,t,i);}this.#O.clear(),this.#x.clear(),this.#r.clear(),this.#ne(),this.#s=null;}#Ce(){const e=this.#t;e!==null&&(e.addEventListener("pointerenter",this.#W),e.addEventListener("pointerleave",this.#J),e.addEventListener("focusin",this.#N),e.addEventListener("focusout",this.#$),e.addEventListener("pointerdown",this.#ge),e.addEventListener("pointermove",this.#ve),e.addEventListener("pointerup",this.#S),e.addEventListener("pointercancel",this.#S),e.addEventListener("click",this.#Te,!0),e.addEventListener("contextmenu",this.#ye));}#fe(e){e!==null&&(e.removeEventListener("pointerenter",this.#W),e.removeEventListener("pointerleave",this.#J),e.removeEventListener("focusin",this.#N),e.removeEventListener("focusout",this.#$),e.removeEventListener("pointerdown",this.#ge),e.removeEventListener("pointermove",this.#ve),e.removeEventListener("pointerup",this.#S),e.removeEventListener("pointercancel",this.#S),e.removeEventListener("click",this.#Te,!0),e.removeEventListener("contextmenu",this.#ye));}#W=e=>{e.pointerType!=="touch"&&(e.currentTarget===this.#t?this.#D=!0:this.#A=!0,this.#h=!1,this.#U(),this.#e||this.#V());};#J=e=>{if(e.pointerType==="touch"){this.#S(e);return;}U(e,e.currentTarget)||(e.currentTarget===this.#t?this.#D=!1:this.#A=!1,this.#B()||this.#j());};#N=e=>{const i=e.target?.matches(":focus-visible")===!0;this.#h||(this.#C(),this.#U(),!this.#e&&e.currentTarget===this.#t&&i&&this.#V());};#$=()=>{(this.#M()?.queueMicrotask??queueMicrotask)(()=>{this.#o||(this.#oe()||(this.#h=!1),this.#B()||this.#j());});};#be=e=>{const t=this.#i?.ownerDocument,i=t===void 0?void 0:y.get(t);e.key!=="Escape"||!this.#e||i!==void 0&&[...i].at(-1)!==this.#l||(e.preventDefault(),e.stopImmediatePropagation(),this.#l());};#l=()=>{this.#p(),this.#L(!1);};#me=e=>{const t=e.composedPath();!t.includes(this.#t)&&!t.includes(this.#i)&&this.#l();};#B(){return this.persistent||this.#D||this.#A||this.#a!==void 0||!this.#h&&this.#oe();}#oe(){return this.#t!==null&&A(this.#t)||this.#i!==null&&A(this.#i);}#ge=e=>{this.#d=!1,!(e.pointerType!=="touch"||!e.isPrimary||a(()=>this.props.disabled===!0))&&(this.#h=!0,this.#a=e.pointerId,this.#Q=e.clientX,this.#Z=e.clientY,this.#V(ee));};#ve=e=>{e.pointerId===this.#a&&Math.hypot(e.clientX-this.#Q,e.clientY-this.#Z)>te&&this.#S(e);};#S=e=>{e.pointerId===this.#a&&(this.#a=void 0,this.#G(),e.type==="pointerup"?this.#e&&this.#j():(this.#d=!1,this.#l()));};#Te=e=>{const t=this.#d;if(this.#d=!1,t&&(e.detail>0||e.pointerType==="touch")){e.preventDefault(),e.stopImmediatePropagation();return;}if(this.persistent&&!this.#e){this.#p(),this.#L(!0);return;}this.#l();};#ye=e=>{this.#d&&e.preventDefault();};#re(){const e=this.#i,t=e?.ownerDocument.defaultView??null;if(e!==null){if(!this.#e){this.#ke(),this.#Me(e);return;}if(!e.isConnected){queueMicrotask(()=>{this.#e&&e.isConnected&&this.#re();});return;}if(!e.matches(":popover-open"))try{e.showPopover();}catch{return;}if(this.#E===void 0&&t!==null){const i=y.get(t.document)??/* @__PURE__ */new Set();this.#E=t,i.add(this.#l),y.set(t.document,i),t.addEventListener("resize",this.#k),t.document.addEventListener("scroll",this.#k,!0),t.document.addEventListener("keydown",this.#be,!0),t.document.addEventListener("pointerdown",this.#me,!0),this.#w=new t.ResizeObserver(this.#k),this.#w.observe(e),this.#s!==null&&this.#w.observe(this.#s);}this.#ae();}}#ke(){const e=this.#E;e!==void 0&&(e.removeEventListener("resize",this.#k),e.document.removeEventListener("scroll",this.#k,!0),e.document.removeEventListener("keydown",this.#be,!0),e.document.removeEventListener("pointerdown",this.#me,!0),y.get(e.document)?.delete(this.#l),this.#u!==void 0&&e.cancelAnimationFrame(this.#u)),this.#u=void 0,this.#E=void 0,this.#A=!1,this.#w?.disconnect(),this.#w=void 0;}#Me(e){const t=++this.#I,i=()=>{if(!(t!==this.#I||this.#e)){e.classList.remove(R);try{e.matches(":popover-open")&&e.hidePopover();}catch{}}};this.#o?i():Y(e,i);}#k=()=>{const e=this.#E;this.#u!==void 0||e===void 0||(this.#u=e.requestAnimationFrame(()=>{this.#u=void 0,this.#ae();}));};#ae(){const e=this.#i,t=this.#s??this.#t,i=e?.ownerDocument.defaultView??null;if(!this.#e||e===null||t===null||i===null)return;const n=t.getBoundingClientRect(),s={height:e.offsetHeight,width:e.offsetWidth},d=i.getComputedStyle(e),r=e.classList.contains(w),c=r?D(d,"--cw-Feedback-tooltip-caretHeight"):0,l=ie+c,p=a(()=>this.props.placement)??"top",h=p==="top"||p==="bottom";let f,u,m;if(h){const v=n.top-s.height-l,b=n.bottom+l,P=b+s.height>i.innerHeight-g;f=p==="top"&&v<g?"bottom":p==="bottom"&&P?"top":p,u=n.left+(n.width-s.width)/2,m=f==="top"?v:b;}else{const v=i.getComputedStyle(t).direction==="rtl";let b=p==="end"!==v;u=b?n.right+l:n.left-s.width-l,(u<g||u+s.width>i.innerWidth-g)&&(b=!b,u=b?n.right+l:n.left-s.width-l),f=b?"right":"left",m=n.top+(n.height-s.height)/2;}if(u=C(u,g,i.innerWidth-s.width-g),m=C(m,g,i.innerHeight-s.height-g),e.dataset.placement=f,e.style.left=`${u}px`,e.style.top=`${m}px`,r){const v=D(d,"--cw-Feedback-tooltip-caretWidth")/2,b=h?n.left+n.width/2-u:n.top+n.height/2-m,P=h?s.width:s.height;e.style.setProperty("--_cw-Tooltip-caretOffset",`${C(b,v,P-v)}px`);}}#V(e){const t=this.#M(),i=e??I(a(()=>this.props.showDelay),Q);if(!(this.#o||a(()=>this.props.disabled===!0))){if(this.#G(),i===0||t===void 0){this.#L(!0);return;}this.#Ee(t,i),this.#g=t.setTimeout(()=>{const n=this.#we(t);if(this.#g=void 0,this.#M()!==t){this.#V(n);return;}this.#L(!0);},i);}}#j(e){const t=this.#M(),i=e??I(a(()=>this.props.hideDelay),Z);if(this.#G(),this.#U(),this.#y=!1,!(this.#o||!this.#e||this.#B())){if(i===0||t===void 0){this.#L(!1);return;}this.#Ee(t,i),this.#v=t.setTimeout(()=>{const n=this.#we(t);if(this.#v=void 0,this.#M()!==t){this.#j(n);return;}this.#B()||this.#L(!1);},i);}}#Ee(e,t){this.#T=e,this.#Y=e.performance.now(),this.#K=t;}#we(e){return Math.max(0,this.#K-(e.performance.now()-this.#Y));}#G(){this.#g!==void 0&&(this.#T?.clearTimeout(this.#g),this.#g=void 0);}#U(){this.#v!==void 0&&(this.#T?.clearTimeout(this.#v),this.#v=void 0);}#p(){this.#G(),this.#U(),this.#T=void 0;}#M(){return(this.#t?.ownerDocument??this.#i?.ownerDocument??this.styleElement?.ownerDocument)?.defaultView??void 0;}#Oe(){const e=this.#i;this.#o=!0,this.#e=!1,this.#re(),this.#p(),this.#m?.(),this.#m=void 0,this.#se(),this.#fe(this.#t),e!==null&&(e.removeEventListener("pointerenter",this.#W),e.removeEventListener("pointerleave",this.#J),e.removeEventListener("focusin",this.#N),e.removeEventListener("focusout",this.#$));}}function oe(o,e,t,i,n){const s=(r,c)=>r in i?L(i[r]):n?void 0:c,d={"aria-controls":s("aria-controls",t?o:void 0),"aria-describedby":s("aria-describedby",o),"aria-expanded":s("aria-expanded",t?`${e}`:void 0),"aria-haspopup":s("aria-haspopup",t?"dialog":void 0),tabIndex:n?void 0:0};for(const r of Object.keys(i))r.startsWith("aria-")&&!k(r)&&(d[r]=L(i[r]));return J(d,()=>e,()=>o);}function $(o,e,t,i,n){const s=e.disabled===!0,d=e.trigger,r=o,c=d===void 0&&!s&&!("tabindex"in r),l=(h,f)=>d!==void 0?void 0:h in r?L(r[h]):s?void 0:f,p={};for(const h of Object.keys(r))!["children","class","classList","ref","style"].includes(h)&&(d===void 0||!h.startsWith("aria-"))&&(p[h]=r[h]);return{attributes:{...p,"aria-controls":n?l("aria-controls",t):void 0,"aria-describedby":l("aria-describedby",t),"aria-expanded":n?l("aria-expanded",`${i}`):void 0,"aria-haspopup":n?l("aria-haspopup","dialog"):void 0,class:n?"cw-RichTooltip-trigger":"cw-PlainTooltip-trigger",tabIndex:c?0:void 0},content:()=>d===void 0?o.children:d(oe(t,i,n,r,s))};}function B(o){return<V when={S(o())}>
|
|
2
2
|
<span class="cw-RichTooltip-action">{o()}</span>
|
|
3
|
-
</V
|
|
3
|
+
</V>;}class re extends N{constructor(e){super(e,!1);}render(e,t){const i=<span class="cw-PlainTooltip">
|
|
4
4
|
<span class="cw-PlainTooltip-trigger"/>
|
|
5
5
|
<span aria-hidden="true"class="cw-PlainTooltip-popup"hidden popover="manual"role="tooltip"/>
|
|
6
|
-
</span>,n=i.firstElementChild,s=i.lastElementChild;return T(n,this.renderTrigger(e)),T(s,()=>this.props.content),this.setPopup(s),t?.(n),i}}const ae
|
|
6
|
+
</span>,n=i.firstElementChild,s=i.lastElementChild;return T(n,this.renderTrigger(e)),T(s,()=>this.props.content),this.setPopup(s),t?.(n),i;}}const ae=/* @__PURE__ */H(()=>(o,e)=>{const t=e.id??M(),i=e.open===!0&&e.disabled!==!0,n=$(o,e,t,i,!1);return<span class={o.class}classList={{...o.classList,"cw-PlainTooltip":!0,"cw-PlainTooltip-open":i}}style={o.style}>
|
|
7
7
|
<span{...n.attributes}>{n.content()}</span>
|
|
8
8
|
<span aria-hidden={i?void 0:"true"}class="cw-PlainTooltip-popup"classList={{[w]:e.caret===!0}}hidden={!i}id={t}popover="manual"role="tooltip">{e.content}</span>
|
|
9
|
-
</span
|
|
9
|
+
</span>;},()=>re),Ee=o=>ae(_(o,["children","content"]));class de extends N{#n;constructor(e){super(e,!0),this.#n=null;}get persistent(){return super.readProp("persistent",!0)[0]===!0;}applyComponentProps(){super.readProp("persistent"),super.applyComponentProps();}applyPopupName(e){const t=super.readProps(["popupLabel","title"]),i=S(t.title),n=`${e.id}-title`;i?(e.setAttribute("aria-labelledby",n),e.removeAttribute("aria-label")):(e.removeAttribute("aria-labelledby"),e.setAttribute("aria-label",t.popupLabel??X)),this.#n!==null&&(this.#n.id=n,i?this.#n.removeAttribute("aria-hidden"):this.#n.setAttribute("aria-hidden","true"));}render(e,t){const i=<span class="cw-RichTooltip">
|
|
10
10
|
<span class="cw-RichTooltip-trigger"/>
|
|
11
11
|
<span aria-hidden="true"class={`cw-RichTooltip-popup ${F}`}hidden popover="manual"role="dialog"tabindex="-1">
|
|
12
12
|
<span class="cw-RichTooltip-title"/>
|
|
13
13
|
<span class="cw-RichTooltip-supportingText"/>
|
|
14
14
|
</span>
|
|
15
|
-
</span>,n=i.firstElementChild,s=i.lastElementChild;return this.#n=s.firstElementChild,T(n,this.renderTrigger(e)),T(this.#n,()=>this.props.title),T(s.lastElementChild,()=>this.props.supportingText??this.props.content),T(s,B(()=>this.props.action),null),this.setPopup(s),t?.(n),i}}const le
|
|
15
|
+
</span>,n=i.firstElementChild,s=i.lastElementChild;return this.#n=s.firstElementChild,T(n,this.renderTrigger(e)),T(this.#n,()=>this.props.title),T(s.lastElementChild,()=>this.props.supportingText??this.props.content),T(s,B(()=>this.props.action),null),this.setPopup(s),t?.(n),i;}}const le=/* @__PURE__ */H(()=>(o,e)=>{const t=e.id??M(),i=e.open===!0&&e.disabled!==!0,n=S(e.title),s=$(o,e,t,i,!0);return<span class={o.class}classList={{...o.classList,"cw-RichTooltip":!0,"cw-RichTooltip-open":i}}style={o.style}>
|
|
16
16
|
<span{...s.attributes}>{s.content()}</span>
|
|
17
17
|
<span aria-hidden={i?void 0:"true"}aria-label={n?void 0:e.popupLabel??X}aria-labelledby={n?`${t}-title`:void 0}class={`cw-RichTooltip-popup ${F}`}classList={{[w]:e.caret===!0}}hidden={!i}id={t}popover="manual"role="dialog"tabindex="-1">
|
|
18
18
|
<span aria-hidden={n?void 0:"true"}class="cw-RichTooltip-title"id={`${t}-title`}>{e.title}</span>
|
|
@@ -21,4 +21,4 @@ import{Show as V,children as j,createSignal as x,createUniqueId as M,getListener
|
|
|
21
21
|
</span>
|
|
22
22
|
{B(()=>e.action)}
|
|
23
23
|
</span>
|
|
24
|
-
</span
|
|
24
|
+
</span>;},()=>de),we=o=>le(_(o,["action","children","content","supportingText","title"]));export{Ee as PlainTooltip,re as PlainTooltipController,we as RichTooltip,de as RichTooltipController,N as TooltipController};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{insert as s}from"solid-js/web";import{defineDomComponent as a}from"..";import"./icon.css";const n="_cw-Icon-autoMirror",d
|
|
1
|
+
import{insert as s}from"solid-js/web";import{defineDomComponent as a}from"..";import"./icon.css";const n="_cw-Icon-autoMirror",d=/* @__PURE__ */a(()=>(o,e)=>("name"in e&&(o.children=e.name),<i aria-hidden="true"role="img"{...o}classList={{...o.classList,[n]:e.autoMirror,"cw-Icon":!0}}/>),o=>class extends o{#e;constructor(e){super(e,{styleElementIsFunction:!0}),this.#e="name"in e;}applyComponentProps(){const[e,r]=super.readProp("autoMirror");if(r&&super.setClass(n,e??!1),!this.#e)return;const[t,i]=super.readProp("name");i&&(super.styleElement.textContent=t??"");}render(e){const r=<i aria-hidden="true"class="cw-Icon"role="img"/>;return this.#e||s(r,e),r;}});export{d as Icon};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Icon as p}from"./icon";export{p as Icon};
|
|
1
|
+
import{Icon as p}from"./icon";export{p as Icon};
|
package/target/esbuild/index.jsx
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{defineDomComponent as m}from"./dom";export{m as defineDomComponent};
|
|
1
|
+
import{defineDomComponent as m}from"./dom";export{m as defineDomComponent};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import{For as E,createUniqueId as w,onCleanup as A,untrack as P}from"solid-js";import{defineDomComponent as C}from"..";import{TextFieldController as D,renderTextField as L}from"./text-field";import"../container/elevation-shadow.css";const x="cw-Autocomplete",y="cw-Autocomplete-menu",r="cw-Autocomplete-option",a=8;function M(l,e){return L(l,e,()=>{const t=w();return{className:x,labelId:`${t}-label`,controlAttributes:{"aria-autocomplete":"list","aria-controls":t,"aria-expanded":"false",autocomplete:e.autocomplete??"off",role:"combobox"},content:()=><div aria-labelledby={`${t}-label`}class={`${y} cw-elevationShadow`}id={t}popover="manual"role="listbox">
|
|
2
2
|
<E each={e.options}>{o=><div aria-selected="false"class={r}role="option">{o}</div>}</E>
|
|
3
|
-
</div>}})}class S extends D{#i;#e;#n;#r;#c;#s;constructor(e){super(e),this.#i=w(),this.#e=null,this.#n=!1,this.#r=null,this.#c=0,this.#s=void 0,A(()=>{this.#t(!1),this.#s!==void 0&&this.#e?.ownerDocument.defaultView?.cancelAnimationFrame(this.#s)})}#l(){return this.#e===null?[]:Array.from(this.#e.children)}#p(){return this.#r===null?-1:this.#l().indexOf(this.#r)}#a(){const e=this.functionElement;return e!==null&&!e.readOnly&&!e.matches(":disabled")}#t(e){this.#n=e&&this.#a(),this.#n||this.#o(-1),this.#d()}#o(e){const t=this.#l(),o=t[e]??null;for(const n of t)n.setAttribute("aria-selected",n===o?"true":"false");if(this.#r=o,o===null){super.setAttribute("aria-activedescendant",void 0);return}o.id===""&&(o.id=`${this.#i}-${this.#c++}`),super.setAttribute("aria-activedescendant",o.id),o.scrollIntoView({block:"nearest"})}#d(){const e=this.#e,t=this.#l().length,o=this.#n&&t>0;if(this.#r!==null&&this.#p()<0&&this.#o(-1),super.setAttribute("aria-expanded",o?"true":"false"),!(e===null||!e.isConnected)){if(e.matches(":popover-open")===o){o&&this.#u();return}o?(e.showPopover(),this.#m(),e.ownerDocument.defaultView?.addEventListener("resize",this.#u),e.ownerDocument.addEventListener("scroll",this.#u,!0)):(e.hidePopover(),e.ownerDocument.defaultView?.removeEventListener("resize",this.#u),e.ownerDocument.removeEventListener("scroll",this.#u,!0))}}#m(){const e=this.#e,t=this.styleElement?.querySelector(".cw-TextField-control")??null,o=e?.ownerDocument.defaultView??null;if(e===null||t===null||o===null)return;const n=t.getBoundingClientRect(),s=o.innerHeight-n.bottom-a,u=n.top-a,i=s<e.scrollHeight&&u>s;e.style.setProperty("inline-size",`${n.width}px`),e.style.setProperty("left",`${n.left}px`),e.style.setProperty("top",i?"auto":`${n.bottom}px`),e.style.setProperty("bottom",i?`${o.innerHeight-n.top}px`:"auto"),e.style.setProperty("max-block-size",`${Math.max(0,i?u:s)}px`),e.style.setProperty("transform-origin",i?"bottom center":"top center")}#u=()=>{const e=this.#e?.ownerDocument.defaultView??null;e===null||this.#s!==void 0||(this.#s=e.requestAnimationFrame(()=>{this.#s=void 0,this.#e?.matches(":popover-open")===!0&&this.#m()}))};#h(e,t){const o=P(()=>this.props.options)[e];this.#t(!1),o!==void 0&&this.#a()&&this.commitValue(o,t)}#f=()=>{this.#o(-1),this.#t(!0)};#v=e=>{const t=this.#l().length,o=this.#n&&t>0,n=this.#p();if(!(e.defaultPrevented||e.isComposing))switch(e.key){case"ArrowDown":case"ArrowUp":{const s=e.key==="ArrowDown";if(t===0||!this.#a())return;e.preventDefault(),o?s?this.#o(n<t-1?n+1:0):this.#o(n>0?n-1:t-1):(this.#t(!0),e.altKey||this.#o(s?0:t-1));return}case"Home":case"End":if(!o||n<0)return;e.preventDefault(),this.#o(e.key==="Home"?0:t-1);return;case"Enter":if(!o||n<0)return;e.preventDefault(),this.#h(n,e);return;case"Escape":if(!o)return;e.preventDefault(),this.#t(!1);return}};#b=e=>{const t=e.relatedTarget;(t===null||!(this.styleElement?.contains(t)??!1))&&this.#t(!1)};#E=e=>{e.preventDefault()};#w=e=>{const t=e.target.closest(`.${r}`),o=t===null?-1:this.#l().indexOf(t);o>=0&&this.#h(o,e)};applyComponentProps(){const[e]=super.readProp("autocomplete"),[,t]=super.readProp("options");super.applyComponentProps(),super.setClass(x,!0),super.setAttribute("autocomplete",e??"off"),this.labelElement?.setAttribute("id",`${this.#i}-label`),this.#n&&!this.#a()&&this.#t(!1),t&&queueMicrotask(()=>this.#d())}onFunctionElementChanged(e){const t=e;super.onFunctionElementChanged(e),t!==null&&(super.setAttribute("aria-autocomplete","list"),super.setAttribute("aria-controls",this.#i),super.setAttribute("aria-expanded","false"),super.setAttribute("role","combobox"),t.addEventListener("focusout",this.#b),t.addEventListener("input",this.#f),t.addEventListener("keydown",this.#v))}renderExtension(){const e=this.#i;return<div aria-labelledby={`${e}-label`}class={`${y} cw-elevationShadow`}id={e}on:click={this.#w}on:mousedown={this.#E}popover="manual"ref={t=>this.#e=t}role="listbox">
|
|
3
|
+
</div>};});}class S extends D{#i;#e;#n;#r;#c;#s;constructor(e){super(e),this.#i=w(),this.#e=null,this.#n=!1,this.#r=null,this.#c=0,this.#s=void 0,A(()=>{this.#t(!1),this.#s!==void 0&&this.#e?.ownerDocument.defaultView?.cancelAnimationFrame(this.#s);});}#l(){return this.#e===null?[]:Array.from(this.#e.children);}#p(){return this.#r===null?-1:this.#l().indexOf(this.#r);}#a(){const e=this.functionElement;return e!==null&&!e.readOnly&&!e.matches(":disabled");}#t(e){this.#n=e&&this.#a(),this.#n||this.#o(-1),this.#d();}#o(e){const t=this.#l(),o=t[e]??null;for(const n of t)n.setAttribute("aria-selected",n===o?"true":"false");if(this.#r=o,o===null){super.setAttribute("aria-activedescendant",void 0);return;}o.id===""&&(o.id=`${this.#i}-${this.#c++}`),super.setAttribute("aria-activedescendant",o.id),o.scrollIntoView({block:"nearest"});}#d(){const e=this.#e,t=this.#l().length,o=this.#n&&t>0;if(this.#r!==null&&this.#p()<0&&this.#o(-1),super.setAttribute("aria-expanded",o?"true":"false"),!(e===null||!e.isConnected)){if(e.matches(":popover-open")===o){o&&this.#u();return;}o?(e.showPopover(),this.#m(),e.ownerDocument.defaultView?.addEventListener("resize",this.#u),e.ownerDocument.addEventListener("scroll",this.#u,!0)):(e.hidePopover(),e.ownerDocument.defaultView?.removeEventListener("resize",this.#u),e.ownerDocument.removeEventListener("scroll",this.#u,!0));}}#m(){const e=this.#e,t=this.styleElement?.querySelector(".cw-TextField-control")??null,o=e?.ownerDocument.defaultView??null;if(e===null||t===null||o===null)return;const n=t.getBoundingClientRect(),s=o.innerHeight-n.bottom-a,u=n.top-a,i=s<e.scrollHeight&&u>s;e.style.setProperty("inline-size",`${n.width}px`),e.style.setProperty("left",`${n.left}px`),e.style.setProperty("top",i?"auto":`${n.bottom}px`),e.style.setProperty("bottom",i?`${o.innerHeight-n.top}px`:"auto"),e.style.setProperty("max-block-size",`${Math.max(0,i?u:s)}px`),e.style.setProperty("transform-origin",i?"bottom center":"top center");}#u=()=>{const e=this.#e?.ownerDocument.defaultView??null;e===null||this.#s!==void 0||(this.#s=e.requestAnimationFrame(()=>{this.#s=void 0,this.#e?.matches(":popover-open")===!0&&this.#m();}));};#h(e,t){const o=P(()=>this.props.options)[e];this.#t(!1),o!==void 0&&this.#a()&&this.commitValue(o,t);}#f=()=>{this.#o(-1),this.#t(!0);};#v=e=>{const t=this.#l().length,o=this.#n&&t>0,n=this.#p();if(!(e.defaultPrevented||e.isComposing))switch(e.key){case"ArrowDown":case"ArrowUp":{const s=e.key==="ArrowDown";if(t===0||!this.#a())return;e.preventDefault(),o?s?this.#o(n<t-1?n+1:0):this.#o(n>0?n-1:t-1):(this.#t(!0),e.altKey||this.#o(s?0:t-1));return;}case"Home":case"End":if(!o||n<0)return;e.preventDefault(),this.#o(e.key==="Home"?0:t-1);return;case"Enter":if(!o||n<0)return;e.preventDefault(),this.#h(n,e);return;case"Escape":if(!o)return;e.preventDefault(),this.#t(!1);return;}};#b=e=>{const t=e.relatedTarget;(t===null||!(this.styleElement?.contains(t)??!1))&&this.#t(!1);};#E=e=>{e.preventDefault();};#w=e=>{const t=e.target.closest(`.${r}`),o=t===null?-1:this.#l().indexOf(t);o>=0&&this.#h(o,e);};applyComponentProps(){const[e]=super.readProp("autocomplete"),[,t]=super.readProp("options");super.applyComponentProps(),super.setClass(x,!0),super.setAttribute("autocomplete",e??"off"),this.labelElement?.setAttribute("id",`${this.#i}-label`),this.#n&&!this.#a()&&this.#t(!1),t&&queueMicrotask(()=>this.#d());}onFunctionElementChanged(e){const t=e;super.onFunctionElementChanged(e),t!==null&&(super.setAttribute("aria-autocomplete","list"),super.setAttribute("aria-controls",this.#i),super.setAttribute("aria-expanded","false"),super.setAttribute("role","combobox"),t.addEventListener("focusout",this.#b),t.addEventListener("input",this.#f),t.addEventListener("keydown",this.#v));}renderExtension(){const e=this.#i;return<div aria-labelledby={`${e}-label`}class={`${y} cw-elevationShadow`}id={e}on:click={this.#w}on:mousedown={this.#E}popover="manual"ref={t=>this.#e=t}role="listbox">
|
|
4
4
|
<E each={this.props.options}>{t=><div aria-selected="false"class={r}role="option">{t}</div>}</E>
|
|
5
|
-
</div
|
|
5
|
+
</div>;}}const $=/* @__PURE__ */C(()=>M,()=>S);export{$ as Autocomplete,S as AutocompleteController};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{createEffect as b,createMemo as x,createSignal as m,onCleanup as O}from"solid-js";import{isServer as L}from"solid-js/web";const M
|
|
1
|
+
import{createEffect as b,createMemo as x,createSignal as m,onCleanup as O}from"solid-js";import{isServer as L}from"solid-js/web";const M=/* @__PURE__ */new Set(["class","classList","style"]),l=/* @__PURE__ */new WeakMap();function S(e){const t=e.getRootNode();return t.nodeType===Node.DOCUMENT_NODE||t.nodeType===Node.DOCUMENT_FRAGMENT_NODE?t:e.ownerDocument;}function E(e){const{form:t}=e;return t===void 0?e.closest("form"):t;}function a(e,t){let n=l.get(t);n===void 0&&(n=/* @__PURE__ */new Set(),l.set(t,n),t.addEventListener("reset",F,!0)),n.add(e);}function p(e,t){const n=l.get(t);n===void 0||!n.delete(e)||n.size!==0||(l.delete(t),t.removeEventListener("reset",F,!0));}function I(e){const t=S(e.element),n=E(e.element);e.root=t,a(e,t),n!==null&&!n.isConnected&&(e.detachedForm=n,a(e,n));}function R(e){e.root!==null&&p(e,e.root),e.detachedForm!==null&&p(e,e.detachedForm),e.root=null,e.detachedForm=null;}function w(e,t){let n=!0;const r=()=>{!n||e.root===null||t.eventPhase!==Event.NONE||(n=!1,t.defaultPrevented||e.callback());};e.lastEvent=t,queueMicrotask(r),setTimeout(r,0);}function F(e){const t=l.get(e.currentTarget);if(t!==void 0)for(const n of Array.from(t))n.root===null||n.lastEvent===e||(n.root!==S(n.element)&&(R(n),I(n),n.onRootChanged?.()),E(n.element)===e.target&&w(n,e));}function D(e){const t=e,n={},r={};for(const o of Object.keys(t).filter(u=>u!=="children")){const u=M.has(o)?n:r;Object.defineProperty(u,o,{enumerable:!0,get:()=>t[o]});}return{containerProps:n,elementProps:r,get children(){return t.children;}};}function s(e){return e!=null&&typeof e!="boolean"&&e!=="";}function T(...e){return e.find(s);}function h(...e){for(const t of e){const n=t();if(s(n))return n;}}function H(e){const t=e.errorText;if(s(t))return t;const n=e.error;return n===!0||s(n)?n:void 0;}function J(e,t){return t!==void 0&&t!==!0?t:h(()=>e.supportingText,()=>e.helperText);}function X(...e){const t=e.filter(n=>n!==void 0&&n!=="");return t.length===0?void 0:t.join(" ");}function z(e){return T(e.errorText,e.error,e.supportingText,e.helperText);}function j(e){const{error:t,errorText:n}=e;return t===!0||T(n,t)!==void 0;}const N=["restingMotion","floatingMotion","restingLabel"],P="--_cw-field-label-inline-size",k={attributes:!0,characterData:!0,childList:!0,subtree:!0};function c(e){return typeof e=="function"?c(e()):Array.isArray(e)?e.flatMap(c):s(e)?[typeof e.nodeType=="number"?e:String(e)]:[];}function g(e,t){return N.map(n=><span aria-hidden="true"class={`${e}-${n}`}inert>
|
|
2
2
|
{t()}
|
|
3
3
|
<span class={`${e}-asterisk`}>*</span>
|
|
4
|
-
</span>)}function A(e,t,n){const r=x(()=>c(t())),[o,u]=m(void 0,{equals:!1});let d;return b(()=>{if(d!==void 0||r().every(f=>typeof f=="string"))return;const i=n();if(i===null)return;const v=i.ownerDocument.defaultView?.MutationObserver??MutationObserver;d=new v(f=>{f.some(y=>y.target!==i)&&u()}),d.observe(i,k)}),O(()=>d?.disconnect()),g(e,()=>(o(),r().map(i=>typeof i=="string"?i:i.cloneNode(!0))))}function $(e){if(L){let r;return{content(o){return r=o,o},copies(){return g(e,()=>r)}}}const[t,n]=m();return{content(r){return n(()=>r),r},copies(r){return A(e,t,r??(()=>null))}}}function B(e,t){const n=e.styleElement?.querySelector(`.${t}-floatingMotion`)??null,r=n?.ownerDocument.defaultView?.ResizeObserver;if(n===null||r===void 0)return()=>{};const o=new r(([u])=>e.setStyle(P,`${u.borderBoxSize[0].inlineSize}px`));return o.observe(n),()=>o.disconnect()}function V(e,t,n){const r={element:e,callback:t,onRootChanged:n,root:null,detachedForm:null,lastEvent:null};return I(r),()=>R(r)}export{$ as createFieldLabel,T as firstInputSlot,h as firstInputSlotOf,j as hasInputError,X as idReferencesOf,H as inputErrorOf,V as observeFormReset,B as observeLabelInlineSize,D as splitInputElementProps,z as supportingSlot,J as supportingSlotOf};
|
|
4
|
+
</span>);}function A(e,t,n){const r=x(()=>c(t())),[o,u]=m(void 0,{equals:!1});let d;return b(()=>{if(d!==void 0||r().every(f=>typeof f=="string"))return;const i=n();if(i===null)return;const v=i.ownerDocument.defaultView?.MutationObserver??MutationObserver;d=new v(f=>{f.some(y=>y.target!==i)&&u();}),d.observe(i,k);}),O(()=>d?.disconnect()),g(e,()=>(o(),r().map(i=>typeof i=="string"?i:i.cloneNode(!0))));}function $(e){if(L){let r;return{content(o){return r=o,o;},copies(){return g(e,()=>r);}};}const[t,n]=m();return{content(r){return n(()=>r),r;},copies(r){return A(e,t,r??(()=>null));}};}function B(e,t){const n=e.styleElement?.querySelector(`.${t}-floatingMotion`)??null,r=n?.ownerDocument.defaultView?.ResizeObserver;if(n===null||r===void 0)return()=>{};const o=new r(([u])=>e.setStyle(P,`${u.borderBoxSize[0].inlineSize}px`));return o.observe(n),()=>o.disconnect();}function V(e,t,n){const r={element:e,callback:t,onRootChanged:n,root:null,detachedForm:null,lastEvent:null};return I(r),()=>R(r);}export{$ as createFieldLabel,T as firstInputSlot,h as firstInputSlotOf,j as hasInputError,X as idReferencesOf,H as inputErrorOf,V as observeFormReset,B as observeLabelInlineSize,D as splitInputElementProps,z as supportingSlot,J as supportingSlotOf};
|