@douyinfe/semi-ui 2.54.1 → 2.55.0-beta.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.
@@ -36,6 +36,6 @@ interface SortableItemProps {
36
36
  prefix?: string;
37
37
  transition?: SortableTransition | null;
38
38
  }
39
- export declare function Sortable({ items, onSortEnd, adjustScale, renderItem, transition, activationConstraint, collisionDetection, strategy, useDragOverlay, dragOverlayCls, container: Container, prefix, }: SortableProps): JSX.Element;
39
+ export declare function Sortable({ items, onSortEnd, adjustScale, renderItem, transition, collisionDetection, strategy, useDragOverlay, dragOverlayCls, container: Container, prefix, }: SortableProps): JSX.Element;
40
40
  export declare function SortableItem({ animateLayoutChanges, id, renderItem, prefix, transition: animation, }: SortableItemProps): JSX.Element;
41
41
  export {};
@@ -16,10 +16,6 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
16
16
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
17
17
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
18
18
  const defaultPrefix = 'semi-sortable';
19
- const defaultConstraint = {
20
- delay: 150,
21
- tolerance: 5
22
- };
23
19
  function DefaultContainer(props) {
24
20
  return /*#__PURE__*/_react.default.createElement("div", Object.assign({
25
21
  style: {
@@ -27,6 +23,9 @@ function DefaultContainer(props) {
27
23
  }
28
24
  }, props));
29
25
  }
26
+ const defaultKeyBoardOptions = {
27
+ coordinateGetter: _sortable.sortableKeyboardCoordinates
28
+ };
30
29
  function Sortable(_ref) {
31
30
  let {
32
31
  items,
@@ -34,7 +33,6 @@ function Sortable(_ref) {
34
33
  adjustScale,
35
34
  renderItem,
36
35
  transition,
37
- activationConstraint = defaultConstraint,
38
36
  collisionDetection = _core.closestCenter,
39
37
  strategy = _sortable.rectSortingStrategy,
40
38
  useDragOverlay = true,
@@ -43,13 +41,7 @@ function Sortable(_ref) {
43
41
  prefix = defaultPrefix
44
42
  } = _ref;
45
43
  const [activeId, setActiveId] = (0, _react.useState)(null);
46
- const sensors = (0, _core.useSensors)((0, _core.useSensor)(_core.MouseSensor, {
47
- activationConstraint
48
- }), (0, _core.useSensor)(_core.TouchSensor, {
49
- activationConstraint
50
- }), (0, _core.useSensor)(_core.KeyboardSensor, {
51
- coordinateGetter: _sortable.sortableKeyboardCoordinates
52
- }));
44
+ const sensors = (0, _core.useSensors)((0, _core.useSensor)(_core.MouseSensor), (0, _core.useSensor)(_core.TouchSensor), (0, _core.useSensor)(_core.KeyboardSensor, defaultKeyBoardOptions));
53
45
  const getIndex = (0, _react.useCallback)(id => items.indexOf(id), [items]);
54
46
  const activeIndex = (0, _react.useMemo)(() => activeId ? getIndex(activeId) : -1, [getIndex, activeId]);
55
47
  const onDragStart = (0, _react.useCallback)(_ref2 => {
@@ -159,13 +151,15 @@ function SortableItem(_ref4) {
159
151
  [`${prefix}-sortable-item-over`]: isOver,
160
152
  [`${prefix}-sortable-item-active`]: (active === null || active === void 0 ? void 0 : active.id) === id
161
153
  });
162
- const wrapperStyle = !(0, _isNull2.default)(animation) ? {
163
- transform: _utilities.CSS.Transform.toString(Object.assign(Object.assign({}, transform), {
164
- scaleX: 1,
165
- scaleY: 1
166
- })),
167
- transition: transition
168
- } : undefined;
154
+ const wrapperStyle = (0, _react.useMemo)(() => {
155
+ return !(0, _isNull2.default)(animation) ? {
156
+ transform: _utilities.CSS.Transform.toString(Object.assign(Object.assign({}, transform), {
157
+ scaleX: 1,
158
+ scaleY: 1
159
+ })),
160
+ transition: transition
161
+ } : undefined;
162
+ }, [animation, transform, transition]);
169
163
  return /*#__PURE__*/_react.default.createElement("div", Object.assign({
170
164
  ref: setNodeRef,
171
165
  style: wrapperStyle,
@@ -1,7 +1,7 @@
1
1
  import BaseComponent, { BaseProps } from '../_base/baseComponent';
2
2
  import React, { ReactElement, ReactNode } from 'react';
3
3
  import PropTypes from 'prop-types';
4
- import { NavigationAdapter } from '@douyinfe/semi-foundation/lib/cjs/navigation/foundation';
4
+ import NavigationFoundation, { NavigationAdapter } from '@douyinfe/semi-foundation/lib/cjs/navigation/foundation';
5
5
  import SubNav, { SubNavProps } from './SubNav';
6
6
  import Item, { NavItemProps } from './Item';
7
7
  import Footer, { NavFooterProps } from './Footer';
@@ -122,6 +122,7 @@ declare class Nav extends BaseComponent<NavProps, NavState> {
122
122
  static __SemiComponentName__: string;
123
123
  static defaultProps: any;
124
124
  itemsChanged: boolean;
125
+ foundation: NavigationFoundation;
125
126
  constructor(props: NavProps);
126
127
  static getDerivedStateFromProps(props: NavProps, state: NavState): Partial<NavState>;
127
128
  componentDidMount(): void;
@@ -48,6 +48,7 @@ declare class Tabs extends BaseComponent<TabsProps, TabsState> {
48
48
  static getDerivedStateFromProps(props: TabsProps, state: TabsState): Partial<TabsState>;
49
49
  componentDidUpdate(prevProps: TabsProps, prevState: TabsState): void;
50
50
  setContentRef: RefCallback<HTMLDivElement>;
51
+ getPanes: () => PlainTab[];
51
52
  onTabClick: (activeKey: string, event: MouseEvent<HTMLDivElement>) => void;
52
53
  rePosChildren: (children: ReactElement[], activeKey: string) => ReactElement[];
53
54
  getActiveItem: () => ReactNode | ReactNode[];
@@ -52,6 +52,34 @@ class Tabs extends _baseComponent.default {
52
52
  current: ref
53
53
  };
54
54
  };
55
+ this.getPanes = () => {
56
+ const {
57
+ tabList,
58
+ children
59
+ } = this.props;
60
+ if (Array.isArray(tabList) && tabList.length) {
61
+ return tabList;
62
+ }
63
+ return _react.default.Children.map(children, child => {
64
+ if (child) {
65
+ const {
66
+ tab,
67
+ icon,
68
+ disabled,
69
+ itemKey,
70
+ closable
71
+ } = child.props;
72
+ return {
73
+ tab,
74
+ icon,
75
+ disabled,
76
+ itemKey,
77
+ closable
78
+ };
79
+ }
80
+ return undefined;
81
+ });
82
+ };
55
83
  this.onTabClick = (activeKey, event) => {
56
84
  this.foundation.handleTabClick(activeKey, event);
57
85
  };
@@ -90,7 +118,7 @@ class Tabs extends _baseComponent.default {
90
118
  this.foundation = new _foundation.default(this.adapter);
91
119
  this.state = {
92
120
  activeKey: this.foundation.getDefaultActiveKey(),
93
- panes: [],
121
+ panes: this.getPanes(),
94
122
  prevActiveKey: null,
95
123
  forceDisableMotion: false
96
124
  };
@@ -100,41 +128,12 @@ class Tabs extends _baseComponent.default {
100
128
  get adapter() {
101
129
  return Object.assign(Object.assign({}, super.adapter), {
102
130
  collectPane: () => {
103
- const {
104
- tabList,
105
- children
106
- } = this.props;
107
- if (Array.isArray(tabList) && tabList.length) {
108
- this.setState({
109
- panes: tabList
110
- });
111
- return;
112
- }
113
- const panes = _react.default.Children.map(children, child => {
114
- if (child) {
115
- const {
116
- tab,
117
- icon,
118
- disabled,
119
- itemKey,
120
- closable
121
- } = child.props;
122
- return {
123
- tab,
124
- icon,
125
- disabled,
126
- itemKey,
127
- closable
128
- };
129
- }
130
- return undefined;
131
- });
131
+ const panes = this.getPanes();
132
132
  this.setState({
133
133
  panes
134
134
  });
135
135
  },
136
136
  collectActiveKey: () => {
137
- let panes = [];
138
137
  const {
139
138
  tabList,
140
139
  children,
@@ -146,29 +145,7 @@ class Tabs extends _baseComponent.default {
146
145
  const {
147
146
  activeKey
148
147
  } = this.state;
149
- if (Array.isArray(tabList) && tabList.length) {
150
- panes = tabList;
151
- } else {
152
- panes = _react.default.Children.map(children, child => {
153
- if (child) {
154
- const {
155
- tab,
156
- icon,
157
- disabled,
158
- itemKey,
159
- closable
160
- } = child.props;
161
- return {
162
- tab,
163
- icon,
164
- disabled,
165
- itemKey,
166
- closable
167
- };
168
- }
169
- return undefined;
170
- });
171
- }
148
+ const panes = this.getPanes();
172
149
  if (panes.findIndex(p => p.itemKey === activeKey) === -1) {
173
150
  if (panes.length > 0) {
174
151
  this.setState({
@@ -36,6 +36,6 @@ interface SortableItemProps {
36
36
  prefix?: string;
37
37
  transition?: SortableTransition | null;
38
38
  }
39
- export declare function Sortable({ items, onSortEnd, adjustScale, renderItem, transition, activationConstraint, collisionDetection, strategy, useDragOverlay, dragOverlayCls, container: Container, prefix, }: SortableProps): JSX.Element;
39
+ export declare function Sortable({ items, onSortEnd, adjustScale, renderItem, transition, collisionDetection, strategy, useDragOverlay, dragOverlayCls, container: Container, prefix, }: SortableProps): JSX.Element;
40
40
  export declare function SortableItem({ animateLayoutChanges, id, renderItem, prefix, transition: animation, }: SortableItemProps): JSX.Element;
41
41
  export {};
@@ -6,10 +6,6 @@ import cls from 'classnames';
6
6
  import { closestCenter, DragOverlay, DndContext, MouseSensor, TouchSensor, useSensor, useSensors, KeyboardSensor, TraversalOrder } from '@dnd-kit/core';
7
7
  import { useSortable, SortableContext, rectSortingStrategy, sortableKeyboardCoordinates } from '@dnd-kit/sortable';
8
8
  const defaultPrefix = 'semi-sortable';
9
- const defaultConstraint = {
10
- delay: 150,
11
- tolerance: 5
12
- };
13
9
  function DefaultContainer(props) {
14
10
  return /*#__PURE__*/React.createElement("div", Object.assign({
15
11
  style: {
@@ -17,6 +13,9 @@ function DefaultContainer(props) {
17
13
  }
18
14
  }, props));
19
15
  }
16
+ const defaultKeyBoardOptions = {
17
+ coordinateGetter: sortableKeyboardCoordinates
18
+ };
20
19
  export function Sortable(_ref) {
21
20
  let {
22
21
  items,
@@ -24,7 +23,6 @@ export function Sortable(_ref) {
24
23
  adjustScale,
25
24
  renderItem,
26
25
  transition,
27
- activationConstraint = defaultConstraint,
28
26
  collisionDetection = closestCenter,
29
27
  strategy = rectSortingStrategy,
30
28
  useDragOverlay = true,
@@ -33,13 +31,7 @@ export function Sortable(_ref) {
33
31
  prefix = defaultPrefix
34
32
  } = _ref;
35
33
  const [activeId, setActiveId] = useState(null);
36
- const sensors = useSensors(useSensor(MouseSensor, {
37
- activationConstraint
38
- }), useSensor(TouchSensor, {
39
- activationConstraint
40
- }), useSensor(KeyboardSensor, {
41
- coordinateGetter: sortableKeyboardCoordinates
42
- }));
34
+ const sensors = useSensors(useSensor(MouseSensor), useSensor(TouchSensor), useSensor(KeyboardSensor, defaultKeyBoardOptions));
43
35
  const getIndex = useCallback(id => items.indexOf(id), [items]);
44
36
  const activeIndex = useMemo(() => activeId ? getIndex(activeId) : -1, [getIndex, activeId]);
45
37
  const onDragStart = useCallback(_ref2 => {
@@ -149,13 +141,15 @@ export function SortableItem(_ref4) {
149
141
  [`${prefix}-sortable-item-over`]: isOver,
150
142
  [`${prefix}-sortable-item-active`]: (active === null || active === void 0 ? void 0 : active.id) === id
151
143
  });
152
- const wrapperStyle = !_isNull(animation) ? {
153
- transform: cssDndKit.Transform.toString(Object.assign(Object.assign({}, transform), {
154
- scaleX: 1,
155
- scaleY: 1
156
- })),
157
- transition: transition
158
- } : undefined;
144
+ const wrapperStyle = useMemo(() => {
145
+ return !_isNull(animation) ? {
146
+ transform: cssDndKit.Transform.toString(Object.assign(Object.assign({}, transform), {
147
+ scaleX: 1,
148
+ scaleY: 1
149
+ })),
150
+ transition: transition
151
+ } : undefined;
152
+ }, [animation, transform, transition]);
159
153
  return /*#__PURE__*/React.createElement("div", Object.assign({
160
154
  ref: setNodeRef,
161
155
  style: wrapperStyle,
@@ -1,7 +1,7 @@
1
1
  import BaseComponent, { BaseProps } from '../_base/baseComponent';
2
2
  import React, { ReactElement, ReactNode } from 'react';
3
3
  import PropTypes from 'prop-types';
4
- import { NavigationAdapter } from '@douyinfe/semi-foundation/lib/es/navigation/foundation';
4
+ import NavigationFoundation, { NavigationAdapter } from '@douyinfe/semi-foundation/lib/es/navigation/foundation';
5
5
  import SubNav, { SubNavProps } from './SubNav';
6
6
  import Item, { NavItemProps } from './Item';
7
7
  import Footer, { NavFooterProps } from './Footer';
@@ -122,6 +122,7 @@ declare class Nav extends BaseComponent<NavProps, NavState> {
122
122
  static __SemiComponentName__: string;
123
123
  static defaultProps: any;
124
124
  itemsChanged: boolean;
125
+ foundation: NavigationFoundation;
125
126
  constructor(props: NavProps);
126
127
  static getDerivedStateFromProps(props: NavProps, state: NavState): Partial<NavState>;
127
128
  componentDidMount(): void;
@@ -48,6 +48,7 @@ declare class Tabs extends BaseComponent<TabsProps, TabsState> {
48
48
  static getDerivedStateFromProps(props: TabsProps, state: TabsState): Partial<TabsState>;
49
49
  componentDidUpdate(prevProps: TabsProps, prevState: TabsState): void;
50
50
  setContentRef: RefCallback<HTMLDivElement>;
51
+ getPanes: () => PlainTab[];
51
52
  onTabClick: (activeKey: string, event: MouseEvent<HTMLDivElement>) => void;
52
53
  rePosChildren: (children: ReactElement[], activeKey: string) => ReactElement[];
53
54
  getActiveItem: () => ReactNode | ReactNode[];
@@ -31,6 +31,34 @@ class Tabs extends BaseComponent {
31
31
  current: ref
32
32
  };
33
33
  };
34
+ this.getPanes = () => {
35
+ const {
36
+ tabList,
37
+ children
38
+ } = this.props;
39
+ if (Array.isArray(tabList) && tabList.length) {
40
+ return tabList;
41
+ }
42
+ return React.Children.map(children, child => {
43
+ if (child) {
44
+ const {
45
+ tab,
46
+ icon,
47
+ disabled,
48
+ itemKey,
49
+ closable
50
+ } = child.props;
51
+ return {
52
+ tab,
53
+ icon,
54
+ disabled,
55
+ itemKey,
56
+ closable
57
+ };
58
+ }
59
+ return undefined;
60
+ });
61
+ };
34
62
  this.onTabClick = (activeKey, event) => {
35
63
  this.foundation.handleTabClick(activeKey, event);
36
64
  };
@@ -69,7 +97,7 @@ class Tabs extends BaseComponent {
69
97
  this.foundation = new TabsFoundation(this.adapter);
70
98
  this.state = {
71
99
  activeKey: this.foundation.getDefaultActiveKey(),
72
- panes: [],
100
+ panes: this.getPanes(),
73
101
  prevActiveKey: null,
74
102
  forceDisableMotion: false
75
103
  };
@@ -79,41 +107,12 @@ class Tabs extends BaseComponent {
79
107
  get adapter() {
80
108
  return Object.assign(Object.assign({}, super.adapter), {
81
109
  collectPane: () => {
82
- const {
83
- tabList,
84
- children
85
- } = this.props;
86
- if (Array.isArray(tabList) && tabList.length) {
87
- this.setState({
88
- panes: tabList
89
- });
90
- return;
91
- }
92
- const panes = React.Children.map(children, child => {
93
- if (child) {
94
- const {
95
- tab,
96
- icon,
97
- disabled,
98
- itemKey,
99
- closable
100
- } = child.props;
101
- return {
102
- tab,
103
- icon,
104
- disabled,
105
- itemKey,
106
- closable
107
- };
108
- }
109
- return undefined;
110
- });
110
+ const panes = this.getPanes();
111
111
  this.setState({
112
112
  panes
113
113
  });
114
114
  },
115
115
  collectActiveKey: () => {
116
- let panes = [];
117
116
  const {
118
117
  tabList,
119
118
  children,
@@ -125,29 +124,7 @@ class Tabs extends BaseComponent {
125
124
  const {
126
125
  activeKey
127
126
  } = this.state;
128
- if (Array.isArray(tabList) && tabList.length) {
129
- panes = tabList;
130
- } else {
131
- panes = React.Children.map(children, child => {
132
- if (child) {
133
- const {
134
- tab,
135
- icon,
136
- disabled,
137
- itemKey,
138
- closable
139
- } = child.props;
140
- return {
141
- tab,
142
- icon,
143
- disabled,
144
- itemKey,
145
- closable
146
- };
147
- }
148
- return undefined;
149
- });
150
- }
127
+ const panes = this.getPanes();
151
128
  if (panes.findIndex(p => p.itemKey === activeKey) === -1) {
152
129
  if (panes.length > 0) {
153
130
  this.setState({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@douyinfe/semi-ui",
3
- "version": "2.54.1",
3
+ "version": "2.55.0-beta.0",
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.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",
23
+ "@douyinfe/semi-animation": "2.55.0-beta.0",
24
+ "@douyinfe/semi-animation-react": "2.55.0-beta.0",
25
+ "@douyinfe/semi-foundation": "2.55.0-beta.0",
26
+ "@douyinfe/semi-icons": "2.55.0-beta.0",
27
+ "@douyinfe/semi-illustrations": "2.55.0-beta.0",
28
+ "@douyinfe/semi-theme-default": "2.55.0-beta.0",
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": "29a9d7e115640dd1e9d8559609d9e4ee44dcfd12",
78
+ "gitHead": "1b20ba60f41785e247a71987235b5f3bbd577ff0",
79
79
  "devDependencies": {
80
80
  "@babel/plugin-proposal-decorators": "^7.15.8",
81
81
  "@babel/plugin-transform-runtime": "^7.15.8",