@vantageos/mosaic 0.2.1 → 0.3.0-alpha.1
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/README.md +181 -0
- package/dist/Alert.schema-BQsZGG6P.d.cts +41 -0
- package/dist/Alert.schema-BQsZGG6P.d.ts +41 -0
- package/dist/ConfirmDialog-B3CQQGmJ.d.cts +34 -0
- package/dist/ConfirmDialog-B3CQQGmJ.d.ts +34 -0
- package/dist/Skeleton.schema-BO0ca2UX.d.cts +135 -0
- package/dist/Skeleton.schema-BO0ca2UX.d.ts +135 -0
- package/dist/Tabs.schema-BzcEyeq8.d.cts +79 -0
- package/dist/Tabs.schema-BzcEyeq8.d.ts +79 -0
- package/dist/artifacts.cjs +20 -2
- package/dist/artifacts.cjs.map +1 -1
- package/dist/artifacts.js +20 -2
- package/dist/artifacts.js.map +1 -1
- package/dist/confirmation.cjs +44 -2
- package/dist/confirmation.cjs.map +1 -1
- package/dist/confirmation.d.cts +34 -1
- package/dist/confirmation.d.ts +34 -1
- package/dist/confirmation.js +41 -3
- package/dist/confirmation.js.map +1 -1
- package/dist/display.cjs +145 -2
- package/dist/display.cjs.map +1 -1
- package/dist/display.d.cts +1 -0
- package/dist/display.d.ts +1 -0
- package/dist/display.js +140 -3
- package/dist/display.js.map +1 -1
- package/dist/forms.cjs +1412 -0
- package/dist/forms.cjs.map +1 -0
- package/dist/forms.d.cts +159 -0
- package/dist/forms.d.ts +159 -0
- package/dist/forms.js +1331 -0
- package/dist/forms.js.map +1 -0
- package/dist/index-CwXVgtGb.d.cts +917 -0
- package/dist/index-CwXVgtGb.d.ts +917 -0
- package/dist/index.cjs +188 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -2
- package/dist/index.d.ts +5 -2
- package/dist/index.js +177 -3
- package/dist/index.js.map +1 -1
- package/dist/input.cjs +19 -0
- package/dist/input.cjs.map +1 -1
- package/dist/input.d.cts +4 -34
- package/dist/input.d.ts +4 -34
- package/dist/input.js +18 -1
- package/dist/input.js.map +1 -1
- package/dist/media.cjs +20 -2
- package/dist/media.cjs.map +1 -1
- package/dist/media.js +20 -2
- package/dist/media.js.map +1 -1
- package/dist/preact/artifacts.d.ts +2 -0
- package/dist/preact/confirmation.d.ts +86 -0
- package/dist/preact/confirmation.js +263 -0
- package/dist/preact/confirmation.js.map +1 -1
- package/dist/preact/display.d.ts +241 -0
- package/dist/preact/display.js +366 -0
- package/dist/preact/display.js.map +1 -1
- package/dist/preact/forms.d.ts +875 -0
- package/dist/preact/forms.js +1323 -0
- package/dist/preact/forms.js.map +1 -0
- package/dist/preact/index.d.ts +2 -0
- package/dist/preact/input.d.ts +89 -0
- package/dist/preact/input.js +194 -0
- package/dist/preact/input.js.map +1 -1
- package/dist/preact/media.d.ts +2 -0
- package/dist/preact/progress.d.ts +2 -0
- package/dist/progress.cjs +20 -2
- package/dist/progress.cjs.map +1 -1
- package/dist/progress.js +20 -2
- package/dist/progress.js.map +1 -1
- package/dist/react/confirmation.cjs +267 -0
- package/dist/react/confirmation.cjs.map +1 -1
- package/dist/react/confirmation.d.cts +21 -1
- package/dist/react/confirmation.d.ts +21 -1
- package/dist/react/confirmation.js +263 -0
- package/dist/react/confirmation.js.map +1 -1
- package/dist/react/display.cjs +372 -0
- package/dist/react/display.cjs.map +1 -1
- package/dist/react/display.d.cts +112 -1
- package/dist/react/display.d.ts +112 -1
- package/dist/react/display.js +362 -0
- package/dist/react/display.js.map +1 -1
- package/dist/react/forms.cjs +1384 -0
- package/dist/react/forms.cjs.map +1 -0
- package/dist/react/forms.d.cts +5 -0
- package/dist/react/forms.d.ts +5 -0
- package/dist/react/forms.js +1323 -0
- package/dist/react/forms.js.map +1 -0
- package/dist/react/input.cjs +197 -0
- package/dist/react/input.cjs.map +1 -1
- package/dist/react/input.d.cts +13 -1
- package/dist/react/input.d.ts +13 -1
- package/dist/react/input.js +194 -0
- package/dist/react/input.js.map +1 -1
- package/dist/tokens.d.cts +35 -0
- package/dist/tokens.d.ts +35 -0
- package/package.json +74 -49
- package/registry.yaml +154 -1
package/dist/react/input.js
CHANGED
|
@@ -1,3 +1,197 @@
|
|
|
1
|
+
import { useId, useRef, useState } from 'react';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
1
4
|
|
|
5
|
+
// src/runtimes/react/components/input/Tabs.tsx
|
|
6
|
+
|
|
7
|
+
// src/components/input/Tabs.logic.ts
|
|
8
|
+
function getNavKeys(orientation) {
|
|
9
|
+
return orientation === "horizontal" ? { prev: "ArrowLeft", next: "ArrowRight" } : { prev: "ArrowUp", next: "ArrowDown" };
|
|
10
|
+
}
|
|
11
|
+
function findNextEnabledIndex(tabs, currentIndex, direction) {
|
|
12
|
+
const len = tabs.length;
|
|
13
|
+
let i = (currentIndex + direction + len) % len;
|
|
14
|
+
for (let tries = 0; tries < len; tries++) {
|
|
15
|
+
if (!tabs[i]?.disabled) return i;
|
|
16
|
+
i = (i + direction + len) % len;
|
|
17
|
+
}
|
|
18
|
+
return currentIndex;
|
|
19
|
+
}
|
|
20
|
+
function findFirstEnabledIndex(tabs) {
|
|
21
|
+
const idx = tabs.findIndex((t) => !t.disabled);
|
|
22
|
+
return idx === -1 ? 0 : idx;
|
|
23
|
+
}
|
|
24
|
+
function findLastEnabledIndex(tabs) {
|
|
25
|
+
for (let i = tabs.length - 1; i >= 0; i--) {
|
|
26
|
+
if (!tabs[i]?.disabled) return i;
|
|
27
|
+
}
|
|
28
|
+
return tabs.length - 1;
|
|
29
|
+
}
|
|
30
|
+
function getTabId(instanceId, tabId) {
|
|
31
|
+
return `${instanceId}-tab-${tabId}`;
|
|
32
|
+
}
|
|
33
|
+
function getPanelId(instanceId, tabId) {
|
|
34
|
+
return `${instanceId}-panel-${tabId}`;
|
|
35
|
+
}
|
|
36
|
+
function resolveInitialActive(tabs, value, defaultValue) {
|
|
37
|
+
if (value !== void 0) {
|
|
38
|
+
const found = tabs.find((t) => t.id === value && !t.disabled);
|
|
39
|
+
if (found) return found.id;
|
|
40
|
+
}
|
|
41
|
+
if (defaultValue !== void 0) {
|
|
42
|
+
const found = tabs.find((t) => t.id === defaultValue && !t.disabled);
|
|
43
|
+
if (found) return found.id;
|
|
44
|
+
}
|
|
45
|
+
const firstEnabled = tabs.find((t) => !t.disabled);
|
|
46
|
+
return firstEnabled?.id ?? tabs[0]?.id ?? "";
|
|
47
|
+
}
|
|
48
|
+
function getTablistClasses(orientation) {
|
|
49
|
+
return orientation === "horizontal" ? "flex flex-row border-b border-slate-200" : "flex flex-col border-r border-slate-200 self-start";
|
|
50
|
+
}
|
|
51
|
+
function getTabClasses(isSelected, isDisabled, orientation) {
|
|
52
|
+
const base = "relative px-4 py-2 text-sm font-medium transition-colors focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-600 select-none";
|
|
53
|
+
const orientationCls = orientation === "horizontal" ? "border-b-2 -mb-px" : "border-r-2 -mr-px text-left";
|
|
54
|
+
const stateCls = isDisabled ? "text-slate-400 cursor-not-allowed border-transparent" : isSelected ? "border-blue-600 text-blue-700 bg-slate-50" : "border-transparent text-slate-600 hover:text-slate-900 hover:border-slate-300 hover:bg-slate-50";
|
|
55
|
+
return [base, orientationCls, stateCls].join(" ");
|
|
56
|
+
}
|
|
57
|
+
function getPanelClasses(orientation) {
|
|
58
|
+
return orientation === "horizontal" ? "pt-4" : "pl-4 flex-1";
|
|
59
|
+
}
|
|
60
|
+
function getRootClasses(orientation) {
|
|
61
|
+
return orientation === "horizontal" ? "flex flex-col" : "flex flex-row";
|
|
62
|
+
}
|
|
63
|
+
var TabItemSchema = z.object({
|
|
64
|
+
id: z.string().min(1),
|
|
65
|
+
label: z.string().min(1),
|
|
66
|
+
/** ReactNode / PreactNode — accepted as unknown at Zod layer (JSX not serialisable). */
|
|
67
|
+
content: z.unknown(),
|
|
68
|
+
disabled: z.boolean().optional().default(false)
|
|
69
|
+
});
|
|
70
|
+
var TabsPropsSchema = z.object({
|
|
71
|
+
tabs: z.array(TabItemSchema).min(1),
|
|
72
|
+
value: z.string().optional(),
|
|
73
|
+
defaultValue: z.string().optional(),
|
|
74
|
+
orientation: z.enum(["horizontal", "vertical"]).default("horizontal"),
|
|
75
|
+
locale: z.enum(["en", "fr"]).default("en")
|
|
76
|
+
});
|
|
77
|
+
function validateTabsProps(raw) {
|
|
78
|
+
return TabsPropsSchema.parse(raw);
|
|
79
|
+
}
|
|
80
|
+
function TabsInner({
|
|
81
|
+
tabs,
|
|
82
|
+
value: controlledValue,
|
|
83
|
+
defaultValue,
|
|
84
|
+
orientation,
|
|
85
|
+
onValueChange
|
|
86
|
+
}) {
|
|
87
|
+
const instanceId = useId();
|
|
88
|
+
const tabButtonRefs = useRef(/* @__PURE__ */ new Map());
|
|
89
|
+
const isControlled = controlledValue !== void 0;
|
|
90
|
+
const [internalValue, setInternalValue] = useState(
|
|
91
|
+
() => resolveInitialActive(tabs, controlledValue, defaultValue)
|
|
92
|
+
);
|
|
93
|
+
const activeId = isControlled ? controlledValue ?? resolveInitialActive(tabs, void 0, defaultValue) : internalValue;
|
|
94
|
+
function handleSelect(tabId) {
|
|
95
|
+
if (!isControlled) {
|
|
96
|
+
setInternalValue(tabId);
|
|
97
|
+
}
|
|
98
|
+
onValueChange?.(tabId);
|
|
99
|
+
}
|
|
100
|
+
function focusTabByIndex(index) {
|
|
101
|
+
const tab = tabs[index];
|
|
102
|
+
if (!tab) return;
|
|
103
|
+
const btn = tabButtonRefs.current.get(tab.id);
|
|
104
|
+
btn?.focus();
|
|
105
|
+
handleSelect(tab.id);
|
|
106
|
+
}
|
|
107
|
+
function handleKeyDown(e, currentIndex) {
|
|
108
|
+
const { prev, next } = getNavKeys(orientation);
|
|
109
|
+
switch (e.key) {
|
|
110
|
+
case next: {
|
|
111
|
+
e.preventDefault();
|
|
112
|
+
focusTabByIndex(findNextEnabledIndex(tabs, currentIndex, 1));
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
case prev: {
|
|
116
|
+
e.preventDefault();
|
|
117
|
+
focusTabByIndex(findNextEnabledIndex(tabs, currentIndex, -1));
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
case "Home": {
|
|
121
|
+
e.preventDefault();
|
|
122
|
+
focusTabByIndex(findFirstEnabledIndex(tabs));
|
|
123
|
+
break;
|
|
124
|
+
}
|
|
125
|
+
case "End": {
|
|
126
|
+
e.preventDefault();
|
|
127
|
+
focusTabByIndex(findLastEnabledIndex(tabs));
|
|
128
|
+
break;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
const rootCls = getRootClasses(orientation);
|
|
133
|
+
const tablistCls = getTablistClasses(orientation);
|
|
134
|
+
const panelCls = getPanelClasses(orientation);
|
|
135
|
+
return /* @__PURE__ */ jsxs("div", { className: rootCls, children: [
|
|
136
|
+
/* @__PURE__ */ jsx("div", { role: "tablist", "aria-orientation": orientation, className: tablistCls, children: tabs.map((tab, index) => {
|
|
137
|
+
const isSelected = tab.id === activeId;
|
|
138
|
+
const tabDomId = getTabId(instanceId, tab.id);
|
|
139
|
+
const panelDomId = getPanelId(instanceId, tab.id);
|
|
140
|
+
const isDisabled = tab.disabled ?? false;
|
|
141
|
+
return /* @__PURE__ */ jsx(
|
|
142
|
+
"button",
|
|
143
|
+
{
|
|
144
|
+
ref: (el) => {
|
|
145
|
+
tabButtonRefs.current.set(tab.id, el);
|
|
146
|
+
},
|
|
147
|
+
id: tabDomId,
|
|
148
|
+
type: "button",
|
|
149
|
+
role: "tab",
|
|
150
|
+
"aria-selected": isSelected,
|
|
151
|
+
"aria-controls": panelDomId,
|
|
152
|
+
"aria-disabled": isDisabled || void 0,
|
|
153
|
+
disabled: isDisabled,
|
|
154
|
+
tabIndex: isSelected ? 0 : -1,
|
|
155
|
+
className: getTabClasses(isSelected, isDisabled, orientation),
|
|
156
|
+
onClick: () => {
|
|
157
|
+
if (!isDisabled) handleSelect(tab.id);
|
|
158
|
+
},
|
|
159
|
+
onKeyDown: (e) => handleKeyDown(e, index),
|
|
160
|
+
children: tab.label
|
|
161
|
+
},
|
|
162
|
+
tab.id
|
|
163
|
+
);
|
|
164
|
+
}) }),
|
|
165
|
+
tabs.map((tab) => {
|
|
166
|
+
const isSelected = tab.id === activeId;
|
|
167
|
+
const tabDomId = getTabId(instanceId, tab.id);
|
|
168
|
+
const panelDomId = getPanelId(instanceId, tab.id);
|
|
169
|
+
return /* @__PURE__ */ jsx(
|
|
170
|
+
"div",
|
|
171
|
+
{
|
|
172
|
+
id: panelDomId,
|
|
173
|
+
role: "tabpanel",
|
|
174
|
+
"aria-labelledby": tabDomId,
|
|
175
|
+
tabIndex: 0,
|
|
176
|
+
hidden: !isSelected,
|
|
177
|
+
className: panelCls,
|
|
178
|
+
children: tab.content
|
|
179
|
+
},
|
|
180
|
+
tab.id
|
|
181
|
+
);
|
|
182
|
+
})
|
|
183
|
+
] });
|
|
184
|
+
}
|
|
185
|
+
function Tabs(raw) {
|
|
186
|
+
try {
|
|
187
|
+
const parsed = validateTabsProps(raw);
|
|
188
|
+
return /* @__PURE__ */ jsx(TabsInner, { ...parsed, onValueChange: raw.onValueChange });
|
|
189
|
+
} catch (err) {
|
|
190
|
+
console.error("[Tabs] Invalid props \u2014 component will not render.", err);
|
|
191
|
+
return null;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
export { Tabs, TabsPropsSchema, validateTabsProps };
|
|
2
196
|
//# sourceMappingURL=input.js.map
|
|
3
197
|
//# sourceMappingURL=input.js.map
|
package/dist/react/input.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"input.js"}
|
|
1
|
+
{"version":3,"sources":["../../src/components/input/Tabs.logic.ts","../../src/components/input/Tabs.schema.ts","../../src/runtimes/react/components/input/Tabs.tsx"],"names":[],"mappings":";;;;;;;AAoBO,SAAS,WAAW,WAAA,EAGzB;AACA,EAAA,OAAO,WA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AA,GAAA,CAAI;AAAA,SAAA;AAAA,QATA,GAAA,CAAI;AAAA,OAUX;AAAA,IAEJ,CAAC;AAAA,GAAA,EACH,CAAA;AAEJ;AAWO,SAAS,KAAK,GAAA,EAA8B;AACjD,EAAA,IAAI;AACF,IAAA,MAAM,MAAA,GAAS,kBAAkB,GAAG,CAAA;AACpC,IAAA,2BAAQ,SAAA,EAAA,EAAW,GAAG,MAAA,EAAQ,aAAA,EAAgB,IAAkB,aAAA,EAAe,CAAA;AAAA,EACjF,SAAS,GAAA,EAAK;AACZ,IAAA,OAAA,CAAQ,KAAA,CAAM,0DAAqD,GAAG,CAAA;AACtE,IAAA,OAAO,IAAA;AAAA,EACT;AACF","file":"input.js","sourcesContent":["/**\n * Tabs.logic.ts — pure, framework-agnostic logic.\n * No JSX here — shared between React 19 and Preact 10 runtimes.\n *\n * WCAG-AA ARIA + roving tabindex spec:\n * - role=\"tablist\" on container\n * - role=\"tab\" + aria-selected + aria-controls on each button\n * - role=\"tabpanel\" + aria-labelledby on each panel\n * - Roving tabindex: active tab = tabIndex 0, all others = tabIndex -1\n * - ArrowLeft/Right (horizontal) or ArrowUp/Down (vertical) moves focus between tabs\n * - Home → first enabled tab, End → last enabled tab\n * - Tab key moves focus INTO the active panel content (no tabIndex manipulation needed — natural DOM order)\n * - Disabled tabs are skipped during keyboard nav\n */\n\nexport type TabOrientation = \"horizontal\" | \"vertical\";\n\n/**\n * Returns the prev/next key pair for the given orientation.\n */\nexport function getNavKeys(orientation: TabOrientation): {\n prev: string;\n next: string;\n} {\n return orientation === \"horizontal\"\n ? { prev: \"ArrowLeft\", next: \"ArrowRight\" }\n : { prev: \"ArrowUp\", next: \"ArrowDown\" };\n}\n\n/**\n * Finds the next focusable (non-disabled) tab index in direction.\n * Wraps around at boundaries.\n */\nexport function findNextEnabledIndex(\n tabs: Array<{ id: string; disabled?: boolean }>,\n currentIndex: number,\n direction: 1 | -1,\n): number {\n const len = tabs.length;\n let i = (currentIndex + direction + len) % len;\n // Guard: prevent infinite loop if all tabs are disabled (shouldn't happen but defensive)\n for (let tries = 0; tries < len; tries++) {\n if (!tabs[i]?.disabled) return i;\n i = (i + direction + len) % len;\n }\n return currentIndex;\n}\n\n/**\n * Finds the first enabled tab index.\n */\nexport function findFirstEnabledIndex(tabs: Array<{ id: string; disabled?: boolean }>): number {\n const idx = tabs.findIndex((t) => !t.disabled);\n return idx === -1 ? 0 : idx;\n}\n\n/**\n * Finds the last enabled tab index.\n */\nexport function findLastEnabledIndex(tabs: Array<{ id: string; disabled?: boolean }>): number {\n for (let i = tabs.length - 1; i >= 0; i--) {\n if (!tabs[i]?.disabled) return i;\n }\n return tabs.length - 1;\n}\n\n/**\n * Generates stable DOM IDs for tab + panel linking.\n */\nexport function getTabId(instanceId: string, tabId: string): string {\n return `${instanceId}-tab-${tabId}`;\n}\n\nexport function getPanelId(instanceId: string, tabId: string): string {\n return `${instanceId}-panel-${tabId}`;\n}\n\n/**\n * Resolves the initial active tab ID.\n * Priority: value (controlled) > defaultValue > first enabled tab.\n */\nexport function resolveInitialActive(\n tabs: Array<{ id: string; disabled?: boolean }>,\n value?: string,\n defaultValue?: string,\n): string {\n if (value !== undefined) {\n const found = tabs.find((t) => t.id === value && !t.disabled);\n if (found) return found.id;\n }\n if (defaultValue !== undefined) {\n const found = tabs.find((t) => t.id === defaultValue && !t.disabled);\n if (found) return found.id;\n }\n const firstEnabled = tabs.find((t) => !t.disabled);\n return firstEnabled?.id ?? tabs[0]?.id ?? \"\";\n}\n\n/**\n * Tailwind class helpers for the tablist container.\n */\nexport function getTablistClasses(orientation: TabOrientation): string {\n return orientation === \"horizontal\"\n ? \"flex flex-row border-b border-slate-200\"\n : \"flex flex-col border-r border-slate-200 self-start\";\n}\n\n/**\n * Tailwind class helpers for a single tab button.\n */\nexport function getTabClasses(\n isSelected: boolean,\n isDisabled: boolean,\n orientation: TabOrientation,\n): string {\n const base =\n \"relative px-4 py-2 text-sm font-medium transition-colors focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-600 select-none\";\n\n const orientationCls =\n orientation === \"horizontal\" ? \"border-b-2 -mb-px\" : \"border-r-2 -mr-px text-left\";\n\n const stateCls = isDisabled\n ? \"text-slate-400 cursor-not-allowed border-transparent\"\n : isSelected\n ? \"border-blue-600 text-blue-700 bg-slate-50\"\n : \"border-transparent text-slate-600 hover:text-slate-900 hover:border-slate-300 hover:bg-slate-50\";\n\n return [base, orientationCls, stateCls].join(\" \");\n}\n\n/**\n * Tailwind class helpers for the tab panel wrapper.\n */\nexport function getPanelClasses(orientation: TabOrientation): string {\n return orientation === \"horizontal\" ? \"pt-4\" : \"pl-4 flex-1\";\n}\n\n/**\n * Tailwind class helpers for the root container.\n */\nexport function getRootClasses(orientation: TabOrientation): string {\n return orientation === \"horizontal\" ? \"flex flex-col\" : \"flex flex-row\";\n}\n","import { z } from \"zod\";\n\n// i18nKeys: Tabs.error.invalidProps\n\n/**\n * Tabs component props schema.\n *\n * Supports controlled (value + onValueChange) and uncontrolled (defaultValue) modes.\n * orientation — \"horizontal\" (default) or \"vertical\" — affects ArrowLeft/Right vs ArrowUp/Down nav.\n * tabs — ordered list of tab descriptors (id must be unique within the instance).\n */\nexport const TabItemSchema = z.object({\n id: z.string().min(1),\n label: z.string().min(1),\n /** ReactNode / PreactNode — accepted as unknown at Zod layer (JSX not serialisable). */\n content: z.unknown(),\n disabled: z.boolean().optional().default(false),\n});\n\nexport type TabItem = z.infer<typeof TabItemSchema>;\n\nexport const TabsPropsSchema = z.object({\n tabs: z.array(TabItemSchema).min(1),\n value: z.string().optional(),\n defaultValue: z.string().optional(),\n orientation: z.enum([\"horizontal\", \"vertical\"]).default(\"horizontal\"),\n locale: z.enum([\"en\", \"fr\"]).default(\"en\"),\n});\n\n/** Runtime props — onValueChange is a function (not serialisable via Zod, kept outside schema). */\nexport type TabsProps = z.infer<typeof TabsPropsSchema> & {\n onValueChange?: (id: string) => void;\n};\n\nexport function validateTabsProps(raw: unknown): z.infer<typeof TabsPropsSchema> {\n return TabsPropsSchema.parse(raw);\n}\n","\"use client\";\n\n// i18nKeys: Tabs.error.invalidProps\n\nimport { type KeyboardEvent, useId, useRef, useState } from \"react\";\nimport {\n findFirstEnabledIndex,\n findLastEnabledIndex,\n findNextEnabledIndex,\n getNavKeys,\n getPanelClasses,\n getPanelId,\n getRootClasses,\n getTabClasses,\n getTabId,\n getTablistClasses,\n resolveInitialActive,\n} from \"../../../../components/input/Tabs.logic.js\";\nimport {\n type TabItem,\n type TabsProps,\n validateTabsProps,\n} from \"../../../../components/input/Tabs.schema.js\";\n\n// ─── Inner component (validated props) ────────────────────────────────────────\n\nfunction TabsInner({\n tabs,\n value: controlledValue,\n defaultValue,\n orientation,\n onValueChange,\n}: TabsProps) {\n const instanceId = useId();\n const tabButtonRefs = useRef<Map<string, HTMLButtonElement | null>>(new Map());\n\n const isControlled = controlledValue !== undefined;\n\n const [internalValue, setInternalValue] = useState<string>(() =>\n resolveInitialActive(tabs, controlledValue, defaultValue),\n );\n\n const activeId = isControlled\n ? (controlledValue ?? resolveInitialActive(tabs, undefined, defaultValue))\n : internalValue;\n\n function handleSelect(tabId: string) {\n if (!isControlled) {\n setInternalValue(tabId);\n }\n onValueChange?.(tabId);\n }\n\n function focusTabByIndex(index: number) {\n const tab = tabs[index];\n if (!tab) return;\n const btn = tabButtonRefs.current.get(tab.id);\n btn?.focus();\n handleSelect(tab.id);\n }\n\n function handleKeyDown(e: KeyboardEvent<HTMLButtonElement>, currentIndex: number) {\n const { prev, next } = getNavKeys(orientation);\n\n switch (e.key) {\n case next: {\n e.preventDefault();\n focusTabByIndex(findNextEnabledIndex(tabs, currentIndex, 1));\n break;\n }\n case prev: {\n e.preventDefault();\n focusTabByIndex(findNextEnabledIndex(tabs, currentIndex, -1));\n break;\n }\n case \"Home\": {\n e.preventDefault();\n focusTabByIndex(findFirstEnabledIndex(tabs));\n break;\n }\n case \"End\": {\n e.preventDefault();\n focusTabByIndex(findLastEnabledIndex(tabs));\n break;\n }\n }\n }\n\n const rootCls = getRootClasses(orientation);\n const tablistCls = getTablistClasses(orientation);\n const panelCls = getPanelClasses(orientation);\n\n return (\n <div className={rootCls}>\n {/* Tab list */}\n <div role=\"tablist\" aria-orientation={orientation} className={tablistCls}>\n {tabs.map((tab: TabItem, index: number) => {\n const isSelected = tab.id === activeId;\n const tabDomId = getTabId(instanceId, tab.id);\n const panelDomId = getPanelId(instanceId, tab.id);\n const isDisabled = tab.disabled ?? false;\n\n return (\n <button\n key={tab.id}\n ref={(el) => {\n tabButtonRefs.current.set(tab.id, el);\n }}\n id={tabDomId}\n type=\"button\"\n role=\"tab\"\n aria-selected={isSelected}\n aria-controls={panelDomId}\n aria-disabled={isDisabled || undefined}\n disabled={isDisabled}\n tabIndex={isSelected ? 0 : -1}\n className={getTabClasses(isSelected, isDisabled, orientation)}\n onClick={() => {\n if (!isDisabled) handleSelect(tab.id);\n }}\n onKeyDown={(e) => handleKeyDown(e, index)}\n >\n {tab.label}\n </button>\n );\n })}\n </div>\n\n {/* Tab panels — tabIndex={0} required by WAI-ARIA Tabs pattern for keyboard focus entry */}\n {tabs.map((tab: TabItem) => {\n const isSelected = tab.id === activeId;\n const tabDomId = getTabId(instanceId, tab.id);\n const panelDomId = getPanelId(instanceId, tab.id);\n\n return (\n <div\n key={tab.id}\n id={panelDomId}\n role=\"tabpanel\"\n aria-labelledby={tabDomId}\n // biome-ignore lint/a11y/noNoninteractiveTabindex: WAI-ARIA Tabs pattern requires tabIndex=0 on tabpanel to allow Tab key entry into panel content\n tabIndex={0}\n hidden={!isSelected}\n className={panelCls}\n >\n {tab.content as React.ReactNode}\n </div>\n );\n })}\n </div>\n );\n}\n\n// ─── Public export with Zod guard ─────────────────────────────────────────────\n\n/**\n * Tabs — cross-runtime tab navigation component.\n *\n * Supports controlled (value + onValueChange) and uncontrolled (defaultValue) modes.\n * WCAG-AA: role=tablist/tab/tabpanel, aria-selected, aria-controls, aria-labelledby,\n * roving tabindex, ArrowLeft/Right/Up/Down, Home/End keyboard navigation.\n */\nexport function Tabs(raw: Record<string, unknown>) {\n try {\n const parsed = validateTabsProps(raw);\n return <TabsInner {...parsed} onValueChange={(raw as TabsProps).onValueChange} />;\n } catch (err) {\n console.error(\"[Tabs] Invalid props — component will not render.\", err);\n return null;\n }\n}\n"]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @vantageos/mosaic-tokens — design tokens (T3-B implementation).
|
|
3
|
+
*
|
|
4
|
+
* Framework-free, OKLCH-based, mirror of the CSS custom properties in
|
|
5
|
+
* tokens.css. Consumers can opt for either the CSS surface (Tailwind v4
|
|
6
|
+
* + @theme inline) or the JS surface (typed runtime access in JSX styles,
|
|
7
|
+
* Storybook stories, Playwright assertions, snapshot tests).
|
|
8
|
+
*
|
|
9
|
+
* Size targets (.size-limit.json): JS bundle ≤5 KB gz, CSS ≤3 KB gz.
|
|
10
|
+
*
|
|
11
|
+
* Schema invariants (enforced by mosaic-tokens-coherence-test in T3-C):
|
|
12
|
+
* - Every CSS var has a JS counterpart (and vice versa).
|
|
13
|
+
* - Color shades 50 < 500 < 700 monotonic luminance.
|
|
14
|
+
* - Spacing scale ascending, ratio 1.5x average (4 → 64 px).
|
|
15
|
+
* - Typography scale uses 1.25x ratio (12 → 38 px).
|
|
16
|
+
* - Shadow elevation 0 < 1 < 2 < 3 < 4 < 5 monotonic blur radius.
|
|
17
|
+
* - Radii strictly ascending (none → full).
|
|
18
|
+
*/
|
|
19
|
+
interface MosaicTokens {
|
|
20
|
+
readonly colors: Readonly<Record<string, string>>;
|
|
21
|
+
readonly spacing: Readonly<Record<string, string>>;
|
|
22
|
+
readonly typography: Readonly<Record<string, string>>;
|
|
23
|
+
readonly shadows: Readonly<Record<string, string>>;
|
|
24
|
+
readonly radii: Readonly<Record<string, string>>;
|
|
25
|
+
readonly motion: Readonly<Record<string, string>>;
|
|
26
|
+
}
|
|
27
|
+
declare const colors: MosaicTokens["colors"];
|
|
28
|
+
declare const spacing: MosaicTokens["spacing"];
|
|
29
|
+
declare const typography: MosaicTokens["typography"];
|
|
30
|
+
declare const shadows: MosaicTokens["shadows"];
|
|
31
|
+
declare const radii: MosaicTokens["radii"];
|
|
32
|
+
declare const motion: MosaicTokens["motion"];
|
|
33
|
+
declare const tokens: MosaicTokens;
|
|
34
|
+
|
|
35
|
+
export { type MosaicTokens, colors, tokens as default, motion, radii, shadows, spacing, tokens, typography };
|
package/dist/tokens.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @vantageos/mosaic-tokens — design tokens (T3-B implementation).
|
|
3
|
+
*
|
|
4
|
+
* Framework-free, OKLCH-based, mirror of the CSS custom properties in
|
|
5
|
+
* tokens.css. Consumers can opt for either the CSS surface (Tailwind v4
|
|
6
|
+
* + @theme inline) or the JS surface (typed runtime access in JSX styles,
|
|
7
|
+
* Storybook stories, Playwright assertions, snapshot tests).
|
|
8
|
+
*
|
|
9
|
+
* Size targets (.size-limit.json): JS bundle ≤5 KB gz, CSS ≤3 KB gz.
|
|
10
|
+
*
|
|
11
|
+
* Schema invariants (enforced by mosaic-tokens-coherence-test in T3-C):
|
|
12
|
+
* - Every CSS var has a JS counterpart (and vice versa).
|
|
13
|
+
* - Color shades 50 < 500 < 700 monotonic luminance.
|
|
14
|
+
* - Spacing scale ascending, ratio 1.5x average (4 → 64 px).
|
|
15
|
+
* - Typography scale uses 1.25x ratio (12 → 38 px).
|
|
16
|
+
* - Shadow elevation 0 < 1 < 2 < 3 < 4 < 5 monotonic blur radius.
|
|
17
|
+
* - Radii strictly ascending (none → full).
|
|
18
|
+
*/
|
|
19
|
+
interface MosaicTokens {
|
|
20
|
+
readonly colors: Readonly<Record<string, string>>;
|
|
21
|
+
readonly spacing: Readonly<Record<string, string>>;
|
|
22
|
+
readonly typography: Readonly<Record<string, string>>;
|
|
23
|
+
readonly shadows: Readonly<Record<string, string>>;
|
|
24
|
+
readonly radii: Readonly<Record<string, string>>;
|
|
25
|
+
readonly motion: Readonly<Record<string, string>>;
|
|
26
|
+
}
|
|
27
|
+
declare const colors: MosaicTokens["colors"];
|
|
28
|
+
declare const spacing: MosaicTokens["spacing"];
|
|
29
|
+
declare const typography: MosaicTokens["typography"];
|
|
30
|
+
declare const shadows: MosaicTokens["shadows"];
|
|
31
|
+
declare const radii: MosaicTokens["radii"];
|
|
32
|
+
declare const motion: MosaicTokens["motion"];
|
|
33
|
+
declare const tokens: MosaicTokens;
|
|
34
|
+
|
|
35
|
+
export { type MosaicTokens, colors, tokens as default, motion, radii, shadows, spacing, tokens, typography };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vantageos/mosaic",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0-alpha.1",
|
|
4
4
|
"description": "Fleet-wide MCP UI design system — 6-category taxonomy, Zod-validated, registry-gated, streaming-ready, cross-runtime (React 19 + Preact 10).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -8,112 +8,126 @@
|
|
|
8
8
|
"types": "./dist/index.d.ts",
|
|
9
9
|
"exports": {
|
|
10
10
|
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
11
12
|
"import": "./dist/index.js",
|
|
12
|
-
"require": "./dist/index.cjs"
|
|
13
|
-
"types": "./dist/index.d.ts"
|
|
13
|
+
"require": "./dist/index.cjs"
|
|
14
14
|
},
|
|
15
15
|
"./progress": {
|
|
16
|
+
"types": "./dist/progress.d.ts",
|
|
16
17
|
"import": "./dist/progress.js",
|
|
17
|
-
"require": "./dist/progress.cjs"
|
|
18
|
-
"types": "./dist/progress.d.ts"
|
|
18
|
+
"require": "./dist/progress.cjs"
|
|
19
19
|
},
|
|
20
20
|
"./input": {
|
|
21
|
+
"types": "./dist/input.d.ts",
|
|
21
22
|
"import": "./dist/input.js",
|
|
22
|
-
"require": "./dist/input.cjs"
|
|
23
|
-
"types": "./dist/input.d.ts"
|
|
23
|
+
"require": "./dist/input.cjs"
|
|
24
24
|
},
|
|
25
25
|
"./display": {
|
|
26
|
+
"types": "./dist/display.d.ts",
|
|
26
27
|
"import": "./dist/display.js",
|
|
27
|
-
"require": "./dist/display.cjs"
|
|
28
|
-
"types": "./dist/display.d.ts"
|
|
28
|
+
"require": "./dist/display.cjs"
|
|
29
29
|
},
|
|
30
30
|
"./artifacts": {
|
|
31
|
+
"types": "./dist/artifacts.d.ts",
|
|
31
32
|
"import": "./dist/artifacts.js",
|
|
32
|
-
"require": "./dist/artifacts.cjs"
|
|
33
|
-
"types": "./dist/artifacts.d.ts"
|
|
33
|
+
"require": "./dist/artifacts.cjs"
|
|
34
34
|
},
|
|
35
35
|
"./confirmation": {
|
|
36
|
+
"types": "./dist/confirmation.d.ts",
|
|
36
37
|
"import": "./dist/confirmation.js",
|
|
37
|
-
"require": "./dist/confirmation.cjs"
|
|
38
|
-
"types": "./dist/confirmation.d.ts"
|
|
38
|
+
"require": "./dist/confirmation.cjs"
|
|
39
39
|
},
|
|
40
40
|
"./media": {
|
|
41
|
+
"types": "./dist/media.d.ts",
|
|
41
42
|
"import": "./dist/media.js",
|
|
42
|
-
"require": "./dist/media.cjs"
|
|
43
|
-
|
|
43
|
+
"require": "./dist/media.cjs"
|
|
44
|
+
},
|
|
45
|
+
"./forms": {
|
|
46
|
+
"types": "./dist/forms.d.ts",
|
|
47
|
+
"import": "./dist/forms.js",
|
|
48
|
+
"require": "./dist/forms.cjs"
|
|
44
49
|
},
|
|
45
50
|
"./react": {
|
|
51
|
+
"types": "./dist/react/index.d.ts",
|
|
46
52
|
"import": "./dist/react/index.js",
|
|
47
|
-
"require": "./dist/react/index.cjs"
|
|
48
|
-
"types": "./dist/react/index.d.ts"
|
|
53
|
+
"require": "./dist/react/index.cjs"
|
|
49
54
|
},
|
|
50
55
|
"./react/progress": {
|
|
56
|
+
"types": "./dist/react/progress.d.ts",
|
|
51
57
|
"import": "./dist/react/progress.js",
|
|
52
|
-
"require": "./dist/react/progress.cjs"
|
|
53
|
-
"types": "./dist/react/progress.d.ts"
|
|
58
|
+
"require": "./dist/react/progress.cjs"
|
|
54
59
|
},
|
|
55
60
|
"./react/input": {
|
|
61
|
+
"types": "./dist/react/input.d.ts",
|
|
56
62
|
"import": "./dist/react/input.js",
|
|
57
|
-
"require": "./dist/react/input.cjs"
|
|
58
|
-
"types": "./dist/react/input.d.ts"
|
|
63
|
+
"require": "./dist/react/input.cjs"
|
|
59
64
|
},
|
|
60
65
|
"./react/display": {
|
|
66
|
+
"types": "./dist/react/display.d.ts",
|
|
61
67
|
"import": "./dist/react/display.js",
|
|
62
|
-
"require": "./dist/react/display.cjs"
|
|
63
|
-
"types": "./dist/react/display.d.ts"
|
|
68
|
+
"require": "./dist/react/display.cjs"
|
|
64
69
|
},
|
|
65
70
|
"./react/artifacts": {
|
|
71
|
+
"types": "./dist/react/artifacts.d.ts",
|
|
66
72
|
"import": "./dist/react/artifacts.js",
|
|
67
|
-
"require": "./dist/react/artifacts.cjs"
|
|
68
|
-
"types": "./dist/react/artifacts.d.ts"
|
|
73
|
+
"require": "./dist/react/artifacts.cjs"
|
|
69
74
|
},
|
|
70
75
|
"./react/confirmation": {
|
|
76
|
+
"types": "./dist/react/confirmation.d.ts",
|
|
71
77
|
"import": "./dist/react/confirmation.js",
|
|
72
|
-
"require": "./dist/react/confirmation.cjs"
|
|
73
|
-
"types": "./dist/react/confirmation.d.ts"
|
|
78
|
+
"require": "./dist/react/confirmation.cjs"
|
|
74
79
|
},
|
|
75
80
|
"./react/media": {
|
|
81
|
+
"types": "./dist/react/media.d.ts",
|
|
76
82
|
"import": "./dist/react/media.js",
|
|
77
|
-
"require": "./dist/react/media.cjs"
|
|
78
|
-
|
|
83
|
+
"require": "./dist/react/media.cjs"
|
|
84
|
+
},
|
|
85
|
+
"./react/forms": {
|
|
86
|
+
"types": "./dist/react/forms.d.ts",
|
|
87
|
+
"import": "./dist/react/forms.js",
|
|
88
|
+
"require": "./dist/react/forms.cjs"
|
|
79
89
|
},
|
|
80
90
|
"./preact": {
|
|
81
|
-
"
|
|
82
|
-
"
|
|
91
|
+
"types": "./dist/preact/index.d.ts",
|
|
92
|
+
"import": "./dist/preact/index.js"
|
|
83
93
|
},
|
|
84
94
|
"./preact/progress": {
|
|
85
|
-
"
|
|
86
|
-
"
|
|
95
|
+
"types": "./dist/preact/progress.d.ts",
|
|
96
|
+
"import": "./dist/preact/progress.js"
|
|
87
97
|
},
|
|
88
98
|
"./preact/input": {
|
|
89
|
-
"
|
|
90
|
-
"
|
|
99
|
+
"types": "./dist/preact/input.d.ts",
|
|
100
|
+
"import": "./dist/preact/input.js"
|
|
91
101
|
},
|
|
92
102
|
"./preact/display": {
|
|
93
|
-
"
|
|
94
|
-
"
|
|
103
|
+
"types": "./dist/preact/display.d.ts",
|
|
104
|
+
"import": "./dist/preact/display.js"
|
|
95
105
|
},
|
|
96
106
|
"./preact/artifacts": {
|
|
97
|
-
"
|
|
98
|
-
"
|
|
107
|
+
"types": "./dist/preact/artifacts.d.ts",
|
|
108
|
+
"import": "./dist/preact/artifacts.js"
|
|
99
109
|
},
|
|
100
110
|
"./preact/confirmation": {
|
|
101
|
-
"
|
|
102
|
-
"
|
|
111
|
+
"types": "./dist/preact/confirmation.d.ts",
|
|
112
|
+
"import": "./dist/preact/confirmation.js"
|
|
103
113
|
},
|
|
104
114
|
"./preact/media": {
|
|
105
|
-
"
|
|
106
|
-
"
|
|
115
|
+
"types": "./dist/preact/media.d.ts",
|
|
116
|
+
"import": "./dist/preact/media.js"
|
|
117
|
+
},
|
|
118
|
+
"./preact/forms": {
|
|
119
|
+
"types": "./dist/preact/forms.d.ts",
|
|
120
|
+
"import": "./dist/preact/forms.js"
|
|
107
121
|
},
|
|
108
122
|
"./tokens": {
|
|
123
|
+
"types": "./dist/tokens.d.ts",
|
|
109
124
|
"import": "./dist/tokens.js",
|
|
110
|
-
"require": "./dist/tokens.cjs"
|
|
111
|
-
"types": "./dist/tokens.d.ts"
|
|
125
|
+
"require": "./dist/tokens.cjs"
|
|
112
126
|
},
|
|
113
127
|
"./server": {
|
|
128
|
+
"types": "./dist/server.d.ts",
|
|
114
129
|
"import": "./dist/server.js",
|
|
115
|
-
"require": "./dist/server.cjs"
|
|
116
|
-
"types": "./dist/server.d.ts"
|
|
130
|
+
"require": "./dist/server.cjs"
|
|
117
131
|
},
|
|
118
132
|
"./registry.yaml": "./registry.yaml"
|
|
119
133
|
},
|
|
@@ -124,14 +138,19 @@
|
|
|
124
138
|
],
|
|
125
139
|
"sideEffects": false,
|
|
126
140
|
"peerDependencies": {
|
|
141
|
+
"@hookform/resolvers": "^3.10.0",
|
|
127
142
|
"@mcp-ui/client": "7.1.1",
|
|
128
143
|
"preact": "^10.25.0",
|
|
129
144
|
"react": "^19.1.0",
|
|
130
145
|
"react-dom": "^19.1.0",
|
|
146
|
+
"react-hook-form": "^7.54.0",
|
|
131
147
|
"react-i18next": "15.5.2",
|
|
132
148
|
"rxjs": "^7.8.0"
|
|
133
149
|
},
|
|
134
150
|
"peerDependenciesMeta": {
|
|
151
|
+
"@hookform/resolvers": {
|
|
152
|
+
"optional": true
|
|
153
|
+
},
|
|
135
154
|
"@mcp-ui/client": {
|
|
136
155
|
"optional": true
|
|
137
156
|
},
|
|
@@ -144,6 +163,9 @@
|
|
|
144
163
|
"react-dom": {
|
|
145
164
|
"optional": true
|
|
146
165
|
},
|
|
166
|
+
"react-hook-form": {
|
|
167
|
+
"optional": true
|
|
168
|
+
},
|
|
147
169
|
"react-i18next": {
|
|
148
170
|
"optional": true
|
|
149
171
|
},
|
|
@@ -161,11 +183,11 @@
|
|
|
161
183
|
"@vantageos/mosaic-tokens": "0.2.0"
|
|
162
184
|
},
|
|
163
185
|
"devDependencies": {
|
|
186
|
+
"@axe-core/playwright": "4.10.1",
|
|
164
187
|
"@babel/parser": "7.29.7",
|
|
165
188
|
"@babel/traverse": "7.29.7",
|
|
166
|
-
"@types/babel__traverse": "7.28.0",
|
|
167
|
-
"@axe-core/playwright": "4.10.1",
|
|
168
189
|
"@biomejs/biome": "1.9.4",
|
|
190
|
+
"@hookform/resolvers": "^3.10.0",
|
|
169
191
|
"@playwright/test": "1.50.1",
|
|
170
192
|
"@size-limit/preset-small-lib": "11.2.0",
|
|
171
193
|
"@storybook/builder-vite": "8.6.18",
|
|
@@ -175,6 +197,7 @@
|
|
|
175
197
|
"@tailwindcss/vite": "4.1.8",
|
|
176
198
|
"@testing-library/react": "16.3.0",
|
|
177
199
|
"@testing-library/user-event": "14.6.1",
|
|
200
|
+
"@types/babel__traverse": "7.28.0",
|
|
178
201
|
"@types/dompurify": "3.0.5",
|
|
179
202
|
"@types/react": "19.1.0",
|
|
180
203
|
"@types/react-dom": "19.1.0",
|
|
@@ -184,6 +207,7 @@
|
|
|
184
207
|
"preact": "10.27.1",
|
|
185
208
|
"react": "19.1.0",
|
|
186
209
|
"react-dom": "19.1.0",
|
|
210
|
+
"react-hook-form": "^7.54.0",
|
|
187
211
|
"size-limit": "11.2.0",
|
|
188
212
|
"storybook": "8.6.18",
|
|
189
213
|
"tailwindcss": "4.1.8",
|
|
@@ -194,6 +218,7 @@
|
|
|
194
218
|
"vitest": "3.2.2"
|
|
195
219
|
},
|
|
196
220
|
"scripts": {
|
|
221
|
+
"prebuild": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\"",
|
|
197
222
|
"build": "tsup",
|
|
198
223
|
"dev": "tsup --watch",
|
|
199
224
|
"test": "vitest run",
|