@tak-ps/vue-tabler 5.8.0 → 5.9.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,11 @@
12
12
 
13
13
  ### Pending
14
14
 
15
+ ### v5.9.0 - 2026-10-13
16
+
17
+ - :bug: `TablerSchema` renders an array of strings, numbers or booleans as a list of inline inputs with add & remove controls - previously each entry was an empty `Entry N` box as the item schema has no properties to recurse into
18
+ - :white_check_mark: Add `TablerSchema` primitive list tests
19
+
15
20
  ### v5.8.0 - 2026-09-21
16
21
 
17
22
  - :tada: Add a `dismissable` prop to `TablerModal`, off by default, that emits `close` when the backdrop is clicked
@@ -178,6 +178,78 @@
178
178
  />
179
179
  </div>
180
180
  </template>
181
+ <template v-else-if='isPrimitiveList(s.properties[key])'>
182
+ <div class='d-flex align-items-center'>
183
+ <label
184
+ class='form-label mb-0'
185
+ v-text='key'
186
+ />
187
+ <span
188
+ v-if='s.properties[key].required'
189
+ class='text-red mx-1'
190
+ >*</span>
191
+ <div
192
+ v-if='!disabled'
193
+ class='ms-auto d-flex'
194
+ >
195
+ <TablerIconButton
196
+ title='Add Entry'
197
+ @click='push(key)'
198
+ >
199
+ <IconPlus
200
+ :size='32'
201
+ stroke='1'
202
+ />
203
+ </TablerIconButton>
204
+ </div>
205
+ </div>
206
+ <div
207
+ v-if='s.properties[key].description'
208
+ class='text-muted small mb-1'
209
+ v-text='s.properties[key].description'
210
+ />
211
+
212
+ <div
213
+ v-for='(entry, i) of data[key]'
214
+ :key='i'
215
+ class='d-flex align-items-center my-1'
216
+ >
217
+ <div class='flex-grow-1'>
218
+ <TablerToggle
219
+ v-if='s.properties[key].items.type === "boolean"'
220
+ v-model='data[key][i]'
221
+ :label='`${key} ${Number(i) + 1}`'
222
+ :disabled='disabled'
223
+ />
224
+ <TablerInput
225
+ v-else
226
+ v-model='data[key][i]'
227
+ :type='s.properties[key].items.type === "string" ? "text" : s.properties[key].items.type'
228
+ :step='s.properties[key].items.type === "integer" ? 1 : "any"'
229
+ :placeholder='`${key} ${Number(i) + 1}`'
230
+ :disabled='disabled'
231
+ />
232
+ </div>
233
+ <TablerIconButton
234
+ v-if='!disabled'
235
+ title='Remove Entry'
236
+ class='ms-2'
237
+ @click='data[key].splice(i, 1)'
238
+ >
239
+ <IconTrash
240
+ :size='32'
241
+ stroke='1'
242
+ />
243
+ </TablerIconButton>
244
+ </div>
245
+
246
+ <TablerNone
247
+ v-if='!data[key].length'
248
+ :label='key'
249
+ :create='!disabled'
250
+ @create='push(key)'
251
+ />
252
+ </template>
181
253
  <template v-else-if='s.properties[key].type === "array"'>
182
254
  <div class='d-flex'>
183
255
  <label
@@ -467,6 +539,15 @@ const isObjectTable = (prop: any): boolean => {
467
539
  && !!prop.items.properties;
468
540
  }
469
541
 
542
+ /** An array of strings, numbers or booleans is rendered as a list of inline inputs */
543
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
544
+ const isPrimitiveList = (prop: any): boolean => {
545
+ return prop.type === 'array'
546
+ && prop.items
547
+ && !prop.items.enum
548
+ && ['string', 'number', 'integer', 'boolean'].includes(prop.items.type);
549
+ }
550
+
470
551
  const columns = (key: string): string[] => {
471
552
  const prop = s.value.properties[key];
472
553
  if (!prop || !isObjectTable(prop)) return [];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tak-ps/vue-tabler",
3
3
  "type": "module",
4
- "version": "5.8.0",
4
+ "version": "5.9.0",
5
5
  "lib": "lib.ts",
6
6
  "main": "lib.ts",
7
7
  "module": "lib.ts",
@@ -385,6 +385,103 @@ describe('TablerSchema editing primitives', () => {
385
385
  })
386
386
  })
387
387
 
388
+ describe('TablerSchema primitive lists', () => {
389
+ it('renders an array of strings as one text input per entry', async () => {
390
+ const wrapper = mount(Schema, {
391
+ props: {
392
+ modelValue: { Agencies: ['BVFD', 'KCCAMB'] },
393
+ schema: {
394
+ type: 'object',
395
+ properties: {
396
+ Agencies: { type: 'array', items: { type: 'string' }, description: 'Agency codes' },
397
+ },
398
+ },
399
+ },
400
+ })
401
+
402
+ await flushPromises()
403
+
404
+ const inputs = wrapper.findAll('input[type="text"]')
405
+ expect(inputs.map((i) => (i.element as HTMLInputElement).value)).toEqual(['BVFD', 'KCCAMB'])
406
+ expect(wrapper.text()).toContain('Agency codes')
407
+
408
+ await inputs[1].setValue('CWVFD')
409
+ await flushPromises()
410
+ expect(lastEmitted(wrapper).Agencies).toEqual(['BVFD', 'CWVFD'])
411
+ })
412
+
413
+ it('adds and removes entries', async () => {
414
+ const wrapper = mount(Schema, {
415
+ props: {
416
+ modelValue: {},
417
+ schema: {
418
+ type: 'object',
419
+ properties: {
420
+ Agencies: { type: 'array', items: { type: 'string' } },
421
+ },
422
+ },
423
+ },
424
+ })
425
+
426
+ await flushPromises()
427
+ expect(wrapper.findAll('input[type="text"]').length).toBe(0)
428
+
429
+ await wrapper.find('[title="Add Entry"]').trigger('click')
430
+ await flushPromises()
431
+ expect(wrapper.findAll('input[type="text"]').length).toBe(1)
432
+
433
+ await wrapper.find('input[type="text"]').setValue('SFD')
434
+ await flushPromises()
435
+ expect(lastEmitted(wrapper).Agencies).toEqual(['SFD'])
436
+
437
+ await wrapper.find('[title="Remove Entry"]').trigger('click')
438
+ await flushPromises()
439
+ expect(lastEmitted(wrapper).Agencies).toEqual([])
440
+ })
441
+
442
+ it('emits typed values for number and boolean lists', async () => {
443
+ const wrapper = mount(Schema, {
444
+ props: {
445
+ modelValue: { Ports: [80], Flags: [false] },
446
+ schema: {
447
+ type: 'object',
448
+ properties: {
449
+ Ports: { type: 'array', items: { type: 'integer' } },
450
+ Flags: { type: 'array', items: { type: 'boolean' } },
451
+ },
452
+ },
453
+ },
454
+ })
455
+
456
+ await flushPromises()
457
+
458
+ await wrapper.find('input[type="number"]').setValue('443')
459
+ await wrapper.find('.form-switch input').setValue(true)
460
+ await flushPromises()
461
+
462
+ const data = lastEmitted(wrapper)
463
+ expect(data.Ports).toEqual([443])
464
+ expect(data.Flags).toEqual([true])
465
+ })
466
+
467
+ it('leaves enum arrays to the multi enum control', async () => {
468
+ const wrapper = mount(Schema, {
469
+ props: {
470
+ modelValue: {},
471
+ schema: {
472
+ type: 'object',
473
+ properties: {
474
+ Roles: { type: 'array', uniqueItems: true, items: { type: 'string', enum: ['admin', 'user'] } },
475
+ },
476
+ },
477
+ },
478
+ })
479
+
480
+ await flushPromises()
481
+ expect(wrapper.find('[title="Add Entry"]').exists()).toBe(false)
482
+ })
483
+ })
484
+
388
485
  const DEFAULT_SCHEMA = {
389
486
  type: 'object',
390
487
  properties: {