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

Commit 356a02c

Browse files
committed
fixed typos
1 parent 1b4b23c commit 356a02c

File tree

5 files changed

+36
-31
lines changed

5 files changed

+36
-31
lines changed

packages/core/src/collection/collection.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export class Collection<
3232
public agileInstance: () => Agile;
3333

3434
public config: CollectionConfigInterface;
35-
private initialConfig: CreateCollectionConfigInterface;
35+
private initialConfig: CreateCollectionConfigImpl;
3636

3737
// Key/Name identifier of the Collection
3838
public _key?: CollectionKey;
@@ -74,7 +74,10 @@ export class Collection<
7474
* @param agileInstance - Instance of Agile the Collection belongs to.
7575
* @param config - Configuration object
7676
*/
77-
constructor(agileInstance: Agile, config: CollectionConfig<DataType> = {}) {
77+
constructor(
78+
agileInstance: Agile,
79+
config: CreateCollectionConfig<DataType> = {}
80+
) {
7881
this.agileInstance = () => agileInstance;
7982
let _config = typeof config === 'function' ? config(this) : config;
8083
_config = defineConfig(_config, {
@@ -1521,7 +1524,9 @@ export type DefaultItem = Record<string, any>; // same as { [key: string]: any }
15211524
export type CollectionKey = string | number;
15221525
export type ItemKey = string | number;
15231526

1524-
export interface CreateCollectionConfigInterface<DataType = DefaultItem> {
1527+
export interface CreateCollectionConfigImpl<
1528+
DataType extends DefaultItem = DefaultItem
1529+
> {
15251530
/**
15261531
* Initial Groups of the Collection.
15271532
* @default []
@@ -1557,11 +1562,13 @@ export interface CreateCollectionConfigInterface<DataType = DefaultItem> {
15571562
initialData?: Array<DataType>;
15581563
}
15591564

1560-
export type CollectionConfig<DataType extends Object = DefaultItem> =
1561-
| CreateCollectionConfigInterface<DataType>
1565+
export type CreateCollectionConfig<
1566+
DataType extends DefaultItem = DefaultItem
1567+
> =
1568+
| CreateCollectionConfigImpl<DataType>
15621569
| ((
15631570
collection: Collection<DataType>
1564-
) => CreateCollectionConfigInterface<DataType>);
1571+
) => CreateCollectionConfigImpl<DataType>);
15651572

15661573
export interface CollectionConfigInterface {
15671574
/**

packages/core/src/collection/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Agile } from '../agile';
22
import { shared } from '../shared';
3-
import { Collection, CollectionConfig, DefaultItem } from './collection';
3+
import { Collection, CreateCollectionConfig, DefaultItem } from './collection';
44

55
export * from './collection';
66
export * from './collection.persistent';
@@ -29,7 +29,7 @@ export * from './selector';
2929
* @param agileInstance - Instance of Agile the Collection belongs to.
3030
*/
3131
export function createCollection<DataType extends DefaultItem = DefaultItem>(
32-
config?: CollectionConfig<DataType>,
32+
config?: CreateCollectionConfig<DataType>,
3333
agileInstance: Agile = shared
3434
): Collection<DataType> {
3535
return new Collection<DataType>(agileInstance, config);

packages/multieditor/src/multieditor/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Agile, shared } from '@agile-ts/core';
22
import { Multieditor } from './multieditor';
3-
import { EditorConfig, FieldData } from './types';
3+
import { CreateEditorConfig, FieldData } from './types';
44

55
export * from './multieditor';
66
export * from './types';
@@ -15,7 +15,7 @@ export * from './types';
1515
* @param agileInstance - Instance of Agile the Multieditor belongs to.
1616
*/
1717
export function createMultieditor<TFieldData extends FieldData = FieldData>(
18-
config: EditorConfig<TFieldData>,
18+
config: CreateEditorConfig<TFieldData>,
1919
agileInstance: Agile = shared
2020
): Multieditor<TFieldData> {
2121
return new Multieditor<TFieldData>(config, agileInstance);

packages/multieditor/src/multieditor/multieditor.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { StatusInterface, StatusType } from '../status';
66
import {
77
DeepFieldPaths,
88
DeepFieldPathValues,
9-
EditorConfig,
9+
CreateEditorConfig,
1010
EditorConfigInterface,
1111
EditorKey,
1212
EditorValidationSchemaType,
@@ -51,7 +51,7 @@ export class Multieditor<TFieldData extends FieldData = FieldData> {
5151
* @param agileInstance - Instance of Agile the Multieditor belongs to.
5252
* @param config - Configuration object
5353
*/
54-
constructor(config: EditorConfig<TFieldData>, agileInstance: Agile) {
54+
constructor(config: CreateEditorConfig<TFieldData>, agileInstance: Agile) {
5555
this.agileInstance = () => agileInstance;
5656
let _config = typeof config === 'function' ? config(this) : config;
5757
_config = defineConfig(_config, {
@@ -375,7 +375,7 @@ export class Multieditor<TFieldData extends FieldData = FieldData> {
375375
/**
376376
* Retrieves a single Item with the specified key/name identifier from the Multieditor.
377377
*
378-
* If the to retrieve Item doesn't exist, `undefined` is returned.
378+
* If the to retrieve Item doesn't exist, `null` is returned.
379379
*
380380
* @public
381381
* @param itemKey - Key/Name identifier of the Item.
@@ -422,7 +422,6 @@ export class Multieditor<TFieldData extends FieldData = FieldData> {
422422
return this.getItem(itemKey)?.initialStateValue;
423423
}
424424

425-
/**
426425
/**
427426
* Returns a boolean indicating whether at least one Item
428427
* of the Items with the specified key/name identifiers is modified.

packages/multieditor/src/multieditor/types.ts

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export type NestedValue<TValue extends Object = Object> = {
2525
[$NestedValue]: never;
2626
} & TValue;
2727

28-
// Creates an object type based on the specified object were each property is optional
28+
// Creates an object type, based on the specified object were each property is optional
2929
export type DeepPartial<T> = {
3030
[K in keyof T]?: DeepPartialImpl<T[K]>;
3131
};
@@ -36,13 +36,13 @@ type DeepPartialImpl<T> = T extends NestedValue
3636
? DeepPartial<T>
3737
: T;
3838

39-
// Creates an object type based on the specified object were each property at the top level is optional
39+
// Creates an object type, based on the specified object were each property at the top level is optional
4040
export type ShallowPartial<T> = {
4141
[K in keyof T]?: T;
4242
};
4343

4444

45-
// Extracts each path to a property from the specified object
45+
// Extracts each path to a property (e.g. user.location.city) from the specified object
4646
export type DeepPaths<T> = {
4747
[K in keyof T]: DeepPathsImpl<K & string, T[K]>;
4848
}[keyof T] & string;
@@ -51,12 +51,12 @@ type DeepPathsImpl<K extends string | number, V> = V extends Primitive
5151
? `${K}`
5252
: `${K}` | `${K}.${DeepPaths<V>}`;
5353

54-
// Extracts each path to a property at the top level of the specified object
54+
// Extracts each path to a property (e.g. user) at the top level of the specified object
5555
export type FlatPaths<T> = {
5656
[K in keyof T]: T[K] extends any ? K : never;
5757
}[keyof T] & string;
5858

59-
// Extracts the value type of the specified Path (P) in the provided object (T) at top level
59+
// Extracts the value type of the specified Path (P) in the provided object (T) at the top level
6060
export type DeepPathValues<T, P extends DeepPaths<T> | string | number> = T extends any
6161
? P extends `${infer K}.${infer R}` // if having nested Path like 'image.id'
6262
? K extends keyof T
@@ -81,10 +81,9 @@ export type DeepFieldPathValues<
8181
TFieldPath extends DeepFieldPaths<TFieldData>,
8282
> = DeepPathValues<TFieldData, TFieldPath>;
8383

84-
8584
export type EditorKey = string | number;
8685

87-
export interface CreateEditorConfigInterface<
86+
export interface CreateEditorConfigImpl<
8887
TFieldData extends FieldData = FieldData
8988
> {
9089
/**
@@ -98,13 +97,13 @@ export interface CreateEditorConfigInterface<
9897
*/
9998
initialData: TFieldData;
10099
/**
101-
* Key/name identifiers of Items whose values
100+
* Key/name identifiers of the Items whose values
102101
* to be always passed to the specified 'onSubmit()' method.
103102
* @default []
104103
*/
105104
fixedProperties?: string[];
106105
/**
107-
* Key/Name identifiers of Items that can be edited.
106+
* Key/Name identifiers of the Items that can be edited.
108107
* @default Object.keys(config.initialData)
109108
*/
110109
editableProperties?: string[];
@@ -127,7 +126,7 @@ export interface CreateEditorConfigInterface<
127126
config?: any
128127
) => Promise<any>;
129128
/**
130-
* In which circumstances the Multieditor is revalidated.
129+
* In which circumstances the Multieditor should be revalidated.
131130
* @default 'onSubmit'
132131
*/
133132
reValidateMode?: ValidationMode;
@@ -138,13 +137,19 @@ export interface CreateEditorConfigInterface<
138137
toValidate?: ValidateType;
139138
}
140139

140+
export type CreateEditorConfig<TFieldData extends FieldData = FieldData> =
141+
| CreateEditorConfigImpl<TFieldData>
142+
| ((
143+
editor: Multieditor<TFieldData>
144+
) => CreateEditorConfigImpl<TFieldData>);
145+
141146
export type EditorValidationSchemaType = {
142147
[key: string]: ValidationMethodInterface | Validator;
143148
};
144149

145150
export interface EditorConfigInterface {
146151
/**
147-
* In which circumstances the Multieditor is revalidated.
152+
* In which circumstances the Multieditor should be revalidated.
148153
* @default 'onSubmit'
149154
*/
150155
reValidateMode: ValidationMode;
@@ -155,12 +160,6 @@ export interface EditorConfigInterface {
155160
toValidate: ValidateType;
156161
}
157162

158-
export type EditorConfig<TFieldData extends FieldData = FieldData> =
159-
| CreateEditorConfigInterface<TFieldData>
160-
| ((
161-
editor: Multieditor<TFieldData>
162-
) => CreateEditorConfigInterface<TFieldData>);
163-
164163
export interface SubmitConfigInterface<OnSubmitConfigType = any> {
165164
/**
166165
* Whether the submitted values should be assigned

0 commit comments

Comments
 (0)