vuetable-next 1.0.5 → 1.0.7

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 (62) hide show
  1. package/dist/vuetable-next.d.ts +63 -14
  2. package/dist/vuetable-next.js +1538 -1548
  3. package/dist/vuetable-next.js.map +1 -1
  4. package/dist/vuetable-next.umd.cjs +20 -20
  5. package/dist/vuetable-next.umd.cjs.map +1 -1
  6. package/package.json +9 -9
  7. package/.eslintignore +0 -4
  8. package/.idea/easycode.ignore +0 -13
  9. package/.idea/inspectionProfiles/Project_Default.xml +0 -6
  10. package/.idea/jsLinters/eslint.xml +0 -6
  11. package/.idea/material_theme_project_new.xml +0 -13
  12. package/.idea/modules.xml +0 -8
  13. package/.idea/vcs.xml +0 -6
  14. package/.idea/vuetable-next.iml +0 -12
  15. package/.vscode/extensions.json +0 -3
  16. package/auto-imports.d.ts +0 -73
  17. package/demo/vue2/index.ts +0 -6
  18. package/demo/vue2/index.vue +0 -17
  19. package/demo/vue3/index.ts +0 -4
  20. package/demo/vue3/index.vue +0 -12
  21. package/eslint.config.js +0 -122
  22. package/index.html +0 -86
  23. package/public/vite.svg +0 -1
  24. package/src/assets/vue.svg +0 -1
  25. package/src/components/Vuetable.vue +0 -1207
  26. package/src/components/VuetableColGroup.vue +0 -66
  27. package/src/components/VuetableColGutter.vue +0 -25
  28. package/src/components/VuetableCssSemanticUI.ts +0 -36
  29. package/src/components/VuetableFieldCheckbox.vue +0 -87
  30. package/src/components/VuetableFieldCheckboxMixin.vue +0 -46
  31. package/src/components/VuetableFieldHandle.vue +0 -41
  32. package/src/components/VuetableFieldMixin.vue +0 -30
  33. package/src/components/VuetableFieldSequence.vue +0 -43
  34. package/src/components/VuetablePagination.vue +0 -119
  35. package/src/components/VuetablePaginationDropdown.vue +0 -88
  36. package/src/components/VuetablePaginationInfo.vue +0 -51
  37. package/src/components/VuetablePaginationInfoMixin.vue +0 -64
  38. package/src/components/VuetablePaginationMixin.vue +0 -107
  39. package/src/components/VuetableRowHeader.vue +0 -196
  40. package/src/components/useVuetablePagination.ts +0 -56
  41. package/src/components/useVuetablePaginationInfo.ts +0 -40
  42. package/src/data/fields.ts +0 -102
  43. package/src/data/lang.ts +0 -4
  44. package/src/index.ts +0 -57
  45. package/src/main.ts +0 -398
  46. package/src/style.css +0 -79
  47. package/src/vite-env.d.ts +0 -1
  48. package/test/Vuetable.AJAX.test.ts +0 -291
  49. package/test/Vuetable.Components.test.ts +0 -27
  50. package/test/Vuetable.Composable.test.ts +0 -151
  51. package/test/Vuetable.Computed.test.ts +0 -211
  52. package/test/Vuetable.Features.test.ts +0 -145
  53. package/test/Vuetable.FieldsDefinition.test.ts +0 -236
  54. package/test/Vuetable.HTML.test.ts +0 -16
  55. package/test/Vuetable.Methods.test.ts +0 -373
  56. package/test/__snapshots__/Vuetable.Components.test.ts.snap +0 -11
  57. package/test/__snapshots__/Vuetable.HTML.test.ts.snap +0 -85
  58. package/tsconfig.app.json +0 -32
  59. package/tsconfig.json +0 -22
  60. package/tsconfig.node.json +0 -13
  61. package/vite.config.ts +0 -52
  62. package/vitest.config.ts +0 -17
@@ -1,373 +0,0 @@
1
- import { shallowMount } from "@vue/test-utils";
2
- import Vuetable from "../src/components/Vuetable.vue";
3
- import { createApp, nextTick, defineComponent } from "vue";
4
- import {TaskContext} from "vitest";
5
-
6
- describe("Vuetable - Methods", () => {
7
- beforeAll(() => {
8
- // @ts-ignore
9
- global.console.warn = vitest.fn((msg: string) => msg);
10
- });
11
-
12
- afterAll( () => {
13
- // @ts-ignore
14
- global.console.warn.mockReset();
15
- // @ts-ignore
16
- global.console.warn.mockRestore();
17
- });
18
-
19
- const shallowVuetable = (fields: any[]) => shallowMount(Vuetable, {
20
- propsData: {
21
- loadOnStart: false,
22
- fields
23
- }
24
- });
25
-
26
- describe("normalizeFields", () => {
27
-
28
- it("copies additional options to fields definition as well", () => {
29
- const wrapper = shallowVuetable([
30
- { name: "code", title: "Product Code", options: {} },
31
- { name: "description", foo: "bar", formatter: () => "bee" }
32
- ]);
33
-
34
- const fields = wrapper.vm.tableFields;
35
- expect(fields.length).toEqual(2);
36
- expect(fields[0].name).toEqual("code");
37
- expect(fields[0].title).toEqual("Product Code");
38
- expect(typeof(fields[0].options)).toBe("object");
39
-
40
- expect(fields[1].name).toEqual("description");
41
- expect(fields[1].title).toEqual("Description");
42
- expect(fields[1].foo).toEqual("bar");
43
- expect(typeof(fields[1].formatter)).toBe("function");
44
- expect(fields[1].formatter()).toEqual("bee");
45
- });
46
- });
47
-
48
- describe("checkIfRowIdentifierExists", () => {
49
-
50
- const mountVuetable = (trackBy = "id") => shallowMount(Vuetable, {
51
- propsData: {
52
- apiMode: false,
53
- fields: ["code"],
54
- data: [{ code: "AAA"}],
55
- trackBy
56
- }
57
- });
58
-
59
- it("gives warning when row identifier is invalid", () => {
60
- const wrapper = mountVuetable();
61
-
62
- expect(wrapper.vm.checkIfRowIdentifierExists()).toBe(false);
63
- expect(console.warn).toHaveBeenCalledTimes(1);
64
- });
65
-
66
- it("returns true when row identifier is valid", (context: TaskContext) => new Promise(done => {
67
- const app = createApp({});
68
- const wrapper = mountVuetable("code");
69
-
70
- expect(wrapper.vm.trackBy).toEqual("code");
71
-
72
- app.config.errorHandler = done;
73
- nextTick( () => {
74
- expect(wrapper.vm.checkIfRowIdentifierExists()).toBe(true);
75
- done(context);
76
- });
77
- }));
78
- });
79
-
80
- describe("setData", () => {
81
- const data = [{code: "AAA"}];
82
- const pagination = {"total": 0};
83
-
84
- it("emits loading and loaded events when argument is Array", () => {
85
- const wrapper = shallowVuetable(["code"]);
86
-
87
- wrapper.vm.setData(data);
88
-
89
- const emitted = wrapper.emitted();
90
- expect(emitted).toHaveProperty("vuetable:loading");
91
- expect(emitted).toHaveProperty("vuetable:loaded");
92
- expect(wrapper.vm.tableData).toStrictEqual(data);
93
- });
94
-
95
- it("emits loading and loaded events when argument is Object", (context: TaskContext) => new Promise((done) => {
96
- const app = createApp({});
97
- const wrapper = shallowVuetable(["code"]);
98
-
99
- wrapper.vm.setData({ pagination, data });
100
-
101
- app.config.errorHandler = done;
102
- nextTick( () => {
103
- const emitted = wrapper.emitted();
104
- expect(emitted).toHaveProperty("vuetable:loading");
105
- expect(emitted).toHaveProperty("vuetable:loaded");
106
- expect(wrapper.vm.tableData).toStrictEqual(data);
107
- done(context);
108
- });
109
- }));
110
-
111
- it("set tableData when argument is Array", () => {
112
- const wrapper = shallowVuetable(["code"]);
113
-
114
- wrapper.vm.setData(data);
115
-
116
- expect(wrapper.vm.tableData).toStrictEqual(data);
117
- });
118
-
119
- it("set tableData and tablePagination when argument is Object", () => {
120
- const wrapper = shallowMount(Vuetable, {
121
- propsData: {
122
- apiMode: false,
123
- fields: ["code"],
124
- dataPath: "data",
125
- paginationPath: "pagination"
126
- }
127
- });
128
-
129
- wrapper.vm.setData({ pagination, data });
130
-
131
- expect(wrapper.vm.tableData).toStrictEqual(data);
132
- expect(wrapper.vm.tablePagination).toStrictEqual(pagination);
133
- });
134
- });
135
-
136
- describe("normalizeFieldName", () => {
137
- const dummyComponent = defineComponent({
138
- template: "<div></div>"
139
- });
140
-
141
- const wrapper = shallowVuetable([
142
- "code",
143
- "__checkbox",
144
- { name: dummyComponent },
145
- ]);
146
-
147
- it("returns string name if the field is normal string", () => {
148
- expect(wrapper.vm.tableFields[0].name).toEqual("code");
149
- });
150
-
151
- it("returns expanded string name if it is field component", () => {
152
- expect(wrapper.vm.tableFields[1].name).toEqual(wrapper.vm.fieldPrefix + "checkbox");
153
- });
154
-
155
- it("returns the Object if field name is an Object", () => {
156
- expect(wrapper.vm.tableFields[2].name).toStrictEqual(dummyComponent);
157
- });
158
- });
159
-
160
- describe("isFieldComponent", () => {
161
- const wrapper = shallowVuetable(["code"]);
162
-
163
- it("returns true if given name is of type Object (VueComponent)", () => {
164
- expect(wrapper.vm.isFieldComponent(Object)).toBe(true);
165
- });
166
-
167
- it("returns true if it starts with field-prefix", () => {
168
- expect(wrapper.vm.isFieldComponent(wrapper.vm.fieldPrefix)).toBe(true);
169
- });
170
-
171
- it("returns true if it begins with __ char", () => {
172
- expect(wrapper.vm.isFieldComponent("__name")).toBe(true);
173
- });
174
-
175
- it("returns false in other cases", () => {
176
- expect(wrapper.vm.isFieldComponent("name")).toBe(false);
177
- expect(wrapper.vm.isFieldComponent("_name")).toBe(false);
178
- });
179
- });
180
-
181
- describe("makeTitle", () => {
182
- const dummyComponent = defineComponent({
183
- template: "<div></div>"
184
- });
185
-
186
- const wrapper = shallowVuetable(["code"]);
187
-
188
- it("returns empty string if the given name is field component", () => {
189
- expect(wrapper.vm.makeTitle(dummyComponent)).toBe("");
190
- expect(wrapper.vm.makeTitle("__checkbox")).toBe("");
191
- });
192
-
193
- it("returns string replacing . with space", () => {
194
- expect(wrapper.vm.makeTitle("Hello.World")).toEqual("Hello World");
195
- });
196
-
197
- it("returns capitalized string", () => {
198
- expect(wrapper.vm.makeTitle("hello")).toEqual("Hello");
199
- expect(wrapper.vm.makeTitle("hello world")).toEqual("Hello World");
200
- expect(wrapper.vm.makeTitle("hello.world")).toEqual("Hello World");
201
- });
202
- });
203
-
204
- describe("getFieldTitle", () => {
205
- const wrapper = shallowVuetable([
206
- "code",
207
- {
208
- name: "description",
209
- title: () => "DUMMY"
210
- }
211
- ]);
212
-
213
- it("returns predefined field title", () => {
214
- expect(wrapper.vm.getFieldTitle(wrapper.vm.tableFields[0])).toEqual("Code");
215
- });
216
-
217
- it("calls field title function if it is defined as Funcation", () => {
218
- expect(wrapper.vm.getFieldTitle(wrapper.vm.tableFields[1])).toEqual("DUMMY");
219
- });
220
- });
221
-
222
- describe("getAllQueryParams", () => {
223
-
224
- const q1 = (sortOrder: string[], currentPage: number, perPage: number) => {
225
- // return object
226
- return { sortOrder, currentPage, perPage };
227
- };
228
-
229
- const q2 = () => {
230
- // return something else which is not an object
231
- return "dummy";
232
- };
233
-
234
- const mountVuetable = (queryParams: any) => shallowMount(Vuetable, {
235
- propsData: {
236
- apiMode: false,
237
- fields: ["code"],
238
- queryParams
239
- }
240
- });
241
-
242
- it("calls `query-params` if it is a Function", () => {
243
- const wrapper = mountVuetable(q1);
244
-
245
- expect(wrapper.vm.getAllQueryParams()).toEqual({
246
- sortOrder: [], currentPage: 1, perPage: 10
247
- });
248
- });
249
-
250
- it("returns empty object if the given Function does not return an Object", () => {
251
- const wrapper = mountVuetable(q2);
252
-
253
- expect(wrapper.vm.getAllQueryParams()).toEqual({});
254
- });
255
- });
256
-
257
- describe("isSortable", () => {
258
-
259
- it("returns false if the given field did not define \"sortField\" option", () => {
260
- const wrapper = shallowVuetable(["code"]);
261
- const field = wrapper.vm.tableFields[0];
262
-
263
- expect(wrapper.vm.isSortable(field)).toEqual(false);
264
- });
265
-
266
- it("returns true if the given field defined \"sortField\" option", () => {
267
- const wrapper = shallowVuetable([
268
- { name: "code", sortField: "code" }
269
- ]);
270
- const field = wrapper.vm.tableFields[0];
271
-
272
- expect(wrapper.vm.isSortable(field)).toBe(true);
273
- });
274
- });
275
-
276
- describe("getDefaultSortParam", () => {
277
-
278
- const mountVuetable = (sortOrder) => shallowMount(Vuetable, {
279
- propsData: {
280
- apiMode: false,
281
- fields: ["code"],
282
- sortOrder
283
- }
284
- });
285
-
286
- it("returns single sortOrder into sort params", () => {
287
- const wrapper = mountVuetable([
288
- { field: "code", sortField: "code", direction: "asc" },
289
- ]);
290
-
291
- expect(wrapper.vm.getDefaultSortParam()).toEqual("code|asc");
292
- });
293
-
294
- it("returns consolidated multiple sortOrder into sort param", () => {
295
- const wrapper = mountVuetable([
296
- { field: "code", sortField: "code", direction: "asc" },
297
- { field: "group.description", sortField: "group_id", direction: "desc" }
298
- ]);
299
-
300
- expect(wrapper.vm.getDefaultSortParam()).toEqual("code|asc,group_id|desc");
301
- });
302
- });
303
-
304
- describe("getObjectValue", () => {
305
- const obj = {
306
- code: "aaa",
307
- address: {
308
- primary: {
309
- street: "somewhere",
310
- zip: 12345
311
- },
312
- dummy: "zzzzz"
313
- }
314
- };
315
- const cmp = shallowVuetable(["code"]).vm;
316
-
317
- it("returns value inside the given object", () => {
318
- expect(
319
- cmp.getObjectValue(obj, "code")
320
- ).toEqual("aaa");
321
- });
322
-
323
- it("returns null when given path does not exist and no default value is given", () => {
324
- expect(
325
- cmp.getObjectValue(obj, "foo")
326
- ).toEqual(null);
327
- });
328
-
329
- it("returns default value when the given path does not exist and default value is given", () => {
330
- expect(
331
- cmp.getObjectValue(obj, "foo", "bar")
332
- ).toEqual("bar");
333
- });
334
-
335
- it("returns the object when an empty path is given without default value", () => {
336
- expect(
337
- cmp.getObjectValue(obj, "")
338
- ).toEqual(obj);
339
- });
340
-
341
- it("returns the object when an empty path is given eventhough the default value is given", () => {
342
- expect(
343
- cmp.getObjectValue(obj, "", "foo")
344
- ).toEqual(obj);
345
- });
346
-
347
- it("returns null when given object is null and no default value is given", () => {
348
- expect(
349
- cmp.getObjectValue(null, "foo")
350
- ).toEqual(null);
351
-
352
- expect(
353
- cmp.getObjectValue(null, "")
354
- ).toEqual(null);
355
- });
356
-
357
- it("returns default value when given object is null and default value is given", () => {
358
- expect(
359
- cmp.getObjectValue(null, "foo", "baz")
360
- ).toEqual("baz");
361
- });
362
-
363
- it("returns value for nested object", () => {
364
- expect(
365
- cmp.getObjectValue(obj, "address.dummy")
366
- ).toEqual("zzzzz");
367
-
368
- expect(
369
- cmp.getObjectValue(obj, "address.primary.zip")
370
- ).toEqual(12345);
371
- });
372
- });
373
- });
@@ -1,11 +0,0 @@
1
- // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2
-
3
- exports[`Vuetable - Components > render VuetableFieldCheckbox 1`] = `
4
- <td
5
- class="vuetable-td-component-checkbox"
6
- >
7
- <input
8
- type="checkbox"
9
- />
10
- </td>
11
- `;
@@ -1,85 +0,0 @@
1
- // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2
-
3
- exports[`Vuetable - HTML structure > renders the HTML table 1`] = `
4
- <div
5
- class=""
6
- >
7
- <!--v-if-->
8
- <div
9
- class="vuetable-body-wrapper"
10
- >
11
- <table
12
- class="vuetable ui blue selectable unstackable celled table fixed"
13
- >
14
- <colgroup>
15
-
16
-
17
- <col
18
- class="vuetable-col-code code-0"
19
- />
20
-
21
-
22
- <col
23
- class="vuetable-col-describe describe-1"
24
- />
25
-
26
-
27
- <!--v-if-->
28
- </colgroup>
29
- <thead>
30
-
31
-
32
- <tr
33
- index="0"
34
- >
35
-
36
-
37
-
38
- <th
39
- class="vuetable-th-code"
40
- id="_code"
41
- >
42
- Code
43
- </th>
44
-
45
-
46
-
47
-
48
- <th
49
- class="vuetable-th-describe"
50
- id="_describe"
51
- >
52
- Describe
53
- </th>
54
-
55
-
56
-
57
- <!--v-if-->
58
- </tr>
59
-
60
-
61
- </thead>
62
- <tfoot>
63
-
64
-
65
- </tfoot>
66
- <tbody
67
- class="vuetable-body"
68
- >
69
-
70
-
71
- <tr>
72
- <td
73
- class="vuetable-empty-result"
74
- colspan="2"
75
- >
76
- No Data Available
77
- </td>
78
- </tr>
79
-
80
-
81
- </tbody>
82
- </table>
83
- </div>
84
- </div>
85
- `;
package/tsconfig.app.json DELETED
@@ -1,32 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "composite": true,
4
- "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
5
- "target": "ES2020",
6
- "useDefineForClassFields": true,
7
- "module": "ESNext",
8
- "lib": ["ES2020", "DOM", "DOM.Iterable"],
9
- "skipLibCheck": true,
10
-
11
- /* Bundler mode */
12
- "moduleResolution": "bundler",
13
- "allowImportingTsExtensions": true,
14
- "resolveJsonModule": true,
15
- "isolatedModules": true,
16
- "moduleDetection": "force",
17
- "noEmit": true,
18
- "jsx": "preserve",
19
-
20
- /* Linting */
21
- "strict": true,
22
- "noUnusedLocals": true,
23
- "noUnusedParameters": true,
24
- "noFallthroughCasesInSwitch": true
25
- },
26
- "include": [
27
- "src/**/*.ts",
28
- "src/**/*.tsx",
29
- "src/**/*.vue",
30
- "node_modules/.pnpm/sweetalert@2.1.2/node_modules/sweetalert/typings/sweetalert.d.ts"
31
- ]
32
- }
package/tsconfig.json DELETED
@@ -1,22 +0,0 @@
1
- {
2
- "files": [],
3
- "compilerOptions": {
4
- "noImplicitAny": false,
5
- "types": ["vitest/globals"],
6
- "baseUrl": ".",
7
- "lib": [
8
- "es2020",
9
- "dom"
10
- ],
11
- "moduleResolution": "Node",
12
- "allowSyntheticDefaultImports": true
13
- },
14
- "references": [
15
- {
16
- "path": "./tsconfig.app.json"
17
- },
18
- {
19
- "path": "./tsconfig.node.json"
20
- }
21
- ]
22
- }
@@ -1,13 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "composite": true,
4
- "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
5
- "skipLibCheck": true,
6
- "module": "ESNext",
7
- "moduleResolution": "bundler",
8
- "allowSyntheticDefaultImports": true,
9
- "strict": true,
10
- "noEmit": true
11
- },
12
- "include": ["vite.config.ts"]
13
- }
package/vite.config.ts DELETED
@@ -1,52 +0,0 @@
1
- import { defineConfig } from "vite";
2
- import vue from "@vitejs/plugin-vue";
3
- import AutoImport from "unplugin-auto-import/vite";
4
- import { name, PascalCasedName } from "./package.json";
5
- import { version } from "vue";
6
- import type { SemVer } from "semver";
7
- import { parse } from "semver";
8
- import dts from "vite-plugin-dts";
9
- import { resolve } from "path";
10
-
11
- const { major, minor } = parse(version) as SemVer;
12
-
13
- // https://vitejs.dev/config/
14
- export default defineConfig({
15
- plugins: [
16
- {
17
- name: "html-transform",
18
- transformIndexHtml (html: string) {
19
- return html.replace(/\{\{ NAME \}\}/, name).replace(/\{\{ VUE_VERSION \}\}/g, String(major === 3 ? major : `${major}.${minor}`));
20
- },
21
- },
22
- vue(),
23
- dts({
24
- insertTypesEntry: true,
25
- rollupTypes: true
26
- }),
27
- AutoImport({
28
- viteOptimizeDeps: true
29
- })
30
- ],
31
- optimizeDeps: {
32
- exclude: ["vue-demi"]
33
- },
34
- build: {
35
- lib: {
36
- name,
37
- entry: resolve(__dirname, "src/index.ts")
38
- },
39
- copyPublicDir: false,
40
- sourcemap: true,
41
- rollupOptions: {
42
- external: ["vue-demi"],
43
- output: {
44
- globals: {
45
- [name]: PascalCasedName,
46
- "vue-demi": "VueDemi"
47
- },
48
- exports: "named"
49
- }
50
- }
51
- }
52
- });
package/vitest.config.ts DELETED
@@ -1,17 +0,0 @@
1
- import { defineConfig } from "vitest/config";
2
- import AutoImport from "unplugin-auto-import/vite";
3
- import vue from "@vitejs/plugin-vue";
4
-
5
- export default defineConfig({
6
- test: {
7
- globals: true,
8
- environment: "jsdom",
9
- },
10
- plugins: [
11
- vue(),
12
- AutoImport({
13
- imports: ["vitest"],
14
- dts: true
15
- })
16
- ]
17
- });