@thecb/components 8.0.6-beta.7 → 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 CHANGED
@@ -4,6 +4,7 @@ type Expand<T> = T extends infer O ? { [K in keyof O]: O[K] } : never;
4
4
 
5
5
  interface ButtonWithActionProps {
6
6
  action?: (event: React.ChangeEvent<HTMLInputElement>) => void;
7
+ disabled?: boolean;
7
8
  variant?: string;
8
9
  text?: string;
9
10
  textWrap?: boolean;
@@ -18,6 +19,7 @@ declare const ButtonWithAction: React.FC<Expand<ButtonWithActionProps> &
18
19
  React.HTMLAttributes<HTMLElement>>;
19
20
 
20
21
  interface ButtonWithLinkProps extends ButtonWithActionProps {
22
+ active?: boolean;
21
23
  linkExtraStyles?: string;
22
24
  url: string;
23
25
  disabled?: boolean;
@@ -59,21 +61,53 @@ interface CardProps {
59
61
  declare const Card: React.FC<Expand<CardProps> &
60
62
  React.HTMLAttributes<HTMLElement>>;
61
63
 
62
- interface ErrorMessage {
63
- [fieldName: string]: string;
64
- }
65
-
66
64
  interface Field {
67
- hasErrors?: boolean;
68
- dirty?: boolean;
69
- rawValue?: string;
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;
70
85
  }
71
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
+
72
98
  interface FieldActions {
73
- set?: (value: any) => void;
74
- addValidator?: (validator: any) => void;
75
- removeValidator?: (validator: any) => void;
76
- clear?: () => void;
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;
77
111
  }
78
112
 
79
113
  interface FormInputProps {
@@ -105,8 +139,8 @@ interface FormSelectProps {
105
139
  options?: Option[];
106
140
  fieldActions?: FieldActions;
107
141
  showErrors?: boolean;
108
- errorMessages?: ErrorMessage[]
109
- field?: Field
142
+ errorMessages?: ErrorMessage[];
143
+ field?: Field;
110
144
  }
111
145
 
112
146
  declare const FormSelect: React.FC<Expand<FormSelectProps> &
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thecb/components",
3
- "version": "8.0.6-beta.7",
3
+ "version": "8.0.6-beta.9",
4
4
  "description": "Common lib for CityBase react components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "typings": "dist/index.d.ts",
@@ -3,6 +3,7 @@ import Expand from "../../../util/expand";
3
3
 
4
4
  export interface ButtonWithActionProps {
5
5
  action?: (event: React.ChangeEvent<HTMLInputElement>) => void;
6
+ disabled?: boolean;
6
7
  variant?: string;
7
8
  text?: string;
8
9
  textWrap?: boolean;
@@ -3,6 +3,7 @@ import Expand from "../../../util/expand";
3
3
  import { ButtonWithActionProps } from "../button-with-action";
4
4
 
5
5
  export interface ButtonWithLinkProps extends ButtonWithActionProps {
6
+ active?: boolean;
6
7
  linkExtraStyles?: string;
7
8
  url: string;
8
9
  disabled?: boolean;
@@ -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,4 +1,3 @@
1
1
  export default interface ErrorMessage {
2
- [fieldName: string]: string;
3
- }
4
-
2
+ [fieldName: string]: string;
3
+ }
@@ -1,5 +1,5 @@
1
1
  export default interface Field {
2
- hasErrors?: boolean;
3
- dirty?: boolean;
4
- rawValue?: string;
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: any) => void;
3
- addValidator?: (validator: any) => void;
4
- removeValidator?: (validator: any) => void;
5
- clear?: () => void;
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
  }
@@ -0,0 +1,4 @@
1
+ export default interface ReduxAction<T = string, P = {}> {
2
+ type: T;
3
+ payload?: P;
4
+ }
@@ -1,3 +1,4 @@
1
- export { default as ErrorMessage } from "./ErrorMessage";
2
1
  export { default as Field } from "./Field";
3
- export { default as FieldActions } from "./FieldActions"
2
+ export { default as ReduxAction } from "./ReduxAction";
3
+ export { default as FieldActions } from "./FieldActions";
4
+ export { default as ErrorMessage } from "./ErrorMessage";