orc-shared 5.8.0-dev.8 → 5.9.0-dev.1
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/actions/applications.js +5 -5
- package/dist/actions/authentication.js +5 -5
- package/dist/actions/countries.js +5 -5
- package/dist/actions/locale.js +5 -5
- package/dist/actions/makeApiAction.js +7 -7
- package/dist/actions/makeOrcApiAction.js +2 -2
- package/dist/actions/metadata.js +7 -7
- package/dist/actions/navigation.js +2 -2
- package/dist/actions/scopes.js +5 -5
- package/dist/actions/tasks.js +5 -5
- package/dist/actions/timezones.js +5 -5
- package/dist/actions/versionInfo.js +5 -5
- package/dist/buildStore.js +4 -4
- package/dist/components/AppFrame/About.js +9 -9
- package/dist/components/AppFrame/Anchor.js +1 -1
- package/dist/components/AppFrame/AppFrame.js +6 -6
- package/dist/components/AppFrame/ApplicationSelector/ApplicationDialog.js +1 -1
- package/dist/components/AppFrame/ApplicationSelector/Header.js +4 -4
- package/dist/components/AppFrame/ApplicationSelector/index.js +3 -3
- package/dist/components/AppFrame/ConnectedToastList.js +2 -2
- package/dist/components/AppFrame/Help.js +1 -1
- package/dist/components/AppFrame/MenuItem.js +6 -6
- package/dist/components/AppFrame/Preferences.js +7 -7
- package/dist/components/AppFrame/Sidebar.js +5 -5
- package/dist/components/AppFrame/Topbar.js +3 -3
- package/dist/components/AppFrame/index.js +2 -2
- package/dist/components/ApplicationModuleLoader.js +5 -5
- package/dist/components/Authenticate.js +2 -2
- package/dist/components/Button.js +1 -1
- package/dist/components/CategoryList.js +6 -6
- package/dist/components/Checkbox.js +5 -5
- package/dist/components/ColumnWrapper.js +1 -1
- package/dist/components/Culture.js +1 -1
- package/dist/components/DevPages.js +1 -1
- package/dist/components/DropMenu/Menu.js +2 -2
- package/dist/components/DropMenu/index.js +5 -5
- package/dist/components/ErrorPlaceholder.js +4 -4
- package/dist/components/Form/Combination.js +2 -2
- package/dist/components/Form/Field.js +3 -3
- package/dist/components/Form/FieldElements.js +4 -4
- package/dist/components/Form/FieldList.js +6 -6
- package/dist/components/Form/Fieldset.js +1 -1
- package/dist/components/Form/Form.js +2 -2
- package/dist/components/Form/FormElement.js +1 -1
- package/dist/components/Form/InputField.js +10 -10
- package/dist/components/Form/Inputs/Button.js +4 -4
- package/dist/components/Form/Inputs/Date.js +4 -4
- package/dist/components/Form/Inputs/FieldButtons.js +2 -2
- package/dist/components/Form/Inputs/Number.js +4 -4
- package/dist/components/Form/Inputs/ReadOnly.js +1 -1
- package/dist/components/Form/Inputs/SmallButton.js +4 -4
- package/dist/components/Form/Inputs/Text.js +4 -4
- package/dist/components/Form/Inputs/Time.js +4 -4
- package/dist/components/Form/Inputs/Toggles.js +4 -4
- package/dist/components/Form/Inputs/Translation.js +11 -11
- package/dist/components/Form/Inputs/index.js +1 -1
- package/dist/components/Form/index.js +2 -2
- package/dist/components/I18n.js +2 -2
- package/dist/components/Icon.js +3 -3
- package/dist/components/IconButton.js +3 -3
- package/dist/components/Input.js +5 -5
- package/dist/components/InternetExplorerWarningMessage.js +1 -1
- package/dist/components/List/DataCell.js +2 -2
- package/dist/components/List/HeadCell.js +2 -2
- package/dist/components/List/HeadRow.js +1 -1
- package/dist/components/List/List.js +5 -5
- package/dist/components/List/Row.js +2 -2
- package/dist/components/List/enhanceColumnDefs.js +2 -2
- package/dist/components/List/index.js +2 -2
- package/dist/components/Loader.js +6 -6
- package/dist/components/LoadingIcon.js +2 -2
- package/dist/components/MaterialUI/DataDisplay/Badge.js +4 -4
- package/dist/components/MaterialUI/DataDisplay/Chip.js +2 -2
- package/dist/components/MaterialUI/DataDisplay/CollapsableList.js +6 -6
- package/dist/components/MaterialUI/DataDisplay/Divider.js +2 -2
- package/dist/components/MaterialUI/DataDisplay/Icon.js +4 -4
- package/dist/components/MaterialUI/DataDisplay/List.js +1 -1
- package/dist/components/MaterialUI/DataDisplay/Modal.js +4 -4
- package/dist/components/MaterialUI/DataDisplay/Notification.js +8 -8
- package/dist/components/MaterialUI/DataDisplay/NotificationProps.js +6 -6
- package/dist/components/MaterialUI/DataDisplay/PopperedElements/PopperedIcon.js +2 -2
- package/dist/components/MaterialUI/DataDisplay/PredefinedElements/ActionModal.js +1 -1
- package/dist/components/MaterialUI/DataDisplay/PredefinedElements/Address.js +2 -2
- package/dist/components/MaterialUI/DataDisplay/PredefinedElements/ConfirmationModal.js +1 -1
- package/dist/components/MaterialUI/DataDisplay/PredefinedElements/DiscountedPrice.js +1 -1
- package/dist/components/MaterialUI/DataDisplay/PredefinedElements/GlobalErrorMessages.js +1 -1
- package/dist/components/MaterialUI/DataDisplay/PredefinedElements/InformationItem.js +3 -3
- package/dist/components/MaterialUI/DataDisplay/PredefinedElements/LookupDisplayValue.js +4 -4
- package/dist/components/MaterialUI/DataDisplay/PredefinedElements/Placeholder.js +1 -1
- package/dist/components/MaterialUI/DataDisplay/PredefinedElements/SectionTitle.js +1 -1
- package/dist/components/MaterialUI/DataDisplay/PredefinedElements/StepperModal.js +28 -12
- package/dist/components/MaterialUI/DataDisplay/PredefinedElements/TableInfoBar.js +1 -1
- package/dist/components/MaterialUI/DataDisplay/PredefinedElements/Translations.js +9 -9
- package/dist/components/MaterialUI/DataDisplay/SelectionList.js +17 -25
- package/dist/components/MaterialUI/DataDisplay/Table.js +9 -9
- package/dist/components/MaterialUI/DataDisplay/TableHeaderCell.js +1 -1
- package/dist/components/MaterialUI/DataDisplay/TableProps.js +6 -6
- package/dist/components/MaterialUI/DataDisplay/Timeline.js +1 -1
- package/dist/components/MaterialUI/DataDisplay/TimelineItem.js +1 -1
- package/dist/components/MaterialUI/DataDisplay/TooltippedElements/MultipleLinesText.js +7 -7
- package/dist/components/MaterialUI/DataDisplay/TooltippedElements/TooltippedIcon.js +4 -4
- package/dist/components/MaterialUI/DataDisplay/TooltippedElements/TooltippedTypography.js +2 -2
- package/dist/components/MaterialUI/DataDisplay/TransferList.js +9 -9
- package/dist/components/MaterialUI/DataDisplay/chipProps.js +6 -6
- package/dist/components/MaterialUI/DataDisplay/collapsableListProps.js +6 -6
- package/dist/components/MaterialUI/DataDisplay/dividerProps.js +6 -6
- package/dist/components/MaterialUI/DataDisplay/index.js +1 -1
- package/dist/components/MaterialUI/DataDisplay/modalProps.js +6 -6
- package/dist/components/MaterialUI/DataDisplay/tableHelpers.js +9 -5
- package/dist/components/MaterialUI/DataDisplay/useTableSelection.js +6 -6
- package/dist/components/MaterialUI/Feedback/NotificationContext.js +6 -6
- package/dist/components/MaterialUI/Feedback/loadingScreen.js +6 -6
- package/dist/components/MaterialUI/Inputs/Autocomplete.js +5 -5
- package/dist/components/MaterialUI/Inputs/AutocompleteProps.js +6 -6
- package/dist/components/MaterialUI/Inputs/Checkbox.js +4 -4
- package/dist/components/MaterialUI/Inputs/CheckboxGroup.js +41 -18
- package/dist/components/MaterialUI/Inputs/CheckboxGroupProps.js +6 -6
- package/dist/components/MaterialUI/Inputs/CheckboxProps.js +6 -6
- package/dist/components/MaterialUI/Inputs/DatePicker.js +15 -16
- package/dist/components/MaterialUI/Inputs/InputBase.js +11 -11
- package/dist/components/MaterialUI/Inputs/InputBaseProps.js +6 -6
- package/dist/components/MaterialUI/Inputs/LookupSelect.js +3 -3
- package/dist/components/MaterialUI/Inputs/PredefinedElements/SearchControl.js +2 -2
- package/dist/components/MaterialUI/Inputs/PredefinedElements/TitledSelect.js +1 -1
- package/dist/components/MaterialUI/Inputs/Radio.js +4 -3
- package/dist/components/MaterialUI/Inputs/RadioProps.js +6 -6
- package/dist/components/MaterialUI/Inputs/Select.js +23 -10
- package/dist/components/MaterialUI/Inputs/SelectProps.js +8 -7
- package/dist/components/MaterialUI/Inputs/StandaloneRadio.js +4 -4
- package/dist/components/MaterialUI/Inputs/Switch.js +32 -20
- package/dist/components/MaterialUI/Inputs/SwitchProps.js +6 -6
- package/dist/components/MaterialUI/Inputs/TimePicker.js +7 -7
- package/dist/components/MaterialUI/Inputs/createInput.js +5 -5
- package/dist/components/MaterialUI/Inputs/index.js +1 -1
- package/dist/components/MaterialUI/Inputs/standaloneRadioProps.js +6 -6
- package/dist/components/MaterialUI/Navigation/DropDownMenu.js +6 -6
- package/dist/components/MaterialUI/Navigation/DropDownMenuProps.js +6 -6
- package/dist/components/MaterialUI/Navigation/ExternalLink.js +1 -1
- package/dist/components/MaterialUI/Navigation/PredefinedElements/ActionMenu.js +1 -1
- package/dist/components/MaterialUI/Navigation/TabBar.js +60 -38
- package/dist/components/MaterialUI/Navigation/TabLabel.js +5 -5
- package/dist/components/MaterialUI/ScopeSelector/ScopeSelector.js +1 -1
- package/dist/components/MaterialUI/ScopeSelector/ScopeTreeView.js +5 -5
- package/dist/components/MaterialUI/ScopeSelector/TreeItem.js +13 -7
- package/dist/components/MaterialUI/Surfaces/ExpansionPanel.js +5 -5
- package/dist/components/MaterialUI/Surfaces/Paper.js +2 -2
- package/dist/components/MaterialUI/Surfaces/PredefinedElements/TitledPaper.js +1 -1
- package/dist/components/MaterialUI/Surfaces/SectionExpansionPanel.js +5 -5
- package/dist/components/MaterialUI/Surfaces/expansionPanelProps.js +7 -7
- package/dist/components/MaterialUI/Surfaces/paperProps.js +6 -6
- package/dist/components/MaterialUI/componentProps.js +2 -2
- package/dist/components/MaterialUI/hocs/withDeferredPopper.js +10 -16
- package/dist/components/MaterialUI/hocs/withDeferredTooltip.js +9 -9
- package/dist/components/MaterialUI/muiThemes.js +2 -2
- package/dist/components/MaterialUI/textProps.js +6 -6
- package/dist/components/Modal/Background.js +1 -1
- package/dist/components/Modal/Dialog.js +2 -2
- package/dist/components/Modal/Wrapper.js +2 -2
- package/dist/components/Modal/index.js +6 -6
- package/dist/components/Modules.js +9 -9
- package/dist/components/MultiSelector.js +9 -9
- package/dist/components/Navigation/Bar.js +8 -8
- package/dist/components/Navigation/Tab.js +8 -8
- package/dist/components/Navigation/index.js +1 -1
- package/dist/components/Navigation/useNavigationState.js +8 -8
- package/dist/components/Placeholder.js +5 -5
- package/dist/components/Provision.js +1 -1
- package/dist/components/Routing/FullPage.js +1 -1
- package/dist/components/Routing/Page.js +7 -7
- package/dist/components/Routing/Segment.js +2 -2
- package/dist/components/Routing/SegmentPage.js +10 -10
- package/dist/components/Routing/SubPage.js +5 -5
- package/dist/components/Routing/withWaypointing.js +4 -4
- package/dist/components/Scope/ScopeModificationConfirmationDialog.js +1 -1
- package/dist/components/Scope/ScopeNode.js +6 -6
- package/dist/components/Scope/Selector.js +1 -1
- package/dist/components/Scope/index.js +8 -8
- package/dist/components/Scope/useScopeConfirmationModalState.js +10 -10
- package/dist/components/Scope/useScopeSelect.js +1 -1
- package/dist/components/ScopeExtendedConfigurationLoader.js +5 -5
- package/dist/components/Selector.js +9 -9
- package/dist/components/Sidepanel.js +2 -2
- package/dist/components/Spritesheet.js +1 -1
- package/dist/components/Switch.js +5 -5
- package/dist/components/TaskDetailsModal.js +2 -2
- package/dist/components/Text.js +6 -6
- package/dist/components/ToastList.js +9 -6
- package/dist/components/Toolbar.js +5 -5
- package/dist/components/Tooltip.js +1 -1
- package/dist/components/Treeview/Branch.js +1 -1
- package/dist/components/Treeview/Label.js +2 -2
- package/dist/components/Treeview/Leaf.js +1 -1
- package/dist/components/Treeview/Node.js +6 -6
- package/dist/components/Treeview/index.js +10 -10
- package/dist/constants.js +7 -1
- package/dist/getThemeOverrides.js +2 -2
- package/dist/hocs/withAuthentication.js +2 -2
- package/dist/hocs/withClickOutside.js +4 -4
- package/dist/hocs/withErrorBoundary.js +7 -7
- package/dist/hocs/withId.js +4 -4
- package/dist/hocs/withNavigationLink.js +5 -5
- package/dist/hocs/withScopeData.js +5 -5
- package/dist/hocs/withScrollBox.js +4 -4
- package/dist/hocs/withToggle.js +7 -7
- package/dist/hocs/withUpdateHandler.js +2 -2
- package/dist/hocs/withViewState.js +5 -5
- package/dist/hooks/useEditState.js +2 -2
- package/dist/hooks/useEntityLoader.js +7 -7
- package/dist/hooks/useFullEntityEditState.js +7 -7
- package/dist/hooks/useInfiniteScroll.js +4 -4
- package/dist/hooks/useLabelMessage.js +3 -3
- package/dist/hooks/useMultipleFieldEditState.js +2 -2
- package/dist/hooks/useNotificationRequestState.js +3 -3
- package/dist/hooks/useRequestState.js +1 -1
- package/dist/hooks/useScopeGuardLoader.js +1 -1
- package/dist/hooks/useSelectorAndUnwrap.js +1 -1
- package/dist/hooks/useToggle.js +4 -4
- package/dist/reducers/applications.js +1 -1
- package/dist/reducers/authentication.js +5 -5
- package/dist/reducers/countries.js +1 -1
- package/dist/reducers/globalErrorMessages.js +1 -1
- package/dist/reducers/localeFactory.js +1 -1
- package/dist/reducers/metadata.js +6 -6
- package/dist/reducers/modules.js +1 -1
- package/dist/reducers/navigation.js +1 -1
- package/dist/reducers/request.js +1 -1
- package/dist/reducers/requestStates.js +1 -1
- package/dist/reducers/scopeRouteState.js +1 -1
- package/dist/reducers/scopes.js +1 -1
- package/dist/reducers/scopesExtendedConfiguration.js +1 -1
- package/dist/reducers/settings.js +1 -1
- package/dist/reducers/tasks.js +1 -1
- package/dist/reducers/timezones.js +1 -1
- package/dist/reducers/toasts.js +1 -1
- package/dist/reducers/versionInfo.js +1 -1
- package/dist/reducers/view.js +1 -1
- package/dist/selectors/locale.js +1 -1
- package/dist/selectors/metadata.js +3 -3
- package/dist/selectors/modules.js +2 -2
- package/dist/selectors/navigation.js +1 -1
- package/dist/selectors/route.js +1 -1
- package/dist/selectors/scope.js +1 -1
- package/dist/selectors/tasks.js +1 -1
- package/dist/utils/buildUrl.js +19 -5
- package/dist/utils/flatten.js +6 -6
- package/dist/utils/index.js +1 -1
- package/dist/utils/inputHelper.js +14 -2
- package/dist/utils/logPass.js +1 -1
- package/dist/utils/memoize.js +1 -1
- package/dist/utils/modelValidationHelper.js +2 -2
- package/dist/utils/normalizeForSearch.js +4 -1
- package/dist/utils/propertyBagHelper.js +4 -4
- package/dist/utils/propertyHelper.js +6 -6
- package/dist/utils/propertyValidator.js +1 -1
- package/dist/utils/setTranslation.js +3 -3
- package/dist/utils/setTranslationWithFallback.js +3 -3
- package/dist/utils/stripKey.js +3 -3
- package/dist/utils/styledPropFuncs.js +1 -1
- package/dist/utils/testUtils.js +8 -5
- package/dist/utils/timezoneHelper.js +6 -6
- package/dist/utils/unwrapImmutable.js +1 -1
- package/dist/utils/urlHelper.js +3 -3
- package/dist/whyDidYouRerender.js +1 -1
- package/package.json +2 -2
- package/src/components/AppFrame/ConnectedToastList.test.js +3 -1
- package/src/components/DropMenu/DropMenu.test.js +2 -0
- package/src/components/Form/InputField.js +1 -1
- package/src/components/Form/InputField.test.js +1 -1
- package/src/components/MaterialUI/DataDisplay/Badge.js +1 -1
- package/src/components/MaterialUI/DataDisplay/PredefinedElements/StepperModal.js +33 -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/DataDisplay/tableHelpers.js +14 -4
- package/src/components/MaterialUI/Feedback/loadingScreen.test.js +1 -0
- package/src/components/MaterialUI/Feedback/useNotification.test.js +1 -0
- package/src/components/MaterialUI/Inputs/CheckboxGroup.js +36 -12
- package/src/components/MaterialUI/Inputs/CheckboxGroup.test.js +55 -4
- package/src/components/MaterialUI/Inputs/DatePicker.js +16 -4
- package/src/components/MaterialUI/Inputs/DatePicker.test.js +35 -1
- package/src/components/MaterialUI/Inputs/Radio.js +1 -1
- package/src/components/MaterialUI/Inputs/Radio.test.js +35 -1
- package/src/components/MaterialUI/Inputs/Select.js +13 -1
- package/src/components/MaterialUI/Inputs/Select.test.js +37 -0
- package/src/components/MaterialUI/Inputs/SelectProps.js +1 -0
- package/src/components/MaterialUI/Inputs/Switch.js +28 -6
- package/src/components/MaterialUI/Inputs/Switch.test.js +39 -0
- package/src/components/MaterialUI/Navigation/TabBar.js +55 -34
- package/src/components/MaterialUI/ScopeSelector/TreeItem.js +7 -3
- package/src/components/MaterialUI/ScopeSelector/TreeItem.test.js +39 -0
- package/src/components/MaterialUI/hocs/withDeferredPopper.js +1 -4
- package/src/components/MaterialUI/hocs/withDeferredPopper.test.js +2 -0
- package/src/components/Modal/Modal.test.js +3 -1
- package/src/components/Modal/Wrapper.test.js +3 -1
- package/src/components/Routing/SegmentPage.js +1 -1
- package/src/components/Scope/Scope.test.js +3 -1
- package/src/components/Sidepanel.test.js +3 -1
- package/src/components/ToastList.js +2 -2
- package/src/constants.js +5 -0
- package/src/hocs/withErrorBoundary.test.js +4 -3
- package/src/hooks/useEditState.test.js +2 -0
- package/src/hooks/useLabelMessage.test.js +2 -0
- package/src/utils/buildUrl.js +15 -0
- package/src/utils/buildUrl.test.js +27 -1
- package/src/utils/inputHelper.js +18 -2
- package/src/utils/inputHelper.test.js +18 -2
- package/src/utils/normalizeForSearch.js +2 -0
- package/src/utils/propertyBagHelper.js +6 -3
- package/src/utils/propertyHelper.js +6 -6
- package/src/utils/testUtils.js +25 -22
- package/src/utils/testUtils.test.js +4 -4
|
@@ -66,7 +66,15 @@ const renderByType = (e, def, rowId, readOnly, transformedValue, index) => {
|
|
|
66
66
|
);
|
|
67
67
|
checkboxProps.set(CheckboxProps.propNames.metadata, { id: rowId, name: def.fieldName });
|
|
68
68
|
|
|
69
|
-
return [
|
|
69
|
+
return [
|
|
70
|
+
<Checkbox
|
|
71
|
+
key={def.type + "_" + rowId}
|
|
72
|
+
id={"select_" + transformedValue}
|
|
73
|
+
data-row-id={rowId}
|
|
74
|
+
checkboxProps={checkboxProps}
|
|
75
|
+
/>,
|
|
76
|
+
null,
|
|
77
|
+
];
|
|
70
78
|
|
|
71
79
|
case "switch":
|
|
72
80
|
const switchProps = new SwitchProps();
|
|
@@ -85,7 +93,9 @@ const renderByType = (e, def, rowId, readOnly, transformedValue, index) => {
|
|
|
85
93
|
switchProps.set(SwitchProps.propNames.className, def.switch?.className);
|
|
86
94
|
switchProps.set(SwitchProps.propNames.metadata, { id: rowId, name: def.fieldName });
|
|
87
95
|
|
|
88
|
-
return transformedValue != null
|
|
96
|
+
return transformedValue != null
|
|
97
|
+
? [<Switch key={def.type + "_" + rowId} data-row-id={rowId} switchProps={switchProps} />]
|
|
98
|
+
: [null];
|
|
89
99
|
|
|
90
100
|
case "radio":
|
|
91
101
|
const selectedValue = def.selectedValue;
|
|
@@ -107,7 +117,7 @@ const renderByType = (e, def, rowId, readOnly, transformedValue, index) => {
|
|
|
107
117
|
StandaloneRadioProps.propNames.readOnly,
|
|
108
118
|
def.transform?.readOnly != null ? def.transform.readOnly(e, readOnly, def) : readOnly,
|
|
109
119
|
);
|
|
110
|
-
return [<StandaloneRadio radioProps={radioProps} />];
|
|
120
|
+
return [<StandaloneRadio key={def.type + "_" + rowId} radioProps={radioProps} />];
|
|
111
121
|
|
|
112
122
|
case "textInput":
|
|
113
123
|
const inputBaseProps = new InputBaseProps();
|
|
@@ -124,7 +134,7 @@ const renderByType = (e, def, rowId, readOnly, transformedValue, index) => {
|
|
|
124
134
|
);
|
|
125
135
|
inputBaseProps.set(InputBaseProps.propNames.inputAttributes, def.inputAttributes);
|
|
126
136
|
inputBaseProps.set(InputBaseProps.propNames.metadata, { id: rowId, name: def.fieldName });
|
|
127
|
-
return [<InputBase inputProps={inputBaseProps} />];
|
|
137
|
+
return [<InputBase key={def.type + "_" + rowId} inputProps={inputBaseProps} />];
|
|
128
138
|
default:
|
|
129
139
|
return [defaultRendering(e, def, rowId, readOnly, transformedValue)];
|
|
130
140
|
}
|
|
@@ -70,6 +70,7 @@ describe("loadingScreen", () => {
|
|
|
70
70
|
const clock = sinon.useFakeTimers();
|
|
71
71
|
const menuNode = document.createElement("div");
|
|
72
72
|
document.body.appendChild(menuNode);
|
|
73
|
+
// eslint-disable-next-line react/no-render-return-value
|
|
73
74
|
const menu = ReactDOM.render(
|
|
74
75
|
<div>
|
|
75
76
|
<TestWrapper stylesProvider muiThemeProvider={{ theme }} provider={{ store }}>
|
|
@@ -8,6 +8,7 @@ const TestComp = () => {
|
|
|
8
8
|
const addNotification = useNotification(snackPack, setSnackPack);
|
|
9
9
|
return (
|
|
10
10
|
<div>
|
|
11
|
+
{/* eslint-disable-next-line react/no-unknown-property */}
|
|
11
12
|
<div id="notification" snacks={snackPack} onClick={(message, type) => addNotification(message, type)} />
|
|
12
13
|
</div>
|
|
13
14
|
);
|
|
@@ -3,7 +3,9 @@ import FormControlLabel from "@material-ui/core/FormControlLabel";
|
|
|
3
3
|
import CheckboxGroupProps, { isCheckboxGroupProps } from "./CheckboxGroupProps";
|
|
4
4
|
import Checkbox from "./Checkbox";
|
|
5
5
|
import CheckboxProps from "./CheckboxProps";
|
|
6
|
+
import TooltippedIcon from "../DataDisplay/TooltippedElements/TooltippedIcon";
|
|
6
7
|
import { makeStyles } from "@material-ui/core/styles";
|
|
8
|
+
import classNames from "classnames";
|
|
7
9
|
|
|
8
10
|
const useStyles = makeStyles(theme => ({
|
|
9
11
|
container: {
|
|
@@ -14,17 +16,6 @@ const useStyles = makeStyles(theme => ({
|
|
|
14
16
|
display: "flex",
|
|
15
17
|
flexDirection: props => (props.row ? "row" : "column"),
|
|
16
18
|
flexWrap: "wrap",
|
|
17
|
-
"& .MuiFormControlLabel-root": {
|
|
18
|
-
[theme.breakpoints.up("xs")]: {},
|
|
19
|
-
[theme.breakpoints.up("sm")]: {},
|
|
20
|
-
[theme.breakpoints.up("md")]: { width: "45%" },
|
|
21
|
-
[theme.breakpoints.up("lg")]: { width: "30%" },
|
|
22
|
-
[theme.breakpoints.up("xl")]: { width: "20%" },
|
|
23
|
-
|
|
24
|
-
"& + .MuiFormControlLabel-root": {
|
|
25
|
-
marginTop: theme.spacing(1),
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
19
|
},
|
|
29
20
|
errorText: {
|
|
30
21
|
marginTop: theme.spacing(0.5),
|
|
@@ -32,6 +23,28 @@ const useStyles = makeStyles(theme => ({
|
|
|
32
23
|
fontSize: theme.typography.fieldLabelSize,
|
|
33
24
|
float: "left",
|
|
34
25
|
},
|
|
26
|
+
warningIcon: {
|
|
27
|
+
width: "1em",
|
|
28
|
+
height: "1em",
|
|
29
|
+
fontSize: 16,
|
|
30
|
+
alignSelf: "center",
|
|
31
|
+
marginRight: theme.spacing(2),
|
|
32
|
+
"& > svg": {
|
|
33
|
+
color: theme.palette.error.main,
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
checkboxItemWarning: {
|
|
37
|
+
color: theme.palette.error.main,
|
|
38
|
+
},
|
|
39
|
+
checkboxItem: props => ({
|
|
40
|
+
display: "flex",
|
|
41
|
+
[theme.breakpoints.up("xs")]: {},
|
|
42
|
+
[theme.breakpoints.up("sm")]: {},
|
|
43
|
+
[theme.breakpoints.up("md")]: props.row ? { width: "45%" } : {},
|
|
44
|
+
[theme.breakpoints.up("lg")]: props.row ? { width: "30%" } : {},
|
|
45
|
+
[theme.breakpoints.up("xl")]: props.row ? { width: "20%" } : {},
|
|
46
|
+
marginTop: theme.spacing(1),
|
|
47
|
+
}),
|
|
35
48
|
}));
|
|
36
49
|
|
|
37
50
|
const CheckboxGroup = ({ checkboxGroupProps }) => {
|
|
@@ -73,7 +86,18 @@ const CheckboxGroup = ({ checkboxGroupProps }) => {
|
|
|
73
86
|
checkboxProps.set(CheckboxProps.propNames.label, option.label ?? option.value);
|
|
74
87
|
checkboxProps.set(CheckboxProps.propNames.readOnly, readOnly);
|
|
75
88
|
checkboxProps.set(CheckboxProps.propNames.disabled, disabled);
|
|
76
|
-
|
|
89
|
+
|
|
90
|
+
return (
|
|
91
|
+
<div
|
|
92
|
+
key={index}
|
|
93
|
+
className={classNames(classes.checkboxItem, { [classes.checkboxItemWarning]: !!option.warningMessage })}
|
|
94
|
+
>
|
|
95
|
+
<Checkbox checkboxProps={checkboxProps} />
|
|
96
|
+
{option.warningMessage && (
|
|
97
|
+
<TooltippedIcon className={classes.warningIcon} titleValue={option.warningMessage} id="warning" />
|
|
98
|
+
)}
|
|
99
|
+
</div>
|
|
100
|
+
);
|
|
77
101
|
})}
|
|
78
102
|
</div>
|
|
79
103
|
{error && <div className={classes.errorText}>{error}</div>}
|
|
@@ -7,6 +7,7 @@ import sinon from "sinon";
|
|
|
7
7
|
import { ignoreConsoleError } from "../../../utils/testUtils";
|
|
8
8
|
import CheckboxGroupProps from "./CheckboxGroupProps";
|
|
9
9
|
import CheckboxProps from "./CheckboxProps";
|
|
10
|
+
import TooltippedIcon from "../DataDisplay/TooltippedElements/TooltippedIcon";
|
|
10
11
|
|
|
11
12
|
describe("CheckboxGroup Component", () => {
|
|
12
13
|
let update, container;
|
|
@@ -74,10 +75,60 @@ describe("CheckboxGroup Component", () => {
|
|
|
74
75
|
const expected = (
|
|
75
76
|
<div>
|
|
76
77
|
<div>
|
|
77
|
-
<
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
<
|
|
78
|
+
<div key={1}>
|
|
79
|
+
<Checkbox checkboxProps={checkbox1Props} />
|
|
80
|
+
</div>
|
|
81
|
+
<div key={2}>
|
|
82
|
+
<Checkbox checkboxProps={checkbox2Props} />
|
|
83
|
+
</div>
|
|
84
|
+
<div key={3}>
|
|
85
|
+
<Checkbox checkboxProps={checkbox3Props} />
|
|
86
|
+
</div>
|
|
87
|
+
<div key={4}>
|
|
88
|
+
<Checkbox checkboxProps={checkbox4Props} />
|
|
89
|
+
</div>
|
|
90
|
+
</div>
|
|
91
|
+
</div>
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
expect(component, "when mounted", "to satisfy", expected);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it("Renders CheckboxGroup component with one warning", () => {
|
|
98
|
+
const props = new CheckboxGroupProps();
|
|
99
|
+
const options = [
|
|
100
|
+
{ value: "option1", sortOrder: 1 },
|
|
101
|
+
{ value: "option2", sortOrder: 2, warningMessage: "warning message" },
|
|
102
|
+
];
|
|
103
|
+
|
|
104
|
+
props.set(CheckboxGroupProps.propNames.update, update);
|
|
105
|
+
props.set(CheckboxGroupProps.propNames.value, "option1|option2");
|
|
106
|
+
props.set(CheckboxGroupProps.propNames.options, options);
|
|
107
|
+
const component = <CheckboxGroup checkboxGroupProps={props} />;
|
|
108
|
+
|
|
109
|
+
const checkbox1Props = new CheckboxProps();
|
|
110
|
+
checkbox1Props.set(CheckboxProps.propNames.update, update);
|
|
111
|
+
checkbox1Props.set(CheckboxProps.propNames.value, true);
|
|
112
|
+
checkbox1Props.set(CheckboxProps.propNames.label, "option1");
|
|
113
|
+
checkbox1Props.set(CheckboxProps.propNames.readOnly, false);
|
|
114
|
+
checkbox1Props.set(CheckboxProps.propNames.disabled, false);
|
|
115
|
+
|
|
116
|
+
const checkbox2Props = new CheckboxProps();
|
|
117
|
+
checkbox2Props.set(CheckboxProps.propNames.update, update);
|
|
118
|
+
checkbox2Props.set(CheckboxProps.propNames.value, false);
|
|
119
|
+
checkbox2Props.set(CheckboxProps.propNames.label, "option2");
|
|
120
|
+
checkbox2Props.set(CheckboxProps.propNames.readOnly, false);
|
|
121
|
+
checkbox2Props.set(CheckboxProps.propNames.disabled, false);
|
|
122
|
+
const expected = (
|
|
123
|
+
<div>
|
|
124
|
+
<div>
|
|
125
|
+
<div key={1}>
|
|
126
|
+
<Checkbox checkboxProps={checkbox1Props} />
|
|
127
|
+
</div>
|
|
128
|
+
<div key={2}>
|
|
129
|
+
<Checkbox checkboxProps={checkbox2Props} />
|
|
130
|
+
<TooltippedIcon titleValue={"warning message"} id="warning" />
|
|
131
|
+
</div>
|
|
81
132
|
</div>
|
|
82
133
|
</div>
|
|
83
134
|
);
|
|
@@ -21,11 +21,11 @@ const useStyles = makeStyles(theme => ({
|
|
|
21
21
|
datePickerWrapper: {
|
|
22
22
|
display: "flex",
|
|
23
23
|
width: "auto",
|
|
24
|
-
padding:
|
|
25
|
-
border:
|
|
24
|
+
padding: theme.spacing(0.3, 0.5),
|
|
25
|
+
border: `1px solid ${theme.palette.grey.borders}`,
|
|
26
26
|
borderRadius: theme.shape.borderRadius,
|
|
27
27
|
alignItems: "center",
|
|
28
|
-
backgroundColor:
|
|
28
|
+
backgroundColor: theme.palette.background.default,
|
|
29
29
|
"&:focus, &:focus-within": {
|
|
30
30
|
borderRadius: theme.shape.borderRadius,
|
|
31
31
|
borderColor: theme.palette.focus,
|
|
@@ -82,6 +82,11 @@ const useStyles = makeStyles(theme => ({
|
|
|
82
82
|
opacity: 0.4,
|
|
83
83
|
},
|
|
84
84
|
},
|
|
85
|
+
datePickerWrapperReadOnly: {
|
|
86
|
+
padding: "0",
|
|
87
|
+
border: "none",
|
|
88
|
+
backgroundColor: "inherit",
|
|
89
|
+
},
|
|
85
90
|
disabled: {
|
|
86
91
|
border: `1px solid ${theme.palette.grey.light} !important`,
|
|
87
92
|
backgroundColor: `${theme.palette.grey.light} !important`,
|
|
@@ -157,7 +162,14 @@ const WrappedDatePicker = ({
|
|
|
157
162
|
|
|
158
163
|
return (
|
|
159
164
|
<div className={classes.container}>
|
|
160
|
-
<label
|
|
165
|
+
<label
|
|
166
|
+
className={classNames(
|
|
167
|
+
classes.datePickerWrapper,
|
|
168
|
+
readOnly ? classes.datePickerWrapperReadOnly : null,
|
|
169
|
+
disabledCls,
|
|
170
|
+
error ? classes.errorInput : null,
|
|
171
|
+
)}
|
|
172
|
+
>
|
|
161
173
|
<div className={classes.datePickerContainer}>
|
|
162
174
|
<DatePicker
|
|
163
175
|
{...props}
|
|
@@ -3,8 +3,10 @@ import DatePicker, { createFormat } from "./DatePicker";
|
|
|
3
3
|
import { mount } from "enzyme";
|
|
4
4
|
import sinon from "sinon";
|
|
5
5
|
import Icon from "../DataDisplay/Icon";
|
|
6
|
-
import { TestWrapper, createMuiTheme } from "./../../../utils/testUtils";
|
|
6
|
+
import { TestWrapper, createMuiTheme, generateClassName } from "./../../../utils/testUtils";
|
|
7
7
|
import Immutable from "immutable";
|
|
8
|
+
import { StylesProvider } from "@material-ui/core/styles";
|
|
9
|
+
import { MuiThemeProvider } from "@material-ui/core";
|
|
8
10
|
|
|
9
11
|
describe("DatePicker", () => {
|
|
10
12
|
let updater, state, store;
|
|
@@ -426,6 +428,38 @@ describe("DatePicker", () => {
|
|
|
426
428
|
input.at(0).simulate("change", event);
|
|
427
429
|
});
|
|
428
430
|
|
|
431
|
+
it("should have readonly styles when readonly", () => {
|
|
432
|
+
const date = new Date("2020-06-30T00:00:00");
|
|
433
|
+
|
|
434
|
+
const component = (
|
|
435
|
+
<TestWrapper provider={{ store }} intlProvider>
|
|
436
|
+
<StylesProvider generateClassName={generateClassName}>
|
|
437
|
+
<MuiThemeProvider theme={createMuiTheme()}>
|
|
438
|
+
<DatePicker useTime={true} readOnly={true} onChange={updater} value={date} />
|
|
439
|
+
</MuiThemeProvider>
|
|
440
|
+
</StylesProvider>
|
|
441
|
+
</TestWrapper>
|
|
442
|
+
);
|
|
443
|
+
const mountedComponent = mount(component);
|
|
444
|
+
expect(mountedComponent.exists(".makeStyles-datePickerWrapperReadOnly"), "to be true");
|
|
445
|
+
});
|
|
446
|
+
|
|
447
|
+
it("should have updatable styles when updatable", () => {
|
|
448
|
+
const date = new Date("2020-06-30T00:00:00");
|
|
449
|
+
|
|
450
|
+
const component = (
|
|
451
|
+
<TestWrapper provider={{ store }} intlProvider>
|
|
452
|
+
<StylesProvider generateClassName={generateClassName}>
|
|
453
|
+
<MuiThemeProvider theme={createMuiTheme()}>
|
|
454
|
+
<DatePicker useTime={true} readOnly={false} onChange={updater} value={date} />
|
|
455
|
+
</MuiThemeProvider>
|
|
456
|
+
</StylesProvider>
|
|
457
|
+
</TestWrapper>
|
|
458
|
+
);
|
|
459
|
+
const mountedComponent = mount(component);
|
|
460
|
+
expect(mountedComponent.exists(".makeStyles-datePickerWrapperReadOnly"), "to be false");
|
|
461
|
+
});
|
|
462
|
+
|
|
429
463
|
it("should call onChange prop with useTimeZone", () => {
|
|
430
464
|
const onChangeMock = jest.fn();
|
|
431
465
|
const date = new Date("2020-06-30T00:00:00");
|
|
@@ -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
|
});
|
|
@@ -145,6 +145,8 @@ export const SelectIconButton = props => {
|
|
|
145
145
|
);
|
|
146
146
|
};
|
|
147
147
|
|
|
148
|
+
const selectEmptyValue = "~~#~~";
|
|
149
|
+
|
|
148
150
|
const Select = ({ options, selectProps, children }) => {
|
|
149
151
|
if (isSelectProps(selectProps) === false) {
|
|
150
152
|
throw new TypeError("selectProps property is not of type SelectProps");
|
|
@@ -177,6 +179,16 @@ const Select = ({ options, selectProps, children }) => {
|
|
|
177
179
|
);
|
|
178
180
|
} else if (sortType === sortTypeEnum.default) {
|
|
179
181
|
options.sort((a, b) => (a.sortOrder > b.sortOrder ? 1 : -1));
|
|
182
|
+
} else if (sortType === sortTypeEnum.alphabetical) {
|
|
183
|
+
options.sort((a, b) => {
|
|
184
|
+
if (a.value === selectEmptyValue) {
|
|
185
|
+
return -1;
|
|
186
|
+
}
|
|
187
|
+
if (b.value === selectEmptyValue) {
|
|
188
|
+
return 1;
|
|
189
|
+
}
|
|
190
|
+
return a.label.localeCompare(b.label);
|
|
191
|
+
});
|
|
180
192
|
}
|
|
181
193
|
|
|
182
194
|
if (showAllValue && showAllLabel) {
|
|
@@ -207,7 +219,7 @@ const Select = ({ options, selectProps, children }) => {
|
|
|
207
219
|
const appliedClasses = classNames(classes.baseItem, clss);
|
|
208
220
|
const labelClss = classNames({
|
|
209
221
|
[classes.label]: true,
|
|
210
|
-
[classes.emptyLabel]: option.value === "" || option.value ===
|
|
222
|
+
[classes.emptyLabel]: option.value === "" || option.value === selectEmptyValue,
|
|
211
223
|
});
|
|
212
224
|
|
|
213
225
|
const disabled = !!option.disabled;
|
|
@@ -496,6 +496,43 @@ describe("Select Component", () => {
|
|
|
496
496
|
expect(optionsKeys, "to equal", ["#All#", "a", "b", "c"]);
|
|
497
497
|
});
|
|
498
498
|
|
|
499
|
+
it("Sorts select options correctly with alphabetical sorting", () => {
|
|
500
|
+
const emptyValue = "~~#~~";
|
|
501
|
+
|
|
502
|
+
const options = [
|
|
503
|
+
{ value: "c", label: "c" },
|
|
504
|
+
{ value: "a", label: "a" },
|
|
505
|
+
{ value: "b", label: "b" },
|
|
506
|
+
{ value: "f", label: "f" },
|
|
507
|
+
{ value: emptyValue, label: "empty" },
|
|
508
|
+
{ value: "h", label: "h" },
|
|
509
|
+
{ value: "g", label: "g" },
|
|
510
|
+
{ value: "e", label: "e" },
|
|
511
|
+
{ value: "d", label: "[d]" },
|
|
512
|
+
];
|
|
513
|
+
|
|
514
|
+
const selectProps = new SelectProps();
|
|
515
|
+
|
|
516
|
+
selectProps.set(SelectProps.propNames.sortType, sortTypeEnum.alphabetical);
|
|
517
|
+
selectProps.set(SelectProps.propNames.value, "b");
|
|
518
|
+
|
|
519
|
+
const component = (
|
|
520
|
+
<TestWrapper stylesProvider muiThemeProvider={{ theme }}>
|
|
521
|
+
<Select options={options} selectProps={selectProps} />
|
|
522
|
+
</TestWrapper>
|
|
523
|
+
);
|
|
524
|
+
|
|
525
|
+
const mountedComponent = mount(component);
|
|
526
|
+
|
|
527
|
+
const test = mountedComponent.find(SelectMUI);
|
|
528
|
+
|
|
529
|
+
const mountedOptions = test.props().children;
|
|
530
|
+
|
|
531
|
+
const optionsKeys = mountedOptions.map(option => option.key);
|
|
532
|
+
|
|
533
|
+
expect(optionsKeys, "to equal", [emptyValue, "d", "a", "b", "c", "e", "f", "g", "h"]);
|
|
534
|
+
});
|
|
535
|
+
|
|
499
536
|
it("Sorts select options correctly with numeric sorting", () => {
|
|
500
537
|
const options = [
|
|
501
538
|
{ value: "BRC-409 - BRC-PROMENADES", label: "BRC-409 - BRC-PROMENADES", sortOrder: "BRC-409 - BRC-PROMENADES" },
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import classNames from "classnames";
|
|
2
3
|
import SwitchMui from "@material-ui/core/Switch";
|
|
3
4
|
import { makeStyles } from "@material-ui/core/styles";
|
|
4
5
|
import SwitchProps, { isSwitchProps } from "./SwitchProps";
|
|
@@ -21,13 +22,19 @@ export const useStyles = makeStyles(theme => ({
|
|
|
21
22
|
input: {
|
|
22
23
|
left: "-250%",
|
|
23
24
|
width: "600%",
|
|
24
|
-
cursor:
|
|
25
|
+
cursor: "inherit",
|
|
26
|
+
},
|
|
27
|
+
inputReadOnly: {
|
|
28
|
+
cursor: "default",
|
|
25
29
|
},
|
|
26
30
|
thumb: {
|
|
27
31
|
width: theme.spacing(1.3),
|
|
28
32
|
height: theme.spacing(1.3),
|
|
29
33
|
backgroundColor: theme.palette.background.default,
|
|
30
|
-
display:
|
|
34
|
+
display: "inherit",
|
|
35
|
+
},
|
|
36
|
+
thumbReadOnly: {
|
|
37
|
+
display: "none",
|
|
31
38
|
},
|
|
32
39
|
track: {
|
|
33
40
|
backgroundColor: theme.palette.grey.borders,
|
|
@@ -45,13 +52,19 @@ export const useStyles = makeStyles(theme => ({
|
|
|
45
52
|
"&:before": {
|
|
46
53
|
content: props => `"${props.formattedOnCaption}"`,
|
|
47
54
|
left: theme.spacing(0.9),
|
|
48
|
-
right: props => props.readOnly && theme.spacing(0.9),
|
|
49
55
|
opacity: 0,
|
|
50
56
|
},
|
|
51
57
|
"&:after": {
|
|
52
58
|
content: props => `"${props.formattedOffCaption}"`,
|
|
53
59
|
right: theme.spacing(0.9),
|
|
54
|
-
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
trackReadOnly: {
|
|
63
|
+
"&:before": {
|
|
64
|
+
right: theme.spacing(0.9),
|
|
65
|
+
},
|
|
66
|
+
"&:after": {
|
|
67
|
+
left: theme.spacing(0.9),
|
|
55
68
|
},
|
|
56
69
|
},
|
|
57
70
|
checked: {
|
|
@@ -95,8 +108,17 @@ const Switch = ({ switchProps }) => {
|
|
|
95
108
|
const formattedOnCaption = onCaption != null ? formatMessage(onCaption) : "";
|
|
96
109
|
const formattedOffCaption = offCaption != null ? formatMessage(offCaption) : "";
|
|
97
110
|
|
|
98
|
-
const classes = useStyles({ formattedOnCaption, formattedOffCaption
|
|
99
|
-
const switchClasses = {
|
|
111
|
+
const classes = useStyles({ formattedOnCaption, formattedOffCaption });
|
|
112
|
+
const switchClasses = {
|
|
113
|
+
root: classes.root,
|
|
114
|
+
switchBase: classes.switchBase,
|
|
115
|
+
input: classNames(classes.input, { [classes.inputReadOnly]: readOnly }),
|
|
116
|
+
thumb: classNames(classes.thumb, { [classes.thumbReadOnly]: readOnly }),
|
|
117
|
+
track: classNames(classes.track, { [classes.trackReadOnly]: readOnly }),
|
|
118
|
+
checked: classes.checked,
|
|
119
|
+
disabled: classes.disabled,
|
|
120
|
+
...className,
|
|
121
|
+
};
|
|
100
122
|
|
|
101
123
|
return (
|
|
102
124
|
<SwitchMui
|
|
@@ -6,6 +6,9 @@ import { ignoreConsoleError } from "../../../utils/testUtils";
|
|
|
6
6
|
import SwitchProps from "./SwitchProps";
|
|
7
7
|
import Switch from "./Switch";
|
|
8
8
|
import { IntlProvider } from "react-intl";
|
|
9
|
+
import { StylesProvider } from "@material-ui/core/styles";
|
|
10
|
+
import { MuiThemeProvider } from "@material-ui/core";
|
|
11
|
+
import { generateClassName, createMuiTheme } from "~/utils/testUtils";
|
|
9
12
|
|
|
10
13
|
const messages = {
|
|
11
14
|
captionOn: "is On",
|
|
@@ -77,6 +80,42 @@ describe("Switch Component", () => {
|
|
|
77
80
|
expect(update, "to have calls satisfying", [{ args: [true, {}] }]);
|
|
78
81
|
});
|
|
79
82
|
|
|
83
|
+
it("Renders readonly switch with readonly styles", () => {
|
|
84
|
+
const switchProps = new SwitchProps();
|
|
85
|
+
switchProps.set(SwitchProps.propNames.readOnly, true);
|
|
86
|
+
const component = (
|
|
87
|
+
<IntlProvider locale="en-US">
|
|
88
|
+
<StylesProvider generateClassName={generateClassName}>
|
|
89
|
+
<MuiThemeProvider theme={createMuiTheme()}>
|
|
90
|
+
<Switch switchProps={switchProps} />
|
|
91
|
+
</MuiThemeProvider>
|
|
92
|
+
</StylesProvider>
|
|
93
|
+
</IntlProvider>
|
|
94
|
+
);
|
|
95
|
+
const mountedComponent = mount(component);
|
|
96
|
+
expect(mountedComponent.exists(".makeStyles-inputReadOnly"), "to be true");
|
|
97
|
+
expect(mountedComponent.exists(".makeStyles-thumbReadOnly"), "to be true");
|
|
98
|
+
expect(mountedComponent.exists(".makeStyles-trackReadOnly"), "to be true");
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it("Renders updatable switch with updatable styles", () => {
|
|
102
|
+
const switchProps = new SwitchProps();
|
|
103
|
+
switchProps.set(SwitchProps.propNames.readOnly, false);
|
|
104
|
+
const component = (
|
|
105
|
+
<IntlProvider locale="en-US">
|
|
106
|
+
<StylesProvider generateClassName={generateClassName}>
|
|
107
|
+
<MuiThemeProvider theme={createMuiTheme()}>
|
|
108
|
+
<Switch switchProps={switchProps} />
|
|
109
|
+
</MuiThemeProvider>
|
|
110
|
+
</StylesProvider>
|
|
111
|
+
</IntlProvider>
|
|
112
|
+
);
|
|
113
|
+
const mountedComponent = mount(component);
|
|
114
|
+
expect(mountedComponent.exists(".makeStyles-inputReadOnly"), "to be false");
|
|
115
|
+
expect(mountedComponent.exists(".makeStyles-thumbReadOnly"), "to be false");
|
|
116
|
+
expect(mountedComponent.exists(".makeStyles-trackReadOnly"), "to be false");
|
|
117
|
+
});
|
|
118
|
+
|
|
80
119
|
it("Checkbox component handles uncheck", () => {
|
|
81
120
|
const switchProps = new SwitchProps();
|
|
82
121
|
|