@ssplib/react-components 0.0.77 → 0.0.78

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.
@@ -35,6 +35,7 @@ function getChildrenNames(children) {
35
35
  children.forEach((x) => {
36
36
  if (!x.props)
37
37
  return;
38
+ console.log('PROPS:', x.props);
38
39
  if (x.props.children) {
39
40
  const childrenArr = getChildrenNames(Array.isArray(x.props.children) ? x.props.children : [x.props.children]);
40
41
  arr = arr.concat(childrenArr);
@@ -1,8 +1,9 @@
1
1
  import { ReactElement } from 'react';
2
- export default function FileUpload({ name, required, title, defaultChecked, xs, sm, md, ...props }: {
2
+ export default function FileUpload({ name, required, title, defaultChecked, xs, unregisterNameList, sm, md, ...props }: {
3
3
  name: string;
4
4
  children?: [ReactElement, ReactElement];
5
5
  title?: string;
6
+ unregisterNameList: string[];
6
7
  defaultChecked?: boolean;
7
8
  required?: boolean;
8
9
  xs?: number;
@@ -19,14 +19,15 @@ const InputLabel_1 = __importDefault(require("@mui/material/InputLabel"));
19
19
  const react_1 = __importDefault(require("react"));
20
20
  const Switch_1 = __importDefault(require("../switch/Switch"));
21
21
  const ToggleVisibility_1 = require("../switch/ToggleVisibility");
22
+ const Input_1 = require("./Input");
22
23
  function FileUpload(_a) {
23
- var { name, required = false, title, defaultChecked = false, xs = 12, sm, md } = _a, props = __rest(_a, ["name", "required", "title", "defaultChecked", "xs", "sm", "md"]);
24
+ var { name, required = false, title, defaultChecked = false, xs = 12, unregisterNameList, sm, md } = _a, props = __rest(_a, ["name", "required", "title", "defaultChecked", "xs", "unregisterNameList", "sm", "md"]);
24
25
  const switchName = `${name}-switch`;
25
26
  return (react_1.default.createElement(material_1.Grid, Object.assign({ item: true }, { xs, sm, md }),
26
27
  title && (react_1.default.createElement(InputLabel_1.default, { required: required, sx: { textTransform: 'capitalize' } }, title)),
27
28
  react_1.default.createElement(material_1.Stack, { direction: 'row' },
28
29
  react_1.default.createElement(Switch_1.default, { name: switchName, defaultChecked: defaultChecked }),
29
- react_1.default.createElement(ToggleVisibility_1.SwitchWatch, { switchId: switchName, unregisterNameList: [] }, props.children[0]),
30
- react_1.default.createElement(ToggleVisibility_1.SwitchWatch, { switchId: switchName, unregisterNameList: [], invert: true }, props.children[1]))));
30
+ react_1.default.createElement(ToggleVisibility_1.SwitchWatch, { switchId: switchName, unregisterNameList: unregisterNameList },
31
+ react_1.default.createElement(Input_1.Input, { name: 'ddd', type: 'input' })))));
31
32
  }
32
33
  exports.default = FileUpload;
@@ -64,6 +64,34 @@ const getKeys = (values, id) => {
64
64
  keys = [...keys, ...Object.keys(values.files).map((x) => `files.${x}`)];
65
65
  return keys;
66
66
  };
67
+ const _getKeys = (value) => {
68
+ const keys = Object.keys(value);
69
+ if (!value || keys.length <= 0)
70
+ return { objs: [], literals: [] };
71
+ console.log('ATUAL KEYS:', keys);
72
+ let literalValues = [];
73
+ let objectValues = [];
74
+ let result = keys;
75
+ keys.forEach((x) => {
76
+ console.log(x, ':', typeof value[x]);
77
+ if (typeof value[x] === 'object') {
78
+ objectValues.push(x);
79
+ const obj = _getKeys(value[x]);
80
+ objectValues = objectValues.concat(obj.objs);
81
+ }
82
+ else {
83
+ literalValues.push(x);
84
+ }
85
+ });
86
+ console.log({
87
+ objs: objectValues,
88
+ literals: literalValues,
89
+ });
90
+ return {
91
+ objs: objectValues,
92
+ literals: literalValues,
93
+ };
94
+ };
67
95
  function Stepper(_a) {
68
96
  var { debugLog = false } = _a, props = __rest(_a, ["debugLog"]);
69
97
  const length = Array.isArray(props.children) ? props.children.length : 1;
@@ -79,6 +107,8 @@ function Stepper(_a) {
79
107
  const handleNext = () => __awaiter(this, void 0, void 0, function* () {
80
108
  if (debugLog)
81
109
  console.log(context.formGetValues());
110
+ console.log('TRIGGER:', getKeys(context.formGetValues(), activeStep));
111
+ // _getKeys(context.formGetValues()[activeStep])
82
112
  const result = yield context.formTrigger(getKeys(context.formGetValues(), activeStep));
83
113
  if (!result) {
84
114
  setCanPass(true);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ssplib/react-components",
3
- "version": "0.0.77",
3
+ "version": "0.0.78",
4
4
  "description": "SSP React Components",
5
5
  "main": "index.js",
6
6
  "author": "Pedro Henrique <sr.hudrick@gmail.com>",