@xyo-network/react-address-render 2.64.0-rc.3 → 2.64.0-rc.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/browser/components/RenderRowBox.d.mts.map +1 -0
- package/dist/browser/components/RenderRowBox.d.ts.map +1 -0
- package/dist/browser/components/RenderRowBox.js +49 -0
- package/dist/browser/components/RenderRowBox.js.map +1 -0
- package/dist/browser/components/RenderRowBox.stories.js +81 -0
- package/dist/browser/components/RenderRowBox.stories.js.map +1 -0
- package/dist/browser/components/favorite/FavoriteIconButton.d.mts.map +1 -0
- package/dist/browser/components/favorite/FavoriteIconButton.d.ts.map +1 -0
- package/dist/browser/components/favorite/FavoriteIconButton.js +70 -0
- package/dist/browser/components/favorite/FavoriteIconButton.js.map +1 -0
- package/dist/browser/components/favorite/FavoriteToggleSVG.d.mts.map +1 -0
- package/dist/browser/components/favorite/FavoriteToggleSVG.d.ts.map +1 -0
- package/dist/browser/components/favorite/FavoriteToggleSVG.js +7 -0
- package/dist/browser/components/favorite/FavoriteToggleSVG.js.map +1 -0
- package/dist/browser/components/favorite/Popper.d.mts.map +1 -0
- package/dist/browser/components/favorite/Popper.d.ts.map +1 -0
- package/dist/browser/components/favorite/Popper.js +54 -0
- package/dist/browser/components/favorite/Popper.js.map +1 -0
- package/dist/browser/components/favorite/PopperButtonGroup.d.mts.map +1 -0
- package/dist/browser/components/favorite/PopperButtonGroup.d.ts.map +1 -0
- package/dist/browser/components/favorite/PopperButtonGroup.js +35 -0
- package/dist/browser/components/favorite/PopperButtonGroup.js.map +1 -0
- package/dist/browser/components/favorite/index.d.mts.map +1 -0
- package/dist/browser/components/favorite/index.d.ts.map +1 -0
- package/dist/browser/components/favorite/index.js +2 -0
- package/dist/browser/components/favorite/index.js.map +1 -0
- package/dist/browser/components/favorite/lib/PopperId.d.mts.map +1 -0
- package/dist/browser/components/favorite/lib/PopperId.d.ts.map +1 -0
- package/dist/browser/components/favorite/lib/PopperId.js +5 -0
- package/dist/browser/components/favorite/lib/PopperId.js.map +1 -0
- package/dist/browser/components/favorite/lib/index.d.mts.map +1 -0
- package/dist/browser/components/favorite/lib/index.d.ts.map +1 -0
- package/dist/browser/components/favorite/lib/index.js +2 -0
- package/dist/browser/components/favorite/lib/index.js.map +1 -0
- package/dist/browser/components/index.d.mts.map +1 -0
- package/dist/browser/components/index.d.ts.map +1 -0
- package/dist/browser/components/index.js +4 -0
- package/dist/browser/components/index.js.map +1 -0
- package/dist/browser/components/lib/FavoriteItemEvent.d.mts.map +1 -0
- package/dist/browser/components/lib/FavoriteItemEvent.d.ts.map +1 -0
- package/dist/browser/components/lib/FavoriteItemEvent.js +10 -0
- package/dist/browser/components/lib/FavoriteItemEvent.js.map +1 -0
- package/dist/browser/components/lib/index.d.mts.map +1 -0
- package/dist/browser/components/lib/index.d.ts.map +1 -0
- package/dist/browser/components/lib/index.js +2 -0
- package/dist/browser/components/lib/index.js.map +1 -0
- package/dist/{index.d.mts.map → browser/index.d.mts.map} +1 -1
- package/dist/{index.d.ts.map → browser/index.d.ts.map} +1 -1
- package/dist/browser/index.js +2 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/node/components/RenderRowBox.d.mts +14 -0
- package/dist/node/components/RenderRowBox.d.mts.map +1 -0
- package/dist/node/components/RenderRowBox.d.ts +14 -0
- package/dist/node/components/RenderRowBox.d.ts.map +1 -0
- package/dist/node/components/RenderRowBox.js +73 -0
- package/dist/node/components/RenderRowBox.js.map +1 -0
- package/dist/node/components/RenderRowBox.mjs +49 -0
- package/dist/node/components/RenderRowBox.mjs.map +1 -0
- package/dist/node/components/RenderRowBox.stories.js +111 -0
- package/dist/node/components/RenderRowBox.stories.js.map +1 -0
- package/dist/node/components/RenderRowBox.stories.mjs +81 -0
- package/dist/node/components/RenderRowBox.stories.mjs.map +1 -0
- package/dist/node/components/favorite/FavoriteIconButton.d.mts +12 -0
- package/dist/node/components/favorite/FavoriteIconButton.d.mts.map +1 -0
- package/dist/node/components/favorite/FavoriteIconButton.d.ts +12 -0
- package/dist/node/components/favorite/FavoriteIconButton.d.ts.map +1 -0
- package/dist/node/components/favorite/FavoriteIconButton.js +94 -0
- package/dist/node/components/favorite/FavoriteIconButton.js.map +1 -0
- package/dist/node/components/favorite/FavoriteIconButton.mjs +70 -0
- package/dist/node/components/favorite/FavoriteIconButton.mjs.map +1 -0
- package/dist/node/components/favorite/FavoriteToggleSVG.d.mts +5 -0
- package/dist/node/components/favorite/FavoriteToggleSVG.d.mts.map +1 -0
- package/dist/node/components/favorite/FavoriteToggleSVG.d.ts +5 -0
- package/dist/node/components/favorite/FavoriteToggleSVG.d.ts.map +1 -0
- package/dist/node/components/favorite/FavoriteToggleSVG.js +31 -0
- package/dist/node/components/favorite/FavoriteToggleSVG.js.map +1 -0
- package/dist/node/components/favorite/FavoriteToggleSVG.mjs +7 -0
- package/dist/node/components/favorite/FavoriteToggleSVG.mjs.map +1 -0
- package/dist/node/components/favorite/Popper.d.mts +11 -0
- package/dist/node/components/favorite/Popper.d.mts.map +1 -0
- package/dist/node/components/favorite/Popper.d.ts +11 -0
- package/dist/node/components/favorite/Popper.d.ts.map +1 -0
- package/dist/node/components/favorite/Popper.js +78 -0
- package/dist/node/components/favorite/Popper.js.map +1 -0
- package/dist/node/components/favorite/Popper.mjs +54 -0
- package/dist/node/components/favorite/Popper.mjs.map +1 -0
- package/dist/node/components/favorite/PopperButtonGroup.d.mts +9 -0
- package/dist/node/components/favorite/PopperButtonGroup.d.mts.map +1 -0
- package/dist/node/components/favorite/PopperButtonGroup.d.ts +9 -0
- package/dist/node/components/favorite/PopperButtonGroup.d.ts.map +1 -0
- package/dist/node/components/favorite/PopperButtonGroup.js +59 -0
- package/dist/node/components/favorite/PopperButtonGroup.js.map +1 -0
- package/dist/node/components/favorite/PopperButtonGroup.mjs +35 -0
- package/dist/node/components/favorite/PopperButtonGroup.mjs.map +1 -0
- package/dist/node/components/favorite/index.d.mts +2 -0
- package/dist/node/components/favorite/index.d.mts.map +1 -0
- package/dist/node/components/favorite/index.d.ts +2 -0
- package/dist/node/components/favorite/index.d.ts.map +1 -0
- package/dist/node/components/favorite/index.js +23 -0
- package/dist/node/components/favorite/index.js.map +1 -0
- package/dist/node/components/favorite/index.mjs +2 -0
- package/dist/node/components/favorite/index.mjs.map +1 -0
- package/dist/node/components/favorite/lib/PopperId.d.mts +2 -0
- package/dist/node/components/favorite/lib/PopperId.d.mts.map +1 -0
- package/dist/node/components/favorite/lib/PopperId.d.ts +2 -0
- package/dist/node/components/favorite/lib/PopperId.d.ts.map +1 -0
- package/dist/node/components/favorite/lib/PopperId.js +29 -0
- package/dist/node/components/favorite/lib/PopperId.js.map +1 -0
- package/dist/node/components/favorite/lib/PopperId.mjs +5 -0
- package/dist/node/components/favorite/lib/PopperId.mjs.map +1 -0
- package/dist/node/components/favorite/lib/index.d.mts +2 -0
- package/dist/node/components/favorite/lib/index.d.mts.map +1 -0
- package/dist/node/components/favorite/lib/index.d.ts +2 -0
- package/dist/node/components/favorite/lib/index.d.ts.map +1 -0
- package/dist/node/components/favorite/lib/index.js +23 -0
- package/dist/node/components/favorite/lib/index.js.map +1 -0
- package/dist/node/components/favorite/lib/index.mjs +2 -0
- package/dist/node/components/favorite/lib/index.mjs.map +1 -0
- package/dist/node/components/index.d.mts +4 -0
- package/dist/node/components/index.d.mts.map +1 -0
- package/dist/node/components/index.d.ts +4 -0
- package/dist/node/components/index.d.ts.map +1 -0
- package/dist/node/components/index.js +27 -0
- package/dist/node/components/index.js.map +1 -0
- package/dist/node/components/index.mjs +4 -0
- package/dist/node/components/index.mjs.map +1 -0
- package/dist/node/components/lib/FavoriteItemEvent.d.mts +9 -0
- package/dist/node/components/lib/FavoriteItemEvent.d.mts.map +1 -0
- package/dist/node/components/lib/FavoriteItemEvent.d.ts +9 -0
- package/dist/node/components/lib/FavoriteItemEvent.d.ts.map +1 -0
- package/dist/node/components/lib/FavoriteItemEvent.js +34 -0
- package/dist/node/components/lib/FavoriteItemEvent.js.map +1 -0
- package/dist/node/components/lib/FavoriteItemEvent.mjs +10 -0
- package/dist/node/components/lib/FavoriteItemEvent.mjs.map +1 -0
- package/dist/node/components/lib/index.d.mts +2 -0
- package/dist/node/components/lib/index.d.mts.map +1 -0
- package/dist/node/components/lib/index.d.ts +2 -0
- package/dist/node/components/lib/index.d.ts.map +1 -0
- package/dist/node/components/lib/index.js +23 -0
- package/dist/node/components/lib/index.js.map +1 -0
- package/dist/node/components/lib/index.mjs +2 -0
- package/dist/node/components/lib/index.mjs.map +1 -0
- package/dist/node/index.d.mts +2 -0
- package/dist/node/index.d.mts.map +1 -0
- package/dist/node/index.d.ts +2 -0
- package/dist/node/index.d.ts.map +1 -0
- package/dist/node/index.js +23 -0
- package/dist/node/index.js.map +1 -0
- package/dist/node/index.mjs +2 -0
- package/dist/node/index.mjs.map +1 -0
- package/package.json +23 -23
- package/dist/components/RenderRowBox.d.mts.map +0 -1
- package/dist/components/RenderRowBox.d.ts.map +0 -1
- package/dist/components/RenderRowBox.stories.d.mts +0 -12
- package/dist/components/RenderRowBox.stories.d.mts.map +0 -1
- package/dist/components/RenderRowBox.stories.d.ts +0 -12
- package/dist/components/RenderRowBox.stories.d.ts.map +0 -1
- package/dist/components/favorite/FavoriteIconButton.d.mts.map +0 -1
- package/dist/components/favorite/FavoriteIconButton.d.ts.map +0 -1
- package/dist/components/favorite/FavoriteToggleSVG.d.mts.map +0 -1
- package/dist/components/favorite/FavoriteToggleSVG.d.ts.map +0 -1
- package/dist/components/favorite/Popper.d.mts.map +0 -1
- package/dist/components/favorite/Popper.d.ts.map +0 -1
- package/dist/components/favorite/PopperButtonGroup.d.mts.map +0 -1
- package/dist/components/favorite/PopperButtonGroup.d.ts.map +0 -1
- package/dist/components/favorite/index.d.mts.map +0 -1
- package/dist/components/favorite/index.d.ts.map +0 -1
- package/dist/components/favorite/lib/PopperId.d.mts.map +0 -1
- package/dist/components/favorite/lib/PopperId.d.ts.map +0 -1
- package/dist/components/favorite/lib/index.d.mts.map +0 -1
- package/dist/components/favorite/lib/index.d.ts.map +0 -1
- package/dist/components/index.d.mts.map +0 -1
- package/dist/components/index.d.ts.map +0 -1
- package/dist/components/lib/FavoriteItemEvent.d.mts.map +0 -1
- package/dist/components/lib/FavoriteItemEvent.d.ts.map +0 -1
- package/dist/components/lib/index.d.mts.map +0 -1
- package/dist/components/lib/index.d.ts.map +0 -1
- package/dist/index.js +0 -247
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -218
- package/dist/index.mjs.map +0 -1
- /package/dist/{components → browser/components}/RenderRowBox.d.mts +0 -0
- /package/dist/{components → browser/components}/RenderRowBox.d.ts +0 -0
- /package/dist/{components → browser/components}/favorite/FavoriteIconButton.d.mts +0 -0
- /package/dist/{components → browser/components}/favorite/FavoriteIconButton.d.ts +0 -0
- /package/dist/{components → browser/components}/favorite/FavoriteToggleSVG.d.mts +0 -0
- /package/dist/{components → browser/components}/favorite/FavoriteToggleSVG.d.ts +0 -0
- /package/dist/{components → browser/components}/favorite/Popper.d.mts +0 -0
- /package/dist/{components → browser/components}/favorite/Popper.d.ts +0 -0
- /package/dist/{components → browser/components}/favorite/PopperButtonGroup.d.mts +0 -0
- /package/dist/{components → browser/components}/favorite/PopperButtonGroup.d.ts +0 -0
- /package/dist/{components → browser/components}/favorite/index.d.mts +0 -0
- /package/dist/{components → browser/components}/favorite/index.d.ts +0 -0
- /package/dist/{components → browser/components}/favorite/lib/PopperId.d.mts +0 -0
- /package/dist/{components → browser/components}/favorite/lib/PopperId.d.ts +0 -0
- /package/dist/{components → browser/components}/favorite/lib/index.d.mts +0 -0
- /package/dist/{components → browser/components}/favorite/lib/index.d.ts +0 -0
- /package/dist/{components → browser/components}/index.d.mts +0 -0
- /package/dist/{components → browser/components}/index.d.ts +0 -0
- /package/dist/{components → browser/components}/lib/FavoriteItemEvent.d.mts +0 -0
- /package/dist/{components → browser/components}/lib/FavoriteItemEvent.d.ts +0 -0
- /package/dist/{components → browser/components}/lib/index.d.mts +0 -0
- /package/dist/{components → browser/components}/lib/index.d.ts +0 -0
- /package/dist/{index.d.mts → browser/index.d.mts} +0 -0
- /package/dist/{index.d.ts → browser/index.d.ts} +0 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var RenderRowBox_exports = {};
|
|
20
|
+
__export(RenderRowBox_exports, {
|
|
21
|
+
AddressRenderRowBox: () => AddressRenderRowBox
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(RenderRowBox_exports);
|
|
24
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
25
|
+
var import_material = require("@mui/material");
|
|
26
|
+
var import_react_flexbox = require("@xylabs/react-flexbox");
|
|
27
|
+
var import_react_identicon = require("@xylabs/react-identicon");
|
|
28
|
+
var import_react_event = require("@xyo-network/react-event");
|
|
29
|
+
var import_react_shared = require("@xyo-network/react-shared");
|
|
30
|
+
var import_react = require("react");
|
|
31
|
+
var import_favorite = require("./favorite");
|
|
32
|
+
const AddressRenderRowBox = (0, import_react.forwardRef)(
|
|
33
|
+
({ address, children, disableSharedRef, favorite: favoriteProp = false, iconOnly, iconSize = 24, icons, name, showFavorite = false, ...props }, ref) => {
|
|
34
|
+
const theme = (0, import_material.useTheme)();
|
|
35
|
+
const sharedRef = (0, import_react_shared.useShareForwardedRef)(ref);
|
|
36
|
+
const [elementRef, dispatch] = (0, import_react_event.useEvent)(void 0, sharedRef);
|
|
37
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
38
|
+
import_react_flexbox.FlexRow,
|
|
39
|
+
{
|
|
40
|
+
gap: 2,
|
|
41
|
+
justifyContent: "flex-start",
|
|
42
|
+
ref: elementRef,
|
|
43
|
+
onClick: () => {
|
|
44
|
+
if (address) {
|
|
45
|
+
dispatch("address", "click", address);
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
...props,
|
|
49
|
+
children: [
|
|
50
|
+
icons && address ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.ListItemIcon, { sx: { minWidth: 0 }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_identicon.Identicon, { size: iconSize, value: address }) }) : null,
|
|
51
|
+
iconOnly ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
52
|
+
import_react_shared.EllipsizeBox,
|
|
53
|
+
{
|
|
54
|
+
disableSharedRef,
|
|
55
|
+
ellipsisPosition: "end",
|
|
56
|
+
width: "100%",
|
|
57
|
+
typographyProps: { fontSize: theme.typography.body1.fontSize },
|
|
58
|
+
children: name ?? address
|
|
59
|
+
}
|
|
60
|
+
),
|
|
61
|
+
children,
|
|
62
|
+
showFavorite && address ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_favorite.FavoriteIconButton, { name, size: "small", value: address, valueType: "address", favorite: favoriteProp }) : null
|
|
63
|
+
]
|
|
64
|
+
}
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
);
|
|
68
|
+
AddressRenderRowBox.displayName = "AddressRenderRowBox";
|
|
69
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
70
|
+
0 && (module.exports = {
|
|
71
|
+
AddressRenderRowBox
|
|
72
|
+
});
|
|
73
|
+
//# sourceMappingURL=RenderRowBox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/RenderRowBox.tsx"],"sourcesContent":["import { ListItemIcon, useTheme } from '@mui/material'\nimport { FlexBoxProps, 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 { forwardRef } from 'react'\n\nimport { FavoriteIconButton } from './favorite'\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 = forwardRef<HTMLElement, AddressRenderRowBoxProps>(\n (\n { address, children, disableSharedRef, favorite: favoriteProp = false, iconOnly, iconSize = 24, icons, name, showFavorite = false, ...props },\n ref,\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 <ListItemIcon sx={{ minWidth: 0 }}>\n <Identicon size={iconSize} value={address} />\n </ListItemIcon>\n ) : null}\n {iconOnly ? null : (\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)\n\nAddressRenderRowBox.displayName = 'AddressRenderRowBox'\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA+BM;AA/BN,sBAAuC;AACvC,2BAAsC;AACtC,6BAA0B;AAC1B,yBAAyB;AACzB,0BAAmD;AACnD,mBAA2B;AAE3B,sBAAmC;AAa5B,MAAM,0BAAsB;AAAA,EACjC,CACE,EAAE,SAAS,UAAU,kBAAkB,UAAU,eAAe,OAAO,UAAU,WAAW,IAAI,OAAO,MAAM,eAAe,OAAO,GAAG,MAAM,GAC5I,QACG;AACH,UAAM,YAAQ,0BAAS;AAEvB,UAAM,gBAAY,0CAAqB,GAAG;AAC1C,UAAM,CAAC,YAAY,QAAQ,QAAI,6BAAS,QAAW,SAAS;AAE5D,WACE;AAAA,MAAC;AAAA;AAAA,QACC,KAAK;AAAA,QACL,gBAAe;AAAA,QACf,KAAK;AAAA,QACL,SAAS,MAAM;AACb,cAAI,SAAS;AACX,qBAAS,WAAW,SAAS,OAAO;AAAA,UACtC;AAAA,QACF;AAAA,QACC,GAAG;AAAA,QAEH;AAAA,mBAAS,UACR,4CAAC,gCAAa,IAAI,EAAE,UAAU,EAAE,GAC9B,sDAAC,oCAAU,MAAM,UAAU,OAAO,SAAS,GAC7C,IACE;AAAA,UACH,WAAW,OACV;AAAA,YAAC;AAAA;AAAA,cACC;AAAA,cACA,kBAAkB;AAAA,cAClB,OAAM;AAAA,cACN,iBAAiB,EAAE,UAAU,MAAM,WAAW,MAAM,SAAS;AAAA,cAE5D,kBAAQ;AAAA;AAAA,UACX;AAAA,UAED;AAAA,UACA,gBAAgB,UACf,4CAAC,sCAAmB,MAAY,MAAM,SAAS,OAAO,SAAS,WAAW,WAAW,UAAU,cAAc,IAC3G;AAAA;AAAA;AAAA,IACN;AAAA,EAEJ;AACF;AAEA,oBAAoB,cAAc;","names":[]}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { ListItemIcon, useTheme } from "@mui/material";
|
|
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 { forwardRef } from "react";
|
|
8
|
+
import { FavoriteIconButton } from "./favorite";
|
|
9
|
+
const AddressRenderRowBox = forwardRef(
|
|
10
|
+
({ address, children, disableSharedRef, favorite: favoriteProp = false, iconOnly, iconSize = 24, icons, name, showFavorite = false, ...props }, ref) => {
|
|
11
|
+
const theme = useTheme();
|
|
12
|
+
const sharedRef = useShareForwardedRef(ref);
|
|
13
|
+
const [elementRef, dispatch] = useEvent(void 0, sharedRef);
|
|
14
|
+
return /* @__PURE__ */ jsxs(
|
|
15
|
+
FlexRow,
|
|
16
|
+
{
|
|
17
|
+
gap: 2,
|
|
18
|
+
justifyContent: "flex-start",
|
|
19
|
+
ref: elementRef,
|
|
20
|
+
onClick: () => {
|
|
21
|
+
if (address) {
|
|
22
|
+
dispatch("address", "click", address);
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
...props,
|
|
26
|
+
children: [
|
|
27
|
+
icons && address ? /* @__PURE__ */ jsx(ListItemIcon, { sx: { minWidth: 0 }, children: /* @__PURE__ */ jsx(Identicon, { size: iconSize, value: address }) }) : null,
|
|
28
|
+
iconOnly ? null : /* @__PURE__ */ jsx(
|
|
29
|
+
EllipsizeBox,
|
|
30
|
+
{
|
|
31
|
+
disableSharedRef,
|
|
32
|
+
ellipsisPosition: "end",
|
|
33
|
+
width: "100%",
|
|
34
|
+
typographyProps: { fontSize: theme.typography.body1.fontSize },
|
|
35
|
+
children: name ?? address
|
|
36
|
+
}
|
|
37
|
+
),
|
|
38
|
+
children,
|
|
39
|
+
showFavorite && address ? /* @__PURE__ */ jsx(FavoriteIconButton, { name, size: "small", value: address, valueType: "address", favorite: favoriteProp }) : null
|
|
40
|
+
]
|
|
41
|
+
}
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
);
|
|
45
|
+
AddressRenderRowBox.displayName = "AddressRenderRowBox";
|
|
46
|
+
export {
|
|
47
|
+
AddressRenderRowBox
|
|
48
|
+
};
|
|
49
|
+
//# sourceMappingURL=RenderRowBox.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/RenderRowBox.tsx"],"sourcesContent":["import { ListItemIcon, useTheme } from '@mui/material'\nimport { FlexBoxProps, 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 { forwardRef } from 'react'\n\nimport { FavoriteIconButton } from './favorite'\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 = forwardRef<HTMLElement, AddressRenderRowBoxProps>(\n (\n { address, children, disableSharedRef, favorite: favoriteProp = false, iconOnly, iconSize = 24, icons, name, showFavorite = false, ...props },\n ref,\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 <ListItemIcon sx={{ minWidth: 0 }}>\n <Identicon size={iconSize} value={address} />\n </ListItemIcon>\n ) : null}\n {iconOnly ? null : (\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)\n\nAddressRenderRowBox.displayName = 'AddressRenderRowBox'\n"],"mappings":"AA+BM,SAaM,KAbN;AA/BN,SAAS,cAAc,gBAAgB;AACvC,SAAuB,eAAe;AACtC,SAAS,iBAAiB;AAC1B,SAAS,gBAAgB;AACzB,SAAS,cAAc,4BAA4B;AACnD,SAAS,kBAAkB;AAE3B,SAAS,0BAA0B;AAa5B,MAAM,sBAAsB;AAAA,EACjC,CACE,EAAE,SAAS,UAAU,kBAAkB,UAAU,eAAe,OAAO,UAAU,WAAW,IAAI,OAAO,MAAM,eAAe,OAAO,GAAG,MAAM,GAC5I,QACG;AACH,UAAM,QAAQ,SAAS;AAEvB,UAAM,YAAY,qBAAqB,GAAG;AAC1C,UAAM,CAAC,YAAY,QAAQ,IAAI,SAAS,QAAW,SAAS;AAE5D,WACE;AAAA,MAAC;AAAA;AAAA,QACC,KAAK;AAAA,QACL,gBAAe;AAAA,QACf,KAAK;AAAA,QACL,SAAS,MAAM;AACb,cAAI,SAAS;AACX,qBAAS,WAAW,SAAS,OAAO;AAAA,UACtC;AAAA,QACF;AAAA,QACC,GAAG;AAAA,QAEH;AAAA,mBAAS,UACR,oBAAC,gBAAa,IAAI,EAAE,UAAU,EAAE,GAC9B,8BAAC,aAAU,MAAM,UAAU,OAAO,SAAS,GAC7C,IACE;AAAA,UACH,WAAW,OACV;AAAA,YAAC;AAAA;AAAA,cACC;AAAA,cACA,kBAAkB;AAAA,cAClB,OAAM;AAAA,cACN,iBAAiB,EAAE,UAAU,MAAM,WAAW,MAAM,SAAS;AAAA,cAE5D,kBAAQ;AAAA;AAAA,UACX;AAAA,UAED;AAAA,UACA,gBAAgB,UACf,oBAAC,sBAAmB,MAAY,MAAM,SAAS,OAAO,SAAS,WAAW,WAAW,UAAU,cAAc,IAC3G;AAAA;AAAA;AAAA,IACN;AAAA,EAEJ;AACF;AAEA,oBAAoB,cAAc;","names":[]}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var RenderRowBox_stories_exports = {};
|
|
20
|
+
__export(RenderRowBox_stories_exports, {
|
|
21
|
+
Default: () => Default,
|
|
22
|
+
WithAddress: () => WithAddress,
|
|
23
|
+
WithChildren: () => WithChildren,
|
|
24
|
+
WithFavorite: () => WithFavorite,
|
|
25
|
+
WithFavoriteAlias: () => WithFavoriteAlias,
|
|
26
|
+
WithIcon: () => WithIcon,
|
|
27
|
+
WithIconOnly: () => WithIconOnly,
|
|
28
|
+
default: () => RenderRowBox_stories_default
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(RenderRowBox_stories_exports);
|
|
31
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
32
|
+
var import_account = require("@xyo-network/account");
|
|
33
|
+
var import_react_event = require("@xyo-network/react-event");
|
|
34
|
+
var import_react2 = require("react");
|
|
35
|
+
var import_RenderRowBox = require("./RenderRowBox");
|
|
36
|
+
const address = new import_account.Account({ phrase: "temp" }).address;
|
|
37
|
+
const StorybookEntry = {
|
|
38
|
+
argTypes: {},
|
|
39
|
+
component: import_RenderRowBox.AddressRenderRowBox,
|
|
40
|
+
parameters: {
|
|
41
|
+
docs: {
|
|
42
|
+
page: null
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
title: "address/render/AddressRenderRowBox"
|
|
46
|
+
};
|
|
47
|
+
const Template = (args) => {
|
|
48
|
+
const [ref] = (0, import_react_event.useEvent)((noun, verb, data) => {
|
|
49
|
+
console.log(`${noun}|${verb}|${data}`);
|
|
50
|
+
const parsedEvent = JSON.parse(data ?? "");
|
|
51
|
+
if (parsedEvent.favorite) {
|
|
52
|
+
setName(parsedEvent.name);
|
|
53
|
+
} else {
|
|
54
|
+
setName(void 0);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
const [name, setName] = (0, import_react2.useState)(args.name);
|
|
58
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_RenderRowBox.AddressRenderRowBox, { ...args, name, ref });
|
|
59
|
+
};
|
|
60
|
+
const Default = Template.bind({});
|
|
61
|
+
Default.args = {};
|
|
62
|
+
const WithAddress = Template.bind({});
|
|
63
|
+
WithAddress.args = {
|
|
64
|
+
address
|
|
65
|
+
};
|
|
66
|
+
const WithIcon = Template.bind({});
|
|
67
|
+
WithIcon.args = {
|
|
68
|
+
address,
|
|
69
|
+
icons: true
|
|
70
|
+
};
|
|
71
|
+
const WithIconOnly = Template.bind({});
|
|
72
|
+
WithIconOnly.args = {
|
|
73
|
+
address,
|
|
74
|
+
iconOnly: true,
|
|
75
|
+
icons: true
|
|
76
|
+
};
|
|
77
|
+
const WithFavorite = Template.bind({});
|
|
78
|
+
WithFavorite.args = {
|
|
79
|
+
address,
|
|
80
|
+
favorite: true,
|
|
81
|
+
icons: true,
|
|
82
|
+
showFavorite: true
|
|
83
|
+
};
|
|
84
|
+
const WithFavoriteAlias = Template.bind({});
|
|
85
|
+
WithFavoriteAlias.args = {
|
|
86
|
+
address,
|
|
87
|
+
favorite: true,
|
|
88
|
+
icons: true,
|
|
89
|
+
name: "My Name",
|
|
90
|
+
showFavorite: true
|
|
91
|
+
};
|
|
92
|
+
const WithChildren = Template.bind({});
|
|
93
|
+
WithChildren.args = {
|
|
94
|
+
address,
|
|
95
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "[InsertedChild]" }),
|
|
96
|
+
favorite: true,
|
|
97
|
+
icons: true,
|
|
98
|
+
showFavorite: true
|
|
99
|
+
};
|
|
100
|
+
var RenderRowBox_stories_default = StorybookEntry;
|
|
101
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
102
|
+
0 && (module.exports = {
|
|
103
|
+
Default,
|
|
104
|
+
WithAddress,
|
|
105
|
+
WithChildren,
|
|
106
|
+
WithFavorite,
|
|
107
|
+
WithFavoriteAlias,
|
|
108
|
+
WithIcon,
|
|
109
|
+
WithIconOnly
|
|
110
|
+
});
|
|
111
|
+
//# sourceMappingURL=RenderRowBox.stories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/RenderRowBox.stories.tsx"],"sourcesContent":["import { Meta, StoryFn } from '@storybook/react'\nimport { Account } from '@xyo-network/account'\nimport { useEvent } from '@xyo-network/react-event'\nimport { useState } from 'react'\n\nimport { FavoriteItemEvent } from './lib'\nimport { AddressRenderRowBox } from './RenderRowBox'\n\nconst address = new Account({ phrase: 'temp' }).address\n\nconst StorybookEntry = {\n argTypes: {},\n component: AddressRenderRowBox,\n parameters: {\n docs: {\n page: null,\n },\n },\n title: 'address/render/AddressRenderRowBox',\n} as Meta<typeof AddressRenderRowBox>\n\nconst Template: StoryFn<typeof AddressRenderRowBox> = (args) => {\n const [ref] = useEvent<HTMLLIElement>((noun, verb, data) => {\n console.log(`${noun}|${verb}|${data}`)\n const parsedEvent = JSON.parse(data ?? '') as FavoriteItemEvent\n if (parsedEvent.favorite) {\n setName(parsedEvent.name)\n } else {\n setName(undefined)\n }\n })\n const [name, setName] = useState(args.name)\n return <AddressRenderRowBox {...args} name={name} ref={ref} />\n}\n\nconst Default = Template.bind({})\nDefault.args = {}\n\nconst WithAddress = Template.bind({})\nWithAddress.args = {\n address,\n}\n\nconst WithIcon = Template.bind({})\nWithIcon.args = {\n address,\n icons: true,\n}\n\nconst WithIconOnly = Template.bind({})\nWithIconOnly.args = {\n address,\n iconOnly: true,\n icons: true,\n}\n\nconst WithFavorite = Template.bind({})\nWithFavorite.args = {\n address,\n favorite: true,\n icons: true,\n showFavorite: true,\n}\n\nconst WithFavoriteAlias = Template.bind({})\nWithFavoriteAlias.args = {\n address,\n favorite: true,\n icons: true,\n name: 'My Name',\n showFavorite: true,\n}\n\nconst WithChildren = Template.bind({})\nWithChildren.args = {\n address,\n children: <span>{'[InsertedChild]'}</span>,\n favorite: true,\n icons: true,\n showFavorite: true,\n}\n\nexport { Default, WithAddress, WithChildren, WithFavorite, WithFavoriteAlias, WithIcon, WithIconOnly }\n\n// eslint-disable-next-line import/no-default-export\nexport default StorybookEntry\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgCS;AA/BT,qBAAwB;AACxB,yBAAyB;AACzB,IAAAA,gBAAyB;AAGzB,0BAAoC;AAEpC,MAAM,UAAU,IAAI,uBAAQ,EAAE,QAAQ,OAAO,CAAC,EAAE;AAEhD,MAAM,iBAAiB;AAAA,EACrB,UAAU,CAAC;AAAA,EACX,WAAW;AAAA,EACX,YAAY;AAAA,IACV,MAAM;AAAA,MACJ,MAAM;AAAA,IACR;AAAA,EACF;AAAA,EACA,OAAO;AACT;AAEA,MAAM,WAAgD,CAAC,SAAS;AAC9D,QAAM,CAAC,GAAG,QAAI,6BAAwB,CAAC,MAAM,MAAM,SAAS;AAC1D,YAAQ,IAAI,GAAG,IAAI,IAAI,IAAI,IAAI,IAAI,EAAE;AACrC,UAAM,cAAc,KAAK,MAAM,QAAQ,EAAE;AACzC,QAAI,YAAY,UAAU;AACxB,cAAQ,YAAY,IAAI;AAAA,IAC1B,OAAO;AACL,cAAQ,MAAS;AAAA,IACnB;AAAA,EACF,CAAC;AACD,QAAM,CAAC,MAAM,OAAO,QAAI,wBAAS,KAAK,IAAI;AAC1C,SAAO,4CAAC,2CAAqB,GAAG,MAAM,MAAY,KAAU;AAC9D;AAEA,MAAM,UAAU,SAAS,KAAK,CAAC,CAAC;AAChC,QAAQ,OAAO,CAAC;AAEhB,MAAM,cAAc,SAAS,KAAK,CAAC,CAAC;AACpC,YAAY,OAAO;AAAA,EACjB;AACF;AAEA,MAAM,WAAW,SAAS,KAAK,CAAC,CAAC;AACjC,SAAS,OAAO;AAAA,EACd;AAAA,EACA,OAAO;AACT;AAEA,MAAM,eAAe,SAAS,KAAK,CAAC,CAAC;AACrC,aAAa,OAAO;AAAA,EAClB;AAAA,EACA,UAAU;AAAA,EACV,OAAO;AACT;AAEA,MAAM,eAAe,SAAS,KAAK,CAAC,CAAC;AACrC,aAAa,OAAO;AAAA,EAClB;AAAA,EACA,UAAU;AAAA,EACV,OAAO;AAAA,EACP,cAAc;AAChB;AAEA,MAAM,oBAAoB,SAAS,KAAK,CAAC,CAAC;AAC1C,kBAAkB,OAAO;AAAA,EACvB;AAAA,EACA,UAAU;AAAA,EACV,OAAO;AAAA,EACP,MAAM;AAAA,EACN,cAAc;AAChB;AAEA,MAAM,eAAe,SAAS,KAAK,CAAC,CAAC;AACrC,aAAa,OAAO;AAAA,EAClB;AAAA,EACA,UAAU,4CAAC,UAAM,6BAAkB;AAAA,EACnC,UAAU;AAAA,EACV,OAAO;AAAA,EACP,cAAc;AAChB;AAKA,IAAO,+BAAQ;","names":["import_react"]}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Account } from "@xyo-network/account";
|
|
3
|
+
import { useEvent } from "@xyo-network/react-event";
|
|
4
|
+
import { useState } from "react";
|
|
5
|
+
import { AddressRenderRowBox } from "./RenderRowBox";
|
|
6
|
+
const address = new Account({ phrase: "temp" }).address;
|
|
7
|
+
const StorybookEntry = {
|
|
8
|
+
argTypes: {},
|
|
9
|
+
component: AddressRenderRowBox,
|
|
10
|
+
parameters: {
|
|
11
|
+
docs: {
|
|
12
|
+
page: null
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
title: "address/render/AddressRenderRowBox"
|
|
16
|
+
};
|
|
17
|
+
const Template = (args) => {
|
|
18
|
+
const [ref] = useEvent((noun, verb, data) => {
|
|
19
|
+
console.log(`${noun}|${verb}|${data}`);
|
|
20
|
+
const parsedEvent = JSON.parse(data ?? "");
|
|
21
|
+
if (parsedEvent.favorite) {
|
|
22
|
+
setName(parsedEvent.name);
|
|
23
|
+
} else {
|
|
24
|
+
setName(void 0);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
const [name, setName] = useState(args.name);
|
|
28
|
+
return /* @__PURE__ */ jsx(AddressRenderRowBox, { ...args, name, ref });
|
|
29
|
+
};
|
|
30
|
+
const Default = Template.bind({});
|
|
31
|
+
Default.args = {};
|
|
32
|
+
const WithAddress = Template.bind({});
|
|
33
|
+
WithAddress.args = {
|
|
34
|
+
address
|
|
35
|
+
};
|
|
36
|
+
const WithIcon = Template.bind({});
|
|
37
|
+
WithIcon.args = {
|
|
38
|
+
address,
|
|
39
|
+
icons: true
|
|
40
|
+
};
|
|
41
|
+
const WithIconOnly = Template.bind({});
|
|
42
|
+
WithIconOnly.args = {
|
|
43
|
+
address,
|
|
44
|
+
iconOnly: true,
|
|
45
|
+
icons: true
|
|
46
|
+
};
|
|
47
|
+
const WithFavorite = Template.bind({});
|
|
48
|
+
WithFavorite.args = {
|
|
49
|
+
address,
|
|
50
|
+
favorite: true,
|
|
51
|
+
icons: true,
|
|
52
|
+
showFavorite: true
|
|
53
|
+
};
|
|
54
|
+
const WithFavoriteAlias = Template.bind({});
|
|
55
|
+
WithFavoriteAlias.args = {
|
|
56
|
+
address,
|
|
57
|
+
favorite: true,
|
|
58
|
+
icons: true,
|
|
59
|
+
name: "My Name",
|
|
60
|
+
showFavorite: true
|
|
61
|
+
};
|
|
62
|
+
const WithChildren = Template.bind({});
|
|
63
|
+
WithChildren.args = {
|
|
64
|
+
address,
|
|
65
|
+
children: /* @__PURE__ */ jsx("span", { children: "[InsertedChild]" }),
|
|
66
|
+
favorite: true,
|
|
67
|
+
icons: true,
|
|
68
|
+
showFavorite: true
|
|
69
|
+
};
|
|
70
|
+
var RenderRowBox_stories_default = StorybookEntry;
|
|
71
|
+
export {
|
|
72
|
+
Default,
|
|
73
|
+
WithAddress,
|
|
74
|
+
WithChildren,
|
|
75
|
+
WithFavorite,
|
|
76
|
+
WithFavoriteAlias,
|
|
77
|
+
WithIcon,
|
|
78
|
+
WithIconOnly,
|
|
79
|
+
RenderRowBox_stories_default as default
|
|
80
|
+
};
|
|
81
|
+
//# sourceMappingURL=RenderRowBox.stories.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/RenderRowBox.stories.tsx"],"sourcesContent":["import { Meta, StoryFn } from '@storybook/react'\nimport { Account } from '@xyo-network/account'\nimport { useEvent } from '@xyo-network/react-event'\nimport { useState } from 'react'\n\nimport { FavoriteItemEvent } from './lib'\nimport { AddressRenderRowBox } from './RenderRowBox'\n\nconst address = new Account({ phrase: 'temp' }).address\n\nconst StorybookEntry = {\n argTypes: {},\n component: AddressRenderRowBox,\n parameters: {\n docs: {\n page: null,\n },\n },\n title: 'address/render/AddressRenderRowBox',\n} as Meta<typeof AddressRenderRowBox>\n\nconst Template: StoryFn<typeof AddressRenderRowBox> = (args) => {\n const [ref] = useEvent<HTMLLIElement>((noun, verb, data) => {\n console.log(`${noun}|${verb}|${data}`)\n const parsedEvent = JSON.parse(data ?? '') as FavoriteItemEvent\n if (parsedEvent.favorite) {\n setName(parsedEvent.name)\n } else {\n setName(undefined)\n }\n })\n const [name, setName] = useState(args.name)\n return <AddressRenderRowBox {...args} name={name} ref={ref} />\n}\n\nconst Default = Template.bind({})\nDefault.args = {}\n\nconst WithAddress = Template.bind({})\nWithAddress.args = {\n address,\n}\n\nconst WithIcon = Template.bind({})\nWithIcon.args = {\n address,\n icons: true,\n}\n\nconst WithIconOnly = Template.bind({})\nWithIconOnly.args = {\n address,\n iconOnly: true,\n icons: true,\n}\n\nconst WithFavorite = Template.bind({})\nWithFavorite.args = {\n address,\n favorite: true,\n icons: true,\n showFavorite: true,\n}\n\nconst WithFavoriteAlias = Template.bind({})\nWithFavoriteAlias.args = {\n address,\n favorite: true,\n icons: true,\n name: 'My Name',\n showFavorite: true,\n}\n\nconst WithChildren = Template.bind({})\nWithChildren.args = {\n address,\n children: <span>{'[InsertedChild]'}</span>,\n favorite: true,\n icons: true,\n showFavorite: true,\n}\n\nexport { Default, WithAddress, WithChildren, WithFavorite, WithFavoriteAlias, WithIcon, WithIconOnly }\n\n// eslint-disable-next-line import/no-default-export\nexport default StorybookEntry\n"],"mappings":"AAgCS;AA/BT,SAAS,eAAe;AACxB,SAAS,gBAAgB;AACzB,SAAS,gBAAgB;AAGzB,SAAS,2BAA2B;AAEpC,MAAM,UAAU,IAAI,QAAQ,EAAE,QAAQ,OAAO,CAAC,EAAE;AAEhD,MAAM,iBAAiB;AAAA,EACrB,UAAU,CAAC;AAAA,EACX,WAAW;AAAA,EACX,YAAY;AAAA,IACV,MAAM;AAAA,MACJ,MAAM;AAAA,IACR;AAAA,EACF;AAAA,EACA,OAAO;AACT;AAEA,MAAM,WAAgD,CAAC,SAAS;AAC9D,QAAM,CAAC,GAAG,IAAI,SAAwB,CAAC,MAAM,MAAM,SAAS;AAC1D,YAAQ,IAAI,GAAG,IAAI,IAAI,IAAI,IAAI,IAAI,EAAE;AACrC,UAAM,cAAc,KAAK,MAAM,QAAQ,EAAE;AACzC,QAAI,YAAY,UAAU;AACxB,cAAQ,YAAY,IAAI;AAAA,IAC1B,OAAO;AACL,cAAQ,MAAS;AAAA,IACnB;AAAA,EACF,CAAC;AACD,QAAM,CAAC,MAAM,OAAO,IAAI,SAAS,KAAK,IAAI;AAC1C,SAAO,oBAAC,uBAAqB,GAAG,MAAM,MAAY,KAAU;AAC9D;AAEA,MAAM,UAAU,SAAS,KAAK,CAAC,CAAC;AAChC,QAAQ,OAAO,CAAC;AAEhB,MAAM,cAAc,SAAS,KAAK,CAAC,CAAC;AACpC,YAAY,OAAO;AAAA,EACjB;AACF;AAEA,MAAM,WAAW,SAAS,KAAK,CAAC,CAAC;AACjC,SAAS,OAAO;AAAA,EACd;AAAA,EACA,OAAO;AACT;AAEA,MAAM,eAAe,SAAS,KAAK,CAAC,CAAC;AACrC,aAAa,OAAO;AAAA,EAClB;AAAA,EACA,UAAU;AAAA,EACV,OAAO;AACT;AAEA,MAAM,eAAe,SAAS,KAAK,CAAC,CAAC;AACrC,aAAa,OAAO;AAAA,EAClB;AAAA,EACA,UAAU;AAAA,EACV,OAAO;AAAA,EACP,cAAc;AAChB;AAEA,MAAM,oBAAoB,SAAS,KAAK,CAAC,CAAC;AAC1C,kBAAkB,OAAO;AAAA,EACvB;AAAA,EACA,UAAU;AAAA,EACV,OAAO;AAAA,EACP,MAAM;AAAA,EACN,cAAc;AAChB;AAEA,MAAM,eAAe,SAAS,KAAK,CAAC,CAAC;AACrC,aAAa,OAAO;AAAA,EAClB;AAAA,EACA,UAAU,oBAAC,UAAM,6BAAkB;AAAA,EACnC,UAAU;AAAA,EACV,OAAO;AAAA,EACP,cAAc;AAChB;AAKA,IAAO,+BAAQ;","names":[]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { IconButtonProps } from '@mui/material';
|
|
3
|
+
import { WithChildren } from '@xylabs/react-shared';
|
|
4
|
+
import { FavoriteItemEvent } from '../lib';
|
|
5
|
+
export interface FavoriteIconButtonProps extends WithChildren, IconButtonProps {
|
|
6
|
+
favorite?: FavoriteItemEvent['favorite'];
|
|
7
|
+
name?: FavoriteItemEvent['name'];
|
|
8
|
+
value?: string;
|
|
9
|
+
valueType?: FavoriteItemEvent['favoriteType'];
|
|
10
|
+
}
|
|
11
|
+
export declare const FavoriteIconButton: import("react").ForwardRefExoticComponent<Omit<FavoriteIconButtonProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
|
|
12
|
+
//# sourceMappingURL=FavoriteIconButton.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FavoriteIconButton.d.ts","sourceRoot":"","sources":["../../../../src/components/favorite/FavoriteIconButton.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAc,eAAe,EAAU,MAAM,eAAe,CAAA;AACnE,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,oIAqD9B,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { IconButtonProps } from '@mui/material';
|
|
3
|
+
import { WithChildren } from '@xylabs/react-shared';
|
|
4
|
+
import { FavoriteItemEvent } from '../lib';
|
|
5
|
+
export interface FavoriteIconButtonProps extends WithChildren, IconButtonProps {
|
|
6
|
+
favorite?: FavoriteItemEvent['favorite'];
|
|
7
|
+
name?: FavoriteItemEvent['name'];
|
|
8
|
+
value?: string;
|
|
9
|
+
valueType?: FavoriteItemEvent['favoriteType'];
|
|
10
|
+
}
|
|
11
|
+
export declare const FavoriteIconButton: import("react").ForwardRefExoticComponent<Omit<FavoriteIconButtonProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
|
|
12
|
+
//# sourceMappingURL=FavoriteIconButton.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FavoriteIconButton.d.ts","sourceRoot":"","sources":["../../../../src/components/favorite/FavoriteIconButton.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAc,eAAe,EAAU,MAAM,eAAe,CAAA;AACnE,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,oIAqD9B,CAAA"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var FavoriteIconButton_exports = {};
|
|
20
|
+
__export(FavoriteIconButton_exports, {
|
|
21
|
+
FavoriteIconButton: () => FavoriteIconButton
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(FavoriteIconButton_exports);
|
|
24
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
25
|
+
var import_material = require("@mui/material");
|
|
26
|
+
var import_react_event = require("@xyo-network/react-event");
|
|
27
|
+
var import_react_shared2 = require("@xyo-network/react-shared");
|
|
28
|
+
var import_react = require("react");
|
|
29
|
+
var import_lib = require("../lib");
|
|
30
|
+
var import_FavoriteToggleSVG = require("./FavoriteToggleSVG");
|
|
31
|
+
var import_lib2 = require("./lib");
|
|
32
|
+
var import_Popper = require("./Popper");
|
|
33
|
+
const FavoriteIconButton = (0, import_react.forwardRef)(
|
|
34
|
+
({ children, favorite: favoriteProp, name, valueType, value, ...props }, ref) => {
|
|
35
|
+
const [openPopper, setOpenPopper] = (0, import_react.useState)(false);
|
|
36
|
+
const [favorite, setFavorite] = (0, import_react.useState)(favoriteProp);
|
|
37
|
+
(0, import_react.useEffect)(() => {
|
|
38
|
+
setFavorite(favoriteProp);
|
|
39
|
+
}, [favoriteProp]);
|
|
40
|
+
const sharedRef = (0, import_react_shared2.useShareForwardedRef)(ref);
|
|
41
|
+
const [buttonRef, dispatch] = (0, import_react_event.useEvent)(void 0, sharedRef);
|
|
42
|
+
const onConfirmFavorite = (name2, newFavoriteState) => {
|
|
43
|
+
const favoriteEvent = (0, import_lib.generateFavoriteEvent)(!!newFavoriteState, valueType, value, name2);
|
|
44
|
+
dispatch("address", "favorite", JSON.stringify(favoriteEvent));
|
|
45
|
+
setFavorite(newFavoriteState);
|
|
46
|
+
setOpenPopper(false);
|
|
47
|
+
};
|
|
48
|
+
const starRef = (0, import_react.useRef)(null);
|
|
49
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
50
|
+
IconButtonCondensed,
|
|
51
|
+
{
|
|
52
|
+
"aria-describedby": import_lib2.popperId,
|
|
53
|
+
ref: buttonRef,
|
|
54
|
+
onClick: (event) => {
|
|
55
|
+
event.stopPropagation();
|
|
56
|
+
setOpenPopper(!openPopper);
|
|
57
|
+
},
|
|
58
|
+
onTouchStart: (event) => {
|
|
59
|
+
event.stopPropagation();
|
|
60
|
+
setOpenPopper(!openPopper);
|
|
61
|
+
},
|
|
62
|
+
onMouseDown: (e) => e.stopPropagation(),
|
|
63
|
+
sx: { lineHeight: 0, p: 0.25 },
|
|
64
|
+
...props,
|
|
65
|
+
children: [
|
|
66
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { ref: starRef, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_FavoriteToggleSVG.FavoriteToggleSVG, { favorite }) }),
|
|
67
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
68
|
+
import_Popper.FavoritePopper,
|
|
69
|
+
{
|
|
70
|
+
sx: { zIndex: 1301 },
|
|
71
|
+
name,
|
|
72
|
+
favorite,
|
|
73
|
+
favoriteRef: starRef,
|
|
74
|
+
open: openPopper,
|
|
75
|
+
onConfirmFavorite,
|
|
76
|
+
onClickAway: () => setOpenPopper(false)
|
|
77
|
+
}
|
|
78
|
+
),
|
|
79
|
+
children
|
|
80
|
+
]
|
|
81
|
+
}
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
);
|
|
85
|
+
FavoriteIconButton.displayName = "FavoriteIconButton";
|
|
86
|
+
const IconButtonCondensed = (0, import_material.styled)(import_material.IconButton, { name: "IconButtonCondensed" })(({ theme }) => ({
|
|
87
|
+
lineHeight: 0,
|
|
88
|
+
padding: theme.spacing(0.25)
|
|
89
|
+
}));
|
|
90
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
91
|
+
0 && (module.exports = {
|
|
92
|
+
FavoriteIconButton
|
|
93
|
+
});
|
|
94
|
+
//# sourceMappingURL=FavoriteIconButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/favorite/FavoriteIconButton.tsx"],"sourcesContent":["import { IconButton, IconButtonProps, styled } from '@mui/material'\nimport { WithChildren } from '@xylabs/react-shared'\nimport { useEvent } from '@xyo-network/react-event'\nimport { useShareForwardedRef } from '@xyo-network/react-shared'\nimport { forwardRef, useEffect, useRef, useState } from 'react'\n\nimport { FavoriteItemEvent, generateFavoriteEvent } from '../lib'\nimport { FavoriteToggleSVG } from './FavoriteToggleSVG'\nimport { popperId } from './lib'\nimport { FavoritePopper } from './Popper'\n\nexport interface FavoriteIconButtonProps extends WithChildren, IconButtonProps {\n favorite?: FavoriteItemEvent['favorite']\n name?: FavoriteItemEvent['name']\n value?: string\n valueType?: FavoriteItemEvent['favoriteType']\n}\n\nexport const FavoriteIconButton = forwardRef<HTMLButtonElement, FavoriteIconButtonProps>(\n ({ children, favorite: favoriteProp, name, valueType, value, ...props }, ref) => {\n const [openPopper, setOpenPopper] = useState(false)\n\n const [favorite, setFavorite] = useState(favoriteProp)\n useEffect(() => {\n setFavorite(favoriteProp)\n }, [favoriteProp])\n\n const sharedRef = useShareForwardedRef(ref)\n const [buttonRef, dispatch] = useEvent(undefined, sharedRef)\n\n const onConfirmFavorite = (name?: string, newFavoriteState?: boolean) => {\n const favoriteEvent = generateFavoriteEvent(!!newFavoriteState, valueType, value, name)\n dispatch('address', 'favorite', JSON.stringify(favoriteEvent))\n setFavorite(newFavoriteState)\n setOpenPopper(false)\n }\n\n const starRef = useRef<HTMLSpanElement>(null)\n\n return (\n <IconButtonCondensed\n aria-describedby={popperId}\n ref={buttonRef}\n onClick={(event) => {\n event.stopPropagation()\n setOpenPopper(!openPopper)\n }}\n onTouchStart={(event) => {\n event.stopPropagation()\n setOpenPopper(!openPopper)\n }}\n onMouseDown={(e) => e.stopPropagation()}\n sx={{ lineHeight: 0, p: 0.25 }}\n {...props}\n >\n <span ref={starRef}>\n <FavoriteToggleSVG favorite={favorite} />\n </span>\n <FavoritePopper\n sx={{ zIndex: 1301 }}\n name={name}\n favorite={favorite}\n favoriteRef={starRef}\n open={openPopper}\n onConfirmFavorite={onConfirmFavorite}\n onClickAway={() => setOpenPopper(false)}\n />\n {children}\n </IconButtonCondensed>\n )\n },\n)\n\nFavoriteIconButton.displayName = 'FavoriteIconButton'\n\nconst IconButtonCondensed = styled(IconButton, { name: 'IconButtonCondensed' })(({ theme }) => ({\n lineHeight: 0,\n padding: theme.spacing(0.25),\n}))\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAwCM;AAxCN,sBAAoD;AAEpD,yBAAyB;AACzB,IAAAA,uBAAqC;AACrC,mBAAwD;AAExD,iBAAyD;AACzD,+BAAkC;AAClC,IAAAC,cAAyB;AACzB,oBAA+B;AASxB,MAAM,yBAAqB;AAAA,EAChC,CAAC,EAAE,UAAU,UAAU,cAAc,MAAM,WAAW,OAAO,GAAG,MAAM,GAAG,QAAQ;AAC/E,UAAM,CAAC,YAAY,aAAa,QAAI,uBAAS,KAAK;AAElD,UAAM,CAAC,UAAU,WAAW,QAAI,uBAAS,YAAY;AACrD,gCAAU,MAAM;AACd,kBAAY,YAAY;AAAA,IAC1B,GAAG,CAAC,YAAY,CAAC;AAEjB,UAAM,gBAAY,2CAAqB,GAAG;AAC1C,UAAM,CAAC,WAAW,QAAQ,QAAI,6BAAS,QAAW,SAAS;AAE3D,UAAM,oBAAoB,CAACC,OAAe,qBAA+B;AACvE,YAAM,oBAAgB,kCAAsB,CAAC,CAAC,kBAAkB,WAAW,OAAOA,KAAI;AACtF,eAAS,WAAW,YAAY,KAAK,UAAU,aAAa,CAAC;AAC7D,kBAAY,gBAAgB;AAC5B,oBAAc,KAAK;AAAA,IACrB;AAEA,UAAM,cAAU,qBAAwB,IAAI;AAE5C,WACE;AAAA,MAAC;AAAA;AAAA,QACC,oBAAkB;AAAA,QAClB,KAAK;AAAA,QACL,SAAS,CAAC,UAAU;AAClB,gBAAM,gBAAgB;AACtB,wBAAc,CAAC,UAAU;AAAA,QAC3B;AAAA,QACA,cAAc,CAAC,UAAU;AACvB,gBAAM,gBAAgB;AACtB,wBAAc,CAAC,UAAU;AAAA,QAC3B;AAAA,QACA,aAAa,CAAC,MAAM,EAAE,gBAAgB;AAAA,QACtC,IAAI,EAAE,YAAY,GAAG,GAAG,KAAK;AAAA,QAC5B,GAAG;AAAA,QAEJ;AAAA,sDAAC,UAAK,KAAK,SACT,sDAAC,8CAAkB,UAAoB,GACzC;AAAA,UACA;AAAA,YAAC;AAAA;AAAA,cACC,IAAI,EAAE,QAAQ,KAAK;AAAA,cACnB;AAAA,cACA;AAAA,cACA,aAAa;AAAA,cACb,MAAM;AAAA,cACN;AAAA,cACA,aAAa,MAAM,cAAc,KAAK;AAAA;AAAA,UACxC;AAAA,UACC;AAAA;AAAA;AAAA,IACH;AAAA,EAEJ;AACF;AAEA,mBAAmB,cAAc;AAEjC,MAAM,0BAAsB,wBAAO,4BAAY,EAAE,MAAM,sBAAsB,CAAC,EAAE,CAAC,EAAE,MAAM,OAAO;AAAA,EAC9F,YAAY;AAAA,EACZ,SAAS,MAAM,QAAQ,IAAI;AAC7B,EAAE;","names":["import_react_shared","import_lib","name"]}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { IconButton, styled } from "@mui/material";
|
|
3
|
+
import { useEvent } from "@xyo-network/react-event";
|
|
4
|
+
import { useShareForwardedRef } from "@xyo-network/react-shared";
|
|
5
|
+
import { forwardRef, useEffect, useRef, useState } from "react";
|
|
6
|
+
import { generateFavoriteEvent } from "../lib";
|
|
7
|
+
import { FavoriteToggleSVG } from "./FavoriteToggleSVG";
|
|
8
|
+
import { popperId } from "./lib";
|
|
9
|
+
import { FavoritePopper } from "./Popper";
|
|
10
|
+
const FavoriteIconButton = forwardRef(
|
|
11
|
+
({ children, favorite: favoriteProp, name, valueType, value, ...props }, ref) => {
|
|
12
|
+
const [openPopper, setOpenPopper] = useState(false);
|
|
13
|
+
const [favorite, setFavorite] = useState(favoriteProp);
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
setFavorite(favoriteProp);
|
|
16
|
+
}, [favoriteProp]);
|
|
17
|
+
const sharedRef = useShareForwardedRef(ref);
|
|
18
|
+
const [buttonRef, dispatch] = useEvent(void 0, sharedRef);
|
|
19
|
+
const onConfirmFavorite = (name2, newFavoriteState) => {
|
|
20
|
+
const favoriteEvent = generateFavoriteEvent(!!newFavoriteState, valueType, value, name2);
|
|
21
|
+
dispatch("address", "favorite", JSON.stringify(favoriteEvent));
|
|
22
|
+
setFavorite(newFavoriteState);
|
|
23
|
+
setOpenPopper(false);
|
|
24
|
+
};
|
|
25
|
+
const starRef = useRef(null);
|
|
26
|
+
return /* @__PURE__ */ jsxs(
|
|
27
|
+
IconButtonCondensed,
|
|
28
|
+
{
|
|
29
|
+
"aria-describedby": popperId,
|
|
30
|
+
ref: buttonRef,
|
|
31
|
+
onClick: (event) => {
|
|
32
|
+
event.stopPropagation();
|
|
33
|
+
setOpenPopper(!openPopper);
|
|
34
|
+
},
|
|
35
|
+
onTouchStart: (event) => {
|
|
36
|
+
event.stopPropagation();
|
|
37
|
+
setOpenPopper(!openPopper);
|
|
38
|
+
},
|
|
39
|
+
onMouseDown: (e) => e.stopPropagation(),
|
|
40
|
+
sx: { lineHeight: 0, p: 0.25 },
|
|
41
|
+
...props,
|
|
42
|
+
children: [
|
|
43
|
+
/* @__PURE__ */ jsx("span", { ref: starRef, children: /* @__PURE__ */ jsx(FavoriteToggleSVG, { favorite }) }),
|
|
44
|
+
/* @__PURE__ */ jsx(
|
|
45
|
+
FavoritePopper,
|
|
46
|
+
{
|
|
47
|
+
sx: { zIndex: 1301 },
|
|
48
|
+
name,
|
|
49
|
+
favorite,
|
|
50
|
+
favoriteRef: starRef,
|
|
51
|
+
open: openPopper,
|
|
52
|
+
onConfirmFavorite,
|
|
53
|
+
onClickAway: () => setOpenPopper(false)
|
|
54
|
+
}
|
|
55
|
+
),
|
|
56
|
+
children
|
|
57
|
+
]
|
|
58
|
+
}
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
);
|
|
62
|
+
FavoriteIconButton.displayName = "FavoriteIconButton";
|
|
63
|
+
const IconButtonCondensed = styled(IconButton, { name: "IconButtonCondensed" })(({ theme }) => ({
|
|
64
|
+
lineHeight: 0,
|
|
65
|
+
padding: theme.spacing(0.25)
|
|
66
|
+
}));
|
|
67
|
+
export {
|
|
68
|
+
FavoriteIconButton
|
|
69
|
+
};
|
|
70
|
+
//# sourceMappingURL=FavoriteIconButton.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/favorite/FavoriteIconButton.tsx"],"sourcesContent":["import { IconButton, IconButtonProps, styled } from '@mui/material'\nimport { WithChildren } from '@xylabs/react-shared'\nimport { useEvent } from '@xyo-network/react-event'\nimport { useShareForwardedRef } from '@xyo-network/react-shared'\nimport { forwardRef, useEffect, useRef, useState } from 'react'\n\nimport { FavoriteItemEvent, generateFavoriteEvent } from '../lib'\nimport { FavoriteToggleSVG } from './FavoriteToggleSVG'\nimport { popperId } from './lib'\nimport { FavoritePopper } from './Popper'\n\nexport interface FavoriteIconButtonProps extends WithChildren, IconButtonProps {\n favorite?: FavoriteItemEvent['favorite']\n name?: FavoriteItemEvent['name']\n value?: string\n valueType?: FavoriteItemEvent['favoriteType']\n}\n\nexport const FavoriteIconButton = forwardRef<HTMLButtonElement, FavoriteIconButtonProps>(\n ({ children, favorite: favoriteProp, name, valueType, value, ...props }, ref) => {\n const [openPopper, setOpenPopper] = useState(false)\n\n const [favorite, setFavorite] = useState(favoriteProp)\n useEffect(() => {\n setFavorite(favoriteProp)\n }, [favoriteProp])\n\n const sharedRef = useShareForwardedRef(ref)\n const [buttonRef, dispatch] = useEvent(undefined, sharedRef)\n\n const onConfirmFavorite = (name?: string, newFavoriteState?: boolean) => {\n const favoriteEvent = generateFavoriteEvent(!!newFavoriteState, valueType, value, name)\n dispatch('address', 'favorite', JSON.stringify(favoriteEvent))\n setFavorite(newFavoriteState)\n setOpenPopper(false)\n }\n\n const starRef = useRef<HTMLSpanElement>(null)\n\n return (\n <IconButtonCondensed\n aria-describedby={popperId}\n ref={buttonRef}\n onClick={(event) => {\n event.stopPropagation()\n setOpenPopper(!openPopper)\n }}\n onTouchStart={(event) => {\n event.stopPropagation()\n setOpenPopper(!openPopper)\n }}\n onMouseDown={(e) => e.stopPropagation()}\n sx={{ lineHeight: 0, p: 0.25 }}\n {...props}\n >\n <span ref={starRef}>\n <FavoriteToggleSVG favorite={favorite} />\n </span>\n <FavoritePopper\n sx={{ zIndex: 1301 }}\n name={name}\n favorite={favorite}\n favoriteRef={starRef}\n open={openPopper}\n onConfirmFavorite={onConfirmFavorite}\n onClickAway={() => setOpenPopper(false)}\n />\n {children}\n </IconButtonCondensed>\n )\n },\n)\n\nFavoriteIconButton.displayName = 'FavoriteIconButton'\n\nconst IconButtonCondensed = styled(IconButton, { name: 'IconButtonCondensed' })(({ theme }) => ({\n lineHeight: 0,\n padding: theme.spacing(0.25),\n}))\n"],"mappings":"AAwCM,SAgBI,KAhBJ;AAxCN,SAAS,YAA6B,cAAc;AAEpD,SAAS,gBAAgB;AACzB,SAAS,4BAA4B;AACrC,SAAS,YAAY,WAAW,QAAQ,gBAAgB;AAExD,SAA4B,6BAA6B;AACzD,SAAS,yBAAyB;AAClC,SAAS,gBAAgB;AACzB,SAAS,sBAAsB;AASxB,MAAM,qBAAqB;AAAA,EAChC,CAAC,EAAE,UAAU,UAAU,cAAc,MAAM,WAAW,OAAO,GAAG,MAAM,GAAG,QAAQ;AAC/E,UAAM,CAAC,YAAY,aAAa,IAAI,SAAS,KAAK;AAElD,UAAM,CAAC,UAAU,WAAW,IAAI,SAAS,YAAY;AACrD,cAAU,MAAM;AACd,kBAAY,YAAY;AAAA,IAC1B,GAAG,CAAC,YAAY,CAAC;AAEjB,UAAM,YAAY,qBAAqB,GAAG;AAC1C,UAAM,CAAC,WAAW,QAAQ,IAAI,SAAS,QAAW,SAAS;AAE3D,UAAM,oBAAoB,CAACA,OAAe,qBAA+B;AACvE,YAAM,gBAAgB,sBAAsB,CAAC,CAAC,kBAAkB,WAAW,OAAOA,KAAI;AACtF,eAAS,WAAW,YAAY,KAAK,UAAU,aAAa,CAAC;AAC7D,kBAAY,gBAAgB;AAC5B,oBAAc,KAAK;AAAA,IACrB;AAEA,UAAM,UAAU,OAAwB,IAAI;AAE5C,WACE;AAAA,MAAC;AAAA;AAAA,QACC,oBAAkB;AAAA,QAClB,KAAK;AAAA,QACL,SAAS,CAAC,UAAU;AAClB,gBAAM,gBAAgB;AACtB,wBAAc,CAAC,UAAU;AAAA,QAC3B;AAAA,QACA,cAAc,CAAC,UAAU;AACvB,gBAAM,gBAAgB;AACtB,wBAAc,CAAC,UAAU;AAAA,QAC3B;AAAA,QACA,aAAa,CAAC,MAAM,EAAE,gBAAgB;AAAA,QACtC,IAAI,EAAE,YAAY,GAAG,GAAG,KAAK;AAAA,QAC5B,GAAG;AAAA,QAEJ;AAAA,8BAAC,UAAK,KAAK,SACT,8BAAC,qBAAkB,UAAoB,GACzC;AAAA,UACA;AAAA,YAAC;AAAA;AAAA,cACC,IAAI,EAAE,QAAQ,KAAK;AAAA,cACnB;AAAA,cACA;AAAA,cACA,aAAa;AAAA,cACb,MAAM;AAAA,cACN;AAAA,cACA,aAAa,MAAM,cAAc,KAAK;AAAA;AAAA,UACxC;AAAA,UACC;AAAA;AAAA;AAAA,IACH;AAAA,EAEJ;AACF;AAEA,mBAAmB,cAAc;AAEjC,MAAM,sBAAsB,OAAO,YAAY,EAAE,MAAM,sBAAsB,CAAC,EAAE,CAAC,EAAE,MAAM,OAAO;AAAA,EAC9F,YAAY;AAAA,EACZ,SAAS,MAAM,QAAQ,IAAI;AAC7B,EAAE;","names":["name"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FavoriteToggleSVG.d.ts","sourceRoot":"","sources":["../../../../src/components/favorite/FavoriteToggleSVG.tsx"],"names":[],"mappings":";AAEA,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,CAQ9D,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FavoriteToggleSVG.d.ts","sourceRoot":"","sources":["../../../../src/components/favorite/FavoriteToggleSVG.tsx"],"names":[],"mappings":";AAEA,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,CAQ9D,CAAA"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var FavoriteToggleSVG_exports = {};
|
|
20
|
+
__export(FavoriteToggleSVG_exports, {
|
|
21
|
+
FavoriteToggleSVG: () => FavoriteToggleSVG
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(FavoriteToggleSVG_exports);
|
|
24
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
25
|
+
var import_icons_material = require("@mui/icons-material");
|
|
26
|
+
const FavoriteToggleSVG = ({ favorite }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: favorite ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons_material.Star, { className: "favorite-icon", component: "svg", color: "secondary", fontSize: "small" }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons_material.StarBorder, { className: "favorite-icon", fontSize: "small" }) });
|
|
27
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
28
|
+
0 && (module.exports = {
|
|
29
|
+
FavoriteToggleSVG
|
|
30
|
+
});
|
|
31
|
+
//# sourceMappingURL=FavoriteToggleSVG.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/favorite/FavoriteToggleSVG.tsx"],"sourcesContent":["import { Star as StarIcon, StarBorder as StarBorderIcon } from '@mui/icons-material'\n\nexport const FavoriteToggleSVG: React.FC<{ favorite?: boolean }> = ({ favorite }) => (\n <>\n {favorite ? (\n <StarIcon className=\"favorite-icon\" component={'svg'} color=\"secondary\" fontSize=\"small\" />\n ) : (\n <StarBorderIcon className=\"favorite-icon\" fontSize=\"small\" />\n )}\n </>\n)\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGE;AAHF,4BAA+D;AAExD,MAAM,oBAAsD,CAAC,EAAE,SAAS,MAC7E,2EACG,qBACC,4CAAC,sBAAAA,MAAA,EAAS,WAAU,iBAAgB,WAAW,OAAO,OAAM,aAAY,UAAS,SAAQ,IAEzF,4CAAC,sBAAAC,YAAA,EAAe,WAAU,iBAAgB,UAAS,SAAQ,GAE/D;","names":["StarIcon","StarBorderIcon"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Star as StarIcon, StarBorder as StarBorderIcon } from "@mui/icons-material";
|
|
3
|
+
const 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" }) });
|
|
4
|
+
export {
|
|
5
|
+
FavoriteToggleSVG
|
|
6
|
+
};
|
|
7
|
+
//# sourceMappingURL=FavoriteToggleSVG.mjs.map
|