@cdx-ui/utils 0.0.1-beta.98 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +15 -6
- package/coverage.svg +1 -0
- package/lib/commonjs/common/cva.js +13 -0
- package/lib/commonjs/common/cva.js.map +1 -0
- package/lib/commonjs/common/index.js +7 -0
- package/lib/commonjs/common/index.js.map +1 -1
- package/lib/module/common/cva.js +4 -0
- package/lib/module/common/cva.js.map +1 -0
- package/lib/module/common/index.js +1 -0
- package/lib/module/common/index.js.map +1 -1
- package/lib/typescript/common/cva.d.ts +2 -0
- package/lib/typescript/common/cva.d.ts.map +1 -0
- package/lib/typescript/common/index.d.ts +1 -0
- package/lib/typescript/common/index.d.ts.map +1 -1
- package/package.json +13 -5
- package/src/common/cva.ts +1 -0
- package/src/common/index.ts +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright © 2026 Digital First Holdings LLC
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# @cdx-ui/utils
|
|
2
2
|
|
|
3
|
+

|
|
4
|
+
|
|
3
5
|
Shared utilities used across FDS packages.
|
|
4
6
|
|
|
5
7
|
Provides common helpers for styling, event handling, state management, and context propagation used by [`@cdx-ui/primitives`](../primitives/) and [`@cdx-ui/components`](../components/).
|
|
@@ -22,6 +24,7 @@ pnpm add @cdx-ui/utils
|
|
|
22
24
|
| `mergeRefs(...refs)` | Combines multiple refs (callback or object) into one ref callback. |
|
|
23
25
|
| `flattenChildren(children)` | Recursively flattens React `children` (including Fragments) into a flat array with re-keyed elements. |
|
|
24
26
|
| `ariaAttr(condition)` | Returns `true` (boolean) or `undefined` — shorthand for boolean ARIA attribute values. |
|
|
27
|
+
| `cva(base, config)` | Class Variance Authority helper for authoring variant-driven `className` builders. `VariantProps<typeof fn>` derives the prop type. |
|
|
25
28
|
|
|
26
29
|
### Context
|
|
27
30
|
|
|
@@ -33,11 +36,11 @@ pnpm add @cdx-ui/utils
|
|
|
33
36
|
|
|
34
37
|
Used internally by `@cdx-ui/components` to propagate variant props (size, color, etc.) from a compound root to its sub-components.
|
|
35
38
|
|
|
36
|
-
| Export
|
|
37
|
-
|
|
|
38
|
-
| `ParentContext`
|
|
39
|
-
| `useStyleContext(scope?)`
|
|
40
|
-
| `useParentContext()`
|
|
39
|
+
| Export | Description |
|
|
40
|
+
| ------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
41
|
+
| `ParentContext` | React context for propagating variant props from a compound root to sub-components. Wrap children in `<ParentContext.Provider value={...}>`. |
|
|
42
|
+
| `useStyleContext(scope?)` | Reads the style context set by the nearest `ParentContext.Provider`. |
|
|
43
|
+
| `useParentContext()` | Reads the full `StyleContextMap` from the nearest provider. |
|
|
41
44
|
|
|
42
45
|
### Form control
|
|
43
46
|
|
|
@@ -56,6 +59,7 @@ Low-level form-field state used by the `Field` and `Input` primitives.
|
|
|
56
59
|
| Type | Source |
|
|
57
60
|
| ---------------------------- | ------------ |
|
|
58
61
|
| `UseControllableStateParams` | common |
|
|
62
|
+
| `VariantProps` | common |
|
|
59
63
|
| `Focusable` | form-control |
|
|
60
64
|
| `FormControlContextValue` | form-control |
|
|
61
65
|
| `FormControlFieldProps` | form-control |
|
|
@@ -63,7 +67,6 @@ Low-level form-field state used by the `Field` and `Input` primitives.
|
|
|
63
67
|
| `FormControlRootReturn` | form-control |
|
|
64
68
|
| `FormControlState` | form-control |
|
|
65
69
|
| `StyleContextMap` | style |
|
|
66
|
-
| `WithStyleContextProps` | style |
|
|
67
70
|
|
|
68
71
|
## Testing
|
|
69
72
|
|
|
@@ -79,3 +82,9 @@ All runtime exports have test coverage using `@testing-library/react-native` (`r
|
|
|
79
82
|
|
|
80
83
|
- [State management practices](../../docs/internal/practices/state.md) — `useControllableState` and `composeEventHandlers` patterns
|
|
81
84
|
- [Styling practices](../../docs/internal/practices/styling.md) — `cn()` and CVA variant authoring
|
|
85
|
+
|
|
86
|
+
## License
|
|
87
|
+
|
|
88
|
+
[](./LICENSE)
|
|
89
|
+
|
|
90
|
+
MIT © 2026 Digital First Holdings LLC. See [LICENSE](./LICENSE) for details.
|
package/coverage.svg
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="114" height="20" role="img" aria-label="coverage: 100.0%"><title>coverage: 100.0%</title><filter id="blur"><feGaussianBlur stdDeviation="16"/></filter><linearGradient id="s" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="r"><rect width="114" height="20" rx="3"/></clipPath><g clip-path="url(#r)"><rect width="61" height="20" fill="#555"/><rect x="61" width="53" height="20" fill="#4b0"/><rect width="114" height="20" fill="url(#s)"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110"><g transform="scale(.1)"><g aria-hidden="true" fill="#010101"><text x="315" y="150" fill-opacity=".8" filter="url(#blur)" textLength="510">coverage</text><text x="315" y="150" fill-opacity=".3" textLength="510">coverage</text></g><text x="315" y="140" textLength="510">coverage</text></g><g transform="scale(.1)"><g aria-hidden="true" fill="#010101"><text x="865" y="150" fill-opacity=".8" filter="url(#blur)" textLength="430">100.0%</text><text x="865" y="150" fill-opacity=".3" textLength="430">100.0%</text></g><text x="865" y="140" textLength="430">100.0%</text></g></g></svg>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "cva", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _classVarianceAuthority.cva;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _classVarianceAuthority = require("class-variance-authority");
|
|
13
|
+
//# sourceMappingURL=cva.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_classVarianceAuthority","require"],"sourceRoot":"../../../src","sources":["common/cva.ts"],"mappings":";;;;;;;;;;;AAAA,IAAAA,uBAAA,GAAAC,OAAA","ignoreList":[]}
|
|
@@ -21,6 +21,12 @@ Object.defineProperty(exports, "composeEventHandlers", {
|
|
|
21
21
|
return _composeEventHandlers.composeEventHandlers;
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
|
+
Object.defineProperty(exports, "cva", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return _cva.cva;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
24
30
|
Object.defineProperty(exports, "flattenChildren", {
|
|
25
31
|
enumerable: true,
|
|
26
32
|
get: function () {
|
|
@@ -41,6 +47,7 @@ Object.defineProperty(exports, "useControllableState", {
|
|
|
41
47
|
});
|
|
42
48
|
var _accessibilityUtils = require("./accessibilityUtils");
|
|
43
49
|
var _cn = require("./cn");
|
|
50
|
+
var _cva = require("./cva");
|
|
44
51
|
var _composeEventHandlers = require("./composeEventHandlers");
|
|
45
52
|
var _getSpacedChild = require("./getSpacedChild");
|
|
46
53
|
var _mergeRefs = require("./mergeRefs");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_accessibilityUtils","require","_cn","_composeEventHandlers","_getSpacedChild","_mergeRefs","_useControllableState"],"sourceRoot":"../../../src","sources":["common/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"names":["_accessibilityUtils","require","_cn","_cva","_composeEventHandlers","_getSpacedChild","_mergeRefs","_useControllableState"],"sourceRoot":"../../../src","sources":["common/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,mBAAA,GAAAC,OAAA;AACA,IAAAC,GAAA,GAAAD,OAAA;AACA,IAAAE,IAAA,GAAAF,OAAA;AACA,IAAAG,qBAAA,GAAAH,OAAA;AACA,IAAAI,eAAA,GAAAJ,OAAA;AACA,IAAAK,UAAA,GAAAL,OAAA;AACA,IAAAM,qBAAA,GAAAN,OAAA","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["cva"],"sourceRoot":"../../../src","sources":["common/cva.ts"],"mappings":";;AAAA,SAASA,GAAG,QAA2B,0BAA0B","ignoreList":[]}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
export { ariaAttr } from './accessibilityUtils';
|
|
4
4
|
export { cn } from './cn';
|
|
5
|
+
export { cva } from './cva';
|
|
5
6
|
export { composeEventHandlers } from './composeEventHandlers';
|
|
6
7
|
export { flattenChildren } from './getSpacedChild';
|
|
7
8
|
export { mergeRefs } from './mergeRefs';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ariaAttr","cn","composeEventHandlers","flattenChildren","mergeRefs","useControllableState"],"sourceRoot":"../../../src","sources":["common/index.ts"],"mappings":";;AAAA,SAASA,QAAQ,QAAQ,sBAAsB;AAC/C,SAASC,EAAE,QAAQ,MAAM;AACzB,SAASC,oBAAoB,QAAQ,wBAAwB;AAC7D,SAASC,eAAe,QAAQ,kBAAkB;AAClD,SAASC,SAAS,QAAQ,aAAa;AACvC,SAA0CC,oBAAoB,QAAQ,wBAAwB","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["ariaAttr","cn","cva","composeEventHandlers","flattenChildren","mergeRefs","useControllableState"],"sourceRoot":"../../../src","sources":["common/index.ts"],"mappings":";;AAAA,SAASA,QAAQ,QAAQ,sBAAsB;AAC/C,SAASC,EAAE,QAAQ,MAAM;AACzB,SAASC,GAAG,QAA2B,OAAO;AAC9C,SAASC,oBAAoB,QAAQ,wBAAwB;AAC7D,SAASC,eAAe,QAAQ,kBAAkB;AAClD,SAASC,SAAS,QAAQ,aAAa;AACvC,SAA0CC,oBAAoB,QAAQ,wBAAwB","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cva.d.ts","sourceRoot":"","sources":["../../../src/common/cva.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { ariaAttr } from './accessibilityUtils';
|
|
2
2
|
export { cn } from './cn';
|
|
3
|
+
export { cva, type VariantProps } from './cva';
|
|
3
4
|
export { composeEventHandlers } from './composeEventHandlers';
|
|
4
5
|
export { flattenChildren } from './getSpacedChild';
|
|
5
6
|
export { mergeRefs } from './mergeRefs';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/common/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAC1B,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,KAAK,0BAA0B,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/common/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAC1B,OAAO,EAAE,GAAG,EAAE,KAAK,YAAY,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,KAAK,0BAA0B,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cdx-ui/utils",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/dfh-candescent-ui/ui-component-framework",
|
|
8
|
+
"directory": "packages/utils"
|
|
9
|
+
},
|
|
4
10
|
"main": "lib/commonjs/index.js",
|
|
5
11
|
"module": "lib/module/index.js",
|
|
6
12
|
"react-native": "src/index.ts",
|
|
@@ -17,7 +23,8 @@
|
|
|
17
23
|
},
|
|
18
24
|
"files": [
|
|
19
25
|
"lib",
|
|
20
|
-
"src"
|
|
26
|
+
"src",
|
|
27
|
+
"coverage.svg"
|
|
21
28
|
],
|
|
22
29
|
"react-native-builder-bob": {
|
|
23
30
|
"source": "src",
|
|
@@ -30,6 +37,7 @@
|
|
|
30
37
|
]
|
|
31
38
|
},
|
|
32
39
|
"dependencies": {
|
|
40
|
+
"class-variance-authority": "^0.7.1",
|
|
33
41
|
"clsx": "2.1.1",
|
|
34
42
|
"tailwind-merge": "3.5.0"
|
|
35
43
|
},
|
|
@@ -47,10 +55,10 @@
|
|
|
47
55
|
}
|
|
48
56
|
},
|
|
49
57
|
"devDependencies": {
|
|
50
|
-
"@types/react": "
|
|
58
|
+
"@types/react": "19.1.17",
|
|
51
59
|
"@types/react-dom": "*",
|
|
52
|
-
"react": "
|
|
53
|
-
"react-dom": "
|
|
60
|
+
"react": "19.1.0",
|
|
61
|
+
"react-dom": "19.1.0",
|
|
54
62
|
"react-native": "*",
|
|
55
63
|
"react-native-builder-bob": "*",
|
|
56
64
|
"react-native-web": "*",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { cva, type VariantProps } from 'class-variance-authority';
|
package/src/common/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { ariaAttr } from './accessibilityUtils';
|
|
2
2
|
export { cn } from './cn';
|
|
3
|
+
export { cva, type VariantProps } from './cva';
|
|
3
4
|
export { composeEventHandlers } from './composeEventHandlers';
|
|
4
5
|
export { flattenChildren } from './getSpacedChild';
|
|
5
6
|
export { mergeRefs } from './mergeRefs';
|