baseline-kit 2.0.1 → 3.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 (47) hide show
  1. package/README.md +258 -102
  2. package/dist/README.md +258 -102
  3. package/dist/baseline-kit.css +151 -0
  4. package/dist/components/Baseline/Baseline.d.ts +4 -5
  5. package/dist/components/Box/Box.d.ts +16 -5
  6. package/dist/components/Config/Config.d.ts +60 -17
  7. package/dist/components/Config/defaults.d.ts +2 -2
  8. package/dist/components/Config/index.d.ts +1 -1
  9. package/dist/components/Guide/Guide.d.ts +21 -12
  10. package/dist/components/Guide/index.d.ts +0 -6
  11. package/dist/components/Guide/types.d.ts +1 -1
  12. package/dist/components/Layout/Layout.d.ts +10 -6
  13. package/dist/components/Padder/Padder.d.ts +13 -7
  14. package/dist/components/Spacer/Spacer.d.ts +40 -11
  15. package/dist/components/Stack/Stack.d.ts +15 -8
  16. package/dist/components/index.d.ts +4 -3
  17. package/dist/components/styles/index.d.ts +11 -0
  18. package/dist/components/types.d.ts +3 -3
  19. package/dist/hooks/useBaseline.d.ts +13 -18
  20. package/dist/hooks/useConfig.d.ts +3 -8
  21. package/dist/hooks/useDebug.d.ts +1 -6
  22. package/dist/hooks/useGuide.d.ts +2 -7
  23. package/dist/hooks/useIsClient.d.ts +6 -0
  24. package/dist/hooks/useVirtual.d.ts +0 -5
  25. package/dist/index.cjs +1 -31
  26. package/dist/index.cjs.map +1 -1
  27. package/dist/index.d.ts +25 -3
  28. package/dist/index.mjs +1557 -1542
  29. package/dist/index.mjs.map +1 -1
  30. package/dist/styles.css +1 -1
  31. package/dist/styles.d.ts +6 -0
  32. package/dist/theme/dark.css +67 -0
  33. package/dist/theme/default.css +82 -0
  34. package/dist/theme/tokens.css +82 -0
  35. package/dist/theme.css +142 -0
  36. package/dist/theme.d.ts +6 -0
  37. package/dist/utils/convert.d.ts +0 -22
  38. package/dist/utils/grid.d.ts +22 -0
  39. package/dist/utils/index.d.ts +2 -0
  40. package/dist/utils/math.d.ts +20 -36
  41. package/dist/utils/merge.d.ts +54 -5
  42. package/dist/utils/normalize.d.ts +0 -35
  43. package/dist/utils/parse.d.ts +0 -34
  44. package/dist/utils/snapping.d.ts +0 -5
  45. package/dist/utils/ssr.d.ts +26 -0
  46. package/dist/utils/timing.d.ts +0 -5
  47. package/package.json +81 -39
@@ -14,35 +14,9 @@ export interface NormalizationOptions {
14
14
  /**
15
15
  * Normalizes CSS values to a consistent format based on base unit.
16
16
  *
17
- * @remarks
18
- * Handles:
19
- * - CSS length values
20
- * - Numeric values
21
- * - Special values (auto)
22
- * - Rounding to base unit
23
- * - Value clamping
24
- *
25
17
  * @param value - Value to normalize
26
18
  * @param options - Normalization configuration
27
19
  * @returns Normalized numeric value
28
- *
29
- * @example
30
- * ```ts
31
- * // Base unit normalization
32
- * normalizeValue(14, { base: 8 }) // => 16
33
- *
34
- * // With clamping
35
- * normalizeValue(14, {
36
- * base: 8,
37
- * clamp: { min: 8, max: 24 }
38
- * }) // => 16
39
- *
40
- * // Without rounding
41
- * normalizeValue(14, {
42
- * base: 8,
43
- * round: false
44
- * }) // => 14
45
- * ```
46
20
  */
47
21
  export declare function normalizeValue(value: string | number | undefined, options?: NormalizationOptions): number;
48
22
  /**
@@ -52,14 +26,5 @@ export declare function normalizeValue(value: string | number | undefined, optio
52
26
  * @param defaults - Default values if input is undefined
53
27
  * @param options - Normalization options
54
28
  * @returns Tuple of normalized values
55
- *
56
- * @example
57
- * ```ts
58
- * normalizeValuePair(
59
- * ['14px', '20px'],
60
- * [0, 0],
61
- * { base: 8 }
62
- * ) // => [16, 24]
63
- * ```
64
29
  */
65
30
  export declare function normalizeValuePair(values: [string | number | undefined, string | number | undefined] | undefined, defaults: [number, number], options?: NormalizationOptions): [number, number];
@@ -1,28 +1,8 @@
1
- /**
2
- * @file parse.ts
3
- * @description CSS value parsing utilities
4
- * @module utils
5
- */
6
1
  /**
7
2
  * Parses a CSS unit string into its numeric value and unit.
8
3
  *
9
- * @remarks
10
- * Handles:
11
- * - Integer and decimal values
12
- * - All CSS units (px, em, rem, etc.)
13
- * - Percentage values
14
- * - Sign prefixes (+ and -)
15
- *
16
4
  * @param value - CSS value string to parse
17
5
  * @returns Object with value and unit, or null if parsing fails
18
- *
19
- * @example
20
- * ```ts
21
- * parseUnit('100px') // => { value: 100, unit: 'px' }
22
- * parseUnit('1.5rem') // => { value: 1.5, unit: 'rem' }
23
- * parseUnit('-20%') // => { value: -20, unit: '%' }
24
- * parseUnit('invalid') // => null
25
- * ```
26
6
  */
27
7
  export declare function parseUnit(value: string): {
28
8
  value: number;
@@ -31,22 +11,8 @@ export declare function parseUnit(value: string): {
31
11
  /**
32
12
  * Formats a value as a valid CSS string.
33
13
  *
34
- * @remarks
35
- * Handles:
36
- * - Numbers (adds px suffix)
37
- * - Special values (auto, 100%, etc.)
38
- * - Undefined values with defaults
39
- *
40
14
  * @param value - Value to format
41
15
  * @param defaultValue - Optional default if value is undefined
42
16
  * @returns Formatted CSS string
43
- *
44
- * @example
45
- * ```ts
46
- * formatValue(14) // => "14px"
47
- * formatValue('auto') // => "auto"
48
- * formatValue(undefined, 10) // => "10px"
49
- * formatValue('1fr') // => "1fr"
50
- * ```
51
17
  */
52
18
  export declare function formatValue(value: string | number | undefined, defaultValue?: number): string;
@@ -1,8 +1,3 @@
1
- /**
2
- * @file snapping.ts
3
- * @description Baseline grid snapping utilities
4
- * @module utils
5
- */
6
1
  import { SnappingMode, Padding, PaddingValue } from '@components';
7
2
  /**
8
3
  * Calculates spacing adjustments to maintain baseline grid alignment.
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Detects if code is running in a server-side environment
3
+ */
4
+ export declare const isSSR: boolean;
5
+ /**
6
+ * Default dimensions to use during server-side rendering
7
+ */
8
+ export declare const SSR_DIMENSIONS: {
9
+ width: number;
10
+ height: number;
11
+ };
12
+ /**
13
+ * Safe window-using function that works in both server and client
14
+ * @param clientFn Function that uses window/browser APIs
15
+ * @param fallback Fallback value to use in SSR environment
16
+ * @returns Result of clientFn in browser, fallback in SSR
17
+ */
18
+ export declare function safeClientValue<T>(clientFn: () => T, fallback: T): T;
19
+ /**
20
+ * Returns a stable value during SSR and initial render, then switches to
21
+ * the dynamic value after hydration
22
+ * @param isHydrated Boolean indicating if component is hydrated
23
+ * @param ssrValue Value to use during SSR/initial render
24
+ * @param dynamicValue Value to use after hydration
25
+ */
26
+ export declare function hydratedValue<T>(isHydrated: boolean, ssrValue: T, dynamicValue: T): T;
@@ -1,8 +1,3 @@
1
- /**
2
- * @file timing.ts
3
- * @description Performance optimization utilities
4
- * @module utils
5
- */
6
1
  /**
7
2
  * Creates a debounced version of a function.
8
3
  *
package/package.json CHANGED
@@ -1,25 +1,24 @@
1
1
  {
2
2
  "scripts": {
3
- "lint": "eslint src/lib --fix",
3
+ "build": "vite build && bun run build:type && bun run build:combine-css",
4
4
  "build:type": "tsc -p tsconfig.build.json",
5
- "prepare": "bun run build && bun run build:type",
6
- "version": "changeset version",
7
- "test:coverage": "vitest run --coverage",
8
- "release": "changeset publish",
9
- "typecheck": "tsc --noEmit",
10
- "test:ui": "vitest --ui",
5
+ "build:combine-css": "node scripts/combine-css.js",
6
+ "changeset": "changeset",
11
7
  "dev": "vite",
12
- "test:ci": "vitest run",
13
- "format": "prettier --write \"src/lib/**/*.{ts,tsx,css}\"",
8
+ "format": "prettier --write \"src/**/*.{ts,tsx,css}\"",
9
+ "lint": "eslint src --fix",
10
+ "prepare": "bun run build && bun run build:type",
14
11
  "prepublishOnly": "bun run build && bun run build:type",
15
- "changeset": "changeset",
12
+ "release": "changeset publish",
16
13
  "test": "vitest",
17
- "build": "vite build"
14
+ "test:coverage": "vitest run --coverage",
15
+ "typecheck": "tsc --noEmit",
16
+ "version": "changeset version"
18
17
  },
19
18
  "peerDependencies": {
20
- "react": "^18.0.0 || ^19.0.0",
21
- "react-dom": "^18.0.0 || ^19.0.0",
22
- "typescript": "^5.7.3"
19
+ "react": "^19.0.0",
20
+ "react-dom": "^19.0.0",
21
+ "typescript": "^5.8.2"
23
22
  },
24
23
  "main": "dist/index.cjs",
25
24
  "engines": {
@@ -48,33 +47,35 @@
48
47
  "url": "git+https://github.com/dnvt/baseline-kit.git"
49
48
  },
50
49
  "devDependencies": {
51
- "@changesets/cli": "^2.27.12",
50
+ "@changesets/cli": "^2.28.1",
51
+ "@eslint/js": "^9.21.0",
52
52
  "@testing-library/jest-dom": "^6.6.3",
53
53
  "@testing-library/react": "^16.2.0",
54
- "@types/node": "^22.13.0",
55
- "@types/react": "^19.0.8",
56
- "@types/react-dom": "^19.0.3",
57
- "@typescript-eslint/eslint-plugin": "^6.21.0",
58
- "@typescript-eslint/parser": "^6.21.0",
59
- "@vitejs/plugin-react-swc": "^3.7.2",
60
- "@vitest/coverage-v8": "^2.1.8",
54
+ "@types/node": "^22.13.9",
55
+ "@types/react": "^19.0.10",
56
+ "@types/react-dom": "^19.0.4",
57
+ "@typescript-eslint/eslint-plugin": "^8.26.0",
58
+ "@typescript-eslint/parser": "^8.26.0",
59
+ "@vitejs/plugin-react-swc": "^3.8.0",
60
+ "@vitest/coverage-v8": "^3.0.8",
61
61
  "autoprefixer": "^10.4.20",
62
62
  "cssnano": "^7.0.6",
63
- "eslint": "^8.57.1",
64
- "eslint-config-prettier": "^9.1.0",
63
+ "eslint": "^9.0.0",
64
+ "eslint-config-prettier": "^10.1.1",
65
+ "eslint-plugin-prettier": "^5.2.3",
65
66
  "eslint-plugin-react": "^7.37.4",
66
- "eslint-plugin-react-hooks": "^4.6.2",
67
- "jsdom": "^25.0.1",
68
- "prettier": "^3.4.2",
69
- "rollup": "^4.34.0",
67
+ "eslint-plugin-react-hooks": "^5.2.0",
68
+ "jsdom": "^26.0.0",
69
+ "prettier": "^3.5.3",
70
+ "rollup": "^4.34.9",
70
71
  "rollup-plugin-dts": "^6.1.1",
71
72
  "rollup-plugin-visualizer": "^5.14.0",
72
- "vite": "^6.1.0",
73
- "vite-plugin-static-copy": "^2.2.0",
74
- "vitest": "^2.1.8"
73
+ "vite": "6.2.1",
74
+ "vite-plugin-static-copy": "^2.3.0",
75
+ "vitest": "3.0.8"
75
76
  },
76
77
  "name": "baseline-kit",
77
- "version": "2.0.1",
78
+ "version": "3.0.0",
78
79
  "type": "module",
79
80
  "homepage": "https://github.com/dnvt/baseline-kit#readme",
80
81
  "types": "dist/index.d.ts",
@@ -82,9 +83,46 @@
82
83
  ".": {
83
84
  "types": "./dist/index.d.ts",
84
85
  "import": "./dist/index.mjs",
85
- "require": "./dist/index.cjs"
86
+ "require": "./dist/index.cjs",
87
+ "default": "./dist/index.mjs"
88
+ },
89
+ "./styles": {
90
+ "import": "./dist/styles.css",
91
+ "require": "./dist/styles.css",
92
+ "default": "./dist/styles.css"
93
+ },
94
+ "./theme": {
95
+ "import": "./dist/theme.css",
96
+ "require": "./dist/theme.css",
97
+ "default": "./dist/theme.css"
98
+ },
99
+ "./theme/default": {
100
+ "import": "./dist/theme/default.css",
101
+ "require": "./dist/theme/default.css",
102
+ "default": "./dist/theme/default.css"
103
+ },
104
+ "./theme/dark": {
105
+ "import": "./dist/theme/dark.css",
106
+ "require": "./dist/theme/dark.css",
107
+ "default": "./dist/theme/dark.css"
108
+ },
109
+ "./theme/tokens": {
110
+ "import": "./dist/theme/tokens.css",
111
+ "require": "./dist/theme/tokens.css",
112
+ "default": "./dist/theme/tokens.css"
113
+ },
114
+ "./full": {
115
+ "import": "./dist/baseline-kit.css",
116
+ "require": "./dist/baseline-kit.css",
117
+ "default": "./dist/baseline-kit.css"
86
118
  },
87
- "./styles.css": "./dist/styles.css"
119
+ "./dist/styles.css": "./dist/styles.css",
120
+ "./dist/theme.css": "./dist/theme.css",
121
+ "./dist/theme/default.css": "./dist/theme/default.css",
122
+ "./dist/theme/dark.css": "./dist/theme/dark.css",
123
+ "./dist/theme/tokens.css": "./dist/theme/tokens.css",
124
+ "./dist/baseline-kit.css": "./dist/baseline-kit.css",
125
+ "./package.json": "./package.json"
88
126
  },
89
127
  "files": [
90
128
  "dist",
@@ -93,7 +131,12 @@
93
131
  ],
94
132
  "style": "dist/styles.css",
95
133
  "sideEffects": [
96
- "dist/styles.css"
134
+ "dist/styles.css",
135
+ "dist/theme.css",
136
+ "dist/theme/default.css",
137
+ "dist/theme/dark.css",
138
+ "dist/theme/tokens.css",
139
+ "dist/baseline-kit.css"
97
140
  ],
98
141
  "bugs": {
99
142
  "url": "https://github.com/dnvt/baseline-kit/issues"
@@ -101,13 +144,12 @@
101
144
  "license": "MIT",
102
145
  "module": "dist/index.mjs",
103
146
  "publishConfig": {
104
- "access": "public",
105
- "registry": "https://registry.npmjs.org/"
147
+ "access": "public"
106
148
  },
107
149
  "author": "Francois Denavaut",
108
150
  "description": "Baseline Kit is a lightweight development tool for visualizing and debugging grid systems and spacing in React applications. It provides configurable overlays for both column-based and baseline grids, flexible spacing components, and theme-aware configuration—all optimized for performance and built with TypeScript.",
109
151
  "dependencies": {
110
- "esbuild": "^0.24.2",
111
- "postcss-preset-env": "^10.1.3"
152
+ "esbuild": "^0.25.0",
153
+ "postcss-preset-env": "^10.1.5"
112
154
  }
113
155
  }