@mgamadeus/ddd-admin-ui 0.0.0-stage → 0.1.0-rc.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.
Files changed (193) hide show
  1. package/.claude/skills/ddd-admin-ui-specialist/SKILL.md +29 -0
  2. package/CHANGELOG.md +16 -0
  3. package/LICENSE +21 -0
  4. package/README.md +131 -2
  5. package/dist/cli/ddd-admin-ui.d.ts +3 -0
  6. package/dist/cli/ddd-admin-ui.d.ts.map +1 -0
  7. package/dist/cli/ddd-admin-ui.js +18 -0
  8. package/dist/cli/ddd-admin-ui.js.map +1 -0
  9. package/dist/cli/linkSkills.d.ts +25 -0
  10. package/dist/cli/linkSkills.d.ts.map +1 -0
  11. package/dist/cli/linkSkills.js +76 -0
  12. package/dist/cli/linkSkills.js.map +1 -0
  13. package/dist/components.css +42 -0
  14. package/dist/data/StatTile.d.ts +8 -0
  15. package/dist/data/StatTile.d.ts.map +1 -0
  16. package/dist/data/StatTile.js +6 -0
  17. package/dist/data/StatTile.js.map +1 -0
  18. package/dist/data/index.d.ts +2 -0
  19. package/dist/data/index.d.ts.map +1 -0
  20. package/dist/data/index.js +2 -0
  21. package/dist/data/index.js.map +1 -0
  22. package/dist/form/Form.d.ts +13 -0
  23. package/dist/form/Form.d.ts.map +1 -0
  24. package/dist/form/Form.js +11 -0
  25. package/dist/form/Form.js.map +1 -0
  26. package/dist/form/fieldLabels.d.ts +10 -0
  27. package/dist/form/fieldLabels.d.ts.map +1 -0
  28. package/dist/form/fieldLabels.js +8 -0
  29. package/dist/form/fieldLabels.js.map +1 -0
  30. package/dist/form/index.d.ts +3 -0
  31. package/dist/form/index.d.ts.map +1 -0
  32. package/dist/form/index.js +3 -0
  33. package/dist/form/index.js.map +1 -0
  34. package/dist/glass/GlassPanel.d.ts +7 -0
  35. package/dist/glass/GlassPanel.d.ts.map +1 -0
  36. package/dist/glass/GlassPanel.js +5 -0
  37. package/dist/glass/GlassPanel.js.map +1 -0
  38. package/dist/glass/index.d.ts +2 -0
  39. package/dist/glass/index.d.ts.map +1 -0
  40. package/dist/glass/index.js +2 -0
  41. package/dist/glass/index.js.map +1 -0
  42. package/dist/i18n/Translate.d.ts +7 -0
  43. package/dist/i18n/Translate.d.ts.map +1 -0
  44. package/dist/i18n/Translate.js +9 -0
  45. package/dist/i18n/Translate.js.map +1 -0
  46. package/dist/i18n/index.d.ts +5 -0
  47. package/dist/i18n/index.d.ts.map +1 -0
  48. package/dist/i18n/index.js +5 -0
  49. package/dist/i18n/index.js.map +1 -0
  50. package/dist/i18n/m.d.ts +7 -0
  51. package/dist/i18n/m.d.ts.map +1 -0
  52. package/dist/i18n/m.js +7 -0
  53. package/dist/i18n/m.js.map +1 -0
  54. package/dist/i18n/store.d.ts +24 -0
  55. package/dist/i18n/store.d.ts.map +1 -0
  56. package/dist/i18n/store.js +30 -0
  57. package/dist/i18n/store.js.map +1 -0
  58. package/dist/i18n/useTranslate.d.ts +9 -0
  59. package/dist/i18n/useTranslate.d.ts.map +1 -0
  60. package/dist/i18n/useTranslate.js +12 -0
  61. package/dist/i18n/useTranslate.js.map +1 -0
  62. package/dist/i18n-keys.json +32 -0
  63. package/dist/list/ClearFiltersButton.d.ts +7 -0
  64. package/dist/list/ClearFiltersButton.d.ts.map +1 -0
  65. package/dist/list/ClearFiltersButton.js +10 -0
  66. package/dist/list/ClearFiltersButton.js.map +1 -0
  67. package/dist/list/DateCell.d.ts +8 -0
  68. package/dist/list/DateCell.d.ts.map +1 -0
  69. package/dist/list/DateCell.js +12 -0
  70. package/dist/list/DateCell.js.map +1 -0
  71. package/dist/list/index.d.ts +3 -0
  72. package/dist/list/index.d.ts.map +1 -0
  73. package/dist/list/index.js +3 -0
  74. package/dist/list/index.js.map +1 -0
  75. package/dist/logic/index.d.ts +6 -0
  76. package/dist/logic/index.d.ts.map +1 -0
  77. package/dist/logic/index.js +6 -0
  78. package/dist/logic/index.js.map +1 -0
  79. package/dist/logic/pure/errors.d.ts +3 -0
  80. package/dist/logic/pure/errors.d.ts.map +1 -0
  81. package/dist/logic/pure/errors.js +5 -0
  82. package/dist/logic/pure/errors.js.map +1 -0
  83. package/dist/logic/pure/format.d.ts +15 -0
  84. package/dist/logic/pure/format.d.ts.map +1 -0
  85. package/dist/logic/pure/format.js +32 -0
  86. package/dist/logic/pure/format.js.map +1 -0
  87. package/dist/logic/pure/notify.d.ts +19 -0
  88. package/dist/logic/pure/notify.d.ts.map +1 -0
  89. package/dist/logic/pure/notify.js +33 -0
  90. package/dist/logic/pure/notify.js.map +1 -0
  91. package/dist/logic/pure/statusMap.d.ts +12 -0
  92. package/dist/logic/pure/statusMap.d.ts.map +1 -0
  93. package/dist/logic/pure/statusMap.js +5 -0
  94. package/dist/logic/pure/statusMap.js.map +1 -0
  95. package/dist/logic/react/useToggle.d.ts +8 -0
  96. package/dist/logic/react/useToggle.d.ts.map +1 -0
  97. package/dist/logic/react/useToggle.js +9 -0
  98. package/dist/logic/react/useToggle.js.map +1 -0
  99. package/dist/media/MediaItemField.d.ts +6 -0
  100. package/dist/media/MediaItemField.d.ts.map +1 -0
  101. package/dist/media/MediaItemField.js +11 -0
  102. package/dist/media/MediaItemField.js.map +1 -0
  103. package/dist/media/index.d.ts +3 -0
  104. package/dist/media/index.d.ts.map +1 -0
  105. package/dist/media/index.js +2 -0
  106. package/dist/media/index.js.map +1 -0
  107. package/dist/media/types.d.ts +7 -0
  108. package/dist/media/types.d.ts.map +1 -0
  109. package/dist/media/types.js +2 -0
  110. package/dist/media/types.js.map +1 -0
  111. package/dist/next/index.d.ts +3 -0
  112. package/dist/next/index.d.ts.map +1 -0
  113. package/dist/next/index.js +3 -0
  114. package/dist/next/index.js.map +1 -0
  115. package/dist/next/searchParamsWriter.d.ts +7 -0
  116. package/dist/next/searchParamsWriter.d.ts.map +1 -0
  117. package/dist/next/searchParamsWriter.js +34 -0
  118. package/dist/next/searchParamsWriter.js.map +1 -0
  119. package/dist/next/useNextSearchParam.d.ts +3 -0
  120. package/dist/next/useNextSearchParam.d.ts.map +1 -0
  121. package/dist/next/useNextSearchParam.js +16 -0
  122. package/dist/next/useNextSearchParam.js.map +1 -0
  123. package/dist/notify-sonner/index.d.ts +2 -0
  124. package/dist/notify-sonner/index.d.ts.map +1 -0
  125. package/dist/notify-sonner/index.js +2 -0
  126. package/dist/notify-sonner/index.js.map +1 -0
  127. package/dist/notify-sonner/sonnerNotifications.d.ts +4 -0
  128. package/dist/notify-sonner/sonnerNotifications.d.ts.map +1 -0
  129. package/dist/notify-sonner/sonnerNotifications.js +12 -0
  130. package/dist/notify-sonner/sonnerNotifications.js.map +1 -0
  131. package/dist/page/PageFrame.d.ts +9 -0
  132. package/dist/page/PageFrame.d.ts.map +1 -0
  133. package/dist/page/PageFrame.js +5 -0
  134. package/dist/page/PageFrame.js.map +1 -0
  135. package/dist/page/index.d.ts +2 -0
  136. package/dist/page/index.d.ts.map +1 -0
  137. package/dist/page/index.js +2 -0
  138. package/dist/page/index.js.map +1 -0
  139. package/dist/primitives/button.d.ts +10 -0
  140. package/dist/primitives/button.d.ts.map +1 -0
  141. package/dist/primitives/button.js +20 -0
  142. package/dist/primitives/button.js.map +1 -0
  143. package/dist/primitives/cn.d.ts +4 -0
  144. package/dist/primitives/cn.d.ts.map +1 -0
  145. package/dist/primitives/cn.js +5 -0
  146. package/dist/primitives/cn.js.map +1 -0
  147. package/dist/primitives/dialog.d.ts +10 -0
  148. package/dist/primitives/dialog.d.ts.map +1 -0
  149. package/dist/primitives/dialog.js +19 -0
  150. package/dist/primitives/dialog.js.map +1 -0
  151. package/dist/primitives/index.d.ts +7 -0
  152. package/dist/primitives/index.d.ts.map +1 -0
  153. package/dist/primitives/index.js +7 -0
  154. package/dist/primitives/index.js.map +1 -0
  155. package/dist/primitives/portalContainer.d.ts +8 -0
  156. package/dist/primitives/portalContainer.d.ts.map +1 -0
  157. package/dist/primitives/portalContainer.js +12 -0
  158. package/dist/primitives/portalContainer.js.map +1 -0
  159. package/dist/primitives/select.d.ts +9 -0
  160. package/dist/primitives/select.d.ts.map +1 -0
  161. package/dist/primitives/select.js +16 -0
  162. package/dist/primitives/select.js.map +1 -0
  163. package/dist/primitives/sheet.d.ts +9 -0
  164. package/dist/primitives/sheet.d.ts.map +1 -0
  165. package/dist/primitives/sheet.js +15 -0
  166. package/dist/primitives/sheet.js.map +1 -0
  167. package/dist/provider/AdminUiProvider.d.ts +7 -0
  168. package/dist/provider/AdminUiProvider.d.ts.map +1 -0
  169. package/dist/provider/AdminUiProvider.js +32 -0
  170. package/dist/provider/AdminUiProvider.js.map +1 -0
  171. package/dist/provider/index.d.ts +3 -0
  172. package/dist/provider/index.d.ts.map +1 -0
  173. package/dist/provider/index.js +2 -0
  174. package/dist/provider/index.js.map +1 -0
  175. package/dist/provider/types.d.ts +33 -0
  176. package/dist/provider/types.d.ts.map +1 -0
  177. package/dist/provider/types.js +2 -0
  178. package/dist/provider/types.js.map +1 -0
  179. package/dist/theme.css +44 -0
  180. package/dist/tokens.json +66 -0
  181. package/dist/translations/TranslatableInputField.d.ts +8 -0
  182. package/dist/translations/TranslatableInputField.d.ts.map +1 -0
  183. package/dist/translations/TranslatableInputField.js +12 -0
  184. package/dist/translations/TranslatableInputField.js.map +1 -0
  185. package/dist/translations/index.d.ts +2 -0
  186. package/dist/translations/index.d.ts.map +1 -0
  187. package/dist/translations/index.js +2 -0
  188. package/dist/translations/index.js.map +1 -0
  189. package/docs/README.md +11 -0
  190. package/package.json +158 -3
  191. package/scripts/check-tokens.mjs +136 -0
  192. package/scripts/lib/i18n-manifest.mjs +91 -0
  193. package/scripts/lib/source-scan.mjs +258 -0
@@ -0,0 +1,258 @@
1
+ // Small, dependency-free scanners for the built JavaScript, declaration and CSS files of this package.
2
+ // They read tsc output (unminified, one file per source file); they are not general JavaScript parsers:
3
+ // regular-expression literals that contain `//` or quotes are not recognised as such.
4
+ import * as fs from 'node:fs';
5
+ import * as path from 'node:path';
6
+
7
+ /**
8
+ * Walks `code` once and reports comments and string literals. Template literals are reported with their raw text;
9
+ * `${…}` expressions inside them are scanned as code.
10
+ *
11
+ * @returns {{ kind: 'comment' | 'string' | 'template', start: number, end: number, value: string }[]}
12
+ */
13
+ export function scanTokens(code) {
14
+ const tokens = [];
15
+ /** Brace depth at which each open template expression resumes its template. */
16
+ const templateStack = [];
17
+ let braceDepth = 0;
18
+ let index = 0;
19
+ const readTemplate = (start) => {
20
+ // `index` points just after the opening backtick or the closing brace of an expression.
21
+ let value = '';
22
+ while (index < code.length) {
23
+ const char = code[index];
24
+ if (char === '\\') {
25
+ value += code.slice(index, index + 2);
26
+ index += 2;
27
+ continue;
28
+ }
29
+ if (char === '`') {
30
+ index += 1;
31
+ tokens.push({ kind: 'template', start, end: index, value });
32
+ return;
33
+ }
34
+ if (char === '$' && code[index + 1] === '{') {
35
+ index += 2;
36
+ tokens.push({ kind: 'template', start, end: index, value, open: true });
37
+ templateStack.push(braceDepth);
38
+ braceDepth += 1;
39
+ return;
40
+ }
41
+ value += char;
42
+ index += 1;
43
+ }
44
+ tokens.push({ kind: 'template', start, end: index, value });
45
+ };
46
+ while (index < code.length) {
47
+ const char = code[index];
48
+ const next = code[index + 1];
49
+ if (char === '/' && next === '/') {
50
+ const end = code.indexOf('\n', index);
51
+ const stop = end === -1 ? code.length : end;
52
+ tokens.push({ kind: 'comment', start: index, end: stop, value: code.slice(index, stop) });
53
+ index = stop;
54
+ } else if (char === '/' && next === '*') {
55
+ const end = code.indexOf('*/', index + 2);
56
+ const stop = end === -1 ? code.length : end + 2;
57
+ tokens.push({ kind: 'comment', start: index, end: stop, value: code.slice(index, stop) });
58
+ index = stop;
59
+ } else if (char === '"' || char === "'") {
60
+ const start = index;
61
+ index += 1;
62
+ let value = '';
63
+ while (index < code.length && code[index] !== char && code[index] !== '\n') {
64
+ if (code[index] === '\\') {
65
+ value += code[index + 1] ?? '';
66
+ index += 2;
67
+ } else {
68
+ value += code[index];
69
+ index += 1;
70
+ }
71
+ }
72
+ index += 1;
73
+ tokens.push({ kind: 'string', start, end: index, value });
74
+ } else if (char === '`') {
75
+ const start = index;
76
+ index += 1;
77
+ readTemplate(start);
78
+ } else if (char === '{') {
79
+ braceDepth += 1;
80
+ index += 1;
81
+ } else if (char === '}') {
82
+ braceDepth -= 1;
83
+ index += 1;
84
+ if (templateStack.length > 0 && templateStack[templateStack.length - 1] === braceDepth) {
85
+ templateStack.pop();
86
+ readTemplate(index - 1);
87
+ }
88
+ } else {
89
+ index += 1;
90
+ }
91
+ }
92
+ return tokens;
93
+ }
94
+
95
+ /** `code` with every comment replaced by spaces (line breaks kept). */
96
+ export function stripComments(code) {
97
+ let result = '';
98
+ let last = 0;
99
+ for (const token of scanTokens(code)) {
100
+ if (token.kind !== 'comment') continue;
101
+ result += code.slice(last, token.start) + token.value.replace(/[^\n]/g, ' ');
102
+ last = token.end;
103
+ }
104
+ return result + code.slice(last);
105
+ }
106
+
107
+ /** `code` without comments and with the content of every string and template literal blanked. */
108
+ export function blankLiterals(code) {
109
+ let result = '';
110
+ let last = 0;
111
+ for (const token of scanTokens(code)) {
112
+ const blank =
113
+ token.kind === 'comment'
114
+ ? token.value.replace(/[^\n]/g, ' ')
115
+ : code.slice(token.start, token.end).replace(/[^\n'"`${}]/g, ' ');
116
+ result += code.slice(last, token.start) + blank;
117
+ last = token.end;
118
+ }
119
+ return result + code.slice(last);
120
+ }
121
+
122
+ const STATIC_SPECIFIER = /(?:^|[^\w$.])(?:import|export)\s*(?:type\s+)?(?:[^'";]*?\bfrom\s*)?(['"])([^'"\n]+)\1/g;
123
+ const DYNAMIC_SPECIFIER = /(?:^|[^\w$.])import\s*\(\s*(['"])([^'"\n]+)\1\s*\)/g;
124
+
125
+ /**
126
+ * Module specifiers of a JS or declaration file: static imports and re-exports, side-effect imports, dynamic
127
+ * `import('…')` and declaration `import("…")` types.
128
+ *
129
+ * @returns {{ specifier: string, isTypeOnly: boolean }[]}
130
+ */
131
+ export function extractSpecifiers(code) {
132
+ const source = stripComments(code);
133
+ const found = [];
134
+ for (const match of source.matchAll(STATIC_SPECIFIER)) {
135
+ found.push({ specifier: match[2], isTypeOnly: /^\W?(?:import|export)\s*type\b/.test(match[0].trimStart()) });
136
+ }
137
+ for (const match of source.matchAll(DYNAMIC_SPECIFIER)) found.push({ specifier: match[2], isTypeOnly: false });
138
+ return found;
139
+ }
140
+
141
+ /** Whether a file starts with a `'use client'` directive (after an optional shebang and comments). */
142
+ export function hasUseClientDirective(code) {
143
+ const body = stripComments(code.startsWith('#!') ? code.slice(code.indexOf('\n') + 1) : code).trimStart();
144
+ return /^(['"])use client\1\s*;?/.test(body);
145
+ }
146
+
147
+ /**
148
+ * Why a file needs `'use client'`: the React hooks, `createContext` or `react-dom` it uses. Empty for a file that
149
+ * can run in a server component.
150
+ *
151
+ * @returns {string[]}
152
+ */
153
+ export function clientReasons(code) {
154
+ const reasons = new Set();
155
+ const source = blankLiterals(code);
156
+ for (const match of source.matchAll(/(?<!function\s+)(?<![\w$])(use(?:[A-Z][\w$]*)?)\s*\(/g)) {
157
+ reasons.add(`${match[1]}()`);
158
+ }
159
+ if (/(?<![\w$])createContext\s*[(<]/.test(source)) reasons.add('createContext()');
160
+ for (const { specifier } of extractSpecifiers(code)) {
161
+ if (specifier === 'react-dom' || specifier.startsWith('react-dom/')) reasons.add(`import '${specifier}'`);
162
+ }
163
+ return [...reasons].sort();
164
+ }
165
+
166
+ /** Skips a balanced `(…)` / `{…}` / `[…]` group of blanked code starting at `open`; returns the index after it. */
167
+ function skipBalanced(blanked, open) {
168
+ const pairs = { '(': ')', '{': '}', '[': ']' };
169
+ const stack = [];
170
+ for (let index = open; index < blanked.length; index += 1) {
171
+ const char = blanked[index];
172
+ if (pairs[char]) stack.push(pairs[char]);
173
+ else if (char === stack[stack.length - 1]) {
174
+ stack.pop();
175
+ if (stack.length === 0) return index + 1;
176
+ }
177
+ }
178
+ return blanked.length;
179
+ }
180
+
181
+ const CLASS_FUNCTIONS = /(?<![\w$])(?:cn|cva|clsx|cx|twMerge)\s*\(/g;
182
+
183
+ /**
184
+ * The class-name string literals of a built file: values of `className:` / `className=` and the string arguments of
185
+ * `cn(…)`, `cva(…)`, `clsx(…)`, `cx(…)`, `twMerge(…)` (without cva's `defaultVariants`).
186
+ *
187
+ * @returns {string[]}
188
+ */
189
+ export function extractClassLiterals(code) {
190
+ const blanked = blankLiterals(code);
191
+ const literals = scanTokens(code).filter((token) => token.kind === 'string' || (token.kind === 'template' && !token.open));
192
+ const ranges = [];
193
+ for (const match of blanked.matchAll(/className\s*[:=]\s*/g)) {
194
+ const at = match.index + match[0].length;
195
+ if (blanked[at] === '"' || blanked[at] === "'" || blanked[at] === '`') ranges.push([at, at + 1]);
196
+ }
197
+ const excluded = [];
198
+ for (const match of blanked.matchAll(CLASS_FUNCTIONS)) {
199
+ const open = match.index + match[0].length - 1;
200
+ const end = skipBalanced(blanked, open);
201
+ ranges.push([open, end]);
202
+ const inner = blanked.slice(open, end);
203
+ for (const defaults of inner.matchAll(/defaultVariants\s*:\s*\{/g)) {
204
+ const start = open + defaults.index + defaults[0].length - 1;
205
+ excluded.push([start, skipBalanced(blanked, start)]);
206
+ }
207
+ }
208
+ const inside = (position, list) => list.some(([start, end]) => position >= start && position < end);
209
+ return literals
210
+ .filter((token) => inside(token.start, ranges) && !inside(token.start, excluded))
211
+ .map((token) => token.value)
212
+ .filter((value) => value.trim() !== '');
213
+ }
214
+
215
+ /** Every class token of a set of class literals. */
216
+ export function classTokensOf(literals) {
217
+ return literals.flatMap((literal) => literal.split(/\s+/)).filter((token) => token !== '');
218
+ }
219
+
220
+ /** CSS without comments. */
221
+ export function stripCssComments(css) {
222
+ return css.replace(/\/\*[\s\S]*?\*\//g, (comment) => comment.replace(/[^\n]/g, ' '));
223
+ }
224
+
225
+ /** Innermost rules of a stylesheet: `{ selector, body }` (nested at-rules are flattened). */
226
+ export function cssRules(css) {
227
+ const rules = [];
228
+ for (const match of stripCssComments(css).matchAll(/([^{};]+)\{([^{}]*)\}/g)) {
229
+ rules.push({ selector: match[1].trim(), body: match[2] });
230
+ }
231
+ return rules;
232
+ }
233
+
234
+ /** Custom-property declarations of a rule body: `[name, value]` pairs. */
235
+ export function customPropertyDeclarations(body) {
236
+ return [...body.matchAll(/(--[\w-]+)\s*:\s*([^;]*)(?:;|$)/g)].map((match) => [match[1], match[2].trim()]);
237
+ }
238
+
239
+ /** Every file below `dir` (relative paths with `/`), symlinks not followed. */
240
+ export function listFiles(dir) {
241
+ if (!fs.existsSync(dir)) return [];
242
+ const result = [];
243
+ const walk = (current) => {
244
+ for (const entry of fs.readdirSync(current, { withFileTypes: true })) {
245
+ const full = path.join(current, entry.name);
246
+ if (entry.isDirectory()) walk(full);
247
+ else result.push(path.relative(dir, full).split(path.sep).join('/'));
248
+ }
249
+ };
250
+ walk(dir);
251
+ return result.sort();
252
+ }
253
+
254
+ /** The package name of a bare specifier (`@scope/name/sub` → `@scope/name`). */
255
+ export function packageNameOf(specifier) {
256
+ const parts = specifier.split('/');
257
+ return specifier.startsWith('@') ? parts.slice(0, 2).join('/') : parts[0];
258
+ }