wj-elements 0.2.0-alpha.9 → 0.3.0-alpha.1
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/dark.css +15 -1
- package/dist/{form-associated-element-o0UjvdUp.js → form-associated-element-DEQ4y-jn.js} +1 -2
- package/dist/form-associated-element-DEQ4y-jn.js.map +1 -0
- package/dist/{icon-DY5AZ6xM.js → icon-DVyMc4Wv.js} +36 -2
- package/dist/{icon-DY5AZ6xM.js.map → icon-DVyMc4Wv.js.map} +1 -1
- package/dist/light.css +7 -2
- package/dist/localize.js +8 -5
- package/dist/localize.js.map +1 -1
- package/dist/packages/internals/form-associated-element.d.ts +0 -1
- package/dist/packages/utils/utils.d.ts +16 -0
- package/dist/packages/wje-accordion-item/accordion-item.element.d.ts +3 -0
- package/dist/packages/wje-avatar/avatar.element.d.ts +5 -0
- package/dist/packages/wje-breadcrumb/breadcrumb.element.d.ts +1 -0
- package/dist/packages/wje-button/button.element.d.ts +5 -1
- package/dist/packages/wje-button-group/button-group.element.d.ts +4 -0
- package/dist/packages/wje-card/card.element.d.ts +15 -6
- package/dist/packages/wje-carousel/carousel.element.d.ts +4 -0
- package/dist/packages/wje-checkbox/checkbox.element.d.ts +14 -0
- package/dist/packages/wje-chip/chip.element.d.ts +6 -0
- package/dist/packages/wje-color-picker/color-picker.element.d.ts +43 -1
- package/dist/packages/wje-copy-button/copy-button.element.d.ts +4 -0
- package/dist/packages/wje-dialog/dialog.element.d.ts +2 -0
- package/dist/packages/wje-dropdown/dropdown.element.d.ts +7 -0
- package/dist/packages/wje-element/element.d.ts +55 -24
- package/dist/packages/wje-file-upload/file-upload.element.d.ts +17 -6
- package/dist/packages/wje-file-upload/service/service.d.ts +0 -23
- package/dist/packages/wje-file-upload-item/file-upload-item.element.d.ts +5 -0
- package/dist/packages/wje-format-digital/format-digital.element.d.ts +2 -0
- package/dist/packages/wje-icon/icon.element.d.ts +11 -0
- package/dist/packages/wje-icon-picker/icon-picker.element.d.ts +4 -0
- package/dist/packages/wje-img/img.element.d.ts +1 -0
- package/dist/packages/wje-infinite-scroll/infinite-scroll.element.d.ts +4 -0
- package/dist/packages/wje-input/input.element.d.ts +9 -1
- package/dist/packages/wje-item/item.element.d.ts +8 -0
- package/dist/packages/wje-kanban/kanban.element.d.ts +4 -0
- package/dist/packages/wje-level-indicator/level-indicator.element.d.ts +17 -0
- package/dist/packages/wje-list/list.element.d.ts +4 -0
- package/dist/packages/wje-menu-item/menu-item.element.d.ts +4 -0
- package/dist/packages/wje-option/option.element.d.ts +4 -0
- package/dist/packages/wje-options/options.element.d.ts +4 -0
- package/dist/packages/wje-orgchart/orgchart.element.d.ts +4 -0
- package/dist/packages/wje-progress-bar/progress-bar.element.d.ts +11 -0
- package/dist/packages/wje-qr-code/qr-code.element.d.ts +63 -0
- package/dist/packages/wje-radio/radio.element.d.ts +5 -0
- package/dist/packages/wje-radio-group/radio-group.element.d.ts +16 -1
- package/dist/packages/wje-rate/rate.element.d.ts +4 -0
- package/dist/packages/wje-relative-time/relative-time.element.d.ts +2 -0
- package/dist/packages/wje-reorder/reorder.element.d.ts +4 -0
- package/dist/packages/wje-reorder-handle/reorder-handle.element.d.ts +4 -0
- package/dist/packages/wje-select/select.element.d.ts +7 -0
- package/dist/packages/wje-slider/slider.element.d.ts +5 -0
- package/dist/packages/wje-sliding-container/sliding-container.element.d.ts +4 -0
- package/dist/packages/wje-split-view/split-view.element.d.ts +1 -0
- package/dist/packages/wje-stepper/stepper.element.d.ts +1 -0
- package/dist/packages/wje-tab/tab.element.d.ts +10 -0
- package/dist/packages/wje-tab-group/tab-group.element.d.ts +11 -0
- package/dist/packages/wje-textarea/textarea.element.d.ts +20 -1
- package/dist/packages/wje-thumbnail/thumbnail.element.d.ts +4 -0
- package/dist/packages/wje-timeline/timeline.element.d.ts +4 -0
- package/dist/packages/wje-toggle/toggle.element.d.ts +4 -0
- package/dist/packages/wje-toolbar/toolbar.element.d.ts +4 -0
- package/dist/packages/wje-tooltip/tooltip.element.d.ts +3 -0
- package/dist/packages/wje-tree/tree.element.d.ts +4 -0
- package/dist/packages/wje-tree-item/tree-item.element.d.ts +5 -0
- package/dist/{popup.element-DeajFyOQ.js → popup.element-Cl6QeG8M.js} +2 -2
- package/dist/{popup.element-DeajFyOQ.js.map → popup.element-Cl6QeG8M.js.map} +1 -1
- package/dist/skeleton.css +197 -0
- package/dist/utils.js +18 -1
- package/dist/utils.js.map +1 -1
- package/dist/wje-accordion-item.js +26 -4
- package/dist/wje-accordion-item.js.map +1 -1
- package/dist/wje-accordion.js +1 -0
- package/dist/wje-accordion.js.map +1 -1
- package/dist/wje-animation.js +1 -0
- package/dist/wje-animation.js.map +1 -1
- package/dist/wje-avatar.js +18 -0
- package/dist/wje-avatar.js.map +1 -1
- package/dist/wje-badge.js +1 -0
- package/dist/wje-badge.js.map +1 -1
- package/dist/wje-breadcrumb.js +13 -1
- package/dist/wje-breadcrumb.js.map +1 -1
- package/dist/wje-breadcrumbs.js +1 -0
- package/dist/wje-breadcrumbs.js.map +1 -1
- package/dist/wje-button-group.js +10 -0
- package/dist/wje-button-group.js.map +1 -1
- package/dist/wje-button.js +29 -5
- package/dist/wje-button.js.map +1 -1
- package/dist/wje-card.js +37 -0
- package/dist/wje-card.js.map +1 -1
- package/dist/wje-carousel.js +38 -4
- package/dist/wje-carousel.js.map +1 -1
- package/dist/wje-checkbox.js +48 -3
- package/dist/wje-checkbox.js.map +1 -1
- package/dist/wje-chip.js +22 -0
- package/dist/wje-chip.js.map +1 -1
- package/dist/wje-color-picker.js +143 -29
- package/dist/wje-color-picker.js.map +1 -1
- package/dist/wje-copy-button.js +21 -0
- package/dist/wje-copy-button.js.map +1 -1
- package/dist/wje-dialog.js +35 -2
- package/dist/wje-dialog.js.map +1 -1
- package/dist/wje-dropdown.js +27 -3
- package/dist/wje-dropdown.js.map +1 -1
- package/dist/wje-element.js +87 -242
- package/dist/wje-element.js.map +1 -1
- package/dist/wje-file-upload-item.js +23 -1
- package/dist/wje-file-upload-item.js.map +1 -1
- package/dist/wje-file-upload.js +100 -77
- package/dist/wje-file-upload.js.map +1 -1
- package/dist/wje-format-digital.js +9 -0
- package/dist/wje-format-digital.js.map +1 -1
- package/dist/wje-icon-picker.js +15 -0
- package/dist/wje-icon-picker.js.map +1 -1
- package/dist/wje-icon.js +1 -1
- package/dist/wje-img-comparer.js +5 -1
- package/dist/wje-img-comparer.js.map +1 -1
- package/dist/wje-img.js +16 -1
- package/dist/wje-img.js.map +1 -1
- package/dist/wje-infinite-scroll.js +10 -0
- package/dist/wje-infinite-scroll.js.map +1 -1
- package/dist/wje-input-file.js +2 -0
- package/dist/wje-input-file.js.map +1 -1
- package/dist/wje-input.js +59 -4
- package/dist/wje-input.js.map +1 -1
- package/dist/wje-item.js +14 -0
- package/dist/wje-item.js.map +1 -1
- package/dist/wje-kanban.js +14 -0
- package/dist/wje-kanban.js.map +1 -1
- package/dist/wje-level-indicator.js +36 -0
- package/dist/wje-level-indicator.js.map +1 -1
- package/dist/wje-list.js +10 -0
- package/dist/wje-list.js.map +1 -1
- package/dist/wje-master.js +11 -2
- package/dist/wje-master.js.map +1 -1
- package/dist/wje-menu-button.js +1 -0
- package/dist/wje-menu-button.js.map +1 -1
- package/dist/wje-menu-item.js +24 -0
- package/dist/wje-menu-item.js.map +1 -1
- package/dist/wje-menu.js +4 -1
- package/dist/wje-menu.js.map +1 -1
- package/dist/wje-option.js +14 -1
- package/dist/wje-option.js.map +1 -1
- package/dist/wje-options.js +13 -0
- package/dist/wje-options.js.map +1 -1
- package/dist/wje-orgchart.js +9 -0
- package/dist/wje-orgchart.js.map +1 -1
- package/dist/wje-pagination.js +18 -9
- package/dist/wje-pagination.js.map +1 -1
- package/dist/wje-popup.js +1 -1
- package/dist/wje-progress-bar.js +26 -0
- package/dist/wje-progress-bar.js.map +1 -1
- package/dist/wje-qr-code.js +159 -17
- package/dist/wje-qr-code.js.map +1 -1
- package/dist/wje-radio-group.js +49 -2
- package/dist/wje-radio-group.js.map +1 -1
- package/dist/wje-radio.js +27 -1
- package/dist/wje-radio.js.map +1 -1
- package/dist/wje-rate.js +23 -1
- package/dist/wje-rate.js.map +1 -1
- package/dist/wje-relative-time.js +14 -1
- package/dist/wje-relative-time.js.map +1 -1
- package/dist/wje-reorder-handle.js +21 -0
- package/dist/wje-reorder-handle.js.map +1 -1
- package/dist/wje-reorder.js +10 -0
- package/dist/wje-reorder.js.map +1 -1
- package/dist/wje-select.js +35 -5
- package/dist/wje-select.js.map +1 -1
- package/dist/wje-slider.js +51 -1
- package/dist/wje-slider.js.map +1 -1
- package/dist/wje-sliding-container.js +18 -0
- package/dist/wje-sliding-container.js.map +1 -1
- package/dist/wje-split-view.js +9 -0
- package/dist/wje-split-view.js.map +1 -1
- package/dist/wje-status.js +1 -0
- package/dist/wje-status.js.map +1 -1
- package/dist/wje-stepper.js +24 -1
- package/dist/wje-stepper.js.map +1 -1
- package/dist/wje-tab-group.js +59 -2
- package/dist/wje-tab-group.js.map +1 -1
- package/dist/wje-tab.js +30 -0
- package/dist/wje-tab.js.map +1 -1
- package/dist/wje-textarea.js +96 -14
- package/dist/wje-textarea.js.map +1 -1
- package/dist/wje-thumbnail.js +19 -0
- package/dist/wje-thumbnail.js.map +1 -1
- package/dist/wje-toast.js +4 -0
- package/dist/wje-toast.js.map +1 -1
- package/dist/wje-toggle.js +17 -1
- package/dist/wje-toggle.js.map +1 -1
- package/dist/wje-toolbar.js +14 -0
- package/dist/wje-toolbar.js.map +1 -1
- package/dist/wje-tooltip.js +31 -7
- package/dist/wje-tooltip.js.map +1 -1
- package/dist/wje-tree-item.js +41 -5
- package/dist/wje-tree-item.js.map +1 -1
- package/dist/wje-tree.js +12 -1
- package/dist/wje-tree.js.map +1 -1
- package/package.json +21 -2
- package/dist/form-associated-element-o0UjvdUp.js.map +0 -1
- package/dist/packages/wje-accordion/accordion.test.d.ts +0 -0
- package/dist/packages/wje-animation/animation.test.d.ts +0 -1
- package/dist/packages/wje-avatar/avatar.test.d.ts +0 -1
- package/dist/packages/wje-badge/badge.test.d.ts +0 -1
- package/dist/packages/wje-breadcrumbs/breadcrumbs.test.d.ts +0 -1
- package/dist/packages/wje-button/button.test.d.ts +0 -1
- package/dist/packages/wje-chip/chip.test.d.ts +0 -1
- package/dist/packages/wje-color-picker/color-picker.test.d.ts +0 -1
- package/dist/packages/wje-file-upload/file-upload.test.d.ts +0 -1
- package/dist/packages/wje-format-digital/format-digital.test.d.ts +0 -1
- package/dist/packages/wje-pagination/pagination.test.d.ts +0 -1
- package/dist/packages/wje-relative-time/relative-time.test.d.ts +0 -1
- package/dist/packages/wje-select/select.test.d.ts +0 -1
- package/dist/packages/wje-tab-group/tab-group.test.d.ts +0 -1
- package/dist/packages/wje-toast/toast.test.d.ts +0 -1
- package/dist/packages/wje-toggle/toggle.test.d.ts +0 -1
- package/dist/packages/wje-tree/tree.test.d.ts +0 -1
- package/dist/packages/wje-tree-item/tree-item.test.d.ts +0 -1
package/dist/dark.css
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
:host,
|
|
6
6
|
.wje-theme-dark,
|
|
7
|
-
.dark
|
|
7
|
+
.dark,
|
|
8
|
+
[data-theme=dark] {
|
|
8
9
|
color-scheme: dark;
|
|
9
10
|
|
|
10
11
|
--wje-font-family:
|
|
@@ -134,6 +135,13 @@
|
|
|
134
135
|
--wje-color-contrast-10: hsla(0, 0%, 98%, 1);
|
|
135
136
|
--wje-color-contrast-11: hsla(0, 0%, 100%, 1);
|
|
136
137
|
|
|
138
|
+
/*
|
|
139
|
+
[ Skeleton ]
|
|
140
|
+
*/
|
|
141
|
+
--wje-skeleton-bg: var(--wje-color-contrast-3);
|
|
142
|
+
--wje-skeleton-bg-strong: var(--wje-color-contrast-5);
|
|
143
|
+
--wje-skeleton-highlight: rgba(255, 255, 255, 0.45);
|
|
144
|
+
|
|
137
145
|
/*
|
|
138
146
|
[ Elements ]
|
|
139
147
|
*/
|
|
@@ -157,6 +165,9 @@
|
|
|
157
165
|
--wje-card-color: var(--wje-color-white);
|
|
158
166
|
--wje-card-border-color: transparent;
|
|
159
167
|
|
|
168
|
+
/* Dialog */
|
|
169
|
+
--wje-dialog-background: var(--wje-color-contrast-1);
|
|
170
|
+
|
|
160
171
|
/* Divider */
|
|
161
172
|
--wje-divider-border-color: var(--wje-border-color);
|
|
162
173
|
|
|
@@ -224,6 +235,9 @@
|
|
|
224
235
|
--wje-orgchart-item-boss-border: 1px solid var(--wje-border-color);
|
|
225
236
|
--wje-orgchart-item-hover-border: 1px solid var(--wje-color-danger-3);
|
|
226
237
|
|
|
238
|
+
/* Popup */
|
|
239
|
+
--wje-popup-overlay-background: var(--wje-color-contrast-0);
|
|
240
|
+
|
|
227
241
|
/* Rate */
|
|
228
242
|
--wje-rate-color: var(--wje-color-contrast-11);
|
|
229
243
|
--wje-rate-selected-color: var(--wje-color-danger-6);
|
|
@@ -6,7 +6,6 @@ import { event } from "./event.js";
|
|
|
6
6
|
class FormAssociatedElement extends WJElement {
|
|
7
7
|
constructor() {
|
|
8
8
|
super();
|
|
9
|
-
this.internals = this.attachInternals();
|
|
10
9
|
}
|
|
11
10
|
/**
|
|
12
11
|
* Sets the 'name' attribute to the given value.
|
|
@@ -243,4 +242,4 @@ __publicField(FormAssociatedElement, "formAssociated", true);
|
|
|
243
242
|
export {
|
|
244
243
|
FormAssociatedElement as F
|
|
245
244
|
};
|
|
246
|
-
//# sourceMappingURL=form-associated-element-
|
|
245
|
+
//# sourceMappingURL=form-associated-element-DEQ4y-jn.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"form-associated-element-DEQ4y-jn.js","sources":["../packages/internals/form-associated-element.js"],"sourcesContent":["import { default as WJElement, event } from \"../wje-element/element.js\";\n\nexport class FormAssociatedElement extends WJElement {\n static formAssociated = true;\n\n constructor() {\n super();\n }\n\n /**\n * Sets the 'name' attribute to the given value.\n * @param {string} value The new value for the 'name' attribute.\n */\n set name(value) {\n this.setAttribute('name', value);\n }\n\n /**\n * Getter for the name attribute.\n * @returns {string} The name of the input.\n */\n get name() {\n return this.getAttribute('name');\n }\n\n /**\n * Getter for the type attribute.\n * @returns {string} The type of the input.\n */\n get type() {\n return this.getAttribute(\"type\");\n }\n\n /**\n * Sets or removes the 'required' attribute on the element.\n * @param {boolean} value If true, adds the 'required' attribute. If false, removes the 'required' attribute.\n */\n set required(value) {\n if (value) {\n this.setAttribute('required', '');\n } else {\n this.removeAttribute('required');\n }\n }\n\n /**\n * Checks if the 'required' attribute is present on the element.\n * @returns {boolean} `true` if the 'required' attribute is set, otherwise `false`.\n */\n get required() {\n return this.hasAttribute('required');\n }\n\n /**\n * Setter for the invalid attribute.\n * @param {boolean} isInvalid Whether the input is invalid.\n */\n set invalid(isInvalid) {\n if (isInvalid) this.setAttribute('invalid', '');\n else this.removeAttribute('invalid');\n }\n\n /**\n * Getter for the invalid attribute.\n * @returns {boolean} Whether the attribute is present.\n */\n get invalid() {\n return this.hasAttribute('invalid');\n }\n\n /**\n * Set checked attribute.\n * @param {boolean} value true if the toggle is checked, false otherwise\n */\n set disabled(value) {\n if (value) {\n this.setAttribute('disabled', '');\n } else {\n this.removeAttribute('disabled');\n }\n }\n\n /**\n * Get disabled attribute value.\n * @returns {boolean} true if the toggle is disabled, false otherwise\n */\n get disabled() {\n return this.hasAttribute('disabled');\n }\n\n /**\n * Retrieves the form element associated with this object.\n * @returns {HTMLFormElement|null} The associated form element, or null if there isn't one.\n */\n get form() {\n return this.internals.form;\n }\n\n /**\n * Retrieves the validity state of the element by returning the validity object from the internal element.\n * The validity object provides information on whether the element satisfies its validation constraints.\n * @returns {ValidityState} The validity state object representing the element's validation constraints.\n */\n get validity() {\n return this.internals.validity;\n }\n\n /**\n * Retrieves the current validation message associated with the element.\n * @returns {string} The validation message that describes why the element's value fails validity checks.\n */\n get validationMessage() {\n return this.internals.validationMessage;\n }\n\n /**\n * Indicates whether the element is a candidate for constraint validation.\n * @returns {boolean} Returns true if the element will be validated during constraint validation, false otherwise.\n */\n get willValidate() {\n return this.internals.willValidate;\n }\n\n /**\n * Validates the input element associated with the component and updates its validity state\n * and error messages based on the user's input and the current validation rules.\n * @returns {void} This method does not return a value. It modifies the validity state\n * internally and sets appropriate validation messages.\n */\n validate() {\n const validState = this.input.validity;\n\n if (!validState.valid) {\n for (let state in validState) {\n const attr = `message-${state.toString()}`;\n\n if (validState[state]) {\n this.validationError = state.toString();\n let errorMessage = this.message;\n\n // TODO this take error messages based on lang from operating system of user should we implement custom translations based on app language ?\n if (!this.hasAttribute('message'))\n errorMessage = this.hasAttribute(attr) ? this.getAttribute(attr) : this.input.validationMessage;\n\n this.internals.setValidity({ [this.validationError]: true }, errorMessage, this.input);\n }\n }\n } else {\n this.internals.setValidity({});\n }\n }\n\n /**\n * Propagates a validation event based on the validity state of the component.\n *\n * This method checks the validity status of the component and emits a custom\n * event if the component is invalid. The event's name and additional details\n * can be specified.\n * @param {string} [eventName] The name of the event to dispatch when the component is invalid.\n * @param {object} [detail] Additional detail to include in the dispatched event.\n * @returns {void} This method does not return a value.\n */\n propagateValidation(eventName = 'invalid', detail = {}) {\n const internals = this.internals;\n\n this.invalid = !this.pristine && !internals.validity.valid;\n\n if (this.invalid) {\n event.dispatchCustomEvent(this, this.tagName.toLocaleLowerCase() + ':' + eventName, detail);\n }\n }\n\n /**\n * Displays an invalid message for the current element.\n * If an error message element does not exist within the designated slot,\n * it creates one and appends it to the slot. Updates the text content\n * of the error message element with the validation message from the\n * element's internals.\n * @returns {void} This method does not return any value.\n */\n showInvalidMessage() {\n const internals = this.internals;\n const slot = this.querySelector(\"[slot='error']\");\n let errorMessageEl = slot?.querySelector('[error-message]');\n\n if (!errorMessageEl) {\n const error = document.createElement('div');\n error.setAttribute('error-message', '');\n slot?.append(error);\n errorMessageEl = error;\n }\n\n errorMessageEl.textContent = internals.validationMessage;\n }\n\n /**\n * Checks the validity of the input by invoking custom validation logic\n * and then verifying against internal validation rules.\n * @returns {boolean} Returns true if the input is valid according to both custom validation and internal validation rules, otherwise false.\n */\n checkValidity() {\n // zavolá tvoju vlastnú validáciu pred kontrolou internals\n this.validate();\n return this.internals.checkValidity();\n }\n\n /**\n * Callback to handle the reset action for a form.\n * Resets the value of the form control to its default value, updates the form value, and clears any validity states.\n * @returns {void} Does not return a value.\n */\n formResetCallback() {\n this.value = this.defaultValue;\n this.internals.setFormValue(this.defaultValue);\n this.internals.setValidity({});\n }\n\n /**\n * Restores the form state by assigning the provided state value\n * and updating the internal form value and validity.\n * @param {object} state The state object containing the value to restore the form.\n * @param {*} state.value The value to set for the form element.\n * @returns {void} This method does not return any value.\n */\n formStateRestoreCallback(state) {\n this.value = state.value;\n this.internals.setFormValue(state.value);\n this.internals.setValidity({});\n }\n\n /**\n * Callback method to save the current state of a form.\n * This method captures and returns the form's value property.\n * @returns {object} An object containing the `value` property of the current form state.\n */\n formStateSaveCallback() {\n return {\n value: this.value\n };\n }\n\n /**\n * Toggles the disabled state of the component and updates corresponding attributes.\n * @param {boolean} disabled Indicates whether the form should be marked as disabled.\n * If true, the 'disabled' class is added, and the 'disabled' attribute is set.\n * If false, both the class and attribute are removed.\n * @returns {void}\n */\n formDisabledCallback(disabled) {\n this.native?.classList.toggle('disabled', disabled);\n this.toggleAttribute('disabled', disabled);\n }\n\n /**\n * A lifecycle callback that is executed when the element is associated with a form.\n * It updates the form's value field with the element's value and sets up an event\n * listener to perform validation and propagate it whenever the form is submitted.\n * @returns {void} Does not return any value.\n */\n formAssociatedCallback() {\n if (this.form) {\n this.internals.setFormValue(this.value);\n this.form?.addEventListener('submit', () => {\n this.validate();\n this.propagateValidation();\n });\n }\n }\n}\n"],"names":[],"mappings":";;;;;AAEO,MAAM,8BAA8B,UAAU;AAAA,EAGnD,cAAc;AACZ,UAAO;AAAA,EACX;AAAA;AAAA;AAAA;AAAA;AAAA,EAME,IAAI,KAAK,OAAO;AACd,SAAK,aAAa,QAAQ,KAAK;AAAA,EACnC;AAAA;AAAA;AAAA;AAAA;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A;AAAA,EAOE,gBAAgB;AAEd,SAAK,SAAU;AACf,WAAO,KAAK,UAAU,cAAe;AAAA,EACzC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOE,oBAAoB;AAClB,SAAK,QAAQ,KAAK;AAClB,SAAK,UAAU,aAAa,KAAK,YAAY;AAC7C,SAAK,UAAU,YAAY,EAAE;AAAA,EACjC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASE,yBAAyB,OAAO;AAC9B,SAAK,QAAQ,MAAM;AACnB,SAAK,UAAU,aAAa,MAAM,KAAK;AACvC,SAAK,UAAU,YAAY,EAAE;AAAA,EACjC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOE,wBAAwB;AACtB,WAAO;AAAA,MACL,OAAO,KAAK;AAAA,IACb;AAAA,EACL;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASE,qBAAqB,UAAU;;AAC7B,eAAK,WAAL,mBAAa,UAAU,OAAO,YAAY;AAC1C,SAAK,gBAAgB,YAAY,QAAQ;AAAA,EAC7C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQE,yBAAyB;;AACvB,QAAI,KAAK,MAAM;AACb,WAAK,UAAU,aAAa,KAAK,KAAK;AACtC,iBAAK,SAAL,mBAAW,iBAAiB,UAAU,MAAM;AAC1C,aAAK,SAAU;AACf,aAAK,oBAAqB;AAAA,MAClC;AAAA,IACA;AAAA,EACA;AACA;AAzQE,cADW,uBACJ,kBAAiB;"}
|
|
@@ -156,13 +156,14 @@ class Icon extends WJElement {
|
|
|
156
156
|
* @returns {Array<string>}
|
|
157
157
|
*/
|
|
158
158
|
static get observedAttributes() {
|
|
159
|
-
return ["name", "filled"];
|
|
159
|
+
return ["name", "filled", "label"];
|
|
160
160
|
}
|
|
161
161
|
/**
|
|
162
162
|
* Sets up the attributes for the component.
|
|
163
163
|
*/
|
|
164
164
|
setupAttributes() {
|
|
165
165
|
this.isShadowRoot = "open";
|
|
166
|
+
this.syncAria();
|
|
166
167
|
}
|
|
167
168
|
/**
|
|
168
169
|
* Draws the component.
|
|
@@ -186,6 +187,7 @@ class Icon extends WJElement {
|
|
|
186
187
|
* Called after the component has been drawn.
|
|
187
188
|
*/
|
|
188
189
|
afterDraw() {
|
|
190
|
+
this.syncAria();
|
|
189
191
|
let lazyImageObserver = new IntersectionObserver((entries, observer) => {
|
|
190
192
|
entries.forEach((entry) => {
|
|
191
193
|
if (entry.isIntersecting) {
|
|
@@ -201,6 +203,38 @@ class Icon extends WJElement {
|
|
|
201
203
|
});
|
|
202
204
|
lazyImageObserver.observe(this.native);
|
|
203
205
|
}
|
|
206
|
+
/**
|
|
207
|
+
* Sync ARIA attributes on host.
|
|
208
|
+
*/
|
|
209
|
+
syncAria() {
|
|
210
|
+
const ariaLabel = this.getAttribute("aria-label");
|
|
211
|
+
const label = this.getAttribute("label");
|
|
212
|
+
if (ariaLabel || label) {
|
|
213
|
+
if (!this.hasAttribute("role")) {
|
|
214
|
+
this.setAttribute("role", "img");
|
|
215
|
+
}
|
|
216
|
+
if (!ariaLabel && label) {
|
|
217
|
+
this.setAriaState({ label });
|
|
218
|
+
}
|
|
219
|
+
this.removeAttribute("aria-hidden");
|
|
220
|
+
} else {
|
|
221
|
+
this.setAttribute("aria-hidden", "true");
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Handles attribute changes for ARIA sync.
|
|
226
|
+
* @param {string} name
|
|
227
|
+
* @param {string|null} oldValue
|
|
228
|
+
* @param {string|null} newValue
|
|
229
|
+
*/
|
|
230
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
231
|
+
if (super.attributeChangedCallback) {
|
|
232
|
+
super.attributeChangedCallback(name, oldValue, newValue);
|
|
233
|
+
}
|
|
234
|
+
if (name === "label" && oldValue !== newValue) {
|
|
235
|
+
this.syncAria();
|
|
236
|
+
}
|
|
237
|
+
}
|
|
204
238
|
}
|
|
205
239
|
Icon.define("wje-icon", Icon);
|
|
206
240
|
export {
|
|
@@ -208,4 +242,4 @@ export {
|
|
|
208
242
|
registerIconLibrary as r,
|
|
209
243
|
unregisterIconLibrary as u
|
|
210
244
|
};
|
|
211
|
-
//# sourceMappingURL=icon-
|
|
245
|
+
//# sourceMappingURL=icon-DVyMc4Wv.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icon-DY5AZ6xM.js","sources":["../packages/utils/icon-library.js","../packages/wje-icon/service/service.js","../packages/wje-icon/icon.element.js","../packages/wje-icon/icon.js"],"sourcesContent":["import { getBasePath } from \"./base-path.js\";\n\nlet registry = [];\n\nregisterIconLibrary(\"default\", {\n resolver: (name, style) => getBasePath(`assets/img/icons/${style}/${name}.svg`)\n});\n\nexport function getIconLibrary(name) {\n return registry.find(lib => lib.name === name);\n}\n\nexport function registerIconLibrary(name, options) {\n unregisterIconLibrary(name);\n registry.push({\n name,\n resolver: options.resolver,\n });\n}\n\nexport function unregisterIconLibrary(name) {\n registry = registry.filter(lib => lib.name !== name);\n}","import { getIconLibrary } from \"../../utils/icon-library.js\";\n\nexport const iconContent = new Map();\nconst requests = new Map();\n\nlet parser;\n\n/**\n * Validates and returns a trimmed source string if it meets the required criteria.\n * @param {string} src The source string to validate and trim.\n * @returns {string|null} The validated and trimmed source string, or `null` if invalid.\n * @example\n * getSrc(' https://example.com/image.jpg '); // Returns 'https://example.com/image.jpg'\n * getSrc('invalid-src'); // Returns null\n */\nexport const getSrc = (src) => {\n if (isStr(src)) {\n src = src.trim();\n if (isSrc(src)) {\n return src;\n }\n }\n return null;\n};\n\n/**\n * Checks if a given string is a valid source based on specific criteria.\n * @param {string} str The string to validate as a source.\n * @returns {boolean} `true` if the string is considered a valid source, `false` otherwise.\n * @example\n * isSrc('https://example.com/image.jpg'); // Returns true\n * isSrc('image.jpg'); // Returns true\n * isSrc('invalid-src'); // Returns false\n */\nexport const isSrc = (str) => str.length > 0 && /(\\/|\\.)/.test(str);\n\n/**\n * Checks if the provided URL is an SVG data URL.\n * @param {string} url The URL to check.\n * @returns {boolean} - Returns `true` if the URL starts with 'data:image/svg+xml', otherwise `false`.\n * @example\n * isSvgDataUrl('data:image/svg+xml;base64,...'); // Returns true\n * isSvgDataUrl('https://example.com/image.svg'); // Returns false\n */\nexport const isSvgDataUrl = (url) => url.startsWith('data:image/svg+xml');\n\n/**\n * Checks if the provided URL is an encoded data URL.\n * @param {string} url The URL to check.\n * @returns {boolean} - Returns `true` if the URL contains ';utf8,', otherwise `false`.\n * @example\n * isEncodedDataUrl('data:text/plain;charset=utf8,...'); // Returns true\n * isEncodedDataUrl('https://example.com/file.txt'); // Returns false\n */\nexport const isEncodedDataUrl = (url) => url.indexOf(';utf8,') !== -1;\n\n/**\n * Checks if the provided value is of string type.\n * @param {*} val The value to check.\n * @returns {boolean} - Returns `true` if the value is a string, otherwise `false`.\n * @example\n * isStr('Hello, World!'); // Returns true\n * isStr(12345); // Returns false\n */\nexport const isStr = (val) => typeof val === 'string';\n\n/**\n * Validates the provided SVG content and ensures it contains a valid SVG element.\n * @param {string} svgContent The SVG content to validate.\n * @returns {string} Returns the validated SVG content as a string if valid, otherwise an empty string.\n * @example\n * const validSvg = '<svg class=\"icon\" xmlns=\"http://www.w3.org/2000/svg\"></svg>';\n * validateContent(validSvg); // Returns '<svg class=\"icon\" xmlns=\"http://www.w3.org/2000/svg\"></svg>'\n * const invalidSvg = '<div></div>';\n * validateContent(invalidSvg); // Returns ''\n */\nexport const validateContent = (svgContent) => {\n const div = document.createElement('div');\n div.innerHTML = svgContent;\n\n const svgElm = div.firstElementChild;\n if (svgElm && svgElm.nodeName.toLowerCase() === 'svg') {\n const svgClass = svgElm.getAttribute('class') || '';\n\n if (isValid(svgElm)) {\n return div.innerHTML;\n }\n }\n return '';\n};\n\n/**\n * Validates an element to ensure it does not contain potentially unsafe content.\n * @param {Element|Node} elm The element or node to validate.\n * @returns {boolean} - Returns `true` if the element is valid, otherwise `false`.\n * @description\n * This function checks the following:\n * 1. The element is an element node (nodeType 1).\n * 2. The element is not a `<script>` tag.\n * 3. The element does not contain any `on*` event handler attributes (e.g., `onclick`).\n * 4. All child nodes recursively pass the same validation.\n * @example\n * const validElement = document.createElement('div');\n * isValid(validElement); // Returns true\n *\n * const scriptElement = document.createElement('script');\n * isValid(scriptElement); // Returns false\n *\n * const divWithOnClick = document.createElement('div');\n * divWithOnClick.setAttribute('onclick', 'alert(\"hi\")');\n * isValid(divWithOnClick); // Returns false\n */\nexport const isValid = (elm) => {\n // Only element nodes\n if (elm.nodeType === 1) {\n // Check for script elements\n if (elm.nodeName.toLowerCase() === 'script') {\n return false;\n }\n\n // Check for on* attributes\n for (let i = 0; i < elm.attributes.length; i++) {\n const name = elm.attributes[i].name;\n if (isStr(name) && name.toLowerCase().indexOf('on') === 0) {\n return false;\n }\n }\n\n // Check for child nodes\n for (let i = 0; i < elm.childNodes.length; i++) {\n if (!isValid(elm.childNodes[i])) {\n return false;\n }\n }\n }\n return true;\n};\n\n/**\n * Fetches and optionally sanitizes SVG content from a given URL.\n * @param {string} url The URL of the SVG resource or data URL.\n * @param {boolean} [sanitize] Whether to sanitize the SVG content. Defaults to `true`.\n * @returns {Promise<void>} A promise that resolves when the SVG content is fetched and stored.\n * @description\n * This function performs the following:\n * - If the URL is an SVG data URL and encoded, it parses the content to extract the SVG.\n * - If the URL is a standard HTTP/HTTPS URL, it fetches the content.\n * - Optionally sanitizes the fetched SVG content.\n * - Caches the content for future use.\n * @example\n * getSvgContent('https://example.com/icon.svg').then(() => {\n * console.log('SVG content fetched and stored.');\n * });\n * @example\n * getSvgContent('data:image/svg+xml;base64,...', false).then(() => {\n * console.log('SVG data URL processed without sanitization.');\n * });\n */\nexport const getSvgContent = (url, sanitize) => {\n let req = requests.get(url);\n if (!req) {\n if (typeof fetch !== 'undefined' && typeof document !== 'undefined') {\n if (isSvgDataUrl(url) && isEncodedDataUrl(url)) {\n if (!parser) {\n parser = new DOMParser();\n }\n const doc = parser.parseFromString(url, 'text/html');\n const svg = doc.querySelector('svg');\n if (svg) {\n iconContent.set(url, svg.outerHTML);\n }\n return Promise.resolve();\n } else {\n req = fetch(url).then((rsp) => {\n if (rsp.ok) {\n return rsp.text().then((svgContent) => {\n if (svgContent && sanitize !== false) {\n svgContent = validateContent(svgContent);\n }\n iconContent.set(url, svgContent || '');\n });\n }\n return iconContent.set(url, '');\n });\n requests.set(url, req);\n }\n } else {\n iconContent.set(url, '');\n return Promise.resolve();\n }\n }\n return req;\n};\n\n/**\n * Retrieves the URL for an icon based on its `src` or `name` attributes.\n * @param {HTMLElement} i The icon element from which to extract the URL.\n * @returns {string|null} The URL of the icon if found, or `null` if no valid URL can be determined.\n * @description\n * This function performs the following:\n * 1. Attempts to retrieve the URL from the `src` attribute using `getSrc`.\n * 2. If no `src` is provided, it falls back to the `name` attribute using `getName`.\n * 3. If a name is found, it uses `getNamedUrl` to construct the URL, considering the `filled` attribute.\n * @example\n * const iconElement = document.querySelector('wje-icon');\n * const url = getUrl(iconElement);\n * console.log(url); // Outputs the resolved URL or `null`.\n */\nexport const getUrl = (i) => {\n let url = getSrc(i.src);\n if (url) {\n return url;\n }\n\n url = getName(i.name);\n\n if (url) {\n return getNamedUrl(url, i.library, i.hasAttribute('filled'));\n }\n\n return null;\n};\n\n/**\n * Validates and returns a sanitized icon name.\n * @param {string} iconName The icon name to validate.\n * @returns {string|null} The sanitized icon name, or `null` if the input is invalid.\n * @description\n * This function checks if the provided `iconName` is a valid string:\n * - It must not be empty or contain invalid characters.\n * - Only alphanumeric characters, hyphens, and digits are allowed.\n * @example\n * const validName = getName('user-icon');\n * console.log(validName); // 'user-icon'\n * const invalidName = getName('user@icon!');\n * console.log(invalidName); // null\n */\nexport const getName = (iconName) => {\n if (!isStr(iconName) || iconName.trim() === '') {\n return null;\n }\n\n const invalidChars = iconName.replace(/[a-z]|-|\\d/gi, '');\n if (invalidChars !== '') {\n return null;\n }\n\n return iconName;\n};\n\n/**\n * Constructs the URL for a named SVG icon.\n * @param {string} iconName The name of the icon to retrieve.\n * @param {string} [libraryName] The name of the icon library to use. Defaults to \"default\".\n * @param {boolean} [filled] Whether to use the \"filled\" variant of the icon. Defaults to \"outline\" if `false`.\n * @returns {string} - The complete URL to the SVG icon.\n * @description\n * This function generates a URL for an icon based on its name and style (filled or outline).\n * It uses the base URL from the environment variable `VITE_ICON_ASSETS_URL`.\n * @example\n * const url = getNamedUrl('user-icon', 'default', true);\n * console.log(url); // 'https://example.com/filled/user-icon.svg'\n *\n * const outlineUrl = getNamedUrl('settings', 'default');\n * console.log(outlineUrl); // 'https://example.com/outline/settings.svg'\n */\nconst getNamedUrl = (iconName, libraryName = 'default', filled = false) => {\n let library = getIconLibrary(libraryName);\n let url = library.resolver(iconName, filled ? 'filled' : 'outline');\n\n return url;\n}\n","import { default as WJElement } from '../wje-element/element.js';\nimport { getSvgContent, getUrl, iconContent } from './service/service.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * @summary This element represents an icon. `IconElement` is a custom web component that represents an icon.\n * @documentation https://elements.webjet.sk/components/icon\n * @status stable\n * @augments WJElement\n * @csspart svg - The SVG part of the icon\n * @cssproperty [--wje-icon-size=1rem] - The size of the icon element\n * @cssproperty [--wje-icon-width=var(--wje-icon-size, 100%)] - The width of the icon element\n * @cssproperty [--wje-icon-height=var(--wje-icon-size, 100%)] - The height of the icon element\n * @tag wje-icon\n */\nexport default class Icon extends WJElement {\n /**\n * Creates an instance of IconElement.\n * @class\n */\n constructor() {\n super();\n }\n\n /**\n * Sets the name of the icon.\n * @type {string}\n */\n className = 'Icon';\n\n /**\n * Returns the CSS styles for the component.\n * @static\n * @returns {CSSStyleSheet}\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Returns the list of attributes to observe for changes.\n * @static\n * @returns {Array<string>}\n */\n static get observedAttributes() {\n return ['name', 'filled'];\n }\n\n /**\n * Sets up the attributes for the component.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n }\n\n /**\n * Draws the component.\n * @param {object} context The context for drawing.\n * @param {object} store The store for drawing.\n * @param {object} params The parameters for drawing.\n * @returns {DocumentFragment}\n */\n draw(context, store, params) {\n let fragment = document.createDocumentFragment();\n\n this.classList.add('lazy-loaded-image', 'lazy');\n\n let native = document.createElement('div');\n native.setAttribute('part', 'native');\n native.classList.add('native-icon');\n\n this.url = getUrl(this);\n\n fragment.appendChild(native);\n\n this.native = native;\n\n return fragment;\n }\n\n /**\n * Called after the component has been drawn.\n */\n afterDraw() {\n let lazyImageObserver = new IntersectionObserver((entries, observer) => {\n entries.forEach((entry) => {\n if (entry.isIntersecting) {\n getSvgContent(this.url).then((svgContent) => {\n this.native.innerHTML = iconContent?.get(this.url);\n this.native.querySelector('svg')?.setAttribute('part', 'svg');\n });\n\n this.classList.remove('lazy');\n lazyImageObserver.unobserve(entry.target);\n }\n });\n });\n\n lazyImageObserver.observe(this.native);\n }\n}\n","import Icon from './icon.element.js';\n\nexport default Icon;\n\nIcon.define('wje-icon', Icon);\n"],"names":[],"mappings":";;;;;AAEA,IAAI,WAAW,CAAE;AAEjB,oBAAoB,WAAW;AAAA,EAC7B,UAAU,CAAC,MAAM,UAAU,YAAY,oBAAoB,KAAK,IAAI,IAAI,MAAM;AAChF,CAAC;AAEM,SAAS,eAAe,MAAM;AACnC,SAAO,SAAS,KAAK,SAAO,IAAI,SAAS,IAAI;AAC/C;AAEO,SAAS,oBAAoB,MAAM,SAAS;AACjD,wBAAsB,IAAI;AAC1B,WAAS,KAAK;AAAA,IACZ;AAAA,IACA,UAAU,QAAQ;AAAA,EACtB,CAAG;AACH;AAEO,SAAS,sBAAsB,MAAM;AAC1C,aAAW,SAAS,OAAO,SAAO,IAAI,SAAS,IAAI;AACrD;ACpBO,MAAM,cAAc,oBAAI,IAAK;AACpC,MAAM,WAAW,oBAAI,IAAK;AAE1B,IAAI;AAUG,MAAM,SAAS,CAAC,QAAQ;AAC3B,MAAI,MAAM,GAAG,GAAG;AACZ,UAAM,IAAI,KAAM;AAChB,QAAI,MA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CAAqB;AAED,eAAK,UAAU,OAAO,MAAM;AAC5B,4BAAkB,UAAU,MAAM,MAAM;AAAA,QAC5D;AAAA,MACA,CAAa;AAAA,IACb,CAAS;AAED,sBAAkB,QAAQ,KAAK,MAAM;AAAA,EAC7C;AACA;AChGA,KAAK,OAAO,YAAY,IAAI;"}
|
|
1
|
+
{"version":3,"file":"icon-DVyMc4Wv.js","sources":["../packages/utils/icon-library.js","../packages/wje-icon/service/service.js","../packages/wje-icon/icon.element.js","../packages/wje-icon/icon.js"],"sourcesContent":["import { getBasePath } from \"./base-path.js\";\n\nlet registry = [];\n\nregisterIconLibrary(\"default\", {\n resolver: (name, style) => getBasePath(`assets/img/icons/${style}/${name}.svg`)\n});\n\nexport function getIconLibrary(name) {\n return registry.find(lib => lib.name === name);\n}\n\nexport function registerIconLibrary(name, options) {\n unregisterIconLibrary(name);\n registry.push({\n name,\n resolver: options.resolver,\n });\n}\n\nexport function unregisterIconLibrary(name) {\n registry = registry.filter(lib => lib.name !== name);\n}","import { getIconLibrary } from \"../../utils/icon-library.js\";\n\nexport const iconContent = new Map();\nconst requests = new Map();\n\nlet parser;\n\n/**\n * Validates and returns a trimmed source string if it meets the required criteria.\n * @param {string} src The source string to validate and trim.\n * @returns {string|null} The validated and trimmed source string, or `null` if invalid.\n * @example\n * getSrc(' https://example.com/image.jpg '); // Returns 'https://example.com/image.jpg'\n * getSrc('invalid-src'); // Returns null\n */\nexport const getSrc = (src) => {\n if (isStr(src)) {\n src = src.trim();\n if (isSrc(src)) {\n return src;\n }\n }\n return null;\n};\n\n/**\n * Checks if a given string is a valid source based on specific criteria.\n * @param {string} str The string to validate as a source.\n * @returns {boolean} `true` if the string is considered a valid source, `false` otherwise.\n * @example\n * isSrc('https://example.com/image.jpg'); // Returns true\n * isSrc('image.jpg'); // Returns true\n * isSrc('invalid-src'); // Returns false\n */\nexport const isSrc = (str) => str.length > 0 && /(\\/|\\.)/.test(str);\n\n/**\n * Checks if the provided URL is an SVG data URL.\n * @param {string} url The URL to check.\n * @returns {boolean} - Returns `true` if the URL starts with 'data:image/svg+xml', otherwise `false`.\n * @example\n * isSvgDataUrl('data:image/svg+xml;base64,...'); // Returns true\n * isSvgDataUrl('https://example.com/image.svg'); // Returns false\n */\nexport const isSvgDataUrl = (url) => url.startsWith('data:image/svg+xml');\n\n/**\n * Checks if the provided URL is an encoded data URL.\n * @param {string} url The URL to check.\n * @returns {boolean} - Returns `true` if the URL contains ';utf8,', otherwise `false`.\n * @example\n * isEncodedDataUrl('data:text/plain;charset=utf8,...'); // Returns true\n * isEncodedDataUrl('https://example.com/file.txt'); // Returns false\n */\nexport const isEncodedDataUrl = (url) => url.indexOf(';utf8,') !== -1;\n\n/**\n * Checks if the provided value is of string type.\n * @param {*} val The value to check.\n * @returns {boolean} - Returns `true` if the value is a string, otherwise `false`.\n * @example\n * isStr('Hello, World!'); // Returns true\n * isStr(12345); // Returns false\n */\nexport const isStr = (val) => typeof val === 'string';\n\n/**\n * Validates the provided SVG content and ensures it contains a valid SVG element.\n * @param {string} svgContent The SVG content to validate.\n * @returns {string} Returns the validated SVG content as a string if valid, otherwise an empty string.\n * @example\n * const validSvg = '<svg class=\"icon\" xmlns=\"http://www.w3.org/2000/svg\"></svg>';\n * validateContent(validSvg); // Returns '<svg class=\"icon\" xmlns=\"http://www.w3.org/2000/svg\"></svg>'\n * const invalidSvg = '<div></div>';\n * validateContent(invalidSvg); // Returns ''\n */\nexport const validateContent = (svgContent) => {\n const div = document.createElement('div');\n div.innerHTML = svgContent;\n\n const svgElm = div.firstElementChild;\n if (svgElm && svgElm.nodeName.toLowerCase() === 'svg') {\n const svgClass = svgElm.getAttribute('class') || '';\n\n if (isValid(svgElm)) {\n return div.innerHTML;\n }\n }\n return '';\n};\n\n/**\n * Validates an element to ensure it does not contain potentially unsafe content.\n * @param {Element|Node} elm The element or node to validate.\n * @returns {boolean} - Returns `true` if the element is valid, otherwise `false`.\n * @description\n * This function checks the following:\n * 1. The element is an element node (nodeType 1).\n * 2. The element is not a `<script>` tag.\n * 3. The element does not contain any `on*` event handler attributes (e.g., `onclick`).\n * 4. All child nodes recursively pass the same validation.\n * @example\n * const validElement = document.createElement('div');\n * isValid(validElement); // Returns true\n *\n * const scriptElement = document.createElement('script');\n * isValid(scriptElement); // Returns false\n *\n * const divWithOnClick = document.createElement('div');\n * divWithOnClick.setAttribute('onclick', 'alert(\"hi\")');\n * isValid(divWithOnClick); // Returns false\n */\nexport const isValid = (elm) => {\n // Only element nodes\n if (elm.nodeType === 1) {\n // Check for script elements\n if (elm.nodeName.toLowerCase() === 'script') {\n return false;\n }\n\n // Check for on* attributes\n for (let i = 0; i < elm.attributes.length; i++) {\n const name = elm.attributes[i].name;\n if (isStr(name) && name.toLowerCase().indexOf('on') === 0) {\n return false;\n }\n }\n\n // Check for child nodes\n for (let i = 0; i < elm.childNodes.length; i++) {\n if (!isValid(elm.childNodes[i])) {\n return false;\n }\n }\n }\n return true;\n};\n\n/**\n * Fetches and optionally sanitizes SVG content from a given URL.\n * @param {string} url The URL of the SVG resource or data URL.\n * @param {boolean} [sanitize] Whether to sanitize the SVG content. Defaults to `true`.\n * @returns {Promise<void>} A promise that resolves when the SVG content is fetched and stored.\n * @description\n * This function performs the following:\n * - If the URL is an SVG data URL and encoded, it parses the content to extract the SVG.\n * - If the URL is a standard HTTP/HTTPS URL, it fetches the content.\n * - Optionally sanitizes the fetched SVG content.\n * - Caches the content for future use.\n * @example\n * getSvgContent('https://example.com/icon.svg').then(() => {\n * console.log('SVG content fetched and stored.');\n * });\n * @example\n * getSvgContent('data:image/svg+xml;base64,...', false).then(() => {\n * console.log('SVG data URL processed without sanitization.');\n * });\n */\nexport const getSvgContent = (url, sanitize) => {\n let req = requests.get(url);\n if (!req) {\n if (typeof fetch !== 'undefined' && typeof document !== 'undefined') {\n if (isSvgDataUrl(url) && isEncodedDataUrl(url)) {\n if (!parser) {\n parser = new DOMParser();\n }\n const doc = parser.parseFromString(url, 'text/html');\n const svg = doc.querySelector('svg');\n if (svg) {\n iconContent.set(url, svg.outerHTML);\n }\n return Promise.resolve();\n } else {\n req = fetch(url).then((rsp) => {\n if (rsp.ok) {\n return rsp.text().then((svgContent) => {\n if (svgContent && sanitize !== false) {\n svgContent = validateContent(svgContent);\n }\n iconContent.set(url, svgContent || '');\n });\n }\n return iconContent.set(url, '');\n });\n requests.set(url, req);\n }\n } else {\n iconContent.set(url, '');\n return Promise.resolve();\n }\n }\n return req;\n};\n\n/**\n * Retrieves the URL for an icon based on its `src` or `name` attributes.\n * @param {HTMLElement} i The icon element from which to extract the URL.\n * @returns {string|null} The URL of the icon if found, or `null` if no valid URL can be determined.\n * @description\n * This function performs the following:\n * 1. Attempts to retrieve the URL from the `src` attribute using `getSrc`.\n * 2. If no `src` is provided, it falls back to the `name` attribute using `getName`.\n * 3. If a name is found, it uses `getNamedUrl` to construct the URL, considering the `filled` attribute.\n * @example\n * const iconElement = document.querySelector('wje-icon');\n * const url = getUrl(iconElement);\n * console.log(url); // Outputs the resolved URL or `null`.\n */\nexport const getUrl = (i) => {\n let url = getSrc(i.src);\n if (url) {\n return url;\n }\n\n url = getName(i.name);\n\n if (url) {\n return getNamedUrl(url, i.library, i.hasAttribute('filled'));\n }\n\n return null;\n};\n\n/**\n * Validates and returns a sanitized icon name.\n * @param {string} iconName The icon name to validate.\n * @returns {string|null} The sanitized icon name, or `null` if the input is invalid.\n * @description\n * This function checks if the provided `iconName` is a valid string:\n * - It must not be empty or contain invalid characters.\n * - Only alphanumeric characters, hyphens, and digits are allowed.\n * @example\n * const validName = getName('user-icon');\n * console.log(validName); // 'user-icon'\n * const invalidName = getName('user@icon!');\n * console.log(invalidName); // null\n */\nexport const getName = (iconName) => {\n if (!isStr(iconName) || iconName.trim() === '') {\n return null;\n }\n\n const invalidChars = iconName.replace(/[a-z]|-|\\d/gi, '');\n if (invalidChars !== '') {\n return null;\n }\n\n return iconName;\n};\n\n/**\n * Constructs the URL for a named SVG icon.\n * @param {string} iconName The name of the icon to retrieve.\n * @param {string} [libraryName] The name of the icon library to use. Defaults to \"default\".\n * @param {boolean} [filled] Whether to use the \"filled\" variant of the icon. Defaults to \"outline\" if `false`.\n * @returns {string} - The complete URL to the SVG icon.\n * @description\n * This function generates a URL for an icon based on its name and style (filled or outline).\n * It uses the base URL from the environment variable `VITE_ICON_ASSETS_URL`.\n * @example\n * const url = getNamedUrl('user-icon', 'default', true);\n * console.log(url); // 'https://example.com/filled/user-icon.svg'\n *\n * const outlineUrl = getNamedUrl('settings', 'default');\n * console.log(outlineUrl); // 'https://example.com/outline/settings.svg'\n */\nconst getNamedUrl = (iconName, libraryName = 'default', filled = false) => {\n let library = getIconLibrary(libraryName);\n let url = library.resolver(iconName, filled ? 'filled' : 'outline');\n\n return url;\n}\n","import { default as WJElement } from '../wje-element/element.js';\nimport { getSvgContent, getUrl, iconContent } from './service/service.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * @summary This element represents an icon. `IconElement` is a custom web component that represents an icon.\n * @documentation https://elements.webjet.sk/components/icon\n * @status stable\n * @augments WJElement\n * @csspart svg - The SVG part of the icon\n * @cssproperty [--wje-icon-size=1rem] - The size of the icon element\n * @cssproperty [--wje-icon-width=var(--wje-icon-size, 100%)] - The width of the icon element\n * @cssproperty [--wje-icon-height=var(--wje-icon-size, 100%)] - The height of the icon element\n * @tag wje-icon\n */\nexport default class Icon extends WJElement {\n /**\n * Creates an instance of IconElement.\n * @class\n */\n constructor() {\n super();\n }\n\n /**\n * Sets the name of the icon.\n * @type {string}\n */\n className = 'Icon';\n\n /**\n * Returns the CSS styles for the component.\n * @static\n * @returns {CSSStyleSheet}\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Returns the list of attributes to observe for changes.\n * @static\n * @returns {Array<string>}\n */\n static get observedAttributes() {\n return ['name', 'filled', 'label'];\n }\n\n /**\n * Sets up the attributes for the component.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n this.syncAria();\n }\n\n /**\n * Draws the component.\n * @param {object} context The context for drawing.\n * @param {object} store The store for drawing.\n * @param {object} params The parameters for drawing.\n * @returns {DocumentFragment}\n */\n draw(context, store, params) {\n let fragment = document.createDocumentFragment();\n\n this.classList.add('lazy-loaded-image', 'lazy');\n\n let native = document.createElement('div');\n native.setAttribute('part', 'native');\n native.classList.add('native-icon');\n\n this.url = getUrl(this);\n\n fragment.appendChild(native);\n\n this.native = native;\n\n return fragment;\n }\n\n /**\n * Called after the component has been drawn.\n */\n afterDraw() {\n this.syncAria();\n let lazyImageObserver = new IntersectionObserver((entries, observer) => {\n entries.forEach((entry) => {\n if (entry.isIntersecting) {\n getSvgContent(this.url).then((svgContent) => {\n this.native.innerHTML = iconContent?.get(this.url);\n this.native.querySelector('svg')?.setAttribute('part', 'svg');\n });\n\n this.classList.remove('lazy');\n lazyImageObserver.unobserve(entry.target);\n }\n });\n });\n\n lazyImageObserver.observe(this.native);\n }\n\n /**\n * Sync ARIA attributes on host.\n */\n syncAria() {\n const ariaLabel = this.getAttribute('aria-label');\n const label = this.getAttribute('label');\n\n if (ariaLabel || label) {\n if (!this.hasAttribute('role')) {\n this.setAttribute('role', 'img');\n }\n if (!ariaLabel && label) {\n this.setAriaState({ label });\n }\n this.removeAttribute('aria-hidden');\n } else {\n this.setAttribute('aria-hidden', 'true');\n }\n }\n\n /**\n * Handles attribute changes for ARIA sync.\n * @param {string} name\n * @param {string|null} oldValue\n * @param {string|null} newValue\n */\n attributeChangedCallback(name, oldValue, newValue) {\n if (super.attributeChangedCallback) {\n super.attributeChangedCallback(name, oldValue, newValue);\n }\n\n if (name === 'label' && oldValue !== newValue) {\n this.syncAria();\n }\n }\n}\n","import Icon from './icon.element.js';\n\nexport default Icon;\n\nIcon.define('wje-icon', Icon);\n"],"names":[],"mappings":";;;;;AAEA,IAAI,WAAW,CAAE;AAEjB,oBAAoB,WAAW;AAAA,EAC7B,UAAU,CAAC,MAAM,UAAU,YAAY,oBAAoB,KAAK,IAAI,IAAI,MAAM;AAChF,CAAC;AAEM,SAAS,eAAe,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U;AAC3C,WAAK,SAAU;AAAA,IAC3B;AAAA,EACA;AACA;ACtIA,KAAK,OAAO,YAAY,IAAI;"}
|
package/dist/light.css
CHANGED
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
:root,
|
|
6
6
|
:host,
|
|
7
7
|
.wje-theme-light,
|
|
8
|
-
.light
|
|
8
|
+
.light,
|
|
9
|
+
[data-theme=light] {
|
|
9
10
|
* {
|
|
10
11
|
box-sizing: border-box !important;
|
|
11
12
|
}
|
|
@@ -226,7 +227,7 @@
|
|
|
226
227
|
[ Skeleton ]
|
|
227
228
|
*/
|
|
228
229
|
--wje-skeleton-bg: var(--wje-color-contrast-3);
|
|
229
|
-
--wje-skeleton-bg-strong: var(--wje-color-contrast-
|
|
230
|
+
--wje-skeleton-bg-strong: var(--wje-color-contrast-5);
|
|
230
231
|
--wje-skeleton-highlight: rgba(255, 255, 255, 0.45);
|
|
231
232
|
--wje-skeleton-radius: var(--wje-border-radius-pill);
|
|
232
233
|
--wje-skeleton-height: var(--wje-size-small);
|
|
@@ -358,6 +359,7 @@
|
|
|
358
359
|
--wje-chip-padding-inline: var(--wje-spacing-small);
|
|
359
360
|
|
|
360
361
|
/* Dialog */
|
|
362
|
+
--wje-dialog-background: var(--wje-color-contrast-1);
|
|
361
363
|
--wje-dialog-width: 600px;
|
|
362
364
|
--wje-dialog-height: 600px;
|
|
363
365
|
--wje-dialog-border-radius: var(--wje-border-radius-medium);
|
|
@@ -562,6 +564,9 @@
|
|
|
562
564
|
--wje-orgchart-group-height-line: 10px;
|
|
563
565
|
--wje-orgchart-group-padding: 0.25rem 0;
|
|
564
566
|
|
|
567
|
+
/* Popup */
|
|
568
|
+
--wje-popup-overlay-background: var(--wje-color-contrast-0);
|
|
569
|
+
|
|
565
570
|
/* Radio */
|
|
566
571
|
--wje-radio-margin-top: 0;
|
|
567
572
|
--wje-radio-margin-bottom: 0.5rem;
|
package/dist/localize.js
CHANGED
|
@@ -4,9 +4,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
4
4
|
class LocalizerDefault {
|
|
5
5
|
constructor(element) {
|
|
6
6
|
__publicField(this, "convertLangCode", (lang) => lang.replace("-", "_").replace(/_([a-z]{2})$/, (_, code) => `_${code.toUpperCase()}`));
|
|
7
|
+
var _a, _b, _c, _d;
|
|
7
8
|
this.element = element;
|
|
8
|
-
this.lang = this.element.lang || document.documentElement.lang || "en-GB";
|
|
9
|
-
this.dir = this.element.dir || document.documentElement.dir || "ltr";
|
|
9
|
+
this.lang = ((_a = this.element) == null ? void 0 : _a.lang) || ((_b = document.documentElement) == null ? void 0 : _b.lang) || "en-GB";
|
|
10
|
+
this.dir = ((_c = this.element) == null ? void 0 : _c.dir) || ((_d = document.documentElement) == null ? void 0 : _d.dir) || "ltr";
|
|
10
11
|
this.currentLang = "en-GB";
|
|
11
12
|
this.setLanguage();
|
|
12
13
|
}
|
|
@@ -41,9 +42,11 @@ class LocalizerDefault {
|
|
|
41
42
|
* @returns {string} The translated string, adapted to the pluralization rules and count.
|
|
42
43
|
*/
|
|
43
44
|
translatePlural(key, count = 0, type = "cardinal") {
|
|
44
|
-
const plural = new Intl.PluralRules(this.
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
const plural = new Intl.PluralRules(this.currentLang, { type });
|
|
46
|
+
const k = `${key}.${plural.select(count)}`;
|
|
47
|
+
const t = this.translate(k);
|
|
48
|
+
if (t !== k) return t;
|
|
49
|
+
return this.translate(`${key}.other`);
|
|
47
50
|
}
|
|
48
51
|
/**
|
|
49
52
|
* Formats a number according to the specified locale and formatting options.
|
package/dist/localize.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localize.js","sources":["../packages/localize/localize.js","../packages/utils/localize.js"],"sourcesContent":["// export const translations = new Map();\n\nexport class LocalizerDefault {\n constructor(element) {\n this.element = element;\n\n this.lang = this.element
|
|
1
|
+
{"version":3,"file":"localize.js","sources":["../packages/localize/localize.js","../packages/utils/localize.js"],"sourcesContent":["// export const translations = new Map();\n\nexport class LocalizerDefault {\n constructor(element) {\n this.element = element;\n\n this.lang = this.element?.lang || document.documentElement?.lang || 'en-GB';\n this.dir = this.element?.dir || document.documentElement?.dir || 'ltr';\n this.currentLang = 'en-GB';\n\n this.setLanguage();\n }\n\n get languages() {\n return window.translations;\n }\n\n // Nastavenie aktuálneho jazyka\n setLanguage() {\n if (this.languages?.has(this.lang)) {\n this.currentLang = this.lang;\n } else {\n console.error(`Language \"${this.lang}\" not loaded.`);\n }\n }\n\n convertLangCode = (lang) => lang.replace(\"-\", \"_\").replace(/_([a-z]{2})$/, (_, code) => `_${code.toUpperCase()}`);\n\n /**\n * Translates a given translation key based on the currently selected language.\n * @param {string} key The key representing the text to be translated.\n * @returns {string} The translated text if available; otherwise, returns the original key.\n */\n translate(key) {\n const langMap = this.languages?.get(this.currentLang);\n if (!langMap) return key;\n return langMap ? langMap[key] || key : key;\n }\n\n /**\n * Translates a key into a localized string based on the provided count and pluralization type.\n * @param {string} key The base translation key to be used for fetching the localized string.\n * @param {number} [count=0] The count value used to determine the pluralization form.\n * @param {string} [type='cardinal'] The type of pluralization to use, such as 'cardinal' or 'ordinal'.\n * @returns {string} The translated string, adapted to the pluralization rules and count.\n */\n translatePlural(key, count = 0, type = 'cardinal') {\n const plural = new Intl.PluralRules(this.currentLang, { type });\n const k = `${key}.${plural.select(count)}`;\n const t = this.translate(k);\n if (t !== k) return t;\n return this.translate(`${key}.other`);\n }\n\n /**\n * Formats a number according to the specified locale and formatting options.\n * @param {number} number The numeric value to format.\n * @param {object} options An object containing formatting options for the number.\n * @returns {string} The formatted number as a string.\n */\n formatNumber(number, options) {\n return new Intl.NumberFormat(this.currentLang, options).format(number);\n }\n\n /**\n * Formats a given date based on the specified options and the current language setting.\n * @param {string|Date|number} date The date to format. Can be a Date object, a timestamp, or a date string.\n * @param {object} options The formatting options to customize the output, as supported by Intl.DateTimeFormat.\n * @returns {string} The formatted date string based on the specified options and current language.\n */\n formatDate(date, options) {\n return new Intl.DateTimeFormat(this.currentLang, options).format(new Date(date));\n }\n\n /**\n * Formats a relative time string based on a given language, value, unit, and formatting options.\n * @param {string} lang The language to use for formatting. Defaults to `this.currentLang` if not provided.\n * @param {number} value The numerical value to format, representing the time difference.\n * @param {string} [unit] The unit of time to use (e.g., \"second\", \"minute\", \"hour\", \"day\", \"week\", \"month\", \"year\").\n * @param {object} [options] An object containing formatting options, such as the style for the numeric representation.\n * @returns {string} The formatted relative time string in the specified language.\n */\n relativeTime(lang, value = 0, unit = 'day', options = { numeric: 'auto' }) {\n lang = lang || this.currentLang;\n return new Intl.RelativeTimeFormat(lang, options).format(value, unit);\n }\n}\n\nexport function registerTranslation(...translation) {\n translation.forEach((t) => {\n if (!t.code) {\n console.error(\"Translation object is missing 'code' property:\", t);\n return;\n }\n\n const code = t.code.toLowerCase();\n if (window.translations.has(code)) {\n window.translations.set(code, { ...window.translations.get(code), ...t });\n } else {\n window.translations.set(code, t);\n }\n });\n}\n","import { LocalizerDefault, registerTranslation } from '../localize/localize.js';\n\nexport class Localizer extends LocalizerDefault {\n constructor(element) {\n super(element);\n }\n static registerTranslation(...translation) {\n registerTranslation(...translation);\n }\n}\n"],"names":[],"mappings":";;;AAEO,MAAM,iBAAiB;AAAA,EAC1B,YAAY,SAAS;AAuBrB,2CAAkB,CAAC,SAAS,KAAK,QAAQ,KAAK,GAAG,EAAE,QAAQ,gBAAgB,CAAC,GAAG,SAAS,IAAI,KAAK,YAAa,CAAA,EAAE;AA1BpH;AAIQ,SAAK,UAAU;AAEf,SAAK,SAAO,UAAK,YAAL,mBAAc,WAAQ,cAAS,oBAAT,mBAA0B,SAAQ;AACpE,SAAK,QAAM,UAAK,YAAL,mBAAc,UAAO,cAAS,oBAAT,mBAA0B,QAAO;AACjE,SAAK,cAAc;AAEnB,SAAK,YAAa;AAAA,EAC1B;AAAA,EAEI,IAAI,YAAY;AACZ,WAAO,OAAO;AAAA,EACtB;AAAA;AAAA,EAGI,cAAc;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AI;AAAA,EAC5E;AACA;AAEO,SAAS,uBAAuB,aAAa;AAChD,cAAY,QAAQ,CAAC,MAAM;AACvB,QAAI,CAAC,EAAE,MAAM;AACT,cAAQ,MAAM,kDAAkD,CAAC;AACjE;AAAA,IACZ;AAEQ,UAAM,OAAO,EAAE,KAAK,YAAa;AACjC,QAAI,OAAO,aAAa,IAAI,IAAI,GAAG;AAC/B,aAAO,aAAa,IAAI,MAAM,EAAE,GAAG,OAAO,aAAa,IAAI,IAAI,GAAG,GAAG,EAAC,CAAE;AAAA,IACpF,OAAe;AACH,aAAO,aAAa,IAAI,MAAM,CAAC;AAAA,IAC3C;AAAA,EACA,CAAK;AACL;ACpGO,MAAM,kBAAkB,iBAAiB;AAAA,EAC5C,YAAY,SAAS;AACjB,UAAM,OAAO;AAAA,EACrB;AAAA,EACI,OAAO,uBAAuB,aAAa;AACvC,wBAAoB,GAAG,WAAW;AAAA,EAC1C;AACA;"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { default as WJElement } from '../wje-element/element.js';
|
|
2
2
|
export class FormAssociatedElement extends WJElement {
|
|
3
3
|
static formAssociated: boolean;
|
|
4
|
-
internals: ElementInternals;
|
|
5
4
|
/**
|
|
6
5
|
* Sets the 'name' attribute to the given value.
|
|
7
6
|
* @param {string} value The new value for the 'name' attribute.
|
|
@@ -1 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if a given file matches any of the accepted file types.
|
|
3
|
+
* @param {File} file The file to validate.
|
|
4
|
+
* @param {string|string[]} acceptedFileTypes A comma-separated string or an array of accepted MIME types or file extensions.
|
|
5
|
+
* @returns {boolean} Returns `true` if the file type is valid, otherwise `false`.
|
|
6
|
+
* @throws {Error} Throws an error if `acceptedFileTypes` is empty.
|
|
7
|
+
* @example
|
|
8
|
+
* const file = new File([""], "example.png", { type: "image/png" });
|
|
9
|
+
* const isValid = isValidFileType(file, "image/*,application/pdf");
|
|
10
|
+
* console.log(isValid); // true
|
|
11
|
+
* @example
|
|
12
|
+
* const file = new File([""], "example.txt", { type: "text/plain" });
|
|
13
|
+
* const isValid = isValidFileType(file, ["text/plain", "application/json"]);
|
|
14
|
+
* console.log(isValid); // true
|
|
15
|
+
*/
|
|
16
|
+
export function isValidFileType(file: File, acceptedFileTypes: string | string[]): boolean;
|
|
1
17
|
export function bool(v: any): boolean;
|
|
@@ -8,6 +8,7 @@ import { default as WJElement } from '../wje-element/element.js';
|
|
|
8
8
|
* @tag wje-accordion
|
|
9
9
|
*/
|
|
10
10
|
export default class AccordionItem extends WJElement {
|
|
11
|
+
static _instanceId: number;
|
|
11
12
|
/**
|
|
12
13
|
* Getter for the CSS stylesheet.
|
|
13
14
|
* @returns {object} The styles for the Accordion Item element.
|
|
@@ -18,6 +19,7 @@ export default class AccordionItem extends WJElement {
|
|
|
18
19
|
* @returns {Array} An array containing the name of the observed attribute.
|
|
19
20
|
*/
|
|
20
21
|
static get observedAttributes(): any[];
|
|
22
|
+
_instanceId: number;
|
|
21
23
|
/**
|
|
22
24
|
* Method to draw the Accordion Item element. This method returns a document fragment containing the drawn element.
|
|
23
25
|
* @returns {object} The document fragment containing the drawn element.
|
|
@@ -25,6 +27,7 @@ export default class AccordionItem extends WJElement {
|
|
|
25
27
|
draw(): object;
|
|
26
28
|
headline: HTMLDivElement;
|
|
27
29
|
toggle: HTMLSlotElement;
|
|
30
|
+
content: HTMLDivElement;
|
|
28
31
|
/**
|
|
29
32
|
* Method to execute after the Accordion Item element is drawn.
|
|
30
33
|
*/
|
|
@@ -63,11 +63,16 @@ export default class Avatar extends WJElement {
|
|
|
63
63
|
* @returns {string} The size value of the element or 'medium' if not specified.
|
|
64
64
|
*/
|
|
65
65
|
get size(): string;
|
|
66
|
+
attributeChangedCallback(name: any, oldValue: any, newValue: any): void;
|
|
66
67
|
/**
|
|
67
68
|
* Method to draw the avatar element and return a document fragment.
|
|
68
69
|
* @returns {object} fragment - The document fragment
|
|
69
70
|
*/
|
|
70
71
|
draw(): object;
|
|
72
|
+
/**
|
|
73
|
+
* Syncs ARIA attributes on the host element.
|
|
74
|
+
*/
|
|
75
|
+
syncAria(): void;
|
|
71
76
|
/**
|
|
72
77
|
* Method to check if the avatar is an image.
|
|
73
78
|
* @returns {boolean} - True if the avatar is an image, false otherwise
|
|
@@ -59,6 +59,7 @@ export default class Breadcrumb extends WJElement {
|
|
|
59
59
|
*/
|
|
60
60
|
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): boolean;
|
|
61
61
|
active: boolean;
|
|
62
|
+
syncAria(): void;
|
|
62
63
|
/**
|
|
63
64
|
* Draw method for the Breadcrumb element.
|
|
64
65
|
* @returns {object} fragment - The document fragment
|
|
@@ -40,7 +40,6 @@ export default class Button extends WJElement {
|
|
|
40
40
|
* @type {boolean}
|
|
41
41
|
*/
|
|
42
42
|
static formAssociated: boolean;
|
|
43
|
-
internals_: ElementInternals;
|
|
44
43
|
/**
|
|
45
44
|
* Dependencies of the Button element.
|
|
46
45
|
* @type {object}
|
|
@@ -166,6 +165,7 @@ export default class Button extends WJElement {
|
|
|
166
165
|
* @returns {object} An object containing key-value pairs of custom event parameters.
|
|
167
166
|
*/
|
|
168
167
|
get customEventParameters(): object;
|
|
168
|
+
attributeChangedCallback(name: any, oldValue: any, newValue: any): void;
|
|
169
169
|
/**
|
|
170
170
|
* @summary Callback function that is called when the custom element is associated with a form.
|
|
171
171
|
* This function sets the internal `_form` property to the associated form.
|
|
@@ -200,5 +200,9 @@ export default class Button extends WJElement {
|
|
|
200
200
|
* Toggle states method for the Button element.
|
|
201
201
|
*/
|
|
202
202
|
toggleStates: () => void;
|
|
203
|
+
/**
|
|
204
|
+
* Syncs ARIA attributes on the host element.
|
|
205
|
+
*/
|
|
206
|
+
syncAria(): void;
|
|
203
207
|
#private;
|
|
204
208
|
}
|
|
@@ -73,6 +73,10 @@ export default class ButtonGroup extends WJElement {
|
|
|
73
73
|
* After draw method for the ButtonGroup element.
|
|
74
74
|
*/
|
|
75
75
|
afterDraw(): void;
|
|
76
|
+
/**
|
|
77
|
+
* Sync ARIA attributes on host.
|
|
78
|
+
*/
|
|
79
|
+
syncAria(): void;
|
|
76
80
|
/**
|
|
77
81
|
* Find button method to find the button element.
|
|
78
82
|
* @param {object} el The element
|
|
@@ -21,11 +21,20 @@ export default class Card extends WJElement {
|
|
|
21
21
|
*/
|
|
22
22
|
static get cssStyleSheet(): object;
|
|
23
23
|
/**
|
|
24
|
-
*
|
|
25
|
-
* @
|
|
26
|
-
* @
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
* Get observed attributes for the Card element.
|
|
25
|
+
* @static
|
|
26
|
+
* @returns {Array<string>} observedAttributes - The observed attributes array
|
|
27
|
+
*/
|
|
28
|
+
static get observedAttributes(): Array<string>;
|
|
29
|
+
/**
|
|
30
|
+
* Handles attribute changes for ARIA sync.
|
|
31
|
+
* @param {string} name
|
|
32
|
+
* @param {string|null} oldValue
|
|
33
|
+
* @param {string|null} newValue
|
|
34
|
+
*/
|
|
35
|
+
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
36
|
+
/**
|
|
37
|
+
* Sync ARIA attributes on host only when labeling is provided.
|
|
29
38
|
*/
|
|
30
|
-
|
|
39
|
+
syncAria(): void;
|
|
31
40
|
}
|
|
@@ -83,6 +83,10 @@ export default class Carousel extends WJElement {
|
|
|
83
83
|
* @param next
|
|
84
84
|
*/
|
|
85
85
|
goToSlide(index: any, behavior?: string, next?: boolean): void;
|
|
86
|
+
/**
|
|
87
|
+
* Syncs ARIA attributes on the carousel and slides.
|
|
88
|
+
*/
|
|
89
|
+
syncAria(): void;
|
|
86
90
|
/**
|
|
87
91
|
* Clones the first and last items.
|
|
88
92
|
*/
|
|
@@ -43,6 +43,16 @@ export default class Checkbox extends FormAssociatedElement {
|
|
|
43
43
|
* @returns {boolean} Whether the attribute is present.
|
|
44
44
|
*/
|
|
45
45
|
get validateOnChange(): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Setter for the label attribute.
|
|
48
|
+
* @param {string} value The label to set.
|
|
49
|
+
*/
|
|
50
|
+
set label(value: string);
|
|
51
|
+
/**
|
|
52
|
+
* Getter for the label attribute.
|
|
53
|
+
* @returns {string|null}
|
|
54
|
+
*/
|
|
55
|
+
get label(): string | null;
|
|
46
56
|
/**
|
|
47
57
|
* Setter for the defaultValue attribute.
|
|
48
58
|
* This method sets the 'value' attribute of the custom input element to the provided value.
|
|
@@ -96,5 +106,9 @@ export default class Checkbox extends FormAssociatedElement {
|
|
|
96
106
|
* Adds an event listener after drawing the checkbox.
|
|
97
107
|
*/
|
|
98
108
|
afterDraw(): void;
|
|
109
|
+
/**
|
|
110
|
+
* Syncs ARIA attributes on the host element.
|
|
111
|
+
*/
|
|
112
|
+
syncAria(): void;
|
|
99
113
|
#private;
|
|
100
114
|
}
|
|
@@ -16,6 +16,7 @@ export default class Chip extends WJElement {
|
|
|
16
16
|
* @returns {*}
|
|
17
17
|
*/
|
|
18
18
|
static get cssStyleSheet(): any;
|
|
19
|
+
static get observedAttributes(): string[];
|
|
19
20
|
/**
|
|
20
21
|
* Sets or removes the "round" attribute on the element based on the provided value.
|
|
21
22
|
* @param {boolean} value Determines whether the "round" attribute should be set or removed.
|
|
@@ -62,6 +63,7 @@ export default class Chip extends WJElement {
|
|
|
62
63
|
* @returns {boolean} True if the element has the 'disabled' attribute, otherwise false.
|
|
63
64
|
*/
|
|
64
65
|
get disabled(): boolean;
|
|
66
|
+
attributeChangedCallback(name: any, oldValue: any, newValue: any): void;
|
|
65
67
|
/**
|
|
66
68
|
* Draws the Chip element.
|
|
67
69
|
* @returns {DocumentFragment}
|
|
@@ -69,6 +71,10 @@ export default class Chip extends WJElement {
|
|
|
69
71
|
draw(): DocumentFragment;
|
|
70
72
|
removeElement: HTMLElement;
|
|
71
73
|
slotEnd: HTMLSlotElement;
|
|
74
|
+
/**
|
|
75
|
+
* Syncs ARIA attributes on the host element.
|
|
76
|
+
*/
|
|
77
|
+
syncAria(): void;
|
|
72
78
|
/**
|
|
73
79
|
* Getter for the observed attributes.
|
|
74
80
|
*/
|