wj-elements 0.1.171 → 0.1.173
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/packages/wje-button/button.element.d.ts +30 -3
- package/dist/packages/wje-chip/chip.element.d.ts +34 -0
- package/dist/packages/wje-format-digital/format-digital.element.d.ts +0 -4
- package/dist/packages/wje-kanban/kanban.element.d.ts +1 -2
- package/dist/packages/wje-menu-item/menu-item.element.d.ts +19 -0
- package/dist/packages/wje-select/select.element.d.ts +55 -17
- package/dist/wje-button.js +58 -9
- package/dist/wje-button.js.map +1 -1
- package/dist/wje-chip.js +66 -3
- package/dist/wje-chip.js.map +1 -1
- package/dist/wje-format-digital.js.map +1 -1
- package/dist/wje-kanban.js.map +1 -1
- package/dist/wje-menu-item.js +54 -4
- package/dist/wje-menu-item.js.map +1 -1
- package/dist/wje-routerx.js +1 -1
- package/dist/wje-routerx.js.map +1 -1
- package/dist/wje-select.js +83 -26
- package/dist/wje-select.js.map +1 -1
- package/package.json +1 -1
|
@@ -66,6 +66,18 @@ export default class Button extends WJElement {
|
|
|
66
66
|
* @returns {boolean}
|
|
67
67
|
*/
|
|
68
68
|
get caret(): boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Sets the 'round' attribute on the element. If the value is true, the attribute is added;
|
|
71
|
+
* otherwise, it is removed from the element.
|
|
72
|
+
* @param {boolean} value A boolean indicating whether to set or remove the 'round' attribute.
|
|
73
|
+
*/
|
|
74
|
+
set round(value: boolean);
|
|
75
|
+
/**
|
|
76
|
+
* Retrieves the value of the 'round' attribute as a boolean.
|
|
77
|
+
* Checks if the 'round' attribute is present on the element.
|
|
78
|
+
* @returns {boolean} True if the 'round' attribute exists, otherwise false.
|
|
79
|
+
*/
|
|
80
|
+
get round(): boolean;
|
|
69
81
|
/**
|
|
70
82
|
* Set variant of the Button element.
|
|
71
83
|
* @param value
|
|
@@ -136,9 +148,24 @@ export default class Button extends WJElement {
|
|
|
136
148
|
* @returns {boolean} stopPropagation - The stop propagation state
|
|
137
149
|
*/
|
|
138
150
|
get stopPropagation(): boolean;
|
|
151
|
+
/**
|
|
152
|
+
* Sets the value of the custom event attribute.
|
|
153
|
+
* @param {string} value The value to be assigned to the custom event attribute.
|
|
154
|
+
*/
|
|
139
155
|
set customEvent(value: string);
|
|
140
|
-
|
|
141
|
-
|
|
156
|
+
/**
|
|
157
|
+
* Retrieves the value of the 'custom-event' attribute from the element.
|
|
158
|
+
* @returns {string | null} The value of the 'custom-event' attribute, or null if the attribute is not set.
|
|
159
|
+
*/
|
|
160
|
+
get customEvent(): string | null;
|
|
161
|
+
/**
|
|
162
|
+
* Retrieves a mapped object containing custom event parameters extracted from the element's attributes.
|
|
163
|
+
* Attributes considered are those that begin with 'custom-event-'.
|
|
164
|
+
* The mapped object's keys are derived by removing the 'custom-event-' prefix from the attribute names,
|
|
165
|
+
* and the values are the corresponding attribute values.
|
|
166
|
+
* @returns {object} An object containing key-value pairs of custom event parameters.
|
|
167
|
+
*/
|
|
168
|
+
get customEventParameters(): object;
|
|
142
169
|
/**
|
|
143
170
|
* @summary Callback function that is called when the custom element is associated with a form.
|
|
144
171
|
* This function sets the internal `_form` property to the associated form.
|
|
@@ -159,7 +186,6 @@ export default class Button extends WJElement {
|
|
|
159
186
|
draw(): object;
|
|
160
187
|
hasToggle: boolean;
|
|
161
188
|
slotToggle: HTMLSlotElement;
|
|
162
|
-
populateCustomEvent(): void;
|
|
163
189
|
/**
|
|
164
190
|
* After draw method for the Button element.
|
|
165
191
|
*/
|
|
@@ -174,4 +200,5 @@ export default class Button extends WJElement {
|
|
|
174
200
|
* Toggle states method for the Button element.
|
|
175
201
|
*/
|
|
176
202
|
toggleStates: () => void;
|
|
203
|
+
#private;
|
|
177
204
|
}
|
|
@@ -16,6 +16,40 @@ export default class Chip extends WJElement {
|
|
|
16
16
|
* @returns {*}
|
|
17
17
|
*/
|
|
18
18
|
static get cssStyleSheet(): any;
|
|
19
|
+
/**
|
|
20
|
+
* Sets or removes the "round" attribute on the element based on the provided value.
|
|
21
|
+
* @param {boolean} value Determines whether the "round" attribute should be set or removed.
|
|
22
|
+
* If true, the "round" attribute is added. If false, the "round"
|
|
23
|
+
* attribute is removed.
|
|
24
|
+
*/
|
|
25
|
+
set round(value: boolean);
|
|
26
|
+
/**
|
|
27
|
+
* Checks if the 'round' attribute is present on the element.
|
|
28
|
+
* @returns {boolean} Returns true if the 'round' attribute exists, otherwise false.
|
|
29
|
+
*/
|
|
30
|
+
get round(): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Sets the size attribute of the element.
|
|
33
|
+
* @param {string} value The value to set for the size attribute.
|
|
34
|
+
*/
|
|
35
|
+
set size(value: string);
|
|
36
|
+
/**
|
|
37
|
+
* Retrieves the 'size' attribute of the current element.
|
|
38
|
+
* @returns {string | null} The value of the 'size' attribute, or null if the attribute is not set.
|
|
39
|
+
*/
|
|
40
|
+
get size(): string | null;
|
|
41
|
+
/**
|
|
42
|
+
* Sets or removes the "removable" attribute on the element.
|
|
43
|
+
* @param {boolean} value A boolean indicating whether the element should have the "removable" attribute.
|
|
44
|
+
* If true, the "removable" attribute is added;
|
|
45
|
+
* if false, the "removable" attribute is removed.
|
|
46
|
+
*/
|
|
47
|
+
set removable(value: boolean);
|
|
48
|
+
/**
|
|
49
|
+
* Determines if the element has the 'removable' attribute.
|
|
50
|
+
* @returns {boolean} True if the element has the 'removable' attribute, otherwise false.
|
|
51
|
+
*/
|
|
52
|
+
get removable(): boolean;
|
|
19
53
|
/**
|
|
20
54
|
* Draws the Chip element.
|
|
21
55
|
* @returns {DocumentFragment}
|
|
@@ -14,10 +14,6 @@ import { Localizer } from '../utils/localize.js';
|
|
|
14
14
|
* @csspart formatted - The part representing the formatted value.
|
|
15
15
|
* @csspart start - Slot for content before the formatted value.
|
|
16
16
|
* @csspart end - Slot for content after the formatted value.
|
|
17
|
-
* @cssproperty [--wje-format-digital-font-size=1rem] - The font size of the formatted digital value.
|
|
18
|
-
* @cssproperty [--wje-format-digital-color=var(--wje-text-color)] - The color of the formatted text.
|
|
19
|
-
* @cssproperty [--wje-format-digital-padding=.5rem] - The padding around the component.
|
|
20
|
-
* @cssproperty [--wje-format-digital-border-radius=var(--wje-border-radius-small)] - The border radius of the component.
|
|
21
17
|
* @tag wje-format-digital
|
|
22
18
|
*/
|
|
23
19
|
export default class FormatDigital extends WJElement {
|
|
@@ -8,8 +8,7 @@ import { default as MenuItem } from '../wje-menu-item/menu-item.js';
|
|
|
8
8
|
* @status stable
|
|
9
9
|
* @augments {WJElement}
|
|
10
10
|
* @slot - The default slot for the Kanban board.
|
|
11
|
-
* @csspart native - Styles the native part of the Kanban board.
|
|
12
|
-
* @csspart pool - Styles the pool of the Kanban board.
|
|
11
|
+
* @csspart native-infinite-scroll - Styles the native part of the Kanban board.
|
|
13
12
|
* @tag wje-kanban
|
|
14
13
|
*/
|
|
15
14
|
export default class Kanban extends WJElement {
|
|
@@ -64,6 +64,24 @@ export default class MenuItem extends WJElement {
|
|
|
64
64
|
* @returns {boolean} True if the closest parent has the collapse attribute, false otherwise.
|
|
65
65
|
*/
|
|
66
66
|
get collapse(): boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Sets the value of the custom event attribute.
|
|
69
|
+
* @param {string} value The value to be assigned to the custom event attribute.
|
|
70
|
+
*/
|
|
71
|
+
set customEvent(value: string);
|
|
72
|
+
/**
|
|
73
|
+
* Retrieves the value of the 'custom-event' attribute from the element.
|
|
74
|
+
* @returns {string | null} The value of the 'custom-event' attribute, or null if the attribute is not set.
|
|
75
|
+
*/
|
|
76
|
+
get customEvent(): string | null;
|
|
77
|
+
/**
|
|
78
|
+
* Retrieves a mapped object containing custom event parameters extracted from the element's attributes.
|
|
79
|
+
* Attributes considered are those that begin with 'custom-event-'.
|
|
80
|
+
* The mapped object's keys are derived by removing the 'custom-event-' prefix from the attribute names,
|
|
81
|
+
* and the values are the corresponding attribute values.
|
|
82
|
+
* @returns {object} An object containing key-value pairs of custom event parameters.
|
|
83
|
+
*/
|
|
84
|
+
get customEventParameters(): object;
|
|
67
85
|
/**
|
|
68
86
|
* Removes the active attribute from the menu before drawing the MenuItem.
|
|
69
87
|
*/
|
|
@@ -136,4 +154,5 @@ export default class MenuItem extends WJElement {
|
|
|
136
154
|
* @returns {string} The concatenated and trimmed text content from the element's text nodes.
|
|
137
155
|
*/
|
|
138
156
|
getTextFromElement(element: HTMLElement): string;
|
|
157
|
+
#private;
|
|
139
158
|
}
|
|
@@ -22,6 +22,7 @@ import { default as Options } from '../wje-options/options.js';
|
|
|
22
22
|
* @property {Array} _selected - An array to store selected items.
|
|
23
23
|
* @property {HTMLElement|null} counterEl - A reference to the counter element, initially null.
|
|
24
24
|
* @property {ElementInternals} internals - The internal element API for managing state and attributes.
|
|
25
|
+
* @property {number} maxOptions - The maximum number of options allowed.
|
|
25
26
|
* @property {boolean} _wasOppened - Tracks whether the select element was previously opened, initially false.
|
|
26
27
|
* @cssproperty [--wje-select-border-width=1px] - Specifies the width of the border around the select component. Accepts any valid CSS length unit (e.g., `px`, `rem`, `em`).
|
|
27
28
|
* @cssproperty [--wje-select-border-style=solid] - Defines the style of the border for the select component. Accepts standard CSS border styles, such as `solid`, `dashed`, or `dotted`.
|
|
@@ -132,6 +133,20 @@ export default class Select extends WJElement {
|
|
|
132
133
|
*/
|
|
133
134
|
list: HTMLElement | null;
|
|
134
135
|
selectedOptions: any[];
|
|
136
|
+
/**
|
|
137
|
+
* An object representing component dependencies with their respective classes.
|
|
138
|
+
* Each property in the object maps a custom component name (as a string key)
|
|
139
|
+
* to its corresponding class or constructor.
|
|
140
|
+
* @typedef {{[key: string]: Function}} Dependencies
|
|
141
|
+
* @property {Function} 'wje-button' Represents the Button component class.
|
|
142
|
+
* @property {Function} 'wje-popup' Represents the Popup component class.
|
|
143
|
+
* @property {Function} 'wje-icon' Represents the Icon component class.
|
|
144
|
+
* @property {Function} 'wje-label' Represents the Label component class.
|
|
145
|
+
* @property {Function} 'wje-chip' Represents the Chip component class.
|
|
146
|
+
* @property {Function} 'wje-input' Represents the Input component class.
|
|
147
|
+
* @property {Function} 'wje-option' Represents the Option component class.
|
|
148
|
+
* @property {Function} 'wje-options' Represents the Options component class.
|
|
149
|
+
*/
|
|
135
150
|
dependencies: {
|
|
136
151
|
'wje-button': typeof Button;
|
|
137
152
|
'wje-popup': typeof Popup;
|
|
@@ -172,6 +187,19 @@ export default class Select extends WJElement {
|
|
|
172
187
|
* @returns {boolean} Whether the attribute is present.
|
|
173
188
|
*/
|
|
174
189
|
get invalid(): boolean;
|
|
190
|
+
/**
|
|
191
|
+
* Sets the maximum number of options allowed.
|
|
192
|
+
* @param {string | number | null} value The value to set as the maximum number of options.
|
|
193
|
+
* If null, the 'max-options' attribute will be removed.
|
|
194
|
+
*/
|
|
195
|
+
set maxOptions(value: string | number | null);
|
|
196
|
+
/**
|
|
197
|
+
* Retrieves the maximum number of options allowed.
|
|
198
|
+
* Parses the value of the 'max-options' attribute from the element and converts it to a number.
|
|
199
|
+
* If the attribute is not present or cannot be converted to a valid number, defaults to 0.
|
|
200
|
+
* @returns {number} The maximum number of options, or 0 if the attribute is not set or invalid.
|
|
201
|
+
*/
|
|
202
|
+
get maxOptions(): number;
|
|
175
203
|
/**
|
|
176
204
|
* Getter for the form attribute.
|
|
177
205
|
* @returns {HTMLFormElement} The form the input is associated with.
|
|
@@ -252,8 +280,22 @@ export default class Select extends WJElement {
|
|
|
252
280
|
* @param {Event} e The event.
|
|
253
281
|
*/
|
|
254
282
|
optionChange: (e: Event) => void;
|
|
255
|
-
|
|
256
|
-
|
|
283
|
+
/**
|
|
284
|
+
* Handles the selection and deselection of an option element.
|
|
285
|
+
* @param {HTMLElement} option The option element that was clicked.
|
|
286
|
+
* @param {boolean} [multiple] Indicates whether multiple selection is allowed.
|
|
287
|
+
*/
|
|
288
|
+
processClickedOption: (option: HTMLElement, multiple?: boolean) => void;
|
|
289
|
+
/**
|
|
290
|
+
* Filters out a specified option from the `selectedOptions` array.
|
|
291
|
+
* This function removes an option from the `selectedOptions` array if its value
|
|
292
|
+
* matches the value of the option provided as an argument. It allows for dynamically
|
|
293
|
+
* updating the selected options by excluding the specified option.
|
|
294
|
+
* @param {object} option The option to be removed from the `selectedOptions` array.
|
|
295
|
+
* Should be an object containing a `value` property that is compared to the
|
|
296
|
+
* `value` property of objects in the `selectedOptions` array.
|
|
297
|
+
*/
|
|
298
|
+
filterOutOption: (option: object) => void;
|
|
257
299
|
/**
|
|
258
300
|
* Returns all the options as HTML.
|
|
259
301
|
* @returns {NodeList} The options as HTML.
|
|
@@ -276,21 +318,10 @@ export default class Select extends WJElement {
|
|
|
276
318
|
*/
|
|
277
319
|
selectionChanged(option?: Element, length?: number): void;
|
|
278
320
|
/**
|
|
279
|
-
*
|
|
280
|
-
*
|
|
281
|
-
* @
|
|
282
|
-
* @
|
|
283
|
-
* This method fetches the currently selected options and updates the `selectedOptions` array.
|
|
284
|
-
* It clears and rebuilds the chips representing the selected items in the UI.
|
|
285
|
-
* If the number of selected options reaches the maximum allowed (`maxOptions`), it stops updating the counter.
|
|
286
|
-
* Optionally, it dispatches a custom event when the selection changes unless `silence` is set to `true`.
|
|
287
|
-
* //@fires wje-select:change - Dispatched when the selection changes, unless `silence` is `true`.
|
|
288
|
-
* @example
|
|
289
|
-
* // Call the method and allow event dispatch
|
|
290
|
-
* selections();
|
|
291
|
-
* @example
|
|
292
|
-
* // Call the method without dispatching the event
|
|
293
|
-
* selections(true);
|
|
321
|
+
* Handles the selection of options and updates the UI chips accordingly.
|
|
322
|
+
* Also manages the max selection logic and fires an event when selections change.
|
|
323
|
+
* @param {boolean} [silence] Indicates whether to suppress the event dispatch when a change occurs.
|
|
324
|
+
* @returns {void} Does not return anything.
|
|
294
325
|
*/
|
|
295
326
|
selections(silence?: boolean): void;
|
|
296
327
|
/**
|
|
@@ -383,4 +414,11 @@ export default class Select extends WJElement {
|
|
|
383
414
|
* @function
|
|
384
415
|
*/
|
|
385
416
|
formDisabledCallback(disabled: boolean): void;
|
|
417
|
+
/**
|
|
418
|
+
* Checks if all elements in the `elements` array are present in the `options` array based on their `option` property.
|
|
419
|
+
* @param {Array} elements The array of elements to check. Each element should have an `option` property.
|
|
420
|
+
* @param {Array} options The array of options to verify against.
|
|
421
|
+
* @returns {boolean} Returns true if all elements in the `elements` array are found within the `options` array, otherwise returns false.
|
|
422
|
+
*/
|
|
423
|
+
areAllElementsInOptions(elements: any[], options: any[]): boolean;
|
|
386
424
|
}
|
package/dist/wje-button.js
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
|
+
var __typeError = (msg) => {
|
|
3
|
+
throw TypeError(msg);
|
|
4
|
+
};
|
|
2
5
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
6
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
7
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
8
|
+
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
9
|
+
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
10
|
+
var _Button_instances, populateCustomEvent_fn;
|
|
4
11
|
import { b as bindRouterLinks } from "./router-links-CJnOdbas.js";
|
|
5
12
|
import WJElement, { WjElementUtils, event } from "./wje-element.js";
|
|
6
13
|
import Icon from "./wje-icon.js";
|
|
@@ -15,6 +22,7 @@ class Button extends WJElement {
|
|
|
15
22
|
*/
|
|
16
23
|
constructor() {
|
|
17
24
|
super();
|
|
25
|
+
__privateAdd(this, _Button_instances);
|
|
18
26
|
/**
|
|
19
27
|
* Dependencies of the Button element.
|
|
20
28
|
* @type {object}
|
|
@@ -78,6 +86,26 @@ class Button extends WJElement {
|
|
|
78
86
|
get caret() {
|
|
79
87
|
return this.hasAttribute("caret");
|
|
80
88
|
}
|
|
89
|
+
/**
|
|
90
|
+
* Sets the 'round' attribute on the element. If the value is true, the attribute is added;
|
|
91
|
+
* otherwise, it is removed from the element.
|
|
92
|
+
* @param {boolean} value A boolean indicating whether to set or remove the 'round' attribute.
|
|
93
|
+
*/
|
|
94
|
+
set round(value) {
|
|
95
|
+
if (value) {
|
|
96
|
+
this.setAttribute("round", "");
|
|
97
|
+
} else {
|
|
98
|
+
this.removeAttribute("round");
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Retrieves the value of the 'round' attribute as a boolean.
|
|
103
|
+
* Checks if the 'round' attribute is present on the element.
|
|
104
|
+
* @returns {boolean} True if the 'round' attribute exists, otherwise false.
|
|
105
|
+
*/
|
|
106
|
+
get round() {
|
|
107
|
+
return this.hasAttribute("round");
|
|
108
|
+
}
|
|
81
109
|
/**
|
|
82
110
|
* Set variant of the Button element.
|
|
83
111
|
* @param value
|
|
@@ -179,12 +207,27 @@ class Button extends WJElement {
|
|
|
179
207
|
get stopPropagation() {
|
|
180
208
|
return bool(this.getAttribute("stop-propagation"));
|
|
181
209
|
}
|
|
210
|
+
/**
|
|
211
|
+
* Sets the value of the custom event attribute.
|
|
212
|
+
* @param {string} value The value to be assigned to the custom event attribute.
|
|
213
|
+
*/
|
|
182
214
|
set customEvent(value) {
|
|
183
215
|
this.setAttribute("custom-event", value);
|
|
184
216
|
}
|
|
217
|
+
/**
|
|
218
|
+
* Retrieves the value of the 'custom-event' attribute from the element.
|
|
219
|
+
* @returns {string | null} The value of the 'custom-event' attribute, or null if the attribute is not set.
|
|
220
|
+
*/
|
|
185
221
|
get customEvent() {
|
|
186
222
|
return this.getAttribute("custom-event");
|
|
187
223
|
}
|
|
224
|
+
/**
|
|
225
|
+
* Retrieves a mapped object containing custom event parameters extracted from the element's attributes.
|
|
226
|
+
* Attributes considered are those that begin with 'custom-event-'.
|
|
227
|
+
* The mapped object's keys are derived by removing the 'custom-event-' prefix from the attribute names,
|
|
228
|
+
* and the values are the corresponding attribute values.
|
|
229
|
+
* @returns {object} An object containing key-value pairs of custom event parameters.
|
|
230
|
+
*/
|
|
188
231
|
get customEventParameters() {
|
|
189
232
|
const attributes = Array.from(this.attributes).filter((attr) => attr.name.startsWith("custom-event-"));
|
|
190
233
|
return attributes.reduce((acc, attr) => {
|
|
@@ -309,13 +352,6 @@ class Button extends WJElement {
|
|
|
309
352
|
}
|
|
310
353
|
return fragment;
|
|
311
354
|
}
|
|
312
|
-
populateCustomEvent() {
|
|
313
|
-
let customEvent = this.customEvent;
|
|
314
|
-
let customEventParameters = this.customEventParameters;
|
|
315
|
-
this.dispatchEvent(
|
|
316
|
-
new CustomEvent(customEvent, { detail: customEventParameters, composed: true, bubbles: true })
|
|
317
|
-
);
|
|
318
|
-
}
|
|
319
355
|
/**
|
|
320
356
|
* After draw method for the Button element.
|
|
321
357
|
*/
|
|
@@ -333,7 +369,7 @@ class Button extends WJElement {
|
|
|
333
369
|
}
|
|
334
370
|
}
|
|
335
371
|
if (this.hasAttribute("custom-event")) {
|
|
336
|
-
event.addListener(this, "click", null, this
|
|
372
|
+
event.addListener(this, "click", null, __privateMethod(this, _Button_instances, populateCustomEvent_fn));
|
|
337
373
|
}
|
|
338
374
|
if (this.hasAttribute("dialog")) {
|
|
339
375
|
event.addListener(this, "click", null, this.eventDialogOpen);
|
|
@@ -364,13 +400,26 @@ class Button extends WJElement {
|
|
|
364
400
|
event.removeListener(this, "click", null, this.eventDialogOpen);
|
|
365
401
|
event.removeListener(this, "click", "wje-button:click", null);
|
|
366
402
|
event.removeListener(this, "click", "wje-button:toggle", this.toggleStates);
|
|
367
|
-
event.removeListener(this, "click", null, this
|
|
403
|
+
event.removeListener(this, "click", null, __privateMethod(this, _Button_instances, populateCustomEvent_fn));
|
|
368
404
|
event.removeListener(this, "click", "wje-button:submit", null);
|
|
369
405
|
event.removeListener(this, "click", "wje-button:reset", null);
|
|
370
406
|
this.removeEventListener("click", this.eventDialogOpen);
|
|
371
407
|
(_a = this.unbindRouterLinks) == null ? void 0 : _a.call(this);
|
|
372
408
|
}
|
|
373
409
|
}
|
|
410
|
+
_Button_instances = new WeakSet();
|
|
411
|
+
/**
|
|
412
|
+
* Dispatches a custom event with specified parameters.
|
|
413
|
+
* This method uses the `customEvent` and `customEventParameters` properties
|
|
414
|
+
* to create and dispatch a `CustomEvent`. The event is configured to be
|
|
415
|
+
* composed and bubbles up through the DOM.
|
|
416
|
+
* @returns {void} This method does not return a value.
|
|
417
|
+
*/
|
|
418
|
+
populateCustomEvent_fn = function() {
|
|
419
|
+
this.dispatchEvent(
|
|
420
|
+
new CustomEvent(this.customEvent, { detail: this.customEventParameters, composed: true, bubbles: true })
|
|
421
|
+
);
|
|
422
|
+
};
|
|
374
423
|
/**
|
|
375
424
|
* @summary A static property that indicates whether the custom element is form-associated or not.
|
|
376
425
|
* Form-associated custom elements are elements that can participate in form submission.
|
package/dist/wje-button.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wje-button.js","sources":["../packages/utils/utils.js","../packages/wje-button/button.element.js","../packages/wje-button/button.js"],"sourcesContent":["export const bool = (v) => {\n return v === 'false' || v === 'null' || v === 'NaN' || v === 'undefined' || v === '0' ? false : !!v;\n};\n","import { bindRouterLinks } from 'slick-router/middlewares/router-links.js';\n\nimport { bool } from '../utils/utils.js';\nimport { default as WJElement, event, WjElementUtils } from '../wje-element/element.js';\nimport Icon from '../wje-icon/icon.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * @summary This class represents Button element, extending the WJElement class.\n * @documentation https://elements.webjet.sk/components/button\n * @status stable\n * @augments WJElement\n * @dependency wje-icon\n * @slot - The button main content.\n * @slot icon - The button icon.\n * @slot caret - The button caret.\n * @slot start - The button start slot.\n * @slot end - The button end slot.\n * @slot toggle - The button toggle slot.\n * @csspart native - The component's native wrapper.\n * @cssproperty [--wje-button-background-color=transparent] - Background color of the component;\n * @cssproperty [--wje-button-border-color=--wje-color-contrast-4] - Border color of the component;\n * @cssproperty [--wje-button-color=--wje-color-contrast-11] - Color of the component;\n * @cssproperty [--wje-button-border-radius=--wje-border-radius-medium] - Border radius of the component;\n * @cssproperty [--wje-button-border-width=1px] - Border width of the component;\n * @cssproperty [--wje-button-border-style=solid] - Border style of the component;\n * @cssproperty [--wje-button-border-color=--wje-color-contrast-1] - Border color of the component;\n * @cssproperty [--wje-button-margin-inline=0] - Margin inline of the component;\n */\n\nexport default class Button extends WJElement {\n /**\n * Button constructor method.\n * @class\n */\n constructor() {\n super();\n\n this.internals_ = this.attachInternals();\n }\n\n /**\n * Dependencies of the Button element.\n * @type {object}\n */\n dependencies = {\n 'wje-icon': Icon,\n };\n\n /**\n * Properties of the element Button.\n * @param value\n */\n set color(value) {\n this.setAttribute('color', value || 'default');\n }\n\n /**\n * Get color of the Button element.\n * @returns {string|string}\n */\n get color() {\n return this.getAttribute('color') || 'default';\n }\n\n /**\n * Set variant of the Button element.\n * @param value\n */\n set caret(value) {\n this.setAttribute('caret', value);\n }\n\n /**\n * Get variant of the Button element.\n * @returns {boolean}\n */\n get caret() {\n return this.hasAttribute('caret');\n }\n\n /**\n * Set variant of the Button element.\n * @param value\n */\n set tooltip(value) {\n this.setAttribute('tooltip', value);\n }\n\n /**\n * Get variant of the Button element.\n * @returns {boolean}\n */\n get tooltip() {\n return this.hasAttribute('tooltip');\n }\n\n /**\n * Set variant of the Button element.\n * @param value\n */\n set dialog(value) {\n this.setAttribute('dialog', value);\n }\n\n /**\n * Get variant of the Button element.\n * @returns {string|object}\n */\n get dialog() {\n return this.getAttribute('dialog');\n }\n\n /**\n * Set active state of the Button element.\n * @param {boolean} value The value to set\n */\n set active(value) {\n this.setAttribute('active', '');\n }\n\n /**\n * Get active state of the Button element.\n * @returns {boolean} active - The active state\n */\n get active() {\n return this.hasAttribute('active');\n }\n\n /**\n * Set disabled state of the Button element.\n * @param {boolean} value The value to set\n */\n set disabled(value) {\n this.removeAttribute('disabled');\n\n if (value) {\n this.setAttribute('disabled', '');\n }\n }\n\n /**\n * Get disabled state of the Button element.\n * @returns {boolean} disabled - The disabled state\n */\n get disabled() {\n return this.hasAttribute('disabled');\n }\n\n /**\n * Set fill of the Button element.\n * @param {string} value The value to set\n */\n set fill(value) {\n this.setAttribute('fill', value);\n }\n\n /**\n * Get fill of the Button element.\n * @returns {string} fill - The fill value\n */\n get fill() {\n return this.getAttribute('fill') || 'solid';\n }\n\n /**\n * Set outline state of the Button element.\n * @param {boolean} value The value to set\n */\n set outline(value) {\n this.setAttribute('outline', '');\n }\n\n /**\n * Get outline state of the Button element.\n * @returns {boolean} outline - The outline state\n */\n get outline() {\n return this.hasAttribute('outline');\n }\n\n /**\n * Set stop propagation state of the Button element.\n * @param {boolean} value The value to set\n */\n set stopPropagation(value) {\n this.setAttribute('stop-propagation', bool(value));\n }\n\n /**\n * Get stop propagation state of the Button element.\n * @returns {boolean} stopPropagation - The stop propagation state\n */\n get stopPropagation() {\n return bool(this.getAttribute('stop-propagation'));\n }\n\n set customEvent(value) {\n this.setAttribute('custom-event', value);\n }\n\n get customEvent() {\n return this.getAttribute('custom-event');\n }\n\n get customEventParameters() {\n const attributes = Array.from(this.attributes).filter((attr) => attr.name.startsWith('custom-event-'));\n\n return attributes.reduce((acc, attr) => {\n const key = attr.name.replace('custom-event-', '');\n acc[key] = attr.value;\n\n return acc;\n }, {});\n }\n\n /**\n * Class name for the Button element\n * @type {string}\n */\n className = 'Button';\n\n /**\n * Get CSS stylesheet for the Button element.\n * @static\n * @returns {CSSStyleSheet} styles - The CSS stylesheet for the Button element.\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Get observed attributes for the Button element.\n * @static\n * @returns {Array<string>} observedAttributes - The observed attributes array for the Button element.\n */\n static get observedAttributes() {\n return ['disabled'];\n }\n\n /**\n * @summary A static property that indicates whether the custom element is form-associated or not.\n * Form-associated custom elements are elements that can participate in form submission.\n * @type {boolean}\n */\n static formAssociated = true;\n\n /**\n * @summary Callback function that is called when the custom element is associated with a form.\n * This function sets the internal `_form` property to the associated form.\n * @param {HTMLFormElement} form The form the custom element is associated with.\n */\n formAssociatedCallback(form) {\n this._form = form;\n }\n\n /**\n * @summary Callback function that is called when the form-associated state of the custom element changes.\n * This function updates the 'disabled' attribute of the element based on the new state.\n * @param {boolean} disabled The new form-associated state.\n */\n formDisabledCallback(disabled) {\n if (disabled) {\n this.setAttribute('disabled', '');\n } else {\n this.removeAttribute('disabled');\n }\n }\n\n /**\n * Setup attributes for the Button element.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n }\n\n /**\n * Draw method for the Button element.\n * @returns {object} fragment - The document fragment containing the drawn element.\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let native = document.createElement(this.hasAttribute('href') ? 'a' : 'button');\n if (this.hasAttribute('href')) {\n native.setAttribute('href', this.getAttribute('href'));\n } else {\n if (this.type === 'submit') {\n native.setAttribute('type', 'submit');\n }\n }\n\n native.classList.add('native-button');\n native.setAttribute('part', 'native');\n\n this.classList.remove('wje-button-disabled');\n\n if (this.disabled) native.classList.add('wje-button-disabled');\n\n if (this.variant) native.classList.add('wje-button-' + this.variant);\n\n if (this.hasAttribute('round')) native.classList.add('wje-button-round');\n\n if (this.hasAttribute('circle')) native.classList.add('wje-button-circle');\n\n if (this.outline) native.classList.add('wje-outline');\n\n if (this.fill) native.classList.add('wje-button-' + this.fill);\n\n if (this.size) native.classList.add('wje-button-' + this.size);\n\n if (\n (this.querySelectorAll('[slot=caret]').length < 1 && this.hasAttribute('caret')) ||\n this.hasAttribute('only-caret')\n ) {\n let i = document.createElement('wje-icon');\n i.style.setProperty('--wje-icon-size', '14px');\n i.setAttribute('slot', 'caret');\n i.setAttribute('name', 'chevron-down');\n i.setAttribute('part', 'caret');\n\n this.appendChild(i);\n }\n\n if (this.active) {\n this.classList.add('wje-active');\n let i = document.createElement('wje-icon');\n i.setAttribute('name', 'check');\n\n this.appendChild(i);\n }\n\n native.classList.add('wje-color-' + this.color, 'wje-color');\n\n let span = document.createElement('span');\n span.setAttribute('part', 'inner');\n span.classList.add('button-inner');\n\n let slot = document.createElement('slot');\n slot.setAttribute('name', 'icon-only');\n span.appendChild(slot);\n\n slot = document.createElement('slot');\n slot.setAttribute('name', 'start');\n span.appendChild(slot);\n\n slot = document.createElement('slot');\n span.appendChild(slot);\n\n slot = document.createElement('slot');\n slot.setAttribute('name', 'end');\n span.appendChild(slot);\n\n slot = document.createElement('slot');\n slot.setAttribute('name', 'caret');\n span.appendChild(slot);\n\n this.hasToggle = WjElementUtils.hasSlot(this, 'toggle');\n\n if (this.hasToggle) {\n this.slotToggle = document.createElement('slot');\n this.slotToggle.setAttribute('name', 'toggle');\n\n span.appendChild(this.slotToggle);\n }\n\n native.appendChild(span);\n\n if (this.tooltip) {\n let tooltip = document.createElement('wje-tooltip');\n tooltip.setAttribute('content', this.getAttribute('tooltip'));\n tooltip.setAttribute('placement', this.getAttribute('tooltip-placement') || 'top');\n tooltip.appendChild(native);\n\n fragment.appendChild(tooltip);\n } else {\n fragment.appendChild(native);\n }\n\n return fragment;\n }\n\n populateCustomEvent() {\n let customEvent = this.customEvent;\n let customEventParameters = this.customEventParameters;\n\n this.dispatchEvent(\n new CustomEvent(customEvent, { detail: customEventParameters, composed: true, bubbles: true })\n );\n }\n\n /**\n * After draw method for the Button element.\n */\n afterDraw() {\n if (this.hasAttribute('route')) {\n this.unbindRouterLinks = bindRouterLinks(this.parentElement, { selector: false });\n }\n\n // nastavenie toggle podla atributu, ak nie je nastaveny, tak sa zobrazi vzdy prvy element\n if (this.hasToggle) {\n if (this.toggle === 'off') {\n this.slotToggle.assignedNodes()[1].classList.add('show');\n this.setAttribute('value', 'off');\n } else {\n this.slotToggle.assignedNodes()[0].classList.add('show');\n this.setAttribute('value', 'on');\n }\n }\n\n if (this.hasAttribute('custom-event')) {\n event.addListener(this, 'click', null, this.populateCustomEvent);\n }\n\n if (this.hasAttribute('dialog')) {\n event.addListener(this, 'click', null, this.eventDialogOpen);\n } else {\n event.addListener(this, 'click', 'wje-button:click', null); // { stopPropagation: this.stopPropagation } - zrusene kvoli dropdown kde som nevedel odchytit event click\n }\n\n if (this.hasToggle)\n event.addListener(this, 'click', 'wje-button:toggle', this.toggleStates, {\n stopPropagation: this.stopPropagation,\n });\n\n if (this.type === 'submit') {\n event.addListener(this, 'click', 'wje-button:submit', () => {\n console.log('submit', this.internals_.form);\n event.dispatchCustomEvent(this.internals_.form, 'submit', {});\n });\n }\n\n if (this.type === 'reset') {\n event.addListener(this, 'click', 'wje-button:reset', () => {\n this.internals_.form.reset();\n });\n }\n }\n\n /**\n * Before disconnect method for the Button element.\n */\n beforeDisconnect() {\n // remove all events from the button\n event.removeListener(this, 'click', null, this.eventDialogOpen);\n event.removeListener(this, 'click', 'wje-button:click', null);\n event.removeListener(this, 'click', 'wje-button:toggle', this.toggleStates);\n event.removeListener(this, 'click', null, this.populateCustomEvent);\n event.removeListener(this, 'click', 'wje-button:submit', null);\n event.removeListener(this, 'click', 'wje-button:reset', null);\n\n this.removeEventListener('click', this.eventDialogOpen);\n this.unbindRouterLinks?.();\n }\n\n /**\n * Event dialog open method for the Button element.\n * @param {Event} e The event object\n */\n eventDialogOpen = (e) => {\n event.dispatchCustomEvent(this, this.dialog);\n };\n\n /**\n * Toggle states method for the Button element.\n */\n toggleStates = () => {\n const nodes = this.slotToggle.assignedNodes().filter((node) => node.nodeType === Node.ELEMENT_NODE);\n\n nodes.forEach((node, index) => {\n if (node.classList.contains('show')) {\n node.classList.remove('show');\n } else {\n node.classList.add('show');\n this.setAttribute('value', index === 0 ? 'on' : 'off');\n }\n });\n };\n}\n","import Button from './button.element.js';\n\nexport default Button;\n\nButton.define('wje-button', Button);\n"],"names":[],"mappings":";;;;;;AAAO,MAAM,OAAO,CAAC,MAAM;AACvB,SAAO,MAAM,WAAW,MAAM,UAAU,MAAM,SAAS,MAAM,eAAe,MAAM,MAAM,QAAQ,CAAC,CAAC;AACtG;;AC4Be,MAAM,eAAe,UAAU;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AqB,IAAI;AAC7D,UAAM,eAAe,MAAM,SAAS,oBAAoB,IAAI;AAE5D,SAAK,oBAAoB,SAAS,KAAK,eAAe;AACtD,eAAK,sBAAL;AAAA,EACR;AAyBA;AAAA;AAAA;AAAA;AAAA;AAAA;AAzOI,cAvNiB,QAuNV,kBAAiB;ACjP5B,OAAO,OAAO,cAAc,MAAM;"}
|
|
1
|
+
{"version":3,"file":"wje-button.js","sources":["../packages/utils/utils.js","../packages/wje-button/button.element.js","../packages/wje-button/button.js"],"sourcesContent":["export const bool = (v) => {\n return v === 'false' || v === 'null' || v === 'NaN' || v === 'undefined' || v === '0' ? false : !!v;\n};\n","import { bindRouterLinks } from 'slick-router/middlewares/router-links.js';\n\nimport { bool } from '../utils/utils.js';\nimport { default as WJElement, event, WjElementUtils } from '../wje-element/element.js';\nimport Icon from '../wje-icon/icon.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * @summary This class represents Button element, extending the WJElement class.\n * @documentation https://elements.webjet.sk/components/button\n * @status stable\n * @augments WJElement\n * @dependency wje-icon\n * @slot - The button main content.\n * @slot icon - The button icon.\n * @slot caret - The button caret.\n * @slot start - The button start slot.\n * @slot end - The button end slot.\n * @slot toggle - The button toggle slot.\n * @csspart native - The component's native wrapper.\n * @cssproperty [--wje-button-background-color=transparent] - Background color of the component;\n * @cssproperty [--wje-button-border-color=--wje-color-contrast-4] - Border color of the component;\n * @cssproperty [--wje-button-color=--wje-color-contrast-11] - Color of the component;\n * @cssproperty [--wje-button-border-radius=--wje-border-radius-medium] - Border radius of the component;\n * @cssproperty [--wje-button-border-width=1px] - Border width of the component;\n * @cssproperty [--wje-button-border-style=solid] - Border style of the component;\n * @cssproperty [--wje-button-border-color=--wje-color-contrast-1] - Border color of the component;\n * @cssproperty [--wje-button-margin-inline=0] - Margin inline of the component;\n */\n\nexport default class Button extends WJElement {\n /**\n * Button constructor method.\n * @class\n */\n constructor() {\n super();\n\n this.internals_ = this.attachInternals();\n }\n\n /**\n * Dependencies of the Button element.\n * @type {object}\n */\n dependencies = {\n 'wje-icon': Icon,\n };\n\n /**\n * Properties of the element Button.\n * @param value\n */\n set color(value) {\n this.setAttribute('color', value || 'default');\n }\n\n /**\n * Get color of the Button element.\n * @returns {string|string}\n */\n get color() {\n return this.getAttribute('color') || 'default';\n }\n\n /**\n * Set variant of the Button element.\n * @param value\n */\n set caret(value) {\n this.setAttribute('caret', value);\n }\n\n /**\n * Get variant of the Button element.\n * @returns {boolean}\n */\n get caret() {\n return this.hasAttribute('caret');\n }\n\n /**\n * Sets the 'round' attribute on the element. If the value is true, the attribute is added;\n * otherwise, it is removed from the element.\n * @param {boolean} value A boolean indicating whether to set or remove the 'round' attribute.\n */\n set round(value) {\n if (value) {\n this.setAttribute('round', '');\n } else {\n this.removeAttribute('round');\n }\n }\n\n /**\n * Retrieves the value of the 'round' attribute as a boolean.\n * Checks if the 'round' attribute is present on the element.\n * @returns {boolean} True if the 'round' attribute exists, otherwise false.\n */\n get round() {\n return this.hasAttribute('round');\n }\n\n /**\n * Set variant of the Button element.\n * @param value\n */\n set tooltip(value) {\n this.setAttribute('tooltip', value);\n }\n\n /**\n * Get variant of the Button element.\n * @returns {boolean}\n */\n get tooltip() {\n return this.hasAttribute('tooltip');\n }\n\n /**\n * Set variant of the Button element.\n * @param value\n */\n set dialog(value) {\n this.setAttribute('dialog', value);\n }\n\n /**\n * Get variant of the Button element.\n * @returns {string|object}\n */\n get dialog() {\n return this.getAttribute('dialog');\n }\n\n /**\n * Set active state of the Button element.\n * @param {boolean} value The value to set\n */\n set active(value) {\n this.setAttribute('active', '');\n }\n\n /**\n * Get active state of the Button element.\n * @returns {boolean} active - The active state\n */\n get active() {\n return this.hasAttribute('active');\n }\n\n /**\n * Set disabled state of the Button element.\n * @param {boolean} value The value to set\n */\n set disabled(value) {\n this.removeAttribute('disabled');\n\n if (value) {\n this.setAttribute('disabled', '');\n }\n }\n\n /**\n * Get disabled state of the Button element.\n * @returns {boolean} disabled - The disabled state\n */\n get disabled() {\n return this.hasAttribute('disabled');\n }\n\n /**\n * Set fill of the Button element.\n * @param {string} value The value to set\n */\n set fill(value) {\n this.setAttribute('fill', value);\n }\n\n /**\n * Get fill of the Button element.\n * @returns {string} fill - The fill value\n */\n get fill() {\n return this.getAttribute('fill') || 'solid';\n }\n\n /**\n * Set outline state of the Button element.\n * @param {boolean} value The value to set\n */\n set outline(value) {\n this.setAttribute('outline', '');\n }\n\n /**\n * Get outline state of the Button element.\n * @returns {boolean} outline - The outline state\n */\n get outline() {\n return this.hasAttribute('outline');\n }\n\n /**\n * Set stop propagation state of the Button element.\n * @param {boolean} value The value to set\n */\n set stopPropagation(value) {\n this.setAttribute('stop-propagation', bool(value));\n }\n\n /**\n * Get stop propagation state of the Button element.\n * @returns {boolean} stopPropagation - The stop propagation state\n */\n get stopPropagation() {\n return bool(this.getAttribute('stop-propagation'));\n }\n\n /**\n * Sets the value of the custom event attribute.\n * @param {string} value The value to be assigned to the custom event attribute.\n */\n set customEvent(value) {\n this.setAttribute('custom-event', value);\n }\n\n /**\n * Retrieves the value of the 'custom-event' attribute from the element.\n * @returns {string | null} The value of the 'custom-event' attribute, or null if the attribute is not set.\n */\n get customEvent() {\n return this.getAttribute('custom-event');\n }\n\n /**\n * Retrieves a mapped object containing custom event parameters extracted from the element's attributes.\n * Attributes considered are those that begin with 'custom-event-'.\n * The mapped object's keys are derived by removing the 'custom-event-' prefix from the attribute names,\n * and the values are the corresponding attribute values.\n * @returns {object} An object containing key-value pairs of custom event parameters.\n */\n get customEventParameters() {\n const attributes = Array.from(this.attributes).filter((attr) => attr.name.startsWith('custom-event-'));\n\n return attributes.reduce((acc, attr) => {\n const key = attr.name.replace('custom-event-', '');\n acc[key] = attr.value;\n\n return acc;\n }, {});\n }\n\n /**\n * Class name for the Button element\n * @type {string}\n */\n className = 'Button';\n\n /**\n * Get CSS stylesheet for the Button element.\n * @static\n * @returns {CSSStyleSheet} styles - The CSS stylesheet for the Button element.\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Get observed attributes for the Button element.\n * @static\n * @returns {Array<string>} observedAttributes - The observed attributes array for the Button element.\n */\n static get observedAttributes() {\n return ['disabled'];\n }\n\n /**\n * @summary A static property that indicates whether the custom element is form-associated or not.\n * Form-associated custom elements are elements that can participate in form submission.\n * @type {boolean}\n */\n static formAssociated = true;\n\n /**\n * @summary Callback function that is called when the custom element is associated with a form.\n * This function sets the internal `_form` property to the associated form.\n * @param {HTMLFormElement} form The form the custom element is associated with.\n */\n formAssociatedCallback(form) {\n this._form = form;\n }\n\n /**\n * @summary Callback function that is called when the form-associated state of the custom element changes.\n * This function updates the 'disabled' attribute of the element based on the new state.\n * @param {boolean} disabled The new form-associated state.\n */\n formDisabledCallback(disabled) {\n if (disabled) {\n this.setAttribute('disabled', '');\n } else {\n this.removeAttribute('disabled');\n }\n }\n\n /**\n * Setup attributes for the Button element.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n }\n\n /**\n * Draw method for the Button element.\n * @returns {object} fragment - The document fragment containing the drawn element.\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let native = document.createElement(this.hasAttribute('href') ? 'a' : 'button');\n if (this.hasAttribute('href')) {\n native.setAttribute('href', this.getAttribute('href'));\n } else {\n if (this.type === 'submit') {\n native.setAttribute('type', 'submit');\n }\n }\n\n native.classList.add('native-button');\n native.setAttribute('part', 'native');\n\n this.classList.remove('wje-button-disabled');\n\n if (this.disabled) native.classList.add('wje-button-disabled');\n\n if (this.variant) native.classList.add('wje-button-' + this.variant);\n\n if (this.hasAttribute('round')) native.classList.add('wje-button-round');\n\n if (this.hasAttribute('circle')) native.classList.add('wje-button-circle');\n\n if (this.outline) native.classList.add('wje-outline');\n\n if (this.fill) native.classList.add('wje-button-' + this.fill);\n\n if (this.size) native.classList.add('wje-button-' + this.size);\n\n if (\n (this.querySelectorAll('[slot=caret]').length < 1 && this.hasAttribute('caret')) ||\n this.hasAttribute('only-caret')\n ) {\n let i = document.createElement('wje-icon');\n i.style.setProperty('--wje-icon-size', '14px');\n i.setAttribute('slot', 'caret');\n i.setAttribute('name', 'chevron-down');\n i.setAttribute('part', 'caret');\n\n this.appendChild(i);\n }\n\n if (this.active) {\n this.classList.add('wje-active');\n let i = document.createElement('wje-icon');\n i.setAttribute('name', 'check');\n\n this.appendChild(i);\n }\n\n native.classList.add('wje-color-' + this.color, 'wje-color');\n\n let span = document.createElement('span');\n span.setAttribute('part', 'inner');\n span.classList.add('button-inner');\n\n let slot = document.createElement('slot');\n slot.setAttribute('name', 'icon-only');\n span.appendChild(slot);\n\n slot = document.createElement('slot');\n slot.setAttribute('name', 'start');\n span.appendChild(slot);\n\n slot = document.createElement('slot');\n span.appendChild(slot);\n\n slot = document.createElement('slot');\n slot.setAttribute('name', 'end');\n span.appendChild(slot);\n\n slot = document.createElement('slot');\n slot.setAttribute('name', 'caret');\n span.appendChild(slot);\n\n this.hasToggle = WjElementUtils.hasSlot(this, 'toggle');\n\n if (this.hasToggle) {\n this.slotToggle = document.createElement('slot');\n this.slotToggle.setAttribute('name', 'toggle');\n\n span.appendChild(this.slotToggle);\n }\n\n native.appendChild(span);\n\n if (this.tooltip) {\n let tooltip = document.createElement('wje-tooltip');\n tooltip.setAttribute('content', this.getAttribute('tooltip'));\n tooltip.setAttribute('placement', this.getAttribute('tooltip-placement') || 'top');\n tooltip.appendChild(native);\n\n fragment.appendChild(tooltip);\n } else {\n fragment.appendChild(native);\n }\n\n return fragment;\n }\n\n /**\n * After draw method for the Button element.\n */\n afterDraw() {\n if (this.hasAttribute('route')) {\n this.unbindRouterLinks = bindRouterLinks(this.parentElement, { selector: false });\n }\n\n // nastavenie toggle podla atributu, ak nie je nastaveny, tak sa zobrazi vzdy prvy element\n if (this.hasToggle) {\n if (this.toggle === 'off') {\n this.slotToggle.assignedNodes()[1].classList.add('show');\n this.setAttribute('value', 'off');\n } else {\n this.slotToggle.assignedNodes()[0].classList.add('show');\n this.setAttribute('value', 'on');\n }\n }\n\n if (this.hasAttribute('custom-event')) {\n event.addListener(this, 'click', null, this.#populateCustomEvent);\n }\n\n if (this.hasAttribute('dialog')) {\n event.addListener(this, 'click', null, this.eventDialogOpen);\n } else {\n event.addListener(this, 'click', 'wje-button:click', null); // { stopPropagation: this.stopPropagation } - zrusene kvoli dropdown kde som nevedel odchytit event click\n }\n\n if (this.hasToggle)\n event.addListener(this, 'click', 'wje-button:toggle', this.toggleStates, {\n stopPropagation: this.stopPropagation,\n });\n\n if (this.type === 'submit') {\n event.addListener(this, 'click', 'wje-button:submit', () => {\n console.log('submit', this.internals_.form);\n event.dispatchCustomEvent(this.internals_.form, 'submit', {});\n });\n }\n\n if (this.type === 'reset') {\n event.addListener(this, 'click', 'wje-button:reset', () => {\n this.internals_.form.reset();\n });\n }\n }\n\n /**\n * Before disconnect method for the Button element.\n */\n beforeDisconnect() {\n // remove all events from the button\n event.removeListener(this, 'click', null, this.eventDialogOpen);\n event.removeListener(this, 'click', 'wje-button:click', null);\n event.removeListener(this, 'click', 'wje-button:toggle', this.toggleStates);\n event.removeListener(this, 'click', null, this.#populateCustomEvent);\n event.removeListener(this, 'click', 'wje-button:submit', null);\n event.removeListener(this, 'click', 'wje-button:reset', null);\n\n this.removeEventListener('click', this.eventDialogOpen);\n this.unbindRouterLinks?.();\n }\n\n /**\n * Event dialog open method for the Button element.\n * @param {Event} e The event object\n */\n eventDialogOpen = (e) => {\n event.dispatchCustomEvent(this, this.dialog);\n };\n\n /**\n * Toggle states method for the Button element.\n */\n toggleStates = () => {\n const nodes = this.slotToggle.assignedNodes().filter((node) => node.nodeType === Node.ELEMENT_NODE);\n\n nodes.forEach((node, index) => {\n if (node.classList.contains('show')) {\n node.classList.remove('show');\n } else {\n node.classList.add('show');\n this.setAttribute('value', index === 0 ? 'on' : 'off');\n }\n });\n }\n\n /**\n * Dispatches a custom event with specified parameters.\n * This method uses the `customEvent` and `customEventParameters` properties\n * to create and dispatch a `CustomEvent`. The event is configured to be\n * composed and bubbles up through the DOM.\n * @returns {void} This method does not return a value.\n */\n #populateCustomEvent() {\n this.dispatchEvent(\n new CustomEvent(this.customEvent, { detail: this.customEventParameters, composed: true, bubbles: true })\n );\n }\n}\n","import Button from './button.element.js';\n\nexport default Button;\n\nButton.define('wje-button', Button);\n"],"names":[],"mappings":";;;;;;;;;;;;;AAAO,MAAM,OAAO,CAAC,MAAM;AACvB,SAAO,MAAM,WAAW,MAAM,UAAU,MAAM,SAAS,MAAM,eAAe,MAAM,MAAM,QAAQ,CAAC,CAAC;AACtG;;AC4Be,MAAM,eAAe,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA,EAK1C,cAAc;AACV,UAAO;AANA;AAeX;AAAA;AAAA;AAAA;AAAA,wCAAe;AAAA,MACX,YAAY;AAAA,IACf;AAkND;AAAA;AAAA;AAAA;AAAA,qCAAY;AAsOZ;AAAA;AAAA;AAAA;AAAA,2CAAkB,CAAC,MAAM;AACrB,YAAM,oBAAoB,MAAM,KAAK,MAAM;AAAA,IAC9C;AAKD;AAAA;AAAA;AAAA,wCAAe,MAAM;AACjB,YAAM,QAAQ,KAAK,WAAW,cAAa,EAAG,OAAO,CAAC,SAAS,KAAK,aAAa,KAAK,YAAY;AAElG,YAAM,QAAQ,CAAC,MAAM,UAAU;AAC3B,YAAI,KAAK,UAAU,SAAS,MAAM,GAAG;AACjC,eAAK,UAAU,OAAO,MAAM;AAAA,QAC5C,OAAmB;AACH,eAAK,UAAU,IAAI,MAAM;AACzB,eAAK,aAAa,SAAS,UAAU,IAAI,OAAO,KAAK;AAAA,QACrE;AAAA,MACA,CAAS;AAAA,IACT;AAndQ,SAAK,aAAa,KAAK,gBAAiB;AAAA,EAChD;AAAA;AAAA;AAAA;AAAA;AAAA,EAcI,IAAI,MAAM,OAAO;AACb,SAAK,aAAa,SAAS,SAAS,SAAS;AAAA,EACrD;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,IAAI,QAAQ;AACR,WAAO,KAAK,aAAa,OAAO,KAAK;AAAA,EAC7C;AAAA;AAAA;AAAA;A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,IAAI;AAC1C,cAAM,oBAAoB,KAAK,WAAW,MAAM,UAAU,EAAE;AAAA,MAC5E,CAAa;AAAA,IACb;AAEQ,QAAI,KAAK,SAAS,SAAS;AACvB,YAAM,YAAY,MAAM,SAAS,oBAAoB,MAAM;AACvD,aAAK,WAAW,KAAK,MAAO;AAAA,MAC5C,CAAa;AAAA,IACb;AAAA,EACA;AAAA;AAAA;AAAA;AAAA,EAKI,mBAAmB;;AAEf,UAAM,eAAe,MAAM,SAAS,MAAM,KAAK,eAAe;AAC9D,UAAM,eAAe,MAAM,SAAS,oBAAoB,IAAI;AAC5D,UAAM,eAAe,MAAM,SAAS,qBAAqB,KAAK,YAAY;AAC1E,UAAM,eAAe,MAAM,SAAS,MAAM,sBAAK,0CAAoB;AACnE,UAAM,eAAe,MAAM,SAAS,qBAAqB,IAAI;AAC7D,UAAM,eAAe,MAAM,SAAS,oBAAoB,IAAI;AAE5D,SAAK,oBAAoB,SAAS,KAAK,eAAe;AACtD,eAAK,sBAAL;AAAA,EACR;AAsCA;AAzee;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAoeX,yBAAoB,WAAG;AACnB,OAAK;AAAA,IACH,IAAI,YAAY,KAAK,aAAa,EAAE,QAAQ,KAAK,uBAAuB,UAAU,MAAM,SAAS,KAAM,CAAA;AAAA,EACxG;AACT;AAAA;AAAA;AAAA;AAAA;AAAA;AA5OI,cA5PiB,QA4PV,kBAAiB;ACtR5B,OAAO,OAAO,cAAc,MAAM;"}
|
package/dist/wje-chip.js
CHANGED
|
@@ -2,7 +2,7 @@ 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, { WjElementUtils, event } from "./wje-element.js";
|
|
5
|
-
const styles = "/*\n[ WJ Chip ]\n*/\n\n.native-chip {\n display: inline-flex;\n justify-content: center;\n align-items: center;\n font-size:
|
|
5
|
+
const styles = "/*\n[ WJ Chip ]\n*/\n\n:host {\n display: inline-flex;\n --wje-chip-round-border-radius: var(--wje-border-radius-large);\n --wje-button-border-radius: var(--wje-chip-round-border-radius);\n}\n\n.native-chip {\n display: inline-flex;\n justify-content: center;\n align-items: center;\n font-size: var(--wje-font-size);\n line-height: 1;\n letter-spacing: -0.006em;\n margin: 0;\n padding: 0 var(--wje-spacing-small);\n text-align: center;\n cursor: pointer;\n white-space: nowrap;\n text-shadow: none;\n box-shadow: none;\n border: 0 none;\n width: 100%;\n height: 28px;\n max-width: fit-content;\n position: relative;\n transition: width 0.15s cubic-bezier(0.4, 0, 0.2, 1);\n border-radius: var(--wje-border-radius-pill);\n overflow: hidden;\n vertical-align: middle;\n box-sizing: border-box;\n}\n\n:host(.focus) {\n box-shadow: none;\n}\n\n:host(.wje-active) .native-chip {\n border: 1px solid var(--wje-color-primary-11);\n background-color: var(--wje-color-contrast-3);\n color: var(--wje-color);\n}\n\n:host(:focus, :active:focus, .wje-active:focus) {\n outline: none !important;\n}\n\n:host([size='small']) .native-chip {\n font-size: var(--wje-font-size-small);\n height: 24px;\n padding: var(--wje-spacing-3x-small) var(--wje-spacing-x-small);\n wje-button {\n --wje-button-margin-inline: var(--wje-spacing-3x-small) calc(-1 * var(--wje-spacing-3x-small));\n }\n}\n\n:host([size='large']) .native-chip {\n font-size: var(--wje-font-size-medium);\n height: 34px;\n padding: var(--wje-spacing-x-small) var(--wje-spacing-small);\n\n}\n\n:host([round]) .native-chip {\n border-radius: var(--wje-chip-round-border-radius);\n}\n\n.check {\n display: none;\n}\n\n:host([active]) {\n .check {\n display: block;\n margin-inline: 4px 0;\n }\n}\n\n:host([disabled]) {\n opacity: 0.5;\n border: 0;\n pointer-events: none;\n cursor: not-allowed;\n}\n\n::slotted(wje-avatar) {\n width: 22px;\n height: 22px;\n}\n\n::slotted(wje-avatar:first-child) {\n margin-inline: -8px 8px;\n margin-top: -4px;\n margin-bottom: -4px;\n}\n\n::slotted(wje-icon:first-child) {\n margin: -4px 8px -4px -4px;\n}\n\n::slotted(wje-icon:last-child) {\n margin: -4px -4px -4px 8px;\n}\n\nslot[name='end'].has-content {\n display: block;\n margin-inline-start: 8px;\n}\n\nwje-button {\n /*--wje-button-border-radius: 50%;*/\n --wje-button-margin-inline: 0.25rem -0.5rem;\n --wje-padding-top: 0.15rem;\n --wje-padding-start: 0.15rem;\n --wje-padding-end: 0.15rem;\n --wje-padding-bottom: 0.15rem;\n}\n\n/*BG - TEXT*/\n.native-chip.wje-color-primary {\n background-color: var(--wje-color-primary-1);\n color: var(--wje-color-primary-9);\n}\n\n.native-chip.wje-color-complete {\n background-color: var(--wje-color-complete-1);\n color: var(--wje-color-complete-9);\n}\n\n.native-chip.wje-color-success {\n background-color: var(--wje-color-success-1);\n color: var(--wje-color-success-9);\n}\n\n.native-chip.wje-color-warning {\n background-color: var(--wje-color-warning-2);\n color: var(--wje-color-warning-11);\n}\n\n.native-chip.wje-color-danger {\n background-color: var(--wje-color-danger-1);\n color: var(--wje-color-danger-9);\n}\n\n.native-chip.wje-color-info {\n background-color: var(--wje-color-info-1);\n color: var(--wje-color-info-9);\n}\n\n.native-chip.wje-color-default {\n background-color: var(--wje-color-contrast-3);\n color: var(--wje-color-contrast-11);\n}\n\n/*HOVER*/\n@media (any-hover: hover) {\n .native-chip.wje-color-primary:hover {\n background-color: var(--wje-color-primary-4);\n color: var(--wje-color-primary-10);\n }\n\n .native-chip.wje-color-complete:hover {\n background-color: var(--wje-color-complete-4);\n color: var(--wje-color-complete-10);\n }\n\n .native-chip.wje-color-success:hover {\n background-color: var(--wje-color-success-4);\n color: var(--wje-color-success-10);\n }\n\n .native-chip.wje-color-warning:hover {\n background-color: var(--wje-color-warning-4);\n color: var(--wje-color-warning-11);\n }\n\n .native-chip.wje-color-danger:hover {\n background-color: var(--wje-color-danger-4);\n color: var(--wje-color-danger-10);\n }\n\n .native-chip.wje-color-info:hover {\n background-color: var(--wje-color-info-4);\n color: var(--wje-color-info-10);\n }\n\n .native-chip.wje-color-default:hover {\n background-color: var(--wje-color-contrast-4);\n color: var(--wje-color-contrast-11);\n }\n}\n";
|
|
6
6
|
class Chip extends WJElement {
|
|
7
7
|
/**
|
|
8
8
|
* Chip constructor method.
|
|
@@ -15,6 +15,60 @@ class Chip extends WJElement {
|
|
|
15
15
|
*/
|
|
16
16
|
__publicField(this, "className", "Chip");
|
|
17
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* Sets or removes the "round" attribute on the element based on the provided value.
|
|
20
|
+
* @param {boolean} value Determines whether the "round" attribute should be set or removed.
|
|
21
|
+
* If true, the "round" attribute is added. If false, the "round"
|
|
22
|
+
* attribute is removed.
|
|
23
|
+
*/
|
|
24
|
+
set round(value) {
|
|
25
|
+
if (value) {
|
|
26
|
+
this.setAttribute("round", "");
|
|
27
|
+
} else {
|
|
28
|
+
this.removeAttribute("round");
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Checks if the 'round' attribute is present on the element.
|
|
33
|
+
* @returns {boolean} Returns true if the 'round' attribute exists, otherwise false.
|
|
34
|
+
*/
|
|
35
|
+
get round() {
|
|
36
|
+
return this.hasAttribute("round");
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Sets the size attribute of the element.
|
|
40
|
+
* @param {string} value The value to set for the size attribute.
|
|
41
|
+
*/
|
|
42
|
+
set size(value) {
|
|
43
|
+
this.setAttribute("size", value);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Retrieves the 'size' attribute of the current element.
|
|
47
|
+
* @returns {string | null} The value of the 'size' attribute, or null if the attribute is not set.
|
|
48
|
+
*/
|
|
49
|
+
get size() {
|
|
50
|
+
return this.getAttribute("size");
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Sets or removes the "removable" attribute on the element.
|
|
54
|
+
* @param {boolean} value A boolean indicating whether the element should have the "removable" attribute.
|
|
55
|
+
* If true, the "removable" attribute is added;
|
|
56
|
+
* if false, the "removable" attribute is removed.
|
|
57
|
+
*/
|
|
58
|
+
set removable(value) {
|
|
59
|
+
if (value) {
|
|
60
|
+
this.setAttribute("removable", "");
|
|
61
|
+
} else {
|
|
62
|
+
this.removeAttribute("removable");
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Determines if the element has the 'removable' attribute.
|
|
67
|
+
* @returns {boolean} True if the element has the 'removable' attribute, otherwise false.
|
|
68
|
+
*/
|
|
69
|
+
get removable() {
|
|
70
|
+
return this.hasAttribute("removable");
|
|
71
|
+
}
|
|
18
72
|
/**
|
|
19
73
|
* Getter for the CSS stylesheet.
|
|
20
74
|
* @returns {*}
|
|
@@ -43,7 +97,16 @@ class Chip extends WJElement {
|
|
|
43
97
|
remove.setAttribute("part", "remove");
|
|
44
98
|
remove.setAttribute("fill", "link");
|
|
45
99
|
remove.setAttribute("color", this.color || "default");
|
|
46
|
-
remove.
|
|
100
|
+
remove.round = !this.round;
|
|
101
|
+
if (this.hasAttribute("size")) {
|
|
102
|
+
if (this.size === "small") {
|
|
103
|
+
remove.innerHTML = `<wje-icon name="x" size="small"></wje-icon>`;
|
|
104
|
+
} else if (this.size === "large") {
|
|
105
|
+
remove.innerHTML = `<wje-icon name="x"></wje-icon>`;
|
|
106
|
+
}
|
|
107
|
+
} else {
|
|
108
|
+
remove.innerHTML = `<wje-icon name="x"></wje-icon>`;
|
|
109
|
+
}
|
|
47
110
|
let active = document.createElement("wje-icon");
|
|
48
111
|
active.setAttribute("name", "check");
|
|
49
112
|
active.classList.add("check");
|
|
@@ -54,7 +117,7 @@ class Chip extends WJElement {
|
|
|
54
117
|
native.appendChild(slot);
|
|
55
118
|
native.appendChild(slotEnd);
|
|
56
119
|
native.appendChild(active);
|
|
57
|
-
if (this.
|
|
120
|
+
if (this.removable) native.appendChild(remove);
|
|
58
121
|
fragment.appendChild(native);
|
|
59
122
|
this.removeElement = remove;
|
|
60
123
|
this.slotEnd = slotEnd;
|