react-semaphor 0.1.534 → 0.1.536

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/dist/brand-studio/index.js +25 -25
  2. package/dist/briefings/index.js +1 -1
  3. package/dist/chunks/{calculated-field-identity-Cz1ZU_UL.js → calculated-field-identity-BptYhyOP.js} +4 -4
  4. package/dist/chunks/{card-config-utils-BlIiFn0O.js → card-config-utils-BOM1dxCk.js} +102 -86
  5. package/dist/chunks/{dashboard-CCK80YKL.js → dashboard-BTDY_I5L.js} +1 -1
  6. package/dist/chunks/dashboard-briefing-launcher-DV_rlhT2.js +4224 -0
  7. package/dist/chunks/{dashboard-controls-CoiTGnEr.js → dashboard-controls-B4LxN5dr.js} +862 -873
  8. package/dist/chunks/{dashboard-json-BRGozO--.js → dashboard-json-Ccjo0Dzw.js} +1 -1
  9. package/dist/chunks/{edit-dashboard-visual-CZFnhGZQ.js → edit-dashboard-visual-L5zsle6X.js} +9922 -9900
  10. package/dist/chunks/{index-BQl5rC54.js → index-DTcTAGGM.js} +1 -1
  11. package/dist/chunks/{matrix-control-sources-Tls-h3AN.js → matrix-control-sources-DTqcA2_L.js} +1 -1
  12. package/dist/chunks/report-preferences-dialog-CW8VEIDx.js +1623 -0
  13. package/dist/chunks/{layout-grid-CiubineE.js → save-kO6cIaob.js} +20 -2
  14. package/dist/chunks/{semaphor-ready-indicator-z4SNdxiC.js → semaphor-ready-indicator-3TXTZgw-.js} +65377 -79784
  15. package/dist/chunks/shelf-drop-preview-context-CBCs9rjz.js +2404 -0
  16. package/dist/chunks/{switch-BR3Xgbqr.js → switch-CKB-kUaC.js} +4355 -4779
  17. package/dist/chunks/upload-CAIpsti1.js +15 -0
  18. package/dist/chunks/use-create-flow-overlay-state-Bk-SBnaY.js +1457 -0
  19. package/dist/dashboard/index.js +1 -1
  20. package/dist/dashboard-authoring/index.js +4 -4
  21. package/dist/index.js +221 -220
  22. package/dist/style.css +1 -1
  23. package/dist/surfboard/index.js +1 -1
  24. package/dist/types/components/surfboard/controls/dashboard-filter-controls-launcher.d.ts +0 -1
  25. package/dist/types/lib/hooks/use-dashboard-query.d.ts +0 -2
  26. package/dist/types/lib/hooks/use-dashboard.d.ts +0 -1
  27. package/dist/types/lib/stores/dashboard-store.d.ts +1 -11
  28. package/dist/types/lib/stores/editor-store.d.ts +1 -10
  29. package/dist/types/lib/types/ai-context-types.d.ts +20 -0
  30. package/dist/types/lib/types/common-types.d.ts +1 -20
  31. package/dist/types/lib/types/token-types.d.ts +0 -7
  32. package/dist/types/lib/utils.d.ts +0 -2
  33. package/package.json +1 -7
  34. package/dist/chunks/dashboard-briefing-launcher-B9Fq2Rf3.js +0 -3489
  35. package/dist/chunks/editor-action-buttons-CVtSO3I3.js +0 -2067
  36. package/dist/chunks/report-preferences-dialog-CWdTlWsr.js +0 -1231
  37. package/dist/chunks/save-DgMfP0j8.js +0 -21
  38. package/dist/chunks/slider-DbwmuVB-.js +0 -875
  39. package/dist/dashboard-assistant/index.js +0 -11
  40. package/dist/types/dashboard-assistant/index.d.ts +0 -80
  41. package/dist/types/dashboard-assistant.d.ts +0 -2
  42. package/dist/types/lib/types/assistant-types.d.ts +0 -127
@@ -1,875 +0,0 @@
1
- import { jsxs as Q, jsx as p, Fragment as me } from "react/jsx-runtime";
2
- import * as C from "react";
3
- import Ue, { useState as he, useRef as F, useCallback as W, useEffect as U, forwardRef as ge, useMemo as _, memo as Qe, Suspense as Ye } from "react";
4
- import { aP as $e, aQ as oe, aR as Se, aS as je, aD as Ge, aT as We, aU as Xe, aV as Ze, aW as Je, aX as et, aY as tt, aZ as nt, a_ as rt, a$ as ot, b0 as st, b1 as at } from "./semaphor-ready-indicator-z4SNdxiC.js";
5
- import { a2 as L, a3 as ye, C as ve, a7 as it, c as se, a8 as lt, u as J, a9 as be, aa as B, ab as K, ac as ct, ad as ut, ae as dt, af as H, ag as ft, ah as Ce, ai as mt, aj as pt } from "./switch-BR3Xgbqr.js";
6
- import { f as ht, u as Ee, r as Re } from "./editor-action-buttons-CVtSO3I3.js";
7
- import "./x-CXDkqdur.js";
8
- import "./validators-DMSH81OM.js";
9
- import "./matrix-operation-contract-BKupLHXL.js";
10
- import "zod";
11
- import "../value-format-preferences/index.js";
12
- import { u as gt } from "./appearance-context-DEYtWinQ.js";
13
- import { r as St, g as yt, a as pe, b as ee, n as vt, c as bt } from "./index-BQl5rC54.js";
14
- const ln = Ue.memo(function({
15
- context: t = "editor"
16
- } = {}) {
17
- return /* @__PURE__ */ Q(
18
- "div",
19
- {
20
- "data-content": "fields-section",
21
- className: "flex h-full grow flex-col items-center overflow-hidden",
22
- children: [
23
- " ",
24
- /* @__PURE__ */ p($e, { context: t }),
25
- " "
26
- ]
27
- }
28
- );
29
- });
30
- function we({
31
- storeValue: e,
32
- defaultValue: t = "",
33
- onStoreUpdate: r,
34
- delay: o = 300
35
- }) {
36
- const [s, l] = he(e ?? t), n = F(null), a = F(s), u = F(e), h = F(!1), S = W(() => {
37
- n.current && (clearTimeout(n.current), n.current = null), h.current && a.current !== (u.current ?? t) && (r(a.current), u.current = a.current);
38
- }, [t, r]);
39
- U(() => {
40
- if (e !== u.current) {
41
- n.current && (clearTimeout(n.current), n.current = null);
42
- const c = e ?? t;
43
- l(c), a.current = c, u.current = e, h.current = !1;
44
- }
45
- }, [e, t]), U(() => {
46
- if (h.current)
47
- return n.current = setTimeout(() => {
48
- S();
49
- }, o), () => {
50
- n.current && (clearTimeout(n.current), n.current = null);
51
- };
52
- }, [o, S, s]), U(() => () => {
53
- n.current && clearTimeout(n.current);
54
- }, []);
55
- const i = W(
56
- (c) => {
57
- const b = c ?? t;
58
- h.current = !0, a.current = b, l(b);
59
- },
60
- [t]
61
- );
62
- return { value: s, onChange: i, flush: S };
63
- }
64
- function Pe({
65
- queryClient: e,
66
- readQueryKey: t,
67
- setRunSql: r
68
- }) {
69
- ht(), setTimeout(() => {
70
- e.resetQueries({ queryKey: t(), exact: !0 }), r(!0);
71
- }, 0);
72
- }
73
- const Ct = 300;
74
- function Et({ className: e }, t) {
75
- const r = L((f) => f.card.sql), o = L((f) => f.sqlGen), s = L((f) => f.card), l = Ee(), { setCardSql: n, setSqlGen: a, setRunSql: u } = ye(), h = _(() => l !== s.type ? { ...s, type: l } : s, [s, l]), { queryKey: S } = oe(h), i = Se(), c = F(S);
76
- c.current = S;
77
- const b = F(o);
78
- b.current = o;
79
- const E = W(
80
- (f) => {
81
- n(f);
82
- },
83
- [n]
84
- ), {
85
- value: d,
86
- onChange: g,
87
- flush: y
88
- } = we({
89
- storeValue: r,
90
- defaultValue: "",
91
- onStoreUpdate: E,
92
- delay: Ct
93
- });
94
- U(() => Re(y), [y]);
95
- function x(f) {
96
- g(f), it(b.current) || a({});
97
- }
98
- return /* @__PURE__ */ p("div", { className: "relative h-full w-full", children: /* @__PURE__ */ p(
99
- ve,
100
- {
101
- ref: t,
102
- value: d ?? "",
103
- onValueChange: x,
104
- language: "sql-jinja",
105
- embedded: !0,
106
- hideLineNumbers: !0,
107
- wrapLines: !0,
108
- placeholder: "Write your SQL here",
109
- className: e,
110
- onKeyDown: (f) => {
111
- f.key === "Enter" && f.shiftKey && (f.preventDefault(), Pe({
112
- queryClient: i,
113
- readQueryKey: () => c.current,
114
- setRunSql: u
115
- }));
116
- }
117
- }
118
- ) });
119
- }
120
- const cn = ge(Et), Rt = 300, wt = `# 'data' holds the SQL result.
121
- # Set 'result' to a list of dicts to replace it, for example:
122
- # import pandas as pd
123
- # result = pd.DataFrame(data).to_dict('records')`;
124
- function Pt({ className: e }, t) {
125
- const r = L((E) => E.card.python), o = L((E) => E.card), s = Ee(), { setCardPython: l, setRunSql: n } = ye(), a = _(() => s !== o.type ? { ...o, type: s } : o, [o, s]), { queryKey: u } = oe(a), h = Se(), S = F(u);
126
- S.current = u;
127
- const { value: i, onChange: c, flush: b } = we({
128
- storeValue: r,
129
- onStoreUpdate: l,
130
- delay: Rt
131
- });
132
- return U(() => Re(b), [b]), /* @__PURE__ */ p(
133
- ve,
134
- {
135
- ref: t,
136
- value: i ?? "",
137
- onValueChange: c,
138
- language: "python",
139
- placeholder: wt,
140
- ariaLabel: "Python code",
141
- embedded: !0,
142
- hideLineNumbers: !0,
143
- wrapLines: !0,
144
- className: se(
145
- "[&_.code-editor-pre]:!pt-2 [&_.code-editor-textarea]:!pt-2",
146
- e
147
- ),
148
- onKeyDown: (E) => {
149
- E.key === "Enter" && E.shiftKey && (E.preventDefault(), Pe({
150
- queryClient: h,
151
- readQueryKey: () => S.current,
152
- setRunSql: n
153
- }));
154
- }
155
- }
156
- );
157
- }
158
- const un = ge(Pt), xt = /* @__PURE__ */ new Set([
159
- "askForMoreInfo",
160
- "getAvailableChartTypes",
161
- "getChartSQLSyntax",
162
- "getDomainRelationships",
163
- "getTableColumns",
164
- "getUserSql",
165
- "validateCardConfigFormat"
166
- ]), dn = /* @__PURE__ */ new Set([
167
- "createChartFromSql",
168
- "createForecast",
169
- "generateQueryConfig",
170
- "getChartDataFromCardConfig",
171
- "getChartDataFromSqlAndPython",
172
- "getForecastDataFromSqlAndPython"
173
- ]), fn = Array.from(
174
- xt
175
- ).join(", "), mn = 3, pn = "Self-heal", hn = /* @__PURE__ */ new Set([
176
- "SQL_PARSE_ERROR",
177
- "SQL_EXPLAIN_ERROR"
178
- ]);
179
- function Dt({ card: e }) {
180
- var le, ce, ue, de, fe;
181
- const t = je(), [r, o] = he({}), { authToken: s } = Ge(), l = lt(s == null ? void 0 : s.accessToken), { compiledAppearance: n } = gt(), a = _(
182
- () => We(n),
183
- [n]
184
- ), u = L((m) => m.frame), h = L(
185
- (m) => m.inlineFilterValuesMap[e.id]
186
- ), S = L(
187
- (m) => m.actions.setCardInlineFilterValue
188
- ), i = L(
189
- (m) => m.actions.removeCardInlineFilterValue
190
- ), c = e, { getCard: b, manifest: E } = Xe(
191
- ((le = c.customCardPreferences) == null ? void 0 : le.url) || ""
192
- ), d = (ce = E == null ? void 0 : E.visuals) == null ? void 0 : ce.find(
193
- (m) => {
194
- var D;
195
- return m.name === ((D = c.customCardPreferences) == null ? void 0 : D.componentName);
196
- }
197
- ), g = St(c, d) ?? "single", y = _(
198
- () => yt({
199
- frame: u,
200
- configCard: c,
201
- isMultiInputVisual: g === "multiple"
202
- }),
203
- [u, c, g]
204
- ), x = _(() => {
205
- const m = y.findIndex(
206
- (D) => (D == null ? void 0 : D.id) === e.id
207
- );
208
- return m < 0 ? -1 : pe(e, m);
209
- }, [y, e]), f = _(() => g !== "multiple" || x < 0 ? e.type : ee(
210
- e,
211
- x,
212
- d == null ? void 0 : d.slots
213
- ) ?? e.type, [g, x, e, d == null ? void 0 : d.slots]), R = _(() => g === "multiple" ? {
214
- ...e,
215
- connectionId: void 0,
216
- dataSource: void 0,
217
- sql: "",
218
- python: "",
219
- config: void 0,
220
- queryConfig: void 0
221
- } : f !== e.type ? { ...e, type: f } : e, [e, f, g]), { data: v, effectiveCardConfig: O } = oe(R), k = Ze(), Y = J((m) => m.dashboard.filters), $ = J((m) => m.filterValues), T = J((m) => m.selectedSheetId), w = _(
222
- () => Je({
223
- card: e,
224
- sheetId: T || "",
225
- inlineFilterValues: h,
226
- setInlineFilterValue: (m) => S(e.id, m),
227
- removeInlineFilterValue: (m) => i(e.id, m)
228
- }),
229
- [
230
- e,
231
- T,
232
- h,
233
- S,
234
- i
235
- ]
236
- ), { cardFilters: I, cardFilterValues: V } = _(
237
- () => et({
238
- card: e,
239
- transientContexts: k,
240
- filters: Y,
241
- filterValues: $,
242
- selectedSheetId: T
243
- }),
244
- [
245
- e,
246
- k,
247
- Y,
248
- $,
249
- T
250
- ]
251
- ), q = W(
252
- (m, D) => {
253
- const G = vt(D);
254
- o((Z) => ({
255
- ...Z,
256
- [m]: G
257
- }));
258
- },
259
- []
260
- ), A = (ue = c.customCardPreferences) == null ? void 0 : ue.componentName, N = A ? b(A) : null, M = tt(
261
- (de = c.customCardPreferences) == null ? void 0 : de.settings,
262
- c
263
- ), P = _(
264
- () => bt(y),
265
- [y]
266
- ), j = _(
267
- () => P.map(
268
- (m, D) => ee(
269
- m,
270
- D,
271
- d == null ? void 0 : d.slots
272
- )
273
- ),
274
- [P, d == null ? void 0 : d.slots]
275
- ), ie = _(
276
- () => nt(
277
- g === "multiple" ? rt({
278
- slotOrderedCards: P,
279
- multiInputData: r,
280
- valueFormatPreferences: t
281
- }) : [
282
- {
283
- card: e,
284
- cardConfig: O,
285
- columns: v == null ? void 0 : v.columns,
286
- columnKeyMap: v == null ? void 0 : v.columnKeyMap,
287
- valueFormatPreferences: t
288
- }
289
- ]
290
- ),
291
- [
292
- e,
293
- v == null ? void 0 : v.columnKeyMap,
294
- v == null ? void 0 : v.columns,
295
- O,
296
- r,
297
- P,
298
- g,
299
- t
300
- ]
301
- );
302
- return A ? /* @__PURE__ */ p("div", { className: "semaphor-custom mb-3 flex grow basis-0 flex-col space-y-2 overflow-y-auto", children: /* @__PURE__ */ Q(
303
- Ye,
304
- {
305
- fallback: /* @__PURE__ */ p(me, {}),
306
- children: [
307
- N && g === "single" && /* @__PURE__ */ p(
308
- N,
309
- {
310
- editing: !0,
311
- params: l,
312
- theme: a,
313
- settings: M,
314
- cardMetadata: ot({
315
- card: e,
316
- dataMetadata: v == null ? void 0 : v.metadata
317
- }),
318
- onDataChange: q,
319
- data: (v == null ? void 0 : v.records) || [],
320
- columns: (v == null ? void 0 : v.columns) || [],
321
- formatTemporalBucketValue: ie,
322
- filters: I,
323
- filterValues: [
324
- ...V || [],
325
- ...h || []
326
- ],
327
- inlineFilters: w
328
- }
329
- ),
330
- N && g === "multiple" && /* @__PURE__ */ Q(me, { children: [
331
- y.map((m, D) => {
332
- if (!m) return null;
333
- const G = pe(m, D), Z = ee(
334
- m,
335
- G,
336
- d == null ? void 0 : d.slots
337
- );
338
- return /* @__PURE__ */ p(
339
- st,
340
- {
341
- onDataChange: q,
342
- card: m,
343
- effectiveCardType: Z
344
- },
345
- `${m.id}-${G}`
346
- );
347
- }),
348
- /* @__PURE__ */ p("div", { className: "flex flex-col gap-2", children: /* @__PURE__ */ p(
349
- N,
350
- {
351
- editing: !0,
352
- onDataChange: q,
353
- ...at({
354
- configCard: c,
355
- slotOrderedCards: P,
356
- slotTypes: j,
357
- multiInputData: r,
358
- params: l,
359
- theme: a,
360
- chartSettings: M,
361
- filters: I,
362
- filterValues: [
363
- ...V || [],
364
- ...h || []
365
- ],
366
- inlineFilters: w,
367
- formatTemporalBucketValue: ie
368
- })
369
- }
370
- ) })
371
- ] })
372
- ]
373
- },
374
- (fe = c.customCardPreferences) == null ? void 0 : fe.componentName
375
- ) }) : null;
376
- }
377
- const gn = Qe(Dt);
378
- var xe = "Toggle", De = C.forwardRef((e, t) => {
379
- const { pressed: r, defaultPressed: o, onPressedChange: s, ...l } = e, [n, a] = be({
380
- prop: r,
381
- onChange: s,
382
- defaultProp: o ?? !1,
383
- caller: xe
384
- });
385
- return /* @__PURE__ */ p(
386
- B.button,
387
- {
388
- type: "button",
389
- "aria-pressed": n,
390
- "data-state": n ? "on" : "off",
391
- "data-disabled": e.disabled ? "" : void 0,
392
- ...l,
393
- ref: t,
394
- onClick: K(e.onClick, () => {
395
- e.disabled || a(!n);
396
- })
397
- }
398
- );
399
- });
400
- De.displayName = xe;
401
- var _e = De;
402
- const _t = ct(
403
- "inline-flex items-center justify-center rounded-control text-sm font-medium ring-offset-background transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground",
404
- {
405
- variants: {
406
- variant: {
407
- default: "bg-transparent",
408
- outline: "border border-input bg-transparent hover:bg-accent hover:text-accent-foreground"
409
- },
410
- size: {
411
- default: "h-10 px-3",
412
- sm: "h-9 px-2.5",
413
- lg: "h-11 px-5"
414
- }
415
- },
416
- defaultVariants: {
417
- variant: "default",
418
- size: "default"
419
- }
420
- }
421
- ), Tt = C.forwardRef(({ className: e, variant: t, size: r, ...o }, s) => /* @__PURE__ */ p(
422
- _e,
423
- {
424
- ref: s,
425
- className: se(_t({ variant: t, size: r, className: e })),
426
- ...o
427
- }
428
- ));
429
- Tt.displayName = _e.displayName;
430
- var Te = ["PageUp", "PageDown"], Ie = ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"], Ne = {
431
- "from-left": ["Home", "PageDown", "ArrowDown", "ArrowLeft"],
432
- "from-right": ["Home", "PageDown", "ArrowDown", "ArrowRight"],
433
- "from-bottom": ["Home", "PageDown", "ArrowDown", "ArrowLeft"],
434
- "from-top": ["Home", "PageDown", "ArrowUp", "ArrowLeft"]
435
- }, z = "Slider", [te, It, Nt] = dt(z), [Ve] = ut(z, [
436
- Nt
437
- ]), [Vt, X] = Ve(z), Me = C.forwardRef(
438
- (e, t) => {
439
- const {
440
- name: r,
441
- min: o = 0,
442
- max: s = 100,
443
- step: l = 1,
444
- orientation: n = "horizontal",
445
- disabled: a = !1,
446
- minStepsBetweenThumbs: u = 0,
447
- defaultValue: h = [o],
448
- value: S,
449
- onValueChange: i = () => {
450
- },
451
- onValueCommit: c = () => {
452
- },
453
- inverted: b = !1,
454
- form: E,
455
- ...d
456
- } = e, g = C.useRef(/* @__PURE__ */ new Set()), y = C.useRef(0), f = n === "horizontal" ? Mt : Lt, [R = [], v] = be({
457
- prop: S,
458
- defaultProp: h,
459
- onChange: (w) => {
460
- var V;
461
- (V = [...g.current][y.current]) == null || V.focus(), i(w);
462
- }
463
- }), O = C.useRef(R);
464
- function k(w) {
465
- const I = kt(R, w);
466
- T(w, I);
467
- }
468
- function Y(w) {
469
- T(w, y.current);
470
- }
471
- function $() {
472
- const w = O.current[y.current];
473
- R[y.current] !== w && c(R);
474
- }
475
- function T(w, I, { commit: V } = { commit: !1 }) {
476
- const q = zt(l), A = Ut(Math.round((w - o) / l) * l + o, q), N = Ce(A, [o, s]);
477
- v((M = []) => {
478
- const P = Kt(M, N, I);
479
- if (Ht(P, u * l)) {
480
- y.current = P.indexOf(N);
481
- const j = String(P) !== String(M);
482
- return j && V && c(P), j ? P : M;
483
- } else
484
- return M;
485
- });
486
- }
487
- return /* @__PURE__ */ p(
488
- Vt,
489
- {
490
- scope: e.__scopeSlider,
491
- name: r,
492
- disabled: a,
493
- min: o,
494
- max: s,
495
- valueIndexToChangeRef: y,
496
- thumbs: g.current,
497
- values: R,
498
- orientation: n,
499
- form: E,
500
- children: /* @__PURE__ */ p(te.Provider, { scope: e.__scopeSlider, children: /* @__PURE__ */ p(te.Slot, { scope: e.__scopeSlider, children: /* @__PURE__ */ p(
501
- f,
502
- {
503
- "aria-disabled": a,
504
- "data-disabled": a ? "" : void 0,
505
- ...d,
506
- ref: t,
507
- onPointerDown: K(d.onPointerDown, () => {
508
- a || (O.current = R);
509
- }),
510
- min: o,
511
- max: s,
512
- inverted: b,
513
- onSlideStart: a ? void 0 : k,
514
- onSlideMove: a ? void 0 : Y,
515
- onSlideEnd: a ? void 0 : $,
516
- onHomeKeyDown: () => !a && T(o, 0, { commit: !0 }),
517
- onEndKeyDown: () => !a && T(s, R.length - 1, { commit: !0 }),
518
- onStepKeyDown: ({ event: w, direction: I }) => {
519
- if (!a) {
520
- const A = Te.includes(w.key) || w.shiftKey && Ie.includes(w.key) ? 10 : 1, N = y.current, M = R[N], P = l * A * I;
521
- T(M + P, N, { commit: !0 });
522
- }
523
- }
524
- }
525
- ) }) })
526
- }
527
- );
528
- }
529
- );
530
- Me.displayName = z;
531
- var [Le, Ae] = Ve(z, {
532
- startEdge: "left",
533
- endEdge: "right",
534
- size: "width",
535
- direction: 1
536
- }), Mt = C.forwardRef(
537
- (e, t) => {
538
- const {
539
- min: r,
540
- max: o,
541
- dir: s,
542
- inverted: l,
543
- onSlideStart: n,
544
- onSlideMove: a,
545
- onSlideEnd: u,
546
- onStepKeyDown: h,
547
- ...S
548
- } = e, [i, c] = C.useState(null), b = H(t, (f) => c(f)), E = C.useRef(void 0), d = ft(s), g = d === "ltr", y = g && !l || !g && l;
549
- function x(f) {
550
- const R = E.current || i.getBoundingClientRect(), v = [0, R.width], k = ae(v, y ? [r, o] : [o, r]);
551
- return E.current = R, k(f - R.left);
552
- }
553
- return /* @__PURE__ */ p(
554
- Le,
555
- {
556
- scope: e.__scopeSlider,
557
- startEdge: y ? "left" : "right",
558
- endEdge: y ? "right" : "left",
559
- direction: y ? 1 : -1,
560
- size: "width",
561
- children: /* @__PURE__ */ p(
562
- Fe,
563
- {
564
- dir: d,
565
- "data-orientation": "horizontal",
566
- ...S,
567
- ref: b,
568
- style: {
569
- ...S.style,
570
- "--radix-slider-thumb-transform": "translateX(-50%)"
571
- },
572
- onSlideStart: (f) => {
573
- const R = x(f.clientX);
574
- n == null || n(R);
575
- },
576
- onSlideMove: (f) => {
577
- const R = x(f.clientX);
578
- a == null || a(R);
579
- },
580
- onSlideEnd: () => {
581
- E.current = void 0, u == null || u();
582
- },
583
- onStepKeyDown: (f) => {
584
- const v = Ne[y ? "from-left" : "from-right"].includes(f.key);
585
- h == null || h({ event: f, direction: v ? -1 : 1 });
586
- }
587
- }
588
- )
589
- }
590
- );
591
- }
592
- ), Lt = C.forwardRef(
593
- (e, t) => {
594
- const {
595
- min: r,
596
- max: o,
597
- inverted: s,
598
- onSlideStart: l,
599
- onSlideMove: n,
600
- onSlideEnd: a,
601
- onStepKeyDown: u,
602
- ...h
603
- } = e, S = C.useRef(null), i = H(t, S), c = C.useRef(void 0), b = !s;
604
- function E(d) {
605
- const g = c.current || S.current.getBoundingClientRect(), y = [0, g.height], f = ae(y, b ? [o, r] : [r, o]);
606
- return c.current = g, f(d - g.top);
607
- }
608
- return /* @__PURE__ */ p(
609
- Le,
610
- {
611
- scope: e.__scopeSlider,
612
- startEdge: b ? "bottom" : "top",
613
- endEdge: b ? "top" : "bottom",
614
- size: "height",
615
- direction: b ? 1 : -1,
616
- children: /* @__PURE__ */ p(
617
- Fe,
618
- {
619
- "data-orientation": "vertical",
620
- ...h,
621
- ref: i,
622
- style: {
623
- ...h.style,
624
- "--radix-slider-thumb-transform": "translateY(50%)"
625
- },
626
- onSlideStart: (d) => {
627
- const g = E(d.clientY);
628
- l == null || l(g);
629
- },
630
- onSlideMove: (d) => {
631
- const g = E(d.clientY);
632
- n == null || n(g);
633
- },
634
- onSlideEnd: () => {
635
- c.current = void 0, a == null || a();
636
- },
637
- onStepKeyDown: (d) => {
638
- const y = Ne[b ? "from-bottom" : "from-top"].includes(d.key);
639
- u == null || u({ event: d, direction: y ? -1 : 1 });
640
- }
641
- }
642
- )
643
- }
644
- );
645
- }
646
- ), Fe = C.forwardRef(
647
- (e, t) => {
648
- const {
649
- __scopeSlider: r,
650
- onSlideStart: o,
651
- onSlideMove: s,
652
- onSlideEnd: l,
653
- onHomeKeyDown: n,
654
- onEndKeyDown: a,
655
- onStepKeyDown: u,
656
- ...h
657
- } = e, S = X(z, r);
658
- return /* @__PURE__ */ p(
659
- B.span,
660
- {
661
- ...h,
662
- ref: t,
663
- onKeyDown: K(e.onKeyDown, (i) => {
664
- i.key === "Home" ? (n(i), i.preventDefault()) : i.key === "End" ? (a(i), i.preventDefault()) : Te.concat(Ie).includes(i.key) && (u(i), i.preventDefault());
665
- }),
666
- onPointerDown: K(e.onPointerDown, (i) => {
667
- const c = i.target;
668
- c.setPointerCapture(i.pointerId), i.preventDefault(), S.thumbs.has(c) ? c.focus() : o(i);
669
- }),
670
- onPointerMove: K(e.onPointerMove, (i) => {
671
- i.target.hasPointerCapture(i.pointerId) && s(i);
672
- }),
673
- onPointerUp: K(e.onPointerUp, (i) => {
674
- const c = i.target;
675
- c.hasPointerCapture(i.pointerId) && (c.releasePointerCapture(i.pointerId), l(i));
676
- })
677
- }
678
- );
679
- }
680
- ), Ke = "SliderTrack", Oe = C.forwardRef(
681
- (e, t) => {
682
- const { __scopeSlider: r, ...o } = e, s = X(Ke, r);
683
- return /* @__PURE__ */ p(
684
- B.span,
685
- {
686
- "data-disabled": s.disabled ? "" : void 0,
687
- "data-orientation": s.orientation,
688
- ...o,
689
- ref: t
690
- }
691
- );
692
- }
693
- );
694
- Oe.displayName = Ke;
695
- var ne = "SliderRange", ke = C.forwardRef(
696
- (e, t) => {
697
- const { __scopeSlider: r, ...o } = e, s = X(ne, r), l = Ae(ne, r), n = C.useRef(null), a = H(t, n), u = s.values.length, h = s.values.map(
698
- (c) => He(c, s.min, s.max)
699
- ), S = u > 1 ? Math.min(...h) : 0, i = 100 - Math.max(...h);
700
- return /* @__PURE__ */ p(
701
- B.span,
702
- {
703
- "data-orientation": s.orientation,
704
- "data-disabled": s.disabled ? "" : void 0,
705
- ...o,
706
- ref: a,
707
- style: {
708
- ...e.style,
709
- [l.startEdge]: S + "%",
710
- [l.endEdge]: i + "%"
711
- }
712
- }
713
- );
714
- }
715
- );
716
- ke.displayName = ne;
717
- var re = "SliderThumb", qe = C.forwardRef(
718
- (e, t) => {
719
- const r = It(e.__scopeSlider), [o, s] = C.useState(null), l = H(t, (a) => s(a)), n = C.useMemo(
720
- () => o ? r().findIndex((a) => a.ref.current === o) : -1,
721
- [r, o]
722
- );
723
- return /* @__PURE__ */ p(At, { ...e, ref: l, index: n });
724
- }
725
- ), At = C.forwardRef(
726
- (e, t) => {
727
- const { __scopeSlider: r, index: o, name: s, ...l } = e, n = X(re, r), a = Ae(re, r), [u, h] = C.useState(null), S = H(t, (x) => h(x)), i = u ? n.form || !!u.closest("form") : !0, c = mt(u), b = n.values[o], E = b === void 0 ? 0 : He(b, n.min, n.max), d = Ot(o, n.values.length), g = c == null ? void 0 : c[a.size], y = g ? qt(g, E, a.direction) : 0;
728
- return C.useEffect(() => {
729
- if (u)
730
- return n.thumbs.add(u), () => {
731
- n.thumbs.delete(u);
732
- };
733
- }, [u, n.thumbs]), /* @__PURE__ */ Q(
734
- "span",
735
- {
736
- style: {
737
- transform: "var(--radix-slider-thumb-transform)",
738
- position: "absolute",
739
- [a.startEdge]: `calc(${E}% + ${y}px)`
740
- },
741
- children: [
742
- /* @__PURE__ */ p(te.ItemSlot, { scope: e.__scopeSlider, children: /* @__PURE__ */ p(
743
- B.span,
744
- {
745
- role: "slider",
746
- "aria-label": e["aria-label"] || d,
747
- "aria-valuemin": n.min,
748
- "aria-valuenow": b,
749
- "aria-valuemax": n.max,
750
- "aria-orientation": n.orientation,
751
- "data-orientation": n.orientation,
752
- "data-disabled": n.disabled ? "" : void 0,
753
- tabIndex: n.disabled ? void 0 : 0,
754
- ...l,
755
- ref: S,
756
- style: b === void 0 ? { display: "none" } : e.style,
757
- onFocus: K(e.onFocus, () => {
758
- n.valueIndexToChangeRef.current = o;
759
- })
760
- }
761
- ) }),
762
- i && /* @__PURE__ */ p(
763
- Be,
764
- {
765
- name: s ?? (n.name ? n.name + (n.values.length > 1 ? "[]" : "") : void 0),
766
- form: n.form,
767
- value: b
768
- },
769
- o
770
- )
771
- ]
772
- }
773
- );
774
- }
775
- );
776
- qe.displayName = re;
777
- var Ft = "RadioBubbleInput", Be = C.forwardRef(
778
- ({ __scopeSlider: e, value: t, ...r }, o) => {
779
- const s = C.useRef(null), l = H(s, o), n = pt(t);
780
- return C.useEffect(() => {
781
- const a = s.current;
782
- if (!a) return;
783
- const u = window.HTMLInputElement.prototype, S = Object.getOwnPropertyDescriptor(u, "value").set;
784
- if (n !== t && S) {
785
- const i = new Event("input", { bubbles: !0 });
786
- S.call(a, t), a.dispatchEvent(i);
787
- }
788
- }, [n, t]), /* @__PURE__ */ p(
789
- B.input,
790
- {
791
- style: { display: "none" },
792
- ...r,
793
- ref: l,
794
- defaultValue: t
795
- }
796
- );
797
- }
798
- );
799
- Be.displayName = Ft;
800
- function Kt(e = [], t, r) {
801
- const o = [...e];
802
- return o[r] = t, o.sort((s, l) => s - l);
803
- }
804
- function He(e, t, r) {
805
- const l = 100 / (r - t) * (e - t);
806
- return Ce(l, [0, 100]);
807
- }
808
- function Ot(e, t) {
809
- return t > 2 ? `Value ${e + 1} of ${t}` : t === 2 ? ["Minimum", "Maximum"][e] : void 0;
810
- }
811
- function kt(e, t) {
812
- if (e.length === 1) return 0;
813
- const r = e.map((s) => Math.abs(s - t)), o = Math.min(...r);
814
- return r.indexOf(o);
815
- }
816
- function qt(e, t, r) {
817
- const o = e / 2, l = ae([0, 50], [0, o]);
818
- return (o - l(t) * r) * r;
819
- }
820
- function Bt(e) {
821
- return e.slice(0, -1).map((t, r) => e[r + 1] - t);
822
- }
823
- function Ht(e, t) {
824
- if (t > 0) {
825
- const r = Bt(e);
826
- return Math.min(...r) >= t;
827
- }
828
- return !0;
829
- }
830
- function ae(e, t) {
831
- return (r) => {
832
- if (e[0] === e[1] || t[0] === t[1]) return t[0];
833
- const o = (t[1] - t[0]) / (e[1] - e[0]);
834
- return t[0] + o * (r - e[0]);
835
- };
836
- }
837
- function zt(e) {
838
- return (String(e).split(".")[1] || "").length;
839
- }
840
- function Ut(e, t) {
841
- const r = Math.pow(10, t);
842
- return Math.round(e * r) / r;
843
- }
844
- var ze = Me, Qt = Oe, Yt = ke, $t = qe;
845
- const jt = C.forwardRef(({ className: e, ...t }, r) => /* @__PURE__ */ Q(
846
- ze,
847
- {
848
- ref: r,
849
- className: se(
850
- "relative flex w-full touch-none select-none items-center",
851
- e
852
- ),
853
- ...t,
854
- children: [
855
- /* @__PURE__ */ p(Qt, { className: "relative h-2 w-full grow overflow-hidden rounded-full bg-secondary", children: /* @__PURE__ */ p(Yt, { className: "absolute h-full bg-primary" }) }),
856
- /* @__PURE__ */ p($t, { className: "block h-5 w-5 rounded-full border-2 border-primary bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50" })
857
- ]
858
- }
859
- ));
860
- jt.displayName = ze.displayName;
861
- export {
862
- gn as E,
863
- ln as F,
864
- fn as I,
865
- mn as M,
866
- un as P,
867
- hn as R,
868
- pn as S,
869
- Tt as T,
870
- dn as a,
871
- xt as b,
872
- cn as c,
873
- jt as d,
874
- Pe as r
875
- };