@incursa/ui-kit 1.7.0 → 1.8.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/NOTICE +8 -0
- package/README.md +16 -0
- package/dist/icons/index.js +371 -0
- package/dist/icons/package.json +3 -0
- package/dist/inc-design-language.css +34 -1
- package/dist/inc-design-language.css.map +1 -1
- package/dist/inc-design-language.js +1558 -1462
- package/dist/inc-design-language.min.css +1 -1
- package/dist/inc-design-language.min.css.map +1 -1
- package/dist/mcp/components/cards.json +3 -3
- package/dist/mcp/components/metrics.json +3 -3
- package/dist/mcp/components/states.json +3 -3
- package/dist/mcp/examples/data-grid-advanced.json +2 -2
- package/dist/mcp/examples/demo.json +2 -2
- package/dist/mcp/examples/overlay-workflows.json +2 -2
- package/dist/mcp/examples/reference.json +2 -2
- package/dist/mcp/examples/states.json +2 -2
- package/dist/mcp/examples/web-components.json +2 -2
- package/dist/mcp/guides/latest.json +2 -2
- package/dist/mcp/guides/package-metadata.json +2 -2
- package/dist/mcp/guides/update.json +2 -2
- package/dist/mcp/install.json +1 -1
- package/dist/mcp/patterns/data-grid-advanced.json +2 -2
- package/dist/mcp/patterns/demo.json +2 -2
- package/dist/mcp/patterns/overlay-workflows.json +2 -2
- package/dist/mcp/patterns/reference.json +2 -2
- package/dist/mcp/patterns/states.json +2 -2
- package/dist/mcp/patterns/web-components.json +2 -2
- package/dist/mcp/resources.json +77 -74
- package/dist/mcp/search-index.json +21 -21
- package/dist/mcp/update.json +2 -2
- package/dist/mcp/worker.mjs +164 -281
- package/dist/mcp/worker.mjs.map +2 -2
- package/dist/web-components/README.md +4 -0
- package/dist/web-components/components/actions.js +149 -2
- package/dist/web-components/components/feedback.js +63 -12
- package/dist/web-components/index.js +501 -14
- package/package.json +10 -3
- package/src/icons/index.js +229 -0
- package/src/icons/package.json +3 -0
- package/src/inc-design-language.js +12 -11
- package/src/inc-design-language.scss +38 -1
- package/src/web-components/README.md +4 -0
- package/src/web-components/components/actions.js +149 -2
- package/src/web-components/components/feedback.js +63 -12
|
@@ -1,15 +1,30 @@
|
|
|
1
|
+
import {
|
|
2
|
+
incIconNames,
|
|
3
|
+
normalizeIconName,
|
|
4
|
+
replaceIconContents,
|
|
5
|
+
} from "../../icons/index.js";
|
|
6
|
+
|
|
1
7
|
const THEME_MODES = ["light", "dark", "system"];
|
|
2
8
|
const DEFAULT_THEME_STORAGE_KEY = "inc-theme-mode";
|
|
3
9
|
const BADGE_TONES = new Set(["primary", "secondary", "success", "danger", "warning", "info"]);
|
|
4
10
|
const SPINNER_VARIANTS = new Set(["border", "grow"]);
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
const ICON_NAME_SET = new Set(incIconNames);
|
|
12
|
+
const STATE_ICON_BY_VARIANT = new Map([
|
|
13
|
+
["empty", "empty"],
|
|
14
|
+
["results", "no-results"],
|
|
15
|
+
["loading", "loading"],
|
|
16
|
+
["error", "error"],
|
|
17
|
+
["danger", "error"],
|
|
18
|
+
["warning", "warning"],
|
|
19
|
+
["success", "success"],
|
|
20
|
+
["info", "info"],
|
|
21
|
+
]);
|
|
22
|
+
const STATE_ICON_BY_STATUS = new Map([
|
|
23
|
+
["+", "empty"],
|
|
24
|
+
["?", "no-results"],
|
|
25
|
+
["!", "error"],
|
|
26
|
+
["...", "loading"],
|
|
27
|
+
]);
|
|
13
28
|
const HostElement = typeof HTMLElement === "undefined" ? class {} : HTMLElement;
|
|
14
29
|
const themeSubscribers = new Set();
|
|
15
30
|
|
|
@@ -46,6 +61,33 @@ function normalizeToken(value) {
|
|
|
46
61
|
return String(value ?? "").trim().toLowerCase();
|
|
47
62
|
}
|
|
48
63
|
|
|
64
|
+
function resolveStateIconName(icon, status, variant) {
|
|
65
|
+
const explicitIcon = normalizeIconName(icon);
|
|
66
|
+
if (explicitIcon) {
|
|
67
|
+
return explicitIcon;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const normalizedStatus = normalizeIconName(status);
|
|
71
|
+
if (STATE_ICON_BY_STATUS.has(String(status || "").trim())) {
|
|
72
|
+
return STATE_ICON_BY_STATUS.get(String(status || "").trim());
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (ICON_NAME_SET.has(normalizedStatus)) {
|
|
76
|
+
return normalizedStatus;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return STATE_ICON_BY_VARIANT.get(normalizeToken(variant)) || "info";
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function renderDecorativeIcon(container, name, size = 18) {
|
|
83
|
+
replaceIconContents(container, name, {
|
|
84
|
+
className: "inc-icon",
|
|
85
|
+
decorative: true,
|
|
86
|
+
size,
|
|
87
|
+
});
|
|
88
|
+
container.hidden = false;
|
|
89
|
+
}
|
|
90
|
+
|
|
49
91
|
function getSystemTheme() {
|
|
50
92
|
if (!window.matchMedia) {
|
|
51
93
|
return "light";
|
|
@@ -206,7 +248,7 @@ function formatRemaining(totalSeconds) {
|
|
|
206
248
|
}
|
|
207
249
|
|
|
208
250
|
export class IncStatePanel extends HostElement {
|
|
209
|
-
static observedAttributes = ["tone", "variant", "title", "body", "status", "open"];
|
|
251
|
+
static observedAttributes = ["tone", "variant", "title", "body", "status", "icon", "open"];
|
|
210
252
|
|
|
211
253
|
#fallback = null;
|
|
212
254
|
#appliedVariantClass = "";
|
|
@@ -246,6 +288,7 @@ export class IncStatePanel extends HostElement {
|
|
|
246
288
|
actions.className = "inc-state-panel__actions";
|
|
247
289
|
|
|
248
290
|
icon.setAttribute("part", "icon");
|
|
291
|
+
icon.setAttribute("aria-hidden", "true");
|
|
249
292
|
title.setAttribute("part", "title");
|
|
250
293
|
body.setAttribute("part", "body");
|
|
251
294
|
actions.setAttribute("part", "actions");
|
|
@@ -282,11 +325,19 @@ export class IncStatePanel extends HostElement {
|
|
|
282
325
|
const title = this.getAttribute("title") || "";
|
|
283
326
|
const body = this.getAttribute("body") || "";
|
|
284
327
|
const status = this.getAttribute("status") || "";
|
|
328
|
+
const iconName = resolveStateIconName(this.getAttribute("icon"), status, nextVariant);
|
|
285
329
|
|
|
286
330
|
this.#fallback.title.textContent = title;
|
|
287
331
|
this.#fallback.body.textContent = body;
|
|
288
|
-
|
|
289
|
-
|
|
332
|
+
if (iconName === "none") {
|
|
333
|
+
this.#fallback.icon.replaceChildren();
|
|
334
|
+
this.#fallback.icon.hidden = true;
|
|
335
|
+
} else if (ICON_NAME_SET.has(iconName)) {
|
|
336
|
+
renderDecorativeIcon(this.#fallback.icon, iconName, 22);
|
|
337
|
+
} else {
|
|
338
|
+
this.#fallback.icon.textContent = status;
|
|
339
|
+
this.#fallback.icon.hidden = !status;
|
|
340
|
+
}
|
|
290
341
|
this.#fallback.actions.hidden = true;
|
|
291
342
|
}
|
|
292
343
|
|
|
@@ -872,7 +923,7 @@ export class IncAutoRefresh extends HostElement {
|
|
|
872
923
|
}
|
|
873
924
|
|
|
874
925
|
if (this.#parts.toggleIcon instanceof HTMLElement) {
|
|
875
|
-
this.#parts.toggleIcon
|
|
926
|
+
renderDecorativeIcon(this.#parts.toggleIcon, this.#isPaused ? "play" : "pause", 16);
|
|
876
927
|
}
|
|
877
928
|
}
|
|
878
929
|
|