@agentero/design-system 0.27.1 → 0.29.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.
Files changed (50) hide show
  1. package/lib/index.d.ts +1 -0
  2. package/lib/index.js +2 -1
  3. package/lib/merge-props.d.ts +42 -0
  4. package/lib/merge-props.js +24 -0
  5. package/mcp/manifests/components.html +1258 -71
  6. package/mcp/manifests/components.json +1033 -9
  7. package/package.json +22 -1
  8. package/src/alert/alert.js +28 -28
  9. package/src/avatar/avatar.js +22 -22
  10. package/src/avatar-group/avatar-group.js +6 -6
  11. package/src/button/button.js +7 -7
  12. package/src/data-table/data-table.js +36 -36
  13. package/src/field/context.d.ts +70 -0
  14. package/src/field/context.js +6 -0
  15. package/src/field/field.d.ts +216 -0
  16. package/src/field/field.js +132 -0
  17. package/src/field/icons.d.ts +9 -0
  18. package/src/field/icons.js +14 -0
  19. package/src/field/index.d.ts +30 -0
  20. package/src/field/index.js +13 -0
  21. package/src/field-text/field-text.d.ts +28 -0
  22. package/src/field-text/field-text.js +26 -0
  23. package/src/field-text/index.d.ts +2 -0
  24. package/src/field-text/index.js +2 -0
  25. package/src/form/form.d.ts +60 -0
  26. package/src/form/form.js +16 -0
  27. package/src/form/index.d.ts +7 -0
  28. package/src/form/index.js +5 -0
  29. package/src/form-text/form-text.d.ts +136 -0
  30. package/src/form-text/form-text.js +40 -0
  31. package/src/form-text/index.d.ts +2 -0
  32. package/src/form-text/index.js +2 -0
  33. package/src/input/context.d.ts +17 -0
  34. package/src/input/context.js +10 -0
  35. package/src/input/index.d.ts +1 -0
  36. package/src/input/index.js +3 -2
  37. package/src/input/input.d.ts +7 -7
  38. package/src/input/input.js +16 -11
  39. package/src/label/context.d.ts +13 -0
  40. package/src/label/context.js +7 -0
  41. package/src/label/index.d.ts +1 -0
  42. package/src/label/index.js +3 -2
  43. package/src/label/label.d.ts +6 -1
  44. package/src/label/label.js +19 -17
  45. package/src/modal/modal.js +23 -23
  46. package/src/progress/progress.js +9 -9
  47. package/src/switch/switch.js +7 -7
  48. package/src/table/table.js +28 -28
  49. package/src/tabs/tabs.js +26 -26
  50. package/src/tag/tag.js +7 -7
package/lib/index.d.ts CHANGED
@@ -1 +1,2 @@
1
+ export * from './merge-props';
1
2
  export * from './utils';
package/lib/index.js CHANGED
@@ -1,2 +1,3 @@
1
1
  import { cn as e } from "./utils.js";
2
- export { e as cn };
2
+ import { chain as t, mergeProps as n, mergeRefs as r, useMergeProps as i } from "./merge-props.js";
3
+ export { t as chain, e as cn, n as mergeProps, r as mergeRefs, i as useMergeProps };
@@ -0,0 +1,42 @@
1
+ import { composeRefs } from '@radix-ui/react-compose-refs';
2
+ type Handler<Args extends unknown[]> = (...args: Args) => void;
3
+ /**
4
+ * Calls every callback in order with the same arguments. Skips the ones that
5
+ * are `null` or `undefined`, so optional handlers can be passed straight in.
6
+ */
7
+ export declare const chain: <Args extends unknown[]>(...callbacks: Array<Handler<Args> | null | undefined>) => (...args: Args) => void;
8
+ /**
9
+ * Merges several refs into one callback ref that assigns all of them. Radix's
10
+ * `composeRefs` under the design system's own name, so the whole `lib` surface
11
+ * reads the same: it honors React 19 cleanup functions — a callback ref that
12
+ * returns a cleanup gets it called on detach, the others are reset to `null`
13
+ * the classic way.
14
+ *
15
+ * Memoize the result (see `useMergeProps`): React re-runs a callback ref whose
16
+ * identity changed, so rebuilding it every render detaches and re-attaches
17
+ * every underlying ref each time.
18
+ */
19
+ export declare const mergeRefs: typeof composeRefs;
20
+ /**
21
+ * Merges props a component receives from a context under the props it was
22
+ * given directly. Own props win; a context is a default, never an override.
23
+ * Mirrors React Aria's `mergeProps`:
24
+ *
25
+ * - `on*` handlers present on both sides are chained, context first.
26
+ * - `aria-describedby` ids are concatenated (context first, de-duplicated).
27
+ * - `className` is merged with `cn`.
28
+ * - `ref`s present on both sides are merged with `mergeRefs`.
29
+ * - `id` and everything else: the own value wins when it is not `undefined`.
30
+ *
31
+ * With no context (`null`/`undefined`) the own props are returned untouched,
32
+ * so a component reading a context still behaves as before outside of it.
33
+ */
34
+ export declare const mergeProps: <P extends object>(contextProps: Partial<P> | null | undefined, ownProps: P) => P;
35
+ /**
36
+ * `mergeProps` for render time: same rules, but the merged `ref` keeps a stable
37
+ * identity across renders as long as the two underlying refs do, so React does
38
+ * not detach and re-attach them on every render. This is the hook every
39
+ * `useXContext(props)` in the design system is built on.
40
+ */
41
+ export declare const useMergeProps: <P extends object>(contextProps: Partial<P> | null | undefined, ownProps: P) => P;
42
+ export {};
@@ -0,0 +1,24 @@
1
+ import { cn as e } from "./utils.js";
2
+ import { useMemo as t } from "react";
3
+ import { composeRefs as n } from "@radix-ui/react-compose-refs";
4
+ //#region lib/merge-props.ts
5
+ var r = (...e) => (...t) => {
6
+ for (let n of e) n?.(...t);
7
+ }, i = n, a = (e, t) => [...new Set(`${e} ${t}`.split(/\s+/).filter(Boolean))].join(" "), o = (e) => /^on[A-Z]/.test(e), s = (t, n) => {
8
+ if (!t) return n;
9
+ let s = { ...t };
10
+ for (let [t, c] of Object.entries(n)) {
11
+ if (c === void 0) continue;
12
+ let n = s[t];
13
+ o(t) && typeof n == "function" && typeof c == "function" ? s[t] = r(n, c) : t === "aria-describedby" && typeof n == "string" && typeof c == "string" ? s[t] = a(n, c) : t === "className" && typeof n == "string" ? s[t] = e(n, c) : t === "ref" && n && c ? s[t] = i(n, c) : s[t] = c;
14
+ }
15
+ return s;
16
+ }, c = (e, n) => {
17
+ let r = e?.ref, a = n.ref, o = t(() => r && a ? i(r, a) : void 0, [r, a]), c = s(e, n);
18
+ return o ? {
19
+ ...c,
20
+ ref: o
21
+ } : c;
22
+ };
23
+ //#endregion
24
+ export { r as chain, s as mergeProps, i as mergeRefs, c as useMergeProps };