@microsoft/fabric-slicers 3.0.1 → 4.0.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 CHANGED
@@ -5,6 +5,32 @@ All notable changes to `@microsoft/fabric-slicers` will be documented in this fi
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
- ## 3.0.1 - 2026-09-08
8
+ ## 4.0.0 - 2026-10-21
9
9
 
10
- - Add the initial package scaffold.
10
+ - BREAKING: Emit `fieldId` and tagged `InteractionValue` objects instead of `name` and raw values from public interaction callbacks.
11
+
12
+ ## 3.1.0 - 2026-10-09
13
+
14
+ - Use shared slicers for DataGrid column filtering
15
+ - [Slicer] Interaction manager integration for List and drop down slicer
16
+ - Improve list slicer keyboard navigation and Range Home/End behavior
17
+ - Support external selections in list and dropdown slicers
18
+ - [Slicer] Preserve formatting when editing range inputs
19
+ - Use integer steps for whole-number range slicers
20
+ - [Slicer] Adding fade for list slicer
21
+ - Support host-managed selection and embedded RangeSlicer controls
22
+ - Fix RangeSlicer Home key at fractional minimums
23
+ - [Slicer] Editing clear button for range slicer
24
+ - Rename fabric slicers to Microsoft scope
25
+ - Add range slicer interaction events
26
+ - [Slicer] List slicer search bar focus bug fix
27
+ - [Slicers] Add the Dropdown slicer
28
+ - Add dynamic range slicer bins and automatic steps
29
+ - Add basic histogram to numeric range slicers
30
+ - [Slicers] Bug fix for clear button causing layout shift
31
+ - [Slicers 2/2] Add editable range inputs
32
+ - [Slicers] List slicer implementation
33
+ - [Slicers 1/2] Add a data-backed range slider
34
+ - Slicers adding basic contracts and skeleton implementation
35
+ - Scaffold ListSlicer package
36
+ - Set the Slicers package version to 1.0.0 for release.
package/README.md CHANGED
@@ -6,7 +6,7 @@ React slicer components for Fabric Apps - Analytics.
6
6
 
7
7
  > **Use when**: You need categorical selection or a numeric range control.
8
8
  > **Components**: `ListSlicer`, `DropdownSlicer`, `RangeSlicer`.
9
- > **Selection**: Starts with all values or the full range selected. State is local; `RangeSlicer` emits interaction events for host-managed filtering.
9
+ > **Selection**: Starts with all values or the full range selected unless supplied by the host. All slicers accept `selection` to restore or synchronize local state and emit interaction events for host-managed filtering.
10
10
  > **Peer dependencies**: React 18 or 19, React DOM, and `@griffel/react`.
11
11
 
12
12
  ## Installation
@@ -25,11 +25,13 @@ Import components and types from `@microsoft/fabric-slicers`. All three componen
25
25
  | `column` | `string` | yes | Table column to display; also the fallback title for flat data. |
26
26
  | `title` | `string` | no | Overrides the column's display name or name. |
27
27
  | `theme` | `VisualTheme` | no | Color, typography, and border overrides. Defaults to shared design tokens. |
28
- | `displayOptions` | `SlicerDisplayOptions` | no | Shared display options, extended by each slicer. |
29
- | `onInteraction` | `InteractionEventCallback` | no | Selection and clear events. Currently emitted by `RangeSlicer` only. |
28
+ | `displayOptions` | `SlicerDisplayOptions` | no | Shared `hideHeader` and `frameless` options, extended by each slicer. |
29
+ | `selection` | Component-specific | no | Restore or synchronize host-provided selection. See [External selections](#external-selections). |
30
+ | `onInteraction` | `InteractionEventCallback` | no | Selection and clear events for host-managed filtering. |
30
31
 
31
32
  `DataTable`, `VisualTheme`, and `InteractionEventCallback` come from `@microsoft/fabric-visuals-core`.
32
33
  `SlicerValue` supports strings, finite numbers, booleans, valid dates, `null`, and `undefined`.
34
+ `isSlicerValue` validates untyped data cells against that contract.
33
35
  Table column formats apply to displayed values.
34
36
 
35
37
  ## List slicer
@@ -58,6 +60,34 @@ Props type: `ListSlicerInputParams`. Its optional `displayOptions` uses `ListSli
58
60
  | Option | Default | Description |
59
61
  |--------|---------|-------------|
60
62
  | `showSearch` | `true` | Show the search input. |
63
+ | `hideHeader` | `false` | Hide the title and Clear button when the host supplies its own header. |
64
+ | `frameless` | `false` | Remove the body's border, background, and padding when embedded in a host surface. |
65
+
66
+ ### Host-owned list filtering
67
+
68
+ Embed `ListSlicer` with `selection` and `onInteraction` when the host owns filtering.
69
+ Use `displayOptions: { hideHeader: true, frameless: true }` when the host provides the surrounding
70
+ surface and Clear action, as DataGrid does. Raw values are retained internally for selection and
71
+ interaction events; formatted labels are presentation-only.
72
+
73
+ ### Keyboard navigation
74
+
75
+ Select all and the matching values share one Tab stop, separate from Search.
76
+ Initial entry focuses Select all. Tab and Shift+Tab leave the checkboxes; returning
77
+ restores the last focused checkbox, falling back to Select all if that value is no longer present.
78
+ The same navigation works in the dropdown's shared selection list.
79
+
80
+ | Key | Action |
81
+ |-----|--------|
82
+ | Up / Down arrow | Move between Select all and the matching values without changing selection. Stops at either end. |
83
+ | Home / End | Focus Select all / the last matching value, including values outside the rendered virtual window. |
84
+ | Space / Enter | Toggle the focused value or Select all. |
85
+
86
+ Unmodified arrows and Home/End provide navigation based on the [documented Power BI slicer shortcuts](https://learn.microsoft.com/en-us/power-bi/create-reports/desktop-accessibility-keyboard-shortcuts#slicer).
87
+ Shift+Arrow range selection is intentionally unsupported to keep keyboard handling simple;
88
+ use Space or Enter to toggle individual values. Modified navigation keys are left to the browser.
89
+ The shared Tab stop and inclusion of Select all are explicit interaction choices here, not specified by that documentation.
90
+ Search retains normal text-editing keys, and Escape still closes an open dropdown and returns focus to its trigger.
61
91
 
62
92
  ## Dropdown slicer
63
93
 
@@ -76,7 +106,7 @@ import { DropdownSlicer } from '@microsoft/fabric-slicers';
76
106
  />;
77
107
  ```
78
108
 
79
- Props type: `DropdownSlicerInputParams`. It accepts the same `displayOptions` as List slicer.
109
+ Props type: `DropdownSlicerInputParams`. It accepts the same `selection` and `displayOptions` as List slicer.
80
110
 
81
111
  ## Range slicer
82
112
 
@@ -101,39 +131,55 @@ Props type: `RangeSlicerInputParams`. Additional options:
101
131
  | `displayOptions.showHistogram` | `true` | Show the value distribution above the slider. |
102
132
  | `displayOptions.hideHeader` | `false` | Hide the title and Clear button when the host supplies its own header. The range retains its accessible name. |
103
133
  | `displayOptions.frameless` | `false` | Remove the body's border, background, and padding when embedded in a host surface. Input borders remain visible. |
104
- | `selection` | Local state | Restore or synchronize host-provided inclusive bounds without emitting events. `null` resets the full range; infinities map to domain endpoints. |
105
134
  | `step` | Automatic | Positive slider increment; does not restrict typed values. |
106
135
  | `disabled` | `false` | Disable interaction. |
107
136
 
108
- The histogram uses an automatic data-driven bin count and highlights the selected range.
109
- Set `displayOptions.binCount` to a positive safe integer to override it; invalid counts use automatic bins.
110
- Set `showHistogram: false` to hide it and skip bin computation and validation.
137
+ Home/End changes only the focused handle and keeps focus there, with either automatic or explicit steps:
138
+ the minimum handle moves to the domain minimum / current maximum, and the maximum handle moves to
139
+ the current minimum / domain maximum. Handles can meet without crossing; typed off-step bounds remain exact.
111
140
 
112
- Set `title` to override the heading or `disabled` to prevent interaction.
113
- When `step` is omitted or invalid, the slider chooses a precision- and formatter-aware increment;
114
- an explicit finite positive `step` overrides it.
115
- Typed values can be any finite number within the current bounds, independent of the slider step.
141
+ ## External selections
116
142
 
117
- Automatic steps start at `(maximum - minimum) / 100`, round up to a 1, 2, or 5 times a power of ten,
118
- and increase when neighboring stops have identical formatted labels.
119
- Slider interaction uses the original domain and native step-based rounding.
120
- The exact endpoints remain reachable with Home and End even when native step rounding would miss them.
143
+ All slicers accept an optional `selection` prop to restore a saved selection or synchronize it while mounted.
144
+ Omit it to manage selection locally (initially all values or the full range).
145
+ Supply `null` to reset to all values or the full range, including newly arriving data.
146
+ Host updates do not emit interaction events. Local selection controls and Clear continue to work;
147
+ the next supplied selection update replaces that local state.
148
+ Keep selection arrays immutable and retain their reference on unrelated rerenders to preserve local edits.
149
+
150
+ | Component | Selection type | Meaning |
151
+ |-----------|----------------|---------|
152
+ | `ListSlicer`, `DropdownSlicer` | `readonly SlicerValue[] \| null` | Raw selected values. `[]` selects none. |
153
+ | `RangeSlicer` | `SlicerRange \| null` | Inclusive `[minimum, maximum]` bounds. Infinities leave that side unbounded. |
154
+
155
+ ```tsx
156
+ <ListSlicer data={['Action', 'Adventure', 'Role-playing']} column="genre" selection={['Action', 'Adventure']} />;
157
+ <DropdownSlicer data={['North', 'South', 'East', 'West']} column="region" selection={['North']} />;
158
+ <RangeSlicer data={[0, 20, 80, 100]} column="revenue" selection={[20, Infinity]} />;
159
+ ```
121
160
 
122
161
  ### Interactions
123
162
 
124
163
  Optional `onInteraction` uses `InteractionEventCallback` from `@microsoft/fabric-visuals-core`.
125
- It emits `select` on drag release, keyboard changes, or valid input commits (Enter/blur).
164
+ List and Dropdown slicers emit one `select` event per checkbox or search-scoped Select all change,
165
+ with a `set` predicate whose `fieldId` is `column` and whose values are the complete selection as
166
+ `InteractionValue`s: `{ kind: 'value', value }` for raw values and `{ kind: 'blank' }` for blanks.
167
+ An empty array selects nothing. Selecting all values or clearing emits `[{ action: 'clear' }]`.
168
+ Standalone list and dropdown slicers preserve valid `Date` objects in emitted values. Interaction
169
+ Manager requires semantic-model dates and datetimes as their original normalized strings and rejects
170
+ `Date` objects at that boundary.
171
+
172
+ Range slicers emit `select` on drag release, keyboard changes, or valid input commits (Enter/blur).
126
173
  Unchanged, invalid, or cancelled edits do not emit.
127
174
 
128
- Selections contain one inclusive `range` predicate using `column` and raw numeric bounds.
129
- Domain endpoints emit `min: -Infinity` or `max: Infinity` to leave that side unbounded.
130
- Encode infinities explicitly when serializing; `JSON.stringify` converts them to `null`.
175
+ Range selections contain one inclusive `range` predicate whose `fieldId` is `column`. Each bound is a
176
+ `RangeBoundary` (`{ kind: 'value', value }`). A bound at the data domain's edge is omitted to leave
177
+ that side unbounded.
131
178
 
132
179
  Clear or returning to the full range emits `[{ action: 'clear' }]`.
133
- Selection stays local unless the host supplies `selection` to restore or synchronize it; the host applies events to other visuals.
134
- With `selection`, refreshed data clamps the displayed handles to the available domain without changing the host's predicate or emitting events.
135
- For example, `[20, Infinity]` displays as `[20, 100]` for a `[0, 100]` domain; `null` displays the full domain.
136
- Otherwise keep `data` and `column` fixed while mounted; remount to change them.
180
+
181
+ With Interaction Manager, slicers only report selections. They do not accept managed `selections`,
182
+ so a slicer does not show selections made by other sources.
137
183
 
138
184
  ## Theming
139
185
 
package/dist/index.d.ts CHANGED
@@ -1,14 +1,16 @@
1
1
  import { ReactElement } from 'react';
2
2
  import { DataTable, VisualTheme, InteractionEventCallback } from '@microsoft/fabric-visuals-core';
3
3
 
4
- /** Supported raw slicer values. */
4
+ /** Supported raw slicer values. Null and undefined share one blank entry in list and dropdown slicers. */
5
5
  type SlicerValue = string | number | boolean | Date | null | undefined;
6
6
  /** Display options shared by all slicers. */
7
7
  interface SlicerDisplayOptions {
8
8
  /** Hide the title and Clear button. Defaults to false. */
9
9
  hideHeader?: boolean;
10
+ /** Remove the body frame and padding when the host provides the surrounding surface. Defaults to false. */
11
+ frameless?: boolean;
10
12
  }
11
- /** Shared inputs for all slicers. Every slicer starts with all values selected, with no filter applied. */
13
+ /** Shared inputs for all slicers. Without a host selection, slicers start with all values selected. */
12
14
  interface SlicerInputParams {
13
15
  /** Structured tabular data or a flat collection of slicer values. */
14
16
  data: DataTable | readonly SlicerValue[];
@@ -30,10 +32,15 @@ interface ListSlicerDisplayOptions extends SlicerDisplayOptions {
30
32
  /** Inputs for the list slicer. */
31
33
  interface ListSlicerInputParams extends SlicerInputParams {
32
34
  displayOptions?: ListSlicerDisplayOptions;
35
+ /**
36
+ * Raw selected values to restore or synchronize without emitting events.
37
+ * Null resets to all, including future values. An empty array selects none.
38
+ * Omitted leaves selection locally managed; supplying values does not disable local edits.
39
+ */
40
+ selection?: readonly SlicerValue[] | null;
33
41
  }
34
42
  /** Inputs for the dropdown slicer. */
35
- interface DropdownSlicerInputParams extends SlicerInputParams {
36
- displayOptions?: ListSlicerDisplayOptions;
43
+ interface DropdownSlicerInputParams extends ListSlicerInputParams {
37
44
  }
38
45
  /** Lower and upper bounds, inclusive. */
39
46
  type SlicerRange = [number, number];
@@ -43,8 +50,6 @@ interface RangeSlicerDisplayOptions extends SlicerDisplayOptions {
43
50
  showHistogram?: boolean;
44
51
  /** Positive safe integer overriding the histogram bin count. Omitted or invalid values use automatic binning. */
45
52
  binCount?: number;
46
- /** Remove the body frame and padding when the host provides the surrounding surface. */
47
- frameless?: boolean;
48
53
  }
49
54
  /** Numeric range slicer. Keep column fixed; data may refresh when the host supplies selection. */
50
55
  interface RangeSlicerInputParams extends SlicerInputParams {
@@ -55,7 +60,10 @@ interface RangeSlicerInputParams extends SlicerInputParams {
55
60
  * Null resets to the full range. Omitted leaves selection locally managed.
56
61
  */
57
62
  selection?: SlicerRange | null;
58
- /** Finite positive keyboard and pointer increment. Omitted or invalid values use precision- and formatter-aware automatic steps. */
63
+ /**
64
+ * Finite positive keyboard and pointer increment. Omitted or invalid values use precision- and formatter-aware automatic steps,
65
+ * restricted to whole-number increments when all finite data values are integers. Typed values are not restricted by the step.
66
+ */
59
67
  step?: number;
60
68
  disabled?: boolean;
61
69
  }
@@ -66,4 +74,7 @@ declare function DropdownSlicer(props: DropdownSlicerInputParams): ReactElement;
66
74
 
67
75
  declare function RangeSlicer({ data, column, title, theme, step, disabled, displayOptions, onInteraction, selection, }: RangeSlicerInputParams): ReactElement;
68
76
 
69
- export { DropdownSlicer, type DropdownSlicerInputParams, ListSlicer, type ListSlicerDisplayOptions, type ListSlicerInputParams, RangeSlicer, type RangeSlicerDisplayOptions, type RangeSlicerInputParams, type SlicerDisplayOptions, type SlicerInputParams, type SlicerRange, type SlicerValue };
77
+ /** Narrows unvalidated data cells and interaction values to supported slicer values. */
78
+ declare function isSlicerValue(value: DataTable['rows'][number][number]): value is SlicerValue;
79
+
80
+ export { DropdownSlicer, type DropdownSlicerInputParams, ListSlicer, type ListSlicerDisplayOptions, type ListSlicerInputParams, RangeSlicer, type RangeSlicerDisplayOptions, type RangeSlicerInputParams, type SlicerDisplayOptions, type SlicerInputParams, type SlicerRange, type SlicerValue, isSlicerValue };
package/dist/index.js CHANGED
@@ -1,15 +1,20 @@
1
1
  // src/components/list-slicer/list-slicer.tsx
2
2
  import { useVirtualizer } from "@tanstack/react-virtual";
3
- import { useCallback as useCallback2, useEffect, useId, useMemo as useMemo2, useRef, useState as useState2 } from "react";
3
+ import { useCallback as useCallback4, useEffect as useEffect2, useId, useMemo as useMemo2, useRef as useRef3, useState as useState3 } from "react";
4
4
  import { getString as getString3 } from "@microsoft/fabric-visuals-core";
5
5
 
6
6
  // src/hooks/use-list-slicer.ts
7
- import { useCallback, useMemo, useState } from "react";
8
- import { formatString, formatValue, getString, isDataTable } from "@microsoft/fabric-visuals-core";
7
+ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
8
+ import { formatString, formatValue, getString, isDataTable, toInteractionValue } from "@microsoft/fabric-visuals-core";
9
+
10
+ // src/utils/slicer-value.ts
9
11
  function isSlicerValue(value) {
10
12
  return value == null || typeof value === "string" || typeof value === "boolean" || typeof value === "number" && Number.isFinite(value) || value instanceof Date && Number.isFinite(value.getTime());
11
13
  }
14
+
15
+ // src/hooks/use-list-slicer.ts
12
16
  function valueKey(value) {
17
+ if (value == null) return "blank";
13
18
  if (value instanceof Date) return `date:${value.getTime()}`;
14
19
  return `${typeof value}:${String(value)}`;
15
20
  }
@@ -48,43 +53,151 @@ function prepareListSlicerData({ data, column, title }) {
48
53
  }
49
54
  return { title: resolvedTitle, items };
50
55
  }
51
- function useListSlicer({ data, column, title }) {
56
+ function useListSlicer({ data, column, title, selection, onInteraction }) {
52
57
  const prepared = useMemo(
53
58
  () => prepareListSlicerData({ data, column, title }),
54
59
  [data, column, title]
55
60
  );
56
- const [selection, setSelection] = useState("all");
61
+ const valuesByKey = useMemo(
62
+ () => new Map(prepared.items.map((item) => [item.key, item.value])),
63
+ [prepared.items]
64
+ );
65
+ const resolvedSelection = useMemo(() => {
66
+ if (selection !== void 0) {
67
+ if (selection === null) return "all";
68
+ if (!selection.every(isSlicerValue)) {
69
+ throw new Error("Slicer selection must contain text, finite numbers, booleans, valid dates, or blanks.");
70
+ }
71
+ const resolved = /* @__PURE__ */ new Map();
72
+ for (const value of selection) {
73
+ const key = valueKey(value);
74
+ if (!resolved.has(key)) resolved.set(key, value);
75
+ }
76
+ return resolved;
77
+ }
78
+ return void 0;
79
+ }, [selection]);
80
+ const [localSelection, setLocalSelection] = useState(resolvedSelection ?? "all");
81
+ const selectionRef = useRef(resolvedSelection ?? "all");
82
+ useEffect(() => {
83
+ if (resolvedSelection !== void 0) {
84
+ selectionRef.current = resolvedSelection;
85
+ setLocalSelection(resolvedSelection);
86
+ }
87
+ }, [resolvedSelection]);
57
88
  const isSelected = useCallback(
58
- (key) => selection === "all" || selection.has(key),
59
- [selection]
89
+ (key) => localSelection === "all" || localSelection.has(key),
90
+ [localSelection]
60
91
  );
61
92
  const selectedItems = useMemo(
62
93
  () => prepared.items.filter((item) => isSelected(item.key)),
63
94
  [prepared.items, isSelected]
64
95
  );
65
- const toggle = useCallback((keys) => {
66
- if (keys.length === 0) return;
67
- setSelection((previous) => {
68
- const next = previous === "all" ? new Set(prepared.items.map((item) => item.key)) : new Set(previous);
69
- const remove = keys.every((key) => next.has(key));
70
- for (const key of keys) {
71
- if (remove) next.delete(key);
72
- else next.add(key);
73
- }
74
- return prepared.items.length > 0 && prepared.items.every((item) => next.has(item.key)) ? "all" : next;
75
- });
76
- }, [prepared.items]);
77
- const clear = useCallback(() => setSelection("all"), []);
96
+ const updateSelection = useCallback((next) => {
97
+ const normalized = next !== "all" && prepared.items.length > 0 && next.size >= prepared.items.length && prepared.items.every((item) => next.has(item.key)) ? "all" : next;
98
+ selectionRef.current = normalized;
99
+ setLocalSelection(normalized);
100
+ if (!onInteraction) return;
101
+ const event = normalized === "all" ? { action: "clear" } : {
102
+ action: "select",
103
+ selections: [{
104
+ predicates: [{
105
+ type: "set",
106
+ fieldId: column,
107
+ values: [...normalized.values()].map(toInteractionValue)
108
+ }]
109
+ }]
110
+ };
111
+ onInteraction([event]);
112
+ }, [column, onInteraction, prepared.items]);
113
+ const clear = useCallback(() => {
114
+ if (selectionRef.current !== "all") updateSelection("all");
115
+ }, [updateSelection]);
116
+ const toggle = useCallback((key, checked) => {
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.has(key)) === checked) return;
120
+ const next = new Map(previous === "all" ? valuesByKey : previous);
121
+ if (checked) next.set(key, valuesByKey.get(key));
122
+ else next.delete(key);
123
+ updateSelection(next);
124
+ }, [valuesByKey, updateSelection]);
125
+ const toggleAll = useCallback((checked, keys) => {
126
+ if (valuesByKey.size === 0 || keys?.length === 0) return;
127
+ if (keys === void 0 && checked) {
128
+ clear();
129
+ return;
130
+ }
131
+ const previous = selectionRef.current;
132
+ if (keys === void 0 && previous === "all") {
133
+ updateSelection(/* @__PURE__ */ new Map());
134
+ return;
135
+ }
136
+ let next;
137
+ for (const key of keys ?? valuesByKey.keys()) {
138
+ if (!valuesByKey.has(key)) throw new Error(`Cannot update an unknown slicer key: ${key}`);
139
+ if ((previous === "all" || previous.has(key)) === checked) continue;
140
+ next ??= new Map(previous === "all" ? valuesByKey : previous);
141
+ if (checked) next.set(key, valuesByKey.get(key));
142
+ else next.delete(key);
143
+ }
144
+ if (next) updateSelection(next);
145
+ }, [valuesByKey, clear, updateSelection]);
78
146
  return {
79
147
  ...prepared,
80
148
  selectedItems,
81
149
  isSelected,
82
150
  toggle,
151
+ toggleAll,
83
152
  clear,
84
- allSelected: selection === "all"
153
+ allSelected: localSelection === "all"
85
154
  };
86
155
  }
87
156
 
157
+ // src/hooks/use-list-navigation.ts
158
+ import { defaultRangeExtractor } from "@tanstack/react-virtual";
159
+ import { useCallback as useCallback2, useLayoutEffect, useRef as useRef2, useState as useState2 } from "react";
160
+ function useListNavigation(items) {
161
+ const panelRef = useRef2(null);
162
+ const [activeKey, setActiveKey] = useState2(null);
163
+ const activeIndex = items.findIndex((item) => item.key === activeKey);
164
+ const pendingFocusKey = useRef2(void 0);
165
+ const rangeExtractor = useCallback2((range) => {
166
+ const visibleIndices = defaultRangeExtractor(range);
167
+ return activeIndex >= 0 ? [.../* @__PURE__ */ new Set([...visibleIndices, activeIndex])].sort((left, right) => left - right) : visibleIndices;
168
+ }, [activeIndex]);
169
+ useLayoutEffect(() => {
170
+ if (pendingFocusKey.current !== void 0 && pendingFocusKey.current === (items[activeIndex]?.key ?? null)) {
171
+ const checkbox = panelRef.current?.querySelector(`[data-slicer-index="${activeIndex}"] [role="checkbox"]`);
172
+ checkbox?.focus();
173
+ pendingFocusKey.current = void 0;
174
+ }
175
+ }, [activeIndex, items]);
176
+ const handleFocus = useCallback2((event) => {
177
+ const row = event.target.closest("[data-slicer-index]");
178
+ if (row) {
179
+ setActiveKey(items[Number(row.dataset.slicerIndex)]?.key ?? null);
180
+ }
181
+ }, [items]);
182
+ const handleKeyDown = useCallback2((event) => {
183
+ const isCheckboxTarget = event.target instanceof HTMLButtonElement && event.target.getAttribute("role") === "checkbox";
184
+ const isNavigationKey = event.key === "ArrowUp" || event.key === "ArrowDown" || event.key === "Home" || event.key === "End";
185
+ if (isCheckboxTarget && isNavigationKey && !event.altKey && !event.ctrlKey && !event.metaKey && !event.shiftKey) {
186
+ if (event.defaultPrevented || items.length === 0) return;
187
+ event.preventDefault();
188
+ event.stopPropagation();
189
+ let nextIndex;
190
+ if (event.key === "Home") nextIndex = -1;
191
+ else if (event.key === "End") nextIndex = items.length - 1;
192
+ else nextIndex = Math.max(-1, Math.min(items.length - 1, activeIndex + (event.key === "ArrowDown" ? 1 : -1)));
193
+ if (nextIndex === activeIndex) return;
194
+ pendingFocusKey.current = items[nextIndex]?.key ?? null;
195
+ setActiveKey(pendingFocusKey.current);
196
+ }
197
+ }, [items, activeIndex]);
198
+ return { panelRef, activeIndex, rangeExtractor, handleFocus, handleKeyDown };
199
+ }
200
+
88
201
  // src/components/shared/slicer-header.tsx
89
202
  import { formatString as formatString2, getString as getString2 } from "@microsoft/fabric-visuals-core";
90
203
 
@@ -196,6 +309,7 @@ function SlicerHeader({ title, titleId, onClear, clearDisabled }) {
196
309
 
197
310
  // src/components/ui/checkbox.tsx
198
311
  import { Checkbox as CheckBox } from "radix-ui";
312
+ import { useCallback as useCallback3 } from "react";
199
313
  import { mergeClasses as mergeClasses2 } from "@griffel/react";
200
314
 
201
315
  // src/components/ui/ui-slicer-styles.ts
@@ -235,9 +349,17 @@ var useCheckboxStyles = makeStyles2(inVisualsLayer2({
235
349
 
236
350
  // src/components/ui/checkbox.tsx
237
351
  import { jsx as jsx2 } from "react/jsx-runtime";
238
- function Checkbox({ className, checked, ...props }) {
352
+ function Checkbox({ className, checked, onKeyDown, ...props }) {
239
353
  const styles = useCheckboxStyles();
240
- return /* @__PURE__ */ jsx2(CheckBox.Root, { ...props, checked, className: mergeClasses2(styles.checkbox, className), children: /* @__PURE__ */ jsx2(CheckBox.Indicator, { className: styles.indicator, children: /* @__PURE__ */ jsx2("svg", { width: "12", height: "12", viewBox: "0 0 12 12", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx2(
354
+ const handleKeyDown = useCallback3((event) => {
355
+ onKeyDown?.(event);
356
+ if (event.key === "Enter" && !event.defaultPrevented) {
357
+ event.preventDefault();
358
+ event.stopPropagation();
359
+ event.currentTarget.click();
360
+ }
361
+ }, [onKeyDown]);
362
+ return /* @__PURE__ */ jsx2(CheckBox.Root, { ...props, checked, onKeyDown: handleKeyDown, className: mergeClasses2(styles.checkbox, className), children: /* @__PURE__ */ jsx2(CheckBox.Indicator, { className: styles.indicator, children: /* @__PURE__ */ jsx2("svg", { width: "12", height: "12", viewBox: "0 0 12 12", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx2(
241
363
  "path",
242
364
  {
243
365
  d: checked === "indeterminate" ? "M2 6h8" : "m2 6 2.5 2.5L10 3",
@@ -265,6 +387,8 @@ function SearchIcon({ className }) {
265
387
  import { makeStyles as makeStyles3 } from "@griffel/react";
266
388
  import { inVisualsLayer as inVisualsLayer3, tokens as tokens3 } from "@microsoft/fabric-visuals-core";
267
389
  var useListSlicerStyles = makeStyles3(inVisualsLayer3({
390
+ // Without panel padding, outward focus rings need visible overflow; the value list owns scrolling.
391
+ frameless: { border: 0, borderRadius: 0, padding: 0, backgroundColor: "transparent", overflow: "visible" },
268
392
  search: {
269
393
  display: "flex",
270
394
  alignItems: "center",
@@ -350,10 +474,10 @@ var useListSlicerStyles = makeStyles3(inVisualsLayer3({
350
474
  // src/components/list-slicer/list-slicer.tsx
351
475
  import { Fragment, jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
352
476
  var ROW_HEIGHT = 32;
353
- function ListSlicerRow({ label, checked, onToggle, disabled, className }) {
477
+ function ListSlicerRow({ label, checked, onToggle, disabled, className, tabIndex, navigationIndex }) {
354
478
  const styles = { ...useSlicerStyles(), ...useListSlicerStyles() };
355
479
  const id = useId();
356
- return /* @__PURE__ */ jsxs3("div", { className: mergeClasses(styles.row, className), children: [
480
+ return /* @__PURE__ */ jsxs3("div", { className: mergeClasses(styles.row, className), "data-slicer-index": navigationIndex, children: [
357
481
  /* @__PURE__ */ jsx4(
358
482
  Checkbox,
359
483
  {
@@ -361,20 +485,25 @@ function ListSlicerRow({ label, checked, onToggle, disabled, className }) {
361
485
  checked,
362
486
  onCheckedChange: onToggle,
363
487
  disabled,
364
- "aria-label": label
488
+ "aria-label": label,
489
+ tabIndex
365
490
  }
366
491
  ),
367
492
  /* @__PURE__ */ jsx4("label", { className: styles.label, htmlFor: id, children: /* @__PURE__ */ jsx4("span", { className: styles.text, title: label, children: label }) })
368
493
  ] });
369
494
  }
370
- function ItemRow({ item, state }) {
371
- const toggle = useCallback2(() => state.toggle([item.key]), [state, item.key]);
495
+ function ItemRow({ item, state, tabIndex }) {
496
+ const toggle = useCallback4(
497
+ (checked) => state.toggle(item.key, checked === true),
498
+ [state, item.key]
499
+ );
372
500
  return /* @__PURE__ */ jsx4(
373
501
  ListSlicerRow,
374
502
  {
375
503
  label: item.label,
376
504
  checked: state.isSelected(item.key),
377
- onToggle: toggle
505
+ onToggle: toggle,
506
+ tabIndex
378
507
  }
379
508
  );
380
509
  }
@@ -399,30 +528,40 @@ function ListSlicerContent({
399
528
  const themeStyle = useMemo2(() => slicerThemeStyle(theme), [theme]);
400
529
  const showSearch = displayOptions?.showSearch ?? true;
401
530
  const hideHeader = displayOptions?.hideHeader ?? false;
402
- const scrollRef = useRef(null);
531
+ const scrollRef = useRef3(null);
403
532
  const scrollStyle = useMemo2(
404
- () => ({ maxHeight: maxVisibleItems * ROW_HEIGHT }),
533
+ // Include Select all without reducing the initial number of visible values.
534
+ () => ({ maxHeight: (maxVisibleItems + 1) * ROW_HEIGHT }),
405
535
  [maxVisibleItems]
406
536
  );
407
- const [search, setSearch] = useState2("");
537
+ const [search, setSearch] = useState3("");
408
538
  const items = useMemo2(() => {
409
539
  const query = showSearch ? search.toLocaleLowerCase() : "";
410
540
  return state.items.filter((item) => item.label.toLocaleLowerCase().includes(query));
411
541
  }, [state.items, search, showSearch]);
412
- const handleSearch = useCallback2((event) => {
542
+ const handleSearch = useCallback4((event) => {
413
543
  setSearch(event.target.value);
414
544
  if (scrollRef.current) scrollRef.current.scrollTop = 0;
415
545
  }, []);
416
546
  const selectedCount = items.filter((item) => state.isSelected(item.key)).length;
417
547
  const checked = selectedCount === 0 ? false : selectedCount === items.length ? true : "indeterminate";
418
- const toggleAll = useCallback2(() => state.toggle(items.map((item) => item.key)), [state, items]);
548
+ const toggleAll = useCallback4(
549
+ (nextChecked) => state.toggleAll(
550
+ nextChecked === true,
551
+ items.length === state.items.length ? void 0 : items.map((item) => item.key)
552
+ ),
553
+ [state, items]
554
+ );
555
+ const navigation = useListNavigation(items);
419
556
  const virtual = items.length > 50;
420
557
  const virtualizer = useVirtualizer({
421
558
  count: items.length,
422
559
  getScrollElement: () => scrollRef.current,
423
560
  estimateSize: () => ROW_HEIGHT,
424
561
  getItemKey: (index) => items[index].key,
562
+ scrollMargin: ROW_HEIGHT,
425
563
  overscan: 5,
564
+ rangeExtractor: navigation.rangeExtractor,
426
565
  enabled: virtual
427
566
  });
428
567
  const totalHeight = virtualizer.getTotalSize();
@@ -430,8 +569,8 @@ function ListSlicerContent({
430
569
  () => virtual ? { height: totalHeight } : void 0,
431
570
  [virtual, totalHeight]
432
571
  );
433
- const [hasMoreBelow, setHasMoreBelow] = useState2(false);
434
- useEffect(() => {
572
+ const [hasMoreBelow, setHasMoreBelow] = useState3(false);
573
+ useEffect2(() => {
435
574
  const scroll = scrollRef.current;
436
575
  if (!scroll) return;
437
576
  const updateFade = () => {
@@ -439,7 +578,7 @@ function ListSlicerContent({
439
578
  };
440
579
  const observer = new ResizeObserver(updateFade);
441
580
  observer.observe(scroll);
442
- if (scroll.firstElementChild) observer.observe(scroll.firstElementChild);
581
+ if (scroll.lastElementChild) observer.observe(scroll.lastElementChild);
443
582
  scroll.addEventListener("scroll", updateFade, { passive: true });
444
583
  updateFade();
445
584
  return () => {
@@ -464,33 +603,62 @@ function ListSlicerContent({
464
603
  clearDisabled: !!state.error || state.items.length === 0
465
604
  }
466
605
  ),
467
- /* @__PURE__ */ jsx4("div", { className: styles.panel, children: state.error ? /* @__PURE__ */ jsx4("div", { role: "alert", className: styles.message, children: state.error }) : /* @__PURE__ */ jsxs3(Fragment, { children: [
468
- showSearch && /* @__PURE__ */ jsxs3("div", { className: styles.search, children: [
469
- /* @__PURE__ */ jsx4(SearchIcon, { className: styles.icon }),
470
- /* @__PURE__ */ jsx4(
471
- "input",
472
- {
473
- type: "search",
474
- className: styles.input,
475
- placeholder: getString3("Slicer_Search"),
476
- "aria-label": getString3("Slicer_Search"),
477
- value: search,
478
- onChange: handleSearch
479
- }
480
- )
481
- ] }),
482
- /* @__PURE__ */ jsx4(
483
- ListSlicerRow,
484
- {
485
- className: styles.selectAll,
486
- label: getString3("Slicer_SelectAll"),
487
- checked,
488
- onToggle: toggleAll,
489
- disabled: items.length === 0
490
- }
491
- ),
492
- /* @__PURE__ */ jsx4("div", { ref: scrollRef, className: mergeClasses(styles.scroll, hasMoreBelow && styles.scrollFade), style: scrollStyle, children: items.length === 0 ? /* @__PURE__ */ jsx4("div", { role: "status", className: styles.message, children: getString3(state.items.length === 0 ? "Slicer_NoData" : "Slicer_NoResults") }) : /* @__PURE__ */ jsx4("ul", { className: styles.list, style: listStyle, "aria-label": state.title, children: virtual ? virtualizer.getVirtualItems().map((row) => /* @__PURE__ */ jsx4("li", { style: virtualRowStyle(row.start), "aria-posinset": row.index + 1, "aria-setsize": items.length, children: /* @__PURE__ */ jsx4(ItemRow, { item: items[row.index], state }) }, row.key)) : items.map((item) => /* @__PURE__ */ jsx4("li", { children: /* @__PURE__ */ jsx4(ItemRow, { item, state }) }, item.key)) }) })
493
- ] }) })
606
+ /* @__PURE__ */ jsx4(
607
+ "div",
608
+ {
609
+ ref: navigation.panelRef,
610
+ className: mergeClasses(styles.panel, displayOptions?.frameless && styles.frameless),
611
+ role: "group",
612
+ "aria-label": state.title,
613
+ onFocus: navigation.handleFocus,
614
+ onKeyDown: navigation.handleKeyDown,
615
+ children: state.error ? /* @__PURE__ */ jsx4("div", { role: "alert", className: styles.message, children: state.error }) : /* @__PURE__ */ jsxs3(Fragment, { children: [
616
+ showSearch && /* @__PURE__ */ jsxs3("div", { className: styles.search, children: [
617
+ /* @__PURE__ */ jsx4(SearchIcon, { className: styles.icon }),
618
+ /* @__PURE__ */ jsx4(
619
+ "input",
620
+ {
621
+ type: "search",
622
+ className: styles.input,
623
+ placeholder: getString3("Slicer_Search"),
624
+ "aria-label": getString3("Slicer_Search"),
625
+ value: search,
626
+ onChange: handleSearch
627
+ }
628
+ )
629
+ ] }),
630
+ /* @__PURE__ */ jsxs3("div", { ref: scrollRef, tabIndex: -1, className: mergeClasses(styles.scroll, hasMoreBelow && styles.scrollFade), style: scrollStyle, children: [
631
+ /* @__PURE__ */ jsx4(
632
+ ListSlicerRow,
633
+ {
634
+ className: styles.selectAll,
635
+ label: getString3("Slicer_SelectAll"),
636
+ checked,
637
+ onToggle: toggleAll,
638
+ disabled: items.length === 0,
639
+ navigationIndex: -1,
640
+ tabIndex: navigation.activeIndex === -1 && items.length > 0 ? 0 : -1
641
+ }
642
+ ),
643
+ items.length === 0 ? /* @__PURE__ */ jsx4("div", { role: "status", className: styles.message, children: getString3(state.items.length === 0 ? "Slicer_NoData" : "Slicer_NoResults") }) : /* @__PURE__ */ jsx4("ul", { className: styles.list, style: listStyle, "aria-label": state.title, children: virtual ? virtualizer.getVirtualItems().map((row) => /* @__PURE__ */ jsx4("li", { "data-slicer-index": row.index, style: virtualRowStyle(row.start - ROW_HEIGHT), "aria-posinset": row.index + 1, "aria-setsize": items.length, children: /* @__PURE__ */ jsx4(
644
+ ItemRow,
645
+ {
646
+ item: items[row.index],
647
+ state,
648
+ tabIndex: row.index === navigation.activeIndex ? 0 : -1
649
+ }
650
+ ) }, row.key)) : items.map((item, index) => /* @__PURE__ */ jsx4("li", { "data-slicer-index": index, children: /* @__PURE__ */ jsx4(
651
+ ItemRow,
652
+ {
653
+ item,
654
+ state,
655
+ tabIndex: index === navigation.activeIndex ? 0 : -1
656
+ }
657
+ ) }, item.key)) })
658
+ ] })
659
+ ] })
660
+ }
661
+ )
494
662
  ]
495
663
  }
496
664
  );
@@ -622,9 +790,9 @@ function DropdownSlicerContent(props) {
622
790
  }
623
791
 
624
792
  // src/components/range-slicer/range-slicer.tsx
625
- import { useCallback as useCallback6, useId as useId5, useMemo as useMemo6 } from "react";
793
+ import { useCallback as useCallback8, useId as useId5, useMemo as useMemo6 } from "react";
626
794
  import { mergeClasses as mergeClasses3 } from "@griffel/react";
627
- import { formatString as formatString8, formatValue as formatValue2, getString as getString5 } from "@microsoft/fabric-visuals-core";
795
+ import { formatNumericInput, formatString as formatString8, formatValue as formatValue2, getString as getString5, parseNumericInput } from "@microsoft/fabric-visuals-core";
628
796
 
629
797
  // src/components/range-slicer/range-slicer-data.ts
630
798
  import { formatString as formatString4, isDataTable as isDataTable2 } from "@microsoft/fabric-visuals-core";
@@ -637,6 +805,7 @@ function readRangeSlicerData(data, column, includeHistogram = true, binCount) {
637
805
  title: column,
638
806
  format: void 0,
639
807
  domain: null,
808
+ hasOnlyIntegerValues: false,
640
809
  histogram: [],
641
810
  error: formatString4("Common_ColumnNotFound", column)
642
811
  };
@@ -644,6 +813,7 @@ function readRangeSlicerData(data, column, includeHistogram = true, binCount) {
644
813
  const definition = table.columns[columnIndex];
645
814
  let minimum;
646
815
  let maximum;
816
+ let hasOnlyIntegerValues = true;
647
817
  let numericRowCount = 0;
648
818
  const validBinCount = includeHistogram ? getValidHistogramBinCount(binCount) : void 0;
649
819
  const distinctValues = includeHistogram && validBinCount === void 0 ? /* @__PURE__ */ new Set() : void 0;
@@ -652,6 +822,7 @@ function readRangeSlicerData(data, column, includeHistogram = true, binCount) {
652
822
  if (typeof value === "number" && Number.isFinite(value)) {
653
823
  minimum = minimum === void 0 ? value : Math.min(minimum, value);
654
824
  maximum = maximum === void 0 ? value : Math.max(maximum, value);
825
+ hasOnlyIntegerValues = hasOnlyIntegerValues && Number.isInteger(value);
655
826
  if (distinctValues) {
656
827
  numericRowCount++;
657
828
  if (distinctValues.size < maxAutomaticHistogramBinCount) distinctValues.add(value);
@@ -675,6 +846,7 @@ function readRangeSlicerData(data, column, includeHistogram = true, binCount) {
675
846
  title: definition.displayName ?? definition.name,
676
847
  format: definition.format,
677
848
  domain,
849
+ hasOnlyIntegerValues: domain !== null && hasOnlyIntegerValues,
678
850
  histogram
679
851
  };
680
852
  }
@@ -867,7 +1039,7 @@ var useRangeSlicerStyles = makeStyles6(inVisualsLayer6({
867
1039
  }));
868
1040
 
869
1041
  // src/components/range-slicer/range-value-input.tsx
870
- import { useCallback as useCallback3, useId as useId3, useState as useState3 } from "react";
1042
+ import { useCallback as useCallback5, useId as useId3, useState as useState4 } from "react";
871
1043
  import { formatString as formatString5 } from "@microsoft/fabric-visuals-core";
872
1044
  import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
873
1045
  function RangeValueInput({
@@ -878,41 +1050,39 @@ function RangeValueInput({
878
1050
  disabled,
879
1051
  descriptionId,
880
1052
  formatValue: formatValue3,
1053
+ parseValue,
881
1054
  onCommit
882
1055
  }) {
883
1056
  const styles = useRangeSlicerStyles();
884
1057
  const errorId = useId3();
885
- const [draft, setDraft] = useState3();
886
- const [error, setError] = useState3();
887
- const handleFocus = useCallback3(() => {
888
- setDraft(String(value));
889
- setError(void 0);
890
- }, [value]);
891
- const handleChange = useCallback3((event) => {
1058
+ const [draft, setDraft] = useState4();
1059
+ const [error, setError] = useState4();
1060
+ const handleChange = useCallback5((event) => {
892
1061
  setDraft(event.currentTarget.value);
893
1062
  setError(void 0);
894
1063
  }, []);
895
- const handleBlur = useCallback3((event) => {
1064
+ const handleBlur = useCallback5((event) => {
1065
+ if (draft === void 0) return;
896
1066
  const text = event.currentTarget.value.trim();
897
- const nextValue = Number(text);
898
- if (text !== "" && Number.isFinite(nextValue) && nextValue >= min && nextValue <= max) {
1067
+ const nextValue = parseValue(text);
1068
+ if (nextValue !== void 0 && nextValue >= min && nextValue <= max) {
899
1069
  onCommit(nextValue);
900
1070
  setDraft(void 0);
901
1071
  setError(void 0);
902
1072
  } else {
903
1073
  setError(formatString5("RangeSlicer_InvalidValue", formatValue3(min), formatValue3(max)));
904
1074
  }
905
- }, [min, max, formatValue3, onCommit]);
906
- const handleKeyDown = useCallback3((event) => {
1075
+ }, [draft, min, max, formatValue3, parseValue, onCommit]);
1076
+ const handleKeyDown = useCallback5((event) => {
907
1077
  if (event.key === "Enter") {
908
1078
  event.preventDefault();
909
1079
  event.currentTarget.blur();
910
1080
  } else if (event.key === "Escape") {
911
1081
  event.preventDefault();
912
- setDraft(String(value));
1082
+ setDraft(void 0);
913
1083
  setError(void 0);
914
1084
  }
915
- }, [value]);
1085
+ }, []);
916
1086
  return /* @__PURE__ */ jsxs5("div", { children: [
917
1087
  /* @__PURE__ */ jsx7(
918
1088
  "input",
@@ -925,7 +1095,6 @@ function RangeValueInput({
925
1095
  "aria-invalid": Boolean(error),
926
1096
  disabled,
927
1097
  value: draft ?? formatValue3(value),
928
- onFocus: handleFocus,
929
1098
  onChange: handleChange,
930
1099
  onBlur: handleBlur,
931
1100
  onKeyDown: handleKeyDown
@@ -977,15 +1146,18 @@ function RangeHistogram({ counts, domain, selectedRange, title }) {
977
1146
 
978
1147
  // src/components/range-slicer/range-slider.tsx
979
1148
  import { Root as Slider, Track, Range, Thumb } from "@radix-ui/react-slider";
980
- import { useCallback as useCallback4, useMemo as useMemo4, useRef as useRef2 } from "react";
1149
+ import { useCallback as useCallback6, useMemo as useMemo4, useRef as useRef4 } from "react";
981
1150
  import { formatString as formatString7 } from "@microsoft/fabric-visuals-core";
982
1151
 
983
1152
  // src/components/range-slicer/range-slider-steps.ts
984
- function getAutomaticRangeStep(domain, formatBound = String) {
1153
+ function getAutomaticRangeStep(domain, formatBound = String, hasOnlyIntegerValues = false) {
985
1154
  const [minimum, maximum] = domain;
986
1155
  if (minimum === maximum) return 1;
987
1156
  const span = maximum - minimum;
988
1157
  let step = getNiceStep(Math.max(span / 100, Number.MIN_VALUE));
1158
+ if (hasOnlyIntegerValues) {
1159
+ step = Math.max(1, Math.ceil(step));
1160
+ }
989
1161
  while (step < span && hasRepeatedLabels(domain, step, formatBound)) {
990
1162
  step = getNiceStep(step * 2);
991
1163
  }
@@ -1015,6 +1187,7 @@ function RangeSlider({
1015
1187
  domain,
1016
1188
  selectedRange,
1017
1189
  step,
1190
+ hasOnlyIntegerValues,
1018
1191
  disabled,
1019
1192
  title,
1020
1193
  descriptionId,
@@ -1023,28 +1196,28 @@ function RangeSlider({
1023
1196
  onValueCommit
1024
1197
  }) {
1025
1198
  const styles = useRangeSlicerStyles();
1026
- const lowerThumb = useRef2(null);
1027
- const upperThumb = useRef2(null);
1028
- const usesAutomaticStep = step === void 0;
1199
+ const lowerThumb = useRef4(null);
1200
+ const upperThumb = useRef4(null);
1029
1201
  const sliderStep = useMemo4(
1030
- () => step ?? getAutomaticRangeStep(domain, formatBound),
1031
- [domain, step, formatBound]
1202
+ () => step ?? getAutomaticRangeStep(domain, formatBound, hasOnlyIntegerValues),
1203
+ [domain, step, formatBound, hasOnlyIntegerValues]
1032
1204
  );
1033
- const handleKeyDown = useCallback4((event) => {
1034
- if (usesAutomaticStep && !disabled) {
1035
- if (event.key === "Home") {
1036
- event.preventDefault();
1037
- onValueChange([domain[0], selectedRange[1]]);
1038
- onValueCommit([domain[0], selectedRange[1]]);
1039
- lowerThumb.current?.focus();
1040
- } else if (event.key === "End") {
1205
+ const handleKeyDown = useCallback6((event) => {
1206
+ const isEndpointKey = event.key === "Home" || event.key === "End";
1207
+ if (isEndpointKey && !disabled) {
1208
+ let nextRange;
1209
+ if (event.target === lowerThumb.current) {
1210
+ nextRange = [event.key === "Home" ? domain[0] : selectedRange[1], selectedRange[1]];
1211
+ } else if (event.target === upperThumb.current) {
1212
+ nextRange = [selectedRange[0], event.key === "Home" ? selectedRange[0] : domain[1]];
1213
+ }
1214
+ if (nextRange) {
1041
1215
  event.preventDefault();
1042
- onValueChange([selectedRange[0], domain[1]]);
1043
- onValueCommit([selectedRange[0], domain[1]]);
1044
- upperThumb.current?.focus();
1216
+ onValueChange(nextRange);
1217
+ onValueCommit(nextRange);
1045
1218
  }
1046
1219
  }
1047
- }, [usesAutomaticStep, disabled, selectedRange, domain, onValueChange, onValueCommit]);
1220
+ }, [disabled, selectedRange, domain, onValueChange, onValueCommit]);
1048
1221
  return /* @__PURE__ */ jsxs7(
1049
1222
  Slider,
1050
1223
  {
@@ -1091,7 +1264,7 @@ function RangeSlider({
1091
1264
  }
1092
1265
 
1093
1266
  // src/components/range-slicer/use-range-selection.ts
1094
- import { useCallback as useCallback5, useEffect as useEffect2, useMemo as useMemo5, useRef as useRef3, useState as useState4 } from "react";
1267
+ import { useCallback as useCallback7, useEffect as useEffect3, useMemo as useMemo5, useRef as useRef5, useState as useState5 } from "react";
1095
1268
  function resolveSelection(domain, selection) {
1096
1269
  if (selection) {
1097
1270
  if (Number.isNaN(selection[0]) || Number.isNaN(selection[1]) || selection[0] > selection[1]) {
@@ -1108,13 +1281,13 @@ function resolveSelection(domain, selection) {
1108
1281
  }
1109
1282
  function useRangeSelection(domain, column, onInteraction, selection) {
1110
1283
  const resolvedSelection = useMemo5(() => resolveSelection(domain, selection), [domain, selection]);
1111
- const [selectedRange, setSelectedRange] = useState4(resolvedSelection);
1112
- const lastCommittedRange = useRef3(resolvedSelection);
1113
- const [inputRevision, setInputRevision] = useState4(0);
1114
- const incrementInputRevision = useCallback5(() => {
1284
+ const [selectedRange, setSelectedRange] = useState5(resolvedSelection);
1285
+ const lastCommittedRange = useRef5(resolvedSelection);
1286
+ const [inputRevision, setInputRevision] = useState5(0);
1287
+ const incrementInputRevision = useCallback7(() => {
1115
1288
  setInputRevision((revision) => revision + 1);
1116
1289
  }, []);
1117
- useEffect2(() => {
1290
+ useEffect3(() => {
1118
1291
  if (selection !== void 0) {
1119
1292
  const previousRange = lastCommittedRange.current;
1120
1293
  if (previousRange?.[0] === resolvedSelection?.[0] && previousRange?.[1] === resolvedSelection?.[1]) return;
@@ -1123,7 +1296,7 @@ function useRangeSelection(domain, column, onInteraction, selection) {
1123
1296
  incrementInputRevision();
1124
1297
  }
1125
1298
  }, [selection, resolvedSelection, incrementInputRevision]);
1126
- const commitSelectedRange = useCallback5((values) => {
1299
+ const commitSelectedRange = useCallback7((values) => {
1127
1300
  if (domain) {
1128
1301
  setSelectedRange([values[0], values[1]]);
1129
1302
  const previousRange = lastCommittedRange.current;
@@ -1138,9 +1311,9 @@ function useRangeSelection(domain, column, onInteraction, selection) {
1138
1311
  selections: [{
1139
1312
  predicates: [{
1140
1313
  type: "range",
1141
- name: column,
1142
- min: isLowerBoundAtDomainMinimum ? -Infinity : values[0],
1143
- max: isUpperBoundAtDomainMaximum ? Infinity : values[1]
1314
+ fieldId: column,
1315
+ ...isLowerBoundAtDomainMinimum ? {} : { min: { kind: "value", value: values[0] } },
1316
+ ...isUpperBoundAtDomainMaximum ? {} : { max: { kind: "value", value: values[1] } }
1144
1317
  }]
1145
1318
  }]
1146
1319
  };
@@ -1148,11 +1321,11 @@ function useRangeSelection(domain, column, onInteraction, selection) {
1148
1321
  }
1149
1322
  }
1150
1323
  }, [domain, column, onInteraction]);
1151
- const handleSliderChange = useCallback5((values) => {
1324
+ const handleSliderChange = useCallback7((values) => {
1152
1325
  setSelectedRange([values[0], values[1]]);
1153
1326
  incrementInputRevision();
1154
1327
  }, [incrementInputRevision]);
1155
- const clearSelection = useCallback5(() => {
1328
+ const clearSelection = useCallback7(() => {
1156
1329
  setSelectedRange(domain);
1157
1330
  lastCommittedRange.current = domain;
1158
1331
  incrementInputRevision();
@@ -1211,11 +1384,13 @@ function RangeSlicer({
1211
1384
  "--range-stroke": theme.stroke,
1212
1385
  fontFamily: theme.typography?.label?.family
1213
1386
  } : {}, [theme]);
1214
- const formatBound = useCallback6((value) => String(formatValue2(value, slicerData.format)), [slicerData.format]);
1215
- const handleLowerCommit = useCallback6((value) => {
1387
+ const formatBound = useCallback8((value) => String(formatValue2(value, slicerData.format)), [slicerData.format]);
1388
+ const formatInput = useCallback8((value) => formatNumericInput(value, slicerData.format), [slicerData.format]);
1389
+ const parseInput = useCallback8((text) => parseNumericInput(text, slicerData.format), [slicerData.format]);
1390
+ const handleLowerCommit = useCallback8((value) => {
1216
1391
  if (selectedRange) commitSelectedRange([value, selectedRange[1]]);
1217
1392
  }, [selectedRange, commitSelectedRange]);
1218
- const handleUpperCommit = useCallback6((value) => {
1393
+ const handleUpperCommit = useCallback8((value) => {
1219
1394
  if (selectedRange) commitSelectedRange([selectedRange[0], value]);
1220
1395
  }, [selectedRange, commitSelectedRange]);
1221
1396
  if (slicerData.error) return /* @__PURE__ */ jsx10("div", { role: "alert", children: slicerData.error });
@@ -1244,6 +1419,7 @@ function RangeSlicer({
1244
1419
  domain: slicerData.domain,
1245
1420
  selectedRange,
1246
1421
  step: sliderStep,
1422
+ hasOnlyIntegerValues: slicerData.hasOnlyIntegerValues,
1247
1423
  disabled: areControlsDisabled,
1248
1424
  title: displayTitle,
1249
1425
  descriptionId,
@@ -1262,7 +1438,8 @@ function RangeSlicer({
1262
1438
  max: selectedRange[1],
1263
1439
  disabled: areControlsDisabled,
1264
1440
  descriptionId,
1265
- formatValue: formatBound,
1441
+ formatValue: formatInput,
1442
+ parseValue: parseInput,
1266
1443
  onCommit: handleLowerCommit
1267
1444
  },
1268
1445
  `lower-${inputRevision}`
@@ -1277,7 +1454,8 @@ function RangeSlicer({
1277
1454
  max: slicerData.domain[1],
1278
1455
  disabled: areControlsDisabled,
1279
1456
  descriptionId,
1280
- formatValue: formatBound,
1457
+ formatValue: formatInput,
1458
+ parseValue: parseInput,
1281
1459
  onCommit: handleUpperCommit
1282
1460
  },
1283
1461
  `upper-${inputRevision}`
@@ -1292,5 +1470,6 @@ function RangeSlicer({
1292
1470
  export {
1293
1471
  DropdownSlicer,
1294
1472
  ListSlicer,
1295
- RangeSlicer
1473
+ RangeSlicer,
1474
+ isSlicerValue
1296
1475
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@microsoft/fabric-slicers",
3
3
  "description": "Slicer components for Fabric Apps - Analytics",
4
- "version": "3.0.1",
4
+ "version": "4.0.0",
5
5
  "author": "Microsoft",
6
6
  "license": "MIT",
7
7
  "type": "module",
@@ -27,6 +27,6 @@
27
27
  "@tanstack/react-virtual": "^3.13.23",
28
28
  "radix-ui": "^1.6.7",
29
29
  "@radix-ui/react-slider": "^1.2.0",
30
- "@microsoft/fabric-visuals-core": "4.3.0"
30
+ "@microsoft/fabric-visuals-core": "5.0.0"
31
31
  }
32
32
  }