@blankways/ui 0.0.0-stage → 0.1.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.
Files changed (216) hide show
  1. package/README.md +228 -2
  2. package/dist/cli/cli.options.d.ts +5 -0
  3. package/dist/cli/cli.options.js +53 -0
  4. package/dist/cli/cli.registry.d.ts +6 -0
  5. package/dist/cli/cli.registry.js +37 -0
  6. package/dist/cli/cli.types.d.ts +32 -0
  7. package/dist/cli/cli.types.js +1 -0
  8. package/dist/cli/index.d.ts +3 -0
  9. package/dist/cli/index.js +3 -0
  10. package/dist/cli.d.ts +2 -0
  11. package/dist/cli.js +47 -0
  12. package/dist/commands/add.command.d.ts +2 -0
  13. package/dist/commands/add.command.js +101 -0
  14. package/dist/commands/doctor.command.d.ts +3 -0
  15. package/dist/commands/doctor.command.js +92 -0
  16. package/dist/commands/index.d.ts +6 -0
  17. package/dist/commands/index.js +6 -0
  18. package/dist/commands/init.command.d.ts +2 -0
  19. package/dist/commands/init.command.js +38 -0
  20. package/dist/commands/list.command.d.ts +2 -0
  21. package/dist/commands/list.command.js +54 -0
  22. package/dist/commands/meta.command.d.ts +1 -0
  23. package/dist/commands/meta.command.js +19 -0
  24. package/dist/commands/styles.command.d.ts +6 -0
  25. package/dist/commands/styles.command.js +68 -0
  26. package/dist/config/config.helpers.d.ts +7 -0
  27. package/dist/config/config.helpers.js +63 -0
  28. package/dist/config/framework.helpers.d.ts +3 -0
  29. package/dist/config/framework.helpers.js +14 -0
  30. package/dist/config/index.d.ts +2 -0
  31. package/dist/config/index.js +2 -0
  32. package/dist/constants/cli.constants.d.ts +9 -0
  33. package/dist/constants/cli.constants.js +15 -0
  34. package/dist/constants/framework.constants.d.ts +3 -0
  35. package/dist/constants/framework.constants.js +2 -0
  36. package/dist/constants/index.d.ts +2 -0
  37. package/dist/constants/index.js +2 -0
  38. package/dist/doctor/checks/entries.check.d.ts +1 -0
  39. package/dist/doctor/checks/entries.check.js +21 -0
  40. package/dist/doctor/checks/icons.check.d.ts +1 -0
  41. package/dist/doctor/checks/icons.check.js +55 -0
  42. package/dist/doctor/checks/imports.check.d.ts +1 -0
  43. package/dist/doctor/checks/imports.check.js +45 -0
  44. package/dist/doctor/checks/index.d.ts +7 -0
  45. package/dist/doctor/checks/index.js +7 -0
  46. package/dist/doctor/checks/motion.check.d.ts +1 -0
  47. package/dist/doctor/checks/motion.check.js +66 -0
  48. package/dist/doctor/checks/peers.check.d.ts +1 -0
  49. package/dist/doctor/checks/peers.check.js +55 -0
  50. package/dist/doctor/checks/styles.check.d.ts +1 -0
  51. package/dist/doctor/checks/styles.check.js +45 -0
  52. package/dist/doctor/checks/themes.check.d.ts +1 -0
  53. package/dist/doctor/checks/themes.check.js +64 -0
  54. package/dist/doctor/doctor.helpers.d.ts +6 -0
  55. package/dist/doctor/doctor.helpers.js +39 -0
  56. package/dist/doctor/doctor.registry.d.ts +10 -0
  57. package/dist/doctor/doctor.registry.js +24 -0
  58. package/dist/doctor/doctor.types.d.ts +27 -0
  59. package/dist/doctor/doctor.types.js +1 -0
  60. package/dist/doctor/index.d.ts +3 -0
  61. package/dist/doctor/index.js +3 -0
  62. package/dist/errors/cli-error.d.ts +3 -0
  63. package/dist/errors/cli-error.js +6 -0
  64. package/dist/errors/index.d.ts +1 -0
  65. package/dist/errors/index.js +1 -0
  66. package/dist/helpers/args.helpers.d.ts +4 -0
  67. package/dist/helpers/args.helpers.js +75 -0
  68. package/dist/helpers/help.helpers.d.ts +1 -0
  69. package/dist/helpers/help.helpers.js +30 -0
  70. package/dist/helpers/index.d.ts +5 -0
  71. package/dist/helpers/index.js +5 -0
  72. package/dist/helpers/package.helpers.d.ts +2 -0
  73. package/dist/helpers/package.helpers.js +12 -0
  74. package/dist/helpers/path.helpers.d.ts +3 -0
  75. package/dist/helpers/path.helpers.js +15 -0
  76. package/dist/helpers/styles.helpers.d.ts +21 -0
  77. package/dist/helpers/styles.helpers.js +164 -0
  78. package/dist/index.d.ts +9 -0
  79. package/dist/index.js +9 -0
  80. package/dist/registry/index.d.ts +1 -0
  81. package/dist/registry/index.js +1 -0
  82. package/dist/registry/registry.helpers.d.ts +22 -0
  83. package/dist/registry/registry.helpers.js +328 -0
  84. package/dist/registry-data/README.md +71 -0
  85. package/dist/registry-data/avatar/Avatar.tsx +64 -0
  86. package/dist/registry-data/avatar/component.json +30 -0
  87. package/dist/registry-data/avatar/index.ts +1 -0
  88. package/dist/registry-data/badge/Badge.tsx +76 -0
  89. package/dist/registry-data/badge/component.json +30 -0
  90. package/dist/registry-data/badge/index.ts +1 -0
  91. package/dist/registry-data/brand-logo/BrandLogo.tsx +24 -0
  92. package/dist/registry-data/brand-logo/component.json +26 -0
  93. package/dist/registry-data/brand-logo/index.ts +1 -0
  94. package/dist/registry-data/button/Button.tsx +76 -0
  95. package/dist/registry-data/button/component.json +33 -0
  96. package/dist/registry-data/button/index.ts +1 -0
  97. package/dist/registry-data/button-link/ButtonLink.tsx +83 -0
  98. package/dist/registry-data/button-link/component.json +33 -0
  99. package/dist/registry-data/button-link/index.ts +5 -0
  100. package/dist/registry-data/button-styles/component.json +19 -0
  101. package/dist/registry-data/button-styles/index.ts +45 -0
  102. package/dist/registry-data/cn/cn.ts +6 -0
  103. package/dist/registry-data/cn/component.json +16 -0
  104. package/dist/registry-data/confirm-dialog/ConfirmDialog.tsx +134 -0
  105. package/dist/registry-data/confirm-dialog/component.json +34 -0
  106. package/dist/registry-data/confirm-dialog/index.ts +1 -0
  107. package/dist/registry-data/container/Container.tsx +22 -0
  108. package/dist/registry-data/container/component.json +28 -0
  109. package/dist/registry-data/container/index.ts +1 -0
  110. package/dist/registry-data/cursor-glow/CursorGlow.tsx +29 -0
  111. package/dist/registry-data/cursor-glow/component.json +28 -0
  112. package/dist/registry-data/cursor-glow/index.ts +1 -0
  113. package/dist/registry-data/dropdown-menu/DropdownMenu.tsx +157 -0
  114. package/dist/registry-data/dropdown-menu/component.json +34 -0
  115. package/dist/registry-data/dropdown-menu/index.ts +5 -0
  116. package/dist/registry-data/empty-state/EmptyState.tsx +92 -0
  117. package/dist/registry-data/empty-state/component.json +30 -0
  118. package/dist/registry-data/empty-state/index.ts +5 -0
  119. package/dist/registry-data/eyebrow/Eyebrow.tsx +68 -0
  120. package/dist/registry-data/eyebrow/component.json +30 -0
  121. package/dist/registry-data/eyebrow/index.ts +1 -0
  122. package/dist/registry-data/field-styles/component.json +19 -0
  123. package/dist/registry-data/field-styles/index.ts +42 -0
  124. package/dist/registry-data/form-dialog/FormDialog.tsx +128 -0
  125. package/dist/registry-data/form-dialog/component.json +34 -0
  126. package/dist/registry-data/form-dialog/index.ts +1 -0
  127. package/dist/registry-data/icons/component.json +22 -0
  128. package/dist/registry-data/icons/index.ts +21 -0
  129. package/dist/registry-data/icons-form/component.json +17 -0
  130. package/dist/registry-data/icons-form/index.ts +1 -0
  131. package/dist/registry-data/icons-sidebar/component.json +17 -0
  132. package/dist/registry-data/icons-sidebar/index.ts +1 -0
  133. package/dist/registry-data/icons-theme/component.json +17 -0
  134. package/dist/registry-data/icons-theme/index.ts +1 -0
  135. package/dist/registry-data/icons-toast/component.json +17 -0
  136. package/dist/registry-data/icons-toast/index.ts +1 -0
  137. package/dist/registry-data/info-dialog/InfoDialog.tsx +119 -0
  138. package/dist/registry-data/info-dialog/component.json +36 -0
  139. package/dist/registry-data/info-dialog/index.ts +1 -0
  140. package/dist/registry-data/input/Input.tsx +96 -0
  141. package/dist/registry-data/input/component.json +33 -0
  142. package/dist/registry-data/input/index.ts +1 -0
  143. package/dist/registry-data/multi-combobox/MultiCombobox.tsx +205 -0
  144. package/dist/registry-data/multi-combobox/component.json +35 -0
  145. package/dist/registry-data/multi-combobox/index.ts +5 -0
  146. package/dist/registry-data/remote-provider/RemoteProvider.tsx +8 -0
  147. package/dist/registry-data/remote-provider/component.json +25 -0
  148. package/dist/registry-data/remote-provider/index.ts +3 -0
  149. package/dist/registry-data/reveal/Reveal.tsx +22 -0
  150. package/dist/registry-data/reveal/component.json +30 -0
  151. package/dist/registry-data/reveal/index.ts +1 -0
  152. package/dist/registry-data/section/Section.tsx +80 -0
  153. package/dist/registry-data/section/component.json +30 -0
  154. package/dist/registry-data/section/index.ts +1 -0
  155. package/dist/registry-data/section-heading/SectionHeading.tsx +105 -0
  156. package/dist/registry-data/section-heading/component.json +32 -0
  157. package/dist/registry-data/section-heading/index.ts +1 -0
  158. package/dist/registry-data/select/Select.tsx +197 -0
  159. package/dist/registry-data/select/component.json +34 -0
  160. package/dist/registry-data/select/index.ts +1 -0
  161. package/dist/registry-data/sidebar/Sidebar.tsx +432 -0
  162. package/dist/registry-data/sidebar/SidebarCollapsible.tsx +77 -0
  163. package/dist/registry-data/sidebar/SidebarParts.tsx +373 -0
  164. package/dist/registry-data/sidebar/component.json +47 -0
  165. package/dist/registry-data/sidebar/index.ts +4 -0
  166. package/dist/registry-data/sidebar/useSidebar.ts +29 -0
  167. package/dist/registry-data/styles-base/component.json +19 -0
  168. package/dist/registry-data/styles-base/index.css +67 -0
  169. package/dist/registry-data/styles-components/component.json +19 -0
  170. package/dist/registry-data/styles-components/index.css +30 -0
  171. package/dist/registry-data/styles-motion/component.json +20 -0
  172. package/dist/registry-data/styles-motion/index.css +381 -0
  173. package/dist/registry-data/styles-tokens/component.json +17 -0
  174. package/dist/registry-data/styles-tokens/index.css +77 -0
  175. package/dist/registry-data/styles-utilities/component.json +19 -0
  176. package/dist/registry-data/styles-utilities/index.css +29 -0
  177. package/dist/registry-data/switch/Switch.tsx +91 -0
  178. package/dist/registry-data/switch/component.json +34 -0
  179. package/dist/registry-data/switch/index.ts +1 -0
  180. package/dist/registry-data/tabs/Tabs.tsx +226 -0
  181. package/dist/registry-data/tabs/component.json +32 -0
  182. package/dist/registry-data/tabs/index.ts +1 -0
  183. package/dist/registry-data/textarea/Textarea.tsx +94 -0
  184. package/dist/registry-data/textarea/component.json +33 -0
  185. package/dist/registry-data/textarea/index.ts +1 -0
  186. package/dist/registry-data/theme-core/component.json +17 -0
  187. package/dist/registry-data/theme-core/theme.ts +84 -0
  188. package/dist/registry-data/theme-dark/component.json +19 -0
  189. package/dist/registry-data/theme-dark/index.ts +7 -0
  190. package/dist/registry-data/theme-light/component.json +19 -0
  191. package/dist/registry-data/theme-light/index.ts +7 -0
  192. package/dist/registry-data/theme-provider/ThemeContext.tsx +177 -0
  193. package/dist/registry-data/theme-provider/component.json +30 -0
  194. package/dist/registry-data/theme-provider/index.ts +2 -0
  195. package/dist/registry-data/theme-selector/ThemeSelector.tsx +269 -0
  196. package/dist/registry-data/theme-selector/component.json +35 -0
  197. package/dist/registry-data/theme-selector/selector.ts +1 -0
  198. package/dist/registry-data/theme-system/component.json +19 -0
  199. package/dist/registry-data/theme-system/index.ts +7 -0
  200. package/dist/registry-data/theme-toggle/ThemeToggle.tsx +71 -0
  201. package/dist/registry-data/theme-toggle/component.json +31 -0
  202. package/dist/registry-data/theme-toggle/toggle.ts +1 -0
  203. package/dist/registry-data/toast/Toast.tsx +260 -0
  204. package/dist/registry-data/toast/ToastTypeIcon.tsx +83 -0
  205. package/dist/registry-data/toast/component.json +43 -0
  206. package/dist/registry-data/toast/index.ts +3 -0
  207. package/dist/registry-data/toast/useToast.ts +47 -0
  208. package/dist/types/cli.types.d.ts +6 -0
  209. package/dist/types/cli.types.js +1 -0
  210. package/dist/types/config.types.d.ts +41 -0
  211. package/dist/types/config.types.js +1 -0
  212. package/dist/types/index.d.ts +3 -0
  213. package/dist/types/index.js +3 -0
  214. package/dist/types/registry.types.d.ts +37 -0
  215. package/dist/types/registry.types.js +1 -0
  216. package/package.json +35 -3
@@ -0,0 +1,328 @@
1
+ import { existsSync } from 'node:fs';
2
+ import { copyFile, mkdir, readFile, readdir, stat } from 'node:fs/promises';
3
+ import { basename, dirname, isAbsolute, join, normalize, relative, resolve } from 'node:path';
4
+ import { fileURLToPath } from 'node:url';
5
+ import { BUNDLED_REGISTRY_DIR_NAME, COMPONENT_NAME_PATTERN, COMPONENTS_SUBDIR, DEFAULT_FRAMEWORK, MANIFEST_FILE_NAME, REGISTRY_DIR_NAME } from '../constants/index.js';
6
+ import { assertFramework } from '../config/framework.helpers.js';
7
+ import { CliError } from '../errors/index.js';
8
+ import { getPackageRoot } from '../helpers/package.helpers.js';
9
+ import { assertSafeRelativePath, toDisplayPath } from '../helpers/path.helpers.js';
10
+ import { REGISTRY_KINDS } from '../types/registry.types.js';
11
+ const COMPONENT_EXTENSIONS = ['.tsx', '.ts', '.jsx', '.js'];
12
+ const IGNORED_DIRECTORIES = new Set(['node_modules']);
13
+ const IGNORED_FILE_NAMES = new Set([MANIFEST_FILE_NAME, 'README.md']);
14
+ async function pathExists(path) {
15
+ try {
16
+ await stat(path);
17
+ return true;
18
+ }
19
+ catch {
20
+ return false;
21
+ }
22
+ }
23
+ async function isDirectory(path) {
24
+ try {
25
+ return (await stat(path)).isDirectory();
26
+ }
27
+ catch {
28
+ return false;
29
+ }
30
+ }
31
+ async function isFile(path) {
32
+ try {
33
+ return (await stat(path)).isFile();
34
+ }
35
+ catch {
36
+ return false;
37
+ }
38
+ }
39
+ export function getRegistryRoot() {
40
+ const sourceRegistry = join(getPackageRoot(), REGISTRY_DIR_NAME);
41
+ if (existsSync(sourceRegistry))
42
+ return sourceRegistry;
43
+ // Published packages ship registry data inside dist/ so `files: ["dist"]` is enough.
44
+ return resolve(dirname(fileURLToPath(import.meta.url)), '..', BUNDLED_REGISTRY_DIR_NAME);
45
+ }
46
+ export function isValidComponentName(name) {
47
+ return COMPONENT_NAME_PATTERN.test(name) && name !== '.' && name !== '..';
48
+ }
49
+ export function assertValidComponentName(name) {
50
+ if (!isValidComponentName(name)) {
51
+ throw new CliError(`Invalid component name "${name}". Use letters, numbers, dots, dashes or underscores.`);
52
+ }
53
+ }
54
+ export function assertValidRegistryKind(value) {
55
+ if (value === undefined)
56
+ return undefined;
57
+ if (!REGISTRY_KINDS.includes(value)) {
58
+ throw new CliError(`Unknown kind "${value}". Use ${REGISTRY_KINDS.join(', ')}.`);
59
+ }
60
+ return value;
61
+ }
62
+ function inferKind(name) {
63
+ if (name.startsWith('icons'))
64
+ return 'icon';
65
+ if (name.startsWith('styles'))
66
+ return 'style';
67
+ if (name.startsWith('theme'))
68
+ return 'theme';
69
+ if (name === 'cn' || name.endsWith('-styles'))
70
+ return 'utility';
71
+ return 'component';
72
+ }
73
+ function getFileComponentName(fileName) {
74
+ for (const extension of COMPONENT_EXTENSIONS) {
75
+ if (fileName.endsWith(extension)) {
76
+ return fileName.slice(0, -extension.length);
77
+ }
78
+ }
79
+ return undefined;
80
+ }
81
+ async function walkDirectory(directory) {
82
+ const files = [];
83
+ const entries = await readdir(directory, { withFileTypes: true });
84
+ for (const entry of entries) {
85
+ if (entry.name.startsWith('.') || IGNORED_DIRECTORIES.has(entry.name))
86
+ continue;
87
+ const fullPath = join(directory, entry.name);
88
+ if (entry.isDirectory()) {
89
+ files.push(...(await walkDirectory(fullPath)));
90
+ }
91
+ else if (entry.isFile() && !IGNORED_FILE_NAMES.has(entry.name)) {
92
+ files.push(fullPath);
93
+ }
94
+ }
95
+ return files;
96
+ }
97
+ function toStringArray(value, field) {
98
+ if (value === undefined)
99
+ return [];
100
+ if (!Array.isArray(value) || value.some(item => typeof item !== 'string')) {
101
+ throw new CliError(`${MANIFEST_FILE_NAME}: "${field}" must be an array of strings.`);
102
+ }
103
+ return value;
104
+ }
105
+ function normalizeTarget(target, kind) {
106
+ assertSafeRelativePath(target);
107
+ const normalized = normalize(target).replace(/\\/g, '/');
108
+ const componentsPrefix = `${COMPONENTS_SUBDIR}/`;
109
+ if (kind !== 'component' || normalized.startsWith(componentsPrefix))
110
+ return normalized;
111
+ return `${componentsPrefix}${normalized}`;
112
+ }
113
+ function resolveSource(name, source) {
114
+ if (isAbsolute(source))
115
+ return source;
116
+ assertSafeRelativePath(source);
117
+ return join(getRegistryRoot(), name, normalize(source));
118
+ }
119
+ function normalizeFiles(name, files, kind) {
120
+ if (files === undefined)
121
+ return [];
122
+ if (!Array.isArray(files)) {
123
+ throw new CliError(`${MANIFEST_FILE_NAME}: "files" must be an array.`);
124
+ }
125
+ return files.map((file, index) => {
126
+ if (typeof file !== 'object' || file === null) {
127
+ throw new CliError(`${MANIFEST_FILE_NAME}: files[${index}] must be an object.`);
128
+ }
129
+ const record = file;
130
+ if (typeof record.source !== 'string' || typeof record.target !== 'string') {
131
+ throw new CliError(`${MANIFEST_FILE_NAME}: files[${index}] needs string "source" and "target".`);
132
+ }
133
+ return {
134
+ source: resolveSource(name, record.source),
135
+ target: normalizeTarget(record.target, kind)
136
+ };
137
+ });
138
+ }
139
+ async function readManifest(path) {
140
+ let parsed;
141
+ try {
142
+ parsed = JSON.parse(await readFile(path, 'utf8'));
143
+ }
144
+ catch (error) {
145
+ const message = error instanceof Error ? error.message : String(error);
146
+ throw new CliError(`Invalid ${MANIFEST_FILE_NAME}: ${message}`);
147
+ }
148
+ if (typeof parsed !== 'object' || parsed === null) {
149
+ throw new CliError(`${MANIFEST_FILE_NAME} must contain a JSON object.`);
150
+ }
151
+ return parsed;
152
+ }
153
+ async function createItem(name, manifest, fallbackFiles, framework = DEFAULT_FRAMEWORK) {
154
+ assertValidComponentName(name);
155
+ if (manifest?.name !== undefined && manifest.name !== name) {
156
+ throw new CliError(`${MANIFEST_FILE_NAME} in "${name}" declares name "${manifest.name}".`);
157
+ }
158
+ const declaredKind = manifest?.kind;
159
+ if (declaredKind !== undefined &&
160
+ !REGISTRY_KINDS.includes(declaredKind)) {
161
+ throw new CliError(`${MANIFEST_FILE_NAME} in "${name}" has invalid kind "${String(declaredKind)}".`);
162
+ }
163
+ const kind = declaredKind ?? inferKind(name);
164
+ const files = manifest?.files !== undefined
165
+ ? normalizeFiles(name, manifest.files, kind)
166
+ : fallbackFiles.map(file => {
167
+ const directoryRoot = join(getRegistryRoot(), name);
168
+ const target = isAbsolute(file) && file.startsWith(directoryRoot)
169
+ ? join(name, relative(directoryRoot, file))
170
+ : basename(file);
171
+ return { source: file, target: normalizeTarget(target, kind) };
172
+ });
173
+ if (files.length === 0)
174
+ return null;
175
+ return {
176
+ name,
177
+ kind,
178
+ framework: assertFramework(manifest?.framework ?? framework),
179
+ description: manifest?.description ?? `Local registry entry "${name}".`,
180
+ dependencies: toStringArray(manifest?.dependencies, 'dependencies'),
181
+ peers: toStringArray(manifest?.peers, 'peers'),
182
+ suggestions: toStringArray(manifest?.suggestions, 'suggestions'),
183
+ files,
184
+ hidden: manifest?.hidden === true
185
+ };
186
+ }
187
+ async function loadDirectoryItem(name, directory, framework) {
188
+ const manifestPath = join(directory, MANIFEST_FILE_NAME);
189
+ const manifest = (await isFile(manifestPath)) ? await readManifest(manifestPath) : null;
190
+ const fallbackFiles = manifest === null ? await walkDirectory(directory) : [];
191
+ return createItem(name, manifest, fallbackFiles, framework);
192
+ }
193
+ export async function listRegistryItems(options = {}) {
194
+ const framework = assertFramework(options.framework);
195
+ const root = getRegistryRoot();
196
+ if (!(await isDirectory(root)))
197
+ return [];
198
+ const entries = await readdir(root, { withFileTypes: true });
199
+ const items = [];
200
+ for (const entry of entries) {
201
+ if (entry.name.startsWith('.') || IGNORED_DIRECTORIES.has(entry.name))
202
+ continue;
203
+ if (entry.isDirectory() && isValidComponentName(entry.name)) {
204
+ const item = await loadDirectoryItem(entry.name, join(root, entry.name), framework);
205
+ if (item?.framework === framework)
206
+ items.push(item);
207
+ continue;
208
+ }
209
+ if (entry.isFile() && !IGNORED_FILE_NAMES.has(entry.name)) {
210
+ const name = getFileComponentName(entry.name);
211
+ if (name !== undefined && isValidComponentName(name)) {
212
+ const item = await createItem(name, null, [join(root, entry.name)], framework);
213
+ if (item?.framework === framework)
214
+ items.push(item);
215
+ }
216
+ }
217
+ }
218
+ return items.sort((a, b) => a.name.localeCompare(b.name));
219
+ }
220
+ export async function resolveRegistryItem(name, frameworkOption) {
221
+ assertValidComponentName(name);
222
+ const framework = assertFramework(frameworkOption);
223
+ const root = getRegistryRoot();
224
+ const directory = join(root, name);
225
+ if (await isDirectory(directory)) {
226
+ const item = await loadDirectoryItem(name, directory, framework);
227
+ return item?.framework === framework ? item : null;
228
+ }
229
+ for (const extension of COMPONENT_EXTENSIONS) {
230
+ const file = join(root, `${name}${extension}`);
231
+ const item = await createItem(name, null, [file], framework);
232
+ if (item?.framework === framework)
233
+ return item;
234
+ }
235
+ return null;
236
+ }
237
+ export async function resolveSelectedComponents(names, all, options = {}) {
238
+ const kind = assertValidRegistryKind(options.kind);
239
+ const framework = assertFramework(options.framework);
240
+ const items = await listRegistryItems({ framework });
241
+ const byName = new Map(items.map(item => [item.name, item]));
242
+ const requestedNames = all
243
+ ? items
244
+ .filter(item => !item.hidden && (kind === undefined || item.kind === kind))
245
+ .map(item => item.name)
246
+ : Array.from(new Set(names));
247
+ if (requestedNames.length === 0) {
248
+ throw new CliError('No entries specified. Use <name...>, --all or --kind.');
249
+ }
250
+ for (const name of requestedNames)
251
+ assertValidComponentName(name);
252
+ const missing = requestedNames.filter(name => !byName.has(name));
253
+ if (missing.length > 0) {
254
+ const available = items
255
+ .filter(item => !item.hidden)
256
+ .map(item => item.name)
257
+ .join(', ') || 'none';
258
+ throw new CliError(`Unknown registry entry/entries: ${missing.join(', ')}. Available: ${available}.`);
259
+ }
260
+ const hidden = requestedNames.filter(name => byName.get(name)?.hidden);
261
+ if (hidden.length > 0) {
262
+ throw new CliError(`Internal registry entries cannot be added directly: ${hidden.join(', ')}. They are installed automatically as dependencies.`);
263
+ }
264
+ if (kind !== undefined) {
265
+ const wrongKind = requestedNames.filter(name => byName.get(name)?.kind !== kind);
266
+ if (wrongKind.length > 0) {
267
+ throw new CliError(`Expected kind "${kind}" but got: ${wrongKind.join(', ')}.`);
268
+ }
269
+ }
270
+ const orderedNames = [];
271
+ const requested = new Set();
272
+ const resolved = new Set();
273
+ const visiting = [];
274
+ const visit = async (name, isRequested) => {
275
+ if (isRequested)
276
+ requested.add(name);
277
+ if (resolved.has(name))
278
+ return;
279
+ const item = byName.get(name);
280
+ if (!item) {
281
+ throw new CliError(`Unknown registry dependency "${name}".`);
282
+ }
283
+ const cycleIndex = visiting.indexOf(name);
284
+ if (cycleIndex !== -1) {
285
+ throw new CliError(`Registry dependency cycle: ${[...visiting.slice(cycleIndex), name].join(' -> ')}`);
286
+ }
287
+ visiting.push(name);
288
+ if (!options.noDeps) {
289
+ for (const dependency of item.dependencies)
290
+ await visit(dependency, false);
291
+ }
292
+ visiting.pop();
293
+ resolved.add(name);
294
+ orderedNames.push(name);
295
+ };
296
+ for (const name of requestedNames)
297
+ await visit(name, true);
298
+ return orderedNames.map(name => ({
299
+ ...byName.get(name),
300
+ requested: requested.has(name)
301
+ }));
302
+ }
303
+ export async function copyRegistryItem(item, componentsDir, options) {
304
+ const result = { copied: [], skipped: [], planned: [] };
305
+ for (const entry of item.files) {
306
+ assertSafeRelativePath(entry.target);
307
+ const target = join(componentsDir, entry.target);
308
+ const displayPath = toDisplayPath(options.cwd, target);
309
+ if (options.dryRun) {
310
+ result.planned.push(displayPath);
311
+ continue;
312
+ }
313
+ if (!options.force && (await pathExists(target))) {
314
+ result.skipped.push(displayPath);
315
+ continue;
316
+ }
317
+ await mkdir(dirname(target), { recursive: true });
318
+ try {
319
+ await copyFile(entry.source, target);
320
+ }
321
+ catch (error) {
322
+ const message = error instanceof Error ? error.message : String(error);
323
+ throw new CliError(`Could not copy "${entry.source}": ${message}`);
324
+ }
325
+ result.copied.push(displayPath);
326
+ }
327
+ return result;
328
+ }
@@ -0,0 +1,71 @@
1
+ # Component registry
2
+
3
+ Cada entrada es una carpeta con un `component.json`. El CLI la copia a `ui/` respetando los `target` del manifiesto.
4
+
5
+ ```json
6
+ {
7
+ "name": "button",
8
+ "kind": "component",
9
+ "framework": "react",
10
+ "description": "Native button with shared variants.",
11
+ "hidden": false,
12
+ "dependencies": ["cn", "button-styles"],
13
+ "peers": ["@blankways/state", "@blankways/state-react@0.1.0-alpha.1", "react"],
14
+ "suggestions": ["styles-tokens", "styles-base"],
15
+ "files": [
16
+ { "source": "Button.tsx", "target": "components/button/Button.tsx" },
17
+ { "source": "index.ts", "target": "components/button/index.ts" }
18
+ ]
19
+ }
20
+ ```
21
+
22
+ `source` es relativo a la carpeta de la entrada. `target` es relativo a `componentsDir`, que por defecto es `ui`. `framework` declara la alternativa de UI a la que pertenece la entrada; `init` guarda esa misma alternativa en `components.json` y el CLI filtra el registro por ella. Por ahora solo existe `react`.
23
+
24
+ ## Tipos
25
+
26
+ - `component`: componentes React.
27
+ - `icon`: re-exports públicos de `lucide-react`.
28
+ - `theme`: core, provider, toggle, selector y constantes de tema.
29
+ - `style`: archivos CSS con tokens y utilidades de Tailwind v4.
30
+ - `utility`: helpers como `buttonStyles` y `fieldStyles`.
31
+
32
+ Las entradas con `"hidden": true` son internas: no se listan ni se seleccionan directamente con `add`, pero se resuelven como dependencias cuando otra entrada las necesita. `cn` es la entrada interna actual y se copia a `internals/cn.ts`. Los helpers `button-styles` y `field-styles` se copian a `styles/`.
33
+
34
+ ## Peers versionados
35
+
36
+ `peers` admite specs con versión, por ejemplo `@blankways/state-react@0.1.0-alpha.1`. `doctor` compara la versión declarada en el `package.json` del proyecto y avisa si falta o no coincide.
37
+
38
+ ## Entradas remotas
39
+
40
+ `remote-provider` envuelve `RemoteProvider` y re-exporta `useCall` desde `@blankways/remote-react@0.1.0-alpha.1`.
41
+
42
+ ## Themes
43
+
44
+ Los themes son strings abiertos. `theme-core` registra automáticamente `light` y `dark`, pero cualquier entrada puede añadir otro:
45
+
46
+ ```ts
47
+ export const sepiaTheme = 'sepia'
48
+ ```
49
+
50
+ El usuario puede pasarlos a `ThemeProvider`:
51
+
52
+ ```tsx
53
+ <ThemeProvider themes={['light', 'dark', 'sepia']}>
54
+ ```
55
+
56
+ `system` es una preferencia que se resuelve a uno de los themes registrados mediante `systemThemes`.
57
+
58
+ Dependencias entre themes:
59
+
60
+ ```text
61
+ theme-light/dark/system → theme-core
62
+ theme-provider → theme-core
63
+ theme-toggle → theme-provider + icons-theme + cn
64
+ theme-selector → theme-provider + icons-form + cn
65
+ ```
66
+
67
+ ## Validación
68
+
69
+ `pnpm typecheck` valida el registro con `node scripts/validate-registry.mjs`: comprueba manifiestos, archivos fuente, rutas `target`, dependencias, ciclos e imports relativos como `../icons/form.js` en la disposición que tendrá el usuario. La validación no compila las plantillas, por lo que no requiere React ni sus tipos.
70
+
71
+ Tras cambiar `source/`, ejecuta `pnpm build`.
@@ -0,0 +1,64 @@
1
+ import { useEffect } from 'react'
2
+ import { State, type StateId } from '@blankways/state'
3
+ import { Show, Text, useCompute, useState } from '@blankways/state-react'
4
+ import { cn } from '../../internals/cn.js'
5
+
6
+ export type AvatarProps = {
7
+ src?: string
8
+ alt?: string
9
+ /** Full name used for the initials when there is no photo. */
10
+ name?: string
11
+ /** Custom text shown instead of calculated initials. */
12
+ fallback?: string
13
+ className?: string
14
+ }
15
+
16
+ function initialsOf(label: string) {
17
+ return label
18
+ .split(' ')
19
+ .filter(Boolean)
20
+ .slice(0, 2)
21
+ .map((part) => part[0]?.toUpperCase())
22
+ .join('')
23
+ }
24
+
25
+ function useSyncedState<Type>(value: Type): StateId<Type> {
26
+ const state = useState(value)
27
+ useEffect(() => {
28
+ if (!Object.is(State.get(state), value)) State.set(state, value)
29
+ }, [state, value])
30
+ return state
31
+ }
32
+
33
+ /** Round avatar: the photo, or the initials on a neutral gradient. */
34
+ export function Avatar({ src, alt, name, fallback, className }: AvatarProps) {
35
+ const label = name ?? fallback ?? alt ?? ''
36
+ const labelState = useSyncedState(label)
37
+ const hasImage = useSyncedState(Boolean(src))
38
+ const hasInitials = useCompute([hasImage] as const, ([present]) => !present)
39
+ const initials = useCompute(
40
+ [labelState] as const,
41
+ ([value]) => initialsOf(value) || fallback || '·',
42
+ )
43
+
44
+ return (
45
+ <span
46
+ className={cn(
47
+ 'relative inline-flex size-9 shrink-0 items-center justify-center overflow-hidden rounded-full bg-gradient-to-br from-brand-500 to-brand-300 text-xs font-bold text-[#111111]',
48
+ className,
49
+ )}
50
+ >
51
+ <Show when={hasImage}>
52
+ <img src={src} alt={alt ?? name ?? ''} className="size-full object-cover" />
53
+ </Show>
54
+ <Show when={hasInitials}>
55
+ <span
56
+ aria-hidden="true"
57
+ className="inline-flex size-full items-center justify-center"
58
+ >
59
+ <Text as="span" value={initials} />
60
+ </span>
61
+ </Show>
62
+ </span>
63
+ )
64
+ }
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "avatar",
3
+ "kind": "component",
4
+ "framework": "react",
5
+ "description": "Round avatar that falls back to initials on a neutral gradient.",
6
+ "dependencies": [
7
+ "cn"
8
+ ],
9
+ "peers": [
10
+ "@blankways/state",
11
+ "@blankways/state-react@0.1.0-alpha.1",
12
+ "react"
13
+ ],
14
+ "suggestions": [
15
+ "styles-tokens",
16
+ "styles-base",
17
+ "styles-components",
18
+ "styles-utilities"
19
+ ],
20
+ "files": [
21
+ {
22
+ "source": "Avatar.tsx",
23
+ "target": "components/avatar/Avatar.tsx"
24
+ },
25
+ {
26
+ "source": "index.ts",
27
+ "target": "components/avatar/index.ts"
28
+ }
29
+ ]
30
+ }
@@ -0,0 +1 @@
1
+ export { Avatar, type AvatarProps } from './Avatar.js'
@@ -0,0 +1,76 @@
1
+ import { useEffect, useMemo, useRef } from 'react'
2
+ import type { ReactNode } from 'react'
3
+ import { State, type StateId } from '@blankways/state'
4
+ import {
5
+ Text,
6
+ useAttributes,
7
+ useMatch,
8
+ useState,
9
+ type ReactiveAttributes,
10
+ } from '@blankways/state-react'
11
+ import { cn } from '../../internals/cn.js'
12
+
13
+ const TONE_CASES = ['default', 'brand', 'success', 'warning', 'danger'] as const
14
+
15
+ export type BadgeTone = (typeof TONE_CASES)[number]
16
+
17
+ export type BadgeProps = {
18
+ children: ReactNode | StateId<string>
19
+ tone?: BadgeTone
20
+ className?: string
21
+ }
22
+
23
+ const toneClasses: Record<BadgeTone, string> = {
24
+ default: 'bg-surface-2 text-ink-soft',
25
+ brand: 'bg-accent-soft text-accent-soft-fg',
26
+ success: 'bg-surface-2 text-ink',
27
+ warning: 'bg-ink/10 text-ink',
28
+ danger: 'bg-ink/20 text-ink',
29
+ }
30
+
31
+ function useSyncedState<Type>(value: Type): StateId<Type> {
32
+ const state = useState(value)
33
+ useEffect(() => {
34
+ if (!Object.is(State.get(state), value)) State.set(state, value)
35
+ }, [state, value])
36
+ return state
37
+ }
38
+
39
+ /** Small pill for statuses and labels; children may be a reactive text state. */
40
+ export function Badge({ children, tone = 'default', className }: BadgeProps) {
41
+ const toneState = useSyncedState(tone)
42
+ const [isDefault, isBrand, isSuccess, isWarning, isDanger] = useMatch(
43
+ toneState,
44
+ TONE_CASES,
45
+ )
46
+ const ref = useRef<HTMLSpanElement | null>(null)
47
+ const attributes = useMemo<ReactiveAttributes<HTMLSpanElement>>(
48
+ () => ({
49
+ 'data-tone': toneState,
50
+ 'data-tone-default': isDefault,
51
+ 'data-tone-brand': isBrand,
52
+ 'data-tone-success': isSuccess,
53
+ 'data-tone-warning': isWarning,
54
+ 'data-tone-danger': isDanger,
55
+ }),
56
+ [toneState, isDefault, isBrand, isSuccess, isWarning, isDanger],
57
+ )
58
+ useAttributes(ref, attributes)
59
+
60
+ return (
61
+ <span
62
+ ref={ref}
63
+ className={cn(
64
+ 'motion-lift inline-flex items-center rounded-2xl px-[0.469rem] py-[0.188rem] text-[11px] leading-none font-semibold tracking-wide',
65
+ toneClasses[tone],
66
+ className,
67
+ )}
68
+ >
69
+ {typeof children === 'number' ? (
70
+ <Text as="span" value={children as StateId<string>} />
71
+ ) : (
72
+ children
73
+ )}
74
+ </span>
75
+ )
76
+ }
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "badge",
3
+ "kind": "component",
4
+ "framework": "react",
5
+ "description": "Compact status pill with reactive tones and optional reactive text.",
6
+ "dependencies": [
7
+ "cn"
8
+ ],
9
+ "peers": [
10
+ "@blankways/state",
11
+ "@blankways/state-react@0.1.0-alpha.1",
12
+ "react"
13
+ ],
14
+ "suggestions": [
15
+ "styles-tokens",
16
+ "styles-base",
17
+ "styles-components",
18
+ "styles-utilities"
19
+ ],
20
+ "files": [
21
+ {
22
+ "source": "Badge.tsx",
23
+ "target": "components/badge/Badge.tsx"
24
+ },
25
+ {
26
+ "source": "index.ts",
27
+ "target": "components/badge/index.ts"
28
+ }
29
+ ]
30
+ }
@@ -0,0 +1 @@
1
+ export { Badge, type BadgeProps, type BadgeTone } from './Badge.js'
@@ -0,0 +1,24 @@
1
+ export type BrandLogoProps = {
2
+ className?: string
3
+ /** Accessible name; omit it for a decorative, hidden logo. */
4
+ title?: string
5
+ }
6
+
7
+ /** Official Bisnes symbol: SVG only, no wordmark. Inherits the current text color. */
8
+ export function BrandLogo({ className, title }: BrandLogoProps) {
9
+ return (
10
+ <svg
11
+ viewBox="0 0 240 244"
12
+ focusable="false"
13
+ role={title ? 'img' : undefined}
14
+ aria-hidden={title ? undefined : true}
15
+ className={['h-8 w-auto fill-current text-brand-500', className]
16
+ .filter(Boolean)
17
+ .join(' ')}
18
+ >
19
+ {title ? <title>{title}</title> : null}
20
+ <path d="M33 40H52C75 40 93 59 93 83V214C59 205 33 179 33 150Z" />
21
+ <path d="M104 96H148C178 96 201 123 201 155C201 188 178 215 145 215H100V181C100 168 108 160 121 160H157C163 160 168 157 168 154C165 151 160 149 154 149H104Z" />
22
+ </svg>
23
+ )
24
+ }
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "brand-logo",
3
+ "kind": "component",
4
+ "framework": "react",
5
+ "description": "Native SVG brand symbol with an optional accessible title.",
6
+ "dependencies": [],
7
+ "peers": [
8
+ "react"
9
+ ],
10
+ "suggestions": [
11
+ "styles-tokens",
12
+ "styles-base",
13
+ "styles-components",
14
+ "styles-utilities"
15
+ ],
16
+ "files": [
17
+ {
18
+ "source": "BrandLogo.tsx",
19
+ "target": "components/brand-logo/BrandLogo.tsx"
20
+ },
21
+ {
22
+ "source": "index.ts",
23
+ "target": "components/brand-logo/index.ts"
24
+ }
25
+ ]
26
+ }
@@ -0,0 +1 @@
1
+ export { BrandLogo, type BrandLogoProps } from './BrandLogo.js'