vueless 0.0.155 → 0.0.157

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.155",
3
+ "version": "0.0.157",
4
4
  "license": "MIT",
5
5
  "description": "Vue Styleless Component Framework.",
6
6
  "homepage": "https://vueless.com",
@@ -31,6 +31,7 @@ export default /*tw*/ {
31
31
  },
32
32
  defaultVariants: {
33
33
  animationDuration: 200,
34
+ labelKey: "label",
34
35
  nesting: false,
35
36
  upperlined: false,
36
37
  },
@@ -2,4 +2,4 @@
2
2
  This const is needed to prevent the issue in script setup:
3
3
  `defineProps` is referencing locally declared variables. (vue/valid-define-props)
4
4
  */
5
- export const UDataListName = "UDataList";
5
+ export const UDataList = "UDataList";
@@ -30,7 +30,7 @@
30
30
  <div v-bind="labelAttrs(element.isActive)">
31
31
  <!-- @slot Use it to modify label. -->
32
32
  <slot name="label" :item="element">
33
- {{ element.label }}
33
+ {{ element[labelKey] }}
34
34
  </slot>
35
35
  </div>
36
36
 
@@ -52,7 +52,7 @@
52
52
  :data-cy="`${dataCy}-delete`"
53
53
  :tooltip="currentLocale.delete"
54
54
  v-bind="deleteIconAttrs"
55
- @click="onClickDelete(element.id, element.label)"
55
+ @click="onClickDelete(element.id, element[labelKey])"
56
56
  />
57
57
 
58
58
  <UIcon
@@ -64,7 +64,7 @@
64
64
  :data-cy="`${dataCy}-edit`"
65
65
  :tooltip="currentLocale.edit"
66
66
  v-bind="editIconAttrs"
67
- @click="onClickEdit(element.id, element.label)"
67
+ @click="onClickEdit(element.id, element[labelKey])"
68
68
  />
69
69
  </template>
70
70
  </div>
@@ -81,9 +81,9 @@
81
81
  @click-edit="onClickEdit"
82
82
  @drag-sort="onDragEnd"
83
83
  >
84
- <template #default="{ item }">
85
- <slot :item="item">
86
- <div v-bind="labelAttrs" v-text="item.label" />
84
+ <template #label="{ item }">
85
+ <slot name="label" :item="item">
86
+ <div v-bind="labelAttrs" v-text="item[labelKey]" />
87
87
  </slot>
88
88
  </template>
89
89
 
@@ -108,7 +108,7 @@ import UEmpty from "../ui.text-empty";
108
108
  import UDivider from "../ui.container-divider";
109
109
  import UIService from "../service.ui";
110
110
 
111
- import { UDataListName } from "./constants";
111
+ import { UDataList as UDataListName } from "./constants";
112
112
  import defaultConfig from "./configs/default.config";
113
113
  import { useAttrs } from "./composables/attrs.composable";
114
114
  import { useLocale } from "../composable.locale";
@@ -133,6 +133,14 @@ const props = defineProps({
133
133
  default: "",
134
134
  },
135
135
 
136
+ /**
137
+ * Label key in the item object of options.
138
+ */
139
+ labelKey: {
140
+ type: String,
141
+ default: UIService.get(defaultConfig, UDataListName).default.labelKey,
142
+ },
143
+
136
144
  /**
137
145
  * Empty state title.
138
146
  */
@@ -237,12 +245,12 @@ function onDragEnd() {
237
245
  emit("dragSort", sortData);
238
246
  }
239
247
 
240
- function onClickEdit(id) {
241
- emit("clickEdit", id);
248
+ function onClickEdit(id, label) {
249
+ emit("clickEdit", id, label);
242
250
  }
243
251
 
244
- function onClickDelete(id, title) {
245
- emit("clickDelete", id, title);
252
+ function onClickDelete(id, label) {
253
+ emit("clickDelete", id, label);
246
254
  }
247
255
 
248
256
  function prepareSortData(list, parentId) {
@@ -1,14 +1,16 @@
1
1
  export default /*tw*/ {
2
- label: "w-auto max-w-max relative gap-3",
2
+ label: "w-auto max-w-max relative", // TODO: label classes should be defined in ULabel component
3
3
  partialIconName: "remove",
4
4
  selectedIconName: "check",
5
5
  iconWrapper: {
6
6
  base: "flex items-center justify-center absolute rounded bg-{color}-500",
7
7
  variants: {
8
8
  size: {
9
+ xs: "size-4",
9
10
  sm: "size-5",
10
11
  md: "size-6",
11
12
  lg: "size-7",
13
+ xl: "size-8",
12
14
  },
13
15
  color: {
14
16
  grayscale: "border-gray-900 bg-gray-900",
@@ -18,24 +20,24 @@ export default /*tw*/ {
18
20
  icon: "",
19
21
  checkbox: {
20
22
  base: `
21
- border border-solid border-{color}-300 rounded bg-white
22
- hover:border-{color}-400
23
- focus:border-{color}-500 focus:ring-4 focus:ring-{color}-200 focus:ring-offset-0
23
+ border border-solid rounded
24
+ border-gray-300 bg-white
25
+ hover:border-gray-400
26
+ focus:border-{color}-500 focus:ring-4 focus:ring-opacity-20 focus:ring-offset-0 focus:ring-{color}-500
24
27
  active:border-{color}-500 active:bg-{color}-500
25
- checked:border-{color}-500 checked:bg-{color}-500 checked:hover:bg-{color}-500
26
- checked:text-{color}-500 checked:bg-none
27
- checked:focus:text-{color}-500 checked:active:text-{color}-500
28
+ checked:border-{color}-500 checked:bg-{color}-500 checked:text-{color}-500
29
+ checked:hover:bg-{color}-500 checked:focus:text-{color}-500 checked:active:text-{color}-500
28
30
  `,
29
31
  variants: {
30
32
  size: {
33
+ xs: "size-4 text-xs",
31
34
  sm: "size-5 text-sm",
32
35
  md: "size-6",
33
36
  lg: "size-7 text-lg",
37
+ xl: "size-6 text-xl",
34
38
  },
35
39
  color: {
36
40
  grayscale: `
37
- border-gray-300
38
- hover:border-gray-400
39
41
  focus:border-gray-500 focus:ring-gray-200
40
42
  checked:border-gray-900 checked:bg-gray-900 checked:text-gray-900
41
43
  active:border-gray-900 active:bg-gray-900
@@ -58,12 +60,9 @@ export default /*tw*/ {
58
60
  disabled: false,
59
61
  },
60
62
  safelist: (colors) => [
61
- { pattern: `bg-(${colors})-900` /* , variants: ["checked:hover", "checked", "active"] */ },
62
- { pattern: `border-(${colors})-300` },
63
- { pattern: `border-(${colors})-400`, variants: ["hover"] },
64
- { pattern: `border-(${colors})-500`, variants: ["focus"] },
65
- { pattern: `border-(${colors})-500`, variants: ["active", "checked"] },
63
+ { pattern: `bg-(${colors})-500`, variants: ["active", "checked", "checked:hover"] },
64
+ { pattern: `border-(${colors})-500`, variants: ["focus", "active", "checked"] },
66
65
  { pattern: `text-(${colors})-500`, variants: ["checked:focus", "checked", "checked:active"] },
67
- { pattern: `ring-(${colors})-200`, variants: ["focus"] },
66
+ { pattern: `ring-(${colors})-500`, variants: ["focus"] },
68
67
  ],
69
68
  };
@@ -831,7 +831,7 @@ function deactivate() {
831
831
  function onBlur(event) {
832
832
  const { relatedTarget } = event;
833
833
 
834
- if (!menuRef.value.contains(relatedTarget)) {
834
+ if (!menuRef.value?.contains(relatedTarget)) {
835
835
  deactivate();
836
836
  }
837
837
  }
@@ -844,7 +844,7 @@ function onBlurRangeInput(event) {
844
844
  menuRef.value.focus();
845
845
  }
846
846
 
847
- if (!menuRef.value.contains(relatedTarget) && !isHoverEvent.value) {
847
+ if (!menuRef.value?.contains(relatedTarget) && !isHoverEvent.value) {
848
848
  deactivate();
849
849
  }
850
850
 
package/web-types.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "framework": "vue",
3
3
  "name": "vueless",
4
- "version": "0.0.155",
4
+ "version": "0.0.157",
5
5
  "contributions": {
6
6
  "html": {
7
7
  "description-markup": "markdown",
@@ -1401,6 +1401,15 @@
1401
1401
  },
1402
1402
  "default": "\"\""
1403
1403
  },
1404
+ {
1405
+ "name": "labelKey",
1406
+ "description": "Label key in the item object of options.",
1407
+ "value": {
1408
+ "kind": "expression",
1409
+ "type": "string"
1410
+ },
1411
+ "default": "label"
1412
+ },
1404
1413
  {
1405
1414
  "name": "emptyTitle",
1406
1415
  "description": "Empty state title.",
@@ -1493,9 +1502,6 @@
1493
1502
  {
1494
1503
  "name": "actions",
1495
1504
  "description": "Use it to add custom actions."
1496
- },
1497
- {
1498
- "name": "default"
1499
1505
  }
1500
1506
  ],
1501
1507
  "source": {