@adia-ai/web-components 0.5.3 → 0.5.5
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/components/accordion/accordion-item.a2ui.json +50 -0
- package/components/accordion/accordion-item.yaml +27 -0
- package/components/action-list/action-item.a2ui.json +63 -0
- package/components/action-list/action-item.yaml +37 -0
- package/components/avatar/avatar-group.a2ui.json +50 -0
- package/components/avatar/avatar-group.yaml +26 -0
- package/components/avatar/avatar.a2ui.json +4 -1
- package/components/avatar/avatar.yaml +7 -0
- package/components/button/class.js +39 -0
- package/components/calendar-picker/class.js +1 -0
- package/components/chart/chart.a2ui.json +4 -2
- package/components/chat-thread/chat-input.a2ui.json +158 -0
- package/components/chat-thread/chat-input.yaml +251 -0
- package/components/check/class.js +1 -0
- package/components/feed/feed-item.a2ui.json +86 -0
- package/components/list/list-item.a2ui.json +53 -0
- package/components/list/list-item.yaml +29 -0
- package/components/radio/class.js +1 -0
- package/components/select/class.js +15 -0
- package/components/select/select.a2ui.json +5 -0
- package/components/select/select.css +10 -0
- package/components/select/select.yaml +5 -0
- package/components/slider/class.js +58 -0
- package/components/slider/slider.a2ui.json +10 -0
- package/components/slider/slider.css +13 -0
- package/components/slider/slider.yaml +10 -0
- package/components/switch/class.js +19 -4
- package/components/switch/switch.css +10 -0
- package/components/tabs/tab.a2ui.json +58 -0
- package/components/tabs/tab.yaml +33 -0
- package/components/textarea/class.js +1 -0
- package/components/timeline/timeline-item.a2ui.json +76 -0
- package/components/timeline/timeline-item.yaml +47 -0
- package/components/tree/class.js +91 -0
- package/components/tree/tree-item.a2ui.json +65 -0
- package/components/tree/tree-item.yaml +41 -0
- package/components/tree/tree.a2ui.json +15 -0
- package/components/tree/tree.css +18 -0
- package/components/tree/tree.yaml +10 -0
- package/components/upload/class.js +1 -0
- package/core/icons.d.ts +148 -0
- package/core/template.js +21 -3
- package/package.json +2 -2
package/core/icons.d.ts
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Icon registry — pluggable lookup map for `<icon-ui>` SVG resolution.
|
|
3
|
+
*
|
|
4
|
+
* Three consumer paths, picked by bundle-size budget:
|
|
5
|
+
*
|
|
6
|
+
* 1. **Zero-config** — import the main barrel; phosphor side-effect-loads
|
|
7
|
+
* via `core/icons-phosphor.js`. Largest bundle (~9 000 chunks under
|
|
8
|
+
* `vite build`). Best for prototypes.
|
|
9
|
+
*
|
|
10
|
+
* 2. **Opt-in phosphor with piecemeal component imports** — when you
|
|
11
|
+
* `import '@adia-ai/web-components/components/button'` etc. you skip
|
|
12
|
+
* the barrel's phosphor side-effect. Add it explicitly:
|
|
13
|
+
* import '@adia-ai/web-components/core/icons-phosphor';
|
|
14
|
+
*
|
|
15
|
+
* 3. **Scoped registration (smallest bundle)** — install only the icons
|
|
16
|
+
* you use via `installIconLoaders()` with a brace-list glob, OR
|
|
17
|
+
* `installIconLoadersForRegistered()` to auto-discover from defined
|
|
18
|
+
* primitives' `static requiredIcons`.
|
|
19
|
+
*
|
|
20
|
+
* Runtime exports mirror `core/icons.js`. `installIconLoadersForRegistered`
|
|
21
|
+
* shipped in v0.5.3 §154 (FEEDBACK-06 §4 + FEEDBACK-07 §4). `.d.ts`
|
|
22
|
+
* authored in v0.5.4 to close the missing-type-surface gap that blocked
|
|
23
|
+
* TypeScript consumers from importing the helper.
|
|
24
|
+
*
|
|
25
|
+
* @see ../USAGE.md (consumer guide)
|
|
26
|
+
* @see ./icons-phosphor.js (the zero-config side-effect path)
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Phosphor weight identifiers. `regular` is the default; the other five
|
|
31
|
+
* weights resolve to the corresponding `@phosphor-icons/core/assets/<weight>/`
|
|
32
|
+
* subtree when consumers install loaders for them.
|
|
33
|
+
*/
|
|
34
|
+
export const ICON_WEIGHTS: ReadonlyArray<'regular' | 'thin' | 'light' | 'bold' | 'fill' | 'duotone'>;
|
|
35
|
+
|
|
36
|
+
/** A single phosphor weight identifier. */
|
|
37
|
+
export type IconWeight = 'regular' | 'thin' | 'light' | 'bold' | 'fill' | 'duotone';
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Loader value in an icon-loader map. Either the SVG string itself (eager
|
|
41
|
+
* `import.meta.glob({ eager: true })` output) or a thunk that resolves to
|
|
42
|
+
* the SVG string (lazy / dynamic import).
|
|
43
|
+
*/
|
|
44
|
+
export type IconLoader = string | (() => string | Promise<string>);
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Per-path loader map for a single weight. Keys are typically the
|
|
48
|
+
* `/node_modules/@phosphor-icons/core/assets/<weight>/<filename>.svg` paths
|
|
49
|
+
* `import.meta.glob` produces — but any keys work (§140's filename-suffix
|
|
50
|
+
* fallback handles pnpm / yarn-berry / custom-Vite-root prefixes).
|
|
51
|
+
*/
|
|
52
|
+
export type IconLoaderMap = Record<string, IconLoader>;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Per-weight loader maps. Pass to `installIconLoaders()` /
|
|
56
|
+
* `installIconLoadersForRegistered()`. Most consumers pass only `regular`;
|
|
57
|
+
* weight-overloaded usage (e.g. `<icon-ui name="star" weight="fill">`)
|
|
58
|
+
* needs the corresponding weight populated.
|
|
59
|
+
*/
|
|
60
|
+
export interface WeightModules {
|
|
61
|
+
regular?: IconLoaderMap;
|
|
62
|
+
thin?: IconLoaderMap;
|
|
63
|
+
light?: IconLoaderMap;
|
|
64
|
+
bold?: IconLoaderMap;
|
|
65
|
+
fill?: IconLoaderMap;
|
|
66
|
+
duotone?: IconLoaderMap;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** Register a single icon by name. Bypasses loader-map lookup entirely. */
|
|
70
|
+
export function registerIcon(name: string, svg: string, weight?: IconWeight): void;
|
|
71
|
+
|
|
72
|
+
/** Register multiple icons at a single weight. Bypasses loader-map lookup. */
|
|
73
|
+
export function registerIcons(icons: Record<string, string>, weight?: IconWeight): void;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Get icon SVG by name + weight. Returns the cached SVG if present;
|
|
77
|
+
* otherwise triggers an async load (returning `''` immediately) + the
|
|
78
|
+
* registered `<icon-ui>` elements re-render once the load resolves.
|
|
79
|
+
*/
|
|
80
|
+
export function getIcon(name: string, weight?: IconWeight): string;
|
|
81
|
+
|
|
82
|
+
/** Sync check — is `name` cached in the registry at this weight? */
|
|
83
|
+
export function hasIcon(name: string, weight?: IconWeight): boolean;
|
|
84
|
+
|
|
85
|
+
/** List all cached `weight:name` keys in the registry. */
|
|
86
|
+
export function listIcons(): string[];
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Sync check — is `name` (or its `ICON_ALIASES` alias) a known icon at
|
|
90
|
+
* the given weight? Doesn't trigger loading. Used by primitives that
|
|
91
|
+
* accept either an icon name or a text label (`<input-ui prefix>`,
|
|
92
|
+
* `<input-ui suffix>`) to disambiguate.
|
|
93
|
+
*/
|
|
94
|
+
export function isIconName(name: string, weight?: IconWeight): boolean;
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Resolves once the icon registry is sync-checkable — i.e., after the
|
|
98
|
+
* first `installIconLoaders()` call. Primitives that branch on
|
|
99
|
+
* `isIconName` at connect time should await this to avoid the static-
|
|
100
|
+
* deploy race (the registry starts empty, fills async via manifest fetch).
|
|
101
|
+
*/
|
|
102
|
+
export const whenIconRegistryReady: Promise<void>;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Install a per-weight loader map. Idempotent — subsequent calls replace
|
|
106
|
+
* the previous map. After install, re-stamps any existing
|
|
107
|
+
* `<icon-ui[name]>` elements so they re-render with the newly-loadable
|
|
108
|
+
* SVGs.
|
|
109
|
+
*
|
|
110
|
+
* @param modules per-weight maps; missing weights stay empty.
|
|
111
|
+
*/
|
|
112
|
+
export function installIconLoaders(modules: WeightModules): void;
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Auto-discover the icon set from defined primitives' `static
|
|
116
|
+
* requiredIcons` declarations, then install loaders.
|
|
117
|
+
*
|
|
118
|
+
* Each AdiaUI primitive that auto-stamps icons declares them via:
|
|
119
|
+
*
|
|
120
|
+
* export class UISelect extends UIFormElement {
|
|
121
|
+
* static requiredIcons = ['caret-up-down'];
|
|
122
|
+
* // ...
|
|
123
|
+
* }
|
|
124
|
+
*
|
|
125
|
+
* This helper aggregates the union across all currently-defined
|
|
126
|
+
* primitives (post-side-effect imports) and installs `modules` as the
|
|
127
|
+
* loader source. The returned list is the discovered set — useful for
|
|
128
|
+
* trimming a wide glob to only what's needed.
|
|
129
|
+
*
|
|
130
|
+
* Shipped v0.5.3 §154 (FEEDBACK-06 §4 + FEEDBACK-07 §4).
|
|
131
|
+
*
|
|
132
|
+
* @param modules - per-weight loader maps (typically `import.meta.glob`
|
|
133
|
+
* output for `@phosphor-icons/core/assets/<weight>/*.svg`)
|
|
134
|
+
* @returns the union of `static requiredIcons` across all defined primitives
|
|
135
|
+
*/
|
|
136
|
+
export function installIconLoadersForRegistered(
|
|
137
|
+
modules: IconLoaderMap | WeightModules
|
|
138
|
+
): string[];
|
|
139
|
+
|
|
140
|
+
export namespace installIconLoadersForRegistered {
|
|
141
|
+
/**
|
|
142
|
+
* Same-shape companion to `installIconLoadersForRegistered` but
|
|
143
|
+
* doesn't install. Returns the union of `static requiredIcons` across
|
|
144
|
+
* all currently-defined primitives — useful when you want to build a
|
|
145
|
+
* narrower glob from the discovered list.
|
|
146
|
+
*/
|
|
147
|
+
function discover(): string[];
|
|
148
|
+
}
|
package/core/template.js
CHANGED
|
@@ -137,14 +137,32 @@ function scan(fragment, count) {
|
|
|
137
137
|
// bug. Hot template paths fire many times, so warn (not throw):
|
|
138
138
|
// a thrown error would crash render; warn surfaces the bug class.
|
|
139
139
|
if (attr.value.includes('{{p:')) {
|
|
140
|
+
// §184 (v0.5.5, FEEDBACK-08 §5): `class` is special-cased
|
|
141
|
+
// in the hint because `.class=${expr}` sets a JS expando
|
|
142
|
+
// property (`element.class = "foo"`) — NOT the `class`
|
|
143
|
+
// attribute / className. Consumers following the original
|
|
144
|
+
// §152 generic hint silently lost CSS classes. For class,
|
|
145
|
+
// suggest `.className=${expr}`; for style suggest the
|
|
146
|
+
// canonical style-object path; for everything else keep
|
|
147
|
+
// the generic property-assignment recipe.
|
|
148
|
+
const a = attr.name;
|
|
149
|
+
const specific =
|
|
150
|
+
a === 'class'
|
|
151
|
+
? ` .className=\${expression} ← write to the className property (NOT .class, which is an expando)\n` +
|
|
152
|
+
` class="\${expression}" ← full replacement (whole class string is the expression)\n` +
|
|
153
|
+
` .classList=\${{foo: true, bar: false}} ← if/when implemented; verify in USAGE.md\n`
|
|
154
|
+
: a === 'style'
|
|
155
|
+
? ` .style.cssText=\${expression} ← write CSS text to .style.cssText\n` +
|
|
156
|
+
` style="\${expression}" ← full replacement of the style string\n`
|
|
157
|
+
: ` ${a}="\${expression}" ← full replacement (whole attr is the placeholder)\n` +
|
|
158
|
+
` .${a}=\${expression} ← property assignment (preferred for objects/functions)\n`;
|
|
140
159
|
// eslint-disable-next-line no-console
|
|
141
160
|
console.warn(
|
|
142
161
|
`[template] Partial attribute interpolation is not supported.\n` +
|
|
143
162
|
` Element: <${n.tagName.toLowerCase()}>\n` +
|
|
144
|
-
` Attribute: ${
|
|
163
|
+
` Attribute: ${a}="${attr.value.slice(0, 80)}${attr.value.length > 80 ? '…' : ''}"\n` +
|
|
145
164
|
` Use one of:\n` +
|
|
146
|
-
|
|
147
|
-
` .${attr.name}=\${expression} ← property assignment (preferred for objects/functions)\n` +
|
|
165
|
+
specific +
|
|
148
166
|
` Compute the full attr value as a single expression and interpolate the whole.`
|
|
149
167
|
);
|
|
150
168
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adia-ai/web-components",
|
|
3
|
-
"version": "0.5.
|
|
4
|
-
"description": "AdiaUI web components
|
|
3
|
+
"version": "0.5.5",
|
|
4
|
+
"description": "AdiaUI web components \u2014 vanilla custom elements. A2UI runtime (renderer, registry, streams, wiring) lives in @adia-ai/a2ui-runtime.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./index.d.ts",
|
|
7
7
|
"exports": {
|