@arcanewizards/sigil 0.1.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.
Files changed (66) hide show
  1. package/dist/chunk-4PMRDURG.js +66 -0
  2. package/dist/chunk-5DRI7C4U.cjs +66 -0
  3. package/dist/chunk-A5LYYZER.cjs +103 -0
  4. package/dist/chunk-BIY5HAXP.js +125 -0
  5. package/dist/chunk-CAYKPJIX.cjs +10 -0
  6. package/dist/chunk-EJNNLQ2S.js +72 -0
  7. package/dist/chunk-FHXT3DAL.js +103 -0
  8. package/dist/chunk-H4U4Z4GM.js +66 -0
  9. package/dist/chunk-LSHKAVON.js +10 -0
  10. package/dist/chunk-MXDDIFIO.cjs +767 -0
  11. package/dist/chunk-PEARNJ5G.cjs +125 -0
  12. package/dist/chunk-RI33QVOD.cjs +66 -0
  13. package/dist/chunk-VZ4A6RRT.cjs +72 -0
  14. package/dist/chunk-XAK7WC3D.js +767 -0
  15. package/dist/frontend/appearance.cjs +88 -0
  16. package/dist/frontend/appearance.d.cts +11 -0
  17. package/dist/frontend/appearance.d.ts +11 -0
  18. package/dist/frontend/appearance.js +88 -0
  19. package/dist/frontend/context.cjs +16 -0
  20. package/dist/frontend/context.d.cts +32 -0
  21. package/dist/frontend/context.d.ts +32 -0
  22. package/dist/frontend/context.js +16 -0
  23. package/dist/frontend/controls/index.cjs +49 -0
  24. package/dist/frontend/controls/index.d.cts +168 -0
  25. package/dist/frontend/controls/index.d.ts +168 -0
  26. package/dist/frontend/controls/index.js +49 -0
  27. package/dist/frontend/dialogs.cjs +17 -0
  28. package/dist/frontend/dialogs.d.cts +36 -0
  29. package/dist/frontend/dialogs.d.ts +36 -0
  30. package/dist/frontend/dialogs.js +17 -0
  31. package/dist/frontend/input.cjs +8 -0
  32. package/dist/frontend/input.d.cts +33 -0
  33. package/dist/frontend/input.d.ts +33 -0
  34. package/dist/frontend/input.js +8 -0
  35. package/dist/frontend/preferences.cjs +54 -0
  36. package/dist/frontend/preferences.d.cts +14 -0
  37. package/dist/frontend/preferences.d.ts +14 -0
  38. package/dist/frontend/preferences.js +54 -0
  39. package/dist/frontend/styles/base.css +321 -0
  40. package/dist/frontend/styles/sigil.css +785 -0
  41. package/dist/frontend/styles/theme.css +625 -0
  42. package/dist/frontend/styling.cjs +18 -0
  43. package/dist/frontend/styling.d.cts +32 -0
  44. package/dist/frontend/styling.d.ts +32 -0
  45. package/dist/frontend/styling.js +18 -0
  46. package/dist/frontend/toolbars.cjs +18 -0
  47. package/dist/frontend/toolbars.d.cts +11 -0
  48. package/dist/frontend/toolbars.d.ts +11 -0
  49. package/dist/frontend/toolbars.js +18 -0
  50. package/dist/frontend/tooltip.cjs +10 -0
  51. package/dist/frontend/tooltip.d.cts +16 -0
  52. package/dist/frontend/tooltip.d.ts +16 -0
  53. package/dist/frontend/tooltip.js +10 -0
  54. package/dist/frontend.cjs +359 -0
  55. package/dist/frontend.d.cts +90 -0
  56. package/dist/frontend.d.ts +90 -0
  57. package/dist/frontend.js +359 -0
  58. package/dist/index.cjs +492 -0
  59. package/dist/index.d.cts +134 -0
  60. package/dist/index.d.ts +134 -0
  61. package/dist/index.js +492 -0
  62. package/dist/proto-B-WcMUOE.d.cts +33 -0
  63. package/dist/proto-kGDF-yWB.d.ts +33 -0
  64. package/dist/types-X8O95zmC.d.cts +23 -0
  65. package/dist/types-X8O95zmC.d.ts +23 -0
  66. package/package.json +123 -0
@@ -0,0 +1,168 @@
1
+ import * as react from 'react';
2
+ import { ComponentPropsWithoutRef, ReactNode, CSSProperties, FC, ComponentProps, InputHTMLAttributes, MutableRefObject } from 'react';
3
+ import { TooltipProps } from '../tooltip.js';
4
+ import { PressableOnClickListener } from '../input.js';
5
+ import { DialogProps } from '../dialogs.js';
6
+ import * as react_jsx_runtime from 'react/jsx-runtime';
7
+ import { SigilColor } from '../styling.js';
8
+ import 'zod';
9
+
10
+ type ControlPosition = 'row' | 'label' | 'first' | 'second' | 'both' | 'all' | 'extra';
11
+ declare const clsControlPosition: (position?: ControlPosition) => "control-grid-pos-row" | "control-grid-pos-label" | "control-grid-pos-first" | "control-grid-pos-second" | "control-grid-pos-both" | "control-grid-pos-all" | "control-grid-pos-extra" | undefined;
12
+ declare const clsControlSubgridPosition: (position: ControlPosition, subgrid?: boolean) => "col-[1/span_1]" | "col-[2/span_1]" | "col-[3/span_1]" | undefined;
13
+ declare const controlPositionClass: (position?: ControlPosition) => "control-grid-pos-row" | "control-grid-pos-label" | "control-grid-pos-first" | "control-grid-pos-second" | "control-grid-pos-both" | "control-grid-pos-all" | "control-grid-pos-extra" | undefined;
14
+
15
+ declare const CONTROL_BUTTON_VAR_SUFFIX: {
16
+ readonly bg: "bg";
17
+ readonly bgHover: "bg-hover";
18
+ readonly bgActive: "bg-active";
19
+ readonly fg: "fg";
20
+ readonly fgHover: "fg-hover";
21
+ readonly fgActive: "fg-active";
22
+ readonly border: "border";
23
+ readonly borderHover: "border-hover";
24
+ readonly borderActive: "border-active";
25
+ };
26
+ declare const controlButtonColorVariable: (property: keyof typeof CONTROL_BUTTON_VAR_SUFFIX) => string;
27
+ declare const controlButtonColorVariables: (usage: Record<keyof typeof CONTROL_BUTTON_VAR_SUFFIX, string>) => CSSProperties;
28
+ type ControlButtonVariant = 'standard' | 'border' | 'large' | 'table-row' | 'toolbar' | 'titlebar' | 'properties';
29
+ type ControlButtonProps = Omit<ComponentPropsWithoutRef<'button'>, 'children' | 'onClick' | 'title'> & {
30
+ onClick: PressableOnClickListener;
31
+ variant: ControlButtonVariant;
32
+ active?: boolean;
33
+ title?: ReactNode;
34
+ tooltipSide?: TooltipProps['side'];
35
+ position?: ControlPosition;
36
+ } & ({
37
+ children: ReactNode;
38
+ icon?: string;
39
+ } | {
40
+ children?: undefined;
41
+ icon: string;
42
+ });
43
+ type ControlButtonFrameProps = Omit<ComponentPropsWithoutRef<'button'>, 'children' | 'title'> & {
44
+ children?: ReactNode;
45
+ icon?: string;
46
+ variant?: ControlButtonVariant;
47
+ active?: boolean;
48
+ touching?: boolean;
49
+ title?: ReactNode;
50
+ tooltipSide?: TooltipProps['side'];
51
+ position?: ControlPosition;
52
+ };
53
+ declare const clsControlButton: ({ variant, active, touching, position, className, }: Pick<ControlButtonFrameProps, "variant" | "active" | "touching" | "position" | "className">) => string;
54
+ declare const ControlButton: react.ForwardRefExoticComponent<ControlButtonProps & react.RefAttributes<HTMLButtonElement>>;
55
+ type CheckboxControlButtonProps = Omit<ControlButtonProps, 'children' | 'icon'> & {
56
+ label?: string;
57
+ };
58
+ declare const CheckboxControlButton: react.ForwardRefExoticComponent<Omit<ControlButtonProps, "children" | "icon"> & {
59
+ label?: string;
60
+ } & react.RefAttributes<HTMLButtonElement>>;
61
+ type LongPressableControlButtonProps = Omit<ControlButtonFrameProps, 'icon' | 'onClick' | 'touching'> & {
62
+ children: ReactNode;
63
+ onPress: () => void;
64
+ onRelease: () => void;
65
+ };
66
+ declare const LongPressableControlButton: react.ForwardRefExoticComponent<Omit<ControlButtonFrameProps, "onClick" | "touching" | "icon"> & {
67
+ children: ReactNode;
68
+ onPress: () => void;
69
+ onRelease: () => void;
70
+ } & react.RefAttributes<HTMLButtonElement>>;
71
+ type ControlButtonGroupProps = ComponentPropsWithoutRef<'div'> & {
72
+ position?: ControlPosition;
73
+ };
74
+ declare const ControlButtonGroup: react.ForwardRefExoticComponent<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
75
+ position?: ControlPosition;
76
+ } & react.RefAttributes<HTMLDivElement>>;
77
+
78
+ type ControlParagraphMode = 'error' | 'success' | 'warning';
79
+ type ControlParagraphProps = ComponentPropsWithoutRef<'p'> & {
80
+ position?: ControlPosition;
81
+ mode?: ControlParagraphMode;
82
+ };
83
+ declare const ControlParagraph: react.ForwardRefExoticComponent<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>, "ref"> & {
84
+ position?: ControlPosition;
85
+ mode?: ControlParagraphMode;
86
+ } & react.RefAttributes<HTMLParagraphElement>>;
87
+ type ControlLabelProps = ComponentPropsWithoutRef<'div'> & {
88
+ subgrid?: boolean;
89
+ position?: ControlPosition;
90
+ disabled?: boolean;
91
+ nonMicro?: boolean;
92
+ };
93
+ declare const ControlLabel: react.ForwardRefExoticComponent<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
94
+ subgrid?: boolean;
95
+ position?: ControlPosition;
96
+ disabled?: boolean;
97
+ nonMicro?: boolean;
98
+ } & react.RefAttributes<HTMLDivElement>>;
99
+ type ControlDetailsProps = ComponentPropsWithoutRef<'div'> & {
100
+ position?: ControlPosition;
101
+ align?: 'start' | 'center' | 'end';
102
+ };
103
+ declare const ControlDetails: react.ForwardRefExoticComponent<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
104
+ position?: ControlPosition;
105
+ align?: "start" | "center" | "end";
106
+ } & react.RefAttributes<HTMLDivElement>>;
107
+ type InputSpanningTitleProps = ComponentPropsWithoutRef<'div'> & {
108
+ position?: ControlPosition;
109
+ };
110
+ declare const InputSpanningTitle: react.ForwardRefExoticComponent<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
111
+ position?: ControlPosition;
112
+ } & react.RefAttributes<HTMLDivElement>>;
113
+
114
+ declare const ControlDialogButtons: react.ForwardRefExoticComponent<react.HTMLAttributes<HTMLDivElement> & react.RefAttributes<HTMLDivElement>>;
115
+ type ControlDialogProps = Omit<DialogProps, 'variant'> & {
116
+ large?: boolean;
117
+ };
118
+ declare const ControlDialog: FC<ControlDialogProps>;
119
+
120
+ type InputProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'ref' | 'onChange'> & {
121
+ value: string | null;
122
+ disabled?: boolean;
123
+ onChange: (value: string, enterPressed: boolean) => void;
124
+ inputRef?: MutableRefObject<HTMLInputElement | null>;
125
+ };
126
+ declare const InputWithDelayedPropagation: FC<InputProps>;
127
+ type ControlInputProps = ComponentProps<typeof InputWithDelayedPropagation> & {
128
+ position?: ControlPosition;
129
+ subgrid?: boolean;
130
+ nonMicro?: boolean;
131
+ };
132
+ declare const ControlInput: FC<ControlInputProps>;
133
+ type ControlPercentProps = Omit<ControlInputProps, 'className'> & {
134
+ className?: string;
135
+ };
136
+ declare const ControlPercent: FC<ControlPercentProps>;
137
+
138
+ type SelectOption<T> = {
139
+ label: string;
140
+ value: T;
141
+ /**
142
+ * Set to true to indicate that when selected,
143
+ * the select should look active.
144
+ */
145
+ active?: boolean;
146
+ };
147
+ type SelectProps<T extends string | null> = {
148
+ options: SelectOption<T>[];
149
+ value: T | '';
150
+ onChange: (value: T) => void;
151
+ triggerText?: (option: SelectOption<T>) => ReactNode;
152
+ triggerButton?: (option: null | SelectOption<T>) => ReactNode;
153
+ option?: (option: SelectOption<T>) => ReactNode;
154
+ variant: ControlButtonVariant;
155
+ position?: ControlPosition;
156
+ disabled?: boolean;
157
+ tooltip?: string;
158
+ placeholder?: ReactNode;
159
+ triggerClassName?: string;
160
+ };
161
+ declare const ControlSelect: <T extends string | null>({ options, value, onChange, triggerText, triggerButton, option, variant, position, disabled, tooltip, placeholder, triggerClassName: className, }: SelectProps<T>) => react_jsx_runtime.JSX.Element;
162
+ type ControlColorSelectProps = {
163
+ color: SigilColor | '';
164
+ onChange: (color: SigilColor) => void;
165
+ } & Pick<SelectProps<SigilColor>, 'variant' | 'position' | 'disabled' | 'tooltip' | 'placeholder'>;
166
+ declare const ControlColorSelect: ({ color, onChange, variant, position, disabled, placeholder, ...props }: ControlColorSelectProps) => react_jsx_runtime.JSX.Element;
167
+
168
+ export { CheckboxControlButton, type CheckboxControlButtonProps, ControlButton, ControlButtonGroup, type ControlButtonGroupProps, type ControlButtonProps, type ControlButtonVariant, ControlColorSelect, ControlDetails, type ControlDetailsProps, ControlDialog, ControlDialogButtons, ControlInput, type ControlInputProps, ControlLabel, type ControlLabelProps, ControlParagraph, type ControlParagraphMode, type ControlParagraphProps, ControlPercent, type ControlPercentProps, type ControlPosition, ControlSelect, InputSpanningTitle, type InputSpanningTitleProps, InputWithDelayedPropagation, LongPressableControlButton, type LongPressableControlButtonProps, type SelectOption, clsControlButton, clsControlPosition, clsControlSubgridPosition, controlButtonColorVariable, controlButtonColorVariables, controlPositionClass };
@@ -0,0 +1,49 @@
1
+ import {
2
+ CheckboxControlButton,
3
+ ControlButton,
4
+ ControlButtonGroup,
5
+ ControlColorSelect,
6
+ ControlDetails,
7
+ ControlDialog,
8
+ ControlDialogButtons,
9
+ ControlInput,
10
+ ControlLabel,
11
+ ControlParagraph,
12
+ ControlPercent,
13
+ ControlSelect,
14
+ InputSpanningTitle,
15
+ InputWithDelayedPropagation,
16
+ LongPressableControlButton,
17
+ clsControlButton,
18
+ clsControlPosition,
19
+ clsControlSubgridPosition,
20
+ controlButtonColorVariable,
21
+ controlButtonColorVariables,
22
+ controlPositionClass
23
+ } from "../../chunk-XAK7WC3D.js";
24
+ import "../../chunk-BIY5HAXP.js";
25
+ import "../../chunk-4PMRDURG.js";
26
+ import "../../chunk-H4U4Z4GM.js";
27
+ export {
28
+ CheckboxControlButton,
29
+ ControlButton,
30
+ ControlButtonGroup,
31
+ ControlColorSelect,
32
+ ControlDetails,
33
+ ControlDialog,
34
+ ControlDialogButtons,
35
+ ControlInput,
36
+ ControlLabel,
37
+ ControlParagraph,
38
+ ControlPercent,
39
+ ControlSelect,
40
+ InputSpanningTitle,
41
+ InputWithDelayedPropagation,
42
+ LongPressableControlButton,
43
+ clsControlButton,
44
+ clsControlPosition,
45
+ clsControlSubgridPosition,
46
+ controlButtonColorVariable,
47
+ controlButtonColorVariables,
48
+ controlPositionClass
49
+ };
@@ -0,0 +1,17 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+
5
+
6
+
7
+ var _chunkMXDDIFIOcjs = require('../chunk-MXDDIFIO.cjs');
8
+ require('../chunk-PEARNJ5G.cjs');
9
+ require('../chunk-RI33QVOD.cjs');
10
+ require('../chunk-5DRI7C4U.cjs');
11
+
12
+
13
+
14
+
15
+
16
+
17
+ exports.Dialog = _chunkMXDDIFIOcjs.Dialog; exports.DialogButtons = _chunkMXDDIFIOcjs.DialogButtons; exports.DialogContext = _chunkMXDDIFIOcjs.DialogContext; exports.DialogProvider = _chunkMXDDIFIOcjs.DialogProvider; exports.DialogTitle = _chunkMXDDIFIOcjs.DialogTitle;
@@ -0,0 +1,36 @@
1
+ import * as react from 'react';
2
+ import { FC, ReactNode, ComponentPropsWithoutRef } from 'react';
3
+
4
+ type DialogComponent = (close: () => void) => ReactNode;
5
+ type DialogVariant = 'dark' | 'light' | 'light-compact' | 'dark-compact';
6
+ type DialogOptions = {
7
+ closable?: boolean;
8
+ title?: string | ReactNode;
9
+ variant?: DialogVariant;
10
+ };
11
+ type CreateDialog = (dialog: DialogComponent, opts?: DialogOptions) => void;
12
+ type DisplayMessage = (message: string | ReactNode, title?: string | ReactNode) => void;
13
+ type DisplayError = (message: string | ReactNode, title?: string | ReactNode) => void;
14
+ declare const DialogContext: react.Context<{
15
+ createDialog: CreateDialog;
16
+ displayMessage: DisplayMessage;
17
+ displayError: DisplayError;
18
+ }>;
19
+ type DialogTitleProps = ComponentPropsWithoutRef<'div'> & {
20
+ variant?: DialogVariant;
21
+ };
22
+ declare const DialogTitle: react.ForwardRefExoticComponent<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
23
+ variant?: DialogVariant;
24
+ } & react.RefAttributes<HTMLDivElement>>;
25
+ declare const DialogButtons: react.ForwardRefExoticComponent<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & react.RefAttributes<HTMLDivElement>>;
26
+ type DialogProps = DialogOptions & {
27
+ children: ReactNode;
28
+ dialogClosed: () => void;
29
+ };
30
+ declare const Dialog: FC<DialogProps>;
31
+ type DialogProviderProps = {
32
+ children: ReactNode;
33
+ };
34
+ declare const DialogProvider: FC<DialogProviderProps>;
35
+
36
+ export { Dialog, DialogButtons, type DialogComponent, DialogContext, type DialogProps, DialogProvider, DialogTitle, type DialogTitleProps, type DialogVariant };
@@ -0,0 +1,36 @@
1
+ import * as react from 'react';
2
+ import { FC, ReactNode, ComponentPropsWithoutRef } from 'react';
3
+
4
+ type DialogComponent = (close: () => void) => ReactNode;
5
+ type DialogVariant = 'dark' | 'light' | 'light-compact' | 'dark-compact';
6
+ type DialogOptions = {
7
+ closable?: boolean;
8
+ title?: string | ReactNode;
9
+ variant?: DialogVariant;
10
+ };
11
+ type CreateDialog = (dialog: DialogComponent, opts?: DialogOptions) => void;
12
+ type DisplayMessage = (message: string | ReactNode, title?: string | ReactNode) => void;
13
+ type DisplayError = (message: string | ReactNode, title?: string | ReactNode) => void;
14
+ declare const DialogContext: react.Context<{
15
+ createDialog: CreateDialog;
16
+ displayMessage: DisplayMessage;
17
+ displayError: DisplayError;
18
+ }>;
19
+ type DialogTitleProps = ComponentPropsWithoutRef<'div'> & {
20
+ variant?: DialogVariant;
21
+ };
22
+ declare const DialogTitle: react.ForwardRefExoticComponent<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
23
+ variant?: DialogVariant;
24
+ } & react.RefAttributes<HTMLDivElement>>;
25
+ declare const DialogButtons: react.ForwardRefExoticComponent<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & react.RefAttributes<HTMLDivElement>>;
26
+ type DialogProps = DialogOptions & {
27
+ children: ReactNode;
28
+ dialogClosed: () => void;
29
+ };
30
+ declare const Dialog: FC<DialogProps>;
31
+ type DialogProviderProps = {
32
+ children: ReactNode;
33
+ };
34
+ declare const DialogProvider: FC<DialogProviderProps>;
35
+
36
+ export { Dialog, DialogButtons, type DialogComponent, DialogContext, type DialogProps, DialogProvider, DialogTitle, type DialogTitleProps, type DialogVariant };
@@ -0,0 +1,17 @@
1
+ import {
2
+ Dialog,
3
+ DialogButtons,
4
+ DialogContext,
5
+ DialogProvider,
6
+ DialogTitle
7
+ } from "../chunk-XAK7WC3D.js";
8
+ import "../chunk-BIY5HAXP.js";
9
+ import "../chunk-4PMRDURG.js";
10
+ import "../chunk-H4U4Z4GM.js";
11
+ export {
12
+ Dialog,
13
+ DialogButtons,
14
+ DialogContext,
15
+ DialogProvider,
16
+ DialogTitle
17
+ };
@@ -0,0 +1,8 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+ var _chunkRI33QVODcjs = require('../chunk-RI33QVOD.cjs');
5
+
6
+
7
+
8
+ exports.useLongPressable = _chunkRI33QVODcjs.useLongPressable; exports.usePressable = _chunkRI33QVODcjs.usePressable;
@@ -0,0 +1,33 @@
1
+ type KeyboardBinding = {
2
+ key: string;
3
+ modifiers?: {
4
+ ctrlOrMetaKey?: boolean;
5
+ shiftKey?: boolean;
6
+ };
7
+ };
8
+ type RegisteredBinding = [KeyboardBinding, ...KeyboardBinding[]];
9
+ type PressableOnClickListener = (event: React.MouseEvent<unknown> | React.TouchEvent<unknown>) => unknown;
10
+ declare const usePressable: (click: PressableOnClickListener) => {
11
+ touching: boolean;
12
+ handlers: {
13
+ onClick: React.MouseEventHandler<unknown>;
14
+ onTouchStart: React.TouchEventHandler<unknown>;
15
+ onTouchMove: React.TouchEventHandler<unknown>;
16
+ onTouchEnd: React.TouchEventHandler<unknown>;
17
+ };
18
+ };
19
+ declare const useLongPressable: ({ onPress, onRelease, }: {
20
+ onPress: () => unknown;
21
+ onRelease: () => unknown;
22
+ }) => {
23
+ touching: boolean;
24
+ handlers: {
25
+ onMouseDown: React.MouseEventHandler<unknown>;
26
+ onMouseUp: React.MouseEventHandler<unknown>;
27
+ onTouchStart: React.TouchEventHandler<unknown>;
28
+ onTouchMove: React.TouchEventHandler<unknown>;
29
+ onTouchEnd: React.TouchEventHandler<unknown>;
30
+ };
31
+ };
32
+
33
+ export { type KeyboardBinding, type PressableOnClickListener, type RegisteredBinding, useLongPressable, usePressable };
@@ -0,0 +1,33 @@
1
+ type KeyboardBinding = {
2
+ key: string;
3
+ modifiers?: {
4
+ ctrlOrMetaKey?: boolean;
5
+ shiftKey?: boolean;
6
+ };
7
+ };
8
+ type RegisteredBinding = [KeyboardBinding, ...KeyboardBinding[]];
9
+ type PressableOnClickListener = (event: React.MouseEvent<unknown> | React.TouchEvent<unknown>) => unknown;
10
+ declare const usePressable: (click: PressableOnClickListener) => {
11
+ touching: boolean;
12
+ handlers: {
13
+ onClick: React.MouseEventHandler<unknown>;
14
+ onTouchStart: React.TouchEventHandler<unknown>;
15
+ onTouchMove: React.TouchEventHandler<unknown>;
16
+ onTouchEnd: React.TouchEventHandler<unknown>;
17
+ };
18
+ };
19
+ declare const useLongPressable: ({ onPress, onRelease, }: {
20
+ onPress: () => unknown;
21
+ onRelease: () => unknown;
22
+ }) => {
23
+ touching: boolean;
24
+ handlers: {
25
+ onMouseDown: React.MouseEventHandler<unknown>;
26
+ onMouseUp: React.MouseEventHandler<unknown>;
27
+ onTouchStart: React.TouchEventHandler<unknown>;
28
+ onTouchMove: React.TouchEventHandler<unknown>;
29
+ onTouchEnd: React.TouchEventHandler<unknown>;
30
+ };
31
+ };
32
+
33
+ export { type KeyboardBinding, type PressableOnClickListener, type RegisteredBinding, useLongPressable, usePressable };
@@ -0,0 +1,8 @@
1
+ import {
2
+ useLongPressable,
3
+ usePressable
4
+ } from "../chunk-4PMRDURG.js";
5
+ export {
6
+ useLongPressable,
7
+ usePressable
8
+ };
@@ -0,0 +1,54 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/frontend/preferences.ts
2
+ var _react = require('react');
3
+ var createBrowserPreferencesHook = (def) => () => {
4
+ const [preferences, setPreference] = _react.useState.call(void 0, () => {
5
+ const stored = window.localStorage.getItem(def.key);
6
+ if (stored) {
7
+ try {
8
+ return def.zodType.parse(JSON.parse(stored));
9
+ } catch (err) {
10
+ console.log("Failed to parse browser settings, using defaults.", err);
11
+ }
12
+ }
13
+ return def.defaultValue;
14
+ });
15
+ const updateBrowserPrefs = (change) => {
16
+ const newValue = JSON.stringify(change(preferences));
17
+ window.localStorage.setItem(def.key, newValue);
18
+ window.dispatchEvent(
19
+ new StorageEvent("storage", {
20
+ key: def.key,
21
+ newValue
22
+ })
23
+ );
24
+ };
25
+ _react.useEffect.call(void 0, () => {
26
+ const onStorageChange = (event) => {
27
+ if (event.key === def.key) {
28
+ const newValue = event.newValue;
29
+ if (newValue) {
30
+ try {
31
+ setPreference(def.zodType.parse(JSON.parse(newValue)));
32
+ } catch (err) {
33
+ console.log(
34
+ "Failed to parse browser settings from storage event, ignoring.",
35
+ err
36
+ );
37
+ }
38
+ }
39
+ }
40
+ };
41
+ window.addEventListener("storage", onStorageChange);
42
+ return () => {
43
+ window.removeEventListener("storage", onStorageChange);
44
+ };
45
+ }, []);
46
+ return {
47
+ preferences,
48
+ updateBrowserPrefs,
49
+ defaultPreferences: def.defaultValue
50
+ };
51
+ };
52
+
53
+
54
+ exports.createBrowserPreferencesHook = createBrowserPreferencesHook;
@@ -0,0 +1,14 @@
1
+ import z from 'zod';
2
+
3
+ type BrowserPreferencesDefinition<T> = {
4
+ key: string;
5
+ zodType: z.ZodType<T>;
6
+ defaultValue: T;
7
+ };
8
+ declare const createBrowserPreferencesHook: <T>(def: BrowserPreferencesDefinition<T>) => () => {
9
+ preferences: T;
10
+ updateBrowserPrefs: (change: (current: T) => T) => void;
11
+ defaultPreferences: T;
12
+ };
13
+
14
+ export { type BrowserPreferencesDefinition, createBrowserPreferencesHook };
@@ -0,0 +1,14 @@
1
+ import z from 'zod';
2
+
3
+ type BrowserPreferencesDefinition<T> = {
4
+ key: string;
5
+ zodType: z.ZodType<T>;
6
+ defaultValue: T;
7
+ };
8
+ declare const createBrowserPreferencesHook: <T>(def: BrowserPreferencesDefinition<T>) => () => {
9
+ preferences: T;
10
+ updateBrowserPrefs: (change: (current: T) => T) => void;
11
+ defaultPreferences: T;
12
+ };
13
+
14
+ export { type BrowserPreferencesDefinition, createBrowserPreferencesHook };
@@ -0,0 +1,54 @@
1
+ // src/frontend/preferences.ts
2
+ import { useEffect, useState } from "react";
3
+ var createBrowserPreferencesHook = (def) => () => {
4
+ const [preferences, setPreference] = useState(() => {
5
+ const stored = window.localStorage.getItem(def.key);
6
+ if (stored) {
7
+ try {
8
+ return def.zodType.parse(JSON.parse(stored));
9
+ } catch (err) {
10
+ console.log("Failed to parse browser settings, using defaults.", err);
11
+ }
12
+ }
13
+ return def.defaultValue;
14
+ });
15
+ const updateBrowserPrefs = (change) => {
16
+ const newValue = JSON.stringify(change(preferences));
17
+ window.localStorage.setItem(def.key, newValue);
18
+ window.dispatchEvent(
19
+ new StorageEvent("storage", {
20
+ key: def.key,
21
+ newValue
22
+ })
23
+ );
24
+ };
25
+ useEffect(() => {
26
+ const onStorageChange = (event) => {
27
+ if (event.key === def.key) {
28
+ const newValue = event.newValue;
29
+ if (newValue) {
30
+ try {
31
+ setPreference(def.zodType.parse(JSON.parse(newValue)));
32
+ } catch (err) {
33
+ console.log(
34
+ "Failed to parse browser settings from storage event, ignoring.",
35
+ err
36
+ );
37
+ }
38
+ }
39
+ }
40
+ };
41
+ window.addEventListener("storage", onStorageChange);
42
+ return () => {
43
+ window.removeEventListener("storage", onStorageChange);
44
+ };
45
+ }, []);
46
+ return {
47
+ preferences,
48
+ updateBrowserPrefs,
49
+ defaultPreferences: def.defaultValue
50
+ };
51
+ };
52
+ export {
53
+ createBrowserPreferencesHook
54
+ };