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