vueless 0.0.178 → 0.0.180
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.data-table/configs/default.config.js +2 -2
- package/ui.form-calendar/components/DayView.vue +6 -6
- package/ui.form-calendar/components/MonthView.vue +9 -5
- package/ui.form-calendar/components/YearView.vue +8 -4
- package/ui.form-calendar/composables/attrs.composable.js +23 -18
- package/ui.form-calendar/configs/default.config.js +12 -17
- package/ui.form-calendar/index.vue +4 -4
- package/ui.form-checkbox-group/configs/default.config.js +2 -0
- package/ui.form-checkbox-group/index.vue +39 -22
- package/ui.form-color-picker/composables/attrs.composable.js +19 -14
- package/ui.form-color-picker/configs/default.config.js +21 -15
- package/ui.form-color-picker/index.stories.js +1 -1
- package/ui.form-color-picker/index.vue +78 -59
- package/ui.form-date-picker/index.vue +4 -3
- package/ui.form-date-picker-range/index.vue +16 -4
- package/ui.form-input/index.stories.js +15 -5
- package/ui.form-input/index.vue +56 -28
- package/ui.form-radio/index.stories.js +4 -4
- package/ui.form-radio/index.vue +8 -4
- package/ui.form-radio-group/composables/attrs.composable.js +2 -0
- package/ui.form-radio-group/configs/default.config.js +3 -3
- package/ui.form-radio-group/index.stories.js +3 -3
- package/ui.form-radio-group/index.vue +29 -8
- 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/ui.navigation-progress/composables/attrs.composable.js +38 -2
- package/ui.navigation-progress/configs/default.config.js +32 -0
- package/ui.navigation-progress/index.stories.js +127 -2
- package/ui.navigation-progress/index.vue +53 -5
- package/ui.text-alert/configs/default.config.js +7 -7
- package/ui.text-block/composables/attrs.composable.js +2 -0
- package/ui.text-block/configs/default.config.js +7 -7
- package/ui.text-block/index.stories.js +16 -16
- package/ui.text-block/index.vue +4 -4
- package/web-types.json +111 -45
|
@@ -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
|
});
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import useUI from "../../composable.ui";
|
|
2
|
-
import { cva } from "../../service.ui";
|
|
2
|
+
import { cva, cx } from "../../service.ui";
|
|
3
3
|
|
|
4
4
|
import defaultConfig from "../configs/default.config";
|
|
5
5
|
import { computed } from "vue";
|
|
6
6
|
|
|
7
7
|
export function useAttrs(props) {
|
|
8
8
|
const { config, getAttrs, getColor, setColor } = useUI(defaultConfig, () => props.config);
|
|
9
|
-
const { progress } = config.value;
|
|
9
|
+
const { progress, indicator, step } = config.value;
|
|
10
10
|
|
|
11
11
|
const cvaProgress = cva({
|
|
12
12
|
base: progress.base,
|
|
@@ -14,6 +14,18 @@ export function useAttrs(props) {
|
|
|
14
14
|
compoundVariants: progress.compoundVariants,
|
|
15
15
|
});
|
|
16
16
|
|
|
17
|
+
const cvaIndicator = cva({
|
|
18
|
+
base: indicator.base,
|
|
19
|
+
variants: indicator.variants,
|
|
20
|
+
compoundVariants: indicator.compoundVariants,
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const cvaStep = cva({
|
|
24
|
+
base: step.base,
|
|
25
|
+
variants: step.variants,
|
|
26
|
+
compoundVariants: step.compoundVariants,
|
|
27
|
+
});
|
|
28
|
+
|
|
17
29
|
const progressClasses = computed(() =>
|
|
18
30
|
setColor(
|
|
19
31
|
cvaProgress({
|
|
@@ -24,9 +36,33 @@ export function useAttrs(props) {
|
|
|
24
36
|
),
|
|
25
37
|
);
|
|
26
38
|
|
|
39
|
+
const indicatorClasses = computed(() =>
|
|
40
|
+
setColor(
|
|
41
|
+
cvaIndicator({
|
|
42
|
+
size: props.size,
|
|
43
|
+
color: getColor(props.color),
|
|
44
|
+
}),
|
|
45
|
+
props.color,
|
|
46
|
+
),
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
const stepClasses = computed(() => setColor(cvaStep({ size: props.size }), props.color));
|
|
50
|
+
|
|
51
|
+
const wrapperAttrs = getAttrs("wrapper");
|
|
52
|
+
const indicatorAttrs = getAttrs("indicator", { classes: indicatorClasses });
|
|
27
53
|
const progressAttrs = getAttrs("progress", { classes: progressClasses });
|
|
54
|
+
const stepAttrsRaw = getAttrs("step", { classes: stepClasses });
|
|
55
|
+
|
|
56
|
+
const stepAttrs = computed(() => (classes) => ({
|
|
57
|
+
...stepAttrsRaw.value,
|
|
58
|
+
class: cx([stepAttrsRaw.value.class, classes]),
|
|
59
|
+
}));
|
|
28
60
|
|
|
29
61
|
return {
|
|
30
62
|
progressAttrs,
|
|
63
|
+
wrapperAttrs,
|
|
64
|
+
indicatorAttrs,
|
|
65
|
+
stepAttrs,
|
|
66
|
+
config,
|
|
31
67
|
};
|
|
32
68
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export default /*tw*/ {
|
|
2
|
+
wrapper: "h-auto flex flex-col gap-1.5 w-full",
|
|
2
3
|
progress: {
|
|
3
4
|
base: `
|
|
4
5
|
block appearance-none border-none overflow-hidden w-full
|
|
@@ -26,6 +27,37 @@ export default /*tw*/ {
|
|
|
26
27
|
},
|
|
27
28
|
},
|
|
28
29
|
},
|
|
30
|
+
indicator: {
|
|
31
|
+
base: "w-full flex justify-end font-medium text-brand-500 min-w-fit",
|
|
32
|
+
variants: {
|
|
33
|
+
color: {
|
|
34
|
+
white: "text-white",
|
|
35
|
+
grayscale: "text-gray-900",
|
|
36
|
+
},
|
|
37
|
+
size: {
|
|
38
|
+
xs: "text-xs",
|
|
39
|
+
sm: "text-sm",
|
|
40
|
+
md: "text-md",
|
|
41
|
+
lg: "text-lg",
|
|
42
|
+
xl: "text-xl",
|
|
43
|
+
"2xl": "text-2xl",
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
firstStep: "text-gray-500",
|
|
48
|
+
step: {
|
|
49
|
+
base: "flex w-full justify-end text-brand-500",
|
|
50
|
+
variants: {
|
|
51
|
+
size: {
|
|
52
|
+
xs: "text-xs",
|
|
53
|
+
sm: "text-sm",
|
|
54
|
+
md: "text-md",
|
|
55
|
+
lg: "text-lg",
|
|
56
|
+
xl: "text-xl",
|
|
57
|
+
"2xl": "text-2xl",
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
},
|
|
29
61
|
defaultVariants: {
|
|
30
62
|
color: "brand",
|
|
31
63
|
size: "md",
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import UProgress from "./index.vue";
|
|
2
2
|
import UButton from "../ui.button/index.vue";
|
|
3
|
+
import UIcon from "../ui.image-icon";
|
|
4
|
+
import URow from "../ui.container-row";
|
|
3
5
|
|
|
4
6
|
import { getArgTypes } from "../service.storybook";
|
|
5
7
|
|
|
@@ -16,7 +18,7 @@ export default {
|
|
|
16
18
|
};
|
|
17
19
|
|
|
18
20
|
const DefaultTemplate = (args) => ({
|
|
19
|
-
components: { UProgress, UButton },
|
|
21
|
+
components: { UProgress, UButton, UIcon },
|
|
20
22
|
setup() {
|
|
21
23
|
return { args };
|
|
22
24
|
},
|
|
@@ -35,11 +37,134 @@ const DefaultTemplate = (args) => ({
|
|
|
35
37
|
},
|
|
36
38
|
},
|
|
37
39
|
template: `
|
|
38
|
-
<UProgress :value="progress"
|
|
40
|
+
<UProgress v-bind="args" :value="progress">
|
|
41
|
+
${args.slotTemplate}
|
|
42
|
+
</UProgress>
|
|
39
43
|
|
|
40
44
|
<UButton class="mt-4" @click="updateProgress">Update Progress</UButton>
|
|
41
45
|
`,
|
|
42
46
|
});
|
|
43
47
|
|
|
48
|
+
const StepsTemplate = (args) => ({
|
|
49
|
+
components: { UProgress, UButton, UIcon },
|
|
50
|
+
setup() {
|
|
51
|
+
return { args };
|
|
52
|
+
},
|
|
53
|
+
data() {
|
|
54
|
+
return {
|
|
55
|
+
progress: 1,
|
|
56
|
+
max: ["Step 1", "Step 2", "Step 3"],
|
|
57
|
+
};
|
|
58
|
+
},
|
|
59
|
+
methods: {
|
|
60
|
+
updateProgress() {
|
|
61
|
+
this.progress += 1;
|
|
62
|
+
|
|
63
|
+
if (this.progress > 3) {
|
|
64
|
+
this.progress = 0;
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
template: `
|
|
69
|
+
<UProgress v-bind="args" :max="max" :value="progress">
|
|
70
|
+
${args.slotTemplate}
|
|
71
|
+
</UProgress>
|
|
72
|
+
|
|
73
|
+
<UButton class="mt-4" @click="updateProgress">Update Progress</UButton>
|
|
74
|
+
`,
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
const ColorsTemplate = (args, { argTypes } = {}) => ({
|
|
78
|
+
components: { UProgress, URow },
|
|
79
|
+
setup() {
|
|
80
|
+
return {
|
|
81
|
+
args,
|
|
82
|
+
colors: argTypes.color.options,
|
|
83
|
+
};
|
|
84
|
+
},
|
|
85
|
+
data() {
|
|
86
|
+
return {
|
|
87
|
+
progress: 10,
|
|
88
|
+
};
|
|
89
|
+
},
|
|
90
|
+
template: `
|
|
91
|
+
<URow class="!flex-col">
|
|
92
|
+
<UProgress
|
|
93
|
+
v-for="(color, index) in colors"
|
|
94
|
+
:key="index"
|
|
95
|
+
:color="color"
|
|
96
|
+
v-bind="args"
|
|
97
|
+
:value="progress"
|
|
98
|
+
/>
|
|
99
|
+
</URow>
|
|
100
|
+
`,
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
const SizesTemplate = (args, { argTypes } = {}) => ({
|
|
104
|
+
components: { UProgress, URow },
|
|
105
|
+
setup() {
|
|
106
|
+
return {
|
|
107
|
+
args,
|
|
108
|
+
sizes: argTypes.size.options,
|
|
109
|
+
};
|
|
110
|
+
},
|
|
111
|
+
data() {
|
|
112
|
+
return {
|
|
113
|
+
progress: 10,
|
|
114
|
+
};
|
|
115
|
+
},
|
|
116
|
+
template: `
|
|
117
|
+
<URow class="!flex-col">
|
|
118
|
+
<UProgress
|
|
119
|
+
v-for="(size, index) in sizes"
|
|
120
|
+
:key="index"
|
|
121
|
+
:size="size"
|
|
122
|
+
v-bind="args"
|
|
123
|
+
:value="progress"
|
|
124
|
+
/>
|
|
125
|
+
</URow>
|
|
126
|
+
`,
|
|
127
|
+
});
|
|
128
|
+
|
|
44
129
|
export const Default = DefaultTemplate.bind({});
|
|
45
130
|
Default.args = {};
|
|
131
|
+
|
|
132
|
+
export const Indicator = DefaultTemplate.bind({});
|
|
133
|
+
Indicator.args = { indicator: true };
|
|
134
|
+
|
|
135
|
+
export const Steps = StepsTemplate.bind({});
|
|
136
|
+
Steps.args = {};
|
|
137
|
+
|
|
138
|
+
export const Colors = ColorsTemplate.bind({});
|
|
139
|
+
Colors.args = {};
|
|
140
|
+
|
|
141
|
+
export const Sizes = SizesTemplate.bind({});
|
|
142
|
+
Sizes.args = {};
|
|
143
|
+
|
|
144
|
+
export const IndicatorSlot = DefaultTemplate.bind({});
|
|
145
|
+
IndicatorSlot.args = {
|
|
146
|
+
indicator: true,
|
|
147
|
+
slotTemplate: `
|
|
148
|
+
<template #indicator>
|
|
149
|
+
<UIcon
|
|
150
|
+
name="star"
|
|
151
|
+
color="black"
|
|
152
|
+
/>
|
|
153
|
+
</template>
|
|
154
|
+
`,
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
export const stepSlot = StepsTemplate.bind({});
|
|
158
|
+
stepSlot.args = {
|
|
159
|
+
slotTemplate: `
|
|
160
|
+
<template #step-0>
|
|
161
|
+
💻
|
|
162
|
+
</template>
|
|
163
|
+
<template #step-1>
|
|
164
|
+
🧇
|
|
165
|
+
</template>
|
|
166
|
+
<template #step-2>
|
|
167
|
+
😴
|
|
168
|
+
</template>
|
|
169
|
+
`,
|
|
170
|
+
};
|
|
@@ -1,13 +1,37 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
2
|
+
<div v-bind="wrapperAttrs">
|
|
3
|
+
<div v-if="indicator" v-bind="indicatorAttrs" :style="{ width: progressPercent }">
|
|
4
|
+
<slot name="indicator" :percent="progressPercent" :value="value" :max="realMax">
|
|
5
|
+
{{ progressPercent }}
|
|
6
|
+
</slot>
|
|
7
|
+
</div>
|
|
8
|
+
|
|
9
|
+
<progress v-bind="progressAttrs" :max="realMax" :value="value" />
|
|
10
|
+
|
|
11
|
+
<div v-if="isSteps" v-bind="stepAttrs(!value && config.firstStep)">
|
|
12
|
+
<template v-for="(step, index) in max" :key="index">
|
|
13
|
+
<slot
|
|
14
|
+
v-if="isActiveStep(index)"
|
|
15
|
+
:name="`step-${index}`"
|
|
16
|
+
:step="step"
|
|
17
|
+
:value="value"
|
|
18
|
+
:max="max"
|
|
19
|
+
>
|
|
20
|
+
{{ step }}
|
|
21
|
+
</slot>
|
|
22
|
+
</template>
|
|
23
|
+
</div>
|
|
24
|
+
</div>
|
|
3
25
|
</template>
|
|
4
26
|
|
|
5
27
|
<script setup>
|
|
28
|
+
import { computed } from "vue";
|
|
29
|
+
|
|
6
30
|
import UIService from "../service.ui";
|
|
31
|
+
import { useAttrs } from "./composables/attrs.composable";
|
|
7
32
|
|
|
8
|
-
import { UProgress } from "./constants";
|
|
9
33
|
import defaultConfig from "./configs/default.config";
|
|
10
|
-
import {
|
|
34
|
+
import { UProgress } from "./constants";
|
|
11
35
|
|
|
12
36
|
/* Should be a string for correct web-types gen */
|
|
13
37
|
defineOptions({ name: "UProgress", inheritAttrs: false });
|
|
@@ -26,7 +50,7 @@ const props = defineProps({
|
|
|
26
50
|
* Progress max amount of steps.
|
|
27
51
|
*/
|
|
28
52
|
max: {
|
|
29
|
-
type: Number,
|
|
53
|
+
type: [Number, Array],
|
|
30
54
|
default: 100,
|
|
31
55
|
},
|
|
32
56
|
|
|
@@ -47,7 +71,31 @@ const props = defineProps({
|
|
|
47
71
|
type: String,
|
|
48
72
|
default: UIService.get(defaultConfig, UProgress).default.color,
|
|
49
73
|
},
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Progress indicator visibility.
|
|
77
|
+
*/
|
|
78
|
+
indicator: {
|
|
79
|
+
type: Boolean,
|
|
80
|
+
default: UIService.get(defaultConfig, UProgress).default.indicator,
|
|
81
|
+
},
|
|
50
82
|
});
|
|
51
83
|
|
|
52
|
-
const { progressAttrs } = useAttrs(props);
|
|
84
|
+
const { progressAttrs, wrapperAttrs, indicatorAttrs, stepAttrs, config } = useAttrs(props);
|
|
85
|
+
|
|
86
|
+
const isSteps = computed(() => Array.isArray(props.max));
|
|
87
|
+
|
|
88
|
+
const realMax = computed(() => {
|
|
89
|
+
if (isSteps.value) {
|
|
90
|
+
return props.max.length;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return Number(props.max);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
const progressPercent = computed(() => `${(props.value / realMax.value) * 100}%`);
|
|
97
|
+
|
|
98
|
+
function isActiveStep(index) {
|
|
99
|
+
return index + 1 == props.value;
|
|
100
|
+
}
|
|
53
101
|
</script>
|
|
@@ -15,22 +15,22 @@ export default /*tw*/ {
|
|
|
15
15
|
},
|
|
16
16
|
body: {
|
|
17
17
|
base: `
|
|
18
|
-
flex gap-2 items-baseline
|
|
18
|
+
flex gap-2 items-baseline
|
|
19
|
+
font-normal leading-normal
|
|
19
20
|
[&_b]:font-bold [&_i]:italic [&_p]:font-normal
|
|
20
21
|
[&_a:not([class])]:underline [&_a:not([class])]:underline-offset-4
|
|
21
22
|
[&_a:not([class]):hover]:no-underline [&_a:not([class])]:font-bold
|
|
22
23
|
[&_ul]:font-normal [&_ol]:font-normal
|
|
23
|
-
[&_ul]:leading-
|
|
24
|
-
[&_ul]:list-inside [&_ol]:list-inside
|
|
24
|
+
[&_ul]:leading-normal [&_ol]:leading-normal
|
|
25
25
|
[&_ul]:list-disc [&_ol]:list-decimal
|
|
26
26
|
[&_ul]:ml-2 [&_ol]:ml-2
|
|
27
27
|
`,
|
|
28
28
|
variants: {
|
|
29
29
|
size: {
|
|
30
|
-
xs: "text-xs",
|
|
31
|
-
sm: "text-sm",
|
|
32
|
-
md: "text-base",
|
|
33
|
-
lg: "text-lg",
|
|
30
|
+
xs: "text-xs space-y-2",
|
|
31
|
+
sm: "text-sm space-y-3",
|
|
32
|
+
md: "text-base space-y-4",
|
|
33
|
+
lg: "text-lg space-y-5",
|
|
34
34
|
},
|
|
35
35
|
},
|
|
36
36
|
},
|
|
@@ -1,22 +1,21 @@
|
|
|
1
1
|
export default /*tw*/ {
|
|
2
2
|
wrapper: {
|
|
3
3
|
base: `
|
|
4
|
-
|
|
4
|
+
font-normal leading-normal
|
|
5
5
|
[&_b]:font-bold [&_i]:italic [&_p]:font-normal
|
|
6
6
|
[&_a:not([class])]:underline [&_a:not([class])]:underline-offset-4
|
|
7
7
|
[&_a:not([class]):hover]:no-underline [&_a:not([class])]:font-bold
|
|
8
8
|
[&_ul]:font-normal [&_ol]:font-normal
|
|
9
|
-
[&_ul]:leading-
|
|
10
|
-
[&_ul]:list-inside [&_ol]:list-inside
|
|
9
|
+
[&_ul]:leading-normal [&_ol]:leading-normal
|
|
11
10
|
[&_ul]:list-disc [&_ol]:list-decimal
|
|
12
11
|
[&_ul]:ml-2 [&_ol]:ml-2
|
|
13
12
|
`,
|
|
14
13
|
variants: {
|
|
15
14
|
size: {
|
|
16
|
-
xs: "text-xs",
|
|
17
|
-
sm: "text-sm",
|
|
18
|
-
md: "text-base",
|
|
19
|
-
lg: "text-lg",
|
|
15
|
+
xs: "text-xs space-y-2",
|
|
16
|
+
sm: "text-sm space-y-3",
|
|
17
|
+
md: "text-base space-y-4",
|
|
18
|
+
lg: "text-lg space-y-5",
|
|
20
19
|
},
|
|
21
20
|
align: {
|
|
22
21
|
left: "text-left",
|
|
@@ -28,6 +27,7 @@ export default /*tw*/ {
|
|
|
28
27
|
},
|
|
29
28
|
},
|
|
30
29
|
},
|
|
30
|
+
html: "",
|
|
31
31
|
defaultVariants: {
|
|
32
32
|
size: "md",
|
|
33
33
|
align: "left",
|
|
@@ -13,29 +13,29 @@ export default {
|
|
|
13
13
|
argTypes: {
|
|
14
14
|
...getArgTypes(UText.name),
|
|
15
15
|
},
|
|
16
|
-
args: {
|
|
17
|
-
slotTemplate: `
|
|
18
|
-
<template #default>
|
|
19
|
-
<p>
|
|
20
|
-
<b>Lorem ipsum dolor sit amet</b><u>, consectetur adipiscing elit,
|
|
21
|
-
</u><em> sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</em>
|
|
22
|
-
<a href="https://uk.wikipedia.org/wiki/Lorem_ipsum" target="_blank">Wikipedia</a>
|
|
23
|
-
</p>
|
|
24
|
-
</template>
|
|
25
|
-
`,
|
|
26
|
-
},
|
|
16
|
+
args: {},
|
|
27
17
|
};
|
|
28
18
|
|
|
19
|
+
const defaultTemplate = `
|
|
20
|
+
<template #default>
|
|
21
|
+
<p>
|
|
22
|
+
<b>Lorem ipsum dolor sit amet</b>, consectetur adipiscing elit,
|
|
23
|
+
sed do <u>eiusmod</u> tempor incididunt ut <i>labore</i> et dolore magna aliqua.
|
|
24
|
+
<a href="https://uk.wikipedia.org/wiki/Lorem_ipsum" target="_blank">Wikipedia</a>
|
|
25
|
+
</p>
|
|
26
|
+
</template>
|
|
27
|
+
`;
|
|
28
|
+
|
|
29
29
|
const DefaultTemplate = (args) => ({
|
|
30
|
-
components: { UText },
|
|
30
|
+
components: { UText, URow },
|
|
31
31
|
setup() {
|
|
32
32
|
const slots = getSlotNames(UText.name);
|
|
33
33
|
|
|
34
34
|
return { args, slots };
|
|
35
35
|
},
|
|
36
36
|
template: `
|
|
37
|
-
<UText v-bind="args"
|
|
38
|
-
${args.slotTemplate}
|
|
37
|
+
<UText v-bind="args">
|
|
38
|
+
${args.slotTemplate || defaultTemplate}
|
|
39
39
|
</UText>
|
|
40
40
|
`,
|
|
41
41
|
});
|
|
@@ -56,7 +56,7 @@ const SizesTemplate = (args, { argTypes } = {}) => ({
|
|
|
56
56
|
v-bind="args"
|
|
57
57
|
:key="index"
|
|
58
58
|
>
|
|
59
|
-
${args.slotTemplate}
|
|
59
|
+
${args.slotTemplate || defaultTemplate}
|
|
60
60
|
</UText>
|
|
61
61
|
</URow>
|
|
62
62
|
`,
|
|
@@ -97,7 +97,7 @@ export const list = DefaultTemplate.bind({});
|
|
|
97
97
|
list.args = {
|
|
98
98
|
slotTemplate: `
|
|
99
99
|
<template #default>
|
|
100
|
-
<URow>
|
|
100
|
+
<URow gap="2xl">
|
|
101
101
|
<ul>
|
|
102
102
|
<li> Lorem ipsum dolor </li>
|
|
103
103
|
<li> Lorem ipsum dolor </li>
|
package/ui.text-block/index.vue
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div v-bind="wrapperAttrs" :data-cy="dataCy">
|
|
3
|
-
<!-- @slot Use it to add something. -->
|
|
4
|
-
<div v-if="!hasSlotContent($slots['default'])" v-html="html" />
|
|
3
|
+
<!-- @slot Use it to add something inside. -->
|
|
4
|
+
<div v-if="!hasSlotContent($slots['default'])" v-bind="htmlAttrs" v-html="html" />
|
|
5
5
|
<slot />
|
|
6
6
|
</div>
|
|
7
7
|
</template>
|
|
@@ -44,7 +44,7 @@ const props = defineProps({
|
|
|
44
44
|
},
|
|
45
45
|
|
|
46
46
|
/**
|
|
47
|
-
* Remove line height.
|
|
47
|
+
* Remove line height (useful for 1-line text).
|
|
48
48
|
*/
|
|
49
49
|
line: {
|
|
50
50
|
type: Boolean,
|
|
@@ -68,5 +68,5 @@ const props = defineProps({
|
|
|
68
68
|
},
|
|
69
69
|
});
|
|
70
70
|
|
|
71
|
-
const { wrapperAttrs, hasSlotContent } = useAttrs(props);
|
|
71
|
+
const { wrapperAttrs, htmlAttrs, hasSlotContent } = useAttrs(props);
|
|
72
72
|
</script>
|