@nadicodeai/ui 12.1.72 → 12.1.74

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.
@@ -70,12 +70,14 @@ export type ModelSelectProps = Omit<ComponentProps<typeof SelectPrimitive.Trigge
70
70
  onValueChange: (model: string) => void;
71
71
  /** What the trigger reads while no model is chosen. */
72
72
  placeholder: string;
73
+ /** The product's own name for a model id, when its runtime names models itself. */
74
+ nameOf?: (model: string) => string;
73
75
  };
74
76
  /**
75
77
  * A model chosen from a list: the trigger and every option read the model the
76
78
  * way every surface does, with its maker's mark (`ModelIdentity`).
77
79
  */
78
- export declare function ModelSelect({ value, options, onValueChange, placeholder, disabled, className, ...props }: ModelSelectProps): import("react").JSX.Element;
80
+ export declare function ModelSelect({ value, options, onValueChange, placeholder, nameOf, disabled, className, ...props }: ModelSelectProps): import("react").JSX.Element;
79
81
  export type SegmentedChoiceProps<Choice extends string> = Omit<ComponentProps<typeof RadioGroup>, "children" | "defaultValue" | "onValueChange" | "value"> & {
80
82
  value: Choice | null;
81
83
  options: readonly {
@@ -1 +1 @@
1
- {"version":3,"file":"agent-profile.d.ts","sourceRoot":"","sources":["../../src/components/agent-profile.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,IAAI,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAElE,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAK5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAIhD,OAAO,EAAkB,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAe,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAMnE,+EAA+E;AAC/E,MAAM,MAAM,gBAAgB,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC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AAM,EACN,UAAU,EACV,OAAO,EACP,YAAY,GACb,EAAE,qBAAqB,+BAoGvB;AAED,MAAM,MAAM,gBAAgB,GAAG,IAAI,CACjC,cAAc,CAAC,OAAO,eAAe,CAAC,OAAO,CAAC,EAC9C,UAAU,GAAG,OAAO,GAAG,UAAU,CAClC,GAAG;IACF,yDAAyD;IACzD,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,8DAA8D;IAC9D,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3B,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,uDAAuD;IACvD,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF;;;GAGG;AACH,wBAAgB,WAAW,CAAC,EAC1B,KAAK,EACL,OAAO,EACP,aAAa,EACb,WAAW,EACX,QAAQ,EACR,SAAS,EACT,GAAG,KAAK,EACT,EAAE,gBAAgB,+BAkClB;AAED,MAAM,MAAM,oBAAoB,CAAC,MAAM,SAAS,MAAM,IAAI,IAAI,CAC5D,cAAc,CAAC,OAAO,UAAU,CAAC,EACjC,UAAU,GAAG,cAAc,GAAG,eAAe,GAAG,OAAO,CACxD,GAAG;IACF,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,OAAO,EAAE,SAAS;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACrD,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACxC,CAAC;AAEF;;;GAGG;AACH,wBAAgB,eAAe,CAAC,MAAM,SAAS,MAAM,EAAE,EACrD,KAAK,EACL,OAAO,EACP,aAAa,EACb,QAAQ,EACR,SAAS,EACT,GAAG,KAAK,EACT,EAAE,oBAAoB,CAAC,MAAM,CAAC,+BA8B9B"}
1
+ {"version":3,"file":"agent-profile.d.ts","sourceRoot":"","sources":["../../src/components/agent-profile.tsx"],"names":[],"mappings":"AAGA,O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,UAAU,GAAG,cAAc,GAAG,eAAe,GAAG,OAAO,CACxD,GAAG;IACF,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,OAAO,EAAE,SAAS;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACrD,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACxC,CAAC;AAEF;;;GAGG;AACH,wBAAgB,eAAe,CAAC,MAAM,SAAS,MAAM,EAAE,EACrD,KAAK,EACL,OAAO,EACP,aAAa,EACb,QAAQ,EACR,SAAS,EACT,GAAG,KAAK,EACT,EAAE,oBAAoB,CAAC,MAAM,CAAC,+BA8B9B"}
@@ -41,11 +41,11 @@ export function AgentProfileCard({ orb, name, description, descriptionMissingLab
41
41
  * A model chosen from a list: the trigger and every option read the model the
42
42
  * way every surface does, with its maker's mark (`ModelIdentity`).
43
43
  */
44
- export function ModelSelect({ value, options, onValueChange, placeholder, disabled, className, ...props }) {
44
+ export function ModelSelect({ value, options, onValueChange, placeholder, nameOf, disabled, className, ...props }) {
45
45
  return (_jsxs(Select, { disabled: disabled, onValueChange: (model) => {
46
46
  if (typeof model === "string")
47
47
  onValueChange(model);
48
- }, value: value, children: [_jsx(SelectTrigger, { className: cn("w-full min-w-0", className), ...props, children: _jsx(SelectPrimitive.Value, { className: "flex min-w-0 flex-1 items-center gap-1.5 text-left", "data-slot": "select-value", children: (model) => model ? (_jsx(ModelIdentity, { className: "min-w-0", markSize: 20, model: model })) : (_jsx("span", { className: "text-placeholder", children: placeholder })) }) }), _jsx(SelectContent, { align: "start", alignItemWithTrigger: false, children: _jsx(SelectGroup, { children: options.map((model) => (_jsx(SelectItem, { value: model, children: _jsx(ModelIdentity, { markSize: 20, model: model }) }, model))) }) })] }));
48
+ }, value: value, children: [_jsx(SelectTrigger, { className: cn("w-full min-w-0", className), ...props, children: _jsx(SelectPrimitive.Value, { className: "flex min-w-0 flex-1 items-center gap-1.5 text-left", "data-slot": "select-value", children: (model) => model ? (_jsx(ModelIdentity, { className: "min-w-0", markSize: 20, model: model, name: nameOf?.(model) })) : (_jsx("span", { className: "text-placeholder", children: placeholder })) }) }), _jsx(SelectContent, { align: "start", alignItemWithTrigger: false, children: _jsx(SelectGroup, { children: options.map((model) => (_jsx(SelectItem, { value: model, children: _jsx(ModelIdentity, { markSize: 20, model: model, name: nameOf?.(model) }) }, model))) }) })] }));
49
49
  }
50
50
  /**
51
51
  * One choice among a few short levels, drawn as segments that share a row,
@@ -13,13 +13,16 @@ export declare function modelAuthor(model: string): string;
13
13
  export declare function modelDisplayName(model: string): string;
14
14
  export type ModelIdentityProps = Omit<ComponentPropsWithoutRef<"span">, "children"> & {
15
15
  model: string;
16
+ name?: string | undefined;
16
17
  markSize?: number;
17
18
  };
18
19
  /**
19
20
  * A model as every surface reads it: the maker's mark, one name, the muted
20
21
  * maker. Callers pass the id and nothing else about its shape — the split, the
21
22
  * name form and the mark all belong here, so a ranked list, a routing table and
22
- * a settings row cannot drift into three readings of the same model.
23
+ * a settings row cannot drift into three readings of the same model. A product
24
+ * whose runtime names its models itself, as Hermes does in Nadia, passes that
25
+ * `name` so a model reads the same in its settings as in its chat.
23
26
  */
24
- export declare function ModelIdentity({ model, markSize, ...props }: ModelIdentityProps): import("react").JSX.Element;
27
+ export declare function ModelIdentity({ model, name, markSize, ...props }: ModelIdentityProps): import("react").JSX.Element;
25
28
  //# sourceMappingURL=model-identity.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"model-identity.d.ts","sourceRoot":"","sources":["../../src/components/model-identity.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,OAAO,CAAC;AAItD;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAGjD;AAUD;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAKtD;AAED,MAAM,MAAM,kBAAkB,GAAG,IAAI,CAAC,wBAAwB,CAAC,MAAM,CAAC,EAAE,UAAU,CAAC,GAAG;IACpF,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,kBAAkB,+BAS9E"}
1
+ {"version":3,"file":"model-identity.d.ts","sourceRoot":"","sources":["../../src/components/model-identity.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,OAAO,CAAC;AAItD;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAGjD;AAUD;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAKtD;AAED,MAAM,MAAM,kBAAkB,GAAG,IAAI,CAAC,wBAAwB,CAAC,MAAM,CAAC,EAAE,UAAU,CAAC,GAAG;IACpF,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,kBAAkB,+BASpF"}
@@ -32,8 +32,10 @@ export function modelDisplayName(model) {
32
32
  * A model as every surface reads it: the maker's mark, one name, the muted
33
33
  * maker. Callers pass the id and nothing else about its shape — the split, the
34
34
  * name form and the mark all belong here, so a ranked list, a routing table and
35
- * a settings row cannot drift into three readings of the same model.
35
+ * a settings row cannot drift into three readings of the same model. A product
36
+ * whose runtime names its models itself, as Hermes does in Nadia, passes that
37
+ * `name` so a model reads the same in its settings as in its chat.
36
38
  */
37
- export function ModelIdentity({ model, markSize, ...props }) {
38
- return (_jsx(ModelMark, { author: modelAuthor(model), name: modelDisplayName(model), ...(markSize === undefined ? {} : { size: markSize }), ...props }));
39
+ export function ModelIdentity({ model, name, markSize, ...props }) {
40
+ return (_jsx(ModelMark, { author: modelAuthor(model), name: name ?? modelDisplayName(model), ...(markSize === undefined ? {} : { size: markSize }), ...props }));
39
41
  }
@@ -2,7 +2,7 @@ import * as React from "react";
2
2
  type NativeSelectProps = Omit<React.ComponentProps<"select">, "size"> & {
3
3
  size?: "sm" | "default";
4
4
  };
5
- declare function NativeSelect({ className, size, ...props }: NativeSelectProps): React.JSX.Element;
5
+ declare function NativeSelect({ className, size, ref, ...props }: NativeSelectProps): React.JSX.Element;
6
6
  declare function NativeSelectOption({ className, ...props }: React.ComponentProps<"option">): React.JSX.Element;
7
7
  declare function NativeSelectOptGroup({ className, ...props }: React.ComponentProps<"optgroup">): React.JSX.Element;
8
8
  export { NativeSelect, NativeSelectOptGroup, NativeSelectOption };
@@ -1 +1 @@
1
- {"version":3,"file":"native-select.d.ts","sourceRoot":"","sources":["../../src/components/native-select.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,KAAK,iBAAiB,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,GAAG;IACtE,IAAI,CAAC,EAAE,IAAI,GAAG,SAAS,CAAC;CACzB,CAAC;AAEF,iBAAS,YAAY,CAAC,EAAE,SAAS,EAAE,IAAgB,EAAE,GAAG,KAAK,EAAE,EAAE,iBAAiB,qBAuBjF;AAED,iBAAS,kBAAkB,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC,qBAQlF;AAED,iBAAS,oBAAoB,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,KAAK,CAAC,cAAc,CAAC,UAAU,CAAC,qBAQtF;AAED,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,CAAC"}
1
+ {"version":3,"file":"native-select.d.ts","sourceRoot":"","sources":["../../src/components/native-select.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,KAAK,iBAAiB,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,GAAG;IACtE,IAAI,CAAC,EAAE,IAAI,GAAG,SAAS,CAAC;CACzB,CAAC;AAEF,iBAAS,YAAY,CAAC,EAAE,SAAS,EAAE,IAAgB,EAAE,GAAG,EAAE,GAAG,KAAK,EAAE,EAAE,iBAAiB,qBA4DtF;AAED,iBAAS,kBAAkB,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC,qBAQlF;AAED,iBAAS,oBAAoB,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,KAAK,CAAC,cAAc,CAAC,UAAU,CAAC,qBAQtF;AAED,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,CAAC"}
@@ -1,8 +1,48 @@
1
+ "use client";
1
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import * as React from "react";
2
4
  import { cn } from "../lib/utils.js";
3
5
  import { ChevronDownIcon } from "lucide-react";
4
- function NativeSelect({ className, size = "default", ...props }) {
5
- return (_jsxs("div", { className: cn("group/native-select relative w-fit has-[select:disabled]:opacity-50", className), "data-slot": "native-select-wrapper", "data-size": size, children: [_jsx("select", { "data-slot": "native-select", "data-size": size, className: "h-control-height min-h-touch-target w-full min-w-0 appearance-none rounded-md border border-input bg-background py-1 pr-8 pl-control-padding-inline text-sm transition-colors select-none selection:bg-primary selection:text-primary-foreground placeholder:text-placeholder disabled:pointer-events-none disabled:cursor-not-allowed aria-invalid:border-destructive data-[size=sm]:h-7 data-[size=sm]:py-0.5 [@media(hover:hover)_and_(pointer:fine)]:min-h-0", ...props }), _jsx(ChevronDownIcon, { className: "pointer-events-none absolute top-1/2 right-2.5 size-4 -translate-y-1/2 text-muted-foreground select-none", "aria-hidden": "true", "data-slot": "native-select-icon" })] }));
6
+ function NativeSelect({ className, size = "default", ref, ...props }) {
7
+ const select = React.useRef(null);
8
+ const setRef = React.useCallback((node) => {
9
+ select.current = node;
10
+ const cleanup = typeof ref === "function" ? ref(node) : undefined;
11
+ if (ref && typeof ref !== "function")
12
+ ref.current = node;
13
+ return () => {
14
+ select.current = null;
15
+ if (typeof cleanup === "function")
16
+ cleanup();
17
+ else if (typeof ref === "function")
18
+ ref(null);
19
+ else if (ref)
20
+ ref.current = null;
21
+ };
22
+ }, [ref]);
23
+ // React sets an uncontrolled select's default only when it mounts, and resets
24
+ // a form to that default after its action returns, so a saved value would
25
+ // snap back to the one the page loaded with.
26
+ const defaultKey = props.defaultValue === undefined
27
+ ? undefined
28
+ : JSON.stringify([props.defaultValue].flat().map(String));
29
+ const appliedDefault = React.useRef(defaultKey);
30
+ React.useLayoutEffect(() => {
31
+ const node = select.current;
32
+ if (defaultKey === undefined || !node || defaultKey === appliedDefault.current)
33
+ return;
34
+ const options = [...node.options];
35
+ const shown = options.filter((option) => option.selected).map((option) => option.value);
36
+ const stillShowsOldDefault = JSON.stringify(shown) === appliedDefault.current;
37
+ const wanted = new Set(JSON.parse(defaultKey));
38
+ for (const option of options)
39
+ option.defaultSelected = wanted.has(option.value);
40
+ if (!stillShowsOldDefault)
41
+ for (const option of options)
42
+ option.selected = shown.includes(option.value);
43
+ appliedDefault.current = defaultKey;
44
+ }, [defaultKey]);
45
+ return (_jsxs("div", { className: cn("group/native-select relative w-fit has-[select:disabled]:opacity-50", className), "data-slot": "native-select-wrapper", "data-size": size, children: [_jsx("select", { ref: setRef, "data-slot": "native-select", "data-size": size, className: "h-control-height min-h-touch-target w-full min-w-0 appearance-none rounded-md border border-input bg-background py-1 pr-8 pl-control-padding-inline text-sm transition-colors select-none selection:bg-primary selection:text-primary-foreground placeholder:text-placeholder disabled:pointer-events-none disabled:cursor-not-allowed aria-invalid:border-destructive data-[size=sm]:h-7 data-[size=sm]:py-0.5 [@media(hover:hover)_and_(pointer:fine)]:min-h-0", ...props }), _jsx(ChevronDownIcon, { className: "pointer-events-none absolute top-1/2 right-2.5 size-4 -translate-y-1/2 text-muted-foreground select-none", "aria-hidden": "true", "data-slot": "native-select-icon" })] }));
6
46
  }
7
47
  function NativeSelectOption({ className, ...props }) {
8
48
  return (_jsx("option", { "data-slot": "native-select-option", className: cn("bg-[Canvas] text-[CanvasText]", className), ...props }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nadicodeai/ui",
3
- "version": "12.1.72",
3
+ "version": "12.1.74",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -75,7 +75,7 @@
75
75
  "@base-ui/react": "^1.8.0",
76
76
  "@iconify-icons/logos": "^2.0.2",
77
77
  "@iconify/react": "^6.0.2",
78
- "@nadicodeai/design-system": "12.1.72",
78
+ "@nadicodeai/design-system": "12.1.74",
79
79
  "@tanstack/react-table": "^9.2.4",
80
80
  "class-variance-authority": "^0.7.1",
81
81
  "clsx": "^2.1.1",