vueless 0.0.177 → 0.0.179
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/package.json +1 -1
- package/ui.button/index.stories.js +20 -10
- package/ui.button/index.vue +27 -6
- package/ui.form-date-picker-range/index.vue +16 -4
- package/ui.loader-top/Docs.mdx +8 -10
- package/ui.loader-top/composables/useLoaderTop.js +22 -11
- package/ui.loader-top/index.vue +17 -35
- package/ui.loader-top/services/loaderTop.service.js +6 -0
- package/web-types.json +21 -3
package/package.json
CHANGED
|
@@ -21,7 +21,7 @@ export default {
|
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
const DefaultTemplate = (args) => ({
|
|
24
|
-
components: { UButton },
|
|
24
|
+
components: { UButton, UIcon },
|
|
25
25
|
setup() {
|
|
26
26
|
const slots = getSlotNames(UButton.name);
|
|
27
27
|
|
|
@@ -43,7 +43,7 @@ const SlotTemplate = (args) => ({
|
|
|
43
43
|
},
|
|
44
44
|
template: `
|
|
45
45
|
<UButton v-bind="args">
|
|
46
|
-
${args.slotTemplate}
|
|
46
|
+
${args.slotTemplate || ""}
|
|
47
47
|
</UButton>
|
|
48
48
|
`,
|
|
49
49
|
});
|
|
@@ -133,6 +133,16 @@ disabled.args = { disabled: true };
|
|
|
133
133
|
export const colors = ColorTemplate.bind({});
|
|
134
134
|
colors.args = {};
|
|
135
135
|
|
|
136
|
+
export const iconLeft = DefaultTemplate.bind({});
|
|
137
|
+
iconLeft.args = {
|
|
138
|
+
iconLeft: "star",
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
export const iconRight = DefaultTemplate.bind({});
|
|
142
|
+
iconRight.args = {
|
|
143
|
+
iconRight: "star",
|
|
144
|
+
};
|
|
145
|
+
|
|
136
146
|
export const slotDefault = SlotTemplate.bind({});
|
|
137
147
|
slotDefault.args = {
|
|
138
148
|
slotTemplate: `
|
|
@@ -142,26 +152,26 @@ slotDefault.args = {
|
|
|
142
152
|
`,
|
|
143
153
|
};
|
|
144
154
|
|
|
145
|
-
export const
|
|
146
|
-
|
|
155
|
+
export const iconLeftSlot = SlotTemplate.bind({});
|
|
156
|
+
iconLeftSlot.args = {
|
|
147
157
|
slotTemplate: `
|
|
148
158
|
<template #left>
|
|
149
159
|
<UIcon
|
|
150
160
|
name="star"
|
|
151
|
-
color="
|
|
152
|
-
|
|
161
|
+
color="green"
|
|
162
|
+
/>
|
|
153
163
|
</template>
|
|
154
164
|
`,
|
|
155
165
|
};
|
|
156
166
|
|
|
157
|
-
export const
|
|
158
|
-
|
|
167
|
+
export const iconRightSlot = SlotTemplate.bind({});
|
|
168
|
+
iconRightSlot.args = {
|
|
159
169
|
slotTemplate: `
|
|
160
170
|
<template #right>
|
|
161
171
|
<UIcon
|
|
162
172
|
name="star"
|
|
163
|
-
color="
|
|
164
|
-
|
|
173
|
+
color="green"
|
|
174
|
+
/>
|
|
165
175
|
</template>
|
|
166
176
|
`,
|
|
167
177
|
};
|
package/ui.button/index.vue
CHANGED
|
@@ -11,19 +11,23 @@
|
|
|
11
11
|
<template v-if="loading">
|
|
12
12
|
<!-- Label is needed to prevent changing button height -->
|
|
13
13
|
<div v-bind="textAttrs" tabindex="-1" class="invisible w-0" v-text="label" />
|
|
14
|
-
<ULoader :size="loaderSize" :color="
|
|
14
|
+
<ULoader :size="loaderSize" :color="componentColor" v-bind="loaderAttrs" />
|
|
15
15
|
</template>
|
|
16
16
|
|
|
17
17
|
<template v-else>
|
|
18
|
-
<!-- @slot Use it to add
|
|
19
|
-
<slot name="left"
|
|
18
|
+
<!-- @slot Use it to add icon before text. -->
|
|
19
|
+
<slot name="left">
|
|
20
|
+
<UIcon v-if="iconLeft" :name="iconLeft" :color="componentColor" />
|
|
21
|
+
</slot>
|
|
20
22
|
|
|
21
23
|
<!-- @slot Use it to add something instead of text. -->
|
|
22
24
|
<slot />
|
|
23
25
|
<div v-if="label" v-bind="textAttrs" tabindex="-1" v-text="label" />
|
|
24
26
|
|
|
25
|
-
<!-- @slot Use it to add
|
|
26
|
-
<slot name="right"
|
|
27
|
+
<!-- @slot Use it to add icon after text. -->
|
|
28
|
+
<slot name="right">
|
|
29
|
+
<UIcon v-if="iconRight" :name="iconRight" :color="componentColor" />
|
|
30
|
+
</slot>
|
|
27
31
|
</template>
|
|
28
32
|
</component>
|
|
29
33
|
</template>
|
|
@@ -33,6 +37,7 @@ import { computed, ref } from "vue";
|
|
|
33
37
|
|
|
34
38
|
import UIService, { getRandomId } from "../service.ui";
|
|
35
39
|
import ULoader from "../ui.loader";
|
|
40
|
+
import UIcon from "../ui.image-icon";
|
|
36
41
|
|
|
37
42
|
import defaultConfig from "./configs/default.config";
|
|
38
43
|
import { useAttrs } from "./composables/attrs.composable";
|
|
@@ -157,6 +162,22 @@ const props = defineProps({
|
|
|
157
162
|
type: String,
|
|
158
163
|
default: "",
|
|
159
164
|
},
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Left side icon name.
|
|
168
|
+
*/
|
|
169
|
+
iconLeft: {
|
|
170
|
+
type: String,
|
|
171
|
+
default: "",
|
|
172
|
+
},
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Right side icon name.
|
|
176
|
+
*/
|
|
177
|
+
iconRight: {
|
|
178
|
+
type: String,
|
|
179
|
+
default: "",
|
|
180
|
+
},
|
|
160
181
|
});
|
|
161
182
|
|
|
162
183
|
const emit = defineEmits(["click"]);
|
|
@@ -180,7 +201,7 @@ const loaderSize = computed(() => {
|
|
|
180
201
|
return sizes[props.size];
|
|
181
202
|
});
|
|
182
203
|
|
|
183
|
-
const
|
|
204
|
+
const componentColor = computed(() => {
|
|
184
205
|
return props.variant === "primary" ? "white" : props.color;
|
|
185
206
|
});
|
|
186
207
|
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
<UInput
|
|
4
4
|
v-if="isVariant.input"
|
|
5
5
|
:id="id"
|
|
6
|
+
ref="inputRef"
|
|
6
7
|
v-model="userFormatDate"
|
|
7
8
|
:label="label"
|
|
8
9
|
:placeholder="placeholder"
|
|
@@ -421,6 +422,7 @@ const rangeInputEndRef = ref(null);
|
|
|
421
422
|
const buttonRef = ref(null);
|
|
422
423
|
const buttonPrevRef = ref(null);
|
|
423
424
|
const buttonNextRef = ref(null);
|
|
425
|
+
const inputRef = ref(null);
|
|
424
426
|
|
|
425
427
|
const { isTop, isRight, adjustPositionY, adjustPositionX } = useAdjustElementPosition(
|
|
426
428
|
wrapperRef,
|
|
@@ -463,10 +465,6 @@ const i18nGlobal = tm(UDatePickerRange);
|
|
|
463
465
|
|
|
464
466
|
const currentLocale = computed(() => merge(defaultConfig.i18n, i18nGlobal, props.config.i18n));
|
|
465
467
|
|
|
466
|
-
const clickOutsideOptions = computed(() => ({
|
|
467
|
-
ignore: [buttonRef.value.buttonRef, buttonPrevRef.value.buttonRef, buttonNextRef.value.buttonRef],
|
|
468
|
-
}));
|
|
469
|
-
|
|
470
468
|
const locale = computed(() => {
|
|
471
469
|
const { months, weekdays } = currentLocale.value;
|
|
472
470
|
|
|
@@ -610,6 +608,20 @@ const isVariant = computed(() => ({
|
|
|
610
608
|
input: props.variant === DATE_PICKER_INPUT_TYPE,
|
|
611
609
|
}));
|
|
612
610
|
|
|
611
|
+
const clickOutsideOptions = computed(() => {
|
|
612
|
+
if (isVariant.value.input) {
|
|
613
|
+
return { ignore: [inputRef.value.input] };
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
return {
|
|
617
|
+
ignore: [
|
|
618
|
+
buttonRef.value.buttonRef,
|
|
619
|
+
buttonPrevRef.value.buttonRef,
|
|
620
|
+
buttonNextRef.value.buttonRef,
|
|
621
|
+
],
|
|
622
|
+
};
|
|
623
|
+
});
|
|
624
|
+
|
|
613
625
|
const userFormatDate = computed(() => {
|
|
614
626
|
if ((!localValue.value.from && !localValue.value.to) || !localValue.value.from) return "";
|
|
615
627
|
|
package/ui.loader-top/Docs.mdx
CHANGED
|
@@ -25,9 +25,8 @@ const {
|
|
|
25
25
|
loaderTopOn,
|
|
26
26
|
loaderTopOff,
|
|
27
27
|
requestQueue,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
removeComponentRequestQueue
|
|
28
|
+
addRequestUrl
|
|
29
|
+
removeRequestUrl
|
|
31
30
|
} = useLoaderTop();
|
|
32
31
|
|
|
33
32
|
// get loader state
|
|
@@ -42,14 +41,13 @@ loaderTopOff("/transactions");
|
|
|
42
41
|
// get current resource array
|
|
43
42
|
console.log(requestQueue.value);
|
|
44
43
|
|
|
45
|
-
//
|
|
46
|
-
|
|
44
|
+
// add resource into loader queue
|
|
45
|
+
addRequestUrl("/transactions");
|
|
46
|
+
addRequestUrl(["/transactions", "/products"]);
|
|
47
47
|
|
|
48
|
-
//
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
// remove resource from component related loader queue
|
|
52
|
-
removeComponentRequestQueue("/transactions");
|
|
48
|
+
// remove resource from loader queue
|
|
49
|
+
removeRequestUrl("/transactions");
|
|
50
|
+
removeRequestUrl(["/transactions", "/products"]);
|
|
53
51
|
`} language="jsx" dark />
|
|
54
52
|
|
|
55
53
|
## Using loader outside Vue components
|
|
@@ -1,21 +1,25 @@
|
|
|
1
1
|
import { inject, readonly, ref } from "vue";
|
|
2
2
|
|
|
3
|
+
import { getRequestWithoutQuery } from "../services/loaderTop.service";
|
|
4
|
+
|
|
3
5
|
export const LoaderTopSymbol = Symbol.for("vueless:loader-top");
|
|
4
6
|
|
|
5
|
-
const isLoading = ref(
|
|
7
|
+
const isLoading = ref(false);
|
|
6
8
|
const requestQueue = ref([]);
|
|
7
9
|
const requestTimeout = ref(0);
|
|
8
|
-
const componentRequestQueue = ref([]);
|
|
9
10
|
|
|
10
11
|
function loaderTopOn(url) {
|
|
11
|
-
|
|
12
|
+
addRequestUrl(url);
|
|
13
|
+
|
|
12
14
|
isLoading.value = true;
|
|
13
15
|
|
|
14
16
|
clearTimeout(requestTimeout.value);
|
|
15
17
|
}
|
|
16
18
|
|
|
17
19
|
function loaderTopOff(url) {
|
|
18
|
-
requestQueue.value = url
|
|
20
|
+
requestQueue.value = url
|
|
21
|
+
? requestQueue.value.filter((item) => item !== getRequestWithoutQuery(url))
|
|
22
|
+
: [];
|
|
19
23
|
|
|
20
24
|
requestTimeout.value = setTimeout(() => {
|
|
21
25
|
if (!requestQueue.value.length) {
|
|
@@ -24,23 +28,30 @@ function loaderTopOff(url) {
|
|
|
24
28
|
}, 50);
|
|
25
29
|
}
|
|
26
30
|
|
|
27
|
-
function
|
|
28
|
-
|
|
31
|
+
function addRequestUrl(url) {
|
|
32
|
+
Array.isArray(url)
|
|
33
|
+
? requestQueue.value.push(...url.map(getRequestWithoutQuery))
|
|
34
|
+
: requestQueue.value.push(getRequestWithoutQuery(url));
|
|
29
35
|
}
|
|
30
36
|
|
|
31
|
-
function
|
|
32
|
-
|
|
37
|
+
function removeRequestUrl(url) {
|
|
38
|
+
if (Array.isArray(url)) {
|
|
39
|
+
url.map(getRequestWithoutQuery).forEach(removeRequestUrl);
|
|
40
|
+
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
requestQueue.value = requestQueue.value.filter((item) => item !== getRequestWithoutQuery(url));
|
|
33
45
|
}
|
|
34
46
|
|
|
35
47
|
export function createLoaderTop() {
|
|
36
48
|
return {
|
|
37
49
|
isLoading: readonly(isLoading),
|
|
38
50
|
requestQueue: readonly(requestQueue),
|
|
39
|
-
componentRequestQueue: readonly(componentRequestQueue),
|
|
40
51
|
loaderTopOn,
|
|
41
52
|
loaderTopOff,
|
|
42
|
-
|
|
43
|
-
|
|
53
|
+
addRequestUrl,
|
|
54
|
+
removeRequestUrl,
|
|
44
55
|
};
|
|
45
56
|
}
|
|
46
57
|
|
package/ui.loader-top/index.vue
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import { computed, onBeforeUnmount, watch, ref, onMounted, onUnmounted } from "vue";
|
|
9
9
|
|
|
10
10
|
import UIService, { isMobileApp } from "../service.ui";
|
|
11
|
-
import { clamp, queue } from "./services/loaderTop.service";
|
|
11
|
+
import { clamp, queue, getRequestWithoutQuery } from "./services/loaderTop.service";
|
|
12
12
|
import { useLoaderTop } from "./composables/useLoaderTop";
|
|
13
13
|
|
|
14
14
|
import { ULoaderTop, MAXIMUM, SPEED } from "./constants";
|
|
@@ -43,15 +43,7 @@ const progress = ref(0);
|
|
|
43
43
|
const opacity = ref(1);
|
|
44
44
|
const status = ref(null);
|
|
45
45
|
|
|
46
|
-
const {
|
|
47
|
-
isLoading,
|
|
48
|
-
requestQueue,
|
|
49
|
-
loaderTopOn,
|
|
50
|
-
loaderTopOff,
|
|
51
|
-
loaderRequestQueue,
|
|
52
|
-
setComponentRequestQueue,
|
|
53
|
-
removeComponentRequestQueue,
|
|
54
|
-
} = useLoaderTop();
|
|
46
|
+
const { requestQueue, removeRequestUrl, isLoading, loaderTopOff, loaderTopOn } = useLoaderTop();
|
|
55
47
|
const { progressAttrs } = useAttrs(props, { error, isMobileApp });
|
|
56
48
|
|
|
57
49
|
const isStarted = computed(() => {
|
|
@@ -66,27 +58,27 @@ const barStyle = computed(() => {
|
|
|
66
58
|
});
|
|
67
59
|
|
|
68
60
|
const resourceNamesArray = computed(() => {
|
|
69
|
-
return Array.isArray(props.resources)
|
|
61
|
+
return Array.isArray(props.resources)
|
|
62
|
+
? props.resources.map(getRequestWithoutQuery)
|
|
63
|
+
: [getRequestWithoutQuery(props.resources)];
|
|
70
64
|
});
|
|
71
65
|
|
|
72
|
-
watch(requestQueue, onChangeRequestsQueue
|
|
73
|
-
watch(isLoading, onChangeLoadingState
|
|
74
|
-
|
|
75
|
-
if (props.resources) {
|
|
76
|
-
setComponentRequestQueue(resourceNamesArray.value);
|
|
77
|
-
}
|
|
66
|
+
watch(() => requestQueue.value.length, onChangeRequestsQueue);
|
|
67
|
+
watch(isLoading, onChangeLoadingState);
|
|
78
68
|
|
|
79
69
|
onMounted(() => {
|
|
80
70
|
window.addEventListener("loaderTopOn", setLoaderOnHandler);
|
|
81
71
|
window.addEventListener("loaderTopOff", setLoaderOffHandler);
|
|
82
|
-
});
|
|
83
72
|
|
|
84
|
-
onBeforeUnmount(() => {
|
|
85
73
|
if (props.resources) {
|
|
86
|
-
|
|
74
|
+
onChangeRequestsQueue();
|
|
87
75
|
}
|
|
88
76
|
});
|
|
89
77
|
|
|
78
|
+
onBeforeUnmount(() => {
|
|
79
|
+
removeRequestUrl(resourceNamesArray.value);
|
|
80
|
+
});
|
|
81
|
+
|
|
90
82
|
onUnmounted(() => {
|
|
91
83
|
window.removeEventListener("loaderTopOn", setLoaderOnHandler);
|
|
92
84
|
window.removeEventListener("loaderTopOff", setLoaderOffHandler);
|
|
@@ -100,12 +92,6 @@ function setLoaderOffHandler(event) {
|
|
|
100
92
|
loaderTopOff(event.detail.resource);
|
|
101
93
|
}
|
|
102
94
|
|
|
103
|
-
function requestWithoutQuery(request) {
|
|
104
|
-
const [requestWithoutQuery] = request.split("?");
|
|
105
|
-
|
|
106
|
-
return requestWithoutQuery;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
95
|
function onChangeLoadingState() {
|
|
110
96
|
if (!props.resources && isStarted.value && show.value && !isLoading.value) {
|
|
111
97
|
done();
|
|
@@ -116,13 +102,11 @@ function onChangeRequestsQueue() {
|
|
|
116
102
|
let isActiveRequests = false;
|
|
117
103
|
|
|
118
104
|
if (props.resources) {
|
|
119
|
-
resourceNamesArray.value.forEach((
|
|
105
|
+
resourceNamesArray.value.forEach((resource) => {
|
|
120
106
|
if (!isActiveRequests) {
|
|
121
|
-
const activeRequest = requestQueue.value.find(
|
|
122
|
-
(request) => requestWithoutQuery(request) === item,
|
|
123
|
-
);
|
|
107
|
+
const activeRequest = requestQueue.value.find((request) => request === resource);
|
|
124
108
|
|
|
125
|
-
isActiveRequests =
|
|
109
|
+
isActiveRequests = Boolean(activeRequest);
|
|
126
110
|
}
|
|
127
111
|
});
|
|
128
112
|
|
|
@@ -132,10 +116,8 @@ function onChangeRequestsQueue() {
|
|
|
132
116
|
done();
|
|
133
117
|
}
|
|
134
118
|
} else {
|
|
135
|
-
|
|
136
|
-
const activeRequest =
|
|
137
|
-
(request) => request === requestWithoutQuery(item),
|
|
138
|
-
);
|
|
119
|
+
resourceNamesArray.value.forEach((resource) => {
|
|
120
|
+
const activeRequest = requestQueue.value.find((request) => request === resource);
|
|
139
121
|
|
|
140
122
|
isActiveRequests = !activeRequest;
|
|
141
123
|
});
|
package/web-types.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"framework": "vue",
|
|
3
3
|
"name": "vueless",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.179",
|
|
5
5
|
"contributions": {
|
|
6
6
|
"html": {
|
|
7
7
|
"description-markup": "markdown",
|
|
@@ -806,6 +806,24 @@
|
|
|
806
806
|
"type": "string"
|
|
807
807
|
},
|
|
808
808
|
"default": "\"\""
|
|
809
|
+
},
|
|
810
|
+
{
|
|
811
|
+
"name": "iconLeft",
|
|
812
|
+
"description": "Left side icon name.",
|
|
813
|
+
"value": {
|
|
814
|
+
"kind": "expression",
|
|
815
|
+
"type": "string"
|
|
816
|
+
},
|
|
817
|
+
"default": "\"\""
|
|
818
|
+
},
|
|
819
|
+
{
|
|
820
|
+
"name": "iconRight",
|
|
821
|
+
"description": "Right side icon name.",
|
|
822
|
+
"value": {
|
|
823
|
+
"kind": "expression",
|
|
824
|
+
"type": "string"
|
|
825
|
+
},
|
|
826
|
+
"default": "\"\""
|
|
809
827
|
}
|
|
810
828
|
],
|
|
811
829
|
"events": [
|
|
@@ -816,7 +834,7 @@
|
|
|
816
834
|
"slots": [
|
|
817
835
|
{
|
|
818
836
|
"name": "left",
|
|
819
|
-
"description": "Use it to add
|
|
837
|
+
"description": "Use it to add icon before text."
|
|
820
838
|
},
|
|
821
839
|
{
|
|
822
840
|
"name": "default",
|
|
@@ -824,7 +842,7 @@
|
|
|
824
842
|
},
|
|
825
843
|
{
|
|
826
844
|
"name": "right",
|
|
827
|
-
"description": "Use it to add
|
|
845
|
+
"description": "Use it to add icon after text."
|
|
828
846
|
}
|
|
829
847
|
],
|
|
830
848
|
"source": {
|