@cypress-design/vue-alert 0.0.2 → 0.1.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.
@@ -3,7 +3,7 @@ import dedent from 'dedent'
3
3
  import { ref } from 'vue'
4
4
  import Alert from './Alert.vue'
5
5
 
6
- export default (() => ({
6
+ export default () => ({
7
7
  setup() {
8
8
  const displayTimedAlert = ref(false)
9
9
  return () => (
@@ -107,4 +107,4 @@ export default (() => ({
107
107
  </div>
108
108
  )
109
109
  },
110
- }))()
110
+ })
package/Alert.stories.mdx CHANGED
@@ -17,7 +17,7 @@ import AlertStory from './Alert.rootstory'
17
17
 
18
18
  <Canvas withSource="none">
19
19
  <Story name="Alert">
20
- {AlertStory()}
20
+ {AlertStory}
21
21
  </Story>
22
22
  </Canvas>
23
23
 
package/Alert.vue CHANGED
@@ -133,8 +133,13 @@ const icon: ComputedRef<FunctionalComponent | null> = computed(() => {
133
133
  </script>
134
134
 
135
135
  <style scoped>
136
+ details :deep(summary::-webkit-details-marker) {
137
+ display: none;
138
+ }
139
+
136
140
  details summary .icon {
137
141
  transform: rotate(-90deg);
142
+ transition: transform 0.2s;
138
143
  }
139
144
 
140
145
  details[open] summary .icon {
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @cypress-design/vue-alert
2
2
 
3
+ ## 0.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#51](https://github.com/cypress-io/cypress-design/pull/51) [`ccd8f9a`](https://github.com/cypress-io/cypress-design/commit/ccd8f9a8feb624c0a52deaa9754c76969f43fc1e) Thanks [@elevatebart](https://github.com/elevatebart)! - in the build asset, add a comment containing all used windicss classes in the component
8
+
9
+ ### Patch Changes
10
+
11
+ - [#46](https://github.com/cypress-io/cypress-design/pull/46) [`2608f59`](https://github.com/cypress-io/cypress-design/commit/2608f59e77f13ebdc25834309bf5d6390b37c350) Thanks [@elevatebart](https://github.com/elevatebart)! - fix alert story and details caret on webkit
12
+
13
+ * [#50](https://github.com/cypress-io/cypress-design/pull/50) [`1cb98e6`](https://github.com/cypress-io/cypress-design/commit/1cb98e6fc921e61e4645cdc9a60d48acb6d812c7) Thanks [@elevatebart](https://github.com/elevatebart)! - animate transition of details caret from closed to open
14
+
15
+ * Updated dependencies [[`ccd8f9a`](https://github.com/cypress-io/cypress-design/commit/ccd8f9a8feb624c0a52deaa9754c76969f43fc1e), [`0866c65`](https://github.com/cypress-io/cypress-design/commit/0866c654f24c36951c98468d789462748606b428), [`43b53eb`](https://github.com/cypress-io/cypress-design/commit/43b53eb6bd10111629239a87374cfcc894eda0e3)]:
16
+ - @cypress-design/vue-icon@0.5.0
17
+
3
18
  ## 0.0.2
4
19
 
5
20
  ### Patch Changes
package/dist/index.es.js CHANGED
@@ -1,223 +1,215 @@
1
- import { defineComponent, ref, useSlots, computed, onMounted, onUnmounted, h, openBlock, createElementBlock, normalizeClass, createElementVNode, unref, createCommentVNode, renderSlot, normalizeProps, guardReactiveProps, createBlock, resolveDynamicComponent, mergeProps, createVNode, createTextVNode, toDisplayString } from 'vue';
2
- import { IconWarningCircle, IconCheckmarkOutline, IconActionDeleteLarge, IconChevronDownSmall } from '@cypress-design/vue-icon';
3
-
4
- const alertClasses = {
5
- neutral: {
6
- headerClass: 'text-gray-800 bg-gray-100',
7
- bodyClass: 'bg-gray-50 text-gray-500',
8
- borderClass: 'border-gray-100',
9
- detailsHeaderClass: 'text-gray-600',
10
- /* <windi-keep strokeColor="gray-600"/> */
11
- iconCloseColor: 'gray-600',
12
- /* <windi-keep strokeColor="gray-500"/> */
13
- iconColor: 'gray-500',
14
- /* <windi-keep strokeColor="gray-300"/> */
15
- iconChevronColor: 'gray-300',
16
- },
17
- info: {
18
- headerClass: 'text-indigo-700 bg-indigo-100',
19
- bodyClass: 'bg-indigo-50 text-indigo-500',
20
- borderClass: 'border-indigo-100',
21
- detailsHeaderClass: 'text-indigo-600',
22
- /* <windi-keep strokeColor="indigo-500"/> */
23
- iconCloseColor: 'indigo-500',
24
- /* <windi-keep strokeColor="indigo-500"/> */
25
- iconColor: 'indigo-500',
26
- /* <windi-keep strokeColor="indigo-300"/> */
27
- iconChevronColor: 'indigo-300',
28
- },
29
- warning: {
30
- headerClass: 'text-orange-700 bg-orange-100',
31
- bodyClass: 'bg-orange-50 text-orange-500',
32
- borderClass: 'border-orange-100',
33
- detailsHeaderClass: 'text-orange-600',
34
- /* <windi-keep strokeColor="orange-500"/> */
35
- iconCloseColor: 'orange-500',
36
- /* <windi-keep strokeColor="orange-400"/> */
37
- iconColor: 'orange-400',
38
- /* <windi-keep strokeColor="orange-300"/> */
39
- iconChevronColor: 'orange-300',
40
- },
41
- error: {
42
- headerClass: 'text-red-700 bg-red-100',
43
- bodyClass: 'bg-red-50 text-red-500',
44
- borderClass: 'border-red-100',
45
- detailsHeaderClass: 'text-red-600',
46
- /* <windi-keep strokeColor="red-500"/> */
47
- iconCloseColor: 'red-500',
48
- /* <windi-keep strokeColor="red-400"/> */
49
- iconColor: 'red-400',
50
- /* <windi-keep strokeColor="red-300"/> */
51
- iconChevronColor: 'red-300',
52
- },
53
- success: {
54
- headerClass: 'text-jade-700 bg-jade-100',
55
- bodyClass: 'bg-jade-50 text-jade-600',
56
- borderClass: 'border-jade-100',
57
- detailsHeaderClass: 'text-jade-600',
58
- /* <windi-keep strokeColor="jade-600"/> */
59
- iconCloseColor: 'jade-600',
60
- /* <windi-keep strokeColor="jade-500"/> */
61
- iconColor: 'jade-500',
62
- /* <windi-keep strokeColor="jade-300"/> */
63
- iconChevronColor: 'jade-300',
64
- },
65
- };
66
-
67
- function styleInject(css, ref) {
68
- if ( ref === void 0 ) ref = {};
69
- var insertAt = ref.insertAt;
70
-
71
- if (!css || typeof document === 'undefined') { return; }
72
-
73
- var head = document.head || document.getElementsByTagName('head')[0];
74
- var style = document.createElement('style');
75
- style.type = 'text/css';
76
-
77
- if (insertAt === 'top') {
78
- if (head.firstChild) {
79
- head.insertBefore(style, head.firstChild);
80
- } else {
81
- head.appendChild(style);
82
- }
83
- } else {
84
- head.appendChild(style);
85
- }
86
-
87
- if (style.styleSheet) {
88
- style.styleSheet.cssText = css;
89
- } else {
90
- style.appendChild(document.createTextNode(css));
91
- }
92
- }
93
-
94
- var css_248z = "\ndetails summary .icon[data-v-836252c4] {\n transform: rotate(-90deg);\n}\ndetails[open] summary .icon[data-v-836252c4] {\n transform: rotate(0);\n}\n";
95
- styleInject(css_248z);
96
-
97
- var _export_sfc = (sfc, props) => {
98
- const target = sfc.__vccOpts || sfc;
99
- for (const [key, val] of props) {
100
- target[key] = val;
1
+ import { h as n, defineComponent as j, ref as E, useSlots as A, computed as f, onMounted as B, onUnmounted as I, openBlock as C, createElementBlock as b, normalizeClass as p, createElementVNode as v, unref as t, renderSlot as y, normalizeProps as x, guardReactiveProps as D, createBlock as S, resolveDynamicComponent as $, mergeProps as H, createCommentVNode as m, createVNode as _, createTextVNode as M, toDisplayString as N } from "vue";
2
+ import * as h from "@cypress-design/icon-registry";
3
+ import { ICON_COLOR_PROP_NAMES as O } from "@cypress-design/icon-registry";
4
+ const k = ({
5
+ body: s,
6
+ compiledClasses: e,
7
+ size: o,
8
+ class: r,
9
+ interactiveColorsOnGroup: c,
10
+ ...l
11
+ }) => {
12
+ const a = Object.keys(l).reduce((i, d) => (O.includes(d) || (i[d] = l[d]), i), {}), u = {
13
+ width: o,
14
+ height: o,
15
+ fill: "none",
16
+ innerHTML: s,
17
+ ...a
18
+ };
19
+ return e.length && (u.class = e.join(" ")), u;
20
+ }, T = (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({
27
+ ...s,
28
+ size: e,
29
+ body: r,
30
+ compiledClasses: o
31
+ }));
32
+ }, P = (s) => {
33
+ const { sizeWithDefault: e, compiledClasses: o } = h.getComponentAttributes({ ...s, availableSizes: ["16"] }), r = {
34
+ 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="#1B1E2E" stroke-width="2" class="icon-dark"/><path d="m6 8 1.5 2L10 6" stroke="#1B1E2E" 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({
39
+ ...s,
40
+ size: e,
41
+ body: r,
42
+ compiledClasses: o
43
+ }));
44
+ }, R = (s) => {
45
+ const { sizeWithDefault: e, compiledClasses: o } = h.getComponentAttributes({ ...s, availableSizes: ["8", "16"] }), r = {
46
+ 8: '<path d="m1 2.5 3 3 3-3" stroke="#1B1E2E" class="icon-dark" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>',
47
+ 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({
52
+ ...s,
53
+ size: e,
54
+ body: r,
55
+ compiledClasses: o
56
+ }));
57
+ }, z = (s) => {
58
+ const { sizeWithDefault: e, compiledClasses: o } = h.getComponentAttributes({ ...s, availableSizes: ["16"] }), r = {
59
+ 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="#DB7903" 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({
64
+ ...s,
65
+ size: e,
66
+ body: r,
67
+ compiledClasses: o
68
+ }));
69
+ }, w = {
70
+ neutral: {
71
+ headerClass: "text-gray-800 bg-gray-100",
72
+ bodyClass: "bg-gray-50 text-gray-500",
73
+ borderClass: "border-gray-100",
74
+ detailsHeaderClass: "text-gray-600",
75
+ iconCloseColor: "gray-600",
76
+ iconColor: "gray-500",
77
+ iconChevronColor: "gray-300"
78
+ },
79
+ info: {
80
+ headerClass: "text-indigo-700 bg-indigo-100",
81
+ bodyClass: "bg-indigo-50 text-indigo-500",
82
+ borderClass: "border-indigo-100",
83
+ detailsHeaderClass: "text-indigo-600",
84
+ iconCloseColor: "indigo-500",
85
+ iconColor: "indigo-500",
86
+ iconChevronColor: "indigo-300"
87
+ },
88
+ warning: {
89
+ headerClass: "text-orange-700 bg-orange-100",
90
+ bodyClass: "bg-orange-50 text-orange-500",
91
+ borderClass: "border-orange-100",
92
+ detailsHeaderClass: "text-orange-600",
93
+ iconCloseColor: "orange-500",
94
+ iconColor: "orange-400",
95
+ iconChevronColor: "orange-300"
96
+ },
97
+ error: {
98
+ headerClass: "text-red-700 bg-red-100",
99
+ bodyClass: "bg-red-50 text-red-500",
100
+ borderClass: "border-red-100",
101
+ detailsHeaderClass: "text-red-600",
102
+ iconCloseColor: "red-500",
103
+ iconColor: "red-400",
104
+ iconChevronColor: "red-300"
105
+ },
106
+ success: {
107
+ headerClass: "text-jade-700 bg-jade-100",
108
+ bodyClass: "bg-jade-50 text-jade-600",
109
+ borderClass: "border-jade-100",
110
+ detailsHeaderClass: "text-jade-600",
111
+ iconCloseColor: "jade-600",
112
+ iconColor: "jade-500",
113
+ iconChevronColor: "jade-300"
101
114
  }
102
- return target;
103
115
  };
104
-
105
- const _hoisted_1 = { class: "flex-1 font-medium" };
106
- const _hoisted_2 = { class: "mt-16px" };
107
- const _sfc_main = /* @__PURE__ */ defineComponent({
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({
108
122
  __name: "Alert",
109
123
  props: {
110
- type: { type: null, required: false, default: "info" },
111
- detailsTitle: { type: String, required: false, default: "Additional details" },
112
- dismissible: { type: Boolean, required: false },
113
- noIcon: { type: Boolean, required: false },
114
- notRounded: { type: Boolean, required: false },
115
- duration: { type: Number, required: false }
124
+ type: { default: "info" },
125
+ detailsTitle: { default: "Additional details" },
126
+ dismissible: { type: Boolean },
127
+ noIcon: { type: Boolean },
128
+ notRounded: { type: Boolean },
129
+ duration: null
116
130
  },
117
131
  emits: ["dismiss"],
118
- setup(__props, { emit }) {
119
- const props = __props;
120
- const dismissed = ref(false);
121
- const slots = useSlots();
122
- const typeClasses = computed(() => {
123
- return alertClasses[props.type];
124
- });
125
- let timeout;
126
- onMounted(() => {
127
- if (props.duration) {
128
- timeout = setTimeout(dismiss, props.duration);
129
- }
130
- });
131
- onUnmounted(() => {
132
- if (timeout) {
133
- clearTimeout(timeout);
134
- }
132
+ setup(s, { emit: e }) {
133
+ const o = s, r = E(!1), c = A(), l = f(() => w[o.type]);
134
+ let a;
135
+ B(() => {
136
+ o.duration && (a = setTimeout(u, o.duration));
137
+ }), I(() => {
138
+ a && clearTimeout(a);
135
139
  });
136
- function dismiss() {
137
- dismissed.value = true;
138
- emit("dismiss");
139
- if (timeout) {
140
- clearTimeout(timeout);
141
- timeout = void 0;
142
- }
140
+ function u() {
141
+ r.value = !0, e("dismiss"), a && (clearTimeout(a), a = void 0);
143
142
  }
144
- const computedIconProps = computed(() => {
145
- return {
146
- strokeColor: alertClasses[props.type].iconColor,
147
- class: "my-4px mr-8px"
148
- };
149
- });
150
- const icon = computed(() => {
151
- switch (props.type) {
143
+ const i = f(() => ({
144
+ strokeColor: w[o.type].iconColor,
145
+ class: "my-4px mr-8px"
146
+ })), d = f(() => {
147
+ switch (o.type) {
152
148
  case "info":
153
149
  return null;
154
150
  case "success":
155
- return () => h(IconCheckmarkOutline, computedIconProps.value);
151
+ return () => n(P, i.value);
156
152
  case "warning":
157
- return () => h(IconWarningCircle, computedIconProps.value);
153
+ return () => n(z, i.value);
158
154
  case "error":
159
- return () => h(IconWarningCircle, computedIconProps.value);
155
+ return () => n(z, i.value);
160
156
  default:
161
157
  return null;
162
158
  }
163
159
  });
164
- return (_ctx, _cache) => {
165
- return !dismissed.value ? (openBlock(), createElementBlock("div", {
166
- key: 0,
167
- class: normalizeClass(["overflow-hidden text-left", props.notRounded ? void 0 : "rounded"])
160
+ return (g, G) => r.value ? m("", !0) : (C(), b("div", {
161
+ key: 0,
162
+ class: p(["overflow-hidden text-left", o.notRounded ? void 0 : "rounded"])
163
+ }, [
164
+ v("div", {
165
+ class: p(["flex p-16px", t(l).headerClass])
168
166
  }, [
169
- createElementVNode("div", {
170
- class: normalizeClass(["flex p-16px", unref(typeClasses).headerClass])
171
- }, [
172
- createCommentVNode(" @slot replace the default left icon here "),
173
- renderSlot(_ctx.$slots, "icon", normalizeProps(guardReactiveProps(unref(computedIconProps))), () => [
174
- !props.noIcon && unref(icon) ? (openBlock(), createBlock(resolveDynamicComponent(unref(icon)), normalizeProps(mergeProps({ key: 0 }, unref(computedIconProps))), null, 16)) : createCommentVNode("v-if", true)
175
- ], true),
176
- createElementVNode("div", _hoisted_1, [
177
- createCommentVNode(" @slot title of the alert "),
178
- renderSlot(_ctx.$slots, "default", {}, void 0, true)
179
- ]),
180
- __props.dismissible ? (openBlock(), createElementBlock("button", {
181
- key: 0,
182
- class: "m-4px ml-8px h-16px",
183
- onClick: dismiss,
184
- "aria-label": "Dismiss"
185
- }, [
186
- createVNode(unref(IconActionDeleteLarge), {
187
- "stroke-color": unref(typeClasses).iconCloseColor
188
- }, null, 8, ["stroke-color"])
189
- ])) : createCommentVNode("v-if", true)
190
- ], 2),
191
- unref(slots).body ? (openBlock(), createElementBlock("div", {
167
+ y(g.$slots, "icon", x(D(t(i))), () => [
168
+ !o.noIcon && t(d) ? (C(), S($(t(d)), x(H({ key: 0 }, t(i))), null, 16)) : m("", !0)
169
+ ], !0),
170
+ v("div", Z, [
171
+ y(g.$slots, "default", {}, void 0, !0)
172
+ ]),
173
+ s.dismissible ? (C(), b("button", {
192
174
  key: 0,
193
- class: normalizeClass(["p-16px", unref(typeClasses).bodyClass])
175
+ class: "m-4px ml-8px h-16px",
176
+ onClick: u,
177
+ "aria-label": "Dismiss"
194
178
  }, [
195
- createCommentVNode(" @slot body/details of the alert "),
196
- renderSlot(_ctx.$slots, "body", {}, void 0, true)
197
- ], 2)) : createCommentVNode("v-if", true),
198
- unref(slots).details ? (openBlock(), createElementBlock("details", {
199
- key: 1,
200
- class: normalizeClass(["p-16px border-t-1", [unref(typeClasses).bodyClass, unref(typeClasses).borderClass]])
179
+ _(t(T), {
180
+ "stroke-color": t(l).iconCloseColor
181
+ }, null, 8, ["stroke-color"])
182
+ ])) : m("", !0)
183
+ ], 2),
184
+ t(c).body ? (C(), b("div", {
185
+ key: 0,
186
+ class: p(["p-16px", t(l).bodyClass])
187
+ }, [
188
+ y(g.$slots, "body", {}, void 0, !0)
189
+ ], 2)) : m("", !0),
190
+ t(c).details ? (C(), b("details", {
191
+ key: 1,
192
+ class: p(["p-16px border-t-1", [t(l).bodyClass, t(l).borderClass]])
193
+ }, [
194
+ v("summary", {
195
+ class: p(["flex font-medium cursor-pointer", t(l).detailsHeaderClass])
201
196
  }, [
202
- createElementVNode("summary", {
203
- class: normalizeClass(["flex font-medium cursor-pointer", unref(typeClasses).detailsHeaderClass])
204
- }, [
205
- createVNode(unref(IconChevronDownSmall), {
206
- strokeColor: unref(typeClasses).iconChevronColor,
207
- class: "icon my-4px mr-8px"
208
- }, null, 8, ["strokeColor"]),
209
- createTextVNode(" " + toDisplayString(props.detailsTitle), 1)
210
- ], 2),
211
- createElementVNode("div", _hoisted_2, [
212
- createCommentVNode("@slot Togglable additional details"),
213
- renderSlot(_ctx.$slots, "details", {}, void 0, true)
214
- ])
215
- ], 2)) : createCommentVNode("v-if", true)
216
- ], 2)) : createCommentVNode("v-if", true);
217
- };
197
+ _(t(R), {
198
+ strokeColor: t(l).iconChevronColor,
199
+ class: "icon my-4px mr-8px"
200
+ }, null, 8, ["strokeColor"]),
201
+ M(" " + N(o.detailsTitle), 1)
202
+ ], 2),
203
+ v("div", W, [
204
+ y(g.$slots, "details", {}, void 0, !0)
205
+ ])
206
+ ], 2)) : m("", !0)
207
+ ], 2));
218
208
  }
219
- });
220
- var Alert = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-836252c4"], ["__file", "/home/runner/work/cypress-design/cypress-design/components/Alert/vue/Alert.vue"]]);
209
+ }), F = /* @__PURE__ */ V(L, [["__scopeId", "data-v-5e7e1d8e"]]);
210
+ export {
211
+ F as default
212
+ };
213
+ /* <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"> */
221
214
 
222
- export { Alert as default };
223
215
  //# sourceMappingURL=index.es.js.map