lido-player 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/components/app-col.d.ts +11 -0
- package/dist/components/app-container.d.ts +11 -0
- package/dist/components/app-home.d.ts +11 -0
- package/dist/components/app-image.d.ts +11 -0
- package/dist/components/app-pos.d.ts +11 -0
- package/dist/components/app-random.d.ts +11 -0
- package/dist/components/app-root.d.ts +11 -0
- package/dist/components/app-row.d.ts +11 -0
- package/dist/components/app-shape.d.ts +11 -0
- package/dist/components/app-text.d.ts +11 -0
- package/dist/components/app-trace.d.ts +11 -0
- package/dist/components/app-wrap.d.ts +11 -0
- package/dist/components/index.d.ts +33 -0
- package/dist/lido-player/app-col.entry.js +58 -0
- package/dist/lido-player/app-col.entry.js.map +1 -0
- package/dist/lido-player/app-container.entry.js +90 -0
- package/dist/lido-player/app-container.entry.js.map +1 -0
- package/dist/lido-player/app-globals-0f993ce5.js +5 -0
- package/dist/lido-player/app-globals-0f993ce5.js.map +1 -0
- package/dist/lido-player/app-home.entry.js +191 -0
- package/dist/lido-player/app-home.entry.js.map +1 -0
- package/dist/lido-player/app-image.entry.js +60 -0
- package/dist/lido-player/app-image.entry.js.map +1 -0
- package/dist/lido-player/app-pos.entry.js +58 -0
- package/dist/lido-player/app-pos.entry.js.map +1 -0
- package/dist/lido-player/app-random.entry.js +64 -0
- package/dist/lido-player/app-random.entry.js.map +1 -0
- package/dist/lido-player/app-root.entry.js +34 -0
- package/dist/lido-player/app-root.entry.js.map +1 -0
- package/dist/lido-player/app-row.entry.js +57 -0
- package/dist/lido-player/app-row.entry.js.map +1 -0
- package/dist/lido-player/app-shape.entry.js +59 -0
- package/dist/lido-player/app-shape.entry.js.map +1 -0
- package/dist/lido-player/app-text.entry.js +66 -0
- package/dist/lido-player/app-text.entry.js.map +1 -0
- package/dist/lido-player/app-trace.entry.js +488 -0
- package/dist/lido-player/app-trace.entry.js.map +1 -0
- package/dist/lido-player/app-wrap.entry.js +58 -0
- package/dist/lido-player/app-wrap.entry.js.map +1 -0
- package/dist/lido-player/assets/Audio/goodJob.mp3 +0 -0
- package/dist/lido-player/assets/Audio/tryAgain.mp3 +0 -0
- package/dist/lido-player/assets/Audio/wellDone.mp3 +0 -0
- package/dist/lido-player/assets/images/HIimage.png +0 -0
- package/dist/lido-player/assets/images/VIimage.png +0 -0
- package/dist/lido-player/assets/images/animals/giraffe.png +0 -0
- package/dist/lido-player/assets/images/animals/leopard.png +0 -0
- package/dist/lido-player/assets/images/animals/lion.png +0 -0
- package/dist/lido-player/assets/images/animals/tiger.png +0 -0
- package/dist/lido-player/assets/images/bodyParts/ear.png +0 -0
- package/dist/lido-player/assets/images/bodyParts/eyes.png +0 -0
- package/dist/lido-player/assets/images/bodyParts/nose.png +0 -0
- package/dist/lido-player/assets/images/girl.png +0 -0
- package/dist/lido-player/assets/images/icons/access.png +0 -0
- package/dist/lido-player/assets/images/icons/brightness.png +0 -0
- package/dist/lido-player/assets/images/icons/cancel.png +0 -0
- package/dist/lido-player/assets/images/icons/contrast.png +0 -0
- package/dist/lido-player/assets/images/icons/dropDown.png +0 -0
- package/dist/lido-player/assets/images/icons/exit.png +0 -0
- package/dist/lido-player/assets/images/icons/hide.png +0 -0
- package/dist/lido-player/assets/images/icons/invert.png +0 -0
- package/dist/lido-player/assets/images/icons/lineSpacing.png +0 -0
- package/dist/lido-player/assets/images/icons/sound.png +0 -0
- package/dist/lido-player/assets/images/icons/zoom.png +0 -0
- package/dist/lido-player/assets/images/truck/blueTruck.png +0 -0
- package/dist/lido-player/assets/images/truck/dashedBox.png +0 -0
- package/dist/lido-player/assets/images/truck/face.png +0 -0
- package/dist/lido-player/assets/images/truck/road.jpg +0 -0
- package/dist/lido-player/assets/images/truck/seeing.png +0 -0
- package/dist/lido-player/assets/images/truck/truck.png +0 -0
- package/dist/lido-player/assets/images/twoColorBg.jpg +0 -0
- package/dist/lido-player/assets/xmlData.xml +121 -0
- package/dist/lido-player/constants-f484fcec.js +14 -0
- package/dist/lido-player/constants-f484fcec.js.map +1 -0
- package/dist/lido-player/index-9624adf5.js +3013 -0
- package/dist/lido-player/index-9624adf5.js.map +1 -0
- package/dist/lido-player/index.esm.js +14 -0
- package/dist/lido-player/index.esm.js.map +1 -0
- package/dist/lido-player/lido-player.css +6 -0
- package/dist/lido-player/lido-player.esm.js +49 -0
- package/dist/lido-player/lido-player.esm.js.map +1 -0
- package/dist/lido-player/shadow-css-7ad5caf8.js +334 -0
- package/dist/lido-player/shadow-css-7ad5caf8.js.map +1 -0
- package/dist/lido-player/utils-291495a4.js +642 -0
- package/dist/lido-player/utils-291495a4.js.map +1 -0
- package/dist/types/components/column/AppCol.d.ts +99 -0
- package/dist/types/components/container/AppContainer.d.ts +114 -0
- package/dist/types/components/home/AppHome.d.ts +78 -0
- package/dist/types/components/image/AppImage.d.ts +98 -0
- package/dist/types/components/position/AppPos.d.ts +97 -0
- package/dist/types/components/random/AppRandom.d.ts +97 -0
- package/dist/types/components/root/AppRoot.d.ts +19 -0
- package/dist/types/components/row/AppRow.d.ts +92 -0
- package/dist/types/components/shape/AppShape.d.ts +104 -0
- package/dist/types/components/text/AppText.d.ts +117 -0
- package/dist/types/components/trace/app-trace.d.ts +98 -0
- package/dist/types/components/wrap/AppWrap.d.ts +97 -0
- package/dist/types/components.d.ts +2032 -0
- package/dist/types/index.d.ts +11 -0
- package/dist/types/stencil-public-runtime.d.ts +1674 -0
- package/dist/types/utils/constants.d.ts +9 -0
- package/dist/types/utils/utils.d.ts +4 -0
- package/loader/cdn.js +1 -0
- package/loader/index.cjs.js +1 -0
- package/loader/index.d.ts +24 -0
- package/loader/index.es2017.js +1 -0
- package/loader/index.js +2 -0
- package/loader/package.json +11 -0
- package/package.json +51 -0
- package/readme.md +114 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "../types/components";
|
|
2
|
+
|
|
3
|
+
interface AppCol extends Components.AppCol, HTMLElement {}
|
|
4
|
+
export const AppCol: {
|
|
5
|
+
prototype: AppCol;
|
|
6
|
+
new (): AppCol;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "../types/components";
|
|
2
|
+
|
|
3
|
+
interface AppContainer extends Components.AppContainer, HTMLElement {}
|
|
4
|
+
export const AppContainer: {
|
|
5
|
+
prototype: AppContainer;
|
|
6
|
+
new (): AppContainer;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "../types/components";
|
|
2
|
+
|
|
3
|
+
interface AppHome extends Components.AppHome, HTMLElement {}
|
|
4
|
+
export const AppHome: {
|
|
5
|
+
prototype: AppHome;
|
|
6
|
+
new (): AppHome;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "../types/components";
|
|
2
|
+
|
|
3
|
+
interface AppImage extends Components.AppImage, HTMLElement {}
|
|
4
|
+
export const AppImage: {
|
|
5
|
+
prototype: AppImage;
|
|
6
|
+
new (): AppImage;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "../types/components";
|
|
2
|
+
|
|
3
|
+
interface AppPos extends Components.AppPos, HTMLElement {}
|
|
4
|
+
export const AppPos: {
|
|
5
|
+
prototype: AppPos;
|
|
6
|
+
new (): AppPos;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "../types/components";
|
|
2
|
+
|
|
3
|
+
interface AppRandom extends Components.AppRandom, HTMLElement {}
|
|
4
|
+
export const AppRandom: {
|
|
5
|
+
prototype: AppRandom;
|
|
6
|
+
new (): AppRandom;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "../types/components";
|
|
2
|
+
|
|
3
|
+
interface AppRoot extends Components.AppRoot, HTMLElement {}
|
|
4
|
+
export const AppRoot: {
|
|
5
|
+
prototype: AppRoot;
|
|
6
|
+
new (): AppRoot;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "../types/components";
|
|
2
|
+
|
|
3
|
+
interface AppRow extends Components.AppRow, HTMLElement {}
|
|
4
|
+
export const AppRow: {
|
|
5
|
+
prototype: AppRow;
|
|
6
|
+
new (): AppRow;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "../types/components";
|
|
2
|
+
|
|
3
|
+
interface AppShape extends Components.AppShape, HTMLElement {}
|
|
4
|
+
export const AppShape: {
|
|
5
|
+
prototype: AppShape;
|
|
6
|
+
new (): AppShape;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "../types/components";
|
|
2
|
+
|
|
3
|
+
interface AppText extends Components.AppText, HTMLElement {}
|
|
4
|
+
export const AppText: {
|
|
5
|
+
prototype: AppText;
|
|
6
|
+
new (): AppText;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "../types/components";
|
|
2
|
+
|
|
3
|
+
interface AppTrace extends Components.AppTrace, HTMLElement {}
|
|
4
|
+
export const AppTrace: {
|
|
5
|
+
prototype: AppTrace;
|
|
6
|
+
new (): AppTrace;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "../types/components";
|
|
2
|
+
|
|
3
|
+
interface AppWrap extends Components.AppWrap, HTMLElement {}
|
|
4
|
+
export const AppWrap: {
|
|
5
|
+
prototype: AppWrap;
|
|
6
|
+
new (): AppWrap;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get the base path to where the assets can be found. Use "setAssetPath(path)"
|
|
3
|
+
* if the path needs to be customized.
|
|
4
|
+
*/
|
|
5
|
+
export declare const getAssetPath: (path: string) => string;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Used to manually set the base path where assets can be found.
|
|
9
|
+
* If the script is used as "module", it's recommended to use "import.meta.url",
|
|
10
|
+
* such as "setAssetPath(import.meta.url)". Other options include
|
|
11
|
+
* "setAssetPath(document.currentScript.src)", or using a bundler's replace plugin to
|
|
12
|
+
* dynamically set the path at build time, such as "setAssetPath(process.env.ASSET_PATH)".
|
|
13
|
+
* But do note that this configuration depends on how your script is bundled, or lack of
|
|
14
|
+
* bundling, and where your assets can be loaded from. Additionally custom bundling
|
|
15
|
+
* will have to ensure the static assets are copied to its build directory.
|
|
16
|
+
*/
|
|
17
|
+
export declare const setAssetPath: (path: string) => void;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Used to specify a nonce value that corresponds with an application's CSP.
|
|
21
|
+
* When set, the nonce will be added to all dynamically created script and style tags at runtime.
|
|
22
|
+
* Alternatively, the nonce value can be set on a meta tag in the DOM head
|
|
23
|
+
* (<meta name="csp-nonce" content="{ nonce value here }" />) which
|
|
24
|
+
* will result in the same behavior.
|
|
25
|
+
*/
|
|
26
|
+
export declare const setNonce: (nonce: string) => void
|
|
27
|
+
|
|
28
|
+
export interface SetPlatformOptions {
|
|
29
|
+
raf?: (c: FrameRequestCallback) => number;
|
|
30
|
+
ael?: (el: EventTarget, eventName: string, listener: EventListenerOrEventListenerObject, options: boolean | AddEventListenerOptions) => void;
|
|
31
|
+
rel?: (el: EventTarget, eventName: string, listener: EventListenerOrEventListenerObject, options: boolean | AddEventListenerOptions) => void;
|
|
32
|
+
}
|
|
33
|
+
export declare const setPlatformOptions: (opts: SetPlatformOptions) => void;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { r as registerInstance, h, a as Host, e as getElement } from './index-9624adf5.js';
|
|
2
|
+
import { i as initEventsForElement } from './utils-291495a4.js';
|
|
3
|
+
import './constants-f484fcec.js';
|
|
4
|
+
|
|
5
|
+
const appColCss = ".col{top:var(--y, 0);left:var(--x, 0);height:var(--height, 100%);width:var(--width, 100%);background-color:var(--bgColor, #eeeeee);padding:15px;border-radius:10px;display:flex;justify-content:space-around;flex-direction:column;align-items:center}.col>*{}";
|
|
6
|
+
|
|
7
|
+
const AppCol = class {
|
|
8
|
+
constructor(hostRef) {
|
|
9
|
+
registerInstance(this, hostRef);
|
|
10
|
+
this.id = undefined;
|
|
11
|
+
this.value = undefined;
|
|
12
|
+
this.height = undefined;
|
|
13
|
+
this.width = undefined;
|
|
14
|
+
this.ariaLabel = undefined;
|
|
15
|
+
this.ariaHidden = undefined;
|
|
16
|
+
this.x = undefined;
|
|
17
|
+
this.y = undefined;
|
|
18
|
+
this.z = undefined;
|
|
19
|
+
this.bgColor = undefined;
|
|
20
|
+
this.type = undefined;
|
|
21
|
+
this.tabIndex = undefined;
|
|
22
|
+
this.visible = undefined;
|
|
23
|
+
this.audio = undefined;
|
|
24
|
+
this.onTouch = undefined;
|
|
25
|
+
this.onCorrectTouch = undefined;
|
|
26
|
+
this.onInCorrectTouch = undefined;
|
|
27
|
+
this.onCorrectMatch = undefined;
|
|
28
|
+
this.onMatch = undefined;
|
|
29
|
+
this.onWrong = undefined;
|
|
30
|
+
this.onEntry = undefined;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* This lifecycle hook is called after the component is rendered in the DOM.
|
|
34
|
+
* It initializes events for the column based on the provided type.
|
|
35
|
+
*/
|
|
36
|
+
componentDidLoad() {
|
|
37
|
+
initEventsForElement(this.el, this.type);
|
|
38
|
+
}
|
|
39
|
+
render() {
|
|
40
|
+
// Inline styles applied to the column, mainly for positioning and background.
|
|
41
|
+
const style = {
|
|
42
|
+
height: this.height,
|
|
43
|
+
width: this.width,
|
|
44
|
+
backgroundColor: this.bgColor,
|
|
45
|
+
top: this.y,
|
|
46
|
+
left: this.x,
|
|
47
|
+
display: this.visible ? 'flex' : 'none',
|
|
48
|
+
zIndex: this.z,
|
|
49
|
+
};
|
|
50
|
+
return (h(Host, { key: '3cd3b141cf167e7c43132fc0f28fe049765e3e68', id: this.id, class: "col", type: this.type, tabindex: this.tabIndex, value: this.value, style: style, "aria-label": this.ariaLabel, "aria-hidden": this.ariaHidden, audio: this.audio, onTouch: this.onTouch, onMatch: this.onMatch, onWrong: this.onWrong, onCorrectMatch: this.onCorrectMatch, onCorrectTouch: this.onCorrectTouch, onInCorrectTouch: this.onInCorrectTouch, onEntry: this.onEntry }, h("slot", { key: 'fecc9cdf6b7204461c07e89de0ebec35559f8daf' })));
|
|
51
|
+
}
|
|
52
|
+
get el() { return getElement(this); }
|
|
53
|
+
};
|
|
54
|
+
AppCol.style = appColCss;
|
|
55
|
+
|
|
56
|
+
export { AppCol as app_col };
|
|
57
|
+
|
|
58
|
+
//# sourceMappingURL=app-col.entry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"file":"app-col.entry.esm.js","mappings":";;;;AAAA,MAAM,SAAS,GAAG,gQAAgQ;;MCiBrQ,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA6GjB,gBAAgB;QACd,oBAAoB,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;KAC1C;IAED,MAAM;;QAEJ,MAAM,KAAK,GAAG;YACZ,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,eAAe,EAAE,IAAI,CAAC,OAAO;YAC7B,GAAG,EAAE,IAAI,CAAC,CAAC;YACX,IAAI,EAAE,IAAI,CAAC,CAAC;YACZ,OAAO,EAAE,IAAI,CAAC,OAAO,GAAG,MAAM,GAAG,MAAM;YACvC,MAAM,EAAE,IAAI,CAAC,CAAC;SACf,CAAC;QAEF,QACE,EAAC,IAAI,qDACH,EAAE,EAAE,IAAI,CAAC,EAAE,EACX,KAAK,EAAC,KAAK,EACX,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,KAAK,EAAE,KAAK,gBACA,IAAI,CAAC,SAAS,iBACb,IAAI,CAAC,UAAU,EAC5B,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,OAAO,EAAE,IAAI,CAAC,OAAO,EACrB,OAAO,EAAE,IAAI,CAAC,OAAO,EACrB,OAAO,EAAE,IAAI,CAAC,OAAO,EACrB,cAAc,EAAE,IAAI,CAAC,cAAc,EACnC,cAAc,EAAE,IAAI,CAAC,cAAc,EACnC,gBAAgB,EAAE,IAAI,CAAC,gBAAgB,EACvC,OAAO,EAAE,IAAI,CAAC,OAAO,IAErB,8DAAQ,CACH,EACP;KACH;;;;;;;","names":[],"sources":["src/components/column/app-col.css?tag=app-col","src/components/column/AppCol.tsx"],"sourcesContent":[".col {\n /* position: absolute; */\n top: var(--y, 0);\n left: var(--x, 0);\n height: var(--height, 100%);\n width: var(--width, 100%);\n background-color: var(--bgColor, #eeeeee);\n /* position: relative; */\n padding: 15px;\n border-radius: 10px;\n display: flex;\n justify-content: space-around;\n flex-direction: column;\n align-items: center;\n}\n\n.col > * {\n /* position: relative; */\n}\n","import { Component, Host, Prop, h, Element } from '@stencil/core';\nimport { initEventsForElement } from '../../utils/utils';\n\n/**\n * @component AppCol\n *\n * The `AppCol` component is a dynamic column-like UI element that can be\n * customized via various properties such as dimensions, position, visibility,\n * background color, and event handlers. It is designed to work within\n * containers (`app-container`) and can include child components like\n * `app-text`, `app-row`, etc.\n */\n@Component({\n tag: 'app-col',\n styleUrl: 'app-col.css',\n shadow: false,\n})\nexport class AppCol {\n /**\n * The unique identifier for the column component.\n */\n @Prop() id: string;\n\n /**\n * The value associated with the column component. Typically used for internal logic.\n */\n @Prop() value: string;\n\n /**\n * The height of the column component (CSS value, e.g., '100px', '50%').\n */\n @Prop() height: string;\n\n /**\n * The width of the column component (CSS value, e.g., '100px', '50%').\n */\n @Prop() width: string;\n\n /**\n * The ARIA label of the container. Used for accessibility to indicate the purpose of the element.\n */\n @Prop() ariaLabel: string;\n\n /**\n * The ARIA hidden attribute of the container. Used for accessibility to hide the element.\n */\n @Prop() ariaHidden: string;\n\n /**\n * The x-coordinate (left position) of the column within its container (CSS value, e.g., '10px', '5vw').\n */\n @Prop() x: string;\n\n /**\n * The y-coordinate (top position) of the column within its container (CSS value, e.g., '10px', '5vh').\n */\n @Prop() y: string;\n\n /**\n * The z-index of the column to control stacking order.\n */\n @Prop() z: string;\n\n /**\n * The background color of the column (CSS color value, e.g., '#FFFFFF', 'blue').\n */\n @Prop() bgColor: string;\n\n /**\n * Defines the type of the column, which can be used for styling or specific logic handling.\n */\n @Prop() type: string;\n\n /**\n * The tab index value, used to set the tab order of the column for keyboard navigation.\n */\n @Prop() tabIndex: number;\n\n /**\n * A boolean that controls whether the column is visible (`true`) or hidden (`false`).\n */\n @Prop() visible: boolean;\n\n /**\n * Audio file URL or identifier for sound that will be associated with the column.\n */\n @Prop() audio: string;\n\n /**\n * Event handler for a touch event, where a custom function can be triggered when the column is touched.\n */\n @Prop() onTouch: string;\n\n /**\n * Event handler for a Correct touch event, where a custom function can be triggered when the column is touched.\n */\n @Prop() onCorrectTouch: string;\n\n @Prop() onInCorrectTouch: string;\n\n /**\n * Event handler for a Correct matching action, which can be used to hide the column or trigger other custom logic.\n */\n @Prop() onCorrectMatch: string;\n\n /**\n * Event handler for a matching action, which can be used to hide the column or trigger other custom logic.\n */\n @Prop() onMatch: string;\n\n @Prop() onWrong: string;\n\n /**\n * Event handler for when the column is entered, which can be used to initiate specific behaviors on entry.\n */\n @Prop() onEntry: string;\n\n /**\n * Reference to the HTML element that represents this component.\n */\n @Element() el: HTMLElement;\n\n /**\n * This lifecycle hook is called after the component is rendered in the DOM.\n * It initializes events for the column based on the provided type.\n */\n componentDidLoad() {\n initEventsForElement(this.el, this.type);\n }\n\n render() {\n // Inline styles applied to the column, mainly for positioning and background.\n const style = {\n height: this.height,\n width: this.width,\n backgroundColor: this.bgColor,\n top: this.y,\n left: this.x,\n display: this.visible ? 'flex' : 'none',\n zIndex: this.z,\n };\n\n return (\n <Host\n id={this.id}\n class=\"col\"\n type={this.type}\n tabindex={this.tabIndex}\n value={this.value}\n style={style}\n aria-label={this.ariaLabel}\n aria-hidden={this.ariaHidden}\n audio={this.audio}\n onTouch={this.onTouch}\n onMatch={this.onMatch}\n onWrong={this.onWrong}\n onCorrectMatch={this.onCorrectMatch}\n onCorrectTouch={this.onCorrectTouch}\n onInCorrectTouch={this.onInCorrectTouch}\n onEntry={this.onEntry}\n >\n <slot />\n </Host>\n );\n }\n}\n"],"version":3}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { r as registerInstance, h, a as Host, e as getElement } from './index-9624adf5.js';
|
|
2
|
+
import { i as initEventsForElement } from './utils-291495a4.js';
|
|
3
|
+
import './constants-f484fcec.js';
|
|
4
|
+
|
|
5
|
+
const appContainerCss = ".container{position:relative;height:100%;width:100%;background-color:var(--bgColor, #ffffff);display:flex;flex-direction:column;justify-content:center;align-items:center}";
|
|
6
|
+
|
|
7
|
+
const AppContainer = class {
|
|
8
|
+
constructor(hostRef) {
|
|
9
|
+
registerInstance(this, hostRef);
|
|
10
|
+
this.id = undefined;
|
|
11
|
+
this.objective = undefined;
|
|
12
|
+
this.value = undefined;
|
|
13
|
+
this.height = undefined;
|
|
14
|
+
this.width = undefined;
|
|
15
|
+
this.ariaLabel = undefined;
|
|
16
|
+
this.ariaHidden = undefined;
|
|
17
|
+
this.x = undefined;
|
|
18
|
+
this.y = undefined;
|
|
19
|
+
this.z = undefined;
|
|
20
|
+
this.bgColor = undefined;
|
|
21
|
+
this.type = undefined;
|
|
22
|
+
this.tabIndex = undefined;
|
|
23
|
+
this.visible = undefined;
|
|
24
|
+
this.audio = undefined;
|
|
25
|
+
this.onTouch = undefined;
|
|
26
|
+
this.onCorrectTouch = undefined;
|
|
27
|
+
this.onCorrectMatch = undefined;
|
|
28
|
+
this.onMatch = undefined;
|
|
29
|
+
this.onWrong = undefined;
|
|
30
|
+
this.onIncorrectTouch = undefined;
|
|
31
|
+
this.onEntry = undefined;
|
|
32
|
+
this.canplay = true;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Scales the container based on the window or screen size, maintaining the aspect ratio.
|
|
36
|
+
* The container scales according to the minimum dimension of the screen.
|
|
37
|
+
*
|
|
38
|
+
* @param container The container element to be scaled.
|
|
39
|
+
*/
|
|
40
|
+
scaleContainer(container) {
|
|
41
|
+
var _a;
|
|
42
|
+
const widths = [window.innerWidth];
|
|
43
|
+
const heights = [window.innerHeight];
|
|
44
|
+
if ((_a = window.screen) === null || _a === void 0 ? void 0 : _a.width) {
|
|
45
|
+
widths.push(window.screen.width);
|
|
46
|
+
heights.push(window.screen.height);
|
|
47
|
+
}
|
|
48
|
+
const width = Math.min(...widths);
|
|
49
|
+
const height = document.documentElement.clientHeight;
|
|
50
|
+
const scaleX = width / 1600; // Scale based on a reference width of 1600px
|
|
51
|
+
const scaleY = height / 900; // Scale based on a reference height of 900px
|
|
52
|
+
const scale = Math.min(scaleX, scaleY);
|
|
53
|
+
// Center the container and apply scaling
|
|
54
|
+
container.style.transform = `translate(-50%, -50%) scale(${scale})`;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Lifecycle hook that runs after the component is loaded.
|
|
58
|
+
* - It scales the container.
|
|
59
|
+
* - It sets the background color of the body.
|
|
60
|
+
* - Adds event listeners for `resize` and `load` to rescale the container on window size changes.
|
|
61
|
+
*/
|
|
62
|
+
componentDidLoad() {
|
|
63
|
+
this.scaleContainer(this.el);
|
|
64
|
+
document.body.style.backgroundColor = this.bgColor;
|
|
65
|
+
// Re-scale the container on window resize or load events
|
|
66
|
+
window.addEventListener('resize', () => this.scaleContainer(this.el));
|
|
67
|
+
window.addEventListener('load', () => this.scaleContainer(this.el));
|
|
68
|
+
initEventsForElement(this.el, this.type);
|
|
69
|
+
}
|
|
70
|
+
render() {
|
|
71
|
+
// Define the styles for the container element
|
|
72
|
+
const style = {
|
|
73
|
+
backgroundColor: this.bgColor,
|
|
74
|
+
width: '1600px', // Fixed width of the container
|
|
75
|
+
height: '900px', // Fixed height of the container
|
|
76
|
+
position: 'absolute',
|
|
77
|
+
top: '50%',
|
|
78
|
+
left: '50%',
|
|
79
|
+
transform: 'translate(-50%, -50%)', // Centering the container
|
|
80
|
+
};
|
|
81
|
+
console.log('🚀 ~ AppContainer ~ canplay:', this.canplay);
|
|
82
|
+
return (h(Host, { key: '3de4da721c5eb3dcdd9b29e01cfcc7968d40a761', id: "container", tabindex: 0, class: "container", objective: this.objective, style: style, "aria-label": this.ariaLabel, "aria-hidden": this.ariaHidden, onTouch: this.onTouch, onMatch: this.onMatch, onWrong: this.onWrong, onIncorrectTouch: this.onIncorrectTouch, onCorrectMatch: this.onCorrectMatch, onCorrectTouch: this.onCorrectTouch, onEntry: this.onEntry }, h("slot", { key: 'bd4abd0fd97b92a6f942554be26a28d3948f7a5d' })));
|
|
83
|
+
}
|
|
84
|
+
get el() { return getElement(this); }
|
|
85
|
+
};
|
|
86
|
+
AppContainer.style = appContainerCss;
|
|
87
|
+
|
|
88
|
+
export { AppContainer as app_container };
|
|
89
|
+
|
|
90
|
+
//# sourceMappingURL=app-container.entry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"file":"app-container.entry.esm.js","mappings":";;;;AAAA,MAAM,eAAe,GAAG,4KAA4K;;MCevL,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;uBA0GI,IAAI;;;;;;;;IAa/B,cAAc,CAAC,SAAsB;;QACnC,MAAM,MAAM,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QACnC,MAAM,OAAO,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QAErC,IAAI,MAAA,MAAM,CAAC,MAAM,0CAAE,KAAK,EAAE;YACxB,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACjC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;SACpC;QAED,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC;QAClC,MAAM,MAAM,GAAG,QAAQ,CAAC,eAAe,CAAC,YAAY,CAAC;QAErD,MAAM,MAAM,GAAG,KAAK,GAAG,IAAI,CAAC;QAC5B,MAAM,MAAM,GAAG,MAAM,GAAG,GAAG,CAAC;QAC5B,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;;QAGvC,SAAS,CAAC,KAAK,CAAC,SAAS,GAAG,+BAA+B,KAAK,GAAG,CAAC;KACrE;;;;;;;IAQD,gBAAgB;QACd,IAAI,CAAC,cAAc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],"sources":["src/components/container/app-container.css?tag=app-container","src/components/container/AppContainer.tsx"],"sourcesContent":[".container {\n position: relative;\n height: 100%;\n width: 100%;\n background-color: var(--bgColor, #ffffff);\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n}\n","import { Component, Host, Prop, h, Element } from '@stencil/core';\nimport { initEventsForElement } from '../../utils/utils';\n\n/**\n * @component AppContainer\n *\n * The `AppContainer` component acts as a container for other elements. It scales responsively\n * based on the window size, adjusts background color, and provides various configurable properties\n * such as dimensions, positioning, visibility, and custom event handlers.\n */\n@Component({\n tag: 'app-container',\n styleUrl: 'app-container.css',\n shadow: false,\n})\nexport class AppContainer {\n /**\n * Unique identifier for the container.\n */\n @Prop() id: string;\n\n /**\n * Objective or purpose of the container. Can be used for internal logic or tracking.\n */\n @Prop() objective: string;\n\n /**\n * Value assigned to the container. This can be used for logic related to this component.\n */\n @Prop() value: string;\n\n /**\n * The height of the container (CSS value).\n */\n @Prop() height: string;\n\n /**\n * The width of the container (CSS value).\n */\n @Prop() width: string;\n\n /**\n * The ARIA label of the container. Used for accessibility to indicate the purpose of the element.\n */\n @Prop() ariaLabel: string;\n\n /**\n * The ARIA hidden attribute of the container. Used for accessibility to hide the element.\n */\n @Prop() ariaHidden: string;\n\n /**\n * X-axis (horizontal) position of the container.\n */\n @Prop() x: string;\n\n /**\n * Y-axis (vertical) position of the container.\n */\n @Prop() y: string;\n\n /**\n * Z-index to control the stacking order of the container.\n */\n @Prop() z: string;\n\n /**\n * Background color of the container (CSS color value).\n */\n @Prop() bgColor: string;\n\n /**\n * Type of the container, which can be used for conditional logic or styling purposes.\n */\n @Prop() type: string;\n\n /**\n * TabIndex for keyboard navigation.\n */\n @Prop() tabIndex: number;\n\n /**\n * Visibility flag for the container. If `true`, the container is visible; otherwise, it is hidden.\n */\n @Prop() visible: boolean;\n\n /**\n * URL or identifier of an audio file associated with the container.\n */\n @Prop() audio: string;\n\n /**\n * Event handler triggered when the container is touched or clicked.\n */\n @Prop() onTouch: string;\n\n /**\n * Event handler for a Correct touch event, where a custom function can be triggered when the column is touched.\n */\n @Prop() onCorrectTouch: string;\n\n /**\n * Event handler for a Correct matching action, which can be used to hide the column or trigger other custom logic.\n */\n @Prop() onCorrectMatch: string;\n\n /**\n * Event handler triggered when a specific match condition is met within the container.\n */\n @Prop() onMatch: string;\n @Prop() onWrong: string;\n @Prop() onIncorrectTouch: string;\n\n /**\n * Event handler triggered when the container is entered, useful for triggering animations or logic.\n */\n @Prop() onEntry: string;\n\n /**\n * Boolean that controls the playability of the game.\n */\n @Prop() canplay: boolean = true;\n\n /**\n * Reference to the HTML element that represents this container component.\n */\n @Element() el: HTMLElement;\n\n /**\n * Scales the container based on the window or screen size, maintaining the aspect ratio.\n * The container scales according to the minimum dimension of the screen.\n *\n * @param container The container element to be scaled.\n */\n scaleContainer(container: HTMLElement) {\n const widths = [window.innerWidth];\n const heights = [window.innerHeight];\n\n if (window.screen?.width) {\n widths.push(window.screen.width);\n heights.push(window.screen.height);\n }\n\n const width = Math.min(...widths);\n const height = document.documentElement.clientHeight;\n\n const scaleX = width / 1600; // Scale based on a reference width of 1600px\n const scaleY = height / 900; // Scale based on a reference height of 900px\n const scale = Math.min(scaleX, scaleY);\n\n // Center the container and apply scaling\n container.style.transform = `translate(-50%, -50%) scale(${scale})`;\n }\n\n /**\n * Lifecycle hook that runs after the component is loaded.\n * - It scales the container.\n * - It sets the background color of the body.\n * - Adds event listeners for `resize` and `load` to rescale the container on window size changes.\n */\n componentDidLoad() {\n this.scaleContainer(this.el);\n document.body.style.backgroundColor = this.bgColor;\n\n // Re-scale the container on window resize or load events\n window.addEventListener('resize', () => this.scaleContainer(this.el));\n window.addEventListener('load', () => this.scaleContainer(this.el));\n initEventsForElement(this.el, this.type);\n }\n\n render() {\n // Define the styles for the container element\n const style = {\n backgroundColor: this.bgColor,\n width: '1600px', // Fixed width of the container\n height: '900px', // Fixed height of the container\n position: 'absolute',\n top: '50%',\n left: '50%',\n transform: 'translate(-50%, -50%)', // Centering the container\n };\n console.log('🚀 ~ AppContainer ~ canplay:', this.canplay);\n\n return (\n <Host\n id=\"container\"\n tabindex={0}\n class=\"container\"\n objective={this.objective}\n style={style}\n aria-label={this.ariaLabel}\n aria-hidden={this.ariaHidden}\n onTouch={this.onTouch}\n onMatch={this.onMatch}\n onWrong={this.onWrong}\n onIncorrectTouch={this.onIncorrectTouch}\n onCorrectMatch={this.onCorrectMatch}\n onCorrectTouch={this.onCorrectTouch}\n onEntry={this.onEntry}\n >\n <slot />\n </Host>\n );\n }\n}\n"],"version":3}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"file":"app-globals-0f993ce5.js","mappings":"AAAY,MAAC,aAAa,GAAG,MAAM;;;;","names":[],"sources":["@stencil/core/internal/app-globals"],"sourcesContent":["export const globalScripts = () => {};\n"],"version":3}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { r as registerInstance, h } from './index-9624adf5.js';
|
|
2
|
+
import { S as SelectedValuesKey, D as DragSelectedMapKey } from './constants-f484fcec.js';
|
|
3
|
+
|
|
4
|
+
const indexCss = "@import url('https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap'); body{overflow:hidden}";
|
|
5
|
+
|
|
6
|
+
const animationCss = "@keyframes rightToPlace{from{transform:translateX(2000px)}to{left:0}}@keyframes placeToLeft{from{}to{transform:translateX(-2000px)}}@keyframes shake{0%{transform:translateX(0);color:red;outline:4px solid red}10%{transform:translateX(-5px);color:red;outline:4px solid red}20%{transform:translateX(5px);color:red;outline:4px solid red}30%{transform:translateX(-5px);color:red;outline:4px solid red}40%{transform:translateX(5px);color:red;outline:4px solid red}50%{transform:translateX(-5px);color:red;outline:4px solid red}60%{transform:translateX(5px);color:red;outline:4px solid red}70%{transform:translateX(-5px);color:red;outline:4px solid red}80%{transform:translateX(5px);color:red;outline:4px solid red}90%{transform:translateX(-5px);color:red;outline:4px solid red}100%{transform:translateX(0);color:red;outline:4px solid red}}@keyframes fallAndBounce{0%{transform:translateY(-1000px)}25%{transform:translateY(0px)}50%{transform:translateY(-200px)}75%{transform:translateY(0)}90%{transform:translateY(-100px)}100%{transform:translateY(0)}}";
|
|
7
|
+
|
|
8
|
+
const appHomeCss = ".snackbar{visibility:visible;min-width:250px;background-color:#333;color:#fff;text-align:center;border-radius:2px;padding:16px;position:fixed;z-index:1;bottom:30px;left:50%;transform:translateX(-50%);font-size:17px}.dot-container{text-align:center;position:fixed;z-index:1;width:fit-content;top:1%;left:50%;transform:translate(-50%)}.dot{height:15px;width:15px;margin:0 4px;background-color:#bbb;border-radius:50%;display:inline-block;transition:background-color 0.3s;cursor:pointer}.dot.completed{background-color:grey}.dot.current{background-color:green}.dot:not(.completed):not(.current){background-color:#bbb}";
|
|
9
|
+
|
|
10
|
+
const AppHome = class {
|
|
11
|
+
constructor(hostRef) {
|
|
12
|
+
registerInstance(this, hostRef);
|
|
13
|
+
/**
|
|
14
|
+
* Event handler for transitioning to the next container in the sequence.
|
|
15
|
+
* If the last container is reached, it shows a completion message.
|
|
16
|
+
*/
|
|
17
|
+
this.nextContainer = (index) => {
|
|
18
|
+
if (index != undefined && index == this.currentContainerIndex)
|
|
19
|
+
return;
|
|
20
|
+
// Clear selected values from localStorage on container transition
|
|
21
|
+
localStorage.removeItem(SelectedValuesKey);
|
|
22
|
+
localStorage.removeItem(DragSelectedMapKey);
|
|
23
|
+
if (index != undefined && index < this.containers.length) {
|
|
24
|
+
// Move to the next container
|
|
25
|
+
this.currentContainerIndex = index;
|
|
26
|
+
window.dispatchEvent(new CustomEvent('activityChange', { detail: { index: this.currentContainerIndex } }));
|
|
27
|
+
}
|
|
28
|
+
else if (this.currentContainerIndex < this.containers.length - 1) {
|
|
29
|
+
// Move to the next container
|
|
30
|
+
this.currentContainerIndex++;
|
|
31
|
+
window.dispatchEvent(new CustomEvent('activityChange', { detail: { index: this.currentContainerIndex } }));
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
// Show the completion message if all containers have been viewed
|
|
35
|
+
this.showCompletionMessage = true;
|
|
36
|
+
const event = new CustomEvent('gameCompleted');
|
|
37
|
+
window.dispatchEvent(event);
|
|
38
|
+
// Hide the completion message after 3 seconds
|
|
39
|
+
setTimeout(() => {
|
|
40
|
+
this.showCompletionMessage = false;
|
|
41
|
+
}, 3000);
|
|
42
|
+
}
|
|
43
|
+
// Reset the containers array to trigger a re-render
|
|
44
|
+
this.containers = [...this.containers];
|
|
45
|
+
};
|
|
46
|
+
this.xmlData = undefined;
|
|
47
|
+
this.initialIndex = 0;
|
|
48
|
+
this.canplay = true;
|
|
49
|
+
this.currentContainerIndex = this.initialIndex;
|
|
50
|
+
this.showCompletionMessage = false;
|
|
51
|
+
this.containers = [];
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Lifecycle method that runs before the component is loaded. It sets up event listeners for transitioning
|
|
55
|
+
* between containers and parses the XML data into containers.
|
|
56
|
+
*/
|
|
57
|
+
componentWillLoad() {
|
|
58
|
+
// Listen for 'nextContainer' event to transition between containers
|
|
59
|
+
window.addEventListener('nextContainer', () => {
|
|
60
|
+
this.nextContainer();
|
|
61
|
+
});
|
|
62
|
+
window.addEventListener('changeContainer', (e) => {
|
|
63
|
+
this.nextContainer(e.detail.index);
|
|
64
|
+
});
|
|
65
|
+
// Parse the provided XML data
|
|
66
|
+
this.parseXMLData(this.xmlData);
|
|
67
|
+
// Remove stored values in localStorage when the page is about to be unloaded
|
|
68
|
+
window.addEventListener('beforeunload', () => {
|
|
69
|
+
localStorage.removeItem(SelectedValuesKey);
|
|
70
|
+
localStorage.removeItem(DragSelectedMapKey);
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Lifecycle method that cleans up event listeners when the component is removed from the DOM.
|
|
75
|
+
*/
|
|
76
|
+
disconnectedCallback() {
|
|
77
|
+
window.removeEventListener('nextContainer', () => {
|
|
78
|
+
this.nextContainer();
|
|
79
|
+
});
|
|
80
|
+
window.removeEventListener('changeContainer', (e) => {
|
|
81
|
+
this.nextContainer(e.detail.index);
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Parses the provided XML string into an XML DOM object and extracts the containers from it.
|
|
86
|
+
*
|
|
87
|
+
* @param xmlData - The XML data as a string.
|
|
88
|
+
*/
|
|
89
|
+
parseXMLData(xmlData) {
|
|
90
|
+
if (xmlData) {
|
|
91
|
+
const parser = new DOMParser();
|
|
92
|
+
const xmlDoc = parser.parseFromString(xmlData, 'text/xml');
|
|
93
|
+
const rootElement = xmlDoc.documentElement;
|
|
94
|
+
// Parse containers from the root XML element
|
|
95
|
+
this.parseContainers(rootElement);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Recursively parses an XML element and its children, converting them into corresponding Stencil components.
|
|
100
|
+
*
|
|
101
|
+
* @param element - The XML element to parse.
|
|
102
|
+
* @returns The corresponding Stencil component with parsed props and children.
|
|
103
|
+
*/
|
|
104
|
+
parseElement(element) {
|
|
105
|
+
const tagName = element.nodeName.toLowerCase();
|
|
106
|
+
const props = {};
|
|
107
|
+
// Extract attributes from the element and map them to props
|
|
108
|
+
Array.from(element.attributes).forEach(attr => {
|
|
109
|
+
props[attr.name] = attr.value;
|
|
110
|
+
});
|
|
111
|
+
// Recursively parse child elements
|
|
112
|
+
const children = Array.from(element.childNodes)
|
|
113
|
+
.map(child => {
|
|
114
|
+
if (child.nodeType === 1) {
|
|
115
|
+
return this.parseElement(child);
|
|
116
|
+
}
|
|
117
|
+
else if (child.nodeType === 3 && child.textContent.trim() !== '') {
|
|
118
|
+
return child.textContent;
|
|
119
|
+
}
|
|
120
|
+
return null;
|
|
121
|
+
})
|
|
122
|
+
.filter(Boolean);
|
|
123
|
+
// Map XML tags to Stencil components
|
|
124
|
+
const componentMapping = {
|
|
125
|
+
'app-container': (h("app-container", Object.assign({}, props, { canplay: this.canplay }), children)),
|
|
126
|
+
'app-col': h("app-col", Object.assign({}, props), children),
|
|
127
|
+
'app-trace': h("app-trace", Object.assign({}, props), children),
|
|
128
|
+
'app-image': h("app-image", Object.assign({}, props), children),
|
|
129
|
+
'app-row': h("app-row", Object.assign({}, props), children),
|
|
130
|
+
'app-text': h("app-text", Object.assign({}, props), children),
|
|
131
|
+
'app-pos': h("app-pos", Object.assign({}, props), children),
|
|
132
|
+
'app-shape': h("app-shape", Object.assign({}, props), children),
|
|
133
|
+
'app-wrap': h("app-wrap", Object.assign({}, props), children),
|
|
134
|
+
'app-random': h("app-random", Object.assign({}, props), children),
|
|
135
|
+
};
|
|
136
|
+
// If the tag is known, return the corresponding Stencil component, otherwise log a warning
|
|
137
|
+
if (componentMapping[tagName]) {
|
|
138
|
+
return componentMapping[tagName];
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
console.warn(`Unknown tag: ${tagName}`);
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Parses the `app-container` elements from the XML root element and stores them in the `containers` state.
|
|
147
|
+
*
|
|
148
|
+
* @param rootElement - The root element of the parsed XML document.
|
|
149
|
+
*/
|
|
150
|
+
parseContainers(rootElement) {
|
|
151
|
+
const containers = [];
|
|
152
|
+
const containerElements = rootElement.querySelectorAll('app-container');
|
|
153
|
+
// Parse each container and add it to the array
|
|
154
|
+
containerElements.forEach(container => {
|
|
155
|
+
const parsedElement = this.parseElement(container);
|
|
156
|
+
if (parsedElement) {
|
|
157
|
+
containers.push(parsedElement);
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
this.containers = containers;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Renders navigation dots for each container, indicating the progress of the user.
|
|
164
|
+
* Clicking on a dot allows the user to jump to a specific container.
|
|
165
|
+
*/
|
|
166
|
+
renderDots() {
|
|
167
|
+
return (h("div", { id: "dot-indicator", class: "dot-container" }, this.containers.map((_, index) => (h("span", { class: `dot ${index < this.currentContainerIndex ? 'completed' : index === this.currentContainerIndex ? 'current' : ''}`, onClick: () => this.jumpToContainer(index) })))));
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Jumps to a specific container based on the index of the dot clicked.
|
|
171
|
+
*
|
|
172
|
+
* @param index - The index of the container to jump to.
|
|
173
|
+
*/
|
|
174
|
+
jumpToContainer(index) {
|
|
175
|
+
this.nextContainer(index);
|
|
176
|
+
// this.currentContainerIndex = index;
|
|
177
|
+
// this.containers = [...this.containers]; // Trigger re-render
|
|
178
|
+
}
|
|
179
|
+
render() {
|
|
180
|
+
if (!this.xmlData) {
|
|
181
|
+
// If no XML data is provided, prompt the user to provide it
|
|
182
|
+
return h("div", null, "Please provide XML data.");
|
|
183
|
+
}
|
|
184
|
+
return (h("div", null, h("div", { key: this.currentContainerIndex }, this.containers[this.currentContainerIndex]), this.renderDots(), this.showCompletionMessage && h("div", { class: "snackbar" }, "All containers have been displayed!")));
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
AppHome.style = indexCss + (animationCss + appHomeCss);
|
|
188
|
+
|
|
189
|
+
export { AppHome as app_home };
|
|
190
|
+
|
|
191
|
+
//# sourceMappingURL=app-home.entry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"file":"app-home.entry.esm.js","mappings":";;;AAAA,MAAM,QAAQ,GAAG,2NAA2N;;ACA5O,MAAM,YAAY,GAAG,uhCAAuhC;;ACA5iC,MAAM,UAAU,GAAG,umBAAumB;;MCe7mB,OAAO;;;;;;;QAmClB,kBAAa,GAAG,CAAC,KAA0B;YACzC,IAAI,KAAK,IAAI,SAAS,IAAI,KAAK,IAAI,IAAI,CAAC,qBAAqB;gBAAE,OAAO;;YAEtE,YAAY,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAC;YAC3C,YAAY,CAAC,UAAU,CAAC,kBAAkB,CAAC,CAAC;YAE5C,IAAI,KA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AW,CAAC,gBAAgB,CAAC,eAAe,CAAC,CAAC;;QAGxE,iBAAiB,CAAC,OAAO,CAAC,SAAS;YACjC,MAAM,aAAa,GAAG,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;YACnD,IAAI,aAAa,EAAE;gBACjB,UAAU,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;aAChC;SACF,CAAC,CAAC;QAEH,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;KAC9B;;;;;IAMO,UAAU;QAChB,QACE,WAAK,EAAE,EAAC,eAAe,EAAC,KAAK,EAAC,eAAe,IAC1C,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,MAC5B,YACE,KAAK,EAAE,OAAO,KAAK,GAAG,IAAI,CAAC,qBAAqB,GAAG,WAAW,GAAG,KAAK,KAAK,IAAI,CAAC,qBAAqB,GAAG,SAAS,GAAG,EAAE,EAAE,EACxH,OAAO,EAAE,MAAM,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,GACpC,CACT,CAAC,CACE,EACN;KACH;;;;;;IAOO,eAAe,CAAC,KAAa;QACnC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;;;KAG3B;IAED,MAAM;QACJ,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;;YAEjB,OAAO,0CAAmC,CAAC;SAC5C;QAED,QACE,eAEE,WAAK,GAAG,EAAE,IAAI,CAAC,qBAAqB,IAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAO,EAGxF,IAAI,CAAC,UAAU,EAAE,EAGjB,IAAI,CAAC,qBAAqB,IAAI,WAAK,KAAK,EAAC,UAAU,0CAA0C,CAC1F,EACN;KACH;;;;;;","names":[],"sources":["src/index.css?tag=app-home","src/utils/css/animation.css?tag=app-home","src/components/home/app-home.css?tag=app-home","src/components/home/AppHome.tsx"],"sourcesContent":["@import url('https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap');\n\nbody {\n overflow: hidden;\n}\n\n","/* animations */\n\n@keyframes rightToPlace {\n from {\n transform: translateX(2000px);\n }\n to {\n left: 0;\n }\n}\n\n@keyframes placeToLeft {\n from {\n }\n to {\n transform: translateX(-2000px);\n }\n}\n\n@keyframes shake {\n 0% {\n transform: translateX(0);\n color: red;\n outline: 4px solid red;\n }\n 10% {\n transform: translateX(-5px);\n color: red;\n outline: 4px solid red;\n }\n 20% {\n transform: translateX(5px);\n color: red;\n outline: 4px solid red;\n }\n 30% {\n transform: translateX(-5px);\n color: red;\n outline: 4px solid red;\n }\n 40% {\n transform: translateX(5px);\n color: red;\n outline: 4px solid red;\n }\n 50% {\n transform: translateX(-5px);\n color: red;\n outline: 4px solid red;\n }\n 60% {\n transform: translateX(5px);\n color: red;\n outline: 4px solid red;\n }\n 70% {\n transform: translateX(-5px);\n color: red;\n outline: 4px solid red;\n }\n 80% {\n transform: translateX(5px);\n color: red;\n outline: 4px solid red;\n }\n 90% {\n transform: translateX(-5px);\n color: red;\n outline: 4px solid red;\n }\n 100% {\n transform: translateX(0);\n color: red;\n outline: 4px solid red;\n }\n}\n\n@keyframes fallAndBounce {\n 0% {\n transform: translateY(-1000px);\n }\n 25%{\n transform: translateY(0px);\n }\n 50% {\n transform: translateY(-200px);\n }\n 75% {\n transform: translateY(0);\n }\n 90% {\n transform: translateY(-100px);\n }\n 100% {\n transform: translateY(0);\n }\n}\n",".snackbar {\n visibility: visible;\n min-width: 250px;\n background-color: #333;\n color: #fff;\n text-align: center;\n border-radius: 2px;\n padding: 16px;\n position: fixed;\n z-index: 1;\n bottom: 30px;\n left: 50%;\n transform: translateX(-50%);\n font-size: 17px;\n}\n\n.dot-container {\n text-align: center;\n position: fixed;\n z-index: 1;\n width: fit-content;\n top: 1%;\n left: 50%;\n transform: translate(-50%);\n}\n\n.dot {\n height: 15px;\n width: 15px;\n margin: 0 4px;\n background-color: #bbb;\n border-radius: 50%;\n display: inline-block;\n transition: background-color 0.3s;\n cursor: pointer;\n}\n\n.dot.completed {\n background-color: grey;\n}\n\n.dot.current {\n background-color: green;\n}\n\n.dot:not(.completed):not(.current) {\n background-color: #bbb;\n}\n","import { Component, Prop, h, State } from '@stencil/core';\nimport { DragSelectedMapKey, SelectedValuesKey } from '../../utils/constants';\n\n/**\n * @component AppHome\n *\n * The `AppHome` component renders a series of containers parsed from the provided XML data.\n * It handles navigation between containers, resets the state on page reloads or container transitions,\n * and displays progress indicators (dots) for each container.\n */\n@Component({\n tag: 'app-home',\n shadow: false,\n styleUrls: ['./../../index.css', '../../utils/css/animation.css', './app-home.css'],\n})\nexport class AppHome {\n /**\n * XML data passed to the component, which is parsed and used to render various containers.\n */\n @Prop() xmlData: string;\n\n /**\n * Initial index of the container being displayed.\n */\n @Prop() initialIndex: number = 0;\n\n /**\n * Boolean that controls the playability of the game.\n */\n @Prop() canplay: boolean = true;\n\n /**\n * Current index of the container being displayed.\n */\n @State() currentContainerIndex: number = this.initialIndex;\n\n /**\n * Boolean that controls the display of the completion message after all containers have been viewed.\n */\n @State() showCompletionMessage: boolean = false;\n\n /**\n * Array that stores the parsed containers from the XML data.\n */\n @State() containers: any[] = [];\n\n /**\n * Event handler for transitioning to the next container in the sequence.\n * If the last container is reached, it shows a completion message.\n */\n nextContainer = (index?: number | undefined) => {\n if (index != undefined && index == this.currentContainerIndex) return;\n // Clear selected values from localStorage on container transition\n localStorage.removeItem(SelectedValuesKey);\n localStorage.removeItem(DragSelectedMapKey);\n\n if (index != undefined && index < this.containers.length) {\n // Move to the next container\n this.currentContainerIndex = index;\n window.dispatchEvent(new CustomEvent('activityChange', { detail: { index: this.currentContainerIndex } }));\n } else if (this.currentContainerIndex < this.containers.length - 1) {\n // Move to the next container\n this.currentContainerIndex++;\n window.dispatchEvent(new CustomEvent('activityChange', { detail: { index: this.currentContainerIndex } }));\n } else {\n // Show the completion message if all containers have been viewed\n this.showCompletionMessage = true;\n const event = new CustomEvent('gameCompleted');\n window.dispatchEvent(event);\n\n // Hide the completion message after 3 seconds\n setTimeout(() => {\n this.showCompletionMessage = false;\n }, 3000);\n }\n\n // Reset the containers array to trigger a re-render\n this.containers = [...this.containers];\n };\n\n /**\n * Lifecycle method that runs before the component is loaded. It sets up event listeners for transitioning\n * between containers and parses the XML data into containers.\n */\n componentWillLoad() {\n // Listen for 'nextContainer' event to transition between containers\n window.addEventListener('nextContainer', () => {\n this.nextContainer();\n });\n\n window.addEventListener('changeContainer', (e: any) => {\n this.nextContainer(e.detail.index);\n });\n\n // Parse the provided XML data\n this.parseXMLData(this.xmlData);\n\n // Remove stored values in localStorage when the page is about to be unloaded\n window.addEventListener('beforeunload', () => {\n localStorage.removeItem(SelectedValuesKey);\n localStorage.removeItem(DragSelectedMapKey);\n });\n }\n\n /**\n * Lifecycle method that cleans up event listeners when the component is removed from the DOM.\n */\n disconnectedCallback() {\n window.removeEventListener('nextContainer', () => {\n this.nextContainer();\n });\n window.removeEventListener('changeContainer', (e: any) => {\n this.nextContainer(e.detail.index);\n });\n }\n\n /**\n * Parses the provided XML string into an XML DOM object and extracts the containers from it.\n *\n * @param xmlData - The XML data as a string.\n */\n private parseXMLData(xmlData: string) {\n if (xmlData) {\n const parser = new DOMParser();\n const xmlDoc = parser.parseFromString(xmlData, 'text/xml');\n const rootElement = xmlDoc.documentElement;\n\n // Parse containers from the root XML element\n this.parseContainers(rootElement);\n }\n }\n\n /**\n * Recursively parses an XML element and its children, converting them into corresponding Stencil components.\n *\n * @param element - The XML element to parse.\n * @returns The corresponding Stencil component with parsed props and children.\n */\n private parseElement(element: Element): any {\n const tagName = element.nodeName.toLowerCase();\n const props: { [key: string]: any } = {};\n\n // Extract attributes from the element and map them to props\n Array.from(element.attributes).forEach(attr => {\n props[attr.name] = attr.value;\n });\n\n // Recursively parse child elements\n const children = Array.from(element.childNodes)\n .map(child => {\n if (child.nodeType === 1) {\n return this.parseElement(child as Element);\n } else if (child.nodeType === 3 && child.textContent.trim() !== '') {\n return child.textContent;\n }\n return null;\n })\n .filter(Boolean);\n\n // Map XML tags to Stencil components\n const componentMapping = {\n 'app-container': (\n <app-container {...props} canplay={this.canplay}>\n {children}\n </app-container>\n ),\n 'app-col': <app-col {...props}>{children}</app-col>,\n 'app-trace': <app-trace {...props}>{children}</app-trace>,\n 'app-image': <app-image {...props}>{children}</app-image>,\n 'app-row': <app-row {...props}>{children}</app-row>,\n 'app-text': <app-text {...props}>{children}</app-text>,\n 'app-pos': <app-pos {...props}>{children}</app-pos>,\n 'app-shape': <app-shape {...props}>{children}</app-shape>,\n 'app-wrap': <app-wrap {...props}>{children}</app-wrap>,\n 'app-random': <app-random {...props}>{children}</app-random>,\n };\n\n // If the tag is known, return the corresponding Stencil component, otherwise log a warning\n if (componentMapping[tagName]) {\n return componentMapping[tagName];\n } else {\n console.warn(`Unknown tag: ${tagName}`);\n return null;\n }\n }\n\n /**\n * Parses the `app-container` elements from the XML root element and stores them in the `containers` state.\n *\n * @param rootElement - The root element of the parsed XML document.\n */\n private parseContainers(rootElement: Element) {\n const containers = [];\n const containerElements = rootElement.querySelectorAll('app-container');\n\n // Parse each container and add it to the array\n containerElements.forEach(container => {\n const parsedElement = this.parseElement(container);\n if (parsedElement) {\n containers.push(parsedElement);\n }\n });\n\n this.containers = containers;\n }\n\n /**\n * Renders navigation dots for each container, indicating the progress of the user.\n * Clicking on a dot allows the user to jump to a specific container.\n */\n private renderDots() {\n return (\n <div id=\"dot-indicator\" class=\"dot-container\">\n {this.containers.map((_, index) => (\n <span\n class={`dot ${index < this.currentContainerIndex ? 'completed' : index === this.currentContainerIndex ? 'current' : ''}`}\n onClick={() => this.jumpToContainer(index)}\n ></span>\n ))}\n </div>\n );\n }\n\n /**\n * Jumps to a specific container based on the index of the dot clicked.\n *\n * @param index - The index of the container to jump to.\n */\n private jumpToContainer(index: number) {\n this.nextContainer(index);\n // this.currentContainerIndex = index;\n // this.containers = [...this.containers]; // Trigger re-render\n }\n\n render() {\n if (!this.xmlData) {\n // If no XML data is provided, prompt the user to provide it\n return <div>Please provide XML data.</div>;\n }\n\n return (\n <div>\n {/* Render the current container */}\n <div key={this.currentContainerIndex}>{this.containers[this.currentContainerIndex]}</div>\n\n {/* Render navigation dots below the container */}\n {this.renderDots()}\n\n {/* Show completion message if all containers have been displayed */}\n {this.showCompletionMessage && <div class=\"snackbar\">All containers have been displayed!</div>}\n </div>\n );\n }\n}\n"],"version":3}
|