vueless 0.0.543 → 0.0.544

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.543",
3
+ "version": "0.0.544",
4
4
  "license": "MIT",
5
5
  "description": "Vue Styleless UI Component Library, powered by Tailwind CSS.",
6
6
  "keywords": [
@@ -1,5 +1,5 @@
1
1
  <script setup lang="ts">
2
- import { computed, useId, useTemplateRef } from "vue";
2
+ import { watch, computed, useId, ref, useTemplateRef, nextTick } from "vue";
3
3
  import { merge } from "lodash-es";
4
4
 
5
5
  import UIcon from "../ui.image-icon/UIcon.vue";
@@ -49,6 +49,10 @@ const emit = defineEmits([
49
49
 
50
50
  const wrapperRef = useTemplateRef<HTMLDivElement>("wrapper");
51
51
  const optionsRef = useTemplateRef<HTMLLIElement[]>("option");
52
+ const emptyOptionRef = useTemplateRef<HTMLLIElement>("empty-option");
53
+ const addOptionRef = useTemplateRef<HTMLLIElement>("add-option");
54
+
55
+ const wrapperMaxHeight = ref("");
52
56
 
53
57
  const { pointer, pointerDirty, pointerSet, pointerBackward, pointerForward, pointerReset } =
54
58
  usePointer(props.options, optionsRef, wrapperRef);
@@ -80,16 +84,30 @@ const addOptionKeyCombination = computed(() => {
80
84
  return isMac ? "(⌘ + Enter)" : "(Ctrl + Enter)";
81
85
  });
82
86
 
83
- const wrapperMaxHeight = computed(() => {
84
- if (!optionsRef.value?.length) return "auto";
85
-
86
- const maxHeight = optionsRef.value
87
- .slice(0, props.visibleOptions)
88
- .map((el) => el.getBoundingClientRect().height)
89
- .reduce((acc, cur) => acc + cur, 0);
90
-
91
- return !props.visibleOptions ? "auto" : `${maxHeight + 10}px`;
92
- });
87
+ watch(
88
+ () => props.options,
89
+ () => {
90
+ nextTick(() => {
91
+ const options = [
92
+ ...(optionsRef.value || []),
93
+ ...(addOptionRef.value ? [addOptionRef.value] : []),
94
+ ...(emptyOptionRef.value ? [emptyOptionRef.value] : []),
95
+ ];
96
+
97
+ if (props.visibleOptions) {
98
+ options.slice(0, props.visibleOptions);
99
+ }
100
+
101
+ const maxHeight = options
102
+ .slice(0, props.visibleOptions)
103
+ .map((el) => el.getBoundingClientRect().height)
104
+ .reduce((acc, cur) => acc + cur, 0);
105
+
106
+ wrapperMaxHeight.value = `${maxHeight + 10}px`;
107
+ });
108
+ },
109
+ { immediate: true },
110
+ );
93
111
 
94
112
  function onClickAddOption() {
95
113
  emit("add");
@@ -269,9 +287,10 @@ defineExpose({
269
287
 
270
288
  <li
271
289
  v-if="!options.length"
272
- ref="option"
290
+ :id="`${elementId}-empty`"
291
+ ref="empty-option"
292
+ role="option"
273
293
  v-bind="optionAttrs"
274
- @mouseenter.self="pointerSet(options.length + 1)"
275
294
  >
276
295
  <!-- @slot Use it to add something instead of empty state. -->
277
296
  <slot name="empty">
@@ -282,6 +301,9 @@ defineExpose({
282
301
  <!-- Add button -->
283
302
  <template v-if="addOption">
284
303
  <li
304
+ :id="`${elementId}-addOption`"
305
+ ref="add-option"
306
+ role="option"
285
307
  v-bind="addOptionLabelWrapperAttrs"
286
308
  @click="onClickAddOption"
287
309
  @mouseenter.self="pointerSet(options.length + 1)"
@@ -5,13 +5,13 @@ export default /*tw*/ {
5
5
  overflow-auto [-webkit-overflow-scrolling:touch]
6
6
  focus:outline-none
7
7
  `,
8
- list: "m-1 inline-block list-none align-top w-full p-0 bg-white opacity-1 hover:transition",
8
+ list: "m-1 p-0 inline-block list-none align-top w-full",
9
9
  listItem: "group/item block",
10
10
  option: {
11
11
  base: `
12
12
  rounded px-2 py-2.5 flex items-center align-middle whitespace-nowrap cursor-pointer
13
13
  font-normal !leading-none normal-case text-gray-900
14
- hover:bg-brand-50
14
+ hover:bg-brand-50 active:bg-brand-100
15
15
  overflow-hidden text-ellipsis
16
16
  `,
17
17
  variants: {
@@ -50,7 +50,7 @@ export default /*tw*/ {
50
50
  },
51
51
  },
52
52
  addOptionLabelWrapper: "-mb-[1.375rem] active:bg-brand-100",
53
- addOptionLabel: "text-sm leading-none font-medium text-gray-900",
53
+ addOptionLabel: "leading-none font-medium",
54
54
  addOptionLabelHotkey: "text-gray-500",
55
55
  addOptionButton: "{UButton} !leading-none sticky left-[calc(100%-2.15rem)] bottom-2 p-1",
56
56
  addOptionIcon: "{UIcon} bg-transparent",
package/web-types.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "framework": "vue",
3
3
  "name": "vueless",
4
- "version": "0.0.543",
4
+ "version": "0.0.544",
5
5
  "contributions": {
6
6
  "html": {
7
7
  "description-markup": "markdown",