@digigov/ui 1.0.0-290a96e2 → 1.0.0-55e4210c

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,13 +1,33 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
3
  var _excluded = ["children", "href"];
4
- import * as React from 'react';
4
+ import React, { useEffect } from 'react';
5
5
  import LinkBase from '@digigov/react-core/LinkBase';
6
6
  export var CommonLink = function CommonLink(props) {
7
7
  return /*#__PURE__*/React.createElement(LinkBase, props, props.children);
8
8
  };
9
9
  var LinkComponentContext = /*#__PURE__*/React.createContext(LinkBase);
10
10
  export var LinkProvider = function LinkProvider(props) {
11
+ useEffect(function () {
12
+ var path = window.location.hash;
13
+
14
+ if (path && path.includes("#")) {
15
+ setTimeout(function () {
16
+ var id = path.replace("#", "");
17
+ var el = window.document.getElementById(id);
18
+ var r = el === null || el === void 0 ? void 0 : el.getBoundingClientRect();
19
+
20
+ if (r) {
21
+ var _window$top;
22
+
23
+ (_window$top = window.top) === null || _window$top === void 0 ? void 0 : _window$top.scroll({
24
+ top: scrollY + r.top,
25
+ behavior: "smooth"
26
+ });
27
+ }
28
+ }, 600);
29
+ }
30
+ });
11
31
  return /*#__PURE__*/React.createElement(LinkComponentContext.Provider, {
12
32
  value: props.component
13
33
  }, props.children);
package/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license Digigov v1.0.0-290a96e2
1
+ /** @license Digigov v1.0.0-55e4210c
2
2
  *
3
3
  * This source code is licensed under the BSD-2-Clause license found in the
4
4
  * LICENSE file in the root directory of this source tree.
@@ -1,13 +1,33 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
3
  var _excluded = ["children", "href"];
4
- import * as React from 'react';
4
+ import React, { useEffect } from 'react';
5
5
  import LinkBase from '@digigov/react-core/LinkBase';
6
6
  export var CommonLink = function CommonLink(props) {
7
7
  return /*#__PURE__*/React.createElement(LinkBase, props, props.children);
8
8
  };
9
9
  var LinkComponentContext = /*#__PURE__*/React.createContext(LinkBase);
10
10
  export var LinkProvider = function LinkProvider(props) {
11
+ useEffect(function () {
12
+ var path = window.location.hash;
13
+
14
+ if (path && path.includes("#")) {
15
+ setTimeout(function () {
16
+ var id = path.replace("#", "");
17
+ var el = window.document.getElementById(id);
18
+ var r = el === null || el === void 0 ? void 0 : el.getBoundingClientRect();
19
+
20
+ if (r) {
21
+ var _window$top;
22
+
23
+ (_window$top = window.top) === null || _window$top === void 0 ? void 0 : _window$top.scroll({
24
+ top: scrollY + r.top,
25
+ behavior: "smooth"
26
+ });
27
+ }
28
+ }, 600);
29
+ }
30
+ });
11
31
  return /*#__PURE__*/React.createElement(LinkComponentContext.Provider, {
12
32
  value: props.component
13
33
  }, props.children);
@@ -1,4 +1,4 @@
1
- import * as React from 'react';
1
+ import React from 'react';
2
2
  import LinkBase, { LinkBaseProps } from '@digigov/react-core/LinkBase';
3
3
  export interface LinkComponentContextProps {
4
4
  component: React.ElementType<LinkProps>;
@@ -20,7 +20,7 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
20
20
 
21
21
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
22
22
 
23
- var React = _interopRequireWildcard(require("react"));
23
+ var _react = _interopRequireWildcard(require("react"));
24
24
 
25
25
  var _LinkBase = _interopRequireDefault(require("@digigov/react-core/LinkBase"));
26
26
 
@@ -31,31 +31,56 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
31
31
  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; }
32
32
 
33
33
  var CommonLink = function CommonLink(props) {
34
- return /*#__PURE__*/React.createElement(_LinkBase["default"], props, props.children);
34
+ return /*#__PURE__*/_react["default"].createElement(_LinkBase["default"], props, props.children);
35
35
  };
36
36
 
37
37
  exports.CommonLink = CommonLink;
38
- var LinkComponentContext = /*#__PURE__*/React.createContext(_LinkBase["default"]);
38
+
39
+ var LinkComponentContext = /*#__PURE__*/_react["default"].createContext(_LinkBase["default"]);
39
40
 
40
41
  var LinkProvider = function LinkProvider(props) {
41
- return /*#__PURE__*/React.createElement(LinkComponentContext.Provider, {
42
+ (0, _react.useEffect)(function () {
43
+ var path = window.location.hash;
44
+
45
+ if (path && path.includes("#")) {
46
+ setTimeout(function () {
47
+ var id = path.replace("#", "");
48
+ var el = window.document.getElementById(id);
49
+ var r = el === null || el === void 0 ? void 0 : el.getBoundingClientRect();
50
+
51
+ if (r) {
52
+ var _window$top;
53
+
54
+ (_window$top = window.top) === null || _window$top === void 0 ? void 0 : _window$top.scroll({
55
+ top: scrollY + r.top,
56
+ behavior: "smooth"
57
+ });
58
+ }
59
+ }, 600);
60
+ }
61
+ });
62
+ return /*#__PURE__*/_react["default"].createElement(LinkComponentContext.Provider, {
42
63
  value: props.component
43
64
  }, props.children);
44
65
  };
45
66
 
46
67
  exports.LinkProvider = LinkProvider;
47
- var Link = /*#__PURE__*/React.forwardRef(function Link(_ref, ref) {
68
+
69
+ var Link = /*#__PURE__*/_react["default"].forwardRef(function Link(_ref, ref) {
48
70
  var children = _ref.children,
49
71
  _ref$href = _ref.href,
50
72
  href = _ref$href === void 0 ? '' : _ref$href,
51
73
  props = (0, _objectWithoutProperties2["default"])(_ref, _excluded);
52
- var LinkComponent = React.useContext(LinkComponentContext);
53
- return /*#__PURE__*/React.createElement(LinkComponent, (0, _extends2["default"])({
74
+
75
+ var LinkComponent = _react["default"].useContext(LinkComponentContext);
76
+
77
+ return /*#__PURE__*/_react["default"].createElement(LinkComponent, (0, _extends2["default"])({
54
78
  ref: ref,
55
79
  href: href
56
80
  }, props), children);
57
81
  }); //@ts-ignore
58
82
 
83
+
59
84
  exports.Link = Link;
60
85
  Link.displayName = 'Link';
61
86
  var _default = Link;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digigov/ui",
3
- "version": "1.0.0-290a96e2",
3
+ "version": "1.0.0-55e4210c",
4
4
  "description": "@digigov reusable components toolkit",
5
5
  "main": "./index.js",
6
6
  "module": "./esm/index.js",
@@ -13,7 +13,7 @@
13
13
  "react-query": "2.26.4",
14
14
  "yup": "0.32.11",
15
15
  "publint": "0.1.8",
16
- "@digigov/react-icons": "1.0.0-290a96e2"
16
+ "@digigov/react-icons": "1.0.0-55e4210c"
17
17
  },
18
18
  "peerDependencies": {
19
19
  "@material-ui/core": "4.11.3",
@@ -21,7 +21,7 @@
21
21
  "clsx": "1.1.1",
22
22
  "react": "^16.8.0 || ^17.0.0",
23
23
  "react-dom": "^16.8.0 || ^17.0.0",
24
- "@digigov/react-core": "1.0.0-290a96e2"
24
+ "@digigov/react-core": "1.0.0-55e4210c"
25
25
  },
26
26
  "gitHead": "c903a46306f77f55ad7fc4d2e274006f39a6c871",
27
27
  "private": false,
@@ -1,4 +1,4 @@
1
- import * as React from 'react';
1
+ import React, { useEffect } from 'react';
2
2
  import LinkBase, { LinkBaseProps } from '@digigov/react-core/LinkBase';
3
3
 
4
4
  export interface LinkComponentContextProps {
@@ -13,6 +13,23 @@ const LinkComponentContext = React.createContext<React.ElementType<LinkProps>>(
13
13
  LinkBase
14
14
  );
15
15
  export const LinkProvider: React.FC<LinkComponentContextProps> = (props) => {
16
+ useEffect(() => {
17
+ const path = window.location.hash
18
+ if (path && path.includes("#")) {
19
+ setTimeout(() => {
20
+ const id = path.replace("#", "")
21
+ const el = window.document.getElementById(id)
22
+ const r = el?.getBoundingClientRect()
23
+ if (r) {
24
+ window.top?.scroll({
25
+ top: scrollY + r.top,
26
+ behavior: "smooth",
27
+ })
28
+ }
29
+ }, 600)
30
+ }
31
+ })
32
+
16
33
  return (
17
34
  <LinkComponentContext.Provider value={props.component}>
18
35
  {props.children}