vuetable-next 1.0.4 → 1.0.6

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 +17 -5
  2. package/dist/vuetable-next.js +1500 -4236
  3. package/dist/vuetable-next.js.map +1 -1
  4. package/dist/vuetable-next.umd.cjs +7 -32
  5. package/dist/vuetable-next.umd.cjs.map +1 -1
  6. package/package.json +8 -10
  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,145 +0,0 @@
1
- import { createApp, nextTick } from "vue";
2
- import { mount, shallowMount } from "@vue/test-utils";
3
- import Vuetable from "../src/components/Vuetable.vue";
4
-
5
- describe("Vuetable - Features", () => {
6
- const mountVuetable = (fields) => mount(Vuetable, {
7
- propsData: {
8
- loadOnStart: false,
9
- fields
10
- }
11
- });
12
-
13
- it("should render HTML in title", () => {
14
- const wrapper = mountVuetable([
15
- { name: "code", title: "Hi, <strong>there</strong>" }
16
- ]);
17
-
18
- expect(wrapper.find("thead tr th.vuetable-th-code").element.innerHTML)
19
- .toEqual("Hi, <strong>there</strong>");
20
- });
21
-
22
- it("should call the function to get title value if title is a Function", () => {
23
- const myFunc = () => {
24
- return "My Title";
25
- };
26
-
27
- const wrapper = mountVuetable([
28
- { name: "code", title: myFunc }
29
- ]);
30
-
31
- expect(typeof(wrapper.vm.tableFields[0].title)).toEqual("function");
32
- expect(wrapper.vm.tableFields[0].title).toBe(myFunc);
33
- expect(wrapper.find("thead tr th.vuetable-th-code").element.innerHTML)
34
- .toEqual("My Title");
35
- });
36
-
37
- it('should replace "." with a space if title has not been set and name has "." in it', () => {
38
- const wrapper = mountVuetable(["code.line"]);
39
-
40
- expect(wrapper.find("thead tr th.vuetable-th-code_line").element.innerHTML)
41
- .toEqual("Code Line");
42
- });
43
-
44
- describe("Data mode", () => {
45
- let data, pagination;
46
-
47
- beforeEach( () => {
48
- data = [{ "code": "111" }, { "code": "222" }];
49
- pagination = { "total": 0 };
50
- });
51
-
52
- it('can display data array from "data" prop', context => new Promise(done => {
53
- const app = createApp({});
54
- const wrapper = shallowMount(Vuetable, {
55
- propsData: {
56
- apiMode: false,
57
- fields: ["code"],
58
- data: data,
59
- }
60
- });
61
-
62
- app.config.errorHandler = done;
63
- nextTick( () => {
64
- const nodes = wrapper.findAll("td.vuetable-td-code");
65
- expect(nodes[0].text()).toEqual("111");
66
- expect(nodes[1].text()).toEqual("222");
67
- done(context);
68
- });
69
- }));
70
-
71
- it('can display data in an object from "data" prop', context => new Promise(done => {
72
- const app = createApp({});
73
- const wrapper = shallowMount(Vuetable, {
74
- propsData: {
75
- apiMode: false,
76
- fields: ["code"],
77
- dataPath: "data",
78
- paginationPath: "pagination",
79
- trackBy: "code",
80
- data: {
81
- "data": data,
82
- "pagination": pagination
83
- },
84
- }
85
- });
86
-
87
- app.config.errorHandler = done;
88
- nextTick( () => {
89
- expect(wrapper.vm.tableData).toStrictEqual(data);
90
- expect(wrapper.vm.tablePagination).toStrictEqual(pagination);
91
-
92
- const nodes = wrapper.findAll("td.vuetable-td-code");
93
- expect(nodes[0].text()).toEqual("111");
94
- expect(nodes[1].text()).toEqual("222");
95
- done(context);
96
- });
97
- }));
98
-
99
- it("calls user defined data-manager function", context => new Promise(done => {
100
- const app = createApp({});
101
- const func = vi.fn();
102
- const wrapper = shallowMount(Vuetable, {
103
- propsData: {
104
- apiMode: false,
105
- fields: ["code"],
106
- dataPath: "data",
107
- paginationPath: "pagination",
108
- trackBy: "code",
109
- loadOnStart: true,
110
- data: {
111
- "data": data,
112
- "pagination": pagination
113
- },
114
- dataManager: func,
115
- }
116
- });
117
-
118
- expect(wrapper.vm.dataManager).toBe(func);
119
- app.config.errorHandler = done;
120
- nextTick( () => {
121
- // console.log(wrapper.vm.dataManager!([], {
122
- // "current_page": 1,
123
- // "from": 1,
124
- // "last_page": 0,
125
- // "next_page_url": "",
126
- // "per_page": 10,
127
- // "prev_page_url": "",
128
- // "to": 0,
129
- // "total": 0
130
- // }));
131
- expect(func).toHaveBeenCalledWith([], {
132
- "current_page": 1,
133
- "from": 1,
134
- "last_page": 0,
135
- "next_page_url": "",
136
- "per_page": 10,
137
- "prev_page_url": "",
138
- "to": 0,
139
- "total": 0
140
- });
141
- done(context);
142
- });
143
- }));
144
- });
145
- });
@@ -1,236 +0,0 @@
1
- import { createApp, nextTick } from "vue";
2
- import { shallowMount, mount } from "@vue/test-utils";
3
- import Vuetable from "../src/components/Vuetable.vue";
4
- import VuetableFieldHandle from "../src/components/VuetableFieldHandle.vue";
5
-
6
- describe("Vuetable - Fields Definition", () => {
7
-
8
- beforeAll( () => {
9
- // @ts-ignore
10
- global.console.error = vitest.fn( msg => msg);
11
- // @ts-ignore
12
- global.console.warn = vitest.fn( msg => msg);
13
- });
14
-
15
- afterAll( () => {
16
- // @ts-ignore
17
- global.console.error.mockReset();
18
- // @ts-ignore
19
- global.console.error.mockRestore();
20
- // @ts-ignore
21
- global.console.warn.mockReset();
22
- // @ts-ignore
23
- global.console.warn.mockRestore();
24
- });
25
-
26
- const expectedResult = [
27
- {
28
- name: "code",
29
- title: "Code",
30
- titleClass: "",
31
- dataClass: "",
32
- sortField: null,
33
- formatter: null,
34
- visible: true,
35
- width: null,
36
- $_index: 0
37
- },
38
- {
39
- name: "description",
40
- title: "Description",
41
- titleClass: "",
42
- dataClass: "",
43
- sortField: null,
44
- formatter: null,
45
- visible: true,
46
- width: null,
47
- $_index: 1
48
- }
49
- ];
50
-
51
- const shallowVuetable = (fields) => shallowMount(Vuetable, {
52
- propsData: {
53
- loadOnStart: false,
54
- fields
55
- }
56
- });
57
-
58
- // Setting `loadOnStart` to `false` will prevent Vuetable from
59
- // loading data from API endpoint, so we can test for functionalities
60
- // that do not relate to AJAX request
61
- it("should parse basic array correctly", () => {
62
- const wrapper = shallowVuetable(["code", "description"]);
63
-
64
- expect(wrapper.vm.tableFields).toEqual(expectedResult);
65
- });
66
-
67
- it("should parse array of object correctly", () => {
68
- const wrapper = shallowVuetable([
69
- { name: "code" },
70
- { name: "description" }
71
- ]);
72
-
73
- expect(wrapper.vm.tableFields).toEqual(expectedResult);
74
- });
75
-
76
- it("should parse mix declaration of string and object correctly", () => {
77
- const wrapper = shallowVuetable([
78
- "code",
79
- { name: "description" }
80
- ]);
81
-
82
- expect(wrapper.vm.tableFields).toEqual(expectedResult);
83
- });
84
-
85
- it("should accept (VueComponent) Object in \"name\" option", () => {
86
- const wrapper = shallowVuetable([
87
- { name: VuetableFieldHandle }
88
- ]);
89
-
90
- expect(wrapper.vm.tableFields[0].name instanceof Object).toBe(true);
91
- });
92
-
93
- /**
94
- * title option
95
- */
96
- it("should set field title to capitalized field name if title is not provided", () => {
97
- const wrapper = shallowVuetable(["full name"]);
98
-
99
- expect(wrapper.vm.tableFields[0].title).toEqual("Full Name");
100
- });
101
-
102
- it("should override field title with given value", () => {
103
- const wrapper = shallowVuetable([
104
- { name: "code", title: "My Title" }
105
- ]);
106
-
107
- expect(wrapper.vm.tableFields[0].title).toEqual("My Title");
108
- });
109
-
110
- /**
111
- * titleClass option
112
- */
113
- it("should use the given titleClass to render field title", () => {
114
- const wrapper = mount(Vuetable, {
115
- propsData: {
116
- apiMode: false,
117
- fields: [
118
- { name: "code", titleClass: "foo-bar" }
119
- ]
120
- }
121
- });
122
-
123
- expect(wrapper.vm.tableFields[0].titleClass).toEqual("foo-bar");
124
-
125
- const el = wrapper.findAll("th")[0];
126
- expect(el.attributes().id).toEqual("_code");
127
- expect(el.classes()).toContain("foo-bar");
128
- expect(el.classes()).toContain("vuetable-th-code");
129
- });
130
-
131
- /**
132
- * dataClass option
133
- *
134
- * `apiMode` needs to be set to false to manually set the data for the test
135
- */
136
- it("should use the given dataClass to render field title", context => new Promise(done => {
137
- const app = createApp({});
138
- const wrapper = shallowMount(Vuetable, {
139
- propsData: {
140
- apiMode: false,
141
- fields: [
142
- {
143
- name: "code",
144
- dataClass: "foo-baz"
145
- }
146
- ],
147
- data: [
148
- { code: "MYCODEDATA" }
149
- ]
150
- }
151
- });
152
-
153
- expect(wrapper.vm.tableFields[0].dataClass).toEqual("foo-baz");
154
- expect(wrapper.vm.tableData.length).toEqual(1);
155
-
156
- app.config.errorHandler = done;
157
- nextTick( () => {
158
- const el = wrapper.findAll("tbody tr td")[0];
159
- expect(el.classes()).toContain("vuetable-td-code");
160
- expect(el.classes()).toContain("foo-baz");
161
- done(context);
162
- });
163
- }));
164
-
165
- /**
166
- * sortField option - given
167
- */
168
- it("should set sortField to the given value when specified", () => {
169
- const wrapper = shallowVuetable([
170
- { name: "code", sortField: "aaa" }
171
- ]);
172
-
173
- expect(wrapper.vm.tableFields[0].sortField).toEqual("aaa");
174
- });
175
-
176
- /**
177
- * visible option
178
- */
179
- it("should set visible to the given value when specified", () => {
180
- const wrapper = shallowVuetable([
181
- { name: "code", visible: false }
182
- ]);
183
-
184
- expect(wrapper.vm.tableFields[0].visible).toEqual(false);
185
- });
186
-
187
- /**
188
- * formatter option
189
- */
190
- it("should give warning when the formatter is not a function", () => {
191
- const wrapper = shallowVuetable([
192
- { name: "code", formatter: "myFormatter" }
193
- ]);
194
-
195
- expect(wrapper.vm.tableFields[0].formatter).toBe(null);
196
- expect(console.error).toBeCalledWith("code field formatter must be a function");
197
- });
198
-
199
- it("should call the formatter function to format the column value", context => new Promise(done => {
200
- const app = createApp({});
201
- const myFormatter = (value) => {
202
- return value.toUpperCase();
203
- };
204
-
205
- const wrapper = shallowMount(Vuetable, {
206
- propsData: {
207
- apiMode: false,
208
- fields: [
209
- { name: "code", formatter: myFormatter }
210
- ],
211
- data: [
212
- { code: "mycode" }
213
- ]
214
- }
215
- });
216
-
217
- expect(wrapper.vm.tableFields[0].formatter).toEqual(myFormatter);
218
-
219
- app.config.errorHandler = done;
220
- nextTick( () => {
221
- expect(wrapper.find("tbody tr td.vuetable-td-code").text()).toBe("MYCODE");
222
- done(context);
223
- });
224
- }));
225
-
226
- /**
227
- * width option
228
- */
229
- it("should set width to the given value when specified", () => {
230
- const wrapper = shallowVuetable([
231
- { name: "code", width: "100px" }
232
- ]);
233
-
234
- expect(wrapper.vm.tableFields[0].width).toEqual("100px");
235
- });
236
- });
@@ -1,16 +0,0 @@
1
- import { mount } from "@vue/test-utils";
2
- import Vuetable from "../src/components/Vuetable.vue";
3
-
4
- describe("Vuetable - HTML structure", () => {
5
- const mountVuetable = (fields: string[]) => mount(Vuetable, {
6
- propsData: {
7
- loadOnStart: false,
8
- fields
9
- }
10
- });
11
-
12
- it("renders the HTML table", () => {
13
- const wrapper = mountVuetable(["code", "describe"]);
14
- expect(wrapper.element).toMatchSnapshot();
15
- });
16
- });