@hexdspace/react 0.1.55 → 0.1.57

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.d.ts CHANGED
@@ -989,6 +989,27 @@ type UseVimRegionResult = {
989
989
  };
990
990
  declare function useVimRegion(containerRef: React__default.RefObject<HTMLElement | null>, args: UseVimRegionArgs): UseVimRegionResult;
991
991
 
992
+ type Theme = 'light' | 'dark' | 'system';
993
+
994
+ interface WatchSystemTheme {
995
+ execute(onChange: (theme: Exclude<Theme, 'system'>) => void): () => void;
996
+ }
997
+
998
+ interface SetDocumentTheme {
999
+ execute(theme: Theme): void;
1000
+ }
1001
+
1002
+ declare class ThemeController {
1003
+ private readonly setDocumentTheme;
1004
+ private readonly watchSystemThemeUpdate;
1005
+ constructor(setDocumentTheme: SetDocumentTheme, watchSystemThemeUpdate: WatchSystemTheme);
1006
+ handleNewTheme(theme: Theme): void;
1007
+ handleSystemThemeUpdated(onChange: (theme: Exclude<Theme, 'system'>) => void): () => void;
1008
+ }
1009
+ declare const themeController: ThemeController;
1010
+
1011
+ declare function useIsDark(): boolean;
1012
+
992
1013
  declare const dialogSurfaceVariants: (props?: ({
993
1014
  chrome?: "flat" | "glass" | "glow" | "hairline" | null | undefined;
994
1015
  } & class_variance_authority_types.ClassProp) | undefined) => string;
@@ -1162,4 +1183,4 @@ declare const Kbd: React.ForwardRefExoticComponent<KbdProps & React.RefAttribute
1162
1183
 
1163
1184
  declare function useMotionDuration(varName: string, fallbackSeconds: number): number;
1164
1185
 
1165
- export { AuthController, AuthControllerCtx, type AuthControllerDeps, AuthControllerProvider, AuthDispatchCtx, AuthProvider, type AuthState, AuthStateCtx, Button, type ButtonProps, type CacheInstruction, type ClearSelectionArgs, type ClearTarget, type CombineMode, ConfirmDialog, type ConfirmDialogProps, type ConfirmPayload, type CursorFallback, CustomDialog, type CustomDialogPayload, type CustomDialogProps, type CustomInstruction, DEFAULT_NOTIFICATION_CHANNEL, type DefaultDialogPayloads, type DefaultDialogTemplateKey, DefaultDialogTemplateKeys, Dialog, DialogContent, DialogController, DialogHost, type DialogInstance, type DialogOptions, type DialogProps, type DialogTemplate, type DisableScope, DisableScopeUseCase, DropdownMenu, DropdownMenuItem, type DropdownMenuItemProps, type DropdownMenuProps, DropdownMenuSeparator, type EnableScope, EnableScopeUseCase, type ErrorResponse, Field, type FieldProps, type GenericResponse, type GroupedShortcuts, type HandleSelection, type HttpClient, HttpError, type HttpMethod, type HttpResponse, InMemorySelectionStore, InfoDialog, type InfoDialogProps, type InfoPayload, Input, type InputProps, type Instruction, type InstructionContext, type ItemId, Kbd, type KbdProps, KeyboardController, KeyboardProvider, type ListShortcuts, ListShortcutsUseCase, type ListedShortcut, MockAuthHttpClient, MockHttpClient, type Mode, type MutationFn, type Notification, type NotificationAction, NotificationHost, type NotificationInstruction, type NotificationVariant, NotifierController, type OnSuccessFn, type OptimisticSnapshot, type OptimisticUpdateFn, Popover, type PopoverProps, type QuerySelection, RedirectIfAuthed, type RedirectIfAuthedProps, type RegionId, type RegionKey, type RegionSelection, type RegisterRegionArgs, type RegisterShortcut, RegisterShortcutUseCase, type RequestConfig, RequireAuth, type RequireAuthProps, type ResolvedToastTheme, type ResponsiveMutation, type ScopeId, ScopeManager, type ScopeState, SelectionController, type SelectionControllerDeps, SelectionControllerProvider, type SelectionState, type SelectionStore, type ShortcutBinding, type ShortcutHandler, type ShortcutRegistration, type ShortcutScope, Skeleton, type SkeletonProps, Textarea, type TextareaProps, type ToastActionTheme, type ToastTheme, type ToastTransition, type ToastifyCSSVars, Tooltip, type UIFail, type UIOk, type UIResult, type UnregisterShortcut, UnregisterShortcutUseCase, type UseVimRegionArgs, type UseVimRegionResult, type User, VimController, type VimControllerDeps, VimControllerProvider, type VimDirection, type VimInterDirection, type VimKeyState, type VimModifierMovementAction, type VimModifierMovementActionArgs, type VimModifierMovementActions, type VimMovementModifier, type VimPending, type VimRegionMeta, VimRegionRegistry, authController, controllerFactory, createAuthController, createSelectionController, createVimController, dialogController, httpClient as fetchHttpClient, getDialogTemplate, keyboardController, notifierController, registerDefaultDialogs, registerDialogTemplate, resolveToastTheme, ui, unregisterDialogTemplate, useAuth, useAuthActions, useAuthController, useAuthDispatch, useAuthedUser, useDialog, useKeyboardController, useMotionDuration, useResponsiveMutation, useSelectionController, useShortcut, useShortcutScope, useVimBindings, useVimController, useVimRegion };
1186
+ export { AuthController, AuthControllerCtx, type AuthControllerDeps, AuthControllerProvider, AuthDispatchCtx, AuthProvider, type AuthState, AuthStateCtx, Button, type ButtonProps, type CacheInstruction, type ClearSelectionArgs, type ClearTarget, type CombineMode, ConfirmDialog, type ConfirmDialogProps, type ConfirmPayload, type CursorFallback, CustomDialog, type CustomDialogPayload, type CustomDialogProps, type CustomInstruction, DEFAULT_NOTIFICATION_CHANNEL, type DefaultDialogPayloads, type DefaultDialogTemplateKey, DefaultDialogTemplateKeys, Dialog, DialogContent, DialogController, DialogHost, type DialogInstance, type DialogOptions, type DialogProps, type DialogTemplate, type DisableScope, DisableScopeUseCase, DropdownMenu, DropdownMenuItem, type DropdownMenuItemProps, type DropdownMenuProps, DropdownMenuSeparator, type EnableScope, EnableScopeUseCase, type ErrorResponse, Field, type FieldProps, type GenericResponse, type GroupedShortcuts, type HandleSelection, type HttpClient, HttpError, type HttpMethod, type HttpResponse, InMemorySelectionStore, InfoDialog, type InfoDialogProps, type InfoPayload, Input, type InputProps, type Instruction, type InstructionContext, type ItemId, Kbd, type KbdProps, KeyboardController, KeyboardProvider, type ListShortcuts, ListShortcutsUseCase, type ListedShortcut, MockAuthHttpClient, MockHttpClient, type Mode, type MutationFn, type Notification, type NotificationAction, NotificationHost, type NotificationInstruction, type NotificationVariant, NotifierController, type OnSuccessFn, type OptimisticSnapshot, type OptimisticUpdateFn, Popover, type PopoverProps, type QuerySelection, RedirectIfAuthed, type RedirectIfAuthedProps, type RegionId, type RegionKey, type RegionSelection, type RegisterRegionArgs, type RegisterShortcut, RegisterShortcutUseCase, type RequestConfig, RequireAuth, type RequireAuthProps, type ResolvedToastTheme, type ResponsiveMutation, type ScopeId, ScopeManager, type ScopeState, SelectionController, type SelectionControllerDeps, SelectionControllerProvider, type SelectionState, type SelectionStore, type SetDocumentTheme, type ShortcutBinding, type ShortcutHandler, type ShortcutRegistration, type ShortcutScope, Skeleton, type SkeletonProps, Textarea, type TextareaProps, type Theme, ThemeController, type ToastActionTheme, type ToastTheme, type ToastTransition, type ToastifyCSSVars, Tooltip, type UIFail, type UIOk, type UIResult, type UnregisterShortcut, UnregisterShortcutUseCase, type UseVimRegionArgs, type UseVimRegionResult, type User, VimController, type VimControllerDeps, VimControllerProvider, type VimDirection, type VimInterDirection, type VimKeyState, type VimModifierMovementAction, type VimModifierMovementActionArgs, type VimModifierMovementActions, type VimMovementModifier, type VimPending, type VimRegionMeta, VimRegionRegistry, type WatchSystemTheme, authController, controllerFactory, createAuthController, createSelectionController, createVimController, dialogController, httpClient as fetchHttpClient, getDialogTemplate, keyboardController, notifierController, registerDefaultDialogs, registerDialogTemplate, resolveToastTheme, themeController, ui, unregisterDialogTemplate, useAuth, useAuthActions, useAuthController, useAuthDispatch, useAuthedUser, useDialog, useIsDark, useKeyboardController, useMotionDuration, useResponsiveMutation, useSelectionController, useShortcut, useShortcutScope, useVimBindings, useVimController, useVimRegion };
package/dist/index.js CHANGED
@@ -3684,8 +3684,7 @@ function getScopeEntry(keyboardScopeId) {
3684
3684
  const entry = {
3685
3685
  ownerId: null,
3686
3686
  subscribers: /* @__PURE__ */ new Map(),
3687
- modifierActionsByOwner: /* @__PURE__ */ new Map(),
3688
- modifierActionsVersion: 0
3687
+ modifierActionsByOwner: /* @__PURE__ */ new Map()
3689
3688
  };
3690
3689
  scopeBindings.set(keyboardScopeId, entry);
3691
3690
  return entry;
@@ -3697,10 +3696,8 @@ function useVimBindings(regionKey, keyboardScopeId, options = {}) {
3697
3696
  const modifierMovementActions = options.modifierMovementActions;
3698
3697
  const ownerIdRef = useRef3(Symbol("vim-binding-owner"));
3699
3698
  const [isOwner, setIsOwner] = useState5(false);
3700
- const [modifierActionsVersion, setModifierActionsVersion] = useState5(0);
3701
3699
  const handleEntryChange = useCallback5((entry) => {
3702
3700
  setIsOwner(entry.ownerId === ownerIdRef.current);
3703
- setModifierActionsVersion(entry.modifierActionsVersion);
3704
3701
  }, []);
3705
3702
  const blockWhileTyping = useCallback5(
3706
3703
  (e) => allowArrowKeys && e.key.startsWith("Arrow"),
@@ -3740,13 +3737,11 @@ function useVimBindings(regionKey, keyboardScopeId, options = {}) {
3740
3737
  }
3741
3738
  const entry = getScopeEntry(keyboardScopeId);
3742
3739
  entry.modifierActionsByOwner.set(ownerIdRef.current, modifierMovementActions ?? null);
3743
- entry.modifierActionsVersion += 1;
3744
3740
  notify(entry);
3745
3741
  return () => {
3746
3742
  const existing = scopeBindings.get(keyboardScopeId);
3747
3743
  if (!existing) return;
3748
3744
  existing.modifierActionsByOwner.delete(ownerIdRef.current);
3749
- existing.modifierActionsVersion += 1;
3750
3745
  if (!existing.ownerId && existing.subscribers.size === 0 && existing.modifierActionsByOwner.size === 0) {
3751
3746
  scopeBindings.delete(keyboardScopeId);
3752
3747
  return;
@@ -3860,7 +3855,7 @@ function useVimBindings(regionKey, keyboardScopeId, options = {}) {
3860
3855
  ...modifierBindings("shift", modifierAvailability?.shift),
3861
3856
  ...modifierBindings("ctrlShift", modifierAvailability?.ctrlShift)
3862
3857
  ];
3863
- }, [allowArrowKeys, enabled, isOwner, keyboardScopeId, modifierActionsVersion, vim]);
3858
+ }, [allowArrowKeys, enabled, isOwner, keyboardScopeId, vim]);
3864
3859
  useShortcut(keyboardScopeId, bindings, {
3865
3860
  ignoreTyping: true,
3866
3861
  preventDefault: true,
@@ -4053,6 +4048,77 @@ function useVimRegion(containerRef, args) {
4053
4048
  };
4054
4049
  }
4055
4050
 
4051
+ // src/feature/theme-select/application/use-case/set-document-theme-use-case.ts
4052
+ var SetDocumentThemeUseCase = class {
4053
+ execute(next) {
4054
+ const prefersDark = window.matchMedia("(prefers-color-scheme: dark)").matches;
4055
+ const effective = next === "system" ? prefersDark ? "dark" : "light" : next;
4056
+ const root = document.documentElement;
4057
+ root.classList.add("theme-switching");
4058
+ root.classList.toggle("dark", effective === "dark");
4059
+ root.setAttribute("data-theme", effective);
4060
+ window.setTimeout(() => root.classList.remove("theme-switching"), 0);
4061
+ localStorage.setItem("theme", next);
4062
+ }
4063
+ };
4064
+
4065
+ // src/feature/theme-select/application/use-case/watch-system-theme-use-case.ts
4066
+ var WatchSystemThemeUseCase = class {
4067
+ execute(onChange) {
4068
+ const mql = window.matchMedia("(prefers-color-scheme: dark)");
4069
+ const emit = () => onChange(mql.matches ? "dark" : "light");
4070
+ const shouldReact = () => {
4071
+ try {
4072
+ return localStorage.getItem("theme") === "system";
4073
+ } catch {
4074
+ return true;
4075
+ }
4076
+ };
4077
+ const handler = () => {
4078
+ if (shouldReact()) emit();
4079
+ };
4080
+ if (shouldReact()) emit();
4081
+ mql.addEventListener("change", handler);
4082
+ return () => mql.removeEventListener("change", handler);
4083
+ }
4084
+ };
4085
+
4086
+ // src/feature/theme-select/interface/controller/theme-controller.ts
4087
+ var ThemeController = class {
4088
+ constructor(setDocumentTheme, watchSystemThemeUpdate) {
4089
+ this.setDocumentTheme = setDocumentTheme;
4090
+ this.watchSystemThemeUpdate = watchSystemThemeUpdate;
4091
+ }
4092
+ handleNewTheme(theme) {
4093
+ return this.setDocumentTheme.execute(theme);
4094
+ }
4095
+ handleSystemThemeUpdated(onChange) {
4096
+ return this.watchSystemThemeUpdate.execute(onChange);
4097
+ }
4098
+ };
4099
+ var themeController = new ThemeController(new SetDocumentThemeUseCase(), new WatchSystemThemeUseCase());
4100
+
4101
+ // src/feature/theme-select/interface/web/react/hook/use-is-dark.ts
4102
+ import { useEffect as useEffect10, useState as useState6 } from "react";
4103
+ function useIsDark() {
4104
+ const [isDark, setIsDark] = useState6(() => {
4105
+ if (typeof document === "undefined") return false;
4106
+ return document.documentElement.classList.contains("dark");
4107
+ });
4108
+ useEffect10(() => {
4109
+ if (typeof document === "undefined") return;
4110
+ const el = document.documentElement;
4111
+ const observer = new MutationObserver(() => {
4112
+ setIsDark(el.classList.contains("dark"));
4113
+ });
4114
+ observer.observe(el, { attributes: true, attributeFilter: ["class"] });
4115
+ return () => {
4116
+ observer.disconnect();
4117
+ };
4118
+ }, []);
4119
+ return isDark;
4120
+ }
4121
+
4056
4122
  // src/ui/components/Field.tsx
4057
4123
  import * as React6 from "react";
4058
4124
 
@@ -4442,7 +4508,7 @@ import { Tooltip as TooltipPrimitive } from "radix-ui";
4442
4508
  import * as React10 from "react";
4443
4509
  import { jsx as jsx20, jsxs as jsxs9 } from "react/jsx-runtime";
4444
4510
  var tooltipContentBase = cn(
4445
- "panel shadow-none px-4 py-2.5 text-xs z-5000 select-none",
4511
+ "panel border border-surface-1 shadow-none px-4 py-2.5 text-xs z-5000 select-none",
4446
4512
  "origin-center",
4447
4513
  "[--tooltip-x:0px] [--tooltip-y:4px]",
4448
4514
  "data-[side=bottom]:[--tooltip-y:-4px]",
@@ -4490,7 +4556,13 @@ function Tooltip({
4490
4556
  },
4491
4557
  children: [
4492
4558
  content,
4493
- /* @__PURE__ */ jsx20(TooltipPrimitive.Arrow, { style: { fill: "var(--surface-2)" } })
4559
+ /* @__PURE__ */ jsx20(
4560
+ TooltipPrimitive.Arrow,
4561
+ {
4562
+ className: "fill-(--surface-2) stroke-(--surface-1)",
4563
+ style: { strokeWidth: 1 }
4564
+ }
4565
+ )
4494
4566
  ]
4495
4567
  }
4496
4568
  ) }) }) : null })
@@ -5067,6 +5139,7 @@ export {
5067
5139
  SelectionControllerProvider,
5068
5140
  Skeleton,
5069
5141
  Textarea,
5142
+ ThemeController,
5070
5143
  Tooltip,
5071
5144
  UnregisterShortcutUseCase,
5072
5145
  VimController,
@@ -5085,6 +5158,7 @@ export {
5085
5158
  registerDefaultDialogs,
5086
5159
  registerDialogTemplate,
5087
5160
  resolveToastTheme,
5161
+ themeController,
5088
5162
  ui,
5089
5163
  unregisterDialogTemplate,
5090
5164
  useAuth,
@@ -5093,6 +5167,7 @@ export {
5093
5167
  useAuthDispatch,
5094
5168
  useAuthedUser,
5095
5169
  useDialog,
5170
+ useIsDark,
5096
5171
  useKeyboardController,
5097
5172
  useMotionDuration,
5098
5173
  useResponsiveMutation,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hexdspace/react",
3
- "version": "0.1.55",
3
+ "version": "0.1.57",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",