vueless 0.0.569 → 0.0.570
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/types.ts +14 -0
- package/ui.container-accordion/UAccordion.vue +2 -2
- package/ui.container-accordion/types.ts +1 -0
- package/ui.container-modal/UModal.vue +15 -8
- package/ui.container-page/UPage.vue +10 -6
- package/ui.form-checkbox/types.ts +7 -0
- package/ui.form-checkbox-group/UCheckboxGroup.vue +1 -1
- package/ui.form-checkbox-multi-state/UCheckboxMultiState.vue +4 -1
- package/ui.form-color-picker/UColorPicker.vue +67 -147
- package/ui.form-color-picker/storybook/Docs.mdx +2 -2
- package/ui.form-color-picker/storybook/{stories.js → stories.ts} +13 -5
- package/ui.form-color-picker/types.ts +64 -0
- package/ui.form-color-picker/useAttrs.ts +15 -0
- package/ui.form-input/UInput.vue +162 -321
- package/ui.form-input/{config.js → config.ts} +3 -0
- package/ui.form-input/storybook/Docs.mdx +2 -2
- package/ui.form-input/storybook/{stories.js → stories.ts} +14 -6
- package/ui.form-input/types.ts +103 -0
- package/ui.form-input/useAttrs.ts +31 -0
- package/ui.form-input-file/UInputFile.vue +188 -245
- package/ui.form-input-file/storybook/Docs.mdx +2 -2
- package/ui.form-input-file/storybook/{stories.js → stories.ts} +13 -5
- package/ui.form-input-file/types.ts +72 -0
- package/ui.form-input-file/useAttrs.ts +21 -0
- package/ui.form-input-file/{utilFileForm.js → utilFileForm.ts} +1 -1
- package/ui.form-input-money/UInputMoney.vue +76 -223
- package/ui.form-input-money/storybook/Docs.mdx +2 -2
- package/ui.form-input-money/storybook/{stories.js → stories.ts} +14 -6
- package/ui.form-input-money/types.ts +118 -0
- package/ui.form-input-money/useAttrs.ts +15 -0
- package/ui.form-input-money/{useFormatCurrency.js → useFormatCurrency.ts} +28 -17
- package/ui.form-input-money/utilFormat.ts +83 -0
- package/ui.form-input-number/UInputNumber.vue +69 -156
- package/ui.form-input-number/storybook/Docs.mdx +2 -2
- package/ui.form-input-number/storybook/{stories.js → stories.ts} +17 -9
- package/ui.form-input-number/types.ts +65 -0
- package/ui.form-input-number/useAttrs.ts +15 -0
- package/ui.form-input-rating/UInputRating.vue +70 -158
- package/ui.form-input-rating/storybook/Docs.mdx +2 -2
- package/ui.form-input-rating/storybook/{stories.js → stories.ts} +14 -6
- package/ui.form-input-rating/types.ts +67 -0
- package/ui.form-input-rating/useAttrs.ts +14 -0
- package/ui.form-input-search/UInputSearch.vue +97 -224
- package/ui.form-input-search/storybook/Docs.mdx +2 -2
- package/ui.form-input-search/storybook/{stories.js → stories.ts} +13 -5
- package/ui.form-input-search/types.ts +93 -0
- package/ui.form-input-search/useAttrs.ts +15 -0
- package/ui.form-radio/URadio.vue +1 -1
- package/ui.form-radio-group/URadioGroup.vue +1 -1
- package/ui.navigation-pagination/UPagination.vue +15 -15
- package/ui.navigation-pagination/types.ts +3 -0
- package/ui.navigation-progress/UProgress.vue +16 -2
- package/ui.navigation-progress/types.ts +2 -0
- package/ui.text-files/UFiles.vue +20 -16
- package/ui.text-files/types.ts +1 -1
- package/ui.text-notify/UNotify.vue +38 -48
- package/ui.text-notify/types.ts +24 -0
- package/web-types.json +227 -138
- package/ui.form-color-picker/useAttrs.js +0 -9
- package/ui.form-input/useAttrs.js +0 -15
- package/ui.form-input-file/useAttrs.js +0 -15
- package/ui.form-input-money/useAttrs.js +0 -9
- package/ui.form-input-money/utilFormat.js +0 -75
- package/ui.form-input-number/useAttrs.js +0 -9
- package/ui.form-input-rating/useAttrs.js +0 -8
- package/ui.form-input-search/useAttrs.js +0 -9
- /package/ui.form-color-picker/{config.js → config.ts} +0 -0
- /package/ui.form-color-picker/{constants.js → constants.ts} +0 -0
- /package/ui.form-input/{constants.js → constants.ts} +0 -0
- /package/ui.form-input-file/{config.js → config.ts} +0 -0
- /package/ui.form-input-file/{constants.js → constants.ts} +0 -0
- /package/ui.form-input-money/{config.js → config.ts} +0 -0
- /package/ui.form-input-money/{constants.js → constants.ts} +0 -0
- /package/ui.form-input-number/{config.js → config.ts} +0 -0
- /package/ui.form-input-number/{constants.js → constants.ts} +0 -0
- /package/ui.form-input-rating/{config.js → config.ts} +0 -0
- /package/ui.form-input-rating/{constants.js → constants.ts} +0 -0
- /package/ui.form-input-search/{config.js → config.ts} +0 -0
- /package/ui.form-input-search/{constants.js → constants.ts} +0 -0
package/package.json
CHANGED
package/types.ts
CHANGED
|
@@ -46,6 +46,13 @@ import URadioGroupConfig from "./ui.form-radio-group/config.ts";
|
|
|
46
46
|
import USwitchConfig from "./ui.form-switch/config.ts";
|
|
47
47
|
import UTextareaConfig from "./ui.form-textarea/config.ts";
|
|
48
48
|
import ULabelConfig from "./ui.form-label/config.ts";
|
|
49
|
+
import UColorPickerConfig from "./ui.form-color-picker/config.ts";
|
|
50
|
+
import UInputConfig from "./ui.form-input/config.ts";
|
|
51
|
+
import UInputNumberConfig from "./ui.form-input-number/config.ts";
|
|
52
|
+
import UInputRatingConfig from "./ui.form-input-rating/config.ts";
|
|
53
|
+
import UInputSearchConfig from "./ui.form-input-search/config.ts";
|
|
54
|
+
import UInputFileConfig from "./ui.form-input-file/config.ts";
|
|
55
|
+
import UInputMoneyConfig from "./ui.form-input-money/config.ts";
|
|
49
56
|
import UDataListConfig from "./ui.data-list/config.ts";
|
|
50
57
|
|
|
51
58
|
import type { ComputedRef, MaybeRef, Ref, UnwrapRef } from "vue";
|
|
@@ -209,6 +216,13 @@ export interface Components {
|
|
|
209
216
|
USwitch?: Partial<typeof USwitchConfig>;
|
|
210
217
|
UTextarea?: Partial<typeof UTextareaConfig>;
|
|
211
218
|
ULabel?: Partial<typeof ULabelConfig>;
|
|
219
|
+
UColorPicker?: Partial<typeof UColorPickerConfig>;
|
|
220
|
+
UInput?: Partial<typeof UInputConfig>;
|
|
221
|
+
UInputNumber?: Partial<typeof UInputNumberConfig>;
|
|
222
|
+
UInputRating?: Partial<typeof UInputRatingConfig>;
|
|
223
|
+
UInputSearch?: Partial<typeof UInputSearchConfig>;
|
|
224
|
+
UInputFile?: Partial<typeof UInputFileConfig>;
|
|
225
|
+
UInputMoney?: Partial<typeof UInputMoneyConfig>;
|
|
212
226
|
UDataList?: Partial<typeof UDataListConfig>;
|
|
213
227
|
}
|
|
214
228
|
|
|
@@ -9,7 +9,7 @@ import { UAccordion } from "./constants.ts";
|
|
|
9
9
|
import defaultConfig from "./config.ts";
|
|
10
10
|
import useAttrs from "./useAttrs.ts";
|
|
11
11
|
|
|
12
|
-
import type { UAccordionProps } from "./types.ts";
|
|
12
|
+
import type { UAccordionProps, DividerSize } from "./types.ts";
|
|
13
13
|
|
|
14
14
|
defineOptions({ inheritAttrs: false });
|
|
15
15
|
|
|
@@ -52,7 +52,7 @@ const dividerSize = computed(() => {
|
|
|
52
52
|
lg: "xl",
|
|
53
53
|
};
|
|
54
54
|
|
|
55
|
-
return sizes[props.size];
|
|
55
|
+
return sizes[props.size] as DividerSize;
|
|
56
56
|
});
|
|
57
57
|
|
|
58
58
|
function onClickItem() {
|
|
@@ -16,9 +16,6 @@ import useAttrs from "./useAttrs.ts";
|
|
|
16
16
|
import type { UModalProps } from "./types.ts";
|
|
17
17
|
|
|
18
18
|
defineOptions({ inheritAttrs: false });
|
|
19
|
-
const slots = useSlots();
|
|
20
|
-
|
|
21
|
-
const wrapperRef = ref(null);
|
|
22
19
|
|
|
23
20
|
const props = withDefaults(defineProps<UModalProps>(), {
|
|
24
21
|
size: getDefault<UModalProps>(defaultConfig, UModal).size,
|
|
@@ -29,6 +26,7 @@ const props = withDefaults(defineProps<UModalProps>(), {
|
|
|
29
26
|
noDivider: getDefault<UModalProps>(defaultConfig, UModal).noDivider,
|
|
30
27
|
mobileStickBottom: getDefault<UModalProps>(defaultConfig, UModal).mobileStickBottom,
|
|
31
28
|
dataTest: "",
|
|
29
|
+
config: () => ({}),
|
|
32
30
|
});
|
|
33
31
|
|
|
34
32
|
const emit = defineEmits([
|
|
@@ -69,6 +67,10 @@ const {
|
|
|
69
67
|
footerRightAttrs,
|
|
70
68
|
} = useAttrs(props);
|
|
71
69
|
|
|
70
|
+
const slots = useSlots();
|
|
71
|
+
|
|
72
|
+
const wrapperRef = ref<HTMLElement | null>(null);
|
|
73
|
+
|
|
72
74
|
const isShownModal = computed({
|
|
73
75
|
get: () => props.modelValue,
|
|
74
76
|
set: (value) => emit("update:modelValue", value),
|
|
@@ -94,14 +96,19 @@ const isExistFooter = computed(() => {
|
|
|
94
96
|
|
|
95
97
|
watch(() => isShownModal.value, preventOverlayFromScrolling);
|
|
96
98
|
|
|
97
|
-
function preventOverlayFromScrolling(newValue) {
|
|
99
|
+
function preventOverlayFromScrolling(newValue: boolean) {
|
|
98
100
|
// focus wrapper to be able to close modal on esc
|
|
99
101
|
setTimeout(() => wrapperRef.value?.focus(), 0);
|
|
100
102
|
|
|
101
103
|
if (newValue) {
|
|
102
104
|
document.body.style.overflow = "hidden";
|
|
103
105
|
} else {
|
|
104
|
-
document.getElementById(`${elementId}`)
|
|
106
|
+
const element = document.getElementById(`${elementId}`);
|
|
107
|
+
|
|
108
|
+
if (element) {
|
|
109
|
+
element.style.overflow = "hidden";
|
|
110
|
+
}
|
|
111
|
+
|
|
105
112
|
document.body.style.overflow = "auto";
|
|
106
113
|
}
|
|
107
114
|
}
|
|
@@ -166,7 +173,7 @@ function closeModal() {
|
|
|
166
173
|
internal
|
|
167
174
|
size="xs"
|
|
168
175
|
color="gray"
|
|
169
|
-
:name="config.defaults
|
|
176
|
+
:name="config.defaults?.backIcon"
|
|
170
177
|
v-bind="backLinkIconAttrs"
|
|
171
178
|
/>
|
|
172
179
|
</template>
|
|
@@ -191,12 +198,12 @@ function closeModal() {
|
|
|
191
198
|
@slot Use it to add something instead of the close button.
|
|
192
199
|
@binding {string} icon-name
|
|
193
200
|
-->
|
|
194
|
-
<slot name="close-button" :icon-name="config.defaults
|
|
201
|
+
<slot name="close-button" :icon-name="config.defaults?.closeIcon">
|
|
195
202
|
<UIcon
|
|
196
203
|
internal
|
|
197
204
|
interactive
|
|
198
205
|
size="sm"
|
|
199
|
-
:name="config.defaults
|
|
206
|
+
:name="config.defaults?.closeIcon"
|
|
200
207
|
v-bind="closeIconAttrs"
|
|
201
208
|
:data-test="`${dataTest}-close`"
|
|
202
209
|
@click="onClickCloseModal"
|
|
@@ -25,6 +25,7 @@ const props = withDefaults(defineProps<UPageProps>(), {
|
|
|
25
25
|
gray: getDefault<UPageProps>(defaultConfig, UPage).gray,
|
|
26
26
|
fixedRounding: getDefault<UPageProps>(defaultConfig, UPage).fixedRounding,
|
|
27
27
|
dataTest: "",
|
|
28
|
+
config: () => ({}),
|
|
28
29
|
});
|
|
29
30
|
|
|
30
31
|
const { isMobileBreakpoint } = useBreakpoint();
|
|
@@ -68,11 +69,14 @@ const isShownArrowButton = computed(() => {
|
|
|
68
69
|
});
|
|
69
70
|
|
|
70
71
|
onMounted(() => {
|
|
71
|
-
const classes =
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
72
|
+
const classes =
|
|
73
|
+
props.gray && config.value?.htmlBody
|
|
74
|
+
? config.value.htmlBody.split(" ").filter((item) => Boolean(item))
|
|
75
|
+
: "";
|
|
76
|
+
|
|
77
|
+
if (document.body) {
|
|
78
|
+
document.body.classList.add(...classes);
|
|
79
|
+
}
|
|
76
80
|
});
|
|
77
81
|
</script>
|
|
78
82
|
|
|
@@ -104,7 +108,7 @@ onMounted(() => {
|
|
|
104
108
|
internal
|
|
105
109
|
size="2xs"
|
|
106
110
|
color="gray"
|
|
107
|
-
:name="config.defaults
|
|
111
|
+
:name="config.defaults?.backIcon"
|
|
108
112
|
v-bind="backLinkIconAttrs"
|
|
109
113
|
/>
|
|
110
114
|
</template>
|
|
@@ -6,6 +6,13 @@ export type Config = Partial<typeof defaultConfig>;
|
|
|
6
6
|
|
|
7
7
|
export type IconSize = "2xs" | "xs" | "sm";
|
|
8
8
|
|
|
9
|
+
export interface UCheckboxOption {
|
|
10
|
+
value?: unknown;
|
|
11
|
+
label?: string;
|
|
12
|
+
icon?: string;
|
|
13
|
+
description?: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
9
16
|
export interface UCheckboxProps {
|
|
10
17
|
/**
|
|
11
18
|
* Checkbox value.
|
|
@@ -9,6 +9,7 @@ import { UCheckboxMultiState } from "./constants.ts";
|
|
|
9
9
|
import useAttrs from "./useAttrs.ts";
|
|
10
10
|
|
|
11
11
|
import type { UCheckboxMultiStateProps } from "./types.ts";
|
|
12
|
+
import type { UCheckboxOption } from "../ui.form-checkbox/types.ts";
|
|
12
13
|
|
|
13
14
|
defineOptions({ inheritAttrs: false });
|
|
14
15
|
|
|
@@ -31,7 +32,9 @@ const emit = defineEmits([
|
|
|
31
32
|
const index = ref(0);
|
|
32
33
|
const isChecked = ref(false);
|
|
33
34
|
|
|
34
|
-
const selected = computed(() =>
|
|
35
|
+
const selected = computed<UCheckboxOption>(() => {
|
|
36
|
+
return props.options?.[index.value] || { icon: undefined };
|
|
37
|
+
});
|
|
35
38
|
|
|
36
39
|
const { multiStateCheckboxAttrs } = useAttrs(props, { selected });
|
|
37
40
|
|
|
@@ -1,56 +1,4 @@
|
|
|
1
|
-
<
|
|
2
|
-
<ULabel
|
|
3
|
-
:label="label"
|
|
4
|
-
:description="description"
|
|
5
|
-
:disabled="disabled"
|
|
6
|
-
:error="error"
|
|
7
|
-
:size="size"
|
|
8
|
-
align="topWithDesc"
|
|
9
|
-
v-bind="colorPickerLabelAttrs"
|
|
10
|
-
:data-test="dataTest"
|
|
11
|
-
>
|
|
12
|
-
<div v-bind="listAttrs">
|
|
13
|
-
<div v-bind="unselectedAttrs">
|
|
14
|
-
<URadio
|
|
15
|
-
:id="elementId"
|
|
16
|
-
:name="name"
|
|
17
|
-
:size="size"
|
|
18
|
-
color="gray"
|
|
19
|
-
:checked="selectedItem === ''"
|
|
20
|
-
:disabled="disabled"
|
|
21
|
-
v-bind="unselectedColorPickerRadioAttrs"
|
|
22
|
-
@update:model-value="onUpdateValue('')"
|
|
23
|
-
/>
|
|
24
|
-
|
|
25
|
-
<label :for="elementId">
|
|
26
|
-
<UIcon
|
|
27
|
-
v-if="selectedItem === ''"
|
|
28
|
-
internal
|
|
29
|
-
:size="iconSize"
|
|
30
|
-
color="gray"
|
|
31
|
-
:name="config.defaults.unselectedIcon"
|
|
32
|
-
v-bind="unselectedIconAttrs"
|
|
33
|
-
/>
|
|
34
|
-
</label>
|
|
35
|
-
</div>
|
|
36
|
-
|
|
37
|
-
<URadio
|
|
38
|
-
v-for="(color, index) in colorOptions"
|
|
39
|
-
:key="index"
|
|
40
|
-
:name="name"
|
|
41
|
-
:size="size"
|
|
42
|
-
:value="color"
|
|
43
|
-
:color="color"
|
|
44
|
-
:checked="selectedItem === color"
|
|
45
|
-
:disabled="disabled"
|
|
46
|
-
v-bind="colorPickerRadioAttrs"
|
|
47
|
-
@update:model-value="onUpdateValue(color)"
|
|
48
|
-
/>
|
|
49
|
-
</div>
|
|
50
|
-
</ULabel>
|
|
51
|
-
</template>
|
|
52
|
-
|
|
53
|
-
<script setup>
|
|
1
|
+
<script setup lang="ts">
|
|
54
2
|
import { computed, useId } from "vue";
|
|
55
3
|
|
|
56
4
|
import UIcon from "../ui.image-icon/UIcon.vue";
|
|
@@ -58,101 +6,21 @@ import URadio from "../ui.form-radio/URadio.vue";
|
|
|
58
6
|
import ULabel from "../ui.form-label/ULabel.vue";
|
|
59
7
|
import { getDefault } from "../utils/ui.ts";
|
|
60
8
|
|
|
61
|
-
import { UColorPicker } from "./constants.
|
|
62
|
-
import defaultConfig from "./config.
|
|
63
|
-
import useAttrs from "./useAttrs.
|
|
9
|
+
import { UColorPicker } from "./constants.ts";
|
|
10
|
+
import defaultConfig from "./config.ts";
|
|
11
|
+
import useAttrs from "./useAttrs.ts";
|
|
64
12
|
|
|
65
|
-
|
|
13
|
+
import type { UColorPickerProps, IconSize } from "./types.ts";
|
|
66
14
|
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Color picker selected value.
|
|
70
|
-
*/
|
|
71
|
-
modelValue: {
|
|
72
|
-
type: String,
|
|
73
|
-
default: "",
|
|
74
|
-
},
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Color picker name.
|
|
78
|
-
*/
|
|
79
|
-
name: {
|
|
80
|
-
type: String,
|
|
81
|
-
default: getDefault(defaultConfig, UColorPicker).name,
|
|
82
|
-
},
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Color picker label.
|
|
86
|
-
*/
|
|
87
|
-
label: {
|
|
88
|
-
type: String,
|
|
89
|
-
default: "",
|
|
90
|
-
},
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Color picker description.
|
|
94
|
-
*/
|
|
95
|
-
description: {
|
|
96
|
-
type: String,
|
|
97
|
-
default: "",
|
|
98
|
-
},
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Error message.
|
|
102
|
-
*/
|
|
103
|
-
error: {
|
|
104
|
-
type: String,
|
|
105
|
-
default: "",
|
|
106
|
-
},
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Color picker size.
|
|
110
|
-
* @values sm, md, lg
|
|
111
|
-
*/
|
|
112
|
-
size: {
|
|
113
|
-
type: String,
|
|
114
|
-
default: getDefault(defaultConfig, UColorPicker).size,
|
|
115
|
-
},
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Color picker color list.
|
|
119
|
-
*/
|
|
120
|
-
colorOptions: {
|
|
121
|
-
type: Array,
|
|
122
|
-
default: () => getDefault(defaultConfig, UColorPicker).colorOptions,
|
|
123
|
-
},
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Set color picker disabled.
|
|
127
|
-
*/
|
|
128
|
-
disabled: {
|
|
129
|
-
type: Boolean,
|
|
130
|
-
default: getDefault(defaultConfig, UColorPicker).disabled,
|
|
131
|
-
},
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Unique element id.
|
|
135
|
-
*/
|
|
136
|
-
id: {
|
|
137
|
-
type: String,
|
|
138
|
-
default: "",
|
|
139
|
-
},
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* Component config object.
|
|
143
|
-
*/
|
|
144
|
-
config: {
|
|
145
|
-
type: Object,
|
|
146
|
-
default: () => ({}),
|
|
147
|
-
},
|
|
15
|
+
defineOptions({ inheritAttrs: false });
|
|
148
16
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
},
|
|
17
|
+
const props = withDefaults(defineProps<UColorPickerProps>(), {
|
|
18
|
+
name: getDefault<UColorPickerProps>(defaultConfig, UColorPicker).name,
|
|
19
|
+
size: getDefault<UColorPickerProps>(defaultConfig, UColorPicker).size,
|
|
20
|
+
colorOptions: getDefault<UColorPickerProps>(defaultConfig, UColorPicker).colorOptions,
|
|
21
|
+
disabled: getDefault<UColorPickerProps>(defaultConfig, UColorPicker).disabled,
|
|
22
|
+
dataTest: "",
|
|
23
|
+
config: () => ({}),
|
|
156
24
|
});
|
|
157
25
|
|
|
158
26
|
const emit = defineEmits([
|
|
@@ -189,10 +57,62 @@ const iconSize = computed(() => {
|
|
|
189
57
|
xl: "md",
|
|
190
58
|
};
|
|
191
59
|
|
|
192
|
-
return sizes[props.size];
|
|
60
|
+
return sizes[props.size] as IconSize;
|
|
193
61
|
});
|
|
194
62
|
|
|
195
|
-
function onUpdateValue(value) {
|
|
63
|
+
function onUpdateValue(value: string) {
|
|
196
64
|
selectedItem.value = value;
|
|
197
65
|
}
|
|
198
66
|
</script>
|
|
67
|
+
|
|
68
|
+
<template>
|
|
69
|
+
<ULabel
|
|
70
|
+
:label="label"
|
|
71
|
+
:description="description"
|
|
72
|
+
:disabled="disabled"
|
|
73
|
+
:error="error"
|
|
74
|
+
:size="size"
|
|
75
|
+
align="topWithDesc"
|
|
76
|
+
v-bind="colorPickerLabelAttrs"
|
|
77
|
+
:data-test="dataTest"
|
|
78
|
+
>
|
|
79
|
+
<div v-bind="listAttrs">
|
|
80
|
+
<div v-bind="unselectedAttrs">
|
|
81
|
+
<URadio
|
|
82
|
+
:id="elementId"
|
|
83
|
+
:name="name"
|
|
84
|
+
:size="size"
|
|
85
|
+
color="gray"
|
|
86
|
+
:checked="selectedItem === ''"
|
|
87
|
+
:disabled="disabled"
|
|
88
|
+
v-bind="unselectedColorPickerRadioAttrs"
|
|
89
|
+
@update:model-value="onUpdateValue('')"
|
|
90
|
+
/>
|
|
91
|
+
|
|
92
|
+
<label :for="elementId">
|
|
93
|
+
<UIcon
|
|
94
|
+
v-if="selectedItem === ''"
|
|
95
|
+
internal
|
|
96
|
+
:size="iconSize"
|
|
97
|
+
color="gray"
|
|
98
|
+
:name="config.defaults?.unselectedIcon"
|
|
99
|
+
v-bind="unselectedIconAttrs"
|
|
100
|
+
/>
|
|
101
|
+
</label>
|
|
102
|
+
</div>
|
|
103
|
+
|
|
104
|
+
<URadio
|
|
105
|
+
v-for="(color, index) in colorOptions"
|
|
106
|
+
:key="index"
|
|
107
|
+
:name="name"
|
|
108
|
+
:size="size"
|
|
109
|
+
:value="color"
|
|
110
|
+
:color="color"
|
|
111
|
+
:checked="selectedItem === color"
|
|
112
|
+
:disabled="disabled"
|
|
113
|
+
v-bind="colorPickerRadioAttrs"
|
|
114
|
+
@update:model-value="onUpdateValue(color)"
|
|
115
|
+
/>
|
|
116
|
+
</div>
|
|
117
|
+
</ULabel>
|
|
118
|
+
</template>
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Meta, Title, Subtitle, Description, Primary, Controls, Stories, Source } from "@storybook/blocks";
|
|
2
2
|
import { getSource } from "../../utils/storybook.ts";
|
|
3
3
|
|
|
4
|
-
import * as stories from "./stories.
|
|
5
|
-
import defaultConfig from "../config.
|
|
4
|
+
import * as stories from "./stories.ts";
|
|
5
|
+
import defaultConfig from "../config.ts?raw"
|
|
6
6
|
|
|
7
7
|
<Meta of={stories} />
|
|
8
8
|
<Title of={stories} />
|
|
@@ -8,6 +8,14 @@ import {
|
|
|
8
8
|
import UColorPicker from "../../ui.form-color-picker/UColorPicker.vue";
|
|
9
9
|
import UCol from "../../ui.container-col/UCol.vue";
|
|
10
10
|
|
|
11
|
+
import type { Meta, StoryFn } from "@storybook/vue3";
|
|
12
|
+
import type { UColorPickerProps } from "../types.ts";
|
|
13
|
+
|
|
14
|
+
interface UColorPickerArgs extends UColorPickerProps {
|
|
15
|
+
slotTemplate?: string;
|
|
16
|
+
enum: "size";
|
|
17
|
+
}
|
|
18
|
+
|
|
11
19
|
export default {
|
|
12
20
|
id: "3210",
|
|
13
21
|
title: "Form Inputs & Controls / Color Picker",
|
|
@@ -22,9 +30,9 @@ export default {
|
|
|
22
30
|
parameters: {
|
|
23
31
|
...getDocsDescription(UColorPicker.__name),
|
|
24
32
|
},
|
|
25
|
-
};
|
|
33
|
+
} as Meta;
|
|
26
34
|
|
|
27
|
-
const DefaultTemplate = (args) => ({
|
|
35
|
+
const DefaultTemplate: StoryFn<UColorPickerArgs> = (args: UColorPickerArgs) => ({
|
|
28
36
|
components: { UColorPicker },
|
|
29
37
|
setup() {
|
|
30
38
|
const slots = getSlotNames(UColorPicker.__name);
|
|
@@ -33,17 +41,17 @@ const DefaultTemplate = (args) => ({
|
|
|
33
41
|
},
|
|
34
42
|
template: `
|
|
35
43
|
<UColorPicker v-bind="args" v-model="args.modelValue">
|
|
36
|
-
${args.slotTemplate || getSlotsFragment()}
|
|
44
|
+
${args.slotTemplate || getSlotsFragment("")}
|
|
37
45
|
</UColorPicker>
|
|
38
46
|
`,
|
|
39
47
|
});
|
|
40
48
|
|
|
41
|
-
const EnumVariantTemplate = (args, { argTypes }) => ({
|
|
49
|
+
const EnumVariantTemplate: StoryFn<UColorPickerArgs> = (args: UColorPickerArgs, { argTypes }) => ({
|
|
42
50
|
components: { UCol, UColorPicker },
|
|
43
51
|
setup() {
|
|
44
52
|
return {
|
|
45
53
|
args,
|
|
46
|
-
options: argTypes[args.enum]
|
|
54
|
+
options: argTypes?.[args.enum]?.options,
|
|
47
55
|
};
|
|
48
56
|
},
|
|
49
57
|
template: `
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import defaultConfig from "./config.ts";
|
|
2
|
+
|
|
3
|
+
import type { BrandColors } from "../types.ts";
|
|
4
|
+
|
|
5
|
+
export type Config = Partial<typeof defaultConfig>;
|
|
6
|
+
|
|
7
|
+
export type IconSize = "3xs" | "2xs" | "xs" | "sm" | "md";
|
|
8
|
+
|
|
9
|
+
export interface UColorPickerProps {
|
|
10
|
+
/**
|
|
11
|
+
* Color picker selected value.
|
|
12
|
+
*/
|
|
13
|
+
modelValue?: string;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Color picker name.
|
|
17
|
+
*/
|
|
18
|
+
name?: string;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Color picker label.
|
|
22
|
+
*/
|
|
23
|
+
label?: string;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Color picker description.
|
|
27
|
+
*/
|
|
28
|
+
description?: string;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Error message.
|
|
32
|
+
*/
|
|
33
|
+
error?: string;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Color picker size.
|
|
37
|
+
*/
|
|
38
|
+
size?: "sm" | "md" | "lg";
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Color picker color list.
|
|
42
|
+
*/
|
|
43
|
+
colorOptions?: Array<BrandColors>;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Set color picker disabled.
|
|
47
|
+
*/
|
|
48
|
+
disabled?: boolean;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Unique element id.
|
|
52
|
+
*/
|
|
53
|
+
id?: string;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Component config object.
|
|
57
|
+
*/
|
|
58
|
+
config?: Config;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Data-test attribute for automated testing.
|
|
62
|
+
*/
|
|
63
|
+
dataTest?: string;
|
|
64
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import useUI from "../composables/useUI.ts";
|
|
2
|
+
|
|
3
|
+
import defaultConfig from "./config.ts";
|
|
4
|
+
|
|
5
|
+
import type { UseAttrs } from "../types.ts";
|
|
6
|
+
import type { UColorPickerProps, Config } from "./types.ts";
|
|
7
|
+
|
|
8
|
+
export default function useAttrs(props: UColorPickerProps): UseAttrs<Config> {
|
|
9
|
+
const { config, getKeysAttrs } = useUI<Config>(defaultConfig, () => props.config);
|
|
10
|
+
|
|
11
|
+
return {
|
|
12
|
+
config,
|
|
13
|
+
...getKeysAttrs(),
|
|
14
|
+
};
|
|
15
|
+
}
|