wj-elements 0.0.11 → 0.0.13
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/localize-20081fd1.js +55 -0
- package/dist/router-links-26e4a166.js +204 -0
- package/dist/style.css +2243 -2
- package/dist/wj-animation.js +35 -23
- package/dist/wj-aside.js +22 -16
- package/dist/wj-avatar.js +49 -30
- package/dist/wj-badge.js +22 -18
- package/dist/wj-breadcrumb.js +102 -50
- package/dist/wj-breadcrumbs.js +36 -19
- package/dist/wj-button-group.js +36 -22
- package/dist/wj-button.js +104 -39
- package/dist/wj-card-content.js +18 -14
- package/dist/wj-card-controls.js +18 -14
- package/dist/wj-card-header.js +20 -14
- package/dist/wj-card-subtitle.js +19 -15
- package/dist/wj-card-title.js +18 -14
- package/dist/wj-card.js +20 -14
- package/dist/wj-carousel-item.js +22 -16
- package/dist/wj-carousel.js +169 -92
- package/dist/wj-checkbox.js +46 -24
- package/dist/wj-chip.js +39 -21
- package/dist/wj-col.js +31 -17
- package/dist/wj-color-picker.js +877 -509
- package/dist/wj-container.js +20 -16
- package/dist/wj-copy-button.js +112 -64
- package/dist/wj-dialog.js +68 -42
- package/dist/wj-divider.js +20 -14
- package/dist/wj-dropdown.js +29 -17
- package/dist/wj-element.js +415 -241
- package/dist/wj-fetchAndParseCSS.js +49 -32
- package/dist/wj-file-upload-item.js +64 -38
- package/dist/wj-file-upload.js +237 -137
- package/dist/wj-footer.js +18 -14
- package/dist/wj-form.js +18 -14
- package/dist/wj-format-digital.js +40 -25
- package/dist/wj-grid.js +20 -16
- package/dist/wj-header.js +22 -16
- package/dist/wj-icon-picker.js +122 -68
- package/dist/wj-icon.js +144 -64
- package/dist/wj-img-comparer.js +72 -41
- package/dist/wj-img.js +31 -19
- package/dist/wj-infinite-scroll.js +90 -52
- package/dist/wj-input-file.js +50 -27
- package/dist/wj-input.js +169 -70
- package/dist/wj-item.js +34 -17
- package/dist/wj-label.js +21 -19
- package/dist/wj-list.js +20 -15
- package/dist/wj-main.js +18 -14
- package/dist/wj-masonry.js +140 -83
- package/dist/wj-master.js +492 -350
- package/dist/wj-menu-button.js +19 -15
- package/dist/wj-menu-item.js +150 -64
- package/dist/wj-menu-label.js +21 -17
- package/dist/wj-menu.js +24 -18
- package/dist/wj-popup.js +1140 -712
- package/dist/wj-progress-bar.js +100 -40
- package/dist/wj-radio-group.js +38 -25
- package/dist/wj-radio.js +46 -22
- package/dist/wj-rate.js +121 -71
- package/dist/wj-relative-time.js +48 -24
- package/dist/wj-route.js +11 -8
- package/dist/wj-router-link.js +22 -17
- package/dist/wj-router-outlet.js +135 -71
- package/dist/wj-routerx.js +1124 -641
- package/dist/wj-row.js +21 -19
- package/dist/wj-slider.js +97 -55
- package/dist/wj-split-view.js +81 -43
- package/dist/wj-store.js +195 -110
- package/dist/wj-textarea.js +86 -37
- package/dist/wj-thumbnail.js +19 -15
- package/dist/wj-toast.js +87 -34
- package/dist/wj-toggle.js +42 -24
- package/dist/wj-toolbar-action.js +27 -16
- package/dist/wj-toolbar.js +26 -19
- package/dist/wj-tooltip.js +40 -24
- package/dist/wj-visually-hidden.js +18 -14
- package/package.json +1 -1
- package/dist/localize-762a9f0f.js +0 -43
- package/dist/router-links-e0087f84.js +0 -146
package/dist/wj-list.js
CHANGED
|
@@ -1,30 +1,35 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => {
|
|
4
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
return value;
|
|
6
|
+
};
|
|
7
|
+
import WJElement from "./wj-element.js";
|
|
5
8
|
import "./wj-store.js";
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
class c extends l {
|
|
9
|
+
const styles = "/*\n[ WJ List ]\n*/\n:host {\n --wj-list-inset-padding: 1rem;\n --wj-list-border-radius: 8px;\n --wj-list-background: var(--wj-background);\n margin: 0;\n padding: 0;\n display: block;\n contain: content;\n list-style-type: none;\n}\n\n:host(.wj-inset) {\n background: var(--wj-list-background);\n transform: translateZ(0);\n overflow: hidden;\n padding: var(--wj-list-inset-padding);\n border-radius: var(--wj-list-border-radius);\n}\n\n:host(.wj-lines-none) ::slotted(wj-item) {\n --wj-border-width: 0 !important;\n}";
|
|
10
|
+
class List extends WJElement {
|
|
9
11
|
constructor() {
|
|
10
12
|
super();
|
|
11
|
-
|
|
13
|
+
__publicField(this, "className", "List");
|
|
12
14
|
}
|
|
13
15
|
static get cssStyleSheet() {
|
|
14
|
-
return
|
|
16
|
+
return styles;
|
|
15
17
|
}
|
|
16
18
|
setupAttributes() {
|
|
17
19
|
this.isShadowRoot = "open";
|
|
18
20
|
}
|
|
19
|
-
draw(
|
|
20
|
-
let
|
|
21
|
-
|
|
21
|
+
draw(context, store, params) {
|
|
22
|
+
let fragment = document.createDocumentFragment();
|
|
23
|
+
let element = document.createElement("slot");
|
|
24
|
+
fragment.appendChild(element);
|
|
25
|
+
return fragment;
|
|
22
26
|
}
|
|
23
27
|
afterDraw() {
|
|
24
|
-
this.classList.toggle("wj-lines-" + this.lines, this.hasAttribute("lines"))
|
|
28
|
+
this.classList.toggle("wj-lines-" + this.lines, this.hasAttribute("lines"));
|
|
29
|
+
this.classList.toggle("wj-inset", this.hasAttribute("inset"));
|
|
25
30
|
}
|
|
26
31
|
}
|
|
27
|
-
customElements.get("wj-list") || window.customElements.define("wj-list",
|
|
32
|
+
customElements.get("wj-list") || window.customElements.define("wj-list", List);
|
|
28
33
|
export {
|
|
29
|
-
|
|
34
|
+
List
|
|
30
35
|
};
|
package/dist/wj-main.js
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => {
|
|
4
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
return value;
|
|
6
|
+
};
|
|
7
|
+
import WJElement from "./wj-element.js";
|
|
5
8
|
import "./wj-store.js";
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
class l extends m {
|
|
9
|
+
const styles = "/*\n[ WJ Main ]\n*/\n:host {\n display: block;\n flex: 1;\n flex-basis: auto;\n padding: 1.5rem;\n box-sizing: border-box;\n}";
|
|
10
|
+
class Main extends WJElement {
|
|
9
11
|
constructor() {
|
|
10
12
|
super();
|
|
11
|
-
|
|
13
|
+
__publicField(this, "className", "Main");
|
|
12
14
|
}
|
|
13
15
|
static get cssStyleSheet() {
|
|
14
|
-
return
|
|
16
|
+
return styles;
|
|
15
17
|
}
|
|
16
18
|
static get observedAttributes() {
|
|
17
19
|
return [];
|
|
@@ -19,12 +21,14 @@ class l extends m {
|
|
|
19
21
|
setupAttributes() {
|
|
20
22
|
this.isShadowRoot = "open";
|
|
21
23
|
}
|
|
22
|
-
draw(
|
|
23
|
-
let
|
|
24
|
-
|
|
24
|
+
draw(context, store, params) {
|
|
25
|
+
let fragment = document.createDocumentFragment();
|
|
26
|
+
let element = document.createElement("slot");
|
|
27
|
+
fragment.appendChild(element);
|
|
28
|
+
return fragment;
|
|
25
29
|
}
|
|
26
30
|
}
|
|
27
|
-
customElements.get("wj-main") || window.customElements.define("wj-main",
|
|
31
|
+
customElements.get("wj-main") || window.customElements.define("wj-main", Main);
|
|
28
32
|
export {
|
|
29
|
-
|
|
33
|
+
Main
|
|
30
34
|
};
|
package/dist/wj-masonry.js
CHANGED
|
@@ -1,133 +1,190 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => {
|
|
4
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
return value;
|
|
6
|
+
};
|
|
7
|
+
import WJElement from "./wj-element.js";
|
|
5
8
|
import "./wj-store.js";
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
const DEFAULT_MAX_COL_WIDTH = 500;
|
|
10
|
+
const DEFAULT_DEBOUNCE_MS = 300;
|
|
11
|
+
const COL_COUNT_CSS_VAR_NAME = `--wj-masonry-layout-col-count`;
|
|
12
|
+
const GAP_CSS_VAR_NAME = `--wj-masonry-layout-gap`;
|
|
13
|
+
const ELEMENT_NODE_TYPE = 1;
|
|
14
|
+
const DEBOUNCE_MAP = /* @__PURE__ */ new Map();
|
|
15
|
+
function getNumberAttribute($elem, name, defaultValue) {
|
|
16
|
+
const value = parseFloat($elem.getAttribute(name) || "");
|
|
17
|
+
return isNaN(value) ? defaultValue : value;
|
|
10
18
|
}
|
|
11
|
-
function
|
|
12
|
-
return isNaN(
|
|
19
|
+
function getColCount(totalWidth, cols, maxColWidth) {
|
|
20
|
+
return isNaN(cols) ? Math.max(1, Math.ceil(totalWidth / maxColWidth)) : cols;
|
|
13
21
|
}
|
|
14
|
-
function
|
|
15
|
-
const
|
|
16
|
-
|
|
22
|
+
function debounce(cb, ms, id) {
|
|
23
|
+
const existingTimeout = DEBOUNCE_MAP.get(id);
|
|
24
|
+
if (existingTimeout != null)
|
|
25
|
+
window.clearTimeout(existingTimeout);
|
|
26
|
+
DEBOUNCE_MAP.set(id, window.setTimeout(cb, ms));
|
|
17
27
|
}
|
|
18
|
-
function
|
|
19
|
-
let
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
28
|
+
function findSmallestColIndex(colHeights) {
|
|
29
|
+
let smallestIndex = 0;
|
|
30
|
+
let smallestHeight = Infinity;
|
|
31
|
+
colHeights.forEach((height, i) => {
|
|
32
|
+
if (height < smallestHeight) {
|
|
33
|
+
smallestHeight = height;
|
|
34
|
+
smallestIndex = i;
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
return smallestIndex;
|
|
23
38
|
}
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
class N extends w {
|
|
39
|
+
const styles = "/*\n[ WJ Masonry ]\n*/\n:host {\n display: flex;\n align-items: flex-start;\n justify-content: stretch;\n width: 100%;\n}\n\n.column {\n max-width: calc(100% / var(--wj-masonry-layout-col-count, 1) - var(--wj-masonry-layout-gap, 1rem) * (var(--wj-masonry-layout-col-count, 1) - 1) / var(--wj-masonry-layout-col-count, 1));\n width: 100%;\n flex: 1;\n display: flex;\n flex-direction: column;\n}\n\n.column:not(:last-child) {\n margin-inline-end: var(--wj-masonry-layout-gap, 1rem);\n}\n\n.column ::slotted(*) {\n margin-block-end: var(--wj-masonry-layout-gap, 1rem);\n box-sizing: border-box;\n width: 100%;\n}\n\n/* Hide the items that has not yet found the correct slot */\n#unset-items {\n opacity: 0;\n position: absolute;\n pointer-events: none;\n}";
|
|
40
|
+
class Masonry extends WJElement {
|
|
27
41
|
constructor() {
|
|
28
42
|
super();
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
(this.unsetSlot.assignedNodes() || []).filter((
|
|
43
|
+
__publicField(this, "debounceId", `layout_${Math.random()}`);
|
|
44
|
+
__publicField(this, "ro");
|
|
45
|
+
__publicField(this, "className", "Masonry");
|
|
46
|
+
__publicField(this, "onSlotChange", () => {
|
|
47
|
+
const $unsetElements = (this.unsetSlot.assignedNodes() || []).filter((node) => node.nodeType === ELEMENT_NODE_TYPE);
|
|
48
|
+
if ($unsetElements.length > 0) {
|
|
49
|
+
this.layout();
|
|
50
|
+
}
|
|
34
51
|
});
|
|
35
|
-
|
|
36
|
-
const { width
|
|
37
|
-
|
|
52
|
+
__publicField(this, "onResize", (entries) => {
|
|
53
|
+
const { width } = entries != null && Array.isArray(entries) && entries.length > 0 ? entries[0].contentRect : { width: this.offsetWidth };
|
|
54
|
+
const colCount = getColCount(width, this.cols, this.maxColWidth);
|
|
55
|
+
if (colCount !== this.columns.length) {
|
|
56
|
+
this.scheduleLayout();
|
|
57
|
+
}
|
|
38
58
|
});
|
|
39
|
-
|
|
40
|
-
this.currentRequestAnimationFrameCallback != null
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
59
|
+
__publicField(this, "layout", () => {
|
|
60
|
+
if (this.currentRequestAnimationFrameCallback != null) {
|
|
61
|
+
window.cancelAnimationFrame(this.currentRequestAnimationFrameCallback);
|
|
62
|
+
}
|
|
63
|
+
this.currentRequestAnimationFrameCallback = requestAnimationFrame(() => {
|
|
64
|
+
const gap = this.gap;
|
|
65
|
+
const $elements = Array.from(this.children).filter((node) => node.nodeType === ELEMENT_NODE_TYPE);
|
|
66
|
+
const colCount = getColCount(this.offsetWidth, this.cols, this.maxColWidth);
|
|
67
|
+
const colHeights = Array(colCount).fill(0);
|
|
68
|
+
const writes = [];
|
|
69
|
+
for (const elem of $elements) {
|
|
70
|
+
const height = elem.getBoundingClientRect().height;
|
|
71
|
+
let smallestColIndex = findSmallestColIndex(colHeights);
|
|
72
|
+
colHeights[smallestColIndex] += height + +gap;
|
|
73
|
+
const newSlot = smallestColIndex;
|
|
74
|
+
if (elem.slot !== newSlot) {
|
|
75
|
+
writes.push(() => elem.slot = newSlot);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
for (const write of writes) {
|
|
79
|
+
write();
|
|
48
80
|
}
|
|
49
|
-
|
|
50
|
-
a();
|
|
51
|
-
this.renderCols(n);
|
|
81
|
+
this.renderCols(colCount);
|
|
52
82
|
});
|
|
53
83
|
});
|
|
54
|
-
this.debounceId = `layout_${Math.random()}
|
|
84
|
+
this.debounceId = `layout_${Math.random()}`;
|
|
85
|
+
this.ro = void 0;
|
|
86
|
+
this.currentRequestAnimationFrameCallback = void 0;
|
|
87
|
+
this.unsetSlot = void 0;
|
|
55
88
|
}
|
|
56
|
-
set maxColWidth(
|
|
57
|
-
this.setAttribute("max-col-width",
|
|
89
|
+
set maxColWidth(value) {
|
|
90
|
+
this.setAttribute("max-col-width", value);
|
|
58
91
|
}
|
|
59
92
|
get maxColWidth() {
|
|
60
|
-
return this.hasAttribute("max-col-width") ? +this.getAttribute("max-col-width") : +
|
|
93
|
+
return this.hasAttribute("max-col-width") ? +this.getAttribute("max-col-width") : +DEFAULT_MAX_COL_WIDTH;
|
|
61
94
|
}
|
|
62
|
-
set cols(
|
|
63
|
-
this.hasAttribute("cols")
|
|
95
|
+
set cols(value) {
|
|
96
|
+
this.hasAttribute("cols") ? this.setAttribute("cols", value) : "auto";
|
|
64
97
|
}
|
|
65
98
|
get cols() {
|
|
66
|
-
return
|
|
99
|
+
return getNumberAttribute(this, "cols", "auto");
|
|
67
100
|
}
|
|
68
|
-
set gap(
|
|
69
|
-
this.setAttribute("gap",
|
|
101
|
+
set gap(value) {
|
|
102
|
+
this.setAttribute("gap", value);
|
|
70
103
|
}
|
|
71
104
|
get gap() {
|
|
72
|
-
return
|
|
105
|
+
return getNumberAttribute(this, "gap", "24");
|
|
73
106
|
}
|
|
74
|
-
set debounce(
|
|
75
|
-
this.setAttribute("debounce",
|
|
107
|
+
set debounce(value) {
|
|
108
|
+
this.setAttribute("debounce", value);
|
|
76
109
|
}
|
|
77
110
|
get debounce() {
|
|
78
|
-
return
|
|
111
|
+
return getNumberAttribute(this, "debounce", DEFAULT_DEBOUNCE_MS);
|
|
79
112
|
}
|
|
80
113
|
get columns() {
|
|
81
|
-
return Array.from(this.shadowRoot.querySelectorAll(
|
|
114
|
+
return Array.from(this.shadowRoot.querySelectorAll(`.column`));
|
|
82
115
|
}
|
|
83
116
|
static get cssStyleSheet() {
|
|
84
|
-
return
|
|
117
|
+
return styles;
|
|
85
118
|
}
|
|
86
119
|
static get observedAttributes() {
|
|
87
120
|
return ["max-col-width", "gap", "cols"];
|
|
88
121
|
}
|
|
89
|
-
attributeChangedCallback(
|
|
90
|
-
switch (
|
|
122
|
+
attributeChangedCallback(name, old, newName) {
|
|
123
|
+
switch (name) {
|
|
91
124
|
case "gap":
|
|
92
|
-
this.style.setProperty(
|
|
125
|
+
this.style.setProperty(GAP_CSS_VAR_NAME, `${this.gap}px`);
|
|
93
126
|
break;
|
|
94
127
|
}
|
|
95
128
|
this.scheduleLayout();
|
|
96
129
|
}
|
|
97
130
|
disconnectedCallback() {
|
|
98
|
-
this.unsetSlot.removeEventListener("slotchange", this.onSlotChange)
|
|
131
|
+
this.unsetSlot.removeEventListener("slotchange", this.onSlotChange);
|
|
132
|
+
window.removeEventListener("resize", this.onResize);
|
|
133
|
+
if (this.ro != null) {
|
|
134
|
+
this.ro.unobserve(this);
|
|
135
|
+
}
|
|
99
136
|
}
|
|
100
137
|
setupAttributes() {
|
|
101
138
|
this.isShadowRoot = "open";
|
|
102
139
|
}
|
|
103
|
-
draw(
|
|
104
|
-
let
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
140
|
+
draw(context, store, params) {
|
|
141
|
+
let fragment = document.createDocumentFragment();
|
|
142
|
+
let native = document.createElement("div");
|
|
143
|
+
native.setAttribute("id", "unset-items");
|
|
144
|
+
native.setAttribute("part", "native");
|
|
145
|
+
let unsetSlot = document.createElement("slot");
|
|
146
|
+
native.appendChild(unsetSlot);
|
|
147
|
+
this.unsetSlot = unsetSlot;
|
|
148
|
+
this.native = native;
|
|
149
|
+
fragment.appendChild(native);
|
|
150
|
+
return fragment;
|
|
108
151
|
}
|
|
109
152
|
afterDraw() {
|
|
110
|
-
this.onSlotChange()
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
if (
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
153
|
+
this.onSlotChange();
|
|
154
|
+
this.onResize();
|
|
155
|
+
this.layout();
|
|
156
|
+
this.unsetSlot.addEventListener("slotchange", this.onSlotChange);
|
|
157
|
+
if ("ResizeObserver" in window) {
|
|
158
|
+
this.ro = new ResizeObserver(this.onResize);
|
|
159
|
+
this.ro.observe(this);
|
|
160
|
+
} else {
|
|
161
|
+
window.addEventListener("resize", this.onResize);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
renderCols(colCount) {
|
|
165
|
+
const columns = this.columns;
|
|
166
|
+
if (columns.length === colCount) {
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
for (const column of columns) {
|
|
170
|
+
column.parentNode && column.parentNode.removeChild(column);
|
|
171
|
+
}
|
|
172
|
+
for (let i = 0; i < colCount; i++) {
|
|
173
|
+
const column = document.createElement("div");
|
|
174
|
+
column.classList.add("column");
|
|
175
|
+
column.setAttribute("part", `column column-${i}`);
|
|
176
|
+
const slot = document.createElement("slot");
|
|
177
|
+
slot.setAttribute("name", i);
|
|
178
|
+
column.appendChild(slot);
|
|
179
|
+
this.context.appendChild(column);
|
|
124
180
|
}
|
|
181
|
+
this.style.setProperty(COL_COUNT_CSS_VAR_NAME, colCount);
|
|
125
182
|
}
|
|
126
|
-
scheduleLayout(
|
|
127
|
-
|
|
183
|
+
scheduleLayout(ms = this.debounce) {
|
|
184
|
+
debounce(this.layout, ms, this.debounceId);
|
|
128
185
|
}
|
|
129
186
|
}
|
|
130
|
-
customElements.get("wj-masonry") || window.customElements.define("wj-masonry",
|
|
187
|
+
customElements.get("wj-masonry") || window.customElements.define("wj-masonry", Masonry);
|
|
131
188
|
export {
|
|
132
|
-
|
|
189
|
+
Masonry
|
|
133
190
|
};
|