@veritree/ui 0.91.8 → 0.92.1

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": "@veritree/ui",
3
- "version": "0.91.8",
3
+ "version": "0.92.1",
4
4
  "description": "veritree ui library",
5
5
  "type": "module",
6
6
  "main": "index.js",
package/readme.MD CHANGED
@@ -1,4 +1,4 @@
1
1
  # Deploy/Release Notes:
2
2
 
3
- - It is recommended to use `release-with-git-tag` or `yarn publish` for releasing new versions.
3
+ - It is recommended to use `release-v2` or `yarn publish` for releasing new versions.
4
4
  - Avoid using `yarn release` as it is deprecated and may not be supported in future versions.
@@ -57,6 +57,8 @@ export default {
57
57
 
58
58
  watch: {
59
59
  visible(value) {
60
+ this.$emit('toggle', value);
61
+
60
62
  if (value && this.apiDisclosure().accordion) {
61
63
  this.apiDisclosure().details.forEach((detail) => {
62
64
  if (detail.idGroup !== this.idGroup) {
@@ -88,12 +90,10 @@ export default {
88
90
 
89
91
  methods: {
90
92
  show() {
91
- this.$emit('toggle', true);
92
93
  this.visible = true;
93
94
  },
94
95
 
95
96
  hide() {
96
- this.$emit('toggle', false);
97
97
  this.visible = false;
98
98
  },
99
99
 
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <div :class="[headless ? 'listbox' : null]">
2
+ <div :class="classList">
3
3
  <slot></slot>
4
4
  </div>
5
5
  </template>
@@ -101,6 +101,7 @@ export default {
101
101
  items: this.items,
102
102
  multiple: this.multiple,
103
103
  search: this.search,
104
+ version: this.version,
104
105
  valueComputed: this.valueComputed,
105
106
  registerTrigger,
106
107
  registerContent,
@@ -171,6 +172,15 @@ export default {
171
172
  type: Boolean,
172
173
  default: false,
173
174
  },
175
+ /**
176
+ * The version of the component to use.
177
+ * @type {number|string}
178
+ * @default '1'
179
+ */
180
+ version: {
181
+ type: [Number, String],
182
+ default: '1',
183
+ },
174
184
  },
175
185
 
176
186
  data() {
@@ -211,6 +221,27 @@ export default {
211
221
  this.$emit('change', newValue);
212
222
  },
213
223
  },
224
+
225
+ classList() {
226
+ const list = [];
227
+
228
+ // This will be refactor by moving the inline tailwind styling to its own file
229
+ if (this.headless || this.version === '2') {
230
+ // use semantic list
231
+ list.push('listbox');
232
+ list.push(`listbox--version-${this.version}`);
233
+
234
+ if (this.variant) {
235
+ list.push(`listbox--${this.variant}`);
236
+ }
237
+
238
+ if (this.size) {
239
+ list.push(`listbox--${this.size}`);
240
+ }
241
+ }
242
+
243
+ return list;
244
+ },
214
245
  },
215
246
  };
216
247
  </script>
@@ -4,7 +4,7 @@
4
4
  :visible="visible"
5
5
  :headless="headless"
6
6
  :aria-activedescendant="activeDescedant"
7
- :portal-class="$vnode.data.staticClass"
7
+ :portal-class="`${$vnode.data.staticClass} ${portalClassList}`"
8
8
  component="listbox"
9
9
  role="listbox"
10
10
  @shown="$emit('shown')"
@@ -43,6 +43,16 @@ export default {
43
43
  componentTrigger() {
44
44
  return this.apiListbox().componentTrigger;
45
45
  },
46
+
47
+ portalClassList() {
48
+ const staticClass = this.$attrs.class || this.$attrs.staticClass || '';
49
+
50
+ if (this.apiListbox().version === '2') {
51
+ return `${staticClass} listbox-content--version-2`;
52
+ }
53
+
54
+ return staticClass;
55
+ },
46
56
  },
47
57
 
48
58
  mounted() {
@@ -2,7 +2,7 @@
2
2
  <button
3
3
  :id="id"
4
4
  :data-testid="dataTestidComputed"
5
- :class="triggerClassComputed"
5
+ :class="classList"
6
6
  :disabled="isDisabled"
7
7
  :aria-expanded="expanded"
8
8
  :aria-haspopup="hasPopup"
@@ -104,13 +104,32 @@ export default {
104
104
  return this.items[this.items.length - 1];
105
105
  },
106
106
 
107
- triggerClassComputed() {
107
+ classList() {
108
108
  if (this.headless) {
109
109
  return null;
110
110
  }
111
111
 
112
+ // TODO: role isn't the best way to determine button styles, we should have a better prop for that
112
113
  if (this.role === 'combobox') {
113
- return [this.classComputed, this.headless ? null : 'hover:bg-gray-200'];
114
+ const version2Classes = [];
115
+
116
+ if (this.apiListbox().version === '2') {
117
+ version2Classes.push('listbox-trigger--version-2');
118
+
119
+ if (this.variant) {
120
+ version2Classes.push(`listbox-trigger--${this.variant}`);
121
+ }
122
+
123
+ if (this.size) {
124
+ version2Classes.push(`listbox-trigger--${this.size}`);
125
+ }
126
+ }
127
+
128
+ return [
129
+ this.classComputed,
130
+ this.headless ? null : 'hover:bg-gray-200',
131
+ ...version2Classes,
132
+ ];
114
133
  }
115
134
 
116
135
  return `button-base button--${this.variant} button--${this.size}`;