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