@zendeskgarden/react-tables 9.0.0-next.6 → 9.0.0-next.8

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 (33) hide show
  1. package/dist/esm/elements/Body.js +26 -0
  2. package/dist/esm/elements/Caption.js +26 -0
  3. package/dist/esm/elements/Cell.js +44 -0
  4. package/dist/esm/elements/GroupRow.js +33 -0
  5. package/dist/esm/elements/Head.js +26 -0
  6. package/dist/esm/elements/HeaderCell.js +39 -0
  7. package/dist/esm/elements/HeaderRow.js +33 -0
  8. package/dist/esm/elements/OverflowButton.js +55 -0
  9. package/dist/esm/elements/Row.js +68 -0
  10. package/dist/esm/elements/SortableCell.js +55 -0
  11. package/dist/esm/elements/Table.js +65 -0
  12. package/dist/esm/index.js +17 -0
  13. package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/12/sort-fill.svg.js +27 -0
  14. package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/12/sort-stroke.svg.js +27 -0
  15. package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/16/overflow-stroke.svg.js +36 -0
  16. package/dist/esm/styled/StyledBody.js +22 -0
  17. package/dist/esm/styled/StyledCaption.js +22 -0
  18. package/dist/esm/styled/StyledCell.js +47 -0
  19. package/dist/esm/styled/StyledGroupRow.js +31 -0
  20. package/dist/esm/styled/StyledHead.js +27 -0
  21. package/dist/esm/styled/StyledHeaderCell.js +44 -0
  22. package/dist/esm/styled/StyledHeaderRow.js +33 -0
  23. package/dist/esm/styled/StyledHiddenCell.js +23 -0
  24. package/dist/esm/styled/StyledOverflowButton.js +51 -0
  25. package/dist/esm/styled/StyledRow.js +62 -0
  26. package/dist/esm/styled/StyledSortableButton.js +81 -0
  27. package/dist/esm/styled/StyledTable.js +25 -0
  28. package/dist/esm/styled/style-utils.js +16 -0
  29. package/dist/esm/types/index.js +10 -0
  30. package/dist/esm/utils/useTableContext.js +17 -0
  31. package/dist/index.cjs.js +29 -45
  32. package/package.json +5 -5
  33. package/dist/index.esm.js +0 -648
package/dist/index.esm.js DELETED
@@ -1,648 +0,0 @@
1
- /**
2
- * Copyright Zendesk, Inc.
3
- *
4
- * Use of this source code is governed under the Apache License, Version 2.0
5
- * found at http://www.apache.org/licenses/LICENSE-2.0.
6
- */
7
-
8
- import * as React from 'react';
9
- import React__default, { forwardRef, useContext, useState, useMemo } from 'react';
10
- import styled, { css } from 'styled-components';
11
- import { retrieveComponentStyles, DEFAULT_THEME, getColorV8, focusStyles, SELECTOR_FOCUS_VISIBLE } from '@zendeskgarden/react-theming';
12
- import { math, hideVisually } from 'polished';
13
- import PropTypes from 'prop-types';
14
- import { composeEventHandlers } from '@zendeskgarden/container-utilities';
15
-
16
- function _extends$3() {
17
- _extends$3 = Object.assign ? Object.assign.bind() : function (target) {
18
- for (var i = 1; i < arguments.length; i++) {
19
- var source = arguments[i];
20
- for (var key in source) {
21
- if (Object.prototype.hasOwnProperty.call(source, key)) {
22
- target[key] = source[key];
23
- }
24
- }
25
- }
26
- return target;
27
- };
28
- return _extends$3.apply(this, arguments);
29
- }
30
-
31
- const COMPONENT_ID$b = 'tables.body';
32
- const StyledBody = styled.tbody.attrs({
33
- 'data-garden-id': COMPONENT_ID$b,
34
- 'data-garden-version': '9.0.0-next.6'
35
- }).withConfig({
36
- displayName: "StyledBody",
37
- componentId: "sc-14ud6y-0"
38
- })(["", ";"], props => retrieveComponentStyles(COMPONENT_ID$b, props));
39
- StyledBody.defaultProps = {
40
- theme: DEFAULT_THEME
41
- };
42
-
43
- const COMPONENT_ID$a = 'tables.caption';
44
- const StyledCaption = styled.caption.attrs({
45
- 'data-garden-id': COMPONENT_ID$a,
46
- 'data-garden-version': '9.0.0-next.6'
47
- }).withConfig({
48
- displayName: "StyledCaption",
49
- componentId: "sc-113y327-0"
50
- })(["display:table-caption;text-align:", ";", ";"], props => props.theme.rtl ? 'right' : 'left', props => retrieveComponentStyles(COMPONENT_ID$a, props));
51
- StyledCaption.defaultProps = {
52
- theme: DEFAULT_THEME
53
- };
54
-
55
- const COMPONENT_ID$9 = 'tables.table';
56
- const getLineHeight = props => {
57
- return `${props.theme.space.base * 5}px`;
58
- };
59
- const StyledTable = styled.table.attrs({
60
- 'data-garden-id': COMPONENT_ID$9,
61
- 'data-garden-version': '9.0.0-next.6'
62
- }).withConfig({
63
- displayName: "StyledTable",
64
- componentId: "sc-gje7na-0"
65
- })(["display:table;border:none;width:100%;table-layout:fixed;border-collapse:collapse;border-spacing:0;line-height:", ";color:", ";font-size:", ";direction:", ";", ";"], props => getLineHeight(props), props => getColorV8('foreground', 600 , props.theme), props => props.theme.fontSizes.md, props => props.theme.rtl && 'rtl', props => retrieveComponentStyles(COMPONENT_ID$9, props));
66
- StyledTable.defaultProps = {
67
- theme: DEFAULT_THEME
68
- };
69
-
70
- const getRowHeight = props => {
71
- if (props.size === 'large') {
72
- return `${props.theme.space.base * 16}px`;
73
- } else if (props.size === 'small') {
74
- return `${props.theme.space.base * 8}px`;
75
- }
76
- return `${props.theme.space.base * 10}px`;
77
- };
78
-
79
- const COMPONENT_ID$8 = 'tables.cell';
80
- const truncatedStyling$1 = css(["overflow:hidden;text-overflow:ellipsis;white-space:nowrap;"]);
81
- const sizeStyling = props => {
82
- let boxSizing = 'border-box';
83
- let padding;
84
- let width = props.width;
85
- let height;
86
- if (props.hasOverflow) {
87
- boxSizing = 'content-box';
88
- width = '2em';
89
- height = 'inherit';
90
- padding = props.theme.rtl ? `0 0 0 ${props.theme.space.base}px` : `0 ${props.theme.space.base}px 0 0`;
91
- } else {
92
- const paddingVertical = math(`(${getRowHeight(props)} - ${getLineHeight(props)}) / 2`);
93
- const paddingHorizontal = `${props.theme.space.base * 3}px`;
94
- padding = `${paddingVertical} ${paddingHorizontal}`;
95
- }
96
- if (props.isMinimum) {
97
- boxSizing = 'content-box';
98
- width = '1em';
99
- }
100
- return css(["box-sizing:", ";padding:", ";width:", ";height:", ";"], boxSizing, padding, width, height);
101
- };
102
- const StyledCell = styled.td.attrs({
103
- 'data-garden-id': COMPONENT_ID$8,
104
- 'data-garden-version': '9.0.0-next.6'
105
- }).withConfig({
106
- displayName: "StyledCell",
107
- componentId: "sc-8hpncx-0"
108
- })(["display:table-cell;transition:border-color 0.25s ease-in-out,box-shadow 0.1s ease-in-out;", ";", ";", ";"], props => sizeStyling(props), props => props.isTruncated && truncatedStyling$1, props => retrieveComponentStyles(COMPONENT_ID$8, props));
109
- StyledCell.defaultProps = {
110
- theme: DEFAULT_THEME
111
- };
112
-
113
- const COMPONENT_ID$7 = 'tables.overflow_button';
114
- const OVERFLOW_BUTTON_SIZE = '2em';
115
- const colorStyles$1 = props => {
116
- const hoverBackgroundColor = getColorV8('primaryHue', 600, props.theme, 0.08);
117
- const hoverForegroundColor = getColorV8('neutralHue', 700, props.theme);
118
- const activeBackgroundColor = getColorV8('primaryHue', 600, props.theme, 0.2);
119
- const activeForegroundColor = getColorV8('neutralHue', 800, props.theme);
120
- let foregroundColor;
121
- if (props.isHovered) {
122
- foregroundColor = hoverForegroundColor;
123
- } else if (props.isActive) {
124
- foregroundColor = activeForegroundColor;
125
- } else {
126
- foregroundColor = getColorV8('neutralHue', 600, props.theme);
127
- }
128
- return css(["color:", ";&:hover{background-color:", ";color:", ";}", " &:active{background-color:", ";color:", ";}"], foregroundColor, hoverBackgroundColor, hoverForegroundColor, focusStyles({
129
- theme: props.theme,
130
- inset: true
131
- }), activeBackgroundColor, activeForegroundColor);
132
- };
133
- const StyledOverflowButton = styled.button.attrs({
134
- 'data-garden-id': COMPONENT_ID$7,
135
- 'data-garden-version': '9.0.0-next.6',
136
- type: 'button'
137
- }).withConfig({
138
- displayName: "StyledOverflowButton",
139
- componentId: "sc-1eba2ml-0"
140
- })(["display:block;transition:background-color 0.1s ease-in-out,box-shadow 0.1s ease-in-out;z-index:", ";margin-top:calc(", " - 1em);border:none;border-radius:50%;background-color:transparent;cursor:pointer;padding:0;width:100%;height:", ";text-decoration:none;font-size:inherit;", " ", ";"], props => props.isActive ? '1' : '0', props => math(`${getRowHeight(props)} / 2`), OVERFLOW_BUTTON_SIZE, props => colorStyles$1(props), props => retrieveComponentStyles(COMPONENT_ID$7, props));
141
- StyledOverflowButton.defaultProps = {
142
- theme: DEFAULT_THEME
143
- };
144
- const StyledOverflowButtonIconWrapper = styled.div.withConfig({
145
- displayName: "StyledOverflowButton__StyledOverflowButtonIconWrapper",
146
- componentId: "sc-1eba2ml-1"
147
- })(["display:flex;align-items:center;justify-content:center;transform:rotate(90deg);transition:background-color 0.1s ease-in-out;width:", ";height:", ";"], OVERFLOW_BUTTON_SIZE, OVERFLOW_BUTTON_SIZE);
148
- StyledOverflowButtonIconWrapper.defaultProps = {
149
- theme: DEFAULT_THEME
150
- };
151
-
152
- const COMPONENT_ID$6 = 'tables.row';
153
- const StyledBaseRow = styled.tr.withConfig({
154
- displayName: "StyledRow__StyledBaseRow",
155
- componentId: "sc-ek66ow-0"
156
- })(["display:table-row;transition:background-color 0.1s ease-in-out;border-bottom:", ";background-color:", ";vertical-align:top;box-sizing:border-box;"], props => `${props.theme.borders.sm} ${getColorV8('neutralHue', 200, props.theme)}`, props => props.isStriped && getColorV8('neutralHue', 100, props.theme));
157
- StyledBaseRow.defaultProps = {
158
- theme: DEFAULT_THEME
159
- };
160
- const colorStyles = props => {
161
- const boxShadow = `inset ${props.theme.rtl ? '-' : ''}${props.theme.shadowWidths.md} 0 0 0 ${getColorV8('primaryHue', 600, props.theme)}`;
162
- const hoveredBackgroundColor = getColorV8('primaryHue', 600, props.theme, 0.08);
163
- const hoveredBorderColor = getColorV8('primaryHue', 200, props.theme);
164
- const selectedBackgroundColor = getColorV8('primaryHue', 600, props.theme, 0.2);
165
- const selectedBorderColor = getColorV8('primaryHue', 300, props.theme);
166
- const hoveredSelectedBackgroundColor = getColorV8('primaryHue', 600, props.theme, 0.28);
167
- let backgroundColor = undefined;
168
- let borderColor = undefined;
169
- let hoverBorderBottomColor = undefined;
170
- let hoverBackgroundColor = undefined;
171
- if (props.isSelected) {
172
- if (props.isHovered) {
173
- backgroundColor = hoveredSelectedBackgroundColor;
174
- } else {
175
- backgroundColor = selectedBackgroundColor;
176
- }
177
- borderColor = selectedBorderColor;
178
- hoverBorderBottomColor = selectedBorderColor;
179
- hoverBackgroundColor = hoveredSelectedBackgroundColor;
180
- } else if (props.isHovered) {
181
- backgroundColor = hoveredBackgroundColor;
182
- borderColor = hoveredBorderColor;
183
- } else if (!props.isReadOnly) {
184
- hoverBorderBottomColor = hoveredBorderColor;
185
- hoverBackgroundColor = hoveredBackgroundColor;
186
- }
187
- return css(["border-bottom-color:", ";background-color:", ";&:hover{border-bottom-color:", ";background-color:", ";", "{opacity:1;}}&:focus{outline:none;}", ":first-of-type{box-shadow:", ";&:focus{box-shadow:", ";}}"], borderColor, backgroundColor, hoverBorderBottomColor, hoverBackgroundColor, StyledOverflowButton, StyledCell, props.isFocused && boxShadow, boxShadow);
188
- };
189
- const StyledRow = styled(StyledBaseRow).attrs(props => ({
190
- 'data-garden-id': COMPONENT_ID$6,
191
- 'data-garden-version': '9.0.0-next.6',
192
- tabIndex: props.isReadOnly ? undefined : -1
193
- })).withConfig({
194
- displayName: "StyledRow",
195
- componentId: "sc-ek66ow-1"
196
- })(["height:", ";", " ", ";"], getRowHeight, props => colorStyles(props), props => retrieveComponentStyles(COMPONENT_ID$6, props));
197
- StyledRow.defaultProps = {
198
- theme: DEFAULT_THEME
199
- };
200
-
201
- const COMPONENT_ID$5 = 'tables.header_row';
202
- const getHeaderRowHeight = props => {
203
- if (props.size === 'large') {
204
- return `${props.theme.space.base * 18}px`;
205
- } else if (props.size === 'small') {
206
- return `${props.theme.space.base * 10}px`;
207
- }
208
- return `${props.theme.space.base * 12}px`;
209
- };
210
- const StyledHeaderRow = styled(StyledBaseRow).attrs({
211
- 'data-garden-id': COMPONENT_ID$5,
212
- 'data-garden-version': '9.0.0-next.6'
213
- }).withConfig({
214
- displayName: "StyledHeaderRow",
215
- componentId: "sc-16ogvdx-0"
216
- })(["border-bottom-color:", ";height:", ";vertical-align:bottom;font-weight:", ";", "{opacity:1;margin-top:0;margin-bottom:calc(", " - 1em);}", ";"], props => getColorV8('neutralHue', 300, props.theme), getHeaderRowHeight, props => props.theme.fontWeights.semibold, StyledOverflowButton, props => math(`${getHeaderRowHeight(props)} / 2`), props => retrieveComponentStyles(COMPONENT_ID$5, props));
217
- StyledHeaderRow.defaultProps = {
218
- theme: DEFAULT_THEME
219
- };
220
-
221
- const COMPONENT_ID$4 = 'tables.head';
222
- const stickyStyles = props => {
223
- const borderColor = getColorV8('neutralHue', 300, props.theme);
224
- return css(["position:sticky;top:0;z-index:1;box-shadow:inset 0 -", " 0 ", ";background-color:", ";& > ", ":last-child{border-bottom-color:transparent;}"], props.theme.borderWidths.sm, borderColor, getColorV8('background', 600 , props.theme), StyledHeaderRow);
225
- };
226
- const StyledHead = styled.thead.attrs({
227
- 'data-garden-id': COMPONENT_ID$4,
228
- 'data-garden-version': '9.0.0-next.6'
229
- }).withConfig({
230
- displayName: "StyledHead",
231
- componentId: "sc-spf23a-0"
232
- })(["", " ", ";"], props => props.isSticky && stickyStyles(props), props => retrieveComponentStyles(COMPONENT_ID$4, props));
233
- StyledHead.defaultProps = {
234
- theme: DEFAULT_THEME
235
- };
236
-
237
- const COMPONENT_ID$3 = 'tables.group_row';
238
- const sizeStyles$1 = props => {
239
- const height = `${props.theme.space.base * 8}px`;
240
- const lineHeight = getLineHeight(props);
241
- return css(["height:", ";line-height:", ";font-size:", ";", "{padding:", " ", "px;}"], height, lineHeight, props.theme.fontSizes.sm, StyledCell, math(`(${height} - ${lineHeight}) / 2`), props.theme.space.base * 3);
242
- };
243
- const StyledGroupRow = styled(StyledBaseRow).attrs({
244
- 'data-garden-id': COMPONENT_ID$3,
245
- 'data-garden-version': '9.0.0-next.6'
246
- }).withConfig({
247
- displayName: "StyledGroupRow",
248
- componentId: "sc-mpd0r8-0"
249
- })(["background-color:", ";", " ", ";"], props => getColorV8('neutralHue', 100, props.theme), props => sizeStyles$1(props), props => retrieveComponentStyles(COMPONENT_ID$3, props));
250
- StyledGroupRow.defaultProps = {
251
- theme: DEFAULT_THEME
252
- };
253
-
254
- const COMPONENT_ID$2 = 'tables.sortable';
255
- const StyledBaseIconWrapper = styled.div.withConfig({
256
- displayName: "StyledSortableButton__StyledBaseIconWrapper",
257
- componentId: "sc-2s1dli-0"
258
- })(["display:flex;position:absolute;top:0;", ":0;align-items:center;justify-content:center;opacity:0;width:", ";height:100%;color:inherit;fill:inherit;"], props => props.theme.rtl ? 'left' : 'right', props => props.theme.iconSizes.sm);
259
- StyledBaseIconWrapper.defaultProps = {
260
- theme: DEFAULT_THEME
261
- };
262
- const StyledSortableStrokeIconWrapper = styled(StyledBaseIconWrapper).withConfig({
263
- displayName: "StyledSortableButton__StyledSortableStrokeIconWrapper",
264
- componentId: "sc-2s1dli-1"
265
- })([""]);
266
- StyledSortableStrokeIconWrapper.defaultProps = {
267
- theme: DEFAULT_THEME
268
- };
269
- const StyledSortableFillIconWrapper = styled(StyledBaseIconWrapper).withConfig({
270
- displayName: "StyledSortableButton__StyledSortableFillIconWrapper",
271
- componentId: "sc-2s1dli-2"
272
- })([""]);
273
- StyledSortableFillIconWrapper.defaultProps = {
274
- theme: DEFAULT_THEME
275
- };
276
- const StyledSortableButton = styled.button.attrs({
277
- 'data-garden-id': COMPONENT_ID$2,
278
- 'data-garden-version': '9.0.0-next.6',
279
- type: 'button'
280
- }).withConfig({
281
- displayName: "StyledSortableButton",
282
- componentId: "sc-2s1dli-3"
283
- })(["position:relative;transition:box-shadow 0.1s ease-in-out;border:none;border-radius:", ";background-color:transparent;cursor:pointer;padding:0;padding-", ":", ";width:", ";text-decoration:none;color:inherit;font-family:inherit;font-size:inherit;font-weight:", ";", "{opacity:", ";}", "{opacity:", ";color:", ";fill:", ";}&:hover,", "{text-decoration:none;color:", ";", ";", " ", "}", " ", ";"], props => props.theme.borderRadii.sm, props => props.theme.rtl ? 'left' : 'right', props => math(`${props.theme.space.base} + ${props.theme.iconSizes.sm}`), props => props.width, props => props.theme.fontWeights.semibold, StyledSortableStrokeIconWrapper, props => props.sort === undefined && 1, StyledSortableFillIconWrapper, props => props.sort !== undefined && 1, props => {
284
- if (props.sort === 'asc') {
285
- return getColorV8('neutralHue', 600, props.theme);
286
- } else if (props.sort === 'desc') {
287
- return getColorV8('neutralHue', 400, props.theme);
288
- }
289
- return undefined;
290
- }, props => {
291
- if (props.sort === 'asc') {
292
- return getColorV8('neutralHue', 400, props.theme);
293
- } else if (props.sort === 'desc') {
294
- return getColorV8('neutralHue', 600, props.theme);
295
- }
296
- return undefined;
297
- }, SELECTOR_FOCUS_VISIBLE, props => getColorV8('primaryHue', 600, props.theme), props => props.sort === undefined && `
298
- ${StyledSortableFillIconWrapper} {
299
- opacity: 1;
300
- color: ${getColorV8('primaryHue', 600, props.theme)};
301
- fill: ${getColorV8('primaryHue', 600, props.theme)};
302
- }
303
-
304
- ${StyledSortableStrokeIconWrapper} {
305
- opacity: 0;
306
- }
307
- `, props => props.sort === 'asc' && `
308
- ${StyledSortableFillIconWrapper} {
309
- color: ${getColorV8('primaryHue', 600, props.theme)};
310
- fill: ${getColorV8('primaryHue', 600, props.theme, 0.25)};
311
- }
312
- `, props => props.sort === 'desc' && `
313
- ${StyledSortableFillIconWrapper} {
314
- color: ${getColorV8('primaryHue', 600, props.theme, 0.25)};
315
- fill: ${getColorV8('primaryHue', 600, props.theme)};
316
- }
317
- `, props => focusStyles({
318
- theme: props.theme
319
- }), props => retrieveComponentStyles(COMPONENT_ID$2, props));
320
- StyledSortableButton.defaultProps = {
321
- theme: DEFAULT_THEME
322
- };
323
-
324
- const COMPONENT_ID$1 = 'tables.header_cell';
325
- const truncatedStyling = css(["", "{max-width:100%;overflow:hidden;text-overflow:ellipsis;}"], StyledSortableButton);
326
- const sizeStyles = props => {
327
- let paddingVertical = undefined;
328
- if (!props.hasOverflow) {
329
- paddingVertical = math(`(${getRowHeight(props)} - ${getLineHeight(props)}) / 2`);
330
- }
331
- return css(["padding-top:", ";padding-bottom:", ";"], paddingVertical, paddingVertical);
332
- };
333
- const StyledHeaderCell = styled(StyledCell).attrs({
334
- as: 'th',
335
- 'data-garden-id': COMPONENT_ID$1,
336
- 'data-garden-version': '9.0.0-next.6'
337
- }).withConfig({
338
- displayName: "StyledHeaderCell",
339
- componentId: "sc-fzagoe-0"
340
- })(["text-align:", ";font-weight:inherit;", " ", " ", ";"], props => {
341
- if (!props.hasOverflow) {
342
- if (props.theme.rtl) {
343
- return 'right';
344
- }
345
- return 'left';
346
- }
347
- return undefined;
348
- }, props => sizeStyles(props), props => props.isTruncated && truncatedStyling, props => retrieveComponentStyles(COMPONENT_ID$1, props));
349
- StyledHeaderCell.defaultProps = {
350
- theme: DEFAULT_THEME
351
- };
352
-
353
- const COMPONENT_ID = 'tables.hidden_cell';
354
- const StyledHiddenCell = styled.div.attrs({
355
- 'data-garden-id': COMPONENT_ID,
356
- 'data-garden-version': '9.0.0-next.6'
357
- }).withConfig({
358
- displayName: "StyledHiddenCell",
359
- componentId: "sc-1x454xw-0"
360
- })(["", " ", ";"], hideVisually(), props => retrieveComponentStyles(COMPONENT_ID, props));
361
- StyledHiddenCell.defaultProps = {
362
- theme: DEFAULT_THEME
363
- };
364
-
365
- const Body = forwardRef((props, ref) => React__default.createElement(StyledBody, _extends$3({
366
- ref: ref
367
- }, props)));
368
- Body.displayName = 'Body';
369
-
370
- const Caption = forwardRef((props, ref) => React__default.createElement(StyledCaption, _extends$3({
371
- ref: ref
372
- }, props)));
373
- Caption.displayName = 'Caption';
374
-
375
- const TableContext = React__default.createContext({
376
- size: 'medium',
377
- isReadOnly: false
378
- });
379
- const useTableContext = () => {
380
- return useContext(TableContext);
381
- };
382
-
383
- const Cell = React__default.forwardRef((_ref, ref) => {
384
- let {
385
- hidden,
386
- ...props
387
- } = _ref;
388
- const {
389
- size
390
- } = useTableContext();
391
- return React__default.createElement(StyledCell, _extends$3({
392
- ref: ref,
393
- size: size
394
- }, props), hidden && props.children ? React__default.createElement(StyledHiddenCell, null, props.children) : props.children);
395
- });
396
- Cell.displayName = 'Cell';
397
- Cell.propTypes = {
398
- isMinimum: PropTypes.bool,
399
- isTruncated: PropTypes.bool,
400
- hasOverflow: PropTypes.bool,
401
- width: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
402
- };
403
-
404
- const GroupRow = forwardRef((props, ref) => {
405
- const {
406
- size
407
- } = useTableContext();
408
- return React__default.createElement(StyledGroupRow, _extends$3({
409
- ref: ref,
410
- size: size
411
- }, props));
412
- });
413
- GroupRow.displayName = 'GroupRow';
414
-
415
- const Head = forwardRef((props, ref) => React__default.createElement(StyledHead, _extends$3({
416
- ref: ref
417
- }, props)));
418
- Head.displayName = 'Head';
419
-
420
- const HeaderCell = forwardRef((_ref, ref) => {
421
- let {
422
- hidden,
423
- ...props
424
- } = _ref;
425
- const {
426
- size
427
- } = useTableContext();
428
- return React__default.createElement(StyledHeaderCell, _extends$3({
429
- ref: ref,
430
- size: size
431
- }, props), hidden && props.children ? React__default.createElement(StyledHiddenCell, null, props.children) : props.children);
432
- });
433
- HeaderCell.displayName = 'HeaderCell';
434
- HeaderCell.propTypes = Cell.propTypes;
435
-
436
- const HeaderRow = React__default.forwardRef((props, ref) => {
437
- const {
438
- size
439
- } = useTableContext();
440
- return React__default.createElement(StyledHeaderRow, _extends$3({
441
- ref: ref,
442
- size: size
443
- }, props));
444
- });
445
- HeaderRow.displayName = 'HeaderRow';
446
-
447
- var _g;
448
- function _extends$2() { _extends$2 = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$2.apply(this, arguments); }
449
- var SvgOverflowStroke = function SvgOverflowStroke(props) {
450
- return /*#__PURE__*/React.createElement("svg", _extends$2({
451
- xmlns: "http://www.w3.org/2000/svg",
452
- width: 16,
453
- height: 16,
454
- focusable: "false",
455
- viewBox: "0 0 16 16",
456
- "aria-hidden": "true"
457
- }, props), _g || (_g = /*#__PURE__*/React.createElement("g", {
458
- fill: "currentColor"
459
- }, /*#__PURE__*/React.createElement("circle", {
460
- cx: 2.5,
461
- cy: 8,
462
- r: 1.5
463
- }), /*#__PURE__*/React.createElement("circle", {
464
- cx: 8,
465
- cy: 8,
466
- r: 1.5
467
- }), /*#__PURE__*/React.createElement("circle", {
468
- cx: 13.5,
469
- cy: 8,
470
- r: 1.5
471
- }))));
472
- };
473
-
474
- const OverflowButton = forwardRef((_ref, ref) => {
475
- let {
476
- onFocus,
477
- onBlur,
478
- isFocused: focused,
479
- ...other
480
- } = _ref;
481
- const [isFocused, setIsFocused] = useState(false);
482
- const {
483
- size
484
- } = useTableContext();
485
- return React__default.createElement(StyledOverflowButton, _extends$3({
486
- onFocus: composeEventHandlers(onFocus, () => {
487
- setIsFocused(true);
488
- }),
489
- onBlur: composeEventHandlers(onBlur, () => {
490
- setIsFocused(false);
491
- }),
492
- size: size,
493
- isFocused: typeof focused === 'undefined' ? isFocused : focused,
494
- ref: ref
495
- }, other), React__default.createElement(StyledOverflowButtonIconWrapper, null, React__default.createElement(SvgOverflowStroke, null)));
496
- });
497
- OverflowButton.displayName = 'OverflowButton';
498
- OverflowButton.propTypes = {
499
- isHovered: PropTypes.bool,
500
- isActive: PropTypes.bool,
501
- isFocused: PropTypes.bool
502
- };
503
-
504
- const Row = forwardRef((_ref, ref) => {
505
- let {
506
- onFocus,
507
- onBlur,
508
- isFocused: focused,
509
- ...otherProps
510
- } = _ref;
511
- const [isFocused, setIsFocused] = useState(false);
512
- const {
513
- size,
514
- isReadOnly
515
- } = useTableContext();
516
- const computedFocused = useMemo(() => {
517
- if (typeof focused !== 'undefined') {
518
- return focused;
519
- }
520
- if (isReadOnly) {
521
- return false;
522
- }
523
- return isFocused;
524
- }, [focused, isFocused, isReadOnly]);
525
- const onFocusCallback = useMemo(() => composeEventHandlers(onFocus, () => {
526
- setIsFocused(true);
527
- }), [onFocus, setIsFocused]);
528
- const onBlurCallback = useMemo(() => composeEventHandlers(onBlur, () => {
529
- setIsFocused(false);
530
- }), [onBlur, setIsFocused]);
531
- return React__default.createElement(StyledRow, _extends$3({
532
- onFocus: onFocusCallback,
533
- onBlur: onBlurCallback,
534
- size: size,
535
- isReadOnly: isReadOnly,
536
- isFocused: computedFocused,
537
- ref: ref
538
- }, otherProps));
539
- });
540
- Row.displayName = 'Row';
541
- Row.propTypes = {
542
- isStriped: PropTypes.bool,
543
- isFocused: PropTypes.bool,
544
- isHovered: PropTypes.bool,
545
- isSelected: PropTypes.bool
546
- };
547
-
548
- var _path$1;
549
- function _extends$1() { _extends$1 = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$1.apply(this, arguments); }
550
- var SvgSortStroke = function SvgSortStroke(props) {
551
- return /*#__PURE__*/React.createElement("svg", _extends$1({
552
- xmlns: "http://www.w3.org/2000/svg",
553
- width: 12,
554
- height: 12,
555
- focusable: "false",
556
- viewBox: "0 0 12 12",
557
- "aria-hidden": "true"
558
- }, props), _path$1 || (_path$1 = /*#__PURE__*/React.createElement("path", {
559
- fill: "none",
560
- stroke: "currentColor",
561
- strokeLinecap: "round",
562
- d: "M2.5 4L5.6.9c.2-.2.5-.2.7 0L9.5 4m-7 4l3.1 3.1c.2.2.5.2.7 0L9.5 8"
563
- })));
564
- };
565
-
566
- var _path, _path2;
567
- function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
568
- var SvgSortFill = function SvgSortFill(props) {
569
- return /*#__PURE__*/React.createElement("svg", _extends({
570
- xmlns: "http://www.w3.org/2000/svg",
571
- width: 12,
572
- height: 12,
573
- focusable: "false",
574
- viewBox: "0 0 12 12",
575
- "aria-hidden": "true"
576
- }, props), _path || (_path = /*#__PURE__*/React.createElement("path", {
577
- fill: "currentColor",
578
- d: "M10 5H2a.5.5 0 01-.46-.31.47.47 0 01.11-.54L5.29.5A1 1 0 016.7.5l3.65 3.65a.49.49 0 01.11.54A.51.51 0 0110 5z"
579
- })), _path2 || (_path2 = /*#__PURE__*/React.createElement("path", {
580
- d: "M2 7a.5.5 0 00-.46.31.47.47 0 00.11.54L5.3 11.5a1 1 0 001.41 0l3.65-3.65a.49.49 0 00.11-.54A.53.53 0 0010 7z"
581
- })));
582
- };
583
-
584
- const SIZE = ['small', 'medium', 'large'];
585
- const SORT = ['asc', 'desc'];
586
-
587
- const SortableCell = forwardRef((_ref, ref) => {
588
- let {
589
- sort,
590
- cellProps,
591
- width,
592
- children,
593
- ...otherProps
594
- } = _ref;
595
- let ariaSortValue = 'none';
596
- if (sort === 'asc') {
597
- ariaSortValue = 'ascending';
598
- } else if (sort === 'desc') {
599
- ariaSortValue = 'descending';
600
- }
601
- const SortIcon = sort === undefined ? SvgSortStroke : SvgSortFill;
602
- return React__default.createElement(StyledHeaderCell, _extends$3({
603
- "aria-sort": ariaSortValue,
604
- width: width
605
- }, cellProps), React__default.createElement(StyledSortableButton, _extends$3({
606
- sort: sort,
607
- ref: ref
608
- }, otherProps), children, React__default.createElement(StyledSortableStrokeIconWrapper, null, React__default.createElement(SortIcon, null)), React__default.createElement(StyledSortableFillIconWrapper, null, React__default.createElement(SvgSortFill, null))));
609
- });
610
- SortableCell.displayName = 'SortableCell';
611
- SortableCell.propTypes = {
612
- sort: PropTypes.oneOf(SORT),
613
- cellProps: PropTypes.any,
614
- width: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
615
- };
616
-
617
- const TableComponent = React__default.forwardRef((props, ref) => {
618
- const tableContextValue = useMemo(() => ({
619
- size: props.size,
620
- isReadOnly: props.isReadOnly
621
- }), [props.size, props.isReadOnly]);
622
- return React__default.createElement(TableContext.Provider, {
623
- value: tableContextValue
624
- }, React__default.createElement(StyledTable, _extends$3({
625
- ref: ref
626
- }, props)));
627
- });
628
- TableComponent.displayName = 'Table';
629
- TableComponent.defaultProps = {
630
- size: 'medium'
631
- };
632
- TableComponent.propTypes = {
633
- size: PropTypes.oneOf(SIZE),
634
- isReadOnly: PropTypes.bool
635
- };
636
- const Table = TableComponent;
637
- Table.Body = Body;
638
- Table.Caption = Caption;
639
- Table.Cell = Cell;
640
- Table.GroupRow = GroupRow;
641
- Table.Head = Head;
642
- Table.HeaderCell = HeaderCell;
643
- Table.HeaderRow = HeaderRow;
644
- Table.OverflowButton = OverflowButton;
645
- Table.Row = Row;
646
- Table.SortableCell = SortableCell;
647
-
648
- export { Body, Caption, Cell, GroupRow, Head, HeaderCell, HeaderRow, OverflowButton, Row, SortableCell, Table };