orc-shared 5.8.0-dev.20 → 5.8.0-dev.22
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/MaterialUI/DataDisplay/PredefinedElements/StepperModal.js +19 -5
- package/dist/components/MaterialUI/DataDisplay/SelectionList.js +11 -19
- package/dist/components/MaterialUI/Inputs/Radio.js +2 -1
- package/package.json +1 -1
- package/src/components/MaterialUI/DataDisplay/PredefinedElements/StepperModal.js +27 -6
- package/src/components/MaterialUI/DataDisplay/PredefinedElements/StepperModal.test.js +202 -0
- package/src/components/MaterialUI/DataDisplay/SelectionList.js +6 -20
- package/src/components/MaterialUI/DataDisplay/SelectionList.test.js +0 -6
- package/src/components/MaterialUI/Inputs/Radio.js +1 -1
- package/src/components/MaterialUI/Inputs/Radio.test.js +35 -1
|
@@ -111,7 +111,7 @@ var useStyles = (0, _styles.makeStyles)(function (theme) {
|
|
|
111
111
|
};
|
|
112
112
|
});
|
|
113
113
|
var StepperModal = function StepperModal(_ref) {
|
|
114
|
-
var _steps$currentStep, _steps$currentStep$fu, _steps$currentStep2, _steps$currentStep3;
|
|
114
|
+
var _steps$currentStep, _steps$currentStep$fu, _steps$currentStep2, _steps$currentStep3, _steps$currentStep4;
|
|
115
115
|
var _ref$steps = _ref.steps,
|
|
116
116
|
steps = _ref$steps === void 0 ? [] : _ref$steps,
|
|
117
117
|
_ref$title = _ref.title,
|
|
@@ -153,8 +153,11 @@ var StepperModal = function StepperModal(_ref) {
|
|
|
153
153
|
modalProps.set(_modalProps.default.propNames.open, open);
|
|
154
154
|
modalProps.set(_modalProps.default.propNames.backdropClickCallback, backdropCallback != null ? backdropCallback : closeCallback);
|
|
155
155
|
modalProps.set(_modalProps.default.propNames.type, type);
|
|
156
|
-
var nextClick = (0, _react.useCallback)(function () {
|
|
157
|
-
|
|
156
|
+
var nextClick = (0, _react.useCallback)(function (customHandler) {
|
|
157
|
+
if (customHandler) {
|
|
158
|
+
customHandler();
|
|
159
|
+
}
|
|
160
|
+
changeCurrentStep(function (step) {
|
|
158
161
|
return step + 1;
|
|
159
162
|
});
|
|
160
163
|
}, []);
|
|
@@ -177,13 +180,24 @@ var StepperModal = function StepperModal(_ref) {
|
|
|
177
180
|
}, /*#__PURE__*/_react.default.createElement(_Button.default, {
|
|
178
181
|
variant: "outlined",
|
|
179
182
|
onClick: closeCallback
|
|
180
|
-
}, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, _sharedMessages.default.cancel)), currentStep < steps.length - 1 &&
|
|
183
|
+
}, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, _sharedMessages.default.cancel)), currentStep < steps.length - 1 && (((_steps$currentStep4 = steps[currentStep]) == null || (_steps$currentStep4 = _steps$currentStep4.actions) == null ? void 0 : _steps$currentStep4.length) > 0 ? steps[currentStep].actions.map(function (action) {
|
|
184
|
+
return /*#__PURE__*/_react.default.createElement(_Button.default, {
|
|
185
|
+
key: action.value,
|
|
186
|
+
variant: "contained",
|
|
187
|
+
color: "primary",
|
|
188
|
+
disabled: nextDisabled,
|
|
189
|
+
onClick: function onClick() {
|
|
190
|
+
return nextClick(action.handler);
|
|
191
|
+
},
|
|
192
|
+
disableElevation: true
|
|
193
|
+
}, action.label);
|
|
194
|
+
}) : /*#__PURE__*/_react.default.createElement(_Button.default, {
|
|
181
195
|
variant: "contained",
|
|
182
196
|
color: "primary",
|
|
183
197
|
disabled: nextDisabled,
|
|
184
198
|
onClick: nextClick,
|
|
185
199
|
disableElevation: true
|
|
186
|
-
}, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, _sharedMessages.default.next)), currentStep === steps.length - 1 && /*#__PURE__*/_react.default.createElement(_Button.default, {
|
|
200
|
+
}, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, _sharedMessages.default.next))), currentStep === steps.length - 1 && /*#__PURE__*/_react.default.createElement(_Button.default, {
|
|
187
201
|
variant: "contained",
|
|
188
202
|
color: "primary",
|
|
189
203
|
disabled: nextDisabled,
|
|
@@ -6,8 +6,6 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
6
6
|
var _styles = require("@material-ui/core/styles");
|
|
7
7
|
var _Grid = _interopRequireDefault(require("@material-ui/core/Grid"));
|
|
8
8
|
var _TransferList = require("./TransferList");
|
|
9
|
-
var _Divider = _interopRequireDefault(require("./Divider"));
|
|
10
|
-
var _dividerProps = _interopRequireDefault(require("./dividerProps"));
|
|
11
9
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
10
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
13
11
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -43,6 +41,12 @@ var useStyles = (0, _styles.makeStyles)(function (theme) {
|
|
|
43
41
|
return props.height && theme.spacing(props.height);
|
|
44
42
|
}
|
|
45
43
|
},
|
|
44
|
+
listHeightWithBorder: {
|
|
45
|
+
height: function height(props) {
|
|
46
|
+
return props.height && theme.spacing(props.height);
|
|
47
|
+
},
|
|
48
|
+
borderRight: "1px solid ".concat(theme.palette.grey.borders)
|
|
49
|
+
},
|
|
46
50
|
paper: {
|
|
47
51
|
flexGrow: 1,
|
|
48
52
|
height: "1px",
|
|
@@ -61,9 +65,6 @@ var useStyles = (0, _styles.makeStyles)(function (theme) {
|
|
|
61
65
|
borderRadius: theme.spacing(1.5)
|
|
62
66
|
}
|
|
63
67
|
},
|
|
64
|
-
divider: {
|
|
65
|
-
margin: "auto"
|
|
66
|
-
},
|
|
67
68
|
paperLeft: {
|
|
68
69
|
border: "1px solid ".concat(theme.palette.grey.borders)
|
|
69
70
|
},
|
|
@@ -73,7 +74,8 @@ var useStyles = (0, _styles.makeStyles)(function (theme) {
|
|
|
73
74
|
listContainer: {
|
|
74
75
|
display: "flex",
|
|
75
76
|
flexDirection: "column",
|
|
76
|
-
height: "100%"
|
|
77
|
+
height: "100%",
|
|
78
|
+
boxSizing: "border-box"
|
|
77
79
|
}
|
|
78
80
|
};
|
|
79
81
|
});
|
|
@@ -136,13 +138,8 @@ var SelectionList = function SelectionList(_ref) {
|
|
|
136
138
|
onChange && onChange(formatOnChange(listData.data, ids));
|
|
137
139
|
};
|
|
138
140
|
var showDivider = infoPanel && divider;
|
|
139
|
-
var dividerProps = new _dividerProps.default();
|
|
140
|
-
dividerProps.set(_dividerProps.default.propNames.orientation, "vertical");
|
|
141
|
-
dividerProps.set(_dividerProps.default.propNames.light, true);
|
|
142
|
-
dividerProps.setStyle(_dividerProps.default.ruleNames.vertical, classes.divider);
|
|
143
141
|
infoPanelXs = (_infoPanelXs = infoPanelXs) != null ? _infoPanelXs : defaultInfoPanelXs;
|
|
144
142
|
infoPanel = (_infoPanel = infoPanel) != null ? _infoPanel : defaultPanel;
|
|
145
|
-
var dividerDiff = showDivider ? 1 : 0;
|
|
146
143
|
var listComponent = /*#__PURE__*/_react.default.createElement("div", {
|
|
147
144
|
className: classes.listContainer
|
|
148
145
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -163,19 +160,14 @@ var SelectionList = function SelectionList(_ref) {
|
|
|
163
160
|
}), actionPanel ? /*#__PURE__*/_react.default.createElement("div", {
|
|
164
161
|
className: classes.actionPanel
|
|
165
162
|
}, actionPanel) : null);
|
|
166
|
-
var dividerComponent = showDivider && /*#__PURE__*/_react.default.createElement(_Grid.default, {
|
|
167
|
-
item: true
|
|
168
|
-
}, /*#__PURE__*/_react.default.createElement(_Divider.default, {
|
|
169
|
-
dividerProps: dividerProps
|
|
170
|
-
}));
|
|
171
163
|
return /*#__PURE__*/_react.default.createElement(_Grid.default, {
|
|
172
164
|
container: true,
|
|
173
165
|
spacing: 2
|
|
174
166
|
}, /*#__PURE__*/_react.default.createElement(_Grid.default, {
|
|
175
167
|
item: true,
|
|
176
|
-
xs: 12 - infoPanelXs
|
|
177
|
-
className: classes.listHeight
|
|
178
|
-
}, listComponent),
|
|
168
|
+
xs: 12 - infoPanelXs,
|
|
169
|
+
className: showDivider ? classes.listHeightWithBorder : classes.listHeight
|
|
170
|
+
}, listComponent), /*#__PURE__*/_react.default.createElement(_Grid.default, {
|
|
179
171
|
item: true,
|
|
180
172
|
xs: infoPanelXs
|
|
181
173
|
}, infoPanel));
|
|
@@ -154,6 +154,7 @@ var Radio = function Radio(_ref) {
|
|
|
154
154
|
value: value,
|
|
155
155
|
onChange: handleChange
|
|
156
156
|
}, radios.map(function (radio) {
|
|
157
|
+
var _radio$disabled;
|
|
157
158
|
var handleClick = radio.clickEvent ? function (event) {
|
|
158
159
|
return radio.clickEvent(event.target.value);
|
|
159
160
|
} : null;
|
|
@@ -161,7 +162,7 @@ var Radio = function Radio(_ref) {
|
|
|
161
162
|
key: "radiobutton_".concat(radio.value),
|
|
162
163
|
value: radio.value,
|
|
163
164
|
label: radio.label,
|
|
164
|
-
disabled: disabled,
|
|
165
|
+
disabled: disabled ? true : (_radio$disabled = radio.disabled) != null ? _radio$disabled : false,
|
|
165
166
|
control: /*#__PURE__*/_react.default.createElement(_Radio.default, {
|
|
166
167
|
color: "primary",
|
|
167
168
|
checkedIcon: /*#__PURE__*/_react.default.createElement("span", {
|
package/package.json
CHANGED
|
@@ -142,7 +142,12 @@ const StepperModal = ({
|
|
|
142
142
|
modalProps.set(ModalProps.propNames.backdropClickCallback, backdropCallback ?? closeCallback);
|
|
143
143
|
modalProps.set(ModalProps.propNames.type, type);
|
|
144
144
|
|
|
145
|
-
const nextClick = useCallback(
|
|
145
|
+
const nextClick = useCallback(customHandler => {
|
|
146
|
+
if (customHandler) {
|
|
147
|
+
customHandler();
|
|
148
|
+
}
|
|
149
|
+
changeCurrentStep(step => step + 1);
|
|
150
|
+
}, []);
|
|
146
151
|
const backClick = useCallback(() => changeCurrentStep(step => step - 1), []);
|
|
147
152
|
|
|
148
153
|
const actionPanel = (
|
|
@@ -159,11 +164,27 @@ const StepperModal = ({
|
|
|
159
164
|
<Button variant="outlined" onClick={closeCallback}>
|
|
160
165
|
<FormattedMessage {...sharedMessages.cancel} />
|
|
161
166
|
</Button>
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
+
|
|
168
|
+
{currentStep < steps.length - 1 &&
|
|
169
|
+
(steps[currentStep]?.actions?.length > 0 ? (
|
|
170
|
+
steps[currentStep].actions.map(action => (
|
|
171
|
+
<Button
|
|
172
|
+
key={action.value}
|
|
173
|
+
variant="contained"
|
|
174
|
+
color="primary"
|
|
175
|
+
disabled={nextDisabled}
|
|
176
|
+
onClick={() => nextClick(action.handler)}
|
|
177
|
+
disableElevation
|
|
178
|
+
>
|
|
179
|
+
{action.label}
|
|
180
|
+
</Button>
|
|
181
|
+
))
|
|
182
|
+
) : (
|
|
183
|
+
<Button variant="contained" color="primary" disabled={nextDisabled} onClick={nextClick} disableElevation>
|
|
184
|
+
<FormattedMessage {...sharedMessages.next} />
|
|
185
|
+
</Button>
|
|
186
|
+
))}
|
|
187
|
+
|
|
167
188
|
{currentStep === steps.length - 1 && (
|
|
168
189
|
<Button
|
|
169
190
|
variant="contained"
|
|
@@ -133,6 +133,208 @@ describe("StepperModal", () => {
|
|
|
133
133
|
expect(component, "when mounted", "to satisfy", expected);
|
|
134
134
|
});
|
|
135
135
|
|
|
136
|
+
it("Renders StepperModal correctly with custom actions", () => {
|
|
137
|
+
const open = true;
|
|
138
|
+
const title = "title";
|
|
139
|
+
const backdropClickCallback = jest.fn();
|
|
140
|
+
const okCallback = jest.fn();
|
|
141
|
+
const cancelCallback = jest.fn();
|
|
142
|
+
const modalProps = new ModalProps();
|
|
143
|
+
const actions = [
|
|
144
|
+
{
|
|
145
|
+
value: "first value",
|
|
146
|
+
label: "first action",
|
|
147
|
+
Handler: () => {},
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
value: "second value",
|
|
151
|
+
label: "second action",
|
|
152
|
+
Handler: () => {},
|
|
153
|
+
},
|
|
154
|
+
];
|
|
155
|
+
const steps = [{ title: "step1", content: <div>content</div>, actions }, { title: "step2" }];
|
|
156
|
+
|
|
157
|
+
const titleComponent = (
|
|
158
|
+
<div>
|
|
159
|
+
<div>{title}</div>
|
|
160
|
+
<div>step1</div>
|
|
161
|
+
<div>step2</div>
|
|
162
|
+
</div>
|
|
163
|
+
);
|
|
164
|
+
const messageComponent = <div>{steps[0].content}</div>;
|
|
165
|
+
|
|
166
|
+
modalProps.set(ModalProps.propNames.title, titleComponent);
|
|
167
|
+
modalProps.set(ModalProps.propNames.open, open);
|
|
168
|
+
modalProps.set(ModalProps.propNames.backdropClickCallback, backdropClickCallback);
|
|
169
|
+
modalProps.set(ModalProps.propNames.type, "wide");
|
|
170
|
+
|
|
171
|
+
const actionPanel = (
|
|
172
|
+
<div>
|
|
173
|
+
<div></div>
|
|
174
|
+
<div>
|
|
175
|
+
<Button variant="outlined" disabled={false} onClick={() => cancelCallback()}>
|
|
176
|
+
{sharedMessages.cancel.defaultMessage}
|
|
177
|
+
</Button>
|
|
178
|
+
<Button variant="contained" color="primary" disabled={false} onClick={() => {}} disableElevation>
|
|
179
|
+
first action
|
|
180
|
+
</Button>
|
|
181
|
+
<Button variant="contained" color="primary" disabled={false} onClick={() => {}} disableElevation>
|
|
182
|
+
second action
|
|
183
|
+
</Button>
|
|
184
|
+
</div>
|
|
185
|
+
</div>
|
|
186
|
+
);
|
|
187
|
+
|
|
188
|
+
modalProps.set(ModalProps.propNames.actionPanel, actionPanel);
|
|
189
|
+
|
|
190
|
+
const component = (
|
|
191
|
+
<IntlProvider locale="en-US" messages={messages}>
|
|
192
|
+
<StepperModal
|
|
193
|
+
steps={steps}
|
|
194
|
+
title={title}
|
|
195
|
+
open={open}
|
|
196
|
+
confirmCallback={okCallback}
|
|
197
|
+
closeCallback={cancelCallback}
|
|
198
|
+
/>
|
|
199
|
+
</IntlProvider>
|
|
200
|
+
);
|
|
201
|
+
|
|
202
|
+
const expected = (
|
|
203
|
+
<IntlProvider locale="en-US" messages={messages}>
|
|
204
|
+
<Modal message={messageComponent} modalProps={modalProps} />
|
|
205
|
+
</IntlProvider>
|
|
206
|
+
);
|
|
207
|
+
|
|
208
|
+
expect(component, "when mounted", "to satisfy", expected);
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
it("Renders StepperModal correctly with disabled custom actions", () => {
|
|
212
|
+
const open = true;
|
|
213
|
+
const title = "title";
|
|
214
|
+
const backdropClickCallback = jest.fn();
|
|
215
|
+
const okCallback = jest.fn();
|
|
216
|
+
const cancelCallback = jest.fn();
|
|
217
|
+
const modalProps = new ModalProps();
|
|
218
|
+
const actions = [
|
|
219
|
+
{
|
|
220
|
+
value: "first value",
|
|
221
|
+
label: "first action",
|
|
222
|
+
Handler: () => {},
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
value: "second value",
|
|
226
|
+
label: "second action",
|
|
227
|
+
Handler: () => {},
|
|
228
|
+
},
|
|
229
|
+
];
|
|
230
|
+
const steps = [
|
|
231
|
+
{ title: "step1", nextDisabled: () => true, content: <div>content</div>, actions },
|
|
232
|
+
{ title: "step2" },
|
|
233
|
+
];
|
|
234
|
+
|
|
235
|
+
const titleComponent = (
|
|
236
|
+
<div>
|
|
237
|
+
<div>{title}</div>
|
|
238
|
+
<div>step1</div>
|
|
239
|
+
<div>step2</div>
|
|
240
|
+
</div>
|
|
241
|
+
);
|
|
242
|
+
const messageComponent = <div>{steps[0].content}</div>;
|
|
243
|
+
|
|
244
|
+
modalProps.set(ModalProps.propNames.title, titleComponent);
|
|
245
|
+
modalProps.set(ModalProps.propNames.open, open);
|
|
246
|
+
modalProps.set(ModalProps.propNames.backdropClickCallback, backdropClickCallback);
|
|
247
|
+
modalProps.set(ModalProps.propNames.type, "wide");
|
|
248
|
+
|
|
249
|
+
const actionPanel = (
|
|
250
|
+
<div>
|
|
251
|
+
<div></div>
|
|
252
|
+
<div>
|
|
253
|
+
<Button variant="outlined" disabled={false} onClick={() => cancelCallback()}>
|
|
254
|
+
{sharedMessages.cancel.defaultMessage}
|
|
255
|
+
</Button>
|
|
256
|
+
<Button variant="contained" color="primary" disabled={true} onClick={() => {}} disableElevation>
|
|
257
|
+
first action
|
|
258
|
+
</Button>
|
|
259
|
+
<Button variant="contained" color="primary" disabled={true} onClick={() => {}} disableElevation>
|
|
260
|
+
second action
|
|
261
|
+
</Button>
|
|
262
|
+
</div>
|
|
263
|
+
</div>
|
|
264
|
+
);
|
|
265
|
+
|
|
266
|
+
modalProps.set(ModalProps.propNames.actionPanel, actionPanel);
|
|
267
|
+
|
|
268
|
+
const component = (
|
|
269
|
+
<IntlProvider locale="en-US" messages={messages}>
|
|
270
|
+
<StepperModal
|
|
271
|
+
steps={steps}
|
|
272
|
+
title={title}
|
|
273
|
+
open={open}
|
|
274
|
+
confirmCallback={okCallback}
|
|
275
|
+
closeCallback={cancelCallback}
|
|
276
|
+
/>
|
|
277
|
+
</IntlProvider>
|
|
278
|
+
);
|
|
279
|
+
|
|
280
|
+
const expected = (
|
|
281
|
+
<IntlProvider locale="en-US" messages={messages}>
|
|
282
|
+
<Modal message={messageComponent} modalProps={modalProps} />
|
|
283
|
+
</IntlProvider>
|
|
284
|
+
);
|
|
285
|
+
|
|
286
|
+
expect(component, "when mounted", "to satisfy", expected);
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
it("Renders StepperModal correctly when custom action is clicked", () => {
|
|
290
|
+
const open = true;
|
|
291
|
+
const actions = [
|
|
292
|
+
{
|
|
293
|
+
value: "first value",
|
|
294
|
+
label: "first action",
|
|
295
|
+
handler: jest.fn(),
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
value: "second value",
|
|
299
|
+
label: "second action",
|
|
300
|
+
handler: jest.fn(),
|
|
301
|
+
},
|
|
302
|
+
];
|
|
303
|
+
|
|
304
|
+
const okCallback = sinon.spy();
|
|
305
|
+
const cancelCallback = sinon.spy();
|
|
306
|
+
const steps = [
|
|
307
|
+
{ title: "step1", content: "content", actions },
|
|
308
|
+
{ title: "step2", content: "content2" },
|
|
309
|
+
];
|
|
310
|
+
|
|
311
|
+
const component = (
|
|
312
|
+
<IntlProvider locale="en-US" messages={messages}>
|
|
313
|
+
<StepperModal open={open} steps={steps} closeCallback={cancelCallback} confirmCallback={okCallback} />
|
|
314
|
+
</IntlProvider>
|
|
315
|
+
);
|
|
316
|
+
|
|
317
|
+
const mountedComponent = mount(component);
|
|
318
|
+
|
|
319
|
+
const firstAction = mountedComponent.find(Button).at(1);
|
|
320
|
+
firstAction.invoke("onClick")();
|
|
321
|
+
|
|
322
|
+
expect(mountedComponent.containsMatchingElement(steps[1].content), "to be truthy");
|
|
323
|
+
|
|
324
|
+
const back = mountedComponent.find(Button).at(0);
|
|
325
|
+
back.invoke("onClick")();
|
|
326
|
+
|
|
327
|
+
expect(mountedComponent.containsMatchingElement(steps[0].content), "to be truthy");
|
|
328
|
+
|
|
329
|
+
const secondAction = mountedComponent.find(Button).at(2);
|
|
330
|
+
secondAction.invoke("onClick")();
|
|
331
|
+
|
|
332
|
+
const okButton = mountedComponent.find(Button).at(2);
|
|
333
|
+
okButton.invoke("onClick")();
|
|
334
|
+
|
|
335
|
+
expect(okCallback, "was called");
|
|
336
|
+
});
|
|
337
|
+
|
|
136
338
|
it("Render closed modal", () => {
|
|
137
339
|
const open = false;
|
|
138
340
|
|
|
@@ -2,8 +2,6 @@ import React, { useState, useEffect } from "react";
|
|
|
2
2
|
import { makeStyles } from "@material-ui/core/styles";
|
|
3
3
|
import Grid from "@material-ui/core/Grid";
|
|
4
4
|
import { ScrollableCustomList } from "./TransferList";
|
|
5
|
-
import Divider from "./Divider";
|
|
6
|
-
import DividerProps from "./dividerProps";
|
|
7
5
|
|
|
8
6
|
const useStyles = makeStyles(theme => ({
|
|
9
7
|
title: {
|
|
@@ -14,6 +12,10 @@ const useStyles = makeStyles(theme => ({
|
|
|
14
12
|
listHeight: {
|
|
15
13
|
height: props => props.height && theme.spacing(props.height),
|
|
16
14
|
},
|
|
15
|
+
listHeightWithBorder: {
|
|
16
|
+
height: props => props.height && theme.spacing(props.height),
|
|
17
|
+
borderRight: `1px solid ${theme.palette.grey.borders}`,
|
|
18
|
+
},
|
|
17
19
|
paper: {
|
|
18
20
|
flexGrow: 1,
|
|
19
21
|
height: "1px", // forces the container to takes 100%
|
|
@@ -32,9 +34,6 @@ const useStyles = makeStyles(theme => ({
|
|
|
32
34
|
borderRadius: theme.spacing(1.5),
|
|
33
35
|
},
|
|
34
36
|
},
|
|
35
|
-
divider: {
|
|
36
|
-
margin: "auto",
|
|
37
|
-
},
|
|
38
37
|
paperLeft: {
|
|
39
38
|
border: `1px solid ${theme.palette.grey.borders}`,
|
|
40
39
|
},
|
|
@@ -45,6 +44,7 @@ const useStyles = makeStyles(theme => ({
|
|
|
45
44
|
display: "flex",
|
|
46
45
|
flexDirection: "column",
|
|
47
46
|
height: "100%",
|
|
47
|
+
boxSizing: "border-box",
|
|
48
48
|
},
|
|
49
49
|
}));
|
|
50
50
|
|
|
@@ -98,16 +98,10 @@ const SelectionList = ({
|
|
|
98
98
|
};
|
|
99
99
|
|
|
100
100
|
const showDivider = infoPanel && divider;
|
|
101
|
-
const dividerProps = new DividerProps();
|
|
102
|
-
dividerProps.set(DividerProps.propNames.orientation, "vertical");
|
|
103
|
-
dividerProps.set(DividerProps.propNames.light, true);
|
|
104
|
-
dividerProps.setStyle(DividerProps.ruleNames.vertical, classes.divider);
|
|
105
101
|
|
|
106
102
|
infoPanelXs = infoPanelXs ?? defaultInfoPanelXs;
|
|
107
103
|
infoPanel = infoPanel ?? defaultPanel;
|
|
108
104
|
|
|
109
|
-
const dividerDiff = showDivider ? 1 : 0;
|
|
110
|
-
|
|
111
105
|
const listComponent = (
|
|
112
106
|
<div className={classes.listContainer}>
|
|
113
107
|
<div className={classes.title}>{listData.title}</div>
|
|
@@ -129,23 +123,15 @@ const SelectionList = ({
|
|
|
129
123
|
</div>
|
|
130
124
|
);
|
|
131
125
|
|
|
132
|
-
const dividerComponent = showDivider && (
|
|
133
|
-
<Grid item>
|
|
134
|
-
<Divider dividerProps={dividerProps} />
|
|
135
|
-
</Grid>
|
|
136
|
-
);
|
|
137
|
-
|
|
138
126
|
return (
|
|
139
127
|
<Grid container spacing={2}>
|
|
140
|
-
<Grid item xs={12 - infoPanelXs
|
|
128
|
+
<Grid item xs={12 - infoPanelXs} className={showDivider ? classes.listHeightWithBorder : classes.listHeight}>
|
|
141
129
|
{listComponent}
|
|
142
130
|
</Grid>
|
|
143
|
-
{dividerComponent}
|
|
144
131
|
<Grid item xs={infoPanelXs}>
|
|
145
132
|
{infoPanel}
|
|
146
133
|
</Grid>
|
|
147
134
|
</Grid>
|
|
148
135
|
);
|
|
149
136
|
};
|
|
150
|
-
|
|
151
137
|
export default SelectionList;
|
|
@@ -95,9 +95,6 @@ describe("SelectionList", () => {
|
|
|
95
95
|
<ScrollableCustomList checked={[]} items={list} classes={{}} />
|
|
96
96
|
</div>
|
|
97
97
|
</Grid>
|
|
98
|
-
<Grid>
|
|
99
|
-
<hr />
|
|
100
|
-
</Grid>
|
|
101
98
|
<Grid>
|
|
102
99
|
<div>Test</div>
|
|
103
100
|
</Grid>
|
|
@@ -129,9 +126,6 @@ describe("SelectionList", () => {
|
|
|
129
126
|
<div>{actionPanel}</div>
|
|
130
127
|
</div>
|
|
131
128
|
</Grid>
|
|
132
|
-
<Grid>
|
|
133
|
-
<hr />
|
|
134
|
-
</Grid>
|
|
135
129
|
<Grid>{infoPanel}</Grid>
|
|
136
130
|
</Grid>
|
|
137
131
|
);
|
|
@@ -49,6 +49,7 @@ const ExpectComponentToBeRenderedProperly = radioProps => {
|
|
|
49
49
|
expect(radioElements.length, "to equal", radios.length);
|
|
50
50
|
|
|
51
51
|
radios.forEach(radio => {
|
|
52
|
+
const disabledOption = disabled ? true : radio.disabled ?? false;
|
|
52
53
|
let option =
|
|
53
54
|
radioElements.find(
|
|
54
55
|
x =>
|
|
@@ -57,7 +58,7 @@ const ExpectComponentToBeRenderedProperly = radioProps => {
|
|
|
57
58
|
x.props.control.type.options.name === "MuiRadio" &&
|
|
58
59
|
x.props.value === radio.value &&
|
|
59
60
|
x.props.label === radio.label &&
|
|
60
|
-
x.props.disabled ===
|
|
61
|
+
x.props.disabled === disabledOption,
|
|
61
62
|
) || null;
|
|
62
63
|
expect(option, "not to be", null);
|
|
63
64
|
});
|
|
@@ -226,4 +227,37 @@ describe("Radio Component", () => {
|
|
|
226
227
|
|
|
227
228
|
ExpectEventToBeFiredWithOptionValue(radioProps, clickEvent, "option2");
|
|
228
229
|
});
|
|
230
|
+
|
|
231
|
+
it("Renders Radio component properly with options all disbaled", () => {
|
|
232
|
+
radios.forEach(radio => {
|
|
233
|
+
radio.disabled = true;
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
radioProps.set(RadioProps.propNames.label, "aRadioLabel");
|
|
237
|
+
radioProps.set(RadioProps.propNames.defaultVal, "option1");
|
|
238
|
+
radioProps.set(RadioProps.propNames.value, "option1");
|
|
239
|
+
radioProps.set(RadioProps.propNames.radios, radios);
|
|
240
|
+
radioProps.set(RadioProps.propNames.row, true);
|
|
241
|
+
radioProps.set(RadioProps.propNames.disabled, false);
|
|
242
|
+
radioProps.set(RadioProps.propNames.error, null);
|
|
243
|
+
radioProps.set(RadioProps.propNames.allowSingleRadio, true);
|
|
244
|
+
|
|
245
|
+
ExpectComponentToBeRenderedProperly(radioProps);
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
it("Renders Radio component properly with half options disbaled", () => {
|
|
249
|
+
radios[0].disabled = true;
|
|
250
|
+
radios[1].disabled = true;
|
|
251
|
+
|
|
252
|
+
radioProps.set(RadioProps.propNames.label, "aRadioLabel");
|
|
253
|
+
radioProps.set(RadioProps.propNames.defaultVal, "option1");
|
|
254
|
+
radioProps.set(RadioProps.propNames.value, "option1");
|
|
255
|
+
radioProps.set(RadioProps.propNames.radios, radios);
|
|
256
|
+
radioProps.set(RadioProps.propNames.row, true);
|
|
257
|
+
radioProps.set(RadioProps.propNames.disabled, false);
|
|
258
|
+
radioProps.set(RadioProps.propNames.error, null);
|
|
259
|
+
radioProps.set(RadioProps.propNames.allowSingleRadio, true);
|
|
260
|
+
|
|
261
|
+
ExpectComponentToBeRenderedProperly(radioProps);
|
|
262
|
+
});
|
|
229
263
|
});
|