@canlooks/can-ui 0.0.171 → 0.0.172

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.
@@ -143,7 +143,7 @@ exports.Curd = (0, react_1.memo)((props) => {
143
143
  const setInnerRows = (data) => {
144
144
  setOptions?.(data);
145
145
  _setInnerRows(data);
146
- containerRef.current.scrollTop = 0;
146
+ containerRef.current.scrollTop = containerRef.current.scrollLeft = 0;
147
147
  };
148
148
  const [innerTotal, setInnerTotal] = (0, utils_1.useDerivedState)(props.paginationProps?.total || 0);
149
149
  const suppressReload = (0, react_1.useRef)(false);
@@ -89,7 +89,7 @@ exports.DataGrid = (0, react_1.memo)(({ slots, slotProps, columns, rows, rowProp
89
89
  return new Set(innerExpanded.current);
90
90
  }, [innerExpanded.current]);
91
91
  const syncOnExpandedChange = (0, utils_1.useSync)(onExpandedChange);
92
- const toggleExpanded = (0, react_1.useCallback)((key) => {
92
+ const toggleExpanded = (key) => {
93
93
  const currentExpanded = expandedSet.has(key);
94
94
  setInnerExpanded(o => {
95
95
  const newExpanded = currentExpanded
@@ -98,7 +98,7 @@ exports.DataGrid = (0, react_1.memo)(({ slots, slotProps, columns, rows, rowProp
98
98
  syncOnExpandedChange.current?.(newExpanded, key, !currentExpanded);
99
99
  return newExpanded;
100
100
  });
101
- }, []);
101
+ };
102
102
  /**
103
103
  * ---------------------------------------------------------------
104
104
  * 分页
@@ -17,6 +17,7 @@ const Sweeping = ({ ref, in: _in = false, orientation = 'vertical', collapsedSiz
17
17
  return typeof collapsedSize === 'function' ? collapsedSize() : collapsedSize;
18
18
  };
19
19
  const [size, setSize] = (0, react_1.useState)(() => !_in ? getCollapsedSize() : 'auto');
20
+ const [transiting, setTransiting] = (0, utils_1.useDerivedState)(true, [_in]);
20
21
  const getFullSize = () => {
21
22
  const el = innerRef.current;
22
23
  let size;
@@ -69,7 +70,13 @@ const Sweeping = ({ ref, in: _in = false, orientation = 'vertical', collapsedSiz
69
70
  : collapse();
70
71
  }, [_in]);
71
72
  return ((0, jsx_runtime_1.jsx)(transitionBase_1.TransitionBase, { ...props, ref: (0, utils_1.cloneRef)(ref, innerRef), in: _in, orientation: orientation, appear: appear, style: {
72
- [styleProperty]: size,
73
+ ...(transiting.current || !_in) && { [styleProperty]: size },
73
74
  ...props.style
75
+ }, onEntered: () => {
76
+ props.onEntered?.();
77
+ setTransiting(false);
78
+ }, onExited: () => {
79
+ props.onExited?.();
80
+ setTransiting(false);
74
81
  } }));
75
82
  };
@@ -140,7 +140,7 @@ export const Curd = memo((props) => {
140
140
  const setInnerRows = (data) => {
141
141
  setOptions?.(data);
142
142
  _setInnerRows(data);
143
- containerRef.current.scrollTop = 0;
143
+ containerRef.current.scrollTop = containerRef.current.scrollLeft = 0;
144
144
  };
145
145
  const [innerTotal, setInnerTotal] = useDerivedState(props.paginationProps?.total || 0);
146
146
  const suppressReload = useRef(false);
@@ -85,7 +85,7 @@ export const DataGrid = memo(({ slots, slotProps, columns, rows, rowProps, prima
85
85
  return new Set(innerExpanded.current);
86
86
  }, [innerExpanded.current]);
87
87
  const syncOnExpandedChange = useSync(onExpandedChange);
88
- const toggleExpanded = useCallback((key) => {
88
+ const toggleExpanded = (key) => {
89
89
  const currentExpanded = expandedSet.has(key);
90
90
  setInnerExpanded(o => {
91
91
  const newExpanded = currentExpanded
@@ -94,7 +94,7 @@ export const DataGrid = memo(({ slots, slotProps, columns, rows, rowProps, prima
94
94
  syncOnExpandedChange.current?.(newExpanded, key, !currentExpanded);
95
95
  return newExpanded;
96
96
  });
97
- }, []);
97
+ };
98
98
  /**
99
99
  * ---------------------------------------------------------------
100
100
  * 分页
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
2
2
  import { useLayoutEffect, useRef, useState } from 'react';
3
3
  import { TransitionBase } from './transitionBase.js';
4
- import { cloneRef, useUpdateEffect } from '../../utils/index.js';
4
+ import { cloneRef, useDerivedState, useUpdateEffect } from '../../utils/index.js';
5
5
  export const Collapse = ({ transitionType = 'sweeping', ...props }) => {
6
6
  const Component = transitionType === 'sweeping' ? Sweeping : TransitionBase;
7
7
  return (_jsx(Component, { ...props, _mode: transitionType === 'sweeping' ? '_sweeping' : 'collapse' }));
@@ -13,6 +13,7 @@ const Sweeping = ({ ref, in: _in = false, orientation = 'vertical', collapsedSiz
13
13
  return typeof collapsedSize === 'function' ? collapsedSize() : collapsedSize;
14
14
  };
15
15
  const [size, setSize] = useState(() => !_in ? getCollapsedSize() : 'auto');
16
+ const [transiting, setTransiting] = useDerivedState(true, [_in]);
16
17
  const getFullSize = () => {
17
18
  const el = innerRef.current;
18
19
  let size;
@@ -65,7 +66,13 @@ const Sweeping = ({ ref, in: _in = false, orientation = 'vertical', collapsedSiz
65
66
  : collapse();
66
67
  }, [_in]);
67
68
  return (_jsx(TransitionBase, { ...props, ref: cloneRef(ref, innerRef), in: _in, orientation: orientation, appear: appear, style: {
68
- [styleProperty]: size,
69
+ ...(transiting.current || !_in) && { [styleProperty]: size },
69
70
  ...props.style
71
+ }, onEntered: () => {
72
+ props.onEntered?.();
73
+ setTransiting(false);
74
+ }, onExited: () => {
75
+ props.onExited?.();
76
+ setTransiting(false);
70
77
  } }));
71
78
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canlooks/can-ui",
3
- "version": "0.0.171",
3
+ "version": "0.0.172",
4
4
  "author": "C.CanLiang <canlooks@gmail.com>",
5
5
  "description": "My ui framework",
6
6
  "license": "MIT",