@axinom/mosaic-ui 0.33.0-rc.1 → 0.33.0-rc.19
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/components/Actions/Actions.models.d.ts +0 -13
- package/dist/components/Actions/Actions.models.d.ts.map +1 -1
- package/dist/components/DynamicDataList/DynamicDataList.d.ts.map +1 -1
- package/dist/components/DynamicDataList/DynamicListRow/DynamicListRow.d.ts +3 -1
- package/dist/components/DynamicDataList/DynamicListRow/DynamicListRow.d.ts.map +1 -1
- package/dist/components/FormElements/CustomTags/CustomTags.d.ts.map +1 -1
- package/dist/components/FormElements/FileUploadControl/FileUploadControl.d.ts.map +1 -1
- package/dist/components/FormElements/Radio/Radio.d.ts.map +1 -1
- package/dist/components/FormElements/Tags/Tags.d.ts.map +1 -1
- package/dist/components/FormElements/formStoryHelper.d.ts.map +1 -1
- package/dist/components/FormStation/FormStation.d.ts.map +1 -1
- package/dist/components/InfoPanel/InfoImage/InfoImage.d.ts.map +1 -1
- package/dist/components/List/List.d.ts.map +1 -1
- package/dist/components/Loaders/ImageLoader/ImageLoader.d.ts +2 -0
- package/dist/components/Loaders/ImageLoader/ImageLoader.d.ts.map +1 -1
- package/dist/components/PageHeader/PageHeaderAction/PageHeaderAction.model.d.ts +1 -11
- package/dist/components/PageHeader/PageHeaderAction/PageHeaderAction.model.d.ts.map +1 -1
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.es.js +3 -3
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/initialize.d.ts +7 -4
- package/dist/initialize.d.ts.map +1 -1
- package/dist/utils/ErrorMapper/ApolloClient/ApolloErrorMapper.d.ts +9 -0
- package/dist/utils/ErrorMapper/ApolloClient/ApolloErrorMapper.d.ts.map +1 -0
- package/dist/utils/ErrorMapper/ErrorMapper.d.ts +15 -0
- package/dist/utils/ErrorMapper/ErrorMapper.d.ts.map +1 -0
- package/dist/utils/ErrorMapper/ErrorMapper.type.d.ts +11 -0
- package/dist/utils/ErrorMapper/ErrorMapper.type.d.ts.map +1 -0
- package/dist/utils/ErrorMapper/index.d.ts +4 -0
- package/dist/utils/ErrorMapper/index.d.ts.map +1 -0
- package/dist/utils/ErrorTypeToStationError.d.ts +1 -1
- package/dist/utils/ErrorTypeToStationError.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/components/Accordion/Accordion.scss +1 -1
- package/src/components/Accordion/AccordionItem/AccordionItem.scss +1 -1
- package/src/components/Actions/Action/Action.scss +0 -2
- package/src/components/Actions/Actions.models.ts +0 -14
- package/src/components/Actions/Actions.stories.tsx +4 -1
- package/src/components/Buttons/Button/Button.scss +66 -20
- package/src/components/Buttons/CompositeButton/CompositeButton.scss +50 -18
- package/src/components/Buttons/TextButton/TextButton.scss +45 -16
- package/src/components/DateTime/DatePicker/DatePicker.scss +15 -6
- package/src/components/DateTime/DateTimePicker.scss +6 -2
- package/src/components/DynamicDataList/DynamicDataList.tsx +1 -0
- package/src/components/DynamicDataList/DynamicListDataEntry/DynamicListDataEntry.scss +15 -5
- package/src/components/DynamicDataList/DynamicListDataEntry/Renderers/createInputRenderer/createInputRenderer.tsx +1 -1
- package/src/components/DynamicDataList/DynamicListDataEntry/Renderers/createSelectRenderer/createSelectRenderer.scss +36 -12
- package/src/components/DynamicDataList/DynamicListDataEntry/Renderers/createSelectRenderer/createSelectRenderer.tsx +2 -2
- package/src/components/DynamicDataList/DynamicListRow/DynamicListRow.scss +26 -0
- package/src/components/DynamicDataList/DynamicListRow/DynamicListRow.tsx +7 -1
- package/src/components/Filters/Filter/Filter.scss +8 -2
- package/src/components/Filters/SelectionTypes/DateTimeFilter/DateTimeFilter.scss +4 -1
- package/src/components/FormElements/Checkbox/Checkbox.scss +20 -0
- package/src/components/FormElements/CustomTags/CustomTags.scss +24 -0
- package/src/components/FormElements/CustomTags/CustomTags.tsx +8 -2
- package/src/components/FormElements/DateTimeField/DateTimeText.spec.tsx +1 -1
- package/src/components/FormElements/DateTimeField/DateTimeText.tsx +1 -1
- package/src/components/FormElements/FileUploadControl/FileUploadControl.scss +4 -2
- package/src/components/FormElements/FileUploadControl/FileUploadControl.tsx +12 -3
- package/src/components/FormElements/Radio/Radio.scss +18 -3
- package/src/components/FormElements/Radio/Radio.tsx +2 -2
- package/src/components/FormElements/Select/Select.scss +10 -0
- package/src/components/FormElements/SingleLineText/SingleLineText.spec.tsx +2 -2
- package/src/components/FormElements/SingleLineText/SingleLineText.tsx +1 -1
- package/src/components/FormElements/Tags/Tags.scss +14 -0
- package/src/components/FormElements/Tags/Tags.tsx +5 -1
- package/src/components/FormElements/TextArea/TextArea.spec.tsx +2 -2
- package/src/components/FormElements/TextArea/TextArea.tsx +1 -1
- package/src/components/FormElements/formStoryHelper.tsx +163 -97
- package/src/components/FormStation/FormStation.spec.tsx +13 -3
- package/src/components/FormStation/FormStation.tsx +13 -3
- package/src/components/InfoPanel/InfoImage/InfoImage.scss +8 -3
- package/src/components/InfoPanel/InfoImage/InfoImage.tsx +1 -0
- package/src/components/List/List.tsx +3 -1
- package/src/components/List/ListCheckBox/ListCheckBox.scss +8 -3
- package/src/components/List/ListRow/ListRow.scss +0 -4
- package/src/components/Loaders/ImageLoader/ImageLoader.scss +27 -21
- package/src/components/Loaders/ImageLoader/ImageLoader.spec.tsx +8 -12
- package/src/components/Loaders/ImageLoader/ImageLoader.tsx +8 -3
- package/src/components/PageHeader/PageHeaderAction/PageHeaderAction.model.ts +0 -10
- package/src/components/PageHeader/PageHeaderAction/PageHeaderAction.scss +0 -1
- package/src/components/PageHeader/PageHeaderAction/PageHeaderAction.stories.tsx +5 -0
- package/src/components/index.ts +1 -1
- package/src/index.ts +1 -0
- package/src/initialize.ts +15 -12
- package/src/styles/variables.scss +32 -2
- package/src/utils/ErrorMapper/ApolloClient/ApolloErrorMapper.spec.ts +32 -0
- package/src/utils/ErrorMapper/ApolloClient/ApolloErrorMapper.tsx +33 -0
- package/src/utils/ErrorMapper/ErrorMapper.spec.ts +67 -0
- package/src/utils/ErrorMapper/ErrorMapper.ts +31 -0
- package/src/utils/ErrorMapper/ErrorMapper.type.ts +11 -0
- package/src/utils/ErrorMapper/index.ts +3 -0
- package/src/utils/ErrorTypeToStationError.spec.tsx +12 -0
- package/src/utils/ErrorTypeToStationError.tsx +5 -1
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
import { faker } from '@faker-js/faker';
|
|
2
2
|
import React, { useState } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
Checkbox,
|
|
5
|
+
CustomTags,
|
|
6
|
+
Divider,
|
|
7
|
+
FileUploadControl,
|
|
8
|
+
Radio,
|
|
9
|
+
ReadOnlyField,
|
|
10
|
+
Select,
|
|
11
|
+
SingleLineText,
|
|
12
|
+
Tags,
|
|
13
|
+
} from '.';
|
|
4
14
|
import { generateItemArray } from '../../helpers/storybook';
|
|
15
|
+
import { TextButton } from '../Buttons';
|
|
5
16
|
import { DynamicListColumn } from '../DynamicDataList/DynamicDataList.model';
|
|
6
17
|
import {
|
|
7
18
|
createInputRenderer,
|
|
@@ -10,6 +21,8 @@ import {
|
|
|
10
21
|
import { formatDateTime } from '../Utils';
|
|
11
22
|
import { BooleanViewField } from './BooleanView/BooleanViewField';
|
|
12
23
|
import { DynamicDataListControl } from './DynamicDataListControl/DynamicDataListControl';
|
|
24
|
+
import { FileUpload } from './FileUploadControl/FileUploadControl';
|
|
25
|
+
import { TextArea } from './TextArea/TextArea';
|
|
13
26
|
|
|
14
27
|
interface DynamicListStoryData {
|
|
15
28
|
position: number;
|
|
@@ -67,13 +80,13 @@ const dataListColumns: DynamicListColumn<DynamicListStoryData>[] = [
|
|
|
67
80
|
];
|
|
68
81
|
|
|
69
82
|
export const SampleForm: React.FC = () => useCreateForm().form;
|
|
70
|
-
|
|
71
83
|
export const useCreateForm = (): {
|
|
72
84
|
form: JSX.Element;
|
|
73
85
|
title: string;
|
|
74
86
|
} => {
|
|
75
87
|
const [id] = useState(faker.datatype.uuid());
|
|
76
88
|
const [title, setTitle] = useState(`The ${generateTitle()}`);
|
|
89
|
+
const [title2, setTitle2] = useState(`The ${generateTitle()}`);
|
|
77
90
|
const [genres, setGenres] = useState<string[]>(['Crime', 'Drama']);
|
|
78
91
|
const [ratings, setRatings] = useState<
|
|
79
92
|
string | number | string[] | undefined
|
|
@@ -94,104 +107,157 @@ export const useCreateForm = (): {
|
|
|
94
107
|
country: faker.address.country(),
|
|
95
108
|
})),
|
|
96
109
|
);
|
|
110
|
+
const [radio, setRadio] = useState(1);
|
|
111
|
+
const [check, setCheck] = useState<boolean>();
|
|
112
|
+
const [file, setFile] = useState<FileUpload>();
|
|
113
|
+
|
|
114
|
+
const [disabled, setDisabled] = useState<boolean>(false);
|
|
97
115
|
|
|
98
116
|
return {
|
|
99
117
|
form: (
|
|
100
|
-
|
|
101
|
-
style={{
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
<
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
label="
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
118
|
+
<>
|
|
119
|
+
<div style={{ marginBottom: 10 }}>
|
|
120
|
+
<TextButton
|
|
121
|
+
onButtonClicked={() => setDisabled(!disabled)}
|
|
122
|
+
text="Toggle Disabled"
|
|
123
|
+
/>
|
|
124
|
+
</div>
|
|
125
|
+
<Divider />
|
|
126
|
+
<form
|
|
127
|
+
style={{
|
|
128
|
+
display: 'grid',
|
|
129
|
+
gridAutoRows: 'max-content',
|
|
130
|
+
gridTemplateColumns: '1fr',
|
|
131
|
+
rowGap: '20px',
|
|
132
|
+
}}
|
|
133
|
+
>
|
|
134
|
+
<ReadOnlyField label="Id" value={id} />
|
|
135
|
+
<SingleLineText
|
|
136
|
+
name="title"
|
|
137
|
+
label="Title"
|
|
138
|
+
value={title}
|
|
139
|
+
disabled={disabled}
|
|
140
|
+
onChange={(e) => setTitle(e.currentTarget.value)}
|
|
141
|
+
/>
|
|
142
|
+
<ReadOnlyField label="Publish State" value="PUBLISHED" />
|
|
143
|
+
<BooleanViewField
|
|
144
|
+
label="Status"
|
|
145
|
+
value={status}
|
|
146
|
+
trueLabel="Enabled"
|
|
147
|
+
falseLabel="Disabled"
|
|
148
|
+
/>
|
|
149
|
+
<Tags
|
|
150
|
+
name="genres"
|
|
151
|
+
label="Genre(s)"
|
|
152
|
+
value={genres}
|
|
153
|
+
tagsOptions={genresOptions}
|
|
154
|
+
onChange={(e) =>
|
|
155
|
+
setGenres(e.currentTarget.value as unknown as string[])
|
|
156
|
+
}
|
|
157
|
+
disabled={disabled}
|
|
158
|
+
/>
|
|
159
|
+
<Select
|
|
160
|
+
name="ratings"
|
|
161
|
+
label="Rating"
|
|
162
|
+
value={ratings}
|
|
163
|
+
options={selectOptions}
|
|
164
|
+
onChange={(e) => setRatings(e.currentTarget.value)}
|
|
165
|
+
disabled={disabled}
|
|
166
|
+
/>
|
|
167
|
+
<SingleLineText
|
|
168
|
+
name="shortDescription"
|
|
169
|
+
label="Short Description"
|
|
170
|
+
value={shortDescription}
|
|
171
|
+
placeholder="Enter a short description..."
|
|
172
|
+
onChange={(e) => setShortDescription(e.currentTarget.value)}
|
|
173
|
+
disabled={disabled}
|
|
174
|
+
/>
|
|
175
|
+
<TextArea
|
|
176
|
+
name="longDescription"
|
|
177
|
+
label="Long Description"
|
|
178
|
+
value={longDescription}
|
|
179
|
+
placeholder="Enter a description..."
|
|
180
|
+
onChange={(e) => setLongDescription(e.currentTarget.value)}
|
|
181
|
+
disabled={disabled}
|
|
182
|
+
/>
|
|
183
|
+
<CustomTags
|
|
184
|
+
name="cast"
|
|
185
|
+
value={cast}
|
|
186
|
+
label="Cast"
|
|
187
|
+
onChange={(e) =>
|
|
188
|
+
setCast(e.currentTarget.value as unknown as string[])
|
|
189
|
+
}
|
|
190
|
+
disabled={disabled}
|
|
191
|
+
/>
|
|
192
|
+
<CustomTags
|
|
193
|
+
name="directors"
|
|
194
|
+
value={directors}
|
|
195
|
+
label="Director(s)"
|
|
196
|
+
onChange={(e) =>
|
|
197
|
+
setDirectors(e.currentTarget.value as unknown as string[])
|
|
198
|
+
}
|
|
199
|
+
disabled={disabled}
|
|
200
|
+
/>
|
|
201
|
+
<Tags
|
|
202
|
+
name="locales"
|
|
203
|
+
value={locales}
|
|
204
|
+
label="Locale(s)"
|
|
205
|
+
tagsOptions={['en_US', 'pt_PT', 'zh_CN']}
|
|
206
|
+
onChange={(e) =>
|
|
207
|
+
setLocales(e.currentTarget.value as unknown as string[])
|
|
208
|
+
}
|
|
209
|
+
disabled={disabled}
|
|
210
|
+
/>
|
|
211
|
+
<DynamicDataListControl
|
|
212
|
+
name={'dataList'}
|
|
213
|
+
label={'Subtitles'}
|
|
214
|
+
columns={dataListColumns}
|
|
215
|
+
value={dataList}
|
|
216
|
+
positionPropertyName={'position'}
|
|
217
|
+
allowReordering={true}
|
|
218
|
+
allowRowDragging={true}
|
|
219
|
+
allowNewData={true}
|
|
220
|
+
onChange={(e) => setDataList(e as DynamicListStoryData[])}
|
|
221
|
+
disabled={disabled}
|
|
222
|
+
/>
|
|
223
|
+
|
|
224
|
+
<Radio
|
|
225
|
+
value={radio}
|
|
226
|
+
onChange={(e) => setRadio(Number(e.currentTarget.value))}
|
|
227
|
+
options={[
|
|
228
|
+
{ value: 1, label: 'A' },
|
|
229
|
+
{ value: 2, label: 'B' },
|
|
230
|
+
{ value: 3, label: 'C' },
|
|
231
|
+
]}
|
|
232
|
+
name={'radio'}
|
|
233
|
+
label={'Category'}
|
|
234
|
+
disabled={disabled}
|
|
235
|
+
/>
|
|
236
|
+
|
|
237
|
+
<Checkbox
|
|
238
|
+
value={check}
|
|
239
|
+
onChange={setCheck}
|
|
240
|
+
name={'check'}
|
|
241
|
+
label={'Is Premium?'}
|
|
242
|
+
disabled={disabled}
|
|
243
|
+
/>
|
|
244
|
+
|
|
245
|
+
<FileUploadControl
|
|
246
|
+
name={'file'}
|
|
247
|
+
value={file}
|
|
248
|
+
onFileSelected={(file) => setFile(file)}
|
|
249
|
+
placeholder={'Select a file'}
|
|
250
|
+
label={'File'}
|
|
251
|
+
disabled={disabled}
|
|
252
|
+
/>
|
|
253
|
+
<ReadOnlyField
|
|
254
|
+
label="Created At"
|
|
255
|
+
value={createdTime.toISOString()}
|
|
256
|
+
transform={formatDateTime}
|
|
257
|
+
/>
|
|
258
|
+
<ReadOnlyField label="Writer(s)" value={writers} />
|
|
259
|
+
</form>
|
|
260
|
+
</>
|
|
195
261
|
),
|
|
196
262
|
title,
|
|
197
263
|
};
|
|
@@ -5,7 +5,7 @@ import { act } from 'react-dom/test-utils';
|
|
|
5
5
|
import { MemoryRouter, Route } from 'react-router-dom';
|
|
6
6
|
import * as Yup from 'yup';
|
|
7
7
|
import { noop } from '../../helpers/utils';
|
|
8
|
-
import {
|
|
8
|
+
import { IndicatorType, setSaveIndicator } from '../../initialize';
|
|
9
9
|
import { ActionData, Actions } from '../Actions';
|
|
10
10
|
import { Action } from '../Actions/Action';
|
|
11
11
|
import { MessageBar } from '../MessageBar/MessageBar';
|
|
@@ -675,6 +675,11 @@ describe('Details', () => {
|
|
|
675
675
|
</FormStation>
|
|
676
676
|
</MemoryRouter>,
|
|
677
677
|
);
|
|
678
|
+
expect(setSaveIndicator).toHaveBeenNthCalledWith(
|
|
679
|
+
1,
|
|
680
|
+
IndicatorType.Inactive,
|
|
681
|
+
); // 1. inactive 2. dirty
|
|
682
|
+
expect(setSaveIndicator).toHaveBeenNthCalledWith(2, IndicatorType.Dirty); // 1. inactive 2. dirty
|
|
678
683
|
|
|
679
684
|
// submit form
|
|
680
685
|
const actionSelected = wrapper
|
|
@@ -692,7 +697,7 @@ describe('Details', () => {
|
|
|
692
697
|
|
|
693
698
|
wrapper.update();
|
|
694
699
|
|
|
695
|
-
expect(
|
|
700
|
+
expect(setSaveIndicator).toHaveBeenNthCalledWith(3, IndicatorType.Saving);
|
|
696
701
|
|
|
697
702
|
// complete form submission
|
|
698
703
|
await act(async () => {
|
|
@@ -700,7 +705,12 @@ describe('Details', () => {
|
|
|
700
705
|
});
|
|
701
706
|
wrapper.update();
|
|
702
707
|
|
|
703
|
-
expect(
|
|
708
|
+
expect(setSaveIndicator).toHaveBeenNthCalledWith(
|
|
709
|
+
4,
|
|
710
|
+
IndicatorType.Inactive,
|
|
711
|
+
);
|
|
712
|
+
|
|
713
|
+
console.warn((setSaveIndicator as jest.Mock).mock.calls);
|
|
704
714
|
});
|
|
705
715
|
});
|
|
706
716
|
});
|
|
@@ -16,7 +16,7 @@ import React, {
|
|
|
16
16
|
} from 'react';
|
|
17
17
|
import { useHistory } from 'react-router-dom';
|
|
18
18
|
import { OptionalObjectSchema } from 'yup/lib/object';
|
|
19
|
-
import {
|
|
19
|
+
import { IndicatorType, setSaveIndicator } from '../../initialize';
|
|
20
20
|
import { Data } from '../../types/data';
|
|
21
21
|
import { ErrorTypeToStationError } from '../../utils/ErrorTypeToStationError';
|
|
22
22
|
import { Actions, ActionsProps } from '../Actions';
|
|
@@ -155,7 +155,7 @@ export const FormStation = <TValues extends Data, TSubmitResponse = unknown>({
|
|
|
155
155
|
|
|
156
156
|
try {
|
|
157
157
|
setIsFormSubmitting(true);
|
|
158
|
-
|
|
158
|
+
setSaveIndicator(IndicatorType.Saving);
|
|
159
159
|
setStationError(undefined);
|
|
160
160
|
if (!initialData.loading && saveData) {
|
|
161
161
|
const response = await saveData(values, initialData, formikHelpers);
|
|
@@ -171,13 +171,14 @@ export const FormStation = <TValues extends Data, TSubmitResponse = unknown>({
|
|
|
171
171
|
),
|
|
172
172
|
);
|
|
173
173
|
|
|
174
|
+
setSaveIndicator(IndicatorType.Dirty);
|
|
175
|
+
|
|
174
176
|
// We still throw the error, to make sure that navigation or action execution
|
|
175
177
|
// will not continue after a failed save.
|
|
176
178
|
throw error;
|
|
177
179
|
} finally {
|
|
178
180
|
formikHelpers.setSubmitting(false);
|
|
179
181
|
setIsFormSubmitting(false);
|
|
180
|
-
hideSaveIndicator();
|
|
181
182
|
}
|
|
182
183
|
},
|
|
183
184
|
[isFormSubmitting, initialData, saveData, setStationError],
|
|
@@ -445,6 +446,15 @@ const FormStationHeader: React.FC<
|
|
|
445
446
|
> = ({ titleProperty, defaultTitle, subtitle, cancelNavigationUrl }) => {
|
|
446
447
|
const { dirty, resetForm, values } = useFormikContext<FormikValues>();
|
|
447
448
|
|
|
449
|
+
useEffect(() => {
|
|
450
|
+
// Set the save indicator to dirty depending on the form state
|
|
451
|
+
if (dirty) {
|
|
452
|
+
setSaveIndicator(IndicatorType.Dirty);
|
|
453
|
+
} else {
|
|
454
|
+
setSaveIndicator(IndicatorType.Inactive);
|
|
455
|
+
}
|
|
456
|
+
}, [dirty]);
|
|
457
|
+
|
|
448
458
|
const history = useHistory();
|
|
449
459
|
|
|
450
460
|
const title =
|
|
@@ -320,7 +320,9 @@ export const List = <T extends Data>({
|
|
|
320
320
|
horizontalTextAlign={horizontalTextAlign}
|
|
321
321
|
verticalTextAlign={verticalTextAlign}
|
|
322
322
|
showItemCheckbox={
|
|
323
|
-
enableSelectAll &&
|
|
323
|
+
enableSelectAll &&
|
|
324
|
+
selectionMode === ListSelectMode.Multi &&
|
|
325
|
+
listItems.length > 0
|
|
324
326
|
}
|
|
325
327
|
isCheckboxDisabled={listItems.length === 0}
|
|
326
328
|
onCheckboxToggled={headerCheckboxHandler}
|
|
@@ -9,8 +9,13 @@
|
|
|
9
9
|
|
|
10
10
|
.disabled {
|
|
11
11
|
background-color: var(
|
|
12
|
-
--
|
|
13
|
-
$
|
|
14
|
-
)
|
|
12
|
+
--actions-disabled-bg-color,
|
|
13
|
+
$actions-disabled-bg-color
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
// background-color: var(
|
|
17
|
+
// --page-header-action-context-background-color,
|
|
18
|
+
// $page-header-action-context-background-color
|
|
19
|
+
// ) !important;
|
|
15
20
|
}
|
|
16
21
|
}
|
|
@@ -1,29 +1,35 @@
|
|
|
1
1
|
@import '../../../styles/common.scss';
|
|
2
2
|
|
|
3
3
|
.container {
|
|
4
|
-
@include boxSizing;
|
|
5
|
-
|
|
6
|
-
width: 50px;
|
|
7
|
-
height: 50px;
|
|
8
4
|
display: grid;
|
|
9
|
-
grid
|
|
10
|
-
grid-template-rows: 1fr;
|
|
11
|
-
place-items: center;
|
|
12
|
-
}
|
|
5
|
+
grid: 1fr / 1fr;
|
|
13
6
|
|
|
14
|
-
.
|
|
15
|
-
|
|
16
|
-
}
|
|
7
|
+
.loader {
|
|
8
|
+
@include boxSizing;
|
|
17
9
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
10
|
+
width: 50px;
|
|
11
|
+
height: 50px;
|
|
12
|
+
display: grid;
|
|
13
|
+
grid: 1fr / 1fr;
|
|
14
|
+
place-items: center;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.imageContainer {
|
|
18
|
+
display: grid;
|
|
19
|
+
grid: 1fr / 1fr;
|
|
20
|
+
place-items: center;
|
|
21
|
+
|
|
22
|
+
.fallback {
|
|
23
|
+
background-color: var(
|
|
24
|
+
--fallback-image-bg-color,
|
|
25
|
+
$fallback-image-bg-color
|
|
26
|
+
);
|
|
27
|
+
}
|
|
23
28
|
|
|
24
|
-
.
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
+
.fallBackImage {
|
|
30
|
+
height: 50px;
|
|
31
|
+
width: 50px;
|
|
32
|
+
align-self: center;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
29
35
|
}
|
|
@@ -99,7 +99,7 @@ describe('ImageLoader', () => {
|
|
|
99
99
|
|
|
100
100
|
const loader = wrapper.find(ContentLoader);
|
|
101
101
|
const imgDisplay = wrapper.find('img').prop('style')?.display;
|
|
102
|
-
const fallbackContainer = wrapper.find('.container');
|
|
102
|
+
const fallbackContainer = wrapper.find('.container').at(1);
|
|
103
103
|
|
|
104
104
|
expect(loader.exists()).toBe(false);
|
|
105
105
|
expect(imgDisplay).toBe('none');
|
|
@@ -116,7 +116,7 @@ describe('ImageLoader', () => {
|
|
|
116
116
|
|
|
117
117
|
const loader = wrapper.find(ContentLoader);
|
|
118
118
|
const images = wrapper.find('img');
|
|
119
|
-
const fallbackContainer = wrapper.find('.container');
|
|
119
|
+
const fallbackContainer = wrapper.find('.container').at(1);
|
|
120
120
|
|
|
121
121
|
expect(loader.exists()).toBe(false);
|
|
122
122
|
expect(images.at(0).prop('style')?.display).toBe('none'); // hidden failed image
|
|
@@ -198,12 +198,10 @@ describe('ImageLoader', () => {
|
|
|
198
198
|
it(`loader dimensions defaults to '50px' by '50px'`, () => {
|
|
199
199
|
const wrapper = shallow(<ImageLoader imgSrc="" />);
|
|
200
200
|
|
|
201
|
-
const
|
|
202
|
-
.find('.container')
|
|
203
|
-
.prop('style') as React.CSSProperties;
|
|
201
|
+
const loader = wrapper.find('.loader').prop('style') as React.CSSProperties;
|
|
204
202
|
|
|
205
|
-
expect(
|
|
206
|
-
expect(
|
|
203
|
+
expect(loader.height).toBe('50px');
|
|
204
|
+
expect(loader.width).toBe('50px');
|
|
207
205
|
});
|
|
208
206
|
|
|
209
207
|
it('sets the height and width of the loader', () => {
|
|
@@ -213,11 +211,9 @@ describe('ImageLoader', () => {
|
|
|
213
211
|
<ImageLoader imgSrc="" height={mockHeight} width={mockWidth} />,
|
|
214
212
|
);
|
|
215
213
|
|
|
216
|
-
const
|
|
217
|
-
.find('.container')
|
|
218
|
-
.prop('style') as React.CSSProperties;
|
|
214
|
+
const loader = wrapper.find('.loader').prop('style') as React.CSSProperties;
|
|
219
215
|
|
|
220
|
-
expect(
|
|
221
|
-
expect(
|
|
216
|
+
expect(loader.height).toBe(`${mockHeight}px`);
|
|
217
|
+
expect(loader.width).toBe(`${mockWidth}px`);
|
|
222
218
|
});
|
|
223
219
|
});
|
|
@@ -40,6 +40,9 @@ export interface ImageLoaderProps {
|
|
|
40
40
|
onImageClick?: (
|
|
41
41
|
event: React.MouseEvent<HTMLImageElement, MouseEvent>,
|
|
42
42
|
) => void;
|
|
43
|
+
|
|
44
|
+
/** CSS Class name for additional img element styles */
|
|
45
|
+
imageClassName?: string;
|
|
43
46
|
}
|
|
44
47
|
|
|
45
48
|
/**
|
|
@@ -65,6 +68,7 @@ export const ImageLoader: React.FC<ImageLoaderProps> = ({
|
|
|
65
68
|
onError = noop,
|
|
66
69
|
onImageClick = noop,
|
|
67
70
|
children,
|
|
71
|
+
imageClassName = '',
|
|
68
72
|
}) => {
|
|
69
73
|
const actualViewBox = viewBox || `0 0 ${width} ${height}`;
|
|
70
74
|
|
|
@@ -106,9 +110,9 @@ export const ImageLoader: React.FC<ImageLoaderProps> = ({
|
|
|
106
110
|
}, [imgSrc, onError]);
|
|
107
111
|
|
|
108
112
|
return (
|
|
109
|
-
|
|
113
|
+
<div className={classes.container}>
|
|
110
114
|
{isLoading && (
|
|
111
|
-
<div className={classes.
|
|
115
|
+
<div className={classes.loader} style={customStyles}>
|
|
112
116
|
<ContentLoader
|
|
113
117
|
speed={speed}
|
|
114
118
|
backgroundColor={backgroundColor}
|
|
@@ -135,6 +139,7 @@ export const ImageLoader: React.FC<ImageLoaderProps> = ({
|
|
|
135
139
|
onError={onErrorHandler}
|
|
136
140
|
onClick={onImageClick}
|
|
137
141
|
data-test-id="image-loader-img"
|
|
142
|
+
className={imageClassName}
|
|
138
143
|
/>
|
|
139
144
|
{fallBack &&
|
|
140
145
|
(!fallbackSrc ? (
|
|
@@ -153,6 +158,6 @@ export const ImageLoader: React.FC<ImageLoaderProps> = ({
|
|
|
153
158
|
{!isLoading && !fallBack && children}
|
|
154
159
|
</div>
|
|
155
160
|
)}
|
|
156
|
-
|
|
161
|
+
</div>
|
|
157
162
|
);
|
|
158
163
|
};
|
|
@@ -5,14 +5,6 @@ import { ConfirmAction, DefaultHandler, LinkAction } from '../../models';
|
|
|
5
5
|
export enum PageHeaderActionType {
|
|
6
6
|
Active,
|
|
7
7
|
Context,
|
|
8
|
-
/**
|
|
9
|
-
* @deprecated This value is no longer necessary for navigation type actions in the
|
|
10
|
-
* `PageHeaderAction` component, and will be removed in the future.
|
|
11
|
-
* To create a navigation link, use the `path` property instead of the `onClick` handler,
|
|
12
|
-
* which will automatically generate an anchor element.
|
|
13
|
-
* @note This deprecation only affects the `Navigation` enum value in the PageHeaderActionType
|
|
14
|
-
*/
|
|
15
|
-
Navigation,
|
|
16
8
|
}
|
|
17
9
|
|
|
18
10
|
export type PageHeaderActionProps =
|
|
@@ -27,8 +19,6 @@ export interface PageHeaderJsActionProps
|
|
|
27
19
|
/**
|
|
28
20
|
* Whether the action is an 'Active' or 'Context' type.
|
|
29
21
|
* Changes the background color to the corresponding action type. (default: 'Context')
|
|
30
|
-
* Type `Navigation` is deprecated and will be removed in the future
|
|
31
|
-
* define instead of `onClick` handler `path` property to render element with anchor tag
|
|
32
22
|
*/
|
|
33
23
|
actionType?: PageHeaderActionType;
|
|
34
24
|
}
|
package/src/components/index.ts
CHANGED
|
@@ -19,8 +19,8 @@ export * from './List';
|
|
|
19
19
|
export * from './Loaders';
|
|
20
20
|
export * from './MessageBar';
|
|
21
21
|
export * from './Modal';
|
|
22
|
-
export * from './models';
|
|
23
22
|
export * from './NavigationAwareStation';
|
|
24
23
|
export * from './PageHeader';
|
|
25
24
|
export * from './ProgressBar';
|
|
26
25
|
export * from './Utils';
|
|
26
|
+
export * from './models';
|