@vnejs/plugins.controllers.screens.gallery 0.0.0-stage → 0.2.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -0
- package/dist/index.js +31 -0
- package/dist/modules/controller.accept.d.ts +12 -0
- package/dist/modules/controller.accept.js +26 -0
- package/dist/modules/controller.audio.d.ts +11 -0
- package/dist/modules/controller.audio.js +10 -0
- package/dist/modules/controller.bg.d.ts +14 -0
- package/dist/modules/controller.bg.js +12 -0
- package/dist/modules/controller.d.ts +15 -0
- package/dist/modules/controller.grid.d.ts +20 -0
- package/dist/modules/controller.grid.js +25 -0
- package/dist/modules/controller.js +16 -0
- package/dist/modules/controller.pages.d.ts +12 -0
- package/dist/modules/controller.pages.items.d.ts +27 -0
- package/dist/modules/controller.pages.items.js +29 -0
- package/dist/modules/controller.pages.js +17 -0
- package/dist/modules/controller.preload.d.ts +28 -0
- package/dist/modules/controller.preload.js +29 -0
- package/dist/modules/controller.tabs.d.ts +33 -0
- package/dist/modules/controller.tabs.js +29 -0
- package/dist/modules/gallery.d.ts +10 -0
- package/dist/modules/gallery.js +14 -0
- package/dist/modules/hide.controls.d.ts +8 -0
- package/dist/modules/hide.controls.js +7 -0
- package/dist/modules/hide.state.d.ts +6 -0
- package/dist/modules/hide.state.js +5 -0
- package/dist/modules/view.d.ts +10 -0
- package/dist/modules/view.js +9 -0
- package/dist/types.d.ts +29 -0
- package/dist/types.js +1 -0
- package/dist/utils/gallery.d.ts +21 -0
- package/dist/utils/gallery.js +2 -0
- package/dist/view/components/GalleryClose.d.ts +2 -0
- package/dist/view/components/GalleryClose.js +3 -0
- package/dist/view/components/GalleryControls.d.ts +7 -0
- package/dist/view/components/GalleryControls.js +10 -0
- package/dist/view/components/GalleryItems.d.ts +7 -0
- package/dist/view/components/GalleryItems.js +22 -0
- package/dist/view/components/GalleryPages.d.ts +7 -0
- package/dist/view/components/GalleryPages.js +6 -0
- package/dist/view/components/index.d.ts +4 -0
- package/dist/view/components/index.js +4 -0
- package/dist/view/index.d.ts +3 -0
- package/dist/view/index.js +9 -0
- package/package.json +75 -4
- package/src/index.ts +35 -0
- package/src/modules/controller.accept.ts +41 -0
- package/src/modules/controller.audio.ts +16 -0
- package/src/modules/controller.bg.ts +25 -0
- package/src/modules/controller.grid.ts +41 -0
- package/src/modules/controller.pages.items.ts +47 -0
- package/src/modules/controller.pages.ts +28 -0
- package/src/modules/controller.preload.ts +48 -0
- package/src/modules/controller.tabs.ts +49 -0
- package/src/modules/controller.ts +28 -0
- package/src/modules/gallery.ts +25 -0
- package/src/modules/hide.controls.ts +17 -0
- package/src/modules/hide.state.ts +9 -0
- package/src/modules/view.ts +17 -0
- package/src/tests/accept.test.ts +98 -0
- package/src/tests/audio.test.ts +86 -0
- package/src/tests/controller.bg.test.ts +84 -0
- package/src/tests/gallery.test.ts +49 -0
- package/src/tests/grid.test.ts +189 -0
- package/src/tests/hide.controls.test.ts +55 -0
- package/src/tests/hide.state.test.ts +27 -0
- package/src/tests/pages.items.test.ts +48 -0
- package/src/tests/pages.test.ts +98 -0
- package/src/tests/preload.test.ts +75 -0
- package/src/tests/setup.ts +67 -0
- package/src/tests/tabs.test.ts +101 -0
- package/src/types.ts +42 -0
- package/src/utils/gallery.ts +26 -0
- package/src/view/components/GalleryClose.tsx +12 -0
- package/src/view/components/GalleryControls.tsx +26 -0
- package/src/view/components/GalleryItems.tsx +51 -0
- package/src/view/components/GalleryPages.tsx +24 -0
- package/src/view/components/index.ts +4 -0
- package/src/view/index.tsx +67 -0
- package/tsconfig.json +10 -0
- package/README.md +0 -3
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "@vnejs/contracts.controllers.screens.gallery";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import "@vnejs/contracts.controllers.screens.gallery";
|
|
2
|
+
import { regPlugin } from "@vnejs/registry";
|
|
3
|
+
import { PARAMS, PLUGIN_NAME, SUBSCRIBE_EVENTS } from "@vnejs/contracts.controllers.screens.gallery";
|
|
4
|
+
import { GalleryControllerAccept } from "./modules/controller.accept.js";
|
|
5
|
+
import { GalleryControllerAudio } from "./modules/controller.audio.js";
|
|
6
|
+
import { GalleryControllerBg } from "./modules/controller.bg.js";
|
|
7
|
+
import { GalleryControllerGrid } from "./modules/controller.grid.js";
|
|
8
|
+
import { GalleryController } from "./modules/controller.js";
|
|
9
|
+
import { GalleryControllerPagesItems } from "./modules/controller.pages.items.js";
|
|
10
|
+
import { GalleryControllerPages } from "./modules/controller.pages.js";
|
|
11
|
+
import { GalleryControllerPreload } from "./modules/controller.preload.js";
|
|
12
|
+
import { GalleryControllerTabs } from "./modules/controller.tabs.js";
|
|
13
|
+
import { Gallery } from "./modules/gallery.js";
|
|
14
|
+
import { GalleryHideControls } from "./modules/hide.controls.js";
|
|
15
|
+
import { GalleryHideState } from "./modules/hide.state.js";
|
|
16
|
+
import { GalleryView } from "./modules/view.js";
|
|
17
|
+
regPlugin(PLUGIN_NAME, { events: SUBSCRIBE_EVENTS, params: PARAMS }, [
|
|
18
|
+
GalleryControllerAudio,
|
|
19
|
+
GalleryController,
|
|
20
|
+
GalleryControllerAccept,
|
|
21
|
+
GalleryControllerBg,
|
|
22
|
+
GalleryControllerGrid,
|
|
23
|
+
GalleryControllerPages,
|
|
24
|
+
GalleryControllerPagesItems,
|
|
25
|
+
GalleryControllerPreload,
|
|
26
|
+
GalleryHideControls,
|
|
27
|
+
GalleryHideState,
|
|
28
|
+
GalleryControllerTabs,
|
|
29
|
+
Gallery,
|
|
30
|
+
GalleryView,
|
|
31
|
+
]);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ModuleControllerAccept } from "@vnejs/module.controller.accept";
|
|
2
|
+
import type { GalleryPluginConstants, GalleryPluginEvents, GalleryPluginParams, GalleryPluginSettings } from "../types.js";
|
|
3
|
+
import type { GalleryPluginState } from "../types.js";
|
|
4
|
+
export declare class GalleryControllerAccept extends ModuleControllerAccept<GalleryPluginEvents, GalleryPluginConstants, GalleryPluginSettings, GalleryPluginParams, GalleryPluginState> {
|
|
5
|
+
name: string;
|
|
6
|
+
EVENT_SHOW: "vne:gallery:show";
|
|
7
|
+
EVENT_HIDE: "vne:gallery:hide";
|
|
8
|
+
EVENT_ACCEPT: "vne:gallery:accept";
|
|
9
|
+
EVENT_UPDATE_STATE: "vne:gallery:update_state";
|
|
10
|
+
CONTROLS_ZINDEX: number;
|
|
11
|
+
onAccept: () => void;
|
|
12
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ModuleControllerAccept } from "@vnejs/module.controller.accept";
|
|
2
|
+
export class GalleryControllerAccept extends ModuleControllerAccept {
|
|
3
|
+
name = "gallery.controller.accept";
|
|
4
|
+
EVENT_SHOW = this.EVENTS.GALLERY.SHOW;
|
|
5
|
+
EVENT_HIDE = this.EVENTS.GALLERY.HIDE;
|
|
6
|
+
EVENT_ACCEPT = this.EVENTS.GALLERY.ACCEPT;
|
|
7
|
+
EVENT_UPDATE_STATE = this.EVENTS.GALLERY.UPDATE_STATE;
|
|
8
|
+
CONTROLS_ZINDEX = this.PARAMS.GALLERY.ZINDEX;
|
|
9
|
+
onAccept = () => {
|
|
10
|
+
const { gridRow, gridColumn, gridItems } = this.state;
|
|
11
|
+
if (gridRow == null || gridColumn == null)
|
|
12
|
+
return;
|
|
13
|
+
const index = gridColumn + gridRow * this.PARAMS.GALLERY.COLUMNS;
|
|
14
|
+
const item = gridItems?.[index];
|
|
15
|
+
if (!item || item.isStub || !item.isOpened)
|
|
16
|
+
return;
|
|
17
|
+
void this.emit(this.EVENTS.GALLERY.CHOOSE, {
|
|
18
|
+
index,
|
|
19
|
+
fullName: item.fullName,
|
|
20
|
+
mediaType: item.mediaType,
|
|
21
|
+
layerChildType: item.layerChildType,
|
|
22
|
+
isOpened: item.isOpened,
|
|
23
|
+
variants: item.variants,
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ModuleControllerAudio } from "@vnejs/module.controller.audio";
|
|
2
|
+
import type { GalleryPluginConstants, GalleryPluginEvents, GalleryPluginParams, GalleryPluginSettings } from "../types.js";
|
|
3
|
+
export declare class GalleryControllerAudio extends ModuleControllerAudio<GalleryPluginEvents, GalleryPluginConstants, GalleryPluginSettings, GalleryPluginParams> {
|
|
4
|
+
name: string;
|
|
5
|
+
AUDIO_NAME: string;
|
|
6
|
+
AUDIO_START_DURATION: number;
|
|
7
|
+
VOLUME_SETTING: "vne:music:volume";
|
|
8
|
+
EVENT_SHOW: "vne:gallery:show";
|
|
9
|
+
EVENT_HIDE: "vne:gallery:hide";
|
|
10
|
+
EVENT_LOAD: "vne:gallery:preload";
|
|
11
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ModuleControllerAudio } from "@vnejs/module.controller.audio";
|
|
2
|
+
export class GalleryControllerAudio extends ModuleControllerAudio {
|
|
3
|
+
name = "gallery.controller.audio";
|
|
4
|
+
AUDIO_NAME = this.PARAMS.GALLERY.AUDIO_NAME;
|
|
5
|
+
AUDIO_START_DURATION = this.PARAMS.GALLERY.TRANSITION;
|
|
6
|
+
VOLUME_SETTING = this.SETTINGS.MUSIC.VOLUME;
|
|
7
|
+
EVENT_SHOW = this.EVENTS.GALLERY.SHOW;
|
|
8
|
+
EVENT_HIDE = this.EVENTS.GALLERY.HIDE;
|
|
9
|
+
EVENT_LOAD = this.EVENTS.GALLERY.PRELOAD;
|
|
10
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ModuleControllerBg } from "@vnejs/module.controller.bg";
|
|
2
|
+
import type { GalleryPluginConstants, GalleryPluginEvents, GalleryPluginParams, GalleryPluginSettings } from "../types.js";
|
|
3
|
+
import type { GalleryPluginState } from "../types.js";
|
|
4
|
+
export declare class GalleryControllerBg extends ModuleControllerBg<GalleryPluginEvents, GalleryPluginConstants, GalleryPluginSettings, GalleryPluginParams, GalleryPluginState> {
|
|
5
|
+
name: string;
|
|
6
|
+
EVENT_SHOW: "vne:gallery:show";
|
|
7
|
+
EVENT_HIDE: "vne:gallery:hide";
|
|
8
|
+
EVENT_UPDATE_STATE: "vne:gallery:update_state";
|
|
9
|
+
EVENT_UPDATE_FAST: "vne:gallery:update_fast";
|
|
10
|
+
EVENT_PRELOAD: "vne:gallery:preload";
|
|
11
|
+
BGNAME: "save";
|
|
12
|
+
QUALITY_SETTING: "vne:canvas:quality";
|
|
13
|
+
IS_MEMORY_CLEARED_UPDATE_ENABLED: boolean;
|
|
14
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ModuleControllerBg } from "@vnejs/module.controller.bg";
|
|
2
|
+
export class GalleryControllerBg extends ModuleControllerBg {
|
|
3
|
+
name = "gallery.controller.bg";
|
|
4
|
+
EVENT_SHOW = this.EVENTS.GALLERY.SHOW;
|
|
5
|
+
EVENT_HIDE = this.EVENTS.GALLERY.HIDE;
|
|
6
|
+
EVENT_UPDATE_STATE = this.EVENTS.GALLERY.UPDATE_STATE;
|
|
7
|
+
EVENT_UPDATE_FAST = this.EVENTS.GALLERY.UPDATE_FAST;
|
|
8
|
+
EVENT_PRELOAD = this.EVENTS.GALLERY.PRELOAD;
|
|
9
|
+
BGNAME = this.PARAMS.GALLERY.BACKGROUND;
|
|
10
|
+
QUALITY_SETTING = this.SETTINGS.LAYER.QUALITY;
|
|
11
|
+
IS_MEMORY_CLEARED_UPDATE_ENABLED = true;
|
|
12
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ModuleController } from "@vnejs/module.components";
|
|
2
|
+
import type { GalleryPluginConstants, GalleryPluginEvents, GalleryPluginParams, GalleryPluginSettings } from "../types.js";
|
|
3
|
+
import type { GalleryPluginState } from "../types.js";
|
|
4
|
+
export declare class GalleryController extends ModuleController<GalleryPluginEvents, GalleryPluginConstants, GalleryPluginSettings, GalleryPluginParams, GalleryPluginState> {
|
|
5
|
+
name: string;
|
|
6
|
+
EVENT_UPDATE_VIEW: "vne:gallery:update";
|
|
7
|
+
EVENT_UPDATE_STATE: "vne:gallery:update_state";
|
|
8
|
+
EVENT_UPDATE_FAST: "vne:gallery:update_fast";
|
|
9
|
+
EVENT_UPDATE_FORCE: "vne:gallery:update_force";
|
|
10
|
+
EVENT_SHOW: "vne:gallery:show";
|
|
11
|
+
EVENT_HIDE: "vne:gallery:hide";
|
|
12
|
+
CONTROLS: {};
|
|
13
|
+
CONTROLS_INDEX: number;
|
|
14
|
+
onShowBefore: () => Promise<void>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ModuleControllerArrowsGrid } from "@vnejs/module.controller.arrows.grid";
|
|
2
|
+
import type { GalleryCurrentItem } from "../utils/gallery.js";
|
|
3
|
+
import type { GalleryPluginConstants, GalleryPluginEvents, GalleryPluginParams, GalleryPluginSettings } from "../types.js";
|
|
4
|
+
import type { GalleryPluginState } from "../types.js";
|
|
5
|
+
export declare class GalleryControllerGrid extends ModuleControllerArrowsGrid<GalleryPluginEvents, GalleryPluginConstants, GalleryPluginSettings, GalleryPluginParams, GalleryPluginState> {
|
|
6
|
+
name: string;
|
|
7
|
+
EVENT_SHOW: "vne:gallery:show";
|
|
8
|
+
EVENT_HIDE: "vne:gallery:hide";
|
|
9
|
+
EVENT_UPDATE_STATE: "vne:gallery:update_state";
|
|
10
|
+
EVENT_UPDATE_FAST: "vne:gallery:update_fast";
|
|
11
|
+
EVENT_GRID_NEXT: "vne:gallery:grid_next";
|
|
12
|
+
EVENT_GRID_PREV: "vne:gallery:grid_prev";
|
|
13
|
+
EVENT_GRID_CLEAR: "vne:gallery:grid_clear";
|
|
14
|
+
EVENT_GRID_UPDATE_ITEMS: "vne:gallery:grid_update_items";
|
|
15
|
+
CONTROLS_ZINDEX: number;
|
|
16
|
+
isDisableGridChangeVertical: boolean;
|
|
17
|
+
getMaxRows: () => number;
|
|
18
|
+
getMaxColumns: () => number;
|
|
19
|
+
getGridItems: () => Promise<GalleryCurrentItem[]>;
|
|
20
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ModuleControllerArrowsGrid } from "@vnejs/module.controller.arrows.grid";
|
|
2
|
+
export class GalleryControllerGrid extends ModuleControllerArrowsGrid {
|
|
3
|
+
name = "gallery.controller.grid";
|
|
4
|
+
EVENT_SHOW = this.EVENTS.GALLERY.SHOW;
|
|
5
|
+
EVENT_HIDE = this.EVENTS.GALLERY.HIDE;
|
|
6
|
+
EVENT_UPDATE_STATE = this.EVENTS.GALLERY.UPDATE_STATE;
|
|
7
|
+
EVENT_UPDATE_FAST = this.EVENTS.GALLERY.UPDATE_FAST;
|
|
8
|
+
EVENT_GRID_NEXT = this.EVENTS.GALLERY.GRID_NEXT;
|
|
9
|
+
EVENT_GRID_PREV = this.EVENTS.GALLERY.GRID_PREV;
|
|
10
|
+
EVENT_GRID_CLEAR = this.EVENTS.GALLERY.GRID_CLEAR;
|
|
11
|
+
EVENT_GRID_UPDATE_ITEMS = this.EVENTS.GALLERY.GRID_UPDATE_ITEMS;
|
|
12
|
+
CONTROLS_ZINDEX = this.PARAMS.GALLERY.ZINDEX;
|
|
13
|
+
isDisableGridChangeVertical = true;
|
|
14
|
+
getMaxRows = () => this.PARAMS.GALLERY.ROWS;
|
|
15
|
+
getMaxColumns = () => this.PARAMS.GALLERY.COLUMNS;
|
|
16
|
+
getGridItems = async () => {
|
|
17
|
+
const { gridIndex = 0, tab = "" } = this.state;
|
|
18
|
+
const itemsOnPage = this.getMaxRows() * this.getMaxColumns();
|
|
19
|
+
const content = this.PARAMS.GALLERY.TABS[tab]?.content.slice(gridIndex * itemsOnPage, (gridIndex + 1) * itemsOnPage) ?? [];
|
|
20
|
+
const items = (await Promise.all(content.map((entry) => this.emitOne(this.EVENTS.GALLERY.PAGE_ITEMS_GET, entry))));
|
|
21
|
+
while (items.length < itemsOnPage)
|
|
22
|
+
items.push({ isStub: true });
|
|
23
|
+
return items;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ModuleController } from "@vnejs/module.components";
|
|
2
|
+
export class GalleryController extends ModuleController {
|
|
3
|
+
name = "gallery.controller";
|
|
4
|
+
EVENT_UPDATE_VIEW = this.EVENTS.GALLERY.UPDATE;
|
|
5
|
+
EVENT_UPDATE_STATE = this.EVENTS.GALLERY.UPDATE_STATE;
|
|
6
|
+
EVENT_UPDATE_FAST = this.EVENTS.GALLERY.UPDATE_FAST;
|
|
7
|
+
EVENT_UPDATE_FORCE = this.EVENTS.GALLERY.UPDATE_FORCE;
|
|
8
|
+
EVENT_SHOW = this.EVENTS.GALLERY.SHOW;
|
|
9
|
+
EVENT_HIDE = this.EVENTS.GALLERY.HIDE;
|
|
10
|
+
CONTROLS = {};
|
|
11
|
+
CONTROLS_INDEX = this.PARAMS.GALLERY.ZINDEX;
|
|
12
|
+
onShowBefore = async () => {
|
|
13
|
+
const tab = Object.keys(this.PARAMS.GALLERY.TABS)[0];
|
|
14
|
+
await this.emit(this.EVENTS.GALLERY.TAB_SET, { tab, isForce: true, isUpdateView: false });
|
|
15
|
+
};
|
|
16
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ModuleControllerPages } from "@vnejs/module.controller.pages";
|
|
2
|
+
import type { GalleryPluginConstants, GalleryPluginEvents, GalleryPluginParams, GalleryPluginSettings } from "../types.js";
|
|
3
|
+
import type { GalleryPluginState } from "../types.js";
|
|
4
|
+
export declare class GalleryControllerPages extends ModuleControllerPages<GalleryPluginEvents, GalleryPluginConstants, GalleryPluginSettings, GalleryPluginParams, GalleryPluginState> {
|
|
5
|
+
name: string;
|
|
6
|
+
EVENT_PAGE_SET: "vne:gallery:page_set";
|
|
7
|
+
EVENT_PAGE_NEXT: "vne:gallery:grid_next";
|
|
8
|
+
EVENT_PAGE_PREV: "vne:gallery:grid_prev";
|
|
9
|
+
EVENT_UPDATE_STATE: "vne:gallery:update_state";
|
|
10
|
+
EVENT_UPDATE_FAST: "vne:gallery:update_fast";
|
|
11
|
+
applyPage: () => Promise<void>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ModuleCore } from "@vnejs/module.core";
|
|
2
|
+
import type { GalleryMapTabContentPayload } from "@vnejs/contracts.controllers.screens.gallery";
|
|
3
|
+
import type { GalleryPluginConstants, GalleryPluginEvents, GalleryPluginParams, GalleryPluginSettings } from "../types.js";
|
|
4
|
+
export declare class GalleryControllerPagesItems extends ModuleCore<GalleryPluginEvents, GalleryPluginConstants, GalleryPluginSettings, GalleryPluginParams> {
|
|
5
|
+
name: string;
|
|
6
|
+
subscribe: () => void;
|
|
7
|
+
onPageItemsGet: (payload?: GalleryMapTabContentPayload) => Promise<{
|
|
8
|
+
isOpened: boolean;
|
|
9
|
+
layerChildType: string | undefined;
|
|
10
|
+
fullName: string;
|
|
11
|
+
src: string;
|
|
12
|
+
mediaType: string;
|
|
13
|
+
variants: {
|
|
14
|
+
layerChildType: string;
|
|
15
|
+
name: string;
|
|
16
|
+
overlays: {
|
|
17
|
+
[k: string]: string;
|
|
18
|
+
};
|
|
19
|
+
isOpened: boolean;
|
|
20
|
+
}[] | {
|
|
21
|
+
isOpened: boolean;
|
|
22
|
+
layerChildType: string | undefined;
|
|
23
|
+
name: string;
|
|
24
|
+
}[];
|
|
25
|
+
}>;
|
|
26
|
+
loadImageMedia: (name: string, mediaType: string, quality: string | number) => Promise<HTMLImageElement>;
|
|
27
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ModuleCore } from "@vnejs/module.core";
|
|
2
|
+
import { normalizeGalleryOverlays, toGalleryMediaName } from "../utils/gallery.js";
|
|
3
|
+
export class GalleryControllerPagesItems extends ModuleCore {
|
|
4
|
+
name = "gallery.controller.pages.items";
|
|
5
|
+
subscribe = () => {
|
|
6
|
+
this.on(this.EVENTS.GALLERY.PAGE_ITEMS_GET, this.onPageItemsGet);
|
|
7
|
+
};
|
|
8
|
+
onPageItemsGet = async (payload = {}) => {
|
|
9
|
+
const { check, mediaType, layerChildType, name, fullName, variations = [] } = payload;
|
|
10
|
+
const checkKey = toGalleryMediaName(check, layerChildType);
|
|
11
|
+
const isOpened = Boolean(await this.emitOne(this.EVENTS.GALLERY.CHECK, { key: checkKey }));
|
|
12
|
+
const mediaName = toGalleryMediaName(name, layerChildType);
|
|
13
|
+
const src = isOpened ? (await this.loadImageMedia(mediaName, mediaType, this.shared.settings[this.SETTINGS.LAYER.QUALITY])).src : "";
|
|
14
|
+
const variationVariants = await Promise.all(variations.map(async ({ check: variationCheck, layerChildType: variationLayerChildType, name: variationName, overlays }) => {
|
|
15
|
+
const variationCheckKey = toGalleryMediaName(variationCheck ?? check, variationLayerChildType ?? layerChildType);
|
|
16
|
+
const isOpened = Boolean(await this.emitOne(this.EVENTS.GALLERY.CHECK, { key: variationCheckKey }));
|
|
17
|
+
return { layerChildType: variationLayerChildType, name: variationName, overlays: normalizeGalleryOverlays(overlays), isOpened };
|
|
18
|
+
}));
|
|
19
|
+
const variants = variationVariants.length ? variationVariants : [{ isOpened, layerChildType, name: fullName }];
|
|
20
|
+
return { isOpened, layerChildType, fullName, src, mediaType, variants };
|
|
21
|
+
};
|
|
22
|
+
loadImageMedia = (name, mediaType, quality) => this.emitOne(this.EVENTS.MEDIA.LOAD, {
|
|
23
|
+
type: this.CONST.MEDIA.TYPES.IMAGE,
|
|
24
|
+
priority: this.CONST.MEDIA.PRIORITIES.HIGH,
|
|
25
|
+
quality,
|
|
26
|
+
name,
|
|
27
|
+
mediaType,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ModuleControllerPages } from "@vnejs/module.controller.pages";
|
|
2
|
+
export class GalleryControllerPages extends ModuleControllerPages {
|
|
3
|
+
name = "gallery.controller.pages";
|
|
4
|
+
EVENT_PAGE_SET = this.EVENTS.GALLERY.PAGE_SET;
|
|
5
|
+
EVENT_PAGE_NEXT = this.EVENTS.GALLERY.GRID_NEXT;
|
|
6
|
+
EVENT_PAGE_PREV = this.EVENTS.GALLERY.GRID_PREV;
|
|
7
|
+
EVENT_UPDATE_STATE = this.EVENTS.GALLERY.UPDATE_STATE;
|
|
8
|
+
EVENT_UPDATE_FAST = this.EVENTS.GALLERY.UPDATE_FAST;
|
|
9
|
+
applyPage = async () => {
|
|
10
|
+
await this.emit(this.EVENT_UPDATE_STATE, {
|
|
11
|
+
gridIndex: this.state.pageIndex ?? 0,
|
|
12
|
+
gridsCount: this.state.pagesCount ?? 0,
|
|
13
|
+
});
|
|
14
|
+
await this.emit(this.EVENTS.GALLERY.GRID_UPDATE_ITEMS);
|
|
15
|
+
this.emit(this.EVENTS.MEMORY.CLEAR);
|
|
16
|
+
};
|
|
17
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ModuleCore } from "@vnejs/module.core";
|
|
2
|
+
import type { GalleryMapTabContentPayload } from "@vnejs/contracts.controllers.screens.gallery";
|
|
3
|
+
import type { GalleryPluginConstants, GalleryPluginEvents, GalleryPluginParams, GalleryPluginSettings } from "../types.js";
|
|
4
|
+
import type { GalleryPluginState } from "../types.js";
|
|
5
|
+
export declare class GalleryControllerPreload extends ModuleCore<GalleryPluginEvents, GalleryPluginConstants, GalleryPluginSettings, GalleryPluginParams, GalleryPluginState> {
|
|
6
|
+
name: string;
|
|
7
|
+
subscribe: () => void;
|
|
8
|
+
onPreload: () => Promise<unknown[]>;
|
|
9
|
+
onMemoryCleared: () => Promise<unknown[]> | undefined;
|
|
10
|
+
preloadItem: (entry: GalleryMapTabContentPayload) => Promise<unknown>;
|
|
11
|
+
getItemsOnPage: () => number;
|
|
12
|
+
getMaxPagesCount: (tab: string) => number;
|
|
13
|
+
getItemsInfo: (tab: string, page: number) => {
|
|
14
|
+
check: string;
|
|
15
|
+
mediaType: string;
|
|
16
|
+
layerChildType?: string;
|
|
17
|
+
name: string;
|
|
18
|
+
fullName: string;
|
|
19
|
+
variations?: {
|
|
20
|
+
layerChildType: string;
|
|
21
|
+
name: string;
|
|
22
|
+
overlays: {
|
|
23
|
+
[x: string]: string | number;
|
|
24
|
+
};
|
|
25
|
+
check?: string;
|
|
26
|
+
}[] | undefined;
|
|
27
|
+
}[];
|
|
28
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ModuleCore } from "@vnejs/module.core";
|
|
2
|
+
export class GalleryControllerPreload extends ModuleCore {
|
|
3
|
+
name = "gallery.controller.preload";
|
|
4
|
+
subscribe = () => {
|
|
5
|
+
this.on(this.EVENTS.GALLERY.PRELOAD, this.onPreload);
|
|
6
|
+
this.on(this.EVENTS.GALLERY.UPDATE_STATE, this.updateState);
|
|
7
|
+
this.on(this.EVENTS.MEMORY.CLEARED, this.onMemoryCleared);
|
|
8
|
+
};
|
|
9
|
+
onPreload = () => Promise.all(this.getItemsInfo(Object.keys(this.PARAMS.GALLERY.TABS)[0], 0).map(this.preloadItem));
|
|
10
|
+
onMemoryCleared = () => {
|
|
11
|
+
if (!this.state.isShow)
|
|
12
|
+
return;
|
|
13
|
+
const { pageIndex = 0, tab = "" } = this.state;
|
|
14
|
+
const promises = [...this.getItemsInfo(tab, pageIndex).map(this.preloadItem)];
|
|
15
|
+
if (pageIndex > 0)
|
|
16
|
+
promises.push(...this.getItemsInfo(tab, pageIndex - 1).map(this.preloadItem));
|
|
17
|
+
if (pageIndex + 1 < this.getMaxPagesCount(tab))
|
|
18
|
+
promises.push(...this.getItemsInfo(tab, pageIndex + 1).map(this.preloadItem));
|
|
19
|
+
Object.keys(this.PARAMS.GALLERY.TABS).forEach((otherTab) => otherTab !== tab && promises.push(...this.getItemsInfo(otherTab, 0).map(this.preloadItem)));
|
|
20
|
+
return Promise.all(promises);
|
|
21
|
+
};
|
|
22
|
+
preloadItem = (entry) => this.emitOne(this.EVENTS.GALLERY.PAGE_ITEMS_GET, entry);
|
|
23
|
+
getItemsOnPage = () => this.PARAMS.GALLERY.ROWS * this.PARAMS.GALLERY.COLUMNS;
|
|
24
|
+
getMaxPagesCount = (tab) => Math.ceil((this.PARAMS.GALLERY.TABS[tab]?.content.length ?? 0) / this.getItemsOnPage());
|
|
25
|
+
getItemsInfo = (tab, page) => {
|
|
26
|
+
const itemsOnPage = this.getItemsOnPage();
|
|
27
|
+
return this.PARAMS.GALLERY.TABS[tab].content.slice(page * itemsOnPage, (page + 1) * itemsOnPage);
|
|
28
|
+
};
|
|
29
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ModuleControllerTabs } from "@vnejs/module.controller.tabs";
|
|
2
|
+
import type { ModuleControllerTabsTabSetPayload } from "@vnejs/module.controller.tabs";
|
|
3
|
+
import type { GalleryPluginConstants, GalleryPluginEvents, GalleryPluginParams, GalleryPluginSettings } from "../types.js";
|
|
4
|
+
import type { GalleryPluginState } from "../types.js";
|
|
5
|
+
export declare class GalleryControllerTabs extends ModuleControllerTabs<GalleryPluginEvents, GalleryPluginConstants, GalleryPluginSettings, GalleryPluginParams, GalleryPluginState> {
|
|
6
|
+
name: string;
|
|
7
|
+
EVENT_SHOW: "vne:gallery:show";
|
|
8
|
+
EVENT_HIDE: "vne:gallery:hide";
|
|
9
|
+
EVENT_TAB_SET: "vne:gallery:tab_set";
|
|
10
|
+
EVENT_UPDATE_STATE: "vne:gallery:update_state";
|
|
11
|
+
CONTROLS_ZINDEX: number;
|
|
12
|
+
TABS: {
|
|
13
|
+
[x: string]: {
|
|
14
|
+
locKey: string;
|
|
15
|
+
content: {
|
|
16
|
+
check: string;
|
|
17
|
+
mediaType: string;
|
|
18
|
+
layerChildType?: string;
|
|
19
|
+
name: string;
|
|
20
|
+
fullName: string;
|
|
21
|
+
variations?: {
|
|
22
|
+
layerChildType: string;
|
|
23
|
+
name: string;
|
|
24
|
+
overlays: {
|
|
25
|
+
[x: string]: string | number;
|
|
26
|
+
};
|
|
27
|
+
check?: string;
|
|
28
|
+
}[] | undefined;
|
|
29
|
+
}[];
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
onTabSet: (payload?: ModuleControllerTabsTabSetPayload) => Promise<void>;
|
|
33
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ModuleControllerTabs } from "@vnejs/module.controller.tabs";
|
|
2
|
+
export class GalleryControllerTabs extends ModuleControllerTabs {
|
|
3
|
+
name = "gallery.controller.tabs";
|
|
4
|
+
EVENT_SHOW = this.EVENTS.GALLERY.SHOW;
|
|
5
|
+
EVENT_HIDE = this.EVENTS.GALLERY.HIDE;
|
|
6
|
+
EVENT_TAB_SET = this.EVENTS.GALLERY.TAB_SET;
|
|
7
|
+
EVENT_UPDATE_STATE = this.EVENTS.GALLERY.UPDATE_STATE;
|
|
8
|
+
CONTROLS_ZINDEX = this.PARAMS.GALLERY.ZINDEX;
|
|
9
|
+
TABS = this.PARAMS.GALLERY.TABS;
|
|
10
|
+
onTabSet = async (payload = {}) => {
|
|
11
|
+
const { isUpdateView = true } = payload;
|
|
12
|
+
const tab = this.state.tab;
|
|
13
|
+
const itemsOnPage = this.PARAMS.GALLERY.ROWS * this.PARAMS.GALLERY.COLUMNS;
|
|
14
|
+
const gridsCount = Math.ceil((this.PARAMS.GALLERY.TABS[tab]?.content.length ?? 0) / itemsOnPage);
|
|
15
|
+
await this.emit(this.EVENTS.GALLERY.UPDATE_STATE, {
|
|
16
|
+
tab,
|
|
17
|
+
pageIndex: 0,
|
|
18
|
+
pagesCount: gridsCount,
|
|
19
|
+
gridIndex: 0,
|
|
20
|
+
gridsCount,
|
|
21
|
+
});
|
|
22
|
+
await this.emit(this.EVENTS.GALLERY.GRID_CLEAR);
|
|
23
|
+
await this.emit(this.EVENTS.GALLERY.GRID_UPDATE_ITEMS);
|
|
24
|
+
if (!isUpdateView)
|
|
25
|
+
return;
|
|
26
|
+
await this.emit(this.EVENTS.GALLERY.UPDATE_FAST);
|
|
27
|
+
this.emit(this.EVENTS.MEMORY.CLEAR);
|
|
28
|
+
};
|
|
29
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ModuleCore } from "@vnejs/module.core";
|
|
2
|
+
import type { GalleryCheckPayload, GalleryOpenPayload } from "@vnejs/contracts.controllers.screens.gallery";
|
|
3
|
+
import type { GalleryPluginConstants, GalleryPluginEvents, GalleryPluginParams, GalleryPluginSettings } from "../types.js";
|
|
4
|
+
export declare class Gallery extends ModuleCore<GalleryPluginEvents, GalleryPluginConstants, GalleryPluginSettings, GalleryPluginParams> {
|
|
5
|
+
name: string;
|
|
6
|
+
subscribe: () => void;
|
|
7
|
+
onOpen: ({ key }?: GalleryOpenPayload) => Promise<import("@vnejs/registry").EmitResults<"vne:storage:set">> | undefined;
|
|
8
|
+
onCheck: ({ key }?: GalleryCheckPayload) => Promise<boolean>;
|
|
9
|
+
onClear: () => Promise<import("@vnejs/registry").EmitResults<"vne:storage:rm_all">> | undefined;
|
|
10
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ModuleCore } from "@vnejs/module.core";
|
|
2
|
+
const STORAGE_VALUE = 1;
|
|
3
|
+
const isEqualStorageValueFunc = (value) => value === STORAGE_VALUE;
|
|
4
|
+
export class Gallery extends ModuleCore {
|
|
5
|
+
name = "gallery";
|
|
6
|
+
subscribe = () => {
|
|
7
|
+
this.on(this.EVENTS.GALLERY.OPEN, this.onOpen);
|
|
8
|
+
this.on(this.EVENTS.GALLERY.CHECK, this.onCheck);
|
|
9
|
+
this.on(this.EVENTS.GALLERY.CLEAR, this.onClear);
|
|
10
|
+
};
|
|
11
|
+
onOpen = ({ key } = {}) => this.emit(this.EVENTS.STORAGE.SET, { module: this.name, key, value: STORAGE_VALUE });
|
|
12
|
+
onCheck = ({ key } = {}) => this.emitOne(this.EVENTS.STORAGE.GET, { module: this.name, key }).then(isEqualStorageValueFunc);
|
|
13
|
+
onClear = () => this.emit(this.EVENTS.STORAGE.RM_ALL, { module: this.name });
|
|
14
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ModuleControllerHideOnControls } from "@vnejs/module.controller.hide.on.controls";
|
|
2
|
+
import type { GalleryPluginConstants, GalleryPluginEvents, GalleryPluginParams, GalleryPluginSettings } from "../types.js";
|
|
3
|
+
export declare class GalleryHideControls extends ModuleControllerHideOnControls<GalleryPluginEvents, GalleryPluginConstants, GalleryPluginSettings, GalleryPluginParams> {
|
|
4
|
+
name: string;
|
|
5
|
+
EVENT_SHOW: "vne:gallery:show";
|
|
6
|
+
EVENT_HIDE: "vne:gallery:hide";
|
|
7
|
+
CONTROLS_ZINDEX: number;
|
|
8
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ModuleControllerHideOnControls } from "@vnejs/module.controller.hide.on.controls";
|
|
2
|
+
export class GalleryHideControls extends ModuleControllerHideOnControls {
|
|
3
|
+
name = "gallery.hide.controls";
|
|
4
|
+
EVENT_SHOW = this.EVENTS.GALLERY.SHOW;
|
|
5
|
+
EVENT_HIDE = this.EVENTS.GALLERY.HIDE;
|
|
6
|
+
CONTROLS_ZINDEX = this.PARAMS.GALLERY.ZINDEX;
|
|
7
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ModuleControllerHideOnState } from "@vnejs/module.controller.hide.on.state";
|
|
2
|
+
import type { GalleryPluginConstants, GalleryPluginEvents, GalleryPluginParams, GalleryPluginSettings } from "../types.js";
|
|
3
|
+
export declare class GalleryHideState extends ModuleControllerHideOnState<GalleryPluginEvents, GalleryPluginConstants, GalleryPluginSettings, GalleryPluginParams> {
|
|
4
|
+
name: string;
|
|
5
|
+
EVENT_HIDE: "vne:gallery:hide";
|
|
6
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ModuleView } from "@vnejs/module.components";
|
|
2
|
+
import type { GalleryPluginConstants, GalleryPluginEvents, GalleryPluginParams, GalleryPluginSettings } from "../types.js";
|
|
3
|
+
import type { GalleryPluginState } from "../types.js";
|
|
4
|
+
export declare class GalleryView extends ModuleView<GalleryPluginEvents, GalleryPluginConstants, GalleryPluginSettings, GalleryPluginParams, GalleryPluginState> {
|
|
5
|
+
name: string;
|
|
6
|
+
EVENT_UPDATE_VIEW: "vne:gallery:update";
|
|
7
|
+
LOC_LABEL: string;
|
|
8
|
+
TRANSITION: number;
|
|
9
|
+
renderFunc: import("@vnejs/module.components").ViewRenderFunc<GalleryPluginState>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ModuleView } from "@vnejs/module.components";
|
|
2
|
+
import { render } from "../view/index.js";
|
|
3
|
+
export class GalleryView extends ModuleView {
|
|
4
|
+
name = "gallery.view";
|
|
5
|
+
EVENT_UPDATE_VIEW = this.EVENTS.GALLERY.UPDATE;
|
|
6
|
+
LOC_LABEL = this.PARAMS.GALLERY.LOC_LABEL;
|
|
7
|
+
TRANSITION = this.PARAMS.GALLERY.TRANSITION;
|
|
8
|
+
renderFunc = render;
|
|
9
|
+
}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ModuleComponentsConstants, ModuleComponentsEvents, ModuleComponentsParams, ModuleComponentsSettings } from "@vnejs/module.components";
|
|
2
|
+
import type { PluginName as AudioPluginName, SubscribeEvents as AudioSubscribeEvents } from "@vnejs/contracts.audio";
|
|
3
|
+
import type { PluginName as MusicPluginName, SettingsKeys as MusicSettingsKeys } from "@vnejs/contracts.audio.music";
|
|
4
|
+
import type { SettingsKeys as LayerSettingsKeys, PluginName as LayerPluginName } from "@vnejs/contracts.canvas.layer";
|
|
5
|
+
import type { Params, PluginName, SubscribeEvents } from "@vnejs/contracts.controllers.screens.gallery";
|
|
6
|
+
import type { Constants as ControlsConstants, PluginName as ControlsPluginName } from "@vnejs/contracts.controls";
|
|
7
|
+
import type { PluginName as MemoryPluginName, SubscribeEvents as MemorySubscribeEvents } from "@vnejs/contracts.core.memory";
|
|
8
|
+
import type { PluginName as StatePluginName, SubscribeEvents as StateSubscribeEvents } from "@vnejs/contracts.core.state";
|
|
9
|
+
import type { PluginName as StoragePluginName, SubscribeEvents as StorageSubscribeEvents } from "@vnejs/contracts.core.storage";
|
|
10
|
+
import type { PluginName as SystemPluginName, SubscribeEvents as SystemSubscribeEvents } from "@vnejs/contracts.core.system";
|
|
11
|
+
import type { GalleryCurrentItem } from "./utils/gallery.js";
|
|
12
|
+
export type GalleryPluginEvents = ModuleComponentsEvents & Record<PluginName, SubscribeEvents> & Record<AudioPluginName, AudioSubscribeEvents> & Record<StoragePluginName, StorageSubscribeEvents> & Record<MemoryPluginName, MemorySubscribeEvents> & Record<StatePluginName, StateSubscribeEvents> & Record<SystemPluginName, SystemSubscribeEvents>;
|
|
13
|
+
export type GalleryPluginConstants = ModuleComponentsConstants & Record<ControlsPluginName, ControlsConstants>;
|
|
14
|
+
export type GalleryPluginSettings = ModuleComponentsSettings & Record<LayerPluginName, LayerSettingsKeys> & Record<MusicPluginName, MusicSettingsKeys>;
|
|
15
|
+
export type GalleryPluginParams = ModuleComponentsParams & Record<PluginName, Params>;
|
|
16
|
+
export type GalleryPluginState = {
|
|
17
|
+
isShow: boolean;
|
|
18
|
+
isForce: boolean;
|
|
19
|
+
locs?: Record<string, string>;
|
|
20
|
+
bgSrc?: string;
|
|
21
|
+
tab?: string;
|
|
22
|
+
pageIndex?: number;
|
|
23
|
+
pagesCount?: number;
|
|
24
|
+
gridRow?: number | null;
|
|
25
|
+
gridColumn?: number | null;
|
|
26
|
+
gridItems?: GalleryCurrentItem[];
|
|
27
|
+
gridIndex?: number;
|
|
28
|
+
gridsCount?: number;
|
|
29
|
+
};
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Module } from "@vnejs/module";
|
|
2
|
+
import type { GalleryCurrentVariant } from "@vnejs/contracts.controllers.screens.gallery";
|
|
3
|
+
import type { GalleryPluginConstants, GalleryPluginEvents, GalleryPluginParams, GalleryPluginSettings, GalleryPluginState } from "../types.js";
|
|
4
|
+
export type GalleryCurrentItem = {
|
|
5
|
+
isStub?: boolean;
|
|
6
|
+
isOpened?: boolean;
|
|
7
|
+
layerChildType?: string;
|
|
8
|
+
fullName?: string;
|
|
9
|
+
src?: string;
|
|
10
|
+
mediaType?: string;
|
|
11
|
+
variants?: GalleryCurrentVariant[];
|
|
12
|
+
};
|
|
13
|
+
export type GalleryViewContext = {
|
|
14
|
+
emit: Module<GalleryPluginEvents, GalleryPluginConstants, GalleryPluginSettings, GalleryPluginParams, GalleryPluginState>["emit"];
|
|
15
|
+
EVENTS: GalleryPluginEvents;
|
|
16
|
+
PARAMS: GalleryPluginParams;
|
|
17
|
+
};
|
|
18
|
+
export declare const normalizeGalleryOverlays: (overlays?: Record<string, string | number>) => {
|
|
19
|
+
[k: string]: string;
|
|
20
|
+
};
|
|
21
|
+
export declare const toGalleryMediaName: (name?: string, layerChildType?: string) => string;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { PositionBox, Svg } from "@vnejs/uis.react";
|
|
3
|
+
export const GalleryClose = ({ emit, EVENTS, PARAMS }) => (_jsx(PositionBox, { ...PARAMS.GALLERY.VIEW_PROPS.close.position, children: _jsx(Svg.Cross, { ...PARAMS.GALLERY.VIEW_PROPS.close.svg, onClick: () => void emit(EVENTS.GALLERY.HIDE) }) }));
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { GalleryViewContext } from "../../utils/gallery.js";
|
|
2
|
+
type GalleryControlsProps = GalleryViewContext & {
|
|
3
|
+
locs: Record<string, string>;
|
|
4
|
+
tab: string;
|
|
5
|
+
};
|
|
6
|
+
export declare const GalleryControls: ({ locs, tab, emit, EVENTS, PARAMS }: GalleryControlsProps) => import("react").JSX.Element;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { PositionBox, TextControls } from "@vnejs/uis.react";
|
|
3
|
+
export const GalleryControls = ({ locs, tab, emit, EVENTS, PARAMS }) => {
|
|
4
|
+
const texts = Object.keys(PARAMS.GALLERY.TABS).map((key) => ({ text: locs[PARAMS.GALLERY.TABS[key].locKey], value: key }));
|
|
5
|
+
const selectedIndex = Object.keys(PARAMS.GALLERY.TABS).findIndex((key) => key === tab);
|
|
6
|
+
return (_jsx(PositionBox, { ...PARAMS.GALLERY.VIEW_PROPS.controls.position, children: _jsx(TextControls, { ...PARAMS.GALLERY.VIEW_PROPS.controls.controls, selectedIndex: selectedIndex, texts: texts, onClick: (tab) => {
|
|
7
|
+
if (typeof tab === "string")
|
|
8
|
+
void emit(EVENTS.GALLERY.TAB_SET, { tab });
|
|
9
|
+
} }) }));
|
|
10
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { GalleryCurrentItem, GalleryViewContext } from "../../utils/gallery.js";
|
|
2
|
+
type GalleryItemsProps = GalleryViewContext & {
|
|
3
|
+
gridItems?: GalleryCurrentItem[];
|
|
4
|
+
selectedIndex?: number;
|
|
5
|
+
};
|
|
6
|
+
export declare const GalleryItems: ({ gridItems, selectedIndex, emit, EVENTS, PARAMS }: GalleryItemsProps) => import("react").JSX.Element;
|
|
7
|
+
export {};
|