@xyo-network/react-address-render 2.47.3 → 2.47.5
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/cjs/components/RenderRowBox.js +3 -2
- package/dist/cjs/components/RenderRowBox.js.map +1 -1
- package/dist/cjs/components/favorite/FavoriteIconButton.js +21 -12
- package/dist/cjs/components/favorite/FavoriteIconButton.js.map +1 -1
- package/dist/cjs/components/favorite/Popper.js +21 -0
- package/dist/cjs/components/favorite/Popper.js.map +1 -0
- package/dist/cjs/components/favorite/PopperButtonGroup.js +20 -0
- package/dist/cjs/components/favorite/PopperButtonGroup.js.map +1 -0
- package/dist/cjs/components/favorite/lib/PopperId.js +5 -0
- package/dist/cjs/components/favorite/lib/PopperId.js.map +1 -0
- package/dist/cjs/components/favorite/lib/index.js +5 -0
- package/dist/cjs/components/favorite/lib/index.js.map +1 -0
- package/dist/cjs/components/index.js +1 -0
- package/dist/cjs/components/index.js.map +1 -1
- package/dist/cjs/components/lib/FavoriteItemEvent.js +3 -0
- package/dist/cjs/components/lib/FavoriteItemEvent.js.map +1 -0
- package/dist/cjs/components/lib/index.js +5 -0
- package/dist/cjs/components/lib/index.js.map +1 -0
- package/dist/docs.json +795 -626
- package/dist/esm/components/RenderRowBox.js +2 -2
- package/dist/esm/components/RenderRowBox.js.map +1 -1
- package/dist/esm/components/favorite/FavoriteIconButton.js +22 -13
- package/dist/esm/components/favorite/FavoriteIconButton.js.map +1 -1
- package/dist/esm/components/favorite/Popper.js +16 -0
- package/dist/esm/components/favorite/Popper.js.map +1 -0
- package/dist/esm/components/favorite/PopperButtonGroup.js +14 -0
- package/dist/esm/components/favorite/PopperButtonGroup.js.map +1 -0
- package/dist/esm/components/favorite/lib/PopperId.js +2 -0
- package/dist/esm/components/favorite/lib/PopperId.js.map +1 -0
- package/dist/esm/components/favorite/lib/index.js +2 -0
- package/dist/esm/components/favorite/lib/index.js.map +1 -0
- package/dist/esm/components/index.js +1 -0
- package/dist/esm/components/index.js.map +1 -1
- package/dist/esm/components/lib/FavoriteItemEvent.js +2 -0
- package/dist/esm/components/lib/FavoriteItemEvent.js.map +1 -0
- package/dist/esm/components/lib/index.js +2 -0
- package/dist/esm/components/lib/index.js.map +1 -0
- package/dist/types/components/RenderRowBox.d.ts +1 -0
- package/dist/types/components/RenderRowBox.d.ts.map +1 -1
- package/dist/types/components/favorite/FavoriteIconButton.d.ts +5 -6
- package/dist/types/components/favorite/FavoriteIconButton.d.ts.map +1 -1
- package/dist/types/components/favorite/Popper.d.ts +11 -0
- package/dist/types/components/favorite/Popper.d.ts.map +1 -0
- package/dist/types/components/favorite/PopperButtonGroup.d.ts +9 -0
- package/dist/types/components/favorite/PopperButtonGroup.d.ts.map +1 -0
- package/dist/types/components/favorite/lib/PopperId.d.ts +2 -0
- package/dist/types/components/favorite/lib/PopperId.d.ts.map +1 -0
- package/dist/types/components/favorite/lib/index.d.ts +2 -0
- package/dist/types/components/favorite/lib/index.d.ts.map +1 -0
- package/dist/types/components/index.d.ts +1 -0
- package/dist/types/components/index.d.ts.map +1 -1
- package/dist/types/components/lib/FavoriteItemEvent.d.ts +7 -0
- package/dist/types/components/lib/FavoriteItemEvent.d.ts.map +1 -0
- package/dist/types/components/lib/index.d.ts +2 -0
- package/dist/types/components/lib/index.d.ts.map +1 -0
- package/package.json +4 -4
- package/src/components/RenderRowBox.stories.tsx +23 -3
- package/src/components/RenderRowBox.tsx +6 -3
- package/src/components/favorite/FavoriteIconButton.tsx +37 -18
- package/src/components/favorite/Popper.tsx +59 -0
- package/src/components/favorite/PopperButtonGroup.tsx +36 -0
- package/src/components/favorite/lib/PopperId.ts +1 -0
- package/src/components/favorite/lib/index.ts +1 -0
- package/src/components/index.ts +1 -0
- package/src/components/lib/FavoriteItemEvent.ts +6 -0
- package/src/components/lib/index.ts +1 -0
|
@@ -6,11 +6,11 @@ import { useXyoEvent } from '@xyo-network/react-event';
|
|
|
6
6
|
import { EllipsizeBox, useShareForwardedRef } from '@xyo-network/react-shared';
|
|
7
7
|
import { forwardRef } from 'react';
|
|
8
8
|
import { FavoriteIconButton } from './favorite';
|
|
9
|
-
export const AddressRenderRowBox = forwardRef(({ address, children, favorite: favoriteProp = false, iconOnly, iconSize = 24, icons, name, showFavorite = false, ...props }, ref) => {
|
|
9
|
+
export const AddressRenderRowBox = forwardRef(({ address, alias, children, favorite: favoriteProp = false, iconOnly, iconSize = 24, icons, name, showFavorite = false, ...props }, ref) => {
|
|
10
10
|
const theme = useTheme();
|
|
11
11
|
const sharedRef = useShareForwardedRef(ref);
|
|
12
12
|
const [elementRef, dispatch] = useXyoEvent(undefined, sharedRef);
|
|
13
|
-
return (_jsxs(FlexGrowRow, { gap: 2, justifyContent: "flex-start", ref: elementRef, onClick: () => (address ? dispatch('address', 'click', address) : undefined), ...props, children: [icons && address ? (_jsx(ListItemIcon, { sx: { minWidth: 0 }, children: _jsx(Identicon, { size: iconSize, value: address }) })) : null, iconOnly ? null : (_jsx(ListItemText, { children: _jsx(EllipsizeBox, { ellipsisPosition: 'end', width: "100%", typographyProps: { fontSize: theme.typography.body1.fontSize }, children: name ?? address }) })), children, showFavorite && address ? _jsx(FavoriteIconButton, { size: 'small', address: address, favorite: favoriteProp }) : null] }));
|
|
13
|
+
return (_jsxs(FlexGrowRow, { gap: 2, justifyContent: "flex-start", ref: elementRef, onClick: () => (address ? dispatch('address', 'click', address) : undefined), ...props, children: [icons && address ? (_jsx(ListItemIcon, { sx: { minWidth: 0 }, children: _jsx(Identicon, { size: iconSize, value: address }) })) : null, iconOnly ? null : (_jsx(ListItemText, { children: _jsx(EllipsizeBox, { ellipsisPosition: 'end', width: "100%", typographyProps: { fontSize: theme.typography.body1.fontSize }, children: alias ?? name ?? address }) })), children, showFavorite && address ? (_jsx(FavoriteIconButton, { alias: alias, size: 'small', value: address, valueType: 'address', favorite: favoriteProp })) : null] }));
|
|
14
14
|
});
|
|
15
15
|
AddressRenderRowBox.displayName = 'AddressRenderRowBox';
|
|
16
16
|
//# sourceMappingURL=RenderRowBox.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RenderRowBox.js","sourceRoot":"","sources":["../../../src/components/RenderRowBox.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACpE,OAAO,EAAgB,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAEnD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AACtD,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAC9E,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAElC,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"RenderRowBox.js","sourceRoot":"","sources":["../../../src/components/RenderRowBox.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACpE,OAAO,EAAgB,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAEnD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AACtD,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAC9E,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAElC,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAe/C,MAAM,CAAC,MAAM,mBAAmB,GAAG,UAAU,CAC3C,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,YAAY,GAAG,KAAK,EAAE,QAAQ,EAAE,QAAQ,GAAG,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,YAAY,GAAG,KA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,IACI,CACf,CAAA;AACH,CAAC,CACF,CAAA;AAED,mBAAmB,CAAC,WAAW,GAAG,qBAAqB,CAAA"}
|
|
@@ -4,28 +4,37 @@ import StarBorderIcon from '@mui/icons-material/StarBorder';
|
|
|
4
4
|
import { IconButton } from '@mui/material';
|
|
5
5
|
import { useXyoEvent } from '@xyo-network/react-event';
|
|
6
6
|
import { useShareForwardedRef } from '@xyo-network/react-shared';
|
|
7
|
-
import { forwardRef, useEffect, useState } from 'react';
|
|
8
|
-
|
|
7
|
+
import { forwardRef, useEffect, useRef, useState } from 'react';
|
|
8
|
+
import { popperId } from './lib';
|
|
9
|
+
import { FavoritePopper } from './Popper';
|
|
10
|
+
export const FavoriteIconButton = forwardRef(({ alias, children, favorite: favoriteProp, valueType, value, ...props }, ref) => {
|
|
11
|
+
const [openPopper, setOpenPopper] = useState(false);
|
|
9
12
|
const [favorite, setFavorite] = useState(favoriteProp);
|
|
10
13
|
useEffect(() => {
|
|
11
14
|
setFavorite(favoriteProp);
|
|
12
15
|
}, [favoriteProp]);
|
|
13
16
|
const sharedRef = useShareForwardedRef(ref);
|
|
14
17
|
const [buttonRef, dispatch] = useXyoEvent(undefined, sharedRef);
|
|
15
|
-
|
|
18
|
+
const onConfirmFavorite = (alias, newFavoriteState) => {
|
|
19
|
+
setFavorite(() => {
|
|
20
|
+
const favoriteEvent = {
|
|
21
|
+
alias,
|
|
22
|
+
favorite: !!newFavoriteState,
|
|
23
|
+
favoriteType: valueType,
|
|
24
|
+
favoriteValue: value,
|
|
25
|
+
};
|
|
26
|
+
dispatch('address', 'favorite', JSON.stringify(favoriteEvent));
|
|
27
|
+
return newFavoriteState;
|
|
28
|
+
});
|
|
29
|
+
setOpenPopper(false);
|
|
30
|
+
};
|
|
31
|
+
const starRef = useRef(null);
|
|
32
|
+
return (_jsxs(IconButton, { ref: buttonRef, "aria-describedby": popperId,
|
|
16
33
|
// used to prevent parent items from rippling when IconButton is clicked
|
|
17
34
|
onMouseDown: (e) => e.stopPropagation(), onClick: (event) => {
|
|
18
35
|
event.stopPropagation();
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const favoriteEvent = {
|
|
22
|
-
address,
|
|
23
|
-
favorite: newFavoriteState,
|
|
24
|
-
};
|
|
25
|
-
dispatch('address', 'favorite', JSON.stringify(favoriteEvent));
|
|
26
|
-
return newFavoriteState;
|
|
27
|
-
});
|
|
28
|
-
}, ...props, children: [favorite ? _jsx(StarIcon, { color: "secondary" }) : _jsx(StarBorderIcon, {}), children] }));
|
|
36
|
+
setOpenPopper(true);
|
|
37
|
+
}, ...props, children: [_jsx("span", { ref: starRef, children: favorite ? _jsx(StarIcon, { component: 'svg', color: "secondary" }) : _jsx(StarBorderIcon, {}) }), _jsx(FavoritePopper, { alias: alias, favorite: favorite, favoriteRef: starRef, open: openPopper, onConfirmFavorite: onConfirmFavorite, onClickAway: () => setOpenPopper(false) }), children] }));
|
|
29
38
|
});
|
|
30
39
|
FavoriteIconButton.displayName = 'FavoriteIconButton';
|
|
31
40
|
//# sourceMappingURL=FavoriteIconButton.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FavoriteIconButton.js","sourceRoot":"","sources":["../../../../src/components/favorite/FavoriteIconButton.tsx"],"names":[],"mappings":";AAAA,OAAO,QAAQ,MAAM,0BAA0B,CAAA;AAC/C,OAAO,cAAc,MAAM,gCAAgC,CAAA;AAC3D,OAAO,EAAE,UAAU,EAAmB,MAAM,eAAe,CAAA;AAE3D,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAChE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"FavoriteIconButton.js","sourceRoot":"","sources":["../../../../src/components/favorite/FavoriteIconButton.tsx"],"names":[],"mappings":";AAAA,OAAO,QAAQ,MAAM,0BAA0B,CAAA;A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,CAAC,SAAS,EAAE,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC,CAAA;YAC9D,OAAO,gBAAgB,CAAA;QACzB,CAAC,CAAC,CAAA;QACF,aAAa,CAAC,KAAK,CAAC,CAAA;IACtB,CAAC,CAAA;IAED,MAAM,OAAO,GAAG,MAAM,CAAkB,IAAI,CAAC,CAAA;IAE7C,OAAO,CACL,MAAC,UAAU,IACT,GAAG,EAAE,SAAS,sBACI,QAAQ;QAC1B,wEAAwE;QACxE,WAAW,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,eAAe,EAAE,EACvC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;YACjB,KAAK,CAAC,eAAe,EAAE,CAAA;YACvB,aAAa,CAAC,IAAI,CAAC,CAAA;QACrB,CAAC,KACG,KAAK,aAET,eAAM,GAAG,EAAE,OAAO,YAAG,QAAQ,CAAC,CAAC,CAAC,KAAC,QAAQ,IAAC,SAAS,EAAE,KAAK,EAAE,KAAK,EAAC,WAAW,GAAG,CAAC,CAAC,CAAC,KAAC,cAAc,KAAG,GAAQ,EAC7G,KAAC,cAAc,IACb,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,QAAQ,EAClB,WAAW,EAAE,OAAO,EACpB,IAAI,EAAE,UAAU,EAChB,iBAAiB,EAAE,iBAAiB,EACpC,WAAW,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,KAAK,CAAC,GACvC,EACD,QAAQ,IACE,CACd,CAAA;AACH,CAAC,CACF,CAAA;AAED,kBAAkB,CAAC,WAAW,GAAG,oBAAoB,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Card, CardContent, ClickAwayListener, Fade, Popper, TextField } from '@mui/material';
|
|
3
|
+
import { forwardRef, useEffect, useState } from 'react';
|
|
4
|
+
import { popperId } from './lib';
|
|
5
|
+
import { PopperButtonGroup } from './PopperButtonGroup';
|
|
6
|
+
export const FavoritePopper = forwardRef(({ alias: aliasProp, favorite, favoriteRef, onClickAway = () => {
|
|
7
|
+
return;
|
|
8
|
+
}, onConfirmFavorite, ...props }, ref) => {
|
|
9
|
+
const [alias, setAlias] = useState();
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
setAlias(aliasProp);
|
|
12
|
+
}, [aliasProp]);
|
|
13
|
+
return (_jsx(ClickAwayListener, { onClickAway: onClickAway, children: _jsx(Popper, { id: popperId, anchorEl: favoriteRef?.current, transition: true, ref: ref, ...props, children: ({ TransitionProps }) => (_jsx(Fade, { ...TransitionProps, timeout: 350, children: _jsx(Card, { children: _jsxs(CardContent, { sx: { display: 'flex', gap: 1 }, children: [_jsx(TextField, { autoFocus: true, label: "Favorite Alias", placeholder: "optional", size: "small", value: alias ?? '', onChange: (e) => setAlias(e.target.value) }), _jsx(PopperButtonGroup, { favorite: favorite, onConfirmFavorite: onConfirmFavorite, alias: alias })] }) }) })) }) }));
|
|
14
|
+
});
|
|
15
|
+
FavoritePopper.displayName = 'FavoritePopper';
|
|
16
|
+
//# sourceMappingURL=Popper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Popper.js","sourceRoot":"","sources":["../../../../src/components/favorite/Popper.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,EAAe,SAAS,EAAE,MAAM,eAAe,CAAA;AAC1G,OAAO,EAAE,UAAU,EAAa,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAElE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAChC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AASvD,MAAM,CAAC,MAAM,cAAc,GAAG,UAAU,CACtC,CACE,EACE,KAAK,EAAE,SAAS,EAChB,QAAQ,EACR,WAAW,EACX,WAAW,GAAG,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@mui/icons-material/Delete';
|
|
3
|
+
import StarIcon from '@mui/icons-material/Star';
|
|
4
|
+
import { Button, ButtonGroup } from '@mui/material';
|
|
5
|
+
export const PopperButtonGroup = ({ alias, onConfirmFavorite, favorite, ...props }) => {
|
|
6
|
+
return (_jsxs(ButtonGroup, { ...props, children: [_jsx(Button, { variant: "contained", onClick: (e) => {
|
|
7
|
+
e.stopPropagation();
|
|
8
|
+
onConfirmFavorite?.(alias, true);
|
|
9
|
+
}, children: _jsx(StarIcon, {}) }), favorite ? (_jsx(Button, { variant: "contained", onClick: (e) => {
|
|
10
|
+
e.stopPropagation();
|
|
11
|
+
onConfirmFavorite?.(alias, false);
|
|
12
|
+
}, children: _jsx(DeleteIcon, {}) })) : null] }));
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=PopperButtonGroup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PopperButtonGroup.js","sourceRoot":"","sources":["../../../../src/components/favorite/PopperButtonGroup.tsx"],"names":[],"mappings":";AAAA,OAAO,UAAU,MAAM,4BAA4B,CAAA;AACnD,OAAO,QAAQ,MAAM,0BAA0B,CAAA;AAC/C,OAAO,EAAE,MAAM,EAAE,WAAW,EAAoB,MAAM,eAAe,CAAA;AAQrE,MAAM,CAAC,MAAM,iBAAiB,GAAkC,CAAC,EAAE,KAAK,EAAE,iBAAiB,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,EAAE;IACnH,OAAO,CACL,MAAC,WAAW,OAAK,KAAK,aACpB,KAAC,MAAM,IACL,OAAO,EAAC,WAAW,EACnB,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE;oBACb,CAAC,CAAC,eAAe,EAAE,CAAA;oBACnB,iBAAiB,EAAE,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;gBAClC,CAAC,YAED,KAAC,QAAQ,KAAG,GACL,EACR,QAAQ,CAAC,CAAC,CAAC,CACV,KAAC,MAAM,IACL,OAAO,EAAC,WAAW,EACnB,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE;oBACb,CAAC,CAAC,eAAe,EAAE,CAAA;oBACnB,iBAAiB,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;gBACnC,CAAC,YAED,KAAC,UAAU,KAAG,GACP,CACV,CAAC,CAAC,CAAC,IAAI,IACI,CACf,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PopperId.js","sourceRoot":"","sources":["../../../../../src/components/favorite/lib/PopperId.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,QAAQ,GAAG,iBAAiB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/components/favorite/lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,OAAO,CAAA;AACrB,cAAc,gBAAgB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FavoriteItemEvent.js","sourceRoot":"","sources":["../../../../src/components/lib/FavoriteItemEvent.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RenderRowBox.d.ts","sourceRoot":"","sources":["../../../src/components/RenderRowBox.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,YAAY,EAAe,MAAM,uBAAuB,CAAA;AAEjE,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAOnD,MAAM,WAAW,4BAA4B;IAC3C,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB;AAED,MAAM,WAAW,wBAAyB,SAAQ,YAAY,EAAE,4BAA4B,EAAE,YAAY;CAAG;AAE7G,eAAO,MAAM,mBAAmB,
|
|
1
|
+
{"version":3,"file":"RenderRowBox.d.ts","sourceRoot":"","sources":["../../../src/components/RenderRowBox.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,YAAY,EAAe,MAAM,uBAAuB,CAAA;AAEjE,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAOnD,MAAM,WAAW,4BAA4B;IAC3C,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB;AAED,MAAM,WAAW,wBAAyB,SAAQ,YAAY,EAAE,4BAA4B,EAAE,YAAY;CAAG;AAE7G,eAAO,MAAM,mBAAmB,kHAkC/B,CAAA"}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { IconButtonProps } from '@mui/material';
|
|
3
3
|
import { WithChildren } from '@xylabs/react-shared';
|
|
4
|
-
|
|
5
|
-
address?: string;
|
|
6
|
-
favorite: boolean;
|
|
7
|
-
}
|
|
4
|
+
import { FavoriteItemEvent } from '../lib';
|
|
8
5
|
export interface FavoriteIconButtonProps extends WithChildren, IconButtonProps {
|
|
9
|
-
|
|
10
|
-
favorite?:
|
|
6
|
+
alias?: FavoriteItemEvent['alias'];
|
|
7
|
+
favorite?: FavoriteItemEvent['favorite'];
|
|
8
|
+
value?: string;
|
|
9
|
+
valueType?: FavoriteItemEvent['favoriteType'];
|
|
11
10
|
}
|
|
12
11
|
export declare const FavoriteIconButton: import("react").ForwardRefExoticComponent<Omit<FavoriteIconButtonProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
|
|
13
12
|
//# sourceMappingURL=FavoriteIconButton.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FavoriteIconButton.d.ts","sourceRoot":"","sources":["../../../../src/components/favorite/FavoriteIconButton.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAc,eAAe,EAAE,MAAM,eAAe,CAAA;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAKnD,
|
|
1
|
+
{"version":3,"file":"FavoriteIconButton.d.ts","sourceRoot":"","sources":["../../../../src/components/favorite/FavoriteIconButton.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAc,eAAe,EAAE,MAAM,eAAe,CAAA;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAKnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAA;AAI1C,MAAM,WAAW,uBAAwB,SAAQ,YAAY,EAAE,eAAe;IAC5E,KAAK,CAAC,EAAE,iBAAiB,CAAC,OAAO,CAAC,CAAA;IAClC,QAAQ,CAAC,EAAE,iBAAiB,CAAC,UAAU,CAAC,CAAA;IACxC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,SAAS,CAAC,EAAE,iBAAiB,CAAC,cAAc,CAAC,CAAA;CAC9C;AAED,eAAO,MAAM,kBAAkB,oIAoD9B,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { PopperProps } from '@mui/material';
|
|
2
|
+
import { RefObject } from 'react';
|
|
3
|
+
export interface FavoritePopperProps extends PopperProps {
|
|
4
|
+
alias?: string;
|
|
5
|
+
favorite?: boolean;
|
|
6
|
+
favoriteRef?: RefObject<HTMLElement>;
|
|
7
|
+
onClickAway?: (event: MouseEvent | TouchEvent) => void;
|
|
8
|
+
onConfirmFavorite?: (alias?: string, newFavoriteState?: boolean) => void;
|
|
9
|
+
}
|
|
10
|
+
export declare const FavoritePopper: import("react").ForwardRefExoticComponent<Omit<FavoritePopperProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
11
|
+
//# sourceMappingURL=Popper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Popper.d.ts","sourceRoot":"","sources":["../../../../src/components/favorite/Popper.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAsD,WAAW,EAAa,MAAM,eAAe,CAAA;AAC1G,OAAO,EAAc,SAAS,EAAuB,MAAM,OAAO,CAAA;AAKlE,MAAM,WAAW,mBAAoB,SAAQ,WAAW;IACtD,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,WAAW,CAAC,EAAE,SAAS,CAAC,WAAW,CAAC,CAAA;IACpC,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,KAAK,IAAI,CAAA;IACtD,iBAAiB,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,gBAAgB,CAAC,EAAE,OAAO,KAAK,IAAI,CAAA;CACzE;AACD,eAAO,MAAM,cAAc,6HA2C1B,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ButtonGroupProps } from '@mui/material';
|
|
3
|
+
export interface FavoritePopperProps extends ButtonGroupProps {
|
|
4
|
+
alias?: string;
|
|
5
|
+
favorite?: boolean;
|
|
6
|
+
onConfirmFavorite?: (alias?: string, newFavoriteState?: boolean) => void;
|
|
7
|
+
}
|
|
8
|
+
export declare const PopperButtonGroup: React.FC<FavoritePopperProps>;
|
|
9
|
+
//# sourceMappingURL=PopperButtonGroup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PopperButtonGroup.d.ts","sourceRoot":"","sources":["../../../../src/components/favorite/PopperButtonGroup.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAuB,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAErE,MAAM,WAAW,mBAAoB,SAAQ,gBAAgB;IAC3D,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,iBAAiB,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,gBAAgB,CAAC,EAAE,OAAO,KAAK,IAAI,CAAA;CACzE;AAED,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAyB3D,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PopperId.d.ts","sourceRoot":"","sources":["../../../../../src/components/favorite/lib/PopperId.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,QAAQ,oBAAoB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/favorite/lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,OAAO,CAAA;AACrB,cAAc,gBAAgB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FavoriteItemEvent.d.ts","sourceRoot":"","sources":["../../../../src/components/lib/FavoriteItemEvent.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IAChC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,YAAY,CAAC,EAAE,SAAS,GAAG,QAAQ,GAAG,MAAM,CAAA;IAC5C,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA"}
|
package/package.json
CHANGED
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
"@xylabs/react-flexbox": "^2.16.11",
|
|
14
14
|
"@xylabs/react-identicon": "^2.16.11",
|
|
15
15
|
"@xylabs/react-shared": "^2.16.11",
|
|
16
|
-
"@xyo-network/react-event": "^2.47.
|
|
17
|
-
"@xyo-network/react-shared": "^2.47.
|
|
16
|
+
"@xyo-network/react-event": "^2.47.5",
|
|
17
|
+
"@xyo-network/react-shared": "^2.47.5"
|
|
18
18
|
},
|
|
19
19
|
"peerDependencies": {
|
|
20
20
|
"@mui/icons-material": "^5",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"@storybook/react": "^6.5.16",
|
|
31
31
|
"@xylabs/ts-scripts-yarn3": "^2.16.1",
|
|
32
32
|
"@xylabs/tsconfig-react": "^2.16.1",
|
|
33
|
-
"@xyo-network/account": "^2.53.
|
|
33
|
+
"@xyo-network/account": "^2.53.7",
|
|
34
34
|
"require-from-string": "^2.0.2",
|
|
35
35
|
"typescript": "^4.9.5"
|
|
36
36
|
},
|
|
@@ -76,5 +76,5 @@
|
|
|
76
76
|
},
|
|
77
77
|
"sideEffects": false,
|
|
78
78
|
"types": "dist/types/index.d.ts",
|
|
79
|
-
"version": "2.47.
|
|
79
|
+
"version": "2.47.5"
|
|
80
80
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { ComponentMeta, ComponentStory } from '@storybook/react'
|
|
2
2
|
import { Account } from '@xyo-network/account'
|
|
3
3
|
import { useXyoEvent } from '@xyo-network/react-event'
|
|
4
|
+
import { useState } from 'react'
|
|
4
5
|
|
|
6
|
+
import { FavoriteItemEvent } from './lib'
|
|
5
7
|
import { AddressRenderRowBox } from './RenderRowBox'
|
|
6
8
|
|
|
7
9
|
const address = new Account({ phrase: 'temp' }).addressValue.hex
|
|
@@ -18,8 +20,17 @@ const StorybookEntry = {
|
|
|
18
20
|
} as ComponentMeta<typeof AddressRenderRowBox>
|
|
19
21
|
|
|
20
22
|
const Template: ComponentStory<typeof AddressRenderRowBox> = (args) => {
|
|
21
|
-
const [ref] = useXyoEvent<HTMLLIElement>((noun, verb, data) =>
|
|
22
|
-
|
|
23
|
+
const [ref] = useXyoEvent<HTMLLIElement>((noun, verb, data) => {
|
|
24
|
+
console.log(`${noun}|${verb}|${data}`)
|
|
25
|
+
const parsedEvent = JSON.parse(data ?? '') as FavoriteItemEvent
|
|
26
|
+
if (parsedEvent.favorite) {
|
|
27
|
+
setAlias(parsedEvent.alias)
|
|
28
|
+
} else {
|
|
29
|
+
setAlias(undefined)
|
|
30
|
+
}
|
|
31
|
+
})
|
|
32
|
+
const [alias, setAlias] = useState(args.alias)
|
|
33
|
+
return <AddressRenderRowBox {...args} alias={alias} ref={ref} />
|
|
23
34
|
}
|
|
24
35
|
|
|
25
36
|
const Default = Template.bind({})
|
|
@@ -51,6 +62,15 @@ WithFavorite.args = {
|
|
|
51
62
|
showFavorite: true,
|
|
52
63
|
}
|
|
53
64
|
|
|
65
|
+
const WithFavoriteAlias = Template.bind({})
|
|
66
|
+
WithFavoriteAlias.args = {
|
|
67
|
+
address,
|
|
68
|
+
alias: 'My Alias',
|
|
69
|
+
favorite: true,
|
|
70
|
+
icons: true,
|
|
71
|
+
showFavorite: true,
|
|
72
|
+
}
|
|
73
|
+
|
|
54
74
|
const WithChildren = Template.bind({})
|
|
55
75
|
WithChildren.args = {
|
|
56
76
|
address,
|
|
@@ -60,7 +80,7 @@ WithChildren.args = {
|
|
|
60
80
|
showFavorite: true,
|
|
61
81
|
}
|
|
62
82
|
|
|
63
|
-
export { Default, WithAddress, WithChildren, WithFavorite, WithIcon, WithIconOnly }
|
|
83
|
+
export { Default, WithAddress, WithChildren, WithFavorite, WithFavoriteAlias, WithIcon, WithIconOnly }
|
|
64
84
|
|
|
65
85
|
// eslint-disable-next-line import/no-default-export
|
|
66
86
|
export default StorybookEntry
|
|
@@ -10,6 +10,7 @@ import { FavoriteIconButton } from './favorite'
|
|
|
10
10
|
|
|
11
11
|
export interface AddressRenderRowBoxPropsBase {
|
|
12
12
|
address?: string | null
|
|
13
|
+
alias?: string
|
|
13
14
|
favorite?: boolean
|
|
14
15
|
iconOnly?: boolean
|
|
15
16
|
iconSize?: number
|
|
@@ -21,7 +22,7 @@ export interface AddressRenderRowBoxPropsBase {
|
|
|
21
22
|
export interface AddressRenderRowBoxProps extends WithChildren, AddressRenderRowBoxPropsBase, FlexBoxProps {}
|
|
22
23
|
|
|
23
24
|
export const AddressRenderRowBox = forwardRef<HTMLElement, AddressRenderRowBoxProps>(
|
|
24
|
-
({ address, children, favorite: favoriteProp = false, iconOnly, iconSize = 24, icons, name, showFavorite = false, ...props }, ref) => {
|
|
25
|
+
({ address, alias, children, favorite: favoriteProp = false, iconOnly, iconSize = 24, icons, name, showFavorite = false, ...props }, ref) => {
|
|
25
26
|
const theme = useTheme()
|
|
26
27
|
|
|
27
28
|
const sharedRef = useShareForwardedRef(ref)
|
|
@@ -43,12 +44,14 @@ export const AddressRenderRowBox = forwardRef<HTMLElement, AddressRenderRowBoxPr
|
|
|
43
44
|
{iconOnly ? null : (
|
|
44
45
|
<ListItemText>
|
|
45
46
|
<EllipsizeBox ellipsisPosition={'end'} width="100%" typographyProps={{ fontSize: theme.typography.body1.fontSize }}>
|
|
46
|
-
{name ?? address}
|
|
47
|
+
{alias ?? name ?? address}
|
|
47
48
|
</EllipsizeBox>
|
|
48
49
|
</ListItemText>
|
|
49
50
|
)}
|
|
50
51
|
{children}
|
|
51
|
-
{showFavorite && address ?
|
|
52
|
+
{showFavorite && address ? (
|
|
53
|
+
<FavoriteIconButton alias={alias} size={'small'} value={address} valueType={'address'} favorite={favoriteProp} />
|
|
54
|
+
) : null}
|
|
52
55
|
</FlexGrowRow>
|
|
53
56
|
)
|
|
54
57
|
},
|
|
@@ -4,20 +4,23 @@ import { IconButton, IconButtonProps } from '@mui/material'
|
|
|
4
4
|
import { WithChildren } from '@xylabs/react-shared'
|
|
5
5
|
import { useXyoEvent } from '@xyo-network/react-event'
|
|
6
6
|
import { useShareForwardedRef } from '@xyo-network/react-shared'
|
|
7
|
-
import { forwardRef, useEffect, useState } from 'react'
|
|
7
|
+
import { forwardRef, useEffect, useRef, useState } from 'react'
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
9
|
+
import { FavoriteItemEvent } from '../lib'
|
|
10
|
+
import { popperId } from './lib'
|
|
11
|
+
import { FavoritePopper } from './Popper'
|
|
13
12
|
|
|
14
13
|
export interface FavoriteIconButtonProps extends WithChildren, IconButtonProps {
|
|
15
|
-
|
|
16
|
-
favorite?:
|
|
14
|
+
alias?: FavoriteItemEvent['alias']
|
|
15
|
+
favorite?: FavoriteItemEvent['favorite']
|
|
16
|
+
value?: string
|
|
17
|
+
valueType?: FavoriteItemEvent['favoriteType']
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
export const FavoriteIconButton = forwardRef<HTMLButtonElement, FavoriteIconButtonProps>(
|
|
20
|
-
({
|
|
21
|
+
({ alias, children, favorite: favoriteProp, valueType, value, ...props }, ref) => {
|
|
22
|
+
const [openPopper, setOpenPopper] = useState(false)
|
|
23
|
+
|
|
21
24
|
const [favorite, setFavorite] = useState(favoriteProp)
|
|
22
25
|
useEffect(() => {
|
|
23
26
|
setFavorite(favoriteProp)
|
|
@@ -25,27 +28,43 @@ export const FavoriteIconButton = forwardRef<HTMLButtonElement, FavoriteIconButt
|
|
|
25
28
|
|
|
26
29
|
const sharedRef = useShareForwardedRef(ref)
|
|
27
30
|
const [buttonRef, dispatch] = useXyoEvent(undefined, sharedRef)
|
|
31
|
+
const onConfirmFavorite = (alias?: string, newFavoriteState?: boolean) => {
|
|
32
|
+
setFavorite(() => {
|
|
33
|
+
const favoriteEvent: FavoriteItemEvent = {
|
|
34
|
+
alias,
|
|
35
|
+
favorite: !!newFavoriteState,
|
|
36
|
+
favoriteType: valueType,
|
|
37
|
+
favoriteValue: value,
|
|
38
|
+
}
|
|
39
|
+
dispatch('address', 'favorite', JSON.stringify(favoriteEvent))
|
|
40
|
+
return newFavoriteState
|
|
41
|
+
})
|
|
42
|
+
setOpenPopper(false)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const starRef = useRef<HTMLSpanElement>(null)
|
|
28
46
|
|
|
29
47
|
return (
|
|
30
48
|
<IconButton
|
|
31
49
|
ref={buttonRef}
|
|
50
|
+
aria-describedby={popperId}
|
|
32
51
|
// used to prevent parent items from rippling when IconButton is clicked
|
|
33
52
|
onMouseDown={(e) => e.stopPropagation()}
|
|
34
53
|
onClick={(event) => {
|
|
35
54
|
event.stopPropagation()
|
|
36
|
-
|
|
37
|
-
const newFavoriteState = !current
|
|
38
|
-
const favoriteEvent: FavoriteEvent = {
|
|
39
|
-
address,
|
|
40
|
-
favorite: newFavoriteState,
|
|
41
|
-
}
|
|
42
|
-
dispatch('address', 'favorite', JSON.stringify(favoriteEvent))
|
|
43
|
-
return newFavoriteState
|
|
44
|
-
})
|
|
55
|
+
setOpenPopper(true)
|
|
45
56
|
}}
|
|
46
57
|
{...props}
|
|
47
58
|
>
|
|
48
|
-
{favorite ? <StarIcon color="secondary" /> : <StarBorderIcon />}
|
|
59
|
+
<span ref={starRef}>{favorite ? <StarIcon component={'svg'} color="secondary" /> : <StarBorderIcon />}</span>
|
|
60
|
+
<FavoritePopper
|
|
61
|
+
alias={alias}
|
|
62
|
+
favorite={favorite}
|
|
63
|
+
favoriteRef={starRef}
|
|
64
|
+
open={openPopper}
|
|
65
|
+
onConfirmFavorite={onConfirmFavorite}
|
|
66
|
+
onClickAway={() => setOpenPopper(false)}
|
|
67
|
+
/>
|
|
49
68
|
{children}
|
|
50
69
|
</IconButton>
|
|
51
70
|
)
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Card, CardContent, ClickAwayListener, Fade, Popper, PopperProps, TextField } from '@mui/material'
|
|
2
|
+
import { forwardRef, RefObject, useEffect, useState } from 'react'
|
|
3
|
+
|
|
4
|
+
import { popperId } from './lib'
|
|
5
|
+
import { PopperButtonGroup } from './PopperButtonGroup'
|
|
6
|
+
|
|
7
|
+
export interface FavoritePopperProps extends PopperProps {
|
|
8
|
+
alias?: string
|
|
9
|
+
favorite?: boolean
|
|
10
|
+
favoriteRef?: RefObject<HTMLElement>
|
|
11
|
+
onClickAway?: (event: MouseEvent | TouchEvent) => void
|
|
12
|
+
onConfirmFavorite?: (alias?: string, newFavoriteState?: boolean) => void
|
|
13
|
+
}
|
|
14
|
+
export const FavoritePopper = forwardRef<HTMLDivElement, FavoritePopperProps>(
|
|
15
|
+
(
|
|
16
|
+
{
|
|
17
|
+
alias: aliasProp,
|
|
18
|
+
favorite,
|
|
19
|
+
favoriteRef,
|
|
20
|
+
onClickAway = () => {
|
|
21
|
+
return
|
|
22
|
+
},
|
|
23
|
+
onConfirmFavorite,
|
|
24
|
+
...props
|
|
25
|
+
},
|
|
26
|
+
ref,
|
|
27
|
+
) => {
|
|
28
|
+
const [alias, setAlias] = useState<string>()
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
setAlias(aliasProp)
|
|
31
|
+
}, [aliasProp])
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<ClickAwayListener onClickAway={onClickAway}>
|
|
35
|
+
<Popper id={popperId} anchorEl={favoriteRef?.current} transition ref={ref} {...props}>
|
|
36
|
+
{({ TransitionProps }) => (
|
|
37
|
+
<Fade {...TransitionProps} timeout={350}>
|
|
38
|
+
<Card>
|
|
39
|
+
<CardContent sx={{ display: 'flex', gap: 1 }}>
|
|
40
|
+
<TextField
|
|
41
|
+
autoFocus
|
|
42
|
+
label="Favorite Alias"
|
|
43
|
+
placeholder="optional"
|
|
44
|
+
size="small"
|
|
45
|
+
value={alias ?? ''}
|
|
46
|
+
onChange={(e) => setAlias(e.target.value)}
|
|
47
|
+
/>
|
|
48
|
+
<PopperButtonGroup favorite={favorite} onConfirmFavorite={onConfirmFavorite} alias={alias} />
|
|
49
|
+
</CardContent>
|
|
50
|
+
</Card>
|
|
51
|
+
</Fade>
|
|
52
|
+
)}
|
|
53
|
+
</Popper>
|
|
54
|
+
</ClickAwayListener>
|
|
55
|
+
)
|
|
56
|
+
},
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
FavoritePopper.displayName = 'FavoritePopper'
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import DeleteIcon from '@mui/icons-material/Delete'
|
|
2
|
+
import StarIcon from '@mui/icons-material/Star'
|
|
3
|
+
import { Button, ButtonGroup, ButtonGroupProps } from '@mui/material'
|
|
4
|
+
|
|
5
|
+
export interface FavoritePopperProps extends ButtonGroupProps {
|
|
6
|
+
alias?: string
|
|
7
|
+
favorite?: boolean
|
|
8
|
+
onConfirmFavorite?: (alias?: string, newFavoriteState?: boolean) => void
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const PopperButtonGroup: React.FC<FavoritePopperProps> = ({ alias, onConfirmFavorite, favorite, ...props }) => {
|
|
12
|
+
return (
|
|
13
|
+
<ButtonGroup {...props}>
|
|
14
|
+
<Button
|
|
15
|
+
variant="contained"
|
|
16
|
+
onClick={(e) => {
|
|
17
|
+
e.stopPropagation()
|
|
18
|
+
onConfirmFavorite?.(alias, true)
|
|
19
|
+
}}
|
|
20
|
+
>
|
|
21
|
+
<StarIcon />
|
|
22
|
+
</Button>
|
|
23
|
+
{favorite ? (
|
|
24
|
+
<Button
|
|
25
|
+
variant="contained"
|
|
26
|
+
onClick={(e) => {
|
|
27
|
+
e.stopPropagation()
|
|
28
|
+
onConfirmFavorite?.(alias, false)
|
|
29
|
+
}}
|
|
30
|
+
>
|
|
31
|
+
<DeleteIcon />
|
|
32
|
+
</Button>
|
|
33
|
+
) : null}
|
|
34
|
+
</ButtonGroup>
|
|
35
|
+
)
|
|
36
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const popperId = 'favorite-popper'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './PopperId'
|
package/src/components/index.ts
CHANGED