@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.
Files changed (45) hide show
  1. package/NOTICE +8 -0
  2. package/README.md +16 -0
  3. package/dist/icons/index.js +371 -0
  4. package/dist/icons/package.json +3 -0
  5. package/dist/inc-design-language.css +34 -1
  6. package/dist/inc-design-language.css.map +1 -1
  7. package/dist/inc-design-language.js +1558 -1462
  8. package/dist/inc-design-language.min.css +1 -1
  9. package/dist/inc-design-language.min.css.map +1 -1
  10. package/dist/mcp/components/cards.json +3 -3
  11. package/dist/mcp/components/metrics.json +3 -3
  12. package/dist/mcp/components/states.json +3 -3
  13. package/dist/mcp/examples/data-grid-advanced.json +2 -2
  14. package/dist/mcp/examples/demo.json +2 -2
  15. package/dist/mcp/examples/overlay-workflows.json +2 -2
  16. package/dist/mcp/examples/reference.json +2 -2
  17. package/dist/mcp/examples/states.json +2 -2
  18. package/dist/mcp/examples/web-components.json +2 -2
  19. package/dist/mcp/guides/latest.json +2 -2
  20. package/dist/mcp/guides/package-metadata.json +2 -2
  21. package/dist/mcp/guides/update.json +2 -2
  22. package/dist/mcp/install.json +1 -1
  23. package/dist/mcp/patterns/data-grid-advanced.json +2 -2
  24. package/dist/mcp/patterns/demo.json +2 -2
  25. package/dist/mcp/patterns/overlay-workflows.json +2 -2
  26. package/dist/mcp/patterns/reference.json +2 -2
  27. package/dist/mcp/patterns/states.json +2 -2
  28. package/dist/mcp/patterns/web-components.json +2 -2
  29. package/dist/mcp/resources.json +77 -74
  30. package/dist/mcp/search-index.json +21 -21
  31. package/dist/mcp/update.json +2 -2
  32. package/dist/mcp/worker.mjs +164 -281
  33. package/dist/mcp/worker.mjs.map +2 -2
  34. package/dist/web-components/README.md +4 -0
  35. package/dist/web-components/components/actions.js +149 -2
  36. package/dist/web-components/components/feedback.js +63 -12
  37. package/dist/web-components/index.js +501 -14
  38. package/package.json +10 -3
  39. package/src/icons/index.js +229 -0
  40. package/src/icons/package.json +3 -0
  41. package/src/inc-design-language.js +12 -11
  42. package/src/inc-design-language.scss +38 -1
  43. package/src/web-components/README.md +4 -0
  44. package/src/web-components/components/actions.js +149 -2
  45. 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 AUTO_REFRESH_PAUSE_ICON = `
6
- <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true">
7
- <path d="M4 3h3v10H4zM9 3h3v10H9z"></path>
8
- </svg>`.trim();
9
- const AUTO_REFRESH_PLAY_ICON = `
10
- <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true">
11
- <path d="M4 3.5v9l8-4.5-8-4.5z"></path>
12
- </svg>`.trim();
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
- this.#fallback.icon.textContent = status;
289
- this.#fallback.icon.hidden = !status;
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.innerHTML = this.#isPaused ? AUTO_REFRESH_PLAY_ICON : AUTO_REFRESH_PAUSE_ICON;
926
+ renderDecorativeIcon(this.#parts.toggleIcon, this.#isPaused ? "play" : "pause", 16);
876
927
  }
877
928
  }
878
929