@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{Checkbox as t,CheckboxController as r}from"./checkbox";import{AssistChip as i,ChipController as n,ElevatedAssistChip as s,ElevatedFilterChip as h,ElevatedSuggestionChip as C,FilterChip as u,InputChip as l,SuggestionChip as m}from"./chip";import{RadioButton as g,RadioButtonController as a,RadioGroup as S}from"./radio";import{MultiChoiceSegmentedButtonRow as c,SegmentedButton as B,SegmentedButtonController as P,SegmentedButtonGroup as f,SegmentedButtonGroupController as G,SingleChoiceSegmentedButtonRow as R}from"./segmented";import{Switch as w,SwitchController as y}from"./switch";export{i as AssistChip,t as Checkbox,r as CheckboxController,n as ChipController,s as ElevatedAssistChip,h as ElevatedFilterChip,C as ElevatedSuggestionChip,u as FilterChip,l as InputChip,c as MultiChoiceSegmentedButtonRow,g as RadioButton,a as RadioButtonController,S as RadioGroup,B as SegmentedButton,P as SegmentedButtonController,f as SegmentedButtonGroup,G as SegmentedButtonGroupController,R as SingleChoiceSegmentedButtonRow,m as SuggestionChip,w as Switch,y as SwitchController};
|
|
1
|
+
import{Checkbox as t,CheckboxController as r}from"./checkbox";import{AssistChip as i,ChipController as n,ElevatedAssistChip as s,ElevatedFilterChip as h,ElevatedSuggestionChip as C,FilterChip as u,InputChip as l,SuggestionChip as m}from"./chip";import{RadioButton as g,RadioButtonController as a,RadioGroup as S}from"./radio";import{MultiChoiceSegmentedButtonRow as c,SegmentedButton as B,SegmentedButtonController as P,SegmentedButtonGroup as f,SegmentedButtonGroupController as G,SingleChoiceSegmentedButtonRow as R}from"./segmented";import{Switch as w,SwitchController as y}from"./switch";export{i as AssistChip,t as Checkbox,r as CheckboxController,n as ChipController,s as ElevatedAssistChip,h as ElevatedFilterChip,C as ElevatedSuggestionChip,u as FilterChip,l as InputChip,c as MultiChoiceSegmentedButtonRow,g as RadioButton,a as RadioButtonController,S as RadioGroup,B as SegmentedButton,P as SegmentedButtonController,f as SegmentedButtonGroup,G as SegmentedButtonGroupController,R as SingleChoiceSegmentedButtonRow,m as SuggestionChip,w as Switch,y as SwitchController};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import{onCleanup as R,onMount as g}from"solid-js";import{defineDomComponent as I}from"..";import{defineInteractableComponent as L}from"../state";import{InteractableController as y}from"../state/controller";import{SELECTION_INTERACTION_STATES as p,applyNativeSelectionAttributes as k,eventRootOf as m,notifySelectionChange as T,observeFormReset as P,splitContainerElementProps as M}from"./base";import"./selection.css";const s="cw-RadioButton-selected",h="cw-RadioButton-disabled",C="cw-RadioButton-input",a
|
|
1
|
+
import{onCleanup as R,onMount as g}from"solid-js";import{defineDomComponent as I}from"..";import{defineInteractableComponent as L}from"../state";import{InteractableController as y}from"../state/controller";import{SELECTION_INTERACTION_STATES as p,applyNativeSelectionAttributes as k,eventRootOf as m,notifySelectionChange as T,observeFormReset as P,splitContainerElementProps as M}from"./base";import"./selection.css";const s="cw-RadioButton-selected",h="cw-RadioButton-disabled",C="cw-RadioButton-input",a=/* @__PURE__ */new WeakMap();function v(n,e){return n.name!==""&&n.name===e.name&&n.form===e.form;}function B(n,e){const t=m(n);if(t===void 0)return()=>{};let o=a.get(t);if(o===void 0){const l=/* @__PURE__ */new Map(),u=b=>{const d=b.target;d?.localName!=="input"||d.type!=="radio"||queueMicrotask(()=>{for(const[c,{onGroupChange:S}]of l)(c===d||v(c,d))&&S();});};o={listener:u,radios:l},a.set(t,o),t.addEventListener("change",u);}const{listener:i,radios:r}=o;return r.set(n,e),()=>{r.get(n)===e&&(r.delete(n),r.size===0&&(t.removeEventListener("change",i),a.delete(t)));};}function H(n){const e=m(n),t=e===void 0?void 0:a.get(e)?.radios;for(const[o,{onPeerSelected:i}]of t??[])o!==n&&v(o,n)&&i();}function E(){return<span class="cw-RadioButton-circle"aria-hidden="true"/>;}class G extends y{#e;#o;#i;#t;#n;constructor(e){super(e,{baseInteractionCssClassName:"cw-RadioButton",enabledInteractionStates:p}),this.#e="selected"in e?"selected":"checked"in e?"checked":void 0,this.#o=t=>this.#a(t),this.#i=!1,this.#t=!1,this.#n=void 0,g(()=>{const t=super.functionElement;if(t===null)return;const o=B(t,{onGroupChange:()=>this.#d(),onPeerSelected:()=>super.setClass(s,t.checked)}),i=P(t,()=>this.#d());this.#n=()=>{o(),i();},this.#r(t);}),R(()=>{this.#n?.(),this.#n=void 0;});}#r(e){super.setClass(s,e.checked),e.checked&&H(e);}#d(){const e=super.functionElement;e!==null&&(this.#e!==void 0&&(e.checked=this.props[this.#e]===!0),this.#r(e));}#a(e){const t=super.functionElement;t===null||this.#t||(T([this.props.onChange,this.props.onSelectedChange],t.checked,e),this.#d());}applyComponentProps(){const e=super.readProps(["checked","defaultChecked","defaultSelected","disabled","name","required","selected","tabIndex","value"]),t=super.functionElement;if(t!==null){if(!this.#i){const o=(e.defaultSelected??e.defaultChecked)===!0;this.#i=!0,t.defaultChecked=o,this.#e===void 0&&(t.checked=o);}this.#e!==void 0&&e[`${this.#e}Changed`]&&(t.checked=e[this.#e]===!0),e.disabledChanged&&(this.#t=e.disabled===!0,super.setClass(h,this.#t),super.setEnabledInteractionStates(this.#t?0:p)),(e.disabledChanged||e.nameChanged||e.requiredChanged||e.tabIndexChanged||e.valueChanged)&&k(t,e,(o,i)=>super.setAttribute(o,i)),this.#r(t);}}onFunctionElementChanged(e){super.functionElement?.removeEventListener("change",this.#o),super.onFunctionElementChanged(e),e?.addEventListener("change",this.#o);}render(e,t){return<label class="cw-RadioButton">
|
|
2
2
|
<input class={C}ref={t}type="radio"/>
|
|
3
3
|
{E()}
|
|
4
4
|
<span class="_cw-selection-label">{e}</span>
|
|
5
|
-
</label
|
|
5
|
+
</label>;}}function w(n,e){const[t,o]=M(n),i=("selected"in e?e.selected:"checked"in e?e.checked:e.defaultSelected??e.defaultChecked)===!0;return<label{...t}classList={{...t.classList,[h]:e.disabled===!0,[s]:i,"cw-RadioButton":!0}}>
|
|
6
6
|
<input{...o}checked={i}class={C}disabled={e.disabled===!0}name={e.name}required={e.required===!0}tabIndex={e.tabIndex}type="radio"value={e.value}/>
|
|
7
7
|
{E()}
|
|
8
8
|
<span class="_cw-selection-label">{n.children}</span>
|
|
9
|
-
</label
|
|
9
|
+
</label>;}const J=/* @__PURE__ */L(()=>w,()=>G);function f(n){return`_cw-RadioGroup-${n??"vertical"}`;}const N=/* @__PURE__ */I(()=>(n,e)=><fieldset aria-orientation={e.orientation??"vertical"}{...n}classList={{...n.classList,[f(e.orientation)]:!0,"cw-RadioGroup":!0}}role="radiogroup"/>,n=>class extends n{#e;constructor(e){super(e,{styleElementIsFunction:!0}),this.#e="attr:aria-orientation"in e;}applyComponentProps(){const[e,t]=super.readProp("orientation");t&&(super.setClass("orientation",f(e)),this.#e||super.setAttribute("aria-orientation",e??"vertical"));}render(e){return<fieldset class="cw-RadioGroup"role="radiogroup">{e}</fieldset>;}});export{J as RadioButton,G as RadioButtonController,N as RadioGroup};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{For as W,createComponent as w,createContext as Y,createEffect as $,createMemo as L,createSignal as k,mergeProps as Z,on as ee,onCleanup as _,onMount as A,untrack as te,useContext as I}from"solid-js";import{isServer as x}from"solid-js/web";import{defineDomComponent as ne}from"..";import{DomController as oe}from"../dom/client";import{defineInteractableComponent as ie}from"../state";import{InteractableController as re}from"../state/controller";import{deferAfterDelegatedCancellation as P}from"../util/event";import{SELECTION_INTERACTION_STATES as B,applyNativeSelectionAttributes as se,notifySelectionChange as T,observeFormReset as de}from"./base";import"./selection.css";const E=Y(),M="cw-SegmentedButton-selected",O="cw-SegmentedButton-disabled",R="cw-SegmentedButton-invalid",V="cw-SegmentedButton-grouped",H="cw-SegmentedButton-vertical",J="cw-SegmentedButton-first",X="cw-SegmentedButton-last",N="cw-SegmentedButton-only",F="_cw-selection-form-value",ae="data-cw-invalid-value";function C(o){return o!==void 0&&o.trim().length!==0}function G(o,e){const t=o===void 0?[]:typeof o=="string"?[o]:o;return new Set(e?t:t.slice(0,1))}function ue(o,e){const t
|
|
1
|
+
import{For as W,createComponent as w,createContext as Y,createEffect as $,createMemo as L,createSignal as k,mergeProps as Z,on as ee,onCleanup as _,onMount as A,untrack as te,useContext as I}from"solid-js";import{isServer as x}from"solid-js/web";import{defineDomComponent as ne}from"..";import{DomController as oe}from"../dom/client";import{defineInteractableComponent as ie}from"../state";import{InteractableController as re}from"../state/controller";import{deferAfterDelegatedCancellation as P}from"../util/event";import{SELECTION_INTERACTION_STATES as B,applyNativeSelectionAttributes as se,notifySelectionChange as T,observeFormReset as de}from"./base";import"./selection.css";const E=Y(),M="cw-SegmentedButton-selected",O="cw-SegmentedButton-disabled",R="cw-SegmentedButton-invalid",V="cw-SegmentedButton-grouped",H="cw-SegmentedButton-vertical",J="cw-SegmentedButton-first",X="cw-SegmentedButton-last",N="cw-SegmentedButton-only",F="_cw-selection-form-value",ae="data-cw-invalid-value";function C(o){return o!==void 0&&o.trim().length!==0;}function G(o,e){const t=o===void 0?[]:typeof o=="string"?[o]:o;return new Set(e?t:t.slice(0,1));}function ue(o,e){const t=/* @__PURE__ */new Set(),i=[];return o.forEach((n,r)=>{!C(n.value)||t.has(n.value)||(t.add(n.value),n.disabled!==!0&&i.push(r));}),i.find(n=>(o[n].tabIndex??-1)>=0)??i.find(n=>e.has(o[n].value))??i[0];}function le(o,e){return(o.element().compareDocumentPosition(e.element())&Node.DOCUMENT_POSITION_FOLLOWING)!==0?-1:1;}function z(o,e){return<>
|
|
2
2
|
<span class="_cw-SegmentedButton-icon">
|
|
3
3
|
<svg class="_cw-SegmentedButton-checkmark"viewBox="0 0 18 18">
|
|
4
4
|
<path d="M3.75 9.5 7.25 13 14.25 6"/>
|
|
@@ -6,10 +6,10 @@ import{For as W,createComponent as w,createContext as Y,createEffect as $,create
|
|
|
6
6
|
<span class="_cw-SegmentedButton-iconContent">{o()}</span>
|
|
7
7
|
</span>
|
|
8
8
|
<span class="_cw-SegmentedButton-label">{e()}</span>
|
|
9
|
-
|
|
9
|
+
</>;}class ce extends re{#e;#n;#i;#r;#o;#a;#m;#v;#f;#d;#u;#p;#t;#l;#S;#h;#g;#c;constructor(e){super(e,{baseInteractionCssClassName:"cw-SegmentedButton",enabledInteractionStates:B});const[t,i]=k(void 0,{equals:(n,r)=>n!==void 0&&r!==void 0&&n.valid===r.valid&&n.first===r.first&&n.last===r.last&&n.tabStop===r.tabStop});this.#e=I(E),this.#n=this.#e!==void 0?void 0:"selected"in e?"selected":"checked"in e?"checked":void 0,this.#i="attr:aria-checked"in e,this.#r="attr:aria-disabled"in e,this.#o="attr:aria-pressed"in e,this.#a="attr:role"in e,this.#m=t,this.#v=i,this.#f=n=>this.#B(n),this.#d=!1,this.#u=!1,this.#p=!1,this.#t=!1,this.#l=0,this.#S=null,this.#h=void 0,this.#g=void 0,this.#c=void 0,A(()=>{const n=super.functionElement,r=this.#e;if(n===null)return;const s=r?.register({disabled:()=>this.#t,element:()=>super.functionElement,setLayout:this.#v,tabIndex:()=>super.readProp("tabIndex",!0)[0],value:()=>super.readProp("value",!0)[0]}),d=de(n,()=>this.#E());this.#c=()=>{s?.(),d();};}),_(()=>{this.#l++,this.#c?.(),this.#c=void 0;});}#s(){return this.#e===void 0||this.#m()?.valid!==!1;}#C(){const e=this.#e,t=super.readProp("value",!0)[0];return e!==void 0?C(t)&&this.#s()&&e.isSelected(t):this.#n===void 0?this.#d:this.props[this.#n]===!0;}#b(){const e=super.functionElement,t=this.#S;if(e===null)return;const i=this.#C(),n=this.#e?.multiple()===!1,r=n?i?"radio":"unradio":i?"pressed":"unpressed",s=this.#t||!i||!this.#s()||e.name==="",d=e.getAttribute("form");r!==this.#g&&(this.#g=r,super.setClass(M,i),this.#a||super.setAttribute("role",n?"radio":void 0),this.#i||super.setAttribute("aria-checked",n?String(i):void 0),this.#o||super.setAttribute("aria-pressed",n?void 0:String(i))),t!==null&&(t.disabled!==s&&(t.disabled=s),t.name!==e.name&&(t.name=e.name),t.value!==e.value&&(t.value=e.value),t.getAttribute("form")!==d&&(d===null?t.removeAttribute("form"):t.setAttribute("form",d)));}#y(e){this.#h=e,super.setClass(J,e.first),super.setClass(X,e.last),super.setClass(N,e.first&&e.last),super.setClass(R,!e.valid),super.setAttribute(ae,e.valid?void 0:"true"),this.#r||super.setAttribute("aria-disabled",e.valid?void 0:"true"),super.setEnabledInteractionStates(!e.valid||this.#t?0:B),super.setAttribute("tabindex",e.tabStop?0:-1);}#E(){this.#e!==void 0?this.#e.resetSelection():this.#n===void 0&&(this.#d=this.#u),this.#b();}#B(e){const t=super.functionElement;if(!this.#s()){e.preventDefault(),e.stopImmediatePropagation();return;}if(t===null||this.#t||e.defaultPrevented)return;const i=++this.#l;P(e,t,()=>{const n=this.#e,r=super.readProp("value",!0)[0],s=[this.props.onChange,this.props.onSelectedChange];if(!(i!==this.#l||e.defaultPrevented||this.#t||super.functionElement!==t||!this.#s())){if(n!==void 0)C(r)&&n.requestSelection(r,e,s);else{const d=!this.#C();this.#n===void 0&&(this.#d=d),T(s,d,e);}this.#b();}},!1);}onEvent(e){(e.type!=="click"||this.#s())&&super.onEvent(e);}applyComponentProps(){const e=super.readProps(["checked","defaultSelected","disabled","name","selected","tabIndex","value"]),t=super.functionElement,i=this.#e,n=this.#m();if(t!==null){if(this.#p||(this.#p=!0,this.#u=e.defaultSelected===!0,this.#d=this.#u),e.disabledChanged&&(this.#t=e.disabled===!0,super.setClass(O,this.#t),super.setEnabledInteractionStates(this.#t||!this.#s()?0:B)),e.disabledChanged||e.nameChanged||e.tabIndexChanged||e.valueChanged){const{disabled:r,name:s,value:d}=e;se(t,i===void 0?e:{disabled:r,name:s,value:d},(f,m)=>super.setAttribute(f,m));}i!==void 0&&(super.setClass(V,!0),super.setClass(H,i.orientation()==="vertical"),(e.disabledChanged||e.tabIndexChanged||e.valueChanged)&&i.invalidate(),n!==void 0&&n!==this.#h&&this.#y(n)),this.#b();}}onFunctionElementChanged(e){super.functionElement?.removeEventListener("click",this.#f,!0),super.onFunctionElementChanged(e),e?.addEventListener("click",this.#f,!0);}render(e,t){const i=this.props,n=L(()=>i.label??e),r=s=>{this.#S=s;};return<button class="cw-SegmentedButton"ref={t}type="button">
|
|
10
10
|
{z(()=>i.icon,n)}
|
|
11
11
|
<input class={F}ref={r}type="hidden"/>
|
|
12
|
-
</button
|
|
12
|
+
</button>;}}function me(o,e){const t=I(E),i=e.disabled===!0,n=t?.claimServer?.(e.value,i,e.tabIndex),r=n!==void 0?n.selected:("selected"in e?e.selected:"checked"in e?e.checked:e.defaultSelected)===!0,s=t?.multiple()===!1,d=n?.valid===!1;return<button aria-checked={s?r?"true":"false":void 0}aria-disabled={d?"true":void 0}aria-pressed={s?void 0:r?"true":"false"}data-cw-invalid-value={d?"true":void 0}role={s?"radio":void 0}tabIndex={n===void 0?e.tabIndex:n.tabStop?0:-1}{...o}classList={{...o.classList,[O]:i,[J]:n?.first===!0,[V]:t!==void 0,[R]:d,[X]:n?.last===!0,[N]:n?.first===!0&&n.last,[M]:r,[H]:t?.orientation()==="vertical","cw-SegmentedButton":!0}}disabled={i}name={e.name}type="button"value={e.value}>
|
|
13
13
|
{z(()=>e.icon,()=>e.label??o.children)}
|
|
14
14
|
<input class={F}disabled={i||d||!r||(e.name??"")===""}form={o.form}name={e.name}type="hidden"value={e.value}/>
|
|
15
|
-
</button
|
|
15
|
+
</button>;}const Se=/* @__PURE__ */ie(()=>me,()=>ce);function q(o){return`_cw-SegmentedButtonGroup-${o??"horizontal"}`;}function D(o){return o.parentElement?.closest(".cw-SegmentedButtonGroup")??null;}class he extends oe{#e;#n;#i;#r;#o;constructor(e){super(e,{styleElementIsFunction:!0}),this.#e=I(E),this.#n="attr:aria-orientation"in e,this.#i=t=>this.#a(t),this.#r=()=>this.#e?.invalidate(),this.#o=void 0,A(()=>{const t=super.styleElement,i=this.#e,n=t?.ownerDocument.defaultView?.MutationObserver;t===null||i===void 0||n===void 0||(this.#o=new n(()=>i.invalidate()),this.#o.observe(t,{childList:!0,subtree:!0}));}),_(()=>{this.#o?.disconnect(),this.#o=void 0;});}#a(e){const t=super.styleElement,i=this.props.multiple!==!0,n=(this.props.orientation??"horizontal")==="vertical",r=e.target?.closest("button.cw-SegmentedButton");if(t===null||r===null||r===void 0||D(r)!==t)return;const s=Array.from(t.querySelectorAll('button.cw-SegmentedButton:not(:disabled):not([aria-disabled="true"])')).filter(p=>D(p)===t),d=s.indexOf(r),f=getComputedStyle(t).direction==="rtl",m=e.key==="Home"?-d:e.key==="End"?s.length-1-d:e.key==="ArrowDown"&&(n||i)?1:e.key==="ArrowUp"&&(n||i)?-1:e.key==="ArrowRight"&&(!n||i)?f?-1:1:e.key==="ArrowLeft"&&(!n||i)?f?1:-1:0;if(d<0||m===0||s.length<2)return;const l=s[(d+m+s.length)%s.length];P(e,t,()=>{super.styleElement!==t||!l.isConnected||(l.focus(),i&&l.click());});}applyComponentProps(){const e=super.readProps(["multiple","orientation"]);e.orientationChanged&&super.setClass("orientation",q(e.orientation)),e.multipleChanged&&super.setAttribute("role",e.multiple===!0?"group":"radiogroup"),(e.multipleChanged||e.orientationChanged)&&!this.#n&&super.setAttribute("aria-orientation",e.multiple===!0?void 0:e.orientation??"horizontal");}onStyleElementChanged(e){const t=super.styleElement;t?.removeEventListener("keydown",this.#i),t?.removeEventListener("focusin",this.#r),super.onStyleElementChanged(e),e?.addEventListener("keydown",this.#i),e?.addEventListener("focusin",this.#r);}render(e){return<div class="cw-SegmentedButtonGroup">{e}</div>;}}function ge(o,e){const t=e.multiple===!0;return<div aria-orientation={t?void 0:e.orientation??"horizontal"}role={t?"group":"radiogroup"}{...o}classList={{...o.classList,[q(e.orientation)]:!0,"cw-SegmentedButtonGroup":!0}}/>;}const be=/* @__PURE__ */ne(()=>ge,()=>he);function ve(o,e){const t=/* @__PURE__ */new Set();let i=0,n=!1,r;return(s,d,f)=>{const m=i++,l=o();m===0&&l!==void 0&&(r=ue(l,e()));const p=C(s)&&!t.has(s),h=p&&e().has(s),y=!n&&p&&!d&&(l!==void 0?m===r:h||(f??-1)>=0||e().size===0);return p&&t.add(s),y&&(n=!0),{first:m===0,last:l!==void 0&&m===l.length-1,selected:h,tabStop:y,valid:p};};}const U=o=>{const e="value"in o,t="items"in o,i=te(()=>G(o.defaultValue,o.multiple===!0)),n=()=>o.multiple===!0,[r,s]=k(i),d=L(()=>G(e?o.value:[...r()],n())),f=/* @__PURE__ */new Set();let m,l=!1;const p=()=>{const a=Array.from(f).filter(u=>u.element()?.isConnected===!0).sort(le),g=/* @__PURE__ */new Set(),b=/* @__PURE__ */new Set();for(const u of a){const S=u.value();C(S)&&!g.has(S)&&(g.add(S),b.add(u));}const c=a.filter(u=>b.has(u)&&!u.disabled()),v=c.find(u=>{const S=u.element();return S.getRootNode().activeElement===S;})??c.find(u=>(u.tabIndex()??-1)>=0)??c.find(u=>d().has(u.value()))??c[0];a.forEach((u,S)=>u.setLayout({first:S===0,last:S===a.length-1,tabStop:u===v,valid:b.has(u)}));},h=()=>{l||(l=!0,queueMicrotask(()=>{l=!1,p();}));},y=()=>{const a=L(()=>o.items);return m=a,<W each={a()}>{g=><Se{...g}/>}</W>;},K={claimServer:x?ve(()=>m?.(),d):void 0,invalidate:h,isSelected:a=>d().has(a),multiple:n,orientation:()=>o.orientation??"horizontal",register(a){return f.add(a),h(),()=>{f.delete(a),h();};},requestSelection(a,g,b){const c=new Set(d()),v=n()?!c.has(a):!0;!n()&&c.has(a)||!v&&o.required===!0&&c.size===1||(n()||c.clear(),v?c.add(a):c.delete(a),e||s(c),T(b,v,g),o.onChange?.(n()?[...c]:a,g));},resetSelection(){e||s(i);}},j=Z(o,{get children(){return t?y():o.children;}}),Q=w(E.Provider,{value:K,get children(){return w(be,j);}});return x||(A(p),$(ee(d,h,{defer:!0}))),Q;},Ge=o=><U{...o}multiple={!1}/>,De=o=><U{...o}multiple={!0}/>;export{De as MultiChoiceSegmentedButtonRow,Se as SegmentedButton,ce as SegmentedButtonController,U as SegmentedButtonGroup,he as SegmentedButtonGroupController,Ge as SingleChoiceSegmentedButtonRow};
|
|
@@ -3,12 +3,12 @@ import{onCleanup as l,onMount as h}from"solid-js";import{defineInteractableCompo
|
|
|
3
3
|
<span class="cw-Switch-selectedIcon">{n()}</span>
|
|
4
4
|
<span class="cw-Switch-unselectedIcon">{e()}</span>
|
|
5
5
|
</span>
|
|
6
|
-
</span
|
|
6
|
+
</span>;}class b extends p{#t;#i;#s;#e;#n;constructor(e){super(e,{baseInteractionCssClassName:"cw-Switch",enabledInteractionStates:d}),this.#t="checked"in e,this.#i=t=>this.#d(t),this.#s=!1,this.#e=!1,this.#n=void 0,h(()=>{const t=super.functionElement;t!==null&&(this.#n=C(t,()=>this.#c()));}),l(()=>{this.#n?.(),this.#n=void 0;});}#c(){const e=super.functionElement;e!==null&&(this.#t&&(e.checked=this.props.checked===!0),super.setClass(c,e.checked));}#d(e){const t=super.functionElement;t===null||this.#e||(S([this.props.onChange,this.props.onCheckedChange],t.checked,e),this.#c());}applyComponentProps(){const e=super.readProps(["checked","defaultChecked","disabled","name","required","tabIndex","value"]),t=super.functionElement;t!==null&&(this.#s||(this.#s=!0,t.defaultChecked=e.defaultChecked===!0,this.#t||(t.checked=e.defaultChecked===!0)),this.#t&&e.checkedChanged&&(t.checked=e.checked===!0),e.disabledChanged&&(this.#e=e.disabled===!0,super.setClass(o,this.#e),super.setEnabledInteractionStates(this.#e?0:d)),(e.disabledChanged||e.nameChanged||e.requiredChanged||e.tabIndexChanged||e.valueChanged)&&m(t,e,(s,i)=>super.setAttribute(s,i)),super.setClass(c,t.checked));}onFunctionElementChanged(e){super.functionElement?.removeEventListener("change",this.#i),super.onFunctionElementChanged(e),e?.addEventListener("change",this.#i);}render(e,t){return<label class="cw-Switch">
|
|
7
7
|
<input class={r}ref={t}role="switch"type="checkbox"/>
|
|
8
8
|
{a(()=>this.props.selectedIcon,()=>this.props.unselectedIcon)}
|
|
9
9
|
<span class="_cw-selection-label">{e}</span>
|
|
10
|
-
</label
|
|
10
|
+
</label>;}}function w(n,e){const[t,s]=f(n),i=("checked"in e?e.checked:e.defaultChecked)===!0;return<label{...t}classList={{...t.classList,[c]:i,[o]:e.disabled===!0,"cw-Switch":!0}}>
|
|
11
11
|
<input{...s}checked={i}class={r}disabled={e.disabled===!0}name={e.name}required={e.required===!0}role="switch"tabIndex={e.tabIndex}type="checkbox"value={e.value}/>
|
|
12
12
|
{a(()=>e.selectedIcon,()=>e.unselectedIcon)}
|
|
13
13
|
<span class="_cw-selection-label">{n.children}</span>
|
|
14
|
-
</label
|
|
14
|
+
</label>;}const L=/* @__PURE__ */u(()=>w,()=>b);export{L as Switch,b as SwitchController};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{checkArgument as n}from"../util";class t{static Unrounded=new t;radius;smoothing;constructor(e=0,r=0){n(Number.isFinite(e)&&e>=0,"corner radius must be at least 0"),n(r>=0&&r<=1,"corner smoothing must be in [0, 1]"),this.radius=e,this.smoothing=r,Object.freeze(this)}}export{t as CornerRounding};
|
|
1
|
+
import{checkArgument as n}from"../util";class t{static Unrounded=new t();radius;smoothing;constructor(e=0,r=0){n(Number.isFinite(e)&&e>=0,"corner radius must be at least 0"),n(r>=0&&r<=1,"corner smoothing must be in [0, 1]"),this.radius=e,this.smoothing=r,Object.freeze(this);}}export{t as CornerRounding};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{checkArgument as M}from"../util";import{Point as f,checkPoint as z,directionVector as $,isConvex as I}from"./point";const w=1e-4;let p;class y{points;constructor(n){const t=p;if(p=void 0,t==="frame"){this.points=n;return}M(n.length===8,"a cubic curve requires exactly eight coordinates"),M(t?N(n):n.every(Number.isFinite),"cubic coordinates must be finite"),this.points=Object.freeze(t?n:Array.from(n)),Object.freeze(this)}get anchor0X(){return this.points[0]}get anchor0Y(){return this.points[1]}get control0X(){return this.points[2]}get control0Y(){return this.points[3]}get control1X(){return this.points[4]}get control1Y(){return this.points[5]}get anchor1X(){return this.points[6]}get anchor1Y(){return this.points[7]}static fromPoints(n,t,r,u){return x([n.x,n.y,t.x,t.y,r.x,r.y,u.x,u.y])}static straightLine(n,t,r,u){return x([n,t,n+(r-n)/3,t+(u-t)/3,n+2*(r-n)/3,t+2*(u-t)/3,r,u])}static circularArc(n,t,r,u,i,o){const c=r-n,b=u-t,m=$(c,b),s=$(i-n,o-t),a=m.dot(s);if(a
|
|
1
|
+
import{checkArgument as M}from"../util";import{Point as f,checkPoint as z,directionVector as $,isConvex as I}from"./point";const w=1e-4;let p;class y{points;constructor(n){const t=p;if(p=void 0,t==="frame"){this.points=n;return;}M(n.length===8,"a cubic curve requires exactly eight coordinates"),M(t?N(n):n.every(Number.isFinite),"cubic coordinates must be finite"),this.points=Object.freeze(t?n:Array.from(n)),Object.freeze(this);}get anchor0X(){return this.points[0];}get anchor0Y(){return this.points[1];}get control0X(){return this.points[2];}get control0Y(){return this.points[3];}get control1X(){return this.points[4];}get control1Y(){return this.points[5];}get anchor1X(){return this.points[6];}get anchor1Y(){return this.points[7];}static fromPoints(n,t,r,u){return x([n.x,n.y,t.x,t.y,r.x,r.y,u.x,u.y]);}static straightLine(n,t,r,u){return x([n,t,n+(r-n)/3,t+(u-t)/3,n+2*(r-n)/3,t+2*(u-t)/3,r,u]);}static circularArc(n,t,r,u,i,o){const c=r-n,b=u-t,m=$(c,b),s=$(i-n,o-t),a=m.dot(s);if(a>0.999)return y.straightLine(r,u,i,o);const h=Math.sqrt(c*c+b*b)*4/3*(Math.sqrt(2*(1-a))-Math.sqrt(Math.max(0,1-a*a)))/(1-a)*(-m.y*(i-n)+m.x*(o-t)>=0?1:-1);return x([r,u,r-m.y*h,u+m.x*h,i+s.y*h,o-s.x*h,i,o]);}static empty(n,t){return x([n,t,n,t,n,t,n,t]);}static interpolate(n,t,r){const u=[];F(r);for(let i=0;i<8;i++)u.push(n.points[i]+(t.points[i]-n.points[i])*r);return B(u);}pointAt(n){return new f(P(this.points,0,n),P(this.points,1,n));}zeroLength(){return q(this.points,0);}convexTo(n){const[t,r,,,,,u,i]=this.points;return I(new f(t,r),new f(u,i),new f(n.points[6],n.points[7]));}calculateBounds(n=[0,0,0,0],t=!1){return Y(n),j(n),S(n,this.points,0,t),n;}split(n){return T(this.points,0,n).map(x);}reverse(){return x(O(this.points));}transformed(n){const{points:t}=this;return y.fromPoints(n(t[0],t[1]),n(t[2],t[3]),n(t[4],t[5]),n(t[6],t[7]));}equals(n){return n instanceof y&&this.points.every((t,r)=>t===n.points[r]);}toString(){const[n,t,r,u,i,o,c,b]=this.points;return`Cubic(${n},${t} ${r},${u} ${i},${o} ${c},${b})`;}}function x(e){return p="frozen",new y(e);}function B(e){return p="frame",new y(e);}function F(e){M(Number.isFinite(e),"interpolation progress must be finite");}function N(e){let n=0;for(let t=0;t<8;t++)n+=e[t]*0;return n===0;}function O(e){return[e[6],e[7],e[4],e[5],e[2],e[3],e[0],e[1]];}function P(e,n,t){const r=1-t,u=r*r,i=t*t;return e[n]*u*r+e[n+2]*3*t*u+e[n+4]*3*i*r+e[n+6]*i*t;}function T(e,n,t){const r=1-t,u=P(e,n,t),i=P(e,n+1,t),o=e[n],c=e[n+1],b=e[n+2],m=e[n+3],s=e[n+4],a=e[n+5],h=e[n+6],l=e[n+7];return z(u,i),[[o,c,o*r+b*t,c*r+m*t,o*r*r+b*2*r*t+s*t*t,c*r*r+m*2*r*t+a*t*t,u,i],[u,i,b*r*r+s*2*r*t+h*t*t,m*r*r+a*2*r*t+l*t*t,s*r+h*t,a*r+l*t,h,l]];}function q(e,n){for(let t=0;t<8;t++)if(!(Math.abs(e[n+t]-e[n+(t&1)])<w))return!1;return!0;}function E(e,n){return Math.abs(e.points[6]-n.points[0])<=w&&Math.abs(e.points[7]-n.points[1])<=w;}function Y(e){M(e.length>=4,"bounds buffer must have at least four entries");}function j(e){e[0]=e[1]=1/0,e[2]=e[3]=-1/0;}function S(e,n,t,r){const u=q(n,t);for(let i=0;i<2;i++){const o=n[t+i],c=n[t+i+2],b=n[t+i+4],m=n[t+i+6];let s=o,a=o;if(!u)if(s=Math.min(o,m),a=Math.max(o,m),r)s=Math.min(s,c,b),a=Math.max(a,c,b);else{const h=-o+3*c-3*b+m,l=2*o-4*c+2*b,L=-o+c,k=l*l-4*h*L,v=[];Math.abs(h)>=1e-4?k>0&&v.push((-l+Math.sqrt(k))/(2*h),(-l-Math.sqrt(k))/(2*h)):Math.abs(l)>=1e-4&&v.push(-L/l);for(const C of v)if(C>0&&C<1){const d=1-C,A=o*d*d*d+3*c*C*d*d+3*b*C*C*d+m*C*C*C;s=Math.min(s,A),a=Math.max(a,A);}}e[i]=Math.min(e[i],s),e[i+2]=Math.max(e[i+2],a);}}export{w as CUBIC_CONTINUITY_EPSILON,y as Cubic,Y as checkBounds,F as checkProgress,P as coordinateOf,S as extendBounds,E as isContiguous,q as isZeroLength,B as newFrameCubic,x as newFrozenCubic,j as resetBounds,O as reverseCoordinates,T as splitCoordinates};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{CornerRounding as t}from"./corner-rounding";import{CUBIC_CONTINUITY_EPSILON as p,Cubic as a}from"./cubic";import{MATERIAL_SHAPE_NAMES as i,MaterialShapes as m}from"./material-shapes";import{Morph as h}from"./morph";import{Path as f,
|
|
1
|
+
import{CornerRounding as t}from"./corner-rounding";import{CUBIC_CONTINUITY_EPSILON as p,Cubic as a}from"./cubic";import{MATERIAL_SHAPE_NAMES as i,MaterialShapes as m}from"./material-shapes";import{Morph as h}from"./morph";import{Path as f,compactSvgPath as s,cubicsToPath as x,formatPathCoordinate as u,morphToCssPath as y,morphToPath as c,roundedPolygonToPath as C,toCssPath as g,toSvgPath as l}from"./path";import{Point as T,directionVector as M,distanceBetween as b,isConvex as I}from"./point";import{PolygonFeature as R,RoundedPolygon as A,isRoundedPolygon as E}from"./rounded-polygon";import{Shapes as _}from"./shapes";export{p as CUBIC_CONTINUITY_EPSILON,t as CornerRounding,a as Cubic,i as MATERIAL_SHAPE_NAMES,m as MaterialShapes,h as Morph,f as Path,T as Point,R as PolygonFeature,A as RoundedPolygon,_ as Shapes,s as compactSvgPath,x as cubicsToPath,M as directionVector,b as distanceBetween,u as formatPathCoordinate,I as isConvex,E as isRoundedPolygon,y as morphToCssPath,c as morphToPath,C as roundedPolygonToPath,g as toCssPath,l as toSvgPath};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{checkArgument as
|
|
1
|
+
import{checkArgument as M}from"../util";import{CornerRounding as n}from"./corner-rounding";import{Point as p,lengthOfVector as N}from"./point";import{RoundedPolygon as f}from"./rounded-polygon";import{Shapes as i}from"./shapes";const A=new p(0.5,0.5),B=[];function o(t,r,y){const c=[],S=[],k=t.map(([,,d,u])=>new n(d,u)),h=(d,u,l)=>{c.push(d,u),S.push(k[l]);};if(y){const d=r*2,u=2*Math.PI/d,l=t.map(([a,g])=>Math.atan2(g-0.5,a-0.5)),w=t.map(([a,g])=>N(a-0.5,g-0.5));for(let a=0;a<d;a++){const g=a%2===0;for(let m=0;m<t.length-(g?0:1);m++){const P=g?m:t.length-1-m,C=g?u*a+l[P]:u*a+(u-l[P]+2*l[0]);h(0.5+Math.cos(C)*w[P],0.5+Math.sin(C)*w[P],P);}}}else for(let d=0;d<r;d++)for(let u=0;u<t.length;u++){const l=new p(t[u][0],t[u][1]).rotate(d*360/r,A);h(l.x,l.y,u);}return f.fromVertices(c,n.Unrounded,S,0.5,0.5);}function s(t,r){return t.transformed((y,c)=>new p(y,c).rotate(r));}function b(t,r){return t.transformed((y,c)=>new p(y,c*r));}function e(t,r){return B[t]??=r().normalized();}function T(){return e(0,()=>i.circle(10));}function V(){return e(5,()=>s(b(i.circle(),0.64),-45));}function E(){return e(6,()=>o([[0.961,0.039,0.426],[1.001,0.428],[1,0.609,1]],2,!0));}function L(){return e(12,()=>o([[0.5,-9e-3,0.172],[1.03,0.365,0.164],[0.828,0.97,0.169]],1,!0));}function O(){return e(15,()=>i.star(8,1,0.8,new n(0.15)));}function D(){return e(16,()=>o([[1.237,1.236,0.258],[0.5,0.918,0.233]],4));}function F(){return e(19,()=>s(i.star(9,1,0.8,new n(0.5)),-90));}function G(){return e(24,()=>o([[0.193,0.277,0.053],[0.176,0.055,0.053]],10));}class R{static get Circle(){return T();}static get Square(){return e(1,()=>i.rectangle(1,1,new n(0.3)));}static get Slanted(){return e(2,()=>o([[0.926,0.97,0.189,0.811],[-0.021,0.967,0.187,0.057]],2));}static get Arch(){return e(3,()=>s(f.fromNumVertices(4,1,0,0,n.Unrounded,[new n(1),new n(1),new n(0.2),new n(0.2)]),-135));}static get SemiCircle(){return e(4,()=>i.rectangle(1.6,1,n.Unrounded,[new n(0.2),new n(0.2),new n(1),new n(1)]));}static get Oval(){return V();}static get Pill(){return E();}static get Triangle(){return e(7,()=>s(f.fromNumVertices(3,1,0,0,new n(0.2)),-90));}static get Arrow(){return e(8,()=>o([[0.5,0.892,0.313],[-0.216,1.05,0.207],[0.499,-0.16,0.215,1],[1.225,1.06,0.211]],1));}static get Fan(){return e(9,()=>o([[1.004,1,0.148,0.417],[0,1,0.151],[0,-3e-3,0.148],[0.978,0.02,0.803]],1));}static get Diamond(){return e(10,()=>o([[0.5,1.096,0.151,0.524],[0.04,0.5,0.159]],2));}static get ClamShell(){return e(11,()=>o([[0.171,0.841,0.159],[-0.02,0.5,0.14],[0.17,0.159,0.159]],2));}static get Pentagon(){return L();}static get Gem(){return e(13,()=>o([[0.499,1.023,0.241,0.778],[-5e-3,0.792,0.208],[0.073,0.258,0.228],[0.433,0,0.491]],1,!0));}static get VerySunny(){return e(14,()=>o([[0.5,1.08,0.085],[0.358,0.843,0.085]],8));}static get Sunny(){return O();}static get Cookie4Sided(){return D();}static get Cookie6Sided(){return e(17,()=>o([[0.723,0.884,0.394],[0.5,1.099,0.398]],6));}static get Cookie7Sided(){return e(18,()=>s(i.star(7,1,0.75,new n(0.5)),-90));}static get Cookie9Sided(){return F();}static get Cookie12Sided(){return e(20,()=>s(i.star(12,1,0.8,new n(0.5)),-90));}static get Clover4Leaf(){return e(21,()=>o([[0.5,0.074],[0.725,-0.099,0.476]],4,!0));}static get Clover8Leaf(){return e(22,()=>o([[0.5,0.036],[0.758,-0.101,0.209]],8));}static get Burst(){return e(23,()=>o([[0.5,-6e-3,6e-3],[0.592,0.158,6e-3]],12));}static get SoftBurst(){return G();}static get Boom(){return e(25,()=>o([[0.457,0.296,7e-3],[0.5,-0.051,7e-3]],15));}static get SoftBoom(){return e(26,()=>o([[0.733,0.454],[0.839,0.437,0.532],[0.949,0.449,0.439,1],[0.998,0.478,0.174]],16,!0));}static get Flower(){return e(27,()=>o([[0.37,0.187],[0.416,0.049,0.381],[0.479,1e-3,0.095]],8,!0));}static get Puffy(){return e(28,()=>b(o([[0.5,0.053],[0.545,-0.04,0.405],[0.67,-0.035,0.426],[0.717,0.066,0.574],[0.722,0.128],[0.777,2e-3,0.36],[0.914,0.149,0.66],[0.926,0.289,0.66],[0.881,0.346],[0.94,0.344,0.126],[1.003,0.437,0.255]],2,!0),0.742));}static get PuffyDiamond(){return e(29,()=>o([[0.87,0.13,0.146],[0.818,0.357],[1,0.332,0.853]],4,!0));}static get Ghostish(){return e(30,()=>o([[0.5,0,1],[1,0,1],[1,1.14,0.254,0.106],[0.575,0.906,0.253]],1,!0));}static get PixelCircle(){return e(31,()=>o([[0.5,0],[0.704,0],[0.704,0.065],[0.843,0.065],[0.843,0.148],[0.926,0.148],[0.926,0.296],[1,0.296]],2,!0));}static get PixelTriangle(){return e(32,()=>o([[0.11,0.5],[0.113,0],[0.287,0],[0.287,0.087],[0.421,0.087],[0.421,0.17],[0.56,0.17],[0.56,0.265],[0.674,0.265],[0.675,0.344],[0.789,0.344],[0.789,0.439],[0.888,0.439]],1,!0));}static get Bun(){return e(33,()=>o([[0.796,0.5],[0.853,0.518,1],[0.992,0.631,1],[0.968,1,1]],2,!0));}static get Heart(){return e(34,()=>o([[0.5,0.268,0.016],[0.792,-0.066,0.958],[1.064,0.276,1],[0.501,0.946,0.129]],1,!0));}static byName(r){return M(x.includes(r),`unknown Material shape: ${r}`),R[r];}static all(){return x.map(r=>({name:r,polygon:R[r]}));}}const x=/* @__PURE__ */H();function H(){return Object.freeze(Object.getOwnPropertyNames(R).filter(t=>t<"a"));}export{x as MATERIAL_SHAPE_NAMES,R as MaterialShapes,T as circleShape,D as cookie4SidedShape,F as cookie9SidedShape,V as ovalShape,L as pentagonShape,E as pillShape,G as softBurstShape,O as sunnyShape};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{checkArgument as I,checkState as R}from"../util";import{checkBounds as F,checkProgress as v,coordinateOf as x,newFrameCubic as j,splitCoordinates as z}from"./cubic";import{checkPoint as N,lengthOfVector as W}from"./point";const k
|
|
1
|
+
import{checkArgument as I,checkState as R}from"../util";import{checkBounds as F,checkProgress as v,coordinateOf as x,newFrameCubic as j,splitCoordinates as z}from"./cubic";import{checkPoint as N,lengthOfVector as W}from"./point";const k=/* @__PURE__ */new WeakMap();class _{start;end;cubicCount;#e;#n;constructor(e,n){const o=[],r=[];U(O(e),O(n),o,r);for(const u of[o,r]){for(let s=8;s<u.length;s+=8)u[s]=u[s-2],u[s+1]=u[s-1];u[u.length-2]=u[0],u[u.length-1]=u[1];}for(let u=0;u<o.length;u++)r[u]=r[u]-o[u];this.start=e,this.end=n,this.cubicCount=o.length/8,this.#e=o,this.#n=r,Object.freeze(this);}asCubics(e){const n=[];v(e);for(let o=0;o<this.#e.length;o+=8)n.push(this.#t(o,e));return n;}forEachCubic(e,n){v(e);for(let o=0;o<this.#e.length;o+=8)n(this.#t(o,e));}calculateBounds(e=[0,0,0,0],n=!0){return w(e,this.start.calculateBounds([0,0,0,0],n),this.end.calculateBounds([0,0,0,0],n));}calculateMaxBounds(e=[0,0,0,0]){return w(e,this.start.calculateMaxBounds(),this.end.calculateMaxBounds());}_frame(e,n){v(e);for(let o=0;o<this.#e.length;o++)n[o]=this.#e[o]+this.#n[o]*e;return n;}#t(e,n){const o=this.#e,r=this.#n;return j([o[e]+r[e]*n,o[e+1]+r[e+1]*n,o[e+2]+r[e+2]*n,o[e+3]+r[e+3]*n,o[e+4]+r[e+4]*n,o[e+5]+r[e+5]*n,o[e+6]+r[e+6]*n,o[e+7]+r[e+7]*n]);}}function w(t,e,n){return F(t),t[0]=Math.min(e[0],n[0]),t[1]=Math.min(e[1],n[1]),t[2]=Math.max(e[2],n[2]),t[3]=Math.max(e[3],n[3]),t;}function f(t){const e=t-Math.floor(t);return e<1?e:0;}function p(t,e){return Math.min(Math.abs(t-e),1-Math.abs(t-e));}function B(t,e,n){return n>=e?e<=t&&t<=n:t>=e||t<=n;}function P(t){let e=t[0],n=t[1];for(let o=1;o<=3;o++){const r=x(t,0,o/3),u=x(t,1,o/3);N(r,u),t.push(W(r-e,u-n)),e=r,n=u;}return t;}function A(t){return t[8]+t[9]+t[10];}function E(t,e){const n=[];let o=0;for(let r=0;r<t.length;r++){const u=e[r+1];u-e[r]>1e-4&&(n.push({curve:t[r],start:o,end:u}),o=u);}return R(n.length>0,"a measured outline requires a curve of nonzero length"),n.push({...n.pop(),end:1}),n;}function O(t){const{features:e}=t;let n=k.get(t);if(n===void 0){const o=[],r=[0],u=[];let s=0,c=0;for(let l=0;l<e.length;l++){const{cubics:a}=e[l];for(let i=0;i<a.length;i++)o.push(P([...a[i].points])),s+=A(o[o.length-1]),r.push(s);}I(s>0&&Number.isFinite(s),"a polygon outline must have length");for(let l=0;l<r.length;l++)r[l]=r[l]/s;for(let l=0;l<e.length;l++){const{cubics:a,kind:i,convex:h}=e[l],m=c+(a.length>>1),d=a[0].points,g=a[a.length-1].points;i==="corner"&&u.push({convex:h,progress:f((r[m]+r[m+1])/2),x:(d[0]+g[6])/2,y:(d[1]+g[7])/2}),c+=a.length;}n={segments:E(o,r),corners:u},k.set(t,n);}return n;}function S({curve:t,start:e,end:n},o){const r=Math.max(e,Math.min(o,n));let u=(n-e===0?0:(r-e)/(n-e))*A(t),s=1;for(let l=8;l<11;l++){if(t[l]>=u){s=(l-7)/3-(1-u/t[l])/3;break;}u-=t[l];}const c=z(t,0,s);return[{curve:P(c[0]),start:e,end:r},{curve:P(c[1]),start:r,end:n}];}function q(t,e){const n=t.find(({end:o})=>Math.abs(o-e)<=1e-6);return e<1e-4?0:n===void 0?e:n.end<1?n.end:0;}function D(t,e){const n=t.findIndex(({start:s,end:c})=>s<=e&&e<=c),o=S(t[n],e),r=[o[1].curve],u=[0,o[1].end-e];for(let s=n+1;s<n+t.length;s++){const{curve:c,end:l}=t[s%t.length];r.push(c),u.push(l-e+(s<t.length?0:1));}return r.push(o[0].curve),u.push(1),E(r,u);}function C(t,e,n){const o=t.length-1;let r=0;for(;r<o&&!B(n,t[r],t[r+1]);)r++;const u=r===o?0:r+1,s=t[r],c=e[r],l=f(t[u]-s);return f(c+f(e[u]-c)*(l<1e-3?0.5:f(n-s)/l));}function T(t,e){const n=[],o=/* @__PURE__ */new Set(),r=[],u=[];let s=0;for(let c=0;c<t.length;c++)for(let l=0;l<e.length;l++){const a=t[c],i=e[l],h=(a.x-i.x)*(a.x-i.x)+(a.y-i.y)*(a.y-i.y);a.convex===i.convex&&(n.push([a,i,h]),s=Math.max(s,h*1e-9));}for(let c=0;c<n.length;c++)n[c][2]=s>0?Math.round(n[c][2]/s):0;if(n.sort((c,l)=>c[2]-l[2]||c[0].progress-l[0].progress||c[1].progress-l[1].progress),n.length===1){const[{progress:c},{progress:l}]=n[0];return[[c,f(c+0.5)],[l,f(l+0.5)]];}for(let c=0;c<n.length;c++){const l=n[c][0],a=n[c][1],i=l.progress,h=a.progress;if(o.has(l)||o.has(a))continue;let m=r.findIndex(d=>d>i);if(m<0&&(m=r.length),r.length>0){const d=(m||r.length)-1,g=m%r.length;if(p(i,r[d])<=1e-4||p(i,r[g])<=1e-4||p(h,u[d])<=1e-4||p(h,u[g])<=1e-4||r.length>=2&&!B(h,u[d],u[g]))continue;}if(r.splice(m,0,i),u.splice(m,0,h),o.add(l).add(a),r.length===Math.min(t.length,e.length))break;}return r.length>=2?[r,u]:[[0,0.5],[0,0.5]];}function M(t,e){for(let n=0;n<8;n++)t.push(e[n]);}function U(t,e,n,o){const[r,u]=T(t.corners,e.corners),s=q(e.segments,C(r,u,0)),c=t.segments,l=s===0?e.segments:D(e.segments,s);let a=0,i=0,h=c[0],m=l[0];for(;h!==void 0&&m!==void 0;){const d=a===c.length-1?1:h.end,g=i===l.length-1?1:C(u,r,f(m.end+s)),y=Math.min(d,g);if(d>y+1e-6){const b=S(h,y);M(n,b[0].curve),h=b[1];}else M(n,h.curve),h=c[++a];if(g>y+1e-6){const b=S(m,f(C(r,u,y)-s));M(o,b[0].curve),m=b[1];}else M(o,m.curve),m=l[++i];}R(h===void 0&&m===void 0,"polygon outlines could not be fully matched");}export{_ as Morph};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{checkArgument as
|
|
1
|
+
import{checkArgument as g}from"../util";import{extendBounds as v,resetBounds as O}from"./cubic";const b=1e5,f=[1,0,0,1,0,0];let a=new Uint8Array(0),u=0,_,T=new Float64Array(0);function N(t){return g(Number.isFinite(t),"path coordinates must be finite"),String(Math.round(t*b)/b);}class P{#t;constructor(){this.#t="";}moveTo(e,n){return this.#e("M",[e,n]);}lineTo(e,n){return this.#e("L",[e,n]);}cubicTo(e,n,r,i,s,o){return this.#e("C",[e,n,r,i,s,o]);}close(){return this.#e("Z",[]);}rewind(){return this._assign("");}toSvgPathData(){return this.#t;}toString(){return this.#t;}_assign(e){return this.#t=e,this;}#e(e,n){return this._assign(this.#t+e+n.map(N).join(" "));}}function z(t,e=new P()){return g(t.length>0,"a path requires at least one cubic"),A(e,x(t),t.length,f,!1);}function D(t,e,n=new P()){const r=x(t.cubics);return A(n,r,t.cubics.length,S(r,t.centerX,t.centerY,e?.startAngle),e?.repeatPath===!0);}function G(t,e,n,r=new P()){const i=t._frame(e,C(t.cubicCount)),{start:s,end:o}=t;return A(r,i,t.cubicCount,S(i,s.centerX+(o.centerX-s.centerX)*e,s.centerY+(o.centerY-s.centerY)*e,n?.startAngle),n?.repeatPath===!0);}const R=/[\s,]*/y,I=/[A-Za-z]/y,B=/[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/y,$=/[01]/y,H=7,L=/* @__PURE__ */new Set([3,4]);function l(t,e,n){return t.lastIndex=n,t.exec(e)?.[0];}function W(t,e){let n="",r="",i=0,s=!1,o=l(R,t,0)?.length??0;for(;o<t.length;){const h=l(I,t,o),y=s&&L.has(i%H),d=h??l(y?$:B,t,o);if(g(d!==void 0,`invalid path data at ${o}: ${t}`),o+=d.length,o+=l(R,t,o)?.length??0,h!==void 0){n+=h,r="",i=0,s=h==="A"||h==="a";continue;}const c=String(Number(Number(d).toFixed(e))).replace(/^(-?)0\./,"$1."),F=r===""||c.startsWith("-")||c.startsWith(".")&&r.includes(".");n+=F?c:` ${c}`,r=c,i++;}return n;}function Y(t){return D(t).toSvgPathData();}function Z(t,e,n=e){return w(x(t.cubics),t.cubics.length,e,n);}function q(t,e,n,r=n){return w(t._frame(e,C(t.cubicCount)),t.cubicCount,n,r);}function C(t){return T.length<t*8&&(T=new Float64Array(t*16)),T;}function x(t){const e=C(t.length);for(let n=0;n<t.length;n++){const r=t[n].points;for(let i=0;i<8;i++)e[n*8+i]=r[i];}return e;}function S(t,e,n,r){if(r===void 0)return f;const i=r*Math.PI/180-Math.atan2(t[1]-n,t[0]-e),s=Math.cos(i),o=Math.sin(i);return[s,o,-o,s,e-s*e+o*n,n-o*e-s*n];}function w(t,e,n,r){g(Number.isFinite(n)&&n>0&&Number.isFinite(r)&&r>0,"a CSS path box must have a positive size");const i=[0,0,0,0];O(i);for(let c=0;c<e;c++)v(i,t,c*8,!0);const[s,o,h,y]=i,d=[n,0,0,r,(1-s-h)*n/2,(1-o-y)*r/2];return`path('${A(new P(),t,e,d,!1)}')`;}function p(t){if(u+t>a.length){const e=new Uint8Array(Math.max(a.length*2,u+t));e.set(a),a=e;}}function M(t){let e=Math.round(t*b);if(e>-2147483648&&e<2147483648){e<0&&(a[u++]=45,e=-e);const n=e%b;if(E((e-n)/b),n>0){a[u]=46;for(let r=u+5,i=n;r>u;r--)a[r]=48+i%10,i=(i-i%10)/10;for(u+=6;a[u-1]===48;)u--;}}else{const n=N(t);for(let r=0;r<n.length;r++)a[u++]=n.charCodeAt(r);}}function E(t){t>=10&&E((t-t%10)/10),a[u++]=48+t%10;}function m(t,e,n){M(t===f?e:t[0]*e+t[2]*n+t[4]),a[u++]=32,M(t===f?n:t[1]*e+t[3]*n+t[5]);}function A(t,e,n,r,i){let s=u=0;try{p(200),a[u++]=77,m(r,e[0],e[1]);for(let o=0;o<n*8;o+=8)s=u,p(200),a[u++]=67,m(r,e[o+2],e[o+3]),a[u++]=32,m(r,e[o+4],e[o+5]),a[u++]=32,m(r,e[o+6],e[o+7]);if(i){const o=u;p(o),a[u++]=76,a.copyWithin(u,1,o),u+=o-1;}a[u++]=90,s=u;}finally{u=s,t._assign(U());}return t;}function U(){return _??=new TextDecoder(),_.decode(a.subarray(0,u));}export{P as Path,W as compactSvgPath,z as cubicsToPath,N as formatPathCoordinate,q as morphToCssPath,G as morphToPath,D as roundedPolygonToPath,Z as toCssPath,Y as toSvgPath};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{checkArgument as h,checkState as m}from"../util";function x(e,n){h(Number.isFinite(e)&&Number.isFinite(n),"point coordinates must be finite")}function b(e,n){return Math.sqrt(e*e+n*n)}class i{static Zero=new i(0,0);x;y;constructor(n,t){x(n,t),this.x=n,this.y=t,Object.freeze(this)}static interpolate(n,t,r){return new i(n.x+(t.x-n.x)*r,n.y+(t.y-n.y)*r)}minus(n){return new i(this.x-n.x,this.y-n.y)}plus(n){return new i(this.x+n.x,this.y+n.y)}times(n){return new i(this.x*n,this.y*n)}div(n){return new i(this.x/n,this.y/n)}distanceSquared(){return this.x*this.x+this.y*this.y}distance(){return Math.sqrt(this.distanceSquared())}dot(n){return this.x*n.x+this.y*n.y}direction(){const n=this.distance();return m(n>0,"a zero-length vector has no direction"),this.div(n)}rotate90(){return new i(-this.y,this.x)}cross(n){return this.x*n.y-this.y*n.x}rotate(n,t=i.Zero){const r=n*Math.PI/180,o=Math.cos(r),s=Math.sin(r),u=this.x-t.x,c=this.y-t.y;return new i(u*o-c*s+t.x,u*s+c*o+t.y)}}function y(e,n){if(n===void 0)return new i(Math.cos(e),Math.sin(e));const t=b(e,n);return h(t>0,"a zero-length vector has no direction"),new i(e/t,n/t)}function d(e,n){return e.minus(n).distance()}function P(e,n,t){return(n.x-e.x)*(t.y-n.y)-(n.y-e.y)*(t.x-n.x)>0}export{i as Point,x as checkPoint,y as directionVector,d as distanceBetween,P as isConvex,b as lengthOfVector};
|
|
1
|
+
import{checkArgument as h,checkState as m}from"../util";function x(e,n){h(Number.isFinite(e)&&Number.isFinite(n),"point coordinates must be finite");}function b(e,n){return Math.sqrt(e*e+n*n);}class i{static Zero=new i(0,0);x;y;constructor(n,t){x(n,t),this.x=n,this.y=t,Object.freeze(this);}static interpolate(n,t,r){return new i(n.x+(t.x-n.x)*r,n.y+(t.y-n.y)*r);}minus(n){return new i(this.x-n.x,this.y-n.y);}plus(n){return new i(this.x+n.x,this.y+n.y);}times(n){return new i(this.x*n,this.y*n);}div(n){return new i(this.x/n,this.y/n);}distanceSquared(){return this.x*this.x+this.y*this.y;}distance(){return Math.sqrt(this.distanceSquared());}dot(n){return this.x*n.x+this.y*n.y;}direction(){const n=this.distance();return m(n>0,"a zero-length vector has no direction"),this.div(n);}rotate90(){return new i(-this.y,this.x);}cross(n){return this.x*n.y-this.y*n.x;}rotate(n,t=i.Zero){const r=n*Math.PI/180,o=Math.cos(r),s=Math.sin(r),u=this.x-t.x,c=this.y-t.y;return new i(u*o-c*s+t.x,u*s+c*o+t.y);}}function y(e,n){if(n===void 0)return new i(Math.cos(e),Math.sin(e));const t=b(e,n);return h(t>0,"a zero-length vector has no direction"),new i(e/t,n/t);}function d(e,n){return e.minus(n).distance();}function P(e,n,t){return(n.x-e.x)*(t.y-n.y)-(n.y-e.y)*(t.x-n.x)>0;}export{i as Point,x as checkPoint,y as directionVector,d as distanceBetween,P as isConvex,b as lengthOfVector};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{checkArgument as m}from"../util";import{CornerRounding as L}from"./corner-rounding";import{Cubic as A,checkBounds as ln,extendBounds as mn,isContiguous as gn,newFrozenCubic as Q,resetBounds as fn,reverseCoordinates as bn}from"./cubic";import{Point as J,checkPoint as pn,directionVector as yn,lengthOfVector as C}from"./point";class X{cubics;kind;convex;constructor(n,t,o=!0){m(n.length>0,"a polygon feature requires at least one cubic");for(let r=1;r<n.length;r++)m(gn(n[r-1],n[r]),"polygon feature cubics must be contiguous");this.cubics=Object.freeze([...n]),this.kind=t,this.convex=t==="corner"?o:!0,Object.freeze(this)}get isEdge(){return this.kind==="edge"}get isCorner(){return this.kind==="corner"}get isIgnorableFeature(){return this.kind==="edge"}get isConvexCorner(){return this.kind==="corner"&&this.convex}get isConcaveCorner(){return this.kind==="corner"&&!this.convex}transformed(n){return new X(this.cubics.map(t=>t.transformed(n)),this.kind,this.convex)}reversed(){return new X(this.cubics.map(n=>n.reverse()).reverse(),this.kind,this.kind==="corner"?!this.convex:!0)}equals(n){return n instanceof X&&this.kind===n.kind&&this.convex===n.convex&&this.cubics.length===n.cubics.length&&this.cubics.every((t,o)=>t.equals(n.cubics[o]))}}class x{center;features;cubics;constructor(n,t){const o=[];for(let r=0;r<n.length;r++){const{cubics:i}=n[r];for(let c=0;c<i.length;c++)o.push(i[c])}m(n.length>=2,"a polygon requires at least two features");for(let r=0;r<o.length;r++)m(gn(o[(r||o.length)-1],o[r]),"polygon features must form a contiguous closed outline");this.center=t,this.features=Object.freeze([...n]),this.cubics=Object.freeze(Pn(n,o,t)),Object.freeze(this)}get centerX(){return this.center.x}get centerY(){return this.center.y}static fromVertices(n,t=L.Unrounded,o,r,i){m(n.length>=6&&n.length%2===0,"a polygon requires at least three x/y vertex pairs");const c=n.length/2,e=[],s=t instanceof L?{rounding:t,perVertexRounding:o,centerX:r,centerY:i}:t,a=s.perVertexRounding;let d=0,g=0;m(a===void 0||a.length*2===n.length,"per-vertex rounding must have one entry per vertex");for(let l=0;l<c;l++)pn(n[l*2],n[l*2+1]),d+=n[l*2],g+=n[l*2+1],e.push(a?.[l]??s.rounding??L.Unrounded);const f=xn(n,e);return new x(f,new J(s.centerX??d/c,s.centerY??g/c))}static fromFeatures(n,t,o){let r=0,i=0,c=0;for(let e=0;e<n.length;e++){const{cubics:s}=n[e];for(let a=0;a<s.length;a++)r+=s[a].points[0],i+=s[a].points[1],c
|
|
1
|
+
import{checkArgument as m}from"../util";import{CornerRounding as L}from"./corner-rounding";import{Cubic as A,checkBounds as ln,extendBounds as mn,isContiguous as gn,newFrozenCubic as Q,resetBounds as fn,reverseCoordinates as bn}from"./cubic";import{Point as J,checkPoint as pn,directionVector as yn,lengthOfVector as C}from"./point";class X{cubics;kind;convex;constructor(n,t,o=!0){m(n.length>0,"a polygon feature requires at least one cubic");for(let r=1;r<n.length;r++)m(gn(n[r-1],n[r]),"polygon feature cubics must be contiguous");this.cubics=Object.freeze([...n]),this.kind=t,this.convex=t==="corner"?o:!0,Object.freeze(this);}get isEdge(){return this.kind==="edge";}get isCorner(){return this.kind==="corner";}get isIgnorableFeature(){return this.kind==="edge";}get isConvexCorner(){return this.kind==="corner"&&this.convex;}get isConcaveCorner(){return this.kind==="corner"&&!this.convex;}transformed(n){return new X(this.cubics.map(t=>t.transformed(n)),this.kind,this.convex);}reversed(){return new X(this.cubics.map(n=>n.reverse()).reverse(),this.kind,this.kind==="corner"?!this.convex:!0);}equals(n){return n instanceof X&&this.kind===n.kind&&this.convex===n.convex&&this.cubics.length===n.cubics.length&&this.cubics.every((t,o)=>t.equals(n.cubics[o]));}}class x{center;features;cubics;constructor(n,t){const o=[];for(let r=0;r<n.length;r++){const{cubics:i}=n[r];for(let c=0;c<i.length;c++)o.push(i[c]);}m(n.length>=2,"a polygon requires at least two features");for(let r=0;r<o.length;r++)m(gn(o[(r||o.length)-1],o[r]),"polygon features must form a contiguous closed outline");this.center=t,this.features=Object.freeze([...n]),this.cubics=Object.freeze(Pn(n,o,t)),Object.freeze(this);}get centerX(){return this.center.x;}get centerY(){return this.center.y;}static fromVertices(n,t=L.Unrounded,o,r,i){m(n.length>=6&&n.length%2===0,"a polygon requires at least three x/y vertex pairs");const c=n.length/2,e=[],s=t instanceof L?{rounding:t,perVertexRounding:o,centerX:r,centerY:i}:t,a=s.perVertexRounding;let d=0,g=0;m(a===void 0||a.length*2===n.length,"per-vertex rounding must have one entry per vertex");for(let l=0;l<c;l++)pn(n[l*2],n[l*2+1]),d+=n[l*2],g+=n[l*2+1],e.push(a?.[l]??s.rounding??L.Unrounded);const f=xn(n,e);return new x(f,new J(s.centerX??d/c,s.centerY??g/c));}static fromFeatures(n,t,o){let r=0,i=0,c=0;for(let e=0;e<n.length;e++){const{cubics:s}=n[e];for(let a=0;a<s.length;a++)r+=s[a].points[0],i+=s[a].points[1],c++;}return new x(n,new J(t??(c===0?0:r/c),o??(c===0?0:i/c)));}static fromNumVertices(n,t=1,o=0,r=0,i=L.Unrounded,c){return m(Number.isInteger(n)&&n>=3,"a polygon requires at least three vertices"),m(Number.isFinite(t)&&t>0,"polygon radius must be positive"),x.fromVertices(Cn(n,o,r,t),i,c,o,r);}transformed(n){const t=this.features.map(o=>o.transformed(n));return new x(t,n(this.centerX,this.centerY));}normalized(){const n=this.calculateBounds(),t=n[0],o=n[1],r=n[2]-t,i=n[3]-o,c=Math.max(r,i),e=(c-r)/2-t,s=(c-i)/2-o;return m(c>0,"cannot normalize a zero-area polygon"),this.transformed((a,d)=>new J(dn((a+e)/c),dn((d+s)/c)));}calculateBounds(n=[0,0,0,0],t=!0){ln(n),fn(n);for(let o=0;o<this.cubics.length;o++)mn(n,this.cubics[o].points,0,t);return n;}calculateMaxBounds(n=[0,0,0,0]){const{x:t,y:o}=this.center;let r=0;ln(n);for(let i=0;i<this.cubics.length;i++){const c=this.cubics[i],e=c.pointAt(0.5);r=Math.max(r,C(c.points[0]-t,c.points[1]-o),C(e.x-t,e.y-o));}return n[0]=t-r,n[1]=o-r,n[2]=t+r,n[3]=o+r,n;}equals(n){return n instanceof x&&this.features.length===n.features.length&&this.features.every((t,o)=>t.equals(n.features[o]));}}function wn(u){return u instanceof x;}function Cn(u,n,t,...o){const r=[];for(let i=0;i<u;i++){const c=2*Math.PI*i/u,e=o[i%o.length];r.push(n+Math.cos(c)*e,t+Math.sin(c)*e);}return r;}function dn(u){return u<0&&u>-1e-12?0:u>1&&u<1.000000000001?1:u;}function xn(u,n){const t=n.length,o=[],r=[],i=[],c=[];for(let e=0;e<t;e++){const s=u[e*2],a=u[e*2+1],d=((e||t)-1)*2,g=(e+1)%t*2,f=u[d]-s,l=u[d+1]-a,b=u[g]-s,P=u[g+1]-a,R=C(f,l),p=C(b,P),Y=R===0||p===0,h=Y?[0,0,0,0]:[f/R,l/R,b/p,P/p],y=Math.max(-1,Math.min(1,h[0]*h[2]+h[1]*h[3])),w=Math.sqrt(1-y*y),{radius:F,smoothing:O}=n[e],M=!Y&&w>1e-3?F*(y+1)/w:0;h.push(M,(1+O)*M,l*b-f*P),o.push(h);}for(let e=0;e<t;e++){const s=(e+1)%t,a=C(u[e*2]-u[s*2],u[e*2+1]-u[s*2+1]),d=o[e][4]+o[s][4],g=o[e][5]+o[s][5];r.push(d>a?[a/d,0]:g>a?[1,(a-d)/(g-d)]:[1,1]);}for(let e=0;e<t;e++){const s=o[e],a=u[e*2],d=u[e*2+1],{radius:g,smoothing:f}=n[e],l=s[4],b=s[5],P=r[(e||t)-1],R=r[e],p=[l*P[0]+(b-l)*P[1],l*R[0]+(b-l)*R[1]],Y=Math.min(p[0],p[1]),h=Math.min(Y,l);if(!(l>=1e-4&&Y>=1e-4&&g>=1e-4)){i.push([A.empty(a,d)]);continue;}const y=g*h/l,w=(s[0]+s[2])/2,F=(s[1]+s[3])/2,O=C(w,F),M=C(y,h),q=a+w/O*M,z=d+F/O*M,V=[a+s[0]*h,d+s[1]*h,a+s[2]*h,d+s[3]*h],W=N=>{const k=N*2,T=s[k],U=s[k+1],v=V[k],j=V[k+1],Z=N===0?((e||t)-1)*2:(e+1)%t*2,$=u[Z],_=u[Z+1],E=p[N],D=E>b?f:E>l?f*(E-l)/(b-l):0,nn=h*(1+D),en=a+T*nn,tn=d+U*nn,on=yn(v+((v+V[2-k])/2-v)*D-q,j+((j+V[3-k])/2-j)*D-z),S=q+on.x*y,G=z+on.y*y,rn=-(S-q),sn=-(G-z),B=T*rn+U*sn,H=(S-$)*rn+(G-_)*sn,cn=Math.abs(B)<1e-4||Math.abs(B)<1e-4*Math.abs(H),un=cn?v:$+T*(H/B),an=cn?j:_+U*(H/B);return[en,tn,(en+un*2)/3,(tn+an*2)/3,un,an,S,G];},I=W(0),K=W(1);i.push([Q(I),A.circularArc(q,z,I[6],I[7],K[6],K[7]),Q(bn(K))]);}for(let e=0;e<t;e++){const s=i[e][i[e].length-1].points,a=i[(e+1)%t][0].points;c.push(new X(i[e],"corner",o[e][6]>0),new X([A.straightLine(s[6],s[7],a[0],a[1])],"edge"));}return c;}function Pn(u,n,t){const o=u[0].cubics,r=[];let i=n;if(o.length===3){const e=o[1].split(0.5);i=[e[1],o[2]].concat(n.slice(3),o[0],e[0]);}for(let e=0;e<i.length;e++){const s=i[e];s.zeroLength()?r.length>0&&r.push(hn(r.pop(),s.points,6)):r.push(s);}if(r.length===0)return[A.empty(t.x,t.y)];const c=r[0].points;return r.push(hn(r.pop(),c,0)),r;}function hn(u,n,t){const o=[...u.points];return o[6]=n[t],o[7]=n[t+1],Q(o);}export{X as PolygonFeature,x as RoundedPolygon,Cn as calculateVertices,wn as isRoundedPolygon};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{checkArgument as i}from"../util";import{CornerRounding as a}from"./corner-rounding";import{RoundedPolygon as b,calculateVertices as p}from"./rounded-polygon";class g{static circle(e=8,o=1,r=0,n=0){return i(Number.isInteger(e)&&e>=3,"a circle requires at least three vertices"),i(Number.isFinite(o)&&o>0,"circle radius must be positive"),b.fromNumVertices(e,o/Math.cos(Math.PI/e),r,n,new a(o))}static rectangle(e=2,o=2,r=a.Unrounded,n,t=0,s=0){const l=t+e/2,m=s+o/2,c=t-e/2,u=s-o/2;return i(Number.isFinite(e)&&e>0&&Number.isFinite(o)&&o>0,"rectangle dimensions must be positive"),b.fromVertices([l,m,c,m,c,u,l,u],r,n,t,s)}static star(e,o=1,r
|
|
1
|
+
import{checkArgument as i}from"../util";import{CornerRounding as a}from"./corner-rounding";import{RoundedPolygon as b,calculateVertices as p}from"./rounded-polygon";class g{static circle(e=8,o=1,r=0,n=0){return i(Number.isInteger(e)&&e>=3,"a circle requires at least three vertices"),i(Number.isFinite(o)&&o>0,"circle radius must be positive"),b.fromNumVertices(e,o/Math.cos(Math.PI/e),r,n,new a(o));}static rectangle(e=2,o=2,r=a.Unrounded,n,t=0,s=0){const l=t+e/2,m=s+o/2,c=t-e/2,u=s-o/2;return i(Number.isFinite(e)&&e>0&&Number.isFinite(o)&&o>0,"rectangle dimensions must be positive"),b.fromVertices([l,m,c,m,c,u,l,u],r,n,t,s);}static star(e,o=1,r=0.5,n=a.Unrounded,t,s,l=0,m=0){return i(Number.isInteger(e)&&e>=2,"a star requires at least two outer vertices"),i(Number.isFinite(o)&&o>0&&Number.isFinite(r)&&r>0,"star radii must be positive"),i(r<o,"star inner radius must be less than its radius"),b.fromVertices(p(e*2,l,m,o,r),n,s??Array.from({length:e*2},(c,u)=>u%2===0?n:t??n),l,m);}static pill(e=2,o=1,r=0,n=0,t=0){return i(Number.isFinite(e)&&e>0&&Number.isFinite(o)&&o>0,"pill dimensions must be positive"),g.rectangle(e,o,new a(Math.min(e,o)/2,r),void 0,n,t);}}export{g as Shapes};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=Object.freeze({0:0,25:2,50:4,75:6,100:8,125:10,150:12,175:14,200:16,250:20,300:24,400:32,450:36,500:40,600:48,700:56,800:64,900:72});export{e as spacing};
|
|
1
|
+
const e=Object.freeze({0:0,25:2,50:4,75:6,100:8,125:10,150:12,175:14,200:16,250:20,300:24,400:32,450:36,500:40,600:48,700:56,800:64,900:72});export{e as spacing};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{splitProps as i}from"solid-js";import{isServer as e}from"solid-js/web";import{defineDomComponent as d}from"..";import{InteractableController as P}from"./controller";import"./component.css";function I(n,t){return d(()=>{if(!e)throw new Error;const o=n();return(r,a)
|
|
1
|
+
import{splitProps as i}from"solid-js";import{isServer as e}from"solid-js/web";import{defineDomComponent as d}from"..";import{InteractableController as P}from"./controller";import"./component.css";function I(n,t){return/* @__PURE__ */d(()=>{if(!e)throw new Error();const o=n();return(r,a)=>/* @__PURE__ */o(r,i(a,["onClick","onFocusIn","onFocusOut","onPointerEnter","onPointerLeave","onInteractionStateEntered","onInteractionStateExited"])[1]);},()=>{if(e)throw new Error();return/* @__PURE__ */t(P);});}export{I as defineInteractableComponent};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{DomController as K}from"../dom/client";import{assertDebug as O,checkArgument as F,checkState as g,consumeProps as U,deferAfterDelegatedCancellation as q,eventListenerOptionsOf as C}from"../util";import{isLeaveWithin as B}from"../util/event";import{DragState as l,FocusState as u,HoverState as f,PressState as s,highestInteractionStateOf as v,isInteractionState as H,isInteractionStateMask as A,nameOfInteractionState as X,streamInteractionStates as E}from"./state";import{applyRipple as j}from"./ripple";import{CSS_CLASS_FOCUS_INDICATOR as M,CSS_CLASS_INTERACTABLE as P,CSS_CLASS_STATE_LAYER as x,STATE_LAYER_PSEUDO_ELEMENT as $}from"./style";const z=150,J=350,Q=8,Z="button, input, select, textarea, a[href], [contenteditable]:not([contenteditable=false])",ee={click:s,contextmenu:l|s,focusin:u,focusout:u,keydown:s,keyup:s,lostpointercapture:l|s,pointercancel:l|s,pointerdown:l|s,pointerenter:f,pointerleave:l|f|s,pointermove:l|s,pointerup:l|s},V=Object.keys(ee),W=["click","focusin","keydown","pointerdown","pointerenter"],h=new WeakMap,R=new WeakMap,L=new WeakMap,D=new WeakMap,m=new WeakSet,p=new Set;function I(o){return typeof o=="object"&&o!==null&&o.nodeType===1}function N(o){return o.nodeType===11&&"host"in o}function y(o,e){const t=e?.defaultView?.PointerEvent;return typeof t=="function"&&o instanceof t||o.type.startsWith("pointer")&&"pointerId"in o&&"pointerType"in o}function te(o,e){const t=e?.defaultView?.MouseEvent;return typeof t=="function"&&o instanceof t||"clientX"in o}function ne(o){const e=o.target,t=o.currentTarget;return I(e)?e.ownerDocument:typeof t=="object"&&t!==null&&t.nodeType===9?t:o.composedPath().find(I)?.ownerDocument}function oe(o){const e=o.ownerDocument;return e.defaultView!==null?e:document}function ie(o){const e=[];for(let t=o.getRootNode();N(t);t=t.host.getRootNode())t.mode==="closed"&&e.push(t);return e}function c(o){return D.get(o)??null}function w(o){let e=R.get(o);if(e===void 0){const t=r=>b._maybeHandleTriggerEvent(r),n=C({capture:!0,passive:!1}),i=C({capture:!0,passive:!0});e={handler:t,root:o,subscribers:0},R.set(o,e);for(const r of V)o.addEventListener(r,t,r==="click"?n:i);N(o)&&L.set(o.host,o)}return e.subscribers++,e}function k(o){const e=o.root;if(o.subscribers--,o.subscribers===0){for(const t of V)e.removeEventListener(t,o.handler,!0);R.delete(e),N(e)&&L.delete(e.host)}}function _(o,e){const t=o.ownerDocument,n=e.document;n.root!==t&&(e.document=w(t),k(n)),e.closedRoots.length===0&&o.getRootNode()!==t&&(e.closedRoots=ie(o).map(w))}function re(o,e){const t=C({capture:!0,passive:!1}),n=i=>{o.isConnected&&(G(o,e),_(o,e)),b._maybeHandleTriggerEvent(i)};e.sentinel=n;for(const i of W)o.addEventListener(i,n,t)}function G(o,e){const t=e.sentinel;if(t!==void 0){e.sentinel=void 0;for(const n of W)o.removeEventListener(n,t,!0)}}function se(){for(const o of p){const e=h.get(o);e!==void 0&&(o.isConnected?_(o,e):re(o,e))}p.clear()}function le(o,e){const t=h.get(o);if(t?.controller===e)return;t!==void 0&&Y(o,t.controller);const n={closedRoots:[],controller:e,document:w(oe(o))};if(h.set(o,n),o.isConnected){_(o,n);return}p.size===0&&queueMicrotask(se),p.add(o)}function Y(o,e){const t=h.get(o);if(t?.controller===e){h.delete(o),p.delete(o),G(o,t),k(t.document);for(const n of t.closedRoots)k(n)}}function ae(o,e){for(let t=0;t<o.length;t++){const n=o[t];if(!I(n))continue;const i=h.get(n),r=L.get(n);if(i!==void 0)return{controller:i.controller,element:n};if(!e)return;if(r!==void 0&&o[t-1]!==r)return null;if(n.matches(Z))return}}function ue(o){return o.ownerDocument.defaultView?.matchMedia("(any-hover: hover)").matches===!0}function S(o){const e=v(o)??0;return e===s?e|(v(o&~s)??0):e}function ce(o){return"transitionProperty"in o&&o.transitionProperty==="color"&&o.effect?.pseudoElement===$}class b extends K{#p;#E;#m;#y;#S;#I;#g;#P;#a;#o;#n;#s;#d;#u;#e;#l;constructor(e,t){super(e,t),{onClick:this.#p,onFocusIn:this.#E,onFocusOut:this.#m,onInteractionStateEntered:this.#I,onInteractionStateExited:this.#g,onPointerEnter:this.#y,onPointerLeave:this.#S}=U(e,[],["onClick","onFocusIn","onFocusOut","onInteractionStateEntered","onInteractionStateExited","onPointerEnter","onPointerLeave"]),this.#P=t?.baseInteractionCssClassName??"cw-interactable",this.#a=(t?.noPressRipple?1:0)|(t?.noFocusIndicator?2:0)|([this.#p,this.#E,this.#m,this.#y,this.#S].some(n=>n!==void 0)?8:0),this.#o=t?.enabledInteractionStates??0,this.#n=0,F(A(this.#o))}#c(e){return(this.#a&e)===e}get isControllerDisposed(){return this.#c(16)}#w(e){const t=this.#c(e);return this.#a|=e,t}isPressRippleDisabled(){return this.#c(1)}isFocusIndicatorDisabled(){return this.#c(2)}#C(e){return`${this.#P}-${X(e)}`}get enabledInteractionStates(){return this.#o}get enteredInteractionStates(){return this.#n}isInteractionStateEnabled(e){return O(H(e)),(this.#o&e)===e}isInteractionStateEntered(e){return O(H(e)),(this.#n&e)===e}#f(e,t){const n=this;t!==null&&Y(t,n),!(e===null||this.isControllerDisposed||this.#o===0&&!this.#c(8))&&(le(e,n),e.isConnected&&queueMicrotask(()=>this.#v(this.#o)))}#k(e){const t=this.#c(8),n=super.styleElement?.classList;e?(n?.add(P),t||(this.#f(super.styleElement,null),this.#f(super.functionElement,null))):(n?.remove(P,x),this.#a&=-5,t||(this.#f(null,super.styleElement),this.#f(null,super.functionElement)))}setEnabledInteractionStates(e){const t=this.#o,n=this.#e;if(!(this.isControllerDisposed||t===e)){F(A(e)),this.#o=e,(e&s)===0&&(this.#l=void 0),n!==void 0&&(e&(n.dragStarted===!0?l:s))===0&&this.#t(!0);for(const i of E(this.#n&~e))this.#r(i,!0);t!==0!=(e!==0)&&this.#k(e!==0),this.#v(e&~t)}}#v(e){const t=super.styleElement,n=super.functionElement,i=(e&f)!==0&&t!==null&&t.matches(":hover")&&ue(t),r=(e&u)!==0&&I(n)&&n.matches(":focus-visible");if(!(this.isControllerDisposed||!i&&!r)){for(const a of this.#b())ce(a)&&a.finish();i&&this.#i(f),r&&this.#i(u)}}#b(){const e=super.styleElement;return e===null||typeof e.getAnimations!="function"?[]:e.getAnimations({subtree:!0}).filter(t=>{const n=t.effect;return n!==null&&n.target===e&&Number.isFinite(Number(n.getComputedTiming().endTime))&&t.playbackRate!==0&&t.playState!=="paused"})}#L(){this.#u?.cancel(),this.#u=void 0}#R(e,t,n){for(const i of E(t&~n))e.classList.remove(this.#C(i));for(const i of E(n&~t))e.classList.add(this.#C(i))}#i(e,t){if(this.#s?.(),this.isControllerDisposed||(e&this.#o&~this.#n)!==e)return;const n=super.styleElement,i=S(this.#n),r=S(this.#n|e);let a;if(g(n!==null,"interaction state requires a style element"),this.#n|=e,e===u&&!this.isFocusIndicatorDisabled()&&n.classList.add(M),(r&e)===0){this.#I?.(e,this,t);return}e===s&&(a=this.#b()),this.#w(4)||n.classList.add(x),this.#R(n,i,r),a!==void 0?(this.#d=Promise.allSettled(this.#b().filter(d=>!a.includes(d)).map(d=>d.finished)),this.isPressRippleDisabled()||(this.#u=j(n,this.#e?.position))):(i&~r&s)!==0&&(this.#d=void 0,this.#u?.finish()),this.#I?.(e,this,t)}#N(e,t,n){const i=()=>{this.#s===i&&(this.#s=void 0,this.#r(e,!0,n))};this.#d=void 0,this.#s?.(),this.#s=i,t.then(i)}#r(e,t,n){const i=this.#n,r=i&~e,a=(v(r)??0)<e,d=this.#d,T=super.styleElement;if(this.isInteractionStateEntered(e)){if(e===s&&this.#u?.finish(),a&&e===s&&d!==void 0){if(t!==!0){this.#N(e,d,n);return}this.#d=void 0}a&&this.#s!==void 0&&(this.#s(),!this.isInteractionStateEntered(e))||(g(T!==null,"interaction state requires a style element"),this.#n=r,e===u&&T.classList.remove(M),this.#R(T,S(i),S(r)),this.#g?.(e,this,n))}}#T(e,t){const n=y(e,t),i=c(t);let r=i;if(!this.isControllerDisposed){if(i!==null){if(n&&e.type==="pointerdown"&&i===this.#e&&i.pointerId===e.pointerId)return;i!==this.#e||i.touchTimeoutId===void 0?(i.controller.#t(!0,e),r=null):(t.defaultView?.clearTimeout(i.touchTimeoutId),i.touchTimeoutId=void 0)}if(!this.isControllerDisposed){if(r??=this.#_(e,t),r.position===void 0&&te(e,t)&&(e.type!=="click"||n&&e.pointerType!=="")&&(r.position=[e.clientX,e.clientY]),!n){this.#i(s,e);return}if(r.pointerId=e.pointerId,r.pointerType=e.pointerType,e.type==="pointerdown"&&!this.isInteractionStateEnabled(s)){this.isInteractionStateEnabled(l)||this.#t(!0,e);return}if(e.type==="click"||e.pointerType!=="touch"||t.defaultView===null){this.#i(s,e);return}this.#O(r,e)}}}#_(e,t){const n=t.defaultView,i={controller:this,document:t,keyboard:e.type==="keydown"};if(D.set(t,i),this.#e=i,i.keyboard&&n!==null){const r=()=>{this.#e===i&&this.#t(!0)};n.addEventListener("blur",r),i.removeBlurListener=()=>n.removeEventListener("blur",r)}return i}#O(e,t){const n=e.document.defaultView?.setTimeout(()=>{c(e.document)!==e||e.touchTimeoutId!==n||e.dragStarted===!0||(e.touchTimeoutId=void 0,this.#i(s,t))},z);e.touchTimeoutId=n}#F(e,t){const n=super.styleElement,i=e.position;if(!(e.dragStarted===!0||i===void 0||!this.isInteractionStateEnabled(l)||(t.clientX-i[0])**2+(t.clientY-i[1])**2<Q**2)&&(e.touchTimeoutId!==void 0&&(e.document.defaultView?.clearTimeout(e.touchTimeoutId),e.touchTimeoutId=void 0),e.dragStarted=!0,this.#i(l,t),!(this.#e!==e||n===null||!n.isConnected)))try{n.setPointerCapture(t.pointerId),e.pointerCaptureElement=n}catch{}}#H(e,t){if(this.#r(l,!1,t),!(this.isControllerDisposed||this.#e!==e)){if(!this.isInteractionStateEntered(s)){this.#t(!0,t);return}this.#D(e,t)}}#A(e,t){(t.type!=="lostpointercapture"||e.releaseTimeoutId===void 0)&&this.#t(!0,t)}#D(e,t){const n=e.document.defaultView?.setTimeout(()=>{c(e.document)===e&&e.releaseTimeoutId===n&&(e.releaseTimeoutId=void 0,this.#t(!0,t))},e.pointerType==="touch"?J:0);this.#u?.finish(),n===void 0?this.#t(!0,t):e.releaseTimeoutId=n}#t(e,t){const n=this.#e,i=n?.document.defaultView,r=n?.pointerCaptureElement;if(g(n!==void 0,"controller owns no press"),D.delete(n.document),this.#e=void 0,this.#l=void 0,n.removeBlurListener?.(),r!==void 0&&n.pointerId!==void 0)try{r.hasPointerCapture(n.pointerId)&&r.releasePointerCapture(n.pointerId)}catch{}n.releaseTimeoutId!==void 0&&i?.clearTimeout(n.releaseTimeoutId),this.#r(l,e??!0,t),n.touchTimeoutId!==void 0?i?.clearTimeout(n.touchTimeoutId):this.#r(s,e??!0,t)}onEvent(e){e.type==="click"?this.#p?.(e,this):e.type==="focusin"?this.#E?.(e,this):e.type==="focusout"?this.#m?.(e,this):e.type==="pointerenter"?this.#y?.(e,this):e.type==="pointerleave"&&this.#S?.(e,this)}#M(e,t,n){if(!this.isControllerDisposed){switch(e.type){case"click":this.#x(e,n);return;case"focusin":case"focusout":this.#V(e,t);return;case"keydown":case"keyup":this.#W(e,t);return}y(e,n)&&e.isPrimary&&this.#G(e,t,n)}}#x(e,t){let n;this.onEvent(e),this.isInteractionStateEnabled(s)&&(n=c(t),(n===null||n===this.#e&&n.touchTimeoutId!==void 0)&&(this.#T(e,t),n=c(t)),n!==null&&n.controller.#t(!1,e))}#V(e,t){if(t===super.functionElement){if(e.type==="focusin"){this.onEvent(e),t.matches(":focus-visible")&&this.#i(u,e);return}this.#l=void 0,this.#e?.keyboard===!0&&this.#t(!0,e),this.onEvent(e),this.#r(u,!1,e)}}#W(e,t){const n=this.#e;if(!(t!==super.functionElement||t.localName!=="button")){if(e.type==="keyup"){this.#l=void 0,n?.keyboard===!0&&this.#D(n,e);return}e.repeat||e.isComposing||!this.isInteractionStateEnabled(s)||(this.#l=e,q(e,t,()=>{this.#l===e&&!this.isControllerDisposed&&!e.defaultPrevented&&t===super.functionElement&&t.matches(":focus:enabled")&&this.isInteractionStateEnabled(s)&&this.#T(e,t.ownerDocument)},!1))}}#G(e,t,n){const i=e.pointerType==="touch",r=this.#e;if(e.type==="pointerdown"){(this.isInteractionStateEnabled(s)||this.isInteractionStateEnabled(l))&&(i||e.buttons===1)&&this.#T(e,n);return}if(!(i||t!==super.styleElement)&&!(e.type==="pointerleave"&&B(e,t))){if(this.onEvent(e),e.type==="pointerenter"){this.#i(f,e);return}this.#r(f,!1,e),r!==void 0&&r.pointerId===e.pointerId&&r.dragStarted!==!0&&r.releaseTimeoutId===void 0&&this.#t(!0,e)}}static#Y(e,t){const n=c(t);if(n!==null){if(e.type==="contextmenu"){m.add(e),n.controller.#t(!0,e);return}!y(e,t)||!e.isPrimary||e.pointerId!==n.pointerId||(m.add(e),e.type==="pointermove"?n.controller.#F(n,e):e.type==="pointerup"?n.controller.#H(n,e):n.controller.#A(n,e))}}static _maybeHandleTriggerEvent(e){const t=ne(e);if(t===void 0||m.has(e))return;switch(e.type){case"contextmenu":case"lostpointercapture":case"pointercancel":case"pointermove":case"pointerup":b.#Y(e,t);return;case"keydown":case"keyup":if(e.key!==" ")return;break}const n=ae(e.composedPath(),e.type==="click"||e.type==="pointerdown"),i=c(t);if(n!=null){m.add(e),n.controller.#M(e,n.element,t);return}n===void 0&&i!==null&&(e.type==="click"||e.type==="pointerdown")&&(!y(e,t)||i.pointerId===e.pointerId)&&i.controller.#t(!0,e)}#h(e,t){this.#l=void 0,this.#e!==void 0&&this.#t(!0),this.#L();for(const n of E(this.#n))this.#r(n,!0);this.#f(e,t)}onStyleElementChanged(e){this.#a&=-5,e!==null&&this.#o!==0&&e.classList.add(P),this.#h(e,super.styleElement)}onFunctionElementChanged(e){super.isFunctionElementStyle()||this.#h(e,super.functionElement)}onControllerCleanup(){this.isControllerDisposed||(this.#a|=16,this.#h(null,super.styleElement),super.isFunctionElementStyle()||this.#h(null,super.functionElement),super.onControllerCleanup())}}export{b as InteractableController};
|
|
1
|
+
import{DomController as K}from"../dom/client";import{assertDebug as O,checkArgument as F,checkState as g,consumeProps as U,deferAfterDelegatedCancellation as q,eventListenerOptionsOf as C}from"../util";import{isLeaveWithin as B}from"../util/event";import{DragState as l,FocusState as u,HoverState as f,PressState as s,highestInteractionStateOf as v,isInteractionState as H,isInteractionStateMask as A,nameOfInteractionState as X,streamInteractionStates as E}from"./state";import{applyRipple as j}from"./ripple";import{CSS_CLASS_FOCUS_INDICATOR as M,CSS_CLASS_INTERACTABLE as P,CSS_CLASS_STATE_LAYER as x,STATE_LAYER_PSEUDO_ELEMENT as $}from"./style";const z=150,J=350,Q=8,Z="button, input, select, textarea, a[href], [contenteditable]:not([contenteditable=false])",ee={click:s,contextmenu:l|s,focusin:u,focusout:u,keydown:s,keyup:s,lostpointercapture:l|s,pointercancel:l|s,pointerdown:l|s,pointerenter:f,pointerleave:l|f|s,pointermove:l|s,pointerup:l|s},V=Object.keys(ee),W=["click","focusin","keydown","pointerdown","pointerenter"],h=/* @__PURE__ */new WeakMap(),R=/* @__PURE__ */new WeakMap(),L=/* @__PURE__ */new WeakMap(),D=/* @__PURE__ */new WeakMap(),m=/* @__PURE__ */new WeakSet(),p=/* @__PURE__ */new Set();function I(o){return typeof o=="object"&&o!==null&&o.nodeType===1;}function N(o){return o.nodeType===11&&"host"in o;}function y(o,e){const t=e?.defaultView?.PointerEvent;return typeof t=="function"&&o instanceof t||o.type.startsWith("pointer")&&"pointerId"in o&&"pointerType"in o;}function te(o,e){const t=e?.defaultView?.MouseEvent;return typeof t=="function"&&o instanceof t||"clientX"in o;}function ne(o){const e=o.target,t=o.currentTarget;return I(e)?e.ownerDocument:typeof t=="object"&&t!==null&&t.nodeType===9?t:o.composedPath().find(I)?.ownerDocument;}function oe(o){const e=o.ownerDocument;return e.defaultView!==null?e:document;}function ie(o){const e=[];for(let t=o.getRootNode();N(t);t=t.host.getRootNode())t.mode==="closed"&&e.push(t);return e;}function c(o){return D.get(o)??null;}function w(o){let e=R.get(o);if(e===void 0){const t=r=>b._maybeHandleTriggerEvent(r),n=C({capture:!0,passive:!1}),i=C({capture:!0,passive:!0});e={handler:t,root:o,subscribers:0},R.set(o,e);for(const r of V)o.addEventListener(r,t,r==="click"?n:i);N(o)&&L.set(o.host,o);}return e.subscribers++,e;}function k(o){const e=o.root;if(o.subscribers--,o.subscribers===0){for(const t of V)e.removeEventListener(t,o.handler,!0);R.delete(e),N(e)&&L.delete(e.host);}}function _(o,e){const t=o.ownerDocument,n=e.document;n.root!==t&&(e.document=w(t),k(n)),e.closedRoots.length===0&&o.getRootNode()!==t&&(e.closedRoots=ie(o).map(w));}function re(o,e){const t=C({capture:!0,passive:!1}),n=i=>{o.isConnected&&(G(o,e),_(o,e)),b._maybeHandleTriggerEvent(i);};e.sentinel=n;for(const i of W)o.addEventListener(i,n,t);}function G(o,e){const t=e.sentinel;if(t!==void 0){e.sentinel=void 0;for(const n of W)o.removeEventListener(n,t,!0);}}function se(){for(const o of p){const e=h.get(o);e!==void 0&&(o.isConnected?_(o,e):re(o,e));}p.clear();}function le(o,e){const t=h.get(o);if(t?.controller===e)return;t!==void 0&&Y(o,t.controller);const n={closedRoots:[],controller:e,document:w(oe(o))};if(h.set(o,n),o.isConnected){_(o,n);return;}p.size===0&&queueMicrotask(se),p.add(o);}function Y(o,e){const t=h.get(o);if(t?.controller===e){h.delete(o),p.delete(o),G(o,t),k(t.document);for(const n of t.closedRoots)k(n);}}function ae(o,e){for(let t=0;t<o.length;t++){const n=o[t];if(!I(n))continue;const i=h.get(n),r=L.get(n);if(i!==void 0)return{controller:i.controller,element:n};if(!e)return;if(r!==void 0&&o[t-1]!==r)return null;if(n.matches(Z))return;}}function ue(o){return o.ownerDocument.defaultView?.matchMedia("(any-hover: hover)").matches===!0;}function S(o){const e=v(o)??0;return e===s?e|(v(o&~s)??0):e;}function ce(o){return"transitionProperty"in o&&o.transitionProperty==="color"&&o.effect?.pseudoElement===$;}class b extends K{#p;#E;#m;#y;#S;#I;#g;#P;#a;#o;#n;#s;#d;#u;#e;#l;constructor(e,t){super(e,t),{onClick:this.#p,onFocusIn:this.#E,onFocusOut:this.#m,onInteractionStateEntered:this.#I,onInteractionStateExited:this.#g,onPointerEnter:this.#y,onPointerLeave:this.#S}=U(e,[],["onClick","onFocusIn","onFocusOut","onInteractionStateEntered","onInteractionStateExited","onPointerEnter","onPointerLeave"]),this.#P=t?.baseInteractionCssClassName??"cw-interactable",this.#a=(t?.noPressRipple?1:0)|(t?.noFocusIndicator?2:0)|([this.#p,this.#E,this.#m,this.#y,this.#S].some(n=>n!==void 0)?8:0),this.#o=t?.enabledInteractionStates??0,this.#n=0,F(A(this.#o));}#c(e){return(this.#a&e)===e;}get isControllerDisposed(){return this.#c(16);}#w(e){const t=this.#c(e);return this.#a|=e,t;}isPressRippleDisabled(){return this.#c(1);}isFocusIndicatorDisabled(){return this.#c(2);}#C(e){return`${this.#P}-${X(e)}`;}get enabledInteractionStates(){return this.#o;}get enteredInteractionStates(){return this.#n;}isInteractionStateEnabled(e){return O(H(e)),(this.#o&e)===e;}isInteractionStateEntered(e){return O(H(e)),(this.#n&e)===e;}#f(e,t){const n=this;t!==null&&Y(t,n),!(e===null||this.isControllerDisposed||this.#o===0&&!this.#c(8))&&(le(e,n),e.isConnected&&queueMicrotask(()=>this.#v(this.#o)));}#k(e){const t=this.#c(8),n=super.styleElement?.classList;e?(n?.add(P),t||(this.#f(super.styleElement,null),this.#f(super.functionElement,null))):(n?.remove(P,x),this.#a&=-5,t||(this.#f(null,super.styleElement),this.#f(null,super.functionElement)));}setEnabledInteractionStates(e){const t=this.#o,n=this.#e;if(!(this.isControllerDisposed||t===e)){F(A(e)),this.#o=e,(e&s)===0&&(this.#l=void 0),n!==void 0&&(e&(n.dragStarted===!0?l:s))===0&&this.#t(!0);for(const i of E(this.#n&~e))this.#r(i,!0);t!==0!=(e!==0)&&this.#k(e!==0),this.#v(e&~t);}}#v(e){const t=super.styleElement,n=super.functionElement,i=(e&f)!==0&&t!==null&&t.matches(":hover")&&ue(t),r=(e&u)!==0&&I(n)&&n.matches(":focus-visible");if(!(this.isControllerDisposed||!i&&!r)){for(const a of this.#b())ce(a)&&a.finish();i&&this.#i(f),r&&this.#i(u);}}#b(){const e=super.styleElement;return e===null||typeof e.getAnimations!="function"?[]:e.getAnimations({subtree:!0}).filter(t=>{const n=t.effect;return n!==null&&n.target===e&&Number.isFinite(Number(n.getComputedTiming().endTime))&&t.playbackRate!==0&&t.playState!=="paused";});}#L(){this.#u?.cancel(),this.#u=void 0;}#R(e,t,n){for(const i of E(t&~n))e.classList.remove(this.#C(i));for(const i of E(n&~t))e.classList.add(this.#C(i));}#i(e,t){if(this.#s?.(),this.isControllerDisposed||(e&this.#o&~this.#n)!==e)return;const n=super.styleElement,i=S(this.#n),r=S(this.#n|e);let a;if(g(n!==null,"interaction state requires a style element"),this.#n|=e,e===u&&!this.isFocusIndicatorDisabled()&&n.classList.add(M),(r&e)===0){this.#I?.(e,this,t);return;}e===s&&(a=this.#b()),this.#w(4)||n.classList.add(x),this.#R(n,i,r),a!==void 0?(this.#d=Promise.allSettled(this.#b().filter(d=>!a.includes(d)).map(d=>d.finished)),this.isPressRippleDisabled()||(this.#u=j(n,this.#e?.position))):(i&~r&s)!==0&&(this.#d=void 0,this.#u?.finish()),this.#I?.(e,this,t);}#N(e,t,n){const i=()=>{this.#s===i&&(this.#s=void 0,this.#r(e,!0,n));};this.#d=void 0,this.#s?.(),this.#s=i,t.then(i);}#r(e,t,n){const i=this.#n,r=i&~e,a=(v(r)??0)<e,d=this.#d,T=super.styleElement;if(this.isInteractionStateEntered(e)){if(e===s&&this.#u?.finish(),a&&e===s&&d!==void 0){if(t!==!0){this.#N(e,d,n);return;}this.#d=void 0;}a&&this.#s!==void 0&&(this.#s(),!this.isInteractionStateEntered(e))||(g(T!==null,"interaction state requires a style element"),this.#n=r,e===u&&T.classList.remove(M),this.#R(T,S(i),S(r)),this.#g?.(e,this,n));}}#T(e,t){const n=y(e,t),i=c(t);let r=i;if(!this.isControllerDisposed){if(i!==null){if(n&&e.type==="pointerdown"&&i===this.#e&&i.pointerId===e.pointerId)return;i!==this.#e||i.touchTimeoutId===void 0?(i.controller.#t(!0,e),r=null):(t.defaultView?.clearTimeout(i.touchTimeoutId),i.touchTimeoutId=void 0);}if(!this.isControllerDisposed){if(r??=this.#_(e,t),r.position===void 0&&te(e,t)&&(e.type!=="click"||n&&e.pointerType!=="")&&(r.position=[e.clientX,e.clientY]),!n){this.#i(s,e);return;}if(r.pointerId=e.pointerId,r.pointerType=e.pointerType,e.type==="pointerdown"&&!this.isInteractionStateEnabled(s)){this.isInteractionStateEnabled(l)||this.#t(!0,e);return;}if(e.type==="click"||e.pointerType!=="touch"||t.defaultView===null){this.#i(s,e);return;}this.#O(r,e);}}}#_(e,t){const n=t.defaultView,i={controller:this,document:t,keyboard:e.type==="keydown"};if(D.set(t,i),this.#e=i,i.keyboard&&n!==null){const r=()=>{this.#e===i&&this.#t(!0);};n.addEventListener("blur",r),i.removeBlurListener=()=>n.removeEventListener("blur",r);}return i;}#O(e,t){const n=e.document.defaultView?.setTimeout(()=>{c(e.document)!==e||e.touchTimeoutId!==n||e.dragStarted===!0||(e.touchTimeoutId=void 0,this.#i(s,t));},z);e.touchTimeoutId=n;}#F(e,t){const n=super.styleElement,i=e.position;if(!(e.dragStarted===!0||i===void 0||!this.isInteractionStateEnabled(l)||(t.clientX-i[0])**2+(t.clientY-i[1])**2<Q**2)&&(e.touchTimeoutId!==void 0&&(e.document.defaultView?.clearTimeout(e.touchTimeoutId),e.touchTimeoutId=void 0),e.dragStarted=!0,this.#i(l,t),!(this.#e!==e||n===null||!n.isConnected)))try{n.setPointerCapture(t.pointerId),e.pointerCaptureElement=n;}catch{}}#H(e,t){if(this.#r(l,!1,t),!(this.isControllerDisposed||this.#e!==e)){if(!this.isInteractionStateEntered(s)){this.#t(!0,t);return;}this.#D(e,t);}}#A(e,t){(t.type!=="lostpointercapture"||e.releaseTimeoutId===void 0)&&this.#t(!0,t);}#D(e,t){const n=e.document.defaultView?.setTimeout(()=>{c(e.document)===e&&e.releaseTimeoutId===n&&(e.releaseTimeoutId=void 0,this.#t(!0,t));},e.pointerType==="touch"?J:0);this.#u?.finish(),n===void 0?this.#t(!0,t):e.releaseTimeoutId=n;}#t(e,t){const n=this.#e,i=n?.document.defaultView,r=n?.pointerCaptureElement;if(g(n!==void 0,"controller owns no press"),D.delete(n.document),this.#e=void 0,this.#l=void 0,n.removeBlurListener?.(),r!==void 0&&n.pointerId!==void 0)try{r.hasPointerCapture(n.pointerId)&&r.releasePointerCapture(n.pointerId);}catch{}n.releaseTimeoutId!==void 0&&i?.clearTimeout(n.releaseTimeoutId),this.#r(l,e??!0,t),n.touchTimeoutId!==void 0?i?.clearTimeout(n.touchTimeoutId):this.#r(s,e??!0,t);}onEvent(e){e.type==="click"?this.#p?.(e,this):e.type==="focusin"?this.#E?.(e,this):e.type==="focusout"?this.#m?.(e,this):e.type==="pointerenter"?this.#y?.(e,this):e.type==="pointerleave"&&this.#S?.(e,this);}#M(e,t,n){if(!this.isControllerDisposed){switch(e.type){case"click":this.#x(e,n);return;case"focusin":case"focusout":this.#V(e,t);return;case"keydown":case"keyup":this.#W(e,t);return;}y(e,n)&&e.isPrimary&&this.#G(e,t,n);}}#x(e,t){let n;this.onEvent(e),this.isInteractionStateEnabled(s)&&(n=c(t),(n===null||n===this.#e&&n.touchTimeoutId!==void 0)&&(this.#T(e,t),n=c(t)),n!==null&&n.controller.#t(!1,e));}#V(e,t){if(t===super.functionElement){if(e.type==="focusin"){this.onEvent(e),t.matches(":focus-visible")&&this.#i(u,e);return;}this.#l=void 0,this.#e?.keyboard===!0&&this.#t(!0,e),this.onEvent(e),this.#r(u,!1,e);}}#W(e,t){const n=this.#e;if(!(t!==super.functionElement||t.localName!=="button")){if(e.type==="keyup"){this.#l=void 0,n?.keyboard===!0&&this.#D(n,e);return;}e.repeat||e.isComposing||!this.isInteractionStateEnabled(s)||(this.#l=e,q(e,t,()=>{this.#l===e&&!this.isControllerDisposed&&!e.defaultPrevented&&t===super.functionElement&&t.matches(":focus:enabled")&&this.isInteractionStateEnabled(s)&&this.#T(e,t.ownerDocument);},!1));}}#G(e,t,n){const i=e.pointerType==="touch",r=this.#e;if(e.type==="pointerdown"){(this.isInteractionStateEnabled(s)||this.isInteractionStateEnabled(l))&&(i||e.buttons===1)&&this.#T(e,n);return;}if(!(i||t!==super.styleElement)&&!(e.type==="pointerleave"&&B(e,t))){if(this.onEvent(e),e.type==="pointerenter"){this.#i(f,e);return;}this.#r(f,!1,e),r!==void 0&&r.pointerId===e.pointerId&&r.dragStarted!==!0&&r.releaseTimeoutId===void 0&&this.#t(!0,e);}}static#Y(e,t){const n=c(t);if(n!==null){if(e.type==="contextmenu"){m.add(e),n.controller.#t(!0,e);return;}!y(e,t)||!e.isPrimary||e.pointerId!==n.pointerId||(m.add(e),e.type==="pointermove"?n.controller.#F(n,e):e.type==="pointerup"?n.controller.#H(n,e):n.controller.#A(n,e));}}static _maybeHandleTriggerEvent(e){const t=ne(e);if(t===void 0||m.has(e))return;switch(e.type){case"contextmenu":case"lostpointercapture":case"pointercancel":case"pointermove":case"pointerup":b.#Y(e,t);return;case"keydown":case"keyup":if(e.key!==" ")return;break;}const n=ae(e.composedPath(),e.type==="click"||e.type==="pointerdown"),i=c(t);if(n!=null){m.add(e),n.controller.#M(e,n.element,t);return;}n===void 0&&i!==null&&(e.type==="click"||e.type==="pointerdown")&&(!y(e,t)||i.pointerId===e.pointerId)&&i.controller.#t(!0,e);}#h(e,t){this.#l=void 0,this.#e!==void 0&&this.#t(!0),this.#L();for(const n of E(this.#n))this.#r(n,!0);this.#f(e,t);}onStyleElementChanged(e){this.#a&=-5,e!==null&&this.#o!==0&&e.classList.add(P),this.#h(e,super.styleElement);}onFunctionElementChanged(e){super.isFunctionElementStyle()||this.#h(e,super.functionElement);}onControllerCleanup(){this.isControllerDisposed||(this.#a|=16,this.#h(null,super.styleElement),super.isFunctionElementStyle()||this.#h(null,super.functionElement),super.onControllerCleanup());}}export{b as InteractableController};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{defineInteractableComponent as a}from"./component";import{DragState as r,FocusState as o,HoverState as c,PressState as l,isInteractionState as p,isInteractionStateMask as I,nameOfInteractionState as i}from"./state";export{r as DragState,o as FocusState,c as HoverState,l as PressState,a as defineInteractableComponent,p as isInteractionState,I as isInteractionStateMask,i as nameOfInteractionState};
|
|
1
|
+
import{defineInteractableComponent as a}from"./component";import{DragState as r,FocusState as o,HoverState as c,PressState as l,isInteractionState as p,isInteractionStateMask as I,nameOfInteractionState as i}from"./state";export{r as DragState,o as FocusState,c as HoverState,l as PressState,a as defineInteractableComponent,p as isInteractionState,I as isInteractionStateMask,i as nameOfInteractionState};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{applyMotion as p}from"../motion";import{checkState as x,printDebug as w}from"../util";import{CSS_CLASS_RIPPLE as I,STATE_LAYER_PSEUDO_ELEMENT as d}from"./style";const N=75,E=225,D=150,M="cubic-bezier(0.4, 0, 0.2, 1)",_
|
|
1
|
+
import{applyMotion as p}from"../motion";import{checkState as x,printDebug as w}from"../util";import{CSS_CLASS_RIPPLE as I,STATE_LAYER_PSEUDO_ELEMENT as d}from"./style";const N=75,E=225,D=150,M="cubic-bezier(0.4, 0, 0.2, 1)",_=0.3,b="calc(50% + 10px)",O="--cw-interactable-ripple-color",W="--cw-interactable-ripple-opacity",B="--cw-interactable-ripple-radius",g=[{color:"--_CW-INTERACTABLE-RIPPLE1_COLOR",radius:"--_CW-INTERACTABLE-RIPPLE1_RADIUS",x:"--_CW-INTERACTABLE-RIPPLE1_X",y:"--_CW-INTERACTABLE-RIPPLE1_Y"},{color:"--_CW-INTERACTABLE-RIPPLE2_COLOR",radius:"--_CW-INTERACTABLE-RIPPLE2_RADIUS",x:"--_CW-INTERACTABLE-RIPPLE2_X",y:"--_CW-INTERACTABLE-RIPPLE2_Y"}],u=/* @__PURE__ */new WeakMap();class v{#e;layer;#o;#i;#t;#n;constructor(t,n,o){this.#e=t,this.layer=n,this.#o=o.color,this.#i=y(t.ownerDocument),this.#t=[p(t,[{[n.radius]:`${o.radius}px`,offset:0},{[n.radius]:o.end,offset:1}],{duration:E,easing:M,fill:"forwards",pseudoElement:d}),p(t,[{[n.x]:o.x,[n.y]:o.y,offset:0},{[n.x]:"50%",[n.y]:"50%",offset:1}],{duration:E,fill:"forwards",pseudoElement:d}),p(t,[{[n.color]:"transparent",offset:0},{[n.color]:o.color,offset:1}],{duration:N,fill:"forwards",pseudoElement:d})],this.#n=!1;}finish(){if(this.#n)return;const t=p(this.#e,[{[this.layer.color]:this.#o,offset:0},{[this.layer.color]:"transparent",offset:1}],{duration:D,fill:"both",pseudoElement:d,startDelay:Math.max(0,E-(y(this.#e.ownerDocument)-this.#i))});this.#n=!0,this.#t.push(t),t.finished.then(()=>this.cancel(),()=>{});}cancel(){const t=u.get(this.#e);this.#n=!0;for(const n of this.#t)n.finished.catch(()=>{}),n.cancel();this.#t.length=0,t?.includes(this)===!0&&(t.splice(t.indexOf(this),1),t.length===0&&(u.delete(this.#e),this.#e.classList.remove(I)));}}function y(e){const t=e.timeline.currentTime;return typeof t=="number"?t:0;}function i(e,t=0){const n=Number.parseFloat(e);return Number.isFinite(n)?n:t;}function R(e,t){return e.boxSizing==="border-box"?[i(e.width,t[0]),i(e.height,t[1])]:[i(e.width,t[0])+i(e.paddingLeft)+i(e.paddingRight)+i(e.borderLeftWidth)+i(e.borderRightWidth),i(e.height,t[1])+i(e.paddingTop)+i(e.paddingBottom)+i(e.borderTopWidth)+i(e.borderBottomWidth)];}function U(e,t){const n=e.ownerDocument.defaultView;x(n!==null,"element owner document has no browsing context");const o=n.getComputedStyle(e),r=n.getComputedStyle(e,d),a=o.getPropertyValue(O).trim(),h=i(o.getPropertyValue(W)),m=`rgb(from ${a==="currentcolor"?o.color:a} r g b / calc(alpha * ${h}))`,f=i(o.getPropertyValue(B),NaN);if(t===void 0||Number.isFinite(f)){const[S,C]=R(r,[0,0]);return{color:m,end:Number.isFinite(f)?`${f}px`:b,radius:_*Math.max(S,C),x:"50%",y:"50%"};}const s=e.getBoundingClientRect(),[P,L]=R(o,[s.width,s.height]),[c,l]=R(r,[P,L]),T=(t[0]-s.left)*(s.width===0?1:P/s.width)-i(o.borderLeftWidth)-i(r.left),A=(t[1]-s.top)*(s.height===0?1:L/s.height)-i(o.borderTopWidth)-i(r.top);return{color:m,end:b,radius:_*Math.max(c,l),x:`${c===0?50:Math.max(0,Math.min(c,T))/c*100}%`,y:`${l===0?50:Math.max(0,Math.min(l,A))/l*100}%`};}function V(e,t){const n=u.get(e)??[];let o;try{const r=U(e,t);for(const a of n)a.finish();n.length===g.length&&n[0].cancel(),o=new v(e,g.find(a=>n.every(h=>h.layer!==a)),r);}catch(r){w("failed to enter ripple motion",r);return;}return n.push(o),u.set(e,n),e.classList.add(I),o;}export{V as applyRipple};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{assertDebug as i}from"../util";const c=1,u=2,f=4,S=8,n=S|u|c|f,s=["hover","focus","press","drag"];function r(t){return 31-Math.clz32(t>>>0)}function o(t){if(t<0)return;const e=1<<Math.min(t,31);return(e&n)===e?e:void 0}function d(t){return t!==0&&(t&n)===t&&(t&t-1)===0}function x(t){return(t&n)===t}function b(t){const e=r(t);return i(d(t)&&e>=0&&e<=3),s[e]}function a(t){return o(r(t>>>0&-(t>>>0)))}function m(t){return o(r(t))}function p(t,e){return a(t&~(e|e-1))}function*y(t){for(let e=a(t);e!==void 0&&!(yield e);e=p(t,e));}export{S as DragState,u as FocusState,c as HoverState,f as PressState,m as highestInteractionStateOf,d as isInteractionState,x as isInteractionStateMask,a as lowestInteractionStateOf,b as nameOfInteractionState,p as nextInteractionStateOf,y as streamInteractionStates};
|
|
1
|
+
import{assertDebug as i}from"../util";const c=1,u=2,f=4,S=8,n=S|u|c|f,s=["hover","focus","press","drag"];function r(t){return 31-Math.clz32(t>>>0);}function o(t){if(t<0)return;const e=1<<Math.min(t,31);return(e&n)===e?e:void 0;}function d(t){return t!==0&&(t&n)===t&&(t&t-1)===0;}function x(t){return(t&n)===t;}function b(t){const e=r(t);return i(d(t)&&e>=0&&e<=3),s[e];}function a(t){return o(r(t>>>0&-(t>>>0)));}function m(t){return o(r(t));}function p(t,e){return a(t&~(e|e-1));}function*y(t){for(let e=a(t);e!==void 0&&!(yield e);e=p(t,e));}export{S as DragState,u as FocusState,c as HoverState,f as PressState,m as highestInteractionStateOf,d as isInteractionState,x as isInteractionStateMask,a as lowestInteractionStateOf,b as nameOfInteractionState,p as nextInteractionStateOf,y as streamInteractionStates};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const t="::before",S="cw-interactable",e="_cw-interactable-stateLayer",_="_cw-interactable-focusIndicator",c="_cw-interactable-ripple";export{_ as CSS_CLASS_FOCUS_INDICATOR,S as CSS_CLASS_INTERACTABLE,c as CSS_CLASS_RIPPLE,e as CSS_CLASS_STATE_LAYER,t as STATE_LAYER_PSEUDO_ELEMENT};
|
|
1
|
+
const t="::before",S="cw-interactable",e="_cw-interactable-stateLayer",_="_cw-interactable-focusIndicator",c="_cw-interactable-ripple";export{_ as CSS_CLASS_FOCUS_INDICATOR,S as CSS_CLASS_INTERACTABLE,c as CSS_CLASS_RIPPLE,e as CSS_CLASS_STATE_LAYER,t as STATE_LAYER_PSEUDO_ELEMENT};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function X(e,n,o){return Math.min(o,Math.max(n,e))}function M(e,n,o){return e+(n-e)*o}function C(e,n,o,t,r){return r<=o?e:r>=t?n:e+(n-e)*((r-o)/(t-o))}function x(e){if(e>=4294967296)throw new RangeError("invalid keyline count");return Math.max(0,Math.trunc(e)||0)}function N(e,n,o,t,r,u,i){return{size:e,offset:n,unadjustedOffset:o,focal:t,anchor:r,pivot:u,cutoff:i}}function L(e){for(let n=0;n<e.length;n++)if(e[n].focal)return n;return-1}function O(e){for(let n=e.length-1;n>=0;n--)if(e[n].focal)return n;return-1}function T(e,n,o,t){const r=t>0?e.length-1:0;let u=o;for(;u!==r&&e[u].size!==n;)u+=t;return u}function Z(e){let n=-1,o=0;for(let t=0;t<e.length;t++){const r=e[t];!r.anchor&&r.size>o&&(n=t,o=r.size)}return n}function H(e,n){let o=n;for(;n>=0&&o+1<e.length&&e[o+1].size===e[n].size;)o++;return o}function g(e,n,o,t,r){const u=Z(e),i=H(e,u),s=e[u].size,l=[],a=(c,d,_)=>{const{size:b,anchor:h}=e[c],y=d-b/2,S=d+b/2;return N(b,d,_,u<=c&&c<=i,h,c===t,y<0&&S>0?-y:y<n&&S>n?S-n:0)};let f=r-s/2-o,m=f;for(let c=t-1;c>=0;c--){const d=e[c].size;l.push(a(c,f-d/2,m-s/2)),f-=d+o,m-=s+o}l.reverse(),l.push(a(t,r,r)),f=r+s/2+o,m=f;for(let c=t+1;c<e.length;c++){const d=e[c].size;l.push(a(c,f+d/2,m+s/2)),f+=d+o,m+=s+o}return l}function P(e,n,o,t){const r=Z(e);if(r<0)return[];const u=e[r].size,i=H(e,r)-r,s=o===0||i%2===0?0:o/2;return g(e,n,o,r,t?n/2-u/2*i-s-Math.floor(i/2)*o:u/2)}function F(e,n,o){const t=[{size:e,anchor:!0}];for(let r=0;r<n.length;r+=2){const u=n[r+1];for(let i=x(n[r]);i>0;i--)t.push({size:u,anchor:!1})}return t.push({size:o,anchor:!0}),t}function w(e,n,o,t,r,u,i,s,l){const a=e-(s+u+t-1)*n,f=X(r,40,56),m=a-(l*s+i*u+f*t),c=t===0?0:m>0?f+Math.min(m/t,56-f):m<0?f+Math.max(m/t,40-f):f,d=(a-(t+u/2)*c)/(s+u/2),_=(d+c)/2;let b=_,h=d;if(u>0&&d!==l){const S=(l-d)*s,A=Math.min(Math.abs(S),_
|
|
1
|
+
function X(e,n,o){return Math.min(o,Math.max(n,e));}function M(e,n,o){return e+(n-e)*o;}function C(e,n,o,t,r){return r<=o?e:r>=t?n:e+(n-e)*((r-o)/(t-o));}function x(e){if(e>=4294967296)throw new RangeError("invalid keyline count");return Math.max(0,Math.trunc(e)||0);}function N(e,n,o,t,r,u,i){return{size:e,offset:n,unadjustedOffset:o,focal:t,anchor:r,pivot:u,cutoff:i};}function L(e){for(let n=0;n<e.length;n++)if(e[n].focal)return n;return-1;}function O(e){for(let n=e.length-1;n>=0;n--)if(e[n].focal)return n;return-1;}function T(e,n,o,t){const r=t>0?e.length-1:0;let u=o;for(;u!==r&&e[u].size!==n;)u+=t;return u;}function Z(e){let n=-1,o=0;for(let t=0;t<e.length;t++){const r=e[t];!r.anchor&&r.size>o&&(n=t,o=r.size);}return n;}function H(e,n){let o=n;for(;n>=0&&o+1<e.length&&e[o+1].size===e[n].size;)o++;return o;}function g(e,n,o,t,r){const u=Z(e),i=H(e,u),s=e[u].size,l=[],a=(c,d,_)=>{const{size:b,anchor:h}=e[c],y=d-b/2,S=d+b/2;return N(b,d,_,u<=c&&c<=i,h,c===t,y<0&&S>0?-y:y<n&&S>n?S-n:0);};let f=r-s/2-o,m=f;for(let c=t-1;c>=0;c--){const d=e[c].size;l.push(a(c,f-d/2,m-s/2)),f-=d+o,m-=s+o;}l.reverse(),l.push(a(t,r,r)),f=r+s/2+o,m=f;for(let c=t+1;c<e.length;c++){const d=e[c].size;l.push(a(c,f+d/2,m+s/2)),f+=d+o,m+=s+o;}return l;}function P(e,n,o,t){const r=Z(e);if(r<0)return[];const u=e[r].size,i=H(e,r)-r,s=o===0||i%2===0?0:o/2;return g(e,n,o,r,t?n/2-u/2*i-s-Math.floor(i/2)*o:u/2);}function F(e,n,o){const t=[{size:e,anchor:!0}];for(let r=0;r<n.length;r+=2){const u=n[r+1];for(let i=x(n[r]);i>0;i--)t.push({size:u,anchor:!1});}return t.push({size:o,anchor:!0}),t;}function w(e,n,o,t,r,u,i,s,l){const a=e-(s+u+t-1)*n,f=X(r,40,56),m=a-(l*s+i*u+f*t),c=t===0?0:m>0?f+Math.min(m/t,56-f):m<0?f+Math.max(m/t,40-f):f,d=(a-(t+u/2)*c)/(s+u/2),_=(d+c)/2;let b=_,h=d;if(u>0&&d!==l){const S=(l-d)*s,A=Math.min(Math.abs(S),_*0.1*u);S>0?(b-=A/u,h+=A/s):(b+=A/u,h-=A/s);}return{cost:!(s>0&&t>0)||(u>0?h>b&&b>c:h>c)?Math.abs(l-h)*o:1/0,small:c,smallCount:t,medium:b,mediumCount:u,large:h,largeCount:s};}function z(e,n,o,t,r,u,i,s,l){let a,f=0;for(let m=0;m<l;m++)for(const c of u)for(const d of t){const _=w(e,n,++f,d,o,c,r,s-m,i);if((a===void 0||!(_.cost>=a.cost))&&(a=_,a.cost===0))return a;}return a;}function j(e,n,o){const{small:t,smallCount:r,medium:u,mediumCount:i,large:s,largeCount:l}=e;return P(F(10,[l,s,i,u,r,t],10),n,o,!1);}function G(e,n,o,t){if(e===0||n===0)return[];const r=e<80?0:1,u=Math.min(n,e),i=X(u/3,40,56),s=(u+i)/2,l=Math.ceil(e/u),a=Math.max(1,Math.floor((e-s-56*r)/u)),f=x(l-a+1);let m=z(e,o,i,[r],s,[1,0],u,l,f);return m!==void 0&&m.largeCount+m.mediumCount+m.smallCount>t&&(m=z(e,o,i,[0],s,[m.mediumCount],u,l,f)),m===void 0?[]:j(m,e,o);}function D(e,n,o,t){if(e===0)return[];const r=t&&o>=3,u=o<=1?0:r?2:1,i=e<40*u+40*1.25?0:u,s=X(e/3,40,56),l=Math.max(1,Math.floor((e-40*i)/e)),a=x(1-l+1),f=z(e,n,s,[i],0,[0],e,1,a);if(f===void 0)return[];if(!r||o<f.largeCount+f.smallCount)return j(f,e,n);const m=f.smallCount/2,c=f.mediumCount/2;return P(F(10,[m,f.small,c,f.medium,f.largeCount,f.large,c,f.medium,m,f.small],10),e,n,!0);}function U(e,n,o){if(e===0||n===0)return[];const t=Math.min(n,e),r=Math.max(1,Math.floor(e/(t+o))),u=e-r*(t+o);let i=Math.max(u*1.5,10);return i>t*0.85&&(i=Math.min(Math.max(t*0.85,u*1.2),t)),P(F(Math.max(Math.min(10,n),i/2),[r,t,u>0?1:0,i],10),e,o,!1);}function v(e,n,o,t,r){switch(e){case"multi-browse":return G(n,o,t,r);case"hero":case"center-aligned-hero":return D(n,t,r,e==="center-aligned-hero");case"uncontained":return U(n,o,t);default:return[];}}function I(e,n,o,t,r){const u=n>o?1:-1,i=e[n],s=e.findIndex(a=>a.pivot),l=e.slice();return l.splice(n,1),l.splice(o,0,i),g(l,t,r,s+u,e[s].offset+(i.size-i.cutoff+r)*u);}function B(e,n,o){const t=L(e),r=e.findIndex(l=>!l.anchor),u=e[t],i=t-r,s=[e];if(u.offset-u.size/2>=0&&t===r)return s;if(i<=0&&u.cutoff>0)return[e,I(e,0,0,n,o)];for(let l=0,a=e;l<i;l++){const f=r+l,m=f>0?T(a,e[f-1].size,O(a),1)-1:e.length-1;a=I(a,r,m,n,o),s.push(a);}return s;}function p(e,n,o){const t=O(e);let r=e.length-1;for(;r>=0&&e[r].anchor;)r--;const u=e[t],i=r-t,s=[e];if(u.offset+u.size/2<=n&&t===r)return s;if(i<=0&&u.cutoff>0)return[e,I(e,0,0,n,o)];for(let l=0,a=e;l<i;l++){const f=r-l,m=f<e.length-1?T(a,e[f+1].size,L(a)-1,-1)+1:0;a=I(a,r,m,n,o),s.push(a);}return s;}function E(e){return e[0].unadjustedOffset;}function K(e){return-e[e.length-1].unadjustedOffset;}function R(e,n,o){const t=[0];if(n===0)return t;for(let r=1;r<e.length;r++)t.push(r===e.length-1?1:t[r-1]+(o(e[r])-o(e[r-1]))/n);return t;}function W(e,n,o){const t=[];for(let r=0;r<e.length;r++){const u=e[r],i=n[r],s=o<0.5?u:i;t.push(N(M(u.size,i.size,o),M(u.offset,i.offset,o),M(u.unadjustedOffset,i.unadjustedOffset,o),s.focal,s.anchor,s.pivot,M(u.cutoff,i.cutoff,o)));}return t;}function q(e,n,o,t,r){const u=v(e,n,o,t,r),i=L(u);if(r===0||i<0)return;const s=B(u,n,t),l=p(u,n,t),a=E(s[s.length-1])-E(u),f=K(l[l.length-1])-K(u);return{availableSpace:n,itemSize:u[i].size,itemSpacing:t,defaultKeylines:u,startSteps:s,endSteps:l,startShiftDistance:a,endShiftDistance:f,startShiftPoints:R(s,a,E),endShiftPoints:R(l,f,K)};}function J(e,n){return Math.max(0,e.itemSize*n+e.itemSpacing*(n-1)-e.availableSpace);}function Q(e,n,o){const t=Math.max(0,n),r=e.startShiftDistance,u=Math.max(0,o-e.endShiftDistance);let i,s,l,a;if(t>=r&&t<=u)return e.defaultKeylines;t>u?(i=C(0,1,u,o,t),s=e.endShiftPoints,l=e.endSteps,a=u<0.01&&e.startSteps.length===2&&l.length===2?e.startSteps[1]:l[0]):(i=C(1,0,0,r,t),s=e.startShiftPoints,l=e.startSteps,a=l[0]);const f=Math.min(l.length,s.length);for(let m=1;m<f;m++)if(i<=s[m])return W(m===1?a:l[m-1],l[m],C(0,1,s[m-1],s[m],i));return a;}function V(e,n,o,t){const r=e.itemSize,u=o*(r+e.itemSpacing)+r/2-t,i=n.length-1;let s=0,l=n[0];for(;!(l.unadjustedOffset>=u)&&s<i;)l=n[++s];const a=s===0||!(l.unadjustedOffset>=u)?l:n[s-1],f=a===l,m=f?1:(u-a.unadjustedOffset)/(l.unadjustedOffset-a.unadjustedOffset),c=M(a.offset,l.offset,m),d=M(a.size,l.size,m);return{translation:c-u+(f?(u-a.unadjustedOffset)/d:0),maskSize:d,visible:d>0&&c+d/2>0&&c-d/2<e.availableSpace};}function Y(e,n,o){const t=e.defaultKeylines,r=e.startSteps,u=e.endSteps,i=e.itemSize/2,s=L(t),l=r.length-1,a=u.length-1,f=o-1-n;let m=t[s].unadjustedOffset-i;if(n<=l){const c=r[Math.min(l,Math.max(0,l-n))];m=c[L(c)].unadjustedOffset-i;}if(n>=o-1-a&&o>O(t)-s+1){const c=u[Math.min(a,Math.max(0,a-f))];m=c[O(c)].unadjustedOffset-i;}return Math.round(m);}export{Q as carouselKeylinesAt,J as carouselMaxScroll,Y as carouselSnapOffset,q as carouselStrategy,V as placeCarouselItem};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{createComponent as D,createContext as k,onCleanup as z,onMount as H,untrack as f,useContext as R}from"solid-js";import{defineDomComponent as S}from"..";import{DomController as E}from"../dom/client";import{deferAfterDelegatedCancellation as v}from"../util";import{carouselKeylinesAt as _,carouselMaxScroll as O,carouselSnapOffset as N,carouselStrategy as B,placeCarouselItem as F}from"./carousel-layout";import{hasNestedInteractive as $,isElementNode as V}from"./interactive";import"./carousel.css";const X=240,J=40,q=8,G=9/16,U=16/9,K=150,g
|
|
1
|
+
import{createComponent as D,createContext as k,onCleanup as z,onMount as H,untrack as f,useContext as R}from"solid-js";import{defineDomComponent as S}from"..";import{DomController as E}from"../dom/client";import{deferAfterDelegatedCancellation as v}from"../util";import{carouselKeylinesAt as _,carouselMaxScroll as O,carouselSnapOffset as N,carouselStrategy as B,placeCarouselItem as F}from"./carousel-layout";import{hasNestedInteractive as $,isElementNode as V}from"./interactive";import"./carousel.css";const X=240,J=40,q=8,G=9/16,U=16/9,K=150,g=0.5,L="cw-carousel-label-change",W="data-cw-carousel-slide",p="data-cw-carousel-generated-label",A="cw-Carousel-controls",Z=`${A} cw-Carousel-controls-hidden`,M=k();function I(s){return s===void 0||!Number.isFinite(s)?void 0:Math.max(0,Math.trunc(s));}function C(s){return s!==void 0&&Number.isFinite(s)?Math.trunc(s):0;}function w(s){return f(()=>C("index"in s?s.index:"activeIndex"in s?s.activeIndex:s.defaultIndex));}function T(s){return s===void 0||!Number.isFinite(s)?1:Math.max(G,Math.min(U,s));}function j(s){return s==="multi-browse"||s==="hero"||s==="center-aligned-hero"||s==="uncontained";}function P(s,e){const t=I(e.itemCount),i=Math.max(0,w(e)),n=t===void 0?i:Math.min(i,Math.max(0,t-1)),o=e.loop===!0;return<div{...s}aria-label={s["aria-label"]??e.label??"Carousel"}aria-roledescription="carousel"classList={{...s.classList,"cw-Carousel":!0,[`_cw-Carousel-${e.orientation??"horizontal"}`]:!0}}data-cw-carousel-layout={e.layout??"full-screen"}data-cw-carousel-orientation={e.orientation??"horizontal"}data-cw-carousel-snap={e.snap===!0?"true":"false"}role="region">
|
|
2
2
|
<div class={e.showControls===!1?Z:A}>
|
|
3
3
|
<button aria-label={e.previousLabel??"Previous"}class="cw-Carousel-previous"data-cw-carousel-previous disabled={t!==void 0&&!o&&n<=0}type="button">{e.previousLabel??"Previous"}</button>
|
|
4
4
|
<button aria-label={e.nextLabel??"Next"}class="cw-Carousel-next"data-cw-carousel-next disabled={t!==void 0&&!o&&n>=t-1}type="button">{e.nextLabel??"Next"}</button>
|
|
@@ -7,4 +7,4 @@ import{createComponent as D,createContext as k,onCleanup as z,onMount as H,untra
|
|
|
7
7
|
<div class="cw-Carousel-viewport"data-cw-carousel-viewport tabIndex={0}>
|
|
8
8
|
<div class="cw-Carousel-track"data-cw-carousel-track>{s.children}</div>
|
|
9
9
|
</div>
|
|
10
|
-
</div>}class Y extends E{#o;#t;#f;#E;#a;#u;#m;#i;#e;#h;#n;#r;#c;#p;#w;#b;#l;#d;#v;#s;#L;#A;#y;#C;constructor(e){super(e,{styleElementIsFunction:!0}),this.#o="index"in e||"activeIndex"in e,this.#t=null,this.#f=null,this.#E=null,this.#a=null,this.#u=null,this.#m=null,this.#i=[],this.#e=Math.max(0,w(e)),this.#h=void 0,this.#n=f(()=>e.orientation??"horizontal"),this.#r=!1,this.#c=void 0,this.#p=0,this.#w=[],this.#b=new Set,this.#l=void 0,this.#d=void 0,this.#v=!1,this.#s=void 0,this.#L=!1,this.#A=0,this.#y=void 0,this.#C=void 0,H(()=>this.#g()),z(()=>this.#ee())}#x(){return this.props.layout??"full-screen"}#M(){const e=this.#t;return e===null?0:this.#n==="vertical"?e.scrollTop:e.scrollLeft*(this.#r?-1:1)}#q(){const e=this.#f;this.#i=e===null?[]:Array.from(e.children).filter(t=>t.hasAttribute(W)),this.#b.clear()}#g(){this.#t?.isConnected===!0&&(this.#C===void 0&&this.#Q(),this.#q(),this.#I(),this.#O(),this.#$())}#I(){const e=this.#t,t=this.#x(),i=this.#n==="vertical",n=this.#i;if(e===null)return;const o=e.ownerDocument.defaultView,r=i?e.clientHeight:e.clientWidth,d=Math.max(J,this.props.itemSize??X),h=Math.max(0,this.props.itemGap??q),m=i?"scroll-margin-block-start":"scroll-margin-inline-start",b=i?"scroll-margin-inline-start":"scroll-margin-block-start";this.#A=r,this.#r=!i&&o?.getComputedStyle(e).direction==="rtl",this.#c=!j(t)||r<=0?void 0:B(t,r,d,h,n.length),e.style.setProperty("--cw-carousel-item-gap",`${h}px`),e.style.setProperty("--cw-carousel-item-size",`${this.#c?.itemSize??d}px`);const c=this.#c;if(c!==void 0){const l=c.itemSize+c.itemSpacing;this.#p=O(c,n.length),this.#w=n.map((u,y)=>{const x=N(c,y,n.length);return u.style.setProperty(m,`${x}px`),u.style.removeProperty(b),Math.min(this.#p,Math.max(0,y*l-x))});for(const u of n)u.style.visibility="hidden",u.inert=!0;this.#T();return}this.#p=0;for(const l of n)l.style.removeProperty(m),l.style.removeProperty(b),l.style.removeProperty("--cw-carousel-item-offset"),l.style.removeProperty("--cw-carousel-item-inset"),l.style.removeProperty("visibility");const a=this.#f?.getBoundingClientRect();this.#w=a===void 0?[]:n.map(l=>{const u=l.getBoundingClientRect();return i?u.top-a.top:this.#r?a.right-u.right:u.left-a.left})}#T(){const e=this.#c,t=this.#i;if(e===void 0)return;const i=Math.max(0,Math.min(this.#p,this.#M())),n=_(e,i,this.#p),o=e.itemSize+e.itemSpacing,r=n.length,d=Math.max(0,Math.floor(i/o)-r),h=Math.ceil((i+e.availableSpace)/o),m=Math.min(t.length-1,h+r),b=this.#r?-1:1,c=new Set;for(let a=d;a<=m;a++){const l=F(e,n,a,i),u=t[a];l.visible&&(u.style.setProperty("--cw-carousel-item-offset",`${l.translation*b}px`),u.style.setProperty("--cw-carousel-item-inset",`${Math.max(0,(e.itemSize-l.maskSize)/2)}px`),this.#b.has(a)||(u.style.removeProperty("visibility"),u.inert=!1),c.add(a))}for(const a of this.#b){const l=t[a];l!==void 0&&!c.has(a)&&(l.style.visibility="hidden",l.inert=!0)}this.#b=c}#_(){const e=this.#w,t=this.#M();let i=0,n=e.length-1;for(;i<n;){const o=Math.floor((i+n)/2);e[o]<t?i=o+1:n=o}return i>0&&t-e[i-1]<e[i]-t?i-1:i}#O(){const e=this.#i,t=this.#x(),i=this.#c!==void 0;this.#o&&(this.#e=C(this.props.index??this.props.activeIndex)),this.#e=Math.max(0,Math.min(this.#e,e.length-1));for(const[n,o]of e.entries())(!o.hasAttribute("aria-label")||o.hasAttribute(p))&&(o.setAttribute("aria-label",`Slide ${n+1} of ${e.length}`),o.setAttribute(p,"true")),o.setAttribute("aria-current",n===this.#e?"true":"false"),t==="full-screen"?o.inert=n!==this.#e:i||(o.inert=!1);this.#D()}#P(e,t){const i=this.#x()==="full-screen";for(const[n,o]of[[e,!1],[t,!0]]){const r=this.#i[n];r!==void 0&&(r.setAttribute("aria-current",o?"true":"false"),i&&(r.inert=!o))}this.#D()}#D(){const e=this.props.loop===!0,t=this.#i.length;this.#a!==null&&(this.#a.disabled=t===0||!e&&this.#e<=0),this.#u!==null&&(this.#u.disabled=t===0||!e&&this.#e>=t-1)}#k(e,t,i){const n=this.#i.length,o=this.props.loop===!0?(e%n+n)%n:Math.max(0,Math.min(e,n-1)),r=this.#e;if(!(n===0||o===r)){if(this.#o){this.#S(o,t);return}this.#e=o,this.#P(r,o),this.#z(i),this.#S(o,t)}}#S(e,t){f(()=>this.props.onIndexChange?.(e,t))}#z(e){const t=this.#t,i=this.#i[this.#e],n=t?.ownerDocument.defaultView;if(t===null||i===void 0||n==null)return;const o=n.matchMedia("(prefers-reduced-motion: reduce)").matches;this.#N(o?"auto":"smooth"),e&&(i.inert=!1,i.style.removeProperty("visibility"),i.focus({preventScroll:!0}))}#N(e){const t=this.#t,i=this.#i[this.#e],n=this.#n==="vertical";if(t===null||i===void 0)return;if(this.#c!==void 0){const h=this.#w[this.#e]??0,m=this.#r?-h:h;if(Math.abs(h-this.#M())<g)return;this.#B(),t.scrollTo(n?{behavior:e,top:h}:{behavior:e,left:m});return}const o=t.getBoundingClientRect(),r=i.getBoundingClientRect(),d=n?r.top-o.top:this.#r?r.right-o.right:r.left-o.left;!Number.isFinite(d)||Math.abs(d)<g||(this.#B(),t.scrollBy({behavior:e,left:n?0:d,top:n?d:0}))}#B(){this.#v=!0,this.#F()}#F(){const e=this.#t?.ownerDocument.defaultView;this.#s!==void 0&&e?.clearTimeout(this.#s),this.#s=e?.setTimeout(this.#J,K)}#$(){const e=this.#t?.ownerDocument.defaultView;e!=null&&(this.#d!==void 0&&e.cancelAnimationFrame(this.#d),this.#d=e.requestAnimationFrame(()=>{this.#d=void 0,this.#N("auto"),this.#T()}))}#V(){this.#l=void 0,this.#T(),this.#v||this.#X()}#X(){const e=this.#i.length===0?this.#e:this.#_(),t=this.#e;if(!(e===t&&this.#h===void 0)){if(this.#o){e!==(this.#h??t)&&(this.#h=e===t?void 0:e,e!==t&&this.#S(e));return}this.#e=e,this.#P(t,e),this.#S(e)}}#G=()=>{const e=this.#t?.ownerDocument.defaultView;(this.#v||!this.#L)&&this.#F(),!(this.#l!==void 0||e==null)&&(this.#l=e.requestAnimationFrame(()=>this.#V()))};#J=()=>{const e=this.#t?.ownerDocument.defaultView;if(this.#s!==void 0&&e?.clearTimeout(this.#s),this.#s=void 0,this.#l!==void 0&&(e?.cancelAnimationFrame(this.#l),this.#V()),this.#v){this.#v=!1,this.#X();return}!this.#o||this.#i.length===0||(this.#h=void 0,this.#_()!==this.#e&&this.#z(!1))};#U=e=>v(e,this.#t,()=>this.#k(this.#e-1,e,!1),!1);#K=e=>v(e,this.#t,()=>this.#k(this.#e+1,e,!1),!1);#W=e=>{f(()=>this.props.onShowAll?.(e))};#Z=()=>{this.#x()==="uncontained-multi-aspect-ratio"&&this.#I(),this.#O()};#j=e=>{const t=this.#t,i=this.#n==="horizontal",n=i?this.#r?"ArrowLeft":"ArrowRight":"ArrowDown",o=i?this.#r?"ArrowRight":"ArrowLeft":"ArrowUp";if(e.defaultPrevented||t===null||e.target!==t&&V(e.target)&&$(e.target,t,e.composedPath()))return;const r=e.key==="Home"?0:e.key==="End"?this.#i.length-1:e.key===n?this.#e+1:e.key===o?this.#e-1:void 0;r!==void 0&&v(e,t,()=>this.#k(r,e,!0))};applyComponentProps(){const e=super.readProps(["activeIndex","index","itemGap","itemSize","label","layout","loop","nextLabel","onShowAll","orientation","previousLabel","showAllLabel","showControls","snap","attr:aria-label"]),t=e["attr:aria-label"]??e.label??"Carousel";let i=e.layoutChanged||e.itemSizeChanged||e.itemGapChanged;e.snapChanged&&super.setAttribute("data-cw-carousel-snap",e.snap===!0?"true":"false"),e.layoutChanged&&super.setAttribute("data-cw-carousel-layout",e.layout??"full-screen"),e.orientationChanged&&(this.#n=e.orientation??"horizontal",super.setAttribute("data-cw-carousel-orientation",this.#n),super.setClass("orientation",`_cw-Carousel-${this.#n}`),i=!0),super.styleElement?.getAttribute("aria-label")!==t&&super.setAttribute("aria-label",t),this.#m!==null&&(e.onShowAllChanged||e.showAllLabelChanged)&&(this.#m.hidden=e.onShowAll===void 0,this.#m.textContent=e.showAllLabel??"Show all"),e.previousLabelChanged&&this.#a!==null&&(this.#a.setAttribute("aria-label",e.previousLabel??"Previous"),this.#a.textContent=e.previousLabel??"Previous"),e.nextLabelChanged&&this.#u!==null&&(this.#u.setAttribute("aria-label",e.nextLabel??"Next"),this.#u.textContent=e.nextLabel??"Next"),e.showControlsChanged&&this.#E?.classList.toggle("cw-Carousel-controls-hidden",e.showControls===!1),i?this.#g():e.loopChanged&&this.#D(),this.#o&&(e.indexChanged||e.activeIndexChanged)&&this.#Y(C("index"in this.props?e.index:e.activeIndex))}#Y(e){const t=Math.max(0,Math.min(e,this.#i.length-1)),i=this.#e,n=t===this.#h;this.#h=void 0,!(this.#i.length===0||t===i)&&(this.#e=t,this.#P(i,t),n||this.#z(!1))}#H(e,t){const i=t?"addEventListener":"removeEventListener",n=this.#t;n?.[i]("scroll",this.#G,{passive:!0}),n?.[i]("scrollend",this.#J),n?.[i]("keydown",this.#j),this.#a?.[i]("click",this.#U),this.#u?.[i]("click",this.#K),this.#m?.[i]("click",this.#W),e?.[i](L,this.#Z)}#R(){this.#y?.disconnect(),this.#C?.disconnect(),this.#y=void 0,this.#C=void 0}#Q(){const e=this.#t,t=e?.ownerDocument.defaultView;this.#R(),!(t==null||e===null||this.#f===null)&&(this.#y=new t.MutationObserver(()=>this.#g()),this.#y.observe(this.#f,{childList:!0}),this.#C=new t.ResizeObserver(()=>{(this.#n==="vertical"?e.clientHeight:e.clientWidth)!==this.#A&&(this.#I(),this.#$())}),this.#C.observe(e))}onStyleElementChanged(e){this.#H(super.styleElement,!1),super.onStyleElementChanged(e),this.#t=e?.querySelector("[data-cw-carousel-viewport]")??null,this.#f=this.#t?.querySelector(":scope > [data-cw-carousel-track]")??null,this.#E=e?.querySelector(".cw-Carousel-controls")??null,this.#a=e?.querySelector("[data-cw-carousel-previous]")??null,this.#u=e?.querySelector("[data-cw-carousel-next]")??null,this.#m=e?.querySelector(".cw-Carousel-showAll")??null,this.#L=this.#t!==null&&"onscrollend"in this.#t,this.#H(e,!0),this.#R(),this.#g()}render(e){return f(()=>P({children:e},{index:this.#e,itemCount:this.props.itemCount,label:this.props["attr:aria-label"]??this.props.label,layout:this.props.layout,loop:this.props.loop,nextLabel:this.props.nextLabel,onShowAll:this.props.onShowAll,orientation:this.#n,previousLabel:this.props.previousLabel,showAllLabel:this.props.showAllLabel,showControls:this.props.showControls,snap:this.props.snap}))}#ee(){const e=this.#t?.ownerDocument.defaultView;this.#s!==void 0&&e?.clearTimeout(this.#s),this.#l!==void 0&&e?.cancelAnimationFrame(this.#l),this.#d!==void 0&&e?.cancelAnimationFrame(this.#d),this.#s=void 0,this.#l=void 0,this.#d=void 0,this.#R(),this.#H(super.styleElement,!1),this.#i=[],this.#b.clear()}}const Q=S(()=>P,()=>Y),de=s=>D(M.Provider,{value:f(()=>{const e=I(s.itemCount),t=Math.max(0,w(s));let i=0;return{layout:s.layout??"full-screen",currentIndex:e===void 0?t:Math.min(t,Math.max(0,e-1)),itemCount:e,nextItemIndex:()=>i++}}),get children(){return f(()=>Q(s))}});function ee(s,e){const t=R(M),i=t?.nextItemIndex()??0,n=s["aria-label"]??e.label,o=t===void 0?void 0:i===t.currentIndex?"true":"false",r=t?.itemCount===void 0?`Slide ${i+1}`:`Slide ${i+1} of ${t.itemCount}`;return<div{...s}aria-current={o}aria-label={n??r}aria-roledescription="slide"classList={{...s.classList,"cw-Carousel-slide":!0}}data-cw-carousel-generated-label={n===void 0?"true":void 0}data-cw-carousel-slide="true"inert={t?.layout==="full-screen"&&i!==t.currentIndex}role="group"style={{...s.style,"--cw-carousel-aspect-ratio":T(e.aspectRatio)}}tabIndex={-1}><div class="cw-Carousel-mask">{s.children}</div></div>}class te extends E{constructor(e){super(e,{styleElementIsFunction:!0})}#o(){super.styleElement?.dispatchEvent(new Event(L,{bubbles:!0}))}applyComponentProps(){const e=super.readProps(["aspectRatio","label","attr:aria-label"]),t=e["attr:aria-label"]??e.label,i=super.styleElement,n=i?.hasAttribute(p)===!0,o=t===void 0?n&&i?.hasAttribute("aria-label")===!0:!n&&i?.getAttribute("aria-label")===t;e.aspectRatioChanged&&(super.setStyle("--cw-carousel-aspect-ratio",T(e.aspectRatio)),this.#o()),!o&&(t===void 0?(super.setAttribute("aria-label",void 0),i?.setAttribute(p,"true")):(i?.removeAttribute(p),super.setAttribute("aria-label",t)),this.#o())}render(e){return<div aria-roledescription="slide"class="cw-Carousel-slide"data-cw-carousel-slide="true"role="group"tabIndex={-1}><div class="cw-Carousel-mask">{e}</div></div>}}const ie=S(()=>ee,()=>te),he=ie;export{de as Carousel,Y as CarouselController,ie as CarouselItem,he as CarouselSlide};
|
|
10
|
+
</div>;}class Y extends E{#o;#t;#f;#E;#a;#u;#m;#i;#e;#h;#n;#r;#c;#p;#w;#b;#l;#d;#v;#s;#L;#A;#y;#C;constructor(e){super(e,{styleElementIsFunction:!0}),this.#o="index"in e||"activeIndex"in e,this.#t=null,this.#f=null,this.#E=null,this.#a=null,this.#u=null,this.#m=null,this.#i=[],this.#e=Math.max(0,w(e)),this.#h=void 0,this.#n=f(()=>e.orientation??"horizontal"),this.#r=!1,this.#c=void 0,this.#p=0,this.#w=[],this.#b=/* @__PURE__ */new Set(),this.#l=void 0,this.#d=void 0,this.#v=!1,this.#s=void 0,this.#L=!1,this.#A=0,this.#y=void 0,this.#C=void 0,H(()=>this.#g()),z(()=>this.#ee());}#x(){return this.props.layout??"full-screen";}#M(){const e=this.#t;return e===null?0:this.#n==="vertical"?e.scrollTop:e.scrollLeft*(this.#r?-1:1);}#q(){const e=this.#f;this.#i=e===null?[]:Array.from(e.children).filter(t=>t.hasAttribute(W)),this.#b.clear();}#g(){this.#t?.isConnected===!0&&(this.#C===void 0&&this.#Q(),this.#q(),this.#I(),this.#O(),this.#$());}#I(){const e=this.#t,t=this.#x(),i=this.#n==="vertical",n=this.#i;if(e===null)return;const o=e.ownerDocument.defaultView,r=i?e.clientHeight:e.clientWidth,d=Math.max(J,this.props.itemSize??X),h=Math.max(0,this.props.itemGap??q),m=i?"scroll-margin-block-start":"scroll-margin-inline-start",b=i?"scroll-margin-inline-start":"scroll-margin-block-start";this.#A=r,this.#r=!i&&o?.getComputedStyle(e).direction==="rtl",this.#c=!j(t)||r<=0?void 0:B(t,r,d,h,n.length),e.style.setProperty("--cw-carousel-item-gap",`${h}px`),e.style.setProperty("--cw-carousel-item-size",`${this.#c?.itemSize??d}px`);const c=this.#c;if(c!==void 0){const l=c.itemSize+c.itemSpacing;this.#p=O(c,n.length),this.#w=n.map((u,y)=>{const x=N(c,y,n.length);return u.style.setProperty(m,`${x}px`),u.style.removeProperty(b),Math.min(this.#p,Math.max(0,y*l-x));});for(const u of n)u.style.visibility="hidden",u.inert=!0;this.#T();return;}this.#p=0;for(const l of n)l.style.removeProperty(m),l.style.removeProperty(b),l.style.removeProperty("--cw-carousel-item-offset"),l.style.removeProperty("--cw-carousel-item-inset"),l.style.removeProperty("visibility");const a=this.#f?.getBoundingClientRect();this.#w=a===void 0?[]:n.map(l=>{const u=l.getBoundingClientRect();return i?u.top-a.top:this.#r?a.right-u.right:u.left-a.left;});}#T(){const e=this.#c,t=this.#i;if(e===void 0)return;const i=Math.max(0,Math.min(this.#p,this.#M())),n=_(e,i,this.#p),o=e.itemSize+e.itemSpacing,r=n.length,d=Math.max(0,Math.floor(i/o)-r),h=Math.ceil((i+e.availableSpace)/o),m=Math.min(t.length-1,h+r),b=this.#r?-1:1,c=/* @__PURE__ */new Set();for(let a=d;a<=m;a++){const l=F(e,n,a,i),u=t[a];l.visible&&(u.style.setProperty("--cw-carousel-item-offset",`${l.translation*b}px`),u.style.setProperty("--cw-carousel-item-inset",`${Math.max(0,(e.itemSize-l.maskSize)/2)}px`),this.#b.has(a)||(u.style.removeProperty("visibility"),u.inert=!1),c.add(a));}for(const a of this.#b){const l=t[a];l!==void 0&&!c.has(a)&&(l.style.visibility="hidden",l.inert=!0);}this.#b=c;}#_(){const e=this.#w,t=this.#M();let i=0,n=e.length-1;for(;i<n;){const o=Math.floor((i+n)/2);e[o]<t?i=o+1:n=o;}return i>0&&t-e[i-1]<e[i]-t?i-1:i;}#O(){const e=this.#i,t=this.#x(),i=this.#c!==void 0;this.#o&&(this.#e=C(this.props.index??this.props.activeIndex)),this.#e=Math.max(0,Math.min(this.#e,e.length-1));for(const[n,o]of e.entries())(!o.hasAttribute("aria-label")||o.hasAttribute(p))&&(o.setAttribute("aria-label",`Slide ${n+1} of ${e.length}`),o.setAttribute(p,"true")),o.setAttribute("aria-current",n===this.#e?"true":"false"),t==="full-screen"?o.inert=n!==this.#e:i||(o.inert=!1);this.#D();}#P(e,t){const i=this.#x()==="full-screen";for(const[n,o]of[[e,!1],[t,!0]]){const r=this.#i[n];r!==void 0&&(r.setAttribute("aria-current",o?"true":"false"),i&&(r.inert=!o));}this.#D();}#D(){const e=this.props.loop===!0,t=this.#i.length;this.#a!==null&&(this.#a.disabled=t===0||!e&&this.#e<=0),this.#u!==null&&(this.#u.disabled=t===0||!e&&this.#e>=t-1);}#k(e,t,i){const n=this.#i.length,o=this.props.loop===!0?(e%n+n)%n:Math.max(0,Math.min(e,n-1)),r=this.#e;if(!(n===0||o===r)){if(this.#o){this.#S(o,t);return;}this.#e=o,this.#P(r,o),this.#z(i),this.#S(o,t);}}#S(e,t){f(()=>this.props.onIndexChange?.(e,t));}#z(e){const t=this.#t,i=this.#i[this.#e],n=t?.ownerDocument.defaultView;if(t===null||i===void 0||n==null)return;const o=n.matchMedia("(prefers-reduced-motion: reduce)").matches;this.#N(o?"auto":"smooth"),e&&(i.inert=!1,i.style.removeProperty("visibility"),i.focus({preventScroll:!0}));}#N(e){const t=this.#t,i=this.#i[this.#e],n=this.#n==="vertical";if(t===null||i===void 0)return;if(this.#c!==void 0){const h=this.#w[this.#e]??0,m=this.#r?-h:h;if(Math.abs(h-this.#M())<g)return;this.#B(),t.scrollTo(n?{behavior:e,top:h}:{behavior:e,left:m});return;}const o=t.getBoundingClientRect(),r=i.getBoundingClientRect(),d=n?r.top-o.top:this.#r?r.right-o.right:r.left-o.left;!Number.isFinite(d)||Math.abs(d)<g||(this.#B(),t.scrollBy({behavior:e,left:n?0:d,top:n?d:0}));}#B(){this.#v=!0,this.#F();}#F(){const e=this.#t?.ownerDocument.defaultView;this.#s!==void 0&&e?.clearTimeout(this.#s),this.#s=e?.setTimeout(this.#J,K);}#$(){const e=this.#t?.ownerDocument.defaultView;e!=null&&(this.#d!==void 0&&e.cancelAnimationFrame(this.#d),this.#d=e.requestAnimationFrame(()=>{this.#d=void 0,this.#N("auto"),this.#T();}));}#V(){this.#l=void 0,this.#T(),this.#v||this.#X();}#X(){const e=this.#i.length===0?this.#e:this.#_(),t=this.#e;if(!(e===t&&this.#h===void 0)){if(this.#o){e!==(this.#h??t)&&(this.#h=e===t?void 0:e,e!==t&&this.#S(e));return;}this.#e=e,this.#P(t,e),this.#S(e);}}#G=()=>{const e=this.#t?.ownerDocument.defaultView;(this.#v||!this.#L)&&this.#F(),!(this.#l!==void 0||e==null)&&(this.#l=e.requestAnimationFrame(()=>this.#V()));};#J=()=>{const e=this.#t?.ownerDocument.defaultView;if(this.#s!==void 0&&e?.clearTimeout(this.#s),this.#s=void 0,this.#l!==void 0&&(e?.cancelAnimationFrame(this.#l),this.#V()),this.#v){this.#v=!1,this.#X();return;}!this.#o||this.#i.length===0||(this.#h=void 0,this.#_()!==this.#e&&this.#z(!1));};#U=e=>v(e,this.#t,()=>this.#k(this.#e-1,e,!1),!1);#K=e=>v(e,this.#t,()=>this.#k(this.#e+1,e,!1),!1);#W=e=>{f(()=>this.props.onShowAll?.(e));};#Z=()=>{this.#x()==="uncontained-multi-aspect-ratio"&&this.#I(),this.#O();};#j=e=>{const t=this.#t,i=this.#n==="horizontal",n=i?this.#r?"ArrowLeft":"ArrowRight":"ArrowDown",o=i?this.#r?"ArrowRight":"ArrowLeft":"ArrowUp";if(e.defaultPrevented||t===null||e.target!==t&&V(e.target)&&$(e.target,t,e.composedPath()))return;const r=e.key==="Home"?0:e.key==="End"?this.#i.length-1:e.key===n?this.#e+1:e.key===o?this.#e-1:void 0;r!==void 0&&v(e,t,()=>this.#k(r,e,!0));};applyComponentProps(){const e=super.readProps(["activeIndex","index","itemGap","itemSize","label","layout","loop","nextLabel","onShowAll","orientation","previousLabel","showAllLabel","showControls","snap","attr:aria-label"]),t=e["attr:aria-label"]??e.label??"Carousel";let i=e.layoutChanged||e.itemSizeChanged||e.itemGapChanged;e.snapChanged&&super.setAttribute("data-cw-carousel-snap",e.snap===!0?"true":"false"),e.layoutChanged&&super.setAttribute("data-cw-carousel-layout",e.layout??"full-screen"),e.orientationChanged&&(this.#n=e.orientation??"horizontal",super.setAttribute("data-cw-carousel-orientation",this.#n),super.setClass("orientation",`_cw-Carousel-${this.#n}`),i=!0),super.styleElement?.getAttribute("aria-label")!==t&&super.setAttribute("aria-label",t),this.#m!==null&&(e.onShowAllChanged||e.showAllLabelChanged)&&(this.#m.hidden=e.onShowAll===void 0,this.#m.textContent=e.showAllLabel??"Show all"),e.previousLabelChanged&&this.#a!==null&&(this.#a.setAttribute("aria-label",e.previousLabel??"Previous"),this.#a.textContent=e.previousLabel??"Previous"),e.nextLabelChanged&&this.#u!==null&&(this.#u.setAttribute("aria-label",e.nextLabel??"Next"),this.#u.textContent=e.nextLabel??"Next"),e.showControlsChanged&&this.#E?.classList.toggle("cw-Carousel-controls-hidden",e.showControls===!1),i?this.#g():e.loopChanged&&this.#D(),this.#o&&(e.indexChanged||e.activeIndexChanged)&&this.#Y(C("index"in this.props?e.index:e.activeIndex));}#Y(e){const t=Math.max(0,Math.min(e,this.#i.length-1)),i=this.#e,n=t===this.#h;this.#h=void 0,!(this.#i.length===0||t===i)&&(this.#e=t,this.#P(i,t),n||this.#z(!1));}#H(e,t){const i=t?"addEventListener":"removeEventListener",n=this.#t;n?.[i]("scroll",this.#G,{passive:!0}),n?.[i]("scrollend",this.#J),n?.[i]("keydown",this.#j),this.#a?.[i]("click",this.#U),this.#u?.[i]("click",this.#K),this.#m?.[i]("click",this.#W),e?.[i](L,this.#Z);}#R(){this.#y?.disconnect(),this.#C?.disconnect(),this.#y=void 0,this.#C=void 0;}#Q(){const e=this.#t,t=e?.ownerDocument.defaultView;this.#R(),!(t==null||e===null||this.#f===null)&&(this.#y=new t.MutationObserver(()=>this.#g()),this.#y.observe(this.#f,{childList:!0}),this.#C=new t.ResizeObserver(()=>{(this.#n==="vertical"?e.clientHeight:e.clientWidth)!==this.#A&&(this.#I(),this.#$());}),this.#C.observe(e));}onStyleElementChanged(e){this.#H(super.styleElement,!1),super.onStyleElementChanged(e),this.#t=e?.querySelector("[data-cw-carousel-viewport]")??null,this.#f=this.#t?.querySelector(":scope > [data-cw-carousel-track]")??null,this.#E=e?.querySelector(".cw-Carousel-controls")??null,this.#a=e?.querySelector("[data-cw-carousel-previous]")??null,this.#u=e?.querySelector("[data-cw-carousel-next]")??null,this.#m=e?.querySelector(".cw-Carousel-showAll")??null,this.#L=this.#t!==null&&"onscrollend"in this.#t,this.#H(e,!0),this.#R(),this.#g();}render(e){return f(()=>P({children:e},{index:this.#e,itemCount:this.props.itemCount,label:this.props["attr:aria-label"]??this.props.label,layout:this.props.layout,loop:this.props.loop,nextLabel:this.props.nextLabel,onShowAll:this.props.onShowAll,orientation:this.#n,previousLabel:this.props.previousLabel,showAllLabel:this.props.showAllLabel,showControls:this.props.showControls,snap:this.props.snap}));}#ee(){const e=this.#t?.ownerDocument.defaultView;this.#s!==void 0&&e?.clearTimeout(this.#s),this.#l!==void 0&&e?.cancelAnimationFrame(this.#l),this.#d!==void 0&&e?.cancelAnimationFrame(this.#d),this.#s=void 0,this.#l=void 0,this.#d=void 0,this.#R(),this.#H(super.styleElement,!1),this.#i=[],this.#b.clear();}}const Q=/* @__PURE__ */S(()=>P,()=>Y),de=s=>D(M.Provider,{value:f(()=>{const e=I(s.itemCount),t=Math.max(0,w(s));let i=0;return{layout:s.layout??"full-screen",currentIndex:e===void 0?t:Math.min(t,Math.max(0,e-1)),itemCount:e,nextItemIndex:()=>i++};}),get children(){return f(()=>Q(s));}});function ee(s,e){const t=R(M),i=t?.nextItemIndex()??0,n=s["aria-label"]??e.label,o=t===void 0?void 0:i===t.currentIndex?"true":"false",r=t?.itemCount===void 0?`Slide ${i+1}`:`Slide ${i+1} of ${t.itemCount}`;return<div{...s}aria-current={o}aria-label={n??r}aria-roledescription="slide"classList={{...s.classList,"cw-Carousel-slide":!0}}data-cw-carousel-generated-label={n===void 0?"true":void 0}data-cw-carousel-slide="true"inert={t?.layout==="full-screen"&&i!==t.currentIndex}role="group"style={{...s.style,"--cw-carousel-aspect-ratio":T(e.aspectRatio)}}tabIndex={-1}><div class="cw-Carousel-mask">{s.children}</div></div>;}class te extends E{constructor(e){super(e,{styleElementIsFunction:!0});}#o(){super.styleElement?.dispatchEvent(new Event(L,{bubbles:!0}));}applyComponentProps(){const e=super.readProps(["aspectRatio","label","attr:aria-label"]),t=e["attr:aria-label"]??e.label,i=super.styleElement,n=i?.hasAttribute(p)===!0,o=t===void 0?n&&i?.hasAttribute("aria-label")===!0:!n&&i?.getAttribute("aria-label")===t;e.aspectRatioChanged&&(super.setStyle("--cw-carousel-aspect-ratio",T(e.aspectRatio)),this.#o()),!o&&(t===void 0?(super.setAttribute("aria-label",void 0),i?.setAttribute(p,"true")):(i?.removeAttribute(p),super.setAttribute("aria-label",t)),this.#o());}render(e){return<div aria-roledescription="slide"class="cw-Carousel-slide"data-cw-carousel-slide="true"role="group"tabIndex={-1}><div class="cw-Carousel-mask">{e}</div></div>;}}const ie=/* @__PURE__ */S(()=>ee,()=>te),he=ie;export{de as Carousel,Y as CarouselController,ie as CarouselItem,he as CarouselSlide};
|