@veritree/ui 0.21.1-8 → 0.22.0

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.
@@ -22,44 +22,33 @@ export default {
22
22
  },
23
23
  },
24
24
 
25
- data() {
26
- return {
27
- isMousemove: false,
28
- };
29
- },
30
-
31
25
  computed: {
32
26
  id() {
33
27
  return `listbox-list-${this.apiListbox().id}`;
34
28
  },
35
29
  },
36
30
 
37
- mounted() {
38
- const list = {
39
- el: this.$el,
40
- getMousemove: this.getMousemove,
41
- setMousemove: this.setMousemove,
42
- unsetMousemove: this.unsetMousemove,
43
- };
31
+ // mounted() {
32
+ // const list = {
33
+ // el: this.$el,
34
+ // };
44
35
 
45
- this.apiListbox().registerList(list);
46
- },
36
+ // this.apiListbox().registerList(list);
37
+ // },
47
38
 
48
39
  methods: {
49
40
  // Mousemove instead of mouseover to support keyboard navigation.
50
41
  // The problem with mouseover is that when scrolling (scrollIntoView),
51
42
  // mouseover event gets triggered.
52
- setMousemove() {
53
- this.isMousemove = true;
54
- },
55
-
56
- unsetMousemove() {
57
- this.isMousemove = false;
58
- },
59
-
60
- getMousemove() {
61
- return this.isMousemove;
62
- },
43
+ // setMousemove() {
44
+ // this.isMousemove = true;
45
+ // },
46
+ // unsetMousemove() {
47
+ // this.isMousemove = false;
48
+ // },
49
+ // getMousemove() {
50
+ // return this.isMousemove;
51
+ // },
63
52
  },
64
53
  };
65
54
  </script>
@@ -1,8 +1,8 @@
1
1
  <template>
2
2
  <input
3
3
  v-model="search"
4
- :class="{ 'listbox-search': headless, 'form-control mb-1': !headless }"
5
4
  type="text"
5
+ :class="classComputed"
6
6
  @input="onChange"
7
7
  @click.stop
8
8
  @keydown.down.prevent="focusNextItem"
@@ -16,22 +16,20 @@
16
16
  </template>
17
17
 
18
18
  <script>
19
+ import { formControlMixin } from '../../../mixins/form-control';
20
+
19
21
  export default {
20
22
  name: 'VTListboxSearch',
21
23
 
22
- inject: ['apiListbox'],
24
+ mixins: [formControlMixin],
23
25
 
24
- props: {
25
- headless: {
26
- type: Boolean,
27
- default: false,
28
- },
29
- },
26
+ inject: ['apiListbox'],
30
27
 
31
28
  data() {
32
29
  return {
33
- search: '',
30
+ name: 'listbox-search',
34
31
  index: -1,
32
+ search: '',
35
33
  };
36
34
  },
37
35
 
@@ -40,8 +38,8 @@ export default {
40
38
  return this.apiListbox().componentTrigger;
41
39
  },
42
40
 
43
- list() {
44
- return this.apiListbox().list;
41
+ componentContent() {
42
+ return this.apiListbox().componentContent;
45
43
  },
46
44
 
47
45
  items() {
@@ -107,10 +105,10 @@ export default {
107
105
  },
108
106
 
109
107
  unselectItem() {
110
- const isMousemove = this.list.getMousemove();
108
+ const isMousemove = this.componentContent.getMousemove();
111
109
 
112
110
  if (isMousemove) {
113
- this.list.unsetMousemove();
111
+ this.componentContent.unsetMousemove();
114
112
  this.items.forEach((item) => item.unselect());
115
113
  }
116
114
 
@@ -1,37 +1,19 @@
1
1
  <template>
2
2
  <button
3
3
  :id="id"
4
+ :class="classComputed"
4
5
  :aria-expanded="expanded"
5
6
  :aria-haspopup="hasPopup"
6
- :class="[
7
- headless
8
- ? 'listbox-button'
9
- : 'flex w-full justify-between border border-solid py-2 px-3 gap-3 rounded text-inherit max-w-full',
10
- headless
11
- ? `listbox-button--${variant}`
12
- : isError
13
- ? 'border-error-300'
14
- : 'border-gray-300',
15
- ]"
16
7
  type="button"
17
8
  @click.prevent="onClick"
18
9
  @keydown.down.prevent="onKeyDownOrUp"
19
10
  @keydown.up.prevent="onKeyDownOrUp"
20
11
  @keydown.esc.stop="onKeyEsc"
21
12
  >
22
- <span
23
- :class="{
24
- 'listbox-button__text': headless,
25
- 'text-left': !headless,
26
- }"
27
- >
13
+ <span :class="[headless ? 'listbox-button__text' : 'text-left truncate']">
28
14
  <slot></slot>
29
15
  </span>
30
- <span
31
- :class="{
32
- 'listbox-button__icon': headless,
33
- }"
34
- >
16
+ <span :class="[headless ? 'listbox-button__icon' : 'shrink-0']">
35
17
  <IconChevronDown
36
18
  class="transition-transform"
37
19
  :class="{ 'rotate-180': expanded }"
@@ -41,6 +23,7 @@
41
23
  </template>
42
24
 
43
25
  <script>
26
+ import { formControlMixin } from '../../../mixins/form-control';
44
27
  import { IconChevronDown } from '@veritree/icons';
45
28
 
46
29
  export default {
@@ -48,25 +31,13 @@ export default {
48
31
 
49
32
  components: { IconChevronDown },
50
33
 
51
- inject: ['apiListbox'],
34
+ mixins: [formControlMixin],
52
35
 
53
- props: {
54
- disabled: {
55
- type: Boolean,
56
- default: false,
57
- },
58
- headless: {
59
- type: Boolean,
60
- default: false,
61
- },
62
- variant: {
63
- type: [String, Object, Function],
64
- default: '',
65
- },
66
- },
36
+ inject: ['apiListbox'],
67
37
 
68
38
  data() {
69
39
  return {
40
+ name: 'listbox-button',
70
41
  expanded: false,
71
42
  hasPopup: false,
72
43
  };
@@ -77,10 +48,6 @@ export default {
77
48
  return `listbox-trigger-${this.apiListbox().id}`;
78
49
  },
79
50
 
80
- isError() {
81
- return this.variant === 'error';
82
- },
83
-
84
51
  componentContent() {
85
52
  return this.apiListbox().componentContent;
86
53
  },
@@ -15,7 +15,7 @@
15
15
  :class="[
16
16
  headless
17
17
  ? null
18
- : 'absolute z-50 grid min-w-min overflow-hidden rounded-md py-2 px-3 border-gray-100 bg-white shadow-300',
18
+ : 'absolute z-50 grid overflow-x-hidden rounded-md py-2 px-3 border-gray-100 bg-white shadow-300',
19
19
  floatingUiClass ? floatingUiClass : null,
20
20
  ]"
21
21
  >
@@ -1,18 +0,0 @@
1
- /**
2
- *
3
- * @param {HTMLElement} el
4
- * @param {HTMLElement} parent
5
- */
6
- export const scrollElementIntoView = (el, parent) => {
7
- // this works better than scrollIntoView
8
- if (parent.scrollHeight <= parent.clientHeight) return;
9
-
10
- const scrollBottom = parent.clientHeight + parent.scrollTop;
11
- const elBottom = el.offsetTop + el.offsetHeight;
12
-
13
- if (elBottom > scrollBottom) {
14
- parent.scrollTop = elBottom - parent.clientHeight;
15
- } else if (el.offsetTop < parent.scrollTop) {
16
- parent.scrollTop = el.offsetTop;
17
- }
18
- };