Skip to content

Commit 0215f21

Browse files
authored
Refactor SettingColumns and Modal Logic (#160)
- Added new `SettingColumn` base class - Updated `Button`, `DisplayField`, `Dropdown`, `Input`, and `TagSearch` to extend `SettingColumn` - Standardized settings and elements definitions across setting column classes - Removed `ISettingColumn` interface and associated file - Introduced `IToggleSettings` and `IToggleElements` interfaces - Refactored `Input`, `Toggle`, and `TagSearch` classes for improved structure - Enhanced modal logic to include required fields validation - Added `Notice` import and usage for user notifications - Updated ESLint configuration for naming conventions - Removed unnecessary type imports and cleaned up code structure
1 parent f7bf658 commit 0215f21

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1442
-1269
lines changed

.eslintrc

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,18 @@
6767
"match": true
6868
}
6969
},
70+
{
71+
"selector": "classProperty",
72+
"modifiers": [
73+
"private",
74+
"readonly"
75+
],
76+
"format": [],
77+
"custom": {
78+
"regex": "^(_{1,2}I[A-Z][a-zA-Z0-9]*_?|_{1,2}[a-z][a-zA-Z0-9]*|_{2}[a-zA-Z][a-zA-Z0-9]*)$",
79+
"match": true
80+
}
81+
},
7082
{
7183
"selector": "classProperty",
7284
"modifiers": [
@@ -109,7 +121,7 @@
109121
],
110122
"leadingUnderscore": "forbid",
111123
"filter": {
112-
"regex": "^(Events|Styles|Classes|Then|TextContent)$",
124+
"regex": "^(Events|Styles|Classes|Then|TextContent|El)$",
113125
"match": false
114126
}
115127
},
@@ -137,7 +149,7 @@
137149
"camelCase"
138150
],
139151
"filter": {
140-
"regex": ".*-event$|^(Events|Styles|Classes|Then|TextContent)$",
152+
"regex": ".*-event$|^(Events|Styles|Classes|Then|TextContent|El)$",
141153
"match": false
142154
}
143155
}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,6 @@ src/auto-imports.ts
4040

4141
.locale
4242
isolate-*-v8.log
43+
44+
ait.config.json
45+
ait.*.config.json

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "prj",
33
"name": "Prj Plugin",
4-
"version": "0.6.26",
4+
"version": "0.6.27",
55
"minAppVersion": "0.15.0",
66
"description": "Prj Plugin - Project, Document, and Task Management",
77
"author": "M. Passarello",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "obsidian-prj-plugin",
3-
"version": "0.6.26",
3+
"version": "0.6.27",
44
"description": "Prj Plugin - Project, Document, and Task Management",
55
"main": "main.js",
66
"scripts": {
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
* Decorator to enforce **static** implementation of an interface.
3+
* @returns A decorator function
4+
* ---
5+
* **Will be checked at compile time.**
6+
* @see {@link Implements} for instance implementation type checking.
7+
*/
8+
export function ImplementsStatic<I>() {
9+
return <T extends I>(constructor: T, ...args: unknown[]) => {};
10+
}
11+
12+
export { ImplementsStatic as Implements_ };
13+
14+
/**
15+
* Decorator to enforce **instance** implementation of an interface.
16+
* @returns A decorator function
17+
* ---
18+
* **Will be checked at compile time.**
19+
* @see {@link ImplementsStatic} for static implementation type checking.
20+
*/
21+
export function Implements<I>() {
22+
return <T extends new (...args: unknown[]) => I>(
23+
constructor: T,
24+
): void => {};
25+
}
Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1 @@
1-
/**
2-
* Decorator to enforce static implementation of an interface
3-
* @returns A decorator function
4-
*/
5-
export function ImplementsStatic<I>() {
6-
return <T extends I>(constructor: T, ...args: unknown[]) => {};
7-
}
1+
export { ImplementsStatic } from './Implements';

src/libs/DIComponent/types/EventTypes.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/* eslint-disable @typescript-eslint/naming-convention */
2+
import { ValidatorDelegate } from 'src/libs/Settings/SettingColumns/types/General';
23
import { IDIComponent } from '../interfaces/IDIComponent';
34

45
/**
@@ -29,6 +30,11 @@ export type EventRegistry = Record<EventKey, (EventCallback | undefined)[]>;
2930
export type InjectDelegate = (ctx: IDIComponent & unknown) => void;
3031

3132
export type SpecificEventMap = {
33+
/**
34+
* The event is broadcasted to all children
35+
* after the parent and children are loaded.
36+
*/
37+
loaded: [];
3238
/**
3339
* All indipendent Windows should have this classes.
3440
* The parent will emit this event to all children
@@ -40,6 +46,11 @@ export type SpecificEventMap = {
4046
* key of the result and the result itself.
4147
*/
4248
result: [string, unknown];
49+
/**
50+
* A child can emit this event to the parent with the
51+
* key of the result and a boolean value or a validator delegate.
52+
*/
53+
'required-results': [string, boolean | ValidatorDelegate | undefined];
4354
};
4455

4556
export type SpecificEventCallback<K extends keyof SpecificEventMap> = (

src/libs/HTMLFlow/Flow.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,13 @@ import { ImplementsStatic } from 'src/classes/decorators/ImplementsStatic';
22
import type { ILogger, ILogger_ } from 'src/interfaces/ILogger';
33
import { Register } from 'ts-injex';
44
import { Inject } from 'ts-injex';
5-
import type { IFlow, IFlowApiType, ISetValueType } from './interfaces/IFlow';
6-
import { IFlow_, IFlowApi } from './interfaces/IFlow';
5+
import {
6+
IFlow_,
7+
IFlow,
8+
IFlowApiType,
9+
IFlowApi,
10+
ISetValueType,
11+
} from './interfaces/IFlow';
712
import type { IFlowTag } from './interfaces/IFlowTag';
813
import { IFlowSymbol, isIFlowTagged } from './interfaces/IFlowTag';
914
import {
@@ -18,8 +23,7 @@ import type {
1823
IFlowEventCallback,
1924
IFlowThenCallback,
2025
} from './types/IFlowDelegates';
21-
import { DIComponent } from '../DIComponent/DIComponent';
22-
import { shouldRemoveOnUnload, isLoaded } from '../DIComponent/types/IDIComponentSymbols';
26+
import { DIComponent, isLoaded, shouldRemoveOnUnload } from '../DIComponent';
2327

2428
/**
2529
* A HTML Fluent API class.
@@ -558,6 +562,9 @@ export class Flow<Tag extends keyof HTMLElementTagNameMap>
558562
this.addEventListener(events);
559563
}
560564
break;
565+
case 'El':
566+
this.getEl(value[key]);
567+
break;
561568
case 'Styles':
562569
this.setStyles(value[key]);
563570
break;

src/libs/HTMLFlow/Opts.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
/**
1010
* Options inspector factory.
1111
* @see {@link Opts.inspect}
12+
* @deprecated This class is deprecated and will be removed in the next **MINOR** version.
1213
*/
1314
@Register('Opts')
1415
export class Opts {

src/libs/HTMLFlow/interfaces/IFlow.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
StylesParameters,
88
ClassesParameters,
99
AddEventsParameters,
10+
GetElParameters,
1011
} from '../types/IFlow';
1112
import {
1213
IFlowConfig,
@@ -263,7 +264,9 @@ export interface IFlowApi<
263264
//# Set generic methods
264265

265266
/**
266-
* Sets the **Atrributes**, **Classes**, **Styles** and **Events** of the element.
267+
* Sets the **Atrributes**, **Classes**, **Styles** and **Events** of the element
268+
* an let you get the **El**ement.
269+
* @see {@link ISetValueType}
267270
* @param value The values to set.
268271
* @returns The Flow instance.
269272
*/
@@ -285,6 +288,11 @@ export interface ISetValueType<
285288
*/
286289
[key: string]: string | unknown;
287290

291+
/**
292+
* Element to get.
293+
*/
294+
El?: TupleToUnion<GetElParameters<Tag>>;
295+
288296
/**
289297
* Events to add to the element.
290298
*/

0 commit comments

Comments
 (0)