@dtjoy/dt-design 1.0.6 → 1.0.8

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 (222) hide show
  1. package/esm/_util/easings.d.ts +1 -0
  2. package/esm/_util/easings.js +9 -0
  3. package/esm/_util/extendsObject.d.ts +4 -0
  4. package/esm/_util/extendsObject.js +17 -0
  5. package/esm/_util/gapSize.d.ts +3 -3
  6. package/esm/_util/getScroll.d.ts +3 -0
  7. package/esm/_util/getScroll.js +32 -0
  8. package/esm/_util/hooks/index.d.ts +4 -1
  9. package/esm/_util/hooks/index.js +4 -1
  10. package/esm/_util/hooks/useForceUpdate.d.ts +2 -0
  11. package/esm/_util/hooks/useForceUpdate.js +6 -0
  12. package/esm/_util/hooks/useOrientation.d.ts +2 -2
  13. package/esm/_util/hooks/useProxyImperativeHandle.d.ts +4 -0
  14. package/esm/_util/hooks/useProxyImperativeHandle.js +31 -0
  15. package/esm/_util/hooks/useSyncState.d.ts +3 -0
  16. package/esm/_util/hooks/useSyncState.js +20 -0
  17. package/esm/_util/index.d.ts +3 -3
  18. package/esm/_util/isNonNullable.d.ts +2 -2
  19. package/esm/_util/scrollTo.d.ts +10 -0
  20. package/esm/_util/scrollTo.js +38 -0
  21. package/esm/_util/type.d.ts +52 -52
  22. package/esm/_util/warning.d.ts +31 -31
  23. package/esm/_util/warning.js +5 -5
  24. package/esm/blockHeader/index.d.ts +50 -48
  25. package/esm/blockHeader/index.js +13 -15
  26. package/esm/blockHeader/style/index.d.ts +2 -2
  27. package/esm/blockHeader/style/index.less +143 -143
  28. package/esm/button/index.d.ts +10 -10
  29. package/esm/button/index.js +2 -2
  30. package/esm/button/style/index.d.ts +2 -2
  31. package/esm/collapsible/index.d.ts +102 -97
  32. package/esm/collapsible/index.js +53 -55
  33. package/esm/collapsible/style/index.d.ts +1 -1
  34. package/esm/collapsibleActionItems/index.d.ts +24 -24
  35. package/esm/collapsibleActionItems/index.js +2 -2
  36. package/esm/collapsibleActionItems/style/index.d.ts +2 -2
  37. package/esm/flex/index.d.ts +7 -7
  38. package/esm/flex/index.js +1 -1
  39. package/esm/flex/interface.d.ts +16 -16
  40. package/esm/flex/style/index.d.ts +2 -2
  41. package/esm/flex/style/index.less +76 -76
  42. package/esm/flex/utils.d.ts +7 -7
  43. package/esm/flex/utils.js +1 -1
  44. package/esm/formList/index.d.ts +78 -77
  45. package/esm/formList/index.js +13 -11
  46. package/esm/formList/style/index.d.ts +2 -2
  47. package/esm/formList/style/index.less +45 -45
  48. package/esm/index.d.ts +17 -14
  49. package/esm/index.js +3 -1
  50. package/esm/overflowList/index.d.ts +40 -39
  51. package/esm/overflowList/index.js +4 -3
  52. package/esm/overflowList/style/index.d.ts +2 -2
  53. package/esm/resize/index.d.ts +9 -8
  54. package/esm/resize/index.js +1 -1
  55. package/esm/resizeObserver/index.d.ts +45 -45
  56. package/esm/resizeObserver/index.js +3 -2
  57. package/esm/splitter/Panel.d.ts +7 -7
  58. package/esm/splitter/Panel.js +3 -3
  59. package/esm/splitter/SplitBar.d.ts +24 -24
  60. package/esm/splitter/SplitBar.js +8 -7
  61. package/esm/splitter/Splitter.d.ts +5 -5
  62. package/esm/splitter/Splitter.js +5 -4
  63. package/esm/splitter/hooks/sizeUtil.d.ts +3 -3
  64. package/esm/splitter/hooks/useItems.d.ts +14 -14
  65. package/esm/splitter/hooks/useItems.js +2 -2
  66. package/esm/splitter/hooks/useResizable.d.ts +10 -10
  67. package/esm/splitter/hooks/useResize.d.ts +6 -6
  68. package/esm/splitter/hooks/useResize.js +5 -5
  69. package/esm/splitter/hooks/useSizes.d.ts +4 -4
  70. package/esm/splitter/index.d.ts +8 -8
  71. package/esm/splitter/interface.d.ts +69 -69
  72. package/esm/splitter/style/index.d.ts +2 -2
  73. package/esm/statusTag/index.d.ts +29 -28
  74. package/esm/statusTag/index.js +8 -8
  75. package/esm/statusTag/style/index.d.ts +2 -2
  76. package/esm/style/index.d.ts +1 -1
  77. package/esm/style/index.less +1 -1
  78. package/esm/style/themes/index.less +2 -2
  79. package/esm/style/themes/variable.less +4 -0
  80. package/esm/table/InternalTable.d.ts +32 -0
  81. package/esm/table/InternalTable.js +429 -0
  82. package/esm/table/RcTable/VirtualTable.d.ts +2 -0
  83. package/esm/table/RcTable/VirtualTable.js +9 -0
  84. package/esm/table/RcTable/index.d.ts +2 -0
  85. package/esm/table/RcTable/index.js +9 -0
  86. package/esm/table/Table.d.ts +17 -0
  87. package/esm/table/Table.js +28 -0
  88. package/esm/table/TableMeasureRowContext.d.ts +3 -0
  89. package/esm/table/TableMeasureRowContext.js +3 -0
  90. package/esm/table/hooks/useContainerWidth.d.ts +1 -0
  91. package/esm/table/hooks/useContainerWidth.js +14 -0
  92. package/esm/table/index.d.ts +7 -0
  93. package/esm/table/index.js +2 -0
  94. package/esm/table/interface.d.ts +196 -0
  95. package/esm/table/interface.js +4 -0
  96. package/esm/table/style/bordered.less +141 -0
  97. package/esm/table/style/fixed.less +88 -0
  98. package/esm/table/style/index.d.ts +2 -0
  99. package/esm/table/style/index.js +2 -0
  100. package/esm/table/style/index.less +150 -0
  101. package/esm/table/style/selection.less +90 -0
  102. package/esm/table/style/sticky.less +55 -0
  103. package/esm/table/style/virtual.less +65 -0
  104. package/esm/table/util.d.ts +14 -0
  105. package/esm/table/util.js +33 -0
  106. package/lib/_util/easings.d.ts +1 -0
  107. package/lib/_util/easings.js +15 -0
  108. package/lib/_util/extendsObject.d.ts +4 -0
  109. package/lib/_util/extendsObject.js +20 -0
  110. package/lib/_util/gapSize.d.ts +3 -3
  111. package/lib/_util/getScroll.d.ts +3 -0
  112. package/lib/_util/getScroll.js +39 -0
  113. package/lib/_util/hooks/index.d.ts +4 -1
  114. package/lib/_util/hooks/index.js +33 -0
  115. package/lib/_util/hooks/useForceUpdate.d.ts +2 -0
  116. package/lib/_util/hooks/useForceUpdate.js +12 -0
  117. package/lib/_util/hooks/useOrientation.d.ts +2 -2
  118. package/lib/_util/hooks/useProxyImperativeHandle.d.ts +4 -0
  119. package/lib/_util/hooks/useProxyImperativeHandle.js +40 -0
  120. package/lib/_util/hooks/useSyncState.d.ts +3 -0
  121. package/lib/_util/hooks/useSyncState.js +19 -0
  122. package/lib/_util/index.d.ts +3 -3
  123. package/lib/_util/isNonNullable.d.ts +2 -2
  124. package/lib/_util/scrollTo.d.ts +10 -0
  125. package/lib/_util/scrollTo.js +44 -0
  126. package/lib/_util/type.d.ts +52 -52
  127. package/lib/_util/warning.d.ts +31 -31
  128. package/lib/_util/warning.js +7 -8
  129. package/lib/blockHeader/index.d.ts +50 -48
  130. package/lib/blockHeader/index.js +13 -12
  131. package/lib/blockHeader/style/index.d.ts +2 -2
  132. package/lib/blockHeader/style/index.less +143 -143
  133. package/lib/button/index.d.ts +10 -10
  134. package/lib/button/index.js +2 -2
  135. package/lib/button/style/index.d.ts +2 -2
  136. package/lib/collapsible/index.d.ts +102 -97
  137. package/lib/collapsible/index.js +49 -49
  138. package/lib/collapsible/style/index.d.ts +1 -1
  139. package/lib/collapsibleActionItems/index.d.ts +24 -24
  140. package/lib/collapsibleActionItems/index.js +2 -2
  141. package/lib/collapsibleActionItems/style/index.d.ts +2 -2
  142. package/lib/flex/index.d.ts +7 -7
  143. package/lib/flex/index.js +2 -2
  144. package/lib/flex/interface.d.ts +16 -16
  145. package/lib/flex/style/index.d.ts +2 -2
  146. package/lib/flex/style/index.less +76 -76
  147. package/lib/flex/utils.d.ts +7 -7
  148. package/lib/flex/utils.js +2 -2
  149. package/lib/formList/index.d.ts +78 -77
  150. package/lib/formList/index.js +10 -10
  151. package/lib/formList/style/index.d.ts +2 -2
  152. package/lib/formList/style/index.less +45 -45
  153. package/lib/index.d.ts +17 -14
  154. package/lib/index.js +21 -2
  155. package/lib/overflowList/index.d.ts +40 -39
  156. package/lib/overflowList/index.js +4 -3
  157. package/lib/overflowList/style/index.d.ts +2 -2
  158. package/lib/resize/index.d.ts +9 -8
  159. package/lib/resize/index.js +1 -1
  160. package/lib/resizeObserver/index.d.ts +45 -45
  161. package/lib/resizeObserver/index.js +3 -2
  162. package/lib/splitter/Panel.d.ts +7 -7
  163. package/lib/splitter/Panel.js +3 -3
  164. package/lib/splitter/SplitBar.d.ts +24 -24
  165. package/lib/splitter/SplitBar.js +8 -7
  166. package/lib/splitter/Splitter.d.ts +5 -5
  167. package/lib/splitter/Splitter.js +5 -4
  168. package/lib/splitter/hooks/sizeUtil.d.ts +3 -3
  169. package/lib/splitter/hooks/useItems.d.ts +14 -14
  170. package/lib/splitter/hooks/useItems.js +2 -2
  171. package/lib/splitter/hooks/useResizable.d.ts +10 -10
  172. package/lib/splitter/hooks/useResize.d.ts +6 -6
  173. package/lib/splitter/hooks/useResize.js +5 -5
  174. package/lib/splitter/hooks/useSizes.d.ts +4 -4
  175. package/lib/splitter/index.d.ts +8 -8
  176. package/lib/splitter/interface.d.ts +69 -69
  177. package/lib/splitter/style/index.d.ts +2 -2
  178. package/lib/statusTag/index.d.ts +29 -28
  179. package/lib/statusTag/index.js +8 -8
  180. package/lib/statusTag/style/index.d.ts +2 -2
  181. package/lib/style/index.d.ts +1 -1
  182. package/lib/style/index.less +1 -1
  183. package/lib/style/themes/index.less +2 -2
  184. package/lib/style/themes/variable.less +4 -0
  185. package/lib/table/InternalTable.d.ts +32 -0
  186. package/lib/table/InternalTable.js +395 -0
  187. package/lib/table/RcTable/VirtualTable.d.ts +2 -0
  188. package/lib/table/RcTable/VirtualTable.js +17 -0
  189. package/lib/table/RcTable/index.d.ts +2 -0
  190. package/lib/table/RcTable/index.js +17 -0
  191. package/lib/table/Table.d.ts +17 -0
  192. package/lib/table/Table.js +37 -0
  193. package/lib/table/TableMeasureRowContext.d.ts +3 -0
  194. package/lib/{_util/zindexContext.js → table/TableMeasureRowContext.js} +2 -5
  195. package/lib/table/hooks/useContainerWidth.d.ts +1 -0
  196. package/lib/table/hooks/useContainerWidth.js +20 -0
  197. package/lib/table/index.d.ts +7 -0
  198. package/lib/table/index.js +9 -0
  199. package/lib/table/interface.d.ts +196 -0
  200. package/lib/table/interface.js +8 -0
  201. package/lib/table/style/bordered.less +141 -0
  202. package/lib/table/style/fixed.less +88 -0
  203. package/lib/table/style/index.d.ts +2 -0
  204. package/lib/table/style/index.js +4 -0
  205. package/lib/table/style/index.less +150 -0
  206. package/lib/table/style/selection.less +90 -0
  207. package/lib/table/style/sticky.less +55 -0
  208. package/lib/table/style/virtual.less +65 -0
  209. package/lib/table/util.d.ts +14 -0
  210. package/lib/table/util.js +44 -0
  211. package/package.json +82 -66
  212. package/esm/_util/convertToTooltipProps.d.ts +0 -4
  213. package/esm/_util/convertToTooltipProps.js +0 -15
  214. package/esm/_util/hooks/useZIndex.d.ts +0 -8
  215. package/esm/_util/hooks/useZIndex.js +0 -51
  216. package/esm/_util/zindexContext.d.ts +0 -3
  217. package/esm/_util/zindexContext.js +0 -6
  218. package/lib/_util/convertToTooltipProps.d.ts +0 -4
  219. package/lib/_util/convertToTooltipProps.js +0 -21
  220. package/lib/_util/hooks/useZIndex.d.ts +0 -8
  221. package/lib/_util/hooks/useZIndex.js +0 -59
  222. package/lib/_util/zindexContext.d.ts +0 -3
@@ -0,0 +1,55 @@
1
+ @import '../../style/themes/index.less';
2
+
3
+ @table-prefix-cls: ~'@{ant-prefix}-table';
4
+
5
+ @table-scroll-thumb-bg: #c1c1c1;
6
+ @table-scroll-thumb-bg-hover: #a8a8a8;
7
+ @table-scroll-thumb-size: 6px;
8
+ @table-scroll-bg: #fafafa;
9
+ @sticky-scroll-bar-border-radius: @border-radius-base;
10
+ @opacity-loading: 0.6;
11
+
12
+ @motion-duration-slow: 0.3s;
13
+
14
+ .@{table-prefix-cls}-wrapper {
15
+ .@{table-prefix-cls}-sticky {
16
+ &-holder {
17
+ position: sticky;
18
+
19
+ z-index: calc(var(--columns-count) * 2 + @zindex-table-fixed + 1);
20
+ background: @background-color-base;
21
+ }
22
+
23
+ &-scroll {
24
+ position: sticky;
25
+ bottom: 0;
26
+
27
+ height: @table-scroll-thumb-size !important;
28
+ z-index: calc(var(--columns-count) * 2 + @zindex-table-fixed + 1);
29
+ display: flex;
30
+ align-items: center;
31
+ background: @table-scroll-bg;
32
+ border-top: @border-width-base @border-style-base @border-color-base;
33
+ opacity: @opacity-loading;
34
+
35
+ &:hover {
36
+ transform-origin: center bottom;
37
+ }
38
+
39
+ &-bar {
40
+ height: @table-scroll-thumb-size;
41
+ background-color: @table-scroll-thumb-bg;
42
+ border-radius: @sticky-scroll-bar-border-radius;
43
+
44
+ transition: all @motion-duration-slow, transform 0s;
45
+ position: absolute;
46
+ bottom: 0;
47
+
48
+ &:hover,
49
+ &-active {
50
+ background-color: @table-scroll-thumb-bg-hover;
51
+ }
52
+ }
53
+ }
54
+ }
55
+ }
@@ -0,0 +1,65 @@
1
+ @import '../../style/themes/index.less';
2
+
3
+ @table-prefix-cls: ~'@{ant-prefix}-table';
4
+
5
+ .@{table-prefix-cls}-wrapper {
6
+ .@{table-prefix-cls}-tbody-virtual {
7
+ .@{table-prefix-cls}-tbody-virtual-holder-inner {
8
+ & > .@{table-prefix-cls}-row,
9
+ & > div:not(.@{table-prefix-cls}-row) > .@{table-prefix-cls}-row {
10
+ display: flex;
11
+ box-sizing: border-box;
12
+ width: 100%;
13
+ }
14
+ }
15
+
16
+ .@{table-prefix-cls}-cell {
17
+ border-bottom: @border-width-base @border-style-base @border-color-base;
18
+ transition: background 0.2s;
19
+ }
20
+
21
+ .@{table-prefix-cls}-expanded-row {
22
+ .@{table-prefix-cls}-expanded-row-cell.@{table-prefix-cls}-expanded-row-cell-fixed {
23
+ position: sticky;
24
+ left: 0;
25
+ overflow: hidden;
26
+
27
+ width: calc(var(--virtual-width) - @border-width-base);
28
+ border-right: none;
29
+ }
30
+ }
31
+ }
32
+
33
+ .@{table-prefix-cls}-bordered {
34
+ .@{table-prefix-cls}-tbody-virtual {
35
+ &:after {
36
+ content: '';
37
+ left: 0;
38
+ right: 0;
39
+ bottom: 0;
40
+ border-bottom: @border-width-base @border-style-base @border-color-base;
41
+ position: absolute;
42
+ }
43
+
44
+ .@{table-prefix-cls}-cell {
45
+ border-right: @border-width-base @border-style-base @border-color-base;
46
+
47
+ &.@{table-prefix-cls}-cell-fix-right-first:before {
48
+ content: '';
49
+ position: absolute;
50
+ top: 0;
51
+ bottom: 0;
52
+ left: calc(-@border-width-base);
53
+ border-left: @border-width-base @border-style-base @border-color-base;
54
+ }
55
+ }
56
+ }
57
+
58
+ &.@{table-prefix-cls}-virtual {
59
+ .@{table-prefix-cls}-placeholder .@{table-prefix-cls}-cell {
60
+ border-right: @border-width-base @border-style-base @border-color-base;
61
+ border-bottom: @border-width-base @border-style-base @border-color-base;
62
+ }
63
+ }
64
+ }
65
+ }
@@ -0,0 +1,14 @@
1
+ /// <reference types="react" />
2
+ import type { AnyObject } from '../_util/type';
3
+ import type { ColumnTitle, ColumnTitleProps, ColumnType, Key } from './interface';
4
+ export declare const getColumnKey: <RecordType extends AnyObject = AnyObject>(column: ColumnType<RecordType>, defaultKey: string) => Key;
5
+ export declare function getColumnPos(index: number, pos?: string): string;
6
+ export declare const renderColumnTitle: <RecordType extends AnyObject = AnyObject>(title: ColumnTitle<RecordType>, props: ColumnTitleProps<RecordType>) => import("react").ReactNode;
7
+ /**
8
+ * Safe get column title
9
+ *
10
+ * Should filter [object Object]
11
+ *
12
+ * @param title
13
+ */
14
+ export declare const safeColumnTitle: <RecordType extends AnyObject = AnyObject>(title: ColumnTitle<RecordType>, props: ColumnTitleProps<RecordType>) => import("react").ReactNode;
@@ -0,0 +1,33 @@
1
+ export var getColumnKey = function getColumnKey(column, defaultKey) {
2
+ if ('key' in column && column.key !== undefined && column.key !== null) {
3
+ return column.key;
4
+ }
5
+ if (column.dataIndex) {
6
+ return Array.isArray(column.dataIndex) ? column.dataIndex.join('.') : column.dataIndex;
7
+ }
8
+ return defaultKey;
9
+ };
10
+ export function getColumnPos(index, pos) {
11
+ return pos ? "".concat(pos, "-").concat(index) : "".concat(index);
12
+ }
13
+ export var renderColumnTitle = function renderColumnTitle(title, props) {
14
+ if (typeof title === 'function') {
15
+ return title(props);
16
+ }
17
+ return title;
18
+ };
19
+
20
+ /**
21
+ * Safe get column title
22
+ *
23
+ * Should filter [object Object]
24
+ *
25
+ * @param title
26
+ */
27
+ export var safeColumnTitle = function safeColumnTitle(title, props) {
28
+ var res = renderColumnTitle(title, props);
29
+ if (Object.prototype.toString.call(res) === '[object Object]') {
30
+ return '';
31
+ }
32
+ return res;
33
+ };
@@ -0,0 +1 @@
1
+ export declare function easeInOutCubic(t: number, b: number, c: number, d: number): number;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.easeInOutCubic = easeInOutCubic;
7
+ function easeInOutCubic(t, b, c, d) {
8
+ const cc = c - b;
9
+ t /= d / 2;
10
+ if (t < 1) {
11
+ return cc / 2 * t * t * t + b;
12
+ }
13
+ // biome-ignore lint: it is a common easing function
14
+ return cc / 2 * ((t -= 2) * t * t + 2) + b;
15
+ }
@@ -0,0 +1,4 @@
1
+ declare function mergeProps<A, B>(a: A, b: B): B & A;
2
+ declare function mergeProps<A, B, C>(a: A, b: B, c: C): C & B & A;
3
+ declare function mergeProps<A, B, C, D>(a: A, b: B, c: C, d: D): D & C & B & A;
4
+ export default mergeProps;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ function mergeProps(...items) {
8
+ const ret = {};
9
+ items.forEach(item => {
10
+ if (item) {
11
+ Object.keys(item).forEach(key => {
12
+ if (item[key] !== undefined) {
13
+ ret[key] = item[key];
14
+ }
15
+ });
16
+ }
17
+ });
18
+ return ret;
19
+ }
20
+ var _default = exports.default = mergeProps;
@@ -1,3 +1,3 @@
1
- import { SizeType } from 'antd/es/config-provider/SizeContext';
2
- export declare function isPresetSize(size?: SizeType | string | number): size is SizeType;
3
- export declare function isValidGapNumber(size?: SizeType | string | number): size is number;
1
+ import type { SizeType } from 'antd/es/config-provider/SizeContext';
2
+ export declare function isPresetSize(size?: SizeType | string | number): size is SizeType;
3
+ export declare function isValidGapNumber(size?: SizeType | string | number): size is number;
@@ -0,0 +1,3 @@
1
+ export declare function isWindow(obj: any): obj is Window;
2
+ declare const getScroll: (target: HTMLElement | Window | Document | null) => number;
3
+ export default getScroll;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ exports.isWindow = isWindow;
8
+ var _isNonNullable = _interopRequireDefault(require("./isNonNullable"));
9
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
+ function isWindow(obj) {
11
+ return (0, _isNonNullable.default)(obj) && obj === obj.window;
12
+ }
13
+ const getScroll = target => {
14
+ if (typeof window === 'undefined') {
15
+ /* istanbul ignore next */
16
+ return 0;
17
+ }
18
+ let result = 0;
19
+ if (isWindow(target)) {
20
+ result = target.pageYOffset;
21
+ } else if (target instanceof Document) {
22
+ result = target.documentElement.scrollTop;
23
+ } else if (target instanceof HTMLElement) {
24
+ result = target.scrollTop;
25
+ } else if (target) {
26
+ // According to the type inference, the `target` is `never` type.
27
+ // Since we configured the loose mode type checking, and supports mocking the target with such shape below::
28
+ // `{ documentElement: { scrollLeft: 200, scrollTop: 400 } }`,
29
+ // the program may falls into this branch.
30
+ // Check the corresponding tests for details. Don't sure what is the real scenario this happens.
31
+ /* biome-ignore lint/complexity/useLiteralKeys: target is a never type */ /* eslint-disable-next-line dot-notation */
32
+ result = target['scrollTop'];
33
+ }
34
+ if (target && !isWindow(target) && typeof result !== 'number') {
35
+ result = (target.ownerDocument ?? target).documentElement?.scrollTop;
36
+ }
37
+ return result;
38
+ };
39
+ var _default = exports.default = getScroll;
@@ -1 +1,4 @@
1
- export * from './useOrientation';
1
+ export * from './useForceUpdate';
2
+ export * from './useOrientation';
3
+ export * from './useProxyImperativeHandle';
4
+ export * from './useSyncState';
@@ -3,6 +3,17 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ var _useForceUpdate = require("./useForceUpdate");
7
+ Object.keys(_useForceUpdate).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _useForceUpdate[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _useForceUpdate[key];
14
+ }
15
+ });
16
+ });
6
17
  var _useOrientation = require("./useOrientation");
7
18
  Object.keys(_useOrientation).forEach(function (key) {
8
19
  if (key === "default" || key === "__esModule") return;
@@ -13,4 +24,26 @@ Object.keys(_useOrientation).forEach(function (key) {
13
24
  return _useOrientation[key];
14
25
  }
15
26
  });
27
+ });
28
+ var _useProxyImperativeHandle = require("./useProxyImperativeHandle");
29
+ Object.keys(_useProxyImperativeHandle).forEach(function (key) {
30
+ if (key === "default" || key === "__esModule") return;
31
+ if (key in exports && exports[key] === _useProxyImperativeHandle[key]) return;
32
+ Object.defineProperty(exports, key, {
33
+ enumerable: true,
34
+ get: function () {
35
+ return _useProxyImperativeHandle[key];
36
+ }
37
+ });
38
+ });
39
+ var _useSyncState = require("./useSyncState");
40
+ Object.keys(_useSyncState).forEach(function (key) {
41
+ if (key === "default" || key === "__esModule") return;
42
+ if (key in exports && exports[key] === _useSyncState[key]) return;
43
+ Object.defineProperty(exports, key, {
44
+ enumerable: true,
45
+ get: function () {
46
+ return _useSyncState[key];
47
+ }
48
+ });
16
49
  });
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export declare const useForceUpdate: () => [any, React.DispatchWithoutAction];
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useForceUpdate = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
+ const useForceUpdate = () => {
10
+ return _react.default.useReducer(ori => ori + 1, 0);
11
+ };
12
+ exports.useForceUpdate = useForceUpdate;
@@ -1,2 +1,2 @@
1
- export declare type Orientation = 'horizontal' | 'vertical';
2
- export declare const useOrientation: (orientation?: Orientation, vertical?: boolean, legacyDirection?: Orientation) => [Orientation, boolean];
1
+ export type Orientation = 'horizontal' | 'vertical';
2
+ export declare const useOrientation: (orientation?: Orientation, vertical?: boolean, legacyDirection?: Orientation) => [Orientation, boolean];
@@ -0,0 +1,4 @@
1
+ import type { Ref } from 'react';
2
+ export declare const useProxyImperativeHandle: <NativeELementType extends HTMLElement, ReturnRefType extends {
3
+ nativeElement: NativeELementType;
4
+ }>(ref: Ref<any> | undefined, init: () => ReturnRefType) => void;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useProxyImperativeHandle = void 0;
7
+ var _react = require("react");
8
+ const fillProxy = (element, handler) => {
9
+ element._dtProxy = element._dtProxy || {};
10
+ Object.keys(handler).forEach(key => {
11
+ if (!(key in element._dtProxy)) {
12
+ const ori = element[key];
13
+ element._dtProxy[key] = ori;
14
+ element[key] = handler[key];
15
+ }
16
+ });
17
+ return element;
18
+ };
19
+ const useProxyImperativeHandle = (ref, init) => {
20
+ return (0, _react.useImperativeHandle)(ref, () => {
21
+ const refObj = init();
22
+ const {
23
+ nativeElement
24
+ } = refObj;
25
+ if (typeof Proxy !== 'undefined') {
26
+ return new Proxy(nativeElement, {
27
+ get(obj, prop) {
28
+ if (refObj[prop]) {
29
+ return refObj[prop];
30
+ }
31
+ return Reflect.get(obj, prop);
32
+ }
33
+ });
34
+ }
35
+
36
+ // Fallback of IE
37
+ return fillProxy(nativeElement, refObj);
38
+ });
39
+ };
40
+ exports.useProxyImperativeHandle = useProxyImperativeHandle;
@@ -0,0 +1,3 @@
1
+ type UseSyncStateProps<T> = readonly [() => T, (newValue: T) => void];
2
+ export declare const useSyncState: <T>(initialValue: T) => UseSyncStateProps<T>;
3
+ export {};
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useSyncState = void 0;
7
+ var React = _interopRequireWildcard(require("react"));
8
+ var _useForceUpdate = require("./useForceUpdate");
9
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
10
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
11
+ const useSyncState = initialValue => {
12
+ const ref = React.useRef(initialValue);
13
+ const [, forceUpdate] = (0, _useForceUpdate.useForceUpdate)();
14
+ return [() => ref.current, newValue => {
15
+ ref.current = newValue;
16
+ forceUpdate();
17
+ }];
18
+ };
19
+ exports.useSyncState = useSyncState;
@@ -1,3 +1,3 @@
1
- import { TooltipProps } from 'antd';
2
- export declare type LabelTooltipType = TooltipProps | TooltipProps['title'];
3
- export declare function toTooltipProps(tooltip: LabelTooltipType): TooltipProps | null;
1
+ import type { TooltipProps } from 'antd';
2
+ export type LabelTooltipType = TooltipProps | TooltipProps['title'];
3
+ export declare function toTooltipProps(tooltip: LabelTooltipType): TooltipProps | null;
@@ -1,2 +1,2 @@
1
- declare const isNonNullable: <T>(val: T) => val is NonNullable<T>;
2
- export default isNonNullable;
1
+ declare const isNonNullable: <T>(val: T) => val is NonNullable<T>;
2
+ export default isNonNullable;
@@ -0,0 +1,10 @@
1
+ interface ScrollToOptions {
2
+ /** Scroll container, default as window */
3
+ getContainer?: () => HTMLElement | Window | Document;
4
+ /** Scroll end callback */
5
+ callback?: () => void;
6
+ /** Animation duration, default as 450 */
7
+ duration?: number;
8
+ }
9
+ export default function scrollTo(y: number, options?: ScrollToOptions): () => void;
10
+ export {};
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = scrollTo;
7
+ var _raf = _interopRequireDefault(require("@rc-component/util/lib/raf"));
8
+ var _easings = require("./easings");
9
+ var _getScroll = _interopRequireWildcard(require("./getScroll"));
10
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
11
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+ function scrollTo(y, options = {}) {
14
+ const {
15
+ getContainer = () => window,
16
+ callback,
17
+ duration = 450
18
+ } = options;
19
+ const container = getContainer();
20
+ const scrollTop = (0, _getScroll.default)(container);
21
+ const startTime = Date.now();
22
+ let rafId;
23
+ const frameFunc = () => {
24
+ const timestamp = Date.now();
25
+ const time = timestamp - startTime;
26
+ const nextScrollTop = (0, _easings.easeInOutCubic)(time > duration ? duration : time, scrollTop, y, duration);
27
+ if ((0, _getScroll.isWindow)(container)) {
28
+ container.scrollTo(window.pageXOffset, nextScrollTop);
29
+ } else if (container instanceof Document || container.constructor.name === 'HTMLDocument') {
30
+ container.documentElement.scrollTop = nextScrollTop;
31
+ } else {
32
+ container.scrollTop = nextScrollTop;
33
+ }
34
+ if (time < duration) {
35
+ rafId = (0, _raf.default)(frameFunc);
36
+ } else if (typeof callback === 'function') {
37
+ callback();
38
+ }
39
+ };
40
+ rafId = (0, _raf.default)(frameFunc);
41
+ return () => {
42
+ _raf.default.cancel(rafId);
43
+ };
44
+ }
@@ -1,52 +1,52 @@
1
- import type React from 'react';
2
- export declare type Primitive = null | undefined | string | number | boolean | symbol | bigint;
3
- /** https://github.com/Microsoft/TypeScript/issues/29729 */
4
- export declare type LiteralUnion<T, U extends Primitive = string> = T | (U & Record<never, never>);
5
- export declare type AnyObject = Record<string, any>;
6
- export declare type CustomComponent<P = AnyObject> = React.ComponentType<P> | string;
7
- /**
8
- * Get component props
9
- * @example
10
- * ```ts
11
- * import { Checkbox } from '@dtjoy/dt-design'
12
- * import type { GetProps } from '@dtjoy/dt-design';
13
- *
14
- * type CheckboxGroupProps = GetProps<typeof Checkbox.Group>
15
- * ```
16
- */
17
- export declare type GetProps<T extends React.ComponentType<any> | object> = T extends React.ComponentType<infer P> ? P : T extends object ? T : never;
18
- /**
19
- * Get component props by component name
20
- * @example
21
- * ```ts
22
- * import { Select } from '@dtjoy/dt-design';
23
- * import type { GetProp, SelectProps } from '@dtjoy/dt-design';
24
- *
25
- * type SelectOption1 = GetProp<SelectProps, 'options'>[number];
26
- * // or
27
- * type SelectOption2 = GetProp<typeof Select, 'options'>[number];
28
- *
29
- * const onChange: GetProp<typeof Select, 'onChange'> = (value, option) => {
30
- * // Do something
31
- * };
32
- * ```
33
- */
34
- export declare type GetProp<T extends React.ComponentType<any> | object, PropName extends keyof GetProps<T>> = NonNullable<GetProps<T>[PropName]>;
35
- declare type ReactRefComponent<Props extends {
36
- ref?: React.Ref<any> | string;
37
- }> = (props: Props) => React.ReactNode;
38
- declare type ExtractRefAttributesRef<T> = T extends React.RefAttributes<infer P> ? P : never;
39
- /**
40
- * Get component ref
41
- * @example
42
- * ```ts
43
- * import { Input } from '@dtjoy/dt-design';
44
- * import type { GetRef } from '@dtjoy/dt-design';
45
- *
46
- * type InputRef = GetRef<typeof Input>;
47
- * ```
48
- */
49
- export declare type GetRef<T extends ReactRefComponent<any> | React.Component<any>> = T extends React.Component<any> ? T : T extends React.ComponentType<infer P> ? ExtractRefAttributesRef<P> : never;
50
- export declare type GetContextProps<T> = T extends React.Context<infer P> ? P : never;
51
- export declare type GetContextProp<T extends React.Context<any>, PropName extends keyof GetContextProps<T>> = NonNullable<GetContextProps<T>[PropName]>;
52
- export {};
1
+ import type React from 'react';
2
+ export type Primitive = null | undefined | string | number | boolean | symbol | bigint;
3
+ /** https://github.com/Microsoft/TypeScript/issues/29729 */
4
+ export type LiteralUnion<T, U extends Primitive = string> = T | (U & Record<never, never>);
5
+ export type AnyObject = Record<PropertyKey, any>;
6
+ export type CustomComponent<P = AnyObject> = React.ComponentType<P> | string;
7
+ /**
8
+ * Get component props
9
+ * @example
10
+ * ```ts
11
+ * import { Checkbox } from '@dtjoy/dt-design'
12
+ * import type { GetProps } from '@dtjoy/dt-design';
13
+ *
14
+ * type CheckboxGroupProps = GetProps<typeof Checkbox.Group>
15
+ * ```
16
+ */
17
+ export type GetProps<T extends React.ComponentType<any> | object> = T extends React.ComponentType<infer P> ? P : T extends object ? T : never;
18
+ /**
19
+ * Get component props by component name
20
+ * @example
21
+ * ```ts
22
+ * import { Select } from '@dtjoy/dt-design';
23
+ * import type { GetProp, SelectProps } from '@dtjoy/dt-design';
24
+ *
25
+ * type SelectOption1 = GetProp<SelectProps, 'options'>[number];
26
+ * // or
27
+ * type SelectOption2 = GetProp<typeof Select, 'options'>[number];
28
+ *
29
+ * const onChange: GetProp<typeof Select, 'onChange'> = (value, option) => {
30
+ * // Do something
31
+ * };
32
+ * ```
33
+ */
34
+ export type GetProp<T extends React.ComponentType<any> | object, PropName extends keyof GetProps<T>> = NonNullable<GetProps<T>[PropName]>;
35
+ type ReactRefComponent<Props extends {
36
+ ref?: React.Ref<any> | string;
37
+ }> = (props: Props) => React.ReactNode;
38
+ type ExtractRefAttributesRef<T> = T extends React.RefAttributes<infer P> ? P : never;
39
+ /**
40
+ * Get component ref
41
+ * @example
42
+ * ```ts
43
+ * import { Input } from '@dtjoy/dt-design';
44
+ * import type { GetRef } from '@dtjoy/dt-design';
45
+ *
46
+ * type InputRef = GetRef<typeof Input>;
47
+ * ```
48
+ */
49
+ export type GetRef<T extends ReactRefComponent<any> | React.Component<any>> = T extends React.Component<any> ? T : T extends React.ComponentType<infer P> ? ExtractRefAttributesRef<P> : never;
50
+ export type GetContextProps<T> = T extends React.Context<infer P> ? P : never;
51
+ export type GetContextProp<T extends React.Context<any>, PropName extends keyof GetContextProps<T>> = NonNullable<GetContextProps<T>[PropName]>;
52
+ export {};