baseline-kit 3.0.2 → 5.0.0

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 (123) hide show
  1. package/README.md +70 -48
  2. package/dist/README.md +70 -48
  3. package/dist/baseline-kit.css +3 -21
  4. package/dist/core/src/config/defaults.d.ts +2 -0
  5. package/dist/core/src/config/index.d.ts +3 -0
  6. package/dist/core/src/config/merge.d.ts +21 -0
  7. package/dist/core/src/config/schema.d.ts +33 -0
  8. package/dist/core/src/descriptors/baseline.d.ts +26 -0
  9. package/dist/core/src/descriptors/box.d.ts +20 -0
  10. package/dist/core/src/descriptors/guide.d.ts +44 -0
  11. package/dist/core/src/descriptors/index.d.ts +5 -0
  12. package/dist/core/src/descriptors/padder.d.ts +19 -0
  13. package/dist/core/src/descriptors/spacer.d.ts +24 -0
  14. package/dist/core/src/index.d.ts +10 -0
  15. package/dist/core/src/types.d.ts +62 -0
  16. package/dist/core/src/utils/convert.d.ts +10 -0
  17. package/dist/core/src/utils/grid.d.ts +18 -0
  18. package/dist/{utils → core/src/utils}/index.d.ts +2 -9
  19. package/dist/core/src/utils/math.d.ts +9 -0
  20. package/dist/core/src/utils/merge.d.ts +28 -0
  21. package/dist/core/src/utils/normalize.d.ts +13 -0
  22. package/dist/core/src/utils/padding.d.ts +2 -0
  23. package/dist/core/src/utils/parse.d.ts +5 -0
  24. package/dist/core/src/utils/snapping.d.ts +2 -0
  25. package/dist/core/src/validation/guide.d.ts +3 -0
  26. package/dist/core/src/validation/index.d.ts +1 -0
  27. package/dist/core.cjs +1 -0
  28. package/dist/core.d.ts +344 -0
  29. package/dist/core.mjs +2 -0
  30. package/dist/dom/src/index.d.ts +11 -0
  31. package/dist/dom/src/measure.d.ts +18 -0
  32. package/dist/dom/src/observers.d.ts +5 -0
  33. package/dist/{utils → dom/src}/ssr.d.ts +0 -6
  34. package/dist/dom/src/timing.d.ts +2 -0
  35. package/dist/dom/src/viewport.d.ts +7 -0
  36. package/dist/dom/src/virtual.d.ts +23 -0
  37. package/dist/guide.cjs +2 -0
  38. package/dist/guide.cjs.map +1 -0
  39. package/dist/guide.css +2 -0
  40. package/dist/guide.d.ts +146 -0
  41. package/dist/guide.mjs +589 -0
  42. package/dist/guide.mjs.map +1 -0
  43. package/dist/index.cjs +2 -2
  44. package/dist/index.cjs.map +1 -1
  45. package/dist/index.d.ts +197 -30
  46. package/dist/index.mjs +614 -1747
  47. package/dist/index.mjs.map +1 -1
  48. package/dist/react/src/components/Baseline/Baseline.d.ts +13 -0
  49. package/dist/react/src/components/Baseline/index.d.ts +1 -0
  50. package/dist/react/src/components/Box/Box.d.ts +26 -0
  51. package/dist/react/src/components/Box/index.d.ts +1 -0
  52. package/dist/react/src/components/Config/Config.d.ts +20 -0
  53. package/dist/react/src/components/Config/index.d.ts +2 -0
  54. package/dist/react/src/components/Guide/Guide.d.ts +16 -0
  55. package/dist/react/src/components/Guide/index.d.ts +1 -0
  56. package/dist/react/src/components/Padder/Padder.d.ts +20 -0
  57. package/dist/react/src/components/Padder/index.d.ts +1 -0
  58. package/dist/react/src/components/Spacer/Spacer.d.ts +14 -0
  59. package/dist/react/src/components/Spacer/index.d.ts +1 -0
  60. package/dist/{components → react/src/components}/index.d.ts +1 -5
  61. package/dist/react/src/components/types.d.ts +29 -0
  62. package/dist/react/src/guide.d.ts +10 -0
  63. package/dist/{hooks → react/src/hooks}/index.d.ts +2 -3
  64. package/dist/react/src/hooks/useBaseline.d.ts +26 -0
  65. package/dist/react/src/hooks/useConfig.d.ts +9 -0
  66. package/dist/react/src/hooks/useDebug.d.ts +6 -0
  67. package/dist/react/src/hooks/useGuide.d.ts +7 -0
  68. package/dist/{hooks → react/src/hooks}/useIsClient.d.ts +0 -2
  69. package/dist/react/src/hooks/useMeasure.d.ts +10 -0
  70. package/dist/react/src/hooks/useVirtual.d.ts +14 -0
  71. package/dist/react/src/index.d.ts +21 -0
  72. package/dist/react/src/utils/index.d.ts +9 -0
  73. package/dist/react/src/utils/merge.d.ts +10 -0
  74. package/dist/react/src/utils/ssr.d.ts +1 -0
  75. package/dist/reset.css +43 -0
  76. package/dist/src-CMjyHjX5.cjs +2 -0
  77. package/dist/src-CMjyHjX5.cjs.map +1 -0
  78. package/dist/src-QHaSfgVe.js +619 -0
  79. package/dist/src-QHaSfgVe.js.map +1 -0
  80. package/dist/styles.css +1 -1
  81. package/dist/theme/dark.css +0 -8
  82. package/dist/theme/default.css +0 -9
  83. package/dist/theme/tokens.css +1 -10
  84. package/dist/theme.css +0 -18
  85. package/package.json +82 -42
  86. package/dist/components/Baseline/Baseline.d.ts +0 -48
  87. package/dist/components/Baseline/index.d.ts +0 -6
  88. package/dist/components/Box/Box.d.ts +0 -73
  89. package/dist/components/Box/index.d.ts +0 -6
  90. package/dist/components/Config/Config.d.ts +0 -179
  91. package/dist/components/Config/defaults.d.ts +0 -25
  92. package/dist/components/Config/index.d.ts +0 -11
  93. package/dist/components/Guide/Guide.d.ts +0 -70
  94. package/dist/components/Guide/index.d.ts +0 -6
  95. package/dist/components/Guide/types.d.ts +0 -144
  96. package/dist/components/Guide/validation.d.ts +0 -82
  97. package/dist/components/Layout/Layout.d.ts +0 -73
  98. package/dist/components/Layout/index.d.ts +0 -10
  99. package/dist/components/Padder/Padder.d.ts +0 -67
  100. package/dist/components/Padder/index.d.ts +0 -10
  101. package/dist/components/Spacer/Spacer.d.ts +0 -48
  102. package/dist/components/Spacer/index.d.ts +0 -10
  103. package/dist/components/Stack/Stack.d.ts +0 -84
  104. package/dist/components/Stack/index.d.ts +0 -10
  105. package/dist/components/styles/index.d.ts +0 -11
  106. package/dist/components/types.d.ts +0 -102
  107. package/dist/hooks/useBaseline.d.ts +0 -55
  108. package/dist/hooks/useConfig.d.ts +0 -41
  109. package/dist/hooks/useDebug.d.ts +0 -49
  110. package/dist/hooks/useGuide.d.ts +0 -61
  111. package/dist/hooks/useMeasure.d.ts +0 -35
  112. package/dist/hooks/useVirtual.d.ts +0 -60
  113. package/dist/styles.d.ts +0 -6
  114. package/dist/theme.d.ts +0 -6
  115. package/dist/utils/convert.d.ts +0 -24
  116. package/dist/utils/grid.d.ts +0 -22
  117. package/dist/utils/math.d.ts +0 -48
  118. package/dist/utils/merge.d.ts +0 -117
  119. package/dist/utils/normalize.d.ts +0 -30
  120. package/dist/utils/padding.d.ts +0 -11
  121. package/dist/utils/parse.d.ts +0 -18
  122. package/dist/utils/snapping.d.ts +0 -28
  123. package/dist/utils/timing.d.ts +0 -45
@@ -1,48 +0,0 @@
1
- import * as React from 'react';
2
- import { ComponentsProps, Variant } from '../types';
3
- export type IndicatorNode = (value: number, type: 'width' | 'height') => React.ReactNode;
4
- export type SpacerProps = {
5
- /** Explicit width (takes precedence over block) */
6
- width?: React.CSSProperties['width'];
7
- /** Explicit height (takes precedence over block) */
8
- height?: React.CSSProperties['height'];
9
- /** Visual style in debug mode */
10
- variant?: Variant;
11
- /** Color to use for debug visuals (overrides theme) */
12
- color?: string;
13
- /** Base unit for measurements (defaults to theme value) */
14
- base?: number;
15
- /** Custom content to render (for debugging info) */
16
- children?: React.ReactNode;
17
- /** Custom indicator node rendering function */
18
- indicatorNode?: IndicatorNode;
19
- /** Flag to enable SSR-compatible mode (simplified initial render) */
20
- ssrMode?: boolean;
21
- } & ComponentsProps;
22
- /**
23
- * Creates empty space for implementing margins, gaps, and spacing.
24
- *
25
- * @remarks
26
- * - Flexible sizing: Set width and height directly
27
- * - Normalized values: All inputs convert to base unit multiples
28
- * - Debug visuals: Shows spacing measurements with theming
29
- * - Automatic: Empty in production, visible in debug mode
30
- *
31
- * @example
32
- * ```tsx
33
- * // Fixed size spacer
34
- * <Spacer width={32} height={16} />
35
- *
36
- * // Percentage-based spacer with debug hints
37
- * <Spacer
38
- * width="50%"
39
- * height={32}
40
- * debugging="visible"
41
- * variant="line"
42
- * />
43
- *
44
- * // Full-width spacer
45
- * <Spacer height={64} />
46
- * ```
47
- */
48
- export declare const Spacer: React.NamedExoticComponent<SpacerProps>;
@@ -1,10 +0,0 @@
1
- /**
2
- * @file Spacer Component Entry (components/Spacer/index.ts)
3
- * @description Spacing management component with measurement indicators
4
- * @module baseline-kit/components/Spacer
5
- *
6
- * @remarks
7
- * Provides both horizontal and vertical spacing with optional
8
- * visual debugging features.
9
- */
10
- export * from './Spacer';
@@ -1,84 +0,0 @@
1
- import * as React from 'react';
2
- import type { Gaps } from '@components';
3
- import { IndicatorNode } from '../Spacer';
4
- import { ComponentsProps, Variant } from '../types';
5
- declare const DIRECTION_AXIS: Record<string, React.CSSProperties['flexDirection']>;
6
- export type CSSPropertiesDirectionalAxis = keyof typeof DIRECTION_AXIS;
7
- export type StackProps = {
8
- /** Main axis orientation */
9
- direction?: React.CSSProperties['flexDirection'] & CSSPropertiesDirectionalAxis;
10
- /** Distribution of space on main axis */
11
- justify?: React.CSSProperties['justifyContent'];
12
- /** Alignment on cross axis */
13
- align?: React.CSSProperties['alignItems'];
14
- /** Container width (defaults to "auto") */
15
- width?: React.CSSProperties['width'];
16
- /** Container height (defaults to "auto") */
17
- height?: React.CSSProperties['height'];
18
- /** Custom measurement indicator renderer */
19
- indicatorNode?: IndicatorNode;
20
- /** Visual style in debug mode */
21
- variant?: Variant;
22
- /** Gap between items in base units */
23
- gap?: Gaps;
24
- /** Row gap when using different values for rows and columns */
25
- rowGap?: Gaps;
26
- /** Column gap when using different values for rows and columns */
27
- columnGap?: Gaps;
28
- /** Flag to enable SSR-compatible mode (simplified initial render) */
29
- ssrMode?: boolean;
30
- children?: React.ReactNode;
31
- } & ComponentsProps;
32
- /**
33
- * A flexible container component aligning children to the baseline grid.
34
- *
35
- * @remarks
36
- * Stack provides a flex container that:
37
- * - Maintains baseline grid alignment
38
- * - Supports both row and column layouts
39
- * - Handles consistent spacing between items
40
- * - Includes visual debug overlays
41
- *
42
- * Key features:
43
- * - Automatic dimension management (defaults to auto)
44
- * - Direct padding application in non-debug mode
45
- * - Comprehensive alignment controls
46
- * - Theme-aware debug visuals
47
- *
48
- * @example
49
- * ```tsx
50
- * // Basic horizontal stack
51
- * <Stack gap={16}>
52
- * <div>Item 1</div>
53
- * <div>Item 2</div>
54
- * </Stack>
55
- *
56
- * // Vertical stack with alignment
57
- * <Stack
58
- * direction="column"
59
- * gap={24}
60
- * align="center"
61
- * justify="space-between"
62
- * debugging="visible"
63
- * >
64
- * <div>Top</div>
65
- * <div>Middle</div>
66
- * <div>Bottom</div>
67
- * </Stack>
68
- *
69
- * // Complex layout with padding
70
- * <Stack
71
- * direction="row"
72
- * gap={32}
73
- * align="stretch"
74
- * block={[16, 24]}
75
- * inline={16}
76
- * debugging="visible"
77
- * >
78
- * <div>Panel 1</div>
79
- * <div>Panel 2</div>
80
- * </Stack>
81
- * ```
82
- */
83
- export declare const Stack: React.NamedExoticComponent<StackProps>;
84
- export {};
@@ -1,10 +0,0 @@
1
- /**
2
- * @file Stack/Flex Component Entry (components/Stack/index.ts)
3
- * @description Flexible container with baseline grid alignment
4
- * @module baseline-kit/components/Stack
5
- *
6
- * @remarks
7
- * While the component is called Stack internally, it's exported as Flex
8
- * for API consistency.
9
- */
10
- export * from './Stack';
@@ -1,11 +0,0 @@
1
- /**
2
- * Baseline Kit Styles System
3
- *
4
- * This file exports all core styles needed for the component library.
5
- * The import order is important:
6
- * 1. core.css - Contains reset.css, base.css, and component styles
7
- * 2. theme.css - Contains color variables and theming
8
- */
9
- import './core.css';
10
- import './theme.css';
11
- export {};
@@ -1,102 +0,0 @@
1
- import * as React from 'react';
2
- import { DebuggingMode } from './Config/Config';
3
- /**
4
- * Defines spacing as either a single value, start/end pair, or object with explicit edges.
5
- * Used for block and inline spacing across components.
6
- *
7
- * @example
8
- * ```tsx
9
- * // Single value
10
- * <Box block={8} />
11
- *
12
- * // Start/end pair
13
- * <Box block={[8, 16]} />
14
- *
15
- * // Object with explicit values
16
- * <Box block={{ start: 8, end: 16 }} />
17
- * ```
18
- */
19
- export type Spacing = number | [number, number] | {
20
- start?: number;
21
- end?: number;
22
- };
23
- /**
24
- * Flexible padding definition that supports multiple formats for setting padding on all sides.
25
- *
26
- * @example
27
- * ```tsx
28
- * // Single value for all sides
29
- * padding={8}
30
- *
31
- * // Block and inline pairs
32
- * padding={[8, 16]}
33
- *
34
- * // Explicit values for each side
35
- * padding={[8, 16, 8, 16]}
36
- *
37
- * // Object with named sides
38
- * padding={{ top: 8, right: 16, bottom: 8, left: 16 }}
39
- * ```
40
- */
41
- export type PaddingValue = number | [number, number] | [number, number, number, number] | {
42
- top?: number;
43
- bottom?: number;
44
- left?: number;
45
- right?: number;
46
- };
47
- /** Resolved padding values for all edges after normalization. */
48
- export type Padding = {
49
- top: number;
50
- right: number;
51
- bottom: number;
52
- left: number;
53
- };
54
- /** Props interface for components that support spacing configuration. */
55
- export type SpacingProps = {
56
- padding?: PaddingValue;
57
- block?: Spacing;
58
- inline?: Spacing;
59
- };
60
- /** Controls how columns are laid out in grid components. */
61
- export type GuideVariant = 'line' | 'pattern' | 'fixed' | 'auto';
62
- /**
63
- * Valid value types for grid columns. Can be a CSS length, fractional unit,
64
- * or 'auto' for automatic sizing.
65
- */
66
- export type GuideColumnValue = string | number | undefined | 'auto';
67
- /** Array of column definitions for pattern-based grid layouts. */
68
- export type GuideColumnsPattern = readonly GuideColumnValue[];
69
- /** Valid grid alignment values. */
70
- export declare const GRID_ALIGNMENTS: readonly ["start", "center", "end"];
71
- export type GridAlignment = (typeof GRID_ALIGNMENTS)[number];
72
- /** Valid component variants affecting visual style. */
73
- export declare const PADD_VARIANTS: readonly ["line", "flat"];
74
- export type PaddedVariant = (typeof PADD_VARIANTS)[number];
75
- /**
76
- * Common props shared across library components.
77
- * Provides consistent sizing, spacing, styling, and debugging options.
78
- */
79
- export type ComponentsProps = {
80
- debugging?: DebuggingMode;
81
- className?: string;
82
- style?: React.CSSProperties;
83
- height?: React.CSSProperties['height'];
84
- width?: React.CSSProperties['width'];
85
- } & SpacingProps;
86
- /** Base configuration for components that support padding. */
87
- export type PaddedBaseConfig = {
88
- base?: number;
89
- color?: React.CSSProperties['color'] | React.CSSProperties['backgroundColor'];
90
- zIndex?: React.CSSProperties['zIndex'];
91
- };
92
- export type Variant = 'line' | 'flat' | 'pattern';
93
- export type Gaps = {
94
- gap?: React.CSSProperties['gap'];
95
- rowGap?: never;
96
- columnGap?: never;
97
- } | {
98
- /** When using separate gaps, omit unified gap */
99
- gap?: never;
100
- rowGap?: React.CSSProperties['rowGap'];
101
- columnGap?: React.CSSProperties['columnGap'];
102
- };
@@ -1,55 +0,0 @@
1
- import * as React from 'react';
2
- import type { SnappingMode, Padding } from '@components';
3
- export interface BaselineOptions {
4
- base?: number;
5
- /** Snapping strategy: 'none' | 'height' | 'clamp'. */
6
- snapping?: SnappingMode;
7
- /** Initial padding config. e.g. { top: 10, bottom: 20 } or just 8, etc. */
8
- spacing?: Partial<Padding> | number;
9
- /** Whether to warn in the console if the measured height is not a multiple of base. */
10
- warnOnMisalignment?: boolean;
11
- }
12
- export interface BaselineResult {
13
- padding: Padding;
14
- isAligned: boolean;
15
- height: number;
16
- }
17
- /**
18
- * Hook for managing baseline grid alignment in components.
19
- *
20
- * @remarks
21
- * This hook handles the complex calculations needed to maintain baseline grid
22
- * alignment, including:
23
- * ▪ Measuring element dimensions
24
- * ▪ Calculating padding adjustments
25
- * ▪ Potentially snapping values to ensure multiples of the base
26
- * ▪ Warning about misalignments in development
27
- *
28
- * Different snapping modes affect how spacing is adjusted:
29
- * ▪ 'none': Uses raw spacing values without adjustment
30
- * ▪ 'height': Adjusts only the final (bottom) padding to align
31
- * ▪ 'clamp': Adjusts top and bottom to align
32
- *
33
- * @param ref Reference to the DOM element
34
- * @param options Configuration options for alignment behavior
35
- * @returns Object with adjusted padding, alignment status, and height
36
- *
37
- * @example
38
- * ```tsx
39
- * export function MyComponent() {
40
- * const ref = useRef<HTMLDivElement>(null)
41
- * const { padding } = useBaseline(ref, {
42
- * base: 8,
43
- * snapping: 'height',
44
- * spacing: {
45
- * top: 16,
46
- * bottom: 16
47
- * }
48
- * }}
49
- * >
50
- * Content
51
- * </div>
52
- * )
53
- * }
54
- */
55
- export declare function useBaseline(ref: React.RefObject<HTMLElement | null>, { base, snapping, spacing, warnOnMisalignment, }?: BaselineOptions): BaselineResult;
@@ -1,41 +0,0 @@
1
- import { ConfigSchema } from '@components';
2
- /** Type helper that merges base configuration with component-specific settings. */
3
- export type ComponentConfig<K extends keyof ConfigSchema> = ConfigSchema[K] & {
4
- /** Base unit for spacing calculations */
5
- base: number;
6
- };
7
- /**
8
- * Hook for accessing component-specific theme configuration.
9
- *
10
- * @remarks
11
- * This hook provides:
12
- * - Access to component-specific theme settings
13
- * - Automatic base unit inheritance
14
- * - Memoized configuration to prevent unnecessary updates
15
- * - Type-safe configuration access
16
- *
17
- * It merges:
18
- * - Global base unit settings
19
- * - Component-specific configurations
20
- * - Theme-based color schemes
21
- *
22
- * @param component - Name of the component requesting configuration
23
- * @returns Merged configuration for the specific component
24
- *
25
- * @example
26
- * ```tsx
27
- * function Box() {
28
- * const config = useConfig('box');
29
- *
30
- * return (
31
- * <div style={{
32
- * '--box-base': `${config.base}px`,
33
- * '--box-color': config.colors.line
34
- * }}>
35
- * {children}
36
- * </div>
37
- * );
38
- * }
39
- * ```
40
- */
41
- export declare function useConfig<K extends keyof ConfigSchema>(component: K): ComponentConfig<K>;
@@ -1,49 +0,0 @@
1
- import { DebuggingMode } from '../components/Config/Config';
2
- interface DebugResult {
3
- /** Whether debug visuals should be shown */
4
- isShown: boolean;
5
- /** Whether debug features exist but are hidden */
6
- isHidden: boolean;
7
- /** Whether debug features are disabled */
8
- isNone: boolean;
9
- /** Current debugging mode */
10
- debugging: DebuggingMode | undefined;
11
- }
12
- /**
13
- * Hook for managing component debug state and visibility.
14
- *
15
- * @remarks
16
- * Determines the active debugging mode by:
17
- * - Using prop value if provided
18
- * - Falling back to config value if prop is undefined
19
- * - Computing visibility states based on active mode
20
- *
21
- * This hook helps components:
22
- * - Control debug visual rendering
23
- * - Manage debug feature states
24
- * - Handle prop/config inheritance
25
- *
26
- * @param debuggingProp - Optional debugging mode from props
27
- * @param debuggingConfig - Debugging mode from theme/config
28
- * @returns Debug state information
29
- *
30
- * @example
31
- * ```tsx
32
- * function DebugComponent({ debugging: debugProp }) {
33
- * const { isShown, isHidden, isNone } = useDebug(
34
- * debugProp,
35
- * 'hidden' // Default from config
36
- * );
37
- *
38
- * return (
39
- * <div>
40
- * {isShown && <DebugOverlay />}
41
- * {!isNone && <DebugFeatures />}
42
- * <Content />
43
- * </div>
44
- * );
45
- * }
46
- * ```
47
- */
48
- export declare function useDebug(debuggingProp?: DebuggingMode, debuggingConfig?: DebuggingMode): DebugResult;
49
- export {};
@@ -1,61 +0,0 @@
1
- import * as React from 'react';
2
- import { GuideConfig } from '@components';
3
- export interface GuideResult {
4
- /** CSS grid template string */
5
- template: string;
6
- /** Total number of columns */
7
- columnsCount: number;
8
- /** Final gap size in pixels */
9
- calculatedGap: number;
10
- /** Whether the configuration is valid */
11
- isValid: boolean;
12
- }
13
- /**
14
- * Hook for calculating grid layout parameters based on container dimensions.
15
- *
16
- * @remarks
17
- * This hook handles complex grid calculations for different layout variants:
18
- * - 'line': Evenly spaced vertical lines
19
- * - 'pattern': Custom repeating column patterns
20
- * - 'fixed': Set number of columns with optional width
21
- * - 'auto': Dynamic columns based on available space
22
- *
23
- * Key features:
24
- * - Responsive grid calculations
25
- * - Pattern validation
26
- * - Gap management
27
- * - Error handling
28
- *
29
- * @param ref - Reference to container element
30
- * @param config - Grid configuration object
31
- * @returns Grid calculation results
32
- *
33
- * @example
34
- * ```tsx
35
- * function GridOverlay() {
36
- * const ref = useRef<HTMLDivElement>(null);
37
- * const { template, columnsCount } = useGuide(ref, {
38
- * variant: 'fixed',
39
- * columns: 12,
40
- * gap: 16,
41
- * base: 8
42
- * });
43
- *
44
- * return (
45
- * <div
46
- * ref={ref}
47
- * style={{
48
- * display: 'grid',
49
- * gridTemplateColumns: template,
50
- * gap: calculatedGap
51
- * }}
52
- * >
53
- * {Array(columnsCount).fill(null).map((_, i) => (
54
- * <div key={i} className="grid-line" />
55
- * ))}
56
- * </div>
57
- * );
58
- * }
59
- * ```
60
- */
61
- export declare function useGuide(ref: React.RefObject<HTMLElement | null>, config: GuideConfig): GuideResult;
@@ -1,35 +0,0 @@
1
- import * as React from 'react';
2
- export interface MeasureResult {
3
- /** Measured width in pixels */
4
- width: number;
5
- /** Measured height in pixels */
6
- height: number;
7
- /** Function to force a remeasurement */
8
- refresh: () => void;
9
- }
10
- /**
11
- * Hook for measuring and tracking DOM element dimensions.
12
- *
13
- * Provides responsive element measurements using ResizeObserver,
14
- * with performance optimization (via RAF throttling), error handling,
15
- * and a manual refresh method.
16
- *
17
- * @param ref - Reference to the DOM element to measure
18
- * @returns Current dimensions and refresh function
19
- *
20
- * @example
21
- * ```tsx
22
- * function ResponsiveBox() {
23
- * const ref = React.useRef<HTMLDivElement>(null);
24
- * const { width, height, refresh } = useMeasure(ref);
25
- *
26
- * return (
27
- * <div ref={ref} className="responsive-box">
28
- * Width: {width}px, Height: {height}px
29
- * <button onClick={refresh}>Remeasure</button>
30
- * </div>
31
- * );
32
- * }
33
- * ```
34
- */
35
- export declare function useMeasure(ref: React.RefObject<HTMLElement | null>): MeasureResult;
@@ -1,60 +0,0 @@
1
- import { RefObject } from 'react';
2
- type VirtualResult = {
3
- /** Total number of items/lines to virtualize */
4
- totalLines: number;
5
- /** Height of each item in pixels */
6
- lineHeight: number;
7
- /** Reference to the scrollable container */
8
- containerRef: RefObject<HTMLDivElement | null>;
9
- /** Additional items to render above/below viewport */
10
- buffer?: number | string;
11
- };
12
- /**
13
- * Hook for optimizing large lists through virtual scrolling.
14
- *
15
- * @remarks
16
- * This hook helps manage virtual scrolling by:
17
- * - Calculating visible item ranges
18
- * - Handling scroll events efficiently
19
- * - Managing buffer zones for smooth scrolling
20
- * - Supporting dynamic container sizes
21
- *
22
- * Performance optimizations:
23
- * - RAF-based scroll handling
24
- * - Intersection Observer for visibility
25
- * - Buffer zones to prevent flicker
26
- * - Efficient range calculations
27
- *
28
- * @param options - Virtual scrolling configuration
29
- * @returns Object containing start and end indices of visible items
30
- *
31
- * @example
32
- * ```tsx
33
- * function VirtualList() {
34
- * const containerRef = useRef<HTMLDivElement>(null);
35
- * const { start, end } = useVirtual({
36
- * totalLines: 1000,
37
- * lineHeight: 30,
38
- * containerRef,
39
- * buffer: 5
40
- * });
41
- *
42
- * return (
43
- * <div ref={containerRef} className="scroll-container">
44
- * <div style={{ height: 1000 * 30 }}>
45
- * {items.slice(start, end).map(item => (
46
- * <div key={item.id} style={{ height: 30 }}>
47
- * {item.content}
48
- * </div>
49
- * ))}
50
- * </div>
51
- * </div>
52
- * );
53
- * }
54
- * ```
55
- */
56
- export declare function useVirtual({ totalLines, lineHeight, containerRef, buffer, }: VirtualResult): {
57
- start: number;
58
- end: number;
59
- };
60
- export {};
package/dist/styles.d.ts DELETED
@@ -1,6 +0,0 @@
1
- /**
2
- * @file Style Entry Point
3
- * @description Clean import path for core CSS styles
4
- * @module baseline-kit/styles
5
- */
6
- import './components/styles/core.css';
package/dist/theme.d.ts DELETED
@@ -1,6 +0,0 @@
1
- /**
2
- * @file Theme Entry Point
3
- * @description Clean import path for theme CSS styles
4
- * @module baseline-kit/theme
5
- */
6
- import './components/styles/theme.css';
@@ -1,24 +0,0 @@
1
- export interface ConversionContext {
2
- /** Parent element dimension for relative units */
3
- parentSize?: number;
4
- /** Viewport width for vw units */
5
- viewportWidth?: number;
6
- /** Viewport height for vh units */
7
- viewportHeight?: number;
8
- /** Root font size for rem units */
9
- rootFontSize?: number;
10
- /** Parent font size for em units */
11
- parentFontSize?: number;
12
- }
13
- /** Conversion factors for absolute units to pixels */
14
- export declare const ABSOLUTE_UNIT_CONVERSIONS: Record<string, number>;
15
- /** Supported relative CSS units */
16
- export declare const RELATIVE_UNITS: string[];
17
- /**
18
- * Converts CSS values to pixels.
19
- *
20
- * @param value - CSS value to convert
21
- * @param context - Optional context for relative unit conversion
22
- * @returns Value in pixels or null if conversion fails
23
- */
24
- export declare function convertValue(value: number | string | undefined, context?: ConversionContext): number | null;
@@ -1,22 +0,0 @@
1
- /**
2
- * @file grid.ts
3
- * @description Grid layout utilities
4
- * @module utils
5
- */
6
- import * as React from 'react';
7
- /**
8
- * Creates grid span styles based on span props.
9
- * Handles both combined span and individual col/row span values.
10
- *
11
- * @param span - Optional equal span for both rows and columns
12
- * @param colSpan - Optional column span value
13
- * @param rowSpan - Optional row span value
14
- * @returns CSS properties object with grid span values
15
- *
16
- * @example
17
- * ```ts
18
- * createGridSpanStyles(2) // => { gridColumn: "span 2", gridRow: "span 2" }
19
- * createGridSpanStyles(undefined, 3, 2) // => { gridColumn: "span 3", gridRow: "span 2" }
20
- * ```
21
- */
22
- export declare const createGridSpanStyles: (span?: number, colSpan?: number, rowSpan?: number) => React.CSSProperties;
@@ -1,48 +0,0 @@
1
- /**
2
- * Calculates the modulo (remainder) of a CSS value when divided by a base unit.
3
- *
4
- * @param value - Input value (number or CSS string)
5
- * @param base - Base unit to calculate remainder against
6
- * @param options - Optional calculation controls
7
- * @returns Remainder in pixel units (e.g., "6px")
8
- */
9
- export declare function moduloize(value: number | string | undefined, base: number, options?: {
10
- round?: boolean;
11
- }): string;
12
- /**
13
- * Constrains a number within a specified range.
14
- *
15
- * @param value - Number to clamp
16
- * @param min - Minimum allowed value
17
- * @param max - Maximum allowed value
18
- * @returns Clamped value
19
- */
20
- export declare function clamp(value: number, min: number, max: number): number;
21
- /**
22
- * Rounds a number to specified precision.
23
- *
24
- * @param value - Number to round
25
- * @param precision - Decimal places (default: 0)
26
- * @returns Rounded number
27
- */
28
- export declare function round(value: number, precision?: number): number;
29
- /** Parameters for row count calculation */
30
- type RowCountParams = {
31
- /** Available height for the container */
32
- height?: number;
33
- /** Top padding/offset value */
34
- top: number;
35
- /** Bottom padding/offset value */
36
- bottom: number;
37
- /** Base unit for calculations */
38
- base: number;
39
- };
40
- /**
41
- * Calculates the number of rows that fit in the available space.
42
- * Ensures at least one row is always returned.
43
- *
44
- * @param params - Parameters for calculation
45
- * @returns Number of rows that fit in the space
46
- */
47
- export declare function calculateRowCount(params: RowCountParams): number;
48
- export {};