dynamic-mui 1.0.35 → 1.0.37

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.
@@ -8,6 +8,7 @@ var _react = _interopRequireDefault(require("react"));
8
8
  var _propTypes = _interopRequireDefault(require("prop-types"));
9
9
  var _Checkbox = _interopRequireDefault(require("@mui/material/Checkbox"));
10
10
  var _FormControlLabel = _interopRequireDefault(require("@mui/material/FormControlLabel"));
11
+ var _useUpdateEffect = _interopRequireDefault(require("../../../util/useUpdateEffect"));
11
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
13
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
13
14
  /** CheckBox Component */
@@ -22,6 +23,9 @@ function CheckBox(_ref) {
22
23
  id = ''
23
24
  } = attributes;
24
25
  const [checked, setChecked] = _react.default.useState(MuiAttributes.defaultChecked || (attributes === null || attributes === void 0 ? void 0 : attributes.value) || false);
26
+ (0, _useUpdateEffect.default)(() => {
27
+ setChecked(attributes.value);
28
+ }, [attributes.value]);
25
29
  const handleChange = event => {
26
30
  setChecked(event.target.checked);
27
31
  onChange({
@@ -82,11 +82,17 @@ function Select(_ref2) {
82
82
 
83
83
  const onChangeEvent = (0, _react.useCallback)((event, newValue) => {
84
84
  setValue(newValue);
85
- const data = MuiAttributes.multiple ? (newValue || []).map(option => option.title || option.label || option.value) : newValue.title || newValue.label || newValue.value;
86
- onChange({
85
+ if (newValue) {
86
+ const data = MuiAttributes.multiple ? (newValue || []).map(option => (option === null || option === void 0 ? void 0 : option.title) || (option === null || option === void 0 ? void 0 : option.label) || (option === null || option === void 0 ? void 0 : option.value)) : (newValue === null || newValue === void 0 ? void 0 : newValue.title) || (newValue === null || newValue === void 0 ? void 0 : newValue.label) || (newValue === null || newValue === void 0 ? void 0 : newValue.value);
87
+ onChange({
88
+ id,
89
+ value: data,
90
+ option: newValue
91
+ });
92
+ } else onChange({
87
93
  id,
88
- value: data,
89
- option: newValue
94
+ value: '',
95
+ options: newValue
90
96
  });
91
97
  }, []);
92
98
  return /*#__PURE__*/_react.default.createElement(_Autocomplete.default, _extends({}, getMuiAttributes(), {
@@ -9,6 +9,7 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
9
9
  var _Switch = _interopRequireDefault(require("@mui/material/Switch"));
10
10
  var _FormControlLabel = _interopRequireDefault(require("@mui/material/FormControlLabel"));
11
11
  var _styles = require("@mui/material/styles");
12
+ var _useUpdateEffect = _interopRequireDefault(require("../../../util/useUpdateEffect"));
12
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
14
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
14
15
  const ColorSwitch = (0, _styles.experimentalStyled)(_ref => {
@@ -46,7 +47,10 @@ function Switch(_ref3) {
46
47
  color = '',
47
48
  id = ''
48
49
  } = attributes;
49
- const [checked, setChecked] = _react.default.useState(MuiAttributes.defaultChecked || false);
50
+ const [checked, setChecked] = _react.default.useState(MuiAttributes.defaultValue || (attributes === null || attributes === void 0 ? void 0 : attributes.value) || false);
51
+ (0, _useUpdateEffect.default)(() => {
52
+ setChecked(attributes.value);
53
+ }, [attributes.value]);
50
54
  const handleChange = event => {
51
55
  setChecked(event.target.checked);
52
56
  onChange({
@@ -72,9 +72,8 @@ const checkBoxCustom = exports.checkBoxCustom = [{
72
72
  type: 'checkbox',
73
73
  props: {
74
74
  id: 'label',
75
- MuiAttributes: {
76
- defaultChecked: true
77
- },
75
+ value: true,
76
+ MuiAttributes: {},
78
77
  MuiFCLAttributes: {
79
78
  label: 'Label'
80
79
  }
@@ -8,9 +8,8 @@ const switchData = exports.switchData = [{
8
8
  type: 'switch',
9
9
  props: {
10
10
  id: 'switchdefault',
11
- MuiAttributes: {
12
- defaultChecked: true
13
- },
11
+ value: true,
12
+ MuiAttributes: {},
14
13
  MuiFCLAttributes: {
15
14
  label: ''
16
15
  }
@@ -24,6 +23,7 @@ const switchData = exports.switchData = [{
24
23
  type: 'switch',
25
24
  props: {
26
25
  id: 'switch',
26
+ value: true,
27
27
  MuiAttributes: {},
28
28
  MuiFCLAttributes: {
29
29
  label: ''
@@ -38,6 +38,7 @@ const switchData = exports.switchData = [{
38
38
  type: 'switch',
39
39
  props: {
40
40
  id: 'switchdisabled',
41
+ value: true,
41
42
  MuiAttributes: {
42
43
  disabled: true
43
44
  },
@@ -106,8 +107,8 @@ const switchCustom = exports.switchCustom = [{
106
107
  type: 'switch',
107
108
  props: {
108
109
  id: 'switchlabelcolor',
110
+ value: true,
109
111
  MuiAttributes: {
110
- defaultChecked: true,
111
112
  color: 'default'
112
113
  },
113
114
  MuiFCLAttributes: {
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "files": {
3
- "main.js": "/DinakaranS/-dynamic-mui/build/main.523b831f.js",
3
+ "main.js": "/DinakaranS/-dynamic-mui/build/main.5b2b2fe7.js",
4
4
  "runtime-main.js": "/DinakaranS/-dynamic-mui/build/bundle.2d61df25.js",
5
- "build/2.7567d890.js": "/DinakaranS/-dynamic-mui/build/2.7567d890.js",
6
- "build/2.7567d890.js.LICENSE.txt": "/DinakaranS/-dynamic-mui/build/2.7567d890.js.LICENSE.txt",
5
+ "build/2.8784a577.js": "/DinakaranS/-dynamic-mui/build/2.8784a577.js",
6
+ "build/2.8784a577.js.LICENSE.txt": "/DinakaranS/-dynamic-mui/build/2.8784a577.js.LICENSE.txt",
7
7
  "index.html": "/DinakaranS/-dynamic-mui/index.html"
8
8
  },
9
9
  "entrypoints": [
10
10
  "build/bundle.2d61df25.js",
11
- "build/2.7567d890.js",
12
- "build/main.523b831f.js"
11
+ "build/2.8784a577.js",
12
+ "build/main.5b2b2fe7.js"
13
13
  ]
14
14
  }