vueless 0.0.556 → 0.0.557

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.
@@ -19,9 +19,10 @@ import type {
19
19
  NestedComponent,
20
20
  ComponentNames,
21
21
  CVA,
22
+ UseUI,
22
23
  KeyAttrs,
23
- ExtendedKeyClasses,
24
24
  KeysAttrs,
25
+ ExtendedKeyClasses,
25
26
  } from "../types.ts";
26
27
 
27
28
  /**
@@ -35,7 +36,8 @@ export default function useUI<T>(
35
36
  defaultConfig: T & Component,
36
37
  propsConfigGetter?: () => (T & Component) | undefined,
37
38
  topLevelClassKey?: string,
38
- ) {
39
+ mutatedProps?: ComputedRef,
40
+ ): UseUI<T> {
39
41
  const { type, props } = getCurrentInstance() as ComponentInternalInstance;
40
42
  const componentName = type.__name as ComponentNames;
41
43
  const globalConfig = vuelessConfig?.component?.[componentName] || {};
@@ -48,7 +50,7 @@ export default function useUI<T>(
48
50
  : (STRATEGY_TYPE.merge as Strategies);
49
51
 
50
52
  const firstClassKey = defaultConfig ? Object.keys(defaultConfig)[0] : "";
51
- const config = ref({} as T);
53
+ const config = ref({} as T & Component);
52
54
  const attrs = useAttrs();
53
55
 
54
56
  watchEffect(() => {
@@ -191,7 +193,7 @@ export default function useUI<T>(
191
193
  return vuelessAttrs;
192
194
  }
193
195
 
194
- return { config, getKeysAttrs };
196
+ return { config, getKeysAttrs, ...getKeysAttrs(mutatedProps) };
195
197
  }
196
198
 
197
199
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vueless",
3
- "version": "0.0.556",
3
+ "version": "0.0.557",
4
4
  "license": "MIT",
5
5
  "description": "Vue Styleless UI Component Library, powered by Tailwind CSS.",
6
6
  "keywords": [
package/types.ts CHANGED
@@ -44,7 +44,7 @@ import UCheckboxMultiStateConfig from "./ui.form-checkbox-multi-state/config.ts"
44
44
  import URadioConfig from "./ui.form-radio/config.ts";
45
45
  import URadioGroupConfig from "./ui.form-radio-group/config.ts";
46
46
 
47
- import type { MaybeRef, Ref } from "vue";
47
+ import type { ComputedRef, MaybeRef, Ref, UnwrapRef } from "vue";
48
48
  import type { Props } from "tippy.js";
49
49
  import type { LocaleOptions } from "./adatper.locale/vueless.ts";
50
50
 
@@ -227,6 +227,19 @@ export interface NestedComponent {
227
227
  [key: string]: Record<string, string | object> | string;
228
228
  }
229
229
 
230
+ export type ComponentConfig<T> = [T & Component] extends [Ref]
231
+ ? Ref<T & Component>
232
+ : Ref<UnwrapRef<T & Component>, T & Component>;
233
+
234
+ export interface UseUI<T> {
235
+ config: ComponentConfig<T>;
236
+ getKeysAttrs: (mutatedProps?: ComputedRef) => KeysAttrs;
237
+ [key: string]:
238
+ | ComputedRef<KeyAttrs>
239
+ | ComponentConfig<T>
240
+ | ((mutatedProps?: ComputedRef) => KeysAttrs);
241
+ }
242
+
230
243
  export interface Transition {
231
244
  enterFromClass?: string;
232
245
  enterActiveClass?: string;
@@ -106,16 +106,18 @@ defineExpose({
106
106
  * Get element / nested component attributes for each config token ✨
107
107
  * Applies: `class`, `config`, redefined default `props` and dev `vl-...` attributes.
108
108
  */
109
- const { getKeysAttrs } = useUI<Config>(defaultConfig, () => props.config);
110
-
111
109
  const mutatedProps = computed(() => ({
112
110
  leftIcon: Boolean(props.leftIcon) || hasSlotContent(slots["left"]),
113
111
  rightIcon: Boolean(props.rightIcon) || hasSlotContent(slots["right"]),
114
112
  label: Boolean(props.label),
115
113
  }));
116
114
 
117
- const { buttonAttrs, loaderAttrs, leftIconAttrs, rightIconAttrs, centerIconAttrs } =
118
- getKeysAttrs(mutatedProps);
115
+ const { buttonAttrs, loaderAttrs, leftIconAttrs, rightIconAttrs, centerIconAttrs } = useUI<Config>(
116
+ defaultConfig,
117
+ () => props.config,
118
+ "",
119
+ mutatedProps,
120
+ );
119
121
  </script>
120
122
 
121
123
  <template>
package/web-types.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "framework": "vue",
3
3
  "name": "vueless",
4
- "version": "0.0.556",
4
+ "version": "0.0.557",
5
5
  "contributions": {
6
6
  "html": {
7
7
  "description-markup": "markdown",