@vnejs/plugins.settings.filter 0.1.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/dist/index.d.ts +1 -0
- package/dist/index.js +5 -0
- package/dist/modules/filter.d.ts +11 -0
- package/dist/modules/filter.js +21 -0
- package/dist/types.d.ts +6 -0
- package/dist/types.js +1 -0
- package/package.json +42 -0
- package/src/index.ts +8 -0
- package/src/modules/filter.ts +33 -0
- package/src/types.ts +10 -0
- package/tsconfig.json +9 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "@vnejs/contracts.settings.filter";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import "@vnejs/contracts.settings.filter";
|
|
2
|
+
import { regPlugin } from "@vnejs/shared";
|
|
3
|
+
import { CONSTANTS, PARAMS, PLUGIN_NAME, SETTINGS_KEYS } from "@vnejs/contracts.settings.filter";
|
|
4
|
+
import { Filter } from "./modules/filter.js";
|
|
5
|
+
regPlugin(PLUGIN_NAME, { constants: CONSTANTS, settings: SETTINGS_KEYS, params: PARAMS }, [Filter]);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ModuleCore } from "@vnejs/module.core";
|
|
2
|
+
import type { FilterPluginConstants, FilterPluginEvents, FilterPluginParams, FilterPluginSettings } from "../types.js";
|
|
3
|
+
import type { SettingsChangedResult } from "@vnejs/module.core";
|
|
4
|
+
export declare class Filter extends ModuleCore<FilterPluginEvents, FilterPluginConstants, FilterPluginSettings, FilterPluginParams> {
|
|
5
|
+
name: string;
|
|
6
|
+
filterElement: HTMLElement | null;
|
|
7
|
+
subscribe: () => void;
|
|
8
|
+
init: () => Promise<void>;
|
|
9
|
+
onSettingChange: ({ name, value }: SettingsChangedResult) => false | void;
|
|
10
|
+
setFilter: (presetId?: string) => void;
|
|
11
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ModuleCore } from "@vnejs/module.core";
|
|
2
|
+
import { PARAMS as FILTER_PARAMS, SETTINGS_KEYS } from "@vnejs/contracts.settings.filter";
|
|
3
|
+
export class Filter extends ModuleCore {
|
|
4
|
+
name = "filter";
|
|
5
|
+
filterElement = null;
|
|
6
|
+
subscribe = () => {
|
|
7
|
+
this.on(this.EVENTS.SETTINGS.CHANGED, this.onSettingChange);
|
|
8
|
+
};
|
|
9
|
+
init = async () => {
|
|
10
|
+
this.filterElement = document.body;
|
|
11
|
+
const options = Object.keys(FILTER_PARAMS.PRESETS);
|
|
12
|
+
await this.emit(this.EVENTS.SETTINGS.INIT, { name: SETTINGS_KEYS.VALUE, value: FILTER_PARAMS.DEFAULT, options });
|
|
13
|
+
this.setFilter(this.shared.settings[SETTINGS_KEYS.VALUE]);
|
|
14
|
+
};
|
|
15
|
+
onSettingChange = ({ name, value }) => name === SETTINGS_KEYS.VALUE && this.setFilter(value);
|
|
16
|
+
setFilter = (presetId = "") => {
|
|
17
|
+
if (!this.filterElement)
|
|
18
|
+
return;
|
|
19
|
+
this.filterElement.style.filter = FILTER_PARAMS.PRESETS[presetId] ?? "";
|
|
20
|
+
};
|
|
21
|
+
}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ModuleCoreConstants, ModuleCoreEvents, ModuleCoreParams, ModuleCoreSettings } from "@vnejs/module.core";
|
|
2
|
+
import type { PluginName, SettingsKeys } from "@vnejs/contracts.settings.filter";
|
|
3
|
+
export type FilterPluginEvents = ModuleCoreEvents;
|
|
4
|
+
export type FilterPluginConstants = ModuleCoreConstants;
|
|
5
|
+
export type FilterPluginSettings = ModuleCoreSettings & Record<PluginName, SettingsKeys>;
|
|
6
|
+
export type FilterPluginParams = ModuleCoreParams;
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vnejs/plugins.settings.filter",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"require": "./dist/index.js",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"src",
|
|
18
|
+
"tsconfig.json"
|
|
19
|
+
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
22
|
+
"build": "npx @vnejs/monorepo package",
|
|
23
|
+
"publish:major:plugin": "npm run publish:major",
|
|
24
|
+
"publish:minor:plugin": "npm run publish:minor",
|
|
25
|
+
"publish:patch:plugin": "npm run publish:patch",
|
|
26
|
+
"publish:major": "npx @vnejs/monorepo publish major --access public",
|
|
27
|
+
"publish:minor": "npx @vnejs/monorepo publish minor --access public",
|
|
28
|
+
"publish:patch": "npx @vnejs/monorepo publish patch --access public"
|
|
29
|
+
},
|
|
30
|
+
"author": "",
|
|
31
|
+
"license": "ISC",
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@vnejs/contracts.settings.filter": "~0.1.0"
|
|
34
|
+
},
|
|
35
|
+
"peerDependencies": {
|
|
36
|
+
"@vnejs/module.core": "~0.1.0",
|
|
37
|
+
"@vnejs/shared": "~0.1.0"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@vnejs/configs.ts-common": "~0.1.0"
|
|
41
|
+
}
|
|
42
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import "@vnejs/contracts.settings.filter";
|
|
2
|
+
|
|
3
|
+
import { regPlugin } from "@vnejs/shared";
|
|
4
|
+
import { CONSTANTS, PARAMS, PLUGIN_NAME, SETTINGS_KEYS } from "@vnejs/contracts.settings.filter";
|
|
5
|
+
|
|
6
|
+
import { Filter } from "./modules/filter.js";
|
|
7
|
+
|
|
8
|
+
regPlugin(PLUGIN_NAME, { constants: CONSTANTS, settings: SETTINGS_KEYS, params: PARAMS }, [Filter]);
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ModuleCore } from "@vnejs/module.core";
|
|
2
|
+
import { PARAMS as FILTER_PARAMS, SETTINGS_KEYS } from "@vnejs/contracts.settings.filter";
|
|
3
|
+
|
|
4
|
+
import type { FilterPluginConstants, FilterPluginEvents, FilterPluginParams, FilterPluginSettings } from "../types.js";
|
|
5
|
+
import type { SettingsChangedResult } from "@vnejs/module.core";
|
|
6
|
+
|
|
7
|
+
export class Filter extends ModuleCore<FilterPluginEvents, FilterPluginConstants, FilterPluginSettings, FilterPluginParams> {
|
|
8
|
+
name = "filter";
|
|
9
|
+
|
|
10
|
+
filterElement: HTMLElement | null = null;
|
|
11
|
+
|
|
12
|
+
subscribe = () => {
|
|
13
|
+
this.on(this.EVENTS.SETTINGS.CHANGED, this.onSettingChange);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
init = async () => {
|
|
17
|
+
this.filterElement = document.body;
|
|
18
|
+
|
|
19
|
+
const options = Object.keys(FILTER_PARAMS.PRESETS);
|
|
20
|
+
|
|
21
|
+
await this.emit(this.EVENTS.SETTINGS.INIT, { name: SETTINGS_KEYS.VALUE, value: FILTER_PARAMS.DEFAULT, options });
|
|
22
|
+
|
|
23
|
+
this.setFilter(this.shared.settings[SETTINGS_KEYS.VALUE]);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
onSettingChange = ({ name, value }: SettingsChangedResult) => name === SETTINGS_KEYS.VALUE && this.setFilter(value as string);
|
|
27
|
+
|
|
28
|
+
setFilter = (presetId = "") => {
|
|
29
|
+
if (!this.filterElement) return;
|
|
30
|
+
|
|
31
|
+
this.filterElement.style.filter = FILTER_PARAMS.PRESETS[presetId as keyof typeof FILTER_PARAMS.PRESETS] ?? "";
|
|
32
|
+
};
|
|
33
|
+
}
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ModuleCoreConstants, ModuleCoreEvents, ModuleCoreParams, ModuleCoreSettings } from "@vnejs/module.core";
|
|
2
|
+
import type { PluginName, SettingsKeys } from "@vnejs/contracts.settings.filter";
|
|
3
|
+
|
|
4
|
+
export type FilterPluginEvents = ModuleCoreEvents;
|
|
5
|
+
|
|
6
|
+
export type FilterPluginConstants = ModuleCoreConstants;
|
|
7
|
+
|
|
8
|
+
export type FilterPluginSettings = ModuleCoreSettings & Record<PluginName, SettingsKeys>;
|
|
9
|
+
|
|
10
|
+
export type FilterPluginParams = ModuleCoreParams;
|