@m3e/web 2.2.1 → 2.3.0
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 +2 -0
- package/dist/all.js +782 -5
- package/dist/all.js.map +1 -1
- package/dist/all.min.js +45 -45
- package/dist/all.min.js.map +1 -1
- package/dist/calendar.js +4 -2
- package/dist/calendar.js.map +1 -1
- package/dist/calendar.min.js +3 -3
- package/dist/calendar.min.js.map +1 -1
- package/dist/core.js +22 -1
- package/dist/core.js.map +1 -1
- package/dist/core.min.js +1 -1
- package/dist/core.min.js.map +1 -1
- package/dist/css-custom-data.json +733 -603
- package/dist/custom-elements.json +8398 -7000
- package/dist/datepicker.js +3 -1
- package/dist/datepicker.js.map +1 -1
- package/dist/datepicker.min.js +1 -1
- package/dist/datepicker.min.js.map +1 -1
- package/dist/html-custom-data.json +293 -205
- package/dist/skeleton.js +153 -0
- package/dist/skeleton.js.map +1 -0
- package/dist/skeleton.min.js +7 -0
- package/dist/skeleton.min.js.map +1 -0
- package/dist/split-pane.js +627 -0
- package/dist/split-pane.js.map +1 -0
- package/dist/split-pane.min.js +7 -0
- package/dist/split-pane.min.js.map +1 -0
- package/dist/src/all.d.ts +2 -0
- package/dist/src/all.d.ts.map +1 -1
- package/dist/src/calendar/CalendarElement.d.ts +2 -0
- package/dist/src/calendar/CalendarElement.d.ts.map +1 -1
- package/dist/src/calendar/CalendarViewElementBase.d.ts.map +1 -1
- package/dist/src/calendar/MonthViewElement.d.ts.map +1 -1
- package/dist/src/core/shared/utils/index.d.ts +1 -0
- package/dist/src/core/shared/utils/index.d.ts.map +1 -1
- package/dist/src/core/shared/utils/waitForUpgrade.d.ts +6 -0
- package/dist/src/core/shared/utils/waitForUpgrade.d.ts.map +1 -0
- package/dist/src/datepicker/DatepickerElement.d.ts +2 -0
- package/dist/src/datepicker/DatepickerElement.d.ts.map +1 -1
- package/dist/src/skeleton/SkeletonAnimation.d.ts +3 -0
- package/dist/src/skeleton/SkeletonAnimation.d.ts.map +1 -0
- package/dist/src/skeleton/SkeletonElement.d.ts +73 -0
- package/dist/src/skeleton/SkeletonElement.d.ts.map +1 -0
- package/dist/src/skeleton/SkeletonShape.d.ts +3 -0
- package/dist/src/skeleton/SkeletonShape.d.ts.map +1 -0
- package/dist/src/skeleton/index.d.ts +4 -0
- package/dist/src/skeleton/index.d.ts.map +1 -0
- package/dist/src/split-pane/SplitPaneElement.d.ts +163 -0
- package/dist/src/split-pane/SplitPaneElement.d.ts.map +1 -0
- package/dist/src/split-pane/SplitPaneOrientation.d.ts +3 -0
- package/dist/src/split-pane/SplitPaneOrientation.d.ts.map +1 -0
- package/dist/src/split-pane/index.d.ts +3 -0
- package/dist/src/split-pane/index.d.ts.map +1 -0
- package/package.json +11 -1
package/dist/skeleton.js
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license MIT
|
|
3
|
+
* Copyright (c) 2025 matraic
|
|
4
|
+
* See LICENSE file in the project root for full license text.
|
|
5
|
+
*/
|
|
6
|
+
import { __classPrivateFieldGet, __decorate } from 'tslib';
|
|
7
|
+
import { LitElement, html, unsafeCSS, css } from 'lit';
|
|
8
|
+
import { property } from 'lit/decorators.js';
|
|
9
|
+
import { ReconnectedCallback, waitForUpgrade, DesignToken, customElement } from '@m3e/web/core';
|
|
10
|
+
import { positionAnchor } from '@m3e/web/core/anchoring';
|
|
11
|
+
|
|
12
|
+
var _M3eSkeletonElement_instances, _M3eSkeletonElement_anchoringCleanupMap, _M3eSkeletonElement_handleSlotChange, _M3eSkeletonElement_clearShapes, _M3eSkeletonElement_createShapes, _M3eSkeletonElement_createShape;
|
|
13
|
+
/**
|
|
14
|
+
* A visual placeholder that mimics the layout of content while it's still loading.
|
|
15
|
+
* @description
|
|
16
|
+
* The `m3e-skeleton` component provides a loading placeholder surface with flexible shape variants and
|
|
17
|
+
* motion-based animations that communicate loading state while preserving layout stability. It mimics
|
|
18
|
+
* the layout of content while it's still loading, ensuring a smooth user experience during data fetching
|
|
19
|
+
* or rendering delays. The component supports different animation effects (`pulse`, `wave`, `none`) and
|
|
20
|
+
* shape variants (`circular`, `rounded`, `square`, `auto`) to adapt to various content types. When the
|
|
21
|
+
* content is loaded, the skeleton fades out with a smooth transition.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* The following example illustrates a skeleton shaped and sized by the slotted `m3e-card`.
|
|
25
|
+
* ```html
|
|
26
|
+
* <m3e-skeleton>
|
|
27
|
+
* <m3e-card></m3e-card>
|
|
28
|
+
* </m3e-skeleton>
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @tag m3e-skeleton
|
|
32
|
+
*
|
|
33
|
+
* @attr animation - The animation effect of the skeleton.
|
|
34
|
+
* @attr shape - The shape of the skeleton.
|
|
35
|
+
* @attr loaded - Whether the content of the skeleton has been loaded.
|
|
36
|
+
*
|
|
37
|
+
* @slot - Renders the content to be mimicked by the skeleton.
|
|
38
|
+
*
|
|
39
|
+
* @cssprop --m3e-skeleton-color - Base fill color for the skeleton surface.
|
|
40
|
+
* @cssprop --m3e-skeleton-tint-color - Tint fill color for the skeleton surface.
|
|
41
|
+
* @cssprop --m3e-skeleton-tint-opacity - Tint Opacity applied when the skeleton animation is not pulsating.
|
|
42
|
+
* @cssprop --m3e-skeleton-accent-color - Accent color used in wave animation.
|
|
43
|
+
* @cssprop --m3e-skeleton-accent-opacity - Opacity of the accent effect in animations.
|
|
44
|
+
* @cssprop --m3e-skeleton-rounded-shape - Corner radius for the rounded skeleton shape.
|
|
45
|
+
* @cssprop --m3e-skeleton-circular-shape - Corner radius for the circular skeleton shape.
|
|
46
|
+
* @cssprop --m3e-skeleton-square-shape - Corner radius for the square skeleton shape.
|
|
47
|
+
* @cssprop --m3e-skeleton-shape - Corner radius for the skeleton shape.
|
|
48
|
+
*/
|
|
49
|
+
let M3eSkeletonElement = class M3eSkeletonElement extends ReconnectedCallback(LitElement) {
|
|
50
|
+
constructor() {
|
|
51
|
+
super(...arguments);
|
|
52
|
+
_M3eSkeletonElement_instances.add(this);
|
|
53
|
+
/** @private */
|
|
54
|
+
_M3eSkeletonElement_anchoringCleanupMap.set(this, new Map());
|
|
55
|
+
/**
|
|
56
|
+
* The shape of the skeleton.
|
|
57
|
+
* @default "auto"
|
|
58
|
+
*/
|
|
59
|
+
this.shape = "auto";
|
|
60
|
+
/**
|
|
61
|
+
* The animation effect of the skeleton.
|
|
62
|
+
* @default "wave"
|
|
63
|
+
*/
|
|
64
|
+
this.animation = "wave";
|
|
65
|
+
/**
|
|
66
|
+
* Whether the content of the skeleton has been loaded.
|
|
67
|
+
* @default false
|
|
68
|
+
*/
|
|
69
|
+
this.loaded = false;
|
|
70
|
+
}
|
|
71
|
+
/** @inheritdoc */
|
|
72
|
+
disconnectedCallback() {
|
|
73
|
+
super.disconnectedCallback();
|
|
74
|
+
__classPrivateFieldGet(this, _M3eSkeletonElement_instances, "m", _M3eSkeletonElement_clearShapes).call(this);
|
|
75
|
+
}
|
|
76
|
+
/** @inheritdoc */
|
|
77
|
+
reconnectedCallback() {
|
|
78
|
+
super.reconnectedCallback();
|
|
79
|
+
__classPrivateFieldGet(this, _M3eSkeletonElement_instances, "m", _M3eSkeletonElement_createShapes).call(this);
|
|
80
|
+
}
|
|
81
|
+
/** @inheritdoc */
|
|
82
|
+
render() {
|
|
83
|
+
return html`<slot ?inert="${!this.loaded}" @slotchange="${__classPrivateFieldGet(this, _M3eSkeletonElement_instances, "m", _M3eSkeletonElement_handleSlotChange)}"></slot>`;
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
_M3eSkeletonElement_anchoringCleanupMap = new WeakMap();
|
|
87
|
+
_M3eSkeletonElement_instances = new WeakSet();
|
|
88
|
+
_M3eSkeletonElement_handleSlotChange = /** @private */
|
|
89
|
+
async function _M3eSkeletonElement_handleSlotChange() {
|
|
90
|
+
__classPrivateFieldGet(this, _M3eSkeletonElement_instances, "m", _M3eSkeletonElement_createShapes).call(this);
|
|
91
|
+
};
|
|
92
|
+
_M3eSkeletonElement_clearShapes = function _M3eSkeletonElement_clearShapes() {
|
|
93
|
+
for (const item of __classPrivateFieldGet(this, _M3eSkeletonElement_anchoringCleanupMap, "f")) {
|
|
94
|
+
item[0].remove();
|
|
95
|
+
item[1]();
|
|
96
|
+
}
|
|
97
|
+
__classPrivateFieldGet(this, _M3eSkeletonElement_anchoringCleanupMap, "f").clear();
|
|
98
|
+
};
|
|
99
|
+
_M3eSkeletonElement_createShapes = /** @private */
|
|
100
|
+
async function _M3eSkeletonElement_createShapes() {
|
|
101
|
+
__classPrivateFieldGet(this, _M3eSkeletonElement_instances, "m", _M3eSkeletonElement_clearShapes).call(this);
|
|
102
|
+
const slot = this.shadowRoot?.querySelector("slot");
|
|
103
|
+
if (!slot) return;
|
|
104
|
+
for (const element of slot.assignedElements({
|
|
105
|
+
flatten: true
|
|
106
|
+
}).filter(x => x instanceof HTMLElement)) {
|
|
107
|
+
await __classPrivateFieldGet(this, _M3eSkeletonElement_instances, "m", _M3eSkeletonElement_createShape).call(this, element);
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
_M3eSkeletonElement_createShape = /** @private */
|
|
111
|
+
async function _M3eSkeletonElement_createShape(element) {
|
|
112
|
+
await waitForUpgrade(element);
|
|
113
|
+
const shape = document.createElement("div");
|
|
114
|
+
shape.classList.add("shape");
|
|
115
|
+
if (this.shape === "auto") {
|
|
116
|
+
let borderRadius = getComputedStyle(element).borderRadius;
|
|
117
|
+
if (!borderRadius || borderRadius === "0px") {
|
|
118
|
+
const firstElement = element.shadowRoot?.firstElementChild;
|
|
119
|
+
if (firstElement && !firstElement.nextElementSibling) {
|
|
120
|
+
borderRadius = getComputedStyle(firstElement).borderRadius;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
if (borderRadius && borderRadius !== "0px") {
|
|
124
|
+
shape.style.borderRadius = borderRadius;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
const anchoringCleanup = await positionAnchor(shape, element, {
|
|
128
|
+
position: "bottom"
|
|
129
|
+
}, (x, y) => {
|
|
130
|
+
shape.style.left = `${x}px`;
|
|
131
|
+
shape.style.top = `${y - element.clientHeight}px`;
|
|
132
|
+
shape.style.width = `${element.clientWidth}px`;
|
|
133
|
+
shape.style.height = `${element.clientHeight}px`;
|
|
134
|
+
});
|
|
135
|
+
__classPrivateFieldGet(this, _M3eSkeletonElement_anchoringCleanupMap, "f").set(shape, anchoringCleanup);
|
|
136
|
+
this.shadowRoot?.appendChild(shape);
|
|
137
|
+
};
|
|
138
|
+
/** The styles of the element. */
|
|
139
|
+
M3eSkeletonElement.styles = css`:host { display: contents; } .shape { position: absolute; overflow: hidden; pointer-events: none; opacity: 1; background-color: var(--m3e-skeleton-color, ${DesignToken.color.surface}); } .shape::before { content: ""; position: absolute; left: 0; top: 0; width: 100%; height: 100%; background-color: color-mix( in srgb, var(--m3e-skeleton-tint-color, ${DesignToken.color.onSurface}) var(--m3e-skeleton-tint-opacity, 8%), transparent ); } :host(:not([loaded])) slot { visibility: hidden; } :host([loaded]) .shape { opacity: 0; transition: ${unsafeCSS(`opacity ${DesignToken.motion.duration.short3} ${DesignToken.motion.easing.standard}`)}; } :host([shape="rounded"]) .shape { border-radius: var(--m3e-skeleton-rounded-shape, var(--m3e-skeleton-shape, ${DesignToken.shape.corner.large})); } :host([shape="circular"]) .shape { border-radius: var(--m3e-skeleton-circular-shape, var(--m3e-skeleton-shape, ${DesignToken.shape.corner.full})); } :host([shape="square"]) .shape { border-radius: var(--m3e-skeleton-square-shape, var(--m3e-skeleton-shape, 0px)); } :host([animation="pulse"]:not([loaded])) .shape::after { content: ""; position: absolute; top: 0; left: 0; width: 100%; height: 100%; animation: pulse 1.2s ease-in-out infinite; background-color: var(--m3e-skeleton-tint-color, ${DesignToken.color.surfaceDim}); } :host([animation="wave"]:not([loaded])) .shape::after { content: ""; position: absolute; top: 0; left: -150%; height: 100%; width: 150%; opacity: var(--m3e-skeleton-accent-opacity, 6%); background: linear-gradient( 90deg, transparent, var(--m3e-skeleton-accent-color, ${DesignToken.color.onSurface}), transparent ); animation: wave 2.1s linear infinite; } @keyframes pulse { 0% { opacity: 1; } 50% { opacity: var(--m3e-skeleton-accent-opacity, 6%); } 100% { opacity: 1; } } @keyframes wave { 0% { left: -150%; } 100% { left: 100%; } } @media (forced-colors: active) { :host([loaded]) .shape { transition: none; } .shape::after { display: none; } .shape { background-color: GrayText; } } @media (prefers-reduced-motion) { :host([loaded]) .shape { transition: none; } .shape::after { display: none; } }`;
|
|
140
|
+
__decorate([property({
|
|
141
|
+
reflect: true
|
|
142
|
+
})], M3eSkeletonElement.prototype, "shape", void 0);
|
|
143
|
+
__decorate([property({
|
|
144
|
+
reflect: true
|
|
145
|
+
})], M3eSkeletonElement.prototype, "animation", void 0);
|
|
146
|
+
__decorate([property({
|
|
147
|
+
type: Boolean,
|
|
148
|
+
reflect: true
|
|
149
|
+
})], M3eSkeletonElement.prototype, "loaded", void 0);
|
|
150
|
+
M3eSkeletonElement = __decorate([customElement("m3e-skeleton")], M3eSkeletonElement);
|
|
151
|
+
|
|
152
|
+
export { M3eSkeletonElement };
|
|
153
|
+
//# sourceMappingURL=skeleton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skeleton.js","sources":["../../src/skeleton/SkeletonElement.ts"],"sourcesContent":["import { css, CSSResultGroup, html, LitElement, unsafeCSS } from \"lit\";\r\nimport { property } from \"lit/decorators.js\";\r\n\r\nimport { customElement, DesignToken, ReconnectedCallback, waitForUpgrade } from \"@m3e/web/core\";\r\nimport { positionAnchor } from \"@m3e/web/core/anchoring\";\r\n\r\nimport { SkeletonShape } from \"./SkeletonShape\";\r\nimport { SkeletonAnimation } from \"./SkeletonAnimation\";\r\n\r\n/**\r\n * A visual placeholder that mimics the layout of content while it's still loading.\r\n * @description\r\n * The `m3e-skeleton` component provides a loading placeholder surface with flexible shape variants and\r\n * motion-based animations that communicate loading state while preserving layout stability. It mimics\r\n * the layout of content while it's still loading, ensuring a smooth user experience during data fetching\r\n * or rendering delays. The component supports different animation effects (`pulse`, `wave`, `none`) and\r\n * shape variants (`circular`, `rounded`, `square`, `auto`) to adapt to various content types. When the\r\n * content is loaded, the skeleton fades out with a smooth transition.\r\n *\r\n * @example\r\n * The following example illustrates a skeleton shaped and sized by the slotted `m3e-card`.\r\n * ```html\r\n * <m3e-skeleton>\r\n * <m3e-card></m3e-card>\r\n * </m3e-skeleton>\r\n * ```\r\n *\r\n * @tag m3e-skeleton\r\n *\r\n * @attr animation - The animation effect of the skeleton.\r\n * @attr shape - The shape of the skeleton.\r\n * @attr loaded - Whether the content of the skeleton has been loaded.\r\n *\r\n * @slot - Renders the content to be mimicked by the skeleton.\r\n *\r\n * @cssprop --m3e-skeleton-color - Base fill color for the skeleton surface.\r\n * @cssprop --m3e-skeleton-tint-color - Tint fill color for the skeleton surface.\r\n * @cssprop --m3e-skeleton-tint-opacity - Tint Opacity applied when the skeleton animation is not pulsating.\r\n * @cssprop --m3e-skeleton-accent-color - Accent color used in wave animation.\r\n * @cssprop --m3e-skeleton-accent-opacity - Opacity of the accent effect in animations.\r\n * @cssprop --m3e-skeleton-rounded-shape - Corner radius for the rounded skeleton shape.\r\n * @cssprop --m3e-skeleton-circular-shape - Corner radius for the circular skeleton shape.\r\n * @cssprop --m3e-skeleton-square-shape - Corner radius for the square skeleton shape.\r\n * @cssprop --m3e-skeleton-shape - Corner radius for the skeleton shape.\r\n */\r\n@customElement(\"m3e-skeleton\")\r\nexport class M3eSkeletonElement extends ReconnectedCallback(LitElement) {\r\n /** The styles of the element. */\r\n static override styles: CSSResultGroup = css`\r\n :host {\r\n display: contents;\r\n }\r\n .shape {\r\n position: absolute;\r\n overflow: hidden;\r\n pointer-events: none;\r\n opacity: 1;\r\n background-color: var(--m3e-skeleton-color, ${DesignToken.color.surface});\r\n }\r\n .shape::before {\r\n content: \"\";\r\n position: absolute;\r\n left: 0;\r\n top: 0;\r\n width: 100%;\r\n height: 100%;\r\n background-color: color-mix(\r\n in srgb,\r\n var(--m3e-skeleton-tint-color, ${DesignToken.color.onSurface}) var(--m3e-skeleton-tint-opacity, 8%),\r\n transparent\r\n );\r\n }\r\n :host(:not([loaded])) slot {\r\n visibility: hidden;\r\n }\r\n :host([loaded]) .shape {\r\n opacity: 0;\r\n transition: ${unsafeCSS(`opacity ${DesignToken.motion.duration.short3} ${DesignToken.motion.easing.standard}`)};\r\n }\r\n :host([shape=\"rounded\"]) .shape {\r\n border-radius: var(--m3e-skeleton-rounded-shape, var(--m3e-skeleton-shape, ${DesignToken.shape.corner.large}));\r\n }\r\n :host([shape=\"circular\"]) .shape {\r\n border-radius: var(--m3e-skeleton-circular-shape, var(--m3e-skeleton-shape, ${DesignToken.shape.corner.full}));\r\n }\r\n :host([shape=\"square\"]) .shape {\r\n border-radius: var(--m3e-skeleton-square-shape, var(--m3e-skeleton-shape, 0px));\r\n }\r\n :host([animation=\"pulse\"]:not([loaded])) .shape::after {\r\n content: \"\";\r\n position: absolute;\r\n top: 0;\r\n left: 0;\r\n width: 100%;\r\n height: 100%;\r\n animation: pulse 1.2s ease-in-out infinite;\r\n background-color: var(--m3e-skeleton-tint-color, ${DesignToken.color.surfaceDim});\r\n }\r\n :host([animation=\"wave\"]:not([loaded])) .shape::after {\r\n content: \"\";\r\n position: absolute;\r\n top: 0;\r\n left: -150%;\r\n height: 100%;\r\n width: 150%;\r\n opacity: var(--m3e-skeleton-accent-opacity, 6%);\r\n background: linear-gradient(\r\n 90deg,\r\n transparent,\r\n var(--m3e-skeleton-accent-color, ${DesignToken.color.onSurface}),\r\n transparent\r\n );\r\n animation: wave 2.1s linear infinite;\r\n }\r\n @keyframes pulse {\r\n 0% {\r\n opacity: 1;\r\n }\r\n 50% {\r\n opacity: var(--m3e-skeleton-accent-opacity, 6%);\r\n }\r\n 100% {\r\n opacity: 1;\r\n }\r\n }\r\n @keyframes wave {\r\n 0% {\r\n left: -150%;\r\n }\r\n 100% {\r\n left: 100%;\r\n }\r\n }\r\n @media (forced-colors: active) {\r\n :host([loaded]) .shape {\r\n transition: none;\r\n }\r\n .shape::after {\r\n display: none;\r\n }\r\n .shape {\r\n background-color: GrayText;\r\n }\r\n }\r\n @media (prefers-reduced-motion) {\r\n :host([loaded]) .shape {\r\n transition: none;\r\n }\r\n .shape::after {\r\n display: none;\r\n }\r\n }\r\n `;\r\n\r\n /** @private */ readonly #anchoringCleanupMap = new Map<HTMLElement, () => void>();\r\n\r\n /**\r\n * The shape of the skeleton.\r\n * @default \"auto\"\r\n */\r\n @property({ reflect: true }) shape: SkeletonShape = \"auto\";\r\n\r\n /**\r\n * The animation effect of the skeleton.\r\n * @default \"wave\"\r\n */\r\n @property({ reflect: true }) animation: SkeletonAnimation = \"wave\";\r\n\r\n /**\r\n * Whether the content of the skeleton has been loaded.\r\n * @default false\r\n */\r\n @property({ type: Boolean, reflect: true }) loaded = false;\r\n\r\n /** @inheritdoc */\r\n override disconnectedCallback(): void {\r\n super.disconnectedCallback();\r\n this.#clearShapes();\r\n }\r\n\r\n /** @inheritdoc */\r\n override reconnectedCallback(): void {\r\n super.reconnectedCallback();\r\n this.#createShapes();\r\n }\r\n\r\n /** @inheritdoc */\r\n protected override render(): unknown {\r\n return html`<slot ?inert=\"${!this.loaded}\" @slotchange=\"${this.#handleSlotChange}\"></slot>`;\r\n }\r\n\r\n /** @private */\r\n async #handleSlotChange(): Promise<void> {\r\n this.#createShapes();\r\n }\r\n\r\n /** @private */\r\n #clearShapes(): void {\r\n for (const item of this.#anchoringCleanupMap) {\r\n item[0].remove();\r\n item[1]();\r\n }\r\n this.#anchoringCleanupMap.clear();\r\n }\r\n\r\n /** @private */\r\n async #createShapes(): Promise<void> {\r\n this.#clearShapes();\r\n\r\n const slot = this.shadowRoot?.querySelector(\"slot\");\r\n if (!slot) return;\r\n\r\n for (const element of slot.assignedElements({ flatten: true }).filter((x) => x instanceof HTMLElement)) {\r\n await this.#createShape(element);\r\n }\r\n }\r\n\r\n /** @private */\r\n async #createShape(element: HTMLElement): Promise<void> {\r\n await waitForUpgrade(element);\r\n\r\n const shape = document.createElement(\"div\");\r\n shape.classList.add(\"shape\");\r\n\r\n if (this.shape === \"auto\") {\r\n let borderRadius = getComputedStyle(element).borderRadius;\r\n if (!borderRadius || borderRadius === \"0px\") {\r\n const firstElement = element.shadowRoot?.firstElementChild;\r\n if (firstElement && !firstElement.nextElementSibling) {\r\n borderRadius = getComputedStyle(firstElement).borderRadius;\r\n }\r\n }\r\n\r\n if (borderRadius && borderRadius !== \"0px\") {\r\n shape.style.borderRadius = borderRadius;\r\n }\r\n }\r\n\r\n const anchoringCleanup = await positionAnchor(\r\n shape,\r\n element,\r\n {\r\n position: \"bottom\",\r\n },\r\n (x, y) => {\r\n shape.style.left = `${x}px`;\r\n shape.style.top = `${y - element.clientHeight}px`;\r\n shape.style.width = `${element.clientWidth}px`;\r\n shape.style.height = `${element.clientHeight}px`;\r\n },\r\n );\r\n\r\n this.#anchoringCleanupMap.set(shape, anchoringCleanup);\r\n this.shadowRoot?.appendChild(shape);\r\n }\r\n}\r\n\r\ndeclare global {\r\n interface HTMLElementTagNameMap {\r\n \"m3e-skeleton\": M3eSkeletonElement;\r\n }\r\n}\r\n"],"names":["M3eSkeletonElement","ReconnectedCallback","LitElement","constructor","_M3eSkeletonElement_anchoringCleanupMap","set","Map","shape","animation","loaded","disconnectedCallback","__classPrivateFieldGet","_M3eSkeletonElement_instances","_M3eSkeletonElement_clearShapes","call","reconnectedCallback","_M3eSkeletonElement_createShapes","render","html","_M3eSkeletonElement_handleSlotChange","item","remove","clear","slot","shadowRoot","querySelector","element","assignedElements","flatten","filter","x","HTMLElement","_M3eSkeletonElement_createShape","waitForUpgrade","document","createElement","classList","add","borderRadius","getComputedStyle","firstElement","firstElementChild","nextElementSibling","style","anchoringCleanup","positionAnchor","position","y","left","top","clientHeight","width","clientWidth","height","appendChild","styles","css","DesignToken","color","surface","onSurface","unsafeCSS","motion","duration","short3","easing","standard","corner","large","full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E file in the project root for full license text.
|
|
5
|
+
*/
|
|
6
|
+
import{__classPrivateFieldGet as e,__decorate as t}from"tslib";import{LitElement as o,html as a,unsafeCSS as s,css as n}from"lit";import{property as i}from"lit/decorators.js";import{ReconnectedCallback as r,waitForUpgrade as l,DesignToken as c,customElement as d}from"@m3e/web/core";import{positionAnchor as p}from"@m3e/web/core/anchoring";var h,m,f,u,y,b;let k=class extends(r(o)){constructor(){super(...arguments),h.add(this),m.set(this,new Map),this.shape="auto",this.animation="wave",this.loaded=!1}disconnectedCallback(){super.disconnectedCallback(),e(this,h,"m",u).call(this)}reconnectedCallback(){super.reconnectedCallback(),e(this,h,"m",y).call(this)}render(){return a`<slot ?inert="${!this.loaded}" @slotchange="${e(this,h,"m",f)}"></slot>`}};m=new WeakMap,h=new WeakSet,f=async function(){e(this,h,"m",y).call(this)},u=function(){for(const t of e(this,m,"f"))t[0].remove(),t[1]();e(this,m,"f").clear()},y=async function(){e(this,h,"m",u).call(this);const t=this.shadowRoot?.querySelector("slot");if(t)for(const o of t.assignedElements({flatten:!0}).filter(e=>e instanceof HTMLElement))await e(this,h,"m",b).call(this,o)},b=async function(t){await l(t);const o=document.createElement("div");if(o.classList.add("shape"),"auto"===this.shape){let e=getComputedStyle(t).borderRadius;if(!e||"0px"===e){const o=t.shadowRoot?.firstElementChild;o&&!o.nextElementSibling&&(e=getComputedStyle(o).borderRadius)}e&&"0px"!==e&&(o.style.borderRadius=e)}const a=await p(o,t,{position:"bottom"},(e,a)=>{o.style.left=`${e}px`,o.style.top=a-t.clientHeight+"px",o.style.width=`${t.clientWidth}px`,o.style.height=`${t.clientHeight}px`});e(this,m,"f").set(o,a),this.shadowRoot?.appendChild(o)},k.styles=n`:host { display: contents; } .shape { position: absolute; overflow: hidden; pointer-events: none; opacity: 1; background-color: var(--m3e-skeleton-color, ${c.color.surface}); } .shape::before { content: ""; position: absolute; left: 0; top: 0; width: 100%; height: 100%; background-color: color-mix( in srgb, var(--m3e-skeleton-tint-color, ${c.color.onSurface}) var(--m3e-skeleton-tint-opacity, 8%), transparent ); } :host(:not([loaded])) slot { visibility: hidden; } :host([loaded]) .shape { opacity: 0; transition: ${s(`opacity ${c.motion.duration.short3} ${c.motion.easing.standard}`)}; } :host([shape="rounded"]) .shape { border-radius: var(--m3e-skeleton-rounded-shape, var(--m3e-skeleton-shape, ${c.shape.corner.large})); } :host([shape="circular"]) .shape { border-radius: var(--m3e-skeleton-circular-shape, var(--m3e-skeleton-shape, ${c.shape.corner.full})); } :host([shape="square"]) .shape { border-radius: var(--m3e-skeleton-square-shape, var(--m3e-skeleton-shape, 0px)); } :host([animation="pulse"]:not([loaded])) .shape::after { content: ""; position: absolute; top: 0; left: 0; width: 100%; height: 100%; animation: pulse 1.2s ease-in-out infinite; background-color: var(--m3e-skeleton-tint-color, ${c.color.surfaceDim}); } :host([animation="wave"]:not([loaded])) .shape::after { content: ""; position: absolute; top: 0; left: -150%; height: 100%; width: 150%; opacity: var(--m3e-skeleton-accent-opacity, 6%); background: linear-gradient( 90deg, transparent, var(--m3e-skeleton-accent-color, ${c.color.onSurface}), transparent ); animation: wave 2.1s linear infinite; } @keyframes pulse { 0% { opacity: 1; } 50% { opacity: var(--m3e-skeleton-accent-opacity, 6%); } 100% { opacity: 1; } } @keyframes wave { 0% { left: -150%; } 100% { left: 100%; } } @media (forced-colors: active) { :host([loaded]) .shape { transition: none; } .shape::after { display: none; } .shape { background-color: GrayText; } } @media (prefers-reduced-motion) { :host([loaded]) .shape { transition: none; } .shape::after { display: none; } }`,t([i({reflect:!0})],k.prototype,"shape",void 0),t([i({reflect:!0})],k.prototype,"animation",void 0),t([i({type:Boolean,reflect:!0})],k.prototype,"loaded",void 0),k=t([d("m3e-skeleton")],k);export{k as M3eSkeletonElement};
|
|
7
|
+
//# sourceMappingURL=skeleton.min.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skeleton.min.js","sources":["../../src/skeleton/SkeletonElement.ts"],"sourcesContent":["import { css, CSSResultGroup, html, LitElement, unsafeCSS } from \"lit\";\r\nimport { property } from \"lit/decorators.js\";\r\n\r\nimport { customElement, DesignToken, ReconnectedCallback, waitForUpgrade } from \"@m3e/web/core\";\r\nimport { positionAnchor } from \"@m3e/web/core/anchoring\";\r\n\r\nimport { SkeletonShape } from \"./SkeletonShape\";\r\nimport { SkeletonAnimation } from \"./SkeletonAnimation\";\r\n\r\n/**\r\n * A visual placeholder that mimics the layout of content while it's still loading.\r\n * @description\r\n * The `m3e-skeleton` component provides a loading placeholder surface with flexible shape variants and\r\n * motion-based animations that communicate loading state while preserving layout stability. It mimics\r\n * the layout of content while it's still loading, ensuring a smooth user experience during data fetching\r\n * or rendering delays. The component supports different animation effects (`pulse`, `wave`, `none`) and\r\n * shape variants (`circular`, `rounded`, `square`, `auto`) to adapt to various content types. When the\r\n * content is loaded, the skeleton fades out with a smooth transition.\r\n *\r\n * @example\r\n * The following example illustrates a skeleton shaped and sized by the slotted `m3e-card`.\r\n * ```html\r\n * <m3e-skeleton>\r\n * <m3e-card></m3e-card>\r\n * </m3e-skeleton>\r\n * ```\r\n *\r\n * @tag m3e-skeleton\r\n *\r\n * @attr animation - The animation effect of the skeleton.\r\n * @attr shape - The shape of the skeleton.\r\n * @attr loaded - Whether the content of the skeleton has been loaded.\r\n *\r\n * @slot - Renders the content to be mimicked by the skeleton.\r\n *\r\n * @cssprop --m3e-skeleton-color - Base fill color for the skeleton surface.\r\n * @cssprop --m3e-skeleton-tint-color - Tint fill color for the skeleton surface.\r\n * @cssprop --m3e-skeleton-tint-opacity - Tint Opacity applied when the skeleton animation is not pulsating.\r\n * @cssprop --m3e-skeleton-accent-color - Accent color used in wave animation.\r\n * @cssprop --m3e-skeleton-accent-opacity - Opacity of the accent effect in animations.\r\n * @cssprop --m3e-skeleton-rounded-shape - Corner radius for the rounded skeleton shape.\r\n * @cssprop --m3e-skeleton-circular-shape - Corner radius for the circular skeleton shape.\r\n * @cssprop --m3e-skeleton-square-shape - Corner radius for the square skeleton shape.\r\n * @cssprop --m3e-skeleton-shape - Corner radius for the skeleton shape.\r\n */\r\n@customElement(\"m3e-skeleton\")\r\nexport class M3eSkeletonElement extends ReconnectedCallback(LitElement) {\r\n /** The styles of the element. */\r\n static override styles: CSSResultGroup = css`\r\n :host {\r\n display: contents;\r\n }\r\n .shape {\r\n position: absolute;\r\n overflow: hidden;\r\n pointer-events: none;\r\n opacity: 1;\r\n background-color: var(--m3e-skeleton-color, ${DesignToken.color.surface});\r\n }\r\n .shape::before {\r\n content: \"\";\r\n position: absolute;\r\n left: 0;\r\n top: 0;\r\n width: 100%;\r\n height: 100%;\r\n background-color: color-mix(\r\n in srgb,\r\n var(--m3e-skeleton-tint-color, ${DesignToken.color.onSurface}) var(--m3e-skeleton-tint-opacity, 8%),\r\n transparent\r\n );\r\n }\r\n :host(:not([loaded])) slot {\r\n visibility: hidden;\r\n }\r\n :host([loaded]) .shape {\r\n opacity: 0;\r\n transition: ${unsafeCSS(`opacity ${DesignToken.motion.duration.short3} ${DesignToken.motion.easing.standard}`)};\r\n }\r\n :host([shape=\"rounded\"]) .shape {\r\n border-radius: var(--m3e-skeleton-rounded-shape, var(--m3e-skeleton-shape, ${DesignToken.shape.corner.large}));\r\n }\r\n :host([shape=\"circular\"]) .shape {\r\n border-radius: var(--m3e-skeleton-circular-shape, var(--m3e-skeleton-shape, ${DesignToken.shape.corner.full}));\r\n }\r\n :host([shape=\"square\"]) .shape {\r\n border-radius: var(--m3e-skeleton-square-shape, var(--m3e-skeleton-shape, 0px));\r\n }\r\n :host([animation=\"pulse\"]:not([loaded])) .shape::after {\r\n content: \"\";\r\n position: absolute;\r\n top: 0;\r\n left: 0;\r\n width: 100%;\r\n height: 100%;\r\n animation: pulse 1.2s ease-in-out infinite;\r\n background-color: var(--m3e-skeleton-tint-color, ${DesignToken.color.surfaceDim});\r\n }\r\n :host([animation=\"wave\"]:not([loaded])) .shape::after {\r\n content: \"\";\r\n position: absolute;\r\n top: 0;\r\n left: -150%;\r\n height: 100%;\r\n width: 150%;\r\n opacity: var(--m3e-skeleton-accent-opacity, 6%);\r\n background: linear-gradient(\r\n 90deg,\r\n transparent,\r\n var(--m3e-skeleton-accent-color, ${DesignToken.color.onSurface}),\r\n transparent\r\n );\r\n animation: wave 2.1s linear infinite;\r\n }\r\n @keyframes pulse {\r\n 0% {\r\n opacity: 1;\r\n }\r\n 50% {\r\n opacity: var(--m3e-skeleton-accent-opacity, 6%);\r\n }\r\n 100% {\r\n opacity: 1;\r\n }\r\n }\r\n @keyframes wave {\r\n 0% {\r\n left: -150%;\r\n }\r\n 100% {\r\n left: 100%;\r\n }\r\n }\r\n @media (forced-colors: active) {\r\n :host([loaded]) .shape {\r\n transition: none;\r\n }\r\n .shape::after {\r\n display: none;\r\n }\r\n .shape {\r\n background-color: GrayText;\r\n }\r\n }\r\n @media (prefers-reduced-motion) {\r\n :host([loaded]) .shape {\r\n transition: none;\r\n }\r\n .shape::after {\r\n display: none;\r\n }\r\n }\r\n `;\r\n\r\n /** @private */ readonly #anchoringCleanupMap = new Map<HTMLElement, () => void>();\r\n\r\n /**\r\n * The shape of the skeleton.\r\n * @default \"auto\"\r\n */\r\n @property({ reflect: true }) shape: SkeletonShape = \"auto\";\r\n\r\n /**\r\n * The animation effect of the skeleton.\r\n * @default \"wave\"\r\n */\r\n @property({ reflect: true }) animation: SkeletonAnimation = \"wave\";\r\n\r\n /**\r\n * Whether the content of the skeleton has been loaded.\r\n * @default false\r\n */\r\n @property({ type: Boolean, reflect: true }) loaded = false;\r\n\r\n /** @inheritdoc */\r\n override disconnectedCallback(): void {\r\n super.disconnectedCallback();\r\n this.#clearShapes();\r\n }\r\n\r\n /** @inheritdoc */\r\n override reconnectedCallback(): void {\r\n super.reconnectedCallback();\r\n this.#createShapes();\r\n }\r\n\r\n /** @inheritdoc */\r\n protected override render(): unknown {\r\n return html`<slot ?inert=\"${!this.loaded}\" @slotchange=\"${this.#handleSlotChange}\"></slot>`;\r\n }\r\n\r\n /** @private */\r\n async #handleSlotChange(): Promise<void> {\r\n this.#createShapes();\r\n }\r\n\r\n /** @private */\r\n #clearShapes(): void {\r\n for (const item of this.#anchoringCleanupMap) {\r\n item[0].remove();\r\n item[1]();\r\n }\r\n this.#anchoringCleanupMap.clear();\r\n }\r\n\r\n /** @private */\r\n async #createShapes(): Promise<void> {\r\n this.#clearShapes();\r\n\r\n const slot = this.shadowRoot?.querySelector(\"slot\");\r\n if (!slot) return;\r\n\r\n for (const element of slot.assignedElements({ flatten: true }).filter((x) => x instanceof HTMLElement)) {\r\n await this.#createShape(element);\r\n }\r\n }\r\n\r\n /** @private */\r\n async #createShape(element: HTMLElement): Promise<void> {\r\n await waitForUpgrade(element);\r\n\r\n const shape = document.createElement(\"div\");\r\n shape.classList.add(\"shape\");\r\n\r\n if (this.shape === \"auto\") {\r\n let borderRadius = getComputedStyle(element).borderRadius;\r\n if (!borderRadius || borderRadius === \"0px\") {\r\n const firstElement = element.shadowRoot?.firstElementChild;\r\n if (firstElement && !firstElement.nextElementSibling) {\r\n borderRadius = getComputedStyle(firstElement).borderRadius;\r\n }\r\n }\r\n\r\n if (borderRadius && borderRadius !== \"0px\") {\r\n shape.style.borderRadius = borderRadius;\r\n }\r\n }\r\n\r\n const anchoringCleanup = await positionAnchor(\r\n shape,\r\n element,\r\n {\r\n position: \"bottom\",\r\n },\r\n (x, y) => {\r\n shape.style.left = `${x}px`;\r\n shape.style.top = `${y - element.clientHeight}px`;\r\n shape.style.width = `${element.clientWidth}px`;\r\n shape.style.height = `${element.clientHeight}px`;\r\n },\r\n );\r\n\r\n this.#anchoringCleanupMap.set(shape, anchoringCleanup);\r\n this.shadowRoot?.appendChild(shape);\r\n }\r\n}\r\n\r\ndeclare global {\r\n interface HTMLElementTagNameMap {\r\n \"m3e-skeleton\": M3eSkeletonElement;\r\n }\r\n}\r\n"],"names":["M3eSkeletonElement","ReconnectedCallback","LitElement","constructor","_M3eSkeletonElement_anchoringCleanupMap","set","this","Map","shape","animation","loaded","disconnectedCallback","super","__classPrivateFieldGet","_M3eSkeletonElement_instances","_M3eSkeletonElement_clearShapes","call","reconnectedCallback","_M3eSkeletonElement_createShapes","render","html","_M3eSkeletonElement_handleSlotChange","async","item","remove","clear","slot","shadowRoot","querySelector","element","assignedElements","flatten","filter","x","HTMLElement","_M3eSkeletonElement_createShape","waitForUpgrade","document","createElement","classList","add","borderRadius","getComputedStyle","firstElement","firstElementChild","nextElementSibling","style","anchoringCleanup","positionAnchor","position","y","left","top","clientHeight","width","clientWidth","height","appendChild","styles","css","DesignToken","color","surface","onSurface","unsafeCSS","motion","duration","short3","easing","standard","corner","large","full","surfaceDim","__decorate","property","reflect","prototype","type","Boolean","customElement"],"mappings":";;;;;oWA8CO,IAAMA,EAAN,cAAiCC,EAAoBC,IAArDC,WAAAA,mCA4GoBC,EAAAC,IAAAC,KAAuB,IAAIC,KAMvBD,KAAAE,MAAuB,OAMvBF,KAAAG,UAA+B,OAMhBH,KAAAI,QAAS,CAmFvD,CAhFWC,oBAAAA,GACPC,MAAMD,uBACNE,EAAAP,KAAIQ,EAAA,IAAAC,GAAaC,KAAjBV,KACF,CAGSW,mBAAAA,GACPL,MAAMK,sBACNJ,EAAAP,KAAIQ,EAAA,IAAAI,GAAcF,KAAlBV,KACF,CAGmBa,MAAAA,GACjB,OAAOC,CAAI,kBAAkBd,KAAKI,wBAAwBG,EAAAP,KAAIQ,EAAA,IAAAO,aAChE,iCAGAC,iBACET,EAAAP,KAAIQ,EAAA,IAAAI,GAAcF,KAAlBV,KACF,eAIE,IAAK,MAAMiB,KAAQV,EAAAP,KAAIF,EAAA,KACrBmB,EAAK,GAAGC,SACRD,EAAK,KAEPV,EAAAP,KAAIF,EAAA,KAAsBqB,OAC5B,IAGAH,iBACET,EAAAP,KAAIQ,EAAA,IAAAC,GAAaC,KAAjBV,MAEA,MAAMoB,EAAOpB,KAAKqB,YAAYC,cAAc,QAC5C,GAAKF,EAEL,IAAK,MAAMG,KAAWH,EAAKI,iBAAiB,CAAEC,SA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