@kbach/react 0.5.60 → 0.6.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.
- package/README.md +2 -9
- package/dist/{chunk-NP4FVE77.mjs → chunk-6NED62DB.mjs} +23 -20
- package/dist/{chunk-LU2QNVYU.mjs → chunk-AAAI37Y4.mjs} +4 -4
- package/dist/{chunk-2MVCYYH5.mjs → chunk-D4LJICWZ.mjs} +5 -6
- package/dist/index.d.mts +1 -29
- package/dist/index.d.ts +1 -29
- package/dist/index.js +78 -205
- package/dist/index.mjs +17 -156
- package/dist/jsx-dev-runtime.js +29 -18
- package/dist/jsx-dev-runtime.mjs +3 -3
- package/dist/jsx-runtime.js +29 -18
- package/dist/jsx-runtime.mjs +3 -3
- package/dist/vite-plugin.js +37 -14
- package/dist/vite-plugin.mjs +3 -1
- package/kbach-react.md +0 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -12,6 +12,8 @@ Tailwind-like utility classes for React (web). Write classes as `className` stri
|
|
|
12
12
|
|
|
13
13
|
## Install
|
|
14
14
|
|
|
15
|
+
[npm package](https://www.npmjs.com/package/@kbach/react)
|
|
16
|
+
|
|
15
17
|
```
|
|
16
18
|
npm install @kbach/react
|
|
17
19
|
```
|
|
@@ -226,15 +228,6 @@ colors['white/20'] // 'rgba(255,255,255,0.2)'
|
|
|
226
228
|
colors.alpha('#ff6b35', 60) // 'rgba(255,107,53,0.6)'
|
|
227
229
|
```
|
|
228
230
|
|
|
229
|
-
### ThemeToggle
|
|
230
|
-
|
|
231
|
-
```jsx
|
|
232
|
-
<ThemeToggle /> // button (default)
|
|
233
|
-
<ThemeToggle variant="switch" /> // toggle switch
|
|
234
|
-
<ThemeToggle variant="icon-button" /> // icon button
|
|
235
|
-
<ThemeToggle variant="button" includeSystem /> // three-way selector
|
|
236
|
-
```
|
|
237
|
-
|
|
238
231
|
## Modifiers
|
|
239
232
|
|
|
240
233
|
Chain modifiers in any order before the utility name:
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
-
}) : x)(function(x) {
|
|
4
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
5
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
6
|
-
});
|
|
7
|
-
|
|
8
1
|
// src/core/theme.ts
|
|
9
2
|
var defaultColors = {
|
|
10
3
|
transparent: "transparent",
|
|
@@ -1151,10 +1144,12 @@ var RESOLVERS = {
|
|
|
1151
1144
|
const color = resolveColor(value, colors, isArbitrary);
|
|
1152
1145
|
return color ? { backgroundColor: color } : null;
|
|
1153
1146
|
},
|
|
1154
|
-
"bg-opacity": ({ value }, _) => {
|
|
1147
|
+
"bg-opacity": ({ value, isArbitrary }, _) => {
|
|
1155
1148
|
if (!getEffectiveIsWeb()) return null;
|
|
1156
|
-
const
|
|
1157
|
-
|
|
1149
|
+
const n = parseFloat(value);
|
|
1150
|
+
if (isNaN(n)) return null;
|
|
1151
|
+
const v = isArbitrary ? n > 1 ? n / 100 : n : n / 100;
|
|
1152
|
+
return { "--bg-opacity": v };
|
|
1158
1153
|
},
|
|
1159
1154
|
// ── Text ───────────────────────────────────────────────────────────────────
|
|
1160
1155
|
text: ({ value, isArbitrary }, { colors, fontSize }) => {
|
|
@@ -1169,10 +1164,12 @@ var RESOLVERS = {
|
|
|
1169
1164
|
const color = resolveColor(value, colors, false);
|
|
1170
1165
|
return color ? { color } : null;
|
|
1171
1166
|
},
|
|
1172
|
-
"text-opacity": ({ value }, _) => {
|
|
1167
|
+
"text-opacity": ({ value, isArbitrary }, _) => {
|
|
1173
1168
|
if (!getEffectiveIsWeb()) return null;
|
|
1174
|
-
const
|
|
1175
|
-
|
|
1169
|
+
const n = parseFloat(value);
|
|
1170
|
+
if (isNaN(n)) return null;
|
|
1171
|
+
const v = isArbitrary ? n > 1 ? n / 100 : n : n / 100;
|
|
1172
|
+
return { "--text-opacity": v };
|
|
1176
1173
|
},
|
|
1177
1174
|
// ── Padding ────────────────────────────────────────────────────────────────
|
|
1178
1175
|
p: ({ value, negative, isArbitrary }, { spacing }) => {
|
|
@@ -2073,9 +2070,9 @@ var RESOLVERS = {
|
|
|
2073
2070
|
const n = parseFloat(value);
|
|
2074
2071
|
return { flexShrink: isNaN(n) ? 1 : n };
|
|
2075
2072
|
},
|
|
2076
|
-
order: ({ value,
|
|
2077
|
-
const n = parseInt(value);
|
|
2078
|
-
return isNaN(n) ? null : { order: n };
|
|
2073
|
+
order: ({ value, negative }, _) => {
|
|
2074
|
+
const n = parseInt(value, 10);
|
|
2075
|
+
return isNaN(n) ? null : { order: negative ? -n : n };
|
|
2079
2076
|
},
|
|
2080
2077
|
// ── Gap ────────────────────────────────────────────────────────────────────
|
|
2081
2078
|
gap: ({ value, negative, isArbitrary }, { spacing }) => {
|
|
@@ -2292,10 +2289,17 @@ var RESOLVERS = {
|
|
|
2292
2289
|
const DEFAULT_RING_COLOR = "rgba(59, 130, 246, 0.5)";
|
|
2293
2290
|
const DEFAULT_RING_WIDTH = 3;
|
|
2294
2291
|
const offsetTokens = { "0": 0, "1": 1, "2": 2, "4": 4, "8": 8 };
|
|
2295
|
-
|
|
2296
|
-
if (
|
|
2292
|
+
let offsetWidth;
|
|
2293
|
+
if (!isArbitrary) {
|
|
2294
|
+
offsetWidth = value in offsetTokens ? offsetTokens[value] : null;
|
|
2295
|
+
} else {
|
|
2296
|
+
offsetWidth = /^-?\d+(\.\d+)?$/.test(value) ? parseFloat(value) : value;
|
|
2297
|
+
}
|
|
2298
|
+
if (offsetWidth === null || typeof offsetWidth === "number" && isNaN(offsetWidth)) return null;
|
|
2299
|
+
const isZero = offsetWidth === 0 || offsetWidth === "0";
|
|
2300
|
+
const offsetCss = typeof offsetWidth === "number" ? `${offsetWidth}px` : offsetWidth;
|
|
2297
2301
|
return {
|
|
2298
|
-
boxShadow:
|
|
2302
|
+
boxShadow: isZero ? `0 0 0 ${DEFAULT_RING_WIDTH}px ${DEFAULT_RING_COLOR}` : `0 0 0 ${offsetCss} #fff, 0 0 0 calc(${offsetCss} + ${DEFAULT_RING_WIDTH}px) ${DEFAULT_RING_COLOR}`
|
|
2299
2303
|
};
|
|
2300
2304
|
},
|
|
2301
2305
|
// ── Space between ─────────────────────────────────────────────────────────
|
|
@@ -3120,7 +3124,6 @@ var customVariants = new Proxy(
|
|
|
3120
3124
|
);
|
|
3121
3125
|
|
|
3122
3126
|
export {
|
|
3123
|
-
__require,
|
|
3124
3127
|
defaultColors,
|
|
3125
3128
|
defaultTheme,
|
|
3126
3129
|
isWeb,
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
EMPTY_BREAKPOINTS,
|
|
3
3
|
InteractiveWrapper,
|
|
4
4
|
getWebTag,
|
|
5
5
|
hasResponsiveBuckets,
|
|
6
6
|
transformToWebProps,
|
|
7
7
|
useConditionalWidth,
|
|
8
8
|
useGlobalDarkMode
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-D4LJICWZ.mjs";
|
|
10
10
|
import {
|
|
11
11
|
flatten,
|
|
12
12
|
getActiveBreakpoints,
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
normalizeClassString,
|
|
23
23
|
onConfigChange,
|
|
24
24
|
resolve
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-6NED62DB.mjs";
|
|
26
26
|
|
|
27
27
|
// src/jsx-runtime.tsx
|
|
28
28
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -187,7 +187,7 @@ function processElement(type, rawProps, key, isStaticChildren) {
|
|
|
187
187
|
...userStyle2 !== void 0 ? { style: userStyle2 } : {}
|
|
188
188
|
}, key);
|
|
189
189
|
}
|
|
190
|
-
if (classStr && !__kbachStyles && /^(__[
|
|
190
|
+
if (classStr && !__kbachStyles && /^(__[A-Za-z0-9_]+\s*)+$/.test(classStr.trim())) {
|
|
191
191
|
const { style: userStyle2, ...passProps2 } = omitConsumed(workingProps);
|
|
192
192
|
return makeElement(isStaticChildren, effectiveType, {
|
|
193
193
|
...passProps2,
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
isNative,
|
|
8
8
|
isWeb,
|
|
9
9
|
subscribeGlobalWidth
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-6NED62DB.mjs";
|
|
11
11
|
|
|
12
12
|
// src/core/darkModeStore.ts
|
|
13
13
|
var KEY = "__kbach_dark_store__";
|
|
@@ -407,7 +407,6 @@ function hasInteractiveBuckets(resolved) {
|
|
|
407
407
|
}
|
|
408
408
|
return false;
|
|
409
409
|
}
|
|
410
|
-
var EMPTY_BREAKPOINTS2 = /* @__PURE__ */ new Set();
|
|
411
410
|
|
|
412
411
|
// src/InteractiveWrapper.tsx
|
|
413
412
|
function chain(original, extra) {
|
|
@@ -495,9 +494,10 @@ var InteractiveWrapper = forwardRef(
|
|
|
495
494
|
...checked !== void 0 ? { checked } : {},
|
|
496
495
|
style: finalStyle,
|
|
497
496
|
...!isNative && className ? { className } : {},
|
|
498
|
-
//
|
|
499
|
-
//
|
|
500
|
-
|
|
497
|
+
// On web, onPointerDown/Up drive the wrapper's own pressed state (covers mouse + touch),
|
|
498
|
+
// but onPressIn/onPressOut are still forwarded unchanged — react-native-web components
|
|
499
|
+
// (and any component that accepts both prop names) depend on receiving them directly.
|
|
500
|
+
...!isNative ? { onPointerDown: handlePointerDown, onPointerUp: handlePointerUp, onPointerLeave: handlePointerLeave, onPointerCancel: handlePointerLeave, onPressIn, onPressOut } : { onPressIn: handlePressIn, onPressOut: handlePressOut },
|
|
501
501
|
onMouseEnter: handleMouseEnter,
|
|
502
502
|
onMouseLeave: handleMouseLeave,
|
|
503
503
|
onFocus: handleFocus,
|
|
@@ -517,7 +517,6 @@ export {
|
|
|
517
517
|
useConditionalWidth,
|
|
518
518
|
hasResponsiveBuckets,
|
|
519
519
|
hasInteractiveBuckets,
|
|
520
|
-
EMPTY_BREAKPOINTS2,
|
|
521
520
|
registerWebElement,
|
|
522
521
|
getWebTag,
|
|
523
522
|
transformToWebProps,
|
package/dist/index.d.mts
CHANGED
|
@@ -133,34 +133,6 @@ interface ThemeProviderProps {
|
|
|
133
133
|
}
|
|
134
134
|
declare function ThemeProvider({ children, defaultMode, colorScheme, windowWidth: windowWidthProp, config: configOverride, disablePersistence, }: ThemeProviderProps): React__default.JSX.Element;
|
|
135
135
|
|
|
136
|
-
type ToggleVariant = 'button' | 'switch' | 'icon-button';
|
|
137
|
-
interface ThemeToggleProps {
|
|
138
|
-
/** Visual variant. Default: 'button' */
|
|
139
|
-
variant?: ToggleVariant;
|
|
140
|
-
/** Override label text (button variant) */
|
|
141
|
-
label?: string;
|
|
142
|
-
/** Custom light-mode label */
|
|
143
|
-
lightLabel?: string;
|
|
144
|
-
/** Custom dark-mode label */
|
|
145
|
-
darkLabel?: string;
|
|
146
|
-
/** Show system mode option */
|
|
147
|
-
includeSystem?: boolean;
|
|
148
|
-
/** Custom styles applied to the root container */
|
|
149
|
-
style?: object;
|
|
150
|
-
/** Custom styles for the label text */
|
|
151
|
-
labelStyle?: object;
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
* Drop-in theme toggle. Works on web and React Native.
|
|
155
|
-
*
|
|
156
|
-
* ```tsx
|
|
157
|
-
* <ThemeToggle />
|
|
158
|
-
* <ThemeToggle variant="switch" />
|
|
159
|
-
* <ThemeToggle variant="icon-button" lightLabel="☀️" darkLabel="🌙" />
|
|
160
|
-
* ```
|
|
161
|
-
*/
|
|
162
|
-
declare function ThemeToggle({ variant, label, lightLabel, darkLabel, includeSystem, style, labelStyle, }: ThemeToggleProps): React__default.JSX.Element;
|
|
163
|
-
|
|
164
136
|
interface StyledProps {
|
|
165
137
|
/** Additional utility classes applied on top of the base classes */
|
|
166
138
|
kb?: string;
|
|
@@ -306,4 +278,4 @@ declare function kb(classString: string, isDark?: boolean): StyleValue | string;
|
|
|
306
278
|
*/
|
|
307
279
|
declare function cx(...classes: Array<string | false | null | undefined>): string;
|
|
308
280
|
|
|
309
|
-
export { type ColorScale, type ColorsAPI, FrameworkConfig, type InteractionState, InteractiveWrapper, type InteractiveWrapperProps, ParsedClass, ResolvedConfig, ResolvedStyle, StyleValue, type StyledProps, ThemeConfig, ThemeContext, type ThemeContextValue, ThemeMode, ThemeProvider, type ThemeProviderProps,
|
|
281
|
+
export { type ColorScale, type ColorsAPI, FrameworkConfig, type InteractionState, InteractiveWrapper, type InteractiveWrapperProps, ParsedClass, ResolvedConfig, ResolvedStyle, StyleValue, type StyledProps, ThemeConfig, ThemeContext, type ThemeContextValue, ThemeMode, ThemeProvider, type ThemeProviderProps, buildConfig, cx, defaultColors, defaultTheme, disableRuntimeCSS, flatten, getConfig, initConfig, kb, normalizeClassString, parseClass, parseClasses, resolve, splitClassTokens, styled, updateConfig, useBreakpoint, useColors, useGlobalDarkMode, useIsDark, useResolvedStyle, useResponsive, useStyles, useTheme, wrapColors };
|
package/dist/index.d.ts
CHANGED
|
@@ -133,34 +133,6 @@ interface ThemeProviderProps {
|
|
|
133
133
|
}
|
|
134
134
|
declare function ThemeProvider({ children, defaultMode, colorScheme, windowWidth: windowWidthProp, config: configOverride, disablePersistence, }: ThemeProviderProps): React__default.JSX.Element;
|
|
135
135
|
|
|
136
|
-
type ToggleVariant = 'button' | 'switch' | 'icon-button';
|
|
137
|
-
interface ThemeToggleProps {
|
|
138
|
-
/** Visual variant. Default: 'button' */
|
|
139
|
-
variant?: ToggleVariant;
|
|
140
|
-
/** Override label text (button variant) */
|
|
141
|
-
label?: string;
|
|
142
|
-
/** Custom light-mode label */
|
|
143
|
-
lightLabel?: string;
|
|
144
|
-
/** Custom dark-mode label */
|
|
145
|
-
darkLabel?: string;
|
|
146
|
-
/** Show system mode option */
|
|
147
|
-
includeSystem?: boolean;
|
|
148
|
-
/** Custom styles applied to the root container */
|
|
149
|
-
style?: object;
|
|
150
|
-
/** Custom styles for the label text */
|
|
151
|
-
labelStyle?: object;
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
* Drop-in theme toggle. Works on web and React Native.
|
|
155
|
-
*
|
|
156
|
-
* ```tsx
|
|
157
|
-
* <ThemeToggle />
|
|
158
|
-
* <ThemeToggle variant="switch" />
|
|
159
|
-
* <ThemeToggle variant="icon-button" lightLabel="☀️" darkLabel="🌙" />
|
|
160
|
-
* ```
|
|
161
|
-
*/
|
|
162
|
-
declare function ThemeToggle({ variant, label, lightLabel, darkLabel, includeSystem, style, labelStyle, }: ThemeToggleProps): React__default.JSX.Element;
|
|
163
|
-
|
|
164
136
|
interface StyledProps {
|
|
165
137
|
/** Additional utility classes applied on top of the base classes */
|
|
166
138
|
kb?: string;
|
|
@@ -306,4 +278,4 @@ declare function kb(classString: string, isDark?: boolean): StyleValue | string;
|
|
|
306
278
|
*/
|
|
307
279
|
declare function cx(...classes: Array<string | false | null | undefined>): string;
|
|
308
280
|
|
|
309
|
-
export { type ColorScale, type ColorsAPI, FrameworkConfig, type InteractionState, InteractiveWrapper, type InteractiveWrapperProps, ParsedClass, ResolvedConfig, ResolvedStyle, StyleValue, type StyledProps, ThemeConfig, ThemeContext, type ThemeContextValue, ThemeMode, ThemeProvider, type ThemeProviderProps,
|
|
281
|
+
export { type ColorScale, type ColorsAPI, FrameworkConfig, type InteractionState, InteractiveWrapper, type InteractiveWrapperProps, ParsedClass, ResolvedConfig, ResolvedStyle, StyleValue, type StyledProps, ThemeConfig, ThemeContext, type ThemeContextValue, ThemeMode, ThemeProvider, type ThemeProviderProps, buildConfig, cx, defaultColors, defaultTheme, disableRuntimeCSS, flatten, getConfig, initConfig, kb, normalizeClassString, parseClass, parseClasses, resolve, splitClassTokens, styled, updateConfig, useBreakpoint, useColors, useGlobalDarkMode, useIsDark, useResolvedStyle, useResponsive, useStyles, useTheme, wrapColors };
|