vueless 0.0.579 → 0.0.580
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/composables/useUI.ts +46 -60
- package/constants.js +3 -0
- package/package.json +1 -1
- package/types.ts +39 -48
- package/ui.button/UButton.vue +2 -3
- package/ui.button/types.ts +2 -2
- package/ui.button-link/ULink.vue +23 -24
- package/ui.button-link/storybook/stories.ts +2 -2
- package/ui.button-link/types.ts +7 -6
- package/ui.button-toggle/UToggle.vue +15 -16
- package/ui.button-toggle/storybook/stories.ts +2 -2
- package/ui.button-toggle/types.ts +6 -4
- package/ui.button-toggle-item/UToggleItem.vue +29 -20
- package/ui.button-toggle-item/storybook/stories.ts +2 -2
- package/ui.button-toggle-item/types.ts +5 -4
- package/ui.container-accordion/UAccordion.vue +22 -17
- package/ui.container-accordion/storybook/stories.ts +2 -2
- package/ui.container-accordion/types.ts +5 -4
- package/ui.container-card/UCard.vue +12 -5
- package/ui.container-card/storybook/stories.ts +2 -2
- package/ui.container-card/types.ts +4 -3
- package/ui.container-col/UCol.vue +11 -12
- package/ui.container-col/storybook/stories.ts +2 -2
- package/ui.container-col/types.ts +5 -3
- package/ui.container-divider/UDivider.vue +13 -13
- package/ui.container-divider/storybook/stories.ts +2 -2
- package/ui.container-divider/types.ts +5 -3
- package/ui.container-group/UGroup.vue +10 -8
- package/ui.container-group/storybook/stories.ts +2 -2
- package/ui.container-group/types.ts +5 -3
- package/ui.container-groups/UGroups.vue +10 -7
- package/ui.container-groups/storybook/stories.ts +2 -2
- package/ui.container-groups/types.ts +5 -3
- package/ui.container-modal/UModal.vue +43 -43
- package/ui.container-modal/storybook/stories.ts +2 -3
- package/ui.container-modal/types.ts +5 -3
- package/ui.container-modal-confirm/UModalConfirm.vue +14 -17
- package/ui.container-modal-confirm/storybook/stories.ts +8 -6
- package/ui.container-modal-confirm/types.ts +5 -3
- package/ui.container-page/UPage.vue +32 -31
- package/ui.container-page/storybook/stories.ts +2 -2
- package/ui.container-page/types.ts +4 -3
- package/ui.container-row/URow.vue +10 -13
- package/ui.container-row/storybook/stories.ts +2 -2
- package/ui.container-row/types.ts +5 -3
- package/ui.data-list/UDataList.vue +40 -51
- package/ui.data-list/storybook/stories.ts +2 -2
- package/ui.data-list/types.ts +4 -4
- package/ui.data-table/UTable.vue +61 -60
- package/ui.data-table/types.ts +4 -3
- package/ui.dropdown-badge/UDropdownBadge.vue +21 -25
- package/ui.dropdown-badge/storybook/stories.ts +3 -3
- package/ui.dropdown-badge/types.ts +4 -3
- package/ui.dropdown-button/UDropdownButton.vue +20 -23
- package/ui.dropdown-button/storybook/stories.ts +3 -3
- package/ui.dropdown-button/types.ts +4 -3
- package/ui.dropdown-link/UDropdownLink.vue +20 -23
- package/ui.dropdown-link/storybook/stories.ts +3 -3
- package/ui.dropdown-link/types.ts +4 -3
- package/ui.dropdown-list/UDropdownList.vue +28 -32
- package/ui.dropdown-list/storybook/stories.ts +4 -4
- package/ui.dropdown-list/types.ts +4 -4
- package/ui.form-calendar/UCalendar.vue +36 -34
- package/ui.form-calendar/UCalendarDayView.vue +28 -23
- package/ui.form-calendar/UCalendarMonthView.vue +24 -19
- package/ui.form-calendar/UCalendarYearView.vue +24 -19
- package/ui.form-calendar/config.ts +2 -2
- package/ui.form-calendar/storybook/stories.ts +2 -2
- package/ui.form-calendar/types.ts +8 -7
- package/ui.form-checkbox/UCheckbox.vue +23 -21
- package/ui.form-checkbox/storybook/stories.ts +2 -2
- package/ui.form-checkbox/types.ts +7 -5
- package/ui.form-checkbox-group/UCheckboxGroup.vue +17 -14
- package/ui.form-checkbox-group/storybook/stories.ts +2 -2
- package/ui.form-checkbox-group/types.ts +6 -6
- package/ui.form-checkbox-multi-state/UCheckboxMultiState.vue +33 -14
- package/ui.form-checkbox-multi-state/storybook/stories.ts +2 -2
- package/ui.form-checkbox-multi-state/types.ts +4 -4
- package/ui.form-color-picker/UColorPicker.vue +23 -21
- package/ui.form-color-picker/storybook/stories.ts +2 -2
- package/ui.form-color-picker/types.ts +5 -5
- package/ui.form-date-picker/UDatePicker.vue +42 -27
- package/ui.form-date-picker/config.ts +5 -5
- package/ui.form-date-picker/types.ts +5 -2
- package/ui.form-date-picker-range/UDatePickerRange.vue +80 -53
- package/ui.form-date-picker-range/types.ts +7 -4
- package/ui.form-input/UInput.vue +32 -28
- package/ui.form-input/storybook/stories.ts +2 -2
- package/ui.form-input/types.ts +5 -3
- package/ui.form-input-file/UInputFile.vue +37 -32
- package/ui.form-input-file/storybook/stories.ts +2 -2
- package/ui.form-input-file/types.ts +6 -4
- package/ui.form-input-money/UInputMoney.vue +13 -18
- package/ui.form-input-money/storybook/stories.ts +2 -2
- package/ui.form-input-money/types.ts +5 -3
- package/ui.form-input-number/UInputNumber.vue +23 -24
- package/ui.form-input-number/types.ts +4 -2
- package/ui.form-input-rating/UInputRating.vue +24 -19
- package/ui.form-input-rating/storybook/stories.ts +2 -2
- package/ui.form-input-rating/types.ts +5 -3
- package/ui.form-input-search/UInputSearch.vue +22 -20
- package/ui.form-input-search/storybook/stories.ts +2 -2
- package/ui.form-input-search/types.ts +5 -3
- package/ui.form-label/ULabel.vue +19 -11
- package/ui.form-label/config.ts +0 -1
- package/ui.form-label/storybook/stories.ts +2 -2
- package/ui.form-label/types.ts +10 -8
- package/ui.form-radio/URadio.vue +22 -12
- package/ui.form-radio/storybook/stories.ts +2 -2
- package/ui.form-radio/types.ts +5 -5
- package/ui.form-radio-group/URadioGroup.vue +16 -12
- package/ui.form-radio-group/storybook/stories.ts +2 -2
- package/ui.form-radio-group/types.ts +7 -7
- package/ui.form-select/USelect.vue +53 -39
- package/ui.form-switch/USwitch.vue +30 -23
- package/ui.form-switch/storybook/stories.ts +2 -2
- package/ui.form-switch/types.ts +5 -3
- package/ui.form-textarea/UTextarea.vue +19 -15
- package/ui.form-textarea/storybook/stories.ts +2 -2
- package/ui.form-textarea/types.ts +5 -3
- package/ui.image-avatar/UAvatar.vue +12 -11
- package/ui.image-avatar/types.ts +4 -2
- package/ui.image-icon/UIcon.vue +31 -18
- package/ui.image-icon/storybook/stories.ts +2 -2
- package/ui.image-icon/types.ts +12 -5
- package/ui.loader/ULoader.vue +11 -9
- package/ui.loader/storybook/stories.ts +2 -2
- package/ui.loader/types.ts +10 -3
- package/ui.loader-overlay/ULoaderOverlay.vue +11 -7
- package/ui.loader-overlay/storybook/stories.ts +2 -2
- package/ui.loader-overlay/types.ts +4 -3
- package/ui.loader-progress/ULoaderProgress.vue +14 -10
- package/ui.loader-progress/storybook/stories.ts +2 -2
- package/ui.loader-progress/types.ts +4 -3
- package/ui.navigation-pagination/UPagination.vue +34 -33
- package/ui.navigation-pagination/storybook/stories.ts +2 -2
- package/ui.navigation-pagination/types.ts +4 -3
- package/ui.navigation-progress/StepperProgress.vue +25 -12
- package/ui.navigation-progress/UProgress.vue +12 -12
- package/ui.navigation-progress/types.ts +4 -3
- package/ui.navigation-tab/UTab.vue +18 -9
- package/ui.navigation-tab/storybook/stories.ts +2 -2
- package/ui.navigation-tab/types.ts +4 -3
- package/ui.navigation-tabs/UTabs.vue +13 -8
- package/ui.navigation-tabs/storybook/stories.ts +2 -2
- package/ui.navigation-tabs/types.ts +5 -5
- package/ui.other-dot/UDot.vue +10 -8
- package/ui.other-dot/storybook/stories.ts +2 -2
- package/ui.other-dot/types.ts +4 -3
- package/ui.text-alert/UAlert.vue +24 -27
- package/ui.text-alert/storybook/stories.ts +2 -2
- package/ui.text-alert/types.ts +4 -3
- package/ui.text-badge/UBadge.vue +25 -13
- package/ui.text-badge/storybook/stories.ts +2 -2
- package/ui.text-badge/types.ts +4 -3
- package/ui.text-block/UText.vue +10 -9
- package/ui.text-block/storybook/stories.ts +2 -2
- package/ui.text-block/types.ts +4 -3
- package/ui.text-empty/UEmpty.vue +22 -19
- package/ui.text-empty/storybook/stories.ts +2 -2
- package/ui.text-empty/types.ts +4 -3
- package/ui.text-file/UFile.vue +23 -20
- package/ui.text-file/storybook/stories.ts +2 -2
- package/ui.text-file/types.ts +4 -3
- package/ui.text-files/UFiles.vue +16 -10
- package/ui.text-files/storybook/stories.ts +2 -2
- package/ui.text-files/types.ts +4 -3
- package/ui.text-header/UHeader.vue +11 -11
- package/ui.text-header/storybook/stories.ts +2 -2
- package/ui.text-header/types.ts +4 -3
- package/ui.text-money/UMoney.vue +20 -27
- package/ui.text-money/storybook/stories.ts +2 -2
- package/ui.text-money/types.ts +4 -3
- package/ui.text-notify/UNotify.vue +58 -41
- package/ui.text-notify/config.ts +3 -3
- package/ui.text-notify/constants.ts +18 -20
- package/ui.text-notify/storybook/stories.ts +2 -2
- package/ui.text-notify/types.ts +10 -5
- package/ui.text-notify/utilNotify.ts +17 -11
- package/utils/helper.ts +5 -5
- package/utils/storybook.ts +11 -1
- package/utils/ui.ts +19 -9
- package/web-types.json +521 -368
- package/ui.button-link/useAttrs.ts +0 -20
- package/ui.button-toggle/useAttrs.ts +0 -12
- package/ui.button-toggle-item/useAttrs.ts +0 -29
- package/ui.container-accordion/useAttrs.ts +0 -26
- package/ui.container-card/useAttrs.ts +0 -12
- package/ui.container-col/useAttrs.ts +0 -12
- package/ui.container-divider/useAttrs.ts +0 -17
- package/ui.container-group/useAttrs.ts +0 -12
- package/ui.container-groups/useAttrs.ts +0 -12
- package/ui.container-modal/useAttrs.ts +0 -12
- package/ui.container-modal-confirm/useAttrs.ts +0 -12
- package/ui.container-page/useAttrs.ts +0 -12
- package/ui.container-row/useAttrs.ts +0 -12
- package/ui.data-list/useAttrs.ts +0 -12
- package/ui.data-table/useAttrs.ts +0 -31
- package/ui.dropdown-badge/useAttrs.ts +0 -26
- package/ui.dropdown-button/useAttrs.ts +0 -26
- package/ui.dropdown-link/useAttrs.ts +0 -26
- package/ui.dropdown-list/useAttrs.ts +0 -12
- package/ui.form-calendar/useAttrs.ts +0 -12
- package/ui.form-checkbox/useAttrs.ts +0 -29
- package/ui.form-checkbox-group/useAttrs.ts +0 -12
- package/ui.form-checkbox-multi-state/useAttrs.ts +0 -37
- package/ui.form-color-picker/useAttrs.ts +0 -15
- package/ui.form-date-picker/useAttrs.ts +0 -43
- package/ui.form-date-picker-range/useAttrs.ts +0 -53
- package/ui.form-input/useAttrs.ts +0 -31
- package/ui.form-input-file/useAttrs.ts +0 -21
- package/ui.form-input-money/useAttrs.ts +0 -15
- package/ui.form-input-number/useAttrs.ts +0 -15
- package/ui.form-input-rating/useAttrs.ts +0 -14
- package/ui.form-input-search/useAttrs.ts +0 -15
- package/ui.form-label/useAttrs.ts +0 -20
- package/ui.form-radio/useAttrs.ts +0 -29
- package/ui.form-radio-group/useAttrs.ts +0 -12
- package/ui.form-select/useAttrs.js +0 -19
- package/ui.form-switch/useAttrs.ts +0 -28
- package/ui.form-textarea/useAttrs.ts +0 -21
- package/ui.image-avatar/useAttrs.ts +0 -12
- package/ui.image-icon/useAttrs.ts +0 -12
- package/ui.loader/useAttrs.ts +0 -12
- package/ui.loader-overlay/useAttrs.ts +0 -12
- package/ui.loader-progress/useAttrs.ts +0 -12
- package/ui.navigation-pagination/useAttrs.ts +0 -12
- package/ui.navigation-progress/useAttrs.ts +0 -17
- package/ui.navigation-tab/useAttrs.ts +0 -28
- package/ui.navigation-tabs/useAttrs.ts +0 -12
- package/ui.other-dot/useAttrs.ts +0 -12
- package/ui.text-alert/useAttrs.ts +0 -12
- package/ui.text-badge/useAttrs.ts +0 -21
- package/ui.text-block/useAttrs.ts +0 -12
- package/ui.text-empty/useAttrs.ts +0 -12
- package/ui.text-file/useAttrs.ts +0 -12
- package/ui.text-files/useAttrs.ts +0 -12
- package/ui.text-header/useAttrs.ts +0 -12
- package/ui.text-money/useAttrs.ts +0 -12
- package/ui.text-notify/useAttrs.ts +0 -12
|
@@ -2,31 +2,22 @@
|
|
|
2
2
|
import { computed, onBeforeUnmount, onMounted, ref } from "vue";
|
|
3
3
|
import { merge } from "lodash-es";
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import useUI from "../composables/useUI.ts";
|
|
6
|
+
import { getDefaults, vuelessConfig } from "../utils/ui.ts";
|
|
6
7
|
import { useLocale } from "../composables/useLocale.ts";
|
|
7
|
-
import useAttrs from "./useAttrs.ts";
|
|
8
8
|
|
|
9
9
|
import defaultConfig from "./config.ts";
|
|
10
|
-
import { UNotify,
|
|
10
|
+
import { UNotify, NotificationType, NotificationPosition } from "./constants.ts";
|
|
11
11
|
|
|
12
12
|
import UIcon from "../ui.image-icon/UIcon.vue";
|
|
13
13
|
|
|
14
|
-
import type {
|
|
15
|
-
|
|
16
|
-
Notification,
|
|
17
|
-
NotifyEvent,
|
|
18
|
-
NotificationsWrapperRef,
|
|
19
|
-
NotificationType,
|
|
20
|
-
} from "./types.ts";
|
|
14
|
+
import type { Props, Config, NotifyEvent, Notification, NotificationsWrapperRef } from "./types.ts";
|
|
15
|
+
import type { Transition } from "../types.ts";
|
|
21
16
|
|
|
22
17
|
defineOptions({ inheritAttrs: false });
|
|
23
18
|
|
|
24
|
-
const props = withDefaults(defineProps<
|
|
25
|
-
|
|
26
|
-
yPosition: getDefault<UNotifyProps>(defaultConfig, UNotify).yPosition,
|
|
27
|
-
html: getDefault<UNotifyProps>(defaultConfig, UNotify).html,
|
|
28
|
-
dataTest: "",
|
|
29
|
-
config: () => ({}),
|
|
19
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
20
|
+
...getDefaults<Props, Config>(defaultConfig, UNotify),
|
|
30
21
|
});
|
|
31
22
|
|
|
32
23
|
const { tm } = useLocale();
|
|
@@ -39,19 +30,6 @@ const notificationsWrapperRef = ref<NotificationsWrapperRef | null>(null);
|
|
|
39
30
|
const i18nGlobal = tm(UNotify);
|
|
40
31
|
const currentLocale = computed(() => merge(defaultConfig.i18n, i18nGlobal, props.config.i18n));
|
|
41
32
|
|
|
42
|
-
const {
|
|
43
|
-
config,
|
|
44
|
-
wrapperAttrs,
|
|
45
|
-
bodyAttrs,
|
|
46
|
-
contentAttrs,
|
|
47
|
-
labelAttrs,
|
|
48
|
-
descriptionAttrs,
|
|
49
|
-
successIconAttrs,
|
|
50
|
-
warningIconAttrs,
|
|
51
|
-
errorIconAttrs,
|
|
52
|
-
closeIconAttrs,
|
|
53
|
-
} = useAttrs(props, { notifications });
|
|
54
|
-
|
|
55
33
|
onMounted(() => {
|
|
56
34
|
window.addEventListener("resize", setPosition, { passive: true });
|
|
57
35
|
window.addEventListener("notifyStart", onNotifyStart);
|
|
@@ -111,22 +89,55 @@ function setPosition() {
|
|
|
111
89
|
|
|
112
90
|
styles[props.yPosition] = "0px";
|
|
113
91
|
|
|
114
|
-
if (props.xPosition ===
|
|
92
|
+
if (props.xPosition === NotificationPosition.Center) {
|
|
115
93
|
styles.left = `calc(50% - ${notifyWidth / 2}px)`;
|
|
116
94
|
} else {
|
|
117
95
|
styles[props.xPosition] = "0px";
|
|
118
96
|
}
|
|
119
97
|
|
|
120
|
-
if (pageWidth && props.xPosition !==
|
|
98
|
+
if (pageWidth && props.xPosition !== NotificationPosition.Right) {
|
|
121
99
|
styles.left = `${asideWidth + pageWidth / 2 - notifyWidth / 2}px`;
|
|
122
100
|
}
|
|
123
101
|
|
|
124
102
|
notifyPositionStyles.value = styles;
|
|
125
103
|
}
|
|
126
104
|
|
|
127
|
-
function getText(notificationText: string, type:
|
|
105
|
+
function getText(notificationText: string, type: Notification["type"]): string {
|
|
128
106
|
return notificationText || currentLocale.value[type]?.default;
|
|
129
107
|
}
|
|
108
|
+
|
|
109
|
+
function getBodyAttrs(type: Notification["type"]) {
|
|
110
|
+
if (type === NotificationType.Success) {
|
|
111
|
+
return bodySuccessAttrs.value;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (type === NotificationType.Warning) {
|
|
115
|
+
return bodyWarningAttrs.value;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (type === NotificationType.Error) {
|
|
119
|
+
return bodyErrorAttrs.value;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Get element / nested component attributes for each config token ✨
|
|
125
|
+
* Applies: `class`, `config`, redefined default `props` and dev `vl-...` attributes.
|
|
126
|
+
*/
|
|
127
|
+
const {
|
|
128
|
+
config,
|
|
129
|
+
wrapperAttrs,
|
|
130
|
+
bodySuccessAttrs,
|
|
131
|
+
bodyWarningAttrs,
|
|
132
|
+
bodyErrorAttrs,
|
|
133
|
+
contentAttrs,
|
|
134
|
+
labelAttrs,
|
|
135
|
+
descriptionAttrs,
|
|
136
|
+
successIconAttrs,
|
|
137
|
+
warningIconAttrs,
|
|
138
|
+
errorIconAttrs,
|
|
139
|
+
closeIconAttrs,
|
|
140
|
+
} = useUI<Config>(defaultConfig);
|
|
130
141
|
</script>
|
|
131
142
|
|
|
132
143
|
<template>
|
|
@@ -134,39 +145,44 @@ function getText(notificationText: string, type: NotificationType): string {
|
|
|
134
145
|
ref="notificationsWrapperRef"
|
|
135
146
|
:style="notifyPositionStyles"
|
|
136
147
|
tag="div"
|
|
137
|
-
v-bind="{ ...config?.transitionGroup, ...wrapperAttrs }"
|
|
148
|
+
v-bind="{ ...(config?.transitionGroup as Transition), ...wrapperAttrs }"
|
|
149
|
+
:data-test="dataTest"
|
|
138
150
|
>
|
|
139
|
-
<div
|
|
151
|
+
<div
|
|
152
|
+
v-for="notification in notifications"
|
|
153
|
+
:key="notification.id"
|
|
154
|
+
v-bind="getBodyAttrs(notification.type)"
|
|
155
|
+
>
|
|
140
156
|
<UIcon
|
|
141
|
-
v-if="notification.type ===
|
|
157
|
+
v-if="notification.type === NotificationType.Success"
|
|
142
158
|
color="green"
|
|
143
159
|
variant="light"
|
|
144
160
|
size="md"
|
|
145
161
|
internal
|
|
146
|
-
:name="config.defaults
|
|
162
|
+
:name="config.defaults.successIcon"
|
|
147
163
|
v-bind="successIconAttrs"
|
|
148
164
|
data-test="type-notify"
|
|
149
165
|
/>
|
|
150
166
|
|
|
151
167
|
<UIcon
|
|
152
|
-
v-else-if="notification.type ===
|
|
168
|
+
v-else-if="notification.type === NotificationType.Warning"
|
|
153
169
|
color="orange"
|
|
154
170
|
variant="light"
|
|
155
171
|
size="md"
|
|
156
172
|
internal
|
|
157
|
-
:name="config.defaults
|
|
173
|
+
:name="config.defaults.warningIcon"
|
|
158
174
|
v-bind="warningIconAttrs"
|
|
159
175
|
data-test="type-notify"
|
|
160
176
|
/>
|
|
161
177
|
|
|
162
178
|
<UIcon
|
|
163
|
-
v-else-if="notification.type ===
|
|
179
|
+
v-else-if="notification.type === NotificationType.Error"
|
|
164
180
|
data-test="type-notify"
|
|
165
181
|
color="red"
|
|
166
182
|
variant="light"
|
|
167
183
|
size="md"
|
|
168
184
|
internal
|
|
169
|
-
:name="config.defaults
|
|
185
|
+
:name="config.defaults.errorIcon"
|
|
170
186
|
v-bind="errorIconAttrs"
|
|
171
187
|
/>
|
|
172
188
|
|
|
@@ -194,8 +210,9 @@ function getText(notificationText: string, type: NotificationType): string {
|
|
|
194
210
|
size="xs"
|
|
195
211
|
internal
|
|
196
212
|
interactive
|
|
197
|
-
:name="config.defaults
|
|
213
|
+
:name="config.defaults.closeIcon"
|
|
198
214
|
v-bind="closeIconAttrs"
|
|
215
|
+
:data-test="`${dataTest}-close`"
|
|
199
216
|
@click="onClickClose(notification)"
|
|
200
217
|
/>
|
|
201
218
|
</div>
|
package/ui.text-notify/config.ts
CHANGED
|
@@ -11,9 +11,9 @@ export default /*tw*/ {
|
|
|
11
11
|
mb-3 flex w-full items-center justify-center gap-3 rounded-2xl bg-gray-900/90
|
|
12
12
|
p-4 shadow-[0_4px_16px_rgba(17,24,39,0.5)] backdrop-blur-md md:shadow-[0_0px_12px_rgba(0,0,0,0.25)]
|
|
13
13
|
`,
|
|
14
|
-
bodySuccess: "bg-[radial-gradient(100.16%_500.78%_at_0%_50%,rgba(74,222,128,0.1)_2.17%,transparent)]",
|
|
15
|
-
bodyWarning: "bg-[radial-gradient(100.16%_500.78%_at_0%_50%,rgba(251,146,60,0.2)_2.17%,transparent)]",
|
|
16
|
-
bodyError: "bg-[radial-gradient(100.16%_500.78%_at_0%_50%,rgba(251,113,133,0.2)_2.17%,transparent)]",
|
|
14
|
+
bodySuccess: "{>body} bg-[radial-gradient(100.16%_500.78%_at_0%_50%,rgba(74,222,128,0.1)_2.17%,transparent)]",
|
|
15
|
+
bodyWarning: "{>body} bg-[radial-gradient(100.16%_500.78%_at_0%_50%,rgba(251,146,60,0.2)_2.17%,transparent)]",
|
|
16
|
+
bodyError: "{>body} bg-[radial-gradient(100.16%_500.78%_at_0%_50%,rgba(251,113,133,0.2)_2.17%,transparent)]",
|
|
17
17
|
content: "w-full flex flex-col max-w-full text-sm text-gray-200",
|
|
18
18
|
label: "mb-0.5 font-medium",
|
|
19
19
|
description: "break-words font-normal",
|
|
@@ -3,27 +3,25 @@
|
|
|
3
3
|
`defineProps` is referencing locally declared variables. (vue/valid-define-props)
|
|
4
4
|
*/
|
|
5
5
|
export const UNotify = "UNotify";
|
|
6
|
-
|
|
7
6
|
export const LOCAL_STORAGE_ID = "vueless:notify";
|
|
7
|
+
export const DELAY_BETWEEN_CLONES = 1000;
|
|
8
8
|
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export const POSITION = {
|
|
16
|
-
left: "left",
|
|
17
|
-
right: "right",
|
|
18
|
-
top: "top",
|
|
19
|
-
bottom: "bottom",
|
|
20
|
-
center: "center",
|
|
21
|
-
};
|
|
9
|
+
export enum NotificationType {
|
|
10
|
+
Success = "success",
|
|
11
|
+
Warning = "warning",
|
|
12
|
+
Error = "error",
|
|
13
|
+
}
|
|
22
14
|
|
|
23
|
-
export
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
15
|
+
export enum NotificationPosition {
|
|
16
|
+
Left = "left",
|
|
17
|
+
Right = "right",
|
|
18
|
+
Top = "top",
|
|
19
|
+
Bottom = "bottom",
|
|
20
|
+
Center = "center",
|
|
21
|
+
}
|
|
28
22
|
|
|
29
|
-
export
|
|
23
|
+
export enum NotificationDuration {
|
|
24
|
+
Short = 4000,
|
|
25
|
+
Medium = 8000,
|
|
26
|
+
Long = 12000,
|
|
27
|
+
}
|
|
@@ -12,9 +12,9 @@ import UButton from "../../ui.button/UButton.vue";
|
|
|
12
12
|
import UCol from "../../ui.container-col/UCol.vue";
|
|
13
13
|
|
|
14
14
|
import type { Meta, StoryFn } from "@storybook/vue3";
|
|
15
|
-
import type {
|
|
15
|
+
import type { Props } from "../types.ts";
|
|
16
16
|
|
|
17
|
-
interface UNotifyArgs extends
|
|
17
|
+
interface UNotifyArgs extends Props {
|
|
18
18
|
slotTemplate?: string;
|
|
19
19
|
}
|
|
20
20
|
|
package/ui.text-notify/types.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import defaultConfig from "./config.ts";
|
|
2
|
+
import type { ComponentConfig } from "../types.ts";
|
|
3
|
+
import { NotificationType } from "./constants.ts";
|
|
2
4
|
|
|
3
|
-
export type Config =
|
|
4
|
-
|
|
5
|
-
export type NotificationType = "success" | "warning" | "error";
|
|
5
|
+
export type Config = typeof defaultConfig;
|
|
6
6
|
|
|
7
7
|
export type Notification = {
|
|
8
8
|
id: string;
|
|
@@ -26,7 +26,7 @@ declare global {
|
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
export interface
|
|
29
|
+
export interface Props {
|
|
30
30
|
/**
|
|
31
31
|
* A position on the x-axis.
|
|
32
32
|
*/
|
|
@@ -45,5 +45,10 @@ export interface UNotifyProps {
|
|
|
45
45
|
/**
|
|
46
46
|
* Component config object.
|
|
47
47
|
*/
|
|
48
|
-
config?: Config
|
|
48
|
+
config?: ComponentConfig<Config>;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Data-test attribute for automated testing.
|
|
52
|
+
*/
|
|
53
|
+
dataTest?: string;
|
|
49
54
|
}
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { vuelessConfig } from "../utils/ui.ts";
|
|
2
2
|
import { getRandomId } from "../utils/helper.ts";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
LOCAL_STORAGE_ID,
|
|
5
|
+
DELAY_BETWEEN_CLONES,
|
|
6
|
+
NotificationDuration,
|
|
7
|
+
NotificationType,
|
|
8
|
+
} from "./constants.ts";
|
|
4
9
|
|
|
5
10
|
interface NotifyConfig {
|
|
6
|
-
type?:
|
|
11
|
+
type?: NotificationType;
|
|
7
12
|
label?: string;
|
|
8
13
|
description?: string;
|
|
9
14
|
duration?: number;
|
|
@@ -11,7 +16,7 @@ interface NotifyConfig {
|
|
|
11
16
|
}
|
|
12
17
|
|
|
13
18
|
interface NotifyEventDetail {
|
|
14
|
-
type:
|
|
19
|
+
type: NotificationType;
|
|
15
20
|
id: string;
|
|
16
21
|
label: string;
|
|
17
22
|
description: string;
|
|
@@ -39,7 +44,8 @@ export function notify({
|
|
|
39
44
|
duration,
|
|
40
45
|
ignoreDuplicates,
|
|
41
46
|
}: NotifyConfig = {}): void {
|
|
42
|
-
const notifyDuration: number =
|
|
47
|
+
const notifyDuration: number =
|
|
48
|
+
duration || globalNotifyDuration?.short || NotificationDuration.Short;
|
|
43
49
|
|
|
44
50
|
const isSameMessage = Boolean(
|
|
45
51
|
lastMessage === description &&
|
|
@@ -55,7 +61,7 @@ export function notify({
|
|
|
55
61
|
lastMessage = description;
|
|
56
62
|
|
|
57
63
|
const eventDetail: NotifyEventDetail = {
|
|
58
|
-
type: type as
|
|
64
|
+
type: type as NotificationType,
|
|
59
65
|
id: getRandomId(),
|
|
60
66
|
label,
|
|
61
67
|
description,
|
|
@@ -84,8 +90,8 @@ export function notifySuccess({
|
|
|
84
90
|
label,
|
|
85
91
|
description,
|
|
86
92
|
ignoreDuplicates,
|
|
87
|
-
type:
|
|
88
|
-
duration: duration || globalNotifyDuration?.short ||
|
|
93
|
+
type: NotificationType.Success,
|
|
94
|
+
duration: duration || globalNotifyDuration?.short || NotificationDuration.Short,
|
|
89
95
|
});
|
|
90
96
|
}
|
|
91
97
|
|
|
@@ -99,8 +105,8 @@ export function notifyWarning({
|
|
|
99
105
|
label,
|
|
100
106
|
description,
|
|
101
107
|
ignoreDuplicates,
|
|
102
|
-
type:
|
|
103
|
-
duration: duration || globalNotifyDuration?.medium ||
|
|
108
|
+
type: NotificationType.Warning,
|
|
109
|
+
duration: duration || globalNotifyDuration?.medium || NotificationDuration.Medium,
|
|
104
110
|
});
|
|
105
111
|
}
|
|
106
112
|
|
|
@@ -114,8 +120,8 @@ export function notifyError({
|
|
|
114
120
|
label,
|
|
115
121
|
description,
|
|
116
122
|
ignoreDuplicates,
|
|
117
|
-
type:
|
|
118
|
-
duration: duration || globalNotifyDuration?.long ||
|
|
123
|
+
type: NotificationType.Error,
|
|
124
|
+
duration: duration || globalNotifyDuration?.long || NotificationDuration.Long,
|
|
119
125
|
});
|
|
120
126
|
}
|
|
121
127
|
|
package/utils/helper.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { UnknownObject } from "../types.ts";
|
|
1
2
|
import { Comment, Text, Fragment } from "vue";
|
|
2
3
|
|
|
3
4
|
import type { Slot, VNode } from "vue";
|
|
@@ -5,7 +6,7 @@ import type { Slot, VNode } from "vue";
|
|
|
5
6
|
/**
|
|
6
7
|
* Deeply clone given object (same as lodash.cloneDeep).
|
|
7
8
|
*/
|
|
8
|
-
export function cloneDeep(entity: unknown, cache = new WeakMap()): unknown {
|
|
9
|
+
export function cloneDeep(entity: unknown, cache = new WeakMap()): unknown | UnknownObject {
|
|
9
10
|
// primitives
|
|
10
11
|
if (Object(entity) !== entity || !entity) {
|
|
11
12
|
return entity;
|
|
@@ -42,13 +43,12 @@ export function cloneDeep(entity: unknown, cache = new WeakMap()): unknown {
|
|
|
42
43
|
/**
|
|
43
44
|
* Creates a debounced function with delay (same as lodash.debounce).
|
|
44
45
|
*/
|
|
45
|
-
export function createDebounce(func: () => void, ms: number) {
|
|
46
|
+
export function createDebounce<T extends unknown[]>(func: (...args: T) => void, ms: number) {
|
|
46
47
|
let timeout: ReturnType<typeof setTimeout>;
|
|
47
48
|
|
|
48
|
-
return function (...args:
|
|
49
|
+
return function (this: unknown, ...args: T) {
|
|
49
50
|
clearTimeout(timeout);
|
|
50
|
-
|
|
51
|
-
timeout = setTimeout(() => func.apply(this as unknown, args), ms);
|
|
51
|
+
timeout = setTimeout(() => func.apply(this, args), ms);
|
|
52
52
|
};
|
|
53
53
|
}
|
|
54
54
|
|
package/utils/storybook.ts
CHANGED
|
@@ -14,7 +14,7 @@ interface Types {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
export interface ArgType {
|
|
17
|
-
control?: "text" | "date" | "number" | "boolean" | "array" | "select" | false;
|
|
17
|
+
control?: "text" | "date" | "number" | "boolean" | "array" | "select" | "object" | false;
|
|
18
18
|
options?: string[];
|
|
19
19
|
table?: TableConfig;
|
|
20
20
|
name?: string;
|
|
@@ -113,6 +113,16 @@ export function getArgTypes(componentName: string | undefined) {
|
|
|
113
113
|
};
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
+
if (attribute.enum?.length === 1) {
|
|
117
|
+
types[attribute.name] = {
|
|
118
|
+
control: "object",
|
|
119
|
+
table: {
|
|
120
|
+
defaultValue: { summary: attribute.default || "" },
|
|
121
|
+
type: { summary: attribute.enum.join(" | ") },
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
|
|
116
126
|
if (type === "string" || type.includes("string")) {
|
|
117
127
|
types[attribute.name] = {
|
|
118
128
|
control: "text",
|
package/utils/ui.ts
CHANGED
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
GRAYSCALE_COLOR,
|
|
9
9
|
DEFAULT_BRAND_COLOR,
|
|
10
10
|
TAILWIND_MERGE_EXTENSION,
|
|
11
|
+
SYSTEM_NON_PROPS_DEFAULTS,
|
|
11
12
|
NESTED_COMPONENT_PATTERN_REG_EXP,
|
|
12
13
|
} from "../constants.js";
|
|
13
14
|
|
|
@@ -21,13 +22,13 @@ import type {
|
|
|
21
22
|
} from "../types.ts";
|
|
22
23
|
|
|
23
24
|
interface MergedConfigOptions {
|
|
24
|
-
defaultConfig:
|
|
25
|
-
globalConfig:
|
|
26
|
-
propsConfig?:
|
|
25
|
+
defaultConfig: unknown;
|
|
26
|
+
globalConfig: unknown;
|
|
27
|
+
propsConfig?: unknown;
|
|
27
28
|
vuelessStrategy?: Strategies;
|
|
28
29
|
}
|
|
29
30
|
|
|
30
|
-
type
|
|
31
|
+
type GetMergedConfig = (options: MergedConfigOptions) => unknown;
|
|
31
32
|
|
|
32
33
|
/**
|
|
33
34
|
* Load Vueless config from the project root.
|
|
@@ -82,7 +83,7 @@ export const {
|
|
|
82
83
|
},
|
|
83
84
|
});
|
|
84
85
|
|
|
85
|
-
export const getMergedConfig = createGetMergedConfig(cx) as
|
|
86
|
+
export const getMergedConfig = createGetMergedConfig(cx) as GetMergedConfig;
|
|
86
87
|
|
|
87
88
|
/* This allows skipping some CVA config keys in vueless config. */
|
|
88
89
|
export const cva = ({ base = "", variants = {}, compoundVariants = [], defaultVariants = {} }) =>
|
|
@@ -111,23 +112,32 @@ export function getDefault<T>(defaultConfig: Component, name: ComponentNames) {
|
|
|
111
112
|
return {
|
|
112
113
|
...defaults,
|
|
113
114
|
dataTest: "",
|
|
114
|
-
config: () => {},
|
|
115
|
+
config: () => ({}),
|
|
115
116
|
};
|
|
116
117
|
}
|
|
117
118
|
|
|
118
119
|
/**
|
|
119
120
|
* Return default values for component props, icons, etc..
|
|
120
121
|
*/
|
|
121
|
-
export function getDefaults<
|
|
122
|
-
const componentDefaults = cloneDeep(defaultConfig.defaults) || {};
|
|
122
|
+
export function getDefaults<Props, Config>(defaultConfig: Config, name: ComponentNames) {
|
|
123
|
+
const componentDefaults = cloneDeep((defaultConfig as Component).defaults) || {};
|
|
123
124
|
const globalDefaults = cloneDeep(vuelessConfig.component?.[name]?.defaults) || {};
|
|
124
125
|
|
|
125
|
-
const defaults = merge(componentDefaults, globalDefaults) as
|
|
126
|
+
const defaults = merge(componentDefaults, globalDefaults) as Props & Defaults;
|
|
126
127
|
|
|
127
128
|
if (defaults.color) {
|
|
128
129
|
defaults.color = getColor(defaults.color as BrandColors);
|
|
129
130
|
}
|
|
130
131
|
|
|
132
|
+
/* Remove non a props defaults. */
|
|
133
|
+
for (const key in defaults) {
|
|
134
|
+
const isNonPropIcon = /Icon/.test(key) && !/(leftIcon|rightIcon)/.test(key);
|
|
135
|
+
|
|
136
|
+
if (SYSTEM_NON_PROPS_DEFAULTS.includes(key) || isNonPropIcon) {
|
|
137
|
+
delete defaults[key];
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
131
141
|
return {
|
|
132
142
|
...defaults,
|
|
133
143
|
dataTest: "",
|