wj-elements 0.1.50 → 0.1.52
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 +1 -2
- package/dist/wje-accordion-item.js +26 -33
- package/dist/wje-accordion.js +9 -11
- package/dist/wje-avatar.js +5 -8
- package/dist/wje-dialog.js +6 -6
- package/dist/wje-master.js +103 -101
- package/dist/wje-orgchart-item.js +49 -0
- package/dist/wje-orgchart.js +511 -0
- package/dist/wje-orgchartItem.js +4 -0
- package/dist/wje-sliding-container.js +99 -55
- package/dist/wje-store.js +35 -35
- package/dist/wje-tab-group.js +32 -13
- package/dist/wje-tab.js +1 -1
- package/package.json +1 -1
- package/dist/wje-inline-edit.js +0 -145
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
var p = Object.defineProperty;
|
|
2
|
-
var u = (
|
|
3
|
-
var
|
|
2
|
+
var u = (a, s, t) => s in a ? p(a, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[s] = t;
|
|
3
|
+
var l = (a, s, t) => (u(a, typeof s != "symbol" ? s + "" : s, t), t);
|
|
4
4
|
import v from "./wje-element.js";
|
|
5
5
|
const f = ":host{display:block}.sliding-container-wrapper{height:100%;position:relative;overflow:hidden}.native-sliding-container{overflow:auto}";
|
|
6
|
-
class
|
|
6
|
+
class d extends v {
|
|
7
7
|
/**
|
|
8
8
|
* Creates an instance of SlidingContainer.
|
|
9
9
|
*
|
|
@@ -11,15 +11,15 @@ class l extends v {
|
|
|
11
11
|
*/
|
|
12
12
|
constructor() {
|
|
13
13
|
super();
|
|
14
|
-
|
|
14
|
+
l(this, "className", "SlidingContainer");
|
|
15
15
|
/**
|
|
16
16
|
* Triggers the event based on the target element.
|
|
17
17
|
* If the target element is different from the last caller, it refreshes the children by calling the `open` method.
|
|
18
18
|
* If the target element is the same as the last caller, it toggles the state by calling the `toggle` method.
|
|
19
19
|
* @param {Event} e - The event object.
|
|
20
20
|
*/
|
|
21
|
-
|
|
22
|
-
this._lastCaller && this._lastCaller !== t.
|
|
21
|
+
l(this, "triggerEvent", (t) => {
|
|
22
|
+
this._lastCaller && this._lastCaller !== t.composedPath()[0] ? this.open(t) : this.toggle(t), this._lastCaller = t.composedPath()[0];
|
|
23
23
|
});
|
|
24
24
|
this._isOpen = !1, this._lastCaller = null;
|
|
25
25
|
}
|
|
@@ -91,7 +91,18 @@ class l extends v {
|
|
|
91
91
|
* @returns {string[]}
|
|
92
92
|
*/
|
|
93
93
|
static get observedAttributes() {
|
|
94
|
-
return [
|
|
94
|
+
return [
|
|
95
|
+
"max-width",
|
|
96
|
+
"max-height",
|
|
97
|
+
"trigger",
|
|
98
|
+
"direction",
|
|
99
|
+
"variant",
|
|
100
|
+
"screen-break-point",
|
|
101
|
+
"remove-child-after-close",
|
|
102
|
+
"animation-duration",
|
|
103
|
+
"animation-easing",
|
|
104
|
+
"has-opacity"
|
|
105
|
+
];
|
|
95
106
|
}
|
|
96
107
|
/**
|
|
97
108
|
* Returns the CSS styles for the component.
|
|
@@ -116,13 +127,14 @@ class l extends v {
|
|
|
116
127
|
* @param {Object} params - The parameters for drawing.
|
|
117
128
|
* @returns {DocumentFragment}
|
|
118
129
|
*/
|
|
119
|
-
draw(t, i,
|
|
130
|
+
draw(t, i, o) {
|
|
120
131
|
let r = document.createDocumentFragment();
|
|
121
132
|
this.style.position = "relative", this.style.height = "100%", this.wrapperDiv = document.createElement("div"), this.wrapperDiv.classList.add("sliding-container-wrapper"), this.transparentDiv = document.createElement("div"), this.transparentDiv.classList.add("sliding-container-transparent");
|
|
122
133
|
let e = document.createElement("div");
|
|
123
|
-
e.style.position = "absolute", e.style.width =
|
|
124
|
-
let
|
|
125
|
-
|
|
134
|
+
e.style.position = "absolute", e.style.width = 0, this.hasOpacity && (e.style.opacity = 0), e.style.height = "100%", e.classList.add("native-sliding-container"), e.setAttribute("part", "sliding-container"), this.direction === "right" ? e.style.right = 0 : e.style.left = 0;
|
|
135
|
+
let h = document.createElement("slot");
|
|
136
|
+
const n = document.createElement("div");
|
|
137
|
+
return n.classList.add("native-sliding-container-inner"), n.style.height = "100%", n.style.position = "absolute", n.style.width = this.maxWidth, n.appendChild(h), n.appendChild(this.getCloseButton()), e.appendChild(n), this.wrapperDiv.appendChild(this.transparentDiv), this.wrapperDiv.appendChild(e), r.appendChild(this.wrapperDiv), this.nativeElement = e, r;
|
|
126
138
|
}
|
|
127
139
|
/**
|
|
128
140
|
* Creates and returns a close button element.
|
|
@@ -162,34 +174,40 @@ class l extends v {
|
|
|
162
174
|
* @param {string} variant - The variant to check for.
|
|
163
175
|
*/
|
|
164
176
|
checkForVariant(t) {
|
|
165
|
-
var i,
|
|
177
|
+
var i, o;
|
|
166
178
|
if (t === "over") {
|
|
167
179
|
this.style.position = "fixed";
|
|
168
|
-
let r = window.getComputedStyle(
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
180
|
+
let r = window.getComputedStyle(
|
|
181
|
+
this.getParentElement()
|
|
182
|
+
), e = this.getParentElement().getBoundingClientRect(), h = parseFloat(
|
|
183
|
+
r.height
|
|
184
|
+
), n = parseFloat(
|
|
185
|
+
r.width
|
|
186
|
+
), c = parseFloat(r.top);
|
|
187
|
+
this.style.height = h + +this.addToHeight + "px", this.wrapperDiv.style.height = h + +this.addToHeight + "px", this.style.top = c + "px";
|
|
188
|
+
let g = this.getParentElement().firstElementChild === this || ((i = this.getParentElement().shadowRoot) == null ? void 0 : i.firstElementChild) === this, m = this.getParentElement().lastElementChild === this || ((o = this.getParentElement().shadowRoot) == null ? void 0 : o.lastElementChild) === this;
|
|
189
|
+
g && (this.direction === "right" ? this.style.left = e.left + "px" : this.style.right = window.innerWidth - (e.left + e.width) + n + "px"), m && (this.style.right = window.innerWidth - (e.left + e.width) + "px");
|
|
172
190
|
}
|
|
173
191
|
}
|
|
174
192
|
/**
|
|
175
193
|
* Executes before the element is opened.
|
|
176
194
|
*/
|
|
177
|
-
beforeOpen() {
|
|
195
|
+
beforeOpen(t) {
|
|
178
196
|
}
|
|
179
197
|
/**
|
|
180
198
|
* Callback function called after the element is opened.
|
|
181
199
|
*/
|
|
182
|
-
afterOpen() {
|
|
200
|
+
afterOpen(t) {
|
|
183
201
|
}
|
|
184
202
|
/**
|
|
185
203
|
* Executes before closing the element.
|
|
186
204
|
*/
|
|
187
|
-
beforeClose() {
|
|
205
|
+
beforeClose(t) {
|
|
188
206
|
}
|
|
189
207
|
/**
|
|
190
208
|
* Callback function that is called after the container is closed.
|
|
191
209
|
*/
|
|
192
|
-
afterClose() {
|
|
210
|
+
afterClose(t) {
|
|
193
211
|
}
|
|
194
212
|
/**
|
|
195
213
|
* Animates the transition of the element's width from 0 to the maximum width or vice versa.
|
|
@@ -207,29 +225,37 @@ class l extends v {
|
|
|
207
225
|
easing: this.animationEasing
|
|
208
226
|
};
|
|
209
227
|
if (this._isOpen)
|
|
210
|
-
this.animation.reverse(), this.
|
|
228
|
+
this.animation.reverse(), this.nativeAnimation.reverse();
|
|
211
229
|
else {
|
|
212
230
|
if (this.animation) {
|
|
213
|
-
this.animation.reverse(), this.
|
|
231
|
+
this.animation.reverse(), this.nativeAnimation.reverse();
|
|
214
232
|
return;
|
|
215
233
|
}
|
|
216
|
-
this.animation = this.transparentDiv.animate(
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
234
|
+
this.animation = this.transparentDiv.animate(
|
|
235
|
+
[
|
|
236
|
+
{
|
|
237
|
+
width: 0
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
width: this.maxWidth
|
|
241
|
+
}
|
|
242
|
+
],
|
|
243
|
+
t
|
|
244
|
+
), this.nativeAnimation = this.nativeElement.animate(
|
|
245
|
+
[
|
|
246
|
+
{
|
|
247
|
+
...this.hasOpacity ? { opacity: 0 } : {},
|
|
248
|
+
width: 0
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
...this.hasOpacity ? { opacity: 1 } : {},
|
|
252
|
+
width: this.maxWidth
|
|
253
|
+
}
|
|
254
|
+
],
|
|
255
|
+
t
|
|
256
|
+
);
|
|
231
257
|
}
|
|
232
|
-
return new Promise((i,
|
|
258
|
+
return new Promise((i, o) => {
|
|
233
259
|
this.animation.onfinish = () => {
|
|
234
260
|
i();
|
|
235
261
|
};
|
|
@@ -239,11 +265,20 @@ class l extends v {
|
|
|
239
265
|
* Opens the container with an animation.
|
|
240
266
|
* @returns {Promise<void>} A promise that resolves when the container is opened.
|
|
241
267
|
*/
|
|
242
|
-
async open() {
|
|
243
|
-
await Promise.resolve(this.beforeOpen()).then(() => {
|
|
244
|
-
Promise.resolve(
|
|
245
|
-
|
|
246
|
-
|
|
268
|
+
async open(t) {
|
|
269
|
+
await Promise.resolve(this.beforeOpen(t)).then(async () => {
|
|
270
|
+
await Promise.resolve(
|
|
271
|
+
this._isOpen ? () => {
|
|
272
|
+
} : (() => {
|
|
273
|
+
this.dispatchEvent(
|
|
274
|
+
new CustomEvent("wje-sliding-container:open", {
|
|
275
|
+
bubbles: !0,
|
|
276
|
+
composed: !0
|
|
277
|
+
})
|
|
278
|
+
), this.doAnimateTransition();
|
|
279
|
+
})()
|
|
280
|
+
).then(async () => {
|
|
281
|
+
await Promise.resolve(this.afterOpen(t)).then(() => {
|
|
247
282
|
this._isOpen = !0;
|
|
248
283
|
});
|
|
249
284
|
});
|
|
@@ -251,16 +286,25 @@ class l extends v {
|
|
|
251
286
|
}
|
|
252
287
|
/**
|
|
253
288
|
* Closes the animation container.
|
|
254
|
-
*
|
|
289
|
+
*
|
|
255
290
|
* @returns {Promise<void>} A promise that resolves when the container is closed.
|
|
256
291
|
*/
|
|
257
|
-
async close() {
|
|
258
|
-
await Promise.resolve(this.beforeClose()).then(() => {
|
|
259
|
-
Promise.resolve(
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
292
|
+
async close(t) {
|
|
293
|
+
await Promise.resolve(this.beforeClose(t)).then(async () => {
|
|
294
|
+
await Promise.resolve(
|
|
295
|
+
this._isOpen ? (() => {
|
|
296
|
+
this.dispatchEvent(
|
|
297
|
+
new CustomEvent("wje-sliding-container:close", {
|
|
298
|
+
bubbles: !0,
|
|
299
|
+
composed: !0
|
|
300
|
+
})
|
|
301
|
+
), this.doAnimateTransition();
|
|
302
|
+
})() : () => {
|
|
303
|
+
}
|
|
304
|
+
).then(async () => {
|
|
305
|
+
await Promise.resolve(this.afterClose(t)).then(() => {
|
|
306
|
+
this.removeChildAfterClose && this.childNodes.forEach((i) => {
|
|
307
|
+
i.remove();
|
|
264
308
|
}), this._isOpen = !1;
|
|
265
309
|
});
|
|
266
310
|
});
|
|
@@ -271,11 +315,11 @@ class l extends v {
|
|
|
271
315
|
* If the element is open, it will be closed. If it is closed, it will be opened.
|
|
272
316
|
* @returns {Promise<void>} A promise that resolves when the toggle operation is complete.
|
|
273
317
|
*/
|
|
274
|
-
async toggle() {
|
|
275
|
-
this._isOpen ? await this.close() : await this.open();
|
|
318
|
+
async toggle(t) {
|
|
319
|
+
this._isOpen ? await this.close(t) : await this.open(t);
|
|
276
320
|
}
|
|
277
321
|
}
|
|
278
|
-
|
|
322
|
+
d.define("wje-sliding-container", d);
|
|
279
323
|
export {
|
|
280
|
-
|
|
324
|
+
d as default
|
|
281
325
|
};
|
package/dist/wje-store.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
class
|
|
1
|
+
var d = Object.defineProperty;
|
|
2
|
+
var h = (i, r, e) => r in i ? d(i, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[r] = e;
|
|
3
|
+
var u = (i, r, e) => (h(i, typeof r != "symbol" ? r + "" : r, e), e);
|
|
4
|
+
class p {
|
|
5
5
|
constructor() {
|
|
6
6
|
this.events = {};
|
|
7
7
|
}
|
|
@@ -33,40 +33,40 @@ class d {
|
|
|
33
33
|
*/
|
|
34
34
|
publish(r, e = {}, t) {
|
|
35
35
|
let s = this;
|
|
36
|
-
return s.events.hasOwnProperty(r) ? s.events[r].map((
|
|
36
|
+
return s.events.hasOwnProperty(r) ? s.events[r].map((n) => n(e, t)) : [];
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
const c = (
|
|
40
|
-
type: `${
|
|
39
|
+
const c = (i) => (r) => ({
|
|
40
|
+
type: `${i}/ADD`,
|
|
41
41
|
payload: r
|
|
42
|
-
}),
|
|
43
|
-
type: `${
|
|
42
|
+
}), l = (i) => (r) => ({
|
|
43
|
+
type: `${i}/ADD_MANY`,
|
|
44
44
|
payload: r
|
|
45
|
-
}),
|
|
46
|
-
type: `${
|
|
45
|
+
}), y = (i) => (r) => ({
|
|
46
|
+
type: `${i}/UPDATE`,
|
|
47
47
|
payload: r
|
|
48
|
-
}), a = (
|
|
49
|
-
type: `${
|
|
48
|
+
}), a = (i) => (r) => ({
|
|
49
|
+
type: `${i}/DELETE`,
|
|
50
50
|
payload: r
|
|
51
|
-
}), f = (
|
|
52
|
-
type: `${
|
|
51
|
+
}), f = (i) => (r) => ({
|
|
52
|
+
type: `${i}/LOAD`,
|
|
53
53
|
payload: r
|
|
54
|
-
}),
|
|
54
|
+
}), o = {
|
|
55
55
|
addAction: c,
|
|
56
56
|
deleteAction: a,
|
|
57
57
|
loadAction: f,
|
|
58
|
-
updateAction:
|
|
59
|
-
addManyAction:
|
|
58
|
+
updateAction: y,
|
|
59
|
+
addManyAction: l
|
|
60
60
|
};
|
|
61
61
|
class A {
|
|
62
62
|
constructor(r = {}) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
63
|
+
u(this, "_state");
|
|
64
|
+
u(this, "_reducer");
|
|
65
|
+
u(this, "events");
|
|
66
|
+
u(this, "status");
|
|
67
67
|
this._isPause = !1, this._state = {}, this._reducer = function(t = {}, s) {
|
|
68
68
|
return {};
|
|
69
|
-
}, this.status = "resting", this.events = new
|
|
69
|
+
}, this.status = "resting", this.events = new p(), r != null && r.hasOwnProperty("reducer") && (this._reducer = r.reducer), this.refreshProxy(r == null ? void 0 : r.state);
|
|
70
70
|
}
|
|
71
71
|
/**
|
|
72
72
|
* A dispatcher for actions that looks in the actions
|
|
@@ -99,14 +99,14 @@ class A {
|
|
|
99
99
|
}
|
|
100
100
|
mergeReducers(r, e) {
|
|
101
101
|
let t = this._reducer;
|
|
102
|
-
this._reducer = (s,
|
|
103
|
-
...t(s,
|
|
104
|
-
[r]: e(s[r],
|
|
102
|
+
this._reducer = (s, n) => ({
|
|
103
|
+
...t(s, n),
|
|
104
|
+
[r]: e(s[r], n)
|
|
105
105
|
});
|
|
106
106
|
}
|
|
107
107
|
makeEveryArrayEntryAsStoreState(r, e = [], t = "id") {
|
|
108
108
|
e.forEach((s) => {
|
|
109
|
-
this.getState().hasOwnProperty(`${r}-${s[t]}`) ? this.dispatch(
|
|
109
|
+
this.getState().hasOwnProperty(`${r}-${s[t]}`) ? this.dispatch(o.updateAction(`${r}-${s[t]}`)(s)) : this.define(`${r}-${s.id || s.source || s[t]}`, s, null, t);
|
|
110
110
|
});
|
|
111
111
|
}
|
|
112
112
|
define(r, e, t, s = "id") {
|
|
@@ -124,14 +124,14 @@ class A {
|
|
|
124
124
|
set: (e, t, s) => {
|
|
125
125
|
if (JSON.stringify(e[t]) === JSON.stringify(s))
|
|
126
126
|
return !0;
|
|
127
|
-
let
|
|
128
|
-
return e[t] = s, this._isPause || this.events.publish(t, this._state,
|
|
127
|
+
let n = e[t];
|
|
128
|
+
return e[t] = s, this._isPause || this.events.publish(t, this._state, n), this.status !== "mutation" && console.warn(`You should use a mutation to set ${t}`), this.status = "resting", !0;
|
|
129
129
|
}
|
|
130
130
|
});
|
|
131
131
|
}
|
|
132
132
|
createObjectReducer(r) {
|
|
133
133
|
return (e = {}, t) => {
|
|
134
|
-
switch (t.type) {
|
|
134
|
+
switch (Array.isArray(t.payload) && console.error(`Nemôžete pridať do objektu hodnotu, ktorá je pole. Skontrolujte si či definovanie stavu vyzerá takto: "store.define(${r}, {})"`), t.type) {
|
|
135
135
|
case `${r}/ADD`:
|
|
136
136
|
return {
|
|
137
137
|
...t.payload
|
|
@@ -150,7 +150,7 @@ class A {
|
|
|
150
150
|
}
|
|
151
151
|
createArrayReducer(r, e) {
|
|
152
152
|
return (t = [], s) => {
|
|
153
|
-
switch (s.type) {
|
|
153
|
+
switch (Array.isArray(s.payload) && s.payload.length == 0 && console.warn("Nemá zmysel pridávať prázdne pole do pola"), !Array.isArray(s.payload) && (s.type != o.updateAction(r).type || s.type != o.deleteAction(r).type) && console.error(`Nemôžete pridať do poľa hodnotu, ktorá nie je pole. Skontrolujte si či definovanie stavu vyzerá takto: "store.define(${r}, [])"`), s.type) {
|
|
154
154
|
case `${r}/ADD`:
|
|
155
155
|
return Array.isArray(s.payload) ? [
|
|
156
156
|
...t,
|
|
@@ -165,15 +165,15 @@ class A {
|
|
|
165
165
|
...s.payload
|
|
166
166
|
];
|
|
167
167
|
case `${r}/UPDATE`:
|
|
168
|
-
return t.some((
|
|
169
|
-
...t.map((
|
|
168
|
+
return t.some((n) => n[e] == s.payload[e]) ? [
|
|
169
|
+
...t.map((n) => n[e] == s.payload[e] ? s.payload : n)
|
|
170
170
|
] : [
|
|
171
171
|
...t,
|
|
172
172
|
s.payload
|
|
173
173
|
];
|
|
174
174
|
case `${r}/DELETE`:
|
|
175
175
|
return [
|
|
176
|
-
...t.filter((
|
|
176
|
+
...t.filter((n) => n.hasOwnProperty(e) && n[e] != s.payload[e] || !n.hasOwnProperty(e) && n != s.payload)
|
|
177
177
|
];
|
|
178
178
|
case `${r}/LOAD`:
|
|
179
179
|
return [
|
|
@@ -187,6 +187,6 @@ class A {
|
|
|
187
187
|
}
|
|
188
188
|
let D = new A();
|
|
189
189
|
export {
|
|
190
|
-
|
|
190
|
+
o as defaultStoreActions,
|
|
191
191
|
D as store
|
|
192
192
|
};
|
package/dist/wje-tab-group.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
var u = Object.defineProperty;
|
|
2
2
|
var m = (a, e, t) => e in a ? u(a, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[e] = t;
|
|
3
|
-
var
|
|
3
|
+
var b = (a, e, t) => (m(a, typeof e != "symbol" ? e + "" : e, t), t);
|
|
4
4
|
import h from "./wje-element.js";
|
|
5
5
|
const g = ":host{--wje-tab-top: 0;--wje-tab-start: 0;--wje-tab-end: 0;--wje-tab-bottom: 0}.native-tab-group{display:flex;flex-direction:column;overflow:hidden;position:relative}.native-tab-group>header{display:flex;flex-direction:column}.native-tab-group>header>nav{display:flex}.native-tab-group>section{width:100%}.native-tab-group>section>article{scroll-snap-align:start;overflow-y:auto;overscroll-behavior-y:contain}:host([variant=top]){--wje-tab-top: auto !important;--wje-tab-writing-mode: horizontal-tb}:host([variant=top]) .native-tab-group{flex-direction:column}:host([variant=top]) nav{border-bottom:1px solid var(--wje-border-color)}:host([variant=start]){--wje-tab-start: auto !important;--wje-tab-writing-mode: vertical-rl}:host([variant=start]) .native-tab-group{flex-direction:row}:host([variant=start]) nav{flex-direction:column;border-right:1px solid var(--wje-border-color)}:host([variant=end]){--wje-tab-writing-mode: vertical-rl}:host([variant=end]) .native-tab-group{flex-direction:row-reverse}:host([variant=end]) nav{flex-direction:column;border-left:1px solid var(--wje-border-color)}:host([variant=bottom]){--wje-tab-bottom: auto !important;--wje-tab-writing-mode: horizontal-tb}:host([variant=bottom]) .native-tab-group{flex-direction:column-reverse}:host([variant=bottom]) nav{border-top:1px solid var(--wje-border-color)}";
|
|
6
|
-
class
|
|
6
|
+
class v extends h {
|
|
7
7
|
/**
|
|
8
8
|
* Creates an instance of TabGroup.
|
|
9
9
|
*
|
|
@@ -11,7 +11,7 @@ class b extends h {
|
|
|
11
11
|
*/
|
|
12
12
|
constructor() {
|
|
13
13
|
super();
|
|
14
|
-
|
|
14
|
+
b(this, "className", "TabGroup");
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
17
|
* Returns the CSS styles for the component.
|
|
@@ -28,6 +28,17 @@ class b extends h {
|
|
|
28
28
|
setupAttributes() {
|
|
29
29
|
this.isShadowRoot = "open";
|
|
30
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Sets up the event listeners before the component is drawn.
|
|
33
|
+
* This method is called before the component is drawn.
|
|
34
|
+
* It is used to set up event listeners.
|
|
35
|
+
*/
|
|
36
|
+
beforeDraw() {
|
|
37
|
+
let t = location.hash.replace("#", "");
|
|
38
|
+
this.getPanelAllName().includes(t) && window.addEventListener("load", (i) => {
|
|
39
|
+
this.setActiveTab(t);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
31
42
|
/**
|
|
32
43
|
* Draws the component.
|
|
33
44
|
*
|
|
@@ -36,25 +47,25 @@ class b extends h {
|
|
|
36
47
|
* @param {Object} params - The parameters for drawing.
|
|
37
48
|
* @returns {DocumentFragment}
|
|
38
49
|
*/
|
|
39
|
-
draw(t,
|
|
50
|
+
draw(t, i, n) {
|
|
40
51
|
let s = document.createDocumentFragment(), r = document.createElement("div");
|
|
41
52
|
r.setAttribute("part", "native"), r.classList.add("native-tab-group");
|
|
42
53
|
let o = document.createElement("header");
|
|
43
54
|
o.setAttribute("part", "tabs"), o.classList.add("scroll-snap-x");
|
|
44
|
-
let c = document.createElement("nav"),
|
|
45
|
-
|
|
55
|
+
let c = document.createElement("nav"), l = document.createElement("section");
|
|
56
|
+
l.setAttribute("part", "panels");
|
|
46
57
|
let p = document.createElement("slot"), d = document.createElement("slot");
|
|
47
|
-
return d.setAttribute("name", "nav"), o.appendChild(c), c.appendChild(d),
|
|
58
|
+
return d.setAttribute("name", "nav"), o.appendChild(c), c.appendChild(d), l.appendChild(p), r.appendChild(o), r.appendChild(l), s.appendChild(r), s;
|
|
48
59
|
}
|
|
49
60
|
/**
|
|
50
61
|
* Sets up the event listeners after the component is drawn.
|
|
51
62
|
*/
|
|
52
63
|
afterDraw() {
|
|
53
|
-
let t = this.getActiveTab(),
|
|
54
|
-
this.setActiveTab(
|
|
55
|
-
if (
|
|
64
|
+
let t = this.getActiveTab(), i = t ? t[0].name : this.getTabAll()[0].panel;
|
|
65
|
+
this.setActiveTab(i), this.addEventListener("wje-tab:change", (n) => {
|
|
66
|
+
if (n.detail.context.hasAttribute("disabled"))
|
|
56
67
|
return !1;
|
|
57
|
-
this.setActiveTab(
|
|
68
|
+
this.setActiveTab(n.detail.context.panel);
|
|
58
69
|
});
|
|
59
70
|
}
|
|
60
71
|
/**
|
|
@@ -100,8 +111,16 @@ class b extends h {
|
|
|
100
111
|
getPanelAll() {
|
|
101
112
|
return Array.from(this.querySelectorAll("wje-tab-panel"));
|
|
102
113
|
}
|
|
114
|
+
/**
|
|
115
|
+
* Returns the names of all tabs.
|
|
116
|
+
*
|
|
117
|
+
* @returns {Array<string>} An array of all tab names.
|
|
118
|
+
*/
|
|
119
|
+
getPanelAllName() {
|
|
120
|
+
return this.getPanelAll().map((t) => t.getAttribute("name"));
|
|
121
|
+
}
|
|
103
122
|
}
|
|
104
|
-
|
|
123
|
+
v.define("wje-tab-group", v);
|
|
105
124
|
export {
|
|
106
|
-
|
|
125
|
+
v as default
|
|
107
126
|
};
|
package/dist/wje-tab.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wj-elements",
|
|
3
3
|
"description": "WebJET Elements is a modern set of user interface tools harnessing the power of web components designed to simplify web application development.",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.52",
|
|
5
5
|
"homepage": "https://github.com/lencys/wj-elements",
|
|
6
6
|
"author": "Lukáš Ondrejček <lukas.ondrejcek@gmail.com>",
|
|
7
7
|
"license": "MIT",
|
package/dist/wje-inline-edit.js
DELETED
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
var u = Object.defineProperty;
|
|
2
|
-
var p = (s, n, t) => n in s ? u(s, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[n] = t;
|
|
3
|
-
var r = (s, n, t) => (p(s, typeof n != "symbol" ? n + "" : n, t), t);
|
|
4
|
-
import c from "./wje-element.js";
|
|
5
|
-
import m from "./wje-format-digital.js";
|
|
6
|
-
import b from "./wje-button.js";
|
|
7
|
-
import v from "./wje-input.js";
|
|
8
|
-
import f from "./wje-icon.js";
|
|
9
|
-
const g = ":host{cursor:pointer;overflow:hidden;@keyframes wjFade{0%{display:flex}to{display:none}}}:host .heading{z-index:1;display:flex;align-items:center;position:relative;min-height:34px}:host .heading .edit{margin-left:.5rem;opacity:0}:host .heading:hover .edit{opacity:1}:host .heading h5{margin:0;width:calc(100% - 50px);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}:host .native-inline-edit{align-items:center;border-radius:3px!important;margin:0 1rem 0 0;display:flex}:host .native-inline-edit.open{z-index:9}:host .native-inline-edit .buttons{display:flex;margin:0 0 0 .5rem}:host .fade-out{display:none}:host .fade-in{display:flex}";
|
|
10
|
-
class l extends c {
|
|
11
|
-
constructor() {
|
|
12
|
-
super();
|
|
13
|
-
/**
|
|
14
|
-
* Dependencies
|
|
15
|
-
* @type {Object}
|
|
16
|
-
*/
|
|
17
|
-
r(this, "depandencies", {
|
|
18
|
-
"wje-format-digital": m,
|
|
19
|
-
"wje-button": b,
|
|
20
|
-
"wje-input": v,
|
|
21
|
-
"wje-icon": f
|
|
22
|
-
});
|
|
23
|
-
/**
|
|
24
|
-
* The class name.
|
|
25
|
-
*/
|
|
26
|
-
r(this, "className", "InlineEdit");
|
|
27
|
-
}
|
|
28
|
-
get title() {
|
|
29
|
-
return this.getAttribute("title");
|
|
30
|
-
}
|
|
31
|
-
set title(t) {
|
|
32
|
-
return this.setAttribute("title", t);
|
|
33
|
-
}
|
|
34
|
-
get notEditable() {
|
|
35
|
-
return this.hasAttribute("not-editable");
|
|
36
|
-
}
|
|
37
|
-
set notEditable(t) {
|
|
38
|
-
return this.setAttribute("not-editable", "");
|
|
39
|
-
}
|
|
40
|
-
get endpoint() {
|
|
41
|
-
return this.getAttribute("endpoint");
|
|
42
|
-
}
|
|
43
|
-
set endpoint(t) {
|
|
44
|
-
return this.setAttribute("endpoint", t);
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Getter for the CSS stylesheet.
|
|
48
|
-
* @returns {string} The CSS stylesheet.
|
|
49
|
-
*/
|
|
50
|
-
static get cssStyleSheet() {
|
|
51
|
-
return g;
|
|
52
|
-
}
|
|
53
|
-
static get observedAttributes() {
|
|
54
|
-
return ["checked", "disabled"];
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Sets up the attributes for the checkbox.
|
|
58
|
-
*/
|
|
59
|
-
setupAttributes() {
|
|
60
|
-
this.isShadowRoot = "open";
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Draws the checkbox.
|
|
64
|
-
* @param {object} context - The context.
|
|
65
|
-
* @param {object} store - The store.
|
|
66
|
-
* @param {object} params - The parameters.
|
|
67
|
-
* @returns {DocumentFragment} The created fragment.
|
|
68
|
-
*/
|
|
69
|
-
draw(t, e, h) {
|
|
70
|
-
let i = document.createDocumentFragment();
|
|
71
|
-
if (this.heading = document.createElement("div"), this.heading.classList.add("heading"), this.h5 = document.createElement("h5"), this.h5.innerHTML = this.textContent || this.title || "Názov", this.heading.appendChild(this.h5), i.appendChild(this.heading), !this.notEditable) {
|
|
72
|
-
this.span = document.createElement("span"), this.span.innerHTML = '<wje-icon name="pencil"></wje-icon>';
|
|
73
|
-
let a = document.createElement("div");
|
|
74
|
-
a.setAttribute("part", "native"), a.classList.add("native-inline-edit"), this.input = this.inputElement(), this.buttons = document.createElement("div"), this.buttons.classList.add("buttons", "btn-group");
|
|
75
|
-
let d = document.createElement("wje-button");
|
|
76
|
-
d.setAttribute("fill", "outline"), d.setAttribute("color", "success"), d.innerHTML = '<wje-icon name="check"></wje-icon>';
|
|
77
|
-
let o = document.createElement("wje-button");
|
|
78
|
-
o.setAttribute("fill", "outline"), o.setAttribute("color", "danger"), o.innerHTML = '<wje-icon name="x"></wje-icon>', this.heading.appendChild(this.span), this.buttons.appendChild(d), this.buttons.appendChild(o), a.appendChild(this.input), a.appendChild(this.buttons), this.save = d, this.close = o, i.appendChild(a);
|
|
79
|
-
}
|
|
80
|
-
return i;
|
|
81
|
-
}
|
|
82
|
-
afterDraw(t, e, h) {
|
|
83
|
-
this.notEditable || (this.heading.addEventListener("click", (i) => {
|
|
84
|
-
this.heading.classList.remove("fade-in"), this.heading.classList.add("fade-out");
|
|
85
|
-
}), this.close.addEventListener("click", (i) => {
|
|
86
|
-
i.preventDefault(), i.stopImmediatePropagation(), i.stopPropagation(), native.classList.remove("open", "fade-in"), this.heading.classList.remove("fade-out"), this.heading.classList.add("fade-in");
|
|
87
|
-
}), this.save.addEventListener("click", (i) => {
|
|
88
|
-
this.endpoint === null ? this.dispatchEdit(this.input.value) : this.save(this.input.value);
|
|
89
|
-
}));
|
|
90
|
-
}
|
|
91
|
-
inputElement() {
|
|
92
|
-
let t = document.createElement("wje-input");
|
|
93
|
-
return t.setAttribute("variant", "standard"), t.setAttribute("type", "text"), t.setAttribute("placeholder", this.placelhoder), t.setAttribute("value", this.textContent), t;
|
|
94
|
-
}
|
|
95
|
-
save(t) {
|
|
96
|
-
return fetch(this.endpoint, {
|
|
97
|
-
method: "PUT",
|
|
98
|
-
headers: {
|
|
99
|
-
"Content-Type": "application/json"
|
|
100
|
-
},
|
|
101
|
-
body: t
|
|
102
|
-
}).then((e) => e.ok ? e.json() : e.text).then((e) => {
|
|
103
|
-
this.title = e.data, this.refresh(), intranet.notification(e), this.dispatchResponse(e.data);
|
|
104
|
-
}).catch((e) => {
|
|
105
|
-
intranet.notification(e), this.dispatchError(e);
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
dispatchEdit(t) {
|
|
109
|
-
document.dispatchEvent(
|
|
110
|
-
new CustomEvent("wje-inline-edit-save", {
|
|
111
|
-
bubbles: !0,
|
|
112
|
-
detail: {
|
|
113
|
-
value: t,
|
|
114
|
-
element: this
|
|
115
|
-
}
|
|
116
|
-
})
|
|
117
|
-
);
|
|
118
|
-
}
|
|
119
|
-
dispatchResponse(t) {
|
|
120
|
-
document.dispatchEvent(
|
|
121
|
-
new CustomEvent("wje-inline-edit-response", {
|
|
122
|
-
bubbles: !0,
|
|
123
|
-
detail: {
|
|
124
|
-
value: t,
|
|
125
|
-
element: this
|
|
126
|
-
}
|
|
127
|
-
})
|
|
128
|
-
);
|
|
129
|
-
}
|
|
130
|
-
dispatchError(t) {
|
|
131
|
-
document.dispatchEvent(
|
|
132
|
-
new CustomEvent("wje-inline-edit-error", {
|
|
133
|
-
bubbles: !0,
|
|
134
|
-
detail: {
|
|
135
|
-
value: t,
|
|
136
|
-
element: this
|
|
137
|
-
}
|
|
138
|
-
})
|
|
139
|
-
);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
l.define("wje-inline-edit", l);
|
|
143
|
-
export {
|
|
144
|
-
l as default
|
|
145
|
-
};
|