@portnet/ui 0.0.99 → 0.0.101

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.
@@ -1,55 +1,41 @@
1
1
  "use strict";
2
2
 
3
- require("core-js/modules/web.dom-collections.iterator.js");
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
7
6
  exports.default = void 0;
7
+ require("core-js/modules/web.dom-collections.iterator.js");
8
8
  var _formik = require("formik");
9
9
  var React = _interopRequireWildcard(require("react"));
10
10
  var _jsxRuntime = require("react/jsx-runtime");
11
11
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
12
12
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
13
- const getFieldErrorNames = formikErrors => {
14
- const transformObjectToDotNotation = function transformObjectToDotNotation(obj) {
15
- let prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
16
- let result = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
17
- Object.keys(obj).forEach(key => {
18
- const value = obj[key];
19
- if (!value) return;
20
- const nextKey = prefix ? "".concat(prefix, ".").concat(key) : key;
21
- if (typeof value === "object") {
22
- transformObjectToDotNotation(value, nextKey, result);
23
- } else {
24
- result.push(nextKey);
25
- }
26
- });
27
- return result;
28
- };
29
- return transformObjectToDotNotation(formikErrors);
30
- };
31
13
  const PuiFormikForm = _ref => {
32
14
  let {
33
15
  children
34
16
  } = _ref;
17
+ const [verifyError, setVerifyError] = React.useState(false);
35
18
  const {
36
- submitCount,
37
- isValidating,
19
+ isSubmitting,
38
20
  isValid,
39
- errors
21
+ isValidating
40
22
  } = (0, _formik.useFormikContext)();
41
- React.useLayoutEffect(() => {
42
- if (submitCount === 0 || isValidating || isValid) return;
43
- const fieldErrorNames = getFieldErrorNames(errors);
44
- if (fieldErrorNames.length <= 0) return;
45
- const element = document.querySelector("input[name='".concat(fieldErrorNames[0], "']"));
46
- if (!element) return;
47
- element.scrollIntoView({
48
- behavior: "smooth",
49
- block: "center"
50
- });
51
- // eslint-disable-next-line react-hooks/exhaustive-deps
52
- }, [isValidating]);
23
+ React.useEffect(() => {
24
+ if (isSubmitting || isValidating) {
25
+ setVerifyError(true);
26
+ }
27
+ }, [isSubmitting, isValidating]);
28
+ React.useEffect(() => {
29
+ if (verifyError && !isValid && !isValidating) {
30
+ const element = document.querySelector(".Mui-error");
31
+ if (Boolean(element)) {
32
+ element.scrollIntoView({
33
+ behavior: "smooth",
34
+ block: "center"
35
+ });
36
+ }
37
+ }
38
+ }, [verifyError, isValid, isValidating]);
53
39
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_formik.Form, {
54
40
  children: children
55
41
  });
@@ -7,7 +7,7 @@ exports.palette = void 0;
7
7
  const palette = {
8
8
  inherit: "inherit",
9
9
  primary: "#232f66",
10
- secondary: "#dbdbdb",
10
+ secondary: "#e7e7e7",
11
11
  error: "#d32f2f",
12
12
  warning: "#FD9727",
13
13
  success: "#48AC24",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@portnet/ui",
3
- "version": "0.0.99",
3
+ "version": "0.0.101",
4
4
  "description": "Portnet UI",
5
5
  "keywords": [
6
6
  "react",