vueless 0.0.483 → 0.0.485

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/README.md CHANGED
@@ -29,7 +29,7 @@ createApp(App).use(vueless).mount('#app');
29
29
  3. Add TailwindCSS preset.
30
30
 
31
31
  ```javascript
32
- import { vuelessPreset } from "vueless/preset-tailwind.js";
32
+ import { vuelessPreset } from "vueless/preset-tailwind";
33
33
 
34
34
  export default {
35
35
  presets: [vuelessPreset],
@@ -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, ...params: unknown[]) => 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 String(str);
103
+ return str as TMassages;
104
104
  };
105
105
  }
106
106
 
@@ -25,13 +25,13 @@ import type {
25
25
  BrandColors,
26
26
  Strategies,
27
27
  UnknownObject,
28
- VueAttrs,
29
28
  Component,
30
29
  NestedComponent,
31
30
  ComponentNames,
32
31
  CVA,
33
32
  KeyAttrs,
34
33
  KeysToExtend,
34
+ ExtendedKeyClasses,
35
35
  } from "../types.ts";
36
36
 
37
37
  interface MergedConfigOptions {
@@ -71,14 +71,12 @@ export default function useUI<T>(
71
71
  watchEffect(() => {
72
72
  const propsConfig = propsConfigGetter ? propsConfigGetter() : {};
73
73
 
74
- const mergedConfig = getMergedConfig({
74
+ config.value = getMergedConfig({
75
75
  defaultConfig,
76
76
  globalConfig,
77
77
  propsConfig,
78
78
  vuelessStrategy,
79
79
  });
80
-
81
- config.value = mergeClassesIntoConfig(mergedConfig, topLevelClassKey || firstClassKey, attrs);
82
80
  });
83
81
 
84
82
  /**
@@ -103,6 +101,10 @@ export default function useUI<T>(
103
101
  classes = value;
104
102
  }
105
103
 
104
+ if (key === (topLevelClassKey || firstClassKey)) {
105
+ classes = cx([classes, attrs.class]);
106
+ }
107
+
106
108
  return color ? setColor(classes, color) : classes;
107
109
  });
108
110
  }
@@ -113,7 +115,7 @@ export default function useUI<T>(
113
115
  * – value: reactive string of extendingKey classes.
114
116
  */
115
117
  function getExtendingKeysClasses(extendingKeys: string[], mutatedProps = {}) {
116
- const extendingClasses: UnknownObject = {};
118
+ const extendingClasses: ExtendedKeyClasses = {};
117
119
 
118
120
  for (const key of extendingKeys) {
119
121
  extendingClasses[key] = getClasses(key, mutatedProps);
@@ -192,18 +194,11 @@ export default function useUI<T>(
192
194
  const configKeyValue = config.value[configKey] as Component | string;
193
195
  const isObject = typeof configKeyValue === "object";
194
196
 
195
- const configAttrs = {
196
- config: configKeyValue,
197
- ...(isObject ? configKeyValue.defaults : {}),
198
- };
199
-
200
- const isTopLevelClassKey = configKey === (topLevelClassKey || firstClassKey);
201
- const attrClass = isTopLevelClassKey && !nestedComponent ? attrs.class : "";
202
-
203
197
  vuelessAttrs.value = {
204
198
  ...commonAttrs,
205
- class: cx([getBaseClasses(toValue(classes)), attrClass]),
206
- ...((isObject && configAttrs) || {}),
199
+ class: toValue(classes),
200
+ ...(isObject ? { config: configKeyValue } : {}),
201
+ ...(isObject ? configKeyValue.defaults : {}),
207
202
  };
208
203
  }
209
204
 
@@ -212,8 +207,6 @@ export default function useUI<T>(
212
207
 
213
208
  return {
214
209
  config,
215
- setColor,
216
- getColor,
217
210
  getKeysAttrs,
218
211
  getExtendingKeysClasses,
219
212
  hasSlotContent,
@@ -255,23 +248,6 @@ function getMergedConfig({
255
248
  return mergedConfig;
256
249
  }
257
250
 
258
- /**
259
- * Merge component classes from "class" attribute into final config.
260
- */
261
- function mergeClassesIntoConfig(config: Component, topLevelClassKey: string, attrs: VueAttrs) {
262
- const configTopKey = config[topLevelClassKey];
263
-
264
- if (typeof configTopKey === "object") {
265
- (configTopKey as CVA).base = cx([(configTopKey as CVA)?.base, attrs.class]);
266
-
267
- config[topLevelClassKey] = configTopKey;
268
- } else {
269
- config[topLevelClassKey] = cx([configTopKey, attrs.class]);
270
- }
271
-
272
- return config;
273
- }
274
-
275
251
  /**
276
252
  * Return base classes.
277
253
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vueless",
3
- "version": "0.0.483",
3
+ "version": "0.0.485",
4
4
  "license": "MIT",
5
5
  "description": "Vue Styleless UI Component Library, powered by Tailwind CSS.",
6
6
  "keywords": [
package/plugin-vite.js CHANGED
@@ -27,6 +27,7 @@ export const VuelessUnpluginComponents = (options) =>
27
27
  export const Vueless = function (options = {}) {
28
28
  const { mode, debug, env, include } = options;
29
29
 
30
+ const isVuelessEnv = env === "vueless";
30
31
  const isNuxt = mode === "nuxt-module";
31
32
  const srcDir = isNuxt ? process.cwd() : getVueSourceFile();
32
33
 
@@ -51,7 +52,7 @@ export const Vueless = function (options = {}) {
51
52
  "process.env": {},
52
53
  },
53
54
  optimizeDeps: {
54
- include: ["tailwindcss/colors.js"],
55
+ include: ["tailwindcss/colors.js", ...(!isVuelessEnv ? ["vueless/preset-tailwind"] : [])],
55
56
  },
56
57
  }),
57
58
 
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
- [key: string]: object | undefined;
173
+ config: Ref<TConfig | undefined>;
174
+ [key: string]: Ref<TConfig | undefined> | typeof hasSlotContent;
168
175
  }
169
176
 
170
177
  export interface KeyAttrs extends VueAttrs {