dynamic-mui 1.0.84 → 1.0.85

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/craco.config.js CHANGED
@@ -1,33 +1,34 @@
1
- // craco.config.js
1
+ /// /////////////////////////////////////////////////////////////////////////
2
+ //
3
+ // Copyright 2023 Realm Inc.
4
+ //
5
+ // Licensed under the Apache License, Version 2.0 (the "License");
6
+ // you may not use this file except in compliance with the License.
7
+ // You may obtain a copy of the License at
8
+ //
9
+ // http://www.apache.org/licenses/LICENSE-2.0
10
+ //
11
+ // Unless required by applicable law or agreed to in writing, software
12
+ // distributed under the License is distributed on an "AS IS" BASIS,
13
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ // See the License for the specific language governing permissions and
15
+ // limitations under the License.
16
+ //
17
+ /// /////////////////////////////////////////////////////////////////////////
18
+
2
19
  module.exports = {
3
20
  webpack: {
4
21
  configure(config) {
22
+ const experiments = {
23
+ ...config.experiments,
24
+ topLevelAwait: true,
25
+ };
26
+
5
27
  return {
6
28
  ...config,
7
- experiments: {
8
- ...config.experiments,
9
- topLevelAwait: true,
10
- },
29
+ experiments,
11
30
  };
12
31
  },
13
32
  alias: {},
14
33
  },
15
-
16
- eslint: {
17
- enable: true,
18
- mode: 'extends',
19
- configure: {
20
- extends: [
21
- 'react-app', // CRA’s built-in rules
22
- 'airbnb', // your Airbnb overrides
23
- 'prettier', // disables any conflicts with Prettier
24
- ],
25
- // you can omit the `plugins` array entirely—ESLint will load
26
- // all the plugins that react-app already configures
27
- rules: {
28
- 'react/react-in-jsx-scope': 'off',
29
- 'prettier/prettier': 'error',
30
- },
31
- },
32
- },
33
34
  };
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = MixChart;
7
7
  var React = _interopRequireWildcard(require("react"));
8
8
  var _Box = _interopRequireDefault(require("@mui/material/Box"));
9
- var _ChartContainer = require("@mui/x-charts/ChartContainer");
9
+ var _ResponsiveChartContainer = require("@mui/x-charts/ResponsiveChartContainer");
10
10
  var _LineChart = require("@mui/x-charts/LineChart");
11
11
  var _BarChart = require("@mui/x-charts/BarChart");
12
12
  var _ChartsXAxis = require("@mui/x-charts/ChartsXAxis");
@@ -39,7 +39,7 @@ function MixChart(_ref) {
39
39
  maxWidth: 600
40
40
  },
41
41
  key: id
42
- }, MuiBoxAttributes), /*#__PURE__*/React.createElement(_ChartContainer.ChartContainer, _extends({
42
+ }, MuiBoxAttributes), /*#__PURE__*/React.createElement(_ResponsiveChartContainer.ResponsiveChartContainer, _extends({
43
43
  sx: _objectSpread({
44
44
  [".".concat(_ChartsAxis.axisClasses.left, " .").concat(_ChartsAxis.axisClasses.label)]: {
45
45
  transform: 'translate(-25px, 0)'
@@ -31,35 +31,34 @@ const getValue = function () {
31
31
  let defaultValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
32
32
  let isMultiple = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
33
33
  if (isMultiple) {
34
- const values = Array.isArray(defaultValue) ? defaultValue : (() => {
35
- let sep = ',';
36
- if (defaultValue.includes(';')) sep = ';';
37
- return defaultValue.split(sep).map(v => v.trim());
38
- })();
39
- const dValueSet = new Set(values);
40
- return options.filter(opt => dValueSet.has(opt.value));
34
+ let separator = ',';
35
+ if (defaultValue !== null && defaultValue !== void 0 && defaultValue.includes(',')) separator = ',';else if (defaultValue !== null && defaultValue !== void 0 && defaultValue.includes(';')) separator = ';';
36
+ const dValueSet = new Set(defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue.split(separator));
37
+ return options === null || options === void 0 ? void 0 : options.filter(_ref => {
38
+ let {
39
+ value
40
+ } = _ref;
41
+ return dValueSet === null || dValueSet === void 0 ? void 0 : dValueSet.has(value);
42
+ });
41
43
  }
42
- return options.find(_ref => {
44
+ return options.find(_ref2 => {
43
45
  let {
44
46
  value
45
- } = _ref;
47
+ } = _ref2;
46
48
  return value === defaultValue;
47
49
  });
48
50
  };
49
- function Select(_ref2) {
51
+ function Select(_ref3) {
50
52
  let {
51
53
  attributes,
52
54
  onChange
53
- } = _ref2;
55
+ } = _ref3;
54
56
  const {
55
57
  MuiAttributes = {},
56
58
  options = [],
57
59
  MuiBoxAttributes = {},
58
60
  id = '',
59
- InputProps = {},
60
- additionalProps = {
61
- split: ','
62
- }
61
+ InputProps = {}
63
62
  } = attributes;
64
63
  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));
65
64
  const getMuiAttributes = () => {
@@ -89,7 +88,7 @@ function Select(_ref2) {
89
88
  const data = MuiAttributes.multiple ? newValue.map(extractValue) : extractValue(newValue);
90
89
  onChange({
91
90
  id,
92
- value: MuiAttributes.multiple ? data === null || data === void 0 ? void 0 : data.join(additionalProps === null || additionalProps === void 0 ? void 0 : additionalProps.split) : data,
91
+ value: MuiAttributes.multiple ? data.toString() : data,
93
92
  option: newValue
94
93
  });
95
94
  } else onChange({
@@ -15,7 +15,7 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
15
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
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
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 => {
18
+ const ColorSwitch = (0, _styles.experimentalStyled)(_ref => {
19
19
  let {
20
20
  color
21
21
  } = _ref,
@@ -12,7 +12,13 @@ var _helper = require("../../../util/helper");
12
12
  var _validation = _interopRequireDefault(require("../../../util/validation"));
13
13
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
14
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 react/jsx-no-duplicate-props */
15
20
  function TextField(_ref) {
21
+ var _MuiAttributes$slotPr;
16
22
  let {
17
23
  attributes,
18
24
  rules = {},
@@ -59,7 +65,6 @@ function TextField(_ref) {
59
65
  const {
60
66
  value
61
67
  } = args[0].target;
62
- // const formatValue = value ? getValue(value) : '';
63
68
  const validator = validate(value);
64
69
  setTextData({
65
70
  value,
@@ -81,25 +86,47 @@ function TextField(_ref) {
81
86
  helperText: validator.message,
82
87
  error: !validator.isValid
83
88
  });
84
- if (typeof onChange === 'function') {
85
- onChange({
86
- id,
87
- value: formatValue
88
- });
89
- }
89
+ if (typeof onChange === 'function') onChange({
90
+ id,
91
+ value: formatValue
92
+ });
90
93
  };
91
- const handleOnFocus = () => {
92
- // const { value } = args[0].target;
93
- // const formatValue = getValue(value);
94
- // const validator = validate(formatValue);
95
- // setTextData({
96
- // value: formatValue,
97
- // helperText: validator.message,
98
- // });
94
+ const handleOnFocus = () => {};
95
+
96
+ // Wheel-block for numeric inputs
97
+ const isNumberType = (MuiAttributes === null || MuiAttributes === void 0 ? void 0 : MuiAttributes.type) === 'number' || (attributes === null || attributes === void 0 ? void 0 : attributes.type) === 'number' || (MuiAttributes === null || MuiAttributes === void 0 ? void 0 : MuiAttributes.inputMode) === 'numeric';
98
+ const onWheelBlock = e => {
99
+ const el = e.currentTarget;
100
+ el.blur();
101
+ setTimeout(() => el.focus(), 0);
99
102
  };
103
+
104
+ // Build merged input props we want to ensure exist
105
+ const ourInputProps = _objectSpread(_objectSpread({}, isNumberType ? {
106
+ onWheel: onWheelBlock
107
+ } : {}), {}, {
108
+ inputMode: (MuiAttributes === null || MuiAttributes === void 0 ? void 0 : MuiAttributes.inputProps) && MuiAttributes.inputProps.inputMode || (MuiAttributes === null || MuiAttributes === void 0 || (_MuiAttributes$slotPr = MuiAttributes.slotProps) === null || _MuiAttributes$slotPr === void 0 ? void 0 : _MuiAttributes$slotPr.input) && MuiAttributes.slotProps.input.inputMode || 'numeric'
109
+ });
110
+ const isV6 = !!(MuiAttributes !== null && MuiAttributes !== void 0 && MuiAttributes.slotProps);
111
+ const baseAttrs = _objectSpread({}, MuiAttributes);
112
+ let finalInputProps;
113
+ let finalSlotProps;
114
+ if (isV6) {
115
+ const existingSlotInput = MuiAttributes.slotProps && MuiAttributes.slotProps.input || {};
116
+ finalSlotProps = _objectSpread(_objectSpread({}, MuiAttributes.slotProps || {}), {}, {
117
+ input: _objectSpread(_objectSpread({}, existingSlotInput), ourInputProps)
118
+ });
119
+ delete baseAttrs.slotProps;
120
+ } else {
121
+ const existingInputProps = MuiAttributes.inputProps || {};
122
+ finalInputProps = _objectSpread(_objectSpread({}, existingInputProps), ourInputProps);
123
+ delete baseAttrs.inputProps;
124
+ }
100
125
  return /*#__PURE__*/_react.default.createElement(_TextField.default, _extends({
101
126
  fullWidth: true
102
- }, MuiAttributes, {
127
+ }, baseAttrs, {
128
+ inputProps: !isV6 ? finalInputProps : undefined,
129
+ slotProps: isV6 ? finalSlotProps : undefined,
103
130
  InputProps: (0, _helper.getInputProps)(InputProps),
104
131
  onChange: handleOnChange,
105
132
  onBlur: handleOnBlur,
@@ -110,11 +137,8 @@ function TextField(_ref) {
110
137
  }));
111
138
  }
112
139
  TextField.propTypes = process.env.NODE_ENV !== "production" ? {
113
- /** Attributes for TextField */
114
140
  attributes: _propTypes.default.objectOf(_propTypes.default.object),
115
- /** Rules to be used */
116
141
  rules: _propTypes.default.objectOf(_propTypes.default.array),
117
- /** Function */
118
142
  onChange: _propTypes.default.func
119
143
  } : {};
120
144
  TextField.defaultProps = {
@@ -12,56 +12,40 @@ var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
12
12
  var _material = require("@mui/material");
13
13
  var _xDatePickers = require("@mui/x-date-pickers");
14
14
  var _react = _interopRequireDefault(require("react"));
15
- const _excluded = ["row", "xs", "sm", "md", "lg", "xl"];
16
15
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
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
16
  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
17
  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
18
  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
19
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
22
20
  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); }
23
- 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; }
24
- 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; }
21
+ 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); }
25
22
  function generateLayout(data) {
26
- const cloned = (0, _lodash.cloneDeep)(data);
27
- const normalized = cloned.map(item => {
28
- if (!item.layout) return item;
29
- const _item$layout = item.layout,
30
- {
31
- row,
32
- xs,
33
- sm,
34
- md,
35
- lg,
36
- xl
37
- } = _item$layout,
38
- restLayout = _objectWithoutProperties(_item$layout, _excluded);
39
- return _objectSpread(_objectSpread({}, item), {}, {
40
- layout: _objectSpread(_objectSpread({}, restLayout), {}, {
41
- row,
42
- size: {
43
- xs,
44
- sm,
45
- md,
46
- lg,
47
- xl
48
- }
49
- })
50
- });
51
- });
52
23
  const layout = {
53
24
  wrows: [],
54
25
  worows: []
55
26
  };
56
- layout.worows = (0, _lodash.remove)(normalized, it => {
57
- var _it$layout;
58
- return ((_it$layout = it.layout) === null || _it$layout === void 0 ? void 0 : _it$layout.row) == null;
59
- });
60
- const rowIndex = (0, _lodash.map)(normalized, 'layout.row');
61
- const sortedRows = (0, _lodash.sortBy)((0, _lodash.uniq)(rowIndex));
62
- (0, _lodash.each)(sortedRows, rowNum => {
63
- const rowItems = normalized.filter(it => it.layout.row === rowNum);
64
- layout.wrows.push(rowItems);
27
+ // All Items
28
+ const wrows = (0, _lodash.clone)(data);
29
+ // Remove Without Rows
30
+ layout.worows = (0, _lodash.remove)(wrows, item => {
31
+ const isLayout = item.layout ? item.layout.row : item.layout;
32
+ return isLayout === undefined;
33
+ }); // Concat all items without rows
34
+
35
+ // All row indices
36
+ const rowIndex = (0, _lodash.map)(wrows, 'layout.row');
37
+ const uniqIndex = (0, _lodash.uniq)(rowIndex);
38
+ const sortedIndex = (0, _lodash.sortBy)(uniqIndex);
39
+ (0, _lodash.each)(sortedIndex, value => {
40
+ const rows = [];
41
+ (0, _lodash.each)(wrows, item => {
42
+ if (item.layout) {
43
+ if (item.layout.row === value) {
44
+ rows.push(item);
45
+ }
46
+ }
47
+ });
48
+ layout.wrows.push(rows);
65
49
  });
66
50
  return layout;
67
51
  }
@@ -74,13 +58,13 @@ function getInputProps(InputProps) {
74
58
  text,
75
59
  textstyle = {}
76
60
  } = InputProps;
77
- return position ? {
61
+ return {
78
62
  ["".concat(position, "Adornment")]: /*#__PURE__*/_react.default.createElement(_material.InputAdornment, _extends({}, MuiInputAdornment, {
79
63
  key: "custom-icon-Adornment-".concat(position)
80
64
  }), icon && /*#__PURE__*/_react.default.createElement(_material.Icon, null, icon), !(0, _isEmpty.default)(textstyle) ? /*#__PURE__*/_react.default.createElement("div", {
81
65
  style: textstyle
82
66
  }, text || '') : text || '')
83
- } : _objectSpread({}, InputProps);
67
+ };
84
68
  }
85
69
  return {};
86
70
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dynamic-mui",
3
- "version": "1.0.84",
3
+ "version": "1.0.85",
4
4
  "author": "Dinakaran S",
5
5
  "user": "dinakarans",
6
6
  "repository": {
@@ -19,11 +19,11 @@
19
19
  "@babel/plugin-transform-modules-commonjs": "^7.26.3",
20
20
  "@emotion/react": "^11.14.0",
21
21
  "@emotion/styled": "^11.14.0",
22
- "@mui/icons-material": "^7.3.0",
23
- "@mui/material": "^7.3.0",
24
- "@mui/x-charts": "^8.9.2",
25
- "@mui/x-data-grid": "^8.9.2",
26
- "@mui/x-date-pickers": "^8.9.2",
22
+ "@mui/icons-material": "^6.3.1",
23
+ "@mui/material": "^6.3.1",
24
+ "@mui/x-charts": "^7.23.2",
25
+ "@mui/x-data-grid": "^7.23.5",
26
+ "@mui/x-date-pickers": "^7.23.3",
27
27
  "@testing-library/jest-dom": "^6.6.3",
28
28
  "@testing-library/react": "^16.1.0",
29
29
  "@testing-library/user-event": "^14.5.2",