@devicechain/widgets 0.23.0 → 0.24.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.
- package/README.md +8 -3
- package/dist/aggregate-fold.d.ts +3 -2
- package/dist/aggregate-strings.d.ts +1 -0
- package/dist/alarm-strings.d.ts +18 -0
- package/dist/binding-policy.d.ts +4 -0
- package/dist/bound-devices-notice.d.ts +30 -0
- package/dist/builtin-descriptors.d.ts +290 -249
- package/dist/builtin-option-docs.d.ts +2 -0
- package/dist/builtin-registry.d.ts +249 -226
- package/dist/category-geometry.d.ts +1 -0
- package/dist/chunks/{aggregate-feed-BD3CHNFU.js → aggregate-feed-4FSBQYJL.js} +39 -11
- package/dist/chunks/aggregate-feed-4FSBQYJL.js.map +7 -0
- package/dist/chunks/{aggregate-widgets-HZQI5HTX.js → aggregate-widgets-2ZQBW3YF.js} +376 -182
- package/dist/chunks/aggregate-widgets-2ZQBW3YF.js.map +7 -0
- package/dist/chunks/alarm-widgets-X4PX5MYJ.js +72 -0
- package/dist/chunks/alarm-widgets-X4PX5MYJ.js.map +7 -0
- package/dist/chunks/chunk-546TK2QG.js +722 -0
- package/dist/chunks/chunk-546TK2QG.js.map +7 -0
- package/dist/chunks/{chunk-WBKHYZU2.js → chunk-62CHYCHI.js} +6 -62
- package/dist/chunks/chunk-62CHYCHI.js.map +7 -0
- package/dist/chunks/chunk-BMFQOTYG.js +41 -0
- package/dist/chunks/chunk-BMFQOTYG.js.map +7 -0
- package/dist/chunks/{chunk-2D7JNKFE.js → chunk-JFH4QMLA.js} +28 -4
- package/dist/chunks/chunk-JFH4QMLA.js.map +7 -0
- package/dist/chunks/chunk-QMGKB6J3.js +84 -0
- package/dist/chunks/chunk-QMGKB6J3.js.map +7 -0
- package/dist/chunks/chunk-XNEBAY4J.js +19 -0
- package/dist/chunks/chunk-XNEBAY4J.js.map +7 -0
- package/dist/chunks/chunk-YYJV54BV.js +58 -0
- package/dist/chunks/chunk-YYJV54BV.js.map +7 -0
- package/dist/chunks/compare-feed-AY3CVKUZ.js +346 -0
- package/dist/chunks/compare-feed-AY3CVKUZ.js.map +7 -0
- package/dist/chunks/{control-widgets-3V2LSSRF.js → control-widgets-UCTJJJ2D.js} +267 -78
- package/dist/chunks/control-widgets-UCTJJJ2D.js.map +7 -0
- package/dist/chunks/event-markers-feed-GEGTIHXT.js +373 -0
- package/dist/chunks/event-markers-feed-GEGTIHXT.js.map +7 -0
- package/dist/chunks/{fleet-feed-5QGDLOV5.js → fleet-feed-2SKDR6ZQ.js} +47 -8
- package/dist/chunks/fleet-feed-2SKDR6ZQ.js.map +7 -0
- package/dist/chunks/presence-widgets-2LIUKN4Y.js +350 -0
- package/dist/chunks/presence-widgets-2LIUKN4Y.js.map +7 -0
- package/dist/command-control-strings.d.ts +5 -0
- package/dist/compare-feed.d.ts +13 -0
- package/dist/compare-model.d.ts +38 -0
- package/dist/compare-strings.d.ts +13 -0
- package/dist/documented-descriptors.d.ts +4826 -0
- package/dist/event-markers-feed.d.ts +11 -0
- package/dist/event-markers-model.d.ts +38 -0
- package/dist/event-markers-strings.d.ts +20 -0
- package/dist/event-markers-types.d.ts +7 -0
- package/dist/fleet-count-model.d.ts +13 -0
- package/dist/fleet-feed.d.ts +1 -0
- package/dist/fleet-model.d.ts +1 -0
- package/dist/fleet-strings.d.ts +11 -0
- package/dist/index.d.ts +6 -3
- package/dist/index.js +946 -398
- package/dist/index.js.map +4 -4
- package/dist/presence-feed.d.ts +24 -0
- package/dist/presence-model.d.ts +13 -0
- package/dist/presence-strings.d.ts +19 -0
- package/dist/sparkline.d.ts +23 -0
- package/dist/use-bound-devices.d.ts +26 -0
- package/dist/widgets/aggregate-lazy.d.ts +81 -46
- package/dist/widgets/aggregate-widgets.d.ts +1 -0
- package/dist/widgets/alarm-grouped.d.ts +17 -0
- package/dist/widgets/alarm-lazy.d.ts +63 -16
- package/dist/widgets/alarm-severity.d.ts +8 -0
- package/dist/widgets/alarm-table.d.ts +2 -0
- package/dist/widgets/alarm-type-tabs.d.ts +10 -0
- package/dist/widgets/alarm-widgets.d.ts +2 -0
- package/dist/widgets/command-stepper.d.ts +22 -0
- package/dist/widgets/control-lazy.d.ts +16 -24
- package/dist/widgets/device-status.d.ts +4 -0
- package/dist/widgets/fleet-count.d.ts +2 -0
- package/dist/widgets/gauge.d.ts +2 -15
- package/dist/widgets/image.d.ts +2 -6
- package/dist/widgets/label.d.ts +2 -6
- package/dist/widgets/latest-card.d.ts +2 -13
- package/dist/widgets/lazy-chunk.d.ts +7 -2
- package/dist/widgets/level-lazy.d.ts +14 -96
- package/dist/widgets/map.d.ts +8 -5
- package/dist/widgets/online-doughnut.d.ts +2 -0
- package/dist/widgets/presence-lazy.d.ts +27 -0
- package/dist/widgets/presence-widgets.d.ts +3 -0
- package/dist/widgets/selection-lazy.d.ts +2 -4
- package/dist/widgets/table-lazy.d.ts +2 -7
- package/dist/widgets/time-series-chart.d.ts +62 -12
- package/package.json +13 -13
- package/dist/chunks/aggregate-feed-BD3CHNFU.js.map +0 -7
- package/dist/chunks/aggregate-widgets-HZQI5HTX.js.map +0 -7
- package/dist/chunks/alarm-widgets-7UY6MIYZ.js +0 -9
- package/dist/chunks/alarm-widgets-7UY6MIYZ.js.map +0 -7
- package/dist/chunks/chunk-2D7JNKFE.js.map +0 -7
- package/dist/chunks/chunk-6OGI4UFJ.js +0 -367
- package/dist/chunks/chunk-6OGI4UFJ.js.map +0 -7
- package/dist/chunks/chunk-WBKHYZU2.js.map +0 -7
- package/dist/chunks/control-widgets-3V2LSSRF.js.map +0 -7
- package/dist/chunks/fleet-feed-5QGDLOV5.js.map +0 -7
|
@@ -11,15 +11,15 @@ import {
|
|
|
11
11
|
// src/widgets/command-slider.tsx
|
|
12
12
|
import { useEffect as useEffect2, useId, useMemo, useRef as useRef2, useState as useState2 } from "react";
|
|
13
13
|
import {
|
|
14
|
-
css as
|
|
15
|
-
FIT_MIN_FONT_PX,
|
|
16
|
-
fitValueFont,
|
|
17
|
-
fitValueFontCss,
|
|
18
|
-
fontVar as
|
|
14
|
+
css as css3,
|
|
15
|
+
FIT_MIN_FONT_PX as FIT_MIN_FONT_PX2,
|
|
16
|
+
fitValueFont as fitValueFont2,
|
|
17
|
+
fitValueFontCss as fitValueFontCss2,
|
|
18
|
+
fontVar as fontVar3,
|
|
19
19
|
optNumber,
|
|
20
20
|
optString,
|
|
21
|
-
spaceVar as
|
|
22
|
-
useStickyChars,
|
|
21
|
+
spaceVar as spaceVar3,
|
|
22
|
+
useStickyChars as useStickyChars2,
|
|
23
23
|
WidgetFrame
|
|
24
24
|
} from "@devicechain/widget-sdk";
|
|
25
25
|
|
|
@@ -131,6 +131,17 @@ function lastSent(kind, commands, commandName, parameter, optimistic) {
|
|
|
131
131
|
return { token: newest.token, value: readValue(kind, newest.payload, parameter), status: newest.status };
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
+
// src/widgets/command-stepper.tsx
|
|
135
|
+
import {
|
|
136
|
+
css as css2,
|
|
137
|
+
FIT_MIN_FONT_PX,
|
|
138
|
+
fitValueFont,
|
|
139
|
+
fitValueFontCss,
|
|
140
|
+
fontVar as fontVar2,
|
|
141
|
+
spaceVar as spaceVar2,
|
|
142
|
+
useStickyChars
|
|
143
|
+
} from "@devicechain/widget-sdk";
|
|
144
|
+
|
|
134
145
|
// src/command-control.tsx
|
|
135
146
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
136
147
|
import { css, fontVar, spaceVar } from "@devicechain/widget-sdk";
|
|
@@ -156,6 +167,11 @@ var CONTROL_STRINGS = {
|
|
|
156
167
|
noValue: "no value",
|
|
157
168
|
unsent: "Not sent yet. Release or press Enter to send",
|
|
158
169
|
sliderHint: "Arrow keys choose a value; press Enter to send it, or Escape to discard it.",
|
|
170
|
+
stepperHint: "Arrow keys and Page Up or Down change the value; press Enter to send it, or Escape to discard it.",
|
|
171
|
+
stepperUnsent: "Not sent yet. Press Send",
|
|
172
|
+
send: "Send",
|
|
173
|
+
decrease: "Decrease",
|
|
174
|
+
increase: "Increase",
|
|
159
175
|
pending: "Pending",
|
|
160
176
|
delivered: "Delivered",
|
|
161
177
|
failed: "Failed",
|
|
@@ -186,6 +202,11 @@ var CONTROL_STRINGS = {
|
|
|
186
202
|
noValue: "sin valor",
|
|
187
203
|
unsent: "A\xFAn no enviado. Suelte o pulse Intro para enviar",
|
|
188
204
|
sliderHint: "Las flechas eligen un valor; pulse Intro para enviarlo o Escape para descartarlo.",
|
|
205
|
+
stepperHint: "Las flechas y Re P\xE1g o Av P\xE1g cambian el valor; pulse Intro para enviarlo o Escape para descartarlo.",
|
|
206
|
+
stepperUnsent: "A\xFAn no enviado. Pulse Enviar",
|
|
207
|
+
send: "Enviar",
|
|
208
|
+
decrease: "Disminuir",
|
|
209
|
+
increase: "Aumentar",
|
|
189
210
|
pending: "Pendiente",
|
|
190
211
|
delivered: "Entregado",
|
|
191
212
|
failed: "Fallido",
|
|
@@ -355,8 +376,161 @@ function LastSentCaption({
|
|
|
355
376
|
);
|
|
356
377
|
}
|
|
357
378
|
|
|
358
|
-
// src/widgets/command-
|
|
379
|
+
// src/widgets/command-stepper.tsx
|
|
359
380
|
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
381
|
+
var PAGE_STEPS = 10;
|
|
382
|
+
var button = (off) => ({
|
|
383
|
+
flex: "0 0 auto",
|
|
384
|
+
boxSizing: "border-box",
|
|
385
|
+
minWidth: TOUCH_TARGET_PX,
|
|
386
|
+
height: TOUCH_TARGET_PX,
|
|
387
|
+
padding: `0 ${spaceVar2(2)}`,
|
|
388
|
+
border: `1px solid ${css2("border")}`,
|
|
389
|
+
borderRadius: 6,
|
|
390
|
+
background: css2("card"),
|
|
391
|
+
color: css2("foreground"),
|
|
392
|
+
font: "inherit",
|
|
393
|
+
fontSize: fontVar2("md"),
|
|
394
|
+
fontWeight: 600,
|
|
395
|
+
cursor: off ? "not-allowed" : "pointer",
|
|
396
|
+
opacity: off ? 0.5 : 1
|
|
397
|
+
});
|
|
398
|
+
function StepperBody({
|
|
399
|
+
binding,
|
|
400
|
+
label,
|
|
401
|
+
draft,
|
|
402
|
+
lastValue,
|
|
403
|
+
sender,
|
|
404
|
+
captionId,
|
|
405
|
+
hintId,
|
|
406
|
+
caption,
|
|
407
|
+
onStage,
|
|
408
|
+
onCommit,
|
|
409
|
+
onDiscard,
|
|
410
|
+
scale: ws
|
|
411
|
+
}) {
|
|
412
|
+
const range = binding.range;
|
|
413
|
+
const unit = binding.param.unit;
|
|
414
|
+
const busy = sender.pending;
|
|
415
|
+
const inert = !sender.canSend || busy;
|
|
416
|
+
const rest = lastValue !== void 0 ? clampToRange(range, lastValue) : range.min;
|
|
417
|
+
const shown = draft ?? rest;
|
|
418
|
+
const known = draft !== null || lastValue !== void 0;
|
|
419
|
+
const readout = known ? String(shown) : "\u2014";
|
|
420
|
+
const text = unit && known ? `${shown} ${unit}` : String(shown);
|
|
421
|
+
const by = (steps) => {
|
|
422
|
+
if (inert) return;
|
|
423
|
+
const next = clampToRange(range, shown + steps * range.step);
|
|
424
|
+
if (next !== shown || draft === null) onStage(next);
|
|
425
|
+
};
|
|
426
|
+
const canSendNow = draft !== null && !inert;
|
|
427
|
+
const chars = useStickyChars(readout.length + (unit && known ? Math.ceil(unit.length / 2) + 1 : 0));
|
|
428
|
+
const floor = Math.round(FIT_MIN_FONT_PX * ws.scale);
|
|
429
|
+
const measured = ws.size.width > 0 && ws.size.height > 0;
|
|
430
|
+
const font = measured ? fitValueFont({ width: Math.floor(ws.size.width * 0.3), height: Math.max(TOUCH_TARGET_PX, Math.floor(ws.size.height * 0.5)) }, chars, { floor }) : fitValueFontCss(chars, { floor });
|
|
431
|
+
const key = (e) => {
|
|
432
|
+
const k = e.key;
|
|
433
|
+
if (k === "ArrowUp" || k === "ArrowRight") by(1);
|
|
434
|
+
else if (k === "ArrowDown" || k === "ArrowLeft") by(-1);
|
|
435
|
+
else if (k === "PageUp") by(PAGE_STEPS);
|
|
436
|
+
else if (k === "PageDown") by(-PAGE_STEPS);
|
|
437
|
+
else if (k === "Home") inert || onStage(range.min);
|
|
438
|
+
else if (k === "End") inert || onStage(range.max);
|
|
439
|
+
else if (k === "Enter") onCommit();
|
|
440
|
+
else if (k === "Escape") onDiscard();
|
|
441
|
+
else return;
|
|
442
|
+
e.preventDefault();
|
|
443
|
+
};
|
|
444
|
+
const atMin = shown <= range.min;
|
|
445
|
+
const atMax = shown >= range.max;
|
|
446
|
+
return /* @__PURE__ */ jsxs2(
|
|
447
|
+
"div",
|
|
448
|
+
{
|
|
449
|
+
style: { height: "100%", boxSizing: "border-box", display: "flex", flexDirection: "column", justifyContent: "safe center", gap: spaceVar2(1), overflow: "hidden" },
|
|
450
|
+
children: [
|
|
451
|
+
/* @__PURE__ */ jsxs2("div", { style: { display: "flex", alignItems: "center", gap: spaceVar2(1), minHeight: TOUCH_TARGET_PX }, children: [
|
|
452
|
+
/* @__PURE__ */ jsx2(
|
|
453
|
+
"button",
|
|
454
|
+
{
|
|
455
|
+
type: "button",
|
|
456
|
+
tabIndex: -1,
|
|
457
|
+
"aria-label": sender.strings.decrease,
|
|
458
|
+
"aria-disabled": inert || atMin || void 0,
|
|
459
|
+
"data-step": "down",
|
|
460
|
+
onClick: () => by(-1),
|
|
461
|
+
style: button(inert || atMin),
|
|
462
|
+
children: "\u2212"
|
|
463
|
+
}
|
|
464
|
+
),
|
|
465
|
+
/* @__PURE__ */ jsxs2(
|
|
466
|
+
"div",
|
|
467
|
+
{
|
|
468
|
+
role: "spinbutton",
|
|
469
|
+
tabIndex: 0,
|
|
470
|
+
"aria-label": label,
|
|
471
|
+
"aria-valuemin": range.min,
|
|
472
|
+
"aria-valuemax": range.max,
|
|
473
|
+
"aria-valuenow": known ? shown : void 0,
|
|
474
|
+
"aria-valuetext": known ? text : sender.strings.noValue,
|
|
475
|
+
"aria-describedby": `${hintId} ${captionId}${sender.readOnlyReason ? ` ${readOnlyId(captionId)}` : ""}`,
|
|
476
|
+
"aria-disabled": inert || void 0,
|
|
477
|
+
"aria-busy": busy || void 0,
|
|
478
|
+
"data-staged": draft !== null ? "true" : void 0,
|
|
479
|
+
onKeyDown: key,
|
|
480
|
+
style: {
|
|
481
|
+
flex: "1 1 0",
|
|
482
|
+
minWidth: 0,
|
|
483
|
+
textAlign: "center",
|
|
484
|
+
fontSize: font,
|
|
485
|
+
fontWeight: 600,
|
|
486
|
+
lineHeight: 1.1,
|
|
487
|
+
whiteSpace: "nowrap",
|
|
488
|
+
fontVariantNumeric: "tabular-nums",
|
|
489
|
+
color: draft !== null ? css2("foreground") : css2("muted-foreground")
|
|
490
|
+
},
|
|
491
|
+
children: [
|
|
492
|
+
readout,
|
|
493
|
+
unit && known ? /* @__PURE__ */ jsx2("span", { style: { fontSize: fontVar2("sm"), marginLeft: spaceVar2(1), color: css2("muted-foreground") }, children: unit }) : null
|
|
494
|
+
]
|
|
495
|
+
}
|
|
496
|
+
),
|
|
497
|
+
/* @__PURE__ */ jsx2(
|
|
498
|
+
"button",
|
|
499
|
+
{
|
|
500
|
+
type: "button",
|
|
501
|
+
tabIndex: -1,
|
|
502
|
+
"aria-label": sender.strings.increase,
|
|
503
|
+
"aria-disabled": inert || atMax || void 0,
|
|
504
|
+
"data-step": "up",
|
|
505
|
+
onClick: () => by(1),
|
|
506
|
+
style: button(inert || atMax),
|
|
507
|
+
children: "+"
|
|
508
|
+
}
|
|
509
|
+
),
|
|
510
|
+
/* @__PURE__ */ jsx2(
|
|
511
|
+
"button",
|
|
512
|
+
{
|
|
513
|
+
type: "button",
|
|
514
|
+
"aria-disabled": !canSendNow || void 0,
|
|
515
|
+
"data-step": "send",
|
|
516
|
+
onClick: () => canSendNow && onCommit(),
|
|
517
|
+
style: { ...button(!canSendNow), background: canSendNow ? css2("primary") : css2("card"), color: canSendNow ? css2("primary-foreground") : css2("foreground") },
|
|
518
|
+
children: sender.strings.send
|
|
519
|
+
}
|
|
520
|
+
),
|
|
521
|
+
/* @__PURE__ */ jsx2("span", { id: hintId, hidden: true, children: sender.strings.stepperHint })
|
|
522
|
+
] }),
|
|
523
|
+
/* @__PURE__ */ jsxs2("div", { style: { display: "flex", flexWrap: "wrap", alignItems: "baseline", columnGap: spaceVar2(2) }, children: [
|
|
524
|
+
caption,
|
|
525
|
+
/* @__PURE__ */ jsx2(ControlNotes, { sender, captionId })
|
|
526
|
+
] })
|
|
527
|
+
]
|
|
528
|
+
}
|
|
529
|
+
);
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
// src/widgets/command-slider.tsx
|
|
533
|
+
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
360
534
|
var withUnit = (v, unit) => unit ? `${v} ${unit}` : String(v);
|
|
361
535
|
function CommandSlider({ widget, data, actions }) {
|
|
362
536
|
const commandName = optString(widget.options, "commandName");
|
|
@@ -366,6 +540,7 @@ function CommandSlider({ widget, data, actions }) {
|
|
|
366
540
|
const min = optNumber(widget.options, "min");
|
|
367
541
|
const max = optNumber(widget.options, "max");
|
|
368
542
|
const step = optNumber(widget.options, "step");
|
|
543
|
+
const stepper = optString(widget.options, "mode") === "stepper";
|
|
369
544
|
const binding = useMemo(
|
|
370
545
|
() => bindControl("number", { commandName, parameterSchema, parameter, min, max, step }),
|
|
371
546
|
[commandName, parameterSchema, parameter, min, max, step]
|
|
@@ -385,6 +560,12 @@ function CommandSlider({ widget, data, actions }) {
|
|
|
385
560
|
};
|
|
386
561
|
const captionId = useId();
|
|
387
562
|
const hintId = useId();
|
|
563
|
+
const lastToken = last?.token;
|
|
564
|
+
useEffect2(() => {
|
|
565
|
+
if (!stepper || draftRef.current === null) return;
|
|
566
|
+
draftRef.current = null;
|
|
567
|
+
setDraftState(null);
|
|
568
|
+
}, [lastToken, stepper]);
|
|
388
569
|
const pressed = useRef2(false);
|
|
389
570
|
const offRelease = useRef2(null);
|
|
390
571
|
useEffect2(() => () => offRelease.current?.(), []);
|
|
@@ -417,9 +598,23 @@ function CommandSlider({ widget, data, actions }) {
|
|
|
417
598
|
offRelease.current = null;
|
|
418
599
|
commit();
|
|
419
600
|
};
|
|
420
|
-
|
|
421
|
-
|
|
601
|
+
const caption = binding.ok ? /* @__PURE__ */ jsx3(
|
|
602
|
+
LastSentCaption,
|
|
422
603
|
{
|
|
604
|
+
id: captionId,
|
|
605
|
+
last,
|
|
606
|
+
strings: sender.strings,
|
|
607
|
+
truncated: data.total > data.commands.length,
|
|
608
|
+
format: (v) => typeof v === "number" ? withUnit(v, binding.param.unit) : sender.strings.noValue,
|
|
609
|
+
override: draft !== null ? stepper ? sender.strings.stepperUnsent : sender.strings.unsent : sender.pending ? sender.strings.sending : void 0
|
|
610
|
+
}
|
|
611
|
+
) : null;
|
|
612
|
+
const onStage = (v) => {
|
|
613
|
+
if (binding.ok && !sender.pending) setDraft(clampToRange(binding.range, v));
|
|
614
|
+
};
|
|
615
|
+
return /* @__PURE__ */ jsx3(WidgetFrame, { title: optString(widget.options, "title"), children: (scale) => {
|
|
616
|
+
if (!binding.ok) return /* @__PURE__ */ jsx3(ControlEmpty, { message: refusalText(binding.refusal, sender.strings, "number") });
|
|
617
|
+
const common = {
|
|
423
618
|
binding,
|
|
424
619
|
label: commandLabel ?? binding.param.name,
|
|
425
620
|
draft,
|
|
@@ -427,30 +622,24 @@ function CommandSlider({ widget, data, actions }) {
|
|
|
427
622
|
sender,
|
|
428
623
|
captionId,
|
|
429
624
|
hintId,
|
|
430
|
-
caption
|
|
431
|
-
|
|
432
|
-
{
|
|
433
|
-
id: captionId,
|
|
434
|
-
last,
|
|
435
|
-
strings: sender.strings,
|
|
436
|
-
truncated: data.total > data.commands.length,
|
|
437
|
-
format: (v) => typeof v === "number" ? withUnit(v, binding.param.unit) : sender.strings.noValue,
|
|
438
|
-
override: draft !== null ? sender.strings.unsent : sender.pending ? sender.strings.sending : void 0
|
|
439
|
-
}
|
|
440
|
-
),
|
|
441
|
-
onStage: (v) => {
|
|
442
|
-
if (!sender.pending) setDraft(clampToRange(binding.range, v));
|
|
443
|
-
},
|
|
625
|
+
caption,
|
|
626
|
+
onStage,
|
|
444
627
|
onCommit: commit,
|
|
445
|
-
onPress: press,
|
|
446
|
-
onRelease: release,
|
|
447
628
|
onDiscard: discard,
|
|
448
|
-
onLostCapture: () => {
|
|
449
|
-
if (pressed.current) discard();
|
|
450
|
-
},
|
|
451
629
|
scale
|
|
452
|
-
}
|
|
453
|
-
|
|
630
|
+
};
|
|
631
|
+
return stepper ? /* @__PURE__ */ jsx3(StepperBody, { ...common }) : /* @__PURE__ */ jsx3(
|
|
632
|
+
SliderBody,
|
|
633
|
+
{
|
|
634
|
+
...common,
|
|
635
|
+
onPress: press,
|
|
636
|
+
onRelease: release,
|
|
637
|
+
onLostCapture: () => {
|
|
638
|
+
if (pressed.current) discard();
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
);
|
|
642
|
+
} });
|
|
454
643
|
}
|
|
455
644
|
function SliderBody({
|
|
456
645
|
binding,
|
|
@@ -477,15 +666,15 @@ function SliderBody({
|
|
|
477
666
|
const shown = draft ?? rest;
|
|
478
667
|
const known = draft !== null || lastValue !== void 0;
|
|
479
668
|
const readout = known ? String(shown) : "\u2014";
|
|
480
|
-
const chars =
|
|
481
|
-
const floor = Math.round(
|
|
669
|
+
const chars = useStickyChars2(readout.length + (unit && known ? Math.ceil(unit.length / 2) + 1 : 0));
|
|
670
|
+
const floor = Math.round(FIT_MIN_FONT_PX2 * ws.scale);
|
|
482
671
|
const measured = ws.size.width > 0 && ws.size.height > 0;
|
|
483
672
|
const room = {
|
|
484
673
|
width: Math.floor(ws.size.width * 0.34),
|
|
485
674
|
height: Math.max(TOUCH_TARGET_PX, Math.floor(ws.size.height * 0.5))
|
|
486
675
|
};
|
|
487
|
-
const font = measured ?
|
|
488
|
-
return /* @__PURE__ */
|
|
676
|
+
const font = measured ? fitValueFont2(room, chars, { floor }) : fitValueFontCss2(chars, { floor });
|
|
677
|
+
return /* @__PURE__ */ jsxs3(
|
|
489
678
|
"div",
|
|
490
679
|
{
|
|
491
680
|
style: {
|
|
@@ -494,12 +683,12 @@ function SliderBody({
|
|
|
494
683
|
display: "flex",
|
|
495
684
|
flexDirection: "column",
|
|
496
685
|
justifyContent: "safe center",
|
|
497
|
-
gap:
|
|
686
|
+
gap: spaceVar3(1),
|
|
498
687
|
overflow: "hidden"
|
|
499
688
|
},
|
|
500
689
|
children: [
|
|
501
|
-
/* @__PURE__ */
|
|
502
|
-
/* @__PURE__ */
|
|
690
|
+
/* @__PURE__ */ jsxs3("div", { style: { display: "flex", alignItems: "center", gap: spaceVar3(2), minHeight: TOUCH_TARGET_PX }, children: [
|
|
691
|
+
/* @__PURE__ */ jsx3(
|
|
503
692
|
"input",
|
|
504
693
|
{
|
|
505
694
|
type: "range",
|
|
@@ -529,13 +718,13 @@ function SliderBody({
|
|
|
529
718
|
minWidth: 0,
|
|
530
719
|
height: TOUCH_TARGET_PX,
|
|
531
720
|
margin: 0,
|
|
532
|
-
accentColor:
|
|
721
|
+
accentColor: css3("primary"),
|
|
533
722
|
cursor: disabled || busy ? "not-allowed" : "pointer"
|
|
534
723
|
}
|
|
535
724
|
}
|
|
536
725
|
),
|
|
537
|
-
/* @__PURE__ */
|
|
538
|
-
/* @__PURE__ */
|
|
726
|
+
/* @__PURE__ */ jsx3("span", { id: hintId, hidden: true, children: sender.strings.sliderHint }),
|
|
727
|
+
/* @__PURE__ */ jsxs3(
|
|
539
728
|
"output",
|
|
540
729
|
{
|
|
541
730
|
"aria-hidden": "true",
|
|
@@ -547,18 +736,18 @@ function SliderBody({
|
|
|
547
736
|
lineHeight: 1.1,
|
|
548
737
|
whiteSpace: "nowrap",
|
|
549
738
|
fontVariantNumeric: "tabular-nums",
|
|
550
|
-
color: draft !== null ?
|
|
739
|
+
color: draft !== null ? css3("foreground") : css3("muted-foreground")
|
|
551
740
|
},
|
|
552
741
|
children: [
|
|
553
742
|
readout,
|
|
554
|
-
unit && known ? /* @__PURE__ */
|
|
743
|
+
unit && known ? /* @__PURE__ */ jsx3("span", { style: { fontSize: fontVar3("sm"), marginLeft: spaceVar3(1), color: css3("muted-foreground") }, children: unit }) : null
|
|
555
744
|
]
|
|
556
745
|
}
|
|
557
746
|
)
|
|
558
747
|
] }),
|
|
559
|
-
/* @__PURE__ */
|
|
748
|
+
/* @__PURE__ */ jsxs3("div", { style: { display: "flex", flexWrap: "wrap", alignItems: "baseline", columnGap: spaceVar3(2) }, children: [
|
|
560
749
|
caption,
|
|
561
|
-
/* @__PURE__ */
|
|
750
|
+
/* @__PURE__ */ jsx3(ControlNotes, { sender, captionId })
|
|
562
751
|
] })
|
|
563
752
|
]
|
|
564
753
|
}
|
|
@@ -568,16 +757,16 @@ function SliderBody({
|
|
|
568
757
|
// src/widgets/command-toggle.tsx
|
|
569
758
|
import { useId as useId2, useMemo as useMemo2 } from "react";
|
|
570
759
|
import {
|
|
571
|
-
css as
|
|
572
|
-
FIT_MIN_FONT_PX as
|
|
573
|
-
fitValueFont as
|
|
574
|
-
fitValueFontCss as
|
|
760
|
+
css as css4,
|
|
761
|
+
FIT_MIN_FONT_PX as FIT_MIN_FONT_PX3,
|
|
762
|
+
fitValueFont as fitValueFont3,
|
|
763
|
+
fitValueFontCss as fitValueFontCss3,
|
|
575
764
|
optString as optString2,
|
|
576
|
-
spaceVar as
|
|
577
|
-
useStickyChars as
|
|
765
|
+
spaceVar as spaceVar4,
|
|
766
|
+
useStickyChars as useStickyChars3,
|
|
578
767
|
WidgetFrame as WidgetFrame2
|
|
579
768
|
} from "@devicechain/widget-sdk";
|
|
580
|
-
import { jsx as
|
|
769
|
+
import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
581
770
|
var TRACK_W = 52;
|
|
582
771
|
var TRACK_H = 30;
|
|
583
772
|
var THUMB = 24;
|
|
@@ -598,7 +787,7 @@ function CommandToggle({ widget, data, actions }) {
|
|
|
598
787
|
);
|
|
599
788
|
const last = binding.ok && commandName ? lastSent("boolean", data.commands, commandName, binding.param.name, sender.optimistic) : null;
|
|
600
789
|
const captionId = useId2();
|
|
601
|
-
return /* @__PURE__ */
|
|
790
|
+
return /* @__PURE__ */ jsx4(WidgetFrame2, { title: optString2(widget.options, "title"), children: (scale) => !binding.ok ? /* @__PURE__ */ jsx4(ControlEmpty, { message: refusalText(binding.refusal, sender.strings, "boolean") }) : /* @__PURE__ */ jsx4(
|
|
602
791
|
ToggleBody,
|
|
603
792
|
{
|
|
604
793
|
binding,
|
|
@@ -606,7 +795,7 @@ function CommandToggle({ widget, data, actions }) {
|
|
|
606
795
|
value: intentOf(last),
|
|
607
796
|
sender,
|
|
608
797
|
captionId,
|
|
609
|
-
caption: /* @__PURE__ */
|
|
798
|
+
caption: /* @__PURE__ */ jsx4(
|
|
610
799
|
LastSentCaption,
|
|
611
800
|
{
|
|
612
801
|
id: captionId,
|
|
@@ -639,18 +828,18 @@ function ToggleBody({
|
|
|
639
828
|
const unknown = value === void 0;
|
|
640
829
|
const disabled = !sender.canSend;
|
|
641
830
|
const word = checked ? sender.strings.on : sender.strings.off;
|
|
642
|
-
const chars =
|
|
643
|
-
const floor = Math.round(
|
|
831
|
+
const chars = useStickyChars3(word.length);
|
|
832
|
+
const floor = Math.round(FIT_MIN_FONT_PX3 * ws.scale);
|
|
644
833
|
const measured = ws.size.width > 0 && ws.size.height > 0;
|
|
645
834
|
const room = {
|
|
646
835
|
width: Math.floor(ws.size.width - TRACK_W - 16),
|
|
647
836
|
height: Math.max(TOUCH_TARGET_PX, Math.floor(ws.size.height * 0.5))
|
|
648
837
|
};
|
|
649
|
-
const font = measured ?
|
|
838
|
+
const font = measured ? fitValueFont3(room, chars, { floor }) : fitValueFontCss3(chars, { floor });
|
|
650
839
|
const sendValue = (next) => {
|
|
651
840
|
sender.send(payloadFor(binding, next), next);
|
|
652
841
|
};
|
|
653
|
-
return /* @__PURE__ */
|
|
842
|
+
return /* @__PURE__ */ jsxs4(
|
|
654
843
|
"div",
|
|
655
844
|
{
|
|
656
845
|
style: {
|
|
@@ -659,11 +848,11 @@ function ToggleBody({
|
|
|
659
848
|
display: "flex",
|
|
660
849
|
flexDirection: "column",
|
|
661
850
|
justifyContent: "safe center",
|
|
662
|
-
gap:
|
|
851
|
+
gap: spaceVar4(1),
|
|
663
852
|
overflow: "hidden"
|
|
664
853
|
},
|
|
665
854
|
children: [
|
|
666
|
-
unknown ? /* @__PURE__ */
|
|
855
|
+
unknown ? /* @__PURE__ */ jsx4("div", { role: "group", "aria-label": label, "aria-describedby": sender.readOnlyReason ? `${captionId} ${readOnlyId(captionId)}` : captionId, "data-toggle-choose": "", style: { display: "flex", gap: spaceVar4(2) }, children: [true, false].map((v) => /* @__PURE__ */ jsx4(
|
|
667
856
|
"button",
|
|
668
857
|
{
|
|
669
858
|
type: "button",
|
|
@@ -674,11 +863,11 @@ function ToggleBody({
|
|
|
674
863
|
flex: "1 1 0",
|
|
675
864
|
minHeight: TOUCH_TARGET_PX,
|
|
676
865
|
minWidth: TOUCH_TARGET_PX,
|
|
677
|
-
padding: `0 ${
|
|
866
|
+
padding: `0 ${spaceVar4(2)}`,
|
|
678
867
|
borderRadius: 6,
|
|
679
|
-
border: `1px solid ${
|
|
680
|
-
background:
|
|
681
|
-
color:
|
|
868
|
+
border: `1px solid ${css4("border")}`,
|
|
869
|
+
background: css4("background"),
|
|
870
|
+
color: css4("foreground"),
|
|
682
871
|
fontWeight: 600,
|
|
683
872
|
cursor: disabled ? "not-allowed" : "pointer",
|
|
684
873
|
opacity: disabled ? 0.6 : 1
|
|
@@ -686,7 +875,7 @@ function ToggleBody({
|
|
|
686
875
|
children: v ? sender.strings.on : sender.strings.off
|
|
687
876
|
},
|
|
688
877
|
String(v)
|
|
689
|
-
)) }) : /* @__PURE__ */
|
|
878
|
+
)) }) : /* @__PURE__ */ jsxs4(
|
|
690
879
|
"button",
|
|
691
880
|
{
|
|
692
881
|
type: "button",
|
|
@@ -700,19 +889,19 @@ function ToggleBody({
|
|
|
700
889
|
style: {
|
|
701
890
|
display: "flex",
|
|
702
891
|
alignItems: "center",
|
|
703
|
-
gap:
|
|
892
|
+
gap: spaceVar4(2),
|
|
704
893
|
minHeight: TOUCH_TARGET_PX,
|
|
705
894
|
minWidth: TOUCH_TARGET_PX,
|
|
706
895
|
padding: 0,
|
|
707
896
|
border: "none",
|
|
708
897
|
background: "transparent",
|
|
709
|
-
color:
|
|
898
|
+
color: css4("foreground"),
|
|
710
899
|
cursor: disabled ? "not-allowed" : "pointer",
|
|
711
900
|
opacity: disabled ? 0.6 : 1,
|
|
712
901
|
textAlign: "left"
|
|
713
902
|
},
|
|
714
903
|
children: [
|
|
715
|
-
/* @__PURE__ */
|
|
904
|
+
/* @__PURE__ */ jsx4(
|
|
716
905
|
"span",
|
|
717
906
|
{
|
|
718
907
|
"aria-hidden": "true",
|
|
@@ -723,10 +912,10 @@ function ToggleBody({
|
|
|
723
912
|
height: TRACK_H,
|
|
724
913
|
borderRadius: TRACK_H / 2,
|
|
725
914
|
boxSizing: "border-box",
|
|
726
|
-
border: `1px solid ${
|
|
727
|
-
background: checked ?
|
|
915
|
+
border: `1px solid ${css4("border")}`,
|
|
916
|
+
background: checked ? css4("primary") : css4("muted")
|
|
728
917
|
},
|
|
729
|
-
children: /* @__PURE__ */
|
|
918
|
+
children: /* @__PURE__ */ jsx4(
|
|
730
919
|
"span",
|
|
731
920
|
{
|
|
732
921
|
style: {
|
|
@@ -736,15 +925,15 @@ function ToggleBody({
|
|
|
736
925
|
width: THUMB,
|
|
737
926
|
height: THUMB,
|
|
738
927
|
borderRadius: "50%",
|
|
739
|
-
background: checked ?
|
|
740
|
-
border: `1px solid ${
|
|
928
|
+
background: checked ? css4("primary-foreground") : css4("background"),
|
|
929
|
+
border: `1px solid ${css4("border")}`,
|
|
741
930
|
boxSizing: "border-box"
|
|
742
931
|
}
|
|
743
932
|
}
|
|
744
933
|
)
|
|
745
934
|
}
|
|
746
935
|
),
|
|
747
|
-
/* @__PURE__ */
|
|
936
|
+
/* @__PURE__ */ jsx4(
|
|
748
937
|
"span",
|
|
749
938
|
{
|
|
750
939
|
"data-toggle-word": "",
|
|
@@ -753,7 +942,7 @@ function ToggleBody({
|
|
|
753
942
|
fontWeight: 600,
|
|
754
943
|
lineHeight: 1.1,
|
|
755
944
|
whiteSpace: "nowrap",
|
|
756
|
-
color:
|
|
945
|
+
color: css4("foreground")
|
|
757
946
|
},
|
|
758
947
|
children: word
|
|
759
948
|
}
|
|
@@ -761,9 +950,9 @@ function ToggleBody({
|
|
|
761
950
|
]
|
|
762
951
|
}
|
|
763
952
|
),
|
|
764
|
-
/* @__PURE__ */
|
|
953
|
+
/* @__PURE__ */ jsxs4("div", { style: { display: "flex", flexWrap: "wrap", alignItems: "baseline", columnGap: spaceVar4(2) }, children: [
|
|
765
954
|
caption,
|
|
766
|
-
/* @__PURE__ */
|
|
955
|
+
/* @__PURE__ */ jsx4(ControlNotes, { sender, captionId })
|
|
767
956
|
] })
|
|
768
957
|
]
|
|
769
958
|
}
|
|
@@ -774,4 +963,4 @@ export {
|
|
|
774
963
|
CommandSlider,
|
|
775
964
|
CommandToggle
|
|
776
965
|
};
|
|
777
|
-
//# sourceMappingURL=control-widgets-
|
|
966
|
+
//# sourceMappingURL=control-widgets-UCTJJJ2D.js.map
|