wj-elements 0.1.181 → 0.1.183

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/dist/light.css CHANGED
@@ -254,6 +254,12 @@
254
254
  --wje-button-margin-inline: 0;
255
255
  --wje-button-outline-width: 0.5rem;
256
256
 
257
+ /* Button - Group */
258
+ --wje-button-group-border-radius: var(--wje-border-radius-medium);
259
+ --wje-button-group-border-width: 1px;
260
+ --wje-button-group-border-style: solid;
261
+ --wje-button-group-border-color: var(--wje-color-contrast-3);
262
+
257
263
  /* Card */
258
264
  --wje-card-border-radius: var(--wje-border-radius-large);
259
265
  --wje-card-border-color: transparent;
@@ -505,13 +511,15 @@
505
511
  --wje-select-border-width: 1px;
506
512
  --wje-select-border-style: solid;
507
513
  --wje-select-border-color: var(--wje-border-color);
514
+ --wje-select-border-radius: var(--wje-border-radius-medium) var(--wje-border-radius-medium) 0 0;
508
515
  --wje-select-options-border-width: 1px;
509
516
  --wje-select-options-border-style: var(--wje-border-style);
510
517
  --wje-select-options-border-color: var(--wje-border-color);
518
+ --wje-select-options-border-radius: 0 0 var(--wje-border-radius-medium) var(--wje-border-radius-medium);
511
519
  --wje-select-background: var(--wje-color-contrast-0);
512
520
  --wje-select-line-height: 20px;
513
521
  --wje-select-color: var(--wje-color);
514
- --wje-select-border-radius: var(--wje-border-radius-medium);
522
+
515
523
  --wje-select-margin-bottom: var(--wje-spacing-x-small);
516
524
  --wje-select-find-margin-inline: var(--wje-spacing-x-small);
517
525
  --wje-select-find-margin-block: var(--wje-spacing-x-small);
@@ -543,7 +551,7 @@
543
551
  --wje-textarea-font-family: var(--wje-font-family);
544
552
  --wje-textarea-background-color: var(--wje-background);
545
553
  --wje-textarea-color: var(--wje-color);
546
- --wje-textarea-color-invalid: var(--wje-color-danger);
554
+ --wje-textarea-color-invalid: var(--wje-color-danger-9);
547
555
  --wje-textarea-border-width: 1px;
548
556
  --wje-textarea-border-style: solid;
549
557
  --wje-textarea-border-color: var(--wje-border-color);
@@ -20,6 +20,49 @@ export default class ButtonGroup extends WJElement {
20
20
  * @returns {Array<string>} observedAttributes - The observed attributes array
21
21
  */
22
22
  static get observedAttributes(): Array<string>;
23
+ /**
24
+ * Sets the "active" attribute to indicate the active state.
25
+ * @param {boolean|string|number} value The value to set for the "active" attribute, indicating the active state.
26
+ */
27
+ set active(value: boolean | string | number);
28
+ /**
29
+ * Retrieves the value of the 'active' attribute.
30
+ * If the attribute is not set, it returns false.
31
+ * @returns {string|boolean} The value of the 'active' attribute or false if it is not set.
32
+ */
33
+ get active(): string | boolean;
34
+ /**
35
+ * Sets the color attribute of the element.
36
+ * @param {string} value The value to set for the color attribute.
37
+ */
38
+ set color(value: string);
39
+ /**
40
+ * Retrieves the current value of the 'color' attribute.
41
+ * If the 'color' attribute is not set, it defaults to 'primary'.
42
+ * @returns {string} The value of the 'color' attribute or the default value 'primary'.
43
+ */
44
+ get color(): string;
45
+ /**
46
+ * Sets the round attribute for the element.
47
+ * @param {string} value The value to set for the round attribute.
48
+ */
49
+ set round(value: string);
50
+ /**
51
+ * Returns whether the element has the 'round' attribute.
52
+ * @returns {boolean} True if the 'round' attribute is present, otherwise false.
53
+ */
54
+ get round(): boolean;
55
+ /**
56
+ * Sets the 'fill' attribute of the element.
57
+ * @param {string} value The value to assign to the 'fill' attribute.
58
+ */
59
+ set fill(value: string);
60
+ /**
61
+ * Retrieves the 'fill' attribute of the element. If the 'fill' attribute is not set,
62
+ * it returns the default value 'link'.
63
+ * @returns {string} The value of the 'fill' attribute, or 'link' if the attribute is not present.
64
+ */
65
+ get fill(): string;
23
66
  /**
24
67
  * Draw method for the ButtonGroup element.
25
68
  * @returns {object} fragment - The document fragment
@@ -36,4 +79,18 @@ export default class ButtonGroup extends WJElement {
36
79
  * @returns {object} button - The button element
37
80
  */
38
81
  findButton(el: object): object;
82
+ /**
83
+ * Toggles the state of a group of buttons based on the active button.
84
+ * @param {object} activeButton The button that is currently active.
85
+ * @param {Array<object>} buttons An array of button objects to be toggled.
86
+ * @returns {void} This method does not return a value.
87
+ */
88
+ toggle(activeButton: object, buttons: Array<object>, index: any): void;
89
+ /**
90
+ * Updates the state of a button by removing one mode attribute and setting another mode attribute.
91
+ * @param {HTMLElement} button The button element whose state is to be updated.
92
+ * @param {string} modeToRemove The mode attribute to be removed from the button. Expected values are 'color' or 'fill'.
93
+ * @returns {void}
94
+ */
95
+ updateButtonState(button: HTMLElement, modeToRemove: string): void;
39
96
  }
@@ -42,13 +42,14 @@ export default class Input extends WJElement {
42
42
  */
43
43
  static formAssociated: boolean;
44
44
  /**
45
- * Setter for the invalid attribute.
46
- * @param {boolean} isInvalid Whether the input is invalid.
45
+ * Sets or removes the 'invalid' attribute on an element based on the provided value.
46
+ * @param {boolean} value If true, the 'invalid' attribute is set. If false, the 'invalid' attribute is removed.
47
47
  */
48
- set invalid(isInvalid: boolean);
48
+ set invalid(value: boolean);
49
49
  /**
50
- * Getter for the invalid attribute.
51
- * @returns {boolean} Whether the attribute is present.
50
+ * Gets the value of the 'invalid' attribute.
51
+ * Determines whether the 'invalid' attribute is present on the element.
52
+ * @returns {boolean} True if the 'invalid' attribute is present, otherwise false.
52
53
  */
53
54
  get invalid(): boolean;
54
55
  pristine: boolean;
@@ -61,16 +62,42 @@ export default class Input extends WJElement {
61
62
  */
62
63
  set value(value: string);
63
64
  /**
64
- * Getter for the value attribute.
65
- * @returns {string} The value of the attribute.
65
+ * Retrieves the value from the input element if available; otherwise,
66
+ * returns the internal _value property or an empty string as the default.
67
+ * @returns {string} The current value from the input element, the internal _value, or an empty string.
66
68
  */
67
69
  get value(): string;
68
70
  _value: string;
71
+ /**
72
+ * Sets the label attribute of the element.
73
+ * @param {string} value The value to set as the label attribute.
74
+ */
75
+ set label(value: string);
76
+ /**
77
+ * Retrieves the value of the 'label' attribute if it exists.
78
+ * If the 'label' attribute is not set, it returns false.
79
+ * @returns {string|boolean} The value of the 'label' attribute as a string, or false if the attribute is not set.
80
+ */
81
+ get label(): string | boolean;
82
+ /**
83
+ * Sets the custom error display attribute for an element.
84
+ * @param {boolean} value If true, adds the 'custom-error-display' attribute to the element. If false, removes the attribute from the element.
85
+ */
86
+ set customErrorDisplay(value: boolean);
69
87
  /**
70
88
  * Getter for the customErrorDisplay attribute.
71
89
  * @returns {boolean} Whether the attribute is present.
72
90
  */
73
91
  get customErrorDisplay(): boolean;
92
+ /**
93
+ * Sets the `validateOnChange` property. If set to a truthy value, it adds the
94
+ * `validate-on-change` attribute to the element. If set to a falsy value, it
95
+ * removes the `validate-on-change` attribute from the element.
96
+ * @param {boolean} value Determines whether to add or remove the
97
+ * `validate-on-change` attribute. A truthy value adds the attribute, whereas a
98
+ * falsy value removes it.
99
+ */
100
+ set validateOnChange(value: boolean);
74
101
  /**
75
102
  * Getter for the validateOnChange attribute.
76
103
  * @returns {boolean} Whether the attribute is present.
@@ -116,11 +143,41 @@ export default class Input extends WJElement {
116
143
  * @returns {string} The default value of the input element.
117
144
  */
118
145
  get defaultValue(): string;
146
+ /**
147
+ * Sets or removes the 'clearable' attribute on the element.
148
+ * When set to a truthy value, the 'clearable' attribute is added; when falsy, the attribute is removed.
149
+ * @param {boolean} value Determines whether to set or remove the 'clearable' attribute. If true, the 'clearable' attribute is added. If false, it is removed.
150
+ */
119
151
  set clearable(value: boolean);
152
+ /**
153
+ * Checks if the 'clearable' attribute is present on the element.
154
+ * @returns {boolean} True if the 'clearable' attribute is set, otherwise false.
155
+ */
120
156
  get clearable(): boolean;
157
+ /**
158
+ * Sets the placeholder value for an element. If the provided value is non-empty,
159
+ * it assigns the value to the "placeholder" attribute. Otherwise, it removes
160
+ * the "placeholder" attribute from the element.
161
+ * @param {string} value The placeholder text to set or null/undefined to remove the attribute.
162
+ */
121
163
  set placeholder(value: string);
164
+ /**
165
+ * Retrieves the value of the 'placeholder' attribute from the element.
166
+ * If the attribute is not set, it returns an empty string.
167
+ * @returns {string} The value of the 'placeholder' attribute or an empty string if not set.
168
+ */
122
169
  get placeholder(): string;
170
+ /**
171
+ * Sets the `variant` attribute on the element. If a value is provided, it will set the attribute to the given value.
172
+ * If no value is provided, it removes the `variant` attribute from the element.
173
+ * @param {string} value The value to set for the `variant` attribute. If falsy, the attribute is removed.
174
+ */
123
175
  set variant(value: string);
176
+ /**
177
+ * Retrieves the value of the 'variant' attribute from the element.
178
+ * If the attribute is not set, it defaults to 'default'.
179
+ * @returns {string} The value of the 'variant' attribute or 'default' if not set.
180
+ */
124
181
  get variant(): string;
125
182
  beforeDraw(): void;
126
183
  /**
@@ -155,9 +212,9 @@ export default class Input extends WJElement {
155
212
  validateInput(): void;
156
213
  validationError: string;
157
214
  /**
158
- * @summary Propagates the validation state of the input.
159
- * This method sets the 'invalid' property of the input based on its 'pristine' state and its internal validity state.
160
- * If the input is invalid and the 'customErrorDisplay' property is true, it dispatches an 'invalid' event.
215
+ * Checks and updates the validation state of the component based on its current properties.
216
+ * If the component is invalid and a custom error display is enabled, it dispatches an 'invalid' event.
217
+ * @returns {void} This method does not return a value.
161
218
  */
162
219
  propagateValidation(): void;
163
220
  /**
@@ -1,7 +1,7 @@
1
1
  import { default as WJElement } from '../wje-element/element.js';
2
2
  import { default as Option } from '../wje-option/option.js';
3
- import { default as InfiniteScroll } from '../wje-infinite-scroll/infinite-scroll.element.js';
4
- import { default as List } from '../wje-list/list.element.js';
3
+ import { default as InfiniteScroll } from '../wje-infinite-scroll/infinite-scroll.js';
4
+ import { default as List } from '../wje-list/list.js';
5
5
  /**
6
6
  * `Options` is a custom web component that represents a set of options.
7
7
  * It extends from `WJElement`.
@@ -170,6 +170,8 @@ export default class Select extends WJElement {
170
170
  * @returns {object} The value of the attribute.
171
171
  */
172
172
  get value(): object;
173
+ set required(value: boolean);
174
+ get required(): boolean;
173
175
  /**
174
176
  * Getter for the customErrorDisplay attribute.
175
177
  * @returns {boolean} Whether the attribute is present.
@@ -181,13 +183,16 @@ export default class Select extends WJElement {
181
183
  */
182
184
  get validateOnChange(): boolean;
183
185
  /**
184
- * Setter for the invalid attribute.
185
- * @param {boolean} isInvalid Whether the input is invalid.
186
+ * Sets the 'invalid' property of the element.
187
+ * When set to a truthy value, the 'invalid' attribute is added to the element.
188
+ * When set to a falsy value, the 'invalid' attribute is removed from the element.
189
+ * @param {boolean} value A boolean indicating whether the element is invalid.
186
190
  */
187
- set invalid(isInvalid: boolean);
191
+ set invalid(value: boolean);
188
192
  /**
189
- * Getter for the invalid attribute.
190
- * @returns {boolean} Whether the attribute is present.
193
+ * Retrieves the value of the 'invalid' attribute.
194
+ * This method checks if the 'invalid' attribute is present on the element.
195
+ * @returns {boolean} Returns true if the 'invalid' attribute is present, otherwise false.
191
196
  */
192
197
  get invalid(): boolean;
193
198
  /**
@@ -263,9 +268,9 @@ export default class Select extends WJElement {
263
268
  * The options are determined by combining elements from various sources, including loaded options, added options, and HTML-sourced options.
264
269
  * If a `wje-options` element is present within the component, its loaded options are included in the merged list.
265
270
  * In the absence of a `wje-options` element, duplicates among the added and HTML options are removed, retaining their order.
266
- * @returns {Array<Object>} An array containing all the available options, combining the loaded, added, and HTML-based options, with duplicates removed where applicable.
271
+ * @returns {Array<object>} An array containing all the available options, combining the loaded, added, and HTML-based options, with duplicates removed where applicable.
267
272
  */
268
- get options(): Array<any>;
273
+ get options(): Array<object>;
269
274
  /**
270
275
  * Sets the trigger value.
271
276
  * @param {string} value The trigger value to set.
@@ -276,6 +281,8 @@ export default class Select extends WJElement {
276
281
  * @returns {string} The trigger value.
277
282
  */
278
283
  get trigger(): string;
284
+ set offset(value: string);
285
+ get offset(): string;
279
286
  /**
280
287
  * Draws the component for the select.
281
288
  * @returns {DocumentFragment}
@@ -289,6 +296,7 @@ export default class Select extends WJElement {
289
296
  * @returns {void} Does not return a value. The method operates by updating the state and behavior of the component.
290
297
  */
291
298
  afterDraw(): void;
299
+ pristine: boolean;
292
300
  /**
293
301
  * Handles the option change event.
294
302
  * @param {Event} e The event.
@@ -411,9 +419,31 @@ export default class Select extends WJElement {
411
419
  */
412
420
  htmlSelectedItem(item: any): any;
413
421
  /**
414
- * @summary Callback function that is called when the custom element is associated with a form.
415
- * This function adds an event listener to the form's submit event, which validates the input and propagates the validation.
416
- * @param {HTMLFormElement} form The form the custom element is associated with.
422
+ * Clones and appends an icon from a template with slot "check" to the given option element.
423
+ * @param {HTMLElement} option The target option element where the "check" icon will be added.
424
+ * @returns {void}
425
+ */
426
+ optionCheckSlot(option: HTMLElement): void;
427
+ /**
428
+ * Validates the selection of options in the select element.
429
+ * Checks if the element is required and no option is selected,
430
+ * in which case it sets a validation error with a custom message.
431
+ * If the element passes validation, it clears any existing validation errors.
432
+ *
433
+ * @return {void} Does not return a value.
434
+ */
435
+ validateSelect(): void;
436
+ /**
437
+ * Checks and updates the validation state of the component based on its current properties.
438
+ * If the component is invalid and a custom error display is enabled, it dispatches an 'invalid' event.
439
+ * @returns {void} This method does not return a value.
440
+ */
441
+ propagateValidation(): void;
442
+ showInvalidMessage(): void;
443
+ /**
444
+ * Lifecycle callback invoked when the custom element becomes associated with a form element.
445
+ * @param {HTMLFormElement} form The form element the custom element is associated with.
446
+ * @returns {void}
417
447
  */
418
448
  formAssociatedCallback(form: HTMLFormElement): void;
419
449
  /**
@@ -452,11 +482,5 @@ export default class Select extends WJElement {
452
482
  * @returns {boolean} Returns true if all elements in the `elements` array are found within the `options` array, otherwise returns false.
453
483
  */
454
484
  areAllElementsInOptions(elements: any[], options: any[]): boolean;
455
- /**
456
- * Clones and appends an icon from a template with slot "check" to the given option element.
457
- * @param {HTMLElement} option The target option element where the "check" icon will be added.
458
- * @returns {void}
459
- */
460
- optionCheckSlot(option: HTMLElement): void;
461
485
  #private;
462
486
  }
@@ -65,6 +65,20 @@ export default class Textarea extends WJElement {
65
65
  */
66
66
  get value(): string;
67
67
  _value: string;
68
+ /**
69
+ * Sets the `validateOnChange` property. If set to a truthy value, it adds the
70
+ * `validate-on-change` attribute to the element. If set to a falsy value, it
71
+ * removes the `validate-on-change` attribute from the element.
72
+ * @param {boolean} value Determines whether to add or remove the
73
+ * `validate-on-change` attribute. A truthy value adds the attribute, whereas a
74
+ * falsy value removes it.
75
+ */
76
+ set validateOnChange(value: boolean);
77
+ /**
78
+ * Getter for the validateOnChange attribute.
79
+ * @returns {boolean} Whether the attribute is present.
80
+ */
81
+ get validateOnChange(): boolean;
68
82
  /**
69
83
  * Getter for the form attribute.
70
84
  * @returns {HTMLFormElement} The form the input is associated with.
@@ -121,6 +135,12 @@ export default class Textarea extends WJElement {
121
135
  * @param {Event} e The event object.
122
136
  */
123
137
  counterFn: (e: Event) => void;
138
+ /**
139
+ * @summary Displays the validation message for the input.
140
+ * If the input has a slot named 'error', it sets the text content of the element with attribute 'error-message' inside the slot to the validation message.
141
+ * If the input does not have an 'error' slot, it sets the text content of the errorMessage property to the validation message.
142
+ */
143
+ showInvalidMessage(): void;
124
144
  /**
125
145
  * @summary Validates the input.
126
146
  * This method checks the validity state of the input. If the input is not valid, it iterates over the validity state object.
@@ -2,7 +2,8 @@ var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
4
  import WJElement from "./wje-element.js";
5
- const styles = "/*\n[ WJ Button Group ]\n*/\n\n:host {\n display: inline-block;\n .native-button-group {\n display: flex;\n flex-wrap: nowrap;\n line-height: 1;\n }\n\n slot {\n display: contents;\n }\n}\n\n::slotted(wje-button) {\n margin: 0 !important;\n}\n";
5
+ import { event } from "./event.js";
6
+ const styles = "/*\n[ WJ Button Group ]\n*/\n\n:host {\n --wje-button-outline-width: 0;\n --wje-button-border-color: transparent;\n display: inline-block;\n .native-button-group {\n position: relative;\n }\n .wje-button-group-content {\n display: flex;\n flex-wrap: nowrap;\n slot {\n display: contents;\n }\n }\n .wje-button-group-border {\n top: 0;\n position: absolute;\n width: 100%;\n height: 100%;\n box-sizing: border-box;\n border-radius: var(--wje-button-group-border-radius);\n border-width: var(--wje-button-group-border-width);\n border-style: var(--wje-button-group-border-style);\n border-color: var(--wje-button-group-border-color);\n }\n}\n\n:host([round]) {\n .wje-button-group-border {\n --wje-button-group-border-radius: var(--wje-border-radius-pill);\n }\n}\n\n::slotted(wje-button) {\n margin: 0 !important;\n}\n";
6
7
  class ButtonGroup extends WJElement {
7
8
  /**
8
9
  * ButtonGroup constructor method.
@@ -16,6 +17,65 @@ class ButtonGroup extends WJElement {
16
17
  */
17
18
  __publicField(this, "className", "ButtonGroup");
18
19
  }
20
+ /**
21
+ * Sets the "active" attribute to indicate the active state.
22
+ * @param {boolean|string|number} value The value to set for the "active" attribute, indicating the active state.
23
+ */
24
+ set active(value) {
25
+ this.setAttribute("active", value);
26
+ }
27
+ /**
28
+ * Retrieves the value of the 'active' attribute.
29
+ * If the attribute is not set, it returns false.
30
+ * @returns {string|boolean} The value of the 'active' attribute or false if it is not set.
31
+ */
32
+ get active() {
33
+ return +this.getAttribute("active") || false;
34
+ }
35
+ /**
36
+ * Sets the color attribute of the element.
37
+ * @param {string} value The value to set for the color attribute.
38
+ */
39
+ set color(value) {
40
+ this.setAttribute("color", value);
41
+ }
42
+ /**
43
+ * Retrieves the current value of the 'color' attribute.
44
+ * If the 'color' attribute is not set, it defaults to 'primary'.
45
+ * @returns {string} The value of the 'color' attribute or the default value 'primary'.
46
+ */
47
+ get color() {
48
+ return this.getAttribute("color") || "primary";
49
+ }
50
+ /**
51
+ * Sets the round attribute for the element.
52
+ * @param {string} value The value to set for the round attribute.
53
+ */
54
+ set round(value) {
55
+ this.setAttribute("round", value);
56
+ }
57
+ /**
58
+ * Returns whether the element has the 'round' attribute.
59
+ * @returns {boolean} True if the 'round' attribute is present, otherwise false.
60
+ */
61
+ get round() {
62
+ return this.hasAttribute("round");
63
+ }
64
+ /**
65
+ * Sets the 'fill' attribute of the element.
66
+ * @param {string} value The value to assign to the 'fill' attribute.
67
+ */
68
+ set fill(value) {
69
+ this.setAttribute("fill", value);
70
+ }
71
+ /**
72
+ * Retrieves the 'fill' attribute of the element. If the 'fill' attribute is not set,
73
+ * it returns the default value 'link'.
74
+ * @returns {string} The value of the 'fill' attribute, or 'link' if the attribute is not present.
75
+ */
76
+ get fill() {
77
+ return this.getAttribute("fill") || "link";
78
+ }
19
79
  /**
20
80
  * Get CSS stylesheet for the ButtonGroup element.
21
81
  * @static
@@ -47,9 +107,16 @@ class ButtonGroup extends WJElement {
47
107
  let element = document.createElement("div");
48
108
  element.classList.add("native-button-group");
49
109
  element.setAttribute("part", "native");
50
- this.slotElement = document.createElement("slot");
51
- element.appendChild(this.slotElement);
52
- fragment.appendChild(element);
110
+ let content = document.createElement("div");
111
+ content.classList.add("wje-button-group-content");
112
+ let border = document.createElement("div");
113
+ border.classList.add("wje-button-group-border");
114
+ let slot = document.createElement("slot");
115
+ content.append(slot);
116
+ element.append(border);
117
+ element.append(content);
118
+ fragment.append(element);
119
+ this.slotElement = slot;
53
120
  return fragment;
54
121
  }
55
122
  /**
@@ -61,10 +128,16 @@ class ButtonGroup extends WJElement {
61
128
  let index = slottedElements.indexOf(el);
62
129
  let button = this.findButton(el);
63
130
  if (button) {
64
- button.classList.add("wje-button-group-button");
65
- button.classList.toggle("wje-button-group-first", index === 0);
66
- button.classList.toggle("wje-button-group-inner", index > 0 && index < slottedElements.length - 1);
67
- button.classList.toggle("wje-button-group-last", index === slottedElements.length - 1);
131
+ button.setAttribute("fill", this.fill);
132
+ if (this.round) {
133
+ button.round = true;
134
+ }
135
+ event.addListener(button, "wje-button:click", null, (e) => {
136
+ this.toggle(e.target, slottedElements, index);
137
+ });
138
+ if (this.active && this.active === index + 1) {
139
+ this.updateButtonState(button, "fill");
140
+ }
68
141
  }
69
142
  });
70
143
  }
@@ -77,6 +150,30 @@ class ButtonGroup extends WJElement {
77
150
  const selector = "wje-button";
78
151
  return el.closest(selector) ?? el.querySelector(selector);
79
152
  }
153
+ /**
154
+ * Toggles the state of a group of buttons based on the active button.
155
+ * @param {object} activeButton The button that is currently active.
156
+ * @param {Array<object>} buttons An array of button objects to be toggled.
157
+ * @returns {void} This method does not return a value.
158
+ */
159
+ toggle(activeButton, buttons, index) {
160
+ this.active = index + 1;
161
+ buttons.forEach((button) => {
162
+ const mode = button === activeButton ? "fill" : "color";
163
+ this.updateButtonState(button, mode);
164
+ });
165
+ }
166
+ /**
167
+ * Updates the state of a button by removing one mode attribute and setting another mode attribute.
168
+ * @param {HTMLElement} button The button element whose state is to be updated.
169
+ * @param {string} modeToRemove The mode attribute to be removed from the button. Expected values are 'color' or 'fill'.
170
+ * @returns {void}
171
+ */
172
+ updateButtonState(button, modeToRemove) {
173
+ button.removeAttribute(modeToRemove);
174
+ const modeToSet = modeToRemove === "color" ? "fill" : "color";
175
+ button.setAttribute(modeToSet, this[modeToSet]);
176
+ }
80
177
  }
81
178
  WJElement.define("wje-button-group", ButtonGroup);
82
179
  export {
@@ -1 +1 @@
1
- {"version":3,"file":"wje-button-group.js","sources":["../packages/wje-button-group/button-group.element.js","../packages/wje-button-group/button-group.js"],"sourcesContent":["import { default as WJElement } from '../wje-element/element.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * @summary ButtonGroup class\n * @class\n * @augments WJElement\n * @csspart native - The component's native wrapper.\n * @slot - The button group main content.\n * @csspart native - The component's native wrapper.\n */\n\nexport default class ButtonGroup extends WJElement {\n /**\n * ButtonGroup constructor method.\n * @class\n */\n constructor() {\n super();\n }\n\n /**\n * Class name for the ButtonGroup element\n * @type {string}\n */\n className = 'ButtonGroup';\n\n /**\n * Get CSS stylesheet for the ButtonGroup element.\n * @static\n * @returns {object} styles - The CSS styles\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Get observed attributes for the ButtonGroup element.\n * @static\n * @returns {Array<string>} observedAttributes - The observed attributes array\n */\n static get observedAttributes() {\n return [];\n }\n\n /**\n * Setup attributes for the ButtonGroup element.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n }\n\n /**\n * Draw method for the ButtonGroup element.\n * @returns {object} fragment - The document fragment\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let element = document.createElement('div');\n element.classList.add('native-button-group');\n element.setAttribute('part', 'native');\n\n this.slotElement = document.createElement('slot');\n\n element.appendChild(this.slotElement);\n\n fragment.appendChild(element);\n\n return fragment;\n }\n\n /**\n * After draw method for the ButtonGroup element.\n */\n afterDraw() {\n const slottedElements = [...this.slotElement.assignedElements({ flatten: true })];\n\n slottedElements.forEach((el) => {\n let index = slottedElements.indexOf(el);\n let button = this.findButton(el);\n if (button) {\n button.classList.add('wje-button-group-button');\n button.classList.toggle('wje-button-group-first', index === 0);\n button.classList.toggle('wje-button-group-inner', index > 0 && index < slottedElements.length - 1);\n button.classList.toggle('wje-button-group-last', index === slottedElements.length - 1);\n }\n });\n }\n\n /**\n * Find button method to find the button element.\n * @param {object} el The element\n * @returns {object} button - The button element\n */\n findButton(el) {\n const selector = 'wje-button';\n\n return el.closest(selector) ?? el.querySelector(selector);\n }\n}\n","import { default as WJElement } from '../wje-element/element.js';\nimport ButtonGroup from './button-group.element.js';\n\n// export * from \"./button-group.element.js\";\nexport default ButtonGroup;\n\nWJElement.define('wje-button-group', ButtonGroup);\n"],"names":[],"mappings":";;;;;AAYe,MAAM,oBAAoB,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA,EAK/C,cAAc;AACV,UAAO;AAOX;AAAA;AAAA;AAAA;AAAA,qCAAY;AAAA,EANhB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAaI,WAAW,gBAAgB;AACvB,WAAO;AAAA,EACf;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOI,WAAW,qBAAqB;AAC5B,WAAO,CAAE;AAAA,EACjB;AAAA;AAAA;AAAA;AAAA,EAKI,kBAAkB;AACd,SAAK,eAAe;AAAA,EAC5B;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,OAAO;AACH,QAAI,WAAW,SAAS,uBAAwB;AAEhD,QAAI,UAAU,SAAS,cAAc,KAAK;AAC1C,YAAQ,UAAU,IAAI,qBAAqB;AAC3C,YAAQ,aAAa,QAAQ,QAAQ;AAErC,SAAK,cAAc,SAAS,cAAc,MAAM;AAEhD,YAAQ,YAAY,KAAK,WAAW;AAEpC,aAAS,YAAY,OAAO;AAE5B,WAAO;AAAA,EACf;AAAA;AAAA;AAAA;AAAA,EAKI,YAAY;AACR,UAAM,kBAAkB,CAAC,GAAG,KAAK,YAAY,iBAAiB,EAAE,SAAS,KAAI,CAAE,CAAC;AAEhF,oBAAgB,QAAQ,CAAC,OAAO;AAC5B,UAAI,QAAQ,gBAAgB,QAAQ,EAAE;AACtC,UAAI,SAAS,KAAK,WAAW,EAAE;AAC/B,UAAI,QAAQ;AACR,eAAO,UAAU,IAAI,yBAAyB;AAC9C,eAAO,UAAU,OAAO,0BAA0B,UAAU,CAAC;AAC7D,eAAO,UAAU,OAAO,0BAA0B,QAAQ,KAAK,QAAQ,gBAAgB,SAAS,CAAC;AACjG,eAAO,UAAU,OAAO,yBAAyB,UAAU,gBAAgB,SAAS,CAAC;AAAA,MACrG;AAAA,IACA,CAAS;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOI,WAAW,IAAI;AACX,UAAM,WAAW;AAEjB,WAAO,GAAG,QAAQ,QAAQ,KAAK,GAAG,cAAc,QAAQ;AAAA,EAChE;AACA;AC9FA,UAAU,OAAO,oBAAoB,WAAW;"}
1
+ {"version":3,"file":"wje-button-group.js","sources":["../packages/wje-button-group/button-group.element.js","../packages/wje-button-group/button-group.js"],"sourcesContent":["import { default as WJElement, event } from '../wje-element/element.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * @summary ButtonGroup class\n * @class\n * @augments WJElement\n * @csspart native - The component's native wrapper.\n * @slot - The button group main content.\n * @csspart native - The component's native wrapper.\n */\n\nexport default class ButtonGroup extends WJElement {\n /**\n * ButtonGroup constructor method.\n * @class\n */\n constructor() {\n super();\n }\n\n /**\n * Sets the \"active\" attribute to indicate the active state.\n * @param {boolean|string|number} value The value to set for the \"active\" attribute, indicating the active state.\n */\n set active(value) {\n this.setAttribute('active', value);\n }\n\n /**\n * Retrieves the value of the 'active' attribute.\n * If the attribute is not set, it returns false.\n * @returns {string|boolean} The value of the 'active' attribute or false if it is not set.\n */\n get active() {\n return +this.getAttribute('active') || false;\n }\n\n /**\n * Sets the color attribute of the element.\n * @param {string} value The value to set for the color attribute.\n */\n set color(value) {\n this.setAttribute('color', value);\n }\n\n /**\n * Retrieves the current value of the 'color' attribute.\n * If the 'color' attribute is not set, it defaults to 'primary'.\n * @returns {string} The value of the 'color' attribute or the default value 'primary'.\n */\n get color() {\n return this.getAttribute('color') || 'primary';\n }\n\n /**\n * Sets the round attribute for the element.\n * @param {string} value The value to set for the round attribute.\n */\n set round(value) {\n this.setAttribute('round', value);\n }\n\n /**\n * Returns whether the element has the 'round' attribute.\n * @returns {boolean} True if the 'round' attribute is present, otherwise false.\n */\n get round() {\n return this.hasAttribute('round');\n }\n\n /**\n * Sets the 'fill' attribute of the element.\n * @param {string} value The value to assign to the 'fill' attribute.\n */\n set fill(value) {\n this.setAttribute('fill', value);\n }\n\n /**\n * Retrieves the 'fill' attribute of the element. If the 'fill' attribute is not set,\n * it returns the default value 'link'.\n * @returns {string} The value of the 'fill' attribute, or 'link' if the attribute is not present.\n */\n get fill() {\n return this.getAttribute('fill') || 'link';\n }\n\n /**\n * Class name for the ButtonGroup element\n * @type {string}\n */\n className = 'ButtonGroup';\n\n /**\n * Get CSS stylesheet for the ButtonGroup element.\n * @static\n * @returns {object} styles - The CSS styles\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Get observed attributes for the ButtonGroup element.\n * @static\n * @returns {Array<string>} observedAttributes - The observed attributes array\n */\n static get observedAttributes() {\n return [];\n }\n\n /**\n * Setup attributes for the ButtonGroup element.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n }\n\n /**\n * Draw method for the ButtonGroup element.\n * @returns {object} fragment - The document fragment\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let element = document.createElement('div');\n element.classList.add('native-button-group');\n element.setAttribute('part', 'native');\n\n let content = document.createElement('div');\n content.classList.add('wje-button-group-content');\n\n let border = document.createElement('div');\n border.classList.add('wje-button-group-border');\n\n let slot = document.createElement('slot');\n\n content.append(slot);\n\n element.append(border);\n element.append(content);\n\n fragment.append(element);\n\n this.slotElement = slot;\n\n return fragment;\n }\n\n /**\n * After draw method for the ButtonGroup element.\n */\n afterDraw() {\n const slottedElements = [...this.slotElement.assignedElements({ flatten: true })];\n\n slottedElements.forEach((el) => {\n let index = slottedElements.indexOf(el);\n let button = this.findButton(el);\n if (button) {\n button.setAttribute('fill', this.fill);\n if(this.round) {\n button.round = true;\n }\n\n event.addListener(button, 'wje-button:click', null,(e) => {\n this.toggle(e.target, slottedElements, index);\n });\n\n if(this.active && this.active === index + 1) {\n this.updateButtonState(button, 'fill')\n }\n }\n });\n }\n\n /**\n * Find button method to find the button element.\n * @param {object} el The element\n * @returns {object} button - The button element\n */\n findButton(el) {\n const selector = 'wje-button';\n\n return el.closest(selector) ?? el.querySelector(selector);\n }\n\n /**\n * Toggles the state of a group of buttons based on the active button.\n * @param {object} activeButton The button that is currently active.\n * @param {Array<object>} buttons An array of button objects to be toggled.\n * @returns {void} This method does not return a value.\n */\n toggle(activeButton, buttons, index) {\n this.active = index + 1;\n buttons.forEach(button => {\n const mode = button === activeButton ? 'fill' : 'color';\n this.updateButtonState(button, mode);\n });\n }\n\n /**\n * Updates the state of a button by removing one mode attribute and setting another mode attribute.\n * @param {HTMLElement} button The button element whose state is to be updated.\n * @param {string} modeToRemove The mode attribute to be removed from the button. Expected values are 'color' or 'fill'.\n * @returns {void}\n */\n updateButtonState(button, modeToRemove) {\n button.removeAttribute(modeToRemove);\n\n const modeToSet = modeToRemove === 'color' ? 'fill' : 'color';\n button.setAttribute(modeToSet, this[modeToSet]);\n }\n}\n","import { default as WJElement } from '../wje-element/element.js';\nimport ButtonGroup from './button-group.element.js';\n\n// export * from \"./button-group.element.js\";\nexport default ButtonGroup;\n\nWJElement.define('wje-button-group', ButtonGroup);\n"],"names":[],"mappings":";;;;;;AAYe,MAAM,oBAAoB,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA,EAK/C,cAAc;AACV,UAAO;AA0EX;AAAA;AAAA;AAAA;AAAA,qCAAY;AAAA,EAzEhB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,IAAI,OAAO,OAAO;AACd,SAAK,aAAa,UAAU,KAAK;AAAA,EACzC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOI,IAAI,SAAS;AACT,WAAO,CAAC,KAAK,aAAa,QAAQ,KAAK;AAAA,EAC/C;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,IAAI,MAAM,OAAO;AACb,SAAK,aAAa,SAAS,KAAK;AAAA,EACxC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOI,IAAI,QAAQ;AACR,WAAO,KAAK,aAAa,OAAO,KAAK;AAAA,EAC7C;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,IAAI,MAAM,OAAO;AACb,SAAK,aAAa,SAAS,KAAK;AAAA,EACxC;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,IAAI,QAAQ;AACR,WAAO,KAAK,aAAa,OAAO;AAAA,EACxC;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,IAAI,KAAK,OAAO;AACZ,SAAK,aAAa,QAAQ,KAAK;AAAA,EACvC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOI,IAAI,OAAO;AACP,WAAO,KAAK,aAAa,MAAM,KAAK;AAAA,EAC5C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAaI,WAAW,gBAAgB;AACvB,WAAO;AAAA,EACf;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOI,WAAW,qBAAqB;AAC5B,WAAO,CAAE;AAAA,EACjB;AAAA;AAAA;AAAA;AAAA,EAKI,kBAAkB;AACd,SAAK,eAAe;AAAA,EAC5B;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,OAAO;AACH,QAAI,WAAW,SAAS,uBAAwB;AAEhD,QAAI,UAAU,SAAS,cAAc,KAAK;AAC1C,YAAQ,UAAU,IAAI,qBAAqB;AAC3C,YAAQ,aAAa,QAAQ,QAAQ;AAErC,QAAI,UAAU,SAAS,cAAc,KAAK;AAC1C,YAAQ,UAAU,IAAI,0BAA0B;AAEhD,QAAI,SAAS,SAAS,cAAc,KAAK;AACzC,WAAO,UAAU,IAAI,yBAAyB;AAE9C,QAAI,OAAO,SAAS,cAAc,MAAM;AAExC,YAAQ,OAAO,IAAI;AAEnB,YAAQ,OAAO,MAAM;AACrB,YAAQ,OAAO,OAAO;AAEtB,aAAS,OAAO,OAAO;AAEvB,SAAK,cAAc;AAEnB,WAAO;AAAA,EACf;AAAA;AAAA;AAAA;AAAA,EAKI,YAAY;AACR,UAAM,kBAAkB,CAAC,GAAG,KAAK,YAAY,iBAAiB,EAAE,SAAS,KAAI,CAAE,CAAC;AAEhF,oBAAgB,QAAQ,CAAC,OAAO;AAC5B,UAAI,QAAQ,gBAAgB,QAAQ,EAAE;AACtC,UAAI,SAAS,KAAK,WAAW,EAAE;AAC/B,UAAI,QAAQ;AACR,eAAO,aAAa,QAAQ,KAAK,IAAI;AACrC,YAAG,KAAK,OAAO;AACX,iBAAO,QAAQ;AAAA,QACnC;AAEgB,cAAM,YAAY,QAAQ,oBAAoB,MAAK,CAAC,MAAM;AACtD,eAAK,OAAO,EAAE,QAAQ,iBAAiB,KAAK;AAAA,QAChE,CAAiB;AAED,YAAG,KAAK,UAAU,KAAK,WAAW,QAAQ,GAAG;AACzC,eAAK,kBAAkB,QAAQ,MAAM;AAAA,QACzD;AAAA,MACA;AAAA,IACA,CAAS;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOI,WAAW,IAAI;AACX,UAAM,WAAW;AAEjB,WAAO,GAAG,QAAQ,QAAQ,KAAK,GAAG,cAAc,QAAQ;AAAA,EAChE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQI,OAAO,cAAc,SAAS,OAAO;AACjC,SAAK,SAAS,QAAQ;AACtB,YAAQ,QAAQ,YAAU;AACtB,YAAM,OAAO,WAAW,eAAe,SAAS;AAChD,WAAK,kBAAkB,QAAQ,IAAI;AAAA,IAC/C,CAAS;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQI,kBAAkB,QAAQ,cAAc;AACpC,WAAO,gBAAgB,YAAY;AAEnC,UAAM,YAAY,iBAAiB,UAAU,SAAS;AACtD,WAAO,aAAa,WAAW,KAAK,SAAS,CAAC;AAAA,EACtD;AACA;AC/MA,UAAU,OAAO,oBAAoB,WAAW;"}
@@ -14,7 +14,7 @@ import WJElement from "./wje-element.js";
14
14
  import { I as Icon } from "./icon-DY5AZ6xM.js";
15
15
  import { WjElementUtils } from "./element-utils.js";
16
16
  import { event } from "./event.js";
17
- const styles = "/*\n[ WJ Button ]\n*/\n\n/*PRIMARY*/\n.wje-button-solid.wje-color-primary {\n background-color: var(--wje-color-primary-9);\n border-color: var(--wje-color-primary-9);\n color: var(--wje-color-contrast-0);\n}\n\n.wje-button-outline.wje-color-primary {\n background-color: var(--wje-color-primary-1);\n border-color: var(--wje-color-primary-9);\n color: var(--wje-color-primary-9);\n}\n\n.wje-button-link.wje-color-primary {\n background-color: transparent;\n border-color: transparent;\n color: var(--wje-color-primary-9);\n}\n\n/*COMPLETE*/\n.wje-button-solid.wje-color-complete {\n background-color: var(--wje-color-complete-9);\n border-color: var(--wje-color-complete-9);\n color: var(--wje-color-contrast-0);\n}\n\n.wje-button-outline.wje-color-complete {\n background-color: var(--wje-color-complete-1);\n border-color: var(--wje-color-complete-9);\n color: var(--wje-color-complete-9);\n}\n\n.wje-button-link.wje-color-complete {\n background-color: transparent;\n border-color: transparent;\n color: var(--wje-color-complete-9);\n}\n\n/*SUCCESS*/\n.wje-button-solid.wje-color-success {\n background-color: var(--wje-color-success-9);\n border-color: var(--wje-color-success-9);\n color: var(--wje-color-contrast-0);\n}\n\n.wje-button-outline.wje-color-success {\n background-color: var(--wje-color-success-1);\n border-color: var(--wje-color-success-9);\n color: var(--wje-color-success-9);\n}\n\n.wje-button-link.wje-color-success {\n background-color: transparent;\n border-color: transparent;\n color: var(--wje-color-success-9);\n}\n\n/*WARNING*/\n.wje-button-solid.wje-color-warning {\n background-color: var(--wje-color-warning-9);\n border-color: var(--wje-color-warning-9);\n color: var(--wje-color-black);\n}\n\n.wje-button-outline.wje-color-warning {\n background-color: var(--wje-color-warning-1);\n border-color: var(--wje-color-warning-11);\n color: var(--wje-color-warning-11);\n}\n\n.wje-button-link.wje-color-warning {\n background-color: transparent;\n border-color: transparent;\n color: var(--wje-color-warning-11);\n}\n\n/*DANGER*/\n.wje-button-solid.wje-color-danger {\n background-color: var(--wje-color-danger-9);\n border-color: var(--wje-color-danger-9);\n color: var(--wje-color-contrast-0);\n}\n\n.wje-button-outline.wje-color-danger {\n background-color: var(--wje-color-danger-1);\n border-color: var(--wje-color-danger-9);\n color: var(--wje-color-danger-9);\n}\n\n.wje-button-link.wje-color-danger {\n background-color: transparent;\n border-color: transparent;\n color: var(--wje-color-danger-9);\n}\n\n/*NEUTRAL*/\n.wje-button-solid.wje-color-info {\n background-color: var(--wje-color-contrast-9);\n border-color: var(--wje-color-contrast-9);\n color: var(--wje-color-contrast-0);\n}\n\n.wje-button-outline.wje-color-info {\n background-color: var(--wje-color-contrast-1);\n border-color: var(--wje-color-contrast-9);\n color: var(--wje-color-contrast-9);\n}\n\n.wje-button-link.wje-color-info {\n background-color: transparent;\n border-color: transparent;\n color: var(--wje-color-contrast-9);\n}\n\n/*DEFAULT*/\n.wje-button-solid.wje-color-default {\n background-color: var(--wje-color-contrast-0);\n border-color: var(--wje-color-contrast-3);\n color: var(--wje-color-contrast-11);\n}\n\n.wje-button-outline.wje-color-default {\n background-color: var(--wje-color-contrast-1);\n border-color: var(--wje-color-contrast-5);\n color: var(--wje-color-contrast-11);\n}\n\n.wje-button-link.wje-color-default {\n background-color: transparent;\n border-color: transparent;\n color: var(--wje-color-contrast-11);\n}\n\n:host {\n --wje-padding-top: 0.4rem;\n --wje-padding-start: 0.5rem;\n --wje-padding-end: 0.5rem;\n --wje-padding-bottom: 0.4rem;\n\n display: inline-flex;\n position: relative;\n width: auto;\n cursor: pointer;\n margin-inline: var(--wje-button-margin-inline);\n}\n\n:host(.wje-button-group-button) {\n display: block;\n}\n\n.native-button {\n font-family: var(--wje-font-family);\n font-size: var(--wje-font-size);\n display: flex;\n position: relative;\n align-items: center;\n width: 100%;\n height: 100%;\n min-height: inherit;\n /*overflow: hidden;*/ /* Sposobovalo problemy s badge a tooltip */\n border-width: var(--wje-button-border-width);\n border-style: var(--wje-button-border-style);\n border-color: var(--wje-button-border-color);\n background-color: transparent;\n /*color: var(--wje-button-color);*/\n line-height: 1;\n contain: layout style;\n cursor: pointer;\n z-index: 0;\n box-sizing: border-box;\n appearance: none;\n margin: 0;\n border-radius: var(--wje-button-border-radius);\n padding-top: var(--wje-padding-top);\n padding-bottom: var(--wje-padding-bottom);\n padding-inline: var(--wje-padding-start) var(--wje-padding-end);\n white-space: nowrap;\n}\n\n.native-button:hover {\n outline-style: solid;\n outline-width: var(--wje-button-outline-width);\n transition: outline-width 0.1s linear;\n}\n\n@media (any-hover: hover) {\n .wje-button-solid.wje-color-primary:hover {\n background-color: var(--wje-color-primary-9);\n border-color: var(--wje-color-primary-9);\n color: var(--wje-color-contrast-0);\n outline-color: var(--wje-color-primary-2);\n }\n\n .wje-button-outline.wje-color-primary:hover {\n background-color: var(--wje-color-primary-1);\n border-color: var(--wje-color-primary-9);\n color: var(--wje-color-primary-9);\n outline-color: var(--wje-color-primary-2);\n }\n\n .wje-button-link.wje-color-primary:hover {\n background-color: var(--wje-color-primary-1);\n border-color: transparent;\n color: var(--wje-color-primary-9);\n outline-color: transparent;\n outline-width: 0;\n }\n\n .wje-button-solid.wje-color-complete:hover {\n background-color: var(--wje-color-complete-9);\n border-color: var(--wje-color-complete-9);\n color: var(--wje-color-contrast-0);\n outline-color: var(--wje-color-complete-2);\n }\n\n .wje-button-outline.wje-color-complete:hover {\n background-color: var(--wje-color-complete-1);\n border-color: var(--wje-color-complete-9);\n color: var(--wje-color-complete-9);\n outline-color: var(--wje-color-complete-2);\n }\n\n .wje-button-link.wje-color-complete:hover {\n background-color: var(--wje-color-complete-1);\n border-color: transparent;\n color: var(--wje-color-complete-9);\n outline-color: transparent;\n outline-width: 0;\n }\n\n .wje-button-solid.wje-color-success:hover {\n background-color: var(--wje-color-success-9);\n border-color: var(--wje-color-success-9);\n color: var(--wje-color-contrast-0);\n outline-color: var(--wje-color-success-2);\n }\n\n .wje-button-outline.wje-color-success:hover {\n background-color: var(--wje-color-success-1);\n border-color: var(--wje-color-success-9);\n color: var(--wje-color-success-9);\n outline-color: var(--wje-color-success-2);\n }\n\n .wje-button-link.wje-color-success:hover {\n background-color: var(--wje-color-success-1);\n border-color: transparent;\n color: var(--wje-color-success-9);\n outline-color: transparent;\n outline-width: 0;\n }\n\n .wje-button-solid.wje-color-warning:hover {\n background-color: var(--wje-color-warning-9);\n border-color: var(--wje-color-warning-9);\n color: var(--wje-color-black);\n outline-color: var(--wje-color-warning-2);\n }\n\n .wje-button-outline.wje-color-warning:hover {\n background-color: var(--wje-color-warning-1);\n border-color: var(--wje-color-warning-11);\n color: var(--wje-color-warning-11);\n outline-color: var(--wje-color-warning-2);\n }\n\n .wje-button-link.wje-color-warning:hover {\n background-color: var(--wje-color-warning-1);\n border-color: transparent;\n color: var(--wje-color-warning-11);\n outline-color: transparent;\n outline-width: 0;\n }\n\n .wje-button-solid.wje-color-danger:hover {\n background-color: var(--wje-color-danger-9);\n border-color: var(--wje-color-danger-9);\n color: var(--wje-color-contrast-0);\n outline-color: var(--wje-color-danger-2);\n }\n\n .wje-button-outline.wje-color-danger:hover {\n background-color: var(--wje-color-danger-1);\n border-color: var(--wje-color-danger-9);\n color: var(--wje-color-danger-9);\n outline-color: var(--wje-color-danger-2);\n }\n\n .wje-button-link.wje-color-danger:hover {\n background-color: var(--wje-color-danger-1);\n border-color: transparent;\n color: var(--wje-color-danger-9);\n outline-color: transparent;\n outline-width: 0;\n }\n\n .wje-button-solid.wje-color-info:hover {\n background-color: var(--wje-color-contrast-9);\n border-color: var(--wje-color-contrast-9);\n color: var(--wje-color-contrast-0);\n outline-color: var(--wje-color-contrast-3);\n }\n\n .wje-button-outline.wje-color-info:hover {\n background-color: var(--wje-color-contrast-1);\n border-color: var(--wje-color-contrast-9);\n color: var(--wje-color-contrast-9);\n outline-color: var(--wje-color-contrast-3);\n }\n\n .wje-button-link.wje-color-info:hover {\n background-color: var(--wje-color-contrast-3);\n border-color: transparent;\n color: var(--wje-color-contrast-11);\n outline-color: transparent;\n outline-width: 0;\n }\n\n .wje-button-solid.wje-color-default:hover {\n background-color: var(--wje-color-contrast-0);\n border-color: var(--wje-color-contrast-3);\n color: var(--wje-color-contrast-11);\n outline-color: var(--wje-color-contrast-3);\n }\n\n .wje-button-outline.wje-color-default:hover {\n background-color: var(--wje-color-contrast-2);\n border-color: var(--wje-color-contrast-5);\n color: var(--wje-color-contrast-11);\n outline-color: var(--wje-color-contrast-3);\n }\n\n .wje-button-link.wje-color-default:hover {\n background-color: var(--wje-color-contrast-3);\n border-color: transparent;\n color: var(--wje-color-contrast-11);\n outline-color: transparent;\n outline-width: 0;\n }\n}\n\n.button-inner {\n display: flex;\n position: relative;\n flex-flow: row nowrap;\n flex-shrink: 0;\n align-items: center;\n justify-content: center;\n width: 100%;\n height: 100%;\n z-index: 1;\n line-height: normal;\n}\n\n/*\n[ Link ]\n*/\n\n.wje-button-link {\n border-width: var(--wje-button-border-width);\n border-radius: var(--wje-button-border-radius);\n border-color: transparent;\n background-color: transparent;\n}\n\n/*\n[ Disabled ]\n*/\n\n.wje-button-disabled {\n cursor: default;\n opacity: 0.5;\n pointer-events: none;\n}\n\n/*\n[ Round ]\n*/\n\n:host([round]) .native-button {\n border-radius: var(--wje-border-radius-pill);\n}\n\n:host([circle]) .native-button {\n border-radius: var(--wje-border-radius-circle);\n aspect-ratio: 1/1;\n width: 1.813rem;\n display: flex;\n align-items: center;\n --wje-padding-top: 0;\n --wje-padding-start: 0;\n --wje-padding-end: 0;\n --wje-padding-bottom: 0;\n}\n\n:host([size='small']) .native-button {\n --wje-padding-top: 0.25rem;\n --wje-padding-start: 0.25rem;\n --wje-padding-end: 0.25rem;\n --wje-padding-bottom: 0.25rem;\n}\n\n:host([size='large']) .native-button {\n --wje-padding-top: 0.6rem;\n --wje-padding-start: 0.7rem;\n --wje-padding-end: 0.7rem;\n --wje-padding-bottom: 0.6rem;\n}\n\n:host([size='small'][circle]) .native-button {\n width: 1.5rem;\n --wje-padding-top: 0;\n --wje-padding-start: 0;\n --wje-padding-end: 0;\n --wje-padding-bottom: 0;\n}\n\n:host([size='large'][circle]) .native-button {\n width: 2.188rem;\n --wje-padding-top: 0;\n --wje-padding-start: 0;\n --wje-padding-end: 0;\n --wje-padding-bottom: 0;\n}\n\n::slotted(wje-icon[slot='start']) {\n margin: 0 0.3rem 0 0;\n}\n\n::slotted(wje-icon[slot='end']) {\n margin: 0 -0.2rem 0 0.3rem;\n}\n\n:host(:not([only-caret])) slot[name='caret'] {\n padding: 0 0 0 0.3rem;\n}\n\n:host([only-caret]) slot[name='caret'] {\n padding: 0;\n display: block;\n}\n\n:host(.wje-button-group-first:not(.wje-button-group-last)) .native-button {\n border-start-end-radius: 0;\n border-end-end-radius: 0;\n}\n\n:host(.wje-button-group-inner) .native-button {\n border-radius: 0;\n}\n\n:host(.wje-button-group-last:not(.wje-button-group-first)) .native-button {\n border-start-start-radius: 0;\n border-end-start-radius: 0;\n}\n\n:host(.wje-button-group-button:not(.wje-button-group-first)) {\n margin-inline-start: calc(-1 * var(--wje-button-border-width)) !important;\n}\n\n::slotted([slot='toggle']) {\n display: none;\n}\n\n::slotted([slot='toggle'].show) {\n display: block;\n}\n";
17
+ const styles = "/*\n[ WJ Button ]\n*/\n\n/*PRIMARY*/\n.wje-button-solid.wje-color-primary {\n background-color: var(--wje-color-primary-9);\n border-color: var(--wje-color-primary-9);\n color: var(--wje-color-contrast-0);\n}\n\n.wje-button-outline.wje-color-primary {\n background-color: var(--wje-color-primary-1);\n border-color: var(--wje-color-primary-9);\n color: var(--wje-color-primary-9);\n}\n\n.wje-button-link.wje-color-primary {\n background-color: transparent;\n border-color: transparent;\n color: var(--wje-color-primary-9);\n}\n\n/*COMPLETE*/\n.wje-button-solid.wje-color-complete {\n background-color: var(--wje-color-complete-9);\n border-color: var(--wje-color-complete-9);\n color: var(--wje-color-contrast-0);\n}\n\n.wje-button-outline.wje-color-complete {\n background-color: var(--wje-color-complete-1);\n border-color: var(--wje-color-complete-9);\n color: var(--wje-color-complete-9);\n}\n\n.wje-button-link.wje-color-complete {\n background-color: transparent;\n border-color: transparent;\n color: var(--wje-color-complete-9);\n}\n\n/*SUCCESS*/\n.wje-button-solid.wje-color-success {\n background-color: var(--wje-color-success-9);\n border-color: var(--wje-color-success-9);\n color: var(--wje-color-contrast-0);\n}\n\n.wje-button-outline.wje-color-success {\n background-color: var(--wje-color-success-1);\n border-color: var(--wje-color-success-9);\n color: var(--wje-color-success-9);\n}\n\n.wje-button-link.wje-color-success {\n background-color: transparent;\n border-color: transparent;\n color: var(--wje-color-success-9);\n}\n\n/*WARNING*/\n.wje-button-solid.wje-color-warning {\n background-color: var(--wje-color-warning-9);\n border-color: var(--wje-color-warning-9);\n color: var(--wje-color-black);\n}\n\n.wje-button-outline.wje-color-warning {\n background-color: var(--wje-color-warning-1);\n border-color: var(--wje-color-warning-11);\n color: var(--wje-color-warning-11);\n}\n\n.wje-button-link.wje-color-warning {\n background-color: transparent;\n border-color: transparent;\n color: var(--wje-color-warning-11);\n}\n\n/*DANGER*/\n.wje-button-solid.wje-color-danger {\n background-color: var(--wje-color-danger-9);\n border-color: var(--wje-color-danger-9);\n color: var(--wje-color-contrast-0);\n}\n\n.wje-button-outline.wje-color-danger {\n background-color: var(--wje-color-danger-1);\n border-color: var(--wje-color-danger-9);\n color: var(--wje-color-danger-9);\n}\n\n.wje-button-link.wje-color-danger {\n background-color: transparent;\n border-color: transparent;\n color: var(--wje-color-danger-9);\n}\n\n/*NEUTRAL*/\n.wje-button-solid.wje-color-info {\n background-color: var(--wje-color-contrast-9);\n border-color: var(--wje-color-contrast-9);\n color: var(--wje-color-contrast-0);\n}\n\n.wje-button-outline.wje-color-info {\n background-color: var(--wje-color-contrast-1);\n border-color: var(--wje-color-contrast-9);\n color: var(--wje-color-contrast-9);\n}\n\n.wje-button-link.wje-color-info {\n background-color: transparent;\n border-color: transparent;\n color: var(--wje-color-contrast-9);\n}\n\n/*DEFAULT*/\n.wje-button-solid.wje-color-default {\n background-color: var(--wje-color-contrast-0);\n border-color: var(--wje-color-contrast-3);\n color: var(--wje-color-contrast-11);\n}\n\n.wje-button-outline.wje-color-default {\n background-color: var(--wje-color-contrast-1);\n border-color: var(--wje-color-contrast-5);\n color: var(--wje-color-contrast-11);\n}\n\n.wje-button-link.wje-color-default {\n background-color: transparent;\n border-color: transparent;\n color: var(--wje-color-contrast-11);\n}\n\n:host {\n --wje-padding-top: 0.4rem;\n --wje-padding-start: 0.5rem;\n --wje-padding-end: 0.5rem;\n --wje-padding-bottom: 0.4rem;\n\n display: inline-flex;\n position: relative;\n width: auto;\n cursor: pointer;\n margin-inline: var(--wje-button-margin-inline);\n}\n\n:host(.wje-button-group-button) {\n display: block;\n}\n\n.native-button {\n font-family: var(--wje-font-family);\n font-size: var(--wje-font-size);\n display: flex;\n position: relative;\n align-items: center;\n width: 100%;\n height: 100%;\n min-height: inherit;\n /*overflow: hidden;*/ /* Sposobovalo problemy s badge a tooltip */\n border-width: var(--wje-button-border-width);\n border-style: var(--wje-button-border-style);\n border-color: var(--wje-button-border-color);\n background-color: transparent;\n /*color: var(--wje-button-color);*/\n line-height: 1;\n contain: layout style;\n cursor: pointer;\n z-index: 0;\n box-sizing: border-box;\n appearance: none;\n margin: 0;\n border-radius: var(--wje-button-border-radius);\n padding-top: var(--wje-padding-top);\n padding-bottom: var(--wje-padding-bottom);\n padding-inline: var(--wje-padding-start) var(--wje-padding-end);\n white-space: nowrap;\n}\n\n.native-button:hover {\n outline-style: solid;\n outline-width: var(--wje-button-outline-width);\n transition: outline-width 0.1s linear;\n}\n\n@media (any-hover: hover) {\n .wje-button-solid.wje-color-primary:hover {\n background-color: var(--wje-color-primary-9);\n border-color: var(--wje-color-primary-9);\n color: var(--wje-color-contrast-0);\n outline-color: var(--wje-color-primary-2);\n }\n\n .wje-button-outline.wje-color-primary:hover {\n background-color: var(--wje-color-primary-1);\n border-color: var(--wje-color-primary-9);\n color: var(--wje-color-primary-9);\n outline-color: var(--wje-color-primary-2);\n }\n\n .wje-button-link.wje-color-primary:hover {\n background-color: var(--wje-color-primary-1);\n border-color: transparent;\n color: var(--wje-color-primary-9);\n outline-color: transparent;\n outline-width: 0;\n }\n\n .wje-button-solid.wje-color-complete:hover {\n background-color: var(--wje-color-complete-9);\n border-color: var(--wje-color-complete-9);\n color: var(--wje-color-contrast-0);\n outline-color: var(--wje-color-complete-2);\n }\n\n .wje-button-outline.wje-color-complete:hover {\n background-color: var(--wje-color-complete-1);\n border-color: var(--wje-color-complete-9);\n color: var(--wje-color-complete-9);\n outline-color: var(--wje-color-complete-2);\n }\n\n .wje-button-link.wje-color-complete:hover {\n background-color: var(--wje-color-complete-1);\n border-color: transparent;\n color: var(--wje-color-complete-9);\n outline-color: transparent;\n outline-width: 0;\n }\n\n .wje-button-solid.wje-color-success:hover {\n background-color: var(--wje-color-success-9);\n border-color: var(--wje-color-success-9);\n color: var(--wje-color-contrast-0);\n outline-color: var(--wje-color-success-2);\n }\n\n .wje-button-outline.wje-color-success:hover {\n background-color: var(--wje-color-success-1);\n border-color: var(--wje-color-success-9);\n color: var(--wje-color-success-9);\n outline-color: var(--wje-color-success-2);\n }\n\n .wje-button-link.wje-color-success:hover {\n background-color: var(--wje-color-success-1);\n border-color: transparent;\n color: var(--wje-color-success-9);\n outline-color: transparent;\n outline-width: 0;\n }\n\n .wje-button-solid.wje-color-warning:hover {\n background-color: var(--wje-color-warning-9);\n border-color: var(--wje-color-warning-9);\n color: var(--wje-color-black);\n outline-color: var(--wje-color-warning-2);\n }\n\n .wje-button-outline.wje-color-warning:hover {\n background-color: var(--wje-color-warning-1);\n border-color: var(--wje-color-warning-11);\n color: var(--wje-color-warning-11);\n outline-color: var(--wje-color-warning-2);\n }\n\n .wje-button-link.wje-color-warning:hover {\n background-color: var(--wje-color-warning-1);\n border-color: transparent;\n color: var(--wje-color-warning-11);\n outline-color: transparent;\n outline-width: 0;\n }\n\n .wje-button-solid.wje-color-danger:hover {\n background-color: var(--wje-color-danger-9);\n border-color: var(--wje-color-danger-9);\n color: var(--wje-color-contrast-0);\n outline-color: var(--wje-color-danger-2);\n }\n\n .wje-button-outline.wje-color-danger:hover {\n background-color: var(--wje-color-danger-1);\n border-color: var(--wje-color-danger-9);\n color: var(--wje-color-danger-9);\n outline-color: var(--wje-color-danger-2);\n }\n\n .wje-button-link.wje-color-danger:hover {\n background-color: var(--wje-color-danger-1);\n border-color: transparent;\n color: var(--wje-color-danger-9);\n outline-color: transparent;\n outline-width: 0;\n }\n\n .wje-button-solid.wje-color-info:hover {\n background-color: var(--wje-color-contrast-9);\n border-color: var(--wje-color-contrast-9);\n color: var(--wje-color-contrast-0);\n outline-color: var(--wje-color-contrast-3);\n }\n\n .wje-button-outline.wje-color-info:hover {\n background-color: var(--wje-color-contrast-1);\n border-color: var(--wje-color-contrast-9);\n color: var(--wje-color-contrast-9);\n outline-color: var(--wje-color-contrast-3);\n }\n\n .wje-button-link.wje-color-info:hover {\n background-color: var(--wje-color-contrast-3);\n border-color: transparent;\n color: var(--wje-color-contrast-11);\n outline-color: transparent;\n outline-width: 0;\n }\n\n .wje-button-solid.wje-color-default:hover {\n background-color: var(--wje-color-contrast-0);\n border-color: var(--wje-color-contrast-3);\n color: var(--wje-color-contrast-11);\n outline-color: var(--wje-color-contrast-3);\n }\n\n .wje-button-outline.wje-color-default:hover {\n background-color: var(--wje-color-contrast-2);\n border-color: var(--wje-color-contrast-5);\n color: var(--wje-color-contrast-11);\n outline-color: var(--wje-color-contrast-3);\n }\n\n .wje-button-link.wje-color-default:hover {\n background-color: var(--wje-color-contrast-3);\n border-color: transparent;\n color: var(--wje-color-contrast-11);\n outline-color: transparent;\n outline-width: 0;\n }\n}\n\n.button-inner {\n display: flex;\n position: relative;\n flex-flow: row nowrap;\n flex-shrink: 0;\n align-items: center;\n justify-content: center;\n width: 100%;\n height: 100%;\n z-index: 1;\n line-height: normal;\n}\n\n/*\n[ Link ]\n*/\n\n.wje-button-link {\n border-width: var(--wje-button-border-width);\n border-radius: var(--wje-button-border-radius);\n border-color: transparent;\n background-color: transparent;\n}\n\n/*\n[ Disabled ]\n*/\n\n.wje-button-disabled {\n cursor: default;\n opacity: 0.5;\n pointer-events: none;\n}\n\n/*\n[ Round ]\n*/\n\n:host([round]) .native-button {\n border-radius: var(--wje-border-radius-pill);\n}\n\n:host([circle]) .native-button {\n border-radius: var(--wje-border-radius-circle);\n aspect-ratio: 1/1;\n width: 1.988rem;\n display: flex;\n align-items: center;\n --wje-padding-top: 0;\n --wje-padding-start: 0;\n --wje-padding-end: 0;\n --wje-padding-bottom: 0;\n}\n\n:host([size='small']) .native-button {\n --wje-padding-top: 0.25rem;\n --wje-padding-start: 0.25rem;\n --wje-padding-end: 0.25rem;\n --wje-padding-bottom: 0.25rem;\n}\n\n:host([size='large']) .native-button {\n --wje-padding-top: 0.6rem;\n --wje-padding-start: 0.7rem;\n --wje-padding-end: 0.7rem;\n --wje-padding-bottom: 0.6rem;\n}\n\n:host([size='small'][circle]) .native-button {\n width: 1.688rem;\n --wje-padding-top: 0;\n --wje-padding-start: 0;\n --wje-padding-end: 0;\n --wje-padding-bottom: 0;\n}\n\n:host([size='large'][circle]) .native-button {\n width: 2.388rem;\n --wje-padding-top: 0;\n --wje-padding-start: 0;\n --wje-padding-end: 0;\n --wje-padding-bottom: 0;\n}\n\n::slotted(wje-icon[slot='start']) {\n margin: 0 0.3rem 0 0;\n}\n\n::slotted(wje-icon[slot='end']) {\n margin: 0 -0.2rem 0 0.3rem;\n}\n\n:host(:not([only-caret])) slot[name='caret'] {\n padding: 0 0 0 0.3rem;\n}\n\n:host([only-caret]) {\n .native-button {\n aspect-ratio: 1/1;\n width: 1.988rem;\n display: flex;\n align-items: center;\n }\n slot[name='caret'] {\n padding: 0;\n display: block;\n }\n}\n\n::slotted([slot='toggle']) {\n display: none;\n}\n\n::slotted([slot='toggle'].show) {\n display: block;\n}\n";
18
18
  class Button extends WJElement {
19
19
  /**
20
20
  * Button constructor method.
@@ -250,7 +250,7 @@ class Button extends WJElement {
250
250
  * @returns {Array<string>} observedAttributes - The observed attributes array for the Button element.
251
251
  */
252
252
  static get observedAttributes() {
253
- return ["disabled"];
253
+ return ["disabled", "color"];
254
254
  }
255
255
  /**
256
256
  * @summary Callback function that is called when the custom element is associated with a form.