Skip to content
This repository was archived by the owner on Oct 16, 2024. It is now read-only.

Commit 06c46f1

Browse files
committed
removed internal from multieditor
1 parent 86d1085 commit 06c46f1

File tree

15 files changed

+429
-365
lines changed

15 files changed

+429
-365
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
"nodemon": "^2.0.12",
7171
"prettier": "^2.3.2",
7272
"rollup": "^2.56.3",
73+
"rollup-plugin-bundle-size": "^1.0.3",
7374
"rollup-plugin-esbuild": "^4.5.0",
7475
"shx": "^0.3.3",
7576
"size-limit": "^5.0.1",

packages/multieditor/src/index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import { MultiEditor } from './internal';
1+
import { MultiEditor } from './multieditor';
2+
3+
export * from './multieditor';
4+
export * from './item';
5+
export * from './validator';
6+
export * from './status';
27

3-
export * from './internal';
48
export default MultiEditor;

packages/multieditor/src/internal.ts

Lines changed: 0 additions & 13 deletions
This file was deleted.

packages/multieditor/src/item.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ import {
33
defineConfig,
44
EnhancedState,
55
} from '@agile-ts/core';
6-
import { MultiEditor, Validator, Status, ItemKey } from './internal';
6+
import { ItemKey, MultiEditor } from './multieditor';
7+
import { Status } from './status';
8+
import { Validator } from './validator';
79

810
export class Item<DataType = any> extends EnhancedState<DataType> {
911
public editor: () => MultiEditor<DataType>;

packages/multieditor/src/multieditor/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { defineConfig } from '@agile-ts/utils';
21
import { Agile, shared } from '@agile-ts/core';
3-
import { EditorConfig, MultiEditor } from '../internal';
2+
import { defineConfig } from '@agile-ts/utils';
3+
import { EditorConfig, MultiEditor } from './multieditor';
44

55
export * from './multieditor';
66

packages/multieditor/src/multieditor/multieditor.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,9 @@ import {
77
Observer,
88
defineConfig,
99
} from '@agile-ts/core';
10-
import {
11-
Item,
12-
Validator,
13-
StatusType,
14-
StatusInterface,
15-
ValidationMethodInterface,
16-
} from '../internal';
10+
import { ValidationMethodInterface, Validator } from '../validator';
11+
import { Item } from '../item';
12+
import { StatusInterface, StatusType } from '../status';
1713

1814
export class MultiEditor<
1915
DataType = any,
Lines changed: 2 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -1,101 +1,2 @@
1-
import { Agile, copy, RuntimeJobConfigInterface } from '@agile-ts/core';
2-
import { Item, StatusObserver } from '../internal';
3-
4-
export class Status<DataType = any> {
5-
public agileInstance: () => Agile;
6-
7-
public item: Item<DataType>;
8-
public observer: StatusObserver; // Handles deps and subs of Status and is like an interface to the Runtime
9-
10-
public display = false;
11-
public _value: StatusInterface | null; // The last assigned Value
12-
public nextValue: StatusInterface | null; // The last set Value
13-
public activeValues: Set<StatusInterface> = new Set(); // All Values that got set during the validation Time of the Validator
14-
15-
// Tracking
16-
public track = false;
17-
public foundValues: Set<StatusInterface> = new Set();
18-
19-
/**
20-
* @public
21-
* Status - Represents the Status of an Item
22-
* @param item - Item to that the Status belongs
23-
*/
24-
constructor(item: Item<DataType>) {
25-
this.item = item;
26-
this.agileInstance = () => item.agileInstance();
27-
this._value = null;
28-
this.nextValue = null;
29-
this.observer = new StatusObserver(this.agileInstance(), this);
30-
}
31-
32-
/**
33-
* @public
34-
* Get current Value of Status
35-
* Note: Returns null if Status shouldn't get displayed
36-
*/
37-
public get value(): StatusInterface | null {
38-
return this.display ? this._value : null;
39-
}
40-
41-
//=========================================================================================================
42-
// Set
43-
//=========================================================================================================
44-
/**
45-
* @public
46-
* Set next Status Value that will be assigned to the Status
47-
* @param value - next Status Value
48-
*/
49-
public set(value: StatusInterface | null): this {
50-
this.nextValue = copy(value);
51-
52-
// Track Status
53-
if (this.track && value) this.foundValues.add(value);
54-
55-
// Assign Status to Item
56-
if (this.item.editor().canAssignStatusToItemOnChange(this.item))
57-
this.assign();
58-
59-
return this;
60-
}
61-
62-
//=========================================================================================================
63-
// Assign
64-
//=========================================================================================================
65-
/**
66-
* @public
67-
* Assign last set Status Value to the current Status Value
68-
* @param config - Config
69-
*/
70-
public assign(config: RuntimeJobConfigInterface = {}) {
71-
this.observer.assign(config);
72-
}
73-
74-
//=========================================================================================================
75-
// Get Tracked Statuses
76-
//=========================================================================================================
77-
/**
78-
* @internal
79-
* Returns tracked Values and stops Status from tracking anymore Values
80-
*/
81-
public getTrackedValues(): Set<StatusInterface> {
82-
const finalFoundStatuses = this.foundValues;
83-
84-
// Reset tracking
85-
this.track = false;
86-
this.foundValues = new Set();
87-
88-
return finalFoundStatuses;
89-
}
90-
}
91-
92-
export type StatusType = 'error' | 'success';
93-
94-
/**
95-
* @param type - Type of Status
96-
* @param message - Message of Status
97-
*/
98-
export interface StatusInterface {
99-
type: StatusType;
100-
message: string;
101-
}
1+
export * from './status.observer';
2+
export * from './status';

packages/multieditor/src/status/status.observer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { Status, StatusInterface } from '../internal';
21
import {
32
Agile,
43
copy,
@@ -10,6 +9,7 @@ import {
109
RuntimeJobConfigInterface,
1110
defineConfig,
1211
} from '@agile-ts/core';
12+
import { Status, StatusInterface } from './status';
1313

1414
export class StatusObserver extends Observer {
1515
public status: () => Status;
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
import { Agile, copy, RuntimeJobConfigInterface } from '@agile-ts/core';
2+
import { Item } from '../item';
3+
import { StatusObserver } from './status.observer';
4+
5+
export class Status<DataType = any> {
6+
public agileInstance: () => Agile;
7+
8+
public item: Item<DataType>;
9+
public observer: StatusObserver; // Handles deps and subs of Status and is like an interface to the Runtime
10+
11+
public display = false;
12+
public _value: StatusInterface | null; // The last assigned Value
13+
public nextValue: StatusInterface | null; // The last set Value
14+
public activeValues: Set<StatusInterface> = new Set(); // All Values that got set during the validation Time of the Validator
15+
16+
// Tracking
17+
public track = false;
18+
public foundValues: Set<StatusInterface> = new Set();
19+
20+
/**
21+
* @public
22+
* Status - Represents the Status of an Item
23+
* @param item - Item to that the Status belongs
24+
*/
25+
constructor(item: Item<DataType>) {
26+
this.item = item;
27+
this.agileInstance = () => item.agileInstance();
28+
this._value = null;
29+
this.nextValue = null;
30+
this.observer = new StatusObserver(this.agileInstance(), this);
31+
}
32+
33+
/**
34+
* @public
35+
* Get current Value of Status
36+
* Note: Returns null if Status shouldn't get displayed
37+
*/
38+
public get value(): StatusInterface | null {
39+
return this.display ? this._value : null;
40+
}
41+
42+
//=========================================================================================================
43+
// Set
44+
//=========================================================================================================
45+
/**
46+
* @public
47+
* Set next Status Value that will be assigned to the Status
48+
* @param value - next Status Value
49+
*/
50+
public set(value: StatusInterface | null): this {
51+
this.nextValue = copy(value);
52+
53+
// Track Status
54+
if (this.track && value) this.foundValues.add(value);
55+
56+
// Assign Status to Item
57+
if (this.item.editor().canAssignStatusToItemOnChange(this.item))
58+
this.assign();
59+
60+
return this;
61+
}
62+
63+
//=========================================================================================================
64+
// Assign
65+
//=========================================================================================================
66+
/**
67+
* @public
68+
* Assign last set Status Value to the current Status Value
69+
* @param config - Config
70+
*/
71+
public assign(config: RuntimeJobConfigInterface = {}) {
72+
this.observer.assign(config);
73+
}
74+
75+
//=========================================================================================================
76+
// Get Tracked Statuses
77+
//=========================================================================================================
78+
/**
79+
* @internal
80+
* Returns tracked Values and stops Status from tracking anymore Values
81+
*/
82+
public getTrackedValues(): Set<StatusInterface> {
83+
const finalFoundStatuses = this.foundValues;
84+
85+
// Reset tracking
86+
this.track = false;
87+
this.foundValues = new Set();
88+
89+
return finalFoundStatuses;
90+
}
91+
}
92+
93+
export type StatusType = 'error' | 'success';
94+
95+
/**
96+
* @param type - Type of Status
97+
* @param message - Message of Status
98+
*/
99+
export interface StatusInterface {
100+
type: StatusType;
101+
message: string;
102+
}

0 commit comments

Comments
 (0)