@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
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
+
3
+ var _chunkPEARNJ5Gcjs = require('./chunk-PEARNJ5G.cjs');
4
+
5
+
6
+
7
+ var _chunkRI33QVODcjs = require('./chunk-RI33QVOD.cjs');
8
+
9
+
10
+
11
+
12
+ var _chunk5DRI7C4Ucjs = require('./chunk-5DRI7C4U.cjs');
13
+
14
+ // src/frontend/dialogs.tsx
15
+
16
+
17
+
18
+
19
+
20
+ var _react = require('react');
21
+ var _core = require('@arcanejs/toolkit-frontend/components/core');
22
+ var _util = require('@arcanejs/toolkit-frontend/util');
23
+
24
+ // src/frontend/controls/buttons.tsx
25
+
26
+
27
+
28
+
29
+
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
+ var _jsxruntime = require('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) => _chunk5DRI7C4Ucjs.cssVariables.call(void 0,
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
+ }) => _util.cn.call(void 0,
92
+ `sigil-control-button`,
93
+ _chunk5DRI7C4Ucjs.cnd.call(void 0, variant === "border", `sigil-control-button-variant-border`),
94
+ _chunk5DRI7C4Ucjs.cnd.call(void 0, variant === "large", `sigil-control-button-variant-large`),
95
+ _chunk5DRI7C4Ucjs.cnd.call(void 0, variant === "properties", `sigil-control-button-variant-properties`),
96
+ _chunk5DRI7C4Ucjs.cnd.call(void 0, variant === "table-row", `sigil-control-button-variant-table-row`),
97
+ _chunk5DRI7C4Ucjs.cnd.call(void 0, variant === "toolbar", `sigil-control-button-variant-toolbar`),
98
+ _chunk5DRI7C4Ucjs.cnd.call(void 0, variant === "titlebar", `sigil-control-button-variant-titlebar`),
99
+ _chunk5DRI7C4Ucjs.cnd.call(void 0, touching, `sigil-control-button-touching`),
100
+ _chunk5DRI7C4Ucjs.cnd.call(void 0, active, `sigil-control-button-active`),
101
+ _chunk5DRI7C4Ucjs.cnd.call(void 0, touching && active, `sigil-control-button-active-touching`),
102
+ clsControlPosition(position),
103
+ className
104
+ );
105
+ var ControlButtonFrame = _react.forwardRef.call(void 0,
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__ */ _jsxruntime.jsx.call(void 0,
121
+ "button",
122
+ {
123
+ ...props,
124
+ ref,
125
+ type: _nullishCoalesce(type, () => ( "button")),
126
+ disabled,
127
+ className: clsControlButton({
128
+ variant,
129
+ active,
130
+ touching,
131
+ position,
132
+ className
133
+ }),
134
+ children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { children: [
135
+ icon && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
136
+ _core.Icon,
137
+ {
138
+ icon,
139
+ className: _util.cn.call(void 0, _chunk5DRI7C4Ucjs.cnd.call(void 0, children, "text-[120%]", "text-[150%]"))
140
+ }
141
+ ),
142
+ children
143
+ ] })
144
+ }
145
+ );
146
+ if (!title) return btn;
147
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkPEARNJ5Gcjs.TooltipWrapper, { tooltip: title, side: tooltipSide, children: btn });
148
+ }
149
+ );
150
+ ControlButtonFrame.displayName = "ControlButtonFrame";
151
+ var ControlButton = _react.forwardRef.call(void 0,
152
+ ({ onClick, disabled, ...props }, ref) => {
153
+ const { handlers, touching } = _chunkRI33QVODcjs.usePressable.call(void 0, onClick);
154
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
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 = _react.forwardRef.call(void 0, ({ active, label, ...props }, ref) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, ControlButton, { ...props, ref, active, children: [
168
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _core.Icon, { icon: active ? "check_box" : "check_box_outline_blank" }),
169
+ label
170
+ ] }));
171
+ CheckboxControlButton.displayName = "CheckboxControlButton";
172
+ var LongPressableControlButton = _react.forwardRef.call(void 0, ({ active, disabled, onPress, onRelease, ...props }, ref) => {
173
+ const { handlers, touching } = _chunkRI33QVODcjs.useLongPressable.call(void 0, { onPress, onRelease });
174
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
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 = _react.forwardRef.call(void 0, ({ children, className, position, ...props }, ref) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
187
+ "div",
188
+ {
189
+ ...props,
190
+ ref,
191
+ className: _util.cn.call(void 0,
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
+
206
+
207
+
208
+ var ControlParagraph = _react.forwardRef.call(void 0, ({ className, mode, position = "all", ...props }, ref) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
209
+ "p",
210
+ {
211
+ ...props,
212
+ ref,
213
+ className: _util.cn.call(void 0,
214
+ "border border-transparent",
215
+ clsControlPosition(position),
216
+ _chunk5DRI7C4Ucjs.cnd.call(void 0,
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
+ _chunk5DRI7C4Ucjs.cnd.call(void 0,
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
+ _chunk5DRI7C4Ucjs.cnd.call(void 0,
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 = _react.forwardRef.call(void 0,
244
+ ({ className, disabled, nonMicro, position = "label", subgrid, ...props }, ref) => {
245
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
246
+ "div",
247
+ {
248
+ ...props,
249
+ ref,
250
+ className: _util.cn.call(void 0,
251
+ "flex items-center justify-end gap-0.6 p-0.6",
252
+ clsControlPosition(position),
253
+ _chunk5DRI7C4Ucjs.cnd.call(void 0, nonMicro, "max-[550px]:hidden"),
254
+ _chunk5DRI7C4Ucjs.cnd.call(void 0, disabled, "opacity-50"),
255
+ clsControlSubgridPosition(position, subgrid),
256
+ className
257
+ )
258
+ }
259
+ );
260
+ }
261
+ );
262
+ ControlLabel.displayName = "ControlLabel";
263
+ var ControlDetails = _react.forwardRef.call(void 0,
264
+ ({ align, className, position = "all", ...props }, ref) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
265
+ "div",
266
+ {
267
+ ...props,
268
+ ref,
269
+ className: _util.cn.call(void 0,
270
+ "flex items-center px-0.3 text-sigil-foreground-muted",
271
+ clsControlPosition(position),
272
+ _chunk5DRI7C4Ucjs.cnd.call(void 0, align === "start", "justify-start"),
273
+ _chunk5DRI7C4Ucjs.cnd.call(void 0, align === "center", "justify-center"),
274
+ _chunk5DRI7C4Ucjs.cnd.call(void 0, align === "end", "justify-end"),
275
+ className
276
+ )
277
+ }
278
+ )
279
+ );
280
+ ControlDetails.displayName = "ControlDetails";
281
+ var InputSpanningTitle = _react.forwardRef.call(void 0, ({ className, position = "row", ...props }, ref) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
282
+ "div",
283
+ {
284
+ ...props,
285
+ ref,
286
+ className: _util.cn.call(void 0,
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
+
297
+
298
+
299
+ var ControlDialogButtons = _react.forwardRef.call(void 0, ({ children, className, ...props }, ref) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
300
+ ControlButtonGroup,
301
+ {
302
+ ref,
303
+ className: _util.cn.call(void 0, "control-grid-pos-row", className),
304
+ ...props,
305
+ children
306
+ }
307
+ ));
308
+ var ControlDialog = ({
309
+ children,
310
+ large,
311
+ ...props
312
+ }) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Dialog, { ...props, variant: "dark", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
313
+ "div",
314
+ {
315
+ className: _util.cn.call(void 0,
316
+ "gap-1 bg-sigil-bg-dark select-none",
317
+ _chunk5DRI7C4Ucjs.cnd.call(void 0, large, "control-grid-large", "control-grid")
318
+ ),
319
+ children
320
+ }
321
+ ) });
322
+
323
+ // src/frontend/controls/input.tsx
324
+
325
+
326
+
327
+
328
+
329
+
330
+
331
+ var InputWithDelayedPropagation = ({
332
+ value,
333
+ disabled,
334
+ onChange,
335
+ inputRef: inputRefProp,
336
+ ...props
337
+ }) => {
338
+ const lastValue = _react.useRef.call(void 0, value);
339
+ const inputRef = _react.useRef.call(void 0, null);
340
+ _react.useEffect.call(void 0, () => {
341
+ if (inputRef.current && inputRef.current.value !== value) {
342
+ inputRef.current.value = value;
343
+ }
344
+ lastValue.current = value;
345
+ }, [value]);
346
+ const updateRef = _react.useCallback.call(void 0,
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 = _react.useCallback.call(void 0,
357
+ (e) => {
358
+ if (e.currentTarget.value !== lastValue.current) {
359
+ onChange(e.currentTarget.value, false);
360
+ }
361
+ _optionalChain([onBlurProp, 'optionalCall', _ => _(e)]);
362
+ },
363
+ [onChange, onBlurProp]
364
+ );
365
+ const onKeyUpProp = props.onKeyUp;
366
+ const onKeyUp = _react.useCallback.call(void 0,
367
+ (e) => {
368
+ if ((e.key === "Enter" || e.key.startsWith("Arrow")) && e.currentTarget.value !== lastValue.current) {
369
+ onChange(e.currentTarget.value, true);
370
+ }
371
+ _optionalChain([onKeyUpProp, 'optionalCall', _2 => _2(e)]);
372
+ },
373
+ [onChange, onKeyUpProp]
374
+ );
375
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
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__ */ _jsxruntime.jsx.call(void 0,
394
+ InputWithDelayedPropagation,
395
+ {
396
+ ...props,
397
+ className: _util.cn.call(void 0,
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
+ _chunk5DRI7C4Ucjs.cnd.call(void 0, nonMicro, "max-[550px]:hidden"),
413
+ className
414
+ )
415
+ }
416
+ );
417
+ var ControlPercent = ({
418
+ className,
419
+ ...props
420
+ }) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ControlInput, { ...props, className: _util.cn.call(void 0, "min-w-[5rem]", className) });
421
+
422
+ // src/frontend/controls/select.tsx
423
+ var _radixui = require('radix-ui');
424
+
425
+
426
+
427
+
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 = _react.useCallback.call(void 0,
445
+ (val) => {
446
+ const matchingOption = options.find(
447
+ (option2) => (_nullishCoalesce(option2.value, () => ( NULL_VALUE))) === val
448
+ );
449
+ if (matchingOption) {
450
+ onChange(matchingOption.value);
451
+ }
452
+ },
453
+ [options, onChange]
454
+ );
455
+ const t = triggerButton ? triggerButton(_nullishCoalesce(selectedOption, () => ( null))) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
456
+ _radixui.Select.Trigger,
457
+ {
458
+ disabled,
459
+ className: _util.cn.call(void 0,
460
+ clsControlButton({
461
+ variant,
462
+ position,
463
+ active: _optionalChain([selectedOption, 'optionalAccess', _3 => _3.active])
464
+ }),
465
+ className
466
+ ),
467
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _radixui.Select.Value, { placeholder, children: selectedOption ? _nullishCoalesce(_optionalChain([triggerText, 'optionalCall', _4 => _4(selectedOption)]), () => ( selectedOption.label)) : "Unknown" })
468
+ }
469
+ );
470
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
471
+ _radixui.Select.Root,
472
+ {
473
+ value: _nullishCoalesce(value, () => ( NULL_VALUE)),
474
+ onValueChange,
475
+ disabled,
476
+ children: [
477
+ tooltip ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkPEARNJ5Gcjs.TooltipWrapper, { tooltip, children: t }) : t,
478
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
479
+ _radixui.Select.Content,
480
+ {
481
+ className: _util.cn.call(void 0,
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__ */ _jsxruntime.jsx.call(void 0, _radixui.Select.ScrollUpButton, { className: "text-center", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _core.Icon, { icon: "arrow_drop_up" }) }),
489
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _radixui.Select.Viewport, { className: "p-1", children: options.map((o) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
490
+ _radixui.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: _nullishCoalesce(o.value, () => ( NULL_VALUE)),
494
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _radixui.Select.ItemText, { children: _nullishCoalesce(_optionalChain([option, 'optionalCall', _5 => _5(o)]), () => ( o.label)) })
495
+ },
496
+ _nullishCoalesce(o.value, () => ( NULL_VALUE))
497
+ )) }),
498
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _radixui.Select.ScrollDownButton, { className: "text-center", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _core.Icon, { 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 = _chunk5DRI7C4Ucjs.sigilColorUsage.call(void 0, color || "gray");
528
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
529
+ ControlSelect,
530
+ {
531
+ options,
532
+ value: color,
533
+ onChange,
534
+ triggerButton: (option) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
535
+ _radixui.Select.Trigger,
536
+ {
537
+ disabled,
538
+ className: clsControlButton({
539
+ variant,
540
+ position,
541
+ active: _optionalChain([option, 'optionalAccess', _6 => _6.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__ */ _jsxruntime.jsxs.call(void 0,
555
+ _radixui.Select.Value,
556
+ {
557
+ placeholder: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
558
+ placeholder,
559
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
560
+ _core.Icon,
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
+ _nullishCoalesce(_optionalChain([option, 'optionalAccess', _7 => _7.label]), () => ( placeholder)),
569
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
570
+ _core.Icon,
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__ */ _jsxruntime.jsx.call(void 0,
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
+
601
+ var isDarkDialog = (variant) => variant === "dark" || variant === "dark-compact";
602
+ var DialogContext = _react.createContext.call(void 0, {
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 = _react.forwardRef.call(void 0,
614
+ ({ className, variant = "light", ...props }, ref) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
615
+ "div",
616
+ {
617
+ ...props,
618
+ ref,
619
+ className: _util.cn.call(void 0,
620
+ `
621
+ flex items-center justify-center gap-0.6 border-b border-sigil-border
622
+ p-arcane font-bold
623
+ `,
624
+ _chunk5DRI7C4Ucjs.cnd.call(void 0, isDarkDialog(variant), "bg-sigil-bg-light", "bg-sigil-bg-dark"),
625
+ className
626
+ )
627
+ }
628
+ )
629
+ );
630
+ DialogTitle.displayName = "DialogTitle";
631
+ var DialogButtons = _react.forwardRef.call(void 0, ({ className, ...props }, ref) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
632
+ "div",
633
+ {
634
+ ...props,
635
+ ref,
636
+ className: _util.cn.call(void 0, "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] = _react.useState.call(void 0, null);
648
+ _react.useEffect.call(void 0, () => {
649
+ if (!dialogRef) return;
650
+ dialogRef.showModal();
651
+ }, [dialogRef]);
652
+ const close = () => _optionalChain([dialogRef, 'optionalAccess', _8 => _8.close, 'call', _9 => _9()]);
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__ */ _jsxruntime.jsx.call(void 0,
667
+ "dialog",
668
+ {
669
+ ref: setDialogRef,
670
+ onMouseDown,
671
+ onClose,
672
+ className: _util.cn.call(void 0,
673
+ `
674
+ max-w-[80vw] min-w-[10vw] border-none p-0 text-sigil-dialog-foreground
675
+ outline-none backdrop-sigil-dialog
676
+ `,
677
+ _chunk5DRI7C4Ucjs.cnd.call(void 0, isDarkDialog(variant), "bg-sigil-bg-dark", "bg-sigil-bg-light")
678
+ ),
679
+ children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "border border-sigil-border", children: [
680
+ title && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, DialogTitle, { variant, children: title }),
681
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
682
+ "div",
683
+ {
684
+ className: _util.cn.call(void 0,
685
+ "text-sigil-foreground",
686
+ _chunk5DRI7C4Ucjs.cnd.call(void 0,
687
+ variant === "light-compact" || variant === "dark-compact",
688
+ "p-0"
689
+ ),
690
+ _chunk5DRI7C4Ucjs.cnd.call(void 0,
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] = _react.useState.call(void 0, []);
704
+ const createDialog = (dialog, options = {}) => {
705
+ setDialogs((items) => [...items, { dialog, options }]);
706
+ };
707
+ const displayMessage = (message, title) => {
708
+ createDialog(
709
+ (close) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
710
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { children: message }),
711
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, DialogButtons, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ControlButton, { onClick: close, variant: "large", children: "OK" }) })
712
+ ] }),
713
+ { title }
714
+ );
715
+ };
716
+ const displayError = (message, title) => displayMessage(
717
+ message,
718
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
719
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _core.Icon, { icon: "error" }),
720
+ title || "Error"
721
+ ] })
722
+ );
723
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
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__ */ _jsxruntime.jsx.call(void 0, Dialog, { dialogClosed: deleteDialog, ...item.options, children: item.dialog(deleteDialog) }, index);
734
+ })
735
+ ]
736
+ }
737
+ );
738
+ };
739
+
740
+
741
+
742
+
743
+
744
+
745
+
746
+
747
+
748
+
749
+
750
+
751
+
752
+
753
+
754
+
755
+
756
+
757
+
758
+
759
+
760
+
761
+
762
+
763
+
764
+
765
+
766
+
767
+ exports.clsControlPosition = clsControlPosition; exports.clsControlSubgridPosition = clsControlSubgridPosition; exports.controlPositionClass = controlPositionClass; exports.controlButtonColorVariable = controlButtonColorVariable; exports.controlButtonColorVariables = controlButtonColorVariables; exports.clsControlButton = clsControlButton; exports.ControlButton = ControlButton; exports.CheckboxControlButton = CheckboxControlButton; exports.LongPressableControlButton = LongPressableControlButton; exports.ControlButtonGroup = ControlButtonGroup; exports.ControlParagraph = ControlParagraph; exports.ControlLabel = ControlLabel; exports.ControlDetails = ControlDetails; exports.InputSpanningTitle = InputSpanningTitle; exports.DialogContext = DialogContext; exports.DialogTitle = DialogTitle; exports.DialogButtons = DialogButtons; exports.Dialog = Dialog; exports.DialogProvider = DialogProvider; exports.ControlDialogButtons = ControlDialogButtons; exports.ControlDialog = ControlDialog; exports.InputWithDelayedPropagation = InputWithDelayedPropagation; exports.ControlInput = ControlInput; exports.ControlPercent = ControlPercent; exports.ControlSelect = ControlSelect; exports.ControlColorSelect = ControlColorSelect;