@dataloop-ai/components 0.20.177 → 0.20.178-alert.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/package.json
CHANGED
|
@@ -1,42 +1,76 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div
|
|
3
|
-
v-if="show"
|
|
4
|
-
:id="uuid"
|
|
5
|
-
ref="rootRef"
|
|
6
|
-
class="root"
|
|
7
|
-
:style="rootStyle"
|
|
8
|
-
data-test="root"
|
|
9
|
-
>
|
|
10
|
-
<div>
|
|
11
|
-
<dl-icon
|
|
12
|
-
data-test="icon"
|
|
13
|
-
:style="iconStyle"
|
|
14
|
-
:icon="icon"
|
|
15
|
-
:color="iconColor"
|
|
16
|
-
:size="iconSize"
|
|
17
|
-
/>
|
|
18
|
-
<span class="text" :style="textStyle">
|
|
19
|
-
<slot v-if="!text" />
|
|
20
|
-
<span v-else>
|
|
21
|
-
{{ text }}
|
|
22
|
-
</span>
|
|
23
|
-
</span>
|
|
24
|
-
</div>
|
|
2
|
+
<div>
|
|
25
3
|
<div
|
|
26
|
-
v-if="
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
4
|
+
v-if="show"
|
|
5
|
+
:id="uuid"
|
|
6
|
+
ref="rootRef"
|
|
7
|
+
class="root"
|
|
8
|
+
:style="rootStyle"
|
|
9
|
+
data-test="root"
|
|
30
10
|
>
|
|
31
|
-
<
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
11
|
+
<div>
|
|
12
|
+
<dl-icon
|
|
13
|
+
data-test="icon"
|
|
14
|
+
:style="iconStyle"
|
|
15
|
+
:icon="icon"
|
|
16
|
+
:color="iconColor"
|
|
17
|
+
:size="iconSize"
|
|
18
|
+
/>
|
|
19
|
+
<span class="text" :style="textStyle">
|
|
20
|
+
<slot v-if="!text" />
|
|
21
|
+
<span v-else>
|
|
22
|
+
{{ text }}
|
|
23
|
+
</span>
|
|
24
|
+
</span>
|
|
25
|
+
</div>
|
|
26
|
+
<div
|
|
27
|
+
v-if="closable"
|
|
28
|
+
class="close-button"
|
|
29
|
+
data-test="close-button"
|
|
30
|
+
:style="closeButtonStyle"
|
|
31
|
+
>
|
|
32
|
+
<dl-icon
|
|
33
|
+
class="close-button-icon"
|
|
34
|
+
data-test="close-button-icon"
|
|
35
|
+
icon="icon-dl-close"
|
|
36
|
+
color="dl-color-darker"
|
|
37
|
+
size="16px"
|
|
38
|
+
@click="handleClose"
|
|
39
|
+
/>
|
|
40
|
+
</div>
|
|
39
41
|
</div>
|
|
42
|
+
<dl-dialog-box
|
|
43
|
+
v-model="showConfirmDialog"
|
|
44
|
+
:width="400"
|
|
45
|
+
data-test="confirm-dialog"
|
|
46
|
+
>
|
|
47
|
+
<template #header>
|
|
48
|
+
<dl-dialog-box-header
|
|
49
|
+
:title="props.confirmCloseHeader"
|
|
50
|
+
:close-button="false"
|
|
51
|
+
/>
|
|
52
|
+
</template>
|
|
53
|
+
<template #body>
|
|
54
|
+
<p class="confirm-message">
|
|
55
|
+
{{ props.confirmCloseMessage }}
|
|
56
|
+
</p>
|
|
57
|
+
</template>
|
|
58
|
+
<template #footer>
|
|
59
|
+
<dl-dialog-box-footer>
|
|
60
|
+
<dl-button
|
|
61
|
+
outlined
|
|
62
|
+
label="Cancel"
|
|
63
|
+
data-test="cancel-button"
|
|
64
|
+
@click="handleCancelDismiss"
|
|
65
|
+
/>
|
|
66
|
+
<dl-button
|
|
67
|
+
label="Dismiss"
|
|
68
|
+
data-test="dismiss-button"
|
|
69
|
+
@click="handleConfirmDismiss"
|
|
70
|
+
/>
|
|
71
|
+
</dl-dialog-box-footer>
|
|
72
|
+
</template>
|
|
73
|
+
</dl-dialog-box>
|
|
40
74
|
</div>
|
|
41
75
|
</template>
|
|
42
76
|
|
|
@@ -54,6 +88,12 @@ import {
|
|
|
54
88
|
} from 'vue-demi'
|
|
55
89
|
import { getColor, includes } from '../../../utils'
|
|
56
90
|
import { DlIcon } from '../../essential'
|
|
91
|
+
import { DlButton } from '../DlButton'
|
|
92
|
+
import {
|
|
93
|
+
DlDialogBox,
|
|
94
|
+
DlDialogBoxHeader,
|
|
95
|
+
DlDialogBoxFooter
|
|
96
|
+
} from '../../compound/DlDialogBox'
|
|
57
97
|
import { DlAlertType } from './types'
|
|
58
98
|
|
|
59
99
|
const typeToIconMap: Record<DlAlertType, string> = {
|
|
@@ -80,7 +120,11 @@ const typeToBackgroundMap: Record<DlAlertType, string> = {
|
|
|
80
120
|
export default defineComponent({
|
|
81
121
|
name: 'DlAlert',
|
|
82
122
|
components: {
|
|
83
|
-
DlIcon
|
|
123
|
+
DlIcon,
|
|
124
|
+
DlButton,
|
|
125
|
+
DlDialogBox,
|
|
126
|
+
DlDialogBoxHeader,
|
|
127
|
+
DlDialogBoxFooter
|
|
84
128
|
},
|
|
85
129
|
model: {
|
|
86
130
|
prop: 'modelValue',
|
|
@@ -120,9 +164,21 @@ export default defineComponent({
|
|
|
120
164
|
padding: {
|
|
121
165
|
type: String,
|
|
122
166
|
default: null
|
|
167
|
+
},
|
|
168
|
+
confirmClose: {
|
|
169
|
+
type: Boolean,
|
|
170
|
+
default: false
|
|
171
|
+
},
|
|
172
|
+
confirmCloseHeader: {
|
|
173
|
+
type: String,
|
|
174
|
+
default: 'Are you sure?'
|
|
175
|
+
},
|
|
176
|
+
confirmCloseMessage: {
|
|
177
|
+
type: String,
|
|
178
|
+
default: ''
|
|
123
179
|
}
|
|
124
180
|
},
|
|
125
|
-
emits: ['update:model-value'],
|
|
181
|
+
emits: ['update:model-value', 'dismiss'],
|
|
126
182
|
setup(props, { emit }) {
|
|
127
183
|
const { padding, modelValue, type } = toRefs(props)
|
|
128
184
|
const show = ref(modelValue.value)
|
|
@@ -138,6 +194,7 @@ export default defineComponent({
|
|
|
138
194
|
const rootStyle = ref()
|
|
139
195
|
const iconStyle = ref()
|
|
140
196
|
const closeButtonStyle = ref()
|
|
197
|
+
const showConfirmDialog = ref(false)
|
|
141
198
|
|
|
142
199
|
onMounted(() => {
|
|
143
200
|
normalizeStyles(props.fluid)
|
|
@@ -166,9 +223,12 @@ export default defineComponent({
|
|
|
166
223
|
|
|
167
224
|
function normalizeStyles(fluid?: boolean) {
|
|
168
225
|
nextTick(() => {
|
|
169
|
-
const
|
|
170
|
-
|
|
171
|
-
|
|
226
|
+
const rootElement = (rootRef as Ref<HTMLElement | null>).value
|
|
227
|
+
if (!rootElement) {
|
|
228
|
+
return
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
const { height } = rootElement.getBoundingClientRect()
|
|
172
232
|
const iconS: Record<string, any> = {
|
|
173
233
|
display: 'flex'
|
|
174
234
|
}
|
|
@@ -199,10 +259,28 @@ export default defineComponent({
|
|
|
199
259
|
}
|
|
200
260
|
|
|
201
261
|
function handleClose() {
|
|
262
|
+
if (props.confirmClose) {
|
|
263
|
+
showConfirmDialog.value = true
|
|
264
|
+
} else {
|
|
265
|
+
closeAlert()
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
function closeAlert() {
|
|
202
270
|
show.value = false
|
|
203
271
|
emit('update:model-value', false)
|
|
204
272
|
}
|
|
205
273
|
|
|
274
|
+
function handleConfirmDismiss() {
|
|
275
|
+
showConfirmDialog.value = false
|
|
276
|
+
closeAlert()
|
|
277
|
+
emit('dismiss')
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
function handleCancelDismiss() {
|
|
281
|
+
showConfirmDialog.value = false
|
|
282
|
+
}
|
|
283
|
+
|
|
206
284
|
return {
|
|
207
285
|
uuid: `dl-alert-${v4()}`,
|
|
208
286
|
rootRef,
|
|
@@ -213,7 +291,11 @@ export default defineComponent({
|
|
|
213
291
|
iconStyle,
|
|
214
292
|
closeButtonStyle,
|
|
215
293
|
textStyle,
|
|
216
|
-
|
|
294
|
+
showConfirmDialog,
|
|
295
|
+
props,
|
|
296
|
+
handleClose,
|
|
297
|
+
handleConfirmDismiss,
|
|
298
|
+
handleCancelDismiss
|
|
217
299
|
}
|
|
218
300
|
},
|
|
219
301
|
template: 'dl-alert'
|
|
@@ -257,4 +339,11 @@ export default defineComponent({
|
|
|
257
339
|
cursor: pointer;
|
|
258
340
|
}
|
|
259
341
|
}
|
|
342
|
+
|
|
343
|
+
.confirm-message {
|
|
344
|
+
margin: 0;
|
|
345
|
+
color: var(--dl-color-darker);
|
|
346
|
+
font-size: var(--dl-font-size-body);
|
|
347
|
+
line-height: 1.5;
|
|
348
|
+
}
|
|
260
349
|
</style>
|
|
@@ -66,6 +66,42 @@
|
|
|
66
66
|
ratione cumque!
|
|
67
67
|
</DlAlert>
|
|
68
68
|
</div>
|
|
69
|
+
|
|
70
|
+
<div style="margin-top: 20px">
|
|
71
|
+
<h3 style="margin-bottom: 10px">Confirmation Dialog Examples</h3>
|
|
72
|
+
<DlAlert
|
|
73
|
+
type="warning"
|
|
74
|
+
:closable="true"
|
|
75
|
+
:confirm-close="true"
|
|
76
|
+
fluid
|
|
77
|
+
@dismiss="handleDismiss"
|
|
78
|
+
>
|
|
79
|
+
Click the X button to see the confirmation dialog before
|
|
80
|
+
closing.
|
|
81
|
+
</DlAlert>
|
|
82
|
+
<DlAlert
|
|
83
|
+
type="error"
|
|
84
|
+
:closable="true"
|
|
85
|
+
:confirm-close="true"
|
|
86
|
+
confirm-close-header="Custom Dismiss Alert"
|
|
87
|
+
confirm-close-message="This is a custom confirmation message."
|
|
88
|
+
fluid
|
|
89
|
+
style="margin-top: 10px"
|
|
90
|
+
@dismiss="handleDismiss"
|
|
91
|
+
>
|
|
92
|
+
Custom confirmation dialog with custom header and message.
|
|
93
|
+
</DlAlert>
|
|
94
|
+
<DlAlert
|
|
95
|
+
type="info"
|
|
96
|
+
:closable="true"
|
|
97
|
+
:confirm-close="false"
|
|
98
|
+
fluid
|
|
99
|
+
style="margin-top: 10px"
|
|
100
|
+
>
|
|
101
|
+
This alert closes immediately without confirmation
|
|
102
|
+
(confirm-close is false).
|
|
103
|
+
</DlAlert>
|
|
104
|
+
</div>
|
|
69
105
|
</div>
|
|
70
106
|
</template>
|
|
71
107
|
|
|
@@ -94,6 +130,10 @@ export default defineComponent({
|
|
|
94
130
|
index === alertTypes.length - 1
|
|
95
131
|
? alertTypes[0]
|
|
96
132
|
: alertTypes[index + 1]
|
|
133
|
+
},
|
|
134
|
+
handleDismiss() {
|
|
135
|
+
console.log('Alert dismissed!')
|
|
136
|
+
// You can add custom logic here when the alert is dismissed
|
|
97
137
|
}
|
|
98
138
|
},
|
|
99
139
|
template: 'dl-alert-demo'
|