@cdx-ui/utils 0.0.1-beta.2 → 0.0.1-beta.21

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 +26 -21
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -14,42 +14,47 @@ 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'` 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. 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'` or `undefined` — shorthand for boolean ARIA attribute values. |
25
25
 
26
26
  ### Context
27
27
 
28
- | Export | Description |
29
- | --- | --- |
28
+ | Export | Description |
29
+ | ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
30
30
  | `createContext(displayName)` | Wrapper around React's `createContext` that returns a `[Provider, useHook]` tuple. The hook throws a descriptive error if called outside the provider — eliminates silent `undefined` bugs. |
31
31
 
32
32
  ### Style context
33
33
 
34
34
  Used internally by `@cdx-ui/components` to propagate variant props (size, color, etc.) from a compound root to its sub-components.
35
35
 
36
- | Export | Description |
37
- | --- | --- |
36
+ | Export | Description |
37
+ | ------------------------------------- | ---------------------------------------------------------------------------------- |
38
38
  | `withStyleContext(Component, scope?)` | HOC that adds a `context` prop and provides it to descendants via `ParentContext`. |
39
- | `useStyleContext(scope?)` | Reads the style context set by the nearest `withStyleContext` wrapper. |
40
- | `useParentContext()` | Reads the full `StyleContextMap` from the nearest provider. |
41
- | `ParentContext` | The raw React context (rarely needed directly). |
39
+ | `useStyleContext(scope?)` | Reads the style context set by the nearest `withStyleContext` wrapper. |
40
+ | `useParentContext()` | Reads the full `StyleContextMap` from the nearest provider. |
41
+ | `ParentContext` | The raw React context (rarely needed directly). |
42
42
 
43
43
  ### Form control
44
44
 
45
45
  Low-level form-field state used by the `Field` and `Input` primitives.
46
46
 
47
- | Export | Description |
48
- | --- | --- |
49
- | `useFormControlRoot(props)` | Creates the root state object for a form field (id generation, `aria-describedby` wiring). |
50
- | `useFormControl(props)` | Merges component-level props with inherited form-control context. |
51
- | `useFormControlContext()` | Reads form-control state from the nearest provider. |
52
- | `FormControlContext` | The raw React context for form-control state. |
47
+ | Export | Description |
48
+ | --------------------------- | --------------------------------------------------------------------------------------------------------- |
49
+ | `useFormControlRoot(props)` | Creates the root state object for a form field (id generation, `aria-describedby` wiring). |
50
+ | `useFormControl(props)` | Merges component-level props with inherited form-control context. |
51
+ | `useFormControlContext()` | Reads form-control state from the nearest provider. |
52
+ | `FormControlContext` | The raw React context for form-control state. |
53
+ | `FormControlContextValue` | Type: full context shape including field state, `id`, `labelId`, `feedbackId`, `helpTextId`, and setters. |
54
+ | `FormControlState` | Type: `{ isRequired, isInvalid, isDisabled, isReadOnly }`. |
55
+ | `FormControlRootProps` | Type: input props for `useFormControlRoot`. |
56
+ | `FormControlRootReturn` | Type: return value of `useFormControlRoot` (`htmlProps` + context fields). |
57
+ | `FormControlFieldProps` | Type: props accepted by `useFormControl` (field state flags + `id`). |
53
58
 
54
59
  ## Further reading
55
60
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cdx-ui/utils",
3
- "version": "0.0.1-beta.2",
3
+ "version": "0.0.1-beta.21",
4
4
  "main": "lib/commonjs/index.js",
5
5
  "module": "lib/module/index.js",
6
6
  "react-native": "src/index.ts",