@studious-creative/yumekit 0.1.10 → 0.1.11

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.
@@ -1,3 +1,5 @@
1
+ import { getIcon } from '../icons/registry.js';
2
+
1
3
  class YumeButton extends HTMLElement {
2
4
  static get observedAttributes() {
3
5
  return [
@@ -554,25 +556,6 @@ if (!customElements.get("y-button")) {
554
556
  customElements.define("y-button", YumeButton);
555
557
  }
556
558
 
557
- /**
558
- * Icon registry — a runtime map of icon names to SVG markup strings.
559
- *
560
- * Register only the icons you need for tree-shaking:
561
- *
562
- * import { registerIcon } from "@studious-creative/yumekit";
563
- * registerIcon("home", homeSvgString);
564
- *
565
- * Or register all bundled icons at once (separate import):
566
- *
567
- * import "@studious-creative/yumekit/icons/all.js";
568
- */
569
-
570
- const icons = new Map();
571
-
572
- function getIcon(name) {
573
- return icons.get(name) || "";
574
- }
575
-
576
559
  // Allowlist-based SVG sanitizer — only known-safe elements and attributes are kept.
577
560
  const ALLOWED_ELEMENTS = new Set([
578
561
  "svg",
@@ -1,28 +1,4 @@
1
- /**
2
- * Return a [background, foreground] CSS variable pair for a color scheme.
3
- * Background is `--{color}-content--`, foreground is `--{color}-content-inverse`.
4
- * @param {string} color — one of base, primary, secondary, success, warning, error, help
5
- * @param {string} [fallbackColor="base"] — color to fall back to when `color` is unrecognised.
6
- * Use `null` to pass the raw `color` string through as the background instead.
7
- * @returns {[string, string]} — [bg var, fg var]
8
- */
9
- function getColorVarPair(color, fallbackColor = "base") {
10
- const map = {
11
- base: ["var(--base-content--)", "var(--base-content-inverse)"],
12
- primary: ["var(--primary-content--)", "var(--primary-content-inverse)"],
13
- secondary: [
14
- "var(--secondary-content--)",
15
- "var(--secondary-content-inverse)",
16
- ],
17
- success: ["var(--success-content--)", "var(--success-content-inverse)"],
18
- warning: ["var(--warning-content--)", "var(--warning-content-inverse)"],
19
- error: ["var(--error-content--)", "var(--error-content-inverse)"],
20
- help: ["var(--help-content--)", "var(--help-content-inverse)"],
21
- };
22
- if (map[color]) return map[color];
23
- if (fallbackColor === null) return [color, "var(--base-content-inverse)"];
24
- return map[fallbackColor] || map.base;
25
- }
1
+ import { getColorVarPair } from '../modules/helpers.js';
26
2
 
27
3
  class YumeAvatar extends HTMLElement {
28
4
  static get observedAttributes() {
@@ -1,34 +1,4 @@
1
- /**
2
- * Return a [background, foreground] CSS variable pair for a color scheme.
3
- * Background is `--{color}-content--`, foreground is `--{color}-content-inverse`.
4
- * @param {string} color — one of base, primary, secondary, success, warning, error, help
5
- * @param {string} [fallbackColor="base"] — color to fall back to when `color` is unrecognised.
6
- * Use `null` to pass the raw `color` string through as the background instead.
7
- * @returns {[string, string]} — [bg var, fg var]
8
- */
9
-
10
- // helpers/slot-utils.js
11
- function hideEmptySlotContainers(shadowRoot, slotsConfig = {}) {
12
- Object.entries(slotsConfig).forEach(([slotName, containerSelector]) => {
13
- const slot = shadowRoot.querySelector(
14
- `slot${slotName ? `[name="${slotName}"]` : ":not([name])"}`,
15
- );
16
- const container = shadowRoot.querySelector(containerSelector);
17
-
18
- if (slot && container) {
19
- const assigned = slot
20
- .assignedNodes({ flatten: true })
21
- .filter((n) => {
22
- return !(
23
- n.nodeType === Node.TEXT_NODE &&
24
- n.textContent.trim() === ""
25
- );
26
- });
27
-
28
- container.style.display = assigned.length > 0 ? "" : "none";
29
- }
30
- });
31
- }
1
+ import { hideEmptySlotContainers } from '../modules/helpers.js';
32
2
 
33
3
  class YumeCard extends HTMLElement {
34
4
  static get observedAttributes() {
@@ -1,21 +1,4 @@
1
- /**
2
- * Icon registry — a runtime map of icon names to SVG markup strings.
3
- *
4
- * Register only the icons you need for tree-shaking:
5
- *
6
- * import { registerIcon } from "@studious-creative/yumekit";
7
- * registerIcon("home", homeSvgString);
8
- *
9
- * Or register all bundled icons at once (separate import):
10
- *
11
- * import "@studious-creative/yumekit/icons/all.js";
12
- */
13
-
14
- const icons = new Map();
15
-
16
- function getIcon(name) {
17
- return icons.get(name) || "";
18
- }
1
+ import { getIcon } from '../icons/registry.js';
19
2
 
20
3
  // Allowlist-based SVG sanitizer — only known-safe elements and attributes are kept.
21
4
  const ALLOWED_ELEMENTS = new Set([
@@ -1,28 +1,4 @@
1
- /**
2
- * Return a [background, foreground] CSS variable pair for a color scheme.
3
- * Background is `--{color}-content--`, foreground is `--{color}-content-inverse`.
4
- * @param {string} color — one of base, primary, secondary, success, warning, error, help
5
- * @param {string} [fallbackColor="base"] — color to fall back to when `color` is unrecognised.
6
- * Use `null` to pass the raw `color` string through as the background instead.
7
- * @returns {[string, string]} — [bg var, fg var]
8
- */
9
- function getColorVarPair(color, fallbackColor = "base") {
10
- const map = {
11
- base: ["var(--base-content--)", "var(--base-content-inverse)"],
12
- primary: ["var(--primary-content--)", "var(--primary-content-inverse)"],
13
- secondary: [
14
- "var(--secondary-content--)",
15
- "var(--secondary-content-inverse)",
16
- ],
17
- success: ["var(--success-content--)", "var(--success-content-inverse)"],
18
- warning: ["var(--warning-content--)", "var(--warning-content-inverse)"],
19
- error: ["var(--error-content--)", "var(--error-content-inverse)"],
20
- help: ["var(--help-content--)", "var(--help-content-inverse)"],
21
- };
22
- if (map[color]) return map[color];
23
- if (fallbackColor === null) return [color, "var(--base-content-inverse)"];
24
- return map[fallbackColor] || map.base;
25
- }
1
+ import { getColorVarPair } from '../modules/helpers.js';
26
2
 
27
3
  class YumeProgress extends HTMLElement {
28
4
  static get observedAttributes() {
@@ -1,28 +1,4 @@
1
- /**
2
- * Return a [background, foreground] CSS variable pair for a color scheme.
3
- * Background is `--{color}-content--`, foreground is `--{color}-content-inverse`.
4
- * @param {string} color — one of base, primary, secondary, success, warning, error, help
5
- * @param {string} [fallbackColor="base"] — color to fall back to when `color` is unrecognised.
6
- * Use `null` to pass the raw `color` string through as the background instead.
7
- * @returns {[string, string]} — [bg var, fg var]
8
- */
9
- function getColorVarPair(color, fallbackColor = "base") {
10
- const map = {
11
- base: ["var(--base-content--)", "var(--base-content-inverse)"],
12
- primary: ["var(--primary-content--)", "var(--primary-content-inverse)"],
13
- secondary: [
14
- "var(--secondary-content--)",
15
- "var(--secondary-content-inverse)",
16
- ],
17
- success: ["var(--success-content--)", "var(--success-content-inverse)"],
18
- warning: ["var(--warning-content--)", "var(--warning-content-inverse)"],
19
- error: ["var(--error-content--)", "var(--error-content-inverse)"],
20
- help: ["var(--help-content--)", "var(--help-content-inverse)"],
21
- };
22
- if (map[color]) return map[color];
23
- if (fallbackColor === null) return [color, "var(--base-content-inverse)"];
24
- return map[fallbackColor] || map.base;
25
- }
1
+ import { getColorVarPair } from '../modules/helpers.js';
26
2
 
27
3
  class YumeToast extends HTMLElement {
28
4
  static get observedAttributes() {
@@ -1,28 +1,4 @@
1
- /**
2
- * Return a [background, foreground] CSS variable pair for a color scheme.
3
- * Background is `--{color}-content--`, foreground is `--{color}-content-inverse`.
4
- * @param {string} color — one of base, primary, secondary, success, warning, error, help
5
- * @param {string} [fallbackColor="base"] — color to fall back to when `color` is unrecognised.
6
- * Use `null` to pass the raw `color` string through as the background instead.
7
- * @returns {[string, string]} — [bg var, fg var]
8
- */
9
- function getColorVarPair(color, fallbackColor = "base") {
10
- const map = {
11
- base: ["var(--base-content--)", "var(--base-content-inverse)"],
12
- primary: ["var(--primary-content--)", "var(--primary-content-inverse)"],
13
- secondary: [
14
- "var(--secondary-content--)",
15
- "var(--secondary-content-inverse)",
16
- ],
17
- success: ["var(--success-content--)", "var(--success-content-inverse)"],
18
- warning: ["var(--warning-content--)", "var(--warning-content-inverse)"],
19
- error: ["var(--error-content--)", "var(--error-content-inverse)"],
20
- help: ["var(--help-content--)", "var(--help-content-inverse)"],
21
- };
22
- if (map[color]) return map[color];
23
- if (fallbackColor === null) return [color, "var(--base-content-inverse)"];
24
- return map[fallbackColor] || map.base;
25
- }
1
+ import { getColorVarPair } from '../modules/helpers.js';
26
2
 
27
3
  class YumeTooltip extends HTMLElement {
28
4
  static get observedAttributes() {
package/dist/icons/all.js CHANGED
@@ -1,23 +1,4 @@
1
- /**
2
- * Icon registry — a runtime map of icon names to SVG markup strings.
3
- *
4
- * Register only the icons you need for tree-shaking:
5
- *
6
- * import { registerIcon } from "@studious-creative/yumekit";
7
- * registerIcon("home", homeSvgString);
8
- *
9
- * Or register all bundled icons at once (separate import):
10
- *
11
- * import "@studious-creative/yumekit/icons/all.js";
12
- */
13
-
14
- const icons = new Map();
15
-
16
- function registerIcons(entries) {
17
- for (const [name, svg] of Object.entries(entries)) {
18
- icons.set(name, svg);
19
- }
20
- }
1
+ import { registerIcons } from './registry.js';
21
2
 
22
3
  var ai = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n <path d=\"M12 8V4H8\"/>\n <rect width=\"16\" height=\"12\" x=\"4\" y=\"8\" rx=\"2\"/>\n <path d=\"M2 14h2M20 14h2M15 13v2M9 13v2\"/>\n</svg>\n";
23
4
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@studious-creative/yumekit",
3
- "version": "0.1.10",
3
+ "version": "0.1.11",
4
4
  "description": "Modern Web Component UI Kit",
5
5
  "type": "module",
6
6
  "main": "dist/yumekit.min.js",