@purpurds/toggle 6.0.1 → 6.1.0
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/dist/LICENSE.txt +14 -50
- package/dist/toggle.cjs.js +5 -5
- package/dist/toggle.cjs.js.map +1 -1
- package/dist/toggle.es.js +491 -541
- package/dist/toggle.es.js.map +1 -1
- package/package.json +6 -6
package/dist/LICENSE.txt
CHANGED
|
@@ -1,62 +1,26 @@
|
|
|
1
1
|
Name: @purpurds/icon
|
|
2
|
-
Version: 6.0.
|
|
2
|
+
Version: 6.0.2
|
|
3
3
|
License: AGPL-3.0-only
|
|
4
4
|
Private: false
|
|
5
5
|
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
Name: @purpurds/label
|
|
9
|
-
Version: 6.0.
|
|
9
|
+
Version: 6.0.2
|
|
10
10
|
License: AGPL-3.0-only
|
|
11
11
|
Private: false
|
|
12
12
|
|
|
13
13
|
---
|
|
14
14
|
|
|
15
15
|
Name: @purpurds/paragraph
|
|
16
|
-
Version: 6.0.
|
|
16
|
+
Version: 6.0.2
|
|
17
17
|
License: AGPL-3.0-only
|
|
18
18
|
Private: false
|
|
19
19
|
|
|
20
20
|
---
|
|
21
21
|
|
|
22
|
-
Name: @babel/runtime
|
|
23
|
-
Version: 7.26.0
|
|
24
|
-
License: MIT
|
|
25
|
-
Private: false
|
|
26
|
-
Description: babel's modular runtime helpers
|
|
27
|
-
Repository: https://github.com/babel/babel.git
|
|
28
|
-
Homepage: https://babel.dev/docs/en/next/babel-runtime
|
|
29
|
-
Author: The Babel Team (https://babel.dev/team)
|
|
30
|
-
License Copyright:
|
|
31
|
-
===
|
|
32
|
-
|
|
33
|
-
MIT License
|
|
34
|
-
|
|
35
|
-
Copyright (c) 2014-present Sebastian McKenzie and other contributors
|
|
36
|
-
|
|
37
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
|
38
|
-
a copy of this software and associated documentation files (the
|
|
39
|
-
"Software"), to deal in the Software without restriction, including
|
|
40
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
|
41
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
|
42
|
-
permit persons to whom the Software is furnished to do so, subject to
|
|
43
|
-
the following conditions:
|
|
44
|
-
|
|
45
|
-
The above copyright notice and this permission notice shall be
|
|
46
|
-
included in all copies or substantial portions of the Software.
|
|
47
|
-
|
|
48
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
49
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
50
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
51
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
52
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
53
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
54
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
55
|
-
|
|
56
|
-
---
|
|
57
|
-
|
|
58
22
|
Name: @radix-ui/primitive
|
|
59
|
-
Version: 1.
|
|
23
|
+
Version: 1.1.1
|
|
60
24
|
License: MIT
|
|
61
25
|
Private: false
|
|
62
26
|
Repository: git+https://github.com/radix-ui/primitives.git
|
|
@@ -65,7 +29,7 @@ Homepage: https://radix-ui.com/primitives
|
|
|
65
29
|
---
|
|
66
30
|
|
|
67
31
|
Name: @radix-ui/react-compose-refs
|
|
68
|
-
Version: 1.
|
|
32
|
+
Version: 1.1.1
|
|
69
33
|
License: MIT
|
|
70
34
|
Private: false
|
|
71
35
|
Repository: git+https://github.com/radix-ui/primitives.git
|
|
@@ -74,7 +38,7 @@ Homepage: https://radix-ui.com/primitives
|
|
|
74
38
|
---
|
|
75
39
|
|
|
76
40
|
Name: @radix-ui/react-context
|
|
77
|
-
Version: 1.
|
|
41
|
+
Version: 1.1.1
|
|
78
42
|
License: MIT
|
|
79
43
|
Private: false
|
|
80
44
|
Repository: git+https://github.com/radix-ui/primitives.git
|
|
@@ -83,7 +47,7 @@ Homepage: https://radix-ui.com/primitives
|
|
|
83
47
|
---
|
|
84
48
|
|
|
85
49
|
Name: @radix-ui/react-use-callback-ref
|
|
86
|
-
Version: 1.0
|
|
50
|
+
Version: 1.1.0
|
|
87
51
|
License: MIT
|
|
88
52
|
Private: false
|
|
89
53
|
Repository: git+https://github.com/radix-ui/primitives.git
|
|
@@ -92,7 +56,7 @@ Homepage: https://radix-ui.com/primitives
|
|
|
92
56
|
---
|
|
93
57
|
|
|
94
58
|
Name: @radix-ui/react-use-controllable-state
|
|
95
|
-
Version: 1.0
|
|
59
|
+
Version: 1.1.0
|
|
96
60
|
License: MIT
|
|
97
61
|
Private: false
|
|
98
62
|
Repository: git+https://github.com/radix-ui/primitives.git
|
|
@@ -101,7 +65,7 @@ Homepage: https://radix-ui.com/primitives
|
|
|
101
65
|
---
|
|
102
66
|
|
|
103
67
|
Name: @radix-ui/react-use-previous
|
|
104
|
-
Version: 1.0
|
|
68
|
+
Version: 1.1.0
|
|
105
69
|
License: MIT
|
|
106
70
|
Private: false
|
|
107
71
|
Repository: git+https://github.com/radix-ui/primitives.git
|
|
@@ -110,7 +74,7 @@ Homepage: https://radix-ui.com/primitives
|
|
|
110
74
|
---
|
|
111
75
|
|
|
112
76
|
Name: @radix-ui/react-use-layout-effect
|
|
113
|
-
Version: 1.0
|
|
77
|
+
Version: 1.1.0
|
|
114
78
|
License: MIT
|
|
115
79
|
Private: false
|
|
116
80
|
Repository: git+https://github.com/radix-ui/primitives.git
|
|
@@ -119,7 +83,7 @@ Homepage: https://radix-ui.com/primitives
|
|
|
119
83
|
---
|
|
120
84
|
|
|
121
85
|
Name: @radix-ui/react-use-size
|
|
122
|
-
Version: 1.0
|
|
86
|
+
Version: 1.1.0
|
|
123
87
|
License: MIT
|
|
124
88
|
Private: false
|
|
125
89
|
Repository: git+https://github.com/radix-ui/primitives.git
|
|
@@ -128,7 +92,7 @@ Homepage: https://radix-ui.com/primitives
|
|
|
128
92
|
---
|
|
129
93
|
|
|
130
94
|
Name: @radix-ui/react-slot
|
|
131
|
-
Version: 1.
|
|
95
|
+
Version: 1.1.2
|
|
132
96
|
License: MIT
|
|
133
97
|
Private: false
|
|
134
98
|
Repository: git+https://github.com/radix-ui/primitives.git
|
|
@@ -137,7 +101,7 @@ Homepage: https://radix-ui.com/primitives
|
|
|
137
101
|
---
|
|
138
102
|
|
|
139
103
|
Name: @radix-ui/react-primitive
|
|
140
|
-
Version:
|
|
104
|
+
Version: 2.0.2
|
|
141
105
|
License: MIT
|
|
142
106
|
Private: false
|
|
143
107
|
Repository: git+https://github.com/radix-ui/primitives.git
|
|
@@ -146,7 +110,7 @@ Homepage: https://radix-ui.com/primitives
|
|
|
146
110
|
---
|
|
147
111
|
|
|
148
112
|
Name: @radix-ui/react-switch
|
|
149
|
-
Version: 1.
|
|
113
|
+
Version: 1.1.3
|
|
150
114
|
License: MIT
|
|
151
115
|
Private: false
|
|
152
116
|
Repository: git+https://github.com/radix-ui/primitives.git
|
package/dist/toggle.cjs.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),f=require("react");require("react-dom");function ae(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const o=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,o.get?o:{enumerable:!0,get:()=>e[t]})}}return n.default=e,Object.freeze(n)}const s=ae(f);function ie(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var I={exports:{}};/*!
|
|
2
2
|
Copyright (c) 2018 Jed Watson.
|
|
3
3
|
Licensed under the MIT License (MIT), see
|
|
4
4
|
http://jedwatson.github.io/classnames
|
|
5
|
-
*/(function(e){(function(){var n={}.hasOwnProperty;function t(){for(var r="",
|
|
5
|
+
*/(function(e){(function(){var n={}.hasOwnProperty;function t(){for(var r="",i=0;i<arguments.length;i++){var u=arguments[i];u&&(r=a(r,o.call(this,u)))}return r}function o(r){if(typeof r=="string"||typeof r=="number")return this&&this[r]||r;if(typeof r!="object")return"";if(Array.isArray(r))return t.apply(this,r);if(r.toString!==Object.prototype.toString&&!r.toString.toString().includes("[native code]"))return r.toString();var i="";for(var u in r)n.call(r,u)&&r[u]&&(i=a(i,this&&this[u]||u));return i}function a(r,i){return i?r?r+" "+i:r+i:r}e.exports?(t.default=t,e.exports=t):window.classNames=t})()})(I);var ue=I.exports;const se=ie(ue),ce={"purpur-icon":"_purpur-icon_8u1lq_1","purpur-icon--xxs":"_purpur-icon--xxs_8u1lq_4","purpur-icon--xs":"_purpur-icon--xs_8u1lq_8","purpur-icon--sm":"_purpur-icon--sm_8u1lq_12","purpur-icon--md":"_purpur-icon--md_8u1lq_16","purpur-icon--lg":"_purpur-icon--lg_8u1lq_20","purpur-icon--xl":"_purpur-icon--xl_8u1lq_24"},le=se.bind(ce),M="purpur-icon",pe="md",de=e=>e.filter(n=>Object.keys(n).length>=1).map(n=>`${n.name}="${n.value}"`).join(" "),fe=({content:e="",title:n}={})=>{const t=[{name:"xmlns",value:"http://www.w3.org/2000/svg"},{name:"fill",value:"currentColor"},{name:"viewBox",value:"0 0 24 24"},n?{name:"role",value:"img"}:{name:"aria-hidden",value:"true"}],o=n?`<title>${n}</title>`:"";return`<svg ${de(t)}>${o}${e}</svg>`},ge=e=>e.replace(/<(\/?)svg([^>]*)>/g,"").trim(),H=({["data-testid"]:e,svg:n,allyTitle:t,className:o,size:a=pe,...r})=>{const i=fe({content:ge(n.svg),title:t}),u=le(o,M,`${M}--${a}`);return l.jsx("span",{"aria-label":t,className:u,"data-testid":e,dangerouslySetInnerHTML:{__html:i},...r})};H.displayName="Icon";const he={name:"checkmark-bold",svg:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path fill-rule="evenodd" d="M21.243 4.176a2 2 0 0 1 .324 2.81l-10.45 13.176a2.092 2.092 0 0 1-3.118.18l-5.413-5.413A2 2 0 1 1 5.414 12.1l3.9 3.9 9.118-11.5a2 2 0 0 1 2.81-.324Z" clip-rule="evenodd"/></svg>',keywords:["checkmark-bold"],category:"utility"};function z(e,n){if(typeof e=="function")return e(n);e!=null&&(e.current=n)}function me(...e){return n=>{let t=!1;const o=e.map(a=>{const r=z(a,n);return!t&&typeof r=="function"&&(t=!0),r});if(t)return()=>{for(let a=0;a<o.length;a++){const r=o[a];typeof r=="function"?r():z(e[a],null)}}}}var V=s.forwardRef((e,n)=>{const{children:t,...o}=e,a=s.Children.toArray(t),r=a.find(ve);if(r){const i=r.props.children,u=a.map(c=>c===r?s.Children.count(i)>1?s.Children.only(null):s.isValidElement(i)?i.props.children:null:c);return l.jsx(D,{...o,ref:n,children:s.isValidElement(i)?s.cloneElement(i,void 0,u):null})}return l.jsx(D,{...o,ref:n,children:t})});V.displayName="Slot";var D=s.forwardRef((e,n)=>{const{children:t,...o}=e;if(s.isValidElement(t)){const a=ye(t),r=be(o,t.props);return t.type!==s.Fragment&&(r.ref=n?me(n,a):a),s.cloneElement(t,r)}return s.Children.count(t)>1?s.Children.only(null):null});D.displayName="SlotClone";var _e=({children:e})=>l.jsx(l.Fragment,{children:e});function ve(e){return s.isValidElement(e)&&e.type===_e}function be(e,n){const t={...n};for(const o in n){const a=e[o],r=n[o];/^on[A-Z]/.test(o)?a&&r?t[o]=(...i)=>{r(...i),a(...i)}:a&&(t[o]=a):o==="style"?t[o]={...a,...r}:o==="className"&&(t[o]=[a,r].filter(Boolean).join(" "))}return{...e,...t}}function ye(e){var n,t;let o=(n=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:n.get,a=o&&"isReactWarning"in o&&o.isReactWarning;return a?e.ref:(o=(t=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:t.get,a=o&&"isReactWarning"in o&&o.isReactWarning,a?e.props.ref:e.props.ref||e.ref)}var we=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],xe=we.reduce((e,n)=>{const t=s.forwardRef((o,a)=>{const{asChild:r,...i}=o,u=r?V:n;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),l.jsx(u,{...i,ref:a})});return t.displayName=`Primitive.${n}`,{...e,[n]:t}},{}),Se="Label",q=s.forwardRef((e,n)=>l.jsx(xe.label,{...e,ref:n,onMouseDown:t=>{var o;t.target.closest("button, input, select, textarea")||((o=e.onMouseDown)==null||o.call(e,t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));q.displayName=Se;var Re=q;function Pe(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var F={exports:{}};/*!
|
|
6
6
|
Copyright (c) 2018 Jed Watson.
|
|
7
7
|
Licensed under the MIT License (MIT), see
|
|
8
8
|
http://jedwatson.github.io/classnames
|
|
9
|
-
*/(function(e){(function(){var n={}.hasOwnProperty;function t(){for(var r="",
|
|
9
|
+
*/(function(e){(function(){var n={}.hasOwnProperty;function t(){for(var r="",i=0;i<arguments.length;i++){var u=arguments[i];u&&(r=a(r,o(u)))}return r}function o(r){if(typeof r=="string"||typeof r=="number")return r;if(typeof r!="object")return"";if(Array.isArray(r))return t.apply(null,r);if(r.toString!==Object.prototype.toString&&!r.toString.toString().includes("[native code]"))return r.toString();var i="";for(var u in r)n.call(r,u)&&r[u]&&(i=a(i,u));return i}function a(r,i){return i?r?r+" "+i:r+i:r}e.exports?(t.default=t,e.exports=t):window.classNames=t})()})(F);var je=F.exports;const Ce=Pe(je),$={"purpur-label":"_purpur-label_12cfi_1","purpur-label--negative":"_purpur-label--negative_12cfi_9","purpur-label--disabled":"_purpur-label--disabled_12cfi_12"},k="purpur-label",Ee=({children:e,className:n,htmlFor:t,"data-testid":o,disabled:a,negative:r=!1,...i})=>{const u=Ce([n,$[k],{[$[`${k}--disabled`]]:a,[$[`${k}--negative`]]:r}]);return l.jsx(Re,{className:u,"data-testid":o,htmlFor:t,...i,children:e})};function $e(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var U={exports:{}};/*!
|
|
10
10
|
Copyright (c) 2018 Jed Watson.
|
|
11
11
|
Licensed under the MIT License (MIT), see
|
|
12
12
|
http://jedwatson.github.io/classnames
|
|
13
|
-
*/(function(e){(function(){var n={}.hasOwnProperty;function t(){for(var r="",
|
|
13
|
+
*/(function(e){(function(){var n={}.hasOwnProperty;function t(){for(var r="",i=0;i<arguments.length;i++){var u=arguments[i];u&&(r=a(r,o(u)))}return r}function o(r){if(typeof r=="string"||typeof r=="number")return r;if(typeof r!="object")return"";if(Array.isArray(r))return t.apply(null,r);if(r.toString!==Object.prototype.toString&&!r.toString.toString().includes("[native code]"))return r.toString();var i="";for(var u in r)n.call(r,u)&&r[u]&&(i=a(i,u));return i}function a(r,i){return i?r?r+" "+i:r+i:r}e.exports?(t.default=t,e.exports=t):window.classNames=t})()})(U);var ke=U.exports;const Oe=$e(ke),j={"purpur-paragraph":"_purpur-paragraph_1rh57_1","purpur-paragraph--disabled":"_purpur-paragraph--disabled_1rh57_7","purpur-paragraph--hyphens":"_purpur-paragraph--hyphens_1rh57_10","purpur-paragraph--negative":"_purpur-paragraph--negative_1rh57_13","purpur-paragraph--paragraph-100":"_purpur-paragraph--paragraph-100_1rh57_16","purpur-paragraph--paragraph-100-medium":"_purpur-paragraph--paragraph-100-medium_1rh57_22","purpur-paragraph--paragraph-100-bold":"_purpur-paragraph--paragraph-100-bold_1rh57_29","purpur-paragraph--paragraph-200":"_purpur-paragraph--paragraph-200_1rh57_36","purpur-paragraph--preamble-100":"_purpur-paragraph--preamble-100_1rh57_42","purpur-paragraph--preamble-200":"_purpur-paragraph--preamble-200_1rh57_48","purpur-paragraph--additional-100":"_purpur-paragraph--additional-100_1rh57_54","purpur-paragraph--additional-100-medium":"_purpur-paragraph--additional-100-medium_1rh57_60","purpur-paragraph--overline-100":"_purpur-paragraph--overline-100_1rh57_67","purpur-paragraph--overline-200":"_purpur-paragraph--overline-200_1rh57_75"},De={PARAGRAPH100:"paragraph-100",PARAGRAPH100MEDIUM:"paragraph-100-medium",PARAGRAPH100BOLD:"paragraph-100-bold",PARAGRAPH200:"paragraph-200",PREAMBLE100:"preamble-100",PREAMBLE200:"preamble-200",ADDITIONAL100:"additional-100",ADDITIONAL100MEDIUM:"additional-100-medium",OVERLINE100:"overline-100",OVERLINE200:"overline-200"},C="purpur-paragraph",G=({["data-testid"]:e,children:n,className:t,disabled:o,enableHyphenation:a=!1,negative:r=!1,variant:i=De.PARAGRAPH100,...u})=>{const c=Oe([t,j[C],j[`${C}--${i}`],{[j[`${C}--hyphens`]]:a,[j[`${C}--disabled`]]:o,[j[`${C}--negative`]]:r}]);return l.jsx("p",{...u,className:c,"data-testid":e,children:n})};G.displayName="Paragraph";function Ne(e,n,{checkForDefaultPrevented:t=!0}={}){return function(a){if(e==null||e(a),t===!1||!a.defaultPrevented)return n==null?void 0:n(a)}}function L(e,n){if(typeof e=="function")return e(n);e!=null&&(e.current=n)}function Z(...e){return n=>{let t=!1;const o=e.map(a=>{const r=L(a,n);return!t&&typeof r=="function"&&(t=!0),r});if(t)return()=>{for(let a=0;a<o.length;a++){const r=o[a];typeof r=="function"?r():L(e[a],null)}}}}function Ae(...e){return s.useCallback(Z(...e),e)}function Me(e,n=[]){let t=[];function o(r,i){const u=s.createContext(i),c=t.length;t=[...t,i];const p=g=>{var b;const{scope:d,children:m,...h}=g,_=((b=d==null?void 0:d[e])==null?void 0:b[c])||u,y=s.useMemo(()=>h,Object.values(h));return l.jsx(_.Provider,{value:y,children:m})};p.displayName=r+"Provider";function v(g,d){var _;const m=((_=d==null?void 0:d[e])==null?void 0:_[c])||u,h=s.useContext(m);if(h)return h;if(i!==void 0)return i;throw new Error(`\`${g}\` must be used within \`${r}\``)}return[p,v]}const a=()=>{const r=t.map(i=>s.createContext(i));return function(u){const c=(u==null?void 0:u[e])||r;return s.useMemo(()=>({[`__scope${e}`]:{...u,[e]:c}}),[u,c])}};return a.scopeName=e,[o,ze(a,...n)]}function ze(...e){const n=e[0];if(e.length===1)return n;const t=()=>{const o=e.map(a=>({useScope:a(),scopeName:a.scopeName}));return function(r){const i=o.reduce((u,{useScope:c,scopeName:p})=>{const g=c(r)[`__scope${p}`];return{...u,...g}},{});return s.useMemo(()=>({[`__scope${n.scopeName}`]:i}),[i])}};return t.scopeName=n.scopeName,t}function J(e){const n=s.useRef(e);return s.useEffect(()=>{n.current=e}),s.useMemo(()=>(...t)=>{var o;return(o=n.current)==null?void 0:o.call(n,...t)},[])}function Le({prop:e,defaultProp:n,onChange:t=()=>{}}){const[o,a]=Be({defaultProp:n,onChange:t}),r=e!==void 0,i=r?e:o,u=J(t),c=s.useCallback(p=>{if(r){const g=typeof p=="function"?p(e):p;g!==e&&u(g)}else a(p)},[r,e,a,u]);return[i,c]}function Be({defaultProp:e,onChange:n}){const t=s.useState(e),[o]=t,a=s.useRef(o),r=J(n);return s.useEffect(()=>{a.current!==o&&(r(o),a.current=o)},[o,a,r]),t}function Xe(e){const n=s.useRef({value:e,previous:e});return s.useMemo(()=>(n.current.value!==e&&(n.current.previous=n.current.value,n.current.value=e),n.current.previous),[e])}var We=globalThis!=null&&globalThis.document?s.useLayoutEffect:()=>{};function Te(e){const[n,t]=s.useState(void 0);return We(()=>{if(e){t({width:e.offsetWidth,height:e.offsetHeight});const o=new ResizeObserver(a=>{if(!Array.isArray(a)||!a.length)return;const r=a[0];let i,u;if("borderBoxSize"in r){const c=r.borderBoxSize,p=Array.isArray(c)?c[0]:c;i=p.inlineSize,u=p.blockSize}else i=e.offsetWidth,u=e.offsetHeight;t({width:i,height:u})});return o.observe(e,{box:"border-box"}),()=>o.unobserve(e)}else t(void 0)},[e]),n}var K=s.forwardRef((e,n)=>{const{children:t,...o}=e,a=s.Children.toArray(t),r=a.find(He);if(r){const i=r.props.children,u=a.map(c=>c===r?s.Children.count(i)>1?s.Children.only(null):s.isValidElement(i)?i.props.children:null:c);return l.jsx(N,{...o,ref:n,children:s.isValidElement(i)?s.cloneElement(i,void 0,u):null})}return l.jsx(N,{...o,ref:n,children:t})});K.displayName="Slot";var N=s.forwardRef((e,n)=>{const{children:t,...o}=e;if(s.isValidElement(t)){const a=qe(t),r=Ve(o,t.props);return t.type!==s.Fragment&&(r.ref=n?Z(n,a):a),s.cloneElement(t,r)}return s.Children.count(t)>1?s.Children.only(null):null});N.displayName="SlotClone";var Ie=({children:e})=>l.jsx(l.Fragment,{children:e});function He(e){return s.isValidElement(e)&&e.type===Ie}function Ve(e,n){const t={...n};for(const o in n){const a=e[o],r=n[o];/^on[A-Z]/.test(o)?a&&r?t[o]=(...u)=>{r(...u),a(...u)}:a&&(t[o]=a):o==="style"?t[o]={...a,...r}:o==="className"&&(t[o]=[a,r].filter(Boolean).join(" "))}return{...e,...t}}function qe(e){var o,a;let n=(o=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:o.get,t=n&&"isReactWarning"in n&&n.isReactWarning;return t?e.ref:(n=(a=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:a.get,t=n&&"isReactWarning"in n&&n.isReactWarning,t?e.props.ref:e.props.ref||e.ref)}var Fe=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],Q=Fe.reduce((e,n)=>{const t=s.forwardRef((o,a)=>{const{asChild:r,...i}=o,u=r?K:n;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),l.jsx(u,{...i,ref:a})});return t.displayName=`Primitive.${n}`,{...e,[n]:t}},{}),A="Switch",[Ue,ar]=Me(A),[Ge,Ze]=Ue(A),Y=s.forwardRef((e,n)=>{const{__scopeSwitch:t,name:o,checked:a,defaultChecked:r,required:i,disabled:u,value:c="on",onCheckedChange:p,form:v,...g}=e,[d,m]=s.useState(null),h=Ae(n,w=>m(w)),_=s.useRef(!1),y=d?v||!!d.closest("form"):!0,[b=!1,P]=Le({prop:a,defaultProp:r,onChange:p});return l.jsxs(Ge,{scope:t,checked:b,disabled:u,children:[l.jsx(Q.button,{type:"button",role:"switch","aria-checked":b,"aria-required":i,"data-state":te(b),"data-disabled":u?"":void 0,disabled:u,value:c,...g,ref:h,onClick:Ne(e.onClick,w=>{P(x=>!x),y&&(_.current=w.isPropagationStopped(),_.current||w.stopPropagation())})}),y&&l.jsx(Je,{control:d,bubbles:!_.current,name:o,value:c,checked:b,required:i,disabled:u,form:v,style:{transform:"translateX(-100%)"}})]})});Y.displayName=A;var ee="SwitchThumb",re=s.forwardRef((e,n)=>{const{__scopeSwitch:t,...o}=e,a=Ze(ee,t);return l.jsx(Q.span,{"data-state":te(a.checked),"data-disabled":a.disabled?"":void 0,...o,ref:n})});re.displayName=ee;var Je=e=>{const{control:n,checked:t,bubbles:o=!0,...a}=e,r=s.useRef(null),i=Xe(t),u=Te(n);return s.useEffect(()=>{const c=r.current,p=window.HTMLInputElement.prototype,g=Object.getOwnPropertyDescriptor(p,"checked").set;if(i!==t&&g){const d=new Event("click",{bubbles:o});g.call(c,t),c.dispatchEvent(d)}},[i,t,o]),l.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:t,...a,tabIndex:-1,ref:r,style:{...e.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function te(e){return e?"checked":"unchecked"}var Ke=Y,Qe=re;function Ye(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ne={exports:{}};/*!
|
|
14
14
|
Copyright (c) 2018 Jed Watson.
|
|
15
15
|
Licensed under the MIT License (MIT), see
|
|
16
16
|
http://jedwatson.github.io/classnames
|
|
17
|
-
*/(function(e){(function(){var n={}.hasOwnProperty;function t(){for(var r="",
|
|
17
|
+
*/(function(e){(function(){var n={}.hasOwnProperty;function t(){for(var r="",i=0;i<arguments.length;i++){var u=arguments[i];u&&(r=a(r,o(u)))}return r}function o(r){if(typeof r=="string"||typeof r=="number")return r;if(typeof r!="object")return"";if(Array.isArray(r))return t.apply(null,r);if(r.toString!==Object.prototype.toString&&!r.toString.toString().includes("[native code]"))return r.toString();var i="";for(var u in r)n.call(r,u)&&r[u]&&(i=a(i,u));return i}function a(r,i){return i?r?r+" "+i:r+i:r}e.exports?(t.default=t,e.exports=t):window.classNames=t})()})(ne);var er=ne.exports;const O=Ye(er),B=e=>e&&"touches"in e,rr=({children:e,disabled:n,onStart:t,onDrag:o,onStop:a,bounds:r,position:i,style:u})=>{const[c,p]=f.useState(void 0),[v,g]=f.useState(void 0),[d,m]=f.useState(!1),h=b=>{if(!n){b.preventDefault();const P=B(b.nativeEvent)?b.nativeEvent.touches[0].clientX:b.nativeEvent.clientX;g(P),t==null||t()}},_=f.useCallback(b=>{if(typeof v!="number")return;const w=(B(b)?b.touches[0].clientX:b.clientX)-v;if(!w)return;const x=i+w;!d&&Math.abs(x)&&m(!0);const E=x>r.right?r.right:x<r.left?r.left:x;p(E),o==null||o({x:E})},[o,p,d,v]),y=f.useCallback(()=>{g(void 0),p(void 0),m(!1),a==null||a()},[a,g]);return f.useEffect(()=>(window.addEventListener("mousemove",_),window.addEventListener("touchmove",_),()=>{window.removeEventListener("mousemove",_),window.removeEventListener("touchmove",_)}),[_]),f.useEffect(()=>(window.addEventListener("mouseup",y),window.addEventListener("touchend",y),()=>{window.removeEventListener("mouseup",y),window.removeEventListener("touchend",y)}),[y]),f.isValidElement(e)?f.cloneElement(f.Children.only(e),{onMouseDown:h,onTouchStart:h,style:{...u,transform:`translateX(${d?c:i}px)`}}):null},X={width:void 0,height:void 0};function W(e){const{ref:n,box:t="content-box",round:o}=e,[{width:a,height:r},i]=f.useState(X),u=tr(),c=f.useRef({...X}),p=f.useRef(void 0);return p.current=e.onResize,f.useEffect(()=>{if(!n.current||typeof window>"u"||!("ResizeObserver"in window))return;const v=new ResizeObserver(([g])=>{const d=t==="border-box"?"borderBoxSize":t==="device-pixel-content-box"?"devicePixelContentBoxSize":"contentBoxSize",m=T(g,d,"inlineSize"),h=T(g,d,"blockSize");if(c.current.width!==m||c.current.height!==h){const y={width:m&&o?Math.round(m):m,height:h&&o?Math.round(h):h};c.current.width=m,c.current.height=h,p.current?p.current(y):u()&&i(y)}});return v.observe(n.current,{box:t}),()=>{v.disconnect()}},[t,n,u,o]),{width:a,height:r}}function T(e,n,t){return e[n]?Array.isArray(e[n])?e[n][0][t]:e[n][t]:n==="contentBoxSize"?e.contentRect[t==="inlineSize"?"width":"height"]:void 0}function tr(){const e=f.useRef(!1);return f.useEffect(()=>(e.current=!0,()=>{e.current=!1}),[]),f.useCallback(()=>e.current,[])}const nr=({checked:e,onChange:n})=>{const t=f.useRef(null),o=f.useRef(null),[a,r]=f.useState(void 0),[i,u]=f.useState(!1),[c,p]=f.useState(0),{height:v=0}=W({ref:o,round:!0}),{height:g=0}=W({ref:t,round:!0}),d=(g||0)-v,m=v+d,h=d/2,_=m/2,y=typeof a=="number"&&(e?a<_:a>_);return{trackRef:t,thumbRef:o,isDragging:i,bounds:{left:h,right:m},position:e?m:h,onDrag:({x})=>{r(x),Math.abs((e?m:h)-x)>2&&u(!0)},onStop:()=>{u(!1),i&&p(Date.now()),y&&(n==null||n(!e))},onChangeWithDrag:()=>{Date.now()-c>50&&(n==null||n(!e)),r(void 0)}}},S={"purpur-toggle":"_purpur-toggle_1xng6_1","purpur-toggle__track":"_purpur-toggle__track_1xng6_7","purpur-toggle__checkmark-container":"_purpur-toggle__checkmark-container_1xng6_45","purpur-toggle__thumb":"_purpur-toggle__thumb_1xng6_60","purpur-toggle__thumb--dragging":"_purpur-toggle__thumb--dragging_1xng6_80","purpur-toggle__checkmark":"_purpur-toggle__checkmark_1xng6_45","purpur-toggle__label--right":"_purpur-toggle__label--right_1xng6_100","purpur-toggle__label--left":"_purpur-toggle__label--left_1xng6_103","purpur-toggle__container":"_purpur-toggle__container_1xng6_106"},R="purpur-toggle",or=({["data-testid"]:e,className:n,label:t,onChange:o,labelPosition:a="right",checked:r,disableDrag:i,defaultChecked:u,...c},p)=>{const[v,g]=f.useState(typeof r=="boolean"?r:!!u),d=!!(typeof r=="boolean"?r:v),{thumbRef:m,trackRef:h,isDragging:_,onChangeWithDrag:y,...b}=nr({checked:d,onChange:w=>{c.disabled||(o==null||o(w),g(w))}}),P=()=>l.jsx(Ee,{htmlFor:c.id,"data-testid":e&&`${e}-label`,disabled:c.disabled,className:O(S[`${R}__label`],S[`${R}__label--${a}`]),children:l.jsx(G,{variant:"paragraph-100",disabled:c.disabled,children:t})});return l.jsxs("div",{className:O([n,S[`${R}__container`]]),children:[t&&a==="left"&&P(),l.jsx(Ke,{...c,ref:p,id:c.id,"data-testid":e,className:S[R],onCheckedChange:y,checked:d,children:l.jsxs("span",{ref:h,className:S[`${R}__track`],children:[l.jsx("span",{className:S[`${R}__checkmark-container`],children:l.jsx(H,{className:S[`${R}__checkmark`],svg:he,size:"xxs"})}),l.jsx(rr,{disabled:i,...b,children:l.jsx(Qe,{ref:m,"data-testid":e&&`${e}-thumb`,className:O([S[`${R}__thumb`],{[S[`${R}__thumb--dragging`]]:_}])})})]})}),t&&a==="right"&&P()]})},oe=f.forwardRef(or);oe.displayName="Toggle";exports.Toggle=oe;
|
|
18
18
|
//# sourceMappingURL=toggle.cjs.js.map
|