@atlaskit/table-tree 11.1.2 → 11.2.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,20 @@
1
1
  # @atlaskit/table-tree
2
2
 
3
+ ## 11.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 11.2.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [#129233](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/129233)
14
+ [`6cb13640c156e`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/6cb13640c156e) -
15
+ We are testing removing lodash import in favor of local code behind a feature flag. If this fix is
16
+ successful it will be available in a later release.
17
+
3
18
  ## 11.1.2
4
19
 
5
20
  ### 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.2"
72
+ packageVersion: "11.2.1"
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.2"
82
+ packageVersion: "11.2.1"
83
83
  });
84
84
 
85
85
  /**
@@ -4,18 +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
- 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; } // TODO: Replace with native function
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; }
16
17
  // https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore?tab=readme-ov-file#_get
17
- // TODO: Replace with native function
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
+
18
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
+ };
19
57
  function updateRootItems(rootItems) {
20
58
  var allItems = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
21
59
  var _ref = arguments.length > 2 ? arguments[2] : undefined,
@@ -43,6 +81,10 @@ function updateChildItems(newitems, allTableItems, itemParent, _ref2) {
43
81
  var key = _ref2.key,
44
82
  keysCache = _ref2.keysCache,
45
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;
46
88
  var newKeysCache = _objectSpread({}, keysCache);
47
89
  var parentCacheKey = itemParent[key];
48
90
  if (parentCacheKey === undefined) {
@@ -50,8 +92,8 @@ function updateChildItems(newitems, allTableItems, itemParent, _ref2) {
50
92
  }
51
93
  var parentLocation = newKeysCache[parentCacheKey];
52
94
  var allItemsCopy = (0, _toConsumableArray2.default)(allTableItems);
53
- var objectToChange = (0, _get.default)(allItemsCopy, parentLocation);
54
- var baseChildrenOfObjectToChange = operation === 'UPDATE' ? [] : (0, _get.default)(objectToChange, 'children', []);
95
+ var objectToChange = get(allItemsCopy, parentLocation);
96
+ var baseChildrenOfObjectToChange = operation === 'UPDATE' ? [] : get(objectToChange, 'children', []);
55
97
  objectToChange.children = baseChildrenOfObjectToChange.concat(newitems);
56
98
 
57
99
  // Update cache
@@ -60,7 +102,7 @@ function updateChildItems(newitems, allTableItems, itemParent, _ref2) {
60
102
  });
61
103
  return {
62
104
  keysCache: newKeysCache,
63
- items: (0, _set.default)(allItemsCopy, parentLocation, objectToChange)
105
+ items: set(allItemsCopy, parentLocation, objectToChange)
64
106
  };
65
107
  }
66
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.2"
56
+ packageVersion: "11.2.1"
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.2"
64
+ packageVersion: "11.2.1"
65
65
  });
66
66
 
67
67
  /**
@@ -1,9 +1,41 @@
1
- // TODO: Replace with native function
1
+ import lodashGet from 'lodash/get';
2
+ import lodashSet from 'lodash/set';
3
+ import { fg } from '@atlaskit/platform-feature-flags';
2
4
  // https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore?tab=readme-ov-file#_get
3
- import get from 'lodash/get';
4
- // TODO: Replace with native function
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
+
5
12
  // https://stackoverflow.com/a/54733755/14857724
6
- import set from 'lodash/set';
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
+ };
7
39
  function updateRootItems(rootItems, allItems = [], {
8
40
  key,
9
41
  keysCache,
@@ -33,6 +65,10 @@ function updateChildItems(newitems, allTableItems, itemParent, {
33
65
  keysCache,
34
66
  operation
35
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;
36
72
  const newKeysCache = {
37
73
  ...keysCache
38
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.2"
61
+ packageVersion: "11.2.1"
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.2"
71
+ packageVersion: "11.2.1"
72
72
  });
73
73
 
74
74
  /**
@@ -4,12 +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
- // TODO: Replace with native function
7
+ import lodashGet from 'lodash/get';
8
+ import lodashSet from 'lodash/set';
9
+ import { fg } from '@atlaskit/platform-feature-flags';
8
10
  // https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore?tab=readme-ov-file#_get
9
- import get from 'lodash/get';
10
- // TODO: Replace with native function
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
+
11
23
  // https://stackoverflow.com/a/54733755/14857724
12
- import set from 'lodash/set';
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
+ };
13
50
  function updateRootItems(rootItems) {
14
51
  var allItems = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
15
52
  var _ref = arguments.length > 2 ? arguments[2] : undefined,
@@ -37,6 +74,10 @@ function updateChildItems(newitems, allTableItems, itemParent, _ref2) {
37
74
  var key = _ref2.key,
38
75
  keysCache = _ref2.keysCache,
39
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;
40
81
  var newKeysCache = _objectSpread({}, keysCache);
41
82
  var parentCacheKey = itemParent[key];
42
83
  if (parentCacheKey === undefined) {
@@ -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
  }
@@ -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.2",
3
+ "version": "11.2.1",
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/"
@@ -26,12 +26,13 @@
26
26
  },
27
27
  "dependencies": {
28
28
  "@atlaskit/analytics-next": "^11.0.0",
29
- "@atlaskit/button": "^21.1.0",
29
+ "@atlaskit/button": "^22.0.0",
30
30
  "@atlaskit/ds-lib": "^4.0.0",
31
- "@atlaskit/icon": "^25.0.0",
31
+ "@atlaskit/icon": "^25.2.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"
@@ -47,8 +48,8 @@
47
48
  "@atlaskit/empty-state": "^9.0.0",
48
49
  "@atlaskit/form": "^12.0.0",
49
50
  "@atlaskit/link": "^3.0.0",
50
- "@atlaskit/primitives": "^14.1.0",
51
- "@atlaskit/section-message": "^8.1.0",
51
+ "@atlaskit/primitives": "^14.2.0",
52
+ "@atlaskit/section-message": "^8.2.0",
52
53
  "@atlaskit/select": "^20.0.0",
53
54
  "@atlaskit/ssr": "^0.4.0",
54
55
  "@atlaskit/visually-hidden": "^3.0.0",
@@ -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
  }