@kbach/react 0.6.33 → 0.6.35
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.
- package/dist/{chunk-QCBA2JJK.mjs → chunk-O7GFDFVJ.mjs} +1 -1
- package/dist/{chunk-4DFD4WX3.mjs → chunk-Y6JF3TZM.mjs} +1 -1
- package/dist/index.d.ts +65 -21
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/jsx-dev-runtime.js +1 -1
- package/dist/jsx-dev-runtime.mjs +2 -2
- package/dist/jsx-runtime.js +1 -1
- package/dist/jsx-runtime.mjs +2 -2
- package/kbach-react.md +13 -1
- package/package.json +1 -1
|
@@ -3527,7 +3527,7 @@ function getImpliedRNStyle(webTag, resolvedBase) {
|
|
|
3527
3527
|
const compensation = {};
|
|
3528
3528
|
if (resolvedBase.position === void 0) compensation.position = "relative";
|
|
3529
3529
|
const explicitDisplay = resolvedBase.display;
|
|
3530
|
-
const hasFlexItemProps = "flexGrow" in resolvedBase || "flexShrink" in resolvedBase || "flex" in resolvedBase;
|
|
3530
|
+
const hasFlexItemProps = "flexGrow" in resolvedBase || "flexShrink" in resolvedBase || "flex" in resolvedBase || "gap" in resolvedBase || "columnGap" in resolvedBase || "rowGap" in resolvedBase;
|
|
3531
3531
|
const willBeFlex = explicitDisplay === "flex" || explicitDisplay === void 0 && hasFlexItemProps;
|
|
3532
3532
|
if (willBeFlex) {
|
|
3533
3533
|
if (explicitDisplay === void 0) compensation.display = "flex";
|
package/dist/index.d.ts
CHANGED
|
@@ -29,17 +29,43 @@ interface ColorScale {
|
|
|
29
29
|
/** `colors.blue['6/50']` → shade 6 at 50% opacity */
|
|
30
30
|
readonly [key: string]: string;
|
|
31
31
|
}
|
|
32
|
-
type ColorValueFor<K extends string> = K extends keyof typeof defaultColors ? (typeof defaultColors)[K] extends string ? string : ColorScale : ColorScale | string;
|
|
33
32
|
/**
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
33
|
+
* Empty on purpose — augment it via declaration merging so `useColors()` (and
|
|
34
|
+
* `useSpacing()`'s equivalent, `KbachCustomSpacing`) know about a project's
|
|
35
|
+
* `kbach.config.js` colors without repeating a type parameter at every call
|
|
36
|
+
* site. `kbach.config.js` is a plain runtime-loaded .js file, so TypeScript
|
|
37
|
+
* can't see into it on its own — this is the same declaration-merging pattern
|
|
38
|
+
* styled-components' `DefaultTheme` and i18next's resource typing use for the
|
|
39
|
+
* identical problem. Put this in any .d.ts your tsconfig includes:
|
|
40
|
+
*
|
|
41
|
+
* ```ts
|
|
42
|
+
* import '@kbach/react'; // or '@kbach/native' — either works, native re-exports react's types
|
|
43
|
+
* declare module '@kbach/react' {
|
|
44
|
+
* interface KbachCustomColors {
|
|
45
|
+
* primary: string; // a flat color, like the built-in `white`/`black`
|
|
46
|
+
* brand: ColorScale; // a 1–12 shade scale, like the built-in `blue`/`red`
|
|
47
|
+
* }
|
|
48
|
+
* }
|
|
49
|
+
* ```
|
|
50
|
+
*
|
|
51
|
+
* A mode-aware `{ light, dark }` config color (see ColorValue) still resolves
|
|
52
|
+
* to a flat `string` at read time — declare those as `string` here too, not
|
|
53
|
+
* as the config shape.
|
|
54
|
+
*/
|
|
55
|
+
interface KbachCustomColors {
|
|
56
|
+
}
|
|
57
|
+
type ColorValueFor<K extends string> = K extends keyof typeof defaultColors ? (typeof defaultColors)[K] extends string ? string : ColorScale : K extends keyof KbachCustomColors ? KbachCustomColors[K] : ColorScale | string;
|
|
58
|
+
/** Every color name TypeScript knows about without an explicit type parameter: the built-in theme plus whatever's been added via the KbachCustomColors augmentation above. */
|
|
59
|
+
type KnownColorName = DefaultColorName | Extract<keyof KbachCustomColors, string>;
|
|
60
|
+
/**
|
|
61
|
+
* `ColorName` defaults to `KnownColorName` (the built-in theme's color names
|
|
62
|
+
* plus anything augmented onto `KbachCustomColors` above), so `useColors()`
|
|
63
|
+
* gets full autocomplete and typo-catching out of the box — including custom
|
|
64
|
+
* `kbach.config.js` colors, once augmented once project-wide. Without that
|
|
65
|
+
* augmentation, a project with extra colors can still widen per call instead:
|
|
40
66
|
* `useColors<DefaultColorName | 'brand'>()`.
|
|
41
67
|
*/
|
|
42
|
-
type ColorsAPI<ColorName extends string =
|
|
68
|
+
type ColorsAPI<ColorName extends string = KnownColorName> = {
|
|
43
69
|
readonly [K in ColorName]: ColorValueFor<K>;
|
|
44
70
|
} & {
|
|
45
71
|
/**
|
|
@@ -50,22 +76,40 @@ type ColorsAPI<ColorName extends string = DefaultColorName> = {
|
|
|
50
76
|
*/
|
|
51
77
|
readonly alpha: (color: string, opacity?: number) => string;
|
|
52
78
|
};
|
|
53
|
-
declare function wrapColors<ColorName extends string =
|
|
54
|
-
declare function useColors<ColorName extends string =
|
|
79
|
+
declare function wrapColors<ColorName extends string = KnownColorName>(rawColors: ThemeColors, isDark?: boolean): ColorsAPI<ColorName>;
|
|
80
|
+
declare function useColors<ColorName extends string = KnownColorName>(): ColorsAPI<ColorName>;
|
|
55
81
|
|
|
56
82
|
/**
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
83
|
+
* Empty on purpose — augment it via declaration merging so `useSpacing()`
|
|
84
|
+
* (like `useColors()`'s `KbachCustomColors`) knows about a project's
|
|
85
|
+
* `kbach.config.js` spacing keys without repeating a type parameter at every
|
|
86
|
+
* call site:
|
|
87
|
+
*
|
|
88
|
+
* ```ts
|
|
89
|
+
* import '@kbach/react'; // or '@kbach/native'
|
|
90
|
+
* declare module '@kbach/react' {
|
|
91
|
+
* interface KbachCustomSpacing {
|
|
92
|
+
* 18: true; // value doesn't matter — only the key is read (see SpacingAPI)
|
|
93
|
+
* }
|
|
94
|
+
* }
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
interface KbachCustomSpacing {
|
|
98
|
+
}
|
|
99
|
+
/** Every spacing key TypeScript knows about without an explicit type parameter. */
|
|
100
|
+
type KnownSpacingKey = DefaultSpacingKey | Extract<keyof KbachCustomSpacing, string>;
|
|
101
|
+
/**
|
|
102
|
+
* `SpacingKey` defaults to `KnownSpacingKey` (the built-in theme's spacing keys
|
|
103
|
+
* plus anything augmented onto `KbachCustomSpacing` above), so `useSpacing()`
|
|
104
|
+
* gets full autocomplete and typo-catching out of the box — including custom
|
|
105
|
+
* `kbach.config.js` keys, once augmented once project-wide. Without that
|
|
106
|
+
* augmentation, a project with extra keys can still widen per call instead:
|
|
107
|
+
* `useSpacing<DefaultSpacingKey | '18'>()`.
|
|
64
108
|
*/
|
|
65
|
-
type SpacingAPI<SpacingKey extends string =
|
|
109
|
+
type SpacingAPI<SpacingKey extends string = KnownSpacingKey> = {
|
|
66
110
|
readonly [K in SpacingKey]: number | string;
|
|
67
111
|
};
|
|
68
|
-
declare function wrapSpacing<SpacingKey extends string =
|
|
112
|
+
declare function wrapSpacing<SpacingKey extends string = KnownSpacingKey>(rawSpacing: ThemeSpacing): SpacingAPI<SpacingKey>;
|
|
69
113
|
/**
|
|
70
114
|
* Returns the active theme's spacing scale as a typed, autocomplete-friendly
|
|
71
115
|
* object — useful anywhere a raw JS number/string is needed instead of a
|
|
@@ -80,7 +124,7 @@ declare function wrapSpacing<SpacingKey extends string = DefaultSpacingKey>(rawS
|
|
|
80
124
|
* spacing['1/2'] // '50%'
|
|
81
125
|
* ```
|
|
82
126
|
*/
|
|
83
|
-
declare function useSpacing<SpacingKey extends string =
|
|
127
|
+
declare function useSpacing<SpacingKey extends string = KnownSpacingKey>(): SpacingAPI<SpacingKey>;
|
|
84
128
|
|
|
85
129
|
interface ThemeProviderProps {
|
|
86
130
|
children: ReactNode;
|
|
@@ -278,4 +322,4 @@ declare function kb(classString: string, isDark?: boolean): StyleValue | string;
|
|
|
278
322
|
*/
|
|
279
323
|
declare function cx(...classes: Array<string | false | null | undefined>): string;
|
|
280
324
|
|
|
281
|
-
export { type ColorScale, type ColorsAPI, type InteractionState, InteractiveWrapper, type InteractiveWrapperProps, KbachReset, type SpacingAPI, type StyledProps, ThemeContext, type ThemeContextValue, ThemeProvider, type ThemeProviderProps, cx, kb, styled, useBreakpoint, useColors, useGlobalDarkMode, useIsDark, useResolvedStyle, useResponsive, useSpacing, useStyles, useTheme, wrapColors, wrapSpacing };
|
|
325
|
+
export { type ColorScale, type ColorsAPI, type InteractionState, InteractiveWrapper, type InteractiveWrapperProps, type KbachCustomColors, type KbachCustomSpacing, KbachReset, type SpacingAPI, type StyledProps, ThemeContext, type ThemeContextValue, ThemeProvider, type ThemeProviderProps, cx, kb, styled, useBreakpoint, useColors, useGlobalDarkMode, useIsDark, useResolvedStyle, useResponsive, useSpacing, useStyles, useTheme, wrapColors, wrapSpacing };
|
package/dist/index.js
CHANGED
|
@@ -549,7 +549,7 @@ function getImpliedRNStyle(webTag, resolvedBase) {
|
|
|
549
549
|
const compensation = {};
|
|
550
550
|
if (resolvedBase.position === void 0) compensation.position = "relative";
|
|
551
551
|
const explicitDisplay = resolvedBase.display;
|
|
552
|
-
const hasFlexItemProps = "flexGrow" in resolvedBase || "flexShrink" in resolvedBase || "flex" in resolvedBase;
|
|
552
|
+
const hasFlexItemProps = "flexGrow" in resolvedBase || "flexShrink" in resolvedBase || "flex" in resolvedBase || "gap" in resolvedBase || "columnGap" in resolvedBase || "rowGap" in resolvedBase;
|
|
553
553
|
const willBeFlex = explicitDisplay === "flex" || explicitDisplay === void 0 && hasFlexItemProps;
|
|
554
554
|
if (willBeFlex) {
|
|
555
555
|
if (explicitDisplay === void 0) compensation.display = "flex";
|
package/dist/index.mjs
CHANGED
package/dist/jsx-dev-runtime.js
CHANGED
|
@@ -343,7 +343,7 @@ function getImpliedRNStyle(webTag, resolvedBase) {
|
|
|
343
343
|
const compensation = {};
|
|
344
344
|
if (resolvedBase.position === void 0) compensation.position = "relative";
|
|
345
345
|
const explicitDisplay = resolvedBase.display;
|
|
346
|
-
const hasFlexItemProps = "flexGrow" in resolvedBase || "flexShrink" in resolvedBase || "flex" in resolvedBase;
|
|
346
|
+
const hasFlexItemProps = "flexGrow" in resolvedBase || "flexShrink" in resolvedBase || "flex" in resolvedBase || "gap" in resolvedBase || "columnGap" in resolvedBase || "rowGap" in resolvedBase;
|
|
347
347
|
const willBeFlex = explicitDisplay === "flex" || explicitDisplay === void 0 && hasFlexItemProps;
|
|
348
348
|
if (willBeFlex) {
|
|
349
349
|
if (explicitDisplay === void 0) compensation.display = "flex";
|
package/dist/jsx-dev-runtime.mjs
CHANGED
|
@@ -3,8 +3,8 @@ import {
|
|
|
3
3
|
Fragment,
|
|
4
4
|
jsx,
|
|
5
5
|
jsxs
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
6
|
+
} from "./chunk-Y6JF3TZM.mjs";
|
|
7
|
+
import "./chunk-O7GFDFVJ.mjs";
|
|
8
8
|
|
|
9
9
|
// src/jsx-dev-runtime.tsx
|
|
10
10
|
function jsxDEV(type, props, key, isStaticChildren, source, self) {
|
package/dist/jsx-runtime.js
CHANGED
|
@@ -349,7 +349,7 @@ function getImpliedRNStyle(webTag, resolvedBase) {
|
|
|
349
349
|
const compensation = {};
|
|
350
350
|
if (resolvedBase.position === void 0) compensation.position = "relative";
|
|
351
351
|
const explicitDisplay = resolvedBase.display;
|
|
352
|
-
const hasFlexItemProps = "flexGrow" in resolvedBase || "flexShrink" in resolvedBase || "flex" in resolvedBase;
|
|
352
|
+
const hasFlexItemProps = "flexGrow" in resolvedBase || "flexShrink" in resolvedBase || "flex" in resolvedBase || "gap" in resolvedBase || "columnGap" in resolvedBase || "rowGap" in resolvedBase;
|
|
353
353
|
const willBeFlex = explicitDisplay === "flex" || explicitDisplay === void 0 && hasFlexItemProps;
|
|
354
354
|
if (willBeFlex) {
|
|
355
355
|
if (explicitDisplay === void 0) compensation.display = "flex";
|
package/dist/jsx-runtime.mjs
CHANGED
|
@@ -4,10 +4,10 @@ import {
|
|
|
4
4
|
_invalidateDefaultFontCache,
|
|
5
5
|
jsx,
|
|
6
6
|
jsxs
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-Y6JF3TZM.mjs";
|
|
8
8
|
import {
|
|
9
9
|
registerWebElement
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-O7GFDFVJ.mjs";
|
|
11
11
|
export {
|
|
12
12
|
Fragment,
|
|
13
13
|
_invalidateDefaultFontCache,
|
package/kbach-react.md
CHANGED
|
@@ -189,7 +189,19 @@ colors.white // '#ffffff'
|
|
|
189
189
|
colors['white/20'] // 'rgba(255,255,255,0.2)'
|
|
190
190
|
colors.alpha('#ff6b35', 60) // 'rgba(255,107,53,0.6)'
|
|
191
191
|
```
|
|
192
|
-
Typed against the built-in theme by default — `colors.blu` (typo) is a compile error. Custom `kbach.config.js` colors aren't visible to TypeScript (runtime-loaded plain `.js`), so widen
|
|
192
|
+
Typed against the built-in theme by default — `colors.blu` (typo) is a compile error. Custom `kbach.config.js` colors aren't visible to TypeScript (runtime-loaded plain `.js`), so either widen per call — `useColors<DefaultColorName | 'brand'>()` — or, better, augment once project-wide in any `.d.ts` your tsconfig includes:
|
|
193
|
+
|
|
194
|
+
```ts
|
|
195
|
+
import '@kbach/react'; // or '@kbach/native' — either works, native re-exports react's types
|
|
196
|
+
declare module '@kbach/react' {
|
|
197
|
+
interface KbachCustomColors {
|
|
198
|
+
brand: ColorScale; // a 1–12 shade scale, like the built-in blue/red
|
|
199
|
+
accent: string; // a flat color, like the built-in white/black — also what a
|
|
200
|
+
// mode-aware { light, dark } config color resolves to at read time
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
```
|
|
204
|
+
Every `useColors()` call in the project then sees `brand`/`accent` automatically, no type parameter needed — same typo-catching as the built-in names. `useSpacing()` has the equivalent `KbachCustomSpacing` interface (`interface KbachCustomSpacing { 18: true }` — only the key is read) for the spacing scale (`spacing[4]` → `16`, `spacing.full` → `'100%'`).
|
|
193
205
|
|
|
194
206
|
---
|
|
195
207
|
|