@wxn0brp/flanker-settings 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/README.md +73 -0
- package/dist/engine.d.ts +17 -0
- package/dist/engine.js +61 -0
- package/dist/html/gen.d.ts +6 -0
- package/dist/html/gen.js +70 -0
- package/dist/html/index.d.ts +3 -0
- package/dist/html/index.js +19 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/keys.d.ts +3 -0
- package/dist/keys.js +30 -0
- package/dist/minified/index.css +2 -0
- package/dist/minified/index.css.map +7 -0
- package/dist/minified/index.js +2 -0
- package/dist/minified/index.js.map +7 -0
- package/dist/types/html.d.ts +36 -0
- package/dist/types/html.js +1 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.js +1 -0
- package/package.json +47 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 wxn0brP
|
|
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.
|
package/README.md
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# Flanker Settings
|
|
2
|
+
|
|
3
|
+
A library for creating settings pages with a reactive store and database persistence.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @wxn0brp/flanker-settings @wxn0brp/flanker-ui @wxn0brp/db-core
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## JavaScript API
|
|
12
|
+
|
|
13
|
+
The JavaScript API allows you to initialize the settings engine and generate the HTML for the settings page.
|
|
14
|
+
|
|
15
|
+
**Example:**
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
import "@wxn0brp/flanker-ui/html";
|
|
19
|
+
import { Engine, generateHTML } from "@wxn0brp/flanker-settings";
|
|
20
|
+
import { SettingsElement } from "@wxn0brp/flanker-settings/types";
|
|
21
|
+
import { createMemoryValthera } from "@wxn0brp/db-core";
|
|
22
|
+
|
|
23
|
+
const db = createMemoryValthera();
|
|
24
|
+
const root = qs("settings-container");
|
|
25
|
+
|
|
26
|
+
const elements: SettingsElement[] = [
|
|
27
|
+
{
|
|
28
|
+
type: "select",
|
|
29
|
+
id: "theme",
|
|
30
|
+
label: "Theme",
|
|
31
|
+
options: [
|
|
32
|
+
{ value: "dark", label: "Dark" },
|
|
33
|
+
{ value: "light", label: "Light" },
|
|
34
|
+
],
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
type: "checkbox",
|
|
38
|
+
id: "notifications",
|
|
39
|
+
label: "Enable notifications",
|
|
40
|
+
},
|
|
41
|
+
];
|
|
42
|
+
|
|
43
|
+
generateHTML(elements, root);
|
|
44
|
+
|
|
45
|
+
const engine = new Engine(
|
|
46
|
+
db,
|
|
47
|
+
{
|
|
48
|
+
theme: "dark",
|
|
49
|
+
notifications: true,
|
|
50
|
+
},
|
|
51
|
+
root
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
engine.init();
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## CSS API
|
|
58
|
+
|
|
59
|
+
The library uses CSS variables for styling. You can override these variables to customize the look and feel of the settings page.
|
|
60
|
+
|
|
61
|
+
| Variable | Description |
|
|
62
|
+
| -------------------------------------- | ---------------------------------------------- |
|
|
63
|
+
| `--settings-background-color` | Background color of the settings container. |
|
|
64
|
+
| `--settings-border-color` | Border color of the settings container. |
|
|
65
|
+
| `--settings-text-color` | Main text color. |
|
|
66
|
+
| `--settings-input-background` | Background color of input fields. |
|
|
67
|
+
| `--settings-input-text-color` | Text color of input fields. |
|
|
68
|
+
| `--settings-input-border-color` | Border color of input fields. |
|
|
69
|
+
| `--settings-input-focus-border-color` | Border color of input fields when focused. |
|
|
70
|
+
| `--settings-input-focus-background` | Background color of input fields when focused. |
|
|
71
|
+
| `--settings-accent-color` | Accent color for checkboxes and radios. |
|
|
72
|
+
| `--settings-link-color` | Color of links. |
|
|
73
|
+
| `--settings-link-hover-color` | Color of links when hovered. |
|
package/dist/engine.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ValtheraCompatible } from "@wxn0brp/db-core";
|
|
2
|
+
import { StoreType } from "@wxn0brp/flanker-ui";
|
|
3
|
+
export interface Opts {
|
|
4
|
+
collection?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare class Engine<T = any> {
|
|
7
|
+
private db;
|
|
8
|
+
private storeData;
|
|
9
|
+
private root;
|
|
10
|
+
private opts;
|
|
11
|
+
store: StoreType<T>;
|
|
12
|
+
constructor(db: ValtheraCompatible, storeData: T, root: HTMLDivElement, opts?: Opts);
|
|
13
|
+
init(): Promise<void>;
|
|
14
|
+
_initStoreAndDb(): Promise<void>;
|
|
15
|
+
private _pickCell;
|
|
16
|
+
private _initWatch;
|
|
17
|
+
}
|
package/dist/engine.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { deepMerge } from "@wxn0brp/db-core/utils/merge";
|
|
2
|
+
import { createStore } from "@wxn0brp/flanker-ui";
|
|
3
|
+
import { watchCheckbox, watchInput, watchSelect } from "@wxn0brp/flanker-ui/component/helpers";
|
|
4
|
+
import { keysToObj } from "./keys.js";
|
|
5
|
+
export class Engine {
|
|
6
|
+
db;
|
|
7
|
+
storeData;
|
|
8
|
+
root;
|
|
9
|
+
opts;
|
|
10
|
+
store;
|
|
11
|
+
constructor(db, storeData, root, opts = {}) {
|
|
12
|
+
this.db = db;
|
|
13
|
+
this.storeData = storeData;
|
|
14
|
+
this.root = root;
|
|
15
|
+
this.opts = {
|
|
16
|
+
collection: "settings",
|
|
17
|
+
...opts
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
async init() {
|
|
21
|
+
await this._initStoreAndDb();
|
|
22
|
+
await this._initWatch();
|
|
23
|
+
}
|
|
24
|
+
async _initStoreAndDb() {
|
|
25
|
+
const settings = await this.db.find(this.opts.collection);
|
|
26
|
+
const obj = keysToObj(settings);
|
|
27
|
+
const storeData = deepMerge({}, this.storeData, obj);
|
|
28
|
+
this.store = createStore(storeData);
|
|
29
|
+
}
|
|
30
|
+
_pickCell(keys) {
|
|
31
|
+
let current = this.store;
|
|
32
|
+
for (const key of keys) {
|
|
33
|
+
current = current[key];
|
|
34
|
+
}
|
|
35
|
+
return current;
|
|
36
|
+
}
|
|
37
|
+
async _initWatch() {
|
|
38
|
+
this.root.querySelectorAll("[data-id]").forEach(el => {
|
|
39
|
+
const id = el.getAttribute("data-id");
|
|
40
|
+
if (!id)
|
|
41
|
+
return;
|
|
42
|
+
const cell = this._pickCell(id.split("."));
|
|
43
|
+
cell.subscribe(v => {
|
|
44
|
+
this.db.updateOneOrAdd(this.opts.collection, { _id: id }, { v });
|
|
45
|
+
});
|
|
46
|
+
const target = el;
|
|
47
|
+
if (target.type === "checkbox") {
|
|
48
|
+
target.checked = cell.get();
|
|
49
|
+
watchCheckbox(target, cell);
|
|
50
|
+
}
|
|
51
|
+
else if (target instanceof HTMLSelectElement) {
|
|
52
|
+
target.value = cell.get();
|
|
53
|
+
watchSelect(target, cell);
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
target.value = cell.get();
|
|
57
|
+
watchInput(target, cell);
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { SettingsAreaElement, SettingsCheckboxElement, SettingsInputElement, SettingsSelectElement } from "../types/html.js";
|
|
2
|
+
export declare function generateBase(title: string, inline?: boolean): HTMLLabelElement;
|
|
3
|
+
export declare function generateInput({ id, title, value, number, inline }: SettingsInputElement): HTMLLabelElement;
|
|
4
|
+
export declare function generateSelect({ id, title, options, value, inline }: SettingsSelectElement): HTMLLabelElement;
|
|
5
|
+
export declare function generateCheckbox({ id, title, value, inline }: SettingsCheckboxElement): HTMLLabelElement;
|
|
6
|
+
export declare function generateArea({ id, title, value, width, height, cols, rows, inline }: SettingsAreaElement): HTMLLabelElement;
|
package/dist/html/gen.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
export function generateBase(title, inline = false) {
|
|
2
|
+
const label = document.createElement("label");
|
|
3
|
+
label.innerHTML = title;
|
|
4
|
+
if (inline)
|
|
5
|
+
label.classList.add("inline");
|
|
6
|
+
return label;
|
|
7
|
+
}
|
|
8
|
+
export function generateInput({ id, title, value, number, inline }) {
|
|
9
|
+
const label = generateBase(title, inline);
|
|
10
|
+
const input = document.createElement("input");
|
|
11
|
+
if (number) {
|
|
12
|
+
input.setAttribute("type", "number");
|
|
13
|
+
if (typeof number.min !== "undefined")
|
|
14
|
+
input.setAttribute("min", number.min.toString());
|
|
15
|
+
if (typeof number.max !== "undefined")
|
|
16
|
+
input.setAttribute("max", number.max.toString());
|
|
17
|
+
if (typeof number.step !== "undefined")
|
|
18
|
+
input.setAttribute("step", number.step.toString());
|
|
19
|
+
}
|
|
20
|
+
else
|
|
21
|
+
input.setAttribute("type", "text");
|
|
22
|
+
input.setAttribute("data-id", id);
|
|
23
|
+
value = typeof value === "number" ? value.toString() : value;
|
|
24
|
+
input.value = value || "";
|
|
25
|
+
label.appendChild(input);
|
|
26
|
+
return label;
|
|
27
|
+
}
|
|
28
|
+
export function generateSelect({ id, title, options, value, inline }) {
|
|
29
|
+
const label = generateBase(title, inline);
|
|
30
|
+
const select = document.createElement("select");
|
|
31
|
+
select.setAttribute("data-id", id);
|
|
32
|
+
for (const option of options) {
|
|
33
|
+
const optionElement = document.createElement("option");
|
|
34
|
+
optionElement.setAttribute("value", option.value);
|
|
35
|
+
optionElement.innerHTML = option.label || option.value;
|
|
36
|
+
select.appendChild(optionElement);
|
|
37
|
+
}
|
|
38
|
+
select.value = value || "";
|
|
39
|
+
label.appendChild(select);
|
|
40
|
+
return label;
|
|
41
|
+
}
|
|
42
|
+
export function generateCheckbox({ id, title, value, inline }) {
|
|
43
|
+
const label = generateBase(title, inline);
|
|
44
|
+
const checkbox = document.createElement("input");
|
|
45
|
+
checkbox.setAttribute("type", "checkbox");
|
|
46
|
+
checkbox.setAttribute("data-id", id);
|
|
47
|
+
checkbox.checked = value || false;
|
|
48
|
+
label.insertBefore(checkbox, label.firstChild);
|
|
49
|
+
return label;
|
|
50
|
+
}
|
|
51
|
+
export function generateArea({ id, title, value, width, height, cols, rows, inline }) {
|
|
52
|
+
const label = generateBase(title, inline);
|
|
53
|
+
const textarea = document.createElement("textarea");
|
|
54
|
+
textarea.setAttribute("data-id", id);
|
|
55
|
+
textarea.value = value || "";
|
|
56
|
+
if (width || cols)
|
|
57
|
+
textarea.style.maxWidth = "100%";
|
|
58
|
+
if (height || rows)
|
|
59
|
+
textarea.style.maxHeight = "100%";
|
|
60
|
+
if (width)
|
|
61
|
+
textarea.style.width = typeof width === "number" ? `${width}px` : width;
|
|
62
|
+
if (height)
|
|
63
|
+
textarea.style.height = typeof height === "number" ? `${height}px` : height;
|
|
64
|
+
if (cols)
|
|
65
|
+
textarea.cols = cols;
|
|
66
|
+
if (rows)
|
|
67
|
+
textarea.rows = rows;
|
|
68
|
+
label.appendChild(textarea);
|
|
69
|
+
return label;
|
|
70
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { generateInput, generateSelect, generateCheckbox, generateArea } from "./gen.js";
|
|
2
|
+
export function generateElement(element) {
|
|
3
|
+
switch (element.type) {
|
|
4
|
+
case "input":
|
|
5
|
+
return generateInput(element);
|
|
6
|
+
case "select":
|
|
7
|
+
return generateSelect(element);
|
|
8
|
+
case "checkbox":
|
|
9
|
+
return generateCheckbox(element);
|
|
10
|
+
case "area":
|
|
11
|
+
return generateArea(element);
|
|
12
|
+
default:
|
|
13
|
+
const n = element;
|
|
14
|
+
throw new Error(`Unknown element type: ${n}`);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export function generateHTML(elements, container) {
|
|
18
|
+
elements.forEach(el => container.appendChild(generateElement(el)));
|
|
19
|
+
}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
package/dist/keys.d.ts
ADDED
package/dist/keys.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export function objToKeys(obj, prefix = "") {
|
|
2
|
+
const result = [];
|
|
3
|
+
for (const [k, v] of Object.entries(obj)) {
|
|
4
|
+
const key = prefix ? `${prefix}.${k}` : k;
|
|
5
|
+
if (v !== null && typeof v === "object" && !Array.isArray(v)) {
|
|
6
|
+
result.push(...objToKeys(v, key));
|
|
7
|
+
}
|
|
8
|
+
else {
|
|
9
|
+
result.push({ _id: key, v });
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
return result;
|
|
13
|
+
}
|
|
14
|
+
export function keysToObj(settings) {
|
|
15
|
+
const result = {};
|
|
16
|
+
for (const { _id, v } of settings) {
|
|
17
|
+
const keys = _id.split(".");
|
|
18
|
+
let current = result;
|
|
19
|
+
for (let i = 0; i < keys.length - 1; i++) {
|
|
20
|
+
const k = keys[i];
|
|
21
|
+
if (!(k in current) || typeof current[k] !== "object" || Array.isArray(current[k])) {
|
|
22
|
+
current[k] = {};
|
|
23
|
+
}
|
|
24
|
+
current = current[k];
|
|
25
|
+
}
|
|
26
|
+
const lastKey = keys[keys.length - 1];
|
|
27
|
+
current[lastKey] = v;
|
|
28
|
+
}
|
|
29
|
+
return result;
|
|
30
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
.settings{background:var(--settings-background-color);padding:20px;border-radius:10px;border:1px solid var(--settings-border-color);box-shadow:0 4px 12px #0009;margin-bottom:20px;display:flex;flex-direction:column;gap:12px}.settings h1,.settings h2,.settings h3{color:var(--settings-text-color);margin-bottom:20px;font-weight:600;text-shadow:0 2px 4px rgba(0,0,0,.6)}.settings label{display:flex;flex-direction:column;margin-bottom:6px;gap:4px}.settings label.inline{flex-direction:row;align-items:center;gap:8px}.settings input,.settings select,.settings textarea{background:var(--settings-input-background);color:var(--settings-input-text-color);border:1px solid var(--settings-input-border-color);padding:8px 12px;border-radius:6px;width:100%;max-width:240px;font-size:14px;box-shadow:inset 0 1px 3px #0009;transition:border-color .3s ease,box-shadow .3s ease,background .3s ease,transform .2s ease}.settings input:focus,.settings select:focus,.settings textarea:focus{border-color:var(--settings-input-focus-border-color);background:var(--settings-input-focus-background);box-shadow:0 0 8px #6496ffb3;outline:none;transform:scale(1.02)}.settings input[type=checkbox],.settings input[type=radio],.settings select[type=checkbox],.settings select[type=radio],.settings textarea[type=checkbox],.settings textarea[type=radio]{width:auto;accent-color:var(--settings-accent-color);transition:transform .2s ease}.settings input[type=checkbox]:checked,.settings input[type=radio]:checked,.settings select[type=checkbox]:checked,.settings select[type=radio]:checked,.settings textarea[type=checkbox]:checked,.settings textarea[type=radio]:checked{transform:scale(1.2)}.settings a{color:var(--settings-link-color);text-decoration:none;transition:color .2s}.settings a:hover{color:var(--settings-link-hover-color)}
|
|
2
|
+
/*# sourceMappingURL=index.css.map */
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["temp_stylePlugin:src/style.scss"],
|
|
4
|
+
"sourcesContent": [".settings {\n background: var(--settings-background-color);\n padding: 20px;\n border-radius: 10px;\n border: 1px solid var(--settings-border-color);\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);\n margin-bottom: 20px;\n display: flex;\n flex-direction: column;\n gap: 12px;\n}\n.settings h1,\n.settings h2,\n.settings h3 {\n color: var(--settings-text-color);\n margin-bottom: 20px;\n font-weight: 600;\n text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);\n}\n.settings label {\n display: flex;\n flex-direction: column;\n margin-bottom: 6px;\n gap: 4px;\n}\n.settings label.inline {\n flex-direction: row;\n align-items: center;\n gap: 8px;\n}\n.settings input,\n.settings select,\n.settings textarea {\n background: var(--settings-input-background);\n color: var(--settings-input-text-color);\n border: 1px solid var(--settings-input-border-color);\n padding: 8px 12px;\n border-radius: 6px;\n width: 100%;\n max-width: 240px;\n font-size: 14px;\n box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.6);\n transition: border-color 0.3s ease, box-shadow 0.3s ease, background 0.3s ease, transform 0.2s ease;\n}\n.settings input:focus,\n.settings select:focus,\n.settings textarea:focus {\n border-color: var(--settings-input-focus-border-color);\n background: var(--settings-input-focus-background);\n box-shadow: 0 0 8px rgba(100, 150, 255, 0.7);\n outline: none;\n transform: scale(1.02);\n}\n.settings input[type=checkbox], .settings input[type=radio],\n.settings select[type=checkbox],\n.settings select[type=radio],\n.settings textarea[type=checkbox],\n.settings textarea[type=radio] {\n width: auto;\n accent-color: var(--settings-accent-color);\n transition: transform 0.2s ease;\n}\n.settings input[type=checkbox]:checked, .settings input[type=radio]:checked,\n.settings select[type=checkbox]:checked,\n.settings select[type=radio]:checked,\n.settings textarea[type=checkbox]:checked,\n.settings textarea[type=radio]:checked {\n transform: scale(1.2);\n}\n.settings a {\n color: var(--settings-link-color);\n text-decoration: none;\n transition: color 0.2s;\n}\n.settings a:hover {\n color: var(--settings-link-hover-color);\n}"],
|
|
5
|
+
"mappings": "AAAA,CAAC,SACC,WAAY,IAAI,6BADlB,QAEW,KAFX,cAGiB,KACf,OAAQ,IAAI,MAAM,IAAI,yBACtB,WAAY,EAAE,IAAI,KAAK,MACvB,cAAe,KACf,QAAS,KACT,eAAgB,OAChB,IAAK,IACP,CACA,CAXC,SAWS,GACV,CAZC,SAYS,GACV,CAbC,SAaS,GACR,MAAO,IAAI,uBACX,cAAe,KACf,YAAa,IACb,YAAa,EAAE,IAAI,IAAI,KAAK,CAAC,CAAE,CAAC,CAAE,CAAC,CAAE,GACvC,CACA,CAnBC,SAmBS,MACR,QAAS,KACT,eAAgB,OAChB,cAAe,IACf,IAAK,GACP,CACA,CAzBC,SAyBS,KAAK,CAAC,OACd,eAAgB,IAChB,YAAa,OACb,IAAK,GACP,CACA,CA9BC,SA8BS,MACV,CA/BC,SA+BS,OACV,CAhCC,SAgCS,SACR,WAAY,IAAI,6BAChB,MAAO,IAAI,6BACX,OAAQ,IAAI,MAAM,IAAI,+BAnCxB,QAoCW,IAAI,KApCf,cAqCiB,IACf,MAAO,KACP,UAAW,MACX,UAAW,KACX,WAAY,MAAM,EAAE,IAAI,IAAI,MAC5B,WAAY,aAAa,IAAK,IAAI,CAAE,WAAW,IAAK,IAAI,CAAE,WAAW,IAAK,IAAI,CAAE,UAAU,IAAK,IACjG,CACA,CA5CC,SA4CS,KAAK,OACf,CA7CC,SA6CS,MAAM,OAChB,CA9CC,SA8CS,QAAQ,OAChB,aAAc,IAAI,qCAClB,WAAY,IAAI,mCAChB,WAAY,EAAE,EAAE,IAAI,UACpB,QAAS,KACT,UAAW,MAAM,KACnB,CACA,CArDC,SAqDS,KAAK,CAAC,eAAgB,CArD/B,SAqDyC,KAAK,CAAC,YAChD,CAtDC,SAsDS,MAAM,CAAC,eACjB,CAvDC,SAuDS,MAAM,CAAC,YACjB,CAxDC,SAwDS,QAAQ,CAAC,eACnB,CAzDC,SAyDS,QAAQ,CAAC,YACjB,MAAO,KACP,aAAc,IAAI,yBAClB,WAAY,UAAU,IAAK,IAC7B,CACA,CA9DC,SA8DS,KAAK,CAAC,cAAc,SAAU,CA9DvC,SA8DiD,KAAK,CAAC,WAAW,SACnE,CA/DC,SA+DS,MAAM,CAAC,cAAc,SAC/B,CAhEC,SAgES,MAAM,CAAC,WAAW,SAC5B,CAjEC,SAiES,QAAQ,CAAC,cAAc,SACjC,CAlEC,SAkES,QAAQ,CAAC,WAAW,SAC5B,UAAW,MAAM,IACnB,CACA,CArEC,SAqES,EACR,MAAO,IAAI,uBACX,gBAAiB,KACjB,WAAY,MAAM,GACpB,CACA,CA1EC,SA0ES,CAAC,OACT,MAAO,IAAI,4BACb",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var L=Object.defineProperty;var s=(n,r)=>L(n,"name",{value:r,configurable:!0});function g(n,...r){if(!r.length)return n;let e=r.shift();if(n||(n={}),d(n)&&d(e))for(let t in e)d(e[t])?(n[t]||Object.assign(n,{[t]:{}}),g(n[t],e[t])):Object.assign(n,{[t]:e[t]});return g(n,...r)}s(g,"_deepMerge");function m(n,...r){return g(structuredClone(n),...r.map(e=>structuredClone(e)))}s(m,"deepMerge");function d(n){return n&&typeof n=="object"&&!Array.isArray(n)}s(d,"isObject");var f=["listeners","value","notify","get","set","subscribe","parent","isStore"];function b(n,r){let e={};for(let t in n)n.hasOwnProperty(t)&&(typeof n[t]=="object"&&!Array.isArray(n[t])&&n[t]!==null?e[t]=b(n[t],e):e[t]=new y(n[t],e));return e.isStore=!0,e.listeners=[],e.value=void 0,e.parent=r,e.notify=(t=0)=>(e.listeners.forEach(o=>o(e)),t>0&&r&&typeof r.notify=="function"&&r.notify(t-1),e),e.get=()=>{let t={};for(let o in e)f.includes(o)||e.hasOwnProperty(o)&&(t[o]=e[o].get());return t},e.getPointer=()=>{let t={};for(let o in e)f.includes(o)||e.hasOwnProperty(o)&&(t[o]=e[o]);return t},e.set=(t,o=0)=>{for(let i in t){if(f.includes(i))throw new Error(`Reserved key: ${i}`);if(!e.hasOwnProperty(i))throw new Error(`Unknown key: ${i}`);if(e[i].isStore)throw new Error(`Cannot set nested store: ${i}`);let c=t[i];if(typeof c=="object"&&c!==null&&!Array.isArray(c))throw new Error(`Invalid value for key: ${i}`)}for(let i in t)e[i].set(t[i],o);return e},e.subscribe=t=>(e.listeners.push(t),e),e}s(b,"createStore");var y=class{static{s(this,"ReactiveCell")}value;parent;listeners=[];isStore=!1;constructor(r,e){this.value=r,this.parent=e}get(){return this.value}set(r,e=0){return this.value=r,this.notify(e),this}notify(r=0){return this.listeners.forEach(e=>e(this.value)),r>0&&this.parent&&typeof this.parent.notify=="function"&&this.parent.notify(r-1),this}subscribe(r){return this.listeners.push(r),this}};function h(n,r,e=!1){e&&r.set(n.value),n.addEventListener("input",()=>{r.set(n.value)}),r.subscribe(t=>{n.value!==t&&(n.value=t)})}s(h,"watchInput");function x(n,r,e=!1){e&&r.set(n.value),n.addEventListener("change",()=>{r.set(n.value)}),r.subscribe(t=>{n.value!==t&&(n.value=t)})}s(x,"watchSelect");function k(n,r,e=!1){e&&r.set(n.checked),n.addEventListener("change",()=>{r.set(n.checked)}),r.subscribe(t=>{n.checked!==t&&(n.checked=t)})}s(k,"watchCheckbox");var K=window?.VQLClient?.fetchVQL;globalThis.lo=console.log;function v(n){let r={};for(let{_id:e,v:t}of n){let o=e.split("."),i=r;for(let c=0;c<o.length-1;c++){let l=o[c];(!(l in i)||typeof i[l]!="object"||Array.isArray(i[l]))&&(i[l]={}),i=i[l]}let a=o[o.length-1];i[a]=t}return r}s(v,"keysToObj");var S=class{constructor(r,e,t,o={}){this.db=r;this.storeData=e;this.root=t;this.opts={collection:"settings",...o}}static{s(this,"Engine")}opts;store;async init(){await this._initStoreAndDb(),await this._initWatch()}async _initStoreAndDb(){let r=await this.db.find(this.opts.collection),e=v(r),t=m({},this.storeData,e);this.store=b(t)}_pickCell(r){let e=this.store;for(let t of r)e=e[t];return e}async _initWatch(){this.root.querySelectorAll("[data-id]").forEach(r=>{let e=r.getAttribute("data-id");if(!e)return;let t=this._pickCell(e.split("."));t.subscribe(i=>{this.db.updateOneOrAdd(this.opts.collection,{_id:e},{v:i})});let o=r;o.type==="checkbox"?(o.checked=t.get(),k(o,t)):o instanceof HTMLSelectElement?(o.value=t.get(),x(o,t)):(o.value=t.get(),h(o,t))})}};function p(n,r=!1){let e=document.createElement("label");return e.innerHTML=n,r&&e.classList.add("inline"),e}s(p,"generateBase");function T({id:n,title:r,value:e,number:t,inline:o}){let i=p(r,o),a=document.createElement("input");return t?(a.setAttribute("type","number"),typeof t.min<"u"&&a.setAttribute("min",t.min.toString()),typeof t.max<"u"&&a.setAttribute("max",t.max.toString()),typeof t.step<"u"&&a.setAttribute("step",t.step.toString())):a.setAttribute("type","text"),a.setAttribute("data-id",n),e=typeof e=="number"?e.toString():e,a.value=e||"",i.appendChild(a),i}s(T,"generateInput");function w({id:n,title:r,options:e,value:t,inline:o}){let i=p(r,o),a=document.createElement("select");a.setAttribute("data-id",n);for(let c of e){let l=document.createElement("option");l.setAttribute("value",c.value),l.innerHTML=c.label||c.value,a.appendChild(l)}return a.value=t||"",i.appendChild(a),i}s(w,"generateSelect");function A({id:n,title:r,value:e,inline:t}){let o=p(r,t),i=document.createElement("input");return i.setAttribute("type","checkbox"),i.setAttribute("data-id",n),i.checked=e||!1,o.insertBefore(i,o.firstChild),o}s(A,"generateCheckbox");function E({id:n,title:r,value:e,width:t,height:o,cols:i,rows:a,inline:c}){let l=p(r,c),u=document.createElement("textarea");return u.setAttribute("data-id",n),u.value=e||"",(t||i)&&(u.style.maxWidth="100%"),(o||a)&&(u.style.maxHeight="100%"),t&&(u.style.width=typeof t=="number"?`${t}px`:t),o&&(u.style.height=typeof o=="number"?`${o}px`:o),i&&(u.cols=i),a&&(u.rows=a),l.appendChild(u),l}s(E,"generateArea");function D(n){switch(n.type){case"input":return T(n);case"select":return w(n);case"checkbox":return A(n);case"area":return E(n);default:let r=n;throw new Error(`Unknown element type: ${r}`)}}s(D,"generateElement");function ye(n,r){n.forEach(e=>r.appendChild(D(e)))}s(ye,"generateHTML");export{S as Engine,D as generateElement,ye as generateHTML};
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../node_modules/@wxn0brp/db-core/dist/utils/merge.js", "../../node_modules/@wxn0brp/flanker-ui/src/store.ts", "../../node_modules/@wxn0brp/flanker-ui/src/component/helpers.ts", "../../node_modules/@wxn0brp/flanker-ui/src/component/index.ts", "../../node_modules/@wxn0brp/flanker-ui/src/index.ts", "../../src/keys.ts", "../../src/engine.ts", "../../src/html/gen.ts", "../../src/html/index.ts"],
|
|
4
|
+
"sourcesContent": ["export function _deepMerge(target, ...sources) {\n if (!sources.length)\n return target;\n const source = sources.shift();\n if (!target)\n target = {};\n if (isObject(target) && isObject(source)) {\n for (const key in source) {\n if (isObject(source[key])) {\n if (!target[key])\n Object.assign(target, { [key]: {} });\n _deepMerge(target[key], source[key]);\n }\n else {\n Object.assign(target, { [key]: source[key] });\n }\n }\n }\n return _deepMerge(target, ...sources);\n}\nexport function deepMerge(target, ...sources) {\n return _deepMerge(structuredClone(target), ...sources.map(s => structuredClone(s)));\n}\nfunction isObject(item) {\n return (item && typeof item === \"object\" && !Array.isArray(item));\n}\n", null, null, null, null, "import { DbSetting } from \"./types\";\n\nexport function objToKeys(obj: Record<string, any>, prefix: string = \"\"): DbSetting[] {\n const result: DbSetting[] = [];\n\n for (const [k, v] of Object.entries(obj)) {\n const key = prefix ? `${prefix}.${k}` : k;\n\n if (v !== null && typeof v === \"object\" && !Array.isArray(v)) {\n result.push(...objToKeys(v, key));\n } else {\n result.push({ _id: key, v });\n }\n }\n\n return result;\n}\n\nexport function keysToObj(settings: DbSetting[]): Record<string, any> {\n const result: Record<string, any> = {};\n\n for (const { _id, v } of settings) {\n const keys = _id.split(\".\");\n let current = result;\n\n for (let i = 0; i < keys.length - 1; i++) {\n const k = keys[i];\n if (!(k in current) || typeof current[k] !== \"object\" || Array.isArray(current[k])) {\n current[k] = {};\n }\n current = current[k];\n }\n\n const lastKey = keys[keys.length - 1];\n current[lastKey] = v;\n }\n\n return result;\n}", "import { ValtheraCompatible } from \"@wxn0brp/db-core\";\nimport { deepMerge } from \"@wxn0brp/db-core/utils/merge\";\nimport { createStore, ReactiveCell, StoreType } from \"@wxn0brp/flanker-ui\";\nimport { watchCheckbox, watchInput, watchSelect } from \"@wxn0brp/flanker-ui/component/helpers\";\nimport { keysToObj } from \"./keys\";\nimport { DbSetting } from \"./types\";\n\nexport interface Opts {\n collection?: string;\n}\n\nexport class Engine<T = any> {\n private opts: Opts;\n public store: StoreType<T>;\n\n constructor(\n private db: ValtheraCompatible,\n private storeData: T,\n private root: HTMLDivElement,\n opts: Opts = {}\n ) {\n this.opts = {\n collection: \"settings\",\n ...opts\n }\n }\n\n async init() {\n await this._initStoreAndDb();\n await this._initWatch();\n }\n\n async _initStoreAndDb() {\n const settings = await this.db.find<DbSetting>(this.opts.collection);\n const obj = keysToObj(settings);\n\n const storeData = deepMerge({}, this.storeData, obj);\n this.store = createStore(storeData) as StoreType<T>;\n }\n\n private _pickCell<T = any>(keys: string[]): ReactiveCell<T> {\n let current = this.store;\n for (const key of keys) {\n current = current[key];\n }\n return current as any;\n }\n\n private async _initWatch() {\n this.root.querySelectorAll(\"[data-id]\").forEach(el => {\n const id = el.getAttribute(\"data-id\");\n if (!id) return;\n const cell = this._pickCell(id.split(\".\"));\n\n cell.subscribe(v => {\n this.db.updateOneOrAdd(this.opts.collection, { _id: id }, { v });\n });\n\n const target = el as HTMLInputElement | HTMLSelectElement;\n\n if (target.type === \"checkbox\") {\n target.checked = cell.get();\n watchCheckbox(target, cell);\n } else if (target instanceof HTMLSelectElement) {\n target.value = cell.get();\n watchSelect(target, cell);\n } else {\n target.value = cell.get();\n watchInput(target, cell);\n }\n });\n }\n}", "import { SettingsAreaElement, SettingsCheckboxElement, SettingsInputElement, SettingsSelectElement } from \"../types/html\";\n\nexport function generateBase(title: string, inline: boolean = false): HTMLLabelElement {\n const label = document.createElement(\"label\");\n label.innerHTML = title;\n if (inline) label.classList.add(\"inline\");\n return label;\n}\n\nexport function generateInput({ id, title, value, number, inline }: SettingsInputElement): HTMLLabelElement {\n const label = generateBase(title, inline);\n\n const input = document.createElement(\"input\");\n if (number) {\n input.setAttribute(\"type\", \"number\");\n if (typeof number.min !== \"undefined\") input.setAttribute(\"min\", number.min.toString());\n if (typeof number.max !== \"undefined\") input.setAttribute(\"max\", number.max.toString());\n if (typeof number.step !== \"undefined\") input.setAttribute(\"step\", number.step.toString());\n }\n else input.setAttribute(\"type\", \"text\");\n\n input.setAttribute(\"data-id\", id);\n value = typeof value === \"number\" ? value.toString() : value;\n input.value = value || \"\";\n label.appendChild(input);\n\n return label;\n}\n\nexport function generateSelect({ id, title, options, value, inline }: SettingsSelectElement): HTMLLabelElement {\n const label = generateBase(title, inline);\n\n const select = document.createElement(\"select\");\n select.setAttribute(\"data-id\", id);\n\n for (const option of options) {\n const optionElement = document.createElement(\"option\");\n optionElement.setAttribute(\"value\", option.value);\n optionElement.innerHTML = option.label || option.value;\n select.appendChild(optionElement);\n }\n\n select.value = value || \"\";\n label.appendChild(select);\n\n return label;\n}\n\nexport function generateCheckbox({ id, title, value, inline }: SettingsCheckboxElement): HTMLLabelElement {\n const label = generateBase(title, inline);\n\n const checkbox = document.createElement(\"input\");\n checkbox.setAttribute(\"type\", \"checkbox\");\n checkbox.setAttribute(\"data-id\", id);\n checkbox.checked = value || false;\n label.insertBefore(checkbox, label.firstChild);\n\n return label;\n}\n\nexport function generateArea({ id, title, value, width, height, cols, rows, inline }: SettingsAreaElement): HTMLLabelElement {\n const label = generateBase(title, inline);\n\n const textarea = document.createElement(\"textarea\");\n textarea.setAttribute(\"data-id\", id);\n textarea.value = value || \"\";\n\n if (width || cols) textarea.style.maxWidth = \"100%\";\n if (height || rows) textarea.style.maxHeight = \"100%\";\n\n if (width) textarea.style.width = typeof width === \"number\" ? `${width}px` : width;\n if (height) textarea.style.height = typeof height === \"number\" ? `${height}px` : height;\n if (cols) textarea.cols = cols;\n if (rows) textarea.rows = rows;\n\n label.appendChild(textarea);\n\n return label;\n}", "import { SettingsElement } from \"../types/html\";\nimport { generateInput, generateSelect, generateCheckbox, generateArea } from \"./gen\";\n\nexport function generateElement(element: SettingsElement): HTMLLabelElement {\n switch (element.type) {\n case \"input\":\n return generateInput(element);\n case \"select\":\n return generateSelect(element);\n case \"checkbox\":\n return generateCheckbox(element);\n case \"area\":\n return generateArea(element);\n default:\n const n: never = element;\n throw new Error(`Unknown element type: ${n}`);\n }\n}\n\nexport function generateHTML(elements: SettingsElement[], container: HTMLDivElement) {\n elements.forEach(el => container.appendChild(generateElement(el)));\n}"],
|
|
5
|
+
"mappings": "+EAAO,SAASA,EAAWC,KAAWC,EAAS,CAC3C,GAAI,CAACA,EAAQ,OACT,OAAOD,EACX,IAAME,EAASD,EAAQ,MAAM,EAG7B,GAFKD,IACDA,EAAS,CAAC,GACVG,EAASH,CAAM,GAAKG,EAASD,CAAM,EACnC,QAAWE,KAAOF,EACVC,EAASD,EAAOE,CAAG,CAAC,GACfJ,EAAOI,CAAG,GACX,OAAO,OAAOJ,EAAQ,CAAE,CAACI,CAAG,EAAG,CAAC,CAAE,CAAC,EACvCL,EAAWC,EAAOI,CAAG,EAAGF,EAAOE,CAAG,CAAC,GAGnC,OAAO,OAAOJ,EAAQ,CAAE,CAACI,CAAG,EAAGF,EAAOE,CAAG,CAAE,CAAC,EAIxD,OAAOL,EAAWC,EAAQ,GAAGC,CAAO,CACxC,CAnBgBI,EAAAN,EAAA,cAoBT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B,EAAM,YAAYmB,CAAQ,EAEnBnB,CACX,CAlBgBC,EAAAa,EAAA,gBCzDT,SAASM,EAAgBC,EAA4C,CACxE,OAAQA,EAAQ,KAAM,CAClB,IAAK,QACD,OAAOC,EAAcD,CAAO,EAChC,IAAK,SACD,OAAOE,EAAeF,CAAO,EACjC,IAAK,WACD,OAAOG,EAAiBH,CAAO,EACnC,IAAK,OACD,OAAOI,EAAaJ,CAAO,EAC/B,QACI,IAAMK,EAAWL,EACjB,MAAM,IAAI,MAAM,yBAAyBK,CAAC,EAAE,CACpD,CACJ,CAdgBC,EAAAP,EAAA,mBAgBT,SAASQ,GAAaC,EAA6BC,EAA2B,CACjFD,EAAS,QAAQE,GAAMD,EAAU,YAAYV,EAAgBW,CAAE,CAAC,CAAC,CACrE,CAFgBJ,EAAAC,GAAA",
|
|
6
|
+
"names": ["_deepMerge", "target", "sources", "source", "isObject", "key", "__name", "deepMerge", "s", "item", "storeKeys", "createStore", "schema", "parent", "store", "key", "ReactiveCell", "propagate", "listener", "obj", "data", "value", "__name", "ReactiveCell", "__name", "value", "parent", "newVal", "propagation", "listener", "watchInput", "el", "store", "setFromElement", "value", "__name", "watchSelect", "watchCheckbox", "fetchVQL", "keysToObj", "settings", "result", "_id", "v", "keys", "current", "i", "k", "lastKey", "__name", "Engine", "db", "storeData", "root", "opts", "__name", "settings", "obj", "keysToObj", "deepMerge", "createStore", "keys", "current", "key", "el", "id", "cell", "v", "target", "watchCheckbox", "watchSelect", "watchInput", "generateBase", "title", "inline", "label", "__name", "generateInput", "id", "value", "number", "input", "generateSelect", "options", "select", "option", "optionElement", "generateCheckbox", "checkbox", "generateArea", "width", "height", "cols", "rows", "textarea", "generateElement", "element", "generateInput", "generateSelect", "generateCheckbox", "generateArea", "n", "__name", "generateHTML", "elements", "container", "el"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export interface SettingsBaseElement {
|
|
2
|
+
id: string;
|
|
3
|
+
title: string;
|
|
4
|
+
inline?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export interface SettingsInputElement extends SettingsBaseElement {
|
|
7
|
+
type: "input";
|
|
8
|
+
number?: {
|
|
9
|
+
min?: number;
|
|
10
|
+
max?: number;
|
|
11
|
+
step?: number;
|
|
12
|
+
};
|
|
13
|
+
width?: number;
|
|
14
|
+
value?: string | number;
|
|
15
|
+
}
|
|
16
|
+
export interface SettingsSelectElement extends SettingsBaseElement {
|
|
17
|
+
type: "select";
|
|
18
|
+
options: {
|
|
19
|
+
value: string;
|
|
20
|
+
label?: string;
|
|
21
|
+
}[];
|
|
22
|
+
value?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface SettingsCheckboxElement extends SettingsBaseElement {
|
|
25
|
+
type: "checkbox";
|
|
26
|
+
value?: boolean;
|
|
27
|
+
}
|
|
28
|
+
export interface SettingsAreaElement extends SettingsBaseElement {
|
|
29
|
+
type: "area";
|
|
30
|
+
value?: string;
|
|
31
|
+
width?: number | string;
|
|
32
|
+
height?: number | string;
|
|
33
|
+
cols?: number;
|
|
34
|
+
rows?: number;
|
|
35
|
+
}
|
|
36
|
+
export type SettingsElement = SettingsInputElement | SettingsSelectElement | SettingsCheckboxElement | SettingsAreaElement;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@wxn0brp/flanker-settings",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"types": "dist/index.d.ts",
|
|
6
|
+
"description": "",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/wxn0brP/FlankerSettings.git"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/wxn0brP/FlankerSettings",
|
|
12
|
+
"author": "wxn0brP",
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"type": "module",
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "tsc && tsc-alias && bun run build.ts"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@wxn0brp/db-core": "^0.3.0",
|
|
20
|
+
"@wxn0brp/db-storage-web": "^0.0.5",
|
|
21
|
+
"@wxn0brp/flanker-ui": "^0.4.6",
|
|
22
|
+
"esbuild": "*",
|
|
23
|
+
"esbuild-style-plugin": "*",
|
|
24
|
+
"sass": "*",
|
|
25
|
+
"tsc-alias": "*",
|
|
26
|
+
"typescript": "*"
|
|
27
|
+
},
|
|
28
|
+
"peerDependencies": {
|
|
29
|
+
"@wxn0brp/db-core": ">=0.3.0",
|
|
30
|
+
"@wxn0brp/flanker-ui": ">=0.4.6"
|
|
31
|
+
},
|
|
32
|
+
"files": [
|
|
33
|
+
"dist"
|
|
34
|
+
],
|
|
35
|
+
"exports": {
|
|
36
|
+
".": {
|
|
37
|
+
"types": "./dist/index.d.ts",
|
|
38
|
+
"import": "./dist/index.js",
|
|
39
|
+
"default": "./dist/index.js"
|
|
40
|
+
},
|
|
41
|
+
"./*": {
|
|
42
|
+
"types": "./dist/*.d.ts",
|
|
43
|
+
"import": "./dist/*.js",
|
|
44
|
+
"default": "./dist/*.js"
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|