carbon-react 121.0.2 → 121.2.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/esm/__internal__/character-count/character-count.style.js +4 -8
- package/esm/components/heading/heading.style.d.ts +1 -1
- package/esm/components/text-editor/__internal__/editor-validation-wrapper/editor-validation-wrapper.component.d.ts +11 -0
- package/esm/components/text-editor/__internal__/editor-validation-wrapper/editor-validation-wrapper.component.js +18 -0
- package/esm/components/text-editor/__internal__/editor-validation-wrapper/editor-validation-wrapper.style.d.ts +2 -0
- package/esm/components/text-editor/__internal__/editor-validation-wrapper/editor-validation-wrapper.style.js +11 -0
- package/esm/components/text-editor/__internal__/editor-validation-wrapper/index.d.ts +2 -0
- package/esm/components/text-editor/__internal__/editor-validation-wrapper/index.js +1 -0
- package/esm/components/text-editor/text-editor.component.d.ts +2 -0
- package/esm/components/text-editor/text-editor.component.js +48 -12
- package/esm/components/typography/typography.component.d.ts +4 -2
- package/esm/components/typography/typography.component.js +3 -1
- package/esm/components/typography/typography.style.js +5 -0
- package/lib/__internal__/character-count/character-count.style.js +4 -8
- package/lib/components/heading/heading.style.d.ts +1 -1
- package/lib/components/text-editor/__internal__/editor-validation-wrapper/editor-validation-wrapper.component.d.ts +11 -0
- package/lib/components/text-editor/__internal__/{editor-counter/editor-counter.component.js → editor-validation-wrapper/editor-validation-wrapper.component.js} +7 -11
- package/lib/components/text-editor/__internal__/editor-validation-wrapper/editor-validation-wrapper.style.d.ts +2 -0
- package/lib/components/text-editor/__internal__/editor-validation-wrapper/editor-validation-wrapper.style.js +19 -0
- package/lib/components/text-editor/__internal__/editor-validation-wrapper/index.d.ts +2 -0
- package/lib/components/text-editor/__internal__/{editor-counter → editor-validation-wrapper}/index.js +2 -2
- package/lib/components/text-editor/__internal__/{editor-counter → editor-validation-wrapper}/package.json +1 -1
- package/lib/components/text-editor/text-editor.component.d.ts +2 -0
- package/lib/components/text-editor/text-editor.component.js +46 -10
- package/lib/components/typography/typography.component.d.ts +4 -2
- package/lib/components/typography/typography.component.js +3 -1
- package/lib/components/typography/typography.style.js +5 -0
- package/package.json +1 -1
- package/esm/components/text-editor/__internal__/editor-counter/editor-counter.component.d.ts +0 -15
- package/esm/components/text-editor/__internal__/editor-counter/editor-counter.component.js +0 -22
- package/esm/components/text-editor/__internal__/editor-counter/editor-counter.style.d.ts +0 -5
- package/esm/components/text-editor/__internal__/editor-counter/editor-counter.style.js +0 -18
- package/esm/components/text-editor/__internal__/editor-counter/index.d.ts +0 -2
- package/esm/components/text-editor/__internal__/editor-counter/index.js +0 -1
- package/lib/components/text-editor/__internal__/editor-counter/editor-counter.component.d.ts +0 -15
- package/lib/components/text-editor/__internal__/editor-counter/editor-counter.style.d.ts +0 -5
- package/lib/components/text-editor/__internal__/editor-counter/editor-counter.style.js +0 -26
- package/lib/components/text-editor/__internal__/editor-counter/index.d.ts +0 -2
|
@@ -3,14 +3,10 @@ import baseTheme from "../../style/themes/base";
|
|
|
3
3
|
import visuallyHidden from "../../style/utils/visually-hidden";
|
|
4
4
|
const StyledCharacterCountWrapper = styled.div``;
|
|
5
5
|
const StyledCharacterCount = styled.div`
|
|
6
|
-
::after {
|
|
7
|
-
content: " ";
|
|
8
|
-
}
|
|
9
|
-
|
|
10
6
|
text-align: left;
|
|
11
|
-
font-size:
|
|
12
|
-
margin-top:
|
|
13
|
-
margin-bottom:
|
|
7
|
+
font-size: var(--fontSizes100);
|
|
8
|
+
margin-top: var(--spacing050);
|
|
9
|
+
margin-bottom: var(--spacing050);
|
|
14
10
|
color: ${({
|
|
15
11
|
isOverLimit
|
|
16
12
|
}) => isOverLimit ? "var(--colorsSemanticNegative500)" : "var(--colorsUtilityYin055)"};
|
|
@@ -18,7 +14,7 @@ const StyledCharacterCount = styled.div`
|
|
|
18
14
|
${({
|
|
19
15
|
isOverLimit
|
|
20
16
|
}) => isOverLimit && css`
|
|
21
|
-
font-weight:
|
|
17
|
+
font-weight: var(--fontWeights700);
|
|
22
18
|
`}
|
|
23
19
|
`;
|
|
24
20
|
const VisuallyHiddenCharacterCount = styled.div`
|
|
@@ -12,7 +12,7 @@ declare type StyledHeadingTitleProps = {
|
|
|
12
12
|
withMargin?: boolean;
|
|
13
13
|
};
|
|
14
14
|
declare const StyledHeadingTitle: import("styled-components").StyledComponent<{
|
|
15
|
-
({ "data-component": dataComponent, variant, as, id, fontSize, fontWeight, textTransform, lineHeight, textDecoration, display, listStyleType, whiteSpace, wordWrap, textOverflow, truncate, color, backgroundColor, bg, opacity, children, className, screenReaderOnly, ...rest }: import("../typography").TypographyProps): import("react").JSX.Element;
|
|
15
|
+
({ "data-component": dataComponent, variant, as, id, fontSize, fontWeight, textTransform, lineHeight, textDecoration, display, listStyleType, whiteSpace, wordWrap, textAlign, textOverflow, truncate, color, backgroundColor, bg, opacity, children, className, screenReaderOnly, ...rest }: import("../typography").TypographyProps): import("react").JSX.Element;
|
|
16
16
|
displayName: string;
|
|
17
17
|
}, any, StyledHeadingTitleProps, never>;
|
|
18
18
|
declare const StyledHeadingPills: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface EditorValidationWrapperProps {
|
|
3
|
+
/** Message to be displayed when there is an error */
|
|
4
|
+
error?: string;
|
|
5
|
+
/** Message to be displayed when there is a warning */
|
|
6
|
+
warning?: string;
|
|
7
|
+
/** Message to be displayed when there is an info */
|
|
8
|
+
info?: string;
|
|
9
|
+
}
|
|
10
|
+
declare const ValidationWrapper: ({ error, warning, info, }: EditorValidationWrapperProps) => React.JSX.Element;
|
|
11
|
+
export default ValidationWrapper;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import PropTypes from "prop-types";
|
|
3
|
+
import StyledValidationWrapper from "./editor-validation-wrapper.style";
|
|
4
|
+
import ValidationIcon from "../../../../__internal__/validations";
|
|
5
|
+
const ValidationWrapper = ({
|
|
6
|
+
error,
|
|
7
|
+
warning,
|
|
8
|
+
info
|
|
9
|
+
}) => /*#__PURE__*/React.createElement(StyledValidationWrapper, {
|
|
10
|
+
"data-component": "text-editor-validation-wrapper"
|
|
11
|
+
}, /*#__PURE__*/React.createElement(ValidationIcon, {
|
|
12
|
+
error: error,
|
|
13
|
+
warning: warning,
|
|
14
|
+
info: info,
|
|
15
|
+
tooltipPosition: "top",
|
|
16
|
+
tabIndex: 0
|
|
17
|
+
}));
|
|
18
|
+
export default ValidationWrapper;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
const StyledValidationWrapper = styled.div`
|
|
3
|
+
margin: var(--spacing200) var(--spacing200) var(--spacing000)
|
|
4
|
+
var(--spacing050);
|
|
5
|
+
min-width: var(--sizing500);
|
|
6
|
+
height: var(--sizing275);
|
|
7
|
+
display: flex;
|
|
8
|
+
float: right;
|
|
9
|
+
align-items: center;
|
|
10
|
+
`;
|
|
11
|
+
export default StyledValidationWrapper;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./editor-validation-wrapper.component";
|
|
@@ -30,6 +30,8 @@ export interface TextEditorProps extends MarginProps {
|
|
|
30
30
|
previews?: React.ReactNode;
|
|
31
31
|
/** Callback to report a url when a link is added */
|
|
32
32
|
onLinkAdded?: (url: string) => void;
|
|
33
|
+
/** Hint text to be rendered when validationRedesignOptIn flag is set */
|
|
34
|
+
inputHint?: string;
|
|
33
35
|
}
|
|
34
36
|
export declare const TextEditor: React.ForwardRefExoticComponent<TextEditorProps & React.RefAttributes<Editor>>;
|
|
35
37
|
export declare const TextEditorState: typeof EditorState;
|
|
@@ -1,15 +1,21 @@
|
|
|
1
|
-
import React, { useCallback, useEffect, useRef, useState } from "react";
|
|
1
|
+
import React, { useCallback, useEffect, useRef, useState, useContext } from "react";
|
|
2
2
|
import PropTypes from "prop-types";
|
|
3
3
|
import { ContentState, EditorState, RichUtils, getDefaultKeyBinding, Modifier, Editor } from "draft-js";
|
|
4
4
|
import { computeBlockType, getContent, getContentInfo, getDecoratedValue, getSelectedLength, moveSelectionToEnd, resetBlockType, isASCIIChar, replaceText, hasInlineStyle, hasBlockStyle, blockStyleFn } from "./__internal__/utils";
|
|
5
5
|
import { StyledEditorWrapper, StyledEditorOutline, StyledEditorContainer } from "./text-editor.style";
|
|
6
|
-
import
|
|
6
|
+
import ValidationWrapper from "./__internal__/editor-validation-wrapper";
|
|
7
7
|
import Toolbar from "./__internal__/toolbar";
|
|
8
8
|
import Label from "../../__internal__/label";
|
|
9
9
|
import Events from "../../__internal__/utils/helpers/events";
|
|
10
|
-
import
|
|
10
|
+
import guid from "../../__internal__/utils/helpers/guid";
|
|
11
11
|
import LabelWrapper from "./__internal__/label-wrapper";
|
|
12
12
|
import { BOLD, ITALIC, UNORDERED_LIST, ORDERED_LIST } from "./types";
|
|
13
|
+
import { NewValidationContext } from "../carbon-provider/carbon-provider.component";
|
|
14
|
+
import { ErrorBorder, StyledHintText } from "../textbox/textbox.style";
|
|
15
|
+
import ValidationMessage from "../../__internal__/validation-message";
|
|
16
|
+
import useInputAccessibility from "../../hooks/__internal__/useInputAccessibility";
|
|
17
|
+
import Box from "../box";
|
|
18
|
+
import useCharacterCount from "../../hooks/__internal__/useCharacterCount";
|
|
13
19
|
const NUMBERS = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"];
|
|
14
20
|
const INLINE_STYLES = [BOLD, ITALIC];
|
|
15
21
|
export const EditorContext = /*#__PURE__*/React.createContext({});
|
|
@@ -26,8 +32,12 @@ const TextEditor = /*#__PURE__*/React.forwardRef(({
|
|
|
26
32
|
rows,
|
|
27
33
|
previews,
|
|
28
34
|
onLinkAdded,
|
|
35
|
+
inputHint,
|
|
29
36
|
...rest
|
|
30
37
|
}, ref) => {
|
|
38
|
+
const {
|
|
39
|
+
validationRedesignOptIn
|
|
40
|
+
} = useContext(NewValidationContext);
|
|
31
41
|
const [isFocused, setIsFocused] = useState(false);
|
|
32
42
|
const [inlines, setInlines] = useState([]);
|
|
33
43
|
const [activeInlines, setActiveInlines] = useState({});
|
|
@@ -37,7 +47,24 @@ const TextEditor = /*#__PURE__*/React.forwardRef(({
|
|
|
37
47
|
const contentLength = getContent(value).getPlainText("").length;
|
|
38
48
|
const moveCursor = useRef(contentLength > 0);
|
|
39
49
|
const lastKeyPressed = useRef();
|
|
40
|
-
const
|
|
50
|
+
const inputHintId = useRef(`${guid()}-hint`);
|
|
51
|
+
const {
|
|
52
|
+
current: id
|
|
53
|
+
} = useRef(guid());
|
|
54
|
+
const {
|
|
55
|
+
labelId,
|
|
56
|
+
validationId,
|
|
57
|
+
ariaDescribedBy
|
|
58
|
+
} = useInputAccessibility({
|
|
59
|
+
id,
|
|
60
|
+
validationRedesignOptIn,
|
|
61
|
+
error,
|
|
62
|
+
warning,
|
|
63
|
+
info,
|
|
64
|
+
label: labelText
|
|
65
|
+
});
|
|
66
|
+
const [characterCount, visuallyHiddenHintId] = useCharacterCount(getContent(value).getPlainText(""), characterLimit);
|
|
67
|
+
const combinedAriaDescribedBy = [ariaDescribedBy, inputHint ? inputHintId.current : undefined, visuallyHiddenHintId].filter(Boolean).join(" ");
|
|
41
68
|
if (rows && (typeof rows !== "number" || rows < 2)) {
|
|
42
69
|
// eslint-disable-next-line no-console
|
|
43
70
|
console.warn(`Prop rows must be a number value that is 2 or greater to override the min-height of the \`${TextEditor.displayName}\``);
|
|
@@ -223,9 +250,19 @@ const TextEditor = /*#__PURE__*/React.forwardRef(({
|
|
|
223
250
|
}, /*#__PURE__*/React.createElement(StyledEditorWrapper, rest, /*#__PURE__*/React.createElement(LabelWrapper, {
|
|
224
251
|
onClick: () => handleEditorFocus(true)
|
|
225
252
|
}, /*#__PURE__*/React.createElement(Label, {
|
|
226
|
-
labelId: labelId
|
|
253
|
+
labelId: labelId,
|
|
227
254
|
isRequired: required
|
|
228
|
-
}, labelText)), /*#__PURE__*/React.createElement(
|
|
255
|
+
}, labelText)), inputHint && /*#__PURE__*/React.createElement(StyledHintText, {
|
|
256
|
+
id: inputHintId.current
|
|
257
|
+
}, inputHint), /*#__PURE__*/React.createElement(Box, {
|
|
258
|
+
position: "relative"
|
|
259
|
+
}, validationRedesignOptIn && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ValidationMessage, {
|
|
260
|
+
error: error,
|
|
261
|
+
validationId: validationId,
|
|
262
|
+
warning: warning
|
|
263
|
+
}), (error || warning) && /*#__PURE__*/React.createElement(ErrorBorder, {
|
|
264
|
+
warning: !!(!error && warning)
|
|
265
|
+
})), /*#__PURE__*/React.createElement(StyledEditorOutline, {
|
|
229
266
|
isFocused: isFocused,
|
|
230
267
|
hasError: !!error
|
|
231
268
|
}, /*#__PURE__*/React.createElement(StyledEditorContainer, {
|
|
@@ -233,9 +270,7 @@ const TextEditor = /*#__PURE__*/React.forwardRef(({
|
|
|
233
270
|
hasError: !!error,
|
|
234
271
|
rows: rows,
|
|
235
272
|
hasPreview: !!React.Children.count(previews)
|
|
236
|
-
}, /*#__PURE__*/React.createElement(
|
|
237
|
-
limit: characterLimit,
|
|
238
|
-
count: contentLength,
|
|
273
|
+
}, !validationRedesignOptIn && (error || warning || info) && /*#__PURE__*/React.createElement(ValidationWrapper, {
|
|
239
274
|
error: error,
|
|
240
275
|
warning: warning,
|
|
241
276
|
info: info
|
|
@@ -248,8 +283,8 @@ const TextEditor = /*#__PURE__*/React.forwardRef(({
|
|
|
248
283
|
handleBeforeInput: handleBeforeInput,
|
|
249
284
|
handlePastedText: handlePastedText,
|
|
250
285
|
handleKeyCommand: handleKeyCommand,
|
|
251
|
-
ariaLabelledBy: labelId
|
|
252
|
-
ariaDescribedBy:
|
|
286
|
+
ariaLabelledBy: labelId,
|
|
287
|
+
ariaDescribedBy: combinedAriaDescribedBy,
|
|
253
288
|
blockStyleFn: blockStyleFn,
|
|
254
289
|
keyBindingFn: keyBindingFn,
|
|
255
290
|
tabIndex: 0
|
|
@@ -270,12 +305,13 @@ const TextEditor = /*#__PURE__*/React.forwardRef(({
|
|
|
270
305
|
activeControls: activeControls,
|
|
271
306
|
canFocus: focusToolbar,
|
|
272
307
|
toolbarElements: toolbarElements
|
|
273
|
-
})))));
|
|
308
|
+
}))), characterCount)));
|
|
274
309
|
});
|
|
275
310
|
TextEditor.propTypes = {
|
|
276
311
|
"characterLimit": PropTypes.number,
|
|
277
312
|
"error": PropTypes.string,
|
|
278
313
|
"info": PropTypes.string,
|
|
314
|
+
"inputHint": PropTypes.string,
|
|
279
315
|
"labelText": PropTypes.string.isRequired,
|
|
280
316
|
"m": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
281
317
|
"__@toStringTag": PropTypes.string.isRequired,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { SpaceProps } from "styled-system";
|
|
3
3
|
import { TagProps } from "../../__internal__/utils/helpers/tags";
|
|
4
|
-
declare const VARIANT_TYPES: readonly ["h1-large", "h1", "h2", "h3", "h4", "h5", "segment-header", "segment-header-small", "segment-subheader", "segment-subheader-alt", "p", "small", "big", "sup", "sub", "strong", "b", "em", "ul", "ol"];
|
|
4
|
+
declare const VARIANT_TYPES: readonly ["h1-large", "h1", "h2", "h3", "h4", "h5", "segment-header", "segment-header-small", "segment-subheader", "segment-subheader-alt", "p", "span", "small", "big", "sup", "sub", "strong", "b", "em", "ul", "ol"];
|
|
5
5
|
export declare type VariantTypes = typeof VARIANT_TYPES[number];
|
|
6
6
|
export interface TypographyProps extends SpaceProps, TagProps {
|
|
7
7
|
/** Override the variant component */
|
|
@@ -30,6 +30,8 @@ export interface TypographyProps extends SpaceProps, TagProps {
|
|
|
30
30
|
whiteSpace?: string;
|
|
31
31
|
/** Override the word-wrap */
|
|
32
32
|
wordWrap?: string;
|
|
33
|
+
/** Override the text-align */
|
|
34
|
+
textAlign?: string;
|
|
33
35
|
/** Override the text-overflow */
|
|
34
36
|
textOverflow?: string;
|
|
35
37
|
/** Apply truncation */
|
|
@@ -49,7 +51,7 @@ export interface TypographyProps extends SpaceProps, TagProps {
|
|
|
49
51
|
screenReaderOnly?: boolean;
|
|
50
52
|
}
|
|
51
53
|
export declare const Typography: {
|
|
52
|
-
({ "data-component": dataComponent, variant, as, id, fontSize, fontWeight, textTransform, lineHeight, textDecoration, display, listStyleType, whiteSpace, wordWrap, textOverflow, truncate, color, backgroundColor, bg, opacity, children, className, screenReaderOnly, ...rest }: TypographyProps): React.JSX.Element;
|
|
54
|
+
({ "data-component": dataComponent, variant, as, id, fontSize, fontWeight, textTransform, lineHeight, textDecoration, display, listStyleType, whiteSpace, wordWrap, textAlign, textOverflow, truncate, color, backgroundColor, bg, opacity, children, className, screenReaderOnly, ...rest }: TypographyProps): React.JSX.Element;
|
|
53
55
|
displayName: string;
|
|
54
56
|
};
|
|
55
57
|
export default Typography;
|
|
@@ -4,7 +4,7 @@ import PropTypes from "prop-types";
|
|
|
4
4
|
import tagComponent from "../../__internal__/utils/helpers/tags";
|
|
5
5
|
import { filterStyledSystemMarginProps, filterStyledSystemPaddingProps } from "../../style/utils";
|
|
6
6
|
import StyledTypography from "./typography.style";
|
|
7
|
-
const VARIANT_TYPES = ["h1-large", "h1", "h2", "h3", "h4", "h5", "segment-header", "segment-header-small", "segment-subheader", "segment-subheader-alt", "p", "small", "big", "sup", "sub", "strong", "b", "em", "ul", "ol"];
|
|
7
|
+
const VARIANT_TYPES = ["h1-large", "h1", "h2", "h3", "h4", "h5", "segment-header", "segment-header-small", "segment-subheader", "segment-subheader-alt", "p", "span", "small", "big", "sup", "sub", "strong", "b", "em", "ul", "ol"];
|
|
8
8
|
export const Typography = ({
|
|
9
9
|
"data-component": dataComponent,
|
|
10
10
|
variant = "p",
|
|
@@ -19,6 +19,7 @@ export const Typography = ({
|
|
|
19
19
|
listStyleType,
|
|
20
20
|
whiteSpace,
|
|
21
21
|
wordWrap,
|
|
22
|
+
textAlign,
|
|
22
23
|
textOverflow,
|
|
23
24
|
truncate,
|
|
24
25
|
color = "blackOpacity90",
|
|
@@ -43,6 +44,7 @@ export const Typography = ({
|
|
|
43
44
|
listStyleType: listStyleType,
|
|
44
45
|
whiteSpace: whiteSpace,
|
|
45
46
|
wordWrap: wordWrap,
|
|
47
|
+
textAlign: textAlign,
|
|
46
48
|
textOverflow: textOverflow,
|
|
47
49
|
truncate: truncate,
|
|
48
50
|
color: color,
|
|
@@ -42,6 +42,7 @@ const getSize = variant => {
|
|
|
42
42
|
return "13px";
|
|
43
43
|
case "segment-subheader-alt":
|
|
44
44
|
case "p":
|
|
45
|
+
case "span":
|
|
45
46
|
case "b":
|
|
46
47
|
case "strong":
|
|
47
48
|
case "em":
|
|
@@ -73,6 +74,7 @@ const getLineHeight = variant => {
|
|
|
73
74
|
case "h5":
|
|
74
75
|
case "segment-subheader-alt":
|
|
75
76
|
case "p":
|
|
77
|
+
case "span":
|
|
76
78
|
case "b":
|
|
77
79
|
case "strong":
|
|
78
80
|
case "em":
|
|
@@ -98,6 +100,7 @@ const getWeight = variant => {
|
|
|
98
100
|
case "h4":
|
|
99
101
|
case "h5":
|
|
100
102
|
case "p":
|
|
103
|
+
case "span":
|
|
101
104
|
case "small":
|
|
102
105
|
case "big":
|
|
103
106
|
case "sub":
|
|
@@ -149,6 +152,7 @@ const StyledTypography = styled.span.attrs(({
|
|
|
149
152
|
listStyleType,
|
|
150
153
|
whiteSpace,
|
|
151
154
|
wordWrap,
|
|
155
|
+
textAlign,
|
|
152
156
|
textOverflow,
|
|
153
157
|
truncate,
|
|
154
158
|
screenReaderOnly
|
|
@@ -163,6 +167,7 @@ const StyledTypography = styled.span.attrs(({
|
|
|
163
167
|
padding: 0;
|
|
164
168
|
white-space: ${truncate ? "nowrap" : whiteSpace};
|
|
165
169
|
word-wrap: ${wordWrap};
|
|
170
|
+
text-align: ${textAlign};
|
|
166
171
|
text-overflow: ${truncate ? "ellipsis" : textOverflow};
|
|
167
172
|
${truncate && css`
|
|
168
173
|
overflow: hidden;
|
|
@@ -13,14 +13,10 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
13
13
|
const StyledCharacterCountWrapper = _styledComponents.default.div``;
|
|
14
14
|
exports.StyledCharacterCountWrapper = StyledCharacterCountWrapper;
|
|
15
15
|
const StyledCharacterCount = _styledComponents.default.div`
|
|
16
|
-
::after {
|
|
17
|
-
content: " ";
|
|
18
|
-
}
|
|
19
|
-
|
|
20
16
|
text-align: left;
|
|
21
|
-
font-size:
|
|
22
|
-
margin-top:
|
|
23
|
-
margin-bottom:
|
|
17
|
+
font-size: var(--fontSizes100);
|
|
18
|
+
margin-top: var(--spacing050);
|
|
19
|
+
margin-bottom: var(--spacing050);
|
|
24
20
|
color: ${({
|
|
25
21
|
isOverLimit
|
|
26
22
|
}) => isOverLimit ? "var(--colorsSemanticNegative500)" : "var(--colorsUtilityYin055)"};
|
|
@@ -28,7 +24,7 @@ const StyledCharacterCount = _styledComponents.default.div`
|
|
|
28
24
|
${({
|
|
29
25
|
isOverLimit
|
|
30
26
|
}) => isOverLimit && (0, _styledComponents.css)`
|
|
31
|
-
font-weight:
|
|
27
|
+
font-weight: var(--fontWeights700);
|
|
32
28
|
`}
|
|
33
29
|
`;
|
|
34
30
|
exports.StyledCharacterCount = StyledCharacterCount;
|
|
@@ -12,7 +12,7 @@ declare type StyledHeadingTitleProps = {
|
|
|
12
12
|
withMargin?: boolean;
|
|
13
13
|
};
|
|
14
14
|
declare const StyledHeadingTitle: import("styled-components").StyledComponent<{
|
|
15
|
-
({ "data-component": dataComponent, variant, as, id, fontSize, fontWeight, textTransform, lineHeight, textDecoration, display, listStyleType, whiteSpace, wordWrap, textOverflow, truncate, color, backgroundColor, bg, opacity, children, className, screenReaderOnly, ...rest }: import("../typography").TypographyProps): import("react").JSX.Element;
|
|
15
|
+
({ "data-component": dataComponent, variant, as, id, fontSize, fontWeight, textTransform, lineHeight, textDecoration, display, listStyleType, whiteSpace, wordWrap, textAlign, textOverflow, truncate, color, backgroundColor, bg, opacity, children, className, screenReaderOnly, ...rest }: import("../typography").TypographyProps): import("react").JSX.Element;
|
|
16
16
|
displayName: string;
|
|
17
17
|
}, any, StyledHeadingTitleProps, never>;
|
|
18
18
|
declare const StyledHeadingPills: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface EditorValidationWrapperProps {
|
|
3
|
+
/** Message to be displayed when there is an error */
|
|
4
|
+
error?: string;
|
|
5
|
+
/** Message to be displayed when there is a warning */
|
|
6
|
+
warning?: string;
|
|
7
|
+
/** Message to be displayed when there is an info */
|
|
8
|
+
info?: string;
|
|
9
|
+
}
|
|
10
|
+
declare const ValidationWrapper: ({ error, warning, info, }: EditorValidationWrapperProps) => React.JSX.Element;
|
|
11
|
+
export default ValidationWrapper;
|
|
@@ -6,25 +6,21 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _react = _interopRequireDefault(require("react"));
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
-
var
|
|
9
|
+
var _editorValidationWrapper = _interopRequireDefault(require("./editor-validation-wrapper.style"));
|
|
10
10
|
var _validations = _interopRequireDefault(require("../../../../__internal__/validations"));
|
|
11
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
-
const
|
|
13
|
-
count = 0,
|
|
14
|
-
limit = 3000,
|
|
12
|
+
const ValidationWrapper = ({
|
|
15
13
|
error,
|
|
16
14
|
warning,
|
|
17
15
|
info
|
|
18
|
-
}) => /*#__PURE__*/_react.default.createElement(
|
|
19
|
-
"data-component": "text-editor-
|
|
20
|
-
},
|
|
16
|
+
}) => /*#__PURE__*/_react.default.createElement(_editorValidationWrapper.default, {
|
|
17
|
+
"data-component": "text-editor-validation-wrapper"
|
|
18
|
+
}, /*#__PURE__*/_react.default.createElement(_validations.default, {
|
|
21
19
|
error: error,
|
|
22
20
|
warning: warning,
|
|
23
21
|
info: info,
|
|
24
22
|
tooltipPosition: "top",
|
|
25
23
|
tabIndex: 0
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
}, `${limit - count}`));
|
|
29
|
-
var _default = Counter;
|
|
24
|
+
}));
|
|
25
|
+
var _default = ValidationWrapper;
|
|
30
26
|
exports.default = _default;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
8
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
|
+
const StyledValidationWrapper = _styledComponents.default.div`
|
|
10
|
+
margin: var(--spacing200) var(--spacing200) var(--spacing000)
|
|
11
|
+
var(--spacing050);
|
|
12
|
+
min-width: var(--sizing500);
|
|
13
|
+
height: var(--sizing275);
|
|
14
|
+
display: flex;
|
|
15
|
+
float: right;
|
|
16
|
+
align-items: center;
|
|
17
|
+
`;
|
|
18
|
+
var _default = StyledValidationWrapper;
|
|
19
|
+
exports.default = _default;
|
|
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
Object.defineProperty(exports, "default", {
|
|
7
7
|
enumerable: true,
|
|
8
8
|
get: function () {
|
|
9
|
-
return
|
|
9
|
+
return _editorValidationWrapper.default;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
|
-
var
|
|
12
|
+
var _editorValidationWrapper = _interopRequireDefault(require("./editor-validation-wrapper.component"));
|
|
13
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"sideEffects": false,
|
|
3
|
-
"module": "../../../../../esm/components/text-editor/__internal__/editor-
|
|
3
|
+
"module": "../../../../../esm/components/text-editor/__internal__/editor-validation-wrapper/index.js",
|
|
4
4
|
"main": "./index.js",
|
|
5
5
|
"types": "./index.d.ts"
|
|
6
6
|
}
|
|
@@ -30,6 +30,8 @@ export interface TextEditorProps extends MarginProps {
|
|
|
30
30
|
previews?: React.ReactNode;
|
|
31
31
|
/** Callback to report a url when a link is added */
|
|
32
32
|
onLinkAdded?: (url: string) => void;
|
|
33
|
+
/** Hint text to be rendered when validationRedesignOptIn flag is set */
|
|
34
|
+
inputHint?: string;
|
|
33
35
|
}
|
|
34
36
|
export declare const TextEditor: React.ForwardRefExoticComponent<TextEditorProps & React.RefAttributes<Editor>>;
|
|
35
37
|
export declare const TextEditorState: typeof EditorState;
|
|
@@ -9,13 +9,19 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
9
9
|
var _draftJs = require("draft-js");
|
|
10
10
|
var _utils = require("./__internal__/utils");
|
|
11
11
|
var _textEditor = require("./text-editor.style");
|
|
12
|
-
var
|
|
12
|
+
var _editorValidationWrapper = _interopRequireDefault(require("./__internal__/editor-validation-wrapper"));
|
|
13
13
|
var _toolbar = _interopRequireDefault(require("./__internal__/toolbar"));
|
|
14
14
|
var _label = _interopRequireDefault(require("../../__internal__/label"));
|
|
15
15
|
var _events = _interopRequireDefault(require("../../__internal__/utils/helpers/events"));
|
|
16
16
|
var _guid = _interopRequireDefault(require("../../__internal__/utils/helpers/guid"));
|
|
17
17
|
var _labelWrapper = _interopRequireDefault(require("./__internal__/label-wrapper"));
|
|
18
18
|
var _types = require("./types");
|
|
19
|
+
var _carbonProvider = require("../carbon-provider/carbon-provider.component");
|
|
20
|
+
var _textbox = require("../textbox/textbox.style");
|
|
21
|
+
var _validationMessage = _interopRequireDefault(require("../../__internal__/validation-message"));
|
|
22
|
+
var _useInputAccessibility = _interopRequireDefault(require("../../hooks/__internal__/useInputAccessibility"));
|
|
23
|
+
var _box = _interopRequireDefault(require("../box"));
|
|
24
|
+
var _useCharacterCount = _interopRequireDefault(require("../../hooks/__internal__/useCharacterCount"));
|
|
19
25
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
20
26
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
21
27
|
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; }
|
|
@@ -36,8 +42,12 @@ const TextEditor = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
36
42
|
rows,
|
|
37
43
|
previews,
|
|
38
44
|
onLinkAdded,
|
|
45
|
+
inputHint,
|
|
39
46
|
...rest
|
|
40
47
|
}, ref) => {
|
|
48
|
+
const {
|
|
49
|
+
validationRedesignOptIn
|
|
50
|
+
} = (0, _react.useContext)(_carbonProvider.NewValidationContext);
|
|
41
51
|
const [isFocused, setIsFocused] = (0, _react.useState)(false);
|
|
42
52
|
const [inlines, setInlines] = (0, _react.useState)([]);
|
|
43
53
|
const [activeInlines, setActiveInlines] = (0, _react.useState)({});
|
|
@@ -47,7 +57,24 @@ const TextEditor = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
47
57
|
const contentLength = (0, _utils.getContent)(value).getPlainText("").length;
|
|
48
58
|
const moveCursor = (0, _react.useRef)(contentLength > 0);
|
|
49
59
|
const lastKeyPressed = (0, _react.useRef)();
|
|
50
|
-
const
|
|
60
|
+
const inputHintId = (0, _react.useRef)(`${(0, _guid.default)()}-hint`);
|
|
61
|
+
const {
|
|
62
|
+
current: id
|
|
63
|
+
} = (0, _react.useRef)((0, _guid.default)());
|
|
64
|
+
const {
|
|
65
|
+
labelId,
|
|
66
|
+
validationId,
|
|
67
|
+
ariaDescribedBy
|
|
68
|
+
} = (0, _useInputAccessibility.default)({
|
|
69
|
+
id,
|
|
70
|
+
validationRedesignOptIn,
|
|
71
|
+
error,
|
|
72
|
+
warning,
|
|
73
|
+
info,
|
|
74
|
+
label: labelText
|
|
75
|
+
});
|
|
76
|
+
const [characterCount, visuallyHiddenHintId] = (0, _useCharacterCount.default)((0, _utils.getContent)(value).getPlainText(""), characterLimit);
|
|
77
|
+
const combinedAriaDescribedBy = [ariaDescribedBy, inputHint ? inputHintId.current : undefined, visuallyHiddenHintId].filter(Boolean).join(" ");
|
|
51
78
|
if (rows && (typeof rows !== "number" || rows < 2)) {
|
|
52
79
|
// eslint-disable-next-line no-console
|
|
53
80
|
console.warn(`Prop rows must be a number value that is 2 or greater to override the min-height of the \`${TextEditor.displayName}\``);
|
|
@@ -233,9 +260,19 @@ const TextEditor = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
233
260
|
}, /*#__PURE__*/_react.default.createElement(_textEditor.StyledEditorWrapper, rest, /*#__PURE__*/_react.default.createElement(_labelWrapper.default, {
|
|
234
261
|
onClick: () => handleEditorFocus(true)
|
|
235
262
|
}, /*#__PURE__*/_react.default.createElement(_label.default, {
|
|
236
|
-
labelId: labelId
|
|
263
|
+
labelId: labelId,
|
|
237
264
|
isRequired: required
|
|
238
|
-
}, labelText)), /*#__PURE__*/_react.default.createElement(
|
|
265
|
+
}, labelText)), inputHint && /*#__PURE__*/_react.default.createElement(_textbox.StyledHintText, {
|
|
266
|
+
id: inputHintId.current
|
|
267
|
+
}, inputHint), /*#__PURE__*/_react.default.createElement(_box.default, {
|
|
268
|
+
position: "relative"
|
|
269
|
+
}, validationRedesignOptIn && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_validationMessage.default, {
|
|
270
|
+
error: error,
|
|
271
|
+
validationId: validationId,
|
|
272
|
+
warning: warning
|
|
273
|
+
}), (error || warning) && /*#__PURE__*/_react.default.createElement(_textbox.ErrorBorder, {
|
|
274
|
+
warning: !!(!error && warning)
|
|
275
|
+
})), /*#__PURE__*/_react.default.createElement(_textEditor.StyledEditorOutline, {
|
|
239
276
|
isFocused: isFocused,
|
|
240
277
|
hasError: !!error
|
|
241
278
|
}, /*#__PURE__*/_react.default.createElement(_textEditor.StyledEditorContainer, {
|
|
@@ -243,9 +280,7 @@ const TextEditor = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
243
280
|
hasError: !!error,
|
|
244
281
|
rows: rows,
|
|
245
282
|
hasPreview: !!_react.default.Children.count(previews)
|
|
246
|
-
}, /*#__PURE__*/_react.default.createElement(
|
|
247
|
-
limit: characterLimit,
|
|
248
|
-
count: contentLength,
|
|
283
|
+
}, !validationRedesignOptIn && (error || warning || info) && /*#__PURE__*/_react.default.createElement(_editorValidationWrapper.default, {
|
|
249
284
|
error: error,
|
|
250
285
|
warning: warning,
|
|
251
286
|
info: info
|
|
@@ -258,8 +293,8 @@ const TextEditor = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
258
293
|
handleBeforeInput: handleBeforeInput,
|
|
259
294
|
handlePastedText: handlePastedText,
|
|
260
295
|
handleKeyCommand: handleKeyCommand,
|
|
261
|
-
ariaLabelledBy: labelId
|
|
262
|
-
ariaDescribedBy:
|
|
296
|
+
ariaLabelledBy: labelId,
|
|
297
|
+
ariaDescribedBy: combinedAriaDescribedBy,
|
|
263
298
|
blockStyleFn: _utils.blockStyleFn,
|
|
264
299
|
keyBindingFn: keyBindingFn,
|
|
265
300
|
tabIndex: 0
|
|
@@ -280,13 +315,14 @@ const TextEditor = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
280
315
|
activeControls: activeControls,
|
|
281
316
|
canFocus: focusToolbar,
|
|
282
317
|
toolbarElements: toolbarElements
|
|
283
|
-
})))));
|
|
318
|
+
}))), characterCount)));
|
|
284
319
|
});
|
|
285
320
|
exports.TextEditor = TextEditor;
|
|
286
321
|
TextEditor.propTypes = {
|
|
287
322
|
"characterLimit": _propTypes.default.number,
|
|
288
323
|
"error": _propTypes.default.string,
|
|
289
324
|
"info": _propTypes.default.string,
|
|
325
|
+
"inputHint": _propTypes.default.string,
|
|
290
326
|
"labelText": _propTypes.default.string.isRequired,
|
|
291
327
|
"m": _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.oneOf([null]), _propTypes.default.number, _propTypes.default.shape({
|
|
292
328
|
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { SpaceProps } from "styled-system";
|
|
3
3
|
import { TagProps } from "../../__internal__/utils/helpers/tags";
|
|
4
|
-
declare const VARIANT_TYPES: readonly ["h1-large", "h1", "h2", "h3", "h4", "h5", "segment-header", "segment-header-small", "segment-subheader", "segment-subheader-alt", "p", "small", "big", "sup", "sub", "strong", "b", "em", "ul", "ol"];
|
|
4
|
+
declare const VARIANT_TYPES: readonly ["h1-large", "h1", "h2", "h3", "h4", "h5", "segment-header", "segment-header-small", "segment-subheader", "segment-subheader-alt", "p", "span", "small", "big", "sup", "sub", "strong", "b", "em", "ul", "ol"];
|
|
5
5
|
export declare type VariantTypes = typeof VARIANT_TYPES[number];
|
|
6
6
|
export interface TypographyProps extends SpaceProps, TagProps {
|
|
7
7
|
/** Override the variant component */
|
|
@@ -30,6 +30,8 @@ export interface TypographyProps extends SpaceProps, TagProps {
|
|
|
30
30
|
whiteSpace?: string;
|
|
31
31
|
/** Override the word-wrap */
|
|
32
32
|
wordWrap?: string;
|
|
33
|
+
/** Override the text-align */
|
|
34
|
+
textAlign?: string;
|
|
33
35
|
/** Override the text-overflow */
|
|
34
36
|
textOverflow?: string;
|
|
35
37
|
/** Apply truncation */
|
|
@@ -49,7 +51,7 @@ export interface TypographyProps extends SpaceProps, TagProps {
|
|
|
49
51
|
screenReaderOnly?: boolean;
|
|
50
52
|
}
|
|
51
53
|
export declare const Typography: {
|
|
52
|
-
({ "data-component": dataComponent, variant, as, id, fontSize, fontWeight, textTransform, lineHeight, textDecoration, display, listStyleType, whiteSpace, wordWrap, textOverflow, truncate, color, backgroundColor, bg, opacity, children, className, screenReaderOnly, ...rest }: TypographyProps): React.JSX.Element;
|
|
54
|
+
({ "data-component": dataComponent, variant, as, id, fontSize, fontWeight, textTransform, lineHeight, textDecoration, display, listStyleType, whiteSpace, wordWrap, textAlign, textOverflow, truncate, color, backgroundColor, bg, opacity, children, className, screenReaderOnly, ...rest }: TypographyProps): React.JSX.Element;
|
|
53
55
|
displayName: string;
|
|
54
56
|
};
|
|
55
57
|
export default Typography;
|
|
@@ -11,7 +11,7 @@ var _utils = require("../../style/utils");
|
|
|
11
11
|
var _typography = _interopRequireDefault(require("./typography.style"));
|
|
12
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
13
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
14
|
-
const VARIANT_TYPES = ["h1-large", "h1", "h2", "h3", "h4", "h5", "segment-header", "segment-header-small", "segment-subheader", "segment-subheader-alt", "p", "small", "big", "sup", "sub", "strong", "b", "em", "ul", "ol"];
|
|
14
|
+
const VARIANT_TYPES = ["h1-large", "h1", "h2", "h3", "h4", "h5", "segment-header", "segment-header-small", "segment-subheader", "segment-subheader-alt", "p", "span", "small", "big", "sup", "sub", "strong", "b", "em", "ul", "ol"];
|
|
15
15
|
const Typography = ({
|
|
16
16
|
"data-component": dataComponent,
|
|
17
17
|
variant = "p",
|
|
@@ -26,6 +26,7 @@ const Typography = ({
|
|
|
26
26
|
listStyleType,
|
|
27
27
|
whiteSpace,
|
|
28
28
|
wordWrap,
|
|
29
|
+
textAlign,
|
|
29
30
|
textOverflow,
|
|
30
31
|
truncate,
|
|
31
32
|
color = "blackOpacity90",
|
|
@@ -50,6 +51,7 @@ const Typography = ({
|
|
|
50
51
|
listStyleType: listStyleType,
|
|
51
52
|
whiteSpace: whiteSpace,
|
|
52
53
|
wordWrap: wordWrap,
|
|
54
|
+
textAlign: textAlign,
|
|
53
55
|
textOverflow: textOverflow,
|
|
54
56
|
truncate: truncate,
|
|
55
57
|
color: color,
|
|
@@ -51,6 +51,7 @@ const getSize = variant => {
|
|
|
51
51
|
return "13px";
|
|
52
52
|
case "segment-subheader-alt":
|
|
53
53
|
case "p":
|
|
54
|
+
case "span":
|
|
54
55
|
case "b":
|
|
55
56
|
case "strong":
|
|
56
57
|
case "em":
|
|
@@ -82,6 +83,7 @@ const getLineHeight = variant => {
|
|
|
82
83
|
case "h5":
|
|
83
84
|
case "segment-subheader-alt":
|
|
84
85
|
case "p":
|
|
86
|
+
case "span":
|
|
85
87
|
case "b":
|
|
86
88
|
case "strong":
|
|
87
89
|
case "em":
|
|
@@ -107,6 +109,7 @@ const getWeight = variant => {
|
|
|
107
109
|
case "h4":
|
|
108
110
|
case "h5":
|
|
109
111
|
case "p":
|
|
112
|
+
case "span":
|
|
110
113
|
case "small":
|
|
111
114
|
case "big":
|
|
112
115
|
case "sub":
|
|
@@ -158,6 +161,7 @@ const StyledTypography = _styledComponents.default.span.attrs(({
|
|
|
158
161
|
listStyleType,
|
|
159
162
|
whiteSpace,
|
|
160
163
|
wordWrap,
|
|
164
|
+
textAlign,
|
|
161
165
|
textOverflow,
|
|
162
166
|
truncate,
|
|
163
167
|
screenReaderOnly
|
|
@@ -172,6 +176,7 @@ const StyledTypography = _styledComponents.default.span.attrs(({
|
|
|
172
176
|
padding: 0;
|
|
173
177
|
white-space: ${truncate ? "nowrap" : whiteSpace};
|
|
174
178
|
word-wrap: ${wordWrap};
|
|
179
|
+
text-align: ${textAlign};
|
|
175
180
|
text-overflow: ${truncate ? "ellipsis" : textOverflow};
|
|
176
181
|
${truncate && (0, _styledComponents.css)`
|
|
177
182
|
overflow: hidden;
|
package/package.json
CHANGED
package/esm/components/text-editor/__internal__/editor-counter/editor-counter.component.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
export interface EditorCounterProps {
|
|
3
|
-
/** Sets the current count value */
|
|
4
|
-
count?: number;
|
|
5
|
-
/** Sets the current limit value */
|
|
6
|
-
limit?: number;
|
|
7
|
-
/** Message to be displayed when there is an error */
|
|
8
|
-
error?: string;
|
|
9
|
-
/** Message to be displayed when there is a warning */
|
|
10
|
-
warning?: string;
|
|
11
|
-
/** Message to be displayed when there is an info */
|
|
12
|
-
info?: string;
|
|
13
|
-
}
|
|
14
|
-
declare const Counter: ({ count, limit, error, warning, info, }: EditorCounterProps) => React.JSX.Element;
|
|
15
|
-
export default Counter;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import PropTypes from "prop-types";
|
|
3
|
-
import { StyledCounterWrapper, StyledCounter } from "./editor-counter.style";
|
|
4
|
-
import ValidationIcon from "../../../../__internal__/validations";
|
|
5
|
-
const Counter = ({
|
|
6
|
-
count = 0,
|
|
7
|
-
limit = 3000,
|
|
8
|
-
error,
|
|
9
|
-
warning,
|
|
10
|
-
info
|
|
11
|
-
}) => /*#__PURE__*/React.createElement(StyledCounterWrapper, {
|
|
12
|
-
"data-component": "text-editor-counter"
|
|
13
|
-
}, !!(error || warning || info) && /*#__PURE__*/React.createElement(ValidationIcon, {
|
|
14
|
-
error: error,
|
|
15
|
-
warning: warning,
|
|
16
|
-
info: info,
|
|
17
|
-
tooltipPosition: "top",
|
|
18
|
-
tabIndex: 0
|
|
19
|
-
}), /*#__PURE__*/React.createElement(StyledCounter, {
|
|
20
|
-
hasError: !!error
|
|
21
|
-
}, `${limit - count}`));
|
|
22
|
-
export default Counter;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
declare const StyledCounter: import("styled-components").StyledComponent<"span", any, {
|
|
2
|
-
hasError: boolean;
|
|
3
|
-
}, never>;
|
|
4
|
-
declare const StyledCounterWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
5
|
-
export { StyledCounter, StyledCounterWrapper };
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import styled from "styled-components";
|
|
2
|
-
const StyledCounter = styled.span`
|
|
3
|
-
color: ${({
|
|
4
|
-
hasError
|
|
5
|
-
}) => hasError ? "var(--colorsSemanticNegative500)" : "var(--colorsUtilityYin055)"};
|
|
6
|
-
width: 100%;
|
|
7
|
-
`;
|
|
8
|
-
const StyledCounterWrapper = styled.div`
|
|
9
|
-
margin: 16px 16px 0px 4px;
|
|
10
|
-
min-width: 40px;
|
|
11
|
-
height: 21px;
|
|
12
|
-
font-size: 14px;
|
|
13
|
-
display: flex;
|
|
14
|
-
float: right;
|
|
15
|
-
text-align: right;
|
|
16
|
-
align-items: center;
|
|
17
|
-
`;
|
|
18
|
-
export { StyledCounter, StyledCounterWrapper };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from "./editor-counter.component";
|
package/lib/components/text-editor/__internal__/editor-counter/editor-counter.component.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
export interface EditorCounterProps {
|
|
3
|
-
/** Sets the current count value */
|
|
4
|
-
count?: number;
|
|
5
|
-
/** Sets the current limit value */
|
|
6
|
-
limit?: number;
|
|
7
|
-
/** Message to be displayed when there is an error */
|
|
8
|
-
error?: string;
|
|
9
|
-
/** Message to be displayed when there is a warning */
|
|
10
|
-
warning?: string;
|
|
11
|
-
/** Message to be displayed when there is an info */
|
|
12
|
-
info?: string;
|
|
13
|
-
}
|
|
14
|
-
declare const Counter: ({ count, limit, error, warning, info, }: EditorCounterProps) => React.JSX.Element;
|
|
15
|
-
export default Counter;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
declare const StyledCounter: import("styled-components").StyledComponent<"span", any, {
|
|
2
|
-
hasError: boolean;
|
|
3
|
-
}, never>;
|
|
4
|
-
declare const StyledCounterWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
5
|
-
export { StyledCounter, StyledCounterWrapper };
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.StyledCounterWrapper = exports.StyledCounter = void 0;
|
|
7
|
-
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
8
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
|
-
const StyledCounter = _styledComponents.default.span`
|
|
10
|
-
color: ${({
|
|
11
|
-
hasError
|
|
12
|
-
}) => hasError ? "var(--colorsSemanticNegative500)" : "var(--colorsUtilityYin055)"};
|
|
13
|
-
width: 100%;
|
|
14
|
-
`;
|
|
15
|
-
exports.StyledCounter = StyledCounter;
|
|
16
|
-
const StyledCounterWrapper = _styledComponents.default.div`
|
|
17
|
-
margin: 16px 16px 0px 4px;
|
|
18
|
-
min-width: 40px;
|
|
19
|
-
height: 21px;
|
|
20
|
-
font-size: 14px;
|
|
21
|
-
display: flex;
|
|
22
|
-
float: right;
|
|
23
|
-
text-align: right;
|
|
24
|
-
align-items: center;
|
|
25
|
-
`;
|
|
26
|
-
exports.StyledCounterWrapper = StyledCounterWrapper;
|