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
package/ui.form-radio/URadio.vue
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { computed, inject, onMounted, ref, watchEffect, toValue, useId } from "vue";
|
|
3
3
|
|
|
4
|
+
import useUI from "../composables/useUI.ts";
|
|
5
|
+
import { getDefaults } from "../utils/ui.ts";
|
|
6
|
+
|
|
4
7
|
import ULabel from "../ui.form-label/ULabel.vue";
|
|
5
|
-
import { getDefault } from "../utils/ui.ts";
|
|
6
8
|
|
|
7
9
|
import defaultConfig from "./config.ts";
|
|
8
|
-
import useAttrs from "./useAttrs.ts";
|
|
9
10
|
import { URadio } from "./constants.ts";
|
|
10
11
|
|
|
11
|
-
import type {
|
|
12
|
+
import type { Props, LocalValueType, Config } from "./types.ts";
|
|
12
13
|
import type { SetRadioGroupSelectedItem } from "../ui.form-radio-group/types.ts";
|
|
13
14
|
|
|
14
15
|
defineOptions({ inheritAttrs: false });
|
|
@@ -22,13 +23,11 @@ const getRadioGroupColor = inject("getRadioGroupColor", null);
|
|
|
22
23
|
const getRadioGroupSize = inject("getRadioGroupSize", null);
|
|
23
24
|
const getRadioGroupSelectedItem = inject("getRadioGroupSelectedItem", null);
|
|
24
25
|
|
|
25
|
-
const props = withDefaults(defineProps<
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
checked: getDefault<URadioProps>(defaultConfig, URadio).checked,
|
|
31
|
-
dataTest: "",
|
|
26
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
27
|
+
...getDefaults<Props, Config>(defaultConfig, URadio),
|
|
28
|
+
modelValue: () => ({}),
|
|
29
|
+
value: () => ({}),
|
|
30
|
+
label: "",
|
|
32
31
|
});
|
|
33
32
|
|
|
34
33
|
const emit = defineEmits([
|
|
@@ -56,8 +55,6 @@ const isChecked = computed(() => {
|
|
|
56
55
|
|
|
57
56
|
const elementId = props.id || useId();
|
|
58
57
|
|
|
59
|
-
const { radioAttrs, radioLabelAttrs } = useAttrs(props, { radioColor, radioSize });
|
|
60
|
-
|
|
61
58
|
const radioValue = computed(() => {
|
|
62
59
|
return props.value === "" ? "on" : props.value;
|
|
63
60
|
});
|
|
@@ -82,6 +79,19 @@ function onChange(event: Event) {
|
|
|
82
79
|
|
|
83
80
|
emit("update:modelValue", target.value);
|
|
84
81
|
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Get element / nested component attributes for each config token ✨
|
|
85
|
+
* Applies: `class`, `config`, redefined default `props` and dev `vl-...` attributes.
|
|
86
|
+
*/
|
|
87
|
+
const mutatedProps = computed(() => ({
|
|
88
|
+
color: radioColor.value,
|
|
89
|
+
size: radioSize.value,
|
|
90
|
+
label: Boolean(props.label),
|
|
91
|
+
error: Boolean(props.error),
|
|
92
|
+
}));
|
|
93
|
+
|
|
94
|
+
const { radioAttrs, radioLabelAttrs } = useUI<Config>(defaultConfig, mutatedProps);
|
|
85
95
|
</script>
|
|
86
96
|
|
|
87
97
|
<template>
|
|
@@ -9,9 +9,9 @@ import URadio from "../../ui.form-radio/URadio.vue";
|
|
|
9
9
|
import UBadge from "../../ui.text-badge/UBadge.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 URadioArgs extends
|
|
14
|
+
interface URadioArgs extends Props {
|
|
15
15
|
slotTemplate?: string;
|
|
16
16
|
enum: "variant" | "size";
|
|
17
17
|
}
|
package/ui.form-radio/types.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import defaultConfig from "./config.ts";
|
|
2
2
|
|
|
3
|
-
import type { UnknownObject, UnknownArray } from "../types.ts";
|
|
3
|
+
import type { UnknownObject, UnknownArray, ComponentConfig } from "../types.ts";
|
|
4
4
|
|
|
5
|
-
export type Config =
|
|
5
|
+
export type Config = typeof defaultConfig;
|
|
6
6
|
|
|
7
|
-
export type LocalValueType = string | number | boolean | UnknownObject | null;
|
|
7
|
+
export type LocalValueType = string | number | boolean | UnknownObject | UnknownArray | null;
|
|
8
8
|
|
|
9
|
-
export interface
|
|
9
|
+
export interface Props {
|
|
10
10
|
/**
|
|
11
11
|
* Radio value.
|
|
12
12
|
*/
|
|
@@ -90,7 +90,7 @@ export interface URadioProps {
|
|
|
90
90
|
/**
|
|
91
91
|
* Component config object.
|
|
92
92
|
*/
|
|
93
|
-
config?: Config
|
|
93
|
+
config?: ComponentConfig<Config>;
|
|
94
94
|
|
|
95
95
|
/**
|
|
96
96
|
* Data-test attribute for automated testing.
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { computed, provide } from "vue";
|
|
3
3
|
|
|
4
|
+
import useUI from "../composables/useUI.ts";
|
|
5
|
+
import { getDefaults } from "../utils/ui.ts";
|
|
6
|
+
|
|
4
7
|
import ULabel from "../ui.form-label/ULabel.vue";
|
|
5
8
|
import URadio from "../ui.form-radio/URadio.vue";
|
|
6
|
-
import { getDefault } from "../utils/ui.ts";
|
|
7
9
|
|
|
8
10
|
import defaultConfig from "./config.ts";
|
|
9
11
|
import { URadioGroup } from "./constants.ts";
|
|
10
|
-
import useAttrs from "./useAttrs.ts";
|
|
11
12
|
|
|
12
|
-
import type {
|
|
13
|
+
import type { Props, SetRadioGroupSelectedItem, Config } from "./types.ts";
|
|
13
14
|
|
|
14
15
|
defineOptions({ inheritAttrs: false });
|
|
15
16
|
|
|
16
|
-
const props = withDefaults(defineProps<
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
dataTest: "",
|
|
17
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
18
|
+
...getDefaults<Props, Config>(defaultConfig, URadioGroup),
|
|
19
|
+
modelValue: () => [],
|
|
20
|
+
options: () => [],
|
|
21
|
+
label: "",
|
|
22
22
|
});
|
|
23
23
|
|
|
24
24
|
const emit = defineEmits([
|
|
@@ -29,8 +29,6 @@ const emit = defineEmits([
|
|
|
29
29
|
"update:modelValue",
|
|
30
30
|
]);
|
|
31
31
|
|
|
32
|
-
const { groupLabelAttrs, listAttrs, groupRadioAttrs } = useAttrs(props);
|
|
33
|
-
|
|
34
32
|
const selectedItem = computed({
|
|
35
33
|
get: () => props.modelValue,
|
|
36
34
|
set: (value) => emit("update:modelValue", value),
|
|
@@ -43,6 +41,12 @@ provide("getRadioGroupSelectedItem", () => selectedItem.value);
|
|
|
43
41
|
provide("getRadioGroupName", () => props.name);
|
|
44
42
|
provide("getRadioGroupColor", () => props.color);
|
|
45
43
|
provide("getRadioGroupSize", () => props.size);
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Get element / nested component attributes for each config token ✨
|
|
47
|
+
* Applies: `class`, `config`, redefined default `props` and dev `vl-...` attributes.
|
|
48
|
+
*/
|
|
49
|
+
const { groupLabelAttrs, listAttrs, groupRadioAttrs } = useUI<Config>(defaultConfig);
|
|
46
50
|
</script>
|
|
47
51
|
|
|
48
52
|
<template>
|
|
@@ -61,7 +65,7 @@ provide("getRadioGroupSize", () => props.size);
|
|
|
61
65
|
<slot>
|
|
62
66
|
<URadio
|
|
63
67
|
v-for="(option, index) in options"
|
|
64
|
-
:key="
|
|
68
|
+
:key="index"
|
|
65
69
|
:model-value="selectedItem"
|
|
66
70
|
:value="option.value"
|
|
67
71
|
:label="option.label"
|
|
@@ -11,9 +11,9 @@ import UAlert from "../../ui.text-alert/UAlert.vue";
|
|
|
11
11
|
import UCol from "../../ui.container-col/UCol.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 URadioGroupArgs extends
|
|
16
|
+
interface URadioGroupArgs extends Props {
|
|
17
17
|
slotTemplate?: string;
|
|
18
18
|
enum: "size" | "color";
|
|
19
19
|
}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import defaultConfig from "./config.ts";
|
|
2
2
|
|
|
3
|
-
import type { UnknownObject, UnknownArray } from "../types.ts";
|
|
3
|
+
import type { UnknownObject, UnknownArray, ComponentConfig } from "../types.ts";
|
|
4
4
|
|
|
5
|
-
export type Config =
|
|
5
|
+
export type Config = typeof defaultConfig;
|
|
6
6
|
|
|
7
7
|
export interface URadioGroupOption {
|
|
8
|
-
value: string | number;
|
|
8
|
+
value: string | number | boolean | UnknownArray | UnknownObject;
|
|
9
9
|
label: string;
|
|
10
|
-
description
|
|
10
|
+
description?: string;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
export type SetRadioGroupSelectedItem =
|
|
14
14
|
| ((value: string | number | boolean | UnknownArray | UnknownObject) => void)
|
|
15
15
|
| null;
|
|
16
16
|
|
|
17
|
-
export interface
|
|
17
|
+
export interface Props {
|
|
18
18
|
/**
|
|
19
19
|
* Radio group selected value.
|
|
20
20
|
*/
|
|
@@ -23,7 +23,7 @@ export interface URadioGroupProps {
|
|
|
23
23
|
/**
|
|
24
24
|
* Radio group options.
|
|
25
25
|
*/
|
|
26
|
-
options?:
|
|
26
|
+
options?: URadioGroupOption[];
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
29
|
* Radio group label.
|
|
@@ -83,7 +83,7 @@ export interface URadioGroupProps {
|
|
|
83
83
|
/**
|
|
84
84
|
* Component config object.
|
|
85
85
|
*/
|
|
86
|
-
config?: Config
|
|
86
|
+
config?: ComponentConfig<Config>;
|
|
87
87
|
|
|
88
88
|
/**
|
|
89
89
|
* Data-test attribute for automated testing.
|
|
@@ -318,12 +318,12 @@ import UIcon from "../ui.image-icon/UIcon.vue";
|
|
|
318
318
|
import ULabel from "../ui.form-label/ULabel.vue";
|
|
319
319
|
import UDropdownList from "../ui.dropdown-list/UDropdownList.vue";
|
|
320
320
|
|
|
321
|
+
import useUI from "../composables/useUI.ts";
|
|
321
322
|
import { createDebounce, hasSlotContent } from "../utils/helper.ts";
|
|
322
|
-
import {
|
|
323
|
+
import { getDefaults } from "../utils/ui.ts";
|
|
323
324
|
import { isMac } from "../utils/platform.ts";
|
|
324
325
|
|
|
325
326
|
import SelectService from "./utilSelect.js";
|
|
326
|
-
import useAttrs from "./useAttrs.js";
|
|
327
327
|
import defaultConfig from "./config.js";
|
|
328
328
|
import { USelect, DIRECTION, KEY_CODES } from "./constants.js";
|
|
329
329
|
|
|
@@ -362,7 +362,7 @@ const props = defineProps({
|
|
|
362
362
|
*/
|
|
363
363
|
labelAlign: {
|
|
364
364
|
type: String,
|
|
365
|
-
default:
|
|
365
|
+
default: getDefaults(defaultConfig, USelect).labelAlign,
|
|
366
366
|
},
|
|
367
367
|
|
|
368
368
|
/**
|
|
@@ -395,7 +395,7 @@ const props = defineProps({
|
|
|
395
395
|
*/
|
|
396
396
|
size: {
|
|
397
397
|
type: String,
|
|
398
|
-
default:
|
|
398
|
+
default: getDefaults(defaultConfig, USelect).size,
|
|
399
399
|
},
|
|
400
400
|
|
|
401
401
|
/**
|
|
@@ -420,7 +420,7 @@ const props = defineProps({
|
|
|
420
420
|
*/
|
|
421
421
|
openDirection: {
|
|
422
422
|
type: String,
|
|
423
|
-
default:
|
|
423
|
+
default: getDefaults(defaultConfig, USelect).openDirection,
|
|
424
424
|
},
|
|
425
425
|
|
|
426
426
|
/**
|
|
@@ -428,7 +428,7 @@ const props = defineProps({
|
|
|
428
428
|
*/
|
|
429
429
|
labelKey: {
|
|
430
430
|
type: String,
|
|
431
|
-
default:
|
|
431
|
+
default: getDefaults(defaultConfig, USelect).labelKey,
|
|
432
432
|
},
|
|
433
433
|
|
|
434
434
|
/**
|
|
@@ -436,7 +436,7 @@ const props = defineProps({
|
|
|
436
436
|
*/
|
|
437
437
|
valueKey: {
|
|
438
438
|
type: String,
|
|
439
|
-
default:
|
|
439
|
+
default: getDefaults(defaultConfig, USelect).valueKey,
|
|
440
440
|
},
|
|
441
441
|
|
|
442
442
|
/**
|
|
@@ -460,7 +460,7 @@ const props = defineProps({
|
|
|
460
460
|
*/
|
|
461
461
|
optionsLimit: {
|
|
462
462
|
type: Number,
|
|
463
|
-
default:
|
|
463
|
+
default: getDefaults(defaultConfig, USelect).optionsLimit,
|
|
464
464
|
},
|
|
465
465
|
|
|
466
466
|
/**
|
|
@@ -468,7 +468,7 @@ const props = defineProps({
|
|
|
468
468
|
*/
|
|
469
469
|
visibleOptions: {
|
|
470
470
|
type: Number,
|
|
471
|
-
default:
|
|
471
|
+
default: getDefaults(defaultConfig, USelect).visibleOptions,
|
|
472
472
|
},
|
|
473
473
|
|
|
474
474
|
/**
|
|
@@ -476,7 +476,7 @@ const props = defineProps({
|
|
|
476
476
|
*/
|
|
477
477
|
clearable: {
|
|
478
478
|
type: Boolean,
|
|
479
|
-
default:
|
|
479
|
+
default: getDefaults(defaultConfig, USelect).clearable,
|
|
480
480
|
},
|
|
481
481
|
|
|
482
482
|
/**
|
|
@@ -484,7 +484,7 @@ const props = defineProps({
|
|
|
484
484
|
*/
|
|
485
485
|
multiple: {
|
|
486
486
|
type: Boolean,
|
|
487
|
-
default:
|
|
487
|
+
default: getDefaults(defaultConfig, USelect).multiple,
|
|
488
488
|
},
|
|
489
489
|
|
|
490
490
|
/**
|
|
@@ -492,7 +492,7 @@ const props = defineProps({
|
|
|
492
492
|
*/
|
|
493
493
|
searchable: {
|
|
494
494
|
type: Boolean,
|
|
495
|
-
default:
|
|
495
|
+
default: getDefaults(defaultConfig, USelect).searchable,
|
|
496
496
|
},
|
|
497
497
|
|
|
498
498
|
/**
|
|
@@ -500,7 +500,7 @@ const props = defineProps({
|
|
|
500
500
|
*/
|
|
501
501
|
disabled: {
|
|
502
502
|
type: Boolean,
|
|
503
|
-
default:
|
|
503
|
+
default: getDefaults(defaultConfig, USelect).disabled,
|
|
504
504
|
},
|
|
505
505
|
|
|
506
506
|
/**
|
|
@@ -508,7 +508,7 @@ const props = defineProps({
|
|
|
508
508
|
*/
|
|
509
509
|
addOption: {
|
|
510
510
|
type: Boolean,
|
|
511
|
-
default:
|
|
511
|
+
default: getDefaults(defaultConfig, USelect).addOption,
|
|
512
512
|
},
|
|
513
513
|
|
|
514
514
|
/**
|
|
@@ -694,31 +694,6 @@ const isEmpty = computed(() => {
|
|
|
694
694
|
);
|
|
695
695
|
});
|
|
696
696
|
|
|
697
|
-
const {
|
|
698
|
-
config,
|
|
699
|
-
selectLabelAttrs,
|
|
700
|
-
wrapperAttrs,
|
|
701
|
-
innerWrapperAttrs,
|
|
702
|
-
leftIconWrapperAttrs,
|
|
703
|
-
rightIconWrapperAttrs,
|
|
704
|
-
leftIconAttrs,
|
|
705
|
-
rightIconAttrs,
|
|
706
|
-
beforeCaretAttrs,
|
|
707
|
-
afterCaretAttrs,
|
|
708
|
-
toggleAttrs,
|
|
709
|
-
clearAttrs,
|
|
710
|
-
clearMultipleTextAttrs,
|
|
711
|
-
clearMultipleAttrs,
|
|
712
|
-
searchAttrs,
|
|
713
|
-
searchInputAttrs,
|
|
714
|
-
selectedLabelsAttrs,
|
|
715
|
-
selectedLabelAttrs,
|
|
716
|
-
dropdownListAttrs,
|
|
717
|
-
toggleIconAttrs,
|
|
718
|
-
clearIconAttrs,
|
|
719
|
-
clearMultipleIconAttrs,
|
|
720
|
-
} = useAttrs(props, { isTop, isOpen, selectedLabel });
|
|
721
|
-
|
|
722
697
|
const onSearchChange = createDebounce(function (query) {
|
|
723
698
|
emit("searchChange", query);
|
|
724
699
|
}, 300);
|
|
@@ -905,4 +880,43 @@ defineExpose({
|
|
|
905
880
|
*/
|
|
906
881
|
innerWrapperRef,
|
|
907
882
|
});
|
|
883
|
+
|
|
884
|
+
/**
|
|
885
|
+
* Get element / nested component attributes for each config token ✨
|
|
886
|
+
* Applies: `class`, `config`, redefined default `props` and dev `vl-...` attributes.
|
|
887
|
+
*/
|
|
888
|
+
const mutatedProps = computed(() => ({
|
|
889
|
+
error: Boolean(props.error),
|
|
890
|
+
label: Boolean(props.label),
|
|
891
|
+
/* component state, not a props */
|
|
892
|
+
selected: Boolean(selectedLabel.value),
|
|
893
|
+
opened: isOpen.value,
|
|
894
|
+
openedTop: isTop.value,
|
|
895
|
+
}));
|
|
896
|
+
|
|
897
|
+
// eslint-disable-next-line vue/no-dupe-keys
|
|
898
|
+
const {
|
|
899
|
+
config,
|
|
900
|
+
selectLabelAttrs,
|
|
901
|
+
wrapperAttrs,
|
|
902
|
+
innerWrapperAttrs,
|
|
903
|
+
leftIconWrapperAttrs,
|
|
904
|
+
rightIconWrapperAttrs,
|
|
905
|
+
leftIconAttrs,
|
|
906
|
+
rightIconAttrs,
|
|
907
|
+
beforeCaretAttrs,
|
|
908
|
+
afterCaretAttrs,
|
|
909
|
+
toggleAttrs,
|
|
910
|
+
clearAttrs,
|
|
911
|
+
clearMultipleTextAttrs,
|
|
912
|
+
clearMultipleAttrs,
|
|
913
|
+
searchAttrs,
|
|
914
|
+
searchInputAttrs,
|
|
915
|
+
selectedLabelsAttrs,
|
|
916
|
+
selectedLabelAttrs,
|
|
917
|
+
dropdownListAttrs,
|
|
918
|
+
toggleIconAttrs,
|
|
919
|
+
clearIconAttrs,
|
|
920
|
+
clearMultipleIconAttrs,
|
|
921
|
+
} = useUI(defaultConfig, mutatedProps);
|
|
908
922
|
</script>
|
|
@@ -2,29 +2,24 @@
|
|
|
2
2
|
import { computed, useId } from "vue";
|
|
3
3
|
import { merge } from "lodash-es";
|
|
4
4
|
|
|
5
|
+
import useUI from "../composables/useUI.ts";
|
|
6
|
+
import { getDefaults } from "../utils/ui.ts";
|
|
7
|
+
|
|
5
8
|
import UIcon from "../ui.image-icon/UIcon.vue";
|
|
6
9
|
import ULabel from "../ui.form-label/ULabel.vue";
|
|
7
|
-
import { getDefault } from "../utils/ui.ts";
|
|
8
10
|
|
|
9
11
|
import { USwitch } from "./constants.ts";
|
|
10
12
|
import defaultConfig from "./config.ts";
|
|
11
|
-
import useAttrs from "./useAttrs.ts";
|
|
12
13
|
import { useLocale } from "../composables/useLocale.ts";
|
|
13
14
|
|
|
14
|
-
import type {
|
|
15
|
+
import type { Props, IconSize, Config } from "./types.ts";
|
|
15
16
|
|
|
16
17
|
defineOptions({ inheritAttrs: false });
|
|
17
18
|
|
|
18
|
-
const props = withDefaults(defineProps<
|
|
19
|
-
|
|
20
|
-
size: getDefault<USwitchProps>(defaultConfig, USwitch).size,
|
|
21
|
-
color: getDefault<USwitchProps>(defaultConfig, USwitch).color,
|
|
22
|
-
toggleIcon: getDefault<USwitchProps>(defaultConfig, USwitch).toggleIcon,
|
|
23
|
-
toggleLabel: getDefault<USwitchProps>(defaultConfig, USwitch).toggleLabel,
|
|
24
|
-
disabled: getDefault<USwitchProps>(defaultConfig, USwitch).disabled,
|
|
19
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
20
|
+
...getDefaults<Props, Config>(defaultConfig, USwitch),
|
|
25
21
|
modelValue: false,
|
|
26
|
-
|
|
27
|
-
config: () => ({}),
|
|
22
|
+
label: "",
|
|
28
23
|
});
|
|
29
24
|
|
|
30
25
|
const emit = defineEmits([
|
|
@@ -47,16 +42,6 @@ const checkedValue = computed({
|
|
|
47
42
|
|
|
48
43
|
const elementId = props.id || useId();
|
|
49
44
|
|
|
50
|
-
const {
|
|
51
|
-
config,
|
|
52
|
-
toggleIconAttrs,
|
|
53
|
-
switchLabelAttrs,
|
|
54
|
-
inputAttrs,
|
|
55
|
-
wrapperAttrs,
|
|
56
|
-
circleAttrs,
|
|
57
|
-
toggleLabelAttrs,
|
|
58
|
-
} = useAttrs(props, { checked: checkedValue });
|
|
59
|
-
|
|
60
45
|
const switchLabel = computed(() => {
|
|
61
46
|
return checkedValue.value ? currentLocale.value.active : currentLocale.value.inactive;
|
|
62
47
|
});
|
|
@@ -75,6 +60,10 @@ const iconColor = computed(() => {
|
|
|
75
60
|
return checkedValue.value ? props.color : "grayscale";
|
|
76
61
|
});
|
|
77
62
|
|
|
63
|
+
const toggleIconName = computed(() => {
|
|
64
|
+
return checkedValue.value ? config.value.defaults.onIcon : config.value.defaults.offIcon;
|
|
65
|
+
});
|
|
66
|
+
|
|
78
67
|
function toggle() {
|
|
79
68
|
if (!props.disabled) {
|
|
80
69
|
checkedValue.value = !checkedValue.value;
|
|
@@ -88,6 +77,24 @@ function onClickToggle() {
|
|
|
88
77
|
function onKeydownSpace() {
|
|
89
78
|
toggle();
|
|
90
79
|
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Get element / nested component attributes for each config token ✨
|
|
83
|
+
* Applies: `class`, `config`, redefined default `props` and dev `vl-...` attributes.
|
|
84
|
+
*/
|
|
85
|
+
const mutatedProps = computed(() => ({
|
|
86
|
+
checked: Boolean(checkedValue.value),
|
|
87
|
+
}));
|
|
88
|
+
|
|
89
|
+
const {
|
|
90
|
+
config,
|
|
91
|
+
toggleIconAttrs,
|
|
92
|
+
switchLabelAttrs,
|
|
93
|
+
inputAttrs,
|
|
94
|
+
wrapperAttrs,
|
|
95
|
+
circleAttrs,
|
|
96
|
+
toggleLabelAttrs,
|
|
97
|
+
} = useUI<Config>(defaultConfig, mutatedProps);
|
|
91
98
|
</script>
|
|
92
99
|
|
|
93
100
|
<template>
|
|
@@ -117,7 +124,7 @@ function onKeydownSpace() {
|
|
|
117
124
|
<UIcon
|
|
118
125
|
v-if="toggleIcon"
|
|
119
126
|
internal
|
|
120
|
-
:name="
|
|
127
|
+
:name="toggleIconName"
|
|
121
128
|
:color="iconColor"
|
|
122
129
|
:size="iconSize"
|
|
123
130
|
v-bind="toggleIconAttrs"
|
|
@@ -10,9 +10,9 @@ import UIcon from "../../ui.image-icon/UIcon.vue";
|
|
|
10
10
|
import URow from "../../ui.container-row/URow.vue";
|
|
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 USwitchArgs extends
|
|
15
|
+
interface USwitchArgs extends Props {
|
|
16
16
|
slotTemplate?: string;
|
|
17
17
|
enum: "size" | "color";
|
|
18
18
|
}
|
package/ui.form-switch/types.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
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 type IconSize = "2xs" | "xs" | "sm";
|
|
6
8
|
|
|
7
|
-
export interface
|
|
9
|
+
export interface Props {
|
|
8
10
|
/**
|
|
9
11
|
* Switch value.
|
|
10
12
|
*/
|
|
@@ -79,7 +81,7 @@ export interface USwitchProps {
|
|
|
79
81
|
/**
|
|
80
82
|
* Component config object.
|
|
81
83
|
*/
|
|
82
|
-
config?: Config
|
|
84
|
+
config?: ComponentConfig<Config>;
|
|
83
85
|
|
|
84
86
|
/**
|
|
85
87
|
* Data-test attribute for automated testing.
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { computed, onMounted, ref, watch, useSlots, useId } from "vue";
|
|
3
3
|
|
|
4
|
-
import
|
|
4
|
+
import useUI from "../composables/useUI.ts";
|
|
5
|
+
import { getDefaults } from "../utils/ui.ts";
|
|
5
6
|
import { hasSlotContent } from "../utils/helper.ts";
|
|
6
7
|
|
|
7
8
|
import { useMutationObserver } from "../composables/useMutationObserver.ts";
|
|
@@ -10,22 +11,16 @@ import ULabel from "../ui.form-label/ULabel.vue";
|
|
|
10
11
|
|
|
11
12
|
import { UTextarea } from "./constants.ts";
|
|
12
13
|
import defaultConfig from "./config.ts";
|
|
13
|
-
import useAttrs from "./useAttrs.ts";
|
|
14
14
|
|
|
15
|
-
import type {
|
|
15
|
+
import type { Props, Config } from "./types.ts";
|
|
16
16
|
|
|
17
17
|
defineOptions({ inheritAttrs: false });
|
|
18
18
|
|
|
19
|
-
const props = withDefaults(defineProps<
|
|
20
|
-
|
|
21
|
-
labelAlign: getDefault<UTextareaProps>(defaultConfig, UTextarea).labelAlign,
|
|
22
|
-
resizable: getDefault<UTextareaProps>(defaultConfig, UTextarea).resizable,
|
|
23
|
-
readonly: getDefault<UTextareaProps>(defaultConfig, UTextarea).readonly,
|
|
24
|
-
disabled: getDefault<UTextareaProps>(defaultConfig, UTextarea).disabled,
|
|
25
|
-
inputmode: getDefault<UTextareaProps>(defaultConfig, UTextarea).inputmode,
|
|
26
|
-
noAutocomplete: getDefault<UTextareaProps>(defaultConfig, UTextarea).noAutocomplete,
|
|
19
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
20
|
+
...getDefaults<Props, Config>(defaultConfig, UTextarea),
|
|
27
21
|
modelValue: "",
|
|
28
|
-
|
|
22
|
+
label: "",
|
|
23
|
+
placeholder: "",
|
|
29
24
|
});
|
|
30
25
|
|
|
31
26
|
const emit = defineEmits([
|
|
@@ -65,9 +60,6 @@ const slots = useSlots();
|
|
|
65
60
|
|
|
66
61
|
const elementId = props.id || useId();
|
|
67
62
|
|
|
68
|
-
const { textareaAttrs, textareaLabelAttrs, textareaWrapperAttrs, leftSlotAttrs, rightSlotAttrs } =
|
|
69
|
-
useAttrs(props);
|
|
70
|
-
|
|
71
63
|
const textareaRef = ref<HTMLTextAreaElement | null>(null);
|
|
72
64
|
const labelComponentRef = ref<{ labelElement: HTMLElement | null } | null>(null);
|
|
73
65
|
const leftSlotWrapperRef = ref<HTMLElement | null>(null);
|
|
@@ -184,6 +176,18 @@ defineExpose({
|
|
|
184
176
|
*/
|
|
185
177
|
textareaRef,
|
|
186
178
|
});
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Get element / nested component attributes for each config token ✨
|
|
182
|
+
* Applies: `class`, `config`, redefined default `props` and dev `vl-...` attributes.
|
|
183
|
+
*/
|
|
184
|
+
const mutatedProps = computed(() => ({
|
|
185
|
+
error: Boolean(props.error),
|
|
186
|
+
label: Boolean(props.label),
|
|
187
|
+
}));
|
|
188
|
+
|
|
189
|
+
const { textareaAttrs, textareaLabelAttrs, textareaWrapperAttrs, leftSlotAttrs, rightSlotAttrs } =
|
|
190
|
+
useUI<Config>(defaultConfig, mutatedProps);
|
|
187
191
|
</script>
|
|
188
192
|
|
|
189
193
|
<template>
|
|
@@ -10,9 +10,9 @@ import UIcon from "../../ui.image-icon/UIcon.vue";
|
|
|
10
10
|
import UCol from "../../ui.container-col/UCol.vue";
|
|
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 UTextareaArgs extends
|
|
15
|
+
interface UTextareaArgs extends Props {
|
|
16
16
|
slotTemplate?: string;
|
|
17
17
|
enum: "size" | "labelAlign";
|
|
18
18
|
}
|
|
@@ -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
|
* Set input size.
|
|
8
10
|
*/
|
|
@@ -76,7 +78,7 @@ export interface UTextareaProps {
|
|
|
76
78
|
/**
|
|
77
79
|
* Component config object.
|
|
78
80
|
*/
|
|
79
|
-
config?: Config
|
|
81
|
+
config?: ComponentConfig<Config>;
|
|
80
82
|
|
|
81
83
|
/**
|
|
82
84
|
* Data-test attribute for automated testing.
|