@tak-ps/vue-tabler 5.2.1 → 5.4.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.
package/CHANGELOG.md CHANGED
@@ -12,6 +12,18 @@
12
12
 
13
13
  ### Pending
14
14
 
15
+ ### v5.4.0
16
+
17
+ - :tada: Add a Multiple Choice field to `TablerSchemaBuilder`, built as an array of enum strings and rendered by `TablerSchema` as a checkbox group via the new `TablerMultiEnum` input
18
+ - :rocket: Use human readable field type names in `TablerSchemaBuilder` (Text, Dropdown, Toggle, Number, Whole Number) instead of raw JSON Schema types, with a matching icon per type
19
+ - :bug: Shift a `TablerDropdown` menu up to stay within the viewport instead of shrinking it into a scrolling panel when the trigger sits near the bottom of the screen
20
+ - :tada: Add an `advanced` scoped slot to `TablerAlert` and `TablerError` to customize how the error body is rendered
21
+ - :rocket: Wrap long lines in the `TablerAlert` Advanced body
22
+
23
+ ### v5.3.0
24
+
25
+ - :arrow_up: Update all Core Deps
26
+
15
27
  ### v5.2.1
16
28
 
17
29
  - :bug: Ensure Input Error border is shown consistently
@@ -51,18 +51,24 @@
51
51
  />
52
52
  <span>Advanced</span>
53
53
  </div>
54
- <pre
54
+ <slot
55
55
  v-if='open'
56
- class='my-3'
57
- v-text='err.body || err.stack'
58
- />
56
+ name='advanced'
57
+ :body='body'
58
+ >
59
+ <pre
60
+ class='my-3'
61
+ style='white-space: pre-wrap; word-break: break-word;'
62
+ v-text='body'
63
+ />
64
+ </slot>
59
65
  </div>
60
66
  </template>
61
67
  </div>
62
68
  </template>
63
69
 
64
70
  <script setup lang="ts">
65
- import { ref } from 'vue'
71
+ import { ref, computed } from 'vue'
66
72
  import {
67
73
  IconAlertTriangle,
68
74
  IconChevronRight,
@@ -71,17 +77,26 @@ import {
71
77
 
72
78
  export interface AlertProps {
73
79
  title?: string;
74
- err?: Error & { body?: string };
80
+ err?: Error & { body?: string | Record<string, unknown> };
75
81
  compact?: boolean;
76
82
  advanced?: boolean;
77
83
  }
78
84
 
79
- withDefaults(defineProps<AlertProps>(), {
85
+ const props = withDefaults(defineProps<AlertProps>(), {
80
86
  title: 'Generic Error',
81
87
  err: () => new Error('Something is amiss'),
82
88
  compact: false,
83
89
  advanced: true
84
90
  });
85
91
 
92
+ defineSlots<{
93
+ advanced?: (props: { body: string }) => unknown;
94
+ }>()
95
+
86
96
  const open = ref(false)
97
+
98
+ const body = computed<string>(() => {
99
+ const raw = props.err.body || props.err.stack || '';
100
+ return typeof raw === 'string' ? raw : JSON.stringify(raw, null, 4);
101
+ })
87
102
  </script>
@@ -119,11 +119,11 @@ function calcPosition() {
119
119
  left = t.right - m.width;
120
120
  }
121
121
 
122
- // Keep within viewport
122
+ // Keep within viewport - shift the menu rather than shrink it, so only a
123
+ // menu taller than the viewport itself ends up scrolling
123
124
  left = Math.max(gap, Math.min(left, vw - m.width - gap));
124
- top = Math.max(gap, Math.min(top, vh - gap));
125
+ top = Math.max(gap, Math.min(top, vh - m.height - gap));
125
126
 
126
- // Constrain height to available space below the computed top
127
127
  const maxHeight = Math.max(100, vh - top - gap);
128
128
 
129
129
  floatingStyle.value = {
@@ -11,7 +11,17 @@
11
11
  <Alert
12
12
  :title='title'
13
13
  :err='err'
14
- />
14
+ >
15
+ <template
16
+ v-if='$slots.advanced'
17
+ #advanced='slotProps'
18
+ >
19
+ <slot
20
+ name='advanced'
21
+ v-bind='slotProps'
22
+ />
23
+ </template>
24
+ </Alert>
15
25
 
16
26
  <div class='modal-footer'>
17
27
  <div class='w-100'>
@@ -43,6 +53,10 @@ withDefaults(defineProps<ErrProps>(), {
43
53
  trace: true
44
54
  });
45
55
 
56
+ defineSlots<{
57
+ advanced?: (props: { body: string }) => unknown;
58
+ }>()
59
+
46
60
  const emit = defineEmits<{
47
61
  (e: 'close'): void
48
62
  }>()
@@ -7,7 +7,17 @@
7
7
  :key='key'
8
8
  class='py-2 floating-input'
9
9
  >
10
- <template v-if='s.properties[key].enum'>
10
+ <template v-if='s.properties[key].type === "array" && s.properties[key].items && s.properties[key].items.enum'>
11
+ <TablerMultiEnum
12
+ v-model='data[key]'
13
+ :label='key'
14
+ :disabled='disabled'
15
+ :required='s.properties[key].required || false'
16
+ :description='s.properties[key].description || ""'
17
+ :options='s.properties[key].items.enum'
18
+ />
19
+ </template>
20
+ <template v-else-if='s.properties[key].enum'>
11
21
  <TablerEnum
12
22
  v-model='data[key]'
13
23
  :label='key'
@@ -111,6 +121,7 @@ import { ref, watch, onMounted } from 'vue'
111
121
  import TablerInput from './input/Input.vue';
112
122
  import TablerToggle from './input/Toggle.vue';
113
123
  import TablerEnum from './input/Enum.vue';
124
+ import TablerMultiEnum from './input/MultiEnum.vue';
114
125
  import TablerLoading from './Loading.vue';
115
126
  import {
116
127
  IconPlus,
@@ -27,55 +27,18 @@
27
27
  >
28
28
  <div class='m-1 text-center'>
29
29
  <div
30
- class='opt cursor-pointer py-1'
31
- @click='create({
32
- "name": "",
33
- "type": "string",
34
- "required": false,
35
- })'
30
+ v-for='option in SCHEMA_TYPES'
31
+ :key='option.label'
32
+ class='opt cursor-pointer py-1 d-flex align-items-center justify-content-center'
33
+ @click='add(option)'
36
34
  >
37
- String
38
- </div>
39
- <div
40
- class='opt cursor-pointer py-1'
41
- @click='create({
42
- "name": "",
43
- "type": "string",
44
- "enum": [],
45
- "required": false,
46
- })'
47
- >
48
- Enum
49
- </div>
50
- <div
51
- class='opt cursor-pointer py-1'
52
- @click='create({
53
- "name": "",
54
- "type": "boolean",
55
- "required": false,
56
- })'
57
- >
58
- Boolean
59
- </div>
60
- <div
61
- class='opt cursor-pointer py-1'
62
- @click='create({
63
- "name": "",
64
- "type": "number",
65
- "required": false,
66
- })'
67
- >
68
- Number
69
- </div>
70
- <div
71
- class='opt cursor-pointer py-1'
72
- @click='create({
73
- "name": "",
74
- "type": "integer",
75
- "required": false,
76
- })'
77
- >
78
- Integer
35
+ <component
36
+ :is='option.icon'
37
+ :size='20'
38
+ stroke='1'
39
+ class='me-2'
40
+ />
41
+ <span v-text='option.label' />
79
42
  </div>
80
43
  </div>
81
44
  </ul>
@@ -104,8 +67,17 @@
104
67
  />
105
68
  </div>
106
69
  <div class='overlay' />
70
+ <TablerMultiEnum
71
+ v-if='isMultiEnum(prop)'
72
+ :model-value='input[prop.name] || []'
73
+ :label='prop.name'
74
+ :disabled='true'
75
+ :required='prop.required || false'
76
+ :description='prop.description || ""'
77
+ :options='enumValues(prop) || []'
78
+ />
107
79
  <TablerEnum
108
- v-if='prop.enum'
80
+ v-else-if='prop.enum'
109
81
  :model-value='input[prop.name]'
110
82
  :label='prop.name'
111
83
  :disabled='true'
@@ -148,9 +120,12 @@ import {
148
120
  IconPlus,
149
121
  } from '@tabler/icons-vue';
150
122
  import BuilderEdit from './SchemaBuilderEdit.vue';
123
+ import { SCHEMA_TYPES, isMultiEnum, enumValues, schemaTemplate } from './schema-types';
124
+ import type { SchemaTypeOption } from './schema-types';
151
125
  import TablerNone from './None.vue';
152
126
  import TablerInput from './input/Input.vue';
153
127
  import TablerEnum from './input/Enum.vue';
128
+ import TablerMultiEnum from './input/MultiEnum.vue';
154
129
  import TablerToggle from './input/Toggle.vue';
155
130
  import TablerDelete from './Delete.vue';
156
131
 
@@ -231,6 +206,14 @@ onMounted(() => {
231
206
  }
232
207
  });
233
208
 
209
+ function add(option: SchemaTypeOption) {
210
+ create({
211
+ name: '',
212
+ required: false,
213
+ ...schemaTemplate(option),
214
+ } as SchemaProperty);
215
+ }
216
+
234
217
  function create(prop: SchemaProperty) {
235
218
  prop._id = Math.random().toString(36).substring(7);
236
219
  editIdx.value = null;
@@ -9,33 +9,14 @@
9
9
  <div class='modal-status bg-yellow' />
10
10
  <div class='modal-header'>
11
11
  <div class='d-flex align-items-center my-2'>
12
- <template v-if='edit.type === "string"'>
13
- <IconAlphabetLatin
14
- :size='32'
15
- stroke='1'
16
- />
17
- </template>
18
- <template v-else-if='edit.type === "number"'>
19
- <DecimalIcon
20
- :size='32'
21
- stroke='1'
22
- />
23
- </template>
24
- <template v-else-if='edit.type === "integer"'>
25
- <Sort09Icon
26
- :size='32'
27
- stroke='1'
28
- />
29
- </template>
30
- <template v-else>
31
- <BinaryIcon
32
- :size='32'
33
- stroke='1'
34
- />
35
- </template>
12
+ <component
13
+ :is='schemaType(edit).icon'
14
+ :size='32'
15
+ stroke='1'
16
+ />
36
17
  <span
37
18
  class='my-1 mx-2 strong'
38
- v-text='edit.type'
19
+ v-text='schemaType(edit).label'
39
20
  />
40
21
  </div>
41
22
  </div>
@@ -56,10 +37,9 @@
56
37
  label='Description'
57
38
  />
58
39
 
59
- <template v-if='edit.type === "string" && edit.enum === undefined' />
60
- <template v-else-if='edit.type === "string" && Array.isArray(edit.enum)'>
40
+ <template v-if='options'>
61
41
  <div class='subheader mt-2'>
62
- Enum Values
42
+ Options
63
43
  </div>
64
44
  <div class='col-12 d-flex'>
65
45
  <TablerInput
@@ -80,7 +60,7 @@
80
60
  </div>
81
61
  <div class='list-group list-group-flush mt-2'>
82
62
  <div
83
- v-for='(val, i) in edit.enum'
63
+ v-for='(val, i) in options'
84
64
  :key='i'
85
65
  class='list-group-item d-flex justify-content-between align-items-center py-1'
86
66
  >
@@ -89,13 +69,11 @@
89
69
  :size='16'
90
70
  stroke='1'
91
71
  class='cursor-pointer text-danger'
92
- @click='edit.enum?.splice(i, 1)'
72
+ @click='options.splice(i, 1)'
93
73
  />
94
74
  </div>
95
75
  </div>
96
76
  </template>
97
- <template v-else-if='edit.type === "number"' />
98
- <template v-else-if='edit.type === "integer"' />
99
77
  </div>
100
78
  </div>
101
79
  <div class='modal-footer'>
@@ -111,12 +89,12 @@
111
89
  </template>
112
90
 
113
91
  <script setup lang="ts">
114
- import { ref } from 'vue';
92
+ import { ref, computed } from 'vue';
115
93
  import {
116
- IconAlphabetLatin,
117
94
  IconPlus,
118
95
  IconTrash
119
96
  } from '@tabler/icons-vue';
97
+ import { schemaType, enumValues } from './schema-types';
120
98
  import TablerModal from './Modal.vue';
121
99
  import TablerInput from './input/Input.vue';
122
100
  import TablerToggle from './input/Toggle.vue';
@@ -127,6 +105,7 @@ interface SchemaProperty {
127
105
  required: boolean;
128
106
  description?: string;
129
107
  enum?: string[];
108
+ items?: { type: string; enum?: string[] };
130
109
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
131
110
  [key: string]: any;
132
111
  }
@@ -143,10 +122,13 @@ defineEmits<{
143
122
  const edit = ref<SchemaProperty>(JSON.parse(JSON.stringify(props.prop)));
144
123
  const newEnum = ref('');
145
124
 
125
+ /** Live option list of a Dropdown or Multiple Choice element */
126
+ const options = computed<string[] | undefined>(() => enumValues(edit.value));
127
+
146
128
  function addEnum() {
147
- if (!newEnum.value.trim()) return;
148
- if (!edit.value.enum) edit.value.enum = [];
149
- edit.value.enum.push(newEnum.value.trim());
129
+ const value = newEnum.value.trim();
130
+ if (!value || !options.value || options.value.includes(value)) return;
131
+ options.value.push(value);
150
132
  newEnum.value = '';
151
133
  }
152
134
  </script>
@@ -0,0 +1,78 @@
1
+ <template>
2
+ <div class='row'>
3
+ <TablerLabel
4
+ v-if='label'
5
+ :label='label'
6
+ :description='description'
7
+ :required='required'
8
+ >
9
+ <slot />
10
+ </TablerLabel>
11
+ <div class='col-12'>
12
+ <label
13
+ v-for='option in options'
14
+ :key='option'
15
+ class='form-check'
16
+ >
17
+ <input
18
+ class='form-check-input'
19
+ type='checkbox'
20
+ :value='option'
21
+ :checked='current.includes(option)'
22
+ :disabled='disabled'
23
+ @change='toggle(option)'
24
+ @blur='$emit("blur")'
25
+ >
26
+ <span
27
+ class='form-check-label'
28
+ v-text='option'
29
+ />
30
+ </label>
31
+ </div>
32
+ </div>
33
+ </template>
34
+
35
+ <script setup lang="ts">
36
+ import { ref, watch } from 'vue'
37
+ import TablerLabel from '../internal/Label.vue'
38
+
39
+ export interface MultiEnumProps {
40
+ modelValue: string[];
41
+ required?: boolean;
42
+ description?: string;
43
+ options: string[];
44
+ disabled?: boolean;
45
+ label?: string;
46
+ }
47
+
48
+ const props = withDefaults(defineProps<MultiEnumProps>(), {
49
+ required: false,
50
+ description: '',
51
+ disabled: false,
52
+ label: ''
53
+ });
54
+
55
+ const emit = defineEmits<{
56
+ (e: 'blur'): void;
57
+ (e: 'update:modelValue', value: string[]): void;
58
+ }>();
59
+
60
+ const current = ref<string[]>([...(props.modelValue || [])])
61
+
62
+ watch(() => props.modelValue, (newValue) => {
63
+ current.value = [...(newValue || [])]
64
+ })
65
+
66
+ function toggle(option: string) {
67
+ if (current.value.includes(option)) {
68
+ current.value = current.value.filter((value) => value !== option)
69
+ } else {
70
+ // Preserve option order so the value is stable regardless of click order
71
+ current.value = props.options.filter((value) => {
72
+ return value === option || current.value.includes(value)
73
+ })
74
+ }
75
+
76
+ emit('update:modelValue', current.value)
77
+ }
78
+ </script>
@@ -0,0 +1,91 @@
1
+ import type { Component } from 'vue';
2
+ import {
3
+ IconDecimal,
4
+ IconSort09,
5
+ IconSelector,
6
+ IconListCheck,
7
+ IconToggleLeft,
8
+ IconAlphabetLatin,
9
+ } from '@tabler/icons-vue';
10
+
11
+ export interface SchemaTypeOption {
12
+ /** Human readable name shown in the builder */
13
+ label: string;
14
+ icon: Component;
15
+ /** JSON Schema type the option produces */
16
+ type: string;
17
+ /** Option produces a string constrained to an enum */
18
+ enum?: boolean;
19
+ /** Option produces an array of strings constrained to an enum */
20
+ multiple?: boolean;
21
+ }
22
+
23
+ export const SCHEMA_TYPES: SchemaTypeOption[] = [
24
+ { label: 'Text', icon: IconAlphabetLatin, type: 'string' },
25
+ { label: 'Dropdown', icon: IconSelector, type: 'string', enum: true },
26
+ { label: 'Multiple Choice', icon: IconListCheck, type: 'array', multiple: true },
27
+ { label: 'Toggle', icon: IconToggleLeft, type: 'boolean' },
28
+ { label: 'Number', icon: IconDecimal, type: 'number' },
29
+ { label: 'Whole Number', icon: IconSort09, type: 'integer' },
30
+ ];
31
+
32
+ /** A schema element whose value is one of a fixed set of options */
33
+ export function isEnum(prop: { enum?: unknown }): boolean {
34
+ return Array.isArray(prop.enum);
35
+ }
36
+
37
+ /** A schema element whose value is any number of a fixed set of options */
38
+ export function isMultiEnum(prop: { type?: unknown; items?: unknown }): boolean {
39
+ return prop.type === 'array'
40
+ && typeof prop.items === 'object'
41
+ && prop.items !== null
42
+ && isEnum(prop.items as { enum?: unknown });
43
+ }
44
+
45
+ /**
46
+ * The option values a Dropdown or Multiple Choice element allows - the array
47
+ * is the live one on the element so it can be edited in place
48
+ */
49
+ export function enumValues(prop: { type?: unknown; enum?: unknown; items?: unknown }): string[] | undefined {
50
+ if (isEnum(prop)) return prop.enum as string[];
51
+ if (isMultiEnum(prop)) return (prop.items as { enum: string[] }).enum;
52
+ return undefined;
53
+ }
54
+
55
+ /** The JSON Schema element a builder option creates */
56
+ export function schemaTemplate(option: SchemaTypeOption): Record<string, unknown> {
57
+ if (option.multiple) {
58
+ return {
59
+ type: 'array',
60
+ uniqueItems: true,
61
+ items: { type: 'string', enum: [] },
62
+ };
63
+ }
64
+
65
+ if (option.enum) return { type: option.type, enum: [] };
66
+
67
+ return { type: option.type };
68
+ }
69
+
70
+ /**
71
+ * Resolve the builder option a schema element was created from, falling back
72
+ * to a capitalized copy of the raw JSON Schema type for anything unrecognised
73
+ */
74
+ export function schemaType(prop: { type: string; enum?: unknown; items?: unknown }): SchemaTypeOption {
75
+ const multiple = isMultiEnum(prop);
76
+ const single = !multiple && isEnum(prop);
77
+
78
+ const match = SCHEMA_TYPES.find((option) => {
79
+ return option.type === prop.type
80
+ && Boolean(option.enum) === single
81
+ && Boolean(option.multiple) === multiple;
82
+ });
83
+
84
+ if (match) return match;
85
+
86
+ return {
87
+ label: prop.type.charAt(0).toUpperCase() + prop.type.slice(1),
88
+ icon: IconAlphabetLatin,
89
+ type: prop.type,
90
+ };
91
+ }
package/lib.ts CHANGED
@@ -7,6 +7,7 @@ export { default as TablerToggle } from './components/input/Toggle.vue'
7
7
  export { default as TablerInput } from './components/input/Input.vue'
8
8
  export { default as TablerFileInput } from './components/input/FileInput.vue'
9
9
  export { default as TablerEnum } from './components/input/Enum.vue';
10
+ export { default as TablerMultiEnum } from './components/input/MultiEnum.vue';
10
11
 
11
12
  export { default as TablerAlert } from './components/Alert.vue'
12
13
  export { default as TablerBorder } from './components/Border.vue'
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tak-ps/vue-tabler",
3
3
  "type": "module",
4
- "version": "5.2.1",
4
+ "version": "5.4.0",
5
5
  "lib": "lib.ts",
6
6
  "main": "lib.ts",
7
7
  "module": "lib.ts",
@@ -46,7 +46,7 @@
46
46
  "typescript": "^6.0.0",
47
47
  "typescript-eslint": "^8.36.0",
48
48
  "vite": "^8.0.0",
49
- "vitest": "^4.1.0",
49
+ "vitest": "^5.0.0",
50
50
  "vue": "^3.5.12",
51
51
  "vue-tsc": "^3.2.1"
52
52
  }
@@ -0,0 +1,122 @@
1
+ import { describe, expect, it } from 'vitest'
2
+ import { mount } from '@vue/test-utils'
3
+ import SchemaBuilder from '../components/SchemaBuilder.vue'
4
+ import SchemaBuilderEdit from '../components/SchemaBuilderEdit.vue'
5
+ import MultiEnum from '../components/input/MultiEnum.vue'
6
+ import { schemaType, schemaTemplate, enumValues, SCHEMA_TYPES } from '../components/schema-types'
7
+
8
+ describe('schemaType', () => {
9
+ it('maps JSON Schema types to human readable labels', () => {
10
+ expect(schemaType({ type: 'string' }).label).toBe('Text')
11
+ expect(schemaType({ type: 'string', enum: ['a'] }).label).toBe('Dropdown')
12
+ expect(schemaType({ type: 'array', items: { type: 'string', enum: ['a'] } }).label).toBe('Multiple Choice')
13
+ expect(schemaType({ type: 'boolean' }).label).toBe('Toggle')
14
+ expect(schemaType({ type: 'number' }).label).toBe('Number')
15
+ expect(schemaType({ type: 'integer' }).label).toBe('Whole Number')
16
+ })
17
+
18
+ it('falls back to a capitalized raw type for anything unrecognised', () => {
19
+ expect(schemaType({ type: 'array' }).label).toBe('Array')
20
+ expect(schemaType({ type: 'array', items: { type: 'object' } }).label).toBe('Array')
21
+ })
22
+ })
23
+
24
+ describe('schemaTemplate', () => {
25
+ it('builds a Multiple Choice element as an array of enum strings', () => {
26
+ const option = SCHEMA_TYPES.find((o) => o.label === 'Multiple Choice')!
27
+
28
+ expect(schemaTemplate(option)).toEqual({
29
+ type: 'array',
30
+ uniqueItems: true,
31
+ items: { type: 'string', enum: [] },
32
+ })
33
+ })
34
+
35
+ it('edits the option list in place for both enum shapes', () => {
36
+ const single = { type: 'string', enum: ['a'] }
37
+ const multiple = { type: 'array', items: { type: 'string', enum: ['a'] } }
38
+
39
+ enumValues(single)!.push('b')
40
+ enumValues(multiple)!.push('b')
41
+
42
+ expect(single.enum).toEqual(['a', 'b'])
43
+ expect(multiple.items.enum).toEqual(['a', 'b'])
44
+ expect(enumValues({ type: 'string' })).toBeUndefined()
45
+ })
46
+ })
47
+
48
+ describe('TablerSchemaBuilder', () => {
49
+ it('offers every field type by its human readable name', () => {
50
+ const wrapper = mount(SchemaBuilder, {
51
+ props: {
52
+ modelValue: { type: 'object', properties: {} },
53
+ },
54
+ })
55
+
56
+ const labels = wrapper.findAll('.opt').map((opt) => opt.text().trim())
57
+
58
+ expect(labels).toEqual(SCHEMA_TYPES.map((option) => option.label))
59
+ expect(labels).not.toContain('string')
60
+ expect(labels).not.toContain('String')
61
+ })
62
+
63
+ it('offers the option list for a Multiple Choice element', () => {
64
+ const wrapper = mount(SchemaBuilderEdit, {
65
+ attachTo: document.body,
66
+ props: {
67
+ prop: {
68
+ name: 'resources',
69
+ type: 'array',
70
+ required: false,
71
+ items: { type: 'string', enum: ['fire', 'police'] },
72
+ },
73
+ },
74
+ })
75
+
76
+ const body = document.body.textContent || ''
77
+
78
+ expect(document.body.querySelector('.modal-header')?.textContent?.trim()).toBe('Multiple Choice')
79
+ expect(body).toContain('Options')
80
+ expect(body).toContain('fire')
81
+ expect(body).toContain('police')
82
+
83
+ wrapper.unmount()
84
+ })
85
+
86
+ it('titles the property editor with the human readable type', () => {
87
+ const wrapper = mount(SchemaBuilderEdit, {
88
+ attachTo: document.body,
89
+ props: {
90
+ prop: { name: 'priority', type: 'string', required: false, enum: ['low', 'high'] },
91
+ },
92
+ })
93
+
94
+ const header = document.body.querySelector('.modal-header')
95
+
96
+ expect(header?.textContent?.trim()).toBe('Dropdown')
97
+
98
+ wrapper.unmount()
99
+ })
100
+ })
101
+
102
+ describe('TablerMultiEnum', () => {
103
+ it('emits the checked options in option order', async () => {
104
+ const wrapper = mount(MultiEnum, {
105
+ props: {
106
+ modelValue: [],
107
+ options: ['fire', 'police', 'medical'],
108
+ },
109
+ })
110
+
111
+ const boxes = wrapper.findAll('input[type="checkbox"]')
112
+
113
+ await boxes[2].setValue(true)
114
+ await boxes[0].setValue(true)
115
+
116
+ const emitted = wrapper.emitted('update:modelValue')!
117
+ expect(emitted[emitted.length - 1][0]).toEqual(['fire', 'medical'])
118
+
119
+ await boxes[2].setValue(false)
120
+ expect(wrapper.emitted('update:modelValue')!.at(-1)![0]).toEqual(['fire'])
121
+ })
122
+ })