dynamic-mui 1.1.5 → 2.0.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/LICENSE +21 -0
- package/README.md +57 -22
- package/dist/components/DynamicComponent.d.ts +12 -0
- package/dist/components/FormGenerator.d.ts +37 -0
- package/dist/components/charts/Bar/bar.d.ts +2 -0
- package/dist/components/charts/Line/line.d.ts +2 -0
- package/dist/components/charts/Mixchart/mixChart.d.ts +2 -0
- package/dist/components/charts/Pie/pie.d.ts +2 -0
- package/dist/components/controls/Accordion/accordion.d.ts +2 -0
- package/dist/components/controls/Autocomplete/autocomplete.d.ts +2 -0
- package/dist/components/controls/CheckBox/checkbox.d.ts +3 -0
- package/dist/components/controls/Chip/chip.d.ts +2 -0
- package/dist/components/controls/DataTable/datatable.d.ts +2 -0
- package/dist/components/controls/DateTime/datetime.d.ts +2 -0
- package/dist/components/controls/DateTimePicker/datetimepicker.d.ts +2 -0
- package/dist/components/controls/Divider/divider.d.ts +2 -0
- package/dist/components/controls/Group/group.d.ts +2 -0
- package/dist/components/controls/Hyperlink/hyperlink.d.ts +2 -0
- package/dist/components/controls/ImageList/imagelist.d.ts +2 -0
- package/dist/components/controls/List/list.d.ts +2 -0
- package/dist/components/controls/MultiTextbox/multitextbox.d.ts +2 -0
- package/dist/components/controls/NumberField/numberfield.d.ts +2 -0
- package/dist/components/controls/Radio/radio.d.ts +3 -0
- package/dist/components/controls/Select/select.d.ts +2 -0
- package/dist/components/controls/Signature/signature.d.ts +2 -0
- package/dist/components/controls/Stepper/stepper.d.ts +8 -0
- package/dist/components/controls/Switch/switch.d.ts +3 -0
- package/dist/components/controls/Tabs/tabs.d.ts +2 -0
- package/dist/components/controls/TextField/textfield.d.ts +2 -0
- package/dist/components/controls/TimePicker/timepicker.d.ts +2 -0
- package/dist/components/controls/Typography/typography.d.ts +3 -0
- package/dist/components/controls/index.d.ts +57 -0
- package/dist/config/mui.d.ts +8 -0
- package/dist/dynamic-mui.cjs.js +1 -0
- package/dist/dynamic-mui.es.js +9 -0
- package/dist/index-BFycuK80.js +465 -0
- package/dist/index-CJMUh0I6.js +1 -0
- package/dist/index-DvtivzW0.mjs +101901 -0
- package/dist/index-ipsOTYQY.mjs +153 -0
- package/dist/index.d.ts +5 -0
- package/dist/loadCognitoIdentity-BwoR11En.js +1 -0
- package/dist/loadCognitoIdentity-Cqci1Eff.mjs +935 -0
- package/dist/main.d.ts +1 -0
- package/dist/playground/Builder.d.ts +1 -0
- package/dist/playground/Canvas.d.ts +9 -0
- package/dist/playground/PropertiesEditor.d.ts +10 -0
- package/dist/playground/Sidebar.d.ts +1 -0
- package/dist/playground/documentation.d.ts +6 -0
- package/dist/playground/templates.d.ts +7 -0
- package/dist/playground/testData.d.ts +2 -0
- package/dist/test/setup.d.ts +0 -0
- package/dist/theme/theme.d.ts +1 -0
- package/dist/types.d.ts +19 -0
- package/dist/util/helper.d.ts +64 -0
- package/dist/util/s3Upload.d.ts +13 -0
- package/dist/util/stepperComponents.d.ts +6 -0
- package/dist/util/useIsFirstRender.d.ts +1 -0
- package/dist/util/useUpdateEffect.d.ts +2 -0
- package/dist/util/validation.d.ts +6 -0
- package/package.json +65 -54
- package/build/asset-manifest.json +0 -10
- package/build/favicon.ico +0 -0
- package/build/index.html +0 -1
- package/build/logo192.png +0 -0
- package/build/logo512.png +0 -0
- package/build/manifest.json +0 -25
- package/build/robots.txt +0 -3
- package/build/static/js/main.11a67c51.js +0 -3
- package/build/static/js/main.11a67c51.js.LICENSE.txt +0 -85
- package/build/static/js/main.11a67c51.js.map +0 -1
- package/craco.config.js +0 -34
- package/dist-modules/components/DynamicComponent.js +0 -22
- package/dist-modules/components/FormGenerator.js +0 -200
- package/dist-modules/components/charts/Bar/bar.js +0 -31
- package/dist-modules/components/charts/Line/line.js +0 -31
- package/dist-modules/components/charts/Mixchart/mixChart.js +0 -59
- package/dist-modules/components/charts/Pie/pie.js +0 -31
- package/dist-modules/components/controls/CheckBox/checkbox.js +0 -56
- package/dist-modules/components/controls/DataTable/datatable.js +0 -28
- package/dist-modules/components/controls/DateTime/datetime.js +0 -53
- package/dist-modules/components/controls/DateTimePicker/datetimepicker.js +0 -53
- package/dist-modules/components/controls/Radio/radio.js +0 -88
- package/dist-modules/components/controls/Select/select.js +0 -173
- package/dist-modules/components/controls/Stepper/stepper.js +0 -192
- package/dist-modules/components/controls/Switch/switch.js +0 -85
- package/dist-modules/components/controls/TextField/textfield.js +0 -148
- package/dist-modules/components/controls/TimePicker/timepicker.js +0 -53
- package/dist-modules/components/controls/Typography/typography.js +0 -43
- package/dist-modules/components/controls/index.js +0 -42
- package/dist-modules/config/mui.js +0 -73
- package/dist-modules/data/checkbox.js +0 -143
- package/dist-modules/data/dataTable.js +0 -90
- package/dist-modules/data/dateTime.js +0 -136
- package/dist-modules/data/radio.js +0 -36
- package/dist-modules/data/select.js +0 -126
- package/dist-modules/data/stepper.js +0 -237
- package/dist-modules/data/switch.js +0 -123
- package/dist-modules/data/textfield.js +0 -240
- package/dist-modules/index.js +0 -16
- package/dist-modules/util/helper.js +0 -226
- package/dist-modules/util/stepperComponents.js +0 -40
- package/dist-modules/util/useIsFirstRender.js +0 -15
- package/dist-modules/util/useUpdateEffect.js +0 -19
- package/dist-modules/util/validation.js +0 -102
- package/docs/asset-manifest.json +0 -9
- package/docs/build/bundle.1eab2706.js +0 -2
- package/docs/build/bundle.1eab2706.js.LICENSE.txt +0 -153
- package/docs/index.html +0 -16
- package/public/favicon.ico +0 -0
- package/public/index.html +0 -43
- package/public/logo192.png +0 -0
- package/public/logo512.png +0 -0
- package/public/manifest.json +0 -25
- package/public/robots.txt +0 -3
- package/styleguide.config.js +0 -108
- package/themes/default.js +0 -114
- package/themes/index.js +0 -29
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = Radio;
|
|
7
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
-
var _Radio = _interopRequireDefault(require("@mui/material/Radio"));
|
|
10
|
-
var _Box = _interopRequireDefault(require("@mui/material/Box"));
|
|
11
|
-
var _RadioGroup = _interopRequireDefault(require("@mui/material/RadioGroup"));
|
|
12
|
-
var _FormControlLabel = _interopRequireDefault(require("@mui/material/FormControlLabel"));
|
|
13
|
-
var _FormControl = _interopRequireDefault(require("@mui/material/FormControl"));
|
|
14
|
-
var _FormLabel = _interopRequireDefault(require("@mui/material/FormLabel"));
|
|
15
|
-
var _material = require("@mui/material");
|
|
16
|
-
var _useUpdateEffect = _interopRequireDefault(require("../../../util/useUpdateEffect"));
|
|
17
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
18
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
19
|
-
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
20
|
-
/** Radio Component */
|
|
21
|
-
function Radio(_ref) {
|
|
22
|
-
let {
|
|
23
|
-
attributes,
|
|
24
|
-
onChange
|
|
25
|
-
} = _ref;
|
|
26
|
-
const {
|
|
27
|
-
MuiAttributes = {},
|
|
28
|
-
MuiFCLAttributes = {},
|
|
29
|
-
MuiRGAttributes = {},
|
|
30
|
-
id = '',
|
|
31
|
-
MuiFLAttributes = {},
|
|
32
|
-
MuiFCLabels = [],
|
|
33
|
-
MuiFLabel = '',
|
|
34
|
-
MuiFLabelIcon = {}
|
|
35
|
-
} = attributes;
|
|
36
|
-
const [value, setValue] = _react.default.useState('');
|
|
37
|
-
(0, _react.useEffect)(() => {
|
|
38
|
-
if (attributes.value || MuiAttributes.defaultValue) setValue(attributes.value || MuiAttributes.defaultValue);
|
|
39
|
-
}, []);
|
|
40
|
-
(0, _useUpdateEffect.default)(() => {
|
|
41
|
-
setValue(attributes.value);
|
|
42
|
-
}, [attributes.value]);
|
|
43
|
-
const handleChange = event => {
|
|
44
|
-
setValue(event.target.value);
|
|
45
|
-
onChange({
|
|
46
|
-
id,
|
|
47
|
-
value: event.target.value
|
|
48
|
-
});
|
|
49
|
-
};
|
|
50
|
-
const FLabel = (0, _react.useMemo)(() => {
|
|
51
|
-
if (MuiFLabelIcon && MuiFLabelIcon.icon) {
|
|
52
|
-
return /*#__PURE__*/_react.default.createElement(_Box.default, {
|
|
53
|
-
sx: {
|
|
54
|
-
display: 'flex',
|
|
55
|
-
width: '100%'
|
|
56
|
-
}
|
|
57
|
-
}, MuiFLabelIcon && MuiFLabelIcon.icon && /*#__PURE__*/_react.default.createElement(_material.Icon, _extends({
|
|
58
|
-
key: MuiFLabelIcon.icon
|
|
59
|
-
}, MuiFLabelIcon.MuiFLabelIconAttributes), MuiFLabelIcon.icon), /*#__PURE__*/_react.default.createElement(_FormLabel.default, _extends({}, MuiFLAttributes, {
|
|
60
|
-
id: "radio-buttons-group-label"
|
|
61
|
-
}), MuiFLabel));
|
|
62
|
-
}
|
|
63
|
-
return /*#__PURE__*/_react.default.createElement(_FormLabel.default, _extends({}, MuiFLAttributes, {
|
|
64
|
-
id: "radio-buttons-group-label"
|
|
65
|
-
}), MuiFLabel);
|
|
66
|
-
}, []);
|
|
67
|
-
return /*#__PURE__*/_react.default.createElement(_FormControl.default, null, MuiFLabel && FLabel, /*#__PURE__*/_react.default.createElement(_RadioGroup.default, _extends({
|
|
68
|
-
"aria-labelledby": "radio-buttons-group-label",
|
|
69
|
-
name: "radio-buttons-group"
|
|
70
|
-
}, MuiRGAttributes, {
|
|
71
|
-
value: value,
|
|
72
|
-
onChange: handleChange
|
|
73
|
-
}), MuiFCLabels.map(label => /*#__PURE__*/_react.default.createElement(_FormControlLabel.default, _extends({}, MuiFCLAttributes, {
|
|
74
|
-
value: label,
|
|
75
|
-
control: /*#__PURE__*/_react.default.createElement(_Radio.default, MuiAttributes),
|
|
76
|
-
label: label
|
|
77
|
-
})))));
|
|
78
|
-
}
|
|
79
|
-
Radio.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
80
|
-
/** Attributes for Radio */
|
|
81
|
-
attributes: _propTypes.default.objectOf(_propTypes.default.object),
|
|
82
|
-
/** Function */
|
|
83
|
-
onChange: _propTypes.default.func
|
|
84
|
-
} : {};
|
|
85
|
-
Radio.defaultProps = {
|
|
86
|
-
attributes: {},
|
|
87
|
-
onChange: null
|
|
88
|
-
};
|
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = Select;
|
|
7
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
-
var _Checkbox = _interopRequireDefault(require("@mui/material/Checkbox"));
|
|
9
|
-
var _TextField = _interopRequireDefault(require("@mui/material/TextField"));
|
|
10
|
-
var _Autocomplete = _interopRequireDefault(require("@mui/material/Autocomplete"));
|
|
11
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
12
|
-
var _CheckBoxOutlineBlank = _interopRequireDefault(require("@mui/icons-material/CheckBoxOutlineBlank"));
|
|
13
|
-
var _CheckBox = _interopRequireDefault(require("@mui/icons-material/CheckBox"));
|
|
14
|
-
var _helper = require("../../../util/helper");
|
|
15
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
17
|
-
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
18
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
19
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
20
|
-
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
21
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
22
|
-
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /* eslint-disable default-param-last,react/jsx-no-duplicate-props */
|
|
23
|
-
const icon = /*#__PURE__*/_react.default.createElement(_CheckBoxOutlineBlank.default, {
|
|
24
|
-
fontSize: "small"
|
|
25
|
-
});
|
|
26
|
-
const checkedIcon = /*#__PURE__*/_react.default.createElement(_CheckBox.default, {
|
|
27
|
-
fontSize: "small"
|
|
28
|
-
});
|
|
29
|
-
const getValue = function () {
|
|
30
|
-
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
31
|
-
let defaultValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
32
|
-
let isMultiple = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
33
|
-
let separator = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : ',';
|
|
34
|
-
try {
|
|
35
|
-
const safeOptions = Array.isArray(options) ? options : [];
|
|
36
|
-
if (isMultiple) {
|
|
37
|
-
let values = [];
|
|
38
|
-
if (Array.isArray(defaultValue)) {
|
|
39
|
-
values = defaultValue;
|
|
40
|
-
} else if (typeof defaultValue === 'string' && defaultValue.trim() !== '') {
|
|
41
|
-
let tempSeparator = separator;
|
|
42
|
-
if (defaultValue.includes(',')) tempSeparator = ',';else if (defaultValue.includes(';')) tempSeparator = ';';
|
|
43
|
-
values = defaultValue.split(tempSeparator).map(v => v.trim());
|
|
44
|
-
}
|
|
45
|
-
const dValueSet = new Set(values);
|
|
46
|
-
return safeOptions.filter(_ref => {
|
|
47
|
-
let {
|
|
48
|
-
value
|
|
49
|
-
} = _ref;
|
|
50
|
-
return dValueSet.has(value);
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
if (Array.isArray(defaultValue)) {
|
|
54
|
-
const first = defaultValue[0];
|
|
55
|
-
return safeOptions.find(_ref2 => {
|
|
56
|
-
let {
|
|
57
|
-
value
|
|
58
|
-
} = _ref2;
|
|
59
|
-
return value === first;
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
return safeOptions.find(_ref3 => {
|
|
63
|
-
let {
|
|
64
|
-
value
|
|
65
|
-
} = _ref3;
|
|
66
|
-
return value === defaultValue;
|
|
67
|
-
});
|
|
68
|
-
} catch (err) {
|
|
69
|
-
// eslint-disable-next-line no-console
|
|
70
|
-
console.error('getValue error:', err);
|
|
71
|
-
return isMultiple ? [] : null;
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
function Select(_ref4) {
|
|
75
|
-
let {
|
|
76
|
-
attributes,
|
|
77
|
-
onChange
|
|
78
|
-
} = _ref4;
|
|
79
|
-
const {
|
|
80
|
-
MuiAttributes = {},
|
|
81
|
-
options = [],
|
|
82
|
-
MuiBoxAttributes = {},
|
|
83
|
-
id = '',
|
|
84
|
-
InputProps = {}
|
|
85
|
-
} = attributes;
|
|
86
|
-
const [value, setValue] = _react.default.useState((attributes === null || attributes === void 0 ? void 0 : attributes.value) && getValue(options, attributes === null || attributes === void 0 ? void 0 : attributes.value, MuiAttributes.multiple, attributes === null || attributes === void 0 ? void 0 : attributes.separator));
|
|
87
|
-
const getMuiAttributes = () => {
|
|
88
|
-
if (MuiAttributes.multiple) {
|
|
89
|
-
MuiAttributes.renderOption = function (props) {
|
|
90
|
-
let option = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
91
|
-
let {
|
|
92
|
-
selected
|
|
93
|
-
} = arguments.length > 2 ? arguments[2] : undefined;
|
|
94
|
-
return /*#__PURE__*/_react.default.createElement("li", props, /*#__PURE__*/_react.default.createElement(_Checkbox.default, {
|
|
95
|
-
icon: icon,
|
|
96
|
-
checkedIcon: checkedIcon,
|
|
97
|
-
style: {
|
|
98
|
-
marginRight: 8
|
|
99
|
-
},
|
|
100
|
-
checked: selected,
|
|
101
|
-
sx: (0, _helper.checkboxSX)(option.color || '')
|
|
102
|
-
}), option.title || option.label || option.value);
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
return MuiAttributes;
|
|
106
|
-
};
|
|
107
|
-
const extractValue = option => (option === null || option === void 0 ? void 0 : option.value) || (option === null || option === void 0 ? void 0 : option.title) || (option === null || option === void 0 ? void 0 : option.label);
|
|
108
|
-
const onChangeEvent = (0, _react.useCallback)((event, newValue) => {
|
|
109
|
-
var _attributes$separator;
|
|
110
|
-
setValue(newValue);
|
|
111
|
-
|
|
112
|
-
// Use attributes?.separator, default to ';'
|
|
113
|
-
const separator = (_attributes$separator = attributes === null || attributes === void 0 ? void 0 : attributes.separator) !== null && _attributes$separator !== void 0 ? _attributes$separator : ';';
|
|
114
|
-
if (newValue) {
|
|
115
|
-
const data = MuiAttributes.multiple ? newValue.map(extractValue) : extractValue(newValue);
|
|
116
|
-
const customValue = MuiAttributes.multiple ? data.join(separator) // <-- use custom separator here
|
|
117
|
-
: data;
|
|
118
|
-
onChange({
|
|
119
|
-
id,
|
|
120
|
-
value: customValue,
|
|
121
|
-
option: newValue
|
|
122
|
-
});
|
|
123
|
-
} else {
|
|
124
|
-
onChange({
|
|
125
|
-
id,
|
|
126
|
-
value: '',
|
|
127
|
-
option: newValue
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
}, [id, onChange, attributes === null || attributes === void 0 ? void 0 : attributes.separator,
|
|
131
|
-
// so changes to separator update the callback
|
|
132
|
-
MuiAttributes.multiple, extractValue]);
|
|
133
|
-
return /*#__PURE__*/_react.default.createElement(_Autocomplete.default, _extends({
|
|
134
|
-
disablePortal: false
|
|
135
|
-
}, getMuiAttributes(), {
|
|
136
|
-
options: options,
|
|
137
|
-
value: value,
|
|
138
|
-
onChange: onChangeEvent,
|
|
139
|
-
PopperProps: {
|
|
140
|
-
modifiers: [{
|
|
141
|
-
name: 'preventOverflow',
|
|
142
|
-
options: {
|
|
143
|
-
boundary: 'window'
|
|
144
|
-
}
|
|
145
|
-
}]
|
|
146
|
-
},
|
|
147
|
-
renderInput: params => {
|
|
148
|
-
// Ensure custom adornments are incorporated without overriding other essential props
|
|
149
|
-
const customInputProps = (0, _helper.getInputProps)(InputProps);
|
|
150
|
-
const mergedInputProps = _objectSpread(_objectSpread(_objectSpread({}, params.InputProps), customInputProps), {}, {
|
|
151
|
-
startAdornment: /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, customInputProps === null || customInputProps === void 0 ? void 0 : customInputProps.startAdornment, params.InputProps.startAdornment, " "),
|
|
152
|
-
endAdornment: /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, customInputProps === null || customInputProps === void 0 ? void 0 : customInputProps.endAdornment, params.InputProps.endAdornment)
|
|
153
|
-
});
|
|
154
|
-
return /*#__PURE__*/_react.default.createElement(_TextField.default, _extends({}, params, MuiBoxAttributes, {
|
|
155
|
-
slotProps: {
|
|
156
|
-
input: _objectSpread(_objectSpread({}, mergedInputProps), {}, {
|
|
157
|
-
autoComplete: 'new-password'
|
|
158
|
-
})
|
|
159
|
-
}
|
|
160
|
-
}));
|
|
161
|
-
}
|
|
162
|
-
}));
|
|
163
|
-
}
|
|
164
|
-
Select.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
165
|
-
/** Attributes for Select */
|
|
166
|
-
attributes: _propTypes.default.objectOf(_propTypes.default.object),
|
|
167
|
-
/** Function */
|
|
168
|
-
onChange: _propTypes.default.func
|
|
169
|
-
} : {};
|
|
170
|
-
Select.defaultProps = {
|
|
171
|
-
attributes: {},
|
|
172
|
-
onChange: null
|
|
173
|
-
};
|
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
-
var _material = require("@mui/material");
|
|
10
|
-
var _stepperComponents = _interopRequireDefault(require("../../../util/stepperComponents"));
|
|
11
|
-
var _helper = require("../../../util/helper");
|
|
12
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
14
|
-
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
15
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
16
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
17
|
-
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
18
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
19
|
-
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } // eslint-disable-next-line import/no-cycle
|
|
20
|
-
// Initial State
|
|
21
|
-
const initialState = {
|
|
22
|
-
activeStep: 0,
|
|
23
|
-
stepperResponse: {},
|
|
24
|
-
MuiSteps: []
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
// Reducer Logic
|
|
28
|
-
const reducer = (state, action) => {
|
|
29
|
-
const {
|
|
30
|
-
type,
|
|
31
|
-
payload
|
|
32
|
-
} = action;
|
|
33
|
-
switch (type) {
|
|
34
|
-
case 'SET_STEPS':
|
|
35
|
-
return _objectSpread(_objectSpread({}, state), {}, {
|
|
36
|
-
MuiSteps: payload.MuiSteps
|
|
37
|
-
});
|
|
38
|
-
case 'SET_STEP':
|
|
39
|
-
return _objectSpread(_objectSpread({}, state), {}, {
|
|
40
|
-
activeStep: payload.currentStep
|
|
41
|
-
});
|
|
42
|
-
case 'UPDATE_RESPONSE':
|
|
43
|
-
return _objectSpread(_objectSpread({}, state), {}, {
|
|
44
|
-
stepperResponse: _objectSpread(_objectSpread({}, state.stepperResponse), {}, {
|
|
45
|
-
[payload.id]: payload.value
|
|
46
|
-
})
|
|
47
|
-
});
|
|
48
|
-
case 'CHANGE_STEP':
|
|
49
|
-
return _objectSpread(_objectSpread({}, state), {}, {
|
|
50
|
-
activeStep: state.activeStep + payload.stepChange
|
|
51
|
-
});
|
|
52
|
-
default:
|
|
53
|
-
return state;
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
function Stepper(_ref) {
|
|
57
|
-
let {
|
|
58
|
-
attributes,
|
|
59
|
-
onChange,
|
|
60
|
-
onStepUpdate,
|
|
61
|
-
currentStep,
|
|
62
|
-
patch
|
|
63
|
-
} = _ref;
|
|
64
|
-
const [state, dispatch] = (0, _react.useReducer)(reducer, initialState, () => ({
|
|
65
|
-
activeStep: currentStep,
|
|
66
|
-
stepperResponse: patch,
|
|
67
|
-
MuiSteps: attributes.MuiSteps || []
|
|
68
|
-
}));
|
|
69
|
-
const {
|
|
70
|
-
activeStep,
|
|
71
|
-
stepperResponse,
|
|
72
|
-
MuiSteps
|
|
73
|
-
} = state;
|
|
74
|
-
(0, _react.useEffect)(() => {
|
|
75
|
-
dispatch({
|
|
76
|
-
type: 'SET_STEP',
|
|
77
|
-
payload: {
|
|
78
|
-
currentStep
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
}, [currentStep]);
|
|
82
|
-
const handleStepChange = (0, _react.useCallback)((stepChange, isScreenChange, isLastStep) => {
|
|
83
|
-
dispatch({
|
|
84
|
-
type: 'CHANGE_STEP',
|
|
85
|
-
payload: {
|
|
86
|
-
stepChange
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
const newStep = activeStep + stepChange;
|
|
90
|
-
onStepUpdate === null || onStepUpdate === void 0 || onStepUpdate(newStep, isScreenChange && stepChange > 0, isLastStep);
|
|
91
|
-
if (isLastStep) {
|
|
92
|
-
onChange === null || onChange === void 0 || onChange({
|
|
93
|
-
id: attributes.id,
|
|
94
|
-
value: stepperResponse
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
}, [activeStep, attributes.id, onChange, onStepUpdate, stepperResponse]);
|
|
98
|
-
const handleUpdate = (0, _react.useCallback)(_ref2 => {
|
|
99
|
-
let {
|
|
100
|
-
id,
|
|
101
|
-
value
|
|
102
|
-
} = _ref2;
|
|
103
|
-
dispatch({
|
|
104
|
-
type: 'UPDATE_RESPONSE',
|
|
105
|
-
payload: {
|
|
106
|
-
id,
|
|
107
|
-
value
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
onChange === null || onChange === void 0 || onChange({
|
|
111
|
-
id,
|
|
112
|
-
value
|
|
113
|
-
});
|
|
114
|
-
}, [onChange]);
|
|
115
|
-
const isDisabled = function () {
|
|
116
|
-
let mandatoryIds = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
117
|
-
let optionalMandatoryIds = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
118
|
-
return mandatoryIds.some(id => !stepperResponse[id]) || optionalMandatoryIds.some(item => stepperResponse[item.key] === item.value && item.mandatoryIds.some(id => !stepperResponse[id]));
|
|
119
|
-
};
|
|
120
|
-
const renderButtons = (index, isScreenChange, mandatoryIds, optionalMandatoryIds) => /*#__PURE__*/_react.default.createElement(_material.Box, {
|
|
121
|
-
sx: {
|
|
122
|
-
mb: 2
|
|
123
|
-
}
|
|
124
|
-
}, /*#__PURE__*/_react.default.createElement(_material.Button, _extends({
|
|
125
|
-
variant: "contained",
|
|
126
|
-
onClick: () => handleStepChange(1, isScreenChange, index === MuiSteps.length - 1),
|
|
127
|
-
disabled: isDisabled(mandatoryIds, optionalMandatoryIds),
|
|
128
|
-
sx: {
|
|
129
|
-
mt: 1,
|
|
130
|
-
mr: 1
|
|
131
|
-
}
|
|
132
|
-
}, attributes.MuiButtonAttributes.next, index === MuiSteps.length - 1 && _objectSpread({}, attributes.MuiButtonAttributes.final)), index === MuiSteps.length - 1 ? 'Finish' : 'Continue'), /*#__PURE__*/_react.default.createElement(_material.Button, _extends({
|
|
133
|
-
disabled: index === 0,
|
|
134
|
-
onClick: () => handleStepChange(-1, isScreenChange, false),
|
|
135
|
-
sx: {
|
|
136
|
-
mt: 1,
|
|
137
|
-
mr: 1
|
|
138
|
-
}
|
|
139
|
-
}, attributes.MuiButtonAttributes.back), "Back"));
|
|
140
|
-
return /*#__PURE__*/_react.default.createElement(_material.Box, _extends({
|
|
141
|
-
sx: {
|
|
142
|
-
maxWidth: 400
|
|
143
|
-
}
|
|
144
|
-
}, attributes.MuiBoxAttributes), /*#__PURE__*/_react.default.createElement(_material.Stepper, _extends({
|
|
145
|
-
activeStep: activeStep,
|
|
146
|
-
orientation: "vertical"
|
|
147
|
-
}, attributes.MuiStepperAttributes), MuiSteps.map((step, index) => /*#__PURE__*/_react.default.createElement(_material.Step, _extends({
|
|
148
|
-
key: step.label
|
|
149
|
-
}, attributes.MuiStepAttributes), /*#__PURE__*/_react.default.createElement(_material.StepLabel, _extends({
|
|
150
|
-
optional: index === MuiSteps.length - 1 && /*#__PURE__*/_react.default.createElement(_material.Typography, {
|
|
151
|
-
variant: "caption"
|
|
152
|
-
}, "Last step")
|
|
153
|
-
}, attributes.MuiStepLabelAttributes), step.label), /*#__PURE__*/_react.default.createElement(_material.StepContent, attributes.MuiStepContentAttributes, step.components ? /*#__PURE__*/_react.default.createElement(_stepperComponents.default, {
|
|
154
|
-
onUpdate: handleUpdate,
|
|
155
|
-
components: (0, _helper.updatePatchData)(step.components, stepperResponse, '', {}, step.enableDisableIds)
|
|
156
|
-
}) : /*#__PURE__*/_react.default.createElement(_material.Typography, null, step.description), renderButtons(index, step.isScreenChange, step.mandatoryIds, step.optionalMandatoryIds))))));
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
// PropTypes Definition
|
|
160
|
-
Stepper.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
161
|
-
attributes: _propTypes.default.shape({
|
|
162
|
-
id: _propTypes.default.string.isRequired,
|
|
163
|
-
MuiSteps: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
164
|
-
label: _propTypes.default.string.isRequired,
|
|
165
|
-
description: _propTypes.default.string,
|
|
166
|
-
isScreenChange: _propTypes.default.bool,
|
|
167
|
-
components: _propTypes.default.array,
|
|
168
|
-
mandatoryIds: _propTypes.default.array,
|
|
169
|
-
optionalMandatoryIds: _propTypes.default.array
|
|
170
|
-
})).isRequired,
|
|
171
|
-
MuiButtonAttributes: _propTypes.default.object,
|
|
172
|
-
MuiBoxAttributes: _propTypes.default.object,
|
|
173
|
-
MuiStepperAttributes: _propTypes.default.object,
|
|
174
|
-
MuiStepAttributes: _propTypes.default.object,
|
|
175
|
-
MuiStepLabelAttributes: _propTypes.default.object,
|
|
176
|
-
MuiStepContentAttributes: _propTypes.default.object
|
|
177
|
-
}),
|
|
178
|
-
onChange: _propTypes.default.func,
|
|
179
|
-
onStepUpdate: _propTypes.default.func,
|
|
180
|
-
currentStep: _propTypes.default.number,
|
|
181
|
-
patch: _propTypes.default.object
|
|
182
|
-
} : {};
|
|
183
|
-
|
|
184
|
-
// Default Props
|
|
185
|
-
Stepper.defaultProps = {
|
|
186
|
-
attributes: {},
|
|
187
|
-
onChange: () => {},
|
|
188
|
-
onStepUpdate: () => {},
|
|
189
|
-
currentStep: 0,
|
|
190
|
-
patch: {}
|
|
191
|
-
};
|
|
192
|
-
var _default = exports.default = Stepper;
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = Switch;
|
|
7
|
-
var _react = _interopRequireDefault(require("react"));
|
|
8
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
-
var _Switch = _interopRequireDefault(require("@mui/material/Switch"));
|
|
10
|
-
var _FormControlLabel = _interopRequireDefault(require("@mui/material/FormControlLabel"));
|
|
11
|
-
var _styles = require("@mui/material/styles");
|
|
12
|
-
var _useUpdateEffect = _interopRequireDefault(require("../../../util/useUpdateEffect"));
|
|
13
|
-
const _excluded = ["color"];
|
|
14
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
|
-
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
16
|
-
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
17
|
-
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
18
|
-
const ColorSwitch = (0, _styles.styled)(_ref => {
|
|
19
|
-
let {
|
|
20
|
-
color
|
|
21
|
-
} = _ref,
|
|
22
|
-
other = _objectWithoutProperties(_ref, _excluded);
|
|
23
|
-
return /*#__PURE__*/_react.default.createElement(_Switch.default, other);
|
|
24
|
-
})(_ref2 => {
|
|
25
|
-
let {
|
|
26
|
-
theme
|
|
27
|
-
} = _ref2;
|
|
28
|
-
return {
|
|
29
|
-
'& .MuiSwitch-switchBase.Mui-checked': {
|
|
30
|
-
color: props => props.color || 'green',
|
|
31
|
-
'&:hover': {
|
|
32
|
-
backgroundColor: props => (0, _styles.alpha)(props.color || 'green', theme.palette.action.hoverOpacity)
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
'& .MuiSwitch-switchBase.Mui-checked + .MuiSwitch-track': {
|
|
36
|
-
backgroundColor: props => props.color || 'green'
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
/** Switch Component */
|
|
42
|
-
function Switch(_ref3) {
|
|
43
|
-
let {
|
|
44
|
-
attributes,
|
|
45
|
-
onChange
|
|
46
|
-
} = _ref3;
|
|
47
|
-
const {
|
|
48
|
-
MuiAttributes = {},
|
|
49
|
-
MuiFCLAttributes = {},
|
|
50
|
-
color = '',
|
|
51
|
-
id = ''
|
|
52
|
-
} = attributes;
|
|
53
|
-
const [checked, setChecked] = _react.default.useState(MuiAttributes.defaultValue || attributes.value || false);
|
|
54
|
-
(0, _useUpdateEffect.default)(() => {
|
|
55
|
-
setChecked(attributes.value);
|
|
56
|
-
}, [attributes.value]);
|
|
57
|
-
const handleChange = event => {
|
|
58
|
-
setChecked(event.target.checked);
|
|
59
|
-
onChange({
|
|
60
|
-
id,
|
|
61
|
-
value: event.target.checked
|
|
62
|
-
});
|
|
63
|
-
};
|
|
64
|
-
const MSwitch = color ? ColorSwitch : _Switch.default;
|
|
65
|
-
return /*#__PURE__*/_react.default.createElement(_FormControlLabel.default, _extends({}, MuiFCLAttributes, {
|
|
66
|
-
control: /*#__PURE__*/_react.default.createElement(MSwitch, _extends({
|
|
67
|
-
checked: checked,
|
|
68
|
-
onChange: handleChange
|
|
69
|
-
}, MuiAttributes, {
|
|
70
|
-
inputProps: {
|
|
71
|
-
'aria-label': 'controlled'
|
|
72
|
-
}
|
|
73
|
-
}))
|
|
74
|
-
}));
|
|
75
|
-
}
|
|
76
|
-
Switch.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
77
|
-
/** Attributes for Switch */
|
|
78
|
-
attributes: _propTypes.default.objectOf(_propTypes.default.object),
|
|
79
|
-
/** Function */
|
|
80
|
-
onChange: _propTypes.default.func
|
|
81
|
-
} : {};
|
|
82
|
-
Switch.defaultProps = {
|
|
83
|
-
attributes: {},
|
|
84
|
-
onChange: null
|
|
85
|
-
};
|