@teamturing/react-kit 2.14.1 → 2.15.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.
@@ -0,0 +1,68 @@
1
+ import { forwardRef } from 'react';
2
+ import styled from 'styled-components';
3
+ import '../../node_modules/styled-system/dist/index.esm.js';
4
+ import { forcePixelValue } from '../../utils/forcePixelValue.js';
5
+ import { sx } from '../../utils/styled-system/index.js';
6
+ import Image from '../Image/index.js';
7
+ import { j as jsxRuntimeExports } from '../../node_modules/react/jsx-runtime.js';
8
+ import { variant } from '../../node_modules/@styled-system/variant/dist/index.esm.js';
9
+
10
+ const Avatar = ({
11
+ src,
12
+ alt = '',
13
+ size = 'm',
14
+ sx
15
+ }, ref) => /*#__PURE__*/jsxRuntimeExports.jsx(BaseAvatar, {
16
+ ref: ref,
17
+ src: src,
18
+ alt: alt,
19
+ sx: sx,
20
+ size: size
21
+ });
22
+ const BaseAvatar = styled(Image)`
23
+ border-radius: ${({
24
+ theme
25
+ }) => forcePixelValue(theme.radii.full)};
26
+
27
+ ${variant({
28
+ prop: 'size',
29
+ variants: {
30
+ xxs: {
31
+ width: 16,
32
+ height: 16
33
+ },
34
+ xs: {
35
+ width: 20,
36
+ height: 20
37
+ },
38
+ s: {
39
+ width: 24,
40
+ height: 24
41
+ },
42
+ m: {
43
+ width: 28,
44
+ height: 28
45
+ },
46
+ l: {
47
+ width: 32,
48
+ height: 32
49
+ },
50
+ xl: {
51
+ width: 40,
52
+ height: 40
53
+ },
54
+ xxl: {
55
+ width: 48,
56
+ height: 48
57
+ },
58
+ xxxl: {
59
+ width: 64,
60
+ height: 64
61
+ }
62
+ }
63
+ })}
64
+ ${sx}
65
+ `;
66
+ var index = /*#__PURE__*/forwardRef(Avatar);
67
+
68
+ export { index as default };
@@ -0,0 +1,168 @@
1
+ import { forwardRef, useLayoutEffect } from 'react';
2
+ import styled, { css } from 'styled-components';
3
+ import useProvidedOrCreatedRef from '../../hook/useProvidedOrCreatedRef.js';
4
+ import { forcePixelValue } from '../../utils/forcePixelValue.js';
5
+ import { sx } from '../../utils/styled-system/index.js';
6
+ import { j as jsxRuntimeExports } from '../../node_modules/react/jsx-runtime.js';
7
+
8
+ const Checkbox = ({
9
+ checked,
10
+ validationStatus,
11
+ indeterminate = false,
12
+ ...props
13
+ }, ref) => {
14
+ const checkboxRef = useProvidedOrCreatedRef(ref);
15
+ useLayoutEffect(() => {
16
+ if (checkboxRef.current) {
17
+ checkboxRef.current.indeterminate = indeterminate || false;
18
+ }
19
+ }, [indeterminate, checked, checkboxRef]);
20
+ return /*#__PURE__*/jsxRuntimeExports.jsx(BaseCheckbox, {
21
+ ref: checkboxRef,
22
+ checked: checked,
23
+ validationStatus: validationStatus,
24
+ ...props
25
+ });
26
+ };
27
+ const UnstyledCheckbox = styled.input.attrs({
28
+ type: 'checkbox'
29
+ })`
30
+ appearance: none;
31
+
32
+ ${sx}
33
+ `;
34
+ const BaseCheckbox = styled(UnstyledCheckbox)`
35
+ position: relative;
36
+
37
+ width: ${forcePixelValue(20)};
38
+ height: ${forcePixelValue(20)};
39
+
40
+ border-width: ${forcePixelValue(2)};
41
+ border-style: solid;
42
+ border-color: ${({
43
+ theme
44
+ }) => theme.colors['border/neutral']};
45
+ border-radius: ${({
46
+ theme
47
+ }) => `${forcePixelValue(theme.radii.xxs)}`};
48
+ cursor: pointer;
49
+
50
+ transition: visibility 200ms;
51
+
52
+ &::before {
53
+ visibility: hidden;
54
+
55
+ content: '';
56
+ display: grid;
57
+ position: absolute;
58
+
59
+ top: 0;
60
+ right: 0;
61
+ bottom: 0;
62
+ left: 0;
63
+
64
+ border-radius: ${({
65
+ theme
66
+ }) => `${forcePixelValue(theme.radii.xxs)}`};
67
+
68
+ background-color: ${({
69
+ theme
70
+ }) => theme.colors['icon/inverse']};
71
+ mask-image: url("data:image/svg+xml,%3Csvg width='24' height='24' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M10.6 17.2C10.3 17.2 10 17.1 9.80001 16.8L5.20001 12.2C4.70001 11.7 4.70001 11 5.20001 10.5C5.70001 9.99998 6.40001 9.99998 6.90001 10.5L10.6 14.2L17.2 7.59998C17.7 7.09998 18.4 7.09998 18.9 7.59998C19.4 8.09998 19.4 8.79998 18.9 9.29998L11.5 16.7C11.2 17.1 10.9 17.2 10.6 17.2Z' fill='%238D94A0'/%3E%3C/svg%3E%0A");
72
+ -webkit-mask-image: url("data:image/svg+xml,%3Csvg width='24' height='24' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M10.6 17.2C10.3 17.2 10 17.1 9.80001 16.8L5.20001 12.2C4.70001 11.7 4.70001 11 5.20001 10.5C5.70001 9.99998 6.40001 9.99998 6.90001 10.5L10.6 14.2L17.2 7.59998C17.7 7.09998 18.4 7.09998 18.9 7.59998C19.4 8.09998 19.4 8.79998 18.9 9.29998L11.5 16.7C11.2 17.1 10.9 17.2 10.6 17.2Z' fill='%238D94A0'/%3E%3C/svg%3E%0A");
73
+ mask-size: 100%;
74
+ -webkit-mask-size: 100%;
75
+ mask-repeat: no-repeat;
76
+ -webkit-mask-repeat: no-repeat;
77
+ mask-position: center;
78
+ -webkit-mask-position: center;
79
+ }
80
+
81
+ &:disabled {
82
+ background-color: ${({
83
+ theme
84
+ }) => theme.colors['bg/disabled']};
85
+ border-color: ${({
86
+ theme
87
+ }) => theme.colors['border/disabled']};
88
+ }
89
+
90
+ &:checked {
91
+ background-color: ${({
92
+ theme
93
+ }) => theme.colors['bg/primary']};
94
+ border-width: 0;
95
+
96
+ &::before {
97
+ visibility: visible;
98
+ }
99
+
100
+ &:disabled {
101
+ background-color: ${({
102
+ theme
103
+ }) => theme.colors['bg/disabled']};
104
+ border-color: ${({
105
+ theme
106
+ }) => theme.colors['border/disabled']};
107
+
108
+ &::before {
109
+ background-color: ${({
110
+ theme
111
+ }) => theme.colors['icon/disabled']};
112
+ }
113
+ }
114
+ }
115
+
116
+ &:indeterminate {
117
+ background-color: ${({
118
+ theme
119
+ }) => theme.colors['bg/primary']};
120
+ border-width: 0;
121
+
122
+ &::before {
123
+ visibility: visible;
124
+ mask-image: url("data:image/svg+xml,%3Csvg width='24' height='24' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M20.05 13.2H4.05001C3.73175 13.2 3.42652 13.0736 3.20148 12.8485C2.97643 12.6235 2.85001 12.3182 2.85001 12C2.85001 11.6817 2.97643 11.3765 3.20148 11.1515C3.42652 10.9264 3.73175 10.8 4.05001 10.8H20.05C20.3683 10.8 20.6735 10.9264 20.8985 11.1515C21.1236 11.3765 21.25 11.6817 21.25 12C21.25 12.3182 21.1236 12.6235 20.8985 12.8485C20.6735 13.0736 20.3683 13.2 20.05 13.2Z' fill='%238D94A0'/%3E%3C/svg%3E%0A");
125
+ -webkit-mask-image: url("data:image/svg+xml,%3Csvg width='24' height='24' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M20.05 13.2H4.05001C3.73175 13.2 3.42652 13.0736 3.20148 12.8485C2.97643 12.6235 2.85001 12.3182 2.85001 12C2.85001 11.6817 2.97643 11.3765 3.20148 11.1515C3.42652 10.9264 3.73175 10.8 4.05001 10.8H20.05C20.3683 10.8 20.6735 10.9264 20.8985 11.1515C21.1236 11.3765 21.25 11.6817 21.25 12C21.25 12.3182 21.1236 12.6235 20.8985 12.8485C20.6735 13.0736 20.3683 13.2 20.05 13.2Z' fill='%238D94A0'/%3E%3C/svg%3E%0A");
126
+ mask-size: 100%;
127
+ -webkit-mask-size: 100%;
128
+ mask-repeat: no-repeat;
129
+ -webkit-mask-repeat: no-repeat;
130
+ mask-position: center;
131
+ -webkit-mask-position: center;
132
+ }
133
+
134
+ &:disabled {
135
+ background-color: ${({
136
+ theme
137
+ }) => theme.colors['bg/disabled']};
138
+ border-color: ${({
139
+ theme
140
+ }) => theme.colors['border/disabled']};
141
+
142
+ &::before {
143
+ background-color: ${({
144
+ theme
145
+ }) => theme.colors['icon/disabled']};
146
+ }
147
+ }
148
+ }
149
+
150
+ &:focus-visible {
151
+ outline-width: ${forcePixelValue(2)};
152
+ outline-style: solid;
153
+ outline-color: ${({
154
+ theme
155
+ }) => theme.colors['border/focused']};
156
+ }
157
+
158
+ ${props => props.validationStatus === 'error' && css`
159
+ border-color: ${({
160
+ theme
161
+ }) => theme.colors['border/danger']};
162
+ `}
163
+
164
+ ${sx}
165
+ `;
166
+ var index = /*#__PURE__*/forwardRef(Checkbox);
167
+
168
+ export { index as default };
@@ -0,0 +1,16 @@
1
+ import styled from 'styled-components';
2
+ import { sx } from '../../utils/styled-system/index.js';
3
+ import { j as jsxRuntimeExports } from '../../node_modules/react/jsx-runtime.js';
4
+
5
+ const DatagridBody = ({
6
+ ...props
7
+ }) => /*#__PURE__*/jsxRuntimeExports.jsx(BaseDatagridBody, {
8
+ ...props
9
+ });
10
+ const BaseDatagridBody = styled.div`
11
+ width: inherit;
12
+
13
+ ${sx}
14
+ `;
15
+
16
+ export { DatagridBody as default };
@@ -0,0 +1,13 @@
1
+ import Grid from '../Grid/index.js';
2
+ import { j as jsxRuntimeExports } from '../../node_modules/react/jsx-runtime.js';
3
+
4
+ const DatagridCell = ({
5
+ children,
6
+ ...props
7
+ }) => /*#__PURE__*/jsxRuntimeExports.jsx(BaseDatagridCell, {
8
+ ...props,
9
+ children: children
10
+ });
11
+ const BaseDatagridCell = Grid.Unit;
12
+
13
+ export { DatagridCell as default };
@@ -0,0 +1,41 @@
1
+ import { r as reactIsExports } from '../../node_modules/react-is/index.js';
2
+ import styled from 'styled-components';
3
+ import { forcePixelValue } from '../../utils/forcePixelValue.js';
4
+ import { sx } from '../../utils/styled-system/index.js';
5
+ import View from '../View/index.js';
6
+ import { j as jsxRuntimeExports } from '../../node_modules/react/jsx-runtime.js';
7
+
8
+ const DatagridHeader = ({
9
+ leadingVisual: LeadingVisual,
10
+ trailingAction,
11
+ ...props
12
+ }) => /*#__PURE__*/jsxRuntimeExports.jsxs(DataGridHeaderWrapper, {
13
+ ...props,
14
+ children: [/*#__PURE__*/jsxRuntimeExports.jsx(View, {
15
+ sx: {
16
+ fontSize: 'xs',
17
+ fontWeight: 'medium',
18
+ lineHeight: 2,
19
+ color: 'text/neutral/subtle'
20
+ },
21
+ children: typeof LeadingVisual !== 'string' && reactIsExports.isValidElementType(LeadingVisual) ? /*#__PURE__*/jsxRuntimeExports.jsx(LeadingVisual, {}) : LeadingVisual
22
+ }), /*#__PURE__*/jsxRuntimeExports.jsx(View, {
23
+ children: trailingAction
24
+ })]
25
+ });
26
+ const DataGridHeaderWrapper = styled.div`
27
+ display: flex;
28
+ align-items: center;
29
+ justify-content: space-between;
30
+ height: 40px;
31
+ padding: ${({
32
+ theme
33
+ }) => `${forcePixelValue(theme.space[1])} ${forcePixelValue(theme.space[4])}`};
34
+ background-color: ${({
35
+ theme
36
+ }) => theme.colors['bg/neutral']};
37
+
38
+ ${sx}
39
+ `;
40
+
41
+ export { DatagridHeader as default };
@@ -0,0 +1,26 @@
1
+ import Grid from '../Grid/index.js';
2
+ import Space from '../Space/index.js';
3
+ import { j as jsxRuntimeExports } from '../../node_modules/react/jsx-runtime.js';
4
+
5
+ const DatagridRow = ({
6
+ gapX = 2,
7
+ alignItems,
8
+ justifyContent,
9
+ sx,
10
+ children,
11
+ ...props
12
+ }) => /*#__PURE__*/jsxRuntimeExports.jsx(DatagridRowWrapper, {
13
+ ...props,
14
+ children: /*#__PURE__*/jsxRuntimeExports.jsx(BaseDatagridRow, {
15
+ wrap: false,
16
+ gapX: gapX,
17
+ alignItems: alignItems,
18
+ justifyContent: justifyContent,
19
+ sx: sx,
20
+ children: children
21
+ })
22
+ });
23
+ const BaseDatagridRow = Grid;
24
+ const DatagridRowWrapper = Space;
25
+
26
+ export { DatagridRow as default };
@@ -0,0 +1,56 @@
1
+ import styled from 'styled-components';
2
+ import useRelocation from '../../hook/useRelocation.js';
3
+ import { forcePixelValue } from '../../utils/forcePixelValue.js';
4
+ import { sx } from '../../utils/styled-system/index.js';
5
+ import DatagridBody from './DatagridBody.js';
6
+ import DatagridCell from './DatagridCell.js';
7
+ import DatagridHeader from './DatagridHeader.js';
8
+ import DatagridRow from './DatagridRow.js';
9
+ import { j as jsxRuntimeExports } from '../../node_modules/react/jsx-runtime.js';
10
+
11
+ const Datagrid = ({
12
+ children,
13
+ sx,
14
+ ...props
15
+ }) => {
16
+ const [relocatableComponentsObject, restConmponents] = useRelocation({
17
+ children,
18
+ config: {
19
+ header: DatagridHeader
20
+ }
21
+ });
22
+ return /*#__PURE__*/jsxRuntimeExports.jsxs(DatagridWrapper, {
23
+ sx: sx,
24
+ children: [relocatableComponentsObject.header, /*#__PURE__*/jsxRuntimeExports.jsx(BaseDatagrid, {
25
+ ...props,
26
+ children: restConmponents
27
+ })]
28
+ });
29
+ };
30
+ const DatagridWrapper = styled.div`
31
+ width: 100%;
32
+
33
+ border-width: ${forcePixelValue(1)};
34
+ border-style: solid;
35
+ border-color: ${({
36
+ theme
37
+ }) => theme.colors['border/neutral']};
38
+ border-radius: ${({
39
+ theme
40
+ }) => forcePixelValue(theme.radii.s)};
41
+ overflow: hidden;
42
+ isolation: isolate;
43
+
44
+ ${sx}
45
+ `;
46
+ const BaseDatagrid = styled.div`
47
+ width: inherit;
48
+ `;
49
+ var index = Object.assign(Datagrid, {
50
+ Header: DatagridHeader,
51
+ Body: DatagridBody,
52
+ Row: DatagridRow,
53
+ Cell: DatagridCell
54
+ });
55
+
56
+ export { index as default };
@@ -0,0 +1,70 @@
1
+ import { isNullable } from '../../utils/isNullable.js';
2
+ import Grid from '../Grid/index.js';
3
+ import ItemList from '../ItemList/index.js';
4
+ import StyledIcon from '../StyledIcon/index.js';
5
+ import Text from '../Text/index.js';
6
+ import View from '../View/index.js';
7
+ import { j as jsxRuntimeExports } from '../../node_modules/react/jsx-runtime.js';
8
+
9
+ const DescriptionList = ({
10
+ item,
11
+ itemDescriptions,
12
+ renderTitle = title => /*#__PURE__*/jsxRuntimeExports.jsx(Text, {
13
+ typography: 'xs',
14
+ color: 'text/neutral/subtler',
15
+ children: title
16
+ }),
17
+ renderDescription = description => /*#__PURE__*/jsxRuntimeExports.jsx(Text, {
18
+ typography: 'xs',
19
+ color: 'text/neutral',
20
+ children: description
21
+ }),
22
+ picks,
23
+ gapX = 2,
24
+ gapY = 1,
25
+ gapItem = 3,
26
+ titleUnitSize = [1, 1 / 8, 1 / 8],
27
+ descriptionUnitSize = [1, 7 / 8, 7 / 8],
28
+ ...props
29
+ }) => /*#__PURE__*/jsxRuntimeExports.jsx(ItemList, {
30
+ items: picks.map(pick => itemDescriptions[pick]),
31
+ renderItem: ({
32
+ icon,
33
+ title,
34
+ renderValue
35
+ }) => {
36
+ const description = renderValue(item);
37
+ return /*#__PURE__*/jsxRuntimeExports.jsxs(Grid, {
38
+ gapX: gapX,
39
+ gapY: gapY,
40
+ children: [/*#__PURE__*/jsxRuntimeExports.jsx(Grid.Unit, {
41
+ size: titleUnitSize,
42
+ children: /*#__PURE__*/jsxRuntimeExports.jsxs(View, {
43
+ display: 'flex',
44
+ alignItems: 'center',
45
+ flexWrap: 'nowrap',
46
+ sx: {
47
+ columnGap: 1
48
+ },
49
+ children: [icon ? /*#__PURE__*/jsxRuntimeExports.jsx(StyledIcon, {
50
+ icon: icon,
51
+ size: 16,
52
+ color: 'icon/neutral'
53
+ }) : null, renderTitle(title)]
54
+ })
55
+ }), /*#__PURE__*/jsxRuntimeExports.jsx(Grid.Unit, {
56
+ size: descriptionUnitSize,
57
+ children: renderDescription(!isNullable(description) ? description : '-')
58
+ })]
59
+ });
60
+ },
61
+ renderItemWrapper: (children, _, i) => /*#__PURE__*/jsxRuntimeExports.jsx(View, {
62
+ sx: {
63
+ marginTop: i > 0 ? gapItem : 0
64
+ },
65
+ children: children
66
+ }, i),
67
+ ...props
68
+ });
69
+
70
+ export { DescriptionList as default };
@@ -16,6 +16,7 @@ const Pill = ({
16
16
  variant = 'secondary',
17
17
  leadingVisual: LeadingVisual,
18
18
  onRemove,
19
+ removeIcon: RemoveIcon = SvgClose,
19
20
  ...props
20
21
  }, ref) => /*#__PURE__*/jsxRuntimeExports.jsxs(BasePill, {
21
22
  ref: ref,
@@ -24,11 +25,14 @@ const Pill = ({
24
25
  hasLeadingVisual: !isNullable(LeadingVisual),
25
26
  hasRemoveButton: !isNullable(onRemove),
26
27
  ...props,
27
- children: [typeof LeadingVisual !== 'string' && reactIsExports.isValidElementType(LeadingVisual) ? /*#__PURE__*/jsxRuntimeExports.jsx(LeadingVisual, {}) : LeadingVisual, text, onRemove ? /*#__PURE__*/jsxRuntimeExports.jsx(UnstyledButton, {
28
+ children: [typeof LeadingVisual !== 'string' && reactIsExports.isValidElementType(LeadingVisual) ? /*#__PURE__*/jsxRuntimeExports.jsx(LeadingVisual, {}) : LeadingVisual, /*#__PURE__*/jsxRuntimeExports.jsx("span", {
29
+ title: text,
30
+ children: text
31
+ }), onRemove ? /*#__PURE__*/jsxRuntimeExports.jsx(UnstyledButton, {
28
32
  type: 'button',
29
33
  onClick: onRemove,
30
34
  "aria-label": 'Remove Pill',
31
- children: /*#__PURE__*/jsxRuntimeExports.jsx(SvgClose, {})
35
+ children: /*#__PURE__*/jsxRuntimeExports.jsx(RemoveIcon, {})
32
36
  }) : null]
33
37
  });
34
38
  const BasePill = styled.span`
@@ -38,6 +42,13 @@ const BasePill = styled.span`
38
42
  theme
39
43
  }) => forcePixelValue(theme.radii.xxs)};
40
44
 
45
+ & span {
46
+ max-width: 240px;
47
+ overflow: hidden;
48
+ text-overflow: ellipsis;
49
+ white-space: pre;
50
+ word-break: break-all;
51
+ }
41
52
  & > button {
42
53
  display: flex;
43
54
  transition: background-color 100ms;
@@ -62,7 +73,7 @@ const BasePill = styled.span`
62
73
  'lineHeight': theme.lineHeights[2],
63
74
  'columnGap': 1,
64
75
  '& svg': {
65
- width: 16,
76
+ minWidth: 16,
66
77
  height: 16,
67
78
  color: theme.colors['icon/primary']
68
79
  },
@@ -79,7 +90,7 @@ const BasePill = styled.span`
79
90
  'lineHeight': theme.lineHeights[2],
80
91
  'columnGap': 0.5,
81
92
  '& svg': {
82
- width: 16,
93
+ minWidth: 16,
83
94
  height: 16,
84
95
  color: theme.colors['icon/primary']
85
96
  },
@@ -96,7 +107,7 @@ const BasePill = styled.span`
96
107
  'lineHeight': theme.lineHeights[2],
97
108
  'columnGap': 0.5,
98
109
  '& svg': {
99
- width: 12,
110
+ minWidth: 12,
100
111
  height: 12,
101
112
  color: theme.colors['icon/primary']
102
113
  },