carbon-react 125.11.0 → 125.12.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/README.md +2 -2
- package/esm/components/portal/portal.js +2 -1
- package/esm/components/portal/portal.style.d.ts +2 -0
- package/esm/components/portal/portal.style.js +7 -0
- package/esm/components/select/option/option.component.d.ts +1 -1
- package/esm/components/select/option/option.component.js +5 -3
- package/esm/components/select/option-group-header/option-group-header.component.js +6 -2
- package/esm/components/select/option-row/option-row.component.js +6 -4
- package/esm/components/select/select-list/select-list.component.js +26 -29
- package/esm/components/text-editor/__internal__/toolbar/toolbar-button/toolbar-button.style.js +8 -13
- package/esm/components/text-editor/__internal__/toolbar/toolbar.component.d.ts +1 -1
- package/esm/components/text-editor/__internal__/toolbar/toolbar.component.js +4 -0
- package/esm/components/text-editor/__internal__/toolbar/toolbar.style.js +16 -24
- package/esm/components/text-editor/text-editor.style.js +0 -2
- package/lib/components/portal/portal.js +2 -1
- package/lib/components/portal/portal.style.d.ts +2 -0
- package/lib/components/portal/portal.style.js +14 -0
- package/lib/components/select/option/option.component.d.ts +1 -1
- package/lib/components/select/option/option.component.js +4 -2
- package/lib/components/select/option-group-header/option-group-header.component.js +8 -2
- package/lib/components/select/option-row/option-row.component.js +5 -3
- package/lib/components/select/select-list/select-list.component.js +26 -29
- package/lib/components/text-editor/__internal__/toolbar/toolbar-button/toolbar-button.style.js +8 -13
- package/lib/components/text-editor/__internal__/toolbar/toolbar.component.d.ts +1 -1
- package/lib/components/text-editor/__internal__/toolbar/toolbar.component.js +4 -0
- package/lib/components/text-editor/__internal__/toolbar/toolbar.style.js +16 -24
- package/lib/components/text-editor/text-editor.style.js +0 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Carbon [](https://www.npmjs.com/package/carbon-react) [](https://github.com/Sage/carbon/actions/workflows/cypress.yml) [](https://github.com/Sage/carbon/actions/workflows/playwright.yml)
|
|
2
2
|
|
|
3
|
-
Carbon is a [React](https://
|
|
3
|
+
Carbon is a [React](https://react.dev/) component library developed by Sage.
|
|
4
4
|
|
|
5
5
|
## Getting started
|
|
6
6
|
|
|
@@ -8,7 +8,7 @@ Our [getting started guide](https://carbon.sage.com/?path=/story/getting-started
|
|
|
8
8
|
|
|
9
9
|
## Examples
|
|
10
10
|
|
|
11
|
-
See
|
|
11
|
+
See our [docs](https://carbon.sage.com/) for live examples.
|
|
12
12
|
|
|
13
13
|
## Browser Support
|
|
14
14
|
|
|
@@ -2,6 +2,7 @@ import React, { useContext, useEffect, useMemo, useState } from "react";
|
|
|
2
2
|
import ReactDOM from "react-dom";
|
|
3
3
|
import guid from "../../__internal__/utils/helpers/guid";
|
|
4
4
|
import CarbonScopedTokensProvider from "../../style/design-tokens/carbon-scoped-tokens-provider/carbon-scoped-tokens-provider.component";
|
|
5
|
+
import StyledPortalEntrance from "./portal.style";
|
|
5
6
|
export const PortalContext = /*#__PURE__*/React.createContext({});
|
|
6
7
|
const Portal = ({
|
|
7
8
|
children,
|
|
@@ -63,7 +64,7 @@ const Portal = ({
|
|
|
63
64
|
}
|
|
64
65
|
return node;
|
|
65
66
|
};
|
|
66
|
-
return /*#__PURE__*/React.createElement(
|
|
67
|
+
return /*#__PURE__*/React.createElement(StyledPortalEntrance, {
|
|
67
68
|
"data-portal-entrance": uniqueId
|
|
68
69
|
}, /*#__PURE__*/ReactDOM.createPortal( /*#__PURE__*/React.createElement(CarbonScopedTokensProvider, null, children), getPortalContainer()));
|
|
69
70
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { TagProps } from "__internal__/utils/helpers/tags";
|
|
2
|
+
import { TagProps } from "../../../__internal__/utils/helpers/tags";
|
|
3
3
|
export interface OptionProps extends Omit<React.InputHTMLAttributes<HTMLLIElement>, "value" | "onSelect" | "onClick">, TagProps {
|
|
4
4
|
/**
|
|
5
5
|
* Unique identifier for the component.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
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); }
|
|
2
|
-
import React, { useContext } from "react";
|
|
2
|
+
import React, { useContext, useRef } from "react";
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
|
+
import guid from "../../../__internal__/utils/helpers/guid";
|
|
4
5
|
import StyledOption from "./option.style";
|
|
5
6
|
import SelectListContext from "../__internal__/select-list-context";
|
|
6
7
|
const Option = /*#__PURE__*/React.forwardRef(({
|
|
@@ -18,6 +19,7 @@ const Option = /*#__PURE__*/React.forwardRef(({
|
|
|
18
19
|
}, ref) => {
|
|
19
20
|
const selectListContext = useContext(SelectListContext);
|
|
20
21
|
let isSelected = selectListContext.currentOptionsListIndex === index;
|
|
22
|
+
const internalIdRef = useRef(id || guid());
|
|
21
23
|
if (selectListContext.multiselectValues) {
|
|
22
24
|
isSelected = selectListContext.multiselectValues.includes(value);
|
|
23
25
|
}
|
|
@@ -29,7 +31,7 @@ const Option = /*#__PURE__*/React.forwardRef(({
|
|
|
29
31
|
onSelect?.({
|
|
30
32
|
text,
|
|
31
33
|
value,
|
|
32
|
-
id
|
|
34
|
+
id: internalIdRef.current
|
|
33
35
|
});
|
|
34
36
|
} else {
|
|
35
37
|
onSelect?.();
|
|
@@ -37,7 +39,7 @@ const Option = /*#__PURE__*/React.forwardRef(({
|
|
|
37
39
|
}
|
|
38
40
|
}
|
|
39
41
|
return /*#__PURE__*/React.createElement(StyledOption, _extends({
|
|
40
|
-
id:
|
|
42
|
+
id: internalIdRef.current,
|
|
41
43
|
ref: ref,
|
|
42
44
|
"aria-selected": isSelected,
|
|
43
45
|
"aria-disabled": disabled,
|
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
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); }
|
|
2
|
-
import React from "react";
|
|
2
|
+
import React, { useRef } from "react";
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
|
+
import guid from "../../../__internal__/utils/helpers/guid";
|
|
4
5
|
import StyledOptionGroupHeader from "./option-group-header.style";
|
|
5
6
|
import Icon from "../../icon";
|
|
6
7
|
const OptionGroupHeader = /*#__PURE__*/React.forwardRef(({
|
|
7
8
|
label,
|
|
8
9
|
icon,
|
|
9
10
|
style,
|
|
11
|
+
id,
|
|
10
12
|
...rest
|
|
11
13
|
}, ref) => {
|
|
14
|
+
const internalIdRef = useRef(id || guid());
|
|
12
15
|
return /*#__PURE__*/React.createElement(StyledOptionGroupHeader, _extends({
|
|
13
|
-
style: style
|
|
16
|
+
style: style,
|
|
17
|
+
id: internalIdRef.current
|
|
14
18
|
}, rest, {
|
|
15
19
|
ref: ref
|
|
16
20
|
}), icon && /*#__PURE__*/React.createElement(Icon, {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
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); }
|
|
2
|
-
import React, { useContext } from "react";
|
|
2
|
+
import React, { useContext, useRef } from "react";
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
|
+
import guid from "../../../__internal__/utils/helpers/guid";
|
|
4
5
|
import StyledOptionRow from "./option-row.style";
|
|
5
6
|
import SelectListContext from "../__internal__/select-list-context";
|
|
6
7
|
const OptionRow = /*#__PURE__*/React.forwardRef(({
|
|
@@ -15,14 +16,15 @@ const OptionRow = /*#__PURE__*/React.forwardRef(({
|
|
|
15
16
|
style,
|
|
16
17
|
...rest
|
|
17
18
|
}, ref) => {
|
|
19
|
+
const internalIdRef = useRef(id || guid());
|
|
18
20
|
const handleClick = () => {
|
|
19
21
|
if (disabled) {
|
|
20
22
|
return;
|
|
21
23
|
}
|
|
22
24
|
onSelect?.({
|
|
23
|
-
id,
|
|
24
25
|
text,
|
|
25
|
-
value
|
|
26
|
+
value,
|
|
27
|
+
id: internalIdRef.current
|
|
26
28
|
});
|
|
27
29
|
};
|
|
28
30
|
const selectListContext = useContext(SelectListContext);
|
|
@@ -31,7 +33,7 @@ const OptionRow = /*#__PURE__*/React.forwardRef(({
|
|
|
31
33
|
isSelected = selectListContext.multiselectValues.includes(value);
|
|
32
34
|
}
|
|
33
35
|
return /*#__PURE__*/React.createElement(StyledOptionRow, _extends({
|
|
34
|
-
id:
|
|
36
|
+
id: internalIdRef.current,
|
|
35
37
|
ref: ref,
|
|
36
38
|
"aria-selected": isSelected,
|
|
37
39
|
"aria-disabled": disabled,
|
|
@@ -17,7 +17,6 @@ import ListActionButton from "../list-action-button";
|
|
|
17
17
|
import StyledSelectListContainer from "./select-list-container.style";
|
|
18
18
|
import Loader from "../../loader";
|
|
19
19
|
import Option from "../option";
|
|
20
|
-
import guid from "../../../__internal__/utils/helpers/guid";
|
|
21
20
|
import SelectListContext from "../__internal__/select-list-context";
|
|
22
21
|
const TABLE_HEADER_HEIGHT = 48;
|
|
23
22
|
const SCROLL_OPTIONS = {
|
|
@@ -92,16 +91,23 @@ const SelectList = /*#__PURE__*/React.forwardRef(({
|
|
|
92
91
|
rangeExtractor
|
|
93
92
|
});
|
|
94
93
|
const items = virtualizer.getVirtualItems();
|
|
94
|
+
const childrenList = useMemo(() => React.Children.toArray(children), [children]);
|
|
95
|
+
const getIndexOfMatch = useCallback(valueToMatch => {
|
|
96
|
+
return childrenList.findIndex(child => /*#__PURE__*/React.isValidElement(child) && child.props.value === valueToMatch);
|
|
97
|
+
}, [childrenList]);
|
|
95
98
|
|
|
96
99
|
// getVirtualItems returns an empty array of items if the select list is currently closed - which is correct visually but
|
|
97
100
|
// we need to ensure that any currently-selected option is still in the DOM to avoid any accessibility issues.
|
|
98
101
|
// The isOpen prop will ensure that no options are visible regardless of what is in the items array.
|
|
99
|
-
if (items.length === 0
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
102
|
+
if (items.length === 0) {
|
|
103
|
+
const currentIndex = highlightedValue ? getIndexOfMatch(highlightedValue) : currentOptionsListIndex;
|
|
104
|
+
if (currentIndex > -1) {
|
|
105
|
+
// only index property is required with the item not visible so the following type assertion, even though incorrect,
|
|
106
|
+
// should be OK
|
|
107
|
+
items.push({
|
|
108
|
+
index: currentIndex
|
|
109
|
+
});
|
|
110
|
+
}
|
|
105
111
|
}
|
|
106
112
|
const listHeight = virtualizer.getTotalSize();
|
|
107
113
|
useEffect(() => {
|
|
@@ -129,18 +135,9 @@ const SelectList = /*#__PURE__*/React.forwardRef(({
|
|
|
129
135
|
selectionConfirmed: true
|
|
130
136
|
});
|
|
131
137
|
}, [onSelect]);
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
// as that isn't absolutely guaranteed to never rerun when dependencies haven't changed.
|
|
136
|
-
const setChildIds = () => {
|
|
137
|
-
childIdsRef.current = React.Children.map(children, child => /*#__PURE__*/React.isValidElement(child) && child?.props.id || guid()) || /* istanbul ignore next */null;
|
|
138
|
-
};
|
|
139
|
-
if (childIdsRef.current?.length !== React.Children.count(children)) {
|
|
140
|
-
setChildIds();
|
|
141
|
-
}
|
|
142
|
-
const childIds = childIdsRef.current;
|
|
143
|
-
const childrenList = useMemo(() => React.Children.toArray(children), [children]);
|
|
138
|
+
const childElementRefs = useRef(Array.from({
|
|
139
|
+
length: React.Children.count(children)
|
|
140
|
+
}));
|
|
144
141
|
const optionChildrenList = useMemo(() => childrenList.filter(child => /*#__PURE__*/React.isValidElement(child) && (child.type === Option || child.type === OptionRow)), [childrenList]);
|
|
145
142
|
const {
|
|
146
143
|
measureElement
|
|
@@ -166,7 +163,6 @@ const SelectList = /*#__PURE__*/React.forwardRef(({
|
|
|
166
163
|
const isOption = optionChildIndex > -1;
|
|
167
164
|
const newProps = {
|
|
168
165
|
index,
|
|
169
|
-
id: childIds ? childIds[index] : /* istanbul ignore next */undefined,
|
|
170
166
|
onSelect: handleSelect,
|
|
171
167
|
hidden: isLoading && childrenList.length === 1,
|
|
172
168
|
// these need to be inline styles rather than implemented in styled-components to avoid it generating thousands of classes
|
|
@@ -175,8 +171,12 @@ const SelectList = /*#__PURE__*/React.forwardRef(({
|
|
|
175
171
|
},
|
|
176
172
|
"aria-setsize": isOption ? optionChildrenList.length : undefined,
|
|
177
173
|
"aria-posinset": isOption ? optionChildIndex + 1 : undefined,
|
|
178
|
-
|
|
179
|
-
|
|
174
|
+
ref: optionElement => {
|
|
175
|
+
// needed to dynamically compute the size
|
|
176
|
+
measureCallback(optionElement);
|
|
177
|
+
// add the DOM element to the array of refs
|
|
178
|
+
childElementRefs.current[index] = optionElement;
|
|
179
|
+
},
|
|
180
180
|
"data-index": index
|
|
181
181
|
};
|
|
182
182
|
return /*#__PURE__*/React.cloneElement(child, newProps);
|
|
@@ -194,9 +194,6 @@ const SelectList = /*#__PURE__*/React.forwardRef(({
|
|
|
194
194
|
}
|
|
195
195
|
return nextIndex;
|
|
196
196
|
}, [childrenList, lastOptionIndex, isLoading]);
|
|
197
|
-
const getIndexOfMatch = useCallback(valueToMatch => {
|
|
198
|
-
return childrenList.findIndex(child => /*#__PURE__*/React.isValidElement(child) && child.props.value === valueToMatch);
|
|
199
|
-
}, [childrenList]);
|
|
200
197
|
const highlightNextItem = useCallback(key => {
|
|
201
198
|
let currentIndex = currentOptionsListIndex;
|
|
202
199
|
if (highlightedValue) {
|
|
@@ -215,10 +212,10 @@ const SelectList = /*#__PURE__*/React.forwardRef(({
|
|
|
215
212
|
text,
|
|
216
213
|
value,
|
|
217
214
|
selectionType: "navigationKey",
|
|
218
|
-
id:
|
|
215
|
+
id: childElementRefs.current[nextIndex]?.id,
|
|
219
216
|
selectionConfirmed: false
|
|
220
217
|
});
|
|
221
|
-
}, [childrenList, currentOptionsListIndex, getIndexOfMatch, getNextHighlightableItemIndex, highlightedValue, onSelect
|
|
218
|
+
}, [childrenList, currentOptionsListIndex, getIndexOfMatch, getNextHighlightableItemIndex, highlightedValue, onSelect]);
|
|
222
219
|
const handleActionButtonTab = useCallback((event, isActionButtonFocused) => {
|
|
223
220
|
if (isActionButtonFocused) {
|
|
224
221
|
onSelect({
|
|
@@ -262,7 +259,7 @@ const SelectList = /*#__PURE__*/React.forwardRef(({
|
|
|
262
259
|
value
|
|
263
260
|
} = currentOption.props;
|
|
264
261
|
onSelect({
|
|
265
|
-
id:
|
|
262
|
+
id: childElementRefs.current[currentOptionsListIndex]?.id,
|
|
266
263
|
text,
|
|
267
264
|
value,
|
|
268
265
|
selectionType: "enterKey",
|
|
@@ -272,7 +269,7 @@ const SelectList = /*#__PURE__*/React.forwardRef(({
|
|
|
272
269
|
focusOnAnchor();
|
|
273
270
|
highlightNextItem(key);
|
|
274
271
|
}
|
|
275
|
-
}, [childrenList, listActionButton, handleActionButtonTab, onSelectListClose, currentOptionsListIndex, onSelect, highlightNextItem, focusOnAnchor, isOpen
|
|
272
|
+
}, [childrenList, listActionButton, handleActionButtonTab, onSelectListClose, currentOptionsListIndex, onSelect, highlightNextItem, focusOnAnchor, isOpen]);
|
|
276
273
|
const handleEscapeKey = useCallback(event => {
|
|
277
274
|
if (event.key === "Escape") {
|
|
278
275
|
onSelectListClose();
|
package/esm/components/text-editor/__internal__/toolbar/toolbar-button/toolbar-button.style.js
CHANGED
|
@@ -1,21 +1,17 @@
|
|
|
1
1
|
import styled, { css } from "styled-components";
|
|
2
|
-
import StyledIcon from "../../../../icon/icon.style";
|
|
3
2
|
import { baseTheme } from "../../../../../style/themes";
|
|
4
3
|
import addFocusStyling from "../../../../../style/utils/add-focus-styling";
|
|
5
4
|
const StyledToolbarButton = styled.button.attrs({
|
|
6
5
|
type: "button"
|
|
7
6
|
})`
|
|
7
|
+
display: inline-flex;
|
|
8
|
+
justify-content: center;
|
|
9
|
+
align-items: center;
|
|
10
|
+
padding: 6px;
|
|
8
11
|
background-color: inherit;
|
|
9
|
-
border-radius: var(--
|
|
12
|
+
border-radius: var(--borderRadius100);
|
|
10
13
|
border: none;
|
|
11
14
|
cursor: pointer;
|
|
12
|
-
width: 32px;
|
|
13
|
-
font-size: 14px;
|
|
14
|
-
height: 32px;
|
|
15
|
-
|
|
16
|
-
${StyledIcon} {
|
|
17
|
-
width: auto;
|
|
18
|
-
}
|
|
19
15
|
|
|
20
16
|
${({
|
|
21
17
|
isActive,
|
|
@@ -25,6 +21,7 @@ const StyledToolbarButton = styled.button.attrs({
|
|
|
25
21
|
:active {
|
|
26
22
|
z-index: 1;
|
|
27
23
|
position: relative;
|
|
24
|
+
|
|
28
25
|
${theme.focusRedesignOptOut && /* istanbul ignore next */
|
|
29
26
|
css`
|
|
30
27
|
outline: 2px solid var(--colorsSemanticFocus500);
|
|
@@ -34,16 +31,14 @@ css`
|
|
|
34
31
|
${!theme.focusRedesignOptOut && css`
|
|
35
32
|
${addFocusStyling()}
|
|
36
33
|
`}
|
|
37
|
-
border-radius: var(--borderRadius050);
|
|
38
34
|
}
|
|
39
35
|
|
|
40
36
|
:hover {
|
|
41
|
-
background-color: var(--colorsActionMinor200);
|
|
42
|
-
border-radius: var(--borderRadius050);
|
|
37
|
+
background-color: ${!isActive && "var(--colorsActionMinor200)"};
|
|
43
38
|
}
|
|
44
39
|
|
|
45
40
|
${isActive && css`
|
|
46
|
-
background-color: var(--
|
|
41
|
+
background-color: var(--colorsActionMinor600);
|
|
47
42
|
`}
|
|
48
43
|
`}
|
|
49
44
|
`;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { InlineStyleType, BlockType } from "../../types";
|
|
2
|
+
import type { InlineStyleType, BlockType } from "../../types";
|
|
3
3
|
export interface ToolbarProps {
|
|
4
4
|
/** Used to override the active status of the inline controls */
|
|
5
5
|
activeControls: Record<InlineStyleType | BlockType, boolean>;
|
|
@@ -97,6 +97,7 @@ const Toolbar = ({
|
|
|
97
97
|
onFocus: () => setActiveTooltip("Bold"),
|
|
98
98
|
onBlur: () => setActiveTooltip("")
|
|
99
99
|
}, /*#__PURE__*/React.createElement(Icon, {
|
|
100
|
+
color: activeControls[BOLD] ? "var(--colorsActionMinorYang100)" : undefined,
|
|
100
101
|
type: "bold"
|
|
101
102
|
}))), /*#__PURE__*/React.createElement(Tooltip, {
|
|
102
103
|
isVisible: activeTooltip === "Italic",
|
|
@@ -114,6 +115,7 @@ const Toolbar = ({
|
|
|
114
115
|
onFocus: () => setActiveTooltip("Italic"),
|
|
115
116
|
onBlur: () => setActiveTooltip("")
|
|
116
117
|
}, /*#__PURE__*/React.createElement(Icon, {
|
|
118
|
+
color: activeControls[ITALIC] ? "var(--colorsActionMinorYang100)" : undefined,
|
|
117
119
|
type: "italic"
|
|
118
120
|
}))), /*#__PURE__*/React.createElement(Tooltip, {
|
|
119
121
|
isVisible: activeTooltip === "Bulleted List",
|
|
@@ -131,6 +133,7 @@ const Toolbar = ({
|
|
|
131
133
|
onFocus: () => setActiveTooltip("Bulleted List"),
|
|
132
134
|
onBlur: () => setActiveTooltip("")
|
|
133
135
|
}, /*#__PURE__*/React.createElement(Icon, {
|
|
136
|
+
color: activeControls[UNORDERED_LIST] ? "var(--colorsActionMinorYang100)" : undefined,
|
|
134
137
|
type: "bullet_list_dotted"
|
|
135
138
|
}))), /*#__PURE__*/React.createElement(Tooltip, {
|
|
136
139
|
isVisible: activeTooltip === "Numbered List",
|
|
@@ -148,6 +151,7 @@ const Toolbar = ({
|
|
|
148
151
|
onFocus: () => setActiveTooltip("Numbered List"),
|
|
149
152
|
onBlur: () => setActiveTooltip("")
|
|
150
153
|
}, /*#__PURE__*/React.createElement(Icon, {
|
|
154
|
+
color: activeControls[ORDERED_LIST] ? "var(--colorsActionMinorYang100)" : undefined,
|
|
151
155
|
type: "bullet_list_numbers"
|
|
152
156
|
})))), toolbarElements && /*#__PURE__*/React.createElement(StyledEditorActionControls, null, toolbarElements));
|
|
153
157
|
};
|
|
@@ -1,36 +1,28 @@
|
|
|
1
1
|
import styled from "styled-components";
|
|
2
|
-
import StyledButton from "../../../button/button.style";
|
|
3
2
|
const StyledToolbar = styled.div`
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
3
|
+
display: inline-flex;
|
|
4
|
+
justify-content: space-between;
|
|
5
|
+
flex-flow: row wrap;
|
|
6
|
+
gap: 8px;
|
|
7
|
+
padding: 12px;
|
|
8
|
+
height: fit-content;
|
|
9
|
+
width: 100%;
|
|
10
|
+
box-sizing: border-box;
|
|
12
11
|
border: none;
|
|
13
12
|
border-top: 1px solid var(--colorsUtilityMajor200);
|
|
14
13
|
background-color: var(--colorsUtilityMajor025);
|
|
15
|
-
|
|
14
|
+
user-select: none;
|
|
16
15
|
z-index: 10;
|
|
17
16
|
`;
|
|
18
17
|
const StyledEditorStyleControls = styled.div`
|
|
19
|
-
display: inline-
|
|
20
|
-
|
|
21
|
-
width: 50%;
|
|
22
|
-
min-width: 60px;
|
|
23
|
-
margin-left: -2px;
|
|
18
|
+
display: inline-flex;
|
|
19
|
+
gap: 8px;
|
|
24
20
|
`;
|
|
25
21
|
const StyledEditorActionControls = styled.div`
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
${StyledButton} {
|
|
32
|
-
width: 62px;
|
|
33
|
-
min-height: 33px;
|
|
34
|
-
}
|
|
22
|
+
flex-grow: 1;
|
|
23
|
+
display: inline-flex;
|
|
24
|
+
justify-content: flex-end;
|
|
25
|
+
flex-wrap: wrap;
|
|
26
|
+
gap: var(--spacing200);
|
|
35
27
|
`;
|
|
36
28
|
export { StyledToolbar, StyledEditorActionControls, StyledEditorStyleControls };
|
|
@@ -18,7 +18,6 @@ const StyledEditorContainer = styled.div`
|
|
|
18
18
|
}) => css`
|
|
19
19
|
border-radius: var(--borderRadius050);
|
|
20
20
|
min-height: ${rows ? `${rows * lineHeight}` : `${hasPreview ? 125 : 220}`}px;
|
|
21
|
-
min-width: 320px;
|
|
22
21
|
position: relative;
|
|
23
22
|
|
|
24
23
|
div.DraftEditor-root {
|
|
@@ -65,7 +64,6 @@ const StyledEditorOutline = styled.div`
|
|
|
65
64
|
}) => css`
|
|
66
65
|
border-radius: var(--borderRadius050);
|
|
67
66
|
outline: none;
|
|
68
|
-
min-width: 320px;
|
|
69
67
|
|
|
70
68
|
${isFocused && css`
|
|
71
69
|
${!theme.focusRedesignOptOut ? addFocusStyling() : `
|
|
@@ -8,6 +8,7 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
8
8
|
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
9
9
|
var _guid = _interopRequireDefault(require("../../__internal__/utils/helpers/guid"));
|
|
10
10
|
var _carbonScopedTokensProvider = _interopRequireDefault(require("../../style/design-tokens/carbon-scoped-tokens-provider/carbon-scoped-tokens-provider.component"));
|
|
11
|
+
var _portal = _interopRequireDefault(require("./portal.style"));
|
|
11
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
13
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
13
14
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -72,7 +73,7 @@ const Portal = ({
|
|
|
72
73
|
}
|
|
73
74
|
return node;
|
|
74
75
|
};
|
|
75
|
-
return /*#__PURE__*/_react.default.createElement(
|
|
76
|
+
return /*#__PURE__*/_react.default.createElement(_portal.default, {
|
|
76
77
|
"data-portal-entrance": uniqueId
|
|
77
78
|
}, /*#__PURE__*/_reactDom.default.createPortal( /*#__PURE__*/_react.default.createElement(_carbonScopedTokensProvider.default, null, children), getPortalContainer()));
|
|
78
79
|
};
|
|
@@ -0,0 +1,14 @@
|
|
|
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 StyledPortalEntrance = _styledComponents.default.span`
|
|
10
|
+
display: none;
|
|
11
|
+
height: 0;
|
|
12
|
+
width: 0;
|
|
13
|
+
`;
|
|
14
|
+
var _default = exports.default = StyledPortalEntrance;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { TagProps } from "__internal__/utils/helpers/tags";
|
|
2
|
+
import { TagProps } from "../../../__internal__/utils/helpers/tags";
|
|
3
3
|
export interface OptionProps extends Omit<React.InputHTMLAttributes<HTMLLIElement>, "value" | "onSelect" | "onClick">, TagProps {
|
|
4
4
|
/**
|
|
5
5
|
* Unique identifier for the component.
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
+
var _guid = _interopRequireDefault(require("../../../__internal__/utils/helpers/guid"));
|
|
9
10
|
var _option = _interopRequireDefault(require("./option.style"));
|
|
10
11
|
var _selectListContext = _interopRequireDefault(require("../__internal__/select-list-context"));
|
|
11
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -27,6 +28,7 @@ const Option = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
27
28
|
}, ref) => {
|
|
28
29
|
const selectListContext = (0, _react.useContext)(_selectListContext.default);
|
|
29
30
|
let isSelected = selectListContext.currentOptionsListIndex === index;
|
|
31
|
+
const internalIdRef = (0, _react.useRef)(id || (0, _guid.default)());
|
|
30
32
|
if (selectListContext.multiselectValues) {
|
|
31
33
|
isSelected = selectListContext.multiselectValues.includes(value);
|
|
32
34
|
}
|
|
@@ -38,7 +40,7 @@ const Option = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
38
40
|
onSelect?.({
|
|
39
41
|
text,
|
|
40
42
|
value,
|
|
41
|
-
id
|
|
43
|
+
id: internalIdRef.current
|
|
42
44
|
});
|
|
43
45
|
} else {
|
|
44
46
|
onSelect?.();
|
|
@@ -46,7 +48,7 @@ const Option = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
46
48
|
}
|
|
47
49
|
}
|
|
48
50
|
return /*#__PURE__*/_react.default.createElement(_option.default, _extends({
|
|
49
|
-
id:
|
|
51
|
+
id: internalIdRef.current,
|
|
50
52
|
ref: ref,
|
|
51
53
|
"aria-selected": isSelected,
|
|
52
54
|
"aria-disabled": disabled,
|
|
@@ -4,20 +4,26 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var _react =
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
+
var _guid = _interopRequireDefault(require("../../../__internal__/utils/helpers/guid"));
|
|
9
10
|
var _optionGroupHeader = _interopRequireDefault(require("./option-group-header.style"));
|
|
10
11
|
var _icon = _interopRequireDefault(require("../../icon"));
|
|
11
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
14
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
12
15
|
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); }
|
|
13
16
|
const OptionGroupHeader = /*#__PURE__*/_react.default.forwardRef(({
|
|
14
17
|
label,
|
|
15
18
|
icon,
|
|
16
19
|
style,
|
|
20
|
+
id,
|
|
17
21
|
...rest
|
|
18
22
|
}, ref) => {
|
|
23
|
+
const internalIdRef = (0, _react.useRef)(id || (0, _guid.default)());
|
|
19
24
|
return /*#__PURE__*/_react.default.createElement(_optionGroupHeader.default, _extends({
|
|
20
|
-
style: style
|
|
25
|
+
style: style,
|
|
26
|
+
id: internalIdRef.current
|
|
21
27
|
}, rest, {
|
|
22
28
|
ref: ref
|
|
23
29
|
}), icon && /*#__PURE__*/_react.default.createElement(_icon.default, {
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
+
var _guid = _interopRequireDefault(require("../../../__internal__/utils/helpers/guid"));
|
|
9
10
|
var _optionRow = _interopRequireDefault(require("./option-row.style"));
|
|
10
11
|
var _selectListContext = _interopRequireDefault(require("../__internal__/select-list-context"));
|
|
11
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -24,14 +25,15 @@ const OptionRow = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
24
25
|
style,
|
|
25
26
|
...rest
|
|
26
27
|
}, ref) => {
|
|
28
|
+
const internalIdRef = (0, _react.useRef)(id || (0, _guid.default)());
|
|
27
29
|
const handleClick = () => {
|
|
28
30
|
if (disabled) {
|
|
29
31
|
return;
|
|
30
32
|
}
|
|
31
33
|
onSelect?.({
|
|
32
|
-
id,
|
|
33
34
|
text,
|
|
34
|
-
value
|
|
35
|
+
value,
|
|
36
|
+
id: internalIdRef.current
|
|
35
37
|
});
|
|
36
38
|
};
|
|
37
39
|
const selectListContext = (0, _react.useContext)(_selectListContext.default);
|
|
@@ -40,7 +42,7 @@ const OptionRow = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
40
42
|
isSelected = selectListContext.multiselectValues.includes(value);
|
|
41
43
|
}
|
|
42
44
|
return /*#__PURE__*/_react.default.createElement(_optionRow.default, _extends({
|
|
43
|
-
id:
|
|
45
|
+
id: internalIdRef.current,
|
|
44
46
|
ref: ref,
|
|
45
47
|
"aria-selected": isSelected,
|
|
46
48
|
"aria-disabled": disabled,
|
|
@@ -22,7 +22,6 @@ var _listActionButton = _interopRequireDefault(require("../list-action-button"))
|
|
|
22
22
|
var _selectListContainer = _interopRequireDefault(require("./select-list-container.style"));
|
|
23
23
|
var _loader = _interopRequireDefault(require("../../loader"));
|
|
24
24
|
var _option = _interopRequireDefault(require("../option"));
|
|
25
|
-
var _guid = _interopRequireDefault(require("../../../__internal__/utils/helpers/guid"));
|
|
26
25
|
var _selectListContext = _interopRequireDefault(require("../__internal__/select-list-context"));
|
|
27
26
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
28
27
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
@@ -101,16 +100,23 @@ const SelectList = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
101
100
|
rangeExtractor
|
|
102
101
|
});
|
|
103
102
|
const items = virtualizer.getVirtualItems();
|
|
103
|
+
const childrenList = (0, _react.useMemo)(() => _react.default.Children.toArray(children), [children]);
|
|
104
|
+
const getIndexOfMatch = (0, _react.useCallback)(valueToMatch => {
|
|
105
|
+
return childrenList.findIndex(child => /*#__PURE__*/_react.default.isValidElement(child) && child.props.value === valueToMatch);
|
|
106
|
+
}, [childrenList]);
|
|
104
107
|
|
|
105
108
|
// getVirtualItems returns an empty array of items if the select list is currently closed - which is correct visually but
|
|
106
109
|
// we need to ensure that any currently-selected option is still in the DOM to avoid any accessibility issues.
|
|
107
110
|
// The isOpen prop will ensure that no options are visible regardless of what is in the items array.
|
|
108
|
-
if (items.length === 0
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
111
|
+
if (items.length === 0) {
|
|
112
|
+
const currentIndex = highlightedValue ? getIndexOfMatch(highlightedValue) : currentOptionsListIndex;
|
|
113
|
+
if (currentIndex > -1) {
|
|
114
|
+
// only index property is required with the item not visible so the following type assertion, even though incorrect,
|
|
115
|
+
// should be OK
|
|
116
|
+
items.push({
|
|
117
|
+
index: currentIndex
|
|
118
|
+
});
|
|
119
|
+
}
|
|
114
120
|
}
|
|
115
121
|
const listHeight = virtualizer.getTotalSize();
|
|
116
122
|
(0, _react.useEffect)(() => {
|
|
@@ -138,18 +144,9 @@ const SelectList = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
138
144
|
selectionConfirmed: true
|
|
139
145
|
});
|
|
140
146
|
}, [onSelect]);
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
// as that isn't absolutely guaranteed to never rerun when dependencies haven't changed.
|
|
145
|
-
const setChildIds = () => {
|
|
146
|
-
childIdsRef.current = _react.default.Children.map(children, child => /*#__PURE__*/_react.default.isValidElement(child) && child?.props.id || (0, _guid.default)()) || /* istanbul ignore next */null;
|
|
147
|
-
};
|
|
148
|
-
if (childIdsRef.current?.length !== _react.default.Children.count(children)) {
|
|
149
|
-
setChildIds();
|
|
150
|
-
}
|
|
151
|
-
const childIds = childIdsRef.current;
|
|
152
|
-
const childrenList = (0, _react.useMemo)(() => _react.default.Children.toArray(children), [children]);
|
|
147
|
+
const childElementRefs = (0, _react.useRef)(Array.from({
|
|
148
|
+
length: _react.default.Children.count(children)
|
|
149
|
+
}));
|
|
153
150
|
const optionChildrenList = (0, _react.useMemo)(() => childrenList.filter(child => /*#__PURE__*/_react.default.isValidElement(child) && (child.type === _option.default || child.type === _optionRow.default)), [childrenList]);
|
|
154
151
|
const {
|
|
155
152
|
measureElement
|
|
@@ -175,7 +172,6 @@ const SelectList = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
175
172
|
const isOption = optionChildIndex > -1;
|
|
176
173
|
const newProps = {
|
|
177
174
|
index,
|
|
178
|
-
id: childIds ? childIds[index] : /* istanbul ignore next */undefined,
|
|
179
175
|
onSelect: handleSelect,
|
|
180
176
|
hidden: isLoading && childrenList.length === 1,
|
|
181
177
|
// these need to be inline styles rather than implemented in styled-components to avoid it generating thousands of classes
|
|
@@ -184,8 +180,12 @@ const SelectList = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
184
180
|
},
|
|
185
181
|
"aria-setsize": isOption ? optionChildrenList.length : undefined,
|
|
186
182
|
"aria-posinset": isOption ? optionChildIndex + 1 : undefined,
|
|
187
|
-
|
|
188
|
-
|
|
183
|
+
ref: optionElement => {
|
|
184
|
+
// needed to dynamically compute the size
|
|
185
|
+
measureCallback(optionElement);
|
|
186
|
+
// add the DOM element to the array of refs
|
|
187
|
+
childElementRefs.current[index] = optionElement;
|
|
188
|
+
},
|
|
189
189
|
"data-index": index
|
|
190
190
|
};
|
|
191
191
|
return /*#__PURE__*/_react.default.cloneElement(child, newProps);
|
|
@@ -203,9 +203,6 @@ const SelectList = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
203
203
|
}
|
|
204
204
|
return nextIndex;
|
|
205
205
|
}, [childrenList, lastOptionIndex, isLoading]);
|
|
206
|
-
const getIndexOfMatch = (0, _react.useCallback)(valueToMatch => {
|
|
207
|
-
return childrenList.findIndex(child => /*#__PURE__*/_react.default.isValidElement(child) && child.props.value === valueToMatch);
|
|
208
|
-
}, [childrenList]);
|
|
209
206
|
const highlightNextItem = (0, _react.useCallback)(key => {
|
|
210
207
|
let currentIndex = currentOptionsListIndex;
|
|
211
208
|
if (highlightedValue) {
|
|
@@ -224,10 +221,10 @@ const SelectList = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
224
221
|
text,
|
|
225
222
|
value,
|
|
226
223
|
selectionType: "navigationKey",
|
|
227
|
-
id:
|
|
224
|
+
id: childElementRefs.current[nextIndex]?.id,
|
|
228
225
|
selectionConfirmed: false
|
|
229
226
|
});
|
|
230
|
-
}, [childrenList, currentOptionsListIndex, getIndexOfMatch, getNextHighlightableItemIndex, highlightedValue, onSelect
|
|
227
|
+
}, [childrenList, currentOptionsListIndex, getIndexOfMatch, getNextHighlightableItemIndex, highlightedValue, onSelect]);
|
|
231
228
|
const handleActionButtonTab = (0, _react.useCallback)((event, isActionButtonFocused) => {
|
|
232
229
|
if (isActionButtonFocused) {
|
|
233
230
|
onSelect({
|
|
@@ -271,7 +268,7 @@ const SelectList = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
271
268
|
value
|
|
272
269
|
} = currentOption.props;
|
|
273
270
|
onSelect({
|
|
274
|
-
id:
|
|
271
|
+
id: childElementRefs.current[currentOptionsListIndex]?.id,
|
|
275
272
|
text,
|
|
276
273
|
value,
|
|
277
274
|
selectionType: "enterKey",
|
|
@@ -281,7 +278,7 @@ const SelectList = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
281
278
|
focusOnAnchor();
|
|
282
279
|
highlightNextItem(key);
|
|
283
280
|
}
|
|
284
|
-
}, [childrenList, listActionButton, handleActionButtonTab, onSelectListClose, currentOptionsListIndex, onSelect, highlightNextItem, focusOnAnchor, isOpen
|
|
281
|
+
}, [childrenList, listActionButton, handleActionButtonTab, onSelectListClose, currentOptionsListIndex, onSelect, highlightNextItem, focusOnAnchor, isOpen]);
|
|
285
282
|
const handleEscapeKey = (0, _react.useCallback)(event => {
|
|
286
283
|
if (event.key === "Escape") {
|
|
287
284
|
onSelectListClose();
|
package/lib/components/text-editor/__internal__/toolbar/toolbar-button/toolbar-button.style.js
CHANGED
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
8
|
-
var _icon = _interopRequireDefault(require("../../../../icon/icon.style"));
|
|
9
8
|
var _themes = require("../../../../../style/themes");
|
|
10
9
|
var _addFocusStyling = _interopRequireDefault(require("../../../../../style/utils/add-focus-styling"));
|
|
11
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -14,17 +13,14 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
14
13
|
const StyledToolbarButton = _styledComponents.default.button.attrs({
|
|
15
14
|
type: "button"
|
|
16
15
|
})`
|
|
16
|
+
display: inline-flex;
|
|
17
|
+
justify-content: center;
|
|
18
|
+
align-items: center;
|
|
19
|
+
padding: 6px;
|
|
17
20
|
background-color: inherit;
|
|
18
|
-
border-radius: var(--
|
|
21
|
+
border-radius: var(--borderRadius100);
|
|
19
22
|
border: none;
|
|
20
23
|
cursor: pointer;
|
|
21
|
-
width: 32px;
|
|
22
|
-
font-size: 14px;
|
|
23
|
-
height: 32px;
|
|
24
|
-
|
|
25
|
-
${_icon.default} {
|
|
26
|
-
width: auto;
|
|
27
|
-
}
|
|
28
24
|
|
|
29
25
|
${({
|
|
30
26
|
isActive,
|
|
@@ -34,6 +30,7 @@ const StyledToolbarButton = _styledComponents.default.button.attrs({
|
|
|
34
30
|
:active {
|
|
35
31
|
z-index: 1;
|
|
36
32
|
position: relative;
|
|
33
|
+
|
|
37
34
|
${theme.focusRedesignOptOut && /* istanbul ignore next */
|
|
38
35
|
(0, _styledComponents.css)`
|
|
39
36
|
outline: 2px solid var(--colorsSemanticFocus500);
|
|
@@ -43,16 +40,14 @@ const StyledToolbarButton = _styledComponents.default.button.attrs({
|
|
|
43
40
|
${!theme.focusRedesignOptOut && (0, _styledComponents.css)`
|
|
44
41
|
${(0, _addFocusStyling.default)()}
|
|
45
42
|
`}
|
|
46
|
-
border-radius: var(--borderRadius050);
|
|
47
43
|
}
|
|
48
44
|
|
|
49
45
|
:hover {
|
|
50
|
-
background-color: var(--colorsActionMinor200);
|
|
51
|
-
border-radius: var(--borderRadius050);
|
|
46
|
+
background-color: ${!isActive && "var(--colorsActionMinor200)"};
|
|
52
47
|
}
|
|
53
48
|
|
|
54
49
|
${isActive && (0, _styledComponents.css)`
|
|
55
|
-
background-color: var(--
|
|
50
|
+
background-color: var(--colorsActionMinor600);
|
|
56
51
|
`}
|
|
57
52
|
`}
|
|
58
53
|
`;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { InlineStyleType, BlockType } from "../../types";
|
|
2
|
+
import type { InlineStyleType, BlockType } from "../../types";
|
|
3
3
|
export interface ToolbarProps {
|
|
4
4
|
/** Used to override the active status of the inline controls */
|
|
5
5
|
activeControls: Record<InlineStyleType | BlockType, boolean>;
|
|
@@ -106,6 +106,7 @@ const Toolbar = ({
|
|
|
106
106
|
onFocus: () => setActiveTooltip("Bold"),
|
|
107
107
|
onBlur: () => setActiveTooltip("")
|
|
108
108
|
}, /*#__PURE__*/_react.default.createElement(_icon.default, {
|
|
109
|
+
color: activeControls[_types.BOLD] ? "var(--colorsActionMinorYang100)" : undefined,
|
|
109
110
|
type: "bold"
|
|
110
111
|
}))), /*#__PURE__*/_react.default.createElement(_tooltip.default, {
|
|
111
112
|
isVisible: activeTooltip === "Italic",
|
|
@@ -123,6 +124,7 @@ const Toolbar = ({
|
|
|
123
124
|
onFocus: () => setActiveTooltip("Italic"),
|
|
124
125
|
onBlur: () => setActiveTooltip("")
|
|
125
126
|
}, /*#__PURE__*/_react.default.createElement(_icon.default, {
|
|
127
|
+
color: activeControls[_types.ITALIC] ? "var(--colorsActionMinorYang100)" : undefined,
|
|
126
128
|
type: "italic"
|
|
127
129
|
}))), /*#__PURE__*/_react.default.createElement(_tooltip.default, {
|
|
128
130
|
isVisible: activeTooltip === "Bulleted List",
|
|
@@ -140,6 +142,7 @@ const Toolbar = ({
|
|
|
140
142
|
onFocus: () => setActiveTooltip("Bulleted List"),
|
|
141
143
|
onBlur: () => setActiveTooltip("")
|
|
142
144
|
}, /*#__PURE__*/_react.default.createElement(_icon.default, {
|
|
145
|
+
color: activeControls[_types.UNORDERED_LIST] ? "var(--colorsActionMinorYang100)" : undefined,
|
|
143
146
|
type: "bullet_list_dotted"
|
|
144
147
|
}))), /*#__PURE__*/_react.default.createElement(_tooltip.default, {
|
|
145
148
|
isVisible: activeTooltip === "Numbered List",
|
|
@@ -157,6 +160,7 @@ const Toolbar = ({
|
|
|
157
160
|
onFocus: () => setActiveTooltip("Numbered List"),
|
|
158
161
|
onBlur: () => setActiveTooltip("")
|
|
159
162
|
}, /*#__PURE__*/_react.default.createElement(_icon.default, {
|
|
163
|
+
color: activeControls[_types.ORDERED_LIST] ? "var(--colorsActionMinorYang100)" : undefined,
|
|
160
164
|
type: "bullet_list_numbers"
|
|
161
165
|
})))), toolbarElements && /*#__PURE__*/_react.default.createElement(_toolbar.StyledEditorActionControls, null, toolbarElements));
|
|
162
166
|
};
|
|
@@ -5,38 +5,30 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.StyledToolbar = exports.StyledEditorStyleControls = exports.StyledEditorActionControls = void 0;
|
|
7
7
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
8
|
-
var _button = _interopRequireDefault(require("../../../button/button.style"));
|
|
9
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
9
|
const StyledToolbar = exports.StyledToolbar = _styledComponents.default.div`
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
10
|
+
display: inline-flex;
|
|
11
|
+
justify-content: space-between;
|
|
12
|
+
flex-flow: row wrap;
|
|
13
|
+
gap: 8px;
|
|
14
|
+
padding: 12px;
|
|
15
|
+
height: fit-content;
|
|
16
|
+
width: 100%;
|
|
17
|
+
box-sizing: border-box;
|
|
19
18
|
border: none;
|
|
20
19
|
border-top: 1px solid var(--colorsUtilityMajor200);
|
|
21
20
|
background-color: var(--colorsUtilityMajor025);
|
|
22
|
-
|
|
21
|
+
user-select: none;
|
|
23
22
|
z-index: 10;
|
|
24
23
|
`;
|
|
25
24
|
const StyledEditorStyleControls = exports.StyledEditorStyleControls = _styledComponents.default.div`
|
|
26
|
-
display: inline-
|
|
27
|
-
|
|
28
|
-
width: 50%;
|
|
29
|
-
min-width: 60px;
|
|
30
|
-
margin-left: -2px;
|
|
25
|
+
display: inline-flex;
|
|
26
|
+
gap: 8px;
|
|
31
27
|
`;
|
|
32
28
|
const StyledEditorActionControls = exports.StyledEditorActionControls = _styledComponents.default.div`
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
${_button.default} {
|
|
39
|
-
width: 62px;
|
|
40
|
-
min-height: 33px;
|
|
41
|
-
}
|
|
29
|
+
flex-grow: 1;
|
|
30
|
+
display: inline-flex;
|
|
31
|
+
justify-content: flex-end;
|
|
32
|
+
flex-wrap: wrap;
|
|
33
|
+
gap: var(--spacing200);
|
|
42
34
|
`;
|
|
@@ -27,7 +27,6 @@ const StyledEditorContainer = exports.StyledEditorContainer = _styledComponents.
|
|
|
27
27
|
}) => (0, _styledComponents.css)`
|
|
28
28
|
border-radius: var(--borderRadius050);
|
|
29
29
|
min-height: ${rows ? `${rows * lineHeight}` : `${hasPreview ? 125 : 220}`}px;
|
|
30
|
-
min-width: 320px;
|
|
31
30
|
position: relative;
|
|
32
31
|
|
|
33
32
|
div.DraftEditor-root {
|
|
@@ -74,7 +73,6 @@ const StyledEditorOutline = exports.StyledEditorOutline = _styledComponents.defa
|
|
|
74
73
|
}) => (0, _styledComponents.css)`
|
|
75
74
|
border-radius: var(--borderRadius050);
|
|
76
75
|
outline: none;
|
|
77
|
-
min-width: 320px;
|
|
78
76
|
|
|
79
77
|
${isFocused && (0, _styledComponents.css)`
|
|
80
78
|
${!theme.focusRedesignOptOut ? (0, _addFocusStyling.default)() : `
|