@tak-ps/vue-tabler 5.10.0 → 5.11.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 +6 -0
- package/components/Badge.vue +1 -1
- package/components/Dropdown.vue +10 -0
- package/components/IconButton.vue +36 -2
- package/package.json +2 -2
- package/test/Badge.spec.ts +1 -1
- package/test/Dropdown.spec.ts +78 -0
- package/test/IconButton.spec.ts +27 -0
package/CHANGELOG.md
CHANGED
|
@@ -12,6 +12,12 @@
|
|
|
12
12
|
|
|
13
13
|
### Pending
|
|
14
14
|
|
|
15
|
+
### v5.11.0 - 2026-11-23
|
|
16
|
+
|
|
17
|
+
- :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
|
|
18
|
+
- :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)
|
|
19
|
+
- :bug: `TablerBadge` text now defaults to `var(--tblr-body-color)` instead of white so badges stay legible in light mode
|
|
20
|
+
|
|
15
21
|
### v5.10.0 - 2026-10-18
|
|
16
22
|
|
|
17
23
|
- :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
|
package/components/Badge.vue
CHANGED
|
@@ -27,7 +27,7 @@ const props = withDefaults(defineProps<BadgeProps>(), {
|
|
|
27
27
|
borderColor: undefined,
|
|
28
28
|
borderStyle: 'solid',
|
|
29
29
|
borderWidth: '1px',
|
|
30
|
-
textColor: '
|
|
30
|
+
textColor: 'var(--tblr-body-color)',
|
|
31
31
|
hoverBackgroundColor: undefined,
|
|
32
32
|
hoverBorderColor: undefined,
|
|
33
33
|
hoverBorderStyle: undefined,
|
package/components/Dropdown.vue
CHANGED
|
@@ -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.
|
|
4
|
+
"version": "5.11.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": "^
|
|
52
|
+
"jsdom": "^31.0.0",
|
|
53
53
|
"typescript": "^6.0.0",
|
|
54
54
|
"typescript-eslint": "^8.36.0",
|
|
55
55
|
"vite": "^8.0.0",
|
package/test/Badge.spec.ts
CHANGED
|
@@ -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('
|
|
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,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
|
+
})
|
package/test/IconButton.spec.ts
CHANGED
|
@@ -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
|
})
|