@cdx-ui/utils 0.0.1-beta.60 → 0.0.1-beta.62

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.
Files changed (2) hide show
  1. package/README.md +38 -15
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -14,14 +14,14 @@ pnpm add @cdx-ui/utils
14
14
 
15
15
  ### Common helpers
16
16
 
17
- | Export | Description |
18
- | ----------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
19
- | `cn(...inputs)` | Merges class names with `clsx` + `tailwind-merge` — conditionals and conflict resolution in one call. |
20
- | `composeEventHandlers(...handlers)` | Chains multiple event callbacks into a single handler; skips `null`/`undefined` entries. |
21
- | `useControllableState(params)` | Hook that supports both controlled and uncontrolled modes for a single value. Warns in dev if the mode switches during a component's lifetime. |
22
- | `mergeRefs(...refs)` | Combines multiple refs (callback or object) into one ref callback. |
23
- | `flattenChildren(children)` | Recursively flattens React `children` into a flat array (used internally for spaced-child layouts). |
24
- | `ariaAttr(condition)` | Returns `true` (boolean) or `undefined` — shorthand for boolean ARIA attribute values. |
17
+ | Export | Description |
18
+ | ----------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
19
+ | `cn(...inputs)` | Merges class names with `clsx` + `tailwind-merge` — conditionals and conflict resolution in one call. |
20
+ | `composeEventHandlers(...handlers)` | Chains multiple event callbacks into a single handler; skips `null`/`undefined` entries. |
21
+ | `useControllableState(params)` | Hook that supports both controlled and uncontrolled modes for a single value. Derives `isControlled` from whether the prop is `undefined`. |
22
+ | `mergeRefs(...refs)` | Combines multiple refs (callback or object) into one ref callback. |
23
+ | `flattenChildren(children)` | Recursively flattens React `children` (including Fragments) into a flat array with re-keyed elements. |
24
+ | `ariaAttr(condition)` | Returns `true` (boolean) or `undefined` — shorthand for boolean ARIA attribute values. |
25
25
 
26
26
  ### Context
27
27
 
@@ -43,13 +43,36 @@ Used internally by `@cdx-ui/components` to propagate variant props (size, color,
43
43
 
44
44
  Low-level form-field state used by the `Field` and `Input` primitives.
45
45
 
46
- | Export | Description |
47
- | ------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
48
- | `useFormControlRoot(props)` | Creates the root state object for a form field (id generation, `aria-describedby` wiring). |
49
- | `useFormControl(props)` | Merges component-level props with inherited form-control context. |
50
- | `useFormControlContext()` | Reads form-control state from the nearest provider. |
51
- | `useReportFormControlLabelFocus(ref)` | Reports label focus/blur events to the parent `FormControlContext` — used by `Field.Label` to trigger `isFocused` styling on the associated input. |
52
- | `FormControlContext` | The React context object for form-control state propagation. |
46
+ | Export | Description |
47
+ | ------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
48
+ | `useFormControlRoot(props)` | Creates the root state object for a form field (id generation, tracks `hasFeedbackText`/`hasHelpText` for describedby assembly). |
49
+ | `useFormControl(props)` | Merges component-level props with inherited form-control context. Assembles `aria-describedby` from feedback/help text ids. |
50
+ | `useFormControlContext()` | Reads form-control state from the nearest provider. |
51
+ | `useReportFormControlLabelFocus(isActive)` | Reports focus/active state to the parent `FormControlContext` — used by `Input`/`Select.Trigger` to trigger `isFocused` styling on the associated label. |
52
+ | `FormControlContext` | The React context object for form-control state propagation. |
53
+
54
+ ## Exported types
55
+
56
+ | Type | Source |
57
+ | ---------------------------- | ------------ |
58
+ | `UseControllableStateParams` | common |
59
+ | `FormControlContextValue` | form-control |
60
+ | `FormControlFieldProps` | form-control |
61
+ | `FormControlRootProps` | form-control |
62
+ | `FormControlRootReturn` | form-control |
63
+ | `FormControlState` | form-control |
64
+ | `StyleContextMap` | style |
65
+ | `WithStyleContextProps` | style |
66
+
67
+ ## Testing
68
+
69
+ Tests are colocated next to source files (`*.test.{ts,tsx}`). Run via the `utils` Jest project:
70
+
71
+ ```bash
72
+ pnpm nx run @cdx-ui/utils:test
73
+ ```
74
+
75
+ All runtime exports have test coverage using `@testing-library/react-native` (`renderHook`, `act`).
53
76
 
54
77
  ## Further reading
55
78
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cdx-ui/utils",
3
- "version": "0.0.1-beta.60",
3
+ "version": "0.0.1-beta.62",
4
4
  "main": "lib/commonjs/index.js",
5
5
  "module": "lib/module/index.js",
6
6
  "react-native": "src/index.ts",