@agentero/design-system 0.27.1 → 0.28.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/lib/index.d.ts +1 -0
- package/lib/index.js +2 -1
- package/lib/merge-props.d.ts +42 -0
- package/lib/merge-props.js +24 -0
- package/mcp/manifests/components.html +796 -71
- package/mcp/manifests/components.json +500 -9
- package/package.json +10 -1
- package/src/alert/alert.js +28 -28
- package/src/avatar/avatar.js +22 -22
- package/src/avatar-group/avatar-group.js +6 -6
- package/src/button/button.js +7 -7
- package/src/data-table/data-table.js +36 -36
- package/src/field/context.d.ts +62 -0
- package/src/field/context.js +6 -0
- package/src/field/field.d.ts +214 -0
- package/src/field/field.js +129 -0
- package/src/field/icons.d.ts +9 -0
- package/src/field/icons.js +14 -0
- package/src/field/index.d.ts +30 -0
- package/src/field/index.js +13 -0
- package/src/field-text/field-text.d.ts +28 -0
- package/src/field-text/field-text.js +26 -0
- package/src/field-text/index.d.ts +2 -0
- package/src/field-text/index.js +2 -0
- package/src/input/context.d.ts +17 -0
- package/src/input/context.js +10 -0
- package/src/input/index.d.ts +1 -0
- package/src/input/index.js +3 -2
- package/src/input/input.d.ts +7 -7
- package/src/input/input.js +16 -11
- package/src/label/context.d.ts +13 -0
- package/src/label/context.js +7 -0
- package/src/label/index.d.ts +1 -0
- package/src/label/index.js +3 -2
- package/src/label/label.d.ts +6 -1
- package/src/label/label.js +19 -17
- package/src/modal/modal.js +23 -23
- package/src/progress/progress.js +9 -9
- package/src/switch/switch.js +7 -7
- package/src/table/table.js +28 -28
- package/src/tabs/tabs.js +26 -26
- package/src/tag/tag.js +7 -7
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -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 };
|