vueless 0.0.206 → 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 (44) 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.data-table/components/TableRow.vue +1 -1
  30. package/ui.data-table/composables/attrs.composable.js +2 -0
  31. package/ui.data-table/configs/default.config.js +3 -2
  32. package/ui.data-table/index.vue +2 -0
  33. package/ui.form-date-picker-range/configs/default.config.js +2 -6
  34. package/ui.form-date-picker-range/index.vue +29 -12
  35. package/ui.form-input/index.stories.js +2 -5
  36. package/ui.image-avatar/composables/attrs.composable.js +28 -24
  37. package/ui.image-avatar/configs/default.config.js +1 -1
  38. package/ui.image-avatar/index.vue +7 -2
  39. package/ui.image-icon/composables/attrs.composable.js +24 -49
  40. package/ui.image-icon/index.vue +17 -2
  41. package/ui.loader/index.stories.js +32 -2
  42. package/ui.navigation-progress/index.stories.js +48 -106
  43. package/ui.navigation-progress/index.vue +9 -1
  44. package/web-types.json +58 -15
@@ -79,27 +79,35 @@
79
79
  @keydown.esc="deactivate"
80
80
  >
81
81
  <div v-bind="periodsRowAttrs">
82
- <div
82
+ <UButton
83
83
  v-for="periodButton in periods"
84
84
  :key="periodButton.name"
85
+ variant="thirdary"
86
+ size="xs"
87
+ square
88
+ color="brand"
85
89
  v-bind="periodButtonAttrs(getPeriodButtonsClasses(periodButton.name))"
86
90
  @click="onClickPeriodButton(periodButton.name)"
87
91
  >
88
92
  {{ periodButton.title }}
89
- </div>
93
+ </UButton>
90
94
  </div>
91
95
 
92
96
  <div v-bind="periodsRowAttrs">
93
- <div
97
+ <UButton
94
98
  v-if="customRangeButton.range.to && customRangeButton.range.from"
99
+ variant="thirdary"
100
+ color="brand"
95
101
  v-bind="periodButtonAttrs(getPeriodButtonsClasses(PERIOD.custom))"
96
102
  @click="onClickCustomRangeButton"
97
103
  >
98
104
  {{ customRangeButton.label }}
99
105
  <span v-if="customRangeButton.description" v-text="customRangeButton.description" />
100
- </div>
106
+ </UButton>
101
107
 
102
- <div
108
+ <UButton
109
+ variant="thirdary"
110
+ color="brand"
103
111
  v-bind="periodButtonAttrs(getPeriodButtonsClasses(PERIOD.ownRange))"
104
112
  @click="onClickOwnRange"
105
113
  >
@@ -110,7 +118,7 @@
110
118
  v-bind="periodButtonIconAttrs"
111
119
  />
112
120
  {{ locale.ownRange }}
113
- </div>
121
+ </UButton>
114
122
  </div>
115
123
 
116
124
  <template v-if="!isPeriod.ownRange && !isPeriod.custom">
@@ -141,13 +149,16 @@
141
149
  </div>
142
150
 
143
151
  <div v-bind="periodDateListAttrs(getPeriodDateListClasses())">
144
- <button
152
+ <UButton
145
153
  v-for="date in periodDateList"
146
154
  :key="date.title"
147
155
  :disabled="isDatePeriodOutOfRange(date)"
156
+ variant="thirdary"
157
+ color="brand"
158
+ size="sm"
148
159
  v-bind="periodDateAttrs(getPeriodDateClasses(date))"
160
+ :label="String(date.title)"
149
161
  @click="selectDate(date), toggleMenu()"
150
- v-text="date.title"
151
162
  />
152
163
  </div>
153
164
  </template>
@@ -522,9 +533,7 @@ const localValue = computed({
522
533
  emit("update:modelValue", newValue);
523
534
  }
524
535
 
525
- activeDate.value = props.dateFormat
526
- ? formatDate(parsedDateFrom || new Date(), props.dateFormat, locale.value)
527
- : value.from || new Date();
536
+ activeDate.value = props.dateFormat ? parsedDateFrom || new Date() : value.from || new Date();
528
537
  },
529
538
  });
530
539
 
@@ -739,7 +748,15 @@ watch(
739
748
  );
740
749
 
741
750
  watch(period, () => {
742
- activeDate.value = localValue.value.from !== null ? localValue.value.from : new Date();
751
+ const isDate = localValue.value.from !== null;
752
+
753
+ if (isDate && !props.dateFormat) {
754
+ activeDate.value = isDate ? localValue.value.from : new Date();
755
+ }
756
+
757
+ if (isDate && props.dateFormat) {
758
+ activeDate.value = isDate ? parseDate(localValue.value.from, locale.value) : new Date();
759
+ }
743
760
  });
744
761
 
745
762
  function onClickPeriodButton(periodName) {
@@ -30,9 +30,7 @@ const DefaultTemplate = (args) => ({
30
30
  return { args, slots };
31
31
  },
32
32
  template: `
33
- <UInput
34
- v-bind="args"
35
- >
33
+ <UInput v-bind="args" v-model="args.modelValue">
36
34
  ${allSlotsFragment}
37
35
  </UInput>
38
36
  `,
@@ -44,8 +42,7 @@ const SlotTemplate = (args) => ({
44
42
  return { args };
45
43
  },
46
44
  template: `
47
- <UInput v-bind="args"
48
- >
45
+ <UInput v-bind="args">
49
46
  ${args.slotTemplate}
50
47
  </UInput>
51
48
  `,
@@ -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,