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
|
@@ -1,24 +1,21 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { computed } from "vue";
|
|
3
3
|
|
|
4
|
+
import useUI from "../composables/useUI.ts";
|
|
5
|
+
import { getDefaults } from "../utils/ui.ts";
|
|
6
|
+
|
|
4
7
|
import UIcon from "../ui.image-icon/UIcon.vue";
|
|
5
|
-
import { getDefault } from "../utils/ui.ts";
|
|
6
8
|
|
|
7
9
|
import { UAvatar } from "./constants.ts";
|
|
8
10
|
import defaultConfig from "./config.ts";
|
|
9
|
-
import useAttrs from "./useAttrs.ts";
|
|
10
11
|
|
|
11
|
-
import type { UAvatarProps } from "./types.ts";
|
|
12
|
+
import type { UAvatarProps, Config } from "./types.ts";
|
|
12
13
|
|
|
13
14
|
defineOptions({ inheritAttrs: false });
|
|
14
15
|
|
|
15
16
|
const props = withDefaults(defineProps<UAvatarProps>(), {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
color: getDefault<UAvatarProps>(defaultConfig, UAvatar).color,
|
|
19
|
-
rounded: getDefault<UAvatarProps>(defaultConfig, UAvatar).rounded,
|
|
20
|
-
bordered: getDefault<UAvatarProps>(defaultConfig, UAvatar).bordered,
|
|
21
|
-
dataTest: "",
|
|
17
|
+
...getDefaults<UAvatarProps, Config>(defaultConfig, UAvatar),
|
|
18
|
+
label: "",
|
|
22
19
|
});
|
|
23
20
|
|
|
24
21
|
const emit = defineEmits([
|
|
@@ -28,8 +25,6 @@ const emit = defineEmits([
|
|
|
28
25
|
"click",
|
|
29
26
|
]);
|
|
30
27
|
|
|
31
|
-
const { avatarAttrs, placeholderIconAttrs } = useAttrs(props);
|
|
32
|
-
|
|
33
28
|
const labelFirstLetters = computed(() => {
|
|
34
29
|
if (!props.label) return "";
|
|
35
30
|
|
|
@@ -55,6 +50,12 @@ const componentColor = computed(() => {
|
|
|
55
50
|
function onClick(event: MouseEvent) {
|
|
56
51
|
emit("click", event);
|
|
57
52
|
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Get element / nested component attributes for each config token ✨
|
|
56
|
+
* Applies: `class`, `config`, redefined default `props` and dev `vl-...` attributes.
|
|
57
|
+
*/
|
|
58
|
+
const { avatarAttrs, placeholderIconAttrs } = useUI<Config>(defaultConfig);
|
|
58
59
|
</script>
|
|
59
60
|
|
|
60
61
|
<template>
|
package/ui.image-avatar/types.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import defaultConfig from "./config.ts";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import type { ComponentConfig } from "../types.ts";
|
|
4
|
+
|
|
5
|
+
export type Config = typeof defaultConfig;
|
|
4
6
|
|
|
5
7
|
export interface UAvatarProps {
|
|
6
8
|
/**
|
|
@@ -62,7 +64,7 @@ export interface UAvatarProps {
|
|
|
62
64
|
/**
|
|
63
65
|
* Component config object.
|
|
64
66
|
*/
|
|
65
|
-
config?: Config
|
|
67
|
+
config?: ComponentConfig<Config>;
|
|
66
68
|
|
|
67
69
|
/**
|
|
68
70
|
* Data-test attribute for automated testing.
|
package/ui.image-icon/UIcon.vue
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { computed, defineAsyncComponent } from "vue";
|
|
3
|
+
|
|
4
|
+
import useUI from "../composables/useUI.ts";
|
|
3
5
|
import { vTooltip } from "../directives";
|
|
4
|
-
import {
|
|
6
|
+
import { getDefaults } from "../utils/ui.ts";
|
|
5
7
|
import { isSSR } from "../utils/helper.ts";
|
|
6
8
|
import { VUELESS_ICONS_CACHED_DIR, VUELESS_LIBRARY } from "../constants.js";
|
|
7
9
|
|
|
8
10
|
import { UIcon } from "./constants.ts";
|
|
9
11
|
import defaultConfig from "./config.ts";
|
|
10
|
-
import useAttrs from "./useAttrs.ts";
|
|
11
12
|
|
|
12
|
-
import type {
|
|
13
|
+
import type { AsyncComponentLoader } from "vue";
|
|
14
|
+
import type { Props, Config, IconLibraries } from "./types.ts";
|
|
15
|
+
import type { Props as TippyProps, Instance as TippyInstance } from "tippy.js";
|
|
13
16
|
|
|
14
17
|
defineOptions({ inheritAttrs: false });
|
|
15
18
|
|
|
16
|
-
const props = withDefaults(defineProps<
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
variant: getDefault<UIconProps>(defaultConfig, UIcon).variant,
|
|
20
|
-
interactive: getDefault<UIconProps>(defaultConfig, UIcon).interactive,
|
|
21
|
-
dataTest: "",
|
|
19
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
20
|
+
...getDefaults<Props, Config>(defaultConfig, UIcon),
|
|
21
|
+
tooltipSettings: () => ({}) as TippyProps,
|
|
22
22
|
});
|
|
23
23
|
|
|
24
24
|
const emit = defineEmits([
|
|
@@ -28,8 +28,6 @@ const emit = defineEmits([
|
|
|
28
28
|
"click",
|
|
29
29
|
]);
|
|
30
30
|
|
|
31
|
-
const { config, iconAttrs } = useAttrs(props);
|
|
32
|
-
|
|
33
31
|
const generatedIcons = computed(() => {
|
|
34
32
|
return (
|
|
35
33
|
Object.entries(
|
|
@@ -48,10 +46,11 @@ const dynamicComponent = computed(() => {
|
|
|
48
46
|
generatedIcons.value.find(([path]) => path.includes(VUELESS_LIBRARY + "/" + props.name)),
|
|
49
47
|
);
|
|
50
48
|
|
|
51
|
-
const userLibrary = config.value
|
|
49
|
+
const userLibrary = config.value.defaults.library as IconLibraries;
|
|
50
|
+
|
|
52
51
|
const library = props.internal && isInternalIcon ? VUELESS_LIBRARY : userLibrary;
|
|
53
|
-
const weight = config.value
|
|
54
|
-
const style = config.value
|
|
52
|
+
const weight = config.value.defaults.weight;
|
|
53
|
+
const style = config.value.defaults.style;
|
|
55
54
|
const isFill = props.name?.endsWith(FILL_SUFFIX);
|
|
56
55
|
const name = props.name;
|
|
57
56
|
const src = props.src;
|
|
@@ -60,12 +59,14 @@ const dynamicComponent = computed(() => {
|
|
|
60
59
|
if (!src && !name) return "";
|
|
61
60
|
|
|
62
61
|
/* Static import */
|
|
63
|
-
if (src)
|
|
62
|
+
if (src?.render) {
|
|
63
|
+
return src.render({}, {});
|
|
64
|
+
}
|
|
64
65
|
|
|
65
66
|
/* Dynamic import */
|
|
66
67
|
if (!name) return "";
|
|
67
68
|
|
|
68
|
-
function getIcon(params:
|
|
69
|
+
function getIcon(params: (string | number)[]) {
|
|
69
70
|
const [, component] =
|
|
70
71
|
generatedIcons.value.find(([path]) =>
|
|
71
72
|
params.every(
|
|
@@ -111,18 +112,30 @@ const dynamicComponent = computed(() => {
|
|
|
111
112
|
};
|
|
112
113
|
/* eslint-enable prettier/prettier */
|
|
113
114
|
|
|
114
|
-
return defineAsyncComponent(libraries[library]);
|
|
115
|
+
return defineAsyncComponent(libraries[library] as AsyncComponentLoader);
|
|
115
116
|
});
|
|
116
117
|
|
|
117
118
|
const tooltipConfig = computed(() => ({
|
|
118
|
-
onShow: () => !!props.tooltip,
|
|
119
119
|
...props.tooltipSettings,
|
|
120
120
|
content: props.tooltip,
|
|
121
|
+
onShow: (instance: TippyInstance) => {
|
|
122
|
+
const userOnShow = props.tooltipSettings?.onShow;
|
|
123
|
+
|
|
124
|
+
userOnShow && userOnShow(instance);
|
|
125
|
+
|
|
126
|
+
return !!props.tooltip;
|
|
127
|
+
},
|
|
121
128
|
}));
|
|
122
129
|
|
|
123
130
|
function onClick(event: MouseEvent) {
|
|
124
131
|
emit("click", event);
|
|
125
132
|
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Get element / nested component attributes for each config token ✨
|
|
136
|
+
* Applies: `class`, `config`, redefined default `props` and dev `vl-...` attributes.
|
|
137
|
+
*/
|
|
138
|
+
const { config, iconAttrs } = useUI<Config>(defaultConfig);
|
|
126
139
|
</script>
|
|
127
140
|
|
|
128
141
|
<template>
|
|
@@ -9,9 +9,9 @@ import UIcon from "../../ui.image-icon/UIcon.vue";
|
|
|
9
9
|
import URow from "../../ui.container-row/URow.vue";
|
|
10
10
|
|
|
11
11
|
import type { Meta, StoryFn } from "@storybook/vue3";
|
|
12
|
-
import type {
|
|
12
|
+
import type { Props } from "../types.ts";
|
|
13
13
|
|
|
14
|
-
interface UIconArgs extends
|
|
14
|
+
interface UIconArgs extends Props {
|
|
15
15
|
slotTemplate?: string;
|
|
16
16
|
enum: "color" | "size" | "variant";
|
|
17
17
|
}
|
package/ui.image-icon/types.ts
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
import defaultConfig from "./config.ts";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import type { DefineComponent, SVGAttributes } from "vue";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
import type { ComponentConfig } from "../types.ts";
|
|
6
|
+
import type { Props as TippyProps } from "tippy.js";
|
|
7
|
+
|
|
8
|
+
export type Config = typeof defaultConfig;
|
|
9
|
+
|
|
10
|
+
export type IconLibraries = "vueless" | "@material-symbols" | "bootstrap-icons" | "heroicons";
|
|
11
|
+
|
|
12
|
+
export interface Props {
|
|
6
13
|
/**
|
|
7
14
|
* Icon name.
|
|
8
15
|
*/
|
|
@@ -11,7 +18,7 @@ export interface UIconProps {
|
|
|
11
18
|
/**
|
|
12
19
|
* Icon source (svg as a vue component).
|
|
13
20
|
*/
|
|
14
|
-
src?:
|
|
21
|
+
src?: DefineComponent<SVGAttributes>;
|
|
15
22
|
|
|
16
23
|
/**
|
|
17
24
|
* Icon color.
|
|
@@ -64,7 +71,7 @@ export interface UIconProps {
|
|
|
64
71
|
* Tooltip settings.
|
|
65
72
|
* [See all settings here](https://kabbouchi.github.io/vue-tippy/4.0/features/placement.html).
|
|
66
73
|
*/
|
|
67
|
-
tooltipSettings?:
|
|
74
|
+
tooltipSettings?: TippyProps;
|
|
68
75
|
|
|
69
76
|
/**
|
|
70
77
|
* Mark that Icon used inside Vueless components (used to get icons from vueless library).
|
|
@@ -74,7 +81,7 @@ export interface UIconProps {
|
|
|
74
81
|
/**
|
|
75
82
|
* Component config object.
|
|
76
83
|
*/
|
|
77
|
-
config?: Config
|
|
84
|
+
config?: ComponentConfig<Config>;
|
|
78
85
|
|
|
79
86
|
/**
|
|
80
87
|
* Data-test attribute for automated testing.
|
package/ui.loader/ULoader.vue
CHANGED
|
@@ -1,26 +1,28 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import
|
|
2
|
+
import useUI from "../composables/useUI.ts";
|
|
3
|
+
import { getDefaults } from "../utils/ui.ts";
|
|
3
4
|
|
|
4
5
|
import { ULoader, ELLIPSES_AMOUNT } from "./constants.ts";
|
|
5
6
|
import defaultConfig from "./config.ts";
|
|
6
|
-
import useAttrs from "./useAttrs.ts";
|
|
7
7
|
|
|
8
|
-
import type {
|
|
8
|
+
import type { Props, Config } from "./types.ts";
|
|
9
9
|
|
|
10
10
|
defineOptions({ inheritAttrs: false });
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
color: getDefault<ULoaderProps>(defaultConfig, ULoader).color,
|
|
15
|
-
size: getDefault<ULoaderProps>(defaultConfig, ULoader).size,
|
|
12
|
+
withDefaults(defineProps<Props>(), {
|
|
13
|
+
...getDefaults<Props, Config>(defaultConfig, ULoader),
|
|
16
14
|
});
|
|
17
15
|
|
|
18
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Get element / nested component attributes for each config token ✨
|
|
18
|
+
* Applies: `class`, `config`, redefined default `props` and dev `vl-...` attributes.
|
|
19
|
+
*/
|
|
20
|
+
const { loaderAttrs, ellipseAttrs, config } = useUI<Config>(defaultConfig);
|
|
19
21
|
</script>
|
|
20
22
|
|
|
21
23
|
<template>
|
|
22
24
|
<Transition v-bind="config?.transition">
|
|
23
|
-
<div v-if="loading" v-bind="loaderAttrs">
|
|
25
|
+
<div v-if="loading" v-bind="loaderAttrs" :data-test="dataTest">
|
|
24
26
|
<!-- @slot Use it to add something instead of the default loader. -->
|
|
25
27
|
<slot>
|
|
26
28
|
<div v-for="ellipse in ELLIPSES_AMOUNT" :key="ellipse" v-bind="ellipseAttrs" />
|
|
@@ -11,9 +11,9 @@ import UButton from "../../ui.button/UButton.vue";
|
|
|
11
11
|
import { ref } from "vue";
|
|
12
12
|
|
|
13
13
|
import type { Meta, StoryFn } from "@storybook/vue3";
|
|
14
|
-
import type {
|
|
14
|
+
import type { Props } from "../types.ts";
|
|
15
15
|
|
|
16
|
-
interface ULoaderArgs extends
|
|
16
|
+
interface ULoaderArgs extends Props {
|
|
17
17
|
slotTemplate?: string;
|
|
18
18
|
enum: "size" | "color";
|
|
19
19
|
}
|
package/ui.loader/types.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import defaultConfig from "./config.ts";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import type { ComponentConfig } from "../types.ts";
|
|
4
4
|
|
|
5
|
-
export
|
|
5
|
+
export type Config = typeof defaultConfig;
|
|
6
|
+
|
|
7
|
+
export interface Props {
|
|
6
8
|
/**
|
|
7
9
|
* Loader state (shown / hidden).
|
|
8
10
|
*/
|
|
@@ -43,5 +45,10 @@ export interface ULoaderProps {
|
|
|
43
45
|
/**
|
|
44
46
|
* Component config object.
|
|
45
47
|
*/
|
|
46
|
-
config?: Config
|
|
48
|
+
config?: ComponentConfig<Config>;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Data-test attribute for automated testing.
|
|
52
|
+
*/
|
|
53
|
+
dataTest?: string;
|
|
47
54
|
}
|
|
@@ -1,26 +1,24 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { computed, onMounted, onUnmounted } from "vue";
|
|
3
3
|
|
|
4
|
-
import
|
|
4
|
+
import useUI from "../composables/useUI.ts";
|
|
5
|
+
import { getDefaults } from "../utils/ui.ts";
|
|
5
6
|
import { useDarkMode } from "../composables/useDarkMode.ts";
|
|
6
7
|
|
|
7
8
|
import ULoader from "../ui.loader/ULoader.vue";
|
|
8
9
|
|
|
9
10
|
import { ULoaderOverlay } from "./constants.ts";
|
|
10
11
|
import defaultConfig from "./config.ts";
|
|
11
|
-
import useAttrs from "./useAttrs.ts";
|
|
12
12
|
import { useLoaderOverlay } from "./useLoaderOverlay.ts";
|
|
13
13
|
|
|
14
|
-
import type {
|
|
14
|
+
import type { Props, Config } from "./types.ts";
|
|
15
15
|
|
|
16
16
|
defineOptions({ inheritAttrs: false });
|
|
17
17
|
|
|
18
|
-
const props = withDefaults(defineProps<
|
|
19
|
-
|
|
20
|
-
color: getDefault<ULoaderOverlayProps>(defaultConfig, ULoaderOverlay).color,
|
|
18
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
19
|
+
...getDefaults<Props, Config>(defaultConfig, ULoaderOverlay),
|
|
21
20
|
});
|
|
22
21
|
|
|
23
|
-
const { overlayAttrs, nestedLoaderAttrs, config } = useAttrs(props);
|
|
24
22
|
const { loaderOverlayOn, loaderOverlayOff, isLoading } = useLoaderOverlay();
|
|
25
23
|
const { isDarkMode } = useDarkMode();
|
|
26
24
|
|
|
@@ -44,6 +42,12 @@ onUnmounted(() => {
|
|
|
44
42
|
const showLoader = computed(() => {
|
|
45
43
|
return props.loading === undefined ? (isLoading.value ?? false) : props.loading;
|
|
46
44
|
});
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Get element / nested component attributes for each config token ✨
|
|
48
|
+
* Applies: `class`, `config`, redefined default `props` and dev `vl-...` attributes.
|
|
49
|
+
*/
|
|
50
|
+
const { overlayAttrs, nestedLoaderAttrs, config } = useUI<Config>(defaultConfig);
|
|
47
51
|
</script>
|
|
48
52
|
|
|
49
53
|
<template>
|
|
@@ -12,9 +12,9 @@ import UCol from "../../ui.container-col/UCol.vue";
|
|
|
12
12
|
import { useLoaderOverlay } from "../useLoaderOverlay.ts";
|
|
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 ULoaderOverlayArgs extends
|
|
17
|
+
interface ULoaderOverlayArgs extends Props {
|
|
18
18
|
slotTemplate?: string;
|
|
19
19
|
}
|
|
20
20
|
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import defaultConfig from "./config.ts";
|
|
2
|
+
import type { ComponentConfig } from "../types.ts";
|
|
2
3
|
|
|
3
|
-
export type Config =
|
|
4
|
+
export type Config = typeof defaultConfig;
|
|
4
5
|
|
|
5
|
-
export interface
|
|
6
|
+
export interface Props {
|
|
6
7
|
/**
|
|
7
8
|
* Loader state (shown / hidden).
|
|
8
9
|
*/
|
|
@@ -38,5 +39,5 @@ export interface ULoaderOverlayProps {
|
|
|
38
39
|
/**
|
|
39
40
|
* Component config object.
|
|
40
41
|
*/
|
|
41
|
-
config?: Config
|
|
42
|
+
config?: ComponentConfig<Config>;
|
|
42
43
|
}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { computed, onBeforeUnmount, watch, ref, onMounted, onUnmounted } from "vue";
|
|
3
3
|
|
|
4
|
-
import
|
|
4
|
+
import useUI from "../composables/useUI.ts";
|
|
5
|
+
import { getDefaults } from "../utils/ui.ts";
|
|
6
|
+
|
|
5
7
|
import { clamp, queue, getRequestWithoutQuery } from "./utilLoaderProgress.ts";
|
|
6
8
|
import { useLoaderProgress } from "./useLoaderProgress.ts";
|
|
7
|
-
import useAttrs from "./useAttrs.ts";
|
|
8
9
|
|
|
9
10
|
import { ULoaderProgress, MAXIMUM, SPEED, INFINITY_LOADING } from "./constants.ts";
|
|
10
11
|
import defaultConfig from "./config.ts";
|
|
11
12
|
|
|
12
|
-
import type {
|
|
13
|
+
import type { Props, Config } from "./types.ts";
|
|
13
14
|
|
|
14
15
|
defineOptions({ inheritAttrs: false });
|
|
15
16
|
|
|
16
|
-
const props = withDefaults(defineProps<
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
loading: getDefault<ULoaderProgressProps>(defaultConfig, ULoaderProgress).loading,
|
|
17
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
18
|
+
...getDefaults<Props, Config>(defaultConfig, ULoaderProgress),
|
|
19
|
+
resources: () => [],
|
|
20
20
|
});
|
|
21
21
|
|
|
22
22
|
const error = ref(false);
|
|
@@ -34,8 +34,6 @@ const {
|
|
|
34
34
|
addRequestUrl,
|
|
35
35
|
} = useLoaderProgress();
|
|
36
36
|
|
|
37
|
-
const { stripeAttrs } = useAttrs(props);
|
|
38
|
-
|
|
39
37
|
const isStarted = computed(() => {
|
|
40
38
|
return typeof status.value === "number";
|
|
41
39
|
});
|
|
@@ -101,7 +99,7 @@ function setLoaderOffHandler(event: CustomEvent<{ resource: string }>) {
|
|
|
101
99
|
function onChangeRequestsQueue() {
|
|
102
100
|
const isActiveRequests =
|
|
103
101
|
requestQueue.value.includes(INFINITY_LOADING) ||
|
|
104
|
-
resourceNamesArray.value.some((resource) => {
|
|
102
|
+
resourceNamesArray.value.some((resource: string) => {
|
|
105
103
|
return requestQueue.value.includes(resource);
|
|
106
104
|
});
|
|
107
105
|
|
|
@@ -205,6 +203,12 @@ function increase(amount?: number) {
|
|
|
205
203
|
function done() {
|
|
206
204
|
set(100);
|
|
207
205
|
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Get element / nested component attributes for each config token ✨
|
|
209
|
+
* Applies: `class`, `config`, redefined default `props` and dev `vl-...` attributes.
|
|
210
|
+
*/
|
|
211
|
+
const { stripeAttrs } = useUI<Config>(defaultConfig);
|
|
208
212
|
</script>
|
|
209
213
|
|
|
210
214
|
<template>
|
|
@@ -10,9 +10,9 @@ import { useLoaderProgress } from "../useLoaderProgress.ts";
|
|
|
10
10
|
import { loaderProgressOff, loaderProgressOn } from "../utilLoaderProgress.ts";
|
|
11
11
|
|
|
12
12
|
import type { Meta, StoryFn } from "@storybook/vue3";
|
|
13
|
-
import type {
|
|
13
|
+
import type { Props } from "../types.ts";
|
|
14
14
|
|
|
15
|
-
interface ULoaderProgressArgs extends
|
|
15
|
+
interface ULoaderProgressArgs extends Props {
|
|
16
16
|
slotTemplate?: string;
|
|
17
17
|
enum: "color";
|
|
18
18
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import defaultConfig from "./config.ts";
|
|
2
|
+
import type { ComponentConfig } from "../types.ts";
|
|
2
3
|
|
|
3
|
-
export type Config =
|
|
4
|
+
export type Config = typeof defaultConfig;
|
|
4
5
|
|
|
5
|
-
export interface
|
|
6
|
+
export interface Props {
|
|
6
7
|
/**
|
|
7
8
|
* Loader stripe color.
|
|
8
9
|
*/
|
|
@@ -47,5 +48,5 @@ export interface ULoaderProgressProps {
|
|
|
47
48
|
/**
|
|
48
49
|
* Component config object.
|
|
49
50
|
*/
|
|
50
|
-
config?: Config
|
|
51
|
+
config?: ComponentConfig<Config>;
|
|
51
52
|
}
|
|
@@ -2,29 +2,26 @@
|
|
|
2
2
|
import { computed } from "vue";
|
|
3
3
|
import { range } from "lodash-es";
|
|
4
4
|
|
|
5
|
+
import useUI from "../composables/useUI.ts";
|
|
6
|
+
import { getDefaults } from "../utils/ui.ts";
|
|
7
|
+
|
|
5
8
|
import UButton from "../ui.button/UButton.vue";
|
|
6
9
|
import UIcon from "../ui.image-icon/UIcon.vue";
|
|
7
|
-
import { getDefault } from "../utils/ui.ts";
|
|
8
10
|
|
|
9
11
|
import defaultConfig from "./config.ts";
|
|
10
12
|
import { UPagination } from "./constants.ts";
|
|
11
|
-
import useAttrs from "./useAttrs.ts";
|
|
12
13
|
|
|
13
|
-
import type {
|
|
14
|
+
import type { Props, ButtonSize, IconSize, Config } from "./types.ts";
|
|
14
15
|
|
|
15
16
|
defineOptions({ inheritAttrs: false });
|
|
16
17
|
|
|
17
|
-
const props = withDefaults(defineProps<
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
showFirst: getDefault<UPaginationProps>(defaultConfig, UPagination).showFirst,
|
|
25
|
-
showLast: getDefault<UPaginationProps>(defaultConfig, UPagination).showLast,
|
|
26
|
-
dataTest: "",
|
|
27
|
-
config: () => ({}),
|
|
18
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
19
|
+
...getDefaults<Props, Config>(defaultConfig, UPagination),
|
|
20
|
+
modelValue: 1,
|
|
21
|
+
firstLabel: "",
|
|
22
|
+
prevLabel: "",
|
|
23
|
+
nextLabel: "",
|
|
24
|
+
lastLabel: "",
|
|
28
25
|
});
|
|
29
26
|
|
|
30
27
|
const emit = defineEmits([
|
|
@@ -41,21 +38,6 @@ const emit = defineEmits([
|
|
|
41
38
|
"update:modelValue",
|
|
42
39
|
]);
|
|
43
40
|
|
|
44
|
-
const {
|
|
45
|
-
config,
|
|
46
|
-
paginationAttrs,
|
|
47
|
-
firstButtonAttrs,
|
|
48
|
-
lastButtonAttrs,
|
|
49
|
-
prevButtonAttrs,
|
|
50
|
-
nextButtonAttrs,
|
|
51
|
-
activeButtonAttrs,
|
|
52
|
-
inactiveButtonAttrs,
|
|
53
|
-
lastIconAttrs,
|
|
54
|
-
firstIconAttrs,
|
|
55
|
-
prevIconAttrs,
|
|
56
|
-
nextIconAttrs,
|
|
57
|
-
} = useAttrs(props);
|
|
58
|
-
|
|
59
41
|
const currentPage = computed({
|
|
60
42
|
get: () => props.modelValue,
|
|
61
43
|
set: (value) => {
|
|
@@ -137,6 +119,25 @@ function goToFirstPage() {
|
|
|
137
119
|
function goToLastPage() {
|
|
138
120
|
currentPage.value = totalPages.value;
|
|
139
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
|
+
paginationAttrs,
|
|
130
|
+
firstButtonAttrs,
|
|
131
|
+
lastButtonAttrs,
|
|
132
|
+
prevButtonAttrs,
|
|
133
|
+
nextButtonAttrs,
|
|
134
|
+
activeButtonAttrs,
|
|
135
|
+
inactiveButtonAttrs,
|
|
136
|
+
lastIconAttrs,
|
|
137
|
+
firstIconAttrs,
|
|
138
|
+
prevIconAttrs,
|
|
139
|
+
nextIconAttrs,
|
|
140
|
+
} = useUI<Config>(defaultConfig);
|
|
140
141
|
</script>
|
|
141
142
|
|
|
142
143
|
<template>
|
|
@@ -159,7 +160,7 @@ function goToLastPage() {
|
|
|
159
160
|
v-if="!firstLabel"
|
|
160
161
|
internal
|
|
161
162
|
:size="iconSize"
|
|
162
|
-
:name="config.defaults
|
|
163
|
+
:name="config.defaults.firstIcon"
|
|
163
164
|
v-bind="firstIconAttrs"
|
|
164
165
|
/>
|
|
165
166
|
</slot>
|
|
@@ -182,7 +183,7 @@ function goToLastPage() {
|
|
|
182
183
|
v-if="!prevLabel"
|
|
183
184
|
internal
|
|
184
185
|
:size="iconSize"
|
|
185
|
-
:name="config.defaults
|
|
186
|
+
:name="config.defaults.prevIcon"
|
|
186
187
|
v-bind="prevIconAttrs"
|
|
187
188
|
/>
|
|
188
189
|
</slot>
|
|
@@ -244,7 +245,7 @@ function goToLastPage() {
|
|
|
244
245
|
v-if="!nextLabel"
|
|
245
246
|
internal
|
|
246
247
|
:size="iconSize"
|
|
247
|
-
:name="config.defaults
|
|
248
|
+
:name="config.defaults.nextIcon"
|
|
248
249
|
v-bind="nextIconAttrs"
|
|
249
250
|
/>
|
|
250
251
|
</slot>
|
|
@@ -268,7 +269,7 @@ function goToLastPage() {
|
|
|
268
269
|
v-if="!lastLabel"
|
|
269
270
|
internal
|
|
270
271
|
:size="iconSize"
|
|
271
|
-
:name="config.defaults
|
|
272
|
+
:name="config.defaults.lastIcon"
|
|
272
273
|
v-bind="lastIconAttrs"
|
|
273
274
|
/>
|
|
274
275
|
</slot>
|
|
@@ -8,9 +8,9 @@ import {
|
|
|
8
8
|
import UPagination from "../../ui.navigation-pagination/UPagination.vue";
|
|
9
9
|
|
|
10
10
|
import type { Meta, StoryFn } from "@storybook/vue3";
|
|
11
|
-
import type {
|
|
11
|
+
import type { Props } from "../types.ts";
|
|
12
12
|
|
|
13
|
-
interface UPaginationArgs extends
|
|
13
|
+
interface UPaginationArgs extends Props {
|
|
14
14
|
slotTemplate?: string;
|
|
15
15
|
}
|
|
16
16
|
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import defaultConfig from "./config.ts";
|
|
2
|
+
import type { ComponentConfig } from "../types.ts";
|
|
2
3
|
|
|
3
|
-
export type Config =
|
|
4
|
+
export type Config = typeof defaultConfig;
|
|
4
5
|
|
|
5
6
|
export type ButtonSize = "xs" | "sm" | "md";
|
|
6
7
|
export type IconSize = "xs" | "sm" | "md";
|
|
7
8
|
|
|
8
|
-
export interface
|
|
9
|
+
export interface Props {
|
|
9
10
|
/**
|
|
10
11
|
* Current page number.
|
|
11
12
|
*/
|
|
@@ -79,7 +80,7 @@ export interface UPaginationProps {
|
|
|
79
80
|
/**
|
|
80
81
|
* Component config object.
|
|
81
82
|
*/
|
|
82
|
-
config?: Config
|
|
83
|
+
config?: ComponentConfig<Config>;
|
|
83
84
|
|
|
84
85
|
/**
|
|
85
86
|
* Data-test attribute for automated testing.
|