vueless 0.0.569 → 0.0.571
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/types.ts +24 -3
- package/ui.button/types.ts +2 -2
- package/ui.container-accordion/UAccordion.vue +2 -2
- package/ui.container-accordion/types.ts +1 -0
- package/ui.container-modal/UModal.vue +15 -8
- package/ui.container-page/UPage.vue +10 -6
- package/ui.form-checkbox/types.ts +7 -0
- package/ui.form-checkbox-group/UCheckboxGroup.vue +1 -1
- package/ui.form-checkbox-multi-state/UCheckboxMultiState.vue +4 -1
- package/ui.form-color-picker/UColorPicker.vue +67 -147
- package/ui.form-color-picker/storybook/Docs.mdx +2 -2
- package/ui.form-color-picker/storybook/{stories.js → stories.ts} +13 -5
- package/ui.form-color-picker/types.ts +64 -0
- package/ui.form-color-picker/useAttrs.ts +15 -0
- package/ui.form-input/UInput.vue +162 -321
- package/ui.form-input/{config.js → config.ts} +3 -0
- package/ui.form-input/storybook/Docs.mdx +2 -2
- package/ui.form-input/storybook/{stories.js → stories.ts} +14 -6
- package/ui.form-input/types.ts +103 -0
- package/ui.form-input/useAttrs.ts +31 -0
- package/ui.form-input-file/UInputFile.vue +188 -245
- package/ui.form-input-file/storybook/Docs.mdx +2 -2
- package/ui.form-input-file/storybook/{stories.js → stories.ts} +13 -5
- package/ui.form-input-file/types.ts +72 -0
- package/ui.form-input-file/useAttrs.ts +21 -0
- package/ui.form-input-file/{utilFileForm.js → utilFileForm.ts} +1 -1
- package/ui.form-input-money/UInputMoney.vue +76 -223
- package/ui.form-input-money/storybook/Docs.mdx +2 -2
- package/ui.form-input-money/storybook/{stories.js → stories.ts} +14 -6
- package/ui.form-input-money/types.ts +118 -0
- package/ui.form-input-money/useAttrs.ts +15 -0
- package/ui.form-input-money/{useFormatCurrency.js → useFormatCurrency.ts} +28 -17
- package/ui.form-input-money/utilFormat.ts +83 -0
- package/ui.form-input-number/UInputNumber.vue +69 -156
- package/ui.form-input-number/storybook/Docs.mdx +2 -2
- package/ui.form-input-number/storybook/{stories.js → stories.ts} +17 -9
- package/ui.form-input-number/types.ts +65 -0
- package/ui.form-input-number/useAttrs.ts +15 -0
- package/ui.form-input-rating/UInputRating.vue +70 -158
- package/ui.form-input-rating/storybook/Docs.mdx +2 -2
- package/ui.form-input-rating/storybook/{stories.js → stories.ts} +14 -6
- package/ui.form-input-rating/types.ts +67 -0
- package/ui.form-input-rating/useAttrs.ts +14 -0
- package/ui.form-input-search/UInputSearch.vue +97 -224
- package/ui.form-input-search/storybook/Docs.mdx +2 -2
- package/ui.form-input-search/storybook/{stories.js → stories.ts} +13 -5
- package/ui.form-input-search/types.ts +93 -0
- package/ui.form-input-search/useAttrs.ts +15 -0
- package/ui.form-radio/URadio.vue +1 -1
- package/ui.form-radio-group/URadioGroup.vue +1 -1
- package/ui.navigation-pagination/UPagination.vue +15 -15
- package/ui.navigation-pagination/types.ts +3 -0
- package/ui.navigation-progress/UProgress.vue +16 -2
- package/ui.navigation-progress/types.ts +2 -0
- package/ui.text-files/UFiles.vue +20 -16
- package/ui.text-files/types.ts +1 -1
- package/ui.text-notify/UNotify.vue +38 -48
- package/ui.text-notify/types.ts +24 -0
- package/web-types.json +227 -138
- package/ui.form-color-picker/useAttrs.js +0 -9
- package/ui.form-input/useAttrs.js +0 -15
- package/ui.form-input-file/useAttrs.js +0 -15
- package/ui.form-input-money/useAttrs.js +0 -9
- package/ui.form-input-money/utilFormat.js +0 -75
- package/ui.form-input-number/useAttrs.js +0 -9
- package/ui.form-input-rating/useAttrs.js +0 -8
- package/ui.form-input-search/useAttrs.js +0 -9
- /package/ui.form-color-picker/{config.js → config.ts} +0 -0
- /package/ui.form-color-picker/{constants.js → constants.ts} +0 -0
- /package/ui.form-input/{constants.js → constants.ts} +0 -0
- /package/ui.form-input-file/{config.js → config.ts} +0 -0
- /package/ui.form-input-file/{constants.js → constants.ts} +0 -0
- /package/ui.form-input-money/{config.js → config.ts} +0 -0
- /package/ui.form-input-money/{constants.js → constants.ts} +0 -0
- /package/ui.form-input-number/{config.js → config.ts} +0 -0
- /package/ui.form-input-number/{constants.js → constants.ts} +0 -0
- /package/ui.form-input-rating/{config.js → config.ts} +0 -0
- /package/ui.form-input-rating/{constants.js → constants.ts} +0 -0
- /package/ui.form-input-search/{config.js → config.ts} +0 -0
- /package/ui.form-input-search/{constants.js → constants.ts} +0 -0
package/ui.text-files/UFiles.vue
CHANGED
|
@@ -7,6 +7,7 @@ import { UFiles } from "./constants.ts";
|
|
|
7
7
|
import defaultConfig from "./config.ts";
|
|
8
8
|
import useAttrs from "./useAttrs.ts";
|
|
9
9
|
import { computed } from "vue";
|
|
10
|
+
import { getRandomId } from "../utils/helper.ts";
|
|
10
11
|
|
|
11
12
|
import type { UFilesProps } from "./types.ts";
|
|
12
13
|
|
|
@@ -15,6 +16,7 @@ defineOptions({ inheritAttrs: false });
|
|
|
15
16
|
const props = withDefaults(defineProps<UFilesProps>(), {
|
|
16
17
|
labelAlign: getDefault<UFilesProps>(defaultConfig, UFiles).labelAlign,
|
|
17
18
|
size: getDefault<UFilesProps>(defaultConfig, UFiles).size,
|
|
19
|
+
fileList: () => [],
|
|
18
20
|
dataTest: "",
|
|
19
21
|
});
|
|
20
22
|
|
|
@@ -28,18 +30,20 @@ const emit = defineEmits([
|
|
|
28
30
|
|
|
29
31
|
const { filesLabelAttrs, itemsAttrs, itemAttrs } = useAttrs(props);
|
|
30
32
|
|
|
31
|
-
const formattedFileList = computed(() =>
|
|
32
|
-
props.fileList.map((file) => {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
33
|
+
const formattedFileList = computed(() => {
|
|
34
|
+
return props.fileList.map((file) => {
|
|
35
|
+
if (file instanceof File) {
|
|
36
|
+
return {
|
|
37
|
+
id: getRandomId(),
|
|
38
|
+
label: file.name || "",
|
|
39
|
+
url: URL.createObjectURL(file),
|
|
40
|
+
imageUrl: file.type.includes("image") ? URL.createObjectURL(file) : undefined,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
});
|
|
41
45
|
|
|
42
|
-
function onRemoveFile(fileId) {
|
|
46
|
+
function onRemoveFile(fileId: string | number) {
|
|
43
47
|
emit("remove", fileId);
|
|
44
48
|
}
|
|
45
49
|
</script>
|
|
@@ -57,11 +61,11 @@ function onRemoveFile(fileId) {
|
|
|
57
61
|
<slot>
|
|
58
62
|
<UFile
|
|
59
63
|
v-for="(file, index) in formattedFileList"
|
|
60
|
-
:id="file
|
|
61
|
-
:key="file
|
|
62
|
-
:label="file
|
|
63
|
-
:url="file
|
|
64
|
-
:image-url="file
|
|
64
|
+
:id="file?.id"
|
|
65
|
+
:key="file?.id"
|
|
66
|
+
:label="file?.label"
|
|
67
|
+
:url="file?.url"
|
|
68
|
+
:image-url="file?.imageUrl"
|
|
65
69
|
:size="size"
|
|
66
70
|
:removable="removable"
|
|
67
71
|
v-bind="itemAttrs"
|
package/ui.text-files/types.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { computed, onBeforeUnmount, onMounted, ref } from "vue";
|
|
3
3
|
import { merge } from "lodash-es";
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { getDefault, vuelessConfig } from "../utils/ui.ts";
|
|
6
6
|
import { useLocale } from "../composables/useLocale.ts";
|
|
7
7
|
import useAttrs from "./useAttrs.ts";
|
|
8
8
|
|
|
@@ -11,7 +11,13 @@ import { UNotify, NOTIFY_TYPE, POSITION } from "./constants.ts";
|
|
|
11
11
|
|
|
12
12
|
import UIcon from "../ui.image-icon/UIcon.vue";
|
|
13
13
|
|
|
14
|
-
import type {
|
|
14
|
+
import type {
|
|
15
|
+
UNotifyProps,
|
|
16
|
+
Notification,
|
|
17
|
+
NotifyEvent,
|
|
18
|
+
NotificationsWrapperRef,
|
|
19
|
+
NotificationType,
|
|
20
|
+
} from "./types.ts";
|
|
15
21
|
|
|
16
22
|
defineOptions({ inheritAttrs: false });
|
|
17
23
|
|
|
@@ -20,8 +26,19 @@ const props = withDefaults(defineProps<UNotifyProps>(), {
|
|
|
20
26
|
yPosition: getDefault<UNotifyProps>(defaultConfig, UNotify).yPosition,
|
|
21
27
|
html: getDefault<UNotifyProps>(defaultConfig, UNotify).html,
|
|
22
28
|
dataTest: "",
|
|
29
|
+
config: () => ({}),
|
|
23
30
|
});
|
|
24
31
|
|
|
32
|
+
const { tm } = useLocale();
|
|
33
|
+
|
|
34
|
+
const notifications = ref<Notification[]>([]);
|
|
35
|
+
const notifyPositionStyles = ref({});
|
|
36
|
+
|
|
37
|
+
const notificationsWrapperRef = ref<NotificationsWrapperRef | null>(null);
|
|
38
|
+
|
|
39
|
+
const i18nGlobal = tm(UNotify);
|
|
40
|
+
const currentLocale = computed(() => merge(defaultConfig.i18n, i18nGlobal, props.config.i18n));
|
|
41
|
+
|
|
25
42
|
const {
|
|
26
43
|
config,
|
|
27
44
|
wrapperAttrs,
|
|
@@ -33,17 +50,7 @@ const {
|
|
|
33
50
|
warningIconAttrs,
|
|
34
51
|
errorIconAttrs,
|
|
35
52
|
closeIconAttrs,
|
|
36
|
-
} = useAttrs(props);
|
|
37
|
-
|
|
38
|
-
const { tm } = useLocale();
|
|
39
|
-
|
|
40
|
-
const notifications = ref([]);
|
|
41
|
-
const notifyPositionStyles = ref({});
|
|
42
|
-
|
|
43
|
-
const notificationsWrapperRef = ref(null);
|
|
44
|
-
|
|
45
|
-
const i18nGlobal = tm(UNotify);
|
|
46
|
-
const currentLocale = computed(() => merge(defaultConfig.i18n, i18nGlobal, props.config.i18n));
|
|
53
|
+
} = useAttrs(props, { notifications });
|
|
47
54
|
|
|
48
55
|
onMounted(() => {
|
|
49
56
|
window.addEventListener("resize", setPosition, { passive: true });
|
|
@@ -61,11 +68,11 @@ onBeforeUnmount(() => {
|
|
|
61
68
|
window.removeEventListener("notifyClearAll", onClearAll);
|
|
62
69
|
});
|
|
63
70
|
|
|
64
|
-
function onNotifyStart(event) {
|
|
71
|
+
function onNotifyStart(event: NotifyEvent) {
|
|
65
72
|
notifications.value.push({ ...event.detail });
|
|
66
73
|
}
|
|
67
74
|
|
|
68
|
-
function onNotifyEnd(event) {
|
|
75
|
+
function onNotifyEnd(event: NotifyEvent) {
|
|
69
76
|
notifications.value = notifications.value.filter(
|
|
70
77
|
(notification) => notification.id !== event.detail.id,
|
|
71
78
|
);
|
|
@@ -75,25 +82,27 @@ function onClearAll() {
|
|
|
75
82
|
notifications.value = [];
|
|
76
83
|
}
|
|
77
84
|
|
|
78
|
-
function onClickClose(targetNotification) {
|
|
85
|
+
function onClickClose(targetNotification: Notification) {
|
|
79
86
|
notifications.value = notifications.value.filter(
|
|
80
87
|
(notification) => notification.id !== targetNotification.id,
|
|
81
88
|
);
|
|
82
89
|
}
|
|
83
90
|
|
|
84
|
-
function getOffsetWidth(selector) {
|
|
85
|
-
|
|
91
|
+
function getOffsetWidth(selector: string): number {
|
|
92
|
+
const element = document.querySelector(selector);
|
|
93
|
+
|
|
94
|
+
return element ? (element as HTMLElement).offsetWidth : 0;
|
|
86
95
|
}
|
|
87
96
|
|
|
88
97
|
function setPosition() {
|
|
89
98
|
const positionClasses = vuelessConfig.component?.UNotify?.positionClasses;
|
|
90
|
-
const pageClass = positionClasses?.page || config.value
|
|
91
|
-
const asideClass = positionClasses?.aside || config.value
|
|
99
|
+
const pageClass = positionClasses?.page || config.value?.positionClasses?.page;
|
|
100
|
+
const asideClass = positionClasses?.aside || config.value?.positionClasses?.aside;
|
|
92
101
|
const pageWidth = getOffsetWidth(`${pageClass}`);
|
|
93
102
|
const asideWidth = getOffsetWidth(`${asideClass}`);
|
|
94
|
-
const notifyWidth = notificationsWrapperRef.value
|
|
103
|
+
const notifyWidth = notificationsWrapperRef.value?.$el.offsetWidth || 0;
|
|
95
104
|
|
|
96
|
-
const styles = {
|
|
105
|
+
const styles: Record<string, string> = {
|
|
97
106
|
left: "auto",
|
|
98
107
|
top: "auto",
|
|
99
108
|
right: "auto",
|
|
@@ -115,23 +124,9 @@ function setPosition() {
|
|
|
115
124
|
notifyPositionStyles.value = styles;
|
|
116
125
|
}
|
|
117
126
|
|
|
118
|
-
function getText(notificationText, type) {
|
|
127
|
+
function getText(notificationText: string, type: NotificationType): string {
|
|
119
128
|
return notificationText || currentLocale.value[type]?.default;
|
|
120
129
|
}
|
|
121
|
-
|
|
122
|
-
function getNotificationClasses(notification) {
|
|
123
|
-
if (notification.type === NOTIFY_TYPE.success) {
|
|
124
|
-
return cx([bodyAttrs.value.class, config.value.bodySuccess]);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
if (notification.type === NOTIFY_TYPE.warning) {
|
|
128
|
-
return cx([bodyAttrs.value.class, config.value.bodyWarning]);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
if (notification.type === NOTIFY_TYPE.error) {
|
|
132
|
-
return cx([bodyAttrs.value.class, config.value.bodyError]);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
130
|
</script>
|
|
136
131
|
|
|
137
132
|
<template>
|
|
@@ -139,21 +134,16 @@ function getNotificationClasses(notification) {
|
|
|
139
134
|
ref="notificationsWrapperRef"
|
|
140
135
|
:style="notifyPositionStyles"
|
|
141
136
|
tag="div"
|
|
142
|
-
v-bind="{ ...config
|
|
137
|
+
v-bind="{ ...config?.transitionGroup, ...wrapperAttrs }"
|
|
143
138
|
>
|
|
144
|
-
<div
|
|
145
|
-
v-for="notification in notifications"
|
|
146
|
-
:key="notification.id"
|
|
147
|
-
v-bind="bodyAttrs"
|
|
148
|
-
:class="getNotificationClasses(notification)"
|
|
149
|
-
>
|
|
139
|
+
<div v-for="notification in notifications" :key="notification.id" v-bind="bodyAttrs">
|
|
150
140
|
<UIcon
|
|
151
141
|
v-if="notification.type === NOTIFY_TYPE.success"
|
|
152
142
|
color="green"
|
|
153
143
|
variant="light"
|
|
154
144
|
size="md"
|
|
155
145
|
internal
|
|
156
|
-
:name="config.defaults
|
|
146
|
+
:name="config.defaults?.successIcon"
|
|
157
147
|
v-bind="successIconAttrs"
|
|
158
148
|
data-test="type-notify"
|
|
159
149
|
/>
|
|
@@ -164,7 +154,7 @@ function getNotificationClasses(notification) {
|
|
|
164
154
|
variant="light"
|
|
165
155
|
size="md"
|
|
166
156
|
internal
|
|
167
|
-
:name="config.defaults
|
|
157
|
+
:name="config.defaults?.warningIcon"
|
|
168
158
|
v-bind="warningIconAttrs"
|
|
169
159
|
data-test="type-notify"
|
|
170
160
|
/>
|
|
@@ -176,7 +166,7 @@ function getNotificationClasses(notification) {
|
|
|
176
166
|
variant="light"
|
|
177
167
|
size="md"
|
|
178
168
|
internal
|
|
179
|
-
:name="config.defaults
|
|
169
|
+
:name="config.defaults?.errorIcon"
|
|
180
170
|
v-bind="errorIconAttrs"
|
|
181
171
|
/>
|
|
182
172
|
|
|
@@ -204,7 +194,7 @@ function getNotificationClasses(notification) {
|
|
|
204
194
|
size="xs"
|
|
205
195
|
internal
|
|
206
196
|
interactive
|
|
207
|
-
:name="config.defaults
|
|
197
|
+
:name="config.defaults?.closeIcon"
|
|
208
198
|
v-bind="closeIconAttrs"
|
|
209
199
|
@click="onClickClose(notification)"
|
|
210
200
|
/>
|
package/ui.text-notify/types.ts
CHANGED
|
@@ -2,6 +2,30 @@ import defaultConfig from "./config.ts";
|
|
|
2
2
|
|
|
3
3
|
export type Config = Partial<typeof defaultConfig>;
|
|
4
4
|
|
|
5
|
+
export type NotificationType = "success" | "warning" | "error";
|
|
6
|
+
|
|
7
|
+
export type Notification = {
|
|
8
|
+
id: string;
|
|
9
|
+
type: NotificationType;
|
|
10
|
+
label: string;
|
|
11
|
+
description: string;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export interface NotifyEvent extends Event {
|
|
15
|
+
detail: Notification;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface NotificationsWrapperRef {
|
|
19
|
+
$el: HTMLElement;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
declare global {
|
|
23
|
+
interface WindowEventMap {
|
|
24
|
+
notifyStart: NotifyEvent;
|
|
25
|
+
notifyEnd: NotifyEvent;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
5
29
|
export interface UNotifyProps {
|
|
6
30
|
/**
|
|
7
31
|
* A position on the x-axis.
|