aidos-ui 4.0.2 → 4.0.4
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/BaseButton.js +1 -1
- package/dist/BaseButton.js.map +1 -1
- package/dist/BaseView.js +4 -4
- package/dist/BaseView.js.map +1 -1
- package/dist/Calendar.js +22 -22
- package/dist/Calendar.js.map +1 -1
- package/dist/Card.js +1 -1
- package/dist/Card.js.map +1 -1
- package/dist/DateInput.d.ts +1 -1
- package/dist/DatePicker.js +2 -2
- package/dist/DatePicker.js.map +1 -1
- package/dist/DatetimeInput.js +2 -2
- package/dist/DatetimeInput.js.map +1 -1
- package/dist/Dialog.js +3 -3
- package/dist/Dialog.js.map +1 -1
- package/dist/Dropdown.d.ts +1 -1
- package/dist/Dropdown.js +8 -7
- package/dist/Dropdown.js.map +1 -1
- package/dist/Icon.js +9 -9
- package/dist/Icon.js.map +1 -1
- package/dist/IconButton.d.ts +2 -0
- package/dist/IconButton.js +7 -4
- package/dist/IconButton.js.map +1 -1
- package/dist/Interactable.js +10 -10
- package/dist/Interactable.js.map +1 -1
- package/dist/JSSComment.d.ts +10 -0
- package/dist/JSSComment.js +52 -0
- package/dist/JSSComment.js.map +1 -0
- package/dist/ListDivider.js +2 -2
- package/dist/ListDivider.js.map +1 -1
- package/dist/ListSpacer.js +2 -2
- package/dist/ListSpacer.js.map +1 -1
- package/dist/NextJSRouter.js +3 -3
- package/dist/NextJSRouter.js.map +1 -1
- package/dist/Popover.js +2 -2
- package/dist/Popover.js.map +1 -1
- package/dist/ProgressBar.js +3 -3
- package/dist/ProgressBar.js.map +1 -1
- package/dist/StaticCheckbox.js +2 -2
- package/dist/StaticCheckbox.js.map +1 -1
- package/dist/Storage.js +1 -3
- package/dist/Storage.js.map +1 -1
- package/dist/Tooltip.js +2 -2
- package/dist/Tooltip.js.map +1 -1
- package/dist/jss.d.ts +1 -1
- package/dist/jss.js +21 -11
- package/dist/jss.js.map +1 -1
- package/dist/jsx-dev-runtime.d.ts +2 -0
- package/dist/jsx-dev-runtime.js +48 -0
- package/dist/jsx-dev-runtime.js.map +1 -0
- package/dist/jsx-runtime.d.ts +1 -0
- package/dist/jsx-runtime.js +3 -0
- package/dist/jsx-runtime.js.map +1 -0
- package/dist/vite-plugin-jss-debug.d.ts +37 -0
- package/dist/vite-plugin-jss-debug.js +76 -0
- package/dist/vite-plugin-jss-debug.js.map +1 -0
- package/jss-debug-loader.mjs +44 -0
- package/next.config.js +12 -1
- package/package.json +19 -1
- package/src/BaseButton.tsx +1 -0
- package/src/BaseView.tsx +4 -4
- package/src/Calendar.tsx +27 -29
- package/src/Card.tsx +1 -1
- package/src/DateInput.tsx +1 -1
- package/src/DatePicker.tsx +2 -2
- package/src/DatetimeInput.tsx +3 -3
- package/src/Dialog.tsx +5 -5
- package/src/Dropdown.tsx +9 -8
- package/src/Icon.tsx +9 -9
- package/src/IconButton.tsx +25 -2
- package/src/Interactable.tsx +10 -10
- package/src/JSSComment.tsx +56 -0
- package/src/ListDivider.tsx +2 -2
- package/src/ListSpacer.tsx +2 -2
- package/src/NextJSRouter.tsx +8 -10
- package/src/Popover.tsx +2 -2
- package/src/ProgressBar.tsx +3 -3
- package/src/StaticCheckbox.tsx +3 -3
- package/src/Storage.tsx +1 -3
- package/src/Tooltip.tsx +2 -2
- package/src/jss.tsx +27 -14
- package/src/jsx-dev-runtime.ts +74 -0
- package/src/jsx-runtime.ts +2 -0
- package/src/vite-plugin-jss-debug.ts +77 -0
- package/tsconfig.json +6 -0
- package/.claude/settings.local.json +0 -21
package/src/jss.tsx
CHANGED
|
@@ -75,7 +75,7 @@ const aliases: {
|
|
|
75
75
|
},
|
|
76
76
|
};
|
|
77
77
|
|
|
78
|
-
const rawHashMap = new Map<string, string>();
|
|
78
|
+
const rawHashMap = new Map<string, { selector: string; key: string }>();
|
|
79
79
|
|
|
80
80
|
function createStyleNode(content: string) {
|
|
81
81
|
if (isServer()) {
|
|
@@ -111,6 +111,9 @@ const pixelStyles = new Set([
|
|
|
111
111
|
"left",
|
|
112
112
|
"right",
|
|
113
113
|
"outline-offset",
|
|
114
|
+
"gap",
|
|
115
|
+
"row-gap",
|
|
116
|
+
"column-gap",
|
|
114
117
|
]);
|
|
115
118
|
|
|
116
119
|
const toPixelValue = (key: string, value): string => {
|
|
@@ -141,20 +144,25 @@ const flattenJSS = (jss: JSS): Styles => {
|
|
|
141
144
|
if (!jss) {
|
|
142
145
|
return {};
|
|
143
146
|
} else if (Array.isArray(jss)) {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
}
|
|
147
|
+
const result: Styles = {};
|
|
148
|
+
for (const item of jss) {
|
|
149
|
+
Object.assign(result, flattenJSS(item));
|
|
150
|
+
}
|
|
151
|
+
return result;
|
|
148
152
|
} else {
|
|
149
153
|
return jss;
|
|
150
154
|
}
|
|
151
155
|
};
|
|
152
156
|
|
|
153
|
-
export const toClassnames = (jss: JSS): string => {
|
|
157
|
+
export const toClassnames = (jss: JSS, componentName?: string): string => {
|
|
154
158
|
jss = flattenJSS(jss);
|
|
155
159
|
|
|
156
160
|
const stylesStack = Object.entries(jss);
|
|
157
|
-
const classNames = [];
|
|
161
|
+
const classNames: string[] = [];
|
|
162
|
+
|
|
163
|
+
if (componentName) {
|
|
164
|
+
classNames.push(componentName);
|
|
165
|
+
}
|
|
158
166
|
|
|
159
167
|
while (stylesStack.length) {
|
|
160
168
|
const [key, value] = stylesStack.pop();
|
|
@@ -164,17 +172,22 @@ export const toClassnames = (jss: JSS): string => {
|
|
|
164
172
|
continue;
|
|
165
173
|
}
|
|
166
174
|
|
|
167
|
-
const
|
|
168
|
-
const
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
175
|
+
const inputKey = key + JSON.stringify(value);
|
|
176
|
+
const rawHash = hash(inputKey).toString(32);
|
|
177
|
+
const cached = rawHashMap.get(rawHash);
|
|
178
|
+
|
|
179
|
+
if (cached != null) {
|
|
180
|
+
if (cached.key !== inputKey) {
|
|
181
|
+
console.warn(
|
|
182
|
+
`[jss] Hash collision detected: "${inputKey}" collides with "${cached.key}"`
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
classNames.push(cached.selector);
|
|
172
186
|
continue;
|
|
173
187
|
}
|
|
174
188
|
|
|
175
|
-
// const selector = numberToBase(rawHashMap.size);
|
|
176
189
|
const selector = `x${rawHash}`;
|
|
177
|
-
rawHashMap.set(rawHash, selector);
|
|
190
|
+
rawHashMap.set(rawHash, { selector, key: inputKey });
|
|
178
191
|
classNames.push(selector);
|
|
179
192
|
|
|
180
193
|
if (typeof value === "number" || typeof value === "string") {
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// Custom JSX dev runtime that injects <!-- ComponentName --> comments
|
|
2
|
+
// into the DOM at component boundaries.
|
|
3
|
+
//
|
|
4
|
+
// Usage: in tsconfig.json, set "jsxImportSource": "aidos-ui/src"
|
|
5
|
+
// (or wherever this file is importable from)
|
|
6
|
+
|
|
7
|
+
export { Fragment } from "react/jsx-dev-runtime";
|
|
8
|
+
import { jsxDEV as _jsxDEV, Fragment } from "react/jsx-dev-runtime";
|
|
9
|
+
import { JSSComment } from "./JSSComment";
|
|
10
|
+
|
|
11
|
+
const wrapCache = new WeakMap<Function, Function>();
|
|
12
|
+
|
|
13
|
+
function getWrapped(type: Function): Function {
|
|
14
|
+
let wrapped = wrapCache.get(type);
|
|
15
|
+
if (wrapped) return wrapped;
|
|
16
|
+
|
|
17
|
+
const name = (type as any).displayName || type.name;
|
|
18
|
+
|
|
19
|
+
wrapped = function JSSBoundary(props: any) {
|
|
20
|
+
return _jsxDEV(
|
|
21
|
+
Fragment,
|
|
22
|
+
{
|
|
23
|
+
children: [
|
|
24
|
+
_jsxDEV(JSSComment, { name }, undefined, false, undefined, undefined),
|
|
25
|
+
_jsxDEV(type as any, props, undefined, false, undefined, undefined),
|
|
26
|
+
],
|
|
27
|
+
},
|
|
28
|
+
undefined,
|
|
29
|
+
true,
|
|
30
|
+
undefined,
|
|
31
|
+
undefined
|
|
32
|
+
);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
(wrapped as any).displayName = name;
|
|
36
|
+
wrapCache.set(type, wrapped);
|
|
37
|
+
|
|
38
|
+
return wrapped;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Skip our own wrapper components by name
|
|
42
|
+
const SKIP_NAMES = new Set(["JSSComment", "JSSBoundary"]);
|
|
43
|
+
|
|
44
|
+
function isUserComponent(type: any, source: any): boolean {
|
|
45
|
+
if (typeof type !== "function") return false;
|
|
46
|
+
const name = type.displayName || type.name;
|
|
47
|
+
if (!name || !/^[A-Z]/.test(name)) return false;
|
|
48
|
+
if (SKIP_NAMES.has(name)) return false;
|
|
49
|
+
// Use the source fileName from the JSX transform to skip node_modules
|
|
50
|
+
if (source?.fileName?.includes("node_modules")) return false;
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function jsxDEV(
|
|
55
|
+
type: any,
|
|
56
|
+
props: any,
|
|
57
|
+
key: any,
|
|
58
|
+
isStaticChildren: boolean,
|
|
59
|
+
source: any,
|
|
60
|
+
self: any
|
|
61
|
+
) {
|
|
62
|
+
if (isUserComponent(type, source)) {
|
|
63
|
+
return _jsxDEV(
|
|
64
|
+
getWrapped(type) as any,
|
|
65
|
+
props,
|
|
66
|
+
key,
|
|
67
|
+
isStaticChildren,
|
|
68
|
+
source,
|
|
69
|
+
self
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return _jsxDEV(type, props, key, isStaticChildren, source, self);
|
|
74
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Vite plugin that enables JSS debug tooling:
|
|
5
|
+
*
|
|
6
|
+
* 1. Injects component names into toClassnames() calls so they appear as CSS classes.
|
|
7
|
+
* toClassnames(jss) → toClassnames(jss, "Card")
|
|
8
|
+
*
|
|
9
|
+
* 2. Configures the custom JSX dev runtime that injects <!-- ComponentName -->
|
|
10
|
+
* HTML comments at component boundaries (same approach as the Next.js setup).
|
|
11
|
+
*
|
|
12
|
+
* Usage in vite.config.ts:
|
|
13
|
+
* import jssDebug from "aidos-ui/vite-plugin-jss-debug";
|
|
14
|
+
* export default defineConfig({ plugins: [jssDebug()] });
|
|
15
|
+
*/
|
|
16
|
+
export default function jssDebug() {
|
|
17
|
+
return [
|
|
18
|
+
{
|
|
19
|
+
name: "jss-debug-jsx",
|
|
20
|
+
config(_config: unknown, { command }: { command: string }) {
|
|
21
|
+
return {
|
|
22
|
+
oxc: {
|
|
23
|
+
jsx: {
|
|
24
|
+
runtime: "automatic",
|
|
25
|
+
development: command === "serve",
|
|
26
|
+
importSource: "aidos-ui",
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
name: "jss-debug-classnames",
|
|
34
|
+
enforce: "pre" as const,
|
|
35
|
+
|
|
36
|
+
transform(code: string, id: string) {
|
|
37
|
+
if (id.includes("node_modules")) return;
|
|
38
|
+
if (!id.match(/\.[jt]sx?$/)) return;
|
|
39
|
+
if (!code.includes("toClassnames(")) return;
|
|
40
|
+
|
|
41
|
+
const filename = path.basename(id, path.extname(id));
|
|
42
|
+
const name = JSON.stringify(filename);
|
|
43
|
+
const needle = "toClassnames(";
|
|
44
|
+
let result = "";
|
|
45
|
+
let i = 0;
|
|
46
|
+
|
|
47
|
+
while (i < code.length) {
|
|
48
|
+
const idx = code.indexOf(needle, i);
|
|
49
|
+
if (idx === -1) {
|
|
50
|
+
result += code.slice(i);
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Copy everything up to and including "toClassnames("
|
|
55
|
+
result += code.slice(i, idx + needle.length);
|
|
56
|
+
i = idx + needle.length;
|
|
57
|
+
|
|
58
|
+
// Track parens to find the matching closing )
|
|
59
|
+
let depth = 1;
|
|
60
|
+
let j = i;
|
|
61
|
+
while (j < code.length && depth > 0) {
|
|
62
|
+
const ch = code[j];
|
|
63
|
+
if (ch === "(") depth++;
|
|
64
|
+
else if (ch === ")") depth--;
|
|
65
|
+
if (depth > 0) j++;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Copy the original arguments, then inject the component name
|
|
69
|
+
result += code.slice(i, j) + ", " + name;
|
|
70
|
+
i = j;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return { code: result, map: null };
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
];
|
|
77
|
+
}
|
package/tsconfig.json
CHANGED
|
@@ -11,6 +11,12 @@
|
|
|
11
11
|
"sourceMap": true,
|
|
12
12
|
"outDir": "dist/",
|
|
13
13
|
"jsx": "react-jsx",
|
|
14
|
+
"jsxImportSource": "aidos-ui-jsx",
|
|
15
|
+
"baseUrl": ".",
|
|
16
|
+
"paths": {
|
|
17
|
+
"aidos-ui-jsx/jsx-dev-runtime": ["./src/jsx-dev-runtime"],
|
|
18
|
+
"aidos-ui-jsx/jsx-runtime": ["./src/jsx-runtime"]
|
|
19
|
+
},
|
|
14
20
|
"moduleResolution": "node",
|
|
15
21
|
"esModuleInterop": true,
|
|
16
22
|
"declaration": true,
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"permissions": {
|
|
3
|
-
"allow": [
|
|
4
|
-
"Bash(npm publish:*)",
|
|
5
|
-
"Bash(npm whoami:*)",
|
|
6
|
-
"Bash(npm run dev:*)",
|
|
7
|
-
"Bash(npx npm-check-updates:*)",
|
|
8
|
-
"Bash(npm install:*)",
|
|
9
|
-
"Bash(npm run build:lib:*)",
|
|
10
|
-
"Bash(npm run build:*)",
|
|
11
|
-
"Bash(npm ls:*)",
|
|
12
|
-
"Bash(npm show:*)",
|
|
13
|
-
"Bash(npm info:*)",
|
|
14
|
-
"WebFetch(domain:iconify.design)",
|
|
15
|
-
"Bash(ls:*)",
|
|
16
|
-
"Bash(xargs basename:*)",
|
|
17
|
-
"Bash(pkill:*)",
|
|
18
|
-
"Bash(npx tsc:*)"
|
|
19
|
-
]
|
|
20
|
-
}
|
|
21
|
-
}
|