@tak-ps/vue-tabler 5.10.0 → 5.12.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,19 @@
12
12
 
13
13
  ### Pending
14
14
 
15
+ ### v5.12.0 - 2026-11-23
16
+
17
+ - :tada: `TablerDelete` gains an `open` model (`v-model:open`) and a `displaytype='none'` mode that renders no trigger, so the confirmation can be opened from elsewhere and closed by the parent once its delete completes
18
+ - :bug: `TablerDelete` resets its loading state and `match` input whenever the confirmation closes - previously a reopened confirmation kept its spinner
19
+ - :pencil2: A `TablerDelete` inside a `TablerDropdown` never emits `delete`, as the click on the teleported confirmation closes the menu and unmounts it first - use a plain menu item with `displaytype='none'` and `v-model:open` instead
20
+ - :white_check_mark: Add `TablerDelete` tests
21
+
22
+ ### v5.11.0 - 2026-11-23
23
+
24
+ - :tada: `TablerIconButton` gains a `bordered` prop that draws it as an outlined button and an `active` prop that fills it with the primary color and sets `aria-pressed` for use as a toggle
25
+ - :bug: `TablerDropdown` handles `Escape` and arrow keys on the teleported menu and stops them propagating so Bootstrap's `.dropdown-menu` keydown handler never runs against a menu without a `data-bs-toggle` trigger (previously threw `this._element is undefined` when pressing `Escape` inside a dropdown input)
26
+ - :bug: `TablerBadge` text now defaults to `var(--tblr-body-color)` instead of white so badges stay legible in light mode
27
+
15
28
  ### v5.10.0 - 2026-10-18
16
29
 
17
30
  - :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
@@ -27,7 +27,7 @@ const props = withDefaults(defineProps<BadgeProps>(), {
27
27
  borderColor: undefined,
28
28
  borderStyle: 'solid',
29
29
  borderWidth: '1px',
30
- textColor: '#ffffff',
30
+ textColor: 'var(--tblr-body-color)',
31
31
  hoverBackgroundColor: undefined,
32
32
  hoverBorderColor: undefined,
33
33
  hoverBorderStyle: undefined,
@@ -27,7 +27,7 @@
27
27
  />
28
28
  </div>
29
29
  </template>
30
- <template v-else>
30
+ <template v-else-if='props.displaytype === "icon"'>
31
31
  <TablerIconButton
32
32
  :title='props.title'
33
33
  :disabled='props.disabled'
@@ -40,12 +40,12 @@
40
40
  </TablerIconButton>
41
41
  </template>
42
42
 
43
- <TablerModal v-if='modal'>
43
+ <TablerModal v-if='open'>
44
44
  <button
45
45
  type='button'
46
46
  class='btn-close'
47
47
  aria-label='Close'
48
- @click='modal = false'
48
+ @click='open = false'
49
49
  />
50
50
  <div class='modal-status bg-red' />
51
51
  <div class='modal-header text-center py-4'>
@@ -92,7 +92,7 @@
92
92
  </template>
93
93
 
94
94
  <script setup lang="ts">
95
- import { ref } from 'vue'
95
+ import { ref, watch } from 'vue'
96
96
  import TablerModal from './Modal.vue';
97
97
  import TablerIconButton from './IconButton.vue';
98
98
  import TablerLoading from './Loading.vue';
@@ -106,7 +106,7 @@ export interface DeleteProps {
106
106
  title?: string;
107
107
  size?: number;
108
108
  disabled?: boolean;
109
- displaytype?: 'button' | 'icon' | 'menu';
109
+ displaytype?: 'button' | 'icon' | 'menu' | 'none';
110
110
  match?: string;
111
111
  }
112
112
 
@@ -122,14 +122,19 @@ const emit = defineEmits<{
122
122
  (e: 'delete'): void
123
123
  }>()
124
124
 
125
+ const open = defineModel<boolean>('open', { default: false })
126
+
125
127
  const loading = ref(false)
126
- const modal = ref(false)
127
128
  const matchInput = ref('')
128
129
 
130
+ watch(open, () => {
131
+ loading.value = false;
132
+ matchInput.value = '';
133
+ })
134
+
129
135
  const openModal = () => {
130
136
  if (props.disabled) return;
131
- matchInput.value = '';
132
- modal.value = true;
137
+ open.value = true;
133
138
  }
134
139
 
135
140
  const deleting = () => {
@@ -22,6 +22,7 @@
22
22
  :style='floatingStyle'
23
23
  :aria-labelledby='id'
24
24
  @click='onMenuClick'
25
+ @keydown='onMenuKeydown'
25
26
  >
26
27
  <slot name='dropdown'>
27
28
  Dropdown Content
@@ -168,6 +169,15 @@ function onEscape(e: KeyboardEvent) {
168
169
  if (e.key === 'Escape') isOpen.value = false;
169
170
  }
170
171
 
172
+ function onMenuKeydown(e: KeyboardEvent) {
173
+ if (e.key === 'Escape') {
174
+ e.stopPropagation();
175
+ isOpen.value = false;
176
+ } else if (e.key === 'ArrowUp' || e.key === 'ArrowDown') {
177
+ e.stopPropagation();
178
+ }
179
+ }
180
+
171
181
  onMounted(() => {
172
182
  document.addEventListener('click', onOutsideClick, true);
173
183
  document.addEventListener('keydown', onEscape);
@@ -5,10 +5,13 @@
5
5
  :aria-label='props.title'
6
6
  tabindex='0'
7
7
  role='button'
8
+ :aria-pressed='props.active'
8
9
  :class='{
9
10
  "cursor-pointer": props.disabled === false,
10
11
  "cursor-default disabled": props.disabled === true,
11
- "custom-hover": props.hover && !props.color,
12
+ "custom-hover": props.hover && !props.color && !props.active,
13
+ "icon-button-bordered": props.bordered,
14
+ "icon-button-active": props.active === true,
12
15
  }'
13
16
  :style='iconButtonStyle'
14
17
  class='rounded'
@@ -30,11 +33,15 @@ export interface IconButtonProps {
30
33
  title: string;
31
34
  hover?: boolean;
32
35
  disabled?: boolean;
36
+ bordered?: boolean;
37
+ active?: boolean;
33
38
  }
34
39
 
35
40
  const props = withDefaults(defineProps<IconButtonProps>(), {
36
41
  hover: true,
37
- disabled: false
42
+ disabled: false,
43
+ bordered: false,
44
+ active: undefined
38
45
  });
39
46
 
40
47
  const iconButtonStyle = computed(() => {
@@ -69,4 +76,31 @@ const iconButtonStyle = computed(() => {
69
76
  border-color: color-mix(in srgb, var(--tblr-light) 30%, transparent);
70
77
  background: color-mix(in srgb, var(--tblr-light) 12%, transparent);
71
78
  }
79
+
80
+ .icon-button-bordered {
81
+ display: inline-flex;
82
+ align-items: center;
83
+ justify-content: center;
84
+ padding: 0.5rem;
85
+ border: var(--tblr-border-width) solid var(--tblr-border-color);
86
+ border-radius: var(--tblr-border-radius);
87
+ background: var(--tblr-bg-surface);
88
+ }
89
+
90
+ .icon-button-bordered.custom-hover:not(.disabled) {
91
+ border-color: var(--tblr-border-color);
92
+ }
93
+
94
+ .icon-button-active {
95
+ border: var(--tblr-border-width) solid var(--tblr-primary);
96
+ border-radius: var(--tblr-border-radius);
97
+ background: var(--tblr-primary);
98
+ color: var(--tblr-primary-fg, #ffffff);
99
+ transition: filter 0.15s ease;
100
+ }
101
+
102
+ .icon-button-active:not(.disabled):hover,
103
+ .icon-button-active:not(.disabled):focus-visible {
104
+ filter: brightness(1.1);
105
+ }
72
106
  </style>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tak-ps/vue-tabler",
3
3
  "type": "module",
4
- "version": "5.10.0",
4
+ "version": "5.12.0",
5
5
  "lib": "lib.ts",
6
6
  "main": "lib.ts",
7
7
  "module": "lib.ts",
@@ -49,7 +49,7 @@
49
49
  "eslint": "^10.0.0",
50
50
  "eslint-plugin-vue": "^10.0.0",
51
51
  "globals": "^17.0.0",
52
- "jsdom": "^30.0.0",
52
+ "jsdom": "^31.0.0",
53
53
  "typescript": "^6.0.0",
54
54
  "typescript-eslint": "^8.36.0",
55
55
  "vite": "^8.0.0",
@@ -19,7 +19,7 @@ describe('TablerBadge', () => {
19
19
 
20
20
  expect(badge.style.backgroundColor).toBe('rgba(34, 197, 94, 0.2)')
21
21
  expect(badge.style.borderColor).toBe('rgba(27, 158, 75, 0.2)')
22
- expect(badge.style.color).toBe('rgb(255, 255, 255)')
22
+ expect(badge.style.color).toBe('var(--tblr-body-color)')
23
23
  })
24
24
 
25
25
  it('derives a darker border color from the provided background color', () => {
@@ -0,0 +1,63 @@
1
+ import { afterEach, describe, expect, it } from 'vitest'
2
+ import { mount, VueWrapper } from '@vue/test-utils'
3
+ import { nextTick } from 'vue'
4
+ import Delete from '../components/Delete.vue'
5
+
6
+ let wrapper: VueWrapper | undefined
7
+
8
+ const modal = () => document.body.querySelector('.modal')
9
+
10
+ describe('TablerDelete', () => {
11
+ afterEach(() => {
12
+ wrapper?.unmount()
13
+ wrapper = undefined
14
+ })
15
+
16
+ it('opens the confirmation from its own trigger', async () => {
17
+ wrapper = mount(Delete, { attachTo: document.body })
18
+
19
+ expect(modal()).toBeNull()
20
+
21
+ await wrapper.find('button').trigger('click')
22
+
23
+ expect(modal()).not.toBeNull()
24
+ expect(wrapper.emitted('update:open')).toEqual([[true]])
25
+ })
26
+
27
+ it('renders no trigger with displaytype none and follows v-model:open', async () => {
28
+ wrapper = mount(Delete, {
29
+ props: { displaytype: 'none', open: false },
30
+ attachTo: document.body,
31
+ })
32
+
33
+ expect(wrapper.find('button').exists()).toBe(false)
34
+ expect(modal()).toBeNull()
35
+
36
+ await wrapper.setProps({ open: true })
37
+ expect(modal()).not.toBeNull()
38
+
39
+ ;(modal()?.querySelector('.btn-danger') as HTMLElement).click()
40
+ await nextTick()
41
+
42
+ expect(wrapper.emitted('delete')).toHaveLength(1)
43
+ expect(modal()?.querySelector('.btn-danger svg')).toBeNull()
44
+
45
+ await wrapper.setProps({ open: false })
46
+ expect(modal()).toBeNull()
47
+
48
+ await wrapper.setProps({ open: true })
49
+ expect(modal()?.querySelector('.btn-danger svg')).not.toBeNull()
50
+ })
51
+
52
+ it('requests close from the dismiss button', async () => {
53
+ wrapper = mount(Delete, {
54
+ props: { displaytype: 'none', open: true },
55
+ attachTo: document.body,
56
+ })
57
+
58
+ ;(modal()?.querySelector('.btn-close') as HTMLElement).click()
59
+ await nextTick()
60
+
61
+ expect(wrapper.emitted('update:open')).toEqual([[false]])
62
+ })
63
+ })
@@ -0,0 +1,78 @@
1
+ import { afterEach, describe, expect, it } from 'vitest'
2
+ import { mount, VueWrapper } from '@vue/test-utils'
3
+ import { nextTick } from 'vue'
4
+ import Dropdown from '../components/Dropdown.vue'
5
+
6
+ let wrapper: VueWrapper | undefined
7
+
8
+ const mountDropdown = async () => {
9
+ wrapper = mount(Dropdown, {
10
+ slots: {
11
+ default: '<button class="trigger">Open</button>',
12
+ dropdown: '<li><input class="search" /></li>',
13
+ },
14
+ attachTo: document.body,
15
+ })
16
+
17
+ await wrapper.find('.trigger').trigger('click')
18
+ await nextTick()
19
+
20
+ return wrapper
21
+ }
22
+
23
+ const menu = () => document.body.querySelector('.tabler-dropdown__menu')
24
+
25
+ describe('TablerDropdown', () => {
26
+ afterEach(() => {
27
+ wrapper?.unmount()
28
+ wrapper = undefined
29
+ })
30
+
31
+ it('teleports the menu to body when opened', async () => {
32
+ await mountDropdown()
33
+ expect(menu()).not.toBeNull()
34
+ })
35
+
36
+ it('closes on Escape from inside the menu without the event reaching document', async () => {
37
+ await mountDropdown()
38
+
39
+ let reachedDocument = false
40
+ const listener = () => { reachedDocument = true }
41
+ document.addEventListener('keydown', listener)
42
+
43
+ const input = menu()?.querySelector('.search') as HTMLInputElement
44
+ input.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape', bubbles: true }))
45
+ await nextTick()
46
+
47
+ document.removeEventListener('keydown', listener)
48
+
49
+ expect(reachedDocument).toBe(false)
50
+ expect(menu()).toBeNull()
51
+ })
52
+
53
+ it('keeps arrow keys inside the menu open and away from document', async () => {
54
+ await mountDropdown()
55
+
56
+ let reachedDocument = false
57
+ const listener = () => { reachedDocument = true }
58
+ document.addEventListener('keydown', listener)
59
+
60
+ const input = menu()?.querySelector('.search') as HTMLInputElement
61
+ input.dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowDown', bubbles: true }))
62
+ await nextTick()
63
+
64
+ document.removeEventListener('keydown', listener)
65
+
66
+ expect(reachedDocument).toBe(false)
67
+ expect(menu()).not.toBeNull()
68
+ })
69
+
70
+ it('still closes on Escape pressed outside the menu', async () => {
71
+ await mountDropdown()
72
+
73
+ document.body.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape', bubbles: true }))
74
+ await nextTick()
75
+
76
+ expect(menu()).toBeNull()
77
+ })
78
+ })
@@ -63,4 +63,31 @@ describe('TablerIconButton', () => {
63
63
  expect(iconButtonSource).toContain('border-color: color-mix(in srgb, var(--tblr-light) 30%, transparent);')
64
64
  expect(iconButtonSource).toContain('background: color-mix(in srgb, var(--tblr-light) 12%, transparent);')
65
65
  })
66
+
67
+ it('omits aria-pressed unless used as a toggle', () => {
68
+ const plain = mount(IconButton, { props: { title: 'Toggle Panel' } })
69
+ expect(plain.get('div').attributes('aria-pressed')).toBeUndefined()
70
+
71
+ const off = mount(IconButton, { props: { title: 'Toggle Panel', active: false } })
72
+ expect(off.get('div').attributes('aria-pressed')).toBe('false')
73
+ expect(off.get('div').classes()).toContain('custom-hover')
74
+ expect(off.get('div').classes()).not.toContain('icon-button-active')
75
+ })
76
+
77
+ it('fills with the primary color when active', () => {
78
+ const wrapper = mount(IconButton, { props: { title: 'Toggle Panel', active: true } })
79
+
80
+ expect(wrapper.get('div').attributes('aria-pressed')).toBe('true')
81
+ expect(wrapper.get('div').classes()).toContain('icon-button-active')
82
+ expect(wrapper.get('div').classes()).not.toContain('custom-hover')
83
+ expect(iconButtonSource).toContain('background: var(--tblr-primary);')
84
+ })
85
+
86
+ it('draws a button outline when bordered', () => {
87
+ const wrapper = mount(IconButton, { props: { title: 'Toggle Panel', bordered: true } })
88
+
89
+ expect(wrapper.get('div').classes()).toContain('icon-button-bordered')
90
+ expect(wrapper.get('div').classes()).toContain('custom-hover')
91
+ expect(iconButtonSource).toContain('border: var(--tblr-border-width) solid var(--tblr-border-color);')
92
+ })
66
93
  })