@atlaskit/dynamic-table 14.6.0 → 14.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @atlaskit/dynamic-table
2
2
 
3
+ ## 14.6.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`deca22d60e1`](https://bitbucket.org/atlassian/atlassian-frontend/commits/deca22d60e1) - Update DynamicTable HeaderCellType to make it clear that the width prop takes a percentage not a pixel value
8
+
3
9
  ## 14.6.0
4
10
 
5
11
  ### Minor Changes
@@ -52,7 +52,7 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
52
52
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
53
53
 
54
54
  var packageName = "@atlaskit/dynamic-table";
55
- var packageVersion = "14.6.0";
55
+ var packageVersion = "14.6.1";
56
56
 
57
57
  function toggleSortOrder(currentSortOrder) {
58
58
  switch (currentSortOrder) {
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/dynamic-table",
3
- "version": "14.6.0",
3
+ "version": "14.6.1",
4
4
  "sideEffects": false
5
5
  }
@@ -1,4 +1,6 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+
3
+ /* eslint-disable @repo/internal/dom-events/no-unsafe-event-listeners */
2
4
  import React from 'react';
3
5
  import { findDOMNode } from 'react-dom';
4
6
  import Spinner from '@atlaskit/spinner';
@@ -13,7 +13,7 @@ import ManagedPagination from './managed-pagination';
13
13
  import RankableTableBody from './rankable/Body';
14
14
  import TableHead from './TableHead';
15
15
  const packageName = "@atlaskit/dynamic-table";
16
- const packageVersion = "14.6.0";
16
+ const packageVersion = "14.6.1";
17
17
 
18
18
  function toggleSortOrder(currentSortOrder) {
19
19
  switch (currentSortOrder) {
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/dynamic-table",
3
- "version": "14.6.0",
3
+ "version": "14.6.1",
4
4
  "sideEffects": false
5
5
  }
@@ -11,6 +11,7 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
11
11
 
12
12
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
13
13
 
14
+ /* eslint-disable @repo/internal/dom-events/no-unsafe-event-listeners */
14
15
  import React from 'react';
15
16
  import { findDOMNode } from 'react-dom';
16
17
  import Spinner from '@atlaskit/spinner';
@@ -24,7 +24,7 @@ import ManagedPagination from './managed-pagination';
24
24
  import RankableTableBody from './rankable/Body';
25
25
  import TableHead from './TableHead';
26
26
  var packageName = "@atlaskit/dynamic-table";
27
- var packageVersion = "14.6.0";
27
+ var packageVersion = "14.6.1";
28
28
 
29
29
  function toggleSortOrder(currentSortOrder) {
30
30
  switch (currentSortOrder) {
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/dynamic-table",
3
- "version": "14.6.0",
3
+ "version": "14.6.1",
4
4
  "sideEffects": false
5
5
  }
@@ -317,7 +317,7 @@ export declare type LoadingSpinnerSizeType = 'small' | 'large';
317
317
  export interface HeadCellType extends RowCellType {
318
318
  /** Whether the column the cell sits above is sortable. */
319
319
  isSortable?: boolean;
320
- /** The pixel width of the cell. */
320
+ /** The width of the cell as a percentage. */
321
321
  width?: number;
322
322
  /** Whether the text in the cell will truncate or not if constrained. */
323
323
  shouldTruncate?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/dynamic-table",
3
- "version": "14.6.0",
3
+ "version": "14.6.1",
4
4
  "description": "A dynamic table displays rows of data with built-in pagination, sorting, and re-ordering functionality.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -20,7 +20,8 @@
20
20
  "deprecatedAutoEntryPoints": true,
21
21
  "releaseModel": "scheduled",
22
22
  "website": {
23
- "name": "Dynamic table"
23
+ "name": "Dynamic table",
24
+ "category": "Components"
24
25
  }
25
26
  },
26
27
  "dependencies": {
@@ -60,6 +61,7 @@
60
61
  "import-structure": "atlassian-conventions"
61
62
  },
62
63
  "@repo/internal": {
64
+ "dom-events": "use-bind-event-listener",
63
65
  "theming": "tokens",
64
66
  "deprecation": "no-deprecated-imports",
65
67
  "styling": [
package/report.api.md ADDED
@@ -0,0 +1,508 @@
1
+ ## API Report File for "@atlaskit/dynamic-table"
2
+
3
+ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
4
+
5
+ ````ts
6
+ import { default as React_2 } from 'react';
7
+ import { Ref } from 'react';
8
+ import { UIAnalyticsEvent } from '@atlaskit/analytics-next';
9
+ import { WithAnalyticsEventsProps } from '@atlaskit/analytics-next';
10
+ import { WithContextProps } from '@atlaskit/analytics-next';
11
+
12
+ /**
13
+ * __Dynamic Table__
14
+ *
15
+ * A table displays rows of data with built-in pagination, sorting, and re-ordering functionality.
16
+ *
17
+ * - [Examples](https://atlaskit.atlassian.com/packages/design-system/dynamic-table)
18
+ * - [Code](https://bitbucket.org/atlassian/atlassian-frontend/packages/design-system/dynamic-table)
19
+ *
20
+ * @example
21
+ * ```jsx
22
+ * import DynamicTable from '@atlaskit/dynamic-table';
23
+ *
24
+ * export default function TableUncontrolled() {
25
+ * return (
26
+ * <DynamicTable
27
+ * head={head}
28
+ * rows={rows}
29
+ * rowsPerPage={10}
30
+ * defaultPage={1}
31
+ * loadingSpinnerSize="large"
32
+ * isLoading={false}
33
+ * />
34
+ * );
35
+ * }
36
+ * ```
37
+ */
38
+ declare class DynamicTable extends React_2.Component<StatefulProps, State> {
39
+ static defaultProps: {
40
+ defaultPage: number;
41
+ isLoading: boolean;
42
+ isFixedSize: boolean;
43
+ isRankable: boolean;
44
+ onSetPage: () => void;
45
+ onSort: () => void;
46
+ rowsPerPage: number;
47
+ };
48
+ state: {
49
+ page: number | undefined;
50
+ sortKey: string | undefined;
51
+ sortOrder: SortOrderType | undefined;
52
+ rows: RowType[] | undefined;
53
+ };
54
+ UNSAFE_componentWillReceiveProps(newProps: StatefulProps): void;
55
+ onSetPage: (
56
+ page: number,
57
+ analyticsEvent?: UIAnalyticsEvent | undefined,
58
+ ) => void;
59
+ onSort: (
60
+ { key, item, sortOrder }: any,
61
+ analyticsEvent?: UIAnalyticsEvent | undefined,
62
+ ) => void;
63
+ onRankEndIfExists: (params: RankEnd) => void;
64
+ onRankEnd: (params: RankEnd) => void;
65
+ render(): JSX.Element;
66
+ }
67
+ export default DynamicTable;
68
+
69
+ export declare const DynamicTableStateless: React_2.ForwardRefExoticComponent<
70
+ Pick<
71
+ Pick<
72
+ Omit<StatelessProps, keyof WithAnalyticsEventsProps>,
73
+ | 'caption'
74
+ | 'head'
75
+ | 'label'
76
+ | 'rows'
77
+ | 'sortKey'
78
+ | 'sortOrder'
79
+ | 'onPageRowsUpdate'
80
+ | 'testId'
81
+ | 'highlightedRowIndex'
82
+ | 'emptyView'
83
+ | 'loadingSpinnerSize'
84
+ | 'totalRows'
85
+ > &
86
+ Partial<
87
+ Pick<
88
+ Omit<StatelessProps, keyof WithAnalyticsEventsProps>,
89
+ | 'isFixedSize'
90
+ | 'page'
91
+ | 'rowsPerPage'
92
+ | 'isLoading'
93
+ | 'isRankingDisabled'
94
+ | 'onRankStart'
95
+ | 'onRankEnd'
96
+ | 'onSort'
97
+ | 'isRankable'
98
+ | 'onSetPage'
99
+ | 'paginationi18n'
100
+ >
101
+ > &
102
+ Partial<
103
+ Pick<
104
+ {
105
+ isLoading: boolean;
106
+ isFixedSize: boolean;
107
+ rowsPerPage: number;
108
+ onSetPage: () => void;
109
+ onSort: () => void;
110
+ page: number;
111
+ isRankable: boolean;
112
+ isRankingDisabled: boolean;
113
+ onRankStart: () => void;
114
+ onRankEnd: () => void;
115
+ paginationi18n: {
116
+ prev: string;
117
+ next: string;
118
+ label: string;
119
+ };
120
+ },
121
+ never
122
+ >
123
+ > &
124
+ React_2.RefAttributes<any> &
125
+ WithContextProps,
126
+ | 'caption'
127
+ | 'head'
128
+ | 'label'
129
+ | 'key'
130
+ | 'isFixedSize'
131
+ | 'rows'
132
+ | 'page'
133
+ | 'rowsPerPage'
134
+ | 'sortKey'
135
+ | 'sortOrder'
136
+ | 'onPageRowsUpdate'
137
+ | 'testId'
138
+ | 'highlightedRowIndex'
139
+ | 'isLoading'
140
+ | 'isRankingDisabled'
141
+ | 'onRankStart'
142
+ | 'onRankEnd'
143
+ | 'onSort'
144
+ | 'isRankable'
145
+ | 'emptyView'
146
+ | 'loadingSpinnerSize'
147
+ | 'totalRows'
148
+ | 'onSetPage'
149
+ | 'paginationi18n'
150
+ | 'analyticsContext'
151
+ > &
152
+ React_2.RefAttributes<any>
153
+ >;
154
+
155
+ declare interface HeadCellType extends RowCellType {
156
+ /** Whether the column the cell sits above is sortable. */
157
+ isSortable?: boolean;
158
+ /** The pixel width of the cell. */
159
+ width?: number;
160
+ /** Whether the text in the cell will truncate or not if constrained. */
161
+ shouldTruncate?: boolean;
162
+ }
163
+
164
+ declare interface HeadType {
165
+ cells: Array<HeadCellType>;
166
+ }
167
+
168
+ declare interface I18nShape {
169
+ /**
170
+ * Accessible label applied to the previous page button in the pagination component.
171
+ */
172
+ prev: string;
173
+ /**
174
+ * Accessible label applied to the next page button in the pagination component.
175
+ */
176
+ next: string;
177
+ /**
178
+ * Accessible label applied to the current page button in the pagination component.
179
+ */
180
+ label: string;
181
+ }
182
+
183
+ declare type LoadingSpinnerSizeType = 'small' | 'large';
184
+
185
+ declare interface RankEnd {
186
+ sourceIndex: number;
187
+ sourceKey: string;
188
+ destination?: RankEndLocation;
189
+ }
190
+
191
+ declare interface RankEndLocation {
192
+ index: number;
193
+ afterKey?: string;
194
+ beforeKey?: string;
195
+ }
196
+
197
+ declare interface RankStart {
198
+ index: number;
199
+ key: string;
200
+ }
201
+
202
+ declare interface RowCellType {
203
+ /**
204
+ * Key to resolve sorting this cell in its column.
205
+ */
206
+ key?: string | number;
207
+ /**
208
+ * The number of columns a cell should span. Defaults to 1, and maxes out at the total column width of the table.
209
+ */
210
+ colSpan?: number;
211
+ /**
212
+ * The content of the cell.
213
+ */
214
+ content?: React_2.ReactNode | string;
215
+ /**
216
+ * Hook for automated testing.
217
+ */
218
+ testId?: string;
219
+ }
220
+
221
+ declare interface RowType extends React_2.ComponentPropsWithoutRef<'tr'> {
222
+ cells: Array<RowCellType>;
223
+ key?: string;
224
+ /**
225
+ * A mouse handler to support interaction of a row.
226
+ */
227
+ onClick?: React_2.MouseEventHandler;
228
+ /**
229
+ * A key event handler to support interaction of a row.
230
+ */
231
+ onKeyPress?: React_2.KeyboardEventHandler;
232
+ /**
233
+ * Highlights the row. Should be used to draw attention to a row; not to indicate selection.
234
+ */
235
+ isHighlighted?: boolean;
236
+ /**
237
+ * Hook for automated testing.
238
+ */
239
+ testId?: string;
240
+ ref?: Ref<HTMLTableRowElement>;
241
+ }
242
+
243
+ /**
244
+ * Enum style type to determine whether sort results are ascending or descending.
245
+ */
246
+ declare type SortOrderType = 'ASC' | 'DESC';
247
+
248
+ declare interface State {
249
+ page?: number;
250
+ sortKey?: string;
251
+ sortOrder?: SortOrderType;
252
+ rows?: RowType[];
253
+ }
254
+
255
+ declare interface StatefulProps extends WithAnalyticsEventsProps {
256
+ /**
257
+ * Caption for the table styled as a heading.
258
+ */
259
+ caption?: React_2.ReactNode;
260
+ /**
261
+ * Cells to be placed in the head of the table.
262
+ * Each element in the head creates a new column.
263
+ */
264
+ head?: HeadType;
265
+ /**
266
+ * Rows to be placed in the table.
267
+ * Each row contains cells which should map to the ones defined in the head.
268
+ * Rows accept standard HTML <tr> props in addition to those listed below.
269
+
270
+ * Ensure each cell has a unique `key` per column - this is used for both React's reconciliation of lists and column sorting.
271
+ */
272
+ rows?: Array<RowType>;
273
+ /**
274
+ * Shown when the table has no content.
275
+ */
276
+ emptyView?: React_2.ReactElement<any>;
277
+ /**
278
+ * Configuration of the loading spinner shown when `isLoading` is true.
279
+ * Defaults to `"large"` when a page has more than two rows, else `"small"`.
280
+ */
281
+ loadingSpinnerSize?: LoadingSpinnerSizeType;
282
+ /**
283
+ * Displays a loading spinner overlaid on top of the current page.
284
+ */
285
+ isLoading?: boolean;
286
+ /**
287
+ * Displays columns as their initial width regardless of the content that loads in.
288
+ */
289
+ isFixedSize?: boolean;
290
+ /**
291
+ * Controls how many rows should be diplayed per page.
292
+ */
293
+ rowsPerPage?: number;
294
+ /**
295
+ * Callback fired when the table page has changed,
296
+ * useful when wanting to control dynamic table.
297
+ */
298
+ onSetPage?: (page: number, UIAnalyticsEvent?: UIAnalyticsEvent) => void;
299
+ /**
300
+ * Callback fired when a column heading has been sorted,
301
+ * useful when wanting to control dynamic table.
302
+ */
303
+ onSort?: (data: any, UIAnalyticsEvent?: UIAnalyticsEvent) => void;
304
+ /**
305
+ * Callback fired when the rows displayed on a page have changed.
306
+ */
307
+ onPageRowsUpdate?: (pageRows: Array<RowType>) => void;
308
+ /**
309
+ * Page the table should show.
310
+ * Useful when wanting to control dynamic table.
311
+ */
312
+ page?: number;
313
+ /**
314
+ * Default page dynamic table should show when initially rendering.
315
+ */
316
+ defaultPage?: number;
317
+ /**
318
+ * Column key that the rows should be sorted by.
319
+ * Corresponds to the `key`'s defined in the `head` prop.
320
+ * Useful when wanting to control dynamic table.
321
+ */
322
+ sortKey?: string;
323
+ /**
324
+ * Default column sort key that the rows should be sorted by.
325
+ * Corresponds to the `key`'s defined in the `head` prop.
326
+ */
327
+ defaultSortKey?: string;
328
+ /**
329
+ * Column sort order.
330
+ * Useful when wanting to control dynamic table.
331
+ */
332
+ sortOrder?: SortOrderType;
333
+ /**
334
+ * Default column sort order used when initially rendering.
335
+ * Defaults to `"ASC"`.
336
+ */
337
+ defaultSortOrder?: SortOrderType;
338
+ /**
339
+ * Enables drag & drop sorting of table rows.
340
+ */
341
+ isRankable?: boolean;
342
+ /**
343
+ * Disables being able to drop rows on the table.
344
+ * Drag will still function.
345
+ */
346
+ isRankingDisabled?: boolean;
347
+ /**
348
+ * Callback fired when a drag of a row has started.
349
+ */
350
+ onRankStart?: (rankStart: RankStart) => void;
351
+ /**
352
+ * Callback fired when a drop of a row has completed.
353
+ */
354
+ onRankEnd?: (rankEnd: RankEnd) => void;
355
+ /**
356
+ * Labels for the previous and next buttons used in pagination.
357
+ * Defaults to `"previous"` and `"next"`.
358
+ */
359
+ paginationi18n?: I18nShape;
360
+ /**
361
+ * Will highlight a row(s) of the table.
362
+ */
363
+ highlightedRowIndex?: number | number[];
364
+ /**
365
+ A `testId` prop is provided for specified elements,
366
+ which is a unique string that appears as a data attribute
367
+ `data-testid` in the rendered code, serving as a hook for automated tests.
368
+
369
+ The value of `testId` is used to prefix `testId` props in given elements.
370
+ - `{testId}--table` - Table.
371
+ - `{testId}--head` - Table header.
372
+ - `{testId}--head--{content of the cell}` - Table header cell can be identified by their content.
373
+ - `{testId}--row--{index - content of the first cell}` - Table row.
374
+ - `{testId}--body` - Table body.
375
+ - `{testId}--body--{content of the cell}` - Table body cell can be identified by their content.
376
+ - `{testId}--loadingSpinner` - The spinner overlaid when loading.
377
+ - `{testId}--pagination` - The table pagination.
378
+ */
379
+ testId?: string;
380
+ /**
381
+ * Used to provide a better description of the table for users with assistive technologies.
382
+ * Rather than a screen reader speaking "Entering table", passing in an label
383
+ * allows a custom message like "Entering Sample Numerical Data table".
384
+ */
385
+ label?: string;
386
+ }
387
+
388
+ declare interface StatelessProps extends WithAnalyticsEventsProps {
389
+ /**
390
+ * Caption for the table styled as a heading.
391
+ */
392
+ caption?: React_2.ReactNode;
393
+ /**
394
+ * Cells to be placed in the head of the table.
395
+ * Each element in the head creates a new column.
396
+ */
397
+ head?: HeadType;
398
+ /**
399
+ * Rows to be placed in the table.
400
+ * Each row contains cells which should map to the ones defined in the head.
401
+
402
+ * Ensure each cell has a unique `key` per column - this is used for both Reacts reconcilation of lists and column sorting.
403
+ */
404
+ rows?: Array<RowType>;
405
+ /**
406
+ * Shown when the table has no content.
407
+ */
408
+ emptyView?: React_2.ReactElement<any>;
409
+ /**
410
+ * Configuration of the loading spinner shown when `isLoading` is true.
411
+ * Defaults to `"large"` when a page has more than two rows, else `"small"`.
412
+ */
413
+ loadingSpinnerSize?: LoadingSpinnerSizeType;
414
+ /**
415
+ * Displays a loading spinner overlaid on top of the current page.
416
+ */
417
+ isLoading?: boolean;
418
+ /**
419
+ * Displays columns as their initial width regardless of the content that loads in.
420
+ */
421
+ isFixedSize?: boolean;
422
+ /**
423
+ * Controls how many rows should be displayed per page.
424
+ */
425
+ rowsPerPage?: number;
426
+ /**
427
+ * Total number of rows, in case of paginated data.
428
+ */
429
+ totalRows?: number;
430
+ /**
431
+ * Callback fired when the table page has changed,
432
+ * useful when wanting to control the pagination of the table.
433
+ */
434
+ onSetPage?: (page: number, UIAnalyticsEvent?: UIAnalyticsEvent) => void;
435
+ /**
436
+ * Callback fired when a column heading has been sorted,
437
+ * useful when wanting to control the sort order of the table.
438
+ */
439
+ onSort?: (data: any, UIAnalyticsEvent?: UIAnalyticsEvent) => void;
440
+ /**
441
+ * Callback fired when the rows displayed on a page have changed.
442
+ */
443
+ onPageRowsUpdate?: (pageRows: Array<RowType>) => void;
444
+ /**
445
+ * Page the table should show.
446
+ */
447
+ page?: number;
448
+ /**
449
+ * Column key that the rows should be sorted by.
450
+ * Corresponds to the `key`'s defined in the `head` prop.
451
+ */
452
+ sortKey?: string;
453
+ /**
454
+ * Column sort order.
455
+ */
456
+ sortOrder?: SortOrderType;
457
+ /**
458
+ * Enables drag & drop sorting of table rows.
459
+ */
460
+ isRankable?: boolean;
461
+ /**
462
+ * Disables being able to drop rows on the table.
463
+ * Drag will still function.
464
+ */
465
+ isRankingDisabled?: boolean;
466
+ /**
467
+ * Callback fired when a drag of a row has started.
468
+ */
469
+ onRankStart?: (rankStart: RankStart) => void;
470
+ /**
471
+ * Callback fired when a drop of a row has completed.
472
+ */
473
+ onRankEnd?: (rankEnd: RankEnd, uiAnalyticsEvent?: UIAnalyticsEvent) => void;
474
+ /**
475
+ * Labels for the pagination wrapper, previous and next buttons used in pagination.
476
+ * Defaults to `"pagination"`, `"previous"` and `"next"`.
477
+ */
478
+ paginationi18n?: I18nShape;
479
+ /**
480
+ * Will highlight a row(s) of the table. Should be used to draw attention to a row; not to indicate selection.
481
+ */
482
+ highlightedRowIndex?: number | number[];
483
+ /**
484
+ A `testId` prop is provided for specified elements,
485
+ which is a unique string that appears as a data attribute
486
+ `data-testid` in the rendered code, serving as a hook for automated tests.
487
+
488
+ The value of `testId` is used to prefix `testId` props in given elements.
489
+ - `{testId}--table` - Table.
490
+ - `{testId}--head` - Table header.
491
+ - `{testId}--head--{content of the cell}` - Table header cell can be identified by their content.
492
+ - `{testId}--row--{index - content of the first cell}` - Table row.
493
+ - `{testId}--body` - Table body.
494
+ - `{testId}--body--{content of the cell}` - Table body cell can be identified by their content.
495
+ - `{testId}--loadingSpinner` - The spinner overlaid when loading.
496
+ - `{testId}--pagination` - The table pagination.
497
+ */
498
+ testId?: string;
499
+ /**
500
+ * Used to provide a better description of the table for users with assistive technologies.
501
+ * Rather than a screen reader speaking "Entering table", passing in an label
502
+ * allows a custom message like "Entering Sample Numerical Data table".
503
+ */
504
+ label?: string;
505
+ }
506
+
507
+ export {};
508
+ ````