vueless 0.0.317 → 0.0.319

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.317",
3
+ "version": "0.0.319",
4
4
  "license": "MIT",
5
5
  "description": "Vue Styleless Component Framework.",
6
6
  "homepage": "https://vueless.com",
@@ -1,6 +1,8 @@
1
1
  import { computed, useSlots } from "vue";
2
+
2
3
  import useUI from "../../composable.ui";
3
4
  import { cva } from "../../service.ui";
5
+
4
6
  import defaultConfig from "../configs/default.config";
5
7
 
6
8
  export default function useAttrs(props) {
@@ -49,7 +49,7 @@ export default /*tw*/ {
49
49
  true: "!ring-0 !ring-offset-0",
50
50
  },
51
51
  loading: {
52
- true: "pointer-events-none gap-0 !ring-0",
52
+ true: "pointer-events-none gap-0",
53
53
  },
54
54
  block: {
55
55
  true: "w-full",
@@ -11,7 +11,7 @@
11
11
  <template v-if="loading">
12
12
  <!-- Label is needed to prevent changing button height -->
13
13
  <div tabindex="-1" class="invisible w-0" v-text="label" />
14
- <ULoader :loading="loading" :size="loaderSize" :color="componentColor" v-bind="loaderAttrs" />
14
+ <ULoader :loading="loading" :size="loaderSize" :color="iconColor" v-bind="loaderAttrs" />
15
15
  </template>
16
16
 
17
17
  <template v-else>
@@ -21,13 +21,13 @@
21
21
  @binding {string} icon-size
22
22
  @binding {string} icon-color
23
23
  -->
24
- <slot name="left" :icon-name="leftIcon" :icon-size="iconSize" :icon-color="componentColor">
24
+ <slot name="left" :icon-name="leftIcon" :icon-size="iconSize" :icon-color="iconColor">
25
25
  <UIcon
26
26
  v-if="leftIcon"
27
27
  internal
28
28
  :name="leftIcon"
29
29
  :size="iconSize"
30
- :color="componentColor"
30
+ :color="iconColor"
31
31
  v-bind="leftIconAttrs"
32
32
  />
33
33
  </slot>
@@ -44,14 +44,14 @@
44
44
  :label="label"
45
45
  :icon-name="icon"
46
46
  :icon-size="iconSize"
47
- :icon-color="componentColor"
47
+ :icon-color="iconColor"
48
48
  >
49
49
  <UIcon
50
50
  v-if="icon"
51
51
  internal
52
52
  :name="icon"
53
53
  :size="iconSize"
54
- :color="componentColor"
54
+ :color="iconColor"
55
55
  v-bind="centerIconAttrs"
56
56
  />
57
57
  <template v-else>
@@ -65,13 +65,13 @@
65
65
  @binding {string} icon-size
66
66
  @binding {string} icon-color
67
67
  -->
68
- <slot name="right" :icon-name="rightIcon" :icon-size="iconSize" :icon-color="componentColor">
68
+ <slot name="right" :icon-name="rightIcon" :icon-size="iconSize" :icon-color="iconColor">
69
69
  <UIcon
70
70
  v-if="rightIcon"
71
71
  internal
72
72
  :name="rightIcon"
73
73
  :size="iconSize"
74
- :color="componentColor"
74
+ :color="iconColor"
75
75
  v-bind="rightIconAttrs"
76
76
  />
77
77
  </slot>
@@ -80,7 +80,7 @@
80
80
  </template>
81
81
 
82
82
  <script setup>
83
- import { computed, ref } from "vue";
83
+ import { computed, ref, watchEffect } from "vue";
84
84
 
85
85
  import { getRandomId, getDefault } from "../service.ui";
86
86
  import ULoader from "../ui.loader";
@@ -284,7 +284,11 @@ const iconSize = computed(() => {
284
284
  return sizes[props.size];
285
285
  });
286
286
 
287
- const componentColor = computed(() => {
287
+ const iconColor = computed(() => {
288
288
  return props.variant === "primary" ? "white" : props.color;
289
289
  });
290
+
291
+ watchEffect(() => {
292
+ props.loading && buttonRef.value.blur();
293
+ });
290
294
  </script>
@@ -28,12 +28,15 @@ export default function useAttrs(props, { isShownOptions }) {
28
28
 
29
29
  attrs[`${key}Attrs`] = getAttrs(key, { classes });
30
30
 
31
- if (key === "badge") {
31
+ if (key === "dropdownBadge") {
32
32
  const badgeAttrs = attrs[`${key}Attrs`];
33
33
 
34
34
  attrs[`${key}Attrs`] = computed(() => ({
35
35
  ...badgeAttrs.value,
36
- class: cx([badgeAttrs.value.class, isShownOptions.value && config.value.badgeActive]),
36
+ class: cx([
37
+ badgeAttrs.value.class,
38
+ isShownOptions.value && config.value.dropdownBadgeActive,
39
+ ]),
37
40
  }));
38
41
  }
39
42
  }
@@ -1,20 +1,11 @@
1
1
  export default /*tw*/ {
2
2
  wrapper: "relative inline-block",
3
- dropdownBadge: {
4
- component: "{UBadge}",
5
- base: "cursor-pointer",
6
- variants: {
7
- size: {
8
- sm: "pr-1",
9
- md: "pr-1.5",
10
- lg: "pr-1.5",
11
- },
12
- },
13
- },
3
+ dropdownBadge: "{UBadge}",
14
4
  dropdownBadgeActive: "group",
15
5
  dropdownIcon: "{UIcon} transition duration-300 group-[]:rotate-180",
16
6
  dropdownList: {
17
- base: "{UDropdownList} w-fit",
7
+ component: "{UDropdownList}",
8
+ base: "w-fit",
18
9
  variants: {
19
10
  listYPosition: {
20
11
  top: "bottom-6 mb-6",
@@ -29,12 +20,12 @@ export default /*tw*/ {
29
20
  defaults: {
30
21
  color: "brand",
31
22
  size: "md",
32
- weight: "medium",
33
23
  variant: "primary",
34
24
  labelKey: "label",
35
25
  valueKey: "id",
36
26
  listYPosition: "bottom",
37
27
  listXPosition: "left",
28
+ round: false,
38
29
  noIcon: false,
39
30
  /* icons */
40
31
  dropdownIcon: "keyboard_arrow_down",
@@ -5,11 +5,13 @@
5
5
  :label="label"
6
6
  :size="size"
7
7
  :color="color"
8
- :weight="weight"
9
8
  :variant="variant"
10
9
  v-bind="dropdownBadgeAttrs"
11
- :data-test="`${dataTest}-badge`"
10
+ tabindex="0"
11
+ :data-test="dataTest"
12
12
  @click="onClickBadge"
13
+ @keydown.enter="onClickBadge"
14
+ @keydown.space.prevent="onClickBadge"
13
15
  >
14
16
  <template #left>
15
17
  <!--
@@ -28,7 +30,7 @@
28
30
  <slot :label="label" :opened="isShownOptions" />
29
31
  </template>
30
32
 
31
- <template #right>
33
+ <template #right="{ iconColor, iconSize }">
32
34
  <!--
33
35
  @slot Use it to add something after the label.
34
36
  @binding {boolean} isOpened
@@ -37,11 +39,11 @@
37
39
  <UIcon
38
40
  v-if="!noIcon"
39
41
  internal
40
- :color="color"
42
+ :color="iconColor"
41
43
  :size="iconSize"
42
44
  :name="config.defaults.dropdownIcon"
43
45
  v-bind="dropdownIconAttrs"
44
- :data-test="`${dataTest}-caret`"
46
+ :data-test="`${dataTest}-dropdown`"
45
47
  />
46
48
  </slot>
47
49
  </template>
@@ -62,7 +64,7 @@
62
64
  </template>
63
65
 
64
66
  <script setup>
65
- import { computed, provide, ref, watch } from "vue";
67
+ import { provide, ref, watch } from "vue";
66
68
 
67
69
  import UIcon from "../ui.image-icon";
68
70
  import UBadge from "../ui.text-badge";
@@ -88,6 +90,30 @@ const props = defineProps({
88
90
  default: "",
89
91
  },
90
92
 
93
+ /**
94
+ * Options list.
95
+ */
96
+ options: {
97
+ type: Array,
98
+ default: () => [],
99
+ },
100
+
101
+ /**
102
+ * Label key in the item object of options.
103
+ */
104
+ labelKey: {
105
+ type: String,
106
+ default: getDefault(defaultConfig, UDropdownBadge).labelKey,
107
+ },
108
+
109
+ /**
110
+ * Value key in the item object of options.
111
+ */
112
+ valueKey: {
113
+ type: String,
114
+ default: getDefault(defaultConfig, UDropdownBadge).valueKey,
115
+ },
116
+
91
117
  /**
92
118
  * Badge variant.
93
119
  * @values primary, secondary, thirdary
@@ -116,12 +142,11 @@ const props = defineProps({
116
142
  },
117
143
 
118
144
  /**
119
- * Badge font weight.
120
- * @values regular, medium, bold
145
+ * Set badge corners rounded.
121
146
  */
122
- weight: {
123
- type: String,
124
- default: getDefault(defaultConfig, UDropdownBadge).weight,
147
+ round: {
148
+ type: Boolean,
149
+ default: getDefault(defaultConfig, UDropdownBadge).round,
125
150
  },
126
151
 
127
152
  /**
@@ -132,30 +157,6 @@ const props = defineProps({
132
157
  default: getDefault(defaultConfig, UDropdownBadge).noIcon,
133
158
  },
134
159
 
135
- /**
136
- * Options list.
137
- */
138
- options: {
139
- type: Array,
140
- default: () => [],
141
- },
142
-
143
- /**
144
- * Label key in the item object of options.
145
- */
146
- labelKey: {
147
- type: String,
148
- default: getDefault(defaultConfig, UDropdownBadge).labelKey,
149
- },
150
-
151
- /**
152
- * Value key in the item object of options.
153
- */
154
- valueKey: {
155
- type: String,
156
- default: getDefault(defaultConfig, UDropdownBadge).valueKey,
157
- },
158
-
159
160
  /**
160
161
  * The position of dropdown list on the y-axis.
161
162
  * @values top, bottom
@@ -220,16 +221,6 @@ const { config, wrapperAttrs, dropdownBadgeAttrs, dropdownListAttrs, dropdownIco
220
221
  },
221
222
  );
222
223
 
223
- const iconSize = computed(() => {
224
- const sizes = {
225
- sm: "2xs",
226
- md: "xs",
227
- lg: "sm",
228
- };
229
-
230
- return sizes[props.size];
231
- });
232
-
233
224
  watch(selectedItem, () => {
234
225
  emit("select", selectedItem.value);
235
226
  });
@@ -11,7 +11,7 @@
11
11
  :disabled="disabled"
12
12
  :filled="filled || isShownOptions"
13
13
  v-bind="dropdownButtonAttrs"
14
- :data-test="`${dataTest}-button`"
14
+ :data-test="dataTest"
15
15
  @click="onClickButton"
16
16
  >
17
17
  <template #left>
@@ -44,7 +44,7 @@
44
44
  :color="iconColor"
45
45
  :name="config.defaults.dropdownIcon"
46
46
  v-bind="dropdownIconAttrs"
47
- :data-test="`${dataTest}-caret`"
47
+ :data-test="`${dataTest}-dropdown`"
48
48
  />
49
49
  </slot>
50
50
  </template>
@@ -85,19 +85,35 @@ defineOptions({ name: "UDropdownButton", inheritAttrs: false });
85
85
 
86
86
  const props = defineProps({
87
87
  /**
88
- * Selected value.
88
+ * Button label.
89
89
  */
90
- modelValue: {
91
- type: [String, Number],
90
+ label: {
91
+ type: String,
92
92
  default: "",
93
93
  },
94
94
 
95
95
  /**
96
- * Button label.
96
+ * Options list.
97
97
  */
98
- label: {
98
+ options: {
99
+ type: Array,
100
+ default: () => [],
101
+ },
102
+
103
+ /**
104
+ * Label key in the item object of options.
105
+ */
106
+ labelKey: {
99
107
  type: String,
100
- default: "",
108
+ default: getDefault(defaultConfig, UDropdownButton).labelKey,
109
+ },
110
+
111
+ /**
112
+ * Value key in the item object of options.
113
+ */
114
+ valueKey: {
115
+ type: String,
116
+ default: getDefault(defaultConfig, UDropdownButton).valueKey,
101
117
  },
102
118
 
103
119
  /**
@@ -167,30 +183,6 @@ const props = defineProps({
167
183
  default: getDefault(defaultConfig, UDropdownButton).noIcon,
168
184
  },
169
185
 
170
- /**
171
- * Options list.
172
- */
173
- options: {
174
- type: Array,
175
- default: () => [],
176
- },
177
-
178
- /**
179
- * Label key in the item object of options.
180
- */
181
- labelKey: {
182
- type: String,
183
- default: getDefault(defaultConfig, UDropdownButton).labelKey,
184
- },
185
-
186
- /**
187
- * Value key in the item object of options.
188
- */
189
- valueKey: {
190
- type: String,
191
- default: getDefault(defaultConfig, UDropdownButton).valueKey,
192
- },
193
-
194
186
  /**
195
187
  * The position of dropdown list on the y-axis.
196
188
  * @values top, bottom
@@ -28,12 +28,12 @@ export default function useAttrs(props, { isShownOptions }) {
28
28
 
29
29
  attrs[`${key}Attrs`] = getAttrs(key, { classes });
30
30
 
31
- if (key === "link") {
31
+ if (key === "dropdownLink") {
32
32
  const linkAttrs = attrs[`${key}Attrs`];
33
33
 
34
34
  attrs[`${key}Attrs`] = computed(() => ({
35
35
  ...linkAttrs.value,
36
- class: cx([linkAttrs.value.class, isShownOptions.value && config.value.linkActive]),
36
+ class: cx([linkAttrs.value.class, isShownOptions.value && config.value.dropdownLinkActive]),
37
37
  }));
38
38
  }
39
39
  }
@@ -1,6 +1,5 @@
1
1
  export default /*tw*/ {
2
2
  wrapper: "relative inline-block",
3
- trigger: "flex items-center relative space-x-0.5",
4
3
  dropdownLink: "{ULink}",
5
4
  dropdownLinkActive: "group",
6
5
  dropdownIcon: "{UIcon} block transition duration-300 group-[]:rotate-180",
@@ -1,57 +1,57 @@
1
1
  <template>
2
2
  <div v-click-outside="hideOptions" v-bind="wrapperAttrs">
3
- <div v-bind="triggerAttrs">
4
- <ULink
5
- :id="id"
6
- :size="size"
7
- :label="label"
8
- :color="color"
9
- :dashed="dashed"
10
- :no-ring="noRing"
11
- :disabled="disabled"
12
- :underlined="underlined"
13
- :data-test="`${dataTest}-link`"
14
- v-bind="dropdownLinkAttrs"
15
- @click="onClickLink"
16
- >
17
- <template #left>
18
- <!--
3
+ <ULink
4
+ :id="id"
5
+ :size="size"
6
+ :label="label"
7
+ :color="color"
8
+ :dashed="dashed"
9
+ :no-ring="noRing"
10
+ :disabled="disabled"
11
+ :underlined="underlined"
12
+ v-bind="dropdownLinkAttrs"
13
+ :data-test="dataTest"
14
+ @click="onClickLink"
15
+ @keydown.enter="onClickLink"
16
+ @keydown.space.prevent="onClickLink"
17
+ >
18
+ <template #left>
19
+ <!--
19
20
  @slot Use it to add something before the label.
20
21
  @binding {boolean} isOpened
21
22
  -->
22
- <slot name="left" :opened="isShownOptions" />
23
- </template>
23
+ <slot name="left" :opened="isShownOptions" />
24
+ </template>
24
25
 
25
- <template #default>
26
- <!--
26
+ <template #default>
27
+ <!--
27
28
  @slot Use it to add something instead of the default label.
28
29
  @binding {string} label
29
30
  @binding {boolean} isOpened
30
31
  -->
31
- <slot :label="label" />
32
- </template>
32
+ <slot :label="label" />
33
+ </template>
33
34
 
34
- <template #right>
35
- <!--
35
+ <template #right>
36
+ <!--
36
37
  @slot Use it to add something after the label.
37
38
  @binding {boolean} isOpened
38
39
  -->
39
- <slot name="right" :opened="isShownOptions">
40
- <UIcon
41
- v-if="!noIcon"
42
- internal
43
- interactive
44
- :color="color"
45
- :size="iconSize"
46
- :name="config.defaults.dropdownIcon"
47
- :data-test="`${dataTest}-caret`"
48
- v-bind="dropdownIconAttrs"
49
- @click="onClickLink"
50
- />
51
- </slot>
52
- </template>
53
- </ULink>
54
- </div>
40
+ <slot name="right" :opened="isShownOptions">
41
+ <UIcon
42
+ v-if="!noIcon"
43
+ internal
44
+ interactive
45
+ :color="color"
46
+ :size="iconSize"
47
+ :name="config.defaults.dropdownIcon"
48
+ v-bind="dropdownIconAttrs"
49
+ :data-test="`${dataTest}-dropdown`"
50
+ @click="onClickLink"
51
+ />
52
+ </slot>
53
+ </template>
54
+ </ULink>
55
55
 
56
56
  <UDropdownList
57
57
  v-if="isShownOptions"
@@ -81,7 +81,6 @@ import vClickOutside from "../directive.clickOutside";
81
81
  import { UDropdownLink } from "./constants";
82
82
  import defaultConfig from "./configs/default.config";
83
83
  import useAttrs from "./composables/attrs.composable";
84
- import { UDropdownButton } from "../ui.dropdown-button/constants/index.js";
85
84
 
86
85
  /* Should be a string for correct web-types gen */
87
86
  defineOptions({ name: "UDropdownLink", inheritAttrs: false });
@@ -95,6 +94,30 @@ const props = defineProps({
95
94
  default: "",
96
95
  },
97
96
 
97
+ /**
98
+ * Options list.
99
+ */
100
+ options: {
101
+ type: Array,
102
+ default: () => [],
103
+ },
104
+
105
+ /**
106
+ * Label key in the item object of options.
107
+ */
108
+ labelKey: {
109
+ type: String,
110
+ default: getDefault(defaultConfig, UDropdownLink).labelKey,
111
+ },
112
+
113
+ /**
114
+ * Value key in the item object of options.
115
+ */
116
+ valueKey: {
117
+ type: String,
118
+ default: getDefault(defaultConfig, UDropdownLink).valueKey,
119
+ },
120
+
98
121
  /**
99
122
  * Link color.
100
123
  * @values brand, grayscale, gray, red, orange, amber, yellow, lime, green, emerald, teal, cyan, sky, blue, indigo, violet, purple, fuchsia, pink, rose, white
@@ -153,30 +176,6 @@ const props = defineProps({
153
176
  default: getDefault(defaultConfig, UDropdownLink).noIcon,
154
177
  },
155
178
 
156
- /**
157
- * Options list.
158
- */
159
- options: {
160
- type: Array,
161
- default: () => [],
162
- },
163
-
164
- /**
165
- * Label key in the item object of options.
166
- */
167
- labelKey: {
168
- type: String,
169
- default: getDefault(defaultConfig, UDropdownButton).labelKey,
170
- },
171
-
172
- /**
173
- * Value key in the item object of options.
174
- */
175
- valueKey: {
176
- type: String,
177
- default: getDefault(defaultConfig, UDropdownButton).valueKey,
178
- },
179
-
180
179
  /**
181
180
  * The position of dropdown list on the y-axis.
182
181
  * @values top, bottom
@@ -234,21 +233,16 @@ provide("hideDropdownOptions", hideOptions);
234
233
  const isShownOptions = ref(false);
235
234
  const selectedItem = ref("");
236
235
 
237
- const {
238
- config,
239
- wrapperAttrs,
240
- dropdownLinkAttrs,
241
- dropdownListAttrs,
242
- dropdownIconAttrs,
243
- triggerAttrs,
244
- } = useAttrs(props, { isShownOptions });
236
+ const { config, wrapperAttrs, dropdownLinkAttrs, dropdownListAttrs, dropdownIconAttrs } = useAttrs(
237
+ props,
238
+ { isShownOptions },
239
+ );
245
240
 
246
241
  const iconSize = computed(() => {
247
242
  const sizes = {
248
- xs: "2xs",
249
- sm: "xs",
250
- md: "sm",
251
- lg: "md",
243
+ sm: "2xs",
244
+ md: "xs",
245
+ lg: "sm",
252
246
  };
253
247
 
254
248
  return sizes[props.size];
@@ -1,11 +1,11 @@
1
1
  export default /*tw*/ {
2
2
  wrapper: {
3
- base: "p-4 flex flex-col rounded-dynamic",
3
+ base: "border p-4 flex flex-col rounded-dynamic",
4
4
  variants: {
5
5
  variant: {
6
- primary: "bg-{color}-600 text-white",
7
- secondary: "bg-transparent border border-{color}-600 text-{color}-600",
8
- thirdary: "bg-{color}-50 text-{color}-600",
6
+ primary: "bg-{color}-600 text-white border-transparent",
7
+ secondary: "border-{color}-600 text-{color}-600",
8
+ thirdary: "bg-{color}-50 text-{color}-600 border-transparent",
9
9
  },
10
10
  size: {
11
11
  xs: "text-2xs",
@@ -15,7 +15,7 @@ export default /*tw*/ {
15
15
  },
16
16
  },
17
17
  compoundVariants: [
18
- { variant: "thirdary", bordered: true, class: "border border-{color}-100" },
18
+ { variant: "thirdary", bordered: true, class: "border-{color}-100" },
19
19
  { color: "white", variant: "primary", class: "text-gray-900 bg-white" },
20
20
  { color: "white", variant: "secondary", class: "text-gray-900 border-gray-200" },
21
21
  { color: "white", variant: "thirdary", class: "text-gray-900 bg-white" },
@@ -136,7 +136,7 @@ const props = defineProps({
136
136
  },
137
137
 
138
138
  /**
139
- * Show Alert with a border.
139
+ * Add border to the `thirdary` variant.
140
140
  */
141
141
  bordered: {
142
142
  type: Boolean,
@@ -1,10 +1,12 @@
1
+ import { computed, useSlots } from "vue";
2
+
1
3
  import useUI from "../../composable.ui";
2
4
  import { cva } from "../../service.ui";
3
5
 
4
6
  import defaultConfig from "../configs/default.config";
5
- import { computed } from "vue";
6
7
 
7
8
  export default function useAttrs(props) {
9
+ const slots = useSlots();
8
10
  const { config, getAttrs, hasSlotContent, getColor, setColor, isSystemKey, isCVA } = useUI(
9
11
  defaultConfig,
10
12
  () => props.config,
@@ -21,6 +23,9 @@ export default function useAttrs(props) {
21
23
  value = cva(value)({
22
24
  ...props,
23
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"]),
24
29
  });
25
30
  }
26
31
 
@@ -1,30 +1,42 @@
1
1
  export default /*tw*/ {
2
- wrapper: {
3
- base: "border rounded-full inline-block py-1 !leading-none",
2
+ badge: {
3
+ base: "border rounded-dynamic inline-block py-1 !leading-none outline-none",
4
4
  variants: {
5
5
  variant: {
6
- primary: "bg-{color}-50 text-{color}-600 border-transparent",
6
+ primary: "bg-{color}-600 text-white border-transparent",
7
7
  secondary: "border-{color}-600 text-{color}-600",
8
- thirdary: "text-{color}-600 border-transparent",
8
+ thirdary: "bg-{color}-50 text-{color}-600 border-transparent",
9
9
  },
10
10
  size: {
11
11
  sm: "px-2 text-2xs",
12
12
  md: "px-2.5 text-xs",
13
13
  lg: "px-3 text-sm",
14
14
  },
15
- weight: {
16
- regular: "font-normal",
17
- medium: "font-medium",
18
- bold: "font-bold",
15
+ round: {
16
+ true: "rounded-full",
17
+ },
18
+ tabindex: {
19
+ true: "cursor-pointer focus:ring-dynamic focus:ring-offset-dynamic focus:ring-{color}-700/15",
20
+ },
21
+ color: {
22
+ grayscale: "focus:ring-gray-700/15",
23
+ white: "focus:ring-gray-700/15",
19
24
  },
20
25
  },
21
26
  compoundVariants: [
22
- { color: "grayscale", variant: "primary", class: "bg-gray-100 text-gray-900" },
27
+ { variant: "thirdary", bordered: true, class: "border-{color}-100" },
28
+ { color: "grayscale", variant: "primary", class: "bg-gray-900" },
23
29
  { color: "grayscale", variant: "secondary", class: "border-gray-900 text-gray-900" },
24
- { color: "grayscale", variant: "thirdary", class: "text-gray-900" },
30
+ { color: "grayscale", variant: "thirdary", class: "bg-gray-100 text-gray-900" },
25
31
  { color: "white", variant: "primary", class: "bg-white text-gray-900" },
26
32
  { color: "white", variant: "secondary", class: "border-white text-white" },
27
- { color: "white", variant: "thirdary", class: "text-white" },
33
+ { color: "white", variant: "thirdary", class: "text-white bg-white/15" },
34
+ { leftIcon: true, size: "sm", class: "pl-1.5" },
35
+ { leftIcon: true, size: "md", class: "pl-1.5" },
36
+ { leftIcon: true, size: "lg", class: "pl-2" },
37
+ { rightIcon: true, size: "sm", class: "pr-1.5" },
38
+ { rightIcon: true, size: "md", class: "pr-1.5" },
39
+ { rightIcon: true, size: "lg", class: "pr-2" },
28
40
  ],
29
41
  },
30
42
  body: {
@@ -32,22 +44,28 @@ export default /*tw*/ {
32
44
  variants: {
33
45
  size: {
34
46
  sm: "gap-0.5",
35
- md: "gap-x-0.5",
36
- lg: "gap-x-0.5",
47
+ md: "gap-0.5",
48
+ lg: "gap-0.5",
37
49
  },
38
50
  },
39
51
  },
40
52
  leftIcon: "{UIcon}",
53
+ centerIcon: "{UIcon}",
41
54
  rightIcon: "{UIcon}",
42
55
  defaults: {
43
56
  color: "brand",
44
57
  size: "md",
45
- weight: "medium",
46
58
  variant: "primary",
59
+ tabindex: "-1",
60
+ round: false,
61
+ bordered: false,
47
62
  },
48
63
  safelist: (colors) => [
49
64
  { pattern: `bg-(${colors})-50` },
65
+ { pattern: `bg-(${colors})-600` },
66
+ { pattern: `border-(${colors})-100` },
50
67
  { pattern: `border-(${colors})-600` },
51
68
  { pattern: `text-(${colors})-600` },
69
+ { pattern: `ring-(${colors})-700`, variants: ["focus"] },
52
70
  ],
53
71
  };
@@ -90,9 +90,6 @@ Variants.args = { enum: "variant" };
90
90
  export const Sizes = EnumVariantTemplate.bind({});
91
91
  Sizes.args = { enum: "size" };
92
92
 
93
- export const Weight = EnumVariantTemplate.bind({});
94
- Weight.args = { enum: "weight" };
95
-
96
93
  export const Colors = ColorsTemplate.bind({});
97
94
  Colors.args = {};
98
95
 
@@ -1,9 +1,9 @@
1
1
  <template>
2
2
  <div
3
3
  ref="wrapperRef"
4
- tabindex="1"
5
4
  :data-test="dataTest"
6
- v-bind="wrapperAttrs"
5
+ v-bind="badgeAttrs"
6
+ :tabindex="tabindex"
7
7
  @blur="onBlur"
8
8
  @focus="onFocus"
9
9
  @keydown="onKeydown"
@@ -16,20 +16,42 @@
16
16
  @binding {string} icon-size
17
17
  @binding {string} icon-color
18
18
  -->
19
- <slot name="left" :icon-name="leftIcon" :icon-size="iconSize" :icon-color="color">
19
+ <slot name="left" :icon-name="leftIcon" :icon-size="iconSize" :icon-color="iconColor">
20
20
  <UIcon
21
21
  v-if="leftIcon"
22
+ internal
22
23
  :name="leftIcon"
23
24
  :size="iconSize"
24
- :color="color"
25
- internal
25
+ :color="iconColor"
26
26
  v-bind="leftIconAttrs"
27
27
  />
28
28
  </slot>
29
29
 
30
- <!-- @slot Use it to add something instead of text. -->
31
- <slot>
32
- {{ label }}
30
+ <!--
31
+ @slot Use it to add something instead of the label.
32
+ @binding {string} label
33
+ @binding {string} icon-name
34
+ @binding {string} icon-size
35
+ @binding {string} icon-color
36
+ -->
37
+ <slot
38
+ name="default"
39
+ :label="label"
40
+ :icon-name="icon"
41
+ :icon-size="iconSize"
42
+ :icon-color="iconColor"
43
+ >
44
+ <UIcon
45
+ v-if="icon"
46
+ internal
47
+ :name="icon"
48
+ :size="iconSize"
49
+ :color="iconColor"
50
+ v-bind="centerIconAttrs"
51
+ />
52
+ <template v-else>
53
+ {{ label }}
54
+ </template>
33
55
  </slot>
34
56
 
35
57
  <!--
@@ -38,12 +60,12 @@
38
60
  @binding {string} icon-size
39
61
  @binding {string} icon-color
40
62
  -->
41
- <slot name="right" :icon-name="rightIcon" :icon-size="iconSize" :icon-color="color">
63
+ <slot name="right" :icon-name="rightIcon" :icon-size="iconSize" :icon-color="iconColor">
42
64
  <UIcon
43
65
  v-if="rightIcon"
44
66
  :name="rightIcon"
45
67
  :size="iconSize"
46
- :color="color"
68
+ :color="iconColor"
47
69
  internal
48
70
  v-bind="rightIconAttrs"
49
71
  />
@@ -71,7 +93,6 @@ const props = defineProps({
71
93
  */
72
94
  label: {
73
95
  type: String,
74
- required: true,
75
96
  default: "",
76
97
  },
77
98
 
@@ -84,6 +105,14 @@ const props = defineProps({
84
105
  default: getDefault(defaultConfig, UBadge).variant,
85
106
  },
86
107
 
108
+ /**
109
+ * Add border to the `thirdary` variant.
110
+ */
111
+ bordered: {
112
+ type: Boolean,
113
+ default: getDefault(defaultConfig, UBadge).bordered,
114
+ },
115
+
87
116
  /**
88
117
  * Badge size.
89
118
  * @values sm, md, lg
@@ -93,6 +122,23 @@ const props = defineProps({
93
122
  default: getDefault(defaultConfig, UBadge).size,
94
123
  },
95
124
 
125
+ /**
126
+ * Badge color.
127
+ * @values brand, grayscale, gray, red, orange, amber, yellow, lime, green, emerald, teal, cyan, sky, blue, indigo, violet, purple, fuchsia, pink, rose, white
128
+ */
129
+ color: {
130
+ type: String,
131
+ default: getDefault(defaultConfig, UBadge).color,
132
+ },
133
+
134
+ /**
135
+ * Icon name (appears instead of label).
136
+ */
137
+ icon: {
138
+ type: String,
139
+ default: "",
140
+ },
141
+
96
142
  /**
97
143
  * Left side icon name.
98
144
  */
@@ -110,21 +156,19 @@ const props = defineProps({
110
156
  },
111
157
 
112
158
  /**
113
- * Badge font weight.
114
- * @values regular, medium, bold
159
+ * Controls the keyboard “Tab” focus order of elements.
115
160
  */
116
- weight: {
117
- type: String,
118
- default: getDefault(defaultConfig, UBadge).weight,
161
+ tabindex: {
162
+ type: [String, Number],
163
+ default: getDefault(defaultConfig, UBadge).tabindex,
119
164
  },
120
165
 
121
166
  /**
122
- * Badge color.
123
- * @values brand, grayscale, gray, red, orange, amber, yellow, lime, green, emerald, teal, cyan, sky, blue, indigo, violet, purple, fuchsia, pink, rose, white
167
+ * Set badge corners rounded.
124
168
  */
125
- color: {
126
- type: String,
127
- default: getDefault(defaultConfig, UBadge).color,
169
+ round: {
170
+ type: Boolean,
171
+ default: getDefault(defaultConfig, UBadge).round,
128
172
  },
129
173
 
130
174
  /**
@@ -166,7 +210,7 @@ const emit = defineEmits([
166
210
  "click",
167
211
  ]);
168
212
 
169
- const { bodyAttrs, wrapperAttrs, leftIconAttrs, rightIconAttrs } = useAttrs(props);
213
+ const { badgeAttrs, bodyAttrs, leftIconAttrs, centerIconAttrs, rightIconAttrs } = useAttrs(props);
170
214
 
171
215
  const wrapperRef = ref(null);
172
216
 
@@ -174,14 +218,18 @@ defineExpose({ wrapperRef });
174
218
 
175
219
  const iconSize = computed(() => {
176
220
  const sizes = {
177
- sm: "2xs",
178
- md: "xs",
179
- lg: "sm",
221
+ sm: "3xs",
222
+ md: "2xs",
223
+ lg: "xs",
180
224
  };
181
225
 
182
226
  return sizes[props.size];
183
227
  });
184
228
 
229
+ const iconColor = computed(() => {
230
+ return props.variant === "primary" ? "white" : props.color;
231
+ });
232
+
185
233
  function onFocus() {
186
234
  emit("focus");
187
235
  }
package/web-types.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "framework": "vue",
3
3
  "name": "vueless",
4
- "version": "0.0.317",
4
+ "version": "0.0.319",
5
5
  "contributions": {
6
6
  "html": {
7
7
  "description-markup": "markdown",
@@ -479,7 +479,7 @@
479
479
  },
480
480
  {
481
481
  "name": "bordered",
482
- "description": "Show Alert with a border.",
482
+ "description": "Add border to the `thirdary` variant.",
483
483
  "value": {
484
484
  "kind": "expression",
485
485
  "type": "boolean"
@@ -718,7 +718,6 @@
718
718
  "attributes": [
719
719
  {
720
720
  "name": "label",
721
- "required": true,
722
721
  "description": "Badge label.",
723
722
  "value": {
724
723
  "kind": "expression",
@@ -735,6 +734,15 @@
735
734
  },
736
735
  "default": "primary"
737
736
  },
737
+ {
738
+ "name": "bordered",
739
+ "description": "Add border to the `thirdary` variant.",
740
+ "value": {
741
+ "kind": "expression",
742
+ "type": "boolean"
743
+ },
744
+ "default": "false"
745
+ },
738
746
  {
739
747
  "name": "size",
740
748
  "description": "Badge size.",
@@ -744,6 +752,24 @@
744
752
  },
745
753
  "default": "md"
746
754
  },
755
+ {
756
+ "name": "color",
757
+ "description": "Badge color.",
758
+ "value": {
759
+ "kind": "expression",
760
+ "type": "'brand' | 'grayscale' | 'gray' | 'red' | 'orange' | 'amber' | 'yellow' | 'lime' | 'green' | 'emerald' | 'teal' | 'cyan' | 'sky' | 'blue' | 'indigo' | 'violet' | 'purple' | 'fuchsia' | 'pink' | 'rose' | 'white'"
761
+ },
762
+ "default": "brand"
763
+ },
764
+ {
765
+ "name": "icon",
766
+ "description": "Icon name (appears instead of label).",
767
+ "value": {
768
+ "kind": "expression",
769
+ "type": "string"
770
+ },
771
+ "default": "\"\""
772
+ },
747
773
  {
748
774
  "name": "leftIcon",
749
775
  "description": "Left side icon name.",
@@ -763,22 +789,22 @@
763
789
  "default": "\"\""
764
790
  },
765
791
  {
766
- "name": "weight",
767
- "description": "Badge font weight.",
792
+ "name": "tabindex",
793
+ "description": "Controls the keyboard “Tab” focus order of elements.",
768
794
  "value": {
769
795
  "kind": "expression",
770
- "type": "'regular' | 'medium' | 'bold'"
796
+ "type": "string|number"
771
797
  },
772
- "default": "medium"
798
+ "default": "-1"
773
799
  },
774
800
  {
775
- "name": "color",
776
- "description": "Badge color.",
801
+ "name": "round",
802
+ "description": "Set badge corners rounded.",
777
803
  "value": {
778
804
  "kind": "expression",
779
- "type": "'brand' | 'grayscale' | 'gray' | 'red' | 'orange' | 'amber' | 'yellow' | 'lime' | 'green' | 'emerald' | 'teal' | 'cyan' | 'sky' | 'blue' | 'indigo' | 'violet' | 'purple' | 'fuchsia' | 'pink' | 'rose' | 'white'"
805
+ "type": "boolean"
780
806
  },
781
- "default": "brand"
807
+ "default": "false"
782
808
  },
783
809
  {
784
810
  "name": "config",
@@ -839,7 +865,26 @@
839
865
  },
840
866
  {
841
867
  "name": "default",
842
- "description": "Use it to add something instead of text."
868
+ "scoped": true,
869
+ "description": "Use it to add something instead of the label.",
870
+ "bindings": [
871
+ {
872
+ "type": "string",
873
+ "name": "label"
874
+ },
875
+ {
876
+ "type": "string",
877
+ "name": "icon-name"
878
+ },
879
+ {
880
+ "type": "string",
881
+ "name": "icon-size"
882
+ },
883
+ {
884
+ "type": "string",
885
+ "name": "icon-color"
886
+ }
887
+ ]
843
888
  },
844
889
  {
845
890
  "name": "right",
@@ -2868,6 +2913,33 @@
2868
2913
  },
2869
2914
  "default": "\"\""
2870
2915
  },
2916
+ {
2917
+ "name": "options",
2918
+ "description": "Options list.",
2919
+ "value": {
2920
+ "kind": "expression",
2921
+ "type": "array"
2922
+ },
2923
+ "default": "[]"
2924
+ },
2925
+ {
2926
+ "name": "labelKey",
2927
+ "description": "Label key in the item object of options.",
2928
+ "value": {
2929
+ "kind": "expression",
2930
+ "type": "string"
2931
+ },
2932
+ "default": "label"
2933
+ },
2934
+ {
2935
+ "name": "valueKey",
2936
+ "description": "Value key in the item object of options.",
2937
+ "value": {
2938
+ "kind": "expression",
2939
+ "type": "string"
2940
+ },
2941
+ "default": "id"
2942
+ },
2871
2943
  {
2872
2944
  "name": "variant",
2873
2945
  "description": "Badge variant.",
@@ -2896,13 +2968,13 @@
2896
2968
  "default": "md"
2897
2969
  },
2898
2970
  {
2899
- "name": "weight",
2900
- "description": "Badge font weight.",
2971
+ "name": "round",
2972
+ "description": "Set badge corners rounded.",
2901
2973
  "value": {
2902
2974
  "kind": "expression",
2903
- "type": "'regular' | 'medium' | 'bold'"
2975
+ "type": "boolean"
2904
2976
  },
2905
- "default": "medium"
2977
+ "default": "false"
2906
2978
  },
2907
2979
  {
2908
2980
  "name": "noIcon",
@@ -2913,33 +2985,6 @@
2913
2985
  },
2914
2986
  "default": "false"
2915
2987
  },
2916
- {
2917
- "name": "options",
2918
- "description": "Options list.",
2919
- "value": {
2920
- "kind": "expression",
2921
- "type": "array"
2922
- },
2923
- "default": "[]"
2924
- },
2925
- {
2926
- "name": "labelKey",
2927
- "description": "Label key in the item object of options.",
2928
- "value": {
2929
- "kind": "expression",
2930
- "type": "string"
2931
- },
2932
- "default": "label"
2933
- },
2934
- {
2935
- "name": "valueKey",
2936
- "description": "Value key in the item object of options.",
2937
- "value": {
2938
- "kind": "expression",
2939
- "type": "string"
2940
- },
2941
- "default": "id"
2942
- },
2943
2988
  {
2944
2989
  "name": "listYPosition",
2945
2990
  "description": "The position of dropdown list on the y-axis.",
@@ -3049,22 +3094,40 @@
3049
3094
  "description": "",
3050
3095
  "attributes": [
3051
3096
  {
3052
- "name": "modelValue",
3053
- "description": "Selected value.",
3097
+ "name": "label",
3098
+ "description": "Button label.",
3054
3099
  "value": {
3055
3100
  "kind": "expression",
3056
- "type": "string|number"
3101
+ "type": "string"
3057
3102
  },
3058
3103
  "default": "\"\""
3059
3104
  },
3060
3105
  {
3061
- "name": "label",
3062
- "description": "Button label.",
3106
+ "name": "options",
3107
+ "description": "Options list.",
3108
+ "value": {
3109
+ "kind": "expression",
3110
+ "type": "array"
3111
+ },
3112
+ "default": "[]"
3113
+ },
3114
+ {
3115
+ "name": "labelKey",
3116
+ "description": "Label key in the item object of options.",
3063
3117
  "value": {
3064
3118
  "kind": "expression",
3065
3119
  "type": "string"
3066
3120
  },
3067
- "default": "\"\""
3121
+ "default": "label"
3122
+ },
3123
+ {
3124
+ "name": "valueKey",
3125
+ "description": "Value key in the item object of options.",
3126
+ "value": {
3127
+ "kind": "expression",
3128
+ "type": "string"
3129
+ },
3130
+ "default": "id"
3068
3131
  },
3069
3132
  {
3070
3133
  "name": "variant",
@@ -3138,33 +3201,6 @@
3138
3201
  },
3139
3202
  "default": "false"
3140
3203
  },
3141
- {
3142
- "name": "options",
3143
- "description": "Options list.",
3144
- "value": {
3145
- "kind": "expression",
3146
- "type": "array"
3147
- },
3148
- "default": "[]"
3149
- },
3150
- {
3151
- "name": "labelKey",
3152
- "description": "Label key in the item object of options.",
3153
- "value": {
3154
- "kind": "expression",
3155
- "type": "string"
3156
- },
3157
- "default": "label"
3158
- },
3159
- {
3160
- "name": "valueKey",
3161
- "description": "Value key in the item object of options.",
3162
- "value": {
3163
- "kind": "expression",
3164
- "type": "string"
3165
- },
3166
- "default": "id"
3167
- },
3168
3204
  {
3169
3205
  "name": "listYPosition",
3170
3206
  "description": "The position of dropdown list on the y-axis.",
@@ -3279,6 +3315,33 @@
3279
3315
  },
3280
3316
  "default": "\"\""
3281
3317
  },
3318
+ {
3319
+ "name": "options",
3320
+ "description": "Options list.",
3321
+ "value": {
3322
+ "kind": "expression",
3323
+ "type": "array"
3324
+ },
3325
+ "default": "[]"
3326
+ },
3327
+ {
3328
+ "name": "labelKey",
3329
+ "description": "Label key in the item object of options.",
3330
+ "value": {
3331
+ "kind": "expression",
3332
+ "type": "string"
3333
+ },
3334
+ "default": "label"
3335
+ },
3336
+ {
3337
+ "name": "valueKey",
3338
+ "description": "Value key in the item object of options.",
3339
+ "value": {
3340
+ "kind": "expression",
3341
+ "type": "string"
3342
+ },
3343
+ "default": "id"
3344
+ },
3282
3345
  {
3283
3346
  "name": "color",
3284
3347
  "description": "Link color.",
@@ -3341,33 +3404,6 @@
3341
3404
  },
3342
3405
  "default": "false"
3343
3406
  },
3344
- {
3345
- "name": "options",
3346
- "description": "Options list.",
3347
- "value": {
3348
- "kind": "expression",
3349
- "type": "array"
3350
- },
3351
- "default": "[]"
3352
- },
3353
- {
3354
- "name": "labelKey",
3355
- "description": "Label key in the item object of options.",
3356
- "value": {
3357
- "kind": "expression",
3358
- "type": "string"
3359
- },
3360
- "default": "label"
3361
- },
3362
- {
3363
- "name": "valueKey",
3364
- "description": "Value key in the item object of options.",
3365
- "value": {
3366
- "kind": "expression",
3367
- "type": "string"
3368
- },
3369
- "default": "id"
3370
- },
3371
3407
  {
3372
3408
  "name": "listYPosition",
3373
3409
  "description": "The position of dropdown list on the y-axis.",