@laoyuehanni/dsh-token-usage 0.3.12 → 0.3.13
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/lib/client/DateRangePicker.d.ts +39 -0
- package/lib/client/DateRangePicker.d.ts.map +1 -0
- package/lib/client/DateRangePicker.js +134 -0
- package/lib/client/DateRangePicker.js.map +1 -0
- package/lib/client/MenuSelect.d.ts +47 -0
- package/lib/client/MenuSelect.d.ts.map +1 -0
- package/lib/client/MenuSelect.js +152 -0
- package/lib/client/MenuSelect.js.map +1 -0
- package/lib/client/TokenUsageSection.d.ts.map +1 -1
- package/lib/client/TokenUsageSection.js +26 -8
- package/lib/client/TokenUsageSection.js.map +1 -1
- package/lib/client/day.d.ts +22 -0
- package/lib/client/day.d.ts.map +1 -1
- package/lib/client/day.js +31 -0
- package/lib/client/day.js.map +1 -1
- package/lib/client/locales.d.ts +13 -2
- package/lib/client/locales.d.ts.map +1 -1
- package/lib/client/locales.js +26 -4
- package/lib/client/locales.js.map +1 -1
- package/lib/client.js +546 -95
- package/lib/client.js.map +1 -1
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -541,13 +541,13 @@ window.__ModuleLoader__.load({
|
|
|
541
541
|
}
|
|
542
542
|
//#endregion
|
|
543
543
|
//#region \0dsh-css:D:\Code\dsh-token-usage\src\client\QuotaButton.module.css.mjs
|
|
544
|
-
const css$
|
|
545
|
-
const tagId$
|
|
546
|
-
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$
|
|
544
|
+
const css$9 = ".jYASuG_root{flex:none;display:inline-flex;position:relative}.jYASuG_trigger{width:28px;height:28px;color:var(--dsw-alias-label-secondary);cursor:pointer;background:0 0;border:none;border-radius:999px;flex:none;place-items:center;padding:0;display:grid}.jYASuG_trigger svg{display:block}.jYASuG_trigger:hover,.jYASuG_trigger[aria-expanded=true]{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}.jYASuG_trigger.jYASuG_icon-ok:hover,.jYASuG_trigger.jYASuG_icon-ok[aria-expanded=true]{color:var(--dsw-alias-state-success-primary)}.jYASuG_trigger.jYASuG_icon-warn:hover,.jYASuG_trigger.jYASuG_icon-warn[aria-expanded=true]{color:var(--dsw-alias-state-warn-primary)}.jYASuG_trigger.jYASuG_icon-exhausted:hover,.jYASuG_trigger.jYASuG_icon-exhausted[aria-expanded=true]{color:var(--dsw-alias-state-error-primary)}.jYASuG_icon-ok{color:var(--dsw-alias-state-success-primary)}.jYASuG_icon-warn{color:var(--dsw-alias-state-warn-primary)}.jYASuG_icon-exhausted{color:var(--dsw-alias-state-error-primary)}.jYASuG_panel{z-index:100;box-sizing:border-box;border:1px solid var(--dsw-alias-border-inverted);background:var(--dsw-specific-menu);width:320px;max-width:calc(100vw - 32px);box-shadow:var(--dsw-shadow-lv3);color:var(--dsw-alias-label-secondary);text-align:left;cursor:default;border-radius:12px;padding:12px;font-size:12px;line-height:20px;position:absolute;bottom:calc(100% + 8px)}.jYASuG_header{justify-content:space-between;align-items:baseline;gap:8px;margin-bottom:10px;display:flex}.jYASuG_title{color:var(--dsw-alias-label-primary);white-space:nowrap;text-overflow:ellipsis;font-size:13px;font-weight:500;overflow:hidden}.jYASuG_plan{color:var(--dsw-alias-label-tertiary);font-weight:400}.jYASuG_updated{color:var(--dsw-alias-label-tertiary);font-variant-numeric:tabular-nums;flex:none;font-size:11px}.jYASuG_grid{grid-template-columns:repeat(var(--cols,3), 1fr);gap:14px;display:grid}.jYASuG_col{min-width:0}.jYASuG_label{color:var(--dsw-alias-label-tertiary);white-space:nowrap;text-overflow:ellipsis;margin-bottom:2px;font-size:11px;line-height:16px;overflow:hidden}.jYASuG_value{color:var(--dsw-alias-label-primary);font-variant-numeric:tabular-nums;white-space:nowrap;margin-bottom:6px;font-size:13px;font-weight:600;line-height:18px}.jYASuG_meta{color:var(--dsw-alias-label-tertiary);font-size:11px;font-weight:400}.jYASuG_bar{background:var(--dsw-alias-interactive-bg-hover);border-radius:999px;height:4px;overflow:hidden}.jYASuG_fill{border-radius:999px;height:100%;transition:width .3s}.jYASuG_ok{background:var(--dsw-alias-state-success-primary)}.jYASuG_warn{background:var(--dsw-alias-state-warn-primary)}.jYASuG_exhausted{background:var(--dsw-alias-state-error-primary)}.jYASuG_aux{color:var(--dsw-alias-label-tertiary);font-variant-numeric:tabular-nums;white-space:nowrap;margin-top:4px;font-size:11px;line-height:14px}.jYASuG_dot{vertical-align:middle;border-radius:50%;width:5px;height:5px;margin-right:3px;display:inline-block}.jYASuG_error{flex-direction:column;gap:8px;display:flex}.jYASuG_errorText{color:var(--dsw-alias-label-secondary);overflow-wrap:anywhere;font-size:12px;line-height:18px}.jYASuG_retry{color:var(--dsw-alias-label-primary);cursor:pointer;text-underline-offset:2px;background:0 0;border:none;align-self:flex-start;padding:0;font-size:12px;text-decoration:underline}.jYASuG_retry:hover{color:var(--dsw-alias-brand-primary)}";
|
|
545
|
+
const tagId$9 = "@laoyuehanni/dsh-token-usage/QuotaButton.module.css";
|
|
546
|
+
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$9) + "]") === null) {
|
|
547
547
|
const tag = document.createElement("style");
|
|
548
548
|
tag.dataset.plugin = "@laoyuehanni/dsh-token-usage";
|
|
549
|
-
tag.dataset.pluginCss = tagId$
|
|
550
|
-
tag.textContent = css$
|
|
549
|
+
tag.dataset.pluginCss = tagId$9;
|
|
550
|
+
tag.textContent = css$9;
|
|
551
551
|
document.head.appendChild(tag);
|
|
552
552
|
}
|
|
553
553
|
var QuotaButton_module_css_default = {
|
|
@@ -951,6 +951,42 @@ window.__ModuleLoader__.load({
|
|
|
951
951
|
date.setDate(date.getDate() + deltaDays);
|
|
952
952
|
return dayKeyOf(date);
|
|
953
953
|
}
|
|
954
|
+
/** The month view holding one day key. */
|
|
955
|
+
function monthViewOf(dayKey) {
|
|
956
|
+
return {
|
|
957
|
+
year: Number(dayKey.slice(0, 4)),
|
|
958
|
+
month: Number(dayKey.slice(5, 7)) - 1
|
|
959
|
+
};
|
|
960
|
+
}
|
|
961
|
+
/** The month view shifted by whole months (year overflow normalized). */
|
|
962
|
+
function shiftMonth(view, deltaMonths) {
|
|
963
|
+
const total = view.year * 12 + view.month + deltaMonths;
|
|
964
|
+
return {
|
|
965
|
+
year: Math.floor(total / 12),
|
|
966
|
+
month: (total % 12 + 12) % 12
|
|
967
|
+
};
|
|
968
|
+
}
|
|
969
|
+
/**
|
|
970
|
+
* The month grid of one month view: Monday-first whole weeks covering the
|
|
971
|
+
* month, so every column aligns under its weekday header. Days of the
|
|
972
|
+
* neighbouring months carry `inMonth: false` — the caller renders them as
|
|
973
|
+
* blank placeholders, keeping the shown month's date texts unique (for
|
|
974
|
+
* tests and screen readers).
|
|
975
|
+
*/
|
|
976
|
+
function monthGrid(view) {
|
|
977
|
+
const leading = (new Date(view.year, view.month, 1).getDay() + 6) % 7;
|
|
978
|
+
const daysInMonth = new Date(view.year, view.month + 1, 0).getDate();
|
|
979
|
+
const total = Math.ceil((leading + daysInMonth) / 7) * 7;
|
|
980
|
+
const cells = [];
|
|
981
|
+
for (let index = 0; index < total; index++) {
|
|
982
|
+
const cursor = new Date(view.year, view.month, 1 - leading + index);
|
|
983
|
+
cells.push({
|
|
984
|
+
day: dayKeyOf(cursor),
|
|
985
|
+
inMonth: cursor.getFullYear() === view.year && cursor.getMonth() === view.month
|
|
986
|
+
});
|
|
987
|
+
}
|
|
988
|
+
return cells;
|
|
989
|
+
}
|
|
954
990
|
/**
|
|
955
991
|
* The zero-filled daily token series over a day range: every calendar day of
|
|
956
992
|
* the range appears once (days without records plot as zero). Absent bounds
|
|
@@ -1157,13 +1193,13 @@ window.__ModuleLoader__.load({
|
|
|
1157
1193
|
}
|
|
1158
1194
|
//#endregion
|
|
1159
1195
|
//#region \0dsh-css:D:\Code\dsh-token-usage\src\client\hit-rate-band.module.css.mjs
|
|
1160
|
-
const css$
|
|
1161
|
-
const tagId$
|
|
1162
|
-
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$
|
|
1196
|
+
const css$8 = ".t6JM8a_band_critical{color:var(--dsw-alias-state-error-primary,#dc2626)}.t6JM8a_band_amber{color:#f59e0b}.t6JM8a_band_lime{color:#84cc16}.t6JM8a_band_healthy{color:var(--dsw-alias-state-success-primary,#16a34a)}";
|
|
1197
|
+
const tagId$8 = "@laoyuehanni/dsh-token-usage/hit-rate-band.module.css";
|
|
1198
|
+
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$8) + "]") === null) {
|
|
1163
1199
|
const tag = document.createElement("style");
|
|
1164
1200
|
tag.dataset.plugin = "@laoyuehanni/dsh-token-usage";
|
|
1165
|
-
tag.dataset.pluginCss = tagId$
|
|
1166
|
-
tag.textContent = css$
|
|
1201
|
+
tag.dataset.pluginCss = tagId$8;
|
|
1202
|
+
tag.textContent = css$8;
|
|
1167
1203
|
document.head.appendChild(tag);
|
|
1168
1204
|
}
|
|
1169
1205
|
var hit_rate_band_module_css_default = {
|
|
@@ -1383,13 +1419,13 @@ window.__ModuleLoader__.load({
|
|
|
1383
1419
|
}
|
|
1384
1420
|
//#endregion
|
|
1385
1421
|
//#region \0dsh-css:D:\Code\dsh-token-usage\src\client\SessionStatsChip.module.css.mjs
|
|
1386
|
-
const css$
|
|
1387
|
-
const tagId$
|
|
1388
|
-
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$
|
|
1422
|
+
const css$7 = ".d5ISLa_strip{border:1px solid var(--dsw-alias-border-l2);font-variant-numeric:tabular-nums;background:0 0;border-radius:14px;flex:none;align-items:stretch;min-width:0;height:28px;font-size:12px;line-height:18px;display:inline-flex;overflow:hidden}.d5ISLa_stripFlyOverflow{z-index:2;position:relative;overflow:visible}.d5ISLa_cell{color:var(--dsw-alias-label-primary);white-space:nowrap;align-items:center;padding:0 10px;display:inline-flex}.d5ISLa_cell+.d5ISLa_cell{border-left:1px solid var(--dsw-alias-border-l1)}.d5ISLa_cellHit{font-weight:500}.d5ISLa_costCell{z-index:1;position:relative;overflow:visible}.d5ISLa_costInner{transform-origin:50%;z-index:2;justify-content:center;align-items:center;display:inline-flex;position:relative}.d5ISLa_deltaLayer{pointer-events:none;z-index:3;position:absolute;inset:0;overflow:visible}.d5ISLa_deltaFly{color:var(--dsw-alias-state-warn-primary);font-variant-numeric:tabular-nums;white-space:nowrap;pointer-events:none;text-shadow:0 0 8px color-mix(in srgb, var(--dsw-alias-state-warn-primary) 35%, transparent);font-size:11px;font-weight:600;position:absolute;top:0;left:50%;transform:translate(-50%,-100%)}@media (prefers-reduced-motion:reduce){.d5ISLa_deltaFly{display:none}}@media (width<=560px){.d5ISLa_strip{font-size:11px}.d5ISLa_cell{padding:0 7px}}";
|
|
1423
|
+
const tagId$7 = "@laoyuehanni/dsh-token-usage/SessionStatsChip.module.css";
|
|
1424
|
+
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$7) + "]") === null) {
|
|
1389
1425
|
const tag = document.createElement("style");
|
|
1390
1426
|
tag.dataset.plugin = "@laoyuehanni/dsh-token-usage";
|
|
1391
|
-
tag.dataset.pluginCss = tagId$
|
|
1392
|
-
tag.textContent = css$
|
|
1427
|
+
tag.dataset.pluginCss = tagId$7;
|
|
1428
|
+
tag.textContent = css$7;
|
|
1393
1429
|
document.head.appendChild(tag);
|
|
1394
1430
|
}
|
|
1395
1431
|
var SessionStatsChip_module_css_default = {
|
|
@@ -1725,13 +1761,13 @@ window.__ModuleLoader__.load({
|
|
|
1725
1761
|
}
|
|
1726
1762
|
//#endregion
|
|
1727
1763
|
//#region \0dsh-css:D:\Code\dsh-token-usage\src\client\TokenUsageCard.module.css.mjs
|
|
1728
|
-
const css$
|
|
1729
|
-
const tagId$
|
|
1730
|
-
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$
|
|
1764
|
+
const css$6 = "._1bMeTa_card{border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-3);border-radius:12px;list-style:none;transition:border-color .16s,background .16s}._1bMeTa_card:hover{border-color:var(--dsw-alias-label-dimmed)}._1bMeTa_cardOpen{background:var(--dsw-alias-bg-layer-2);border-color:var(--dsw-alias-label-dimmed)}._1bMeTa_header{appearance:none;width:100%;font:inherit;color:inherit;text-align:left;cursor:pointer;background:0 0;border:0;border-radius:12px;align-items:center;gap:12px;padding:14px 16px;display:flex}._1bMeTa_header:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:-2px}._1bMeTa_headText{flex-direction:column;flex:1;gap:4px;min-width:0;display:flex}._1bMeTa_name{color:var(--dsw-alias-label-primary);font-size:15px;font-weight:600;line-height:1.4}._1bMeTa_description{color:var(--dsw-alias-label-tertiary);font-size:13px;line-height:1.5}._1bMeTa_pending{white-space:nowrap;background:var(--dsw-alias-bg-module-platform);color:var(--dsw-alias-label-secondary);border-radius:999px;flex:none;padding:1px 8px;font-size:11px;font-weight:500;line-height:17px}._1bMeTa_chevron{color:var(--dsw-alias-label-tertiary);flex:none;transition:transform .16s}._1bMeTa_chevronOpen{transform:rotate(180deg)}._1bMeTa_body{border-top:1px solid var(--dsw-alias-border-l2);flex-direction:column;gap:10px;margin:0 16px;padding:12px 0 8px;display:flex}._1bMeTa_note{color:var(--dsw-alias-label-tertiary);margin:0;font-size:12px;line-height:1.5}._1bMeTa_field{flex-direction:column;gap:4px;display:flex}._1bMeTa_fieldLabel{color:var(--dsw-alias-label-secondary);font-size:12px;line-height:1.5}._1bMeTa_input{box-sizing:border-box;width:100%;font:inherit;color:var(--dsw-alias-label-primary);background-color:var(--dsw-alias-bg-layer-2);border:1px solid var(--dsw-alias-border-l2);appearance:none;border-radius:6px;padding:4px 8px;font-size:13px;line-height:20px}._1bMeTa_input:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:-1px}._1bMeTa_input:disabled{opacity:.6}._1bMeTa_inputRow{align-items:center;gap:6px;display:flex}._1bMeTa_inputRow ._1bMeTa_input{flex:1;min-width:0}._1bMeTa_browse{appearance:none;border:1px solid var(--dsw-alias-border-l2);font:inherit;color:var(--dsw-alias-label-secondary);cursor:pointer;white-space:nowrap;background:0 0;border-radius:6px;flex:none;padding:4px 10px;font-size:13px;line-height:20px}._1bMeTa_browse:hover:not(:disabled){color:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-label-dimmed)}._1bMeTa_browse:disabled{opacity:.4;cursor:default}._1bMeTa_browse:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:1px}._1bMeTa_hint{color:var(--dsw-alias-label-tertiary);margin:0;font-size:12px;line-height:1.5}._1bMeTa_migration{border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-2);border-radius:6px;flex-direction:column;gap:4px;padding:8px 10px;display:flex}._1bMeTa_migrationLabel{color:var(--dsw-alias-label-secondary);font-variant-numeric:tabular-nums;font-size:12px;line-height:1.5}._1bMeTa_migrationBar{background:var(--dsw-alias-bg-multi-select);border-radius:2px;height:4px;display:block;overflow:hidden}._1bMeTa_migrationFill{background:var(--dsw-alias-brand-primary);border-radius:2px;height:100%;transition:width .2s;display:block}._1bMeTa_footer{border-top:1px solid var(--dsw-alias-border-l2);justify-content:flex-end;align-items:center;gap:8px;padding:8px 0 4px;display:flex}._1bMeTa_failed{min-width:0;color:var(--dsw-alias-label-error);flex:1;margin:0;font-size:12px;line-height:1.5}._1bMeTa_discard,._1bMeTa_save{appearance:none;font:inherit;cursor:pointer;border:1px solid #0000;border-radius:8px;padding:5px 14px;font-size:13px;line-height:1.5}._1bMeTa_discard{border-color:var(--dsw-alias-border-l2);color:var(--dsw-alias-label-secondary);background:0 0}._1bMeTa_discard:hover:not(:disabled){color:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-label-dimmed)}._1bMeTa_save{background:var(--dsw-alias-label-primary);color:var(--dsw-alias-bg-layer-3)}._1bMeTa_discard:disabled,._1bMeTa_save:disabled{opacity:.4;cursor:default}._1bMeTa_discard:focus-visible,._1bMeTa_save:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:1px}._1bMeTa_fullSync{border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-2);border-radius:8px;flex-direction:column;gap:8px;padding:10px 12px;display:flex}._1bMeTa_fullSyncHeader{flex-direction:column;gap:2px;display:flex}._1bMeTa_fullSyncTitle{color:var(--dsw-alias-label-primary);font-size:13px;font-weight:600;line-height:1.4}._1bMeTa_fullSyncHint{color:var(--dsw-alias-label-tertiary);font-size:12px;line-height:1.5}._1bMeTa_fullSyncButton{appearance:none;border:1px solid var(--dsw-alias-border-l2);font:inherit;color:var(--dsw-alias-label-secondary);cursor:pointer;white-space:nowrap;background:0 0;border-radius:6px;align-self:flex-start;padding:4px 12px;font-size:13px;line-height:20px}._1bMeTa_fullSyncButton:hover:not(:disabled){color:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-label-dimmed)}._1bMeTa_fullSyncButton:disabled{opacity:.5;cursor:default}._1bMeTa_fullSyncButton:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:1px}._1bMeTa_fullSyncProgress{flex-direction:column;gap:4px;display:flex}._1bMeTa_fullSyncProgressLabel{color:var(--dsw-alias-label-secondary);font-variant-numeric:tabular-nums;font-size:12px;line-height:1.5}._1bMeTa_fullSyncBar{background:var(--dsw-alias-bg-multi-select);border-radius:2px;height:4px;display:block;overflow:hidden}._1bMeTa_fullSyncFill{background:var(--dsw-alias-brand-primary);border-radius:2px;height:100%;transition:width .2s;display:block}._1bMeTa_fullSyncResult{color:var(--dsw-alias-label-secondary);font-variant-numeric:tabular-nums;margin:0;font-size:12px;line-height:1.5}._1bMeTa_fullSyncError{color:var(--dsw-alias-label-error);margin:0;font-size:12px;line-height:1.5}";
|
|
1765
|
+
const tagId$6 = "@laoyuehanni/dsh-token-usage/TokenUsageCard.module.css";
|
|
1766
|
+
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$6) + "]") === null) {
|
|
1731
1767
|
const tag = document.createElement("style");
|
|
1732
1768
|
tag.dataset.plugin = "@laoyuehanni/dsh-token-usage";
|
|
1733
|
-
tag.dataset.pluginCss = tagId$
|
|
1734
|
-
tag.textContent = css$
|
|
1769
|
+
tag.dataset.pluginCss = tagId$6;
|
|
1770
|
+
tag.textContent = css$6;
|
|
1735
1771
|
document.head.appendChild(tag);
|
|
1736
1772
|
}
|
|
1737
1773
|
var TokenUsageCard_module_css_default = {
|
|
@@ -2095,6 +2131,411 @@ window.__ModuleLoader__.load({
|
|
|
2095
2131
|
});
|
|
2096
2132
|
}
|
|
2097
2133
|
//#endregion
|
|
2134
|
+
//#region \0dsh-css:D:\Code\dsh-token-usage\src\client\DateRangePicker.module.css.mjs
|
|
2135
|
+
const css$5 = ".aSiNOq_wrapper{flex:none;display:inline-flex;position:relative}.aSiNOq_trigger{box-sizing:border-box;font-variant-numeric:tabular-nums;color:var(--dsw-alias-label-primary);background-color:var(--dsw-alias-bg-layer-2);border:1px solid var(--dsw-alias-border-l2);cursor:pointer;white-space:nowrap;border-radius:6px;flex:none;padding:4px 10px;font-size:13px;line-height:20px}.aSiNOq_trigger:hover,.aSiNOq_trigger[aria-expanded=true]{background:var(--dsw-alias-interactive-bg-hover)}.aSiNOq_panel{z-index:100;box-sizing:border-box;border:1px solid var(--dsw-alias-border-inverted);background:var(--dsw-specific-menu);width:266px;max-width:calc(100vw - 32px);box-shadow:var(--dsw-shadow-lv3);color:var(--dsw-alias-label-secondary);text-align:left;cursor:default;border-radius:12px;padding:10px;font-size:12px;line-height:20px;position:absolute;top:calc(100% + 6px);left:0}.aSiNOq_head{justify-content:space-between;align-items:center;gap:4px;margin-bottom:6px;display:flex}.aSiNOq_nav{width:24px;height:24px;color:var(--dsw-alias-label-secondary);cursor:pointer;background:0 0;border:none;border-radius:6px;flex:none;padding:0;font-size:14px;line-height:1}.aSiNOq_nav:hover{color:var(--dsw-alias-label-primary);background:var(--dsw-alias-interactive-bg-hover)}.aSiNOq_monthTitle{color:var(--dsw-alias-label-primary);font-variant-numeric:tabular-nums;font-size:13px;font-weight:500}.aSiNOq_weekdays,.aSiNOq_grid{grid-template-columns:repeat(7,1fr);gap:2px;display:grid}.aSiNOq_weekday{text-align:center;color:var(--dsw-alias-label-tertiary);font-size:11px;line-height:16px}.aSiNOq_blank{visibility:hidden;height:26px}.aSiNOq_day{font-variant-numeric:tabular-nums;text-align:center;height:26px;color:var(--dsw-alias-label-primary);cursor:pointer;background:0 0;border:none;border-radius:6px;padding:0;font-size:12px;line-height:26px}.aSiNOq_day:hover{background:var(--dsw-alias-interactive-bg-hover)}.aSiNOq_dayToday{box-shadow:inset 0 0 0 1px var(--dsw-alias-border-l2)}.aSiNOq_dayAnchor,.aSiNOq_daySelected{color:var(--dsw-alias-brand-primary);box-shadow:inset 0 0 0 1px var(--dsw-alias-brand-primary);font-weight:600}.aSiNOq_dayInRange{background:var(--dsw-alias-interactive-bg-hover);border-radius:0}.aSiNOq_foot{border-top:1px solid var(--dsw-alias-border-l1);justify-content:flex-end;margin-top:8px;padding-top:8px;display:flex}.aSiNOq_clear{color:var(--dsw-alias-label-secondary);cursor:pointer;background:0 0;border:none;border-radius:6px;padding:2px 8px;font-size:12px;line-height:18px}.aSiNOq_clear:hover{color:var(--dsw-alias-label-primary);background:var(--dsw-alias-interactive-bg-hover)}";
|
|
2136
|
+
const tagId$5 = "@laoyuehanni/dsh-token-usage/DateRangePicker.module.css";
|
|
2137
|
+
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$5) + "]") === null) {
|
|
2138
|
+
const tag = document.createElement("style");
|
|
2139
|
+
tag.dataset.plugin = "@laoyuehanni/dsh-token-usage";
|
|
2140
|
+
tag.dataset.pluginCss = tagId$5;
|
|
2141
|
+
tag.textContent = css$5;
|
|
2142
|
+
document.head.appendChild(tag);
|
|
2143
|
+
}
|
|
2144
|
+
var DateRangePicker_module_css_default = {
|
|
2145
|
+
"blank": "aSiNOq_blank",
|
|
2146
|
+
"clear": "aSiNOq_clear",
|
|
2147
|
+
"day": "aSiNOq_day",
|
|
2148
|
+
"dayAnchor": "aSiNOq_dayAnchor",
|
|
2149
|
+
"dayInRange": "aSiNOq_dayInRange",
|
|
2150
|
+
"daySelected": "aSiNOq_daySelected",
|
|
2151
|
+
"dayToday": "aSiNOq_dayToday",
|
|
2152
|
+
"foot": "aSiNOq_foot",
|
|
2153
|
+
"grid": "aSiNOq_grid",
|
|
2154
|
+
"head": "aSiNOq_head",
|
|
2155
|
+
"monthTitle": "aSiNOq_monthTitle",
|
|
2156
|
+
"nav": "aSiNOq_nav",
|
|
2157
|
+
"panel": "aSiNOq_panel",
|
|
2158
|
+
"trigger": "aSiNOq_trigger",
|
|
2159
|
+
"weekday": "aSiNOq_weekday",
|
|
2160
|
+
"weekdays": "aSiNOq_weekdays",
|
|
2161
|
+
"wrapper": "aSiNOq_wrapper"
|
|
2162
|
+
};
|
|
2163
|
+
//#endregion
|
|
2164
|
+
//#region src/client/DateRangePicker.tsx
|
|
2165
|
+
/**
|
|
2166
|
+
* Range date picker (browser half): the filter bar's single date control —
|
|
2167
|
+
* one trigger showing the active day range plus a lightweight calendar
|
|
2168
|
+
* popover. The range is picked with two clicks: the first lands an anchor
|
|
2169
|
+
* (start or end, order does not matter), the second settles the range
|
|
2170
|
+
* (min/max sorted); month navigation keeps the anchor, so a range may span
|
|
2171
|
+
* months (navigate, click, navigate back, click). While an anchor is live,
|
|
2172
|
+
* hovering previews the pending range; Escape or an outside pointerdown
|
|
2173
|
+
* closes the popover and DISCARDS the unfinished anchor (the committed
|
|
2174
|
+
* filters never change on cancel). A clear affordance releases the range
|
|
2175
|
+
* back to unconstrained — the capability the two native date inputs it
|
|
2176
|
+
* replaces carried.
|
|
2177
|
+
*
|
|
2178
|
+
* The popover interaction copies QuotaButton's pattern verbatim (click
|
|
2179
|
+
* toggles, document pointerdown outside closes, Escape closes); the plate
|
|
2180
|
+
* styling mirrors its panel (menu background, inverted border, shadow,
|
|
2181
|
+
* z-index 100).
|
|
2182
|
+
*
|
|
2183
|
+
* @module token-usage/client/DateRangePicker
|
|
2184
|
+
*/
|
|
2185
|
+
/** Monday-first weekday header keys (index 0 = Monday). */
|
|
2186
|
+
const WEEKDAY_KEYS = [
|
|
2187
|
+
"calendar.weekday.0",
|
|
2188
|
+
"calendar.weekday.1",
|
|
2189
|
+
"calendar.weekday.2",
|
|
2190
|
+
"calendar.weekday.3",
|
|
2191
|
+
"calendar.weekday.4",
|
|
2192
|
+
"calendar.weekday.5",
|
|
2193
|
+
"calendar.weekday.6"
|
|
2194
|
+
];
|
|
2195
|
+
/** The month view the popover opens on: the range end, else its start, else today. */
|
|
2196
|
+
function initialView(from, to) {
|
|
2197
|
+
return monthViewOf(to !== "" ? to : from !== "" ? from : dayKeyOf(/* @__PURE__ */ new Date()));
|
|
2198
|
+
}
|
|
2199
|
+
/**
|
|
2200
|
+
* Render the trigger + calendar popover.
|
|
2201
|
+
* @param props - the committed range, the change lift, and the locale seat.
|
|
2202
|
+
* @returns the inline wrapper holding the trigger and, while open, the panel.
|
|
2203
|
+
*/
|
|
2204
|
+
function DateRangePicker({ from, to, onChange, t }) {
|
|
2205
|
+
const rootRef = (0, react.useRef)(null);
|
|
2206
|
+
const [open, setOpen] = (0, react.useState)(false);
|
|
2207
|
+
const [view, setView] = (0, react.useState)(() => initialView(from, to));
|
|
2208
|
+
const [anchor, setAnchor] = (0, react.useState)(null);
|
|
2209
|
+
const [hovered, setHovered] = (0, react.useState)(null);
|
|
2210
|
+
const closePanel = () => {
|
|
2211
|
+
setOpen(false);
|
|
2212
|
+
setAnchor(null);
|
|
2213
|
+
setHovered(null);
|
|
2214
|
+
};
|
|
2215
|
+
const openPanel = () => {
|
|
2216
|
+
setView(initialView(from, to));
|
|
2217
|
+
setAnchor(null);
|
|
2218
|
+
setHovered(null);
|
|
2219
|
+
setOpen(true);
|
|
2220
|
+
};
|
|
2221
|
+
(0, react.useEffect)(() => {
|
|
2222
|
+
if (!open) return;
|
|
2223
|
+
const onPointerDown = (event) => {
|
|
2224
|
+
if (event.target instanceof Node && rootRef.current?.contains(event.target) === true) return;
|
|
2225
|
+
closePanel();
|
|
2226
|
+
};
|
|
2227
|
+
const onKeyDown = (event) => {
|
|
2228
|
+
if (event.key === "Escape") closePanel();
|
|
2229
|
+
};
|
|
2230
|
+
document.addEventListener("pointerdown", onPointerDown);
|
|
2231
|
+
document.addEventListener("keydown", onKeyDown);
|
|
2232
|
+
return () => {
|
|
2233
|
+
document.removeEventListener("pointerdown", onPointerDown);
|
|
2234
|
+
document.removeEventListener("keydown", onKeyDown);
|
|
2235
|
+
};
|
|
2236
|
+
}, [open]);
|
|
2237
|
+
const pickDay = (day) => {
|
|
2238
|
+
if (anchor === null) {
|
|
2239
|
+
setAnchor(day);
|
|
2240
|
+
return;
|
|
2241
|
+
}
|
|
2242
|
+
const lo = anchor < day ? anchor : day;
|
|
2243
|
+
const hi = anchor < day ? day : anchor;
|
|
2244
|
+
closePanel();
|
|
2245
|
+
onChange({
|
|
2246
|
+
from: lo,
|
|
2247
|
+
to: hi
|
|
2248
|
+
});
|
|
2249
|
+
};
|
|
2250
|
+
const clear = () => {
|
|
2251
|
+
closePanel();
|
|
2252
|
+
onChange({
|
|
2253
|
+
from: "",
|
|
2254
|
+
to: ""
|
|
2255
|
+
});
|
|
2256
|
+
};
|
|
2257
|
+
const shown = anchor !== null ? {
|
|
2258
|
+
from: hovered !== null && hovered < anchor ? hovered : anchor,
|
|
2259
|
+
to: hovered !== null && hovered > anchor ? hovered : anchor
|
|
2260
|
+
} : {
|
|
2261
|
+
from,
|
|
2262
|
+
to
|
|
2263
|
+
};
|
|
2264
|
+
const today = dayKeyOf(/* @__PURE__ */ new Date());
|
|
2265
|
+
const summary = from !== "" && to !== "" ? `${from} ${t("filter.separator")} ${to}` : from !== "" ? from : to !== "" ? to : t("filter.allDates");
|
|
2266
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
2267
|
+
ref: rootRef,
|
|
2268
|
+
className: DateRangePicker_module_css_default["wrapper"],
|
|
2269
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2270
|
+
type: "button",
|
|
2271
|
+
className: DateRangePicker_module_css_default["trigger"],
|
|
2272
|
+
"aria-label": t("filter.dateRange"),
|
|
2273
|
+
"aria-expanded": open,
|
|
2274
|
+
onClick: () => {
|
|
2275
|
+
(open ? closePanel : openPanel)();
|
|
2276
|
+
},
|
|
2277
|
+
children: summary
|
|
2278
|
+
}), open ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2279
|
+
className: DateRangePicker_module_css_default["panel"],
|
|
2280
|
+
role: "dialog",
|
|
2281
|
+
"aria-label": t("filter.dateRange"),
|
|
2282
|
+
children: [
|
|
2283
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2284
|
+
className: DateRangePicker_module_css_default["head"],
|
|
2285
|
+
children: [
|
|
2286
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2287
|
+
type: "button",
|
|
2288
|
+
className: DateRangePicker_module_css_default["nav"],
|
|
2289
|
+
"aria-label": t("calendar.prevMonth"),
|
|
2290
|
+
onClick: () => {
|
|
2291
|
+
setView(shiftMonth(view, -1));
|
|
2292
|
+
},
|
|
2293
|
+
children: "‹"
|
|
2294
|
+
}),
|
|
2295
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2296
|
+
className: DateRangePicker_module_css_default["monthTitle"],
|
|
2297
|
+
children: t("calendar.monthTitle", {
|
|
2298
|
+
year: String(view.year),
|
|
2299
|
+
month: String(view.month + 1)
|
|
2300
|
+
})
|
|
2301
|
+
}),
|
|
2302
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2303
|
+
type: "button",
|
|
2304
|
+
className: DateRangePicker_module_css_default["nav"],
|
|
2305
|
+
"aria-label": t("calendar.nextMonth"),
|
|
2306
|
+
onClick: () => {
|
|
2307
|
+
setView(shiftMonth(view, 1));
|
|
2308
|
+
},
|
|
2309
|
+
children: "›"
|
|
2310
|
+
})
|
|
2311
|
+
]
|
|
2312
|
+
}),
|
|
2313
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2314
|
+
className: DateRangePicker_module_css_default["weekdays"],
|
|
2315
|
+
children: WEEKDAY_KEYS.map((key) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2316
|
+
className: DateRangePicker_module_css_default["weekday"],
|
|
2317
|
+
children: t(key)
|
|
2318
|
+
}, key))
|
|
2319
|
+
}),
|
|
2320
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2321
|
+
className: DateRangePicker_module_css_default["grid"],
|
|
2322
|
+
children: monthGrid(view).map((cell) => {
|
|
2323
|
+
if (!cell.inMonth) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2324
|
+
className: DateRangePicker_module_css_default["blank"],
|
|
2325
|
+
"aria-hidden": "true"
|
|
2326
|
+
}, `blank-${cell.day}`);
|
|
2327
|
+
const classes = [DateRangePicker_module_css_default["day"]];
|
|
2328
|
+
if (cell.day === shown.from || cell.day === shown.to) classes.push(DateRangePicker_module_css_default["daySelected"]);
|
|
2329
|
+
else if (shown.from !== "" && cell.day > shown.from && cell.day < shown.to) classes.push(DateRangePicker_module_css_default["dayInRange"]);
|
|
2330
|
+
if (cell.day === today) classes.push(DateRangePicker_module_css_default["dayToday"]);
|
|
2331
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2332
|
+
type: "button",
|
|
2333
|
+
className: classes.join(" "),
|
|
2334
|
+
"aria-label": cell.day,
|
|
2335
|
+
"aria-pressed": cell.day === shown.from || cell.day === shown.to,
|
|
2336
|
+
"aria-current": cell.day === today ? "date" : void 0,
|
|
2337
|
+
onMouseEnter: () => {
|
|
2338
|
+
setHovered(cell.day);
|
|
2339
|
+
},
|
|
2340
|
+
onMouseLeave: () => {
|
|
2341
|
+
setHovered(null);
|
|
2342
|
+
},
|
|
2343
|
+
onClick: () => {
|
|
2344
|
+
pickDay(cell.day);
|
|
2345
|
+
},
|
|
2346
|
+
children: Number(cell.day.slice(8))
|
|
2347
|
+
}, cell.day);
|
|
2348
|
+
})
|
|
2349
|
+
}),
|
|
2350
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2351
|
+
className: DateRangePicker_module_css_default["foot"],
|
|
2352
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2353
|
+
type: "button",
|
|
2354
|
+
className: DateRangePicker_module_css_default["clear"],
|
|
2355
|
+
onClick: clear,
|
|
2356
|
+
children: t("filter.clear")
|
|
2357
|
+
})
|
|
2358
|
+
})
|
|
2359
|
+
]
|
|
2360
|
+
}) : null]
|
|
2361
|
+
});
|
|
2362
|
+
}
|
|
2363
|
+
//#endregion
|
|
2364
|
+
//#region \0dsh-css:D:\Code\dsh-token-usage\src\client\MenuSelect.module.css.mjs
|
|
2365
|
+
const css$4 = ".KUIXpG_wrapper{display:inline-flex;position:relative}.KUIXpG_trigger{box-sizing:border-box;color:var(--dsw-alias-label-primary);background-color:var(--dsw-alias-bg-layer-2);border:1px solid var(--dsw-alias-border-l2);cursor:pointer;white-space:nowrap;text-overflow:ellipsis;background-image:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none'%3E%3Cpath d='M3 4.5L6 7.5L9 4.5' stroke='%2381858C' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E/%3C/svg%3E\");background-position:right 6px center;background-repeat:no-repeat;background-size:12px 12px;border-radius:6px;flex:none;padding:4px 24px 4px 8px;font-size:13px;line-height:20px;overflow:hidden}.KUIXpG_trigger:hover,.KUIXpG_trigger[aria-expanded=true]{background-color:var(--dsw-alias-interactive-bg-hover)}.KUIXpG_grow{flex:0 auto;min-width:0;max-width:220px}.KUIXpG_panel{z-index:100;box-sizing:border-box;border:1px solid var(--dsw-alias-border-inverted);background:var(--dsw-specific-menu);min-width:100%;max-width:260px;max-height:240px;box-shadow:var(--dsw-shadow-lv3);color:var(--dsw-alias-label-secondary);text-align:left;cursor:default;border-radius:12px;padding:6px;font-size:13px;line-height:20px;position:absolute;top:calc(100% + 6px);left:0;overflow-y:auto}.KUIXpG_option{width:100%;color:var(--dsw-alias-label-primary);cursor:pointer;white-space:nowrap;background:0 0;border:none;border-radius:6px;justify-content:space-between;align-items:center;gap:12px;padding:4px 8px;font-size:13px;line-height:20px;display:flex}.KUIXpG_option:hover{background:var(--dsw-alias-interactive-bg-hover)}.KUIXpG_optionLabel{text-overflow:ellipsis;overflow:hidden}.KUIXpG_optionSelected{color:var(--dsw-alias-brand-primary)}.KUIXpG_check{color:var(--dsw-alias-brand-primary);flex:none}";
|
|
2366
|
+
const tagId$4 = "@laoyuehanni/dsh-token-usage/MenuSelect.module.css";
|
|
2367
|
+
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$4) + "]") === null) {
|
|
2368
|
+
const tag = document.createElement("style");
|
|
2369
|
+
tag.dataset.plugin = "@laoyuehanni/dsh-token-usage";
|
|
2370
|
+
tag.dataset.pluginCss = tagId$4;
|
|
2371
|
+
tag.textContent = css$4;
|
|
2372
|
+
document.head.appendChild(tag);
|
|
2373
|
+
}
|
|
2374
|
+
var MenuSelect_module_css_default = {
|
|
2375
|
+
"check": "KUIXpG_check",
|
|
2376
|
+
"grow": "KUIXpG_grow",
|
|
2377
|
+
"option": "KUIXpG_option",
|
|
2378
|
+
"optionLabel": "KUIXpG_optionLabel",
|
|
2379
|
+
"optionSelected": "KUIXpG_optionSelected",
|
|
2380
|
+
"panel": "KUIXpG_panel",
|
|
2381
|
+
"trigger": "KUIXpG_trigger",
|
|
2382
|
+
"wrapper": "KUIXpG_wrapper"
|
|
2383
|
+
};
|
|
2384
|
+
//#endregion
|
|
2385
|
+
//#region src/client/MenuSelect.tsx
|
|
2386
|
+
/**
|
|
2387
|
+
* Menu select (browser half): the filter bar's themed dropdown — one
|
|
2388
|
+
* trigger button plus a menu popover. It replaces the native `<select>`,
|
|
2389
|
+
* whose UA-painted option list ignores every design token (the shell sets
|
|
2390
|
+
* no color-scheme on plugin content, so it renders unthemed), and pairs
|
|
2391
|
+
* with the DateRangePicker so all three filter controls share one popover
|
|
2392
|
+
* language.
|
|
2393
|
+
*
|
|
2394
|
+
* Keyboard follows the listbox idiom: opening (trigger click, Enter, or
|
|
2395
|
+
* its arrow keys) lands focus on the SELECTED option — scrolled to the
|
|
2396
|
+
* center like the native select — or the first one; ArrowUp/Down and
|
|
2397
|
+
* Home/End roam (options are tabIndex -1, so Tab skips the list);
|
|
2398
|
+
* Enter/Space commits the focused row; Escape closes and returns focus
|
|
2399
|
+
* to the trigger; committing closes and refocuses the trigger too. An
|
|
2400
|
+
* outside pointerdown closes without stealing focus. The option list
|
|
2401
|
+
* carries listbox/option semantics with the selection marked
|
|
2402
|
+
* (aria-selected plus a check).
|
|
2403
|
+
*
|
|
2404
|
+
* The popover interaction copies QuotaButton's pattern verbatim (click
|
|
2405
|
+
* toggles, document pointerdown outside closes, Escape closes); the plate
|
|
2406
|
+
* styling mirrors the date-range picker's panel.
|
|
2407
|
+
*
|
|
2408
|
+
* @module token-usage/client/MenuSelect
|
|
2409
|
+
*/
|
|
2410
|
+
/**
|
|
2411
|
+
* Render the trigger + menu popover.
|
|
2412
|
+
* @param props - the committed value, options, name, and change lift.
|
|
2413
|
+
* @returns the inline wrapper holding the trigger and, while open, the list.
|
|
2414
|
+
*/
|
|
2415
|
+
function MenuSelect({ value, options, ariaLabel, onChange, grow = false }) {
|
|
2416
|
+
const rootRef = (0, react.useRef)(null);
|
|
2417
|
+
const triggerRef = (0, react.useRef)(null);
|
|
2418
|
+
const optionRefs = (0, react.useRef)([]);
|
|
2419
|
+
const [open, setOpen] = (0, react.useState)(false);
|
|
2420
|
+
const focusIndexRef = (0, react.useRef)(0);
|
|
2421
|
+
const close = () => {
|
|
2422
|
+
setOpen(false);
|
|
2423
|
+
triggerRef.current?.focus();
|
|
2424
|
+
};
|
|
2425
|
+
const openMenu = () => {
|
|
2426
|
+
const selected = options.findIndex((option) => option.value === value);
|
|
2427
|
+
focusIndexRef.current = selected >= 0 ? selected : 0;
|
|
2428
|
+
setOpen(true);
|
|
2429
|
+
};
|
|
2430
|
+
(0, react.useEffect)(() => {
|
|
2431
|
+
if (!open) return;
|
|
2432
|
+
const onPointerDown = (event) => {
|
|
2433
|
+
if (event.target instanceof Node && rootRef.current?.contains(event.target) === true) return;
|
|
2434
|
+
setOpen(false);
|
|
2435
|
+
};
|
|
2436
|
+
const onKeyDown = (event) => {
|
|
2437
|
+
if (event.key === "Escape") close();
|
|
2438
|
+
};
|
|
2439
|
+
document.addEventListener("pointerdown", onPointerDown);
|
|
2440
|
+
document.addEventListener("keydown", onKeyDown);
|
|
2441
|
+
return () => {
|
|
2442
|
+
document.removeEventListener("pointerdown", onPointerDown);
|
|
2443
|
+
document.removeEventListener("keydown", onKeyDown);
|
|
2444
|
+
};
|
|
2445
|
+
}, [open]);
|
|
2446
|
+
(0, react.useEffect)(() => {
|
|
2447
|
+
if (!open) return;
|
|
2448
|
+
const button = optionRefs.current[focusIndexRef.current];
|
|
2449
|
+
if (button === void 0 || button === null) return;
|
|
2450
|
+
button.focus({ preventScroll: true });
|
|
2451
|
+
if (typeof button.scrollIntoView === "function") button.scrollIntoView({ block: "center" });
|
|
2452
|
+
}, [open]);
|
|
2453
|
+
const commit = (index) => {
|
|
2454
|
+
const option = options[index];
|
|
2455
|
+
if (option === void 0) return;
|
|
2456
|
+
close();
|
|
2457
|
+
onChange(option.value);
|
|
2458
|
+
};
|
|
2459
|
+
const moveFocus = (index) => {
|
|
2460
|
+
const next = Math.max(0, Math.min(options.length - 1, index));
|
|
2461
|
+
focusIndexRef.current = next;
|
|
2462
|
+
optionRefs.current[next]?.focus();
|
|
2463
|
+
};
|
|
2464
|
+
const onPanelKeyDown = (event) => {
|
|
2465
|
+
if (event.key === "ArrowDown") {
|
|
2466
|
+
event.preventDefault();
|
|
2467
|
+
moveFocus(focusIndexRef.current + 1);
|
|
2468
|
+
} else if (event.key === "ArrowUp") {
|
|
2469
|
+
event.preventDefault();
|
|
2470
|
+
moveFocus(focusIndexRef.current - 1);
|
|
2471
|
+
} else if (event.key === "Home") {
|
|
2472
|
+
event.preventDefault();
|
|
2473
|
+
moveFocus(0);
|
|
2474
|
+
} else if (event.key === "End") {
|
|
2475
|
+
event.preventDefault();
|
|
2476
|
+
moveFocus(options.length - 1);
|
|
2477
|
+
} else if (event.key === "Enter" || event.key === " ") {
|
|
2478
|
+
event.preventDefault();
|
|
2479
|
+
commit(focusIndexRef.current);
|
|
2480
|
+
}
|
|
2481
|
+
};
|
|
2482
|
+
const onTriggerKeyDown = (event) => {
|
|
2483
|
+
if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
|
2484
|
+
event.preventDefault();
|
|
2485
|
+
if (!open) openMenu();
|
|
2486
|
+
}
|
|
2487
|
+
};
|
|
2488
|
+
const selected = options.find((option) => option.value === value);
|
|
2489
|
+
const triggerClass = [MenuSelect_module_css_default["trigger"], grow === true ? MenuSelect_module_css_default["grow"] : ""].join(" ").trim();
|
|
2490
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
2491
|
+
ref: rootRef,
|
|
2492
|
+
className: MenuSelect_module_css_default["wrapper"],
|
|
2493
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2494
|
+
type: "button",
|
|
2495
|
+
ref: triggerRef,
|
|
2496
|
+
className: triggerClass,
|
|
2497
|
+
"aria-label": ariaLabel,
|
|
2498
|
+
"aria-expanded": open,
|
|
2499
|
+
"aria-haspopup": "listbox",
|
|
2500
|
+
onClick: () => {
|
|
2501
|
+
open ? close() : openMenu();
|
|
2502
|
+
},
|
|
2503
|
+
onKeyDown: onTriggerKeyDown,
|
|
2504
|
+
children: selected?.label ?? value
|
|
2505
|
+
}), open ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2506
|
+
className: MenuSelect_module_css_default["panel"],
|
|
2507
|
+
role: "listbox",
|
|
2508
|
+
"aria-label": ariaLabel,
|
|
2509
|
+
onKeyDown: onPanelKeyDown,
|
|
2510
|
+
children: options.map((option, index) => {
|
|
2511
|
+
const isSelected = option.value === value;
|
|
2512
|
+
const optionClass = [MenuSelect_module_css_default["option"], isSelected ? MenuSelect_module_css_default["optionSelected"] : ""].join(" ").trim();
|
|
2513
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
2514
|
+
type: "button",
|
|
2515
|
+
role: "option",
|
|
2516
|
+
tabIndex: -1,
|
|
2517
|
+
ref: (element) => {
|
|
2518
|
+
optionRefs.current[index] = element;
|
|
2519
|
+
},
|
|
2520
|
+
className: optionClass,
|
|
2521
|
+
"aria-selected": isSelected,
|
|
2522
|
+
onClick: () => {
|
|
2523
|
+
commit(index);
|
|
2524
|
+
},
|
|
2525
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2526
|
+
className: MenuSelect_module_css_default["optionLabel"],
|
|
2527
|
+
children: option.label
|
|
2528
|
+
}), isSelected ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2529
|
+
className: MenuSelect_module_css_default["check"],
|
|
2530
|
+
"aria-hidden": "true",
|
|
2531
|
+
children: "✓"
|
|
2532
|
+
}) : null]
|
|
2533
|
+
}, option.value);
|
|
2534
|
+
})
|
|
2535
|
+
}) : null]
|
|
2536
|
+
});
|
|
2537
|
+
}
|
|
2538
|
+
//#endregion
|
|
2098
2539
|
//#region \0dsh-css:D:\Code\dsh-token-usage\src\client\StatCard.module.css.mjs
|
|
2099
2540
|
const css$3 = ".F2LbNW_card{border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-fill-container,transparent);border-radius:8px;flex-direction:column;gap:2px;min-width:0;padding:10px 12px;display:flex}.F2LbNW_cardLabel{color:var(--dsw-alias-label-secondary);white-space:nowrap;text-overflow:ellipsis;font-size:11px;overflow:hidden}.F2LbNW_cardValue{font-variant-numeric:tabular-nums;color:var(--dsw-alias-label-primary);white-space:nowrap;text-overflow:ellipsis;font-size:18px;font-weight:600;overflow:hidden}";
|
|
2100
2541
|
const tagId$3 = "@laoyuehanni/dsh-token-usage/StatCard.module.css";
|
|
@@ -2619,7 +3060,7 @@ window.__ModuleLoader__.load({
|
|
|
2619
3060
|
}
|
|
2620
3061
|
//#endregion
|
|
2621
3062
|
//#region \0dsh-css:D:\Code\dsh-token-usage\src\client\TokenUsageSection.module.css.mjs
|
|
2622
|
-
const css$1 = ".RbkiSa_section{flex-direction:column;gap:16px;width:100%;display:flex}.RbkiSa_head{justify-content:space-between;align-items:center;gap:12px;display:flex}.RbkiSa_title{color:var(--dsw-alias-label-primary);margin:0;font-size:16px;font-weight:600}.RbkiSa_muted{color:var(--dsw-alias-label-secondary);margin:0;font-size:12px}.RbkiSa_rateNote{color:var(--dsw-alias-label-secondary);margin:6px 0 0;font-size:12px}.RbkiSa_error{color:var(--dsw-alias-state-error-primary);margin:0;font-size:13px}.RbkiSa_subtitle{color:var(--dsw-alias-label-secondary);margin:0;font-size:14px;font-weight:600}.RbkiSa_tableWrap{
|
|
3063
|
+
const css$1 = ".RbkiSa_section{flex-direction:column;gap:16px;width:100%;display:flex}.RbkiSa_head{justify-content:space-between;align-items:center;gap:12px;display:flex}.RbkiSa_title{color:var(--dsw-alias-label-primary);margin:0;font-size:16px;font-weight:600}.RbkiSa_muted{color:var(--dsw-alias-label-secondary);margin:0;font-size:12px}.RbkiSa_rateNote{color:var(--dsw-alias-label-secondary);margin:6px 0 0;font-size:12px}.RbkiSa_error{color:var(--dsw-alias-state-error-primary);margin:0;font-size:13px}.RbkiSa_subtitle{color:var(--dsw-alias-label-secondary);margin:0;font-size:14px;font-weight:600}.RbkiSa_tableWrap{max-height:420px;overflow:auto}.RbkiSa_table{border-collapse:collapse;font-variant-numeric:tabular-nums;width:100%;min-width:500px;font-size:12px}.RbkiSa_table th,.RbkiSa_table td{text-align:right;border-bottom:1px solid var(--dsw-alias-border-l1);white-space:nowrap;padding:4px 6px}.RbkiSa_table th.RbkiSa_modelHead,.RbkiSa_table td.RbkiSa_modelCol{text-align:left;width:150px;max-width:150px}.RbkiSa_table th{color:var(--dsw-alias-label-secondary);z-index:1;background:var(--dsw-alias-bg-layer-2);font-weight:500;position:sticky;top:0}.RbkiSa_table td{color:var(--dsw-alias-label-primary)}.RbkiSa_empty{color:var(--dsw-alias-label-secondary);margin:0;font-size:13px}.RbkiSa_button{color:var(--dsw-alias-label-primary);background:var(--dsw-alias-bg-layer-2);border:1px solid var(--dsw-alias-border-l2);cursor:pointer;border-radius:6px;padding:4px 12px;font-size:13px;line-height:20px}.RbkiSa_button:hover{background:var(--dsw-interactive-bg-hover)}.RbkiSa_filters{flex-wrap:nowrap;align-items:center;gap:8px;display:flex}.RbkiSa_cards{grid-template-columns:repeat(auto-fit,minmax(110px,1fr));gap:8px;display:grid}.RbkiSa_warning{color:var(--dsw-alias-state-warn-label);background:var(--dsw-alias-state-warn-tertiary);border-radius:6px;margin:0;padding:6px 10px;font-size:12px}.RbkiSa_modelCell{align-items:center;gap:4px;max-width:138px;display:inline-flex;position:relative}.RbkiSa_modelName{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.RbkiSa_unpricedTag{color:var(--dsw-alias-state-warn-label);background:var(--dsw-alias-state-warn-tertiary);border-radius:8px;flex:none;padding:0 6px;font-size:10px;line-height:16px}.RbkiSa_pricingButton{color:var(--dsw-alias-label-secondary);background:var(--dsw-alias-bg-layer-2);border:1px solid var(--dsw-alias-border-l2);cursor:pointer;border-radius:8px;flex:none;padding:0 6px;font-size:10px;line-height:16px}.RbkiSa_pricingButton:hover{color:var(--dsw-alias-state-warn-primary);background:var(--dsw-alias-state-warn-tertiary);border-color:var(--dsw-alias-state-warn-primary)}.RbkiSa_dialog{width:min(600px,100vw - 48px);max-height:calc(100vh - 48px);color:var(--dsw-alias-label-primary);background:var(--dsw-alias-bg-layer-2);border:1px solid var(--dsw-alias-border-l2);border-radius:10px;padding:14px 16px;overflow-y:auto}.RbkiSa_dialog::backdrop{background:#0006}.RbkiSa_dialogHead{justify-content:space-between;align-items:center;gap:12px;margin-bottom:8px;display:flex}.RbkiSa_dialogTitle{text-overflow:ellipsis;white-space:nowrap;font-variant-numeric:tabular-nums;font-size:14px;font-weight:600;overflow:hidden}.RbkiSa_dialogClose{color:var(--dsw-alias-label-secondary);cursor:pointer;background:0 0;border:none;border-radius:6px;flex:none;padding:2px 8px;font-size:12px;line-height:18px}.RbkiSa_dialogClose:hover{color:var(--dsw-alias-label-primary);background:var(--dsw-interactive-bg-hover)}th.RbkiSa_conditionHead,td.RbkiSa_conditionCell{text-align:left;white-space:normal;min-width:200px}td.RbkiSa_conditionCell{color:var(--dsw-alias-label-secondary);padding-left:20px}.RbkiSa_groupRow>td{text-align:left;white-space:normal;color:var(--dsw-alias-label-secondary);border-bottom:none;padding-top:8px;font-size:11px;font-weight:600}.RbkiSa_groupRow:not(:first-child)>td{border-top:1px solid var(--dsw-alias-border-l1)}";
|
|
2623
3064
|
const tagId$1 = "@laoyuehanni/dsh-token-usage/TokenUsageSection.module.css";
|
|
2624
3065
|
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$1) + "]") === null) {
|
|
2625
3066
|
const tag = document.createElement("style");
|
|
@@ -2633,8 +3074,6 @@ window.__ModuleLoader__.load({
|
|
|
2633
3074
|
"cards": "RbkiSa_cards",
|
|
2634
3075
|
"conditionCell": "RbkiSa_conditionCell",
|
|
2635
3076
|
"conditionHead": "RbkiSa_conditionHead",
|
|
2636
|
-
"control": "RbkiSa_control",
|
|
2637
|
-
"dateControl": "RbkiSa_dateControl",
|
|
2638
3077
|
"dialog": "RbkiSa_dialog",
|
|
2639
3078
|
"dialogClose": "RbkiSa_dialogClose",
|
|
2640
3079
|
"dialogHead": "RbkiSa_dialogHead",
|
|
@@ -2646,12 +3085,10 @@ window.__ModuleLoader__.load({
|
|
|
2646
3085
|
"head": "RbkiSa_head",
|
|
2647
3086
|
"modelCell": "RbkiSa_modelCell",
|
|
2648
3087
|
"modelCol": "RbkiSa_modelCol",
|
|
2649
|
-
"modelControl": "RbkiSa_modelControl",
|
|
2650
3088
|
"modelHead": "RbkiSa_modelHead",
|
|
2651
3089
|
"modelName": "RbkiSa_modelName",
|
|
2652
3090
|
"muted": "RbkiSa_muted",
|
|
2653
3091
|
"pricingButton": "RbkiSa_pricingButton",
|
|
2654
|
-
"rangeSeparator": "RbkiSa_rangeSeparator",
|
|
2655
3092
|
"rateNote": "RbkiSa_rateNote",
|
|
2656
3093
|
"section": "RbkiSa_section",
|
|
2657
3094
|
"subtitle": "RbkiSa_subtitle",
|
|
@@ -2703,12 +3140,6 @@ window.__ModuleLoader__.load({
|
|
|
2703
3140
|
if (filters.model !== "") params.set("model", filters.model);
|
|
2704
3141
|
return Array.from(params).length > 0 ? `?${params.toString()}` : "";
|
|
2705
3142
|
}
|
|
2706
|
-
/** Quick-range day span in days (1 = today only, inclusive on both ends). */
|
|
2707
|
-
const QUICK_DAYS = [
|
|
2708
|
-
1,
|
|
2709
|
-
7,
|
|
2710
|
-
30
|
|
2711
|
-
];
|
|
2712
3143
|
/** The day keys of one quick range: today minus (days - 1) through today. */
|
|
2713
3144
|
function quickRange(days) {
|
|
2714
3145
|
return {
|
|
@@ -2872,81 +3303,79 @@ window.__ModuleLoader__.load({
|
|
|
2872
3303
|
})]
|
|
2873
3304
|
});
|
|
2874
3305
|
}
|
|
2875
|
-
/**
|
|
3306
|
+
/** Quick-range menu entries (labels are locale-free day counts). */
|
|
3307
|
+
const QUICK_OPTIONS = [
|
|
3308
|
+
{
|
|
3309
|
+
value: "1",
|
|
3310
|
+
label: "1d"
|
|
3311
|
+
},
|
|
3312
|
+
{
|
|
3313
|
+
value: "7",
|
|
3314
|
+
label: "7d"
|
|
3315
|
+
},
|
|
3316
|
+
{
|
|
3317
|
+
value: "30",
|
|
3318
|
+
label: "30d"
|
|
3319
|
+
}
|
|
3320
|
+
];
|
|
3321
|
+
/** The filter bar: quick range menu, day-range picker popover, model
|
|
3322
|
+
* menu — one row, one popover language. */
|
|
2876
3323
|
function FilterBar({ filters, models, onChange, t }) {
|
|
2877
|
-
const quickValue =
|
|
3324
|
+
const quickValue = QUICK_OPTIONS.find((option) => isQuickActive(Number(option.value), filters))?.value ?? (filters.from === "" && filters.to === "" ? "all" : "custom");
|
|
2878
3325
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2879
3326
|
className: TokenUsageSection_module_css_default["filters"],
|
|
2880
3327
|
children: [
|
|
2881
|
-
/* @__PURE__ */ (0, react_jsx_runtime.
|
|
2882
|
-
|
|
2883
|
-
className: TokenUsageSection_module_css_default["control"],
|
|
3328
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(MenuSelect, {
|
|
3329
|
+
ariaLabel: t("filter.quickRange"),
|
|
2884
3330
|
value: quickValue,
|
|
2885
|
-
|
|
2886
|
-
|
|
3331
|
+
options: [
|
|
3332
|
+
...QUICK_OPTIONS,
|
|
3333
|
+
{
|
|
3334
|
+
value: "all",
|
|
3335
|
+
label: t("filter.allDates")
|
|
3336
|
+
},
|
|
3337
|
+
{
|
|
3338
|
+
value: "custom",
|
|
3339
|
+
label: t("filter.custom")
|
|
3340
|
+
}
|
|
3341
|
+
],
|
|
3342
|
+
onChange: (value) => {
|
|
3343
|
+
if (value === "all") onChange({
|
|
3344
|
+
...filters,
|
|
3345
|
+
from: "",
|
|
3346
|
+
to: ""
|
|
3347
|
+
});
|
|
3348
|
+
const days = Number(value);
|
|
2887
3349
|
if (days > 0) onChange({
|
|
2888
3350
|
...filters,
|
|
2889
3351
|
...quickRange(days)
|
|
2890
3352
|
});
|
|
2891
|
-
}
|
|
2892
|
-
children: [
|
|
2893
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
2894
|
-
value: "1",
|
|
2895
|
-
children: "1d"
|
|
2896
|
-
}),
|
|
2897
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
2898
|
-
value: "7",
|
|
2899
|
-
children: "7d"
|
|
2900
|
-
}),
|
|
2901
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
2902
|
-
value: "30",
|
|
2903
|
-
children: "30d"
|
|
2904
|
-
}),
|
|
2905
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
2906
|
-
value: "custom",
|
|
2907
|
-
children: t("filter.custom")
|
|
2908
|
-
})
|
|
2909
|
-
]
|
|
2910
|
-
}),
|
|
2911
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
2912
|
-
type: "date",
|
|
2913
|
-
"aria-label": t("filter.from"),
|
|
2914
|
-
className: TokenUsageSection_module_css_default["dateControl"],
|
|
2915
|
-
value: filters.from,
|
|
2916
|
-
onChange: (event) => onChange({
|
|
2917
|
-
...filters,
|
|
2918
|
-
from: event.target.value
|
|
2919
|
-
})
|
|
2920
|
-
}),
|
|
2921
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2922
|
-
className: TokenUsageSection_module_css_default["rangeSeparator"],
|
|
2923
|
-
children: t("filter.separator")
|
|
3353
|
+
}
|
|
2924
3354
|
}),
|
|
2925
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
value: filters.to,
|
|
2930
|
-
onChange: (event) => onChange({
|
|
3355
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(DateRangePicker, {
|
|
3356
|
+
from: filters.from,
|
|
3357
|
+
to: filters.to,
|
|
3358
|
+
onChange: (next) => onChange({
|
|
2931
3359
|
...filters,
|
|
2932
|
-
|
|
2933
|
-
})
|
|
3360
|
+
...next
|
|
3361
|
+
}),
|
|
3362
|
+
t
|
|
2934
3363
|
}),
|
|
2935
|
-
/* @__PURE__ */ (0, react_jsx_runtime.
|
|
2936
|
-
|
|
2937
|
-
|
|
3364
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(MenuSelect, {
|
|
3365
|
+
ariaLabel: t("filter.model"),
|
|
3366
|
+
grow: true,
|
|
2938
3367
|
value: filters.model,
|
|
2939
|
-
|
|
2940
|
-
...filters,
|
|
2941
|
-
model: event.target.value
|
|
2942
|
-
}),
|
|
2943
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
3368
|
+
options: [{
|
|
2944
3369
|
value: "",
|
|
2945
|
-
|
|
2946
|
-
}
|
|
3370
|
+
label: t("filter.allModels")
|
|
3371
|
+
}, ...models.map((model) => ({
|
|
2947
3372
|
value: model,
|
|
2948
|
-
|
|
2949
|
-
}
|
|
3373
|
+
label: model
|
|
3374
|
+
}))],
|
|
3375
|
+
onChange: (model) => onChange({
|
|
3376
|
+
...filters,
|
|
3377
|
+
model
|
|
3378
|
+
})
|
|
2950
3379
|
})
|
|
2951
3380
|
]
|
|
2952
3381
|
});
|
|
@@ -3591,11 +4020,22 @@ window.__ModuleLoader__.load({
|
|
|
3591
4020
|
"nav.label": "Token 用量",
|
|
3592
4021
|
"filter.quickRange": "快捷区间",
|
|
3593
4022
|
"filter.custom": "自定义",
|
|
3594
|
-
"filter.
|
|
3595
|
-
"filter.
|
|
4023
|
+
"filter.dateRange": "日期范围",
|
|
4024
|
+
"filter.allDates": "全部日期",
|
|
4025
|
+
"filter.clear": "清除范围",
|
|
3596
4026
|
"filter.separator": "至",
|
|
3597
4027
|
"filter.model": "模型",
|
|
3598
4028
|
"filter.allModels": "全部模型",
|
|
4029
|
+
"calendar.monthTitle": "{year}年{month}月",
|
|
4030
|
+
"calendar.prevMonth": "上个月",
|
|
4031
|
+
"calendar.nextMonth": "下个月",
|
|
4032
|
+
"calendar.weekday.0": "一",
|
|
4033
|
+
"calendar.weekday.1": "二",
|
|
4034
|
+
"calendar.weekday.2": "三",
|
|
4035
|
+
"calendar.weekday.3": "四",
|
|
4036
|
+
"calendar.weekday.4": "五",
|
|
4037
|
+
"calendar.weekday.5": "六",
|
|
4038
|
+
"calendar.weekday.6": "日",
|
|
3599
4039
|
"stat.requests": "请求数",
|
|
3600
4040
|
"stat.totalTokens": "总 token",
|
|
3601
4041
|
"stat.hitRate": "命中率",
|
|
@@ -3700,11 +4140,22 @@ window.__ModuleLoader__.load({
|
|
|
3700
4140
|
"nav.label": "Token Usage",
|
|
3701
4141
|
"filter.quickRange": "Quick range",
|
|
3702
4142
|
"filter.custom": "Custom",
|
|
3703
|
-
"filter.
|
|
3704
|
-
"filter.
|
|
4143
|
+
"filter.dateRange": "Date range",
|
|
4144
|
+
"filter.allDates": "All dates",
|
|
4145
|
+
"filter.clear": "Clear range",
|
|
3705
4146
|
"filter.separator": "to",
|
|
3706
4147
|
"filter.model": "Model",
|
|
3707
4148
|
"filter.allModels": "All models",
|
|
4149
|
+
"calendar.monthTitle": "{month} {year}",
|
|
4150
|
+
"calendar.prevMonth": "Previous month",
|
|
4151
|
+
"calendar.nextMonth": "Next month",
|
|
4152
|
+
"calendar.weekday.0": "Mo",
|
|
4153
|
+
"calendar.weekday.1": "Tu",
|
|
4154
|
+
"calendar.weekday.2": "We",
|
|
4155
|
+
"calendar.weekday.3": "Th",
|
|
4156
|
+
"calendar.weekday.4": "Fr",
|
|
4157
|
+
"calendar.weekday.5": "Sa",
|
|
4158
|
+
"calendar.weekday.6": "Su",
|
|
3708
4159
|
"stat.requests": "Requests",
|
|
3709
4160
|
"stat.totalTokens": "Total",
|
|
3710
4161
|
"stat.hitRate": "Hit %",
|