vueless 0.0.255 → 0.0.257
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.autoPosition/index.js +4 -6
- package/composable.ui/index.js +21 -4
- package/package.json +1 -1
- package/ui.button/composables/attrs.composable.js +11 -14
- package/ui.button-link/composables/attrs.composable.js +8 -11
- package/ui.button-toggle/composables/attrs.composable.js +5 -5
- package/ui.button-toggle-item/composables/attrs.composable.js +5 -5
- package/ui.form-date-picker/configs/default.config.js +2 -2
- package/ui.form-date-picker-range/configs/default.config.js +2 -2
- package/web-types.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { computed, toValue } from "vue";
|
|
1
|
+
import { computed, toValue, ref } from "vue";
|
|
2
2
|
|
|
3
3
|
export const POSITION = {
|
|
4
4
|
left: "left",
|
|
@@ -14,10 +14,8 @@ export function useAutoPosition(anchorElement, targetElement, position, preferre
|
|
|
14
14
|
const localPosition = computed(() => toValue(position));
|
|
15
15
|
const localPreferredPosition = computed(() => toValue(preferredPosition));
|
|
16
16
|
|
|
17
|
-
const preferredOpenDirectionY =
|
|
18
|
-
|
|
19
|
-
});
|
|
20
|
-
const preferredOpenDirectionX = computed(() => localPreferredPosition.value?.x || POSITION.left);
|
|
17
|
+
const preferredOpenDirectionY = ref(localPreferredPosition.value?.y || POSITION.bottom);
|
|
18
|
+
const preferredOpenDirectionX = ref(localPreferredPosition.value?.x || POSITION.left);
|
|
21
19
|
|
|
22
20
|
const isTop = computed(() => {
|
|
23
21
|
if (localPosition.value.y !== POSITION.auto) {
|
|
@@ -45,7 +43,7 @@ export function useAutoPosition(anchorElement, targetElement, position, preferre
|
|
|
45
43
|
|
|
46
44
|
const isRight = computed(() => {
|
|
47
45
|
if (localPosition.value.x !== POSITION.auto) {
|
|
48
|
-
return localPosition.value.
|
|
46
|
+
return localPosition.value.x === POSITION.right;
|
|
49
47
|
}
|
|
50
48
|
|
|
51
49
|
return preferredOpenDirectionX.value === POSITION.right;
|
package/composable.ui/index.js
CHANGED
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
} from "../service.ui";
|
|
21
21
|
|
|
22
22
|
import { cloneDeep } from "../service.helper";
|
|
23
|
-
import { STRATEGY_TYPE, SYSTEM_CONFIG_KEY } from "../constants";
|
|
23
|
+
import { STRATEGY_TYPE, CVA_CONFIG_KEY, SYSTEM_CONFIG_KEY } from "../constants";
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
Merging component configs in a given sequence (bigger number = bigger priority):
|
|
@@ -88,12 +88,15 @@ export default function useUI(defaultConfig = {}, propsConfigGetter = null, topL
|
|
|
88
88
|
|
|
89
89
|
const isTopLevelClassKey = configKey === (topLevelClassKey || firstClassKey);
|
|
90
90
|
const attrClass = isTopLevelClassKey && !nestedComponent ? attrs.class : "";
|
|
91
|
-
// TODO: Uncomment and add into `cx` when getAttrs as a function will be resolved.
|
|
92
|
-
// const classes = toValue(options?.classes) || getBaseClasses(configKeyValue);
|
|
93
91
|
|
|
92
|
+
// TODO: remove `getBaseClasses(configKeyValue)` after migration to `setDynamicVars`
|
|
94
93
|
vuelessAttrs.value = {
|
|
95
94
|
...commonAttrs,
|
|
96
|
-
class: cx([
|
|
95
|
+
class: cx([
|
|
96
|
+
getBaseClasses(configKeyValue),
|
|
97
|
+
getBaseClasses(toValue(options?.classes)),
|
|
98
|
+
attrClass,
|
|
99
|
+
]),
|
|
97
100
|
...((isObject && configAttrs) || {}),
|
|
98
101
|
};
|
|
99
102
|
}
|
|
@@ -106,6 +109,7 @@ export default function useUI(defaultConfig = {}, propsConfigGetter = null, topL
|
|
|
106
109
|
getAttrs,
|
|
107
110
|
getColor,
|
|
108
111
|
setColor,
|
|
112
|
+
isCVA,
|
|
109
113
|
isSystemKey,
|
|
110
114
|
hasSlotContent,
|
|
111
115
|
};
|
|
@@ -404,6 +408,19 @@ function isSystemKey(key) {
|
|
|
404
408
|
);
|
|
405
409
|
}
|
|
406
410
|
|
|
411
|
+
/**
|
|
412
|
+
Check is config contains default CVA keys.
|
|
413
|
+
@param { Object | String } config
|
|
414
|
+
@returns { Boolean }
|
|
415
|
+
*/
|
|
416
|
+
function isCVA(config) {
|
|
417
|
+
if (typeof config !== "object") return false;
|
|
418
|
+
|
|
419
|
+
return Object.values(CVA_CONFIG_KEY).some((value) =>
|
|
420
|
+
Object.keys(config).some((key) => key === value),
|
|
421
|
+
);
|
|
422
|
+
}
|
|
423
|
+
|
|
407
424
|
/**
|
|
408
425
|
Check if slot defined, and have a content.
|
|
409
426
|
@param slot
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@ import defaultConfig from "../configs/default.config";
|
|
|
5
5
|
|
|
6
6
|
export default function useAttrs(props) {
|
|
7
7
|
const slots = useSlots();
|
|
8
|
-
const { config, getAttrs, getColor, setColor, hasSlotContent, isSystemKey } = useUI(
|
|
8
|
+
const { config, getAttrs, getColor, setColor, hasSlotContent, isSystemKey, isCVA } = useUI(
|
|
9
9
|
defaultConfig,
|
|
10
10
|
() => props.config,
|
|
11
11
|
);
|
|
@@ -15,22 +15,19 @@ export default function useAttrs(props) {
|
|
|
15
15
|
if (isSystemKey(key)) continue;
|
|
16
16
|
|
|
17
17
|
const classes = computed(() => {
|
|
18
|
-
|
|
18
|
+
let value = config.value[key];
|
|
19
19
|
|
|
20
|
-
if (value
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}),
|
|
29
|
-
props.color,
|
|
30
|
-
);
|
|
20
|
+
if (isCVA(value)) {
|
|
21
|
+
value = cva(value)({
|
|
22
|
+
...props,
|
|
23
|
+
color: getColor(props.color),
|
|
24
|
+
square: props.loading || props.square,
|
|
25
|
+
iconLeft: Boolean(props.iconLeft) || hasSlotContent(slots["icon-left"]),
|
|
26
|
+
iconRight: Boolean(props.iconRight) || hasSlotContent(slots["icon-right"]),
|
|
27
|
+
});
|
|
31
28
|
}
|
|
32
29
|
|
|
33
|
-
return
|
|
30
|
+
return setColor(value, props.color);
|
|
34
31
|
});
|
|
35
32
|
|
|
36
33
|
attrs[`${key}Attrs`] = getAttrs(key, { classes });
|
|
@@ -6,7 +6,7 @@ import defaultConfig from "../configs/default.config";
|
|
|
6
6
|
export default function useAttrs(props, { isActive, isExactActive }) {
|
|
7
7
|
const slots = useSlots();
|
|
8
8
|
|
|
9
|
-
const { config, getAttrs, hasSlotContent, getColor, setColor, isSystemKey } = useUI(
|
|
9
|
+
const { config, getAttrs, hasSlotContent, getColor, setColor, isSystemKey, isCVA } = useUI(
|
|
10
10
|
defaultConfig,
|
|
11
11
|
() => props.config,
|
|
12
12
|
);
|
|
@@ -16,19 +16,16 @@ export default function useAttrs(props, { isActive, isExactActive }) {
|
|
|
16
16
|
if (isSystemKey(key)) continue;
|
|
17
17
|
|
|
18
18
|
const classes = computed(() => {
|
|
19
|
-
|
|
19
|
+
let value = config.value[key];
|
|
20
20
|
|
|
21
|
-
if (value
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}),
|
|
27
|
-
props.color,
|
|
28
|
-
);
|
|
21
|
+
if (isCVA(value)) {
|
|
22
|
+
value = cva(value)({
|
|
23
|
+
...props,
|
|
24
|
+
color: getColor(props.color),
|
|
25
|
+
});
|
|
29
26
|
}
|
|
30
27
|
|
|
31
|
-
return
|
|
28
|
+
return setColor(value, props.color);
|
|
32
29
|
});
|
|
33
30
|
|
|
34
31
|
attrs[`${key}Attrs`] = getAttrs(key, { classes });
|
|
@@ -4,7 +4,7 @@ import { cva } from "../../service.ui";
|
|
|
4
4
|
import defaultConfig from "../configs/default.config";
|
|
5
5
|
|
|
6
6
|
export default function useAttrs(props) {
|
|
7
|
-
const { config, getAttrs, hasSlotContent, isSystemKey } = useUI(
|
|
7
|
+
const { config, getAttrs, hasSlotContent, isSystemKey, isCVA } = useUI(
|
|
8
8
|
defaultConfig,
|
|
9
9
|
() => props.config,
|
|
10
10
|
);
|
|
@@ -14,15 +14,15 @@ export default function useAttrs(props) {
|
|
|
14
14
|
if (isSystemKey(key)) continue;
|
|
15
15
|
|
|
16
16
|
const classes = computed(() => {
|
|
17
|
-
|
|
17
|
+
let value = config.value[key];
|
|
18
18
|
|
|
19
|
-
if (value
|
|
20
|
-
|
|
19
|
+
if (isCVA(value)) {
|
|
20
|
+
value = cva(value)({
|
|
21
21
|
...props,
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
return
|
|
25
|
+
return value;
|
|
26
26
|
});
|
|
27
27
|
|
|
28
28
|
attrs[`${key}Attrs`] = getAttrs(key, { classes });
|
|
@@ -4,7 +4,7 @@ import { cva } from "../../service.ui";
|
|
|
4
4
|
import defaultConfig from "../configs/default.config";
|
|
5
5
|
|
|
6
6
|
export default function useAttrs(props, { isSelected, separated, variant }) {
|
|
7
|
-
const { config, getAttrs, isSystemKey, hasSlotContent } = useUI(
|
|
7
|
+
const { config, getAttrs, isSystemKey, hasSlotContent, isCVA } = useUI(
|
|
8
8
|
defaultConfig,
|
|
9
9
|
() => props.config,
|
|
10
10
|
);
|
|
@@ -15,10 +15,10 @@ export default function useAttrs(props, { isSelected, separated, variant }) {
|
|
|
15
15
|
if (isSystemKey(key)) continue;
|
|
16
16
|
|
|
17
17
|
const classes = computed(() => {
|
|
18
|
-
|
|
18
|
+
let value = config.value[key];
|
|
19
19
|
|
|
20
|
-
if (value
|
|
21
|
-
|
|
20
|
+
if (isCVA(value)) {
|
|
21
|
+
value = cva(value)({
|
|
22
22
|
...props,
|
|
23
23
|
variant: toValue(variant),
|
|
24
24
|
separated: toValue(separated),
|
|
@@ -26,7 +26,7 @@ export default function useAttrs(props, { isSelected, separated, variant }) {
|
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
return
|
|
29
|
+
return value;
|
|
30
30
|
});
|
|
31
31
|
|
|
32
32
|
attrs[`${key}Attrs`] = getAttrs(key, { classes });
|
|
@@ -18,8 +18,8 @@ export default /*tw*/ {
|
|
|
18
18
|
base: "absolute z-40 my-2 w-80 overflow-hidden rounded-dynamic border border-brand-300 bg-white p-2 shadow focus:outline-none",
|
|
19
19
|
variants: {
|
|
20
20
|
openDirectionX: {
|
|
21
|
-
left: "
|
|
22
|
-
right: "
|
|
21
|
+
left: "right-0",
|
|
22
|
+
right: "left-0",
|
|
23
23
|
},
|
|
24
24
|
openDirectionY: {
|
|
25
25
|
top: "bottom-full mt-0",
|