vueless 0.0.207 → 0.0.208

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.
Files changed (40) hide show
  1. package/composable.ui/index.js +1 -0
  2. package/package.json +1 -1
  3. package/service.storybook/index.js +9 -0
  4. package/ui.button/index.stories.js +6 -18
  5. package/ui.button/index.vue +6 -1
  6. package/ui.container-accordion/composables/attrs.composable.js +10 -11
  7. package/ui.container-accordion/index.vue +8 -2
  8. package/ui.container-card/composable/attrs.composable.js +36 -43
  9. package/ui.container-card/configs/default.config.js +2 -2
  10. package/ui.container-card/index.vue +1 -1
  11. package/ui.container-divider/composables/attrs.composable.js +22 -49
  12. package/ui.container-divider/index.vue +1 -1
  13. package/ui.container-group/composables/attrs.composable.js +23 -39
  14. package/ui.container-group/configs/default.config.js +3 -3
  15. package/ui.container-group/index.vue +4 -4
  16. package/ui.container-groups/composables/attrs.composable.js +20 -16
  17. package/ui.container-groups/index.vue +1 -1
  18. package/ui.container-modal/composables/attrs.composable.js +43 -66
  19. package/ui.container-modal/configs/default.config.js +6 -6
  20. package/ui.container-modal/index.vue +13 -2
  21. package/ui.container-modal-confirm/composable/attrs.composable.js +21 -40
  22. package/ui.container-modal-confirm/configs/default.config.js +3 -3
  23. package/ui.container-modal-confirm/index.vue +18 -2
  24. package/ui.container-page/composables/attrs.composable.js +48 -83
  25. package/ui.container-page/configs/default.config.js +3 -3
  26. package/ui.container-page/index.vue +1 -1
  27. package/ui.container-row/composables/attrs.composable.js +20 -17
  28. package/ui.container-row/index.vue +1 -1
  29. package/ui.form-date-picker-range/configs/default.config.js +2 -6
  30. package/ui.form-date-picker-range/index.vue +29 -12
  31. package/ui.form-input/index.stories.js +2 -5
  32. package/ui.image-avatar/composables/attrs.composable.js +28 -24
  33. package/ui.image-avatar/configs/default.config.js +1 -1
  34. package/ui.image-avatar/index.vue +7 -2
  35. package/ui.image-icon/composables/attrs.composable.js +24 -49
  36. package/ui.image-icon/index.vue +17 -2
  37. package/ui.loader/index.stories.js +32 -2
  38. package/ui.navigation-progress/index.stories.js +48 -106
  39. package/ui.navigation-progress/index.vue +9 -1
  40. package/web-types.json +58 -15
@@ -4,33 +4,37 @@ import { cva } from "../../service.ui";
4
4
  import defaultConfig from "../configs/default.config";
5
5
  import { computed } from "vue";
6
6
 
7
- export function useAttrs(props) {
8
- const { config, getAttrs, getColor, setColor } = useUI(defaultConfig, () => props.config);
9
- const { avatar } = config.value;
10
-
11
- const cvaAvatar = cva({
12
- base: avatar.base,
13
- variants: avatar.variants,
14
- compoundVariants: avatar.compoundVariants,
15
- });
16
-
17
- const avatarClasses = computed(() =>
18
- setColor(
19
- cvaAvatar({
20
- size: props.size,
21
- color: getColor(props.color),
22
- rounded: props.rounded,
23
- bordered: props.bordered,
24
- }),
25
- props.color,
26
- ),
7
+ export default function useAttrs(props) {
8
+ const { config, getAttrs, getColor, setColor, isSystemKey } = useUI(
9
+ defaultConfig,
10
+ () => props.config,
27
11
  );
12
+ const attrs = {};
28
13
 
29
- const avatarAttrs = getAttrs("avatar", { classes: avatarClasses });
30
- const iconAttrs = getAttrs("icon", { isComponent: true });
14
+ for (const key in defaultConfig) {
15
+ if (isSystemKey(key)) continue;
16
+
17
+ const classes = computed(() => {
18
+ const value = config.value[key];
19
+
20
+ if (value.variants || value.compoundVariants) {
21
+ return setColor(
22
+ cva(value)({
23
+ ...props,
24
+ color: getColor(props.color),
25
+ }),
26
+ props.color,
27
+ );
28
+ }
29
+
30
+ return "";
31
+ });
32
+
33
+ attrs[`${key}Attrs`] = getAttrs(key, { classes });
34
+ }
31
35
 
32
36
  return {
33
- avatarAttrs,
34
- iconAttrs,
37
+ ...attrs,
38
+ config,
35
39
  };
36
40
  }
@@ -33,7 +33,7 @@ export default /*tw*/ {
33
33
  },
34
34
  },
35
35
  },
36
- icon: "",
36
+ icon: "{UIcon}",
37
37
  defaultVariants: {
38
38
  color: "grayscale",
39
39
  rounded: "md",
@@ -27,7 +27,7 @@ import UIService from "../service.ui";
27
27
 
28
28
  import { UAvatar } from "./constants/index";
29
29
  import defaultConfig from "./configs/default.config";
30
- import { useAttrs } from "./composables/attrs.composable";
30
+ import useAttrs from "./composables/attrs.composable";
31
31
 
32
32
  /* Should be a string for correct web-types gen */
33
33
  defineOptions({ name: "UAvatar", inheritAttrs: false });
@@ -109,7 +109,12 @@ const props = defineProps({
109
109
  },
110
110
  });
111
111
 
112
- const emit = defineEmits(["click"]);
112
+ const emit = defineEmits([
113
+ /**
114
+ * Triggers when the avatar is clicked.
115
+ */
116
+ "click",
117
+ ]);
113
118
 
114
119
  const labelFirstLetters = computed(() => {
115
120
  const [firstWord, secondWord] = props.label.split(" ");
@@ -4,62 +4,37 @@ import { cva } from "../../service.ui";
4
4
  import defaultConfig from "../configs/default.config";
5
5
  import { computed } from "vue";
6
6
 
7
- export function useAttrs(props) {
8
- const { config, getAttrs, getColor, setColor } = useUI(defaultConfig, () => props.config);
9
- const { wrapper, container, icon } = config.value;
10
-
11
- const cvaWrapper = cva({
12
- base: wrapper.base,
13
- variants: wrapper.variants,
14
- compoundVariants: wrapper.compoundVariants,
15
- });
7
+ export default function useAttrs(props) {
8
+ const { config, getAttrs, getColor, setColor, isSystemKey } = useUI(
9
+ defaultConfig,
10
+ () => props.config,
11
+ );
12
+ const attrs = {};
16
13
 
17
- const cvaContainer = cva({
18
- base: container.base,
19
- variants: container.variants,
20
- compoundVariants: container.compoundVariants,
21
- });
14
+ for (const key in defaultConfig) {
15
+ if (isSystemKey(key)) continue;
22
16
 
23
- const cvaIcon = cva({
24
- base: icon.base,
25
- variants: icon.variants,
26
- compoundVariants: icon.compoundVariants,
27
- });
17
+ const classes = computed(() => {
18
+ const value = config.value[key];
28
19
 
29
- const wrapperClasses = computed(() =>
30
- setColor(
31
- cvaWrapper({
32
- pill: props.pill,
33
- size: props.size,
34
- color: getColor(props.color),
35
- }),
36
- props.color,
37
- ),
38
- );
39
-
40
- const containerClasses = computed(() =>
41
- setColor(
42
- cvaContainer({
43
- pill: props.pill,
44
- size: props.size,
45
- color: getColor(props.color),
46
- variant: props.variant,
47
- interactive: props.interactive,
48
- }),
49
- props.color,
50
- ),
51
- );
20
+ if (value.variants || value.compoundVariants) {
21
+ return setColor(
22
+ cva(value)({
23
+ ...props,
24
+ color: getColor(props.color),
25
+ }),
26
+ props.color,
27
+ );
28
+ }
52
29
 
53
- const iconClasses = computed(() => cvaIcon({ size: props.size }));
30
+ return "";
31
+ });
54
32
 
55
- const wrapperAttrs = getAttrs("wrapper", { classes: wrapperClasses });
56
- const containerAttrs = getAttrs("container", { classes: containerClasses });
57
- const iconAttrs = getAttrs("icon", { classes: iconClasses });
33
+ attrs[`${key}Attrs`] = getAttrs(key, { classes });
34
+ }
58
35
 
59
36
  return {
37
+ ...attrs,
60
38
  config,
61
- wrapperAttrs,
62
- containerAttrs,
63
- iconAttrs,
64
39
  };
65
40
  }
@@ -19,7 +19,7 @@ import UIService from "../service.ui";
19
19
 
20
20
  import { UIcon } from "./constants";
21
21
  import defaultConfig from "./configs/default.config";
22
- import { useAttrs } from "./composables/attrs.composable";
22
+ import useAttrs from "./composables/attrs.composable";
23
23
 
24
24
  import vTooltip from "../directive.tooltip";
25
25
 
@@ -132,7 +132,22 @@ const props = defineProps({
132
132
  },
133
133
  });
134
134
 
135
- const emit = defineEmits(["click", "focus", "blur"]);
135
+ const emit = defineEmits([
136
+ /**
137
+ * Triggers when the icon is clicked.
138
+ */
139
+ "click",
140
+
141
+ /**
142
+ * Triggers when the icon is focused.
143
+ */
144
+ "focus",
145
+
146
+ /**
147
+ * Triggers when the icon loses focus.
148
+ */
149
+ "blur",
150
+ ]);
136
151
 
137
152
  const { config, wrapperAttrs, containerAttrs, iconAttrs } = useAttrs(props);
138
153
 
@@ -1,5 +1,6 @@
1
1
  import ULoader from "../ui.loader";
2
2
  import URow from "../ui.container-row";
3
+ import UButton from "../ui.button";
3
4
 
4
5
  import { getArgTypes } from "../service.storybook";
5
6
 
@@ -10,6 +11,9 @@ export default {
10
11
  id: "9010",
11
12
  title: "Loaders and Skeletons / Loader",
12
13
  component: ULoader,
14
+ args: {
15
+ loading: true,
16
+ },
13
17
  argTypes: {
14
18
  ...getArgTypes(ULoader.name),
15
19
  },
@@ -37,9 +41,9 @@ const ColorsTemplate = (args, { argTypes } = {}) => ({
37
41
  <URow class="flex-wrap">
38
42
  <ULoader
39
43
  v-for="(color, index) in colors"
40
- :color="color"
41
- v-bind="args"
42
44
  :key="index"
45
+ v-bind="args"
46
+ :color="color"
43
47
  />
44
48
  </URow>
45
49
  `,
@@ -65,6 +69,29 @@ const SizesTemplate = (args, { argTypes } = {}) => ({
65
69
  `,
66
70
  });
67
71
 
72
+ const LoadingTemplate = (args) => ({
73
+ components: { ULoader, UButton, URow },
74
+ setup() {
75
+ return { args };
76
+ },
77
+ data() {
78
+ return {
79
+ isLoading: false,
80
+ };
81
+ },
82
+ methods: {
83
+ toggleLoader() {
84
+ this.isLoading = !this.isLoading;
85
+ },
86
+ },
87
+ template: `
88
+ <URow>
89
+ <ULoader v-bind="args" :loading="isLoading" />
90
+ <UButton @click="toggleLoader" size="sm">ToggleLoader</UButton>
91
+ </URow>
92
+ `,
93
+ });
94
+
68
95
  export const Default = DefaultTemplate.bind({});
69
96
  Default.args = {};
70
97
 
@@ -73,3 +100,6 @@ sizes.args = {};
73
100
 
74
101
  export const colors = ColorsTemplate.bind({});
75
102
  colors.args = {};
103
+
104
+ export const loading = LoadingTemplate.bind({});
105
+ loading.args = {};
@@ -1,9 +1,9 @@
1
+ import { getArgTypes, allSlotsFragment, getSlotNames } from "../service.storybook";
2
+
1
3
  import UProgress from "./index.vue";
2
- import UButton from "../ui.button/index.vue";
4
+ import UGroup from "../ui.container-group";
5
+ import UButton from "../ui.button";
3
6
  import UIcon from "../ui.image-icon";
4
- import URow from "../ui.container-row";
5
-
6
- import { getArgTypes } from "../service.storybook";
7
7
 
8
8
  /**
9
9
  * The `UProgress` component. | [View on GitHub](https://github.com/vuelessjs/vueless/tree/main/src/ui.navigation-progress)
@@ -18,131 +18,72 @@ export default {
18
18
  };
19
19
 
20
20
  const DefaultTemplate = (args) => ({
21
- components: { UProgress, UButton, UIcon },
21
+ components: { UGroup, UProgress, UButton, UIcon },
22
22
  setup() {
23
- return { args };
24
- },
25
- data() {
26
- return {
27
- progress: 10,
28
- };
29
- },
30
- methods: {
31
- updateProgress() {
32
- this.progress += 10;
33
-
34
- if (this.progress > 100) {
35
- this.progress = 0;
36
- }
37
- },
38
- },
39
- template: `
40
- <UProgress v-bind="args" :value="progress">
41
- ${args.slotTemplate}
42
- </UProgress>
23
+ const slots = getSlotNames(UProgress.name);
43
24
 
44
- <UButton class="mt-4" @click="updateProgress">Update Progress</UButton>
45
- `,
46
- });
25
+ args.value = args.max ? 1 : 10;
26
+ args.iterator = args.max ? 1 : 10;
47
27
 
48
- const StepsTemplate = (args) => ({
49
- components: { UProgress, UButton, UIcon },
50
- setup() {
51
- return { args };
52
- },
53
- data() {
54
- return {
55
- progress: 1,
56
- max: ["Step 1", "Step 2", "Step 3"],
57
- };
58
- },
59
- methods: {
60
- updateProgress() {
61
- this.progress += 1;
62
-
63
- if (this.progress > 3) {
64
- this.progress = 0;
65
- }
66
- },
67
- },
68
- template: `
69
- <UProgress v-bind="args" :max="max" :value="progress">
70
- ${args.slotTemplate}
71
- </UProgress>
72
-
73
- <UButton class="mt-4" @click="updateProgress">Update Progress</UButton>
74
- `,
75
- });
28
+ function updateProgress() {
29
+ args.value = args.value < (args.max?.length || 100) ? args.value + args.iterator : 0;
30
+ }
76
31
 
77
- const ColorsTemplate = (args, { argTypes } = {}) => ({
78
- components: { UProgress, URow },
79
- setup() {
80
- return {
81
- args,
82
- colors: argTypes.color.options,
83
- };
84
- },
85
- data() {
86
- return {
87
- progress: 10,
88
- };
32
+ return { slots, args, updateProgress };
89
33
  },
90
34
  template: `
91
- <URow class="!flex-col">
92
- <UProgress
93
- v-for="(color, index) in colors"
94
- :key="index"
95
- :color="color"
96
- v-bind="args"
97
- :value="progress"
98
- />
99
- </URow>
35
+ <UGroup align="start">
36
+ <UProgress v-bind="args">${args.slotTemplate || allSlotsFragment}</UProgress>
37
+ <UButton label="Next →" size="sm" variant="thirdary" filled @click="updateProgress" />
38
+ </UGroup>
100
39
  `,
101
40
  });
102
41
 
103
- const SizesTemplate = (args, { argTypes } = {}) => ({
104
- components: { UProgress, URow },
42
+ const EnumVariantTemplate = (args, { argTypes } = {}) => ({
43
+ components: { UGroup, UButton, UProgress },
105
44
  setup() {
106
- return {
107
- args,
108
- sizes: argTypes.size.options,
109
- };
110
- },
111
- data() {
112
- return {
113
- progress: 10,
114
- };
45
+ args.progress = 10;
46
+
47
+ function updateProgress() {
48
+ args.progress = args.progress < 100 ? args.progress + 10 : 0;
49
+ }
50
+
51
+ return { args, updateProgress, options: argTypes[args.enum].options };
115
52
  },
116
53
  template: `
117
- <URow class="!flex-col">
118
- <UProgress
119
- v-for="(size, index) in sizes"
120
- :key="index"
121
- :size="size"
122
- v-bind="args"
123
- :value="progress"
124
- />
125
- </URow>
54
+ <UGroup align="start">
55
+ <UGroup>
56
+ <UProgress
57
+ v-for="(option, index) in options"
58
+ :key="index"
59
+ :[args.enum]="option"
60
+ v-bind="args"
61
+ :value="args.progress"
62
+ />
63
+ </UGroup>
64
+
65
+ <UButton label="Next →" size="sm" variant="thirdary" filled @click="updateProgress" />
66
+ </UGroup>
126
67
  `,
127
68
  });
128
69
 
129
70
  export const Default = DefaultTemplate.bind({});
130
71
  Default.args = {};
131
72
 
132
- export const Variant = StepsTemplate.bind({});
133
- Variant.args = { variant: "stepper" };
73
+ export const VariantStepper = DefaultTemplate.bind({});
74
+ VariantStepper.args = { variant: "stepper", max: ["Step 1", "Step 2", "Step 3"] };
134
75
 
135
76
  export const Indicator = DefaultTemplate.bind({});
136
77
  Indicator.args = { indicator: true };
137
78
 
138
- export const Steps = StepsTemplate.bind({});
139
- Steps.args = {};
79
+ export const Steps = DefaultTemplate.bind({});
80
+ Steps.args = { max: ["Step 1", "Step 2", "Step 3"] };
140
81
 
141
- export const Colors = ColorsTemplate.bind({});
142
- Colors.args = {};
82
+ export const Colors = EnumVariantTemplate.bind({});
83
+ Colors.args = { enum: "color" };
143
84
 
144
- export const Sizes = SizesTemplate.bind({});
145
- Sizes.args = {};
85
+ export const Sizes = EnumVariantTemplate.bind({});
86
+ Sizes.args = { enum: "size" };
146
87
 
147
88
  export const IndicatorSlot = DefaultTemplate.bind({});
148
89
  IndicatorSlot.args = {
@@ -157,8 +98,9 @@ IndicatorSlot.args = {
157
98
  `,
158
99
  };
159
100
 
160
- export const stepSlot = StepsTemplate.bind({});
101
+ export const stepSlot = DefaultTemplate.bind({});
161
102
  stepSlot.args = {
103
+ max: ["Step 1", "Step 2", "Step 3"],
162
104
  slotTemplate: `
163
105
  <template #step-0>
164
106
  💻
@@ -104,7 +104,15 @@ const props = defineProps({
104
104
  },
105
105
 
106
106
  /**
107
- * Sets data-cy attribute for automated testing.
107
+ * Component ui config object.
108
+ */
109
+ config: {
110
+ type: Object,
111
+ default: () => ({}),
112
+ },
113
+
114
+ /**
115
+ * Data-cy attribute for automated testing.
108
116
  */
109
117
  dataCy: {
110
118
  type: String,
package/web-types.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "framework": "vue",
3
3
  "name": "vueless",
4
- "version": "0.0.207",
4
+ "version": "0.0.208",
5
5
  "contributions": {
6
6
  "html": {
7
7
  "description-markup": "markdown",
@@ -399,7 +399,16 @@
399
399
  ],
400
400
  "events": [
401
401
  {
402
- "name": "click"
402
+ "name": "click",
403
+ "description": "Triggers when the accordion item is toggled.",
404
+ "properties": [
405
+ {
406
+ "type": [
407
+ "string"
408
+ ],
409
+ "name": "name"
410
+ }
411
+ ]
403
412
  }
404
413
  ],
405
414
  "source": {
@@ -653,7 +662,8 @@
653
662
  ],
654
663
  "events": [
655
664
  {
656
- "name": "click"
665
+ "name": "click",
666
+ "description": "Triggers when the avatar is clicked."
657
667
  }
658
668
  ],
659
669
  "source": {
@@ -3428,11 +3438,11 @@
3428
3438
  },
3429
3439
  {
3430
3440
  "name": "before-title",
3431
- "description": "Use it to add something before title."
3441
+ "description": "Use it to add something before the title."
3432
3442
  },
3433
3443
  {
3434
3444
  "name": "after-title",
3435
- "description": "Use it to add something after title."
3445
+ "description": "Use it to add something after the title."
3436
3446
  },
3437
3447
  {
3438
3448
  "name": "right",
@@ -3440,7 +3450,7 @@
3440
3450
  },
3441
3451
  {
3442
3452
  "name": "default",
3443
- "description": "Use it to add something instead form."
3453
+ "description": "Use it to add something inside."
3444
3454
  }
3445
3455
  ],
3446
3456
  "source": {
@@ -3702,13 +3712,16 @@
3702
3712
  ],
3703
3713
  "events": [
3704
3714
  {
3705
- "name": "click"
3715
+ "name": "click",
3716
+ "description": "Triggers when the icon is clicked."
3706
3717
  },
3707
3718
  {
3708
- "name": "focus"
3719
+ "name": "focus",
3720
+ "description": "Triggers when the icon is focused."
3709
3721
  },
3710
3722
  {
3711
- "name": "blur"
3723
+ "name": "blur",
3724
+ "description": "Triggers when the icon loses focus."
3712
3725
  }
3713
3726
  ],
3714
3727
  "source": {
@@ -5304,10 +5317,20 @@
5304
5317
  ],
5305
5318
  "events": [
5306
5319
  {
5307
- "name": "update:modelValue"
5320
+ "name": "update:modelValue",
5321
+ "description": "Triggers when the modal is toggled.",
5322
+ "properties": [
5323
+ {
5324
+ "type": [
5325
+ "Boolean"
5326
+ ],
5327
+ "name": "value"
5328
+ }
5329
+ ]
5308
5330
  },
5309
5331
  {
5310
- "name": "back"
5332
+ "name": "back",
5333
+ "description": "Triggers when back link in modal is clicked."
5311
5334
  }
5312
5335
  ],
5313
5336
  "slots": [
@@ -5433,13 +5456,24 @@
5433
5456
  ],
5434
5457
  "events": [
5435
5458
  {
5436
- "name": "update:modelValue"
5459
+ "name": "update:modelValue",
5460
+ "description": "Triggers when the modal is toggled.",
5461
+ "properties": [
5462
+ {
5463
+ "type": [
5464
+ "Boolean"
5465
+ ],
5466
+ "name": "value"
5467
+ }
5468
+ ]
5437
5469
  },
5438
5470
  {
5439
- "name": "confirm"
5471
+ "name": "confirm",
5472
+ "description": "Triggers when the action is confirmed."
5440
5473
  },
5441
5474
  {
5442
- "name": "close"
5475
+ "name": "close",
5476
+ "description": "Triggers when the action is declined or modal is closed."
5443
5477
  }
5444
5478
  ],
5445
5479
  "slots": [
@@ -6030,9 +6064,18 @@
6030
6064
  },
6031
6065
  "default": "false"
6032
6066
  },
6067
+ {
6068
+ "name": "config",
6069
+ "description": "Component ui config object.",
6070
+ "value": {
6071
+ "kind": "expression",
6072
+ "type": "object"
6073
+ },
6074
+ "default": "{}"
6075
+ },
6033
6076
  {
6034
6077
  "name": "dataCy",
6035
- "description": "Sets data-cy attribute for automated testing.",
6078
+ "description": "Data-cy attribute for automated testing.",
6036
6079
  "value": {
6037
6080
  "kind": "expression",
6038
6081
  "type": "string"