rxn-ui 0.6.2 → 0.6.3

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/cli/add.js CHANGED
@@ -10,8 +10,10 @@ import { log } from './utils/logger.js'
10
10
  // Patterns to detect and rewrite import paths
11
11
  const IMPORT_PATTERNS = [
12
12
  { type: 'assets', regex: /\.\.\/\.\.\/assets\//g },
13
+ { type: 'assets', regex: /@\/assets\//g },
13
14
  { type: 'composables', regex: /\.\.\/\.\.\/composables\//g },
14
15
  { type: 'utils', regex: /\.\.\/\.\.\/utils\//g },
16
+ { type: 'components', regex: /\.\.\/([\w-]+)\//g },
15
17
  ]
16
18
 
17
19
  export async function add(componentName, cmdOptions = {}) {
@@ -49,6 +51,18 @@ export async function add(componentName, cmdOptions = {}) {
49
51
  // Скачиваем зависимости (assets, composables, utils)
50
52
  const depDirs = await downloadDependencies(entry, config)
51
53
 
54
+ // Скачиваем компонентные зависимости
55
+ if (entry.components) {
56
+ for (const compName of entry.components) {
57
+ const compEntry = registry[compName]
58
+ if (!compEntry) {
59
+ log.error(`Dependency "${compName}" not found`)
60
+ continue
61
+ }
62
+ await addDependency(compName, compEntry, config)
63
+ }
64
+ }
65
+
52
66
  // Скачиваем файлы компонента
53
67
  await downloadItems({
54
68
  type: entry.type,
@@ -61,6 +75,29 @@ export async function add(componentName, cmdOptions = {}) {
61
75
  rewriteImports(entry.files, destDir, depDirs, isMultipleFiles)
62
76
  }
63
77
 
78
+ async function addDependency(compName, compEntry, config) {
79
+ const isMultipleFiles = compEntry.files.length > 1
80
+ const destDir = isMultipleFiles
81
+ ? path.join(cwd, config[compEntry.type], compName)
82
+ : path.join(cwd, config[compEntry.type])
83
+
84
+ log.bold(`\nAdding dependency ${compName}...`)
85
+
86
+ // Скачиваем зависимости компонента
87
+ const depDirs = await downloadDependencies(compEntry, config)
88
+
89
+ // Скачиваем файлы
90
+ await downloadItems({
91
+ type: compEntry.type,
92
+ componentName: compName,
93
+ files: compEntry.files,
94
+ destDir,
95
+ })
96
+
97
+ // Переписываем импорты
98
+ rewriteImports(compEntry.files, destDir, depDirs, isMultipleFiles)
99
+ }
100
+
64
101
  async function downloadDependencies(entry, config) {
65
102
  const deps = entry.dependencies
66
103
  if (!deps) return {}
@@ -91,17 +128,26 @@ function rewriteImports(files, destDir, depDirs, isMultipleFiles) {
91
128
 
92
129
  for (const { type, regex } of IMPORT_PATTERNS) {
93
130
  if (!depDirs[type]) continue
94
- if (!regex.test(content)) continue
95
131
 
96
132
  // Reset regex lastIndex
97
133
  regex.lastIndex = 0
98
134
 
135
+ if (!regex.test(content)) continue
136
+ regex.lastIndex = 0
137
+
99
138
  // Calculate relative path from component file to dependency dir
100
139
  const fileDir = isMultipleFiles ? destDir : path.dirname(filePath)
101
140
  const relPath = path.relative(fileDir, depDirs[type]).replace(/\\/g, '/')
102
141
  const importPath = relPath.startsWith('.') ? relPath : `./${relPath}`
103
142
 
104
- content = content.replace(regex, `${importPath}/`)
143
+ if (type === 'components') {
144
+ // For component imports like ../button-base/ -> ./button-base/
145
+ content = content.replace(regex, (match, compName) => {
146
+ return `${importPath}/${compName}/`
147
+ })
148
+ } else {
149
+ content = content.replace(regex, `${importPath}/`)
150
+ }
105
151
  }
106
152
 
107
153
  fs.writeFileSync(filePath, content)
package/cli/registry.json CHANGED
@@ -33,6 +33,21 @@
33
33
  "utils": ["cssParser.ts", "mergeDefaultProps.ts"]
34
34
  }
35
35
  },
36
+ "sidebar-base": {
37
+ "type": "components",
38
+ "files": [
39
+ "SidebarBase.vue",
40
+ "SidebarButton.vue",
41
+ "sidebar-context.ts",
42
+ "use-resize.ts",
43
+ "types.ts"
44
+ ],
45
+ "dependencies": {
46
+ "assets": ["ChevronDoubleIcon.vue"],
47
+ "composables": ["useRefWithLocalStorage.ts"]
48
+ },
49
+ "components": ["button-base"]
50
+ },
36
51
  "switch-base": {
37
52
  "type": "components",
38
53
  "files": ["SwitchBase.vue"]
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "rxn-ui",
3
3
  "description": "Vue 3 UI component library",
4
- "version": "0.6.2",
4
+ "version": "0.6.3",
5
5
  "license": "MIT",
6
6
  "private": false,
7
7
  "type": "module",
@@ -23,7 +23,8 @@
23
23
  "dev": "vite",
24
24
  "format": "prettier --write .",
25
25
  "storybook": "storybook dev -p 6006",
26
- "build-storybook": "storybook build"
26
+ "build-storybook": "storybook build",
27
+ "build": "vite build"
27
28
  },
28
29
  "peerDependencies": {
29
30
  "vue": "^3.5.0",