@nysds/nys-badge 1.11.4 → 1.13.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/nys-badge.js +41 -53
- package/dist/nys-badge.js.map +1 -1
- package/package.json +2 -2
package/dist/nys-badge.js
CHANGED
|
@@ -1,30 +1,14 @@
|
|
|
1
|
-
import { LitElement as
|
|
2
|
-
import { property as
|
|
1
|
+
import { LitElement as l, unsafeCSS as d, html as f } from "lit";
|
|
2
|
+
import { property as t } from "lit/decorators.js";
|
|
3
3
|
const b = ':host{--_nys-badge-width: fit-content;--_nys-badge-height: var(--nys-size-600, 48px);--_nys-badge-radius: var(--nys-radius-round, 1776px);--_nys-badge-padding: var(--nys-space-2-px, 2px) var(--nys-space-100, 8px);--_nys-badge-gap: var(--nys-space-50, 4px);--_nys-badge-background-color: var(--nys-color-base-weak, #f6f6f6);--_nys-badge-border-color: var(--nys-color-base, #62666a);--_nys-badge-border-width: var(--nys-border-width-sm, 1px);--_nys-badge-font-size: var(--nys-font-size-ui-sm, 14px);--_nys-badge-font-weight: var(--nys-font-weight-semibold, 600);--_nys-badge-line-height: var(--nys-font-lineheight-ui-sm, 24px);--_nys-badge-font-family: var( --nys-font-family-ui, var( --nys-font-family-sans, "Proxima Nova", "Helvetica Neue", "Helvetica", "Arial", sans-serif ) );--_nys-badge-prefix-font-weight: var(--nys-font-weight-regular, 400)}:host([size=sm]){--_nys-badge-font-size: var(--nys-font-size-ui-xs, 12px);--_nys-badge-line-height: var(--nys-font-lineheight-ui-xs, 20px)}:host([intent=neutral]){--_nys-badge-background-color: var(--nys-color-base-weak, #f6f6f6);--_nys-badge-border-color: var(--nys-color-base, #62666a)}:host([intent=error]){--_nys-badge-background-color: var(--nys-color-error-weak, #f7eaea);--_nys-badge-border-color: var(--nys-color-error-strong, #721c1c)}:host([intent=success]){--_nys-badge-background-color: var(--nys-color-success-weak, #e8f1ea);--_nys-badge-border-color: var(--nys-color-success-strong, #0f3d18)}:host([intent=warning]){--_nys-badge-background-color: var(--nys-color-warning-weak, #fefae5);--_nys-badge-border-color: var(--nys-color-warning-strong, #6a5700)}.nys-badge{display:flex;width:fit-content;align-items:center;justify-content:center;gap:var(--_nys-badge-gap);padding:var(--_nys-badge-padding);border:var(--_nys-badge-border-width) solid var(--_nys-badge-border-color);background-color:var(--_nys-badge-background-color);border-radius:var(--_nys-badge-radius);font-family:var(--_nys-badge-font-family);font-size:var(--_nys-badge-font-size);font-weight:var(--_nys-badge-font-weight);line-height:var(--_nys-badge-line-height);cursor:default;--nys-icon-color: var(--_nys-badge-border-color)}.nys-badge__prefix{font-weight:var(--_nys-badge-prefix-font-weight)}';
|
|
4
|
-
var p = Object.defineProperty, h = Object.getOwnPropertyDescriptor, i = (
|
|
5
|
-
for (var o = a > 1 ? void 0 : a ? h(e, n) : e,
|
|
6
|
-
(
|
|
4
|
+
var p = Object.defineProperty, h = Object.getOwnPropertyDescriptor, i = (g, e, n, a) => {
|
|
5
|
+
for (var o = a > 1 ? void 0 : a ? h(e, n) : e, c = g.length - 1, y; c >= 0; c--)
|
|
6
|
+
(y = g[c]) && (o = (a ? y(e, n, o) : y(o)) || o);
|
|
7
7
|
return a && o && p(e, n, o), o;
|
|
8
|
-
},
|
|
9
|
-
const
|
|
8
|
+
}, r;
|
|
9
|
+
const s = (r = class extends l {
|
|
10
10
|
constructor() {
|
|
11
|
-
super(...arguments), this.id = "", this.name = "", this.
|
|
12
|
-
}
|
|
13
|
-
get size() {
|
|
14
|
-
return this._size;
|
|
15
|
-
}
|
|
16
|
-
set size(e) {
|
|
17
|
-
this._size = s.VALID_SIZES.includes(
|
|
18
|
-
e
|
|
19
|
-
) ? e : "md";
|
|
20
|
-
}
|
|
21
|
-
get intent() {
|
|
22
|
-
return this._intent;
|
|
23
|
-
}
|
|
24
|
-
set intent(e) {
|
|
25
|
-
this._intent = s.VALID_INTENT.includes(
|
|
26
|
-
e
|
|
27
|
-
) ? e : "neutral";
|
|
11
|
+
super(...arguments), this.id = "", this.name = "", this.size = "md", this.intent = "neutral", this.prefixLabel = "", this.label = "", this._prefixIcon = "", this._suffixIcon = "";
|
|
28
12
|
}
|
|
29
13
|
get prefixIcon() {
|
|
30
14
|
return this._prefixIcon;
|
|
@@ -38,6 +22,10 @@ const t = (s = class extends g {
|
|
|
38
22
|
set suffixIcon(e) {
|
|
39
23
|
e === "" || e === null ? this._suffixIcon = !0 : e === "false" || e === !1 ? this._suffixIcon = "" : this._suffixIcon = e;
|
|
40
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Lifecycle methods
|
|
27
|
+
* --------------------------------------------------------------------------
|
|
28
|
+
*/
|
|
41
29
|
connectedCallback() {
|
|
42
30
|
super.connectedCallback();
|
|
43
31
|
const e = this.getAttribute("prefixicon");
|
|
@@ -45,56 +33,56 @@ const t = (s = class extends g {
|
|
|
45
33
|
const n = this.getAttribute("suffixicon");
|
|
46
34
|
n !== null && this.suffixIcon === "" && (this.suffixIcon = n);
|
|
47
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* Resolves which icon should be rendered.
|
|
38
|
+
* @param icon The icon property value (string or boolean)
|
|
39
|
+
* @returns Icon name or null if no icon should be rendered
|
|
40
|
+
*/
|
|
48
41
|
resolveIcon(e) {
|
|
49
|
-
return e === !0 ?
|
|
42
|
+
return e === !0 ? r.DEFAULT_ICONS[this.intent] ?? "info" : typeof e == "string" && e.trim() !== "" ? e : null;
|
|
50
43
|
}
|
|
51
44
|
render() {
|
|
52
45
|
const e = this.resolveIcon(this.prefixIcon), n = this.resolveIcon(this.suffixIcon);
|
|
53
|
-
return
|
|
46
|
+
return f`
|
|
54
47
|
<div class="nys-badge">
|
|
55
|
-
${e ?
|
|
56
|
-
${this.prefixLabel ?
|
|
48
|
+
${e ? f`<nys-icon size="16" name=${e}></nys-icon>` : ""}
|
|
49
|
+
${this.prefixLabel ? f`<div class="nys-badge__prefix">${this.prefixLabel}</div>` : ""}
|
|
57
50
|
<div class="nys-badge__label">${this.label}</div>
|
|
58
|
-
${n ?
|
|
51
|
+
${n ? f`<nys-icon size="16" name=${n}></nys-icon>` : ""}
|
|
59
52
|
</div>
|
|
60
53
|
`;
|
|
61
54
|
}
|
|
62
|
-
},
|
|
63
|
-
"neutral",
|
|
64
|
-
"error",
|
|
65
|
-
"success",
|
|
66
|
-
"warning"
|
|
67
|
-
], s.DEFAULT_ICONS = {
|
|
55
|
+
}, r.styles = d(b), r.DEFAULT_ICONS = {
|
|
68
56
|
neutral: "info",
|
|
69
57
|
error: "emergency_home",
|
|
70
58
|
success: "check_circle",
|
|
71
59
|
warning: "warning"
|
|
72
|
-
},
|
|
60
|
+
}, r);
|
|
73
61
|
i([
|
|
74
|
-
|
|
75
|
-
],
|
|
62
|
+
t({ type: String, reflect: !0 })
|
|
63
|
+
], s.prototype, "id", 2);
|
|
76
64
|
i([
|
|
77
|
-
|
|
78
|
-
],
|
|
65
|
+
t({ type: String, reflect: !0 })
|
|
66
|
+
], s.prototype, "name", 2);
|
|
79
67
|
i([
|
|
80
|
-
|
|
81
|
-
],
|
|
68
|
+
t({ type: String, reflect: !0 })
|
|
69
|
+
], s.prototype, "size", 2);
|
|
82
70
|
i([
|
|
83
|
-
|
|
84
|
-
],
|
|
71
|
+
t({ type: String, reflect: !0 })
|
|
72
|
+
], s.prototype, "intent", 2);
|
|
85
73
|
i([
|
|
86
|
-
|
|
87
|
-
],
|
|
74
|
+
t({ type: String })
|
|
75
|
+
], s.prototype, "prefixLabel", 2);
|
|
88
76
|
i([
|
|
89
|
-
|
|
90
|
-
],
|
|
77
|
+
t({ type: String })
|
|
78
|
+
], s.prototype, "label", 2);
|
|
91
79
|
i([
|
|
92
|
-
|
|
93
|
-
],
|
|
80
|
+
t({ type: String, attribute: "prefixicon" })
|
|
81
|
+
], s.prototype, "prefixIcon", 1);
|
|
94
82
|
i([
|
|
95
|
-
|
|
96
|
-
],
|
|
97
|
-
let u =
|
|
83
|
+
t({ type: String, attribute: "suffixicon" })
|
|
84
|
+
], s.prototype, "suffixIcon", 1);
|
|
85
|
+
let u = s;
|
|
98
86
|
customElements.get("nys-badge") || customElements.define("nys-badge", u);
|
|
99
87
|
export {
|
|
100
88
|
u as NysBadge
|
package/dist/nys-badge.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nys-badge.js","sources":["../src/nys-badge.ts"],"sourcesContent":["import { LitElement, html, unsafeCSS } from \"lit\";\nimport { property } from \"lit/decorators.js\";\n// @ts-ignore: SCSS module imported via bundler as inline\nimport styles from \"./nys-badge.scss?inline\";\n\nexport class NysBadge extends LitElement {\n static styles = unsafeCSS(styles);\n\n @property({ type: String, reflect: true }) id = \"\";\n @property({ type: String, reflect: true }) name = \"\";\n
|
|
1
|
+
{"version":3,"file":"nys-badge.js","sources":["../src/nys-badge.ts"],"sourcesContent":["import { LitElement, html, unsafeCSS } from \"lit\";\nimport { property } from \"lit/decorators.js\";\n// @ts-ignore: SCSS module imported via bundler as inline\nimport styles from \"./nys-badge.scss?inline\";\n\n/**\n * `<nys-badge>` displays a badge with optional prefix/suffix icons and labels.\n *\n * Features:\n * - Conveys an intent (`neutral`, `error`, `success`, `warning`) which affects default icons and styling.\n * - Supports custom prefix and suffix icons.\n */\n\nexport class NysBadge extends LitElement {\n static styles = unsafeCSS(styles);\n\n @property({ type: String, reflect: true }) id = \"\";\n @property({ type: String, reflect: true }) name = \"\";\n @property({ type: String, reflect: true }) size: \"sm\" | \"md\" = \"md\";\n @property({ type: String, reflect: true }) intent:\n | \"neutral\"\n | \"error\"\n | \"success\"\n | \"warning\" = \"neutral\";\n @property({ type: String }) prefixLabel = \"\";\n @property({ type: String }) label = \"\";\n\n // Icons (string or boolean)\n private _prefixIcon: string | boolean = \"\";\n @property({ type: String, attribute: \"prefixicon\" })\n get prefixIcon(): string | boolean {\n return this._prefixIcon;\n }\n set prefixIcon(value: string | boolean) {\n if (value === \"\" || value === null) {\n // boolean attribute without value → true\n this._prefixIcon = true;\n } else if (value === \"false\" || value === false) {\n this._prefixIcon = \"\";\n } else {\n this._prefixIcon = value;\n }\n }\n\n private _suffixIcon: string | boolean = \"\";\n @property({ type: String, attribute: \"suffixicon\" })\n get suffixIcon(): string | boolean {\n return this._suffixIcon;\n }\n set suffixIcon(value: string | boolean) {\n if (value === \"\" || value === null) {\n this._suffixIcon = true;\n } else if (value === \"false\" || value === false) {\n this._suffixIcon = \"\";\n } else {\n this._suffixIcon = value;\n }\n }\n\n /**\n * Lifecycle methods\n * --------------------------------------------------------------------------\n */\n\n connectedCallback() {\n super.connectedCallback();\n\n const attr = this.getAttribute(\"prefixicon\");\n if (attr !== null && this.prefixIcon === \"\") {\n this.prefixIcon = attr;\n }\n\n const suffixAttr = this.getAttribute(\"suffixicon\");\n if (suffixAttr !== null && this.suffixIcon === \"\") {\n this.suffixIcon = suffixAttr;\n }\n }\n\n /**\n * Functions\n * --------------------------------------------------------------------------\n */\n\n // Map of default icons by intent\n private static readonly DEFAULT_ICONS: Record<string, string> = {\n neutral: \"info\",\n error: \"emergency_home\",\n success: \"check_circle\",\n warning: \"warning\",\n };\n\n /**\n * Resolves which icon should be rendered.\n * @param icon The icon property value (string or boolean)\n * @returns Icon name or null if no icon should be rendered\n */\n private resolveIcon(icon: string | boolean): string | null {\n if (icon === true) {\n return NysBadge.DEFAULT_ICONS[this.intent] ?? \"info\";\n }\n if (typeof icon === \"string\" && icon.trim() !== \"\") {\n return icon;\n }\n return null;\n }\n\n render() {\n const prefixIconName = this.resolveIcon(this.prefixIcon);\n const suffixIconName = this.resolveIcon(this.suffixIcon);\n\n return html`\n <div class=\"nys-badge\">\n ${prefixIconName\n ? html`<nys-icon size=\"16\" name=${prefixIconName}></nys-icon>`\n : \"\"}\n ${this.prefixLabel\n ? html`<div class=\"nys-badge__prefix\">${this.prefixLabel}</div>`\n : \"\"}\n <div class=\"nys-badge__label\">${this.label}</div>\n ${suffixIconName\n ? html`<nys-icon size=\"16\" name=${suffixIconName}></nys-icon>`\n : \"\"}\n </div>\n `;\n }\n}\n\nif (!customElements.get(\"nys-badge\")) {\n customElements.define(\"nys-badge\", NysBadge);\n}\n"],"names":["_NysBadge","_a","LitElement","value","attr","suffixAttr","icon","prefixIconName","suffixIconName","html","unsafeCSS","styles","__decorateClass","property","NysBadge"],"mappings":";;;;;;;;AAaO,MAAMA,KAANC,IAAA,cAAuBC,EAAW;AAAA,EAAlC,cAAA;AAAA,UAAA,GAAA,SAAA,GAGsC,KAAA,KAAK,IACL,KAAA,OAAO,IACP,KAAA,OAAoB,MACpB,KAAA,SAI3B,WACY,KAAA,cAAc,IACd,KAAA,QAAQ,IAGpC,KAAQ,cAAgC,IAgBxC,KAAQ,cAAgC;AAAA,EAAA;AAAA,EAdxC,IAAI,aAA+B;AACjC,WAAO,KAAK;AAAA,EACd;AAAA,EACA,IAAI,WAAWC,GAAyB;AACtC,IAAIA,MAAU,MAAMA,MAAU,OAE5B,KAAK,cAAc,KACVA,MAAU,WAAWA,MAAU,KACxC,KAAK,cAAc,KAEnB,KAAK,cAAcA;AAAA,EAEvB;AAAA,EAIA,IAAI,aAA+B;AACjC,WAAO,KAAK;AAAA,EACd;AAAA,EACA,IAAI,WAAWA,GAAyB;AACtC,IAAIA,MAAU,MAAMA,MAAU,OAC5B,KAAK,cAAc,KACVA,MAAU,WAAWA,MAAU,KACxC,KAAK,cAAc,KAEnB,KAAK,cAAcA;AAAA,EAEvB;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,oBAAoB;AAClB,UAAM,kBAAA;AAEN,UAAMC,IAAO,KAAK,aAAa,YAAY;AAC3C,IAAIA,MAAS,QAAQ,KAAK,eAAe,OACvC,KAAK,aAAaA;AAGpB,UAAMC,IAAa,KAAK,aAAa,YAAY;AACjD,IAAIA,MAAe,QAAQ,KAAK,eAAe,OAC7C,KAAK,aAAaA;AAAA,EAEtB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAoBQ,YAAYC,GAAuC;AACzD,WAAIA,MAAS,KACJL,EAAS,cAAc,KAAK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cAAc;AAAA,GAhBxCb,EAiBP,WAAA,cAAA,CAAA;AAgBAY,EAAA;AAAA,EADHC,EAAS,EAAE,MAAM,QAAQ,WAAW,cAAc;AAAA,GAhCxCb,EAiCP,WAAA,cAAA,CAAA;AAjCC,IAAMc,IAANd;AAkHF,eAAe,IAAI,WAAW,KACjC,eAAe,OAAO,aAAac,CAAQ;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nysds/nys-badge",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.13.0",
|
|
4
4
|
"description": "The Badge component from the NYS Design System.",
|
|
5
5
|
"module": "dist/nys-badge.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"lit-analyze": "lit-analyzer '**/*.ts'"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@nysds/nys-icon": "^1.
|
|
26
|
+
"@nysds/nys-icon": "^1.13.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"lit": "^3.3.1",
|