@alexandregme/zljs 3.21.0 → 3.23.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.
@@ -46,10 +46,10 @@ var wrapper = tv2({
46
46
  base: "flex flex-col gap-1"
47
47
  });
48
48
  var label = tv2({
49
- base: "text-sm font-medium text-gray-700"
49
+ base: "text-sm font-medium text-zl-text-soft"
50
50
  });
51
51
  var input = tv2({
52
- base: "px-3 py-2 border border-gray-500 rounded-md text-sm placeholder:text-gray-500 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-zl-primary disabled:bg-gray-100 disabled:cursor-not-allowed"
52
+ base: "px-3 py-2 border border-zl-border-strong rounded-md text-sm placeholder:text-zl-muted focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-zl-primary disabled:bg-zl-surface-muted disabled:cursor-not-allowed"
53
53
  });
54
54
 
55
55
  // core/forms/input/input.tsx
package/dist/index.d.ts CHANGED
@@ -12,7 +12,7 @@ import 'react-hook-form';
12
12
  */
13
13
  type Size = "sm" | "md" | "lg";
14
14
 
15
- declare const iconNames: readonly ["Check", "X", "Plus", "Minus", "Search", "Menu", "ChevronDown", "ChevronUp", "ChevronLeft", "ChevronRight", "ChevronsUp", "ArrowUp", "Pencil", "Trash2", "Save", "RefreshCw", "Home", "MessageSquare", "Users", "Store", "ShoppingCart", "BarChart3", "Brain", "Send", "LogOut", "Download", "Share2", "User", "Key", "Contact", "Package", "Warehouse", "HandCoins", "Stethoscope", "LogIn", "Megaphone", "LayoutDashboard", "Smile", "Frown", "Cat", "ArrowRight", "Loader", "LoaderCircle", "CheckCircle", "XCircle", "AlertTriangle", "Info", "Route", "Navigation", "ListChecks", "Map", "MapPinOff", "Settings", "SiWhatsapp", "SiFacebook", "SiInstagram", "SiShopify", "SiGithub", "SiVercel"];
15
+ declare const iconNames: readonly ["Check", "X", "Plus", "Minus", "Search", "Menu", "ChevronDown", "ChevronUp", "ChevronLeft", "ChevronRight", "ChevronsUp", "ArrowUp", "Pencil", "Trash2", "Save", "RefreshCw", "Home", "MessageSquare", "Users", "Store", "ShoppingCart", "BarChart3", "Brain", "Send", "LogOut", "Download", "Share2", "User", "Key", "Contact", "Package", "Warehouse", "HandCoins", "Stethoscope", "LogIn", "Megaphone", "LayoutDashboard", "Smile", "Frown", "Cat", "ArrowRight", "Loader", "LoaderCircle", "CheckCircle", "XCircle", "AlertTriangle", "Info", "Route", "Navigation", "ListChecks", "Map", "MapPinOff", "Settings", "Monitor", "Sun", "Moon", "SiWhatsapp", "SiFacebook", "SiInstagram", "SiShopify", "SiGithub", "SiVercel", "SiSupabase"];
16
16
 
17
17
  type IconName = (typeof iconNames)[number];
18
18
  /** The sizes every component has, and `xl` for an icon that stands alone. */
@@ -39,10 +39,15 @@ interface ButtonProps {
39
39
  "aria-label"?: string;
40
40
  /** For a button that opens and closes something, such as a menu. */
41
41
  "aria-expanded"?: boolean;
42
+ /**
43
+ * For a button that stays on, such as the chosen one of a group. `ghost`
44
+ * draws it with a background.
45
+ */
46
+ "aria-pressed"?: boolean;
42
47
  onClick?: () => void;
43
48
  }
44
49
 
45
- declare const Button: ({ children, type, variant: variantProp, color, size, fullWidth, icon, iconPosition, disabled, "aria-label": ariaLabel, "aria-expanded": ariaExpanded, onClick, }: ButtonProps) => react.JSX.Element;
50
+ declare const Button: ({ children, type, variant: variantProp, color, size, fullWidth, icon, iconPosition, disabled, "aria-label": ariaLabel, "aria-expanded": ariaExpanded, "aria-pressed": ariaPressed, onClick, }: ButtonProps) => react.JSX.Element;
46
51
 
47
52
  interface DataGridCellParams<T extends Record<string, unknown> = Record<string, unknown>> {
48
53
  value?: any;
@@ -226,7 +231,7 @@ interface ModalProps {
226
231
  children?: ReactNode;
227
232
  /** The width. `xs` is the smallest, for a short question and its buttons. */
228
233
  size?: ModalSize;
229
- /** The color of the title and a light background in that color. `none`, the default, is white. */
234
+ /** The color of the title and a light background in that color. `none`, the default, is the surface color. */
230
235
  color?: SemanticColor;
231
236
  }
232
237
 
@@ -259,6 +264,30 @@ interface TextProps {
259
264
 
260
265
  declare const Text: ({ children, as: Tag, variant, color, }: TextProps) => react.JSX.Element;
261
266
 
267
+ interface ThemeToggleProps {
268
+ /**
269
+ * The accessible name of the group of buttons. With `iconOnly`, it starts
270
+ * the name of the one button, before the theme in use.
271
+ */
272
+ label: string;
273
+ /**
274
+ * Shows one button, with the icon of the theme in use, that goes to the next
275
+ * theme on each click. For a place with no room for the three, such as a
276
+ * collapsed sidebar.
277
+ */
278
+ iconOnly?: boolean;
279
+ /** The size of the buttons. `lg` is for a touch screen. */
280
+ size?: Size;
281
+ /** The name of the theme that follows the device. */
282
+ systemLabel?: string;
283
+ /** The name of the light theme. */
284
+ lightLabel?: string;
285
+ /** The name of the dark theme. */
286
+ darkLabel?: string;
287
+ }
288
+
289
+ declare const ThemeToggle: ({ label, iconOnly, size, systemLabel, lightLabel, darkLabel, }: ThemeToggleProps) => react.JSX.Element;
290
+
262
291
  interface ShareAppButtonProps {
263
292
  /** The text of the button. With `iconOnly`, its accessible name. */
264
293
  label: string;
@@ -332,6 +361,13 @@ interface SidebarProps {
332
361
  homeLabel?: string;
333
362
  /** The accessible name of the navigation. */
334
363
  navLabel?: string;
364
+ /**
365
+ * The texts of the theme buttons, over the share button: `label`, the name
366
+ * of the group, and `systemLabel`, `lightLabel` and `darkLabel`, the name of
367
+ * each theme. Collapsed, the three become one button that goes to the next
368
+ * theme on each click.
369
+ */
370
+ theme?: Partial<Omit<ThemeToggleProps, "iconOnly" | "size">>;
335
371
  /**
336
372
  * The share button, over the user: its texts (`label`, `copiedMessage` and
337
373
  * `errorMessage`) and what goes with the address of the app (`title` and
@@ -350,7 +386,7 @@ interface SidebarProps {
350
386
  onLogout: () => void | Promise<void>;
351
387
  }
352
388
 
353
- declare const Sidebar: ({ sections, user, activeHref, defaultCollapsed, collapseLabel, expandLabel, homeHref, homeLabel, navLabel, share, logout, onLogout, }: SidebarProps) => react.JSX.Element;
389
+ declare const Sidebar: ({ sections, user, activeHref, defaultCollapsed, collapseLabel, expandLabel, homeHref, homeLabel, navLabel, theme, share, logout, onLogout, }: SidebarProps) => react.JSX.Element;
354
390
 
355
391
  interface TabsItem {
356
392
  /** Unique among the tabs. `defaultTab` and `onChange` use it. */
@@ -407,6 +443,36 @@ declare const useInstallApp: () => InstallApp;
407
443
  */
408
444
  declare const useIsDesktop: () => boolean | null;
409
445
 
446
+ /** The themes, in the order a control shows them. */
447
+ declare const themes: readonly ["system", "light", "dark"];
448
+
449
+ /**
450
+ * `system` follows the theme of the device, and changes with it. `light` and
451
+ * `dark` are the choice of the user, whatever the device says.
452
+ */
453
+ type Theme = (typeof themes)[number];
454
+ interface UseTheme {
455
+ /** The theme the user chose. `system` while they chose none. */
456
+ theme: Theme;
457
+ /**
458
+ * Changes the theme of the page, and keeps the choice in the browser for the
459
+ * next visit.
460
+ */
461
+ setTheme: (theme: Theme) => void;
462
+ }
463
+
464
+ /**
465
+ * Changes the theme of the page from outside a component, and keeps the choice
466
+ * in the browser for the next visit. Inside a component, use `useTheme`.
467
+ */
468
+ declare const setTheme: (theme: Theme) => void;
469
+ /**
470
+ * The theme the user chose and the function that changes it. `system`, the
471
+ * default, follows the device. On the server the theme is `system`, where the
472
+ * choice can't be read.
473
+ */
474
+ declare const useTheme: () => UseTheme;
475
+
410
476
  interface InstallAppButtonProps {
411
477
  /**
412
478
  * How the browser installs the app, from `useInstallApp`: `prompt` calls
@@ -453,7 +519,13 @@ interface TopNavProps {
453
519
  /** The accessible name of the account button. */
454
520
  accountLabel?: string;
455
521
  /**
456
- * The share button, the first line of the account panel: its texts (`label`,
522
+ * The texts of the theme buttons, the first line of the account panel:
523
+ * `label`, the name of the group, and `systemLabel`, `lightLabel` and
524
+ * `darkLabel`, the name of each theme.
525
+ */
526
+ theme?: Partial<Omit<ThemeToggleProps, "iconOnly" | "size">>;
527
+ /**
528
+ * The share button, the second line of the account panel: its texts (`label`,
457
529
  * `copiedMessage` and `errorMessage`) and what goes with the address of the
458
530
  * app (`title` and `text`).
459
531
  */
@@ -477,7 +549,7 @@ interface TopNavProps {
477
549
  onLogout: () => void | Promise<void>;
478
550
  }
479
551
 
480
- declare const TopNav: ({ sections, user, activeHref, homeHref, homeLabel, navLabel, menuLabel, accountLabel, share, install, logout, onLogout, }: TopNavProps) => react.JSX.Element;
552
+ declare const TopNav: ({ sections, user, activeHref, homeHref, homeLabel, navLabel, menuLabel, accountLabel, theme, share, install, logout, onLogout, }: TopNavProps) => react.JSX.Element;
481
553
 
482
554
  type TagColor = Exclude<SemanticColor, "none"> | AuxiliaryColor;
483
555
  interface TagProps {
@@ -560,7 +632,7 @@ interface NavigationProps extends SidebarProps, Pick<TopNavProps, "menuLabel" |
560
632
  mode?: NavigationMode;
561
633
  }
562
634
 
563
- declare const Navigation: ({ mode, sections, user, activeHref, defaultCollapsed, collapseLabel, expandLabel, homeHref, homeLabel, navLabel, menuLabel, accountLabel, share, install, logout, onLogout, }: NavigationProps) => react.JSX.Element | null;
635
+ declare const Navigation: ({ mode, sections, user, activeHref, defaultCollapsed, collapseLabel, expandLabel, homeHref, homeLabel, navLabel, menuLabel, accountLabel, theme, share, install, logout, onLogout, }: NavigationProps) => react.JSX.Element | null;
564
636
 
565
637
  interface AppState {
566
638
  fetchingCalls: number;
@@ -661,9 +733,9 @@ interface CardProps {
661
733
  title?: string;
662
734
  /** The heading level of `title`: 1 when the card is the whole page. */
663
735
  titleLevel?: 1 | 2 | 3 | 4 | 5 | 6;
664
- /** Shows under `title`. Muted on a white card. */
736
+ /** Shows under `title`. Muted on a card with no color. */
665
737
  message?: string;
666
- /** The border and a light background in that color. `none` is white. */
738
+ /** The border and a light background in that color. `none` is the surface color. */
667
739
  color?: SemanticColor;
668
740
  }
669
741
 
@@ -789,5 +861,5 @@ declare const useAuth: () => UseAuthResult;
789
861
 
790
862
  declare const ZustandProviders: ({ children, auth }: ZustandProvidersProps) => react.JSX.Element;
791
863
 
792
- export { AccessPending, AuthAdapter, AuthProvider, AuthSession, Authorized, AuxiliaryColor, Button, Card, Checkbox, ConnectedModal, DataColor, DataGrid, Disclosure, Error, Form, HTTPClient, Heading, Icon, Input, InstallAppButton, Loader, Login, Modal, Navigation, Radio, ReduxProvider, ReduxProviderProps, Select, SemanticColor, ShareAppButton, Sidebar, SignOutButton, Spinner, StatsCard, Tabs, Tag, Text, TextArea, Toaster, TopNav, WhatsAppButton, ZustandProviders, ZustandProvidersProps, appInitialState, getAuthSession, splitURLasPath, toast, useAppStore, useAuth, useInstallApp, useIsDesktop, usePageStore, useRouterStore, useToastStore };
793
- export type { AppState, AuthorizedProps, ButtonColor, ButtonProps, ButtonVariant, CardProps, CheckboxProps, CheckboxVariant, ConnectedModalProps, DataGridColumn, DataGridProps, DisclosureProps, DisclosureVariant, ErrorProps, FormProps, HeadingProps, HttpClientConfig, HttpRequestConfig, IconName, IconProps, IconSize, InputProps, InstallApp, InstallAppButtonProps, InstallAppWay, LoaderProps, LoginProvider, LoginVendor, ModalProps, NavigationMode, NavigationProps, PageState, RadioProps, ReduxStore, RouterState, SelectOption, SelectProps, ShareAppButtonProps, SidebarItem, SidebarProps, SidebarSection, SidebarUser, Size, SpinnerProps, SpinnerVariant, StatsCardProps, TabsItem, TabsProps, TagColor, TagProps, TextAreaProps, TextProps, TextVariant, Toast, ToastState, ToastType, TopNavProps, WhatsAppButtonProps };
864
+ export { AccessPending, AuthAdapter, AuthProvider, AuthSession, Authorized, AuxiliaryColor, Button, Card, Checkbox, ConnectedModal, DataColor, DataGrid, Disclosure, Error, Form, HTTPClient, Heading, Icon, Input, InstallAppButton, Loader, Login, Modal, Navigation, Radio, ReduxProvider, ReduxProviderProps, Select, SemanticColor, ShareAppButton, Sidebar, SignOutButton, Spinner, StatsCard, Tabs, Tag, Text, TextArea, ThemeToggle, Toaster, TopNav, WhatsAppButton, ZustandProviders, ZustandProvidersProps, appInitialState, getAuthSession, setTheme, splitURLasPath, toast, useAppStore, useAuth, useInstallApp, useIsDesktop, usePageStore, useRouterStore, useTheme, useToastStore };
865
+ export type { AppState, AuthorizedProps, ButtonColor, ButtonProps, ButtonVariant, CardProps, CheckboxProps, CheckboxVariant, ConnectedModalProps, DataGridColumn, DataGridProps, DisclosureProps, DisclosureVariant, ErrorProps, FormProps, HeadingProps, HttpClientConfig, HttpRequestConfig, IconName, IconProps, IconSize, InputProps, InstallApp, InstallAppButtonProps, InstallAppWay, LoaderProps, LoginProvider, LoginVendor, ModalProps, NavigationMode, NavigationProps, PageState, RadioProps, ReduxStore, RouterState, SelectOption, SelectProps, ShareAppButtonProps, SidebarItem, SidebarProps, SidebarSection, SidebarUser, Size, SpinnerProps, SpinnerVariant, StatsCardProps, TabsItem, TabsProps, TagColor, TagProps, TextAreaProps, TextProps, TextVariant, Theme, ThemeToggleProps, Toast, ToastState, ToastType, TopNavProps, UseTheme, WhatsAppButtonProps };
package/dist/index.js CHANGED
@@ -19,11 +19,13 @@ import {
19
19
  SignOutButton,
20
20
  Spinner,
21
21
  Text,
22
+ ThemeToggle,
22
23
  Toaster,
23
24
  TopNav,
24
25
  ZustandProviders,
25
26
  appInitialState,
26
27
  getAuthSession,
28
+ setTheme,
27
29
  splitURLasPath,
28
30
  toast,
29
31
  useAppStore,
@@ -32,14 +34,15 @@ import {
32
34
  useIsDesktop,
33
35
  usePageStore,
34
36
  useRouterStore,
37
+ useTheme,
35
38
  useToastStore
36
- } from "./chunk-DM4EKQGH.js";
39
+ } from "./chunk-NHCD5NHZ.js";
37
40
  import {
38
41
  Error,
39
42
  FormInput,
40
43
  FormProvider,
41
44
  Input
42
- } from "./chunk-VW4GICIJ.js";
45
+ } from "./chunk-US6IUIXD.js";
43
46
 
44
47
  // core/data-grid/data-grid.tsx
45
48
  import { AG_GRID_LOCALE_BR } from "@ag-grid-community/locale";
@@ -60,7 +63,7 @@ var innerWrapper = tv({
60
63
  variants: {
61
64
  variant: {
62
65
  default: "w-fit items-center gap-2",
63
- card: "items-center gap-3 rounded-lg border border-gray-500 p-3 has-checked:border-zl-primary has-checked:ring-1 has-checked:ring-zl-primary has-disabled:bg-gray-100"
66
+ card: "items-center gap-3 rounded-lg border border-zl-border-strong p-3 has-checked:border-zl-primary has-checked:ring-1 has-checked:ring-zl-primary has-disabled:bg-zl-surface-muted"
64
67
  }
65
68
  },
66
69
  defaultVariants: {
@@ -68,7 +71,7 @@ var innerWrapper = tv({
68
71
  }
69
72
  });
70
73
  var checkbox = tv({
71
- base: "shrink-0 accent-zl-primary border-gray-300 rounded focus:ring-2 focus:ring-blue-500 disabled:cursor-not-allowed",
74
+ base: "shrink-0 accent-zl-primary rounded focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-zl-primary disabled:cursor-not-allowed",
72
75
  variants: {
73
76
  size: {
74
77
  sm: "w-3.5 h-3.5",
@@ -81,7 +84,7 @@ var checkbox = tv({
81
84
  }
82
85
  });
83
86
  var label = tv({
84
- base: "min-w-0 flex-1 text-sm text-gray-700 select-none"
87
+ base: "min-w-0 flex-1 text-sm text-zl-text-soft select-none"
85
88
  });
86
89
 
87
90
  // core/forms/checkbox/checkbox.tsx
@@ -148,7 +151,7 @@ var radio = tv3({
148
151
  base: "w-4 h-4 shrink-0 accent-zl-primary focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-zl-primary disabled:cursor-not-allowed"
149
152
  });
150
153
  var label2 = tv3({
151
- base: "text-sm text-gray-700 select-none"
154
+ base: "text-sm text-zl-text-soft select-none"
152
155
  });
153
156
 
154
157
  // core/forms/radio/radio.tsx
@@ -199,10 +202,10 @@ var wrapper3 = tv4({
199
202
  base: "flex flex-col gap-1"
200
203
  });
201
204
  var label3 = tv4({
202
- base: "text-sm font-medium text-gray-700"
205
+ base: "text-sm font-medium text-zl-text-soft"
203
206
  });
204
207
  var select = tv4({
205
- base: "px-3 py-2 border border-gray-500 rounded-md text-sm bg-white focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-zl-primary disabled:bg-gray-100 disabled:cursor-not-allowed"
208
+ base: "px-3 py-2 border border-zl-border-strong rounded-md text-sm bg-zl-surface focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-zl-primary disabled:bg-zl-surface-muted disabled:cursor-not-allowed"
206
209
  });
207
210
 
208
211
  // core/forms/select/select.tsx
@@ -264,10 +267,10 @@ var wrapper4 = tv5({
264
267
  base: "flex flex-col gap-1"
265
268
  });
266
269
  var label4 = tv5({
267
- base: "text-sm font-medium text-gray-700"
270
+ base: "text-sm font-medium text-zl-text-soft"
268
271
  });
269
272
  var textarea = tv5({
270
- base: "px-3 py-2 border border-gray-500 rounded-md text-sm placeholder:text-gray-500 resize-y focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-zl-primary disabled:bg-gray-100 disabled:cursor-not-allowed"
273
+ base: "px-3 py-2 border border-zl-border-strong rounded-md text-sm placeholder:text-zl-muted resize-y focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-zl-primary disabled:bg-zl-surface-muted disabled:cursor-not-allowed"
271
274
  });
272
275
 
273
276
  // core/forms/text-area/text-area.tsx
@@ -416,7 +419,7 @@ var DataGridStatusBar = ({
416
419
  }) => {
417
420
  const isFiltered = displayedRows !== totalRows || activeFilters.length > 0;
418
421
  const count = isFiltered ? `${displayedRows} / ${totalRows} registros` : `${totalRows} registros`;
419
- return /* @__PURE__ */ jsxs7("div", { className: "flex items-center gap-3 px-2 py-1.5 bg-slate-100 border border-slate-200 rounded text-sm text-slate-600 mb-2", children: [
422
+ return /* @__PURE__ */ jsxs7("div", { className: "flex items-center gap-3 px-2 py-1.5 bg-zl-surface-muted border border-zl-border rounded text-sm text-zl-text-soft mb-2", children: [
420
423
  /* @__PURE__ */ jsxs7("span", { role: "status", "aria-label": count, className: "font-medium", children: [
421
424
  isFiltered && /* @__PURE__ */ jsxs7(Fragment, { children: [
422
425
  /* @__PURE__ */ jsx8(Text, { as: "span", variant: "caption", color: "primary", children: displayedRows }),
@@ -428,7 +431,7 @@ var DataGridStatusBar = ({
428
431
  " ",
429
432
  /* @__PURE__ */ jsx8(Text, { as: "span", variant: "caption", children: "registros" })
430
433
  ] }),
431
- activeFilters.length > 0 && /* @__PURE__ */ jsx8(Fragment, { children: /* @__PURE__ */ jsxs7("div", { className: "flex items-center gap-2 flex-wrap border-l border-slate-300 pl-3", children: [
434
+ activeFilters.length > 0 && /* @__PURE__ */ jsx8(Fragment, { children: /* @__PURE__ */ jsxs7("div", { className: "flex items-center gap-2 flex-wrap border-l border-zl-border pl-3", children: [
432
435
  /* @__PURE__ */ jsx8(Text, { as: "span", variant: "caption", children: "Filtros:" }),
433
436
  activeFilters.map((filter) => /* @__PURE__ */ jsx8(
434
437
  Tag,
@@ -449,26 +452,28 @@ import { themeAlpine } from "ag-grid-community";
449
452
  var dataGridPalette = {
450
453
  slate: {
451
454
  50: "#f8fafc",
452
- 200: "#e2e8f0",
453
455
  600: "#475569",
454
456
  700: "#334155"
455
457
  },
456
- sky: {
457
- 100: "#e0f2fe"
458
- },
459
- blue: {
460
- 100: "#dbeafe"
458
+ neutral: {
459
+ 700: "#404040",
460
+ 800: "#262626"
461
461
  }
462
462
  };
463
463
  var dataGridTheme = themeAlpine.withParams({
464
+ // Alpine fixes the grid in the light scheme, which would keep the light side
465
+ // of every theme value: the grid takes the scheme of the page instead.
466
+ browserColorScheme: "inherit",
464
467
  accentColor: "var(--color-zl-primary)",
465
- headerBackgroundColor: dataGridPalette.slate[700],
468
+ backgroundColor: "var(--color-zl-surface)",
469
+ foregroundColor: "var(--color-zl-text)",
470
+ headerBackgroundColor: `light-dark(${dataGridPalette.slate[700]}, ${dataGridPalette.neutral[800]})`,
466
471
  headerTextColor: dataGridPalette.slate[50],
467
- oddRowBackgroundColor: dataGridPalette.slate[50],
468
- rowHoverColor: dataGridPalette.sky[100],
469
- selectedRowBackgroundColor: dataGridPalette.blue[100],
470
- borderColor: dataGridPalette.slate[200],
471
- headerColumnBorder: dataGridPalette.slate[600],
472
+ oddRowBackgroundColor: "var(--color-zl-surface-muted)",
473
+ rowHoverColor: "color-mix(in oklab, var(--color-zl-primary) 12%, var(--color-zl-surface))",
474
+ selectedRowBackgroundColor: "color-mix(in oklab, var(--color-zl-primary) 20%, var(--color-zl-surface))",
475
+ borderColor: "var(--color-zl-border)",
476
+ headerColumnBorder: `light-dark(${dataGridPalette.slate[600]}, ${dataGridPalette.neutral[700]})`,
472
477
  fontSize: 13,
473
478
  headerHeight: 36,
474
479
  rowHeight: 32,
@@ -596,7 +601,9 @@ var disclosure = tv8({
596
601
  variants: {
597
602
  variant: {
598
603
  plain: {},
599
- outlined: { base: "rounded-lg border border-gray-200 bg-white p-3" }
604
+ outlined: {
605
+ base: "rounded-lg border border-zl-border bg-zl-surface p-3"
606
+ }
600
607
  }
601
608
  },
602
609
  defaultVariants: {
@@ -689,16 +696,16 @@ var tabs = tv10({
689
696
  // the height of a parent that has one, and the panel gets what the list
690
697
  // leaves, so a panel can fill the page. With no height around it, both
691
698
  // follow their content.
692
- base: "flex h-full w-full flex-col overflow-hidden rounded-lg border border-gray-200",
693
- list: "flex shrink-0 overflow-x-auto border-b border-gray-200",
699
+ base: "flex h-full w-full flex-col overflow-hidden rounded-lg border border-zl-border",
700
+ list: "flex shrink-0 overflow-x-auto border-b border-zl-border",
694
701
  // A line between the tabs, and the selected one stands out three ways: a
695
- // white background next to the gray ones, a line under it and its label in
702
+ // surface background next to the ones in the color of the page, a line under it and its label in
696
703
  // the primary color. A tab grows to share the width of the list and never
697
704
  // shrinks under its content, so the list scrolls when they don't fit. The
698
705
  // outline sits inside the tab, because the border clips what overflows it.
699
706
  // The first and the last tab follow the round corners of the border, so
700
707
  // the outline does too.
701
- tab: "flex min-h-11 min-w-max shrink-0 grow basis-0 cursor-pointer items-center justify-between gap-3 border-r border-b-2 border-r-gray-200 border-b-transparent bg-gray-50 px-4 py-2 text-left text-gray-700 first:rounded-tl-[calc(var(--radius-lg)-1px)] last:rounded-tr-[calc(var(--radius-lg)-1px)] last:border-r-0 hover:text-gray-900 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-zl-primary data-[state=active]:border-b-zl-primary data-[state=active]:bg-white data-[state=active]:text-zl-primary",
708
+ tab: "flex min-h-11 min-w-max shrink-0 grow basis-0 cursor-pointer items-center justify-between gap-3 border-r border-b-2 border-r-zl-border border-b-transparent bg-zl-page px-4 py-2 text-left text-zl-text-soft first:rounded-tl-[calc(var(--radius-lg)-1px)] last:rounded-tr-[calc(var(--radius-lg)-1px)] last:border-r-0 hover:text-zl-text focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-zl-primary data-[state=active]:border-b-zl-primary data-[state=active]:bg-zl-surface data-[state=active]:text-zl-primary",
702
709
  // The label and the subtitle on the left, and the count at the right edge.
703
710
  text: "flex flex-col justify-center gap-0.5 [&>:first-child]:font-medium",
704
711
  panel: "min-h-0 flex-1 overflow-auto p-4 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-zl-primary"
@@ -840,12 +847,14 @@ export {
840
847
  Tag,
841
848
  Text,
842
849
  TextArea,
850
+ ThemeToggle,
843
851
  Toaster,
844
852
  TopNav,
845
853
  WhatsAppButton,
846
854
  ZustandProviders,
847
855
  appInitialState,
848
856
  getAuthSession,
857
+ setTheme,
849
858
  splitURLasPath,
850
859
  toast,
851
860
  useAppStore,
@@ -854,5 +863,6 @@ export {
854
863
  useIsDesktop,
855
864
  usePageStore,
856
865
  useRouterStore,
866
+ useTheme,
857
867
  useToastStore
858
868
  };
@@ -5,9 +5,10 @@ import {
5
5
  ReduxProvider,
6
6
  Text,
7
7
  ZustandProviders,
8
+ themeScript,
8
9
  usePageStore,
9
10
  useRouterStore
10
- } from "../chunk-DM4EKQGH.js";
11
+ } from "../chunk-NHCD5NHZ.js";
11
12
 
12
13
  // core/next/root-layout/root-layout.tsx
13
14
  import { Analytics } from "@vercel/analytics/next";
@@ -15,13 +16,14 @@ import { Analytics } from "@vercel/analytics/next";
15
16
  // core/next/root-layout/root-layout.styles.ts
16
17
  import { tv } from "tailwind-variants";
17
18
  var rootLayout = tv({
18
- base: "min-h-dvh"
19
+ base: "min-h-dvh bg-zl-page text-zl-text"
19
20
  });
20
21
 
21
22
  // core/next/root-layout/root-layout.tsx
22
23
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
23
24
  var RootLayout = ({ children }) => {
24
25
  return /* @__PURE__ */ jsxs(Fragment, { children: [
26
+ /* @__PURE__ */ jsx("script", { dangerouslySetInnerHTML: { __html: themeScript } }),
25
27
  /* @__PURE__ */ jsx("main", { className: rootLayout(), children }),
26
28
  /* @__PURE__ */ jsx(Analytics, { debug: false })
27
29
  ] });
package/dist/rhf/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  FormInput,
4
4
  FormProvider
5
- } from "../chunk-VW4GICIJ.js";
5
+ } from "../chunk-US6IUIXD.js";
6
6
  export {
7
7
  FormInput,
8
8
  FormProvider
@@ -2,6 +2,11 @@
2
2
  color by redefining its --color-zl-* value in its own @theme, after importing
3
3
  the styles. Only the defaults are checked for contrast.
4
4
 
5
+ Every value is a pair, light-dark(<light>, <dark>): the first is used in the
6
+ light theme and the second in the dark one. The theme itself is set in
7
+ theme.css. An app that redefines a color with a single value gets that value
8
+ in both themes, so it gives a pair too, or checks its contrast in both.
9
+
5
10
  Each color has five values, and the others follow the first unless redefined:
6
11
  --color-zl-<color> text, focus outline and tag background, at 15%
7
12
  --color-zl-<color>-strong link hover and tag text
@@ -9,66 +14,90 @@
9
14
  --color-zl-<color>-hover button hover
10
15
  --color-zl-<color>-on text on the background
11
16
 
17
+ -strong and -hover move away from the page: darker in the light theme,
18
+ lighter in the dark one.
19
+
12
20
  The auxiliary colors (orange, pink, purple) have no meaning of their own. Tag
13
21
  is their only user, so they have two values:
14
22
  --color-zl-<color> tag background, at 15%
15
23
  --color-zl-<color>-strong tag text
16
24
 
25
+ The neutral colors are the page and what sits on it. They have no -strong,
26
+ -bg, -hover or -on of the kind above:
27
+ --color-zl-page the page, behind everything, and a tab at rest
28
+ --color-zl-surface what sits on the page: card, modal, field
29
+ --color-zl-surface-muted a surface that recedes: disabled field, neutral button
30
+ --color-zl-surface-hover hover of the neutral button
31
+ --color-zl-border a line between surfaces
32
+ --color-zl-border-strong the border of a field, which needs 3:1
33
+ --color-zl-text text
34
+ --color-zl-text-soft a label or a description
35
+
17
36
  Prettier is off for this block to keep one value per line. */
18
37
 
19
38
  /* prettier-ignore */
20
39
  @theme {
21
40
  /* Primary */
22
- --color-zl-primary: var(--color-blue-600);
23
- --color-zl-primary-strong: color-mix(in oklab, var(--color-zl-primary), black 30%);
41
+ --color-zl-primary: light-dark(var(--color-blue-600), var(--color-blue-400));
42
+ --color-zl-primary-strong: color-mix(in oklab, var(--color-zl-primary), light-dark(black, white) 30%);
24
43
  --color-zl-primary-bg: var(--color-zl-primary);
25
- --color-zl-primary-hover: color-mix(in oklab, var(--color-zl-primary-bg), black 15%);
26
- --color-zl-primary-on: var(--color-white);
44
+ --color-zl-primary-hover: color-mix(in oklab, var(--color-zl-primary-bg), light-dark(black, white) 15%);
45
+ --color-zl-primary-on: light-dark(var(--color-white), var(--color-neutral-950));
27
46
 
28
47
  /* Success */
29
- --color-zl-success: var(--color-green-700);
30
- --color-zl-success-strong: color-mix(in oklab, var(--color-zl-success), black 30%);
48
+ --color-zl-success: light-dark(var(--color-green-700), var(--color-green-400));
49
+ --color-zl-success-strong: color-mix(in oklab, var(--color-zl-success), light-dark(black, white) 30%);
31
50
  --color-zl-success-bg: var(--color-zl-success);
32
- --color-zl-success-hover: color-mix(in oklab, var(--color-zl-success-bg), black 15%);
33
- --color-zl-success-on: var(--color-white);
51
+ --color-zl-success-hover: color-mix(in oklab, var(--color-zl-success-bg), light-dark(black, white) 15%);
52
+ --color-zl-success-on: light-dark(var(--color-white), var(--color-neutral-950));
34
53
 
35
54
  /* Danger */
36
- --color-zl-danger: var(--color-red-600);
37
- --color-zl-danger-strong: color-mix(in oklab, var(--color-zl-danger), black 30%);
55
+ --color-zl-danger: light-dark(var(--color-red-600), var(--color-red-400));
56
+ --color-zl-danger-strong: color-mix(in oklab, var(--color-zl-danger), light-dark(black, white) 30%);
38
57
  --color-zl-danger-bg: var(--color-zl-danger);
39
- --color-zl-danger-hover: color-mix(in oklab, var(--color-zl-danger-bg), black 15%);
40
- --color-zl-danger-on: var(--color-white);
58
+ --color-zl-danger-hover: color-mix(in oklab, var(--color-zl-danger-bg), light-dark(black, white) 15%);
59
+ --color-zl-danger-on: light-dark(var(--color-white), var(--color-neutral-950));
41
60
 
42
61
  /* Warning */
43
- --color-zl-warning: var(--color-yellow-700);
44
- --color-zl-warning-strong: color-mix(in oklab, var(--color-zl-warning), black 30%);
62
+ --color-zl-warning: light-dark(var(--color-yellow-700), var(--color-yellow-400));
63
+ --color-zl-warning-strong: color-mix(in oklab, var(--color-zl-warning), light-dark(black, white) 30%);
45
64
  --color-zl-warning-bg: var(--color-yellow-500);
46
- --color-zl-warning-hover: color-mix(in oklab, var(--color-zl-warning-bg), black 15%);
65
+ --color-zl-warning-hover: color-mix(in oklab, var(--color-zl-warning-bg), light-dark(black, white) 15%);
47
66
  --color-zl-warning-on: var(--color-gray-900);
48
67
 
49
68
  /* Info */
50
- --color-zl-info: var(--color-cyan-700);
51
- --color-zl-info-strong: color-mix(in oklab, var(--color-zl-info), black 30%);
69
+ --color-zl-info: light-dark(var(--color-cyan-700), var(--color-cyan-400));
70
+ --color-zl-info-strong: color-mix(in oklab, var(--color-zl-info), light-dark(black, white) 30%);
52
71
  --color-zl-info-bg: var(--color-zl-info);
53
- --color-zl-info-hover: color-mix(in oklab, var(--color-zl-info-bg), black 15%);
54
- --color-zl-info-on: var(--color-white);
72
+ --color-zl-info-hover: color-mix(in oklab, var(--color-zl-info-bg), light-dark(black, white) 15%);
73
+ --color-zl-info-on: light-dark(var(--color-white), var(--color-neutral-950));
55
74
 
56
75
  /* Muted */
57
- --color-zl-muted: var(--color-gray-500);
58
- --color-zl-muted-strong: color-mix(in oklab, var(--color-zl-muted), black 30%);
76
+ --color-zl-muted: light-dark(var(--color-gray-500), var(--color-gray-400));
77
+ --color-zl-muted-strong: color-mix(in oklab, var(--color-zl-muted), light-dark(black, white) 30%);
59
78
  --color-zl-muted-bg: var(--color-zl-muted);
60
- --color-zl-muted-hover: color-mix(in oklab, var(--color-zl-muted-bg), black 15%);
61
- --color-zl-muted-on: var(--color-white);
79
+ --color-zl-muted-hover: color-mix(in oklab, var(--color-zl-muted-bg), light-dark(black, white) 15%);
80
+ --color-zl-muted-on: light-dark(var(--color-white), var(--color-neutral-950));
62
81
 
63
82
  /* Orange */
64
- --color-zl-orange: var(--color-orange-700);
65
- --color-zl-orange-strong: color-mix(in oklab, var(--color-zl-orange), black 30%);
83
+ --color-zl-orange: light-dark(var(--color-orange-700), var(--color-orange-400));
84
+ --color-zl-orange-strong: color-mix(in oklab, var(--color-zl-orange), light-dark(black, white) 30%);
66
85
 
67
86
  /* Pink */
68
- --color-zl-pink: var(--color-pink-700);
69
- --color-zl-pink-strong: color-mix(in oklab, var(--color-zl-pink), black 30%);
87
+ --color-zl-pink: light-dark(var(--color-pink-700), var(--color-pink-400));
88
+ --color-zl-pink-strong: color-mix(in oklab, var(--color-zl-pink), light-dark(black, white) 30%);
70
89
 
71
90
  /* Purple */
72
- --color-zl-purple: var(--color-purple-700);
73
- --color-zl-purple-strong: color-mix(in oklab, var(--color-zl-purple), black 30%);
91
+ --color-zl-purple: light-dark(var(--color-purple-700), var(--color-purple-400));
92
+ --color-zl-purple-strong: color-mix(in oklab, var(--color-zl-purple), light-dark(black, white) 30%);
93
+
94
+ /* Neutral */
95
+ --color-zl-page: light-dark(var(--color-gray-50), var(--color-neutral-950));
96
+ --color-zl-surface: light-dark(var(--color-white), var(--color-neutral-900));
97
+ --color-zl-surface-muted: light-dark(var(--color-gray-100), var(--color-neutral-800));
98
+ --color-zl-surface-hover: light-dark(var(--color-gray-200), var(--color-neutral-700));
99
+ --color-zl-border: light-dark(var(--color-gray-200), var(--color-neutral-700));
100
+ --color-zl-border-strong: light-dark(var(--color-gray-500), var(--color-neutral-400));
101
+ --color-zl-text: light-dark(var(--color-gray-900), var(--color-neutral-100));
102
+ --color-zl-text-soft: light-dark(var(--color-gray-700), var(--color-neutral-300));
74
103
  }
@@ -1,4 +1,5 @@
1
- /* Global Scrollbar */
1
+ /* Global Scrollbar. The thumb uses the theme values, so it shows on a light
2
+ and on a dark page. */
2
3
  ::-webkit-scrollbar {
3
4
  width: 4px;
4
5
  }
@@ -8,10 +9,18 @@
8
9
  }
9
10
 
10
11
  ::-webkit-scrollbar-thumb {
11
- background-color: rgba(228, 231, 234, 0.5);
12
+ background-color: color-mix(
13
+ in oklab,
14
+ var(--color-zl-border-strong) 35%,
15
+ transparent
16
+ );
12
17
  border-radius: 2px;
13
18
  }
14
19
 
15
20
  ::-webkit-scrollbar-thumb:hover {
16
- background-color: rgba(156, 163, 175, 0.75);
21
+ background-color: color-mix(
22
+ in oklab,
23
+ var(--color-zl-border-strong) 75%,
24
+ transparent
25
+ );
17
26
  }
@@ -0,0 +1,17 @@
1
+ /* The theme: light, dark, or the one of the system. Every color in colors.css
2
+ is a light-dark() pair, and `color-scheme` picks the side. With no choice
3
+ made, the page follows the system. The choice of the user is applied by
4
+ `useTheme`, in a <style id="zljs-theme"> that sets `color-scheme` on
5
+ :root:root, so it beats this rule and one of the app.
6
+
7
+ An app whose own pages aren't ready for the dark theme sets
8
+ `:root { color-scheme: light; }` after importing the styles: the system
9
+ theme is then always the light one, and the user can still choose the dark.
10
+
11
+ `color-scheme` also turns the scrollbars and the native fields of the
12
+ browser, and the page behind the app when nothing paints it. */
13
+ @layer base {
14
+ :root {
15
+ color-scheme: light dark;
16
+ }
17
+ }
package/dist/styles.css CHANGED
@@ -1,4 +1,5 @@
1
1
  @import "./styles/colors.css";
2
+ @import "./styles/theme.css";
2
3
  @import "./styles/scrollbar.css";
3
4
  @import "./styles/ag-grid.css";
4
5
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alexandregme/zljs",
3
- "version": "3.21.0",
3
+ "version": "3.23.0",
4
4
  "description": "Opinionated, accessible React component library for enterprise apps (Next.js, Tailwind CSS v4).",
5
5
  "keywords": [
6
6
  "react",