jabroni-outfit 1.6.4 → 2.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +68 -108
- package/dist/index.d.ts +148 -62
- package/dist/jabroni-outfit.es.js +3804 -2969
- package/dist/jabroni-outfit.es.js.map +1 -1
- package/dist/jabroni-outfit.umd.js +13 -16
- package/dist/jabroni-outfit.umd.js.map +1 -1
- package/package.json +18 -18
- package/src/app.ts +39 -0
- package/src/components/App.vue +40 -0
- package/src/components/Badge.vue +30 -0
- package/src/components/Chevron.vue +10 -0
- package/src/components/Header.vue +38 -0
- package/src/components/RowButton.vue +21 -0
- package/src/components/Section.vue +66 -0
- package/src/components/icons/Check.vue +17 -0
- package/src/components/icons/ChevronDown.vue +17 -0
- package/src/components/icons/ChevronUp.vue +17 -0
- package/src/components/icons/Minus.vue +17 -0
- package/src/components/icons/Sun.vue +21 -0
- package/src/components/inputs/InputCheckbox.vue +29 -0
- package/src/components/inputs/InputNumber.vue +24 -0
- package/src/components/inputs/InputRange.vue +66 -0
- package/src/components/inputs/InputText.vue +21 -0
- package/src/index.ts +4 -17
- package/src/scheme/default-scheme.ts +129 -0
- package/src/scheme/parser.ts +103 -0
- package/src/scheme/scheme-element.ts +93 -0
- package/src/store/default-state.ts +8 -37
- package/src/store/index.ts +63 -0
- package/src/store/persistent-state.ts +45 -17
- package/src/style/index.css +30 -0
- package/src/test/example.ts +56 -44
- package/src/test/umd-example.js +58 -27
- package/src/types/index.ts +48 -0
- package/src/utils/index.ts +33 -0
- package/src/store/store.ts +0 -52
- package/src/store/types.ts +0 -16
- package/src/style.css +0 -3
- package/src/typings/vue.d.ts +0 -6
- package/src/ui/default-scheme.ts +0 -76
- package/src/ui/index.ts +0 -31
- package/src/ui/types.ts +0 -27
- package/src/ui/vue-templates/App.vue +0 -48
- package/src/ui/vue-templates/Gen.vue +0 -21
- package/src/ui/vue-templates/RowElement.vue +0 -66
- package/src/ui/vue-templates/icons/Close.vue +0 -7
- package/src/ui/vue-templates/icons/Config.vue +0 -7
package/README.md
CHANGED
|
@@ -1,131 +1,91 @@
|
|
|
1
|
-
<h1 align="center">Jabroni Outfit</h1>
|
|
2
|
-
<h3 align="center">
|
|
3
|
-
<p align="center"><a href="https://smartacephale.github.io/
|
|
1
|
+
<h1 align="center">Jabroni Outfit GUI</h1>
|
|
2
|
+
<h3 align="center">Small GUI and Persistent State library based on Vue</h1>
|
|
3
|
+
<p align="center"><a href="https://smartacephale.github.io/Jabroni-Outfit-GUI/">https://smartacephale.github.io/Jabroni-Outfit-GUI/</a></p>
|
|
4
4
|
<p align="center">
|
|
5
|
-
<img src="https://
|
|
5
|
+
<img src="https://repository-images.githubusercontent.com/842958864/1e2ce513-9289-4e51-b68b-0e7f3de255d0" alt="Sublime's custom image"/>
|
|
6
6
|
</p>
|
|
7
7
|
|
|
8
|
-
###
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
### Key Features
|
|
13
|
-
|
|
14
|
-
- **State Management:**
|
|
15
|
-
- Define state variables with properties like `value`, `persistent`, and `watch`.
|
|
16
|
-
- Easily manage and update state values throughout your application.
|
|
17
|
-
- **UI Creation:**
|
|
18
|
-
- Create UI controls (e.g., text inputs, checkboxes) based on state variables.
|
|
19
|
-
- Automatically update the UI whenever state values change.
|
|
20
|
-
- **Persistence:**
|
|
21
|
-
- Store state values persistently across application sessions.
|
|
22
|
-
- **Flexibility:**
|
|
23
|
-
- Customize the UI and state management to fit your specific needs.
|
|
8
|
+
### Features
|
|
9
|
+
- Store vaiables are persistent by default.
|
|
10
|
+
- Store variable with <$> prefix are not persistent.
|
|
24
11
|
|
|
25
12
|
### Usage
|
|
26
13
|
|
|
27
|
-
**
|
|
14
|
+
**Import the Library:**
|
|
28
15
|
|
|
29
16
|
```javascript
|
|
30
|
-
import {
|
|
17
|
+
import { JabronioStore, JabronioGUI } from 'jabroni-outfit';
|
|
31
18
|
```
|
|
32
19
|
or umd cdn:
|
|
33
20
|
```javascript
|
|
34
21
|
<script src="https://unpkg.com/jabroni-outfit@latest/dist/jabroni-outfit.umd.js"></script>
|
|
35
22
|
...
|
|
36
|
-
const {
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
**2. Define State Variables:**
|
|
40
|
-
|
|
41
|
-
Create an object containing state variables. Each variable has properties:
|
|
42
|
-
|
|
43
|
-
- `value`: The current value of the state variable.
|
|
44
|
-
- `persistent`: Boolean indicating if the value should be stored persistently.
|
|
45
|
-
- `watch`: Boolean indicating if the UI should update when the value changes.
|
|
46
|
-
|
|
47
|
-
```javascript
|
|
48
|
-
const myState = {
|
|
49
|
-
gradientColor1: { value: "red", persistent: false, watch: true },
|
|
50
|
-
// ... other state variables
|
|
51
|
-
};
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
**3. Create a Store:**
|
|
55
|
-
|
|
56
|
-
Instantiate a `JabroniOutfitStore` object with your state definition.
|
|
57
|
-
|
|
58
|
-
```javascript
|
|
59
|
-
const store = new JabroniOutfitStore(myState);
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
**4. Create UI Controls:**
|
|
63
|
-
|
|
64
|
-
Define an object mapping state variables to UI control configurations.
|
|
65
|
-
|
|
66
|
-
```javascript
|
|
67
|
-
const uiConfig = {
|
|
68
|
-
gradientColor1: [{ type: "text", model: "localState.gradientColor1" }],
|
|
69
|
-
// ... other UI controls
|
|
70
|
-
};
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
**5. Create the UI:**
|
|
74
|
-
|
|
75
|
-
Instantiate a `JabroniOutfitUI` object with the store and UI configuration.
|
|
76
|
-
|
|
77
|
-
```javascript
|
|
78
|
-
const ui = new JabroniOutfitUI(store, uiConfig);
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
**6. Subscribe to reactive data:**
|
|
82
|
-
|
|
83
|
-
Use the `subscribe` method on the store to trigger updates whenever the state changes.
|
|
84
|
-
|
|
85
|
-
```javascript
|
|
86
|
-
store.subscribe(() => {
|
|
87
|
-
// ...
|
|
88
|
-
});
|
|
23
|
+
const { JabronioStore, JabronioGUI } = window.jabronioutfit;
|
|
89
24
|
```
|
|
90
25
|
|
|
91
26
|
### Example
|
|
92
27
|
|
|
93
28
|
```javascript
|
|
29
|
+
const { JabronioStore, JabronioGUI } = window.jabronioutfit;
|
|
30
|
+
|
|
31
|
+
const example = () => {
|
|
32
|
+
const customState = {
|
|
33
|
+
myFancyVariable: true,
|
|
34
|
+
};
|
|
35
|
+
const store = new JabronioStore(customState);
|
|
36
|
+
|
|
37
|
+
const scheme = [
|
|
38
|
+
{
|
|
39
|
+
title: 'Colors',
|
|
40
|
+
collapsed: true,
|
|
41
|
+
content: [
|
|
42
|
+
{
|
|
43
|
+
$color1: 'coral',
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
color2: 'crimson',
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
$color3: 'tomato',
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
size: 100,
|
|
53
|
+
type: 'range',
|
|
54
|
+
max: '500',
|
|
55
|
+
min: '0',
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
gradientEnabled: true,
|
|
59
|
+
label: 'gradient enabled',
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
reset: () => {
|
|
63
|
+
store.state.$color1 = 'darkslateblue';
|
|
64
|
+
store.state.color2 = 'maroon';
|
|
65
|
+
store.state.$color3 = 'darksalmon';
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
},
|
|
70
|
+
];
|
|
71
|
+
|
|
72
|
+
new JabronioGUI(scheme, store);
|
|
73
|
+
|
|
74
|
+
function drawGradient() {
|
|
75
|
+
const { $color1, color2, $color3, gradientEnabled, size } = store.state;
|
|
76
|
+
if (!gradientEnabled) {
|
|
77
|
+
document.body.style.background = '#000';
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
document.body.style.background = `repeating-radial-gradient(${$color1}, ${color2}, ${$color3} ${size}%)`;
|
|
81
|
+
}
|
|
94
82
|
|
|
95
|
-
|
|
96
|
-
JabroniOutfitStore,
|
|
97
|
-
JabroniOutfitUI
|
|
98
|
-
} = window.jabronioutfit;
|
|
99
|
-
|
|
100
|
-
const customState = {
|
|
101
|
-
gradientColor1: { value: "red", persistent: false, watch: true, type: "string" },
|
|
102
|
-
gradientColor2: { value: "coral", persistent: false, watch: true, type: "string" },
|
|
103
|
-
gradientColor3: { value: "orange", persistent: false, watch: true, type: "string" },
|
|
104
|
-
gradientEnabled: { value: true, persistent: false, watch: true, type: "boolean" },
|
|
105
|
-
uiEnabled: { value: true, persistent: true, watch: true, type: "boolean" }
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
const store = new JabroniOutfitStore(customState);
|
|
83
|
+
drawGradient();
|
|
109
84
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
gradientColor3: [{ type: "text", model: "localState.gradientColor3", placeholder: "color", labelBefore: "color3" }],
|
|
114
|
-
gradientEnabled: [{ type: "checkbox", model: "localState.gradientEnabled", labelBefore: "gradient enabled" }],
|
|
85
|
+
store.subscribe(() => {
|
|
86
|
+
drawGradient();
|
|
87
|
+
});
|
|
115
88
|
};
|
|
116
89
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
function drawGradient() {
|
|
120
|
-
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
121
|
-
const { gradientColor1, gradientColor2, gradientColor3, gradientEnabled } = store.localState;
|
|
122
|
-
if (!gradientEnabled) { document.body.style.background = 'blue'; return; }
|
|
123
|
-
document.body.style.background = `radial-gradient(${gradientColor1}, ${gradientColor2}, ${gradientColor3})`;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
drawGradient();
|
|
127
|
-
|
|
128
|
-
store.subscribe(() => {
|
|
129
|
-
drawGradient();
|
|
130
|
-
});
|
|
90
|
+
example();
|
|
131
91
|
```
|
package/dist/index.d.ts
CHANGED
|
@@ -1,81 +1,167 @@
|
|
|
1
1
|
import { createApp } from 'vue';
|
|
2
2
|
import { Reactive } from 'vue';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
4
|
+
declare type Callback<T> = (...args: T[]) => void;
|
|
5
|
+
|
|
6
|
+
declare const DefaultScheme: [{
|
|
7
|
+
readonly title: "Text Filter";
|
|
8
|
+
readonly collapsed: true;
|
|
9
|
+
readonly content: [{
|
|
10
|
+
readonly filterExclude: false;
|
|
11
|
+
readonly label: "exclude";
|
|
12
|
+
}, {
|
|
13
|
+
readonly filterExcludeWords: "";
|
|
14
|
+
readonly label: "keywords";
|
|
15
|
+
readonly watch: "filterExclude";
|
|
16
|
+
readonly placeholder: "word, word1|word2, f:full_word...";
|
|
17
|
+
}, {
|
|
18
|
+
readonly filterInclude: false;
|
|
19
|
+
readonly label: "include";
|
|
20
|
+
}, {
|
|
21
|
+
readonly filterIncludeWords: "";
|
|
22
|
+
readonly label: "keywords";
|
|
23
|
+
readonly watch: "filterInclude";
|
|
24
|
+
readonly placeholder: "word, word1|word2, f:full_word...";
|
|
25
|
+
}];
|
|
26
|
+
}, {
|
|
27
|
+
readonly title: "Duration Filter";
|
|
28
|
+
readonly collapsed: true;
|
|
29
|
+
readonly content: [{
|
|
30
|
+
readonly filterDuration: false;
|
|
31
|
+
readonly label: "enable";
|
|
32
|
+
}, {
|
|
33
|
+
readonly filterDurationMinutes: true;
|
|
34
|
+
readonly label: "minutes (seconds by default)";
|
|
35
|
+
}, {
|
|
36
|
+
readonly filterDurationFrom: 0;
|
|
37
|
+
readonly watch: "filterDuration";
|
|
38
|
+
readonly label: "from";
|
|
39
|
+
}, {
|
|
40
|
+
readonly filterDurationTo: 600;
|
|
41
|
+
readonly watch: "filterDuration";
|
|
42
|
+
readonly label: "to";
|
|
43
|
+
}];
|
|
44
|
+
}, {
|
|
45
|
+
readonly title: "Sort By";
|
|
46
|
+
readonly content: [{
|
|
47
|
+
readonly views: () => void;
|
|
48
|
+
}, {
|
|
49
|
+
readonly duration: () => void;
|
|
50
|
+
}];
|
|
51
|
+
}, {
|
|
52
|
+
readonly title: "Privacy Filter";
|
|
53
|
+
readonly content: [{
|
|
54
|
+
readonly filterPrivate: false;
|
|
55
|
+
readonly label: "private";
|
|
56
|
+
}, {
|
|
57
|
+
readonly filterPublic: false;
|
|
58
|
+
readonly label: "public";
|
|
59
|
+
}, {
|
|
60
|
+
readonly 'check access \uD83D\uDD13': () => void;
|
|
61
|
+
}];
|
|
62
|
+
}, {
|
|
63
|
+
readonly title: "Quality Filter";
|
|
64
|
+
readonly content: [{
|
|
65
|
+
readonly filterHD: false;
|
|
66
|
+
readonly label: "HD";
|
|
67
|
+
}];
|
|
68
|
+
}, {
|
|
69
|
+
readonly title: "Advanced";
|
|
70
|
+
readonly content: [{
|
|
71
|
+
readonly infiniteScrollEnabled: true;
|
|
72
|
+
readonly label: "infinite scroll";
|
|
73
|
+
}, {
|
|
74
|
+
readonly autoRequestAccess: false;
|
|
75
|
+
readonly label: "auto friend request";
|
|
76
|
+
}, {
|
|
77
|
+
readonly writeHistory: false;
|
|
78
|
+
}];
|
|
79
|
+
}, {
|
|
80
|
+
readonly title: "Badge";
|
|
81
|
+
readonly content: [{
|
|
82
|
+
readonly text: "return `${state.$paginationOffset}/${state.$paginationLast}`";
|
|
83
|
+
readonly vif: "return state.$paginationLast > 1";
|
|
84
|
+
}];
|
|
85
|
+
}];
|
|
86
|
+
|
|
87
|
+
declare type ExtractValuesByKey<T extends readonly any[], K extends string> = Extract<T[number], {
|
|
88
|
+
[P in K]: any;
|
|
89
|
+
}>[K];
|
|
90
|
+
|
|
91
|
+
declare type HTMLInputType = 'checkbox' | 'text' | 'number' | 'range' | '';
|
|
92
|
+
|
|
93
|
+
declare type HTMLTag = keyof HTMLElementTagNameMap;
|
|
94
|
+
|
|
95
|
+
declare type HTMLTagOrInputType = keyof HTMLElementTagNameMap | HTMLInputType;
|
|
96
|
+
|
|
97
|
+
export declare class JabronioGUI {
|
|
35
98
|
app: ReturnType<typeof createApp>;
|
|
36
99
|
private getRoot;
|
|
37
|
-
constructor(
|
|
100
|
+
constructor(scheme: SchemeInput, store: JabronioStore, rootSelector?: string, position?: string);
|
|
38
101
|
}
|
|
39
102
|
|
|
40
|
-
declare
|
|
103
|
+
export declare class JabronioStore {
|
|
104
|
+
private callbacks;
|
|
105
|
+
state: StoreState;
|
|
106
|
+
constructor(options?: StoreStateOptions);
|
|
107
|
+
subscribe(callback: Callback<StoreStateRaw>): void;
|
|
108
|
+
notify(subject: StoreStateRaw): void;
|
|
109
|
+
add(key: string, value: Primitive, watchKey?: string, safe?: boolean): this;
|
|
110
|
+
parseState(options: StoreStateOptions): void;
|
|
111
|
+
}
|
|
41
112
|
|
|
42
|
-
declare type
|
|
113
|
+
declare type Primitive = string | number | boolean;
|
|
43
114
|
|
|
44
|
-
declare
|
|
45
|
-
[key: string]: SchemeRow;
|
|
46
|
-
}
|
|
115
|
+
declare type RawSchemeElement = Partial<Exclude<_RawSchemeElement, keyof SchemeGroup<_RawSchemeElement>>>;
|
|
47
116
|
|
|
48
|
-
declare type
|
|
117
|
+
declare type _RawSchemeElement = Partial<SchemeElement> & {
|
|
118
|
+
[x: string]: Primitive | (() => void);
|
|
119
|
+
};
|
|
49
120
|
|
|
50
|
-
declare
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
labelBefore?: string;
|
|
55
|
-
innerText?: string;
|
|
56
|
-
max?: string;
|
|
57
|
-
min?: string;
|
|
121
|
+
declare class SchemeElement {
|
|
122
|
+
name?: string;
|
|
123
|
+
value?: Primitive | (() => void);
|
|
124
|
+
watch?: string;
|
|
58
125
|
step?: string;
|
|
59
|
-
|
|
126
|
+
min?: string;
|
|
127
|
+
max?: string;
|
|
128
|
+
vif?: string;
|
|
129
|
+
text?: string;
|
|
130
|
+
type: HTMLTagOrInputType;
|
|
131
|
+
label?: string;
|
|
60
132
|
placeholder?: string;
|
|
61
|
-
|
|
133
|
+
id: string;
|
|
134
|
+
constructor(schemeElement: RawSchemeElement);
|
|
135
|
+
private parseType;
|
|
136
|
+
private parseNumber;
|
|
137
|
+
private parseLabel;
|
|
138
|
+
private parseModel;
|
|
139
|
+
get isInput(): boolean;
|
|
140
|
+
get htmlTag(): HTMLTag;
|
|
141
|
+
get inputType(): HTMLInputType;
|
|
142
|
+
get callback(): (() => void) | undefined;
|
|
62
143
|
}
|
|
63
144
|
|
|
64
|
-
declare
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
145
|
+
declare type SchemeGroup<T> = {
|
|
146
|
+
title: string;
|
|
147
|
+
content: T[];
|
|
148
|
+
collapsed: boolean;
|
|
149
|
+
id: string;
|
|
150
|
+
};
|
|
70
151
|
|
|
71
|
-
declare type
|
|
152
|
+
export declare type SchemeInput = Partial<SchemeSection<RawSchemeElement>>[];
|
|
72
153
|
|
|
73
|
-
declare
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
154
|
+
declare type SchemeSection<T> = T | SchemeGroup<T>;
|
|
155
|
+
|
|
156
|
+
export declare function setupScheme<K extends ExtractValuesByKey<typeof DefaultScheme, 'title'>, T extends SchemeInput, TK extends ExtractValuesByKey<T, 'title'>>(selectFromDefaults: K[], customScheme?: T, order?: (K | TK)[]): SchemeInput;
|
|
157
|
+
|
|
158
|
+
declare type StoreState = Reactive<StoreStateRaw>;
|
|
159
|
+
|
|
160
|
+
declare type StoreStateOptions = Record<string, {
|
|
161
|
+
watch?: string;
|
|
162
|
+
value: Primitive;
|
|
163
|
+
} | Primitive>;
|
|
164
|
+
|
|
165
|
+
declare type StoreStateRaw = Record<string, Primitive>;
|
|
80
166
|
|
|
81
167
|
export { }
|