@keboola/design 3.1.1 → 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 +78 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +53 -17
- package/dist/index.d.ts +53 -17
- package/dist/index.js +78 -20
- package/dist/index.js.map +1 -1
- package/dist/markdown-editor.cjs.map +1 -1
- package/dist/markdown-editor.js.map +1 -1
- package/dist/mermaid.cjs.map +1 -1
- package/dist/mermaid.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/testing.cjs +56 -16
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.js +57 -17
- package/dist/testing.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -5973,7 +5973,16 @@ var BadgeRoot = ({
|
|
|
5973
5973
|
className,
|
|
5974
5974
|
children,
|
|
5975
5975
|
...rest
|
|
5976
|
-
}) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
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
|
-
|
|
10315
|
-
|
|
10316
|
-
"--color-
|
|
10317
|
-
"--color-
|
|
10318
|
-
"--color-
|
|
10319
|
-
"--color-
|
|
10320
|
-
"--color-
|
|
10321
|
-
"--color-
|
|
10322
|
-
"--color-
|
|
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
|
|
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
|
|
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,
|
|
@@ -16284,6 +16342,7 @@ exports.themeToolbarBrands = themeToolbarBrands;
|
|
|
16284
16342
|
exports.toast = toast;
|
|
16285
16343
|
exports.useAppForm = useAppForm;
|
|
16286
16344
|
exports.useAutosizeInput = useAutosizeInput;
|
|
16345
|
+
exports.useColorScheme = useColorScheme;
|
|
16287
16346
|
exports.useInputOtpContext = useInputOtpContext;
|
|
16288
16347
|
exports.useIsLegacyBrand = useIsLegacyBrand;
|
|
16289
16348
|
exports.useMergeDiff = useMergeDiff;
|