@pie-lib/plot 2.28.0-mui-update.0 → 2.29.0-mui-update.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/CHANGELOG.md +8 -0
- package/lib/label.js +50 -54
- package/lib/label.js.map +1 -1
- package/package.json +4 -4
- package/src/label.jsx +86 -48
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [2.29.0-mui-update.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@2.28.0-mui-update.0...@pie-lib/plot@2.29.0-mui-update.0) (2025-11-17)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @pie-lib/plot
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
# [2.28.0-mui-update.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@2.27.0-mui-update.0...@pie-lib/plot@2.28.0-mui-update.0) (2025-11-05)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @pie-lib/plot
|
package/lib/label.js
CHANGED
|
@@ -6,56 +6,58 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports["default"] = void 0;
|
|
9
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
11
|
var _react = _interopRequireWildcard(require("react"));
|
|
12
12
|
var _renderUi = require("@pie-lib/render-ui");
|
|
13
13
|
var _editableHtml = _interopRequireDefault(require("@pie-lib/editable-html"));
|
|
14
|
-
var _styles = require("@mui/material/styles");
|
|
15
14
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
15
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
16
16
|
var _utils = require("./utils");
|
|
17
17
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
18
18
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
19
19
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
20
|
-
var
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
})(function (_ref) {
|
|
25
|
-
var theme = _ref.theme,
|
|
26
|
-
side = _ref.side,
|
|
27
|
-
rotatedToHorizontal = _ref.rotatedToHorizontal,
|
|
28
|
-
isChart = _ref.isChart,
|
|
29
|
-
isChartBottomLabel = _ref.isChartBottomLabel,
|
|
30
|
-
isDefineChartBottomLabel = _ref.isDefineChartBottomLabel,
|
|
31
|
-
disabledLabel = _ref.disabledLabel,
|
|
32
|
-
isEmpty = _ref.isEmpty;
|
|
33
|
-
return _objectSpread(_objectSpread(_objectSpread({
|
|
34
|
-
fontSize: isChart ? theme.typography.fontSize + 2 : theme.typography.fontSize - 2,
|
|
20
|
+
var styles = {
|
|
21
|
+
axisLabel: {
|
|
22
|
+
fontSize: 12,
|
|
35
23
|
textAlign: 'center',
|
|
36
|
-
margin:
|
|
37
|
-
padding:
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
24
|
+
margin: 4,
|
|
25
|
+
padding: '4px 0'
|
|
26
|
+
},
|
|
27
|
+
chartLabel: {
|
|
28
|
+
fontSize: 16,
|
|
29
|
+
textAlign: 'center',
|
|
30
|
+
margin: 4,
|
|
31
|
+
padding: '4px 0'
|
|
32
|
+
},
|
|
33
|
+
disabledLabel: {
|
|
34
|
+
pointerEvents: 'none',
|
|
35
|
+
width: '100%'
|
|
36
|
+
},
|
|
37
|
+
editLabel: {
|
|
38
|
+
position: 'absolute',
|
|
49
39
|
backgroundColor: 'white',
|
|
50
|
-
borderRadius:
|
|
51
|
-
boxShadow: '0px 5px 8px rgba(0,
|
|
40
|
+
borderRadius: 4,
|
|
41
|
+
boxShadow: '0px 5px 8px rgba(0,0,0,0.15)',
|
|
52
42
|
zIndex: 10
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
43
|
+
},
|
|
44
|
+
rotateLeftLabel: {
|
|
45
|
+
transform: 'rotate(-90deg)',
|
|
46
|
+
transformOrigin: '0 0',
|
|
47
|
+
position: 'absolute'
|
|
48
|
+
},
|
|
49
|
+
rotateRightLabel: {
|
|
50
|
+
transform: 'rotate(90deg)',
|
|
51
|
+
transformOrigin: '0 0',
|
|
52
|
+
position: 'absolute'
|
|
53
|
+
},
|
|
54
|
+
customBottom: {
|
|
55
|
+
position: 'absolute'
|
|
56
|
+
},
|
|
57
|
+
displayNone: {
|
|
58
|
+
display: 'none'
|
|
59
|
+
}
|
|
60
|
+
};
|
|
59
61
|
var LabelComponent = function LabelComponent(props) {
|
|
60
62
|
var disabledLabel = props.disabledLabel,
|
|
61
63
|
graphHeight = props.graphHeight,
|
|
@@ -76,9 +78,7 @@ var LabelComponent = function LabelComponent(props) {
|
|
|
76
78
|
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
77
79
|
rotatedToHorizontal = _useState2[0],
|
|
78
80
|
setRotatedToHorizontal = _useState2[1];
|
|
79
|
-
var activePlugins = ['bold', 'italic', 'underline', 'strikethrough', 'math'
|
|
80
|
-
// 'languageCharacters'
|
|
81
|
-
];
|
|
81
|
+
var activePlugins = ['bold', 'italic', 'underline', 'strikethrough', 'math'];
|
|
82
82
|
var isChart = isChartBottomLabel || isChartLeftLabel || isDefineChartBottomLabel || isDefineChartLeftLabel;
|
|
83
83
|
var chartValue = side === 'left' && isDefineChartLeftLabel && graphHeight - 220;
|
|
84
84
|
var defaultStyle = {
|
|
@@ -88,25 +88,21 @@ var LabelComponent = function LabelComponent(props) {
|
|
|
88
88
|
};
|
|
89
89
|
var rotatedStyle = {
|
|
90
90
|
width: graphWidth - 8,
|
|
91
|
-
top: side === 'right'
|
|
91
|
+
top: side === 'right' ? "".concat(graphHeight - 22, "px") : 0,
|
|
92
92
|
left: 0
|
|
93
93
|
};
|
|
94
94
|
var rotateLabel = function rotateLabel() {
|
|
95
|
-
|
|
95
|
+
if (!disabledLabel && (side === 'left' || side === 'right')) {
|
|
96
|
+
setRotatedToHorizontal(true);
|
|
97
|
+
}
|
|
96
98
|
};
|
|
97
99
|
return /*#__PURE__*/_react["default"].createElement(_renderUi.Readable, {
|
|
98
100
|
"false": true
|
|
99
|
-
}, /*#__PURE__*/_react["default"].createElement(
|
|
100
|
-
|
|
101
|
-
rotatedToHorizontal: rotatedToHorizontal,
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
isDefineChartBottomLabel: isDefineChartBottomLabel,
|
|
105
|
-
disabledLabel: disabledLabel,
|
|
106
|
-
isEmpty: (0, _utils.isEmptyString)((0, _utils.extractTextFromHTML)(text)),
|
|
107
|
-
style: rotatedToHorizontal ? rotatedStyle : defaultStyle,
|
|
108
|
-
onClick: rotateLabel
|
|
109
|
-
}, disabledLabel ? /*#__PURE__*/_react["default"].createElement(DisabledLabel, {
|
|
101
|
+
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
102
|
+
onClick: rotateLabel,
|
|
103
|
+
style: _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, rotatedToHorizontal ? rotatedStyle : defaultStyle), isChart ? styles.chartLabel : styles.axisLabel), side === 'left' && !rotatedToHorizontal ? styles.rotateLeftLabel : {}), side === 'right' && !rotatedToHorizontal ? styles.rotateRightLabel : {}), rotatedToHorizontal ? styles.editLabel : {}), isChartBottomLabel || isDefineChartBottomLabel ? styles.customBottom : {}), disabledLabel && !isChart && (0, _utils.isEmptyString)((0, _utils.extractTextFromHTML)(text)) && styles.displayNone)
|
|
104
|
+
}, disabledLabel ? /*#__PURE__*/_react["default"].createElement("div", {
|
|
105
|
+
style: styles.disabledLabel,
|
|
110
106
|
dangerouslySetInnerHTML: {
|
|
111
107
|
__html: text || ''
|
|
112
108
|
}
|
package/lib/label.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"label.js","names":["_react","_interopRequireWildcard","require","_renderUi","_editableHtml","_interopRequireDefault","_styles","_propTypes","_utils","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","_typeof","has","get","set","_t","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","ownKeys","keys","getOwnPropertySymbols","filter","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty2","getOwnPropertyDescriptors","defineProperties","StyledLabel","styled","shouldForwardProp","prop","includes","_ref","theme","side","rotatedToHorizontal","isChart","isChartBottomLabel","isDefineChartBottomLabel","disabledLabel","isEmpty","fontSize","typography","textAlign","margin","spacing","padding","concat","display","position","WebkitTransform","transformOrigin","transformStyle","backgroundColor","borderRadius","boxShadow","zIndex","DisabledLabel","pointerEvents","width","LabelComponent","props","graphHeight","graphWidth","isChartLeftLabel","isDefineChartLeftLabel","placeholder","text","onChange","_props$mathMlOptions","mathMlOptions","charactersLimit","titleHeight","_useState","useState","_useState2","_slicedToArray2","setRotatedToHorizontal","activePlugins","chartValue","defaultStyle","top","left","rotatedStyle","rotateLabel","createElement","Readable","isEmptyString","extractTextFromHTML","style","onClick","dangerouslySetInnerHTML","__html","markup","toolbarOpts","noPadding","noBorder","disableScrollbar","onDone","propTypes","PropTypes","bool","number","string","func","object","_default","exports"],"sources":["../src/label.jsx"],"sourcesContent":["import React, { useState } from 'react';\nimport { Readable } from '@pie-lib/render-ui';\nimport EditableHtml from '@pie-lib/editable-html';\nimport { styled } from '@mui/material/styles';\nimport PropTypes from 'prop-types';\nimport { extractTextFromHTML, isEmptyString } from './utils';\n\nconst StyledLabel = styled('div', {\n shouldForwardProp: (prop) => !['side', 'rotatedToHorizontal', 'isChart', 'isChartBottomLabel', 'isDefineChartBottomLabel', 'disabledLabel', 'isEmpty'].includes(prop),\n})(({ theme, side, rotatedToHorizontal, isChart, isChartBottomLabel, isDefineChartBottomLabel, disabledLabel, isEmpty }) => ({\n fontSize: isChart ? theme.typography.fontSize + 2 : theme.typography.fontSize - 2,\n textAlign: 'center',\n margin: theme.spacing(0.5),\n padding: `${theme.spacing(0.5)} 0`,\n display: disabledLabel && !isChart && isEmpty ? 'none' : 'block',\n position: (isChartBottomLabel || isDefineChartBottomLabel || side === 'left' || side === 'right') ? 'absolute' : 'relative',\n ...(side === 'left' && !rotatedToHorizontal && {\n WebkitTransform: 'rotate(-90deg)',\n transformOrigin: '0 0',\n transformStyle: 'preserve-3d',\n }),\n ...(side === 'right' && !rotatedToHorizontal && {\n WebkitTransform: 'rotate(90deg)',\n transformOrigin: '0 0',\n transformStyle: 'preserve-3d',\n }),\n ...(rotatedToHorizontal && {\n backgroundColor: 'white',\n borderRadius: '4px',\n boxShadow: '0px 5px 8px rgba(0, 0, 0, 0.15)',\n zIndex: 10,\n }),\n}));\n\nconst DisabledLabel = styled('div')({\n pointerEvents: 'none',\n width: '100%',\n});\n\nconst LabelComponent = (props) => {\n const {\n disabledLabel,\n graphHeight,\n graphWidth,\n isChartBottomLabel,\n isDefineChartBottomLabel,\n isChartLeftLabel,\n isDefineChartLeftLabel,\n placeholder,\n text,\n side,\n onChange,\n mathMlOptions = {},\n charactersLimit,\n titleHeight,\n } = props;\n const [rotatedToHorizontal, setRotatedToHorizontal] = useState(false);\n const activePlugins = [\n 'bold',\n 'italic',\n 'underline',\n 'strikethrough',\n 'math',\n // 'languageCharacters'\n ];\n\n const isChart = isChartBottomLabel || isChartLeftLabel || isDefineChartBottomLabel || isDefineChartLeftLabel;\n\n const chartValue = side === 'left' && isDefineChartLeftLabel && graphHeight - 220;\n const defaultStyle = {\n width: chartValue || (side === 'left' || side === 'right' ? graphHeight - 8 : graphWidth - 8),\n top:\n chartValue ||\n (isChartLeftLabel && `${graphHeight - 70}px`) ||\n (side === 'left' && `${graphHeight - 8}px`) ||\n (isChartBottomLabel && `${graphHeight - 60 + titleHeight}px`) ||\n (side === 'bottom' && `${graphHeight - 120 + titleHeight}px`) ||\n 0,\n left:\n (side === 'right' && `${graphWidth - 8}px`) ||\n ((isDefineChartLeftLabel || isDefineChartBottomLabel) && '40px') ||\n (isChartBottomLabel && '-10px') ||\n 0,\n };\n\n const rotatedStyle = {\n width: graphWidth - 8,\n top: (side === 'right' && `${graphHeight - 22}px`) || 0,\n left: 0,\n };\n\n const rotateLabel = () => !disabledLabel && (side === 'left' || side === 'right') && setRotatedToHorizontal(true);\n\n return (\n <Readable false>\n <StyledLabel\n side={side}\n rotatedToHorizontal={rotatedToHorizontal}\n isChart={isChart}\n isChartBottomLabel={isChartBottomLabel}\n isDefineChartBottomLabel={isDefineChartBottomLabel}\n disabledLabel={disabledLabel}\n isEmpty={isEmptyString(extractTextFromHTML(text))}\n style={rotatedToHorizontal ? rotatedStyle : defaultStyle}\n onClick={rotateLabel}\n >\n {disabledLabel ? (\n <DisabledLabel dangerouslySetInnerHTML={{ __html: text || '' }} />\n ) : (\n <EditableHtml\n markup={text || ''}\n onChange={onChange}\n placeholder={!disabledLabel && placeholder}\n toolbarOpts={{\n position: side === 'bottom' ? 'top' : 'bottom',\n noPadding: true,\n noBorder: true,\n }}\n disableScrollbar\n activePlugins={activePlugins}\n onDone={() => setRotatedToHorizontal(false)}\n mathMlOptions={mathMlOptions}\n charactersLimit={charactersLimit}\n />\n )}\n </StyledLabel>\n </Readable>\n );\n};\n\nLabelComponent.propTypes = {\n disabledLabel: PropTypes.bool,\n graphHeight: PropTypes.number,\n graphWidth: PropTypes.number,\n isChartBottomLabel: PropTypes.bool,\n isDefineChartBottomLabel: PropTypes.bool,\n isChartLeftLabel: PropTypes.bool,\n isDefineChartLeftLabel: PropTypes.bool,\n placeholder: PropTypes.string,\n text: PropTypes.string,\n side: PropTypes.string,\n onChange: PropTypes.func,\n mathMlOptions: PropTypes.object,\n charactersLimit: PropTypes.number,\n titleHeight: PropTypes.number,\n};\n\nexport default LabelComponent;\n"],"mappings":";;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,aAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,UAAA,GAAAF,sBAAA,CAAAH,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AAA6D,SAAAD,wBAAAQ,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAV,uBAAA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,EAAEgC,qBAAS,CAACI,IAAI;EACxBlC,aAAa,EAAE8B,qBAAS,CAACK,MAAM;EAC/BlC,eAAe,EAAE6B,qBAAS,CAACE,MAAM;EACjC9B,WAAW,EAAE4B,qBAAS,CAACE;AACzB,CAAC;AAAC,IAAAI,QAAA,GAAAC,OAAA,cAEa/C,cAAc","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"label.js","names":["_react","_interopRequireWildcard","require","_renderUi","_editableHtml","_interopRequireDefault","_propTypes","_classnames","_utils","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","_typeof","has","get","set","_t","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","ownKeys","keys","getOwnPropertySymbols","filter","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty2","getOwnPropertyDescriptors","defineProperties","styles","axisLabel","fontSize","textAlign","margin","padding","chartLabel","disabledLabel","pointerEvents","width","editLabel","position","backgroundColor","borderRadius","boxShadow","zIndex","rotateLeftLabel","transform","transformOrigin","rotateRightLabel","customBottom","displayNone","display","LabelComponent","props","graphHeight","graphWidth","isChartBottomLabel","isDefineChartBottomLabel","isChartLeftLabel","isDefineChartLeftLabel","placeholder","text","side","onChange","_props$mathMlOptions","mathMlOptions","charactersLimit","titleHeight","_useState","useState","_useState2","_slicedToArray2","rotatedToHorizontal","setRotatedToHorizontal","activePlugins","isChart","chartValue","defaultStyle","top","concat","left","rotatedStyle","rotateLabel","createElement","Readable","onClick","style","isEmptyString","extractTextFromHTML","dangerouslySetInnerHTML","__html","markup","toolbarOpts","noPadding","noBorder","disableScrollbar","onDone","propTypes","PropTypes","bool","number","string","func","object","_default","exports"],"sources":["../src/label.jsx"],"sourcesContent":["import React, { useState } from 'react';\nimport { color, Readable } from '@pie-lib/render-ui';\nimport EditableHtml from '@pie-lib/editable-html';\nimport PropTypes from 'prop-types';\nimport cn from 'classnames';\nimport { extractTextFromHTML, isEmptyString } from './utils';\n\nconst styles = {\n axisLabel: {\n fontSize: 12,\n textAlign: 'center',\n margin: 4,\n padding: '4px 0',\n },\n chartLabel: {\n fontSize: 16,\n textAlign: 'center',\n margin: 4,\n padding: '4px 0',\n },\n disabledLabel: {\n pointerEvents: 'none',\n width: '100%',\n },\n editLabel: {\n position: 'absolute',\n backgroundColor: 'white',\n borderRadius: 4,\n boxShadow: '0px 5px 8px rgba(0,0,0,0.15)',\n zIndex: 10,\n },\n rotateLeftLabel: {\n transform: 'rotate(-90deg)',\n transformOrigin: '0 0',\n position: 'absolute',\n },\n rotateRightLabel: {\n transform: 'rotate(90deg)',\n transformOrigin: '0 0',\n position: 'absolute',\n },\n customBottom: {\n position: 'absolute',\n },\n displayNone: {\n display: 'none',\n },\n};\n\nconst LabelComponent = (props) => {\n const {\n disabledLabel,\n graphHeight,\n graphWidth,\n isChartBottomLabel,\n isDefineChartBottomLabel,\n isChartLeftLabel,\n isDefineChartLeftLabel,\n placeholder,\n text,\n side,\n onChange,\n mathMlOptions = {},\n charactersLimit,\n titleHeight,\n } = props;\n\n const [rotatedToHorizontal, setRotatedToHorizontal] = useState(false);\n\n const activePlugins = [\n 'bold',\n 'italic',\n 'underline',\n 'strikethrough',\n 'math',\n ];\n\n const isChart =\n isChartBottomLabel ||\n isChartLeftLabel ||\n isDefineChartBottomLabel ||\n isDefineChartLeftLabel;\n\n const chartValue =\n side === 'left' && isDefineChartLeftLabel && graphHeight - 220;\n\n const defaultStyle = {\n width:\n chartValue ||\n (side === 'left' || side === 'right'\n ? graphHeight - 8\n : graphWidth - 8),\n top:\n chartValue ||\n (isChartLeftLabel && `${graphHeight - 70}px`) ||\n (side === 'left' && `${graphHeight - 8}px`) ||\n (isChartBottomLabel && `${graphHeight - 60 + titleHeight}px`) ||\n (side === 'bottom' && `${graphHeight - 120 + titleHeight}px`) ||\n 0,\n left:\n (side === 'right' && `${graphWidth - 8}px`) ||\n ((isDefineChartLeftLabel || isDefineChartBottomLabel) && '40px') ||\n (isChartBottomLabel && '-10px') ||\n 0,\n };\n\n const rotatedStyle = {\n width: graphWidth - 8,\n top: side === 'right' ? `${graphHeight - 22}px` : 0,\n left: 0,\n };\n\n const rotateLabel = () => {\n if (!disabledLabel && (side === 'left' || side === 'right')) {\n setRotatedToHorizontal(true);\n }\n };\n\n return (\n <Readable false>\n <div\n onClick={rotateLabel}\n style={{\n ...(rotatedToHorizontal ? rotatedStyle : defaultStyle),\n ...(isChart ? styles.chartLabel : styles.axisLabel),\n ...(side === 'left' && !rotatedToHorizontal\n ? styles.rotateLeftLabel\n : {}),\n ...(side === 'right' && !rotatedToHorizontal\n ? styles.rotateRightLabel\n : {}),\n ...(rotatedToHorizontal ? styles.editLabel : {}),\n ...((isChartBottomLabel || isDefineChartBottomLabel)\n ? styles.customBottom\n : {}),\n ...((disabledLabel &&\n !isChart &&\n isEmptyString(extractTextFromHTML(text))) &&\n styles.displayNone),\n }}\n >\n {disabledLabel ? (\n <div\n style={styles.disabledLabel}\n dangerouslySetInnerHTML={{ __html: text || '' }}\n />\n ) : (\n <EditableHtml\n markup={text || ''}\n onChange={onChange}\n placeholder={!disabledLabel && placeholder}\n toolbarOpts={{\n position: side === 'bottom' ? 'top' : 'bottom',\n noPadding: true,\n noBorder: true,\n }}\n disableScrollbar\n activePlugins={activePlugins}\n onDone={() => setRotatedToHorizontal(false)}\n mathMlOptions={mathMlOptions}\n charactersLimit={charactersLimit}\n />\n )}\n </div>\n </Readable>\n );\n};\n\nLabelComponent.propTypes = {\n disabledLabel: PropTypes.bool,\n graphHeight: PropTypes.number,\n graphWidth: PropTypes.number,\n isChartBottomLabel: PropTypes.bool,\n isDefineChartBottomLabel: PropTypes.bool,\n isChartLeftLabel: PropTypes.bool,\n isDefineChartLeftLabel: PropTypes.bool,\n placeholder: PropTypes.string,\n text: PropTypes.string,\n side: PropTypes.string,\n onChange: PropTypes.func,\n mathMlOptions: PropTypes.object,\n charactersLimit: PropTypes.number,\n titleHeight: PropTypes.number,\n};\n\nexport default LabelComponent;\n"],"mappings":";;;;;;;;;;AAAA,IAA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arD,cAAc","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "2.
|
|
6
|
+
"version": "2.29.0-mui-update.0",
|
|
7
7
|
"description": "Some underlying components for building charts/graphs",
|
|
8
8
|
"keywords": [
|
|
9
9
|
"react",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"@mapbox/point-geometry": "^0.1.0",
|
|
22
22
|
"@mui/icons-material": "^7.3.4",
|
|
23
23
|
"@mui/material": "^7.3.4",
|
|
24
|
-
"@pie-lib/editable-html": "^11.
|
|
25
|
-
"@pie-lib/render-ui": "^4.
|
|
24
|
+
"@pie-lib/editable-html": "^11.23.0-mui-update.0",
|
|
25
|
+
"@pie-lib/render-ui": "^4.37.0-mui-update.0",
|
|
26
26
|
"@vx/axis": "^0.0.183",
|
|
27
27
|
"@vx/event": "^0.0.182",
|
|
28
28
|
"@vx/grid": "^0.0.183",
|
|
@@ -44,6 +44,6 @@
|
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"react": "^18.2.0"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "4d8ccede3634986a13ea7df987defd26d089f0d6",
|
|
48
48
|
"scripts": {}
|
|
49
49
|
}
|
package/src/label.jsx
CHANGED
|
@@ -1,41 +1,51 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
|
-
import { Readable } from '@pie-lib/render-ui';
|
|
2
|
+
import { color, Readable } from '@pie-lib/render-ui';
|
|
3
3
|
import EditableHtml from '@pie-lib/editable-html';
|
|
4
|
-
import { styled } from '@mui/material/styles';
|
|
5
4
|
import PropTypes from 'prop-types';
|
|
5
|
+
import cn from 'classnames';
|
|
6
6
|
import { extractTextFromHTML, isEmptyString } from './utils';
|
|
7
7
|
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
...(rotatedToHorizontal && {
|
|
8
|
+
const styles = {
|
|
9
|
+
axisLabel: {
|
|
10
|
+
fontSize: 12,
|
|
11
|
+
textAlign: 'center',
|
|
12
|
+
margin: 4,
|
|
13
|
+
padding: '4px 0',
|
|
14
|
+
},
|
|
15
|
+
chartLabel: {
|
|
16
|
+
fontSize: 16,
|
|
17
|
+
textAlign: 'center',
|
|
18
|
+
margin: 4,
|
|
19
|
+
padding: '4px 0',
|
|
20
|
+
},
|
|
21
|
+
disabledLabel: {
|
|
22
|
+
pointerEvents: 'none',
|
|
23
|
+
width: '100%',
|
|
24
|
+
},
|
|
25
|
+
editLabel: {
|
|
26
|
+
position: 'absolute',
|
|
28
27
|
backgroundColor: 'white',
|
|
29
|
-
borderRadius:
|
|
30
|
-
boxShadow: '0px 5px 8px rgba(0,
|
|
28
|
+
borderRadius: 4,
|
|
29
|
+
boxShadow: '0px 5px 8px rgba(0,0,0,0.15)',
|
|
31
30
|
zIndex: 10,
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
31
|
+
},
|
|
32
|
+
rotateLeftLabel: {
|
|
33
|
+
transform: 'rotate(-90deg)',
|
|
34
|
+
transformOrigin: '0 0',
|
|
35
|
+
position: 'absolute',
|
|
36
|
+
},
|
|
37
|
+
rotateRightLabel: {
|
|
38
|
+
transform: 'rotate(90deg)',
|
|
39
|
+
transformOrigin: '0 0',
|
|
40
|
+
position: 'absolute',
|
|
41
|
+
},
|
|
42
|
+
customBottom: {
|
|
43
|
+
position: 'absolute',
|
|
44
|
+
},
|
|
45
|
+
displayNone: {
|
|
46
|
+
display: 'none',
|
|
47
|
+
},
|
|
48
|
+
};
|
|
39
49
|
|
|
40
50
|
const LabelComponent = (props) => {
|
|
41
51
|
const {
|
|
@@ -54,21 +64,32 @@ const LabelComponent = (props) => {
|
|
|
54
64
|
charactersLimit,
|
|
55
65
|
titleHeight,
|
|
56
66
|
} = props;
|
|
67
|
+
|
|
57
68
|
const [rotatedToHorizontal, setRotatedToHorizontal] = useState(false);
|
|
69
|
+
|
|
58
70
|
const activePlugins = [
|
|
59
71
|
'bold',
|
|
60
72
|
'italic',
|
|
61
73
|
'underline',
|
|
62
74
|
'strikethrough',
|
|
63
75
|
'math',
|
|
64
|
-
// 'languageCharacters'
|
|
65
76
|
];
|
|
66
77
|
|
|
67
|
-
const isChart =
|
|
78
|
+
const isChart =
|
|
79
|
+
isChartBottomLabel ||
|
|
80
|
+
isChartLeftLabel ||
|
|
81
|
+
isDefineChartBottomLabel ||
|
|
82
|
+
isDefineChartLeftLabel;
|
|
83
|
+
|
|
84
|
+
const chartValue =
|
|
85
|
+
side === 'left' && isDefineChartLeftLabel && graphHeight - 220;
|
|
68
86
|
|
|
69
|
-
const chartValue = side === 'left' && isDefineChartLeftLabel && graphHeight - 220;
|
|
70
87
|
const defaultStyle = {
|
|
71
|
-
width:
|
|
88
|
+
width:
|
|
89
|
+
chartValue ||
|
|
90
|
+
(side === 'left' || side === 'right'
|
|
91
|
+
? graphHeight - 8
|
|
92
|
+
: graphWidth - 8),
|
|
72
93
|
top:
|
|
73
94
|
chartValue ||
|
|
74
95
|
(isChartLeftLabel && `${graphHeight - 70}px`) ||
|
|
@@ -85,27 +106,44 @@ const LabelComponent = (props) => {
|
|
|
85
106
|
|
|
86
107
|
const rotatedStyle = {
|
|
87
108
|
width: graphWidth - 8,
|
|
88
|
-
top:
|
|
109
|
+
top: side === 'right' ? `${graphHeight - 22}px` : 0,
|
|
89
110
|
left: 0,
|
|
90
111
|
};
|
|
91
112
|
|
|
92
|
-
const rotateLabel = () =>
|
|
113
|
+
const rotateLabel = () => {
|
|
114
|
+
if (!disabledLabel && (side === 'left' || side === 'right')) {
|
|
115
|
+
setRotatedToHorizontal(true);
|
|
116
|
+
}
|
|
117
|
+
};
|
|
93
118
|
|
|
94
119
|
return (
|
|
95
120
|
<Readable false>
|
|
96
|
-
<
|
|
97
|
-
side={side}
|
|
98
|
-
rotatedToHorizontal={rotatedToHorizontal}
|
|
99
|
-
isChart={isChart}
|
|
100
|
-
isChartBottomLabel={isChartBottomLabel}
|
|
101
|
-
isDefineChartBottomLabel={isDefineChartBottomLabel}
|
|
102
|
-
disabledLabel={disabledLabel}
|
|
103
|
-
isEmpty={isEmptyString(extractTextFromHTML(text))}
|
|
104
|
-
style={rotatedToHorizontal ? rotatedStyle : defaultStyle}
|
|
121
|
+
<div
|
|
105
122
|
onClick={rotateLabel}
|
|
123
|
+
style={{
|
|
124
|
+
...(rotatedToHorizontal ? rotatedStyle : defaultStyle),
|
|
125
|
+
...(isChart ? styles.chartLabel : styles.axisLabel),
|
|
126
|
+
...(side === 'left' && !rotatedToHorizontal
|
|
127
|
+
? styles.rotateLeftLabel
|
|
128
|
+
: {}),
|
|
129
|
+
...(side === 'right' && !rotatedToHorizontal
|
|
130
|
+
? styles.rotateRightLabel
|
|
131
|
+
: {}),
|
|
132
|
+
...(rotatedToHorizontal ? styles.editLabel : {}),
|
|
133
|
+
...((isChartBottomLabel || isDefineChartBottomLabel)
|
|
134
|
+
? styles.customBottom
|
|
135
|
+
: {}),
|
|
136
|
+
...((disabledLabel &&
|
|
137
|
+
!isChart &&
|
|
138
|
+
isEmptyString(extractTextFromHTML(text))) &&
|
|
139
|
+
styles.displayNone),
|
|
140
|
+
}}
|
|
106
141
|
>
|
|
107
142
|
{disabledLabel ? (
|
|
108
|
-
<
|
|
143
|
+
<div
|
|
144
|
+
style={styles.disabledLabel}
|
|
145
|
+
dangerouslySetInnerHTML={{ __html: text || '' }}
|
|
146
|
+
/>
|
|
109
147
|
) : (
|
|
110
148
|
<EditableHtml
|
|
111
149
|
markup={text || ''}
|
|
@@ -123,7 +161,7 @@ const LabelComponent = (props) => {
|
|
|
123
161
|
charactersLimit={charactersLimit}
|
|
124
162
|
/>
|
|
125
163
|
)}
|
|
126
|
-
</
|
|
164
|
+
</div>
|
|
127
165
|
</Readable>
|
|
128
166
|
);
|
|
129
167
|
};
|