vueless 0.0.187 → 0.0.189

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vueless",
3
- "version": "0.0.187",
3
+ "version": "0.0.189",
4
4
  "license": "MIT",
5
5
  "description": "Vue Styleless Component Framework.",
6
6
  "homepage": "https://vueless.com",
@@ -212,6 +212,23 @@ export default class UIService {
212
212
  setColor(classes, color) {
213
213
  return classes?.replaceAll("{color}", color);
214
214
  }
215
+
216
+ /**
217
+ Check is config key not contains classes or CVA config object.
218
+ @param { String } key
219
+ @returns { Boolean }
220
+ */
221
+ isSystemKey(key) {
222
+ return (
223
+ key === "i18n" ||
224
+ key === "strategy" ||
225
+ key === "safelist" ||
226
+ key === "safelistColors" ||
227
+ key === "defaultVariants" ||
228
+ key.includes("iconName") ||
229
+ key.includes("IconName")
230
+ );
231
+ }
215
232
  }
216
233
 
217
234
  export const {
@@ -222,6 +239,7 @@ export const {
222
239
  setFavicon,
223
240
  setBrandColor,
224
241
  convertHexInRgb,
242
+ isSystemKey,
225
243
  isMac,
226
244
  isPWA,
227
245
  isIOS,
@@ -1,45 +1,37 @@
1
1
  import { computed } from "vue";
2
2
  import useUI from "../../composable.ui";
3
- import { cva } from "../../service.ui";
4
-
3
+ import { cva, isSystemKey } from "../../service.ui";
5
4
  import defaultConfig from "../configs/default.config";
6
5
 
6
+ const componentKeys = ["icon", "divider"];
7
+
7
8
  export function useAttrs(props, { isOpened }) {
8
9
  const { config, getAttrs } = useUI(defaultConfig, () => props.config);
9
- const { wrapper, description } = config.value;
10
+ const attrs = {};
10
11
 
11
- const cvaWrapper = cva({
12
- base: wrapper.base,
13
- variants: wrapper.variants,
14
- compoundVariants: wrapper.compoundVariants,
15
- });
12
+ // New approach of defining attrs dynamically (need to test).
13
+ for (const key in defaultConfig) {
14
+ if (isSystemKey(key)) continue;
16
15
 
17
- const cvaDescription = cva({
18
- base: description.base,
19
- variants: description.variants,
20
- compoundVariants: description.compoundVariants,
21
- });
16
+ let classes = "";
17
+ let value = config.value[key];
22
18
 
23
- const wrapperClasses = computed(() => cvaWrapper({ size: props.size }));
19
+ if (value.variants || value.compoundVariants) {
20
+ const getCVA = cva(value);
24
21
 
25
- const descriptionClasses = computed(() =>
26
- cvaDescription({ size: props.size, isOpened: isOpened.value }),
27
- );
22
+ classes = computed(() =>
23
+ getCVA({
24
+ ...props,
25
+ isOpened: isOpened.value,
26
+ }),
27
+ );
28
+ }
28
29
 
29
- const wrapperAttrs = getAttrs("wrapper", { classes: wrapperClasses });
30
- const descriptionAttrs = getAttrs("description", { classes: descriptionClasses });
31
- const infoAttrs = getAttrs("info");
32
- const titleAttrs = getAttrs("title");
33
- const iconAttrs = getAttrs("icon", { isComponent: true });
34
- const separatorAttrs = getAttrs("separator");
30
+ attrs[`${key}Attrs`] = getAttrs(key, { classes, isComponent: componentKeys.includes(key) });
31
+ }
35
32
 
36
33
  return {
34
+ ...attrs,
37
35
  config,
38
- wrapperAttrs,
39
- descriptionAttrs,
40
- infoAttrs,
41
- titleAttrs,
42
- iconAttrs,
43
- separatorAttrs,
44
36
  };
45
37
  }
@@ -1,6 +1,8 @@
1
1
  export default /*tw*/ {
2
- wrapper: {
3
- base: "group cursor-pointer [&:not(:first-child)]:pt-6",
2
+ wrapper: "group cursor-pointer",
3
+ body: "",
4
+ title: {
5
+ base: "flex items-center justify-between font-medium text-gray-900",
4
6
  variants: {
5
7
  size: {
6
8
  sm: "text-sm",
@@ -9,10 +11,8 @@ export default /*tw*/ {
9
11
  },
10
12
  },
11
13
  },
12
- info: "leading-6",
13
- title: "flex items-center justify-between font-medium text-gray-800",
14
14
  description: {
15
- base: "text-gray-600 leading-normal h-0 overflow-hidden opacity-0",
15
+ base: "text-gray-600 h-0 opacity-0 transition-all",
16
16
  variants: {
17
17
  size: {
18
18
  sm: "text-xs",
@@ -20,14 +20,14 @@ export default /*tw*/ {
20
20
  lg: "text-base",
21
21
  },
22
22
  isOpened: {
23
- true: "h-full pt-3 opacity-100 transition",
23
+ true: "pt-2 h-full opacity-100",
24
24
  },
25
25
  },
26
26
  },
27
27
  icon: "",
28
28
  expandIconName: "add",
29
29
  collapseIconName: "remove",
30
- separator: "mt-2 h-px w-full lg:mt-6 bg-gray-100 mt-2.5 group-last:hidden",
30
+ divider: "group-last:hidden",
31
31
  defaultVariants: {
32
32
  size: "md",
33
33
  },
@@ -1,8 +1,6 @@
1
1
  import { getArgTypes } from "../service.storybook";
2
2
 
3
3
  import UAccordion from "../ui.container-accordion";
4
- import UCard from "../ui.container-card";
5
- import UGroup from "../ui.container-group";
6
4
 
7
5
  /**
8
6
  * The `UAccordion` component. | [View on GitHub](https://github.com/vuelessjs/vueless/tree/main/src/ui.container-accordion)
@@ -17,76 +15,37 @@ export default {
17
15
  };
18
16
 
19
17
  const DefaultTemplate = (args) => ({
20
- components: { UAccordion, UCard },
18
+ components: { UAccordion },
21
19
  setup() {
22
20
  return { args };
23
21
  },
24
22
  template: `
25
- <UCard>
26
- <UAccordion
27
- name="accordion1"
28
- title="Excellence by necessity"
29
- description="As creators and maintainers of the technologies you are using,
30
- our services are here to showcase the full power of our softwares."
31
- />
32
- <UAccordion
33
- name="accordion1"
34
- title="Unique expertise"
35
- description="All the peoples that will be involved in delivering your project are contributing
36
- to the technologies you are using, when they are not the creators themselves."
37
- />
38
- <UAccordion
39
- name="accordion1"
40
- title="Commitment to innovation"
41
- description="By working with us, you are directly supporting the open source community,
42
- ensuring the ecosystem continuity and enabling Nuxt development."
43
- />
44
- </UCard>
45
- `,
46
- });
47
-
48
- const SizesTemplate = (args, { argTypes } = {}) => ({
49
- components: { UAccordion, UCard, UGroup },
50
- setup() {
51
- return {
52
- args,
53
- sizes: argTypes.size.options,
54
- };
55
- },
56
- template: `
57
- <UGroup>
58
- <UCard v-for="(sizes, index) in sizes" :padding="sizes">
59
- <UAccordion
60
- :size="size"
61
- :name="size"
62
- title="Excellence by necessity"
63
- description="As creators and maintainers of the technologies you are using,
64
- our services are here to showcase the full power of our softwares."
65
- :key="index"
66
- />
67
- <UAccordion
68
- :size="size"
69
- :name="size"
70
- title="Unique expertise"
71
- description="All the peoples that will be involved in delivering your project are contributing
72
- to the technologies you are using, when they are not the creators themselves."
73
- :key="index"
74
- />
75
- <UAccordion
76
- :size="size"
77
- :name="size"
78
- title="Commitment to innovation"
79
- description="By working with us, you are directly supporting the open source community,
80
- ensuring the ecosystem continuity and enabling Nuxt development."
81
- :key="index"
82
- />
83
- </UCard>
84
- </UGroup>
23
+ <UAccordion
24
+ name="Excellence"
25
+ title="Excellence by necessity"
26
+ description="As creators and maintainers of the technologies you are using,
27
+ our services are here to showcase the full power of our softwares."
28
+ v-bind="args"
29
+ />
30
+ <UAccordion
31
+ v-bind="args"
32
+ name="Unique"
33
+ title="Unique expertise"
34
+ description="All the peoples that will be involved in delivering your project are contributing
35
+ to the technologies you are using, when they are not the creators themselves."
36
+ />
37
+ <UAccordion
38
+ v-bind="args"
39
+ name="Commitment"
40
+ title="Commitment to innovation"
41
+ description="By working with us, you are directly supporting the open source community,
42
+ ensuring the ecosystem continuity and enabling Nuxt development."
43
+ />
85
44
  `,
86
45
  });
87
46
 
88
47
  export const Default = DefaultTemplate.bind({});
89
48
  Default.args = {};
90
49
 
91
- export const Sizes = SizesTemplate.bind({});
92
- Sizes.args = {};
50
+ export const Size = DefaultTemplate.bind({});
51
+ Size.args = { size: "sm" };
@@ -1,9 +1,8 @@
1
1
  <template>
2
2
  <div :data-cy="dataCy" v-bind="wrapperAttrs" @click="onClickItem">
3
- <div v-bind="infoAttrs">
3
+ <div v-bind="bodyAttrs">
4
4
  <div v-bind="titleAttrs">
5
- <div v-text="title" />
6
-
5
+ {{ title }}
7
6
  <UIcon
8
7
  :name="isOpened ? config.collapseIconName : config.expandIconName"
9
8
  :size="size"
@@ -16,14 +15,15 @@
16
15
  <div :id="`description-${id}`" v-bind="descriptionAttrs" v-text="description" />
17
16
  </div>
18
17
 
19
- <div v-bind="separatorAttrs" />
18
+ <UDivider :size="dividerSize" v-bind="dividerAttrs" />
20
19
  </div>
21
20
  </template>
22
21
 
23
22
  <script setup>
24
- import { ref } from "vue";
23
+ import { computed, ref } from "vue";
25
24
 
26
25
  import UIcon from "../ui.image-icon";
26
+ import UDivider from "../ui.container-divider";
27
27
  import UIService, { getRandomId } from "../service.ui";
28
28
 
29
29
  import { UAccordion } from "./constants/index";
@@ -35,7 +35,7 @@ defineOptions({ name: "UAccordion", inheritAttrs: false });
35
35
 
36
36
  const props = defineProps({
37
37
  /**
38
- * Set component title.
38
+ * Accordion title.
39
39
  */
40
40
  title: {
41
41
  type: String,
@@ -43,7 +43,7 @@ const props = defineProps({
43
43
  },
44
44
 
45
45
  /**
46
- * Set component description.
46
+ * Accordion description.
47
47
  */
48
48
  description: {
49
49
  type: String,
@@ -51,16 +51,15 @@ const props = defineProps({
51
51
  },
52
52
 
53
53
  /**
54
- * Set unique block name.
55
- * @ignore
54
+ * Unique block name.
56
55
  */
57
56
  name: {
58
57
  type: String,
59
- required: true,
58
+ default: "",
60
59
  },
61
60
 
62
61
  /**
63
- * The size of component.
62
+ * Accordion size.
64
63
  * @values sm, md, lg
65
64
  */
66
65
  size: {
@@ -78,7 +77,7 @@ const props = defineProps({
78
77
  },
79
78
 
80
79
  /**
81
- * Sets data-cy attribute for automated testing.
80
+ * Data-cy attribute for automated testing.
82
81
  */
83
82
  dataCy: {
84
83
  type: String,
@@ -86,16 +85,26 @@ const props = defineProps({
86
85
  },
87
86
  });
88
87
 
89
- const emit = defineEmits(["itemClicked"]);
88
+ const emit = defineEmits(["click"]);
90
89
 
91
90
  const isOpened = ref(false);
92
91
 
93
- const { config, wrapperAttrs, descriptionAttrs, infoAttrs, titleAttrs, iconAttrs, separatorAttrs } =
92
+ const { config, wrapperAttrs, descriptionAttrs, bodyAttrs, titleAttrs, iconAttrs, dividerAttrs } =
94
93
  useAttrs(props, { isOpened });
95
94
 
95
+ const dividerSize = computed(() => {
96
+ const sizes = {
97
+ sm: "md",
98
+ md: "lg",
99
+ lg: "xl",
100
+ };
101
+
102
+ return sizes[props.size];
103
+ });
104
+
96
105
  function onClickItem() {
97
106
  isOpened.value = !isOpened.value;
98
107
 
99
- emit("itemClicked", props.name);
108
+ emit("click", props.name);
100
109
  }
101
110
  </script>
package/web-types.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "framework": "vue",
3
3
  "name": "vueless",
4
- "version": "0.0.187",
4
+ "version": "0.0.189",
5
5
  "contributions": {
6
6
  "html": {
7
7
  "description-markup": "markdown",
@@ -275,7 +275,7 @@
275
275
  {
276
276
  "name": "title",
277
277
  "required": true,
278
- "description": "Set component title.",
278
+ "description": "Accordion title.",
279
279
  "value": {
280
280
  "kind": "expression",
281
281
  "type": "string"
@@ -284,7 +284,7 @@
284
284
  {
285
285
  "name": "description",
286
286
  "required": true,
287
- "description": "Set component description.",
287
+ "description": "Accordion description.",
288
288
  "value": {
289
289
  "kind": "expression",
290
290
  "type": "string"
@@ -292,16 +292,16 @@
292
292
  },
293
293
  {
294
294
  "name": "name",
295
- "required": true,
296
- "description": "@ignore: Set unique block name.",
295
+ "description": "Unique block name.",
297
296
  "value": {
298
297
  "kind": "expression",
299
298
  "type": "string"
300
- }
299
+ },
300
+ "default": "\"\""
301
301
  },
302
302
  {
303
303
  "name": "size",
304
- "description": "The size of component.",
304
+ "description": "Accordion size.",
305
305
  "value": {
306
306
  "kind": "expression",
307
307
  "type": "'sm' | 'md' | 'lg'"
@@ -319,7 +319,7 @@
319
319
  },
320
320
  {
321
321
  "name": "dataCy",
322
- "description": "Sets data-cy attribute for automated testing.",
322
+ "description": "Data-cy attribute for automated testing.",
323
323
  "value": {
324
324
  "kind": "expression",
325
325
  "type": "string"
@@ -329,7 +329,7 @@
329
329
  ],
330
330
  "events": [
331
331
  {
332
- "name": "itemClicked"
332
+ "name": "click"
333
333
  }
334
334
  ],
335
335
  "source": {