@xyo-network/react-address-render 7.5.7 → 7.5.11
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/favorite/Popper.d.ts.map +1 -1
- package/dist/browser/index.mjs +180 -142
- package/dist/browser/index.mjs.map +1 -1
- package/package.json +92 -31
- package/src/components/RenderRowBox.stories.tsx +0 -83
- package/src/components/RenderRowBox.tsx +0 -71
- package/src/components/favorite/FavoriteIconButton.tsx +0 -81
- package/src/components/favorite/FavoriteToggleSVG.tsx +0 -10
- package/src/components/favorite/Popper.tsx +0 -59
- package/src/components/favorite/PopperButtonGroup.tsx +0 -43
- package/src/components/favorite/index.ts +0 -1
- package/src/components/favorite/lib/PopperId.ts +0 -1
- package/src/components/favorite/lib/index.ts +0 -1
- package/src/components/index.ts +0 -3
- package/src/components/lib/FavoriteItemEvent.ts +0 -15
- package/src/components/lib/index.ts +0 -1
- package/src/index.ts +0 -1
|
@@ -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;;CA0CvB,CAAA"}
|
package/dist/browser/index.mjs
CHANGED
|
@@ -1,152 +1,180 @@
|
|
|
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
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 { useLayoutEffect, 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
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
85
|
+
const [anchorEl, setAnchorEl] = useState(null);
|
|
86
|
+
useLayoutEffect(() => {
|
|
87
|
+
setAnchorEl(favoriteRef?.current ?? null);
|
|
88
|
+
}, [favoriteRef]);
|
|
89
|
+
return /* @__PURE__ */ jsx3(ClickAwayListener, { onClickAway: onClickAway ?? (() => null), children: /* @__PURE__ */ jsx3(
|
|
90
|
+
Popper,
|
|
91
|
+
{
|
|
92
|
+
id: popperId,
|
|
93
|
+
anchorEl,
|
|
94
|
+
onClick: (e) => e.stopPropagation(),
|
|
95
|
+
onTouchStart: (e) => e.stopPropagation(),
|
|
96
|
+
transition: true,
|
|
97
|
+
style: { zIndex: 9999 },
|
|
98
|
+
ref,
|
|
99
|
+
...props,
|
|
100
|
+
children: ({ TransitionProps }) => /* @__PURE__ */ jsx3(Fade, { ...TransitionProps, timeout: 350, children: /* @__PURE__ */ jsx3(Card, { children: /* @__PURE__ */ jsxs2(CardContent, { sx: { display: "flex", gap: 1 }, children: [
|
|
101
|
+
/* @__PURE__ */ jsx3(
|
|
102
|
+
TextField,
|
|
103
|
+
{
|
|
104
|
+
autoFocus: true,
|
|
105
|
+
label: "Favorite Name",
|
|
106
|
+
placeholder: "optional",
|
|
107
|
+
size: "small",
|
|
108
|
+
value: name ?? "",
|
|
109
|
+
onChange: (e) => setName(e.target.value)
|
|
110
|
+
}
|
|
111
|
+
),
|
|
112
|
+
/* @__PURE__ */ jsx3(PopperButtonGroup, { favorite, onConfirmFavorite, name })
|
|
113
|
+
] }) }) })
|
|
84
114
|
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
label: "Favorite Name",
|
|
88
|
-
placeholder: "optional",
|
|
89
|
-
size: "small",
|
|
90
|
-
value: name ?? "",
|
|
91
|
-
onChange: /* @__PURE__ */ __name((e) => setName(e.target.value), "onChange")
|
|
92
|
-
}), /* @__PURE__ */ React3.createElement(PopperButtonGroup, {
|
|
93
|
-
favorite,
|
|
94
|
-
onConfirmFavorite,
|
|
95
|
-
name
|
|
96
|
-
}))))));
|
|
97
|
-
}, "FavoritePopper");
|
|
115
|
+
) });
|
|
116
|
+
};
|
|
98
117
|
FavoritePopper.displayName = "FavoritePopper";
|
|
99
118
|
|
|
100
119
|
// src/components/favorite/FavoriteIconButton.tsx
|
|
101
|
-
|
|
120
|
+
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
121
|
+
var FavoriteIconButton = ({
|
|
122
|
+
ref,
|
|
123
|
+
children,
|
|
124
|
+
favorite: favoriteProp,
|
|
125
|
+
name,
|
|
126
|
+
valueType,
|
|
127
|
+
value,
|
|
128
|
+
...props
|
|
129
|
+
}) => {
|
|
102
130
|
const [openPopper, setOpenPopper] = useState2(false);
|
|
103
131
|
const [favorite, setFavorite] = useResetState(favoriteProp);
|
|
104
132
|
const sharedRef = useShareForwardedRef(ref);
|
|
105
133
|
const [buttonRef, dispatch] = useEvent(void 0, sharedRef);
|
|
106
|
-
const onConfirmFavorite =
|
|
134
|
+
const onConfirmFavorite = (name2, newFavoriteState) => {
|
|
107
135
|
const favoriteEvent = generateFavoriteEvent(!!newFavoriteState, valueType, value, name2);
|
|
108
136
|
dispatch("address", "favorite", JSON.stringify(favoriteEvent));
|
|
109
137
|
setFavorite(newFavoriteState);
|
|
110
138
|
setOpenPopper(false);
|
|
111
|
-
}
|
|
139
|
+
};
|
|
112
140
|
const starRef = useRef(null);
|
|
113
|
-
return /* @__PURE__ */
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
p: 0.25
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
}
|
|
141
|
+
return /* @__PURE__ */ jsxs3(
|
|
142
|
+
IconButtonCondensed,
|
|
143
|
+
{
|
|
144
|
+
"aria-describedby": popperId,
|
|
145
|
+
ref: buttonRef,
|
|
146
|
+
onClick: (event) => {
|
|
147
|
+
event.stopPropagation();
|
|
148
|
+
setOpenPopper(!openPopper);
|
|
149
|
+
},
|
|
150
|
+
onTouchStart: (event) => {
|
|
151
|
+
event.stopPropagation();
|
|
152
|
+
setOpenPopper(!openPopper);
|
|
153
|
+
},
|
|
154
|
+
onMouseDown: (event) => event.stopPropagation(),
|
|
155
|
+
sx: { lineHeight: 0, p: 0.25 },
|
|
156
|
+
...props,
|
|
157
|
+
children: [
|
|
158
|
+
/* @__PURE__ */ jsx4("span", { ref: starRef, children: /* @__PURE__ */ jsx4(FavoriteToggleSVG, { favorite }) }),
|
|
159
|
+
/* @__PURE__ */ jsx4(
|
|
160
|
+
FavoritePopper,
|
|
161
|
+
{
|
|
162
|
+
sx: { zIndex: 1301 },
|
|
163
|
+
name,
|
|
164
|
+
favorite,
|
|
165
|
+
favoriteRef: starRef,
|
|
166
|
+
open: openPopper,
|
|
167
|
+
onConfirmFavorite,
|
|
168
|
+
onClickAway: () => setOpenPopper(false)
|
|
169
|
+
}
|
|
170
|
+
),
|
|
171
|
+
children
|
|
172
|
+
]
|
|
173
|
+
}
|
|
174
|
+
);
|
|
175
|
+
};
|
|
146
176
|
FavoriteIconButton.displayName = "FavoriteIconButton";
|
|
147
|
-
var IconButtonCondensed = styled(IconButton, {
|
|
148
|
-
name: "IconButtonCondensed"
|
|
149
|
-
})(({ theme }) => ({
|
|
177
|
+
var IconButtonCondensed = styled(IconButton, { name: "IconButtonCondensed" })(({ theme }) => ({
|
|
150
178
|
lineHeight: 0,
|
|
151
179
|
padding: theme.spacing(0.25)
|
|
152
180
|
}));
|
|
@@ -157,43 +185,53 @@ import { FlexRow } from "@xylabs/react-flexbox";
|
|
|
157
185
|
import { Identicon } from "@xylabs/react-identicon";
|
|
158
186
|
import { useEvent as useEvent2 } from "@xyo-network/react-event";
|
|
159
187
|
import { EllipsizeBox, useShareForwardedRef as useShareForwardedRef2 } from "@xyo-network/react-shared";
|
|
160
|
-
import
|
|
161
|
-
var AddressRenderRowBox =
|
|
188
|
+
import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
189
|
+
var AddressRenderRowBox = ({
|
|
190
|
+
ref,
|
|
191
|
+
address,
|
|
192
|
+
children,
|
|
193
|
+
disableSharedRef,
|
|
194
|
+
favorite: favoriteProp = false,
|
|
195
|
+
iconOnly,
|
|
196
|
+
iconSize = 24,
|
|
197
|
+
icons,
|
|
198
|
+
name,
|
|
199
|
+
showFavorite = false,
|
|
200
|
+
...props
|
|
201
|
+
}) => {
|
|
162
202
|
const theme = useTheme();
|
|
163
203
|
const sharedRef = useShareForwardedRef2(ref);
|
|
164
204
|
const [elementRef, dispatch] = useEvent2(void 0, sharedRef);
|
|
165
|
-
return /* @__PURE__ */
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
205
|
+
return /* @__PURE__ */ jsxs4(
|
|
206
|
+
FlexRow,
|
|
207
|
+
{
|
|
208
|
+
gap: 2,
|
|
209
|
+
justifyContent: "flex-start",
|
|
210
|
+
ref: elementRef,
|
|
211
|
+
onClick: () => {
|
|
212
|
+
if (address) {
|
|
213
|
+
dispatch("address", "click", address);
|
|
214
|
+
}
|
|
215
|
+
},
|
|
216
|
+
...props,
|
|
217
|
+
children: [
|
|
218
|
+
icons && address ? /* @__PURE__ */ jsx5(ListItemIcon, { sx: { minWidth: 0 }, children: /* @__PURE__ */ jsx5(Identicon, { size: iconSize, value: address }) }) : null,
|
|
219
|
+
iconOnly ? null : /* @__PURE__ */ jsx5(
|
|
220
|
+
EllipsizeBox,
|
|
221
|
+
{
|
|
222
|
+
disableSharedRef,
|
|
223
|
+
ellipsisPosition: "end",
|
|
224
|
+
width: "100%",
|
|
225
|
+
typographyProps: { fontSize: theme.typography.body1.fontSize },
|
|
226
|
+
children: name ?? address
|
|
227
|
+
}
|
|
228
|
+
),
|
|
229
|
+
children,
|
|
230
|
+
showFavorite && address ? /* @__PURE__ */ jsx5(FavoriteIconButton, { name, size: "small", value: address, valueType: "address", favorite: favoriteProp }) : null
|
|
231
|
+
]
|
|
178
232
|
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
value: address
|
|
182
|
-
})) : null, iconOnly ? null : /* @__PURE__ */ React5.createElement(EllipsizeBox, {
|
|
183
|
-
disableSharedRef,
|
|
184
|
-
ellipsisPosition: "end",
|
|
185
|
-
width: "100%",
|
|
186
|
-
typographyProps: {
|
|
187
|
-
fontSize: theme.typography.body1.fontSize
|
|
188
|
-
}
|
|
189
|
-
}, name ?? address), children, showFavorite && address ? /* @__PURE__ */ React5.createElement(FavoriteIconButton, {
|
|
190
|
-
name,
|
|
191
|
-
size: "small",
|
|
192
|
-
value: address,
|
|
193
|
-
valueType: "address",
|
|
194
|
-
favorite: favoriteProp
|
|
195
|
-
}) : null);
|
|
196
|
-
}, "AddressRenderRowBox");
|
|
233
|
+
);
|
|
234
|
+
};
|
|
197
235
|
AddressRenderRowBox.displayName = "AddressRenderRowBox";
|
|
198
236
|
export {
|
|
199
237
|
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 {\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"],"m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FA,SAASC,cAAcC,gBAAgB;AAEvC,SAASC,eAAe;AACxB,SAASC,iBAAiB;AAC1B,SAASC,YAAAA,iBAAgB;AACzB,SAASC,cAAcC,wBAAAA,6BAA4B;AACnD,OAAOC,YAAW;AAeX,IAAMC,sBAAsB,wBACjC,EACEC,KAAKC,SAASC,UAAUC,kBAAkBC,UAAUC,eAAe,OAAOC,UAAUC,WAAW,IAAIC,OAAOC,MAAMC,eAAe,OAAO,GAAGC,MAAAA,MAChE;AAE3E,QAAMC,QAAQC,SAAAA;AAEd,QAAMC,YAAYC,sBAAqBf,GAAAA;AACvC,QAAM,CAACgB,YAAYC,QAAAA,IAAYC,UAASC,QAAWL,SAAAA;AAEnD,SACE,gBAAAM,OAAA,cAACC,SAAAA;IACCC,KAAK;IACLC,gBAAe;IACfvB,KAAKgB;IACLQ,SAAS,6BAAA;AACP,UAAIvB,SAAS;AACXgB,iBAAS,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","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","Popper","id","popperId","anchorEl","current","onClick","e","stopPropagation","onTouchStart","transition","style","zIndex","TransitionProps","Fade","timeout","Card","CardContent","sx","display","gap","TextField","autoFocus","label","placeholder","size","value","onChange","target","PopperButtonGroup","displayName","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","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, { useLayoutEffect, 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 const [anchorEl, setAnchorEl] = useState<HTMLElement | null>(null)\n\n useLayoutEffect(() => {\n // eslint-disable-next-line react-x/set-state-in-effect\n setAnchorEl(favoriteRef?.current ?? null)\n }, [favoriteRef])\n\n return (\n <ClickAwayListener onClickAway={onClickAway ?? (() => null)}>\n <Popper\n id={popperId}\n anchorEl={anchorEl}\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"],"mapp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AE5D,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.5.
|
|
3
|
+
"version": "7.5.11",
|
|
4
4
|
"description": "Common React library for all XYO projects that use React",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"xyo",
|
|
@@ -36,49 +36,110 @@
|
|
|
36
36
|
},
|
|
37
37
|
"./package.json": "./package.json"
|
|
38
38
|
},
|
|
39
|
-
"module": "dist/browser/index.mjs",
|
|
40
|
-
"types": "dist/browser/index.d.ts",
|
|
41
39
|
"files": [
|
|
42
40
|
"dist",
|
|
43
|
-
"
|
|
41
|
+
"README.md"
|
|
44
42
|
],
|
|
45
43
|
"dependencies": {
|
|
46
|
-
"@
|
|
47
|
-
"@
|
|
48
|
-
"@xylabs/react-identicon": "~7.1.17",
|
|
49
|
-
"@xyo-network/react-event": "7.5.7",
|
|
50
|
-
"@xyo-network/react-shared": "7.5.7"
|
|
44
|
+
"@xyo-network/react-event": "~7.5.11",
|
|
45
|
+
"@xyo-network/react-shared": "~7.5.11"
|
|
51
46
|
},
|
|
52
47
|
"devDependencies": {
|
|
53
|
-
"@
|
|
54
|
-
"@mui/material": "
|
|
55
|
-
"@
|
|
48
|
+
"@bitauth/libauth": "~3.0.0",
|
|
49
|
+
"@mui/icons-material": "^7.3.10",
|
|
50
|
+
"@mui/material": "^7.3.10",
|
|
51
|
+
"@opentelemetry/api": "^1.9.1",
|
|
52
|
+
"@opentelemetry/sdk-trace-base": "^2.7.0",
|
|
53
|
+
"@scure/base": "~2.2.0",
|
|
54
|
+
"@storybook/react-vite": "~10.3.5",
|
|
55
|
+
"@types/node": "~25.6.0",
|
|
56
56
|
"@types/react": "^19.2.14",
|
|
57
|
-
"@xylabs/
|
|
58
|
-
"@xylabs/
|
|
59
|
-
"@xylabs/
|
|
60
|
-
"@xylabs/
|
|
61
|
-
"@xylabs/
|
|
62
|
-
"@xylabs/
|
|
63
|
-
"
|
|
64
|
-
"react": "
|
|
65
|
-
"react-
|
|
66
|
-
"
|
|
67
|
-
"
|
|
57
|
+
"@xylabs/react-async-effect": "~7.1.20",
|
|
58
|
+
"@xylabs/react-button": "~7.1.20",
|
|
59
|
+
"@xylabs/react-flexbox": "~7.1.20",
|
|
60
|
+
"@xylabs/react-hooks": "~7.1.20",
|
|
61
|
+
"@xylabs/react-identicon": "~7.1.20",
|
|
62
|
+
"@xylabs/react-link": "~7.1.20",
|
|
63
|
+
"@xylabs/react-promise": "~7.1.20",
|
|
64
|
+
"@xylabs/react-shared": "~7.1.20",
|
|
65
|
+
"@xylabs/react-theme": "~7.1.20",
|
|
66
|
+
"@xylabs/sdk-js": "^5.0.100",
|
|
67
|
+
"@xylabs/threads": "~5.0.100",
|
|
68
|
+
"@xylabs/toolchain": "~7.11.9",
|
|
69
|
+
"@xylabs/tsconfig": "^7.11.9",
|
|
70
|
+
"@xylabs/tsconfig-dom": "^7.11.9",
|
|
71
|
+
"@xylabs/tsconfig-react": "~7.11.9",
|
|
72
|
+
"@xylabs/zod": "~5.0.100",
|
|
73
|
+
"@xyo-network/boundwitness-model": "^5.5.1",
|
|
74
|
+
"@xyo-network/boundwitness-validator": "^5.5.1",
|
|
75
|
+
"@xyo-network/payload-builder": "^5.5.1",
|
|
76
|
+
"@xyo-network/payload-model": "^5.5.1",
|
|
77
|
+
"async-mutex": "^0.5.0",
|
|
78
|
+
"axios": "^1.15.2",
|
|
79
|
+
"bn.js": "^5.2.3",
|
|
80
|
+
"bowser": "^2.14.1",
|
|
81
|
+
"buffer": "^6.0.3",
|
|
82
|
+
"chalk": "^5.6.2",
|
|
83
|
+
"debug": "~4.4.3",
|
|
84
|
+
"esbuild": "~0.28.0",
|
|
85
|
+
"eslint": "^10.2.1",
|
|
86
|
+
"ethers": "^6.16.0",
|
|
87
|
+
"fast-deep-equal": "~3.1.3",
|
|
88
|
+
"hash-wasm": "~4.12.0",
|
|
89
|
+
"js-cookie": "~3.0.5",
|
|
90
|
+
"observable-fns": "~0.6.1",
|
|
91
|
+
"pako": "^2.1.0",
|
|
92
|
+
"react": "^19.2.5",
|
|
93
|
+
"react-dom": "^19.2.5",
|
|
94
|
+
"react-router-dom": "^7.14.2",
|
|
95
|
+
"spark-md5": "~3.0.2",
|
|
96
|
+
"storybook": "^10.3.5",
|
|
68
97
|
"typescript": "^5.9.3",
|
|
69
|
-
"vite": "
|
|
98
|
+
"vite": "^8.0.10",
|
|
99
|
+
"wasm-feature-detect": "~1.8.0",
|
|
70
100
|
"zod": "^4.3.6"
|
|
71
101
|
},
|
|
72
102
|
"peerDependencies": {
|
|
73
|
-
"@mui/icons-material": "
|
|
74
|
-
"@mui/material": "
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
"
|
|
78
|
-
"
|
|
103
|
+
"@mui/icons-material": "^7.3.10",
|
|
104
|
+
"@mui/material": "^7.3.10",
|
|
105
|
+
"@opentelemetry/api": "^1.9.1",
|
|
106
|
+
"@opentelemetry/sdk-trace-base": "^2.7.0",
|
|
107
|
+
"@scure/base": "~2.2.0",
|
|
108
|
+
"@xylabs/react-async-effect": "~7.1.20",
|
|
109
|
+
"@xylabs/react-button": "~7.1.20",
|
|
110
|
+
"@xylabs/react-flexbox": "~7.1.20",
|
|
111
|
+
"@xylabs/react-hooks": "~7.1.20",
|
|
112
|
+
"@xylabs/react-identicon": "~7.1.20",
|
|
113
|
+
"@xylabs/react-link": "~7.1.20",
|
|
114
|
+
"@xylabs/react-promise": "~7.1.20",
|
|
115
|
+
"@xylabs/react-shared": "~7.1.20",
|
|
116
|
+
"@xylabs/react-theme": "~7.1.20",
|
|
117
|
+
"@xylabs/sdk-js": "^5.0.100",
|
|
118
|
+
"@xylabs/tsconfig": "^7.11.9",
|
|
119
|
+
"@xylabs/tsconfig-dom": "^7.11.9",
|
|
120
|
+
"@xylabs/zod": "~5.0.100",
|
|
121
|
+
"@xyo-network/boundwitness-model": "^5.5.1",
|
|
122
|
+
"@xyo-network/boundwitness-validator": "^5.5.1",
|
|
123
|
+
"@xyo-network/payload-builder": "^5.5.1",
|
|
124
|
+
"@xyo-network/payload-model": "^5.5.1",
|
|
125
|
+
"async-mutex": "^0.5.0",
|
|
126
|
+
"axios": "^1.15.2",
|
|
127
|
+
"bn.js": "^5.2.3",
|
|
128
|
+
"bowser": "^2.14.1",
|
|
129
|
+
"buffer": "^6.0.3",
|
|
130
|
+
"chalk": "^5.6.2",
|
|
131
|
+
"ethers": "^6.16.0",
|
|
132
|
+
"fast-deep-equal": "~3.1.3",
|
|
133
|
+
"js-cookie": "~3.0.5",
|
|
134
|
+
"pako": "^2.1.0",
|
|
135
|
+
"react": "^19.2.5",
|
|
136
|
+
"react-dom": "^19.2.5",
|
|
137
|
+
"react-router-dom": "^7.14.2",
|
|
138
|
+
"spark-md5": "~3.0.2",
|
|
139
|
+
"zod": "^4.3.6"
|
|
79
140
|
},
|
|
80
141
|
"publishConfig": {
|
|
81
142
|
"access": "public"
|
|
82
143
|
},
|
|
83
144
|
"docs": "dist/docs.json"
|
|
84
|
-
}
|
|
145
|
+
}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryFn } from '@storybook/react-vite'
|
|
2
|
-
import { asAddress, toHex } from '@xylabs/sdk-js'
|
|
3
|
-
import { useEvent } from '@xyo-network/react-event'
|
|
4
|
-
import { randomBytes } from 'ethers'
|
|
5
|
-
import React, { useState } from 'react'
|
|
6
|
-
|
|
7
|
-
import type { FavoriteItemEvent } from './lib/index.ts'
|
|
8
|
-
import { AddressRenderRowBox } from './RenderRowBox.tsx'
|
|
9
|
-
|
|
10
|
-
const address = asAddress(toHex(randomBytes(20).buffer), true)
|
|
11
|
-
|
|
12
|
-
const StorybookEntry = {
|
|
13
|
-
argTypes: {},
|
|
14
|
-
component: AddressRenderRowBox,
|
|
15
|
-
parameters: { docs: { page: null } },
|
|
16
|
-
title: 'address/render/AddressRenderRowBox',
|
|
17
|
-
} as Meta<typeof AddressRenderRowBox>
|
|
18
|
-
|
|
19
|
-
const Template: StoryFn<typeof AddressRenderRowBox> = (args) => {
|
|
20
|
-
const { name: argsName } = args
|
|
21
|
-
const [ref] = useEvent<HTMLLIElement>((noun, verb, data) => {
|
|
22
|
-
console.log(`${noun}|${verb}|${data}`)
|
|
23
|
-
const parsedEvent = JSON.parse(data ?? '') as FavoriteItemEvent
|
|
24
|
-
if (parsedEvent.favorite) {
|
|
25
|
-
setName(parsedEvent.name)
|
|
26
|
-
} else {
|
|
27
|
-
setName(undefined)
|
|
28
|
-
}
|
|
29
|
-
})
|
|
30
|
-
const [name, setName] = useState(argsName)
|
|
31
|
-
return <AddressRenderRowBox {...args} name={name} ref={ref} />
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const Default = Template.bind({})
|
|
35
|
-
Default.args = {}
|
|
36
|
-
|
|
37
|
-
const WithAddress = Template.bind({})
|
|
38
|
-
WithAddress.args = { address }
|
|
39
|
-
|
|
40
|
-
const WithIcon = Template.bind({})
|
|
41
|
-
WithIcon.args = {
|
|
42
|
-
address,
|
|
43
|
-
icons: true,
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const WithIconOnly = Template.bind({})
|
|
47
|
-
WithIconOnly.args = {
|
|
48
|
-
address,
|
|
49
|
-
iconOnly: true,
|
|
50
|
-
icons: true,
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const WithFavorite = Template.bind({})
|
|
54
|
-
WithFavorite.args = {
|
|
55
|
-
address,
|
|
56
|
-
favorite: true,
|
|
57
|
-
icons: true,
|
|
58
|
-
showFavorite: true,
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const WithFavoriteAlias = Template.bind({})
|
|
62
|
-
WithFavoriteAlias.args = {
|
|
63
|
-
address,
|
|
64
|
-
favorite: true,
|
|
65
|
-
icons: true,
|
|
66
|
-
name: 'My Name',
|
|
67
|
-
showFavorite: true,
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const WithChildren = Template.bind({})
|
|
71
|
-
WithChildren.args = {
|
|
72
|
-
address,
|
|
73
|
-
children: <span>[InsertedChild]</span>,
|
|
74
|
-
favorite: true,
|
|
75
|
-
icons: true,
|
|
76
|
-
showFavorite: true,
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export {
|
|
80
|
-
Default, WithAddress, WithChildren, WithFavorite, WithFavoriteAlias, WithIcon, WithIconOnly,
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export default StorybookEntry
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { ListItemIcon, useTheme } from '@mui/material'
|
|
2
|
-
import type { FlexBoxProps } from '@xylabs/react-flexbox'
|
|
3
|
-
import { FlexRow } from '@xylabs/react-flexbox'
|
|
4
|
-
import { Identicon } from '@xylabs/react-identicon'
|
|
5
|
-
import { useEvent } from '@xyo-network/react-event'
|
|
6
|
-
import { EllipsizeBox, useShareForwardedRef } from '@xyo-network/react-shared'
|
|
7
|
-
import React from 'react'
|
|
8
|
-
|
|
9
|
-
import { FavoriteIconButton } from './favorite/index.ts'
|
|
10
|
-
|
|
11
|
-
export interface AddressRenderRowBoxProps extends FlexBoxProps {
|
|
12
|
-
address?: string | null
|
|
13
|
-
disableSharedRef?: boolean
|
|
14
|
-
favorite?: boolean
|
|
15
|
-
iconOnly?: boolean
|
|
16
|
-
iconSize?: number
|
|
17
|
-
icons?: boolean
|
|
18
|
-
name?: string
|
|
19
|
-
showFavorite?: boolean
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export const AddressRenderRowBox = (
|
|
23
|
-
{
|
|
24
|
-
ref, address, children, disableSharedRef, favorite: favoriteProp = false, iconOnly, iconSize = 24, icons, name, showFavorite = false, ...props
|
|
25
|
-
}: AddressRenderRowBoxProps & { ref?: React.RefObject<HTMLElement | null> },
|
|
26
|
-
) => {
|
|
27
|
-
const theme = useTheme()
|
|
28
|
-
|
|
29
|
-
const sharedRef = useShareForwardedRef(ref)
|
|
30
|
-
const [elementRef, dispatch] = useEvent(undefined, sharedRef)
|
|
31
|
-
|
|
32
|
-
return (
|
|
33
|
-
<FlexRow
|
|
34
|
-
gap={2}
|
|
35
|
-
justifyContent="flex-start"
|
|
36
|
-
ref={elementRef}
|
|
37
|
-
onClick={() => {
|
|
38
|
-
if (address) {
|
|
39
|
-
dispatch('address', 'click', address)
|
|
40
|
-
}
|
|
41
|
-
}}
|
|
42
|
-
{...props}
|
|
43
|
-
>
|
|
44
|
-
{icons && address
|
|
45
|
-
? (
|
|
46
|
-
<ListItemIcon sx={{ minWidth: 0 }}>
|
|
47
|
-
<Identicon size={iconSize} value={address} />
|
|
48
|
-
</ListItemIcon>
|
|
49
|
-
)
|
|
50
|
-
: null}
|
|
51
|
-
{iconOnly
|
|
52
|
-
? null
|
|
53
|
-
: (
|
|
54
|
-
<EllipsizeBox
|
|
55
|
-
disableSharedRef={disableSharedRef}
|
|
56
|
-
ellipsisPosition="end"
|
|
57
|
-
width="100%"
|
|
58
|
-
typographyProps={{ fontSize: theme.typography.body1.fontSize }}
|
|
59
|
-
>
|
|
60
|
-
{name ?? address}
|
|
61
|
-
</EllipsizeBox>
|
|
62
|
-
)}
|
|
63
|
-
{children}
|
|
64
|
-
{showFavorite && address
|
|
65
|
-
? <FavoriteIconButton name={name} size="small" value={address} valueType="address" favorite={favoriteProp} />
|
|
66
|
-
: null}
|
|
67
|
-
</FlexRow>
|
|
68
|
-
)
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
AddressRenderRowBox.displayName = 'AddressRenderRowBox'
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import type { IconButtonProps } from '@mui/material'
|
|
2
|
-
import { IconButton, styled } from '@mui/material'
|
|
3
|
-
import { useResetState } from '@xylabs/react-hooks'
|
|
4
|
-
import { useEvent } from '@xyo-network/react-event'
|
|
5
|
-
import { useShareForwardedRef } from '@xyo-network/react-shared'
|
|
6
|
-
import type {
|
|
7
|
-
MouseEvent, PropsWithChildren, TouchEvent,
|
|
8
|
-
} from 'react'
|
|
9
|
-
import React, { useRef, useState } from 'react'
|
|
10
|
-
|
|
11
|
-
import type { FavoriteItemEvent } from '../lib/index.ts'
|
|
12
|
-
import { generateFavoriteEvent } from '../lib/index.ts'
|
|
13
|
-
import { FavoriteToggleSVG } from './FavoriteToggleSVG.tsx'
|
|
14
|
-
import { popperId } from './lib/index.ts'
|
|
15
|
-
import { FavoritePopper } from './Popper.tsx'
|
|
16
|
-
|
|
17
|
-
export interface FavoriteIconButtonProps extends PropsWithChildren, IconButtonProps {
|
|
18
|
-
favorite?: FavoriteItemEvent['favorite']
|
|
19
|
-
name?: FavoriteItemEvent['name']
|
|
20
|
-
value?: string
|
|
21
|
-
valueType?: FavoriteItemEvent['favoriteType']
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export const FavoriteIconButton = ({
|
|
25
|
-
ref, children, favorite: favoriteProp, name, valueType, value, ...props
|
|
26
|
-
}: FavoriteIconButtonProps & { ref?: React.RefObject<HTMLButtonElement | null> }) => {
|
|
27
|
-
const [openPopper, setOpenPopper] = useState(false)
|
|
28
|
-
|
|
29
|
-
const [favorite, setFavorite] = useResetState(favoriteProp)
|
|
30
|
-
|
|
31
|
-
const sharedRef = useShareForwardedRef(ref)
|
|
32
|
-
const [buttonRef, dispatch] = useEvent(undefined, sharedRef)
|
|
33
|
-
|
|
34
|
-
const onConfirmFavorite = (name?: string, newFavoriteState?: boolean) => {
|
|
35
|
-
const favoriteEvent = generateFavoriteEvent(!!newFavoriteState, valueType, value, name)
|
|
36
|
-
dispatch('address', 'favorite', JSON.stringify(favoriteEvent))
|
|
37
|
-
setFavorite(newFavoriteState)
|
|
38
|
-
setOpenPopper(false)
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const starRef = useRef<HTMLSpanElement>(null)
|
|
42
|
-
|
|
43
|
-
return (
|
|
44
|
-
<IconButtonCondensed
|
|
45
|
-
aria-describedby={popperId}
|
|
46
|
-
ref={buttonRef}
|
|
47
|
-
onClick={(event: MouseEvent) => {
|
|
48
|
-
event.stopPropagation()
|
|
49
|
-
setOpenPopper(!openPopper)
|
|
50
|
-
}}
|
|
51
|
-
onTouchStart={(event: TouchEvent) => {
|
|
52
|
-
event.stopPropagation()
|
|
53
|
-
setOpenPopper(!openPopper)
|
|
54
|
-
}}
|
|
55
|
-
onMouseDown={(event: MouseEvent) => event.stopPropagation()}
|
|
56
|
-
sx={{ lineHeight: 0, p: 0.25 }}
|
|
57
|
-
{...props}
|
|
58
|
-
>
|
|
59
|
-
<span ref={starRef}>
|
|
60
|
-
<FavoriteToggleSVG favorite={favorite} />
|
|
61
|
-
</span>
|
|
62
|
-
<FavoritePopper
|
|
63
|
-
sx={{ zIndex: 1301 }}
|
|
64
|
-
name={name}
|
|
65
|
-
favorite={favorite}
|
|
66
|
-
favoriteRef={starRef}
|
|
67
|
-
open={openPopper}
|
|
68
|
-
onConfirmFavorite={onConfirmFavorite}
|
|
69
|
-
onClickAway={() => setOpenPopper(false)}
|
|
70
|
-
/>
|
|
71
|
-
{children}
|
|
72
|
-
</IconButtonCondensed>
|
|
73
|
-
)
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
FavoriteIconButton.displayName = 'FavoriteIconButton'
|
|
77
|
-
|
|
78
|
-
const IconButtonCondensed = styled(IconButton, { name: 'IconButtonCondensed' })(({ theme }) => ({
|
|
79
|
-
lineHeight: 0,
|
|
80
|
-
padding: theme.spacing(0.25),
|
|
81
|
-
}))
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Star as StarIcon, StarBorder as StarBorderIcon } from '@mui/icons-material'
|
|
2
|
-
import React from 'react'
|
|
3
|
-
|
|
4
|
-
export const FavoriteToggleSVG: React.FC<{ favorite?: boolean }> = ({ favorite }) => (
|
|
5
|
-
<>
|
|
6
|
-
{favorite
|
|
7
|
-
? <StarIcon className="favorite-icon" component="svg" color="secondary" fontSize="small" />
|
|
8
|
-
: <StarBorderIcon className="favorite-icon" fontSize="small" />}
|
|
9
|
-
</>
|
|
10
|
-
)
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import type { PopperProps } from '@mui/material'
|
|
2
|
-
import {
|
|
3
|
-
Card, CardContent, ClickAwayListener, Fade, Popper, TextField,
|
|
4
|
-
} from '@mui/material'
|
|
5
|
-
import type { RefObject } from 'react'
|
|
6
|
-
import React, { useState } from 'react'
|
|
7
|
-
|
|
8
|
-
import { popperId } from './lib/index.ts'
|
|
9
|
-
import { PopperButtonGroup } from './PopperButtonGroup.tsx'
|
|
10
|
-
|
|
11
|
-
export interface FavoritePopperProps extends PopperProps {
|
|
12
|
-
favorite?: boolean
|
|
13
|
-
favoriteRef?: RefObject<HTMLElement | null>
|
|
14
|
-
name?: string
|
|
15
|
-
onClickAway?: (event: MouseEvent | TouchEvent) => void
|
|
16
|
-
onConfirmFavorite?: (name?: string, newFavoriteState?: boolean) => void
|
|
17
|
-
}
|
|
18
|
-
export const FavoritePopper = (
|
|
19
|
-
{
|
|
20
|
-
ref, name: nameProp, favorite, favoriteRef, onClickAway, onConfirmFavorite, ...props
|
|
21
|
-
}: FavoritePopperProps,
|
|
22
|
-
) => {
|
|
23
|
-
const [name, setName] = useState(() => nameProp)
|
|
24
|
-
|
|
25
|
-
return (
|
|
26
|
-
<ClickAwayListener onClickAway={onClickAway ?? (() => null)}>
|
|
27
|
-
<Popper
|
|
28
|
-
id={popperId}
|
|
29
|
-
anchorEl={favoriteRef?.current}
|
|
30
|
-
onClick={e => e.stopPropagation()}
|
|
31
|
-
onTouchStart={e => e.stopPropagation()}
|
|
32
|
-
transition
|
|
33
|
-
style={{ zIndex: 9999 }}
|
|
34
|
-
ref={ref}
|
|
35
|
-
{...props}
|
|
36
|
-
>
|
|
37
|
-
{({ TransitionProps }) => (
|
|
38
|
-
<Fade {...TransitionProps} timeout={350}>
|
|
39
|
-
<Card>
|
|
40
|
-
<CardContent sx={{ display: 'flex', gap: 1 }}>
|
|
41
|
-
<TextField
|
|
42
|
-
autoFocus
|
|
43
|
-
label="Favorite Name"
|
|
44
|
-
placeholder="optional"
|
|
45
|
-
size="small"
|
|
46
|
-
value={name ?? ''}
|
|
47
|
-
onChange={e => setName(e.target.value)}
|
|
48
|
-
/>
|
|
49
|
-
<PopperButtonGroup favorite={favorite} onConfirmFavorite={onConfirmFavorite} name={name} />
|
|
50
|
-
</CardContent>
|
|
51
|
-
</Card>
|
|
52
|
-
</Fade>
|
|
53
|
-
)}
|
|
54
|
-
</Popper>
|
|
55
|
-
</ClickAwayListener>
|
|
56
|
-
)
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
FavoritePopper.displayName = 'FavoritePopper'
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { Delete as DeleteIcon, Star as StarIcon } from '@mui/icons-material'
|
|
2
|
-
import type { ButtonGroupProps } from '@mui/material'
|
|
3
|
-
import { Button, ButtonGroup } from '@mui/material'
|
|
4
|
-
import React from 'react'
|
|
5
|
-
|
|
6
|
-
export interface FavoritePopperProps extends ButtonGroupProps {
|
|
7
|
-
favorite?: boolean
|
|
8
|
-
name?: string
|
|
9
|
-
onConfirmFavorite?: (name?: string, newFavoriteState?: boolean) => void
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const PopperButtonGroup: React.FC<FavoritePopperProps> = ({
|
|
13
|
-
name, onConfirmFavorite, favorite, ...props
|
|
14
|
-
}) => {
|
|
15
|
-
return (
|
|
16
|
-
<ButtonGroup {...props}>
|
|
17
|
-
<Button
|
|
18
|
-
title="Save Favorite"
|
|
19
|
-
variant="contained"
|
|
20
|
-
onClick={(e) => {
|
|
21
|
-
e.stopPropagation()
|
|
22
|
-
onConfirmFavorite?.(name, true)
|
|
23
|
-
}}
|
|
24
|
-
>
|
|
25
|
-
<StarIcon />
|
|
26
|
-
</Button>
|
|
27
|
-
{favorite
|
|
28
|
-
? (
|
|
29
|
-
<Button
|
|
30
|
-
title="Remove Favorite"
|
|
31
|
-
variant="contained"
|
|
32
|
-
onClick={(e) => {
|
|
33
|
-
e.stopPropagation()
|
|
34
|
-
onConfirmFavorite?.(name, false)
|
|
35
|
-
}}
|
|
36
|
-
>
|
|
37
|
-
<DeleteIcon />
|
|
38
|
-
</Button>
|
|
39
|
-
)
|
|
40
|
-
: null}
|
|
41
|
-
</ButtonGroup>
|
|
42
|
-
)
|
|
43
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './FavoriteIconButton.tsx'
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const popperId = 'favorite-popper'
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './PopperId.ts'
|
package/src/components/index.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export interface FavoriteItemEvent {
|
|
2
|
-
favorite?: boolean
|
|
3
|
-
favoriteType?: FavoriteType
|
|
4
|
-
favoriteValue?: string
|
|
5
|
-
name?: string
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export type FavoriteType = 'address' | 'schema' | 'hash'
|
|
9
|
-
|
|
10
|
-
export const generateFavoriteEvent = (favorite?: boolean, favoriteType?: FavoriteType, favoriteValue?: string, name?: string): FavoriteItemEvent => ({
|
|
11
|
-
favorite: !!favorite,
|
|
12
|
-
favoriteType,
|
|
13
|
-
favoriteValue,
|
|
14
|
-
name,
|
|
15
|
-
})
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './FavoriteItemEvent.ts'
|
package/src/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './components/index.ts'
|