@thecb/components 9.0.3 → 9.0.4-beta.2
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.cjs.js +23 -12
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +23 -12
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/atoms/alert/Alert.js +7 -3
- package/src/components/atoms/form-layouts/FormInput.js +27 -25
- package/src/components/molecules/partial-amount-form/PartialAmountForm.js +1 -0
- package/src/components/molecules/partial-amount-form/PartialAmountForm.stories.js +146 -0
package/package.json
CHANGED
|
@@ -24,7 +24,10 @@ const Alert = ({
|
|
|
24
24
|
enableSmallText = false,
|
|
25
25
|
innerContentPadding = "1rem",
|
|
26
26
|
iconPadding = "0 0 0 1rem",
|
|
27
|
-
contentFullHeight = false
|
|
27
|
+
contentFullHeight = false,
|
|
28
|
+
ariaRole = "group",
|
|
29
|
+
ariaAtomic = true,
|
|
30
|
+
ariaLive = "polite"
|
|
28
31
|
}) => {
|
|
29
32
|
const Icon = AlertIcons[variant];
|
|
30
33
|
let contentPadding = maxContentWidth
|
|
@@ -92,8 +95,9 @@ const Alert = ({
|
|
|
92
95
|
borderSize={noBorder ? "0px" : "1px"}
|
|
93
96
|
boxShadow={enableBoxShadow ? generateShadows()?.inset?.base : ""}
|
|
94
97
|
extraStyles={extraStyles}
|
|
95
|
-
role=
|
|
96
|
-
aria-atomic={
|
|
98
|
+
role={ariaRole}
|
|
99
|
+
aria-atomic={ariaAtomic}
|
|
100
|
+
aria-live={ariaLive}
|
|
97
101
|
>
|
|
98
102
|
{maxContentWidth ? (
|
|
99
103
|
<Center maxWidth={maxContentWidth}>{content}</Center>
|
|
@@ -221,6 +221,7 @@ const FormInput = ({
|
|
|
221
221
|
$extraStyles={extraStyles}
|
|
222
222
|
data-qa={dataQa || labelTextWhenNoError}
|
|
223
223
|
autoComplete={autocompleteValue}
|
|
224
|
+
aria-busy={true}
|
|
224
225
|
{...props}
|
|
225
226
|
/>
|
|
226
227
|
) : (
|
|
@@ -247,35 +248,36 @@ const FormInput = ({
|
|
|
247
248
|
$extraStyles={extraStyles}
|
|
248
249
|
data-qa={dataQa || labelTextWhenNoError}
|
|
249
250
|
autoComplete={autocompleteValue}
|
|
251
|
+
aria-busy={true}
|
|
250
252
|
{...props}
|
|
251
253
|
/>
|
|
252
254
|
)}
|
|
253
255
|
</Box>
|
|
254
|
-
<
|
|
255
|
-
direction="row"
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
{
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
</
|
|
256
|
+
<div role="status" aria-atomic={true}>
|
|
257
|
+
<Stack direction="row" justify="space-between">
|
|
258
|
+
{(field.hasErrors && field.dirty) ||
|
|
259
|
+
(field.hasErrors && showErrors) ? (
|
|
260
|
+
<Text
|
|
261
|
+
color={ERROR_COLOR}
|
|
262
|
+
variant="pXS"
|
|
263
|
+
weight={themeValues.fontWeight}
|
|
264
|
+
extraStyles={`word-break: break-word;
|
|
265
|
+
font-family: Public Sans;
|
|
266
|
+
&::first-letter {
|
|
267
|
+
text-transform: uppercase;
|
|
268
|
+
}`}
|
|
269
|
+
id={createIdFromString(labelTextWhenNoError, "error message")}
|
|
270
|
+
>
|
|
271
|
+
{errorMessages[field.errors[0]]}
|
|
272
|
+
</Text>
|
|
273
|
+
) : (
|
|
274
|
+
<Text extraStyles={`height: ${themeValues.lineHeight};`} />
|
|
275
|
+
)}
|
|
276
|
+
{!isMobile && decorator && (
|
|
277
|
+
<Box padding="0 0 0 auto">{decorator}</Box>
|
|
278
|
+
)}
|
|
279
|
+
</Stack>
|
|
280
|
+
</div>
|
|
279
281
|
</Stack>
|
|
280
282
|
);
|
|
281
283
|
};
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { connect } from "react-redux";
|
|
3
|
+
import { boolean } from "@storybook/addon-knobs";
|
|
4
|
+
import { createFormState, required } from "redux-freeform";
|
|
5
|
+
import PartialAmountForm from "./PartialAmountForm";
|
|
6
|
+
import page from "../../../../.storybook/page";
|
|
7
|
+
import * as PartialAmountFormState from "./PartialAmountForm.state";
|
|
8
|
+
|
|
9
|
+
const { mapStateToProps, mapDispatchToProps, reducer } = createFormState({
|
|
10
|
+
thing: {
|
|
11
|
+
validators: [required()]
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
const errorMessages = {
|
|
15
|
+
[required.error]: "thing is required"
|
|
16
|
+
};
|
|
17
|
+
const partialAmountFormFields = {
|
|
18
|
+
"3cd98097-1c95-43c6-848a-d44f95d312ec": {
|
|
19
|
+
dirty: false,
|
|
20
|
+
rawValue: "5000",
|
|
21
|
+
validators: [
|
|
22
|
+
{
|
|
23
|
+
type: "validator/REQUIRED",
|
|
24
|
+
args: [],
|
|
25
|
+
error: "error/REQUIRED"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
type: "validator/VALIDATE_SUM",
|
|
29
|
+
args: [
|
|
30
|
+
{
|
|
31
|
+
type: "validator/NUMBER_GREATER_THAN_OR_EQUAL_TO",
|
|
32
|
+
args: [1],
|
|
33
|
+
error: "error/NUMBER_GREATER_THAN_OR_EQUAL_TO"
|
|
34
|
+
},
|
|
35
|
+
[
|
|
36
|
+
"ff4b6d84-7f6a-4692-8d50-05eab56a6351",
|
|
37
|
+
"4396e95d-e0eb-44e6-8691-f94d72c2f7e7"
|
|
38
|
+
]
|
|
39
|
+
],
|
|
40
|
+
error: "error/NUMBER_GREATER_THAN_OR_EQUAL_TO"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
type: "validator/VALIDATE_SUM",
|
|
44
|
+
args: [
|
|
45
|
+
{
|
|
46
|
+
type: "validator/NUMBER_LESS_THAN_OR_EQUAL_TO",
|
|
47
|
+
args: [50000],
|
|
48
|
+
error: "error/NUMBER_LESS_THAN_OR_EQUAL_TO"
|
|
49
|
+
},
|
|
50
|
+
[
|
|
51
|
+
"ff4b6d84-7f6a-4692-8d50-05eab56a6351",
|
|
52
|
+
"4396e95d-e0eb-44e6-8691-f94d72c2f7e7"
|
|
53
|
+
]
|
|
54
|
+
],
|
|
55
|
+
error: "error/NUMBER_LESS_THAN_OR_EQUAL_TO"
|
|
56
|
+
}
|
|
57
|
+
],
|
|
58
|
+
constraints: [
|
|
59
|
+
{
|
|
60
|
+
type: "validator/ONLY_NATURALS",
|
|
61
|
+
args: [],
|
|
62
|
+
error: "error/ONLY_NATURALS"
|
|
63
|
+
}
|
|
64
|
+
],
|
|
65
|
+
errors: ["error/NUMBER_LESS_THAN_OR_EQUAL_TO"],
|
|
66
|
+
hasErrors: true,
|
|
67
|
+
id: "3cd98097-1c95-43c6-848a-d44f95d312ec"
|
|
68
|
+
},
|
|
69
|
+
"ff4b6d84-7f6a-4692-8d50-05eab56a6351": {
|
|
70
|
+
dirty: false,
|
|
71
|
+
rawValue: "25000",
|
|
72
|
+
id: "ff4b6d84-7f6a-4692-8d50-05eab56a6351",
|
|
73
|
+
validators: [
|
|
74
|
+
{
|
|
75
|
+
type: "validator/REQUIRED",
|
|
76
|
+
args: [],
|
|
77
|
+
error: "error/REQUIRED"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
type: "validator/VALIDATE_SUM",
|
|
81
|
+
args: [
|
|
82
|
+
{
|
|
83
|
+
type: "validator/NUMBER_GREATER_THAN_OR_EQUAL_TO",
|
|
84
|
+
args: [1],
|
|
85
|
+
error: "error/NUMBER_GREATER_THAN_OR_EQUAL_TO"
|
|
86
|
+
},
|
|
87
|
+
[
|
|
88
|
+
"3cd98097-1c95-43c6-848a-d44f95d312ec",
|
|
89
|
+
"4396e95d-e0eb-44e6-8691-f94d72c2f7e7"
|
|
90
|
+
]
|
|
91
|
+
],
|
|
92
|
+
error: "error/NUMBER_GREATER_THAN_OR_EQUAL_TO"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
type: "validator/VALIDATE_SUM",
|
|
96
|
+
args: [
|
|
97
|
+
{
|
|
98
|
+
type: "validator/NUMBER_LESS_THAN_OR_EQUAL_TO",
|
|
99
|
+
args: [50000],
|
|
100
|
+
error: "error/NUMBER_LESS_THAN_OR_EQUAL_TO"
|
|
101
|
+
},
|
|
102
|
+
[
|
|
103
|
+
"3cd98097-1c95-43c6-848a-d44f95d312ec",
|
|
104
|
+
"4396e95d-e0eb-44e6-8691-f94d72c2f7e7"
|
|
105
|
+
]
|
|
106
|
+
],
|
|
107
|
+
error: "error/NUMBER_LESS_THAN_OR_EQUAL_TO"
|
|
108
|
+
}
|
|
109
|
+
],
|
|
110
|
+
constraints: [
|
|
111
|
+
{
|
|
112
|
+
type: "validator/ONLY_NATURALS",
|
|
113
|
+
args: [],
|
|
114
|
+
error: "error/ONLY_NATURALS"
|
|
115
|
+
}
|
|
116
|
+
],
|
|
117
|
+
errors: ["error/NUMBER_LESS_THAN_OR_EQUAL_TO"],
|
|
118
|
+
hasErrors: true
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
const options = [
|
|
122
|
+
{ value: "", text: "choose name" },
|
|
123
|
+
{ value: "foo", text: "foo" },
|
|
124
|
+
{ value: "bar", text: "bar" },
|
|
125
|
+
{ value: "baz", text: "baz" },
|
|
126
|
+
{ value: "disabled", text: "disabled" }
|
|
127
|
+
];
|
|
128
|
+
const story = page({
|
|
129
|
+
title: "Components|Molecules/PartialAmountForm",
|
|
130
|
+
Component: PartialAmountForm,
|
|
131
|
+
reducer: PartialAmountFormState.reducer,
|
|
132
|
+
mapStateToProps: PartialAmountFormState.mapStateToProps,
|
|
133
|
+
mapDispatchToProps: PartialAmountFormState.mapDispatchToProps
|
|
134
|
+
});
|
|
135
|
+
export default story;
|
|
136
|
+
|
|
137
|
+
const ConnectedPartialAmountForm = connect(
|
|
138
|
+
PartialAmountFormState.mapStateToProps,
|
|
139
|
+
PartialAmountFormState.mapDispatchToProps
|
|
140
|
+
)(PartialAmountForm);
|
|
141
|
+
export const partialAmountForm = () => (
|
|
142
|
+
<ConnectedPartialAmountForm
|
|
143
|
+
showErrors={boolean("showErrors", false, "props")}
|
|
144
|
+
lineItems={options}
|
|
145
|
+
/>
|
|
146
|
+
);
|