vueless 0.0.372 → 0.0.374

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.
@@ -1,62 +1,36 @@
1
+ import { computed } from "vue";
1
2
  import useUI from "../composables/useUI.js";
2
- import { cva, cx } from "../utils/utilUI.js";
3
3
  import { isMobileApp } from "../utils/utilPlatform.js";
4
4
 
5
5
  import defaultConfig from "./config.js";
6
- import { computed } from "vue";
7
6
 
8
7
  export default function useAttrs(props, { isMobileBreakpoint }) {
9
- const { config, getAttrs, hasSlotContent, isSystemKey, isCVA } = useUI(
8
+ const { config, getKeysAttrs, hasSlotContent, getExtendingKeysClasses } = useUI(
10
9
  defaultConfig,
11
10
  () => props.config,
12
11
  );
13
- const attrs = {};
14
-
15
- for (const key in defaultConfig) {
16
- if (isSystemKey(key)) continue;
17
-
18
- const classes = computed(() => {
19
- let value = config.value[key];
20
-
21
- if (isCVA(value)) {
22
- value = cva(value)({
23
- ...props,
24
- });
25
- }
26
-
27
- return value;
28
- });
29
-
30
- attrs[`${key}Attrs`] = getAttrs(key, { classes });
31
-
32
- if (key === "wrapper") {
33
- const wrapperAttrs = attrs[`${key}Attrs`];
34
-
35
- attrs[`${key}Attrs`] = computed(() => ({
36
- ...wrapperAttrs.value,
37
- class: cx([
38
- wrapperAttrs.value.class,
39
- isMobileBreakpoint.value && !isMobileApp && config.value.wrapperMobile,
40
- ]),
41
- }));
42
- }
43
-
44
- if (key === "footer") {
45
- const footerAttrs = attrs[`${key}Attrs`];
46
12
 
47
- attrs[`${key}Attrs`] = computed(() => ({
48
- ...footerAttrs.value,
49
- class: cx([
50
- footerAttrs.value.class,
51
- props.mobileFooterReverse && isMobileBreakpoint.value && config.value.footerMobileReverse,
52
- ]),
53
- }));
54
- }
55
- }
13
+ const extendingKeys = ["wrapperMobile", "footerMobileReverse"];
14
+ const extendingKeysClasses = getExtendingKeysClasses(extendingKeys);
15
+
16
+ const keysAttrs = getKeysAttrs({}, extendingKeys, {
17
+ wrapper: {
18
+ extend: computed(() => [
19
+ isMobileBreakpoint.value && !isMobileApp && extendingKeysClasses.wrapperMobile.value,
20
+ ]),
21
+ },
22
+ footer: {
23
+ extend: computed(() => [
24
+ props.mobileFooterReverse &&
25
+ isMobileBreakpoint.value &&
26
+ extendingKeysClasses.footerMobileReverse.value,
27
+ ]),
28
+ },
29
+ });
56
30
 
57
31
  return {
58
- ...attrs,
59
32
  config,
33
+ ...keysAttrs,
60
34
  hasSlotContent,
61
35
  };
62
36
  }
@@ -1,36 +1,15 @@
1
1
  import useUI from "../composables/useUI.js";
2
+
2
3
  import defaultConfig from "./config.js";
3
- import { cva } from "../utils/utilUI.js";
4
- import { computed } from "vue";
5
4
 
6
5
  export default function useAttrs(props) {
7
- const { config, getAttrs, isSystemKey, hasSlotContent, isCVA } = useUI(
8
- defaultConfig,
9
- () => props.config,
10
- );
11
- const attrs = {};
12
-
13
- for (const key in defaultConfig) {
14
- if (isSystemKey(key)) continue;
15
-
16
- const classes = computed(() => {
17
- let value = config.value[key];
18
-
19
- if (isCVA(value)) {
20
- value = cva(value)({
21
- ...props,
22
- });
23
- }
24
-
25
- return value;
26
- });
6
+ const { config, getKeysAttrs, hasSlotContent } = useUI(defaultConfig, () => props.config);
27
7
 
28
- attrs[`${key}Attrs`] = getAttrs(key, { classes });
29
- }
8
+ const keysAttrs = getKeysAttrs();
30
9
 
31
10
  return {
32
- ...attrs,
33
11
  config,
12
+ ...keysAttrs,
34
13
  hasSlotContent,
35
14
  };
36
15
  }
@@ -1,50 +1,28 @@
1
+ import { computed } from "vue";
1
2
  import useUI from "../composables/useUI.js";
2
- import { cva, cx } from "../utils/utilUI.js";
3
3
 
4
4
  import defaultConfig from "./config.js";
5
- import { computed } from "vue";
6
5
 
7
6
  export default function useAttrs(props, { isShownOptions }) {
8
- const { config, getColor, setColor, getAttrs, hasSlotContent, isSystemKey, isCVA } = useUI(
7
+ const { config, getKeysAttrs, hasSlotContent, getExtendingKeysClasses } = useUI(
9
8
  defaultConfig,
10
9
  () => props.config,
11
10
  );
12
- const attrs = {};
13
-
14
- for (const key in defaultConfig) {
15
- if (isSystemKey(key)) continue;
16
-
17
- const classes = computed(() => {
18
- let value = config.value[key];
19
-
20
- if (isCVA(value)) {
21
- value = cva(value)({
22
- ...props,
23
- color: getColor(props.color),
24
- });
25
- }
26
-
27
- return setColor(value, props.color);
28
- });
29
-
30
- attrs[`${key}Attrs`] = getAttrs(key, { classes });
31
11
 
32
- if (key === "dropdownBadge") {
33
- const badgeAttrs = attrs[`${key}Attrs`];
12
+ const extendingKeys = ["dropdownBadgeActive"];
13
+ const extendingKeysClasses = getExtendingKeysClasses(extendingKeys);
34
14
 
35
- attrs[`${key}Attrs`] = computed(() => ({
36
- ...badgeAttrs.value,
37
- class: cx([
38
- badgeAttrs.value.class,
39
- isShownOptions.value && setColor(config.value.dropdownBadgeActive, props.color),
40
- ]),
41
- }));
42
- }
43
- }
15
+ const keysAttrs = getKeysAttrs({}, extendingKeys, {
16
+ dropdownBadge: {
17
+ extend: computed(() => [
18
+ isShownOptions.value && extendingKeysClasses.dropdownBadgeActive.value,
19
+ ]),
20
+ },
21
+ });
44
22
 
45
23
  return {
46
- ...attrs,
47
24
  config,
25
+ ...keysAttrs,
48
26
  hasSlotContent,
49
27
  };
50
28
  }
@@ -1,50 +1,28 @@
1
+ import { computed } from "vue";
1
2
  import useUI from "../composables/useUI.js";
2
- import { cva, cx } from "../utils/utilUI.js";
3
3
 
4
4
  import defaultConfig from "./config.js";
5
- import { computed } from "vue";
6
5
 
7
6
  export default function useAttrs(props, { isShownOptions }) {
8
- const { config, getColor, setColor, getAttrs, hasSlotContent, isSystemKey, isCVA } = useUI(
7
+ const { config, getKeysAttrs, hasSlotContent, getExtendingKeysClasses } = useUI(
9
8
  defaultConfig,
10
9
  () => props.config,
11
10
  );
12
- const attrs = {};
13
-
14
- for (const key in defaultConfig) {
15
- if (isSystemKey(key)) continue;
16
-
17
- const classes = computed(() => {
18
- let value = config.value[key];
19
-
20
- if (isCVA(value)) {
21
- value = cva(value)({
22
- ...props,
23
- color: getColor(props.color),
24
- });
25
- }
26
-
27
- return setColor(value, props.color);
28
- });
29
-
30
- attrs[`${key}Attrs`] = getAttrs(key, { classes });
31
11
 
32
- if (key === "dropdownLink") {
33
- const linkAttrs = attrs[`${key}Attrs`];
12
+ const extendingKeys = ["dropdownLinkActive"];
13
+ const extendingKeysClasses = getExtendingKeysClasses(extendingKeys);
34
14
 
35
- attrs[`${key}Attrs`] = computed(() => ({
36
- ...linkAttrs.value,
37
- class: cx([
38
- linkAttrs.value.class,
39
- isShownOptions.value && setColor(config.value.dropdownLinkActive, props.color),
40
- ]),
41
- }));
42
- }
43
- }
15
+ const keysAttrs = getKeysAttrs({}, extendingKeys, {
16
+ dropdownLink: {
17
+ extend: computed(() => [
18
+ isShownOptions.value && extendingKeysClasses.dropdownLinkActive.value,
19
+ ]),
20
+ },
21
+ });
44
22
 
45
23
  return {
46
- ...attrs,
47
24
  config,
25
+ ...keysAttrs,
48
26
  hasSlotContent,
49
27
  };
50
28
  }
@@ -34,10 +34,10 @@
34
34
  <slot name="before-option" :option="option" :index="index" />
35
35
 
36
36
  <!--
37
- @slot Use it to add something instead of the option.
38
- @binding {object} option
39
- @binding {number} index
40
- -->
37
+ @slot Use it to add something instead of the option.
38
+ @binding {object} option
39
+ @binding {number} index
40
+ -->
41
41
  <slot name="option" :option="option" :index="index">
42
42
  <span
43
43
  :style="getMarginForSubCategory(option.level)"
@@ -47,10 +47,10 @@
47
47
  </slot>
48
48
 
49
49
  <!--
50
- @slot Use it to add something after the option.
51
- @binding {object} option
52
- @binding {number} index
53
- -->
50
+ @slot Use it to add something after the option.
51
+ @binding {object} option
52
+ @binding {number} index
53
+ -->
54
54
  <slot name="after-option" :option="option" :index="index" />
55
55
  </span>
56
56
 
@@ -67,15 +67,12 @@
67
67
  </template>
68
68
  </li>
69
69
 
70
- <!--
71
- @slot Use it to add something instead of empty state.
72
- @binding {string} emptyStyles
73
- -->
74
- <slot name="empty" :empty-styles="optionClasses">
75
- <span v-if="!options.length" v-bind="optionAttrs">
70
+ <div v-if="!options.length" v-bind="optionAttrs">
71
+ <!-- @slot Use it to add something instead of empty state. -->
72
+ <slot name="empty">
76
73
  <span v-bind="optionContentAttrs" v-text="currentLocale.noDataToShow" />
77
- </span>
78
- </slot>
74
+ </slot>
75
+ </div>
79
76
 
80
77
  <!-- Add button -->
81
78
  <template v-if="addOption">
@@ -229,7 +226,6 @@ const {
229
226
  optionAttrs,
230
227
  subGroupAttrs,
231
228
  groupAttrs,
232
- optionClasses,
233
229
  optionContentAttrs,
234
230
  } = useAttrs(props);
235
231
 
@@ -1,53 +1,29 @@
1
+ import { computed } from "vue";
1
2
  import useUI from "../composables/useUI.js";
2
- import { cva, cx } from "../utils/utilUI.js";
3
3
 
4
4
  import defaultConfig from "./config.js";
5
- import { computed } from "vue";
6
5
 
7
6
  export default function useAttrs(props) {
8
- const { config, getAttrs, hasSlotContent, isSystemKey, isCVA } = useUI(
7
+ const { config, getKeysAttrs, hasSlotContent, getExtendingKeysClasses } = useUI(
9
8
  defaultConfig,
10
9
  () => props.config,
11
10
  );
12
- const attrs = {};
13
-
14
- const optionClasses = computed(() =>
15
- cva(config.value.option)({
16
- ...props,
17
- }),
18
- );
19
-
20
- for (const key in defaultConfig) {
21
- if (isSystemKey(key)) continue;
22
-
23
- const classes = computed(() => {
24
- let value = config.value[key];
25
11
 
26
- if (isCVA(value)) {
27
- value = cva(value)({
28
- ...props,
29
- });
30
- }
12
+ const extendingKeys = ["option"];
13
+ const extendingKeysClasses = getExtendingKeysClasses(extendingKeys);
31
14
 
32
- return value;
33
- });
34
-
35
- attrs[`${key}Attrs`] = getAttrs(key, { classes });
36
-
37
- if (key === "group" || key === "subGroup") {
38
- const keyAttrs = attrs[`${key}Attrs`];
39
-
40
- attrs[`${key}Attrs`] = computed(() => ({
41
- ...keyAttrs.value,
42
- class: cx([optionClasses.value, keyAttrs.value.class]),
43
- }));
44
- }
45
- }
15
+ const keysAttrs = getKeysAttrs({}, [], {
16
+ group: {
17
+ base: computed(() => [extendingKeysClasses.option.value]),
18
+ },
19
+ subGroup: {
20
+ base: computed(() => [extendingKeysClasses.option.value]),
21
+ },
22
+ });
46
23
 
47
24
  return {
48
- ...attrs,
49
- optionClasses,
50
- hasSlotContent,
51
25
  config,
26
+ ...keysAttrs,
27
+ hasSlotContent,
52
28
  };
53
29
  }
@@ -294,13 +294,14 @@
294
294
  <slot name="after-option" :option="option" :index="index" />
295
295
  </template>
296
296
 
297
- <template #empty="{ emptyStyles }">
298
- <span v-show="isEmpty" :class="emptyStyles" v-text="currentLocale.listIsEmpty" />
299
- <span
300
- v-show="options.length === 0 && !search && !isEmpty"
301
- :class="emptyStyles"
302
- v-text="currentLocale.noDataToShow"
303
- />
297
+ <template #empty>
298
+ <template v-if="isEmpty">
299
+ {{ currentLocale.listIsEmpty }}
300
+ </template>
301
+
302
+ <template v-else>
303
+ {{ currentLocale.noDataToShow }}
304
+ </template>
304
305
  </template>
305
306
  </UDropdownList>
306
307
  </div>
@@ -10,17 +10,23 @@
10
10
  <template v-if="labelFirstLetters">{{ labelFirstLetters }}</template>
11
11
  <!--
12
12
  @slot Use it to add something instead of the avatar image placeholder.
13
+ @binding {string} icon-name
13
14
  @binding {string} icon-color
14
15
  @binding {string} icon-size
15
16
  -->
16
17
  <slot
17
18
  v-else
18
19
  name="placeholder"
19
- :icon-name="icon"
20
+ :icon-name="placeholderIcon"
20
21
  :icon-color="componentColor"
21
22
  :icon-size="size"
22
23
  >
23
- <UIcon :name="icon" :color="componentColor" :size="size" v-bind="placeholderIconAttrs" />
24
+ <UIcon
25
+ :name="placeholderIcon"
26
+ :color="componentColor"
27
+ :size="size"
28
+ v-bind="placeholderIconAttrs"
29
+ />
24
30
  </slot>
25
31
  </template>
26
32
  </div>
@@ -58,7 +64,7 @@ const props = defineProps({
58
64
  /**
59
65
  * Avatar icon placeholder.
60
66
  */
61
- icon: {
67
+ placeholderIcon: {
62
68
  type: String,
63
69
  default: getDefault(defaultConfig, UAvatar).placeholderIcon,
64
70
  },
@@ -122,6 +128,8 @@ const emit = defineEmits([
122
128
  "click",
123
129
  ]);
124
130
 
131
+ const { avatarAttrs, placeholderIconAttrs } = useAttrs(props);
132
+
125
133
  const labelFirstLetters = computed(() => {
126
134
  const [firstWord, secondWord] = props.label.split(" ");
127
135
 
@@ -138,9 +146,9 @@ const backgroundImage = computed(() => {
138
146
  return props.src ? `background-image: url(${src});` : "";
139
147
  });
140
148
 
141
- const { avatarAttrs, placeholderIconAttrs } = useAttrs(props);
142
-
143
- const componentColor = computed(() => (props.color === "white" ? "grayscale" : props.color));
149
+ const componentColor = computed(() => {
150
+ return props.color === "white" ? "grayscale" : props.color;
151
+ });
144
152
 
145
153
  function onClick(event) {
146
154
  emit("click", event);
@@ -1,38 +1,15 @@
1
1
  import useUI from "../composables/useUI.js";
2
- import { cva } from "../utils/utilUI.js";
3
2
 
4
3
  import defaultConfig from "./config.js";
5
- import { computed } from "vue";
6
4
 
7
5
  export default function useAttrs(props) {
8
- const { config, getAttrs, hasSlotContent, getColor, setColor, isSystemKey, isCVA } = useUI(
9
- defaultConfig,
10
- () => props.config,
11
- );
12
- const attrs = {};
6
+ const { config, getKeysAttrs, hasSlotContent } = useUI(defaultConfig, () => props.config);
13
7
 
14
- for (const key in defaultConfig) {
15
- if (isSystemKey(key)) continue;
16
-
17
- const classes = computed(() => {
18
- let value = config.value[key];
19
-
20
- if (isCVA(value)) {
21
- value = cva(value)({
22
- ...props,
23
- color: getColor(props.color),
24
- });
25
- }
26
-
27
- return setColor(value, props.color);
28
- });
29
-
30
- attrs[`${key}Attrs`] = getAttrs(key, { classes });
31
- }
8
+ const keysAttrs = getKeysAttrs();
32
9
 
33
10
  return {
34
- ...attrs,
35
11
  config,
12
+ ...keysAttrs,
36
13
  hasSlotContent,
37
14
  };
38
15
  }
@@ -1,43 +1,23 @@
1
1
  import { computed, useSlots } from "vue";
2
-
3
2
  import useUI from "../composables/useUI.js";
4
- import { cva } from "../utils/utilUI.js";
5
3
 
6
4
  import defaultConfig from "./config.js";
7
5
 
8
6
  export default function useAttrs(props) {
7
+ const { config, getKeysAttrs, hasSlotContent } = useUI(defaultConfig, () => props.config);
9
8
  const slots = useSlots();
10
- const { config, getAttrs, hasSlotContent, getColor, setColor, isSystemKey, isCVA } = useUI(
11
- defaultConfig,
12
- () => props.config,
13
- );
14
- const attrs = {};
15
-
16
- for (const key in defaultConfig) {
17
- if (isSystemKey(key)) continue;
18
-
19
- const classes = computed(() => {
20
- let value = config.value[key];
21
-
22
- if (isCVA(value)) {
23
- value = cva(value)({
24
- ...props,
25
- color: getColor(props.color),
26
- tabindex: Boolean(~props.tabindex),
27
- leftIcon: Boolean(props.leftIcon) || hasSlotContent(slots["left"]),
28
- rightIcon: Boolean(props.rightIcon) || hasSlotContent(slots["right"]),
29
- });
30
- }
31
9
 
32
- return setColor(value, props.color);
33
- });
10
+ const mutatedProps = computed(() => ({
11
+ tabindex: Boolean(~props.tabindex),
12
+ leftIcon: Boolean(props.leftIcon) || hasSlotContent(slots["left"]),
13
+ rightIcon: Boolean(props.rightIcon) || hasSlotContent(slots["right"]),
14
+ }));
34
15
 
35
- attrs[`${key}Attrs`] = getAttrs(key, { classes });
36
- }
16
+ const keysAttrs = getKeysAttrs(mutatedProps);
37
17
 
38
18
  return {
39
- ...attrs,
40
19
  config,
20
+ ...keysAttrs,
41
21
  hasSlotContent,
42
22
  };
43
23
  }
@@ -1,37 +1,15 @@
1
1
  import useUI from "../composables/useUI.js";
2
- import { cva } from "../utils/utilUI.js";
3
2
 
4
3
  import defaultConfig from "./config.js";
5
- import { computed } from "vue";
6
4
 
7
5
  export default function useAttrs(props) {
8
- const { config, getAttrs, hasSlotContent, isSystemKey, isCVA } = useUI(
9
- defaultConfig,
10
- () => props.config,
11
- );
12
- const attrs = {};
6
+ const { config, getKeysAttrs, hasSlotContent } = useUI(defaultConfig, () => props.config);
13
7
 
14
- for (const key in defaultConfig) {
15
- if (isSystemKey(key)) continue;
16
-
17
- const classes = computed(() => {
18
- let value = config.value[key];
19
-
20
- if (isCVA(value)) {
21
- value = cva(value)({
22
- ...props,
23
- });
24
- }
25
-
26
- return value;
27
- });
28
-
29
- attrs[`${key}Attrs`] = getAttrs(key, { classes });
30
- }
8
+ const keysAttrs = getKeysAttrs();
31
9
 
32
10
  return {
33
- ...attrs,
34
11
  config,
12
+ ...keysAttrs,
35
13
  hasSlotContent,
36
14
  };
37
15
  }
@@ -1,37 +1,15 @@
1
1
  import useUI from "../composables/useUI.js";
2
- import { cva } from "../utils/utilUI.js";
3
2
 
4
3
  import defaultConfig from "./config.js";
5
- import { computed } from "vue";
6
4
 
7
5
  export default function useAttrs(props) {
8
- const { config, getAttrs, isSystemKey, hasSlotContent, isCVA } = useUI(
9
- defaultConfig,
10
- () => props.config,
11
- );
12
- const attrs = {};
6
+ const { config, getKeysAttrs, hasSlotContent } = useUI(defaultConfig, () => props.config);
13
7
 
14
- for (const key in defaultConfig) {
15
- if (isSystemKey(key)) continue;
16
-
17
- const classes = computed(() => {
18
- let value = config.value[key];
19
-
20
- if (isCVA(value)) {
21
- value = cva(value)({
22
- ...props,
23
- });
24
- }
25
-
26
- return value;
27
- });
28
-
29
- attrs[`${key}Attrs`] = getAttrs(key, { classes });
30
- }
8
+ const keysAttrs = getKeysAttrs();
31
9
 
32
10
  return {
33
- ...attrs,
34
11
  config,
12
+ ...keysAttrs,
35
13
  hasSlotContent,
36
14
  };
37
15
  }
@@ -103,12 +103,8 @@ const focus = ref(false);
103
103
 
104
104
  const elementId = props.id || useId();
105
105
 
106
- const { config, fileAttrs, bodyAttrs, fileIconAttrs, fileLabelAttrs, fileImageAttrs } = useAttrs(
107
- props,
108
- {
109
- focus,
110
- },
111
- );
106
+ const { config, fileAttrs, bodyAttrs, fileIconAttrs, fileLabelAttrs, fileImageAttrs } =
107
+ useAttrs(props);
112
108
 
113
109
  const iconSize = computed(() => {
114
110
  const sizes = {