@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/dist/index.es.mjs CHANGED
@@ -1,72 +1,80 @@
1
- import { h as n, defineComponent as j, ref as A, useSlots as I, computed as f, onMounted as D, onUnmounted as S, openBlock as C, createElementBlock as b, normalizeClass as p, createElementVNode as v, unref as t, renderSlot as y, normalizeProps as x, guardReactiveProps as $, createBlock as E, resolveDynamicComponent as H, mergeProps as M, createCommentVNode as m, createVNode as _, createTextVNode as N, toDisplayString as O } from "vue";
2
- import * as h from "@cypress-design/icon-registry";
3
- import { ICON_COLOR_PROP_NAMES as T } from "@cypress-design/icon-registry";
4
- const k = ({
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: e,
7
- size: o,
8
- class: r,
9
- interactiveColorsOnGroup: c,
10
- ...l
7
+ compiledClasses: o,
8
+ size: e,
9
+ class: t,
10
+ interactiveColorsOnGroup: h,
11
+ ...i
11
12
  }) => {
12
- const a = Object.keys(l).reduce((i, d) => (T.includes(d) || (i[d] = l[d]), i), {}), u = {
13
- width: o,
14
- height: o,
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
- ...a
19
+ ...c
18
20
  };
19
- return e.length && (u.class = e.join(" ")), u;
20
- }, B = (s) => {
21
- const { sizeWithDefault: e, compiledClasses: o } = h.getComponentAttributes({ ...s, availableSizes: ["16"] }), r = {
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
- }[e];
24
- if (!r)
25
- throw Error(`Icon "action-delete-large" is not available in size ${e}`);
26
- return n("svg", k({
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: e,
29
- body: r,
30
- compiledClasses: o
31
+ size: o,
32
+ body: t,
33
+ compiledClasses: e
31
34
  }));
32
- }, P = (s) => {
33
- const { sizeWithDefault: e, compiledClasses: o } = h.getComponentAttributes({ ...s, availableSizes: ["16"] }), r = {
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
- }[e];
36
- if (!r)
37
- throw Error(`Icon "checkmark-outline" is not available in size ${e}`);
38
- return n("svg", k({
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: e,
41
- body: r,
42
- compiledClasses: o
43
+ size: o,
44
+ body: t,
45
+ compiledClasses: e
43
46
  }));
44
- }, R = (s) => {
45
- const { sizeWithDefault: e, compiledClasses: o } = h.getComponentAttributes({ ...s, availableSizes: ["8", "16"] }), r = {
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
- }[e];
49
- if (!r)
50
- throw Error(`Icon "chevron-down-small" is not available in size ${e}`);
51
- return n("svg", k({
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: e,
54
- body: r,
55
- compiledClasses: o
56
+ size: o,
57
+ body: t,
58
+ compiledClasses: e
56
59
  }));
57
- }, z = (s) => {
58
- const { sizeWithDefault: e, compiledClasses: o } = h.getComponentAttributes({ ...s, availableSizes: ["16"] }), r = {
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
- }[e];
61
- if (!r)
62
- throw Error(`Icon "warning-circle" is not available in size ${e}`);
63
- return n("svg", k({
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: e,
66
- body: r,
67
- compiledClasses: o
68
+ size: o,
69
+ body: t,
70
+ compiledClasses: e
68
71
  }));
69
- }, w = {
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: "info" },
125
- detailsTitle: { default: "Additional details" },
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: e }) {
133
- const o = s, r = A(!1), c = I(), l = f(() => w[o.type]);
134
- let a;
135
- D(() => {
136
- o.duration && (a = setTimeout(u, o.duration));
137
- }), S(() => {
138
- a && clearTimeout(a);
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 u() {
141
- r.value = !0, e("dismiss"), a && (clearTimeout(a), a = void 0);
145
+ function d() {
146
+ t.value = !0, o("dismiss"), n && (clearTimeout(n), n = void 0);
142
147
  }
143
- const i = f(() => ({
144
- strokeColor: w[o.type].iconColor,
148
+ const u = f(() => ({
149
+ strokeColor: D[e.type].iconColor,
145
150
  class: "my-4px mr-8px"
146
- })), d = f(() => {
147
- switch (o.type) {
151
+ })), w = f(() => {
152
+ switch (e.type) {
148
153
  case "info":
149
154
  return null;
150
155
  case "success":
151
- return () => n(P, i.value);
156
+ return () => a(W, u.value);
152
157
  case "warning":
153
- return () => n(z, i.value);
158
+ return () => a($, u.value);
154
159
  case "error":
155
- return () => n(z, i.value);
160
+ return () => a($, u.value);
156
161
  default:
157
162
  return null;
158
163
  }
159
- });
160
- return (g, G) => r.value ? m("", !0) : (C(), b("div", {
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", o.notRounded ? void 0 : "rounded"])
167
+ class: p(["overflow-hidden text-left", e.notRounded ? void 0 : "rounded"])
163
168
  }, [
164
- v("div", {
165
- class: p(["flex p-16px", t(l).headerClass])
169
+ m("div", {
170
+ class: p(["flex", [r(l).headerClass, r(M)]])
166
171
  }, [
167
- y(g.$slots, "icon", x($(t(i))), () => [
168
- !o.noIcon && t(d) ? (C(), E(H(t(d)), x(M({ key: 0 }, t(i))), null, 16)) : m("", !0)
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
- s.dismissible ? (C(), b("button", {
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: u,
181
+ onClick: d,
177
182
  "aria-label": "Dismiss"
178
183
  }, [
179
- _(t(B), {
180
- "stroke-color": t(l).iconCloseColor
184
+ S(r(Z), {
185
+ "stroke-color": r(l).iconCloseColor
181
186
  }, null, 8, ["stroke-color"])
182
- ])) : m("", !0)
187
+ ])) : g("", !0)
183
188
  ], 2),
184
- t(c).body ? (C(), b("div", {
189
+ r(h).body ? (C(), x("div", {
185
190
  key: 0,
186
- class: p(["p-16px", t(l).bodyClass])
191
+ class: p(["p-16px", r(l).bodyClass])
187
192
  }, [
188
- y(g.$slots, "body", {}, void 0, !0)
189
- ], 2)) : m("", !0),
190
- t(c).details ? (C(), b("details", {
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", [t(l).bodyClass, t(l).borderClass]])
197
+ class: p(["p-16px border-t-1", [r(l).bodyClass, r(l).borderClass]]),
198
+ ref_key: "detailsRef",
199
+ ref: i
193
200
  }, [
194
- v("summary", {
195
- class: p(["flex font-medium cursor-pointer", t(l).detailsHeaderClass])
201
+ m("summary", {
202
+ class: p(["flex font-medium cursor-pointer details-none", r(l).detailsHeaderClass])
196
203
  }, [
197
- _(t(R), {
198
- strokeColor: t(l).iconChevronColor,
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(o.detailsTitle), 1)
208
+ N(" " + O(e.detailsTitle), 1)
202
209
  ], 2),
203
- v("div", W, [
204
- y(g.$slots, "details", {}, void 0, !0)
205
- ])
206
- ], 2)) : m("", !0)
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
- }), F = /* @__PURE__ */ V(L, [["__scopeId", "data-v-5e7e1d8e"]]);
221
+ });
210
222
  export {
211
- F as default
223
+ ee as default
212
224
  };
213
225
 
214
- /* <windicss-keep class="overflow-hidden text-left rounded flex p-16px flex-1 font-medium m-4px ml-8px h-16px border-t-1 cursor-pointer my-4px mr-8px mt-16px transform 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"> */
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