@microsoft/fabric-slicers 4.0.0 → 4.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // src/components/list-slicer/list-slicer.tsx
2
2
  import { useVirtualizer } from "@tanstack/react-virtual";
3
3
  import { useCallback as useCallback4, useEffect as useEffect2, useId, useMemo as useMemo2, useRef as useRef3, useState as useState3 } from "react";
4
- import { getString as getString3 } from "@microsoft/fabric-visuals-core";
4
+ import { formatString as formatString3, getString as getString3 } from "@microsoft/fabric-visuals-core";
5
5
 
6
6
  // src/hooks/use-list-slicer.ts
7
7
  import { useCallback, useEffect, useMemo, useRef, useState } from "react";
@@ -93,23 +93,32 @@ function useListSlicer({ data, column, title, selection, onInteraction }) {
93
93
  () => prepared.items.filter((item) => isSelected(item.key)),
94
94
  [prepared.items, isSelected]
95
95
  );
96
- const updateSelection = useCallback((next) => {
97
- const normalized = next !== "all" && prepared.items.length > 0 && next.size >= prepared.items.length && prepared.items.every((item) => next.has(item.key)) ? "all" : next;
98
- selectionRef.current = normalized;
99
- setLocalSelection(normalized);
96
+ const commitSelection = useCallback((next) => {
97
+ selectionRef.current = next;
98
+ setLocalSelection(next);
100
99
  if (!onInteraction) return;
101
- const event = normalized === "all" ? { action: "clear" } : {
100
+ const event = next === "all" || next.size === 0 ? { action: "clear" } : {
102
101
  action: "select",
103
102
  selections: [{
104
103
  predicates: [{
105
104
  type: "set",
106
105
  fieldId: column,
107
- values: [...normalized.values()].map(toInteractionValue)
106
+ values: [...next.values()].map(toInteractionValue)
108
107
  }]
109
108
  }]
110
109
  };
111
110
  onInteraction([event]);
112
- }, [column, onInteraction, prepared.items]);
111
+ }, [column, onInteraction]);
112
+ const updateSelection = useCallback((next) => {
113
+ const normalized = next !== "all" && prepared.items.length > 0 && next.size >= prepared.items.length && prepared.items.every((item) => next.has(item.key)) ? "all" : next;
114
+ commitSelection(normalized);
115
+ }, [commitSelection, prepared.items]);
116
+ const selectOnly = useCallback((key) => {
117
+ if (!valuesByKey.has(key)) throw new Error(`Cannot update an unknown slicer key: ${key}`);
118
+ const previous = selectionRef.current;
119
+ if (previous !== "all" && previous.size === 1 && previous.has(key)) return;
120
+ commitSelection(/* @__PURE__ */ new Map([[key, valuesByKey.get(key)]]));
121
+ }, [valuesByKey, commitSelection]);
113
122
  const clear = useCallback(() => {
114
123
  if (selectionRef.current !== "all") updateSelection("all");
115
124
  }, [updateSelection]);
@@ -148,6 +157,7 @@ function useListSlicer({ data, column, title, selection, onInteraction }) {
148
157
  selectedItems,
149
158
  isSelected,
150
159
  toggle,
160
+ selectOnly,
151
161
  toggleAll,
152
162
  clear,
153
163
  allSelected: localSelection === "all"
@@ -180,10 +190,20 @@ function useListNavigation(items) {
180
190
  }
181
191
  }, [items]);
182
192
  const handleKeyDown = useCallback2((event) => {
183
- const isCheckboxTarget = event.target instanceof HTMLButtonElement && event.target.getAttribute("role") === "checkbox";
184
- const isNavigationKey = event.key === "ArrowUp" || event.key === "ArrowDown" || event.key === "Home" || event.key === "End";
185
- if (isCheckboxTarget && isNavigationKey && !event.altKey && !event.ctrlKey && !event.metaKey && !event.shiftKey) {
193
+ const isRowControl = event.target instanceof HTMLButtonElement && (event.target.getAttribute("role") === "checkbox" || event.target.hasAttribute("data-slicer-only"));
194
+ const isNavigationKey = event.key === "ArrowUp" || event.key === "ArrowDown" || event.key === "Home" || event.key === "End" || event.key === "ArrowRight" || event.key === "ArrowLeft";
195
+ if (isRowControl && isNavigationKey && !event.altKey && !event.ctrlKey && !event.metaKey && !event.shiftKey) {
186
196
  if (event.defaultPrevented || items.length === 0) return;
197
+ if (event.key === "ArrowRight" || event.key === "ArrowLeft") {
198
+ const selector = event.key === "ArrowRight" ? "[data-slicer-only]" : '[role="checkbox"]';
199
+ const control = event.currentTarget.querySelector(`[data-slicer-index="${activeIndex}"] ${selector}`);
200
+ if (control) {
201
+ event.preventDefault();
202
+ event.stopPropagation();
203
+ control.focus();
204
+ }
205
+ return;
206
+ }
187
207
  event.preventDefault();
188
208
  event.stopPropagation();
189
209
  let nextIndex;
@@ -233,11 +253,7 @@ var useSlicerStyles = makeStyles(inVisualsLayer({
233
253
  fontWeight: `var(--slicer-weight, ${tokens.fontWeightRegular})`,
234
254
  color: `var(--slicer-foreground, ${tokens.colorForeground})`,
235
255
  lineHeight: "20px",
236
- "& button, & input": { fontFamily: "inherit", fontSize: "inherit" },
237
- "& button:focus-visible, & input:focus-visible": {
238
- outline: `2px solid var(--slicer-link, ${tokens.colorBrandForeground})`,
239
- outlineOffset: "2px"
240
- }
256
+ "& button, & input": { fontFamily: "inherit", fontSize: "inherit" }
241
257
  },
242
258
  root: { display: "flex", flexDirection: "column", gap: "8px", minWidth: 0, minHeight: 0, width: "100%" },
243
259
  fillHeight: { height: "100%", maxHeight: "100%" },
@@ -260,10 +276,6 @@ var useSlicerStyles = makeStyles(inVisualsLayer({
260
276
  fontFamily: "inherit",
261
277
  fontSize: "12px",
262
278
  flexShrink: 0,
263
- ":focus-visible": {
264
- outline: `2px solid var(--slicer-link, ${tokens.colorBrandForeground})`,
265
- outlineOffset: "2px"
266
- },
267
279
  ":disabled": { opacity: 0.5, cursor: "default" }
268
280
  },
269
281
  clearHidden: { visibility: "hidden" },
@@ -382,10 +394,22 @@ function SearchIcon({ className }) {
382
394
  /* @__PURE__ */ jsx3("path", { d: "m10 10 4 4", stroke: "currentColor" })
383
395
  ] });
384
396
  }
397
+ function CalendarIcon({ className }) {
398
+ return /* @__PURE__ */ jsxs2("svg", { className, width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: [
399
+ /* @__PURE__ */ jsx3("rect", { x: "2", y: "3", width: "12", height: "11", rx: "1", stroke: "currentColor" }),
400
+ /* @__PURE__ */ jsx3("path", { d: "M5 1.5v3M11 1.5v3M2 6h12M5 9h2M9 9h2M5 11.5h2", stroke: "currentColor" })
401
+ ] });
402
+ }
385
403
 
386
404
  // src/components/list-slicer/list-slicer-styles.ts
387
405
  import { makeStyles as makeStyles3 } from "@griffel/react";
388
406
  import { inVisualsLayer as inVisualsLayer3, tokens as tokens3 } from "@microsoft/fabric-visuals-core";
407
+ var nativeFocusOutline = {
408
+ outline: "1px auto",
409
+ outlineColor: "-webkit-focus-ring-color",
410
+ // Wrappers otherwise receive CanvasText instead of the control's system focus color.
411
+ "@media (forced-colors: active)": { outlineColor: "Highlight" }
412
+ };
389
413
  var useListSlicerStyles = makeStyles3(inVisualsLayer3({
390
414
  // Without panel padding, outward focus rings need visible overflow; the value list owns scrolling.
391
415
  frameless: { border: 0, borderRadius: 0, padding: 0, backgroundColor: "transparent", overflow: "visible" },
@@ -400,10 +424,10 @@ var useListSlicerStyles = makeStyles3(inVisualsLayer3({
400
424
  padding: "4px 8px",
401
425
  marginBottom: "4px",
402
426
  color: `var(--slicer-secondary, ${tokens3.colorMutedForeground})`,
403
- ":focus-within": {
404
- outline: `2px solid var(--slicer-link, ${tokens3.colorBrandForeground})`,
405
- outlineOffset: "1px",
406
- "& > input:focus-visible": { outline: "none" }
427
+ // Draw the browser's focus ring around the icon and input without adding a Tab stop.
428
+ ":has(> input:focus-visible)": {
429
+ ...nativeFocusOutline,
430
+ "& > input": { outline: "none" }
407
431
  }
408
432
  },
409
433
  input: {
@@ -457,7 +481,15 @@ var useListSlicerStyles = makeStyles3(inVisualsLayer3({
457
481
  boxSizing: "border-box",
458
482
  borderRadius: "4px",
459
483
  minWidth: 0,
460
- ":hover": { backgroundColor: `var(--slicer-hover, ${tokens3.colorHover})` }
484
+ position: "relative",
485
+ ":hover": { backgroundColor: `var(--slicer-hover, ${tokens3.colorHover})` },
486
+ ':has(> [role="checkbox"]:focus-visible)': {
487
+ ...nativeFocusOutline,
488
+ // Keep the full checkbox-and-label ring inside the scrolling viewport.
489
+ outlineOffset: "-2px",
490
+ '& > [role="checkbox"]': { outline: "none" }
491
+ },
492
+ "&:hover > [data-slicer-only], &:has(:focus-visible) > [data-slicer-only]": { position: "static", opacity: 1, pointerEvents: "auto" }
461
493
  },
462
494
  selectAll: { flexShrink: 0, fontWeight: 600 },
463
495
  label: {
@@ -468,13 +500,39 @@ var useListSlicerStyles = makeStyles3(inVisualsLayer3({
468
500
  cursor: "pointer",
469
501
  minWidth: 0,
470
502
  flexGrow: 1
503
+ },
504
+ only: {
505
+ height: tokens3.spacingXxl,
506
+ minWidth: "44px",
507
+ padding: `0 ${tokens3.spacingM}`,
508
+ flexShrink: 0,
509
+ border: 0,
510
+ borderRadius: tokens3.radiusFull,
511
+ cursor: "pointer",
512
+ whiteSpace: "nowrap",
513
+ backgroundColor: `var(--slicer-muted, ${tokens3.colorMuted})`,
514
+ color: `var(--slicer-link, ${tokens3.colorBrandForeground})`,
515
+ // Keep hidden actions keyboard-focusable without reserving label space.
516
+ position: "absolute",
517
+ insetInlineEnd: tokens3.spacingS,
518
+ opacity: 0,
519
+ pointerEvents: "none",
520
+ ":focus-visible": { position: "static", opacity: 1, pointerEvents: "auto" },
521
+ ":active": {
522
+ backgroundColor: `color-mix(in srgb, var(--slicer-muted, ${tokens3.colorMuted}) 90%, currentColor)`
523
+ },
524
+ "@media (forced-colors: active)": {
525
+ backgroundColor: "ButtonFace",
526
+ color: "ButtonText",
527
+ ":active": { backgroundColor: "Highlight", color: "HighlightText" }
528
+ }
471
529
  }
472
530
  }));
473
531
 
474
532
  // src/components/list-slicer/list-slicer.tsx
475
533
  import { Fragment, jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
476
534
  var ROW_HEIGHT = 32;
477
- function ListSlicerRow({ label, checked, onToggle, disabled, className, tabIndex, navigationIndex }) {
535
+ function ListSlicerRow({ label, checked, onToggle, onSelectOnly, disabled, className, tabIndex, navigationIndex }) {
478
536
  const styles = { ...useSlicerStyles(), ...useListSlicerStyles() };
479
537
  const id = useId();
480
538
  return /* @__PURE__ */ jsxs3("div", { className: mergeClasses(styles.row, className), "data-slicer-index": navigationIndex, children: [
@@ -489,7 +547,20 @@ function ListSlicerRow({ label, checked, onToggle, disabled, className, tabIndex
489
547
  tabIndex
490
548
  }
491
549
  ),
492
- /* @__PURE__ */ jsx4("label", { className: styles.label, htmlFor: id, children: /* @__PURE__ */ jsx4("span", { className: styles.text, title: label, children: label }) })
550
+ /* @__PURE__ */ jsx4("label", { className: styles.label, htmlFor: id, children: /* @__PURE__ */ jsx4("span", { className: styles.text, title: label, children: label }) }),
551
+ onSelectOnly && /* @__PURE__ */ jsx4(
552
+ "button",
553
+ {
554
+ type: "button",
555
+ className: styles.only,
556
+ "data-slicer-only": "",
557
+ "aria-label": formatString3("Slicer_OnlyLabel", label),
558
+ onClick: onSelectOnly,
559
+ tabIndex,
560
+ disabled,
561
+ children: getString3("Slicer_Only")
562
+ }
563
+ )
493
564
  ] });
494
565
  }
495
566
  function ItemRow({ item, state, tabIndex }) {
@@ -497,12 +568,14 @@ function ItemRow({ item, state, tabIndex }) {
497
568
  (checked) => state.toggle(item.key, checked === true),
498
569
  [state, item.key]
499
570
  );
571
+ const selectOnly = useCallback4(() => state.selectOnly(item.key), [state, item.key]);
500
572
  return /* @__PURE__ */ jsx4(
501
573
  ListSlicerRow,
502
574
  {
503
575
  label: item.label,
504
576
  checked: state.isSelected(item.key),
505
577
  onToggle: toggle,
578
+ onSelectOnly: selectOnly,
506
579
  tabIndex
507
580
  }
508
581
  );
@@ -515,13 +588,14 @@ function ListSlicer(props) {
515
588
  }
516
589
  function StatefulListSlicer(props) {
517
590
  const state = useListSlicer(props);
518
- return /* @__PURE__ */ jsx4(ListSlicerContent, { state, theme: props.theme, displayOptions: props.displayOptions });
591
+ return /* @__PURE__ */ jsx4(ListSlicerContent, { state, theme: props.theme, displayOptions: props.displayOptions, isSelectionBoundary: true });
519
592
  }
520
593
  function ListSlicerContent({
521
594
  state,
522
595
  theme,
523
596
  displayOptions,
524
- maxVisibleItems = 8
597
+ maxVisibleItems = 8,
598
+ isSelectionBoundary = false
525
599
  }) {
526
600
  const styles = { ...useSlicerStyles(), ...useListSlicerStyles() };
527
601
  const titleId = useId();
@@ -589,6 +663,7 @@ function ListSlicerContent({
589
663
  return /* @__PURE__ */ jsxs3(
590
664
  "section",
591
665
  {
666
+ "data-lyra-selection-boundary": isSelectionBoundary ? "" : void 0,
592
667
  className: mergeClasses(styles.typography, styles.root, !hideHeader && styles.fillHeight),
593
668
  style: themeStyle,
594
669
  "aria-labelledby": hideHeader ? void 0 : titleId,
@@ -600,7 +675,7 @@ function ListSlicerContent({
600
675
  title: state.title,
601
676
  titleId,
602
677
  onClear: state.allSelected ? void 0 : state.clear,
603
- clearDisabled: !!state.error || state.items.length === 0
678
+ clearDisabled: !!state.error
604
679
  }
605
680
  ),
606
681
  /* @__PURE__ */ jsx4(
@@ -666,7 +741,7 @@ function ListSlicerContent({
666
741
 
667
742
  // src/components/dropdown-slicer/dropdown-slicer.tsx
668
743
  import { useId as useId2, useMemo as useMemo3 } from "react";
669
- import { formatString as formatString3, getString as getString4 } from "@microsoft/fabric-visuals-core";
744
+ import { formatString as formatString4, getString as getString4 } from "@microsoft/fabric-visuals-core";
670
745
 
671
746
  // src/components/ui/popover.tsx
672
747
  import { Popover as PopoverPrimitive } from "radix-ui";
@@ -682,6 +757,7 @@ var usePopoverStyles = makeStyles4(inVisualsLayer4({
682
757
  outline: "none",
683
758
  zIndex: 1e3,
684
759
  borderRadius: `var(--slicer-radius, ${tokens4.radiusXl})`,
760
+ backgroundColor: `var(--slicer-background, ${tokens4.colorBackground})`,
685
761
  boxShadow: "0 2px 6px rgba(0, 0, 0, 0.16)"
686
762
  }
687
763
  }));
@@ -742,10 +818,11 @@ function DropdownSlicerContent(props) {
742
818
  () => ({ ...props.displayOptions, hideHeader: true }),
743
819
  [props.displayOptions]
744
820
  );
745
- const summary = state.items.length === 0 ? getString4("Slicer_NoData") : state.allSelected ? getString4("Slicer_All") : state.selectedItems.length === 0 ? getString4("Slicer_None") : state.selectedItems.length > 2 ? formatString3("Slicer_SelectionCount", state.selectedItems.length, state.items.length) : state.selectedItems.map((item) => item.label).join(", ");
821
+ const summary = state.items.length === 0 ? getString4("Slicer_NoData") : state.allSelected ? getString4("Slicer_All") : state.selectedItems.length === 0 ? getString4("Slicer_None") : state.selectedItems.length > 2 ? formatString4("Slicer_SelectionCount", state.selectedItems.length, state.items.length) : state.selectedItems.map((item) => item.label).join(", ");
746
822
  return /* @__PURE__ */ jsxs4(
747
823
  "section",
748
824
  {
825
+ "data-lyra-selection-boundary": "",
749
826
  className: mergeClasses(styles.typography, styles.root),
750
827
  style: themeStyle,
751
828
  "aria-labelledby": hideHeader ? void 0 : titleId,
@@ -757,7 +834,7 @@ function DropdownSlicerContent(props) {
757
834
  title: state.title,
758
835
  titleId,
759
836
  onClear: state.allSelected ? void 0 : state.clear,
760
- clearDisabled: !!state.error || state.items.length === 0
837
+ clearDisabled: !!state.error
761
838
  }
762
839
  ),
763
840
  state.error ? /* @__PURE__ */ jsx6(ListSlicerContent, { state, theme: props.theme, displayOptions: listDisplayOptions }) : /* @__PURE__ */ jsxs4(Popover, { children: [
@@ -789,13 +866,1121 @@ function DropdownSlicerContent(props) {
789
866
  );
790
867
  }
791
868
 
869
+ // src/components/date-slicer/date-slicer.tsx
870
+ import { useCallback as useCallback9, useEffect as useEffect4, useId as useId3, useMemo as useMemo7, useState as useState8 } from "react";
871
+ import { formatString as formatString9, getString as getString10 } from "@microsoft/fabric-visuals-core";
872
+
873
+ // src/components/date-slicer/date-slicer-calendar.tsx
874
+ import { useCallback as useCallback6, useMemo as useMemo5, useRef as useRef4, useState as useState5 } from "react";
875
+ import { DayPicker, defaultDateLib, formatMonthDropdown } from "@daypicker/react";
876
+ import { compareCalendarDates as compareCalendarDates3, formatString as formatString7, getString as getString7 } from "@microsoft/fabric-visuals-core";
877
+
878
+ // src/components/date-slicer/date-slicer-navigation.tsx
879
+ import { Chevron } from "@daypicker/react";
880
+ import { formatString as formatString5, getString as getString5 } from "@microsoft/fabric-visuals-core";
881
+
882
+ // src/components/date-slicer/date-slicer-styles.ts
883
+ import { makeStyles as makeStyles6 } from "@griffel/react";
884
+ import { borderRadius, fontSize, fontWeight, injectDesignTokens as injectDesignTokens2, inVisualsLayer as inVisualsLayer6, spacing, tokens as tokens6 } from "@microsoft/fabric-visuals-core";
885
+ injectDesignTokens2();
886
+ var useDateSlicerStyles = makeStyles6(inVisualsLayer6({
887
+ root: {
888
+ // A full-width navigation row must not enlarge the calendar's intrinsic width beyond its day grids.
889
+ width: `calc(var(--date-month-count) * 252px + (var(--date-month-count) - 1) * ${spacing.l})`,
890
+ minWidth: 0,
891
+ maxWidth: "100%",
892
+ color: `var(--slicer-foreground, ${tokens6.colorForeground})`,
893
+ fontFamily: `var(--slicer-font, ${tokens6.fontBase})`,
894
+ fontSize: `var(--slicer-size, ${tokens6.text300})`,
895
+ display: "flex",
896
+ flexDirection: "column",
897
+ gap: spacing.s,
898
+ "@media (max-width: 600px)": {
899
+ width: "100%"
900
+ }
901
+ },
902
+ dayPickerRoot: {
903
+ width: "100%"
904
+ },
905
+ months: {
906
+ display: "grid",
907
+ // Reflow whole panels, then share remaining width rather than leaving a narrow column beside the presets.
908
+ gridTemplateColumns: "repeat(auto-fit, minmax(252px, 1fr))",
909
+ alignItems: "start",
910
+ gap: spacing.l
911
+ },
912
+ month: {
913
+ // Seven columns at 36px each keep day buttons large enough to click on narrow screens.
914
+ width: "100%",
915
+ minWidth: 0
916
+ },
917
+ caption: {
918
+ display: "flex",
919
+ alignItems: "center",
920
+ justifyContent: "center",
921
+ minHeight: "24px",
922
+ marginBottom: spacing.xs
923
+ },
924
+ captionLabel: {
925
+ fontFamily: `var(--slicer-heading-font, ${tokens6.fontHeading})`,
926
+ fontSize: fontSize[200],
927
+ fontWeight: fontWeight.semibold,
928
+ color: `var(--slicer-secondary, ${tokens6.colorMutedForeground})`,
929
+ overflowWrap: "anywhere",
930
+ lineHeight: "20px"
931
+ },
932
+ hiddenCaption: {
933
+ display: "none"
934
+ },
935
+ navigation: {
936
+ display: "grid",
937
+ gridTemplateColumns: "36px minmax(0, 1fr) 36px",
938
+ alignItems: "center",
939
+ columnGap: spacing.s,
940
+ width: "100%"
941
+ },
942
+ windowButton: {
943
+ justifySelf: "center",
944
+ width: "auto",
945
+ height: "auto",
946
+ minHeight: "36px",
947
+ minWidth: 0,
948
+ padding: `${spacing.xs} ${spacing.s}`,
949
+ fontFamily: `var(--slicer-heading-font, ${tokens6.fontHeading})`,
950
+ fontSize: "inherit",
951
+ fontWeight: fontWeight.semibold,
952
+ lineHeight: "20px",
953
+ overflowWrap: "anywhere",
954
+ textAlign: "center"
955
+ },
956
+ periodGrid: {
957
+ width: "100%",
958
+ tableLayout: "fixed",
959
+ borderSpacing: spacing.xs,
960
+ "& td": { padding: 0 }
961
+ },
962
+ periodButton: {
963
+ width: "100%",
964
+ minHeight: "44px",
965
+ padding: `${spacing.xs} ${spacing.xs}`,
966
+ border: "1px solid transparent",
967
+ borderRadius: borderRadius.medium,
968
+ backgroundColor: "transparent",
969
+ color: "inherit",
970
+ font: "inherit",
971
+ overflowWrap: "anywhere",
972
+ cursor: "pointer",
973
+ ":hover:not(:disabled)": {
974
+ backgroundColor: `var(--slicer-hover, ${tokens6.colorHover})`
975
+ },
976
+ ":focus-visible": {
977
+ outline: `2px solid var(--slicer-link, ${tokens6.colorBrandForeground})`,
978
+ outlineOffset: "1px"
979
+ },
980
+ ":disabled": {
981
+ color: `var(--slicer-secondary, ${tokens6.colorMutedForeground})`,
982
+ cursor: "default",
983
+ opacity: 0.5
984
+ }
985
+ },
986
+ selectedPeriod: {
987
+ backgroundColor: `color-mix(in srgb, var(--slicer-brand, ${tokens6.colorBrand}) 15%, var(--slicer-background, ${tokens6.colorBackground}))`
988
+ },
989
+ periodEndpoint: {
990
+ backgroundColor: `var(--slicer-brand, ${tokens6.colorBrand})`,
991
+ color: tokens6.colorPrimaryForeground,
992
+ fontWeight: fontWeight.semibold,
993
+ ":hover:not(:disabled)": {
994
+ backgroundColor: `var(--slicer-brand, ${tokens6.colorBrand})`
995
+ }
996
+ },
997
+ navigationButton: {
998
+ display: "inline-flex",
999
+ justifyContent: "center",
1000
+ alignItems: "center",
1001
+ width: "36px",
1002
+ height: "36px",
1003
+ padding: 0,
1004
+ border: 0,
1005
+ borderRadius: borderRadius.medium,
1006
+ color: "inherit",
1007
+ backgroundColor: "transparent",
1008
+ cursor: "pointer",
1009
+ ':hover:not([aria-disabled="true"])': {
1010
+ backgroundColor: `var(--slicer-hover, ${tokens6.colorHover})`
1011
+ },
1012
+ ":focus-visible": {
1013
+ outline: `2px solid var(--slicer-link, ${tokens6.colorBrandForeground})`,
1014
+ outlineOffset: "1px"
1015
+ },
1016
+ '&[aria-disabled="true"]': {
1017
+ color: `var(--slicer-secondary, ${tokens6.colorMutedForeground})`,
1018
+ cursor: "default",
1019
+ opacity: 0.5
1020
+ }
1021
+ },
1022
+ chevron: {
1023
+ width: "20px",
1024
+ height: "20px",
1025
+ fill: "currentColor"
1026
+ },
1027
+ grid: {
1028
+ width: "100%",
1029
+ borderCollapse: "collapse",
1030
+ tableLayout: "fixed"
1031
+ },
1032
+ weekday: {
1033
+ height: "32px",
1034
+ padding: 0,
1035
+ fontSize: fontSize[200],
1036
+ fontWeight: fontWeight.regular,
1037
+ color: `var(--slicer-secondary, ${tokens6.colorMutedForeground})`,
1038
+ textAlign: "center",
1039
+ overflowWrap: "anywhere"
1040
+ },
1041
+ day: {
1042
+ padding: 0,
1043
+ width: "36px",
1044
+ height: "36px",
1045
+ textAlign: "center"
1046
+ },
1047
+ dayButton: {
1048
+ display: "block",
1049
+ width: "100%",
1050
+ minWidth: "36px",
1051
+ height: "36px",
1052
+ margin: 0,
1053
+ padding: 0,
1054
+ border: "1px solid transparent",
1055
+ borderRadius: borderRadius.medium,
1056
+ backgroundColor: "transparent",
1057
+ color: "inherit",
1058
+ fontFamily: "inherit",
1059
+ fontSize: "inherit",
1060
+ fontVariantNumeric: "tabular-nums",
1061
+ cursor: "pointer",
1062
+ ':hover:not(:disabled):not([aria-disabled="true"])': {
1063
+ border: `1px solid var(--slicer-link, ${tokens6.colorBrandForeground})`
1064
+ },
1065
+ ":focus-visible": {
1066
+ position: "relative",
1067
+ outline: `2px solid var(--slicer-link, ${tokens6.colorBrandForeground})`,
1068
+ outlineOffset: "1px",
1069
+ zIndex: 1
1070
+ }
1071
+ },
1072
+ disabled: {
1073
+ color: `var(--slicer-secondary, ${tokens6.colorMutedForeground})`,
1074
+ "& button": { cursor: "not-allowed", opacity: 0.5 }
1075
+ },
1076
+ hidden: { visibility: "hidden" },
1077
+ selected: {
1078
+ backgroundColor: `color-mix(in srgb, var(--slicer-brand, ${tokens6.colorBrand}) 15%, var(--slicer-background, ${tokens6.colorBackground}))`,
1079
+ color: `var(--slicer-foreground, ${tokens6.colorForeground})`
1080
+ },
1081
+ rangeStart: {
1082
+ borderStartStartRadius: borderRadius.medium,
1083
+ borderEndStartRadius: borderRadius.medium,
1084
+ "& button": {
1085
+ backgroundColor: `var(--slicer-brand, ${tokens6.colorBrand})`,
1086
+ color: tokens6.colorPrimaryForeground,
1087
+ fontWeight: fontWeight.semibold
1088
+ }
1089
+ },
1090
+ rangeEnd: {
1091
+ borderStartEndRadius: borderRadius.medium,
1092
+ borderEndEndRadius: borderRadius.medium,
1093
+ "& button": {
1094
+ backgroundColor: `var(--slicer-brand, ${tokens6.colorBrand})`,
1095
+ color: tokens6.colorPrimaryForeground,
1096
+ fontWeight: fontWeight.semibold
1097
+ }
1098
+ },
1099
+ today: {
1100
+ "& button": { textDecorationLine: "underline", textUnderlineOffset: "3px" }
1101
+ }
1102
+ }));
1103
+
1104
+ // src/components/date-slicer/date-slicer-navigation.tsx
1105
+ import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
1106
+ function DateSlicerNavigation({
1107
+ label,
1108
+ pickLabel,
1109
+ previousLabel,
1110
+ nextLabel,
1111
+ canGoPrevious,
1112
+ canGoNext,
1113
+ onPrevious,
1114
+ onNext,
1115
+ onPick,
1116
+ headerRef
1117
+ }) {
1118
+ const styles = useDateSlicerStyles();
1119
+ return /* @__PURE__ */ jsxs5("nav", { className: styles.navigation, "aria-label": getString5("DateSlicer_CalendarNavigation"), children: [
1120
+ /* @__PURE__ */ jsx7(
1121
+ "button",
1122
+ {
1123
+ type: "button",
1124
+ className: styles.navigationButton,
1125
+ "aria-label": previousLabel,
1126
+ "aria-disabled": !canGoPrevious || void 0,
1127
+ tabIndex: canGoPrevious ? void 0 : -1,
1128
+ onClick: canGoPrevious ? onPrevious : void 0,
1129
+ children: /* @__PURE__ */ jsx7(Chevron, { className: styles.chevron, orientation: "left" })
1130
+ }
1131
+ ),
1132
+ /* @__PURE__ */ jsx7(
1133
+ "button",
1134
+ {
1135
+ ref: headerRef,
1136
+ type: "button",
1137
+ className: mergeClasses(styles.navigationButton, styles.windowButton),
1138
+ title: pickLabel,
1139
+ "aria-label": formatString5("DateSlicer_ViewLabel", label, pickLabel),
1140
+ onClick: onPick,
1141
+ children: label
1142
+ }
1143
+ ),
1144
+ /* @__PURE__ */ jsx7(
1145
+ "button",
1146
+ {
1147
+ type: "button",
1148
+ className: styles.navigationButton,
1149
+ "aria-label": nextLabel,
1150
+ "aria-disabled": !canGoNext || void 0,
1151
+ tabIndex: canGoNext ? void 0 : -1,
1152
+ onClick: canGoNext ? onNext : void 0,
1153
+ children: /* @__PURE__ */ jsx7(Chevron, { className: styles.chevron, orientation: "right" })
1154
+ }
1155
+ )
1156
+ ] });
1157
+ }
1158
+
1159
+ // src/components/date-slicer/date-slicer-period-grid.tsx
1160
+ import { useCallback as useCallback5, useMemo as useMemo4, useState as useState4 } from "react";
1161
+ import { compareCalendarDates as compareCalendarDates2 } from "@microsoft/fabric-visuals-core";
1162
+
1163
+ // src/components/date-slicer/date-slicer-utils.ts
1164
+ import { UTCDate } from "@date-fns/utc";
1165
+ import { compareCalendarDates, formatCalendarDate, formatString as formatString6, formatValue as formatValue2, getString as getString6, isValidCalendarDate, parseCalendarDate } from "@microsoft/fabric-visuals-core";
1166
+ var dateSlicerPresetLabels = {
1167
+ last7Days: "DateSlicer_Last7Days",
1168
+ last30Days: "DateSlicer_Last30Days",
1169
+ monthToDate: "DateSlicer_MonthToDate",
1170
+ lastMonth: "DateSlicer_LastMonth",
1171
+ quarterToDate: "DateSlicer_QuarterToDate",
1172
+ lastQuarter: "DateSlicer_LastQuarter",
1173
+ yearToDate: "DateSlicer_YearToDate"
1174
+ };
1175
+ function isValidRange(range) {
1176
+ return range.every((date) => isValidCalendarDate(date.year, date.month, date.day)) && compareCalendarDates(range[0], range[1]) <= 0;
1177
+ }
1178
+ function dateRangesEqual(first, second) {
1179
+ if (first && second) {
1180
+ return compareCalendarDates(first[0], second[0]) === 0 && compareCalendarDates(first[1], second[1]) === 0;
1181
+ }
1182
+ return first === second;
1183
+ }
1184
+ function intersectDateRanges(domain, selection) {
1185
+ if (domain && selection) {
1186
+ const start = compareCalendarDates(domain[0], selection[0]) > 0 ? domain[0] : selection[0];
1187
+ const end = compareCalendarDates(domain[1], selection[1]) < 0 ? domain[1] : selection[1];
1188
+ if (compareCalendarDates(start, end) <= 0) return [start, end];
1189
+ }
1190
+ return void 0;
1191
+ }
1192
+ function toDayPickerDate(date) {
1193
+ const calendarDate = new UTCDate(0);
1194
+ calendarDate.setFullYear(date.year, date.month - 1, date.day);
1195
+ return calendarDate;
1196
+ }
1197
+ function toCalendarDate(date) {
1198
+ return { year: date.getFullYear(), month: date.getMonth() + 1, day: date.getDate() };
1199
+ }
1200
+ function localToday() {
1201
+ return toCalendarDate(/* @__PURE__ */ new Date());
1202
+ }
1203
+ function monthIndex(date) {
1204
+ return date.year * 12 + date.month - 1;
1205
+ }
1206
+ function calendarMonthFromIndex(index) {
1207
+ return { year: Math.floor(index / 12), month: index % 12 + 1, day: 1 };
1208
+ }
1209
+ function datePeriodRange(date, period) {
1210
+ const firstMonth = period === "year" ? 1 : date.month;
1211
+ const lastMonth = period === "year" ? 12 : date.month;
1212
+ return [
1213
+ { year: date.year, month: firstMonth, day: 1 },
1214
+ normalizeCalendarDate(date.year, lastMonth + 1, 0)
1215
+ ];
1216
+ }
1217
+ function dateSummary(day, columnFormat) {
1218
+ if (columnFormat?.trim()) {
1219
+ const normalizedFormat = columnFormat.trim().toLowerCase();
1220
+ let dateFormat = columnFormat;
1221
+ if (normalizedFormat === "short date" || normalizedFormat === "general date") {
1222
+ dateFormat = "m/d/yyyy";
1223
+ } else if (normalizedFormat === "long date") {
1224
+ dateFormat = "dddd, mmmm d, yyyy";
1225
+ }
1226
+ return String(formatValue2(toDayPickerDate(day), dateFormat));
1227
+ }
1228
+ return formatString6("DateSlicer_DateSummary", day.month, day.day, String(day.year).padStart(4, "0"));
1229
+ }
1230
+ function parseSelectionDate(value) {
1231
+ if (typeof value === "string" && /^\d{4}-\d{2}-\d{2}$/.test(value)) {
1232
+ return parseCalendarDate(value);
1233
+ }
1234
+ return void 0;
1235
+ }
1236
+ function readHostSelection(selection) {
1237
+ if (selection === void 0 || selection === null) return { range: selection };
1238
+ if (Array.isArray(selection) && selection.length === 2) {
1239
+ const start = parseSelectionDate(selection[0]);
1240
+ const end = parseSelectionDate(selection[1]);
1241
+ if (start && end && compareCalendarDates(start, end) <= 0) return { range: [start, end] };
1242
+ }
1243
+ return { error: getString6("DateSlicer_InvalidSelection") };
1244
+ }
1245
+ function createDateRangePredicate(range, column, dataType) {
1246
+ const startDate = formatCalendarDate(range[0]);
1247
+ if (dataType === "datetime") {
1248
+ const endDate = range[1];
1249
+ let nextDay;
1250
+ if (isValidCalendarDate(endDate.year, endDate.month, endDate.day + 1)) {
1251
+ nextDay = { ...endDate, day: endDate.day + 1 };
1252
+ } else if (endDate.month < 12) {
1253
+ nextDay = { year: endDate.year, month: endDate.month + 1, day: 1 };
1254
+ } else if (endDate.year < 9999) {
1255
+ nextDay = { year: endDate.year + 1, month: 1, day: 1 };
1256
+ }
1257
+ return {
1258
+ type: "range",
1259
+ fieldId: column,
1260
+ min: { kind: "value", value: `${startDate}T00:00:00` },
1261
+ ...nextDay ? { max: { kind: "value", value: `${formatCalendarDate(nextDay)}T00:00:00`, inclusive: false } } : {}
1262
+ };
1263
+ }
1264
+ return {
1265
+ type: "range",
1266
+ fieldId: column,
1267
+ min: { kind: "value", value: startDate },
1268
+ max: { kind: "value", value: formatCalendarDate(range[1]) }
1269
+ };
1270
+ }
1271
+ function normalizeCalendarDate(year, month, day) {
1272
+ const date = /* @__PURE__ */ new Date(0);
1273
+ date.setUTCFullYear(year, month - 1, day);
1274
+ return { year: date.getUTCFullYear(), month: date.getUTCMonth() + 1, day: date.getUTCDate() };
1275
+ }
1276
+ function resolveDatePreset(preset, today, domain) {
1277
+ if (domain) {
1278
+ const { year, month, day } = today;
1279
+ const quarterStartMonth = Math.floor((month - 1) / 3) * 3 + 1;
1280
+ let range;
1281
+ switch (preset) {
1282
+ case "last7Days":
1283
+ range = [normalizeCalendarDate(year, month, day - 6), today];
1284
+ break;
1285
+ case "last30Days":
1286
+ range = [normalizeCalendarDate(year, month, day - 29), today];
1287
+ break;
1288
+ case "monthToDate":
1289
+ range = [{ year, month, day: 1 }, today];
1290
+ break;
1291
+ case "lastMonth":
1292
+ range = [normalizeCalendarDate(year, month - 1, 1), normalizeCalendarDate(year, month, 0)];
1293
+ break;
1294
+ case "quarterToDate":
1295
+ range = [{ year, month: quarterStartMonth, day: 1 }, today];
1296
+ break;
1297
+ case "lastQuarter":
1298
+ range = [normalizeCalendarDate(year, quarterStartMonth - 3, 1), normalizeCalendarDate(year, quarterStartMonth, 0)];
1299
+ break;
1300
+ case "yearToDate":
1301
+ range = [{ year, month: 1, day: 1 }, today];
1302
+ break;
1303
+ }
1304
+ return intersectDateRanges(domain, range);
1305
+ }
1306
+ return void 0;
1307
+ }
1308
+
1309
+ // src/components/date-slicer/date-slicer-period-grid.tsx
1310
+ import { jsx as jsx8 } from "react/jsx-runtime";
1311
+ function DateSlicerPeriodGrid({ label, cells, columns, unit, domain, selected, onActivate }) {
1312
+ const styles = useDateSlicerStyles();
1313
+ const [focusedIndex, setFocusedIndex] = useState4(null);
1314
+ const periods = useMemo4(() => cells.map((cell) => {
1315
+ const range = datePeriodRange(cell.date, unit);
1316
+ const boundedRange = intersectDateRanges(domain, range);
1317
+ const isSelected = Boolean(boundedRange && selected && compareCalendarDates2(selected[0], boundedRange[0]) <= 0 && compareCalendarDates2(selected[1], boundedRange[1]) >= 0);
1318
+ const isEndpoint = Boolean(isSelected && boundedRange && selected && (compareCalendarDates2(selected[0], boundedRange[0]) === 0 || compareCalendarDates2(selected[1], boundedRange[1]) === 0));
1319
+ return { ...cell, range, isDisabled: !boundedRange, isSelected, isEndpoint };
1320
+ }), [cells, unit, domain, selected]);
1321
+ const firstSelectedIndex = periods.findIndex((period) => period.isSelected);
1322
+ const firstEnabledIndex = periods.findIndex((period) => !period.isDisabled);
1323
+ const activeIndex = focusedIndex !== null && periods[focusedIndex] && !periods[focusedIndex].isDisabled ? focusedIndex : firstSelectedIndex >= 0 ? firstSelectedIndex : firstEnabledIndex;
1324
+ const handleClick = useCallback5((event) => {
1325
+ const period = periods[Number(event.currentTarget.value)];
1326
+ if (!period.isDisabled) onActivate(period.range, unit);
1327
+ }, [periods, unit, onActivate]);
1328
+ const handleFocus = useCallback5((event) => {
1329
+ setFocusedIndex(Number(event.currentTarget.value));
1330
+ }, []);
1331
+ const handleKeyDown = useCallback5((event) => {
1332
+ if (event.target instanceof HTMLButtonElement) {
1333
+ const index = Number(event.target.value);
1334
+ let nextIndex = index;
1335
+ let step = 1;
1336
+ switch (event.key) {
1337
+ case "ArrowLeft":
1338
+ step = -1;
1339
+ nextIndex -= 1;
1340
+ break;
1341
+ case "ArrowRight":
1342
+ nextIndex += 1;
1343
+ break;
1344
+ case "ArrowUp":
1345
+ step = -columns;
1346
+ nextIndex -= columns;
1347
+ break;
1348
+ case "ArrowDown":
1349
+ step = columns;
1350
+ nextIndex += columns;
1351
+ break;
1352
+ case "Home":
1353
+ nextIndex = event.ctrlKey ? 0 : Math.floor(index / columns) * columns;
1354
+ break;
1355
+ case "End":
1356
+ step = -1;
1357
+ nextIndex = event.ctrlKey ? periods.length - 1 : Math.min(periods.length - 1, Math.floor(index / columns) * columns + columns - 1);
1358
+ break;
1359
+ default:
1360
+ return;
1361
+ }
1362
+ event.preventDefault();
1363
+ while (nextIndex >= 0 && nextIndex < periods.length && periods[nextIndex].isDisabled) nextIndex += step;
1364
+ if (nextIndex >= 0 && nextIndex < periods.length) {
1365
+ event.currentTarget.querySelector(`button[value="${nextIndex}"]`)?.focus();
1366
+ }
1367
+ }
1368
+ }, [columns, periods]);
1369
+ return /* @__PURE__ */ jsx8("table", { className: styles.periodGrid, role: "grid", "aria-label": label, "aria-multiselectable": true, onKeyDown: handleKeyDown, children: /* @__PURE__ */ jsx8("tbody", { children: Array.from({ length: Math.ceil(periods.length / columns) }, (_, row) => /* @__PURE__ */ jsx8("tr", { role: "row", children: periods.slice(row * columns, (row + 1) * columns).map((period, column) => {
1370
+ const index = row * columns + column;
1371
+ return /* @__PURE__ */ jsx8("td", { role: "gridcell", "aria-selected": period.isSelected, children: /* @__PURE__ */ jsx8(
1372
+ "button",
1373
+ {
1374
+ type: "button",
1375
+ value: index,
1376
+ className: mergeClasses(styles.periodButton, period.isSelected && styles.selectedPeriod, period.isEndpoint && styles.periodEndpoint),
1377
+ "aria-label": period.accessibleLabel,
1378
+ disabled: period.isDisabled,
1379
+ tabIndex: index === activeIndex ? 0 : -1,
1380
+ onFocus: handleFocus,
1381
+ onClick: handleClick,
1382
+ children: period.label
1383
+ }
1384
+ ) }, period.accessibleLabel);
1385
+ }) }, row)) }) });
1386
+ }
1387
+
1388
+ // src/components/date-slicer/date-slicer-calendar.tsx
1389
+ import { jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
1390
+ var calendarFormatters = {
1391
+ formatCaption: (date) => formatMonthDropdown(date)
1392
+ };
1393
+ var yearPageSize = 12;
1394
+ function yearLabel(year) {
1395
+ return String(year).padStart(4, "0");
1396
+ }
1397
+ function yearWindowLabel(first, last) {
1398
+ return first === last ? yearLabel(first) : formatString7("DateSlicer_YearWindow", yearLabel(first), yearLabel(last));
1399
+ }
1400
+ function monthWindowLabel(firstMonth, count) {
1401
+ const first = calendarMonthFromIndex(firstMonth);
1402
+ const last = calendarMonthFromIndex(firstMonth + count - 1);
1403
+ const firstName = formatMonthDropdown(toDayPickerDate(first));
1404
+ const lastName = formatMonthDropdown(toDayPickerDate(last));
1405
+ if (count === 1) return formatString7("DateSlicer_MonthYear", firstName, yearLabel(first.year));
1406
+ return first.year === last.year ? formatString7("DateSlicer_MonthWindow", firstName, lastName, yearLabel(first.year)) : formatString7("DateSlicer_CrossYearWindow", firstName, yearLabel(first.year), lastName, yearLabel(last.year));
1407
+ }
1408
+ function DateSlicerCalendar(props) {
1409
+ const hasValidRanges = isValidRange(props.domain) && (!props.selected || isValidRange(props.selected));
1410
+ if (hasValidRanges) {
1411
+ const numberOfMonths = props.numberOfMonths ?? 3;
1412
+ const hasValidMonthCount = Number.isSafeInteger(numberOfMonths) && numberOfMonths > 0;
1413
+ const domainMonthKey = `${monthIndex(props.domain[0])}:${monthIndex(props.domain[1])}`;
1414
+ return /* @__PURE__ */ jsx9(BoundedDateCalendar, { ...props, numberOfMonths: hasValidMonthCount ? numberOfMonths : 3 }, domainMonthKey);
1415
+ }
1416
+ return /* @__PURE__ */ jsx9("div", { role: "alert", children: getString7("DateSlicer_InvalidCalendarRange") });
1417
+ }
1418
+ function BoundedDateCalendar({
1419
+ domain,
1420
+ selected,
1421
+ numberOfMonths = 3,
1422
+ theme,
1423
+ onDayActivate,
1424
+ onPeriodActivate
1425
+ }) {
1426
+ const styles = useDateSlicerStyles();
1427
+ const today = localToday();
1428
+ const firstDomainMonth = monthIndex(domain[0]);
1429
+ const lastDomainMonth = monthIndex(domain[1]);
1430
+ const visibleMonthCount = Math.min(numberOfMonths, lastDomainMonth - firstDomainMonth + 1);
1431
+ const lastWindowMonth = lastDomainMonth - visibleMonthCount + 1;
1432
+ const initialMonth = Math.max(firstDomainMonth, Math.min(monthIndex(selected?.[0] ?? today), lastDomainMonth));
1433
+ const [view, setView] = useState5("days");
1434
+ const [browsedMonth, setBrowsedMonth] = useState5(initialMonth);
1435
+ const firstMonth = Math.min(browsedMonth, lastWindowMonth);
1436
+ const browsedYear = Math.floor(browsedMonth / 12);
1437
+ const yearPageStart = Math.floor(browsedYear / yearPageSize) * yearPageSize;
1438
+ const headerRef = useRef4(null);
1439
+ const columnCount = view === "days" ? visibleMonthCount : 1;
1440
+ const calendarStyle = useMemo5(() => ({
1441
+ ...slicerThemeStyle(theme),
1442
+ "--date-month-count": columnCount
1443
+ }), [theme, columnCount]);
1444
+ const displayedMonth = useMemo5(() => toDayPickerDate(calendarMonthFromIndex(firstMonth)), [firstMonth]);
1445
+ const handleMonthChange = useCallback6((month) => {
1446
+ setBrowsedMonth(Math.max(firstDomainMonth, Math.min(monthIndex(toCalendarDate(month)), lastWindowMonth)));
1447
+ }, [firstDomainMonth, lastWindowMonth]);
1448
+ const navigate = useCallback6((direction) => {
1449
+ const startMonth = view === "days" ? firstMonth : view === "months" ? browsedMonth : yearPageStart * 12;
1450
+ const stepMonths = view === "days" ? 1 : view === "months" ? 12 : yearPageSize * 12;
1451
+ const lastMonth = view === "days" ? lastWindowMonth : lastDomainMonth;
1452
+ setBrowsedMonth(Math.max(firstDomainMonth, Math.min(startMonth + direction * stepMonths, lastMonth)));
1453
+ }, [view, firstMonth, browsedMonth, yearPageStart, firstDomainMonth, lastWindowMonth, lastDomainMonth]);
1454
+ const handlePrevious = useCallback6(() => navigate(-1), [navigate]);
1455
+ const handleNext = useCallback6(() => navigate(1), [navigate]);
1456
+ const handlePick = useCallback6(() => {
1457
+ setView(view === "months" ? "years" : "months");
1458
+ }, [view]);
1459
+ const handlePeriodActivate = useCallback6((range, unit) => {
1460
+ const completedRange = onPeriodActivate?.(range, unit);
1461
+ if (completedRange) {
1462
+ setBrowsedMonth(Math.max(firstDomainMonth, Math.min(monthIndex(completedRange[0]), lastDomainMonth)));
1463
+ setView(unit === "year" ? "months" : "days");
1464
+ headerRef.current?.focus();
1465
+ }
1466
+ }, [onPeriodActivate, firstDomainMonth, lastDomainMonth]);
1467
+ const monthCells = useMemo5(() => Array.from(
1468
+ { length: 12 },
1469
+ (_, month) => {
1470
+ const date = { year: browsedYear, month: month + 1, day: 1 };
1471
+ return {
1472
+ date,
1473
+ label: defaultDateLib.format(toDayPickerDate(date), "LLL"),
1474
+ accessibleLabel: formatString7("DateSlicer_MonthYear", formatMonthDropdown(toDayPickerDate(date)), yearLabel(browsedYear))
1475
+ };
1476
+ }
1477
+ ), [browsedYear]);
1478
+ const yearCells = useMemo5(() => Array.from(
1479
+ { length: Math.min(yearPageSize, 1e4 - yearPageStart) },
1480
+ (_, offset) => {
1481
+ const year = yearPageStart + offset;
1482
+ return { date: { year, month: 1, day: 1 }, label: yearLabel(year), accessibleLabel: yearLabel(year) };
1483
+ }
1484
+ ), [yearPageStart]);
1485
+ const windowLabel = view === "days" ? monthWindowLabel(firstMonth, visibleMonthCount) : view === "months" ? yearLabel(browsedYear) : yearWindowLabel(yearPageStart, yearPageStart + yearCells.length - 1);
1486
+ const canGoPrevious = view === "days" ? firstMonth > firstDomainMonth : view === "months" ? browsedYear > domain[0].year : yearPageStart > domain[0].year;
1487
+ const canGoNext = view === "days" ? firstMonth < lastWindowMonth : view === "months" ? browsedYear < domain[1].year : yearPageStart + yearPageSize <= domain[1].year;
1488
+ const [minimumDay, maximumDay] = domain;
1489
+ const lowerDate = useMemo5(() => toDayPickerDate(minimumDay), [minimumDay]);
1490
+ const upperDate = useMemo5(() => toDayPickerDate(maximumDay), [maximumDay]);
1491
+ const disabledDays = useMemo5(() => [{ before: lowerDate }, { after: upperDate }], [lowerDate, upperDate]);
1492
+ const handleDayClick = useCallback6((date, modifiers) => {
1493
+ const day = toCalendarDate(date);
1494
+ const isWithinDomain = compareCalendarDates3(day, minimumDay) >= 0 && compareCalendarDates3(day, maximumDay) <= 0;
1495
+ if (!modifiers.disabled && isWithinDomain) {
1496
+ onDayActivate?.(day);
1497
+ }
1498
+ }, [minimumDay, maximumDay, onDayActivate]);
1499
+ const selectedStart = selected?.[0];
1500
+ const selectedEnd = selected?.[1];
1501
+ const calendarModifiers = useMemo5(() => {
1502
+ if (selectedStart && selectedEnd) {
1503
+ const from = toDayPickerDate(selectedStart);
1504
+ const to = toDayPickerDate(selectedEnd);
1505
+ return {
1506
+ selected: { from, to },
1507
+ range_start: from,
1508
+ range_end: to
1509
+ };
1510
+ }
1511
+ return {};
1512
+ }, [selectedStart, selectedEnd]);
1513
+ const calendarClassNames = useMemo5(() => ({
1514
+ root: styles.dayPickerRoot,
1515
+ months: styles.months,
1516
+ month: styles.month,
1517
+ month_caption: visibleMonthCount === 1 ? styles.hiddenCaption : styles.caption,
1518
+ caption_label: styles.captionLabel,
1519
+ month_grid: styles.grid,
1520
+ weekday: styles.weekday,
1521
+ day: styles.day,
1522
+ day_button: styles.dayButton,
1523
+ disabled: styles.disabled,
1524
+ hidden: styles.hidden,
1525
+ selected: styles.selected,
1526
+ range_start: styles.rangeStart,
1527
+ range_end: styles.rangeEnd,
1528
+ today: styles.today
1529
+ }), [styles, visibleMonthCount]);
1530
+ return /* @__PURE__ */ jsxs6("div", { className: styles.root, style: calendarStyle, children: [
1531
+ /* @__PURE__ */ jsx9(
1532
+ DateSlicerNavigation,
1533
+ {
1534
+ label: windowLabel,
1535
+ pickLabel: getString7(view === "days" ? "DateSlicer_PickByMonth" : view === "months" ? "DateSlicer_PickByYear" : "DateSlicer_BackToMonths"),
1536
+ previousLabel: getString7(view === "days" ? "DateSlicer_PreviousMonth" : view === "months" ? "DateSlicer_PreviousYear" : "DateSlicer_PreviousYears"),
1537
+ nextLabel: getString7(view === "days" ? "DateSlicer_NextMonth" : view === "months" ? "DateSlicer_NextYear" : "DateSlicer_NextYears"),
1538
+ canGoPrevious,
1539
+ canGoNext,
1540
+ onPrevious: handlePrevious,
1541
+ onNext: handleNext,
1542
+ onPick: handlePick,
1543
+ headerRef
1544
+ }
1545
+ ),
1546
+ view === "days" ? /* @__PURE__ */ jsx9(
1547
+ DayPicker,
1548
+ {
1549
+ hideNavigation: true,
1550
+ formatters: calendarFormatters,
1551
+ classNames: calendarClassNames,
1552
+ today: toDayPickerDate(today),
1553
+ month: displayedMonth,
1554
+ onMonthChange: handleMonthChange,
1555
+ startMonth: lowerDate,
1556
+ endMonth: upperDate,
1557
+ numberOfMonths: visibleMonthCount,
1558
+ disabled: disabledDays,
1559
+ modifiers: calendarModifiers,
1560
+ onDayClick: handleDayClick
1561
+ }
1562
+ ) : /* @__PURE__ */ jsx9(
1563
+ DateSlicerPeriodGrid,
1564
+ {
1565
+ label: view === "months" ? formatString7("DateSlicer_MonthsInYear", yearLabel(browsedYear)) : formatString7("DateSlicer_YearsInWindow", windowLabel),
1566
+ cells: view === "months" ? monthCells : yearCells,
1567
+ columns: view === "months" ? 3 : 4,
1568
+ unit: view === "months" ? "month" : "year",
1569
+ domain,
1570
+ selected,
1571
+ onActivate: handlePeriodActivate
1572
+ },
1573
+ `${view}:${view === "months" ? browsedYear : yearPageStart}`
1574
+ )
1575
+ ] });
1576
+ }
1577
+
1578
+ // src/components/date-slicer/date-slicer-data.ts
1579
+ import { compareCalendarDates as compareCalendarDates4, formatString as formatString8, getString as getString8, isDateFormat, parseCalendarDate as parseCalendarDate2 } from "@microsoft/fabric-visuals-core";
1580
+ function isDateColumnFormat(format) {
1581
+ const normalizedFormat = format.trim().toLowerCase();
1582
+ return normalizedFormat === "short date" || normalizedFormat === "long date" || normalizedFormat === "general date" || isDateFormat(format);
1583
+ }
1584
+ function readDateSlicerData(data, column) {
1585
+ const columnIndex = data.columns.findIndex((definition2) => definition2.name === column);
1586
+ if (columnIndex < 0) {
1587
+ return { title: column, format: void 0, domain: null, error: formatString8("Common_ColumnNotFound", column) };
1588
+ }
1589
+ const definition = data.columns[columnIndex];
1590
+ const metadata = { title: definition.displayName ?? definition.name, format: definition.format };
1591
+ if (definition.format?.trim() && !isDateColumnFormat(definition.format)) {
1592
+ return { ...metadata, domain: null, error: getString8("DateSlicer_NonDateFormat") };
1593
+ }
1594
+ let minimumDate;
1595
+ let maximumDate;
1596
+ for (const row of data.rows) {
1597
+ const value = row[columnIndex];
1598
+ if (value === null || value === void 0 || typeof value === "string" && value.trim() === "") continue;
1599
+ const calendarDate = typeof value === "string" ? parseCalendarDate2(value) : void 0;
1600
+ if (calendarDate === void 0) {
1601
+ return { ...metadata, domain: null, error: getString8("DateSlicer_InvalidDateValues") };
1602
+ }
1603
+ if (minimumDate === void 0 || compareCalendarDates4(calendarDate, minimumDate) < 0) minimumDate = calendarDate;
1604
+ if (maximumDate === void 0 || compareCalendarDates4(calendarDate, maximumDate) > 0) maximumDate = calendarDate;
1605
+ }
1606
+ if (minimumDate !== void 0 && maximumDate !== void 0) {
1607
+ return { ...metadata, domain: [minimumDate, maximumDate] };
1608
+ }
1609
+ return { ...metadata, domain: null, error: getString8("DateSlicer_NoDateValues") };
1610
+ }
1611
+
1612
+ // src/components/date-slicer/date-slicer-dropdown-styles.ts
1613
+ import { makeStyles as makeStyles7 } from "@griffel/react";
1614
+ import { borderRadius as borderRadius2, fontWeight as fontWeight2, inVisualsLayer as inVisualsLayer7, spacing as spacing2, tokens as tokens7 } from "@microsoft/fabric-visuals-core";
1615
+ var useDateSlicerDropdownStyles = makeStyles7(inVisualsLayer7({
1616
+ dateTrigger: {
1617
+ ":disabled": { opacity: 0.5, cursor: "default", backgroundColor: "transparent" }
1618
+ },
1619
+ // Only remove the button's frame. The popup is rendered separately and still needs a background and border.
1620
+ framelessTrigger: {
1621
+ border: "none",
1622
+ borderRadius: 0,
1623
+ paddingInline: 0,
1624
+ backgroundColor: "transparent"
1625
+ },
1626
+ datePopover: {
1627
+ width: "max-content",
1628
+ // Limit the whole picker, including shortcuts, to the space Radix finds above or below the button.
1629
+ "& > div": { maxHeight: "min(70vh, 640px, var(--radix-popover-content-available-height))" },
1630
+ "@media (max-width: 600px)": {
1631
+ width: "calc(100vw - 16px)"
1632
+ }
1633
+ },
1634
+ picker: {
1635
+ display: "flex",
1636
+ alignItems: "stretch",
1637
+ minWidth: 0,
1638
+ maxWidth: "100%",
1639
+ padding: spacing2.m,
1640
+ gap: spacing2.m,
1641
+ border: `1px solid var(--slicer-stroke, ${tokens7.colorBorder})`,
1642
+ borderRadius: `var(--slicer-radius, ${tokens7.radiusXl})`,
1643
+ backgroundColor: `var(--slicer-background, ${tokens7.colorBackground})`,
1644
+ // Presets and stacked months share one collision-aware scroll area.
1645
+ overflow: "auto",
1646
+ overscrollBehavior: "contain",
1647
+ boxSizing: "border-box",
1648
+ "@media (max-width: 600px)": {
1649
+ flexDirection: "column",
1650
+ gap: spacing2.s
1651
+ }
1652
+ },
1653
+ calendarContainer: {
1654
+ minWidth: "252px",
1655
+ flexGrow: 1
1656
+ },
1657
+ presets: {
1658
+ display: "flex",
1659
+ flexDirection: "column",
1660
+ flexShrink: 0,
1661
+ alignItems: "stretch",
1662
+ gap: spacing2.xs,
1663
+ width: "148px",
1664
+ paddingInlineEnd: spacing2.m,
1665
+ borderRight: `1px solid var(--slicer-stroke, ${tokens7.colorBorder})`,
1666
+ "@media (max-width: 600px)": {
1667
+ display: "grid",
1668
+ gridTemplateColumns: "repeat(auto-fit, minmax(112px, 1fr))",
1669
+ width: "auto",
1670
+ paddingInlineEnd: 0,
1671
+ paddingBottom: spacing2.s,
1672
+ borderRight: "none",
1673
+ borderBottom: `1px solid var(--slicer-stroke, ${tokens7.colorBorder})`
1674
+ }
1675
+ },
1676
+ presetButton: {
1677
+ minHeight: "36px",
1678
+ padding: `${spacing2.xs} ${spacing2.s}`,
1679
+ border: "1px solid transparent",
1680
+ borderRadius: borderRadius2.medium,
1681
+ backgroundColor: "transparent",
1682
+ color: "inherit",
1683
+ font: "inherit",
1684
+ textAlign: "start",
1685
+ overflowWrap: "anywhere",
1686
+ cursor: "pointer",
1687
+ ":hover:not(:disabled)": {
1688
+ backgroundColor: `var(--slicer-hover, ${tokens7.colorHover})`
1689
+ },
1690
+ ":focus-visible": {
1691
+ outline: `2px solid var(--slicer-link, ${tokens7.colorBrandForeground})`,
1692
+ outlineOffset: "1px"
1693
+ },
1694
+ ":disabled": {
1695
+ color: `var(--slicer-secondary, ${tokens7.colorMutedForeground})`,
1696
+ opacity: 0.5,
1697
+ cursor: "default"
1698
+ },
1699
+ '&[aria-pressed="true"]': {
1700
+ backgroundColor: `color-mix(in srgb, var(--slicer-brand, ${tokens7.colorBrand}) 15%, var(--slicer-background, ${tokens7.colorBackground}))`,
1701
+ fontWeight: fontWeight2.semibold,
1702
+ border: `1px solid var(--slicer-link, ${tokens7.colorBrandForeground})`
1703
+ }
1704
+ }
1705
+ }));
1706
+
1707
+ // src/components/date-slicer/date-slicer-preset-list.tsx
1708
+ import { useCallback as useCallback7, useState as useState6 } from "react";
1709
+ import { getString as getString9 } from "@microsoft/fabric-visuals-core";
1710
+ import { jsx as jsx10 } from "react/jsx-runtime";
1711
+ var presets = [
1712
+ "last7Days",
1713
+ "last30Days",
1714
+ "monthToDate",
1715
+ "lastMonth",
1716
+ "quarterToDate",
1717
+ "lastQuarter",
1718
+ "yearToDate"
1719
+ ];
1720
+ function DateSlicerPresetButton({ id, label, isDisabled, isSelected, onSelect }) {
1721
+ const styles = useDateSlicerDropdownStyles();
1722
+ const handleClick = useCallback7(() => onSelect(id), [id, onSelect]);
1723
+ return /* @__PURE__ */ jsx10(
1724
+ "button",
1725
+ {
1726
+ type: "button",
1727
+ className: styles.presetButton,
1728
+ disabled: isDisabled,
1729
+ "aria-pressed": isSelected,
1730
+ onClick: handleClick,
1731
+ children: getString9(label)
1732
+ }
1733
+ );
1734
+ }
1735
+ function DateSlicerPresetList({ domain, committedRange, selectedPreset, onSelect }) {
1736
+ const styles = useDateSlicerDropdownStyles();
1737
+ const [today, setToday] = useState6(localToday);
1738
+ const selectPreset = useCallback7((id) => {
1739
+ const currentToday = localToday();
1740
+ setToday(currentToday);
1741
+ const range = resolveDatePreset(id, currentToday, domain);
1742
+ if (range) onSelect(id, range);
1743
+ }, [domain, onSelect]);
1744
+ const hasApplicablePreset = presets.some((id) => resolveDatePreset(id, today, domain) !== void 0);
1745
+ return hasApplicablePreset ? /* @__PURE__ */ jsx10("div", { className: styles.presets, role: "group", "aria-label": getString9("DateSlicer_Presets"), children: presets.map((id) => {
1746
+ const range = resolveDatePreset(id, today, domain);
1747
+ const isSelected = id === selectedPreset && range !== void 0 && dateRangesEqual(range, committedRange);
1748
+ return /* @__PURE__ */ jsx10(
1749
+ DateSlicerPresetButton,
1750
+ {
1751
+ id,
1752
+ label: dateSlicerPresetLabels[id],
1753
+ isDisabled: !range,
1754
+ isSelected,
1755
+ onSelect: selectPreset
1756
+ },
1757
+ id
1758
+ );
1759
+ }) }) : null;
1760
+ }
1761
+
1762
+ // src/components/date-slicer/use-date-selection.ts
1763
+ import { useCallback as useCallback8, useEffect as useEffect3, useMemo as useMemo6, useRef as useRef5, useState as useState7 } from "react";
1764
+ import { compareCalendarDates as compareCalendarDates5 } from "@microsoft/fabric-visuals-core";
1765
+ function useDateSelection(domain, column, disabled, selection, onInteraction, dataType = "date") {
1766
+ const hostSelection = useMemo6(
1767
+ () => readHostSelection(selection),
1768
+ [selection]
1769
+ );
1770
+ const [selectionState, setSelectionState] = useState7({
1771
+ committedRange: hostSelection.range ?? null,
1772
+ draft: null,
1773
+ selectedPreset: null
1774
+ });
1775
+ const selectionRef = useRef5(selectionState);
1776
+ const previousHostRange = useRef5(hostSelection.range);
1777
+ const previousDomain = useRef5(domain);
1778
+ const updateSelection = useCallback8((next) => {
1779
+ selectionRef.current = next;
1780
+ setSelectionState(next);
1781
+ }, []);
1782
+ const cancelDraft = useCallback8(() => {
1783
+ if (selectionRef.current.draft) {
1784
+ updateSelection({ ...selectionRef.current, draft: null });
1785
+ }
1786
+ }, [updateSelection]);
1787
+ useEffect3(() => {
1788
+ if (!dateRangesEqual(previousHostRange.current, hostSelection.range)) {
1789
+ previousHostRange.current = hostSelection.range;
1790
+ if (hostSelection.range !== void 0 && !dateRangesEqual(selectionRef.current.committedRange, hostSelection.range)) {
1791
+ updateSelection({ committedRange: hostSelection.range, draft: null, selectedPreset: null });
1792
+ }
1793
+ }
1794
+ }, [hostSelection.range, updateSelection]);
1795
+ useEffect3(() => {
1796
+ if (!dateRangesEqual(previousDomain.current, domain) || disabled || hostSelection.error) {
1797
+ cancelDraft();
1798
+ }
1799
+ previousDomain.current = domain;
1800
+ }, [domain, disabled, hostSelection.error, cancelDraft]);
1801
+ const commitRange = useCallback8((completedRange, preset) => {
1802
+ if (domain && !disabled && !hostSelection.error) {
1803
+ const isUnchanged = dateRangesEqual(selectionRef.current.committedRange, completedRange);
1804
+ updateSelection({ committedRange: completedRange, draft: null, selectedPreset: preset ?? null });
1805
+ if (isUnchanged) return;
1806
+ const event = {
1807
+ action: "select",
1808
+ selections: [{
1809
+ predicates: [createDateRangePredicate(completedRange, column, dataType)]
1810
+ }]
1811
+ };
1812
+ onInteraction?.([event]);
1813
+ }
1814
+ }, [domain, column, disabled, hostSelection.error, onInteraction, updateSelection, dataType]);
1815
+ const activateRangeEndpoint = useCallback8((range, unit) => {
1816
+ if (domain && !disabled && !hostSelection.error) {
1817
+ const boundedRange = intersectDateRanges(domain, range);
1818
+ if (boundedRange) {
1819
+ const draft2 = selectionRef.current.draft;
1820
+ if (draft2?.unit === unit) {
1821
+ const completedRange = [
1822
+ compareCalendarDates5(draft2.range[0], boundedRange[0]) < 0 ? draft2.range[0] : boundedRange[0],
1823
+ compareCalendarDates5(draft2.range[1], boundedRange[1]) > 0 ? draft2.range[1] : boundedRange[1]
1824
+ ];
1825
+ commitRange(completedRange);
1826
+ return completedRange;
1827
+ } else {
1828
+ updateSelection({
1829
+ committedRange: selectionRef.current.committedRange,
1830
+ draft: { range: boundedRange, unit },
1831
+ selectedPreset: null
1832
+ });
1833
+ }
1834
+ }
1835
+ }
1836
+ return void 0;
1837
+ }, [domain, disabled, hostSelection.error, commitRange, updateSelection]);
1838
+ const activateDay = useCallback8((day) => {
1839
+ activateRangeEndpoint([day, day], "day");
1840
+ }, [activateRangeEndpoint]);
1841
+ const clearSelection = useCallback8(() => {
1842
+ if (domain && !disabled && !hostSelection.error) {
1843
+ updateSelection({ committedRange: null, draft: null, selectedPreset: null });
1844
+ onInteraction?.([{ action: "clear" }]);
1845
+ }
1846
+ }, [domain, disabled, hostSelection.error, onInteraction, updateSelection]);
1847
+ const { committedRange, draft, selectedPreset } = selectionState;
1848
+ return {
1849
+ committedRange,
1850
+ selectedPreset,
1851
+ // Clip only DateSlicerCalendar's highlight; summary and interaction bounds remain intact.
1852
+ displayedRange: intersectDateRanges(domain, draft?.range ?? committedRange),
1853
+ error: hostSelection.error,
1854
+ activateDay,
1855
+ activatePeriod: activateRangeEndpoint,
1856
+ commitRange,
1857
+ cancelDraft,
1858
+ clearSelection
1859
+ };
1860
+ }
1861
+
1862
+ // src/components/date-slicer/date-slicer.tsx
1863
+ import { jsx as jsx11, jsxs as jsxs7 } from "react/jsx-runtime";
1864
+ function DateSlicer(props) {
1865
+ return /* @__PURE__ */ jsx11(DateSlicerContent, { ...props }, props.column);
1866
+ }
1867
+ function DateSlicerContent({
1868
+ data,
1869
+ column,
1870
+ title,
1871
+ theme,
1872
+ disabled = false,
1873
+ displayOptions,
1874
+ onInteraction,
1875
+ selection,
1876
+ dataType = "date"
1877
+ }) {
1878
+ const styles = { ...useSlicerStyles(), ...useDropdownStyles(), ...useDateSlicerDropdownStyles() };
1879
+ const titleId = useId3();
1880
+ const summaryId = useId3();
1881
+ const themeStyle = useMemo7(() => slicerThemeStyle(theme), [theme]);
1882
+ const slicerData = useMemo7(() => readDateSlicerData(data, column), [data, column]);
1883
+ const { committedRange, displayedRange, selectedPreset, error: selectionError, activateDay, activatePeriod, commitRange, cancelDraft, clearSelection } = useDateSelection(
1884
+ slicerData.domain,
1885
+ column,
1886
+ disabled,
1887
+ selection,
1888
+ onInteraction,
1889
+ dataType
1890
+ );
1891
+ const [isOpen, setIsOpen] = useState8(false);
1892
+ const [presetNavigationVersion, setPresetNavigationVersion] = useState8(0);
1893
+ const error = slicerData.error ?? selectionError;
1894
+ const canSelect = slicerData.domain !== null && !disabled && !error;
1895
+ const hideHeader = displayOptions?.hideHeader ?? false;
1896
+ const showPresets = displayOptions?.showPresets ?? true;
1897
+ const displayTitle = title ?? slicerData.title;
1898
+ const summary = committedRange ? selectedPreset ? getString10(dateSlicerPresetLabels[selectedPreset]) : formatString9(
1899
+ "DateSlicer_RangeSummary",
1900
+ dateSummary(committedRange[0], slicerData.format),
1901
+ dateSummary(committedRange[1], slicerData.format)
1902
+ ) : getString10("DateSlicer_AllDates");
1903
+ const handleOpenChange = useCallback9((open) => {
1904
+ setIsOpen(open);
1905
+ if (!open) cancelDraft();
1906
+ }, [cancelDraft]);
1907
+ const handlePresetSelect = useCallback9((preset, range) => {
1908
+ commitRange(range, preset);
1909
+ setPresetNavigationVersion((version) => version + 1);
1910
+ }, [commitRange]);
1911
+ useEffect4(() => {
1912
+ if (!canSelect) handleOpenChange(false);
1913
+ }, [canSelect, handleOpenChange]);
1914
+ return /* @__PURE__ */ jsxs7(
1915
+ "section",
1916
+ {
1917
+ "data-lyra-selection-boundary": "",
1918
+ className: mergeClasses(styles.typography, styles.root),
1919
+ style: themeStyle,
1920
+ "aria-labelledby": hideHeader ? void 0 : titleId,
1921
+ "aria-label": hideHeader ? displayTitle : void 0,
1922
+ children: [
1923
+ !hideHeader && /* @__PURE__ */ jsx11(
1924
+ SlicerHeader,
1925
+ {
1926
+ title: displayTitle,
1927
+ titleId,
1928
+ onClear: committedRange ? clearSelection : void 0,
1929
+ clearDisabled: !canSelect
1930
+ }
1931
+ ),
1932
+ error ? /* @__PURE__ */ jsx11("div", { role: "alert", className: styles.message, children: error }) : /* @__PURE__ */ jsxs7(Popover, { open: isOpen && canSelect, onOpenChange: handleOpenChange, children: [
1933
+ /* @__PURE__ */ jsx11(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs7(
1934
+ "button",
1935
+ {
1936
+ type: "button",
1937
+ className: mergeClasses(styles.trigger, styles.dateTrigger, displayOptions?.frameless && styles.framelessTrigger),
1938
+ disabled: !canSelect,
1939
+ "aria-labelledby": hideHeader ? void 0 : `${titleId} ${summaryId}`,
1940
+ "aria-label": hideHeader ? `${displayTitle} ${summary}` : void 0,
1941
+ children: [
1942
+ /* @__PURE__ */ jsx11(CalendarIcon, { className: styles.icon }),
1943
+ /* @__PURE__ */ jsx11("span", { id: summaryId, className: styles.text, title: summary, children: summary }),
1944
+ /* @__PURE__ */ jsx11(ChevronDownIcon, { className: styles.icon })
1945
+ ]
1946
+ }
1947
+ ) }),
1948
+ /* @__PURE__ */ jsx11(PopoverContent, { className: styles.datePopover, style: themeStyle, "aria-label": displayTitle, avoidCollisions: true, children: slicerData.domain && /* @__PURE__ */ jsxs7("div", { className: styles.picker, children: [
1949
+ showPresets && /* @__PURE__ */ jsx11(
1950
+ DateSlicerPresetList,
1951
+ {
1952
+ domain: slicerData.domain,
1953
+ committedRange,
1954
+ selectedPreset,
1955
+ onSelect: handlePresetSelect
1956
+ }
1957
+ ),
1958
+ /* @__PURE__ */ jsx11("div", { className: styles.calendarContainer, children: /* @__PURE__ */ jsx11(
1959
+ DateSlicerCalendar,
1960
+ {
1961
+ domain: slicerData.domain,
1962
+ selected: displayedRange,
1963
+ numberOfMonths: displayOptions?.numberOfMonths,
1964
+ theme,
1965
+ onDayActivate: activateDay,
1966
+ onPeriodActivate: activatePeriod
1967
+ },
1968
+ `${displayOptions?.numberOfMonths}:${presetNavigationVersion}`
1969
+ ) })
1970
+ ] }) })
1971
+ ] })
1972
+ ]
1973
+ }
1974
+ );
1975
+ }
1976
+
792
1977
  // src/components/range-slicer/range-slicer.tsx
793
- import { useCallback as useCallback8, useId as useId5, useMemo as useMemo6 } from "react";
1978
+ import { useCallback as useCallback13, useId as useId6, useMemo as useMemo10 } from "react";
794
1979
  import { mergeClasses as mergeClasses3 } from "@griffel/react";
795
- import { formatNumericInput, formatString as formatString8, formatValue as formatValue2, getString as getString5, parseNumericInput } from "@microsoft/fabric-visuals-core";
1980
+ import { formatNumericInput, formatString as formatString14, formatValue as formatValue3, getString as getString11, parseNumericInput } from "@microsoft/fabric-visuals-core";
796
1981
 
797
1982
  // src/components/range-slicer/range-slicer-data.ts
798
- import { formatString as formatString4, isDataTable as isDataTable2 } from "@microsoft/fabric-visuals-core";
1983
+ import { formatString as formatString10, isDataTable as isDataTable2 } from "@microsoft/fabric-visuals-core";
799
1984
  var maxAutomaticHistogramBinCount = 24;
800
1985
  function readRangeSlicerData(data, column, includeHistogram = true, binCount) {
801
1986
  const table = isDataTable2(data) ? data : { columns: [{ name: column }], rows: data.map((value) => [value]) };
@@ -807,7 +1992,7 @@ function readRangeSlicerData(data, column, includeHistogram = true, binCount) {
807
1992
  domain: null,
808
1993
  hasOnlyIntegerValues: false,
809
1994
  histogram: [],
810
- error: formatString4("Common_ColumnNotFound", column)
1995
+ error: formatString10("Common_ColumnNotFound", column)
811
1996
  };
812
1997
  }
813
1998
  const definition = table.columns[columnIndex];
@@ -861,25 +2046,25 @@ function getRangePosition(value, domain) {
861
2046
  }
862
2047
 
863
2048
  // src/components/range-slicer/range-slicer-styles.ts
864
- import { makeStyles as makeStyles6, shorthands as shorthands2 } from "@griffel/react";
865
- import { borderRadius, fontFamily as fontFamily2, fontSize, injectDesignTokens as injectDesignTokens2, inVisualsLayer as inVisualsLayer6, lineHeight, spacing, tokens as tokens6 } from "@microsoft/fabric-visuals-core";
866
- injectDesignTokens2();
867
- var useRangeSlicerStyles = makeStyles6(inVisualsLayer6({
2049
+ import { makeStyles as makeStyles8, shorthands as shorthands2 } from "@griffel/react";
2050
+ import { borderRadius as borderRadius3, fontFamily as fontFamily2, fontSize as fontSize2, injectDesignTokens as injectDesignTokens3, inVisualsLayer as inVisualsLayer8, lineHeight, spacing as spacing3, tokens as tokens8 } from "@microsoft/fabric-visuals-core";
2051
+ injectDesignTokens3();
2052
+ var useRangeSlicerStyles = makeStyles8(inVisualsLayer8({
868
2053
  root: {
869
- "--range-foreground": tokens6.colorForeground,
870
- "--range-secondary": tokens6.colorMutedForeground,
871
- "--range-accent": tokens6.colorBrandForeground,
872
- "--range-background": tokens6.colorBackground,
873
- "--range-stroke": tokens6.colorBorder,
874
- "--range-error": tokens6.colorDestructive,
2054
+ "--range-foreground": tokens8.colorForeground,
2055
+ "--range-secondary": tokens8.colorMutedForeground,
2056
+ "--range-accent": tokens8.colorBrandForeground,
2057
+ "--range-background": tokens8.colorBackground,
2058
+ "--range-stroke": tokens8.colorBorder,
2059
+ "--range-error": tokens8.colorDestructive,
875
2060
  display: "flex",
876
2061
  flexDirection: "column",
877
- gap: spacing.s,
2062
+ gap: spacing3.s,
878
2063
  width: "300px",
879
2064
  maxWidth: "100%",
880
2065
  minWidth: 0,
881
2066
  fontFamily: fontFamily2.base,
882
- fontSize: fontSize[300],
2067
+ fontSize: fontSize2[300],
883
2068
  lineHeight: lineHeight[300],
884
2069
  color: "var(--range-foreground)",
885
2070
  "& [data-disabled]": {
@@ -899,9 +2084,9 @@ var useRangeSlicerStyles = makeStyles6(inVisualsLayer6({
899
2084
  },
900
2085
  body: {
901
2086
  boxSizing: "border-box",
902
- padding: spacing.mNudge,
2087
+ padding: spacing3.mNudge,
903
2088
  border: "1px solid var(--range-stroke)",
904
- borderRadius: borderRadius.xLarge,
2089
+ borderRadius: borderRadius3.xLarge,
905
2090
  backgroundColor: "var(--range-background)"
906
2091
  },
907
2092
  framelessBody: {
@@ -913,11 +2098,11 @@ var useRangeSlicerStyles = makeStyles6(inVisualsLayer6({
913
2098
  empty: {
914
2099
  margin: 0,
915
2100
  color: "var(--range-secondary)",
916
- fontSize: fontSize[200]
2101
+ fontSize: fontSize2[200]
917
2102
  },
918
2103
  histogram: {
919
2104
  // Match the track inset so histogram values align with the thumb centers.
920
- marginInline: spacing.m,
2105
+ marginInline: spacing3.m,
921
2106
  height: "40px",
922
2107
  "& svg": {
923
2108
  display: "block",
@@ -936,7 +2121,7 @@ var useRangeSlicerStyles = makeStyles6(inVisualsLayer6({
936
2121
  position: "relative",
937
2122
  display: "flex",
938
2123
  alignItems: "center",
939
- height: spacing.xxl,
2124
+ height: spacing3.xxl,
940
2125
  touchAction: "none",
941
2126
  userSelect: "none",
942
2127
  cursor: "pointer"
@@ -945,24 +2130,23 @@ var useRangeSlicerStyles = makeStyles6(inVisualsLayer6({
945
2130
  position: "relative",
946
2131
  flexGrow: 1,
947
2132
  height: "3px",
948
- marginInline: spacing.m,
2133
+ marginInline: spacing3.m,
949
2134
  backgroundColor: "var(--range-stroke)",
950
- borderRadius: borderRadius.circular,
2135
+ borderRadius: borderRadius3.circular,
951
2136
  forcedColorAdjust: "none"
952
2137
  },
953
2138
  range: {
954
2139
  position: "absolute",
955
2140
  height: "100%",
956
2141
  backgroundColor: "var(--range-accent)",
957
- borderRadius: borderRadius.circular
2142
+ borderRadius: borderRadius3.circular
958
2143
  },
959
2144
  thumb: {
960
2145
  display: "block",
961
2146
  position: "relative",
962
- width: spacing.xxl,
963
- height: spacing.xxl,
964
- borderRadius: borderRadius.circular,
965
- outline: "none",
2147
+ width: spacing3.xxl,
2148
+ height: spacing3.xxl,
2149
+ borderRadius: borderRadius3.circular,
966
2150
  forcedColorAdjust: "none",
967
2151
  // Draw a small visible handle while retaining a larger pointer target.
968
2152
  "::before": {
@@ -970,40 +2154,32 @@ var useRangeSlicerStyles = makeStyles6(inVisualsLayer6({
970
2154
  position: "absolute",
971
2155
  inset: "6px",
972
2156
  border: "1px solid var(--range-accent)",
973
- borderRadius: borderRadius.circular,
2157
+ borderRadius: borderRadius3.circular,
974
2158
  backgroundColor: "var(--range-background)"
975
2159
  },
976
2160
  ":hover::before": {
977
2161
  borderWidth: "2px"
978
- },
979
- ":focus-visible": {
980
- outline: "2px solid var(--range-accent)",
981
- outlineOffset: "1px"
982
2162
  }
983
2163
  },
984
2164
  inputs: {
985
2165
  display: "grid",
986
2166
  gridTemplateColumns: "minmax(0, 1fr) auto minmax(0, 1fr)",
987
2167
  alignItems: "start",
988
- gap: spacing.s
2168
+ gap: spacing3.s
989
2169
  },
990
2170
  input: {
991
2171
  boxSizing: "border-box",
992
2172
  width: "100%",
993
2173
  minWidth: 0,
994
2174
  height: "28px",
995
- paddingInline: spacing.s,
2175
+ paddingInline: spacing3.s,
996
2176
  border: "1px solid var(--range-stroke)",
997
- borderRadius: borderRadius.xLarge,
2177
+ borderRadius: borderRadius3.xLarge,
998
2178
  color: "var(--range-foreground)",
999
2179
  backgroundColor: "var(--range-background)",
1000
2180
  fontFamily: "inherit",
1001
2181
  fontSize: "inherit",
1002
2182
  fontVariantNumeric: "tabular-nums",
1003
- ":focus-visible": {
1004
- outline: "2px solid var(--range-accent)",
1005
- outlineOffset: "1px"
1006
- },
1007
2183
  ":disabled": {
1008
2184
  color: "var(--range-secondary)",
1009
2185
  cursor: "not-allowed"
@@ -1011,37 +2187,36 @@ var useRangeSlicerStyles = makeStyles6(inVisualsLayer6({
1011
2187
  '&[aria-invalid="true"]': {
1012
2188
  ...shorthands2.borderColor("var(--range-error)"),
1013
2189
  color: "var(--range-error)",
1014
- outlineColor: "var(--range-error)",
1015
2190
  boxShadow: "0 0 0 3px color-mix(in srgb, var(--range-error) 20%, transparent)"
1016
2191
  }
1017
2192
  },
1018
2193
  separator: {
1019
2194
  lineHeight: "28px",
1020
- fontSize: fontSize[200],
2195
+ fontSize: fontSize2[200],
1021
2196
  color: "var(--range-secondary)"
1022
2197
  },
1023
2198
  fullRange: {
1024
2199
  margin: 0,
1025
- marginTop: spacing.s,
2200
+ marginTop: spacing3.s,
1026
2201
  color: "var(--range-secondary)",
1027
- fontSize: fontSize[200],
2202
+ fontSize: fontSize2[200],
1028
2203
  lineHeight: lineHeight[200],
1029
2204
  overflowWrap: "anywhere"
1030
2205
  },
1031
2206
  error: {
1032
2207
  display: "block",
1033
- marginTop: spacing.xs,
2208
+ marginTop: spacing3.xs,
1034
2209
  color: "var(--range-error)",
1035
- fontSize: fontSize[300],
2210
+ fontSize: fontSize2[300],
1036
2211
  lineHeight: lineHeight[300],
1037
2212
  overflowWrap: "anywhere"
1038
2213
  }
1039
2214
  }));
1040
2215
 
1041
2216
  // src/components/range-slicer/range-value-input.tsx
1042
- import { useCallback as useCallback5, useId as useId3, useState as useState4 } from "react";
1043
- import { formatString as formatString5 } from "@microsoft/fabric-visuals-core";
1044
- import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
2217
+ import { useCallback as useCallback10, useId as useId4, useState as useState9 } from "react";
2218
+ import { formatString as formatString11 } from "@microsoft/fabric-visuals-core";
2219
+ import { jsx as jsx12, jsxs as jsxs8 } from "react/jsx-runtime";
1045
2220
  function RangeValueInput({
1046
2221
  label,
1047
2222
  value,
@@ -1049,19 +2224,19 @@ function RangeValueInput({
1049
2224
  max,
1050
2225
  disabled,
1051
2226
  descriptionId,
1052
- formatValue: formatValue3,
2227
+ formatValue: formatValue4,
1053
2228
  parseValue,
1054
2229
  onCommit
1055
2230
  }) {
1056
2231
  const styles = useRangeSlicerStyles();
1057
- const errorId = useId3();
1058
- const [draft, setDraft] = useState4();
1059
- const [error, setError] = useState4();
1060
- const handleChange = useCallback5((event) => {
2232
+ const errorId = useId4();
2233
+ const [draft, setDraft] = useState9();
2234
+ const [error, setError] = useState9();
2235
+ const handleChange = useCallback10((event) => {
1061
2236
  setDraft(event.currentTarget.value);
1062
2237
  setError(void 0);
1063
2238
  }, []);
1064
- const handleBlur = useCallback5((event) => {
2239
+ const handleBlur = useCallback10((event) => {
1065
2240
  if (draft === void 0) return;
1066
2241
  const text = event.currentTarget.value.trim();
1067
2242
  const nextValue = parseValue(text);
@@ -1070,10 +2245,10 @@ function RangeValueInput({
1070
2245
  setDraft(void 0);
1071
2246
  setError(void 0);
1072
2247
  } else {
1073
- setError(formatString5("RangeSlicer_InvalidValue", formatValue3(min), formatValue3(max)));
2248
+ setError(formatString11("RangeSlicer_InvalidValue", formatValue4(min), formatValue4(max)));
1074
2249
  }
1075
- }, [draft, min, max, formatValue3, parseValue, onCommit]);
1076
- const handleKeyDown = useCallback5((event) => {
2250
+ }, [draft, min, max, formatValue4, parseValue, onCommit]);
2251
+ const handleKeyDown = useCallback10((event) => {
1077
2252
  if (event.key === "Enter") {
1078
2253
  event.preventDefault();
1079
2254
  event.currentTarget.blur();
@@ -1083,8 +2258,8 @@ function RangeValueInput({
1083
2258
  setError(void 0);
1084
2259
  }
1085
2260
  }, []);
1086
- return /* @__PURE__ */ jsxs5("div", { children: [
1087
- /* @__PURE__ */ jsx7(
2261
+ return /* @__PURE__ */ jsxs8("div", { children: [
2262
+ /* @__PURE__ */ jsx12(
1088
2263
  "input",
1089
2264
  {
1090
2265
  className: styles.input,
@@ -1094,25 +2269,25 @@ function RangeValueInput({
1094
2269
  "aria-describedby": error ? `${descriptionId} ${errorId}` : descriptionId,
1095
2270
  "aria-invalid": Boolean(error),
1096
2271
  disabled,
1097
- value: draft ?? formatValue3(value),
2272
+ value: draft ?? formatValue4(value),
1098
2273
  onChange: handleChange,
1099
2274
  onBlur: handleBlur,
1100
2275
  onKeyDown: handleKeyDown
1101
2276
  }
1102
2277
  ),
1103
- error && /* @__PURE__ */ jsx7("span", { className: styles.error, id: errorId, role: "alert", children: error })
2278
+ error && /* @__PURE__ */ jsx12("span", { className: styles.error, id: errorId, role: "alert", children: error })
1104
2279
  ] });
1105
2280
  }
1106
2281
 
1107
2282
  // src/components/range-slicer/range-histogram.tsx
1108
- import { useId as useId4 } from "react";
1109
- import { formatString as formatString6 } from "@microsoft/fabric-visuals-core";
1110
- import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
2283
+ import { useId as useId5 } from "react";
2284
+ import { formatString as formatString12 } from "@microsoft/fabric-visuals-core";
2285
+ import { jsx as jsx13, jsxs as jsxs9 } from "react/jsx-runtime";
1111
2286
  var histogramWidth = 240;
1112
2287
  var histogramHeight = 40;
1113
2288
  function RangeHistogram({ counts, domain, selectedRange, title }) {
1114
2289
  const styles = useRangeSlicerStyles();
1115
- const clipId = useId4();
2290
+ const clipId = useId5();
1116
2291
  const maximumCount = Math.max(...counts);
1117
2292
  const isFixedRange = domain[0] === domain[1];
1118
2293
  const binWidth = isFixedRange ? 10 : histogramWidth / counts.length;
@@ -1121,11 +2296,11 @@ function RangeHistogram({ counts, domain, selectedRange, title }) {
1121
2296
  const bars = counts.map((count, index) => {
1122
2297
  const height = count / maximumCount * histogramHeight;
1123
2298
  const x = startX + index * binWidth + gap / 2;
1124
- return /* @__PURE__ */ jsx8("rect", { x, y: histogramHeight - height, width: binWidth - gap, height }, x);
2299
+ return /* @__PURE__ */ jsx13("rect", { x, y: histogramHeight - height, width: binWidth - gap, height }, x);
1125
2300
  });
1126
2301
  const selectionStart = isFixedRange ? 0 : getRangePosition(selectedRange[0], domain) * histogramWidth;
1127
2302
  const selectionEnd = isFixedRange ? histogramWidth : getRangePosition(selectedRange[1], domain) * histogramWidth;
1128
- return /* @__PURE__ */ jsx8("div", { className: styles.histogram, children: /* @__PURE__ */ jsxs6(
2303
+ return /* @__PURE__ */ jsx13("div", { className: styles.histogram, children: /* @__PURE__ */ jsxs9(
1129
2304
  "svg",
1130
2305
  {
1131
2306
  width: "100%",
@@ -1133,12 +2308,12 @@ function RangeHistogram({ counts, domain, selectedRange, title }) {
1133
2308
  viewBox: `0 0 ${histogramWidth} ${histogramHeight}`,
1134
2309
  preserveAspectRatio: "none",
1135
2310
  role: "img",
1136
- "aria-label": formatString6("RangeSlicer_DistributionLabel", title),
2311
+ "aria-label": formatString12("RangeSlicer_DistributionLabel", title),
1137
2312
  focusable: "false",
1138
2313
  children: [
1139
- /* @__PURE__ */ jsx8("defs", { children: /* @__PURE__ */ jsx8("clipPath", { id: clipId, children: /* @__PURE__ */ jsx8("rect", { x: selectionStart, y: 0, width: selectionEnd - selectionStart, height: histogramHeight }) }) }),
1140
- /* @__PURE__ */ jsx8("g", { className: styles.histogramMuted, children: bars }),
1141
- /* @__PURE__ */ jsx8("g", { className: styles.histogramSelected, clipPath: `url(#${clipId})`, children: bars })
2314
+ /* @__PURE__ */ jsx13("defs", { children: /* @__PURE__ */ jsx13("clipPath", { id: clipId, children: /* @__PURE__ */ jsx13("rect", { x: selectionStart, y: 0, width: selectionEnd - selectionStart, height: histogramHeight }) }) }),
2315
+ /* @__PURE__ */ jsx13("g", { className: styles.histogramMuted, children: bars }),
2316
+ /* @__PURE__ */ jsx13("g", { className: styles.histogramSelected, clipPath: `url(#${clipId})`, children: bars })
1142
2317
  ]
1143
2318
  }
1144
2319
  ) });
@@ -1146,8 +2321,8 @@ function RangeHistogram({ counts, domain, selectedRange, title }) {
1146
2321
 
1147
2322
  // src/components/range-slicer/range-slider.tsx
1148
2323
  import { Root as Slider, Track, Range, Thumb } from "@radix-ui/react-slider";
1149
- import { useCallback as useCallback6, useMemo as useMemo4, useRef as useRef4 } from "react";
1150
- import { formatString as formatString7 } from "@microsoft/fabric-visuals-core";
2324
+ import { useCallback as useCallback11, useMemo as useMemo8, useRef as useRef6 } from "react";
2325
+ import { formatString as formatString13 } from "@microsoft/fabric-visuals-core";
1151
2326
 
1152
2327
  // src/components/range-slicer/range-slider-steps.ts
1153
2328
  function getAutomaticRangeStep(domain, formatBound = String, hasOnlyIntegerValues = false) {
@@ -1182,7 +2357,7 @@ function hasRepeatedLabels(domain, step, formatBound) {
1182
2357
  }
1183
2358
 
1184
2359
  // src/components/range-slicer/range-slider.tsx
1185
- import { jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
2360
+ import { jsx as jsx14, jsxs as jsxs10 } from "react/jsx-runtime";
1186
2361
  function RangeSlider({
1187
2362
  domain,
1188
2363
  selectedRange,
@@ -1196,13 +2371,13 @@ function RangeSlider({
1196
2371
  onValueCommit
1197
2372
  }) {
1198
2373
  const styles = useRangeSlicerStyles();
1199
- const lowerThumb = useRef4(null);
1200
- const upperThumb = useRef4(null);
1201
- const sliderStep = useMemo4(
2374
+ const lowerThumb = useRef6(null);
2375
+ const upperThumb = useRef6(null);
2376
+ const sliderStep = useMemo8(
1202
2377
  () => step ?? getAutomaticRangeStep(domain, formatBound, hasOnlyIntegerValues),
1203
2378
  [domain, step, formatBound, hasOnlyIntegerValues]
1204
2379
  );
1205
- const handleKeyDown = useCallback6((event) => {
2380
+ const handleKeyDown = useCallback11((event) => {
1206
2381
  const isEndpointKey = event.key === "Home" || event.key === "End";
1207
2382
  if (isEndpointKey && !disabled) {
1208
2383
  let nextRange;
@@ -1218,7 +2393,7 @@ function RangeSlider({
1218
2393
  }
1219
2394
  }
1220
2395
  }, [disabled, selectedRange, domain, onValueChange, onValueCommit]);
1221
- return /* @__PURE__ */ jsxs7(
2396
+ return /* @__PURE__ */ jsxs10(
1222
2397
  Slider,
1223
2398
  {
1224
2399
  className: styles.slider,
@@ -1231,13 +2406,13 @@ function RangeSlider({
1231
2406
  onValueCommit,
1232
2407
  onKeyDown: handleKeyDown,
1233
2408
  children: [
1234
- /* @__PURE__ */ jsx9(Track, { className: styles.track, children: /* @__PURE__ */ jsx9(Range, { className: styles.range }) }),
1235
- /* @__PURE__ */ jsx9(
2409
+ /* @__PURE__ */ jsx14(Track, { className: styles.track, children: /* @__PURE__ */ jsx14(Range, { className: styles.range }) }),
2410
+ /* @__PURE__ */ jsx14(
1236
2411
  Thumb,
1237
2412
  {
1238
2413
  ref: lowerThumb,
1239
2414
  className: styles.thumb,
1240
- "aria-label": formatString7("RangeSlicer_MinimumLabel", title),
2415
+ "aria-label": formatString13("RangeSlicer_MinimumLabel", title),
1241
2416
  "aria-valuemin": domain[0],
1242
2417
  "aria-valuemax": domain[1],
1243
2418
  "aria-valuenow": selectedRange[0],
@@ -1245,12 +2420,12 @@ function RangeSlider({
1245
2420
  "aria-describedby": descriptionId
1246
2421
  }
1247
2422
  ),
1248
- /* @__PURE__ */ jsx9(
2423
+ /* @__PURE__ */ jsx14(
1249
2424
  Thumb,
1250
2425
  {
1251
2426
  ref: upperThumb,
1252
2427
  className: styles.thumb,
1253
- "aria-label": formatString7("RangeSlicer_MaximumLabel", title),
2428
+ "aria-label": formatString13("RangeSlicer_MaximumLabel", title),
1254
2429
  "aria-valuemin": domain[0],
1255
2430
  "aria-valuemax": domain[1],
1256
2431
  "aria-valuenow": selectedRange[1],
@@ -1264,7 +2439,8 @@ function RangeSlider({
1264
2439
  }
1265
2440
 
1266
2441
  // src/components/range-slicer/use-range-selection.ts
1267
- import { useCallback as useCallback7, useEffect as useEffect3, useMemo as useMemo5, useRef as useRef5, useState as useState5 } from "react";
2442
+ import { useCallback as useCallback12, useEffect as useEffect5, useMemo as useMemo9, useRef as useRef7, useState as useState10 } from "react";
2443
+ import debounce from "lodash.debounce";
1268
2444
  function resolveSelection(domain, selection) {
1269
2445
  if (selection) {
1270
2446
  if (Number.isNaN(selection[0]) || Number.isNaN(selection[1]) || selection[0] > selection[1]) {
@@ -1279,15 +2455,28 @@ function resolveSelection(domain, selection) {
1279
2455
  }
1280
2456
  return domain;
1281
2457
  }
1282
- function useRangeSelection(domain, column, onInteraction, selection) {
1283
- const resolvedSelection = useMemo5(() => resolveSelection(domain, selection), [domain, selection]);
1284
- const [selectedRange, setSelectedRange] = useState5(resolvedSelection);
1285
- const lastCommittedRange = useRef5(resolvedSelection);
1286
- const [inputRevision, setInputRevision] = useState5(0);
1287
- const incrementInputRevision = useCallback7(() => {
2458
+ function useRangeSelection(domain, column, onInteraction, selection, disabled = false) {
2459
+ const resolvedSelection = useMemo9(() => resolveSelection(domain, selection), [domain, selection]);
2460
+ const [selectedRange, setSelectedRange] = useState10(resolvedSelection);
2461
+ const lastCommittedRange = useRef7(resolvedSelection);
2462
+ const [inputRevision, setInputRevision] = useState10(0);
2463
+ const latestOnInteraction = useRef7(onInteraction);
2464
+ useEffect5(() => {
2465
+ latestOnInteraction.current = onInteraction;
2466
+ }, [onInteraction]);
2467
+ const debouncedInteraction = useMemo9(() => debounce((events) => {
2468
+ latestOnInteraction.current?.(events);
2469
+ }, 200), []);
2470
+ const domainMinimum = domain?.[0];
2471
+ const domainMaximum = domain?.[1];
2472
+ useEffect5(() => {
2473
+ debouncedInteraction.cancel();
2474
+ return debouncedInteraction.cancel;
2475
+ }, [debouncedInteraction, domainMinimum, domainMaximum, column, selection, disabled]);
2476
+ const incrementInputRevision = useCallback12(() => {
1288
2477
  setInputRevision((revision) => revision + 1);
1289
2478
  }, []);
1290
- useEffect3(() => {
2479
+ useEffect5(() => {
1291
2480
  if (selection !== void 0) {
1292
2481
  const previousRange = lastCommittedRange.current;
1293
2482
  if (previousRange?.[0] === resolvedSelection?.[0] && previousRange?.[1] === resolvedSelection?.[1]) return;
@@ -1296,7 +2485,7 @@ function useRangeSelection(domain, column, onInteraction, selection) {
1296
2485
  incrementInputRevision();
1297
2486
  }
1298
2487
  }, [selection, resolvedSelection, incrementInputRevision]);
1299
- const commitSelectedRange = useCallback7((values) => {
2488
+ const commitSelectedRange = useCallback12((values) => {
1300
2489
  if (domain) {
1301
2490
  setSelectedRange([values[0], values[1]]);
1302
2491
  const previousRange = lastCommittedRange.current;
@@ -1317,20 +2506,20 @@ function useRangeSelection(domain, column, onInteraction, selection) {
1317
2506
  }]
1318
2507
  }]
1319
2508
  };
1320
- onInteraction([event]);
2509
+ debouncedInteraction([event]);
1321
2510
  }
1322
2511
  }
1323
- }, [domain, column, onInteraction]);
1324
- const handleSliderChange = useCallback7((values) => {
2512
+ }, [domain, column, onInteraction, debouncedInteraction]);
2513
+ const handleSliderChange = useCallback12((values) => {
1325
2514
  setSelectedRange([values[0], values[1]]);
1326
2515
  incrementInputRevision();
1327
2516
  }, [incrementInputRevision]);
1328
- const clearSelection = useCallback7(() => {
2517
+ const clearSelection = useCallback12(() => {
1329
2518
  setSelectedRange(domain);
1330
2519
  lastCommittedRange.current = domain;
1331
2520
  incrementInputRevision();
1332
- onInteraction?.([{ action: "clear" }]);
1333
- }, [domain, onInteraction, incrementInputRevision]);
2521
+ if (onInteraction) debouncedInteraction([{ action: "clear" }]);
2522
+ }, [domain, onInteraction, debouncedInteraction, incrementInputRevision]);
1334
2523
  return {
1335
2524
  selectedRange,
1336
2525
  inputRevision,
@@ -1341,7 +2530,7 @@ function useRangeSelection(domain, column, onInteraction, selection) {
1341
2530
  }
1342
2531
 
1343
2532
  // src/components/range-slicer/range-slicer.tsx
1344
- import { Fragment as Fragment2, jsx as jsx10, jsxs as jsxs8 } from "react/jsx-runtime";
2533
+ import { Fragment as Fragment2, jsx as jsx15, jsxs as jsxs11 } from "react/jsx-runtime";
1345
2534
  function RangeSlicer({
1346
2535
  data,
1347
2536
  column,
@@ -1354,28 +2543,29 @@ function RangeSlicer({
1354
2543
  selection
1355
2544
  }) {
1356
2545
  const styles = useRangeSlicerStyles();
1357
- const id = useId5();
2546
+ const id = useId6();
1358
2547
  const titleId = `${id}-title`;
1359
2548
  const descriptionId = `${id}-description`;
1360
2549
  const hideHeader = displayOptions?.hideHeader ?? false;
1361
2550
  const showHistogram = displayOptions?.showHistogram ?? true;
1362
2551
  const binCount = showHistogram ? displayOptions?.binCount : void 0;
1363
- const slicerData = useMemo6(
2552
+ const slicerData = useMemo10(
1364
2553
  () => readRangeSlicerData(data, column, showHistogram, binCount),
1365
2554
  [data, column, showHistogram, binCount]
1366
2555
  );
2556
+ const isFixedRange = slicerData.domain !== null && slicerData.domain[0] === slicerData.domain[1];
2557
+ const areControlsDisabled = disabled || isFixedRange;
1367
2558
  const { selectedRange, inputRevision, handleSliderChange, commitSelectedRange, clearSelection } = useRangeSelection(
1368
2559
  slicerData.domain,
1369
2560
  column,
1370
2561
  onInteraction,
1371
- selection
2562
+ selection,
2563
+ areControlsDisabled
1372
2564
  );
1373
2565
  const displayTitle = title ?? slicerData.title;
1374
2566
  const hasSelection = selectedRange !== null && slicerData.domain !== null && (selectedRange[0] !== slicerData.domain[0] || selectedRange[1] !== slicerData.domain[1]);
1375
- const isFixedRange = slicerData.domain !== null && slicerData.domain[0] === slicerData.domain[1];
1376
- const areControlsDisabled = disabled || isFixedRange;
1377
2567
  const sliderStep = step !== void 0 && Number.isFinite(step) && step > 0 ? step : void 0;
1378
- const themeStyle = useMemo6(() => theme ? {
2568
+ const themeStyle = useMemo10(() => theme ? {
1379
2569
  ...slicerThemeStyle(theme),
1380
2570
  "--range-foreground": theme.foreground,
1381
2571
  "--range-secondary": theme.foregroundSecondary,
@@ -1384,25 +2574,26 @@ function RangeSlicer({
1384
2574
  "--range-stroke": theme.stroke,
1385
2575
  fontFamily: theme.typography?.label?.family
1386
2576
  } : {}, [theme]);
1387
- const formatBound = useCallback8((value) => String(formatValue2(value, slicerData.format)), [slicerData.format]);
1388
- const formatInput = useCallback8((value) => formatNumericInput(value, slicerData.format), [slicerData.format]);
1389
- const parseInput = useCallback8((text) => parseNumericInput(text, slicerData.format), [slicerData.format]);
1390
- const handleLowerCommit = useCallback8((value) => {
2577
+ const formatBound = useCallback13((value) => String(formatValue3(value, slicerData.format)), [slicerData.format]);
2578
+ const formatInput = useCallback13((value) => formatNumericInput(value, slicerData.format), [slicerData.format]);
2579
+ const parseInput = useCallback13((text) => parseNumericInput(text, slicerData.format), [slicerData.format]);
2580
+ const handleLowerCommit = useCallback13((value) => {
1391
2581
  if (selectedRange) commitSelectedRange([value, selectedRange[1]]);
1392
2582
  }, [selectedRange, commitSelectedRange]);
1393
- const handleUpperCommit = useCallback8((value) => {
2583
+ const handleUpperCommit = useCallback13((value) => {
1394
2584
  if (selectedRange) commitSelectedRange([selectedRange[0], value]);
1395
2585
  }, [selectedRange, commitSelectedRange]);
1396
- if (slicerData.error) return /* @__PURE__ */ jsx10("div", { role: "alert", children: slicerData.error });
1397
- return /* @__PURE__ */ jsxs8(
2586
+ if (slicerData.error) return /* @__PURE__ */ jsx15("div", { role: "alert", "data-lyra-selection-boundary": "", children: slicerData.error });
2587
+ return /* @__PURE__ */ jsxs11(
1398
2588
  "section",
1399
2589
  {
2590
+ "data-lyra-selection-boundary": "",
1400
2591
  className: styles.root,
1401
2592
  style: themeStyle,
1402
2593
  "aria-labelledby": hideHeader ? void 0 : titleId,
1403
2594
  "aria-label": hideHeader ? displayTitle : void 0,
1404
2595
  children: [
1405
- !hideHeader && /* @__PURE__ */ jsx10(
2596
+ !hideHeader && /* @__PURE__ */ jsx15(
1406
2597
  SlicerHeader,
1407
2598
  {
1408
2599
  title: displayTitle,
@@ -1411,9 +2602,9 @@ function RangeSlicer({
1411
2602
  clearDisabled: areControlsDisabled
1412
2603
  }
1413
2604
  ),
1414
- /* @__PURE__ */ jsx10("div", { className: mergeClasses3(styles.body, displayOptions?.frameless && styles.framelessBody), children: selectedRange && slicerData.domain ? /* @__PURE__ */ jsxs8(Fragment2, { children: [
1415
- showHistogram && /* @__PURE__ */ jsx10(RangeHistogram, { counts: slicerData.histogram, domain: slicerData.domain, selectedRange, title: displayTitle }),
1416
- isFixedRange ? /* @__PURE__ */ jsx10("div", { className: styles.slider, "aria-hidden": "true", children: /* @__PURE__ */ jsx10("div", { className: styles.track }) }) : /* @__PURE__ */ jsx10(
2605
+ /* @__PURE__ */ jsx15("div", { className: mergeClasses3(styles.body, displayOptions?.frameless && styles.framelessBody), children: selectedRange && slicerData.domain ? /* @__PURE__ */ jsxs11(Fragment2, { children: [
2606
+ showHistogram && /* @__PURE__ */ jsx15(RangeHistogram, { counts: slicerData.histogram, domain: slicerData.domain, selectedRange, title: displayTitle }),
2607
+ isFixedRange ? /* @__PURE__ */ jsx15("div", { className: styles.slider, "aria-hidden": "true", children: /* @__PURE__ */ jsx15("div", { className: styles.track }) }) : /* @__PURE__ */ jsx15(
1417
2608
  RangeSlider,
1418
2609
  {
1419
2610
  domain: slicerData.domain,
@@ -1428,11 +2619,11 @@ function RangeSlicer({
1428
2619
  onValueCommit: commitSelectedRange
1429
2620
  }
1430
2621
  ),
1431
- /* @__PURE__ */ jsxs8("div", { className: styles.inputs, children: [
1432
- /* @__PURE__ */ jsx10(
2622
+ /* @__PURE__ */ jsxs11("div", { className: styles.inputs, children: [
2623
+ /* @__PURE__ */ jsx15(
1433
2624
  RangeValueInput,
1434
2625
  {
1435
- label: formatString8("RangeSlicer_MinimumLabel", displayTitle),
2626
+ label: formatString14("RangeSlicer_MinimumLabel", displayTitle),
1436
2627
  value: selectedRange[0],
1437
2628
  min: slicerData.domain[0],
1438
2629
  max: selectedRange[1],
@@ -1444,11 +2635,11 @@ function RangeSlicer({
1444
2635
  },
1445
2636
  `lower-${inputRevision}`
1446
2637
  ),
1447
- /* @__PURE__ */ jsx10("span", { className: styles.separator, children: getString5("RangeSlicer_To") }),
1448
- /* @__PURE__ */ jsx10(
2638
+ /* @__PURE__ */ jsx15("span", { className: styles.separator, children: getString11("RangeSlicer_To") }),
2639
+ /* @__PURE__ */ jsx15(
1449
2640
  RangeValueInput,
1450
2641
  {
1451
- label: formatString8("RangeSlicer_MaximumLabel", displayTitle),
2642
+ label: formatString14("RangeSlicer_MaximumLabel", displayTitle),
1452
2643
  value: selectedRange[1],
1453
2644
  min: selectedRange[0],
1454
2645
  max: slicerData.domain[1],
@@ -1461,13 +2652,14 @@ function RangeSlicer({
1461
2652
  `upper-${inputRevision}`
1462
2653
  )
1463
2654
  ] }),
1464
- /* @__PURE__ */ jsx10("p", { id: descriptionId, className: styles.fullRange, children: formatString8("RangeSlicer_FullRange", formatBound(slicerData.domain[0]), formatBound(slicerData.domain[1])) })
1465
- ] }) : /* @__PURE__ */ jsx10("p", { className: styles.empty, role: "status", children: getString5("Common_NoNumericValues") }) })
2655
+ /* @__PURE__ */ jsx15("p", { id: descriptionId, className: styles.fullRange, children: formatString14("RangeSlicer_FullRange", formatBound(slicerData.domain[0]), formatBound(slicerData.domain[1])) })
2656
+ ] }) : /* @__PURE__ */ jsx15("p", { className: styles.empty, role: "status", children: getString11("Common_NoNumericValues") }) })
1466
2657
  ]
1467
2658
  }
1468
2659
  );
1469
2660
  }
1470
2661
  export {
2662
+ DateSlicer,
1471
2663
  DropdownSlicer,
1472
2664
  ListSlicer,
1473
2665
  RangeSlicer,