@mt-gloss/utils 0.0.19 → 0.0.20
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/index.d.ts +1 -1
- package/index.js +89 -79
- package/lib/featureFlags/index.d.ts +1 -1
- package/lib/featureFlags/v1_1_flags.d.ts +24 -0
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { isStatusModeEnabled, v1_1_status_mode, V1_1_STATUS_MODE_ENV } from './lib/featureFlags';
|
|
1
|
+
export { isStatusModeEnabled, v1_1_status_mode, V1_1_STATUS_MODE_ENV, isEdgeHoverResizeEnabled, v1_1_edge_hover_resize, V1_1_EDGE_HOVER_RESIZE_ENV } from './lib/featureFlags';
|
|
2
2
|
export type { PresetDefinition, MarketPreset, DateRange, MarketEvent } from './lib/types';
|
|
3
3
|
export { formatValue, getValueFontSize } from './lib/formatValue';
|
|
4
4
|
export type { FormatValueOptions, FormattedValue } from './lib/formatValue';
|
package/index.js
CHANGED
|
@@ -1,99 +1,109 @@
|
|
|
1
|
-
import { D as
|
|
2
|
-
const
|
|
3
|
-
function
|
|
4
|
-
return typeof globalThis < "u" && globalThis.__GLOSS_FLAGS__?.v1_1_status_mode === !0 ? !0 : typeof process < "u" && process.env ? process.env[
|
|
1
|
+
import { D as v, y as F, P as I, n as O, o as U, R as V, T as b, d as A, t as N, f as Y, b as G, k as z, l as k, c as H, h as Z, x, g as B, q as C, j as K, m as X, u as j, i as q, v as W, p as J, a as Q, r as w, s as ee, e as te, w as ne } from "./formatting-dHqp6ksD.js";
|
|
2
|
+
const l = "NEXT_PUBLIC_V1_1_STATUS_MODE";
|
|
3
|
+
function _() {
|
|
4
|
+
return typeof globalThis < "u" && globalThis.__GLOSS_FLAGS__?.v1_1_status_mode === !0 ? !0 : typeof process < "u" && process.env ? process.env[l] === "true" : !1;
|
|
5
5
|
}
|
|
6
|
-
const
|
|
7
|
-
env:
|
|
8
|
-
check:
|
|
6
|
+
const $ = {
|
|
7
|
+
env: l,
|
|
8
|
+
check: _
|
|
9
|
+
}, f = "NEXT_PUBLIC_V1_1_EDGE_HOVER_RESIZE";
|
|
10
|
+
function D() {
|
|
11
|
+
return typeof globalThis < "u" && globalThis.__GLOSS_FLAGS__?.v1_1_edge_hover_resize === !0 ? !0 : typeof process < "u" && process.env ? process.env[f] === "true" : !1;
|
|
12
|
+
}
|
|
13
|
+
const S = {
|
|
14
|
+
env: f,
|
|
15
|
+
check: D
|
|
9
16
|
};
|
|
10
|
-
function
|
|
11
|
-
if (
|
|
12
|
-
const
|
|
13
|
-
return { display:
|
|
17
|
+
function m(e, { prefix: t = "", suffix: n = "", abbreviated: a = !0, kThreshold: s = 1e3 } = {}) {
|
|
18
|
+
if (e == null) {
|
|
19
|
+
const c = t ? `${t} —${n}` : `—${n}`;
|
|
20
|
+
return { display: c.trim(), full: c.trim(), length: c.trim().length };
|
|
14
21
|
}
|
|
15
|
-
const
|
|
16
|
-
if (isNaN(
|
|
17
|
-
const
|
|
18
|
-
return { display:
|
|
22
|
+
const r = typeof e == "number" ? e : parseFloat(String(e).replace(/,/g, ""));
|
|
23
|
+
if (isNaN(r)) {
|
|
24
|
+
const u = `${t}${e}${n}`;
|
|
25
|
+
return { display: u, full: u, length: u.length };
|
|
19
26
|
}
|
|
20
27
|
let o;
|
|
21
|
-
|
|
22
|
-
const i = `${
|
|
23
|
-
return { display: i, full:
|
|
28
|
+
a !== !1 && Math.abs(r) >= 1e6 ? o = (r / 1e6).toFixed(1).replace(/\.0$/, "") + "M" : a !== !1 && Math.abs(r) >= s ? o = (r / 1e3).toFixed(1).replace(/\.0$/, "") + "K" : o = r.toLocaleString("en-US");
|
|
29
|
+
const i = `${t}${o}${n}`, g = `${t}${r.toLocaleString("en-US")}${n}`;
|
|
30
|
+
return { display: i, full: g, length: i.length };
|
|
24
31
|
}
|
|
25
|
-
function
|
|
26
|
-
return (
|
|
32
|
+
function h(e, t) {
|
|
33
|
+
return (t ?? 1) >= 2 ? e <= 4 || e <= 6 ? 30 : e <= 8 ? 24 : 20 : e <= 5 ? 28 : e <= 8 ? 20 : 17;
|
|
27
34
|
}
|
|
28
|
-
function
|
|
29
|
-
if (
|
|
35
|
+
function E(e) {
|
|
36
|
+
if (e == null || e === 0)
|
|
30
37
|
return { text: "0%", direction: "flat" };
|
|
31
|
-
const
|
|
32
|
-
return { text: n >= 3 ? `${Math.round(n)}%` : `${n.toFixed(1)}%`, direction:
|
|
38
|
+
const t = e > 0 ? "up" : e < 0 ? "down" : "flat", n = Math.abs(e);
|
|
39
|
+
return { text: n >= 3 ? `${Math.round(n)}%` : `${n.toFixed(1)}%`, direction: t };
|
|
33
40
|
}
|
|
34
|
-
function
|
|
35
|
-
if (!
|
|
36
|
-
const n =
|
|
37
|
-
return
|
|
41
|
+
function d(e, t) {
|
|
42
|
+
if (!e || !t) return "";
|
|
43
|
+
const n = e.toLocaleDateString("en-US", { month: "short" }), a = t.toLocaleDateString("en-US", { month: "short" }), s = e.getDate(), r = t.getDate(), o = e.getFullYear(), i = t.getFullYear();
|
|
44
|
+
return e.getTime() === t.getTime() || n === a && s === r && o === i ? `${n} ${s}, ${o}` : n === a && o === i ? `${n} ${s}–${r}` : o === i ? `${n} ${s} – ${a} ${r}` : `${n} ${s}, ${o} – ${a} ${r}, ${i}`;
|
|
38
45
|
}
|
|
39
|
-
function
|
|
40
|
-
const n =
|
|
41
|
-
return n ===
|
|
46
|
+
function p(e, t) {
|
|
47
|
+
const n = e.toLocaleDateString("en-US", { month: "short" }), a = t.toLocaleDateString("en-US", { month: "short" }), s = e.getDate(), r = t.getDate();
|
|
48
|
+
return n === a ? `${n} ${s}–${r}` : `${n} ${s} – ${a} ${r}`;
|
|
42
49
|
}
|
|
43
|
-
function
|
|
44
|
-
return !
|
|
50
|
+
function T(e, t = /* @__PURE__ */ new Date()) {
|
|
51
|
+
return !e?.startDate || !e?.endDate ? !1 : t >= e.startDate && t <= e.endDate;
|
|
45
52
|
}
|
|
46
|
-
function
|
|
47
|
-
return !
|
|
53
|
+
function P(e, t) {
|
|
54
|
+
return !e || !t ? !1 : e.getFullYear() === t.getFullYear() && e.getMonth() === t.getMonth() && e.getDate() === t.getDate();
|
|
48
55
|
}
|
|
49
|
-
function
|
|
50
|
-
if (!
|
|
51
|
-
const
|
|
52
|
-
return
|
|
56
|
+
function R(e, t, n) {
|
|
57
|
+
if (!e || !t || !n) return !1;
|
|
58
|
+
const a = e.getTime(), s = t.getTime(), r = n.getTime();
|
|
59
|
+
return a >= Math.min(s, r) && a <= Math.max(s, r);
|
|
53
60
|
}
|
|
54
|
-
function
|
|
61
|
+
function M() {
|
|
55
62
|
return `custom-${Date.now()}-${Math.random().toString(36).substring(2, 11)}`;
|
|
56
63
|
}
|
|
57
64
|
export {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
65
|
+
v as DEFAULT_MARKET_PRESETS,
|
|
66
|
+
F as DEFAULT_PINNED,
|
|
67
|
+
I as PERIOD_OPTIONS,
|
|
68
|
+
O as PRESET_ID_MAP,
|
|
69
|
+
U as PRESET_ID_REVERSE_MAP,
|
|
70
|
+
V as ROLLING_OPTIONS,
|
|
71
|
+
b as TODAY_PRESET,
|
|
72
|
+
f as V1_1_EDGE_HOVER_RESIZE_ENV,
|
|
73
|
+
l as V1_1_STATUS_MODE_ENV,
|
|
74
|
+
A as detectPreset,
|
|
75
|
+
N as findPreset,
|
|
76
|
+
d as formatDateRange,
|
|
77
|
+
Y as formatDateRangeSmart,
|
|
78
|
+
G as formatDateRangeWithPreset,
|
|
79
|
+
z as formatDuration,
|
|
80
|
+
p as formatMarketDates,
|
|
81
|
+
k as formatPreset,
|
|
82
|
+
H as formatShortYear,
|
|
83
|
+
Z as formatSingleDate,
|
|
84
|
+
E as formatTrend,
|
|
85
|
+
m as formatValue,
|
|
86
|
+
M as generateMarketId,
|
|
79
87
|
x as getAllPresets,
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
T as
|
|
89
|
-
|
|
90
|
-
|
|
88
|
+
B as getDateRangeDisplayInfo,
|
|
89
|
+
C as getDateRangeForPreset,
|
|
90
|
+
K as getDurationDays,
|
|
91
|
+
X as getPresetDateRange,
|
|
92
|
+
j as getPresetLabel,
|
|
93
|
+
h as getValueFontSize,
|
|
94
|
+
D as isEdgeHoverResizeEnabled,
|
|
95
|
+
R as isInRange,
|
|
96
|
+
T as isMarketActive,
|
|
97
|
+
P as isSameDay,
|
|
98
|
+
_ as isStatusModeEnabled,
|
|
99
|
+
q as isValidDateRangeFormat,
|
|
91
100
|
W as normalizePresetId,
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
101
|
+
J as parseDateRange,
|
|
102
|
+
Q as resolveEvent,
|
|
103
|
+
w as resolvePreset,
|
|
104
|
+
ee as smartDateFormat,
|
|
105
|
+
te as stripLeadingZeros,
|
|
106
|
+
ne as toUppercasePresetId,
|
|
107
|
+
S as v1_1_edge_hover_resize,
|
|
108
|
+
$ as v1_1_status_mode
|
|
99
109
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { isStatusModeEnabled, v1_1_status_mode, V1_1_STATUS_MODE_ENV } from './v1_1_flags';
|
|
1
|
+
export { isStatusModeEnabled, v1_1_status_mode, V1_1_STATUS_MODE_ENV, isEdgeHoverResizeEnabled, v1_1_edge_hover_resize, V1_1_EDGE_HOVER_RESIZE_ENV } from './v1_1_flags';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -18,4 +18,28 @@ export declare const v1_1_status_mode: {
|
|
|
18
18
|
env: string;
|
|
19
19
|
check: typeof isStatusModeEnabled;
|
|
20
20
|
};
|
|
21
|
+
/**
|
|
22
|
+
* Phase 10.5 WR-01 — edge-hover resize decoupling.
|
|
23
|
+
*
|
|
24
|
+
* Independent feature flag for edge-hover resize. Previously the consumer
|
|
25
|
+
* gated `enableEdgeHover` on `isStatusModeEnabled()`, which coupled two
|
|
26
|
+
* independent features behind a single flag. This helper lets consumers
|
|
27
|
+
* toggle edge-hover-resize on its own.
|
|
28
|
+
*
|
|
29
|
+
* Flag is OFF by default in production bundles.
|
|
30
|
+
*/
|
|
31
|
+
export declare const V1_1_EDGE_HOVER_RESIZE_ENV = "NEXT_PUBLIC_V1_1_EDGE_HOVER_RESIZE";
|
|
32
|
+
/**
|
|
33
|
+
* Returns true when edge-hover resize is enabled.
|
|
34
|
+
*
|
|
35
|
+
* Priority order (mirrors isStatusModeEnabled):
|
|
36
|
+
* 1. globalThis.__GLOSS_FLAGS__.v1_1_edge_hover_resize === true (runtime override / tests)
|
|
37
|
+
* 2. process.env.NEXT_PUBLIC_V1_1_EDGE_HOVER_RESIZE === 'true' (build-time env var)
|
|
38
|
+
* 3. false (default — flag OFF)
|
|
39
|
+
*/
|
|
40
|
+
export declare function isEdgeHoverResizeEnabled(): boolean;
|
|
41
|
+
export declare const v1_1_edge_hover_resize: {
|
|
42
|
+
env: string;
|
|
43
|
+
check: typeof isEdgeHoverResizeEnabled;
|
|
44
|
+
};
|
|
21
45
|
//# sourceMappingURL=v1_1_flags.d.ts.map
|