@officesdk/design 0.1.6 → 0.1.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.
@@ -6,6 +6,7 @@ import { ThemedStyledInterface } from 'styled-components';
6
6
  interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
7
7
  /**
8
8
  * Button variant type
9
+ * - 'icon': Square icon button without padding, size based on iconSize
9
10
  */
10
11
  variant?: 'solid' | 'outlined' | 'text' | 'icon';
11
12
  /**
@@ -30,13 +31,15 @@ interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
30
31
  */
31
32
  fullWidth?: boolean;
32
33
  /**
33
- * Icon to display before the button text
34
+ * Icon to display with the button text
35
+ * - If string: treated as icon src URL, rendered using Icon component
36
+ * - If ReactNode: rendered directly
34
37
  */
35
- iconBefore?: React.ReactNode;
38
+ icon?: string | React.ReactNode;
36
39
  /**
37
- * Icon to display after the button text
40
+ * Icon placement relative to text (only for text buttons)
38
41
  */
39
- iconAfter?: React.ReactNode;
42
+ iconPlacement?: 'before' | 'after';
40
43
  /**
41
44
  * Whether the icon button should have a border (only for variant='icon')
42
45
  */
@@ -50,12 +53,20 @@ interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
50
53
  * <Button>button</Button>
51
54
  *
52
55
  * @example
53
- * // Button with icons
54
- * <Button iconBefore={<Icon />}>button</Button>
56
+ * // Button with icon (string URL)
57
+ * <Button icon="https://example.com/icon.svg" iconPlacement="before">button</Button>
55
58
  *
56
59
  * @example
57
- * // Icon-only button
58
- * <Button variant="icon" iconBordered><Icon /></Button>
60
+ * // Button with icon (ReactNode)
61
+ * <Button icon={<CustomIcon />} iconPlacement="after">button</Button>
62
+ *
63
+ * @example
64
+ * // Icon variant button (square, no padding)
65
+ * <Button variant="icon" icon={<CustomIcon />} iconBordered />
66
+ *
67
+ * @example
68
+ * // Icon variant button without border
69
+ * <Button variant="icon" icon={<CustomIcon />} />
59
70
  */
60
71
  declare const Button: React.FC<ButtonProps>;
61
72
 
@@ -586,17 +597,29 @@ interface ToastProps {
586
597
  */
587
598
  variant?: 'success' | 'info' | 'error' | 'warn';
588
599
  /**
589
- * Toast message content
600
+ * Toast message content (main text)
590
601
  */
591
602
  message: string;
592
603
  /**
593
- * Optional action button text
604
+ * Optional description text (shows below message in multiline mode)
594
605
  */
595
- actionText?: string;
606
+ description?: string;
596
607
  /**
597
- * Action button click handler
608
+ * Main action button text (blue color)
598
609
  */
599
- onAction?: () => void;
610
+ mainButtonText?: string;
611
+ /**
612
+ * Main action button click handler
613
+ */
614
+ onMainButtonClick?: () => void;
615
+ /**
616
+ * Secondary action button text (gray color)
617
+ */
618
+ secondaryButtonText?: string;
619
+ /**
620
+ * Secondary action button click handler
621
+ */
622
+ onSecondaryButtonClick?: () => void;
600
623
  /**
601
624
  * Whether to show close button
602
625
  */
@@ -632,14 +655,28 @@ interface ToastProps {
632
655
  * A notification message component with different variants
633
656
  *
634
657
  * @example
635
- * <Toast variant="success" message="Operation successful!" />
658
+ * // Single line toast
659
+ * <Toast variant="success" message="信息反馈" />
636
660
  *
637
661
  * @example
662
+ * // Toast with buttons
638
663
  * <Toast
639
664
  * variant="info"
640
- * message="New update available"
641
- * actionText="Update"
642
- * onAction={() => console.log('Update clicked')}
665
+ * message="信息反馈"
666
+ * mainButtonText="按钮名称"
667
+ * onMainButtonClick={() => console.log('Main clicked')}
668
+ * secondaryButtonText="按钮名称"
669
+ * onSecondaryButtonClick={() => console.log('Secondary clicked')}
670
+ * closable
671
+ * />
672
+ *
673
+ * @example
674
+ * // Multi-line toast with description
675
+ * <Toast
676
+ * variant="success"
677
+ * message="信息反馈"
678
+ * description="信息具体说明"
679
+ * mainButtonText="按钮名称"
643
680
  * closable
644
681
  * />
645
682
  */
@@ -654,6 +691,7 @@ interface ToastContextValue {
654
691
  warn: (message: string, options?: Partial<ToastProps>) => string;
655
692
  }
656
693
  interface ToastContainerProps {
694
+ placement?: 'top-right' | 'top-left' | 'top-center' | 'bottom-right' | 'bottom-left' | 'bottom-center';
657
695
  /**
658
696
  * Maximum number of toasts to show at once
659
697
  */
@@ -688,6 +726,48 @@ declare const ToastContainer: React.FC<ToastContainerProps>;
688
726
  */
689
727
  declare const useToast: () => ToastContextValue;
690
728
 
729
+ type ToastPlacement = 'top-right' | 'top-left' | 'top-center' | 'bottom-right' | 'bottom-left' | 'bottom-center';
730
+ interface ToastContainerConfig {
731
+ placement?: ToastPlacement;
732
+ maxCount?: number;
733
+ defaultDuration?: number;
734
+ }
735
+ /**
736
+ * Global toast object that can be used anywhere
737
+ * No need to render ToastContainer component manually
738
+ *
739
+ * @example
740
+ * import { toast } from '@officesdk/design';
741
+ *
742
+ * // Configure (optional)
743
+ * toast.configure({
744
+ * placement: 'top-right',
745
+ * maxCount: 5,
746
+ * defaultDuration: 3000,
747
+ * });
748
+ *
749
+ * // Show toasts
750
+ * toast.success('Operation successful!');
751
+ * toast.error('Something went wrong');
752
+ * toast.info('Info message', { duration: 5000 });
753
+ * toast.warn('Warning message');
754
+ *
755
+ * const id = toast.show({ variant: 'info', message: 'Custom toast' });
756
+ * toast.hide(id);
757
+ * toast.hideAll();
758
+ */
759
+ declare const toast: {
760
+ configure: (config: ToastContainerConfig) => void;
761
+ show: (props: Omit<ToastProps, "onClose">) => string;
762
+ hide: (id: string) => void;
763
+ hideAll: () => void;
764
+ success: (message: string, options?: Partial<ToastProps>) => string;
765
+ info: (message: string, options?: Partial<ToastProps>) => string;
766
+ error: (message: string, options?: Partial<ToastProps>) => string;
767
+ warn: (message: string, options?: Partial<ToastProps>) => string;
768
+ destroy: () => void;
769
+ };
770
+
691
771
  interface TabItem {
692
772
  /**
693
773
  * Unique key for the tab
@@ -1067,4 +1147,4 @@ declare const styled: ThemedStyledInterface<Theme>;
1067
1147
 
1068
1148
  declare const getGlobalTheme: () => Theme;
1069
1149
 
1070
- export { type A11yConfig, type AnimationConfig, Button, type ButtonProps, Checkbox, type CheckboxProps, type I18nConfig, Icon, type IconComponent, type IconProps, IconProvider, type IconProviderProps, type IconRegistry, Input, type InputProps, NumberInput, type NumberInputProps, Radio, type RadioProps, SearchInput, type SearchInputProps, Slider, type SliderProps, SpinButton, type SpinButtonProps, Switch, type SwitchProps, type TabItem, Tabs, type TabsProps, Toast, type ToastConfig, ToastContainer, type ToastContainerProps, type ToastPosition, type ToastProps, ToolbarButton, type ToolbarButtonProps, Tooltip, type TooltipProps, type UIConfig, UIConfigProvider, type UIConfigProviderProps, type ZIndexConfig, createUIConfig, getGlobalTheme, mergeUIConfig, styled, useIconRegistry, useToast, useUIConfig };
1150
+ export { type A11yConfig, type AnimationConfig, Button, type ButtonProps, Checkbox, type CheckboxProps, type I18nConfig, Icon, type IconComponent, type IconProps, IconProvider, type IconProviderProps, type IconRegistry, Input, type InputProps, NumberInput, type NumberInputProps, Radio, type RadioProps, SearchInput, type SearchInputProps, Slider, type SliderProps, SpinButton, type SpinButtonProps, Switch, type SwitchProps, type TabItem, Tabs, type TabsProps, Toast, type ToastConfig, ToastContainer, type ToastContainerConfig, type ToastContainerProps, type ToastPosition, type ToastProps, ToolbarButton, type ToolbarButtonProps, Tooltip, type TooltipProps, type UIConfig, UIConfigProvider, type UIConfigProviderProps, type ZIndexConfig, createUIConfig, getGlobalTheme, mergeUIConfig, styled, toast, useIconRegistry, useToast, useUIConfig };