@officesdk/design 0.1.14 → 0.1.16

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.
@@ -550,12 +550,16 @@ interface NumberInputProps {
550
550
  * Unit text to display after the input
551
551
  */
552
552
  unit?: string;
553
+ /**
554
+ * Placeholder text
555
+ */
556
+ placeholder?: string;
553
557
  /**
554
558
  * Callback when value changes
555
- * @param fixedValue - The clamped value within min/max range
556
- * @param rawValue - The original input value before clamping
559
+ * @param fixedValue - The clamped value within min/max range (can be undefined if empty)
560
+ * @param rawValue - The original input value before clamping (can be undefined if empty)
557
561
  */
558
- onChange?: (fixedValue: number, rawValue: number) => void;
562
+ onChange?: (fixedValue: number | undefined, rawValue: number | undefined) => void;
559
563
  /**
560
564
  * Custom className
561
565
  */
@@ -1437,10 +1441,16 @@ interface UIConfigProviderProps {
1437
1441
  children: React.ReactNode;
1438
1442
  }
1439
1443
  /**
1440
- * UIConfigProvider Component
1444
+ * UIConfigProvider Component (Optional, for React convenience)
1445
+ *
1446
+ * Unified provider for all UI components and global configurations.
1447
+ * Includes IconProvider, ToastContainer, and other settings.
1448
+ *
1449
+ * Note: Global styles (Tooltip, Menu, Dropdown) are now injected on-demand
1450
+ * when components are first used, so they are no longer included here.
1441
1451
  *
1442
- * Unified provider for all UI components and global configurations
1443
- * Includes ThemeProvider, IconProvider, ToastContainer, and other settings
1452
+ * For non-React environments or when you want to avoid Provider nesting,
1453
+ * use initUIConfig() instead.
1444
1454
  *
1445
1455
  * @example
1446
1456
  * import { UIConfigProvider } from '@officesdk/design';
@@ -1462,12 +1472,15 @@ declare const UIConfigProvider: React.FC<UIConfigProviderProps>;
1462
1472
  /**
1463
1473
  * Hook to access UI configuration
1464
1474
  *
1475
+ * Falls back to global config if context is not available.
1476
+ * This allows components to work even without UIConfigProvider when initUIConfig() is used.
1477
+ *
1465
1478
  * @example
1466
1479
  * const config = useUIConfig();
1467
- * console.log(config.theme);
1468
- * console.log(config.locale);
1480
+ * console.log(config?.theme);
1481
+ * console.log(config?.locale);
1469
1482
  */
1470
- declare const useUIConfig: () => UIConfig;
1483
+ declare const useUIConfig: () => UIConfig | null;
1471
1484
 
1472
1485
  /**
1473
1486
  * Create UI configuration with default values
@@ -1491,8 +1504,83 @@ declare const createUIConfig: (config: UIConfig) => UIConfig;
1491
1504
  */
1492
1505
  declare const mergeUIConfig: (baseConfig: UIConfig, ...configs: Partial<UIConfig>[]) => UIConfig;
1493
1506
 
1507
+ /**
1508
+ * Initialize UI configuration globally (non-React)
1509
+ *
1510
+ * This function allows you to configure the UI library without using React Provider components.
1511
+ * It's useful for:
1512
+ * - Non-React environments
1513
+ * - Avoiding Provider nesting (e.g., in Modal components)
1514
+ * - Setting up configuration before React app starts
1515
+ *
1516
+ * After calling this function, all components will automatically use the global configuration.
1517
+ * Global styles (Tooltip, Menu, Dropdown) will be injected on-demand when components are first used.
1518
+ *
1519
+ * @param config - UI configuration object
1520
+ * @param config.theme - Theme configuration (required)
1521
+ * @param config.icons - Icon registry mapping icon names to React components
1522
+ * @param config.toast - Toast configuration (maxCount, defaultDuration, etc.)
1523
+ * @param config.locale - Locale code (e.g., 'zh-CN', 'en-US')
1524
+ * @param config.i18n - Internationalization configuration
1525
+ * @param config.zIndex - Z-index layer management
1526
+ * @param config.animation - Animation configuration
1527
+ * @param config.a11y - Accessibility configuration
1528
+ *
1529
+ * @example
1530
+ * import { initUIConfig } from '@officesdk/design';
1531
+ * import { lightTheme } from '@officesdk/design/theme';
1532
+ * import { iconRegistry } from '@officesdk/design/icons';
1533
+ *
1534
+ * // Initialize before React app starts
1535
+ * initUIConfig({
1536
+ * theme: lightTheme,
1537
+ * icons: iconRegistry,
1538
+ * toast: {
1539
+ * maxCount: 5,
1540
+ * defaultDuration: 3000,
1541
+ * },
1542
+ * });
1543
+ *
1544
+ * // Now you can use components without UIConfigProvider
1545
+ * function App() {
1546
+ * return <Button>Click me</Button>;
1547
+ * }
1548
+ *
1549
+ * @example
1550
+ * // Useful for Modal scenarios - no need to nest Provider
1551
+ * function Modal({ children }) {
1552
+ * return (
1553
+ * <Portal>
1554
+ * {children}
1555
+ * </Portal>
1556
+ * );
1557
+ * }
1558
+ *
1559
+ * @example
1560
+ * // Can be called multiple times to update config
1561
+ * initUIConfig({ theme: lightTheme });
1562
+ * // Later update icons
1563
+ * initUIConfig({ theme: lightTheme, icons: newIconRegistry });
1564
+ */
1565
+ declare const initUIConfig: (config: UIConfig) => void;
1566
+ /**
1567
+ * Get global UI configuration
1568
+ */
1569
+ declare const getUIConfig: () => UIConfig | null;
1570
+ /**
1571
+ * Get global icon registry
1572
+ */
1573
+ declare const getGlobalIconRegistry: () => Record<string, React.ComponentType<React.SVGProps<SVGSVGElement>>> | null;
1574
+ /**
1575
+ * Get global toast config
1576
+ */
1577
+ declare const getGlobalToastConfig: () => {
1578
+ maxCount?: number;
1579
+ defaultDuration?: number;
1580
+ } | null;
1581
+
1494
1582
  declare const styled: ThemedStyledInterface<Theme>;
1495
1583
 
1496
1584
  declare const getGlobalTheme: () => Theme;
1497
1585
 
1498
- export { type A11yConfig, type AnimationConfig, Button, type ButtonProps, Checkbox, type CheckboxProps, Dropdown, DropdownButton, type DropdownButtonProps, DropdownGlobalStyles, type DropdownProps, type I18nConfig, Icon, type IconComponent, type IconProps, IconProvider, type IconProviderProps, type IconRegistry, Input, type InputProps, Menu, type MenuDivider, MenuGlobalStyles, type MenuGroup, type MenuItem, type MenuItemType, type MenuProps, 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, UnderlinedInput, type InputProps as UnderlinedInputProps, type ZIndexConfig, createUIConfig, getGlobalTheme, mergeUIConfig, styled, toast, useIconRegistry, useToast, useUIConfig };
1586
+ export { type A11yConfig, type AnimationConfig, Button, type ButtonProps, Checkbox, type CheckboxProps, Dropdown, DropdownButton, type DropdownButtonProps, DropdownGlobalStyles, type DropdownProps, type I18nConfig, Icon, type IconComponent, type IconProps, IconProvider, type IconProviderProps, type IconRegistry, Input, type InputProps, Menu, type MenuDivider, MenuGlobalStyles, type MenuGroup, type MenuItem, type MenuItemType, type MenuProps, 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, UnderlinedInput, type InputProps as UnderlinedInputProps, type ZIndexConfig, createUIConfig, getGlobalIconRegistry, getGlobalTheme, getGlobalToastConfig, getUIConfig, initUIConfig, mergeUIConfig, styled, toast, useIconRegistry, useToast, useUIConfig };