@atlaskit/media-table 14.1.2 → 14.1.4

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.
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
@@ -41,11 +40,7 @@ Object.defineProperty(exports, "getValidTableProps", {
41
40
  return _getValidTableProps.default;
42
41
  }
43
42
  });
44
-
45
43
  var _generateRowValues = _interopRequireDefault(require("./generateRowValues"));
46
-
47
44
  var _getValidTableProps = _interopRequireDefault(require("./getValidTableProps"));
48
-
49
45
  var _generateHeadValues = _interopRequireDefault(require("./generateHeadValues"));
50
-
51
46
  var _constants = require("./constants");
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/media-table",
3
- "version": "14.1.2",
3
+ "version": "14.1.4",
4
4
  "sideEffects": false
5
5
  }
@@ -1,14 +1,13 @@
1
- import { token } from '@atlaskit/tokens';
2
- import React from 'react'; // eslint-disable-next-line import/no-extraneous-dependencies
3
-
1
+ import React from 'react';
2
+ // eslint-disable-next-line import/no-extraneous-dependencies
4
3
  import { injectIntl } from 'react-intl-next';
5
4
  import { N40 } from '@atlaskit/theme/colors';
6
5
  import DownloadIcon from '@atlaskit/icon/glyph/download';
7
6
  import Button from '@atlaskit/button/custom-theme-button';
8
- import { messages } from '@atlaskit/media-ui'; // eslint-disable-next-line import/no-extraneous-dependencies
7
+ import { messages } from '@atlaskit/media-ui';
8
+ // eslint-disable-next-line import/no-extraneous-dependencies
9
9
 
10
10
  import { ANALYTICS_MEDIA_CHANNEL } from '../util';
11
-
12
11
  const MediaDownloadButton = props => {
13
12
  const {
14
13
  onClick,
@@ -24,22 +23,23 @@ const MediaDownloadButton = props => {
24
23
  }),
25
24
  onKeyPress: event => event.stopPropagation(),
26
25
  onClick: (event, analyticsEvent) => {
27
- analyticsEvent.update(payload => ({ ...payload,
26
+ analyticsEvent.update(payload => ({
27
+ ...payload,
28
28
  eventType: 'ui',
29
29
  actionSubjectId: 'mediaTableDownload'
30
30
  })).fire(ANALYTICS_MEDIA_CHANNEL);
31
31
  onClick(event);
32
32
  },
33
33
  theme: (current, themeProps) => ({
34
- buttonStyles: { ...current(themeProps).buttonStyles,
34
+ buttonStyles: {
35
+ ...current(themeProps).buttonStyles,
35
36
  minWidth: 'max-content',
36
37
  '&:hover': {
37
- background: token('color.background.neutral.hovered', N40)
38
+ background: `var(--ds-background-neutral-hovered, ${N40})`
38
39
  }
39
40
  },
40
41
  spinnerStyles: current(themeProps).spinnerStyles
41
42
  })
42
43
  });
43
44
  };
44
-
45
45
  export default injectIntl(MediaDownloadButton);
@@ -1,10 +1,9 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
-
3
2
  /**@jsx jsx */
4
3
  import { jsx } from '@emotion/react';
5
4
  import React, { Component } from 'react';
6
- import ReactDOM from 'react-dom'; // eslint-disable-next-line import/no-extraneous-dependencies
7
-
5
+ import ReactDOM from 'react-dom';
6
+ // eslint-disable-next-line import/no-extraneous-dependencies
8
7
  import { IntlProvider, injectIntl } from 'react-intl-next';
9
8
  import { DynamicTableStateless } from '@atlaskit/dynamic-table';
10
9
  import { isFileIdentifier, withMediaClient, isProcessedFileState } from '@atlaskit/media-client';
@@ -17,20 +16,15 @@ import { withAnalyticsEvents } from '@atlaskit/analytics-next';
17
16
  export class MediaTable extends Component {
18
17
  constructor(...args) {
19
18
  super(...args);
20
-
21
19
  _defineProperty(this, "state", {
22
20
  fileInfoState: new Map()
23
21
  });
24
-
25
22
  _defineProperty(this, "subscriptions", []);
26
-
27
23
  _defineProperty(this, "hasBeenMounted", false);
28
-
29
24
  _defineProperty(this, "unsubscribe", () => {
30
25
  this.subscriptions.forEach(subscription => subscription.unsubscribe());
31
26
  this.subscriptions = [];
32
27
  });
33
-
34
28
  _defineProperty(this, "generateCellValues", (data, identifier) => {
35
29
  const cellValues = [];
36
30
  const {
@@ -49,7 +43,6 @@ export class MediaTable extends Component {
49
43
  });
50
44
  return cellValues;
51
45
  });
52
-
53
46
  _defineProperty(this, "onDownloadClick", identifier => event => {
54
47
  const {
55
48
  id,
@@ -65,12 +58,10 @@ export class MediaTable extends Component {
65
58
  const nameInfo = fileInfoState.get(id);
66
59
  mediaClient.file.downloadBinary(id, nameInfo ? nameInfo.fileName : '', collectionName);
67
60
  });
68
-
69
61
  _defineProperty(this, "onPreviewClick", identifier => event => {
70
62
  event.stopPropagation();
71
63
  this.openPreview(identifier);
72
64
  });
73
-
74
65
  _defineProperty(this, "onSort", data => {
75
66
  const {
76
67
  onSort
@@ -82,7 +73,6 @@ export class MediaTable extends Component {
82
73
  } = data;
83
74
  item && item.isSortable && onSort && onSort(key, sortOrder);
84
75
  });
85
-
86
76
  _defineProperty(this, "renderRowValues", (validItemsPerPage, validPageNumber, validTotalItems) => {
87
77
  const {
88
78
  items,
@@ -115,7 +105,6 @@ export class MediaTable extends Component {
115
105
  headerCells: columns.cells
116
106
  });
117
107
  });
118
-
119
108
  _defineProperty(this, "renderTable", () => {
120
109
  const {
121
110
  columns,
@@ -151,7 +140,6 @@ export class MediaTable extends Component {
151
140
  highlightedRowIndex: highlightedRowIndex
152
141
  });
153
142
  });
154
-
155
143
  _defineProperty(this, "openPreview", identifier => {
156
144
  const {
157
145
  onPreviewOpen
@@ -161,7 +149,6 @@ export class MediaTable extends Component {
161
149
  });
162
150
  onPreviewOpen && onPreviewOpen();
163
151
  });
164
-
165
152
  _defineProperty(this, "onRowEnterKeyPressed", (identifier, data, index) => {
166
153
  const {
167
154
  createAnalyticsEvent,
@@ -175,12 +162,10 @@ export class MediaTable extends Component {
175
162
  });
176
163
  ev.fire(ANALYTICS_MEDIA_CHANNEL);
177
164
  const shouldPreventDefaultRowClick = onRowClick === null || onRowClick === void 0 ? void 0 : onRowClick(data, index);
178
-
179
165
  if (!shouldPreventDefaultRowClick) {
180
166
  this.openPreview(identifier);
181
167
  }
182
168
  });
183
-
184
169
  _defineProperty(this, "onRowClick", (identifier, data, index) => () => {
185
170
  const {
186
171
  createAnalyticsEvent,
@@ -194,18 +179,15 @@ export class MediaTable extends Component {
194
179
  });
195
180
  ev.fire(ANALYTICS_MEDIA_CHANNEL);
196
181
  const shouldPreventDefaultRowClick = onRowClick === null || onRowClick === void 0 ? void 0 : onRowClick(data, index);
197
-
198
182
  if (!shouldPreventDefaultRowClick) {
199
183
  this.openPreview(identifier);
200
184
  }
201
185
  });
202
-
203
186
  _defineProperty(this, "safeSetState", state => {
204
187
  if (this.hasBeenMounted) {
205
188
  this.setState(state);
206
189
  }
207
190
  });
208
-
209
191
  _defineProperty(this, "onMediaViewerClose", () => {
210
192
  const {
211
193
  onPreviewClose
@@ -215,7 +197,6 @@ export class MediaTable extends Component {
215
197
  });
216
198
  onPreviewClose && onPreviewClose();
217
199
  });
218
-
219
200
  _defineProperty(this, "renderMediaViewer", () => {
220
201
  const {
221
202
  mediaViewerSelectedItem
@@ -224,11 +205,9 @@ export class MediaTable extends Component {
224
205
  mediaClient,
225
206
  items
226
207
  } = this.props;
227
-
228
208
  if (!mediaViewerSelectedItem) {
229
209
  return null;
230
210
  }
231
-
232
211
  const dataSource = {
233
212
  list: items.map(item => item.identifier)
234
213
  };
@@ -242,7 +221,6 @@ export class MediaTable extends Component {
242
221
  }), document.body);
243
222
  });
244
223
  }
245
-
246
224
  componentDidMount() {
247
225
  this.hasBeenMounted = true;
248
226
  const {
@@ -263,13 +241,11 @@ export class MediaTable extends Component {
263
241
  const {
264
242
  fileInfoState
265
243
  } = this.state;
266
-
267
244
  if (isProcessedFileState(fileState)) {
268
245
  fileInfoState.set(id, {
269
246
  fileName: fileState.name,
270
247
  id
271
248
  });
272
-
273
249
  if (this.hasBeenMounted) {
274
250
  this.safeSetState({
275
251
  fileInfoState
@@ -281,12 +257,10 @@ export class MediaTable extends Component {
281
257
  this.subscriptions.push(subscription);
282
258
  });
283
259
  }
284
-
285
260
  componentWillUnmount() {
286
261
  this.hasBeenMounted = false;
287
262
  this.unsubscribe();
288
263
  }
289
-
290
264
  render() {
291
265
  const content = jsx("div", {
292
266
  css: mediaTableWrapperStyles
@@ -295,7 +269,6 @@ export class MediaTable extends Component {
295
269
  locale: "en"
296
270
  }, content);
297
271
  }
298
-
299
272
  }
300
273
  export default withMediaClient(withAnalyticsEvents()(injectIntl(MediaTable, {
301
274
  enforceContext: false
@@ -1,5 +1,4 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
-
3
2
  /**@jsx jsx */
4
3
  import { jsx } from '@emotion/react';
5
4
  import Tooltip from '@atlaskit/tooltip';
@@ -1,12 +1,12 @@
1
- import React from 'react'; // eslint-disable-next-line import/no-extraneous-dependencies
2
-
1
+ import React from 'react';
2
+ // eslint-disable-next-line import/no-extraneous-dependencies
3
3
  import { injectIntl } from 'react-intl-next';
4
4
  import EditorFilePreviewIcon from '@atlaskit/icon/glyph/editor/file-preview';
5
5
  import Button from '@atlaskit/button/custom-theme-button';
6
- import { messages } from '@atlaskit/media-ui'; // eslint-disable-next-line import/no-extraneous-dependencies
6
+ import { messages } from '@atlaskit/media-ui';
7
+ // eslint-disable-next-line import/no-extraneous-dependencies
7
8
 
8
9
  import { ANALYTICS_MEDIA_CHANNEL } from '../util';
9
-
10
10
  const MediaPreviewButton = props => {
11
11
  const {
12
12
  onClick,
@@ -22,19 +22,20 @@ const MediaPreviewButton = props => {
22
22
  }),
23
23
  onKeyPress: event => event.stopPropagation(),
24
24
  onClick: (event, analyticsEvent) => {
25
- analyticsEvent.update(payload => ({ ...payload,
25
+ analyticsEvent.update(payload => ({
26
+ ...payload,
26
27
  eventType: 'ui',
27
28
  actionSubjectId: 'mediaTablePreview'
28
29
  })).fire(ANALYTICS_MEDIA_CHANNEL);
29
30
  onClick(event);
30
31
  },
31
32
  theme: (current, themeProps) => ({
32
- buttonStyles: { ...current(themeProps).buttonStyles,
33
+ buttonStyles: {
34
+ ...current(themeProps).buttonStyles,
33
35
  minWidth: 'max-content'
34
36
  },
35
37
  spinnerStyles: current(themeProps).spinnerStyles
36
38
  })
37
39
  });
38
40
  };
39
-
40
41
  export default injectIntl(MediaPreviewButton);
@@ -1,6 +1,5 @@
1
1
  // eslint-disable-next-line import/no-extraneous-dependencies
2
2
  import memoizeOne from 'memoize-one';
3
-
4
3
  function generateEmptyRows(emptyCells, length) {
5
4
  const itemsArray = Array.from({
6
5
  length
@@ -9,7 +8,6 @@ function generateEmptyRows(emptyCells, length) {
9
8
  cells: emptyCells
10
9
  }));
11
10
  }
12
-
13
11
  export const generateEmptyRow = memoizeOne(headerCells => {
14
12
  return headerCells.map(cell => ({
15
13
  key: cell.key,
@@ -20,7 +18,6 @@ export const prependRows = memoizeOne((emptyCells, itemsPerPage, pageNumber) =>
20
18
  if (!itemsPerPage || !pageNumber) {
21
19
  return [];
22
20
  }
23
-
24
21
  const itemsCount = (pageNumber - 1) * itemsPerPage;
25
22
  return generateEmptyRows(emptyCells, itemsCount);
26
23
  });
@@ -28,7 +25,6 @@ export const appendRows = memoizeOne((emptyCells, rowsLength, itemsPerPage, page
28
25
  if (!itemsPerPage || !pageNumber || !totalItems) {
29
26
  return [];
30
27
  }
31
-
32
28
  const rowsDiff = rowsLength > itemsPerPage ? rowsLength - itemsPerPage : 0;
33
29
  const itemsCount = (Math.ceil(totalItems / itemsPerPage) - pageNumber) * itemsPerPage - rowsDiff;
34
30
  return generateEmptyRows(emptyCells, itemsCount);
@@ -1,43 +1,36 @@
1
1
  // eslint-disable-next-line import/no-extraneous-dependencies
2
2
  import memoizeOne from 'memoize-one';
3
3
  const DEFAULT_ITEMS_PER_PAGE = 6;
4
-
5
4
  const getValidTableProps = (itemsCount, itemsPerPage, pageNumber, totalItems) => {
6
5
  let validItemsPerPage = itemsPerPage || DEFAULT_ITEMS_PER_PAGE;
7
6
  let validTotalItems = totalItems || itemsCount;
8
7
  let validPageNumber = pageNumber || 1;
9
-
10
8
  if (validItemsPerPage < 0) {
11
- validItemsPerPage = DEFAULT_ITEMS_PER_PAGE; // eslint-disable-next-line no-console
12
-
9
+ validItemsPerPage = DEFAULT_ITEMS_PER_PAGE;
10
+ // eslint-disable-next-line no-console
13
11
  console.warn('Invalid itemsPerPage prop provided to MediaTable. Setting value to default.');
14
12
  }
15
-
16
13
  if (validTotalItems < 0) {
17
- validTotalItems = itemsCount; // eslint-disable-next-line no-console
18
-
14
+ validTotalItems = itemsCount;
15
+ // eslint-disable-next-line no-console
19
16
  console.warn('Invalid totalItems prop provided to MediaTable. Defaulting to length of items array.');
20
17
  }
21
-
22
18
  if (validPageNumber < 0) {
23
- validPageNumber = 1; // eslint-disable-next-line no-console
24
-
19
+ validPageNumber = 1;
20
+ // eslint-disable-next-line no-console
25
21
  console.warn('Invalid pageNumber prop provided to MediaTable. Defaulting to first page.');
26
22
  } else {
27
23
  const totalPages = Math.ceil(validTotalItems / validItemsPerPage);
28
-
29
24
  if (validPageNumber > totalPages) {
30
- validPageNumber = totalPages; // eslint-disable-next-line no-console
31
-
25
+ validPageNumber = totalPages;
26
+ // eslint-disable-next-line no-console
32
27
  console.warn('Invalid pageNumber prop provided to MediaTable. Defaulting to last page.');
33
28
  }
34
29
  }
35
-
36
30
  return {
37
31
  validPageNumber,
38
32
  validTotalItems,
39
33
  validItemsPerPage
40
34
  };
41
35
  };
42
-
43
36
  export default memoizeOne(getValidTableProps);
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/media-table",
3
- "version": "14.1.2",
3
+ "version": "14.1.4",
4
4
  "sideEffects": false
5
5
  }
@@ -1,23 +1,19 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
-
3
2
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
4
-
5
3
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
6
-
7
- import { token } from '@atlaskit/tokens';
8
- import React from 'react'; // eslint-disable-next-line import/no-extraneous-dependencies
9
-
4
+ import React from 'react';
5
+ // eslint-disable-next-line import/no-extraneous-dependencies
10
6
  import { injectIntl } from 'react-intl-next';
11
7
  import { N40 } from '@atlaskit/theme/colors';
12
8
  import DownloadIcon from '@atlaskit/icon/glyph/download';
13
9
  import Button from '@atlaskit/button/custom-theme-button';
14
- import { messages } from '@atlaskit/media-ui'; // eslint-disable-next-line import/no-extraneous-dependencies
10
+ import { messages } from '@atlaskit/media-ui';
11
+ // eslint-disable-next-line import/no-extraneous-dependencies
15
12
 
16
13
  import { ANALYTICS_MEDIA_CHANNEL } from '../util';
17
-
18
14
  var MediaDownloadButton = function MediaDownloadButton(props) {
19
15
  var _onClick = props.onClick,
20
- formatMessage = props.intl.formatMessage;
16
+ formatMessage = props.intl.formatMessage;
21
17
  return /*#__PURE__*/React.createElement(Button, {
22
18
  appearance: "subtle",
23
19
  testId: "download-button",
@@ -34,7 +30,6 @@ var MediaDownloadButton = function MediaDownloadButton(props) {
34
30
  actionSubjectId: 'mediaTableDownload'
35
31
  });
36
32
  }).fire(ANALYTICS_MEDIA_CHANNEL);
37
-
38
33
  _onClick(event);
39
34
  },
40
35
  theme: function theme(current, themeProps) {
@@ -42,7 +37,7 @@ var MediaDownloadButton = function MediaDownloadButton(props) {
42
37
  buttonStyles: _objectSpread(_objectSpread({}, current(themeProps).buttonStyles), {}, {
43
38
  minWidth: 'max-content',
44
39
  '&:hover': {
45
- background: token('color.background.neutral.hovered', N40)
40
+ background: "var(--ds-background-neutral-hovered, ".concat(N40, ")")
46
41
  }
47
42
  }),
48
43
  spinnerStyles: current(themeProps).spinnerStyles
@@ -50,5 +45,4 @@ var MediaDownloadButton = function MediaDownloadButton(props) {
50
45
  }
51
46
  });
52
47
  };
53
-
54
48
  export default injectIntl(MediaDownloadButton);