@vc-shell/create-vc-app 2.0.11 → 2.1.0-pr249.229549

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/dist/index.js CHANGED
@@ -7,7 +7,7 @@ import { fileURLToPath as F } from "node:url";
7
7
  import A from "prompts";
8
8
  import r from "node:fs";
9
9
  import E from "ejs";
10
- const O = "2.0.11", V = {
10
+ const O = "2.1.0-pr249.0229549", V = {
11
11
  version: O
12
12
  };
13
13
  function h(e) {
@@ -10,7 +10,7 @@
10
10
  },
11
11
  "devDependencies": {
12
12
  "@types/node": "^20.10.5",
13
- "@vc-shell/ts-config": "^2.0.11",
13
+ "@vc-shell/ts-config": "^2.1.0",
14
14
  "cross-env": "^7.0.3",
15
15
  "sass": "^1.87.0",
16
16
  "typescript": "^5.8.3",
@@ -18,8 +18,8 @@
18
18
  "vue-tsc": "^3.2.5"
19
19
  },
20
20
  "dependencies": {
21
- "@vc-shell/config-generator": "^2.0.11",
22
- "@vc-shell/framework": "^2.0.11",
21
+ "@vc-shell/config-generator": "^2.1.0",
22
+ "@vc-shell/framework": "^2.1.0",
23
23
  "vue": "^3.5.30",
24
24
  "vue-router": "^5.0.3"
25
25
  }
@@ -11,11 +11,11 @@
11
11
  v-model:sort-order="sortOrder"
12
12
  :items="data"
13
13
  :total-count="totalCount"
14
- :pagination="{ currentPage, pages }"
14
+ :pagination="pagination"
15
15
  :searchable="true"
16
16
  :state-key="'<%- ModuleNameScreamingSnake %>'"
17
17
  @row-click="onRowClick"
18
- @pagination-click="onPaginationClick"
18
+ @pagination-click="pagination.goToPage"
19
19
  >
20
20
  <!-- Add your columns here -->
21
21
  <VcColumn id="name" :title="$t('<%- ModuleNameScreamingSnake %>.PAGES.LIST.COLUMNS.NAME')" sortable />
@@ -25,9 +25,9 @@
25
25
  </template>
26
26
 
27
27
  <script setup lang="ts">
28
- import { useBlade, useDataTableSort, useTableQueryState, useFunctions, type IBladeToolbar } from "@vc-shell/framework";
28
+ import { useBlade, useDataTableSort, useTableSearch, useDataTablePagination, useFunctions, type IBladeToolbar } from "@vc-shell/framework";
29
29
  import { VcBlade, VcDataTable, VcColumn } from "@vc-shell/framework/ui";
30
- import { computed, ref, watch } from "vue";
30
+ import { ref, watch } from "vue";
31
31
  import use<%- ModuleNamePascalCase %>List from "../composables/useList";
32
32
  import { useI18n } from "vue-i18n";
33
33
 
@@ -49,43 +49,29 @@ const { debounce } = useFunctions();
49
49
  const PAGE_SIZE = 20;
50
50
 
51
51
  const { sortField, sortOrder, sortExpression } = useDataTableSort({
52
+ stateKey: "<%- ModuleNameScreamingSnake %>",
52
53
  initialField: "createdDate",
53
54
  initialDirection: "DESC",
54
55
  });
55
56
 
56
57
  const { data, loading, totalCount, getItems } = use<%- ModuleNamePascalCase %>List();
57
58
 
58
- const searchValue = ref<string>();
59
- const currentPage = ref(1);
60
- const pages = computed(() => Math.ceil(totalCount.value / PAGE_SIZE) || 0);
61
-
62
- // Restore sort/search/page from the URL, then load once below.
63
- const restored = useTableQueryState("<%- ModuleNameScreamingSnake %>").read();
64
- if (restored.sort) {
65
- const [field, direction] = restored.sort.split(":");
66
- sortField.value = field;
67
- sortOrder.value = direction === "DESC" ? -1 : 1;
68
- }
69
- if (restored.search) searchValue.value = restored.search;
70
- if (restored.page) currentPage.value = restored.page;
59
+ const { searchValue } = useTableSearch({ stateKey: "<%- ModuleNameScreamingSnake %>" });
60
+ const pagination = useDataTablePagination({ stateKey: "<%- ModuleNameScreamingSnake %>", pageSize: PAGE_SIZE, totalCount });
71
61
 
72
62
  function load() {
73
63
  return getItems({
74
64
  sort: sortExpression.value,
75
65
  keyword: searchValue.value || undefined,
76
- skip: (currentPage.value - 1) * PAGE_SIZE,
66
+ skip: pagination.skip,
77
67
  take: PAGE_SIZE,
78
68
  });
79
69
  }
80
70
 
81
71
  // One loader for sort/search/page. Debounced so typing doesn't fetch per keystroke.
82
72
  load();
83
- watch(searchValue, () => (currentPage.value = 1));
84
- watch([sortExpression, searchValue, currentPage], debounce(load, 300));
85
-
86
- const onPaginationClick = (page: number) => {
87
- currentPage.value = page;
88
- };
73
+ watch(searchValue, () => pagination.setPage(1));
74
+ watch([sortExpression, searchValue, () => pagination.skip], debounce(load, 300));
89
75
 
90
76
  const reload = () => load();
91
77
 
@@ -16,7 +16,7 @@
16
16
  selection-mode="multiple"
17
17
  :items="data ?? []"
18
18
  :row-actions="actionBuilder"
19
- :pagination="{ currentPage, pages }"
19
+ :pagination="pagination"
20
20
  :searchable="true"
21
21
  :search-placeholder="$t('SAMPLE_APP.PAGES.LIST.SEARCH.PLACEHOLDER')"
22
22
  :empty-state="{
@@ -35,7 +35,7 @@
35
35
  :total-count="totalCount"
36
36
  state-key="SAMPLE_APP"
37
37
  @row-click="onItemClick"
38
- @pagination-click="onPaginationClick"
38
+ @pagination-click="pagination.goToPage"
39
39
  >
40
40
  <VcColumn
41
41
  id="imgSrc"
@@ -74,8 +74,8 @@
74
74
  </template>
75
75
 
76
76
  <script lang="ts" setup>
77
- import { computed, ref, watch } from "vue";
78
- import { IBladeToolbar, useBlade, usePopup, useDataTableSort, useTableQueryState, useFunctions } from "@vc-shell/framework";
77
+ import { ref, watch, computed } from "vue";
78
+ import { IBladeToolbar, useBlade, usePopup, useDataTableSort, useTableSearch, useDataTablePagination, useFunctions } from "@vc-shell/framework";
79
79
  import type { TableAction } from "@vc-shell/framework";
80
80
  import { VcColumn, VcDataTable, VcBlade } from "@vc-shell/framework/ui";
81
81
  import { useI18n } from "vue-i18n";
@@ -101,32 +101,23 @@ const { debounce } = useFunctions();
101
101
  const PAGE_SIZE = 20;
102
102
 
103
103
  const { sortField, sortOrder, sortExpression } = useDataTableSort({
104
+ stateKey: "SAMPLE_APP",
104
105
  initialField: "createdDate",
105
106
  initialDirection: "DESC",
106
107
  });
107
108
 
108
- const { getItems, removeItems, data, loading, totalCount, pages } = useList({
109
+ const { getItems, removeItems, data, loading, totalCount } = useList({
109
110
  sort: sortExpression.value,
110
111
  pageSize: PAGE_SIZE,
111
112
  });
112
113
 
113
- const searchValue = ref<string>();
114
- const currentPage = ref(1);
114
+ const { searchValue } = useTableSearch({ stateKey: "SAMPLE_APP" });
115
+ const pagination = useDataTablePagination({ stateKey: "SAMPLE_APP", pageSize: PAGE_SIZE, totalCount });
115
116
  const selectedItemId = ref<string>();
116
117
  const selectedItems = ref<MockedItem[]>([]);
117
118
 
118
119
  const selectedIds = computed(() => selectedItems.value.map((item) => item.id).filter(Boolean) as string[]);
119
120
 
120
- // Restore sort/search/page from the URL, then load once below.
121
- const restored = useTableQueryState("SAMPLE_APP").read();
122
- if (restored.sort) {
123
- const [field, direction] = restored.sort.split(":");
124
- sortField.value = field;
125
- sortOrder.value = direction === "DESC" ? -1 : 1;
126
- }
127
- if (restored.search) searchValue.value = restored.search;
128
- if (restored.page) currentPage.value = restored.page;
129
-
130
121
  watch(
131
122
  param,
132
123
  (newVal) => {
@@ -139,14 +130,14 @@ function load() {
139
130
  return getItems({
140
131
  sort: sortExpression.value,
141
132
  keyword: searchValue.value || undefined,
142
- skip: (currentPage.value - 1) * PAGE_SIZE,
133
+ skip: pagination.skip,
143
134
  });
144
135
  }
145
136
 
146
137
  // One loader for sort/search/page. Debounced so typing doesn't fetch per keystroke.
147
138
  load();
148
- watch(searchValue, () => (currentPage.value = 1));
149
- watch([sortExpression, searchValue, currentPage], debounce(load, 300));
139
+ watch(searchValue, () => pagination.setPage(1));
140
+ watch([sortExpression, searchValue, () => pagination.skip], debounce(load, 300));
150
141
 
151
142
  const clearSearch = () => {
152
143
  searchValue.value = "";
@@ -156,10 +147,6 @@ const addItem = () => {
156
147
  openBlade({ name: "SampleDetails" });
157
148
  };
158
149
 
159
- const onPaginationClick = (page: number) => {
160
- currentPage.value = page;
161
- };
162
-
163
150
  const bladeToolbar = ref<IBladeToolbar[]>([
164
151
  {
165
152
  id: "refresh",
@@ -22,8 +22,8 @@
22
22
  "@types/node": "^20.10.5",
23
23
  "@typescript-eslint/eslint-plugin": "^8.43.0",
24
24
  "@typescript-eslint/parser": "^8.43.0",
25
- "@vc-shell/api-client-generator": "^2.0.11",
26
- "@vc-shell/ts-config": "^2.0.11",
25
+ "@vc-shell/api-client-generator": "^2.1.0",
26
+ "@vc-shell/ts-config": "^2.1.0",
27
27
  "@vitejs/plugin-vue": "^5.2.3",
28
28
  "@vue/eslint-config-prettier": "^10.2.0",
29
29
  "@vue/eslint-config-typescript": "^14.6.0",
@@ -51,8 +51,8 @@
51
51
  "vue-tsc": "^3.2.5"
52
52
  },
53
53
  "dependencies": {
54
- "@vc-shell/config-generator": "^2.0.11",
55
- "@vc-shell/framework": "^2.0.11",
54
+ "@vc-shell/config-generator": "^2.1.0",
55
+ "@vc-shell/framework": "^2.1.0",
56
56
  "@vueuse/core": "^10.7.1",
57
57
  "@vueuse/integrations": "^10.7.1",
58
58
  "vee-validate": "^4.12.4",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vc-shell/create-vc-app",
3
3
  "description": "Application scaffolding",
4
- "version": "2.0.11",
4
+ "version": "2.1.0-pr249.0229549",
5
5
  "type": "module",
6
6
  "bin": "./dist/index.js",
7
7
  "files": [
@@ -16,7 +16,7 @@
16
16
  "devDependencies": {
17
17
  "@types/ejs": "^3.1.5",
18
18
  "@types/prompts": "^2.4.4",
19
- "@vc-shell/ts-config": "2.0.11",
19
+ "@vc-shell/ts-config": "2.1.0-pr249.0229549",
20
20
  "copyfiles": "^2.4.1",
21
21
  "cross-env": "^7.0.3",
22
22
  "shx": "^0.3.4",