@nadicodeai/ui 6.1.0 → 6.2.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/dist/components/forma-appearance.d.ts +13 -0
- package/dist/components/forma-appearance.d.ts.map +1 -0
- package/dist/components/forma-appearance.js +11 -0
- package/dist/internal/forma/stored-appearance.d.ts +29 -0
- package/dist/internal/forma/stored-appearance.d.ts.map +1 -0
- package/dist/internal/forma/stored-appearance.js +53 -0
- package/docs/forma-avatar.md +18 -0
- package/package.json +2 -2
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The stored appearance, reachable from a server. `forma-avatar.tsx` is a
|
|
3
|
+
* `"use client"` module, and under React Server Components every export of one
|
|
4
|
+
* becomes a client reference — a re-exported pure function included, which a
|
|
5
|
+
* server caller can only fail to invoke. A product whose server resolves an
|
|
6
|
+
* Agent's look before it renders the avatar (the Portal builds its rows that
|
|
7
|
+
* way) imports the resolver from here, and so does every other consumer: the
|
|
8
|
+
* avatar comes from `@nadicodeai/ui/components/forma-avatar`, the stored
|
|
9
|
+
* spelling from this module, and neither re-exports the other.
|
|
10
|
+
*/
|
|
11
|
+
export { type StoredAppearance, defaultShape, formaColorValues, resolveAppearance, shapeFor, } from "../internal/forma/stored-appearance.js";
|
|
12
|
+
export { type FormaChoice, type FormaColor, type FormaForm, type FormaState, } from "../internal/forma/model.js";
|
|
13
|
+
//# sourceMappingURL=forma-appearance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"forma-appearance.d.ts","sourceRoot":"","sources":["../../src/components/forma-appearance.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EACL,KAAK,gBAAgB,EACrB,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,EACjB,QAAQ,GACT,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,UAAU,GAChB,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The stored appearance, reachable from a server. `forma-avatar.tsx` is a
|
|
3
|
+
* `"use client"` module, and under React Server Components every export of one
|
|
4
|
+
* becomes a client reference — a re-exported pure function included, which a
|
|
5
|
+
* server caller can only fail to invoke. A product whose server resolves an
|
|
6
|
+
* Agent's look before it renders the avatar (the Portal builds its rows that
|
|
7
|
+
* way) imports the resolver from here, and so does every other consumer: the
|
|
8
|
+
* avatar comes from `@nadicodeai/ui/components/forma-avatar`, the stored
|
|
9
|
+
* spelling from this module, and neither re-exports the other.
|
|
10
|
+
*/
|
|
11
|
+
export { defaultShape, formaColorValues, resolveAppearance, shapeFor, } from "../internal/forma/stored-appearance.js";
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type FormaChoice, type FormaColor } from "./model.js";
|
|
2
|
+
/** What Hermes stores for an Agent's look. Both may be absent or unknown. */
|
|
3
|
+
export interface StoredAppearance {
|
|
4
|
+
shape?: string | null;
|
|
5
|
+
color?: string | null;
|
|
6
|
+
}
|
|
7
|
+
/** The `shape` value a chosen form is stored as. */
|
|
8
|
+
export declare const shapeFor: (form: FormaChoice) => string;
|
|
9
|
+
/** The stored shape of the form an Agent wears until a customer chooses one. */
|
|
10
|
+
export declare const defaultShape: string;
|
|
11
|
+
/**
|
|
12
|
+
* The hex each palette colour is stored as. Hermes keeps an Agent's colour as
|
|
13
|
+
* a CSS colour for its own surfaces, so the stored spelling is a value rather
|
|
14
|
+
* than a token reference; `stored-appearance.test.ts` holds this table to the
|
|
15
|
+
* shipped design-system tokens, and the ESLint colour-literal exemption in the
|
|
16
|
+
* root config names this file.
|
|
17
|
+
*/
|
|
18
|
+
export declare const formaColorValues: Record<FormaColor, string>;
|
|
19
|
+
/**
|
|
20
|
+
* Resolve the stored strings to what `FormaAvatar` draws. An unknown shape is
|
|
21
|
+
* the default form and an unknown colour is undefined, which leaves the form
|
|
22
|
+
* its own pigment. The root Agent is the caller's business: a caller that owns
|
|
23
|
+
* one passes `form="nadia"` instead of asking here.
|
|
24
|
+
*/
|
|
25
|
+
export declare function resolveAppearance(stored: StoredAppearance): {
|
|
26
|
+
form: FormaChoice;
|
|
27
|
+
color: FormaColor | undefined;
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=stored-appearance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stored-appearance.d.ts","sourceRoot":"","sources":["../../../src/internal/forma/stored-appearance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,UAAU,EAA0C,MAAM,SAAS,CAAC;AAEpG,6EAA6E;AAC7E,MAAM,WAAW,gBAAgB;IAC/B,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB;AAED,oDAAoD;AACpD,eAAO,MAAM,QAAQ,GAAI,MAAM,WAAW,KAAG,MAAyB,CAAC;AAEvE,gFAAgF;AAChF,eAAO,MAAM,YAAY,EAAE,MAA8B,CAAC;AAc1D;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,UAAU,EAAE,MAAM,CAOvD,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,gBAAgB,GAAG;IAC3D,IAAI,EAAE,WAAW,CAAC;IAClB,KAAK,EAAE,UAAU,GAAG,SAAS,CAAC;CAC/B,CAEA"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { defaultForm, formaChoices, formaColors } from "./model.js";
|
|
2
|
+
/** The `shape` value a chosen form is stored as. */
|
|
3
|
+
export const shapeFor = (form) => `forma:${form}`;
|
|
4
|
+
/** The stored shape of the form an Agent wears until a customer chooses one. */
|
|
5
|
+
export const defaultShape = shapeFor(defaultForm);
|
|
6
|
+
/**
|
|
7
|
+
* The five role names the launch Agents were stored under, each kept at the
|
|
8
|
+
* form it wore. Forms are shapes, never roles: nothing new is stored this way.
|
|
9
|
+
*/
|
|
10
|
+
const legacyShapes = new Map([
|
|
11
|
+
["forma:research", "uovo"],
|
|
12
|
+
["forma:build", "goccia"],
|
|
13
|
+
["forma:design", "nuvola"],
|
|
14
|
+
["forma:operate", "quadrato"],
|
|
15
|
+
["forma:review", "esagono"],
|
|
16
|
+
]);
|
|
17
|
+
/**
|
|
18
|
+
* The hex each palette colour is stored as. Hermes keeps an Agent's colour as
|
|
19
|
+
* a CSS colour for its own surfaces, so the stored spelling is a value rather
|
|
20
|
+
* than a token reference; `stored-appearance.test.ts` holds this table to the
|
|
21
|
+
* shipped design-system tokens, and the ESLint colour-literal exemption in the
|
|
22
|
+
* root config names this file.
|
|
23
|
+
*/
|
|
24
|
+
export const formaColorValues = {
|
|
25
|
+
verde: "#00a85a",
|
|
26
|
+
cobalto: "#1e3cff",
|
|
27
|
+
rosso: "#d3302f",
|
|
28
|
+
arancio: "#ff5a1f",
|
|
29
|
+
giallo: "#ffc220",
|
|
30
|
+
avorio: "#e9e7db",
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Resolve the stored strings to what `FormaAvatar` draws. An unknown shape is
|
|
34
|
+
* the default form and an unknown colour is undefined, which leaves the form
|
|
35
|
+
* its own pigment. The root Agent is the caller's business: a caller that owns
|
|
36
|
+
* one passes `form="nadia"` instead of asking here.
|
|
37
|
+
*/
|
|
38
|
+
export function resolveAppearance(stored) {
|
|
39
|
+
return { form: formFor(stored.shape), color: colorFor(stored.color) };
|
|
40
|
+
}
|
|
41
|
+
function formFor(shape) {
|
|
42
|
+
if (!shape)
|
|
43
|
+
return defaultForm;
|
|
44
|
+
// A Map, not an object: the shape is a stored string from a machine, and an
|
|
45
|
+
// object lookup would hand back `toString` or `constructor` for those spellings.
|
|
46
|
+
return (formaChoices.find((form) => shape === shapeFor(form)) ?? legacyShapes.get(shape) ?? defaultForm);
|
|
47
|
+
}
|
|
48
|
+
function colorFor(color) {
|
|
49
|
+
if (!color)
|
|
50
|
+
return undefined;
|
|
51
|
+
const stored = color.toLowerCase();
|
|
52
|
+
return formaColors.find((name) => stored === formaColorValues[name] || color === name);
|
|
53
|
+
}
|
package/docs/forma-avatar.md
CHANGED
|
@@ -88,5 +88,23 @@ exposes `data-forma-avatar`, `data-state`, `data-color` on its host and
|
|
|
88
88
|
`defaultForm`) are exported beside it for pickers and stored-appearance
|
|
89
89
|
mapping; the geometry, rig and frame computation are internal.
|
|
90
90
|
|
|
91
|
+
The stored appearance resolves in this package too, so every product draws one
|
|
92
|
+
Agent the same way. `StoredAppearance` is the pair of strings a product stores, `shape`
|
|
93
|
+
and `color`, either of which may be absent or unknown. `resolveAppearance`
|
|
94
|
+
answers the `form` and `color` the avatar takes: an unknown shape is
|
|
95
|
+
`defaultForm`, the five retired role shapes keep the form each one wore, and an
|
|
96
|
+
unknown colour is `undefined`, which leaves the form its own pigment. A stored
|
|
97
|
+
colour matches a palette hex in any case or the bare colour name.
|
|
98
|
+
The resolver lives in `@nadicodeai/ui/components/forma-appearance`, which
|
|
99
|
+
carries no `"use client"`: `FormaAvatar` is a client component, and a pure
|
|
100
|
+
function re-exported from a client module becomes a client reference a server
|
|
101
|
+
cannot call, so the two entry points do not re-export each other and every
|
|
102
|
+
consumer imports the look from one and the avatar from the other.
|
|
103
|
+
`shapeFor(form)` writes the stored spelling of a chosen form, `defaultShape` is
|
|
104
|
+
`shapeFor(defaultForm)`, and `formaColorValues` is the hex each palette colour
|
|
105
|
+
is stored as, held to the shipped design-system tokens by a test beside the
|
|
106
|
+
resolver. The root Agent is the product's decision, not the resolver's: a
|
|
107
|
+
product that owns one passes `form="nadia"` itself.
|
|
108
|
+
|
|
91
109
|
Additions to the family go through this document and the design-system
|
|
92
110
|
token contract, never through an ad-hoc visual.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nadicodeai/ui",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"@assistant-ui/react": "0.15.18",
|
|
71
71
|
"@assistant-ui/react-markdown": "0.14.14",
|
|
72
72
|
"@base-ui/react": "^1.8.0",
|
|
73
|
-
"@nadicodeai/design-system": "6.
|
|
73
|
+
"@nadicodeai/design-system": "6.2.0",
|
|
74
74
|
"@paper-design/shaders": "0.0.80",
|
|
75
75
|
"class-variance-authority": "^0.7.1",
|
|
76
76
|
"clsx": "^2.1.1",
|