@ultraviolet/ui 1.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.
Files changed (115) hide show
  1. package/LICENSE +189 -0
  2. package/README.md +64 -0
  3. package/dist/index.d.ts +2427 -0
  4. package/dist/react-datepicker/dist/react-datepicker.min.css.js +3 -0
  5. package/dist/react-toastify/dist/ReactToastify.min.css.js +3 -0
  6. package/dist/src/components/ActionBar/index.js +55 -0
  7. package/dist/src/components/Alert/index.js +144 -0
  8. package/dist/src/components/Avatar/index.js +90 -0
  9. package/dist/src/components/Badge/index.js +143 -0
  10. package/dist/src/components/Banner/index.js +117 -0
  11. package/dist/src/components/BarChart/Tooltip.js +63 -0
  12. package/dist/src/components/BarChart/index.js +94 -0
  13. package/dist/src/components/BarStack/index.js +223 -0
  14. package/dist/src/components/Breadcrumbs/index.js +89 -0
  15. package/dist/src/components/Bullet/index.js +137 -0
  16. package/dist/src/components/Button/index.js +303 -0
  17. package/dist/src/components/Card/index.js +81 -0
  18. package/dist/src/components/Carousel/index.js +162 -0
  19. package/dist/src/components/Checkbox/index.js +338 -0
  20. package/dist/src/components/CopyButton/index.js +92 -0
  21. package/dist/src/components/DateInput/index.js +250 -0
  22. package/dist/src/components/EmptyState/index.js +124 -0
  23. package/dist/src/components/Expandable/index.js +84 -0
  24. package/dist/src/components/Icon/index.js +350 -0
  25. package/dist/src/components/LineChart/CustomLegend.js +147 -0
  26. package/dist/src/components/LineChart/Tooltip.js +58 -0
  27. package/dist/src/components/LineChart/helpers.js +75 -0
  28. package/dist/src/components/LineChart/index.js +139 -0
  29. package/dist/src/components/Link/index.js +159 -0
  30. package/dist/src/components/List/Body.js +22 -0
  31. package/dist/src/components/List/Cell.js +38 -0
  32. package/dist/src/components/List/HeaderCell.js +118 -0
  33. package/dist/src/components/List/HeaderRow.js +47 -0
  34. package/dist/src/components/List/ListContext.js +120 -0
  35. package/dist/src/components/List/Row.js +211 -0
  36. package/dist/src/components/List/SelectBar.js +52 -0
  37. package/dist/src/components/List/SkeletonRows.js +54 -0
  38. package/dist/src/components/List/constants.js +3 -0
  39. package/dist/src/components/List/index.js +77 -0
  40. package/dist/src/components/Loader/index.js +87 -0
  41. package/dist/src/components/Menu/Item.js +122 -0
  42. package/dist/src/components/Menu/index.js +143 -0
  43. package/dist/src/components/Modal/index.js +279 -0
  44. package/dist/src/components/Notice/index.js +33 -0
  45. package/dist/src/components/NumberInput/helpers.js +6 -0
  46. package/dist/src/components/NumberInput/index.js +366 -0
  47. package/dist/src/components/Pagination/getPageNumbers.js +32 -0
  48. package/dist/src/components/Pagination/index.js +118 -0
  49. package/dist/src/components/PasswordCheck/index.js +42 -0
  50. package/dist/src/components/PasswordStrengthMeter/index.js +116 -0
  51. package/dist/src/components/PieChart/Legends.js +183 -0
  52. package/dist/src/components/PieChart/Tooltip.js +64 -0
  53. package/dist/src/components/PieChart/index.js +133 -0
  54. package/dist/src/components/PieChart/patterns.js +9 -0
  55. package/dist/src/components/Popover/index.js +131 -0
  56. package/dist/src/components/ProgressBar/index.js +72 -0
  57. package/dist/src/components/Radio/index.js +231 -0
  58. package/dist/src/components/Row/index.js +43 -0
  59. package/dist/src/components/SelectInput/index.js +662 -0
  60. package/dist/src/components/SelectableCard/index.js +154 -0
  61. package/dist/src/components/Separator/index.js +91 -0
  62. package/dist/src/components/Skeleton/Block.js +53 -0
  63. package/dist/src/components/Skeleton/Blocks.js +52 -0
  64. package/dist/src/components/Skeleton/BoxWithIcon.js +47 -0
  65. package/dist/src/components/Skeleton/Donut.js +58 -0
  66. package/dist/src/components/Skeleton/IconSkeleton.js +37 -0
  67. package/dist/src/components/Skeleton/Line.js +19 -0
  68. package/dist/src/components/Skeleton/List.js +60 -0
  69. package/dist/src/components/Skeleton/Slider.js +57 -0
  70. package/dist/src/components/Skeleton/index.js +85 -0
  71. package/dist/src/components/Snippet/index.js +250 -0
  72. package/dist/src/components/Stack/index.js +24 -0
  73. package/dist/src/components/Status/index.js +101 -0
  74. package/dist/src/components/StepList/index.js +81 -0
  75. package/dist/src/components/Stepper/index.js +217 -0
  76. package/dist/src/components/SwitchButton/FocusOverlay.js +47 -0
  77. package/dist/src/components/SwitchButton/index.js +131 -0
  78. package/dist/src/components/Table/Body.js +12 -0
  79. package/dist/src/components/Table/Cell.js +27 -0
  80. package/dist/src/components/Table/Header.js +21 -0
  81. package/dist/src/components/Table/HeaderCell.js +119 -0
  82. package/dist/src/components/Table/HeaderRow.js +35 -0
  83. package/dist/src/components/Table/Row.js +70 -0
  84. package/dist/src/components/Table/SelectBar.js +52 -0
  85. package/dist/src/components/Table/SkeletonRows.js +52 -0
  86. package/dist/src/components/Table/TableContext.js +91 -0
  87. package/dist/src/components/Table/index.js +84 -0
  88. package/dist/src/components/Tabs/Tab.js +165 -0
  89. package/dist/src/components/Tabs/TabMenu.js +46 -0
  90. package/dist/src/components/Tabs/TabMenuItem.js +40 -0
  91. package/dist/src/components/Tabs/TabsContext.js +6 -0
  92. package/dist/src/components/Tabs/index.js +117 -0
  93. package/dist/src/components/Tag/index.js +177 -0
  94. package/dist/src/components/TagInput/index.js +277 -0
  95. package/dist/src/components/TagList/index.js +110 -0
  96. package/dist/src/components/Text/index.js +106 -0
  97. package/dist/src/components/TextInput/index.js +529 -0
  98. package/dist/src/components/TimeInput/index.js +38 -0
  99. package/dist/src/components/Toaster/index.js +116 -0
  100. package/dist/src/components/Toggle/index.js +192 -0
  101. package/dist/src/components/Tooltip/helpers.js +131 -0
  102. package/dist/src/components/Tooltip/index.js +275 -0
  103. package/dist/src/components/VerificationCode/index.js +203 -0
  104. package/dist/src/helpers/isJSON.js +11 -0
  105. package/dist/src/helpers/legend.js +13 -0
  106. package/dist/src/helpers/recursivelyGetChildrenString.js +12 -0
  107. package/dist/src/index.js +63 -0
  108. package/dist/src/theme/index.js +25 -0
  109. package/dist/src/utils/animations.js +250 -0
  110. package/dist/src/utils/capitalize.js +4 -0
  111. package/dist/src/utils/ids.js +12 -0
  112. package/dist/src/utils/normalize.js +36 -0
  113. package/dist/src/utils/responsive/Breakpoint.js +12 -0
  114. package/dist/src/utils/responsive/utilities.js +12 -0
  115. package/package.json +70 -0
@@ -0,0 +1,52 @@
1
+ import _styled from '@emotion/styled/base';
2
+ import { useMemo } from 'react';
3
+ import { ActionBar } from '../ActionBar/index.js';
4
+ import { useTableContext } from './TableContext.js';
5
+ import { jsx } from '@emotion/react/jsx-runtime';
6
+
7
+ function _EMOTION_STRINGIFIED_CSS_ERROR__() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
8
+ const StyledActionBar = /*#__PURE__*/_styled(ActionBar, {
9
+ target: "esnuyll1"
10
+ })("display:flex;align-items:center;padding:0 ", _ref => {
11
+ let {
12
+ theme
13
+ } = _ref;
14
+ return theme.space['1'];
15
+ }, ";");
16
+ const FlexDiv = /*#__PURE__*/_styled("div", {
17
+ target: "esnuyll0"
18
+ })(process.env.NODE_ENV === "production" ? {
19
+ name: "82a6rk",
20
+ styles: "flex:1"
21
+ } : {
22
+ name: "82a6rk",
23
+ styles: "flex:1",
24
+ toString: _EMOTION_STRINGIFIED_CSS_ERROR__
25
+ });
26
+ function SelectBar(_ref2) {
27
+ let {
28
+ children,
29
+ data,
30
+ idKey,
31
+ className
32
+ } = _ref2;
33
+ const {
34
+ selectedRowIds,
35
+ unselectAll
36
+ } = useTableContext();
37
+ const selectedItems = useMemo(() => data.filter(item => selectedRowIds[item[idKey]]), [data, idKey, selectedRowIds]);
38
+ if (selectedItems.length === 0) {
39
+ return null;
40
+ }
41
+ return jsx(StyledActionBar, {
42
+ className: className,
43
+ children: jsx(FlexDiv, {
44
+ children: children({
45
+ selectedItems,
46
+ unselectAll
47
+ })
48
+ })
49
+ });
50
+ }
51
+
52
+ export { SelectBar };
@@ -0,0 +1,52 @@
1
+ import _styled from '@emotion/styled/base';
2
+ import { Skeleton } from '../Skeleton/index.js';
3
+ import { Cell } from './Cell.js';
4
+ import { jsx, Fragment, jsxs } from '@emotion/react/jsx-runtime';
5
+
6
+ function _EMOTION_STRINGIFIED_CSS_ERROR__() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
7
+ const StyledLoadingRow = /*#__PURE__*/_styled('tr', {
8
+ target: "e1btquhx1"
9
+ })(process.env.NODE_ENV === "production" ? {
10
+ name: "g8zzui",
11
+ styles: "cursor:progress"
12
+ } : {
13
+ name: "g8zzui",
14
+ styles: "cursor:progress",
15
+ toString: _EMOTION_STRINGIFIED_CSS_ERROR__
16
+ });
17
+ const StyledSkeleton = /*#__PURE__*/_styled(Skeleton, {
18
+ target: "e1btquhx0"
19
+ })(process.env.NODE_ENV === "production" ? {
20
+ name: "bet25o",
21
+ styles: "width:80%;max-width:100%"
22
+ } : {
23
+ name: "bet25o",
24
+ styles: "width:80%;max-width:100%",
25
+ toString: _EMOTION_STRINGIFIED_CSS_ERROR__
26
+ });
27
+ const SkeletonRows = _ref => {
28
+ let {
29
+ selectable,
30
+ rows,
31
+ cols
32
+ } = _ref;
33
+ const rowArray = Array.from({
34
+ length: rows
35
+ }, (_, index) => index);
36
+ const colArray = Array.from({
37
+ length: cols
38
+ }, (_, index) => index);
39
+ return jsx(Fragment, {
40
+ children: rowArray.map(index => jsxs(StyledLoadingRow, {
41
+ role: "row",
42
+ id: `skeleton-${index}`,
43
+ children: [selectable ? jsx(Cell, {}) : null, colArray.map(columnIndex => jsx(Cell, {
44
+ children: jsx(StyledSkeleton, {
45
+ variant: "line"
46
+ })
47
+ }, columnIndex))]
48
+ }, index))
49
+ });
50
+ };
51
+
52
+ export { SkeletonRows };
@@ -0,0 +1,91 @@
1
+ import { useContext, createContext, useState, useCallback, useMemo } from 'react';
2
+ import { jsx } from '@emotion/react/jsx-runtime';
3
+
4
+ const TableContext = /*#__PURE__*/createContext(undefined);
5
+ const TableProvider = _ref => {
6
+ let {
7
+ children,
8
+ selectable,
9
+ bordered,
10
+ stripped
11
+ } = _ref;
12
+ const [selectedRowIds, setSelectedRowIds] = useState({});
13
+ const registerSelectableRow = useCallback(rowId => {
14
+ setSelectedRowIds(current => ({
15
+ ...current,
16
+ [rowId]: false
17
+ }));
18
+ return () => {
19
+ setSelectedRowIds(current => {
20
+ const {
21
+ [rowId]: relatedId,
22
+ ...otherIds
23
+ } = current;
24
+ return otherIds;
25
+ });
26
+ };
27
+ }, []);
28
+ const allRowSelectValue = useMemo(() => {
29
+ const selectableRowCount = Object.keys(selectedRowIds).length;
30
+ if (!selectableRowCount) {
31
+ return false;
32
+ }
33
+ const selectedRowCount = Object.values(selectedRowIds).reduce((acc, isSelected) => acc + (isSelected ? 1 : 0), 0);
34
+ if (selectedRowCount === 0) {
35
+ return false;
36
+ }
37
+ if (selectableRowCount === selectedRowCount) {
38
+ return true;
39
+ }
40
+ return 'indeterminate';
41
+ }, [selectedRowIds]);
42
+ const selectAll = useCallback(() => {
43
+ setSelectedRowIds(current => Object.keys(current).reduce((acc, rowId) => ({
44
+ ...acc,
45
+ [rowId]: true
46
+ }), {}));
47
+ }, []);
48
+ const unselectAll = useCallback(() => {
49
+ setSelectedRowIds(current => Object.keys(current).reduce((acc, rowId) => ({
50
+ ...acc,
51
+ [rowId]: false
52
+ }), {}));
53
+ }, []);
54
+ const selectRow = useCallback(rowId => {
55
+ setSelectedRowIds(current => ({
56
+ ...current,
57
+ [rowId]: true
58
+ }));
59
+ }, []);
60
+ const unselectRow = useCallback(rowId => {
61
+ setSelectedRowIds(current => ({
62
+ ...current,
63
+ [rowId]: false
64
+ }));
65
+ }, []);
66
+ const value = useMemo(() => ({
67
+ registerSelectableRow,
68
+ selectedRowIds,
69
+ selectRow,
70
+ unselectRow,
71
+ selectable,
72
+ selectAll,
73
+ unselectAll,
74
+ allRowSelectValue,
75
+ bordered,
76
+ stripped
77
+ }), [registerSelectableRow, selectedRowIds, selectRow, unselectRow, selectable, selectAll, unselectAll, allRowSelectValue, bordered, stripped]);
78
+ return jsx(TableContext.Provider, {
79
+ value: value,
80
+ children: children
81
+ });
82
+ };
83
+ const useTableContext = () => {
84
+ const context = useContext(TableContext);
85
+ if (!context) {
86
+ throw new Error('useTableContext should be used inside a Table component');
87
+ }
88
+ return context;
89
+ };
90
+
91
+ export { TableProvider, useTableContext };
@@ -0,0 +1,84 @@
1
+ import _styled from '@emotion/styled/base';
2
+ import { forwardRef } from 'react';
3
+ import { Body } from './Body.js';
4
+ import { Cell } from './Cell.js';
5
+ import { Header } from './Header.js';
6
+ import { HeaderCell } from './HeaderCell.js';
7
+ import { HeaderRow } from './HeaderRow.js';
8
+ import { Row } from './Row.js';
9
+ import { SelectBar } from './SelectBar.js';
10
+ import { SkeletonRows } from './SkeletonRows.js';
11
+ import { useTableContext, TableProvider } from './TableContext.js';
12
+ import { jsx, jsxs } from '@emotion/react/jsx-runtime';
13
+
14
+ const StyledTable = /*#__PURE__*/_styled('table', {
15
+ shouldForwardProp: prop => !['bordered', 'stripped'].includes(prop),
16
+ target: "ert5hkm0"
17
+ })("width:100%;box-sizing:content-box;border-collapse:collapse;", _ref => {
18
+ let {
19
+ theme,
20
+ stripped,
21
+ bordered
22
+ } = _ref;
23
+ return `
24
+ ${stripped ? `& tbody tr:nth-of-type(even) {
25
+ background: ${theme.colors.neutral.backgroundStrong};
26
+ }` : ''}
27
+
28
+ ${bordered ? `& tbody tr {
29
+ border-bottom: 1px solid ${theme.colors.neutral.borderWeak};
30
+ }` : ''}
31
+ `;
32
+ }, ";");
33
+ const BaseTable = /*#__PURE__*/forwardRef((_ref2, ref) => {
34
+ let {
35
+ selectable = false,
36
+ children,
37
+ columns,
38
+ loading,
39
+ bordered = false,
40
+ stripped = false
41
+ } = _ref2;
42
+ return jsx(TableProvider, {
43
+ selectable: selectable,
44
+ stripped: stripped,
45
+ bordered: bordered,
46
+ children: jsxs(StyledTable, {
47
+ ref: ref,
48
+ stripped: stripped,
49
+ bordered: bordered,
50
+ children: [jsx(Header, {
51
+ children: jsx(HeaderRow, {
52
+ hasSelectAllColumn: selectable,
53
+ children: columns.map((column, index) => jsx(HeaderCell
54
+ // eslint-disable-next-line react/no-array-index-key
55
+ , {
56
+ isOrdered: column.isOrdered,
57
+ orderDirection: column.orderDirection,
58
+ onOrder: column.onOrder,
59
+ width: column.width,
60
+ minWidth: column.minWidth,
61
+ maxWidth: column.maxWidth,
62
+ info: column.info,
63
+ children: column.label
64
+ }, `header-column-${index}`))
65
+ })
66
+ }), loading ? jsx(Body, {
67
+ children: jsx(SkeletonRows, {
68
+ selectable: selectable,
69
+ rows: 5,
70
+ cols: columns.length
71
+ })
72
+ }) : children]
73
+ })
74
+ });
75
+ });
76
+ const Table = /*#__PURE__*/Object.assign(BaseTable, {
77
+ Body,
78
+ Row,
79
+ Cell,
80
+ useTableContext,
81
+ SelectBar
82
+ });
83
+
84
+ export { BaseTable, Table };
@@ -0,0 +1,165 @@
1
+ import _styled from '@emotion/styled/base';
2
+ import { forwardRef, useMemo } from 'react';
3
+ import { Badge } from '../Badge/index.js';
4
+ import { Tooltip } from '../Tooltip/index.js';
5
+ import { useTabsContext } from './TabsContext.js';
6
+ import { jsx, jsxs } from '@emotion/react/jsx-runtime';
7
+
8
+ const StyledBadge = /*#__PURE__*/_styled(Badge, {
9
+ target: "e1hzf7cr3"
10
+ })("padding:0 ", _ref => {
11
+ let {
12
+ theme
13
+ } = _ref;
14
+ return theme.space['1'];
15
+ }, ";margin-left:", _ref2 => {
16
+ let {
17
+ theme
18
+ } = _ref2;
19
+ return theme.space['1'];
20
+ }, ";");
21
+ const StyledTooltip = /*#__PURE__*/_styled(Tooltip, {
22
+ target: "e1hzf7cr2"
23
+ })();
24
+ const BadgeContainer = /*#__PURE__*/_styled("span", {
25
+ target: "e1hzf7cr1"
26
+ })("margin-left:", _ref3 => {
27
+ let {
28
+ theme
29
+ } = _ref3;
30
+ return theme.space['1'];
31
+ }, ";display:flex;");
32
+ const StyledTabButton = /*#__PURE__*/_styled("button", {
33
+ target: "e1hzf7cr0"
34
+ })("display:flex;flex-direction:row;padding:", _ref4 => {
35
+ let {
36
+ theme
37
+ } = _ref4;
38
+ return `${theme.space['1']} ${theme.space['2']}`;
39
+ }, ";cursor:pointer;justify-content:center;align-items:center;white-space:nowrap;color:", _ref5 => {
40
+ let {
41
+ theme
42
+ } = _ref5;
43
+ return theme.colors.neutral.text;
44
+ }, ";text-decoration:none;user-select:none;touch-action:manipulation;transition:color 0.2s;border:none;background:none;border-bottom-width:2px;border-bottom-style:solid;border-bottom-color:", _ref6 => {
45
+ let {
46
+ theme
47
+ } = _ref6;
48
+ return theme.colors.neutral.borderWeak;
49
+ }, ";outline:none;font-size:", _ref7 => {
50
+ let {
51
+ theme
52
+ } = _ref7;
53
+ return theme.typography.bodyStrong.fontSize;
54
+ }, ";font-family:", _ref8 => {
55
+ let {
56
+ theme
57
+ } = _ref8;
58
+ return theme.typography.bodyStrong.fontFamily;
59
+ }, ";font-weight:", _ref9 => {
60
+ let {
61
+ theme
62
+ } = _ref9;
63
+ return theme.typography.bodyStrong.weight;
64
+ }, ";letter-spacing:", _ref10 => {
65
+ let {
66
+ theme
67
+ } = _ref10;
68
+ return theme.typography.bodyStrong.letterSpacing;
69
+ }, ";line-height:", _ref11 => {
70
+ let {
71
+ theme
72
+ } = _ref11;
73
+ return theme.typography.bodyStrong.lineHeight;
74
+ }, ";&:hover,&:active,&:focus{text-decoration:none;outline:none;}&:focus-visible{outline:auto;}&[aria-selected='true']{color:", _ref12 => {
75
+ let {
76
+ theme
77
+ } = _ref12;
78
+ return theme.colors.primary.text;
79
+ }, ";border-bottom-color:", _ref13 => {
80
+ let {
81
+ theme
82
+ } = _ref13;
83
+ return theme.colors.primary.borderWeak;
84
+ }, ";}&[aria-disabled='false']:not(:disabled){&:hover,&:focus,&:active{outline:none;color:", _ref14 => {
85
+ let {
86
+ theme
87
+ } = _ref14;
88
+ return theme.colors.primary.text;
89
+ }, ";border-bottom-color:", _ref15 => {
90
+ let {
91
+ theme
92
+ } = _ref15;
93
+ return theme.colors.primary.borderWeak;
94
+ }, ";", StyledBadge, "{background-color:", _ref16 => {
95
+ let {
96
+ theme
97
+ } = _ref16;
98
+ return theme.colors.primary.background;
99
+ }, ";border-color:", _ref17 => {
100
+ let {
101
+ theme
102
+ } = _ref17;
103
+ return theme.colors.primary.background;
104
+ }, ";color:", _ref18 => {
105
+ let {
106
+ theme
107
+ } = _ref18;
108
+ return theme.colors.primary.text;
109
+ }, ";}}}&[aria-disabled='true'],&:disabled{cursor:not-allowed;filter:grayscale(1) opacity(50%);}");
110
+ const Tab = /*#__PURE__*/forwardRef((_ref19, ref) => {
111
+ let {
112
+ as,
113
+ badge,
114
+ children,
115
+ className,
116
+ counter,
117
+ disabled = false,
118
+ value,
119
+ onClick,
120
+ onKeyDown,
121
+ tooltip,
122
+ ...props
123
+ } = _ref19;
124
+ const {
125
+ selected,
126
+ onChange
127
+ } = useTabsContext();
128
+ const computedAs = as ?? 'button';
129
+ const isSelected = useMemo(() => value !== undefined && selected === value, [value, selected]);
130
+ return jsx(StyledTooltip, {
131
+ text: tooltip,
132
+ children: jsxs(StyledTabButton, {
133
+ role: "tab",
134
+ ref: ref,
135
+ className: className,
136
+ as: computedAs,
137
+ "aria-label": value ? `${value}` : undefined,
138
+ "aria-selected": isSelected,
139
+ "aria-disabled": disabled,
140
+ disabled: computedAs === 'button' ? disabled : undefined,
141
+ type: computedAs === 'button' ? 'button' : undefined,
142
+ onClick: event => {
143
+ if (value !== undefined) {
144
+ onChange(value);
145
+ }
146
+ onClick?.(event);
147
+ },
148
+ onKeyDown: event => {
149
+ onKeyDown?.(event);
150
+ if (!event.defaultPrevented && !disabled && value) onChange(value);
151
+ },
152
+ ...props,
153
+ children: [children, typeof counter === 'number' || typeof counter === 'string' ? jsx(StyledBadge, {
154
+ sentiment: isSelected ? 'primary' : 'neutral',
155
+ prominence: isSelected ? 'default' : 'strong',
156
+ size: "medium",
157
+ children: counter
158
+ }) : null, badge ? jsx(BadgeContainer, {
159
+ children: badge
160
+ }) : null]
161
+ })
162
+ });
163
+ });
164
+
165
+ export { StyledTabButton, Tab };
@@ -0,0 +1,46 @@
1
+ import _styled from '@emotion/styled/base';
2
+ import { forwardRef } from 'react';
3
+ import { Icon } from '../Icon/index.js';
4
+ import { Menu } from '../Menu/index.js';
5
+ import { StyledTabButton } from './Tab.js';
6
+ import { jsx, jsxs } from '@emotion/react/jsx-runtime';
7
+
8
+ const ArrowIcon = /*#__PURE__*/_styled(Icon, {
9
+ target: "edb1sh91"
10
+ })();
11
+ const StyledMenu = /*#__PURE__*/_styled(StyledTabButton, {
12
+ target: "edb1sh90"
13
+ })(ArrowIcon, "{color:inherit;margin-left:", _ref => {
14
+ let {
15
+ theme
16
+ } = _ref;
17
+ return theme.space['1'];
18
+ }, ";transition:300ms transform ease-out;}&[aria-expanded='true'] ", ArrowIcon, "{transform:rotate(-180deg);}");
19
+ const TabMenu = /*#__PURE__*/forwardRef((_ref2, ref) => {
20
+ let {
21
+ children,
22
+ disclosure,
23
+ visible,
24
+ id,
25
+ disabled,
26
+ ...props
27
+ } = _ref2;
28
+ return jsx(Menu, {
29
+ visible: visible,
30
+ id: id,
31
+ ref: ref,
32
+ disclosure: jsxs(StyledMenu, {
33
+ role: "tab",
34
+ "aria-disabled": disabled ?? 'false',
35
+ disabled: disabled,
36
+ "aria-haspopup": "menu",
37
+ ...props,
38
+ children: [disclosure, jsx(ArrowIcon, {
39
+ name: "arrow-down"
40
+ })]
41
+ }),
42
+ children: children
43
+ });
44
+ });
45
+
46
+ export { TabMenu };
@@ -0,0 +1,40 @@
1
+ import _styled from '@emotion/styled/base';
2
+ import { useMemo } from 'react';
3
+ import Item from '../Menu/Item.js';
4
+ import { useTabsContext } from './TabsContext.js';
5
+ import { jsx } from '@emotion/react/jsx-runtime';
6
+
7
+ const StyledMenuItem = /*#__PURE__*/_styled(Item, {
8
+ target: "eeet93f0"
9
+ })("&[aria-selected='true']{color:", _ref => {
10
+ let {
11
+ theme
12
+ } = _ref;
13
+ return theme.colors.primary.text;
14
+ }, ";}");
15
+ const TabMenuItem = _ref2 => {
16
+ let {
17
+ value,
18
+ children,
19
+ onClick,
20
+ ...props
21
+ } = _ref2;
22
+ const {
23
+ selected,
24
+ onChange
25
+ } = useTabsContext();
26
+ const isSelected = useMemo(() => value !== undefined && selected === value, [value, selected]);
27
+ return jsx(StyledMenuItem, {
28
+ onClick: event => {
29
+ if (value !== undefined) {
30
+ onChange(value);
31
+ }
32
+ onClick?.(event);
33
+ },
34
+ "aria-selected": isSelected,
35
+ ...props,
36
+ children: children
37
+ });
38
+ };
39
+
40
+ export { TabMenuItem };
@@ -0,0 +1,6 @@
1
+ import { createContext, useContext } from 'react';
2
+
3
+ const TabsContext = /*#__PURE__*/createContext({});
4
+ const useTabsContext = () => useContext(TabsContext);
5
+
6
+ export { TabsContext, useTabsContext };
@@ -0,0 +1,117 @@
1
+ import _styled from '@emotion/styled/base';
2
+ import { useRef, useState, useMemo, useEffect } from 'react';
3
+ import { Tab, StyledTabButton } from './Tab.js';
4
+ import { TabMenu } from './TabMenu.js';
5
+ import { TabMenuItem } from './TabMenuItem.js';
6
+ import { TabsContext } from './TabsContext.js';
7
+ import { jsx, jsxs } from '@emotion/react/jsx-runtime';
8
+
9
+ const MenuContainer = /*#__PURE__*/_styled("div", {
10
+ target: "ewug27g2"
11
+ })("display:flex;flex-direction:column;", StyledTabButton, "{font-size:", _ref => {
12
+ let {
13
+ theme
14
+ } = _ref;
15
+ return theme.typography.bodySmall.fontSize;
16
+ }, ";line-height:", _ref2 => {
17
+ let {
18
+ theme
19
+ } = _ref2;
20
+ return theme.typography.bodySmall.lineHeight;
21
+ }, ";font-weight:inherit;padding:", _ref3 => {
22
+ let {
23
+ theme
24
+ } = _ref3;
25
+ return `${theme.space['1']} ${theme.space['2']}`;
26
+ }, ";border-bottom-width:1px;width:100%;cursor:pointer;min-width:110px;background-color:transparent;}");
27
+ const StyledTabMenu = /*#__PURE__*/_styled(TabMenu, {
28
+ target: "ewug27g1"
29
+ })("position:sticky;right:0;top:0;bottom:0;background:", _ref4 => {
30
+ let {
31
+ theme
32
+ } = _ref4;
33
+ return theme.colors.neutral.background;
34
+ }, ";box-shadow:", _ref5 => {
35
+ let {
36
+ theme
37
+ } = _ref5;
38
+ return theme.shadows.menu;
39
+ }, ";");
40
+ const TabsContainer = /*#__PURE__*/_styled("div", {
41
+ target: "ewug27g0"
42
+ })("display:flex;flex-wrap:nowrap;overflow-x:scroll;position:relative;z-index:0;-ms-overflow-style:none;scrollbar-width:none;&::after{z-index:-1;content:'';position:absolute;bottom:0;left:0;right:0;height:2px;background:", _ref6 => {
43
+ let {
44
+ theme
45
+ } = _ref6;
46
+ return theme.colors.neutral.borderWeak;
47
+ }, ";}&::-webkit-scrollbar{display:none;}");
48
+ const SHADOW_THRESHOLD = 10;
49
+ const Tabs = _ref7 => {
50
+ let {
51
+ children = null,
52
+ onChange,
53
+ moreDisclosure = 'More',
54
+ selected,
55
+ className,
56
+ 'data-testid': dataTestId,
57
+ ...props
58
+ } = _ref7;
59
+ const tabsRef = useRef({});
60
+ const moreStaticRef = useRef({});
61
+ const [displayMore, setDisplayMore] = useState(false);
62
+ const value = useMemo(() => ({
63
+ onChange,
64
+ selected
65
+ }), [selected, onChange]);
66
+ useEffect(() => {
67
+ setDisplayMore(tabsRef.current.scrollWidth > tabsRef.current.clientWidth);
68
+ }, [children]);
69
+
70
+ // Scroll automatically to the tab
71
+ useEffect(() => {
72
+ const tab = tabsRef.current.querySelector(`[role='tab'][aria-selected='true']`);
73
+ if (tab && tabsRef.current.scrollTo) {
74
+ tabsRef.current.scrollTo({
75
+ left: tab.offsetLeft,
76
+ behavior: 'smooth'
77
+ });
78
+ }
79
+ }, [selected]);
80
+
81
+ // Change the moreButton style automatically based on the scroll
82
+ useEffect(() => {
83
+ const element = tabsRef.current;
84
+ const moreElement = moreStaticRef.current;
85
+ const handler = () => {
86
+ moreElement.style.boxShadow = element.scrollLeft + SHADOW_THRESHOLD > element.scrollWidth - element.clientWidth ? 'none' : '';
87
+ };
88
+ if (displayMore) {
89
+ element.addEventListener('scroll', handler);
90
+ }
91
+ return () => {
92
+ if (displayMore) element.removeEventListener('scroll', handler);
93
+ };
94
+ }, [displayMore]);
95
+ return jsx(TabsContext.Provider, {
96
+ value: value,
97
+ children: jsxs(TabsContainer, {
98
+ ref: tabsRef,
99
+ role: "tablist",
100
+ className: className,
101
+ "data-testid": dataTestId,
102
+ ...props,
103
+ children: [children, displayMore ? jsx(StyledTabMenu, {
104
+ ref: moreStaticRef,
105
+ disclosure: moreDisclosure,
106
+ children: jsx(MenuContainer, {
107
+ children: children
108
+ })
109
+ }) : null]
110
+ })
111
+ });
112
+ };
113
+ Tabs.Tab = Tab;
114
+ Tabs.Menu = TabMenu;
115
+ Tabs.MenuItem = TabMenuItem;
116
+
117
+ export { Tabs };