@purpurds/badge 3.0.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/LICENSE.txt +38 -0
- package/dist/badge.cjs.js +10 -0
- package/dist/badge.cjs.js.map +1 -0
- package/dist/badge.d.ts +22 -0
- package/dist/badge.d.ts.map +1 -0
- package/dist/badge.es.js +184 -0
- package/dist/badge.es.js.map +1 -0
- package/dist/badge.system.js +10 -0
- package/dist/badge.system.js.map +1 -0
- package/dist/styles.css +1 -0
- package/package.json +60 -0
- package/readme.mdx +56 -0
- package/src/badge.module.scss +49 -0
- package/src/badge.stories.tsx +29 -0
- package/src/badge.test.tsx +55 -0
- package/src/badge.tsx +64 -0
- package/src/global.d.ts +4 -0
package/dist/badge.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React, { ReactNode } from "react";
|
|
2
|
+
export declare const BADGE_VARIANT: {
|
|
3
|
+
readonly ATTENTION: "attention";
|
|
4
|
+
readonly SPECIAL: "special";
|
|
5
|
+
readonly NEUTRAL: "neutral";
|
|
6
|
+
readonly INFORMATION: "information";
|
|
7
|
+
readonly SUCCESS: "success";
|
|
8
|
+
readonly WARNING: "warning";
|
|
9
|
+
readonly ERROR: "error";
|
|
10
|
+
};
|
|
11
|
+
export declare const badgeVariants: ("attention" | "special" | "neutral" | "information" | "success" | "warning" | "error")[];
|
|
12
|
+
export type BadgeVariant = (typeof BADGE_VARIANT)[keyof typeof BADGE_VARIANT];
|
|
13
|
+
export type BadgeProps = {
|
|
14
|
+
children: ReactNode;
|
|
15
|
+
showIcon?: boolean;
|
|
16
|
+
variant: BadgeVariant;
|
|
17
|
+
["data-testid"]?: string;
|
|
18
|
+
allyLabel?: string;
|
|
19
|
+
className?: string;
|
|
20
|
+
};
|
|
21
|
+
export declare const Badge: ({ children, showIcon, variant, ["data-testid"]: dataTestid, allyLabel, className, ...props }: BadgeProps) => React.JSX.Element;
|
|
22
|
+
//# sourceMappingURL=badge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"badge.d.ts","sourceRoot":"","sources":["../src/badge.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAOzC,eAAO,MAAM,aAAa;;;;;;;;CAQhB,CAAC;AAEX,eAAO,MAAM,aAAa,2FAA+B,CAAC;AAC1D,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,OAAO,aAAa,CAAC,CAAC;AAe9E,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,EAAE,SAAS,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,YAAY,CAAC;IACtB,CAAC,aAAa,CAAC,CAAC,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,eAAO,MAAM,KAAK,iGAQf,UAAU,sBAaZ,CAAC"}
|
package/dist/badge.es.js
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { jsx as d, jsxs as _ } from "react/jsx-runtime";
|
|
2
|
+
function m(e) {
|
|
3
|
+
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
4
|
+
}
|
|
5
|
+
var g = { exports: {} };
|
|
6
|
+
/*!
|
|
7
|
+
Copyright (c) 2018 Jed Watson.
|
|
8
|
+
Licensed under the MIT License (MIT), see
|
|
9
|
+
http://jedwatson.github.io/classnames
|
|
10
|
+
*/
|
|
11
|
+
(function(e) {
|
|
12
|
+
(function() {
|
|
13
|
+
var a = {}.hasOwnProperty;
|
|
14
|
+
function n() {
|
|
15
|
+
for (var r = "", t = 0; t < arguments.length; t++) {
|
|
16
|
+
var u = arguments[t];
|
|
17
|
+
u && (r = o(r, s.call(this, u)));
|
|
18
|
+
}
|
|
19
|
+
return r;
|
|
20
|
+
}
|
|
21
|
+
function s(r) {
|
|
22
|
+
if (typeof r == "string" || typeof r == "number")
|
|
23
|
+
return this && this[r] || r;
|
|
24
|
+
if (typeof r != "object")
|
|
25
|
+
return "";
|
|
26
|
+
if (Array.isArray(r))
|
|
27
|
+
return n.apply(this, r);
|
|
28
|
+
if (r.toString !== Object.prototype.toString && !r.toString.toString().includes("[native code]"))
|
|
29
|
+
return r.toString();
|
|
30
|
+
var t = "";
|
|
31
|
+
for (var u in r)
|
|
32
|
+
a.call(r, u) && r[u] && (t = o(t, this && this[u] || u));
|
|
33
|
+
return t;
|
|
34
|
+
}
|
|
35
|
+
function o(r, t) {
|
|
36
|
+
return t ? r ? r + " " + t : r + t : r;
|
|
37
|
+
}
|
|
38
|
+
e.exports ? (n.default = n, e.exports = n) : window.classNames = n;
|
|
39
|
+
})();
|
|
40
|
+
})(g);
|
|
41
|
+
var h = g.exports;
|
|
42
|
+
const y = /* @__PURE__ */ m(h), w = {
|
|
43
|
+
"purpur-icon": "_purpur-icon_8u1lq_1",
|
|
44
|
+
"purpur-icon--xxs": "_purpur-icon--xxs_8u1lq_4",
|
|
45
|
+
"purpur-icon--xs": "_purpur-icon--xs_8u1lq_8",
|
|
46
|
+
"purpur-icon--sm": "_purpur-icon--sm_8u1lq_12",
|
|
47
|
+
"purpur-icon--md": "_purpur-icon--md_8u1lq_16",
|
|
48
|
+
"purpur-icon--lg": "_purpur-icon--lg_8u1lq_20",
|
|
49
|
+
"purpur-icon--xl": "_purpur-icon--xl_8u1lq_24"
|
|
50
|
+
}, b = {
|
|
51
|
+
name: "alert",
|
|
52
|
+
svg: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="m13.038 7.067-.247 6.876h-1.566l-.247-6.876a1.03 1.03 0 1 1 2.06 0Zm.212 8.917c0 .649-.586 1.234-1.25 1.234-.649 0-1.25-.585-1.25-1.234 0-.633.601-1.234 1.25-1.234.664 0 1.25.601 1.25 1.234Z"/><path fill-rule="evenodd" d="M22 12c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2s10 4.477 10 10Zm-1.75 0a8.25 8.25 0 1 1-16.5 0 8.25 8.25 0 0 1 16.5 0Z" clip-rule="evenodd"/></svg>',
|
|
53
|
+
keywords: ["alert"],
|
|
54
|
+
category: "status"
|
|
55
|
+
}, x = {
|
|
56
|
+
name: "check-circle",
|
|
57
|
+
svg: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M16.487 9.514a.872.872 0 1 0-1.42-1.014l-4.248 5.948-2.18-2.18a.872.872 0 0 0-1.233 1.234l2.908 2.908a.872.872 0 0 0 1.326-.11l4.847-6.786Z"/><path fill-rule="evenodd" d="M22 12c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2s10 4.477 10 10Zm-1.75 0a8.25 8.25 0 1 1-16.5 0 8.25 8.25 0 0 1 16.5 0Z" clip-rule="evenodd"/></svg>',
|
|
58
|
+
keywords: ["check-circle"],
|
|
59
|
+
category: "status"
|
|
60
|
+
}, S = {
|
|
61
|
+
name: "error",
|
|
62
|
+
svg: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path fill-rule="evenodd" d="M10.354 3.05c.732-1.267 2.56-1.267 3.291 0l8.66 15c.732 1.267-.182 2.85-1.645 2.85H3.34c-1.463 0-2.377-1.583-1.646-2.85l8.66-15Zm1.595.862a.092.092 0 0 0-.036.038l-8.66 15a.092.092 0 0 0-.015.05c0 .014.005.032.015.05a.11.11 0 0 0 .036.038.09.09 0 0 0 .05.012H20.66a.088.088 0 0 0 .05-.012.106.106 0 0 0 .037-.038.105.105 0 0 0 .015-.05.092.092 0 0 0-.015-.05l-8.66-15a.092.092 0 0 0-.036-.038A.106.106 0 0 0 12 3.9a.105.105 0 0 0-.05.012Z" clip-rule="evenodd"/><path d="m12.523 14.922.412-6.25a.936.936 0 1 0-1.868 0l.421 6.25h1.035ZM12 17.52c.44 0 .826-.387.826-.815 0-.418-.387-.816-.826-.816-.428 0-.825.398-.825.816 0 .428.397.815.825.815Z"/><path fill-rule="evenodd" d="M12.691 15.096h-1.37l-.431-6.53a1 1 0 0 1 .997-1.066h.227a1 1 0 0 1 .998 1.064l-.42 6.532Zm.244-6.425a.936.936 0 1 0-1.868.002l.421 6.249h1.035l.412-6.25ZM13 16.706c0 .526-.466.99-1 .99-.522 0-1-.463-1-.99 0-.264.125-.51.304-.689.18-.178.429-.301.696-.301.536 0 1 .475 1 .99Zm-.174 0c0 .428-.387.815-.826.815-.428 0-.825-.387-.825-.815 0-.418.397-.816.825-.816.44 0 .826.398.826.816Z" clip-rule="evenodd"/></svg>',
|
|
63
|
+
keywords: ["error"],
|
|
64
|
+
category: "status"
|
|
65
|
+
}, N = y.bind(w), i = "purpur-icon", O = "md", Z = (e) => e.filter((a) => Object.keys(a).length >= 1).map((a) => `${a.name}="${a.value}"`).join(" "), A = ({ content: e = "", title: a } = {}) => {
|
|
66
|
+
const n = [
|
|
67
|
+
{ name: "xmlns", value: "http://www.w3.org/2000/svg" },
|
|
68
|
+
{ name: "fill", value: "currentColor" },
|
|
69
|
+
{ name: "viewBox", value: "0 0 24 24" },
|
|
70
|
+
a ? { name: "role", value: "img" } : { name: "aria-hidden", value: "true" }
|
|
71
|
+
], s = a ? `<title>${a}</title>` : "";
|
|
72
|
+
return `<svg ${Z(n)}>${s}${e}</svg>`;
|
|
73
|
+
}, k = (e) => e.replace(/<(\/?)svg([^>]*)>/g, "").trim(), j = ({
|
|
74
|
+
["data-testid"]: e,
|
|
75
|
+
svg: a,
|
|
76
|
+
allyTitle: n,
|
|
77
|
+
className: s = "",
|
|
78
|
+
size: o = O,
|
|
79
|
+
...r
|
|
80
|
+
}) => {
|
|
81
|
+
const t = A({
|
|
82
|
+
content: k(a.svg),
|
|
83
|
+
title: n
|
|
84
|
+
}), u = N(s, i, `${i}--${o}`);
|
|
85
|
+
return /* @__PURE__ */ d(
|
|
86
|
+
"span",
|
|
87
|
+
{
|
|
88
|
+
"aria-label": n,
|
|
89
|
+
className: u,
|
|
90
|
+
"data-testid": e,
|
|
91
|
+
dangerouslySetInnerHTML: { __html: t },
|
|
92
|
+
...r
|
|
93
|
+
}
|
|
94
|
+
);
|
|
95
|
+
};
|
|
96
|
+
function C(e) {
|
|
97
|
+
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
98
|
+
}
|
|
99
|
+
var f = { exports: {} };
|
|
100
|
+
/*!
|
|
101
|
+
Copyright (c) 2018 Jed Watson.
|
|
102
|
+
Licensed under the MIT License (MIT), see
|
|
103
|
+
http://jedwatson.github.io/classnames
|
|
104
|
+
*/
|
|
105
|
+
(function(e) {
|
|
106
|
+
(function() {
|
|
107
|
+
var a = {}.hasOwnProperty;
|
|
108
|
+
function n() {
|
|
109
|
+
for (var r = "", t = 0; t < arguments.length; t++) {
|
|
110
|
+
var u = arguments[t];
|
|
111
|
+
u && (r = o(r, s(u)));
|
|
112
|
+
}
|
|
113
|
+
return r;
|
|
114
|
+
}
|
|
115
|
+
function s(r) {
|
|
116
|
+
if (typeof r == "string" || typeof r == "number")
|
|
117
|
+
return r;
|
|
118
|
+
if (typeof r != "object")
|
|
119
|
+
return "";
|
|
120
|
+
if (Array.isArray(r))
|
|
121
|
+
return n.apply(null, r);
|
|
122
|
+
if (r.toString !== Object.prototype.toString && !r.toString.toString().includes("[native code]"))
|
|
123
|
+
return r.toString();
|
|
124
|
+
var t = "";
|
|
125
|
+
for (var u in r)
|
|
126
|
+
a.call(r, u) && r[u] && (t = o(t, u));
|
|
127
|
+
return t;
|
|
128
|
+
}
|
|
129
|
+
function o(r, t) {
|
|
130
|
+
return t ? r ? r + " " + t : r + t : r;
|
|
131
|
+
}
|
|
132
|
+
e.exports ? (n.default = n, e.exports = n) : window.classNames = n;
|
|
133
|
+
})();
|
|
134
|
+
})(f);
|
|
135
|
+
var M = f.exports;
|
|
136
|
+
const R = /* @__PURE__ */ C(M), p = {
|
|
137
|
+
"purpur-badge": "_purpur-badge_yhork_1",
|
|
138
|
+
"purpur-badge--attention": "_purpur-badge--attention_yhork_13",
|
|
139
|
+
"purpur-badge--special": "_purpur-badge--special_yhork_17",
|
|
140
|
+
"purpur-badge--neutral": "_purpur-badge--neutral_yhork_21",
|
|
141
|
+
"purpur-badge--information": "_purpur-badge--information_yhork_25",
|
|
142
|
+
"purpur-badge--success": "_purpur-badge--success_yhork_29",
|
|
143
|
+
"purpur-badge--warning": "_purpur-badge--warning_yhork_33",
|
|
144
|
+
"purpur-badge--error": "_purpur-badge--error_yhork_37"
|
|
145
|
+
}, c = "purpur-badge", l = {
|
|
146
|
+
ATTENTION: "attention",
|
|
147
|
+
SPECIAL: "special",
|
|
148
|
+
NEUTRAL: "neutral",
|
|
149
|
+
INFORMATION: "information",
|
|
150
|
+
SUCCESS: "success",
|
|
151
|
+
WARNING: "warning",
|
|
152
|
+
ERROR: "error"
|
|
153
|
+
}, I = Object.values(l), $ = (e) => {
|
|
154
|
+
switch (e) {
|
|
155
|
+
case l.SUCCESS:
|
|
156
|
+
return x;
|
|
157
|
+
case l.WARNING:
|
|
158
|
+
return b;
|
|
159
|
+
case l.ERROR:
|
|
160
|
+
return S;
|
|
161
|
+
default:
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
}, q = ({
|
|
165
|
+
children: e,
|
|
166
|
+
showIcon: a = !0,
|
|
167
|
+
variant: n,
|
|
168
|
+
["data-testid"]: s,
|
|
169
|
+
allyLabel: o,
|
|
170
|
+
className: r = "",
|
|
171
|
+
...t
|
|
172
|
+
}) => {
|
|
173
|
+
const u = $(n), v = R([r, p[c], p[`${c}--${n}`]]);
|
|
174
|
+
return /* @__PURE__ */ _("span", { "aria-label": o, className: v, "data-testid": s, ...t, children: [
|
|
175
|
+
a && u && /* @__PURE__ */ d(j, { "data-testid": `${s}-icon`, allyTitle: o, size: "xs", svg: u }),
|
|
176
|
+
e
|
|
177
|
+
] });
|
|
178
|
+
};
|
|
179
|
+
export {
|
|
180
|
+
l as BADGE_VARIANT,
|
|
181
|
+
q as Badge,
|
|
182
|
+
I as badgeVariants
|
|
183
|
+
};
|
|
184
|
+
//# sourceMappingURL=badge.es.js.map
|