@atlaskit/table-tree 11.1.1 → 11.2.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # @atlaskit/table-tree
2
2
 
3
+ ## 11.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#129233](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/129233)
8
+ [`6cb13640c156e`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/6cb13640c156e) -
9
+ We are testing removing lodash import in favor of local code behind a feature flag. If this fix is
10
+ successful it will be available in a later release.
11
+
12
+ ## 11.1.2
13
+
14
+ ### Patch Changes
15
+
16
+ - [#125706](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/125706)
17
+ [`66e0493b5224b`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/66e0493b5224b) -
18
+ Update dependencies and remove unused internal exports.
19
+
3
20
  ## 11.1.1
4
21
 
5
22
  ### Patch Changes
@@ -69,7 +69,7 @@ function Row(_ref) {
69
69
  actionSubject: 'tableTree',
70
70
  componentName: 'row',
71
71
  packageName: "@atlaskit/table-tree",
72
- packageVersion: "11.1.1"
72
+ packageVersion: "11.2.0"
73
73
  });
74
74
  var onCollapse = (0, _analyticsNext.usePlatformLeafEventHandler)({
75
75
  fn: function fn(value) {
@@ -79,7 +79,7 @@ function Row(_ref) {
79
79
  actionSubject: 'tableTree',
80
80
  componentName: 'row',
81
81
  packageName: "@atlaskit/table-tree",
82
- packageVersion: "11.1.1"
82
+ packageVersion: "11.2.0"
83
83
  });
84
84
 
85
85
  /**
@@ -4,15 +4,56 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.default = void 0;
7
+ exports.internalSet = exports.internalGet = exports.default = void 0;
8
8
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
9
9
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
10
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
11
11
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
12
12
  var _get = _interopRequireDefault(require("lodash/get"));
13
13
  var _set = _interopRequireDefault(require("lodash/set"));
14
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
14
15
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
15
16
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
17
+ // https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore?tab=readme-ov-file#_get
18
+ // https://github.com/lodash/lodash/blob/4.17.15/lodash.js#L13126
19
+ var internalGet = exports.internalGet = function internalGet(obj, path) {
20
+ var defaultValue = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
21
+ var travel = function travel(regexp) {
22
+ return String.prototype.split.call(path, regexp).filter(Boolean).reduce(function (res, key) {
23
+ return res !== null && res !== undefined ? res[key] : res;
24
+ }, obj);
25
+ };
26
+ var result = travel(/[,[\]]+?/) || travel(/[,[\].]+?/);
27
+ return result === undefined || result === obj ? defaultValue : result;
28
+ };
29
+
30
+ // https://stackoverflow.com/a/54733755/14857724
31
+ // https://github.com/lodash/lodash/blob/4.17.15/lodash.js#L13673
32
+ var internalSet = exports.internalSet = function internalSet(obj, providedPath, value) {
33
+ // When obj is not an object, fail gracefully
34
+ if (Object(obj) !== obj) {
35
+ return obj;
36
+ }
37
+
38
+ // If not yet an array, get the keys from the string-path
39
+ var path = !Array.isArray(providedPath) ? providedPath.toString().match(/[^.[\]]+/g) || [] : providedPath;
40
+
41
+ // Iterate all of them except the last one
42
+ var result = path.slice(0, -1).reduce(function (acc, c, index) {
43
+ // Does the key exist and is its value an object?
44
+ return Object(acc[c]) === acc[c] ? acc[c] // Yes: then follow that path
45
+ :
46
+ // No: create the key. Is the next key a potential array-index?
47
+ acc[c] = Math.abs(parseInt(path[index + 1])) >> 0 === +path[index + 1] ? [] // Yes: assign a new array object
48
+ : {}; // No: assign a new plain object
49
+ }, obj);
50
+
51
+ // Finally assign the value to the last key
52
+ result[path[path.length - 1]] = value;
53
+
54
+ // Return the top-level object to allow chaining
55
+ return obj;
56
+ };
16
57
  function updateRootItems(rootItems) {
17
58
  var allItems = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
18
59
  var _ref = arguments.length > 2 ? arguments[2] : undefined,
@@ -40,6 +81,10 @@ function updateChildItems(newitems, allTableItems, itemParent, _ref2) {
40
81
  var key = _ref2.key,
41
82
  keysCache = _ref2.keysCache,
42
83
  operation = _ref2.operation;
84
+ // eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
85
+ var get = (0, _platformFeatureFlags.fg)('dst-a11y-remove-lodash-from-table-tree') ? internalGet : _get.default;
86
+ // eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
87
+ var set = (0, _platformFeatureFlags.fg)('dst-a11y-remove-lodash-from-table-tree') ? internalSet : _set.default;
43
88
  var newKeysCache = _objectSpread({}, keysCache);
44
89
  var parentCacheKey = itemParent[key];
45
90
  if (parentCacheKey === undefined) {
@@ -47,8 +92,8 @@ function updateChildItems(newitems, allTableItems, itemParent, _ref2) {
47
92
  }
48
93
  var parentLocation = newKeysCache[parentCacheKey];
49
94
  var allItemsCopy = (0, _toConsumableArray2.default)(allTableItems);
50
- var objectToChange = (0, _get.default)(allItemsCopy, parentLocation);
51
- var baseChildrenOfObjectToChange = operation === 'UPDATE' ? [] : (0, _get.default)(objectToChange, 'children', []);
95
+ var objectToChange = get(allItemsCopy, parentLocation);
96
+ var baseChildrenOfObjectToChange = operation === 'UPDATE' ? [] : get(objectToChange, 'children', []);
52
97
  objectToChange.children = baseChildrenOfObjectToChange.concat(newitems);
53
98
 
54
99
  // Update cache
@@ -57,7 +102,7 @@ function updateChildItems(newitems, allTableItems, itemParent, _ref2) {
57
102
  });
58
103
  return {
59
104
  keysCache: newKeysCache,
60
- items: (0, _set.default)(allItemsCopy, parentLocation, objectToChange)
105
+ items: set(allItemsCopy, parentLocation, objectToChange)
61
106
  };
62
107
  }
63
108
 
@@ -53,7 +53,7 @@ function Row({
53
53
  actionSubject: 'tableTree',
54
54
  componentName: 'row',
55
55
  packageName: "@atlaskit/table-tree",
56
- packageVersion: "11.1.1"
56
+ packageVersion: "11.2.0"
57
57
  });
58
58
  const onCollapse = usePlatformLeafEventHandler({
59
59
  fn: value => providedOnCollapse && providedOnCollapse(value),
@@ -61,7 +61,7 @@ function Row({
61
61
  actionSubject: 'tableTree',
62
62
  componentName: 'row',
63
63
  packageName: "@atlaskit/table-tree",
64
- packageVersion: "11.1.1"
64
+ packageVersion: "11.2.0"
65
65
  });
66
66
 
67
67
  /**
@@ -1,5 +1,41 @@
1
- import get from 'lodash/get';
2
- import set from 'lodash/set';
1
+ import lodashGet from 'lodash/get';
2
+ import lodashSet from 'lodash/set';
3
+ import { fg } from '@atlaskit/platform-feature-flags';
4
+ // https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore?tab=readme-ov-file#_get
5
+ // https://github.com/lodash/lodash/blob/4.17.15/lodash.js#L13126
6
+ export const internalGet = (obj, path, defaultValue = undefined) => {
7
+ const travel = regexp => String.prototype.split.call(path, regexp).filter(Boolean).reduce((res, key) => res !== null && res !== undefined ? res[key] : res, obj);
8
+ const result = travel(/[,[\]]+?/) || travel(/[,[\].]+?/);
9
+ return result === undefined || result === obj ? defaultValue : result;
10
+ };
11
+
12
+ // https://stackoverflow.com/a/54733755/14857724
13
+ // https://github.com/lodash/lodash/blob/4.17.15/lodash.js#L13673
14
+ export const internalSet = (obj, providedPath, value) => {
15
+ // When obj is not an object, fail gracefully
16
+ if (Object(obj) !== obj) {
17
+ return obj;
18
+ }
19
+
20
+ // If not yet an array, get the keys from the string-path
21
+ const path = !Array.isArray(providedPath) ? providedPath.toString().match(/[^.[\]]+/g) || [] : providedPath;
22
+
23
+ // Iterate all of them except the last one
24
+ const result = path.slice(0, -1).reduce((acc, c, index) => {
25
+ // Does the key exist and is its value an object?
26
+ return Object(acc[c]) === acc[c] ? acc[c] // Yes: then follow that path
27
+ :
28
+ // No: create the key. Is the next key a potential array-index?
29
+ acc[c] = Math.abs(parseInt(path[index + 1])) >> 0 === +path[index + 1] ? [] // Yes: assign a new array object
30
+ : {}; // No: assign a new plain object
31
+ }, obj);
32
+
33
+ // Finally assign the value to the last key
34
+ result[path[path.length - 1]] = value;
35
+
36
+ // Return the top-level object to allow chaining
37
+ return obj;
38
+ };
3
39
  function updateRootItems(rootItems, allItems = [], {
4
40
  key,
5
41
  keysCache,
@@ -29,6 +65,10 @@ function updateChildItems(newitems, allTableItems, itemParent, {
29
65
  keysCache,
30
66
  operation
31
67
  }) {
68
+ // eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
69
+ const get = fg('dst-a11y-remove-lodash-from-table-tree') ? internalGet : lodashGet;
70
+ // eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
71
+ const set = fg('dst-a11y-remove-lodash-from-table-tree') ? internalSet : lodashSet;
32
72
  const newKeysCache = {
33
73
  ...keysCache
34
74
  };
@@ -58,7 +58,7 @@ function Row(_ref) {
58
58
  actionSubject: 'tableTree',
59
59
  componentName: 'row',
60
60
  packageName: "@atlaskit/table-tree",
61
- packageVersion: "11.1.1"
61
+ packageVersion: "11.2.0"
62
62
  });
63
63
  var onCollapse = usePlatformLeafEventHandler({
64
64
  fn: function fn(value) {
@@ -68,7 +68,7 @@ function Row(_ref) {
68
68
  actionSubject: 'tableTree',
69
69
  componentName: 'row',
70
70
  packageName: "@atlaskit/table-tree",
71
- packageVersion: "11.1.1"
71
+ packageVersion: "11.2.0"
72
72
  });
73
73
 
74
74
  /**
@@ -4,8 +4,49 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
4
4
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
5
5
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
6
6
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
7
- import get from 'lodash/get';
8
- import set from 'lodash/set';
7
+ import lodashGet from 'lodash/get';
8
+ import lodashSet from 'lodash/set';
9
+ import { fg } from '@atlaskit/platform-feature-flags';
10
+ // https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore?tab=readme-ov-file#_get
11
+ // https://github.com/lodash/lodash/blob/4.17.15/lodash.js#L13126
12
+ export var internalGet = function internalGet(obj, path) {
13
+ var defaultValue = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
14
+ var travel = function travel(regexp) {
15
+ return String.prototype.split.call(path, regexp).filter(Boolean).reduce(function (res, key) {
16
+ return res !== null && res !== undefined ? res[key] : res;
17
+ }, obj);
18
+ };
19
+ var result = travel(/[,[\]]+?/) || travel(/[,[\].]+?/);
20
+ return result === undefined || result === obj ? defaultValue : result;
21
+ };
22
+
23
+ // https://stackoverflow.com/a/54733755/14857724
24
+ // https://github.com/lodash/lodash/blob/4.17.15/lodash.js#L13673
25
+ export var internalSet = function internalSet(obj, providedPath, value) {
26
+ // When obj is not an object, fail gracefully
27
+ if (Object(obj) !== obj) {
28
+ return obj;
29
+ }
30
+
31
+ // If not yet an array, get the keys from the string-path
32
+ var path = !Array.isArray(providedPath) ? providedPath.toString().match(/[^.[\]]+/g) || [] : providedPath;
33
+
34
+ // Iterate all of them except the last one
35
+ var result = path.slice(0, -1).reduce(function (acc, c, index) {
36
+ // Does the key exist and is its value an object?
37
+ return Object(acc[c]) === acc[c] ? acc[c] // Yes: then follow that path
38
+ :
39
+ // No: create the key. Is the next key a potential array-index?
40
+ acc[c] = Math.abs(parseInt(path[index + 1])) >> 0 === +path[index + 1] ? [] // Yes: assign a new array object
41
+ : {}; // No: assign a new plain object
42
+ }, obj);
43
+
44
+ // Finally assign the value to the last key
45
+ result[path[path.length - 1]] = value;
46
+
47
+ // Return the top-level object to allow chaining
48
+ return obj;
49
+ };
9
50
  function updateRootItems(rootItems) {
10
51
  var allItems = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
11
52
  var _ref = arguments.length > 2 ? arguments[2] : undefined,
@@ -33,6 +74,10 @@ function updateChildItems(newitems, allTableItems, itemParent, _ref2) {
33
74
  var key = _ref2.key,
34
75
  keysCache = _ref2.keysCache,
35
76
  operation = _ref2.operation;
77
+ // eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
78
+ var get = fg('dst-a11y-remove-lodash-from-table-tree') ? internalGet : lodashGet;
79
+ // eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
80
+ var set = fg('dst-a11y-remove-lodash-from-table-tree') ? internalSet : lodashSet;
36
81
  var newKeysCache = _objectSpread({}, keysCache);
37
82
  var parentCacheKey = itemParent[key];
38
83
  if (parentCacheKey === undefined) {
@@ -4,7 +4,7 @@
4
4
  */
5
5
  import { type ReactElement } from 'react';
6
6
  import { jsx } from '@emotion/react';
7
- export interface HeadersProps {
7
+ interface HeadersProps {
8
8
  children: ReactElement | ReactElement[];
9
9
  }
10
10
  /**
@@ -1,6 +1,6 @@
1
1
  import React, { type ReactElement } from 'react';
2
2
  import { type RowProps } from '../row';
3
- export interface ItemsProps<Item> {
3
+ interface ItemsProps<Item> {
4
4
  depth?: number;
5
5
  items?: Item[] | null;
6
6
  loadingLabel?: string;
@@ -1,3 +1,5 @@
1
+ export declare const internalGet: (obj: Object, path: Array<any> | string, defaultValue?: any) => any;
2
+ export declare const internalSet: (obj: Object, providedPath: Array<any> | string, value: any) => any;
1
3
  /**
2
4
  * This helper class will create a cache of all the id's in the items object and
3
5
  * path to the object.
@@ -20,6 +22,6 @@ export default class TableTreeDataHelper<T extends any = any> {
20
22
  constructor({ key }?: {
21
23
  key?: keyof T | undefined;
22
24
  });
23
- updateItems(items: T[], allItems?: T[], parentItem?: T | null): T[];
24
- appendItems(items: T[], allItems?: T[], parentItem?: T | null): T[];
25
+ updateItems(items: T[], allItems?: T[], parentItem?: T | null): any;
26
+ appendItems(items: T[], allItems?: T[], parentItem?: T | null): any;
25
27
  }
@@ -4,7 +4,7 @@
4
4
  */
5
5
  import { type ReactElement } from 'react';
6
6
  import { jsx } from '@emotion/react';
7
- export interface HeadersProps {
7
+ interface HeadersProps {
8
8
  children: ReactElement | ReactElement[];
9
9
  }
10
10
  /**
@@ -1,6 +1,6 @@
1
1
  import React, { type ReactElement } from 'react';
2
2
  import { type RowProps } from '../row';
3
- export interface ItemsProps<Item> {
3
+ interface ItemsProps<Item> {
4
4
  depth?: number;
5
5
  items?: Item[] | null;
6
6
  loadingLabel?: string;
@@ -1,3 +1,5 @@
1
+ export declare const internalGet: (obj: Object, path: Array<any> | string, defaultValue?: any) => any;
2
+ export declare const internalSet: (obj: Object, providedPath: Array<any> | string, value: any) => any;
1
3
  /**
2
4
  * This helper class will create a cache of all the id's in the items object and
3
5
  * path to the object.
@@ -20,6 +22,6 @@ export default class TableTreeDataHelper<T extends any = any> {
20
22
  constructor({ key }?: {
21
23
  key?: keyof T | undefined;
22
24
  });
23
- updateItems(items: T[], allItems?: T[], parentItem?: T | null): T[];
24
- appendItems(items: T[], allItems?: T[], parentItem?: T | null): T[];
25
+ updateItems(items: T[], allItems?: T[], parentItem?: T | null): any;
26
+ appendItems(items: T[], allItems?: T[], parentItem?: T | null): any;
25
27
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/table-tree",
3
- "version": "11.1.1",
3
+ "version": "11.2.0",
4
4
  "description": "A table tree is an expandable table for showing nested hierarchies of information.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -29,9 +29,10 @@
29
29
  "@atlaskit/button": "^21.1.0",
30
30
  "@atlaskit/ds-lib": "^4.0.0",
31
31
  "@atlaskit/icon": "^25.0.0",
32
+ "@atlaskit/platform-feature-flags": "^1.1.0",
32
33
  "@atlaskit/spinner": "^18.0.0",
33
34
  "@atlaskit/theme": "^18.0.0",
34
- "@atlaskit/tokens": "^4.4.0",
35
+ "@atlaskit/tokens": "^4.5.0",
35
36
  "@babel/runtime": "^7.0.0",
36
37
  "@emotion/react": "^11.7.1",
37
38
  "lodash": "^4.17.21"
@@ -43,18 +44,18 @@
43
44
  "@af/accessibility-testing": "^2.0.0",
44
45
  "@af/integration-testing": "^0.5.0",
45
46
  "@af/visual-regression": "^1.3.0",
47
+ "@atlaskit/docs": "^10.0.0",
48
+ "@atlaskit/empty-state": "^9.0.0",
49
+ "@atlaskit/form": "^12.0.0",
50
+ "@atlaskit/link": "^3.0.0",
51
+ "@atlaskit/primitives": "^14.2.0",
52
+ "@atlaskit/section-message": "^8.2.0",
53
+ "@atlaskit/select": "^20.0.0",
46
54
  "@atlaskit/ssr": "^0.4.0",
47
- "@atlaskit/visual-regression": "^0.10.0",
48
55
  "@atlaskit/visually-hidden": "^3.0.0",
49
- "@emotion/styled": "^11.0.0",
50
56
  "@testing-library/react": "^13.4.0",
51
57
  "@testing-library/user-event": "^14.4.3",
52
- "@types/react-redux": "^5.0.0",
53
- "exenv": "^1.2.2",
54
- "react-dom": "^18.2.0",
55
- "react-redux": "^5.1.2",
56
- "redux": "^3.7.2",
57
- "redux-thunk": "^2.3.0"
58
+ "react-dom": "^18.2.0"
58
59
  },
59
60
  "keywords": [
60
61
  "atlaskit",
@@ -92,5 +93,10 @@
92
93
  "homepage": "https://atlassian.design/components/table-tree/",
93
94
  "af:exports": {
94
95
  ".": "./src/index.tsx"
96
+ },
97
+ "platform-feature-flags": {
98
+ "dst-a11y-remove-lodash-from-table-tree": {
99
+ "type": "boolean"
100
+ }
95
101
  }
96
102
  }