@vc-shell/create-vc-app 2.0.0-alpha.3 → 2.0.0-alpha.31

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 (61) hide show
  1. package/CHANGELOG.md +2816 -0
  2. package/dist/commands/init.d.ts.map +1 -1
  3. package/dist/commands/init.test.d.ts +2 -0
  4. package/dist/commands/init.test.d.ts.map +1 -0
  5. package/dist/engine/codegen.d.ts.map +1 -1
  6. package/dist/engine/helpers.d.ts +1 -1
  7. package/dist/engine/helpers.d.ts.map +1 -1
  8. package/dist/engine/helpers.test.d.ts +2 -0
  9. package/dist/engine/helpers.test.d.ts.map +1 -0
  10. package/dist/engine/template.d.ts.map +1 -1
  11. package/dist/engine/template.test.d.ts +2 -0
  12. package/dist/engine/template.test.d.ts.map +1 -0
  13. package/dist/index.js +172 -170
  14. package/dist/output.d.ts.map +1 -1
  15. package/dist/templates/dynamic-module/_package.json.ejs +6 -6
  16. package/dist/templates/dynamic-module/src/modules/index.ts.ejs +8 -5
  17. package/dist/templates/dynamic-module/tsconfig.json +1 -1
  18. package/dist/templates/dynamic-module/vite.config.mts.ejs +1 -1
  19. package/dist/templates/host-app/_github/COMMIT_CONVENTION.md +1 -1
  20. package/dist/templates/host-app/_package.json.ejs +7 -10
  21. package/dist/templates/host-app/src/main.ts.ejs +17 -15
  22. package/dist/templates/host-app/src/router/routes.ts.ejs +0 -9
  23. package/dist/templates/host-app/tsconfig.json +1 -0
  24. package/dist/templates/host-app/vite.config.mts.ejs +3 -6
  25. package/dist/templates/module/composables/useDetails.ts.ejs +41 -38
  26. package/dist/templates/module/index.ts.ejs +11 -8
  27. package/dist/templates/module/locales/en.json.ejs +33 -22
  28. package/dist/templates/module/pages/details.vue.ejs +83 -111
  29. package/dist/templates/module/pages/list.vue.ejs +88 -117
  30. package/dist/templates/sample-module/index.ts +11 -8
  31. package/dist/templates/sample-module/pages/details.vue +20 -47
  32. package/dist/templates/sample-module/pages/list.vue +107 -154
  33. package/dist/templates/standalone/_github/COMMIT_CONVENTION.md +1 -1
  34. package/dist/templates/standalone/_package.json.ejs +15 -18
  35. package/dist/templates/standalone/eslint.config.mjs +31 -0
  36. package/dist/templates/standalone/src/bootstrap.ts.ejs +5 -5
  37. package/dist/templates/standalone/src/main.ts.ejs +29 -23
  38. package/dist/templates/standalone/src/router/routes.ts.ejs +0 -9
  39. package/dist/templates/standalone/tsconfig.json +1 -0
  40. package/dist/types.d.ts +2 -2
  41. package/dist/types.d.ts.map +1 -1
  42. package/package.json +5 -5
  43. package/LICENSE +0 -12
  44. package/dist/templates/host-app/public/assets/1.jpeg +0 -0
  45. package/dist/templates/host-app/public/assets/2.jpg +0 -0
  46. package/dist/templates/host-app/public/assets/3.jpg +0 -0
  47. package/dist/templates/host-app/public/assets/app-select.svg +0 -11
  48. package/dist/templates/host-app/public/assets/avatar.jpg +0 -0
  49. package/dist/templates/host-app/public/assets/empty.png +0 -0
  50. package/dist/templates/host-app/src/shims-vue.d.ts +0 -27
  51. package/dist/templates/host-app/src/vue-i18n.d.ts +0 -10
  52. package/dist/templates/standalone/_eslintignore +0 -3
  53. package/dist/templates/standalone/_eslintrc.js +0 -41
  54. package/dist/templates/standalone/public/assets/1.jpeg +0 -0
  55. package/dist/templates/standalone/public/assets/2.jpg +0 -0
  56. package/dist/templates/standalone/public/assets/3.jpg +0 -0
  57. package/dist/templates/standalone/public/assets/app-select.svg +0 -11
  58. package/dist/templates/standalone/public/assets/avatar.jpg +0 -0
  59. package/dist/templates/standalone/public/assets/empty.png +0 -0
  60. package/dist/templates/standalone/src/shims-vue.d.ts +0 -27
  61. package/dist/templates/standalone/src/vue-i18n.d.ts +0 -10
@@ -1,117 +1,88 @@
1
- <template>
2
- <VcBlade
3
- :title="$t('<%- ModuleNameScreamingSnake %>.PAGES.LIST.TITLE')"
4
- :toolbar-items="bladeToolbar"
5
- :loading="loading"
6
- :expanded="expanded"
7
- :closable="closable"
8
- width="50%"
9
- @close="$emit('close:blade')"
10
- @expand="$emit('expand:blade')"
11
- @collapse="$emit('collapse:blade')"
12
- >
13
- <VcDataTable
14
- :items="data"
15
- :total-count="totalCount"
16
- :current-page="currentPage"
17
- :search-value="searchQuery"
18
- :state-key="'<%- ModuleNameScreamingSnake %>'"
19
- @search:change="(val: string) => { searchQuery = val; getItems(); }"
20
- @item-click="openDetails"
21
- @pagination-click="(page: number) => { currentPage = page; getItems(); }"
22
- >
23
- <!-- Add your columns here -->
24
- <VcColumn id="name" :header="'Name'" sortable />
25
- <VcColumn id="createdDate" :header="'Created'" type="datetime" sortable />
26
- </VcDataTable>
27
- </VcBlade>
28
- </template>
29
-
30
- <script setup lang="ts">
31
- import {
32
- VcBlade,
33
- VcDataTable,
34
- VcColumn,
35
- useBladeNavigation,
36
- type IBladeToolbar,
37
- type IParentCallArgs,
38
- } from "@vc-shell/framework";
39
- import { ref, computed, markRaw } from "vue";
40
- import use<%- ModuleNamePascalCase %>List from "../composables/useList";
41
- import Details from "./details.vue";
42
-
43
- export interface Props {
44
- expanded?: boolean;
45
- closable?: boolean;
46
- param?: string;
47
- options?: Record<string, unknown>;
48
- }
49
-
50
- export interface Emits {
51
- (event: "parent:call", args: IParentCallArgs): void;
52
- (event: "collapse:blade"): void;
53
- (event: "expand:blade"): void;
54
- (event: "close:blade"): void;
55
- }
56
-
57
- defineOptions({
58
- url: "/<%- ModuleName %>",
59
- name: "<%- ModuleNamePascalCase %>List",
60
- isWorkspace: true,
61
- menuItem: {
62
- title: "<%- ModuleNameScreamingSnake %>.MENU.TITLE",
63
- icon: "lucide-box",
64
- priority: 10,
65
- },
66
- });
67
-
68
- const props = withDefaults(defineProps<Props>(), {
69
- expanded: true,
70
- closable: true,
71
- });
72
-
73
- defineEmits<Emits>();
74
-
75
- const { openBlade } = useBladeNavigation();
76
-
77
- const {
78
- data,
79
- loading,
80
- totalCount,
81
- currentPage,
82
- searchQuery,
83
- getItems,
84
- } = use<%- ModuleNamePascalCase %>List();
85
-
86
- const bladeToolbar = ref<IBladeToolbar[]>([
87
- {
88
- id: "refresh",
89
- title: "Refresh",
90
- icon: "lucide-refresh-cw",
91
- clickHandler: () => getItems(),
92
- },
93
- {
94
- id: "add",
95
- title: "Add",
96
- icon: "lucide-plus",
97
- clickHandler: () => openDetails(),
98
- },
99
- ]);
100
-
101
- function openDetails(item?: { id?: string }) {
102
- openBlade({
103
- blade: markRaw(Details),
104
- param: item?.id,
105
- onClose() {
106
- getItems();
107
- },
108
- });
109
- }
110
-
111
- getItems();
112
-
113
- defineExpose({
114
- title: computed(() => "<%- ModuleNameSentenceCase %>"),
115
- reload: getItems,
116
- });
117
- </script>
1
+ <template>
2
+ <VcBlade
3
+ :title="$t('<%- ModuleNameScreamingSnake %>.PAGES.LIST.TITLE')"
4
+ :toolbar-items="bladeToolbar"
5
+ :loading="loading"
6
+ width="50%"
7
+ >
8
+ <VcDataTable
9
+ :items="data"
10
+ :total-count="totalCount"
11
+ :current-page="currentPage"
12
+ :search-value="searchQuery"
13
+ :state-key="'<%- ModuleNameScreamingSnake %>'"
14
+ @search:change="(val: string) => { searchQuery = val; getItems(); }"
15
+ @item-click="openDetails"
16
+ @pagination-click="(page: number) => { currentPage = page; getItems(); }"
17
+ >
18
+ <!-- Add your columns here -->
19
+ <VcColumn id="name" :header="$t('<%- ModuleNameScreamingSnake %>.PAGES.LIST.COLUMNS.NAME')" sortable />
20
+ <VcColumn id="createdDate" :header="$t('<%- ModuleNameScreamingSnake %>.PAGES.LIST.COLUMNS.CREATED_DATE')" type="datetime" sortable />
21
+ </VcDataTable>
22
+ </VcBlade>
23
+ </template>
24
+
25
+ <script setup lang="ts">
26
+ import {
27
+ VcBlade,
28
+ VcDataTable,
29
+ VcColumn,
30
+ useBlade,
31
+ type IBladeToolbar,
32
+ } from "@vc-shell/framework";
33
+ import { ref } from "vue";
34
+ import use<%- ModuleNamePascalCase %>List from "../composables/useList";
35
+ import { useI18n } from "vue-i18n";
36
+
37
+ defineBlade({
38
+ url: "/<%- ModuleName %>",
39
+ name: "<%- ModuleNamePascalCase %>List",
40
+ isWorkspace: true,
41
+ menuItem: {
42
+ title: "<%- ModuleNameScreamingSnake %>.MENU.TITLE",
43
+ icon: "lucide-box",
44
+ priority: 10,
45
+ },
46
+ });
47
+
48
+ const { t } = useI18n({ useScope: "global" });
49
+ const { openBlade, exposeToChildren } = useBlade();
50
+
51
+ const {
52
+ data,
53
+ loading,
54
+ totalCount,
55
+ currentPage,
56
+ searchQuery,
57
+ getItems,
58
+ } = use<%- ModuleNamePascalCase %>List();
59
+
60
+ const bladeToolbar = ref<IBladeToolbar[]>([
61
+ {
62
+ id: "refresh",
63
+ title: t("<%- ModuleNameScreamingSnake %>.PAGES.LIST.TOOLBAR.REFRESH"),
64
+ icon: "lucide-refresh-cw",
65
+ clickHandler: () => getItems(),
66
+ },
67
+ {
68
+ id: "add",
69
+ title: t("<%- ModuleNameScreamingSnake %>.PAGES.LIST.TOOLBAR.ADD"),
70
+ icon: "lucide-plus",
71
+ clickHandler: () => openDetails(),
72
+ },
73
+ ]);
74
+
75
+ function openDetails(item?: { id?: string }) {
76
+ openBlade({
77
+ name: "<%- ModuleNamePascalCase %>Details",
78
+ param: item?.id,
79
+ onClose() {
80
+ getItems();
81
+ },
82
+ });
83
+ }
84
+
85
+ getItems();
86
+
87
+ exposeToChildren({ reload: getItems });
88
+ </script>
@@ -1,8 +1,11 @@
1
- import * as pages from "./pages";
2
- import * as locales from "./locales";
3
- import { createAppModule } from "@vc-shell/framework";
4
-
5
- export default createAppModule(pages, locales);
6
-
7
- export * from "./pages";
8
- export * from "./composables";
1
+ import * as blades from "./pages";
2
+ import * as locales from "./locales";
3
+ import { defineAppModule } from "@vc-shell/framework";
4
+
5
+ export default defineAppModule({
6
+ blades,
7
+ locales,
8
+ });
9
+
10
+ export * from "./pages";
11
+ export * from "./composables";
@@ -2,13 +2,8 @@
2
2
  <VcBlade
3
3
  :loading="loading"
4
4
  :title="title"
5
- :expanded="expanded"
6
- :closable="closable"
7
5
  width="70%"
8
6
  :toolbar-items="bladeToolbar"
9
- @close="$emit('close:blade')"
10
- @expand="$emit('expand:blade')"
11
- @collapse="$emit('collapse:blade')"
12
7
  >
13
8
  <VcContainer class="tw-p-2">
14
9
  <VcForm class="tw-space-y-4">
@@ -130,42 +125,22 @@
130
125
  </template>
131
126
 
132
127
  <script lang="ts" setup>
133
- import { IBladeToolbar, IParentCallArgs, useBeforeUnload, useBladeNavigation, usePopup } from "@vc-shell/framework";
128
+ import { IBladeToolbar, useBlade, useBeforeUnload, usePopup } from "@vc-shell/framework";
134
129
  import { useDetails } from "./../composables";
135
130
  import { computed, onMounted, ref } from "vue";
136
131
  import { Field, useForm } from "vee-validate";
137
132
  import { useI18n } from "vue-i18n";
138
133
  import * as _ from "lodash-es";
139
134
 
140
- export interface Props {
141
- expanded?: boolean;
142
- closable?: boolean;
143
- param?: string;
144
- }
145
-
146
- export interface Emits {
147
- (event: "parent:call", args: IParentCallArgs): void;
148
- (event: "collapse:blade"): void;
149
- (event: "expand:blade"): void;
150
- (event: "close:blade"): void;
151
- }
152
-
153
- defineOptions({
154
- url: "/sample-details",
135
+ defineBlade({
155
136
  name: "SampleDetails",
137
+ url: "/sample-details",
156
138
  });
157
139
 
158
- const props = withDefaults(defineProps<Props>(), {
159
- expanded: true,
160
- closable: true,
161
- param: undefined,
162
- });
163
-
164
- const emit = defineEmits<Emits>();
140
+ const { param, closeSelf, callParent, onBeforeClose } = useBlade();
165
141
 
166
142
  const { loading, getItem, saveItem, removeItem, item, currencyOptions, isModified } = useDetails();
167
143
  const { showConfirmation } = usePopup();
168
- const { onBeforeClose } = useBladeNavigation();
169
144
  const { t } = useI18n({ useScope: "global" });
170
145
 
171
146
  const { meta } = useForm({
@@ -177,7 +152,7 @@ const isDisabled = computed(() => {
177
152
  });
178
153
 
179
154
  const title = computed(() => {
180
- return props.param
155
+ return param.value
181
156
  ? item.value?.name
182
157
  ? item.value?.name + t("SAMPLE_APP.PAGES.DETAILS.TITLE.DETAILS")
183
158
  : t("SAMPLE_APP.PAGES.DETAILS.TITLE.LOADING")
@@ -192,10 +167,8 @@ const bladeToolbar = ref<IBladeToolbar[]>([
192
167
  async clickHandler() {
193
168
  await saveItem(item.value);
194
169
 
195
- emit("parent:call", {
196
- method: "reload",
197
- });
198
- emit("close:blade");
170
+ callParent("reload");
171
+ closeSelf();
199
172
  },
200
173
  disabled: computed(() => !(isModified.value && !isDisabled.value)),
201
174
  },
@@ -205,13 +178,11 @@ const bladeToolbar = ref<IBladeToolbar[]>([
205
178
  title: "Delete",
206
179
  async clickHandler() {
207
180
  if (await showConfirmation(t(`SAMPLE_APP.PAGES.ALERTS.DELETE`))) {
208
- if (props.param) {
209
- await removeItem({ id: props.param });
210
- emit("parent:call", {
211
- method: "reload",
212
- });
181
+ if (param.value) {
182
+ await removeItem({ id: param.value });
183
+ callParent("reload");
213
184
 
214
- emit("close:blade");
185
+ closeSelf();
215
186
  }
216
187
  }
217
188
  },
@@ -219,20 +190,22 @@ const bladeToolbar = ref<IBladeToolbar[]>([
219
190
  ]);
220
191
 
221
192
  onMounted(async () => {
222
- if (props.param) {
223
- await getItem({ id: props.param });
193
+ if (param.value) {
194
+ await getItem({ id: param.value });
224
195
  }
225
196
  });
226
197
 
227
198
  onBeforeClose(async () => {
228
199
  if (!isDisabled.value && isModified.value) {
229
- return await showConfirmation(t("SAMPLE_APP.PAGES.ALERTS.CLOSE_CONFIRMATION"));
200
+ return !(await showConfirmation(t("SAMPLE_APP.PAGES.ALERTS.CLOSE_CONFIRMATION")));
230
201
  }
202
+ return false;
231
203
  });
232
204
 
233
- useBeforeUnload(computed(() => !isDisabled.value && isModified.value));
234
205
 
235
- defineExpose({
236
- title,
237
- });
206
+
207
+
208
+
209
+
210
+ useBeforeUnload(computed(() => !isDisabled.value && isModified.value));
238
211
  </script>