argous 1.2.217 → 1.2.218
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/components/index.d.ts +1 -10
- package/dist/components/index.js +1 -11
- package/lib/components/index.d.ts +1 -10
- package/lib/components/index.js +1 -11
- package/package.json +1 -2
- package/lib/components/Carousel/Carousel.d.ts +0 -71
- package/lib/components/Carousel/Carousel.js +0 -218
- package/lib/components/Carousel/index.d.ts +0 -2
- package/lib/components/Carousel/index.js +0 -1
- package/lib/components/TextToHtml/Cursor.js +0 -24
- package/lib/components/TextToHtml/TextStyles.js +0 -111
- package/lib/components/TextToHtml/TextToHtml.d.ts +0 -38
- package/lib/components/TextToHtml/TextToHtml.js +0 -463
- package/lib/components/TextToHtml/icons/resize_area.svg +0 -2
- package/lib/components/TextToHtml/index.d.ts +0 -2
- package/lib/components/TextToHtml/index.js +0 -1
- package/lib/components/TextToHtml/style.css +0 -40
- package/lib/components/TextToHtml/utils.js +0 -848
- package/lib/components/Zoom/Zoom.d.ts +0 -11
- package/lib/components/Zoom/Zoom.js +0 -56
- package/lib/components/Zoom/index.d.ts +0 -2
- package/lib/components/Zoom/index.js +0 -1
- package/lib/components/Zoom/style.css +0 -25
|
@@ -157,13 +157,4 @@ export { default as HalfGauge } from './HalfGauge';
|
|
|
157
157
|
export * from './HalfGauge';
|
|
158
158
|
|
|
159
159
|
export { default as UserCard } from './UserCard';
|
|
160
|
-
export * from './UserCard';
|
|
161
|
-
|
|
162
|
-
export { default as TextToHtml } from './TextToHtml';
|
|
163
|
-
export * from './TextToHtml';
|
|
164
|
-
|
|
165
|
-
export { default as Zoom } from './Zoom';
|
|
166
|
-
export * from './Zoom';
|
|
167
|
-
|
|
168
|
-
export { default as Carousel } from './Carousel';
|
|
169
|
-
export * from './Carousel';
|
|
160
|
+
export * from './UserCard';
|
package/dist/components/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
};
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
16
|
exports.AutoCompleteFavorites = exports.UtilAutoComplete = exports.ThreadLog = exports.TextArea = exports.Tabs = exports.TablePicker = exports.Stepper = exports.SimpleTable = exports.Select = exports.ProgressBar = exports.Programa = exports.Pagination = exports.OutputText = exports.OtpInput = exports.MultipleSelect = exports.MonthPicker = exports.ModalProvider = exports.MenuBar = exports.MaterialButton = exports.ListSelect = exports.InputTags = exports.Input = exports.ImageResizeButton = exports.ImageResize = exports.Highlight = exports.FormVisualizer = exports.FileUploader = exports.FilePreparer = exports.DropArea = exports.Compartilhar = exports.Collapse = exports.CartaoUsuario = exports.Calendar = exports.Cabecalho = exports.Button = exports.BarraFerramentas = exports.BarChart = exports.AutoComplete = exports.ArgousSimpleTable = exports.ArgousProgressBar = exports.ArgousPagination = exports.ArgousInput = exports.ArgousComplexTableToolbar = exports.ArgousComplexTableHead = exports.ArgousComplexTableBody = exports.ArgousComplexTable = exports.ArgousComplexPagination = exports.ArgousAvatar = exports.ArgousAction = exports.Alert = void 0;
|
|
17
|
-
exports.
|
|
17
|
+
exports.UserCard = exports.HalfGauge = exports.PercentageDisplay = void 0;
|
|
18
18
|
var Alert_1 = require("./Alert");
|
|
19
19
|
Object.defineProperty(exports, "Alert", { enumerable: true, get: function () { return __importDefault(Alert_1).default; } });
|
|
20
20
|
__exportStar(require("./Alert"), exports);
|
|
@@ -172,13 +172,3 @@ Object.defineProperty(exports, "HalfGauge", { enumerable: true, get: function ()
|
|
|
172
172
|
__exportStar(require("./HalfGauge"), exports);
|
|
173
173
|
var UserCard_1 = require("./UserCard");
|
|
174
174
|
Object.defineProperty(exports, "UserCard", { enumerable: true, get: function () { return __importDefault(UserCard_1).default; } });
|
|
175
|
-
__exportStar(require("./UserCard"), exports);
|
|
176
|
-
var TextToHtml_1 = require("./TextToHtml");
|
|
177
|
-
Object.defineProperty(exports, "TextToHtml", { enumerable: true, get: function () { return __importDefault(TextToHtml_1).default; } });
|
|
178
|
-
__exportStar(require("./TextToHtml"), exports);
|
|
179
|
-
var Zoom_1 = require("./Zoom");
|
|
180
|
-
Object.defineProperty(exports, "Zoom", { enumerable: true, get: function () { return __importDefault(Zoom_1).default; } });
|
|
181
|
-
__exportStar(require("./Zoom"), exports);
|
|
182
|
-
var Carousel_1 = require("./Carousel");
|
|
183
|
-
Object.defineProperty(exports, "Carousel", { enumerable: true, get: function () { return __importDefault(Carousel_1).default; } });
|
|
184
|
-
__exportStar(require("./Carousel"), exports);
|
|
@@ -157,13 +157,4 @@ export { default as HalfGauge } from './HalfGauge';
|
|
|
157
157
|
export * from './HalfGauge';
|
|
158
158
|
|
|
159
159
|
export { default as UserCard } from './UserCard';
|
|
160
|
-
export * from './UserCard';
|
|
161
|
-
|
|
162
|
-
export { default as TextToHtml } from './TextToHtml';
|
|
163
|
-
export * from './TextToHtml';
|
|
164
|
-
|
|
165
|
-
export { default as Zoom } from './Zoom';
|
|
166
|
-
export * from './Zoom';
|
|
167
|
-
|
|
168
|
-
export { default as Carousel } from './Carousel';
|
|
169
|
-
export * from './Carousel';
|
|
160
|
+
export * from './UserCard';
|
package/lib/components/index.js
CHANGED
|
@@ -154,14 +154,4 @@ export * from './PercentageDisplay';
|
|
|
154
154
|
export { default as HalfGauge } from './HalfGauge';
|
|
155
155
|
export * from './HalfGauge';
|
|
156
156
|
|
|
157
|
-
export { default as UserCard } from './UserCard';
|
|
158
|
-
export * from './UserCard';
|
|
159
|
-
|
|
160
|
-
export { default as TextToHtml } from './TextToHtml';
|
|
161
|
-
export * from './TextToHtml';
|
|
162
|
-
|
|
163
|
-
export { default as Zoom } from './Zoom';
|
|
164
|
-
export * from './Zoom';
|
|
165
|
-
|
|
166
|
-
export { default as Carousel } from './Carousel';
|
|
167
|
-
export * from './Carousel';
|
|
157
|
+
export { default as UserCard } from './UserCard';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "argous",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.218",
|
|
4
4
|
"description": "Argous.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"author": "Carlos Schneider",
|
|
@@ -98,7 +98,6 @@
|
|
|
98
98
|
"dependencies": {
|
|
99
99
|
"highlight.js": "^10.7.1",
|
|
100
100
|
"jquery": "^3.6.0",
|
|
101
|
-
"react-colorful": "^5.6.1",
|
|
102
101
|
"react-date-range": "0.9.4",
|
|
103
102
|
"react-paginate": "^7.1.2",
|
|
104
103
|
"react-transition-group": "^4.4.1",
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
export interface CarouselProps {
|
|
2
|
-
/**
|
|
3
|
-
* ID
|
|
4
|
-
*/
|
|
5
|
-
id: string,
|
|
6
|
-
/**
|
|
7
|
-
* Left icon
|
|
8
|
-
*/
|
|
9
|
-
leftIcon?: SVGElement,
|
|
10
|
-
/**
|
|
11
|
-
* Right icon
|
|
12
|
-
*/
|
|
13
|
-
rightIcon?: SVGElement,
|
|
14
|
-
/**
|
|
15
|
-
* Number to represent the icon size in pixels
|
|
16
|
-
*/
|
|
17
|
-
iconSize?: number,
|
|
18
|
-
/**
|
|
19
|
-
* Value of scroll sensitivity
|
|
20
|
-
*/
|
|
21
|
-
scrollSensitivity?: number,
|
|
22
|
-
/**
|
|
23
|
-
* Number to represent the item spacing in pixels
|
|
24
|
-
*/
|
|
25
|
-
itemSpacing?: number,
|
|
26
|
-
/**
|
|
27
|
-
* Show buttons
|
|
28
|
-
*/
|
|
29
|
-
buttons?: boolean,
|
|
30
|
-
/**
|
|
31
|
-
* Show indicator
|
|
32
|
-
*/
|
|
33
|
-
indicator?: boolean,
|
|
34
|
-
/**
|
|
35
|
-
* Number to represent the indicator size in pixels
|
|
36
|
-
*/
|
|
37
|
-
indicatorSize?: number,
|
|
38
|
-
/**
|
|
39
|
-
* Number to represent the indicator gap in pixels
|
|
40
|
-
*/
|
|
41
|
-
indicatorGap?: number,
|
|
42
|
-
/**
|
|
43
|
-
* Number to represent the indicator padding in pixels
|
|
44
|
-
*/
|
|
45
|
-
indicatorPadding?: number,
|
|
46
|
-
/**
|
|
47
|
-
* Style to carousel element
|
|
48
|
-
*/
|
|
49
|
-
carouselStyle?: object,
|
|
50
|
-
/**
|
|
51
|
-
* Css class to button element
|
|
52
|
-
*/
|
|
53
|
-
buttonClassName?: string,
|
|
54
|
-
/**
|
|
55
|
-
* Css class to indicator element
|
|
56
|
-
*/
|
|
57
|
-
indicatorClassName?: string,
|
|
58
|
-
/**
|
|
59
|
-
* Css class to current indicator element
|
|
60
|
-
*/
|
|
61
|
-
currentIndicatorClassName?: string,
|
|
62
|
-
/**
|
|
63
|
-
* Function called on click
|
|
64
|
-
*/
|
|
65
|
-
onClick?: (event: Event) => void
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
declare function Carousel(props: CarouselProps) : JSX.Element
|
|
70
|
-
|
|
71
|
-
export default Carousel;
|
|
@@ -1,218 +0,0 @@
|
|
|
1
|
-
import { makeStyles } from '@material-ui/core';
|
|
2
|
-
import clsx from 'clsx';
|
|
3
|
-
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
4
|
-
import { IoIosArrowBack, IoIosArrowForward } from 'react-icons/io';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const useStyles = makeStyles(theme => ({
|
|
8
|
-
container: {
|
|
9
|
-
height: '100%',
|
|
10
|
-
width: '100%'
|
|
11
|
-
},
|
|
12
|
-
carouselContainer: {
|
|
13
|
-
width: '100%',
|
|
14
|
-
height: ({ indicator, indicatorPadding }) => (indicator) ? `calc(100% - ${indicatorPadding * 2}px)` : '100%',
|
|
15
|
-
minWidth: '100%',
|
|
16
|
-
display: 'flex',
|
|
17
|
-
alignItems: 'center'
|
|
18
|
-
},
|
|
19
|
-
carousel: {
|
|
20
|
-
width: '100%',
|
|
21
|
-
height: '100%',
|
|
22
|
-
margin: 'auto',
|
|
23
|
-
display: 'flex',
|
|
24
|
-
alignItems: 'center',
|
|
25
|
-
flexDirection: 'row',
|
|
26
|
-
overflow: 'hidden',
|
|
27
|
-
scrollBehavior: 'smooth',
|
|
28
|
-
'&>*:not(:last-child)': {
|
|
29
|
-
marginRight: ({ itemSpacing }) => (itemSpacing || '')
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
button: {
|
|
33
|
-
display: 'flex',
|
|
34
|
-
alignItems: 'center',
|
|
35
|
-
cursor: 'pointer',
|
|
36
|
-
border: 0,
|
|
37
|
-
padding: 0,
|
|
38
|
-
backgroundColor: '#0000',
|
|
39
|
-
color: (theme.palette.type === 'light') ? 'rgba(0, 0, 0, .4)' : 'rgba(255, 255, 255, .5)',
|
|
40
|
-
'&:hover': {
|
|
41
|
-
color: (theme.palette.type === 'light') ? 'rgba(0, 0, 0, .6)' : 'rgba(255, 255, 255, .8)'
|
|
42
|
-
},
|
|
43
|
-
'&:disabled': {
|
|
44
|
-
color: (theme.palette.type === 'light') ? 'rgba(0, 0, 0, .23)' : 'rgba(255, 255, 255, .3)',
|
|
45
|
-
backgroundColor: 'transparent',
|
|
46
|
-
cursor: 'default',
|
|
47
|
-
pointerEvents: 'none'
|
|
48
|
-
}
|
|
49
|
-
},
|
|
50
|
-
leftButton: {
|
|
51
|
-
left: 0
|
|
52
|
-
},
|
|
53
|
-
rightButton: {
|
|
54
|
-
right: 0
|
|
55
|
-
},
|
|
56
|
-
indicator: {
|
|
57
|
-
display: 'flex',
|
|
58
|
-
flexWrap: 'wrap',
|
|
59
|
-
alignItems: 'center',
|
|
60
|
-
justifyContent: 'center',
|
|
61
|
-
gap: ({ indicatorGap }) => (indicatorGap || ''),
|
|
62
|
-
padding: ({ indicatorPadding, indicatorSize, iconSize }) => `${indicatorPadding - (indicatorSize / 2)}px ${iconSize}px`,
|
|
63
|
-
'& span': {
|
|
64
|
-
width: ({ indicatorSize }) => (indicatorSize || ''),
|
|
65
|
-
height: ({ indicatorSize }) => (indicatorSize || ''),
|
|
66
|
-
borderRadius: '50%',
|
|
67
|
-
backgroundColor: (theme.palette.type === 'light') ? 'rgba(0, 0, 0, .4)' : 'rgba(255, 255, 255, .5)',
|
|
68
|
-
transition: 'background-color 500ms'
|
|
69
|
-
}
|
|
70
|
-
},
|
|
71
|
-
currentIndicator: {
|
|
72
|
-
backgroundColor: (theme.palette.type === 'light') ? '#000 !important' : '#fff !important'
|
|
73
|
-
}
|
|
74
|
-
}));
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
const CAROUSEL_ID = 'carousel';
|
|
78
|
-
|
|
79
|
-
const initialState = {
|
|
80
|
-
position: 0,
|
|
81
|
-
indicatorArray: []
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
const Carousel = ({
|
|
86
|
-
id,
|
|
87
|
-
leftIcon: LEFT_ICON = IoIosArrowBack,
|
|
88
|
-
rightIcon: RIGHT_ICON = IoIosArrowForward,
|
|
89
|
-
iconSize = 20,
|
|
90
|
-
scrollSensitivity = 2,
|
|
91
|
-
itemSpacing = 6,
|
|
92
|
-
children,
|
|
93
|
-
buttons = true,
|
|
94
|
-
indicator = false,
|
|
95
|
-
indicatorSize = 6,
|
|
96
|
-
indicatorGap = 10,
|
|
97
|
-
indicatorPadding = 20,
|
|
98
|
-
carouselStyle,
|
|
99
|
-
onClick,
|
|
100
|
-
buttonClassName,
|
|
101
|
-
indicatorClassName,
|
|
102
|
-
currentIndicatorClassName
|
|
103
|
-
}) => {
|
|
104
|
-
|
|
105
|
-
const classes = useStyles({ itemSpacing, indicator, indicatorSize, indicatorGap, indicatorPadding, iconSize });
|
|
106
|
-
const [state, setState] = useState(initialState);
|
|
107
|
-
const { position, indicatorArray } = state;
|
|
108
|
-
const carousel = useRef(null);
|
|
109
|
-
const childWidth = carousel.current?.children?.[0]?.offsetWidth;
|
|
110
|
-
const disabledButtonsRef = useRef(false);
|
|
111
|
-
const carouselId = (id) ? id : CAROUSEL_ID;
|
|
112
|
-
const leftButtonId = `${carouselId}-left-button`;
|
|
113
|
-
const rightButtonId = `${carouselId}-right-button`;
|
|
114
|
-
|
|
115
|
-
const logicSetState = ({ type, field, value }) => setState(states => ({
|
|
116
|
-
...states,
|
|
117
|
-
[type]: (type && field) ? { ...states[type], [field]: value } : value
|
|
118
|
-
}));
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
const control = useCallback(e => {
|
|
122
|
-
if (disabledButtonsRef.current) return;
|
|
123
|
-
|
|
124
|
-
const childWidth = carousel.current?.children?.[0]?.offsetWidth;
|
|
125
|
-
const maxWidth = (childWidth * (carousel.current?.children?.length - 1));
|
|
126
|
-
const scrollLeft = carousel.current?.scrollLeft;
|
|
127
|
-
const leftButtonElement = document.getElementById(leftButtonId);
|
|
128
|
-
const rightButtonElement = document.getElementById(rightButtonId);
|
|
129
|
-
const childrenWidth = ((childWidth + itemSpacing) * carousel.current?.children?.length);
|
|
130
|
-
const childrenSmallerThanParent = (childrenWidth < carousel.current?.offsetWidth);
|
|
131
|
-
|
|
132
|
-
if (leftButtonElement) {
|
|
133
|
-
if ((scrollLeft === 0) || childrenSmallerThanParent) leftButtonElement.disabled = true;
|
|
134
|
-
else if (scrollLeft > 0) leftButtonElement.disabled = false;
|
|
135
|
-
}
|
|
136
|
-
if (rightButtonElement) {
|
|
137
|
-
if ((scrollLeft === maxWidth) || childrenSmallerThanParent) rightButtonElement.disabled = true;
|
|
138
|
-
else if (scrollLeft < maxWidth) rightButtonElement.disabled = false;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
(position === children.length) && logicSetState({ type: 'position', value: (children.length - 1) });
|
|
142
|
-
}, [itemSpacing, leftButtonId, rightButtonId, position, children.length]);
|
|
143
|
-
useEffect(() => control(), [control]);
|
|
144
|
-
control();
|
|
145
|
-
|
|
146
|
-
const createIndicatorArray = useCallback(() => {
|
|
147
|
-
const childrenLength = carousel.current?.children?.length;
|
|
148
|
-
const newIndicatorArray = Array.from(Array(childrenLength).keys());
|
|
149
|
-
logicSetState({ type: 'indicatorArray', value: newIndicatorArray });
|
|
150
|
-
}, []);
|
|
151
|
-
useEffect(() => (indicator) && createIndicatorArray(), [indicator, children, createIndicatorArray]);
|
|
152
|
-
|
|
153
|
-
const handleCarouselClick = (e, direction) => {
|
|
154
|
-
if (!childWidth || (typeof childWidth !== 'number')) return;
|
|
155
|
-
|
|
156
|
-
let newPosition = position;
|
|
157
|
-
const scrollWidth = (childWidth * scrollSensitivity);
|
|
158
|
-
const leftButtonElement = document.getElementById(leftButtonId);
|
|
159
|
-
const rightButtonElement = document.getElementById(rightButtonId);
|
|
160
|
-
|
|
161
|
-
leftButtonElement.disabled = true;
|
|
162
|
-
rightButtonElement.disabled = true;
|
|
163
|
-
disabledButtonsRef.current = true;
|
|
164
|
-
|
|
165
|
-
if (direction === 'right') {
|
|
166
|
-
(carousel.current.scrollLeft += scrollWidth);
|
|
167
|
-
(position < (indicatorArray.length - 1)) && logicSetState({ type: 'position', value: (newPosition += 1) });
|
|
168
|
-
} else {
|
|
169
|
-
(carousel.current.scrollLeft -= scrollWidth);
|
|
170
|
-
(position > 0) && logicSetState({ type: 'position', value: (newPosition -= 1) });
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
(onClick && (typeof onClick === 'function')) && onClick(e);
|
|
174
|
-
setTimeout(() => {
|
|
175
|
-
leftButtonElement.disabled = false;
|
|
176
|
-
rightButtonElement.disabled = false;
|
|
177
|
-
disabledButtonsRef.current = false;
|
|
178
|
-
control();
|
|
179
|
-
}, ((childWidth <= 500) ? 500 : (childWidth * ((childWidth > 1000) ? 0.6 : 0.9)) || 500));
|
|
180
|
-
};
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
return <div id={carouselId} className={classes.container}>
|
|
184
|
-
<div className={classes.carouselContainer}>
|
|
185
|
-
{(buttons && LEFT_ICON) && (
|
|
186
|
-
<button id={leftButtonId} onClick={(e) => handleCarouselClick(e, 'left')} className={clsx(classes.button, classes.leftButton, buttonClassName)}>
|
|
187
|
-
<LEFT_ICON size={iconSize} className={classes.leftButton} />
|
|
188
|
-
</button>
|
|
189
|
-
)}
|
|
190
|
-
<div ref={carousel} style={{ ...carouselStyle }} className={classes.carousel}>
|
|
191
|
-
{children}
|
|
192
|
-
</div>
|
|
193
|
-
{(buttons && RIGHT_ICON) && (
|
|
194
|
-
<button id={rightButtonId} onClick={(e) => handleCarouselClick(e, 'right')} className={clsx(classes.button, classes.rightButton, buttonClassName)}>
|
|
195
|
-
<RIGHT_ICON size={iconSize} className={classes.rightButton} />
|
|
196
|
-
</button>
|
|
197
|
-
)}
|
|
198
|
-
</div>
|
|
199
|
-
{(indicator) && (
|
|
200
|
-
<div className={clsx(classes.indicator, indicatorClassName)}>
|
|
201
|
-
{indicatorArray.map((_, index) => (
|
|
202
|
-
<span
|
|
203
|
-
key={`indicator-${index}`}
|
|
204
|
-
className={
|
|
205
|
-
clsx({
|
|
206
|
-
[classes.currentIndicator]: (position === index),
|
|
207
|
-
[currentIndicatorClassName]: (position === index)
|
|
208
|
-
})
|
|
209
|
-
}
|
|
210
|
-
/>
|
|
211
|
-
))}
|
|
212
|
-
</div>
|
|
213
|
-
)}
|
|
214
|
-
</div>;
|
|
215
|
-
};
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
export default Carousel;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from './Carousel';
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useRef } from 'react';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const Cursor = ({ id, speed = 500, className }) => {
|
|
5
|
-
|
|
6
|
-
const cursorId = `${id}-cursor-component`;
|
|
7
|
-
const intervalIdRef = useRef(null);
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
useEffect(() => {
|
|
11
|
-
const cursorElement = document.getElementById(cursorId);
|
|
12
|
-
if (cursorElement) cursorElement.style.opacity = '1';
|
|
13
|
-
intervalIdRef.current = setInterval(() => {
|
|
14
|
-
if (cursorElement) cursorElement.style.opacity = (cursorElement.style.opacity === '0') ? '1' : '0';
|
|
15
|
-
}, speed);
|
|
16
|
-
return () => clearInterval(intervalIdRef.current);
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return <span id={cursorId} className={`${className}`}>|</span>;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
export default Cursor;
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import { ClickAwayListener, IconButton, makeStyles } from '@material-ui/core';
|
|
2
|
-
import React, { useState } from 'react';
|
|
3
|
-
import { RgbaColorPicker } from 'react-colorful';
|
|
4
|
-
import { RiAlignCenter, RiAlignJustify, RiAlignLeft, RiAlignRight, RiFontColor, RiFontSize } from 'react-icons/ri';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const ICON_SIZE = '2.5rem';
|
|
8
|
-
const BOX_SHADOW = 'rgba(0, 0, 0, 0.3) 0px 1px 12px -2px';
|
|
9
|
-
|
|
10
|
-
const useStyles = makeStyles(theme => ({
|
|
11
|
-
container: {
|
|
12
|
-
zIndex: 1,
|
|
13
|
-
position: 'absolute',
|
|
14
|
-
top: 0,
|
|
15
|
-
right: 0,
|
|
16
|
-
display: 'flex',
|
|
17
|
-
alignItems: 'flex-start',
|
|
18
|
-
justifyContent: 'flex-end',
|
|
19
|
-
gap: ({ defaultSpacing }) => (defaultSpacing) ? defaultSpacing : ''
|
|
20
|
-
},
|
|
21
|
-
button: {
|
|
22
|
-
padding: ({ defaultSpacing }) => (defaultSpacing) ? (defaultSpacing / 2) : '',
|
|
23
|
-
color: `rgba(${(theme.palette.type === 'light') ? '0, 0, 0' : '255, 255, 255'}, .7)`,
|
|
24
|
-
backgroundColor: `rgba(${(theme.palette.type === 'light') ? '255, 255, 255' : '0, 0, 0'}, .5)`,
|
|
25
|
-
'&:hover': {
|
|
26
|
-
backgroundColor: `rgba(${(theme.palette.type === 'light') ? '255, 255, 255' : '0, 0, 0'}, .7)`
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
colorPickerContainer: {
|
|
30
|
-
zIndex: 2,
|
|
31
|
-
position: 'absolute',
|
|
32
|
-
padding: '2rem'
|
|
33
|
-
},
|
|
34
|
-
colorPickerBoxShadow: {
|
|
35
|
-
borderRadius: 8,
|
|
36
|
-
webKitBoxShadow: BOX_SHADOW,
|
|
37
|
-
mozBoxShadow: BOX_SHADOW,
|
|
38
|
-
boxShadow: BOX_SHADOW
|
|
39
|
-
}
|
|
40
|
-
}));
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const initialStateOpen = {
|
|
44
|
-
colorPicker: undefined
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
const initialState = {
|
|
48
|
-
open: initialStateOpen
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const TextStyles = ({ color, setColor, defaultSpacing, toggleClickAway, handleFontSizeChange, textAlign, handleTextAlignChange }) => {
|
|
53
|
-
|
|
54
|
-
const classes = useStyles({ defaultSpacing });
|
|
55
|
-
const [state, setState] = useState(initialState);
|
|
56
|
-
const { open } = state;
|
|
57
|
-
|
|
58
|
-
const logicSetState = (type, field, value) => setState(values => ({
|
|
59
|
-
...values,
|
|
60
|
-
[type]: (type && field) ? { ...values[type], [field]: value } : value
|
|
61
|
-
}));
|
|
62
|
-
|
|
63
|
-
const handleColorPickerOpen = e => {
|
|
64
|
-
toggleClickAway();
|
|
65
|
-
const elRect = e.target.parentElement.getBoundingClientRect();
|
|
66
|
-
logicSetState('open', 'colorPicker', elRect);
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
const handleColorPickerClose = e => {
|
|
70
|
-
toggleClickAway();
|
|
71
|
-
logicSetState('open', 'colorPicker', undefined);
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
return <div className={classes.container}>
|
|
76
|
-
<IconButton onClick={handleTextAlignChange} onTouchStart={handleTextAlignChange} className={classes.button}>
|
|
77
|
-
{(() => {
|
|
78
|
-
switch (textAlign) {
|
|
79
|
-
case 'start':
|
|
80
|
-
return <RiAlignLeft size={ICON_SIZE} />;
|
|
81
|
-
case 'end':
|
|
82
|
-
return <RiAlignRight size={ICON_SIZE} />;
|
|
83
|
-
case 'center':
|
|
84
|
-
return <RiAlignCenter size={ICON_SIZE} />;
|
|
85
|
-
case 'justify':
|
|
86
|
-
return <RiAlignJustify size={ICON_SIZE} />;
|
|
87
|
-
default:
|
|
88
|
-
return null;
|
|
89
|
-
}
|
|
90
|
-
})()}
|
|
91
|
-
</IconButton>
|
|
92
|
-
<IconButton onClick={handleColorPickerOpen} onTouchStart={handleColorPickerOpen} className={classes.button}>
|
|
93
|
-
<RiFontColor size={ICON_SIZE} />
|
|
94
|
-
</IconButton>
|
|
95
|
-
<IconButton onClick={handleFontSizeChange} onTouchStart={handleFontSizeChange} className={classes.button}>
|
|
96
|
-
<RiFontSize size={ICON_SIZE} />
|
|
97
|
-
</IconButton>
|
|
98
|
-
{(!!open.colorPicker) && (
|
|
99
|
-
<ClickAwayListener disableReactTree onClickAway={handleColorPickerClose}>
|
|
100
|
-
<div className={classes.colorPickerContainer}>
|
|
101
|
-
<div className={classes.colorPickerBoxShadow}>
|
|
102
|
-
<RgbaColorPicker color={color} onChange={setColor} />
|
|
103
|
-
</div>
|
|
104
|
-
</div>
|
|
105
|
-
</ClickAwayListener>
|
|
106
|
-
)}
|
|
107
|
-
</div>;
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
export default TextStyles;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
export interface TextToHtmlInitialValue {
|
|
2
|
-
text?: string,
|
|
3
|
-
cssText?: string
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
export interface TextToHtmlProps {
|
|
7
|
-
/**
|
|
8
|
-
* Object containing properties to use as initial value
|
|
9
|
-
*/
|
|
10
|
-
initialValue?: TextToHtmlInitialValue,
|
|
11
|
-
/**
|
|
12
|
-
* Function called on change
|
|
13
|
-
* @param htmlString
|
|
14
|
-
* @returns
|
|
15
|
-
*/
|
|
16
|
-
onChange?: (htmlString: string) => void,
|
|
17
|
-
/**
|
|
18
|
-
* Function called on delete
|
|
19
|
-
* @param event
|
|
20
|
-
* @param deleted
|
|
21
|
-
* @param newCharacters
|
|
22
|
-
* @returns
|
|
23
|
-
*/
|
|
24
|
-
onDelete?: (event: Event, deleted: object, newCharacters: Array<object>) => void,
|
|
25
|
-
/**
|
|
26
|
-
* Number to represent the default spacing in pixels
|
|
27
|
-
*/
|
|
28
|
-
defaultSpacing?: number,
|
|
29
|
-
/**
|
|
30
|
-
* Function called to set external values
|
|
31
|
-
*/
|
|
32
|
-
setExternalValues?: (state: object) => void
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
declare function TextToHtml(props: TextToHtmlProps) : JSX.Element
|
|
37
|
-
|
|
38
|
-
export default TextToHtml;
|