@cyber-harbour/ui 2.2.43 → 3.0.0-fix-button-focus-visible.0

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 (67) hide show
  1. package/README.md +115 -205
  2. package/bin/switch-ui-lib.js +218 -106
  3. package/dist/Icons/index.d.mts +468 -0
  4. package/dist/Icons/index.d.ts +468 -0
  5. package/dist/Icons/index.js +2 -0
  6. package/dist/Icons/index.js.map +1 -0
  7. package/dist/Icons/index.mjs +2 -0
  8. package/dist/Icons/index.mjs.map +1 -0
  9. package/dist/PdfDriver-IRXY5HVF.js +2 -0
  10. package/dist/PdfDriver-IRXY5HVF.js.map +1 -0
  11. package/dist/PdfDriver-XCFXTEEH.mjs +2 -0
  12. package/dist/PdfDriver-XCFXTEEH.mjs.map +1 -0
  13. package/dist/chunk-47BJH42B.mjs +2 -0
  14. package/dist/chunk-47BJH42B.mjs.map +1 -0
  15. package/dist/chunk-47O3IYW3.js +3 -0
  16. package/dist/chunk-47O3IYW3.js.map +1 -0
  17. package/dist/chunk-4O4WHXDT.mjs +3 -0
  18. package/dist/chunk-4O4WHXDT.mjs.map +1 -0
  19. package/dist/chunk-7F6XMY63.mjs +3 -0
  20. package/dist/chunk-7F6XMY63.mjs.map +1 -0
  21. package/dist/chunk-7LHQWEWV.mjs +2 -0
  22. package/dist/chunk-7LHQWEWV.mjs.map +1 -0
  23. package/dist/chunk-AYDF3IFZ.js +2 -0
  24. package/dist/chunk-AYDF3IFZ.js.map +1 -0
  25. package/dist/chunk-HFG4KP6L.js +2 -0
  26. package/dist/chunk-HFG4KP6L.js.map +1 -0
  27. package/dist/chunk-JVDLOXO7.js +2 -0
  28. package/dist/chunk-JVDLOXO7.js.map +1 -0
  29. package/dist/chunk-NQZUCXJV.js +2 -0
  30. package/dist/chunk-NQZUCXJV.js.map +1 -0
  31. package/dist/chunk-QWPVIX2T.mjs +2 -0
  32. package/dist/chunk-QWPVIX2T.mjs.map +1 -0
  33. package/dist/chunk-S3RLHUDJ.js +3 -0
  34. package/dist/chunk-S3RLHUDJ.js.map +1 -0
  35. package/dist/chunk-XP4PPF7V.mjs +2 -0
  36. package/dist/chunk-XP4PPF7V.mjs.map +1 -0
  37. package/dist/index.d.mts +1646 -1871
  38. package/dist/index.d.ts +1646 -1871
  39. package/dist/index.js +8 -1690
  40. package/dist/index.js.map +1 -1
  41. package/dist/index.mjs +8 -1690
  42. package/dist/index.mjs.map +1 -1
  43. package/dist/styles/design-tokens.css +839 -0
  44. package/dist/styles/legacy-token-aliases.css +26 -0
  45. package/dist/styles/tailwind.css +477 -3
  46. package/dist/utils/index.d.mts +7 -0
  47. package/dist/utils/index.d.ts +7 -0
  48. package/dist/utils/index.js +2 -0
  49. package/dist/utils/index.js.map +1 -0
  50. package/dist/utils/index.mjs +2 -0
  51. package/dist/utils/index.mjs.map +1 -0
  52. package/dist/utils-jfCLo6l4.d.mts +26 -0
  53. package/dist/utils-jfCLo6l4.d.ts +26 -0
  54. package/package.json +65 -53
  55. package/dist/PdfDriver-54FN6DBI.js +0 -2
  56. package/dist/PdfDriver-54FN6DBI.js.map +0 -1
  57. package/dist/PdfDriver-AVC3OSKE.mjs +0 -2
  58. package/dist/PdfDriver-AVC3OSKE.mjs.map +0 -1
  59. package/dist/chunk-EGCG27KL.mjs +0 -3
  60. package/dist/chunk-EGCG27KL.mjs.map +0 -1
  61. package/dist/chunk-WRBRJBUL.js +0 -3
  62. package/dist/chunk-WRBRJBUL.js.map +0 -1
  63. package/dist/index.css +0 -3
  64. package/dist/index.css.map +0 -1
  65. package/dist/styles/tailwind.css.map +0 -1
  66. package/dist/styles/tailwind.d.mts +0 -2
  67. package/dist/styles/tailwind.d.ts +0 -2
@@ -1,7 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- const prompts = require('prompts');
4
- const { execSync } = require('child_process');
3
+ const { execFileSync } = require('child_process');
5
4
  const path = require('path');
6
5
  const fs = require('fs');
7
6
 
@@ -48,19 +47,14 @@ const projectRoot = findProjectRoot();
48
47
  const localPath = getLocalPath();
49
48
  const pkgPath = path.resolve(projectRoot, `node_modules/${packageName}/package.json`);
50
49
 
51
- function isUsingLocalVersion() {
52
- try {
53
- const realPath = fs.realpathSync(pkgPath);
54
- return realPath.startsWith(path.resolve(localPath));
55
- } catch {
56
- return false;
57
- }
50
+ function npm(args, cwd) {
51
+ return execFileSync('npm', args, { stdio: 'inherit', cwd });
58
52
  }
59
53
 
60
- function isUsingNpmVersion() {
54
+ function isUsingLocalVersion() {
61
55
  try {
62
56
  const realPath = fs.realpathSync(pkgPath);
63
- return !realPath.includes('..') && realPath.includes('node_modules');
57
+ return realPath.startsWith(path.resolve(localPath));
64
58
  } catch {
65
59
  return false;
66
60
  }
@@ -82,11 +76,134 @@ function checkLocalPathExists() {
82
76
  return true;
83
77
  }
84
78
 
85
- async function main() {
79
+ function printHeader() {
86
80
  console.log(`🏠 Проект: ${projectRoot}`);
87
81
  console.log(`📦 Пакет: ${packageName}`);
88
82
  console.log(`🔧 Локальний шлях: ${localPath}`);
89
83
  console.log('');
84
+ }
85
+
86
+ function printStatus() {
87
+ printHeader();
88
+ if (!fs.existsSync(pkgPath)) {
89
+ console.log('📊 Статус: не встановлено');
90
+ return 'missing';
91
+ }
92
+ if (isUsingLocalVersion()) {
93
+ const realPath = fs.realpathSync(pkgPath);
94
+ console.log(`📊 Статус: local → ${path.dirname(realPath)}`);
95
+ return 'local';
96
+ }
97
+ try {
98
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
99
+ console.log(`📊 Статус: npm @ ${pkg.version}`);
100
+ } catch {
101
+ console.log('📊 Статус: npm (версію не вдалося прочитати)');
102
+ }
103
+ return 'npm';
104
+ }
105
+
106
+ function printHelp() {
107
+ console.log(`Usage: switch-ui-lib [command] [options]
108
+
109
+ Commands:
110
+ local Link the local checkout of ${packageName} via npm link
111
+ npm [version|tag] Install from npm (default: latest)
112
+ status Print current mode (local | npm <version>) and exit
113
+ (no command) Run interactive picker
114
+
115
+ Options:
116
+ -h, --help Show this help and exit
117
+
118
+ Environment:
119
+ UI_LIBRARY_PATH Absolute path to the local ui-kit checkout
120
+ (default: ../ui-kit relative to the consuming project)
121
+
122
+ Examples:
123
+ switch-ui-lib local
124
+ switch-ui-lib npm
125
+ switch-ui-lib npm next
126
+ switch-ui-lib npm 0.42.0
127
+ switch-ui-lib status
128
+ `);
129
+ }
130
+
131
+ function switchToLocal() {
132
+ printHeader();
133
+
134
+ if (!checkLocalPathExists()) {
135
+ return 1;
136
+ }
137
+
138
+ if (isUsingLocalVersion()) {
139
+ console.log('✅ Вже підключено локально.');
140
+ return 0;
141
+ }
142
+
143
+ try {
144
+ console.log('🔄 Видаляємо існуючий пакет...');
145
+ try {
146
+ npm(['uninstall', packageName], projectRoot);
147
+ } catch {
148
+ // Ігноруємо помилку якщо пакет не встановлений
149
+ }
150
+
151
+ // Створюємо глобальний лінк в локальній бібліотеці
152
+ // NB: react/react-dom лінкувати окремо НЕ потрібно — споживач
153
+ // (frontend-svc) має `resolve.dedupe: ['react','react-dom']` у
154
+ // vite.config.ts, що гарантує єдиний інстанс React навіть при
155
+ // symlink-resolution через node_modules/@cyber-harbour/ui.
156
+ console.log('🔄 Створюємо глобальний лінк...');
157
+ npm(['link'], localPath);
158
+
159
+ console.log('🔄 Підключаємо локальну версію...');
160
+ npm(['link', packageName], projectRoot);
161
+
162
+ console.log('✅ Успішно підключено локальну версію через npm link.');
163
+ return 0;
164
+ } catch (error) {
165
+ console.error('❌ Помилка при підключенні локальної версії:', error.message);
166
+ return 1;
167
+ }
168
+ }
169
+
170
+ function switchToNpm(versionOrTag) {
171
+ printHeader();
172
+
173
+ const version = versionOrTag || 'latest';
174
+ const packageToInstall = `${packageName}@${version}`;
175
+
176
+ try {
177
+ console.log('🔄 Видаляємо лінки...');
178
+ try {
179
+ npm(['unlink', packageName], projectRoot);
180
+ } catch {
181
+ // Ігноруємо помилку якщо лінк не існує
182
+ }
183
+
184
+ console.log(`🔄 Встановлюємо ${packageToInstall}...`);
185
+ npm(['install', packageToInstall], projectRoot);
186
+ console.log(`✅ Успішно підключено ${packageToInstall}.`);
187
+ return 0;
188
+ } catch (error) {
189
+ console.error('❌ Помилка при підключенні версії з NPM:', error.message);
190
+ return 1;
191
+ }
192
+ }
193
+
194
+ async function runInteractive() {
195
+ let prompts;
196
+ try {
197
+ require.resolve('prompts');
198
+ prompts = require('prompts');
199
+ } catch {
200
+ console.error('❌ Помилка: пакет "prompts" не знайдено.');
201
+ console.log('💡 Встановіть prompts: npm install --save-dev prompts');
202
+ console.log('💡 Або викличте з аргументами: switch-ui-lib local | npm [version] | status');
203
+ return 1;
204
+ }
205
+
206
+ printHeader();
90
207
 
91
208
  const response = await prompts({
92
209
  type: 'select',
@@ -101,114 +218,109 @@ async function main() {
101
218
  const { mode } = response;
102
219
 
103
220
  if (mode === 'local') {
104
- if (!checkLocalPathExists()) {
105
- return;
106
- }
107
-
108
- if (isUsingLocalVersion()) {
109
- console.log('✅ Вже підключено локально.');
110
- return;
111
- }
221
+ return switchToLocal();
222
+ }
112
223
 
224
+ if (mode === 'npm') {
225
+ let distTags = {};
113
226
  try {
114
- // Спочатку видаляємо існуючий пакет
115
- console.log('🔄 Видаляємо існуючий пакет...');
116
- try {
117
- execSync(`npm uninstall ${packageName}`, { stdio: 'inherit', cwd: projectRoot });
118
- } catch {
119
- // Ігноруємо помилку якщо пакет не встановлений
120
- }
121
-
122
- // Копіюємо React і React DOM з основного проекту в UI бібліотеку
123
- console.log('🔄 Копіюємо React в UI бібліотеку...');
124
- try {
125
- execSync('npm link react react-dom', {
126
- stdio: 'inherit',
127
- cwd: localPath,
128
- });
129
- } catch (error) {
130
- console.log("⚠️ Не вдалося зв'язати React (це може бути нормально)");
131
- }
132
-
133
- // Створюємо глобальний лінк в локальній бібліотеці
134
- console.log('🔄 Створюємо глобальний лінк...');
135
- execSync('npm link', {
136
- stdio: 'inherit',
137
- cwd: localPath,
138
- });
227
+ const raw = execFileSync('npm', ['view', packageName, 'dist-tags', '--json'], {
228
+ stdio: ['ignore', 'pipe', 'ignore'],
229
+ }).toString();
230
+ distTags = JSON.parse(raw);
231
+ } catch {
232
+ console.log('⚠️ Не вдалося отримати список тегів з npm — буде запропоновано ручний ввід.');
233
+ }
139
234
 
140
- // Лінкуємо локальну бібліотеку до проекту
141
- console.log('🔄 Підключаємо локальну версію...');
142
- execSync(`npm link ${packageName}`, { stdio: 'inherit', cwd: projectRoot });
235
+ const PRIMARY_TAGS = ['latest', 'next', 'next-gen', 'beta', 'alpha', 'dev'];
236
+ const tagEntries = Object.entries(distTags).sort(([a], [b]) => {
237
+ const ai = PRIMARY_TAGS.indexOf(a);
238
+ const bi = PRIMARY_TAGS.indexOf(b);
239
+ if (ai !== -1 || bi !== -1) return (ai === -1 ? Infinity : ai) - (bi === -1 ? Infinity : bi);
240
+ return a.localeCompare(b);
241
+ });
242
+ const tagChoices = tagEntries.map(([tag, version]) => ({
243
+ title: `${tag} (${version})`,
244
+ value: tag,
245
+ }));
143
246
 
144
- console.log('✅ Успішно підключено локальну версію через npm link.');
145
- } catch (error) {
146
- console.error('❌ Помилка при підключенні локальної версії:', error.message);
147
- }
148
- }
247
+ const latestIdx = tagChoices.findIndex(c => c.value === 'latest');
149
248
 
150
- if (mode === 'npm') {
151
- const versionResponse = await prompts({
152
- type: 'text',
153
- name: 'version',
154
- message: 'Введіть версію або тег (latest, next, 2.0.0, alpha, beta):',
155
- initial: 'latest',
156
- validate: value => value.length > 0 ? true : 'Версія не може бути пустою'
249
+ const { selected } = await prompts({
250
+ type: 'select',
251
+ name: 'selected',
252
+ message: 'Оберіть тег або вкажіть власну версію:',
253
+ choices: [
254
+ ...tagChoices,
255
+ { title: '✏️ Ввести версію або тег вручну', value: '__custom__' },
256
+ ],
257
+ initial: latestIdx >= 0 ? latestIdx : 0,
157
258
  });
158
-
159
- if (!versionResponse.version) {
259
+
260
+ if (!selected) {
160
261
  console.log('❌ Операція скасована.');
161
- return;
162
- }
163
-
164
- const version = versionResponse.version.startsWith('@')
165
- ? versionResponse.version.substring(1)
166
- : versionResponse.version;
167
- const packageToInstall = `${packageName}@${version}`;
168
-
169
- if (isUsingNpmVersion()) {
170
- console.log('✅ Вже використовується версія з NPM.');
171
- return;
262
+ return 1;
172
263
  }
173
264
 
174
- try {
175
- // Видаляємо лінк якщо він існує
176
- console.log('🔄 Видаляємо лінки...');
177
- try {
178
- execSync(`npm unlink ${packageName}`, { stdio: 'inherit', cwd: projectRoot });
179
- } catch {
180
- // Ігноруємо помилку якщо лінк не існує
181
- }
265
+ let version = selected;
266
+ if (selected === '__custom__') {
267
+ const { custom } = await prompts({
268
+ type: 'text',
269
+ name: 'custom',
270
+ message: 'Введіть версію або тег:',
271
+ initial: 'latest',
272
+ validate: value => (value.length > 0 ? true : 'Версія не може бути пустою'),
273
+ });
182
274
 
183
- // Видаляємо лінк React з UI бібліотеки
184
- if (checkLocalPathExists()) {
185
- console.log('🔄 Видаляємо React лінки з UI бібліотеки...');
186
- try {
187
- execSync('npm unlink react react-dom', {
188
- stdio: 'inherit',
189
- cwd: localPath,
190
- });
191
- } catch {
192
- // Ігноруємо помилку якщо лінк не існує
193
- }
275
+ if (!custom) {
276
+ console.log('❌ Операція скасована.');
277
+ return 1;
194
278
  }
195
279
 
196
- // Встановлюємо пакет з NPM
197
- console.log(`🔄 Встановлюємо ${packageToInstall}...`);
198
- execSync(`npm install ${packageToInstall}`, { stdio: 'inherit', cwd: projectRoot });
199
- console.log(`✅ Успішно підключено ${packageToInstall}.`);
200
- } catch (error) {
201
- console.error('❌ Помилка при підключенні версії з NPM:', error.message);
280
+ version = custom.startsWith('@') ? custom.substring(1) : custom;
202
281
  }
282
+
283
+ return switchToNpm(version);
203
284
  }
285
+
286
+ console.log('❌ Операція скасована.');
287
+ return 1;
204
288
  }
205
289
 
206
- // Перевіряємо чи prompts доступний
207
- try {
208
- require.resolve('prompts');
209
- main().catch(console.error);
210
- } catch (error) {
211
- console.error('❌ Помилка: пакет "prompts" не знайдено.');
212
- console.log('💡 Встановіть prompts: npm install --save-dev prompts');
213
- process.exit(1);
290
+ async function main() {
291
+ const args = process.argv.slice(2);
292
+ const [command, ...rest] = args;
293
+
294
+ if (command === '-h' || command === '--help') {
295
+ printHelp();
296
+ return 0;
297
+ }
298
+
299
+ if (command === 'status') {
300
+ printStatus();
301
+ return 0;
302
+ }
303
+
304
+ if (command === 'local') {
305
+ return switchToLocal();
306
+ }
307
+
308
+ if (command === 'npm') {
309
+ return switchToNpm(rest[0]);
310
+ }
311
+
312
+ if (command !== undefined) {
313
+ console.error(`❌ Невідома команда: ${command}`);
314
+ printHelp();
315
+ return 2;
316
+ }
317
+
318
+ return runInteractive();
214
319
  }
320
+
321
+ main()
322
+ .then(code => process.exit(code ?? 0))
323
+ .catch(error => {
324
+ console.error(error);
325
+ process.exit(1);
326
+ });