@kbach/react-native 1.0.0-beta.28 → 1.0.0-beta.29

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,6 +1,6 @@
1
1
  import {
2
2
  resolveClassName
3
- } from "./chunk-NJZIH3NL.mjs";
3
+ } from "./chunk-B36TKRB6.mjs";
4
4
 
5
5
  // src/jsxRuntimeCoreWeb.ts
6
6
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
@@ -18,7 +18,7 @@ function processElement(resolveClassName2, type, rawProps, key, isStaticChildren
18
18
  }
19
19
  const resolved = resolveClassName2(classStrRaw);
20
20
  const dataSet = { ...userDataSet, kb: resolved };
21
- return makeElement(isStaticChildren, type, { ...rest, dataSet }, key);
21
+ return makeElement(isStaticChildren, type, { ...rest, className: classStrRaw, dataSet }, key);
22
22
  }
23
23
  function createJsxFunctionsWeb(resolveClassName2) {
24
24
  function jsx2(type, props, key) {
@@ -194,4 +194,46 @@ declare function useColors(): ColorsAPI;
194
194
  */
195
195
  declare function useDynamicToken(name: string): string | undefined;
196
196
 
197
- export { type ColorScale as C, type KbachConfig as K, ThemeProvider as T, type ColorsAPI as a, type ThemeProviderProps as b, type ThemeState as c, type ThemeStorageAdapter as d, applyKbachConfig as e, useDynamicToken as f, useTheme as g, resolveKbachConfig as r, useColors as u };
197
+ /**
198
+ * A tiny class-name composer — combine strings, arrays, and objects (with
199
+ * boolean values) into one space-separated className, skipping anything
200
+ * falsy. Matches the widely-used `clsx` npm package's public API and
201
+ * behavior exactly (a from-scratch reimplementation, not a fork or a thin
202
+ * wrapper around it) — this package ships its own copy so using it adds
203
+ * zero runtime dependencies, and so it works identically whether or not
204
+ * `clsx`/`classnames` happens to already be installed.
205
+ *
206
+ * Kbach class strings never NEED this — a Kbach `className` is just a
207
+ * plain string, composable with plain JS (`"bg-" + color + "-6"`,
208
+ * `[base, active && "opacity-100"].join(" ")`, see this package's own
209
+ * README) with no special API required. This exists purely as an
210
+ * ergonomic convenience for the common "several conditional classes on one
211
+ * element" shape, for anyone who'd rather write it declaratively:
212
+ *
213
+ * ```ts
214
+ * clsx("px-4 py-2", isActive && "bg-blue-6", { "opacity-50": disabled });
215
+ * // "px-4 py-2 bg-blue-6" (when isActive is true and disabled is false)
216
+ * ```
217
+ *
218
+ * Identical to `@kbach/react`'s own `clsx.ts` — deliberately duplicated
219
+ * rather than factored into a shared package, since this is genuinely all
220
+ * there is to it and a whole extra published package for one ~20-line
221
+ * function would be more ceremony than the thing itself.
222
+ */
223
+ /** Anything `clsx` accepts as one argument — recursively, for arrays. */
224
+ type ClassValue = ClassArray | ClassDictionary | string | number | bigint | boolean | null | undefined;
225
+ /** A key is kept (as a literal class name) only when its value is truthy — `{ "opacity-50": disabled }`. */
226
+ interface ClassDictionary {
227
+ [className: string]: unknown;
228
+ }
229
+ type ClassArray = ClassValue[];
230
+ /**
231
+ * Joins every truthy piece across all arguments with a single space,
232
+ * skipping falsy values (`false`, `null`, `undefined`, `0`, `""`, `NaN`)
233
+ * entirely — they contribute nothing, not even an extra space. Arrays are
234
+ * flattened (recursively, to any depth); a plain object keeps only the
235
+ * keys whose value is truthy.
236
+ */
237
+ declare function clsx(...inputs: ClassValue[]): string;
238
+
239
+ export { type ClassArray as C, type KbachConfig as K, ThemeProvider as T, type ClassDictionary as a, type ClassValue as b, type ColorScale as c, type ColorsAPI as d, type ThemeProviderProps as e, type ThemeState as f, type ThemeStorageAdapter as g, applyKbachConfig as h, clsx as i, useDynamicToken as j, useTheme as k, resolveKbachConfig as r, useColors as u };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { ColorEntry, ContainerConfig, ThemeConfig, defaultTheme, getTheme, setTheme } from './theme';
2
- export { C as ColorScale, a as ColorsAPI, K as KbachConfig, T as ThemeProvider, b as ThemeProviderProps, c as ThemeState, d as ThemeStorageAdapter, e as applyKbachConfig, r as resolveKbachConfig, u as useColors, f as useDynamicToken, g as useTheme } from './useDynamicToken-C8T9r6Cl.js';
2
+ export { C as ClassArray, a as ClassDictionary, b as ClassValue, c as ColorScale, d as ColorsAPI, K as KbachConfig, T as ThemeProvider, e as ThemeProviderProps, f as ThemeState, g as ThemeStorageAdapter, h as applyKbachConfig, i as clsx, r as resolveKbachConfig, u as useColors, j as useDynamicToken, k as useTheme } from './clsx-BCXALPGh.js';
3
3
  export { ThemeMode, getGlobalDarkMode, getGlobalThemeMode, setGlobalThemeMode, subscribeGlobalDarkMode, toggleGlobalDarkMode } from './darkModeStore';
4
4
  export { deleteDynamicToken, getDynamicToken, setDynamicToken, subscribeDynamicTokens } from './dynamicTokens';
5
5
  import 'react';
package/dist/index.js CHANGED
@@ -22,6 +22,7 @@ var src_exports = {};
22
22
  __export(src_exports, {
23
23
  ThemeProvider: () => ThemeProvider,
24
24
  applyKbachConfig: () => applyKbachConfig,
25
+ clsx: () => clsx,
25
26
  defaultTheme: () => import_theme4.defaultTheme,
26
27
  deleteDynamicToken: () => import_dynamicTokens2.deleteDynamicToken,
27
28
  getDynamicToken: () => import_dynamicTokens2.getDynamicToken,
@@ -333,7 +334,10 @@ function resolveLength(theme, parsed) {
333
334
  }
334
335
  function resolveNegatableLength(theme, parsed) {
335
336
  if (!parsed.negative) return resolveLength(theme, parsed);
336
- if (parsed.isArbitrary) return null;
337
+ if (parsed.isArbitrary) {
338
+ const value2 = parsed.value;
339
+ return value2 === null ? null : `calc(${value2} * -1)`;
340
+ }
337
341
  const value = parsed.value;
338
342
  if (value === null) return null;
339
343
  const px = spacingPx(theme, value);
@@ -1954,10 +1958,37 @@ var import_dynamicTokens = require("./dynamicTokens");
1954
1958
  function useDynamicToken(name) {
1955
1959
  return (0, import_react4.useSyncExternalStore)(import_dynamicTokens.subscribeDynamicTokens, () => (0, import_dynamicTokens.getDynamicToken)(name));
1956
1960
  }
1961
+
1962
+ // src/clsx.ts
1963
+ function clsx(...inputs) {
1964
+ let out = "";
1965
+ for (const input of inputs) {
1966
+ const piece = resolveClassValue(input);
1967
+ if (piece) out = out ? `${out} ${piece}` : piece;
1968
+ }
1969
+ return out;
1970
+ }
1971
+ function resolveClassValue(value) {
1972
+ if (!value) return "";
1973
+ const type = typeof value;
1974
+ if (type === "string" || type === "number" || type === "bigint") return String(value);
1975
+ if (Array.isArray(value)) return clsx(...value);
1976
+ if (type === "object") {
1977
+ let out = "";
1978
+ for (const key in value) {
1979
+ if (Object.prototype.hasOwnProperty.call(value, key) && value[key]) {
1980
+ out = out ? `${out} ${key}` : key;
1981
+ }
1982
+ }
1983
+ return out;
1984
+ }
1985
+ return "";
1986
+ }
1957
1987
  // Annotate the CommonJS export names for ESM import in node:
1958
1988
  0 && (module.exports = {
1959
1989
  ThemeProvider,
1960
1990
  applyKbachConfig,
1991
+ clsx,
1961
1992
  defaultTheme,
1962
1993
  deleteDynamicToken,
1963
1994
  getDynamicToken,
@@ -1,5 +1,5 @@
1
1
  export { ColorEntry, ContainerConfig, ThemeConfig, defaultTheme, getTheme, setTheme } from './theme';
2
- export { C as ColorScale, a as ColorsAPI, K as KbachConfig, T as ThemeProvider, b as ThemeProviderProps, c as ThemeState, e as applyKbachConfig, r as resolveKbachConfig, u as useColors, f as useDynamicToken, g as useTheme } from './useDynamicToken-C8T9r6Cl.js';
2
+ export { C as ClassArray, a as ClassDictionary, b as ClassValue, c as ColorScale, d as ColorsAPI, K as KbachConfig, T as ThemeProvider, e as ThemeProviderProps, f as ThemeState, h as applyKbachConfig, i as clsx, r as resolveKbachConfig, u as useColors, j as useDynamicToken, k as useTheme } from './clsx-BCXALPGh.js';
3
3
  export { ThemeMode, getGlobalDarkMode, getGlobalThemeMode, setGlobalThemeMode, subscribeGlobalDarkMode, toggleGlobalDarkMode } from './darkModeStore';
4
4
  export { deleteDynamicToken, getDynamicToken, setDynamicToken, subscribeDynamicTokens } from './dynamicTokens';
5
5
  import 'react';