pcm-shared-components 0.0.63 → 0.0.66

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.
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { useEffect } from 'react';
2
2
  import Slider from '@mui/material/Slider';
3
3
  import Typography from '@mui/material/Typography';
4
4
  import { combineDrawing } from '../service/image_tools';
@@ -6,6 +6,7 @@ import imageCompression from 'browser-image-compression';
6
6
  import { ChromePicker } from 'react-color';
7
7
  import Button from '@mui/material/Button';
8
8
  import { OUTPUT_TYPES } from '../constants';
9
+ import { rgbToHex } from '../../../Tools/color';
9
10
  const imageScaleMarks = [{
10
11
  value: 1.5,
11
12
  label: 'Full'
@@ -81,32 +82,15 @@ const Controls = props => {
81
82
  return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
82
83
  className: "flex flex-col"
83
84
  }, /*#__PURE__*/React.createElement("div", {
84
- className: "flex flex-row justify-between "
85
- }, /*#__PURE__*/React.createElement(Button, {
86
- color: "secondary",
87
- onClick: () => {
88
- saveableCanvas.current.eraseAll();
89
- }
90
- }, "Erase"), /*#__PURE__*/React.createElement(Button, {
91
- color: "secondary",
92
- onClick: () => {
93
- saveableCanvas.current.undo();
94
- }
95
- }, "Undo"), /*#__PURE__*/React.createElement(Button, {
96
- variant: "outlined",
97
- onClick: () => {
98
- exportImage(onSave, saveableCanvas, outputFormat, state.imageCompressionOptions);
99
- }
100
- }, "Save")), /*#__PURE__*/React.createElement("div", {
101
85
  className: "m-auto my-12"
102
86
  }, /*#__PURE__*/React.createElement(ChromePicker, {
103
87
  className: "drop-shadow-none",
104
- disableAlpha: true,
88
+ disableAlpha: false,
105
89
  color: state.color,
106
90
  onChange: (color, event) => {
107
91
  setState(previousState => {
108
92
  return { ...previousState,
109
- color: color.hex
93
+ color: rgbToHex(color.rgb)
110
94
  };
111
95
  });
112
96
  }
@@ -153,7 +137,7 @@ const Controls = props => {
153
137
  },
154
138
  step: 1,
155
139
  min: 1,
156
- max: 10
140
+ max: 20
157
141
  }))), /*#__PURE__*/React.createElement("div", {
158
142
  className: "my-6"
159
143
  }, /*#__PURE__*/React.createElement(Typography, {
@@ -173,12 +157,29 @@ const Controls = props => {
173
157
  return { ...previousState,
174
158
  imageScale: Number(event.target.value)
175
159
  };
176
- });
160
+ }); // saveableCanvas.current.eraseAll();
177
161
  },
178
162
  marks: imageScaleMarks,
179
163
  min: 1.5,
180
164
  max: 2.5
181
165
  })))), /*#__PURE__*/React.createElement("div", {
166
+ className: "flex flex-row justify-between mt-12 "
167
+ }, /*#__PURE__*/React.createElement(Button, {
168
+ color: "secondary",
169
+ onClick: () => {
170
+ saveableCanvas.current.eraseAll();
171
+ }
172
+ }, "Erase"), /*#__PURE__*/React.createElement(Button, {
173
+ color: "secondary",
174
+ onClick: () => {
175
+ saveableCanvas.current.undo();
176
+ }
177
+ }, "Undo"), /*#__PURE__*/React.createElement(Button, {
178
+ variant: "outlined",
179
+ onClick: () => {
180
+ exportImage(onSave, saveableCanvas, outputFormat, state.imageCompressionOptions);
181
+ }
182
+ }, "Save")), /*#__PURE__*/React.createElement("div", {
182
183
  className: "flex flex-row justify-center mt-12"
183
184
  }, showDownloadButton && /*#__PURE__*/React.createElement(Button, {
184
185
  variant: "outlined",
@@ -8,6 +8,7 @@ import { getStorage, setStorage } from './service/local_storage';
8
8
  import PropTypes from 'prop-types';
9
9
  import { ThemeProvider } from '@mui/system';
10
10
  import { createTheme, useTheme } from '@mui/material/styles';
11
+ import PCMScrollbar from '../../Tools/PCMScrollbar';
11
12
  /**
12
13
  * Displays an image that can is used to draw on to generate maps with highlighted routes.
13
14
  *
@@ -87,6 +88,18 @@ export const ImageCanvasDraw = props => {
87
88
  useEffect(() => {
88
89
  //Get the scaled down image and width, height
89
90
  setImageSize(state.b64DataUrl);
91
+
92
+ try {
93
+ document.addEventListener('keydown', function (e) {
94
+ console.log('debug e', e);
95
+
96
+ if (e.ctrlKey && e.key.toLowerCase() === 'z') {
97
+ saveableCanvas.current.undo();
98
+ }
99
+ });
100
+ } catch (error) {
101
+ console.error('Error in keydown ImageCanvasDraw Controls', error);
102
+ }
90
103
  }, []);
91
104
  useEffect(() => {
92
105
  if (saveableCanvas && saveableCanvas.current) {
@@ -132,8 +145,11 @@ export const ImageCanvasDraw = props => {
132
145
  showDownloadButton: showDownloadButton
133
146
  }), /*#__PURE__*/React.createElement(DrawerButtonOpenClose, null, /*#__PURE__*/React.createElement(ChevronLeftIcon, null))) : /*#__PURE__*/React.createElement("div", {
134
147
  className: "flex flex-row justify-end"
135
- }, /*#__PURE__*/React.createElement(DrawerButtonOpenClose, null, /*#__PURE__*/React.createElement(ChevronRightIcon, null))), state.width !== 0 && /*#__PURE__*/React.createElement("div", {
136
- className: "overflow-scroll"
148
+ }, /*#__PURE__*/React.createElement(DrawerButtonOpenClose, null, /*#__PURE__*/React.createElement(ChevronRightIcon, null))), state.width !== 0 && /*#__PURE__*/React.createElement(PCMScrollbar, {
149
+ className: "overflow-scroll",
150
+ style: {
151
+ maxHeight: '90vh'
152
+ }
137
153
  }, /*#__PURE__*/React.createElement(CanvasDraw, {
138
154
  className: "",
139
155
  ref: saveableCanvas,
@@ -0,0 +1,24 @@
1
+ import { height } from '@mui/system';
2
+ import React from 'react';
3
+ import ImageCanvasDraw from '../../Drawing/ImageCanvasDraw';
4
+ import { cedarShade } from '../../Drawing/ImageCanvasDraw/storybook/testMap.test';
5
+
6
+ const ScrollingInnerDiv = () => {
7
+ return /*#__PURE__*/React.createElement("div", {
8
+ style: {
9
+ backgroundColor: 'yellow',
10
+ padding: 24,
11
+ height: 200
12
+ }
13
+ }, /*#__PURE__*/React.createElement("div", {
14
+ style: {
15
+ backgroundColor: 'blue',
16
+ height: '100%',
17
+ overflow: 'scroll'
18
+ }
19
+ }, /*#__PURE__*/React.createElement(ImageCanvasDraw, {
20
+ b64DataUrl: cedarShade
21
+ }), "CONTENT TO HAVE TAKING UP THE ENTIRE PARENT DIV SPACE CONTENT TO HAVE TAKING UP THE ENTIRE PARENT DIV SPACE CONTENT TO HAVE TAKING UP THE ENTIRE PARENT DIV SPACE CONTENT TO HAVE TAKING UP THE ENTIRE PARENT DIV SPACE CONTENT TO HAVE TAKING UP THE ENTIRE PARENT DIV SPACE CONTENT TO HAVE TAKING UP THE ENTIRE PARENT DIV SPACE CONTENT TO HAVE TAKING UP THE ENTIRE PARENT DIV SPACE CONTENT TO HAVE TAKING UP THE ENTIRE PARENT DIV SPACE CONTENT TO HAVE TAKING UP THE ENTIRE PARENT DIV SPACE CONTENT TO HAVE TAKING UP THE ENTIRE PARENT DIV SPACE CONTENT TO HAVE TAKING UP THE ENTIRE PARENT DIV SPACE CONTENT TO HAVE TAKING UP THE ENTIRE PARENT DIV SPACE CONTENT TO HAVE TAKING UP THE ENTIRE PARENT DIV SPACE CONTENT TO HAVE TAKING UP THE ENTIRE PARENT DIV SPACE CONTENT TO HAVE TAKING UP THE ENTIRE PARENT DIV SPACE CONTENT TO HAVE TAKING UP THE ENTIRE PARENT DIV SPACE CONTENT TO HAVE TAKING UP THE ENTIRE PARENT DIV SPACE CONTENT TO HAVE TAKING UP THE ENTIRE PARENT DIV SPACE CONTENT TO HAVE TAKING UP THE ENTIRE PARENT DIV SPACE CONTENT TO HAVE TAKING UP THE ENTIRE PARENT DIV SPACE CONTENT TO HAVE TAKING UP THE ENTIRE PARENT DIV SPACE"));
22
+ };
23
+
24
+ export default ScrollingInnerDiv;
@@ -10,23 +10,27 @@ export const PCMScrollbar = props => {
10
10
  const {
11
11
  children,
12
12
  className,
13
- enable
13
+ enable,
14
+ style
14
15
  } = props;
15
16
  return /*#__PURE__*/React.createElement(PerfectScrollbar, {
16
17
  key: props.id,
17
18
  className: clsx(className),
18
19
  style: enable && !isMobile ? {
19
20
  position: 'relative',
20
- overflow: 'hidden'
21
+ overflow: 'hidden',
22
+ ...style
21
23
  } : {}
22
24
  }, children);
23
25
  };
24
26
  export default PCMScrollbar;
25
27
  PCMScrollbar.propTypes = {
26
28
  className: PropTypes.any,
29
+ style: PropTypes.object,
27
30
  enable: PropTypes.bool
28
31
  };
29
32
  PCMScrollbar.defaultProps = {
30
33
  className: '',
34
+ style: {},
31
35
  enable: true
32
36
  };
@@ -0,0 +1,6 @@
1
+ export const rgbToHex = rgb => {
2
+ let alpha = Math.ceil(rgb.a * 255).toString(16);
3
+ alpha = alpha.length > 1 ? alpha : `0${alpha}`;
4
+ const hex = rgb ? (rgb.r | 1 << 8).toString(16).slice(1) + (rgb.g | 1 << 8).toString(16).slice(1) + (rgb.b | 1 << 8).toString(16).slice(1) + alpha : undefined;
5
+ return `#${hex}`;
6
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pcm-shared-components",
3
- "version": "0.0.63",
3
+ "version": "0.0.66",
4
4
  "private": false,
5
5
  "main": "dist/index.js",
6
6
  "babel": {