@pg-labs-incubator/cobweb 0.0.5 → 0.0.7
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/src/action/button.yaml +9 -0
- package/target/esbuild/action/action.css +1 -1
- package/target/esbuild/action/base.jsx +1 -1
- package/target/esbuild/action/button.jsx +6 -4
- 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/progress-button.css +1 -0
- package/target/esbuild/action/progress-button.jsx +4 -0
- 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/text/visually-hidden.css +1 -0
- package/target/esbuild/text/visually-hidden.jsx +1 -0
- 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/action/base.d.ts +27 -8
- package/target/tsc/action/index.d.ts +3 -1
- package/target/tsc/action/progress-button.css.d.ts +3 -0
- package/target/tsc/action/progress-button.d.ts +46 -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/text/index.d.ts +5 -2
- package/target/tsc/text/visually-hidden.css.d.ts +3 -0
- package/target/tsc/text/visually-hidden.d.ts +33 -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,4 +1,4 @@
|
|
|
1
|
-
import{createComponent as C,createContext as S,mergeProps as A,untrack as g,useContext as v}from"solid-js";import{insert as b}from"solid-js/web";import{defineDomComponent as x}from"..";import{DomController as E}from"../dom/client";import{computedStyleOf as T,deferAfterDelegatedCancellation as L,directActionableChildren as I,isElementNode as d,isVisibleElement as D,mutationObserverOf as O,resolveNavigationSlots as F}from"./base";import{BarScrollState as k,resizeObserverOf as P}from"./scroll";import"../container/elevation-shadow.css";import"./navigation.css";const M={role:"effect",speed:"default"},B={role:"spatial",speed:"fast"},H=["aria-disabled","disabled","hidden","href","inert","role","tabindex"],f=S();function N(){let r=!1;return{claim(t,e){return t||e!==void 0&&e<-1||r?-1:(r=!0,0)}}}function p(r,t){r.inert!==t&&(r.inert=t)}function h(r,t){t==null?r.removeAttribute("tabindex"):r.setAttribute("tabindex",t)}function R(r,t){const e=t.disabled===!0,n=v(f)?.claim(e,t.tabIndex)??t.tabIndex??0;return<button{...r}classList={{...r.classList,"cw-FloatingToolbar-item":!0}}disabled={e}tabIndex={n}type="button"
|
|
1
|
+
import{createComponent as C,createContext as S,mergeProps as A,untrack as g,useContext as v}from"solid-js";import{insert as b}from"solid-js/web";import{defineDomComponent as x}from"..";import{DomController as E}from"../dom/client";import{computedStyleOf as T,deferAfterDelegatedCancellation as L,directActionableChildren as I,isElementNode as d,isVisibleElement as D,mutationObserverOf as O,resolveNavigationSlots as F}from"./base";import{BarScrollState as k,resizeObserverOf as P}from"./scroll";import"../container/elevation-shadow.css";import"./navigation.css";const M={role:"effect",speed:"default"},B={role:"spatial",speed:"fast"},H=["aria-disabled","disabled","hidden","href","inert","role","tabindex"],f=S();function N(){let r=!1;return{claim(t,e){return t||e!==void 0&&e<-1||r?-1:(r=!0,0);}};}function p(r,t){r.inert!==t&&(r.inert=t);}function h(r,t){t==null?r.removeAttribute("tabindex"):r.setAttribute("tabindex",t);}function R(r,t){const e=t.disabled===!0,n=v(f)?.claim(e,t.tabIndex)??t.tabIndex??0;return<button{...r}classList={{...r.classList,"cw-FloatingToolbar-item":!0}}disabled={e}tabIndex={n}type="button"/>;}class z extends E{#r;constructor(t){super(t,{styleElementIsFunction:!0});const e=v(f);this.#r=g(()=>e?.claim(t.disabled===!0,t.tabIndex)??t.tabIndex??0);}applyComponentProps(){const t=super.readProps(["disabled","tabIndex"]);t.disabledChanged&&super.setAttribute("disabled",t.disabled===!0),t.tabIndexChanged&&super.setAttribute("tabindex",t.tabIndex??this.#r);}render(t){const e=<button class="cw-FloatingToolbar-item"type="button"/>;return e.tabIndex=this.#r,b(e,t),e;}}const X=/* @__PURE__ */x(()=>R,()=>z),Y=r=>X(F(r,void 0,[]));class J extends E{#r;#m;#g;#p;#a;#o;#c;#e;#s;#n;#t;#i;#b;#h;#l;#d;constructor(t,e="horizontal"){super(t,{styleElementIsFunction:!0}),this.#r=e,this.#m="attr:aria-orientation"in t,this.#g=n=>this.#F(n),this.#p=n=>this.#E(n),this.#a=g(()=>t.orientation??e),this.#o=!1,this.#c=!0,this.#e=null,this.#s=null,this.#n=/* @__PURE__ */new WeakMap(),this.#t=/* @__PURE__ */new WeakMap(),this.#i=/* @__PURE__ */new Set(),this.#b=null,this.#h=[],this.#l=null,this.#d=null;}#f(){const t=this.styleElement;if(!d(t))return[];const e=/* @__PURE__ */new Map();return I(t,!0).filter(n=>{if(!D(n,e))return!1;this.#n.has(n)||this.#n.set(n,n.getAttribute("tabindex"));const i=this.#n.get(n),o=i==null||Number(i)>=-1;return o?this.#i.add(n):(this.#t.has(n)&&(h(n,i),this.#t.delete(n)),this.#i.delete(n)),o;});}#v(){for(const t of this.#i)t.getAttribute("tabindex")===this.#t.get(t)&&h(t,this.#n.get(t));this.#i=/* @__PURE__ */new Set(),this.#n=/* @__PURE__ */new WeakMap(),this.#t=/* @__PURE__ */new WeakMap(),this.#e=null;}#x(t){if(!d(t)||this.styleElement?.contains(t)===!0)return;const e=[t,...Array.from(t.querySelectorAll("button, a[href], input, select, textarea, [role=button], [tabindex]"))];for(const n of e)this.#t.has(n)&&(n.getAttribute("tabindex")===this.#t.get(n)&&h(n,this.#n.get(n)),this.#t.delete(n),this.#n.delete(n),this.#i.delete(n),this.#e===n&&(this.#e=null));}#u(){const t=this.styleElement,e=this.#f(),n=new Set(e);for(const o of this.#i)!n.has(o)&&t?.contains(o)===!0&&(this.#t.set(o,"-1"),o.getAttribute("tabindex")!=="-1"&&(o.tabIndex=-1));if(e.length===0)return;const i=this.#e!==null&&n.has(this.#e)?this.#e:e.find(o=>o.tabIndex===0)??e[0];for(const o of e){const a=o===i?"0":"-1";this.#t.set(o,a),o.getAttribute("tabindex")!==a&&o.setAttribute("tabindex",a);}}#E(t){!d(t.target)||!this.#f().includes(t.target)||(this.#e=t.target,this.#u());}#F(t){const e=this.styleElement,n=t.target;if(!d(e)||!d(n)||["input","select","textarea"].includes(n.localName))return;const i=this.#f(),o=i.indexOf(n);if(o<0)return;const a=this.#a==="horizontal",l=a&&T(e).direction==="rtl",s=a?l?"ArrowLeft":"ArrowRight":"ArrowDown",c=a?l?"ArrowRight":"ArrowLeft":"ArrowUp",m=t.key==="Home"?0:t.key==="End"?i.length-1:t.key===s?(o+1)%i.length:t.key===c?(o+i.length-1)%i.length:void 0,u=m===void 0?void 0:i[m];u!==void 0&&L(t,e,()=>{this.styleElement!==e||!e.isConnected||!e.contains(u)||(this.#e=u,this.#u(),u.focus());});}#T(){const t=this.styleElement?.querySelector(".cw-FloatingToolbar-fab:not(:empty)")??null,e=!this.#c&&!this.#o;for(const n of this.#h)p(n,e);this.#b!==null&&p(this.#b,e&&t!==null);}#w(t){const e=this.#l,n=P(t);e===null||n===void 0||(this.#d=new n(i=>{for(const o of i){const a=o.borderBoxSize[0],s=this.#o||["bottom","top"].includes(t.getAttribute("data-cw-exit-direction")??"bottom")?a?.blockSize??o.contentRect.height:a?.inlineSize??o.contentRect.width,c=this.#o?0:parseFloat(T(t).getPropertyValue("--cw-FloatingToolbar-floating-screenOffset"));e.setRange(s+(Number.isFinite(c)?c:0));}}),this.#d.observe(t));}applyComponentProps(){const t=super.readProps(["design","docked","exitDirection","expanded","floatingActionButtonPosition","orientation","scrollBehavior","scrollTarget"]);t.designChanged&&super.setAttribute("data-cw-toolbar-design",t.design??"standard"),t.dockedChanged&&(this.#o=t.docked===!0,super.setClass("cw-DockedToolbar",this.#o)),t.orientationChanged&&(this.#a=t.orientation??this.#r,super.setClass("orientation",`_cw-FloatingToolbar-${this.#a}`),this.#m||super.setAttribute("aria-orientation",this.#a)),t.expandedChanged&&(this.#c=t.expanded!==!1,super.setAttribute("data-cw-floating-toolbar-expanded",this.#c?"true":"false")),t.floatingActionButtonPositionChanged&&super.setAttribute("data-cw-fab-position",t.floatingActionButtonPosition??"end"),(t.exitDirectionChanged||t.orientationChanged||t.dockedChanged)&&super.setAttribute("data-cw-exit-direction",this.#o?"bottom":t.exitDirection??(this.#a==="vertical"?"end":"bottom")),(t.scrollBehaviorChanged||t.scrollTargetChanged||t.dockedChanged)&&this.#l?.bind(t.scrollBehavior,t.scrollTarget),g(()=>{this.#T(),this.#u();});}onStyleElementChanged(t){if(super.onStyleElementChanged(t),!d(t))return;t.addEventListener("focusin",this.#p),t.addEventListener("keydown",this.#g),this.#l=new k(t,{property:"--cw-FloatingToolbar-exit-progress",spring:g(()=>this.props.docked===!0)?B:M,onFractionChange:n=>p(t,n>0)}),this.#w(t);const e=O(t);e!==void 0&&(this.#s=new e(n=>{let i=!1;for(const o of n)if(o.type==="childList"){for(const a of Array.from(o.removedNodes))this.#x(a);i=!0;}else if(o.attributeName!=="tabindex")i=!0;else if(d(o.target)){const a=o.target.getAttribute("tabindex");this.#t.get(o.target)!==a&&(this.#n.set(o.target,a),i=!0);}i&&(this.#T(),this.#u());}),this.#s.observe(t,{attributeFilter:H,attributes:!0,childList:!0,subtree:!0}));}onControllerCleanup(){const t=this.styleElement;this.#v(),t?.removeEventListener("focusin",this.#p),t?.removeEventListener("keydown",this.#g),this.#s?.disconnect(),this.#s=null,this.#d?.disconnect(),this.#d=null,this.#l?.dispose(),super.onControllerCleanup();}render(t){let e,n,i,o,a,l,s;const c=<div class="cw-FloatingToolbar"role="toolbar">
|
|
2
2
|
<div class="cw-FloatingToolbar-container cw-elevationShadow"ref={e}>
|
|
3
3
|
<span class="cw-FloatingToolbar-leading"ref={n}>
|
|
4
4
|
<span class="cw-FloatingToolbar-slot"ref={i}/>
|
|
@@ -9,7 +9,7 @@ import{createComponent as C,createContext as S,mergeProps as A,untrack as g,useC
|
|
|
9
9
|
</span>
|
|
10
10
|
</div>
|
|
11
11
|
<span class="cw-FloatingToolbar-fab"ref={s}/>
|
|
12
|
-
</div>;return this.#b=e,this.#h=[n,a],b(i,()=>this.props.leadingContent),b(o,t),b(l,()=>this.props.trailingContent),b(s,()=>this.props.floatingActionButton),c}}function _(r,t,e){const n=e.orientation??r,i=e.docked===!0,o=e.expanded!==!1,a=!o&&!i,l=i?"bottom":e.exitDirection??(n==="vertical"?"end":"bottom"),s=e.floatingActionButton;return<div aria-orientation={n}{...t}classList={{...t.classList,"cw-FloatingToolbar":!0,"cw-DockedToolbar":i,[`_cw-FloatingToolbar-${n}`]:!0}}data-cw-exit-direction={l}data-cw-fab-position={e.floatingActionButtonPosition??"end"}data-cw-floating-toolbar-expanded={o?"true":"false"}data-cw-toolbar-design={e.design??"standard"}role="toolbar">
|
|
12
|
+
</div>;return this.#b=e,this.#h=[n,a],b(i,()=>this.props.leadingContent),b(o,t),b(l,()=>this.props.trailingContent),b(s,()=>this.props.floatingActionButton),c;}}function _(r,t,e){const n=e.orientation??r,i=e.docked===!0,o=e.expanded!==!1,a=!o&&!i,l=i?"bottom":e.exitDirection??(n==="vertical"?"end":"bottom"),s=e.floatingActionButton;return<div aria-orientation={n}{...t}classList={{...t.classList,"cw-FloatingToolbar":!0,"cw-DockedToolbar":i,[`_cw-FloatingToolbar-${n}`]:!0}}data-cw-exit-direction={l}data-cw-fab-position={e.floatingActionButtonPosition??"end"}data-cw-floating-toolbar-expanded={o?"true":"false"}data-cw-toolbar-design={e.design??"standard"}role="toolbar">
|
|
13
13
|
<div class="cw-FloatingToolbar-container cw-elevationShadow"inert={a&&s!==void 0&&s!==null}>
|
|
14
14
|
<span class="cw-FloatingToolbar-leading"inert={a}>
|
|
15
15
|
<span class="cw-FloatingToolbar-slot">{e.leadingContent}</span>
|
|
@@ -20,4 +20,4 @@ import{createComponent as C,createContext as S,mergeProps as A,untrack as g,useC
|
|
|
20
20
|
</span>
|
|
21
21
|
</div>
|
|
22
22
|
<span class="cw-FloatingToolbar-fab">{s}</span>
|
|
23
|
-
</div
|
|
23
|
+
</div>;}function w(r){const t=x(()=>(e,n)=>_(r,e,n),()=>class extends J{constructor(e){super(e,r);}});return e=>C(f.Provider,{value:N(),get children(){return t(F(e,void 0,["leadingContent","trailingContent","floatingActionButton"]));}});}const y=/* @__PURE__ */w("horizontal"),Q=y,Z=/* @__PURE__ */w("vertical"),tt=r=>{const t=A({docked:!0},r);return y(t);};export{tt as DockedToolbar,y as FloatingToolbar,J as FloatingToolbarController,Y as FloatingToolbarItem,Q as HorizontalFloatingToolbar,Z as VerticalFloatingToolbar};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{FocusState as m,HoverState as E,PressState as v}from"../state";const g=m|E|v,d
|
|
1
|
+
import{FocusState as m,HoverState as E,PressState as v}from"../state";const g=m|E|v,d=/* @__PURE__ */new WeakMap(),p=/* @__PURE__ */new Set(["class","classList","style"]);function P(n){const e={},t={};for(const o of Object.keys(n)){const r=p.has(o)?e:t;o!=="children"&&Object.defineProperty(r,o,Object.getOwnPropertyDescriptor(n,o));}return[e,t];}function b(n,e,t){const o=/* @__PURE__ */new Set();for(const r of n)r!==void 0&&!o.has(r)&&(o.add(r),r(e,t));}function T(n,e,t){const o=e.disabled===!0;t("disabled",o),t("name",e.name),t("value",e.value),t("required",e.required===!0),"tabIndex"in e&&t("tabindex",e.tabIndex),n.disabled=o;}function y(n){const e=n.getRootNode();return e.nodeType===Node.DOCUMENT_NODE||e.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&"host"in e?e:void 0;}function R(n,e){queueMicrotask(()=>{if(n.eventPhase===Event.NONE){n.defaultPrevented||e();return;}setTimeout(()=>{n.defaultPrevented||e();},0);});}function N(n,e){const t=y(n);if(t===void 0)return()=>{};let o=d.get(t);if(o===void 0){const a=/* @__PURE__ */new Map(),l=c=>{const s=[];for(const[i,f]of a)i.form!==null&&i.form===c.target&&s.push(f);s.length!==0&&R(c,()=>s.forEach(i=>i()));};o={controls:a,listener:l},d.set(t,o),t.addEventListener("reset",l,!0);}const{controls:r,listener:u}=o;return r.set(n,e),()=>{r.get(n)===e&&(r.delete(n),r.size===0&&(t.removeEventListener("reset",u,!0),d.delete(t)));};}export{g as SELECTION_INTERACTION_STATES,T as applyNativeSelectionAttributes,y as eventRootOf,b as notifySelectionChange,N as observeFormReset,P as splitContainerElementProps};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import{onCleanup as f,onMount as k}from"solid-js";import{defineInteractableComponent as S}from"../state";import{InteractableController as x}from"../state/controller";import{SELECTION_INTERACTION_STATES as a,applyNativeSelectionAttributes as E,notifySelectionChange as v,observeFormReset as I,splitContainerElementProps as g}from"./base";import"./selection.css";const s="cw-Checkbox-checked",c="cw-Checkbox-indeterminate",h="cw-Checkbox-disabled",l="cw-Checkbox-error",u="cw-Checkbox-input",_="previousState";function m(n){return`_cw-Checkbox-from-${n}
|
|
1
|
+
import{onCleanup as f,onMount as k}from"solid-js";import{defineInteractableComponent as S}from"../state";import{InteractableController as x}from"../state/controller";import{SELECTION_INTERACTION_STATES as a,applyNativeSelectionAttributes as E,notifySelectionChange as v,observeFormReset as I,splitContainerElementProps as g}from"./base";import"./selection.css";const s="cw-Checkbox-checked",c="cw-Checkbox-indeterminate",h="cw-Checkbox-disabled",l="cw-Checkbox-error",u="cw-Checkbox-input",_="previousState";function m(n){return`_cw-Checkbox-from-${n}`;}function C(n,e){return e?"indeterminate":n?"checked":"unchecked";}function b(){return<span class="cw-Checkbox-box"aria-hidden="true">
|
|
2
2
|
<svg class="_cw-Checkbox-marks"viewBox="0 0 18 18">
|
|
3
3
|
<rect class="_cw-Checkbox-mark _cw-Checkbox-short"/>
|
|
4
4
|
<rect class="_cw-Checkbox-mark _cw-Checkbox-long"/>
|
|
5
5
|
</svg>
|
|
6
|
-
</span
|
|
6
|
+
</span>;}class w extends x{#e;#t;#c;#d;#i;#a;#n;#r;#o;constructor(e){super(e,{baseInteractionCssClassName:"cw-Checkbox",enabledInteractionStates:a}),this.#e="checked"in e,this.#t="indeterminate"in e,this.#c="attr:aria-invalid"in e,this.#d=t=>this.#l(t),this.#i=!1,this.#a=!1,this.#n=!1,this.#r=void 0,this.#o=void 0,k(()=>{const t=super.functionElement;t!==null&&(this.#o=I(t,()=>this.#h()));}),f(()=>{this.#o?.(),this.#o=void 0;});}get state(){const e=super.functionElement;return e===null?"unchecked":C(e.checked,e.indeterminate);}#s(){const e=this.state;e!==this.#r&&(super.setClass(_,m(this.#r??e)),super.setClass(s,e==="checked"),super.setClass(c,e==="indeterminate"),this.#r=e);}#h(){const e=super.functionElement;e!==null&&(this.#e&&(e.checked=this.props.checked===!0),e.indeterminate=this.#t?this.props.indeterminate===!0:this.#i,this.#s());}#l(e){const t=super.functionElement;t===null||this.#n||(v([this.props.onChange,this.props.onCheckedChange],t.checked,e),this.#e&&(t.checked=this.props.checked===!0),this.#t&&(t.indeterminate=this.props.indeterminate===!0),this.#s());}applyComponentProps(){const e=super.readProps(["checked","defaultChecked","defaultIndeterminate","disabled","error","indeterminate","name","required","tabIndex","value"]),t=super.functionElement;t!==null&&(this.#a||(this.#a=!0,this.#i=e.defaultIndeterminate===!0,t.defaultChecked=e.defaultChecked===!0,this.#e||(t.checked=e.defaultChecked===!0),this.#t||(t.indeterminate=this.#i)),this.#e&&e.checkedChanged&&(t.checked=e.checked===!0),this.#t&&e.indeterminateChanged&&(t.indeterminate=e.indeterminate===!0),e.disabledChanged&&(this.#n=e.disabled===!0,super.setClass(h,this.#n),super.setEnabledInteractionStates(this.#n?0:a)),e.errorChanged&&(super.setClass(l,e.error===!0),this.#c||super.setAttribute("aria-invalid",e.error===!0?"true":void 0)),(e.disabledChanged||e.nameChanged||e.requiredChanged||e.tabIndexChanged||e.valueChanged)&&E(t,e,(r,i)=>super.setAttribute(r,i)),this.#s());}onFunctionElementChanged(e){super.functionElement?.removeEventListener("change",this.#d),super.onFunctionElementChanged(e),e?.addEventListener("change",this.#d);}render(e,t){return<label class="cw-Checkbox">
|
|
7
7
|
<input class={u}ref={t}type="checkbox"/>
|
|
8
8
|
{b()}
|
|
9
9
|
<span class="_cw-selection-label">{e}</span>
|
|
10
|
-
</label
|
|
10
|
+
</label>;}}function y(n,e){const[t,r]=g(n),i=("checked"in e?e.checked:e.defaultChecked)===!0,p=("indeterminate"in e?e.indeterminate:e.defaultIndeterminate)===!0,o=C(i,p),d=e.error===!0;return<label{...t}classList={{...t.classList,[s]:o==="checked",[h]:e.disabled===!0,[l]:d,[c]:o==="indeterminate",[m(o)]:!0,"cw-Checkbox":!0}}>
|
|
11
11
|
<input aria-invalid={d?"true":void 0}{...r}checked={i}class={u}disabled={e.disabled===!0}name={e.name}required={e.required===!0}tabIndex={e.tabIndex}type="checkbox"value={e.value}/>
|
|
12
12
|
{b()}
|
|
13
13
|
<span class="_cw-selection-label">{n.children}</span>
|
|
14
|
-
</label
|
|
14
|
+
</label>;}const N=/* @__PURE__ */S(()=>y,()=>w);export{N as Checkbox,w as CheckboxController};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{createMemo as I,createUniqueId as b,onCleanup as P,onMount as x}from"solid-js";import{DragState as D,defineInteractableComponent as L}from"../state";import{InteractableController as A}from"../state/controller";import{deferAfterDelegatedCancellation as f}from"../util/event";import{SELECTION_INTERACTION_STATES as m,applyNativeSelectionAttributes as k,notifySelectionChange as w,observeFormReset as M,splitContainerElementProps as $}from"./base";import"../container/elevation-shadow.css";import"./selection.css";const h={assist:"cw-AssistChip",filter:"cw-FilterChip",input:"cw-InputChip",suggestion:"cw-SuggestionChip"},g="_cw-selection-form-value",C="Remove",B
|
|
1
|
+
import{createMemo as I,createUniqueId as b,onCleanup as P,onMount as x}from"solid-js";import{DragState as D,defineInteractableComponent as L}from"../state";import{InteractableController as A}from"../state/controller";import{deferAfterDelegatedCancellation as f}from"../util/event";import{SELECTION_INTERACTION_STATES as m,applyNativeSelectionAttributes as k,notifySelectionChange as w,observeFormReset as M,splitContainerElementProps as $}from"./base";import"../container/elevation-shadow.css";import"./selection.css";const h={assist:"cw-AssistChip",filter:"cw-FilterChip",input:"cw-InputChip",suggestion:"cw-SuggestionChip"},g="_cw-selection-form-value",C="Remove",B=/* @__PURE__ */new Set(["Backspace","Delete"]);function l(n){return n==="filter"||n==="input";}function v(n,e){return`_${h[n]}-${e??"flat"}`;}function E(n){if(l(n))return{label:b(),remove:b()};}function S(n,e,t){return<>
|
|
2
2
|
<span class="_cw-Chip-leading">
|
|
3
3
|
{n==="filter"?<svg class="_cw-Chip-checkmark"viewBox="0 0 18 18">
|
|
4
4
|
<path d="M3.75 9.5 7.25 13 14.25 6"/>
|
|
@@ -10,14 +10,14 @@ import{createMemo as I,createUniqueId as b,onCleanup as P,onMount as x}from"soli
|
|
|
10
10
|
</span>
|
|
11
11
|
<span class="_cw-Chip-label"id={t?.label}>{e.label()}</span>
|
|
12
12
|
<span class="_cw-Chip-trailingIcon">{e.trailingIcon()}</span>
|
|
13
|
-
|
|
13
|
+
</>;}function y(){return<svg class="_cw-Chip-removeIcon"viewBox="0 0 18 18">
|
|
14
14
|
<path d="M4.75 4.75 13.25 13.25M13.25 4.75 4.75 13.25"/>
|
|
15
|
-
</svg
|
|
15
|
+
</svg>;}class _ extends A{#e;#i;#C;#l;#a;#b;#p;#s;#o;#u;#t;#n;#r;#h;#c;#d;constructor(e,t){super(e,{baseInteractionCssClassName:h[t],enabledInteractionStates:m}),this.#e=t,this.#i=l(t)?"selected"in e?"selected":"checked"in e?"checked":void 0:void 0,this.#C="attr:aria-pressed"in e,this.#l=i=>this.#E(i),this.#a=i=>this.#S(i),this.#b=i=>this.#g(i),this.#p=void 0,this.#s=!1,this.#o=!1,this.#u=!1,this.#t=!1,this.#n=!1,this.#r=0,this.#h=null,this.#c=null,this.#d=void 0,x(()=>{const i=super.functionElement;i!==null&&l(t)&&(this.#d=M(i,()=>this.#v()));}),P(()=>{this.#r++,this.#d?.(),this.#d=void 0;});}get baseClassName(){return h[this.#e];}#f(){return l(this.#e)?this.#i===void 0?this.#s:this.props[this.#i]===!0:!1;}#m(){const e=super.functionElement,t=this.#c;if(e===null||!l(this.#e))return;const i=this.#f(),s=e.getAttribute("form");super.setClass(`${this.baseClassName}-selected`,i),this.#C||super.setAttribute("aria-pressed",i?"true":"false"),t!==null&&(t.disabled=this.#t||!i||e.name==="",t.name=e.name,t.value=e.value,s===null?t.removeAttribute("form"):t.setAttribute("form",s));}#v(){this.#i===void 0&&(this.#s=this.#o),this.#m();}#E(e){const t=super.functionElement;if(t===null||this.#t||!l(this.#e))return;const i=++this.#r;f(e,t,()=>{if(i!==this.#r||e.defaultPrevented||this.#t||super.functionElement!==t)return;const s=!this.#f();this.#i===void 0&&(this.#s=s),w([this.props.onChange,this.props.onSelectedChange],s,e),this.#m();},!1);}#S(e){B.has(e.key)&&!e.repeat&&this.#g(e);}#g(e){const t=super.styleElement;t===null||this.#t||!this.#n||e.defaultPrevented||f(e,t,()=>{!super.isControllerDisposed&&!this.#t&&this.#n&&this.props.onDismiss?.(e);},e.type==="keydown");}#y(e,t){const i=this.#p;e.hidden=!this.#n,e.disabled=this.#t,super.setClass(`${this.baseClassName}-removable`,this.#n),t!==void 0?(e.setAttribute("aria-label",t),e.removeAttribute("aria-labelledby")):i!==void 0&&(e.setAttribute("aria-label",C),e.setAttribute("aria-labelledby",`${i.remove} ${i.label}`));}applyComponentProps(){const e=super.readProps(["checked","defaultSelected","design","disabled","draggable","expressive","name","onDismiss","removable","removeLabel","selected","tabIndex","value"]),t=super.functionElement,i=this.#h,s=this.baseClassName;t!==null&&(this.#u||(this.#u=!0,this.#o=e.defaultSelected===!0,this.#s=this.#o),e.designChanged&&this.#e!=="input"&&super.setClass("design",v(this.#e,e.design)),e.expressiveChanged&&l(this.#e)&&super.setClass(`${s}-expressive`,e.expressive===!0),(e.disabledChanged||e.draggableChanged)&&(this.#t=e.disabled===!0,super.setClass(`${s}-disabled`,this.#t),super.setEnabledInteractionStates(this.#t?0:e.draggable===!0?m|D:m)),(e.disabledChanged||e.nameChanged||e.tabIndexChanged||e.valueChanged)&&k(t,e,(a,d)=>super.setAttribute(a,d)),i!==null&&(e.disabledChanged||e.onDismissChanged||e.removableChanged||e.removeLabelChanged)&&(this.#n=e.removable===!0||e.onDismiss!==void 0,this.#y(i,e.removeLabel)),this.#m());}onFunctionElementChanged(e){const t=super.functionElement;t?.removeEventListener("click",this.#l),t?.removeEventListener("keydown",this.#a),super.onFunctionElementChanged(e),e?.addEventListener("click",this.#l),e?.addEventListener("keydown",this.#a);}render(e,t){const i=this.props,s=this.baseClassName,a=I(()=>i.label??e),d={avatar:()=>i.avatar,label:a,leadingIcon:()=>i.leadingIcon,trailingIcon:()=>i.trailingIcon},o=E(this.#e),p=r=>{this.#h=r,r.addEventListener("click",this.#b),r.addEventListener("keydown",this.#a);},u=r=>{this.#c=r;};return this.#p=o,<span class={`${s} cw-elevationShadow`}>
|
|
16
16
|
<button class={`${s}-button`}ref={t}type="button">{S(this.#e,d,o)}</button>
|
|
17
17
|
{o!==void 0?<button aria-label={C}aria-labelledby={`${o.remove} ${o.label}`}class={`${s}-remove`}hidden id={o.remove}ref={p}tabIndex={-1}type="button">{y()}</button>:void 0}
|
|
18
18
|
{l(this.#e)?<input class={g}ref={u}type="hidden"/>:void 0}
|
|
19
|
-
</span
|
|
19
|
+
</span>;}}function F(n,e,t){const[i,s]=$(e),a=h[n],d=l(n),o=t.disabled===!0,p=d&&("selected"in t?t.selected:"checked"in t?t.checked:t.defaultSelected)===!0,u=d&&(t.removable===!0||t.onDismiss!==void 0),r=E(n);return<span{...i}classList={{...i.classList,[a]:!0,[`${a}-disabled`]:o,[`${a}-expressive`]:d&&t.expressive===!0,[`${a}-removable`]:u,[`${a}-selected`]:p,[v(n,t.design)]:n!=="input","cw-elevationShadow":!0}}>
|
|
20
20
|
<button aria-pressed={d?p?"true":"false":void 0}{...s}class={`${a}-button`}disabled={o}name={t.name}tabIndex={t.tabIndex}type="button"value={t.value}>{S(n,{avatar:()=>t.avatar,label:()=>t.label??e.children,leadingIcon:()=>t.leadingIcon,trailingIcon:()=>t.trailingIcon},r)}</button>
|
|
21
21
|
{r!==void 0?<button aria-label={t.removeLabel??C}aria-labelledby={t.removeLabel===void 0?`${r.remove} ${r.label}`:void 0}class={`${a}-remove`}disabled={o}hidden={!u}id={r.remove}tabIndex={-1}type="button">{y()}</button>:void 0}
|
|
22
22
|
{d?<input class={g}disabled={o||!p||(t.name??"")===""}form={s.form}name={t.name}type="hidden"value={t.value}/>:void 0}
|
|
23
|
-
</span
|
|
23
|
+
</span>;}function c(n){return L(()=>(e,t)=>F(n,e,t),()=>class extends _{constructor(e){super(e,n);}});}const H=/* @__PURE__ */c("assist"),U=n=><H{...n}design={n.design??"elevated"}/>,J=/* @__PURE__ */c("filter"),j=n=><J{...n}design={n.design??"elevated"}/>,z=/* @__PURE__ */c("input"),T=/* @__PURE__ */c("suggestion"),Y=n=><T{...n}design={n.design??"elevated"}/>;export{H as AssistChip,_ as ChipController,U as ElevatedAssistChip,j as ElevatedFilterChip,Y as ElevatedSuggestionChip,J as FilterChip,z as InputChip,T as SuggestionChip};
|
|
@@ -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};
|