@tak-ps/vue-tabler 5.9.0 → 5.10.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,10 @@
12
12
 
13
13
  ### Pending
14
14
 
15
+ ### v5.10.0 - 2026-10-18
16
+
17
+ - :tada: `TablerSchema` renders a property carrying an `@widget` hint through a `widget-<name>` scoped slot (`field`, `property`, `modelValue`, `disabled`, `update`) when the parent provides one, falling back to the input implied by the property type otherwise
18
+
15
19
  ### v5.9.0 - 2026-10-13
16
20
 
17
21
  - :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
@@ -7,7 +7,17 @@
7
7
  :key='key'
8
8
  class='py-2 floating-input'
9
9
  >
10
- <template v-if='isMultiEnum(s.properties[key])'>
10
+ <template v-if='widgetSlot(key)'>
11
+ <slot
12
+ :name='widgetSlot(key)'
13
+ :field='key'
14
+ :property='s.properties[key]'
15
+ :model-value='data[key]'
16
+ :disabled='disabled'
17
+ :update='(value: unknown) => data[key] = value'
18
+ />
19
+ </template>
20
+ <template v-else-if='isMultiEnum(s.properties[key])'>
11
21
  <TablerMultiEnum
12
22
  v-model='data[key]'
13
23
  :label='key'
@@ -373,7 +383,7 @@
373
383
  </template>
374
384
 
375
385
  <script setup lang="ts">
376
- import { ref, reactive, computed, watch, onMounted } from 'vue'
386
+ import { ref, reactive, computed, watch, onMounted, useSlots } from 'vue'
377
387
  import TablerInput from './input/Input.vue';
378
388
  import TablerToggle from './input/Toggle.vue';
379
389
  import TablerEnum from './input/Enum.vue';
@@ -409,6 +419,8 @@ const emit = defineEmits<{
409
419
  (e: 'update:modelValue', value: any): void;
410
420
  }>();
411
421
 
422
+ const slots = useSlots();
423
+
412
424
  const loading = ref(true);
413
425
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
414
426
  const s = ref<any>({});
@@ -436,6 +448,14 @@ const csv = reactive({
436
448
  /** Selected union variant index per property key */
437
449
  const variant = reactive<Record<string, number>>({});
438
450
 
451
+ /** Name of the `widget-<name>` slot a property's `@widget` hint is rendered with, when the parent provides one */
452
+ const widgetSlot = (key: string): string | undefined => {
453
+ const widget = s.value.properties[key]['@widget'];
454
+ if (typeof widget !== 'string') return;
455
+ const name = `widget-${widget}`;
456
+ return slots[name] ? name : undefined;
457
+ }
458
+
439
459
  /** Properties with a fixed const value are seeded but never rendered */
440
460
  const visibleKeys = computed<string[]>(() => {
441
461
  if (!s.value.properties) 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.9.0",
4
+ "version": "5.10.0",
5
5
  "lib": "lib.ts",
6
6
  "main": "lib.ts",
7
7
  "module": "lib.ts",
@@ -612,4 +612,36 @@ describe('TablerSchema applying default values', () => {
612
612
  expect((wrapper.find('select').element as HTMLSelectElement).value).toBe('Team Account')
613
613
  expect(lastEmitted(wrapper)).toEqual({ Source: { Mode: 'Team', TeamId: 't', Verbose: true } })
614
614
  })
615
+
616
+ it('renders a property with an @widget hint through its slot and takes the slot update', async () => {
617
+ const wrapper = mount(Schema, {
618
+ props: {
619
+ modelValue: {},
620
+ schema: {
621
+ type: 'object',
622
+ properties: {
623
+ Type: { type: 'string', default: 'a-f-G', '@widget': 'type' },
624
+ Icon: { type: 'string', '@widget': 'icon' },
625
+ },
626
+ },
627
+ },
628
+ slots: {
629
+ 'widget-type': `<template #widget-type='{ field, modelValue, update }'>
630
+ <button class='widget' :data-field='field' @click='update("a-h-G")'>{{ modelValue }}</button>
631
+ </template>`,
632
+ },
633
+ })
634
+
635
+ await flushPromises()
636
+
637
+ const widget = wrapper.get('button.widget')
638
+ expect(widget.attributes('data-field')).toBe('Type')
639
+ expect(widget.text()).toBe('a-f-G')
640
+ expect(wrapper.findAll('input').length).toBe(1)
641
+
642
+ await widget.trigger('click')
643
+ await flushPromises()
644
+
645
+ expect(lastEmitted(wrapper)).toEqual({ Type: 'a-h-G', Icon: '' })
646
+ })
615
647
  })