wj-elements 0.1.128 → 0.1.130
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/README.md +8 -4
- package/dist/assets/tags.json +3252 -22012
- package/dist/dark.css +211 -203
- package/dist/{infinite-scroll.element-DcO1E5Es.js → infinite-scroll.element-BmojLp3Z.js} +54 -44
- package/dist/light.css +511 -496
- package/dist/{list.element-TZXMx1rt.js → list.element-Ce1vIm1O.js} +3 -9
- package/dist/localize.js +4 -4
- package/dist/{popup.element-l8v-dMoK.js → popup.element-4DNn6DjX.js} +44 -53
- package/dist/{router-links-I2vcmVCs.js → router-links-CJnOdbas.js} +30 -77
- package/dist/styles.css +485 -473
- package/dist/wje-accordion-item.js +13 -11
- package/dist/wje-accordion.js +51 -14
- package/dist/wje-animation.js +149 -25
- package/dist/wje-aside.js +7 -12
- package/dist/wje-avatar.js +12 -15
- package/dist/wje-badge.js +24 -19
- package/dist/wje-breadcrumb.js +36 -44
- package/dist/wje-breadcrumbs.js +84 -27
- package/dist/wje-button-group.js +17 -23
- package/dist/wje-button.js +117 -66
- package/dist/wje-card-content.js +10 -13
- package/dist/wje-card-controls.js +10 -13
- package/dist/wje-card-header.js +5 -9
- package/dist/wje-card-subtitle.js +5 -8
- package/dist/wje-card-title.js +5 -8
- package/dist/wje-card.js +13 -14
- package/dist/wje-carousel-item.js +26 -1
- package/dist/wje-carousel.js +141 -24
- package/dist/wje-checkbox.js +300 -51
- package/dist/wje-chip.js +31 -12
- package/dist/wje-col.js +11 -15
- package/dist/wje-color-picker.js +92 -64
- package/dist/wje-container.js +6 -10
- package/dist/wje-copy-button.js +14 -18
- package/dist/wje-dialog.js +89 -5
- package/dist/wje-divider.js +2 -5
- package/dist/wje-dropdown.js +57 -24
- package/dist/wje-element.js +393 -218
- package/dist/wje-fetchAndParseCSS.js +2 -1
- package/dist/wje-file-upload-item.js +12 -19
- package/dist/wje-file-upload.js +117 -68
- package/dist/wje-footer.js +3 -10
- package/dist/wje-form.js +23 -1
- package/dist/wje-format-digital.js +5 -13
- package/dist/wje-grid.js +24 -3
- package/dist/wje-header.js +3 -10
- package/dist/wje-icon-picker.js +15 -31
- package/dist/wje-icon.js +10 -10
- package/dist/wje-img-comparer.js +8 -18
- package/dist/wje-img.js +5 -11
- package/dist/wje-infinite-scroll.js +1 -1
- package/dist/wje-input-file.js +20 -17
- package/dist/wje-input.js +51 -62
- package/dist/wje-item.js +31 -4
- package/dist/wje-kanban.js +37 -53
- package/dist/wje-label.js +4 -21
- package/dist/wje-list.js +1 -1
- package/dist/wje-main.js +4 -11
- package/dist/wje-masonry.js +21 -26
- package/dist/wje-master.js +201 -348
- package/dist/wje-menu-button.js +5 -13
- package/dist/wje-menu-item.js +211 -30
- package/dist/wje-menu-label.js +4 -11
- package/dist/wje-menu.js +6 -15
- package/dist/wje-option.js +19 -26
- package/dist/wje-options.js +148 -48
- package/dist/wje-orgchart-group.js +10 -17
- package/dist/wje-orgchart-item.js +13 -157
- package/dist/wje-orgchart.js +4 -10
- package/dist/wje-popup.js +1 -1
- package/dist/wje-progress-bar.js +17 -27
- package/dist/wje-qr-code.js +29 -13
- package/dist/wje-radio-group.js +21 -43
- package/dist/wje-radio.js +46 -8
- package/dist/wje-rate.js +38 -58
- package/dist/wje-relative-time.js +51 -43
- package/dist/wje-reorder-dropzone.js +20 -2
- package/dist/wje-reorder-handle.js +62 -3
- package/dist/wje-reorder-item.js +20 -2
- package/dist/wje-reorder.js +93 -36
- package/dist/wje-route.js +3 -9
- package/dist/wje-router-link.js +10 -14
- package/dist/wje-router-outlet.js +35 -37
- package/dist/wje-routerx.js +231 -338
- package/dist/wje-row.js +8 -20
- package/dist/wje-select.js +80 -104
- package/dist/wje-slider.js +17 -33
- package/dist/wje-sliding-container.js +127 -55
- package/dist/wje-split-view.js +15 -21
- package/dist/wje-status.js +9 -13
- package/dist/wje-step.js +18 -0
- package/dist/wje-stepper.js +65 -4734
- package/dist/wje-store.js +193 -90
- package/dist/wje-tab-group.js +7 -16
- package/dist/wje-tab-panel.js +4 -13
- package/dist/wje-tab.js +6 -14
- package/dist/wje-textarea.js +128 -42
- package/dist/wje-thumbnail.js +10 -23
- package/dist/wje-toast.js +38 -74
- package/dist/wje-toggle.js +24 -29
- package/dist/wje-toolbar-action.js +11 -15
- package/dist/wje-toolbar.js +11 -16
- package/dist/wje-tooltip.js +35 -23
- package/dist/wje-visually-hidden.js +10 -14
- package/package.json +22 -4
package/dist/wje-input.js
CHANGED
|
@@ -2,23 +2,14 @@ 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, { event } from "./wje-element.js";
|
|
5
|
-
const styles =
|
|
5
|
+
const styles = "/*\n[ WJ Input ]\n*/\n\n:host {\n width: 100%;\n margin-bottom: var(--wje-input-margin-bottom);\n display: block;\n\n .wrapper {\n display: flex;\n width: 100%;\n flex-direction: column;\n }\n .native-input {\n .input-wrapper {\n flex-wrap: wrap;\n display: flex;\n width: 100%;\n position: relative;\n box-sizing: border-box;\n\n label {\n width: 100%;\n }\n }\n &.default {\n background-color: var(--wje-input-background-color);\n font-family: var(--wje-input-font-family);\n position: relative;\n border-radius: var(--wje-input-border-radius);\n border-width: var(--wje-input-border-width);\n border-style: var(--wje-input-border-style);\n border-color: var(--wje-input-border-color);\n padding-inline: 0;\n padding-top: 0.25rem;\n padding-bottom: 0.25rem;\n transition: background-color 0.2s ease;\n cursor: text;\n .input-wrapper {\n padding-inline: 0.5rem;\n }\n &.focused {\n border-color: var(--wje-input-border-color-focus) !important;\n label {\n opacity: 0.67;\n font-size: 12px;\n letter-spacing: normal;\n }\n }\n input {\n border: none;\n height: 25px;\n min-height: 25px;\n padding: 0;\n margin-top: -4px;\n background: none;\n box-shadow: none;\n width: 100%;\n }\n label {\n margin: 0;\n display: block;\n opacity: 1;\n cursor: text;\n transition: opacity 0.2s ease;\n line-height: var(--wje-input-line-height);\n &.fade {\n opacity: 0.5;\n font-size: 12px;\n letter-spacing: normal;\n }\n }\n ::slotted([slot='start']) {\n border-left: none;\n border-top: none;\n border-bottom: none;\n }\n\n ::slotted([slot='end']) {\n border-right: none;\n border-top: none;\n border-bottom: none;\n }\n }\n &.standard {\n font-family: var(--wje-input-font-family);\n position: relative;\n border-radius: var(--wje-input-border-radius);\n padding-inline: 0;\n padding-top: 0;\n padding-bottom: 0;\n transition: background-color 0.2s ease;\n cursor: text;\n &.focused {\n input {\n border-color: var(--wje-input-border-color-focus) !important;\n }\n }\n input {\n background-color: var(--wje-input-background-color);\n display: block;\n min-height: 32px;\n padding-inline: 0.5rem;\n padding-top: 0;\n padding-bottom: 0;\n /*background: none;*/\n box-shadow: none;\n width: 100%;\n box-sizing: border-box;\n border-radius: var(--wje-input-border-radius);\n border-width: var(--wje-input-border-width);\n border-style: var(--wje-input-border-style);\n border-color: var(--wje-input-border-color);\n }\n label {\n margin: 0;\n display: inline-block;\n opacity: 1;\n cursor: text;\n transition: opacity 0.2s ease;\n line-height: var(--wje-input-line-height);\n }\n .input-wrapper {\n flex-wrap: nowrap;\n &:hover .clear {\n visibility: visible;\n }\n }\n ::slotted([slot='start']) {\n border-right: none;\n border-radius: var(--wje-input-border-radius) 0 0 var(--wje-input-border-radius);\n }\n\n ::slotted([slot='end']) {\n border-left: none;\n border-radius: 0 var(--wje-input-border-radius) var(--wje-input-border-radius) 0;\n }\n\n &.has-start input {\n border-top-left-radius: 0;\n border-bottom-left-radius: 0;\n }\n\n &.has-end input {\n border-top-right-radius: 0;\n border-bottom-right-radius: 0;\n }\n .error-message {\n position: static;\n\n background: transparent;\n padding: 0.25rem 0;\n left: auto;\n transform: none;\n color: var(--wje-input-color-invalid);\n font-size: 12px;\n line-height: normal;\n }\n }\n }\n}\n\n.clear {\n visibility: hidden;\n position: absolute;\n right: 0;\n top: 3px;\n --wje-padding-top: 0.25rem;\n --wje-padding-start: 0.25rem;\n --wje-padding-end: 0.25rem;\n --wje-padding-bottom: 0.25rem;\n --wje-button-margin-inline: 0 0.25rem;\n}\n\n:host([required]) .input-wrapper::after {\n color: var(--wje-input-color-invalid);\n content: '*';\n font-family: var(--wje-force-mac-font-family);\n font-size: 20px;\n position: absolute;\n right: 0;\n top: 0;\n}\n\n:host([required]) .standard .input-wrapper::after {\n top: 0;\n}\n\n:host([invalid]) {\n .error-message {\n display: block;\n }\n .default {\n label {\n opacity: 1 !important;\n color: var(--wje-input-color-invalid) !important;\n animation-name: shake;\n animation-duration: 0.4s;\n animation-iteration-count: 1;\n }\n }\n}\n\n::slotted([slot='start']),\n::slotted([slot='end']) {\n display: flex;\n align-items: center;\n border-width: var(--wje-input-border-width);\n border-style: var(--wje-input-border-style);\n border-color: var(--wje-input-border-color);\n padding-inline: var(--wje-input-slot-padding-inline);\n}\n\n/*\n .options-show is a class that is added to the host element when the select options are shown\n */\n:host(.options-show) ::slotted([slot='start']) {\n border-bottom-left-radius: 0 !important;\n}\n\n:host(.options-show) ::slotted([slot='end']) {\n border-bottom-right-radius: 0 !important;\n}\n\nslot[name='start'],\nslot[name='end'] {\n display: flex;\n}\n\nslot[name='error'] {\n display: none;\n margin-inline: 0.5rem;\n}\n\n:host([invalid]) slot[name='error'] {\n display: block;\n}\n\ninput {\n background-color: var(--wje-input-background-color);\n border-width: var(--wje-input-border-width);\n border-style: var(--wje-input-border-style);\n border-color: var(--wje-input-border-color);\n font-family: var(--wje-input-font-family);\n color: var(--wje-input-color);\n appearance: none;\n outline: 0;\n padding: 0.25rem 0.5rem;\n line-height: var(--wje-input-line-height);\n font-size: 14px;\n font-weight: normal;\n vertical-align: middle;\n min-height: 32px;\n}\n\n.error-message {\n display: none;\n position: absolute;\n max-width: 100%;\n min-width: auto;\n border-radius: 50px;\n background: black;\n padding: 0.25rem 0.5rem;\n top: 0;\n left: 50%;\n transform: translate(-50%, -75%);\n color: white;\n font-size: 12px;\n width: max-content;\n line-height: normal;\n}\n\n@keyframes shake {\n 8%,\n 41% {\n transform: translateX(-4px);\n }\n 25%,\n 58% {\n transform: translateX(4px);\n }\n 75% {\n transform: translateX(-2px);\n }\n 92% {\n transform: translateX(2px);\n }\n 0%,\n 100% {\n transform: translateX(0);\n }\n}\n";
|
|
6
6
|
class Input extends WJElement {
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
9
|
-
* @param {Object} options - The options for the Input class.
|
|
8
|
+
* Creates an instance of Input.
|
|
10
9
|
*/
|
|
11
|
-
constructor(
|
|
10
|
+
constructor() {
|
|
12
11
|
super();
|
|
13
|
-
|
|
14
|
-
* The class name of the input.
|
|
15
|
-
* @type {string}
|
|
16
|
-
*/
|
|
17
|
-
__publicField(this, "className", "Input");
|
|
18
|
-
this.invalid = false;
|
|
19
|
-
this.pristine = true;
|
|
20
|
-
this.internals = this.attachInternals();
|
|
21
|
-
this.observer = new MutationObserver((mutations) => {
|
|
12
|
+
__publicField(this, "observeFunction", (mutations) => {
|
|
22
13
|
mutations.forEach((mutation) => {
|
|
23
14
|
if (mutation.type === "attributes") {
|
|
24
15
|
const attributeName = mutation.attributeName;
|
|
@@ -29,15 +20,23 @@ class Input extends WJElement {
|
|
|
29
20
|
});
|
|
30
21
|
this.refresh();
|
|
31
22
|
});
|
|
23
|
+
/**
|
|
24
|
+
* The class name of the input element.
|
|
25
|
+
* @type {string}
|
|
26
|
+
*/
|
|
27
|
+
__publicField(this, "className", "Input");
|
|
28
|
+
this.invalid = false;
|
|
29
|
+
this.pristine = true;
|
|
30
|
+
this.internals = this.attachInternals();
|
|
31
|
+
this.observer = new MutationObserver(this.observeFunction);
|
|
32
32
|
}
|
|
33
33
|
/**
|
|
34
34
|
* Setter for the value attribute.
|
|
35
|
-
* @param {string} value
|
|
35
|
+
* @param {string} value The value to set.
|
|
36
36
|
*/
|
|
37
37
|
set value(value) {
|
|
38
38
|
this.internals.setFormValue(value);
|
|
39
|
-
if (this.input)
|
|
40
|
-
this.input.value = value;
|
|
39
|
+
if (this.input) this.input.value = value;
|
|
41
40
|
this.pristine = false;
|
|
42
41
|
this._value = value;
|
|
43
42
|
}
|
|
@@ -72,10 +71,11 @@ class Input extends WJElement {
|
|
|
72
71
|
}
|
|
73
72
|
/**
|
|
74
73
|
* Setter for the invalid attribute.
|
|
75
|
-
* @param {boolean} isInvalid
|
|
74
|
+
* @param {boolean} isInvalid Whether the input is invalid.
|
|
76
75
|
*/
|
|
77
76
|
set invalid(isInvalid) {
|
|
78
|
-
isInvalid
|
|
77
|
+
if (isInvalid) this.setAttribute("invalid", "");
|
|
78
|
+
else this.removeAttribute("invalid");
|
|
79
79
|
}
|
|
80
80
|
/**
|
|
81
81
|
* Getter for the form attribute.
|
|
@@ -86,14 +86,14 @@ class Input extends WJElement {
|
|
|
86
86
|
}
|
|
87
87
|
/**
|
|
88
88
|
* Getter for the name attribute.
|
|
89
|
-
* @returns {string} The name of the input.
|
|
89
|
+
* @returns {string} The name of the input element.
|
|
90
90
|
*/
|
|
91
91
|
get name() {
|
|
92
92
|
return this.getAttribute("name");
|
|
93
93
|
}
|
|
94
94
|
/**
|
|
95
95
|
* Getter for the type attribute.
|
|
96
|
-
* @returns {string} The type of the input.
|
|
96
|
+
* @returns {string} The type of the input element.
|
|
97
97
|
*/
|
|
98
98
|
get type() {
|
|
99
99
|
return this.localName;
|
|
@@ -107,7 +107,7 @@ class Input extends WJElement {
|
|
|
107
107
|
}
|
|
108
108
|
/**
|
|
109
109
|
* Getter for the validationMessage attribute.
|
|
110
|
-
* @returns {string} The validation message of the input.
|
|
110
|
+
* @returns {string} The validation message of the input element.
|
|
111
111
|
*/
|
|
112
112
|
get validationMessage() {
|
|
113
113
|
return this.internals.validationMessage;
|
|
@@ -133,24 +133,24 @@ class Input extends WJElement {
|
|
|
133
133
|
* @summary Setter for the defaultValue attribute.
|
|
134
134
|
* This method sets the 'value' attribute of the custom input element to the provided value.
|
|
135
135
|
* The 'value' attribute represents the default value of the input element.
|
|
136
|
-
* @param {string} value
|
|
136
|
+
* @param {string} value The value to set as the default value.
|
|
137
137
|
*/
|
|
138
138
|
set defaultValue(value) {
|
|
139
139
|
this.setAttribute("value", value);
|
|
140
140
|
}
|
|
141
141
|
/**
|
|
142
142
|
* Getter for the cssStyleSheet attribute.
|
|
143
|
-
* @returns {CSSStyleSheet} The CSS style sheet of the input.
|
|
143
|
+
* @returns {CSSStyleSheet} The CSS style sheet of the input element.
|
|
144
144
|
*/
|
|
145
145
|
static get cssStyleSheet() {
|
|
146
146
|
return styles;
|
|
147
147
|
}
|
|
148
148
|
/**
|
|
149
|
-
* Getter for the observedAttributes attribute.
|
|
149
|
+
* Getter for the observedAttributes attribute of the input element.
|
|
150
150
|
* @returns {Array} The attributes to observe for changes.
|
|
151
151
|
*/
|
|
152
152
|
static get observedAttributes() {
|
|
153
|
-
return;
|
|
153
|
+
return [];
|
|
154
154
|
}
|
|
155
155
|
/**
|
|
156
156
|
* Sets up the attributes for the input.
|
|
@@ -166,13 +166,10 @@ class Input extends WJElement {
|
|
|
166
166
|
this.observer.disconnect();
|
|
167
167
|
}
|
|
168
168
|
/**
|
|
169
|
-
* Draws the input.
|
|
170
|
-
* @param {CanvasRenderingContext2D} context - The context to draw on.
|
|
171
|
-
* @param {Object} store - The store to use.
|
|
172
|
-
* @param {Object} params - The parameters to use.
|
|
169
|
+
* Draws the input element.
|
|
173
170
|
* @returns {DocumentFragment} The drawn input.
|
|
174
171
|
*/
|
|
175
|
-
draw(
|
|
172
|
+
draw() {
|
|
176
173
|
let hasSlotStart = this.hasSlot(this, "start");
|
|
177
174
|
let hasSlotEnd = this.hasSlot(this, "end");
|
|
178
175
|
let hasSlotError = this.hasSlot(this, "error");
|
|
@@ -180,8 +177,7 @@ class Input extends WJElement {
|
|
|
180
177
|
let native = document.createElement("div");
|
|
181
178
|
native.setAttribute("part", "native");
|
|
182
179
|
native.classList.add("native-input", this.variant || "default");
|
|
183
|
-
if (this.hasAttribute("invalid"))
|
|
184
|
-
native.classList.add("has-error");
|
|
180
|
+
if (this.hasAttribute("invalid")) native.classList.add("has-error");
|
|
185
181
|
let wrapper = document.createElement("div");
|
|
186
182
|
wrapper.classList.add("wrapper");
|
|
187
183
|
let inputWrapper = document.createElement("div");
|
|
@@ -189,8 +185,7 @@ class Input extends WJElement {
|
|
|
189
185
|
inputWrapper.classList.add("input-wrapper");
|
|
190
186
|
let label = document.createElement("label");
|
|
191
187
|
label.innerText = this.label;
|
|
192
|
-
if (this.value && !this.hasAttribute("error"))
|
|
193
|
-
label.classList.add("fade");
|
|
188
|
+
if (this.value && !this.hasAttribute("error")) label.classList.add("fade");
|
|
194
189
|
let input = document.createElement("input");
|
|
195
190
|
input.setAttribute("type", "text");
|
|
196
191
|
input.setAttribute("part", "input");
|
|
@@ -231,12 +226,11 @@ class Input extends WJElement {
|
|
|
231
226
|
end.setAttribute("part", "end");
|
|
232
227
|
}
|
|
233
228
|
if (hasSlotStart) {
|
|
234
|
-
|
|
229
|
+
inputWrapper.appendChild(start);
|
|
235
230
|
native.classList.add("has-start");
|
|
236
231
|
}
|
|
237
232
|
if (this.variant === "standard") {
|
|
238
|
-
if (this.label)
|
|
239
|
-
native.appendChild(label);
|
|
233
|
+
if (this.label) native.appendChild(label);
|
|
240
234
|
} else {
|
|
241
235
|
inputWrapper.appendChild(label);
|
|
242
236
|
}
|
|
@@ -254,7 +248,7 @@ class Input extends WJElement {
|
|
|
254
248
|
inputWrapper.appendChild(this.clear);
|
|
255
249
|
}
|
|
256
250
|
if (hasSlotEnd) {
|
|
257
|
-
|
|
251
|
+
inputWrapper.appendChild(end);
|
|
258
252
|
native.classList.add("has-end");
|
|
259
253
|
}
|
|
260
254
|
fragment.appendChild(native);
|
|
@@ -265,7 +259,7 @@ class Input extends WJElement {
|
|
|
265
259
|
return fragment;
|
|
266
260
|
}
|
|
267
261
|
/**
|
|
268
|
-
* Runs after the input is drawn.
|
|
262
|
+
* Runs after the input is drawn to the DOM.
|
|
269
263
|
*/
|
|
270
264
|
afterDraw() {
|
|
271
265
|
this.input.addEventListener("focus", (e) => {
|
|
@@ -274,8 +268,7 @@ class Input extends WJElement {
|
|
|
274
268
|
});
|
|
275
269
|
this.input.addEventListener("blur", (e) => {
|
|
276
270
|
this.native.classList.remove("focused");
|
|
277
|
-
if (!e.target.value)
|
|
278
|
-
this.labelElement.classList.remove("fade");
|
|
271
|
+
if (!e.target.value) this.labelElement.classList.remove("fade");
|
|
279
272
|
});
|
|
280
273
|
this.input.addEventListener("input", (e) => {
|
|
281
274
|
this.validateInput();
|
|
@@ -308,6 +301,9 @@ class Input extends WJElement {
|
|
|
308
301
|
});
|
|
309
302
|
}
|
|
310
303
|
this.validateInput();
|
|
304
|
+
if (this.hasAttribute("invalid")) {
|
|
305
|
+
this.showInvalidMessage();
|
|
306
|
+
}
|
|
311
307
|
this.observer.observe(this, {
|
|
312
308
|
attributes: true,
|
|
313
309
|
// Watch for attribute changes
|
|
@@ -358,10 +354,7 @@ class Input extends WJElement {
|
|
|
358
354
|
let errorMessage = this.message;
|
|
359
355
|
if (!this.hasAttribute("message"))
|
|
360
356
|
errorMessage = this.hasAttribute(attr) ? this.getAttribute(attr) : this.input.validationMessage;
|
|
361
|
-
this.internals.setValidity(
|
|
362
|
-
{ [this.validationError]: true },
|
|
363
|
-
errorMessage
|
|
364
|
-
);
|
|
357
|
+
this.internals.setValidity({ [this.validationError]: true }, errorMessage);
|
|
365
358
|
}
|
|
366
359
|
}
|
|
367
360
|
} else {
|
|
@@ -381,8 +374,8 @@ class Input extends WJElement {
|
|
|
381
374
|
}
|
|
382
375
|
/**
|
|
383
376
|
* Checks whether the input has a slot.
|
|
384
|
-
* @param {HTMLElement} el
|
|
385
|
-
* @param {string} slotName
|
|
377
|
+
* @param {HTMLElement} el The element to check.
|
|
378
|
+
* @param {string} slotName The name of the slot to check for.
|
|
386
379
|
* @returns {boolean} Whether the input has the slot.
|
|
387
380
|
*/
|
|
388
381
|
hasSlot(el, slotName = null) {
|
|
@@ -392,7 +385,7 @@ class Input extends WJElement {
|
|
|
392
385
|
/**
|
|
393
386
|
* @summary Callback function that is called when the custom element is associated with a form.
|
|
394
387
|
* This function adds an event listener to the form's submit event, which validates the input and propagates the validation.
|
|
395
|
-
* @param {HTMLFormElement} form
|
|
388
|
+
* @param {HTMLFormElement} form The form the custom element is associated with.
|
|
396
389
|
*/
|
|
397
390
|
formAssociatedCallback(form) {
|
|
398
391
|
form == null ? void 0 : form.addEventListener("submit", () => {
|
|
@@ -404,8 +397,7 @@ class Input extends WJElement {
|
|
|
404
397
|
* The formResetCallback method is a built-in lifecycle callback that gets called when a form gets reset.
|
|
405
398
|
* This method is responsible for resetting the value of the custom input element to its default value.
|
|
406
399
|
* It also resets the form value and validity state in the form internals.
|
|
407
|
-
*
|
|
408
|
-
* @method
|
|
400
|
+
* @function
|
|
409
401
|
*/
|
|
410
402
|
formResetCallback() {
|
|
411
403
|
this.value = this.defaultValue;
|
|
@@ -416,9 +408,8 @@ class Input extends WJElement {
|
|
|
416
408
|
* The formStateRestoreCallback method is a built-in lifecycle callback that gets called when the state of a form-associated custom element is restored.
|
|
417
409
|
* This method is responsible for restoring the value of the custom input element to its saved state.
|
|
418
410
|
* It also restores the form value and validity state in the form internals to their saved states.
|
|
419
|
-
*
|
|
420
|
-
* @
|
|
421
|
-
* @method
|
|
411
|
+
* @param {object} state The saved state of the custom input element.
|
|
412
|
+
* @function
|
|
422
413
|
*/
|
|
423
414
|
formStateRestoreCallback(state) {
|
|
424
415
|
this.value = state.value;
|
|
@@ -428,9 +419,8 @@ class Input extends WJElement {
|
|
|
428
419
|
/**
|
|
429
420
|
* The formStateSaveCallback method is a built-in lifecycle callback that gets called when the state of a form-associated custom element is saved.
|
|
430
421
|
* This method is responsible for saving the value of the custom input element.
|
|
431
|
-
*
|
|
432
|
-
* @
|
|
433
|
-
* @method
|
|
422
|
+
* @returns {object} The saved state of the custom input element.
|
|
423
|
+
* @function
|
|
434
424
|
*/
|
|
435
425
|
formStateSaveCallback() {
|
|
436
426
|
return {
|
|
@@ -440,16 +430,15 @@ class Input extends WJElement {
|
|
|
440
430
|
/**
|
|
441
431
|
* The formDisabledCallback method is a built-in lifecycle callback that gets called when the disabled state of a form-associated custom element changes.
|
|
442
432
|
* This method is not implemented yet.
|
|
443
|
-
*
|
|
444
|
-
* @
|
|
445
|
-
* @method
|
|
433
|
+
* @param {boolean} disabled The new disabled state of the custom input element.
|
|
434
|
+
* @function
|
|
446
435
|
*/
|
|
447
436
|
formDisabledCallback(disabled) {
|
|
448
437
|
console.warn("formDisabledCallback not implemented yet");
|
|
449
438
|
}
|
|
450
|
-
dispatchEvent(
|
|
451
|
-
|
|
452
|
-
}
|
|
439
|
+
// dispatchEvent(e) {
|
|
440
|
+
// return false;
|
|
441
|
+
// }
|
|
453
442
|
}
|
|
454
443
|
/**
|
|
455
444
|
* Whether the input is associated with a form.
|
package/dist/wje-item.js
CHANGED
|
@@ -2,11 +2,24 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
4
|
import WJElement from "./wje-element.js";
|
|
5
|
-
const styles =
|
|
5
|
+
const styles = "/*\n[ WJ Item ]\n*/\n\n:host {\n display: block;\n position: relative;\n align-items: center;\n justify-content: space-between;\n outline: none;\n color: var(--wje-item-color);\n text-align: initial;\n text-decoration: none;\n overflow: hidden;\n box-sizing: border-box;\n width: 100%;\n}\n\n.item-native {\n border-radius: var(--wje-item-border-radius);\n padding-top: var(--wje-item-padding-top);\n padding-bottom: var(--wje-item-padding-bottom);\n padding-inline: var(--wje-item-padding-start) var(--wje-item-padding-end);\n margin: 0;\n display: flex;\n position: relative;\n align-items: inherit;\n justify-content: inherit;\n width: 100%;\n min-height: var(--wje-item-min-height);\n transition: var(--wje-item-transition);\n outline: none;\n background: var(--wje-item-background);\n overflow: inherit;\n box-sizing: border-box;\n z-index: 1;\n text-decoration: none;\n color: var(--wje-item-color);\n\n .item-inner {\n margin: 0;\n padding: var(--wje-item-inner-padding-top) var(--wje-item-inner-padding-end)\n var(--wje-item-inner-padding-bottom) var(--wje-item-inner-padding-start);\n\n display: flex;\n position: relative;\n\n flex: 1 1 0;\n flex-direction: inherit;\n align-items: inherit;\n align-self: stretch;\n\n min-height: inherit;\n\n border-width: var(--wje-item-border-width);\n border-style: var(--wje-item-border-style);\n border-color: var(--wje-item-border-color);\n\n box-shadow: var(--wje-item-inner-box-shadow);\n overflow: inherit;\n box-sizing: border-box;\n\n .input-wrapper {\n display: flex;\n flex: 1 1 0;\n flex-direction: inherit;\n align-items: inherit;\n align-self: stretch;\n text-overflow: ellipsis;\n overflow: inherit;\n box-sizing: border-box;\n }\n }\n\n .item-bottom {\n padding: 0 var(--wje-item-inner-padding-end) 0 var(--wje-item-padding-start);\n display: flex;\n justify-content: space-between;\n }\n}\n\n@media (any-hover: hover) {\n :host(:hover) .item-native {\n color: var(--wje-item-color);\n\n :after {\n transition: var(--wje-item-transition);\n z-index: -1;\n inset: 0;\n position: absolute;\n content: '';\n background: var(--wje-item-background-hover);\n opacity: 0.7;\n }\n }\n}\n\nbutton,\na {\n cursor: pointer;\n user-select: none;\n -webkit-user-drag: none;\n}\n\n::slotted([slot='start']) {\n margin-inline: 0 1rem;\n}\n\n::slotted(wje-label:not([slot='end'])) {\n flex: 1 1 0;\n}\n";
|
|
6
6
|
class Item extends WJElement {
|
|
7
|
+
/**
|
|
8
|
+
* Item constructor for the class.
|
|
9
|
+
*/
|
|
7
10
|
constructor() {
|
|
8
11
|
super();
|
|
12
|
+
/**
|
|
13
|
+
* Returns the CSS styles for the component.
|
|
14
|
+
* @type {string}
|
|
15
|
+
*/
|
|
9
16
|
__publicField(this, "className", "Item");
|
|
17
|
+
/**
|
|
18
|
+
* Determines if the given element or any of its ancestors matches the specified selector.
|
|
19
|
+
* @param {string} selector The CSS selector to match against the element's ancestors.
|
|
20
|
+
* @param {HTMLElement} el The element from which to start the search.
|
|
21
|
+
* @returns {boolean} - Returns `true` if the element or one of its ancestors matches the selector; otherwise, `false`.
|
|
22
|
+
*/
|
|
10
23
|
__publicField(this, "hostContext", (selector, el) => {
|
|
11
24
|
return el.closest(selector) !== null;
|
|
12
25
|
});
|
|
@@ -22,18 +35,32 @@ class Item extends WJElement {
|
|
|
22
35
|
this.routerDirection = "forward";
|
|
23
36
|
this.type = "button";
|
|
24
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Returns the CSS styles for the component.
|
|
40
|
+
* @returns {boolean}
|
|
41
|
+
*/
|
|
25
42
|
isClickable() {
|
|
26
43
|
return this.hasAttribute("href") || this.button;
|
|
27
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* Returns the CSS styles for the component.
|
|
47
|
+
* @static
|
|
48
|
+
* @returns {object} styles
|
|
49
|
+
*/
|
|
28
50
|
static get cssStyleSheet() {
|
|
29
51
|
return styles;
|
|
30
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* Sets up the attributes for the component.
|
|
55
|
+
*/
|
|
31
56
|
setupAttributes() {
|
|
32
57
|
this.isShadowRoot = "open";
|
|
33
58
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
59
|
+
/**
|
|
60
|
+
* Draws the component for the item.
|
|
61
|
+
* @returns {DocumentFragment}
|
|
62
|
+
*/
|
|
63
|
+
draw() {
|
|
37
64
|
const TagType = this.isClickable() ? this.hasAttribute("href") === void 0 ? "button" : "a" : "div";
|
|
38
65
|
if (this.hostContext("wje-list", this)) {
|
|
39
66
|
this.classList.add("wje-item-list");
|
package/dist/wje-kanban.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
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
|
-
import WJElement from "./wje-element.js";
|
|
5
4
|
import Checkbox from "./wje-checkbox.js";
|
|
5
|
+
import WJElement from "./wje-element.js";
|
|
6
6
|
import MenuItem from "./wje-menu-item.js";
|
|
7
|
-
const styles = "/*\n[ Wj kanban ]\n*/\n\n:host {\n
|
|
7
|
+
const styles = "/*\n[ Wj kanban ]\n*/\n\n:host {\n display: flex;\n flex-direction: column;\n width: 100%;\n height: 100%;\n}\n.native {\n height: 100%;\n display: grid;\n grid-auto-flow: column;\n grid-auto-columns: 300px;\n overflow-x: auto;\n gap: 1rem;\n}\n\n.pool {\n display: inline-block;\n width: 300px;\n flex: 0 0 300px;\n vertical-align: top;\n overflow: auto;\n padding: 8px;\n border-radius: 8px;\n margin-right: 15px;\n}\n\nh4 {\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n margin: 0;\n}\n\n.card {\n border-radius: 5px;\n background: #fff;\n border: 1px solid #ddd;\n margin-bottom: 5px;\n padding: 8px 10px;\n color: #000;\n}\n\n.card:hover {\n opacity: 0.5;\n}\n\n.dragging {\n box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);\n transform: rotate(-2deg);\n opacity: 0.5;\n position: relative;\n z-index: 1000;\n}\n\n.card-placeholder {\n display: block;\n height: 34px;\n border: 1px dashed #ddd;\n margin: 3px 0;\n border-radius: 5px;\n}\n\n.pool-header {\n display: flex;\n align-items: center;\n margin-bottom: 0.25rem;\n gap: 0 0.25rem;\n wje-checkbox {\n margin: 0;\n }\n wje-badge {\n margin-inline-start: auto;\n }\n}\n";
|
|
8
8
|
class Kanban extends WJElement {
|
|
9
9
|
/**
|
|
10
10
|
* Creates an instance of Kanban.
|
|
11
|
-
* @
|
|
11
|
+
* @class
|
|
12
12
|
*/
|
|
13
13
|
constructor() {
|
|
14
14
|
super();
|
|
@@ -25,9 +25,9 @@ class Kanban extends WJElement {
|
|
|
25
25
|
*/
|
|
26
26
|
__publicField(this, "className", "Kanban");
|
|
27
27
|
/**
|
|
28
|
-
*
|
|
29
|
-
* @param pool
|
|
30
|
-
* @param items
|
|
28
|
+
* Iterates over a list of items, generates an HTML card for each, and appends it to the specified pool's content area.
|
|
29
|
+
* @param {HTMLElement} pool The container element where the cards will be appended. It should contain an element with the class `.pool-content`.
|
|
30
|
+
* @param {Array} items An array of items used to generate HTML cards.
|
|
31
31
|
*/
|
|
32
32
|
__publicField(this, "customForeach", (pool, items) => {
|
|
33
33
|
for (const item of items) {
|
|
@@ -158,21 +158,6 @@ class Kanban extends WJElement {
|
|
|
158
158
|
get response() {
|
|
159
159
|
return this._response;
|
|
160
160
|
}
|
|
161
|
-
// /**
|
|
162
|
-
// * Sets the URL for fetching data.
|
|
163
|
-
// * @param value {string}
|
|
164
|
-
// */
|
|
165
|
-
// set poolName(value) {
|
|
166
|
-
// this.setAttribute("pool-name", value);
|
|
167
|
-
// }
|
|
168
|
-
//
|
|
169
|
-
// /**
|
|
170
|
-
// * Gets the URL for fetching data.
|
|
171
|
-
// * @returns {string|string}
|
|
172
|
-
// */
|
|
173
|
-
// get poolName() {
|
|
174
|
-
// return this.getAttribute("pool-name") || "status";
|
|
175
|
-
// }
|
|
176
161
|
/**
|
|
177
162
|
* Sets the URL for fetching data.
|
|
178
163
|
* @param value {array}
|
|
@@ -189,7 +174,6 @@ class Kanban extends WJElement {
|
|
|
189
174
|
}
|
|
190
175
|
/**
|
|
191
176
|
* Returns the CSS styles for the component.
|
|
192
|
-
*
|
|
193
177
|
* @static
|
|
194
178
|
* @returns {CSSStyleSheet}
|
|
195
179
|
*/
|
|
@@ -198,7 +182,6 @@ class Kanban extends WJElement {
|
|
|
198
182
|
}
|
|
199
183
|
/**
|
|
200
184
|
* Returns the list of attributes to observe for changes.
|
|
201
|
-
*
|
|
202
185
|
* @static
|
|
203
186
|
* @returns {Array<string>}
|
|
204
187
|
*/
|
|
@@ -213,23 +196,18 @@ class Kanban extends WJElement {
|
|
|
213
196
|
}
|
|
214
197
|
/**
|
|
215
198
|
* Prepares the component before drawing.
|
|
216
|
-
*
|
|
217
|
-
* @param {
|
|
218
|
-
* @param {
|
|
219
|
-
* @param {Object} params - The parameters for drawing.
|
|
199
|
+
* @param {object} context The context for drawing.
|
|
200
|
+
* @param {object} store The store for drawing.
|
|
201
|
+
* @param {object} params The parameters for drawing.
|
|
220
202
|
*/
|
|
221
203
|
async beforeDraw(context, store, params) {
|
|
222
204
|
this.response = await this.getPages();
|
|
223
205
|
}
|
|
224
206
|
/**
|
|
225
|
-
* Draws the component.
|
|
226
|
-
*
|
|
227
|
-
* @param {Object} context - The context for drawing.
|
|
228
|
-
* @param {Object} store - The store for drawing.
|
|
229
|
-
* @param {Object} params - The parameters for drawing.
|
|
207
|
+
* Draws the component after it has been prepared.
|
|
230
208
|
* @returns {DocumentFragment}
|
|
231
209
|
*/
|
|
232
|
-
draw(
|
|
210
|
+
draw() {
|
|
233
211
|
let fragment = document.createDocumentFragment();
|
|
234
212
|
let native = document.createElement("div");
|
|
235
213
|
native.classList.add("native");
|
|
@@ -249,8 +227,8 @@ class Kanban extends WJElement {
|
|
|
249
227
|
/**
|
|
250
228
|
* Called after the component has been drawn.
|
|
251
229
|
*/
|
|
252
|
-
|
|
253
|
-
this.
|
|
230
|
+
afterDraw() {
|
|
231
|
+
this.ui = {
|
|
254
232
|
elBoard: this.shadowRoot.getElementById("board"),
|
|
255
233
|
elTotalCardCount: this.shadowRoot.getElementById("totalCards"),
|
|
256
234
|
elCardPlaceholder: null
|
|
@@ -275,10 +253,10 @@ class Kanban extends WJElement {
|
|
|
275
253
|
});
|
|
276
254
|
this.live("dragend", ".pool .card", (e) => {
|
|
277
255
|
e.target.style.opacity = "";
|
|
278
|
-
if (this.
|
|
279
|
-
this.
|
|
256
|
+
if (this.ui.elCardPlaceholder) {
|
|
257
|
+
this.ui.elCardPlaceholder.remove();
|
|
280
258
|
}
|
|
281
|
-
this.
|
|
259
|
+
this.ui.elCardPlaceholder = null;
|
|
282
260
|
this.isDragging = false;
|
|
283
261
|
});
|
|
284
262
|
this.live("dragover", ".pool, .pool .card, .pool .card-placeholder", (e) => {
|
|
@@ -398,16 +376,16 @@ class Kanban extends WJElement {
|
|
|
398
376
|
* @returns {null|*}
|
|
399
377
|
*/
|
|
400
378
|
getCardPlaceholder() {
|
|
401
|
-
if (!this.
|
|
402
|
-
this.
|
|
403
|
-
this.
|
|
404
|
-
this.
|
|
405
|
-
this.
|
|
379
|
+
if (!this.ui.elCardPlaceholder) {
|
|
380
|
+
this.ui.elCardPlaceholder = document.createElement("div");
|
|
381
|
+
this.ui.elCardPlaceholder.className = "card-placeholder";
|
|
382
|
+
this.ui.elCardPlaceholder.style.width = this.draggedElementWidth + "px";
|
|
383
|
+
this.ui.elCardPlaceholder.style.height = this.draggedElementHeight + "px";
|
|
406
384
|
} else {
|
|
407
|
-
this.
|
|
408
|
-
this.
|
|
385
|
+
this.ui.elCardPlaceholder.style.width = this.draggedElementWidth + "px";
|
|
386
|
+
this.ui.elCardPlaceholder.style.height = this.draggedElementHeight + "px";
|
|
409
387
|
}
|
|
410
|
-
return this.
|
|
388
|
+
return this.ui.elCardPlaceholder;
|
|
411
389
|
}
|
|
412
390
|
/**
|
|
413
391
|
* Adds a live event listener to the component.
|
|
@@ -417,15 +395,19 @@ class Kanban extends WJElement {
|
|
|
417
395
|
*/
|
|
418
396
|
live(eventType, selector, callback) {
|
|
419
397
|
const attachListener = (root) => {
|
|
420
|
-
root.addEventListener(
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
398
|
+
root.addEventListener(
|
|
399
|
+
eventType,
|
|
400
|
+
(e) => {
|
|
401
|
+
if (e.target.matches(selector)) {
|
|
402
|
+
callback.call(e.target, e);
|
|
403
|
+
}
|
|
404
|
+
},
|
|
405
|
+
false
|
|
406
|
+
);
|
|
425
407
|
};
|
|
426
408
|
const traverseAndAttach = (root) => {
|
|
427
409
|
attachListener(root);
|
|
428
|
-
root.querySelectorAll("*").forEach(
|
|
410
|
+
root.querySelectorAll("*").forEach((node) => {
|
|
429
411
|
if (node.shadowRoot) {
|
|
430
412
|
traverseAndAttach(node.shadowRoot);
|
|
431
413
|
}
|
|
@@ -461,7 +443,9 @@ class Kanban extends WJElement {
|
|
|
461
443
|
*/
|
|
462
444
|
async getPages(page = 0) {
|
|
463
445
|
let hasParams = this.url.includes("?");
|
|
464
|
-
const response = await fetch(
|
|
446
|
+
const response = await fetch(
|
|
447
|
+
`${this.url}${hasParams ? "&" : "?"}page=${page}&size=${this.size}${this == null ? void 0 : this.queryParams}`
|
|
448
|
+
);
|
|
465
449
|
if (!response.ok) {
|
|
466
450
|
throw new Error(`An error occurred: ${response.status}`);
|
|
467
451
|
}
|