@douyinfe/semi-ui 2.54.0 → 2.54.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.
@@ -125,7 +125,7 @@ declare class Nav extends BaseComponent<NavProps, NavState> {
125
125
  constructor(props: NavProps);
126
126
  static getDerivedStateFromProps(props: NavProps, state: NavState): Partial<NavState>;
127
127
  componentDidMount(): void;
128
- componentDidUpdate(prevProps: NavProps, prevState: NavState): void;
128
+ componentDidUpdate(prevProps: NavProps): void;
129
129
  get adapter(): NavigationAdapter<NavProps, NavState>;
130
130
  /**
131
131
  * Render navigation items recursively
@@ -97,24 +97,19 @@ class Nav extends _baseComponent.default {
97
97
  componentDidMount() {
98
98
  // override BaseComponent
99
99
  }
100
- componentDidUpdate(prevProps, prevState) {
100
+ componentDidUpdate(prevProps) {
101
101
  if (prevProps.items !== this.props.items || prevProps.children !== this.props.children) {
102
102
  this.foundation.init();
103
103
  } else {
104
104
  this.foundation.handleItemsChange(false);
105
- const {
106
- selectedKeys
107
- } = this.state;
108
105
  if (this.props.selectedKeys && !(0, _isEqual2.default)(prevProps.selectedKeys, this.props.selectedKeys)) {
109
106
  this.adapter.updateSelectedKeys(this.props.selectedKeys);
107
+ const willOpenKeys = this.foundation.getWillOpenKeys(this.state.itemKeysMap);
108
+ this.adapter.updateOpenKeys(willOpenKeys);
110
109
  }
111
110
  if (this.props.openKeys && !(0, _isEqual2.default)(prevProps.openKeys, this.props.openKeys)) {
112
111
  this.adapter.updateOpenKeys(this.props.openKeys);
113
112
  }
114
- if (!(0, _isEqual2.default)(selectedKeys, prevState.selectedKeys)) {
115
- const parentSelectKeys = this.foundation.selectLevelZeroParentKeys(null, ...selectedKeys);
116
- this.adapter.addSelectedKeys(...parentSelectKeys);
117
- }
118
113
  }
119
114
  }
120
115
  get adapter() {
@@ -140,9 +135,20 @@ class Nav extends _baseComponent.default {
140
135
  }),
141
136
  addSelectedKeys: createAddKeysFn(this, 'selectedKeys'),
142
137
  removeSelectedKeys: createRemoveKeysFn(this, 'selectedKeys'),
143
- updateSelectedKeys: selectedKeys => this.setState({
144
- selectedKeys: [...selectedKeys]
145
- }),
138
+ /**
139
+ * when `includeParentKeys` is `true`, select a nested nav item will select parent nav sub
140
+ */
141
+ updateSelectedKeys: function (selectedKeys) {
142
+ let includeParentKeys = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
143
+ let willUpdateSelectedKeys = selectedKeys;
144
+ if (includeParentKeys) {
145
+ const parentSelectKeys = _this.foundation.selectLevelZeroParentKeys(null, selectedKeys);
146
+ willUpdateSelectedKeys = Array.from(new Set(selectedKeys.concat(parentSelectKeys)));
147
+ }
148
+ _this.setState({
149
+ selectedKeys: willUpdateSelectedKeys
150
+ });
151
+ },
146
152
  updateOpenKeys: openKeys => this.setState({
147
153
  openKeys: [...openKeys]
148
154
  }),
@@ -125,7 +125,7 @@ declare class Nav extends BaseComponent<NavProps, NavState> {
125
125
  constructor(props: NavProps);
126
126
  static getDerivedStateFromProps(props: NavProps, state: NavState): Partial<NavState>;
127
127
  componentDidMount(): void;
128
- componentDidUpdate(prevProps: NavProps, prevState: NavState): void;
128
+ componentDidUpdate(prevProps: NavProps): void;
129
129
  get adapter(): NavigationAdapter<NavProps, NavState>;
130
130
  /**
131
131
  * Render navigation items recursively
@@ -88,24 +88,19 @@ class Nav extends BaseComponent {
88
88
  componentDidMount() {
89
89
  // override BaseComponent
90
90
  }
91
- componentDidUpdate(prevProps, prevState) {
91
+ componentDidUpdate(prevProps) {
92
92
  if (prevProps.items !== this.props.items || prevProps.children !== this.props.children) {
93
93
  this.foundation.init();
94
94
  } else {
95
95
  this.foundation.handleItemsChange(false);
96
- const {
97
- selectedKeys
98
- } = this.state;
99
96
  if (this.props.selectedKeys && !_isEqual(prevProps.selectedKeys, this.props.selectedKeys)) {
100
97
  this.adapter.updateSelectedKeys(this.props.selectedKeys);
98
+ const willOpenKeys = this.foundation.getWillOpenKeys(this.state.itemKeysMap);
99
+ this.adapter.updateOpenKeys(willOpenKeys);
101
100
  }
102
101
  if (this.props.openKeys && !_isEqual(prevProps.openKeys, this.props.openKeys)) {
103
102
  this.adapter.updateOpenKeys(this.props.openKeys);
104
103
  }
105
- if (!_isEqual(selectedKeys, prevState.selectedKeys)) {
106
- const parentSelectKeys = this.foundation.selectLevelZeroParentKeys(null, ...selectedKeys);
107
- this.adapter.addSelectedKeys(...parentSelectKeys);
108
- }
109
104
  }
110
105
  }
111
106
  get adapter() {
@@ -131,9 +126,20 @@ class Nav extends BaseComponent {
131
126
  }),
132
127
  addSelectedKeys: createAddKeysFn(this, 'selectedKeys'),
133
128
  removeSelectedKeys: createRemoveKeysFn(this, 'selectedKeys'),
134
- updateSelectedKeys: selectedKeys => this.setState({
135
- selectedKeys: [...selectedKeys]
136
- }),
129
+ /**
130
+ * when `includeParentKeys` is `true`, select a nested nav item will select parent nav sub
131
+ */
132
+ updateSelectedKeys: function (selectedKeys) {
133
+ let includeParentKeys = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
134
+ let willUpdateSelectedKeys = selectedKeys;
135
+ if (includeParentKeys) {
136
+ const parentSelectKeys = _this.foundation.selectLevelZeroParentKeys(null, selectedKeys);
137
+ willUpdateSelectedKeys = Array.from(new Set(selectedKeys.concat(parentSelectKeys)));
138
+ }
139
+ _this.setState({
140
+ selectedKeys: willUpdateSelectedKeys
141
+ });
142
+ },
137
143
  updateOpenKeys: openKeys => this.setState({
138
144
  openKeys: [...openKeys]
139
145
  }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@douyinfe/semi-ui",
3
- "version": "2.54.0",
3
+ "version": "2.54.1",
4
4
  "description": "A modern, comprehensive, flexible design system and UI library. Connect DesignOps & DevOps. Quickly build beautiful React apps. Maintained by Douyin-fe team.",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/es/index.js",
@@ -20,12 +20,12 @@
20
20
  "@dnd-kit/core": "^6.0.8",
21
21
  "@dnd-kit/sortable": "^7.0.2",
22
22
  "@dnd-kit/utilities": "^3.2.1",
23
- "@douyinfe/semi-animation": "2.54.0",
24
- "@douyinfe/semi-animation-react": "2.54.0",
25
- "@douyinfe/semi-foundation": "2.54.0",
26
- "@douyinfe/semi-icons": "2.54.0",
27
- "@douyinfe/semi-illustrations": "2.54.0",
28
- "@douyinfe/semi-theme-default": "2.54.0",
23
+ "@douyinfe/semi-animation": "2.54.1",
24
+ "@douyinfe/semi-animation-react": "2.54.1",
25
+ "@douyinfe/semi-foundation": "2.54.1",
26
+ "@douyinfe/semi-icons": "2.54.1",
27
+ "@douyinfe/semi-illustrations": "2.54.1",
28
+ "@douyinfe/semi-theme-default": "2.54.1",
29
29
  "async-validator": "^3.5.0",
30
30
  "classnames": "^2.2.6",
31
31
  "copy-text-to-clipboard": "^2.1.1",
@@ -75,7 +75,7 @@
75
75
  ],
76
76
  "author": "",
77
77
  "license": "MIT",
78
- "gitHead": "30c24d26549ecb166625ef4f0a731235b71968fc",
78
+ "gitHead": "29a9d7e115640dd1e9d8559609d9e4ee44dcfd12",
79
79
  "devDependencies": {
80
80
  "@babel/plugin-proposal-decorators": "^7.15.8",
81
81
  "@babel/plugin-transform-runtime": "^7.15.8",