@purpurds/toggle 8.2.1 → 8.2.3
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/DraggableX.d.ts.map +1 -1
- package/dist/LICENSE.txt +14 -14
- package/dist/hooks/useToggleDrag.d.ts.map +1 -1
- package/dist/toggle.cjs.js +5 -5
- package/dist/toggle.cjs.js.map +1 -1
- package/dist/toggle.es.js +319 -305
- package/dist/toggle.es.js.map +1 -1
- package/package.json +6 -6
package/dist/DraggableX.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DraggableX.d.ts","sourceRoot":"","sources":["../src/DraggableX.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,aAAa,EAElB,KAAK,YAAY,EAIlB,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE/D,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,CAAC,EAAE,YAAY,CAAC,gBAAgB,CAAC,CAAC;IAC1C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IACxC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE;QAAE,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IACvC,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,KAAK,CAAC,EAAE,aAAa,CAAC;CACvB,CAAC;AAIF;;;;;GAKG;AACH,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"DraggableX.d.ts","sourceRoot":"","sources":["../src/DraggableX.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,aAAa,EAElB,KAAK,YAAY,EAIlB,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE/D,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,CAAC,EAAE,YAAY,CAAC,gBAAgB,CAAC,CAAC;IAC1C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IACxC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE;QAAE,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IACvC,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,KAAK,CAAC,EAAE,aAAa,CAAC;CACvB,CAAC;AAIF;;;;;GAKG;AACH,eAAO,MAAM,UAAU,GAAI,2EASxB,eAAe,+FAuFjB,CAAC"}
|
package/dist/LICENSE.txt
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
Name: @purpurds/icon
|
|
2
|
-
Version: 8.2.
|
|
2
|
+
Version: 8.2.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: 8.2.
|
|
9
|
+
Version: 8.2.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: 8.2.
|
|
16
|
+
Version: 8.2.2
|
|
17
17
|
License: AGPL-3.0-only
|
|
18
18
|
Private: false
|
|
19
19
|
|
|
20
20
|
---
|
|
21
21
|
|
|
22
22
|
Name: @radix-ui/primitive
|
|
23
|
-
Version: 1.1.
|
|
23
|
+
Version: 1.1.2
|
|
24
24
|
License: MIT
|
|
25
25
|
Private: false
|
|
26
26
|
Repository: git+https://github.com/radix-ui/primitives.git
|
|
@@ -29,7 +29,7 @@ Homepage: https://radix-ui.com/primitives
|
|
|
29
29
|
---
|
|
30
30
|
|
|
31
31
|
Name: @radix-ui/react-compose-refs
|
|
32
|
-
Version: 1.1.
|
|
32
|
+
Version: 1.1.2
|
|
33
33
|
License: MIT
|
|
34
34
|
Private: false
|
|
35
35
|
Repository: git+https://github.com/radix-ui/primitives.git
|
|
@@ -38,7 +38,7 @@ Homepage: https://radix-ui.com/primitives
|
|
|
38
38
|
---
|
|
39
39
|
|
|
40
40
|
Name: @radix-ui/react-context
|
|
41
|
-
Version: 1.1.
|
|
41
|
+
Version: 1.1.2
|
|
42
42
|
License: MIT
|
|
43
43
|
Private: false
|
|
44
44
|
Repository: git+https://github.com/radix-ui/primitives.git
|
|
@@ -47,7 +47,7 @@ Homepage: https://radix-ui.com/primitives
|
|
|
47
47
|
---
|
|
48
48
|
|
|
49
49
|
Name: @radix-ui/react-use-callback-ref
|
|
50
|
-
Version: 1.1.
|
|
50
|
+
Version: 1.1.1
|
|
51
51
|
License: MIT
|
|
52
52
|
Private: false
|
|
53
53
|
Repository: git+https://github.com/radix-ui/primitives.git
|
|
@@ -56,7 +56,7 @@ Homepage: https://radix-ui.com/primitives
|
|
|
56
56
|
---
|
|
57
57
|
|
|
58
58
|
Name: @radix-ui/react-use-controllable-state
|
|
59
|
-
Version: 1.1.
|
|
59
|
+
Version: 1.1.1
|
|
60
60
|
License: MIT
|
|
61
61
|
Private: false
|
|
62
62
|
Repository: git+https://github.com/radix-ui/primitives.git
|
|
@@ -65,7 +65,7 @@ Homepage: https://radix-ui.com/primitives
|
|
|
65
65
|
---
|
|
66
66
|
|
|
67
67
|
Name: @radix-ui/react-use-previous
|
|
68
|
-
Version: 1.1.
|
|
68
|
+
Version: 1.1.1
|
|
69
69
|
License: MIT
|
|
70
70
|
Private: false
|
|
71
71
|
Repository: git+https://github.com/radix-ui/primitives.git
|
|
@@ -74,7 +74,7 @@ Homepage: https://radix-ui.com/primitives
|
|
|
74
74
|
---
|
|
75
75
|
|
|
76
76
|
Name: @radix-ui/react-use-layout-effect
|
|
77
|
-
Version: 1.1.
|
|
77
|
+
Version: 1.1.1
|
|
78
78
|
License: MIT
|
|
79
79
|
Private: false
|
|
80
80
|
Repository: git+https://github.com/radix-ui/primitives.git
|
|
@@ -83,7 +83,7 @@ Homepage: https://radix-ui.com/primitives
|
|
|
83
83
|
---
|
|
84
84
|
|
|
85
85
|
Name: @radix-ui/react-use-size
|
|
86
|
-
Version: 1.1.
|
|
86
|
+
Version: 1.1.1
|
|
87
87
|
License: MIT
|
|
88
88
|
Private: false
|
|
89
89
|
Repository: git+https://github.com/radix-ui/primitives.git
|
|
@@ -92,7 +92,7 @@ Homepage: https://radix-ui.com/primitives
|
|
|
92
92
|
---
|
|
93
93
|
|
|
94
94
|
Name: @radix-ui/react-slot
|
|
95
|
-
Version: 1.
|
|
95
|
+
Version: 1.2.0
|
|
96
96
|
License: MIT
|
|
97
97
|
Private: false
|
|
98
98
|
Repository: git+https://github.com/radix-ui/primitives.git
|
|
@@ -101,7 +101,7 @@ Homepage: https://radix-ui.com/primitives
|
|
|
101
101
|
---
|
|
102
102
|
|
|
103
103
|
Name: @radix-ui/react-primitive
|
|
104
|
-
Version: 2.0.
|
|
104
|
+
Version: 2.0.3
|
|
105
105
|
License: MIT
|
|
106
106
|
Private: false
|
|
107
107
|
Repository: git+https://github.com/radix-ui/primitives.git
|
|
@@ -110,7 +110,7 @@ Homepage: https://radix-ui.com/primitives
|
|
|
110
110
|
---
|
|
111
111
|
|
|
112
112
|
Name: @radix-ui/react-switch
|
|
113
|
-
Version: 1.1.
|
|
113
|
+
Version: 1.1.4
|
|
114
114
|
License: MIT
|
|
115
115
|
Private: false
|
|
116
116
|
Repository: git+https://github.com/radix-ui/primitives.git
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useToggleDrag.d.ts","sourceRoot":"","sources":["../../src/hooks/useToggleDrag.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAoB,MAAM,OAAO,CAAC;AAIzD,KAAK,kBAAkB,GAAG;IACxB,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,CAAC,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;CACpD,CAAC;AAEF,eAAO,MAAM,aAAa,
|
|
1
|
+
{"version":3,"file":"useToggleDrag.d.ts","sourceRoot":"","sources":["../../src/hooks/useToggleDrag.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAoB,MAAM,OAAO,CAAC;AAIzD,KAAK,kBAAkB,GAAG;IACxB,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,CAAC,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;CACpD,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,uBAAuB,kBAAkB;;;;;;;;;oBAiB9C;QAAE,CAAC,EAAE,MAAM,CAAA;KAAE;;;CAiCrC,CAAC"}
|
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 d=require("react/jsx-runtime"),h=require("react");require("react-dom");function te(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,i.get?i:{enumerable:!0,get:()=>e[t]})}}return n.default=e,Object.freeze(n)}const a=te(h);function ne(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var O={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
|
-
*/var
|
|
5
|
+
*/var N;function oe(){return N||(N=1,(function(e){(function(){var n={}.hasOwnProperty;function t(){for(var r="",s=0;s<arguments.length;s++){var u=arguments[s];u&&(r=o(r,i.call(this,u)))}return r}function i(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 s="";for(var u in r)n.call(r,u)&&r[u]&&(s=o(s,this&&this[u]||u));return s}function o(r,s){return s?r?r+" "+s:r+s:r}e.exports?(t.default=t,e.exports=t):window.classNames=t})()})(O)),O.exports}var ie=oe();const se=ne(ie),ue={"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"},ae=se.bind(ue),D="purpur-icon",ce="md",le=e=>e.filter(n=>Object.keys(n).length>=1).map(n=>`${n.name}="${n.value}"`).join(" "),pe=({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"}],i=n?`<title>${n}</title>`:"";return`<svg ${le(t)}>${i}${e}</svg>`},fe=e=>e.replace(/<(\/?)svg([^>]*)>/g,"").trim(),H=({svg:e,allyTitle:n,className:t,size:i=ce,...o})=>{const r=pe({content:fe(e.svg),title:n}),s=ae(t,D,`${D}--${i}`);return d.jsx("span",{className:s,dangerouslySetInnerHTML:{__html:r},...o})};H.displayName="Icon";const de={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 he(...e){return n=>{let t=!1;const i=e.map(o=>{const r=z(o,n);return!t&&typeof r=="function"&&(t=!0),r});if(t)return()=>{for(let o=0;o<i.length;o++){const r=i[o];typeof r=="function"?r():z(e[o],null)}}}}function ge(e){const n=_e(e),t=a.forwardRef((i,o)=>{const{children:r,...s}=i,u=a.Children.toArray(r),c=u.find(ve);if(c){const l=c.props.children,g=u.map(p=>p===c?a.Children.count(l)>1?a.Children.only(null):a.isValidElement(l)?l.props.children:null:p);return d.jsx(n,{...s,ref:o,children:a.isValidElement(l)?a.cloneElement(l,void 0,g):null})}return d.jsx(n,{...s,ref:o,children:r})});return t.displayName=`${e}.Slot`,t}function _e(e){const n=a.forwardRef((t,i)=>{const{children:o,...r}=t;if(a.isValidElement(o)){const s=ye(o),u=be(r,o.props);return o.type!==a.Fragment&&(u.ref=i?he(i,s):s),a.cloneElement(o,u)}return a.Children.count(o)>1?a.Children.only(null):null});return n.displayName=`${e}.SlotClone`,n}var me=Symbol("radix.slottable");function ve(e){return a.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===me}function be(e,n){const t={...n};for(const i in n){const o=e[i],r=n[i];/^on[A-Z]/.test(i)?o&&r?t[i]=(...s)=>{const u=r(...s);return o(...s),u}:o&&(t[i]=o):i==="style"?t[i]={...o,...r}:i==="className"&&(t[i]=[o,r].filter(Boolean).join(" "))}return{...e,...t}}function ye(e){var n,t;let i=(n=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:n.get,o=i&&"isReactWarning"in i&&i.isReactWarning;return o?e.ref:(i=(t=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:t.get,o=i&&"isReactWarning"in i&&i.isReactWarning,o?e.props.ref:e.props.ref||e.ref)}var we=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],xe=we.reduce((e,n)=>{const t=ge(`Primitive.${n}`),i=a.forwardRef((o,r)=>{const{asChild:s,...u}=o,c=s?t:n;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),d.jsx(c,{...u,ref:r})});return i.displayName=`Primitive.${n}`,{...e,[n]:i}},{}),Se="Label",F=a.forwardRef((e,n)=>d.jsx(xe.label,{...e,ref:n,onMouseDown:t=>{var i;t.target.closest("button, input, select, textarea")||((i=e.onMouseDown)==null||i.call(e,t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));F.displayName=Se;var $e=F;function Re(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var A={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
|
-
*/var
|
|
9
|
+
*/var M;function Ce(){return M||(M=1,(function(e){(function(){var n={}.hasOwnProperty;function t(){for(var r="",s=0;s<arguments.length;s++){var u=arguments[s];u&&(r=o(r,i.call(this,u)))}return r}function i(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 s="";for(var u in r)n.call(r,u)&&r[u]&&(s=o(s,this&&this[u]||u));return s}function o(r,s){return s?r?r+" "+s:r+s:r}e.exports?(t.default=t,e.exports=t):window.classNames=t})()})(A)),A.exports}var je=Ce();const Pe=Re(je),ke={"purpur-label":"_purpur-label_1x80u_1","purpur-label--negative":"_purpur-label--negative_1x80u_8","purpur-label--disabled":"_purpur-label--disabled_1x80u_11"},Ee=Pe.bind(ke),P="purpur-label",Oe=({children:e,className:n,disabled:t,negative:i=!1,...o})=>{const r=Ee(n,P,{[`${P}--disabled`]:t,[`${P}--negative`]:i});return d.jsx($e,{className:r,...o,children:e})};function Ne(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var q={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
|
-
*/var
|
|
13
|
+
*/var B;function De(){return B||(B=1,(function(e){(function(){var n={}.hasOwnProperty;function t(){for(var r="",s=0;s<arguments.length;s++){var u=arguments[s];u&&(r=o(r,i.call(this,u)))}return r}function i(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 s="";for(var u in r)n.call(r,u)&&r[u]&&(s=o(s,this&&this[u]||u));return s}function o(r,s){return s?r?r+" "+s:r+s:r}e.exports?(t.default=t,e.exports=t):window.classNames=t})()})(q)),q.exports}var ze=De();const Ae=Ne(ze),Me={"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"},qe=Ae.bind(Me),Be={PARAGRAPH100:"paragraph-100"},C="purpur-paragraph",U=({children:e,className:n,disabled:t,enableHyphenation:i=!1,negative:o=!1,variant:r=Be.PARAGRAPH100,...s})=>{const u=qe(n,C,`${C}--${r}`,{[`${C}--hyphens`]:i,[`${C}--disabled`]:t,[`${C}--negative`]:o});return d.jsx("p",{...s,className:u,children:e})};U.displayName="Paragraph";function Xe(e,n,{checkForDefaultPrevented:t=!0}={}){return function(o){if(e==null||e(o),t===!1||!o.defaultPrevented)return n==null?void 0:n(o)}}function X(e,n){if(typeof e=="function")return e(n);e!=null&&(e.current=n)}function Z(...e){return n=>{let t=!1;const i=e.map(o=>{const r=X(o,n);return!t&&typeof r=="function"&&(t=!0),r});if(t)return()=>{for(let o=0;o<i.length;o++){const r=i[o];typeof r=="function"?r():X(e[o],null)}}}}function Le(...e){return a.useCallback(Z(...e),e)}function We(e,n=[]){let t=[];function i(r,s){const u=a.createContext(s),c=t.length;t=[...t,s];const l=p=>{var b;const{scope:f,children:m,..._}=p,v=((b=f==null?void 0:f[e])==null?void 0:b[c])||u,y=a.useMemo(()=>_,Object.values(_));return d.jsx(v.Provider,{value:y,children:m})};l.displayName=r+"Provider";function g(p,f){var v;const m=((v=f==null?void 0:f[e])==null?void 0:v[c])||u,_=a.useContext(m);if(_)return _;if(s!==void 0)return s;throw new Error(`\`${p}\` must be used within \`${r}\``)}return[l,g]}const o=()=>{const r=t.map(s=>a.createContext(s));return function(u){const c=(u==null?void 0:u[e])||r;return a.useMemo(()=>({[`__scope${e}`]:{...u,[e]:c}}),[u,c])}};return o.scopeName=e,[i,Te(o,...n)]}function Te(...e){const n=e[0];if(e.length===1)return n;const t=()=>{const i=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(r){const s=i.reduce((u,{useScope:c,scopeName:l})=>{const p=c(r)[`__scope${l}`];return{...u,...p}},{});return a.useMemo(()=>({[`__scope${n.scopeName}`]:s}),[s])}};return t.scopeName=n.scopeName,t}function G(e){const n=a.useRef(e);return a.useEffect(()=>{n.current=e}),a.useMemo(()=>(...t)=>{var i;return(i=n.current)==null?void 0:i.call(n,...t)},[])}function Ie({prop:e,defaultProp:n,onChange:t=()=>{}}){const[i,o]=Ve({defaultProp:n,onChange:t}),r=e!==void 0,s=r?e:i,u=G(t),c=a.useCallback(l=>{if(r){const p=typeof l=="function"?l(e):l;p!==e&&u(p)}else o(l)},[r,e,o,u]);return[s,c]}function Ve({defaultProp:e,onChange:n}){const t=a.useState(e),[i]=t,o=a.useRef(i),r=G(n);return a.useEffect(()=>{o.current!==i&&(r(i),o.current=i)},[i,o,r]),t}function He(e){const n=a.useRef({value:e,previous:e});return a.useMemo(()=>(n.current.value!==e&&(n.current.previous=n.current.value,n.current.value=e),n.current.previous),[e])}var Fe=globalThis!=null&&globalThis.document?a.useLayoutEffect:()=>{};function Ue(e){const[n,t]=a.useState(void 0);return Fe(()=>{if(e){t({width:e.offsetWidth,height:e.offsetHeight});const i=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const r=o[0];let s,u;if("borderBoxSize"in r){const c=r.borderBoxSize,l=Array.isArray(c)?c[0]:c;s=l.inlineSize,u=l.blockSize}else s=e.offsetWidth,u=e.offsetHeight;t({width:s,height:u})});return i.observe(e,{box:"border-box"}),()=>i.unobserve(e)}else t(void 0)},[e]),n}function Ze(e){const n=Ge(e),t=a.forwardRef((i,o)=>{const{children:r,...s}=i,u=a.Children.toArray(r),c=u.find(Ke);if(c){const l=c.props.children,g=u.map(p=>p===c?a.Children.count(l)>1?a.Children.only(null):a.isValidElement(l)?l.props.children:null:p);return d.jsx(n,{...s,ref:o,children:a.isValidElement(l)?a.cloneElement(l,void 0,g):null})}return d.jsx(n,{...s,ref:o,children:r})});return t.displayName=`${e}.Slot`,t}function Ge(e){const n=a.forwardRef((t,i)=>{const{children:o,...r}=t;if(a.isValidElement(o)){const s=Ye(o),u=Qe(r,o.props);return o.type!==a.Fragment&&(u.ref=i?Z(i,s):s),a.cloneElement(o,u)}return a.Children.count(o)>1?a.Children.only(null):null});return n.displayName=`${e}.SlotClone`,n}var Je=Symbol("radix.slottable");function Ke(e){return a.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Je}function Qe(e,n){const t={...n};for(const i in n){const o=e[i],r=n[i];/^on[A-Z]/.test(i)?o&&r?t[i]=(...u)=>{r(...u),o(...u)}:o&&(t[i]=o):i==="style"?t[i]={...o,...r}:i==="className"&&(t[i]=[o,r].filter(Boolean).join(" "))}return{...e,...t}}function Ye(e){var i,o;let n=(i=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:i.get,t=n&&"isReactWarning"in n&&n.isReactWarning;return t?e.ref:(n=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,t=n&&"isReactWarning"in n&&n.isReactWarning,t?e.props.ref:e.props.ref||e.ref)}var er=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],J=er.reduce((e,n)=>{const t=Ze(`Primitive.${n}`),i=a.forwardRef((o,r)=>{const{asChild:s,...u}=o,c=s?t:n;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),d.jsx(c,{...u,ref:r})});return i.displayName=`Primitive.${n}`,{...e,[n]:i}},{}),E="Switch",[rr]=We(E),[tr,nr]=rr(E),K=a.forwardRef((e,n)=>{const{__scopeSwitch:t,name:i,checked:o,defaultChecked:r,required:s,disabled:u,value:c="on",onCheckedChange:l,form:g,...p}=e,[f,m]=a.useState(null),_=Le(n,w=>m(w)),v=a.useRef(!1),y=f?g||!!f.closest("form"):!0,[b=!1,$]=Ie({prop:o,defaultProp:r,onChange:l});return d.jsxs(tr,{scope:t,checked:b,disabled:u,children:[d.jsx(J.button,{type:"button",role:"switch","aria-checked":b,"aria-required":s,"data-state":ee(b),"data-disabled":u?"":void 0,disabled:u,value:c,...p,ref:_,onClick:Xe(e.onClick,w=>{$(x=>!x),y&&(v.current=w.isPropagationStopped(),v.current||w.stopPropagation())})}),y&&d.jsx(or,{control:f,bubbles:!v.current,name:i,value:c,checked:b,required:s,disabled:u,form:g,style:{transform:"translateX(-100%)"}})]})});K.displayName=E;var Q="SwitchThumb",Y=a.forwardRef((e,n)=>{const{__scopeSwitch:t,...i}=e,o=nr(Q,t);return d.jsx(J.span,{"data-state":ee(o.checked),"data-disabled":o.disabled?"":void 0,...i,ref:n})});Y.displayName=Q;var or=e=>{const{control:n,checked:t,bubbles:i=!0,...o}=e,r=a.useRef(null),s=He(t),u=Ue(n);return a.useEffect(()=>{const c=r.current,l=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(l,"checked").set;if(s!==t&&p){const f=new Event("click",{bubbles:i});p.call(c,t),c.dispatchEvent(f)}},[s,t,i]),d.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:t,...o,tabIndex:-1,ref:r,style:{...e.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function ee(e){return e?"checked":"unchecked"}var ir=K,sr=Y;function ur(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var k={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
|
-
*/var
|
|
17
|
+
*/var L;function ar(){return L||(L=1,(function(e){(function(){var n={}.hasOwnProperty;function t(){for(var r="",s=0;s<arguments.length;s++){var u=arguments[s];u&&(r=o(r,i.call(this,u)))}return r}function i(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 s="";for(var u in r)n.call(r,u)&&r[u]&&(s=o(s,this&&this[u]||u));return s}function o(r,s){return s?r?r+" "+s:r+s:r}e.exports?(t.default=t,e.exports=t):window.classNames=t})()})(k)),k.exports}var cr=ar();const lr=ur(cr),W=e=>e&&"touches"in e,pr=({children:e,disabled:n,onStart:t,onDrag:i,onStop:o,bounds:r,position:s,style:u})=>{const[c,l]=h.useState(void 0),[g,p]=h.useState(void 0),[f,m]=h.useState(!1),_=b=>{if(!n){b.preventDefault();const $=W(b.nativeEvent)?b.nativeEvent.touches[0].clientX:b.nativeEvent.clientX;p($),t==null||t()}},v=h.useCallback(b=>{if(typeof g!="number")return;const w=(W(b)?b.touches[0].clientX:b.clientX)-g;if(!w)return;const x=s+w;!f&&Math.abs(x)&&m(!0);const j=x>r.right?r.right:x<r.left?r.left:x;l(j),i==null||i({x:j})},[i,l,f,g]),y=h.useCallback(()=>{p(void 0),l(void 0),m(!1),o==null||o()},[o,p]);return h.useEffect(()=>(window.addEventListener("mousemove",v),window.addEventListener("touchmove",v),()=>{window.removeEventListener("mousemove",v),window.removeEventListener("touchmove",v)}),[v]),h.useEffect(()=>(window.addEventListener("mouseup",y),window.addEventListener("touchend",y),()=>{window.removeEventListener("mouseup",y),window.removeEventListener("touchend",y)}),[y]),h.isValidElement(e)?h.cloneElement(e,{onMouseDown:_,onTouchStart:_,style:{...u,transform:`translateX(${f?c:s}px)`}}):null},T={width:void 0,height:void 0};function I(e){const{ref:n,box:t="content-box",round:i}=e,[{width:o,height:r},s]=h.useState(T),u=fr(),c=h.useRef({...T}),l=h.useRef(void 0);return l.current=e.onResize,h.useEffect(()=>{if(!n.current||typeof window>"u"||!("ResizeObserver"in window))return;const g=new ResizeObserver(([p])=>{const f=t==="border-box"?"borderBoxSize":t==="device-pixel-content-box"?"devicePixelContentBoxSize":"contentBoxSize",m=V(p,f,"inlineSize"),_=V(p,f,"blockSize");if(c.current.width!==m||c.current.height!==_){const y={width:m&&i?Math.round(m):m,height:_&&i?Math.round(_):_};c.current.width=m,c.current.height=_,l.current?l.current(y):u()&&s(y)}});return g.observe(n.current,{box:t}),()=>{g.disconnect()}},[t,n,u,i]),{width:o,height:r}}function V(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 fr(){const e=h.useRef(!1);return h.useEffect(()=>(e.current=!0,()=>{e.current=!1}),[]),h.useCallback(()=>e.current,[])}const dr=({checked:e,onChange:n})=>{const t=h.useRef(null),i=h.useRef(null),[o,r]=h.useState(void 0),[s,u]=h.useState(!1),[c,l]=h.useState(0),{height:g=0}=I({ref:i,round:!0}),{height:p=0}=I({ref:t,round:!0}),f=(p||0)-g,m=g+f,_=f/2,v=m/2,y=typeof o=="number"&&(e?o<v:o>v);return{trackRef:t,thumbRef:i,isDragging:s,bounds:{left:_,right:m},position:e?m:_,onDrag:({x})=>{r(x),Math.abs((e?m:_)-x)>2&&u(!0)},onStop:()=>{u(!1),s&&l(Date.now()),y&&(n==null||n(!e))},onChangeWithDrag:()=>{Date.now()-c>50&&(n==null||n(!e)),r(void 0)}}},hr={"purpur-toggle":"_purpur-toggle_zqs8u_1","purpur-toggle__track":"_purpur-toggle__track_zqs8u_7","purpur-toggle__checkmark-container":"_purpur-toggle__checkmark-container_zqs8u_45","purpur-toggle__thumb":"_purpur-toggle__thumb_zqs8u_60","purpur-toggle__thumb--dragging":"_purpur-toggle__thumb--dragging_zqs8u_85","purpur-toggle__checkmark":"_purpur-toggle__checkmark_zqs8u_45","purpur-toggle__label--right":"_purpur-toggle__label--right_zqs8u_110","purpur-toggle__label--left":"_purpur-toggle__label--left_zqs8u_113","purpur-toggle__container":"_purpur-toggle__container_zqs8u_116"},R=lr.bind(hr),S="purpur-toggle",re=h.forwardRef(({["data-testid"]:e,className:n,label:t,onChange:i,labelPosition:o="right",checked:r,disableDrag:s,defaultChecked:u,...c},l)=>{const[g,p]=h.useState(typeof r=="boolean"?r:!!u),f=!!(typeof r=="boolean"?r:g),{thumbRef:m,trackRef:_,isDragging:v,onChangeWithDrag:y,...b}=dr({checked:f,onChange:w=>{c.disabled||(i==null||i(w),p(w))}}),$=()=>d.jsx(Oe,{htmlFor:c.id,"data-testid":e&&`${e}-label`,disabled:c.disabled,className:R(`${S}__label`,`${S}__label--${o}`),children:d.jsx(U,{disabled:c.disabled,children:t})});return d.jsxs("div",{className:R(n,`${S}__container`),children:[t&&o==="left"&&$(),d.jsx(ir,{...c,ref:l,id:c.id,"data-testid":e,className:R(S),onCheckedChange:y,checked:f,children:d.jsxs("span",{ref:_,className:R(`${S}__track`),children:[d.jsx("span",{className:R(`${S}__checkmark-container`),children:d.jsx(H,{className:R(`${S}__checkmark`),svg:de,size:"xxs"})}),d.jsx(pr,{disabled:s,...b,children:d.jsx(sr,{ref:m,"data-testid":e&&`${e}-thumb`,className:R(`${S}__thumb`,{[`${S}__thumb--dragging`]:v})})})]})}),t&&o==="right"&&$()]})});re.displayName="Toggle";exports.Toggle=re;
|
|
18
18
|
//# sourceMappingURL=toggle.cjs.js.map
|