@cypress-design/vue-alert 0.1.1 → 0.2.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/Alert.rootstory.tsx +85 -71
- package/Alert.stories.mdx +1 -1
- package/Alert.vue +124 -83
- package/AlertVue.cy.tsx +1 -1
- package/CHANGELOG.md +15 -0
- package/dist/constants.d.ts +10 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/index.es.mjs +124 -112
- package/dist/index.es.mjs.map +1 -1
- package/dist/index.umd.js +2 -2
- package/dist/index.umd.js.map +1 -1
- package/dist/vue/Alert.vue.d.ts +29 -6
- package/dist/vue/Alert.vue.d.ts.map +1 -1
- package/package.json +6 -1
- package/dist/style.css +0 -1
package/dist/index.es.mjs
CHANGED
|
@@ -1,72 +1,80 @@
|
|
|
1
|
-
import { h as
|
|
2
|
-
import * as
|
|
3
|
-
import { ICON_COLOR_PROP_NAMES as
|
|
4
|
-
|
|
1
|
+
import { h as a, defineComponent as R, ref as z, useSlots as T, computed as f, onMounted as j, onUnmounted as I, openBlock as C, createElementBlock as x, normalizeClass as p, createElementVNode as m, unref as r, renderSlot as k, normalizeProps as A, guardReactiveProps as _, createBlock as B, resolveDynamicComponent as E, mergeProps as H, createCommentVNode as g, createVNode as S, createTextVNode as N, toDisplayString as O } from "vue";
|
|
2
|
+
import * as y from "@cypress-design/icon-registry";
|
|
3
|
+
import { ICON_COLOR_PROP_NAMES as P } from "@cypress-design/icon-registry";
|
|
4
|
+
import { DetailsAnimation as V } from "@cypress-design/details-animation";
|
|
5
|
+
const v = ({
|
|
5
6
|
body: s,
|
|
6
|
-
compiledClasses:
|
|
7
|
-
size:
|
|
8
|
-
class:
|
|
9
|
-
interactiveColorsOnGroup:
|
|
10
|
-
...
|
|
7
|
+
compiledClasses: o,
|
|
8
|
+
size: e,
|
|
9
|
+
class: t,
|
|
10
|
+
interactiveColorsOnGroup: h,
|
|
11
|
+
...i
|
|
11
12
|
}) => {
|
|
12
|
-
const
|
|
13
|
-
width:
|
|
14
|
-
height:
|
|
13
|
+
const c = Object.keys(i).reduce((n, d) => (P.includes(d) || (n[d] = i[d]), n), {}), l = {
|
|
14
|
+
width: e,
|
|
15
|
+
height: e,
|
|
16
|
+
viewBox: `0 0 ${e} ${e}`,
|
|
15
17
|
fill: "none",
|
|
16
18
|
innerHTML: s,
|
|
17
|
-
...
|
|
19
|
+
...c
|
|
18
20
|
};
|
|
19
|
-
return
|
|
20
|
-
},
|
|
21
|
-
const { sizeWithDefault:
|
|
22
|
-
16: '<path d="M3 13 13 3M3 3l10 10" stroke="currentColor" class="icon-dark" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>'
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
return o.length && (l.class = o.join(" ")), l;
|
|
22
|
+
}, Z = (s) => {
|
|
23
|
+
const { sizeWithDefault: o, compiledClasses: e } = y.getComponentAttributes({ ...s, availableSizes: ["16", "24"] }), t = {
|
|
24
|
+
16: '<path d="M3 13 13 3M3 3l10 10" stroke="currentColor" class="icon-dark" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>',
|
|
25
|
+
24: '<path d="M4 20 20 4M4 4l16 16" stroke="currentColor" class="icon-dark" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>'
|
|
26
|
+
}[o];
|
|
27
|
+
if (!t)
|
|
28
|
+
throw Error(`Icon "action-delete-large" is not available in size ${o}`);
|
|
29
|
+
return a("svg", v({
|
|
27
30
|
...s,
|
|
28
|
-
size:
|
|
29
|
-
body:
|
|
30
|
-
compiledClasses:
|
|
31
|
+
size: o,
|
|
32
|
+
body: t,
|
|
33
|
+
compiledClasses: e
|
|
31
34
|
}));
|
|
32
|
-
},
|
|
33
|
-
const { sizeWithDefault:
|
|
35
|
+
}, W = (s) => {
|
|
36
|
+
const { sizeWithDefault: o, compiledClasses: e } = y.getComponentAttributes({ ...s, availableSizes: ["16"] }), t = {
|
|
34
37
|
16: '<path d="M12.95 12.95a7 7 0 1 1-9.9-9.9 7 7 0 0 1 9.9 9.9Z" stroke="currentColor" stroke-width="2" class="icon-dark"/><path d="m6 8 1.5 2L10 6" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon-dark"/>'
|
|
35
|
-
}[
|
|
36
|
-
if (!
|
|
37
|
-
throw Error(`Icon "checkmark-outline" is not available in size ${
|
|
38
|
-
return
|
|
38
|
+
}[o];
|
|
39
|
+
if (!t)
|
|
40
|
+
throw Error(`Icon "checkmark-outline" is not available in size ${o}`);
|
|
41
|
+
return a("svg", v({
|
|
39
42
|
...s,
|
|
40
|
-
size:
|
|
41
|
-
body:
|
|
42
|
-
compiledClasses:
|
|
43
|
+
size: o,
|
|
44
|
+
body: t,
|
|
45
|
+
compiledClasses: e
|
|
43
46
|
}));
|
|
44
|
-
},
|
|
45
|
-
const { sizeWithDefault:
|
|
47
|
+
}, L = (s) => {
|
|
48
|
+
const { sizeWithDefault: o, compiledClasses: e } = y.getComponentAttributes({ ...s, availableSizes: ["8", "16"] }), t = {
|
|
46
49
|
8: '<path d="m1 2.5 3 3 3-3" stroke="currentColor" class="icon-dark" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>',
|
|
47
50
|
16: '<path d="m4 6 4 4 4-4" stroke="currentColor" class="icon-dark" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>'
|
|
48
|
-
}[
|
|
49
|
-
if (!
|
|
50
|
-
throw Error(`Icon "chevron-down-small" is not available in size ${
|
|
51
|
-
return
|
|
51
|
+
}[o];
|
|
52
|
+
if (!t)
|
|
53
|
+
throw Error(`Icon "chevron-down-small" is not available in size ${o}`);
|
|
54
|
+
return a("svg", v({
|
|
52
55
|
...s,
|
|
53
|
-
size:
|
|
54
|
-
body:
|
|
55
|
-
compiledClasses:
|
|
56
|
+
size: o,
|
|
57
|
+
body: t,
|
|
58
|
+
compiledClasses: e
|
|
56
59
|
}));
|
|
57
|
-
},
|
|
58
|
-
const { sizeWithDefault:
|
|
60
|
+
}, $ = (s) => {
|
|
61
|
+
const { sizeWithDefault: o, compiledClasses: e } = y.getComponentAttributes({ ...s, availableSizes: ["16"] }), t = {
|
|
59
62
|
16: '<path fill-rule="evenodd" clip-rule="evenodd" d="M2 8a6 6 0 1 1 12 0A6 6 0 0 1 2 8Zm6-8a8 8 0 1 0 0 16A8 8 0 0 0 8 0Zm1 5a1 1 0 0 0-2 0v3a1 1 0 0 0 2 0V5Zm-1 7a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z" fill="currentColor" class="icon-dark"/>'
|
|
60
|
-
}[
|
|
61
|
-
if (!
|
|
62
|
-
throw Error(`Icon "warning-circle" is not available in size ${
|
|
63
|
-
return
|
|
63
|
+
}[o];
|
|
64
|
+
if (!t)
|
|
65
|
+
throw Error(`Icon "warning-circle" is not available in size ${o}`);
|
|
66
|
+
return a("svg", v({
|
|
64
67
|
...s,
|
|
65
|
-
size:
|
|
66
|
-
body:
|
|
67
|
-
compiledClasses:
|
|
68
|
+
size: o,
|
|
69
|
+
body: t,
|
|
70
|
+
compiledClasses: e
|
|
68
71
|
}));
|
|
69
|
-
},
|
|
72
|
+
}, q = {
|
|
73
|
+
xs: "py-4px px-8px leading-22px text-14px",
|
|
74
|
+
sm: "py-8px px-12px leading-22px text-14px",
|
|
75
|
+
md: "py-12px px-16px leading-24px text-16px",
|
|
76
|
+
lg: "p-16px leading-24px text-16px"
|
|
77
|
+
}, G = "lg", D = {
|
|
70
78
|
neutral: {
|
|
71
79
|
headerClass: "text-gray-800 bg-gray-100",
|
|
72
80
|
bodyClass: "bg-gray-50 text-gray-500",
|
|
@@ -112,104 +120,108 @@ const k = ({
|
|
|
112
120
|
iconColor: "jade-500",
|
|
113
121
|
iconChevronColor: "jade-300"
|
|
114
122
|
}
|
|
115
|
-
}
|
|
116
|
-
const V = (s, e) => {
|
|
117
|
-
const o = s.__vccOpts || s;
|
|
118
|
-
for (const [r, c] of e)
|
|
119
|
-
o[r] = c;
|
|
120
|
-
return o;
|
|
121
|
-
}, Z = { class: "flex-1 font-medium" }, W = { class: "mt-16px" }, L = /* @__PURE__ */ j({
|
|
123
|
+
}, U = "info", F = "Additional details", J = { class: "flex-1 font-medium" }, ee = /* @__PURE__ */ R({
|
|
122
124
|
__name: "Alert",
|
|
123
125
|
props: {
|
|
124
|
-
type: { default:
|
|
125
|
-
detailsTitle: { default:
|
|
126
|
+
type: { default: U },
|
|
127
|
+
detailsTitle: { default: F },
|
|
126
128
|
dismissible: { type: Boolean },
|
|
127
129
|
noIcon: { type: Boolean },
|
|
128
130
|
notRounded: { type: Boolean },
|
|
129
|
-
duration: null
|
|
131
|
+
duration: null,
|
|
132
|
+
size: { default: G }
|
|
130
133
|
},
|
|
131
134
|
emits: ["dismiss"],
|
|
132
|
-
setup(s, { emit:
|
|
133
|
-
const
|
|
134
|
-
let
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
}),
|
|
138
|
-
|
|
135
|
+
setup(s, { emit: o }) {
|
|
136
|
+
const e = s, t = z(!1), h = T(), i = z(null), c = z(null), l = f(() => D[e.type]);
|
|
137
|
+
let n;
|
|
138
|
+
j(() => {
|
|
139
|
+
e.duration && (n = setTimeout(d, e.duration));
|
|
140
|
+
}), j(() => {
|
|
141
|
+
i.value && c.value && new V(i.value, c.value);
|
|
142
|
+
}), I(() => {
|
|
143
|
+
n && clearTimeout(n);
|
|
139
144
|
});
|
|
140
|
-
function
|
|
141
|
-
|
|
145
|
+
function d() {
|
|
146
|
+
t.value = !0, o("dismiss"), n && (clearTimeout(n), n = void 0);
|
|
142
147
|
}
|
|
143
|
-
const
|
|
144
|
-
strokeColor:
|
|
148
|
+
const u = f(() => ({
|
|
149
|
+
strokeColor: D[e.type].iconColor,
|
|
145
150
|
class: "my-4px mr-8px"
|
|
146
|
-
})),
|
|
147
|
-
switch (
|
|
151
|
+
})), w = f(() => {
|
|
152
|
+
switch (e.type) {
|
|
148
153
|
case "info":
|
|
149
154
|
return null;
|
|
150
155
|
case "success":
|
|
151
|
-
return () =>
|
|
156
|
+
return () => a(W, u.value);
|
|
152
157
|
case "warning":
|
|
153
|
-
return () =>
|
|
158
|
+
return () => a($, u.value);
|
|
154
159
|
case "error":
|
|
155
|
-
return () =>
|
|
160
|
+
return () => a($, u.value);
|
|
156
161
|
default:
|
|
157
162
|
return null;
|
|
158
163
|
}
|
|
159
|
-
});
|
|
160
|
-
return (
|
|
164
|
+
}), M = f(() => q[e.size]);
|
|
165
|
+
return (b, K) => t.value ? g("", !0) : (C(), x("div", {
|
|
161
166
|
key: 0,
|
|
162
|
-
class: p(["overflow-hidden text-left",
|
|
167
|
+
class: p(["overflow-hidden text-left", e.notRounded ? void 0 : "rounded"])
|
|
163
168
|
}, [
|
|
164
|
-
|
|
165
|
-
class: p(["flex
|
|
169
|
+
m("div", {
|
|
170
|
+
class: p(["flex", [r(l).headerClass, r(M)]])
|
|
166
171
|
}, [
|
|
167
|
-
|
|
168
|
-
!
|
|
169
|
-
], !0),
|
|
170
|
-
v("div", Z, [
|
|
171
|
-
y(g.$slots, "default", {}, void 0, !0)
|
|
172
|
+
k(b.$slots, "icon", A(_(r(u))), () => [
|
|
173
|
+
!e.noIcon && r(w) ? (C(), B(E(r(w)), A(H({ key: 0 }, r(u))), null, 16)) : g("", !0)
|
|
172
174
|
]),
|
|
173
|
-
|
|
175
|
+
m("div", J, [
|
|
176
|
+
k(b.$slots, "default")
|
|
177
|
+
]),
|
|
178
|
+
s.dismissible ? (C(), x("button", {
|
|
174
179
|
key: 0,
|
|
175
180
|
class: "m-4px ml-8px h-16px",
|
|
176
|
-
onClick:
|
|
181
|
+
onClick: d,
|
|
177
182
|
"aria-label": "Dismiss"
|
|
178
183
|
}, [
|
|
179
|
-
|
|
180
|
-
"stroke-color":
|
|
184
|
+
S(r(Z), {
|
|
185
|
+
"stroke-color": r(l).iconCloseColor
|
|
181
186
|
}, null, 8, ["stroke-color"])
|
|
182
|
-
])) :
|
|
187
|
+
])) : g("", !0)
|
|
183
188
|
], 2),
|
|
184
|
-
|
|
189
|
+
r(h).body ? (C(), x("div", {
|
|
185
190
|
key: 0,
|
|
186
|
-
class: p(["p-16px",
|
|
191
|
+
class: p(["p-16px", r(l).bodyClass])
|
|
187
192
|
}, [
|
|
188
|
-
|
|
189
|
-
], 2)) :
|
|
190
|
-
|
|
193
|
+
k(b.$slots, "body")
|
|
194
|
+
], 2)) : g("", !0),
|
|
195
|
+
r(h).details ? (C(), x("details", {
|
|
191
196
|
key: 1,
|
|
192
|
-
class: p(["p-16px border-t-1", [
|
|
197
|
+
class: p(["p-16px border-t-1", [r(l).bodyClass, r(l).borderClass]]),
|
|
198
|
+
ref_key: "detailsRef",
|
|
199
|
+
ref: i
|
|
193
200
|
}, [
|
|
194
|
-
|
|
195
|
-
class: p(["flex font-medium cursor-pointer",
|
|
201
|
+
m("summary", {
|
|
202
|
+
class: p(["flex font-medium cursor-pointer details-none", r(l).detailsHeaderClass])
|
|
196
203
|
}, [
|
|
197
|
-
|
|
198
|
-
strokeColor:
|
|
199
|
-
class: "icon my-4px mr-8px"
|
|
204
|
+
S(r(L), {
|
|
205
|
+
strokeColor: r(l).iconChevronColor,
|
|
206
|
+
class: "icon my-4px mr-8px transition transform -rotate-90 open:rotate-0"
|
|
200
207
|
}, null, 8, ["strokeColor"]),
|
|
201
|
-
N(" " + O(
|
|
208
|
+
N(" " + O(e.detailsTitle), 1)
|
|
202
209
|
], 2),
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
210
|
+
m("div", {
|
|
211
|
+
ref_key: "contentRef",
|
|
212
|
+
ref: c
|
|
213
|
+
}, [
|
|
214
|
+
m("div", null, [
|
|
215
|
+
k(b.$slots, "details")
|
|
216
|
+
])
|
|
217
|
+
], 512)
|
|
218
|
+
], 2)) : g("", !0)
|
|
207
219
|
], 2));
|
|
208
220
|
}
|
|
209
|
-
})
|
|
221
|
+
});
|
|
210
222
|
export {
|
|
211
|
-
|
|
223
|
+
ee as default
|
|
212
224
|
};
|
|
213
225
|
|
|
214
|
-
/* <windicss-keep class="overflow-hidden text-left rounded flex
|
|
226
|
+
/* <windicss-keep class="my-4px mr-8px overflow-hidden text-left rounded flex flex-1 font-medium m-4px ml-8px h-16px p-16px border-t-1 cursor-pointer details-none transition transform -rotate-90 open:rotate-0 py-4px px-8px leading-22px text-14px py-8px px-12px py-12px px-16px leading-24px text-16px text-gray-800 bg-gray-100 bg-gray-50 text-gray-500 border-gray-100 text-gray-600 text-indigo-700 bg-indigo-100 bg-indigo-50 text-indigo-500 border-indigo-100 text-indigo-600 text-orange-700 bg-orange-100 bg-orange-50 text-orange-500 border-orange-100 text-orange-600 text-red-700 bg-red-100 bg-red-50 text-red-500 border-red-100 text-red-600 text-jade-700 bg-jade-100 bg-jade-50 text-jade-600 border-jade-100 icon-dark-gray-600 icon-dark-gray-500 icon-dark-gray-300 icon-dark-indigo-500 icon-dark-indigo-300 icon-dark-orange-500 icon-dark-orange-400 icon-dark-orange-300 icon-dark-red-500 icon-dark-red-400 icon-dark-red-300 icon-dark-jade-600 icon-dark-jade-500 icon-dark-jade-300"> */
|
|
215
227
|
//# sourceMappingURL=index.es.mjs.map
|