vueless 0.0.223 → 0.0.225
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/composable.ui/index.js +1 -1
- package/package.json +1 -1
- package/ui.button-toggle/configs/default.config.js +11 -10
- package/ui.button-toggle/index.stories.js +7 -0
- package/ui.button-toggle/index.vue +11 -10
- package/ui.button-toggle-item/composables/attrs.composable.js +4 -28
- package/ui.button-toggle-item/configs/default.config.js +23 -11
- package/ui.button-toggle-item/index.vue +38 -30
- package/ui.form-calendar/composables/attrs.composable.js +1 -0
- package/ui.form-date-picker/composables/attrs.composable.js +7 -15
- package/ui.form-date-picker/configs/default.config.js +12 -12
- package/ui.form-date-picker/index.vue +2 -8
- package/ui.form-input-search/configs/default.config.js +2 -1
- package/web-types.json +1 -1
package/composable.ui/index.js
CHANGED
|
@@ -92,7 +92,7 @@ export default function useUI(defaultConfig = {}, propsConfigGetter = null, topL
|
|
|
92
92
|
|
|
93
93
|
watch(config, updateVuelessAttrs, { immediate: true });
|
|
94
94
|
watch(props, updateVuelessAttrs);
|
|
95
|
-
options?.classes && watch(options?.classes, updateVuelessAttrs);
|
|
95
|
+
options?.classes?.value && watch(options?.classes, updateVuelessAttrs);
|
|
96
96
|
|
|
97
97
|
function updateVuelessAttrs() {
|
|
98
98
|
const configKeyValue = config.value[configKey];
|
package/package.json
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
export default /*tw*/ {
|
|
2
|
+
label: {
|
|
3
|
+
component: "{ULabel}",
|
|
4
|
+
base: "flex flex-wrap",
|
|
5
|
+
variants: {
|
|
6
|
+
block: {
|
|
7
|
+
true: "w-full",
|
|
8
|
+
},
|
|
9
|
+
},
|
|
10
|
+
},
|
|
2
11
|
items: {
|
|
3
12
|
base: "flex flex-wrap",
|
|
4
13
|
variants: {
|
|
@@ -13,8 +22,8 @@ export default /*tw*/ {
|
|
|
13
22
|
separated: {
|
|
14
23
|
false: `
|
|
15
24
|
flex-nowrap -space-x-px gap-0
|
|
16
|
-
[&>:first-child]:rounded-l-lg
|
|
17
|
-
[&>:first-child>*>*]:rounded-l-lg
|
|
25
|
+
[&>:first-child]:rounded-l-lg [&>:last-child]:rounded-r-lg
|
|
26
|
+
[&>:first-child>*>*]:rounded-l-lg [&>:last-child>*>*]:rounded-r-lg
|
|
18
27
|
`,
|
|
19
28
|
},
|
|
20
29
|
},
|
|
@@ -23,14 +32,6 @@ export default /*tw*/ {
|
|
|
23
32
|
{ separated: false, multiple: true, class: "space-x-px" },
|
|
24
33
|
],
|
|
25
34
|
},
|
|
26
|
-
label: {
|
|
27
|
-
base: "{ULabel} flex flex-wrap",
|
|
28
|
-
variants: {
|
|
29
|
-
block: {
|
|
30
|
-
true: "w-full",
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
35
|
item: "{UToggleItem}",
|
|
35
36
|
defaultVariants: {
|
|
36
37
|
variant: "primary",
|
|
@@ -148,8 +148,15 @@ Default.args = {
|
|
|
148
148
|
name: "Default",
|
|
149
149
|
};
|
|
150
150
|
|
|
151
|
+
export const Disabled = DefaultTemplate.bind({});
|
|
152
|
+
Disabled.args = {
|
|
153
|
+
name: "Disabled",
|
|
154
|
+
disabled: true,
|
|
155
|
+
};
|
|
156
|
+
|
|
151
157
|
export const label = DefaultTemplate.bind({});
|
|
152
158
|
label.args = {
|
|
159
|
+
name: "Label",
|
|
153
160
|
label: "Label",
|
|
154
161
|
description: "description",
|
|
155
162
|
};
|
|
@@ -5,8 +5,9 @@
|
|
|
5
5
|
:description="description"
|
|
6
6
|
:align="labelAlign"
|
|
7
7
|
:disabled="disabled"
|
|
8
|
-
|
|
8
|
+
centred
|
|
9
9
|
v-bind="labelAttrs"
|
|
10
|
+
:data-cy="dataCy"
|
|
10
11
|
>
|
|
11
12
|
<div v-bind="itemsAttrs">
|
|
12
13
|
<!-- @slot Use it to add UToggleItem directly. -->
|
|
@@ -223,15 +224,15 @@ function updateSelectedValue(value, checked) {
|
|
|
223
224
|
}
|
|
224
225
|
}
|
|
225
226
|
|
|
226
|
-
provide("
|
|
227
|
-
provide("
|
|
228
|
-
provide("
|
|
229
|
-
provide("
|
|
230
|
-
provide("
|
|
231
|
-
provide("
|
|
232
|
-
provide("
|
|
233
|
-
provide("
|
|
234
|
-
provide("
|
|
227
|
+
provide("getToggleName", () => props.name);
|
|
228
|
+
provide("getToggleType", () => type.value);
|
|
229
|
+
provide("getToggleSize", () => props.size);
|
|
230
|
+
provide("getTogglePill", () => props.pill);
|
|
231
|
+
provide("getToggleBlock", () => props.block);
|
|
232
|
+
provide("getToggleSquare", () => props.square);
|
|
233
|
+
provide("getToggleVariant", () => props.variant);
|
|
234
|
+
provide("getToggleDisabled", () => props.disabled);
|
|
235
|
+
provide("getToggleSeparated", () => props.separated);
|
|
235
236
|
|
|
236
237
|
provide("toggleSelectedValue", {
|
|
237
238
|
selectedValue: readonly(selectedValue),
|
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
import { computed, toValue } from "vue";
|
|
2
2
|
import useUI from "../../composable.ui";
|
|
3
|
-
import {
|
|
3
|
+
import { cva } from "../../service.ui";
|
|
4
4
|
import defaultConfig from "../configs/default.config";
|
|
5
5
|
|
|
6
|
-
export default function useAttrs(props, {
|
|
6
|
+
export default function useAttrs(props, { isSelected, separated, variant }) {
|
|
7
7
|
const { config, getAttrs, isSystemKey, hasSlotContent } = useUI(
|
|
8
8
|
defaultConfig,
|
|
9
9
|
() => props.config,
|
|
10
10
|
);
|
|
11
11
|
|
|
12
|
-
const skipKeys = ["selected"];
|
|
13
|
-
|
|
14
12
|
const attrs = {};
|
|
15
13
|
|
|
16
14
|
for (const key in defaultConfig) {
|
|
17
|
-
if (isSystemKey(key)
|
|
15
|
+
if (isSystemKey(key)) continue;
|
|
18
16
|
|
|
19
17
|
const classes = computed(() => {
|
|
20
18
|
const value = config.value[key];
|
|
@@ -24,6 +22,7 @@ export default function useAttrs(props, { selectedValue, separated, variant }) {
|
|
|
24
22
|
...props,
|
|
25
23
|
variant: toValue(variant),
|
|
26
24
|
separated: toValue(separated),
|
|
25
|
+
selected: isSelected.value,
|
|
27
26
|
});
|
|
28
27
|
}
|
|
29
28
|
|
|
@@ -31,29 +30,6 @@ export default function useAttrs(props, { selectedValue, separated, variant }) {
|
|
|
31
30
|
});
|
|
32
31
|
|
|
33
32
|
attrs[`${key}Attrs`] = getAttrs(key, { classes });
|
|
34
|
-
|
|
35
|
-
if (key === "button") {
|
|
36
|
-
const selectedClasses = computed(() =>
|
|
37
|
-
cva(config.value.selected)({
|
|
38
|
-
...props,
|
|
39
|
-
variant: toValue(variant),
|
|
40
|
-
separated: toValue(separated),
|
|
41
|
-
}),
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
const buttonAttrs = attrs[`${key}Attrs`];
|
|
45
|
-
|
|
46
|
-
attrs[`${key}Attrs`] = computed(() => {
|
|
47
|
-
const isSelected = Array.isArray(selectedValue?.value)
|
|
48
|
-
? selectedValue?.value?.includes(props.value)
|
|
49
|
-
: selectedValue?.value === props.value;
|
|
50
|
-
|
|
51
|
-
return {
|
|
52
|
-
...buttonAttrs.value,
|
|
53
|
-
class: cx([buttonAttrs.value.class, isSelected && selectedClasses.value]),
|
|
54
|
-
};
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
33
|
}
|
|
58
34
|
|
|
59
35
|
return {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export default /*tw*/ {
|
|
2
2
|
button: {
|
|
3
|
+
component: "{UButton}",
|
|
3
4
|
base: `
|
|
4
|
-
|
|
5
|
+
border-gray-300 font-normal
|
|
5
6
|
hover:text-brand-600 hover:border-brand-600 hover:relative hover:z-10
|
|
6
7
|
focus:text-brand-600 focus:border-brand-600 focus:relative focus:z-10 focus:ring-brand-600 focus-within:ring-brand-600
|
|
7
8
|
active:text-brand-700 active:border-brand-700 active:relative active:z-10
|
|
@@ -21,18 +22,29 @@ export default /*tw*/ {
|
|
|
21
22
|
`,
|
|
22
23
|
},
|
|
23
24
|
},
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
variants: {
|
|
29
|
-
variant: {
|
|
30
|
-
primary: "!text-white bg-brand-600 border-brand-600 disabled:border-brand-600",
|
|
31
|
-
secondary: "text-brand-600 border-brand-600 disabled:border-brand-600 bg-brand-600 bg-opacity-10",
|
|
32
|
-
thirdary: " bg-brand-600 bg-opacity-20 hover:bg-opacity-20 focus:bg-opacity-20",
|
|
25
|
+
compoundVariants: [
|
|
26
|
+
{
|
|
27
|
+
selected: true,
|
|
28
|
+
class: "relative disabled:z-10",
|
|
33
29
|
},
|
|
34
|
-
|
|
30
|
+
{
|
|
31
|
+
selected: true,
|
|
32
|
+
variant: "primary",
|
|
33
|
+
class: "!text-white bg-brand-600 border-brand-600 disabled:border-brand-600",
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
selected: true,
|
|
37
|
+
variant: "secondary",
|
|
38
|
+
class: "text-brand-600 border-brand-600 disabled:border-brand-600 bg-brand-600 bg-opacity-10",
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
selected: true,
|
|
42
|
+
variant: "thirdary",
|
|
43
|
+
class: "bg-brand-600 bg-opacity-20 hover:bg-opacity-20 focus:bg-opacity-20",
|
|
44
|
+
},
|
|
45
|
+
],
|
|
35
46
|
},
|
|
47
|
+
input: "p-0 m-0 size-0 invisible absolute",
|
|
36
48
|
defaultVariants: {
|
|
37
49
|
variant: "primary",
|
|
38
50
|
type: "radio",
|
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
color="grayscale"
|
|
6
6
|
variant="secondary"
|
|
7
7
|
:label="label"
|
|
8
|
-
:size="
|
|
9
|
-
:pill="
|
|
10
|
-
:block="
|
|
11
|
-
:square="
|
|
12
|
-
:disabled="
|
|
8
|
+
:size="getToggleSize()"
|
|
9
|
+
:pill="getTogglePill()"
|
|
10
|
+
:block="getToggleBlock()"
|
|
11
|
+
:square="getToggleSquare()"
|
|
12
|
+
:disabled="getToggleDisabled()"
|
|
13
13
|
v-bind="buttonAttrs"
|
|
14
14
|
@click="onClickSetValue"
|
|
15
15
|
>
|
|
@@ -22,12 +22,13 @@
|
|
|
22
22
|
<input
|
|
23
23
|
:id="id"
|
|
24
24
|
v-model="selectedItem"
|
|
25
|
-
:name="
|
|
26
|
-
:type="
|
|
25
|
+
:name="getToggleName()"
|
|
26
|
+
:type="getToggleType()"
|
|
27
27
|
:value="value"
|
|
28
|
-
:disabled="
|
|
28
|
+
:disabled="getToggleDisabled()"
|
|
29
29
|
v-bind="inputAttrs"
|
|
30
30
|
/>
|
|
31
|
+
{{ label }}
|
|
31
32
|
<!-- @slot Use it to add something instead of the text. -->
|
|
32
33
|
<slot name="default" />
|
|
33
34
|
</template>
|
|
@@ -40,7 +41,7 @@
|
|
|
40
41
|
</template>
|
|
41
42
|
|
|
42
43
|
<script setup>
|
|
43
|
-
import { inject, onMounted, ref
|
|
44
|
+
import { computed, inject, onMounted, ref } from "vue";
|
|
44
45
|
|
|
45
46
|
import UButton from "../ui.button";
|
|
46
47
|
import UIService, { getRandomId } from "../service.ui";
|
|
@@ -121,37 +122,44 @@ const emit = defineEmits([
|
|
|
121
122
|
"update:modelValue",
|
|
122
123
|
]);
|
|
123
124
|
|
|
124
|
-
|
|
125
|
-
const
|
|
126
|
-
const
|
|
127
|
-
const
|
|
128
|
-
const
|
|
129
|
-
const
|
|
130
|
-
const
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
const
|
|
125
|
+
/* eslint-disable prettier/prettier, vue/max-len */
|
|
126
|
+
const getToggleName = inject("getToggleName", () => "toggle");
|
|
127
|
+
const getToggleType = inject("getToggleType", () => UIService.get(defaultConfig, UToggleItem).default.type);
|
|
128
|
+
const getToggleSize = inject("getToggleSize", () => UIService.get(defaultConfig, UToggleItem).default.size);
|
|
129
|
+
const getTogglePill = inject("getTogglePill", () => UIService.get(defaultConfig, UToggleItem).default.pill);
|
|
130
|
+
const getToggleBlock = inject("getToggleBlock", () => UIService.get(defaultConfig, UToggleItem).default.block);
|
|
131
|
+
const getToggleSquare = inject("getToggleSquare", () => UIService.get(defaultConfig, UToggleItem).default.square);
|
|
132
|
+
const getToggleVariant = inject("getToggleVariant",() => UIService.get(defaultConfig, UToggleItem).default.variant);
|
|
133
|
+
const getToggleSeparated = inject("getToggleSeparated", () => true);
|
|
134
|
+
const getToggleDisabled = inject("getToggleDisabled", () => props.disabled || UIService.get(defaultConfig, UToggleItem).default.disabled);
|
|
135
|
+
/* eslint-enaable prettier/prettier, vue/max-len */
|
|
134
136
|
|
|
135
137
|
const { selectedValue, updateSelectedValue } = inject("toggleSelectedValue", {});
|
|
136
138
|
|
|
137
139
|
const selectedItem = ref("");
|
|
138
140
|
|
|
139
|
-
const
|
|
141
|
+
const isSelected = computed(() => {
|
|
142
|
+
return Array.isArray(selectedValue?.value)
|
|
143
|
+
? selectedValue?.value?.includes(props.value)
|
|
144
|
+
: selectedValue?.value === props.value;
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
const { buttonAttrs, inputAttrs } = useAttrs(props, {
|
|
148
|
+
isSelected,
|
|
149
|
+
separated: getToggleSeparated,
|
|
150
|
+
variant: getToggleVariant
|
|
151
|
+
});
|
|
140
152
|
|
|
141
153
|
onMounted(() => {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
selectedItem.value = selectedValue
|
|
146
|
-
? selectedValue.value.includes(props.value)
|
|
147
|
-
: selectedItem.value;
|
|
148
|
-
}
|
|
154
|
+
selectedItem.value = getToggleType() === TYPE_RADIO
|
|
155
|
+
? selectedValue?.value || selectedItem.value
|
|
156
|
+
: selectedValue?.value?.includes(props.value) || selectedItem.value;
|
|
149
157
|
});
|
|
150
158
|
|
|
151
159
|
function onClickSetValue() {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
160
|
+
selectedItem.value = getToggleType() === TYPE_RADIO
|
|
161
|
+
? props.value
|
|
162
|
+
: selectedValue?.value?.includes(props.value) || selectedItem.value;
|
|
155
163
|
|
|
156
164
|
updateSelectedValue && updateSelectedValue(props.value, !selectedItem.value);
|
|
157
165
|
|
|
@@ -45,6 +45,7 @@ export default function useAttrs(props) {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
// TODO: Need to find other solution
|
|
48
|
+
// classes is not reactive here, which may cause problems in styling by `config` prop
|
|
48
49
|
if (key === "day") {
|
|
49
50
|
attrs[`${key}Attrs`] = (classes) => {
|
|
50
51
|
return getAttrs("day", { classes }).value;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import useUI from "../../composable.ui";
|
|
2
|
-
import { cva
|
|
2
|
+
import { cva } from "../../service.ui";
|
|
3
3
|
import { computed, watchEffect } from "vue";
|
|
4
4
|
|
|
5
5
|
import defaultConfig from "../configs/default.config";
|
|
@@ -18,6 +18,8 @@ export default function useAttrs(props, { isShownCalendar, isTop, isRight }) {
|
|
|
18
18
|
if (value.variants || value.compoundVariants) {
|
|
19
19
|
return cva(value)({
|
|
20
20
|
...props,
|
|
21
|
+
openDirectionY: isTop.value ? POSITION.top : POSITION.bottom,
|
|
22
|
+
openDirectionX: isRight.value ? POSITION.right : POSITION.left,
|
|
21
23
|
});
|
|
22
24
|
}
|
|
23
25
|
|
|
@@ -31,24 +33,14 @@ export default function useAttrs(props, { isShownCalendar, isTop, isRight }) {
|
|
|
31
33
|
|
|
32
34
|
attrs[`${key}Attrs`] = computed(() => ({
|
|
33
35
|
...inputAttrs.value,
|
|
34
|
-
|
|
36
|
+
config: {
|
|
37
|
+
...inputAttrs.value.config,
|
|
38
|
+
...(isShownCalendar.value ? config.value.inputFocused : {}),
|
|
39
|
+
},
|
|
35
40
|
}));
|
|
36
41
|
}
|
|
37
42
|
|
|
38
43
|
if (key === "calendar") {
|
|
39
|
-
const calendarAttrs = attrs[`${key}Attrs`];
|
|
40
|
-
|
|
41
|
-
attrs[`${key}Attrs`] = computed(() => ({
|
|
42
|
-
...calendarAttrs.value,
|
|
43
|
-
class: cx([
|
|
44
|
-
cva(config.value.calendar.wrapper)({
|
|
45
|
-
openDirectionY: isTop.value ? POSITION.top : POSITION.bottom,
|
|
46
|
-
openDirectionX: isRight.value ? POSITION.right : POSITION.left,
|
|
47
|
-
}),
|
|
48
|
-
calendarAttrs.value.class,
|
|
49
|
-
]),
|
|
50
|
-
}));
|
|
51
|
-
|
|
52
44
|
// This watcher rewrites default calendar locales with datepicker range locales
|
|
53
45
|
// Watcher will not rewrite custom calendar locales
|
|
54
46
|
watchEffect(() => {
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
export default /*tw*/ {
|
|
2
2
|
wrapper: "relative",
|
|
3
|
-
input: "",
|
|
4
|
-
|
|
3
|
+
input: "{UInput}",
|
|
4
|
+
inputFocused: {
|
|
5
|
+
component: "{UInput}",
|
|
5
6
|
block: "ring-4 ring-brand-600/[.15] border-brand-500 hover:border-brand-500",
|
|
6
7
|
},
|
|
7
8
|
calendar: {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
},
|
|
9
|
+
component: "{UCalendar}",
|
|
10
|
+
base: "absolute z-40 my-2",
|
|
11
|
+
variants: {
|
|
12
|
+
openDirectionX: {
|
|
13
|
+
left: "left-0",
|
|
14
|
+
right: "right-0",
|
|
15
|
+
},
|
|
16
|
+
openDirectionY: {
|
|
17
|
+
top: "bottom-full mt-0",
|
|
18
18
|
},
|
|
19
19
|
},
|
|
20
20
|
},
|
|
@@ -251,14 +251,8 @@ const calendarWrapperRef = computed(() => calendarRef?.value?.wrapperRef);
|
|
|
251
251
|
const { isTop, isRight, adjustPositionY, adjustPositionX } = useAdjustElementPosition(
|
|
252
252
|
wrapperRef,
|
|
253
253
|
calendarWrapperRef,
|
|
254
|
-
{
|
|
255
|
-
|
|
256
|
-
y: props.openDirectionY,
|
|
257
|
-
},
|
|
258
|
-
{
|
|
259
|
-
x: "left",
|
|
260
|
-
y: "bottom",
|
|
261
|
-
},
|
|
254
|
+
{ x: props.openDirectionX, y: props.openDirectionY },
|
|
255
|
+
{ x: "left", y: "bottom" },
|
|
262
256
|
);
|
|
263
257
|
|
|
264
258
|
defineExpose({
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export default /*tw*/ {
|
|
2
2
|
input: {
|
|
3
|
+
component: "{UInput}",
|
|
3
4
|
wrapper: "relative flex items-center justify-between w-full rounded-lg bg-gray-900 bg-opacity-5",
|
|
4
|
-
input: "
|
|
5
|
+
input: "w-full",
|
|
5
6
|
label: "w-full",
|
|
6
7
|
rightSlot: "pr-0",
|
|
7
8
|
leftSlot: "pl-0",
|