@clickhouse/click-ui 0.0.237-sc-deprecation.1 → 0.0.238

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 (130) hide show
  1. package/README.md +20 -161
  2. package/dist/click-ui.bundled.es.js +49537 -41533
  3. package/dist/click-ui.bundled.es.js.map +1 -0
  4. package/dist/click-ui.bundled.umd.js +53057 -78
  5. package/dist/click-ui.bundled.umd.js.map +1 -0
  6. package/dist/click-ui.es.js +48004 -41168
  7. package/dist/click-ui.es.js.map +1 -0
  8. package/dist/click-ui.umd.js +51888 -78
  9. package/dist/click-ui.umd.js.map +1 -0
  10. package/dist/components/Accordion/Accordion.d.ts +3 -3
  11. package/dist/components/Alert/Alert.d.ts +9 -3
  12. package/dist/components/AutoComplete/AutoComplete.d.ts +1 -0
  13. package/dist/components/Avatar/Avatar.d.ts +1 -1
  14. package/dist/components/Badge/Badge.d.ts +1 -1
  15. package/dist/components/BigStat/BigStat.d.ts +1 -1
  16. package/dist/components/Button/Button.d.ts +1 -1
  17. package/dist/components/ButtonGroup/ButtonGroup.d.ts +1 -1
  18. package/dist/components/CardHorizontal/CardHorizontal.d.ts +1 -1
  19. package/dist/components/CardPrimary/CardPrimaryTopBadge.d.ts +3 -14
  20. package/dist/components/CardPromotion/CardPromotion.d.ts +1 -1
  21. package/dist/components/CardSecondary/CardSecondary.d.ts +1 -1
  22. package/dist/components/Checkbox/Checkbox.d.ts +1 -1
  23. package/dist/components/ClickUIProvider/ClickUIProvider.d.ts +15 -0
  24. package/dist/components/CodeBlock/CodeBlock.d.ts +1 -1
  25. package/dist/components/CodeBlock/useColorStyle.d.ts +1 -1
  26. package/dist/components/Collapsible/Collapsible.d.ts +3 -3
  27. package/dist/components/Container/Container.d.ts +6 -5
  28. package/dist/components/DatePicker/Common.d.ts +3 -8
  29. package/dist/components/Dialog/Dialog.d.ts +2 -2
  30. package/dist/components/EllipsisContent/EllipsisContent.d.ts +6 -4
  31. package/dist/components/FileTabs/FileTabs.d.ts +2 -2
  32. package/dist/components/Flyout/Flyout.d.ts +1 -1
  33. package/dist/components/GenericMenu.d.ts +10 -22
  34. package/dist/components/Grid/Cell.d.ts +1 -2
  35. package/dist/components/Grid/StyledCell.d.ts +2 -5
  36. package/dist/components/Grid/types.d.ts +1 -1
  37. package/dist/components/GridContainer/GridContainer.d.ts +5 -4
  38. package/dist/components/Icon/IconCommon.d.ts +3 -3
  39. package/dist/components/Icon/types.d.ts +0 -2
  40. package/dist/components/IconWrapper/IconWrapper.d.ts +2 -2
  41. package/dist/components/Input/InputWrapper.d.ts +18 -25
  42. package/dist/components/Link/Link.d.ts +6 -4
  43. package/dist/components/Link/common.d.ts +7 -0
  44. package/dist/components/Logos/Logo.d.ts +1 -1
  45. package/dist/components/MultiAccordion/MultiAccordion.d.ts +1 -1
  46. package/dist/components/Panel/Panel.d.ts +1 -1
  47. package/dist/components/ProgressBar/ProgressBar.d.ts +1 -1
  48. package/dist/components/RadioGroup/RadioGroup.d.ts +1 -1
  49. package/dist/components/Select/common/SelectStyled.d.ts +26 -24
  50. package/dist/components/Separator/Separator.d.ts +3 -4
  51. package/dist/components/SidebarNavigationItem/SidebarNavigationItem.d.ts +9 -5
  52. package/dist/components/SidebarNavigationTitle/SidebarNavigationTitle.d.ts +7 -5
  53. package/dist/components/Spacer/Spacer.d.ts +1 -2
  54. package/dist/components/SplitButton/SplitButton.d.ts +1 -1
  55. package/dist/components/Tabs/Tabs.d.ts +24 -26
  56. package/dist/components/Typography/Text/Text.d.ts +5 -4
  57. package/dist/components/VerticalStepper/VerticalStepper.d.ts +2 -2
  58. package/dist/components/commonElement.d.ts +17 -21
  59. package/dist/components/commonTypes.d.ts +1 -1
  60. package/dist/components/icons/HorizontalLoading.d.ts +1 -3
  61. package/dist/components/icons/Loading.d.ts +1 -1
  62. package/dist/components/icons/LoadingAnimated.d.ts +1 -3
  63. package/dist/components/index.d.ts +3 -6
  64. package/dist/components/types.d.ts +83 -51
  65. package/dist/index.d.ts +1 -77
  66. package/dist/styles/variables.classic.json.d.ts +993 -0
  67. package/dist/{theme/tokens → styles}/variables.dark.json.d.ts +117 -117
  68. package/dist/{theme/tokens → styles}/variables.light.json.d.ts +142 -142
  69. package/dist/theme/index.d.ts +12 -6
  70. package/dist/theme/theme.d.ts +7 -0
  71. package/dist/utils/test-utils.d.ts +3 -1
  72. package/package.json +14 -40
  73. package/bin/README.md +0 -178
  74. package/bin/click-ui.config.example.ts +0 -70
  75. package/bin/click-ui.js +0 -97
  76. package/bin/commands/build-default-theme.ts +0 -48
  77. package/bin/commands/generate.js +0 -117
  78. package/bin/commands/init.js +0 -110
  79. package/bin/utils/config-loader.ts +0 -61
  80. package/bin/utils/css-generator.js +0 -32
  81. package/dist/components/Link/linkStyles.d.ts +0 -134
  82. package/dist/components/ThemeToggle/ThemeToggle.d.ts +0 -4
  83. package/dist/config/tokens/types.d.ts +0 -15296
  84. package/dist/config/tokens/types.d.ts.map +0 -1
  85. package/dist/config/tokens/types.js +0 -2
  86. package/dist/config/tokens/types.js.map +0 -1
  87. package/dist/config/types.d.ts +0 -55
  88. package/dist/config/types.d.ts.map +0 -1
  89. package/dist/config/types.js +0 -2
  90. package/dist/config/types.js.map +0 -1
  91. package/dist/config/utils/css-builder.d.ts +0 -38
  92. package/dist/config/utils/css-builder.d.ts.map +0 -1
  93. package/dist/config/utils/css-builder.js +0 -56
  94. package/dist/config/utils/css-builder.js.map +0 -1
  95. package/dist/config/utils/css-generator.d.ts +0 -25
  96. package/dist/config/utils/css-generator.d.ts.map +0 -1
  97. package/dist/config/utils/css-generator.js +0 -151
  98. package/dist/config/utils/css-generator.js.map +0 -1
  99. package/dist/config/utils/find-config.d.ts +0 -17
  100. package/dist/config/utils/find-config.d.ts.map +0 -1
  101. package/dist/config/utils/find-config.js +0 -28
  102. package/dist/config/utils/find-config.js.map +0 -1
  103. package/dist/cui-components.css +0 -1
  104. package/dist/cui-default-theme.css +0 -1809
  105. package/dist/cui.css +0 -3
  106. package/dist/stories/ChartColorComponent.d.ts +0 -1
  107. package/dist/stories/chart-examples/ChartTooltip.d.ts +0 -12
  108. package/dist/stories/chart-examples/ColorSwatchesChart.d.ts +0 -1
  109. package/dist/stories/chart-examples/GroupedBarChart.d.ts +0 -1
  110. package/dist/stories/chart-examples/MultiLineChart.d.ts +0 -1
  111. package/dist/stories/chart-examples/StackedAreaChart.d.ts +0 -1
  112. package/dist/stories/chart-examples/StackedBarChartDemo.d.ts +0 -1
  113. package/dist/theme/ClickUIProvider/ClickUIProvider.d.ts +0 -5
  114. package/dist/theme/ClickUIProvider/ServerClickUIProvider.d.ts +0 -23
  115. package/dist/theme/ClickUIProvider/context.d.ts +0 -24
  116. package/dist/theme/ClickUIProvider/hooks.d.ts +0 -4
  117. package/dist/theme/ClickUIProvider/index.d.ts +0 -6
  118. package/dist/theme/ClickUIProvider/types.d.ts +0 -39
  119. package/dist/theme/config.d.ts +0 -22
  120. package/dist/theme/hooks/useSystemColorSchemePreference.d.ts +0 -7
  121. package/dist/theme/types.d.ts +0 -54
  122. package/dist/theme/utils/css-builder.d.ts +0 -37
  123. package/dist/theme/utils/css-generator.d.ts +0 -25
  124. package/dist/theme/utils/find-config.d.ts +0 -16
  125. package/dist/theme/utils/theme-attribute.d.ts +0 -13
  126. package/dist/theme/utils.d.ts +0 -29
  127. package/dist/utils/capitalize.d.ts +0 -12
  128. package/dist/utils/polymorphic/index.d.ts +0 -48
  129. /package/dist/{theme/tokens → styles}/types.d.ts +0 -0
  130. /package/dist/{theme/tokens → styles}/variables.json.d.ts +0 -0
package/dist/cui.css DELETED
@@ -1,3 +0,0 @@
1
- /* Click UI - Combined CSS */
2
- @import "./cui-default-theme.css";
3
- @import "./cui-components.css";
@@ -1 +0,0 @@
1
- export declare const ChartColorComponent: () => import("react/jsx-runtime").JSX.Element;
@@ -1,12 +0,0 @@
1
- interface TooltipPayload {
2
- name: string;
3
- value: number;
4
- color: string;
5
- }
6
- interface ChartTooltipProps {
7
- active?: boolean;
8
- payload?: readonly TooltipPayload[];
9
- label?: string | number;
10
- }
11
- export declare const ChartTooltip: (props: ChartTooltipProps) => import("react/jsx-runtime").JSX.Element | null;
12
- export {};
@@ -1 +0,0 @@
1
- export declare const ColorSwatchesChart: () => import("react/jsx-runtime").JSX.Element;
@@ -1 +0,0 @@
1
- export declare const GroupedBarChart: () => import("react/jsx-runtime").JSX.Element;
@@ -1 +0,0 @@
1
- export declare const MultiLineChart: () => import("react/jsx-runtime").JSX.Element;
@@ -1 +0,0 @@
1
- export declare const StackedAreaChart: () => import("react/jsx-runtime").JSX.Element;
@@ -1 +0,0 @@
1
- export declare const StackedBarChartDemo: () => import("react/jsx-runtime").JSX.Element;
@@ -1,5 +0,0 @@
1
- import { default as React } from 'react';
2
- import { ClickUIProviderProps } from './types';
3
-
4
- export declare const ClickUIProvider: React.FC<ClickUIProviderProps>;
5
- export default ClickUIProvider;
@@ -1,23 +0,0 @@
1
- import { default as React } from 'react';
2
- import { ThemeName } from '../types';
3
- import { TooltipProviderProps } from '@radix-ui/react-tooltip';
4
- import { ToastProviderProps } from '../../components/Toast/Toast';
5
-
6
- interface ServerClickUIProviderProps {
7
- children: React.ReactNode;
8
- theme?: ThemeName;
9
- tooltipConfig?: Omit<TooltipProviderProps, "children">;
10
- toastConfig?: Omit<ToastProviderProps, "children">;
11
- }
12
- /**
13
- * Server-side Click UI Provider
14
- *
15
- * IMPORTANT: CSS must be imported in your app:
16
- * - With custom theme: import './cui-custom-theme.css' (generated by CLI)
17
- * - With default theme: import '@clickhouse/click-ui/dist/cui-default-theme.css'
18
- *
19
- * This provider only sets the theme attribute and provides context.
20
- * All theme CSS is pre-built and loaded via imports.
21
- */
22
- export declare const ServerClickUIProvider: ({ children, theme, tooltipConfig, toastConfig, }: ServerClickUIProviderProps) => import("react/jsx-runtime").JSX.Element;
23
- export {};
@@ -1,24 +0,0 @@
1
- import { BaseThemeName, ConfigThemeValues } from '../types';
2
-
3
- export type ThemeName = "light" | "dark" | "system";
4
- export interface ThemeContextValue {
5
- themeName: ThemeName;
6
- resolvedTheme: BaseThemeName;
7
- isSystemTheme: boolean;
8
- updateTheme: (theme: ThemeName) => void;
9
- toggleTheme: () => void;
10
- resetTheme: () => void;
11
- theme: ConfigThemeValues;
12
- breakpoints: Record<string, string>;
13
- sizes: Record<string, string>;
14
- utils: {
15
- isDark: boolean;
16
- isLight: boolean;
17
- getThemeValue: (path: string) => unknown;
18
- setThemeValue: (path: string, value: unknown) => void;
19
- };
20
- isLoading: boolean;
21
- isHydrated: boolean;
22
- availableThemes: ThemeName[];
23
- }
24
- export declare const ThemeContext: import('react').Context<ThemeContextValue | null>;
@@ -1,4 +0,0 @@
1
- import { ThemeContextValue } from './context';
2
-
3
- export declare const useCUITheme: () => ThemeContextValue;
4
- export { useCUITheme as useClickUITheme };
@@ -1,6 +0,0 @@
1
- export { default as ClickUIProvider } from './ClickUIProvider';
2
- export { ServerClickUIProvider } from './ServerClickUIProvider';
3
- export { useCUITheme, useClickUITheme } from './hooks';
4
- export type { ThemeName, ThemeContextValue } from './context';
5
- export type { ClickUIConfig, ClickUIProviderProps } from './types';
6
- export { DEFAULT_CONFIG } from './types';
@@ -1,39 +0,0 @@
1
- import { ReactNode } from 'react';
2
- import { TooltipProviderProps } from '@radix-ui/react-tooltip';
3
- import { ToastProviderProps } from '../../components/Toast/Toast';
4
- import { ThemeConfig, BaseThemeName } from '../types';
5
- import { ThemeName } from './context';
6
-
7
- export interface ClickUIConfig extends ThemeConfig {
8
- defaultTheme?: ThemeName;
9
- storageKey?: string;
10
- tooltipConfig?: Omit<TooltipProviderProps, "children">;
11
- toastConfig?: Omit<ToastProviderProps, "children">;
12
- enableTransitions?: boolean;
13
- transitionDuration?: number;
14
- preloadThemes?: BaseThemeName[];
15
- enableMemoization?: boolean;
16
- debounceDelay?: number;
17
- enableDevTools?: boolean;
18
- logThemeChanges?: boolean;
19
- breakpoints?: Record<string, string>;
20
- sizes?: Record<string, string>;
21
- }
22
- export interface ClickUIProviderProps {
23
- children: ReactNode;
24
- theme?: ThemeName;
25
- defaultTheme?: ThemeName;
26
- storageKey?: string;
27
- config?: {
28
- tooltip?: Omit<TooltipProviderProps, "children">;
29
- toast?: Omit<ToastProviderProps, "children">;
30
- };
31
- enableTransitions?: boolean;
32
- transitionDuration?: number;
33
- suppressHydrationWarning?: boolean;
34
- fallbackTheme?: BaseThemeName;
35
- enableMemoization?: boolean;
36
- debounceDelay?: number;
37
- enableDevTools?: boolean;
38
- }
39
- export declare const DEFAULT_CONFIG: Required<ClickUIConfig>;
@@ -1,22 +0,0 @@
1
- import { RuntimeConfig, ConfigThemeValues, BuildTimeThemeConfig } from './types';
2
-
3
- declare global {
4
- const __CLICK_UI_CONFIG__: RuntimeConfig & BuildTimeThemeConfig;
5
- }
6
- /**
7
- * Get runtime configuration injected by build plugin
8
- *
9
- * NOTE: This returns ONLY runtime config (storageKey, tooltipConfig, toastConfig)
10
- * Theme tokens (theme + dark) are NOT included here - they are compiled to CSS
11
- *
12
- * @returns Runtime configuration object
13
- */
14
- export declare const getRuntimeConfig: () => RuntimeConfig;
15
- /**
16
- * Get the merged theme values for the specified mode
17
- * Combines base theme (merged) + theme-specific overrides + config overrides
18
- *
19
- * @param mode - "light" or "dark"
20
- * @returns Merged theme object with all token values
21
- */
22
- export declare const getThemeValues: (mode: "light" | "dark") => ConfigThemeValues;
@@ -1,7 +0,0 @@
1
- import { ResolvedThemeName } from '../types';
2
-
3
- /**
4
- * Hook that detects and tracks the user's system color scheme preference
5
- * @returns Current system theme preference ("light" | "dark")
6
- */
7
- export declare const useSystemColorSchemePreference: () => ResolvedThemeName;
@@ -1,54 +0,0 @@
1
- import { Theme } from './tokens/types';
2
- export type NestedJSONObject = {
3
- [key: string]: string | number | NestedJSONObject | (string | number)[];
4
- };
5
- export type { Theme } from './tokens/types';
6
- export type ThemeName = "light" | "dark" | "system";
7
- export type ResolvedThemeName = Exclude<ThemeName, "system">;
8
- export type BaseThemeName = ResolvedThemeName;
9
- export type ConfigThemeValues = Theme & NestedJSONObject;
10
- export type DeepPartial<T> = {
11
- [P in keyof T]?: T[P] extends object ? T[P] extends (infer U)[] ? DeepPartial<U>[] : DeepPartial<T[P]> : T[P];
12
- };
13
- type FlexibleTheme = NestedJSONObject;
14
- export type TypedTheme = DeepPartial<Theme>;
15
- /**
16
- * Build-time theme tokens - processed by bundler plugin
17
- * These are transformed into CSS variables at build time
18
- */
19
- export interface BuildTimeThemeConfig {
20
- theme?: FlexibleTheme;
21
- dark?: FlexibleTheme;
22
- }
23
- /**
24
- * Runtime provider configuration
25
- * These settings control provider behavior at runtime
26
- */
27
- export interface RuntimeConfig {
28
- storageKey?: string;
29
- tooltipConfig?: {
30
- delayDuration?: number;
31
- skipDelayDuration?: number;
32
- disableHoverableContent?: boolean;
33
- };
34
- toastConfig?: {
35
- duration?: number;
36
- swipeDirection?: "right" | "left" | "up" | "down";
37
- swipeThreshold?: number;
38
- };
39
- }
40
- /**
41
- * Complete configuration for click-ui.config.ts
42
- * Combines both build-time theme tokens and runtime provider settings
43
- */
44
- export interface ThemeConfig extends BuildTimeThemeConfig, RuntimeConfig {
45
- }
46
- export interface ThemeContextValue {
47
- themeName: ThemeName;
48
- updateTheme: (theme: ThemeName) => void;
49
- isSystemTheme?: boolean;
50
- resolvedTheme: BaseThemeName;
51
- theme: Theme;
52
- breakpoints: Record<string, string>;
53
- sizes: Record<string, string>;
54
- }
@@ -1,37 +0,0 @@
1
- /**
2
- * Shared CSS Builder Utility
3
- * Consolidates CSS output generation logic used across build and CLI commands
4
- */
5
- export interface CSSBuildOptions {
6
- /**
7
- * Header comment to include at the top of the CSS file
8
- */
9
- headerComment?: string;
10
- /**
11
- * Include color-scheme property in :root
12
- * @default true
13
- */
14
- includeColorScheme?: boolean;
15
- }
16
- /**
17
- * Build CSS output from light-dark variables and theme overrides
18
- * Single source of truth for CSS generation across all build pipelines
19
- *
20
- * @param lightDarkVars - CSS variables with light-dark() values for colors
21
- * @param themeOverrides - Non-color variables that differ between themes
22
- * @param options - Configuration options for CSS generation
23
- * @returns Complete CSS string ready to be written to file
24
- *
25
- * @example
26
- * ```typescript
27
- * const lightDarkVars = generateLightDarkVariables(lightTheme, darkTheme);
28
- * const themeOverrides = generateThemeOverrides(lightTheme, darkTheme);
29
- * const css = buildCSSOutput(lightDarkVars, themeOverrides, {
30
- * headerComment: '/* My Custom Theme *\/'
31
- * });
32
- * ```
33
- */
34
- export declare const buildCSSOutput: (lightDarkVars: Record<string, string>, themeOverrides: {
35
- light: Record<string, string>;
36
- dark: Record<string, string>;
37
- }, options?: CSSBuildOptions) => string;
@@ -1,25 +0,0 @@
1
- import { NestedJSONObject, Theme } from '../types';
2
-
3
- /**
4
- * Core traverse function to convert nested theme object to flat variable map
5
- * Used by generateCSSVariables, themeToFlatVariables, and build plugins to avoid duplication
6
- *
7
- * @param obj - Theme or nested JSON object to traverse
8
- * @param prefix - Prefix for CSS variable names (default: "--")
9
- * @param skipFields - Fields to skip during traversal (default: ["name", "isSystem", "resolvedTheme"])
10
- * @returns Record of CSS variable names to their values
11
- */
12
- export declare const traverseThemeObject: (obj: Theme | NestedJSONObject, prefix?: string, skipFields?: string[]) => Record<string, string>;
13
- /**
14
- * Generate CSS variables with light-dark() for colors and fallback handling for non-colors
15
- * Returns an object with base variables and any theme-specific overrides needed
16
- */
17
- export declare const generateLightDarkVariables: (lightTheme: Theme, darkTheme: Theme) => Record<string, string>;
18
- /**
19
- * Generate separate theme-specific overrides for non-color variables that differ
20
- * This is needed when non-color values differ between themes and light-dark() can't be used
21
- */
22
- export declare const generateThemeOverrides: (lightTheme: Theme, darkTheme: Theme) => {
23
- light: Record<string, string>;
24
- dark: Record<string, string>;
25
- };
@@ -1,16 +0,0 @@
1
- /**
2
- * Find Click UI config file in a directory
3
- * Searches for click-ui.config with various extensions
4
- *
5
- * @param root - Directory to search in (usually process.cwd())
6
- * @returns Full path to config file, or null if not found
7
- *
8
- * @example
9
- * ```typescript
10
- * const configPath = findConfigFile(process.cwd());
11
- * if (configPath) {
12
- * console.log('Found config at:', configPath);
13
- * }
14
- * ```
15
- */
16
- export declare const findConfigFile: (root: string) => string | null;
@@ -1,13 +0,0 @@
1
- /**
2
- * Minimal runtime theme switching utility
3
- * Used when theme CSS is already loaded via build-time plugin
4
- */
5
- export type ThemeMode = "light" | "dark";
6
- /**
7
- * Set theme attribute on document root
8
- * This triggers CSS theme switching without regenerating CSS variables
9
- *
10
- * @param theme - The resolved theme ("light" or "dark")
11
- * @param isSystem - Whether system preference mode is active
12
- */
13
- export declare const setThemeAttribute: (theme: ThemeMode, isSystem?: boolean) => void;
@@ -1,29 +0,0 @@
1
- import { Theme, BaseThemeName, ThemeConfig } from './types';
2
-
3
- /**
4
- * Deep merge utility for merging theme objects
5
- * Recursively merges nested objects, with source properties taking precedence
6
- *
7
- * @param target - The target object to merge into
8
- * @param source - The source object to merge from
9
- * @returns A new merged object
10
- *
11
- * @example
12
- * ```typescript
13
- * const result = deepMerge({ a: 1, b: { c: 2 } }, { b: { d: 3 } });
14
- * // Result: { a: 1, b: { c: 2, d: 3 } }
15
- * ```
16
- */
17
- export declare const deepMerge: (target: any, source: any) => any;
18
- /**
19
- * Get base theme by name (synchronous with fallback)
20
- */
21
- export declare const getBaseTheme: (themeName: BaseThemeName) => Theme;
22
- /**
23
- * Helper to get a specific value from a theme by path
24
- * @example
25
- * getThemeValue(lightTheme, "click.button.primary.background.default")
26
- * // Returns: "#007bff"
27
- */
28
- export declare const getThemeValue: (theme: Theme | Record<string, any>, path: string) => unknown;
29
- export declare const loadCustomConfig: () => Promise<ThemeConfig | null>;
@@ -1,12 +0,0 @@
1
- /**
2
- * Capitalizes the first letter of a string and converts kebab-case to PascalCase
3
- * @param str - The string to capitalize
4
- * @returns The string with the first letter capitalized and kebab-case converted to PascalCase
5
- * @example
6
- * capitalize('hello') // 'Hello'
7
- * capitalize('WORLD') // 'WORLD'
8
- * capitalize('') // ''
9
- * capitalize('space-between') // 'SpaceBetween'
10
- * capitalize('space-around') // 'SpaceAround'
11
- */
12
- export declare const capitalize: (str: string) => string;
@@ -1,48 +0,0 @@
1
- import { ComponentProps, ComponentPropsWithRef, ElementType, ReactNode } from 'react';
2
-
3
- /**
4
- * Utility types for creating type-safe polymorphic components with SCSS modules
5
- *
6
- * Usage example:
7
- * ```tsx
8
- * interface MyComponentProps<T extends ElementType = "div"> extends PolymorphicComponentProps<T> {
9
- * customProp?: string;
10
- * }
11
- *
12
- * type MyComponentType = PolymorphicComponent<MyComponentProps>;
13
- *
14
- * const _MyComponent = <T extends ElementType = "div">(
15
- * props: PolymorphicProps<T, MyComponentProps<T>>,
16
- * ref: PolymorphicRef<T>
17
- * ) => {
18
- * const Component = props.component ?? "div";
19
- * return <Component ref={ref} {...props} />;
20
- * };
21
- *
22
- * export const MyComponent: MyComponentType = forwardRef(_MyComponent);
23
- * ```
24
- */
25
- /**
26
- * Base props for polymorphic components
27
- */
28
- export interface PolymorphicComponentProps<T extends ElementType> {
29
- component?: T;
30
- }
31
- /**
32
- * Merges the component's custom props with native HTML element props
33
- * Excludes conflicting keys from ComponentProps to ensure custom props take precedence
34
- */
35
- export type PolymorphicProps<T extends ElementType, TProps extends PolymorphicComponentProps<T>> = Omit<ComponentProps<T>, keyof TProps> & TProps;
36
- /**
37
- * Extracts the correct ref type for the polymorphic component
38
- */
39
- export type PolymorphicRef<T extends ElementType> = ComponentPropsWithRef<T>["ref"];
40
- /**
41
- * Type for the final exported polymorphic component
42
- * This uses a mapped type to properly infer the element type
43
- */
44
- export type PolymorphicComponent<TProps extends PolymorphicComponentProps<ElementType>, TDefaultElement extends ElementType = "div"> = <T extends ElementType = TDefaultElement>(props: PolymorphicProps<T, Omit<TProps, "component"> & {
45
- component?: T;
46
- }> & {
47
- ref?: PolymorphicRef<T>;
48
- }) => ReactNode;
File without changes