@dynamic-labs/sdk-react-core 4.6.2 → 4.6.3

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.
@@ -0,0 +1,5 @@
1
+ export type ButtonAriaProps = {
2
+ ariaLabel?: string;
3
+ ariaExpanded?: boolean;
4
+ ariaControls?: string;
5
+ };
@@ -4,10 +4,10 @@
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
6
  var jsxRuntime = require('react/jsx-runtime');
7
+ var React = require('react');
7
8
  require('@dynamic-labs/utils');
8
9
  require('../../../../../components/Accordion/components/AccordionItem/AccordionItem.cjs');
9
10
  require('../../../../../components/Alert/Alert.cjs');
10
- require('react');
11
11
  require('../../../../../events/dynamicEvents.cjs');
12
12
  require('../../../../../../../_virtual/_tslib.cjs');
13
13
  require('../../../../../context/DynamicContext/DynamicContext.cjs');
@@ -15,7 +15,7 @@ require('@dynamic-labs/sdk-api-core');
15
15
  require('../../../../../shared/logger.cjs');
16
16
  require('@dynamic-labs/iconic');
17
17
  require('@dynamic-labs/wallet-connector-core');
18
- var gear = require('../../../../../shared/assets/gear.cjs');
18
+ var arrowDown = require('../../../../../shared/assets/arrow-down.cjs');
19
19
  require('../../../../../context/ViewContext/ViewContext.cjs');
20
20
  require('@dynamic-labs/wallet-book');
21
21
  var shortenWalletAddress = require('../../../../../shared/utils/functions/shortenWalletAddress/shortenWalletAddress.cjs');
@@ -70,14 +70,15 @@ require('../../../../../context/WalletGroupContext/WalletGroupContext.cjs');
70
70
  require('../../DynamicWidgetHeader/DynamicWidgetHeader.cjs');
71
71
  require('react-focus-lock');
72
72
  require('../../../context/DynamicWidgetContext.cjs');
73
- var DotsMenu = require('../../DotsMenu/DotsMenu.cjs');
73
+ require('../../../../../components/IconButton/IconButton.cjs');
74
+ var Dropdown = require('../../../../../components/MenuList/Dropdown/Dropdown.cjs');
75
+ var DotsMenuDropdown = require('../../DotsMenuDropdown/DotsMenuDropdown.cjs');
76
+ var BaseButton = require('../../../../../components/BaseButton/BaseButton.cjs');
74
77
  require('formik');
75
78
  require('../../../../../utils/hooks/useSubdomainCheck/useSubdomainCheck.cjs');
76
- require('../../../../../components/IconButton/IconButton.cjs');
77
79
  require('../../../../../store/state/sendBalances.cjs');
78
80
  require('../../../../../components/Input/Input.cjs');
79
81
  require('../../../../../components/OverlayCard/OverlayCard.cjs');
80
- require('../../../../../components/MenuList/Dropdown/Dropdown.cjs');
81
82
  require('../../../../../views/TransactionConfirmationView/TransactionConfirmationView.cjs');
82
83
  var PasskeyContext = require('../../../../../context/PasskeyContext/PasskeyContext.cjs');
83
84
  require('../../../views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.cjs');
@@ -118,6 +119,16 @@ const ActiveWalletAddress = ({ wallet, nameServiceName, menuOption, fullWidth =
118
119
  const { showAlert } = PasskeyContext.usePasskeyContext();
119
120
  const header = nameServiceName || getNameIfNoIcon(wallet);
120
121
  const { network } = useWalletConnectorNetwork.useWalletConnectorNetwork(wallet === null || wallet === void 0 ? void 0 : wallet.connector);
122
+ const [showMenu, setShowMenu] = React.useState(false);
123
+ const handleMenuClose = React.useCallback(() => {
124
+ setShowMenu(false);
125
+ }, [setShowMenu]);
126
+ const handleMenuOpen = React.useCallback(() => {
127
+ // Use setTimeout here to prevent React 17 from triggering a click event
128
+ // when the dropdown is rendered.
129
+ setTimeout(() => setShowMenu(true), 0);
130
+ }, [setShowMenu]);
131
+ const iconRef = React.useRef(null);
121
132
  const { data: address } = usePromise.usePromise(() => {
122
133
  // COSMOS wallet address changes based on which network is selected
123
134
  if ((wallet === null || wallet === void 0 ? void 0 : wallet.connector.connectedChain) === 'COSMOS') {
@@ -128,9 +139,10 @@ const ActiveWalletAddress = ({ wallet, nameServiceName, menuOption, fullWidth =
128
139
  deps: [wallet, network],
129
140
  enabled: Boolean(wallet),
130
141
  });
131
- return (jsxRuntime.jsxs("div", { className: 'active-wallet-information__address-container', children: [jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx(Typography.Typography, { className: fullWidth
132
- ? 'active-wallet-information__handle--full-width'
133
- : 'active-wallet-information__handle', color: 'primary', variant: 'body_normal', "data-testid": 'header-text', children: header }), jsxRuntime.jsx(Typography.Typography, { className: 'active-wallet-information__address', weight: header ? 'regular' : 'medium', variant: header ? 'body_small' : 'body_normal', color: header ? 'secondary' : 'primary', children: isLoading ? (jsxRuntime.jsx(Skeleton.Skeleton, { className: 'active-wallet-information__address-skeleton' })) : (shortenWalletAddress.shortenWalletAddress(address, 4, 4)) })] }), jsxRuntime.jsx(DotsMenu.DotsMenu, { "data-testid": 'dots-menu', options: menuOption, buttonClassName: 'active-wallet-information__dots-menu', buttonClassNameWithOpenMenu: 'active-wallet-information__dots-menu', iconOverride: showAlert() ? (jsxRuntime.jsx(IconWithStatus.IconWithStatus, { Icon: () => jsxRuntime.jsx(gear.ReactComponent, { width: 16, height: 16 }), variant: 'yellow' })) : (jsxRuntime.jsx(gear.ReactComponent, { width: 16, height: 16 })) })] }));
142
+ const menuIcon = React.useMemo(() => (jsxRuntime.jsx("div", { ref: iconRef, className: 'active-wallet-information__handle-icon', children: showAlert() ? (jsxRuntime.jsx(IconWithStatus.IconWithStatus, { Icon: () => jsxRuntime.jsx(arrowDown.ReactComponent, { width: 24, height: 24 }), variant: 'yellow' })) : (jsxRuntime.jsx(arrowDown.ReactComponent, { width: 24, height: 24 })) })), [showAlert]);
143
+ return (jsxRuntime.jsxs("div", { className: 'active-wallet-information__address-container', children: [jsxRuntime.jsxs(BaseButton.BaseButton, { onClick: handleMenuOpen, dataTestId: 'active-wallet-information-button', children: [jsxRuntime.jsxs("div", { className: 'active-wallet-information__handle-row', children: [jsxRuntime.jsx(Typography.Typography, { className: fullWidth
144
+ ? 'active-wallet-information__handle--full-width'
145
+ : 'active-wallet-information__handle', color: 'primary', variant: 'body_normal', "data-testid": 'header-text', children: header }), header && menuIcon] }), jsxRuntime.jsxs("div", { className: 'active-wallet-information__handle-row', children: [jsxRuntime.jsx(Typography.Typography, { className: 'active-wallet-information__address', weight: header ? 'regular' : 'medium', variant: header ? 'body_small' : 'body_normal', color: header ? 'secondary' : 'primary', children: isLoading ? (jsxRuntime.jsx(Skeleton.Skeleton, { className: 'active-wallet-information__address-skeleton' })) : (shortenWalletAddress.shortenWalletAddress(address, 4, 4)) }), !header && menuIcon] })] }), jsxRuntime.jsx(Dropdown.Dropdown, { isOpen: showMenu, onClickOutside: handleMenuClose, onScroll: handleMenuClose, anchorRef: iconRef, anchorOrigin: 'bottom-right', transformOrigin: 'top-left', children: jsxRuntime.jsx(DotsMenuDropdown.DotsMenuDropdown, { options: menuOption, setShowMenu: setShowMenu }) })] }));
134
146
  };
135
147
 
136
148
  exports.ActiveWalletAddress = ActiveWalletAddress;
@@ -1,9 +1,9 @@
1
1
  'use client'
2
- import { jsxs, jsx } from 'react/jsx-runtime';
2
+ import { jsx, jsxs } from 'react/jsx-runtime';
3
+ import { useState, useCallback, useRef, useMemo } from 'react';
3
4
  import '@dynamic-labs/utils';
4
5
  import '../../../../../components/Accordion/components/AccordionItem/AccordionItem.js';
5
6
  import '../../../../../components/Alert/Alert.js';
6
- import 'react';
7
7
  import '../../../../../events/dynamicEvents.js';
8
8
  import '../../../../../../../_virtual/_tslib.js';
9
9
  import '../../../../../context/DynamicContext/DynamicContext.js';
@@ -11,7 +11,7 @@ import '@dynamic-labs/sdk-api-core';
11
11
  import '../../../../../shared/logger.js';
12
12
  import '@dynamic-labs/iconic';
13
13
  import '@dynamic-labs/wallet-connector-core';
14
- import { ReactComponent as SvgGear } from '../../../../../shared/assets/gear.js';
14
+ import { ReactComponent as SvgArrowDown } from '../../../../../shared/assets/arrow-down.js';
15
15
  import '../../../../../context/ViewContext/ViewContext.js';
16
16
  import '@dynamic-labs/wallet-book';
17
17
  import { shortenWalletAddress } from '../../../../../shared/utils/functions/shortenWalletAddress/shortenWalletAddress.js';
@@ -66,14 +66,15 @@ import '../../../../../context/WalletGroupContext/WalletGroupContext.js';
66
66
  import '../../DynamicWidgetHeader/DynamicWidgetHeader.js';
67
67
  import 'react-focus-lock';
68
68
  import '../../../context/DynamicWidgetContext.js';
69
- import { DotsMenu } from '../../DotsMenu/DotsMenu.js';
69
+ import '../../../../../components/IconButton/IconButton.js';
70
+ import { Dropdown } from '../../../../../components/MenuList/Dropdown/Dropdown.js';
71
+ import { DotsMenuDropdown } from '../../DotsMenuDropdown/DotsMenuDropdown.js';
72
+ import { BaseButton } from '../../../../../components/BaseButton/BaseButton.js';
70
73
  import 'formik';
71
74
  import '../../../../../utils/hooks/useSubdomainCheck/useSubdomainCheck.js';
72
- import '../../../../../components/IconButton/IconButton.js';
73
75
  import '../../../../../store/state/sendBalances.js';
74
76
  import '../../../../../components/Input/Input.js';
75
77
  import '../../../../../components/OverlayCard/OverlayCard.js';
76
- import '../../../../../components/MenuList/Dropdown/Dropdown.js';
77
78
  import '../../../../../views/TransactionConfirmationView/TransactionConfirmationView.js';
78
79
  import { usePasskeyContext } from '../../../../../context/PasskeyContext/PasskeyContext.js';
79
80
  import '../../../views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.js';
@@ -114,6 +115,16 @@ const ActiveWalletAddress = ({ wallet, nameServiceName, menuOption, fullWidth =
114
115
  const { showAlert } = usePasskeyContext();
115
116
  const header = nameServiceName || getNameIfNoIcon(wallet);
116
117
  const { network } = useWalletConnectorNetwork(wallet === null || wallet === void 0 ? void 0 : wallet.connector);
118
+ const [showMenu, setShowMenu] = useState(false);
119
+ const handleMenuClose = useCallback(() => {
120
+ setShowMenu(false);
121
+ }, [setShowMenu]);
122
+ const handleMenuOpen = useCallback(() => {
123
+ // Use setTimeout here to prevent React 17 from triggering a click event
124
+ // when the dropdown is rendered.
125
+ setTimeout(() => setShowMenu(true), 0);
126
+ }, [setShowMenu]);
127
+ const iconRef = useRef(null);
117
128
  const { data: address } = usePromise(() => {
118
129
  // COSMOS wallet address changes based on which network is selected
119
130
  if ((wallet === null || wallet === void 0 ? void 0 : wallet.connector.connectedChain) === 'COSMOS') {
@@ -124,9 +135,10 @@ const ActiveWalletAddress = ({ wallet, nameServiceName, menuOption, fullWidth =
124
135
  deps: [wallet, network],
125
136
  enabled: Boolean(wallet),
126
137
  });
127
- return (jsxs("div", { className: 'active-wallet-information__address-container', children: [jsxs("div", { children: [jsx(Typography, { className: fullWidth
128
- ? 'active-wallet-information__handle--full-width'
129
- : 'active-wallet-information__handle', color: 'primary', variant: 'body_normal', "data-testid": 'header-text', children: header }), jsx(Typography, { className: 'active-wallet-information__address', weight: header ? 'regular' : 'medium', variant: header ? 'body_small' : 'body_normal', color: header ? 'secondary' : 'primary', children: isLoading ? (jsx(Skeleton, { className: 'active-wallet-information__address-skeleton' })) : (shortenWalletAddress(address, 4, 4)) })] }), jsx(DotsMenu, { "data-testid": 'dots-menu', options: menuOption, buttonClassName: 'active-wallet-information__dots-menu', buttonClassNameWithOpenMenu: 'active-wallet-information__dots-menu', iconOverride: showAlert() ? (jsx(IconWithStatus, { Icon: () => jsx(SvgGear, { width: 16, height: 16 }), variant: 'yellow' })) : (jsx(SvgGear, { width: 16, height: 16 })) })] }));
138
+ const menuIcon = useMemo(() => (jsx("div", { ref: iconRef, className: 'active-wallet-information__handle-icon', children: showAlert() ? (jsx(IconWithStatus, { Icon: () => jsx(SvgArrowDown, { width: 24, height: 24 }), variant: 'yellow' })) : (jsx(SvgArrowDown, { width: 24, height: 24 })) })), [showAlert]);
139
+ return (jsxs("div", { className: 'active-wallet-information__address-container', children: [jsxs(BaseButton, { onClick: handleMenuOpen, dataTestId: 'active-wallet-information-button', children: [jsxs("div", { className: 'active-wallet-information__handle-row', children: [jsx(Typography, { className: fullWidth
140
+ ? 'active-wallet-information__handle--full-width'
141
+ : 'active-wallet-information__handle', color: 'primary', variant: 'body_normal', "data-testid": 'header-text', children: header }), header && menuIcon] }), jsxs("div", { className: 'active-wallet-information__handle-row', children: [jsx(Typography, { className: 'active-wallet-information__address', weight: header ? 'regular' : 'medium', variant: header ? 'body_small' : 'body_normal', color: header ? 'secondary' : 'primary', children: isLoading ? (jsx(Skeleton, { className: 'active-wallet-information__address-skeleton' })) : (shortenWalletAddress(address, 4, 4)) }), !header && menuIcon] })] }), jsx(Dropdown, { isOpen: showMenu, onClickOutside: handleMenuClose, onScroll: handleMenuClose, anchorRef: iconRef, anchorOrigin: 'bottom-right', transformOrigin: 'top-left', children: jsx(DotsMenuDropdown, { options: menuOption, setShowMenu: setShowMenu }) })] }));
130
142
  };
131
143
 
132
144
  export { ActiveWalletAddress, getNameIfNoIcon };
@@ -1,54 +0,0 @@
1
- 'use client'
2
- 'use strict';
3
-
4
- Object.defineProperty(exports, '__esModule', { value: true });
5
-
6
- var React = require('react');
7
-
8
- function _interopNamespace(e) {
9
- if (e && e.__esModule) return e;
10
- var n = Object.create(null);
11
- if (e) {
12
- Object.keys(e).forEach(function (k) {
13
- if (k !== 'default') {
14
- var d = Object.getOwnPropertyDescriptor(e, k);
15
- Object.defineProperty(n, k, d.get ? d : {
16
- enumerable: true,
17
- get: function () { return e[k]; }
18
- });
19
- }
20
- });
21
- }
22
- n["default"] = e;
23
- return Object.freeze(n);
24
- }
25
-
26
- var React__namespace = /*#__PURE__*/_interopNamespace(React);
27
-
28
- var _path;
29
- var _excluded = ["title", "titleId"];
30
- 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); }
31
- function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var s = Object.getOwnPropertySymbols(e); for (r = 0; r < s.length; r++) { o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } } return i; }
32
- function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) { if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } } return t; }
33
- var SvgGear = function SvgGear(_ref) {
34
- var title = _ref.title,
35
- titleId = _ref.titleId,
36
- props = _objectWithoutProperties(_ref, _excluded);
37
- return /*#__PURE__*/React__namespace.createElement("svg", _extends({
38
- width: 24,
39
- height: 24,
40
- viewBox: "0 0 24 24",
41
- fill: "none",
42
- xmlns: "http://www.w3.org/2000/svg",
43
- "aria-labelledby": titleId
44
- }, props), title ? /*#__PURE__*/React__namespace.createElement("title", {
45
- id: titleId
46
- }, title) : null, _path || (_path = /*#__PURE__*/React__namespace.createElement("path", {
47
- fillRule: "evenodd",
48
- clipRule: "evenodd",
49
- d: "M9.353 4.081c.674-2.775 4.62-2.775 5.294 0a.724.724 0 0 0 1.08.448c2.44-1.486 5.23 1.305 3.744 3.744a.724.724 0 0 0 .448 1.08c2.775.674 2.775 4.62 0 5.294a.724.724 0 0 0-.448 1.08c1.486 2.44-1.305 5.23-3.744 3.744a.724.724 0 0 0-1.08.448c-.674 2.775-4.62 2.775-5.294 0a.724.724 0 0 0-1.08-.448c-2.44 1.486-5.23-1.305-3.744-3.744a.724.724 0 0 0-.448-1.08c-2.775-.674-2.775-4.62 0-5.294a.724.724 0 0 0 .448-1.08c-1.486-2.44 1.305-5.23 3.744-3.744a.724.724 0 0 0 1.08-.448Zm3.35.472c-.178-.737-1.227-.737-1.407 0a2.724 2.724 0 0 1-4.064 1.684c-.648-.395-1.39.347-.995.995.96 1.575.109 3.63-1.684 4.064-.737.18-.737 1.229 0 1.408a2.724 2.724 0 0 1 1.684 4.064c-.395.648.347 1.39.995.995a2.724 2.724 0 0 1 4.064 1.684c.18.737 1.229.737 1.408 0a2.724 2.724 0 0 1 4.064-1.684c.648.395 1.39-.347.995-.995a2.724 2.724 0 0 1 1.684-4.064c.737-.18.737-1.229 0-1.408a2.724 2.724 0 0 1-1.684-4.064c.395-.648-.347-1.39-.995-.995-1.575.96-3.63.109-4.064-1.684ZM12 10a2 2 0 1 0 0 4 2 2 0 0 0 0-4Zm-4 2a4 4 0 1 1 8 0 4 4 0 0 1-8 0Z",
50
- fill: "#ABACB2"
51
- })));
52
- };
53
-
54
- exports.ReactComponent = SvgGear;
@@ -1,30 +0,0 @@
1
- 'use client'
2
- import * as React from 'react';
3
-
4
- var _path;
5
- var _excluded = ["title", "titleId"];
6
- 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); }
7
- function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var s = Object.getOwnPropertySymbols(e); for (r = 0; r < s.length; r++) { o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } } return i; }
8
- function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) { if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } } return t; }
9
- var SvgGear = function SvgGear(_ref) {
10
- var title = _ref.title,
11
- titleId = _ref.titleId,
12
- props = _objectWithoutProperties(_ref, _excluded);
13
- return /*#__PURE__*/React.createElement("svg", _extends({
14
- width: 24,
15
- height: 24,
16
- viewBox: "0 0 24 24",
17
- fill: "none",
18
- xmlns: "http://www.w3.org/2000/svg",
19
- "aria-labelledby": titleId
20
- }, props), title ? /*#__PURE__*/React.createElement("title", {
21
- id: titleId
22
- }, title) : null, _path || (_path = /*#__PURE__*/React.createElement("path", {
23
- fillRule: "evenodd",
24
- clipRule: "evenodd",
25
- d: "M9.353 4.081c.674-2.775 4.62-2.775 5.294 0a.724.724 0 0 0 1.08.448c2.44-1.486 5.23 1.305 3.744 3.744a.724.724 0 0 0 .448 1.08c2.775.674 2.775 4.62 0 5.294a.724.724 0 0 0-.448 1.08c1.486 2.44-1.305 5.23-3.744 3.744a.724.724 0 0 0-1.08.448c-.674 2.775-4.62 2.775-5.294 0a.724.724 0 0 0-1.08-.448c-2.44 1.486-5.23-1.305-3.744-3.744a.724.724 0 0 0-.448-1.08c-2.775-.674-2.775-4.62 0-5.294a.724.724 0 0 0 .448-1.08c-1.486-2.44 1.305-5.23 3.744-3.744a.724.724 0 0 0 1.08-.448Zm3.35.472c-.178-.737-1.227-.737-1.407 0a2.724 2.724 0 0 1-4.064 1.684c-.648-.395-1.39.347-.995.995.96 1.575.109 3.63-1.684 4.064-.737.18-.737 1.229 0 1.408a2.724 2.724 0 0 1 1.684 4.064c-.395.648.347 1.39.995.995a2.724 2.724 0 0 1 4.064 1.684c.18.737 1.229.737 1.408 0a2.724 2.724 0 0 1 4.064-1.684c.648.395 1.39-.347.995-.995a2.724 2.724 0 0 1 1.684-4.064c.737-.18.737-1.229 0-1.408a2.724 2.724 0 0 1-1.684-4.064c.395-.648-.347-1.39-.995-.995-1.575.96-3.63.109-4.064-1.684ZM12 10a2 2 0 1 0 0 4 2 2 0 0 0 0-4Zm-4 2a4 4 0 1 1 8 0 4 4 0 0 1-8 0Z",
26
- fill: "#ABACB2"
27
- })));
28
- };
29
-
30
- export { SvgGear as ReactComponent };