renusify 2.5.1 → 3.0.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.
- package/components/app/index.vue +74 -22
- package/components/app/toast/index.vue +76 -71
- package/components/app/toast/toast.vue +62 -44
- package/components/avatar/index.vue +208 -84
- package/components/button/buttonConfirm.vue +53 -26
- package/components/button/buttonGroup.js +0 -2
- package/components/button/buttonGroup.vue +310 -62
- package/components/button/index.vue +584 -100
- package/components/calendar/index.js +0 -2
- package/components/calendar/index.vue +326 -262
- package/components/calendar/month.vue +64 -55
- package/components/calendar/year.vue +30 -25
- package/components/card/index.vue +139 -59
- package/components/codeEditor/highlightCss.vue +38 -39
- package/components/codeEditor/highlightHtml.vue +64 -64
- package/components/codeEditor/highlightJs.vue +37 -38
- package/components/codeEditor/index.vue +129 -79
- package/components/codeEditor/run.vue +225 -39
- package/components/codeEditor/useCodeFormatter.js +150 -0
- package/components/confirm/index.vue +140 -81
- package/components/container/col.vue +5 -4
- package/components/container/divider.vue +28 -19
- package/components/container/index.vue +34 -15
- package/components/container/row.vue +26 -9
- package/components/container/spacer.vue +2 -4
- package/components/container/style.scss +3 -0
- package/components/content/index.vue +49 -32
- package/components/cropper/index.vue +401 -244
- package/components/float/index.vue +542 -415
- package/components/form/addressInput/index.vue +184 -109
- package/components/form/camInput/index.vue +370 -244
- package/components/form/checkInput/index.vue +138 -71
- package/components/form/checkboxInput/index.vue +87 -47
- package/components/form/colorInput/Alpha.vue +81 -83
- package/components/form/colorInput/Hue.vue +91 -68
- package/components/form/colorInput/Preview.vue +43 -47
- package/components/form/colorInput/Saturation.vue +101 -86
- package/components/form/colorInput/index.vue +72 -40
- package/components/form/colorInput/picker.vue +111 -106
- package/components/form/colorInput/useColor.js +153 -0
- package/components/form/dateInput/index.vue +691 -356
- package/components/form/dateInput/month.vue +63 -54
- package/components/form/dateInput/year.vue +35 -25
- package/components/form/fileInput/index.js +0 -1
- package/components/form/fileInput/index.vue +263 -106
- package/components/form/fileInput/single.vue +323 -164
- package/components/form/groupInput/index.vue +199 -101
- package/components/form/index.vue +189 -83
- package/components/form/input/index.vue +416 -377
- package/components/form/jsonInput/JsonView.vue +54 -56
- package/components/form/jsonInput/index.vue +247 -165
- package/components/form/maskInput/index.vue +252 -132
- package/components/form/numberInput/index.js +0 -1
- package/components/form/numberInput/index.vue +226 -117
- package/components/form/passwordInput/index.js +2 -1
- package/components/form/passwordInput/index.vue +269 -102
- package/components/form/radioInput/index.vue +143 -72
- package/components/form/rangeInput/index.vue +280 -167
- package/components/form/ratingInput/index.vue +57 -57
- package/components/form/selectInput/index.js +1 -3
- package/components/form/selectInput/index.vue +584 -296
- package/components/form/switchInput/index.vue +73 -59
- package/components/form/telInput/index.js +0 -1
- package/components/form/telInput/index.vue +238 -135
- package/components/form/textArea/index.vue +72 -35
- package/components/form/textEditor/index.vue +739 -0
- package/components/form/{text-editor → textEditor}/style.scss +8 -16
- package/components/form/textInput/index.vue +54 -32
- package/components/form/timeInput/index.vue +83 -56
- package/components/form/timeInput/range.vue +116 -95
- package/components/form/timeInput/timepicker.vue +382 -449
- package/components/form/uniqueInput/index.vue +105 -48
- package/components/form/unitInput/index.vue +139 -84
- package/components/formCreator/index.js +0 -1
- package/components/formCreator/index.vue +314 -148
- package/components/highlight/index.vue +41 -25
- package/components/highlight/style.scss +2 -2
- package/components/highlight/{mixin.js → useHighlight.js} +181 -160
- package/components/icon/index.vue +79 -33
- package/components/img/index.vue +249 -147
- package/components/img/preview.vue +180 -198
- package/components/img/svgImg.vue +42 -39
- package/components/index.js +5 -20
- package/components/infinite/index.js +1 -2
- package/components/infinite/index.vue +248 -66
- package/components/map/index.vue +428 -261
- package/components/map/route.vue +794 -487
- package/components/map/select.vue +118 -58
- package/components/menu/index.vue +201 -91
- package/components/meta/meta.js +26 -3
- package/components/modal/index.vue +383 -158
- package/components/notify/index.vue +204 -86
- package/components/notify/notification.vue +38 -55
- package/components/progress/circle.vue +189 -70
- package/components/progress/line.vue +266 -46
- package/components/searchBox/index.js +1 -3
- package/components/searchBox/index.vue +194 -101
- package/components/skeleton/index.vue +45 -20
- package/components/slider/index.vue +318 -156
- package/components/swiper/index.vue +254 -106
- package/components/table/crud/footer.vue +77 -53
- package/components/table/crud/header.vue +71 -72
- package/components/table/crud/index.vue +631 -401
- package/components/table/index.vue +721 -278
- package/components/timeAgo/index.vue +145 -96
- package/components/tour/index.vue +338 -235
- package/components/tree/index.vue +235 -89
- package/components/tree/tree-element.vue +107 -106
- package/directive/animate/index.js +77 -0
- package/directive/clickOutSide/index.js +98 -0
- package/directive/drag/index.js +153 -0
- package/directive/index.js +11 -13
- package/directive/intersect/index.js +263 -0
- package/directive/mask/index.js +67 -0
- package/directive/parallax/index.js +78 -0
- package/directive/ripple/index.js +14 -0
- package/directive/scroll/index.js +244 -0
- package/directive/sortable/index.js +274 -0
- package/directive/title/index.js +75 -0
- package/directive/touch/index.js +268 -0
- package/index.js +10 -8
- package/package.json +5 -2
- package/plugins/validation/Validate.js +88 -79
- package/scripts/generate-docs.mjs +226 -0
- package/scripts/menu.mjs +240 -0
- package/scripts/parser.mjs +1086 -0
- package/style/_index.scss +7 -0
- package/style/app.scss +13 -65
- package/style/colors.scss +5 -22
- package/style/functions/index.scss +8 -0
- package/style/mixins/index.scss +17 -5
- package/style/variables/base.scss +154 -175
- package/style/variables/color.scss +0 -12
- package/style/variables/utilities.scss +0 -180
- package/tools/helper.js +0 -8
- package/tools/icons.js +6 -1
- package/tools/root.js +71 -0
- package/components/app/style.scss +0 -41
- package/components/app/toast/style.scss +0 -20
- package/components/avatar/style.scss +0 -32
- package/components/bar/bottomNav.js +0 -1
- package/components/bar/bottomNav.vue +0 -28
- package/components/bar/bottomNavigationCircle.js +0 -2
- package/components/bar/bottomNavigationCircle.vue +0 -99
- package/components/bar/scss/bottomNav.scss +0 -67
- package/components/bar/scss/toolbar.scss +0 -174
- package/components/bar/toolbar/index.js +0 -8
- package/components/bar/toolbar/index.vue +0 -35
- package/components/bar/toolbar/laptop.vue +0 -33
- package/components/bar/toolbar/menuChilds.vue +0 -41
- package/components/bar/toolbar/menuLaptop.vue +0 -41
- package/components/bar/toolbar/menuMob.vue +0 -39
- package/components/bar/toolbar/mixin.js +0 -43
- package/components/bar/toolbar/mobile.vue +0 -34
- package/components/breadcrumb/bredcrumbItem.vue +0 -39
- package/components/breadcrumb/index.js +0 -3
- package/components/breadcrumb/index.vue +0 -71
- package/components/breadcrumb/style.scss +0 -51
- package/components/button/style.scss +0 -411
- package/components/card/style.scss +0 -86
- package/components/chart/chart.js +0 -1
- package/components/chart/chart.vue +0 -69
- package/components/chart/worldMap.js +0 -2
- package/components/chart/worldMap.vue +0 -1112
- package/components/chat/MessageList.vue +0 -163
- package/components/chat/chatInput.vue +0 -150
- package/components/chat/chatMsg.vue +0 -276
- package/components/chat/index.js +0 -11
- package/components/chat/index.vue +0 -113
- package/components/chip/index.js +0 -3
- package/components/chip/index.vue +0 -77
- package/components/chip/style.scss +0 -199
- package/components/codeEditor/mixin.js +0 -145
- package/components/countdown/index.js +0 -1
- package/components/countdown/index.vue +0 -105
- package/components/form/colorInput/mixin.js +0 -132
- package/components/form/fileInput/file.js +0 -148
- package/components/form/telInput/assets/flags.png +0 -0
- package/components/form/telInput/assets/flags@2x.png +0 -0
- package/components/form/text-editor/index.vue +0 -710
- package/components/icon/style.scss +0 -17
- package/components/infinite/div.js +0 -6
- package/components/infinite/div.vue +0 -193
- package/components/infinite/page.js +0 -3
- package/components/infinite/page.vue +0 -105
- package/components/list/index.js +0 -3
- package/components/list/index.vue +0 -122
- package/components/list/style.scss +0 -66
- package/components/message/index.js +0 -4
- package/components/message/index.vue +0 -40
- package/components/modal/style.scss +0 -146
- package/components/nestable/NestableItem.vue +0 -307
- package/components/nestable/editable.js +0 -44
- package/components/nestable/index.js +0 -1
- package/components/nestable/index.vue +0 -226
- package/components/nestable/methods.js +0 -416
- package/components/progress/style.scss +0 -229
- package/components/table/style.scss +0 -338
- package/components/tabs/index.js +0 -3
- package/components/tabs/index.vue +0 -151
- package/components/timeline/index.js +0 -6
- package/components/timeline/index.vue +0 -76
- package/directive/resize/index.js +0 -30
- package/directive/skeleton/index.js +0 -27
- package/directive/skeleton/style.scss +0 -37
- package/plugins/request/Request.js +0 -68
- package/style/animation.scss +0 -94
- package/style/style.scss +0 -8
- package/tools/rootable.js +0 -75
- /package/components/form/{text-editor → textEditor}/index.js +0 -0
- /package/components/form/{text-editor → textEditor}/preview.js +0 -0
- /package/components/form/{text-editor → textEditor}/preview.vue +0 -0
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import {VueComponentAPIParser} from './parser.mjs';
|
|
4
|
+
import {MenuBuilder} from "./menu.mjs";
|
|
5
|
+
|
|
6
|
+
function extractExportPaths(text) {
|
|
7
|
+
const paths = [];
|
|
8
|
+
|
|
9
|
+
const exportRegex = /export\s*\*\s*as\s+(\w+)\s+from\s+['"]([^'"]+)['"]/g;
|
|
10
|
+
|
|
11
|
+
let match;
|
|
12
|
+
while ((match = exportRegex.exec(text)) !== null) {
|
|
13
|
+
paths.push({
|
|
14
|
+
alias: match[1],
|
|
15
|
+
path: match[2]
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return paths;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function build_directives() {
|
|
23
|
+
const componentFiles = fs.readFileSync('./directive/index.js', 'utf-8')
|
|
24
|
+
const simplePaths = extractExportPaths(componentFiles);
|
|
25
|
+
const builder = new MenuBuilder();
|
|
26
|
+
|
|
27
|
+
for (let i = 0; i < simplePaths.length; i++) {
|
|
28
|
+
const name = (simplePaths[i]['alias'])
|
|
29
|
+
|
|
30
|
+
let file_path = "./docs/src/views/index/directive"
|
|
31
|
+
simplePaths[i]['path'].replace('./', '').split("/").forEach(path => {
|
|
32
|
+
if (path !== "index.js") {
|
|
33
|
+
file_path += "/" + path.replace('.js', '')
|
|
34
|
+
}
|
|
35
|
+
})
|
|
36
|
+
builder.addPath(simplePaths[i]['path'])
|
|
37
|
+
|
|
38
|
+
let p = simplePaths[i]['path'].replace('./', './directive/');
|
|
39
|
+
|
|
40
|
+
const vueFile = fs.readFileSync(p, 'utf-8')
|
|
41
|
+
|
|
42
|
+
const componentInfo = VueComponentAPIParser.parse(vueFile)
|
|
43
|
+
|
|
44
|
+
create_component_directive(name, file_path + '/index.vue', componentInfo)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const menu = builder.build('directive');
|
|
48
|
+
|
|
49
|
+
let menu_file = JSON.parse(fs.readFileSync('./docs/src/views/index/menu/menu.json', 'utf-8'))
|
|
50
|
+
menu_file.forEach((item) => {
|
|
51
|
+
if (item.name === 'directive') {
|
|
52
|
+
item.childs = menu
|
|
53
|
+
}
|
|
54
|
+
})
|
|
55
|
+
fs.writeFileSync('./docs/src/views/index/menu/menu.json', JSON.stringify(menu_file, null, 2), 'utf8');
|
|
56
|
+
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function build_components() {
|
|
60
|
+
const componentFiles = fs.readFileSync('./components/index.js', 'utf-8')
|
|
61
|
+
const simplePaths = extractExportPaths(componentFiles);
|
|
62
|
+
const builder = new MenuBuilder();
|
|
63
|
+
|
|
64
|
+
for (let i = 0; i < simplePaths.length; i++) {
|
|
65
|
+
const name = (simplePaths[i]['alias'])
|
|
66
|
+
console.log(name)
|
|
67
|
+
let file_path = "./docs/src/views/index/component"
|
|
68
|
+
simplePaths[i]['path'].replace('./', '').split("/").forEach(path => {
|
|
69
|
+
if (path !== "index.js") {
|
|
70
|
+
file_path += "/" + path.replace('.js', '')
|
|
71
|
+
}
|
|
72
|
+
})
|
|
73
|
+
builder.addPath(simplePaths[i]['path'])
|
|
74
|
+
|
|
75
|
+
let p = simplePaths[i]['path'].replace('./', './components/').replace('.js', '.vue');
|
|
76
|
+
if (name === 'rMeta') {
|
|
77
|
+
p = "./components/meta/meta.js";
|
|
78
|
+
}
|
|
79
|
+
const vueFile = fs.readFileSync(p, 'utf-8')
|
|
80
|
+
|
|
81
|
+
const componentInfo = VueComponentAPIParser.parse(vueFile)
|
|
82
|
+
|
|
83
|
+
create_component(name, file_path + '/index.vue', componentInfo)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const menu = builder.build();
|
|
87
|
+
let menu_file = JSON.parse(fs.readFileSync('./docs/src/views/index/menu/menu.json', 'utf-8'))
|
|
88
|
+
menu_file.forEach((item) => {
|
|
89
|
+
if (item.name === 'component') {
|
|
90
|
+
item.childs = menu
|
|
91
|
+
}
|
|
92
|
+
})
|
|
93
|
+
fs.writeFileSync('./docs/src/views/index/menu/menu.json', JSON.stringify(menu_file, null, 2), 'utf8');
|
|
94
|
+
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function create_component(component_name, file_path, componentInfo = {}) {
|
|
98
|
+
const dirPath = path.dirname(file_path);
|
|
99
|
+
|
|
100
|
+
if (!fs.existsSync(dirPath)) {
|
|
101
|
+
fs.mkdirSync(dirPath, {recursive: true});
|
|
102
|
+
}
|
|
103
|
+
if (Object.keys(componentInfo.example).length === 0) {
|
|
104
|
+
let scr = "import {ref} from 'vue';\n";
|
|
105
|
+
let tmp = "<" + component_name + " "
|
|
106
|
+
componentInfo.props.forEach(prop => {
|
|
107
|
+
if (prop.name === "modelValue") {
|
|
108
|
+
tmp += `\n v-model="${prop.name}"`
|
|
109
|
+
} else {
|
|
110
|
+
tmp += `\n :${prop.name}="${prop.name}"`
|
|
111
|
+
}
|
|
112
|
+
let d = prop.default !== "undefined" ? prop.default : null
|
|
113
|
+
if (prop.default !== "undefined") {
|
|
114
|
+
let types = prop.type.split("|")[0].trim()
|
|
115
|
+
if (types === "String") {
|
|
116
|
+
d = "'" + prop.default + "'"
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
scr += `\nconst ${prop.name}=ref(${d})`
|
|
121
|
+
})
|
|
122
|
+
componentInfo.emits.forEach(emit => {
|
|
123
|
+
tmp += `\n@${emit.name}="log('${emit.name}',$event)"`
|
|
124
|
+
})
|
|
125
|
+
tmp += ">\n"
|
|
126
|
+
componentInfo.slots.forEach(slot => {
|
|
127
|
+
if (slot.example) {
|
|
128
|
+
tmp += `<template #${slot.name}>
|
|
129
|
+
${slot.example}
|
|
130
|
+
</template>\n`
|
|
131
|
+
}
|
|
132
|
+
})
|
|
133
|
+
tmp += "</" + component_name + ">"
|
|
134
|
+
|
|
135
|
+
componentInfo.example['basic usage'] = {
|
|
136
|
+
'template': tmp,
|
|
137
|
+
'script': scr + `\nconst log=(name,e)=>{
|
|
138
|
+
console.log(name,e)
|
|
139
|
+
}`
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
}
|
|
143
|
+
const template = `
|
|
144
|
+
<template>
|
|
145
|
+
<section>
|
|
146
|
+
<r-meta title="${component_name} Component | Renusify" description="Document with example for Renusify ${component_name} component."></r-meta>
|
|
147
|
+
<div class="mb-2">
|
|
148
|
+
<h1 class="display-3 font-weight-light py-1 br-lg">
|
|
149
|
+
${component_name} Component
|
|
150
|
+
</h1>
|
|
151
|
+
</div>
|
|
152
|
+
<table-props :items="info.props"></table-props>
|
|
153
|
+
<table-events :items="info.emits"></table-events>
|
|
154
|
+
<table-provide :items="info.provide"></table-provide>
|
|
155
|
+
<table-expose :items="info.expose"></table-expose>
|
|
156
|
+
<table-slots :items="info.slots"></table-slots>
|
|
157
|
+
</section>
|
|
158
|
+
<br/>
|
|
159
|
+
<section v-for="(item,i) in info.example" :key="i">
|
|
160
|
+
<div class="title-1">{{i}}</div>
|
|
161
|
+
<p class="caption">Press run Button</p>
|
|
162
|
+
<r-code-editor
|
|
163
|
+
runnable
|
|
164
|
+
scriptSetup
|
|
165
|
+
:script='item.script'
|
|
166
|
+
:template='item.template'
|
|
167
|
+
:css='item.style'
|
|
168
|
+
>
|
|
169
|
+
</r-code-editor>
|
|
170
|
+
</section>
|
|
171
|
+
</template>
|
|
172
|
+
<script setup>
|
|
173
|
+
const info=${JSON.stringify(componentInfo, null, 2)}
|
|
174
|
+
</script>`;
|
|
175
|
+
|
|
176
|
+
fs.writeFileSync(file_path, template, 'utf8');
|
|
177
|
+
|
|
178
|
+
return true;
|
|
179
|
+
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function create_component_directive(component_name, file_path, componentInfo = {}) {
|
|
183
|
+
|
|
184
|
+
const dirPath = path.dirname(file_path);
|
|
185
|
+
|
|
186
|
+
if (!fs.existsSync(dirPath)) {
|
|
187
|
+
fs.mkdirSync(dirPath, {recursive: true});
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
const template = `
|
|
191
|
+
<template>
|
|
192
|
+
<section>
|
|
193
|
+
<div class="mb-2">
|
|
194
|
+
<h1 class="display-3 font-weight-light ps-4 pb-1 pt-1 br-lg">
|
|
195
|
+
${component_name} Directive
|
|
196
|
+
</h1>
|
|
197
|
+
</div>
|
|
198
|
+
</section>
|
|
199
|
+
<br/>
|
|
200
|
+
<section v-for="(item,i) in info.example" :key="i">
|
|
201
|
+
<div class="title-1">{{i}}</div>
|
|
202
|
+
<p class="caption">Press run Button</p>
|
|
203
|
+
<r-code-editor
|
|
204
|
+
runnable
|
|
205
|
+
scriptSetup
|
|
206
|
+
:script='item.script'
|
|
207
|
+
:template='item.template'
|
|
208
|
+
:css='item.style'
|
|
209
|
+
>
|
|
210
|
+
</r-code-editor>
|
|
211
|
+
</section>
|
|
212
|
+
</template>
|
|
213
|
+
<script setup>
|
|
214
|
+
const info=${JSON.stringify(componentInfo, null, 2)}
|
|
215
|
+
</script>`;
|
|
216
|
+
|
|
217
|
+
fs.writeFileSync(file_path, template, 'utf8');
|
|
218
|
+
|
|
219
|
+
return true;
|
|
220
|
+
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
build_components()
|
|
225
|
+
build_directives()
|
|
226
|
+
|
package/scripts/menu.mjs
ADDED
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
export class MenuBuilder {
|
|
2
|
+
constructor() {
|
|
3
|
+
this.pathMap = new Map();
|
|
4
|
+
this.addOrder = []; // Track order of addition at root level
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
addPath(path) {
|
|
8
|
+
const normalizedPath = path.replace(/^\.\//, '').replace(/\/index\.js$/, '');
|
|
9
|
+
const parts = normalizedPath.split('/');
|
|
10
|
+
|
|
11
|
+
let currentLevel = this.pathMap;
|
|
12
|
+
let currentAddOrder = this.addOrder; // Track order at current level
|
|
13
|
+
let fullPath = '';
|
|
14
|
+
|
|
15
|
+
for (let i = 0; i < parts.length; i++) {
|
|
16
|
+
const part = parts[i];
|
|
17
|
+
const partName = part.replace(/([A-Z])/g, ' $1').replace(/\.js$/, '').toLowerCase().trim();
|
|
18
|
+
const partKey = part.replace(/\.js$/, '');
|
|
19
|
+
fullPath += (i > 0 ? '/' : '') + partKey;
|
|
20
|
+
|
|
21
|
+
if (i === parts.length - 1) {
|
|
22
|
+
// Leaf node (file)
|
|
23
|
+
if (!currentLevel.has(partKey)) {
|
|
24
|
+
currentLevel.set(partKey, {
|
|
25
|
+
type: 'file',
|
|
26
|
+
name: partName,
|
|
27
|
+
path: fullPath,
|
|
28
|
+
isIndex: path.endsWith('/index.js') || path.endsWith('index.js'),
|
|
29
|
+
addOrder: currentAddOrder.length // Store addition order
|
|
30
|
+
});
|
|
31
|
+
// Track addition order
|
|
32
|
+
currentAddOrder.push(partKey);
|
|
33
|
+
} else {
|
|
34
|
+
const existing = currentLevel.get(partKey);
|
|
35
|
+
if ((path.endsWith('/index.js') || path.endsWith('index.js')) && existing.type === 'dir') {
|
|
36
|
+
existing.hasIndex = true;
|
|
37
|
+
existing.indexPath = fullPath;
|
|
38
|
+
// Don't update addOrder for existing directory with index
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
} else {
|
|
42
|
+
// Directory
|
|
43
|
+
if (!currentLevel.has(partKey)) {
|
|
44
|
+
const newDir = {
|
|
45
|
+
type: 'dir',
|
|
46
|
+
name: partName,
|
|
47
|
+
children: new Map(),
|
|
48
|
+
addOrder: currentAddOrder.length, // Store addition order
|
|
49
|
+
childAddOrder: [], // Track order of children
|
|
50
|
+
hasIndex: false
|
|
51
|
+
};
|
|
52
|
+
currentLevel.set(partKey, newDir);
|
|
53
|
+
// Track addition order
|
|
54
|
+
currentAddOrder.push(partKey);
|
|
55
|
+
} else {
|
|
56
|
+
const existing = currentLevel.get(partKey);
|
|
57
|
+
if (existing.type === 'file') {
|
|
58
|
+
// Convert file to directory
|
|
59
|
+
const newDir = {
|
|
60
|
+
type: 'dir',
|
|
61
|
+
name: existing.name,
|
|
62
|
+
children: new Map(),
|
|
63
|
+
addOrder: existing.addOrder, // Preserve original add order
|
|
64
|
+
childAddOrder: [], // Track order of children
|
|
65
|
+
hasIndex: false
|
|
66
|
+
};
|
|
67
|
+
currentLevel.set(partKey, newDir);
|
|
68
|
+
|
|
69
|
+
// Move existing file into children
|
|
70
|
+
const dir = currentLevel.get(partKey);
|
|
71
|
+
dir.children.set(partKey, {
|
|
72
|
+
type: 'file',
|
|
73
|
+
name: existing.name,
|
|
74
|
+
path: existing.path,
|
|
75
|
+
isIndex: false,
|
|
76
|
+
addOrder: 0 // First child gets order 0
|
|
77
|
+
});
|
|
78
|
+
dir.childAddOrder.push(partKey);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const dir = currentLevel.get(partKey);
|
|
83
|
+
if (!dir.children) {
|
|
84
|
+
dir.children = new Map();
|
|
85
|
+
dir.childAddOrder = [];
|
|
86
|
+
}
|
|
87
|
+
currentLevel = dir.children;
|
|
88
|
+
currentAddOrder = dir.childAddOrder; // Use childAddOrder for this level
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
build(typ = 'component') {
|
|
94
|
+
const convertMapToArray = (map, addOrder) => {
|
|
95
|
+
const result = [];
|
|
96
|
+
|
|
97
|
+
// Sort items by their addOrder property
|
|
98
|
+
const sortedEntries = Array.from(map.entries())
|
|
99
|
+
.sort(([keyA, valueA], [keyB, valueB]) => {
|
|
100
|
+
// Use addOrder if available, otherwise fall back to insertion order
|
|
101
|
+
const orderA = valueA.addOrder !== undefined ? valueA.addOrder : Infinity;
|
|
102
|
+
const orderB = valueB.addOrder !== undefined ? valueB.addOrder : Infinity;
|
|
103
|
+
return orderA - orderB;
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
for (const [key, value] of sortedEntries) {
|
|
107
|
+
if (value.type === 'file') {
|
|
108
|
+
result.push({
|
|
109
|
+
name: value.name,
|
|
110
|
+
to: {
|
|
111
|
+
name: 'pages',
|
|
112
|
+
params: {
|
|
113
|
+
lang: 'en',
|
|
114
|
+
path: `${typ}-${value.path.replace(/\//g, '-')}`
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
} else if (value.type === 'dir') {
|
|
119
|
+
const children = value.children && value.childAddOrder
|
|
120
|
+
? convertMapToArray(value.children, value.childAddOrder)
|
|
121
|
+
: [];
|
|
122
|
+
|
|
123
|
+
// Check if we should create a group or just show as individual item
|
|
124
|
+
if (children.length > 0) {
|
|
125
|
+
// Find index file (child with same name)
|
|
126
|
+
const indexChildIndex = children.findIndex(child => child.name === value.name);
|
|
127
|
+
|
|
128
|
+
if (indexChildIndex !== -1) {
|
|
129
|
+
const indexChild = children[indexChildIndex];
|
|
130
|
+
const otherChildren = children.filter((_, idx) => idx !== indexChildIndex);
|
|
131
|
+
|
|
132
|
+
if (otherChildren.length > 0) {
|
|
133
|
+
result.push({
|
|
134
|
+
name: value.name,
|
|
135
|
+
childs: [
|
|
136
|
+
{
|
|
137
|
+
name: value.name,
|
|
138
|
+
to: indexChild.to
|
|
139
|
+
},
|
|
140
|
+
...otherChildren
|
|
141
|
+
]
|
|
142
|
+
});
|
|
143
|
+
} else {
|
|
144
|
+
// Just the index file, no need for grouping
|
|
145
|
+
result.push(indexChild);
|
|
146
|
+
}
|
|
147
|
+
} else if (children.length === 1 && children[0].name === value.name) {
|
|
148
|
+
// Single child with same name (flatten)
|
|
149
|
+
result.push(children[0]);
|
|
150
|
+
} else {
|
|
151
|
+
// Group all children
|
|
152
|
+
result.push({
|
|
153
|
+
name: value.name,
|
|
154
|
+
childs: children
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
} else if (value.hasIndex && value.indexPath) {
|
|
158
|
+
// Directory with only an index file
|
|
159
|
+
result.push({
|
|
160
|
+
name: value.name,
|
|
161
|
+
to: {
|
|
162
|
+
name: 'pages',
|
|
163
|
+
params: {
|
|
164
|
+
lang: 'en',
|
|
165
|
+
path: `${typ}-${value.indexPath.replace(/\//g, '-')}`
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
} else {
|
|
170
|
+
// Empty directory
|
|
171
|
+
result.push({
|
|
172
|
+
name: value.name,
|
|
173
|
+
childs: []
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return result;
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
return convertMapToArray(this.pathMap, this.addOrder);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// Simplified version that preserves addition order
|
|
186
|
+
buildSimple(typ = 'component') {
|
|
187
|
+
const convertMapToArray = (map, addOrder) => {
|
|
188
|
+
// Sort by addOrder
|
|
189
|
+
const sortedEntries = Array.from(map.entries())
|
|
190
|
+
.sort(([keyA, valueA], [keyB, valueB]) => {
|
|
191
|
+
const orderA = valueA.addOrder !== undefined ? valueA.addOrder : Infinity;
|
|
192
|
+
const orderB = valueB.addOrder !== undefined ? valueB.addOrder : Infinity;
|
|
193
|
+
return orderA - orderB;
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
return sortedEntries.map(([key, value]) => {
|
|
197
|
+
if (value.type === 'file') {
|
|
198
|
+
return {
|
|
199
|
+
name: value.name,
|
|
200
|
+
to: {
|
|
201
|
+
name: 'pages',
|
|
202
|
+
params: {
|
|
203
|
+
lang: 'en',
|
|
204
|
+
path: `${typ}-${value.path.replace(/\//g, '-')}`
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// Directory
|
|
211
|
+
const children = value.children && value.childAddOrder
|
|
212
|
+
? convertMapToArray(value.children, value.childAddOrder)
|
|
213
|
+
: [];
|
|
214
|
+
|
|
215
|
+
if (value.hasIndex && value.indexPath) {
|
|
216
|
+
const baseItem = {
|
|
217
|
+
name: value.name,
|
|
218
|
+
to: {
|
|
219
|
+
name: 'pages',
|
|
220
|
+
params: {
|
|
221
|
+
lang: 'en',
|
|
222
|
+
path: `${typ}-${value.indexPath.replace(/\//g, '-')}`
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
return children.length > 0
|
|
228
|
+
? {...baseItem, childs: children}
|
|
229
|
+
: baseItem;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
return children.length > 0
|
|
233
|
+
? {name: value.name, childs: children}
|
|
234
|
+
: {name: value.name, childs: []};
|
|
235
|
+
});
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
return convertMapToArray(this.pathMap, this.addOrder);
|
|
239
|
+
}
|
|
240
|
+
}
|