@keboola/design 3.1.0 → 3.2.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/dist/index.cjs CHANGED
@@ -5973,7 +5973,16 @@ var BadgeRoot = ({
5973
5973
  className,
5974
5974
  children,
5975
5975
  ...rest
5976
- }) => /* @__PURE__ */ jsxRuntime.jsx("div", { ...rest, ref, className: cn(badgeRootVariants({ variant, color, className })), children });
5976
+ }) => /* @__PURE__ */ jsxRuntime.jsx(
5977
+ "div",
5978
+ {
5979
+ ...rest,
5980
+ ref,
5981
+ "data-slot": "badge",
5982
+ className: cn(badgeRootVariants({ variant, color, className })),
5983
+ children
5984
+ }
5985
+ );
5977
5986
  var BadgeInner = ({
5978
5987
  ref,
5979
5988
  // root props
@@ -10309,18 +10318,20 @@ var AIGradientsSvg = () => /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "0", h
10309
10318
  ] }) });
10310
10319
 
10311
10320
  // src/components/ThemeProvider/brandToCssVars.ts
10312
- var brandToCssVars = (brand) => {
10313
- const vars = {
10314
- "--color-background": brand.colors.background,
10315
- "--color-foreground": brand.colors.foreground,
10316
- "--color-muted": brand.colors.muted,
10317
- "--color-muted-foreground": brand.colors.mutedForeground,
10318
- "--color-border": brand.colors.border,
10319
- "--color-primary": brand.colors.primary,
10320
- "--color-primary-foreground": brand.colors.primaryForeground,
10321
- "--color-destructive": brand.colors.destructive,
10322
- "--color-destructive-foreground": brand.colors.destructiveForeground
10323
- };
10321
+ var brandToCssVars = (brand, resolvedMode) => {
10322
+ const vars = {};
10323
+ const colors8 = resolvedMode === "dark" ? brand.colorsDark : brand.colors;
10324
+ if (colors8) {
10325
+ vars["--color-background"] = colors8.background;
10326
+ vars["--color-foreground"] = colors8.foreground;
10327
+ vars["--color-muted"] = colors8.muted;
10328
+ vars["--color-muted-foreground"] = colors8.mutedForeground;
10329
+ vars["--color-border"] = colors8.border;
10330
+ vars["--color-primary"] = colors8.primary;
10331
+ vars["--color-primary-foreground"] = colors8.primaryForeground;
10332
+ vars["--color-destructive"] = colors8.destructive;
10333
+ vars["--color-destructive-foreground"] = colors8.destructiveForeground;
10334
+ }
10324
10335
  if (brand.radii) {
10325
10336
  vars["--radius-sm"] = brand.radii.sm;
10326
10337
  vars["--radius-md"] = brand.radii.md;
@@ -10328,12 +10339,50 @@ var brandToCssVars = (brand) => {
10328
10339
  }
10329
10340
  return vars;
10330
10341
  };
10331
- var ThemeProvider = ({ brand = brandRegistry.keboola, setBrand, children }) => {
10342
+ var DARK_QUERY = "(prefers-color-scheme: dark)";
10343
+ var systemMode = () => {
10344
+ if (typeof window === "undefined" || typeof window.matchMedia !== "function") return "light";
10345
+ return window.matchMedia(DARK_QUERY).matches ? "dark" : "light";
10346
+ };
10347
+ var ThemeProvider = ({
10348
+ brand = brandRegistry.keboola,
10349
+ setBrand,
10350
+ colorScheme = "light",
10351
+ children
10352
+ }) => {
10353
+ const parent = react.use(ThemeContext);
10354
+ const isRoot = parent === null;
10355
+ const [systemResolved, setSystemResolved] = react.useState(systemMode);
10356
+ react.useEffect(() => {
10357
+ if (!isRoot || colorScheme !== "system") return;
10358
+ if (typeof window === "undefined" || typeof window.matchMedia !== "function") return;
10359
+ const mql = window.matchMedia(DARK_QUERY);
10360
+ const onChange = (event) => setSystemResolved(event.matches ? "dark" : "light");
10361
+ setSystemResolved(mql.matches ? "dark" : "light");
10362
+ mql.addEventListener("change", onChange);
10363
+ return () => mql.removeEventListener("change", onChange);
10364
+ }, [isRoot, colorScheme]);
10365
+ const ownMode = colorScheme === "system" ? systemResolved : colorScheme;
10366
+ const resolvedMode = isRoot ? ownMode : parent.resolvedMode;
10367
+ react.useEffect(() => {
10368
+ if (!isRoot || typeof document === "undefined") return;
10369
+ const root = document.documentElement;
10370
+ const previous = root.getAttribute("data-theme");
10371
+ root.setAttribute("data-theme", resolvedMode);
10372
+ return () => {
10373
+ if (root.getAttribute("data-theme") !== resolvedMode) return;
10374
+ if (previous === null) {
10375
+ root.removeAttribute("data-theme");
10376
+ } else {
10377
+ root.setAttribute("data-theme", previous);
10378
+ }
10379
+ };
10380
+ }, [isRoot, resolvedMode]);
10332
10381
  react.useEffect(() => {
10333
10382
  if (typeof document === "undefined") return;
10334
10383
  const root = document.documentElement;
10335
10384
  const previousBrand = root.getAttribute("data-brand");
10336
- const vars = brandToCssVars(brand);
10385
+ const vars = brandToCssVars(brand, resolvedMode);
10337
10386
  const previousValues = {};
10338
10387
  for (const name of Object.keys(vars)) {
10339
10388
  previousValues[name] = root.style.getPropertyValue(name);
@@ -10359,8 +10408,8 @@ var ThemeProvider = ({ brand = brandRegistry.keboola, setBrand, children }) => {
10359
10408
  }
10360
10409
  }
10361
10410
  };
10362
- }, [brand]);
10363
- return /* @__PURE__ */ jsxRuntime.jsxs(ThemeContext, { value: { brand, setBrand }, children: [
10411
+ }, [brand, resolvedMode]);
10412
+ return /* @__PURE__ */ jsxRuntime.jsxs(ThemeContext, { value: { brand, setBrand, colorScheme, resolvedMode }, children: [
10364
10413
  /* @__PURE__ */ jsxRuntime.jsx(AIGradientsSvg, {}),
10365
10414
  children
10366
10415
  ] });
@@ -10374,7 +10423,16 @@ var useTheme = () => {
10374
10423
  }
10375
10424
  return context;
10376
10425
  };
10377
- var ThemeDecorator = ({ brand, children }) => /* @__PURE__ */ jsxRuntime.jsx(ThemeProvider, { brand, children });
10426
+ var useColorScheme = () => {
10427
+ const context = react.use(ThemeContext);
10428
+ if (context === null) {
10429
+ throw new Error(
10430
+ "useColorScheme must be used within a <ThemeProvider>. Wrap your app root with <ThemeProvider colorScheme={...}> from @keboola/design."
10431
+ );
10432
+ }
10433
+ return { colorScheme: context.colorScheme, resolvedMode: context.resolvedMode };
10434
+ };
10435
+ var ThemeDecorator = ({ brand, colorScheme = "light", children }) => /* @__PURE__ */ jsxRuntime.jsx(ThemeProvider, { brand, colorScheme, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "tw-bg-background tw-text-foreground", children }) });
10378
10436
  var themeToolbarBrands = [brandRegistry.keboola, brandRegistry.keboolaLegacy, brandRegistry.exampleCustomer];
10379
10437
  var resolveStorybookBrand = (id) => {
10380
10438
  if (typeof id !== "string") return brandRegistry.keboola;
@@ -10630,7 +10688,7 @@ var PageLayout = Object.assign(Root25, {
10630
10688
  // src/blocks/PageHeader/styles.ts
10631
10689
  var titleRowClass = "tw-flex tw-flex-wrap tw-items-center tw-gap-x-3 tw-gap-y-2";
10632
10690
  var titleClass = "tw-m-0 tw-text-3xl tw-font-semibold tw-leading-9 tw-text-foreground tw-break-words";
10633
- var badgesClass = "tw-flex tw-flex-wrap tw-items-center tw-gap-2";
10691
+ var badgesClass = "tw-flex tw-flex-wrap tw-items-center tw-gap-2 [&_[data-slot=badge]]:tw-rounded-full [&_[data-slot=badge]]:tw-normal-case [&_[data-slot=badge]]:tw-tracking-normal [&_[data-slot=badge]]:tw-py-0";
10634
10692
  var descriptionClass = "tw-m-0 tw-max-w-[800px] tw-break-words tw-text-sm tw-leading-5 tw-text-muted-foreground";
10635
10693
  var PageHeaderDetail = ({
10636
10694
  ref,
@@ -13118,7 +13176,7 @@ var TableHead = ({ className, ...props }) => {
13118
13176
  "th",
13119
13177
  {
13120
13178
  className: cn(
13121
- "tw-px-3 tw-py-2 tw-text-left tw-font-medium tw-whitespace-nowrap [&:has([role=checkbox])]:tw-pr-0 [&>[role=checkbox]]:tw-translate-y-[2px]",
13179
+ "tw-px-3 tw-py-2 tw-text-left tw-font-medium tw-whitespace-nowrap [&:has([role=checkbox])]:tw-pr-0 [&>[role=checkbox]]:tw-translate-y-[2px] focus-within:tw-ring-2 focus-within:tw-ring-primary/50",
13122
13180
  className
13123
13181
  ),
13124
13182
  ...props
@@ -13146,7 +13204,17 @@ var TableRow = ({
13146
13204
  ref,
13147
13205
  className,
13148
13206
  ...props
13149
- }) => /* @__PURE__ */ jsxRuntime.jsx("tr", { ref, className: cn("hover:tw-bg-muted/50", className), ...props });
13207
+ }) => /* @__PURE__ */ jsxRuntime.jsx(
13208
+ "tr",
13209
+ {
13210
+ ref,
13211
+ className: cn(
13212
+ "hover:tw-bg-muted/50 aria-selected:tw-bg-accent aria-selected:hover:tw-bg-accent",
13213
+ className
13214
+ ),
13215
+ ...props
13216
+ }
13217
+ );
13150
13218
  var Table = ({
13151
13219
  borderCollapsed = true,
13152
13220
  bordered = false,
@@ -16274,6 +16342,7 @@ exports.themeToolbarBrands = themeToolbarBrands;
16274
16342
  exports.toast = toast;
16275
16343
  exports.useAppForm = useAppForm;
16276
16344
  exports.useAutosizeInput = useAutosizeInput;
16345
+ exports.useColorScheme = useColorScheme;
16277
16346
  exports.useInputOtpContext = useInputOtpContext;
16278
16347
  exports.useIsLegacyBrand = useIsLegacyBrand;
16279
16348
  exports.useMergeDiff = useMergeDiff;