@jetbrains/ring-ui 7.0.0-beta.8 → 7.0.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/babel.config.js +20 -14
- package/components/alert/alert.css +7 -7
- package/components/alert/alert.d.ts +2 -2
- package/components/alert/alert.js +10 -12
- package/components/alert/container.js +1 -1
- package/components/alert-service/alert-service.js +4 -2
- package/components/analytics/analytics__custom-plugin.js +1 -1
- package/components/auth/auth.js +1 -1
- package/components/auth/auth__core.js +36 -36
- package/components/auth/background-flow.js +2 -2
- package/components/auth/down-notification.js +3 -1
- package/components/auth/iframe-flow.js +4 -2
- package/components/auth/request-builder.js +5 -5
- package/components/auth/storage.js +10 -9
- package/components/auth/token-validator.js +8 -15
- package/components/auth-dialog/auth-dialog.js +8 -8
- package/components/auth-dialog-service/auth-dialog-service.js +4 -4
- package/components/avatar/avatar.js +9 -7
- package/components/avatar/fallback-avatar.js +15 -12
- package/components/button/button.css +36 -25
- package/components/button/button.js +9 -9
- package/components/button/button__classes.d.ts +1 -1
- package/components/button/button__classes.js +3 -4
- package/components/button-group/button-group.css +25 -13
- package/components/button-group/caption.js +1 -1
- package/components/button-toolbar/button-toolbar.d.ts +1 -1
- package/components/button-toolbar/button-toolbar.js +2 -2
- package/components/caret/caret.js +8 -8
- package/components/checkbox/checkbox.css +8 -5
- package/components/checkbox/checkbox.js +1 -1
- package/components/clipboard/clipboard-fallback.js +2 -6
- package/components/clipboard/clipboard.js +5 -5
- package/components/code/code.d.ts +1 -1
- package/components/code/code.js +2 -2
- package/components/code/highlight.css +3 -1
- package/components/collapse/collapse-content.d.ts +1 -2
- package/components/collapse/collapse-content.js +25 -14
- package/components/collapse/collapse-context.js +1 -1
- package/components/collapse/collapse-control.js +5 -3
- package/components/collapse/collapse.css +21 -20
- package/components/collapse/collapse.js +2 -2
- package/components/confirm/confirm.d.ts +2 -2
- package/components/confirm/confirm.js +2 -2
- package/components/confirm-service/confirm-service.d.ts +1 -1
- package/components/confirm-service/confirm-service.js +6 -6
- package/components/content-layout/content-layout.css +6 -5
- package/components/content-layout/content-layout.js +7 -6
- package/components/content-layout/sidebar.js +5 -5
- package/components/contenteditable/contenteditable.d.ts +1 -1
- package/components/contenteditable/contenteditable.js +3 -4
- package/components/control-label/control-label.js +5 -3
- package/components/data-list/data-list.css +3 -3
- package/components/data-list/data-list.d.ts +2 -2
- package/components/data-list/data-list.js +6 -7
- package/components/data-list/data-list.mock.js +57 -47
- package/components/data-list/item.js +14 -16
- package/components/data-list/selection.js +5 -7
- package/components/data-list/title.js +5 -6
- package/components/date-picker/consts.js +2 -2
- package/components/date-picker/date-input.js +4 -4
- package/components/date-picker/date-picker.css +23 -18
- package/components/date-picker/date-picker.d.ts +2 -1
- package/components/date-picker/date-picker.js +13 -19
- package/components/date-picker/date-popup.js +30 -36
- package/components/date-picker/day.js +6 -9
- package/components/date-picker/formats.js +647 -1
- package/components/date-picker/month-names.js +6 -8
- package/components/date-picker/month-slider.js +2 -2
- package/components/date-picker/month.js +1 -3
- package/components/date-picker/months.js +2 -6
- package/components/date-picker/weekdays.js +2 -3
- package/components/date-picker/years.js +3 -3
- package/components/dialog/dialog.d.ts +1 -0
- package/components/dialog/dialog.js +20 -13
- package/components/dialog/dialog__body-scroll-preventer.js +1 -1
- package/components/dropdown/dropdown.css +2 -4
- package/components/dropdown/dropdown.d.ts +2 -2
- package/components/dropdown/dropdown.js +5 -5
- package/components/dropdown-menu/dropdown-menu.js +5 -5
- package/components/editable-heading/editable-heading.css +5 -2
- package/components/editable-heading/editable-heading.js +21 -19
- package/components/error-bubble/error-bubble.js +1 -1
- package/components/error-message/error-message.js +2 -4
- package/components/footer/footer.js +11 -15
- package/components/form/form.stories.js +45 -63
- package/components/global/create-stateful-context.js +2 -4
- package/components/global/data-tests.js +5 -6
- package/components/global/dom.js +8 -11
- package/components/global/focus-sensor-hoc.js +5 -6
- package/components/global/fuzzy-highlight.js +1 -1
- package/components/global/get-event-key.js +2 -2
- package/components/global/global.css +0 -3
- package/components/global/linear-function.js +1 -1
- package/components/global/normalize-indent.js +2 -6
- package/components/global/react-dom-renderer.js +2 -3
- package/components/global/theme.d.ts +4 -2
- package/components/global/theme.js +14 -12
- package/components/global/url.js +8 -8
- package/components/global/variables.css +1 -8
- package/components/global/variables_dark.css +0 -1
- package/components/grid/col.js +6 -6
- package/components/grid/grid.css +174 -173
- package/components/grid/grid.js +1 -1
- package/components/grid/row.js +13 -6
- package/components/group/group.js +1 -1
- package/components/header/header-icon.js +2 -2
- package/components/header/header.css +19 -15
- package/components/header/header.js +3 -5
- package/components/header/links.js +1 -1
- package/components/header/logo.js +1 -1
- package/components/header/profile.d.ts +2 -2
- package/components/header/profile.js +9 -9
- package/components/header/services-link.js +1 -1
- package/components/header/services.js +4 -5
- package/components/header/smart-profile.js +4 -3
- package/components/header/smart-services.js +9 -5
- package/components/header/tray.js +1 -1
- package/components/heading/heading.css +0 -1
- package/components/heading/heading.js +2 -2
- package/components/http/http.d.ts +3 -3
- package/components/http/http.js +25 -29
- package/components/http/http.mock.js +9 -6
- package/components/hub-source/hub-source.js +5 -7
- package/components/hub-source/hub-source__user.js +1 -1
- package/components/hub-source/hub-source__users-groups.js +6 -7
- package/components/i18n/README.md +3 -4
- package/components/i18n/i18n-context.js +2 -4
- package/components/icon/icon.css +1 -1
- package/components/icon/icon.js +7 -9
- package/components/icon/icon__svg.js +6 -6
- package/components/input/input.css +1 -1
- package/components/input/input.js +11 -14
- package/components/input-size/input-size.stories.js +42 -22
- package/components/island/adaptive-island-hoc.js +1 -1
- package/components/island/content.js +4 -6
- package/components/island/header.js +8 -10
- package/components/island/island.css +5 -5
- package/components/island/island.js +1 -1
- package/components/link/clickableLink.js +3 -1
- package/components/link/link.js +5 -3
- package/components/list/consts.js +1 -1
- package/components/list/list.d.ts +1 -1
- package/components/list/list.js +35 -57
- package/components/list/list__custom.js +3 -5
- package/components/list/list__hint.js +3 -1
- package/components/list/list__item.js +11 -9
- package/components/list/list__link.js +1 -1
- package/components/list/list__separator.js +2 -2
- package/components/list/list__title.js +7 -3
- package/components/list/list__users-groups-source.js +6 -8
- package/components/loader/loader.js +1 -1
- package/components/loader/loader__core.js +5 -5
- package/components/loader-inline/loader-inline.css +0 -3
- package/components/loader-inline/loader-inline.js +5 -7
- package/components/loader-screen/loader-screen.js +1 -1
- package/components/login-dialog/login-dialog.js +4 -4
- package/components/login-dialog/service.js +5 -5
- package/components/markdown/markdown.css +6 -6
- package/components/markdown/markdown.d.ts +2 -2
- package/components/markdown/markdown.js +4 -6
- package/components/message/message.css +2 -1
- package/components/message/message.js +30 -21
- package/components/old-browsers-message/old-browsers-message.js +2 -2
- package/components/old-browsers-message/white-list.js +2 -3
- package/components/pager/pager.js +28 -29
- package/components/permissions/permissions.js +8 -13
- package/components/permissions/permissions__cache.js +6 -7
- package/components/popup/popup.consts.js +8 -2
- package/components/popup/popup.js +27 -33
- package/components/popup/popup.target.js +4 -4
- package/components/popup/position.js +21 -28
- package/components/popup-menu/popup-menu.js +1 -1
- package/components/progress-bar/progress-bar.css +10 -8
- package/components/progress-bar/progress-bar.d.ts +2 -2
- package/components/progress-bar/progress-bar.js +2 -2
- package/components/query-assist/query-assist.css +0 -3
- package/components/query-assist/query-assist.js +73 -84
- package/components/query-assist/query-assist__suggestions.js +10 -9
- package/components/radio/radio.css +6 -2
- package/components/radio/radio.js +1 -3
- package/components/scrollable-section/scrollable-section.css +5 -6
- package/components/scrollable-section/scrollable-section.js +1 -1
- package/components/select/select.css +5 -7
- package/components/select/select.d.ts +1 -1
- package/components/select/select.js +96 -110
- package/components/select/select__filter.js +1 -1
- package/components/select/select__popup.js +40 -51
- package/components/shortcuts/core.js +8 -6
- package/components/shortcuts/shortcut-title.js +6 -6
- package/components/shortcuts/shortcuts.js +1 -1
- package/components/sidebar/sidebar.css +3 -1
- package/components/slider/slider.css +14 -14
- package/components/slider/slider.js +7 -7
- package/components/tab-trap/tab-trap.js +7 -9
- package/components/table/cell.js +3 -1
- package/components/table/disable-hover-hoc.js +2 -2
- package/components/table/header-cell.js +5 -3
- package/components/table/header.d.ts +2 -10
- package/components/table/header.js +10 -12
- package/components/table/multitable.js +5 -3
- package/components/table/row.d.ts +0 -1
- package/components/table/row.js +20 -27
- package/components/table/selection-adapter.js +1 -1
- package/components/table/selection-shortcuts-hoc.js +2 -2
- package/components/table/selection.d.ts +2 -3
- package/components/table/selection.js +4 -5
- package/components/table/simple-table.js +4 -4
- package/components/table/smart-table.js +5 -5
- package/components/table/table.css +8 -9
- package/components/table/table.d.ts +0 -1
- package/components/table/table.js +22 -23
- package/components/table/table.stories.json +45 -16
- package/components/tabs/collapsible-more.d.ts +1 -1
- package/components/tabs/collapsible-more.js +13 -16
- package/components/tabs/collapsible-tab.js +2 -2
- package/components/tabs/collapsible-tabs.d.ts +2 -2
- package/components/tabs/collapsible-tabs.js +13 -22
- package/components/tabs/dumb-tabs.js +6 -9
- package/components/tabs/smart-tabs.js +4 -4
- package/components/tabs/tab-link.js +1 -3
- package/components/tabs/tabs.css +7 -9
- package/components/tag/tag.css +7 -7
- package/components/tag/tag.d.ts +1 -1
- package/components/tag/tag.js +9 -12
- package/components/tags-input/tags-input.js +15 -19
- package/components/tags-list/tags-list.d.ts +2 -2
- package/components/tags-list/tags-list.js +6 -5
- package/components/text/text.js +5 -3
- package/components/toggle/toggle.css +12 -10
- package/components/toggle/toggle.d.ts +2 -2
- package/components/toggle/toggle.js +4 -3
- package/components/tooltip/tooltip.d.ts +4 -1
- package/components/tooltip/tooltip.js +19 -10
- package/components/user-agreement/service.js +15 -13
- package/components/user-agreement/user-agreement.js +3 -5
- package/components/user-card/card.js +10 -9
- package/components/user-card/smart-user-card-tooltip.js +5 -7
- package/components/user-card/tooltip.js +4 -4
- package/components/user-card/user-card.css +4 -0
- package/jslint-xml.js +20 -19
- package/package.json +66 -58
- package/postcss.config.js +3 -4
- package/typings.d.ts +2 -4
- package/webpack.config.js +20 -25
- package/components/badge/badge.css +0 -42
- package/components/badge/badge.d.ts +0 -14
- package/components/badge/badge.js +0 -29
- package/components/island-legacy/content-legacy.d.ts +0 -5
- package/components/island-legacy/content-legacy.js +0 -12
- package/components/island-legacy/header-legacy.d.ts +0 -5
- package/components/island-legacy/header-legacy.js +0 -14
- package/components/island-legacy/island-legacy.css +0 -98
- package/components/island-legacy/island-legacy.d.ts +0 -7
- package/components/island-legacy/island-legacy.js +0 -14
- package/components/table-legacy/table-legacy.css +0 -346
- package/components/table-legacy/table-legacy__toolbar.css +0 -25
|
@@ -6,18 +6,16 @@ import { FakeMoreButton, MoreButton } from './collapsible-more';
|
|
|
6
6
|
import getTabTitles from './collapsible-tab';
|
|
7
7
|
const DEFAULT_DEBOUNCE_INTERVAL = 100;
|
|
8
8
|
const MEASURE_TOLERANCE = 0.5;
|
|
9
|
-
export const CollapsibleTabs = ({ children, selected, onSelect, moreClassName, moreActiveClassName, morePopupClassName, morePopupBeforeEnd, morePopupItemClassName, initialVisibleItems }) => {
|
|
9
|
+
export const CollapsibleTabs = ({ children, selected, onSelect, moreClassName, moreActiveClassName, morePopupClassName, morePopupBeforeEnd, morePopupItemClassName, initialVisibleItems, }) => {
|
|
10
10
|
const [sizes, setSizes] = useState({ tabs: [], more: undefined });
|
|
11
11
|
const [lastVisibleIndex, setLastVisibleIndex] = useState(null);
|
|
12
12
|
const elements = { sizes, lastVisibleIndex };
|
|
13
13
|
const [preparedElements, setPreparedElements] = useState({
|
|
14
14
|
visible: [],
|
|
15
|
-
hidden: []
|
|
15
|
+
hidden: [],
|
|
16
16
|
});
|
|
17
17
|
const measureRef = useRef(null);
|
|
18
|
-
const selectedIndex = useMemo(() => children.
|
|
19
|
-
filter(tab => tab.props.alwaysHidden !== true).
|
|
20
|
-
findIndex(tab => tab.props.id === selected) ?? null, [children, selected]);
|
|
18
|
+
const selectedIndex = useMemo(() => children.filter(tab => tab.props.alwaysHidden !== true).findIndex(tab => tab.props.id === selected) ?? null, [children, selected]);
|
|
21
19
|
const visibleElements = useMemo(() => {
|
|
22
20
|
let items;
|
|
23
21
|
if (preparedElements.ready) {
|
|
@@ -31,22 +29,15 @@ export const CollapsibleTabs = ({ children, selected, onSelect, moreClassName, m
|
|
|
31
29
|
return getTabTitles({
|
|
32
30
|
items,
|
|
33
31
|
selected,
|
|
34
|
-
onSelect
|
|
32
|
+
onSelect,
|
|
35
33
|
});
|
|
36
|
-
}, [
|
|
37
|
-
initialVisibleItems,
|
|
38
|
-
children,
|
|
39
|
-
preparedElements.ready,
|
|
40
|
-
preparedElements.visible,
|
|
41
|
-
onSelect,
|
|
42
|
-
selected
|
|
43
|
-
]);
|
|
34
|
+
}, [initialVisibleItems, children, preparedElements.ready, preparedElements.visible, onSelect, selected]);
|
|
44
35
|
const adjustTabs = useCallback((entry) => {
|
|
45
36
|
const containerWidth = entry.contentRect.width;
|
|
46
37
|
const { tabs: tabsSizes, more = 0 } = elements.sizes;
|
|
47
38
|
let renderMore = children.some(tab => tab.props.alwaysHidden);
|
|
48
39
|
const tabsToRender = [];
|
|
49
|
-
let filledWidth = renderMore ? more ?? 0 : 0;
|
|
40
|
+
let filledWidth = renderMore ? (more ?? 0) : 0;
|
|
50
41
|
for (let i = 0; i < tabsSizes.length; i++) {
|
|
51
42
|
if (filledWidth + tabsSizes[i] < containerWidth + MEASURE_TOLERANCE) {
|
|
52
43
|
filledWidth += tabsSizes[i];
|
|
@@ -90,8 +81,7 @@ export const CollapsibleTabs = ({ children, selected, onSelect, moreClassName, m
|
|
|
90
81
|
useEffect(() => {
|
|
91
82
|
const timeout = setTimeout(() => {
|
|
92
83
|
const res = children.reduce((accumulator, tab) => {
|
|
93
|
-
if (tab.props.alwaysHidden !== true &&
|
|
94
|
-
accumulator.visible.length - 1 < (elements.lastVisibleIndex ?? 0)) {
|
|
84
|
+
if (tab.props.alwaysHidden !== true && accumulator.visible.length - 1 < (elements.lastVisibleIndex ?? 0)) {
|
|
95
85
|
accumulator.visible.push(tab);
|
|
96
86
|
}
|
|
97
87
|
else {
|
|
@@ -132,15 +122,17 @@ export const CollapsibleTabs = ({ children, selected, onSelect, moreClassName, m
|
|
|
132
122
|
const descendants = [...(container?.children ?? [])];
|
|
133
123
|
const moreButton = descendants.pop();
|
|
134
124
|
let moreButtonWidth = moreButton?.offsetWidth ?? 0;
|
|
135
|
-
const { marginLeft: moreButtonMarginLeft = '0', marginRight: moreButtonMarginRight = '0' } = moreButton
|
|
125
|
+
const { marginLeft: moreButtonMarginLeft = '0', marginRight: moreButtonMarginRight = '0' } = moreButton
|
|
126
|
+
? getComputedStyle(moreButton)
|
|
127
|
+
: {};
|
|
136
128
|
moreButtonWidth += +moreButtonMarginLeft.replace('px', '') + +moreButtonMarginRight.replace('px', '');
|
|
137
129
|
const tabsWidth = descendants.map(node => {
|
|
138
130
|
const { marginLeft, marginRight } = getComputedStyle(node);
|
|
139
131
|
const width = node.getBoundingClientRect().width;
|
|
140
132
|
return width + +marginLeft.replace('px', '') + +marginRight.replace('px', '');
|
|
141
133
|
});
|
|
142
|
-
const newSummaryWidth = tabsWidth.reduce((acc, curr) =>
|
|
143
|
-
const oldSummaryWidth = elements.sizes.tabs.reduce((acc, curr) =>
|
|
134
|
+
const newSummaryWidth = tabsWidth.reduce((acc, curr) => acc + curr, 0);
|
|
135
|
+
const oldSummaryWidth = elements.sizes.tabs.reduce((acc, curr) => acc + curr, 0);
|
|
144
136
|
if (elements.sizes.more !== moreButtonWidth || newSummaryWidth !== oldSummaryWidth) {
|
|
145
137
|
fastdom.mutate(() => setSizes({ more: moreButtonWidth, tabs: tabsWidth }));
|
|
146
138
|
}
|
|
@@ -167,8 +159,7 @@ export const CollapsibleTabs = ({ children, selected, onSelect, moreClassName, m
|
|
|
167
159
|
resizeObserver.disconnect();
|
|
168
160
|
};
|
|
169
161
|
}, [adjustTabs]);
|
|
170
|
-
const isAdjusted = (elements.lastVisibleIndex !== null &&
|
|
171
|
-
preparedElements.ready === true) || initialVisibleItems;
|
|
162
|
+
const isAdjusted = (elements.lastVisibleIndex !== null && preparedElements.ready === true) || initialVisibleItems;
|
|
172
163
|
const className = classNames(styles.titles, styles.autoCollapse, isAdjusted && styles.adjusted);
|
|
173
164
|
return (<div className={styles.autoCollapseContainer}>
|
|
174
165
|
<div className={classNames(className, styles.rendered)}>
|
|
@@ -10,7 +10,7 @@ import { CustomItem } from './custom-item';
|
|
|
10
10
|
export { CustomItem };
|
|
11
11
|
class Tabs extends PureComponent {
|
|
12
12
|
static defaultProps = {
|
|
13
|
-
onSelect() { }
|
|
13
|
+
onSelect() { },
|
|
14
14
|
};
|
|
15
15
|
handleSelect = memoize((key) => () => this.props.onSelect(key));
|
|
16
16
|
getTabTitle = (child, i) => {
|
|
@@ -22,21 +22,18 @@ class Tabs extends PureComponent {
|
|
|
22
22
|
const key = id || String(i);
|
|
23
23
|
const isSelected = key === selected;
|
|
24
24
|
const titleClasses = classNames(styles.title, className, isSelected && activeClassName, {
|
|
25
|
-
[styles.selected]: isSelected
|
|
25
|
+
[styles.selected]: isSelected,
|
|
26
26
|
});
|
|
27
27
|
return (<TabLink title={title} isSelected={isSelected} key={key} href={href} className={titleClasses} disabled={disabled} onPlainLeftClick={this.handleSelect(key)} {...titleProps}/>);
|
|
28
28
|
};
|
|
29
29
|
render() {
|
|
30
30
|
const { className, tabContainerClassName, children, selected, autoCollapse, 'data-test': dataTest, ...restProps } = this.props;
|
|
31
31
|
const classes = classNames(styles.tabs, className);
|
|
32
|
-
const childrenArray = React.Children.toArray(children).
|
|
33
|
-
filter(Boolean);
|
|
32
|
+
const childrenArray = React.Children.toArray(children).filter(Boolean);
|
|
34
33
|
return (<div className={classes} data-test={dataTests('ring-dumb-tabs', dataTest)}>
|
|
35
|
-
{autoCollapse === true
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
{childrenArray.map(this.getTabTitle)}
|
|
39
|
-
</div>)}
|
|
34
|
+
{autoCollapse === true ? (<CollapsibleTabs {...restProps} onSelect={this.handleSelect} selected={selected}>
|
|
35
|
+
{childrenArray}
|
|
36
|
+
</CollapsibleTabs>) : (<div className={styles.titles}>{childrenArray.map(this.getTabTitle)}</div>)}
|
|
40
37
|
<div className={classNames(tabContainerClassName)}>
|
|
41
38
|
{childrenArray.find(({ props }, i) => (props.id || String(i)) === selected)}
|
|
42
39
|
</div>
|
|
@@ -5,15 +5,15 @@ export default class SmartTabs extends PureComponent {
|
|
|
5
5
|
constructor(props) {
|
|
6
6
|
super(props);
|
|
7
7
|
this.state = {
|
|
8
|
-
selected: this.props.initSelected ||
|
|
9
|
-
(Array.isArray(this.props.children) && this.props.children[0].props.id) ||
|
|
10
|
-
'0'
|
|
8
|
+
selected: this.props.initSelected || (Array.isArray(this.props.children) && this.props.children[0].props.id) || '0',
|
|
11
9
|
};
|
|
12
10
|
}
|
|
13
11
|
state;
|
|
14
12
|
handleSelect = (selected) => this.setState({ selected });
|
|
15
13
|
render() {
|
|
16
14
|
const { children, initSelected, 'data-test': dataTest, ...restProps } = this.props;
|
|
17
|
-
return (<Tabs data-test={dataTests('ring-smart-tabs', dataTest)} selected={this.state.selected} onSelect={this.handleSelect} {...restProps}>
|
|
15
|
+
return (<Tabs data-test={dataTests('ring-smart-tabs', dataTest)} selected={this.state.selected} onSelect={this.handleSelect} {...restProps}>
|
|
16
|
+
{children}
|
|
17
|
+
</Tabs>);
|
|
18
18
|
}
|
|
19
19
|
}
|
|
@@ -2,9 +2,7 @@ import { memo } from 'react';
|
|
|
2
2
|
import Link from '../link/link';
|
|
3
3
|
import styles from './tabs.css';
|
|
4
4
|
function TabLink({ isSelected, title, collapsed, ...restProps }) {
|
|
5
|
-
const renderedTitle = typeof title === 'function'
|
|
6
|
-
? title(isSelected, collapsed)
|
|
7
|
-
: title;
|
|
5
|
+
const renderedTitle = typeof title === 'function' ? title(isSelected, collapsed) : title;
|
|
8
6
|
return (<Link {...restProps}>
|
|
9
7
|
<div className={styles.container}>
|
|
10
8
|
<span className={styles.visible}>{renderedTitle}</span>
|
package/components/tabs/tabs.css
CHANGED
|
@@ -3,20 +3,18 @@
|
|
|
3
3
|
/* ensure styles order */
|
|
4
4
|
@import "../link/link.css";
|
|
5
5
|
|
|
6
|
-
@value dark from "../global/variables_dark.css";
|
|
7
|
-
@value line-shadow: inset 0 -1px 0 0;
|
|
8
|
-
@value selected-line-shadow: inset 0 -2px 0 0;
|
|
9
|
-
|
|
10
6
|
:root {
|
|
11
7
|
--ring-selected-tab-color: var(--ring-text-color);
|
|
12
8
|
}
|
|
13
9
|
|
|
14
|
-
.dark,
|
|
15
10
|
:global(.ring-ui-theme-dark) {
|
|
16
11
|
--ring-selected-tab-color: var(--ring-text-color);
|
|
17
12
|
}
|
|
18
13
|
|
|
19
14
|
.tabs {
|
|
15
|
+
--ring-tabs-line-shadow: inset 0 -1px 0 0;
|
|
16
|
+
--ring-tabs-selected-line-shadow: inset 0 -2px 0 0;
|
|
17
|
+
|
|
20
18
|
composes: font from "../global/global.css";
|
|
21
19
|
}
|
|
22
20
|
|
|
@@ -31,7 +29,7 @@
|
|
|
31
29
|
}
|
|
32
30
|
|
|
33
31
|
.titles {
|
|
34
|
-
box-shadow: line-shadow var(--ring-line-color);
|
|
32
|
+
box-shadow: var(--ring-tabs-line-shadow) var(--ring-line-color);
|
|
35
33
|
}
|
|
36
34
|
|
|
37
35
|
.title {
|
|
@@ -62,13 +60,13 @@
|
|
|
62
60
|
&.selected,
|
|
63
61
|
&.collapsed {
|
|
64
62
|
color: inherit;
|
|
65
|
-
box-shadow: selected-line-shadow var(--ring-text-color);
|
|
63
|
+
box-shadow: var(--ring-tabs-selected-line-shadow) var(--ring-text-color);
|
|
66
64
|
}
|
|
67
65
|
}
|
|
68
66
|
|
|
69
67
|
&:focus-visible {
|
|
70
68
|
color: var(--ring-main-color);
|
|
71
|
-
box-shadow: selected-line-shadow var(--ring-main-color);
|
|
69
|
+
box-shadow: var(--ring-tabs-selected-line-shadow) var(--ring-main-color);
|
|
72
70
|
}
|
|
73
71
|
|
|
74
72
|
&[disabled] {
|
|
@@ -91,7 +89,7 @@
|
|
|
91
89
|
color: var(--ring-active-text-color);
|
|
92
90
|
|
|
93
91
|
outline: none;
|
|
94
|
-
box-shadow: selected-line-shadow var(--ring-selected-tab-color);
|
|
92
|
+
box-shadow: var(--ring-tabs-selected-line-shadow) var(--ring-selected-tab-color);
|
|
95
93
|
|
|
96
94
|
font-weight: var(--ring-font-weight-bold);
|
|
97
95
|
}
|
package/components/tag/tag.css
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
@import "../global/variables.css";
|
|
2
2
|
|
|
3
|
-
@value max-height: 20px;
|
|
4
|
-
|
|
5
3
|
.tag {
|
|
4
|
+
--ring-tag-max-height: 20px;
|
|
5
|
+
|
|
6
6
|
composes: resetButton from "../global/global.css";
|
|
7
7
|
|
|
8
8
|
position: relative;
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
box-sizing: border-box;
|
|
14
14
|
max-width: 100%;
|
|
15
|
-
height: max-height;
|
|
15
|
+
height: var(--ring-tag-max-height);
|
|
16
16
|
|
|
17
17
|
padding: 0 var(--ring-unit);
|
|
18
18
|
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
.remove {
|
|
82
82
|
position: absolute;
|
|
83
83
|
z-index: 1;
|
|
84
|
-
top:
|
|
84
|
+
top: 2px;
|
|
85
85
|
right: 0;
|
|
86
86
|
|
|
87
87
|
height: auto;
|
|
@@ -110,8 +110,8 @@
|
|
|
110
110
|
overflow: hidden;
|
|
111
111
|
|
|
112
112
|
box-sizing: border-box;
|
|
113
|
-
width: max-height;
|
|
114
|
-
height: max-height;
|
|
113
|
+
width: var(--ring-tag-max-height);
|
|
114
|
+
height: var(--ring-tag-max-height);
|
|
115
115
|
margin-right: calc(var(--ring-unit) / 2);
|
|
116
116
|
margin-left: calc(var(--ring-unit) * -1);
|
|
117
117
|
|
|
@@ -131,7 +131,7 @@
|
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
.avatarIcon {
|
|
134
|
-
width: max-height;
|
|
134
|
+
width: var(--ring-tag-max-height);
|
|
135
135
|
|
|
136
136
|
margin-right: -4px;
|
|
137
137
|
|
package/components/tag/tag.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export interface TagRenderProps extends HTMLAttributes<HTMLElement> {
|
|
|
7
7
|
'data-test': string;
|
|
8
8
|
}
|
|
9
9
|
export interface TagProps {
|
|
10
|
-
onRemove
|
|
10
|
+
onRemove?: ((event: React.MouseEvent<HTMLElement>) => void) | null;
|
|
11
11
|
onClick: (event: React.MouseEvent<HTMLElement>) => void;
|
|
12
12
|
readOnly: boolean;
|
|
13
13
|
disabled: boolean;
|
package/components/tag/tag.js
CHANGED
|
@@ -11,15 +11,14 @@ import styles from './tag.css';
|
|
|
11
11
|
*/
|
|
12
12
|
export default class Tag extends PureComponent {
|
|
13
13
|
static defaultProps = {
|
|
14
|
-
onRemove: () => { },
|
|
15
14
|
onClick: () => { },
|
|
16
15
|
readOnly: false,
|
|
17
16
|
disabled: false,
|
|
18
17
|
focused: false,
|
|
19
|
-
render: props => <button type="button" {...props}
|
|
18
|
+
render: props => <button type="button" {...props}/>,
|
|
20
19
|
};
|
|
21
20
|
state = {
|
|
22
|
-
focused: false
|
|
21
|
+
focused: false,
|
|
23
22
|
};
|
|
24
23
|
componentDidUpdate(prevProps) {
|
|
25
24
|
if (this.props.focused !== prevProps.focused) {
|
|
@@ -53,16 +52,16 @@ export default class Tag extends PureComponent {
|
|
|
53
52
|
}
|
|
54
53
|
renderCustomIcon() {
|
|
55
54
|
if (this.props.rgTagIcon) {
|
|
56
|
-
return
|
|
55
|
+
return <Icon className={styles.icon} title={this.props.rgTagTitle} glyph={this.props.rgTagIcon}/>;
|
|
57
56
|
}
|
|
58
57
|
return null;
|
|
59
58
|
}
|
|
60
59
|
_renderImageElement(avatarSrc) {
|
|
61
60
|
const classes = classNames({
|
|
62
61
|
[styles.customIcon]: this.props.icon,
|
|
63
|
-
[styles.avatarIcon]: avatarSrc
|
|
62
|
+
[styles.avatarIcon]: avatarSrc,
|
|
64
63
|
});
|
|
65
|
-
return
|
|
64
|
+
return <img alt={avatarSrc ? 'Avatar' : 'Icon'} className={classes} src={avatarSrc || this.props.icon}/>;
|
|
66
65
|
}
|
|
67
66
|
renderImage() {
|
|
68
67
|
if (this.props.icon && !this.props.avatar) {
|
|
@@ -72,14 +71,12 @@ export default class Tag extends PureComponent {
|
|
|
72
71
|
}
|
|
73
72
|
renderAvatar() {
|
|
74
73
|
if (this.props.avatar) {
|
|
75
|
-
return
|
|
76
|
-
{this._renderImageElement(this.props.avatar)}
|
|
77
|
-
</span>);
|
|
74
|
+
return <span className={styles.avatarContainer}>{this._renderImageElement(this.props.avatar)}</span>;
|
|
78
75
|
}
|
|
79
76
|
return null;
|
|
80
77
|
}
|
|
81
78
|
renderRemoveIcon() {
|
|
82
|
-
if (!this.props.readOnly) {
|
|
79
|
+
if (!this.props.readOnly && this.props.onRemove) {
|
|
83
80
|
return (<Button title="Remove" icon={closeIcon} data-test="ring-tag-remove" className={styles.remove} iconClassName={styles.removeIcon} onClick={this.props.onRemove} style={{ '--ring-icon-secondary-color': this.props.textColor }} height={ControlsHeight.M}/>);
|
|
84
81
|
}
|
|
85
82
|
return null;
|
|
@@ -88,7 +85,7 @@ export default class Tag extends PureComponent {
|
|
|
88
85
|
const classes = classNames('ring-js-shortcuts', styles.tag, {
|
|
89
86
|
[styles.focused]: this.state.focused,
|
|
90
87
|
[styles.disabled]: this.props.disabled,
|
|
91
|
-
[styles.withRemove]: !this.props.readOnly
|
|
88
|
+
[styles.withRemove]: !this.props.readOnly && this.props.onRemove,
|
|
92
89
|
}, this.props.className);
|
|
93
90
|
const { backgroundColor, textColor, render } = this.props;
|
|
94
91
|
return (<span className={styles.container}>
|
|
@@ -104,7 +101,7 @@ export default class Tag extends PureComponent {
|
|
|
104
101
|
{this.renderCustomIcon()}
|
|
105
102
|
{this.renderImage()}
|
|
106
103
|
<span className={styles.content}>{this.props.children}</span>
|
|
107
|
-
</>)
|
|
104
|
+
</>),
|
|
108
105
|
})}
|
|
109
106
|
{this.renderRemoveIcon()}
|
|
110
107
|
</span>);
|
|
@@ -33,7 +33,7 @@ export default class TagsInput extends PureComponent {
|
|
|
33
33
|
allowAddNewTags: false,
|
|
34
34
|
filter: { fn: () => true },
|
|
35
35
|
placeholder: 'Select an option',
|
|
36
|
-
size: Size.M
|
|
36
|
+
size: Size.M,
|
|
37
37
|
};
|
|
38
38
|
constructor(props) {
|
|
39
39
|
super(props);
|
|
@@ -46,7 +46,7 @@ export default class TagsInput extends PureComponent {
|
|
|
46
46
|
loading: true,
|
|
47
47
|
focused: false,
|
|
48
48
|
query: '',
|
|
49
|
-
activeIndex: 0
|
|
49
|
+
activeIndex: 0,
|
|
50
50
|
};
|
|
51
51
|
static getDerivedStateFromProps({ tags }, { prevTags }) {
|
|
52
52
|
const nextState = { prevTags: tags };
|
|
@@ -99,15 +99,14 @@ export default class TagsInput extends PureComponent {
|
|
|
99
99
|
this.select?.filterValue('');
|
|
100
100
|
if (isUniqueTag) {
|
|
101
101
|
this.setState(prevState => ({
|
|
102
|
-
tags: prevState.tags.concat([tag])
|
|
102
|
+
tags: prevState.tags.concat([tag]),
|
|
103
103
|
}));
|
|
104
104
|
this.props.onAddTag({ tag });
|
|
105
105
|
this.setActiveIndex();
|
|
106
106
|
}
|
|
107
107
|
};
|
|
108
108
|
onRemoveTag(tagToRemove) {
|
|
109
|
-
return Promise.resolve(this.props.onRemoveTag({ tag: tagToRemove })).
|
|
110
|
-
then(() => {
|
|
109
|
+
return Promise.resolve(this.props.onRemoveTag({ tag: tagToRemove })).then(() => {
|
|
111
110
|
const tags = this.state.tags.filter(tag => tag !== tagToRemove);
|
|
112
111
|
if (this.node) {
|
|
113
112
|
this.setState({ tags });
|
|
@@ -129,9 +128,7 @@ export default class TagsInput extends PureComponent {
|
|
|
129
128
|
loadSuggestions = (query = '') => this.setState({ loading: true, query }, async () => {
|
|
130
129
|
try {
|
|
131
130
|
const suggestionsResult = this.props.dataSource({ query });
|
|
132
|
-
const allSuggestions = Array.isArray(suggestionsResult)
|
|
133
|
-
? suggestionsResult
|
|
134
|
-
: await suggestionsResult;
|
|
131
|
+
const allSuggestions = Array.isArray(suggestionsResult) ? suggestionsResult : await suggestionsResult;
|
|
135
132
|
const suggestions = this.filterExistingTags(allSuggestions);
|
|
136
133
|
if (this.node && query === this.state.query) {
|
|
137
134
|
this.setState({ suggestions, loading: false });
|
|
@@ -149,9 +146,7 @@ export default class TagsInput extends PureComponent {
|
|
|
149
146
|
this.setState({ focused: false });
|
|
150
147
|
};
|
|
151
148
|
selectTag = (moveForward) => {
|
|
152
|
-
const activeIndex = typeof this.state.activeIndex === 'number'
|
|
153
|
-
? this.state.activeIndex
|
|
154
|
-
: this.state.tags.length + 1;
|
|
149
|
+
const activeIndex = typeof this.state.activeIndex === 'number' ? this.state.activeIndex : this.state.tags.length + 1;
|
|
155
150
|
let newActiveIndex = activeIndex + (moveForward ? 1 : -1);
|
|
156
151
|
if (newActiveIndex >= this.state.tags.length) {
|
|
157
152
|
newActiveIndex = this.state.tags.length - 1;
|
|
@@ -165,8 +160,7 @@ export default class TagsInput extends PureComponent {
|
|
|
165
160
|
};
|
|
166
161
|
handleKeyDown = (event) => {
|
|
167
162
|
const key = getEventKey(event);
|
|
168
|
-
const isInputFocused = () => event.target instanceof Element &&
|
|
169
|
-
event.target.matches(this.getInputNode()?.tagName ?? '');
|
|
163
|
+
const isInputFocused = () => event.target instanceof Element && event.target.matches(this.getInputNode()?.tagName ?? '');
|
|
170
164
|
if (key === ' ' && this.props.allowAddNewTags) {
|
|
171
165
|
event.stopPropagation();
|
|
172
166
|
const value = this.getInputNode()?.value;
|
|
@@ -205,10 +199,10 @@ export default class TagsInput extends PureComponent {
|
|
|
205
199
|
this.onRemoveTag(this.state.tags[tagsLength - 1]);
|
|
206
200
|
return false;
|
|
207
201
|
}
|
|
208
|
-
if ((key === 'Delete' || key === 'Backspace') &&
|
|
202
|
+
if ((key === 'Delete' || key === 'Backspace') &&
|
|
203
|
+
this.state.activeIndex != null &&
|
|
209
204
|
this.state.tags[this.state.activeIndex]) {
|
|
210
|
-
this.onRemoveTag(this.state.tags[this.state.activeIndex]).
|
|
211
|
-
then(() => this.selectTag(true));
|
|
205
|
+
this.onRemoveTag(this.state.tags[this.state.activeIndex]).then(() => this.selectTag(true));
|
|
212
206
|
return false;
|
|
213
207
|
}
|
|
214
208
|
}
|
|
@@ -227,15 +221,17 @@ export default class TagsInput extends PureComponent {
|
|
|
227
221
|
};
|
|
228
222
|
render() {
|
|
229
223
|
const { focused, tags, activeIndex } = this.state;
|
|
230
|
-
const { disabled, canNotBeEmpty, allowAddNewTags, filter, size, labelType, height = this.context, label } = this.props;
|
|
224
|
+
const { disabled, canNotBeEmpty, allowAddNewTags, filter, size, labelType, height = this.context, label, } = this.props;
|
|
231
225
|
const classes = classNames(styles.tagsInput, [inputStyles[`size${size}`]], [inputStyles[`height${height}`]], {
|
|
232
226
|
[styles.tagsInputDisabled]: disabled,
|
|
233
|
-
[styles.tagsInputFocused]: focused
|
|
227
|
+
[styles.tagsInputFocused]: focused,
|
|
234
228
|
}, this.props.className);
|
|
235
229
|
return (<div
|
|
236
230
|
// it transfers focus to input
|
|
237
231
|
role="presentation" className={classes} onKeyDown={this.handleKeyDown} onClick={this.clickHandler} ref={this.nodeRef}>
|
|
238
|
-
{label && (<ControlLabel htmlFor={this.id} disabled={disabled} type={labelType}>
|
|
232
|
+
{label && (<ControlLabel htmlFor={this.id} disabled={disabled} type={labelType}>
|
|
233
|
+
{label}
|
|
234
|
+
</ControlLabel>)}
|
|
239
235
|
|
|
240
236
|
<TagsList tags={tags} activeIndex={activeIndex} disabled={disabled} canNotBeEmpty={canNotBeEmpty} handleRemove={this.handleRemove} className={styles.tagsList} tagClassName={styles.tag} handleClick={this.handleClick} customTagComponent={this.props.customTagComponent}>
|
|
241
237
|
<Select id={this.id} ref={this.selectRef} size={Select.Size.AUTO} type={Select.Type.INPUT_WITHOUT_CONTROLS} inputPlaceholder={this.props.placeholder} data={this.state.suggestions} className={classNames(styles.tagsSelect)} onSelect={this.addTag} onFocus={this._focusHandler} onBlur={this._blurHandler} renderOptimization={this.props.renderOptimization} add={allowAddNewTags ? { prefix: 'Add new tag' } : undefined} onAdd={allowAddNewTags ? this.handleTagCreation : undefined} filter={filter} maxHeight={this.props.maxPopupHeight} minWidth={this.props.minPopupWidth} top={POPUP_VERTICAL_SHIFT} loading={this.state.loading} onFilter={this.loadSuggestions} onBeforeOpen={this.loadSuggestions} onKeyDown={this.handleKeyDown} disabled={this.props.disabled} loadingMessage={this.props.loadingMessage} notFoundMessage={this.props.notFoundMessage} hint={this.props.hint}/>
|
|
@@ -24,8 +24,8 @@ export default class TagsList<T extends TagType> extends Component<TagsListProps
|
|
|
24
24
|
customTagComponent: null;
|
|
25
25
|
canNotBeEmpty: boolean;
|
|
26
26
|
disabled: boolean;
|
|
27
|
-
handleClick: typeof noop;
|
|
28
|
-
handleRemove: typeof noop;
|
|
27
|
+
handleClick: () => typeof noop;
|
|
28
|
+
handleRemove: () => typeof noop;
|
|
29
29
|
};
|
|
30
30
|
renderTag(tag: T, focusTag: boolean): React.JSX.Element;
|
|
31
31
|
render(): React.JSX.Element;
|
|
@@ -11,15 +11,16 @@ export default class TagsList extends Component {
|
|
|
11
11
|
customTagComponent: null,
|
|
12
12
|
canNotBeEmpty: false,
|
|
13
13
|
disabled: false,
|
|
14
|
-
handleClick: noop,
|
|
15
|
-
handleRemove: noop
|
|
14
|
+
handleClick: () => noop,
|
|
15
|
+
handleRemove: () => noop,
|
|
16
16
|
};
|
|
17
17
|
renderTag(tag, focusTag) {
|
|
18
18
|
const TagComponent = this.props.customTagComponent || Tag;
|
|
19
|
-
const readOnly = this.props.disabled || tag.readOnly ||
|
|
20
|
-
(this.props.canNotBeEmpty && this.props.tags.length === 1);
|
|
19
|
+
const readOnly = this.props.disabled || tag.readOnly || (this.props.canNotBeEmpty && this.props.tags.length === 1);
|
|
21
20
|
const { tagClassName } = this.props;
|
|
22
|
-
return (<TagComponent {...tag} key={tag.key} readOnly={readOnly} disabled={this.props.disabled || tag.disabled} focused={focusTag} onClick={this.props.handleClick(tag)} onRemove={this.props.handleRemove(tag)} className={tagClassName}>
|
|
21
|
+
return (<TagComponent {...tag} key={tag.key} readOnly={readOnly} disabled={this.props.disabled || tag.disabled} focused={focusTag} onClick={this.props.handleClick(tag)} onRemove={this.props.handleRemove(tag)} className={tagClassName}>
|
|
22
|
+
{tag.label}
|
|
23
|
+
</TagComponent>);
|
|
23
24
|
}
|
|
24
25
|
render() {
|
|
25
26
|
const { children, className, customTagComponent, canNotBeEmpty, handleClick, tagClassName, handleRemove, tags, activeIndex, ...props } = this.props;
|
package/components/text/text.js
CHANGED
|
@@ -4,7 +4,7 @@ import styles from './text.css';
|
|
|
4
4
|
const TextSize = {
|
|
5
5
|
S: 's',
|
|
6
6
|
M: 'm',
|
|
7
|
-
L: 'l'
|
|
7
|
+
L: 'l',
|
|
8
8
|
};
|
|
9
9
|
/**
|
|
10
10
|
* @name Text
|
|
@@ -18,8 +18,10 @@ export default class Text extends Component {
|
|
|
18
18
|
[styles.bold]: bold,
|
|
19
19
|
[styles.sizeS]: size === Text.Size.S,
|
|
20
20
|
[styles.sizeM]: size === Text.Size.M,
|
|
21
|
-
[styles.sizeL]: size === Text.Size.L
|
|
21
|
+
[styles.sizeL]: size === Text.Size.L,
|
|
22
22
|
});
|
|
23
|
-
return (<span className={classes} {...restProps}>
|
|
23
|
+
return (<span className={classes} {...restProps}>
|
|
24
|
+
{children}
|
|
25
|
+
</span>);
|
|
24
26
|
}
|
|
25
27
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
@import "../global/variables.css";
|
|
2
2
|
|
|
3
|
-
@value padding: 2px;
|
|
4
|
-
@value duration: 300ms;
|
|
5
|
-
@value timing-function: cubic-bezier(0.23, 1, 0.32, 1);
|
|
6
|
-
|
|
7
3
|
.toggle {
|
|
4
|
+
--ring-toggle-padding: 2px;
|
|
5
|
+
--ring-toggle-duration: 300ms;
|
|
6
|
+
--ring-toggle-timing-function: cubic-bezier(0.23, 1, 0.32, 1);
|
|
7
|
+
|
|
8
8
|
display: inline-flex;
|
|
9
9
|
align-items: baseline;
|
|
10
10
|
|
|
@@ -70,14 +70,16 @@
|
|
|
70
70
|
width: 100%;
|
|
71
71
|
height: 100%;
|
|
72
72
|
|
|
73
|
-
transition: background-color timing-function duration;
|
|
73
|
+
transition: background-color var(--ring-toggle-timing-function) var(--ring-toggle-duration);
|
|
74
74
|
|
|
75
75
|
border: solid 1px var(--ring-toggle-border-color);
|
|
76
76
|
|
|
77
77
|
background-color: var(--ring-toggle-background-color);
|
|
78
78
|
|
|
79
79
|
.input:focus + & {
|
|
80
|
-
box-shadow:
|
|
80
|
+
box-shadow:
|
|
81
|
+
inset 0 0 0 1px var(--ring-border-hover-color),
|
|
82
|
+
0 0 0 1px var(--ring-border-hover-color);
|
|
81
83
|
}
|
|
82
84
|
|
|
83
85
|
&::before {
|
|
@@ -92,9 +94,9 @@
|
|
|
92
94
|
|
|
93
95
|
content: "";
|
|
94
96
|
|
|
95
|
-
transition: transform timing-function duration;
|
|
97
|
+
transition: transform var(--ring-toggle-timing-function) var(--ring-toggle-duration);
|
|
96
98
|
|
|
97
|
-
transform: translateX(padding) translateY(-50%);
|
|
99
|
+
transform: translateX(var(--ring-toggle-padding)) translateY(-50%);
|
|
98
100
|
|
|
99
101
|
border: solid 1px var(--ring-switch-border-color);
|
|
100
102
|
|
|
@@ -132,7 +134,7 @@
|
|
|
132
134
|
|
|
133
135
|
/* stylelint-disable-next-line selector-max-specificity */
|
|
134
136
|
& .input:checked + ::before {
|
|
135
|
-
transform: translateX(calc(var(--ring-unit) * 1.5 - padding)) translateY(-50%);
|
|
137
|
+
transform: translateX(calc(var(--ring-unit) * 1.5 - var(--ring-toggle-padding))) translateY(-50%);
|
|
136
138
|
}
|
|
137
139
|
}
|
|
138
140
|
|
|
@@ -182,7 +184,7 @@
|
|
|
182
184
|
|
|
183
185
|
/* stylelint-disable-next-line selector-max-specificity */
|
|
184
186
|
& .input:checked + ::before {
|
|
185
|
-
transform: translateX(calc(var(--ring-unit) * 2 - padding)) translateY(-50%);
|
|
187
|
+
transform: translateX(calc(var(--ring-unit) * 2 - var(--ring-toggle-padding))) translateY(-50%);
|
|
186
188
|
}
|
|
187
189
|
}
|
|
188
190
|
|
|
@@ -6,17 +6,18 @@ import styles from './toggle.css';
|
|
|
6
6
|
export const Size = {
|
|
7
7
|
Size14: styles.size14,
|
|
8
8
|
Size16: styles.size16,
|
|
9
|
-
Size20: styles.size20
|
|
9
|
+
Size20: styles.size20,
|
|
10
10
|
};
|
|
11
11
|
class Toggle extends PureComponent {
|
|
12
12
|
static defaultProps = {
|
|
13
|
-
size: Size.Size16
|
|
13
|
+
size: Size.Size16,
|
|
14
14
|
};
|
|
15
15
|
render() {
|
|
16
16
|
const { className, children, disabled, title, leftLabel, size = Size.Size16, 'data-test': dataTest, help, onTransitionEnd, ...restProps } = this.props;
|
|
17
17
|
const classes = classNames(className, size, styles.toggle, disabled && styles.disabled);
|
|
18
18
|
return (<label className={classes} title={title} data-test={dataTests('ring-toggle', dataTest)}>
|
|
19
|
-
{leftLabel && (<span className={styles.leftLabel}>
|
|
19
|
+
{leftLabel && (<span className={styles.leftLabel}>
|
|
20
|
+
{leftLabel}
|
|
20
21
|
{help && <ControlHelp className={styles.help}>{help}</ControlHelp>}
|
|
21
22
|
</span>)}
|
|
22
23
|
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { AllHTMLAttributes, Component, ReactNode } from 'react';
|
|
2
1
|
import * as React from 'react';
|
|
2
|
+
import { AllHTMLAttributes, Component, ReactNode } from 'react';
|
|
3
3
|
import Popup, { PopupAttrs } from '../popup/popup';
|
|
4
4
|
import { Listeners } from '../global/dom';
|
|
5
|
+
import Theme from '../global/theme';
|
|
5
6
|
interface Context {
|
|
6
7
|
onNestedTooltipShow: () => void;
|
|
7
8
|
onNestedTooltipHide: () => void;
|
|
@@ -12,6 +13,7 @@ export interface TooltipProps extends Omit<AllHTMLAttributes<HTMLSpanElement>, '
|
|
|
12
13
|
selfOverflowOnly?: boolean | null | undefined;
|
|
13
14
|
popupProps?: Partial<PopupAttrs> | null | undefined;
|
|
14
15
|
title?: ReactNode | null | undefined;
|
|
16
|
+
theme?: Theme;
|
|
15
17
|
'data-test'?: string | null | undefined;
|
|
16
18
|
long?: boolean | null | undefined;
|
|
17
19
|
}
|
|
@@ -22,6 +24,7 @@ export default class Tooltip extends Component<TooltipProps> {
|
|
|
22
24
|
static defaultProps: {
|
|
23
25
|
title: string;
|
|
24
26
|
selfOverflowOnly: boolean;
|
|
27
|
+
theme: Theme;
|
|
25
28
|
popupProps: {};
|
|
26
29
|
};
|
|
27
30
|
state: {
|