@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,767 @@
1
+ import {
2
+ TooltipWrapper
3
+ } from "./chunk-BIY5HAXP.js";
4
+ import {
5
+ useLongPressable,
6
+ usePressable
7
+ } from "./chunk-4PMRDURG.js";
8
+ import {
9
+ cnd,
10
+ cssVariables,
11
+ sigilColorUsage
12
+ } from "./chunk-H4U4Z4GM.js";
13
+
14
+ // src/frontend/dialogs.tsx
15
+ import {
16
+ createContext,
17
+ forwardRef as forwardRef4,
18
+ useEffect as useEffect2,
19
+ useState
20
+ } from "react";
21
+ import { Icon as Icon3 } from "@arcanejs/toolkit-frontend/components/core";
22
+ import { cn as cn6 } from "@arcanejs/toolkit-frontend/util";
23
+
24
+ // src/frontend/controls/buttons.tsx
25
+ import {
26
+ forwardRef
27
+ } from "react";
28
+ import { cn } from "@arcanejs/toolkit-frontend/util";
29
+ import { Icon } from "@arcanejs/toolkit-frontend/components/core";
30
+
31
+ // src/frontend/controls/utils.ts
32
+ var clsControlPosition = (position) => {
33
+ if (!position) return void 0;
34
+ switch (position) {
35
+ case "row":
36
+ return "control-grid-pos-row";
37
+ case "label":
38
+ return "control-grid-pos-label";
39
+ case "first":
40
+ return "control-grid-pos-first";
41
+ case "second":
42
+ return "control-grid-pos-second";
43
+ case "both":
44
+ return "control-grid-pos-both";
45
+ case "all":
46
+ return "control-grid-pos-all";
47
+ case "extra":
48
+ return "control-grid-pos-extra";
49
+ }
50
+ };
51
+ var clsControlSubgridPosition = (position, subgrid) => {
52
+ if (!subgrid) return void 0;
53
+ switch (position) {
54
+ case "label":
55
+ return "col-[1/span_1]";
56
+ case "first":
57
+ return "col-[2/span_1]";
58
+ case "second":
59
+ return "col-[3/span_1]";
60
+ }
61
+ };
62
+ var controlPositionClass = clsControlPosition;
63
+
64
+ // src/frontend/controls/buttons.tsx
65
+ import { jsx, jsxs } from "react/jsx-runtime";
66
+ var CONTROL_BUTTON_VAR_SUFFIX = {
67
+ bg: "bg",
68
+ bgHover: "bg-hover",
69
+ bgActive: "bg-active",
70
+ fg: "fg",
71
+ fgHover: "fg-hover",
72
+ fgActive: "fg-active",
73
+ border: "border",
74
+ borderHover: "border-hover",
75
+ borderActive: "border-active"
76
+ };
77
+ var controlButtonColorVariable = (property) => `--sigil-control-button-${CONTROL_BUTTON_VAR_SUFFIX[property]}`;
78
+ var controlButtonColorVariables = (usage) => cssVariables(
79
+ Object.fromEntries(
80
+ Object.keys(usage).map(
81
+ (key) => [controlButtonColorVariable(key), usage[key]]
82
+ )
83
+ )
84
+ );
85
+ var clsControlButton = ({
86
+ variant,
87
+ active,
88
+ touching,
89
+ position,
90
+ className
91
+ }) => cn(
92
+ `sigil-control-button`,
93
+ cnd(variant === "border", `sigil-control-button-variant-border`),
94
+ cnd(variant === "large", `sigil-control-button-variant-large`),
95
+ cnd(variant === "properties", `sigil-control-button-variant-properties`),
96
+ cnd(variant === "table-row", `sigil-control-button-variant-table-row`),
97
+ cnd(variant === "toolbar", `sigil-control-button-variant-toolbar`),
98
+ cnd(variant === "titlebar", `sigil-control-button-variant-titlebar`),
99
+ cnd(touching, `sigil-control-button-touching`),
100
+ cnd(active, `sigil-control-button-active`),
101
+ cnd(touching && active, `sigil-control-button-active-touching`),
102
+ clsControlPosition(position),
103
+ className
104
+ );
105
+ var ControlButtonFrame = forwardRef(
106
+ ({
107
+ children,
108
+ className,
109
+ type,
110
+ variant = "toolbar",
111
+ icon,
112
+ active,
113
+ touching,
114
+ disabled,
115
+ title,
116
+ tooltipSide,
117
+ position,
118
+ ...props
119
+ }, ref) => {
120
+ const btn = /* @__PURE__ */ jsx(
121
+ "button",
122
+ {
123
+ ...props,
124
+ ref,
125
+ type: type ?? "button",
126
+ disabled,
127
+ className: clsControlButton({
128
+ variant,
129
+ active,
130
+ touching,
131
+ position,
132
+ className
133
+ }),
134
+ children: /* @__PURE__ */ jsxs("span", { children: [
135
+ icon && /* @__PURE__ */ jsx(
136
+ Icon,
137
+ {
138
+ icon,
139
+ className: cn(cnd(children, "text-[120%]", "text-[150%]"))
140
+ }
141
+ ),
142
+ children
143
+ ] })
144
+ }
145
+ );
146
+ if (!title) return btn;
147
+ return /* @__PURE__ */ jsx(TooltipWrapper, { tooltip: title, side: tooltipSide, children: btn });
148
+ }
149
+ );
150
+ ControlButtonFrame.displayName = "ControlButtonFrame";
151
+ var ControlButton = forwardRef(
152
+ ({ onClick, disabled, ...props }, ref) => {
153
+ const { handlers, touching } = usePressable(onClick);
154
+ return /* @__PURE__ */ jsx(
155
+ ControlButtonFrame,
156
+ {
157
+ ...props,
158
+ ref,
159
+ disabled,
160
+ touching,
161
+ ...!disabled ? handlers : {}
162
+ }
163
+ );
164
+ }
165
+ );
166
+ ControlButton.displayName = "ControlButton";
167
+ var CheckboxControlButton = forwardRef(({ active, label, ...props }, ref) => /* @__PURE__ */ jsxs(ControlButton, { ...props, ref, active, children: [
168
+ /* @__PURE__ */ jsx(Icon, { icon: active ? "check_box" : "check_box_outline_blank" }),
169
+ label
170
+ ] }));
171
+ CheckboxControlButton.displayName = "CheckboxControlButton";
172
+ var LongPressableControlButton = forwardRef(({ active, disabled, onPress, onRelease, ...props }, ref) => {
173
+ const { handlers, touching } = useLongPressable({ onPress, onRelease });
174
+ return /* @__PURE__ */ jsx(
175
+ ControlButtonFrame,
176
+ {
177
+ ...props,
178
+ ref,
179
+ active: active || touching,
180
+ disabled,
181
+ ...!disabled ? handlers : {}
182
+ }
183
+ );
184
+ });
185
+ LongPressableControlButton.displayName = "LongPressableControlButton";
186
+ var ControlButtonGroup = forwardRef(({ children, className, position, ...props }, ref) => /* @__PURE__ */ jsx(
187
+ "div",
188
+ {
189
+ ...props,
190
+ ref,
191
+ className: cn(
192
+ `
193
+ flex items-stretch gap-sigil-control-gap
194
+ [&>button]:grow
195
+ `,
196
+ clsControlPosition(position),
197
+ className
198
+ ),
199
+ children
200
+ }
201
+ ));
202
+ ControlButtonGroup.displayName = "ControlButtonGroup";
203
+
204
+ // src/frontend/controls/content.tsx
205
+ import { forwardRef as forwardRef2 } from "react";
206
+ import { cn as cn2 } from "@arcanejs/toolkit-frontend/util";
207
+ import { jsx as jsx2 } from "react/jsx-runtime";
208
+ var ControlParagraph = forwardRef2(({ className, mode, position = "all", ...props }, ref) => /* @__PURE__ */ jsx2(
209
+ "p",
210
+ {
211
+ ...props,
212
+ ref,
213
+ className: cn2(
214
+ "border border-transparent",
215
+ clsControlPosition(position),
216
+ cnd(
217
+ mode === "success",
218
+ `
219
+ border-sigil-usage-green-dimmed-border
220
+ bg-sigil-usage-green-dimmed-background p-1 text-sigil-usage-green-text
221
+ `
222
+ ),
223
+ cnd(
224
+ mode === "warning",
225
+ `
226
+ border-sigil-usage-yellow-dimmed-border
227
+ bg-sigil-usage-yellow-dimmed-background p-1
228
+ text-sigil-usage-yellow-text
229
+ `
230
+ ),
231
+ cnd(
232
+ mode === "error",
233
+ `
234
+ border-sigil-usage-red-dimmed-border
235
+ bg-sigil-usage-red-dimmed-background p-1 text-sigil-usage-red-text
236
+ `
237
+ ),
238
+ className
239
+ )
240
+ }
241
+ ));
242
+ ControlParagraph.displayName = "ControlParagraph";
243
+ var ControlLabel = forwardRef2(
244
+ ({ className, disabled, nonMicro, position = "label", subgrid, ...props }, ref) => {
245
+ return /* @__PURE__ */ jsx2(
246
+ "div",
247
+ {
248
+ ...props,
249
+ ref,
250
+ className: cn2(
251
+ "flex items-center justify-end gap-0.6 p-0.6",
252
+ clsControlPosition(position),
253
+ cnd(nonMicro, "max-[550px]:hidden"),
254
+ cnd(disabled, "opacity-50"),
255
+ clsControlSubgridPosition(position, subgrid),
256
+ className
257
+ )
258
+ }
259
+ );
260
+ }
261
+ );
262
+ ControlLabel.displayName = "ControlLabel";
263
+ var ControlDetails = forwardRef2(
264
+ ({ align, className, position = "all", ...props }, ref) => /* @__PURE__ */ jsx2(
265
+ "div",
266
+ {
267
+ ...props,
268
+ ref,
269
+ className: cn2(
270
+ "flex items-center px-0.3 text-sigil-foreground-muted",
271
+ clsControlPosition(position),
272
+ cnd(align === "start", "justify-start"),
273
+ cnd(align === "center", "justify-center"),
274
+ cnd(align === "end", "justify-end"),
275
+ className
276
+ )
277
+ }
278
+ )
279
+ );
280
+ ControlDetails.displayName = "ControlDetails";
281
+ var InputSpanningTitle = forwardRef2(({ className, position = "row", ...props }, ref) => /* @__PURE__ */ jsx2(
282
+ "div",
283
+ {
284
+ ...props,
285
+ ref,
286
+ className: cn2(
287
+ "truncate p-0.6 text-center text-[0.8rem] font-bold",
288
+ clsControlPosition(position),
289
+ className
290
+ )
291
+ }
292
+ ));
293
+ InputSpanningTitle.displayName = "InputSpanningTitle";
294
+
295
+ // src/frontend/controls/dialogs.tsx
296
+ import { forwardRef as forwardRef3 } from "react";
297
+ import { cn as cn3 } from "@arcanejs/toolkit-frontend/util";
298
+ import { jsx as jsx3 } from "react/jsx-runtime";
299
+ var ControlDialogButtons = forwardRef3(({ children, className, ...props }, ref) => /* @__PURE__ */ jsx3(
300
+ ControlButtonGroup,
301
+ {
302
+ ref,
303
+ className: cn3("control-grid-pos-row", className),
304
+ ...props,
305
+ children
306
+ }
307
+ ));
308
+ var ControlDialog = ({
309
+ children,
310
+ large,
311
+ ...props
312
+ }) => /* @__PURE__ */ jsx3(Dialog, { ...props, variant: "dark", children: /* @__PURE__ */ jsx3(
313
+ "div",
314
+ {
315
+ className: cn3(
316
+ "gap-1 bg-sigil-bg-dark select-none",
317
+ cnd(large, "control-grid-large", "control-grid")
318
+ ),
319
+ children
320
+ }
321
+ ) });
322
+
323
+ // src/frontend/controls/input.tsx
324
+ import {
325
+ useCallback,
326
+ useEffect,
327
+ useRef
328
+ } from "react";
329
+ import { cn as cn4 } from "@arcanejs/toolkit-frontend/util";
330
+ import { jsx as jsx4 } from "react/jsx-runtime";
331
+ var InputWithDelayedPropagation = ({
332
+ value,
333
+ disabled,
334
+ onChange,
335
+ inputRef: inputRefProp,
336
+ ...props
337
+ }) => {
338
+ const lastValue = useRef(value);
339
+ const inputRef = useRef(null);
340
+ useEffect(() => {
341
+ if (inputRef.current && inputRef.current.value !== value) {
342
+ inputRef.current.value = value;
343
+ }
344
+ lastValue.current = value;
345
+ }, [value]);
346
+ const updateRef = useCallback(
347
+ (instance) => {
348
+ inputRef.current = instance;
349
+ if (inputRefProp) {
350
+ inputRefProp.current = instance;
351
+ }
352
+ },
353
+ [inputRefProp]
354
+ );
355
+ const onBlurProp = props.onBlur;
356
+ const onBlur = useCallback(
357
+ (e) => {
358
+ if (e.currentTarget.value !== lastValue.current) {
359
+ onChange(e.currentTarget.value, false);
360
+ }
361
+ onBlurProp?.(e);
362
+ },
363
+ [onChange, onBlurProp]
364
+ );
365
+ const onKeyUpProp = props.onKeyUp;
366
+ const onKeyUp = useCallback(
367
+ (e) => {
368
+ if ((e.key === "Enter" || e.key.startsWith("Arrow")) && e.currentTarget.value !== lastValue.current) {
369
+ onChange(e.currentTarget.value, true);
370
+ }
371
+ onKeyUpProp?.(e);
372
+ },
373
+ [onChange, onKeyUpProp]
374
+ );
375
+ return /* @__PURE__ */ jsx4(
376
+ "input",
377
+ {
378
+ ref: updateRef,
379
+ defaultValue: value,
380
+ onBlur,
381
+ onKeyUp,
382
+ disabled,
383
+ ...props
384
+ }
385
+ );
386
+ };
387
+ var ControlInput = ({
388
+ className,
389
+ nonMicro,
390
+ position = "first",
391
+ subgrid,
392
+ ...props
393
+ }) => /* @__PURE__ */ jsx4(
394
+ InputWithDelayedPropagation,
395
+ {
396
+ ...props,
397
+ className: cn4(
398
+ `
399
+ overflow-hidden border-0 bg-sigil-bg-dark px-arcane-slider-input-hidden
400
+ py-[7px] text-[0.7rem] text-sigil-foreground shadow-none
401
+ focus:border-2 focus:border-sigil-usage-hint-foreground
402
+ focus:bg-sigil-bg-dark-1 focus:px-[7px] focus:py-arcane-slider-input-px
403
+ focus:text-sigil-usage-hint-foreground focus:outline-none
404
+ disabled:opacity-50
405
+ [&::-webkit-inner-spin-button]:opacity-20
406
+ focus:[&::-webkit-inner-spin-button]:opacity-50
407
+ [&::-webkit-outer-spin-button]:opacity-20
408
+ focus:[&::-webkit-outer-spin-button]:opacity-50
409
+ `,
410
+ clsControlPosition(position),
411
+ clsControlSubgridPosition(position, subgrid),
412
+ cnd(nonMicro, "max-[550px]:hidden"),
413
+ className
414
+ )
415
+ }
416
+ );
417
+ var ControlPercent = ({
418
+ className,
419
+ ...props
420
+ }) => /* @__PURE__ */ jsx4(ControlInput, { ...props, className: cn4("min-w-[5rem]", className) });
421
+
422
+ // src/frontend/controls/select.tsx
423
+ import { Select } from "radix-ui";
424
+ import { useCallback as useCallback2 } from "react";
425
+ import { cn as cn5 } from "@arcanejs/toolkit-frontend/util";
426
+ import { Icon as Icon2 } from "@arcanejs/toolkit-frontend/components/core";
427
+ import { Fragment, jsx as jsx5, jsxs as jsxs2 } from "react/jsx-runtime";
428
+ var NULL_VALUE = "__null_value__";
429
+ var ControlSelect = ({
430
+ options,
431
+ value,
432
+ onChange,
433
+ triggerText,
434
+ triggerButton,
435
+ option,
436
+ variant,
437
+ position,
438
+ disabled,
439
+ tooltip,
440
+ placeholder,
441
+ triggerClassName: className
442
+ }) => {
443
+ const selectedOption = options.find((option2) => option2.value === value);
444
+ const onValueChange = useCallback2(
445
+ (val) => {
446
+ const matchingOption = options.find(
447
+ (option2) => (option2.value ?? NULL_VALUE) === val
448
+ );
449
+ if (matchingOption) {
450
+ onChange(matchingOption.value);
451
+ }
452
+ },
453
+ [options, onChange]
454
+ );
455
+ const t = triggerButton ? triggerButton(selectedOption ?? null) : /* @__PURE__ */ jsx5(
456
+ Select.Trigger,
457
+ {
458
+ disabled,
459
+ className: cn5(
460
+ clsControlButton({
461
+ variant,
462
+ position,
463
+ active: selectedOption?.active
464
+ }),
465
+ className
466
+ ),
467
+ children: /* @__PURE__ */ jsx5(Select.Value, { placeholder, children: selectedOption ? triggerText?.(selectedOption) ?? selectedOption.label : "Unknown" })
468
+ }
469
+ );
470
+ return /* @__PURE__ */ jsxs2(
471
+ Select.Root,
472
+ {
473
+ value: value ?? NULL_VALUE,
474
+ onValueChange,
475
+ disabled,
476
+ children: [
477
+ tooltip ? /* @__PURE__ */ jsx5(TooltipWrapper, { tooltip, children: t }) : t,
478
+ /* @__PURE__ */ jsxs2(
479
+ Select.Content,
480
+ {
481
+ className: cn5(
482
+ `
483
+ z-sigil-select-content rounded-sigil-control border
484
+ border-sigil-border bg-sigil-bg-dark shadow-sigil-box
485
+ `
486
+ ),
487
+ children: [
488
+ /* @__PURE__ */ jsx5(Select.ScrollUpButton, { className: "text-center", children: /* @__PURE__ */ jsx5(Icon2, { icon: "arrow_drop_up" }) }),
489
+ /* @__PURE__ */ jsx5(Select.Viewport, { className: "p-1", children: options.map((o) => /* @__PURE__ */ jsx5(
490
+ Select.Item,
491
+ {
492
+ className: "\n mx-0 my-0.6 cursor-pointer rounded-[2px] px-1.5 py-0.6\n outline-none\n data-highlighted:bg-sigil-border\n data-highlighted:text-sigil-foreground-highlight\n data-[state='checked']:text-sigil-usage-hint-foreground\n ",
493
+ value: o.value ?? NULL_VALUE,
494
+ children: /* @__PURE__ */ jsx5(Select.ItemText, { children: option?.(o) ?? o.label })
495
+ },
496
+ o.value ?? NULL_VALUE
497
+ )) }),
498
+ /* @__PURE__ */ jsx5(Select.ScrollDownButton, { className: "text-center", children: /* @__PURE__ */ jsx5(Icon2, { icon: "arrow_drop_down" }) })
499
+ ]
500
+ }
501
+ )
502
+ ]
503
+ }
504
+ );
505
+ };
506
+ var COLOR_OPTIONS = {
507
+ red: { label: "Red", value: "red" },
508
+ blue: { label: "Blue", value: "blue" },
509
+ teal: { label: "Teal", value: "teal" },
510
+ green: { label: "Green", value: "green" },
511
+ yellow: { label: "Yellow", value: "yellow" },
512
+ purple: { label: "Purple", value: "purple" },
513
+ orange: { label: "Orange", value: "orange" },
514
+ brown: { label: "Brown", value: "brown" },
515
+ gray: { label: "Gray", value: "gray" }
516
+ };
517
+ var ControlColorSelect = ({
518
+ color,
519
+ onChange,
520
+ variant,
521
+ position,
522
+ disabled,
523
+ placeholder,
524
+ ...props
525
+ }) => {
526
+ const options = Object.values(COLOR_OPTIONS);
527
+ const selectedColor = sigilColorUsage(color || "gray");
528
+ return /* @__PURE__ */ jsx5(
529
+ ControlSelect,
530
+ {
531
+ options,
532
+ value: color,
533
+ onChange,
534
+ triggerButton: (option) => /* @__PURE__ */ jsx5(
535
+ Select.Trigger,
536
+ {
537
+ disabled,
538
+ className: clsControlButton({
539
+ variant,
540
+ position,
541
+ active: option?.active
542
+ }),
543
+ style: controlButtonColorVariables({
544
+ bg: selectedColor.background,
545
+ bgHover: selectedColor.selectedBackground,
546
+ bgActive: selectedColor.selectedBackground,
547
+ fg: selectedColor.text,
548
+ fgHover: selectedColor.selectedText,
549
+ fgActive: selectedColor.selectedText,
550
+ border: selectedColor.border,
551
+ borderHover: selectedColor.selectedBorder,
552
+ borderActive: selectedColor.selectedBorder
553
+ }),
554
+ children: /* @__PURE__ */ jsxs2(
555
+ Select.Value,
556
+ {
557
+ placeholder: /* @__PURE__ */ jsxs2(Fragment, { children: [
558
+ placeholder,
559
+ /* @__PURE__ */ jsx5(
560
+ Icon2,
561
+ {
562
+ className: "\n -my-text-1 -mr-text-0.5 -ml-text-0.25 text-arcane-normal\n ",
563
+ icon: "arrow_drop_down"
564
+ }
565
+ )
566
+ ] }),
567
+ children: [
568
+ option?.label ?? placeholder,
569
+ /* @__PURE__ */ jsx5(
570
+ Icon2,
571
+ {
572
+ className: "\n -my-text-1 -mr-text-0.5 -ml-text-0.25 text-arcane-normal\n ",
573
+ icon: "arrow_drop_down"
574
+ }
575
+ )
576
+ ]
577
+ }
578
+ )
579
+ }
580
+ ),
581
+ option: (option) => /* @__PURE__ */ jsx5(
582
+ "span",
583
+ {
584
+ className: "",
585
+ style: {
586
+ color: `var(--sigil-usage-${option.value}-foreground)`
587
+ },
588
+ children: option.label
589
+ }
590
+ ),
591
+ variant,
592
+ position,
593
+ disabled,
594
+ ...props
595
+ }
596
+ );
597
+ };
598
+
599
+ // src/frontend/dialogs.tsx
600
+ import { Fragment as Fragment2, jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
601
+ var isDarkDialog = (variant) => variant === "dark" || variant === "dark-compact";
602
+ var DialogContext = createContext({
603
+ createDialog: () => {
604
+ throw new Error("DialogContext not provided");
605
+ },
606
+ displayMessage: () => {
607
+ throw new Error("DialogContext not provided");
608
+ },
609
+ displayError: () => {
610
+ throw new Error("DialogContext not provided");
611
+ }
612
+ });
613
+ var DialogTitle = forwardRef4(
614
+ ({ className, variant = "light", ...props }, ref) => /* @__PURE__ */ jsx6(
615
+ "div",
616
+ {
617
+ ...props,
618
+ ref,
619
+ className: cn6(
620
+ `
621
+ flex items-center justify-center gap-0.6 border-b border-sigil-border
622
+ p-arcane font-bold
623
+ `,
624
+ cnd(isDarkDialog(variant), "bg-sigil-bg-light", "bg-sigil-bg-dark"),
625
+ className
626
+ )
627
+ }
628
+ )
629
+ );
630
+ DialogTitle.displayName = "DialogTitle";
631
+ var DialogButtons = forwardRef4(({ className, ...props }, ref) => /* @__PURE__ */ jsx6(
632
+ "div",
633
+ {
634
+ ...props,
635
+ ref,
636
+ className: cn6("mt-arcane flex justify-end gap-0.6", className)
637
+ }
638
+ ));
639
+ DialogButtons.displayName = "DialogButtons";
640
+ var Dialog = ({
641
+ children,
642
+ dialogClosed,
643
+ closable = true,
644
+ title,
645
+ variant = "light"
646
+ }) => {
647
+ const [dialogRef, setDialogRef] = useState(null);
648
+ useEffect2(() => {
649
+ if (!dialogRef) return;
650
+ dialogRef.showModal();
651
+ }, [dialogRef]);
652
+ const close = () => dialogRef?.close();
653
+ const onClose = (event) => {
654
+ if (closable) {
655
+ dialogClosed();
656
+ return;
657
+ }
658
+ event.preventDefault();
659
+ event.currentTarget.showModal();
660
+ };
661
+ const onMouseDown = (event) => {
662
+ if (event.target === event.currentTarget) {
663
+ close();
664
+ }
665
+ };
666
+ return /* @__PURE__ */ jsx6(
667
+ "dialog",
668
+ {
669
+ ref: setDialogRef,
670
+ onMouseDown,
671
+ onClose,
672
+ className: cn6(
673
+ `
674
+ max-w-[80vw] min-w-[10vw] border-none p-0 text-sigil-dialog-foreground
675
+ outline-none backdrop-sigil-dialog
676
+ `,
677
+ cnd(isDarkDialog(variant), "bg-sigil-bg-dark", "bg-sigil-bg-light")
678
+ ),
679
+ children: /* @__PURE__ */ jsxs3("div", { className: "border border-sigil-border", children: [
680
+ title && /* @__PURE__ */ jsx6(DialogTitle, { variant, children: title }),
681
+ /* @__PURE__ */ jsx6(
682
+ "div",
683
+ {
684
+ className: cn6(
685
+ "text-sigil-foreground",
686
+ cnd(
687
+ variant === "light-compact" || variant === "dark-compact",
688
+ "p-0"
689
+ ),
690
+ cnd(
691
+ variant !== "light-compact" && variant !== "dark-compact",
692
+ "p-arcane"
693
+ )
694
+ ),
695
+ children
696
+ }
697
+ )
698
+ ] })
699
+ }
700
+ );
701
+ };
702
+ var DialogProvider = ({ children }) => {
703
+ const [dialogs, setDialogs] = useState([]);
704
+ const createDialog = (dialog, options = {}) => {
705
+ setDialogs((items) => [...items, { dialog, options }]);
706
+ };
707
+ const displayMessage = (message, title) => {
708
+ createDialog(
709
+ (close) => /* @__PURE__ */ jsxs3(Fragment2, { children: [
710
+ /* @__PURE__ */ jsx6("div", { children: message }),
711
+ /* @__PURE__ */ jsx6(DialogButtons, { children: /* @__PURE__ */ jsx6(ControlButton, { onClick: close, variant: "large", children: "OK" }) })
712
+ ] }),
713
+ { title }
714
+ );
715
+ };
716
+ const displayError = (message, title) => displayMessage(
717
+ message,
718
+ /* @__PURE__ */ jsxs3(Fragment2, { children: [
719
+ /* @__PURE__ */ jsx6(Icon3, { icon: "error" }),
720
+ title || "Error"
721
+ ] })
722
+ );
723
+ return /* @__PURE__ */ jsxs3(
724
+ DialogContext.Provider,
725
+ {
726
+ value: { createDialog, displayMessage, displayError },
727
+ children: [
728
+ children,
729
+ dialogs.map((item, index) => {
730
+ const deleteDialog = () => {
731
+ setDialogs((items) => items.filter((dialog) => dialog !== item));
732
+ };
733
+ return /* @__PURE__ */ jsx6(Dialog, { dialogClosed: deleteDialog, ...item.options, children: item.dialog(deleteDialog) }, index);
734
+ })
735
+ ]
736
+ }
737
+ );
738
+ };
739
+
740
+ export {
741
+ clsControlPosition,
742
+ clsControlSubgridPosition,
743
+ controlPositionClass,
744
+ controlButtonColorVariable,
745
+ controlButtonColorVariables,
746
+ clsControlButton,
747
+ ControlButton,
748
+ CheckboxControlButton,
749
+ LongPressableControlButton,
750
+ ControlButtonGroup,
751
+ ControlParagraph,
752
+ ControlLabel,
753
+ ControlDetails,
754
+ InputSpanningTitle,
755
+ DialogContext,
756
+ DialogTitle,
757
+ DialogButtons,
758
+ Dialog,
759
+ DialogProvider,
760
+ ControlDialogButtons,
761
+ ControlDialog,
762
+ InputWithDelayedPropagation,
763
+ ControlInput,
764
+ ControlPercent,
765
+ ControlSelect,
766
+ ControlColorSelect
767
+ };