@jetbrains/ring-ui 7.0.31 → 7.0.32

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.
@@ -4,5 +4,6 @@ interface InfoAvatarProps {
4
4
  size: Size;
5
5
  children?: ReactNode;
6
6
  }
7
+ export declare const fontSizes: Record<Size, number>;
7
8
  export default function AvatarInfo({ size, children }: InfoAvatarProps): import("react/jsx-runtime").JSX.Element;
8
9
  export {};
@@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import classNames from 'classnames';
3
3
  import styles from './avatar.css';
4
4
  import { Size } from './avatar-size';
5
- const fontSizes = {
5
+ export const fontSizes = {
6
6
  [Size.Size16]: 9,
7
7
  [Size.Size18]: 9,
8
8
  [Size.Size20]: 9,
@@ -26,7 +26,7 @@
26
26
  color: var(--ring-secondary-color);
27
27
  border-radius: inherit;
28
28
 
29
- background-color: var(--ring-disabled-background-color);
29
+ background-color: var(--ring-tag-background-color);
30
30
  }
31
31
 
32
32
  .subavatar {
@@ -1,24 +1,45 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import figma from '@figma/code-connect';
3
- import Avatar, { Size } from './avatar';
4
- figma.connect(Avatar, 'https://www.figma.com/design/HY6d4uE1xxaQXCMG9fe6Y2/RingUI?m=auto&node-id=5990-522&t=v8bItK8qotmnbysK-1', {
5
- props: {
6
- round: figma.boolean('Round'),
7
- size: figma.enum('Size', {
8
- '20 px': Size.Size20,
9
- '24 px': Size.Size24,
10
- '28 px': Size.Size28,
11
- '32 px': Size.Size32,
12
- '40px': Size.Size40,
13
- '56px': Size.Size56,
14
- }),
15
- username: figma.enum('Content', {
16
- name: 'Samuel Morse',
17
- }),
18
- url: figma.enum('Content', {
19
- 'color/image': 'avatar.png',
20
- }),
21
- },
22
- example: props => _jsx(Avatar, { ...props }),
23
- imports: ['import Avatar, {Size} from "@jetbrains/ring-ui/components/avatar/avatar"'],
24
- });
1
+ // url=https://www.figma.com/design/HY6d4uE1xxaQXCMG9fe6Y2/RingUI?node-id=5990-522
2
+ const figma = require('figma');
3
+
4
+ const instance = figma.selectedInstance;
5
+
6
+ const round = instance.getBoolean('Round');
7
+ const size = parseInt(instance.getString('Size'), 10);
8
+ const content = instance.getString('Content');
9
+
10
+ const props = [];
11
+ const DEFAULT_SIZE = 20;
12
+ const isDefaultSize = size === DEFAULT_SIZE;
13
+ const imports = [`import Avatar${isDefaultSize ? '' : ', {Size}'} from '@jetbrains/ring-ui/components/avatar/avatar'`];
14
+ if (!isDefaultSize) {
15
+ props.push(`size={Size.Size${size}}`);
16
+ }
17
+ switch (content) {
18
+ case 'color/image':
19
+ props.push('url="avatar.png"');
20
+ break;
21
+ case 'name':
22
+ props.push('username="Samuel Morse"');
23
+ break;
24
+ case 'label':
25
+ props.push('info="5"');
26
+ break;
27
+ case 'icon':
28
+ imports.push(
29
+ "import Icon from '@jetbrains/ring-ui/components/icon/icon'",
30
+ "import warningIcon from '@jetbrains/icons/warning.svg'",
31
+ );
32
+ props.push('info={<Icon glyph={warningIcon} />}');
33
+ break;
34
+ default:
35
+ }
36
+ if (round) {
37
+ props.push('round');
38
+ }
39
+
40
+ export default {
41
+ id: 'avatar',
42
+ example: figma.code`${imports.join('\n')}
43
+
44
+ <Avatar ${props.map(prop => `${prop} `).join('')}/>`,
45
+ };
@@ -1,37 +1,31 @@
1
1
  .size20 {
2
2
  --ring-avatar-stack-offset: 12px;
3
3
  --ring-avatar-stack-mask-image: url('avatar-stack.mask-20.svg');
4
- --ring-avatar-stack-extra-font-size: 9px
5
4
  }
6
5
 
7
6
  .size24 {
8
7
  --ring-avatar-stack-offset: 16px;
9
8
  --ring-avatar-stack-mask-image: url('avatar-stack.mask-24.svg');
10
- --ring-avatar-stack-extra-font-size: 11px;
11
9
  }
12
10
 
13
11
  .size28 {
14
12
  --ring-avatar-stack-offset: 18px;
15
13
  --ring-avatar-stack-mask-image: url('avatar-stack.mask-28.svg');
16
- --ring-avatar-stack-extra-font-size: var(--ring-font-size-smaller);
17
14
  }
18
15
 
19
16
  .size32 {
20
17
  --ring-avatar-stack-offset: 20px;
21
18
  --ring-avatar-stack-mask-image: url('avatar-stack.mask-32.svg');
22
- --ring-avatar-stack-extra-font-size: var(--ring-font-size);
23
19
  }
24
20
 
25
21
  .size40 {
26
22
  --ring-avatar-stack-offset: 26px;
27
23
  --ring-avatar-stack-mask-image: url('avatar-stack.mask-40.svg');
28
- --ring-avatar-stack-extra-font-size: var(--ring-font-size-larger);
29
24
  }
30
25
 
31
26
  .size56 {
32
27
  --ring-avatar-stack-offset: 42px;
33
28
  --ring-avatar-stack-mask-image: url('avatar-stack.mask-56.svg');
34
- --ring-avatar-stack-extra-font-size: 22px;
35
29
  }
36
30
 
37
31
  .avatarStack {
@@ -80,38 +74,27 @@
80
74
 
81
75
  .extra {
82
76
  composes: item;
83
-
84
- color: var(--ring-secondary-color);
85
-
86
- border-radius: var(--ring-border-radius);
87
-
88
- background-color: var(--ring-disabled-background-color);
89
-
90
- font-size: var(--ring-avatar-stack-extra-font-size);
91
77
  }
92
78
 
93
- .extraText {
79
+ .extraButton {
94
80
  composes: resetButton from "../global/global.css";
95
81
 
96
- display: block;
97
-
98
- width: 100%;
99
- height: 100%;
100
-
101
82
  cursor: pointer;
102
- transition: opacity var(--ring-fast-ease);
103
- text-align: center;
104
-
105
- opacity: 0;
106
83
 
107
84
  border-radius: var(--ring-border-radius);
108
85
  }
109
86
 
110
- .extraText:focus-visible {
87
+ .extraButton:focus-visible {
111
88
  outline: none;
112
89
  box-shadow: 0 0 0 2px var(--ring-border-hover-color);
113
90
  }
114
91
 
92
+ .extraText {
93
+ transition: opacity var(--ring-fast-ease);
94
+
95
+ opacity: 0;
96
+ }
97
+
115
98
  .hovered .extraText,
116
99
  .avatarStack:hover .extraText,
117
100
  .avatarStack:focus-within .extraText {
@@ -2,11 +2,17 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Children, useState } from 'react';
3
3
  import classNames from 'classnames';
4
4
  import DropdownMenu from '../dropdown-menu/dropdown-menu';
5
- import { Size } from '../avatar/avatar';
5
+ import Avatar, { Size } from '../avatar/avatar';
6
+ import { fontSizes } from '../avatar/avatar-info';
6
7
  import styles from './avatar-stack.css';
7
8
  export default function AvatarStack({ children, className, size = Size.Size20, extraItems, dropdownMenuProps, ...restProps }) {
8
9
  const [dropdownOpen, setDropdownOpen] = useState(false);
9
10
  return (_jsxs("div", { className: classNames(styles.avatarStack, className, styles[`size${size}`], {
10
11
  [styles.hovered]: dropdownOpen,
11
- }), ...restProps, children: [Children.map(children, (child, index) => (_jsx("div", { className: styles.item, style: { '--ring-avatar-stack-index': index }, children: child }))), extraItems?.length ? (_jsx(DropdownMenu, { hoverMode: true, hoverShowTimeOut: 10, onShow: () => setDropdownOpen(true), onHide: () => setDropdownOpen(false), className: styles.extra, style: { width: size, height: size, '--ring-avatar-stack-index': Children.count(children) }, anchor: _jsx("button", { type: "button", className: styles.extraText, children: `+${extraItems.length}` }), data: extraItems, menuProps: { offset: 4, ...dropdownMenuProps?.menuProps }, ...dropdownMenuProps })) : null] }));
12
+ }), ...restProps, children: [Children.map(children, (child, index) => (_jsx("div", { className: styles.item, style: { '--ring-avatar-stack-index': index }, children: child }))), extraItems?.length ? (_jsx(DropdownMenu, { hoverMode: true, hoverShowTimeOut: 10, onShow: () => setDropdownOpen(true), onHide: () => setDropdownOpen(false), className: styles.extra, style: {
13
+ width: size,
14
+ height: size,
15
+ '--ring-avatar-stack-index': Children.count(children),
16
+ fontSize: fontSizes[size],
17
+ }, anchor: _jsx("button", { type: "button", className: styles.extraButton, children: _jsx(Avatar, { size: size, info: _jsx("span", { className: styles.extraText, children: `+${extraItems.length}` }) }) }), data: extraItems, menuProps: { offset: 4, ...dropdownMenuProps?.menuProps }, ...dropdownMenuProps })) : null] }));
12
18
  }
@@ -1,70 +1,95 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import figma from '@figma/code-connect';
3
- import addIcon from '@jetbrains/icons/add';
4
- import add12pxIcon from '@jetbrains/icons/add-12px';
5
- import downloadIcon from '@jetbrains/icons/download';
6
- import download12pxIcon from '@jetbrains/icons/download-12px';
7
- import { ControlsHeight } from '../global/controls-height';
8
- import Button from './button';
9
- figma.connect(Button, 'https://www.figma.com/design/HY6d4uE1xxaQXCMG9fe6Y2/RingUI?node-id=9954%3A528', {
10
- props: {
11
- height: figma.enum('Size', {
12
- S: ControlsHeight.S,
13
- M: ControlsHeight.M,
14
- L: ControlsHeight.L,
15
- }),
16
- children: figma.enum('Type', {
17
- Label: 'Button',
18
- 'L-Icon-Label': 'Button',
19
- 'R-Icon-Label': 'Button',
20
- }),
21
- icon: figma.enum('Type', {
22
- 'L-Icon-Label': figma.enum('Size', {
23
- S: figma.enum('Variant', {
24
- Main: download12pxIcon,
25
- Green: download12pxIcon,
26
- 'Red solid': download12pxIcon,
27
- Gray: download12pxIcon,
28
- Outlined: download12pxIcon,
29
- 'Red outlined': download12pxIcon,
30
- Ghost: download12pxIcon,
31
- Text: downloadIcon,
32
- }),
33
- M: downloadIcon,
34
- L: downloadIcon,
35
- }),
36
- Icon: figma.enum('Size', {
37
- S: figma.enum('Variant', {
38
- Main: add12pxIcon,
39
- Green: add12pxIcon,
40
- 'Red solid': add12pxIcon,
41
- Gray: add12pxIcon,
42
- Outlined: add12pxIcon,
43
- 'Red outlined': add12pxIcon,
44
- Ghost: add12pxIcon,
45
- Text: addIcon,
46
- }),
47
- M: addIcon,
48
- L: addIcon,
49
- }),
50
- }),
51
- dropdown: figma.enum('Type', { 'R-Icon-Label': true }),
52
- disabled: figma.enum('State', { Disabled: true }),
53
- primary: figma.enum('Variant', { Main: true }),
54
- success: figma.enum('Variant', { Green: true }),
55
- error: figma.enum('Variant', { 'Red solid': true }),
56
- secondary: figma.enum('Variant', { Gray: true }),
57
- danger: figma.enum('Variant', { 'Red outlined': true }),
58
- ghost: figma.enum('Variant', { Ghost: true }),
59
- inline: figma.enum('Variant', { Text: true }),
60
- },
61
- example: ({ children, ...restProps }) => _jsx(Button, { ...restProps, children: children }),
62
- imports: [
63
- 'import Button from "@jetbrains/ring-ui/components/button/button"',
64
- 'import {ControlsHeight} from "@jetbrains/ring-ui/components/global/controls-height"',
65
- 'import addIcon from "@jetbrains/icons/add"',
66
- 'import add12pxIcon from "@jetbrains/icons/add-12px"',
67
- 'import downloadIcon from "@jetbrains/icons/download"',
68
- 'import download12pxIcon from "@jetbrains/icons/download-12px"',
69
- ],
70
- });
1
+ const figma = require('figma');
2
+
3
+ const instance = figma.selectedInstance;
4
+
5
+ const size = instance.getString('Size');
6
+ const type = instance.getString('Type');
7
+ const state = instance.getString('State');
8
+ const variant = instance.getString('Variant');
9
+
10
+ const imports = ["import Button from '@jetbrains/ring-ui/components/button/button'"];
11
+ const props = [];
12
+ const DEFAULT_SIZE = 'M';
13
+ const isDefaultSize = size === DEFAULT_SIZE;
14
+
15
+ if (!isDefaultSize) {
16
+ imports.push("import {ControlsHeight} from '@jetbrains/ring-ui/components/global/controls-height'");
17
+ props.push(`height={ControlsHeight.${size}}`);
18
+ }
19
+
20
+ switch (variant) {
21
+ case 'Red outlined':
22
+ props.push('danger');
23
+ break;
24
+ case 'Main':
25
+ props.push('primary');
26
+ break;
27
+ case 'Green':
28
+ props.push('success');
29
+ break;
30
+ case 'Red solid':
31
+ props.push('error');
32
+ break;
33
+ case 'Gray':
34
+ props.push('secondary');
35
+ break;
36
+ case 'Ghost':
37
+ props.push('ghost');
38
+ break;
39
+ case 'Text':
40
+ props.push('inline');
41
+ break;
42
+ default:
43
+ }
44
+
45
+ let children = 'Button';
46
+ const use12pxIcon = size === 'S' && variant !== 'Text';
47
+ let useButtonGroup = false;
48
+ switch (type) {
49
+ case 'R-Icon-Label':
50
+ props.push('dropdown');
51
+ break;
52
+ case 'L-Icon-Label':
53
+ imports.push(`import downloadIcon from '@jetbrains/icons/download${use12pxIcon ? '-12px' : ''}'`);
54
+ props.push('icon={downloadIcon}');
55
+ break;
56
+ case 'Icon':
57
+ children = null;
58
+ imports.push(`import addIcon from '@jetbrains/icons/add${use12pxIcon ? '-12px' : ''}'`);
59
+ props.push('icon={addIcon}');
60
+ break;
61
+ case 'Split':
62
+ imports.push("import ButtonGroup from '@jetbrains/ring-ui/components/button-group/button-group'");
63
+ imports.push(`import chevronDownIcon from '@jetbrains/icons/chevron-down${use12pxIcon ? '-12px' : ''}'`);
64
+ useButtonGroup = true;
65
+ break;
66
+ default:
67
+ }
68
+
69
+ switch (state) {
70
+ case 'Disabled':
71
+ props.push('disabled');
72
+ break;
73
+ default:
74
+ }
75
+
76
+ const joinedProps = props.map(prop => `${prop} `).join('');
77
+ // prettier-ignore
78
+ const button = children ?
79
+ `<Button ${joinedProps}>
80
+ ${children}
81
+ </Button>` : `<Button ${joinedProps}/>`;
82
+
83
+ export default {
84
+ id: 'button',
85
+ example: figma.code`${imports.join('\n')}
86
+
87
+ ${
88
+ // prettier-ignore
89
+ useButtonGroup ?
90
+ `<ButtonGroup>
91
+ ${button}
92
+ <Button ${joinedProps} icon={chevronDownIcon} />
93
+ </ButtonGroup>` : button
94
+ }`,
95
+ };
@@ -50,6 +50,7 @@ export interface TableProps<T extends SelectionItem> extends FocusSensorAddProps
50
50
  stickyHeaderOffset?: string | undefined;
51
51
  renderEmpty?: (() => ReactNode) | null | undefined;
52
52
  RowComponent: typeof Row;
53
+ customLoader?: ((loaderClassName?: string) => ReactNode) | null | undefined;
53
54
  }
54
55
  /**
55
56
  * Interactive table with selection and keyboard navigation support.
@@ -109,7 +109,7 @@ export class Table extends PureComponent {
109
109
  window.scrollTo(scrollX, scrollY);
110
110
  };
111
111
  render() {
112
- const { data, selection, columns, caption, getItemKey, selectable, focused, isItemSelectable, getItemLevel, getItemClassName, getMetaColumnClassName, getItemDataTest, draggable, alwaysShowDragHandle, dragHandleTitle, loading, onSort, sortKey, sortOrder, loaderClassName, stickyHeader, stickyHeaderOffset, isItemCollapsible, isParentCollapsible, isItemCollapsed, onItemCollapse, onItemExpand, isDisabledSelectionVisible, getCheckboxTooltip, onItemDoubleClick, onItemClick, renderEmpty, RowComponent, } = this.props;
112
+ const { data, selection, columns, caption, getItemKey, selectable, focused, isItemSelectable, getItemLevel, getItemClassName, getMetaColumnClassName, getItemDataTest, draggable, alwaysShowDragHandle, dragHandleTitle, loading, onSort, sortKey, sortOrder, loaderClassName, stickyHeader, stickyHeaderOffset, isItemCollapsible, isParentCollapsible, isItemCollapsed, onItemCollapse, onItemExpand, isDisabledSelectionVisible, getCheckboxTooltip, onItemDoubleClick, onItemClick, renderEmpty, RowComponent, customLoader, } = this.props;
113
113
  // NOTE: Do not construct new object per render because it causes all rows rerendering
114
114
  const columnsArray = typeof columns === 'function' ? columns(null) : columns;
115
115
  const headerProps = {
@@ -152,7 +152,7 @@ export class Table extends PureComponent {
152
152
  const row = (_createElement(RowComponent, { innerRef: ref, level: getItemLevel(value), item: value, showFocus: selection.isFocused(value), autofocus: selection.isFocused(value), focused: focused && selection.isFocused(value), selectable: selectable && isItemSelectable(value), selected: selectable && selection.isSelected(value), onFocus: this.onRowFocus, onSelect: this.onRowSelect, onDoubleClick: onItemDoubleClick, onClick: onItemClick, collapsible: isItemCollapsible(value), parentCollapsible: isParentCollapsible(value), collapsed: isItemCollapsed(value), onCollapse: onItemCollapse, onExpand: onItemExpand, showDisabledSelection: isDisabledSelectionVisible(value), checkboxTooltip: getCheckboxTooltip(value), className: classNames(getItemClassName(value), { [style.draggingRow]: isDragged }), metaColumnClassName: getMetaColumnClassName(value), draggable: draggable, alwaysShowDragHandle: alwaysShowDragHandle, dragHandleTitle: dragHandleTitle, columns: columns, "data-test": getItemDataTest(value), ...restProps, key: restProps.key ?? getItemKey(value) }));
153
153
  return isDragged ? (_jsx("table", { style: { ...props.style }, className: style.draggingTable, children: _jsx("tbody", { children: row }) })) : (row);
154
154
  };
155
- return (_jsxs("div", { className: wrapperClasses, "data-test": "ring-table-wrapper", ref: this.props.innerRef, children: [focused && _jsx(Shortcuts, { map: this.props.shortcutsMap, scope: this.state.shortcutsScope }), _jsx("div", { role: "presentation", onMouseDown: this.onMouseDown, children: draggable ? (_jsx(List, { values: data, renderList: renderList, renderItem: renderItem, onChange: this.onSortEnd })) : (renderList({ children: data.map((value, index) => renderItem({ value, index })) })) }), loading && (_jsx("div", { className: style.loadingOverlay, children: _jsx(Loader, { className: loaderClassName }) }))] }));
155
+ return (_jsxs("div", { className: wrapperClasses, "data-test": "ring-table-wrapper", ref: this.props.innerRef, children: [focused && _jsx(Shortcuts, { map: this.props.shortcutsMap, scope: this.state.shortcutsScope }), _jsx("div", { role: "presentation", onMouseDown: this.onMouseDown, children: draggable ? (_jsx(List, { values: data, renderList: renderList, renderItem: renderItem, onChange: this.onSortEnd })) : (renderList({ children: data.map((value, index) => renderItem({ value, index })) })) }), loading && (_jsx("div", { className: style.loadingOverlay, children: customLoader ? customLoader(loaderClassName) : _jsx(Loader, { className: loaderClassName }) }))] }));
156
156
  }
157
157
  }
158
158
  const getContainer = () => disableHoverHOC(selectionShortcutsHOC(focusSensorHOC(Table)));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetbrains/ring-ui",
3
- "version": "7.0.31",
3
+ "version": "7.0.32",
4
4
  "description": "JetBrains UI library",
5
5
  "author": {
6
6
  "name": "JetBrains"
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,30 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import figma from '@figma/code-connect';
3
- import chevronDownIcon from '@jetbrains/icons/chevron-down';
4
- import Button from '../button/button';
5
- import { ControlsHeight } from '../global/controls-height';
6
- import ButtonGroup from './button-group';
7
- figma.connect(ButtonGroup, 'https://www.figma.com/design/HY6d4uE1xxaQXCMG9fe6Y2/RingUI?node-id=9954%3A528', {
8
- props: {
9
- height: figma.enum('Size', {
10
- S: ControlsHeight.S,
11
- M: ControlsHeight.M,
12
- L: ControlsHeight.L,
13
- }),
14
- disabled: figma.enum('State', { Disabled: true }),
15
- primary: figma.enum('Variant', { Main: true }),
16
- success: figma.enum('Variant', { Green: true }),
17
- error: figma.enum('Variant', { 'Red solid': true }),
18
- secondary: figma.enum('Variant', { Gray: true }),
19
- danger: figma.enum('Variant', { 'Red outlined': true }),
20
- ghost: figma.enum('Variant', { Ghost: true }),
21
- inline: figma.enum('Variant', { Text: true }),
22
- },
23
- variant: { Type: 'Split' },
24
- example: props => (_jsxs(ButtonGroup, { children: [_jsx(Button, { ...props, children: 'Button' }), _jsx(Button, { ...props, icon: chevronDownIcon })] })),
25
- imports: [
26
- 'import Button from "@jetbrains/ring-ui/components/button/button"',
27
- 'import {ControlsHeight} from "@jetbrains/ring-ui/components/global/controls-height"',
28
- 'import chevronDownIcon from "@jetbrains/icons/chevron-down"',
29
- ],
30
- });