vueless 0.0.482 → 0.0.484
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/adatper.locale/vueless.ts +3 -3
- package/composables/useUI.ts +2 -1
- package/package.json +1 -1
- package/types.ts +10 -3
- package/ui.button/storybook/stories.js +100 -40
- package/ui.button-link/storybook/stories.js +109 -35
- package/ui.form-calendar/UCalendar.vue +310 -370
- package/ui.form-calendar/UCalendarDayView.vue +211 -257
- package/ui.form-calendar/UCalendarMonthView.vue +120 -164
- package/ui.form-calendar/UCalendarYearView.vue +118 -164
- package/ui.form-calendar/{config.js → config.ts} +0 -2
- package/ui.form-calendar/{constants.js → constants.ts} +35 -16
- package/ui.form-calendar/storybook/Docs.mdx +2 -3
- package/ui.form-calendar/storybook/{stories.js → stories.ts} +12 -4
- package/ui.form-calendar/types.ts +91 -0
- package/ui.form-calendar/{useAttrs.js → useAttrs.ts} +5 -2
- package/ui.form-calendar/{utilCalendar.js → utilCalendar.ts} +50 -53
- package/ui.form-calendar/{utilDate.js → utilDate.ts} +44 -37
- package/ui.form-calendar/utilFormatting.ts +178 -0
- package/ui.text-badge/useAttrs.ts +2 -2
- package/ui.text-block/useAttrs.ts +1 -3
- package/web-types.json +177 -50
- package/ui.form-calendar/utilFormatting.js +0 -180
- package/ui.form-date-picker/storybook/Docs.mdx +0 -53
- package/ui.form-date-picker/storybook/stories.js +0 -185
- package/ui.form-date-picker-range/storybook/Docs.mdx +0 -16
- package/ui.form-date-picker-range/storybook/stories.js +0 -216
|
@@ -24,7 +24,7 @@ export interface LocaleInstance {
|
|
|
24
24
|
fallback: Ref<string>;
|
|
25
25
|
t: (key: string, ...params: unknown[]) => string;
|
|
26
26
|
n: (value: number) => string;
|
|
27
|
-
tm: (key: string
|
|
27
|
+
tm: <TMassages>(key: string) => Partial<TMassages>;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
const FALLBACK_LOCALE_CODE = "en";
|
|
@@ -86,7 +86,7 @@ function createTranslateMessageFunction(
|
|
|
86
86
|
fallback: Ref<string>,
|
|
87
87
|
messages: Ref<LocaleMessages>,
|
|
88
88
|
) {
|
|
89
|
-
return (key: string) => {
|
|
89
|
+
return <TMassages>(key: string): Partial<TMassages> => {
|
|
90
90
|
const currentLocale = current.value && messages.value[current.value];
|
|
91
91
|
const fallbackLocale = fallback.value && messages.value[fallback.value];
|
|
92
92
|
|
|
@@ -100,7 +100,7 @@ function createTranslateMessageFunction(
|
|
|
100
100
|
str = getObjectValueByPath(fallbackLocale, key, null);
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
-
return
|
|
103
|
+
return str as TMassages;
|
|
104
104
|
};
|
|
105
105
|
}
|
|
106
106
|
|
package/composables/useUI.ts
CHANGED
|
@@ -32,6 +32,7 @@ import type {
|
|
|
32
32
|
CVA,
|
|
33
33
|
KeyAttrs,
|
|
34
34
|
KeysToExtend,
|
|
35
|
+
ExtendedKeyClasses,
|
|
35
36
|
} from "../types.ts";
|
|
36
37
|
|
|
37
38
|
interface MergedConfigOptions {
|
|
@@ -113,7 +114,7 @@ export default function useUI<T>(
|
|
|
113
114
|
* – value: reactive string of extendingKey classes.
|
|
114
115
|
*/
|
|
115
116
|
function getExtendingKeysClasses(extendingKeys: string[], mutatedProps = {}) {
|
|
116
|
-
const extendingClasses:
|
|
117
|
+
const extendingClasses: ExtendedKeyClasses = {};
|
|
117
118
|
|
|
118
119
|
for (const key of extendingKeys) {
|
|
119
120
|
extendingClasses[key] = getClasses(key, mutatedProps);
|
package/package.json
CHANGED
package/types.ts
CHANGED
|
@@ -4,13 +4,18 @@ import { hasSlotContent } from "./composables/useUI.ts";
|
|
|
4
4
|
import UTextDefaultConfig from "./ui.text-block/config.ts";
|
|
5
5
|
import UButtonDefaultConfig from "./ui.button/config.ts";
|
|
6
6
|
import UBadgeDefaultConfig from "./ui.text-badge/config.ts";
|
|
7
|
+
import UCalendarDefaultConfig from "./ui.form-calendar/config.ts";
|
|
7
8
|
|
|
8
|
-
import type { ComputedRef, MaybeRef } from "vue";
|
|
9
|
+
import type { ComputedRef, MaybeRef, Ref } from "vue";
|
|
9
10
|
import type { Props } from "tippy.js";
|
|
10
11
|
import type { LocaleOptions } from "./adatper.locale/vueless.ts";
|
|
11
12
|
|
|
12
13
|
export type TemplateRefElement = MaybeRef<HTMLElement | HTMLElement[] | null>;
|
|
13
14
|
|
|
15
|
+
export interface ExtendedKeyClasses {
|
|
16
|
+
[key: string]: Ref<string>;
|
|
17
|
+
}
|
|
18
|
+
|
|
14
19
|
export interface ThemeConfig {
|
|
15
20
|
/**
|
|
16
21
|
* Components brand (primary) color.
|
|
@@ -109,6 +114,7 @@ export interface Components {
|
|
|
109
114
|
UText?: Partial<typeof UTextDefaultConfig>;
|
|
110
115
|
UButton?: Partial<typeof UButtonDefaultConfig>;
|
|
111
116
|
UBadge?: Partial<typeof UBadgeDefaultConfig>;
|
|
117
|
+
UCalendar?: Partial<typeof UCalendarDefaultConfig>;
|
|
112
118
|
}
|
|
113
119
|
|
|
114
120
|
export interface Directives {
|
|
@@ -162,9 +168,10 @@ export interface VueAttrs {
|
|
|
162
168
|
value?: string;
|
|
163
169
|
}
|
|
164
170
|
|
|
165
|
-
export interface UseAttrs {
|
|
171
|
+
export interface UseAttrs<TConfig> {
|
|
166
172
|
hasSlotContent: typeof hasSlotContent;
|
|
167
|
-
|
|
173
|
+
config: Ref<TConfig | undefined>;
|
|
174
|
+
[key: string]: Ref<TConfig | undefined> | typeof hasSlotContent;
|
|
168
175
|
}
|
|
169
176
|
|
|
170
177
|
export interface KeyAttrs extends VueAttrs {
|
|
@@ -5,6 +5,8 @@ import {
|
|
|
5
5
|
getDocsDescription,
|
|
6
6
|
} from "../../utils/storybook.ts";
|
|
7
7
|
|
|
8
|
+
import { ref } from "vue";
|
|
9
|
+
|
|
8
10
|
import UButton from "../../ui.button/UButton.vue";
|
|
9
11
|
import UIcon from "../../ui.image-icon/UIcon.vue";
|
|
10
12
|
import URow from "../../ui.container-row/URow.vue";
|
|
@@ -46,7 +48,7 @@ const EnumVariantTemplate = (args, { argTypes }) => ({
|
|
|
46
48
|
},
|
|
47
49
|
template: `
|
|
48
50
|
<UCol>
|
|
49
|
-
<URow>
|
|
51
|
+
<URow no-mobile>
|
|
50
52
|
<UButton
|
|
51
53
|
v-for="(option, index) in options"
|
|
52
54
|
:key="index"
|
|
@@ -62,22 +64,28 @@ const EnumVariantTemplate = (args, { argTypes }) => ({
|
|
|
62
64
|
const ColorTemplate = (args, { argTypes }) => ({
|
|
63
65
|
components: { UButton, URow, UCol },
|
|
64
66
|
setup() {
|
|
67
|
+
const variants = [...argTypes.variant.options, "thirdary"];
|
|
68
|
+
|
|
65
69
|
return {
|
|
66
70
|
args,
|
|
67
|
-
variants
|
|
71
|
+
variants,
|
|
68
72
|
colors: argTypes.color.options,
|
|
73
|
+
shouldBeFilled: (variant, index) => {
|
|
74
|
+
return variant === "thirdary" && index === variants.length - 2;
|
|
75
|
+
},
|
|
69
76
|
};
|
|
70
77
|
},
|
|
71
78
|
template: `
|
|
72
79
|
<UCol>
|
|
73
|
-
<URow v-for="(variant,
|
|
80
|
+
<URow v-for="(variant, variantIndex) in variants" :key="variantIndex" no-mobile>
|
|
74
81
|
<UButton
|
|
75
|
-
v-for="(color,
|
|
82
|
+
v-for="(color, colorIndex) in colors"
|
|
76
83
|
v-bind="args"
|
|
77
84
|
:variant="variant"
|
|
78
85
|
:color="color"
|
|
79
86
|
:label="color"
|
|
80
|
-
:key="
|
|
87
|
+
:key="colorIndex"
|
|
88
|
+
:filled="shouldBeFilled(variant, variantIndex)"
|
|
81
89
|
/>
|
|
82
90
|
</URow>
|
|
83
91
|
</UCol>
|
|
@@ -96,6 +104,37 @@ Sizes.args = { enum: "size" };
|
|
|
96
104
|
export const Round = EnumVariantTemplate.bind({});
|
|
97
105
|
Round.args = { enum: "variant", round: true };
|
|
98
106
|
|
|
107
|
+
export const Loading = (args) => ({
|
|
108
|
+
components: { UButton, URow },
|
|
109
|
+
setup() {
|
|
110
|
+
const loading = ref(false);
|
|
111
|
+
|
|
112
|
+
function toggleLoading() {
|
|
113
|
+
loading.value = !loading.value;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return { args, toggleLoading, loading };
|
|
117
|
+
},
|
|
118
|
+
template: `
|
|
119
|
+
<URow no-mobile>
|
|
120
|
+
<UButton
|
|
121
|
+
label="Loader demo"
|
|
122
|
+
:loading="loading"
|
|
123
|
+
/>
|
|
124
|
+
<UButton
|
|
125
|
+
label="Toggle loading"
|
|
126
|
+
variant="secondary"
|
|
127
|
+
color="green"
|
|
128
|
+
leftIcon="play_arrow"
|
|
129
|
+
@click="toggleLoading"
|
|
130
|
+
/>
|
|
131
|
+
</URow>
|
|
132
|
+
`,
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
export const Block = DefaultTemplate.bind({});
|
|
136
|
+
Block.args = { block: true };
|
|
137
|
+
|
|
99
138
|
export const Disabled = EnumVariantTemplate.bind({});
|
|
100
139
|
Disabled.args = { enum: "variant", disabled: true };
|
|
101
140
|
|
|
@@ -105,43 +144,64 @@ NoRing.args = { noRing: true };
|
|
|
105
144
|
export const Colors = ColorTemplate.bind({});
|
|
106
145
|
Colors.args = {};
|
|
107
146
|
|
|
108
|
-
export const
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
export const RightIcon = DefaultTemplate.bind({});
|
|
112
|
-
RightIcon.args = { rightIcon: "star" };
|
|
147
|
+
export const Square = DefaultTemplate.bind({});
|
|
148
|
+
Square.args = { square: true, icon: "filter_list" };
|
|
113
149
|
|
|
114
|
-
export const
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
LeftSlot.args = {
|
|
125
|
-
slotTemplate: `
|
|
126
|
-
<template #left>
|
|
127
|
-
<UIcon
|
|
128
|
-
name="archive"
|
|
129
|
-
color="red"
|
|
130
|
-
size="sm"
|
|
150
|
+
export const IconProps = (args) => ({
|
|
151
|
+
components: { UButton, URow },
|
|
152
|
+
setup() {
|
|
153
|
+
return { args };
|
|
154
|
+
},
|
|
155
|
+
template: `
|
|
156
|
+
<URow no-mobile>
|
|
157
|
+
<UButton
|
|
158
|
+
leftIcon="download"
|
|
159
|
+
label="Download"
|
|
131
160
|
/>
|
|
132
|
-
|
|
161
|
+
<UButton
|
|
162
|
+
rightIcon="menu"
|
|
163
|
+
label="Menu"
|
|
164
|
+
/>
|
|
165
|
+
</URow>
|
|
133
166
|
`,
|
|
134
|
-
};
|
|
167
|
+
});
|
|
135
168
|
|
|
136
|
-
export const
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
169
|
+
export const Slots = (args) => ({
|
|
170
|
+
components: { UButton, UIcon, URow },
|
|
171
|
+
setup() {
|
|
172
|
+
return { args };
|
|
173
|
+
},
|
|
174
|
+
template: `
|
|
175
|
+
<URow no-mobile>
|
|
176
|
+
<UButton v-bind="args" label="Add to favorite">
|
|
177
|
+
<template #left>
|
|
178
|
+
<UIcon
|
|
179
|
+
name="heart_plus"
|
|
180
|
+
color="green"
|
|
181
|
+
size="sm"
|
|
182
|
+
/>
|
|
183
|
+
</template>
|
|
184
|
+
</UButton>
|
|
185
|
+
|
|
186
|
+
<UButton v-bind="args" square>
|
|
187
|
+
<template #default>
|
|
188
|
+
<UIcon
|
|
189
|
+
name="settings"
|
|
190
|
+
color="green"
|
|
191
|
+
size="sm"
|
|
192
|
+
/>
|
|
193
|
+
</template>
|
|
194
|
+
</UButton>
|
|
195
|
+
|
|
196
|
+
<UButton v-bind="args" label="Delete">
|
|
197
|
+
<template #right>
|
|
198
|
+
<UIcon
|
|
199
|
+
name="delete"
|
|
200
|
+
color="green"
|
|
201
|
+
size="sm"
|
|
202
|
+
/>
|
|
203
|
+
</template>
|
|
204
|
+
</UButton>
|
|
205
|
+
</URow>
|
|
146
206
|
`,
|
|
147
|
-
};
|
|
207
|
+
});
|
|
@@ -50,7 +50,7 @@ const EnumVariantTemplate = (args, { argTypes }) => ({
|
|
|
50
50
|
return { args, options: argTypes[args.enum].options, prefixedOptions };
|
|
51
51
|
},
|
|
52
52
|
template: `
|
|
53
|
-
<URow>
|
|
53
|
+
<URow no-mobile>
|
|
54
54
|
<ULink
|
|
55
55
|
v-for="(option, index) in options"
|
|
56
56
|
:key="index"
|
|
@@ -71,26 +71,93 @@ Sizes.args = { enum: "size" };
|
|
|
71
71
|
export const Colors = EnumVariantTemplate.bind({});
|
|
72
72
|
Colors.args = { enum: "color" };
|
|
73
73
|
|
|
74
|
-
export const Types =
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
74
|
+
export const Types = (args) => ({
|
|
75
|
+
components: { ULink, URow },
|
|
76
|
+
setup() {
|
|
77
|
+
function getTypeLabel(type) {
|
|
78
|
+
switch (type) {
|
|
79
|
+
case "phone":
|
|
80
|
+
return "+1 (000) 123-4567";
|
|
81
|
+
case "email":
|
|
82
|
+
return "hello@vueless.com";
|
|
83
|
+
case "link":
|
|
84
|
+
return "Vueless.com";
|
|
85
|
+
}
|
|
86
|
+
}
|
|
79
87
|
|
|
80
|
-
|
|
81
|
-
|
|
88
|
+
function getTypeHref(type, label) {
|
|
89
|
+
switch (type) {
|
|
90
|
+
case "phone": {
|
|
91
|
+
const phoneNumber = label.replace(/\D/g, "");
|
|
92
|
+
|
|
93
|
+
return `+${phoneNumber}`;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
case "email":
|
|
97
|
+
return `${label}`;
|
|
98
|
+
case "link":
|
|
99
|
+
return "https://vueless.com/";
|
|
100
|
+
default:
|
|
101
|
+
return "#";
|
|
102
|
+
}
|
|
103
|
+
}
|
|
82
104
|
|
|
83
|
-
|
|
84
|
-
|
|
105
|
+
const options = ["phone", "email", "link"];
|
|
106
|
+
const links = options.map((type) => ({
|
|
107
|
+
type,
|
|
108
|
+
label: getTypeLabel(type),
|
|
109
|
+
href: getTypeHref(type, getTypeLabel(type)),
|
|
110
|
+
}));
|
|
85
111
|
|
|
86
|
-
|
|
87
|
-
|
|
112
|
+
return { args, links };
|
|
113
|
+
},
|
|
114
|
+
template: `
|
|
115
|
+
<URow>
|
|
116
|
+
<ULink
|
|
117
|
+
v-for="(link, index) in links"
|
|
118
|
+
:key="index"
|
|
119
|
+
v-bind="args"
|
|
120
|
+
:type="link.type"
|
|
121
|
+
:label="link.label"
|
|
122
|
+
:href="link.href"
|
|
123
|
+
target-blank
|
|
124
|
+
/>
|
|
125
|
+
</URow>
|
|
126
|
+
`,
|
|
127
|
+
});
|
|
88
128
|
|
|
89
|
-
export const
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}
|
|
129
|
+
export const UnderlineVariants = (args, { argTypes } = {}) => ({
|
|
130
|
+
components: { ULink, URow },
|
|
131
|
+
setup() {
|
|
132
|
+
const variants = [
|
|
133
|
+
{ name: "Default", props: {} },
|
|
134
|
+
{ name: "Underlined", props: { underlined: true } },
|
|
135
|
+
{ name: "Dashed", props: { dashed: true } },
|
|
136
|
+
];
|
|
137
|
+
|
|
138
|
+
const colors = argTypes.color.options;
|
|
139
|
+
|
|
140
|
+
return {
|
|
141
|
+
args,
|
|
142
|
+
variants,
|
|
143
|
+
colors,
|
|
144
|
+
};
|
|
145
|
+
},
|
|
146
|
+
template: `
|
|
147
|
+
<div v-for="variant in variants" :key="variant.name" class="mb-8">
|
|
148
|
+
<div class="text-sm font-medium mb-2">{{ variant.name }}</div>
|
|
149
|
+
<URow no-mobile>
|
|
150
|
+
<ULink
|
|
151
|
+
v-for="color in colors"
|
|
152
|
+
:key="color"
|
|
153
|
+
v-bind="variant.props"
|
|
154
|
+
:color="color"
|
|
155
|
+
:label="color"
|
|
156
|
+
/>
|
|
157
|
+
</URow>
|
|
158
|
+
</div>
|
|
159
|
+
`,
|
|
160
|
+
});
|
|
94
161
|
|
|
95
162
|
export const Disabled = DefaultTemplate.bind({});
|
|
96
163
|
Disabled.args = { disabled: true };
|
|
@@ -98,8 +165,11 @@ Disabled.args = { disabled: true };
|
|
|
98
165
|
export const NoRing = DefaultTemplate.bind({});
|
|
99
166
|
NoRing.args = { noRing: true };
|
|
100
167
|
|
|
101
|
-
export const
|
|
102
|
-
|
|
168
|
+
export const Block = DefaultTemplate.bind({});
|
|
169
|
+
Block.args = { block: true, config: { wrapper: "border-2 border-dashed border-green-500 p-2" } };
|
|
170
|
+
|
|
171
|
+
export const DefaultSlot = DefaultTemplate.bind({});
|
|
172
|
+
DefaultSlot.args = {
|
|
103
173
|
slotTemplate: `
|
|
104
174
|
<template #default>
|
|
105
175
|
<UButton label="Text" />
|
|
@@ -107,20 +177,24 @@ SlotDefault.args = {
|
|
|
107
177
|
`,
|
|
108
178
|
};
|
|
109
179
|
|
|
110
|
-
export const
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
<
|
|
124
|
-
|
|
180
|
+
export const LeftAndRightSlots = (args) => ({
|
|
181
|
+
components: { ULink, UIcon, URow },
|
|
182
|
+
setup() {
|
|
183
|
+
return { args };
|
|
184
|
+
},
|
|
185
|
+
template: `
|
|
186
|
+
<URow no-mobile>
|
|
187
|
+
<ULink label="Download">
|
|
188
|
+
<template #left>
|
|
189
|
+
<UIcon name="download" size="xs" color="green" />
|
|
190
|
+
</template>
|
|
191
|
+
</ULink>
|
|
192
|
+
|
|
193
|
+
<ULink label="Open">
|
|
194
|
+
<template #right>
|
|
195
|
+
<UIcon name="open_in_new" size="xs" color="green" />
|
|
196
|
+
</template>
|
|
197
|
+
</ULink>
|
|
198
|
+
</URow>
|
|
125
199
|
`,
|
|
126
|
-
};
|
|
200
|
+
});
|