baseline-kit 2.0.0 → 2.1.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.
@@ -1,10 +1,24 @@
1
- /**
2
- * @file Padder Component
3
- * @description Low-level padding management with visual debugging
4
- * @module components
5
- */
6
1
  import * as React from 'react';
2
+ import { Variant } from '../types';
7
3
  import { IndicatorNode } from '../Spacer';
4
+ import { DebuggingMode } from '@/components';
5
+ type RenderSpacerFn = (width: React.CSSProperties['width'], height: React.CSSProperties['height']) => React.ReactNode;
6
+ type PaddingStyles = {
7
+ paddingBlock?: string;
8
+ paddingInline?: string;
9
+ [key: string]: string | undefined;
10
+ };
11
+ /** Creates default container styles for Padder */
12
+ export declare const createPadderContainerStyles: (width: React.CSSProperties["width"], height: React.CSSProperties["height"], base: number, color: string) => Record<string, string>;
13
+ /** Creates padding styles when spacers are disabled */
14
+ export declare const createDirectPaddingStyles: (enableSpacers: boolean, padding: {
15
+ top: number;
16
+ right: number;
17
+ bottom: number;
18
+ left: number;
19
+ }) => PaddingStyles;
20
+ /** Creates a render function for spacers */
21
+ export declare const createRenderSpacerFn: (variant: Variant | undefined, debugging: DebuggingMode | undefined, indicatorNode?: IndicatorNode) => RenderSpacerFn;
8
22
  /**
9
23
  * A foundational component that manages consistent padding with visual debugging.
10
24
  *
@@ -51,11 +65,14 @@ import { IndicatorNode } from '../Spacer';
51
65
  export declare const Padder: React.NamedExoticComponent<{
52
66
  /** Render function for custom measurement indicators */
53
67
  indicatorNode?: IndicatorNode;
68
+ /** Flag to enable SSR-compatible mode (simplified initial render) */
69
+ ssrMode?: boolean;
54
70
  children?: React.ReactNode;
55
71
  } & {
56
- debugging?: import("..").DebuggingMode;
72
+ debugging?: DebuggingMode;
57
73
  className?: string;
58
74
  style?: React.CSSProperties;
59
75
  height?: React.CSSProperties["height"];
60
76
  width?: React.CSSProperties["width"];
61
- } & import("..").SpacingProps & React.RefAttributes<HTMLDivElement>>;
77
+ } & import("@/components").SpacingProps & React.RefAttributes<HTMLDivElement>>;
78
+ export {};
@@ -1,55 +1,52 @@
1
- /**
2
- * @file Spacer Component
3
- * @description Flexible spacing element with measurement indicators
4
- * @module components
5
- */
6
1
  import * as React from 'react';
7
2
  import { ComponentsProps, Variant } from '../types';
8
- /**
9
- * Function signature for custom measurement indicators.
10
- *
11
- * @param value - The measurement in pixels
12
- * @param dimension - Which dimension is being measured ('width' | 'height')
13
- * @returns React node to display as the indicator
14
- */
15
- export type IndicatorNode = (value: number, dimension: 'width' | 'height') => React.ReactNode;
3
+ export type IndicatorNode = (value: number, type: 'width' | 'height') => React.ReactNode;
16
4
  export type SpacerProps = {
17
- /** Render function for custom measurement display */
18
- indicatorNode?: IndicatorNode;
19
- /** Visual style when debugging is enabled */
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 */
20
10
  variant?: Variant;
11
+ /** Color to use for debug visuals (overrides theme) */
12
+ color?: string;
21
13
  /** Base unit for measurements (defaults to theme value) */
22
14
  base?: number;
23
- /** Color override for visual indicators */
24
- color?: string;
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;
25
21
  } & ComponentsProps;
22
+ /** Creates default spacer styles */
23
+ export declare const createDefaultSpacerStyles: (base: number, textColor: string, flatColor: string, lineColor: string) => Record<string, string>;
24
+ /** Generates measurement indicators for debugging */
25
+ export declare const generateMeasurements: (isShown: boolean, indicatorNode: SpacerProps["indicatorNode"], normWidth: number | string, normHeight: number | string) => React.ReactNode | null;
26
26
  /**
27
- * A flexible layout element that adds precise vertical or horizontal spacing.
27
+ * Creates empty space for implementing margins, gaps, and spacing.
28
28
  *
29
29
  * @remarks
30
- * Spacer provides:
31
- * - Consistent spacing in layouts
32
- * - Optional measurement indicators for debugging
33
- * - Multiple visual styles for different debugging needs
34
- * - Automatic dimension normalization
30
+ * - Flexible sizing: Set width and height directly
31
+ * - Normalized values: All inputs convert to base unit multiples
32
+ * - Debug visuals: Shows spacing measurements with theming
33
+ * - Automatic: Empty in production, visible in debug mode
35
34
  *
36
35
  * @example
37
36
  * ```tsx
38
- * // Basic vertical spacing
39
- * <Spacer
40
- * height="24px"
41
- * base={8}
42
- * />
37
+ * // Fixed size spacer
38
+ * <Spacer width={32} height={16} />
43
39
  *
44
- * // Custom style with indicators
40
+ * // Percentage-based spacer with debug hints
45
41
  * <Spacer
46
- * width="32px"
47
- * height="100%"
48
- * base={4}
49
- * color="#ff0000"
42
+ * width="50%"
43
+ * height={32}
50
44
  * debugging="visible"
51
- * indicatorNode={(value, dim) => `${dim}: ${value}px`}
45
+ * variant="line"
52
46
  * />
47
+ *
48
+ * // Full-width spacer
49
+ * <Spacer height={64} />
53
50
  * ```
54
51
  */
55
52
  export declare const Spacer: React.NamedExoticComponent<SpacerProps>;
@@ -1,28 +1,44 @@
1
- /**
2
- * @file Stack Component
3
- * @description Flex container with baseline grid alignment
4
- * @module components
5
- */
6
1
  import * as React from 'react';
7
- import type { Gaps, IndicatorNode } from '@components';
2
+ import type { Gaps } from '@components';
3
+ import { IndicatorNode } from '../Spacer';
8
4
  import { ComponentsProps, Variant } from '../types';
5
+ export declare const DIRECTION_AXIS: Record<string, React.CSSProperties['flexDirection']>;
6
+ export type CSSPropertiesDirectionalAxis = keyof typeof DIRECTION_AXIS;
9
7
  export type StackProps = {
10
8
  /** Main axis orientation */
11
- direction?: 'row' | 'column';
9
+ direction?: React.CSSProperties['flexDirection'] & CSSPropertiesDirectionalAxis;
12
10
  /** Distribution of space on main axis */
13
11
  justify?: React.CSSProperties['justifyContent'];
14
12
  /** Alignment on cross axis */
15
13
  align?: React.CSSProperties['alignItems'];
16
- /** Container width (defaults to "fit-content") */
14
+ /** Container width (defaults to "auto") */
17
15
  width?: React.CSSProperties['width'];
18
- /** Container height (defaults to "fit-content") */
16
+ /** Container height (defaults to "auto") */
19
17
  height?: React.CSSProperties['height'];
20
18
  /** Custom measurement indicator renderer */
21
19
  indicatorNode?: IndicatorNode;
22
20
  /** Visual style in debug mode */
23
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;
24
30
  children?: React.ReactNode;
25
- } & ComponentsProps & Gaps;
31
+ } & ComponentsProps;
32
+ /** Creates default stack styles with theme colors */
33
+ export declare const createDefaultStackStyles: (colors: Record<string, string>) => {
34
+ '--bkkw': string;
35
+ '--bkkh': string;
36
+ '--bkkcl': string;
37
+ '--bkkcf': string;
38
+ '--bkkci': string;
39
+ };
40
+ /** Creates gap styles for the stack */
41
+ export declare const createStackGapStyles: (rowGap?: number, columnGap?: number, gap?: number) => Record<string, number | undefined>;
26
42
  /**
27
43
  * A flexible container component aligning children to the baseline grid.
28
44
  *
@@ -34,7 +50,7 @@ export type StackProps = {
34
50
  * - Includes visual debug overlays
35
51
  *
36
52
  * Key features:
37
- * - Automatic dimension management (defaults to fit-content)
53
+ * - Automatic dimension management (defaults to auto)
38
54
  * - Direct padding application in non-debug mode
39
55
  * - Comprehensive alignment controls
40
56
  * - Theme-aware debug visuals
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import { DebuggingMode } from '@components';
2
+ import { DebuggingMode } from './Config/Config';
3
3
  /**
4
4
  * Defines spacing as either a single value, start/end pair, or object with explicit edges.
5
5
  * Used for block and inline spacing across components.
@@ -1,72 +1,55 @@
1
- /**
2
- * @file useBaseline Hook
3
- * @description Manages baseline grid alignment calculations
4
- * @module hooks
5
- */
6
- import { RefObject } from 'react';
7
- import { SnappingMode, Padding } from '@components';
1
+ import * as React from 'react';
2
+ import type { SnappingMode, Padding } from '@components';
8
3
  export interface BaselineOptions {
9
- /** Base unit for alignment calculations (default: 8) */
10
4
  base?: number;
11
- /** Alignment strategy to apply (default: 'none') */
5
+ /** Snapping strategy: 'none' | 'height' | 'clamp'. */
12
6
  snapping?: SnappingMode;
13
- /** Initial spacing configuration */
7
+ /** Initial padding config. e.g. { top: 10, bottom: 20 } or just 8, etc. */
14
8
  spacing?: Partial<Padding> | number;
15
- /** Enable console warnings for misalignments */
9
+ /** Whether to warn in the console if the measured height is not a multiple of base. */
16
10
  warnOnMisalignment?: boolean;
17
11
  }
18
12
  export interface BaselineResult {
19
- /** Final adjusted padding values */
20
13
  padding: Padding;
21
- /** Whether the measured height is a multiple of base */
22
14
  isAligned: boolean;
23
- /** Raw measured height in pixels */
24
15
  height: number;
25
16
  }
26
17
  /**
27
- * Hook for managing baseline grid alignment in components.
18
+ * Hook for managing baseline grid alignment in components.
28
19
  *
29
- * @remarks
30
- * This hook handles the complex calculations needed to maintain baseline grid
31
- * alignment, including:
32
- * - Measuring element dimensions
33
- * - Calculating padding adjustments
34
- * - Snapping values to the grid
35
- * - Warning about misalignments
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
36
27
  *
37
- * Different snapping modes affect how spacing is adjusted:
38
- * - 'none': Uses raw spacing values without adjustment
39
- * - 'height': Adjusts only the final height to align
40
- * - 'clamp': Adjusts both height and spacing values
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
41
32
  *
42
- * @param ref - Reference to the DOM element to measure
43
- * @param options - Configuration options for alignment behavior
44
- * @returns Object containing adjusted padding, alignment status, and height
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
45
36
  *
46
37
  * @example
47
38
  * ```tsx
48
- * function MyComponent() {
49
- * const ref = useRef<HTMLDivElement>(null);
50
- * const { padding, isAligned } = useBaseline(ref, {
39
+ * export function MyComponent() {
40
+ * const ref = useRef<HTMLDivElement>(null)
41
+ * const { padding } = useBaseline(ref, {
51
42
  * base: 8,
52
43
  * snapping: 'height',
53
- * spacing: { top: 10, bottom: 20 }
54
- * });
55
- *
56
- * return (
57
- * <div
58
- * ref={ref}
59
- * style={{
60
- * paddingTop: padding.top,
61
- * paddingBottom: padding.bottom
62
- * }}
63
- * >
64
- * Content
65
- * </div>
66
- * );
67
- * }
68
- * ```
69
- *
70
- * @throws {Error} if base is less than 1
44
+ * spacing: {
45
+ * top: 16,
46
+ * bottom: 16
47
+ * }
48
+ * }}
49
+ * >
50
+ * Content
51
+ * </div>
52
+ * )
53
+ * }
71
54
  */
72
- export declare function useBaseline(ref: RefObject<HTMLElement | null>, { base, snapping, spacing, warnOnMisalignment, }?: BaselineOptions): BaselineResult;
55
+ export declare function useBaseline(ref: React.RefObject<HTMLElement | null>, { base, snapping, spacing, warnOnMisalignment, }?: BaselineOptions): BaselineResult;
@@ -1,8 +1,3 @@
1
- /**
2
- * @file useConfig Hook
3
- * @description Manages component-specific theme configuration
4
- * @module hooks
5
- */
6
1
  import { Config } from '@components';
7
2
  /** Type helper that merges base configuration with component-specific settings. */
8
3
  export type ComponentConfig<K extends keyof Config> = Config[K] & {
@@ -1,9 +1,4 @@
1
- /**
2
- * @file useDebug Hook
3
- * @description Manages component debugging state
4
- * @module hooks
5
- */
6
- import { DebuggingMode } from '@components';
1
+ import { DebuggingMode } from '../components/Config/Config';
7
2
  interface DebugResult {
8
3
  /** Whether debug visuals should be shown */
9
4
  isShown: boolean;
@@ -1,9 +1,4 @@
1
- /**
2
- * @file useGuide Hook
3
- * @description Manages grid layout calculations for guide overlays
4
- * @module hooks
5
- */
6
- import { RefObject } from 'react';
1
+ import * as React from 'react';
7
2
  import { GuideConfig } from '@components';
8
3
  export interface GuideResult {
9
4
  /** CSS grid template string */
@@ -63,4 +58,4 @@ export interface GuideResult {
63
58
  * }
64
59
  * ```
65
60
  */
66
- export declare function useGuide(ref: RefObject<HTMLElement | null>, config: GuideConfig): GuideResult;
61
+ export declare function useGuide(ref: React.RefObject<HTMLElement | null>, config: GuideConfig): GuideResult;
@@ -1,9 +1,4 @@
1
- /**
2
- * @file useMeasure Hook
3
- * @description Tracks element dimensions using ResizeObserver
4
- * @module hooks
5
- */
6
- import { RefObject } from 'react';
1
+ import * as React from 'react';
7
2
  export interface MeasureResult {
8
3
  /** Measured width in pixels */
9
4
  width: number;
@@ -15,18 +10,9 @@ export interface MeasureResult {
15
10
  /**
16
11
  * Hook for measuring and tracking DOM element dimensions.
17
12
  *
18
- * @remarks
19
- * Provides responsive element measurements using ResizeObserver, with:
20
- * - Performance optimization via RAF throttling
21
- * - Cache to prevent unnecessary updates
22
- * - Error handling and recovery
23
- * - Manual refresh capability
24
- *
25
- * The hook automatically:
26
- * - Initializes with 0x0 dimensions
27
- * - Updates on element resize
28
- * - Cleans up observers on unmount
29
- * - Rounds dimensions to whole pixels
13
+ * Provides responsive element measurements using ResizeObserver,
14
+ * with performance optimization (via RAF throttling), error handling,
15
+ * and a manual refresh method.
30
16
  *
31
17
  * @param ref - Reference to the DOM element to measure
32
18
  * @returns Current dimensions and refresh function
@@ -34,7 +20,7 @@ export interface MeasureResult {
34
20
  * @example
35
21
  * ```tsx
36
22
  * function ResponsiveBox() {
37
- * const ref = useRef<HTMLDivElement>(null);
23
+ * const ref = React.useRef<HTMLDivElement>(null);
38
24
  * const { width, height, refresh } = useMeasure(ref);
39
25
  *
40
26
  * return (
@@ -46,4 +32,4 @@ export interface MeasureResult {
46
32
  * }
47
33
  * ```
48
34
  */
49
- export declare function useMeasure(ref: RefObject<HTMLElement | null>): MeasureResult;
35
+ export declare function useMeasure(ref: React.RefObject<HTMLElement | null>): MeasureResult;
@@ -1,8 +1,3 @@
1
- /**
2
- * @file useVirtual Hook
3
- * @description Manages virtual scrolling calculations
4
- * @module hooks
5
- */
6
1
  import { RefObject } from 'react';
7
2
  type VirtualResult = {
8
3
  /** Total number of items/lines to virtualize */