@waggylabs/yumekit 0.5.2 → 0.5.3

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.
@@ -7,6 +7,7 @@ class YumeButton extends HTMLElement {
7
7
  "right-icon",
8
8
  "color",
9
9
  "size",
10
+ "variant",
10
11
  "style-type",
11
12
  "type",
12
13
  "padding-mode",
@@ -59,9 +60,13 @@ class YumeButton extends HTMLElement {
59
60
  }
60
61
  }
61
62
 
63
+ if (name === "style-type" && newValue !== null) {
64
+ this._warnStyleTypeDeprecated();
65
+ }
66
+
62
67
  this._init();
63
68
 
64
- if (["color", "size", "style-type", "disabled"].includes(name)) {
69
+ if (["color", "size", "variant", "style-type", "disabled"].includes(name)) {
65
70
  this._updateStyles();
66
71
  }
67
72
  }
@@ -143,9 +148,12 @@ class YumeButton extends HTMLElement {
143
148
  this.setAttribute("size", val);
144
149
  }
145
150
 
146
- /** Visual style: "filled" | "outlined" | "flat" (default "outlined"). */
151
+ /**
152
+ * Deprecated alias for `variant`. Use `variant` instead; retained for
153
+ * backward compatibility and removed in a future major version.
154
+ */
147
155
  get styleType() {
148
- return this.getAttribute("style-type") || "outlined";
156
+ return this.variant;
149
157
  }
150
158
  set styleType(val) {
151
159
  this.setAttribute("style-type", val);
@@ -188,6 +196,18 @@ class YumeButton extends HTMLElement {
188
196
  this.setAttribute("value", newVal);
189
197
  }
190
198
 
199
+ /** Visual style: "filled" | "outlined" | "flat" (default "outlined"). */
200
+ get variant() {
201
+ return (
202
+ this.getAttribute("variant") ||
203
+ this.getAttribute("style-type") ||
204
+ "outlined"
205
+ );
206
+ }
207
+ set variant(val) {
208
+ this.setAttribute("variant", val);
209
+ }
210
+
191
211
  // -------------------------------------------------------------------------
192
212
  // Public
193
213
  // -------------------------------------------------------------------------
@@ -242,7 +262,7 @@ class YumeButton extends HTMLElement {
242
262
  });
243
263
  }
244
264
 
245
- _applyCustomColorStyles(color, styleType, size) {
265
+ _applyCustomColorStyles(color, variant, size) {
246
266
  const text = contrastTextColor(color);
247
267
  const hover = `color-mix(in srgb, ${color} 85%, black)`;
248
268
  const active = `color-mix(in srgb, ${color} 70%, black)`;
@@ -298,7 +318,7 @@ class YumeButton extends HTMLElement {
298
318
  },
299
319
  };
300
320
 
301
- Object.entries(styles[styleType] || styles.outlined).forEach(
321
+ Object.entries(styles[variant] || styles.outlined).forEach(
302
322
  ([key, val]) => this.button.style.setProperty(key, val),
303
323
  );
304
324
 
@@ -344,11 +364,11 @@ class YumeButton extends HTMLElement {
344
364
  );
345
365
  }
346
366
 
347
- _applyInteractionStyles(vars, styleType) {
348
- if (styleType === "filled") {
367
+ _applyInteractionStyles(vars, variant) {
368
+ if (variant === "filled") {
349
369
  this._applyFilledInteractionStyles(vars);
350
370
  } else {
351
- this._applyUnfilledInteractionStyles(vars, styleType);
371
+ this._applyUnfilledInteractionStyles(vars, variant);
352
372
  }
353
373
  }
354
374
 
@@ -473,7 +493,7 @@ class YumeButton extends HTMLElement {
473
493
  this.shadowRoot.appendChild(style);
474
494
  }
475
495
 
476
- _applyUnfilledInteractionStyles(vars, styleType) {
496
+ _applyUnfilledInteractionStyles(vars, variant) {
477
497
  const borderColor = this._outlineBorderColor(
478
498
  `var(${vars[7]}, var(${vars[0]}, #f7f7fa))`,
479
499
  );
@@ -503,7 +523,7 @@ class YumeButton extends HTMLElement {
503
523
  `var(${vars[6]}, #0c0c0d)`,
504
524
  );
505
525
 
506
- if (styleType === "outlined") {
526
+ if (variant === "outlined") {
507
527
  // Outlined buttons keep their border color across all states
508
528
  this.button.style.setProperty("--hover-border-color", borderColor);
509
529
  this.button.style.setProperty("--focus-border-color", borderColor);
@@ -791,11 +811,11 @@ class YumeButton extends HTMLElement {
791
811
  }
792
812
 
793
813
  _updateStyles() {
794
- const { color, size, styleType } = this;
814
+ const { color, size, variant } = this;
795
815
  const colorVars = this._getColorVarsMap();
796
816
 
797
817
  if (!colorVars[color] && isSafeCssColor(color)) {
798
- this._applyCustomColorStyles(color, styleType, size);
818
+ this._applyCustomColorStyles(color, variant, size);
799
819
  return;
800
820
  }
801
821
 
@@ -824,14 +844,23 @@ class YumeButton extends HTMLElement {
824
844
  },
825
845
  };
826
846
 
827
- const currentStyle = styleVars[styleType] || styleVars.outlined;
847
+ const currentStyle = styleVars[variant] || styleVars.outlined;
828
848
  Object.entries(currentStyle).forEach(([key, value]) => {
829
849
  this.button.style.setProperty(key, value);
830
850
  });
831
851
 
832
- this._applyInteractionStyles(vars, styleType);
852
+ this._applyInteractionStyles(vars, variant);
833
853
  this._applySizeStyles(size);
834
854
  }
855
+
856
+ _warnStyleTypeDeprecated() {
857
+ if (YumeButton._styleTypeDeprecationWarned) return;
858
+
859
+ YumeButton._styleTypeDeprecationWarned = true;
860
+ console.warn(
861
+ 'y-button: the "style-type" attribute is deprecated and will be removed in a future major version. Use "variant" instead.',
862
+ );
863
+ }
835
864
  }
836
865
 
837
866
  if (!customElements.get("y-button")) {
@@ -1395,7 +1424,7 @@ class YumeBanner extends HTMLElement {
1395
1424
  part: "close-btn",
1396
1425
  "aria-label": "Dismiss banner",
1397
1426
  color,
1398
- "style-type": "filled",
1427
+ "variant": "filled",
1399
1428
  size,
1400
1429
  },
1401
1430
  [createElement("y-icon", { name: "x", size: iconSize })],
@@ -32,7 +32,10 @@ export class YumeButton extends HTMLElement {
32
32
  /** Size: "small" | "medium" | "large" (default "medium"). */
33
33
  get size(): string;
34
34
  set styleType(val: string);
35
- /** Visual style: "filled" | "outlined" | "flat" (default "outlined"). */
35
+ /**
36
+ * Deprecated alias for `variant`. Use `variant` instead; retained for
37
+ * backward compatibility and removed in a future major version.
38
+ */
36
39
  get styleType(): string;
37
40
  set type(val: string);
38
41
  /** Button type: "button" | "submit" | "reset" (default "button"). */
@@ -40,13 +43,16 @@ export class YumeButton extends HTMLElement {
40
43
  set value(newVal: any);
41
44
  /** The current selected value(s), comma-separated when 'multiple' is set. */
42
45
  get value(): any;
46
+ set variant(val: string);
47
+ /** Visual style: "filled" | "outlined" | "flat" (default "outlined"). */
48
+ get variant(): string;
43
49
  _addEventListeners(): void;
44
- _applyCustomColorStyles(color: any, styleType: any, size: any): void;
50
+ _applyCustomColorStyles(color: any, variant: any, size: any): void;
45
51
  _applyFilledInteractionStyles(vars: any): void;
46
- _applyInteractionStyles(vars: any, styleType: any): void;
52
+ _applyInteractionStyles(vars: any, variant: any): void;
47
53
  _applySizeStyles(size: any): void;
48
54
  _applyStyles(): void;
49
- _applyUnfilledInteractionStyles(vars: any, styleType: any): void;
55
+ _applyUnfilledInteractionStyles(vars: any, variant: any): void;
50
56
  _getColorVarsMap(): {
51
57
  primary: string[];
52
58
  secondary: string[];
@@ -71,4 +77,5 @@ export class YumeButton extends HTMLElement {
71
77
  _outlineBorder(defaultColor: any): string;
72
78
  _outlineBorderColor(defaultColor: any): string;
73
79
  _updateStyles(): void;
80
+ _warnStyleTypeDeprecated(): void;
74
81
  }
@@ -32,7 +32,10 @@ export class YumeButton extends HTMLElement {
32
32
  /** Size: "small" | "medium" | "large" (default "medium"). */
33
33
  get size(): string;
34
34
  set styleType(val: string);
35
- /** Visual style: "filled" | "outlined" | "flat" (default "outlined"). */
35
+ /**
36
+ * Deprecated alias for `variant`. Use `variant` instead; retained for
37
+ * backward compatibility and removed in a future major version.
38
+ */
36
39
  get styleType(): string;
37
40
  set type(val: string);
38
41
  /** Button type: "button" | "submit" | "reset" (default "button"). */
@@ -40,13 +43,16 @@ export class YumeButton extends HTMLElement {
40
43
  set value(newVal: any);
41
44
  /** The current selected value(s), comma-separated when 'multiple' is set. */
42
45
  get value(): any;
46
+ set variant(val: string);
47
+ /** Visual style: "filled" | "outlined" | "flat" (default "outlined"). */
48
+ get variant(): string;
43
49
  _addEventListeners(): void;
44
- _applyCustomColorStyles(color: any, styleType: any, size: any): void;
50
+ _applyCustomColorStyles(color: any, variant: any, size: any): void;
45
51
  _applyFilledInteractionStyles(vars: any): void;
46
- _applyInteractionStyles(vars: any, styleType: any): void;
52
+ _applyInteractionStyles(vars: any, variant: any): void;
47
53
  _applySizeStyles(size: any): void;
48
54
  _applyStyles(): void;
49
- _applyUnfilledInteractionStyles(vars: any, styleType: any): void;
55
+ _applyUnfilledInteractionStyles(vars: any, variant: any): void;
50
56
  _getColorVarsMap(): {
51
57
  primary: string[];
52
58
  secondary: string[];
@@ -71,4 +77,5 @@ export class YumeButton extends HTMLElement {
71
77
  _outlineBorder(defaultColor: any): string;
72
78
  _outlineBorderColor(defaultColor: any): string;
73
79
  _updateStyles(): void;
80
+ _warnStyleTypeDeprecated(): void;
74
81
  }
@@ -7,6 +7,7 @@ class YumeButton extends HTMLElement {
7
7
  "right-icon",
8
8
  "color",
9
9
  "size",
10
+ "variant",
10
11
  "style-type",
11
12
  "type",
12
13
  "padding-mode",
@@ -59,9 +60,13 @@ class YumeButton extends HTMLElement {
59
60
  }
60
61
  }
61
62
 
63
+ if (name === "style-type" && newValue !== null) {
64
+ this._warnStyleTypeDeprecated();
65
+ }
66
+
62
67
  this._init();
63
68
 
64
- if (["color", "size", "style-type", "disabled"].includes(name)) {
69
+ if (["color", "size", "variant", "style-type", "disabled"].includes(name)) {
65
70
  this._updateStyles();
66
71
  }
67
72
  }
@@ -143,9 +148,12 @@ class YumeButton extends HTMLElement {
143
148
  this.setAttribute("size", val);
144
149
  }
145
150
 
146
- /** Visual style: "filled" | "outlined" | "flat" (default "outlined"). */
151
+ /**
152
+ * Deprecated alias for `variant`. Use `variant` instead; retained for
153
+ * backward compatibility and removed in a future major version.
154
+ */
147
155
  get styleType() {
148
- return this.getAttribute("style-type") || "outlined";
156
+ return this.variant;
149
157
  }
150
158
  set styleType(val) {
151
159
  this.setAttribute("style-type", val);
@@ -188,6 +196,18 @@ class YumeButton extends HTMLElement {
188
196
  this.setAttribute("value", newVal);
189
197
  }
190
198
 
199
+ /** Visual style: "filled" | "outlined" | "flat" (default "outlined"). */
200
+ get variant() {
201
+ return (
202
+ this.getAttribute("variant") ||
203
+ this.getAttribute("style-type") ||
204
+ "outlined"
205
+ );
206
+ }
207
+ set variant(val) {
208
+ this.setAttribute("variant", val);
209
+ }
210
+
191
211
  // -------------------------------------------------------------------------
192
212
  // Public
193
213
  // -------------------------------------------------------------------------
@@ -242,7 +262,7 @@ class YumeButton extends HTMLElement {
242
262
  });
243
263
  }
244
264
 
245
- _applyCustomColorStyles(color, styleType, size) {
265
+ _applyCustomColorStyles(color, variant, size) {
246
266
  const text = contrastTextColor(color);
247
267
  const hover = `color-mix(in srgb, ${color} 85%, black)`;
248
268
  const active = `color-mix(in srgb, ${color} 70%, black)`;
@@ -298,7 +318,7 @@ class YumeButton extends HTMLElement {
298
318
  },
299
319
  };
300
320
 
301
- Object.entries(styles[styleType] || styles.outlined).forEach(
321
+ Object.entries(styles[variant] || styles.outlined).forEach(
302
322
  ([key, val]) => this.button.style.setProperty(key, val),
303
323
  );
304
324
 
@@ -344,11 +364,11 @@ class YumeButton extends HTMLElement {
344
364
  );
345
365
  }
346
366
 
347
- _applyInteractionStyles(vars, styleType) {
348
- if (styleType === "filled") {
367
+ _applyInteractionStyles(vars, variant) {
368
+ if (variant === "filled") {
349
369
  this._applyFilledInteractionStyles(vars);
350
370
  } else {
351
- this._applyUnfilledInteractionStyles(vars, styleType);
371
+ this._applyUnfilledInteractionStyles(vars, variant);
352
372
  }
353
373
  }
354
374
 
@@ -473,7 +493,7 @@ class YumeButton extends HTMLElement {
473
493
  this.shadowRoot.appendChild(style);
474
494
  }
475
495
 
476
- _applyUnfilledInteractionStyles(vars, styleType) {
496
+ _applyUnfilledInteractionStyles(vars, variant) {
477
497
  const borderColor = this._outlineBorderColor(
478
498
  `var(${vars[7]}, var(${vars[0]}, #f7f7fa))`,
479
499
  );
@@ -503,7 +523,7 @@ class YumeButton extends HTMLElement {
503
523
  `var(${vars[6]}, #0c0c0d)`,
504
524
  );
505
525
 
506
- if (styleType === "outlined") {
526
+ if (variant === "outlined") {
507
527
  // Outlined buttons keep their border color across all states
508
528
  this.button.style.setProperty("--hover-border-color", borderColor);
509
529
  this.button.style.setProperty("--focus-border-color", borderColor);
@@ -791,11 +811,11 @@ class YumeButton extends HTMLElement {
791
811
  }
792
812
 
793
813
  _updateStyles() {
794
- const { color, size, styleType } = this;
814
+ const { color, size, variant } = this;
795
815
  const colorVars = this._getColorVarsMap();
796
816
 
797
817
  if (!colorVars[color] && isSafeCssColor(color)) {
798
- this._applyCustomColorStyles(color, styleType, size);
818
+ this._applyCustomColorStyles(color, variant, size);
799
819
  return;
800
820
  }
801
821
 
@@ -824,14 +844,23 @@ class YumeButton extends HTMLElement {
824
844
  },
825
845
  };
826
846
 
827
- const currentStyle = styleVars[styleType] || styleVars.outlined;
847
+ const currentStyle = styleVars[variant] || styleVars.outlined;
828
848
  Object.entries(currentStyle).forEach(([key, value]) => {
829
849
  this.button.style.setProperty(key, value);
830
850
  });
831
851
 
832
- this._applyInteractionStyles(vars, styleType);
852
+ this._applyInteractionStyles(vars, variant);
833
853
  this._applySizeStyles(size);
834
854
  }
855
+
856
+ _warnStyleTypeDeprecated() {
857
+ if (YumeButton._styleTypeDeprecationWarned) return;
858
+
859
+ YumeButton._styleTypeDeprecationWarned = true;
860
+ console.warn(
861
+ 'y-button: the "style-type" attribute is deprecated and will be removed in a future major version. Use "variant" instead.',
862
+ );
863
+ }
835
864
  }
836
865
 
837
866
  if (!customElements.get("y-button")) {
@@ -505,8 +505,14 @@ class YumeCheckbox extends HTMLElement {
505
505
  // -------------------------------------------------------------------------
506
506
 
507
507
  _bindCheckboxListeners() {
508
+ const wrapper = this.shadowRoot.querySelector(".wrapper");
508
509
  const box = this.shadowRoot.querySelector(".checkbox");
509
- box.addEventListener("click", () => this.toggle());
510
+
511
+ wrapper.addEventListener("click", () => {
512
+ if (this.disabled) return;
513
+ box.focus();
514
+ this.toggle();
515
+ });
510
516
  box.addEventListener("keydown", (e) => {
511
517
  if (e.key === " " || e.key === "Enter") {
512
518
  e.preventDefault();
@@ -132,7 +132,10 @@ class YumeInput extends HTMLElement {
132
132
  : "default";
133
133
  }
134
134
  set variant(val) {
135
- this.setAttribute("variant", val === "underline" ? "underline" : "default");
135
+ this.setAttribute(
136
+ "variant",
137
+ val === "underline" ? "underline" : "default",
138
+ );
136
139
  }
137
140
 
138
141
  /** @type {string} Input type (default "text"). */
@@ -200,6 +203,13 @@ class YumeInput extends HTMLElement {
200
203
  // -------------------------------------------------------------------------
201
204
 
202
205
  _bindInputListeners() {
206
+ this.inputContainer.addEventListener("mousedown", (e) => {
207
+ if (e.target !== this.input) {
208
+ e.preventDefault();
209
+ this.input.focus();
210
+ }
211
+ });
212
+
203
213
  this.input.addEventListener("input", (e) => {
204
214
  this.setAttribute("value", e.target.value);
205
215
  this.dispatchEvent(
@@ -1750,7 +1760,7 @@ class YumeSelect extends HTMLElement {
1750
1760
  tag.setAttribute("removable", "");
1751
1761
  tag.setAttribute("size", "small");
1752
1762
  tag.setAttribute("color", opt.color || "primary");
1753
- tag.setAttribute("style-type", "filled");
1763
+ tag.setAttribute("variant", "filled");
1754
1764
  tag.textContent = opt.label;
1755
1765
  tag.dataset.value = opt.value;
1756
1766
 
@@ -132,7 +132,10 @@ class YumeInput extends HTMLElement {
132
132
  : "default";
133
133
  }
134
134
  set variant(val) {
135
- this.setAttribute("variant", val === "underline" ? "underline" : "default");
135
+ this.setAttribute(
136
+ "variant",
137
+ val === "underline" ? "underline" : "default",
138
+ );
136
139
  }
137
140
 
138
141
  /** @type {string} Input type (default "text"). */
@@ -200,6 +203,13 @@ class YumeInput extends HTMLElement {
200
203
  // -------------------------------------------------------------------------
201
204
 
202
205
  _bindInputListeners() {
206
+ this.inputContainer.addEventListener("mousedown", (e) => {
207
+ if (e.target !== this.input) {
208
+ e.preventDefault();
209
+ this.input.focus();
210
+ }
211
+ });
212
+
203
213
  this.input.addEventListener("input", (e) => {
204
214
  this.setAttribute("value", e.target.value);
205
215
  this.dispatchEvent(
@@ -1750,7 +1760,7 @@ class YumeSelect extends HTMLElement {
1750
1760
  tag.setAttribute("removable", "");
1751
1761
  tag.setAttribute("size", "small");
1752
1762
  tag.setAttribute("color", opt.color || "primary");
1753
- tag.setAttribute("style-type", "filled");
1763
+ tag.setAttribute("variant", "filled");
1754
1764
  tag.textContent = opt.label;
1755
1765
  tag.dataset.value = opt.value;
1756
1766