@purpurds/label 3.0.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 +104 -0
- package/dist/label.cjs.js +6 -0
- package/dist/label.cjs.js.map +1 -0
- package/dist/label.d.ts +10 -0
- package/dist/label.d.ts.map +1 -0
- package/dist/label.es.js +176 -0
- package/dist/label.es.js.map +1 -0
- package/dist/label.system.js +6 -0
- package/dist/label.system.js.map +1 -0
- package/dist/styles.css +1 -0
- package/package.json +61 -0
- package/readme.mdx +57 -0
- package/src/global.d.ts +4 -0
- package/src/label.module.scss +14 -0
- package/src/label.stories.tsx +76 -0
- package/src/label.test.tsx +35 -0
- package/src/label.tsx +35 -0
package/dist/LICENSE.txt
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
Name: @babel/runtime
|
|
2
|
+
Version: 7.22.15
|
|
3
|
+
License: MIT
|
|
4
|
+
Private: false
|
|
5
|
+
Description: babel's modular runtime helpers
|
|
6
|
+
Repository: https://github.com/babel/babel.git
|
|
7
|
+
Homepage: https://babel.dev/docs/en/next/babel-runtime
|
|
8
|
+
Author: The Babel Team (https://babel.dev/team)
|
|
9
|
+
License Copyright:
|
|
10
|
+
===
|
|
11
|
+
|
|
12
|
+
MIT License
|
|
13
|
+
|
|
14
|
+
Copyright (c) 2014-present Sebastian McKenzie and other contributors
|
|
15
|
+
|
|
16
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
17
|
+
a copy of this software and associated documentation files (the
|
|
18
|
+
"Software"), to deal in the Software without restriction, including
|
|
19
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
20
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
21
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
22
|
+
the following conditions:
|
|
23
|
+
|
|
24
|
+
The above copyright notice and this permission notice shall be
|
|
25
|
+
included in all copies or substantial portions of the Software.
|
|
26
|
+
|
|
27
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
28
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
29
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
30
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
31
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
32
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
33
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
Name: @radix-ui/react-compose-refs
|
|
39
|
+
Version: 1.0.1
|
|
40
|
+
License: MIT
|
|
41
|
+
Private: false
|
|
42
|
+
Repository: git+https://github.com/radix-ui/primitives.git
|
|
43
|
+
Homepage: https://radix-ui.com/primitives
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
Name: @radix-ui/react-slot
|
|
48
|
+
Version: 1.0.2
|
|
49
|
+
License: MIT
|
|
50
|
+
Private: false
|
|
51
|
+
Repository: git+https://github.com/radix-ui/primitives.git
|
|
52
|
+
Homepage: https://radix-ui.com/primitives
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
Name: @radix-ui/react-primitive
|
|
57
|
+
Version: 1.0.3
|
|
58
|
+
License: MIT
|
|
59
|
+
Private: false
|
|
60
|
+
Repository: git+https://github.com/radix-ui/primitives.git
|
|
61
|
+
Homepage: https://radix-ui.com/primitives
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
Name: @radix-ui/react-label
|
|
66
|
+
Version: 2.0.2
|
|
67
|
+
License: MIT
|
|
68
|
+
Private: false
|
|
69
|
+
Repository: git+https://github.com/radix-ui/primitives.git
|
|
70
|
+
Homepage: https://radix-ui.com/primitives
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
Name: classnames
|
|
75
|
+
Version: 2.5.1
|
|
76
|
+
License: MIT
|
|
77
|
+
Private: false
|
|
78
|
+
Description: A simple utility for conditionally joining classNames together
|
|
79
|
+
Repository: git+https://github.com/JedWatson/classnames.git
|
|
80
|
+
Author: Jed Watson
|
|
81
|
+
License Copyright:
|
|
82
|
+
===
|
|
83
|
+
|
|
84
|
+
The MIT License (MIT)
|
|
85
|
+
|
|
86
|
+
Copyright (c) 2018 Jed Watson
|
|
87
|
+
|
|
88
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
89
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
90
|
+
in the Software without restriction, including without limitation the rights
|
|
91
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
92
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
93
|
+
furnished to do so, subject to the following conditions:
|
|
94
|
+
|
|
95
|
+
The above copyright notice and this permission notice shall be included in all
|
|
96
|
+
copies or substantial portions of the Software.
|
|
97
|
+
|
|
98
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
99
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
100
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
101
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
102
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
103
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
104
|
+
SOFTWARE.
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("react/jsx-runtime"),s=require("react");require("react-dom");function u(){return u=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},u.apply(this,arguments)}function i(){return i=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},i.apply(this,arguments)}function v(e,r){typeof e=="function"?e(r):e!=null&&(e.current=r)}function y(...e){return r=>e.forEach(t=>v(t,r))}const b=s.forwardRef((e,r)=>{const{children:t,...o}=e,a=s.Children.toArray(t),n=a.find(j);if(n){const l=n.props.children,c=a.map(d=>d===n?s.Children.count(l)>1?s.Children.only(null):s.isValidElement(l)?l.props.children:null:d);return s.createElement(f,i({},o,{ref:r}),s.isValidElement(l)?s.cloneElement(l,void 0,c):null)}return s.createElement(f,i({},o,{ref:r}),t)});b.displayName="Slot";const f=s.forwardRef((e,r)=>{const{children:t,...o}=e;return s.isValidElement(t)?s.cloneElement(t,{...O(o,t.props),ref:r?y(r,t.ref):t.ref}):s.Children.count(t)>1?s.Children.only(null):null});f.displayName="SlotClone";const E=({children:e})=>s.createElement(s.Fragment,null,e);function j(e){return s.isValidElement(e)&&e.type===E}function O(e,r){const t={...r};for(const o in r){const a=e[o],n=r[o];/^on[A-Z]/.test(o)?a&&n?t[o]=(...c)=>{n(...c),a(...c)}:a&&(t[o]=a):o==="style"?t[o]={...a,...n}:o==="className"&&(t[o]=[a,n].filter(Boolean).join(" "))}return{...e,...t}}const w=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],g=w.reduce((e,r)=>{const t=s.forwardRef((o,a)=>{const{asChild:n,...l}=o,c=n?b:r;return s.useEffect(()=>{window[Symbol.for("radix-ui")]=!0},[]),s.createElement(c,i({},l,{ref:a}))});return t.displayName=`Primitive.${r}`,{...e,[r]:t}},{}),x=s.forwardRef((e,r)=>s.createElement(g.label,u({},e,{ref:r,onMouseDown:t=>{var o;(o=e.onMouseDown)===null||o===void 0||o.call(e,t),!t.defaultPrevented&&t.detail>1&&t.preventDefault()}}))),S=x;function C(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var $={exports:{}};/*!
|
|
2
|
+
Copyright (c) 2018 Jed Watson.
|
|
3
|
+
Licensed under the MIT License (MIT), see
|
|
4
|
+
http://jedwatson.github.io/classnames
|
|
5
|
+
*/(function(e){(function(){var r={}.hasOwnProperty;function t(){for(var n="",l=0;l<arguments.length;l++){var c=arguments[l];c&&(n=a(n,o(c)))}return n}function o(n){if(typeof n=="string"||typeof n=="number")return n;if(typeof n!="object")return"";if(Array.isArray(n))return t.apply(null,n);if(n.toString!==Object.prototype.toString&&!n.toString.toString().includes("[native code]"))return n.toString();var l="";for(var c in n)r.call(n,c)&&n[c]&&(l=a(l,c));return l}function a(n,l){return l?n?n+" "+l:n+l:n}e.exports?(t.default=t,e.exports=t):window.classNames=t})()})($);var N=$.exports;const P=C(N),p={"purpur-label":"_purpur-label_1jub8_1","purpur-label--disabled":"_purpur-label--disabled_1jub8_9"},m="purpur-label",_=({children:e,className:r,htmlFor:t,"data-testid":o,disabled:a,...n})=>{const l=P([r,p[m],{[p[`${m}--disabled`]]:a}]);return h.jsx(S,{className:l,"data-testid":o,htmlFor:t,...n,children:e})};exports.Label=_;
|
|
6
|
+
//# sourceMappingURL=label.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"label.cjs.js","sources":["../../../common/temp/node_modules/.pnpm/@babel+runtime@7.22.15/node_modules/@babel/runtime/helpers/esm/extends.js","../../../common/temp/node_modules/.pnpm/@babel+runtime@7.23.5/node_modules/@babel/runtime/helpers/esm/extends.js","../../../common/temp/node_modules/.pnpm/@radix-ui+react-compose-refs@1.0.1_@types+react@18.2.42_react@18.2.0/node_modules/@radix-ui/react-compose-refs/dist/index.mjs","../../../common/temp/node_modules/.pnpm/@radix-ui+react-slot@1.0.2_@types+react@18.2.42_react@18.2.0/node_modules/@radix-ui/react-slot/dist/index.mjs","../../../common/temp/node_modules/.pnpm/@radix-ui+react-primitive@1.0.3_@types+react-dom@18.2.17_@types+react@18.2.42_react-dom@18.2.0_react@18.2.0/node_modules/@radix-ui/react-primitive/dist/index.mjs","../../../common/temp/node_modules/.pnpm/@radix-ui+react-label@2.0.2_@types+react-dom@18.2.17_@types+react@18.2.42_react-dom@18.2.0_react@18.2.0/node_modules/@radix-ui/react-label/dist/index.mjs","../../../common/temp/node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.js","../src/label.tsx"],"sourcesContent":["export default function _extends() {\n _extends = Object.assign ? Object.assign.bind() : function (target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i];\n for (var key in source) {\n if (Object.prototype.hasOwnProperty.call(source, key)) {\n target[key] = source[key];\n }\n }\n }\n return target;\n };\n return _extends.apply(this, arguments);\n}","export default function _extends() {\n _extends = Object.assign ? Object.assign.bind() : function (target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i];\n for (var key in source) {\n if (Object.prototype.hasOwnProperty.call(source, key)) {\n target[key] = source[key];\n }\n }\n }\n return target;\n };\n return _extends.apply(this, arguments);\n}","import {useCallback as $3vqmr$useCallback} from \"react\";\n\n\n/**\n * Set a given ref to a given value\n * This utility takes care of different types of refs: callback refs and RefObject(s)\n */ function $6ed0406888f73fc4$var$setRef(ref, value) {\n if (typeof ref === 'function') ref(value);\n else if (ref !== null && ref !== undefined) ref.current = value;\n}\n/**\n * A utility to compose multiple refs together\n * Accepts callback refs and RefObject(s)\n */ function $6ed0406888f73fc4$export$43e446d32b3d21af(...refs) {\n return (node)=>refs.forEach((ref)=>$6ed0406888f73fc4$var$setRef(ref, node)\n )\n ;\n}\n/**\n * A custom hook that composes multiple refs\n * Accepts callback refs and RefObject(s)\n */ function $6ed0406888f73fc4$export$c7b2cbe3552a0d05(...refs) {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n return $3vqmr$useCallback($6ed0406888f73fc4$export$43e446d32b3d21af(...refs), refs);\n}\n\n\n\n\nexport {$6ed0406888f73fc4$export$43e446d32b3d21af as composeRefs, $6ed0406888f73fc4$export$c7b2cbe3552a0d05 as useComposedRefs};\n//# sourceMappingURL=index.mjs.map\n","import $9IrjX$babelruntimehelpersesmextends from \"@babel/runtime/helpers/esm/extends\";\nimport {forwardRef as $9IrjX$forwardRef, Children as $9IrjX$Children, isValidElement as $9IrjX$isValidElement, createElement as $9IrjX$createElement, cloneElement as $9IrjX$cloneElement, Fragment as $9IrjX$Fragment} from \"react\";\nimport {composeRefs as $9IrjX$composeRefs} from \"@radix-ui/react-compose-refs\";\n\n\n\n\n/* -------------------------------------------------------------------------------------------------\n * Slot\n * -----------------------------------------------------------------------------------------------*/ const $5e63c961fc1ce211$export$8c6ed5c666ac1360 = /*#__PURE__*/ $9IrjX$forwardRef((props, forwardedRef)=>{\n const { children: children , ...slotProps } = props;\n const childrenArray = $9IrjX$Children.toArray(children);\n const slottable = childrenArray.find($5e63c961fc1ce211$var$isSlottable);\n if (slottable) {\n // the new element to render is the one passed as a child of `Slottable`\n const newElement = slottable.props.children;\n const newChildren = childrenArray.map((child)=>{\n if (child === slottable) {\n // because the new element will be the one rendered, we are only interested\n // in grabbing its children (`newElement.props.children`)\n if ($9IrjX$Children.count(newElement) > 1) return $9IrjX$Children.only(null);\n return /*#__PURE__*/ $9IrjX$isValidElement(newElement) ? newElement.props.children : null;\n } else return child;\n });\n return /*#__PURE__*/ $9IrjX$createElement($5e63c961fc1ce211$var$SlotClone, $9IrjX$babelruntimehelpersesmextends({}, slotProps, {\n ref: forwardedRef\n }), /*#__PURE__*/ $9IrjX$isValidElement(newElement) ? /*#__PURE__*/ $9IrjX$cloneElement(newElement, undefined, newChildren) : null);\n }\n return /*#__PURE__*/ $9IrjX$createElement($5e63c961fc1ce211$var$SlotClone, $9IrjX$babelruntimehelpersesmextends({}, slotProps, {\n ref: forwardedRef\n }), children);\n});\n$5e63c961fc1ce211$export$8c6ed5c666ac1360.displayName = 'Slot';\n/* -------------------------------------------------------------------------------------------------\n * SlotClone\n * -----------------------------------------------------------------------------------------------*/ const $5e63c961fc1ce211$var$SlotClone = /*#__PURE__*/ $9IrjX$forwardRef((props, forwardedRef)=>{\n const { children: children , ...slotProps } = props;\n if (/*#__PURE__*/ $9IrjX$isValidElement(children)) return /*#__PURE__*/ $9IrjX$cloneElement(children, {\n ...$5e63c961fc1ce211$var$mergeProps(slotProps, children.props),\n ref: forwardedRef ? $9IrjX$composeRefs(forwardedRef, children.ref) : children.ref\n });\n return $9IrjX$Children.count(children) > 1 ? $9IrjX$Children.only(null) : null;\n});\n$5e63c961fc1ce211$var$SlotClone.displayName = 'SlotClone';\n/* -------------------------------------------------------------------------------------------------\n * Slottable\n * -----------------------------------------------------------------------------------------------*/ const $5e63c961fc1ce211$export$d9f1ccf0bdb05d45 = ({ children: children })=>{\n return /*#__PURE__*/ $9IrjX$createElement($9IrjX$Fragment, null, children);\n};\n/* ---------------------------------------------------------------------------------------------- */ function $5e63c961fc1ce211$var$isSlottable(child) {\n return /*#__PURE__*/ $9IrjX$isValidElement(child) && child.type === $5e63c961fc1ce211$export$d9f1ccf0bdb05d45;\n}\nfunction $5e63c961fc1ce211$var$mergeProps(slotProps, childProps) {\n // all child props should override\n const overrideProps = {\n ...childProps\n };\n for(const propName in childProps){\n const slotPropValue = slotProps[propName];\n const childPropValue = childProps[propName];\n const isHandler = /^on[A-Z]/.test(propName);\n if (isHandler) {\n // if the handler exists on both, we compose them\n if (slotPropValue && childPropValue) overrideProps[propName] = (...args)=>{\n childPropValue(...args);\n slotPropValue(...args);\n };\n else if (slotPropValue) overrideProps[propName] = slotPropValue;\n } else if (propName === 'style') overrideProps[propName] = {\n ...slotPropValue,\n ...childPropValue\n };\n else if (propName === 'className') overrideProps[propName] = [\n slotPropValue,\n childPropValue\n ].filter(Boolean).join(' ');\n }\n return {\n ...slotProps,\n ...overrideProps\n };\n}\nconst $5e63c961fc1ce211$export$be92b6f5f03c0fe9 = $5e63c961fc1ce211$export$8c6ed5c666ac1360;\n\n\n\n\nexport {$5e63c961fc1ce211$export$8c6ed5c666ac1360 as Slot, $5e63c961fc1ce211$export$d9f1ccf0bdb05d45 as Slottable, $5e63c961fc1ce211$export$be92b6f5f03c0fe9 as Root};\n//# sourceMappingURL=index.mjs.map\n","import $4q5Fq$babelruntimehelpersesmextends from \"@babel/runtime/helpers/esm/extends\";\nimport {forwardRef as $4q5Fq$forwardRef, useEffect as $4q5Fq$useEffect, createElement as $4q5Fq$createElement} from \"react\";\nimport {flushSync as $4q5Fq$flushSync} from \"react-dom\";\nimport {Slot as $4q5Fq$Slot} from \"@radix-ui/react-slot\";\n\n\n\n\n\nconst $8927f6f2acc4f386$var$NODES = [\n 'a',\n 'button',\n 'div',\n 'form',\n 'h2',\n 'h3',\n 'img',\n 'input',\n 'label',\n 'li',\n 'nav',\n 'ol',\n 'p',\n 'span',\n 'svg',\n 'ul'\n]; // Temporary while we await merge of this fix:\n// https://github.com/DefinitelyTyped/DefinitelyTyped/pull/55396\n// prettier-ignore\n/* -------------------------------------------------------------------------------------------------\n * Primitive\n * -----------------------------------------------------------------------------------------------*/ const $8927f6f2acc4f386$export$250ffa63cdc0d034 = $8927f6f2acc4f386$var$NODES.reduce((primitive, node)=>{\n const Node = /*#__PURE__*/ $4q5Fq$forwardRef((props, forwardedRef)=>{\n const { asChild: asChild , ...primitiveProps } = props;\n const Comp = asChild ? $4q5Fq$Slot : node;\n $4q5Fq$useEffect(()=>{\n window[Symbol.for('radix-ui')] = true;\n }, []);\n return /*#__PURE__*/ $4q5Fq$createElement(Comp, $4q5Fq$babelruntimehelpersesmextends({}, primitiveProps, {\n ref: forwardedRef\n }));\n });\n Node.displayName = `Primitive.${node}`;\n return {\n ...primitive,\n [node]: Node\n };\n}, {});\n/* -------------------------------------------------------------------------------------------------\n * Utils\n * -----------------------------------------------------------------------------------------------*/ /**\n * Flush custom event dispatch\n * https://github.com/radix-ui/primitives/pull/1378\n *\n * React batches *all* event handlers since version 18, this introduces certain considerations when using custom event types.\n *\n * Internally, React prioritises events in the following order:\n * - discrete\n * - continuous\n * - default\n *\n * https://github.com/facebook/react/blob/a8a4742f1c54493df00da648a3f9d26e3db9c8b5/packages/react-dom/src/events/ReactDOMEventListener.js#L294-L350\n *\n * `discrete` is an important distinction as updates within these events are applied immediately.\n * React however, is not able to infer the priority of custom event types due to how they are detected internally.\n * Because of this, it's possible for updates from custom events to be unexpectedly batched when\n * dispatched by another `discrete` event.\n *\n * In order to ensure that updates from custom events are applied predictably, we need to manually flush the batch.\n * This utility should be used when dispatching a custom event from within another `discrete` event, this utility\n * is not nessesary when dispatching known event types, or if dispatching a custom type inside a non-discrete event.\n * For example:\n *\n * dispatching a known click 👎\n * target.dispatchEvent(new Event(‘click’))\n *\n * dispatching a custom type within a non-discrete event 👎\n * onScroll={(event) => event.target.dispatchEvent(new CustomEvent(‘customType’))}\n *\n * dispatching a custom type within a `discrete` event 👍\n * onPointerDown={(event) => dispatchDiscreteCustomEvent(event.target, new CustomEvent(‘customType’))}\n *\n * Note: though React classifies `focus`, `focusin` and `focusout` events as `discrete`, it's not recommended to use\n * this utility with them. This is because it's possible for those handlers to be called implicitly during render\n * e.g. when focus is within a component as it is unmounted, or when managing focus on mount.\n */ function $8927f6f2acc4f386$export$6d1a0317bde7de7f(target, event) {\n if (target) $4q5Fq$flushSync(()=>target.dispatchEvent(event)\n );\n}\n/* -----------------------------------------------------------------------------------------------*/ const $8927f6f2acc4f386$export$be92b6f5f03c0fe9 = $8927f6f2acc4f386$export$250ffa63cdc0d034;\n\n\n\n\nexport {$8927f6f2acc4f386$export$250ffa63cdc0d034 as Primitive, $8927f6f2acc4f386$export$be92b6f5f03c0fe9 as Root, $8927f6f2acc4f386$export$6d1a0317bde7de7f as dispatchDiscreteCustomEvent};\n//# sourceMappingURL=index.mjs.map\n","import $7V4JZ$babelruntimehelpersesmextends from \"@babel/runtime/helpers/esm/extends\";\nimport {forwardRef as $7V4JZ$forwardRef, createElement as $7V4JZ$createElement} from \"react\";\nimport {Primitive as $7V4JZ$Primitive} from \"@radix-ui/react-primitive\";\n\n\n\n\n/* -------------------------------------------------------------------------------------------------\n * Label\n * -----------------------------------------------------------------------------------------------*/ const $b73a6c6685e72184$var$NAME = 'Label';\nconst $b73a6c6685e72184$export$b04be29aa201d4f5 = /*#__PURE__*/ $7V4JZ$forwardRef((props, forwardedRef)=>{\n return /*#__PURE__*/ $7V4JZ$createElement($7V4JZ$Primitive.label, $7V4JZ$babelruntimehelpersesmextends({}, props, {\n ref: forwardedRef,\n onMouseDown: (event)=>{\n var _props$onMouseDown;\n (_props$onMouseDown = props.onMouseDown) === null || _props$onMouseDown === void 0 || _props$onMouseDown.call(props, event); // prevent text selection when double clicking label\n if (!event.defaultPrevented && event.detail > 1) event.preventDefault();\n }\n }));\n});\n/*#__PURE__*/ Object.assign($b73a6c6685e72184$export$b04be29aa201d4f5, {\n displayName: $b73a6c6685e72184$var$NAME\n});\n/* -----------------------------------------------------------------------------------------------*/ const $b73a6c6685e72184$export$be92b6f5f03c0fe9 = $b73a6c6685e72184$export$b04be29aa201d4f5;\n\n\n\n\nexport {$b73a6c6685e72184$export$b04be29aa201d4f5 as Label, $b73a6c6685e72184$export$be92b6f5f03c0fe9 as Root};\n//# sourceMappingURL=index.mjs.map\n","/*!\n\tCopyright (c) 2018 Jed Watson.\n\tLicensed under the MIT License (MIT), see\n\thttp://jedwatson.github.io/classnames\n*/\n/* global define */\n\n(function () {\n\t'use strict';\n\n\tvar hasOwn = {}.hasOwnProperty;\n\n\tfunction classNames () {\n\t\tvar classes = '';\n\n\t\tfor (var i = 0; i < arguments.length; i++) {\n\t\t\tvar arg = arguments[i];\n\t\t\tif (arg) {\n\t\t\t\tclasses = appendClass(classes, parseValue(arg));\n\t\t\t}\n\t\t}\n\n\t\treturn classes;\n\t}\n\n\tfunction parseValue (arg) {\n\t\tif (typeof arg === 'string' || typeof arg === 'number') {\n\t\t\treturn arg;\n\t\t}\n\n\t\tif (typeof arg !== 'object') {\n\t\t\treturn '';\n\t\t}\n\n\t\tif (Array.isArray(arg)) {\n\t\t\treturn classNames.apply(null, arg);\n\t\t}\n\n\t\tif (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes('[native code]')) {\n\t\t\treturn arg.toString();\n\t\t}\n\n\t\tvar classes = '';\n\n\t\tfor (var key in arg) {\n\t\t\tif (hasOwn.call(arg, key) && arg[key]) {\n\t\t\t\tclasses = appendClass(classes, key);\n\t\t\t}\n\t\t}\n\n\t\treturn classes;\n\t}\n\n\tfunction appendClass (value, newClass) {\n\t\tif (!newClass) {\n\t\t\treturn value;\n\t\t}\n\t\n\t\tif (value) {\n\t\t\treturn value + ' ' + newClass;\n\t\t}\n\t\n\t\treturn value + newClass;\n\t}\n\n\tif (typeof module !== 'undefined' && module.exports) {\n\t\tclassNames.default = classNames;\n\t\tmodule.exports = classNames;\n\t} else if (typeof define === 'function' && typeof define.amd === 'object' && define.amd) {\n\t\t// register as 'classnames', consistent with npm package name\n\t\tdefine('classnames', [], function () {\n\t\t\treturn classNames;\n\t\t});\n\t} else {\n\t\twindow.classNames = classNames;\n\t}\n}());\n","import React, { ReactNode } from \"react\";\nimport * as RadixLabel from \"@radix-ui/react-label\";\nimport c from \"classnames\";\n\nimport styles from \"./label.module.scss\";\n\nconst rootClassName = \"purpur-label\";\n\nexport type LabelProps = {\n \"data-testid\"?: string;\n children: ReactNode;\n className?: string;\n htmlFor: string;\n disabled?: boolean;\n};\nexport const Label = ({\n children,\n className,\n htmlFor,\n \"data-testid\": dataTestId,\n disabled,\n ...props\n}: LabelProps) => {\n const classes = c([\n className,\n styles[rootClassName],\n { [styles[`${rootClassName}--disabled`]]: disabled },\n ]);\n\n return (\n <RadixLabel.Root className={classes} data-testid={dataTestId} htmlFor={htmlFor} {...props}>\n {children}\n </RadixLabel.Root>\n );\n};\n"],"names":["_extends","target","i","source","key","$6ed0406888f73fc4$var$setRef","ref","value","$6ed0406888f73fc4$export$43e446d32b3d21af","refs","node","$5e63c961fc1ce211$export$8c6ed5c666ac1360","$9IrjX$forwardRef","props","forwardedRef","children","slotProps","childrenArray","$9IrjX$Children","slottable","$5e63c961fc1ce211$var$isSlottable","newElement","newChildren","child","$9IrjX$isValidElement","$9IrjX$createElement","$5e63c961fc1ce211$var$SlotClone","$9IrjX$babelruntimehelpersesmextends","$9IrjX$cloneElement","$5e63c961fc1ce211$var$mergeProps","$9IrjX$composeRefs","$5e63c961fc1ce211$export$d9f1ccf0bdb05d45","$9IrjX$Fragment","childProps","overrideProps","propName","slotPropValue","childPropValue","args","$8927f6f2acc4f386$var$NODES","$8927f6f2acc4f386$export$250ffa63cdc0d034","primitive","Node","$4q5Fq$forwardRef","asChild","primitiveProps","Comp","$4q5Fq$Slot","$4q5Fq$useEffect","$4q5Fq$createElement","$4q5Fq$babelruntimehelpersesmextends","$b73a6c6685e72184$export$b04be29aa201d4f5","$7V4JZ$forwardRef","$7V4JZ$createElement","$7V4JZ$Primitive","$7V4JZ$babelruntimehelpersesmextends","event","_props$onMouseDown","$b73a6c6685e72184$export$be92b6f5f03c0fe9","hasOwn","classNames","classes","arg","appendClass","parseValue","newClass","module","rootClassName","Label","className","htmlFor","dataTestId","disabled","c","styles","jsx","RadixLabel.Root"],"mappings":"6JAAe,SAASA,GAAW,CACjCA,OAAAA,EAAW,OAAO,OAAS,OAAO,OAAO,KAAI,EAAK,SAAUC,EAAQ,CAClE,QAASC,EAAI,EAAGA,EAAI,UAAU,OAAQA,IAAK,CACzC,IAAIC,EAAS,UAAUD,CAAC,EACxB,QAASE,KAAOD,EACV,OAAO,UAAU,eAAe,KAAKA,EAAQC,CAAG,IAClDH,EAAOG,CAAG,EAAID,EAAOC,CAAG,EAG7B,CACD,OAAOH,CACX,EACSD,EAAS,MAAM,KAAM,SAAS,CACvC,CCbe,SAASA,GAA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,GAAQ,SAC7C,OAAOA,EAGR,GAAI,OAAOA,GAAQ,SAClB,MAAO,GAGR,GAAI,MAAM,QAAQA,CAAG,EACpB,OAAOF,EAAW,MAAM,KAAME,CAAG,EAGlC,GAAIA,EAAI,WAAa,OAAO,UAAU,UAAY,CAACA,EAAI,SAAS,SAAQ,EAAG,SAAS,eAAe,EAClG,OAAOA,EAAI,WAGZ,IAAID,EAAU,GAEd,QAASzD,KAAO0D,EACXH,EAAO,KAAKG,EAAK1D,CAAG,GAAK0D,EAAI1D,CAAG,IACnCyD,EAAUE,EAAYF,EAASzD,CAAG,GAIpC,OAAOyD,CACP,CAED,SAASE,EAAaxD,EAAO0D,EAAU,CACtC,OAAKA,EAID1D,EACIA,EAAQ,IAAM0D,EAGf1D,EAAQ0D,EAPP1D,CAQR,CAEoC2D,EAAO,SAC3CN,EAAW,QAAUA,EACrBM,EAAA,QAAiBN,GAOjB,OAAO,WAAaA,CAEtB,6ICtEMO,EAAgB,eASTC,EAAQ,CAAC,CACpB,SAAArD,EACA,UAAAsD,EACA,QAAAC,EACA,cAAeC,EACf,SAAAC,EACA,GAAG3D,CACL,IAAkB,CAChB,MAAMgD,EAAUY,EAAE,CAChBJ,EACAK,EAAOP,CAAa,EACpB,CAAE,CAACO,EAAO,GAAGP,CAAa,YAAY,CAAC,EAAGK,CAAS,CAAA,CACpD,EAGC,OAAAG,MAACC,EAAA,CAAgB,UAAWf,EAAS,cAAaU,EAAY,QAAAD,EAAmB,GAAGzD,EACjF,SAAAE,CACH,CAAA,CAEJ","x_google_ignoreList":[0,1,2,3,4,5,6]}
|
package/dist/label.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React, { ReactNode } from "react";
|
|
2
|
+
export type LabelProps = {
|
|
3
|
+
"data-testid"?: string;
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
className?: string;
|
|
6
|
+
htmlFor: string;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
};
|
|
9
|
+
export declare const Label: ({ children, className, htmlFor, "data-testid": dataTestId, disabled, ...props }: LabelProps) => React.JSX.Element;
|
|
10
|
+
//# sourceMappingURL=label.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"label.d.ts","sourceRoot":"","sources":["../src/label.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAQzC,MAAM,MAAM,UAAU,GAAG;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,SAAS,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AACF,eAAO,MAAM,KAAK,oFAOf,UAAU,sBAYZ,CAAC"}
|
package/dist/label.es.js
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { jsx as O } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as p, Children as a, isValidElement as u, createElement as i, cloneElement as h, Fragment as x, useEffect as g } from "react";
|
|
3
|
+
import "react-dom";
|
|
4
|
+
function d() {
|
|
5
|
+
return d = Object.assign ? Object.assign.bind() : function(e) {
|
|
6
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
7
|
+
var t = arguments[r];
|
|
8
|
+
for (var o in t)
|
|
9
|
+
Object.prototype.hasOwnProperty.call(t, o) && (e[o] = t[o]);
|
|
10
|
+
}
|
|
11
|
+
return e;
|
|
12
|
+
}, d.apply(this, arguments);
|
|
13
|
+
}
|
|
14
|
+
function f() {
|
|
15
|
+
return f = Object.assign ? Object.assign.bind() : function(e) {
|
|
16
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
17
|
+
var t = arguments[r];
|
|
18
|
+
for (var o in t)
|
|
19
|
+
Object.prototype.hasOwnProperty.call(t, o) && (e[o] = t[o]);
|
|
20
|
+
}
|
|
21
|
+
return e;
|
|
22
|
+
}, f.apply(this, arguments);
|
|
23
|
+
}
|
|
24
|
+
function w(e, r) {
|
|
25
|
+
typeof e == "function" ? e(r) : e != null && (e.current = r);
|
|
26
|
+
}
|
|
27
|
+
function N(...e) {
|
|
28
|
+
return (r) => e.forEach(
|
|
29
|
+
(t) => w(t, r)
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
const y = /* @__PURE__ */ p((e, r) => {
|
|
33
|
+
const { children: t, ...o } = e, l = a.toArray(t), n = l.find(_);
|
|
34
|
+
if (n) {
|
|
35
|
+
const s = n.props.children, c = l.map((m) => m === n ? a.count(s) > 1 ? a.only(null) : /* @__PURE__ */ u(s) ? s.props.children : null : m);
|
|
36
|
+
return /* @__PURE__ */ i(b, f({}, o, {
|
|
37
|
+
ref: r
|
|
38
|
+
}), /* @__PURE__ */ u(s) ? /* @__PURE__ */ h(s, void 0, c) : null);
|
|
39
|
+
}
|
|
40
|
+
return /* @__PURE__ */ i(b, f({}, o, {
|
|
41
|
+
ref: r
|
|
42
|
+
}), t);
|
|
43
|
+
});
|
|
44
|
+
y.displayName = "Slot";
|
|
45
|
+
const b = /* @__PURE__ */ p((e, r) => {
|
|
46
|
+
const { children: t, ...o } = e;
|
|
47
|
+
return /* @__PURE__ */ u(t) ? /* @__PURE__ */ h(t, {
|
|
48
|
+
...P(o, t.props),
|
|
49
|
+
ref: r ? N(r, t.ref) : t.ref
|
|
50
|
+
}) : a.count(t) > 1 ? a.only(null) : null;
|
|
51
|
+
});
|
|
52
|
+
b.displayName = "SlotClone";
|
|
53
|
+
const S = ({ children: e }) => /* @__PURE__ */ i(x, null, e);
|
|
54
|
+
function _(e) {
|
|
55
|
+
return /* @__PURE__ */ u(e) && e.type === S;
|
|
56
|
+
}
|
|
57
|
+
function P(e, r) {
|
|
58
|
+
const t = {
|
|
59
|
+
...r
|
|
60
|
+
};
|
|
61
|
+
for (const o in r) {
|
|
62
|
+
const l = e[o], n = r[o];
|
|
63
|
+
/^on[A-Z]/.test(o) ? l && n ? t[o] = (...c) => {
|
|
64
|
+
n(...c), l(...c);
|
|
65
|
+
} : l && (t[o] = l) : o === "style" ? t[o] = {
|
|
66
|
+
...l,
|
|
67
|
+
...n
|
|
68
|
+
} : o === "className" && (t[o] = [
|
|
69
|
+
l,
|
|
70
|
+
n
|
|
71
|
+
].filter(Boolean).join(" "));
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
...e,
|
|
75
|
+
...t
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
const E = [
|
|
79
|
+
"a",
|
|
80
|
+
"button",
|
|
81
|
+
"div",
|
|
82
|
+
"form",
|
|
83
|
+
"h2",
|
|
84
|
+
"h3",
|
|
85
|
+
"img",
|
|
86
|
+
"input",
|
|
87
|
+
"label",
|
|
88
|
+
"li",
|
|
89
|
+
"nav",
|
|
90
|
+
"ol",
|
|
91
|
+
"p",
|
|
92
|
+
"span",
|
|
93
|
+
"svg",
|
|
94
|
+
"ul"
|
|
95
|
+
], C = E.reduce((e, r) => {
|
|
96
|
+
const t = /* @__PURE__ */ p((o, l) => {
|
|
97
|
+
const { asChild: n, ...s } = o, c = n ? y : r;
|
|
98
|
+
return g(() => {
|
|
99
|
+
window[Symbol.for("radix-ui")] = !0;
|
|
100
|
+
}, []), /* @__PURE__ */ i(c, f({}, s, {
|
|
101
|
+
ref: l
|
|
102
|
+
}));
|
|
103
|
+
});
|
|
104
|
+
return t.displayName = `Primitive.${r}`, {
|
|
105
|
+
...e,
|
|
106
|
+
[r]: t
|
|
107
|
+
};
|
|
108
|
+
}, {}), D = /* @__PURE__ */ p((e, r) => /* @__PURE__ */ i(C.label, d({}, e, {
|
|
109
|
+
ref: r,
|
|
110
|
+
onMouseDown: (t) => {
|
|
111
|
+
var o;
|
|
112
|
+
(o = e.onMouseDown) === null || o === void 0 || o.call(e, t), !t.defaultPrevented && t.detail > 1 && t.preventDefault();
|
|
113
|
+
}
|
|
114
|
+
}))), A = D;
|
|
115
|
+
function M(e) {
|
|
116
|
+
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
117
|
+
}
|
|
118
|
+
var j = { exports: {} };
|
|
119
|
+
/*!
|
|
120
|
+
Copyright (c) 2018 Jed Watson.
|
|
121
|
+
Licensed under the MIT License (MIT), see
|
|
122
|
+
http://jedwatson.github.io/classnames
|
|
123
|
+
*/
|
|
124
|
+
(function(e) {
|
|
125
|
+
(function() {
|
|
126
|
+
var r = {}.hasOwnProperty;
|
|
127
|
+
function t() {
|
|
128
|
+
for (var n = "", s = 0; s < arguments.length; s++) {
|
|
129
|
+
var c = arguments[s];
|
|
130
|
+
c && (n = l(n, o(c)));
|
|
131
|
+
}
|
|
132
|
+
return n;
|
|
133
|
+
}
|
|
134
|
+
function o(n) {
|
|
135
|
+
if (typeof n == "string" || typeof n == "number")
|
|
136
|
+
return n;
|
|
137
|
+
if (typeof n != "object")
|
|
138
|
+
return "";
|
|
139
|
+
if (Array.isArray(n))
|
|
140
|
+
return t.apply(null, n);
|
|
141
|
+
if (n.toString !== Object.prototype.toString && !n.toString.toString().includes("[native code]"))
|
|
142
|
+
return n.toString();
|
|
143
|
+
var s = "";
|
|
144
|
+
for (var c in n)
|
|
145
|
+
r.call(n, c) && n[c] && (s = l(s, c));
|
|
146
|
+
return s;
|
|
147
|
+
}
|
|
148
|
+
function l(n, s) {
|
|
149
|
+
return s ? n ? n + " " + s : n + s : n;
|
|
150
|
+
}
|
|
151
|
+
e.exports ? (t.default = t, e.exports = t) : window.classNames = t;
|
|
152
|
+
})();
|
|
153
|
+
})(j);
|
|
154
|
+
var V = j.exports;
|
|
155
|
+
const F = /* @__PURE__ */ M(V), $ = {
|
|
156
|
+
"purpur-label": "_purpur-label_1jub8_1",
|
|
157
|
+
"purpur-label--disabled": "_purpur-label--disabled_1jub8_9"
|
|
158
|
+
}, v = "purpur-label", Z = ({
|
|
159
|
+
children: e,
|
|
160
|
+
className: r,
|
|
161
|
+
htmlFor: t,
|
|
162
|
+
"data-testid": o,
|
|
163
|
+
disabled: l,
|
|
164
|
+
...n
|
|
165
|
+
}) => {
|
|
166
|
+
const s = F([
|
|
167
|
+
r,
|
|
168
|
+
$[v],
|
|
169
|
+
{ [$[`${v}--disabled`]]: l }
|
|
170
|
+
]);
|
|
171
|
+
return /* @__PURE__ */ O(A, { className: s, "data-testid": o, htmlFor: t, ...n, children: e });
|
|
172
|
+
};
|
|
173
|
+
export {
|
|
174
|
+
Z as Label
|
|
175
|
+
};
|
|
176
|
+
//# sourceMappingURL=label.es.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"label.es.js","sources":["../../../common/temp/node_modules/.pnpm/@babel+runtime@7.22.15/node_modules/@babel/runtime/helpers/esm/extends.js","../../../common/temp/node_modules/.pnpm/@babel+runtime@7.23.5/node_modules/@babel/runtime/helpers/esm/extends.js","../../../common/temp/node_modules/.pnpm/@radix-ui+react-compose-refs@1.0.1_@types+react@18.2.42_react@18.2.0/node_modules/@radix-ui/react-compose-refs/dist/index.mjs","../../../common/temp/node_modules/.pnpm/@radix-ui+react-slot@1.0.2_@types+react@18.2.42_react@18.2.0/node_modules/@radix-ui/react-slot/dist/index.mjs","../../../common/temp/node_modules/.pnpm/@radix-ui+react-primitive@1.0.3_@types+react-dom@18.2.17_@types+react@18.2.42_react-dom@18.2.0_react@18.2.0/node_modules/@radix-ui/react-primitive/dist/index.mjs","../../../common/temp/node_modules/.pnpm/@radix-ui+react-label@2.0.2_@types+react-dom@18.2.17_@types+react@18.2.42_react-dom@18.2.0_react@18.2.0/node_modules/@radix-ui/react-label/dist/index.mjs","../../../common/temp/node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.js","../src/label.tsx"],"sourcesContent":["export default function _extends() {\n _extends = Object.assign ? Object.assign.bind() : function (target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i];\n for (var key in source) {\n if (Object.prototype.hasOwnProperty.call(source, key)) {\n target[key] = source[key];\n }\n }\n }\n return target;\n };\n return _extends.apply(this, arguments);\n}","export default function _extends() {\n _extends = Object.assign ? Object.assign.bind() : function (target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i];\n for (var key in source) {\n if (Object.prototype.hasOwnProperty.call(source, key)) {\n target[key] = source[key];\n }\n }\n }\n return target;\n };\n return _extends.apply(this, arguments);\n}","import {useCallback as $3vqmr$useCallback} from \"react\";\n\n\n/**\n * Set a given ref to a given value\n * This utility takes care of different types of refs: callback refs and RefObject(s)\n */ function $6ed0406888f73fc4$var$setRef(ref, value) {\n if (typeof ref === 'function') ref(value);\n else if (ref !== null && ref !== undefined) ref.current = value;\n}\n/**\n * A utility to compose multiple refs together\n * Accepts callback refs and RefObject(s)\n */ function $6ed0406888f73fc4$export$43e446d32b3d21af(...refs) {\n return (node)=>refs.forEach((ref)=>$6ed0406888f73fc4$var$setRef(ref, node)\n )\n ;\n}\n/**\n * A custom hook that composes multiple refs\n * Accepts callback refs and RefObject(s)\n */ function $6ed0406888f73fc4$export$c7b2cbe3552a0d05(...refs) {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n return $3vqmr$useCallback($6ed0406888f73fc4$export$43e446d32b3d21af(...refs), refs);\n}\n\n\n\n\nexport {$6ed0406888f73fc4$export$43e446d32b3d21af as composeRefs, $6ed0406888f73fc4$export$c7b2cbe3552a0d05 as useComposedRefs};\n//# sourceMappingURL=index.mjs.map\n","import $9IrjX$babelruntimehelpersesmextends from \"@babel/runtime/helpers/esm/extends\";\nimport {forwardRef as $9IrjX$forwardRef, Children as $9IrjX$Children, isValidElement as $9IrjX$isValidElement, createElement as $9IrjX$createElement, cloneElement as $9IrjX$cloneElement, Fragment as $9IrjX$Fragment} from \"react\";\nimport {composeRefs as $9IrjX$composeRefs} from \"@radix-ui/react-compose-refs\";\n\n\n\n\n/* -------------------------------------------------------------------------------------------------\n * Slot\n * -----------------------------------------------------------------------------------------------*/ const $5e63c961fc1ce211$export$8c6ed5c666ac1360 = /*#__PURE__*/ $9IrjX$forwardRef((props, forwardedRef)=>{\n const { children: children , ...slotProps } = props;\n const childrenArray = $9IrjX$Children.toArray(children);\n const slottable = childrenArray.find($5e63c961fc1ce211$var$isSlottable);\n if (slottable) {\n // the new element to render is the one passed as a child of `Slottable`\n const newElement = slottable.props.children;\n const newChildren = childrenArray.map((child)=>{\n if (child === slottable) {\n // because the new element will be the one rendered, we are only interested\n // in grabbing its children (`newElement.props.children`)\n if ($9IrjX$Children.count(newElement) > 1) return $9IrjX$Children.only(null);\n return /*#__PURE__*/ $9IrjX$isValidElement(newElement) ? newElement.props.children : null;\n } else return child;\n });\n return /*#__PURE__*/ $9IrjX$createElement($5e63c961fc1ce211$var$SlotClone, $9IrjX$babelruntimehelpersesmextends({}, slotProps, {\n ref: forwardedRef\n }), /*#__PURE__*/ $9IrjX$isValidElement(newElement) ? /*#__PURE__*/ $9IrjX$cloneElement(newElement, undefined, newChildren) : null);\n }\n return /*#__PURE__*/ $9IrjX$createElement($5e63c961fc1ce211$var$SlotClone, $9IrjX$babelruntimehelpersesmextends({}, slotProps, {\n ref: forwardedRef\n }), children);\n});\n$5e63c961fc1ce211$export$8c6ed5c666ac1360.displayName = 'Slot';\n/* -------------------------------------------------------------------------------------------------\n * SlotClone\n * -----------------------------------------------------------------------------------------------*/ const $5e63c961fc1ce211$var$SlotClone = /*#__PURE__*/ $9IrjX$forwardRef((props, forwardedRef)=>{\n const { children: children , ...slotProps } = props;\n if (/*#__PURE__*/ $9IrjX$isValidElement(children)) return /*#__PURE__*/ $9IrjX$cloneElement(children, {\n ...$5e63c961fc1ce211$var$mergeProps(slotProps, children.props),\n ref: forwardedRef ? $9IrjX$composeRefs(forwardedRef, children.ref) : children.ref\n });\n return $9IrjX$Children.count(children) > 1 ? $9IrjX$Children.only(null) : null;\n});\n$5e63c961fc1ce211$var$SlotClone.displayName = 'SlotClone';\n/* -------------------------------------------------------------------------------------------------\n * Slottable\n * -----------------------------------------------------------------------------------------------*/ const $5e63c961fc1ce211$export$d9f1ccf0bdb05d45 = ({ children: children })=>{\n return /*#__PURE__*/ $9IrjX$createElement($9IrjX$Fragment, null, children);\n};\n/* ---------------------------------------------------------------------------------------------- */ function $5e63c961fc1ce211$var$isSlottable(child) {\n return /*#__PURE__*/ $9IrjX$isValidElement(child) && child.type === $5e63c961fc1ce211$export$d9f1ccf0bdb05d45;\n}\nfunction $5e63c961fc1ce211$var$mergeProps(slotProps, childProps) {\n // all child props should override\n const overrideProps = {\n ...childProps\n };\n for(const propName in childProps){\n const slotPropValue = slotProps[propName];\n const childPropValue = childProps[propName];\n const isHandler = /^on[A-Z]/.test(propName);\n if (isHandler) {\n // if the handler exists on both, we compose them\n if (slotPropValue && childPropValue) overrideProps[propName] = (...args)=>{\n childPropValue(...args);\n slotPropValue(...args);\n };\n else if (slotPropValue) overrideProps[propName] = slotPropValue;\n } else if (propName === 'style') overrideProps[propName] = {\n ...slotPropValue,\n ...childPropValue\n };\n else if (propName === 'className') overrideProps[propName] = [\n slotPropValue,\n childPropValue\n ].filter(Boolean).join(' ');\n }\n return {\n ...slotProps,\n ...overrideProps\n };\n}\nconst $5e63c961fc1ce211$export$be92b6f5f03c0fe9 = $5e63c961fc1ce211$export$8c6ed5c666ac1360;\n\n\n\n\nexport {$5e63c961fc1ce211$export$8c6ed5c666ac1360 as Slot, $5e63c961fc1ce211$export$d9f1ccf0bdb05d45 as Slottable, $5e63c961fc1ce211$export$be92b6f5f03c0fe9 as Root};\n//# sourceMappingURL=index.mjs.map\n","import $4q5Fq$babelruntimehelpersesmextends from \"@babel/runtime/helpers/esm/extends\";\nimport {forwardRef as $4q5Fq$forwardRef, useEffect as $4q5Fq$useEffect, createElement as $4q5Fq$createElement} from \"react\";\nimport {flushSync as $4q5Fq$flushSync} from \"react-dom\";\nimport {Slot as $4q5Fq$Slot} from \"@radix-ui/react-slot\";\n\n\n\n\n\nconst $8927f6f2acc4f386$var$NODES = [\n 'a',\n 'button',\n 'div',\n 'form',\n 'h2',\n 'h3',\n 'img',\n 'input',\n 'label',\n 'li',\n 'nav',\n 'ol',\n 'p',\n 'span',\n 'svg',\n 'ul'\n]; // Temporary while we await merge of this fix:\n// https://github.com/DefinitelyTyped/DefinitelyTyped/pull/55396\n// prettier-ignore\n/* -------------------------------------------------------------------------------------------------\n * Primitive\n * -----------------------------------------------------------------------------------------------*/ const $8927f6f2acc4f386$export$250ffa63cdc0d034 = $8927f6f2acc4f386$var$NODES.reduce((primitive, node)=>{\n const Node = /*#__PURE__*/ $4q5Fq$forwardRef((props, forwardedRef)=>{\n const { asChild: asChild , ...primitiveProps } = props;\n const Comp = asChild ? $4q5Fq$Slot : node;\n $4q5Fq$useEffect(()=>{\n window[Symbol.for('radix-ui')] = true;\n }, []);\n return /*#__PURE__*/ $4q5Fq$createElement(Comp, $4q5Fq$babelruntimehelpersesmextends({}, primitiveProps, {\n ref: forwardedRef\n }));\n });\n Node.displayName = `Primitive.${node}`;\n return {\n ...primitive,\n [node]: Node\n };\n}, {});\n/* -------------------------------------------------------------------------------------------------\n * Utils\n * -----------------------------------------------------------------------------------------------*/ /**\n * Flush custom event dispatch\n * https://github.com/radix-ui/primitives/pull/1378\n *\n * React batches *all* event handlers since version 18, this introduces certain considerations when using custom event types.\n *\n * Internally, React prioritises events in the following order:\n * - discrete\n * - continuous\n * - default\n *\n * https://github.com/facebook/react/blob/a8a4742f1c54493df00da648a3f9d26e3db9c8b5/packages/react-dom/src/events/ReactDOMEventListener.js#L294-L350\n *\n * `discrete` is an important distinction as updates within these events are applied immediately.\n * React however, is not able to infer the priority of custom event types due to how they are detected internally.\n * Because of this, it's possible for updates from custom events to be unexpectedly batched when\n * dispatched by another `discrete` event.\n *\n * In order to ensure that updates from custom events are applied predictably, we need to manually flush the batch.\n * This utility should be used when dispatching a custom event from within another `discrete` event, this utility\n * is not nessesary when dispatching known event types, or if dispatching a custom type inside a non-discrete event.\n * For example:\n *\n * dispatching a known click 👎\n * target.dispatchEvent(new Event(‘click’))\n *\n * dispatching a custom type within a non-discrete event 👎\n * onScroll={(event) => event.target.dispatchEvent(new CustomEvent(‘customType’))}\n *\n * dispatching a custom type within a `discrete` event 👍\n * onPointerDown={(event) => dispatchDiscreteCustomEvent(event.target, new CustomEvent(‘customType’))}\n *\n * Note: though React classifies `focus`, `focusin` and `focusout` events as `discrete`, it's not recommended to use\n * this utility with them. This is because it's possible for those handlers to be called implicitly during render\n * e.g. when focus is within a component as it is unmounted, or when managing focus on mount.\n */ function $8927f6f2acc4f386$export$6d1a0317bde7de7f(target, event) {\n if (target) $4q5Fq$flushSync(()=>target.dispatchEvent(event)\n );\n}\n/* -----------------------------------------------------------------------------------------------*/ const $8927f6f2acc4f386$export$be92b6f5f03c0fe9 = $8927f6f2acc4f386$export$250ffa63cdc0d034;\n\n\n\n\nexport {$8927f6f2acc4f386$export$250ffa63cdc0d034 as Primitive, $8927f6f2acc4f386$export$be92b6f5f03c0fe9 as Root, $8927f6f2acc4f386$export$6d1a0317bde7de7f as dispatchDiscreteCustomEvent};\n//# sourceMappingURL=index.mjs.map\n","import $7V4JZ$babelruntimehelpersesmextends from \"@babel/runtime/helpers/esm/extends\";\nimport {forwardRef as $7V4JZ$forwardRef, createElement as $7V4JZ$createElement} from \"react\";\nimport {Primitive as $7V4JZ$Primitive} from \"@radix-ui/react-primitive\";\n\n\n\n\n/* -------------------------------------------------------------------------------------------------\n * Label\n * -----------------------------------------------------------------------------------------------*/ const $b73a6c6685e72184$var$NAME = 'Label';\nconst $b73a6c6685e72184$export$b04be29aa201d4f5 = /*#__PURE__*/ $7V4JZ$forwardRef((props, forwardedRef)=>{\n return /*#__PURE__*/ $7V4JZ$createElement($7V4JZ$Primitive.label, $7V4JZ$babelruntimehelpersesmextends({}, props, {\n ref: forwardedRef,\n onMouseDown: (event)=>{\n var _props$onMouseDown;\n (_props$onMouseDown = props.onMouseDown) === null || _props$onMouseDown === void 0 || _props$onMouseDown.call(props, event); // prevent text selection when double clicking label\n if (!event.defaultPrevented && event.detail > 1) event.preventDefault();\n }\n }));\n});\n/*#__PURE__*/ Object.assign($b73a6c6685e72184$export$b04be29aa201d4f5, {\n displayName: $b73a6c6685e72184$var$NAME\n});\n/* -----------------------------------------------------------------------------------------------*/ const $b73a6c6685e72184$export$be92b6f5f03c0fe9 = $b73a6c6685e72184$export$b04be29aa201d4f5;\n\n\n\n\nexport {$b73a6c6685e72184$export$b04be29aa201d4f5 as Label, $b73a6c6685e72184$export$be92b6f5f03c0fe9 as Root};\n//# sourceMappingURL=index.mjs.map\n","/*!\n\tCopyright (c) 2018 Jed Watson.\n\tLicensed under the MIT License (MIT), see\n\thttp://jedwatson.github.io/classnames\n*/\n/* global define */\n\n(function () {\n\t'use strict';\n\n\tvar hasOwn = {}.hasOwnProperty;\n\n\tfunction classNames () {\n\t\tvar classes = '';\n\n\t\tfor (var i = 0; i < arguments.length; i++) {\n\t\t\tvar arg = arguments[i];\n\t\t\tif (arg) {\n\t\t\t\tclasses = appendClass(classes, parseValue(arg));\n\t\t\t}\n\t\t}\n\n\t\treturn classes;\n\t}\n\n\tfunction parseValue (arg) {\n\t\tif (typeof arg === 'string' || typeof arg === 'number') {\n\t\t\treturn arg;\n\t\t}\n\n\t\tif (typeof arg !== 'object') {\n\t\t\treturn '';\n\t\t}\n\n\t\tif (Array.isArray(arg)) {\n\t\t\treturn classNames.apply(null, arg);\n\t\t}\n\n\t\tif (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes('[native code]')) {\n\t\t\treturn arg.toString();\n\t\t}\n\n\t\tvar classes = '';\n\n\t\tfor (var key in arg) {\n\t\t\tif (hasOwn.call(arg, key) && arg[key]) {\n\t\t\t\tclasses = appendClass(classes, key);\n\t\t\t}\n\t\t}\n\n\t\treturn classes;\n\t}\n\n\tfunction appendClass (value, newClass) {\n\t\tif (!newClass) {\n\t\t\treturn value;\n\t\t}\n\t\n\t\tif (value) {\n\t\t\treturn value + ' ' + newClass;\n\t\t}\n\t\n\t\treturn value + newClass;\n\t}\n\n\tif (typeof module !== 'undefined' && module.exports) {\n\t\tclassNames.default = classNames;\n\t\tmodule.exports = classNames;\n\t} else if (typeof define === 'function' && typeof define.amd === 'object' && define.amd) {\n\t\t// register as 'classnames', consistent with npm package name\n\t\tdefine('classnames', [], function () {\n\t\t\treturn classNames;\n\t\t});\n\t} else {\n\t\twindow.classNames = classNames;\n\t}\n}());\n","import React, { ReactNode } from \"react\";\nimport * as RadixLabel from \"@radix-ui/react-label\";\nimport c from \"classnames\";\n\nimport styles from \"./label.module.scss\";\n\nconst rootClassName = \"purpur-label\";\n\nexport type LabelProps = {\n \"data-testid\"?: string;\n children: ReactNode;\n className?: string;\n htmlFor: string;\n disabled?: boolean;\n};\nexport const Label = ({\n children,\n className,\n htmlFor,\n \"data-testid\": dataTestId,\n disabled,\n ...props\n}: LabelProps) => {\n const classes = c([\n className,\n styles[rootClassName],\n { [styles[`${rootClassName}--disabled`]]: disabled },\n ]);\n\n return (\n <RadixLabel.Root className={classes} data-testid={dataTestId} htmlFor={htmlFor} {...props}>\n {children}\n </RadixLabel.Root>\n );\n};\n"],"names":["_extends","target","i","source","key","$6ed0406888f73fc4$var$setRef","ref","value","$6ed0406888f73fc4$export$43e446d32b3d21af","refs","node","$5e63c961fc1ce211$export$8c6ed5c666ac1360","$9IrjX$forwardRef","props","forwardedRef","children","slotProps","childrenArray","$9IrjX$Children","slottable","$5e63c961fc1ce211$var$isSlottable","newElement","newChildren","child","$9IrjX$isValidElement","$9IrjX$createElement","$5e63c961fc1ce211$var$SlotClone","$9IrjX$babelruntimehelpersesmextends","$9IrjX$cloneElement","$5e63c961fc1ce211$var$mergeProps","$9IrjX$composeRefs","$5e63c961fc1ce211$export$d9f1ccf0bdb05d45","$9IrjX$Fragment","childProps","overrideProps","propName","slotPropValue","childPropValue","args","$8927f6f2acc4f386$var$NODES","$8927f6f2acc4f386$export$250ffa63cdc0d034","primitive","Node","$4q5Fq$forwardRef","asChild","primitiveProps","Comp","$4q5Fq$Slot","$4q5Fq$useEffect","$4q5Fq$createElement","$4q5Fq$babelruntimehelpersesmextends","$b73a6c6685e72184$export$b04be29aa201d4f5","$7V4JZ$forwardRef","$7V4JZ$createElement","$7V4JZ$Primitive","$7V4JZ$babelruntimehelpersesmextends","event","_props$onMouseDown","$b73a6c6685e72184$export$be92b6f5f03c0fe9","hasOwn","classNames","classes","arg","appendClass","parseValue","newClass","module","rootClassName","Label","className","htmlFor","dataTestId","disabled","c","styles","jsx","RadixLabel.Root"],"mappings":";;;AAAe,SAASA,IAAW;AACjCA,SAAAA,IAAW,OAAO,SAAS,OAAO,OAAO,KAAI,IAAK,SAAUC,GAAQ;AAClE,aAASC,IAAI,GAAGA,IAAI,UAAU,QAAQA,KAAK;AACzC,UAAIC,IAAS,UAAUD,CAAC;AACxB,eAASE,KAAOD;AACd,QAAI,OAAO,UAAU,eAAe,KAAKA,GAAQC,CAAG,MAClDH,EAAOG,CAAG,IAAID,EAAOC,CAAG;AAAA,IAG7B;AACD,WAAOH;AAAA,EACX,GACSD,EAAS,MAAM,MAAM,SAAS;AACvC;ACbe,SAASA,IAAW;AACjC,SAAAA,IAAW,OAAO,SAAS,OAAO,OAAO,KAAI,IAAK,SAAUC,GAAQ;AAClE,aAASC,IAAI,GAAGA,IAAI,UAAU,QAAQA,KAAK;AACzC,UAAIC,IAAS,UAAUD,CAAC;AACxB,eAASE,KAAOD;AACd,QAAI,OAAO,UAAU,eAAe,KAAKA,GAAQC,CAAG,MAClDH,EAAOG,CAAG,IAAID,EAAOC,CAAG;AAAA,IAG7B;AACD,WAAOH;AAAA,EACX,GACSD,EAAS,MAAM,MAAM,SAAS;AACvC;ACPI,SAASK,EAA6BC,GAAKC,GAAO;AAClD,EAAI,OAAOD,KAAQ,aAAYA,EAAIC,CAAK,IAC/BD,KAAQ,SAA2BA,EAAI,UAAUC;AAC9D;AAII,SAASC,KAA6CC,GAAM;AAC5D,SAAO,CAACC,MAAOD,EAAK;AAAA,IAAQ,CAACH,MAAMD,EAA6BC,GAAKI,CAAI;AAAA,EACpE;AAET;ACRqG,MAAMC,IAA0DC,gBAAAA,EA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AI;AAGZ,UAAID,IAAU;AAEd,eAASzD,KAAO0D;AACf,QAAIH,EAAO,KAAKG,GAAK1D,CAAG,KAAK0D,EAAI1D,CAAG,MACnCyD,IAAUE,EAAYF,GAASzD,CAAG;AAIpC,aAAOyD;AAAA,IACP;AAED,aAASE,EAAaxD,GAAO0D,GAAU;AACtC,aAAKA,IAID1D,IACIA,IAAQ,MAAM0D,IAGf1D,IAAQ0D,IAPP1D;AAAA,IAQR;AAED,IAAqC2D,EAAO,WAC3CN,EAAW,UAAUA,GACrBM,EAAA,UAAiBN,KAOjB,OAAO,aAAaA;AAAA,EAEtB;;;;;;GCtEMO,IAAgB,gBASTC,IAAQ,CAAC;AAAA,EACpB,UAAArD;AAAA,EACA,WAAAsD;AAAA,EACA,SAAAC;AAAA,EACA,eAAeC;AAAA,EACf,UAAAC;AAAA,EACA,GAAG3D;AACL,MAAkB;AAChB,QAAMgD,IAAUY,EAAE;AAAA,IAChBJ;AAAA,IACAK,EAAOP,CAAa;AAAA,IACpB,EAAE,CAACO,EAAO,GAAGP,CAAa,YAAY,CAAC,GAAGK,EAAS;AAAA,EAAA,CACpD;AAGC,SAAA,gBAAAG,EAACC,GAAA,EAAgB,WAAWf,GAAS,eAAaU,GAAY,SAAAD,GAAmB,GAAGzD,GACjF,UAAAE,EACH,CAAA;AAEJ;","x_google_ignoreList":[0,1,2,3,4,5,6]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
System.register(["react","react-dom"],function(x,F){"use strict";var u,i,p,f,$,m,v,h;return{setters:[l=>{u=l.forwardRef,i=l.Children,p=l.isValidElement,f=l.createElement,$=l.cloneElement,m=l.Fragment,v=l.useEffect,h=l.default},null],execute:function(){function l(){return l=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s])}return e},l.apply(this,arguments)}function d(){return d=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s])}return e},d.apply(this,arguments)}function S(e,r){typeof e=="function"?e(r):e!=null&&(e.current=r)}function w(...e){return r=>e.forEach(t=>S(t,r))}const y=u((e,r)=>{const{children:t,...s}=e,a=i.toArray(t),n=a.find(_);if(n){const o=n.props.children,c=a.map(j=>j===n?i.count(o)>1?i.only(null):p(o)?o.props.children:null:j);return f(b,d({},s,{ref:r}),p(o)?$(o,void 0,c):null)}return f(b,d({},s,{ref:r}),t)});y.displayName="Slot";const b=u((e,r)=>{const{children:t,...s}=e;return p(t)?$(t,{...P(s,t.props),ref:r?w(r,t.ref):t.ref}):i.count(t)>1?i.only(null):null});b.displayName="SlotClone";const N=({children:e})=>f(m,null,e);function _(e){return p(e)&&e.type===N}function P(e,r){const t={...r};for(const s in r){const a=e[s],n=r[s];/^on[A-Z]/.test(s)?a&&n?t[s]=(...c)=>{n(...c),a(...c)}:a&&(t[s]=a):s==="style"?t[s]={...a,...n}:s==="className"&&(t[s]=[a,n].filter(Boolean).join(" "))}return{...e,...t}}const C=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"].reduce((e,r)=>{const t=u((s,a)=>{const{asChild:n,...o}=s,c=n?y:r;return v(()=>{window[Symbol.for("radix-ui")]=!0},[]),f(c,d({},o,{ref:a}))});return t.displayName=`Primitive.${r}`,{...e,[r]:t}},{}),D=u((e,r)=>f(C.label,l({},e,{ref:r,onMouseDown:t=>{var s;(s=e.onMouseDown)===null||s===void 0||s.call(e,t),!t.defaultPrevented&&t.detail>1&&t.preventDefault()}})));function A(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var E={exports:{}};/*!
|
|
2
|
+
Copyright (c) 2018 Jed Watson.
|
|
3
|
+
Licensed under the MIT License (MIT), see
|
|
4
|
+
http://jedwatson.github.io/classnames
|
|
5
|
+
*/(function(e){(function(){var r={}.hasOwnProperty;function t(){for(var n="",o=0;o<arguments.length;o++){var c=arguments[o];c&&(n=a(n,s(c)))}return n}function s(n){if(typeof n=="string"||typeof n=="number")return n;if(typeof n!="object")return"";if(Array.isArray(n))return t.apply(null,n);if(n.toString!==Object.prototype.toString&&!n.toString.toString().includes("[native code]"))return n.toString();var o="";for(var c in n)r.call(n,c)&&n[c]&&(o=a(o,c));return o}function a(n,o){return o?n?n+" "+o:n+o:n}e.exports?(t.default=t,e.exports=t):window.classNames=t})()})(E);var V=E.exports;const M=A(V),O={"purpur-label":"_purpur-label_1jub8_1","purpur-label--disabled":"_purpur-label--disabled_1jub8_9"},g="purpur-label",R=x("Label",({children:e,className:r,htmlFor:t,"data-testid":s,disabled:a,...n})=>{const o=M([r,O[g],{[O[`${g}--disabled`]]:a}]);return h.createElement(D,{className:o,"data-testid":s,htmlFor:t,...n},e)})}}});
|
|
6
|
+
//# sourceMappingURL=label.system.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"label.system.js","sources":["../../../common/temp/node_modules/.pnpm/@babel+runtime@7.22.15/node_modules/@babel/runtime/helpers/esm/extends.js","../../../common/temp/node_modules/.pnpm/@babel+runtime@7.23.5/node_modules/@babel/runtime/helpers/esm/extends.js","../../../common/temp/node_modules/.pnpm/@radix-ui+react-compose-refs@1.0.1_@types+react@18.2.42_react@18.2.0/node_modules/@radix-ui/react-compose-refs/dist/index.mjs","../../../common/temp/node_modules/.pnpm/@radix-ui+react-slot@1.0.2_@types+react@18.2.42_react@18.2.0/node_modules/@radix-ui/react-slot/dist/index.mjs","../../../common/temp/node_modules/.pnpm/@radix-ui+react-primitive@1.0.3_@types+react-dom@18.2.17_@types+react@18.2.42_react-dom@18.2.0_react@18.2.0/node_modules/@radix-ui/react-primitive/dist/index.mjs","../../../common/temp/node_modules/.pnpm/@radix-ui+react-label@2.0.2_@types+react-dom@18.2.17_@types+react@18.2.42_react-dom@18.2.0_react@18.2.0/node_modules/@radix-ui/react-label/dist/index.mjs","../../../common/temp/node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.js","../src/label.tsx"],"sourcesContent":["export default function _extends() {\n _extends = Object.assign ? Object.assign.bind() : function (target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i];\n for (var key in source) {\n if (Object.prototype.hasOwnProperty.call(source, key)) {\n target[key] = source[key];\n }\n }\n }\n return target;\n };\n return _extends.apply(this, arguments);\n}","export default function _extends() {\n _extends = Object.assign ? Object.assign.bind() : function (target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i];\n for (var key in source) {\n if (Object.prototype.hasOwnProperty.call(source, key)) {\n target[key] = source[key];\n }\n }\n }\n return target;\n };\n return _extends.apply(this, arguments);\n}","import {useCallback as $3vqmr$useCallback} from \"react\";\n\n\n/**\n * Set a given ref to a given value\n * This utility takes care of different types of refs: callback refs and RefObject(s)\n */ function $6ed0406888f73fc4$var$setRef(ref, value) {\n if (typeof ref === 'function') ref(value);\n else if (ref !== null && ref !== undefined) ref.current = value;\n}\n/**\n * A utility to compose multiple refs together\n * Accepts callback refs and RefObject(s)\n */ function $6ed0406888f73fc4$export$43e446d32b3d21af(...refs) {\n return (node)=>refs.forEach((ref)=>$6ed0406888f73fc4$var$setRef(ref, node)\n )\n ;\n}\n/**\n * A custom hook that composes multiple refs\n * Accepts callback refs and RefObject(s)\n */ function $6ed0406888f73fc4$export$c7b2cbe3552a0d05(...refs) {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n return $3vqmr$useCallback($6ed0406888f73fc4$export$43e446d32b3d21af(...refs), refs);\n}\n\n\n\n\nexport {$6ed0406888f73fc4$export$43e446d32b3d21af as composeRefs, $6ed0406888f73fc4$export$c7b2cbe3552a0d05 as useComposedRefs};\n//# sourceMappingURL=index.mjs.map\n","import $9IrjX$babelruntimehelpersesmextends from \"@babel/runtime/helpers/esm/extends\";\nimport {forwardRef as $9IrjX$forwardRef, Children as $9IrjX$Children, isValidElement as $9IrjX$isValidElement, createElement as $9IrjX$createElement, cloneElement as $9IrjX$cloneElement, Fragment as $9IrjX$Fragment} from \"react\";\nimport {composeRefs as $9IrjX$composeRefs} from \"@radix-ui/react-compose-refs\";\n\n\n\n\n/* -------------------------------------------------------------------------------------------------\n * Slot\n * -----------------------------------------------------------------------------------------------*/ const $5e63c961fc1ce211$export$8c6ed5c666ac1360 = /*#__PURE__*/ $9IrjX$forwardRef((props, forwardedRef)=>{\n const { children: children , ...slotProps } = props;\n const childrenArray = $9IrjX$Children.toArray(children);\n const slottable = childrenArray.find($5e63c961fc1ce211$var$isSlottable);\n if (slottable) {\n // the new element to render is the one passed as a child of `Slottable`\n const newElement = slottable.props.children;\n const newChildren = childrenArray.map((child)=>{\n if (child === slottable) {\n // because the new element will be the one rendered, we are only interested\n // in grabbing its children (`newElement.props.children`)\n if ($9IrjX$Children.count(newElement) > 1) return $9IrjX$Children.only(null);\n return /*#__PURE__*/ $9IrjX$isValidElement(newElement) ? newElement.props.children : null;\n } else return child;\n });\n return /*#__PURE__*/ $9IrjX$createElement($5e63c961fc1ce211$var$SlotClone, $9IrjX$babelruntimehelpersesmextends({}, slotProps, {\n ref: forwardedRef\n }), /*#__PURE__*/ $9IrjX$isValidElement(newElement) ? /*#__PURE__*/ $9IrjX$cloneElement(newElement, undefined, newChildren) : null);\n }\n return /*#__PURE__*/ $9IrjX$createElement($5e63c961fc1ce211$var$SlotClone, $9IrjX$babelruntimehelpersesmextends({}, slotProps, {\n ref: forwardedRef\n }), children);\n});\n$5e63c961fc1ce211$export$8c6ed5c666ac1360.displayName = 'Slot';\n/* -------------------------------------------------------------------------------------------------\n * SlotClone\n * -----------------------------------------------------------------------------------------------*/ const $5e63c961fc1ce211$var$SlotClone = /*#__PURE__*/ $9IrjX$forwardRef((props, forwardedRef)=>{\n const { children: children , ...slotProps } = props;\n if (/*#__PURE__*/ $9IrjX$isValidElement(children)) return /*#__PURE__*/ $9IrjX$cloneElement(children, {\n ...$5e63c961fc1ce211$var$mergeProps(slotProps, children.props),\n ref: forwardedRef ? $9IrjX$composeRefs(forwardedRef, children.ref) : children.ref\n });\n return $9IrjX$Children.count(children) > 1 ? $9IrjX$Children.only(null) : null;\n});\n$5e63c961fc1ce211$var$SlotClone.displayName = 'SlotClone';\n/* -------------------------------------------------------------------------------------------------\n * Slottable\n * -----------------------------------------------------------------------------------------------*/ const $5e63c961fc1ce211$export$d9f1ccf0bdb05d45 = ({ children: children })=>{\n return /*#__PURE__*/ $9IrjX$createElement($9IrjX$Fragment, null, children);\n};\n/* ---------------------------------------------------------------------------------------------- */ function $5e63c961fc1ce211$var$isSlottable(child) {\n return /*#__PURE__*/ $9IrjX$isValidElement(child) && child.type === $5e63c961fc1ce211$export$d9f1ccf0bdb05d45;\n}\nfunction $5e63c961fc1ce211$var$mergeProps(slotProps, childProps) {\n // all child props should override\n const overrideProps = {\n ...childProps\n };\n for(const propName in childProps){\n const slotPropValue = slotProps[propName];\n const childPropValue = childProps[propName];\n const isHandler = /^on[A-Z]/.test(propName);\n if (isHandler) {\n // if the handler exists on both, we compose them\n if (slotPropValue && childPropValue) overrideProps[propName] = (...args)=>{\n childPropValue(...args);\n slotPropValue(...args);\n };\n else if (slotPropValue) overrideProps[propName] = slotPropValue;\n } else if (propName === 'style') overrideProps[propName] = {\n ...slotPropValue,\n ...childPropValue\n };\n else if (propName === 'className') overrideProps[propName] = [\n slotPropValue,\n childPropValue\n ].filter(Boolean).join(' ');\n }\n return {\n ...slotProps,\n ...overrideProps\n };\n}\nconst $5e63c961fc1ce211$export$be92b6f5f03c0fe9 = $5e63c961fc1ce211$export$8c6ed5c666ac1360;\n\n\n\n\nexport {$5e63c961fc1ce211$export$8c6ed5c666ac1360 as Slot, $5e63c961fc1ce211$export$d9f1ccf0bdb05d45 as Slottable, $5e63c961fc1ce211$export$be92b6f5f03c0fe9 as Root};\n//# sourceMappingURL=index.mjs.map\n","import $4q5Fq$babelruntimehelpersesmextends from \"@babel/runtime/helpers/esm/extends\";\nimport {forwardRef as $4q5Fq$forwardRef, useEffect as $4q5Fq$useEffect, createElement as $4q5Fq$createElement} from \"react\";\nimport {flushSync as $4q5Fq$flushSync} from \"react-dom\";\nimport {Slot as $4q5Fq$Slot} from \"@radix-ui/react-slot\";\n\n\n\n\n\nconst $8927f6f2acc4f386$var$NODES = [\n 'a',\n 'button',\n 'div',\n 'form',\n 'h2',\n 'h3',\n 'img',\n 'input',\n 'label',\n 'li',\n 'nav',\n 'ol',\n 'p',\n 'span',\n 'svg',\n 'ul'\n]; // Temporary while we await merge of this fix:\n// https://github.com/DefinitelyTyped/DefinitelyTyped/pull/55396\n// prettier-ignore\n/* -------------------------------------------------------------------------------------------------\n * Primitive\n * -----------------------------------------------------------------------------------------------*/ const $8927f6f2acc4f386$export$250ffa63cdc0d034 = $8927f6f2acc4f386$var$NODES.reduce((primitive, node)=>{\n const Node = /*#__PURE__*/ $4q5Fq$forwardRef((props, forwardedRef)=>{\n const { asChild: asChild , ...primitiveProps } = props;\n const Comp = asChild ? $4q5Fq$Slot : node;\n $4q5Fq$useEffect(()=>{\n window[Symbol.for('radix-ui')] = true;\n }, []);\n return /*#__PURE__*/ $4q5Fq$createElement(Comp, $4q5Fq$babelruntimehelpersesmextends({}, primitiveProps, {\n ref: forwardedRef\n }));\n });\n Node.displayName = `Primitive.${node}`;\n return {\n ...primitive,\n [node]: Node\n };\n}, {});\n/* -------------------------------------------------------------------------------------------------\n * Utils\n * -----------------------------------------------------------------------------------------------*/ /**\n * Flush custom event dispatch\n * https://github.com/radix-ui/primitives/pull/1378\n *\n * React batches *all* event handlers since version 18, this introduces certain considerations when using custom event types.\n *\n * Internally, React prioritises events in the following order:\n * - discrete\n * - continuous\n * - default\n *\n * https://github.com/facebook/react/blob/a8a4742f1c54493df00da648a3f9d26e3db9c8b5/packages/react-dom/src/events/ReactDOMEventListener.js#L294-L350\n *\n * `discrete` is an important distinction as updates within these events are applied immediately.\n * React however, is not able to infer the priority of custom event types due to how they are detected internally.\n * Because of this, it's possible for updates from custom events to be unexpectedly batched when\n * dispatched by another `discrete` event.\n *\n * In order to ensure that updates from custom events are applied predictably, we need to manually flush the batch.\n * This utility should be used when dispatching a custom event from within another `discrete` event, this utility\n * is not nessesary when dispatching known event types, or if dispatching a custom type inside a non-discrete event.\n * For example:\n *\n * dispatching a known click 👎\n * target.dispatchEvent(new Event(‘click’))\n *\n * dispatching a custom type within a non-discrete event 👎\n * onScroll={(event) => event.target.dispatchEvent(new CustomEvent(‘customType’))}\n *\n * dispatching a custom type within a `discrete` event 👍\n * onPointerDown={(event) => dispatchDiscreteCustomEvent(event.target, new CustomEvent(‘customType’))}\n *\n * Note: though React classifies `focus`, `focusin` and `focusout` events as `discrete`, it's not recommended to use\n * this utility with them. This is because it's possible for those handlers to be called implicitly during render\n * e.g. when focus is within a component as it is unmounted, or when managing focus on mount.\n */ function $8927f6f2acc4f386$export$6d1a0317bde7de7f(target, event) {\n if (target) $4q5Fq$flushSync(()=>target.dispatchEvent(event)\n );\n}\n/* -----------------------------------------------------------------------------------------------*/ const $8927f6f2acc4f386$export$be92b6f5f03c0fe9 = $8927f6f2acc4f386$export$250ffa63cdc0d034;\n\n\n\n\nexport {$8927f6f2acc4f386$export$250ffa63cdc0d034 as Primitive, $8927f6f2acc4f386$export$be92b6f5f03c0fe9 as Root, $8927f6f2acc4f386$export$6d1a0317bde7de7f as dispatchDiscreteCustomEvent};\n//# sourceMappingURL=index.mjs.map\n","import $7V4JZ$babelruntimehelpersesmextends from \"@babel/runtime/helpers/esm/extends\";\nimport {forwardRef as $7V4JZ$forwardRef, createElement as $7V4JZ$createElement} from \"react\";\nimport {Primitive as $7V4JZ$Primitive} from \"@radix-ui/react-primitive\";\n\n\n\n\n/* -------------------------------------------------------------------------------------------------\n * Label\n * -----------------------------------------------------------------------------------------------*/ const $b73a6c6685e72184$var$NAME = 'Label';\nconst $b73a6c6685e72184$export$b04be29aa201d4f5 = /*#__PURE__*/ $7V4JZ$forwardRef((props, forwardedRef)=>{\n return /*#__PURE__*/ $7V4JZ$createElement($7V4JZ$Primitive.label, $7V4JZ$babelruntimehelpersesmextends({}, props, {\n ref: forwardedRef,\n onMouseDown: (event)=>{\n var _props$onMouseDown;\n (_props$onMouseDown = props.onMouseDown) === null || _props$onMouseDown === void 0 || _props$onMouseDown.call(props, event); // prevent text selection when double clicking label\n if (!event.defaultPrevented && event.detail > 1) event.preventDefault();\n }\n }));\n});\n/*#__PURE__*/ Object.assign($b73a6c6685e72184$export$b04be29aa201d4f5, {\n displayName: $b73a6c6685e72184$var$NAME\n});\n/* -----------------------------------------------------------------------------------------------*/ const $b73a6c6685e72184$export$be92b6f5f03c0fe9 = $b73a6c6685e72184$export$b04be29aa201d4f5;\n\n\n\n\nexport {$b73a6c6685e72184$export$b04be29aa201d4f5 as Label, $b73a6c6685e72184$export$be92b6f5f03c0fe9 as Root};\n//# sourceMappingURL=index.mjs.map\n","/*!\n\tCopyright (c) 2018 Jed Watson.\n\tLicensed under the MIT License (MIT), see\n\thttp://jedwatson.github.io/classnames\n*/\n/* global define */\n\n(function () {\n\t'use strict';\n\n\tvar hasOwn = {}.hasOwnProperty;\n\n\tfunction classNames () {\n\t\tvar classes = '';\n\n\t\tfor (var i = 0; i < arguments.length; i++) {\n\t\t\tvar arg = arguments[i];\n\t\t\tif (arg) {\n\t\t\t\tclasses = appendClass(classes, parseValue(arg));\n\t\t\t}\n\t\t}\n\n\t\treturn classes;\n\t}\n\n\tfunction parseValue (arg) {\n\t\tif (typeof arg === 'string' || typeof arg === 'number') {\n\t\t\treturn arg;\n\t\t}\n\n\t\tif (typeof arg !== 'object') {\n\t\t\treturn '';\n\t\t}\n\n\t\tif (Array.isArray(arg)) {\n\t\t\treturn classNames.apply(null, arg);\n\t\t}\n\n\t\tif (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes('[native code]')) {\n\t\t\treturn arg.toString();\n\t\t}\n\n\t\tvar classes = '';\n\n\t\tfor (var key in arg) {\n\t\t\tif (hasOwn.call(arg, key) && arg[key]) {\n\t\t\t\tclasses = appendClass(classes, key);\n\t\t\t}\n\t\t}\n\n\t\treturn classes;\n\t}\n\n\tfunction appendClass (value, newClass) {\n\t\tif (!newClass) {\n\t\t\treturn value;\n\t\t}\n\t\n\t\tif (value) {\n\t\t\treturn value + ' ' + newClass;\n\t\t}\n\t\n\t\treturn value + newClass;\n\t}\n\n\tif (typeof module !== 'undefined' && module.exports) {\n\t\tclassNames.default = classNames;\n\t\tmodule.exports = classNames;\n\t} else if (typeof define === 'function' && typeof define.amd === 'object' && define.amd) {\n\t\t// register as 'classnames', consistent with npm package name\n\t\tdefine('classnames', [], function () {\n\t\t\treturn classNames;\n\t\t});\n\t} else {\n\t\twindow.classNames = classNames;\n\t}\n}());\n","import React, { ReactNode } from \"react\";\nimport * as RadixLabel from \"@radix-ui/react-label\";\nimport c from \"classnames\";\n\nimport styles from \"./label.module.scss\";\n\nconst rootClassName = \"purpur-label\";\n\nexport type LabelProps = {\n \"data-testid\"?: string;\n children: ReactNode;\n className?: string;\n htmlFor: string;\n disabled?: boolean;\n};\nexport const Label = ({\n children,\n className,\n htmlFor,\n \"data-testid\": dataTestId,\n disabled,\n ...props\n}: LabelProps) => {\n const classes = c([\n className,\n styles[rootClassName],\n { [styles[`${rootClassName}--disabled`]]: disabled },\n ]);\n\n return (\n <RadixLabel.Root className={classes} data-testid={dataTestId} htmlFor={htmlFor} {...props}>\n {children}\n </RadixLabel.Root>\n );\n};\n"],"names":["_extends","target","i","source","key","$6ed0406888f73fc4$var$setRef","ref","value","$6ed0406888f73fc4$export$43e446d32b3d21af","refs","node","$5e63c961fc1ce211$export$8c6ed5c666ac1360","$9IrjX$forwardRef","props","forwardedRef","children","slotProps","childrenArray","$9IrjX$Children","slottable","$5e63c961fc1ce211$var$isSlottable","newElement","newChildren","child","$9IrjX$isValidElement","$9IrjX$createElement","$5e63c961fc1ce211$var$SlotClone","$9IrjX$babelruntimehelpersesmextends","$9IrjX$cloneElement","$5e63c961fc1ce211$var$mergeProps","$9IrjX$composeRefs","$5e63c961fc1ce211$export$d9f1ccf0bdb05d45","$9IrjX$Fragment","childProps","overrideProps","propName","slotPropValue","childPropValue","args","$8927f6f2acc4f386$export$250ffa63cdc0d034","primitive","Node","$4q5Fq$forwardRef","asChild","primitiveProps","Comp","$4q5Fq$Slot","$4q5Fq$useEffect","$4q5Fq$createElement","$4q5Fq$babelruntimehelpersesmextends","$b73a6c6685e72184$export$be92b6f5f03c0fe9","$7V4JZ$forwardRef","$7V4JZ$createElement","$7V4JZ$Primitive","$7V4JZ$babelruntimehelpersesmextends","event","_props$onMouseDown","hasOwn","classNames","classes","arg","appendClass","parseValue","newClass","module","rootClassName","Label","className","htmlFor","dataTestId","disabled","c","styles","React","RadixLabel.Root"],"mappings":"4PAAe,SAASA,GAAW,CACjCA,OAAAA,EAAW,OAAO,OAAS,OAAO,OAAO,KAAI,EAAK,SAAUC,EAAQ,CAClE,QAASC,EAAI,EAAGA,EAAI,UAAU,OAAQA,IAAK,CACzC,IAAIC,EAAS,UAAUD,CAAC,EACxB,QAASE,KAAOD,EACV,OAAO,UAAU,eAAe,KAAKA,EAAQC,CAAG,IAClDH,EAAOG,CAAG,EAAID,EAAOC,CAAG,EAG7B,CACD,OAAOH,CACX,EACSD,EAAS,MAAM,KAAM,SAAS,CACvC,CCbe,SAASA,GAAW,CACjC,OAAAA,EAAW,OAAO,OAAS,OAAO,OAAO,KAAI,EAAK,SAAUC,EAAQ,CAClE,QAASC,EAAI,EAAGA,EAAI,UAAU,OAAQA,IAAK,CACzC,IAAIC,EAAS,UAAUD,CAAC,EACxB,QAASE,KAAOD,EACV,OAAO,UAAU,eAAe,KAAKA,EAAQC,CAAG,IAClDH,EAAOG,CAAG,EAAID,EAAOC,CAAG,EAG7B,CACD,OAAOH,CACX,EACSD,EAAS,MAAM,KAAM,SAAS,CACvC,CCPI,SAASK,EAA6BC,EAAKC,EAAO,CAC9C,OAAOD,GAAQ,WAAYA,EAAIC,CAAK,EAC/BD,GAAQ,OAA2BA,EAAI,QAAUC,EAC9D,CAII,SAASC,KAA6CC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CACpB,SAAAnD,EACA,UAAAoD,EACA,QAAAC,EACA,cAAeC,EACf,SAAAC,EACA,GAAGzD,CACL,IAAkB,CAChB,MAAM8C,EAAUY,EAAE,CAChBJ,EACAK,EAAOP,CAAa,EACpB,CAAE,CAACO,EAAO,GAAGP,CAAa,YAAY,CAAC,EAAGK,CAAS,CAAA,CACpD,EAGC,OAAAG,EAAA,cAACC,EAAA,CAAgB,UAAWf,EAAS,cAAaU,EAAY,QAAAD,EAAmB,GAAGvD,CAAA,EACjFE,CACH,CAEJ,CAAA","x_google_ignoreList":[0,1,2,3,4,5,6]}
|
package/dist/styles.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
._purpur-label_1jub8_1{color:var(--purpur-color-text-default);font-family:var(--purpur-typography-family-default),Helvetica,Arial,"Lucida Grande",sans-serif;font-weight:var(--purpur-typography-weight-medium);font-size:var(--purpur-typography-scale-100);line-height:var(--purpur-typography-line-height-default);cursor:pointer}._purpur-label--disabled_1jub8_9{color:var(--purpur-color-text-weak);cursor:default}
|
package/package.json
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@purpurds/label",
|
|
3
|
+
"version": "3.0.0",
|
|
4
|
+
"license": "AGPL-3.0-only",
|
|
5
|
+
"main": "./dist/label.cjs.js",
|
|
6
|
+
"types": "./dist/label.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"require": "./dist/label.cjs.js",
|
|
10
|
+
"systemjs": "./dist/label.system.js",
|
|
11
|
+
"types": "./dist/label.d.ts",
|
|
12
|
+
"default": "./dist/label.es.js"
|
|
13
|
+
},
|
|
14
|
+
"./styles": "./dist/styles.css"
|
|
15
|
+
},
|
|
16
|
+
"source": "src/label.tsx",
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"@radix-ui/react-label": "~2.0.2",
|
|
19
|
+
"classnames": "~2.5.0",
|
|
20
|
+
"@purpurds/icon": "3.0.0",
|
|
21
|
+
"@purpurds/tokens": "3.0.0"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@rushstack/eslint-patch": "~1.7.0",
|
|
25
|
+
"@storybook/blocks": "~7.6.0",
|
|
26
|
+
"@storybook/react": "~7.6.0",
|
|
27
|
+
"@telia/base-rig": "~8.2.0",
|
|
28
|
+
"@telia/react-rig": "~3.2.0",
|
|
29
|
+
"@testing-library/dom": "~9.3.3",
|
|
30
|
+
"@testing-library/jest-dom": "~6.3.0",
|
|
31
|
+
"@testing-library/react": "~14.1.2",
|
|
32
|
+
"@types/node": "18",
|
|
33
|
+
"@types/react-dom": "~18.2.17",
|
|
34
|
+
"@types/react": "~18.2.42",
|
|
35
|
+
"eslint-plugin-testing-library": "~6.2.0",
|
|
36
|
+
"eslint": "~8.56.0",
|
|
37
|
+
"jsdom": "~22.1.0",
|
|
38
|
+
"lint-staged": "~10.5.3",
|
|
39
|
+
"prettier": "~2.8.8",
|
|
40
|
+
"react-dom": "~18.2.0",
|
|
41
|
+
"react": "~18.2.0",
|
|
42
|
+
"typescript": "~5.2.2",
|
|
43
|
+
"vite": "~5.0.6",
|
|
44
|
+
"vitest": "~1.2.0",
|
|
45
|
+
"@purpurds/component-rig": "1.0.0"
|
|
46
|
+
},
|
|
47
|
+
"scripts": {
|
|
48
|
+
"build:dev": "vite",
|
|
49
|
+
"build:watch": "vite build --watch",
|
|
50
|
+
"build": "rm -rf dist && vite build && vite build --mode systemjs",
|
|
51
|
+
"ci:build": "rushx build",
|
|
52
|
+
"coverage": "vitest run --coverage",
|
|
53
|
+
"lint:fix": "eslint . --fix",
|
|
54
|
+
"lint": "lint-staged --no-stash 2>&1",
|
|
55
|
+
"sbdev": "rush sbdev",
|
|
56
|
+
"test:unit": "vitest run --passWithNoTests",
|
|
57
|
+
"test:watch": "vitest --watch",
|
|
58
|
+
"test": "rushx test:unit",
|
|
59
|
+
"typecheck": "tsc -p ./tsconfig.json"
|
|
60
|
+
}
|
|
61
|
+
}
|
package/readme.mdx
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Meta, Stories, ArgTypes, Primary, Title, Subtitle } from "@storybook/blocks";
|
|
2
|
+
|
|
3
|
+
import * as LabelStories from "./src/label.stories";
|
|
4
|
+
import { Label } from "./src/label";
|
|
5
|
+
import packageInfo from "./package.json";
|
|
6
|
+
|
|
7
|
+
<Meta name="Docs" title="Components/Label" of={LabelStories} />
|
|
8
|
+
|
|
9
|
+
# Label
|
|
10
|
+
|
|
11
|
+
<Subtitle>Version {packageInfo.version}</Subtitle>
|
|
12
|
+
|
|
13
|
+
### Showcase
|
|
14
|
+
|
|
15
|
+
<Primary />
|
|
16
|
+
|
|
17
|
+
### Properties
|
|
18
|
+
|
|
19
|
+
<ArgTypes of={Label} />
|
|
20
|
+
|
|
21
|
+
### Installation
|
|
22
|
+
|
|
23
|
+
#### Via NPM
|
|
24
|
+
|
|
25
|
+
Add the dependency to your consumer app like `"label": "x.y.z"`
|
|
26
|
+
|
|
27
|
+
#### From outside the monorepo (build-time)
|
|
28
|
+
|
|
29
|
+
To install this package, you need to setup access to the artifactory. [Click here to go to the guide on how to do that](https://github.com/telia-company/jfrog-documentation/blob/main/doc/JFrog/JFrog_Onboarding.md#getting-access-to-artifactory-and-other-jfrog-applications).
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
In MyApp.tsx
|
|
34
|
+
|
|
35
|
+
```tsx
|
|
36
|
+
import "@purpurds/tokens/index.css";
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
and
|
|
40
|
+
|
|
41
|
+
```tsx
|
|
42
|
+
import "@purpurds/label/styles";
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
In MyComponent.tsx
|
|
46
|
+
|
|
47
|
+
```tsx
|
|
48
|
+
import { Label } from "@purpurds/label";
|
|
49
|
+
|
|
50
|
+
export const MyComponent = () => {
|
|
51
|
+
return (
|
|
52
|
+
<div>
|
|
53
|
+
<Label {...someProps}>Some content</Label>
|
|
54
|
+
</div>
|
|
55
|
+
);
|
|
56
|
+
};
|
|
57
|
+
```
|
package/src/global.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
.purpur-label {
|
|
2
|
+
color: var(--purpur-color-text-default);
|
|
3
|
+
font-family: var(--purpur-typography-family-default), Helvetica, Arial, "Lucida Grande",
|
|
4
|
+
sans-serif;
|
|
5
|
+
font-weight: var(--purpur-typography-weight-medium);
|
|
6
|
+
font-size: var(--purpur-typography-scale-100);
|
|
7
|
+
line-height: var(--purpur-typography-line-height-default);
|
|
8
|
+
cursor: pointer;
|
|
9
|
+
|
|
10
|
+
&--disabled {
|
|
11
|
+
color: var(--purpur-color-text-weak);
|
|
12
|
+
cursor: default;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/* eslint-disable react/prop-types */
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { Label } from "./label";
|
|
4
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
5
|
+
|
|
6
|
+
const meta: Meta<typeof Label> = {
|
|
7
|
+
title: "Components/Label",
|
|
8
|
+
component: Label,
|
|
9
|
+
parameters: {
|
|
10
|
+
design: [
|
|
11
|
+
{
|
|
12
|
+
name: "Checkbox",
|
|
13
|
+
type: "figma",
|
|
14
|
+
url: "https://www.figma.com/file/XEaIIFskrrxIBHMZDkIuIg/Purpur-DS---Component-library-%26-guidelines?type=design&node-id=1274%3A614&mode=design&t=5WYoIWv1It545kCs-1",
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
name: "Date picker",
|
|
18
|
+
type: "figma",
|
|
19
|
+
url: "https://www.figma.com/file/XEaIIFskrrxIBHMZDkIuIg/Purpur-DS---Component-library-%26-guidelines?type=design&node-id=33657%3A20978&mode=design&t=5WYoIWv1It545kCs-1",
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
name: "Radio button",
|
|
23
|
+
type: "figma",
|
|
24
|
+
url: "https://www.figma.com/file/XEaIIFskrrxIBHMZDkIuIg/Purpur-DS---Component-library-%26-guidelines?type=design&node-id=1206%3A0&mode=design&t=5WYoIWv1It545kCs-1",
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
name: "Search input",
|
|
28
|
+
type: "figma",
|
|
29
|
+
url: "https://www.figma.com/file/XEaIIFskrrxIBHMZDkIuIg/Purpur-DS---Component-library-%26-guidelines?type=design&node-id=25720-16573&mode=design&t=5WYoIWv1It545kCs-0",
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
name: "Textarea",
|
|
33
|
+
type: "figma",
|
|
34
|
+
url: "https://www.figma.com/file/XEaIIFskrrxIBHMZDkIuIg/Purpur-DS---Component-library-%26-guidelines?type=design&node-id=1565%3A1896&mode=design&t=5WYoIWv1It545kCs-1",
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
name: "Text input",
|
|
38
|
+
type: "figma",
|
|
39
|
+
url: "https://www.figma.com/file/XEaIIFskrrxIBHMZDkIuIg/Purpur-DS---Component-library-%26-guidelines?type=design&node-id=1528%3A1886&mode=design&t=5WYoIWv1It545kCs-1",
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
name: "Toggle",
|
|
43
|
+
type: "figma",
|
|
44
|
+
url: "https://www.figma.com/file/XEaIIFskrrxIBHMZDkIuIg/Purpur-DS---Component-library-%26-guidelines?type=design&node-id=1187%3A108&mode=design&t=5WYoIWv1It545kCs-1",
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
},
|
|
48
|
+
argTypes: {
|
|
49
|
+
["data-testid"]: { control: { type: "text" } },
|
|
50
|
+
htmlFor: { control: { type: "text" } },
|
|
51
|
+
className: { control: { type: "text" } },
|
|
52
|
+
children: { control: { type: "text" } },
|
|
53
|
+
disabled: { control: { type: "boolean" } },
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
export default meta;
|
|
57
|
+
|
|
58
|
+
type Story = StoryObj<typeof Label>;
|
|
59
|
+
|
|
60
|
+
export const Showcase: Story = {
|
|
61
|
+
args: {
|
|
62
|
+
htmlFor: "firstName",
|
|
63
|
+
children: "First name",
|
|
64
|
+
disabled: false,
|
|
65
|
+
},
|
|
66
|
+
render: ({ children, htmlFor, ...args }) => (
|
|
67
|
+
<>
|
|
68
|
+
<Label htmlFor={htmlFor} {...args}>
|
|
69
|
+
{children}
|
|
70
|
+
</Label>
|
|
71
|
+
<div>
|
|
72
|
+
<input type="text" id={htmlFor} defaultValue="Xavier" />
|
|
73
|
+
</div>
|
|
74
|
+
</>
|
|
75
|
+
),
|
|
76
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import * as matchers from "@testing-library/jest-dom/matchers";
|
|
3
|
+
import { render, screen } from "@testing-library/react";
|
|
4
|
+
import { describe, expect, it } from "vitest";
|
|
5
|
+
|
|
6
|
+
import { Label, LabelProps } from "./label";
|
|
7
|
+
|
|
8
|
+
expect.extend(matchers);
|
|
9
|
+
|
|
10
|
+
const setup = ({
|
|
11
|
+
disabled,
|
|
12
|
+
"data-testid": dataTestId,
|
|
13
|
+
}: Pick<LabelProps, "disabled" | "data-testid">) =>
|
|
14
|
+
render(
|
|
15
|
+
<>
|
|
16
|
+
<Label htmlFor="firstName" data-testid={dataTestId} disabled={disabled}>
|
|
17
|
+
test
|
|
18
|
+
</Label>
|
|
19
|
+
<input type="text" id="firstName" defaultValue="Xavier" />
|
|
20
|
+
</>
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
describe("Label", () => {
|
|
24
|
+
it("should render label", () => {
|
|
25
|
+
setup({});
|
|
26
|
+
|
|
27
|
+
expect(screen.getByLabelText("test"));
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it("should have disabled class", () => {
|
|
31
|
+
setup({ disabled: true, "data-testid": "label" });
|
|
32
|
+
|
|
33
|
+
expect(screen.getByTestId("label")).toHaveClass("purpur-label--disabled");
|
|
34
|
+
});
|
|
35
|
+
});
|
package/src/label.tsx
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React, { ReactNode } from "react";
|
|
2
|
+
import * as RadixLabel from "@radix-ui/react-label";
|
|
3
|
+
import c from "classnames";
|
|
4
|
+
|
|
5
|
+
import styles from "./label.module.scss";
|
|
6
|
+
|
|
7
|
+
const rootClassName = "purpur-label";
|
|
8
|
+
|
|
9
|
+
export type LabelProps = {
|
|
10
|
+
"data-testid"?: string;
|
|
11
|
+
children: ReactNode;
|
|
12
|
+
className?: string;
|
|
13
|
+
htmlFor: string;
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
};
|
|
16
|
+
export const Label = ({
|
|
17
|
+
children,
|
|
18
|
+
className,
|
|
19
|
+
htmlFor,
|
|
20
|
+
"data-testid": dataTestId,
|
|
21
|
+
disabled,
|
|
22
|
+
...props
|
|
23
|
+
}: LabelProps) => {
|
|
24
|
+
const classes = c([
|
|
25
|
+
className,
|
|
26
|
+
styles[rootClassName],
|
|
27
|
+
{ [styles[`${rootClassName}--disabled`]]: disabled },
|
|
28
|
+
]);
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<RadixLabel.Root className={classes} data-testid={dataTestId} htmlFor={htmlFor} {...props}>
|
|
32
|
+
{children}
|
|
33
|
+
</RadixLabel.Root>
|
|
34
|
+
);
|
|
35
|
+
};
|