@canlooks/can-ui 0.0.168 → 0.0.170

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.
Files changed (29) hide show
  1. package/dist/cjs/components/curd/curdColumnConfig.d.ts +4 -4
  2. package/dist/cjs/components/curd/curdColumnConfig.js +3 -3
  3. package/dist/cjs/components/tabs/tab.d.ts +4 -2
  4. package/dist/cjs/components/tabs/tab.js +15 -15
  5. package/dist/cjs/components/tabs/tabs.js +7 -6
  6. package/dist/cjs/components/tabs/tabs.style.d.ts +1 -0
  7. package/dist/cjs/components/tabs/tabs.style.js +16 -7
  8. package/dist/cjs/components/transitionBase/collapse.d.ts +1 -1
  9. package/dist/cjs/components/transitionBase/collapse.js +41 -30
  10. package/dist/cjs/components/transitionBase/transitionBase.js +7 -2
  11. package/dist/cjs/components/transitionBase/transitionBase.style.d.ts +3 -3
  12. package/dist/cjs/components/transitionBase/transitionBase.style.js +82 -99
  13. package/dist/cjs/utils/curd.d.ts +3 -3
  14. package/dist/cjs/utils/curd.js +3 -21
  15. package/dist/esm/components/curd/curdColumnConfig.d.ts +4 -4
  16. package/dist/esm/components/curd/curdColumnConfig.js +3 -3
  17. package/dist/esm/components/tabs/tab.d.ts +4 -2
  18. package/dist/esm/components/tabs/tab.js +15 -15
  19. package/dist/esm/components/tabs/tabs.js +8 -7
  20. package/dist/esm/components/tabs/tabs.style.d.ts +1 -0
  21. package/dist/esm/components/tabs/tabs.style.js +16 -7
  22. package/dist/esm/components/transitionBase/collapse.d.ts +1 -1
  23. package/dist/esm/components/transitionBase/collapse.js +43 -32
  24. package/dist/esm/components/transitionBase/transitionBase.js +9 -4
  25. package/dist/esm/components/transitionBase/transitionBase.style.d.ts +3 -3
  26. package/dist/esm/components/transitionBase/transitionBase.style.js +80 -98
  27. package/dist/esm/utils/curd.d.ts +3 -3
  28. package/dist/esm/utils/curd.js +3 -21
  29. package/package.json +1 -1
@@ -6,6 +6,7 @@ export function useTransitionBaseStyle({ timeout }) {
6
6
  return useCss(() => css `
7
7
  @layer reset {
8
8
  ${timeoutIsNumber ? `transition-duration: ${timeout}ms;` : ''}
9
+
9
10
  &.appear-active {
10
11
  ${!timeoutIsNumber ? `transition-duration: ${timeout.appear}ms;` : ''}
11
12
  }
@@ -22,126 +23,107 @@ export function useTransitionBaseStyle({ timeout }) {
22
23
  }
23
24
  export const fadeStyle = defineCss(({ easing }) => css `
24
25
  @layer reset {
25
- transition-property: opacity;
26
- transition-timing-function: ${easing.easeOut};
27
-
28
- &,
29
26
  &.appear,
30
- &.enter {
27
+ &.exit,
28
+ &.exit-done {
31
29
  opacity: 0;
32
30
  }
33
-
31
+
34
32
  &.appear-active,
35
- &.enter-active,
36
- &.enter-done,
37
- &.exit {
33
+ &.enter,
34
+ &.enter-done {
38
35
  opacity: 1;
39
36
  }
40
37
 
41
- &.exit-active,
42
- &.exit-done {
43
- opacity: 0;
44
- }
45
- }
46
- `);
47
- export const sweepingStyle = defineCss(({ easing }) => css `
48
- @layer reset {
49
- transition-property: opacity, width, height;
50
-
51
38
  &.appear-active,
52
39
  &.enter-active,
53
- &.enter-done {
54
- transition-timing-function: ${easing.easeOut}, ${easing.bounce}, ${easing.bounce};
55
- }
56
-
57
- &.exit-active,
58
- &.exit-done {
40
+ &.exit-active {
41
+ transition-property: opacity;
59
42
  transition-timing-function: ${easing.easeOut};
60
43
  }
61
44
  }
62
45
  `);
46
+ export function useSweepingStyle({ orientation }) {
47
+ return useCss(() => css `
48
+ @layer reset {
49
+ &.appear,
50
+ &.appear-active,
51
+ &.enter-active,
52
+ &.exit,
53
+ &.exit-active,
54
+ &.exit-done {
55
+ overflow: hidden;
56
+ }
57
+
58
+ &.appear-active,
59
+ &.enter-active,
60
+ &.exit-active {
61
+ transition-property: opacity, width, height;
62
+ }
63
+ }
64
+ `, [orientation]);
65
+ }
63
66
  export function useGrowAndCollapseStyle({ orientation, _mode }) {
64
- return useCss(({ easing }) => {
65
- let transformMethod = _mode === 'grow'
66
- ? 'scale'
67
- : orientation === 'vertical'
68
- ? 'scaleY'
69
- : 'scaleX';
70
- return css `
71
- @layer reset {
72
- transition-property: opacity, transform;
73
- ${_mode === 'collapse' ? `transform-origin: ${orientation === 'vertical' ? 'top' : 'left'};` : ''}
74
- &,
75
- &.appear,
76
- &.enter {
77
- transform: ${transformMethod}(0);
78
- }
79
-
80
- &.appear-active,
81
- &.enter-active,
82
- &.enter-done,
83
- &.exit {
84
- transform: scale(1);
85
- }
67
+ let transformMethod = _mode === 'grow'
68
+ ? 'scale'
69
+ : orientation === 'vertical'
70
+ ? 'scaleY'
71
+ : 'scaleX';
72
+ return useCss(() => css `
73
+ @layer reset {
74
+ ${_mode === 'collapse' ? `transform-origin: ${orientation === 'vertical' ? 'top' : 'left'};` : ''}
86
75
 
87
- &.exit-active,
88
- &.exit-done {
89
- transform: ${transformMethod}(0);
90
- }
76
+ transition-property: opacity, transform;
91
77
 
92
- &.appear-active,
93
- &.enter-active {
94
- transition-timing-function: ${easing.easeOut}, ${easing.bounce};
95
- }
78
+ &.appear,
79
+ &.exit,
80
+ &.exit-done {
81
+ transform: ${transformMethod}(0);
82
+ }
96
83
 
97
- &.exit-active {
98
- transition-timing-function: ${easing.easeOut};
99
- }
84
+ &.appear-active,
85
+ &.enter,
86
+ &.enter-done {
87
+ transform: scale(1);
100
88
  }
101
- `;
102
- }, [orientation, _mode]);
89
+
90
+ &.appear-active,
91
+ &.enter-active,
92
+ &.exit-active {
93
+ transition-property: opacity, transform;
94
+ }
95
+ }
96
+ `, [orientation, _mode]);
103
97
  }
104
98
  export function useSlideStyle({ direction, offset }) {
105
- return useCss(({ easing }) => {
106
- const transformMethod = direction === 'up' || direction === 'down' ? 'translateY' : 'translateX';
107
- let offsetValue = typeof offset === 'number' ? `${offset}px` : offset;
108
- if (direction === 'down' || direction === 'right') {
109
- offsetValue = '-' + offsetValue;
110
- }
111
- return css `
112
- @layer reset {
113
- transition-property: opacity, transform;
114
-
115
- &,
116
- &.appear,
117
- &.enter {
118
- pointer-events: none;
119
- transform: ${transformMethod}(${offsetValue});
120
- }
121
-
122
- &.appear-active,
123
- &.enter-active,
124
- &.enter-done,
125
- &.exit {
126
- pointer-events: inherit;
127
- transform: translate(0);
128
- }
99
+ const transformMethod = direction === 'up' || direction === 'down' ? 'translateY' : 'translateX';
100
+ let offsetValue = typeof offset === 'number' ? `${offset}px` : offset;
101
+ if (direction === 'down' || direction === 'right') {
102
+ offsetValue = '-' + offsetValue;
103
+ }
104
+ return useCss(() => css `
105
+ @layer reset {
106
+ transition-property: opacity, transform;
129
107
 
130
- &.exit-active,
131
- &.exit-done {
132
- pointer-events: none;
133
- transform: ${transformMethod}(${offsetValue});
134
- }
108
+ &.appear,
109
+ &.exit,
110
+ &.exit-done {
111
+ pointer-events: none;
112
+ transform: ${transformMethod}(${offsetValue});
113
+ }
135
114
 
136
- &.appear-active,
137
- &.enter-active {
138
- transition-timing-function: ${easing.easeOut}, ${easing.bounce};
139
- }
115
+ &.appear-active,
116
+ &.enter,
117
+ &.enter-done {
118
+ pointer-events: inherit;
119
+ transform: translate(0);
120
+ }
140
121
 
141
- &.exit-active {
142
- transition-timing-function: ${easing.easeOut};
143
- }
122
+ &.appear-active,
123
+ &.enter-active,
124
+ &.exit-active {
125
+ transition-property: opacity, transform;
144
126
  }
145
- `;
146
- }, [direction, offset]);
127
+ }
128
+ `, [direction, offset]);
147
129
  }
@@ -21,7 +21,7 @@ export declare const CONTROL_COLUMN_KEY = "$control";
21
21
  export declare function useCurdColumns<R extends RowType, V extends Id = Id>({ columns, columnConfigurable }: Pick<CurdProps<R, FormValue, V>, 'columns' | 'columnConfigurable'>): {
22
22
  orderedColumns: any[];
23
23
  actualColumns: (symbol | ColumnType<R>)[];
24
- innerVisible: import("react").RefObject<Id[]>;
25
- setInnerVisible: import("react").Dispatch<import("react").SetStateAction<Id[]>>;
26
- setInnerOrder: import("react").Dispatch<import("react").SetStateAction<Id[]>>;
24
+ innerVisible: import("react").RefObject<Id[] | undefined>;
25
+ setInnerVisible: import("react").Dispatch<import("react").SetStateAction<Id[] | undefined>>;
26
+ setInnerOrder: import("react").Dispatch<import("react").SetStateAction<Id[] | undefined>>;
27
27
  };
@@ -63,24 +63,6 @@ export function useCurdColumns({ columns, columnConfigurable }) {
63
63
  columnConfigurable = {};
64
64
  }
65
65
  let { defaultVisible, visible, onVisibleChange, defaultOrder, order, onOrderChange } = columnConfigurable;
66
- if (!defaultVisible || !defaultOrder) {
67
- let hasControlColumn = false;
68
- const defaultKeys = columns?.flatMap((col) => {
69
- if (col.hideInTable) {
70
- return [];
71
- }
72
- if (col._key) {
73
- if (col._key === CONTROL_COLUMN_KEY) {
74
- hasControlColumn = true;
75
- }
76
- return col._key;
77
- }
78
- return [];
79
- }) || [];
80
- !hasControlColumn && defaultKeys.push(CONTROL_COLUMN_KEY);
81
- defaultVisible ||= defaultKeys;
82
- defaultOrder ||= defaultKeys;
83
- }
84
66
  const [innerOrder, setInnerOrder] = useControlled(defaultOrder, order, onOrderChange);
85
67
  const [innerVisible, setInnerVisible] = useControlled(defaultVisible, visible, onVisibleChange);
86
68
  const symbolBoundToNext = useRef(new WeakMap());
@@ -106,7 +88,7 @@ export function useCurdColumns({ columns, columnConfigurable }) {
106
88
  }, [columns]);
107
89
  // 只排序不筛选,用于设置项
108
90
  const orderedColumns = useMemo(() => {
109
- if (!innerOrder.current.length) {
91
+ if (!innerOrder.current?.length) {
110
92
  return pureColumns;
111
93
  }
112
94
  const set = new Set(pureColumns);
@@ -123,12 +105,12 @@ export function useCurdColumns({ columns, columnConfigurable }) {
123
105
  ];
124
106
  }, [innerOrder.current, pureColumns]);
125
107
  const visibleSet = useMemo(() => {
126
- return new Set(innerVisible.current);
108
+ return innerVisible.current && new Set(innerVisible.current);
127
109
  }, [innerVisible.current]);
128
110
  // 筛选表格上可见的列,并将symbol回填
129
111
  const actualColumns = useMemo(() => {
130
112
  return orderedColumns.flatMap(col => {
131
- if (!isUnset(col._key) && visibleSet.has(col._key)) {
113
+ if (!isUnset(col._key) && (!visibleSet || visibleSet.has(col._key))) {
132
114
  const symbolArr = symbolBoundToNext.current.get(col) || [];
133
115
  // 移除DataGrid不需要的属性
134
116
  const { filterInline, filter, form, ...c } = col;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canlooks/can-ui",
3
- "version": "0.0.168",
3
+ "version": "0.0.170",
4
4
  "author": "C.CanLiang <canlooks@gmail.com>",
5
5
  "description": "My ui framework",
6
6
  "license": "MIT",