buckaroo-js-core 0.8.0
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/.prettierrc +16 -0
- package/CHANGELOG.md +23 -0
- package/LICENSE +15 -0
- package/README.md +66 -0
- package/buckaroo_js/baked_data/colorMap.d.ts +3 -0
- package/buckaroo_js/baked_data/colorMap.d.ts.map +1 -0
- package/buckaroo_js/baked_data/colorMap.js +520 -0
- package/buckaroo_js/baked_data/colorMap.js.map +1 -0
- package/buckaroo_js/baked_data/staticData.d.ts +124 -0
- package/buckaroo_js/baked_data/staticData.d.ts.map +1 -0
- package/buckaroo_js/baked_data/staticData.js +459 -0
- package/buckaroo_js/baked_data/staticData.js.map +1 -0
- package/buckaroo_js/components/ColumnsEditor.d.ts +19 -0
- package/buckaroo_js/components/ColumnsEditor.d.ts.map +1 -0
- package/buckaroo_js/components/ColumnsEditor.js +68 -0
- package/buckaroo_js/components/ColumnsEditor.js.map +1 -0
- package/buckaroo_js/components/CommandUtils.d.ts +22 -0
- package/buckaroo_js/components/CommandUtils.d.ts.map +1 -0
- package/buckaroo_js/components/CommandUtils.js +17 -0
- package/buckaroo_js/components/CommandUtils.js.map +1 -0
- package/buckaroo_js/components/DCFCell.d.ts +28 -0
- package/buckaroo_js/components/DCFCell.d.ts.map +1 -0
- package/buckaroo_js/components/DCFCell.js +120 -0
- package/buckaroo_js/components/DCFCell.js.map +1 -0
- package/buckaroo_js/components/DFViewerParts/DFViewer.d.ts +29 -0
- package/buckaroo_js/components/DFViewerParts/DFViewer.d.ts.map +1 -0
- package/buckaroo_js/components/DFViewerParts/DFViewer.js +163 -0
- package/buckaroo_js/components/DFViewerParts/DFViewer.js.map +1 -0
- package/buckaroo_js/components/DFViewerParts/DFWhole.d.ts +111 -0
- package/buckaroo_js/components/DFViewerParts/DFWhole.d.ts.map +1 -0
- package/buckaroo_js/components/DFViewerParts/DFWhole.js +17 -0
- package/buckaroo_js/components/DFViewerParts/DFWhole.js.map +1 -0
- package/buckaroo_js/components/DFViewerParts/Displayer.d.ts +19 -0
- package/buckaroo_js/components/DFViewerParts/Displayer.d.ts.map +1 -0
- package/buckaroo_js/components/DFViewerParts/Displayer.js +221 -0
- package/buckaroo_js/components/DFViewerParts/Displayer.js.map +1 -0
- package/buckaroo_js/components/DFViewerParts/HistogramCell.d.ts +20 -0
- package/buckaroo_js/components/DFViewerParts/HistogramCell.d.ts.map +1 -0
- package/buckaroo_js/components/DFViewerParts/HistogramCell.js +184 -0
- package/buckaroo_js/components/DFViewerParts/HistogramCell.js.map +1 -0
- package/buckaroo_js/components/DFViewerParts/SeriesSummaryTooltip.d.ts +5 -0
- package/buckaroo_js/components/DFViewerParts/SeriesSummaryTooltip.d.ts.map +1 -0
- package/buckaroo_js/components/DFViewerParts/SeriesSummaryTooltip.js +18 -0
- package/buckaroo_js/components/DFViewerParts/SeriesSummaryTooltip.js.map +1 -0
- package/buckaroo_js/components/DFViewerParts/gridUtils.d.ts +24 -0
- package/buckaroo_js/components/DFViewerParts/gridUtils.d.ts.map +1 -0
- package/buckaroo_js/components/DFViewerParts/gridUtils.js +230 -0
- package/buckaroo_js/components/DFViewerParts/gridUtils.js.map +1 -0
- package/buckaroo_js/components/DependentTabs.d.ts +33 -0
- package/buckaroo_js/components/DependentTabs.d.ts.map +1 -0
- package/buckaroo_js/components/DependentTabs.js +108 -0
- package/buckaroo_js/components/DependentTabs.js.map +1 -0
- package/buckaroo_js/components/OperationDetail.d.ts +16 -0
- package/buckaroo_js/components/OperationDetail.d.ts.map +1 -0
- package/buckaroo_js/components/OperationDetail.js +144 -0
- package/buckaroo_js/components/OperationDetail.js.map +1 -0
- package/buckaroo_js/components/OperationUtils.d.ts +17 -0
- package/buckaroo_js/components/OperationUtils.d.ts.map +1 -0
- package/buckaroo_js/components/OperationUtils.js +14 -0
- package/buckaroo_js/components/OperationUtils.js.map +1 -0
- package/buckaroo_js/components/Operations.d.ts +24 -0
- package/buckaroo_js/components/Operations.d.ts.map +1 -0
- package/buckaroo_js/components/Operations.js +209 -0
- package/buckaroo_js/components/Operations.js.map +1 -0
- package/buckaroo_js/components/StatusBar.d.ts +12 -0
- package/buckaroo_js/components/StatusBar.d.ts.map +1 -0
- package/buckaroo_js/components/StatusBar.js +155 -0
- package/buckaroo_js/components/StatusBar.js.map +1 -0
- package/buckaroo_js/components/WidgetTypes.d.ts +25 -0
- package/buckaroo_js/components/WidgetTypes.d.ts.map +1 -0
- package/buckaroo_js/components/WidgetTypes.js +3 -0
- package/buckaroo_js/components/WidgetTypes.js.map +1 -0
- package/buckaroo_js/components/bakedOperationDefaults.d.ts +5 -0
- package/buckaroo_js/components/bakedOperationDefaults.d.ts.map +1 -0
- package/buckaroo_js/components/bakedOperationDefaults.js +15 -0
- package/buckaroo_js/components/bakedOperationDefaults.js.map +1 -0
- package/buckaroo_js/components/utils.d.ts +294 -0
- package/buckaroo_js/components/utils.d.ts.map +1 -0
- package/buckaroo_js/components/utils.js +143 -0
- package/buckaroo_js/components/utils.js.map +1 -0
- package/buckaroo_js/extension.d.ts +2 -0
- package/buckaroo_js/extension.d.ts.map +1 -0
- package/buckaroo_js/extension.js +20 -0
- package/buckaroo_js/extension.js.map +1 -0
- package/buckaroo_js/index.d.ts +25 -0
- package/buckaroo_js/index.d.ts.map +1 -0
- package/buckaroo_js/index.js +46 -0
- package/buckaroo_js/index.js.map +1 -0
- package/buckaroo_js/vendor/RechartExtra.d.ts +38 -0
- package/buckaroo_js/vendor/RechartExtra.d.ts.map +1 -0
- package/buckaroo_js/vendor/RechartExtra.js +17 -0
- package/buckaroo_js/vendor/RechartExtra.js.map +1 -0
- package/buckaroo_js/vendor/RechartTooltip.d.ts +82 -0
- package/buckaroo_js/vendor/RechartTooltip.d.ts.map +1 -0
- package/buckaroo_js/vendor/RechartTooltip.js +232 -0
- package/buckaroo_js/vendor/RechartTooltip.js.map +1 -0
- package/codecov.yml +16 -0
- package/eslint.config.mjs +88 -0
- package/examples/App.tsx +160 -0
- package/examples/CodeBlock.tsx +27 -0
- package/examples/CodePenButton.tsx +77 -0
- package/examples/ReadmeBlock.tsx +11 -0
- package/examples/app.css +29 -0
- package/examples/ex/ColumnsEditorEx.tsx +5 -0
- package/examples/ex/CommandViewerEx.tsx +20 -0
- package/examples/ex/DFViewerEx.tsx +3 -0
- package/examples/ex/DFViewerEx_large.tsx +266 -0
- package/examples/ex/DFViewerEx_real_summary.tsx +20 -0
- package/examples/ex/DFViewerEx_short_data.tsx +22 -0
- package/examples/ex/DFViewerEx_string_index.tsx +1012 -0
- package/examples/ex/HistogramEx.tsx +67 -0
- package/examples/ex/StatusBarEx.tsx +46 -0
- package/examples/ex/WidgetDCFCellEx.tsx +6 -0
- package/examples/example.css +20 -0
- package/examples/index-iframe.hnottml +24 -0
- package/examples/index-react18.tsx +8 -0
- package/examples/index.html +20 -0
- package/examples/jsx-loader.ts +16 -0
- package/examples/tsconfig.json +31 -0
- package/index.d.ts +2 -0
- package/index.d.ts.map +1 -0
- package/index.js +7 -0
- package/index.js.map +1 -0
- package/jest.config.js +24 -0
- package/package.json +117 -0
- package/screen-animation.gif +0 -0
- package/src/buckaroo_js/baked_data/colorMap.ts +523 -0
- package/src/buckaroo_js/baked_data/staticData.ts +503 -0
- package/src/buckaroo_js/components/ColumnsEditor.tsx +66 -0
- package/src/buckaroo_js/components/CommandUtils.ts +40 -0
- package/src/buckaroo_js/components/DCFCell.tsx +175 -0
- package/src/buckaroo_js/components/DFViewerParts/DFViewer.tsx +215 -0
- package/src/buckaroo_js/components/DFViewerParts/DFWhole.ts +190 -0
- package/src/buckaroo_js/components/DFViewerParts/Displayer.ts +215 -0
- package/src/buckaroo_js/components/DFViewerParts/HistogramCell.tsx +251 -0
- package/src/buckaroo_js/components/DFViewerParts/SeriesSummaryTooltip.tsx +20 -0
- package/src/buckaroo_js/components/DFViewerParts/gridUtils.ts +290 -0
- package/src/buckaroo_js/components/DependentTabs.tsx +134 -0
- package/src/buckaroo_js/components/OperationDetail.tsx +203 -0
- package/src/buckaroo_js/components/OperationUtils.ts +33 -0
- package/src/buckaroo_js/components/Operations.tsx +243 -0
- package/src/buckaroo_js/components/StatusBar.tsx +190 -0
- package/src/buckaroo_js/components/WidgetTypes.tsx +42 -0
- package/src/buckaroo_js/components/bakedOperationDefaults.ts +14 -0
- package/src/buckaroo_js/components/utils.ts +60 -0
- package/src/buckaroo_js/extension.ts +15 -0
- package/src/buckaroo_js/index.ts +34 -0
- package/src/buckaroo_js/style/dcf-npm.css +244 -0
- package/src/buckaroo_js/style/icons/arrow-down-short-dark.svg +4 -0
- package/src/buckaroo_js/style/icons/arrow-down-short.svg +4 -0
- package/src/buckaroo_js/style/icons/arrow-up-short-dark.svg +4 -0
- package/src/buckaroo_js/style/icons/arrow-up-short.svg +4 -0
- package/src/buckaroo_js/style/icons/filter-dark.svg +3 -0
- package/src/buckaroo_js/style/icons/filter.svg +3 -0
- package/src/buckaroo_js/vendor/RechartExtra.ts +60 -0
- package/src/buckaroo_js/vendor/RechartTooltip.tsx +357 -0
- package/src/index.tsx +3 -0
- package/tsconfig.json +41 -0
- package/webpack.config.ts +97 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import React, { CSSProperties, ReactNode, ReactElement, SVGProps } from 'react';
|
|
2
|
+
import type { ValueType, NameType, Payload, DefaultProps } from './RechartExtra';
|
|
3
|
+
import { AnimationDuration, AnimationTiming } from './RechartExtra';
|
|
4
|
+
export type ContentType<TValue extends ValueType, TName extends NameType> = ReactElement | ((props: TooltipProps<TValue, TName>) => ReactNode);
|
|
5
|
+
type UniqueFunc<TValue extends ValueType, TName extends NameType> = (entry: Payload<TValue, TName>) => unknown;
|
|
6
|
+
type UniqueOption<TValue extends ValueType, TName extends NameType> = boolean | UniqueFunc<TValue, TName>;
|
|
7
|
+
export type OptionalCoords = {
|
|
8
|
+
x?: number;
|
|
9
|
+
y?: number;
|
|
10
|
+
};
|
|
11
|
+
export type TooltipProps<TValue extends ValueType, TName extends NameType> = DefaultProps<TValue, TName> & {
|
|
12
|
+
allowEscapeViewBox?: {
|
|
13
|
+
x?: boolean;
|
|
14
|
+
y?: boolean;
|
|
15
|
+
};
|
|
16
|
+
reverseDirection?: {
|
|
17
|
+
x?: boolean;
|
|
18
|
+
y?: boolean;
|
|
19
|
+
};
|
|
20
|
+
content?: ContentType<TValue, TName>;
|
|
21
|
+
viewBox?: {
|
|
22
|
+
x?: number;
|
|
23
|
+
y?: number;
|
|
24
|
+
width?: number;
|
|
25
|
+
height?: number;
|
|
26
|
+
};
|
|
27
|
+
active?: boolean;
|
|
28
|
+
offset?: number;
|
|
29
|
+
wrapperStyle?: CSSProperties;
|
|
30
|
+
cursor?: boolean | ReactElement | SVGProps<SVGElement>;
|
|
31
|
+
coordinate?: OptionalCoords;
|
|
32
|
+
position?: OptionalCoords;
|
|
33
|
+
trigger?: 'hover' | 'click';
|
|
34
|
+
shared?: boolean;
|
|
35
|
+
payloadUniqBy?: UniqueOption<TValue, TName>;
|
|
36
|
+
isAnimationActive?: boolean;
|
|
37
|
+
animationDuration?: AnimationDuration;
|
|
38
|
+
animationEasing?: AnimationTiming;
|
|
39
|
+
filterNull?: boolean;
|
|
40
|
+
useTranslate3d?: boolean;
|
|
41
|
+
box?: OptionalCoords;
|
|
42
|
+
};
|
|
43
|
+
export declare const Tooltip: {
|
|
44
|
+
<TValue extends ValueType, TName extends NameType>(props: DefaultProps<TValue, TName> & {
|
|
45
|
+
allowEscapeViewBox?: {
|
|
46
|
+
x?: boolean | undefined;
|
|
47
|
+
y?: boolean | undefined;
|
|
48
|
+
} | undefined;
|
|
49
|
+
reverseDirection?: {
|
|
50
|
+
x?: boolean | undefined;
|
|
51
|
+
y?: boolean | undefined;
|
|
52
|
+
} | undefined;
|
|
53
|
+
content?: ContentType<TValue, TName> | undefined;
|
|
54
|
+
viewBox?: {
|
|
55
|
+
x?: number | undefined;
|
|
56
|
+
y?: number | undefined;
|
|
57
|
+
width?: number | undefined;
|
|
58
|
+
height?: number | undefined;
|
|
59
|
+
} | undefined;
|
|
60
|
+
active?: boolean | undefined;
|
|
61
|
+
offset?: number | undefined;
|
|
62
|
+
wrapperStyle?: React.CSSProperties | undefined;
|
|
63
|
+
cursor?: boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | React.SVGProps<SVGElement> | undefined;
|
|
64
|
+
coordinate?: OptionalCoords | undefined;
|
|
65
|
+
position?: OptionalCoords | undefined;
|
|
66
|
+
trigger?: "hover" | "click" | undefined;
|
|
67
|
+
shared?: boolean | undefined;
|
|
68
|
+
payloadUniqBy?: UniqueOption<TValue, TName> | undefined;
|
|
69
|
+
isAnimationActive?: boolean | undefined;
|
|
70
|
+
animationDuration?: number | undefined;
|
|
71
|
+
animationEasing?: AnimationTiming | undefined;
|
|
72
|
+
filterNull?: boolean | undefined;
|
|
73
|
+
useTranslate3d?: boolean | undefined;
|
|
74
|
+
box?: OptionalCoords | undefined;
|
|
75
|
+
} & {
|
|
76
|
+
children?: React.ReactNode;
|
|
77
|
+
}): React.JSX.Element;
|
|
78
|
+
displayName: string;
|
|
79
|
+
defaultProps: TooltipProps<number, string>;
|
|
80
|
+
};
|
|
81
|
+
export {};
|
|
82
|
+
//# sourceMappingURL=RechartTooltip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RechartTooltip.d.ts","sourceRoot":"","sources":["../../src/buckaroo_js/vendor/RechartTooltip.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,EACV,aAAa,EACb,SAAS,EACT,YAAY,EACZ,QAAQ,EAKX,MAAM,OAAO,CAAC;AAOf,OAAO,KAAK,EAAC,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAM/E,OAAO,EAAC,iBAAiB,EAAE,eAAe,EAAC,MAAM,gBAAgB,CAAC;AAQlE,MAAM,MAAM,WAAW,CAAC,MAAM,SAAS,SAAS,EAAE,KAAK,SAAS,QAAQ,IAClE,YAAY,GACZ,CAAC,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D,UAAU,CAAC,EAAE,cAAc,CAAC;IAC5B,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC;IAC5B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,aAAa,CAAC,EAAE,YAAY,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC5C,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IACtC,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,GAAG,CAAC,EAAE,cAAc,CAAC;CACxB,CAAC;AA4BF,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBACiC,eAAe;;;;CAqMnE,CAAC"}
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
+
}
|
|
19
|
+
Object.defineProperty(o, k2, desc);
|
|
20
|
+
}) : (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
o[k2] = m[k];
|
|
23
|
+
}));
|
|
24
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
+
}) : function(o, v) {
|
|
27
|
+
o["default"] = v;
|
|
28
|
+
});
|
|
29
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
30
|
+
if (mod && mod.__esModule) return mod;
|
|
31
|
+
var result = {};
|
|
32
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
33
|
+
__setModuleDefault(result, mod);
|
|
34
|
+
return result;
|
|
35
|
+
};
|
|
36
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
37
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
38
|
+
if (!m) return o;
|
|
39
|
+
var i = m.call(o), r, ar = [], e;
|
|
40
|
+
try {
|
|
41
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
42
|
+
}
|
|
43
|
+
catch (error) { e = { error: error }; }
|
|
44
|
+
finally {
|
|
45
|
+
try {
|
|
46
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
47
|
+
}
|
|
48
|
+
finally { if (e) throw e.error; }
|
|
49
|
+
}
|
|
50
|
+
return ar;
|
|
51
|
+
};
|
|
52
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
53
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
54
|
+
};
|
|
55
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
56
|
+
exports.Tooltip = void 0;
|
|
57
|
+
var react_1 = __importStar(require("react"));
|
|
58
|
+
var react_smooth_1 = require("react-smooth");
|
|
59
|
+
var lodash_1 = __importDefault(require("lodash"));
|
|
60
|
+
var RechartExtra_1 = require("./RechartExtra");
|
|
61
|
+
var recharts_1 = require("recharts");
|
|
62
|
+
var CLS_PREFIX = 'recharts-tooltip-wrapper';
|
|
63
|
+
var EPS = 1;
|
|
64
|
+
function defaultUniqBy(entry) {
|
|
65
|
+
return entry.dataKey;
|
|
66
|
+
}
|
|
67
|
+
function getUniqPayload(option, payload) {
|
|
68
|
+
if (option === true) {
|
|
69
|
+
return lodash_1.default.uniqBy(payload, defaultUniqBy);
|
|
70
|
+
}
|
|
71
|
+
if (lodash_1.default.isFunction(option)) {
|
|
72
|
+
return lodash_1.default.uniqBy(payload, option);
|
|
73
|
+
}
|
|
74
|
+
return payload;
|
|
75
|
+
}
|
|
76
|
+
function renderContent(content, props) {
|
|
77
|
+
if (react_1.default.isValidElement(content)) {
|
|
78
|
+
return react_1.default.cloneElement(content, props);
|
|
79
|
+
}
|
|
80
|
+
if (lodash_1.default.isFunction(content)) {
|
|
81
|
+
return react_1.default.createElement(content, props);
|
|
82
|
+
}
|
|
83
|
+
return react_1.default.createElement(recharts_1.DefaultTooltipContent, __assign({}, props));
|
|
84
|
+
}
|
|
85
|
+
var tooltipDefaultProps = {
|
|
86
|
+
active: false,
|
|
87
|
+
allowEscapeViewBox: { x: false, y: false },
|
|
88
|
+
reverseDirection: { x: false, y: false },
|
|
89
|
+
offset: 10,
|
|
90
|
+
viewBox: { x: 0, y: 0, height: 0, width: 0 },
|
|
91
|
+
coordinate: { x: 0, y: 0 },
|
|
92
|
+
cursorStyle: {},
|
|
93
|
+
separator: ' : ',
|
|
94
|
+
wrapperStyle: {},
|
|
95
|
+
contentStyle: {},
|
|
96
|
+
itemStyle: {},
|
|
97
|
+
labelStyle: {},
|
|
98
|
+
cursor: true,
|
|
99
|
+
trigger: 'hover',
|
|
100
|
+
isAnimationActive: !RechartExtra_1.Global.isSsr,
|
|
101
|
+
animationEasing: 'ease',
|
|
102
|
+
animationDuration: 400,
|
|
103
|
+
filterNull: true,
|
|
104
|
+
useTranslate3d: false,
|
|
105
|
+
box: { x: 0, y: 0 }
|
|
106
|
+
};
|
|
107
|
+
var Tooltip = function (props) {
|
|
108
|
+
var _a = __read((0, react_1.useState)(-1), 2), boxWidth = _a[0], setBoxWidth = _a[1];
|
|
109
|
+
var _b = __read((0, react_1.useState)(-1), 2), boxHeight = _b[0], setBoxHeight = _b[1];
|
|
110
|
+
var _c = __read((0, react_1.useState)(false), 2), dismissed = _c[0], setDismissed = _c[1];
|
|
111
|
+
var _d = __read((0, react_1.useState)({
|
|
112
|
+
x: 0,
|
|
113
|
+
y: 0
|
|
114
|
+
}), 2), dismissedAtCoordinate = _d[0], setDismissedAtCoordinate = _d[1];
|
|
115
|
+
var _e = __read((0, react_1.useState)({ x: 0, y: 0 }), 2), boxCoords = _e[0], setBoxCoords = _e[1];
|
|
116
|
+
var wrapperNode = (0, react_1.useRef)();
|
|
117
|
+
var allowEscapeViewBox = props.allowEscapeViewBox, reverseDirection = props.reverseDirection, coordinate = props.coordinate, offset = props.offset, position = props.position, viewBox = props.viewBox;
|
|
118
|
+
var handleKeyDown = (0, react_1.useCallback)(function (event) {
|
|
119
|
+
if (event.key === 'Escape') {
|
|
120
|
+
setDismissed(true);
|
|
121
|
+
setDismissedAtCoordinate(function (prev) { return (__assign(__assign({}, prev), { x: coordinate === null || coordinate === void 0 ? void 0 : coordinate.x, y: coordinate === null || coordinate === void 0 ? void 0 : coordinate.y })); });
|
|
122
|
+
}
|
|
123
|
+
}, [coordinate === null || coordinate === void 0 ? void 0 : coordinate.x, coordinate === null || coordinate === void 0 ? void 0 : coordinate.y]);
|
|
124
|
+
(0, react_1.useEffect)(function () {
|
|
125
|
+
var updateBBox = function () {
|
|
126
|
+
if (dismissed) {
|
|
127
|
+
document.removeEventListener('keydown', handleKeyDown);
|
|
128
|
+
if ((coordinate === null || coordinate === void 0 ? void 0 : coordinate.x) !== dismissedAtCoordinate.x ||
|
|
129
|
+
(coordinate === null || coordinate === void 0 ? void 0 : coordinate.y) !== dismissedAtCoordinate.y) {
|
|
130
|
+
setDismissed(false);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
document.addEventListener('keydown', handleKeyDown);
|
|
135
|
+
}
|
|
136
|
+
if (wrapperNode.current && wrapperNode.current.getBoundingClientRect) {
|
|
137
|
+
var box = wrapperNode.current.getBoundingClientRect();
|
|
138
|
+
setBoxCoords({ x: box.x, y: box.y });
|
|
139
|
+
if (Math.abs(box.width - boxWidth) > EPS ||
|
|
140
|
+
Math.abs(box.height - boxHeight) > EPS) {
|
|
141
|
+
setBoxWidth(box.width);
|
|
142
|
+
setBoxHeight(box.height);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
else if (boxWidth !== -1 || boxHeight !== -1) {
|
|
146
|
+
setBoxWidth(-1);
|
|
147
|
+
setBoxHeight(-1);
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
updateBBox();
|
|
151
|
+
return function () {
|
|
152
|
+
document.removeEventListener('keydown', handleKeyDown);
|
|
153
|
+
};
|
|
154
|
+
}, [
|
|
155
|
+
boxHeight,
|
|
156
|
+
boxWidth,
|
|
157
|
+
coordinate,
|
|
158
|
+
dismissed,
|
|
159
|
+
dismissedAtCoordinate.x,
|
|
160
|
+
dismissedAtCoordinate.y,
|
|
161
|
+
handleKeyDown
|
|
162
|
+
]);
|
|
163
|
+
var getTranslate = function (_a) {
|
|
164
|
+
var key = _a.key, tooltipDimension = _a.tooltipDimension, viewBoxDimension = _a.viewBoxDimension;
|
|
165
|
+
if (position && (0, RechartExtra_1.isNumber)(position[key])) {
|
|
166
|
+
return position[key];
|
|
167
|
+
}
|
|
168
|
+
var pCoordinate = coordinate || { x: 0, y: 0 };
|
|
169
|
+
var negative = (pCoordinate[key] || 0) - tooltipDimension - (offset || 0);
|
|
170
|
+
var positive = (pCoordinate[key] || 0) + offset;
|
|
171
|
+
if (allowEscapeViewBox === null || allowEscapeViewBox === void 0 ? void 0 : allowEscapeViewBox[key]) {
|
|
172
|
+
return reverseDirection[key] ? negative : positive;
|
|
173
|
+
}
|
|
174
|
+
if (reverseDirection === null || reverseDirection === void 0 ? void 0 : reverseDirection[key]) {
|
|
175
|
+
var tooltipBoundary_1 = negative;
|
|
176
|
+
var viewBoxBoundary_1 = viewBox[key];
|
|
177
|
+
if (tooltipBoundary_1 < viewBoxBoundary_1) {
|
|
178
|
+
return Math.max(positive, viewBox[key]);
|
|
179
|
+
}
|
|
180
|
+
return Math.max(negative, viewBox[key]);
|
|
181
|
+
}
|
|
182
|
+
var tooltipBoundary = positive + tooltipDimension;
|
|
183
|
+
var viewBoxBoundary = viewBox[key] + viewBoxDimension;
|
|
184
|
+
if (tooltipBoundary > viewBoxBoundary) {
|
|
185
|
+
return Math.max(negative, viewBox[key]);
|
|
186
|
+
}
|
|
187
|
+
return Math.max(positive, viewBox[key]);
|
|
188
|
+
};
|
|
189
|
+
var payload = props.payload, payloadUniqBy = props.payloadUniqBy, filterNull = props.filterNull, active = props.active, wrapperStyle = props.wrapperStyle, useTranslate3d = props.useTranslate3d, isAnimationActive = props.isAnimationActive, animationDuration = props.animationDuration, animationEasing = props.animationEasing;
|
|
190
|
+
var finalPayload = getUniqPayload(payloadUniqBy, filterNull && payload && payload.length
|
|
191
|
+
? payload.filter(function (entry) { return !lodash_1.default.isNil(entry.value); })
|
|
192
|
+
: payload);
|
|
193
|
+
var hasPayload = finalPayload && finalPayload.length;
|
|
194
|
+
var content = props.content;
|
|
195
|
+
var outerStyle = __assign({ pointerEvents: 'none', visibility: !dismissed && active && hasPayload ? 'visible' : 'hidden', position: 'absolute', top: 0, left: 0 }, wrapperStyle);
|
|
196
|
+
var translateX, translateY;
|
|
197
|
+
if (position && (0, RechartExtra_1.isNumber)(position.x) && (0, RechartExtra_1.isNumber)(position.y)) {
|
|
198
|
+
translateX = position.x;
|
|
199
|
+
translateY = position.y;
|
|
200
|
+
}
|
|
201
|
+
else if (boxWidth > 0 && boxHeight > 0 && coordinate) {
|
|
202
|
+
translateX = getTranslate({
|
|
203
|
+
key: 'x',
|
|
204
|
+
tooltipDimension: boxWidth,
|
|
205
|
+
viewBoxDimension: viewBox.width
|
|
206
|
+
});
|
|
207
|
+
translateY = getTranslate({
|
|
208
|
+
key: 'y',
|
|
209
|
+
tooltipDimension: boxHeight,
|
|
210
|
+
viewBoxDimension: viewBox.height
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
else {
|
|
214
|
+
outerStyle.visibility = 'hidden';
|
|
215
|
+
}
|
|
216
|
+
outerStyle = __assign(__assign({}, (0, react_smooth_1.translateStyle)({
|
|
217
|
+
transform: useTranslate3d
|
|
218
|
+
? "translate3d(".concat(translateX, "px, ").concat(translateY, "px, 0)")
|
|
219
|
+
: "translate(".concat(translateX, "px, ").concat(translateY, "px)")
|
|
220
|
+
})), outerStyle);
|
|
221
|
+
if (isAnimationActive && active) {
|
|
222
|
+
outerStyle = __assign(__assign({}, (0, react_smooth_1.translateStyle)({
|
|
223
|
+
transition: "transform ".concat(animationDuration, "ms ").concat(animationEasing)
|
|
224
|
+
})), outerStyle);
|
|
225
|
+
}
|
|
226
|
+
var cls = "".concat(CLS_PREFIX, "-top");
|
|
227
|
+
return (react_1.default.createElement("div", { tabIndex: -1, role: 'dialog', className: cls, style: outerStyle, ref: wrapperNode }, renderContent(content, __assign(__assign({}, props), { box: boxCoords, payload: finalPayload }))));
|
|
228
|
+
};
|
|
229
|
+
exports.Tooltip = Tooltip;
|
|
230
|
+
exports.Tooltip.displayName = 'Tooltip';
|
|
231
|
+
exports.Tooltip.defaultProps = tooltipDefaultProps;
|
|
232
|
+
//# sourceMappingURL=RechartTooltip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RechartTooltip.js","sourceRoot":"","sources":["../../src/buckaroo_js/vendor/RechartTooltip.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,6CASe;AACf,6CAA4C;AAC5C,kDAAuB;AAQvB,+CAAgD;AAKhD,qCAA+C;AA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AY,CAAC;YACtB,GAAG,EAAE,GAAG;YACR,gBAAgB,EAAE,SAAS;YAC3B,gBAAgB,EAAE,OAAO,CAAC,MAAM;SACnC,CAAC,CAAC;KACN;SAAM;QACH,UAAU,CAAC,UAAU,GAAG,QAAQ,CAAC;KACpC;IAED,UAAU,yBACH,IAAA,6BAAc,EAAC;QACd,SAAS,EAAE,cAAc;YACrB,CAAC,CAAC,sBAAe,UAAU,iBAAO,UAAU,WAAQ;YACpD,CAAC,CAAC,oBAAa,UAAU,iBAAO,UAAU,QAAK;KACtD,CAAC,GACC,UAAU,CAChB,CAAC;IAEF,IAAI,iBAAiB,IAAI,MAAM,EAAE;QAC7B,UAAU,yBACH,IAAA,6BAAc,EAAC;YACd,UAAU,EAAE,oBAAa,iBAAiB,gBAAM,eAAe,CAAE;SACpE,CAAC,GACC,UAAU,CAChB,CAAC;KACL;IAWD,IAAM,GAAG,GAAG,UAAG,UAAU,SAAM,CAAC;IAChC,OAAO,CAIH,uCAAK,QAAQ,EAAE,CAAC,CAAC,EAAE,IAAI,EAAC,QAAQ,EAAC,SAAS,EAAE,GAAG,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,EAAE,WAAW,IAC/E,aAAa,CAAC,OAAO,wBACf,KAAK,KACR,GAAG,EAAE,SAAS,EACd,OAAO,EAAE,YAAY,IACvB,CACA,CACT,CAAC;AACN,CAAC,CAAC;AAtMW,QAAA,OAAO,WAsMlB;AAGF,eAAO,CAAC,WAAW,GAAG,SAAS,CAAC;AAOhC,eAAO,CAAC,YAAY,GAAG,mBAAmB,CAAC"}
|
package/codecov.yml
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import typescriptEslint from "@typescript-eslint/eslint-plugin";
|
|
2
|
+
import react from "eslint-plugin-react";
|
|
3
|
+
import reactHooks from "eslint-plugin-react-hooks";
|
|
4
|
+
import _import from "eslint-plugin-import";
|
|
5
|
+
import prettier from "eslint-plugin-prettier";
|
|
6
|
+
import { fixupPluginRules } from "@eslint/compat";
|
|
7
|
+
import globals from "globals";
|
|
8
|
+
import tsParser from "@typescript-eslint/parser";
|
|
9
|
+
import path from "node:path";
|
|
10
|
+
import { fileURLToPath } from "node:url";
|
|
11
|
+
import js from "@eslint/js";
|
|
12
|
+
import { FlatCompat } from "@eslint/eslintrc";
|
|
13
|
+
|
|
14
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
15
|
+
const __dirname = path.dirname(__filename);
|
|
16
|
+
const compat = new FlatCompat({
|
|
17
|
+
baseDirectory: __dirname,
|
|
18
|
+
recommendedConfig: js.configs.recommended,
|
|
19
|
+
allConfig: js.configs.all
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
export default [{
|
|
23
|
+
ignores: ["**/webpack.config.ts", "**/jest.config.js"],
|
|
24
|
+
}, ...compat.extends(
|
|
25
|
+
"plugin:@typescript-eslint/recommended",
|
|
26
|
+
"plugin:react/recommended",
|
|
27
|
+
"plugin:prettier/recommended",
|
|
28
|
+
), {
|
|
29
|
+
plugins: {
|
|
30
|
+
"@typescript-eslint": typescriptEslint,
|
|
31
|
+
react,
|
|
32
|
+
"react-hooks": fixupPluginRules(reactHooks),
|
|
33
|
+
import: fixupPluginRules(_import),
|
|
34
|
+
prettier,
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
languageOptions: {
|
|
38
|
+
globals: {
|
|
39
|
+
...globals.browser,
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
parser: tsParser,
|
|
43
|
+
ecmaVersion: 2020,
|
|
44
|
+
sourceType: "module",
|
|
45
|
+
|
|
46
|
+
parserOptions: {
|
|
47
|
+
project: ["tsconfig.json", "examples/tsconfig.json", "test/tsconfig.json"],
|
|
48
|
+
|
|
49
|
+
ecmaFeatures: {
|
|
50
|
+
jsx: true,
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
settings: {
|
|
56
|
+
react: {
|
|
57
|
+
version: "detect",
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
|
|
61
|
+
rules: {
|
|
62
|
+
"@typescript-eslint/explicit-function-return-type": "off",
|
|
63
|
+
"@typescript-eslint/no-unused-vars": "off",
|
|
64
|
+
"@typescript-eslint/no-non-null-assertion": "off",
|
|
65
|
+
"@typescript-eslint/no-non-null-asserted-optional-chain": "off",
|
|
66
|
+
|
|
67
|
+
"react/jsx-filename-extension": ["warn", {
|
|
68
|
+
extensions: [".jsx", ".tsx"],
|
|
69
|
+
}],
|
|
70
|
+
|
|
71
|
+
"react/prop-types": "off",
|
|
72
|
+
"react-hooks/rules-of-hooks": "error",
|
|
73
|
+
"react-hooks/exhaustive-deps": "warn",
|
|
74
|
+
"no-console": "warn",
|
|
75
|
+
|
|
76
|
+
quotes: [2, "single", {
|
|
77
|
+
avoidEscape: true,
|
|
78
|
+
}],
|
|
79
|
+
|
|
80
|
+
"react/jsx-key": "off",
|
|
81
|
+
},
|
|
82
|
+
}, {
|
|
83
|
+
files: ["examples/ex/*.tsx"],
|
|
84
|
+
|
|
85
|
+
rules: {
|
|
86
|
+
"no-console": "off",
|
|
87
|
+
},
|
|
88
|
+
}];
|
package/examples/App.tsx
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import 'bootstrap/dist/css/bootstrap.min.css';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import {HashRouter as Router, Route, Link} from 'react-router-dom';
|
|
4
|
+
import {Button} from 'react-bootstrap';
|
|
5
|
+
|
|
6
|
+
import './app.css';
|
|
7
|
+
|
|
8
|
+
const examples = {
|
|
9
|
+
|
|
10
|
+
WidgetDCFCellEx: {
|
|
11
|
+
title: 'WigetDCFCell',
|
|
12
|
+
file: 'WidgetDCFCellEx',
|
|
13
|
+
layout: 'HBox',
|
|
14
|
+
},
|
|
15
|
+
ColumnsEditorEx: {
|
|
16
|
+
title: 'ColumnsEditor',
|
|
17
|
+
file: 'ColumnsEditorEx',
|
|
18
|
+
layout: 'HBox',
|
|
19
|
+
},
|
|
20
|
+
CommandViewerEx: {
|
|
21
|
+
title: 'CommandViewer',
|
|
22
|
+
file: 'CommandViewerEx',
|
|
23
|
+
layout: 'HBox',
|
|
24
|
+
},
|
|
25
|
+
DFViewerEx: { title: 'DFViewer', file: 'DFViewerEx', layout: 'HBox' },
|
|
26
|
+
DFViewerEx_string_index: {
|
|
27
|
+
title: 'DFViewer string index',
|
|
28
|
+
file: 'DFViewerEx_string_index',
|
|
29
|
+
layout: 'HBox',
|
|
30
|
+
},
|
|
31
|
+
DFViewerEx_large: {
|
|
32
|
+
title: 'DFViewer large',
|
|
33
|
+
file: 'DFViewerEx_large',
|
|
34
|
+
layout: 'HBox',
|
|
35
|
+
},
|
|
36
|
+
DFViewerEx_real_summary: {
|
|
37
|
+
title: 'DFViewer summary',
|
|
38
|
+
file: 'DFViewerEx_real_summary',
|
|
39
|
+
layout: 'HBox',
|
|
40
|
+
},
|
|
41
|
+
DFViewerEx_short_data: {
|
|
42
|
+
title: 'DFViewer short_data',
|
|
43
|
+
file: 'DFViewerEx_short_data',
|
|
44
|
+
layout: 'HBox',
|
|
45
|
+
},
|
|
46
|
+
|
|
47
|
+
StatusBarEx: { title: 'StatusBar', file: 'StatusBarEx', layout: 'VBox' },
|
|
48
|
+
HistogramEx: { title: 'Histogram', file: 'HistogramEx', layout: 'HBox' },
|
|
49
|
+
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
// The examples use a code-loading technique that I have described in
|
|
53
|
+
// https://mmomtchev.medium.com/making-examples-displaying-code-along-its-output-with-webpack-a28dcf5439c6
|
|
54
|
+
|
|
55
|
+
const ReadmeBlock = React.lazy(() => import(/* webpackPrefetch: true */ './ReadmeBlock'));
|
|
56
|
+
const CodeBlock = React.lazy(() => import(/* webpackPrefetch: true */ './CodeBlock'));
|
|
57
|
+
|
|
58
|
+
for (const ex of Object.keys(examples)) {
|
|
59
|
+
examples[ex].comp = React.lazy(
|
|
60
|
+
() => import(/* webpackPrefetch: true */ `./ex/${examples[ex].file}.tsx`)
|
|
61
|
+
);
|
|
62
|
+
examples[ex].code = import(
|
|
63
|
+
/* webpackPrefetch: true */ `!!html-loader?{"minimize":false}!./jsx-loader.ts!./ex/${examples[ex].file}.tsx`
|
|
64
|
+
).then((code) => code.default);
|
|
65
|
+
examples[ex].text = import(
|
|
66
|
+
/* webpackPrefetch: true */ `!!raw-loader!./ex/${examples[ex].file}.tsx`
|
|
67
|
+
).then((text) => text.default);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const LeftMenuItem = (props): JSX.Element => (
|
|
71
|
+
<Link to={props.id}>
|
|
72
|
+
<Button className='w-100' variant='light'>
|
|
73
|
+
{props.title}
|
|
74
|
+
</Button>
|
|
75
|
+
</Link>
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
// eslint-disable-next-line no-var
|
|
79
|
+
declare var VERSION: string;
|
|
80
|
+
|
|
81
|
+
// eslint-disable-next-line no-var
|
|
82
|
+
//declare var VERSION: string = "handwritten";
|
|
83
|
+
|
|
84
|
+
const RenderEl = (ex: any): JSX.Element => {
|
|
85
|
+
if (ex.layout === 'HBox') {
|
|
86
|
+
return (
|
|
87
|
+
<div className="row">
|
|
88
|
+
<div className="col-12 col-xl-5 mb-1">
|
|
89
|
+
<React.Suspense fallback={<div>Loading component...</div>}>
|
|
90
|
+
<div className="component-example">
|
|
91
|
+
<h2> Component example </h2>
|
|
92
|
+
{React.createElement(ex.comp)}
|
|
93
|
+
</div>
|
|
94
|
+
</React.Suspense>
|
|
95
|
+
</div>
|
|
96
|
+
<div className="col-12 col-xl-7">
|
|
97
|
+
<React.Suspense fallback={<div>Parsing code...</div>}>
|
|
98
|
+
<CodeBlock title={ex.title} code={ex.code} text={ex.text} />
|
|
99
|
+
</React.Suspense>
|
|
100
|
+
</div>
|
|
101
|
+
</div>
|
|
102
|
+
);
|
|
103
|
+
} else {
|
|
104
|
+
return (
|
|
105
|
+
<div className="row">
|
|
106
|
+
<div className="row">
|
|
107
|
+
<React.Suspense fallback={<div>Loading component...</div>}>
|
|
108
|
+
<div className="component-example">
|
|
109
|
+
<h2> Component example </h2>
|
|
110
|
+
{React.createElement(ex.comp)}
|
|
111
|
+
</div>
|
|
112
|
+
</React.Suspense>
|
|
113
|
+
</div>
|
|
114
|
+
<div className="row">
|
|
115
|
+
<React.Suspense fallback={<div>Parsing code...</div>}>
|
|
116
|
+
<CodeBlock title={ex.title} code={ex.code} text={ex.text} />
|
|
117
|
+
</React.Suspense>
|
|
118
|
+
</div>
|
|
119
|
+
</div>
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
const App = (): JSX.Element => {
|
|
125
|
+
const [jsText, setJSText] = React.useState<string>('');
|
|
126
|
+
|
|
127
|
+
return (
|
|
128
|
+
<Router>
|
|
129
|
+
<h1 className='m-2'>
|
|
130
|
+
<strong>react-edit-list {VERSION} Examples</strong>
|
|
131
|
+
</h1>
|
|
132
|
+
<div className='d-flex flex-row p-3'>
|
|
133
|
+
<div className='d-flex flex-column left-menu me-2'>
|
|
134
|
+
<LeftMenuItem id={''} title={'Home'} />
|
|
135
|
+
{Object.keys(examples).map((e) => (
|
|
136
|
+
<LeftMenuItem key={e} id={e} title={examples[e].title} />
|
|
137
|
+
))}
|
|
138
|
+
</div>
|
|
139
|
+
<div className='d-flex flex-column w-100 overflow-hidden'>
|
|
140
|
+
<div className='fluid-container'>
|
|
141
|
+
<Route exact path='/'>
|
|
142
|
+
<div className='ml-2'>
|
|
143
|
+
<React.Suspense fallback={<div>Loading...</div>}>
|
|
144
|
+
<ReadmeBlock />
|
|
145
|
+
</React.Suspense>
|
|
146
|
+
</div>
|
|
147
|
+
</Route>
|
|
148
|
+
{Object.keys(examples).map((e) => (
|
|
149
|
+
<Route key={e} path={`/${e}`}>
|
|
150
|
+
{RenderEl(examples[e])}
|
|
151
|
+
</Route>
|
|
152
|
+
))}
|
|
153
|
+
</div>
|
|
154
|
+
</div>
|
|
155
|
+
</div>
|
|
156
|
+
</Router>
|
|
157
|
+
);
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
export default App;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import CodePenButton from './CodePenButton';
|
|
3
|
+
import 'prism-themes/themes/prism-vsc-dark-plus.css';
|
|
4
|
+
|
|
5
|
+
// This is expensive to render
|
|
6
|
+
const CodeBlock = React.memo(function CodeBlockRaw(props: {
|
|
7
|
+
title: string;
|
|
8
|
+
code: Promise<string>;
|
|
9
|
+
text: Promise<string>;
|
|
10
|
+
}) {
|
|
11
|
+
const [code, setCode] = React.useState('loading()');
|
|
12
|
+
React.useEffect(() => {
|
|
13
|
+
props.code.then((r) => setCode(r));
|
|
14
|
+
}, [props.code, props.text]);
|
|
15
|
+
return (
|
|
16
|
+
<div className='position-relative'>
|
|
17
|
+
<CodePenButton title={props.title} text={props.text} />
|
|
18
|
+
<div className='codeblock'>
|
|
19
|
+
<pre className='p-2' style={{backgroundColor: 'rgb(43, 43, 43)', fontSize: '16px'}}>
|
|
20
|
+
<code className='language-tsx' dangerouslySetInnerHTML={{__html: code}} />
|
|
21
|
+
</pre>
|
|
22
|
+
</div>
|
|
23
|
+
</div>
|
|
24
|
+
);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
export default CodeBlock;
|