twico-ui 1.11.0 → 1.12.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/CHANGELOG.md +28 -0
- package/dist/index.cjs +1690 -214
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +478 -72
- package/dist/index.d.ts +478 -72
- package/dist/index.mjs +1686 -215
- package/dist/index.mjs.map +1 -1
- package/llms.txt +308 -3
- package/package.json +6 -6
package/dist/index.mjs
CHANGED
|
@@ -363,6 +363,12 @@ var ACCORDION_CSS = `
|
|
|
363
363
|
transition: grid-template-rows var(--duration-base) var(--ease-standard), visibility 0s; }
|
|
364
364
|
.twc-accordion__panel-inner { overflow: hidden; }
|
|
365
365
|
.twc-accordion__content { padding: 0 var(--space-4) var(--space-4); font-size: var(--text-sm); color: var(--color-text-muted); line-height: var(--leading-normal); }
|
|
366
|
+
/* WCAG 2.3.3: panels expand/collapse (and the chevron rotates) instantly under reduced motion
|
|
367
|
+
\u2014 visibility still toggles, so open/closed state is unchanged. */
|
|
368
|
+
@media (prefers-reduced-motion: reduce) {
|
|
369
|
+
.twc-accordion__panel, .twc-accordion__panel[data-open="true"] { transition: none; }
|
|
370
|
+
.twc-accordion__chevron { transition: none; }
|
|
371
|
+
}
|
|
366
372
|
`;
|
|
367
373
|
function Accordion({
|
|
368
374
|
items,
|
|
@@ -1122,6 +1128,9 @@ var CSS2 = `
|
|
|
1122
1128
|
transform: scale(0); pointer-events: none;
|
|
1123
1129
|
animation: twico-ripple var(--duration-slow) var(--ease-out) forwards;
|
|
1124
1130
|
}
|
|
1131
|
+
/* WCAG 2.3.3: suppress the click ripple entirely under reduced motion (display:none, not
|
|
1132
|
+
animation:none, so no static scale(0) dot lingers for the 600ms cleanup window). */
|
|
1133
|
+
@media (prefers-reduced-motion: reduce) { .twc-ripple { display: none; } }
|
|
1125
1134
|
`;
|
|
1126
1135
|
function safeHref4(url) {
|
|
1127
1136
|
if (url == null) return void 0;
|
|
@@ -1481,6 +1490,13 @@ var CAROUSEL_CSS = `
|
|
|
1481
1490
|
.twc-carousel__pause svg { width: 15px; height: 15px; display: block; }
|
|
1482
1491
|
.twc-carousel__live { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
|
|
1483
1492
|
overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }
|
|
1493
|
+
/* WCAG 2.3.3: no slide/dot/arrow motion when the user asks for reduced motion \u2014 the index
|
|
1494
|
+
still changes, it just jumps rather than tweening. */
|
|
1495
|
+
@media (prefers-reduced-motion: reduce) {
|
|
1496
|
+
.twc-carousel__track { transition: none; }
|
|
1497
|
+
.twc-carousel__dot { transition: none; }
|
|
1498
|
+
.twc-carousel__arrow { transition: none; }
|
|
1499
|
+
}
|
|
1484
1500
|
`;
|
|
1485
1501
|
function Carousel({
|
|
1486
1502
|
children,
|
|
@@ -1582,7 +1598,7 @@ function Carousel({
|
|
|
1582
1598
|
/* @__PURE__ */ jsx("button", { className: "twc-carousel__arrow", "data-dir": "prev", "aria-label": "Previous", disabled: atStart, onClick: () => go(index - 1), children: /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.4", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsx("path", { d: "m15 18-6-6 6-6" }) }) }),
|
|
1583
1599
|
/* @__PURE__ */ jsx("button", { className: "twc-carousel__arrow", "data-dir": "next", "aria-label": "Next", disabled: atEnd, onClick: () => go(index + 1), children: /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.4", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsx("path", { d: "m9 18 6-6-6-6" }) }) })
|
|
1584
1600
|
] }) : null,
|
|
1585
|
-
showDots && count > 1 ? /* @__PURE__ */ jsx("div", { className: "twc-carousel__dots", children: slides.map((_, i) => /* @__PURE__ */ jsx("button", { className: "twc-carousel__dot", "data-active": i === index || void 0, "aria-label": `Go to slide ${i + 1}`, onClick: () => go(i) }, i)) }) : null
|
|
1601
|
+
showDots && count > 1 ? /* @__PURE__ */ jsx("div", { className: "twc-carousel__dots", children: slides.map((_, i) => /* @__PURE__ */ jsx("button", { className: "twc-carousel__dot", "data-active": i === index || void 0, "aria-current": i === index ? "true" : void 0, "aria-label": `Go to slide ${i + 1}`, onClick: () => go(i) }, i)) }) : null
|
|
1586
1602
|
]
|
|
1587
1603
|
}
|
|
1588
1604
|
);
|
|
@@ -1610,9 +1626,9 @@ function niceCeil(v) {
|
|
|
1610
1626
|
const step = n <= 1 ? 1 : n <= 2 ? 2 : n <= 5 ? 5 : 10;
|
|
1611
1627
|
return step * pow;
|
|
1612
1628
|
}
|
|
1613
|
-
function niceNum(
|
|
1614
|
-
const exp = Math.floor(Math.log10(
|
|
1615
|
-
const frac = (
|
|
1629
|
+
function niceNum(range2, round) {
|
|
1630
|
+
const exp = Math.floor(Math.log10(range2 || 1));
|
|
1631
|
+
const frac = (range2 || 1) / Math.pow(10, exp);
|
|
1616
1632
|
let nf;
|
|
1617
1633
|
if (round) nf = frac < 1.5 ? 1 : frac < 3 ? 2 : frac < 7 ? 5 : 10;
|
|
1618
1634
|
else nf = frac <= 1 ? 1 : frac <= 2 ? 2 : frac <= 5 ? 5 : 10;
|
|
@@ -1623,8 +1639,8 @@ function niceScale(min, max, maxTicks = 5) {
|
|
|
1623
1639
|
if (min === max) {
|
|
1624
1640
|
max = min + 1;
|
|
1625
1641
|
}
|
|
1626
|
-
const
|
|
1627
|
-
const step = niceNum(
|
|
1642
|
+
const range2 = niceNum(max - min, false);
|
|
1643
|
+
const step = niceNum(range2 / Math.max(1, maxTicks - 1), true);
|
|
1628
1644
|
const niceMin = Math.floor(min / step) * step;
|
|
1629
1645
|
const niceMax = Math.ceil(max / step) * step;
|
|
1630
1646
|
const ticks = [];
|
|
@@ -2402,7 +2418,7 @@ function PieChart({
|
|
|
2402
2418
|
styles,
|
|
2403
2419
|
/* @__PURE__ */ jsx("svg", { viewBox: `0 0 ${H} ${H}`, role: "img", "aria-label": svgAriaLabel, "aria-describedby": tableId, children: total <= 0 ? /* @__PURE__ */ jsx("text", { className: "twc-chart__empty", x: cx, y: cy, textAnchor: "middle", dominantBaseline: "middle", children: "No data" }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2404
2420
|
slices.map(({ d, i, v, s0, s1, span, pct, color }) => {
|
|
2405
|
-
const
|
|
2421
|
+
const pad2 = span > padAngle ? padAngle / 2 : 0;
|
|
2406
2422
|
const items = [{ color, label: fmt(v), value: `${pct}%` }];
|
|
2407
2423
|
let explode;
|
|
2408
2424
|
if (selected === i) {
|
|
@@ -2421,7 +2437,7 @@ function PieChart({
|
|
|
2421
2437
|
"data-mark": "",
|
|
2422
2438
|
"data-active": emph === i ? "true" : void 0,
|
|
2423
2439
|
"data-selected": selected === i ? "true" : void 0,
|
|
2424
|
-
d: arcPath(cx, cy, rOuter, rInner, s0 +
|
|
2440
|
+
d: arcPath(cx, cy, rOuter, rInner, s0 + pad2, s1 - pad2),
|
|
2425
2441
|
onMouseMove: (e) => {
|
|
2426
2442
|
setActive(i);
|
|
2427
2443
|
show({ title: d.label, items }, e);
|
|
@@ -2523,9 +2539,9 @@ function Gauge({
|
|
|
2523
2539
|
const cx = size / 2, cy = size / 2;
|
|
2524
2540
|
const span = endAngle - startAngle;
|
|
2525
2541
|
const frac = (v) => {
|
|
2526
|
-
const
|
|
2527
|
-
if (!
|
|
2528
|
-
return Math.max(0, Math.min(1, ((Number(v) || 0) - min) /
|
|
2542
|
+
const range2 = max - min;
|
|
2543
|
+
if (!range2) return 0;
|
|
2544
|
+
return Math.max(0, Math.min(1, ((Number(v) || 0) - min) / range2));
|
|
2529
2545
|
};
|
|
2530
2546
|
const isMulti = Array.isArray(series) && series.length > 0;
|
|
2531
2547
|
const items = isMulti ? series : [{ value: Number(value) || 0, label, color }];
|
|
@@ -2700,9 +2716,9 @@ function Sparkline({
|
|
|
2700
2716
|
const n = values.length;
|
|
2701
2717
|
const W = width, H = height;
|
|
2702
2718
|
const dotR = showDots ? Math.max(2, strokeWidth + 1) : 0;
|
|
2703
|
-
const
|
|
2704
|
-
const innerW = Math.max(1, W -
|
|
2705
|
-
const innerH = Math.max(1, H -
|
|
2719
|
+
const pad2 = Math.max(strokeWidth / 2, dotR) + 1;
|
|
2720
|
+
const innerW = Math.max(1, W - pad2 * 2);
|
|
2721
|
+
const innerH = Math.max(1, H - pad2 * 2);
|
|
2706
2722
|
const dMin = min != null ? min : n ? Math.min(...values) : 0;
|
|
2707
2723
|
const dMax = max != null ? max : n ? Math.max(...values) : 1;
|
|
2708
2724
|
let lo = dMin, hi = dMax;
|
|
@@ -2711,9 +2727,9 @@ function Sparkline({
|
|
|
2711
2727
|
hi = hi + 1;
|
|
2712
2728
|
}
|
|
2713
2729
|
const span = hi - lo;
|
|
2714
|
-
const x = (i) => n <= 1 ?
|
|
2715
|
-
const y = (v) =>
|
|
2716
|
-
const baselineY =
|
|
2730
|
+
const x = (i) => n <= 1 ? pad2 + innerW / 2 : pad2 + innerW / (n - 1) * i;
|
|
2731
|
+
const y = (v) => pad2 + innerH - (v - lo) / span * innerH;
|
|
2732
|
+
const baselineY = pad2 + innerH;
|
|
2717
2733
|
const points = values.map((v, i) => [x(i), y(v)]);
|
|
2718
2734
|
const crv = isBar ? "straight" : curve;
|
|
2719
2735
|
const pathOpts = { smooth: crv === "smooth", step: crv === "stepped" ? "after" : null };
|
|
@@ -2745,7 +2761,7 @@ function Sparkline({
|
|
|
2745
2761
|
"data-mark": true,
|
|
2746
2762
|
"data-selected": selected === i || void 0,
|
|
2747
2763
|
style: { fill: color },
|
|
2748
|
-
x:
|
|
2764
|
+
x: pad2 + band * i + (band - slot) / 2,
|
|
2749
2765
|
y: baselineY - h,
|
|
2750
2766
|
width: Math.max(1, slot),
|
|
2751
2767
|
height: Math.max(1, h),
|
|
@@ -3912,8 +3928,8 @@ function FunnelChart({
|
|
|
3912
3928
|
const n = rows.length;
|
|
3913
3929
|
const fmt = valueFormat || fmtNumber;
|
|
3914
3930
|
const W = 600, H = height;
|
|
3915
|
-
const
|
|
3916
|
-
const innerW = W -
|
|
3931
|
+
const pad2 = 8;
|
|
3932
|
+
const innerW = W - pad2 * 2, innerH = H - pad2 * 2;
|
|
3917
3933
|
const values = rows.map((d) => Number(d.value) || 0);
|
|
3918
3934
|
const maxValue = Math.max(0, ...values);
|
|
3919
3935
|
const denom = maxValue > 0 ? maxValue : 1;
|
|
@@ -3933,16 +3949,16 @@ function FunnelChart({
|
|
|
3933
3949
|
let points, tx, ty;
|
|
3934
3950
|
if (horizontal) {
|
|
3935
3951
|
const bandW = innerW / Math.max(1, n);
|
|
3936
|
-
const x0 =
|
|
3937
|
-
const x1 =
|
|
3952
|
+
const x0 = pad2 + bandW * i + gap / 2;
|
|
3953
|
+
const x1 = pad2 + bandW * (i + 1) - gap / 2;
|
|
3938
3954
|
const cy = H / 2;
|
|
3939
3955
|
points = [[x0, cy - lead], [x1, cy - trail], [x1, cy + trail], [x0, cy + lead]];
|
|
3940
3956
|
tx = (x0 + x1) / 2;
|
|
3941
3957
|
ty = cy;
|
|
3942
3958
|
} else {
|
|
3943
3959
|
const bandH = innerH / Math.max(1, n);
|
|
3944
|
-
const y0 =
|
|
3945
|
-
const y1 =
|
|
3960
|
+
const y0 = pad2 + bandH * i + gap / 2;
|
|
3961
|
+
const y1 = pad2 + bandH * (i + 1) - gap / 2;
|
|
3946
3962
|
const cx = W / 2;
|
|
3947
3963
|
points = [[cx - lead, y0], [cx + lead, y0], [cx + trail, y1], [cx - trail, y1]];
|
|
3948
3964
|
tx = cx;
|
|
@@ -5105,6 +5121,7 @@ function Checkbox({
|
|
|
5105
5121
|
.twc-check[data-invalid="true"] .twc-check__box { border-color: var(--color-danger); }
|
|
5106
5122
|
.twc-check__text { display: flex; flex-direction: column; gap: 2px; }
|
|
5107
5123
|
.twc-check__label { font-size: var(--text-sm); font-weight: var(--font-medium); color: var(--color-text); line-height: 1.3; }
|
|
5124
|
+
.twc-field__req { color: var(--color-danger); }
|
|
5108
5125
|
.twc-check__desc { font-size: var(--text-xs); color: var(--color-text-muted); }
|
|
5109
5126
|
.twc-field { display: flex; flex-direction: column; gap: var(--space-1-5); font-family: var(--font-sans); }
|
|
5110
5127
|
.twc-field__error { font-size: var(--text-xs); color: var(--color-danger-subtle-fg); font-weight: var(--font-medium); }
|
|
@@ -5145,7 +5162,10 @@ function Checkbox({
|
|
|
5145
5162
|
),
|
|
5146
5163
|
/* @__PURE__ */ jsx("span", { className: "twc-check__box", "aria-hidden": "true", children: /* @__PURE__ */ jsx("svg", { className: "twc-check__svg", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "3.5", strokeLinecap: "round", strokeLinejoin: "round", children: mixed ? /* @__PURE__ */ jsx("path", { d: "M5 12h14" }) : /* @__PURE__ */ jsx("path", { d: "M20 6 9 17l-5-5" }) }) }),
|
|
5147
5164
|
label || description ? /* @__PURE__ */ jsxs("span", { className: "twc-check__text", children: [
|
|
5148
|
-
label ? /* @__PURE__ */
|
|
5165
|
+
label ? /* @__PURE__ */ jsxs("span", { className: "twc-check__label", children: [
|
|
5166
|
+
label,
|
|
5167
|
+
required ? /* @__PURE__ */ jsx("span", { className: "twc-field__req", children: "*" }) : null
|
|
5168
|
+
] }) : null,
|
|
5149
5169
|
description ? /* @__PURE__ */ jsx("span", { className: "twc-check__desc", children: description }) : null
|
|
5150
5170
|
] }) : null
|
|
5151
5171
|
] });
|
|
@@ -5165,9 +5185,11 @@ var FIELD_CSS = `
|
|
|
5165
5185
|
var COLORPICKER_CSS = `
|
|
5166
5186
|
.twc-cp { position: relative; font-family: var(--font-sans); display: flex; flex-direction: column; gap: var(--space-1-5); }
|
|
5167
5187
|
.twc-cp__label { font-size: var(--text-sm); font-weight: var(--font-semibold); color: var(--color-text); }
|
|
5168
|
-
.twc-cp__trigger { display: flex; align-items: center; gap: var(--space-2-5);
|
|
5188
|
+
.twc-cp__trigger { display: flex; align-items: center; gap: var(--space-2-5); --_h: var(--control-h-md); height: var(--_h); padding: 0 var(--space-2) 0 var(--space-2);
|
|
5169
5189
|
background: var(--color-surface); border: var(--border-thin) solid var(--color-border); border-radius: var(--radius-md); cursor: pointer;
|
|
5170
5190
|
transition: border-color var(--duration-fast) var(--ease-standard), box-shadow var(--duration-fast) var(--ease-standard); }
|
|
5191
|
+
.twc-cp__trigger[data-size="sm"] { --_h: var(--control-h-sm); }
|
|
5192
|
+
.twc-cp__trigger[data-size="lg"] { --_h: var(--control-h-lg); }
|
|
5171
5193
|
.twc-cp__trigger:hover:not([data-open="true"]):not([data-disabled="true"]) { border-color: var(--color-border-strong); }
|
|
5172
5194
|
.twc-cp__trigger[data-open="true"] { border-color: var(--color-primary); box-shadow: var(--ring); }
|
|
5173
5195
|
.twc-cp__trigger[data-invalid="true"] { border-color: var(--color-danger); }
|
|
@@ -5261,6 +5283,7 @@ function ColorPicker({
|
|
|
5261
5283
|
defaultValue = "#6366F1",
|
|
5262
5284
|
presets = DEFAULT_PRESETS,
|
|
5263
5285
|
disabled = false,
|
|
5286
|
+
size = "md",
|
|
5264
5287
|
alpha = false,
|
|
5265
5288
|
tone = "primary",
|
|
5266
5289
|
onChange,
|
|
@@ -5412,6 +5435,7 @@ function ColorPicker({
|
|
|
5412
5435
|
"data-open": open || void 0,
|
|
5413
5436
|
"data-disabled": disabled || void 0,
|
|
5414
5437
|
"data-invalid": invalid || void 0,
|
|
5438
|
+
"data-size": size,
|
|
5415
5439
|
role: "button",
|
|
5416
5440
|
tabIndex: disabled ? -1 : 0,
|
|
5417
5441
|
"aria-haspopup": "dialog",
|
|
@@ -7332,6 +7356,8 @@ function MultiSelect({
|
|
|
7332
7356
|
name,
|
|
7333
7357
|
max,
|
|
7334
7358
|
maxTagCount,
|
|
7359
|
+
filter,
|
|
7360
|
+
onInputChange,
|
|
7335
7361
|
virtualized = false,
|
|
7336
7362
|
overscan = 8,
|
|
7337
7363
|
id,
|
|
@@ -7359,10 +7385,11 @@ function MultiSelect({
|
|
|
7359
7385
|
const popRef = React51__default.useRef(null);
|
|
7360
7386
|
const listRef = React51__default.useRef(null);
|
|
7361
7387
|
const activeRef = React51__default.useRef(null);
|
|
7362
|
-
const fGroups = React51__default.useMemo(
|
|
7363
|
-
|
|
7364
|
-
|
|
7365
|
-
|
|
7388
|
+
const fGroups = React51__default.useMemo(() => {
|
|
7389
|
+
const q = query.trim();
|
|
7390
|
+
const fn = filter === false ? null : typeof filter === "function" ? filter : matches2;
|
|
7391
|
+
return groups.map((g) => ({ group: g.group, options: fn ? g.options.filter((o) => fn(o, q)) : g.options })).filter((g) => g.options.length);
|
|
7392
|
+
}, [groups, query, filter]);
|
|
7366
7393
|
const visible = React51__default.useMemo(() => fGroups.flatMap((g) => g.options), [fGroups]);
|
|
7367
7394
|
const rowH = React51__default.useMemo(() => visible.some((o) => o.description) ? 48 : 36, [visible]);
|
|
7368
7395
|
const GROUP_H = 30;
|
|
@@ -7642,6 +7669,7 @@ function MultiSelect({
|
|
|
7642
7669
|
onChange: (e) => {
|
|
7643
7670
|
setQuery(e.target.value);
|
|
7644
7671
|
setOpen(true);
|
|
7672
|
+
onInputChange?.(e.target.value);
|
|
7645
7673
|
},
|
|
7646
7674
|
onKeyDown: (e) => {
|
|
7647
7675
|
onKeyDown?.(e);
|
|
@@ -7817,7 +7845,12 @@ var TOOLTIP_CSS = `
|
|
|
7817
7845
|
padding: 6px 10px; border-radius: var(--radius-md);
|
|
7818
7846
|
background: var(--color-text); color: var(--color-surface);
|
|
7819
7847
|
font-family: var(--font-sans); font-size: var(--text-xs); font-weight: var(--font-medium);
|
|
7820
|
-
line-height: 1.3; white-space: normal;
|
|
7848
|
+
line-height: 1.3; white-space: normal;
|
|
7849
|
+
/* Grow horizontally to max-width, then wrap. max-content sizes to the content (capped by
|
|
7850
|
+
max-width) and \u2014 unlike shrink-to-fit width:auto \u2014 is NOT constrained by the space between
|
|
7851
|
+
the fixed left edge and the viewport edge, so a tooltip near the right edge no longer
|
|
7852
|
+
collapses to ~1 word per line and stretch vertically. */
|
|
7853
|
+
width: max-content; max-width: var(--_tw-maxw, 320px); box-shadow: var(--shadow-md);
|
|
7821
7854
|
opacity: 0; transform: scale(0.9); transition: opacity var(--duration-fast) var(--ease-out), transform var(--duration-fast) var(--ease-spring);
|
|
7822
7855
|
}
|
|
7823
7856
|
.twc-tooltip[data-show="true"] { pointer-events: auto; }
|
|
@@ -7828,10 +7861,13 @@ var TOOLTIP_CSS = `
|
|
|
7828
7861
|
.twc-tooltip[data-place="right"] { transform-origin: left center; translate: 0 -50%; }
|
|
7829
7862
|
.twc-tooltip[data-show="true"][data-place="top"], .twc-tooltip[data-show="true"][data-place="bottom"] { transform: scale(1); }
|
|
7830
7863
|
.twc-tooltip__arrow { position: absolute; width: 7px; height: 7px; background: var(--color-text); transform: rotate(45deg); }
|
|
7831
|
-
|
|
7832
|
-
|
|
7833
|
-
|
|
7834
|
-
.twc-tooltip[data-place="
|
|
7864
|
+
/* Arrow tracks the trigger via --_tw-arrow-x/y (px from the tooltip edge) instead of being
|
|
7865
|
+
locked to the centre, so it still points at the trigger when the bubble is clamped near a
|
|
7866
|
+
viewport edge. Falls back to 50% before measurement / SSR. */
|
|
7867
|
+
.twc-tooltip[data-place="top"] .twc-tooltip__arrow { bottom: -3px; left: var(--_tw-arrow-x, 50%); margin-left: -3.5px; }
|
|
7868
|
+
.twc-tooltip[data-place="bottom"] .twc-tooltip__arrow { top: -3px; left: var(--_tw-arrow-x, 50%); margin-left: -3.5px; }
|
|
7869
|
+
.twc-tooltip[data-place="left"] .twc-tooltip__arrow { right: -3px; top: var(--_tw-arrow-y, 50%); margin-top: -3.5px; }
|
|
7870
|
+
.twc-tooltip[data-place="right"] .twc-tooltip__arrow { left: -3px; top: var(--_tw-arrow-y, 50%); margin-top: -3.5px; }
|
|
7835
7871
|
@media (prefers-reduced-motion: reduce) { .twc-tooltip { transition: opacity var(--duration-fast) linear; transform: none; } }
|
|
7836
7872
|
`;
|
|
7837
7873
|
function Tooltip({
|
|
@@ -7885,10 +7921,22 @@ function Tooltip({
|
|
|
7885
7921
|
else if (placement === "left" && spaceLeft < tw && spaceRight > spaceLeft) side = "right";
|
|
7886
7922
|
else if (placement === "right" && spaceRight < tw && spaceLeft > spaceRight) side = "left";
|
|
7887
7923
|
const base = { left: "auto", right: "auto", top: "auto", bottom: "auto", place: side };
|
|
7888
|
-
|
|
7889
|
-
|
|
7890
|
-
|
|
7891
|
-
|
|
7924
|
+
const AP = 12;
|
|
7925
|
+
const arrowX = (center) => tw ? Math.round(Math.min(Math.max(cx - (center - tw / 2), AP), tw - AP)) : void 0;
|
|
7926
|
+
const arrowY = (center) => th ? Math.round(Math.min(Math.max(cy - (center - th / 2), AP), th - AP)) : void 0;
|
|
7927
|
+
if (side === "bottom") {
|
|
7928
|
+
const c = clampX(cx);
|
|
7929
|
+
setCoords({ ...base, left: c, top: Math.round(r2.bottom + gap), arrowX: arrowX(c) });
|
|
7930
|
+
} else if (side === "left") {
|
|
7931
|
+
const c = clampY(cy);
|
|
7932
|
+
setCoords({ ...base, top: c, right: Math.round(vw - r2.left + gap), arrowY: arrowY(c) });
|
|
7933
|
+
} else if (side === "right") {
|
|
7934
|
+
const c = clampY(cy);
|
|
7935
|
+
setCoords({ ...base, top: c, left: Math.round(r2.right + gap), arrowY: arrowY(c) });
|
|
7936
|
+
} else {
|
|
7937
|
+
const c = clampX(cx);
|
|
7938
|
+
setCoords({ ...base, left: c, bottom: Math.round(vh - r2.top + gap), arrowX: arrowX(c) });
|
|
7939
|
+
}
|
|
7892
7940
|
}, [placement]);
|
|
7893
7941
|
React51__default.useEffect(() => {
|
|
7894
7942
|
place();
|
|
@@ -7945,7 +7993,15 @@ function Tooltip({
|
|
|
7945
7993
|
"aria-hidden": show ? void 0 : "true",
|
|
7946
7994
|
onMouseEnter: cancelClose,
|
|
7947
7995
|
onMouseLeave: close,
|
|
7948
|
-
style: {
|
|
7996
|
+
style: {
|
|
7997
|
+
position: "fixed",
|
|
7998
|
+
left: coords.left,
|
|
7999
|
+
right: coords.right,
|
|
8000
|
+
top: coords.top,
|
|
8001
|
+
bottom: coords.bottom,
|
|
8002
|
+
"--_tw-arrow-x": coords.arrowX != null ? `${coords.arrowX}px` : void 0,
|
|
8003
|
+
"--_tw-arrow-y": coords.arrowY != null ? `${coords.arrowY}px` : void 0
|
|
8004
|
+
},
|
|
7949
8005
|
children: [
|
|
7950
8006
|
label,
|
|
7951
8007
|
/* @__PURE__ */ jsx("span", { className: "twc-tooltip__arrow", "aria-hidden": "true" })
|
|
@@ -8325,7 +8381,8 @@ th.twc-dt__rownum .twc-dt__th-inner { padding-inline: 8px; gap: 2px; justify-con
|
|
|
8325
8381
|
.twc-dt__col-pin:hover { background: var(--color-surface); color: var(--color-text); }
|
|
8326
8382
|
.twc-dt__col-pin[data-on="true"] { color: var(--color-primary); background: var(--color-primary-subtle); }
|
|
8327
8383
|
.twc-dt__col-pin svg { width: 14px; height: 14px; }
|
|
8328
|
-
.twc-dt__sw { width: 32px; height: 18px; border-radius: var(--radius-full); background: var(--color-border-strong); position: relative; flex: none; transition: background-color var(--duration-base); }
|
|
8384
|
+
.twc-dt__sw { width: 32px; height: 18px; border-radius: var(--radius-full); background: var(--color-border-strong); position: relative; flex: none; cursor: pointer; transition: background-color var(--duration-base); }
|
|
8385
|
+
.twc-dt__sw[aria-disabled="true"] { cursor: default; }
|
|
8329
8386
|
.twc-dt__sw[data-on="true"] { background: var(--color-primary); }
|
|
8330
8387
|
.twc-dt__sw::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: var(--radius-full); background: var(--color-primary-fg); box-shadow: var(--shadow-sm); transition: transform var(--duration-base) var(--ease-spring); }
|
|
8331
8388
|
.twc-dt__sw:focus-visible { outline: none; box-shadow: var(--ring); }
|
|
@@ -8455,6 +8512,7 @@ var NUM_OPS = [
|
|
|
8455
8512
|
];
|
|
8456
8513
|
var opsFor = (type) => type === "number" ? NUM_OPS : STR_OPS;
|
|
8457
8514
|
var isMultiOp = (op) => op === "isAnyOf";
|
|
8515
|
+
var getColVal = (col, row) => col && col.valueGetter ? col.valueGetter(row) : row == null ? void 0 : row[col && col.field];
|
|
8458
8516
|
function testFilter(raw, op, target, type) {
|
|
8459
8517
|
if (op === "isEmpty") return raw == null || raw === "";
|
|
8460
8518
|
if (op === "isNotEmpty") return !(raw == null || raw === "");
|
|
@@ -8500,14 +8558,15 @@ function runDatatableQuery(rows, query, options = {}) {
|
|
|
8500
8558
|
const cols = options.columns || [];
|
|
8501
8559
|
const typeOf = (field) => cols.find((c) => c.field === field)?.type === "number" ? "number" : "string";
|
|
8502
8560
|
const searchFields = options.searchFields || (cols.length ? cols.filter((c) => c.field && c.type !== "actions").map((c) => c.field) : rows && rows[0] ? Object.keys(rows[0]) : []);
|
|
8561
|
+
const gv = (field, r2) => getColVal(cols.find((c) => c.field === field) || { field }, r2);
|
|
8503
8562
|
let out = Array.isArray(rows) ? rows : [];
|
|
8504
8563
|
const quick = String(q.quickFilter || "").trim().toLowerCase();
|
|
8505
|
-
if (quick) out = out.filter((r2) => searchFields.some((f) => String(
|
|
8506
|
-
for (const f of q.filters || []) out = out.filter((r2) => testFilter(
|
|
8564
|
+
if (quick) out = out.filter((r2) => searchFields.some((f) => String(gv(f, r2) ?? "").toLowerCase().includes(quick)));
|
|
8565
|
+
for (const f of q.filters || []) out = out.filter((r2) => testFilter(gv(f.field, r2), f.op, f.value, typeOf(f.field)));
|
|
8507
8566
|
if (q.sort && q.sort.field) {
|
|
8508
8567
|
const { field, dir } = q.sort, numeric = typeOf(field) === "number";
|
|
8509
8568
|
out = [...out].sort((a, b) => {
|
|
8510
|
-
const av =
|
|
8569
|
+
const av = gv(field, a), bv = gv(field, b);
|
|
8511
8570
|
if (av == null) return 1;
|
|
8512
8571
|
if (bv == null) return -1;
|
|
8513
8572
|
const r2 = numeric ? av - bv : String(av).localeCompare(String(bv));
|
|
@@ -8765,6 +8824,7 @@ function Datatable({
|
|
|
8765
8824
|
"aria-label": ariaLabelAttr,
|
|
8766
8825
|
rowGrouping = [],
|
|
8767
8826
|
rowNumbers = false,
|
|
8827
|
+
searchFields = null,
|
|
8768
8828
|
rowPinning = false,
|
|
8769
8829
|
rowReorder = false,
|
|
8770
8830
|
rowResize = false,
|
|
@@ -9106,17 +9166,18 @@ function Datatable({
|
|
|
9106
9166
|
let out = rows;
|
|
9107
9167
|
if (quick.trim()) {
|
|
9108
9168
|
const q = quick.trim().toLowerCase();
|
|
9109
|
-
|
|
9169
|
+
const searchCols = searchFields && searchFields.length ? searchFields.map((f) => colByField[f] || { field: f }) : visibleCols;
|
|
9170
|
+
out = out.filter((r2) => searchCols.some((c) => String(getColVal(c, r2) ?? "").toLowerCase().includes(q)));
|
|
9110
9171
|
}
|
|
9111
9172
|
for (const f of filters) {
|
|
9112
9173
|
const col = colByField[f.field];
|
|
9113
9174
|
if (!col) continue;
|
|
9114
|
-
out = out.filter((r2) => testFilter(r2
|
|
9175
|
+
out = out.filter((r2) => testFilter(getColVal(col, r2), f.op, f.value, col.type));
|
|
9115
9176
|
}
|
|
9116
9177
|
if (sort) {
|
|
9117
9178
|
const col = colByField[sort.field];
|
|
9118
9179
|
out = [...out].sort((a, b) => {
|
|
9119
|
-
const av = a
|
|
9180
|
+
const av = getColVal(col, a), bv = getColVal(col, b);
|
|
9120
9181
|
if (av == null) return 1;
|
|
9121
9182
|
if (bv == null) return -1;
|
|
9122
9183
|
const r2 = col?.type === "number" ? av - bv : String(av).localeCompare(String(bv));
|
|
@@ -9128,7 +9189,7 @@ function Datatable({
|
|
|
9128
9189
|
out = [...out].sort((a, b) => (idx.get(keyOf(a)) ?? 1e9) - (idx.get(keyOf(b)) ?? 1e9));
|
|
9129
9190
|
}
|
|
9130
9191
|
return out;
|
|
9131
|
-
}, [rows, quick, filters, sort, visibleCols, colByField, serverMode, rowOrder]);
|
|
9192
|
+
}, [rows, quick, filters, sort, visibleCols, colByField, serverMode, rowOrder, searchFields]);
|
|
9132
9193
|
const paginated = pageSize > 0;
|
|
9133
9194
|
const serverTotal = rowCount == null ? processed.length : rowCount;
|
|
9134
9195
|
const totalRows = serverMode ? serverTotal : processed.length;
|
|
@@ -9153,7 +9214,7 @@ function Datatable({
|
|
|
9153
9214
|
function computeAgg(col, data) {
|
|
9154
9215
|
const agg = col.aggregation;
|
|
9155
9216
|
if (!agg) return null;
|
|
9156
|
-
const raw = data.map((r2) => r2
|
|
9217
|
+
const raw = data.map((r2) => getColVal(col, r2)).filter((v) => v != null && v !== "");
|
|
9157
9218
|
if (typeof agg === "function") return agg(raw, data);
|
|
9158
9219
|
if (agg === "count") return raw.length;
|
|
9159
9220
|
const nums = raw.map(Number).filter((n) => !Number.isNaN(n));
|
|
@@ -9171,7 +9232,8 @@ function Datatable({
|
|
|
9171
9232
|
const field = activeGroupBy[depth];
|
|
9172
9233
|
const map = /* @__PURE__ */ new Map();
|
|
9173
9234
|
for (const r2 of rowsIn) {
|
|
9174
|
-
const
|
|
9235
|
+
const gvv = getColVal(colByField[field], r2);
|
|
9236
|
+
const v = gvv == null || gvv === "" ? "\u2014" : gvv;
|
|
9175
9237
|
if (!map.has(v)) map.set(v, []);
|
|
9176
9238
|
map.get(v).push(r2);
|
|
9177
9239
|
}
|
|
@@ -9468,13 +9530,17 @@ function Datatable({
|
|
|
9468
9530
|
function optionsForField(field) {
|
|
9469
9531
|
const col = colByField[field];
|
|
9470
9532
|
if (col?.valueOptions) return col.valueOptions.map((o) => typeof o === "string" ? { value: o, label: o } : o);
|
|
9471
|
-
const
|
|
9533
|
+
const seen2 = /* @__PURE__ */ new Map();
|
|
9472
9534
|
for (const r2 of rows) {
|
|
9473
|
-
const
|
|
9474
|
-
if (
|
|
9475
|
-
|
|
9535
|
+
const raw = getColVal(col, r2);
|
|
9536
|
+
if (raw == null || raw === "") continue;
|
|
9537
|
+
const key = String(raw);
|
|
9538
|
+
if (seen2.has(key)) continue;
|
|
9539
|
+
const label = col?.valueFormatter ? col.valueFormatter(raw, r2) : key;
|
|
9540
|
+
seen2.set(key, { value: key, label: typeof label === "string" || typeof label === "number" ? String(label) : key });
|
|
9541
|
+
if (seen2.size > 80) break;
|
|
9476
9542
|
}
|
|
9477
|
-
return [...
|
|
9543
|
+
return [...seen2.values()].sort((a, b) => String(a.label).localeCompare(String(b.label)));
|
|
9478
9544
|
}
|
|
9479
9545
|
const [resizing, setResizing] = React51__default.useState(false);
|
|
9480
9546
|
function startResize(e, field) {
|
|
@@ -9504,7 +9570,7 @@ function Datatable({
|
|
|
9504
9570
|
meas.setAttribute("aria-hidden", "true");
|
|
9505
9571
|
meas.style.cssText = "position:fixed;left:-9999px;top:-9999px;visibility:hidden;pointer-events:none;white-space:nowrap;display:inline-block;box-sizing:content-box;padding:0;";
|
|
9506
9572
|
document.body.appendChild(meas);
|
|
9507
|
-
let content = 0,
|
|
9573
|
+
let content = 0, pad2 = 0;
|
|
9508
9574
|
try {
|
|
9509
9575
|
for (const cell of cells) {
|
|
9510
9576
|
const src = cell.tagName === "TH" ? cell.querySelector(".twc-dt__th-inner") || cell : cell;
|
|
@@ -9516,13 +9582,13 @@ function Datatable({
|
|
|
9516
9582
|
meas.style.letterSpacing = cs.letterSpacing;
|
|
9517
9583
|
meas.innerHTML = src.innerHTML;
|
|
9518
9584
|
content = Math.max(content, meas.scrollWidth);
|
|
9519
|
-
|
|
9585
|
+
pad2 = Math.max(pad2, (parseFloat(cs.paddingLeft) || 0) + (parseFloat(cs.paddingRight) || 0));
|
|
9520
9586
|
}
|
|
9521
9587
|
} finally {
|
|
9522
9588
|
meas.innerHTML = "";
|
|
9523
9589
|
document.body.removeChild(meas);
|
|
9524
9590
|
}
|
|
9525
|
-
const w = Math.min(640, Math.max(72, Math.ceil(content) + Math.ceil(
|
|
9591
|
+
const w = Math.min(640, Math.max(72, Math.ceil(content) + Math.ceil(pad2) + 6));
|
|
9526
9592
|
setWidths((m) => ({ ...m, [field]: w }));
|
|
9527
9593
|
}
|
|
9528
9594
|
function onColDrop(targetField) {
|
|
@@ -9541,7 +9607,7 @@ function Datatable({
|
|
|
9541
9607
|
function exportData(format = "csv") {
|
|
9542
9608
|
const expCols = ordered.filter((c) => c.type !== "actions");
|
|
9543
9609
|
const source = serverMode ? paged : processed;
|
|
9544
|
-
const cellValue = (c, row) => c.exportValue ? c.exportValue(row[c.field], row) : row
|
|
9610
|
+
const cellValue = (c, row) => c.exportValue ? c.exportValue(row[c.field], row) : getColVal(c, row);
|
|
9545
9611
|
const fname = (ext) => `${exportFilename}.${ext}`;
|
|
9546
9612
|
const download = (text2, mime, ext) => {
|
|
9547
9613
|
const blob = new Blob([text2], { type: mime });
|
|
@@ -9590,7 +9656,7 @@ function Datatable({
|
|
|
9590
9656
|
}
|
|
9591
9657
|
}
|
|
9592
9658
|
const data = serverMode ? paged : processed;
|
|
9593
|
-
const raw = data.map((r2) => r2
|
|
9659
|
+
const raw = data.map((r2) => getColVal(col, r2)).filter((v) => v != null && v !== "");
|
|
9594
9660
|
if (typeof agg === "function") return agg(raw, data);
|
|
9595
9661
|
if (agg === "count") return raw.length;
|
|
9596
9662
|
const nums = raw.map(Number).filter((n) => !Number.isNaN(n));
|
|
@@ -10009,7 +10075,7 @@ function Datatable({
|
|
|
10009
10075
|
showRowNum ? /* @__PURE__ */ jsx("td", { className: "twc-dt__td twc-dt__rownum", role: "gridcell", "aria-hidden": "true", "data-pin": "left", "data-pin-edge": pins.left.length ? void 0 : "left", style: { insetInlineStart: numLeft, width: NUM_W }, children: typeof ri === "number" ? (paginated || serverMode ? pageVal * sizeVal : 0) + ri + 1 : "" }) : null,
|
|
10010
10076
|
ordered.map((c, ci) => {
|
|
10011
10077
|
const st = stickyOf(c.field);
|
|
10012
|
-
const val = row
|
|
10078
|
+
const val = getColVal(c, row);
|
|
10013
10079
|
const isActions = c.type === "actions";
|
|
10014
10080
|
const editable = isColEditable(c);
|
|
10015
10081
|
const isEditing = editing && editing.key === k && editing.field === c.field;
|
|
@@ -10066,9 +10132,9 @@ function Datatable({
|
|
|
10066
10132
|
}
|
|
10067
10133
|
function renderPivot() {
|
|
10068
10134
|
const rFields = pivotConfig.rows, cFields = pivotConfig.columns || [], values = pivotConfig.values;
|
|
10069
|
-
const rowKeyOf = (r2) => rFields.map((f) =>
|
|
10070
|
-
const colPathOf = (r2) => cFields.map((f) => String(
|
|
10071
|
-
const aggOf2 = (subset, v) => computeAgg({ field: v.field, aggregation: v.agg || "sum" }, subset || []);
|
|
10135
|
+
const rowKeyOf = (r2) => rFields.map((f) => getColVal(colByField[f], r2) ?? "\u2014").join(" \xB7 ");
|
|
10136
|
+
const colPathOf = (r2) => cFields.map((f) => String(getColVal(colByField[f], r2) ?? "\u2014"));
|
|
10137
|
+
const aggOf2 = (subset, v) => computeAgg({ ...colByField[v.field], field: v.field, aggregation: v.agg || "sum" }, subset || []);
|
|
10072
10138
|
const fmt = (val, v) => {
|
|
10073
10139
|
if (val == null) return "\u2014";
|
|
10074
10140
|
const col = colByField[v.field];
|
|
@@ -11224,6 +11290,470 @@ function Datatable({
|
|
|
11224
11290
|
] }) : null
|
|
11225
11291
|
] });
|
|
11226
11292
|
}
|
|
11293
|
+
function space(v) {
|
|
11294
|
+
if (v == null) return void 0;
|
|
11295
|
+
if (typeof v === "number") return `var(--space-${String(v).replace(".", "-")})`;
|
|
11296
|
+
return v;
|
|
11297
|
+
}
|
|
11298
|
+
function len(v) {
|
|
11299
|
+
return typeof v === "number" ? `${v}px` : v;
|
|
11300
|
+
}
|
|
11301
|
+
var BP = { sm: 640, md: 768, lg: 1024, xl: 1280 };
|
|
11302
|
+
function safeHref5(url) {
|
|
11303
|
+
if (url == null) return void 0;
|
|
11304
|
+
const s = String(url).replace(/[\x00-\x20]+/g, "").toLowerCase();
|
|
11305
|
+
return s.startsWith("javascript:") || s.startsWith("data:") || s.startsWith("vbscript:") ? void 0 : url;
|
|
11306
|
+
}
|
|
11307
|
+
var Grid = React51__default.forwardRef(function Grid2({
|
|
11308
|
+
as: Tag2 = "div",
|
|
11309
|
+
columns,
|
|
11310
|
+
minChildWidth,
|
|
11311
|
+
gap = 4,
|
|
11312
|
+
rowGap,
|
|
11313
|
+
columnGap,
|
|
11314
|
+
align,
|
|
11315
|
+
justify,
|
|
11316
|
+
justifyItems,
|
|
11317
|
+
alignContent,
|
|
11318
|
+
justifyContent,
|
|
11319
|
+
sx,
|
|
11320
|
+
className = "",
|
|
11321
|
+
style,
|
|
11322
|
+
children,
|
|
11323
|
+
...rest
|
|
11324
|
+
}, ref) {
|
|
11325
|
+
const { flatStyle, styleNode, sxAttr } = useSx(sx);
|
|
11326
|
+
const responsive = columns != null && typeof columns === "object";
|
|
11327
|
+
const uid = React51__default.useId();
|
|
11328
|
+
const gridId = responsive ? `g${uid.replace(/[^a-zA-Z0-9]/g, "")}` : null;
|
|
11329
|
+
let css = "";
|
|
11330
|
+
if (responsive) {
|
|
11331
|
+
const base = columns.base ?? 1;
|
|
11332
|
+
const sel = `[data-twc-grid-id="${gridId}"]`;
|
|
11333
|
+
css = `${sel} { --twc-grid-cols: ${base}; }`;
|
|
11334
|
+
for (const bp of ["sm", "md", "lg", "xl"]) {
|
|
11335
|
+
if (columns[bp] != null) css += `
|
|
11336
|
+
@media (min-width: ${BP[bp]}px) { ${sel} { --twc-grid-cols: ${columns[bp]}; } }`;
|
|
11337
|
+
}
|
|
11338
|
+
}
|
|
11339
|
+
const __twcStyles = useScopedStyles(gridId ? `twc-grid-${gridId}` : "twc-grid", css);
|
|
11340
|
+
const templateColumns = minChildWidth ? `repeat(auto-fill, minmax(min(${len(minChildWidth)}, 100%), 1fr))` : responsive ? `repeat(var(--twc-grid-cols, ${columns.base ?? 1}), minmax(0, 1fr))` : `repeat(${columns || 1}, minmax(0, 1fr))`;
|
|
11341
|
+
if (Tag2 === "a" && rest.href != null) rest.href = safeHref5(rest.href);
|
|
11342
|
+
return /* @__PURE__ */ jsxs(
|
|
11343
|
+
Tag2,
|
|
11344
|
+
{
|
|
11345
|
+
ref,
|
|
11346
|
+
className: `twc-grid ${className}`.trim(),
|
|
11347
|
+
"data-twc-grid-id": gridId || void 0,
|
|
11348
|
+
"data-twc-sx": sxAttr,
|
|
11349
|
+
style: {
|
|
11350
|
+
display: "grid",
|
|
11351
|
+
gridTemplateColumns: templateColumns,
|
|
11352
|
+
rowGap: space(rowGap ?? gap),
|
|
11353
|
+
columnGap: space(columnGap ?? gap),
|
|
11354
|
+
alignItems: align,
|
|
11355
|
+
// #216: `justifyItems` is the explicit, correctly-named prop; `justify` remains a
|
|
11356
|
+
// backward-compatible alias for it (note: on Grid `justify` = justify-**items**, unlike
|
|
11357
|
+
// Stack.justify = justify-**content**). The explicit prop wins when both are set.
|
|
11358
|
+
justifyItems: justifyItems ?? justify,
|
|
11359
|
+
alignContent,
|
|
11360
|
+
justifyContent,
|
|
11361
|
+
...style,
|
|
11362
|
+
...flatStyle
|
|
11363
|
+
},
|
|
11364
|
+
...rest,
|
|
11365
|
+
children: [
|
|
11366
|
+
responsive ? __twcStyles : null,
|
|
11367
|
+
styleNode,
|
|
11368
|
+
children
|
|
11369
|
+
]
|
|
11370
|
+
}
|
|
11371
|
+
);
|
|
11372
|
+
});
|
|
11373
|
+
Grid.displayName = "Grid";
|
|
11374
|
+
var CARDGRID_CSS = `
|
|
11375
|
+
.twc-cardgrid { font-family: var(--font-sans); display: flex; flex-direction: column; gap: var(--space-3); }
|
|
11376
|
+
.twc-cardgrid__label { font-size: var(--text-sm); font-weight: var(--font-semibold); color: var(--color-text); }
|
|
11377
|
+
.twc-cardgrid__toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
|
|
11378
|
+
.twc-cardgrid__search { flex: 1 1 200px; min-width: 160px; }
|
|
11379
|
+
.twc-cardgrid__spacer { flex: 1 1 auto; }
|
|
11380
|
+
.twc-cardgrid__sort { display: inline-flex; align-items: center; gap: var(--space-1); }
|
|
11381
|
+
.twc-cardgrid__dir { display: inline-grid; place-items: center; width: 32px; height: 32px; border: var(--border-thin) solid var(--color-border); background: var(--color-surface); color: var(--color-text-muted); cursor: pointer; border-radius: var(--radius-md); transition: background-color var(--duration-fast), color var(--duration-fast); }
|
|
11382
|
+
.twc-cardgrid__dir:hover { background: var(--color-surface-sunken); color: var(--color-text); }
|
|
11383
|
+
.twc-cardgrid__dir svg { width: 16px; height: 16px; transition: transform var(--duration-fast) var(--ease-standard); }
|
|
11384
|
+
.twc-cardgrid__dir[data-dir="desc"] svg { transform: scaleY(-1); }
|
|
11385
|
+
.twc-cardgrid__body { position: relative; min-height: 60px; }
|
|
11386
|
+
.twc-cardgrid__body[data-loading="true"] .twc-cardgrid__grid { opacity: 0.55; pointer-events: none; }
|
|
11387
|
+
.twc-cardgrid__overlay { position: absolute; inset: 0; display: grid; place-items: center; z-index: 1; }
|
|
11388
|
+
.twc-cardgrid__spinner { width: 26px; height: 26px; border: 3px solid var(--color-border); border-top-color: var(--color-primary); border-radius: var(--radius-full); animation: twc-cardgrid-spin 0.7s linear infinite; }
|
|
11389
|
+
@keyframes twc-cardgrid-spin { to { transform: rotate(360deg); } }
|
|
11390
|
+
@media (prefers-reduced-motion: reduce) { .twc-cardgrid__spinner { animation-duration: 1.6s; } }
|
|
11391
|
+
.twc-cardgrid__empty { padding: var(--space-8) var(--space-4); text-align: center; color: var(--color-text-muted); font-size: var(--text-sm); }
|
|
11392
|
+
.twc-cardgrid__footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2); }
|
|
11393
|
+
.twc-cardgrid__count { font-size: var(--text-sm); color: var(--color-text-muted); }
|
|
11394
|
+
.twc-cardgrid__perpage { display: inline-flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); color: var(--color-text-muted); }
|
|
11395
|
+
`;
|
|
11396
|
+
function CardGrid({
|
|
11397
|
+
rows = [],
|
|
11398
|
+
renderCard,
|
|
11399
|
+
rowKey = "id",
|
|
11400
|
+
minChildWidth = "18rem",
|
|
11401
|
+
gap = 4,
|
|
11402
|
+
columns,
|
|
11403
|
+
// pagination
|
|
11404
|
+
pageSize = 12,
|
|
11405
|
+
pageSizeOptions = [12, 24, 48, 96],
|
|
11406
|
+
page,
|
|
11407
|
+
defaultPage = 0,
|
|
11408
|
+
onPageChange,
|
|
11409
|
+
onPageSizeChange,
|
|
11410
|
+
showPageSize = true,
|
|
11411
|
+
// query / server contract (mirrors Datatable serverMode)
|
|
11412
|
+
serverMode = false,
|
|
11413
|
+
rowCount,
|
|
11414
|
+
loading = false,
|
|
11415
|
+
onServerChange,
|
|
11416
|
+
// filtering & sorting
|
|
11417
|
+
filters = [],
|
|
11418
|
+
quickFilter,
|
|
11419
|
+
defaultQuickFilter = "",
|
|
11420
|
+
onQuickFilterChange,
|
|
11421
|
+
searchable = false,
|
|
11422
|
+
searchFields,
|
|
11423
|
+
searchPlaceholder = "Search\u2026",
|
|
11424
|
+
sort,
|
|
11425
|
+
defaultSort = null,
|
|
11426
|
+
onSortChange,
|
|
11427
|
+
sortOptions,
|
|
11428
|
+
// slots / states
|
|
11429
|
+
toolbar,
|
|
11430
|
+
emptyState = "No results.",
|
|
11431
|
+
label,
|
|
11432
|
+
id,
|
|
11433
|
+
className = "",
|
|
11434
|
+
...rest
|
|
11435
|
+
}) {
|
|
11436
|
+
const styles = useScopedStyles("twc-cardgrid-styles", CARDGRID_CSS);
|
|
11437
|
+
const autoId = React51__default.useId();
|
|
11438
|
+
const fieldId = id || autoId;
|
|
11439
|
+
const [internalPage, setInternalPage] = React51__default.useState(defaultPage);
|
|
11440
|
+
const pageVal = page !== void 0 ? page : internalPage;
|
|
11441
|
+
const commitPage = (p) => {
|
|
11442
|
+
onPageChange?.(p);
|
|
11443
|
+
if (page === void 0) setInternalPage(p);
|
|
11444
|
+
};
|
|
11445
|
+
const [internalSize, setInternalSize] = React51__default.useState(pageSize > 0 ? pageSize : 12);
|
|
11446
|
+
const sizeControlled = onPageSizeChange !== void 0;
|
|
11447
|
+
const sizeVal = sizeControlled ? pageSize > 0 ? pageSize : 12 : internalSize;
|
|
11448
|
+
const commitSize = (n) => {
|
|
11449
|
+
onPageSizeChange?.(n);
|
|
11450
|
+
if (!sizeControlled) setInternalSize(n);
|
|
11451
|
+
commitPage(0);
|
|
11452
|
+
};
|
|
11453
|
+
React51__default.useEffect(() => {
|
|
11454
|
+
if (!sizeControlled) setInternalSize(pageSize > 0 ? pageSize : 12);
|
|
11455
|
+
}, [pageSize]);
|
|
11456
|
+
const [internalQuick, setInternalQuick] = React51__default.useState(defaultQuickFilter);
|
|
11457
|
+
const quickVal = quickFilter !== void 0 ? quickFilter : internalQuick;
|
|
11458
|
+
const commitQuick = (q) => {
|
|
11459
|
+
onQuickFilterChange?.(q);
|
|
11460
|
+
if (quickFilter === void 0) setInternalQuick(q);
|
|
11461
|
+
commitPage(0);
|
|
11462
|
+
};
|
|
11463
|
+
const [internalSort, setInternalSort] = React51__default.useState(defaultSort);
|
|
11464
|
+
const sortVal = sort !== void 0 ? sort : internalSort;
|
|
11465
|
+
const commitSort = (s) => {
|
|
11466
|
+
onSortChange?.(s);
|
|
11467
|
+
if (sort === void 0) setInternalSort(s);
|
|
11468
|
+
commitPage(0);
|
|
11469
|
+
};
|
|
11470
|
+
const filtersKey = JSON.stringify(filters);
|
|
11471
|
+
const mounted = React51__default.useRef(false);
|
|
11472
|
+
React51__default.useEffect(() => {
|
|
11473
|
+
if (!mounted.current) {
|
|
11474
|
+
mounted.current = true;
|
|
11475
|
+
return;
|
|
11476
|
+
}
|
|
11477
|
+
commitPage(0);
|
|
11478
|
+
}, [filtersKey]);
|
|
11479
|
+
const paginated = sizeVal > 0;
|
|
11480
|
+
const query = { page: pageVal, pageSize: paginated ? sizeVal : 0, sort: sortVal, filters, quickFilter: String(quickVal || "").trim() };
|
|
11481
|
+
const queryCols = sortOptions ? sortOptions.map((o) => ({ field: o.field, type: o.type })) : columns;
|
|
11482
|
+
const client = serverMode ? null : runDatatableQuery(rows, query, { columns: queryCols, searchFields });
|
|
11483
|
+
const pageRows = serverMode ? rows : client.rows;
|
|
11484
|
+
const total = serverMode ? rowCount == null ? rows.length : rowCount : client.total;
|
|
11485
|
+
const totalPages = Math.max(1, paginated ? Math.ceil(total / sizeVal) : 1);
|
|
11486
|
+
const onServerChangeRef = React51__default.useRef(onServerChange);
|
|
11487
|
+
onServerChangeRef.current = onServerChange;
|
|
11488
|
+
const queryKey = JSON.stringify(query);
|
|
11489
|
+
React51__default.useEffect(() => {
|
|
11490
|
+
if (!serverMode) return void 0;
|
|
11491
|
+
const t = setTimeout(() => onServerChangeRef.current?.(JSON.parse(queryKey)), 250);
|
|
11492
|
+
return () => clearTimeout(t);
|
|
11493
|
+
}, [serverMode, queryKey]);
|
|
11494
|
+
const keyOf = typeof rowKey === "function" ? rowKey : (r2) => r2 && r2[rowKey];
|
|
11495
|
+
const from = total === 0 ? 0 : pageVal * sizeVal + 1;
|
|
11496
|
+
const to = paginated ? Math.min((pageVal + 1) * sizeVal, total) : total;
|
|
11497
|
+
const rppOptions = Array.from(new Set([...pageSizeOptions || [], pageSize].filter((n) => n > 0))).sort((a, b) => a - b).map((n) => ({ value: String(n), label: String(n) }));
|
|
11498
|
+
const sortSelectOptions = sortOptions ? [{ value: "", label: "Sort by\u2026" }, ...sortOptions.map((o) => ({ value: o.field, label: o.label || o.field }))] : null;
|
|
11499
|
+
const hasToolbar = searchable || sortSelectOptions || toolbar;
|
|
11500
|
+
return /* @__PURE__ */ jsxs("div", { className: `twc-cardgrid ${className}`, id: fieldId, ...rest, children: [
|
|
11501
|
+
styles,
|
|
11502
|
+
label ? /* @__PURE__ */ jsx("div", { className: "twc-cardgrid__label", id: `${fieldId}-label`, children: label }) : null,
|
|
11503
|
+
hasToolbar ? /* @__PURE__ */ jsxs("div", { className: "twc-cardgrid__toolbar", children: [
|
|
11504
|
+
searchable ? /* @__PURE__ */ jsx("div", { className: "twc-cardgrid__search", children: /* @__PURE__ */ jsx(
|
|
11505
|
+
Input,
|
|
11506
|
+
{
|
|
11507
|
+
size: "sm",
|
|
11508
|
+
type: "search",
|
|
11509
|
+
value: quickVal,
|
|
11510
|
+
placeholder: searchPlaceholder,
|
|
11511
|
+
"aria-label": searchPlaceholder,
|
|
11512
|
+
onChange: (e) => commitQuick(e.target.value)
|
|
11513
|
+
}
|
|
11514
|
+
) }) : null,
|
|
11515
|
+
toolbar,
|
|
11516
|
+
/* @__PURE__ */ jsx("div", { className: "twc-cardgrid__spacer" }),
|
|
11517
|
+
sortSelectOptions ? /* @__PURE__ */ jsxs("div", { className: "twc-cardgrid__sort", children: [
|
|
11518
|
+
/* @__PURE__ */ jsx(
|
|
11519
|
+
Select,
|
|
11520
|
+
{
|
|
11521
|
+
size: "sm",
|
|
11522
|
+
searchable: false,
|
|
11523
|
+
value: sortVal?.field || "",
|
|
11524
|
+
options: sortSelectOptions,
|
|
11525
|
+
placeholder: "Sort by\u2026",
|
|
11526
|
+
"aria-label": "Sort by",
|
|
11527
|
+
onChange: (field) => commitSort(field ? { field, dir: sortVal?.dir || "asc" } : null)
|
|
11528
|
+
}
|
|
11529
|
+
),
|
|
11530
|
+
/* @__PURE__ */ jsx(
|
|
11531
|
+
"button",
|
|
11532
|
+
{
|
|
11533
|
+
type: "button",
|
|
11534
|
+
className: "twc-cardgrid__dir",
|
|
11535
|
+
"data-dir": sortVal?.dir || "asc",
|
|
11536
|
+
disabled: !sortVal?.field,
|
|
11537
|
+
"aria-label": sortVal?.dir === "desc" ? "Descending \u2014 click to sort ascending" : "Ascending \u2014 click to sort descending",
|
|
11538
|
+
onClick: () => sortVal?.field && commitSort({ field: sortVal.field, dir: sortVal.dir === "desc" ? "asc" : "desc" }),
|
|
11539
|
+
children: /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsx("path", { d: "M12 5v14M6 11l6-6 6 6" }) })
|
|
11540
|
+
}
|
|
11541
|
+
)
|
|
11542
|
+
] }) : null
|
|
11543
|
+
] }) : null,
|
|
11544
|
+
/* @__PURE__ */ jsxs("div", { className: "twc-cardgrid__body", "data-loading": loading || void 0, "aria-busy": loading || void 0, children: [
|
|
11545
|
+
loading ? /* @__PURE__ */ jsx("div", { className: "twc-cardgrid__overlay", children: /* @__PURE__ */ jsx("div", { className: "twc-cardgrid__spinner", role: "status", "aria-label": "Loading" }) }) : null,
|
|
11546
|
+
pageRows.length === 0 && !loading ? /* @__PURE__ */ jsx("div", { className: "twc-cardgrid__empty", children: emptyState }) : /* @__PURE__ */ jsx(
|
|
11547
|
+
Grid,
|
|
11548
|
+
{
|
|
11549
|
+
className: "twc-cardgrid__grid",
|
|
11550
|
+
minChildWidth,
|
|
11551
|
+
columns,
|
|
11552
|
+
gap,
|
|
11553
|
+
role: "list",
|
|
11554
|
+
"aria-labelledby": label ? `${fieldId}-label` : void 0,
|
|
11555
|
+
children: pageRows.map((row, i) => /* @__PURE__ */ jsx("div", { role: "listitem", children: renderCard(row, i) }, keyOf(row, i) ?? i))
|
|
11556
|
+
}
|
|
11557
|
+
)
|
|
11558
|
+
] }),
|
|
11559
|
+
paginated && totalPages > 0 ? /* @__PURE__ */ jsxs("div", { className: "twc-cardgrid__footer", children: [
|
|
11560
|
+
/* @__PURE__ */ jsx("span", { className: "twc-cardgrid__count", children: total === 0 ? "No results" : `${from}\u2013${to} of ${total}` }),
|
|
11561
|
+
/* @__PURE__ */ jsx(
|
|
11562
|
+
Pagination,
|
|
11563
|
+
{
|
|
11564
|
+
size: "sm",
|
|
11565
|
+
page: pageVal + 1,
|
|
11566
|
+
total: totalPages,
|
|
11567
|
+
boundaries: 1,
|
|
11568
|
+
siblings: 1,
|
|
11569
|
+
showPageJumper: totalPages > 7,
|
|
11570
|
+
onChange: (p) => commitPage(p - 1)
|
|
11571
|
+
}
|
|
11572
|
+
),
|
|
11573
|
+
showPageSize ? /* @__PURE__ */ jsxs("label", { className: "twc-cardgrid__perpage", children: [
|
|
11574
|
+
"Per page",
|
|
11575
|
+
/* @__PURE__ */ jsx(
|
|
11576
|
+
Select,
|
|
11577
|
+
{
|
|
11578
|
+
size: "sm",
|
|
11579
|
+
searchable: false,
|
|
11580
|
+
value: String(sizeVal),
|
|
11581
|
+
options: rppOptions,
|
|
11582
|
+
placement: "top",
|
|
11583
|
+
"aria-label": "Cards per page",
|
|
11584
|
+
onChange: (v) => commitSize(Number(v))
|
|
11585
|
+
}
|
|
11586
|
+
)
|
|
11587
|
+
] }) : /* @__PURE__ */ jsx("span", {})
|
|
11588
|
+
] }) : null
|
|
11589
|
+
] });
|
|
11590
|
+
}
|
|
11591
|
+
var DIFFTABLE_CSS = `
|
|
11592
|
+
.twc-difft { font-family: var(--font-sans); display: flex; flex-direction: column; gap: var(--space-3); color: var(--color-text); }
|
|
11593
|
+
.twc-difft__head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }
|
|
11594
|
+
.twc-difft__label { font-size: var(--text-sm); font-weight: var(--font-semibold); }
|
|
11595
|
+
.twc-difft__summary { display: inline-flex; flex-wrap: wrap; gap: var(--space-1-5); }
|
|
11596
|
+
.twc-difft__toggle { margin-inline-start: auto; }
|
|
11597
|
+
.twc-difft__scroll { overflow-x: auto; border: var(--border-thin) solid var(--color-border); border-radius: var(--radius-lg); }
|
|
11598
|
+
.twc-difft__table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
|
|
11599
|
+
.twc-difft__table th, .twc-difft__table td { text-align: start; padding: var(--space-2) var(--space-3); border-bottom: var(--border-thin) solid var(--color-divider); vertical-align: top; }
|
|
11600
|
+
.twc-difft__table thead th { position: sticky; top: 0; background: var(--color-surface-sunken); font-weight: var(--font-semibold); color: var(--color-text-muted); font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.02em; white-space: nowrap; z-index: 1; }
|
|
11601
|
+
.twc-difft__table tbody tr:last-child td { border-bottom: none; }
|
|
11602
|
+
.twc-difft__table tbody tr[data-op="added"] { background: color-mix(in srgb, var(--color-success) 8%, transparent); }
|
|
11603
|
+
.twc-difft__table tbody tr[data-op="removed"] { background: color-mix(in srgb, var(--color-danger) 8%, transparent); }
|
|
11604
|
+
.twc-difft__table tbody tr[data-op="modified"] { background: color-mix(in srgb, var(--color-warning) 8%, transparent); }
|
|
11605
|
+
.twc-difft__op { white-space: nowrap; }
|
|
11606
|
+
.twc-difft__change { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 2px; }
|
|
11607
|
+
.twc-difft__old { text-decoration: line-through; color: var(--color-text-subtle); }
|
|
11608
|
+
.twc-difft__new { color: var(--color-success-subtle-fg); font-weight: var(--font-medium); }
|
|
11609
|
+
.twc-difft__arrow { margin-inline: 6px; color: var(--color-text-subtle); }
|
|
11610
|
+
.twc-difft__empty { padding: var(--space-8) var(--space-4); text-align: center; color: var(--color-text-muted); }
|
|
11611
|
+
[dir="rtl"] .twc-difft__arrow { transform: scaleX(-1); display: inline-block; }
|
|
11612
|
+
`;
|
|
11613
|
+
var OPS = {
|
|
11614
|
+
added: { label: "Added", tone: "success" },
|
|
11615
|
+
removed: { label: "Removed", tone: "danger" },
|
|
11616
|
+
modified: { label: "Modified", tone: "warning" },
|
|
11617
|
+
moved: { label: "Moved", tone: "info" },
|
|
11618
|
+
unchanged: { label: "Unchanged", tone: "neutral" }
|
|
11619
|
+
};
|
|
11620
|
+
function lisIndexSet(seq) {
|
|
11621
|
+
const n = seq.length;
|
|
11622
|
+
if (n === 0) return /* @__PURE__ */ new Set();
|
|
11623
|
+
const dp = new Array(n).fill(1), prev = new Array(n).fill(-1);
|
|
11624
|
+
let best = 0;
|
|
11625
|
+
for (let i = 0; i < n; i++) {
|
|
11626
|
+
for (let j = 0; j < i; j++) {
|
|
11627
|
+
if (seq[j] < seq[i] && dp[j] + 1 > dp[i]) {
|
|
11628
|
+
dp[i] = dp[j] + 1;
|
|
11629
|
+
prev[i] = j;
|
|
11630
|
+
}
|
|
11631
|
+
}
|
|
11632
|
+
if (dp[i] > dp[best]) best = i;
|
|
11633
|
+
}
|
|
11634
|
+
const set = /* @__PURE__ */ new Set();
|
|
11635
|
+
for (let i = best; i !== -1; i = prev[i]) set.add(i);
|
|
11636
|
+
return set;
|
|
11637
|
+
}
|
|
11638
|
+
var getVal = (col, row) => col.valueGetter ? col.valueGetter(row) : row == null ? void 0 : row[col.field];
|
|
11639
|
+
var fmtVal = (col, v) => col.valueFormatter ? col.valueFormatter(v) : v == null ? "" : String(v);
|
|
11640
|
+
function DiffTable({
|
|
11641
|
+
from = [],
|
|
11642
|
+
to = [],
|
|
11643
|
+
rowKey,
|
|
11644
|
+
columns = [],
|
|
11645
|
+
onlyChanged = true,
|
|
11646
|
+
showToggle = true,
|
|
11647
|
+
showSummary = true,
|
|
11648
|
+
moveDetection = true,
|
|
11649
|
+
compare,
|
|
11650
|
+
emptyState = "No differences.",
|
|
11651
|
+
toggleLabel = "Only changed",
|
|
11652
|
+
label,
|
|
11653
|
+
id,
|
|
11654
|
+
className = "",
|
|
11655
|
+
...rest
|
|
11656
|
+
}) {
|
|
11657
|
+
const styles = useScopedStyles("twc-difftable-styles", DIFFTABLE_CSS);
|
|
11658
|
+
const autoId = React51__default.useId();
|
|
11659
|
+
const fieldId = id || autoId;
|
|
11660
|
+
const [only, setOnly] = React51__default.useState(onlyChanged);
|
|
11661
|
+
const valEq = React51__default.useCallback((a, b, col) => {
|
|
11662
|
+
if (col.compare) return col.compare(a, b);
|
|
11663
|
+
if (compare) return compare(a, b, col.field);
|
|
11664
|
+
if (a === b) return true;
|
|
11665
|
+
if (a == null || b == null) return a === b;
|
|
11666
|
+
return JSON.stringify(a) === JSON.stringify(b);
|
|
11667
|
+
}, [compare]);
|
|
11668
|
+
const diff = React51__default.useMemo(() => {
|
|
11669
|
+
const k = rowKey || ((r2) => r2 == null ? r2 : r2.id);
|
|
11670
|
+
const fromMap = /* @__PURE__ */ new Map(), toMap = /* @__PURE__ */ new Map();
|
|
11671
|
+
from.forEach((r2, i) => fromMap.set(k(r2), { row: r2, i }));
|
|
11672
|
+
to.forEach((r2, i) => toMap.set(k(r2), { row: r2, i }));
|
|
11673
|
+
const movedKeys = /* @__PURE__ */ new Set();
|
|
11674
|
+
if (moveDetection) {
|
|
11675
|
+
const commonFrom = from.filter((r2) => toMap.has(k(r2)));
|
|
11676
|
+
const seq = commonFrom.map((r2) => toMap.get(k(r2)).i);
|
|
11677
|
+
const stable = lisIndexSet(seq);
|
|
11678
|
+
commonFrom.forEach((r2, idx) => {
|
|
11679
|
+
if (!stable.has(idx)) movedKeys.add(k(r2));
|
|
11680
|
+
});
|
|
11681
|
+
}
|
|
11682
|
+
const classify = (key) => {
|
|
11683
|
+
const a = fromMap.get(key), b = toMap.get(key);
|
|
11684
|
+
if (a && !b) return { op: "removed", from: a.row, to: null, changed: /* @__PURE__ */ new Set() };
|
|
11685
|
+
if (!a && b) return { op: "added", from: null, to: b.row, changed: /* @__PURE__ */ new Set() };
|
|
11686
|
+
const changed = /* @__PURE__ */ new Set();
|
|
11687
|
+
for (const col of columns) if (!valEq(getVal(col, a.row), getVal(col, b.row), col)) changed.add(col.field);
|
|
11688
|
+
if (changed.size) return { op: "modified", from: a.row, to: b.row, changed };
|
|
11689
|
+
if (movedKeys.has(key)) return { op: "moved", from: a.row, to: b.row, changed };
|
|
11690
|
+
return { op: "unchanged", from: a.row, to: b.row, changed };
|
|
11691
|
+
};
|
|
11692
|
+
const rows = [];
|
|
11693
|
+
to.forEach((r2) => rows.push({ key: k(r2), ...classify(k(r2)) }));
|
|
11694
|
+
from.forEach((r2) => {
|
|
11695
|
+
const key = k(r2);
|
|
11696
|
+
if (!toMap.has(key)) rows.push({ key, ...classify(key) });
|
|
11697
|
+
});
|
|
11698
|
+
const counts = { added: 0, removed: 0, modified: 0, moved: 0, unchanged: 0 };
|
|
11699
|
+
rows.forEach((r2) => {
|
|
11700
|
+
counts[r2.op] += 1;
|
|
11701
|
+
});
|
|
11702
|
+
return { rows, counts };
|
|
11703
|
+
}, [from, to, columns, rowKey, moveDetection, valEq]);
|
|
11704
|
+
const visible = only ? diff.rows.filter((r2) => r2.op !== "unchanged") : diff.rows;
|
|
11705
|
+
const renderCell = (r2, col) => {
|
|
11706
|
+
if (r2.op === "removed") return /* @__PURE__ */ jsx("span", { className: "twc-difft__old", children: fmtVal(col, getVal(col, r2.from)) });
|
|
11707
|
+
if (r2.op === "added") return /* @__PURE__ */ jsx("span", { className: "twc-difft__new", children: fmtVal(col, getVal(col, r2.to)) });
|
|
11708
|
+
if (r2.op === "modified" && r2.changed.has(col.field)) {
|
|
11709
|
+
return /* @__PURE__ */ jsxs("span", { className: "twc-difft__change", children: [
|
|
11710
|
+
/* @__PURE__ */ jsx("span", { className: "twc-difft__old", children: fmtVal(col, getVal(col, r2.from)) }),
|
|
11711
|
+
/* @__PURE__ */ jsx("span", { className: "twc-difft__arrow", "aria-hidden": "true", children: "\u2192" }),
|
|
11712
|
+
/* @__PURE__ */ jsx("span", { className: "twc-difft__new", children: fmtVal(col, getVal(col, r2.to)) })
|
|
11713
|
+
] });
|
|
11714
|
+
}
|
|
11715
|
+
return /* @__PURE__ */ jsx("span", { children: fmtVal(col, getVal(col, r2.to ?? r2.from)) });
|
|
11716
|
+
};
|
|
11717
|
+
return /* @__PURE__ */ jsxs("div", { className: `twc-difft ${className}`, id: fieldId, ...rest, children: [
|
|
11718
|
+
styles,
|
|
11719
|
+
label || showSummary || showToggle ? /* @__PURE__ */ jsxs("div", { className: "twc-difft__head", children: [
|
|
11720
|
+
label ? /* @__PURE__ */ jsx("div", { className: "twc-difft__label", children: label }) : null,
|
|
11721
|
+
showSummary ? /* @__PURE__ */ jsxs("div", { className: "twc-difft__summary", children: [
|
|
11722
|
+
/* @__PURE__ */ jsxs(Badge, { size: "sm", variant: "soft", tone: "success", children: [
|
|
11723
|
+
"+",
|
|
11724
|
+
diff.counts.added,
|
|
11725
|
+
" added"
|
|
11726
|
+
] }),
|
|
11727
|
+
/* @__PURE__ */ jsxs(Badge, { size: "sm", variant: "soft", tone: "warning", children: [
|
|
11728
|
+
"~",
|
|
11729
|
+
diff.counts.modified,
|
|
11730
|
+
" modified"
|
|
11731
|
+
] }),
|
|
11732
|
+
/* @__PURE__ */ jsxs(Badge, { size: "sm", variant: "soft", tone: "danger", children: [
|
|
11733
|
+
"-",
|
|
11734
|
+
diff.counts.removed,
|
|
11735
|
+
" removed"
|
|
11736
|
+
] }),
|
|
11737
|
+
diff.counts.moved ? /* @__PURE__ */ jsxs(Badge, { size: "sm", variant: "soft", tone: "info", children: [
|
|
11738
|
+
"\u21C5 ",
|
|
11739
|
+
diff.counts.moved,
|
|
11740
|
+
" moved"
|
|
11741
|
+
] }) : null
|
|
11742
|
+
] }) : null,
|
|
11743
|
+
showToggle ? /* @__PURE__ */ jsx("div", { className: "twc-difft__toggle", children: /* @__PURE__ */ jsx(Checkbox, { label: toggleLabel, checked: only, onChange: (e) => setOnly(e.target.checked) }) }) : null
|
|
11744
|
+
] }) : null,
|
|
11745
|
+
/* @__PURE__ */ jsx("div", { className: "twc-difft__scroll", children: /* @__PURE__ */ jsxs("table", { className: "twc-difft__table", children: [
|
|
11746
|
+
/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
11747
|
+
/* @__PURE__ */ jsx("th", { scope: "col", children: "Change" }),
|
|
11748
|
+
columns.map((c) => /* @__PURE__ */ jsx("th", { scope: "col", children: c.headerName || c.field }, c.field))
|
|
11749
|
+
] }) }),
|
|
11750
|
+
/* @__PURE__ */ jsx("tbody", { children: visible.length === 0 ? /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx("td", { className: "twc-difft__empty", colSpan: columns.length + 1, children: emptyState }) }) : visible.map((r2) => /* @__PURE__ */ jsxs("tr", { "data-op": r2.op, children: [
|
|
11751
|
+
/* @__PURE__ */ jsx("td", { className: "twc-difft__op", children: /* @__PURE__ */ jsx(Badge, { size: "sm", variant: "soft", tone: OPS[r2.op].tone, children: OPS[r2.op].label }) }),
|
|
11752
|
+
columns.map((c) => /* @__PURE__ */ jsx("td", { children: renderCell(r2, c) }, c.field))
|
|
11753
|
+
] }, r2.key)) })
|
|
11754
|
+
] }) })
|
|
11755
|
+
] });
|
|
11756
|
+
}
|
|
11227
11757
|
var FIELD_CSS3 = `
|
|
11228
11758
|
.twc-field { display: flex; flex-direction: column; gap: var(--space-1-5); font-family: var(--font-sans); }
|
|
11229
11759
|
.twc-field__label { font-size: var(--text-sm); font-weight: var(--font-semibold); color: var(--color-text); display: flex; gap: 4px; align-items: center; }
|
|
@@ -11235,13 +11765,15 @@ var DATEPICKER_CSS = `
|
|
|
11235
11765
|
.twc-dp { position: relative; font-family: var(--font-sans); display: flex; flex-direction: column; gap: var(--space-1-5); }
|
|
11236
11766
|
.twc-dp__label { font-size: var(--text-sm); font-weight: var(--font-semibold); color: var(--color-text); }
|
|
11237
11767
|
.twc-dp__control {
|
|
11238
|
-
display: flex; align-items: center; gap: var(--space-2);
|
|
11768
|
+
display: flex; align-items: center; gap: var(--space-2); --_h: var(--control-h-md); height: var(--_h); padding: 0 var(--space-3);
|
|
11239
11769
|
background: var(--color-surface); border: var(--border-thin) solid var(--color-border); border-radius: var(--radius-md);
|
|
11240
11770
|
cursor: pointer; transition: border-color var(--duration-fast) var(--ease-standard), box-shadow var(--duration-fast) var(--ease-standard);
|
|
11241
11771
|
}
|
|
11242
11772
|
.twc-dp__control:hover:not([data-open="true"]) { border-color: var(--color-border-strong); }
|
|
11243
11773
|
/* tone \u2192 focus/open accent (default primary; reproduces current look). */
|
|
11244
11774
|
.twc-dp__control { --_accent: var(--color-primary); --_ring: var(--ring); }
|
|
11775
|
+
.twc-dp__control[data-size="sm"] { --_h: var(--control-h-sm); }
|
|
11776
|
+
.twc-dp__control[data-size="lg"] { --_h: var(--control-h-lg); }
|
|
11245
11777
|
.twc-dp__control[data-tone="success"] { --_accent: var(--color-success); --_ring: 0 0 0 var(--ring-width) color-mix(in srgb, var(--color-success) 32%, transparent); }
|
|
11246
11778
|
.twc-dp__control[data-tone="warning"] { --_accent: var(--color-warning); --_ring: 0 0 0 var(--ring-width) color-mix(in srgb, var(--color-warning) 32%, transparent); }
|
|
11247
11779
|
.twc-dp__control[data-tone="danger"] { --_accent: var(--color-danger); --_ring: 0 0 0 var(--ring-width) color-mix(in srgb, var(--color-danger) 32%, transparent); }
|
|
@@ -11301,6 +11833,12 @@ var DATEPICKER_CSS = `
|
|
|
11301
11833
|
.twc-dp__mo { padding: 10px 0; border: none; background: transparent; cursor: pointer; font-family: inherit; font-size: var(--text-sm); color: var(--color-text); border-radius: var(--radius-md); }
|
|
11302
11834
|
.twc-dp__mo:hover { background: var(--color-surface-sunken); }
|
|
11303
11835
|
.twc-dp__mo[data-selected="true"] { background: var(--color-primary); color: var(--color-primary-fg); font-weight: var(--font-bold); }
|
|
11836
|
+
.twc-dp__years { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
|
|
11837
|
+
.twc-dp__yr { padding: 10px 0; border: none; background: transparent; cursor: pointer; font-family: inherit; font-size: var(--text-sm); color: var(--color-text); border-radius: var(--radius-md); }
|
|
11838
|
+
.twc-dp__yr:hover:not(:disabled) { background: var(--color-surface-sunken); }
|
|
11839
|
+
.twc-dp__yr[data-outside="true"] { color: var(--color-text-subtle); }
|
|
11840
|
+
.twc-dp__yr[data-selected="true"] { background: var(--color-primary); color: var(--color-primary-fg); font-weight: var(--font-bold); }
|
|
11841
|
+
.twc-dp__yr:disabled { opacity: 0.4; cursor: not-allowed; }
|
|
11304
11842
|
[dir="rtl"] .twc-dp__nav svg { transform: scaleX(-1); }
|
|
11305
11843
|
`;
|
|
11306
11844
|
var MONTHS = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
|
|
@@ -11328,8 +11866,10 @@ function DatePicker({
|
|
|
11328
11866
|
placeholder = "Select date",
|
|
11329
11867
|
min,
|
|
11330
11868
|
max,
|
|
11869
|
+
disabledDate,
|
|
11331
11870
|
disabled = false,
|
|
11332
11871
|
tone = "primary",
|
|
11872
|
+
size = "md",
|
|
11333
11873
|
clearable = true,
|
|
11334
11874
|
editable = false,
|
|
11335
11875
|
parse,
|
|
@@ -11354,6 +11894,7 @@ function DatePicker({
|
|
|
11354
11894
|
const [mode, setMode] = React51__default.useState("days");
|
|
11355
11895
|
const [focusDate, setFocusDate] = React51__default.useState(null);
|
|
11356
11896
|
const [focusMonth, setFocusMonth] = React51__default.useState(null);
|
|
11897
|
+
const [focusYear, setFocusYear] = React51__default.useState(null);
|
|
11357
11898
|
const [editText, setEditText] = React51__default.useState(null);
|
|
11358
11899
|
const [coords, setCoords] = React51__default.useState(null);
|
|
11359
11900
|
const wrapRef = React51__default.useRef(null);
|
|
@@ -11446,11 +11987,13 @@ function DatePicker({
|
|
|
11446
11987
|
pick(parsed);
|
|
11447
11988
|
};
|
|
11448
11989
|
const y = view.getFullYear(), m = view.getMonth();
|
|
11990
|
+
const decadeStart = Math.floor(y / 10) * 10;
|
|
11991
|
+
const yearCells = Array.from({ length: 12 }, (_, i) => decadeStart - 1 + i);
|
|
11449
11992
|
const first = new Date(y, m, 1);
|
|
11450
11993
|
const startOffset = (first.getDay() - weekStartsOn + 7) % 7;
|
|
11451
11994
|
const gridStart = new Date(y, m, 1 - startOffset);
|
|
11452
11995
|
const today = /* @__PURE__ */ new Date();
|
|
11453
|
-
const outOfRange = (d) => min && d < new Date(min.getFullYear(), min.getMonth(), min.getDate()) || max && d > new Date(max.getFullYear(), max.getMonth(), max.getDate());
|
|
11996
|
+
const outOfRange = (d) => min && d < new Date(min.getFullYear(), min.getMonth(), min.getDate()) || max && d > new Date(max.getFullYear(), max.getMonth(), max.getDate()) || Boolean(disabledDate && disabledDate(d));
|
|
11454
11997
|
const keyOf = (d) => `${d.getFullYear()}-${d.getMonth()}-${d.getDate()}`;
|
|
11455
11998
|
const addDays = (d, n) => new Date(d.getFullYear(), d.getMonth(), d.getDate() + n);
|
|
11456
11999
|
const addMonths = (d, n) => {
|
|
@@ -11487,6 +12030,24 @@ function DatePicker({
|
|
|
11487
12030
|
}
|
|
11488
12031
|
setFocusMonth(next);
|
|
11489
12032
|
};
|
|
12033
|
+
React51__default.useEffect(() => {
|
|
12034
|
+
if (!open || mode !== "years" || focusYear == null) return;
|
|
12035
|
+
gridRef.current?.querySelector(`[data-yr="${focusYear}"]`)?.focus();
|
|
12036
|
+
}, [focusYear, open, mode]);
|
|
12037
|
+
const onYearsKeyDown = (e) => {
|
|
12038
|
+
const cur = focusYear == null ? y : focusYear;
|
|
12039
|
+
let next;
|
|
12040
|
+
if (e.key === "ArrowRight") next = cur + 1;
|
|
12041
|
+
else if (e.key === "ArrowLeft") next = cur - 1;
|
|
12042
|
+
else if (e.key === "ArrowDown") next = cur + 3;
|
|
12043
|
+
else if (e.key === "ArrowUp") next = cur - 3;
|
|
12044
|
+
else if (e.key === "Home") next = decadeStart;
|
|
12045
|
+
else if (e.key === "End") next = decadeStart + 9;
|
|
12046
|
+
else return;
|
|
12047
|
+
e.preventDefault();
|
|
12048
|
+
setView(new Date(next, m, 1));
|
|
12049
|
+
setFocusYear(next);
|
|
12050
|
+
};
|
|
11490
12051
|
const onGridKeyDown = (e) => {
|
|
11491
12052
|
const btn = e.target.closest?.("[data-key]");
|
|
11492
12053
|
if (!btn) return;
|
|
@@ -11531,6 +12092,7 @@ function DatePicker({
|
|
|
11531
12092
|
"data-disabled": disabled || void 0,
|
|
11532
12093
|
"data-tone": tone,
|
|
11533
12094
|
"data-invalid": invalid || void 0,
|
|
12095
|
+
"data-size": size,
|
|
11534
12096
|
children: [
|
|
11535
12097
|
/* @__PURE__ */ jsx(
|
|
11536
12098
|
"input",
|
|
@@ -11604,6 +12166,7 @@ function DatePicker({
|
|
|
11604
12166
|
id: fieldId,
|
|
11605
12167
|
"data-open": open || void 0,
|
|
11606
12168
|
"data-disabled": disabled || void 0,
|
|
12169
|
+
"data-size": size,
|
|
11607
12170
|
"data-tone": tone,
|
|
11608
12171
|
"data-has-clear": clearable && selected && !disabled ? "true" : void 0,
|
|
11609
12172
|
"data-invalid": invalid || void 0,
|
|
@@ -11647,13 +12210,18 @@ function DatePicker({
|
|
|
11647
12210
|
style: { position: "fixed", left: coords.left, right: "auto", top: coords.top, bottom: coords.bottom, zIndex: "var(--z-tooltip)" },
|
|
11648
12211
|
children: [
|
|
11649
12212
|
/* @__PURE__ */ jsxs("div", { className: "twc-dp__head", children: [
|
|
11650
|
-
/* @__PURE__ */ jsx("button", { type: "button", className: "twc-dp__nav", "aria-label": "Previous", onClick: () => setView(mode === "months" ? new Date(y - 1, m, 1) : new Date(y, m - 1, 1)), children: /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsx("path", { d: "m15 18-6-6 6-6" }) }) }),
|
|
12213
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: "twc-dp__nav", "aria-label": mode === "years" ? "Previous decade" : mode === "months" ? "Previous year" : "Previous month", onClick: () => setView(mode === "years" ? new Date(y - 10, m, 1) : mode === "months" ? new Date(y - 1, m, 1) : new Date(y, m - 1, 1)), children: /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsx("path", { d: "m15 18-6-6 6-6" }) }) }),
|
|
11651
12214
|
/* @__PURE__ */ jsx("button", { type: "button", className: "twc-dp__title", onClick: () => {
|
|
11652
|
-
if (mode === "days")
|
|
11653
|
-
|
|
11654
|
-
|
|
11655
|
-
|
|
11656
|
-
|
|
12215
|
+
if (mode === "days") {
|
|
12216
|
+
setFocusMonth(m);
|
|
12217
|
+
setMode("months");
|
|
12218
|
+
} else if (mode === "months") {
|
|
12219
|
+
setFocusYear(y);
|
|
12220
|
+
setMode("years");
|
|
12221
|
+
} else setMode("days");
|
|
12222
|
+
}, children: mode === "days" ? `${months[m]} ${y}` : mode === "months" ? y : `${decadeStart}\u2013${decadeStart + 9}` }),
|
|
12223
|
+
/* @__PURE__ */ jsx("span", { className: "twc-dp__sr", "aria-live": "polite", children: mode === "days" ? `${months[m]} ${y}` : mode === "months" ? y : `${decadeStart}\u2013${decadeStart + 9}` }),
|
|
12224
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: "twc-dp__nav", "aria-label": mode === "years" ? "Next decade" : mode === "months" ? "Next year" : "Next month", onClick: () => setView(mode === "years" ? new Date(y + 10, m, 1) : mode === "months" ? new Date(y + 1, m, 1) : new Date(y, m + 1, 1)), children: /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsx("path", { d: "m9 18 6-6-6-6" }) }) })
|
|
11657
12225
|
] }),
|
|
11658
12226
|
mode === "days" ? /* @__PURE__ */ jsxs("div", { className: "twc-dp__grid", ref: gridRef, onKeyDown: onGridKeyDown, children: [
|
|
11659
12227
|
dows.map((d, i) => /* @__PURE__ */ jsx("div", { className: "twc-dp__dow", children: d }, i)),
|
|
@@ -11679,7 +12247,7 @@ function DatePicker({
|
|
|
11679
12247
|
i
|
|
11680
12248
|
);
|
|
11681
12249
|
})
|
|
11682
|
-
] }) : /* @__PURE__ */ jsx("div", { className: "twc-dp__months", ref: gridRef, onKeyDown: onMonthsKeyDown, role: "grid", children: monthsShort.map((name, i) => /* @__PURE__ */ jsx(
|
|
12250
|
+
] }) : mode === "months" ? /* @__PURE__ */ jsx("div", { className: "twc-dp__months", ref: gridRef, onKeyDown: onMonthsKeyDown, role: "grid", children: monthsShort.map((name, i) => /* @__PURE__ */ jsx(
|
|
11683
12251
|
"button",
|
|
11684
12252
|
{
|
|
11685
12253
|
type: "button",
|
|
@@ -11695,7 +12263,30 @@ function DatePicker({
|
|
|
11695
12263
|
children: name
|
|
11696
12264
|
},
|
|
11697
12265
|
i
|
|
11698
|
-
)) })
|
|
12266
|
+
)) }) : /* @__PURE__ */ jsx("div", { className: "twc-dp__years", ref: gridRef, onKeyDown: onYearsKeyDown, role: "grid", children: yearCells.map((yr) => {
|
|
12267
|
+
const outside = yr < decadeStart || yr > decadeStart + 9;
|
|
12268
|
+
const disabled2 = min && yr < min.getFullYear() || max && yr > max.getFullYear();
|
|
12269
|
+
return /* @__PURE__ */ jsx(
|
|
12270
|
+
"button",
|
|
12271
|
+
{
|
|
12272
|
+
type: "button",
|
|
12273
|
+
className: "twc-dp__yr",
|
|
12274
|
+
role: "gridcell",
|
|
12275
|
+
"data-yr": yr,
|
|
12276
|
+
"data-outside": outside || void 0,
|
|
12277
|
+
disabled: disabled2,
|
|
12278
|
+
"data-selected": selected && selected.getFullYear() === yr || void 0,
|
|
12279
|
+
tabIndex: yr === (focusYear ?? y) ? 0 : -1,
|
|
12280
|
+
onClick: () => {
|
|
12281
|
+
setView(new Date(yr, m, 1));
|
|
12282
|
+
setFocusMonth(m);
|
|
12283
|
+
setMode("months");
|
|
12284
|
+
},
|
|
12285
|
+
children: yr
|
|
12286
|
+
},
|
|
12287
|
+
yr
|
|
12288
|
+
);
|
|
12289
|
+
}) })
|
|
11699
12290
|
]
|
|
11700
12291
|
}
|
|
11701
12292
|
),
|
|
@@ -11714,12 +12305,14 @@ var FIELD_CSS4 = `
|
|
|
11714
12305
|
var RANGE_CSS2 = `
|
|
11715
12306
|
.twc-drp { position: relative; font-family: var(--font-sans); display: flex; flex-direction: column; gap: var(--space-1-5); }
|
|
11716
12307
|
.twc-drp__label { font-size: var(--text-sm); font-weight: var(--font-semibold); color: var(--color-text); }
|
|
11717
|
-
.twc-drp__control { display: flex; align-items: center; gap: var(--space-2);
|
|
12308
|
+
.twc-drp__control { display: flex; align-items: center; gap: var(--space-2); --_h: var(--control-h-md); height: var(--_h); padding: 0 var(--space-3);
|
|
11718
12309
|
background: var(--color-surface); border: var(--border-thin) solid var(--color-border); border-radius: var(--radius-md); cursor: pointer;
|
|
11719
12310
|
transition: border-color var(--duration-fast) var(--ease-standard), box-shadow var(--duration-fast) var(--ease-standard); }
|
|
11720
12311
|
.twc-drp__control:hover:not([data-open="true"]):not([data-disabled="true"]) { border-color: var(--color-border-strong); }
|
|
11721
12312
|
/* tone \u2192 focus/open accent (default primary; reproduces current look). */
|
|
11722
12313
|
.twc-drp__control { --_accent: var(--color-primary); --_ring: var(--ring); }
|
|
12314
|
+
.twc-drp__control[data-size="sm"] { --_h: var(--control-h-sm); }
|
|
12315
|
+
.twc-drp__control[data-size="lg"] { --_h: var(--control-h-lg); }
|
|
11723
12316
|
.twc-drp__control[data-tone="success"] { --_accent: var(--color-success); --_ring: 0 0 0 var(--ring-width) color-mix(in srgb, var(--color-success) 32%, transparent); }
|
|
11724
12317
|
.twc-drp__control[data-tone="warning"] { --_accent: var(--color-warning); --_ring: 0 0 0 var(--ring-width) color-mix(in srgb, var(--color-warning) 32%, transparent); }
|
|
11725
12318
|
.twc-drp__control[data-tone="danger"] { --_accent: var(--color-danger); --_ring: 0 0 0 var(--ring-width) color-mix(in srgb, var(--color-danger) 32%, transparent); }
|
|
@@ -11733,6 +12326,9 @@ var RANGE_CSS2 = `
|
|
|
11733
12326
|
.twc-drp__ic svg { width: 17px; height: 17px; }
|
|
11734
12327
|
.twc-drp__text { flex: 1; font-size: var(--text-sm); color: var(--color-text); white-space: nowrap; }
|
|
11735
12328
|
.twc-drp__text[data-placeholder="true"] { color: var(--color-text-subtle); }
|
|
12329
|
+
.twc-drp__clear { flex: none; display: inline-grid; place-items: center; width: 20px; height: 20px; border: none; padding: 0; background: transparent; color: var(--color-text-subtle); cursor: pointer; border-radius: var(--radius-full); }
|
|
12330
|
+
.twc-drp__clear:hover { background: var(--color-surface-sunken); color: var(--color-text); }
|
|
12331
|
+
.twc-drp__clear svg { width: 14px; height: 14px; }
|
|
11736
12332
|
/* #105: editable (typed entry) variant. */
|
|
11737
12333
|
.twc-drp__control--editable { cursor: text; gap: 0; padding-inline-end: var(--space-1); }
|
|
11738
12334
|
.twc-drp__input { flex: 1; min-width: 0; height: 100%; border: none; background: transparent; outline: none; padding: 0;
|
|
@@ -11756,7 +12352,14 @@ var RANGE_CSS2 = `
|
|
|
11756
12352
|
.twc-drp__nav { display: inline-grid; place-items: center; width: 30px; height: 30px; border: none; background: transparent; color: var(--color-text-muted); cursor: pointer; border-radius: var(--radius-md); }
|
|
11757
12353
|
.twc-drp__nav:hover { background: var(--color-surface-sunken); color: var(--color-text); }
|
|
11758
12354
|
.twc-drp__nav svg { width: 17px; height: 17px; }
|
|
11759
|
-
.twc-drp__title { font-size: var(--text-sm); font-weight: var(--font-bold); }
|
|
12355
|
+
.twc-drp__title { font-size: var(--text-sm); font-weight: var(--font-bold); color: var(--color-text); border: none; background: transparent; cursor: pointer; padding: 5px 10px; border-radius: var(--radius-md); }
|
|
12356
|
+
.twc-drp__title:hover { background: var(--color-surface-sunken); }
|
|
12357
|
+
.twc-drp__months, .twc-drp__years { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
|
|
12358
|
+
.twc-drp__mo, .twc-drp__yr { padding: 10px 0; border: none; background: transparent; cursor: pointer; font-family: inherit; font-size: var(--text-sm); color: var(--color-text); border-radius: var(--radius-md); }
|
|
12359
|
+
.twc-drp__mo:hover:not(:disabled), .twc-drp__yr:hover:not(:disabled) { background: var(--color-surface-sunken); }
|
|
12360
|
+
.twc-drp__yr[data-outside="true"] { color: var(--color-text-subtle); }
|
|
12361
|
+
.twc-drp__mo[data-selected="true"], .twc-drp__yr[data-selected="true"] { background: var(--color-primary); color: var(--color-primary-fg); font-weight: var(--font-bold); }
|
|
12362
|
+
.twc-drp__mo:disabled, .twc-drp__yr:disabled { opacity: 0.4; cursor: not-allowed; }
|
|
11760
12363
|
.twc-drp__grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; }
|
|
11761
12364
|
.twc-drp__dow { text-align: center; font-size: 11px; font-weight: var(--font-bold); color: var(--color-text-subtle); padding: 4px 0; }
|
|
11762
12365
|
.twc-drp__day { aspect-ratio: 1; border: none; background: transparent; cursor: pointer; font-family: inherit; font-size: var(--text-sm); color: var(--color-text); display: grid; place-items: center; position: relative; }
|
|
@@ -11782,6 +12385,18 @@ var weekdayNames2 = (locale, weekStartsOn) => {
|
|
|
11782
12385
|
};
|
|
11783
12386
|
var ymd = (d) => d ? new Date(d.getFullYear(), d.getMonth(), d.getDate()).getTime() : null;
|
|
11784
12387
|
var fmtD = (d, locale) => d ? d.toLocaleDateString(locale, { month: "short", day: "numeric", year: "numeric" }) : "";
|
|
12388
|
+
var rollingDays = (days) => {
|
|
12389
|
+
const end = /* @__PURE__ */ new Date();
|
|
12390
|
+
const start = /* @__PURE__ */ new Date();
|
|
12391
|
+
start.setDate(end.getDate() - days + 1);
|
|
12392
|
+
return { start, end };
|
|
12393
|
+
};
|
|
12394
|
+
var DEFAULT_PRESETS2 = [
|
|
12395
|
+
{ label: "Last 7 days", range: () => rollingDays(7) },
|
|
12396
|
+
{ label: "Last 14 days", range: () => rollingDays(14) },
|
|
12397
|
+
{ label: "Last 30 days", range: () => rollingDays(30) },
|
|
12398
|
+
{ label: "Last 90 days", range: () => rollingDays(90) }
|
|
12399
|
+
];
|
|
11785
12400
|
function DateRangePicker({
|
|
11786
12401
|
label,
|
|
11787
12402
|
hint,
|
|
@@ -11798,6 +12413,9 @@ function DateRangePicker({
|
|
|
11798
12413
|
disabledDate,
|
|
11799
12414
|
disabled = false,
|
|
11800
12415
|
tone = "primary",
|
|
12416
|
+
size = "md",
|
|
12417
|
+
clearable = true,
|
|
12418
|
+
format,
|
|
11801
12419
|
editable = false,
|
|
11802
12420
|
parse,
|
|
11803
12421
|
onChange,
|
|
@@ -11807,11 +12425,14 @@ function DateRangePicker({
|
|
|
11807
12425
|
const __twcStyles0 = useScopedStyles("twc-field-styles", FIELD_CSS4);
|
|
11808
12426
|
const __twcStyles1 = useScopedStyles("twc-drp-styles", RANGE_CSS2);
|
|
11809
12427
|
const [internal, setInternal] = React51__default.useState(defaultValue);
|
|
11810
|
-
const
|
|
12428
|
+
const range2 = value !== void 0 ? value : internal;
|
|
11811
12429
|
const [open, setOpen] = React51__default.useState(false);
|
|
11812
|
-
const [view, setView] = React51__default.useState(
|
|
12430
|
+
const [view, setView] = React51__default.useState(range2.start || /* @__PURE__ */ new Date());
|
|
11813
12431
|
const [hover, setHover] = React51__default.useState(null);
|
|
11814
12432
|
const [focusDate, setFocusDate] = React51__default.useState(null);
|
|
12433
|
+
const [mode, setMode] = React51__default.useState("days");
|
|
12434
|
+
const [focusMonth, setFocusMonth] = React51__default.useState(null);
|
|
12435
|
+
const [focusYear, setFocusYear] = React51__default.useState(null);
|
|
11815
12436
|
const [editText, setEditText] = React51__default.useState(null);
|
|
11816
12437
|
const [coords, setCoords] = React51__default.useState(null);
|
|
11817
12438
|
const wrapRef = React51__default.useRef(null);
|
|
@@ -11883,7 +12504,7 @@ function DateRangePicker({
|
|
|
11883
12504
|
const raw = editText.trim();
|
|
11884
12505
|
if (raw === "") {
|
|
11885
12506
|
setEditText(null);
|
|
11886
|
-
if (
|
|
12507
|
+
if (range2.start || range2.end) set({ start: null, end: null });
|
|
11887
12508
|
return;
|
|
11888
12509
|
}
|
|
11889
12510
|
const parts = raw.split(/\s*(?:–|—|\bto\b|\.\.+)\s*/i).map((p) => p.trim());
|
|
@@ -11915,8 +12536,15 @@ function DateRangePicker({
|
|
|
11915
12536
|
if (!open) {
|
|
11916
12537
|
setFocusDate(null);
|
|
11917
12538
|
setHover(null);
|
|
12539
|
+
setMode("days");
|
|
11918
12540
|
}
|
|
11919
12541
|
}, [open]);
|
|
12542
|
+
React51__default.useEffect(() => {
|
|
12543
|
+
if (open && mode === "months" && focusMonth != null) gridRef.current?.querySelector(`[data-mo="${focusMonth}"]`)?.focus();
|
|
12544
|
+
}, [focusMonth, open, mode]);
|
|
12545
|
+
React51__default.useEffect(() => {
|
|
12546
|
+
if (open && mode === "years" && focusYear != null) gridRef.current?.querySelector(`[data-yr="${focusYear}"]`)?.focus();
|
|
12547
|
+
}, [focusYear, open, mode]);
|
|
11920
12548
|
React51__default.useEffect(() => {
|
|
11921
12549
|
if (!open || !focusDate) return;
|
|
11922
12550
|
gridRef.current?.querySelector(`[data-key="${keyOf(focusDate)}"]`)?.focus();
|
|
@@ -11947,35 +12575,74 @@ function DateRangePicker({
|
|
|
11947
12575
|
setHover(next);
|
|
11948
12576
|
if (next.getFullYear() !== view.getFullYear() || next.getMonth() !== view.getMonth()) setView(new Date(next.getFullYear(), next.getMonth(), 1));
|
|
11949
12577
|
};
|
|
11950
|
-
const
|
|
12578
|
+
const onMonthsKeyDown = (e) => {
|
|
12579
|
+
const vy = view.getFullYear();
|
|
12580
|
+
const cur = focusMonth == null ? view.getMonth() : focusMonth;
|
|
12581
|
+
let next;
|
|
12582
|
+
if (e.key === "ArrowRight") next = cur + 1;
|
|
12583
|
+
else if (e.key === "ArrowLeft") next = cur - 1;
|
|
12584
|
+
else if (e.key === "ArrowDown") next = cur + 3;
|
|
12585
|
+
else if (e.key === "ArrowUp") next = cur - 3;
|
|
12586
|
+
else if (e.key === "Home") next = 0;
|
|
12587
|
+
else if (e.key === "End") next = 11;
|
|
12588
|
+
else return;
|
|
12589
|
+
e.preventDefault();
|
|
12590
|
+
if (next < 0) {
|
|
12591
|
+
setView(new Date(vy - 1, 0, 1));
|
|
12592
|
+
next += 12;
|
|
12593
|
+
} else if (next > 11) {
|
|
12594
|
+
setView(new Date(vy + 1, 0, 1));
|
|
12595
|
+
next -= 12;
|
|
12596
|
+
}
|
|
12597
|
+
setFocusMonth(next);
|
|
12598
|
+
};
|
|
12599
|
+
const onYearsKeyDown = (e) => {
|
|
12600
|
+
const vm = view.getMonth(), ds = Math.floor(view.getFullYear() / 10) * 10;
|
|
12601
|
+
const cur = focusYear == null ? view.getFullYear() : focusYear;
|
|
12602
|
+
let next;
|
|
12603
|
+
if (e.key === "ArrowRight") next = cur + 1;
|
|
12604
|
+
else if (e.key === "ArrowLeft") next = cur - 1;
|
|
12605
|
+
else if (e.key === "ArrowDown") next = cur + 3;
|
|
12606
|
+
else if (e.key === "ArrowUp") next = cur - 3;
|
|
12607
|
+
else if (e.key === "Home") next = ds;
|
|
12608
|
+
else if (e.key === "End") next = ds + 9;
|
|
12609
|
+
else return;
|
|
12610
|
+
e.preventDefault();
|
|
12611
|
+
setView(new Date(next, vm, 1));
|
|
12612
|
+
setFocusYear(next);
|
|
12613
|
+
};
|
|
12614
|
+
const tabbableDate = focusDate || range2.start || /* @__PURE__ */ new Date();
|
|
11951
12615
|
const clickDay = (d) => {
|
|
11952
12616
|
if (outOfRange(d)) return;
|
|
11953
|
-
if (!
|
|
12617
|
+
if (!range2.start || range2.start && range2.end) {
|
|
11954
12618
|
set({ start: d, end: null });
|
|
11955
12619
|
} else {
|
|
11956
|
-
const [start, end] = ymd(d) < ymd(
|
|
12620
|
+
const [start, end] = ymd(d) < ymd(range2.start) ? [d, range2.start] : [range2.start, d];
|
|
11957
12621
|
set({ start, end });
|
|
11958
12622
|
setOpen(false);
|
|
11959
12623
|
}
|
|
11960
12624
|
};
|
|
11961
|
-
const
|
|
11962
|
-
|
|
11963
|
-
const
|
|
11964
|
-
|
|
11965
|
-
set(
|
|
11966
|
-
setView(start);
|
|
12625
|
+
const presetItems = presets === true ? DEFAULT_PRESETS2 : Array.isArray(presets) ? presets : [];
|
|
12626
|
+
const applyPreset = (preset) => {
|
|
12627
|
+
const r2 = typeof preset.range === "function" ? preset.range() : preset.range;
|
|
12628
|
+
if (!r2) return;
|
|
12629
|
+
set(r2);
|
|
12630
|
+
if (r2.start) setView(r2.start);
|
|
11967
12631
|
setOpen(false);
|
|
11968
12632
|
};
|
|
11969
12633
|
const months = React51__default.useMemo(() => locale === void 0 ? MONTHS2 : monthNames2(locale), [locale]);
|
|
12634
|
+
const monthsShort = React51__default.useMemo(() => months.map((n) => n.slice(0, 3)), [months]);
|
|
11970
12635
|
const dows = React51__default.useMemo(
|
|
11971
12636
|
() => locale === void 0 ? Array.from({ length: 7 }, (_, i) => DOW2[(i + weekStartsOn) % 7]) : weekdayNames2(locale, weekStartsOn),
|
|
11972
12637
|
[locale, weekStartsOn]
|
|
11973
12638
|
);
|
|
11974
12639
|
const y = view.getFullYear(), m = view.getMonth();
|
|
12640
|
+
const decadeStart = Math.floor(y / 10) * 10;
|
|
12641
|
+
const yearCells = Array.from({ length: 12 }, (_, i) => decadeStart - 1 + i);
|
|
11975
12642
|
const startOffset = (new Date(y, m, 1).getDay() - weekStartsOn + 7) % 7;
|
|
11976
12643
|
const gridStart = new Date(y, m, 1 - startOffset);
|
|
11977
12644
|
const edgeOf = (t) => {
|
|
11978
|
-
const s = ymd(
|
|
12645
|
+
const s = ymd(range2.start), e = ymd(range2.end) || (range2.start && hover ? ymd(hover) : null);
|
|
11979
12646
|
const lo = s != null && e != null ? Math.min(s, e) : s, hi = s != null && e != null ? Math.max(s, e) : s;
|
|
11980
12647
|
if (s != null && hi === lo && t === s) return "both";
|
|
11981
12648
|
if (t === lo) return "start";
|
|
@@ -11983,13 +12650,13 @@ function DateRangePicker({
|
|
|
11983
12650
|
return null;
|
|
11984
12651
|
};
|
|
11985
12652
|
const inRange = (t) => {
|
|
11986
|
-
const s = ymd(
|
|
11987
|
-
let e = ymd(
|
|
12653
|
+
const s = ymd(range2.start);
|
|
12654
|
+
let e = ymd(range2.end);
|
|
11988
12655
|
if (s != null && e == null && hover) e = ymd(hover);
|
|
11989
12656
|
if (s == null || e == null) return false;
|
|
11990
12657
|
return t > Math.min(s, e) && t < Math.max(s, e);
|
|
11991
12658
|
};
|
|
11992
|
-
const text =
|
|
12659
|
+
const text = range2.start ? format ? format(range2) : `${fmtD(range2.start, locale)} \u2013 ${range2.end ? fmtD(range2.end, locale) : "\u2026"}` : "";
|
|
11993
12660
|
return /* @__PURE__ */ jsxs("div", { className: `twc-drp twc-field ${className}`, ref: wrapRef, ...rest, children: [
|
|
11994
12661
|
__twcStyles0,
|
|
11995
12662
|
__twcStyles1,
|
|
@@ -11999,7 +12666,7 @@ function DateRangePicker({
|
|
|
11999
12666
|
] }) : null,
|
|
12000
12667
|
editable ? (
|
|
12001
12668
|
// #105: typed entry — a text input accepting "start – end"; commits via `parse` on Enter/blur.
|
|
12002
|
-
/* @__PURE__ */ jsxs("div", { className: "twc-drp__control twc-drp__control--editable", "data-open": open || void 0, "data-disabled": disabled || void 0, "data-invalid": invalid || void 0, "data-tone": tone, children: [
|
|
12669
|
+
/* @__PURE__ */ jsxs("div", { className: "twc-drp__control twc-drp__control--editable", "data-open": open || void 0, "data-disabled": disabled || void 0, "data-invalid": invalid || void 0, "data-tone": tone, "data-size": size, children: [
|
|
12003
12670
|
/* @__PURE__ */ jsx(
|
|
12004
12671
|
"input",
|
|
12005
12672
|
{
|
|
@@ -12031,12 +12698,24 @@ function DateRangePicker({
|
|
|
12031
12698
|
}
|
|
12032
12699
|
}
|
|
12033
12700
|
),
|
|
12034
|
-
/* @__PURE__ */ jsx(
|
|
12701
|
+
clearable && (range2.start || range2.end) && !disabled ? /* @__PURE__ */ jsx(
|
|
12035
12702
|
"button",
|
|
12036
12703
|
{
|
|
12037
12704
|
type: "button",
|
|
12038
|
-
className: "twc-
|
|
12039
|
-
"aria-label": "
|
|
12705
|
+
className: "twc-drp__clear",
|
|
12706
|
+
"aria-label": "Clear",
|
|
12707
|
+
tabIndex: -1,
|
|
12708
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
12709
|
+
onClick: () => set({ start: null, end: null }),
|
|
12710
|
+
children: /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsx("path", { d: "M18 6 6 18M6 6l12 12" }) })
|
|
12711
|
+
}
|
|
12712
|
+
) : null,
|
|
12713
|
+
/* @__PURE__ */ jsx(
|
|
12714
|
+
"button",
|
|
12715
|
+
{
|
|
12716
|
+
type: "button",
|
|
12717
|
+
className: "twc-drp__toggle",
|
|
12718
|
+
"aria-label": "Open calendar",
|
|
12040
12719
|
tabIndex: -1,
|
|
12041
12720
|
disabled,
|
|
12042
12721
|
onClick: () => !disabled && setOpen((o) => !o),
|
|
@@ -12056,6 +12735,7 @@ function DateRangePicker({
|
|
|
12056
12735
|
"data-disabled": disabled || void 0,
|
|
12057
12736
|
"data-invalid": invalid || void 0,
|
|
12058
12737
|
"data-tone": tone,
|
|
12738
|
+
"data-size": size,
|
|
12059
12739
|
role: "button",
|
|
12060
12740
|
tabIndex: disabled ? -1 : 0,
|
|
12061
12741
|
"aria-haspopup": "dialog",
|
|
@@ -12076,7 +12756,22 @@ function DateRangePicker({
|
|
|
12076
12756
|
/* @__PURE__ */ jsx("rect", { x: "3", y: "4", width: "18", height: "18", rx: "2" }),
|
|
12077
12757
|
/* @__PURE__ */ jsx("path", { d: "M16 2v4M8 2v4M3 10h18" })
|
|
12078
12758
|
] }) }),
|
|
12079
|
-
/* @__PURE__ */ jsx("span", { className: "twc-drp__text", "data-placeholder": !
|
|
12759
|
+
/* @__PURE__ */ jsx("span", { className: "twc-drp__text", "data-placeholder": !range2.start || void 0, children: range2.start ? text : placeholder }),
|
|
12760
|
+
clearable && (range2.start || range2.end) && !disabled ? /* @__PURE__ */ jsx(
|
|
12761
|
+
"button",
|
|
12762
|
+
{
|
|
12763
|
+
type: "button",
|
|
12764
|
+
className: "twc-drp__clear",
|
|
12765
|
+
"aria-label": "Clear",
|
|
12766
|
+
tabIndex: -1,
|
|
12767
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
12768
|
+
onClick: (e) => {
|
|
12769
|
+
e.stopPropagation();
|
|
12770
|
+
set({ start: null, end: null });
|
|
12771
|
+
},
|
|
12772
|
+
children: /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsx("path", { d: "M18 6 6 18M6 6l12 12" }) })
|
|
12773
|
+
}
|
|
12774
|
+
) : null
|
|
12080
12775
|
]
|
|
12081
12776
|
}
|
|
12082
12777
|
),
|
|
@@ -12091,23 +12786,23 @@ function DateRangePicker({
|
|
|
12091
12786
|
"aria-label": "Choose date range",
|
|
12092
12787
|
style: { position: "fixed", left: coords.left, right: "auto", top: coords.top, bottom: coords.bottom, zIndex: "var(--z-tooltip)" },
|
|
12093
12788
|
children: [
|
|
12094
|
-
|
|
12789
|
+
presetItems.length ? /* @__PURE__ */ jsx("div", { className: "twc-drp__presets", children: presetItems.map((p, i) => /* @__PURE__ */ jsx("button", { type: "button", className: "twc-drp__preset", onClick: () => applyPreset(p), children: p.label }, i)) }) : null,
|
|
12095
12790
|
/* @__PURE__ */ jsxs("div", { className: "twc-drp__cal", children: [
|
|
12096
12791
|
/* @__PURE__ */ jsxs("div", { className: "twc-drp__head", children: [
|
|
12097
|
-
/* @__PURE__ */ jsx("button", { type: "button", className: "twc-drp__nav", "aria-label": "Previous month", onClick: () => setView(new Date(y, m - 1, 1)), children: /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsx("path", { d: "m15 18-6-6 6-6" }) }) }),
|
|
12098
|
-
/* @__PURE__ */
|
|
12099
|
-
|
|
12100
|
-
|
|
12101
|
-
|
|
12102
|
-
|
|
12103
|
-
|
|
12104
|
-
|
|
12105
|
-
|
|
12106
|
-
|
|
12107
|
-
] }),
|
|
12108
|
-
/* @__PURE__ */ jsx("button", { type: "button", className: "twc-drp__nav", "aria-label": "Next month", onClick: () => setView(new Date(y, m + 1, 1)), children: /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsx("path", { d: "m9 18 6-6-6-6" }) }) })
|
|
12792
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: "twc-drp__nav", "aria-label": mode === "years" ? "Previous decade" : mode === "months" ? "Previous year" : "Previous month", onClick: () => setView(mode === "years" ? new Date(y - 10, m, 1) : mode === "months" ? new Date(y - 1, m, 1) : new Date(y, m - 1, 1)), children: /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsx("path", { d: "m15 18-6-6 6-6" }) }) }),
|
|
12793
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: "twc-drp__title", "aria-label": "Switch calendar view", onClick: () => {
|
|
12794
|
+
if (mode === "days") {
|
|
12795
|
+
setFocusMonth(m);
|
|
12796
|
+
setMode("months");
|
|
12797
|
+
} else if (mode === "months") {
|
|
12798
|
+
setFocusYear(y);
|
|
12799
|
+
setMode("years");
|
|
12800
|
+
} else setMode("days");
|
|
12801
|
+
}, children: mode === "days" ? `${months[m]} ${y}` : mode === "months" ? y : `${decadeStart}\u2013${decadeStart + 9}` }),
|
|
12802
|
+
/* @__PURE__ */ jsx("span", { className: "twc-drp__sr", "aria-live": "polite", children: mode === "days" ? `${months[m]} ${y}` : mode === "months" ? y : `${decadeStart}\u2013${decadeStart + 9}` }),
|
|
12803
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: "twc-drp__nav", "aria-label": mode === "years" ? "Next decade" : mode === "months" ? "Next year" : "Next month", onClick: () => setView(mode === "years" ? new Date(y + 10, m, 1) : mode === "months" ? new Date(y + 1, m, 1) : new Date(y, m + 1, 1)), children: /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsx("path", { d: "m9 18 6-6-6-6" }) }) })
|
|
12109
12804
|
] }),
|
|
12110
|
-
/* @__PURE__ */ jsxs("div", { className: "twc-drp__grid", ref: gridRef, onKeyDown: onGridKeyDown, role: "grid", children: [
|
|
12805
|
+
mode === "days" ? /* @__PURE__ */ jsxs("div", { className: "twc-drp__grid", ref: gridRef, onKeyDown: onGridKeyDown, role: "grid", children: [
|
|
12111
12806
|
dows.map((d, i) => /* @__PURE__ */ jsx("div", { className: "twc-drp__dow", children: d }, i)),
|
|
12112
12807
|
Array.from({ length: 42 }).map((_, i) => {
|
|
12113
12808
|
const d = new Date(gridStart.getFullYear(), gridStart.getMonth(), gridStart.getDate() + i);
|
|
@@ -12132,7 +12827,53 @@ function DateRangePicker({
|
|
|
12132
12827
|
i
|
|
12133
12828
|
);
|
|
12134
12829
|
})
|
|
12135
|
-
] })
|
|
12830
|
+
] }) : mode === "months" ? /* @__PURE__ */ jsx("div", { className: "twc-drp__months", ref: gridRef, onKeyDown: onMonthsKeyDown, role: "grid", children: monthsShort.map((mo, i) => {
|
|
12831
|
+
const disabled2 = min && ymd(new Date(y, i + 1, 0)) < ymd(min) || max && ymd(new Date(y, i, 1)) > ymd(max);
|
|
12832
|
+
const sel = range2.start && range2.start.getFullYear() === y && range2.start.getMonth() === i || range2.end && range2.end.getFullYear() === y && range2.end.getMonth() === i;
|
|
12833
|
+
return /* @__PURE__ */ jsx(
|
|
12834
|
+
"button",
|
|
12835
|
+
{
|
|
12836
|
+
type: "button",
|
|
12837
|
+
className: "twc-drp__mo",
|
|
12838
|
+
role: "gridcell",
|
|
12839
|
+
"data-mo": i,
|
|
12840
|
+
disabled: disabled2 || void 0,
|
|
12841
|
+
"data-selected": sel || void 0,
|
|
12842
|
+
tabIndex: i === (focusMonth ?? m) ? 0 : -1,
|
|
12843
|
+
onClick: () => {
|
|
12844
|
+
setView(new Date(y, i, 1));
|
|
12845
|
+
setFocusDate(null);
|
|
12846
|
+
setMode("days");
|
|
12847
|
+
},
|
|
12848
|
+
children: mo
|
|
12849
|
+
},
|
|
12850
|
+
i
|
|
12851
|
+
);
|
|
12852
|
+
}) }) : /* @__PURE__ */ jsx("div", { className: "twc-drp__years", ref: gridRef, onKeyDown: onYearsKeyDown, role: "grid", children: yearCells.map((yr) => {
|
|
12853
|
+
const outside = yr < decadeStart || yr > decadeStart + 9;
|
|
12854
|
+
const disabled2 = min && ymd(new Date(yr, 11, 31)) < ymd(min) || max && ymd(new Date(yr, 0, 1)) > ymd(max);
|
|
12855
|
+
const sel = range2.start && range2.start.getFullYear() === yr || range2.end && range2.end.getFullYear() === yr;
|
|
12856
|
+
return /* @__PURE__ */ jsx(
|
|
12857
|
+
"button",
|
|
12858
|
+
{
|
|
12859
|
+
type: "button",
|
|
12860
|
+
className: "twc-drp__yr",
|
|
12861
|
+
role: "gridcell",
|
|
12862
|
+
"data-yr": yr,
|
|
12863
|
+
"data-outside": outside || void 0,
|
|
12864
|
+
disabled: disabled2 || void 0,
|
|
12865
|
+
"data-selected": sel || void 0,
|
|
12866
|
+
tabIndex: yr === (focusYear ?? y) ? 0 : -1,
|
|
12867
|
+
onClick: () => {
|
|
12868
|
+
setView(new Date(yr, m, 1));
|
|
12869
|
+
setFocusMonth(m);
|
|
12870
|
+
setMode("months");
|
|
12871
|
+
},
|
|
12872
|
+
children: yr
|
|
12873
|
+
},
|
|
12874
|
+
yr
|
|
12875
|
+
);
|
|
12876
|
+
}) })
|
|
12136
12877
|
] })
|
|
12137
12878
|
]
|
|
12138
12879
|
}
|
|
@@ -12142,6 +12883,776 @@ function DateRangePicker({
|
|
|
12142
12883
|
error ? /* @__PURE__ */ jsx("span", { id: descId, className: "twc-field__error", children: error }) : hint ? /* @__PURE__ */ jsx("span", { id: descId, className: "twc-field__hint", children: hint }) : null
|
|
12143
12884
|
] });
|
|
12144
12885
|
}
|
|
12886
|
+
var FIELD_CSS5 = `
|
|
12887
|
+
.twc-field { display: flex; flex-direction: column; gap: var(--space-1-5); font-family: var(--font-sans); }
|
|
12888
|
+
.twc-field__label { font-size: var(--text-sm); font-weight: var(--font-semibold); color: var(--color-text); display: flex; gap: 4px; align-items: center; }
|
|
12889
|
+
.twc-field__req { color: var(--color-danger); }
|
|
12890
|
+
.twc-field__hint { font-size: var(--text-xs); color: var(--color-text-muted); }
|
|
12891
|
+
.twc-field__error { font-size: var(--text-xs); color: var(--color-danger-subtle-fg); font-weight: var(--font-medium); }
|
|
12892
|
+
`;
|
|
12893
|
+
var TIMEPICKER_CSS = `
|
|
12894
|
+
.twc-tp { position: relative; font-family: var(--font-sans); display: flex; flex-direction: column; gap: var(--space-1-5); }
|
|
12895
|
+
.twc-tp__control {
|
|
12896
|
+
display: flex; align-items: center; gap: var(--space-2); --_h: var(--control-h-md); height: var(--_h); padding: 0 var(--space-3);
|
|
12897
|
+
background: var(--color-surface); border: var(--border-thin) solid var(--color-border); border-radius: var(--radius-md);
|
|
12898
|
+
cursor: pointer; transition: border-color var(--duration-fast) var(--ease-standard), box-shadow var(--duration-fast) var(--ease-standard);
|
|
12899
|
+
}
|
|
12900
|
+
.twc-tp__control:hover:not([data-open="true"]) { border-color: var(--color-border-strong); }
|
|
12901
|
+
.twc-tp__control { --_accent: var(--color-primary); --_ring: var(--ring); }
|
|
12902
|
+
.twc-tp__control[data-size="sm"] { --_h: var(--control-h-sm); }
|
|
12903
|
+
.twc-tp__control[data-size="lg"] { --_h: var(--control-h-lg); }
|
|
12904
|
+
.twc-tp__control[data-tone="success"] { --_accent: var(--color-success); --_ring: 0 0 0 var(--ring-width) color-mix(in srgb, var(--color-success) 32%, transparent); }
|
|
12905
|
+
.twc-tp__control[data-tone="warning"] { --_accent: var(--color-warning); --_ring: 0 0 0 var(--ring-width) color-mix(in srgb, var(--color-warning) 32%, transparent); }
|
|
12906
|
+
.twc-tp__control[data-tone="danger"] { --_accent: var(--color-danger); --_ring: 0 0 0 var(--ring-width) color-mix(in srgb, var(--color-danger) 32%, transparent); }
|
|
12907
|
+
.twc-tp__control[data-tone="info"] { --_accent: var(--color-info); --_ring: 0 0 0 var(--ring-width) color-mix(in srgb, var(--color-info) 32%, transparent); }
|
|
12908
|
+
.twc-tp__control[data-tone="neutral"] { --_accent: var(--color-border-strong); --_ring: 0 0 0 var(--ring-width) color-mix(in srgb, var(--color-text) 14%, transparent); }
|
|
12909
|
+
.twc-tp__control[data-open="true"] { border-color: var(--_accent); box-shadow: var(--_ring); }
|
|
12910
|
+
.twc-tp__control[data-invalid="true"] { border-color: var(--color-danger); }
|
|
12911
|
+
.twc-tp__control[data-invalid="true"][data-open="true"] { box-shadow: 0 0 0 var(--ring-width) color-mix(in srgb, var(--color-danger) 28%, transparent); }
|
|
12912
|
+
.twc-tp__control[data-disabled="true"] { background: var(--color-surface-sunken); opacity: 0.7; cursor: not-allowed; }
|
|
12913
|
+
.twc-tp__field { position: relative; display: flex; flex-direction: column; }
|
|
12914
|
+
.twc-tp__control[data-has-clear="true"] { padding-inline-end: 34px; }
|
|
12915
|
+
.twc-tp__ic { flex: none; color: var(--color-text-subtle); display: inline-flex; }
|
|
12916
|
+
.twc-tp__ic svg { width: 17px; height: 17px; }
|
|
12917
|
+
.twc-tp__text { flex: 1; font-size: var(--text-sm); color: var(--color-text); font-variant-numeric: tabular-nums; }
|
|
12918
|
+
.twc-tp__text[data-placeholder="true"] { color: var(--color-text-subtle); font-variant-numeric: normal; }
|
|
12919
|
+
.twc-tp__clear { position: absolute; inset-inline-end: 10px; top: 50%; transform: translateY(-50%); display: inline-grid; place-items: center; width: 20px; height: 20px; border: none; background: transparent; color: var(--color-text-subtle); cursor: pointer; border-radius: var(--radius-full); }
|
|
12920
|
+
.twc-tp__clear:hover { background: var(--color-surface-sunken); color: var(--color-text); }
|
|
12921
|
+
.twc-tp__clear svg { width: 14px; height: 14px; }
|
|
12922
|
+
.twc-tp__control--editable { cursor: text; gap: 0; padding-inline-end: var(--space-1); }
|
|
12923
|
+
.twc-tp__input { flex: 1; min-width: 0; height: 100%; border: none; background: transparent; outline: none; padding: 0; font-family: inherit; font-size: var(--text-sm); color: var(--color-text); font-variant-numeric: tabular-nums; }
|
|
12924
|
+
.twc-tp__input::placeholder { color: var(--color-text-subtle); font-variant-numeric: normal; }
|
|
12925
|
+
.twc-tp__input:disabled { cursor: not-allowed; }
|
|
12926
|
+
.twc-tp__clear--inline { position: static; transform: none; flex: none; }
|
|
12927
|
+
.twc-tp__toggle { flex: none; display: inline-grid; place-items: center; width: 26px; height: 26px; border: none; background: transparent; color: var(--color-text-subtle); cursor: pointer; border-radius: var(--radius-md); transition: background-color var(--duration-fast), color var(--duration-fast); }
|
|
12928
|
+
.twc-tp__toggle:hover:not(:disabled) { background: var(--color-surface-sunken); color: var(--color-text); }
|
|
12929
|
+
.twc-tp__toggle:disabled { cursor: not-allowed; }
|
|
12930
|
+
.twc-tp__toggle svg { width: 17px; height: 17px; }
|
|
12931
|
+
|
|
12932
|
+
.twc-tp__pop {
|
|
12933
|
+
position: fixed; z-index: var(--z-popover);
|
|
12934
|
+
background: var(--color-surface-raised); border: var(--border-thin) solid var(--color-border);
|
|
12935
|
+
border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: var(--space-2);
|
|
12936
|
+
animation: twico-scale-in var(--duration-fast) var(--ease-spring); transform-origin: top;
|
|
12937
|
+
}
|
|
12938
|
+
.twc-tp__cols { display: flex; gap: var(--space-1); max-height: 232px; }
|
|
12939
|
+
.twc-tp__col { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; scrollbar-width: thin; padding-inline: 2px; scroll-behavior: smooth; }
|
|
12940
|
+
.twc-tp__col::-webkit-scrollbar { width: 6px; }
|
|
12941
|
+
.twc-tp__col::-webkit-scrollbar-thumb { background: var(--color-border-strong); border-radius: var(--radius-full); }
|
|
12942
|
+
.twc-tp__col + .twc-tp__col { border-inline-start: var(--border-thin) solid var(--color-divider); }
|
|
12943
|
+
.twc-tp__colhead { text-align: center; font-size: 11px; font-weight: var(--font-bold); color: var(--color-text-subtle); text-transform: uppercase; padding: 2px 0 4px; position: sticky; top: 0; background: var(--color-surface-raised); }
|
|
12944
|
+
.twc-tp__opt { min-width: 46px; padding: 6px 10px; border: none; background: transparent; cursor: pointer; font-family: inherit; font-size: var(--text-sm); color: var(--color-text); border-radius: var(--radius-md); text-align: center; font-variant-numeric: tabular-nums; transition: background-color var(--duration-fast) var(--ease-standard), color var(--duration-fast) var(--ease-standard); }
|
|
12945
|
+
.twc-tp__opt:hover:not(:disabled):not([data-selected="true"]) { background: var(--color-surface-sunken); }
|
|
12946
|
+
.twc-tp__opt[data-selected="true"] { background: var(--color-primary); color: var(--color-primary-fg); font-weight: var(--font-bold); }
|
|
12947
|
+
.twc-tp__opt:disabled { opacity: 0.35; cursor: not-allowed; }
|
|
12948
|
+
.twc-tp__opt:focus-visible { outline: none; box-shadow: var(--ring); }
|
|
12949
|
+
`;
|
|
12950
|
+
var pad = (n) => String(n).padStart(2, "0");
|
|
12951
|
+
var range = (start, end, step) => {
|
|
12952
|
+
const out = [];
|
|
12953
|
+
for (let i = start; i < end; i += step) out.push(i);
|
|
12954
|
+
return out;
|
|
12955
|
+
};
|
|
12956
|
+
var tod = (h, m, s) => h * 3600 + m * 60 + s;
|
|
12957
|
+
var to24 = (dh, mer) => mer === "PM" ? dh === 12 ? 12 : dh + 12 : dh === 12 ? 0 : dh;
|
|
12958
|
+
function TimePicker({
|
|
12959
|
+
label,
|
|
12960
|
+
hint,
|
|
12961
|
+
error,
|
|
12962
|
+
required = false,
|
|
12963
|
+
value,
|
|
12964
|
+
defaultValue = null,
|
|
12965
|
+
placeholder = "Select time",
|
|
12966
|
+
min,
|
|
12967
|
+
max,
|
|
12968
|
+
minuteStep = 5,
|
|
12969
|
+
secondStep = 5,
|
|
12970
|
+
granularity = "minute",
|
|
12971
|
+
// "hour" | "minute" | "second"
|
|
12972
|
+
hourCycle = 24,
|
|
12973
|
+
// 24 | 12
|
|
12974
|
+
referenceDate,
|
|
12975
|
+
disabled = false,
|
|
12976
|
+
tone = "primary",
|
|
12977
|
+
size = "md",
|
|
12978
|
+
clearable = true,
|
|
12979
|
+
editable = false,
|
|
12980
|
+
parse,
|
|
12981
|
+
format,
|
|
12982
|
+
locale,
|
|
12983
|
+
onChange,
|
|
12984
|
+
id,
|
|
12985
|
+
className = "",
|
|
12986
|
+
...rest
|
|
12987
|
+
}) {
|
|
12988
|
+
const __twcStyles0 = useScopedStyles("twc-field-styles", FIELD_CSS5);
|
|
12989
|
+
const __twcStyles1 = useScopedStyles("twc-timepicker-styles", TIMEPICKER_CSS);
|
|
12990
|
+
const autoId = React51__default.useId();
|
|
12991
|
+
const fieldId = id || autoId;
|
|
12992
|
+
const descId = `${fieldId}-desc`;
|
|
12993
|
+
const invalid = Boolean(error);
|
|
12994
|
+
const [internal, setInternal] = React51__default.useState(defaultValue);
|
|
12995
|
+
const selected = value !== void 0 ? value : internal;
|
|
12996
|
+
const [open, setOpen] = React51__default.useState(false);
|
|
12997
|
+
const [editText, setEditText] = React51__default.useState(null);
|
|
12998
|
+
const [coords, setCoords] = React51__default.useState(null);
|
|
12999
|
+
const wrapRef = React51__default.useRef(null);
|
|
13000
|
+
const triggerRef = React51__default.useRef(null);
|
|
13001
|
+
const popRef = React51__default.useRef(null);
|
|
13002
|
+
const place = React51__default.useCallback(() => {
|
|
13003
|
+
const el = triggerRef.current;
|
|
13004
|
+
if (!el) return;
|
|
13005
|
+
const r2 = el.getBoundingClientRect();
|
|
13006
|
+
const vh = window.innerHeight, POP_W = 220;
|
|
13007
|
+
const below = vh - r2.bottom;
|
|
13008
|
+
const flip = below < 300 && r2.top > below;
|
|
13009
|
+
let left = Math.min(r2.left, window.innerWidth - POP_W - 8);
|
|
13010
|
+
left = Math.max(8, left);
|
|
13011
|
+
setCoords({ left, top: flip ? void 0 : Math.round(r2.bottom + 6), bottom: flip ? Math.round(vh - r2.top + 6) : void 0 });
|
|
13012
|
+
}, []);
|
|
13013
|
+
React51__default.useEffect(() => {
|
|
13014
|
+
if (!open) return void 0;
|
|
13015
|
+
place();
|
|
13016
|
+
const onMove = () => place();
|
|
13017
|
+
window.addEventListener("scroll", onMove, true);
|
|
13018
|
+
window.addEventListener("resize", onMove);
|
|
13019
|
+
return () => {
|
|
13020
|
+
window.removeEventListener("scroll", onMove, true);
|
|
13021
|
+
window.removeEventListener("resize", onMove);
|
|
13022
|
+
};
|
|
13023
|
+
}, [open, place]);
|
|
13024
|
+
React51__default.useEffect(() => {
|
|
13025
|
+
if (!open) return void 0;
|
|
13026
|
+
const onDown = (e) => {
|
|
13027
|
+
if (wrapRef.current && wrapRef.current.contains(e.target)) return;
|
|
13028
|
+
if (popRef.current && popRef.current.contains(e.target)) return;
|
|
13029
|
+
setOpen(false);
|
|
13030
|
+
};
|
|
13031
|
+
const onKey = (e) => {
|
|
13032
|
+
if (e.key === "Escape") setOpen(false);
|
|
13033
|
+
};
|
|
13034
|
+
document.addEventListener("mousedown", onDown);
|
|
13035
|
+
document.addEventListener("keydown", onKey);
|
|
13036
|
+
return () => {
|
|
13037
|
+
document.removeEventListener("mousedown", onDown);
|
|
13038
|
+
document.removeEventListener("keydown", onKey);
|
|
13039
|
+
};
|
|
13040
|
+
}, [open]);
|
|
13041
|
+
useFocusTrap(popRef, open && !!coords, {
|
|
13042
|
+
initialFocus: () => popRef.current?.querySelector('.twc-tp__opt[data-selected="true"]') || popRef.current?.querySelector('.twc-tp__opt[tabindex="0"]')
|
|
13043
|
+
});
|
|
13044
|
+
React51__default.useEffect(() => {
|
|
13045
|
+
if (!open || !coords) return;
|
|
13046
|
+
popRef.current?.querySelectorAll('.twc-tp__opt[data-selected="true"]').forEach((el) => el.scrollIntoView({ block: "center" }));
|
|
13047
|
+
}, [open, coords]);
|
|
13048
|
+
const refBase = referenceDate || /* @__PURE__ */ new Date();
|
|
13049
|
+
const minTod = min ? tod(min.getHours(), min.getMinutes(), min.getSeconds()) : null;
|
|
13050
|
+
const maxTod = max ? tod(max.getHours(), max.getMinutes(), max.getSeconds()) : null;
|
|
13051
|
+
const outOfRange = (h, m, s) => minTod != null && tod(h, m, s) < minTod || maxTod != null && tod(h, m, s) > maxTod;
|
|
13052
|
+
const curH = selected ? selected.getHours() : null;
|
|
13053
|
+
const curM = selected ? selected.getMinutes() : null;
|
|
13054
|
+
const curS = selected ? selected.getSeconds() : null;
|
|
13055
|
+
const curMer = curH == null ? "AM" : curH < 12 ? "AM" : "PM";
|
|
13056
|
+
const fmt = (d) => {
|
|
13057
|
+
if (!d) return "";
|
|
13058
|
+
if (format) return format(d);
|
|
13059
|
+
const opts = { hour: hourCycle === 12 ? "numeric" : "2-digit", minute: "2-digit", hour12: hourCycle === 12 };
|
|
13060
|
+
if (granularity === "second") opts.second = "2-digit";
|
|
13061
|
+
if (granularity === "hour") delete opts.minute;
|
|
13062
|
+
return d.toLocaleTimeString(locale, opts);
|
|
13063
|
+
};
|
|
13064
|
+
const commit = (h, m, s) => {
|
|
13065
|
+
const b = selected || refBase;
|
|
13066
|
+
const d = new Date(b.getFullYear(), b.getMonth(), b.getDate(), h, m, s, 0);
|
|
13067
|
+
if (value === void 0) setInternal(d);
|
|
13068
|
+
onChange?.(d);
|
|
13069
|
+
setEditText(null);
|
|
13070
|
+
};
|
|
13071
|
+
const pickHour = (h) => commit(h, granularity === "hour" ? 0 : curM ?? 0, granularity === "second" ? curS ?? 0 : 0);
|
|
13072
|
+
const pickMinute = (m) => commit(curH ?? refBase.getHours(), m, granularity === "second" ? curS ?? 0 : 0);
|
|
13073
|
+
const pickSecond = (s) => commit(curH ?? refBase.getHours(), curM ?? 0, s);
|
|
13074
|
+
const pickMeridiem = (mer) => {
|
|
13075
|
+
const dh = curH == null ? 0 : curH % 12 === 0 ? 12 : curH % 12;
|
|
13076
|
+
commit(to24(dh, mer), curM ?? 0, granularity === "second" ? curS ?? 0 : 0);
|
|
13077
|
+
};
|
|
13078
|
+
const clear = () => {
|
|
13079
|
+
if (value === void 0) setInternal(null);
|
|
13080
|
+
onChange?.(null);
|
|
13081
|
+
setEditText(null);
|
|
13082
|
+
};
|
|
13083
|
+
const parseTyped = (str) => {
|
|
13084
|
+
const s = str.trim();
|
|
13085
|
+
if (s === "") return null;
|
|
13086
|
+
if (parse) {
|
|
13087
|
+
const d = parse(s);
|
|
13088
|
+
return d instanceof Date && !Number.isNaN(d.getTime()) ? d : void 0;
|
|
13089
|
+
}
|
|
13090
|
+
const mm = s.match(/^(\d{1,2}):(\d{2})(?::(\d{2}))?\s*([ap]m)?$/i);
|
|
13091
|
+
if (!mm) return void 0;
|
|
13092
|
+
let h = +mm[1];
|
|
13093
|
+
const mi = +mm[2];
|
|
13094
|
+
const se = mm[3] ? +mm[3] : 0;
|
|
13095
|
+
const mer = mm[4] && mm[4].toLowerCase();
|
|
13096
|
+
if (mer === "pm" && h < 12) h += 12;
|
|
13097
|
+
else if (mer === "am" && h === 12) h = 0;
|
|
13098
|
+
if (h > 23 || mi > 59 || se > 59) return void 0;
|
|
13099
|
+
const b = selected || refBase;
|
|
13100
|
+
return new Date(b.getFullYear(), b.getMonth(), b.getDate(), h, mi, se, 0);
|
|
13101
|
+
};
|
|
13102
|
+
const commitText = () => {
|
|
13103
|
+
if (editText == null) return;
|
|
13104
|
+
const parsed = parseTyped(editText);
|
|
13105
|
+
if (parsed === null) {
|
|
13106
|
+
setEditText(null);
|
|
13107
|
+
if (selected) clear();
|
|
13108
|
+
return;
|
|
13109
|
+
}
|
|
13110
|
+
if (parsed === void 0 || outOfRange(parsed.getHours(), parsed.getMinutes(), parsed.getSeconds())) {
|
|
13111
|
+
setEditText(null);
|
|
13112
|
+
return;
|
|
13113
|
+
}
|
|
13114
|
+
commit(parsed.getHours(), parsed.getMinutes(), parsed.getSeconds());
|
|
13115
|
+
setOpen(false);
|
|
13116
|
+
};
|
|
13117
|
+
const hourVals = hourCycle === 12 ? [12, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] : range(0, 24, 1);
|
|
13118
|
+
const columns = [
|
|
13119
|
+
{
|
|
13120
|
+
key: "h",
|
|
13121
|
+
head: "hr",
|
|
13122
|
+
aria: "Hour",
|
|
13123
|
+
items: hourVals.map((hv) => {
|
|
13124
|
+
const h24 = hourCycle === 12 ? to24(hv, curMer) : hv;
|
|
13125
|
+
return {
|
|
13126
|
+
val: hv,
|
|
13127
|
+
text: hourCycle === 12 ? String(hv) : pad(hv),
|
|
13128
|
+
selected: curH != null && h24 === curH,
|
|
13129
|
+
disabled: outOfRange(h24, 0, 0) && outOfRange(h24, 59, 59),
|
|
13130
|
+
onSelect: () => pickHour(h24)
|
|
13131
|
+
};
|
|
13132
|
+
})
|
|
13133
|
+
}
|
|
13134
|
+
];
|
|
13135
|
+
if (granularity !== "hour") {
|
|
13136
|
+
const h = curH ?? refBase.getHours();
|
|
13137
|
+
columns.push({ key: "m", head: "min", aria: "Minute", items: range(0, 60, minuteStep).map((mv) => ({
|
|
13138
|
+
val: mv,
|
|
13139
|
+
text: pad(mv),
|
|
13140
|
+
selected: curM != null && mv === curM,
|
|
13141
|
+
disabled: outOfRange(h, mv, 0) && outOfRange(h, mv, 59),
|
|
13142
|
+
onSelect: () => pickMinute(mv)
|
|
13143
|
+
})) });
|
|
13144
|
+
}
|
|
13145
|
+
if (granularity === "second") {
|
|
13146
|
+
const h = curH ?? refBase.getHours(), m = curM ?? 0;
|
|
13147
|
+
columns.push({ key: "s", head: "sec", aria: "Second", items: range(0, 60, secondStep).map((sv) => ({
|
|
13148
|
+
val: sv,
|
|
13149
|
+
text: pad(sv),
|
|
13150
|
+
selected: curS != null && sv === curS,
|
|
13151
|
+
disabled: outOfRange(h, m, sv),
|
|
13152
|
+
onSelect: () => pickSecond(sv)
|
|
13153
|
+
})) });
|
|
13154
|
+
}
|
|
13155
|
+
if (hourCycle === 12) {
|
|
13156
|
+
columns.push({ key: "mer", head: "", aria: "AM or PM", items: ["AM", "PM"].map((mer) => ({
|
|
13157
|
+
val: mer,
|
|
13158
|
+
text: mer,
|
|
13159
|
+
selected: curH != null && curMer === mer,
|
|
13160
|
+
disabled: [...Array(12)].every((_, i) => {
|
|
13161
|
+
const hh = mer === "AM" ? i : i + 12;
|
|
13162
|
+
return outOfRange(hh, 0, 0) && outOfRange(hh, 59, 59);
|
|
13163
|
+
}),
|
|
13164
|
+
onSelect: () => pickMeridiem(mer)
|
|
13165
|
+
})) });
|
|
13166
|
+
}
|
|
13167
|
+
const onOptKey = (e) => {
|
|
13168
|
+
const btn = e.target;
|
|
13169
|
+
const col = btn.closest("[data-col]");
|
|
13170
|
+
if (!col) return;
|
|
13171
|
+
const opts = Array.from(col.querySelectorAll(".twc-tp__opt:not(:disabled)"));
|
|
13172
|
+
const i = opts.indexOf(btn);
|
|
13173
|
+
let target;
|
|
13174
|
+
if (e.key === "ArrowDown") target = opts[Math.min(i + 1, opts.length - 1)];
|
|
13175
|
+
else if (e.key === "ArrowUp") target = opts[Math.max(i - 1, 0)];
|
|
13176
|
+
else if (e.key === "Home") target = opts[0];
|
|
13177
|
+
else if (e.key === "End") target = opts[opts.length - 1];
|
|
13178
|
+
else if (e.key === "ArrowRight" || e.key === "ArrowLeft") {
|
|
13179
|
+
const cols = Array.from(popRef.current.querySelectorAll("[data-col]"));
|
|
13180
|
+
const nextCol = cols[cols.indexOf(col) + (e.key === "ArrowRight" ? 1 : -1)];
|
|
13181
|
+
if (nextCol) {
|
|
13182
|
+
const nopts = Array.from(nextCol.querySelectorAll(".twc-tp__opt:not(:disabled)"));
|
|
13183
|
+
target = nextCol.querySelector('.twc-tp__opt[data-selected="true"]') || nopts[Math.min(i, nopts.length - 1)] || nopts[0];
|
|
13184
|
+
}
|
|
13185
|
+
} else return;
|
|
13186
|
+
e.preventDefault();
|
|
13187
|
+
target?.focus();
|
|
13188
|
+
};
|
|
13189
|
+
const clockIcon = /* @__PURE__ */ jsxs("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
13190
|
+
/* @__PURE__ */ jsx("circle", { cx: "12", cy: "12", r: "9" }),
|
|
13191
|
+
/* @__PURE__ */ jsx("path", { d: "M12 7v5l3 2" })
|
|
13192
|
+
] });
|
|
13193
|
+
return /* @__PURE__ */ jsxs("div", { className: `twc-tp twc-field ${className}`, ref: wrapRef, ...rest, children: [
|
|
13194
|
+
__twcStyles0,
|
|
13195
|
+
__twcStyles1,
|
|
13196
|
+
label ? /* @__PURE__ */ jsxs("label", { className: "twc-field__label", id: `${fieldId}-label`, children: [
|
|
13197
|
+
label,
|
|
13198
|
+
required ? /* @__PURE__ */ jsx("span", { className: "twc-field__req", children: "*" }) : null
|
|
13199
|
+
] }) : null,
|
|
13200
|
+
/* @__PURE__ */ jsx("div", { className: "twc-tp__field", children: editable ? /* @__PURE__ */ jsxs(
|
|
13201
|
+
"div",
|
|
13202
|
+
{
|
|
13203
|
+
className: "twc-tp__control twc-tp__control--editable",
|
|
13204
|
+
"data-open": open || void 0,
|
|
13205
|
+
"data-disabled": disabled || void 0,
|
|
13206
|
+
"data-tone": tone,
|
|
13207
|
+
"data-invalid": invalid || void 0,
|
|
13208
|
+
"data-size": size,
|
|
13209
|
+
children: [
|
|
13210
|
+
/* @__PURE__ */ jsx(
|
|
13211
|
+
"input",
|
|
13212
|
+
{
|
|
13213
|
+
ref: triggerRef,
|
|
13214
|
+
className: "twc-tp__input",
|
|
13215
|
+
id: fieldId,
|
|
13216
|
+
type: "text",
|
|
13217
|
+
inputMode: "numeric",
|
|
13218
|
+
autoComplete: "off",
|
|
13219
|
+
disabled,
|
|
13220
|
+
placeholder,
|
|
13221
|
+
value: editText != null ? editText : selected ? fmt(selected) : "",
|
|
13222
|
+
"aria-haspopup": "dialog",
|
|
13223
|
+
"aria-expanded": open,
|
|
13224
|
+
"aria-labelledby": label ? `${fieldId}-label` : void 0,
|
|
13225
|
+
"aria-invalid": invalid || void 0,
|
|
13226
|
+
"aria-describedby": error || hint ? descId : void 0,
|
|
13227
|
+
onChange: (e) => setEditText(e.target.value),
|
|
13228
|
+
onKeyDown: (e) => {
|
|
13229
|
+
if (e.key === "Enter") {
|
|
13230
|
+
e.preventDefault();
|
|
13231
|
+
commitText();
|
|
13232
|
+
} else if (e.key === "ArrowDown" && (e.altKey || !open)) {
|
|
13233
|
+
e.preventDefault();
|
|
13234
|
+
setOpen(true);
|
|
13235
|
+
} else if (e.key === "Escape" && open) setOpen(false);
|
|
13236
|
+
},
|
|
13237
|
+
onBlur: (e) => {
|
|
13238
|
+
if (popRef.current && popRef.current.contains(e.relatedTarget)) return;
|
|
13239
|
+
commitText();
|
|
13240
|
+
}
|
|
13241
|
+
}
|
|
13242
|
+
),
|
|
13243
|
+
clearable && selected && !disabled ? /* @__PURE__ */ jsx(
|
|
13244
|
+
"button",
|
|
13245
|
+
{
|
|
13246
|
+
type: "button",
|
|
13247
|
+
className: "twc-tp__clear twc-tp__clear--inline",
|
|
13248
|
+
"aria-label": "Clear",
|
|
13249
|
+
tabIndex: -1,
|
|
13250
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
13251
|
+
onClick: clear,
|
|
13252
|
+
children: /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.4", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsx("path", { d: "M18 6 6 18M6 6l12 12" }) })
|
|
13253
|
+
}
|
|
13254
|
+
) : null,
|
|
13255
|
+
/* @__PURE__ */ jsx(
|
|
13256
|
+
"button",
|
|
13257
|
+
{
|
|
13258
|
+
type: "button",
|
|
13259
|
+
className: "twc-tp__toggle",
|
|
13260
|
+
"aria-label": "Open time list",
|
|
13261
|
+
tabIndex: -1,
|
|
13262
|
+
disabled,
|
|
13263
|
+
onClick: () => !disabled && setOpen((o) => !o),
|
|
13264
|
+
children: clockIcon
|
|
13265
|
+
}
|
|
13266
|
+
)
|
|
13267
|
+
]
|
|
13268
|
+
}
|
|
13269
|
+
) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
13270
|
+
/* @__PURE__ */ jsxs(
|
|
13271
|
+
"div",
|
|
13272
|
+
{
|
|
13273
|
+
ref: triggerRef,
|
|
13274
|
+
className: "twc-tp__control",
|
|
13275
|
+
id: fieldId,
|
|
13276
|
+
"data-open": open || void 0,
|
|
13277
|
+
"data-disabled": disabled || void 0,
|
|
13278
|
+
"data-size": size,
|
|
13279
|
+
"data-tone": tone,
|
|
13280
|
+
"data-has-clear": clearable && selected && !disabled ? "true" : void 0,
|
|
13281
|
+
"data-invalid": invalid || void 0,
|
|
13282
|
+
role: "button",
|
|
13283
|
+
tabIndex: disabled ? -1 : 0,
|
|
13284
|
+
"aria-haspopup": "dialog",
|
|
13285
|
+
"aria-expanded": open,
|
|
13286
|
+
"aria-labelledby": label ? `${fieldId}-label` : void 0,
|
|
13287
|
+
"aria-invalid": invalid || void 0,
|
|
13288
|
+
"aria-describedby": error || hint ? descId : void 0,
|
|
13289
|
+
onClick: () => !disabled && setOpen((o) => !o),
|
|
13290
|
+
onKeyDown: (e) => {
|
|
13291
|
+
if ((e.key === "Enter" || e.key === " ") && !disabled) {
|
|
13292
|
+
e.preventDefault();
|
|
13293
|
+
setOpen((o) => !o);
|
|
13294
|
+
}
|
|
13295
|
+
},
|
|
13296
|
+
children: [
|
|
13297
|
+
/* @__PURE__ */ jsx("span", { className: "twc-tp__ic", "aria-hidden": "true", children: clockIcon }),
|
|
13298
|
+
/* @__PURE__ */ jsx("span", { className: "twc-tp__text", "data-placeholder": !selected || void 0, children: selected ? fmt(selected) : placeholder })
|
|
13299
|
+
]
|
|
13300
|
+
}
|
|
13301
|
+
),
|
|
13302
|
+
clearable && selected && !disabled ? /* @__PURE__ */ jsx("button", { type: "button", className: "twc-tp__clear", "aria-label": "Clear", onClick: (e) => {
|
|
13303
|
+
e.stopPropagation();
|
|
13304
|
+
clear();
|
|
13305
|
+
}, children: /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.4", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsx("path", { d: "M18 6 6 18M6 6l12 12" }) }) }) : null
|
|
13306
|
+
] }) }),
|
|
13307
|
+
open && coords ? createPortal(
|
|
13308
|
+
/* @__PURE__ */ jsx(
|
|
13309
|
+
"div",
|
|
13310
|
+
{
|
|
13311
|
+
className: "twc-tp__pop",
|
|
13312
|
+
ref: popRef,
|
|
13313
|
+
role: "dialog",
|
|
13314
|
+
"aria-modal": "true",
|
|
13315
|
+
"aria-label": "Choose time",
|
|
13316
|
+
style: { position: "fixed", left: coords.left, right: "auto", top: coords.top, bottom: coords.bottom, zIndex: "var(--z-tooltip)" },
|
|
13317
|
+
children: /* @__PURE__ */ jsx("div", { className: "twc-tp__cols", children: columns.map((col) => {
|
|
13318
|
+
const firstTab = col.items.find((it) => it.selected) || col.items.find((it) => !it.disabled);
|
|
13319
|
+
return /* @__PURE__ */ jsxs("div", { className: "twc-tp__col", role: "listbox", "aria-label": col.aria, "data-col": col.key, children: [
|
|
13320
|
+
col.head ? /* @__PURE__ */ jsx("div", { className: "twc-tp__colhead", "aria-hidden": "true", children: col.head }) : null,
|
|
13321
|
+
col.items.map((it) => /* @__PURE__ */ jsx(
|
|
13322
|
+
"button",
|
|
13323
|
+
{
|
|
13324
|
+
type: "button",
|
|
13325
|
+
className: "twc-tp__opt",
|
|
13326
|
+
role: "option",
|
|
13327
|
+
"aria-selected": it.selected || false,
|
|
13328
|
+
"data-selected": it.selected || void 0,
|
|
13329
|
+
"data-val": it.val,
|
|
13330
|
+
disabled: it.disabled || void 0,
|
|
13331
|
+
tabIndex: it === firstTab ? 0 : -1,
|
|
13332
|
+
onClick: it.onSelect,
|
|
13333
|
+
onKeyDown: onOptKey,
|
|
13334
|
+
children: it.text
|
|
13335
|
+
},
|
|
13336
|
+
it.val
|
|
13337
|
+
))
|
|
13338
|
+
] }, col.key);
|
|
13339
|
+
}) })
|
|
13340
|
+
}
|
|
13341
|
+
),
|
|
13342
|
+
document.body
|
|
13343
|
+
) : null,
|
|
13344
|
+
error ? /* @__PURE__ */ jsx("span", { id: descId, className: "twc-field__error", children: error }) : hint ? /* @__PURE__ */ jsx("span", { id: descId, className: "twc-field__hint", children: hint }) : null
|
|
13345
|
+
] });
|
|
13346
|
+
}
|
|
13347
|
+
var FIELD_CSS6 = `
|
|
13348
|
+
.twc-field { display: flex; flex-direction: column; gap: var(--space-1-5); font-family: var(--font-sans); }
|
|
13349
|
+
.twc-field__label { font-size: var(--text-sm); font-weight: var(--font-semibold); color: var(--color-text); display: flex; gap: 4px; align-items: center; }
|
|
13350
|
+
.twc-field__req { color: var(--color-danger); }
|
|
13351
|
+
.twc-field__hint { font-size: var(--text-xs); color: var(--color-text-muted); }
|
|
13352
|
+
.twc-field__error { font-size: var(--text-xs); color: var(--color-danger-subtle-fg); font-weight: var(--font-medium); }
|
|
13353
|
+
`;
|
|
13354
|
+
var DTP_CSS = `
|
|
13355
|
+
.twc-dtp { display: flex; flex-direction: column; gap: var(--space-1-5); font-family: var(--font-sans); }
|
|
13356
|
+
.twc-dtp__row { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: flex-start; }
|
|
13357
|
+
.twc-dtp__date { flex: 1 1 11rem; min-width: 9rem; }
|
|
13358
|
+
.twc-dtp__time { flex: 0 1 8rem; min-width: 7rem; }
|
|
13359
|
+
`;
|
|
13360
|
+
function DateTimePicker({
|
|
13361
|
+
label,
|
|
13362
|
+
hint,
|
|
13363
|
+
error,
|
|
13364
|
+
required = false,
|
|
13365
|
+
value,
|
|
13366
|
+
defaultValue = null,
|
|
13367
|
+
disabled = false,
|
|
13368
|
+
tone = "primary",
|
|
13369
|
+
size = "md",
|
|
13370
|
+
clearable = true,
|
|
13371
|
+
min,
|
|
13372
|
+
max,
|
|
13373
|
+
disabledDate,
|
|
13374
|
+
minuteStep = 5,
|
|
13375
|
+
secondStep = 5,
|
|
13376
|
+
granularity = "minute",
|
|
13377
|
+
hourCycle = 24,
|
|
13378
|
+
locale,
|
|
13379
|
+
weekStartsOn = 0,
|
|
13380
|
+
dateFormat,
|
|
13381
|
+
timeFormat,
|
|
13382
|
+
datePlaceholder = "Select date",
|
|
13383
|
+
timePlaceholder = "Time",
|
|
13384
|
+
onChange,
|
|
13385
|
+
id,
|
|
13386
|
+
className = "",
|
|
13387
|
+
...rest
|
|
13388
|
+
}) {
|
|
13389
|
+
const __twcStyles0 = useScopedStyles("twc-field-styles", FIELD_CSS6);
|
|
13390
|
+
const __twcStyles1 = useScopedStyles("twc-datetimepicker-styles", DTP_CSS);
|
|
13391
|
+
const autoId = React51__default.useId();
|
|
13392
|
+
const fieldId = id || autoId;
|
|
13393
|
+
const descId = `${fieldId}-desc`;
|
|
13394
|
+
const [internal, setInternal] = React51__default.useState(defaultValue);
|
|
13395
|
+
const selected = value !== void 0 ? value : internal;
|
|
13396
|
+
const commitVal = (d) => {
|
|
13397
|
+
if (value === void 0) setInternal(d);
|
|
13398
|
+
onChange?.(d);
|
|
13399
|
+
};
|
|
13400
|
+
const onDateChange = (d) => {
|
|
13401
|
+
if (!d) return commitVal(null);
|
|
13402
|
+
const b = selected;
|
|
13403
|
+
commitVal(new Date(d.getFullYear(), d.getMonth(), d.getDate(), b ? b.getHours() : 0, b ? b.getMinutes() : 0, b ? b.getSeconds() : 0, 0));
|
|
13404
|
+
};
|
|
13405
|
+
const onTimeChange = (t) => {
|
|
13406
|
+
if (!t) return;
|
|
13407
|
+
const b = selected;
|
|
13408
|
+
commitVal(new Date(b ? b.getFullYear() : t.getFullYear(), b ? b.getMonth() : t.getMonth(), b ? b.getDate() : t.getDate(), t.getHours(), t.getMinutes(), t.getSeconds(), 0));
|
|
13409
|
+
};
|
|
13410
|
+
const childTone = error ? "danger" : tone;
|
|
13411
|
+
return /* @__PURE__ */ jsxs("div", { className: `twc-dtp twc-field ${className}`, id: fieldId, ...rest, children: [
|
|
13412
|
+
__twcStyles0,
|
|
13413
|
+
__twcStyles1,
|
|
13414
|
+
label ? /* @__PURE__ */ jsxs("label", { className: "twc-field__label", id: `${fieldId}-label`, children: [
|
|
13415
|
+
label,
|
|
13416
|
+
required ? /* @__PURE__ */ jsx("span", { className: "twc-field__req", children: "*" }) : null
|
|
13417
|
+
] }) : null,
|
|
13418
|
+
/* @__PURE__ */ jsxs("div", { className: "twc-dtp__row", role: "group", "aria-labelledby": label ? `${fieldId}-label` : void 0, "aria-describedby": error || hint ? descId : void 0, children: [
|
|
13419
|
+
/* @__PURE__ */ jsx("div", { className: "twc-dtp__date", children: /* @__PURE__ */ jsx(
|
|
13420
|
+
DatePicker,
|
|
13421
|
+
{
|
|
13422
|
+
value: selected,
|
|
13423
|
+
onChange: onDateChange,
|
|
13424
|
+
disabled,
|
|
13425
|
+
tone: childTone,
|
|
13426
|
+
size,
|
|
13427
|
+
clearable,
|
|
13428
|
+
min,
|
|
13429
|
+
max,
|
|
13430
|
+
disabledDate,
|
|
13431
|
+
locale,
|
|
13432
|
+
weekStartsOn,
|
|
13433
|
+
format: dateFormat,
|
|
13434
|
+
placeholder: datePlaceholder,
|
|
13435
|
+
"aria-label": "Date"
|
|
13436
|
+
}
|
|
13437
|
+
) }),
|
|
13438
|
+
/* @__PURE__ */ jsx("div", { className: "twc-dtp__time", children: /* @__PURE__ */ jsx(
|
|
13439
|
+
TimePicker,
|
|
13440
|
+
{
|
|
13441
|
+
value: selected,
|
|
13442
|
+
onChange: onTimeChange,
|
|
13443
|
+
disabled,
|
|
13444
|
+
tone: childTone,
|
|
13445
|
+
size,
|
|
13446
|
+
clearable: false,
|
|
13447
|
+
minuteStep,
|
|
13448
|
+
secondStep,
|
|
13449
|
+
granularity,
|
|
13450
|
+
hourCycle,
|
|
13451
|
+
locale,
|
|
13452
|
+
referenceDate: selected || void 0,
|
|
13453
|
+
format: timeFormat,
|
|
13454
|
+
placeholder: timePlaceholder,
|
|
13455
|
+
"aria-label": "Time"
|
|
13456
|
+
}
|
|
13457
|
+
) })
|
|
13458
|
+
] }),
|
|
13459
|
+
error ? /* @__PURE__ */ jsx("span", { id: descId, className: "twc-field__error", children: error }) : hint ? /* @__PURE__ */ jsx("span", { id: descId, className: "twc-field__hint", children: hint }) : null
|
|
13460
|
+
] });
|
|
13461
|
+
}
|
|
13462
|
+
var FILTERBAR_CSS = `
|
|
13463
|
+
.twc-fbar { font-family: var(--font-sans); display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-3); }
|
|
13464
|
+
.twc-fbar__field { display: flex; flex-direction: column; min-width: 170px; }
|
|
13465
|
+
.twc-fbar__field[data-type="search"], .twc-fbar__field[data-type="text"] { flex: 1 1 200px; }
|
|
13466
|
+
.twc-fbar__field[data-type="daterange"] { min-width: 220px; }
|
|
13467
|
+
.twc-fbar__field[data-type="boolean"], .twc-fbar__field[data-type="number"] { min-width: 130px; }
|
|
13468
|
+
.twc-fbar__labelrow { display: flex; align-items: center; gap: 6px; min-height: 18px; margin-bottom: var(--space-1); }
|
|
13469
|
+
.twc-fbar__label { font-size: var(--text-sm); font-weight: var(--font-semibold); color: var(--color-text); }
|
|
13470
|
+
.twc-fbar__clearone { display: inline-grid; place-items: center; width: 16px; height: 16px; border: none; background: transparent; color: var(--color-text-subtle); cursor: pointer; border-radius: var(--radius-full); padding: 0; }
|
|
13471
|
+
.twc-fbar__clearone:hover { background: var(--color-surface-sunken); color: var(--color-text); }
|
|
13472
|
+
.twc-fbar__clearone svg { width: 11px; height: 11px; }
|
|
13473
|
+
.twc-fbar__actions { display: flex; align-items: center; gap: var(--space-2); }
|
|
13474
|
+
.twc-fbar__clearall { display: inline-flex; align-items: center; gap: 6px; height: var(--control-h-md); padding: 0 var(--space-3); border: var(--border-thin) solid var(--color-border); background: var(--color-surface); color: var(--color-text-muted); border-radius: var(--radius-md); cursor: pointer; font-family: inherit; font-size: var(--text-sm); font-weight: var(--font-medium); transition: background-color var(--duration-fast), color var(--duration-fast), border-color var(--duration-fast); }
|
|
13475
|
+
.twc-fbar__clearall:hover:not(:disabled) { background: var(--color-surface-sunken); color: var(--color-text); border-color: var(--color-border-strong); }
|
|
13476
|
+
.twc-fbar__clearall:disabled { opacity: 0.5; cursor: not-allowed; }
|
|
13477
|
+
.twc-fbar__clearall svg { width: 15px; height: 15px; }
|
|
13478
|
+
`;
|
|
13479
|
+
var isEmpty = (f, v) => {
|
|
13480
|
+
if (v == null) return true;
|
|
13481
|
+
if (f.type === "multiselect" || f.type === "select-multiple") return !Array.isArray(v) || v.length === 0;
|
|
13482
|
+
if (f.type === "daterange") return v.start == null && v.end == null;
|
|
13483
|
+
return v === "";
|
|
13484
|
+
};
|
|
13485
|
+
var emptyFor = (f) => f.type === "multiselect" ? [] : f.type === "daterange" ? { start: null, end: null } : void 0;
|
|
13486
|
+
function valuesToClauses(fields, values) {
|
|
13487
|
+
const out = [];
|
|
13488
|
+
for (const f of fields) {
|
|
13489
|
+
const v = values[f.field];
|
|
13490
|
+
if (isEmpty(f, v)) continue;
|
|
13491
|
+
if (f.type === "multiselect") out.push({ field: f.field, op: "isAnyOf", value: v });
|
|
13492
|
+
else if (f.type === "daterange") {
|
|
13493
|
+
if (v.start != null) out.push({ field: f.field, op: ">=", value: v.start });
|
|
13494
|
+
if (v.end != null) out.push({ field: f.field, op: "<", value: v.end });
|
|
13495
|
+
} else if (f.type === "search" || f.type === "text") out.push({ field: f.field, op: f.op || "contains", value: v });
|
|
13496
|
+
else if (f.type === "number") out.push({ field: f.field, op: f.op || "=", value: v });
|
|
13497
|
+
else if (f.type === "boolean") out.push({ field: f.field, op: "=", value: v });
|
|
13498
|
+
else out.push({ field: f.field, op: f.op || "=", value: v });
|
|
13499
|
+
}
|
|
13500
|
+
return out;
|
|
13501
|
+
}
|
|
13502
|
+
function clausesToValues(fields, clauses) {
|
|
13503
|
+
const v = {};
|
|
13504
|
+
for (const f of fields) v[f.field] = emptyFor(f);
|
|
13505
|
+
for (const c of clauses || []) {
|
|
13506
|
+
const f = fields.find((x) => x.field === c.field);
|
|
13507
|
+
if (!f) continue;
|
|
13508
|
+
if (f.type === "daterange") {
|
|
13509
|
+
v[f.field] = { ...v[f.field] || { start: null, end: null } };
|
|
13510
|
+
if (c.op === ">=" || c.op === ">") v[f.field].start = c.value;
|
|
13511
|
+
else if (c.op === "<" || c.op === "<=") v[f.field].end = c.value;
|
|
13512
|
+
} else if (f.type === "multiselect") {
|
|
13513
|
+
v[f.field] = Array.isArray(c.value) ? c.value : [];
|
|
13514
|
+
} else {
|
|
13515
|
+
v[f.field] = c.value;
|
|
13516
|
+
}
|
|
13517
|
+
}
|
|
13518
|
+
return v;
|
|
13519
|
+
}
|
|
13520
|
+
var xIcon = /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.4", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsx("path", { d: "M18 6 6 18M6 6l12 12" }) });
|
|
13521
|
+
function FilterBar({
|
|
13522
|
+
fields = [],
|
|
13523
|
+
value,
|
|
13524
|
+
defaultValue = [],
|
|
13525
|
+
onChange,
|
|
13526
|
+
onValuesChange,
|
|
13527
|
+
showClearAll = false,
|
|
13528
|
+
clearAllLabel = "Clear all",
|
|
13529
|
+
showFieldClear = true,
|
|
13530
|
+
size = "md",
|
|
13531
|
+
tone = "primary",
|
|
13532
|
+
disabled = false,
|
|
13533
|
+
id,
|
|
13534
|
+
className = "",
|
|
13535
|
+
...rest
|
|
13536
|
+
}) {
|
|
13537
|
+
const styles = useScopedStyles("twc-filterbar-styles", FILTERBAR_CSS);
|
|
13538
|
+
const autoId = React51__default.useId();
|
|
13539
|
+
const fieldId = id || autoId;
|
|
13540
|
+
const [internal, setInternal] = React51__default.useState(defaultValue);
|
|
13541
|
+
const clauses = value !== void 0 ? value : internal;
|
|
13542
|
+
const values = React51__default.useMemo(() => clausesToValues(fields, clauses), [fields, clauses]);
|
|
13543
|
+
const emit = (nextValues) => {
|
|
13544
|
+
const next = valuesToClauses(fields, nextValues);
|
|
13545
|
+
if (value === void 0) setInternal(next);
|
|
13546
|
+
onChange?.(next);
|
|
13547
|
+
onValuesChange?.(nextValues);
|
|
13548
|
+
};
|
|
13549
|
+
const setField = (f, v) => emit({ ...values, [f.field]: v });
|
|
13550
|
+
const clearField = (f) => setField(f, emptyFor(f));
|
|
13551
|
+
const clearAll = () => {
|
|
13552
|
+
const cleared = {};
|
|
13553
|
+
for (const f of fields) cleared[f.field] = emptyFor(f);
|
|
13554
|
+
emit(cleared);
|
|
13555
|
+
};
|
|
13556
|
+
const activeCount = fields.reduce((n, f) => n + (isEmpty(f, values[f.field]) ? 0 : 1), 0);
|
|
13557
|
+
const control = (f) => {
|
|
13558
|
+
const v = values[f.field];
|
|
13559
|
+
const name = f.label || f.field;
|
|
13560
|
+
const opts = typeof f.options === "function" ? f.options(values) : f.options;
|
|
13561
|
+
const common = { size, disabled: disabled || f.disabled, "aria-label": name };
|
|
13562
|
+
if (f.type === "multiselect") {
|
|
13563
|
+
return /* @__PURE__ */ jsx(
|
|
13564
|
+
MultiSelect,
|
|
13565
|
+
{
|
|
13566
|
+
...common,
|
|
13567
|
+
options: opts || [],
|
|
13568
|
+
value: v || [],
|
|
13569
|
+
placeholder: f.placeholder || "Any",
|
|
13570
|
+
clearable: true,
|
|
13571
|
+
onChange: (next) => setField(f, next)
|
|
13572
|
+
}
|
|
13573
|
+
);
|
|
13574
|
+
}
|
|
13575
|
+
if (f.type === "daterange") {
|
|
13576
|
+
return /* @__PURE__ */ jsx(
|
|
13577
|
+
DateRangePicker,
|
|
13578
|
+
{
|
|
13579
|
+
...common,
|
|
13580
|
+
tone,
|
|
13581
|
+
value: v || { start: null, end: null },
|
|
13582
|
+
clearable: true,
|
|
13583
|
+
onChange: (range2) => setField(f, range2)
|
|
13584
|
+
}
|
|
13585
|
+
);
|
|
13586
|
+
}
|
|
13587
|
+
if (f.type === "boolean") {
|
|
13588
|
+
const boolOpts = [{ value: "", label: f.anyLabel || "Any" }, { value: "true", label: f.trueLabel || "Yes" }, { value: "false", label: f.falseLabel || "No" }];
|
|
13589
|
+
return /* @__PURE__ */ jsx(
|
|
13590
|
+
Select,
|
|
13591
|
+
{
|
|
13592
|
+
...common,
|
|
13593
|
+
searchable: false,
|
|
13594
|
+
options: boolOpts,
|
|
13595
|
+
value: v == null ? "" : String(v),
|
|
13596
|
+
onChange: (next) => setField(f, next === "" ? void 0 : next === "true")
|
|
13597
|
+
}
|
|
13598
|
+
);
|
|
13599
|
+
}
|
|
13600
|
+
if (f.type === "select") {
|
|
13601
|
+
return /* @__PURE__ */ jsx(
|
|
13602
|
+
Select,
|
|
13603
|
+
{
|
|
13604
|
+
...common,
|
|
13605
|
+
searchable: f.searchable,
|
|
13606
|
+
options: opts || [],
|
|
13607
|
+
value: v ?? "",
|
|
13608
|
+
placeholder: f.placeholder || "Any",
|
|
13609
|
+
portal: f.portal,
|
|
13610
|
+
onChange: (next) => setField(f, next === "" ? void 0 : next)
|
|
13611
|
+
}
|
|
13612
|
+
);
|
|
13613
|
+
}
|
|
13614
|
+
if (f.type === "number") {
|
|
13615
|
+
return /* @__PURE__ */ jsx(
|
|
13616
|
+
Input,
|
|
13617
|
+
{
|
|
13618
|
+
...common,
|
|
13619
|
+
type: "number",
|
|
13620
|
+
value: v ?? "",
|
|
13621
|
+
placeholder: f.placeholder,
|
|
13622
|
+
onChange: (e) => setField(f, e.target.value === "" ? void 0 : Number(e.target.value))
|
|
13623
|
+
}
|
|
13624
|
+
);
|
|
13625
|
+
}
|
|
13626
|
+
return /* @__PURE__ */ jsx(
|
|
13627
|
+
Input,
|
|
13628
|
+
{
|
|
13629
|
+
...common,
|
|
13630
|
+
type: f.type === "search" ? "search" : "text",
|
|
13631
|
+
value: v ?? "",
|
|
13632
|
+
placeholder: f.placeholder || (f.type === "search" ? "Search\u2026" : ""),
|
|
13633
|
+
onChange: (e) => setField(f, e.target.value)
|
|
13634
|
+
}
|
|
13635
|
+
);
|
|
13636
|
+
};
|
|
13637
|
+
return /* @__PURE__ */ jsxs("div", { className: `twc-fbar ${className}`, id: fieldId, role: "group", "aria-label": "Filters", ...rest, children: [
|
|
13638
|
+
styles,
|
|
13639
|
+
fields.map((f) => {
|
|
13640
|
+
const active = !isEmpty(f, values[f.field]);
|
|
13641
|
+
return /* @__PURE__ */ jsxs("div", { className: "twc-fbar__field", "data-type": f.type, children: [
|
|
13642
|
+
/* @__PURE__ */ jsxs("div", { className: "twc-fbar__labelrow", children: [
|
|
13643
|
+
/* @__PURE__ */ jsx("span", { className: "twc-fbar__label", children: f.label || f.field }),
|
|
13644
|
+
showFieldClear && active && !disabled ? /* @__PURE__ */ jsx("button", { type: "button", className: "twc-fbar__clearone", "aria-label": `Clear ${f.label || f.field}`, onClick: () => clearField(f), children: xIcon }) : null
|
|
13645
|
+
] }),
|
|
13646
|
+
control(f)
|
|
13647
|
+
] }, f.field);
|
|
13648
|
+
}),
|
|
13649
|
+
showClearAll ? /* @__PURE__ */ jsx("div", { className: "twc-fbar__actions", children: /* @__PURE__ */ jsxs("button", { type: "button", className: "twc-fbar__clearall", onClick: clearAll, disabled: disabled || activeCount === 0, children: [
|
|
13650
|
+
xIcon,
|
|
13651
|
+
clearAllLabel,
|
|
13652
|
+
activeCount > 0 ? ` (${activeCount})` : ""
|
|
13653
|
+
] }) }) : null
|
|
13654
|
+
] });
|
|
13655
|
+
}
|
|
12145
13656
|
var DIALOG_CSS = `
|
|
12146
13657
|
.twc-dialog__overlay {
|
|
12147
13658
|
position: fixed; inset: 0; z-index: var(--z-modal);
|
|
@@ -12459,7 +13970,7 @@ function EmptyState({
|
|
|
12459
13970
|
actions ? /* @__PURE__ */ jsx("div", { className: "twc-empty__actions", children: actions }) : null
|
|
12460
13971
|
] });
|
|
12461
13972
|
}
|
|
12462
|
-
var
|
|
13973
|
+
var FIELD_CSS7 = `
|
|
12463
13974
|
.twc-field { display: flex; flex-direction: column; gap: var(--space-1-5); font-family: var(--font-sans); }
|
|
12464
13975
|
.twc-field__label { font-size: var(--text-sm); font-weight: var(--font-semibold); color: var(--color-text); display: flex; gap: 4px; align-items: center; }
|
|
12465
13976
|
.twc-field__req { color: var(--color-danger); }
|
|
@@ -12478,7 +13989,7 @@ function Field({
|
|
|
12478
13989
|
children,
|
|
12479
13990
|
...rest
|
|
12480
13991
|
}) {
|
|
12481
|
-
const __twcStyles = useScopedStyles("twc-field-styles",
|
|
13992
|
+
const __twcStyles = useScopedStyles("twc-field-styles", FIELD_CSS7);
|
|
12482
13993
|
const autoId = React51__default.useId();
|
|
12483
13994
|
const fieldId = id || autoId;
|
|
12484
13995
|
const descId = `${fieldId}-desc`;
|
|
@@ -12499,6 +14010,8 @@ function Field({
|
|
|
12499
14010
|
}
|
|
12500
14011
|
var UPLOAD_CSS = `
|
|
12501
14012
|
.twc-upload { font-family: var(--font-sans); display: flex; flex-direction: column; gap: var(--space-3); }
|
|
14013
|
+
.twc-upload[data-size="sm"] { --_pad-y: var(--space-5); --_pad-x: var(--space-4); }
|
|
14014
|
+
.twc-upload[data-size="lg"] { --_pad-y: var(--space-10); --_pad-x: var(--space-8); }
|
|
12502
14015
|
.twc-field__label { font-size: var(--text-sm); font-weight: var(--font-semibold); color: var(--color-text); display: flex; gap: 4px; align-items: center; }
|
|
12503
14016
|
.twc-field__req { color: var(--color-danger); }
|
|
12504
14017
|
.twc-field__hint { font-size: var(--text-xs); color: var(--color-text-muted); }
|
|
@@ -12506,7 +14019,7 @@ var UPLOAD_CSS = `
|
|
|
12506
14019
|
.twc-upload__zone[data-invalid="true"] { border-color: var(--color-danger); }
|
|
12507
14020
|
.twc-upload__zone {
|
|
12508
14021
|
display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
|
|
12509
|
-
gap: 6px; padding: var(--space-8) var(--space-6); cursor: pointer;
|
|
14022
|
+
gap: 6px; padding: var(--_pad-y, var(--space-8)) var(--_pad-x, var(--space-6)); cursor: pointer;
|
|
12510
14023
|
border: var(--border-medium) dashed var(--color-border-strong); border-radius: var(--radius-xl);
|
|
12511
14024
|
background: var(--color-surface); color: var(--color-text-muted);
|
|
12512
14025
|
transition: border-color var(--duration-fast) var(--ease-standard), background-color var(--duration-fast) var(--ease-standard);
|
|
@@ -12559,6 +14072,7 @@ function FileUpload({
|
|
|
12559
14072
|
accept,
|
|
12560
14073
|
multiple = false,
|
|
12561
14074
|
disabled = false,
|
|
14075
|
+
size = "md",
|
|
12562
14076
|
tone = "primary",
|
|
12563
14077
|
label,
|
|
12564
14078
|
hint,
|
|
@@ -12614,7 +14128,7 @@ function FileUpload({
|
|
|
12614
14128
|
function remove(i) {
|
|
12615
14129
|
set(files.filter((_, idx) => idx !== i));
|
|
12616
14130
|
}
|
|
12617
|
-
return /* @__PURE__ */ jsxs("div", { className: `twc-upload ${className}`, ...rest, children: [
|
|
14131
|
+
return /* @__PURE__ */ jsxs("div", { className: `twc-upload ${className}`, "data-size": size, ...rest, children: [
|
|
12618
14132
|
__twcStyles,
|
|
12619
14133
|
label ? /* @__PURE__ */ jsxs("label", { className: "twc-field__label", htmlFor: fieldId, children: [
|
|
12620
14134
|
label,
|
|
@@ -13027,7 +14541,7 @@ button.twc-navbar__brand, a.twc-navbar__brand { cursor: pointer; }
|
|
|
13027
14541
|
.twc-navbar__menu-btn { display: inline-grid; }
|
|
13028
14542
|
}
|
|
13029
14543
|
`;
|
|
13030
|
-
function
|
|
14544
|
+
function safeHref6(url) {
|
|
13031
14545
|
if (url == null) return void 0;
|
|
13032
14546
|
const s = String(url).replace(/[\x00-\x20]+/g, "").toLowerCase();
|
|
13033
14547
|
return s.startsWith("javascript:") || s.startsWith("data:") || s.startsWith("vbscript:") ? void 0 : url;
|
|
@@ -13050,9 +14564,9 @@ function Navbar({
|
|
|
13050
14564
|
return /* @__PURE__ */ jsxs("header", { className: `twc-navbar ${className}`, "data-sticky": sticky || void 0, ...rest, children: [
|
|
13051
14565
|
__twcStyles,
|
|
13052
14566
|
onMenuClick ? /* @__PURE__ */ jsx("button", { type: "button", className: "twc-navbar__menu-btn", "aria-expanded": menuOpen, "aria-controls": menuControls, "aria-label": menuOpen ? "Close menu" : "Open menu", onClick: onMenuClick, children: /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsx("path", { d: "M4 6h16M4 12h16M4 18h16" }) }) }) : null,
|
|
13053
|
-
brand ? brandHref ? /* @__PURE__ */ jsx("a", { className: "twc-navbar__brand", href:
|
|
14567
|
+
brand ? brandHref ? /* @__PURE__ */ jsx("a", { className: "twc-navbar__brand", href: safeHref6(brandHref), children: brand }) : onBrandClick ? /* @__PURE__ */ jsx("button", { type: "button", className: "twc-navbar__brand", onClick: onBrandClick, children: brand }) : /* @__PURE__ */ jsx("span", { className: "twc-navbar__brand", children: brand }) : null,
|
|
13054
14568
|
/* @__PURE__ */ jsx("nav", { className: "twc-navbar__links", "aria-label": navLabel, children: links.map((l, i) => {
|
|
13055
|
-
const href =
|
|
14569
|
+
const href = safeHref6(l.href);
|
|
13056
14570
|
const inner = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
13057
14571
|
l.icon,
|
|
13058
14572
|
l.label
|
|
@@ -13412,6 +14926,7 @@ function Radio({
|
|
|
13412
14926
|
.twc-radio[data-invalid="true"] .twc-radio__dot { border-color: var(--color-danger); }
|
|
13413
14927
|
.twc-radio__text { display: flex; flex-direction: column; gap: 2px; }
|
|
13414
14928
|
.twc-radio__label { font-size: var(--text-sm); font-weight: var(--font-medium); color: var(--color-text); line-height: 1.3; }
|
|
14929
|
+
.twc-field__req { color: var(--color-danger); }
|
|
13415
14930
|
.twc-radio__desc { font-size: var(--text-xs); color: var(--color-text-muted); }
|
|
13416
14931
|
.twc-field { display: flex; flex-direction: column; gap: var(--space-1-5); font-family: var(--font-sans); }
|
|
13417
14932
|
.twc-field__error { font-size: var(--text-xs); color: var(--color-danger-subtle-fg); font-weight: var(--font-medium); }
|
|
@@ -13447,7 +14962,10 @@ function Radio({
|
|
|
13447
14962
|
),
|
|
13448
14963
|
/* @__PURE__ */ jsx("span", { className: "twc-radio__dot", "aria-hidden": "true" }),
|
|
13449
14964
|
label || description ? /* @__PURE__ */ jsxs("span", { className: "twc-radio__text", children: [
|
|
13450
|
-
label ? /* @__PURE__ */
|
|
14965
|
+
label ? /* @__PURE__ */ jsxs("span", { className: "twc-radio__label", children: [
|
|
14966
|
+
label,
|
|
14967
|
+
required ? /* @__PURE__ */ jsx("span", { className: "twc-field__req", children: "*" }) : null
|
|
14968
|
+
] }) : null,
|
|
13451
14969
|
description ? /* @__PURE__ */ jsx("span", { className: "twc-radio__desc", children: description }) : null
|
|
13452
14970
|
] }) : null
|
|
13453
14971
|
] });
|
|
@@ -13977,20 +15495,23 @@ var SLIDER_CSS = `
|
|
|
13977
15495
|
.twc-slider__msgs { display: flex; flex-direction: column; gap: var(--space-1-5); margin-top: var(--space-2); }
|
|
13978
15496
|
.twc-field__hint { font-size: var(--text-xs); color: var(--color-text-muted); }
|
|
13979
15497
|
.twc-field__error { font-size: var(--text-xs); color: var(--color-danger-subtle-fg); font-weight: var(--font-medium); }
|
|
15498
|
+
.twc-slider { --_track-h: 22px; --_thumb: 18px; --_rail: 6px; }
|
|
15499
|
+
.twc-slider[data-size="sm"] { --_track-h: 18px; --_thumb: 14px; --_rail: 4px; }
|
|
15500
|
+
.twc-slider[data-size="lg"] { --_track-h: 28px; --_thumb: 22px; --_rail: 8px; }
|
|
13980
15501
|
.twc-slider__head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: var(--space-2); }
|
|
13981
15502
|
.twc-slider__label { font-size: var(--text-sm); font-weight: var(--font-semibold); color: var(--color-text); }
|
|
13982
15503
|
.twc-slider__value { font-size: var(--text-sm); font-weight: var(--font-semibold); color: var(--_accent); font-variant-numeric: tabular-nums; }
|
|
13983
15504
|
.twc-slider__track {
|
|
13984
|
-
position: relative; height:
|
|
15505
|
+
position: relative; height: var(--_track-h); display: flex; align-items: center; cursor: pointer; touch-action: none;
|
|
13985
15506
|
}
|
|
13986
15507
|
.twc-slider[data-disabled="true"] { opacity: 0.55; }
|
|
13987
15508
|
.twc-slider[data-disabled="true"] .twc-slider__track { cursor: not-allowed; }
|
|
13988
|
-
.twc-slider__rail { position: absolute; left: 0; right: 0; height:
|
|
13989
|
-
.twc-slider__fill { position: absolute; height:
|
|
15509
|
+
.twc-slider__rail { position: absolute; left: 0; right: 0; height: var(--_rail); border-radius: var(--radius-full); background: var(--color-surface-sunken); box-shadow: inset 0 0 0 1px var(--color-border); }
|
|
15510
|
+
.twc-slider__fill { position: absolute; height: var(--_rail); border-radius: var(--radius-full); background: var(--_accent); }
|
|
13990
15511
|
.twc-slider__thumb {
|
|
13991
|
-
position: absolute; width:
|
|
15512
|
+
position: absolute; width: var(--_thumb); height: var(--_thumb); border-radius: var(--radius-full);
|
|
13992
15513
|
background: var(--color-surface); border: var(--border-thick) solid var(--_accent);
|
|
13993
|
-
box-shadow: var(--shadow-sm); transform: translateX(-50%); top: 50%; margin-top: -
|
|
15514
|
+
box-shadow: var(--shadow-sm); transform: translateX(-50%); top: 50%; margin-top: calc(var(--_thumb) / -2);
|
|
13994
15515
|
transition: box-shadow var(--duration-fast) var(--ease-standard), transform var(--duration-fast) var(--ease-spring);
|
|
13995
15516
|
}
|
|
13996
15517
|
.twc-slider__thumb:focus-visible { outline: none; box-shadow: var(--ring); }
|
|
@@ -14018,7 +15539,8 @@ function Slider({
|
|
|
14018
15539
|
precision,
|
|
14019
15540
|
tone = "primary",
|
|
14020
15541
|
disabled = false,
|
|
14021
|
-
|
|
15542
|
+
size = "md",
|
|
15543
|
+
range: range2 = false,
|
|
14022
15544
|
showValue = true,
|
|
14023
15545
|
showTicks = false,
|
|
14024
15546
|
formatValue,
|
|
@@ -14046,7 +15568,7 @@ function Slider({
|
|
|
14046
15568
|
const __twcStyles = useScopedStyles("twc-slider-styles", SLIDER_CSS);
|
|
14047
15569
|
const autoId = React51__default.useId();
|
|
14048
15570
|
const fieldId = id || autoId;
|
|
14049
|
-
const isRange =
|
|
15571
|
+
const isRange = range2 || Array.isArray(value) || Array.isArray(defaultValue);
|
|
14050
15572
|
const [internal, setInternal] = React51__default.useState(() => {
|
|
14051
15573
|
if (isRange) {
|
|
14052
15574
|
const dv = Array.isArray(defaultValue) ? defaultValue : [min, max];
|
|
@@ -14134,7 +15656,7 @@ function Slider({
|
|
|
14134
15656
|
const fillLo = (Math.min(...clampedVals) - min) / (max - min) * 100;
|
|
14135
15657
|
const fillHi = (Math.max(...clampedVals) - min) / (max - min) * 100;
|
|
14136
15658
|
const fillStyle = isRange ? { left: `${fillLo}%`, width: `${fillHi - fillLo}%` } : { width: `${fillHi}%` };
|
|
14137
|
-
return /* @__PURE__ */ jsxs("div", { className: `twc-slider ${className}`, "data-tone": tone, "data-disabled": disabled || void 0, ...rest, children: [
|
|
15659
|
+
return /* @__PURE__ */ jsxs("div", { className: `twc-slider ${className}`, "data-tone": tone, "data-size": size, "data-disabled": disabled || void 0, ...rest, children: [
|
|
14138
15660
|
__twcStyles,
|
|
14139
15661
|
name ? clampedVals.map((v, i) => /* @__PURE__ */ jsx("input", { type: "hidden", name, value: v, disabled: disabled || void 0 }, i)) : null,
|
|
14140
15662
|
label || showValue ? /* @__PURE__ */ jsxs("div", { className: "twc-slider__head", children: [
|
|
@@ -14186,10 +15708,10 @@ function Spinner({
|
|
|
14186
15708
|
className = "",
|
|
14187
15709
|
...rest
|
|
14188
15710
|
}) {
|
|
14189
|
-
if (process.env.NODE_ENV !== "production" &&
|
|
14190
|
-
warnOnce("Spinner.
|
|
15711
|
+
if (process.env.NODE_ENV !== "production" && color !== void 0 && tone === void 0) {
|
|
15712
|
+
warnOnce("Spinner.color", "Spinner: `color` is deprecated and will be removed in 2.0 \u2014 use `tone` (matches every other tone-driven component).");
|
|
14191
15713
|
}
|
|
14192
|
-
const
|
|
15714
|
+
const resolvedTone = tone ?? color ?? "current";
|
|
14193
15715
|
const __twcStyles = useScopedStyles("twc-spinner-styles", `
|
|
14194
15716
|
.twc-spinner {
|
|
14195
15717
|
--_sz: 24px; --_bw: 2.5px;
|
|
@@ -14215,7 +15737,7 @@ function Spinner({
|
|
|
14215
15737
|
.twc-spinner { animation-duration: 0.65s !important; animation-iteration-count: infinite !important; }
|
|
14216
15738
|
}
|
|
14217
15739
|
`);
|
|
14218
|
-
return /* @__PURE__ */ jsx("span", { className: `twc-spinner ${className}`, "data-size": size, "data-tone":
|
|
15740
|
+
return /* @__PURE__ */ jsx("span", { className: `twc-spinner ${className}`, "data-size": size, "data-tone": resolvedTone, role: "status", "aria-label": label, ...rest, children: __twcStyles });
|
|
14219
15741
|
}
|
|
14220
15742
|
var STAT_CSS = `
|
|
14221
15743
|
.twc-stat { display: flex; flex-direction: column; gap: 6px; font-family: var(--font-sans);
|
|
@@ -14449,6 +15971,7 @@ function Switch({
|
|
|
14449
15971
|
.twc-switch[data-invalid="true"] .twc-switch__track { box-shadow: inset 0 0 0 var(--border-medium) var(--color-danger); }
|
|
14450
15972
|
.twc-switch__text { display: flex; flex-direction: column; gap: 2px; }
|
|
14451
15973
|
.twc-switch__label { font-size: var(--text-sm); font-weight: var(--font-medium); color: var(--color-text); line-height: 1.3; }
|
|
15974
|
+
.twc-field__req { color: var(--color-danger); }
|
|
14452
15975
|
.twc-switch__desc { font-size: var(--text-xs); color: var(--color-text-muted); }
|
|
14453
15976
|
.twc-field { display: flex; flex-direction: column; gap: var(--space-1-5); font-family: var(--font-sans); }
|
|
14454
15977
|
.twc-field__error { font-size: var(--text-xs); color: var(--color-danger-subtle-fg); font-weight: var(--font-medium); }
|
|
@@ -14483,7 +16006,10 @@ function Switch({
|
|
|
14483
16006
|
),
|
|
14484
16007
|
/* @__PURE__ */ jsx("span", { className: "twc-switch__track", "aria-hidden": "true", children: /* @__PURE__ */ jsx("span", { className: "twc-switch__thumb" }) }),
|
|
14485
16008
|
label || description ? /* @__PURE__ */ jsxs("span", { className: "twc-switch__text", children: [
|
|
14486
|
-
label ? /* @__PURE__ */
|
|
16009
|
+
label ? /* @__PURE__ */ jsxs("span", { className: "twc-switch__label", children: [
|
|
16010
|
+
label,
|
|
16011
|
+
required ? /* @__PURE__ */ jsx("span", { className: "twc-field__req", children: "*" }) : null
|
|
16012
|
+
] }) : null,
|
|
14487
16013
|
description ? /* @__PURE__ */ jsx("span", { className: "twc-switch__desc", children: description }) : null
|
|
14488
16014
|
] }) : null
|
|
14489
16015
|
] });
|
|
@@ -14696,6 +16222,11 @@ var TABS_CSS = `
|
|
|
14696
16222
|
top: auto; inset-inline-end: 4px; inset-inline-start: 4px; width: auto;
|
|
14697
16223
|
}
|
|
14698
16224
|
.twc-tabs[data-orientation="vertical"] .twc-tabs__panel { padding-top: 0; flex: 1; min-width: 0; }
|
|
16225
|
+
/* WCAG 2.3.3: the active-tab indicator jumps instead of sliding under reduced motion (both
|
|
16226
|
+
the horizontal left/width and vertical top/height variants). */
|
|
16227
|
+
@media (prefers-reduced-motion: reduce) {
|
|
16228
|
+
.twc-tabs__indicator, .twc-tabs[data-orientation="vertical"] .twc-tabs__indicator { transition: none; }
|
|
16229
|
+
}
|
|
14699
16230
|
`;
|
|
14700
16231
|
function Tabs({
|
|
14701
16232
|
items,
|
|
@@ -15074,6 +16605,12 @@ var TOAST_CSS = `
|
|
|
15074
16605
|
from { opacity: 0; transform: translateX(-24px); }
|
|
15075
16606
|
to { opacity: 1; transform: translateX(0); }
|
|
15076
16607
|
}
|
|
16608
|
+
/* WCAG 2.3.3: appear without the slide under reduced motion (covers the RTL variant too). */
|
|
16609
|
+
@media (prefers-reduced-motion: reduce) {
|
|
16610
|
+
.twc-toast, [dir="rtl"] .twc-toast { animation: none; }
|
|
16611
|
+
}
|
|
16612
|
+
/* #209: visually-hidden persistent live-region announcers (rendered by ToastProvider). */
|
|
16613
|
+
.twc-toast-sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }
|
|
15077
16614
|
.twc-toast::before { content: ""; position: absolute; inset-inline-start: 0; top: 0; bottom: 0; width: 4px; background: var(--_accent, var(--color-primary)); }
|
|
15078
16615
|
.twc-toast[data-tone="success"] { --_accent: var(--color-success); }
|
|
15079
16616
|
.twc-toast[data-tone="warning"] { --_accent: var(--color-warning); }
|
|
@@ -15190,6 +16727,8 @@ function useToast() {
|
|
|
15190
16727
|
}
|
|
15191
16728
|
function ToastProvider({ children, limit = 4, duration = 4500, ...viewportProps }) {
|
|
15192
16729
|
const [toasts, setToasts] = React51__default.useState([]);
|
|
16730
|
+
const [politeMsg, setPoliteMsg] = React51__default.useState("");
|
|
16731
|
+
const [assertiveMsg, setAssertiveMsg] = React51__default.useState("");
|
|
15193
16732
|
const idRef = React51__default.useRef(0);
|
|
15194
16733
|
const limitRef = React51__default.useRef(limit);
|
|
15195
16734
|
React51__default.useEffect(() => {
|
|
@@ -15208,6 +16747,12 @@ function ToastProvider({ children, limit = 4, duration = 4500, ...viewportProps
|
|
|
15208
16747
|
const n = limitRef.current;
|
|
15209
16748
|
return n && n > 0 ? arr.slice(-n) : arr;
|
|
15210
16749
|
});
|
|
16750
|
+
const parts = [next.title, next.description != null ? next.description : next.children].filter((p) => typeof p === "string" || typeof p === "number").map(String);
|
|
16751
|
+
const msg = parts.join(". ").trim();
|
|
16752
|
+
if (msg) {
|
|
16753
|
+
const setter = next.tone === "danger" || next.tone === "warning" ? setAssertiveMsg : setPoliteMsg;
|
|
16754
|
+
setter((prev) => prev === msg ? msg + "\u200B" : msg);
|
|
16755
|
+
}
|
|
15211
16756
|
return id;
|
|
15212
16757
|
};
|
|
15213
16758
|
const withTone = (tone) => (title, options) => push(typeof title === "object" && title !== null ? { tone, ...title } : { tone, title, ...options });
|
|
@@ -15223,12 +16768,15 @@ function ToastProvider({ children, limit = 4, duration = 4500, ...viewportProps
|
|
|
15223
16768
|
const value = React51__default.useMemo(() => ({ ...api, toasts }), [api, toasts]);
|
|
15224
16769
|
return /* @__PURE__ */ jsxs(ToastContext.Provider, { value, children: [
|
|
15225
16770
|
children,
|
|
16771
|
+
/* @__PURE__ */ jsx("div", { className: "twc-toast-sr", "aria-live": "polite", "aria-atomic": "true", children: politeMsg }),
|
|
16772
|
+
/* @__PURE__ */ jsx("div", { className: "twc-toast-sr", "aria-live": "assertive", "aria-atomic": "true", children: assertiveMsg }),
|
|
15226
16773
|
/* @__PURE__ */ jsx(ToastViewport, { limit, ...viewportProps, children: toasts.map((t) => /* @__PURE__ */ jsx(
|
|
15227
16774
|
Toast,
|
|
15228
16775
|
{
|
|
15229
16776
|
tone: t.tone,
|
|
15230
16777
|
title: t.title,
|
|
15231
16778
|
icon: t.icon,
|
|
16779
|
+
role: "group",
|
|
15232
16780
|
duration: t.duration != null ? t.duration : duration,
|
|
15233
16781
|
onClose: () => dismiss(t.id),
|
|
15234
16782
|
children: t.description != null ? t.description : t.children
|
|
@@ -15502,7 +17050,7 @@ function bgValue(bg) {
|
|
|
15502
17050
|
if (BG[bg]) return `var(${BG[bg]})`;
|
|
15503
17051
|
return String(bg).startsWith("--") ? `var(${bg})` : bg;
|
|
15504
17052
|
}
|
|
15505
|
-
function
|
|
17053
|
+
function safeHref7(url) {
|
|
15506
17054
|
if (url == null) return void 0;
|
|
15507
17055
|
const s = String(url).replace(/[\x00-\x20]+/g, "").toLowerCase();
|
|
15508
17056
|
return s.startsWith("javascript:") || s.startsWith("data:") || s.startsWith("vbscript:") ? void 0 : url;
|
|
@@ -15550,7 +17098,7 @@ var Box = React51__default.forwardRef(function Box2({
|
|
|
15550
17098
|
...style,
|
|
15551
17099
|
...flatStyle
|
|
15552
17100
|
};
|
|
15553
|
-
if (Tag2 === "a" && rest.href != null) rest.href =
|
|
17101
|
+
if (Tag2 === "a" && rest.href != null) rest.href = safeHref7(rest.href);
|
|
15554
17102
|
return /* @__PURE__ */ jsxs(Tag2, { ref, className: `twc-box ${className}`.trim(), style: s, "data-twc-sx": sxAttr, ...rest, children: [
|
|
15555
17103
|
styleNode,
|
|
15556
17104
|
children
|
|
@@ -15558,7 +17106,7 @@ var Box = React51__default.forwardRef(function Box2({
|
|
|
15558
17106
|
});
|
|
15559
17107
|
Box.displayName = "Box";
|
|
15560
17108
|
var SIZES = { sm: 640, md: 768, lg: 1024, xl: 1280, full: "100%" };
|
|
15561
|
-
function
|
|
17109
|
+
function safeHref8(url) {
|
|
15562
17110
|
if (url == null) return void 0;
|
|
15563
17111
|
const s = String(url).replace(/[\x00-\x20]+/g, "").toLowerCase();
|
|
15564
17112
|
return s.startsWith("javascript:") || s.startsWith("data:") || s.startsWith("vbscript:") ? void 0 : url;
|
|
@@ -15575,7 +17123,7 @@ var Container = React51__default.forwardRef(function Container2({
|
|
|
15575
17123
|
}, ref) {
|
|
15576
17124
|
const { flatStyle, styleNode, sxAttr } = useSx(sx);
|
|
15577
17125
|
const max = SIZES[size] ?? size;
|
|
15578
|
-
if (Tag2 === "a" && rest.href != null) rest.href =
|
|
17126
|
+
if (Tag2 === "a" && rest.href != null) rest.href = safeHref8(rest.href);
|
|
15579
17127
|
return /* @__PURE__ */ jsxs(
|
|
15580
17128
|
Tag2,
|
|
15581
17129
|
{
|
|
@@ -15601,83 +17149,6 @@ var Container = React51__default.forwardRef(function Container2({
|
|
|
15601
17149
|
);
|
|
15602
17150
|
});
|
|
15603
17151
|
Container.displayName = "Container";
|
|
15604
|
-
function space(v) {
|
|
15605
|
-
if (v == null) return void 0;
|
|
15606
|
-
if (typeof v === "number") return `var(--space-${String(v).replace(".", "-")})`;
|
|
15607
|
-
return v;
|
|
15608
|
-
}
|
|
15609
|
-
function len(v) {
|
|
15610
|
-
return typeof v === "number" ? `${v}px` : v;
|
|
15611
|
-
}
|
|
15612
|
-
var BP = { sm: 640, md: 768, lg: 1024, xl: 1280 };
|
|
15613
|
-
function safeHref8(url) {
|
|
15614
|
-
if (url == null) return void 0;
|
|
15615
|
-
const s = String(url).replace(/[\x00-\x20]+/g, "").toLowerCase();
|
|
15616
|
-
return s.startsWith("javascript:") || s.startsWith("data:") || s.startsWith("vbscript:") ? void 0 : url;
|
|
15617
|
-
}
|
|
15618
|
-
var Grid = React51__default.forwardRef(function Grid2({
|
|
15619
|
-
as: Tag2 = "div",
|
|
15620
|
-
columns,
|
|
15621
|
-
minChildWidth,
|
|
15622
|
-
gap = 4,
|
|
15623
|
-
rowGap,
|
|
15624
|
-
columnGap,
|
|
15625
|
-
align,
|
|
15626
|
-
justify,
|
|
15627
|
-
alignContent,
|
|
15628
|
-
justifyContent,
|
|
15629
|
-
sx,
|
|
15630
|
-
className = "",
|
|
15631
|
-
style,
|
|
15632
|
-
children,
|
|
15633
|
-
...rest
|
|
15634
|
-
}, ref) {
|
|
15635
|
-
const { flatStyle, styleNode, sxAttr } = useSx(sx);
|
|
15636
|
-
const responsive = columns != null && typeof columns === "object";
|
|
15637
|
-
const uid = React51__default.useId();
|
|
15638
|
-
const gridId = responsive ? `g${uid.replace(/[^a-zA-Z0-9]/g, "")}` : null;
|
|
15639
|
-
let css = "";
|
|
15640
|
-
if (responsive) {
|
|
15641
|
-
const base = columns.base ?? 1;
|
|
15642
|
-
const sel = `[data-twc-grid-id="${gridId}"]`;
|
|
15643
|
-
css = `${sel} { --twc-grid-cols: ${base}; }`;
|
|
15644
|
-
for (const bp of ["sm", "md", "lg", "xl"]) {
|
|
15645
|
-
if (columns[bp] != null) css += `
|
|
15646
|
-
@media (min-width: ${BP[bp]}px) { ${sel} { --twc-grid-cols: ${columns[bp]}; } }`;
|
|
15647
|
-
}
|
|
15648
|
-
}
|
|
15649
|
-
const __twcStyles = useScopedStyles(gridId ? `twc-grid-${gridId}` : "twc-grid", css);
|
|
15650
|
-
const templateColumns = minChildWidth ? `repeat(auto-fill, minmax(min(${len(minChildWidth)}, 100%), 1fr))` : responsive ? `repeat(var(--twc-grid-cols, ${columns.base ?? 1}), minmax(0, 1fr))` : `repeat(${columns || 1}, minmax(0, 1fr))`;
|
|
15651
|
-
if (Tag2 === "a" && rest.href != null) rest.href = safeHref8(rest.href);
|
|
15652
|
-
return /* @__PURE__ */ jsxs(
|
|
15653
|
-
Tag2,
|
|
15654
|
-
{
|
|
15655
|
-
ref,
|
|
15656
|
-
className: `twc-grid ${className}`.trim(),
|
|
15657
|
-
"data-twc-grid-id": gridId || void 0,
|
|
15658
|
-
"data-twc-sx": sxAttr,
|
|
15659
|
-
style: {
|
|
15660
|
-
display: "grid",
|
|
15661
|
-
gridTemplateColumns: templateColumns,
|
|
15662
|
-
rowGap: space(rowGap ?? gap),
|
|
15663
|
-
columnGap: space(columnGap ?? gap),
|
|
15664
|
-
alignItems: align,
|
|
15665
|
-
justifyItems: justify,
|
|
15666
|
-
alignContent,
|
|
15667
|
-
justifyContent,
|
|
15668
|
-
...style,
|
|
15669
|
-
...flatStyle
|
|
15670
|
-
},
|
|
15671
|
-
...rest,
|
|
15672
|
-
children: [
|
|
15673
|
-
responsive ? __twcStyles : null,
|
|
15674
|
-
styleNode,
|
|
15675
|
-
children
|
|
15676
|
-
]
|
|
15677
|
-
}
|
|
15678
|
-
);
|
|
15679
|
-
});
|
|
15680
|
-
Grid.displayName = "Grid";
|
|
15681
17152
|
function space2(v) {
|
|
15682
17153
|
if (v == null) return void 0;
|
|
15683
17154
|
if (typeof v === "number") return `var(--space-${String(v).replace(".", "-")})`;
|
|
@@ -16267,6 +17738,6 @@ var useFocusTrap2 = useFocusTrap;
|
|
|
16267
17738
|
var usePortal2 = usePortal;
|
|
16268
17739
|
var useScrollLock2 = useScrollLock;
|
|
16269
17740
|
|
|
16270
|
-
export { Accordion, Alert, Anchor, AppShell, Avatar, AvatarMenu, Badge, Box, Boxplot, Breadcrumb, BubbleChart, Button, Candlestick, Card, Carousel, Chart, Checkbox, Code, ColorPicker, ColorSchemeScript, Combobox, CommandPalette, Container, Currency, CurrencyField, Datatable, DatePicker, DateRangePicker, Dialog, Divider, DonutChart, Drawer, EmptyState, Field, FileUpload, Form, FunnelChart, Gauge, Grid, Heading, Heatmap, IconButton, Image, Input, Kanban, Kbd, Label, List, Menu, MultiSelect, Navbar, Pagination, PieChart, PolarAreaChart, Popover, Portal, Pre, Progress, RadarChart, Radio, RadioGroup, RangeChart, Rating, ScatterChart, Select, Sidebar, Skeleton, Slider, Sparkline, Spinner, Stack, Stat, Stepper, Switch, Table, Tabs, Tag, Text, Textarea, ThemeProvider, Timeline, Toast, ToastProvider, ToastViewport, Tooltip, TreeView, Treemap, TwicoProvider, VisuallyHidden, createTheme, getColorSchemeScript, runDatatableQuery, useClickOutside, useColorScheme, useControllableState, useCopyToClipboard, useDebouncedCallback, useDebouncedValue, useDisclosure, useEventListener, useFocusTrap2 as useFocusTrap, useHover, useId, useIntersectionObserver, useInterval, useIsomorphicLayoutEffect, useKeyPress, useLocalStorage, useMediaQuery, useMounted, usePortal2 as usePortal, usePrefersReducedMotion, usePrevious, useScrollLock2 as useScrollLock, useTimeout, useToast, useToggle, useWindowSize };
|
|
17741
|
+
export { Accordion, Alert, Anchor, AppShell, Avatar, AvatarMenu, Badge, Box, Boxplot, Breadcrumb, BubbleChart, Button, Candlestick, Card, CardGrid, Carousel, Chart, Checkbox, Code, ColorPicker, ColorSchemeScript, Combobox, CommandPalette, Container, Currency, CurrencyField, Datatable, DatePicker, DateRangePicker, DateTimePicker, Dialog, DiffTable, Divider, DonutChart, Drawer, EmptyState, Field, FileUpload, FilterBar, Form, FunnelChart, Gauge, Grid, Heading, Heatmap, IconButton, Image, Input, Kanban, Kbd, Label, List, Menu, MultiSelect, Navbar, Pagination, PieChart, PolarAreaChart, Popover, Portal, Pre, Progress, RadarChart, Radio, RadioGroup, RangeChart, Rating, ScatterChart, Select, Sidebar, Skeleton, Slider, Sparkline, Spinner, Stack, Stat, Stepper, Switch, Table, Tabs, Tag, Text, Textarea, ThemeProvider, TimePicker, Timeline, Toast, ToastProvider, ToastViewport, Tooltip, TreeView, Treemap, TwicoProvider, VisuallyHidden, createTheme, getColorSchemeScript, runDatatableQuery, useClickOutside, useColorScheme, useControllableState, useCopyToClipboard, useDebouncedCallback, useDebouncedValue, useDisclosure, useEventListener, useFocusTrap2 as useFocusTrap, useHover, useId, useIntersectionObserver, useInterval, useIsomorphicLayoutEffect, useKeyPress, useLocalStorage, useMediaQuery, useMounted, usePortal2 as usePortal, usePrefersReducedMotion, usePrevious, useScrollLock2 as useScrollLock, useTimeout, useToast, useToggle, useWindowSize };
|
|
16271
17742
|
//# sourceMappingURL=index.mjs.map
|
|
16272
17743
|
//# sourceMappingURL=index.mjs.map
|