@pie-lib/plot 2.14.0 → 2.15.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/lib/index.js ADDED
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ var _typeof = require("@babel/runtime/helpers/typeof");
6
+
7
+ Object.defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+ Object.defineProperty(exports, "Draggable", {
11
+ enumerable: true,
12
+ get: function get() {
13
+ return _draggable["default"];
14
+ }
15
+ });
16
+ Object.defineProperty(exports, "Root", {
17
+ enumerable: true,
18
+ get: function get() {
19
+ return _root["default"];
20
+ }
21
+ });
22
+ Object.defineProperty(exports, "createGraphProps", {
23
+ enumerable: true,
24
+ get: function get() {
25
+ return _graphProps.create;
26
+ }
27
+ });
28
+ Object.defineProperty(exports, "gridDraggable", {
29
+ enumerable: true,
30
+ get: function get() {
31
+ return _gridDraggable.gridDraggable;
32
+ }
33
+ });
34
+ exports.utils = exports.types = exports.trig = void 0;
35
+
36
+ var _root = _interopRequireDefault(require("./root"));
37
+
38
+ var _draggable = _interopRequireDefault(require("./draggable"));
39
+
40
+ var _gridDraggable = require("./grid-draggable");
41
+
42
+ var utils = _interopRequireWildcard(require("./utils"));
43
+
44
+ exports.utils = utils;
45
+
46
+ var trig = _interopRequireWildcard(require("./trig"));
47
+
48
+ exports.trig = trig;
49
+
50
+ var types = _interopRequireWildcard(require("./types"));
51
+
52
+ exports.types = types;
53
+
54
+ var _graphProps = require("./graph-props");
55
+
56
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
57
+
58
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
59
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;;;AACA;;;;AACA;;;;AACA","sourcesContent":["import Root from './root';\nimport Draggable from './draggable';\nimport { gridDraggable } from './grid-draggable';\nimport * as utils from './utils';\nimport * as trig from './trig';\nimport * as types from './types';\nimport { create as createGraphProps } from './graph-props';\n\nexport { Root, Draggable, gridDraggable, utils, trig, types, createGraphProps };\n"],"file":"index.js"}
package/lib/label.js ADDED
@@ -0,0 +1,176 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ var _typeof = require("@babel/runtime/helpers/typeof");
6
+
7
+ Object.defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+ exports["default"] = void 0;
11
+
12
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
+
14
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
15
+
16
+ var _react = _interopRequireWildcard(require("react"));
17
+
18
+ var _renderUi = require("@pie-lib/render-ui");
19
+
20
+ var _classnames = _interopRequireDefault(require("classnames"));
21
+
22
+ var _editableHtml = _interopRequireDefault(require("@pie-lib/editable-html"));
23
+
24
+ var _styles = require("@material-ui/core/styles");
25
+
26
+ var _propTypes = _interopRequireDefault(require("prop-types"));
27
+
28
+ var _utils = require("./utils");
29
+
30
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
31
+
32
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
33
+
34
+ var LabelComponent = function LabelComponent(props) {
35
+ var _cn;
36
+
37
+ var classes = props.classes,
38
+ disabledLabel = props.disabledLabel,
39
+ graphHeight = props.graphHeight,
40
+ graphWidth = props.graphWidth,
41
+ isChartBottomLabel = props.isChartBottomLabel,
42
+ isDefineChartBottomLabel = props.isDefineChartBottomLabel,
43
+ isChartLeftLabel = props.isChartLeftLabel,
44
+ isDefineChartLeftLabel = props.isDefineChartLeftLabel,
45
+ placeholder = props.placeholder,
46
+ text = props.text,
47
+ side = props.side,
48
+ onChange = props.onChange,
49
+ _props$mathMlOptions = props.mathMlOptions,
50
+ mathMlOptions = _props$mathMlOptions === void 0 ? {} : _props$mathMlOptions,
51
+ charactersLimit = props.charactersLimit,
52
+ titleHeight = props.titleHeight;
53
+
54
+ var _useState = (0, _react.useState)(false),
55
+ _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
56
+ rotatedToHorizontal = _useState2[0],
57
+ setRotatedToHorizontal = _useState2[1];
58
+
59
+ var activePlugins = ['bold', 'italic', 'underline', 'strikethrough', 'math' // 'languageCharacters'
60
+ ];
61
+ var isChart = isChartBottomLabel || isChartLeftLabel || isDefineChartBottomLabel || isDefineChartLeftLabel;
62
+ var chartValue = side === 'left' && isDefineChartLeftLabel && graphHeight - 220;
63
+ var defaultStyle = {
64
+ width: chartValue || (side === 'left' || side === 'right' ? graphHeight - 8 : graphWidth - 8),
65
+ top: chartValue || isChartLeftLabel && "".concat(graphHeight - 70, "px") || side === 'left' && "".concat(graphHeight - 8, "px") || isChartBottomLabel && "".concat(graphHeight - 60 + titleHeight, "px") || side === 'bottom' && "".concat(graphHeight - 120 + titleHeight, "px") || 0,
66
+ left: side === 'right' && "".concat(graphWidth - 8, "px") || (isDefineChartLeftLabel || isDefineChartBottomLabel) && '40px' || isChartBottomLabel && '-10px' || 0
67
+ };
68
+ var rotatedStyle = {
69
+ width: graphWidth - 8,
70
+ top: side === 'right' && "".concat(graphHeight - 22, "px") || 0,
71
+ left: 0
72
+ };
73
+
74
+ var rotateLabel = function rotateLabel() {
75
+ return !disabledLabel && (side === 'left' || side === 'right') && setRotatedToHorizontal(true);
76
+ };
77
+
78
+ return /*#__PURE__*/_react["default"].createElement(_renderUi.Readable, {
79
+ "false": true
80
+ }, /*#__PURE__*/_react["default"].createElement("div", {
81
+ className: (0, _classnames["default"])(isChart ? classes.chartLabel : classes.axisLabel, (_cn = {}, (0, _defineProperty2["default"])(_cn, classes.rotateLeftLabel, side === 'left' && !rotatedToHorizontal), (0, _defineProperty2["default"])(_cn, classes.rotateRightLabel, side === 'right' && !rotatedToHorizontal), (0, _defineProperty2["default"])(_cn, classes.editLabel, rotatedToHorizontal), (0, _defineProperty2["default"])(_cn, classes.customBottom, isChartBottomLabel || isDefineChartBottomLabel), (0, _defineProperty2["default"])(_cn, classes.displayNone, disabledLabel && !isChart && (0, _utils.isEmptyString)((0, _utils.extractTextFromHTML)(text))), _cn)),
82
+ style: rotatedToHorizontal ? rotatedStyle : defaultStyle,
83
+ onClick: rotateLabel
84
+ }, disabledLabel ? /*#__PURE__*/_react["default"].createElement("div", {
85
+ className: classes.disabledLabel,
86
+ dangerouslySetInnerHTML: {
87
+ __html: text || ''
88
+ }
89
+ }) : /*#__PURE__*/_react["default"].createElement(_editableHtml["default"], {
90
+ markup: text || '',
91
+ onChange: onChange,
92
+ placeholder: !disabledLabel && placeholder,
93
+ toolbarOpts: {
94
+ position: side === 'bottom' ? 'top' : 'bottom',
95
+ noPadding: true,
96
+ noBorder: true
97
+ },
98
+ disableScrollbar: true,
99
+ activePlugins: activePlugins,
100
+ onDone: function onDone() {
101
+ return setRotatedToHorizontal(false);
102
+ },
103
+ mathMlOptions: mathMlOptions,
104
+ charactersLimit: charactersLimit
105
+ })));
106
+ };
107
+
108
+ LabelComponent.propTypes = {
109
+ classes: _propTypes["default"].object,
110
+ disabledLabel: _propTypes["default"].bool,
111
+ graphHeight: _propTypes["default"].number,
112
+ graphWidth: _propTypes["default"].number,
113
+ isChartBottomLabel: _propTypes["default"].bool,
114
+ isDefineChartBottomLabel: _propTypes["default"].bool,
115
+ isChartLeftLabel: _propTypes["default"].bool,
116
+ isDefineChartLeftLabel: _propTypes["default"].bool,
117
+ placeholder: _propTypes["default"].string,
118
+ text: _propTypes["default"].string,
119
+ side: _propTypes["default"].string,
120
+ onChange: _propTypes["default"].func,
121
+ mathMlOptions: _propTypes["default"].object,
122
+ charactersLimit: _propTypes["default"].number,
123
+ titleHeight: _propTypes["default"].number
124
+ };
125
+
126
+ var _default = (0, _styles.withStyles)(function (theme) {
127
+ return {
128
+ label: {
129
+ fill: _renderUi.color.secondary()
130
+ },
131
+ axisLabel: {
132
+ fontSize: theme.typography.fontSize - 2,
133
+ textAlign: 'center',
134
+ margin: theme.spacing.unit / 2,
135
+ padding: "".concat(theme.spacing.unit / 2, "px 0")
136
+ },
137
+ chartLabel: {
138
+ fontSize: theme.typography.fontSize + 2,
139
+ textAlign: 'center',
140
+ margin: theme.spacing.unit / 2,
141
+ padding: "".concat(theme.spacing.unit / 2, "px 0")
142
+ },
143
+ disabledLabel: {
144
+ pointerEvents: 'none',
145
+ width: '100%'
146
+ },
147
+ editLabel: {
148
+ position: 'absolute',
149
+ backgroundColor: 'white',
150
+ borderRadius: '4px',
151
+ boxShadow: '0px 5px 8px rgba(0, 0, 0, 0.15)',
152
+ zIndex: 10
153
+ },
154
+ rotateLeftLabel: {
155
+ '-webkit-transform': 'rotate(-90deg)',
156
+ transformOrigin: '0 0',
157
+ transformStyle: 'preserve-3d',
158
+ position: 'absolute'
159
+ },
160
+ rotateRightLabel: {
161
+ '-webkit-transform': 'rotate(90deg)',
162
+ transformOrigin: '0 0',
163
+ transformStyle: 'preserve-3d',
164
+ position: 'absolute'
165
+ },
166
+ customBottom: {
167
+ position: 'absolute'
168
+ },
169
+ displayNone: {
170
+ display: 'none'
171
+ }
172
+ };
173
+ })(LabelComponent);
174
+
175
+ exports["default"] = _default;
176
+ //# sourceMappingURL=label.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/label.jsx"],"names":["LabelComponent","props","classes","disabledLabel","graphHeight","graphWidth","isChartBottomLabel","isDefineChartBottomLabel","isChartLeftLabel","isDefineChartLeftLabel","placeholder","text","side","onChange","mathMlOptions","charactersLimit","titleHeight","rotatedToHorizontal","setRotatedToHorizontal","activePlugins","isChart","chartValue","defaultStyle","width","top","left","rotatedStyle","rotateLabel","chartLabel","axisLabel","rotateLeftLabel","rotateRightLabel","editLabel","customBottom","displayNone","__html","position","noPadding","noBorder","propTypes","PropTypes","object","bool","number","string","func","theme","label","fill","color","secondary","fontSize","typography","textAlign","margin","spacing","unit","padding","pointerEvents","backgroundColor","borderRadius","boxShadow","zIndex","transformOrigin","transformStyle","display"],"mappings":";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AAIVC,MAAAA,OAAO,YAAKX,KAAK,CAACS,OAAN,CAAcC,IAAd,GAAqB,CAA1B;AAJG,KAVwB;AAgBpCrD,IAAAA,aAAa,EAAE;AACbuD,MAAAA,aAAa,EAAE,MADF;AAEbnC,MAAAA,KAAK,EAAE;AAFM,KAhBqB;AAoBpCS,IAAAA,SAAS,EAAE;AACTI,MAAAA,QAAQ,EAAE,UADD;AAETuB,MAAAA,eAAe,EAAE,OAFR;AAGTC,MAAAA,YAAY,EAAE,KAHL;AAITC,MAAAA,SAAS,EAAE,iCAJF;AAKTC,MAAAA,MAAM,EAAE;AALC,KApByB;AA2BpChC,IAAAA,eAAe,EAAE;AACf,2BAAqB,gBADN;AAEfiC,MAAAA,eAAe,EAAE,KAFF;AAGfC,MAAAA,cAAc,EAAE,aAHD;AAIf5B,MAAAA,QAAQ,EAAE;AAJK,KA3BmB;AAiCpCL,IAAAA,gBAAgB,EAAE;AAChB,2BAAqB,eADL;AAEhBgC,MAAAA,eAAe,EAAE,KAFD;AAGhBC,MAAAA,cAAc,EAAE,aAHA;AAIhB5B,MAAAA,QAAQ,EAAE;AAJM,KAjCkB;AAuCpCH,IAAAA,YAAY,EAAE;AACZG,MAAAA,QAAQ,EAAE;AADE,KAvCsB;AA0CpCF,IAAAA,WAAW,EAAE;AACX+B,MAAAA,OAAO,EAAE;AADE;AA1CuB,GAAZ;AAAA,CAAX,EA6CXjE,cA7CW,C","sourcesContent":["import React, { useState } from 'react';\nimport { color, Readable } from '@pie-lib/render-ui';\nimport cn from 'classnames';\nimport EditableHtml from '@pie-lib/editable-html';\nimport { withStyles } from '@material-ui/core/styles';\nimport PropTypes from 'prop-types';\nimport { extractTextFromHTML, isEmptyString } from './utils';\nconst LabelComponent = (props) => {\n const {\n classes,\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 <div\n className={cn(isChart ? classes.chartLabel : classes.axisLabel, {\n [classes.rotateLeftLabel]: side === 'left' && !rotatedToHorizontal,\n [classes.rotateRightLabel]: side === 'right' && !rotatedToHorizontal,\n [classes.editLabel]: rotatedToHorizontal,\n [classes.customBottom]: isChartBottomLabel || isDefineChartBottomLabel,\n [classes.displayNone]: disabledLabel && !isChart && isEmptyString(extractTextFromHTML(text)),\n })}\n style={rotatedToHorizontal ? rotatedStyle : defaultStyle}\n onClick={rotateLabel}\n >\n {disabledLabel ? (\n <div className={classes.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 </div>\n </Readable>\n );\n};\nLabelComponent.propTypes = {\n classes: PropTypes.object,\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 withStyles((theme) => ({\n label: {\n fill: color.secondary(),\n },\n axisLabel: {\n fontSize: theme.typography.fontSize - 2,\n textAlign: 'center',\n margin: theme.spacing.unit / 2,\n padding: `${theme.spacing.unit / 2}px 0`,\n },\n chartLabel: {\n fontSize: theme.typography.fontSize + 2,\n textAlign: 'center',\n margin: theme.spacing.unit / 2,\n padding: `${theme.spacing.unit / 2}px 0`,\n },\n disabledLabel: {\n pointerEvents: 'none',\n width: '100%',\n },\n editLabel: {\n position: 'absolute',\n backgroundColor: 'white',\n borderRadius: '4px',\n boxShadow: '0px 5px 8px rgba(0, 0, 0, 0.15)',\n zIndex: 10,\n },\n rotateLeftLabel: {\n '-webkit-transform': 'rotate(-90deg)',\n transformOrigin: '0 0',\n transformStyle: 'preserve-3d',\n position: 'absolute',\n },\n rotateRightLabel: {\n '-webkit-transform': 'rotate(90deg)',\n transformOrigin: '0 0',\n transformStyle: 'preserve-3d',\n position: 'absolute',\n },\n customBottom: {\n position: 'absolute',\n },\n displayNone: {\n display: 'none',\n },\n}))(LabelComponent);\n"],"file":"label.js"}