@hi-ui/grid 5.0.0-experimental.1 → 5.0.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.
- package/CHANGELOG.md +19 -27
- package/lib/cjs/auto-grid/DynamicGrid.js +2 -2
- package/lib/cjs/auto-grid/use-column-count.js +8 -16
- package/lib/cjs/auto-grid/utils.js +4 -4
- package/lib/esm/auto-grid/DynamicGrid.js +1 -1
- package/lib/esm/auto-grid/use-column-count.js +3 -11
- package/lib/esm/auto-grid/utils.js +4 -4
- package/lib/types/auto-grid/AutoGrid.d.ts +4 -4
- package/lib/types/auto-grid/DynamicGrid.d.ts +4 -4
- package/lib/types/auto-grid/use-column-count.d.ts +2 -2
- package/lib/types/context.d.ts +1 -0
- package/lib/types/index.d.ts +1 -0
- package/lib/types/types.d.ts +2 -2
- package/package.json +10 -8
- package/lib/cjs/hooks/use-latest/lib/esm/index.js +0 -38
- package/lib/cjs/hooks/use-merge-refs/lib/esm/index.js +0 -68
- package/lib/cjs/utils/func-utils/lib/esm/index.js +0 -60
- package/lib/esm/hooks/use-latest/lib/esm/index.js +0 -33
- package/lib/esm/hooks/use-merge-refs/lib/esm/index.js +0 -62
- package/lib/esm/utils/func-utils/lib/esm/index.js +0 -55
package/CHANGELOG.md
CHANGED
|
@@ -1,41 +1,33 @@
|
|
|
1
1
|
# @hi-ui/grid
|
|
2
2
|
|
|
3
|
-
## 5.0.0
|
|
4
|
-
|
|
5
|
-
### Patch Changes
|
|
6
|
-
|
|
7
|
-
- c6197357f: 新增 AutoGrid 及 DynamicGrid 组件
|
|
8
|
-
- Updated dependencies [eb17c4697]
|
|
9
|
-
- Updated dependencies [c407744fe]
|
|
10
|
-
- @hi-ui/core@5.0.0-experimental.1
|
|
11
|
-
- @hi-ui/use-merge-semantic@5.0.0-experimental.0
|
|
12
|
-
|
|
13
|
-
## 5.0.0-experimental.0
|
|
3
|
+
## 5.0.0
|
|
14
4
|
|
|
15
5
|
### Major Changes
|
|
16
6
|
|
|
17
|
-
- 8f3aa85e4
|
|
7
|
+
- [#3532](https://github.com/XiaoMi/hiui/pull/3532) [`8f3aa85e4`](https://github.com/XiaoMi/hiui/commit/8f3aa85e4e1977854cecdf2864498a77e959bc39) Thanks [@zyprepare](https://github.com/zyprepare)! - feat: 组件的 package.json 中的 exports 统一加上 types 配置 (5.0)
|
|
18
8
|
|
|
19
9
|
### Minor Changes
|
|
20
10
|
|
|
21
|
-
- 2e56529f7
|
|
11
|
+
- [#3532](https://github.com/XiaoMi/hiui/pull/3532) [`2e56529f7`](https://github.com/XiaoMi/hiui/commit/2e56529f7ea8c74e2fac8b6061628d4fd0d862ac) Thanks [@zyprepare](https://github.com/zyprepare)! - feat(grid): add align api (5.0)
|
|
22
12
|
|
|
23
13
|
### Patch Changes
|
|
24
14
|
|
|
25
|
-
- 9b34d99bc
|
|
26
|
-
|
|
27
|
-
-
|
|
28
|
-
|
|
29
|
-
-
|
|
30
|
-
|
|
31
|
-
-
|
|
32
|
-
|
|
33
|
-
- Updated dependencies [33da3144e]
|
|
34
|
-
-
|
|
35
|
-
- @hi-ui/
|
|
36
|
-
- @hi-ui/
|
|
37
|
-
- @hi-ui/
|
|
38
|
-
- @hi-ui/
|
|
15
|
+
- [#3532](https://github.com/XiaoMi/hiui/pull/3532) [`9b34d99bc`](https://github.com/XiaoMi/hiui/commit/9b34d99bc2aa8b78b9e3281e08afc086ac4afea1) Thanks [@zyprepare](https://github.com/zyprepare)! - chore: 将代码中 v4 改为 v5 (5.0)
|
|
16
|
+
|
|
17
|
+
- [#3500](https://github.com/XiaoMi/hiui/pull/3500) [`c6197357f`](https://github.com/XiaoMi/hiui/commit/c6197357f53481ef89360175d02c1342b5c8b453) Thanks [@lanzhi-lee](https://github.com/lanzhi-lee)! - 新增 AutoGrid 及 DynamicGrid 组件
|
|
18
|
+
|
|
19
|
+
- [#3532](https://github.com/XiaoMi/hiui/pull/3532) [`2e56529f7`](https://github.com/XiaoMi/hiui/commit/2e56529f7ea8c74e2fac8b6061628d4fd0d862ac) Thanks [@zyprepare](https://github.com/zyprepare)! - styles: 主题定制功能完善&&样式变量化写法改造&&兼容 RTL (5.0)
|
|
20
|
+
|
|
21
|
+
- [#3532](https://github.com/XiaoMi/hiui/pull/3532) [`33da3144e`](https://github.com/XiaoMi/hiui/commit/33da3144e916edd75ee0669ca9e5090edc681193) Thanks [@zyprepare](https://github.com/zyprepare)! - build: 将 package.json 中 exports 配置中的 types 配置放在最上面 (5.0)
|
|
22
|
+
|
|
23
|
+
- Updated dependencies [[`eb17c4697`](https://github.com/XiaoMi/hiui/commit/eb17c46978dfcb5e8ec0a0e3b3dcffabae8d31fe), [`8c0ee78f0`](https://github.com/XiaoMi/hiui/commit/8c0ee78f013dcd9ced94cef13a69933e039621aa), [`8f3aa85e4`](https://github.com/XiaoMi/hiui/commit/8f3aa85e4e1977854cecdf2864498a77e959bc39), [`fd4c20bbd`](https://github.com/XiaoMi/hiui/commit/fd4c20bbd30e18bc4c1a2eb078acaa4790f7b2eb), [`79ea480f3`](https://github.com/XiaoMi/hiui/commit/79ea480f33bb8f692dda1e6252a9d2a75c3ac30d), [`f1ab51725`](https://github.com/XiaoMi/hiui/commit/f1ab517258599ee2dfad183e4a8c7b855ef409c1), [`d91a8bb0f`](https://github.com/XiaoMi/hiui/commit/d91a8bb0f887fa886215aa596852eef3c2ce8519), [`33da3144e`](https://github.com/XiaoMi/hiui/commit/33da3144e916edd75ee0669ca9e5090edc681193), [`58ad82e94`](https://github.com/XiaoMi/hiui/commit/58ad82e9441e76bf6090e6a0f4e36a04342c25f0), [`95d930354`](https://github.com/XiaoMi/hiui/commit/95d930354a1ab4291e98a9abccb9525d6c210795)]:
|
|
24
|
+
- @hi-ui/core@5.0.0
|
|
25
|
+
- @hi-ui/use-latest@5.0.0
|
|
26
|
+
- @hi-ui/use-merge-refs@5.0.0
|
|
27
|
+
- @hi-ui/classname@5.0.0
|
|
28
|
+
- @hi-ui/env@5.0.0
|
|
29
|
+
- @hi-ui/func-utils@5.0.0
|
|
30
|
+
- @hi-ui/type-assertion@5.0.0
|
|
39
31
|
|
|
40
32
|
## 4.0.9
|
|
41
33
|
|
|
@@ -15,7 +15,7 @@ Object.defineProperty(exports, '__esModule', {
|
|
|
15
15
|
});
|
|
16
16
|
var tslib = require('tslib');
|
|
17
17
|
var React = require('react');
|
|
18
|
-
var
|
|
18
|
+
var useMergeRefs = require('@hi-ui/use-merge-refs');
|
|
19
19
|
var useColumnCount = require('./use-column-count.js');
|
|
20
20
|
var AutoGrid = require('./AutoGrid.js');
|
|
21
21
|
var env = require('@hi-ui/env');
|
|
@@ -43,7 +43,7 @@ var DynamicGrid = /*#__PURE__*/React.forwardRef(function DynamicGrid(props, ref)
|
|
|
43
43
|
breakpoints: breakpoints,
|
|
44
44
|
sensitive: sensitive
|
|
45
45
|
});
|
|
46
|
-
var mergedRef =
|
|
46
|
+
var mergedRef = useMergeRefs.useMergeRefs(wrapperElRefProp !== null && wrapperElRefProp !== void 0 ? wrapperElRefProp : wrapperRef, ref);
|
|
47
47
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
48
48
|
ref: mergedRef,
|
|
49
49
|
style: {
|
|
@@ -13,8 +13,8 @@ Object.defineProperty(exports, '__esModule', {
|
|
|
13
13
|
value: true
|
|
14
14
|
});
|
|
15
15
|
var React = require('react');
|
|
16
|
-
var
|
|
17
|
-
var
|
|
16
|
+
var useLatest = require('@hi-ui/use-latest');
|
|
17
|
+
var funcUtils = require('@hi-ui/func-utils');
|
|
18
18
|
var types = require('../types.js');
|
|
19
19
|
function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
|
20
20
|
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
@@ -55,27 +55,19 @@ var MAX_EL_READY_POLL_DURATION = 3000;
|
|
|
55
55
|
/** 轮询检查元素的间隔(ms) */
|
|
56
56
|
var EL_READY_POLL_INTERVAL = 50;
|
|
57
57
|
// 根据容器宽度动态计算列数(与 GridResponsiveSize 断点一致)
|
|
58
|
-
var DEFAULT_BREAKPOINTS = [[types.GRID_VIEWPORT_BREAKPOINTS.sm, 1],
|
|
59
|
-
// xs: 宽度 < 576px 时,1 列
|
|
60
|
-
[types.GRID_VIEWPORT_BREAKPOINTS.md, 2],
|
|
61
|
-
// sm: 576px~768px,2 列
|
|
62
|
-
[types.GRID_VIEWPORT_BREAKPOINTS.lg, 3],
|
|
63
|
-
// md: 768px~992px,3 列
|
|
64
|
-
[types.GRID_VIEWPORT_BREAKPOINTS.xl, 4],
|
|
65
|
-
// lg: 992px~1200px,4 列
|
|
66
|
-
[Infinity, 4] // xl: 宽度 >= 1200px,4 列
|
|
58
|
+
var DEFAULT_BREAKPOINTS = [[types.GRID_VIEWPORT_BREAKPOINTS.sm, 1], [types.GRID_VIEWPORT_BREAKPOINTS.md, 2], [types.GRID_VIEWPORT_BREAKPOINTS.lg, 3], [types.GRID_VIEWPORT_BREAKPOINTS.xl, 4], [Infinity, 4] // xl: 宽度 >= 1200px,4 列
|
|
67
59
|
];
|
|
68
60
|
|
|
69
61
|
function useColumnCount(ctx) {
|
|
70
62
|
var _a, _b;
|
|
71
|
-
var ctxRef =
|
|
63
|
+
var ctxRef = useLatest.useLatestRef(ctx);
|
|
72
64
|
var _useState = React.useState((_b = (_a = ctx.columnCount) !== null && _a !== void 0 ? _a : ctx.defaultColumnCount) !== null && _b !== void 0 ? _b : DEFAULT_COLUMN_COUNT),
|
|
73
65
|
columnCount = _useState[0],
|
|
74
66
|
_setColumnCount = _useState[1];
|
|
75
|
-
var columnCountRef =
|
|
76
|
-
var onColumnCountChangeRef =
|
|
67
|
+
var columnCountRef = useLatest.useLatestRef(columnCount);
|
|
68
|
+
var onColumnCountChangeRef = useLatest.useLatestRef(ctx.onColumnCountChange);
|
|
77
69
|
var setColumnCount = React.useMemo(function () {
|
|
78
|
-
return
|
|
70
|
+
return funcUtils.debounce(function (next) {
|
|
79
71
|
var prev = columnCountRef.current;
|
|
80
72
|
_setColumnCount(next);
|
|
81
73
|
// 如果外部有传入,并且实际可视列数变化了,则触发回调
|
|
@@ -84,7 +76,7 @@ function useColumnCount(ctx) {
|
|
|
84
76
|
}, 32);
|
|
85
77
|
}, [columnCountRef, onColumnCountChangeRef]);
|
|
86
78
|
var isFirstCalcRef = React.useRef(true);
|
|
87
|
-
var breakpointsRef =
|
|
79
|
+
var breakpointsRef = useLatest.useLatestRef(ctx.breakpoints);
|
|
88
80
|
var pollTimerRef = React.useRef(null);
|
|
89
81
|
var observerRef = React.useRef(null);
|
|
90
82
|
React.useEffect(function () {
|
|
@@ -34,13 +34,13 @@ function isInvalidGridEl(el) {
|
|
|
34
34
|
return false;
|
|
35
35
|
}
|
|
36
36
|
function getGridElSpan(el) {
|
|
37
|
-
var _a;
|
|
37
|
+
var _a, _b;
|
|
38
38
|
try {
|
|
39
|
-
var props = el === null ||
|
|
40
|
-
var span = (
|
|
39
|
+
var props = (_a = el) === null || _a === void 0 ? void 0 : _a.props;
|
|
40
|
+
var span = (_b = props === null || props === void 0 ? void 0 : props.span) !== null && _b !== void 0 ? _b : props === null || props === void 0 ? void 0 : props['data-span'];
|
|
41
41
|
if (typeof span === 'number' && !isNaN(span) && span >= 0) return span;
|
|
42
42
|
return null;
|
|
43
|
-
} catch (
|
|
43
|
+
} catch (_c) {
|
|
44
44
|
return null;
|
|
45
45
|
}
|
|
46
46
|
}
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import { __rest } from 'tslib';
|
|
11
11
|
import React, { forwardRef, useRef } from 'react';
|
|
12
|
-
import { useMergeRefs } from '
|
|
12
|
+
import { useMergeRefs } from '@hi-ui/use-merge-refs';
|
|
13
13
|
import { useColumnCount } from './use-column-count.js';
|
|
14
14
|
import { AutoGrid } from './AutoGrid.js';
|
|
15
15
|
import { __DEV__ } from '@hi-ui/env';
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
9
|
*/
|
|
10
10
|
import { useState, useMemo, useRef, useEffect } from 'react';
|
|
11
|
-
import { useLatestRef } from '
|
|
12
|
-
import { debounce } from '
|
|
11
|
+
import { useLatestRef } from '@hi-ui/use-latest';
|
|
12
|
+
import { debounce } from '@hi-ui/func-utils';
|
|
13
13
|
import { GRID_VIEWPORT_BREAKPOINTS } from '../types.js';
|
|
14
14
|
function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
|
15
15
|
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
@@ -50,15 +50,7 @@ var MAX_EL_READY_POLL_DURATION = 3000;
|
|
|
50
50
|
/** 轮询检查元素的间隔(ms) */
|
|
51
51
|
var EL_READY_POLL_INTERVAL = 50;
|
|
52
52
|
// 根据容器宽度动态计算列数(与 GridResponsiveSize 断点一致)
|
|
53
|
-
var DEFAULT_BREAKPOINTS = [[GRID_VIEWPORT_BREAKPOINTS.sm, 1],
|
|
54
|
-
// xs: 宽度 < 576px 时,1 列
|
|
55
|
-
[GRID_VIEWPORT_BREAKPOINTS.md, 2],
|
|
56
|
-
// sm: 576px~768px,2 列
|
|
57
|
-
[GRID_VIEWPORT_BREAKPOINTS.lg, 3],
|
|
58
|
-
// md: 768px~992px,3 列
|
|
59
|
-
[GRID_VIEWPORT_BREAKPOINTS.xl, 4],
|
|
60
|
-
// lg: 992px~1200px,4 列
|
|
61
|
-
[Infinity, 4] // xl: 宽度 >= 1200px,4 列
|
|
53
|
+
var DEFAULT_BREAKPOINTS = [[GRID_VIEWPORT_BREAKPOINTS.sm, 1], [GRID_VIEWPORT_BREAKPOINTS.md, 2], [GRID_VIEWPORT_BREAKPOINTS.lg, 3], [GRID_VIEWPORT_BREAKPOINTS.xl, 4], [Infinity, 4] // xl: 宽度 >= 1200px,4 列
|
|
62
54
|
];
|
|
63
55
|
|
|
64
56
|
function useColumnCount(ctx) {
|
|
@@ -22,13 +22,13 @@ function isInvalidGridEl(el) {
|
|
|
22
22
|
return false;
|
|
23
23
|
}
|
|
24
24
|
function getGridElSpan(el) {
|
|
25
|
-
var _a;
|
|
25
|
+
var _a, _b;
|
|
26
26
|
try {
|
|
27
|
-
var props = el === null ||
|
|
28
|
-
var span = (
|
|
27
|
+
var props = (_a = el) === null || _a === void 0 ? void 0 : _a.props;
|
|
28
|
+
var span = (_b = props === null || props === void 0 ? void 0 : props.span) !== null && _b !== void 0 ? _b : props === null || props === void 0 ? void 0 : props['data-span'];
|
|
29
29
|
if (typeof span === 'number' && !isNaN(span) && span >= 0) return span;
|
|
30
30
|
return null;
|
|
31
|
-
} catch (
|
|
31
|
+
} catch (_c) {
|
|
32
32
|
return null;
|
|
33
33
|
}
|
|
34
34
|
}
|
|
@@ -8,7 +8,7 @@ export interface AutoGridNodeType {
|
|
|
8
8
|
columnCount: number;
|
|
9
9
|
}) => ColProps);
|
|
10
10
|
}
|
|
11
|
-
export type AutoGridProps = RowProps & {
|
|
11
|
+
export declare type AutoGridProps = RowProps & {
|
|
12
12
|
/** 列元素清单 */
|
|
13
13
|
nodes?: AutoGridNodeType[];
|
|
14
14
|
/**
|
|
@@ -22,13 +22,13 @@ export type AutoGridProps = RowProps & {
|
|
|
22
22
|
};
|
|
23
23
|
export declare const AutoGrid: React.ForwardRefExoticComponent<RowProps & {
|
|
24
24
|
/** 列元素清单 */
|
|
25
|
-
nodes?: AutoGridNodeType[];
|
|
25
|
+
nodes?: AutoGridNodeType[] | undefined;
|
|
26
26
|
/**
|
|
27
27
|
* 子元素清单
|
|
28
28
|
* - 存在子元素时,会自动按照默认的配置增加网格包裹
|
|
29
29
|
* - 如需控制子元素占据的网格数,请在元素上增加 span 或者 data-span 属性
|
|
30
30
|
*/
|
|
31
|
-
children?: React.ReactNode[];
|
|
31
|
+
children?: React.ReactNode[] | undefined;
|
|
32
32
|
/** 列数 */
|
|
33
|
-
columnCount?: number;
|
|
33
|
+
columnCount?: number | undefined;
|
|
34
34
|
} & React.RefAttributes<HTMLDivElement | null>>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { UseColumnCountCtxType } from './use-column-count';
|
|
3
3
|
import type { AutoGridProps } from './AutoGrid';
|
|
4
|
-
export type DynamicGridProps = AutoGridProps & UseColumnCountCtxType;
|
|
4
|
+
export declare type DynamicGridProps = AutoGridProps & UseColumnCountCtxType;
|
|
5
5
|
export declare const DynamicGrid: React.ForwardRefExoticComponent<import("..").RowProps & {
|
|
6
|
-
nodes?: import("./AutoGrid").AutoGridNodeType[];
|
|
7
|
-
children?: React.ReactNode[];
|
|
8
|
-
columnCount?: number;
|
|
6
|
+
nodes?: import("./AutoGrid").AutoGridNodeType[] | undefined;
|
|
7
|
+
children?: React.ReactNode[] | undefined;
|
|
8
|
+
columnCount?: number | undefined;
|
|
9
9
|
} & UseColumnCountCtxType & React.RefAttributes<HTMLDivElement | null>>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
export type BreakpointType = [width: number, column: number];
|
|
3
|
-
export type UseColumnCountCtxType = {
|
|
2
|
+
export declare type BreakpointType = [width: number, column: number];
|
|
3
|
+
export declare type UseColumnCountCtxType = {
|
|
4
4
|
/**
|
|
5
5
|
* 列数,表示一行包含元素的数量
|
|
6
6
|
* @default 3
|
package/lib/types/context.d.ts
CHANGED
package/lib/types/index.d.ts
CHANGED
package/lib/types/types.d.ts
CHANGED
|
@@ -13,8 +13,8 @@ export declare const GRID_VIEWPORT_BREAKPOINTS: {
|
|
|
13
13
|
readonly lg: 992;
|
|
14
14
|
readonly xl: 1200;
|
|
15
15
|
};
|
|
16
|
-
export type GridJustifyEnum = 'flex-start' | 'flex-end' | 'center' | 'space-around' | 'space-between';
|
|
17
|
-
export type GridAlignEnum = 'flex-start' | 'flex-end' | 'center' | 'stretch';
|
|
16
|
+
export declare type GridJustifyEnum = 'flex-start' | 'flex-end' | 'center' | 'space-around' | 'space-between';
|
|
17
|
+
export declare type GridAlignEnum = 'flex-start' | 'flex-end' | 'center' | 'stretch';
|
|
18
18
|
export interface GridResponsiveSize<T> {
|
|
19
19
|
/**
|
|
20
20
|
* 设置屏幕 < 576px 时响应式栅格数
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hi-ui/grid",
|
|
3
|
-
"version": "5.0.0
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "A sub-package for @hi-ui/hiui.",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"author": "HiUI <mi-hiui@xiaomi.com>",
|
|
@@ -44,19 +44,21 @@
|
|
|
44
44
|
"url": "https://github.com/XiaoMi/hiui/issues"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@hi-ui/classname": "^5.0.0
|
|
48
|
-
"@hi-ui/env": "^5.0.0
|
|
49
|
-
"@hi-ui/
|
|
50
|
-
"@hi-ui/
|
|
47
|
+
"@hi-ui/classname": "^5.0.0",
|
|
48
|
+
"@hi-ui/env": "^5.0.0",
|
|
49
|
+
"@hi-ui/func-utils": "^5.0.0",
|
|
50
|
+
"@hi-ui/type-assertion": "^5.0.0",
|
|
51
|
+
"@hi-ui/use-latest": "^5.0.0",
|
|
52
|
+
"@hi-ui/use-merge-refs": "^5.0.0"
|
|
51
53
|
},
|
|
52
54
|
"peerDependencies": {
|
|
53
|
-
"@hi-ui/core": ">=5.0.0
|
|
55
|
+
"@hi-ui/core": ">=5.0.0",
|
|
54
56
|
"react": ">=16.8.6",
|
|
55
57
|
"react-dom": ">=16.8.6"
|
|
56
58
|
},
|
|
57
59
|
"devDependencies": {
|
|
58
|
-
"@hi-ui/core": "^5.0.0
|
|
59
|
-
"@hi-ui/core-css": "^5.0.0
|
|
60
|
+
"@hi-ui/core": "^5.0.0",
|
|
61
|
+
"@hi-ui/core-css": "^5.0.0",
|
|
60
62
|
"react": "^17.0.1",
|
|
61
63
|
"react-dom": "^17.0.1"
|
|
62
64
|
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/** @LICENSE
|
|
2
|
-
* @hi-ui/grid
|
|
3
|
-
* https://github.com/XiaoMi/hiui/tree/master/packages/ui/grid#readme
|
|
4
|
-
*
|
|
5
|
-
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
|
6
|
-
*
|
|
7
|
-
* This source code is licensed under the MIT license found in the
|
|
8
|
-
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/
|
|
10
|
-
'use strict';
|
|
11
|
-
|
|
12
|
-
Object.defineProperty(exports, '__esModule', {
|
|
13
|
-
value: true
|
|
14
|
-
});
|
|
15
|
-
var React = require('react');
|
|
16
|
-
|
|
17
|
-
/** @LICENSE
|
|
18
|
-
* @hi-ui/use-latest
|
|
19
|
-
* https://github.com/XiaoMi/hiui/tree/master/packages/hooks/use-latest#readme
|
|
20
|
-
*
|
|
21
|
-
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
|
22
|
-
*
|
|
23
|
-
* This source code is licensed under the MIT license found in the
|
|
24
|
-
* LICENSE file in the root directory of this source tree.
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Keep value up-to-date if it changes.
|
|
29
|
-
*
|
|
30
|
-
* @param value
|
|
31
|
-
* @returns
|
|
32
|
-
*/
|
|
33
|
-
var useLatestRef = function useLatestRef(value) {
|
|
34
|
-
var ref = React.useRef(value);
|
|
35
|
-
ref.current = value;
|
|
36
|
-
return ref;
|
|
37
|
-
};
|
|
38
|
-
exports.useLatestRef = useLatestRef;
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
/** @LICENSE
|
|
2
|
-
* @hi-ui/grid
|
|
3
|
-
* https://github.com/XiaoMi/hiui/tree/master/packages/ui/grid#readme
|
|
4
|
-
*
|
|
5
|
-
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
|
6
|
-
*
|
|
7
|
-
* This source code is licensed under the MIT license found in the
|
|
8
|
-
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/
|
|
10
|
-
'use strict';
|
|
11
|
-
|
|
12
|
-
Object.defineProperty(exports, '__esModule', {
|
|
13
|
-
value: true
|
|
14
|
-
});
|
|
15
|
-
var React = require('react');
|
|
16
|
-
|
|
17
|
-
/** @LICENSE
|
|
18
|
-
* @hi-ui/use-merge-refs
|
|
19
|
-
* https://github.com/XiaoMi/hiui/tree/master/packages/hooks/use-merge-refs#readme
|
|
20
|
-
*
|
|
21
|
-
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
|
22
|
-
*
|
|
23
|
-
* This source code is licensed under the MIT license found in the
|
|
24
|
-
* LICENSE file in the root directory of this source tree.
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* A hook to merge multiple refs into a single function ref.
|
|
29
|
-
*
|
|
30
|
-
* @param refs
|
|
31
|
-
*/
|
|
32
|
-
var useMergeRefs = function useMergeRefs() {
|
|
33
|
-
for (var _len = arguments.length, refs = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
34
|
-
refs[_key] = arguments[_key];
|
|
35
|
-
}
|
|
36
|
-
return React.useMemo(function () {
|
|
37
|
-
return mergeRefs.apply(void 0, refs);
|
|
38
|
-
}, refs);
|
|
39
|
-
};
|
|
40
|
-
/**
|
|
41
|
-
* Merges multiple refs into a single function ref.
|
|
42
|
-
*
|
|
43
|
-
* @param refs
|
|
44
|
-
* @returns
|
|
45
|
-
*/
|
|
46
|
-
function mergeRefs() {
|
|
47
|
-
for (var _len2 = arguments.length, refs = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
48
|
-
refs[_key2] = arguments[_key2];
|
|
49
|
-
}
|
|
50
|
-
// Empty check
|
|
51
|
-
if (refs.some(function (ref) {
|
|
52
|
-
return ref;
|
|
53
|
-
}) === false) return null;
|
|
54
|
-
return function (value) {
|
|
55
|
-
refs.forEach(function (ref) {
|
|
56
|
-
setRef(ref, value);
|
|
57
|
-
});
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
function setRef(ref, value) {
|
|
61
|
-
if (typeof ref === 'function') {
|
|
62
|
-
ref(value);
|
|
63
|
-
} else if (ref) {
|
|
64
|
-
ref.current = value;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
exports.mergeRefs = mergeRefs;
|
|
68
|
-
exports.useMergeRefs = useMergeRefs;
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
/** @LICENSE
|
|
2
|
-
* @hi-ui/grid
|
|
3
|
-
* https://github.com/XiaoMi/hiui/tree/master/packages/ui/grid#readme
|
|
4
|
-
*
|
|
5
|
-
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
|
6
|
-
*
|
|
7
|
-
* This source code is licensed under the MIT license found in the
|
|
8
|
-
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/
|
|
10
|
-
'use strict';
|
|
11
|
-
|
|
12
|
-
Object.defineProperty(exports, '__esModule', {
|
|
13
|
-
value: true
|
|
14
|
-
});
|
|
15
|
-
require('@hi-ui/type-assertion');
|
|
16
|
-
|
|
17
|
-
/** @LICENSE
|
|
18
|
-
* @hi-ui/func-utils
|
|
19
|
-
* https://github.com/XiaoMi/hiui/tree/master/packages/utils/func-utils#readme
|
|
20
|
-
*
|
|
21
|
-
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
|
22
|
-
*
|
|
23
|
-
* This source code is licensed under the MIT license found in the
|
|
24
|
-
* LICENSE file in the root directory of this source tree.
|
|
25
|
-
*/
|
|
26
|
-
/**
|
|
27
|
-
* 函数防抖优化
|
|
28
|
-
* @param func 被优化函数
|
|
29
|
-
* @param delay 抖动间隔
|
|
30
|
-
* @returns
|
|
31
|
-
*/
|
|
32
|
-
var debounce = function debounce(func, delay) {
|
|
33
|
-
if (delay === void 0) {
|
|
34
|
-
delay = 150;
|
|
35
|
-
}
|
|
36
|
-
var timer = 0;
|
|
37
|
-
var cancel = function cancel() {
|
|
38
|
-
if (timer) {
|
|
39
|
-
window.clearTimeout(timer);
|
|
40
|
-
timer = 0;
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
var debounceFn = function debounceFn() {
|
|
44
|
-
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
|
|
45
|
-
args[_key4] = arguments[_key4];
|
|
46
|
-
}
|
|
47
|
-
if (timer) {
|
|
48
|
-
cancel();
|
|
49
|
-
}
|
|
50
|
-
if (func) {
|
|
51
|
-
timer = window.setTimeout(function () {
|
|
52
|
-
func.apply(null, args);
|
|
53
|
-
timer = 0;
|
|
54
|
-
}, delay);
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
debounceFn.cancel = cancel;
|
|
58
|
-
return debounceFn;
|
|
59
|
-
};
|
|
60
|
-
exports.debounce = debounce;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/** @LICENSE
|
|
2
|
-
* @hi-ui/grid
|
|
3
|
-
* https://github.com/XiaoMi/hiui/tree/master/packages/ui/grid#readme
|
|
4
|
-
*
|
|
5
|
-
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
|
6
|
-
*
|
|
7
|
-
* This source code is licensed under the MIT license found in the
|
|
8
|
-
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/
|
|
10
|
-
import { useRef } from 'react';
|
|
11
|
-
|
|
12
|
-
/** @LICENSE
|
|
13
|
-
* @hi-ui/use-latest
|
|
14
|
-
* https://github.com/XiaoMi/hiui/tree/master/packages/hooks/use-latest#readme
|
|
15
|
-
*
|
|
16
|
-
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
|
17
|
-
*
|
|
18
|
-
* This source code is licensed under the MIT license found in the
|
|
19
|
-
* LICENSE file in the root directory of this source tree.
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Keep value up-to-date if it changes.
|
|
24
|
-
*
|
|
25
|
-
* @param value
|
|
26
|
-
* @returns
|
|
27
|
-
*/
|
|
28
|
-
var useLatestRef = function useLatestRef(value) {
|
|
29
|
-
var ref = useRef(value);
|
|
30
|
-
ref.current = value;
|
|
31
|
-
return ref;
|
|
32
|
-
};
|
|
33
|
-
export { useLatestRef };
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/** @LICENSE
|
|
2
|
-
* @hi-ui/grid
|
|
3
|
-
* https://github.com/XiaoMi/hiui/tree/master/packages/ui/grid#readme
|
|
4
|
-
*
|
|
5
|
-
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
|
6
|
-
*
|
|
7
|
-
* This source code is licensed under the MIT license found in the
|
|
8
|
-
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/
|
|
10
|
-
import { useMemo } from 'react';
|
|
11
|
-
|
|
12
|
-
/** @LICENSE
|
|
13
|
-
* @hi-ui/use-merge-refs
|
|
14
|
-
* https://github.com/XiaoMi/hiui/tree/master/packages/hooks/use-merge-refs#readme
|
|
15
|
-
*
|
|
16
|
-
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
|
17
|
-
*
|
|
18
|
-
* This source code is licensed under the MIT license found in the
|
|
19
|
-
* LICENSE file in the root directory of this source tree.
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* A hook to merge multiple refs into a single function ref.
|
|
24
|
-
*
|
|
25
|
-
* @param refs
|
|
26
|
-
*/
|
|
27
|
-
var useMergeRefs = function useMergeRefs() {
|
|
28
|
-
for (var _len = arguments.length, refs = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
29
|
-
refs[_key] = arguments[_key];
|
|
30
|
-
}
|
|
31
|
-
return useMemo(function () {
|
|
32
|
-
return mergeRefs.apply(void 0, refs);
|
|
33
|
-
}, refs);
|
|
34
|
-
};
|
|
35
|
-
/**
|
|
36
|
-
* Merges multiple refs into a single function ref.
|
|
37
|
-
*
|
|
38
|
-
* @param refs
|
|
39
|
-
* @returns
|
|
40
|
-
*/
|
|
41
|
-
function mergeRefs() {
|
|
42
|
-
for (var _len2 = arguments.length, refs = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
43
|
-
refs[_key2] = arguments[_key2];
|
|
44
|
-
}
|
|
45
|
-
// Empty check
|
|
46
|
-
if (refs.some(function (ref) {
|
|
47
|
-
return ref;
|
|
48
|
-
}) === false) return null;
|
|
49
|
-
return function (value) {
|
|
50
|
-
refs.forEach(function (ref) {
|
|
51
|
-
setRef(ref, value);
|
|
52
|
-
});
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
function setRef(ref, value) {
|
|
56
|
-
if (typeof ref === 'function') {
|
|
57
|
-
ref(value);
|
|
58
|
-
} else if (ref) {
|
|
59
|
-
ref.current = value;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
export { mergeRefs, useMergeRefs };
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/** @LICENSE
|
|
2
|
-
* @hi-ui/grid
|
|
3
|
-
* https://github.com/XiaoMi/hiui/tree/master/packages/ui/grid#readme
|
|
4
|
-
*
|
|
5
|
-
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
|
6
|
-
*
|
|
7
|
-
* This source code is licensed under the MIT license found in the
|
|
8
|
-
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/
|
|
10
|
-
import '@hi-ui/type-assertion';
|
|
11
|
-
|
|
12
|
-
/** @LICENSE
|
|
13
|
-
* @hi-ui/func-utils
|
|
14
|
-
* https://github.com/XiaoMi/hiui/tree/master/packages/utils/func-utils#readme
|
|
15
|
-
*
|
|
16
|
-
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
|
17
|
-
*
|
|
18
|
-
* This source code is licensed under the MIT license found in the
|
|
19
|
-
* LICENSE file in the root directory of this source tree.
|
|
20
|
-
*/
|
|
21
|
-
/**
|
|
22
|
-
* 函数防抖优化
|
|
23
|
-
* @param func 被优化函数
|
|
24
|
-
* @param delay 抖动间隔
|
|
25
|
-
* @returns
|
|
26
|
-
*/
|
|
27
|
-
var debounce = function debounce(func, delay) {
|
|
28
|
-
if (delay === void 0) {
|
|
29
|
-
delay = 150;
|
|
30
|
-
}
|
|
31
|
-
var timer = 0;
|
|
32
|
-
var cancel = function cancel() {
|
|
33
|
-
if (timer) {
|
|
34
|
-
window.clearTimeout(timer);
|
|
35
|
-
timer = 0;
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
var debounceFn = function debounceFn() {
|
|
39
|
-
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
|
|
40
|
-
args[_key4] = arguments[_key4];
|
|
41
|
-
}
|
|
42
|
-
if (timer) {
|
|
43
|
-
cancel();
|
|
44
|
-
}
|
|
45
|
-
if (func) {
|
|
46
|
-
timer = window.setTimeout(function () {
|
|
47
|
-
func.apply(null, args);
|
|
48
|
-
timer = 0;
|
|
49
|
-
}, delay);
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
debounceFn.cancel = cancel;
|
|
53
|
-
return debounceFn;
|
|
54
|
-
};
|
|
55
|
-
export { debounce };
|