@@ -6,28 +6,33 @@ import { assert } from '../../utilities/assert'
66import { wrap , reducer as reducerDefault } from './reducer'
77import { extract } from '../../utilities/extract'
88import {
9- type ActionDescription ,
10- type GenericInputGroupReducer ,
11- type ActionReducer ,
12- type ActionInput ,
13- type ActionReference ,
14- type Actions ,
15- type Settings ,
16- type State ,
17- TypeAction ,
9+ type InputGroupActionDescription ,
10+ type InputGroupReducerGeneric ,
11+ type InputGroupActionReducer ,
12+ type InputGroupActionInput ,
13+ type InputGroupActionReference ,
14+ type InputGroupActions ,
15+ type InputGroupSettings ,
16+ type InputGroupState ,
17+ InputGroupTypeAction ,
1818} from './types'
1919
20- const fluentReducer = ( log : Actions ) : State => {
20+ const fluentReducer = ( log : InputGroupActions ) : InputGroupState => {
2121 const reference = (
22- find ( log , ( action ) => action . type === TypeAction . Reference ) as ActionReference | undefined
22+ find ( log , ( action ) => action . type === InputGroupTypeAction . Reference ) as
23+ | InputGroupActionReference
24+ | undefined
2325 ) ?. payload
2426
25- const description = find ( log , ( action ) => action . type === TypeAction . Description ) ?. payload
27+ const description = find (
28+ log ,
29+ ( action ) => action . type === InputGroupTypeAction . Description ,
30+ ) ?. payload
2631
2732 const rlog = reverse ( [ ...log ] )
2833
2934 const inputs = map (
30- filter ( rlog , ( { type } ) => type === TypeAction . Input ) as ActionInput [ ] ,
35+ filter ( rlog , ( { type } ) => type === InputGroupTypeAction . Input ) as InputGroupActionInput [ ] ,
3136 ( value ) => value . payload ,
3237 )
3338
@@ -37,10 +42,12 @@ const fluentReducer = (log: Actions): State => {
3742 const variables = flatMap ( inputs , ( value ) => value [ SYMBOL_STATE ] . variables )
3843
3944 const reducerMaybe = (
40- find ( log , ( action ) => action . type === TypeAction . Reducer ) as ActionReducer | undefined
45+ find ( log , ( action ) => action . type === InputGroupTypeAction . Reducer ) as
46+ | InputGroupActionReducer
47+ | undefined
4148 ) ?. payload
4249
43- const reducer : GenericInputGroupReducer =
50+ const reducer : InputGroupReducerGeneric =
4451 reducerMaybe === undefined
4552 ? reducerDefault
4653 : async ( values , properties ) => reducerMaybe ( await wrap ( values , properties ) , properties )
@@ -57,75 +64,75 @@ const fluentReducer = (log: Actions): State => {
5764 }
5865}
5966
60- export const group = builder < Settings > ( [
67+ export const group = builder < InputGroupSettings > ( [
6168 {
6269 [ Options . Interface ] : ( dispatch ) => ( {
6370 reference ( reference : Reference ) {
6471 assert . reference ( reference )
6572
66- return dispatch < ActionReference > ( {
73+ return dispatch < InputGroupActionReference > ( {
6774 payload : reference ,
68- type : TypeAction . Reference ,
75+ type : InputGroupTypeAction . Reference ,
6976 } )
7077 } ,
7178 } ) ,
7279 [ Options . Keys ] : [ 'reference' ] ,
7380 [ Options . Once ] : true ,
7481 [ Options . Reducer ] : fluentReducer ,
75- [ Options . Type ] : TypeAction . Reference ,
82+ [ Options . Type ] : InputGroupTypeAction . Reference ,
7683 } ,
7784 {
78- [ Options . Dependencies ] : [ TypeAction . Reference ] ,
85+ [ Options . Dependencies ] : [ InputGroupTypeAction . Reference ] ,
7986 [ Options . Interface ] : ( dispatch ) => ( {
8087 description ( description : string ) {
8188 assert . string ( description )
8289
83- return dispatch < ActionDescription > ( {
90+ return dispatch < InputGroupActionDescription > ( {
8491 payload : description ,
85- type : TypeAction . Description ,
92+ type : InputGroupTypeAction . Description ,
8693 } )
8794 } ,
8895 } ) ,
8996 [ Options . Keys ] : [ 'description' ] ,
9097 [ Options . Once ] : true ,
9198 [ Options . Reducer ] : fluentReducer ,
92- [ Options . Type ] : TypeAction . Description ,
99+ [ Options . Type ] : InputGroupTypeAction . Description ,
93100 } ,
94101 {
95- [ Options . Conflicts ] : [ TypeAction . Reducer ] ,
96- [ Options . Dependencies ] : [ TypeAction . Description ] ,
102+ [ Options . Conflicts ] : [ InputGroupTypeAction . Reducer ] ,
103+ [ Options . Dependencies ] : [ InputGroupTypeAction . Description ] ,
97104 [ Options . Interface ] : ( dispatch , log , state ) => ( {
98105 input ( value : Input ) {
99106 assert . input ( value , { log, state } )
100107
101108 const payload = extract ( value )
102109
103- return dispatch < ActionInput > ( {
110+ return dispatch < InputGroupActionInput > ( {
104111 payload,
105- type : TypeAction . Input ,
112+ type : InputGroupTypeAction . Input ,
106113 } )
107114 } ,
108115 } ) ,
109116 [ Options . Keys ] : [ 'input' ] ,
110117 [ Options . Once ] : false ,
111118 [ Options . Reducer ] : fluentReducer ,
112- [ Options . Type ] : TypeAction . Input ,
119+ [ Options . Type ] : InputGroupTypeAction . Input ,
113120 } ,
114121 {
115122 [ Options . Enabled ] : ( _ , state ) => ! state . isEmpty ,
116123 [ Options . Interface ] : ( dispatch ) => ( {
117- reducer ( value : GenericInputGroupReducer ) {
124+ reducer ( value : InputGroupReducerGeneric ) {
118125 assert . function ( value )
119126
120- return dispatch < ActionReducer > ( {
127+ return dispatch < InputGroupActionReducer > ( {
121128 payload : value ,
122- type : TypeAction . Reducer ,
129+ type : InputGroupTypeAction . Reducer ,
123130 } )
124131 } ,
125132 } ) ,
126133 [ Options . Keys ] : [ 'reducer' ] ,
127134 [ Options . Once ] : true ,
128135 [ Options . Reducer ] : fluentReducer ,
129- [ Options . Type ] : TypeAction . Reducer ,
136+ [ Options . Type ] : InputGroupTypeAction . Reducer ,
130137 } ,
131138] )
0 commit comments