@thecb/components 8.0.6-beta.8 → 8.0.6-beta.9
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.
- package/dist/index.d.ts +45 -13
- package/package.json +1 -1
- package/src/components/atoms/form-select/index.d.ts +3 -3
- package/src/types/common/ErrorMessage.ts +2 -3
- package/src/types/common/Field.ts +4 -4
- package/src/types/common/FieldActions.ts +33 -4
- package/src/types/common/ReduxAction.ts +4 -0
- package/src/types/common/index.ts +4 -3
package/dist/index.d.ts
CHANGED
|
@@ -61,21 +61,53 @@ interface CardProps {
|
|
|
61
61
|
declare const Card: React.FC<Expand<CardProps> &
|
|
62
62
|
React.HTMLAttributes<HTMLElement>>;
|
|
63
63
|
|
|
64
|
-
interface ErrorMessage {
|
|
65
|
-
[fieldName: string]: string;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
64
|
interface Field {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
65
|
+
hasErrors?: boolean;
|
|
66
|
+
dirty?: boolean;
|
|
67
|
+
rawValue?: string;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
interface ReduxAction<T = string, P = {}> {
|
|
71
|
+
type: T;
|
|
72
|
+
payload?: P;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* These types should be moved to and referenced from redux-freeform if it implements TypeScript
|
|
77
|
+
*/
|
|
78
|
+
|
|
79
|
+
type ValidatorFn = (value: string) => boolean;
|
|
80
|
+
|
|
81
|
+
interface FieldActionPayload {
|
|
82
|
+
fieldName: string;
|
|
83
|
+
value?: string;
|
|
84
|
+
validator?: ValidatorFn;
|
|
72
85
|
}
|
|
73
86
|
|
|
87
|
+
type SetAction = ReduxAction<"field/SET", FieldActionPayload>;
|
|
88
|
+
type AddValidatorAction = ReduxAction<
|
|
89
|
+
"field/ADD_VALIDATOR",
|
|
90
|
+
FieldActionPayload
|
|
91
|
+
>;
|
|
92
|
+
type RemoveValidatorAction = ReduxAction<
|
|
93
|
+
"field/REMOVE_VALIDATOR",
|
|
94
|
+
FieldActionPayload
|
|
95
|
+
>;
|
|
96
|
+
type ClearAction = ReduxAction<"field/CLEAR">;
|
|
97
|
+
|
|
74
98
|
interface FieldActions {
|
|
75
|
-
set?: (value:
|
|
76
|
-
addValidator?: (
|
|
77
|
-
|
|
78
|
-
|
|
99
|
+
set?: (fieldName: string) => (value: string) => SetAction;
|
|
100
|
+
addValidator?: (
|
|
101
|
+
fieldName: string
|
|
102
|
+
) => (validator: ValidatorFn) => AddValidatorAction;
|
|
103
|
+
removeValidator?: (
|
|
104
|
+
fieldName: string
|
|
105
|
+
) => (validator: ValidatorFn) => RemoveValidatorAction;
|
|
106
|
+
clear?: () => ClearAction;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
interface ErrorMessage {
|
|
110
|
+
[fieldName: string]: string;
|
|
79
111
|
}
|
|
80
112
|
|
|
81
113
|
interface FormInputProps {
|
|
@@ -107,8 +139,8 @@ interface FormSelectProps {
|
|
|
107
139
|
options?: Option[];
|
|
108
140
|
fieldActions?: FieldActions;
|
|
109
141
|
showErrors?: boolean;
|
|
110
|
-
errorMessages?: ErrorMessage[]
|
|
111
|
-
field?: Field
|
|
142
|
+
errorMessages?: ErrorMessage[];
|
|
143
|
+
field?: Field;
|
|
112
144
|
}
|
|
113
145
|
|
|
114
146
|
declare const FormSelect: React.FC<Expand<FormSelectProps> &
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import Expand from "../../../util/expand";
|
|
3
|
-
import { ErrorMessage, Field, FieldActions} from "../../../types/common";
|
|
3
|
+
import { ErrorMessage, Field, FieldActions } from "../../../types/common";
|
|
4
4
|
|
|
5
5
|
interface Option {
|
|
6
6
|
text?: string;
|
|
@@ -14,8 +14,8 @@ export interface FormSelectProps {
|
|
|
14
14
|
options?: Option[];
|
|
15
15
|
fieldActions?: FieldActions;
|
|
16
16
|
showErrors?: boolean;
|
|
17
|
-
errorMessages?: ErrorMessage[]
|
|
18
|
-
field?: Field
|
|
17
|
+
errorMessages?: ErrorMessage[];
|
|
18
|
+
field?: Field;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
export const FormSelect: React.FC<Expand<FormSelectProps> &
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export default interface Field {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
2
|
+
hasErrors?: boolean;
|
|
3
|
+
dirty?: boolean;
|
|
4
|
+
rawValue?: string;
|
|
5
|
+
}
|
|
@@ -1,6 +1,35 @@
|
|
|
1
|
+
import ReduxAction from "./ReduxAction";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* These types should be moved to and referenced from redux-freeform if it implements TypeScript
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
type ValidatorFn = (value: string) => boolean;
|
|
8
|
+
|
|
9
|
+
interface FieldActionPayload {
|
|
10
|
+
fieldName: string;
|
|
11
|
+
value?: string;
|
|
12
|
+
validator?: ValidatorFn;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
type SetAction = ReduxAction<"field/SET", FieldActionPayload>;
|
|
16
|
+
type AddValidatorAction = ReduxAction<
|
|
17
|
+
"field/ADD_VALIDATOR",
|
|
18
|
+
FieldActionPayload
|
|
19
|
+
>;
|
|
20
|
+
type RemoveValidatorAction = ReduxAction<
|
|
21
|
+
"field/REMOVE_VALIDATOR",
|
|
22
|
+
FieldActionPayload
|
|
23
|
+
>;
|
|
24
|
+
type ClearAction = ReduxAction<"field/CLEAR">;
|
|
25
|
+
|
|
1
26
|
export default interface FieldActions {
|
|
2
|
-
set?: (value:
|
|
3
|
-
addValidator?: (
|
|
4
|
-
|
|
5
|
-
|
|
27
|
+
set?: (fieldName: string) => (value: string) => SetAction;
|
|
28
|
+
addValidator?: (
|
|
29
|
+
fieldName: string
|
|
30
|
+
) => (validator: ValidatorFn) => AddValidatorAction;
|
|
31
|
+
removeValidator?: (
|
|
32
|
+
fieldName: string
|
|
33
|
+
) => (validator: ValidatorFn) => RemoveValidatorAction;
|
|
34
|
+
clear?: () => ClearAction;
|
|
6
35
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
1
|
+
export { default as Field } from "./Field";
|
|
2
|
+
export { default as ReduxAction } from "./ReduxAction";
|
|
3
|
+
export { default as FieldActions } from "./FieldActions";
|
|
4
|
+
export { default as ErrorMessage } from "./ErrorMessage";
|