@cypress-design/vue-alert 0.5.2 → 0.5.4

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.es.mjs CHANGED
@@ -1,84 +1,101 @@
1
- import { h as i, defineComponent as M, ref as z, useSlots as R, computed as f, onMounted as j, onUnmounted as T, openBlock as C, createElementBlock as x, normalizeClass as p, createElementVNode as m, unref as r, renderSlot as k, normalizeProps as A, guardReactiveProps as I, createBlock as B, resolveDynamicComponent as E, mergeProps as H, createCommentVNode as g, createVNode as S, createTextVNode as _, toDisplayString as N } from "vue";
2
- import * as y from "@cypress-design/icon-registry";
3
- import { ICON_COLOR_PROP_NAMES as O } from "@cypress-design/icon-registry";
4
- import { DetailsAnimation as P } from "@cypress-design/details-animation";
5
- const v = ({
6
- body: s,
7
- compiledClasses: o,
8
- size: e,
9
- class: t,
10
- interactiveColorsOnGroup: h,
11
- ...d
1
+ import { h as c, defineComponent as R, ref as z, useSlots as D, computed as g, onMounted as A, onUnmounted as G, openBlock as C, createElementBlock as b, normalizeClass as p, createElementVNode as f, renderSlot as y, normalizeProps as O, guardReactiveProps as H, createBlock as I, resolveDynamicComponent as T, mergeProps as B, createCommentVNode as m, createVNode as $, unref as x, createTextVNode as E, toDisplayString as N } from "vue";
2
+ import * as h 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 k = ({
6
+ body: l,
7
+ compiledClasses: a,
8
+ size: r,
9
+ ...s
12
10
  }) => {
13
- const c = Object.keys(d).reduce(
14
- (a, n) => (!O.includes(n) && n !== "name" && (a[n] = d[n]), a),
11
+ const e = Object.keys(s).reduce(
12
+ (o, i) => (!P.includes(
13
+ i
14
+ ) && i !== "name" && (o[i] = s[i]), o),
15
15
  {}
16
- ), l = {
17
- width: e,
18
- height: e,
19
- viewBox: `0 0 ${e} ${e}`,
16
+ ), t = {
17
+ width: r,
18
+ height: r,
19
+ viewBox: `0 0 ${r} ${r}`,
20
20
  fill: "none",
21
- innerHTML: s,
22
- ...c
21
+ innerHTML: l,
22
+ class: void 0,
23
+ ...e
23
24
  // add all standard attributes back to the svg tag
24
25
  };
25
- return o.length && (l.class = o.join(" ")), l;
26
- }, Z = (s) => {
27
- const { sizeWithDefault: o, compiledClasses: e } = y.getComponentAttributes({ ...s, availableSizes: ["16", "24"] }), t = {
26
+ return a.length && (t.class = a.join(" ")), t;
27
+ }, _ = (l) => {
28
+ const { interactiveColorsOnGroup: a, name: r, ...s } = l, { sizeWithDefault: e, compiledClasses: t } = h.getComponentAttributes({
29
+ ...s,
30
+ availableSizes: ["16", "24"],
31
+ interactiveColorsOnGroup: a
32
+ }), o = {
28
33
  16: '<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 13 13 3M3 3l10 10" class="icon-dark"/>',
29
34
  24: '<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 20 20 4M4 4l16 16" class="icon-dark"/>'
30
- }[o];
31
- if (!t)
32
- throw Error(`Icon "action-delete-large" is not available in size ${o}`);
33
- return i("svg", v({
35
+ }[e];
36
+ if (!o)
37
+ throw Error(`Icon "action-delete-large" is not available in size ${e}`);
38
+ return c("svg", k({
34
39
  ...s,
35
- size: o,
36
- body: t,
37
- compiledClasses: e
40
+ size: e,
41
+ body: o,
42
+ compiledClasses: t
38
43
  }));
39
- }, V = (s) => {
40
- const { sizeWithDefault: o, compiledClasses: e } = y.getComponentAttributes({ ...s, availableSizes: ["16"] }), t = {
44
+ }, Z = (l) => {
45
+ const { interactiveColorsOnGroup: a, name: r, ...s } = l, { sizeWithDefault: e, compiledClasses: t } = h.getComponentAttributes({
46
+ ...s,
47
+ availableSizes: ["16"],
48
+ interactiveColorsOnGroup: a
49
+ }), o = {
41
50
  16: '<path stroke="currentColor" stroke-width="2" d="M12.95 12.95a7 7 0 1 1-9.9-9.9 7 7 0 0 1 9.9 9.9Z" class="icon-dark"/><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m6 8 1.5 2L10 6" class="icon-dark"/>'
42
- }[o];
43
- if (!t)
44
- throw Error(`Icon "checkmark-outline" is not available in size ${o}`);
45
- return i("svg", v({
51
+ }[e];
52
+ if (!o)
53
+ throw Error(`Icon "checkmark-outline" is not available in size ${e}`);
54
+ return c("svg", k({
46
55
  ...s,
47
- size: o,
48
- body: t,
49
- compiledClasses: e
56
+ size: e,
57
+ body: o,
58
+ compiledClasses: t
50
59
  }));
51
- }, W = (s) => {
52
- const { sizeWithDefault: o, compiledClasses: e } = y.getComponentAttributes({ ...s, availableSizes: ["8", "16"] }), t = {
60
+ }, W = (l) => {
61
+ const { interactiveColorsOnGroup: a, name: r, ...s } = l, { sizeWithDefault: e, compiledClasses: t } = h.getComponentAttributes({
62
+ ...s,
63
+ availableSizes: ["8", "16"],
64
+ interactiveColorsOnGroup: a
65
+ }), o = {
53
66
  8: '<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 2.5 3 3 3-3" class="icon-dark"/>',
54
67
  16: '<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m4 6 4 4 4-4" class="icon-dark"/>'
55
- }[o];
56
- if (!t)
57
- throw Error(`Icon "chevron-down-small" is not available in size ${o}`);
58
- return i("svg", v({
68
+ }[e];
69
+ if (!o)
70
+ throw Error(`Icon "chevron-down-small" is not available in size ${e}`);
71
+ return c("svg", k({
59
72
  ...s,
60
- size: o,
61
- body: t,
62
- compiledClasses: e
73
+ size: e,
74
+ body: o,
75
+ compiledClasses: t
63
76
  }));
64
- }, $ = (s) => {
65
- const { sizeWithDefault: o, compiledClasses: e } = y.getComponentAttributes({ ...s, availableSizes: ["16"] }), t = {
77
+ }, S = (l) => {
78
+ const { interactiveColorsOnGroup: a, name: r, ...s } = l, { sizeWithDefault: e, compiledClasses: t } = h.getComponentAttributes({
79
+ ...s,
80
+ availableSizes: ["16"],
81
+ interactiveColorsOnGroup: a
82
+ }), o = {
66
83
  16: '<path fill="currentColor" fill-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" class="icon-dark" clip-rule="evenodd"/>'
67
- }[o];
68
- if (!t)
69
- throw Error(`Icon "warning-circle" is not available in size ${o}`);
70
- return i("svg", v({
84
+ }[e];
85
+ if (!o)
86
+ throw Error(`Icon "warning-circle" is not available in size ${e}`);
87
+ return c("svg", k({
71
88
  ...s,
72
- size: o,
73
- body: t,
74
- compiledClasses: e
89
+ size: e,
90
+ body: o,
91
+ compiledClasses: t
75
92
  }));
76
93
  }, L = {
77
94
  xs: "py-[4px] px-[8px] leading-[22px] text-[14px]",
78
95
  sm: "py-[8px] px-[12px] leading-[22px] text-[14px]",
79
96
  md: "py-[12px] px-[16px] leading-[24px] text-[16px]",
80
97
  lg: "p-[16px] leading-[24px] text-[16px]"
81
- }, G = "lg", U = {
98
+ }, U = "lg", q = {
82
99
  neutral: {
83
100
  headerClass: "text-gray-800 bg-gray-100",
84
101
  bodyClass: "bg-gray-50 text-gray-500",
@@ -138,109 +155,129 @@ const v = ({
138
155
  iconColor: "jade-500",
139
156
  /* <tw-keep strokeColor="jade-300"/> */
140
157
  iconChevronColor: "jade-300"
158
+ },
159
+ clear: {
160
+ wrapperClass: "border-gray-50 bg-white border text-gray-700",
161
+ headerClass: "",
162
+ bodyClass: "border-gray-50 border-t",
163
+ borderClass: "border-gray-50",
164
+ detailsHeaderClass: "text-gray-700",
165
+ /* <tw-keep strokeColor="gray-600"/> */
166
+ iconCloseColor: "gray-600",
167
+ /* <tw-keep strokeColor="gray-500"/> */
168
+ iconColor: "gray-500",
169
+ /* <tw-keep strokeColor="gray-300"/> */
170
+ iconChevronColor: "gray-300"
141
171
  }
142
- }, q = "info", F = "Additional details", J = { class: "flex-1 font-medium" }, ee = /* @__PURE__ */ M({
172
+ }, F = "info", J = "Additional details", K = { class: "flex-1 font-medium" }, oe = /* @__PURE__ */ R({
143
173
  __name: "Alert",
144
174
  props: {
145
- type: { default: q },
146
- detailsTitle: { default: F },
175
+ variant: { default: void 0 },
176
+ type: { default: F },
177
+ detailsTitle: { default: J },
147
178
  dismissible: { type: Boolean },
148
179
  noIcon: { type: Boolean },
149
180
  notRounded: { type: Boolean },
150
- duration: null,
151
- size: { default: G }
181
+ duration: {},
182
+ size: { default: U }
152
183
  },
153
184
  emits: ["dismiss"],
154
- setup(s, { emit: o }) {
155
- const e = s, t = z(!1), h = R(), d = z(null), c = z(null), l = f(() => U[e.type] ?? {});
156
- let a;
157
- j(() => {
158
- e.duration && (a = setTimeout(n, e.duration));
159
- }), j(() => {
160
- d.value && c.value && new P(d.value, c.value);
161
- }), T(() => {
162
- a && clearTimeout(a);
185
+ setup(l, { emit: a }) {
186
+ const r = l, s = z(!1), e = D(), t = g(() => r.variant ?? r.type), o = z(null), i = z(null), n = g(() => q[t.value] ?? {});
187
+ let u;
188
+ A(() => {
189
+ r.duration && (u = setTimeout(w, r.duration));
190
+ }), A(() => {
191
+ o.value && i.value && new V(o.value, i.value);
192
+ }), G(() => {
193
+ u && clearTimeout(u);
163
194
  });
164
- function n() {
165
- t.value = !0, o("dismiss"), a && (clearTimeout(a), a = void 0);
195
+ function w() {
196
+ s.value = !0, a("dismiss"), u && (clearTimeout(u), u = void 0);
166
197
  }
167
- const u = f(() => ({
168
- strokeColor: l.value.iconColor,
198
+ const v = g(() => ({
199
+ strokeColor: n.value.iconColor,
169
200
  class: "my-[4px] mr-[8px]"
170
- })), w = f(() => {
171
- switch (e.type) {
201
+ })), j = g(() => {
202
+ switch (t.value) {
172
203
  case "info":
173
204
  return null;
174
205
  case "success":
175
- return () => i(V, u.value);
206
+ return () => c(Z, v.value);
176
207
  case "warning":
177
- return () => i($, u.value);
208
+ return () => c(S, v.value);
178
209
  case "error":
179
- return () => i($, u.value);
210
+ return () => c(S, v.value);
180
211
  default:
181
212
  return null;
182
213
  }
183
- }), D = f(() => L[e.size] ?? {});
184
- return (b, K) => t.value ? g("", !0) : (C(), x("div", {
214
+ }), M = g(() => L[r.size] ?? {});
215
+ return (d, Q) => s.value ? m("", !0) : (C(), b("div", {
185
216
  key: 0,
186
- class: p(["overflow-hidden text-left", e.notRounded ? void 0 : "rounded"])
217
+ class: p(["overflow-hidden text-left", [n.value.wrapperClass, { rounded: !r.notRounded }]])
187
218
  }, [
188
- m("div", {
189
- class: p(["flex", [r(l).headerClass, r(D)]])
219
+ f("div", {
220
+ class: p(["flex", [n.value.headerClass, M.value]])
190
221
  }, [
191
- k(b.$slots, "icon", A(I(r(u))), () => [
192
- !e.noIcon && r(w) ? (C(), B(E(r(w)), A(H({ key: 0 }, r(u))), null, 16)) : g("", !0)
222
+ y(d.$slots, "icon", O(H(v.value)), () => [
223
+ !r.noIcon && j.value ? (C(), I(T(j.value), O(B({ key: 0 }, v.value)), null, 16)) : m("", !0)
193
224
  ]),
194
- m("div", J, [
195
- k(b.$slots, "default")
225
+ f("div", K, [
226
+ y(d.$slots, "default")
196
227
  ]),
197
- s.dismissible ? (C(), x("button", {
228
+ d.dismissible ? (C(), b("button", {
198
229
  key: 0,
199
230
  class: "m-[4px] ml-[8px] h-[16px]",
200
- onClick: n,
231
+ onClick: w,
201
232
  "aria-label": "Dismiss"
202
233
  }, [
203
- S(r(Z), {
204
- "stroke-color": r(l).iconCloseColor
234
+ $(x(_), {
235
+ "stroke-color": n.value.iconCloseColor
205
236
  }, null, 8, ["stroke-color"])
206
- ])) : g("", !0)
237
+ ])) : m("", !0)
207
238
  ], 2),
208
- r(h).body ? (C(), x("div", {
239
+ x(e).body ? (C(), b("div", {
209
240
  key: 0,
210
- class: p(["p-[16px]", r(l).bodyClass])
241
+ class: p(["p-[16px]", n.value.bodyClass])
211
242
  }, [
212
- k(b.$slots, "body")
213
- ], 2)) : g("", !0),
214
- r(h).details ? (C(), x("details", {
243
+ y(d.$slots, "body")
244
+ ], 2)) : m("", !0),
245
+ x(e).details ? (C(), b("details", {
215
246
  key: 1,
216
- class: p(["p-[16px] border-t border-t-1", [r(l).bodyClass, r(l).borderClass]]),
247
+ class: p(["p-[16px] border-t border-t-1", [n.value.bodyClass, n.value.borderClass]]),
217
248
  ref_key: "detailsRef",
218
- ref: d
249
+ ref: o
219
250
  }, [
220
- m("summary", {
221
- class: p(["flex font-medium cursor-pointer details-none", r(l).detailsHeaderClass])
251
+ f("summary", {
252
+ class: p(["flex font-medium cursor-pointer details-none", n.value.detailsHeaderClass])
222
253
  }, [
223
- S(r(W), {
224
- strokeColor: r(l).iconChevronColor,
254
+ $(x(W), {
255
+ strokeColor: n.value.iconChevronColor,
225
256
  class: "icon my-[4px] mr-[8px] transition transform -rotate-90 open:rotate-0"
226
257
  }, null, 8, ["strokeColor"]),
227
- _(" " + N(e.detailsTitle), 1)
258
+ E(" " + N(r.detailsTitle), 1)
228
259
  ], 2),
229
- m("div", {
260
+ f("div", {
230
261
  ref_key: "contentRef",
231
- ref: c
262
+ ref: i
232
263
  }, [
233
- m("div", null, [
234
- k(b.$slots, "details")
264
+ f("div", null, [
265
+ y(d.$slots, "details")
235
266
  ])
236
267
  ], 512)
237
- ], 2)) : g("", !0)
268
+ ], 2)) : m("", !0),
269
+ d.$slots.footer ? (C(), b("div", {
270
+ key: 2,
271
+ class: p(n.value.bodyClass)
272
+ }, [
273
+ y(d.$slots, "footer")
274
+ ], 2)) : m("", !0)
238
275
  ], 2));
239
276
  }
240
277
  });
241
278
  export {
242
- ee as default
279
+ oe as default
243
280
  };
244
281
  //# sourceMappingURL=index.es.mjs.map
245
282
 
246
- /* <wind-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 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"> */
283
+ /* <wind-keep class="my-[4px] mr-[8px] overflow-hidden text-left flex flex-1 font-medium m-[4px] ml-[8px] h-[16px] p-[16px] border-t 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 border-gray-50 bg-white border text-gray-700 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"> */