@xyo-network/react-address-render 7.0.0 → 7.0.1
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/dist/browser/components/RenderRowBox.stories.d.ts +7 -7
- package/dist/browser/components/favorite/FavoriteIconButton.d.ts.map +1 -1
- package/dist/browser/components/favorite/Popper.d.ts.map +1 -1
- package/dist/browser/index.mjs +177 -145
- package/dist/browser/index.mjs.map +1 -1
- package/package.json +25 -22
- package/src/components/favorite/FavoriteIconButton.tsx +6 -4
- package/src/components/favorite/Popper.tsx +4 -6
|
@@ -2,25 +2,25 @@ import type { Meta } from '@storybook/react-vite';
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { AddressRenderRowBox } from './RenderRowBox.tsx';
|
|
4
4
|
declare const StorybookEntry: Meta<typeof AddressRenderRowBox>;
|
|
5
|
-
declare const Default: import("storybook/internal/csf").AnnotatedStoryFn<import("@storybook/react-vite").ReactRenderer, import("./RenderRowBox.tsx").AddressRenderRowBoxProps & {
|
|
5
|
+
declare const Default: import(".store/storybook-virtual-997ab3c959/package/internal/csf").AnnotatedStoryFn<import("@storybook/react-vite").ReactRenderer, import("./RenderRowBox.tsx").AddressRenderRowBoxProps & {
|
|
6
6
|
ref?: React.RefObject<HTMLElement | null>;
|
|
7
7
|
}>;
|
|
8
|
-
declare const WithAddress: import("storybook/internal/csf").AnnotatedStoryFn<import("@storybook/react-vite").ReactRenderer, import("./RenderRowBox.tsx").AddressRenderRowBoxProps & {
|
|
8
|
+
declare const WithAddress: import(".store/storybook-virtual-997ab3c959/package/internal/csf").AnnotatedStoryFn<import("@storybook/react-vite").ReactRenderer, import("./RenderRowBox.tsx").AddressRenderRowBoxProps & {
|
|
9
9
|
ref?: React.RefObject<HTMLElement | null>;
|
|
10
10
|
}>;
|
|
11
|
-
declare const WithIcon: import("storybook/internal/csf").AnnotatedStoryFn<import("@storybook/react-vite").ReactRenderer, import("./RenderRowBox.tsx").AddressRenderRowBoxProps & {
|
|
11
|
+
declare const WithIcon: import(".store/storybook-virtual-997ab3c959/package/internal/csf").AnnotatedStoryFn<import("@storybook/react-vite").ReactRenderer, import("./RenderRowBox.tsx").AddressRenderRowBoxProps & {
|
|
12
12
|
ref?: React.RefObject<HTMLElement | null>;
|
|
13
13
|
}>;
|
|
14
|
-
declare const WithIconOnly: import("storybook/internal/csf").AnnotatedStoryFn<import("@storybook/react-vite").ReactRenderer, import("./RenderRowBox.tsx").AddressRenderRowBoxProps & {
|
|
14
|
+
declare const WithIconOnly: import(".store/storybook-virtual-997ab3c959/package/internal/csf").AnnotatedStoryFn<import("@storybook/react-vite").ReactRenderer, import("./RenderRowBox.tsx").AddressRenderRowBoxProps & {
|
|
15
15
|
ref?: React.RefObject<HTMLElement | null>;
|
|
16
16
|
}>;
|
|
17
|
-
declare const WithFavorite: import("storybook/internal/csf").AnnotatedStoryFn<import("@storybook/react-vite").ReactRenderer, import("./RenderRowBox.tsx").AddressRenderRowBoxProps & {
|
|
17
|
+
declare const WithFavorite: import(".store/storybook-virtual-997ab3c959/package/internal/csf").AnnotatedStoryFn<import("@storybook/react-vite").ReactRenderer, import("./RenderRowBox.tsx").AddressRenderRowBoxProps & {
|
|
18
18
|
ref?: React.RefObject<HTMLElement | null>;
|
|
19
19
|
}>;
|
|
20
|
-
declare const WithFavoriteAlias: import("storybook/internal/csf").AnnotatedStoryFn<import("@storybook/react-vite").ReactRenderer, import("./RenderRowBox.tsx").AddressRenderRowBoxProps & {
|
|
20
|
+
declare const WithFavoriteAlias: import(".store/storybook-virtual-997ab3c959/package/internal/csf").AnnotatedStoryFn<import("@storybook/react-vite").ReactRenderer, import("./RenderRowBox.tsx").AddressRenderRowBoxProps & {
|
|
21
21
|
ref?: React.RefObject<HTMLElement | null>;
|
|
22
22
|
}>;
|
|
23
|
-
declare const WithChildren: import("storybook/internal/csf").AnnotatedStoryFn<import("@storybook/react-vite").ReactRenderer, import("./RenderRowBox.tsx").AddressRenderRowBoxProps & {
|
|
23
|
+
declare const WithChildren: import(".store/storybook-virtual-997ab3c959/package/internal/csf").AnnotatedStoryFn<import("@storybook/react-vite").ReactRenderer, import("./RenderRowBox.tsx").AddressRenderRowBoxProps & {
|
|
24
24
|
ref?: React.RefObject<HTMLElement | null>;
|
|
25
25
|
}>;
|
|
26
26
|
export { Default, WithAddress, WithChildren, WithFavorite, WithFavoriteAlias, WithIcon, WithIconOnly, };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FavoriteIconButton.d.ts","sourceRoot":"","sources":["../../../../src/components/favorite/FavoriteIconButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAKpD,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"FavoriteIconButton.d.ts","sourceRoot":"","sources":["../../../../src/components/favorite/FavoriteIconButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAKpD,OAAO,KAAK,EACE,iBAAiB,EAC9B,MAAM,OAAO,CAAA;AACd,OAAO,KAA2B,MAAM,OAAO,CAAA;AAE/C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAMxD,MAAM,WAAW,uBAAwB,SAAQ,iBAAiB,EAAE,eAAe;IACjF,QAAQ,CAAC,EAAE,iBAAiB,CAAC,UAAU,CAAC,CAAA;IACxC,IAAI,CAAC,EAAE,iBAAiB,CAAC,MAAM,CAAC,CAAA;IAChC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,SAAS,CAAC,EAAE,iBAAiB,CAAC,cAAc,CAAC,CAAA;CAC9C;AAED,eAAO,MAAM,kBAAkB;kFAE5B,uBAAuB,GAAG;QAAE,GAAG,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAAA;KAAE;;CAgD/E,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Popper.d.ts","sourceRoot":"","sources":["../../../../src/components/favorite/Popper.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAIhD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAMtC,MAAM,WAAW,mBAAoB,SAAQ,WAAW;IACtD,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,WAAW,CAAC,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAA;IAC3C,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,KAAK,IAAI,CAAA;IACtD,iBAAiB,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,gBAAgB,CAAC,EAAE,OAAO,KAAK,IAAI,CAAA;CACxE;AACD,eAAO,MAAM,cAAc;+FAGtB,mBAAmB;;
|
|
1
|
+
{"version":3,"file":"Popper.d.ts","sourceRoot":"","sources":["../../../../src/components/favorite/Popper.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAIhD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAMtC,MAAM,WAAW,mBAAoB,SAAQ,WAAW;IACtD,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,WAAW,CAAC,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAA;IAC3C,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,KAAK,IAAI,CAAA;IACtD,iBAAiB,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,gBAAgB,CAAC,EAAE,OAAO,KAAK,IAAI,CAAA;CACxE;AACD,eAAO,MAAM,cAAc;+FAGtB,mBAAmB;;CAoCvB,CAAA"}
|
package/dist/browser/index.mjs
CHANGED
|
@@ -1,154 +1,176 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
|
|
4
1
|
// src/components/favorite/FavoriteIconButton.tsx
|
|
5
|
-
import { IconButton, styled
|
|
2
|
+
import { IconButton, styled } from "@mui/material";
|
|
6
3
|
import { useResetState } from "@xylabs/react-hooks";
|
|
7
4
|
import { useEvent } from "@xyo-network/react-event";
|
|
8
5
|
import { useShareForwardedRef } from "@xyo-network/react-shared";
|
|
9
|
-
import
|
|
6
|
+
import { useRef, useState as useState2 } from "react";
|
|
10
7
|
|
|
11
8
|
// src/components/lib/FavoriteItemEvent.ts
|
|
12
|
-
var generateFavoriteEvent =
|
|
9
|
+
var generateFavoriteEvent = (favorite, favoriteType, favoriteValue, name) => ({
|
|
13
10
|
favorite: !!favorite,
|
|
14
11
|
favoriteType,
|
|
15
12
|
favoriteValue,
|
|
16
13
|
name
|
|
17
|
-
})
|
|
14
|
+
});
|
|
18
15
|
|
|
19
16
|
// src/components/favorite/FavoriteToggleSVG.tsx
|
|
20
17
|
import { Star as StarIcon, StarBorder as StarBorderIcon } from "@mui/icons-material";
|
|
21
|
-
import
|
|
22
|
-
var FavoriteToggleSVG =
|
|
23
|
-
className: "favorite-icon",
|
|
24
|
-
component: "svg",
|
|
25
|
-
color: "secondary",
|
|
26
|
-
fontSize: "small"
|
|
27
|
-
}) : /* @__PURE__ */ React.createElement(StarBorderIcon, {
|
|
28
|
-
className: "favorite-icon",
|
|
29
|
-
fontSize: "small"
|
|
30
|
-
})), "FavoriteToggleSVG");
|
|
18
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
19
|
+
var FavoriteToggleSVG = ({ favorite }) => /* @__PURE__ */ jsx(Fragment, { children: favorite ? /* @__PURE__ */ jsx(StarIcon, { className: "favorite-icon", component: "svg", color: "secondary", fontSize: "small" }) : /* @__PURE__ */ jsx(StarBorderIcon, { className: "favorite-icon", fontSize: "small" }) });
|
|
31
20
|
|
|
32
21
|
// src/components/favorite/lib/PopperId.ts
|
|
33
22
|
var popperId = "favorite-popper";
|
|
34
23
|
|
|
35
24
|
// src/components/favorite/Popper.tsx
|
|
36
|
-
import {
|
|
37
|
-
|
|
25
|
+
import {
|
|
26
|
+
Card,
|
|
27
|
+
CardContent,
|
|
28
|
+
ClickAwayListener,
|
|
29
|
+
Fade,
|
|
30
|
+
Popper,
|
|
31
|
+
TextField
|
|
32
|
+
} from "@mui/material";
|
|
33
|
+
import { useState } from "react";
|
|
38
34
|
|
|
39
35
|
// src/components/favorite/PopperButtonGroup.tsx
|
|
40
36
|
import { Delete as DeleteIcon, Star as StarIcon2 } from "@mui/icons-material";
|
|
41
37
|
import { Button, ButtonGroup } from "@mui/material";
|
|
42
|
-
import
|
|
43
|
-
var PopperButtonGroup =
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
38
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
39
|
+
var PopperButtonGroup = ({
|
|
40
|
+
name,
|
|
41
|
+
onConfirmFavorite,
|
|
42
|
+
favorite,
|
|
43
|
+
...props
|
|
44
|
+
}) => {
|
|
45
|
+
return /* @__PURE__ */ jsxs(ButtonGroup, { ...props, children: [
|
|
46
|
+
/* @__PURE__ */ jsx2(
|
|
47
|
+
Button,
|
|
48
|
+
{
|
|
49
|
+
title: "Save Favorite",
|
|
50
|
+
variant: "contained",
|
|
51
|
+
onClick: (e) => {
|
|
52
|
+
e.stopPropagation();
|
|
53
|
+
onConfirmFavorite?.(name, true);
|
|
54
|
+
},
|
|
55
|
+
children: /* @__PURE__ */ jsx2(StarIcon2, {})
|
|
56
|
+
}
|
|
57
|
+
),
|
|
58
|
+
favorite ? /* @__PURE__ */ jsx2(
|
|
59
|
+
Button,
|
|
60
|
+
{
|
|
61
|
+
title: "Remove Favorite",
|
|
62
|
+
variant: "contained",
|
|
63
|
+
onClick: (e) => {
|
|
64
|
+
e.stopPropagation();
|
|
65
|
+
onConfirmFavorite?.(name, false);
|
|
66
|
+
},
|
|
67
|
+
children: /* @__PURE__ */ jsx2(DeleteIcon, {})
|
|
68
|
+
}
|
|
69
|
+
) : null
|
|
70
|
+
] });
|
|
71
|
+
};
|
|
60
72
|
|
|
61
73
|
// src/components/favorite/Popper.tsx
|
|
62
|
-
|
|
74
|
+
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
75
|
+
var FavoritePopper = ({
|
|
76
|
+
ref,
|
|
77
|
+
name: nameProp,
|
|
78
|
+
favorite,
|
|
79
|
+
favoriteRef,
|
|
80
|
+
onClickAway,
|
|
81
|
+
onConfirmFavorite,
|
|
82
|
+
...props
|
|
83
|
+
}) => {
|
|
63
84
|
const [name, setName] = useState(() => nameProp);
|
|
64
|
-
return /* @__PURE__ */
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
85
|
+
return /* @__PURE__ */ jsx3(ClickAwayListener, { onClickAway: onClickAway ?? (() => null), children: /* @__PURE__ */ jsx3(
|
|
86
|
+
Popper,
|
|
87
|
+
{
|
|
88
|
+
id: popperId,
|
|
89
|
+
anchorEl: favoriteRef?.current,
|
|
90
|
+
onClick: (e) => e.stopPropagation(),
|
|
91
|
+
onTouchStart: (e) => e.stopPropagation(),
|
|
92
|
+
transition: true,
|
|
93
|
+
style: { zIndex: 9999 },
|
|
94
|
+
ref,
|
|
95
|
+
...props,
|
|
96
|
+
children: ({ TransitionProps }) => /* @__PURE__ */ jsx3(Fade, { ...TransitionProps, timeout: 350, children: /* @__PURE__ */ jsx3(Card, { children: /* @__PURE__ */ jsxs2(CardContent, { sx: { display: "flex", gap: 1 }, children: [
|
|
97
|
+
/* @__PURE__ */ jsx3(
|
|
98
|
+
TextField,
|
|
99
|
+
{
|
|
100
|
+
autoFocus: true,
|
|
101
|
+
label: "Favorite Name",
|
|
102
|
+
placeholder: "optional",
|
|
103
|
+
size: "small",
|
|
104
|
+
value: name ?? "",
|
|
105
|
+
onChange: (e) => setName(e.target.value)
|
|
106
|
+
}
|
|
107
|
+
),
|
|
108
|
+
/* @__PURE__ */ jsx3(PopperButtonGroup, { favorite, onConfirmFavorite, name })
|
|
109
|
+
] }) }) })
|
|
81
110
|
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
label: "Favorite Name",
|
|
85
|
-
placeholder: "optional",
|
|
86
|
-
size: "small",
|
|
87
|
-
value: name ?? "",
|
|
88
|
-
onChange: /* @__PURE__ */ __name((e) => setName(e.target.value), "onChange")
|
|
89
|
-
}), /* @__PURE__ */ React3.createElement(PopperButtonGroup, {
|
|
90
|
-
favorite,
|
|
91
|
-
onConfirmFavorite,
|
|
92
|
-
name
|
|
93
|
-
}))))));
|
|
94
|
-
}, "FavoritePopper");
|
|
111
|
+
) });
|
|
112
|
+
};
|
|
95
113
|
FavoritePopper.displayName = "FavoritePopper";
|
|
96
|
-
var PopperStyled = styled(Popper, {
|
|
97
|
-
name: "PopperStyled"
|
|
98
|
-
})(() => ({
|
|
99
|
-
zIndex: 9999
|
|
100
|
-
}));
|
|
101
114
|
|
|
102
115
|
// src/components/favorite/FavoriteIconButton.tsx
|
|
103
|
-
|
|
116
|
+
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
117
|
+
var FavoriteIconButton = ({
|
|
118
|
+
ref,
|
|
119
|
+
children,
|
|
120
|
+
favorite: favoriteProp,
|
|
121
|
+
name,
|
|
122
|
+
valueType,
|
|
123
|
+
value,
|
|
124
|
+
...props
|
|
125
|
+
}) => {
|
|
104
126
|
const [openPopper, setOpenPopper] = useState2(false);
|
|
105
127
|
const [favorite, setFavorite] = useResetState(favoriteProp);
|
|
106
128
|
const sharedRef = useShareForwardedRef(ref);
|
|
107
129
|
const [buttonRef, dispatch] = useEvent(void 0, sharedRef);
|
|
108
|
-
const onConfirmFavorite =
|
|
130
|
+
const onConfirmFavorite = (name2, newFavoriteState) => {
|
|
109
131
|
const favoriteEvent = generateFavoriteEvent(!!newFavoriteState, valueType, value, name2);
|
|
110
132
|
dispatch("address", "favorite", JSON.stringify(favoriteEvent));
|
|
111
133
|
setFavorite(newFavoriteState);
|
|
112
134
|
setOpenPopper(false);
|
|
113
|
-
}
|
|
135
|
+
};
|
|
114
136
|
const starRef = useRef(null);
|
|
115
|
-
return /* @__PURE__ */
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
p: 0.25
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
}
|
|
137
|
+
return /* @__PURE__ */ jsxs3(
|
|
138
|
+
IconButtonCondensed,
|
|
139
|
+
{
|
|
140
|
+
"aria-describedby": popperId,
|
|
141
|
+
ref: buttonRef,
|
|
142
|
+
onClick: (event) => {
|
|
143
|
+
event.stopPropagation();
|
|
144
|
+
setOpenPopper(!openPopper);
|
|
145
|
+
},
|
|
146
|
+
onTouchStart: (event) => {
|
|
147
|
+
event.stopPropagation();
|
|
148
|
+
setOpenPopper(!openPopper);
|
|
149
|
+
},
|
|
150
|
+
onMouseDown: (event) => event.stopPropagation(),
|
|
151
|
+
sx: { lineHeight: 0, p: 0.25 },
|
|
152
|
+
...props,
|
|
153
|
+
children: [
|
|
154
|
+
/* @__PURE__ */ jsx4("span", { ref: starRef, children: /* @__PURE__ */ jsx4(FavoriteToggleSVG, { favorite }) }),
|
|
155
|
+
/* @__PURE__ */ jsx4(
|
|
156
|
+
FavoritePopper,
|
|
157
|
+
{
|
|
158
|
+
sx: { zIndex: 1301 },
|
|
159
|
+
name,
|
|
160
|
+
favorite,
|
|
161
|
+
favoriteRef: starRef,
|
|
162
|
+
open: openPopper,
|
|
163
|
+
onConfirmFavorite,
|
|
164
|
+
onClickAway: () => setOpenPopper(false)
|
|
165
|
+
}
|
|
166
|
+
),
|
|
167
|
+
children
|
|
168
|
+
]
|
|
169
|
+
}
|
|
170
|
+
);
|
|
171
|
+
};
|
|
148
172
|
FavoriteIconButton.displayName = "FavoriteIconButton";
|
|
149
|
-
var IconButtonCondensed =
|
|
150
|
-
name: "IconButtonCondensed"
|
|
151
|
-
})(({ theme }) => ({
|
|
173
|
+
var IconButtonCondensed = styled(IconButton, { name: "IconButtonCondensed" })(({ theme }) => ({
|
|
152
174
|
lineHeight: 0,
|
|
153
175
|
padding: theme.spacing(0.25)
|
|
154
176
|
}));
|
|
@@ -159,43 +181,53 @@ import { FlexRow } from "@xylabs/react-flexbox";
|
|
|
159
181
|
import { Identicon } from "@xylabs/react-identicon";
|
|
160
182
|
import { useEvent as useEvent2 } from "@xyo-network/react-event";
|
|
161
183
|
import { EllipsizeBox, useShareForwardedRef as useShareForwardedRef2 } from "@xyo-network/react-shared";
|
|
162
|
-
import
|
|
163
|
-
var AddressRenderRowBox =
|
|
184
|
+
import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
185
|
+
var AddressRenderRowBox = ({
|
|
186
|
+
ref,
|
|
187
|
+
address,
|
|
188
|
+
children,
|
|
189
|
+
disableSharedRef,
|
|
190
|
+
favorite: favoriteProp = false,
|
|
191
|
+
iconOnly,
|
|
192
|
+
iconSize = 24,
|
|
193
|
+
icons,
|
|
194
|
+
name,
|
|
195
|
+
showFavorite = false,
|
|
196
|
+
...props
|
|
197
|
+
}) => {
|
|
164
198
|
const theme = useTheme();
|
|
165
199
|
const sharedRef = useShareForwardedRef2(ref);
|
|
166
200
|
const [elementRef, dispatch] = useEvent2(void 0, sharedRef);
|
|
167
|
-
return /* @__PURE__ */
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
201
|
+
return /* @__PURE__ */ jsxs4(
|
|
202
|
+
FlexRow,
|
|
203
|
+
{
|
|
204
|
+
gap: 2,
|
|
205
|
+
justifyContent: "flex-start",
|
|
206
|
+
ref: elementRef,
|
|
207
|
+
onClick: () => {
|
|
208
|
+
if (address) {
|
|
209
|
+
dispatch("address", "click", address);
|
|
210
|
+
}
|
|
211
|
+
},
|
|
212
|
+
...props,
|
|
213
|
+
children: [
|
|
214
|
+
icons && address ? /* @__PURE__ */ jsx5(ListItemIcon, { sx: { minWidth: 0 }, children: /* @__PURE__ */ jsx5(Identicon, { size: iconSize, value: address }) }) : null,
|
|
215
|
+
iconOnly ? null : /* @__PURE__ */ jsx5(
|
|
216
|
+
EllipsizeBox,
|
|
217
|
+
{
|
|
218
|
+
disableSharedRef,
|
|
219
|
+
ellipsisPosition: "end",
|
|
220
|
+
width: "100%",
|
|
221
|
+
typographyProps: { fontSize: theme.typography.body1.fontSize },
|
|
222
|
+
children: name ?? address
|
|
223
|
+
}
|
|
224
|
+
),
|
|
225
|
+
children,
|
|
226
|
+
showFavorite && address ? /* @__PURE__ */ jsx5(FavoriteIconButton, { name, size: "small", value: address, valueType: "address", favorite: favoriteProp }) : null
|
|
227
|
+
]
|
|
180
228
|
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
value: address
|
|
184
|
-
})) : null, iconOnly ? null : /* @__PURE__ */ React5.createElement(EllipsizeBox, {
|
|
185
|
-
disableSharedRef,
|
|
186
|
-
ellipsisPosition: "end",
|
|
187
|
-
width: "100%",
|
|
188
|
-
typographyProps: {
|
|
189
|
-
fontSize: theme.typography.body1.fontSize
|
|
190
|
-
}
|
|
191
|
-
}, name ?? address), children, showFavorite && address ? /* @__PURE__ */ React5.createElement(FavoriteIconButton, {
|
|
192
|
-
name,
|
|
193
|
-
size: "small",
|
|
194
|
-
value: address,
|
|
195
|
-
valueType: "address",
|
|
196
|
-
favorite: favoriteProp
|
|
197
|
-
}) : null);
|
|
198
|
-
}, "AddressRenderRowBox");
|
|
229
|
+
);
|
|
230
|
+
};
|
|
199
231
|
AddressRenderRowBox.displayName = "AddressRenderRowBox";
|
|
200
232
|
export {
|
|
201
233
|
AddressRenderRowBox,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/favorite/FavoriteIconButton.tsx","../../src/components/lib/FavoriteItemEvent.ts","../../src/components/favorite/FavoriteToggleSVG.tsx","../../src/components/favorite/lib/PopperId.ts","../../src/components/favorite/Popper.tsx","../../src/components/favorite/PopperButtonGroup.tsx","../../src/components/RenderRowBox.tsx"],"sourcesContent":["import type { IconButtonProps } from '@mui/material'\nimport { IconButton, styled } from '@mui/material'\nimport { useResetState } from '@xylabs/react-hooks'\nimport { useEvent } from '@xyo-network/react-event'\nimport { useShareForwardedRef } from '@xyo-network/react-shared'\nimport type { PropsWithChildren } from 'react'\nimport React, { useRef, useState } from 'react'\n\nimport type { FavoriteItemEvent } from '../lib/index.ts'\nimport { generateFavoriteEvent } from '../lib/index.ts'\nimport { FavoriteToggleSVG } from './FavoriteToggleSVG.tsx'\nimport { popperId } from './lib/index.ts'\nimport { FavoritePopper } from './Popper.tsx'\n\nexport interface FavoriteIconButtonProps extends PropsWithChildren, IconButtonProps {\n favorite?: FavoriteItemEvent['favorite']\n name?: FavoriteItemEvent['name']\n value?: string\n valueType?: FavoriteItemEvent['favoriteType']\n}\n\nexport const FavoriteIconButton = ({\n ref, children, favorite: favoriteProp, name, valueType, value, ...props\n}: FavoriteIconButtonProps & { ref?: React.RefObject<HTMLButtonElement | null> }) => {\n const [openPopper, setOpenPopper] = useState(false)\n\n const [favorite, setFavorite] = useResetState(favoriteProp)\n\n const sharedRef = useShareForwardedRef(ref)\n const [buttonRef, dispatch] = useEvent(undefined, sharedRef)\n\n const onConfirmFavorite = (name?: string, newFavoriteState?: boolean) => {\n const favoriteEvent = generateFavoriteEvent(!!newFavoriteState, valueType, value, name)\n dispatch('address', 'favorite', JSON.stringify(favoriteEvent))\n setFavorite(newFavoriteState)\n setOpenPopper(false)\n }\n\n const starRef = useRef<HTMLSpanElement>(null)\n\n return (\n <IconButtonCondensed\n aria-describedby={popperId}\n ref={buttonRef}\n onClick={(event) => {\n event.stopPropagation()\n setOpenPopper(!openPopper)\n }}\n onTouchStart={(event) => {\n event.stopPropagation()\n setOpenPopper(!openPopper)\n }}\n onMouseDown={e => e.stopPropagation()}\n sx={{ lineHeight: 0, p: 0.25 }}\n {...props}\n >\n <span ref={starRef}>\n <FavoriteToggleSVG favorite={favorite} />\n </span>\n <FavoritePopper\n sx={{ zIndex: 1301 }}\n name={name}\n favorite={favorite}\n favoriteRef={starRef}\n open={openPopper}\n onConfirmFavorite={onConfirmFavorite}\n onClickAway={() => setOpenPopper(false)}\n />\n {children}\n </IconButtonCondensed>\n )\n}\n\nFavoriteIconButton.displayName = 'FavoriteIconButton'\n\nconst IconButtonCondensed = styled(IconButton, { name: 'IconButtonCondensed' })(({ theme }) => ({\n lineHeight: 0,\n padding: theme.spacing(0.25),\n}))\n","export interface FavoriteItemEvent {\n favorite?: boolean\n favoriteType?: FavoriteType\n favoriteValue?: string\n name?: string\n}\n\nexport type FavoriteType = 'address' | 'schema' | 'hash'\n\nexport const generateFavoriteEvent = (favorite?: boolean, favoriteType?: FavoriteType, favoriteValue?: string, name?: string): FavoriteItemEvent => ({\n favorite: !!favorite,\n favoriteType,\n favoriteValue,\n name,\n})\n","import { Star as StarIcon, StarBorder as StarBorderIcon } from '@mui/icons-material'\nimport React from 'react'\n\nexport const FavoriteToggleSVG: React.FC<{ favorite?: boolean }> = ({ favorite }) => (\n <>\n {favorite\n ? <StarIcon className=\"favorite-icon\" component=\"svg\" color=\"secondary\" fontSize=\"small\" />\n : <StarBorderIcon className=\"favorite-icon\" fontSize=\"small\" />}\n </>\n)\n","export const popperId = 'favorite-popper'\n","import type { PopperProps } from '@mui/material'\nimport {\n Card, CardContent, ClickAwayListener, Fade, Popper, styled, TextField,\n} from '@mui/material'\nimport type { RefObject } from 'react'\nimport React, { useState } from 'react'\n\nimport { popperId } from './lib/index.ts'\nimport { PopperButtonGroup } from './PopperButtonGroup.tsx'\n\nexport interface FavoritePopperProps extends PopperProps {\n favorite?: boolean\n favoriteRef?: RefObject<HTMLElement | null>\n name?: string\n onClickAway?: (event: MouseEvent | TouchEvent) => void\n onConfirmFavorite?: (name?: string, newFavoriteState?: boolean) => void\n}\nexport const FavoritePopper = (\n {\n ref, name: nameProp, favorite, favoriteRef, onClickAway, onConfirmFavorite, ...props\n }: FavoritePopperProps,\n) => {\n const [name, setName] = useState(() => nameProp)\n\n return (\n <ClickAwayListener onClickAway={onClickAway ?? (() => null)}>\n <PopperStyled\n id={popperId}\n anchorEl={favoriteRef?.current}\n onClick={e => e.stopPropagation()}\n onTouchStart={e => e.stopPropagation()}\n transition\n ref={ref}\n {...props}\n >\n {({ TransitionProps }) => (\n <Fade {...TransitionProps} timeout={350}>\n <Card>\n <CardContent sx={{ display: 'flex', gap: 1 }}>\n <TextField\n autoFocus\n label=\"Favorite Name\"\n placeholder=\"optional\"\n size=\"small\"\n value={name ?? ''}\n onChange={e => setName(e.target.value)}\n />\n <PopperButtonGroup favorite={favorite} onConfirmFavorite={onConfirmFavorite} name={name} />\n </CardContent>\n </Card>\n </Fade>\n )}\n </PopperStyled>\n </ClickAwayListener>\n )\n}\n\nFavoritePopper.displayName = 'FavoritePopper'\n\n// Ensure the popper is over all other mui portal elements\nconst PopperStyled = styled(Popper, { name: 'PopperStyled' })(() => ({ zIndex: 9999 }))\n","import { Delete as DeleteIcon, Star as StarIcon } from '@mui/icons-material'\nimport type { ButtonGroupProps } from '@mui/material'\nimport { Button, ButtonGroup } from '@mui/material'\nimport React from 'react'\n\nexport interface FavoritePopperProps extends ButtonGroupProps {\n favorite?: boolean\n name?: string\n onConfirmFavorite?: (name?: string, newFavoriteState?: boolean) => void\n}\n\nexport const PopperButtonGroup: React.FC<FavoritePopperProps> = ({\n name, onConfirmFavorite, favorite, ...props\n}) => {\n return (\n <ButtonGroup {...props}>\n <Button\n title=\"Save Favorite\"\n variant=\"contained\"\n onClick={(e) => {\n e.stopPropagation()\n onConfirmFavorite?.(name, true)\n }}\n >\n <StarIcon />\n </Button>\n {favorite\n ? (\n <Button\n title=\"Remove Favorite\"\n variant=\"contained\"\n onClick={(e) => {\n e.stopPropagation()\n onConfirmFavorite?.(name, false)\n }}\n >\n <DeleteIcon />\n </Button>\n )\n : null}\n </ButtonGroup>\n )\n}\n","import { ListItemIcon, useTheme } from '@mui/material'\nimport type { FlexBoxProps } from '@xylabs/react-flexbox'\nimport { FlexRow } from '@xylabs/react-flexbox'\nimport { Identicon } from '@xylabs/react-identicon'\nimport { useEvent } from '@xyo-network/react-event'\nimport { EllipsizeBox, useShareForwardedRef } from '@xyo-network/react-shared'\nimport React from 'react'\n\nimport { FavoriteIconButton } from './favorite/index.ts'\n\nexport interface AddressRenderRowBoxProps extends FlexBoxProps {\n address?: string | null\n disableSharedRef?: boolean\n favorite?: boolean\n iconOnly?: boolean\n iconSize?: number\n icons?: boolean\n name?: string\n showFavorite?: boolean\n}\n\nexport const AddressRenderRowBox = (\n {\n ref, address, children, disableSharedRef, favorite: favoriteProp = false, iconOnly, iconSize = 24, icons, name, showFavorite = false, ...props\n }: AddressRenderRowBoxProps & { ref?: React.RefObject<HTMLElement | null> },\n) => {\n const theme = useTheme()\n\n const sharedRef = useShareForwardedRef(ref)\n const [elementRef, dispatch] = useEvent(undefined, sharedRef)\n\n return (\n <FlexRow\n gap={2}\n justifyContent=\"flex-start\"\n ref={elementRef}\n onClick={() => {\n if (address) {\n dispatch('address', 'click', address)\n }\n }}\n {...props}\n >\n {icons && address\n ? (\n <ListItemIcon sx={{ minWidth: 0 }}>\n <Identicon size={iconSize} value={address} />\n </ListItemIcon>\n )\n : null}\n {iconOnly\n ? null\n : (\n <EllipsizeBox\n disableSharedRef={disableSharedRef}\n ellipsisPosition=\"end\"\n width=\"100%\"\n typographyProps={{ fontSize: theme.typography.body1.fontSize }}\n >\n {name ?? address}\n </EllipsizeBox>\n )}\n {children}\n {showFavorite && address\n ? <FavoriteIconButton name={name} size=\"small\" value={address} valueType=\"address\" favorite={favoriteProp} />\n : null}\n </FlexRow>\n )\n}\n\nAddressRenderRowBox.displayName = 'AddressRenderRowBox'\n"],"mappings":";;;;AACA,SAASA,YAAYC,UAAAA,eAAc;AACnC,SAASC,qBAAqB;AAC9B,SAASC,gBAAgB;AACzB,SAASC,4BAA4B;AAErC,OAAOC,UAASC,QAAQC,YAAAA,iBAAgB;;;ACGjC,IAAMC,wBAAwB,wBAACC,UAAoBC,cAA6BC,eAAwBC,UAAsC;EACnJH,UAAU,CAAC,CAACA;EACZC;EACAC;EACAC;AACF,IALqC;;;ACTrC,SAASC,QAAQC,UAAUC,cAAcC,sBAAsB;AAC/D,OAAOC,WAAW;AAEX,IAAMC,oBAAsD,wBAAC,EAAEC,SAAQ,MAC5E,sBAAA,cAAA,MAAA,UAAA,MACGA,WACG,sBAAA,cAACC,UAAAA;EAASC,WAAU;EAAgBC,WAAU;EAAMC,OAAM;EAAYC,UAAS;KAC/E,sBAAA,cAACC,gBAAAA;EAAeJ,WAAU;EAAgBG,UAAS;KAJQ;;;ACH5D,IAAME,WAAW;;;ACCxB,SACEC,MAAMC,aAAaC,mBAAmBC,MAAMC,QAAQC,QAAQC,iBACv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WAAW,SAAShB,OAAAA;MAC/B;IACF,GAJS;IAKR,GAAGU;KAEHH,SAASP,UAEJ,gBAAAmB,OAAA,cAACK,cAAAA;IAAaC,IAAI;MAAEC,UAAU;IAAE;KAC9B,gBAAAP,OAAA,cAACQ,WAAAA;IAAUC,MAAMtB;IAAUuB,OAAO7B;QAGtC,MACHK,WACG,OAEE,gBAAAc,OAAA,cAACW,cAAAA;IACC5B;IACA6B,kBAAiB;IACjBC,OAAM;IACNC,iBAAiB;MAAEC,UAAUvB,MAAMwB,WAAWC,MAAMF;IAAS;KAE5D1B,QAAQR,OAAAA,GAGhBC,UACAQ,gBAAgBT,UACb,gBAAAmB,OAAA,cAACkB,oBAAAA;IAAmB7B;IAAYoB,MAAK;IAAQC,OAAO7B;IAASsC,WAAU;IAAUnC,UAAUC;OAC3F,IAAA;AAGV,GA/CmC;AAiDnCN,oBAAoByC,cAAc;","names":["IconButton","styled","useResetState","useEvent","useShareForwardedRef","React","useRef","useState","generateFavoriteEvent","favorite","favoriteType","favoriteValue","name","Star","StarIcon","StarBorder","StarBorderIcon","React","FavoriteToggleSVG","favorite","StarIcon","className","component","color","fontSize","StarBorderIcon","popperId","Card","CardContent","ClickAwayListener","Fade","Popper","styled","TextField","React","useState","Delete","DeleteIcon","Star","StarIcon","Button","ButtonGroup","React","PopperButtonGroup","name","onConfirmFavorite","favorite","props","React","ButtonGroup","Button","title","variant","onClick","e","stopPropagation","StarIcon","DeleteIcon","FavoritePopper","ref","name","nameProp","favorite","favoriteRef","onClickAway","onConfirmFavorite","props","setName","useState","React","ClickAwayListener","PopperStyled","id","popperId","anchorEl","current","onClick","e","stopPropagation","onTouchStart","transition","TransitionProps","Fade","timeout","Card","CardContent","sx","display","gap","TextField","autoFocus","label","placeholder","size","value","onChange","target","PopperButtonGroup","displayName","styled","Popper","zIndex","FavoriteIconButton","ref","children","favorite","favoriteProp","name","valueType","value","props","openPopper","setOpenPopper","useState","setFavorite","useResetState","sharedRef","useShareForwardedRef","buttonRef","dispatch","useEvent","undefined","onConfirmFavorite","newFavoriteState","favoriteEvent","generateFavoriteEvent","JSON","stringify","starRef","useRef","React","IconButtonCondensed","aria-describedby","popperId","onClick","event","stopPropagation","onTouchStart","onMouseDown","e","sx","lineHeight","p","span","FavoriteToggleSVG","FavoritePopper","zIndex","favoriteRef","open","onClickAway","displayName","styled","IconButton","theme","padding","spacing","ListItemIcon","useTheme","FlexRow","Identicon","useEvent","EllipsizeBox","useShareForwardedRef","React","AddressRenderRowBox","ref","address","children","disableSharedRef","favorite","favoriteProp","iconOnly","iconSize","icons","name","showFavorite","props","theme","useTheme","sharedRef","useShareForwardedRef","elementRef","dispatch","useEvent","undefined","React","FlexRow","gap","justifyContent","onClick","ListItemIcon","sx","minWidth","Identicon","size","value","EllipsizeBox","ellipsisPosition","width","typographyProps","fontSize","typography","body1","FavoriteIconButton","valueType","displayName"]}
|
|
1
|
+
{"version":3,"sources":["../../src/components/favorite/FavoriteIconButton.tsx","../../src/components/lib/FavoriteItemEvent.ts","../../src/components/favorite/FavoriteToggleSVG.tsx","../../src/components/favorite/lib/PopperId.ts","../../src/components/favorite/Popper.tsx","../../src/components/favorite/PopperButtonGroup.tsx","../../src/components/RenderRowBox.tsx"],"sourcesContent":["import type { IconButtonProps } from '@mui/material'\nimport { IconButton, styled } from '@mui/material'\nimport { useResetState } from '@xylabs/react-hooks'\nimport { useEvent } from '@xyo-network/react-event'\nimport { useShareForwardedRef } from '@xyo-network/react-shared'\nimport type {\n MouseEvent, PropsWithChildren, TouchEvent,\n} from 'react'\nimport React, { useRef, useState } from 'react'\n\nimport type { FavoriteItemEvent } from '../lib/index.ts'\nimport { generateFavoriteEvent } from '../lib/index.ts'\nimport { FavoriteToggleSVG } from './FavoriteToggleSVG.tsx'\nimport { popperId } from './lib/index.ts'\nimport { FavoritePopper } from './Popper.tsx'\n\nexport interface FavoriteIconButtonProps extends PropsWithChildren, IconButtonProps {\n favorite?: FavoriteItemEvent['favorite']\n name?: FavoriteItemEvent['name']\n value?: string\n valueType?: FavoriteItemEvent['favoriteType']\n}\n\nexport const FavoriteIconButton = ({\n ref, children, favorite: favoriteProp, name, valueType, value, ...props\n}: FavoriteIconButtonProps & { ref?: React.RefObject<HTMLButtonElement | null> }) => {\n const [openPopper, setOpenPopper] = useState(false)\n\n const [favorite, setFavorite] = useResetState(favoriteProp)\n\n const sharedRef = useShareForwardedRef(ref)\n const [buttonRef, dispatch] = useEvent(undefined, sharedRef)\n\n const onConfirmFavorite = (name?: string, newFavoriteState?: boolean) => {\n const favoriteEvent = generateFavoriteEvent(!!newFavoriteState, valueType, value, name)\n dispatch('address', 'favorite', JSON.stringify(favoriteEvent))\n setFavorite(newFavoriteState)\n setOpenPopper(false)\n }\n\n const starRef = useRef<HTMLSpanElement>(null)\n\n return (\n <IconButtonCondensed\n aria-describedby={popperId}\n ref={buttonRef}\n onClick={(event: MouseEvent) => {\n event.stopPropagation()\n setOpenPopper(!openPopper)\n }}\n onTouchStart={(event: TouchEvent) => {\n event.stopPropagation()\n setOpenPopper(!openPopper)\n }}\n onMouseDown={(event: MouseEvent) => event.stopPropagation()}\n sx={{ lineHeight: 0, p: 0.25 }}\n {...props}\n >\n <span ref={starRef}>\n <FavoriteToggleSVG favorite={favorite} />\n </span>\n <FavoritePopper\n sx={{ zIndex: 1301 }}\n name={name}\n favorite={favorite}\n favoriteRef={starRef}\n open={openPopper}\n onConfirmFavorite={onConfirmFavorite}\n onClickAway={() => setOpenPopper(false)}\n />\n {children}\n </IconButtonCondensed>\n )\n}\n\nFavoriteIconButton.displayName = 'FavoriteIconButton'\n\nconst IconButtonCondensed = styled(IconButton, { name: 'IconButtonCondensed' })(({ theme }) => ({\n lineHeight: 0,\n padding: theme.spacing(0.25),\n}))\n","export interface FavoriteItemEvent {\n favorite?: boolean\n favoriteType?: FavoriteType\n favoriteValue?: string\n name?: string\n}\n\nexport type FavoriteType = 'address' | 'schema' | 'hash'\n\nexport const generateFavoriteEvent = (favorite?: boolean, favoriteType?: FavoriteType, favoriteValue?: string, name?: string): FavoriteItemEvent => ({\n favorite: !!favorite,\n favoriteType,\n favoriteValue,\n name,\n})\n","import { Star as StarIcon, StarBorder as StarBorderIcon } from '@mui/icons-material'\nimport React from 'react'\n\nexport const FavoriteToggleSVG: React.FC<{ favorite?: boolean }> = ({ favorite }) => (\n <>\n {favorite\n ? <StarIcon className=\"favorite-icon\" component=\"svg\" color=\"secondary\" fontSize=\"small\" />\n : <StarBorderIcon className=\"favorite-icon\" fontSize=\"small\" />}\n </>\n)\n","export const popperId = 'favorite-popper'\n","import type { PopperProps } from '@mui/material'\nimport {\n Card, CardContent, ClickAwayListener, Fade, Popper, TextField,\n} from '@mui/material'\nimport type { RefObject } from 'react'\nimport React, { useState } from 'react'\n\nimport { popperId } from './lib/index.ts'\nimport { PopperButtonGroup } from './PopperButtonGroup.tsx'\n\nexport interface FavoritePopperProps extends PopperProps {\n favorite?: boolean\n favoriteRef?: RefObject<HTMLElement | null>\n name?: string\n onClickAway?: (event: MouseEvent | TouchEvent) => void\n onConfirmFavorite?: (name?: string, newFavoriteState?: boolean) => void\n}\nexport const FavoritePopper = (\n {\n ref, name: nameProp, favorite, favoriteRef, onClickAway, onConfirmFavorite, ...props\n }: FavoritePopperProps,\n) => {\n const [name, setName] = useState(() => nameProp)\n\n return (\n <ClickAwayListener onClickAway={onClickAway ?? (() => null)}>\n <Popper\n id={popperId}\n anchorEl={favoriteRef?.current}\n onClick={e => e.stopPropagation()}\n onTouchStart={e => e.stopPropagation()}\n transition\n style={{ zIndex: 9999 }}\n ref={ref}\n {...props}\n >\n {({ TransitionProps }) => (\n <Fade {...TransitionProps} timeout={350}>\n <Card>\n <CardContent sx={{ display: 'flex', gap: 1 }}>\n <TextField\n autoFocus\n label=\"Favorite Name\"\n placeholder=\"optional\"\n size=\"small\"\n value={name ?? ''}\n onChange={e => setName(e.target.value)}\n />\n <PopperButtonGroup favorite={favorite} onConfirmFavorite={onConfirmFavorite} name={name} />\n </CardContent>\n </Card>\n </Fade>\n )}\n </Popper>\n </ClickAwayListener>\n )\n}\n\nFavoritePopper.displayName = 'FavoritePopper'\n","import { Delete as DeleteIcon, Star as StarIcon } from '@mui/icons-material'\nimport type { ButtonGroupProps } from '@mui/material'\nimport { Button, ButtonGroup } from '@mui/material'\nimport React from 'react'\n\nexport interface FavoritePopperProps extends ButtonGroupProps {\n favorite?: boolean\n name?: string\n onConfirmFavorite?: (name?: string, newFavoriteState?: boolean) => void\n}\n\nexport const PopperButtonGroup: React.FC<FavoritePopperProps> = ({\n name, onConfirmFavorite, favorite, ...props\n}) => {\n return (\n <ButtonGroup {...props}>\n <Button\n title=\"Save Favorite\"\n variant=\"contained\"\n onClick={(e) => {\n e.stopPropagation()\n onConfirmFavorite?.(name, true)\n }}\n >\n <StarIcon />\n </Button>\n {favorite\n ? (\n <Button\n title=\"Remove Favorite\"\n variant=\"contained\"\n onClick={(e) => {\n e.stopPropagation()\n onConfirmFavorite?.(name, false)\n }}\n >\n <DeleteIcon />\n </Button>\n )\n : null}\n </ButtonGroup>\n )\n}\n","import { ListItemIcon, useTheme } from '@mui/material'\nimport type { FlexBoxProps } from '@xylabs/react-flexbox'\nimport { FlexRow } from '@xylabs/react-flexbox'\nimport { Identicon } from '@xylabs/react-identicon'\nimport { useEvent } from '@xyo-network/react-event'\nimport { EllipsizeBox, useShareForwardedRef } from '@xyo-network/react-shared'\nimport React from 'react'\n\nimport { FavoriteIconButton } from './favorite/index.ts'\n\nexport interface AddressRenderRowBoxProps extends FlexBoxProps {\n address?: string | null\n disableSharedRef?: boolean\n favorite?: boolean\n iconOnly?: boolean\n iconSize?: number\n icons?: boolean\n name?: string\n showFavorite?: boolean\n}\n\nexport const AddressRenderRowBox = (\n {\n ref, address, children, disableSharedRef, favorite: favoriteProp = false, iconOnly, iconSize = 24, icons, name, showFavorite = false, ...props\n }: AddressRenderRowBoxProps & { ref?: React.RefObject<HTMLElement | null> },\n) => {\n const theme = useTheme()\n\n const sharedRef = useShareForwardedRef(ref)\n const [elementRef, dispatch] = useEvent(undefined, sharedRef)\n\n return (\n <FlexRow\n gap={2}\n justifyContent=\"flex-start\"\n ref={elementRef}\n onClick={() => {\n if (address) {\n dispatch('address', 'click', address)\n }\n }}\n {...props}\n >\n {icons && address\n ? (\n <ListItemIcon sx={{ minWidth: 0 }}>\n <Identicon size={iconSize} value={address} />\n </ListItemIcon>\n )\n : null}\n {iconOnly\n ? null\n : (\n <EllipsizeBox\n disableSharedRef={disableSharedRef}\n ellipsisPosition=\"end\"\n width=\"100%\"\n typographyProps={{ fontSize: theme.typography.body1.fontSize }}\n >\n {name ?? address}\n </EllipsizeBox>\n )}\n {children}\n {showFavorite && address\n ? <FavoriteIconButton name={name} size=\"small\" value={address} valueType=\"address\" favorite={favoriteProp} />\n : null}\n </FlexRow>\n )\n}\n\nAddressRenderRowBox.displayName = 'AddressRenderRowBox'\n"],"mappings":";AACA,SAAS,YAAY,cAAc;AACnC,SAAS,qBAAqB;AAC9B,SAAS,gBAAgB;AACzB,SAAS,4BAA4B;AAIrC,SAAgB,QAAQ,YAAAA,iBAAgB;;;ACCjC,IAAM,wBAAwB,CAAC,UAAoB,cAA6B,eAAwB,UAAsC;AAAA,EACnJ,UAAU,CAAC,CAAC;AAAA,EACZ;AAAA,EACA;AAAA,EACA;AACF;;;ACdA,SAAS,QAAQ,UAAU,cAAc,sBAAsB;AAI7D,mBAEM,WAFN;AADK,IAAM,oBAAsD,CAAC,EAAE,SAAS,MAC7E,gCACG,qBACG,oBAAC,YAAS,WAAU,iBAAgB,WAAU,OAAM,OAAM,aAAY,UAAS,SAAQ,IACvF,oBAAC,kBAAe,WAAU,iBAAgB,UAAS,SAAQ,GACjE;;;ACRK,IAAM,WAAW;;;ACCxB;AAAA,EACE;AAAA,EAAM;AAAA,EAAa;AAAA,EAAmB;AAAA,EAAM;AAAA,EAAQ;AAAA,OAC/C;AAEP,SAAgB,gBAAgB;;;ACLhC,SAAS,UAAU,YAAY,QAAQC,iBAAgB;AAEvD,SAAS,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MACL,SAAS,MAAM;AACb,YAAI,SAAS;AACX,mBAAS,WAAW,SAAS,OAAO;AAAA,QACtC;AAAA,MACF;AAAA,MACC,GAAG;AAAA,MAEH;AAAA,iBAAS,UAEJ,gBAAAD,KAAC,gBAAa,IAAI,EAAE,UAAU,EAAE,GAC9B,0BAAAA,KAAC,aAAU,MAAM,UAAU,OAAO,SAAS,GAC7C,IAEF;AAAA,QACH,WACG,OAEE,gBAAAA;AAAA,UAAC;AAAA;AAAA,YACC;AAAA,YACA,kBAAiB;AAAA,YACjB,OAAM;AAAA,YACN,iBAAiB,EAAE,UAAU,MAAM,WAAW,MAAM,SAAS;AAAA,YAE5D,kBAAQ;AAAA;AAAA,QACX;AAAA,QAEL;AAAA,QACA,gBAAgB,UACb,gBAAAA,KAAC,sBAAmB,MAAY,MAAK,SAAQ,OAAO,SAAS,WAAU,WAAU,UAAU,cAAc,IACzG;AAAA;AAAA;AAAA,EACN;AAEJ;AAEA,oBAAoB,cAAc;","names":["useState","StarIcon","jsx","jsx","jsxs","jsx","jsxs","useState","name","useEvent","useShareForwardedRef","jsx","jsxs","useShareForwardedRef","useEvent"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyo-network/react-address-render",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.1",
|
|
4
4
|
"description": "Common React library for all XYO projects that use React",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"xyo",
|
|
@@ -43,33 +43,36 @@
|
|
|
43
43
|
"src"
|
|
44
44
|
],
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@xylabs/react-flexbox": "
|
|
47
|
-
"@xylabs/react-hooks": "
|
|
48
|
-
"@xylabs/react-identicon": "
|
|
49
|
-
"@xyo-network/react-event": "^7.0.
|
|
50
|
-
"@xyo-network/react-shared": "^7.0.
|
|
46
|
+
"@xylabs/react-flexbox": "~7.0.1",
|
|
47
|
+
"@xylabs/react-hooks": "~7.0.1",
|
|
48
|
+
"@xylabs/react-identicon": "~7.0.1",
|
|
49
|
+
"@xyo-network/react-event": "^7.0.1",
|
|
50
|
+
"@xyo-network/react-shared": "^7.0.1"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@mui/icons-material": "
|
|
54
|
-
"@mui/material": "
|
|
55
|
-
"@storybook/react-vite": "
|
|
56
|
-
"@types/react": "
|
|
57
|
-
"@xylabs/hex": "
|
|
58
|
-
"@xylabs/ts-scripts-yarn3": "
|
|
59
|
-
"@xylabs/tsconfig
|
|
60
|
-
"
|
|
61
|
-
"react": "
|
|
62
|
-
"
|
|
63
|
-
"react
|
|
64
|
-
"
|
|
65
|
-
"
|
|
53
|
+
"@mui/icons-material": "~7.3.1",
|
|
54
|
+
"@mui/material": "~7.3.1",
|
|
55
|
+
"@storybook/react-vite": "~9.1.2",
|
|
56
|
+
"@types/react": "~19.1.10",
|
|
57
|
+
"@xylabs/hex": "~5.0.8",
|
|
58
|
+
"@xylabs/ts-scripts-yarn3": "~7.1.1",
|
|
59
|
+
"@xylabs/tsconfig": "~7.1.1",
|
|
60
|
+
"@xylabs/tsconfig-dom": "~7.1.1",
|
|
61
|
+
"@xylabs/tsconfig-react": "~7.1.1",
|
|
62
|
+
"ethers": "~6.15.0",
|
|
63
|
+
"react": "~19.1.1",
|
|
64
|
+
"react-dom": "~19.1.1",
|
|
65
|
+
"react-router-dom": "~7.8.0",
|
|
66
|
+
"storybook": "~9.1.2",
|
|
67
|
+
"typescript": "~5.9.2",
|
|
68
|
+
"vite": "~7.1.2"
|
|
66
69
|
},
|
|
67
70
|
"peerDependencies": {
|
|
68
71
|
"@mui/icons-material": ">=6 <8",
|
|
69
72
|
"@mui/material": ">=6 <8",
|
|
70
|
-
"react": "
|
|
71
|
-
"react-dom": "
|
|
72
|
-
"react-router-dom": "
|
|
73
|
+
"react": "~19",
|
|
74
|
+
"react-dom": "~19",
|
|
75
|
+
"react-router-dom": "~7"
|
|
73
76
|
},
|
|
74
77
|
"publishConfig": {
|
|
75
78
|
"access": "public"
|
|
@@ -3,7 +3,9 @@ import { IconButton, styled } from '@mui/material'
|
|
|
3
3
|
import { useResetState } from '@xylabs/react-hooks'
|
|
4
4
|
import { useEvent } from '@xyo-network/react-event'
|
|
5
5
|
import { useShareForwardedRef } from '@xyo-network/react-shared'
|
|
6
|
-
import type {
|
|
6
|
+
import type {
|
|
7
|
+
MouseEvent, PropsWithChildren, TouchEvent,
|
|
8
|
+
} from 'react'
|
|
7
9
|
import React, { useRef, useState } from 'react'
|
|
8
10
|
|
|
9
11
|
import type { FavoriteItemEvent } from '../lib/index.ts'
|
|
@@ -42,15 +44,15 @@ export const FavoriteIconButton = ({
|
|
|
42
44
|
<IconButtonCondensed
|
|
43
45
|
aria-describedby={popperId}
|
|
44
46
|
ref={buttonRef}
|
|
45
|
-
onClick={(event) => {
|
|
47
|
+
onClick={(event: MouseEvent) => {
|
|
46
48
|
event.stopPropagation()
|
|
47
49
|
setOpenPopper(!openPopper)
|
|
48
50
|
}}
|
|
49
|
-
onTouchStart={(event) => {
|
|
51
|
+
onTouchStart={(event: TouchEvent) => {
|
|
50
52
|
event.stopPropagation()
|
|
51
53
|
setOpenPopper(!openPopper)
|
|
52
54
|
}}
|
|
53
|
-
onMouseDown={
|
|
55
|
+
onMouseDown={(event: MouseEvent) => event.stopPropagation()}
|
|
54
56
|
sx={{ lineHeight: 0, p: 0.25 }}
|
|
55
57
|
{...props}
|
|
56
58
|
>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { PopperProps } from '@mui/material'
|
|
2
2
|
import {
|
|
3
|
-
Card, CardContent, ClickAwayListener, Fade, Popper,
|
|
3
|
+
Card, CardContent, ClickAwayListener, Fade, Popper, TextField,
|
|
4
4
|
} from '@mui/material'
|
|
5
5
|
import type { RefObject } from 'react'
|
|
6
6
|
import React, { useState } from 'react'
|
|
@@ -24,12 +24,13 @@ export const FavoritePopper = (
|
|
|
24
24
|
|
|
25
25
|
return (
|
|
26
26
|
<ClickAwayListener onClickAway={onClickAway ?? (() => null)}>
|
|
27
|
-
<
|
|
27
|
+
<Popper
|
|
28
28
|
id={popperId}
|
|
29
29
|
anchorEl={favoriteRef?.current}
|
|
30
30
|
onClick={e => e.stopPropagation()}
|
|
31
31
|
onTouchStart={e => e.stopPropagation()}
|
|
32
32
|
transition
|
|
33
|
+
style={{ zIndex: 9999 }}
|
|
33
34
|
ref={ref}
|
|
34
35
|
{...props}
|
|
35
36
|
>
|
|
@@ -50,12 +51,9 @@ export const FavoritePopper = (
|
|
|
50
51
|
</Card>
|
|
51
52
|
</Fade>
|
|
52
53
|
)}
|
|
53
|
-
</
|
|
54
|
+
</Popper>
|
|
54
55
|
</ClickAwayListener>
|
|
55
56
|
)
|
|
56
57
|
}
|
|
57
58
|
|
|
58
59
|
FavoritePopper.displayName = 'FavoritePopper'
|
|
59
|
-
|
|
60
|
-
// Ensure the popper is over all other mui portal elements
|
|
61
|
-
const PopperStyled = styled(Popper, { name: 'PopperStyled' })(() => ({ zIndex: 9999 }))
|