@modular-component/core 0.1.7 → 0.2.0

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.
Files changed (67) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/index.d.ts +31 -354
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +53 -157
  5. package/dist/index.js.map +1 -1
  6. package/package.json +2 -2
  7. package/src/index.ts +155 -240
  8. package/dist/types/arguments.d.ts +0 -33
  9. package/dist/types/arguments.d.ts.map +0 -1
  10. package/dist/types/arguments.js +0 -6
  11. package/dist/types/arguments.js.map +0 -1
  12. package/dist/types/methods/add.d.ts +0 -23
  13. package/dist/types/methods/add.d.ts.map +0 -1
  14. package/dist/types/methods/add.js +0 -8
  15. package/dist/types/methods/add.js.map +0 -1
  16. package/dist/types/methods/at.d.ts +0 -22
  17. package/dist/types/methods/at.d.ts.map +0 -1
  18. package/dist/types/methods/at.js +0 -7
  19. package/dist/types/methods/at.js.map +0 -1
  20. package/dist/types/methods/before.d.ts +0 -22
  21. package/dist/types/methods/before.d.ts.map +0 -1
  22. package/dist/types/methods/before.js +0 -7
  23. package/dist/types/methods/before.js.map +0 -1
  24. package/dist/types/methods/hook.d.ts +0 -14
  25. package/dist/types/methods/hook.d.ts.map +0 -1
  26. package/dist/types/methods/hook.js +0 -7
  27. package/dist/types/methods/hook.js.map +0 -1
  28. package/dist/types/methods/mock.d.ts +0 -26
  29. package/dist/types/methods/mock.d.ts.map +0 -1
  30. package/dist/types/methods/mock.js +0 -6
  31. package/dist/types/methods/mock.js.map +0 -1
  32. package/dist/types/methods/with.d.ts +0 -52
  33. package/dist/types/methods/with.d.ts.map +0 -1
  34. package/dist/types/methods/with.js +0 -8
  35. package/dist/types/methods/with.js.map +0 -1
  36. package/dist/types/methods.d.ts +0 -10
  37. package/dist/types/methods.d.ts.map +0 -1
  38. package/dist/types/methods.js +0 -5
  39. package/dist/types/methods.js.map +0 -1
  40. package/dist/types/modular-component.d.ts +0 -16
  41. package/dist/types/modular-component.d.ts.map +0 -1
  42. package/dist/types/modular-component.js +0 -5
  43. package/dist/types/modular-component.js.map +0 -1
  44. package/dist/types/stage.d.ts +0 -41
  45. package/dist/types/stage.d.ts.map +0 -1
  46. package/dist/types/stage.js +0 -5
  47. package/dist/types/stage.js.map +0 -1
  48. package/dist/types/utils.d.ts +0 -24
  49. package/dist/types/utils.d.ts.map +0 -1
  50. package/dist/types/utils.js +0 -5
  51. package/dist/types/utils.js.map +0 -1
  52. package/dist/types/validation.d.ts +0 -4
  53. package/dist/types/validation.d.ts.map +0 -1
  54. package/dist/types/validation.js +0 -2
  55. package/dist/types/validation.js.map +0 -1
  56. package/src/types/arguments.ts +0 -57
  57. package/src/types/methods/add.ts +0 -52
  58. package/src/types/methods/at.ts +0 -64
  59. package/src/types/methods/before.ts +0 -64
  60. package/src/types/methods/hook.ts +0 -27
  61. package/src/types/methods/mock.ts +0 -90
  62. package/src/types/methods/with.ts +0 -173
  63. package/src/types/methods.ts +0 -11
  64. package/src/types/modular-component.ts +0 -27
  65. package/src/types/stage.ts +0 -91
  66. package/src/types/utils.ts +0 -63
  67. package/src/types/validation.ts +0 -13
@@ -1,26 +0,0 @@
1
- /**
2
- * Methods for mocking the value returned by a given stage,
3
- * replacing the stage and bypassing its transform function
4
- */
5
- import { ModularComponent } from '../modular-component';
6
- import { MethodRecord } from '../methods';
7
- import { ValidateIndex } from '../validation';
8
- import { ComputeArguments } from '../arguments';
9
- import { FilterNever, Last, ToIndices } from '../utils';
10
- import { BeforeStage, ModularStages, StageIndices, StageTuple } from '../stage';
11
- interface ModularMockMethodIndices<Props extends {}, Ref, Methods extends Record<string, MethodRecord>, Stages extends StageTuple, Method extends keyof Methods, Indices extends number[], Symbol extends keyof ModularStages = Methods[Method]['symbol']> {
12
- <Arguments extends ComputeArguments<Props, Ref, Methods, BeforeStage<Stages, StageIndex>>, Value extends Stages[StageIndex]['value'], Mock extends ModularStages<Arguments, Value>[Symbol] extends {
13
- transform: infer T;
14
- } ? T : Value, StageIndex extends Index extends number ? Indices[Index] : Last<Indices>, ValidIndex extends ValidateIndex<Index, ToIndices<Indices>>, Index extends number>(mock: Mock, index: ValidIndex extends true ? Index : ToIndices<Indices>): ModularComponent<Props, Ref, Methods, Stages>;
15
- }
16
- interface ModularMockMethodLast<Props extends {}, Ref, Methods extends Record<string, MethodRecord>, Stages extends StageTuple, Method extends keyof Methods, Index extends number, Symbol extends keyof ModularStages = Methods[Method]['symbol']> {
17
- <Value extends Stages[Index]['value'], Mock extends ModularStages<any, Value>[Symbol] extends {
18
- transform: infer T;
19
- } ? T : Value>(mock: Mock): ModularComponent<Props, Ref, Methods, Stages>;
20
- }
21
- declare type ModularMockMethod<Props extends {}, Ref, Methods extends Record<string, MethodRecord>, Stages extends StageTuple, Method extends keyof Methods, Symbol extends keyof ModularStages = Methods[Method]['symbol'], Indices extends StageIndices<Stages, Symbol> = StageIndices<Stages, Symbol>> = Indices['length'] extends 0 ? never : ModularMockMethodIndices<Props, Ref, Methods, Stages, Method, Indices> & ModularMockMethodLast<Props, Ref, Methods, Stages, Method, Last<Indices>>;
22
- export declare type ModularMockMethods<Props extends {}, Ref, Methods extends Record<string, MethodRecord>, Stages extends StageTuple> = FilterNever<{
23
- [Method in keyof Methods as `mock${Method extends string ? Method : never}`]: ModularMockMethod<Props, Ref, Methods, Stages, Method>;
24
- }>;
25
- export {};
26
- //# sourceMappingURL=mock.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mock.d.ts","sourceRoot":"","sources":["../../../src/types/methods/mock.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,EAAE,WAA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MAAM,OAAO,IAAI,OAAO,MAAM,SAAS,MAAM,GACpD,MAAM,GACN,KAAK,EAAE,GAAG,iBAAiB,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC;CACrE,CAAC,CAAA"}
@@ -1,6 +0,0 @@
1
- /**
2
- * Methods for mocking the value returned by a given stage,
3
- * replacing the stage and bypassing its transform function
4
- */
5
- export {};
6
- //# sourceMappingURL=mock.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mock.js","sourceRoot":"","sources":["../../../src/types/methods/mock.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
@@ -1,52 +0,0 @@
1
- /**
2
- * Main factory methods adding or editing an entry for a given
3
- * stage. If multiple entries for the same stage were added
4
- * with the `add` method, an index can be passed to select the
5
- * entry to edit.
6
- */
7
- import { ModularComponent } from '../modular-component';
8
- import { Last, ToIndices } from '../utils';
9
- import { BeforeStage, ModularStages, StageIndices, StageTuple, UpsertStage } from '../stage';
10
- import { MethodRecord } from '../methods';
11
- import { ComputeArguments } from '../arguments';
12
- import { RestrictValue, ValidateIndex } from '../validation';
13
- interface ModularWithMethodDefault<Props extends {}, Ref, Methods extends Record<string, MethodRecord>, Stages extends StageTuple, Method extends keyof Methods, Symbol extends keyof ModularStages = Methods[Method]['symbol'], Arguments extends {} = ComputeArguments<Props, Ref, Methods, Stages>> {
14
- <Value extends RestrictValue<Arguments, Symbol>>(...args: undefined extends RestrictValue<Arguments, Symbol> ? [value?: Value] : [value: Value]): ModularComponent<Props, Ref, Methods, UpsertStage<Stages, {
15
- stage: Symbol;
16
- value: Value;
17
- }>>;
18
- }
19
- interface ModularWithMethodIndices<Props extends {}, Ref, Methods extends Record<string, MethodRecord>, Stages extends StageTuple, Method extends keyof Methods, Indices extends number[], Symbol extends keyof ModularStages = Methods[Method]['symbol']> {
20
- <Arguments extends ComputeArguments<Props, Ref, Methods, BeforeStage<Stages, StageIndex>>, Value extends RestrictValue<Arguments, Symbol>, PreviousValue extends Stages[StageIndex]['value'], Valid extends ModularStages<Arguments, Value>[Symbol] extends {
21
- validate: infer V;
22
- } ? V : ModularStages<Arguments, Value>[Symbol] extends {
23
- transform: infer V;
24
- } ? V : Value, PreviousValid extends ModularStages<Arguments, PreviousValue>[Symbol] extends {
25
- validate: infer V;
26
- } ? V : ModularStages<Arguments, PreviousValue>[Symbol] extends {
27
- transform: infer V;
28
- } ? V : PreviousValue, ValidValue extends [Valid] extends [PreviousValid] ? true : false, StageIndex extends Index extends number ? Indices[Index] : Last<Indices>, ValidIndex extends ValidateIndex<Index, ToIndices<Indices>>, Index extends number>(value: ValidValue extends true ? Value : PreviousValue, index: ValidIndex extends true ? Index : ToIndices<Indices>): ModularComponent<Props, Ref, Methods, UpsertStage<Stages, {
29
- stage: Symbol;
30
- value: Value;
31
- }, StageIndex>>;
32
- }
33
- interface ModularWithMethodLast<Props extends {}, Ref, Methods extends Record<string, MethodRecord>, Stages extends StageTuple, Method extends keyof Methods, Index extends number, Symbol extends keyof ModularStages = Methods[Method]['symbol'], Arguments extends {} = ComputeArguments<Props, Ref, Methods, BeforeStage<Stages, Index>>> {
34
- <Value extends RestrictValue<Arguments, Symbol>, PreviousValue extends Stages[Index]['value'], Valid extends ModularStages<Arguments, Value>[Symbol] extends {
35
- validate: infer V;
36
- } ? V : ModularStages<Arguments, Value>[Symbol] extends {
37
- transform: infer V;
38
- } ? V : Value, PreviousValid extends ModularStages<Arguments, PreviousValue>[Symbol] extends {
39
- validate: infer V;
40
- } ? V : ModularStages<Arguments, PreviousValue>[Symbol] extends {
41
- transform: infer V;
42
- } ? V : PreviousValue, ValidValue extends [Valid] extends [PreviousValid] ? true : false>(...args: undefined extends PreviousValue ? [value?: ValidValue extends true ? Value : PreviousValue] : [value: ValidValue extends true ? Value : PreviousValue]): ModularComponent<Props, Ref, Methods, UpsertStage<Stages, {
43
- stage: Symbol;
44
- value: Value;
45
- }, Index>>;
46
- }
47
- declare type ModularWithMethod<Props extends {}, Ref, Methods extends Record<string, MethodRecord>, Stages extends StageTuple, Method extends keyof Methods, Symbol extends keyof ModularStages = Methods[Method]['symbol'], Indices extends StageIndices<Stages, Symbol> = StageIndices<Stages, Symbol>> = Indices['length'] extends 0 ? ModularWithMethodDefault<Props, Ref, Methods, Stages, Method> : ModularWithMethodIndices<Props, Ref, Methods, Stages, Method, Indices> & ModularWithMethodLast<Props, Ref, Methods, Stages, Method, Last<Indices>>;
48
- export declare type ModularWithMethods<Props extends {}, Ref, Methods extends Record<string, MethodRecord>, Stages extends StageTuple> = {
49
- [Method in keyof Methods as `with${Method extends string ? Method : never}`]: ModularWithMethod<Props, Ref, Methods, Stages, Method>;
50
- };
51
- export {};
52
- //# sourceMappingURL=with.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"with.d.ts","sourceRoot":"","sources":["../../../src/types/methods/with.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AACvD,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAC1C,OAAO,EACL,WAAW,EACX,aAAa,EACb,YAAY,EACZ,UAAU,EACV,WAAW,EACZ,MAAM,UAAU,CAAA;AACjB,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAE5D,UAAU,wBAAwB,CAChC,KAAK,SAAS,EAAE,EAChB,GAAG,EACH,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,EAC5C,MAAM,SAAS,UAAU,EACzB,MAAM,SAAS,MAAM,OAAO,EAC5B,MAAM,SAAS,MAAM,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,EAC9D,SAAS,SAAS,EAAE,GAAG,gBAAgB,CAAC,KAAK,EAAE,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,MAAM,SAAS,MAAM,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,EAC9D,OAAO,SAAS,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,IACzE,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,GAC3B,wBAAwB,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,GAC7D,wBAAwB,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,GACpE,qBAAqB,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAA;AAE/E,oBAAY,kBAAkB,CAC5B,KAAK,SAAS,EAAE,EAChB,GAAG,EACH,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,EAC5C,MAAM,SAAS,UAAU,IACvB;KACD,MAAM,IAAI,MAAM,OAAO,IAAI,OAAO,MAAM,SAAS,MAAM,GACpD,MAAM,GACN,KAAK,EAAE,GAAG,iBAAiB,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC;CACrE,CAAA"}
@@ -1,8 +0,0 @@
1
- /**
2
- * Main factory methods adding or editing an entry for a given
3
- * stage. If multiple entries for the same stage were added
4
- * with the `add` method, an index can be passed to select the
5
- * entry to edit.
6
- */
7
- export {};
8
- //# sourceMappingURL=with.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"with.js","sourceRoot":"","sources":["../../../src/types/methods/with.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
@@ -1,10 +0,0 @@
1
- /**
2
- * Helper types for handling method records
3
- */
4
- import { ModularStages } from './stage';
5
- export declare type MethodRecord = {
6
- symbol: keyof ModularStages;
7
- field: string;
8
- transform?: (args: any, value: any) => any;
9
- };
10
- //# sourceMappingURL=methods.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"methods.d.ts","sourceRoot":"","sources":["../../src/types/methods.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAEvC,oBAAY,YAAY,GAAG;IACzB,MAAM,EAAE,MAAM,aAAa,CAAA;IAC3B,KAAK,EAAE,MAAM,CAAA;IACb,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,KAAK,GAAG,CAAA;CAC3C,CAAA"}
@@ -1,5 +0,0 @@
1
- /**
2
- * Helper types for handling method records
3
- */
4
- export {};
5
- //# sourceMappingURL=methods.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"methods.js","sourceRoot":"","sources":["../../src/types/methods.ts"],"names":[],"mappings":"AAAA;;GAEG"}
@@ -1,16 +0,0 @@
1
- /**
2
- * Main ModularComponent type
3
- */
4
- import { ForwardedRef, FunctionComponent, PropsWithChildren } from 'react';
5
- import { StageTuple } from './stage';
6
- import { MethodRecord } from './methods';
7
- import { ModularWithMethods } from './methods/with';
8
- import { ModularAddMethods } from './methods/add';
9
- import { ModularAtMethods } from './methods/at';
10
- import { ModularBeforeMethods } from './methods/before';
11
- import { ModularMockMethods } from './methods/mock';
12
- import { ModularHookMethods } from './methods/hook';
13
- export declare type ModularComponent<Props extends {}, Ref, Methods extends Record<string, MethodRecord>, Stages extends StageTuple> = ModularWithMethods<Props, Ref, Methods, Stages> & ModularAddMethods<Props, Ref, Methods, Stages> & ModularAtMethods<Props, Ref, Methods, Stages> & ModularBeforeMethods<Props, Ref, Methods, Stages> & ModularMockMethods<Props, Ref, Methods, Stages> & ModularHookMethods<Props, Ref, Methods, Stages> & FunctionComponent<PropsWithChildren<Props & {
14
- ref?: ForwardedRef<Ref>;
15
- }>>;
16
- //# sourceMappingURL=modular-component.d.ts.map
@@ -1 +0,0 @@
1
- {"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CAAC,CAAC,CAAA"}
@@ -1,5 +0,0 @@
1
- /**
2
- * Main ModularComponent type
3
- */
4
- export {};
5
- //# sourceMappingURL=modular-component.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"modular-component.js","sourceRoot":"","sources":["../../src/types/modular-component.ts"],"names":[],"mappings":"AAAA;;GAEG"}
@@ -1,41 +0,0 @@
1
- /**
2
- * Helper for manipulating stages and stage tuples
3
- */
4
- import { At, Before, Reduce, After, OneLess } from './utils';
5
- export interface ModularStages<Args = any, Value = any> {
6
- }
7
- declare type StageRecord = {
8
- stage: keyof ModularStages;
9
- value: unknown;
10
- };
11
- export declare type StageTuple = StageRecord[];
12
- export declare type AddStage<List extends StageTuple, Stage extends StageRecord> = [
13
- ...List,
14
- Stage
15
- ];
16
- export declare type ReplaceStageAt<List extends StageTuple, Stage extends StageRecord, At extends number | string> = {
17
- [Index in keyof List]: Index extends At ? List[Index]['stage'] extends Stage['stage'] ? Stage : List[Index] : List[Index];
18
- };
19
- declare type ReplaceStage<List extends StageTuple, Stage extends StageRecord, At extends number | string = never> = [At] extends [never] ? {
20
- [Index in keyof List]: List[Index]['stage'] extends Stage['stage'] ? Stage : List[Index];
21
- } : ReplaceStageAt<List, Stage, At>;
22
- export declare type ExtractStage<List extends StageTuple, Stage extends symbol, Union = List[number]> = Union extends {
23
- stage: Stage;
24
- value: infer U;
25
- } ? {
26
- stage: Stage;
27
- value: U;
28
- } : never;
29
- export declare type UpsertStage<List extends StageTuple, Stage extends StageRecord, At extends number = never> = [ExtractStage<List, Stage['stage']>] extends [never] ? AddStage<List, Stage> : ReplaceStage<List, Stage, At>;
30
- declare type IsolateStage<Tuple extends StageTuple, Stage extends symbol> = {
31
- [key in keyof Tuple]: Tuple[key]['stage'] extends Stage ? key : never;
32
- };
33
- export declare type StageIndices<Tuple extends StageTuple, Stage extends symbol> = Reduce<IsolateStage<Tuple, Stage>>;
34
- export declare type AtStage<Tuple extends StageTuple, Index extends number | string> = At<Tuple, Index> extends StageTuple ? At<Tuple, Index> : [];
35
- export declare type BeforeStage<Tuple extends StageTuple, Index extends number | string> = Before<Tuple, Index> extends StageTuple ? Before<Tuple, Index> : [];
36
- declare type AfterStage<Tuple extends StageTuple, Index extends number | string> = After<Tuple, Index> extends StageTuple ? After<Tuple, Index> : [];
37
- export declare type CleanUpStages<Tuple extends StageTuple> = {
38
- [key in keyof Tuple]: StageIndices<OneLess<AfterStage<Tuple, key>>, Tuple[key]['stage']>['length'] extends 0 ? Tuple[key] : never;
39
- };
40
- export {};
41
- //# sourceMappingURL=stage.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stage.d.ts","sourceRoot":"","sources":["../../src/types/stage.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAE5D,MAAM,WAAW,aAAa,CAAC,IAAI,GAAG,GAAG,EAAE,KAAK,GAAG,GAAG;CAAI;AAE1D,aAAK,WAAW,GAAG;IACjB,KAAK,EAAE,MAAM,aAAa,CAAA;IAC1B,KAAK,EAAE,OAAO,CAAA;CACf,CAAA;AACD,oBAAY,UAAU,GAAG,WAAW,EAAE,CAAA;AAEtC,oBAAY,QAAQ,CAAC,IAAI,SAAS,UAAU,EAAE,KAAK,SAAS,WAAW,IAAI;IACzE,GAAG,IAAI;IACP,KAAK;CACN,CAAA;AAED,oBAAY,cAAc,CACxB,IAAI,SAAS,UAAU,EACvB,KAAK,SAAS,WAAW,EACzB,EAAE,SAAS,MAAM,GAAG,MAAM,IACxB;KACD,KAAK,IAAI,MAAM,IAAI,GAAG,KAAK,SAAS,EAAE,GACnC,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,SAAS,KAAK,CAAC,OAAO,CAAC,GACzC,KAAK,GACL,IAAI,CAAC,KAAK,CAAC,GACb,IAAI,CAAC,KAAK,CAAC;CAChB,CAAA;AAED,aAAK,YAAY,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AAM,CAAC,YAAY,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAA;AAEtC,oBAAY,OAAO,CACjB,KAAK,SAAS,UAAU,EACxB,KAAK,SAAS,MAAM,GAAG,MAAM,IAC3B,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,SAAS,UAAU,GAAG,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,EAAE,CAAA;AAE/D,oBAAY,WAAW,CACrB,KAAK,SAAS,UAAU,EACxB,KAAK,SAAS,MAAM,GAAG,MAAM,IAC3B,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,SAAS,UAAU,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,EAAE,CAAA;AAEvE,aAAK,UAAU,CACb,KAAK,SAAS,UAAU,EACxB,KAAK,SAAS,MAAM,GAAG,MAAM,IAC3B,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,SAAS,UAAU,GAAG,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,EAAE,CAAA;AAErE,oBAAY,aAAa,CAAC,KAAK,SAAS,UAAU,IAAI;KACnD,GAAG,IAAI,MAAM,KAAK,GAAG,YAAY,CAChC,OAAO,CAAC,UAAU,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,EAC/B,KAAK,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CACpB,CAAC,QAAQ,CAAC,SAAS,CAAC,GACjB,KAAK,CAAC,GAAG,CAAC,GACV,KAAK;CACV,CAAA"}
@@ -1,5 +0,0 @@
1
- /**
2
- * Helper for manipulating stages and stage tuples
3
- */
4
- export {};
5
- //# sourceMappingURL=stage.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stage.js","sourceRoot":"","sources":["../../src/types/stage.ts"],"names":[],"mappings":"AAAA;;GAEG"}
@@ -1,24 +0,0 @@
1
- /**
2
- * Generic type helpers (tuple, union, object...)
3
- */
4
- export declare type OneLess<Tuple extends unknown[]> = Tuple extends [
5
- unknown,
6
- ...infer Rest
7
- ] ? Rest : Tuple;
8
- export declare type Before<Tuple extends unknown[], Index extends string | number> = `${Tuple['length']}` extends `${Index}` ? Tuple : Tuple extends [...infer Keep, infer Drop] ? Before<Keep, Index> : never;
9
- export declare type After<Tuple extends unknown[], Index extends string | number, Rest extends unknown[] = []> = `${Rest['length']}` extends `${Index}` ? Tuple : Tuple extends [infer Drop, ...infer Keep] ? After<Keep, Index, [...Rest, Drop]> : never;
10
- export declare type At<Tuple extends unknown[], Index extends string | number> = `${OneLess<Tuple>['length']}` extends `${Index}` ? Tuple : Tuple extends [...infer Keep, infer Drop] ? At<Keep, Index> : never;
11
- export declare type Reduce<T extends unknown[]> = T extends [...infer R, infer L] ? [L] extends [never] ? [...Reduce<R>] : [...Reduce<R>, L] : T;
12
- export declare type ToIndices<T extends unknown[]> = {
13
- [key in keyof T]: key;
14
- }[number];
15
- export declare type Last<T extends unknown[]> = T extends [...infer R, infer L] ? L : never;
16
- export declare type UnionToIntersection<U> = [U] extends [never] ? never : (U extends infer V ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
17
- declare type NonNeverKeys<Obj extends {}> = {
18
- [key in keyof Obj]: Obj[key] extends never ? never : key;
19
- }[keyof Obj];
20
- export declare type FilterNever<Obj extends {}> = {
21
- [key in NonNeverKeys<Obj>]: Obj[key];
22
- };
23
- export {};
24
- //# sourceMappingURL=utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/types/utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,oBAAY,OAAO,CAAC,KAAK,SAAS,OAAO,EAAE,IAAI,KAAK,SAAS;IAC3D,OAAO;IACP,GAAG,MAAM,IAAI;CACd,GACG,IAAI,GACJ,KAAK,CAAA;AACT,oBAAY,MAAM,CAChB,KAAK,SAAS,OAAO,EAAE,EACvB,KAAK,SAAS,MAAM,GAAG,MAAM,IAC3B,GAAG,KAAK,CAAC,QAAQ,CAAC,EAAE,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AAC,MAAM,CAAC,CAAA;AAC9E,oBAAY,IAAI,CAAC,CAAC,SAAS,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,GACnE,CAAC,GACD,KAAK,CAAA;AAKT,oBAAY,mBAAmB,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GACpD,KAAK,GACL,CAAC,CAAC,SAAS,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK,IAAI,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,EAAE,MAAM,CAAC,KAAK,IAAI,GACzE,CAAC,GACD,KAAK,CAAA;AAGT,aAAK,YAAY,CAAC,GAAG,SAAS,EAAE,IAAI;KACjC,GAAG,IAAI,MAAM,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,SAAS,KAAK,GAAG,KAAK,GAAG,GAAG;CACzD,CAAC,MAAM,GAAG,CAAC,CAAA;AAEZ,oBAAY,WAAW,CAAC,GAAG,SAAS,EAAE,IAAI;KACvC,GAAG,IAAI,YAAY,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC;CACrC,CAAA"}
@@ -1,5 +0,0 @@
1
- /**
2
- * Generic type helpers (tuple, union, object...)
3
- */
4
- export {};
5
- //# sourceMappingURL=utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/types/utils.ts"],"names":[],"mappings":"AAAA;;GAEG"}
@@ -1,4 +0,0 @@
1
- import { ModularStages } from './stage';
2
- export declare type ValidateIndex<Index extends number | undefined, Candidates extends string | number> = `${Index}` extends Candidates ? true : false;
3
- export declare type RestrictValue<Arguments extends {}, Stage extends keyof ModularStages> = ModularStages<Arguments>[Stage]['restrict'] extends never ? unknown : ModularStages<Arguments>[Stage]['restrict'];
4
- //# sourceMappingURL=validation.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/types/validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAEvC,oBAAY,aAAa,CACvB,KAAK,SAAS,MAAM,GAAG,SAAS,EAChC,UAAU,SAAS,MAAM,GAAG,MAAM,IAChC,GAAG,KAAK,EAAE,SAAS,UAAU,GAAG,IAAI,GAAG,KAAK,CAAA;AAEhD,oBAAY,aAAa,CACvB,SAAS,SAAS,EAAE,EACpB,KAAK,SAAS,MAAM,aAAa,IAC/B,aAAa,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,CAAC,UAAU,CAAC,SAAS,KAAK,GACzD,OAAO,GACP,aAAa,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,CAAC,UAAU,CAAC,CAAA"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=validation.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"validation.js","sourceRoot":"","sources":["../../src/types/validation.ts"],"names":[],"mappings":""}
@@ -1,57 +0,0 @@
1
- /**
2
- * Helpers for computing the arguments map generated by a given
3
- * set of stages
4
- */
5
-
6
- import { PropsWithChildren } from 'react'
7
- import { StageTuple, ModularStages, BeforeStage, CleanUpStages } from './stage'
8
- import { UnionToIntersection } from './utils'
9
-
10
- export type ComputeArguments<
11
- Props extends {},
12
- Ref,
13
- Methods extends Record<
14
- string,
15
- { symbol: keyof ModularStages; field: string }
16
- >,
17
- Stages extends StageTuple,
18
- CleanedStages extends StageTuple = CleanUpStages<Stages>,
19
- MethodList = Methods[keyof Methods],
20
- > = {
21
- props: Props extends { children: unknown } ? Props : PropsWithChildren<Props>
22
- ref: Ref
23
- children: Props extends { children: infer C }
24
- ? C
25
- : PropsWithChildren['children']
26
- } & (Stages['length'] extends 0
27
- ? {}
28
- : UnionToIntersection<
29
- {
30
- [key in keyof CleanedStages]: MethodList extends {
31
- symbol: CleanedStages[key]['stage']
32
- field: infer F
33
- }
34
- ? {
35
- [k in F extends string ? F : never]: ModularStages<
36
- ComputeArguments<
37
- Props,
38
- Ref,
39
- Methods,
40
- BeforeStage<CleanedStages, key>
41
- >,
42
- CleanedStages[key]['value']
43
- >[CleanedStages[key]['stage']] extends { transform: infer T }
44
- ? T
45
- : CleanedStages[key]['value']
46
- }
47
- : never
48
- }[number]
49
- >) extends infer U
50
- ? {
51
- [key in keyof U]: U[key] extends Record<string, unknown>
52
- ? U[key] extends infer V
53
- ? { [key in keyof V]: V[key] }
54
- : never
55
- : U[key]
56
- }
57
- : never
@@ -1,52 +0,0 @@
1
- /**
2
- * Methods for adding a new entry for a previous stage, rather
3
- * than reusing the previous one.
4
- * One two entries for the same stage have been added, `with`, `at` and
5
- * `mock` methods can take an optional index to select the entry to target
6
- */
7
-
8
- import { ModularComponent } from '../modular-component'
9
- import { AddStage, ModularStages, StageIndices, StageTuple } from '../stage'
10
- import { ComputeArguments } from '../arguments'
11
- import { RestrictValue } from '../validation'
12
- import { MethodRecord } from '../methods'
13
- import { FilterNever } from '../utils'
14
-
15
- interface ModularAddMethod<
16
- Props extends {},
17
- Ref,
18
- Methods extends Record<string, MethodRecord>,
19
- Stages extends StageTuple,
20
- Method extends keyof Methods,
21
- Symbol extends keyof ModularStages = Methods[Method]['symbol'],
22
- > {
23
- <
24
- Value extends RestrictValue<Arguments, Symbol>,
25
- Arguments extends ComputeArguments<Props, Ref, Methods, Stages>,
26
- >(
27
- ...args: undefined extends RestrictValue<Arguments, Symbol>
28
- ? [value?: Value]
29
- : [value: Value]
30
- ): ModularComponent<
31
- Props,
32
- Ref,
33
- Methods,
34
- AddStage<Stages, { stage: Symbol; value: Value }>
35
- >
36
- }
37
-
38
- export type ModularAddMethods<
39
- Props extends {},
40
- Ref,
41
- Methods extends Record<string, MethodRecord>,
42
- Stages extends StageTuple,
43
- > = FilterNever<{
44
- [Method in keyof Methods as `add${Method extends string
45
- ? Method
46
- : never}`]: StageIndices<
47
- Stages,
48
- Methods[Method]['symbol']
49
- >['length'] extends 0
50
- ? never
51
- : ModularAddMethod<Props, Ref, Methods, Stages, Method>
52
- }>
@@ -1,64 +0,0 @@
1
- /**
2
- * Methods for rewinding a modular component up to a given stage.
3
- * If multiple entries of the same stage were previously added,
4
- * it's possible to pass the index for the entry to rewind to.
5
- */
6
-
7
- import { ModularComponent } from '../modular-component'
8
- import { AtStage, StageIndices, StageTuple } from '../stage'
9
- import { FilterNever, Last, ToIndices } from '../utils'
10
- import { ValidateIndex } from '../validation'
11
- import { MethodRecord } from '../methods'
12
-
13
- interface ModularAtMethodIndices<
14
- Props extends {},
15
- Ref,
16
- Methods extends Record<string, MethodRecord>,
17
- Stages extends StageTuple,
18
- Method extends keyof Methods,
19
- Indices extends number[],
20
- > {
21
- <
22
- // Validate index
23
- StageIndex extends Index extends number ? Indices[Index] : Last<Indices>,
24
- ValidIndex extends ValidateIndex<Index, ToIndices<Indices>>,
25
- Index extends number,
26
- >(
27
- index: ValidIndex extends true ? Index : ToIndices<Indices>,
28
- ): ModularComponent<Props, Ref, Methods, AtStage<Stages, StageIndex>>
29
- }
30
-
31
- interface ModularAtMethodLast<
32
- Props extends {},
33
- Ref,
34
- Methods extends Record<string, MethodRecord>,
35
- Stages extends StageTuple,
36
- Method extends keyof Methods,
37
- Index extends number,
38
- > {
39
- (): ModularComponent<Props, Ref, Methods, AtStage<Stages, Index>>
40
- }
41
-
42
- type ModularAtMethod<
43
- Props extends {},
44
- Ref,
45
- Methods extends Record<string, MethodRecord>,
46
- Stages extends StageTuple,
47
- Method extends keyof Methods,
48
- Symbol extends symbol = Methods[Method]['symbol'],
49
- Indices extends StageIndices<Stages, Symbol> = StageIndices<Stages, Symbol>,
50
- > = Indices['length'] extends 0
51
- ? never
52
- : ModularAtMethodIndices<Props, Ref, Methods, Stages, Method, Indices> &
53
- ModularAtMethodLast<Props, Ref, Methods, Stages, Method, Last<Indices>>
54
-
55
- export type ModularAtMethods<
56
- Props extends {},
57
- Ref,
58
- Methods extends Record<string, MethodRecord>,
59
- Stages extends StageTuple,
60
- > = FilterNever<{
61
- [Method in keyof Methods as `at${Method extends string
62
- ? Method
63
- : never}`]: ModularAtMethod<Props, Ref, Methods, Stages, Method>
64
- }>
@@ -1,64 +0,0 @@
1
- /**
2
- * Methods for rewinding a modular component up to a given stage.
3
- * If multiple entries of the same stage were previously added,
4
- * it's possible to pass the index for the entry to rewind to.
5
- */
6
-
7
- import { ModularComponent } from '../modular-component'
8
- import { BeforeStage, StageIndices, StageTuple } from '../stage'
9
- import { FilterNever, Last, ToIndices } from '../utils'
10
- import { ValidateIndex } from '../validation'
11
- import { MethodRecord } from '../methods'
12
-
13
- interface ModularBeforeMethodIndices<
14
- Props extends {},
15
- Ref,
16
- Methods extends Record<string, MethodRecord>,
17
- Stages extends StageTuple,
18
- Method extends keyof Methods,
19
- Indices extends number[],
20
- > {
21
- <
22
- // Validate index
23
- StageIndex extends Index extends number ? Indices[Index] : Last<Indices>,
24
- ValidIndex extends ValidateIndex<Index, ToIndices<Indices>>,
25
- Index extends number,
26
- >(
27
- index: ValidIndex extends true ? Index : ToIndices<Indices>,
28
- ): ModularComponent<Props, Ref, Methods, BeforeStage<Stages, StageIndex>>
29
- }
30
-
31
- interface ModularBeforeMethodLast<
32
- Props extends {},
33
- Ref,
34
- Methods extends Record<string, MethodRecord>,
35
- Stages extends StageTuple,
36
- Method extends keyof Methods,
37
- Index extends number,
38
- > {
39
- (): ModularComponent<Props, Ref, Methods, BeforeStage<Stages, Index>>
40
- }
41
-
42
- type ModularBeforeMethod<
43
- Props extends {},
44
- Ref,
45
- Methods extends Record<string, MethodRecord>,
46
- Stages extends StageTuple,
47
- Method extends keyof Methods,
48
- Symbol extends symbol = Methods[Method]['symbol'],
49
- Indices extends StageIndices<Stages, Symbol> = StageIndices<Stages, Symbol>,
50
- > = Indices['length'] extends 0
51
- ? never
52
- : ModularBeforeMethodIndices<Props, Ref, Methods, Stages, Method, Indices> &
53
- ModularBeforeMethodLast<Props, Ref, Methods, Stages, Method, Last<Indices>>
54
-
55
- export type ModularBeforeMethods<
56
- Props extends {},
57
- Ref,
58
- Methods extends Record<string, MethodRecord>,
59
- Stages extends StageTuple,
60
- > = FilterNever<{
61
- [Method in keyof Methods as `before${Method extends string
62
- ? Method
63
- : never}`]: ModularBeforeMethod<Props, Ref, Methods, Stages, Method>
64
- }>
@@ -1,27 +0,0 @@
1
- /**
2
- * Methods for converting a modular component to hooks, either
3
- * a generic hook returning all the arguments, or a specific hook
4
- * returning one given argument.
5
- */
6
-
7
- import { StageTuple } from '../stage'
8
- import { MethodRecord } from '../methods'
9
- import { ComputeArguments } from '../arguments'
10
-
11
- export type ModularHookMethods<
12
- Props extends {},
13
- Ref,
14
- Methods extends Record<string, MethodRecord>,
15
- Stages extends StageTuple,
16
- Arguments extends {} = ComputeArguments<Props, Ref, Methods, Stages>,
17
- > = {
18
- asHook(): keyof Props extends never
19
- ? () => Arguments
20
- : (props: Props) => Arguments
21
- } & {
22
- [Arg in keyof Arguments as `asUse${Capitalize<
23
- Arg extends string ? Arg : never
24
- >}`]: keyof Props extends never
25
- ? () => () => Arguments[Arg]
26
- : () => (props: Props) => Arguments[Arg]
27
- }