vueless 0.0.197 → 0.0.198

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.
@@ -46,7 +46,8 @@ const SYSTEM_CONFIG_KEY = {
46
46
  4. Component classes (class="...")
47
47
  */
48
48
  export default function useUI(defaultConfig = {}, propsConfigGetter = null, topLevelClassKey) {
49
- const { name: componentName } = getCurrentInstance().type;
49
+ const { type, props } = getCurrentInstance();
50
+ const componentName = type.name;
50
51
  const globalConfig = globalComponentConfig[componentName];
51
52
 
52
53
  const isStrategyValid = strategy && Object.values(STRATEGY_TYPE).includes(strategy);
@@ -88,6 +89,7 @@ export default function useUI(defaultConfig = {}, propsConfigGetter = null, topL
88
89
  delete commonAttrs.value;
89
90
 
90
91
  watch(config, updateVuelessAttrs, { immediate: true });
92
+ watch(props, updateVuelessAttrs);
91
93
 
92
94
  function updateVuelessAttrs() {
93
95
  const configKeyValue = config.value[configKey];
@@ -100,7 +102,7 @@ export default function useUI(defaultConfig = {}, propsConfigGetter = null, topL
100
102
 
101
103
  const isTopLevelClassKey = configKey === (topLevelClassKey || firstClassKey);
102
104
  const attrClass = isTopLevelClassKey && !nestedComponent ? attrs.class : "";
103
- const classes = options?.classes ? toValue(options?.classes) : getBaseClasses(configKeyValue);
105
+ const classes = toValue(options?.classes) || getBaseClasses(configKeyValue);
104
106
 
105
107
  vuelessAttrs.value = {
106
108
  ...commonAttrs,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vueless",
3
- "version": "0.0.197",
3
+ "version": "0.0.198",
4
4
  "license": "MIT",
5
5
  "description": "Vue Styleless Component Framework.",
6
6
  "homepage": "https://vueless.com",
@@ -1,58 +1,40 @@
1
1
  import { computed } from "vue";
2
2
  import useUI from "../../composable.ui";
3
3
  import { cva } from "../../service.ui";
4
-
5
4
  import defaultConfig from "../configs/default.config";
6
5
 
7
- export function useAttrs(props) {
8
- const { config, getAttrs, getColor, setColor } = useUI(defaultConfig, () => props.config);
9
- const { button, text } = config.value;
6
+ export default function useAttrs(props) {
7
+ const { config, getAttrs, hasSlotContent, isSystemKey, getColor, setColor } = useUI(
8
+ defaultConfig,
9
+ () => props.config,
10
+ );
11
+ const attrs = {};
10
12
 
11
- const cvaButton = cva({
12
- base: button.base,
13
- variants: button.variants,
14
- compoundVariants: button.compoundVariants,
15
- });
13
+ for (const key in defaultConfig) {
14
+ if (isSystemKey(key)) continue;
16
15
 
17
- const cvaText = cva({
18
- base: text.base,
19
- variants: text.variants,
20
- compoundVariants: text.compoundVariants,
21
- });
16
+ const classes = computed(() => {
17
+ const value = config.value[key];
22
18
 
23
- const buttonClasses = computed(() =>
24
- setColor(
25
- cvaButton({
26
- size: props.size,
27
- color: getColor(props.color),
28
- variant: props.variant,
29
- pill: props.pill,
30
- block: props.block,
31
- square: props.loading || props.square,
32
- filled: props.filled,
33
- loading: props.loading,
34
- disabled: props.disabled,
35
- }),
36
- props.color,
37
- ),
38
- );
19
+ if (value.variants || value.compoundVariants) {
20
+ return setColor(
21
+ cva(value)({
22
+ ...props,
23
+ color: getColor(props.color),
24
+ }),
25
+ props.color,
26
+ );
27
+ }
39
28
 
40
- const textClasses = computed(() =>
41
- setColor(
42
- cvaText({
43
- color: getColor(props.color),
44
- }),
45
- props.color,
46
- ),
47
- );
29
+ return "";
30
+ });
48
31
 
49
- const buttonAttrs = getAttrs("button", { classes: buttonClasses });
50
- const loaderAttrs = getAttrs("loader");
51
- const textAttrs = getAttrs("text", { classes: textClasses });
32
+ attrs[`${key}Attrs`] = getAttrs(key, { classes });
33
+ }
52
34
 
53
35
  return {
54
- buttonAttrs,
55
- loaderAttrs,
56
- textAttrs,
36
+ ...attrs,
37
+ config,
38
+ hasSlotContent,
57
39
  };
58
40
  }
@@ -1,4 +1,4 @@
1
- import { getArgTypes, getSlotNames } from "../service.storybook";
1
+ import { getArgTypes, getSlotNames, allSlotsFragment } from "../service.storybook";
2
2
 
3
3
  import UButton from "../ui.button";
4
4
  import UIcon from "../ui.image-icon";
@@ -29,9 +29,7 @@ const DefaultTemplate = (args) => ({
29
29
  },
30
30
  template: `
31
31
  <UButton v-bind="args">
32
- <template v-for="(slot, index) of slots" :key="index" v-slot:[slot]>
33
- <template v-if="args[slot]">{{ args[slot] }}</template>
34
- </template>
32
+ ${allSlotsFragment}
35
33
  </UButton>
36
34
  `,
37
35
  });
@@ -39,7 +39,7 @@ import ULoader from "../ui.loader";
39
39
  import UIcon from "../ui.image-icon";
40
40
 
41
41
  import defaultConfig from "./configs/default.config";
42
- import { useAttrs } from "./composables/attrs.composable";
42
+ import useAttrs from "./composables/attrs.composable";
43
43
  import { UButton } from "./constants";
44
44
 
45
45
  /* Should be a string for correct web-types gen */
package/web-types.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "framework": "vue",
3
3
  "name": "vueless",
4
- "version": "0.0.197",
4
+ "version": "0.0.198",
5
5
  "contributions": {
6
6
  "html": {
7
7
  "description-markup": "markdown",