@@ -11,11 +11,6 @@ const exportAsTypescript = computed(() => store.exportAsTypescript);
11
11
const activeRoute = computed ( ( ) => store . activeRoute ) ;
12
12
13
13
14
- export const createBoilerOptions = ( componentName : string , children : string [ ] | {
15
- [ key : string ] : RouteComponentMap | Component ;
16
- App : RouteComponentMap ;
17
- HomeView : RouteComponentMap ;
18
- } ) => {
19
14
export const createBoilerOptions = ( componentName : string , children : string [ ] | {
20
15
[ key : string ] : RouteComponentMap | Component ;
21
16
App : RouteComponentMap ;
@@ -24,7 +19,6 @@ export const createBoilerOptions = (componentName: string, children: string[] |
24
19
// add import mapstate and mapactions if they exist
25
20
let imports = "" ;
26
21
const activeComp = componentMap . value [ activeComponent . value ] as Component ;
27
- // console.log('activeComp in Options is ',activeComp)
28
22
// if (checked.value === false) {
29
23
if ( activeComp . actions . length || activeComp . state . length ) {
30
24
imports += "import { " ;
@@ -75,7 +69,7 @@ export const createBoilerOptions = (componentName: string, children: string[] |
75
69
76
70
const vtComponents : string [ ] = [ ] ;
77
71
78
- htmlBinding . forEach ( ( el : { text : string ; } ) => {
72
+ htmlBinding . forEach ( ( el ) => {
79
73
if ( vuetensilsSet . has ( el . text ) ) {
80
74
// Add import statement for Vuetensils components
81
75
vtComponents . push ( el . text ) ;
@@ -89,7 +83,7 @@ export const createBoilerOptions = (componentName: string, children: string[] |
89
83
}
90
84
91
85
data += " data() {\n return {\n" ;
92
- htmlBinding . forEach ( ( el : { binding : string } ) => {
86
+ htmlBinding . forEach ( ( el ) => {
93
87
if ( el . binding !== "" ) {
94
88
data += ` ${ el . binding } : "PLACEHOLDER FOR VALUE", ` ;
95
89
data += "\n" ;
@@ -204,9 +198,6 @@ export const createBoilerComposition = (componentName: string, children: string[
204
198
imports += 'import { defineComponent } from "vue";\n' ;
205
199
}
206
200
207
- let childrenComponentNames = "\n" ;
208
-
209
- if ( Array . isArray ( children ) ) {
210
201
// add imports for children
211
202
let childrenComponentNames = "\n" ;
212
203
if ( Array . isArray ( children ) ) {
@@ -220,137 +211,136 @@ if (Array.isArray(children)){
220
211
} ) ;
221
212
}
222
213
223
- // if true add data section and populate with props
224
- let data = "" ;
225
- if ( activeComp . props . length ) {
226
- data += " props: {" ;
227
- activeComp . props . forEach ( ( prop ) => {
228
- data += `\n ${ prop } : "PLACEHOLDER FOR VALUE",` ;
229
- } ) ;
230
- data += "\n" ;
231
- //data += " }\n";
232
- data += " },\n" ;
233
- }
214
+ // if true add data section and populate with props
215
+ let data = "" ;
216
+ if ( activeComp . props . length ) {
217
+ data += " props: {" ;
218
+ activeComp . props . forEach ( ( prop ) => {
219
+ data += `\n ${ prop } : "PLACEHOLDER FOR VALUE",` ;
220
+ } ) ;
221
+ data += "\n" ;
222
+ //data += " }\n";
223
+ data += " },\n" ;
224
+ }
234
225
235
226
236
- const htmlBinding = componentMap . value [ activeComponent . value ] . htmlList ;
227
+ const htmlBinding = componentMap . value [ activeComponent . value ] . htmlList ;
237
228
238
- // [OverVue v.10.0] add Vuetensils import statements to <script setup>
229
+ // [OverVue v.10.0] add Vuetensils import statements to <script setup>
239
230
240
- const vuetensilsSet = new Set ( Object . keys ( vtIcons ) ) ;
231
+ const vuetensilsSet = new Set ( Object . keys ( vtIcons ) ) ;
241
232
242
- let vuetensilsImports = "" ;
233
+ let vuetensilsImports = "" ;
243
234
244
- const vtComponents : string [ ] = [ ] ;
235
+ const vtComponents : string [ ] = [ ] ;
245
236
246
- htmlBinding . forEach ( ( el : { text : string } ) => {
247
- if ( vuetensilsSet . has ( el . text ) ) {
248
- // Add import statement for Vuetensils components
249
- vtComponents . push ( el . text ) ;
250
- }
251
- } ) ;
237
+ htmlBinding . forEach ( ( el ) => {
238
+ if ( vuetensilsSet . has ( el . text ) ) {
239
+ // Add import statement for Vuetensils components
240
+ vtComponents . push ( el . text ) ;
241
+ }
242
+ } ) ;
252
243
253
- if ( vtComponents . length ) {
254
- vuetensilsImports += `import { ${ vtComponents . join (
255
- ", "
256
- ) } } from 'vuetensils/src/components';\n`;
257
- }
244
+ if ( vtComponents . length ) {
245
+ vuetensilsImports += `import { ${ vtComponents . join (
246
+ ", "
247
+ ) } } from 'vuetensils/src/components';\n`;
248
+ }
258
249
/*------------- setup() function -------------*/
259
250
data += " setup() {"
260
- data += " setup() {"
261
251
if ( activeComp . state . length || activeComp . actions . length ) {
262
- data += " \n const /* testStore */ = useStore(); " ;
252
+ data += " \n const /* testStore */ = useStore(); " ;
263
253
}
264
- htmlBinding . forEach ( ( el : { binding : string } ) => {
265
- if ( el . binding !== "" ) {
266
- data += ` ${ el . binding } : "PLACEHOLDER FOR VALUE", ` ;
267
- data += "\n" ;
268
- }
269
- } ) ;
254
+ htmlBinding . forEach ( ( el ) => {
255
+ if ( el . binding !== "" ) {
256
+ data += ` ${ el . binding } : "PLACEHOLDER FOR VALUE", ` ;
257
+ data += "\n" ;
258
+ }
259
+ } ) ;
270
260
271
- let returnStatement = "" ;
261
+ let returnStatement = "" ;
272
262
273
- if ( activeComp . state . length || activeComp . actions . length ) {
274
- returnStatement = "\n return { \n" ;
275
- }
263
+ if ( activeComp . state . length || activeComp . actions . length ) {
264
+ returnStatement = "\n return { \n" ;
265
+ }
276
266
277
267
278
- // if true add computed section and populate with state
279
- let computed = "" ;
280
- if ( activeComp . state . length ) {
281
- const currState =
282
- activeComp . state . forEach ( ( state ) => {
283
- data += `\n const ${ state } = computed(() => /* testStore */.${ state } ); ` ;
284
- returnStatement += ` ${ state } , \n`
268
+ // if true add computed section and populate with state
269
+ let computed = "" ;
270
+ if ( activeComp . state . length ) {
271
+ const currState =
272
+ activeComp . state . forEach ( ( state ) => {
273
+ data += `\n const ${ state } = computed(() => /* testStore */.${ state } ); ` ;
274
+ returnStatement += ` ${ state } , \n`
285
275
286
- } ) ;
287
- }
276
+ } ) ;
277
+ }
288
278
289
- data += '\n'
279
+ data += '\n'
290
280
291
- // if true add methods section and populate with actions
292
- let methods = "" ;
293
- if ( activeComp . actions . length ) {
294
- activeComp . actions . forEach ( ( action ) => {
295
- methods += `\n const ${ action } = () => /* testStore */.${ action } ();` ;
296
- returnStatement += ` ${ action } , \n`
297
- } ) ;
298
- }
281
+ // if true add methods section and populate with actions
282
+ let methods = "" ;
283
+ if ( activeComp . actions . length ) {
284
+ activeComp . actions . forEach ( ( action ) => {
285
+ methods += `\n const ${ action } = () => /* testStore */.${ action } ();` ;
286
+ returnStatement += ` ${ action } , \n`
287
+ } ) ;
288
+ }
299
289
300
- let htmlArray = componentMap . value [ componentName ] . htmlList ;
301
- let styleString = "" ;
302
- const activeCompObj = activeComponentObj . value as Component ; // typed this to fix activeComponentObj.value "is possibly null" error
303
- if (
304
- activeComponentObj . value &&
305
- ( activeComponentObj . value as Component ) . htmlAttributes . class !== ""
306
- ) {
307
- styleString += `.${
308
- ( activeComponentObj . value as Component ) . htmlAttributes . class
309
- } { \n\tbackground-color: ${ ( activeComponentObj . value as Component ) . color } ;
290
+ let htmlArray = componentMap . value [ componentName ] . htmlList ;
291
+ let styleString = "" ;
292
+ const activeCompObj = activeComponentObj . value as Component ; // typed this to fix activeComponentObj.value "is possibly null" error
293
+ if (
294
+ activeComponentObj . value &&
295
+ ( activeComponentObj . value as Component ) . htmlAttributes . class !== ""
296
+ ) {
297
+ styleString += `.${
298
+ ( activeComponentObj . value as Component ) . htmlAttributes . class
299
+ } { \n\tbackground-color: ${ ( activeComponentObj . value as Component ) . color } ;
310
300
\tgrid-area: ${
311
- ( activeComponentObj . value as Component ) . htmlAttributes . gridArea [ 0 ]
312
- } / ${
313
- ( activeComponentObj . value as Component ) . htmlAttributes . gridArea [ 1 ]
314
- } / ${
315
- ( activeComponentObj . value as Component ) . htmlAttributes . gridArea [ 2 ]
316
- } / ${ ( activeComponentObj . value as Component ) . htmlAttributes . gridArea [ 3 ] } ;
301
+ ( activeComponentObj . value as Component ) . htmlAttributes . gridArea [ 0 ]
302
+ } / ${
303
+ ( activeComponentObj . value as Component ) . htmlAttributes . gridArea [ 1 ]
304
+ } / ${
305
+ ( activeComponentObj . value as Component ) . htmlAttributes . gridArea [ 2 ]
306
+ } / ${ ( activeComponentObj . value as Component ) . htmlAttributes . gridArea [ 3 ] } ;
317
307
\tz-index: ${ ( activeComponentObj . value as Component ) . z } ;
318
308
} \n` ;
319
- }
309
+ }
320
310
321
- for ( const html of htmlArray ) {
322
- if ( html . class === " " ) styleString = "" ;
323
- if ( html . class ) {
324
- styleString += `.${ html . class } {\n height: ${ html . h } %; \n width: ${ html . w } %; \n top: ${ html . x } %;
325
- \n left: ${ html . y } %; \n z-index: ${ html . z } ;}\n` ;
311
+ for ( const html of htmlArray ) {
312
+ if ( html . class === " " ) styleString = "" ;
313
+ if ( html . class ) {
314
+ styleString += `.${ html . class } {\n height: ${ html . h } %; \n width: ${ html . w } %; \n top: ${ html . x } %;
315
+ \n left: ${ html . y } %; \n z-index: ${ html . z } ;}\n` ;
316
+ }
326
317
}
327
- }
328
318
329
- // concat all code within script tags
330
- // if exportAsTypescript is on, out should be <script lang="ts">
331
- let output ;
332
- if ( exportAsTypescript . value === "on" ) {
333
- output = "\n\n<script lang='ts'>\n" ;
334
- output +=
335
- vuetensilsImports +
336
- imports +
337
- "\nexport default defineComponent ({\n name: '" +
338
- componentName +
339
- "';" ;
340
- } else {
341
- output = "\n\n<script>\n" ;
342
- output +=
343
- vuetensilsImports +
344
- imports +
345
- "\nexport default {\n name: '" +
346
- componentName +
347
- "'" ;
348
- }
349
- output += ",\n components: {" ;
350
- output += childrenComponentNames + " },\n" ;
351
- output += data ;
352
- output += computed ;
353
- output += methods ;
319
+ // concat all code within script tags
320
+ // if exportAsTypescript is on, out should be <script lang="ts">
321
+ let output ;
322
+ if ( exportAsTypescript . value === "on" ) {
323
+ output = "\n\n<script lang='ts'>\n" ;
324
+ output +=
325
+ vuetensilsImports +
326
+ imports +
327
+ "\nexport default defineComponent ({\n name: '" +
328
+ componentName +
329
+ "';" ;
330
+ } else {
331
+ output = "\n\n<script>\n" ;
332
+ output +=
333
+ vuetensilsImports +
334
+ imports +
335
+ "\nexport default {\n name: '" +
336
+ componentName +
337
+ "'" ;
338
+ }
339
+ output += ",\n components: {" ;
340
+ output += childrenComponentNames + " },\n" ;
341
+ output += data ;
342
+ output += computed ;
343
+ output += methods ;
354
344
355
345
if ( exportAsTypescript . value === "on" ) {
356
346
if ( activeComp . state . length || activeComp . actions . length ) {
0 commit comments