@tak-ps/vue-tabler 5.11.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 +7 -0
- package/components/Delete.vue +13 -8
- package/package.json +1 -1
- package/test/Delete.spec.ts +63 -0
package/CHANGELOG.md
CHANGED
|
@@ -12,6 +12,13 @@
|
|
|
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
|
+
|
|
15
22
|
### v5.11.0 - 2026-11-23
|
|
16
23
|
|
|
17
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
|
package/components/Delete.vue
CHANGED
|
@@ -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='
|
|
43
|
+
<TablerModal v-if='open'>
|
|
44
44
|
<button
|
|
45
45
|
type='button'
|
|
46
46
|
class='btn-close'
|
|
47
47
|
aria-label='Close'
|
|
48
|
-
@click='
|
|
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
|
-
|
|
132
|
-
modal.value = true;
|
|
137
|
+
open.value = true;
|
|
133
138
|
}
|
|
134
139
|
|
|
135
140
|
const deleting = () => {
|
package/package.json
CHANGED
|
@@ -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
|
+
})
|