@douyinfe/semi-foundation 2.71.2 → 2.71.3

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.
@@ -7,7 +7,8 @@ export interface CarouselAdapter<P = Record<string, any>, S = Record<string, any
7
7
  setNewActiveIndex: (activeIndex: number) => void;
8
8
  setPreActiveIndex: (activeIndex: number) => void;
9
9
  setIsReverse: (isReverse: boolean) => void;
10
- setIsInit: (isInit: boolean) => void
10
+ setIsInit: (isInit: boolean) => void;
11
+ getChildren: () => any[]
11
12
  }
12
13
 
13
14
  class CarouselFoundation<P = Record<string, any>, S = Record<string, any>> extends BaseFoundation<CarouselAdapter<P, S>, P, S> {
@@ -102,7 +103,7 @@ class CarouselFoundation<P = Record<string, any>, S = Record<string, any>> exten
102
103
  }
103
104
 
104
105
  getValidIndex(index: number): number {
105
- const { children } = this.getStates();
106
+ const children = this._adapter.getChildren();
106
107
  return (index + children.length) % children.length;
107
108
  }
108
109
 
@@ -124,7 +125,7 @@ class CarouselFoundation<P = Record<string, any>, S = Record<string, any>> exten
124
125
 
125
126
  handleAutoPlay(): void {
126
127
  const { autoPlay } = this.getProps();
127
- const { children } = this.getStates();
128
+ const children = this._adapter.getChildren();
128
129
  const autoPlayType = typeof autoPlay;
129
130
  // when user manually call the play function, force play
130
131
  // only when carousel children length > 1 to start play
@@ -5,6 +5,7 @@ export interface CarouselAdapter<P = Record<string, any>, S = Record<string, any
5
5
  setPreActiveIndex: (activeIndex: number) => void;
6
6
  setIsReverse: (isReverse: boolean) => void;
7
7
  setIsInit: (isInit: boolean) => void;
8
+ getChildren: () => any[];
8
9
  }
9
10
  declare class CarouselFoundation<P = Record<string, any>, S = Record<string, any>> extends BaseFoundation<CarouselAdapter<P, S>, P, S> {
10
11
  constructor(adapter: CarouselAdapter<P, S>);
@@ -97,9 +97,7 @@ class CarouselFoundation extends _foundation.default {
97
97
  }
98
98
  }
99
99
  getValidIndex(index) {
100
- const {
101
- children
102
- } = this.getStates();
100
+ const children = this._adapter.getChildren();
103
101
  return (index + children.length) % children.length;
104
102
  }
105
103
  getSwitchingTime() {
@@ -123,9 +121,7 @@ class CarouselFoundation extends _foundation.default {
123
121
  const {
124
122
  autoPlay
125
123
  } = this.getProps();
126
- const {
127
- children
128
- } = this.getStates();
124
+ const children = this._adapter.getChildren();
129
125
  const autoPlayType = typeof autoPlay;
130
126
  // when user manually call the play function, force play
131
127
  // only when carousel children length > 1 to start play
@@ -4,6 +4,7 @@ declare const cssClasses: {
4
4
  };
5
5
  declare const strings: {
6
6
  EXPAND_ACTION: (string | boolean)[];
7
+ JSON_KEY_SPLIT: string;
7
8
  };
8
9
  declare const numbers: {};
9
10
  export { cssClasses, strings, numbers };
@@ -10,6 +10,7 @@ const cssClasses = exports.cssClasses = {
10
10
  PREFIX_OPTION: `${_constants.BASE_CLASS_PREFIX}-tree-option`
11
11
  };
12
12
  const strings = exports.strings = {
13
- EXPAND_ACTION: [false, 'click', 'doubleClick']
13
+ EXPAND_ACTION: [false, 'click', 'doubleClick'],
14
+ JSON_KEY_SPLIT: '_SEMI_TREE_SPLIT_'
14
15
  };
15
16
  const numbers = exports.numbers = {};
@@ -10,6 +10,7 @@ var _difference2 = _interopRequireDefault(require("lodash/difference"));
10
10
  var _isUndefined2 = _interopRequireDefault(require("lodash/isUndefined"));
11
11
  var _foundation = _interopRequireDefault(require("../base/foundation"));
12
12
  var _treeUtil = require("./treeUtil");
13
+ var _constants = require("./constants");
13
14
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
14
15
  /**
15
16
  * The drag and drop handler implementation is referenced from rc-tree
@@ -111,7 +112,7 @@ class TreeFoundation extends _foundation.default {
111
112
  }
112
113
  notifyJsonChange(key, e) {
113
114
  const data = this.getProp('treeDataSimpleJson');
114
- const selectedPath = (0, _treeUtil.normalizedArr)(key).map(i => i.replace('-', '.'));
115
+ const selectedPath = (0, _treeUtil.normalizedArr)(key).map(i => i.replaceAll(_constants.strings.JSON_KEY_SPLIT, '.'));
115
116
  const value = (0, _pick2.default)(data, selectedPath);
116
117
  this._adapter.notifyChange(value);
117
118
  }
@@ -41,6 +41,7 @@ var _isObject2 = _interopRequireDefault(require("lodash/isObject"));
41
41
  var _max2 = _interopRequireDefault(require("lodash/max"));
42
42
  var _uniq2 = _interopRequireDefault(require("lodash/uniq"));
43
43
  var _difference2 = _interopRequireDefault(require("lodash/difference"));
44
+ var _constants = require("./constants");
44
45
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
45
46
  /**
46
47
  * Part of the utils function implementation process reference
@@ -109,7 +110,7 @@ function convertJsonToData(treeJson) {
109
110
  const treeData = [];
110
111
  const traverseNode = (key, children, path, res) => {
111
112
  const currPath = [...path, key];
112
- const itemKey = currPath.join('-');
113
+ const itemKey = currPath.join(_constants.strings.JSON_KEY_SPLIT);
113
114
  const newNode = {
114
115
  key: itemKey,
115
116
  label: key,
@@ -162,9 +162,7 @@ export default class TreeSelectFoundation<P = Record<string, any>, S = Record<st
162
162
  handleSingleSelect(e: any, treeNode: BasicTreeNodeProps): void;
163
163
  calcCheckedKeys(eventKey: BasicTreeNodeProps['eventKey'], targetStatus: boolean): {
164
164
  checkedKeys: Set<string>;
165
- halfCheckedKeys: Set<string>; /**
166
- * A11y: simulate selection click
167
- */
165
+ halfCheckedKeys: Set<string>;
168
166
  };
169
167
  handleMultipleSelect(e: any, treeNode: BasicTreeNodeProps): void;
170
168
  calcNonDisabledCheckedKeys(eventKey: string, targetStatus: boolean): {
@@ -5,6 +5,7 @@ export interface CarouselAdapter<P = Record<string, any>, S = Record<string, any
5
5
  setPreActiveIndex: (activeIndex: number) => void;
6
6
  setIsReverse: (isReverse: boolean) => void;
7
7
  setIsInit: (isInit: boolean) => void;
8
+ getChildren: () => any[];
8
9
  }
9
10
  declare class CarouselFoundation<P = Record<string, any>, S = Record<string, any>> extends BaseFoundation<CarouselAdapter<P, S>, P, S> {
10
11
  constructor(adapter: CarouselAdapter<P, S>);
@@ -90,9 +90,7 @@ class CarouselFoundation extends BaseFoundation {
90
90
  }
91
91
  }
92
92
  getValidIndex(index) {
93
- const {
94
- children
95
- } = this.getStates();
93
+ const children = this._adapter.getChildren();
96
94
  return (index + children.length) % children.length;
97
95
  }
98
96
  getSwitchingTime() {
@@ -116,9 +114,7 @@ class CarouselFoundation extends BaseFoundation {
116
114
  const {
117
115
  autoPlay
118
116
  } = this.getProps();
119
- const {
120
- children
121
- } = this.getStates();
117
+ const children = this._adapter.getChildren();
122
118
  const autoPlayType = typeof autoPlay;
123
119
  // when user manually call the play function, force play
124
120
  // only when carousel children length > 1 to start play
@@ -4,6 +4,7 @@ declare const cssClasses: {
4
4
  };
5
5
  declare const strings: {
6
6
  EXPAND_ACTION: (string | boolean)[];
7
+ JSON_KEY_SPLIT: string;
7
8
  };
8
9
  declare const numbers: {};
9
10
  export { cssClasses, strings, numbers };
@@ -4,7 +4,8 @@ const cssClasses = {
4
4
  PREFIX_OPTION: `${BASE_CLASS_PREFIX}-tree-option`
5
5
  };
6
6
  const strings = {
7
- EXPAND_ACTION: [false, 'click', 'doubleClick']
7
+ EXPAND_ACTION: [false, 'click', 'doubleClick'],
8
+ JSON_KEY_SPLIT: '_SEMI_TREE_SPLIT_'
8
9
  };
9
10
  const numbers = {};
10
11
  export { cssClasses, strings, numbers };
@@ -8,6 +8,7 @@ import _isUndefined from "lodash/isUndefined";
8
8
  */
9
9
  import BaseFoundation from '../base/foundation';
10
10
  import { flattenTreeData, findDescendantKeys, findAncestorKeys, filter, normalizedArr, normalizeKeyList, getMotionKeys, calcCheckedKeysForChecked, calcCheckedKeysForUnchecked, calcCheckedKeys, getValueOrKey, getDragNodesKeys, calcDropRelativePosition, calcDropActualPosition } from './treeUtil';
11
+ import { strings } from './constants';
11
12
  export default class TreeFoundation extends BaseFoundation {
12
13
  constructor(adapter) {
13
14
  super(Object.assign({}, adapter));
@@ -103,7 +104,7 @@ export default class TreeFoundation extends BaseFoundation {
103
104
  }
104
105
  notifyJsonChange(key, e) {
105
106
  const data = this.getProp('treeDataSimpleJson');
106
- const selectedPath = normalizedArr(key).map(i => i.replace('-', '.'));
107
+ const selectedPath = normalizedArr(key).map(i => i.replaceAll(strings.JSON_KEY_SPLIT, '.'));
107
108
  const value = _pick(data, selectedPath);
108
109
  this._adapter.notifyChange(value);
109
110
  }
@@ -12,6 +12,7 @@ import _difference from "lodash/difference";
12
12
  * Part of the utils function implementation process reference
13
13
  * https://github.com/react-component/tree/blob/master/src/util.tsx
14
14
  */
15
+ import { strings } from './constants';
15
16
  const DRAG_OFFSET = 0.45;
16
17
  function getPosition(level, index) {
17
18
  return `${level}-${index}`;
@@ -74,7 +75,7 @@ export function convertJsonToData(treeJson) {
74
75
  const treeData = [];
75
76
  const traverseNode = (key, children, path, res) => {
76
77
  const currPath = [...path, key];
77
- const itemKey = currPath.join('-');
78
+ const itemKey = currPath.join(strings.JSON_KEY_SPLIT);
78
79
  const newNode = {
79
80
  key: itemKey,
80
81
  label: key,
@@ -162,9 +162,7 @@ export default class TreeSelectFoundation<P = Record<string, any>, S = Record<st
162
162
  handleSingleSelect(e: any, treeNode: BasicTreeNodeProps): void;
163
163
  calcCheckedKeys(eventKey: BasicTreeNodeProps['eventKey'], targetStatus: boolean): {
164
164
  checkedKeys: Set<string>;
165
- halfCheckedKeys: Set<string>; /**
166
- * A11y: simulate selection click
167
- */
165
+ halfCheckedKeys: Set<string>;
168
166
  };
169
167
  handleMultipleSelect(e: any, treeNode: BasicTreeNodeProps): void;
170
168
  calcNonDisabledCheckedKeys(eventKey: string, targetStatus: boolean): {
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@douyinfe/semi-foundation",
3
- "version": "2.71.2",
3
+ "version": "2.71.3",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "build:lib": "node ./scripts/compileLib.js",
7
7
  "prepublishOnly": "npm run build:lib"
8
8
  },
9
9
  "dependencies": {
10
- "@douyinfe/semi-animation": "2.71.2",
11
- "@douyinfe/semi-json-viewer-core": "2.71.2",
10
+ "@douyinfe/semi-animation": "2.71.3",
11
+ "@douyinfe/semi-json-viewer-core": "2.71.3",
12
12
  "@mdx-js/mdx": "^3.0.1",
13
13
  "async-validator": "^3.5.0",
14
14
  "classnames": "^2.2.6",
@@ -29,7 +29,7 @@
29
29
  "*.scss",
30
30
  "*.css"
31
31
  ],
32
- "gitHead": "e65e2dcb2c75c77a7c41234b1e7b5a2ebc73dd67",
32
+ "gitHead": "2c3f3a4e4e1dee2fe1a55586edc11d6dc3a6bd93",
33
33
  "devDependencies": {
34
34
  "@babel/plugin-transform-runtime": "^7.15.8",
35
35
  "@babel/preset-env": "^7.15.8",
package/tree/constants.ts CHANGED
@@ -7,6 +7,7 @@ const cssClasses = {
7
7
 
8
8
  const strings = {
9
9
  EXPAND_ACTION: [false, 'click', 'doubleClick'],
10
+ JSON_KEY_SPLIT: '_SEMI_TREE_SPLIT_',
10
11
  };
11
12
 
12
13
  const numbers = {};
@@ -23,6 +23,7 @@ import {
23
23
  } from './treeUtil';
24
24
 
25
25
  import type { KeyMapProps } from './treeUtil';
26
+ import { strings } from './constants';
26
27
  export type { KeyMapProps };
27
28
 
28
29
  export interface BasicTreeNodeProps {
@@ -415,7 +416,7 @@ export default class TreeFoundation extends BaseFoundation<TreeAdapter, BasicTre
415
416
 
416
417
  notifyJsonChange(key: string[] | string, e: any) {
417
418
  const data = this.getProp('treeDataSimpleJson');
418
- const selectedPath = normalizedArr(key).map(i => i.replace('-', '.'));
419
+ const selectedPath = normalizedArr(key).map(i => i.replaceAll(strings.JSON_KEY_SPLIT, '.'));
419
420
  const value = pick(data, selectedPath);
420
421
  this._adapter.notifyChange(value as BasicValue);
421
422
  }
package/tree/treeUtil.ts CHANGED
@@ -4,6 +4,7 @@
4
4
  */
5
5
 
6
6
  import { difference, uniq, max, isObject, isNull, isUndefined, isEmpty, pick, get, omit } from 'lodash';
7
+ import { strings } from './constants';
7
8
 
8
9
  export interface KeyEntities {
9
10
  [x: string]: any
@@ -98,7 +99,7 @@ export function convertJsonToData(treeJson: TreeDataSimpleJson) {
98
99
  const treeData: any[] = [];
99
100
  const traverseNode = (key: string, children: any, path: any, res: any[]) => {
100
101
  const currPath = [...path, key];
101
- const itemKey = currPath.join('-');
102
+ const itemKey = currPath.join(strings.JSON_KEY_SPLIT);
102
103
 
103
104
  const newNode: NodeData = {
104
105
  key: itemKey,