@citizenplane/pimp 9.14.0 → 9.15.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/dist/index-z9l8C72U-CAfHR3NZ.js +3733 -0
- package/dist/pimp.es.js +9577 -8322
- package/dist/pimp.umd.js +319 -26
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/src/assets/{styles/base/_base.scss → css/base.css} +3 -10
- package/src/assets/css/colors.css +123 -0
- package/src/assets/css/easings.css +3 -0
- package/src/assets/css/spacing.css +43 -0
- package/src/assets/{styles/variables/_tokens.scss → css/tokens.css} +2 -9
- package/src/assets/main.css +7 -0
- package/src/assets/styles/variables/_colors.scss +13 -128
- package/src/assets/styles/variables/_spacing.scss +0 -44
- package/src/components/CpButton.vue +3 -3
- package/src/components/CpTable.vue +30 -7
- package/src/components/CpToast.vue +322 -0
- package/src/components/icons/IconIntent.vue +36 -0
- package/src/components/index.ts +10 -1
- package/src/constants/CpCustomIcons.ts +2 -0
- package/src/constants/CpTableColumn.ts +1 -0
- package/src/constants/CpToastTypes.ts +7 -0
- package/src/stories/CpTable.stories.ts +2 -14
- package/src/stories/CpToast.stories.ts +194 -0
- package/src/assets/styles/main.scss +0 -5
- /package/src/assets/{styles/variables/_dimensions.scss → css/dimensions.css} +0 -0
- /package/src/assets/{styles/variables/_shadows.scss → css/shadows.css} +0 -0
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<toast class="cpToasts">
|
|
3
|
+
<template #container="{ message, closeCallback }">
|
|
4
|
+
<div class="cpToast" :class="getDynamicClass(message.severity)">
|
|
5
|
+
<div class="cpToast__inner">
|
|
6
|
+
<cp-icon class="cpToast__icon" size="16" :type="getDynamicIcon(message.severity)" />
|
|
7
|
+
<div class="cpToast__content">
|
|
8
|
+
<span class="cpToast__summary">{{ message.summary }}</span>
|
|
9
|
+
<span v-if="message.detail" class="cpToast__detail">{{ message.detail }}</span>
|
|
10
|
+
</div>
|
|
11
|
+
<button class="cpToast__close" type="button" @click="closeCallback">
|
|
12
|
+
<cp-icon class="cpToast__icon cpToast__icon--isClose" size="16" type="x" />
|
|
13
|
+
</button>
|
|
14
|
+
</div>
|
|
15
|
+
<div v-if="hasActions(message)" class="cpToast__actions">
|
|
16
|
+
<cp-button
|
|
17
|
+
v-if="message.primaryAction"
|
|
18
|
+
appearance="primary"
|
|
19
|
+
class="cpToast__action"
|
|
20
|
+
:color="getButtonColor(message.severity)"
|
|
21
|
+
is-square
|
|
22
|
+
size="sm"
|
|
23
|
+
@click="message.primaryAction.onClick"
|
|
24
|
+
>
|
|
25
|
+
{{ message.primaryAction.label }}
|
|
26
|
+
</cp-button>
|
|
27
|
+
<cp-button
|
|
28
|
+
v-if="message.secondaryAction"
|
|
29
|
+
appearance="minimal"
|
|
30
|
+
class="cpToast__action"
|
|
31
|
+
:color="getButtonColor(message.severity)"
|
|
32
|
+
is-square
|
|
33
|
+
size="sm"
|
|
34
|
+
@click="message.secondaryAction.onClick"
|
|
35
|
+
>
|
|
36
|
+
{{ message.secondaryAction.label }}
|
|
37
|
+
</cp-button>
|
|
38
|
+
</div>
|
|
39
|
+
<div
|
|
40
|
+
v-if="displayTimer(message.life)"
|
|
41
|
+
aria-hidden="true"
|
|
42
|
+
class="cpToast__timer"
|
|
43
|
+
role="presentation"
|
|
44
|
+
:style="getTimerBarStyle(message.life)"
|
|
45
|
+
/>
|
|
46
|
+
</div>
|
|
47
|
+
</template>
|
|
48
|
+
</toast>
|
|
49
|
+
</template>
|
|
50
|
+
|
|
51
|
+
<script setup lang="ts">
|
|
52
|
+
import Toast from 'primevue/toast'
|
|
53
|
+
import { defineProps, withDefaults } from 'vue'
|
|
54
|
+
|
|
55
|
+
import { CpToastTypes } from '@/constants/CpToastTypes'
|
|
56
|
+
|
|
57
|
+
import { capitalizeFirstLetter } from '@/helpers'
|
|
58
|
+
|
|
59
|
+
interface Props {
|
|
60
|
+
detail?: string
|
|
61
|
+
hideTimer?: boolean
|
|
62
|
+
primaryAction?: {
|
|
63
|
+
label: string
|
|
64
|
+
onClick: VoidFunction
|
|
65
|
+
}
|
|
66
|
+
secondaryAction?: {
|
|
67
|
+
label: string
|
|
68
|
+
onClick: VoidFunction
|
|
69
|
+
}
|
|
70
|
+
severity: CpToastTypes
|
|
71
|
+
summary: string
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
75
|
+
hideTimer: false,
|
|
76
|
+
primaryAction: undefined,
|
|
77
|
+
secondaryAction: undefined,
|
|
78
|
+
detail: '',
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
const displayTimer = (life: number) => !props.hideTimer && life !== undefined
|
|
82
|
+
|
|
83
|
+
const getDynamicClass = (severity: string) => `cpToast--is${capitalizeFirstLetter(severity)}`
|
|
84
|
+
|
|
85
|
+
const getDynamicIcon = (severity: CpToastTypes) => {
|
|
86
|
+
switch (severity) {
|
|
87
|
+
case CpToastTypes.ERROR:
|
|
88
|
+
return 'alert-octagon'
|
|
89
|
+
case CpToastTypes.INFO:
|
|
90
|
+
return 'info'
|
|
91
|
+
case CpToastTypes.SUCCESS:
|
|
92
|
+
return 'check-circle'
|
|
93
|
+
case CpToastTypes.WARNING:
|
|
94
|
+
return 'alert-triangle'
|
|
95
|
+
default:
|
|
96
|
+
return 'intent'
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const getButtonColor = (severity: string) => {
|
|
101
|
+
switch (severity) {
|
|
102
|
+
case CpToastTypes.ERROR:
|
|
103
|
+
return 'red'
|
|
104
|
+
case CpToastTypes.SUCCESS:
|
|
105
|
+
return 'green'
|
|
106
|
+
case CpToastTypes.WARNING:
|
|
107
|
+
return 'orange'
|
|
108
|
+
default:
|
|
109
|
+
return 'purple'
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const hasActions = (message: Props) => !!message.primaryAction || !!message.secondaryAction
|
|
114
|
+
|
|
115
|
+
const getTimerBarStyle = (life: number) => ({ animationDuration: `${life}ms` })
|
|
116
|
+
</script>
|
|
117
|
+
|
|
118
|
+
<style lang="scss">
|
|
119
|
+
.p-toast-message-enter-active {
|
|
120
|
+
transition:
|
|
121
|
+
transform 400ms fn.v(easing-elastic),
|
|
122
|
+
opacity 200ms fn.v(easing-elastic);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.p-toast-message-move,
|
|
126
|
+
.p-toast-message-leave-active {
|
|
127
|
+
transition:
|
|
128
|
+
transform 400ms ease,
|
|
129
|
+
opacity 200ms ease;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.p-toast-message-enter-from,
|
|
133
|
+
.p-toast-message-leave-to {
|
|
134
|
+
opacity: 0;
|
|
135
|
+
transform: translate3d(0, fn.px-to-rem(-30), 0) scale3d(0.75, 0.75, 1);
|
|
136
|
+
z-index: -1;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.cpToasts div[role='alert']:not(:only-child).p-toast-message-leave-active {
|
|
140
|
+
position: absolute;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.cpToasts > div {
|
|
144
|
+
display: flex;
|
|
145
|
+
flex-direction: column;
|
|
146
|
+
gap: sp.$space;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
.cpToast {
|
|
150
|
+
--toaster-shadow: #{fn.v(drop-shadow-md-offset-x)} #{fn.v(drop-shadow-md-offset-y)} #{fn.v(drop-shadow-md-blur)}
|
|
151
|
+
#{fn.v(drop-shadow-md-spread)} #{fn.v(drop-shadow-md-color)};
|
|
152
|
+
|
|
153
|
+
display: flex;
|
|
154
|
+
overflow: hidden;
|
|
155
|
+
position: relative;
|
|
156
|
+
flex-direction: column;
|
|
157
|
+
padding: sp.$space-md;
|
|
158
|
+
border-radius: fn.px-to-rem(8);
|
|
159
|
+
box-shadow: var(--toaster-shadow);
|
|
160
|
+
gap: sp.$space;
|
|
161
|
+
background-color: fn.v(background-primary);
|
|
162
|
+
|
|
163
|
+
&__inner {
|
|
164
|
+
display: flex;
|
|
165
|
+
align-items: flex-start;
|
|
166
|
+
gap: sp.$space;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
&__content {
|
|
170
|
+
display: flex;
|
|
171
|
+
flex: 1;
|
|
172
|
+
flex-direction: column;
|
|
173
|
+
gap: sp.$space-sm;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
&__icon {
|
|
177
|
+
color: fn.v(text-accent-primary);
|
|
178
|
+
|
|
179
|
+
&:not(.cpToast__icon--isClose) {
|
|
180
|
+
padding-top: sp.$space-xs;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
&__summary,
|
|
185
|
+
&__detail {
|
|
186
|
+
font-size: fn.px-to-rem(14);
|
|
187
|
+
line-height: fn.px-to-rem(20);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
&__summary {
|
|
191
|
+
font-weight: 600;
|
|
192
|
+
color: fn.v(text-accent-primary);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
&__detail {
|
|
196
|
+
font-weight: 500;
|
|
197
|
+
color: fn.v(text-accent-secondary);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
&__actions {
|
|
201
|
+
margin-top: sp.$space-sm;
|
|
202
|
+
display: flex;
|
|
203
|
+
justify-content: flex-end;
|
|
204
|
+
gap: sp.$space;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
&__close {
|
|
208
|
+
display: flex;
|
|
209
|
+
margin-top: sp.$space-xs;
|
|
210
|
+
border-radius: fn.px-to-rem(50);
|
|
211
|
+
|
|
212
|
+
&:focus-visible {
|
|
213
|
+
outline: fn.px-to-rem(2) solid fn.v(border-accent-solid);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
@keyframes toast-timer {
|
|
218
|
+
from {
|
|
219
|
+
transform: scale3d(1, 1, 1);
|
|
220
|
+
}
|
|
221
|
+
to {
|
|
222
|
+
transform: scale3d(0, 1, 1);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
&__timer {
|
|
227
|
+
position: absolute;
|
|
228
|
+
inset: 0;
|
|
229
|
+
top: auto;
|
|
230
|
+
height: fn.px-to-rem(4);
|
|
231
|
+
transform-origin: left;
|
|
232
|
+
animation-name: toast-timer;
|
|
233
|
+
animation-timing-function: linear;
|
|
234
|
+
animation-fill-mode: forwards;
|
|
235
|
+
background-color: fn.v(border-accent-solid);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
&--isInfo {
|
|
239
|
+
background-color: fn.v(background-blue-primary);
|
|
240
|
+
|
|
241
|
+
.cpToast__icon,
|
|
242
|
+
.cpToast__summary {
|
|
243
|
+
color: fn.v(text-blue-primary);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
.cpToast__detail {
|
|
247
|
+
color: fn.v(text-blue-secondary);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
.cpToast__close {
|
|
251
|
+
outline-color: fn.v(border-blue-solid);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
.cpToast__timer {
|
|
255
|
+
background-color: fn.v(border-blue-solid);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
&--isSuccess {
|
|
260
|
+
background-color: fn.v(background-success-primary);
|
|
261
|
+
|
|
262
|
+
.cpToast__icon,
|
|
263
|
+
.cpToast__summary {
|
|
264
|
+
color: fn.v(text-success-primary);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
.cpToast__detail {
|
|
268
|
+
color: fn.v(text-success-secondary);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
.cpToast__close {
|
|
272
|
+
outline-color: fn.v(border-success-solid);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
.cpToast__timer {
|
|
276
|
+
background-color: fn.v(border-success-solid);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
&--isError {
|
|
281
|
+
background-color: fn.v(background-error-primary);
|
|
282
|
+
|
|
283
|
+
.cpToast__icon,
|
|
284
|
+
.cpToast__summary {
|
|
285
|
+
color: fn.v(text-error-primary);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
.cpToast__detail {
|
|
289
|
+
color: fn.v(text-error-secondary);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
.cpToast__close {
|
|
293
|
+
outline-color: fn.v(border-error-solid);
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
.cpToast__timer {
|
|
297
|
+
background-color: fn.v(border-error-solid);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
&--isWarning {
|
|
302
|
+
background-color: fn.v(background-warning-primary);
|
|
303
|
+
|
|
304
|
+
.cpToast__icon,
|
|
305
|
+
.cpToast__summary {
|
|
306
|
+
color: fn.v(text-warning-primary);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
.cpToast__detail {
|
|
310
|
+
color: fn.v(text-warning-secondary);
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
.cpToast__close {
|
|
314
|
+
outline-color: fn.v(border-warning-solid);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
.cpToast__timer {
|
|
318
|
+
background-color: fn.v(border-warning-solid);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
</style>
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<svg
|
|
3
|
+
clip-rule="evenodd"
|
|
4
|
+
fill="currentColor"
|
|
5
|
+
fill-rule="evenodd"
|
|
6
|
+
height="24"
|
|
7
|
+
viewBox="0 0 24 24"
|
|
8
|
+
width="24"
|
|
9
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
10
|
+
>
|
|
11
|
+
<path
|
|
12
|
+
d="M9.9169 1.19704C10.4941 1.0864 11 1.55136 11 2.13907V2.15944C11 2.66921 10.6148 3.09135 10.1162 3.19753C9.02753 3.42938 8.0117 3.85808 7.10775 4.4446C6.68031 4.72194 6.10975 4.6956 5.74945 4.3353L5.73512 4.32098C5.31937 3.90522 5.34858 3.21846 5.83525 2.88854C7.0455 2.0681 8.42786 1.48246 9.9169 1.19704Z"
|
|
13
|
+
/>
|
|
14
|
+
<path
|
|
15
|
+
d="M19.6648 18.2505C19.3045 17.8903 19.2781 17.3197 19.5555 16.8922C20.142 15.9883 20.5707 14.9725 20.8025 13.8838C20.9087 13.3852 21.3308 13 21.8406 13H21.861C22.4487 13 22.9137 13.5059 22.803 14.0831C22.5176 15.5722 21.932 16.9545 21.1115 18.1647C20.7816 18.6514 20.0948 18.6806 19.6791 18.2649L19.6648 18.2505Z"
|
|
16
|
+
/>
|
|
17
|
+
<path
|
|
18
|
+
d="M22.803 9.91695C22.9137 10.4942 22.4487 11.0001 21.861 11.0001H21.8406C21.3309 11.0001 20.9087 10.6149 20.8025 10.1163C20.5707 9.02758 20.142 8.01174 19.5554 7.10779C19.2781 6.68035 19.3044 6.10978 19.6647 5.74948L19.6791 5.73515C20.0948 5.3194 20.7816 5.34861 21.1115 5.83528C21.9319 7.04553 22.5176 8.4279 22.803 9.91695Z"
|
|
19
|
+
/>
|
|
20
|
+
<path
|
|
21
|
+
d="M18.2505 19.6649C17.8903 19.3046 17.3197 19.2782 16.8922 19.5556C15.9883 20.1421 14.9725 20.5708 13.8838 20.8026C13.3853 20.9088 13 21.331 13 21.8407V21.8611C13 22.4488 13.506 22.9138 14.0832 22.8031C15.5722 22.5177 16.9545 21.9321 18.1647 21.1116C18.6514 20.7817 18.6806 20.095 18.2649 19.6792L18.2505 19.6649Z"
|
|
22
|
+
/>
|
|
23
|
+
<path
|
|
24
|
+
d="M9.91689 22.8029C10.4941 22.9136 11 22.4486 11 21.8609V21.8405C11 21.3308 10.6148 20.9086 10.1162 20.8024C9.02751 20.5706 8.01166 20.1419 7.1077 19.5553C6.68026 19.278 6.10969 19.3043 5.74939 19.6646L5.73506 19.679C5.31931 20.0947 5.34851 20.7815 5.83519 21.1114C7.04545 21.9319 8.42783 22.5175 9.91689 22.8029Z"
|
|
25
|
+
/>
|
|
26
|
+
<path
|
|
27
|
+
d="M13 2.15944C13 2.66921 13.3853 3.09134 13.8838 3.19753C14.9725 3.42938 15.9883 3.85806 16.8922 4.44456C17.3196 4.7219 17.8902 4.69555 18.2505 4.33526L18.2648 4.32093C18.6806 3.90517 18.6514 3.21841 18.1647 2.88849C16.9545 2.06808 15.5722 1.48246 14.0832 1.19704C13.506 1.0864 13 1.55135 13 2.13907V2.15944Z"
|
|
28
|
+
/>
|
|
29
|
+
<path
|
|
30
|
+
d="M4.32091 5.73515C3.90516 5.3194 3.2184 5.34861 2.88847 5.83528C2.06804 7.04552 1.4824 8.42787 1.19698 9.9169C1.08634 10.4941 1.55129 11 2.13901 11H2.15938C2.66915 11 3.09128 10.6148 3.19747 10.1162C3.42932 9.02755 3.85802 8.01173 4.44454 7.10778C4.72188 6.68034 4.69553 6.10978 4.33524 5.74948L4.32091 5.73515Z"
|
|
31
|
+
/>
|
|
32
|
+
<path
|
|
33
|
+
d="M2.13901 13C1.55129 13 1.08634 13.5059 1.19698 14.0831C1.48239 15.5721 2.06802 16.9545 2.88843 18.1647C3.21835 18.6514 3.90511 18.6806 4.32087 18.2648L4.3352 18.2505C4.69549 17.8902 4.72184 17.3196 4.4445 16.8922C3.858 15.9883 3.42931 14.9725 3.19747 13.8838C3.09128 13.3852 2.66915 13 2.15938 13H2.13901Z"
|
|
34
|
+
/>
|
|
35
|
+
</svg>
|
|
36
|
+
</template>
|
package/src/components/index.ts
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
|
+
import 'vue-tel-input/vue-tel-input.css'
|
|
2
|
+
import 'floating-vue/dist/style.css'
|
|
3
|
+
import 'modern-normalize/modern-normalize.css'
|
|
4
|
+
|
|
5
|
+
import '@/assets/main.css'
|
|
6
|
+
|
|
1
7
|
import { vTooltip } from 'floating-vue'
|
|
2
8
|
import { vMaska } from 'maska/vue'
|
|
3
9
|
import PrimeVue from 'primevue/config'
|
|
10
|
+
import ToastService from 'primevue/toastservice'
|
|
4
11
|
import { App } from 'vue'
|
|
5
12
|
import { BindOnceDirective } from 'vue-bind-once'
|
|
6
13
|
import VueTelInput from 'vue-tel-input'
|
|
7
|
-
import 'vue-tel-input/vue-tel-input.css'
|
|
8
14
|
|
|
9
15
|
import ClickOutside from '../directives/ClickOutside'
|
|
10
16
|
import CpCoreDatepicker from '../libs/CoreDatepicker.vue'
|
|
@@ -35,6 +41,7 @@ import CpTable from './CpTable.vue'
|
|
|
35
41
|
import CpTableColumnEditor from './CpTableColumnEditor.vue'
|
|
36
42
|
import CpTelInput from './CpTelInput.vue'
|
|
37
43
|
import CpTextarea from './CpTextarea.vue'
|
|
44
|
+
import CpToast from './CpToast.vue'
|
|
38
45
|
import CpToaster from './CpToaster.vue'
|
|
39
46
|
import CpTooltip from './CpTooltip.vue'
|
|
40
47
|
import CpTransitionDialog from './CpTransitionDialog.vue'
|
|
@@ -52,6 +59,7 @@ import createToaster from '@/plugins/toaster'
|
|
|
52
59
|
|
|
53
60
|
const Components = {
|
|
54
61
|
CpToaster,
|
|
62
|
+
CpToast,
|
|
55
63
|
CpBadge,
|
|
56
64
|
CpHeading,
|
|
57
65
|
CpButton,
|
|
@@ -98,6 +106,7 @@ const Pimp = {
|
|
|
98
106
|
install(app: App, options: Record<string, unknown>) {
|
|
99
107
|
app.use(PrimeVue, { unstyled: true })
|
|
100
108
|
app.use(VueTelInput)
|
|
109
|
+
app.use(ToastService)
|
|
101
110
|
|
|
102
111
|
Object.keys(Components).forEach((name) => {
|
|
103
112
|
app.component(name, Components[name as keyof typeof Components])
|
|
@@ -65,6 +65,7 @@ import IconHistory from '@/components/icons/IconHistory.vue'
|
|
|
65
65
|
import IconHourGlass from '@/components/icons/IconHourGlass.vue'
|
|
66
66
|
import IconIdCard from '@/components/icons/IconIdCard.vue'
|
|
67
67
|
import IconInfant from '@/components/icons/IconInfant.vue'
|
|
68
|
+
import IconIntent from '@/components/icons/IconIntent.vue'
|
|
68
69
|
import IconItinerary from '@/components/icons/IconItinerary.vue'
|
|
69
70
|
import IconKnife from '@/components/icons/IconKnife.vue'
|
|
70
71
|
import IconLeave from '@/components/icons/IconLeave.vue'
|
|
@@ -184,6 +185,7 @@ export const CustomCpIcons = {
|
|
|
184
185
|
'id-card': IconIdCard,
|
|
185
186
|
infant: IconInfant,
|
|
186
187
|
itinerary: IconItinerary,
|
|
188
|
+
intent: IconIntent,
|
|
187
189
|
knife: IconKnife,
|
|
188
190
|
leave: IconLeave,
|
|
189
191
|
lighter: IconLighter,
|
|
@@ -14,6 +14,7 @@ const meta = {
|
|
|
14
14
|
backgrounds: {
|
|
15
15
|
default: 'dark',
|
|
16
16
|
},
|
|
17
|
+
layout: 'padded',
|
|
17
18
|
},
|
|
18
19
|
decorators: [
|
|
19
20
|
() => ({ template: '<div style="padding: 20px; border-radius: 8px; background-color: #fff;"><story/></div>' }),
|
|
@@ -66,26 +67,13 @@ export const Default: Story = {
|
|
|
66
67
|
}
|
|
67
68
|
|
|
68
69
|
export const EnableColumnEdition: Story = {
|
|
69
|
-
args: {
|
|
70
|
-
...Default.args,
|
|
71
|
-
columns: [
|
|
72
|
-
{ id: 'name', name: 'Name' },
|
|
73
|
-
{ id: 'age', name: 'Age' },
|
|
74
|
-
{ id: 'email', name: 'Email' },
|
|
75
|
-
{ id: 'status', name: 'Status' },
|
|
76
|
-
],
|
|
77
|
-
enableColumnEdition: true,
|
|
78
|
-
},
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export const EnableColumnEditionWithDefault: Story = {
|
|
82
70
|
args: {
|
|
83
71
|
...Default.args,
|
|
84
72
|
columns: [
|
|
85
73
|
{ id: 'name', name: 'Name', isProtected: true },
|
|
86
74
|
{ id: 'age', name: 'Age', isHidden: true, isProtected: true },
|
|
87
75
|
{ id: 'email', name: 'Email', isHidden: false },
|
|
88
|
-
{ id: 'status', name: 'Status' },
|
|
76
|
+
{ id: 'status', name: 'Status', isFull: true },
|
|
89
77
|
],
|
|
90
78
|
enableColumnEdition: true,
|
|
91
79
|
},
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { useToast } from 'primevue/usetoast'
|
|
2
|
+
|
|
3
|
+
import type { Meta, StoryObj } from '@storybook/vue3'
|
|
4
|
+
|
|
5
|
+
import { CpToastTypes } from '@/constants/CpToastTypes'
|
|
6
|
+
|
|
7
|
+
import CpToast from '@/components/CpToast.vue'
|
|
8
|
+
|
|
9
|
+
const meta: Meta<typeof CpToast> = {
|
|
10
|
+
title: 'CpToast',
|
|
11
|
+
component: CpToast,
|
|
12
|
+
argTypes: {
|
|
13
|
+
position: {
|
|
14
|
+
control: { type: 'select' },
|
|
15
|
+
options: ['center', 'top-left', 'top-center', 'top-right', 'bottom-left', 'bottom-center', 'bottom-right'],
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
args: {
|
|
19
|
+
position: 'top-right',
|
|
20
|
+
group: undefined,
|
|
21
|
+
},
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export default meta
|
|
25
|
+
|
|
26
|
+
type Story = StoryObj<typeof CpToast>
|
|
27
|
+
|
|
28
|
+
export const Default: Story = {
|
|
29
|
+
render: (args) => ({
|
|
30
|
+
components: { CpToast },
|
|
31
|
+
setup() {
|
|
32
|
+
const toast = useToast()
|
|
33
|
+
|
|
34
|
+
const baseOptions = {
|
|
35
|
+
severity: CpToastTypes.SECONDARY,
|
|
36
|
+
summary: `Hello i'm a cpToast !`,
|
|
37
|
+
detail: 'This is a cpToast description.',
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const notifySecondary = () => toast.add({ ...baseOptions })
|
|
41
|
+
|
|
42
|
+
const notifyInfo = () => {
|
|
43
|
+
toast.add({
|
|
44
|
+
...baseOptions,
|
|
45
|
+
severity: CpToastTypes.INFO,
|
|
46
|
+
})
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const notifyError = () => {
|
|
50
|
+
toast.add({
|
|
51
|
+
...baseOptions,
|
|
52
|
+
severity: CpToastTypes.ERROR,
|
|
53
|
+
})
|
|
54
|
+
}
|
|
55
|
+
const notifySuccess = () => {
|
|
56
|
+
toast.add({
|
|
57
|
+
...baseOptions,
|
|
58
|
+
severity: CpToastTypes.SUCCESS,
|
|
59
|
+
})
|
|
60
|
+
}
|
|
61
|
+
const notifyWarning = () => {
|
|
62
|
+
toast.add({
|
|
63
|
+
...baseOptions,
|
|
64
|
+
severity: CpToastTypes.WARNING,
|
|
65
|
+
})
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return { args, notifySecondary, notifyInfo, notifyError, notifySuccess, notifyWarning }
|
|
69
|
+
},
|
|
70
|
+
template: `
|
|
71
|
+
<div style="padding: 16px;">
|
|
72
|
+
|
|
73
|
+
<CpToast v-bind="args" />
|
|
74
|
+
|
|
75
|
+
<div style="display:flex; gap: 12px; align-items:center;">
|
|
76
|
+
<button
|
|
77
|
+
type="button"
|
|
78
|
+
@click="notifySecondary"
|
|
79
|
+
style="padding: 8px 12px; border-radius: 8px; border: 1px solid #ddd; cursor:pointer;"
|
|
80
|
+
>
|
|
81
|
+
Show secondary toast
|
|
82
|
+
</button>
|
|
83
|
+
|
|
84
|
+
<button
|
|
85
|
+
type="button"
|
|
86
|
+
@click="notifyInfo"
|
|
87
|
+
style="padding: 8px 12px; border-radius: 8px; border: 1px solid #ddd; cursor:pointer;"
|
|
88
|
+
>
|
|
89
|
+
Show info toast
|
|
90
|
+
</button>
|
|
91
|
+
|
|
92
|
+
<button
|
|
93
|
+
type="button"
|
|
94
|
+
@click="notifyError"
|
|
95
|
+
style="padding: 8px 12px; border-radius: 8px; border: 1px solid #ddd; cursor:pointer;"
|
|
96
|
+
>
|
|
97
|
+
Show error toast
|
|
98
|
+
</button>
|
|
99
|
+
|
|
100
|
+
<button
|
|
101
|
+
type="button"
|
|
102
|
+
@click="notifySuccess"
|
|
103
|
+
style="padding: 8px 12px; border-radius: 8px; border: 1px solid #ddd; cursor:pointer;"
|
|
104
|
+
>
|
|
105
|
+
Show success toast
|
|
106
|
+
</button>
|
|
107
|
+
|
|
108
|
+
<button
|
|
109
|
+
type="button"
|
|
110
|
+
@click="notifyWarning"
|
|
111
|
+
style="padding: 8px 12px; border-radius: 8px; border: 1px solid #ddd; cursor:pointer;"
|
|
112
|
+
>
|
|
113
|
+
Show warning toast
|
|
114
|
+
</button>
|
|
115
|
+
</div>
|
|
116
|
+
|
|
117
|
+
<p style="margin-top:12px; color:#666;">
|
|
118
|
+
This story demonstrates triggering notifications only via <code>useToast()</code>.
|
|
119
|
+
</p>
|
|
120
|
+
</div>
|
|
121
|
+
`,
|
|
122
|
+
}),
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export const WithTimer: Story = {
|
|
126
|
+
args: {
|
|
127
|
+
...Default.args,
|
|
128
|
+
},
|
|
129
|
+
render: (args) => ({
|
|
130
|
+
components: { CpToast },
|
|
131
|
+
setup() {
|
|
132
|
+
const toast = useToast()
|
|
133
|
+
|
|
134
|
+
const notifyWithTimer = () => {
|
|
135
|
+
toast.add({
|
|
136
|
+
severity: CpToastTypes.INFO,
|
|
137
|
+
summary: "Hello i'm a cpToast with a timer !",
|
|
138
|
+
detail: 'This is a cpToast description.',
|
|
139
|
+
life: 2500,
|
|
140
|
+
})
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return { args, notifyWithTimer }
|
|
144
|
+
},
|
|
145
|
+
template: `
|
|
146
|
+
<div style="padding: 16px;">
|
|
147
|
+
<CpToast v-bind="args" />
|
|
148
|
+
|
|
149
|
+
<cp-button @click="notifyWithTimer">Show toast with timer</cp-button>
|
|
150
|
+
</div>
|
|
151
|
+
`,
|
|
152
|
+
}),
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export const WithActions: Story = {
|
|
156
|
+
args: {
|
|
157
|
+
...Default.args,
|
|
158
|
+
},
|
|
159
|
+
render: (args) => ({
|
|
160
|
+
components: { CpToast },
|
|
161
|
+
setup() {
|
|
162
|
+
const toast = useToast()
|
|
163
|
+
|
|
164
|
+
const notifyWithActions = () => {
|
|
165
|
+
toast.add({
|
|
166
|
+
severity: CpToastTypes.INFO,
|
|
167
|
+
summary: "Hello i'm a cpToast with actions !",
|
|
168
|
+
detail: 'This is a cpToast description.',
|
|
169
|
+
primaryAction: {
|
|
170
|
+
label: 'Primary action',
|
|
171
|
+
onClick: () => {
|
|
172
|
+
console.log('Primary action clicked')
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
secondaryAction: {
|
|
176
|
+
label: 'Secondary action',
|
|
177
|
+
onClick: () => {
|
|
178
|
+
console.log('Secondary action clicked')
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
})
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
return { args, notifyWithActions }
|
|
185
|
+
},
|
|
186
|
+
template: `
|
|
187
|
+
<div style="padding: 16px;">
|
|
188
|
+
<CpToast v-bind="args" />
|
|
189
|
+
|
|
190
|
+
<cp-button @click="notifyWithActions">Show toast with actions</cp-button>
|
|
191
|
+
</div>
|
|
192
|
+
`,
|
|
193
|
+
}),
|
|
194
|
+
}
|
|
File without changes
|
|
File without changes
|