vueless 0.0.566 → 0.0.567
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 +1 -1
- package/package.json +1 -1
- package/ui.button/UButton.vue +2 -14
- package/ui.button/types.ts +2 -1
- package/utils/ui.ts +28 -2
- package/web-types.json +2 -3
package/composables/useUI.ts
CHANGED
|
@@ -34,7 +34,7 @@ import type {
|
|
|
34
34
|
*/
|
|
35
35
|
export default function useUI<T>(
|
|
36
36
|
defaultConfig: T & Component,
|
|
37
|
-
propsConfigGetter?: () =>
|
|
37
|
+
propsConfigGetter?: () => T & Component,
|
|
38
38
|
topLevelClassKey?: string,
|
|
39
39
|
mutatedProps?: ComputedRef,
|
|
40
40
|
): UseUI<T> {
|
package/package.json
CHANGED
package/ui.button/UButton.vue
CHANGED
|
@@ -4,7 +4,7 @@ import { computed, ref, watchEffect, useId, watch, useSlots } from "vue";
|
|
|
4
4
|
import useUI from "../composables/useUI.ts";
|
|
5
5
|
import { useDarkMode } from "../composables/useDarkMode.ts";
|
|
6
6
|
import { hasSlotContent } from "../utils/helper.ts";
|
|
7
|
-
import {
|
|
7
|
+
import { getDefaults } from "../utils/ui.ts";
|
|
8
8
|
|
|
9
9
|
import ULoader from "../ui.loader/ULoader.vue";
|
|
10
10
|
import UIcon from "../ui.image-icon/UIcon.vue";
|
|
@@ -17,19 +17,7 @@ import type { UButtonProps, LoaderSize, IconSize, Config } from "./types.ts";
|
|
|
17
17
|
defineOptions({ inheritAttrs: false });
|
|
18
18
|
|
|
19
19
|
const props = withDefaults(defineProps<UButtonProps>(), {
|
|
20
|
-
|
|
21
|
-
color: getDefault<UButtonProps>(defaultConfig, UButton).color,
|
|
22
|
-
size: getDefault<UButtonProps>(defaultConfig, UButton).size,
|
|
23
|
-
tag: getDefault<UButtonProps>(defaultConfig, UButton).tag,
|
|
24
|
-
tabindex: getDefault<UButtonProps>(defaultConfig, UButton).tabindex,
|
|
25
|
-
filled: getDefault<UButtonProps>(defaultConfig, UButton).filled,
|
|
26
|
-
disabled: getDefault<UButtonProps>(defaultConfig, UButton).disabled,
|
|
27
|
-
block: getDefault<UButtonProps>(defaultConfig, UButton).block,
|
|
28
|
-
round: getDefault<UButtonProps>(defaultConfig, UButton).round,
|
|
29
|
-
square: getDefault<UButtonProps>(defaultConfig, UButton).square,
|
|
30
|
-
loading: getDefault<UButtonProps>(defaultConfig, UButton).loading,
|
|
31
|
-
noRing: getDefault<UButtonProps>(defaultConfig, UButton).noRing,
|
|
32
|
-
dataTest: "",
|
|
20
|
+
...getDefaults<UButtonProps>(defaultConfig, UButton),
|
|
33
21
|
});
|
|
34
22
|
|
|
35
23
|
const slots = useSlots();
|
package/ui.button/types.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import defaultConfig from "./config.ts";
|
|
2
|
+
import type { Component } from "../types.ts";
|
|
2
3
|
|
|
3
|
-
export type Config = Partial<typeof defaultConfig
|
|
4
|
+
export type Config = Partial<typeof defaultConfig> & Component;
|
|
4
5
|
|
|
5
6
|
export type LoaderSize = "sm" | "md" | "lg";
|
|
6
7
|
export type IconSize = "2xs" | "xs" | "sm" | "md";
|
package/utils/ui.ts
CHANGED
|
@@ -94,9 +94,11 @@ export const cva = ({ base = "", variants = {}, compoundVariants = [], defaultVa
|
|
|
94
94
|
});
|
|
95
95
|
|
|
96
96
|
/**
|
|
97
|
+
* @deprecated
|
|
98
|
+
* TODO: remove if after all components migration into getDefaults()
|
|
97
99
|
* Return default values for component props, icons, etc..
|
|
98
100
|
*/
|
|
99
|
-
export function getDefault<T>(defaultConfig: Component, name: ComponentNames)
|
|
101
|
+
export function getDefault<T>(defaultConfig: Component, name: ComponentNames) {
|
|
100
102
|
const componentDefaults = cloneDeep(defaultConfig.defaults) || {};
|
|
101
103
|
const globalDefaults = cloneDeep(vuelessConfig.component?.[name]?.defaults) || {};
|
|
102
104
|
|
|
@@ -106,7 +108,31 @@ export function getDefault<T>(defaultConfig: Component, name: ComponentNames): T
|
|
|
106
108
|
defaults.color = getColor(defaults.color as BrandColors);
|
|
107
109
|
}
|
|
108
110
|
|
|
109
|
-
return
|
|
111
|
+
return {
|
|
112
|
+
...defaults,
|
|
113
|
+
dataTest: "",
|
|
114
|
+
config: () => {},
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Return default values for component props, icons, etc..
|
|
120
|
+
*/
|
|
121
|
+
export function getDefaults<T>(defaultConfig: Component, name: ComponentNames) {
|
|
122
|
+
const componentDefaults = cloneDeep(defaultConfig.defaults) || {};
|
|
123
|
+
const globalDefaults = cloneDeep(vuelessConfig.component?.[name]?.defaults) || {};
|
|
124
|
+
|
|
125
|
+
const defaults = merge(componentDefaults, globalDefaults) as T & Defaults;
|
|
126
|
+
|
|
127
|
+
if (defaults.color) {
|
|
128
|
+
defaults.color = getColor(defaults.color as BrandColors);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return {
|
|
132
|
+
...defaults,
|
|
133
|
+
dataTest: "",
|
|
134
|
+
config: () => ({}),
|
|
135
|
+
};
|
|
110
136
|
}
|
|
111
137
|
|
|
112
138
|
/**
|
package/web-types.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"framework": "vue",
|
|
3
3
|
"name": "vueless",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.567",
|
|
5
5
|
"contributions": {
|
|
6
6
|
"html": {
|
|
7
7
|
"description-markup": "markdown",
|
|
@@ -1027,8 +1027,7 @@
|
|
|
1027
1027
|
"value": {
|
|
1028
1028
|
"kind": "expression",
|
|
1029
1029
|
"type": "string"
|
|
1030
|
-
}
|
|
1031
|
-
"default": "\"\""
|
|
1030
|
+
}
|
|
1032
1031
|
}
|
|
1033
1032
|
],
|
|
1034
1033
|
"slots": [
|