fluentui-extended 2026.2.19 → 2026.8.30

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/README.md CHANGED
@@ -38,6 +38,7 @@ An Advanced Find-style query builder for Dynamics 365. Build complex filter cond
38
38
  ## Quick Start
39
39
 
40
40
  ```tsx
41
+ import { useState } from 'react';
41
42
  import { Lookup, LookupOption } from 'fluentui-extended';
42
43
  import { FluentProvider, webLightTheme } from '@fluentui/react-components';
43
44
 
@@ -161,12 +162,120 @@ import { AddRegular, PersonSearchRegular } from '@fluentui/react-icons';
161
162
  />
162
163
  ```
163
164
 
165
+ ### Multi-Entity Lookup with Filter Buttons
166
+
167
+ Replicate the native Dynamics 365 lookup pattern where users can filter between entity types:
168
+
169
+ ```tsx
170
+ import { Text, Button, Link, ToggleButton } from '@fluentui/react-components';
171
+ import { BuildingRegular, PersonRegular, ArrowLeftRegular } from '@fluentui/react-icons';
172
+
173
+ function MultiEntityLookup() {
174
+ const [showAccounts, setShowAccounts] = useState(true);
175
+ const [showContacts, setShowContacts] = useState(true);
176
+
177
+ const options: LookupOption[] = [
178
+ { key: 'acc-1', text: 'Contoso Ltd', icon: <BuildingRegular />, details: [...] },
179
+ { key: 'con-1', text: 'John Smith', icon: <PersonRegular />, details: [...] },
180
+ ];
181
+
182
+ // Filter based on key prefix
183
+ const filteredOptions = useMemo(() =>
184
+ options.filter(opt => {
185
+ if (opt.key.startsWith('acc-')) return showAccounts;
186
+ if (opt.key.startsWith('con-')) return showContacts;
187
+ return true;
188
+ }), [showAccounts, showContacts]
189
+ );
190
+
191
+ return (
192
+ <Lookup
193
+ options={filteredOptions}
194
+ header={
195
+ // Drill-down view when single entity selected
196
+ showAccounts !== showContacts ? (
197
+ <>
198
+ <Link onClick={() => { setShowAccounts(true); setShowContacts(true); }}>
199
+ <ArrowLeftRegular /> All
200
+ </Link>
201
+ <Text weight="semibold">{showAccounts ? 'Accounts' : 'Contacts'}</Text>
202
+ </>
203
+ ) : (
204
+ // Filter toggles when showing all
205
+ <>
206
+ <div style={{ display: 'flex', alignItems: 'center', gap: 4 }}>
207
+ <Text size={200}>Results from:</Text>
208
+ <ToggleButton size="small" checked={showAccounts}
209
+ onClick={() => { setShowAccounts(true); setShowContacts(false); }}>
210
+ Accounts
211
+ </ToggleButton>
212
+ <ToggleButton size="small" checked={showContacts}
213
+ onClick={() => { setShowAccounts(false); setShowContacts(true); }}>
214
+ Contacts
215
+ </ToggleButton>
216
+ </div>
217
+ <Button size="small">Recent records</Button>
218
+ </>
219
+ )
220
+ }
221
+ />
222
+ );
223
+ }
224
+ ```
225
+
226
+ ### Rich Secondary Text with React Elements
227
+
228
+ Both `secondaryText` and `details` support React elements, not just strings:
229
+
230
+ ```tsx
231
+ import { Badge } from '@fluentui/react-components';
232
+ import { CheckmarkCircleRegular } from '@fluentui/react-icons';
233
+
234
+ const options: LookupOption[] = [
235
+ {
236
+ key: '1',
237
+ text: 'John Smith',
238
+ secondaryText: (
239
+ <span style={{ display: 'flex', alignItems: 'center', gap: 6 }}>
240
+ <Badge appearance="tint" color="success" size="small" icon={<CheckmarkCircleRegular />}>
241
+ Active
242
+ </Badge>
243
+ <span>john.smith@contoso.com</span>
244
+ </span>
245
+ ),
246
+ icon: <PersonRegular />,
247
+ details: [
248
+ { label: 'Status', value: <Badge appearance="filled" color="success" size="small">Verified</Badge> },
249
+ { label: 'Role', value: <Badge appearance="tint" color="brand" size="small">Decision Maker</Badge> },
250
+ { value: <span style={{ color: '#0078d4' }}>View full profile →</span> },
251
+ ],
252
+ },
253
+ ];
254
+ ```
255
+
256
+ ---
257
+
258
+ ## Test Harness Examples
259
+
260
+ Run the test harness with `npm run harness` to see all examples in action.
261
+
262
+ | Example | Description |
263
+ |---------|-------------|
264
+ | **Basic Lookup** | Simple lookup with expandable details, no header/footer |
265
+ | **Header & Footer** | D365-style with "Accounts" header and "New" / "Advanced" footer links |
266
+ | **Details Only (No Secondary Text)** | Options with icons + details but no secondary text; demonstrates icon centering on single-line text |
267
+ | **Multi-Entity Filter** | Toggle between Accounts/Contacts with drill-down header pattern (← All) |
268
+ | **Dynamic Search (Async API)** | Simulated 800ms API delay with loading spinner; auto-loads top 5 on open |
269
+ | **Live Dynamics Lookup** | Connects to real D365 environment via Xrm.WebApi (when connected) |
270
+ | **QueryBuilder** | Full Advanced Find-style query builder with FetchXML serialization |
271
+
164
272
  ## API Reference
165
273
 
166
274
  ### Lookup Props
167
275
 
168
276
  | Prop | Type | Default | Description |
169
277
  |------|------|---------|-------------|
278
+ | `id` | `string` | auto-generated | Unique identifier for the lookup |
170
279
  | `options` | `LookupOption[]` | `[]` | Options to display in the dropdown |
171
280
  | `selectedKey` | `string \| null` | - | Selected option key (controlled) |
172
281
  | `selectedOption` | `LookupOption \| null` | - | Selected option object (recommended for async) |
@@ -178,9 +287,20 @@ import { AddRegular, PersonSearchRegular } from '@fluentui/react-icons';
178
287
  | `clearable` | `boolean` | `true` | Show clear button |
179
288
  | `minSearchLength` | `number` | `0` | Min chars before search fires |
180
289
  | `searchDebounceMs` | `number` | `300` | Search debounce delay (ms) |
290
+ | `matchInputWidth` | `boolean` | `true` | Match dropdown width to input width |
181
291
  | `header` | `ReactNode` | - | Header content |
182
292
  | `footer` | `ReactNode` | - | Footer content |
183
293
  | `disabled` | `boolean` | `false` | Disable the lookup |
294
+ | `open` | `boolean` | - | Controlled open state for the dropdown |
295
+ | `onOpenChange` | `(open: boolean) => void` | - | Callback when dropdown open state changes |
296
+
297
+ ### Cross-Document Support (Dynamics 365 Iframes)
298
+
299
+ The Lookup component automatically detects when it's rendered inside a cross-document context (e.g., a React tree mounted into a parent window's document from an iframe). It uses `ownerDocument` and `ownerDocument.defaultView` instead of the global `document` and `window` to ensure:
300
+
301
+ - **Dismiss on click outside** works correctly (mousedown listener on the correct document)
302
+ - **Scroll/resize tracking** responds to the correct window's events
303
+ - **Dropdown positioning** uses the correct scroll offsets
184
304
 
185
305
  ### Inherited Input Props
186
306
 
@@ -204,21 +324,23 @@ The Lookup component extends Fluent UI's `Input` and supports these standard pro
204
324
 
205
325
  ```ts
206
326
  interface LookupOption {
207
- key: string; // Unique identifier (required)
208
- text: string; // Display text (required)
209
- secondaryText?: string; // Secondary line of text
210
- icon?: ReactNode; // Icon component
211
- details?: LookupOptionDetail[]; // Expandable details (chevron appears)
212
- data?: unknown; // Custom data payload
213
- disabled?: boolean; // Disable this option
327
+ key: string; // Unique identifier (required)
328
+ text: string; // Display text (required)
329
+ secondaryText?: ReactNode; // Secondary line - string, Badge, or JSX
330
+ icon?: ReactNode; // Icon component (e.g., <BuildingRegular />)
331
+ details?: LookupOptionDetail[]; // Expandable details (chevron appears)
332
+ data?: unknown; // Custom data payload for your app
333
+ disabled?: boolean; // Disable this option
214
334
  }
215
335
 
216
336
  interface LookupOptionDetail {
217
- label?: string; // Optional label (e.g., "Phone:")
218
- value: string; // Detail value
337
+ label?: ReactNode; // Optional label (e.g., "Phone:" or a Badge)
338
+ value: ReactNode; // Detail value - string or JSX element
219
339
  }
220
340
  ```
221
341
 
342
+ > **Note:** Both `secondaryText` and `details` support React elements, not just strings. See [Rich Secondary Text](#rich-secondary-text-with-react-elements) for examples.
343
+
222
344
  ## Keyboard Navigation
223
345
 
224
346
  | Key | Action |
@@ -514,14 +636,6 @@ if (!result.isValid) {
514
636
 
515
637
  ---
516
638
 
517
- ## Contributing
518
-
519
- 1. Fork the repository
520
- 2. Create your feature branch (`git checkout -b feature/amazing-feature`)
521
- 3. Commit your changes (`git commit -m 'Add amazing feature'`)
522
- 4. Push to the branch (`git push origin feature/amazing-feature`)
523
- 5. Open a Pull Request
524
-
525
639
  ## Acknowledgments
526
640
 
527
641
  This library extends [Microsoft's Fluent UI React v9](https://react.fluentui.dev/) components. Thank you to Microsoft and the Fluent UI team for creating and maintaining such an excellent design system.
@@ -530,6 +644,83 @@ This library extends [Microsoft's Fluent UI React v9](https://react.fluentui.dev
530
644
  - [Fluent UI GitHub](https://github.com/microsoft/fluentui)
531
645
  - [Fluent 2 Design System](https://fluent2.microsoft.design/)
532
646
 
647
+ ---
648
+
649
+ ## Changelog
650
+
651
+ > Version format: `YYYY.M.DD` (e.g., `2026.8.30` = August 30, 2026)
652
+
653
+ ### 2026.8.30
654
+
655
+ - ✨ Added multi-entity filter pattern with drill-down header ("← All" back button) in test harness
656
+ - ✨ Added "Details Only (No Secondary Text)" example to test harness
657
+ - ✨ Support for React elements in `secondaryText` and `details[].value` (Badges, icons, styled text)
658
+ - ♻️ Improved `aria-selected`/`aria-disabled` attribute handling
659
+ - 📝 Documentation overhaul with complete API reference and examples
660
+
661
+ ### 2026.6.12
662
+
663
+ - ✨ Added React 19 support to peerDependencies
664
+ - 📝 Updated README with cross-document support documentation
665
+
666
+ ### 2026.2.19
667
+
668
+ - 🐛 Fixed cross-document dismiss in Dynamics 365 iframes using `ownerDocument`
669
+
670
+ ### 2026.2.17
671
+
672
+ - 🐛 Removed `requestAnimationFrame` — handler registers immediately
673
+ - 🐛 Switched to capture phase for dismiss handler to prevent D365 DOM interference
674
+
675
+ ### 2026.2.15
676
+
677
+ - ✨ Added controlled `open` and `onOpenChange` props for programmatic dropdown control
678
+ - 🐛 Removed `requestAnimationFrame` from dismiss handler
679
+
680
+ ### 2026.2.13
681
+
682
+ - ♻️ Rebuilt popup from scratch using custom element (Fluent UI Popover had unexpected behavior)
683
+
684
+ ### 2026.2.11
685
+
686
+ - 🐛 Added `onOpenChange` callback to sync internal state with Popover dismiss events (outside click, Escape, focus loss)
687
+
688
+ ### 2026.2.10
689
+
690
+ - 🐛 Fixed Lookup not allowing space character in search input
691
+
692
+ ### 2026.2.8
693
+
694
+ - ✨ **QueryBuilder**: Native API integration for field metadata
695
+ - ✨ **QueryBuilder**: Lookup field support with related entity validation
696
+
697
+ ### 2026.2.7
698
+
699
+ - ♻️ Removed `Xrm` global dependency — now uses native `/api/data/v9.2/` fetch calls
700
+
701
+ ### 2026.2.6
702
+
703
+ - ♻️ **QueryBuilder**: Refactored to reuse shared components and styles
704
+
705
+ ### 2026.2.5
706
+
707
+ - ✨ **QueryBuilder**: Initial release (beta) — Advanced Find-style query builder
708
+ - ♻️ **Lookup**: Changed from options-only to popup-based rendering
709
+
710
+ ### 2026.2.3
711
+
712
+ - ✨ Added `id` prop — auto-generated if not provided
713
+
714
+ ### 2026.2.2
715
+
716
+ - 🐛 Fixed classic JSX transform for React 16 compatibility
717
+ - ✨ Added React 16.8+ support
718
+
719
+ ### 2026.2.1
720
+
721
+ - 🎉 Initial release
722
+ - ✨ Lookup component with async search, expandable details, header/footer
723
+
533
724
  ## License
534
725
 
535
726
  MIT
package/dist/index.d.mts CHANGED
@@ -2,18 +2,18 @@ import * as React from 'react';
2
2
  import { InputProps } from '@fluentui/react-components';
3
3
 
4
4
  interface LookupOptionDetail {
5
- /** Label for the detail row */
6
- label?: string;
7
- /** Value for the detail row */
8
- value: string;
5
+ /** Label for the detail row - can be a string or React element */
6
+ label?: React.ReactNode;
7
+ /** Value for the detail row - can be a string or React element */
8
+ value: React.ReactNode;
9
9
  }
10
10
  interface LookupOption {
11
11
  /** Unique identifier for the option */
12
12
  key: string;
13
13
  /** Display text for the option */
14
14
  text: string;
15
- /** Optional secondary text */
16
- secondaryText?: string;
15
+ /** Optional secondary text - can be a string or React element */
16
+ secondaryText?: React.ReactNode;
17
17
  /** Optional icon to display */
18
18
  icon?: React.ReactNode;
19
19
  /** Optional expandable details */
package/dist/index.d.ts CHANGED
@@ -2,18 +2,18 @@ import * as React from 'react';
2
2
  import { InputProps } from '@fluentui/react-components';
3
3
 
4
4
  interface LookupOptionDetail {
5
- /** Label for the detail row */
6
- label?: string;
7
- /** Value for the detail row */
8
- value: string;
5
+ /** Label for the detail row - can be a string or React element */
6
+ label?: React.ReactNode;
7
+ /** Value for the detail row - can be a string or React element */
8
+ value: React.ReactNode;
9
9
  }
10
10
  interface LookupOption {
11
11
  /** Unique identifier for the option */
12
12
  key: string;
13
13
  /** Display text for the option */
14
14
  text: string;
15
- /** Optional secondary text */
16
- secondaryText?: string;
15
+ /** Optional secondary text - can be a string or React element */
16
+ secondaryText?: React.ReactNode;
17
17
  /** Optional icon to display */
18
18
  icon?: React.ReactNode;
19
19
  /** Optional expandable details */
package/dist/index.js CHANGED
@@ -88,15 +88,19 @@ var useLookupStyles = reactComponents.makeStyles({
88
88
  flexDirection: "row",
89
89
  alignItems: "flex-start",
90
90
  boxSizing: "border-box",
91
- padding: "8px 12px",
91
+ paddingTop: "6px",
92
+ paddingBottom: "6px",
93
+ paddingLeft: "12px",
94
+ paddingRight: "8px",
92
95
  cursor: "pointer",
93
- borderRadius: reactComponents.tokens.borderRadiusSmall,
96
+ borderRadius: reactComponents.tokens.borderRadiusNone,
94
97
  backgroundColor: "transparent",
95
98
  border: "none",
96
99
  width: "100%",
97
100
  overflow: "hidden",
98
101
  textAlign: "left",
99
- gap: "8px",
102
+ gap: "10px",
103
+ minHeight: "40px",
100
104
  "&:hover": {
101
105
  backgroundColor: reactComponents.tokens.colorNeutralBackground1Hover
102
106
  },
@@ -110,16 +114,24 @@ var useLookupStyles = reactComponents.makeStyles({
110
114
  display: "flex",
111
115
  alignItems: "center",
112
116
  justifyContent: "center",
113
- width: "20px",
114
- height: "20px",
117
+ width: "24px",
118
+ height: "24px",
119
+ fontSize: "20px",
115
120
  flexShrink: 0,
116
- color: reactComponents.tokens.colorNeutralForeground3
121
+ color: reactComponents.tokens.colorNeutralForeground1,
122
+ marginTop: "0px"
123
+ // Centered on single text row
124
+ },
125
+ optionIconWithSecondary: {
126
+ marginTop: "6px"
127
+ // Centered between text + secondaryText rows
117
128
  },
118
129
  optionContent: {
119
130
  display: "flex",
120
131
  flexDirection: "column",
121
132
  flex: "1 1 auto",
122
- minWidth: 0
133
+ minWidth: 0,
134
+ gap: "2px"
123
135
  },
124
136
  optionExpandButton: {
125
137
  display: "flex",
@@ -128,6 +140,7 @@ var useLookupStyles = reactComponents.makeStyles({
128
140
  width: "24px",
129
141
  height: "24px",
130
142
  marginLeft: "auto",
143
+ marginTop: "2px",
131
144
  flexShrink: 0,
132
145
  cursor: "pointer",
133
146
  borderRadius: reactComponents.tokens.borderRadiusSmall,
@@ -161,14 +174,15 @@ var useLookupStyles = reactComponents.makeStyles({
161
174
  },
162
175
  optionText: {
163
176
  fontSize: reactComponents.tokens.fontSizeBase300,
164
- fontWeight: reactComponents.tokens.fontWeightRegular,
165
- color: reactComponents.tokens.colorNeutralForeground1
177
+ fontWeight: reactComponents.tokens.fontWeightSemibold,
178
+ color: reactComponents.tokens.colorNeutralForeground1,
179
+ lineHeight: reactComponents.tokens.lineHeightBase300
166
180
  },
167
181
  optionSecondaryText: {
168
182
  fontSize: reactComponents.tokens.fontSizeBase200,
169
183
  fontWeight: reactComponents.tokens.fontWeightRegular,
170
- color: reactComponents.tokens.colorNeutralForeground3,
171
- marginTop: "2px"
184
+ color: reactComponents.tokens.colorNeutralForeground2,
185
+ lineHeight: reactComponents.tokens.lineHeightBase200
172
186
  },
173
187
  optionDetails: {
174
188
  display: "flex",
@@ -306,9 +320,15 @@ var Lookup = ({
306
320
  return options;
307
321
  }
308
322
  const lowerSearch = searchText.toLowerCase();
309
- return options.filter(
310
- (opt) => opt.text.toLowerCase().includes(lowerSearch) || opt.secondaryText?.toLowerCase().includes(lowerSearch)
311
- );
323
+ return options.filter((opt) => {
324
+ if (opt.text.toLowerCase().includes(lowerSearch)) {
325
+ return true;
326
+ }
327
+ if (typeof opt.secondaryText === "string") {
328
+ return opt.secondaryText.toLowerCase().includes(lowerSearch);
329
+ }
330
+ return false;
331
+ });
312
332
  }, [options, searchText, minSearchLength]);
313
333
  const highlightedOptionId = React3__namespace.useMemo(() => {
314
334
  if (!isOpen || highlightedIndex < 0 || highlightedIndex >= filteredOptions.length) {
@@ -580,8 +600,8 @@ var Lookup = ({
580
600
  id: `${lookupId}-option-${option.key}`,
581
601
  role: "option",
582
602
  "data-index": index,
583
- "aria-selected": option.key === selectedOption?.key ? true : false,
584
- "aria-disabled": option.disabled === true ? true : void 0,
603
+ "aria-selected": option.key === selectedOption?.key,
604
+ "aria-disabled": option.disabled || void 0,
585
605
  className: reactComponents.mergeClasses(
586
606
  styles.option,
587
607
  index === highlightedIndex && styles.optionHighlighted,
@@ -591,7 +611,10 @@ var Lookup = ({
591
611
  onClick: () => handleSelectOption(option),
592
612
  onMouseEnter: () => setHighlightedIndex(index)
593
613
  },
594
- option.icon && /* @__PURE__ */ React3__namespace.createElement("span", { className: styles.optionIcon }, option.icon),
614
+ option.icon && /* @__PURE__ */ React3__namespace.createElement("span", { className: reactComponents.mergeClasses(
615
+ styles.optionIcon,
616
+ !!option.secondaryText && styles.optionIconWithSecondary
617
+ ) }, option.icon),
595
618
  /* @__PURE__ */ React3__namespace.createElement("span", { className: styles.optionContent }, /* @__PURE__ */ React3__namespace.createElement("span", { className: styles.optionText }, option.text), option.secondaryText && /* @__PURE__ */ React3__namespace.createElement("span", { className: styles.optionSecondaryText }, option.secondaryText), isExpanded && hasDetails && /* @__PURE__ */ React3__namespace.createElement("div", { className: styles.optionDetails }, option.details.map((detail, detailIndex) => /* @__PURE__ */ React3__namespace.createElement("div", { key: detailIndex, className: styles.optionDetailRow }, detail.label && /* @__PURE__ */ React3__namespace.createElement("span", { className: styles.optionDetailLabel }, detail.label, ":"), /* @__PURE__ */ React3__namespace.createElement("span", { className: styles.optionDetailValue }, detail.value))))),
596
619
  hasDetails && /* @__PURE__ */ React3__namespace.createElement(
597
620
  "span",