@canvas-components/react-components 0.1.1 → 0.1.5

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/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as react from 'react';
2
- import { InputHTMLAttributes, ReactNode, KeyboardEvent, RefObject, CSSProperties } from 'react';
2
+ import { InputHTMLAttributes, ReactNode, KeyboardEvent, RefObject, CSSProperties, ButtonHTMLAttributes, MouseEvent } from 'react';
3
3
 
4
4
  interface ReactCheckboxRef {
5
5
  focus: () => void;
@@ -49,6 +49,11 @@ interface ReactInputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "s
49
49
  declare const ReactInput: react.ForwardRefExoticComponent<ReactInputProps & react.RefAttributes<HTMLInputElement>>;
50
50
 
51
51
  interface ReactColorPickerProps extends Omit<ReactInputProps, "value" | "onChange" | "onPressEnter"> {
52
+ /**
53
+ * 是否显示右侧下拉箭头。
54
+ * @default true
55
+ */
56
+ showArrow?: boolean;
52
57
  /** 当前颜色值。 */
53
58
  value?: string;
54
59
  /** 颜色变化回调,返回标准六位 HEX。 */
@@ -80,6 +85,11 @@ interface ReactDatePickerProps extends Omit<ReactInputProps, "value" | "onChange
80
85
  * 是否允许清空。
81
86
  */
82
87
  allowClear?: boolean;
88
+ /**
89
+ * 是否显示右侧下拉箭头。
90
+ * @default true
91
+ */
92
+ showArrow?: boolean;
83
93
  }
84
94
  /**
85
95
  * 基础日期选择器。
@@ -107,6 +117,11 @@ interface ReactDateRangePickerProps extends Omit<ReactInputProps, "value" | "onC
107
117
  * 是否允许清空。
108
118
  */
109
119
  allowClear?: boolean;
120
+ /**
121
+ * 是否显示右侧下拉箭头。
122
+ * @default true
123
+ */
124
+ showArrow?: boolean;
110
125
  }
111
126
  /**
112
127
  * 日期区间选择器。
@@ -130,6 +145,11 @@ interface ReactDateTimePickerProps extends Omit<ReactInputProps, "value" | "onCh
130
145
  * 是否允许清空。
131
146
  */
132
147
  allowClear?: boolean;
148
+ /**
149
+ * 是否显示右侧下拉箭头。
150
+ * @default true
151
+ */
152
+ showArrow?: boolean;
133
153
  }
134
154
  /**
135
155
  * 年月日时分秒选择器。
@@ -157,6 +177,11 @@ interface ReactDateTimeRangePickerProps extends Omit<ReactInputProps, "value" |
157
177
  * 是否允许清空。
158
178
  */
159
179
  allowClear?: boolean;
180
+ /**
181
+ * 是否显示右侧下拉箭头。
182
+ * @default true
183
+ */
184
+ showArrow?: boolean;
160
185
  }
161
186
  /**
162
187
  * 日期时间区间选择器。
@@ -191,6 +216,11 @@ interface ReactMonthPickerProps extends Omit<ReactInputProps, "value" | "onChang
191
216
  * 是否允许清空。
192
217
  */
193
218
  allowClear?: boolean;
219
+ /**
220
+ * 是否显示右侧下拉箭头。
221
+ * @default true
222
+ */
223
+ showArrow?: boolean;
194
224
  }
195
225
  /**
196
226
  * 基础月份选择器。
@@ -224,6 +254,58 @@ interface ReactNumberInputProps extends Omit<InputHTMLAttributes<HTMLInputElemen
224
254
  */
225
255
  declare const ReactNumberInput: react.ForwardRefExoticComponent<ReactNumberInputProps & react.RefAttributes<HTMLInputElement>>;
226
256
 
257
+ interface ReactInputNumberProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "size" | "value" | "defaultValue" | "onChange" | "min" | "max" | "step" | "prefix"> {
258
+ /**
259
+ * 当前值。
260
+ */
261
+ value?: number | null;
262
+ /**
263
+ * 默认值(非受控)。
264
+ */
265
+ defaultValue?: number | null;
266
+ /**
267
+ * 最小值。
268
+ */
269
+ min?: number;
270
+ /**
271
+ * 最大值。
272
+ */
273
+ max?: number;
274
+ /**
275
+ * 步进。
276
+ * @default 1
277
+ */
278
+ step?: number;
279
+ /**
280
+ * 小数精度;不传时按 step 推断。
281
+ */
282
+ precision?: number;
283
+ /**
284
+ * 值变化回调。
285
+ */
286
+ onChange?: (value: number | null) => void;
287
+ /**
288
+ * 失焦或回车时规范化后的回调。
289
+ */
290
+ onCommit?: (value: number | null) => void;
291
+ /**
292
+ * 右侧附加内容,如 `%`。
293
+ */
294
+ addonAfter?: ReactNode;
295
+ /**
296
+ * 自定义格式化显示。
297
+ */
298
+ formatter?: (value: number | null) => string;
299
+ /**
300
+ * 自定义解析输入文本。
301
+ */
302
+ parser?: (text: string) => number | null;
303
+ }
304
+ /**
305
+ * 左减右加数字计步器。
306
+ */
307
+ declare const ReactInputNumber: react.ForwardRefExoticComponent<ReactInputNumberProps & react.RefAttributes<HTMLInputElement>>;
308
+
227
309
  interface ReactPaginationProps {
228
310
  /**
229
311
  * 当前页码,从 1 开始。
@@ -349,6 +431,114 @@ interface ReactPopupProps {
349
431
  */
350
432
  declare function ReactPopup(props: ReactPopupProps): react.ReactPortal | null;
351
433
 
434
+ /**
435
+ * 确认气泡弹出位置。
436
+ */
437
+ type ReactPopconfirmPlacement = NonNullable<ReactPopupProps["placement"]>;
438
+ /**
439
+ * 确认气泡按钮属性。
440
+ */
441
+ type ReactPopconfirmButtonProps = Omit<ButtonHTMLAttributes<HTMLButtonElement>, "onClick" | "type">;
442
+ type ReactPopconfirmConfirmResult = void | Promise<void>;
443
+ interface ReactPopconfirmProps {
444
+ /**
445
+ * 触发确认气泡的内容。
446
+ */
447
+ children: ReactNode;
448
+ /**
449
+ * 确认标题。
450
+ */
451
+ title: ReactNode;
452
+ /**
453
+ * 补充说明。
454
+ */
455
+ description?: ReactNode;
456
+ /**
457
+ * 是否显示确认气泡,传入后进入受控模式。
458
+ */
459
+ open?: boolean;
460
+ /**
461
+ * 默认是否显示确认气泡。
462
+ */
463
+ defaultOpen?: boolean;
464
+ /**
465
+ * 是否禁用确认气泡。
466
+ */
467
+ disabled?: boolean;
468
+ /**
469
+ * 确认气泡位置。
470
+ */
471
+ placement?: ReactPopconfirmPlacement;
472
+ /**
473
+ * 与触发元素的间距。
474
+ */
475
+ offset?: number;
476
+ /**
477
+ * 自定义层级。
478
+ */
479
+ zIndex?: number;
480
+ /**
481
+ * 图标内容,传入 null 时隐藏默认图标。
482
+ */
483
+ icon?: ReactNode;
484
+ /**
485
+ * 确认按钮文案。
486
+ */
487
+ okText?: ReactNode;
488
+ /**
489
+ * 取消按钮文案。
490
+ */
491
+ cancelText?: ReactNode;
492
+ /**
493
+ * 是否显示取消按钮。
494
+ */
495
+ showCancel?: boolean;
496
+ /**
497
+ * 确认按钮是否加载中。
498
+ */
499
+ confirmLoading?: boolean;
500
+ /**
501
+ * 确认按钮属性。
502
+ */
503
+ okButtonProps?: ReactPopconfirmButtonProps;
504
+ /**
505
+ * 取消按钮属性。
506
+ */
507
+ cancelButtonProps?: ReactPopconfirmButtonProps;
508
+ /**
509
+ * 点击确认回调。
510
+ */
511
+ onConfirm?: (event: MouseEvent<HTMLButtonElement>) => ReactPopconfirmConfirmResult;
512
+ /**
513
+ * 点击取消回调。
514
+ */
515
+ onCancel?: (event: MouseEvent<HTMLButtonElement>) => void;
516
+ /**
517
+ * 打开状态变化回调。
518
+ */
519
+ onOpenChange?: (open: boolean) => void;
520
+ /**
521
+ * 触发器类名。
522
+ */
523
+ className?: string;
524
+ /**
525
+ * 触发器样式。
526
+ */
527
+ style?: CSSProperties;
528
+ /**
529
+ * 弹层面板类名。
530
+ */
531
+ popupClassName?: string;
532
+ /**
533
+ * 弹层面板样式。
534
+ */
535
+ popupStyle?: CSSProperties;
536
+ }
537
+ /**
538
+ * 点击触发的确认气泡组件。
539
+ */
540
+ declare function ReactPopconfirm(props: ReactPopconfirmProps): react.JSX.Element;
541
+
352
542
  interface ReactQuarterPickerProps extends Omit<ReactInputProps, "value" | "onChange" | "onPressEnter"> {
353
543
  /**
354
544
  * 当前季度值,格式为 YYYY-QN。
@@ -366,6 +556,11 @@ interface ReactQuarterPickerProps extends Omit<ReactInputProps, "value" | "onCha
366
556
  * 是否允许清空。
367
557
  */
368
558
  allowClear?: boolean;
559
+ /**
560
+ * 是否显示右侧下拉箭头。
561
+ * @default true
562
+ */
563
+ showArrow?: boolean;
369
564
  }
370
565
  /**
371
566
  * 基础季度选择器。
@@ -427,17 +622,78 @@ interface ReactSelectProps extends Omit<ReactInputProps, "value" | "onChange" |
427
622
  * 是否允许清空。
428
623
  */
429
624
  allowClear?: boolean;
625
+ /**
626
+ * 是否显示右侧下拉箭头。
627
+ * @default true
628
+ */
629
+ showArrow?: boolean;
430
630
  }
431
631
  /**
432
632
  * 基础下拉选择框。
433
633
  */
434
634
  declare const ReactSelect: react.ForwardRefExoticComponent<ReactSelectProps & react.RefAttributes<HTMLInputElement>>;
435
635
 
636
+ /**
637
+ * 过渡动画时长配置。
638
+ */
639
+ type ReactTransitionDuration = number | {
640
+ enter?: number;
641
+ leave?: number;
642
+ };
643
+ /**
644
+ * Vue 风格的过渡阶段。
645
+ */
646
+ type ReactTransitionPhase = "enter-from" | "enter-to" | "entered" | "leave-from" | "leave-to";
647
+ /**
648
+ * 过渡组件提供给渲染函数的状态。
649
+ */
650
+ interface ReactTransitionState {
651
+ /** 当前阶段对应的 CSS 类名。 */
652
+ className?: string;
653
+ /** 当前过渡阶段。 */
654
+ phase: ReactTransitionPhase;
655
+ /** 子节点当前是否需要挂载。 */
656
+ rendered: boolean;
657
+ }
658
+ /**
659
+ * 过渡状态配置。
660
+ */
661
+ interface ReactTransitionOptions {
662
+ /** 是否显示内容。 */
663
+ show: boolean;
664
+ /** CSS 类名前缀。 */
665
+ name?: string;
666
+ /** 进入和离开动画时长。 */
667
+ duration?: ReactTransitionDuration;
668
+ /** 首次显示时是否执行进入动画。 */
669
+ appear?: boolean;
670
+ }
671
+ /**
672
+ * 过渡组件属性。
673
+ */
674
+ interface ReactTransitionProps extends ReactTransitionOptions {
675
+ /** 根据过渡状态渲染内容。 */
676
+ children: (state: ReactTransitionState) => ReactNode;
677
+ }
678
+ /**
679
+ * 提供 Vue 风格 CSS 阶段的过渡状态。
680
+ */
681
+ declare function useReactTransition(options: ReactTransitionOptions): ReactTransitionState;
682
+ /**
683
+ * 在离开动画完成后卸载内容的无包装过渡组件。
684
+ */
685
+ declare function ReactTransition(props: ReactTransitionProps): ReactNode;
686
+
436
687
  interface ReactTimePickerProps extends Omit<ReactInputProps, "value" | "onChange" | "onPressEnter"> {
437
688
  value?: string;
438
689
  onChange?: (value: string) => void;
439
690
  popupClassName?: string;
440
691
  allowClear?: boolean;
692
+ /**
693
+ * 是否显示右侧下拉箭头。
694
+ * @default true
695
+ */
696
+ showArrow?: boolean;
441
697
  }
442
698
  /**
443
699
  * 基础时间选择器,支持时分秒面板选择。
@@ -445,6 +701,11 @@ interface ReactTimePickerProps extends Omit<ReactInputProps, "value" | "onChange
445
701
  declare const ReactTimePicker: react.ForwardRefExoticComponent<ReactTimePickerProps & react.RefAttributes<HTMLInputElement>>;
446
702
 
447
703
  interface ReactTimeRangePickerProps extends Omit<ReactInputProps, "value" | "onChange" | "onPressEnter"> {
704
+ /**
705
+ * 是否显示右侧下拉箭头。
706
+ * @default true
707
+ */
708
+ showArrow?: boolean;
448
709
  /**
449
710
  * 当前时间范围值,格式为 `[开始时间, 结束时间]`。
450
711
  */
@@ -553,15 +814,38 @@ interface ReactYearPickerProps extends Omit<ReactInputProps, "value" | "onChange
553
814
  * 是否允许清空。
554
815
  */
555
816
  allowClear?: boolean;
817
+ /**
818
+ * 是否显示右侧下拉箭头。
819
+ * @default true
820
+ */
821
+ showArrow?: boolean;
556
822
  }
557
823
  /**
558
824
  * 基础年份选择器。
559
825
  */
560
826
  declare const ReactYearPicker: react.ForwardRefExoticComponent<ReactYearPickerProps & react.RefAttributes<HTMLInputElement>>;
561
827
 
828
+ interface ReactContentScaleValue {
829
+ /**
830
+ * 内容缩放比例,1 表示 100%。
831
+ */
832
+ scale: number;
833
+ }
834
+ /**
835
+ * 提供内容缩放上下文,供弹出层等 portal 节点同步表格缩放。
836
+ */
837
+ declare function ReactContentScaleProvider(props: {
838
+ scale?: number;
839
+ children: ReactNode;
840
+ }): react.JSX.Element;
841
+ /**
842
+ * 读取当前内容缩放比例。
843
+ */
844
+ declare function useReactContentScale(): ReactContentScaleValue;
845
+
562
846
  /**
563
847
  * React 基础组件统一类名前缀。
564
848
  */
565
849
  declare const REACT_COMPONENT_PREFIX = "canvas-react";
566
850
 
567
- export { REACT_COMPONENT_PREFIX, ReactCheckbox, type ReactCheckboxProps, type ReactCheckboxRef, ReactColorPicker, type ReactColorPickerProps, ReactDatePicker, type ReactDatePickerProps, ReactDateRangePicker, type ReactDateRangePickerProps, ReactDateTimePicker, type ReactDateTimePickerProps, ReactDateTimeRangePicker, type ReactDateTimeRangePickerProps, ReactImagePreview, type ReactImagePreviewProps, ReactInput, type ReactInputProps, ReactMonthPicker, type ReactMonthPickerProps, ReactNumberInput, type ReactNumberInputProps, ReactPagination, type ReactPaginationProps, ReactPopup, type ReactPopupProps, ReactQuarterPicker, type ReactQuarterPickerProps, ReactSelect, type ReactSelectOption, type ReactSelectProps, ReactTimePicker, type ReactTimePickerProps, ReactTimeRangePicker, type ReactTimeRangePickerProps, ReactVirtualList, type ReactVirtualListProps, type ReactVirtualListRef, ReactYearPicker, type ReactYearPickerProps };
851
+ export { REACT_COMPONENT_PREFIX, ReactCheckbox, type ReactCheckboxProps, type ReactCheckboxRef, ReactColorPicker, type ReactColorPickerProps, ReactContentScaleProvider, type ReactContentScaleValue, ReactDatePicker, type ReactDatePickerProps, ReactDateRangePicker, type ReactDateRangePickerProps, ReactDateTimePicker, type ReactDateTimePickerProps, ReactDateTimeRangePicker, type ReactDateTimeRangePickerProps, ReactImagePreview, type ReactImagePreviewProps, ReactInput, ReactInputNumber, type ReactInputNumberProps, type ReactInputProps, ReactMonthPicker, type ReactMonthPickerProps, ReactNumberInput, type ReactNumberInputProps, ReactPagination, type ReactPaginationProps, ReactPopconfirm, type ReactPopconfirmButtonProps, type ReactPopconfirmPlacement, type ReactPopconfirmProps, ReactPopup, type ReactPopupProps, ReactQuarterPicker, type ReactQuarterPickerProps, ReactSelect, type ReactSelectOption, type ReactSelectProps, ReactTimePicker, type ReactTimePickerProps, ReactTimeRangePicker, type ReactTimeRangePickerProps, ReactTransition, type ReactTransitionDuration, type ReactTransitionOptions, type ReactTransitionPhase, type ReactTransitionProps, type ReactTransitionState, ReactVirtualList, type ReactVirtualListProps, type ReactVirtualListRef, ReactYearPicker, type ReactYearPickerProps, useReactContentScale, useReactTransition };