@xyo-network/react-address-render 2.47.16 → 2.47.18
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 +2 -3
- package/dist/cjs/components/RenderRowBox.js.map +1 -1
- package/dist/cjs/components/favorite/FavoriteIconButton.js +4 -4
- package/dist/cjs/components/favorite/FavoriteIconButton.js.map +1 -1
- package/dist/cjs/components/favorite/Popper.js +6 -6
- package/dist/cjs/components/favorite/Popper.js.map +1 -1
- package/dist/cjs/components/favorite/PopperButtonGroup.js +3 -3
- package/dist/cjs/components/favorite/PopperButtonGroup.js.map +1 -1
- package/dist/cjs/components/lib/FavoriteItemEvent.js +2 -2
- package/dist/cjs/components/lib/FavoriteItemEvent.js.map +1 -1
- package/dist/docs.json +565 -610
- package/dist/esm/components/RenderRowBox.js +2 -2
- package/dist/esm/components/RenderRowBox.js.map +1 -1
- package/dist/esm/components/favorite/FavoriteIconButton.js +4 -4
- package/dist/esm/components/favorite/FavoriteIconButton.js.map +1 -1
- package/dist/esm/components/favorite/Popper.js +5 -5
- package/dist/esm/components/favorite/Popper.js.map +1 -1
- package/dist/esm/components/favorite/PopperButtonGroup.js +3 -3
- package/dist/esm/components/favorite/PopperButtonGroup.js.map +1 -1
- package/dist/esm/components/lib/FavoriteItemEvent.js +2 -2
- package/dist/esm/components/lib/FavoriteItemEvent.js.map +1 -1
- package/dist/types/components/RenderRowBox.d.ts +0 -1
- package/dist/types/components/RenderRowBox.d.ts.map +1 -1
- package/dist/types/components/favorite/FavoriteIconButton.d.ts +1 -1
- package/dist/types/components/favorite/FavoriteIconButton.d.ts.map +1 -1
- package/dist/types/components/favorite/Popper.d.ts +2 -2
- package/dist/types/components/favorite/Popper.d.ts.map +1 -1
- package/dist/types/components/favorite/PopperButtonGroup.d.ts +2 -2
- package/dist/types/components/favorite/PopperButtonGroup.d.ts.map +1 -1
- package/dist/types/components/lib/FavoriteItemEvent.d.ts +2 -2
- package/dist/types/components/lib/FavoriteItemEvent.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/components/RenderRowBox.stories.tsx +5 -5
- package/src/components/RenderRowBox.tsx +3 -4
- package/src/components/favorite/FavoriteIconButton.tsx +5 -5
- package/src/components/favorite/Popper.tsx +10 -10
- package/src/components/favorite/PopperButtonGroup.tsx +5 -5
- package/src/components/lib/FavoriteItemEvent.ts +3 -8
|
@@ -6,12 +6,12 @@ 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,
|
|
9
|
+
export const AddressRenderRowBox = forwardRef(({ address, 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
13
|
const handleClickedAddress = () => (address ? dispatch('address', 'click', address) : undefined);
|
|
14
|
-
return (_jsxs(FlexGrowRow, { gap: 2, justifyContent: "flex-start", ref: elementRef, onClick: handleClickedAddress, ...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:
|
|
14
|
+
return (_jsxs(FlexGrowRow, { gap: 2, justifyContent: "flex-start", ref: elementRef, onClick: handleClickedAddress, ...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, { name: name, size: 'small', value: address, valueType: 'address', favorite: favoriteProp })) : null] }));
|
|
15
15
|
});
|
|
16
16
|
AddressRenderRowBox.displayName = 'AddressRenderRowBox';
|
|
17
17
|
//# 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;AA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ChB,EACA,QAAQ,EACR,YAAY,IAAI,OAAO,CAAC,CAAC,CAAC,CACzB,KAAC,kBAAkB,IAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,YAAY,GAAI,CAChH,CAAC,CAAC,CAAC,IAAI,IACI,CACf,CAAA;AACH,CAAC,CACF,CAAA;AAED,mBAAmB,CAAC,WAAW,GAAG,qBAAqB,CAAA"}
|
|
@@ -7,7 +7,7 @@ import { generateFavoriteEvent } from '../lib';
|
|
|
7
7
|
import { FavoriteToggleSVG } from './FavoriteToggleSVG';
|
|
8
8
|
import { popperId } from './lib';
|
|
9
9
|
import { FavoritePopper } from './Popper';
|
|
10
|
-
export const FavoriteIconButton = forwardRef(({
|
|
10
|
+
export const FavoriteIconButton = forwardRef(({ children, favorite: favoriteProp, name, valueType, value, ...props }, ref) => {
|
|
11
11
|
const [openPopper, setOpenPopper] = useState(false);
|
|
12
12
|
const [favorite, setFavorite] = useState(favoriteProp);
|
|
13
13
|
useEffect(() => {
|
|
@@ -15,8 +15,8 @@ export const FavoriteIconButton = forwardRef(({ alias, children, favorite: favor
|
|
|
15
15
|
}, [favoriteProp]);
|
|
16
16
|
const sharedRef = useShareForwardedRef(ref);
|
|
17
17
|
const [buttonRef, dispatch] = useXyoEvent(undefined, sharedRef);
|
|
18
|
-
const onConfirmFavorite = (
|
|
19
|
-
const favoriteEvent = generateFavoriteEvent(
|
|
18
|
+
const onConfirmFavorite = (name, newFavoriteState) => {
|
|
19
|
+
const favoriteEvent = generateFavoriteEvent(!!newFavoriteState, valueType, value, name);
|
|
20
20
|
dispatch('address', 'favorite', JSON.stringify(favoriteEvent));
|
|
21
21
|
setFavorite(newFavoriteState);
|
|
22
22
|
setOpenPopper(false);
|
|
@@ -25,7 +25,7 @@ export const FavoriteIconButton = forwardRef(({ alias, children, favorite: favor
|
|
|
25
25
|
return (_jsxs(IconButton, { "aria-describedby": popperId, ref: buttonRef, onClick: (event) => {
|
|
26
26
|
event.stopPropagation();
|
|
27
27
|
setOpenPopper(!openPopper);
|
|
28
|
-
}, onMouseDown: (e) => e.stopPropagation(), ...props, children: [_jsx("span", { ref: starRef, children: _jsx(FavoriteToggleSVG, { favorite: favorite }) }), _jsx(FavoritePopper, { sx: { zIndex: 1301 },
|
|
28
|
+
}, onMouseDown: (e) => e.stopPropagation(), ...props, children: [_jsx("span", { ref: starRef, children: _jsx(FavoriteToggleSVG, { favorite: favorite }) }), _jsx(FavoritePopper, { sx: { zIndex: 1301 }, name: name, favorite: favorite, favoriteRef: starRef, open: openPopper, onConfirmFavorite: onConfirmFavorite, onClickAway: () => setOpenPopper(false) }), children] }));
|
|
29
29
|
});
|
|
30
30
|
FavoriteIconButton.displayName = 'FavoriteIconButton';
|
|
31
31
|
//# sourceMappingURL=FavoriteIconButton.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FavoriteIconButton.js","sourceRoot":"","sources":["../../../../src/components/favorite/FavoriteIconButton.tsx"],"names":[],"mappings":";AAAA,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,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAE/D,OAAO,EAAqB,qBAAqB,EAAE,MAAM,QAAQ,CAAA;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAChC,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AASzC,MAAM,CAAC,MAAM,kBAAkB,GAAG,UAAU,CAC1C,CAAC,EAAE,
|
|
1
|
+
{"version":3,"file":"FavoriteIconButton.js","sour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B,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,CAAC,CAAA;QACvF,QAAQ,CAAC,SAAS,EAAE,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC,CAAA;QAC9D,WAAW,CAAC,gBAAgB,CAAC,CAAA;QAC7B,aAAa,CAAC,KAAK,CAAC,CAAA;IACtB,CAAC,CAAA;IAED,MAAM,OAAO,GAAG,MAAM,CAAkB,IAAI,CAAC,CAAA;IAE7C,OAAO,CACL,MAAC,UAAU,wBACS,QAAQ,EAC1B,GAAG,EAAE,SAAS,EACd,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;YACjB,KAAK,CAAC,eAAe,EAAE,CAAA;YACvB,aAAa,CAAC,CAAC,UAAU,CAAC,CAAA;QAC5B,CAAC,EACD,WAAW,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,eAAe,EAAE,KACnC,KAAK,aAET,eAAM,GAAG,EAAE,OAAO,YAChB,KAAC,iBAAiB,IAAC,QAAQ,EAAE,QAAQ,GAAI,GACpC,EACP,KAAC,cAAc,IACb,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,EACpB,IAAI,EAAE,IAAI,EACV,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"}
|
|
@@ -3,14 +3,14 @@ import { Card, CardContent, ClickAwayListener, Fade, Popper, styled, TextField }
|
|
|
3
3
|
import { forwardRef, useEffect, useState } from 'react';
|
|
4
4
|
import { popperId } from './lib';
|
|
5
5
|
import { PopperButtonGroup } from './PopperButtonGroup';
|
|
6
|
-
export const FavoritePopper = forwardRef(({
|
|
6
|
+
export const FavoritePopper = forwardRef(({ name: nameProp, favorite, favoriteRef, onClickAway = () => {
|
|
7
7
|
return;
|
|
8
8
|
}, onConfirmFavorite, ...props }, ref) => {
|
|
9
|
-
const [
|
|
9
|
+
const [name, setName] = useState(nameProp);
|
|
10
10
|
useEffect(() => {
|
|
11
|
-
|
|
12
|
-
}, [
|
|
13
|
-
return (_jsx(ClickAwayListener, { onClickAway: onClickAway, children: _jsx(PopperStyled, { id: popperId, anchorEl: favoriteRef?.current, onClick: (e) => e.stopPropagation(), 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
|
|
11
|
+
setName(nameProp);
|
|
12
|
+
}, [nameProp]);
|
|
13
|
+
return (_jsx(ClickAwayListener, { onClickAway: onClickAway, children: _jsx(PopperStyled, { id: popperId, anchorEl: favoriteRef?.current, onClick: (e) => e.stopPropagation(), 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 Name", placeholder: "optional", size: "small", value: name ?? '', onChange: (e) => setName(e.target.value) }), _jsx(PopperButtonGroup, { favorite: favorite, onConfirmFavorite: onConfirmFavorite, name: name })] }) }) })) }) }));
|
|
14
14
|
});
|
|
15
15
|
FavoritePopper.displayName = 'FavoritePopper';
|
|
16
16
|
// Ensure the popper is over all other mui portal elements
|
|
@@ -1 +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,MAAM,EAAE,SAAS,EAAE,MAAM,e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AAe,EAAE,EAAE,UAAU,QAAC,GAAG,EAAE,GAAG,KAAM,KAAK,YAC5H,CAAC,EAAE,eAAe,EAAE,EAAE,EAAE,CAAC,CACxB,KAAC,IAAI,OAAK,eAAe,EAAE,OAAO,EAAE,GAAG,YACrC,KAAC,IAAI,cACH,MAAC,WAAW,IAAC,EAAE,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,aAC1C,KAAC,SAAS,IACR,SAAS,QACT,KAAK,EAAC,eAAe,EACrB,WAAW,EAAC,UAAU,EACtB,IAAI,EAAC,OAAO,EACZ,KAAK,EAAE,IAAI,IAAI,EAAE,EACjB,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,GACxC,EACF,KAAC,iBAAiB,IAAC,QAAQ,EAAE,QAAQ,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,IAAI,EAAE,IAAI,GAAI,IAC/E,GACT,GACF,CACR,GACY,GACG,CACrB,CAAA;AACH,CAAC,CACF,CAAA;AAED,cAAc,CAAC,WAAW,GAAG,gBAAgB,CAAA;AAE7C,0DAA0D;AAC1D,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA"}
|
|
@@ -2,13 +2,13 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import DeleteIcon from '@mui/icons-material/Delete';
|
|
3
3
|
import StarIcon from '@mui/icons-material/Star';
|
|
4
4
|
import { Button, ButtonGroup } from '@mui/material';
|
|
5
|
-
export const PopperButtonGroup = ({
|
|
5
|
+
export const PopperButtonGroup = ({ name, onConfirmFavorite, favorite, ...props }) => {
|
|
6
6
|
return (_jsxs(ButtonGroup, { ...props, children: [_jsx(Button, { title: "Save Favorite", variant: "contained", onClick: (e) => {
|
|
7
7
|
e.stopPropagation();
|
|
8
|
-
onConfirmFavorite?.(
|
|
8
|
+
onConfirmFavorite?.(name, true);
|
|
9
9
|
}, children: _jsx(StarIcon, {}) }), favorite ? (_jsx(Button, { title: "Remove Favorite", variant: "contained", onClick: (e) => {
|
|
10
10
|
e.stopPropagation();
|
|
11
|
-
onConfirmFavorite?.(
|
|
11
|
+
onConfirmFavorite?.(name, false);
|
|
12
12
|
}, children: _jsx(DeleteIcon, {}) })) : null] }));
|
|
13
13
|
};
|
|
14
14
|
//# sourceMappingURL=PopperButtonGroup.js.map
|
|
@@ -1 +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,
|
|
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,IAAI,EAAE,iBAAiB,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,EAAE;IAClH,OAAO,CACL,MAAC,WAAW,OAAK,KAAK,aACpB,KAAC,MAAM,IACL,KAAK,EAAC,eAAe,EACrB,OAAO,EAAC,WAAW,EACnB,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE;oBACb,CAAC,CAAC,eAAe,EAAE,CAAA;oBACnB,iBAAiB,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;gBACjC,CAAC,YAED,KAAC,QAAQ,KAAG,GACL,EACR,QAAQ,CAAC,CAAC,CAAC,CACV,KAAC,MAAM,IACL,KAAK,EAAC,iBAAiB,EACvB,OAAO,EAAC,WAAW,EACnB,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE;oBACb,CAAC,CAAC,eAAe,EAAE,CAAA;oBACnB,iBAAiB,EAAE,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;gBAClC,CAAC,YAED,KAAC,UAAU,KAAG,GACP,CACV,CAAC,CAAC,CAAC,IAAI,IACI,CACf,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export const generateFavoriteEvent = (
|
|
2
|
-
alias,
|
|
1
|
+
export const generateFavoriteEvent = (favorite, favoriteType, favoriteValue, name) => ({
|
|
3
2
|
favorite: !!favorite,
|
|
4
3
|
favoriteType,
|
|
5
4
|
favoriteValue,
|
|
5
|
+
name,
|
|
6
6
|
});
|
|
7
7
|
//# sourceMappingURL=FavoriteItemEvent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FavoriteItemEvent.js","sourceRoot":"","sources":["../../../../src/components/lib/FavoriteItemEvent.ts"],"names":[],"mappings":"AASA,MAAM,CAAC,MAAM,qBAAqB,GAAG,
|
|
1
|
+
{"version":3,"file":"FavoriteItemEvent.js","sourceRoot":"","sources":["../../../../src/components/lib/FavoriteItemEvent.ts"],"names":[],"mappings":"AASA,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,QAAkB,EAAE,YAA2B,EAAE,aAAsB,EAAE,IAAa,EAAqB,EAAE,CAAC,CAAC;IACnJ,QAAQ,EAAE,CAAC,CAAC,QAAQ;IACpB,YAAY;IACZ,aAAa;IACb,IAAI;CACL,CAAC,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,
|
|
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,kHA8B/B,CAAA"}
|
|
@@ -3,8 +3,8 @@ import { IconButtonProps } from '@mui/material';
|
|
|
3
3
|
import { WithChildren } from '@xylabs/react-shared';
|
|
4
4
|
import { FavoriteItemEvent } from '../lib';
|
|
5
5
|
export interface FavoriteIconButtonProps extends WithChildren, IconButtonProps {
|
|
6
|
-
alias?: FavoriteItemEvent['alias'];
|
|
7
6
|
favorite?: FavoriteItemEvent['favorite'];
|
|
7
|
+
name?: FavoriteItemEvent['name'];
|
|
8
8
|
value?: string;
|
|
9
9
|
valueType?: FavoriteItemEvent['favoriteType'];
|
|
10
10
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FavoriteIconButton.d.ts","sourceRoot":"","sources":["../../../../src/components/favorite/FavoriteIconButton.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAc,eAAe,EAAE,MAAM,eAAe,CAAA;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAKnD,OAAO,EAAE,iBAAiB,EAAyB,MAAM,QAAQ,CAAA;AAKjE,MAAM,WAAW,uBAAwB,SAAQ,YAAY,EAAE,eAAe;IAC5E,
|
|
1
|
+
{"version":3,"file":"FavoriteIconButton.d.ts","sourceRoot":"","sources":["../../../../src/components/favorite/FavoriteIconButton.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAc,eAAe,EAAE,MAAM,eAAe,CAAA;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAKnD,OAAO,EAAE,iBAAiB,EAAyB,MAAM,QAAQ,CAAA;AAKjE,MAAM,WAAW,uBAAwB,SAAQ,YAAY,EAAE,eAAe;IAC5E,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,oIAgD9B,CAAA"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { PopperProps } from '@mui/material';
|
|
2
2
|
import { RefObject } from 'react';
|
|
3
3
|
export interface FavoritePopperProps extends PopperProps {
|
|
4
|
-
alias?: string;
|
|
5
4
|
favorite?: boolean;
|
|
6
5
|
favoriteRef?: RefObject<HTMLElement>;
|
|
6
|
+
name?: string;
|
|
7
7
|
onClickAway?: (event: MouseEvent | TouchEvent) => void;
|
|
8
|
-
onConfirmFavorite?: (
|
|
8
|
+
onConfirmFavorite?: (name?: string, newFavoriteState?: boolean) => void;
|
|
9
9
|
}
|
|
10
10
|
export declare const FavoritePopper: import("react").ForwardRefExoticComponent<Omit<FavoritePopperProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
11
11
|
//# sourceMappingURL=Popper.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Popper.d.ts","sourceRoot":"","sources":["../../../../src/components/favorite/Popper.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAsD,WAAW,EAAqB,MAAM,eAAe,CAAA;AAClH,OAAO,EAAc,SAAS,EAAuB,MAAM,OAAO,CAAA;AAKlE,MAAM,WAAW,mBAAoB,SAAQ,WAAW;IACtD,
|
|
1
|
+
{"version":3,"file":"Popper.d.ts","sourceRoot":"","sources":["../../../../src/components/favorite/Popper.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAsD,WAAW,EAAqB,MAAM,eAAe,CAAA;AAClH,OAAO,EAAc,SAAS,EAAuB,MAAM,OAAO,CAAA;AAKlE,MAAM,WAAW,mBAAoB,SAAQ,WAAW;IACtD,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,WAAW,CAAC,EAAE,SAAS,CAAC,WAAW,CAAC,CAAA;IACpC,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,6HA2C1B,CAAA"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { ButtonGroupProps } from '@mui/material';
|
|
3
3
|
export interface FavoritePopperProps extends ButtonGroupProps {
|
|
4
|
-
alias?: string;
|
|
5
4
|
favorite?: boolean;
|
|
6
|
-
|
|
5
|
+
name?: string;
|
|
6
|
+
onConfirmFavorite?: (name?: string, newFavoriteState?: boolean) => void;
|
|
7
7
|
}
|
|
8
8
|
export declare const PopperButtonGroup: React.FC<FavoritePopperProps>;
|
|
9
9
|
//# sourceMappingURL=PopperButtonGroup.d.ts.map
|
|
@@ -1 +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,
|
|
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,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,iBAAiB,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,gBAAgB,CAAC,EAAE,OAAO,KAAK,IAAI,CAAA;CACxE;AAED,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CA2B3D,CAAA"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export interface FavoriteItemEvent {
|
|
2
|
-
alias?: string;
|
|
3
2
|
favorite?: boolean;
|
|
4
3
|
favoriteType?: FavoriteType;
|
|
5
4
|
favoriteValue?: string;
|
|
5
|
+
name?: string;
|
|
6
6
|
}
|
|
7
7
|
export type FavoriteType = 'address' | 'schema' | 'hash';
|
|
8
|
-
export declare const generateFavoriteEvent: (
|
|
8
|
+
export declare const generateFavoriteEvent: (favorite?: boolean, favoriteType?: FavoriteType, favoriteValue?: string, name?: string) => FavoriteItemEvent;
|
|
9
9
|
//# sourceMappingURL=FavoriteItemEvent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FavoriteItemEvent.d.ts","sourceRoot":"","sources":["../../../../src/components/lib/FavoriteItemEvent.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IAChC,
|
|
1
|
+
{"version":3,"file":"FavoriteItemEvent.d.ts","sourceRoot":"","sources":["../../../../src/components/lib/FavoriteItemEvent.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,YAAY,CAAC,EAAE,YAAY,CAAA;IAC3B,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,QAAQ,GAAG,MAAM,CAAA;AAExD,eAAO,MAAM,qBAAqB,cAAe,OAAO,iBAAiB,YAAY,kBAAkB,MAAM,SAAS,MAAM,KAAG,iBAK7H,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.18",
|
|
17
|
+
"@xyo-network/react-shared": "^2.47.18"
|
|
18
18
|
},
|
|
19
19
|
"peerDependencies": {
|
|
20
20
|
"@mui/icons-material": "^5",
|
|
@@ -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.18"
|
|
80
80
|
}
|
|
@@ -24,13 +24,13 @@ const Template: ComponentStory<typeof AddressRenderRowBox> = (args) => {
|
|
|
24
24
|
console.log(`${noun}|${verb}|${data}`)
|
|
25
25
|
const parsedEvent = JSON.parse(data ?? '') as FavoriteItemEvent
|
|
26
26
|
if (parsedEvent.favorite) {
|
|
27
|
-
|
|
27
|
+
setName(parsedEvent.name)
|
|
28
28
|
} else {
|
|
29
|
-
|
|
29
|
+
setName(undefined)
|
|
30
30
|
}
|
|
31
31
|
})
|
|
32
|
-
const [
|
|
33
|
-
return <AddressRenderRowBox {...args}
|
|
32
|
+
const [name, setName] = useState(args.name)
|
|
33
|
+
return <AddressRenderRowBox {...args} name={name} ref={ref} />
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
const Default = Template.bind({})
|
|
@@ -65,9 +65,9 @@ WithFavorite.args = {
|
|
|
65
65
|
const WithFavoriteAlias = Template.bind({})
|
|
66
66
|
WithFavoriteAlias.args = {
|
|
67
67
|
address,
|
|
68
|
-
alias: 'My Alias',
|
|
69
68
|
favorite: true,
|
|
70
69
|
icons: true,
|
|
70
|
+
name: 'My Name',
|
|
71
71
|
showFavorite: true,
|
|
72
72
|
}
|
|
73
73
|
|
|
@@ -10,7 +10,6 @@ import { FavoriteIconButton } from './favorite'
|
|
|
10
10
|
|
|
11
11
|
export interface AddressRenderRowBoxPropsBase {
|
|
12
12
|
address?: string | null
|
|
13
|
-
alias?: string
|
|
14
13
|
favorite?: boolean
|
|
15
14
|
iconOnly?: boolean
|
|
16
15
|
iconSize?: number
|
|
@@ -22,7 +21,7 @@ export interface AddressRenderRowBoxPropsBase {
|
|
|
22
21
|
export interface AddressRenderRowBoxProps extends WithChildren, AddressRenderRowBoxPropsBase, FlexBoxProps {}
|
|
23
22
|
|
|
24
23
|
export const AddressRenderRowBox = forwardRef<HTMLElement, AddressRenderRowBoxProps>(
|
|
25
|
-
({ address,
|
|
24
|
+
({ address, children, favorite: favoriteProp = false, iconOnly, iconSize = 24, icons, name, showFavorite = false, ...props }, ref) => {
|
|
26
25
|
const theme = useTheme()
|
|
27
26
|
|
|
28
27
|
const sharedRef = useShareForwardedRef(ref)
|
|
@@ -40,13 +39,13 @@ export const AddressRenderRowBox = forwardRef<HTMLElement, AddressRenderRowBoxPr
|
|
|
40
39
|
{iconOnly ? null : (
|
|
41
40
|
<ListItemText>
|
|
42
41
|
<EllipsizeBox ellipsisPosition={'end'} width="100%" typographyProps={{ fontSize: theme.typography.body1.fontSize }}>
|
|
43
|
-
{
|
|
42
|
+
{name ?? address}
|
|
44
43
|
</EllipsizeBox>
|
|
45
44
|
</ListItemText>
|
|
46
45
|
)}
|
|
47
46
|
{children}
|
|
48
47
|
{showFavorite && address ? (
|
|
49
|
-
<FavoriteIconButton
|
|
48
|
+
<FavoriteIconButton name={name} size={'small'} value={address} valueType={'address'} favorite={favoriteProp} />
|
|
50
49
|
) : null}
|
|
51
50
|
</FlexGrowRow>
|
|
52
51
|
)
|
|
@@ -10,14 +10,14 @@ import { popperId } from './lib'
|
|
|
10
10
|
import { FavoritePopper } from './Popper'
|
|
11
11
|
|
|
12
12
|
export interface FavoriteIconButtonProps extends WithChildren, IconButtonProps {
|
|
13
|
-
alias?: FavoriteItemEvent['alias']
|
|
14
13
|
favorite?: FavoriteItemEvent['favorite']
|
|
14
|
+
name?: FavoriteItemEvent['name']
|
|
15
15
|
value?: string
|
|
16
16
|
valueType?: FavoriteItemEvent['favoriteType']
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
export const FavoriteIconButton = forwardRef<HTMLButtonElement, FavoriteIconButtonProps>(
|
|
20
|
-
({
|
|
20
|
+
({ children, favorite: favoriteProp, name, valueType, value, ...props }, ref) => {
|
|
21
21
|
const [openPopper, setOpenPopper] = useState(false)
|
|
22
22
|
|
|
23
23
|
const [favorite, setFavorite] = useState(favoriteProp)
|
|
@@ -28,8 +28,8 @@ export const FavoriteIconButton = forwardRef<HTMLButtonElement, FavoriteIconButt
|
|
|
28
28
|
const sharedRef = useShareForwardedRef(ref)
|
|
29
29
|
const [buttonRef, dispatch] = useXyoEvent(undefined, sharedRef)
|
|
30
30
|
|
|
31
|
-
const onConfirmFavorite = (
|
|
32
|
-
const favoriteEvent = generateFavoriteEvent(
|
|
31
|
+
const onConfirmFavorite = (name?: string, newFavoriteState?: boolean) => {
|
|
32
|
+
const favoriteEvent = generateFavoriteEvent(!!newFavoriteState, valueType, value, name)
|
|
33
33
|
dispatch('address', 'favorite', JSON.stringify(favoriteEvent))
|
|
34
34
|
setFavorite(newFavoriteState)
|
|
35
35
|
setOpenPopper(false)
|
|
@@ -53,7 +53,7 @@ export const FavoriteIconButton = forwardRef<HTMLButtonElement, FavoriteIconButt
|
|
|
53
53
|
</span>
|
|
54
54
|
<FavoritePopper
|
|
55
55
|
sx={{ zIndex: 1301 }}
|
|
56
|
-
|
|
56
|
+
name={name}
|
|
57
57
|
favorite={favorite}
|
|
58
58
|
favoriteRef={starRef}
|
|
59
59
|
open={openPopper}
|
|
@@ -5,16 +5,16 @@ import { popperId } from './lib'
|
|
|
5
5
|
import { PopperButtonGroup } from './PopperButtonGroup'
|
|
6
6
|
|
|
7
7
|
export interface FavoritePopperProps extends PopperProps {
|
|
8
|
-
alias?: string
|
|
9
8
|
favorite?: boolean
|
|
10
9
|
favoriteRef?: RefObject<HTMLElement>
|
|
10
|
+
name?: string
|
|
11
11
|
onClickAway?: (event: MouseEvent | TouchEvent) => void
|
|
12
|
-
onConfirmFavorite?: (
|
|
12
|
+
onConfirmFavorite?: (name?: string, newFavoriteState?: boolean) => void
|
|
13
13
|
}
|
|
14
14
|
export const FavoritePopper = forwardRef<HTMLDivElement, FavoritePopperProps>(
|
|
15
15
|
(
|
|
16
16
|
{
|
|
17
|
-
|
|
17
|
+
name: nameProp,
|
|
18
18
|
favorite,
|
|
19
19
|
favoriteRef,
|
|
20
20
|
onClickAway = () => {
|
|
@@ -25,10 +25,10 @@ export const FavoritePopper = forwardRef<HTMLDivElement, FavoritePopperProps>(
|
|
|
25
25
|
},
|
|
26
26
|
ref,
|
|
27
27
|
) => {
|
|
28
|
-
const [
|
|
28
|
+
const [name, setName] = useState(nameProp)
|
|
29
29
|
useEffect(() => {
|
|
30
|
-
|
|
31
|
-
}, [
|
|
30
|
+
setName(nameProp)
|
|
31
|
+
}, [nameProp])
|
|
32
32
|
|
|
33
33
|
return (
|
|
34
34
|
<ClickAwayListener onClickAway={onClickAway}>
|
|
@@ -39,13 +39,13 @@ export const FavoritePopper = forwardRef<HTMLDivElement, FavoritePopperProps>(
|
|
|
39
39
|
<CardContent sx={{ display: 'flex', gap: 1 }}>
|
|
40
40
|
<TextField
|
|
41
41
|
autoFocus
|
|
42
|
-
label="Favorite
|
|
42
|
+
label="Favorite Name"
|
|
43
43
|
placeholder="optional"
|
|
44
44
|
size="small"
|
|
45
|
-
value={
|
|
46
|
-
onChange={(e) =>
|
|
45
|
+
value={name ?? ''}
|
|
46
|
+
onChange={(e) => setName(e.target.value)}
|
|
47
47
|
/>
|
|
48
|
-
<PopperButtonGroup favorite={favorite} onConfirmFavorite={onConfirmFavorite}
|
|
48
|
+
<PopperButtonGroup favorite={favorite} onConfirmFavorite={onConfirmFavorite} name={name} />
|
|
49
49
|
</CardContent>
|
|
50
50
|
</Card>
|
|
51
51
|
</Fade>
|
|
@@ -3,12 +3,12 @@ import StarIcon from '@mui/icons-material/Star'
|
|
|
3
3
|
import { Button, ButtonGroup, ButtonGroupProps } from '@mui/material'
|
|
4
4
|
|
|
5
5
|
export interface FavoritePopperProps extends ButtonGroupProps {
|
|
6
|
-
alias?: string
|
|
7
6
|
favorite?: boolean
|
|
8
|
-
|
|
7
|
+
name?: string
|
|
8
|
+
onConfirmFavorite?: (name?: string, newFavoriteState?: boolean) => void
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
export const PopperButtonGroup: React.FC<FavoritePopperProps> = ({
|
|
11
|
+
export const PopperButtonGroup: React.FC<FavoritePopperProps> = ({ name, onConfirmFavorite, favorite, ...props }) => {
|
|
12
12
|
return (
|
|
13
13
|
<ButtonGroup {...props}>
|
|
14
14
|
<Button
|
|
@@ -16,7 +16,7 @@ export const PopperButtonGroup: React.FC<FavoritePopperProps> = ({ alias, onConf
|
|
|
16
16
|
variant="contained"
|
|
17
17
|
onClick={(e) => {
|
|
18
18
|
e.stopPropagation()
|
|
19
|
-
onConfirmFavorite?.(
|
|
19
|
+
onConfirmFavorite?.(name, true)
|
|
20
20
|
}}
|
|
21
21
|
>
|
|
22
22
|
<StarIcon />
|
|
@@ -27,7 +27,7 @@ export const PopperButtonGroup: React.FC<FavoritePopperProps> = ({ alias, onConf
|
|
|
27
27
|
variant="contained"
|
|
28
28
|
onClick={(e) => {
|
|
29
29
|
e.stopPropagation()
|
|
30
|
-
onConfirmFavorite?.(
|
|
30
|
+
onConfirmFavorite?.(name, false)
|
|
31
31
|
}}
|
|
32
32
|
>
|
|
33
33
|
<DeleteIcon />
|
|
@@ -1,20 +1,15 @@
|
|
|
1
1
|
export interface FavoriteItemEvent {
|
|
2
|
-
alias?: string
|
|
3
2
|
favorite?: boolean
|
|
4
3
|
favoriteType?: FavoriteType
|
|
5
4
|
favoriteValue?: string
|
|
5
|
+
name?: string
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
export type FavoriteType = 'address' | 'schema' | 'hash'
|
|
9
9
|
|
|
10
|
-
export const generateFavoriteEvent = (
|
|
11
|
-
alias?: string,
|
|
12
|
-
favorite?: boolean,
|
|
13
|
-
favoriteType?: FavoriteType,
|
|
14
|
-
favoriteValue?: string,
|
|
15
|
-
): FavoriteItemEvent => ({
|
|
16
|
-
alias,
|
|
10
|
+
export const generateFavoriteEvent = (favorite?: boolean, favoriteType?: FavoriteType, favoriteValue?: string, name?: string): FavoriteItemEvent => ({
|
|
17
11
|
favorite: !!favorite,
|
|
18
12
|
favoriteType,
|
|
19
13
|
favoriteValue,
|
|
14
|
+
name,
|
|
20
15
|
})
|