@conduction/nextcloud-vue 0.1.0-beta.1 → 0.1.0-beta.2

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.
Files changed (54) hide show
  1. package/README.md +226 -0
  2. package/dist/nextcloud-vue.cjs.js +7039 -2409
  3. package/dist/nextcloud-vue.cjs.js.map +1 -1
  4. package/dist/nextcloud-vue.css +237 -52
  5. package/dist/nextcloud-vue.esm.js +7012 -2386
  6. package/dist/nextcloud-vue.esm.js.map +1 -1
  7. package/package.json +2 -4
  8. package/src/components/CnActionsBar/CnActionsBar.vue +225 -0
  9. package/src/components/CnActionsBar/index.js +1 -0
  10. package/src/components/CnCopyDialog/CnCopyDialog.vue +250 -0
  11. package/src/components/CnCopyDialog/index.js +1 -0
  12. package/src/components/CnDataTable/CnDataTable.vue +0 -5
  13. package/src/components/CnDeleteDialog/CnDeleteDialog.vue +170 -0
  14. package/src/components/CnDeleteDialog/index.js +1 -0
  15. package/src/components/CnFormDialog/CnFormDialog.vue +629 -0
  16. package/src/components/CnFormDialog/index.js +1 -0
  17. package/src/components/CnIcon/CnIcon.vue +89 -0
  18. package/src/components/CnIcon/index.js +1 -0
  19. package/src/components/CnIndexPage/CnIndexPage.vue +434 -300
  20. package/src/components/CnIndexSidebar/CnIndexSidebar.vue +484 -0
  21. package/src/components/CnIndexSidebar/index.js +1 -0
  22. package/src/components/CnPageHeader/CnPageHeader.vue +57 -0
  23. package/src/components/CnPageHeader/index.js +1 -0
  24. package/src/components/CnRegisterMapping/CnRegisterMapping.vue +792 -0
  25. package/src/components/CnRegisterMapping/index.js +1 -0
  26. package/src/components/index.js +8 -4
  27. package/src/constants/metadata.js +30 -0
  28. package/src/css/actions-bar.css +48 -0
  29. package/src/css/badge.css +4 -4
  30. package/src/css/card.css +23 -23
  31. package/src/css/detail.css +13 -13
  32. package/src/css/index-page.css +32 -0
  33. package/src/css/index-sidebar.css +187 -0
  34. package/src/css/index.css +4 -0
  35. package/src/css/layout.css +14 -14
  36. package/src/css/page-header.css +33 -0
  37. package/src/css/pagination.css +12 -12
  38. package/src/css/table.css +21 -22
  39. package/src/css/utilities.css +2 -2
  40. package/src/index.js +11 -8
  41. package/src/store/plugins/index.js +1 -0
  42. package/src/store/plugins/registerMapping.js +185 -0
  43. package/src/store/useObjectStore.js +122 -61
  44. package/src/utils/headers.js +7 -1
  45. package/src/utils/index.js +1 -1
  46. package/src/utils/schema.js +133 -1
  47. package/src/components/CnDetailViewLayout/CnDetailViewLayout.vue +0 -88
  48. package/src/components/CnDetailViewLayout/index.js +0 -1
  49. package/src/components/CnEmptyState/CnEmptyState.vue +0 -78
  50. package/src/components/CnEmptyState/index.js +0 -1
  51. package/src/components/CnListViewLayout/CnListViewLayout.vue +0 -80
  52. package/src/components/CnListViewLayout/index.js +0 -1
  53. package/src/components/CnViewModeToggle/CnViewModeToggle.vue +0 -77
  54. package/src/components/CnViewModeToggle/index.js +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@conduction/nextcloud-vue",
3
- "version": "0.1.0-beta.1",
3
+ "version": "0.1.0-beta.2",
4
4
  "description": "Shared Vue component library for Conduction Nextcloud apps — complements @nextcloud/vue with higher-level components, OpenRegister integration, and NL Design System support",
5
5
  "license": "EUPL-1.2",
6
6
  "author": "Conduction B.V. <info@conduction.nl>",
@@ -12,9 +12,7 @@
12
12
  "dist/",
13
13
  "src/"
14
14
  ],
15
- "sideEffects": [
16
- "*.css"
17
- ],
15
+ "sideEffects": true,
18
16
  "scripts": {
19
17
  "build": "rollup -c",
20
18
  "dev": "rollup -c -w",
@@ -0,0 +1,225 @@
1
+ <template>
2
+ <div class="cn-actions-bar">
3
+ <div class="cn-actions-bar__info">
4
+ <span v-if="pagination && pagination.total > 0" class="cn-actions-bar__count">
5
+ {{ countText }}
6
+ </span>
7
+ </div>
8
+ <div class="cn-actions-bar__actions">
9
+ <!-- View mode toggle (Cards / Table) -->
10
+ <div v-if="showViewToggle" class="cn-actions-bar__view-toggle">
11
+ <NcCheckboxRadioSwitch
12
+ :checked="viewMode"
13
+ :button-variant="true"
14
+ value="cards"
15
+ name="cn_view_mode"
16
+ type="radio"
17
+ button-variant-grouped="horizontal"
18
+ @update:checked="$emit('view-mode-change', 'cards')">
19
+ Cards
20
+ </NcCheckboxRadioSwitch>
21
+ <NcCheckboxRadioSwitch
22
+ :checked="viewMode"
23
+ :button-variant="true"
24
+ value="table"
25
+ name="cn_view_mode"
26
+ type="radio"
27
+ button-variant-grouped="horizontal"
28
+ @update:checked="$emit('view-mode-change', 'table')">
29
+ Table
30
+ </NcCheckboxRadioSwitch>
31
+ </div>
32
+
33
+ <!-- Add button (primary) -->
34
+ <NcButton type="primary" @click="$emit('add')">
35
+ <template #icon>
36
+ <CnIcon v-if="addIcon" :name="addIcon" :size="20" />
37
+ <Plus v-else :size="20" />
38
+ </template>
39
+ {{ addLabel }}
40
+ </NcButton>
41
+
42
+ <!-- Actions menu (Refresh, Import, Export, mass actions) -->
43
+ <NcActions
44
+ :force-name="true"
45
+ :inline="0"
46
+ menu-name="Actions">
47
+ <NcActionButton @click="$emit('refresh')">
48
+ <template #icon>
49
+ <Refresh :size="20" />
50
+ </template>
51
+ Refresh
52
+ </NcActionButton>
53
+
54
+ <!-- Custom primary action items (overflow) -->
55
+ <slot name="action-items" />
56
+
57
+ <!-- Separator between primary and mass actions -->
58
+ <NcActionSeparator v-if="selectable" />
59
+
60
+ <!-- Mass actions (overflow) -->
61
+ <NcActionButton
62
+ v-if="showMassImport"
63
+ @click="$emit('show-import')">
64
+ <template #icon>
65
+ <Import :size="20" />
66
+ </template>
67
+ Import
68
+ </NcActionButton>
69
+ <NcActionButton
70
+ v-if="showMassExport"
71
+ @click="$emit('show-export')">
72
+ <template #icon>
73
+ <Export :size="20" />
74
+ </template>
75
+ Export
76
+ </NcActionButton>
77
+ <NcActionButton
78
+ v-if="showMassCopy"
79
+ :disabled="selectedIds.length < 1"
80
+ :title="selectedIds.length < 1 ? 'Select 1 or more items to copy' : ''"
81
+ @click="$emit('show-copy')">
82
+ <template #icon>
83
+ <ContentCopy :size="20" />
84
+ </template>
85
+ Copy selected
86
+ </NcActionButton>
87
+ <NcActionButton
88
+ v-if="showMassDelete"
89
+ :disabled="selectedIds.length < 1"
90
+ :title="selectedIds.length < 1 ? 'Select 1 or more items to delete' : ''"
91
+ @click="$emit('show-delete')">
92
+ <template #icon>
93
+ <TrashCanOutline :size="20" />
94
+ </template>
95
+ Delete selected
96
+ </NcActionButton>
97
+
98
+ <!-- Custom mass actions (overflow) -->
99
+ <slot name="mass-actions" :count="selectedIds.length" :selected-ids="selectedIds" />
100
+ </NcActions>
101
+
102
+ <slot name="header-actions" />
103
+ </div>
104
+ </div>
105
+ </template>
106
+
107
+ <script>
108
+ import { NcActions, NcActionButton, NcActionSeparator, NcButton, NcCheckboxRadioSwitch } from '@nextcloud/vue'
109
+ import { CnIcon } from '../CnIcon/index.js'
110
+ import Plus from 'vue-material-design-icons/Plus.vue'
111
+ import Refresh from 'vue-material-design-icons/Refresh.vue'
112
+ import ContentCopy from 'vue-material-design-icons/ContentCopy.vue'
113
+ import TrashCanOutline from 'vue-material-design-icons/TrashCanOutline.vue'
114
+ import Import from 'vue-material-design-icons/Import.vue'
115
+ import Export from 'vue-material-design-icons/Export.vue'
116
+
117
+ /**
118
+ * CnActionsBar — Reusable actions toolbar with count, mass actions, and primary actions.
119
+ *
120
+ * @example
121
+ * <CnActionsBar
122
+ * :pagination="pagination"
123
+ * :object-count="items.length"
124
+ * add-label="Add Client"
125
+ * add-icon="AccountGroup"
126
+ * @add="createNew"
127
+ * @refresh="reload" />
128
+ */
129
+ export default {
130
+ name: 'CnActionsBar',
131
+
132
+ components: {
133
+ NcActions,
134
+ NcActionButton,
135
+ NcActionSeparator,
136
+ NcButton,
137
+ NcCheckboxRadioSwitch,
138
+ CnIcon,
139
+ Plus,
140
+ Refresh,
141
+ ContentCopy,
142
+ TrashCanOutline,
143
+ Import,
144
+ Export,
145
+ },
146
+
147
+ props: {
148
+ /** Pagination state: { total, page, pages, limit } */
149
+ pagination: {
150
+ type: Object,
151
+ default: null,
152
+ },
153
+ /** Number of currently visible objects (for "Showing X of Y") */
154
+ objectCount: {
155
+ type: Number,
156
+ default: 0,
157
+ },
158
+ /** Whether rows/cards can be selected */
159
+ selectable: {
160
+ type: Boolean,
161
+ default: true,
162
+ },
163
+ /** Currently selected IDs */
164
+ selectedIds: {
165
+ type: Array,
166
+ default: () => [],
167
+ },
168
+ /** Label for the Add button */
169
+ addLabel: {
170
+ type: String,
171
+ default: 'Add',
172
+ },
173
+ /** MDI icon name for the Add button (e.g. 'AccountGroup'). Falls back to Plus icon. */
174
+ addIcon: {
175
+ type: String,
176
+ default: '',
177
+ },
178
+ /** How many action buttons to show inline (rest go in overflow dropdown) */
179
+ inlineActionCount: {
180
+ type: Number,
181
+ default: 2,
182
+ },
183
+ /** Whether to show the built-in mass Import action */
184
+ showMassImport: {
185
+ type: Boolean,
186
+ default: true,
187
+ },
188
+ /** Whether to show the built-in mass Export action */
189
+ showMassExport: {
190
+ type: Boolean,
191
+ default: true,
192
+ },
193
+ /** Whether to show the built-in mass Copy action */
194
+ showMassCopy: {
195
+ type: Boolean,
196
+ default: true,
197
+ },
198
+ /** Whether to show the built-in mass Delete action */
199
+ showMassDelete: {
200
+ type: Boolean,
201
+ default: true,
202
+ },
203
+ /** Current view mode: 'table' or 'cards' */
204
+ viewMode: {
205
+ type: String,
206
+ default: 'table',
207
+ validator: (v) => ['table', 'cards'].includes(v),
208
+ },
209
+ /** Whether to show the Cards/Table view toggle */
210
+ showViewToggle: {
211
+ type: Boolean,
212
+ default: true,
213
+ },
214
+ },
215
+
216
+ computed: {
217
+ countText() {
218
+ if (!this.pagination) return ''
219
+ return `Showing ${this.objectCount} of ${this.pagination.total}`
220
+ },
221
+ },
222
+ }
223
+ </script>
224
+
225
+ <!-- Styles in css/actions-bar.css -->
@@ -0,0 +1 @@
1
+ export { default as CnActionsBar } from './CnActionsBar.vue'
@@ -0,0 +1,250 @@
1
+ <template>
2
+ <NcDialog
3
+ :name="dialogTitle"
4
+ size="small"
5
+ :can-close="!loading"
6
+ @closing="$emit('close')">
7
+ <!-- Result phase -->
8
+ <div v-if="result !== null" class="cn-copy__result">
9
+ <NcNoteCard v-if="result.success" type="success">
10
+ {{ successText }}
11
+ </NcNoteCard>
12
+ <NcNoteCard v-if="result.error" type="error">
13
+ {{ result.error }}
14
+ </NcNoteCard>
15
+ </div>
16
+
17
+ <!-- Form phase -->
18
+ <div v-else class="cn-copy__form">
19
+ <div class="cn-copy__pattern">
20
+ <label for="cn-copy-pattern">{{ patternLabel }}</label>
21
+ <NcSelect
22
+ input-id="cn-copy-pattern"
23
+ :options="patternOptions"
24
+ :value="selectedPattern"
25
+ :clearable="false"
26
+ @input="selectedPattern = $event" />
27
+ </div>
28
+
29
+ <div class="cn-copy__preview">
30
+ <div class="cn-copy__preview-row">
31
+ <span class="cn-copy__preview-original">{{ itemName }}</span>
32
+ <span class="cn-copy__preview-arrow">&rarr;</span>
33
+ <span class="cn-copy__preview-new">{{ newName }}</span>
34
+ </div>
35
+ </div>
36
+ </div>
37
+
38
+ <template #actions>
39
+ <NcButton @click="$emit('close')">
40
+ {{ result !== null ? closeLabel : cancelLabel }}
41
+ </NcButton>
42
+ <NcButton
43
+ v-if="result === null"
44
+ type="primary"
45
+ :disabled="loading"
46
+ @click="executeCopy">
47
+ <template #icon>
48
+ <NcLoadingIcon v-if="loading" :size="20" />
49
+ <ContentCopy v-else :size="20" />
50
+ </template>
51
+ {{ confirmLabel }}
52
+ </NcButton>
53
+ </template>
54
+ </NcDialog>
55
+ </template>
56
+
57
+ <script>
58
+ import { NcDialog, NcButton, NcNoteCard, NcLoadingIcon, NcSelect } from '@nextcloud/vue'
59
+ import ContentCopy from 'vue-material-design-icons/ContentCopy.vue'
60
+
61
+ /**
62
+ * CnCopyDialog — Single-item copy confirmation dialog with naming pattern.
63
+ *
64
+ * Two-phase UI: form (with name preview) then result. The dialog does NOT
65
+ * perform the copy itself — it emits a `confirm` event with the item ID
66
+ * and the new name. The parent performs the actual API call and calls
67
+ * `setResult()` via a ref.
68
+ *
69
+ * @example
70
+ * <CnCopyDialog
71
+ * v-if="showCopyDialog"
72
+ * ref="copyDialog"
73
+ * :item="itemToCopy"
74
+ * @confirm="onCopyConfirm"
75
+ * @close="showCopyDialog = false" />
76
+ *
77
+ * // In methods:
78
+ * async onCopyConfirm({ id, newName }) {
79
+ * try {
80
+ * await store.copyItem(id, { title: newName })
81
+ * this.$refs.copyDialog.setResult({ success: true })
82
+ * } catch (e) {
83
+ * this.$refs.copyDialog.setResult({ error: e.message })
84
+ * }
85
+ * }
86
+ */
87
+ export default {
88
+ name: 'CnCopyDialog',
89
+
90
+ components: {
91
+ NcDialog,
92
+ NcButton,
93
+ NcNoteCard,
94
+ NcLoadingIcon,
95
+ NcSelect,
96
+ ContentCopy,
97
+ },
98
+
99
+ props: {
100
+ /** The item to copy. Must have an `id` property. */
101
+ item: {
102
+ type: Object,
103
+ required: true,
104
+ },
105
+ /** Property name used for display (e.g., 'title', 'name') */
106
+ nameField: {
107
+ type: String,
108
+ default: 'title',
109
+ },
110
+ /** Dialog title */
111
+ dialogTitle: {
112
+ type: String,
113
+ default: 'Copy Item',
114
+ },
115
+ /** Label for the naming pattern selector */
116
+ patternLabel: {
117
+ type: String,
118
+ default: 'Naming pattern',
119
+ },
120
+ /** Success message */
121
+ successText: {
122
+ type: String,
123
+ default: 'Item successfully copied.',
124
+ },
125
+ cancelLabel: { type: String, default: 'Cancel' },
126
+ closeLabel: { type: String, default: 'Close' },
127
+ confirmLabel: { type: String, default: 'Copy' },
128
+ },
129
+
130
+ data() {
131
+ return {
132
+ loading: false,
133
+ result: null,
134
+ closeTimeout: null,
135
+ selectedPattern: { id: 'copy-of', label: 'Copy of {name}' },
136
+ }
137
+ },
138
+
139
+ computed: {
140
+ itemName() {
141
+ return this.item[this.nameField] || this.item.name || this.item.title || this.item.id
142
+ },
143
+
144
+ patternOptions() {
145
+ return [
146
+ { id: 'copy-of', label: 'Copy of {name}' },
147
+ { id: 'name-copy', label: '{name} - Copy' },
148
+ { id: 'name-parens', label: '{name} (Copy)' },
149
+ ]
150
+ },
151
+
152
+ newName() {
153
+ return this.applyPattern(this.itemName, this.selectedPattern.id)
154
+ },
155
+ },
156
+
157
+ beforeDestroy() {
158
+ if (this.closeTimeout) clearTimeout(this.closeTimeout)
159
+ },
160
+
161
+ /**
162
+ * @event confirm Emitted when the user confirms copying. Payload: `{ id, newName }`.
163
+ * @event close Emitted when the dialog should be closed (cancel, close button, or auto-close after success).
164
+ */
165
+
166
+ methods: {
167
+ applyPattern(name, patternId) {
168
+ switch (patternId) {
169
+ case 'copy-of':
170
+ return `Copy of ${name}`
171
+ case 'name-copy':
172
+ return `${name} - Copy`
173
+ case 'name-parens':
174
+ return `${name} (Copy)`
175
+ default:
176
+ return `Copy of ${name}`
177
+ }
178
+ },
179
+
180
+ executeCopy() {
181
+ this.loading = true
182
+ this.$emit('confirm', {
183
+ id: this.item.id,
184
+ newName: this.newName,
185
+ })
186
+ },
187
+
188
+ /**
189
+ * Set the result of the copy operation. Call this from the parent
190
+ * after the API call completes.
191
+ *
192
+ * @param {{ success?: boolean, error?: string }} resultData
193
+ * @public
194
+ */
195
+ setResult(resultData) {
196
+ this.loading = false
197
+ this.result = resultData
198
+ if (resultData.success) {
199
+ this.closeTimeout = setTimeout(() => {
200
+ this.$emit('close')
201
+ }, 2000)
202
+ }
203
+ },
204
+ },
205
+ }
206
+ </script>
207
+
208
+ <style scoped>
209
+ .cn-copy__pattern {
210
+ margin-bottom: 16px;
211
+ }
212
+
213
+ .cn-copy__pattern label {
214
+ display: block;
215
+ font-weight: 600;
216
+ margin-bottom: 4px;
217
+ }
218
+
219
+ .cn-copy__preview {
220
+ margin-top: 12px;
221
+ }
222
+
223
+ .cn-copy__preview-row {
224
+ display: flex;
225
+ align-items: center;
226
+ gap: 8px;
227
+ padding: 8px 12px;
228
+ background-color: var(--color-background-hover);
229
+ border-radius: var(--border-radius);
230
+ }
231
+
232
+ .cn-copy__preview-original {
233
+ color: var(--color-text-maxcontrast);
234
+ overflow: hidden;
235
+ text-overflow: ellipsis;
236
+ white-space: nowrap;
237
+ }
238
+
239
+ .cn-copy__preview-arrow {
240
+ flex-shrink: 0;
241
+ color: var(--color-text-maxcontrast);
242
+ }
243
+
244
+ .cn-copy__preview-new {
245
+ font-weight: 500;
246
+ overflow: hidden;
247
+ text-overflow: ellipsis;
248
+ white-space: nowrap;
249
+ }
250
+ </style>
@@ -0,0 +1 @@
1
+ export { default as CnCopyDialog } from './CnCopyDialog.vue'
@@ -118,11 +118,6 @@ import { columnsFromSchema } from '../../utils/schema.js'
118
118
  * (dates, booleans, UUIDs, enums, etc.). Scoped slots still override individual
119
119
  * columns when needed.
120
120
  *
121
- * NL Design tokens used:
122
- * - --nldesign-component-table-header-background-color
123
- * - --nldesign-component-table-row-hover-background-color
124
- * - --nldesign-component-table-border-color
125
- *
126
121
  * @example Manual columns (backwards compatible)
127
122
  * <CnDataTable
128
123
  * :columns="[
@@ -0,0 +1,170 @@
1
+ <template>
2
+ <NcDialog
3
+ :name="dialogTitle"
4
+ size="small"
5
+ :can-close="!loading"
6
+ @closing="$emit('close')">
7
+ <!-- Result phase -->
8
+ <div v-if="result !== null" class="cn-delete__result">
9
+ <NcNoteCard v-if="result.success" type="success">
10
+ {{ successText }}
11
+ </NcNoteCard>
12
+ <NcNoteCard v-if="result.error" type="error">
13
+ {{ result.error }}
14
+ </NcNoteCard>
15
+ </div>
16
+
17
+ <!-- Confirm phase -->
18
+ <div v-else class="cn-delete__confirm">
19
+ <NcNoteCard type="warning">
20
+ {{ resolvedWarningText }}
21
+ </NcNoteCard>
22
+ </div>
23
+
24
+ <template #actions>
25
+ <NcButton @click="$emit('close')">
26
+ {{ result !== null ? closeLabel : cancelLabel }}
27
+ </NcButton>
28
+ <NcButton
29
+ v-if="result === null"
30
+ type="error"
31
+ :disabled="loading"
32
+ @click="executeDelete">
33
+ <template #icon>
34
+ <NcLoadingIcon v-if="loading" :size="20" />
35
+ <TrashCanOutline v-else :size="20" />
36
+ </template>
37
+ {{ confirmLabel }}
38
+ </NcButton>
39
+ </template>
40
+ </NcDialog>
41
+ </template>
42
+
43
+ <script>
44
+ import { NcDialog, NcButton, NcNoteCard, NcLoadingIcon } from '@nextcloud/vue'
45
+ import TrashCanOutline from 'vue-material-design-icons/TrashCanOutline.vue'
46
+
47
+ /**
48
+ * CnDeleteDialog — Single-item delete confirmation dialog.
49
+ *
50
+ * Two-phase UI: confirm then result. The dialog does NOT perform the delete
51
+ * itself — it emits a `confirm` event with the item ID. The parent performs
52
+ * the actual API call and calls `setResult()` via a ref.
53
+ *
54
+ * @example
55
+ * <CnDeleteDialog
56
+ * v-if="showDeleteDialog"
57
+ * ref="deleteDialog"
58
+ * :item="itemToDelete"
59
+ * @confirm="onDeleteConfirm"
60
+ * @close="showDeleteDialog = false" />
61
+ *
62
+ * // In methods:
63
+ * async onDeleteConfirm(id) {
64
+ * try {
65
+ * await store.deleteItem(id)
66
+ * this.$refs.deleteDialog.setResult({ success: true })
67
+ * } catch (e) {
68
+ * this.$refs.deleteDialog.setResult({ error: e.message })
69
+ * }
70
+ * }
71
+ */
72
+ export default {
73
+ name: 'CnDeleteDialog',
74
+
75
+ components: {
76
+ NcDialog,
77
+ NcButton,
78
+ NcNoteCard,
79
+ NcLoadingIcon,
80
+ TrashCanOutline,
81
+ },
82
+
83
+ props: {
84
+ /** The item to delete. Must have an `id` property. */
85
+ item: {
86
+ type: Object,
87
+ required: true,
88
+ },
89
+ /** Property name used for display (e.g., 'title', 'name') */
90
+ nameField: {
91
+ type: String,
92
+ default: 'title',
93
+ },
94
+ /** Dialog title */
95
+ dialogTitle: {
96
+ type: String,
97
+ default: 'Delete Item',
98
+ },
99
+ /** Warning text. Use `{name}` as placeholder for the item name. */
100
+ warningText: {
101
+ type: String,
102
+ default: 'Are you sure you want to permanently delete "{name}"? This action cannot be undone.',
103
+ },
104
+ /** Success message */
105
+ successText: {
106
+ type: String,
107
+ default: 'Item successfully deleted.',
108
+ },
109
+ cancelLabel: { type: String, default: 'Cancel' },
110
+ closeLabel: { type: String, default: 'Close' },
111
+ confirmLabel: { type: String, default: 'Delete' },
112
+ },
113
+
114
+ data() {
115
+ return {
116
+ loading: false,
117
+ result: null,
118
+ closeTimeout: null,
119
+ }
120
+ },
121
+
122
+ computed: {
123
+ itemName() {
124
+ return this.item[this.nameField] || this.item.name || this.item.title || this.item.id
125
+ },
126
+ resolvedWarningText() {
127
+ return this.warningText.replace('{name}', this.itemName)
128
+ },
129
+ },
130
+
131
+ beforeDestroy() {
132
+ if (this.closeTimeout) clearTimeout(this.closeTimeout)
133
+ },
134
+
135
+ /**
136
+ * @event confirm Emitted when the user confirms deletion. Payload: the item ID.
137
+ * @event close Emitted when the dialog should be closed (cancel, close button, or auto-close after success).
138
+ */
139
+
140
+ methods: {
141
+ executeDelete() {
142
+ this.loading = true
143
+ this.$emit('confirm', this.item.id)
144
+ },
145
+
146
+ /**
147
+ * Set the result of the delete operation. Call this from the parent
148
+ * after the API call completes.
149
+ *
150
+ * @param {{ success?: boolean, error?: string }} resultData
151
+ * @public
152
+ */
153
+ setResult(resultData) {
154
+ this.loading = false
155
+ this.result = resultData
156
+ if (resultData.success) {
157
+ this.closeTimeout = setTimeout(() => {
158
+ this.$emit('close')
159
+ }, 2000)
160
+ }
161
+ },
162
+ },
163
+ }
164
+ </script>
165
+
166
+ <style scoped>
167
+ .cn-delete__confirm {
168
+ padding: 4px 0;
169
+ }
170
+ </style>
@@ -0,0 +1 @@
1
+ export { default as CnDeleteDialog } from './CnDeleteDialog.vue'