@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")) {
@@ -2021,7 +2050,7 @@ class YumeSidebar extends HTMLElement {
2021
2050
  {
2022
2051
  class: "collapse-btn",
2023
2052
  color: "base",
2024
- "style-type": "flat",
2053
+ "variant": "flat",
2025
2054
  size: cfg.buttonSize,
2026
2055
  "aria-label": isCollapsed
2027
2056
  ? "Expand sidebar"
@@ -2069,7 +2098,7 @@ class YumeSidebar extends HTMLElement {
2069
2098
  const btn = createElement("y-button", {
2070
2099
  id: btnId,
2071
2100
  color: isActive ? "primary" : "base",
2072
- "style-type": "flat",
2101
+ "variant": "flat",
2073
2102
  size: cfg.buttonSize,
2074
2103
  "aria-current": isActive ? "page" : false,
2075
2104
  });
@@ -15,10 +15,17 @@ export class YumeTag extends HTMLElement {
15
15
  /** Size: "small" | "medium" | "large" (default "medium"). */
16
16
  get size(): string;
17
17
  set styleType(val: string);
18
- /** Visual style: "filled" | "outlined" | "flat" (default "filled"). */
18
+ /**
19
+ * Deprecated alias for `variant`. Use `variant` instead; retained for
20
+ * backward compatibility and removed in a future major version.
21
+ */
19
22
  get styleType(): string;
23
+ set variant(val: string);
24
+ /** Visual style: "filled" (default) | "outlined" | "flat". */
25
+ get variant(): string;
20
26
  render(): void;
21
27
  _bindRemoveListener(): void;
22
- _getCustomColorVariant(color: any, styleType: any): any;
28
+ _getCustomColorVariant(color: any, variant: any): any;
23
29
  _getStyle(): string;
30
+ _warnStyleTypeDeprecated(): void;
24
31
  }
@@ -15,10 +15,17 @@ export class YumeTag extends HTMLElement {
15
15
  /** Size: "small" | "medium" | "large" (default "medium"). */
16
16
  get size(): string;
17
17
  set styleType(val: string);
18
- /** Visual style: "filled" | "outlined" | "flat" (default "filled"). */
18
+ /**
19
+ * Deprecated alias for `variant`. Use `variant` instead; retained for
20
+ * backward compatibility and removed in a future major version.
21
+ */
19
22
  get styleType(): string;
23
+ set variant(val: string);
24
+ /** Visual style: "filled" (default) | "outlined" | "flat". */
25
+ get variant(): string;
20
26
  render(): void;
21
27
  _bindRemoveListener(): void;
22
- _getCustomColorVariant(color: any, styleType: any): any;
28
+ _getCustomColorVariant(color: any, variant: any): any;
23
29
  _getStyle(): string;
30
+ _warnStyleTypeDeprecated(): void;
24
31
  }
@@ -4,7 +4,7 @@ var xSvg = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill
4
4
 
5
5
  class YumeTag extends HTMLElement {
6
6
  static get observedAttributes() {
7
- return ["removable", "color", "style-type", "shape", "size"];
7
+ return ["removable", "color", "variant", "style-type", "shape", "size"];
8
8
  }
9
9
 
10
10
  // -------------------------------------------------------------------------
@@ -22,6 +22,10 @@ class YumeTag extends HTMLElement {
22
22
  }
23
23
 
24
24
  attributeChangedCallback(name, oldValue, newValue) {
25
+ if (name === "style-type" && newValue !== null) {
26
+ this._warnStyleTypeDeprecated();
27
+ }
28
+
25
29
  if (oldValue !== newValue) this.render();
26
30
  }
27
31
 
@@ -62,14 +66,29 @@ class YumeTag extends HTMLElement {
62
66
  this.setAttribute("size", val);
63
67
  }
64
68
 
65
- /** Visual style: "filled" | "outlined" | "flat" (default "filled"). */
69
+ /**
70
+ * Deprecated alias for `variant`. Use `variant` instead; retained for
71
+ * backward compatibility and removed in a future major version.
72
+ */
66
73
  get styleType() {
67
- return this.getAttribute("style-type") || "filled";
74
+ return this.variant;
68
75
  }
69
76
  set styleType(val) {
70
77
  this.setAttribute("style-type", val);
71
78
  }
72
79
 
80
+ /** Visual style: "filled" (default) | "outlined" | "flat". */
81
+ get variant() {
82
+ return (
83
+ this.getAttribute("variant") ||
84
+ this.getAttribute("style-type") ||
85
+ "filled"
86
+ );
87
+ }
88
+ set variant(val) {
89
+ this.setAttribute("variant", val);
90
+ }
91
+
73
92
  // -------------------------------------------------------------------------
74
93
  // Public
75
94
  // -------------------------------------------------------------------------
@@ -104,7 +123,7 @@ class YumeTag extends HTMLElement {
104
123
  });
105
124
  }
106
125
 
107
- _getCustomColorVariant(color, styleType) {
126
+ _getCustomColorVariant(color, variant) {
108
127
  const textColor = contrastTextColor(color);
109
128
  const variants = {
110
129
  filled: `
@@ -120,11 +139,11 @@ class YumeTag extends HTMLElement {
120
139
  .remove { color: ${color}; }
121
140
  `,
122
141
  };
123
- return variants[styleType] || variants.filled;
142
+ return variants[variant] || variants.filled;
124
143
  }
125
144
 
126
145
  _getStyle() {
127
- const { color, styleType, shape, size } = this;
146
+ const { color, variant, shape, size } = this;
128
147
 
129
148
  const vars = {
130
149
  primary: [
@@ -226,7 +245,7 @@ class YumeTag extends HTMLElement {
226
245
  `;
227
246
 
228
247
  if (isCustomColor)
229
- return baseStyle + this._getCustomColorVariant(color, styleType);
248
+ return baseStyle + this._getCustomColorVariant(color, variant);
230
249
 
231
250
  const [content, inverse, flatBackground] = varEntry || vars.base;
232
251
 
@@ -245,7 +264,16 @@ class YumeTag extends HTMLElement {
245
264
  `,
246
265
  };
247
266
 
248
- return baseStyle + (styleVariants[styleType] || styleVariants.filled);
267
+ return baseStyle + (styleVariants[variant] || styleVariants.filled);
268
+ }
269
+
270
+ _warnStyleTypeDeprecated() {
271
+ if (YumeTag._styleTypeDeprecationWarned) return;
272
+
273
+ YumeTag._styleTypeDeprecationWarned = true;
274
+ console.warn(
275
+ 'y-tag: the "style-type" attribute is deprecated and will be removed in a future major version. Use "variant" instead.',
276
+ );
249
277
  }
250
278
  }
251
279
 
@@ -125,7 +125,10 @@ class YumeTextarea extends HTMLElement {
125
125
  : "default";
126
126
  }
127
127
  set variant(val) {
128
- this.setAttribute("variant", val === "underline" ? "underline" : "default");
128
+ this.setAttribute(
129
+ "variant",
130
+ val === "underline" ? "underline" : "default",
131
+ );
129
132
  }
130
133
 
131
134
  /** @type {string} The current textarea value. */
@@ -182,6 +185,13 @@ class YumeTextarea extends HTMLElement {
182
185
  // -------------------------------------------------------------------------
183
186
 
184
187
  _bindTextareaListeners() {
188
+ this.inputContainer.addEventListener("mousedown", (e) => {
189
+ if (e.target !== this.textarea) {
190
+ e.preventDefault();
191
+ this.textarea.focus();
192
+ }
193
+ });
194
+
185
195
  this.textarea.addEventListener("input", (e) => {
186
196
  this.setAttribute("value", e.target.value);
187
197
  this._internals.setFormValue(