eco-vue-js 0.11.32 → 0.11.34

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 (78) hide show
  1. package/dist/components/ActionsBar/WActionsBar.vue.d.ts.map +1 -1
  2. package/dist/components/ActionsBar/WActionsBar.vue.js +8 -5
  3. package/dist/components/Button/WButtonMore.vue.d.ts.map +1 -1
  4. package/dist/components/Button/WButtonMore.vue.js +4 -1
  5. package/dist/components/Button/WButtonSelectionState.vue.d.ts.map +1 -1
  6. package/dist/components/Button/WButtonSelectionState.vue.js +1 -0
  7. package/dist/components/Button/WButtonUnselect.vue.d.ts.map +1 -1
  8. package/dist/components/Button/WButtonUnselect.vue.js +5 -1
  9. package/dist/components/Checkbox/WCheckbox.vue.d.ts.map +1 -1
  10. package/dist/components/Checkbox/WCheckbox.vue.js +10 -5
  11. package/dist/components/Dismissable/WDismissable.vue.d.ts.map +1 -1
  12. package/dist/components/Dismissable/WDismissable.vue.js +1 -0
  13. package/dist/components/FieldWrapper/components/FilterButton.vue.d.ts.map +1 -1
  14. package/dist/components/FieldWrapper/components/FilterButton.vue.js +4 -1
  15. package/dist/components/FilePicker/components/FilePickerItem.vue.d.ts.map +1 -1
  16. package/dist/components/FilePicker/components/FilePickerItem.vue.js +1 -0
  17. package/dist/components/HeaderBar/WHeaderBar.vue.d.ts.map +1 -1
  18. package/dist/components/HeaderBar/WHeaderBar.vue.js +1 -0
  19. package/dist/components/ImageViewer/WImageViewer.vue.d.ts.map +1 -1
  20. package/dist/components/ImageViewer/WImageViewer.vue.js +1 -0
  21. package/dist/components/ImageViewer/components/ImageModal.vue.d.ts.map +1 -1
  22. package/dist/components/ImageViewer/components/ImageModal.vue2.js +1 -0
  23. package/dist/components/Input/WInput.vue.d.ts +4 -2
  24. package/dist/components/Input/WInput.vue.d.ts.map +1 -1
  25. package/dist/components/Input/WInput.vue.js +5 -12
  26. package/dist/components/Input/WInputDate.vue.d.ts +1 -1
  27. package/dist/components/Input/WInputSuggest.vue.d.ts.map +1 -1
  28. package/dist/components/Input/WInputSuggest.vue.js +16 -7
  29. package/dist/components/Input/WInputToolbarButton.vue.d.ts.map +1 -1
  30. package/dist/components/Input/WInputToolbarButton.vue.js +8 -4
  31. package/dist/components/Input/components/InputActions.vue.d.ts +4 -3
  32. package/dist/components/Input/components/InputActions.vue.d.ts.map +1 -1
  33. package/dist/components/Input/components/InputActions.vue.js +7 -12
  34. package/dist/components/Input/components/InputActionsButton.vue.d.ts +10 -1
  35. package/dist/components/Input/components/InputActionsButton.vue.d.ts.map +1 -1
  36. package/dist/components/Input/components/InputActionsButton.vue.js +18 -11
  37. package/dist/components/Input/components/InputToolbarButton.vue.d.ts +1 -0
  38. package/dist/components/Input/components/InputToolbarButton.vue.d.ts.map +1 -1
  39. package/dist/components/Input/components/InputToolbarButton.vue.js +6 -3
  40. package/dist/components/Input/models/toolbarActions.d.ts.map +1 -1
  41. package/dist/components/Input/models/toolbarActions.js +4 -2
  42. package/dist/components/Input/types.d.ts +2 -0
  43. package/dist/components/Input/types.d.ts.map +1 -1
  44. package/dist/components/List/components/HeaderItemResizer.vue.d.ts.map +1 -1
  45. package/dist/components/List/components/HeaderItemResizer.vue.js +1 -0
  46. package/dist/components/List/components/HeaderSettings.vue.d.ts.map +1 -1
  47. package/dist/components/List/components/HeaderSettings.vue.js +6 -3
  48. package/dist/components/List/components/HeaderSettingsList.vue.d.ts.map +1 -1
  49. package/dist/components/List/components/HeaderSettingsList.vue.js +7 -2
  50. package/dist/components/List/components/HeaderSettingsModeButton.vue.d.ts +1 -0
  51. package/dist/components/List/components/HeaderSettingsModeButton.vue.d.ts.map +1 -1
  52. package/dist/components/List/components/HeaderSettingsModeButton.vue.js +5 -1
  53. package/dist/components/List/use/useListConfig.d.ts +1 -0
  54. package/dist/components/List/use/useListConfig.d.ts.map +1 -1
  55. package/dist/components/List/use/useListConfig.js +5 -1
  56. package/dist/components/Modal/WModalStepper.vue.d.ts +4 -4
  57. package/dist/components/Modal/components/ModalCloseButton.vue.js +1 -1
  58. package/dist/components/Tabs/WTabs.vue.d.ts +4 -4
  59. package/dist/components/Tabs/WTabs.vue.d.ts.map +1 -1
  60. package/dist/components/Tabs/WTabs.vue.js +1 -0
  61. package/dist/components/Tabs/components/TabItem.vue.d.ts +2 -2
  62. package/dist/components/Toggle/WToggle.vue.d.ts.map +1 -1
  63. package/dist/components/Toggle/WToggle.vue.js +5 -1
  64. package/dist/main.d.ts +1 -3
  65. package/dist/main.d.ts.map +1 -1
  66. package/dist/main.js +203 -207
  67. package/dist/utils/ApiClient.d.ts +3 -90
  68. package/dist/utils/ApiClient.d.ts.map +1 -1
  69. package/dist/utils/ApiClient.js +15 -56
  70. package/package.json +1 -7
  71. package/dist/components/Auth/WRouteAuth.vue.d.ts +0 -22
  72. package/dist/components/Auth/WRouteAuth.vue.d.ts.map +0 -1
  73. package/dist/components/Auth/WRouteAuth.vue.js +0 -44
  74. package/dist/components/Auth/WRouteAuth.vue2.js +0 -5
  75. package/dist/components/Auth/WRouteAuthNo.vue.d.ts +0 -22
  76. package/dist/components/Auth/WRouteAuthNo.vue.d.ts.map +0 -1
  77. package/dist/components/Auth/WRouteAuthNo.vue.js +0 -56
  78. package/dist/components/Auth/WRouteAuthNo.vue2.js +0 -5
@@ -1,6 +1,4 @@
1
1
  import { ref } from 'vue';
2
- import _sfc_main from '../components/Auth/WRouteAuth.vue.js';
3
- import _sfc_main$1 from '../components/Auth/WRouteAuthNo.vue.js';
4
2
  import { removeExpirationDate, getLastRefreshPromise, setRefreshTimestamp, removeRefreshTimestamp, checkExpirationDate, setExpirationDate } from '../components/Auth/utils/utils.js';
5
3
  export { updateExpirationDate } from '../components/Auth/utils/utils.js';
6
4
  import { encodeQueryParams, ApiError, ApiErrorCancel } from './api.js';
@@ -18,20 +16,20 @@ const HEADERS_FORMDATA = {
18
16
  class ApiClientInstance {
19
17
  constructor(config) {
20
18
  this.config = config;
19
+ window.addEventListener("storage", this.checkAuth);
20
+ this.useAuth = () => {
21
+ return this.auth;
22
+ };
21
23
  }
22
24
  refreshPromise = null;
23
- isAuthFailed = ref(false);
24
- get routeNameAuth() {
25
- return this.config.routeNameAuth;
26
- }
27
- get routeNameAuthNo() {
28
- return this.config.routeNameAuthNo;
29
- }
25
+ auth = ref(true);
26
+ useAuth;
30
27
  setOnFailure(value) {
31
28
  this.config.onFailure = value;
32
29
  }
33
30
  logout() {
34
31
  removeExpirationDate();
32
+ this.auth.value = false;
35
33
  }
36
34
  async retry(request) {
37
35
  const newRequest = request.clone();
@@ -48,14 +46,14 @@ class ApiClientInstance {
48
46
  if (refreshTimeoutPromise) {
49
47
  this.refreshPromise = refreshTimeoutPromise.then(() => {
50
48
  this.refreshPromise = null;
51
- this.isAuthFailed.value = false;
49
+ this.auth.value = true;
52
50
  }).catch(async () => {
53
51
  this.refreshPromise = null;
54
52
  const check = this.checkAuth();
55
53
  if (!check) {
56
54
  if (this.refreshPromise) return this.refreshPromise;
57
55
  if (check === null) {
58
- this.isAuthFailed.value = true;
56
+ this.auth.value = false;
59
57
  return Promise.reject();
60
58
  }
61
59
  return this.refresh();
@@ -66,9 +64,10 @@ class ApiClientInstance {
66
64
  const promise = this.config.tokenRefresh ? this.config.tokenRefresh() : this.fetch("GET", this.config.refreshUrl, { updateToken: true });
67
65
  this.refreshPromise = promise.then(() => {
68
66
  this.refreshPromise = null;
67
+ this.auth.value = true;
69
68
  }).catch((error) => {
70
69
  this.refreshPromise = null;
71
- this.isAuthFailed.value = true;
70
+ this.auth.value = false;
72
71
  return Promise.reject(error);
73
72
  }).finally(removeRefreshTimestamp);
74
73
  }
@@ -79,7 +78,7 @@ class ApiClientInstance {
79
78
  let result;
80
79
  if (this.config.tokenGetter && !this.config.tokenRefresh) result = !!this.config.tokenGetter?.();
81
80
  else result = checkExpirationDate();
82
- if (result) this.isAuthFailed.value = false;
81
+ if (result !== false) this.auth.value = result !== null;
83
82
  return result;
84
83
  }
85
84
  fetch(method, url, config, baseUrl) {
@@ -91,7 +90,7 @@ class ApiClientInstance {
91
90
  if (!check) {
92
91
  if (check !== null && (this.config.refreshUrl || this.config.tokenRefresh)) await this.refresh();
93
92
  if (!this.checkAuth()) {
94
- this.isAuthFailed.value = true;
93
+ this.auth.value = false;
95
94
  reject();
96
95
  return;
97
96
  }
@@ -100,6 +99,7 @@ class ApiClientInstance {
100
99
  const token = this.config.tokenGetter();
101
100
  if (token) headers.append("Authorization", "Bearer " + token);
102
101
  else {
102
+ this.auth.value = false;
103
103
  reject();
104
104
  return;
105
105
  }
@@ -132,7 +132,7 @@ class ApiClientInstance {
132
132
  } else {
133
133
  if (response.status === 401) {
134
134
  if (this.config.refreshUrl || this.config.tokenRefresh) return this.refresh().then(() => this.retry(request));
135
- this.isAuthFailed.value = true;
135
+ this.auth.value = false;
136
136
  }
137
137
  this.config.onFailure?.(response);
138
138
  reject(new ApiError({
@@ -172,47 +172,6 @@ class ApiClientInstance {
172
172
  delete(url, config) {
173
173
  return this.fetch("DELETE", url, config);
174
174
  }
175
- getRouteAuth() {
176
- return {
177
- path: "",
178
- props: { apiClientInstance: this },
179
- component: _sfc_main,
180
- beforeEnter: async (to) => {
181
- if (to.meta.noAuth) return;
182
- if (this.refreshPromise) await this.refreshPromise;
183
- if (!this.checkAuth()) {
184
- if (this.config.refreshUrl || this.config.tokenRefresh) return this.refresh().catch(() => ({
185
- name: this.routeNameAuthNo,
186
- query: to.fullPath !== "/" ? { hash: to.fullPath } : void 0
187
- }));
188
- return { name: this.routeNameAuthNo, query: to.fullPath !== "/" ? { hash: to.fullPath } : void 0 };
189
- }
190
- },
191
- meta: {
192
- noAuth: false
193
- }
194
- };
195
- }
196
- getRouteAuthNo() {
197
- return {
198
- path: "",
199
- props: { apiClientInstance: this },
200
- component: _sfc_main$1,
201
- beforeEnter: (to, from) => {
202
- if (!this.checkAuth()) {
203
- if (!to.query.hash && !from.meta.noAuth && from.fullPath !== "/") {
204
- return { ...to, query: { hash: from.fullPath } };
205
- }
206
- return;
207
- }
208
- if (typeof to.query.hash === "string") return to.query.hash;
209
- else return { name: this.routeNameAuth };
210
- },
211
- meta: {
212
- noAuth: true
213
- }
214
- };
215
- }
216
175
  addInstance(baseUrl) {
217
176
  return {
218
177
  baseUrl,
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "type": "git",
5
5
  "url": "https://github.com/rsmple/eco-vue-js.git"
6
6
  },
7
- "version": "0.11.32",
7
+ "version": "0.11.34",
8
8
  "dependencies": {
9
9
  "@stylistic/eslint-plugin": "5.2.3",
10
10
  "@tanstack/eslint-plugin-query": "5.83.1",
@@ -123,12 +123,6 @@
123
123
  "./dist/components/ActionsBar/WActionsBarFilter.vue": {
124
124
  "import": "./dist/components/ActionsBar/WActionsBarFilter.vue.js"
125
125
  },
126
- "./dist/components/Auth/WRouteAuth.vue": {
127
- "import": "./dist/components/Auth/WRouteAuth.vue.js"
128
- },
129
- "./dist/components/Auth/WRouteAuthNo.vue": {
130
- "import": "./dist/components/Auth/WRouteAuthNo.vue.js"
131
- },
132
126
  "./dist/components/BottomSheet/WBottomSheet.vue": {
133
127
  "import": "./dist/components/BottomSheet/WBottomSheet.vue.js"
134
128
  },
@@ -1,22 +0,0 @@
1
- import { ApiClientInstance } from '../../utils/ApiClient';
2
- type __VLS_Props = {
3
- apiClientInstance: ApiClientInstance;
4
- };
5
- declare function __VLS_template(): {
6
- attrs: Partial<{}>;
7
- slots: {
8
- default?(_: {}): any;
9
- };
10
- refs: {};
11
- rootEl: any;
12
- };
13
- type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
14
- declare const __VLS_component: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
15
- declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
16
- export default _default;
17
- type __VLS_WithTemplateSlots<T, S> = T & {
18
- new (): {
19
- $slots: S;
20
- };
21
- };
22
- //# sourceMappingURL=WRouteAuth.vue.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"WRouteAuth.vue.d.ts","sourceRoot":"","sources":["../../../../src/components/Auth/WRouteAuth.vue"],"names":[],"mappings":"AAQA;AAgEA,OAAO,EAAC,KAAK,iBAAiB,EAAC,MAAM,mBAAmB,CAAA;AAExD,KAAK,WAAW,GAAG;IACjB,iBAAiB,EAAE,iBAAiB,CAAA;CACrC,CAAC;AAyCF,iBAAS,cAAc;WA8BT,OAAO,IAA6B;;yBAVrB,GAAG;;;;EAe/B;AASD,KAAK,oBAAoB,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AAC9D,QAAA,MAAM,eAAe,kSAMnB,CAAC;wBACkB,uBAAuB,CAAC,OAAO,eAAe,EAAE,oBAAoB,CAAC,OAAO,CAAC,CAAC;AAAnG,wBAAoG;AAQpG,KAAK,uBAAuB,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IACxC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KAEV,CAAA;CACD,CAAC"}
@@ -1,44 +0,0 @@
1
- import { defineComponent, resolveComponent, watch, onBeforeUnmount, createBlock, renderSlot, unref, openBlock, resolveDynamicComponent } from 'vue';
2
- import { useOptionalRouter, useOptionalRoute } from '../../composables/useOptionalRouter.js';
3
- import '@tanstack/vue-query';
4
-
5
- const _sfc_main = /* @__PURE__ */ defineComponent({
6
- __name: "WRouteAuth",
7
- props: {
8
- apiClientInstance: {}
9
- },
10
- setup(__props) {
11
- const props = __props;
12
- let RouterViewComponent = null;
13
- try {
14
- RouterViewComponent = resolveComponent("RouterView");
15
- } catch {
16
- RouterViewComponent = null;
17
- }
18
- const router = useOptionalRouter();
19
- const route = useOptionalRoute();
20
- const redirect = () => {
21
- router.push({ name: props.apiClientInstance.routeNameAuthNo, query: route.fullPath !== "/" ? { hash: route.fullPath } : void 0 });
22
- };
23
- const checkAuth = () => {
24
- if (props.apiClientInstance.checkAuth()) return;
25
- {
26
- if (props.apiClientInstance.refreshPromise) {
27
- redirect();
28
- }
29
- }
30
- };
31
- watch(() => props.apiClientInstance.isAuthFailed.value, (value) => {
32
- if (value) redirect();
33
- });
34
- window.addEventListener("storage", checkAuth);
35
- onBeforeUnmount(() => {
36
- window.removeEventListener("storage", checkAuth);
37
- });
38
- return (_ctx, _cache) => {
39
- return unref(RouterViewComponent) ? (openBlock(), createBlock(resolveDynamicComponent(unref(RouterViewComponent)), { key: 0 })) : renderSlot(_ctx.$slots, "default", { key: 1 });
40
- };
41
- }
42
- });
43
-
44
- export { _sfc_main as default };
@@ -1,5 +0,0 @@
1
- import _sfc_main from './WRouteAuth.vue.js';
2
-
3
-
4
-
5
- export { _sfc_main as default };
@@ -1,22 +0,0 @@
1
- import { ApiClientInstance } from '../../utils/ApiClient';
2
- type __VLS_Props = {
3
- apiClientInstance: ApiClientInstance;
4
- };
5
- declare function __VLS_template(): {
6
- attrs: Partial<{}>;
7
- slots: {
8
- default?(_: {}): any;
9
- };
10
- refs: {};
11
- rootEl: any;
12
- };
13
- type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
14
- declare const __VLS_component: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
15
- declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
16
- export default _default;
17
- type __VLS_WithTemplateSlots<T, S> = T & {
18
- new (): {
19
- $slots: S;
20
- };
21
- };
22
- //# sourceMappingURL=WRouteAuthNo.vue.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"WRouteAuthNo.vue.d.ts","sourceRoot":"","sources":["../../../../src/components/Auth/WRouteAuthNo.vue"],"names":[],"mappings":"AAQA;AA2EA,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,mBAAmB,CAAA;AAexD,KAAK,WAAW,GAAG;IACjB,iBAAiB,EAAE,iBAAiB,CAAA;CACrC,CAAC;AAiDF,iBAAS,cAAc;WA8BT,OAAO,IAA6B;;yBAVrB,GAAG;;;;EAe/B;AASD,KAAK,oBAAoB,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AAC9D,QAAA,MAAM,eAAe,kSAMnB,CAAC;wBACkB,uBAAuB,CAAC,OAAO,eAAe,EAAE,oBAAoB,CAAC,OAAO,CAAC,CAAC;AAAnG,wBAAoG;AAQpG,KAAK,uBAAuB,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IACxC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KAEV,CAAA;CACD,CAAC"}
@@ -1,56 +0,0 @@
1
- import { defineComponent, resolveComponent, ref, watch, onBeforeMount, onBeforeUnmount, createBlock, renderSlot, unref, openBlock, resolveDynamicComponent } from 'vue';
2
- import { useQueryClient } from '@tanstack/vue-query';
3
- import { useOptionalRouter, useOptionalRoute } from '../../composables/useOptionalRouter.js';
4
-
5
- const _sfc_main = /* @__PURE__ */ defineComponent({
6
- __name: "WRouteAuthNo",
7
- props: {
8
- apiClientInstance: {}
9
- },
10
- setup(__props) {
11
- let RouterViewComponent = null;
12
- try {
13
- RouterViewComponent = resolveComponent("RouterView");
14
- } catch {
15
- RouterViewComponent = null;
16
- }
17
- const props = __props;
18
- const router = useOptionalRouter();
19
- const route = useOptionalRoute();
20
- const queryClient = useQueryClient();
21
- const queryEnabled = ref(false);
22
- const redirect = async () => {
23
- if (typeof route.query.hash === "string" && route.query.hash && route.query.hash !== "/") {
24
- const resolved = router.resolve(route.query.hash);
25
- if (!resolved.matched.length) {
26
- await router.replace({ name: props.apiClientInstance.routeNameAuth });
27
- } else {
28
- await router.replace(resolved);
29
- }
30
- } else {
31
- await router.replace({ name: props.apiClientInstance.routeNameAuth });
32
- }
33
- };
34
- const checkLogin = () => {
35
- if (!props.apiClientInstance.checkAuth()) return;
36
- redirect();
37
- };
38
- watch(() => props.apiClientInstance.isAuthFailed.value, (value) => {
39
- if (value) return;
40
- redirect();
41
- });
42
- onBeforeMount(() => {
43
- window.addEventListener("storage", checkLogin);
44
- queryClient.clear();
45
- queryEnabled.value = true;
46
- });
47
- onBeforeUnmount(() => {
48
- window.removeEventListener("storage", checkLogin);
49
- });
50
- return (_ctx, _cache) => {
51
- return unref(RouterViewComponent) ? (openBlock(), createBlock(resolveDynamicComponent(unref(RouterViewComponent)), { key: 0 })) : renderSlot(_ctx.$slots, "default", { key: 1 });
52
- };
53
- }
54
- });
55
-
56
- export { _sfc_main as default };
@@ -1,5 +0,0 @@
1
- import _sfc_main from './WRouteAuthNo.vue.js';
2
-
3
-
4
-
5
- export { _sfc_main as default };