@fluentui-copilot/react-prompt-listbox 0.0.0-nightly-20240719-0406-ee8d99d6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/CHANGELOG.json +56 -0
  2. package/CHANGELOG.md +19 -0
  3. package/LICENSE +23 -0
  4. package/README.md +5 -0
  5. package/dist/index.d.ts +230 -0
  6. package/lib/PromptListbox.js +2 -0
  7. package/lib/PromptListbox.js.map +1 -0
  8. package/lib/components/PromptListbox/PromptListbox.js +14 -0
  9. package/lib/components/PromptListbox/PromptListbox.js.map +1 -0
  10. package/lib/components/PromptListbox/PromptListbox.types.js +2 -0
  11. package/lib/components/PromptListbox/PromptListbox.types.js.map +1 -0
  12. package/lib/components/PromptListbox/index.js +6 -0
  13. package/lib/components/PromptListbox/index.js.map +1 -0
  14. package/lib/components/PromptListbox/renderPromptListbox.js +20 -0
  15. package/lib/components/PromptListbox/renderPromptListbox.js.map +1 -0
  16. package/lib/components/PromptListbox/usePromptListbox.js +81 -0
  17. package/lib/components/PromptListbox/usePromptListbox.js.map +1 -0
  18. package/lib/components/PromptListbox/usePromptListboxContextValues.js +33 -0
  19. package/lib/components/PromptListbox/usePromptListboxContextValues.js.map +1 -0
  20. package/lib/components/PromptListbox/usePromptListboxStyles.styles.js +37 -0
  21. package/lib/components/PromptListbox/usePromptListboxStyles.styles.js.map +1 -0
  22. package/lib/components/utils/OptionCollection.types.js +3 -0
  23. package/lib/components/utils/OptionCollection.types.js.map +1 -0
  24. package/lib/components/utils/PromptListboxFunctionality.types.js +2 -0
  25. package/lib/components/utils/PromptListboxFunctionality.types.js.map +1 -0
  26. package/lib/components/utils/Selection.types.js +3 -0
  27. package/lib/components/utils/Selection.types.js.map +1 -0
  28. package/lib/components/utils/dropdownKeyActions.js +52 -0
  29. package/lib/components/utils/dropdownKeyActions.js.map +1 -0
  30. package/lib/components/utils/useComboboxPositioning.js +25 -0
  31. package/lib/components/utils/useComboboxPositioning.js.map +1 -0
  32. package/lib/components/utils/useOptionCollection.js +39 -0
  33. package/lib/components/utils/useOptionCollection.js.map +1 -0
  34. package/lib/components/utils/usePromptListboxFunctionality.js +143 -0
  35. package/lib/components/utils/usePromptListboxFunctionality.js.map +1 -0
  36. package/lib/components/utils/useSelection.js +54 -0
  37. package/lib/components/utils/useSelection.js.map +1 -0
  38. package/lib/components/utils/useTriggerKeyDown.js +129 -0
  39. package/lib/components/utils/useTriggerKeyDown.js.map +1 -0
  40. package/lib/index.js +4 -0
  41. package/lib/index.js.map +1 -0
  42. package/lib/plugins/TextCursorPositionPlugin.js +44 -0
  43. package/lib/plugins/TextCursorPositionPlugin.js.map +1 -0
  44. package/lib-commonjs/PromptListbox.js +7 -0
  45. package/lib-commonjs/PromptListbox.js.map +1 -0
  46. package/lib-commonjs/components/PromptListbox/PromptListbox.js +23 -0
  47. package/lib-commonjs/components/PromptListbox/PromptListbox.js.map +1 -0
  48. package/lib-commonjs/components/PromptListbox/PromptListbox.types.js +5 -0
  49. package/lib-commonjs/components/PromptListbox/PromptListbox.types.js.map +1 -0
  50. package/lib-commonjs/components/PromptListbox/index.js +11 -0
  51. package/lib-commonjs/components/PromptListbox/index.js.map +1 -0
  52. package/lib-commonjs/components/PromptListbox/renderPromptListbox.js +26 -0
  53. package/lib-commonjs/components/PromptListbox/renderPromptListbox.js.map +1 -0
  54. package/lib-commonjs/components/PromptListbox/usePromptListbox.js +68 -0
  55. package/lib-commonjs/components/PromptListbox/usePromptListbox.js.map +1 -0
  56. package/lib-commonjs/components/PromptListbox/usePromptListboxContextValues.js +36 -0
  57. package/lib-commonjs/components/PromptListbox/usePromptListboxContextValues.js.map +1 -0
  58. package/lib-commonjs/components/PromptListbox/usePromptListboxStyles.styles.js +71 -0
  59. package/lib-commonjs/components/PromptListbox/usePromptListboxStyles.styles.js.map +1 -0
  60. package/lib-commonjs/components/utils/OptionCollection.types.js +6 -0
  61. package/lib-commonjs/components/utils/OptionCollection.types.js.map +1 -0
  62. package/lib-commonjs/components/utils/PromptListboxFunctionality.types.js +5 -0
  63. package/lib-commonjs/components/utils/PromptListboxFunctionality.types.js.map +1 -0
  64. package/lib-commonjs/components/utils/Selection.types.js +6 -0
  65. package/lib-commonjs/components/utils/Selection.types.js.map +1 -0
  66. package/lib-commonjs/components/utils/dropdownKeyActions.js +52 -0
  67. package/lib-commonjs/components/utils/dropdownKeyActions.js.map +1 -0
  68. package/lib-commonjs/components/utils/useComboboxPositioning.js +32 -0
  69. package/lib-commonjs/components/utils/useComboboxPositioning.js.map +1 -0
  70. package/lib-commonjs/components/utils/useOptionCollection.js +46 -0
  71. package/lib-commonjs/components/utils/useOptionCollection.js.map +1 -0
  72. package/lib-commonjs/components/utils/usePromptListboxFunctionality.js +150 -0
  73. package/lib-commonjs/components/utils/usePromptListboxFunctionality.js.map +1 -0
  74. package/lib-commonjs/components/utils/useSelection.js +72 -0
  75. package/lib-commonjs/components/utils/useSelection.js.map +1 -0
  76. package/lib-commonjs/components/utils/useTriggerKeyDown.js +134 -0
  77. package/lib-commonjs/components/utils/useTriggerKeyDown.js.map +1 -0
  78. package/lib-commonjs/index.js +37 -0
  79. package/lib-commonjs/index.js.map +1 -0
  80. package/lib-commonjs/plugins/TextCursorPositionPlugin.js +52 -0
  81. package/lib-commonjs/plugins/TextCursorPositionPlugin.js.map +1 -0
  82. package/package.json +49 -0
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Note, this is mainly brought from Fluent UI, only removed the closing and
3
+ * opening logic since that's not needed for this use case.
4
+ */import * as keys from '@fluentui/keyboard-keys';
5
+ /**
6
+ * Converts a keyboard interaction into a defined action
7
+ */
8
+ export function getDropdownActionFromKey(e, options) {
9
+ const {
10
+ isInLastPosition
11
+ } = options;
12
+ const code = e.key;
13
+ const {
14
+ altKey,
15
+ ctrlKey,
16
+ key,
17
+ metaKey
18
+ } = e;
19
+ // typing action occurs whether open or closed
20
+ if (key.length === 1 && code !== keys.Space && !altKey && !ctrlKey && !metaKey) {
21
+ return 'Type';
22
+ }
23
+ // select or close actions
24
+ if (code === keys.ArrowUp && altKey || code === keys.Enter) {
25
+ return 'CloseSelect';
26
+ }
27
+ // navigation interactions
28
+ if (code === keys.ArrowDown) {
29
+ return isInLastPosition ? 'Next' : 'Type';
30
+ }
31
+ if (code === keys.ArrowUp) {
32
+ return isInLastPosition ? 'Previous' : 'Type';
33
+ }
34
+ if (code === keys.Home) {
35
+ return 'First';
36
+ }
37
+ if (code === keys.End) {
38
+ return 'Last';
39
+ }
40
+ if (code === keys.PageUp) {
41
+ return 'PageUp';
42
+ }
43
+ if (code === keys.PageDown) {
44
+ return 'PageDown';
45
+ }
46
+ if (code === keys.Tab) {
47
+ return 'Tab';
48
+ }
49
+ // if nothing matched, return none
50
+ return 'None';
51
+ }
52
+ //# sourceMappingURL=dropdownKeyActions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["dropdownKeyActions.ts"],"sourcesContent":["/**\n * Note, this is mainly brought from Fluent UI, only removed the closing and\n * opening logic since that's not needed for this use case.\n */\n\nimport * as keys from '@fluentui/keyboard-keys';\nimport type * as React from 'react';\n\n/**\n * enum of actions available in any type of managed dropdown control\n * e.g. combobox, select, datepicker, menu\n */\nexport type DropdownActions =\n | 'CloseSelect'\n | 'First'\n | 'Last'\n | 'Next'\n | 'None'\n | 'PageDown'\n | 'PageUp'\n | 'Previous'\n | 'Select'\n | 'Tab'\n | 'Type';\n\nexport interface DropdownActionOptions {\n open?: boolean;\n multiselect?: boolean;\n isInLastPosition: boolean;\n}\n\n/**\n * Converts a keyboard interaction into a defined action\n */\nexport function getDropdownActionFromKey(\n e: KeyboardEvent | React.KeyboardEvent,\n options: DropdownActionOptions,\n): DropdownActions {\n const { isInLastPosition } = options;\n const code = e.key;\n const { altKey, ctrlKey, key, metaKey } = e;\n\n // typing action occurs whether open or closed\n if (key.length === 1 && code !== keys.Space && !altKey && !ctrlKey && !metaKey) {\n return 'Type';\n }\n\n // select or close actions\n if ((code === keys.ArrowUp && altKey) || code === keys.Enter) {\n return 'CloseSelect';\n }\n\n // navigation interactions\n if (code === keys.ArrowDown) {\n return isInLastPosition ? 'Next' : 'Type';\n }\n if (code === keys.ArrowUp) {\n return isInLastPosition ? 'Previous' : 'Type';\n }\n if (code === keys.Home) {\n return 'First';\n }\n if (code === keys.End) {\n return 'Last';\n }\n if (code === keys.PageUp) {\n return 'PageUp';\n }\n if (code === keys.PageDown) {\n return 'PageDown';\n }\n if (code === keys.Tab) {\n return 'Tab';\n }\n\n // if nothing matched, return none\n return 'None';\n}\n"],"names":["keys","getDropdownActionFromKey","e","options","isInLastPosition","code","key","altKey","ctrlKey","metaKey","length","Space","ArrowUp","Enter","ArrowDown","Home","End","PageUp","PageDown","Tab"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;;;CAGC,GAED,YAAYA,UAAU,0BAA0B;AA0BhD;;CAEC,GACD,OAAO,SAASC,yBACdC,CAAsC,EACtCC,OAA8B;IAE9B,MAAM,EAAEC,gBAAgB,EAAE,GAAGD;IAC7B,MAAME,OAAOH,EAAEI,GAAG;IAClB,MAAM,EAAEC,MAAM,EAAEC,OAAO,EAAEF,GAAG,EAAEG,OAAO,EAAE,GAAGP;IAE1C,8CAA8C;IAC9C,IAAII,IAAII,MAAM,KAAK,KAAKL,SAASL,KAAKW,KAAK,IAAI,CAACJ,UAAU,CAACC,WAAW,CAACC,SAAS;QAC9E,OAAO;IACT;IAEA,0BAA0B;IAC1B,IAAI,AAACJ,SAASL,KAAKY,OAAO,IAAIL,UAAWF,SAASL,KAAKa,KAAK,EAAE;QAC5D,OAAO;IACT;IAEA,0BAA0B;IAC1B,IAAIR,SAASL,KAAKc,SAAS,EAAE;QAC3B,OAAOV,mBAAmB,SAAS;IACrC;IACA,IAAIC,SAASL,KAAKY,OAAO,EAAE;QACzB,OAAOR,mBAAmB,aAAa;IACzC;IACA,IAAIC,SAASL,KAAKe,IAAI,EAAE;QACtB,OAAO;IACT;IACA,IAAIV,SAASL,KAAKgB,GAAG,EAAE;QACrB,OAAO;IACT;IACA,IAAIX,SAASL,KAAKiB,MAAM,EAAE;QACxB,OAAO;IACT;IACA,IAAIZ,SAASL,KAAKkB,QAAQ,EAAE;QAC1B,OAAO;IACT;IACA,IAAIb,SAASL,KAAKmB,GAAG,EAAE;QACrB,OAAO;IACT;IAEA,kCAAkC;IAClC,OAAO;AACT"}
@@ -0,0 +1,25 @@
1
+ // Brought from Fluent UI
2
+ import { resolvePositioningShorthand, usePositioning } from '@fluentui/react-positioning';
3
+ export function useComboboxPositioning(props) {
4
+ const {
5
+ positioning
6
+ } = props;
7
+ // popper options
8
+ const popperOptions = {
9
+ position: 'below',
10
+ align: 'start',
11
+ offset: {
12
+ crossAxis: 0,
13
+ mainAxis: 2
14
+ },
15
+ fallbackPositions: [],
16
+ matchTargetSize: 'width',
17
+ ...resolvePositioningShorthand(positioning)
18
+ };
19
+ const {
20
+ targetRef,
21
+ containerRef
22
+ } = usePositioning(popperOptions);
23
+ return [containerRef, targetRef];
24
+ }
25
+ //# sourceMappingURL=useComboboxPositioning.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["useComboboxPositioning.ts"],"sourcesContent":["// Brought from Fluent UI\n\nimport { resolvePositioningShorthand, usePositioning } from '@fluentui/react-positioning';\nimport type * as React from 'react';\nimport type { ComboboxBaseProps } from '@fluentui/react-combobox';\n\nexport function useComboboxPositioning(props: ComboboxBaseProps): [\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n listboxRef: React.MutableRefObject<any>,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n triggerRef: React.MutableRefObject<any>,\n] {\n const { positioning } = props;\n\n // popper options\n const popperOptions = {\n position: 'below' as const,\n align: 'start' as const,\n offset: { crossAxis: 0, mainAxis: 2 },\n fallbackPositions: [],\n matchTargetSize: 'width' as const,\n ...resolvePositioningShorthand(positioning),\n };\n\n const { targetRef, containerRef } = usePositioning(popperOptions);\n\n return [containerRef, targetRef];\n}\n"],"names":["resolvePositioningShorthand","usePositioning","useComboboxPositioning","props","positioning","popperOptions","position","align","offset","crossAxis","mainAxis","fallbackPositions","matchTargetSize","targetRef","containerRef"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,yBAAyB;AAEzB,SAASA,2BAA2B,EAAEC,cAAc,QAAQ,8BAA8B;AAI1F,OAAO,SAASC,uBAAuBC,KAAwB;IAM7D,MAAM,EAAEC,WAAW,EAAE,GAAGD;IAExB,iBAAiB;IACjB,MAAME,gBAAgB;QACpBC,UAAU;QACVC,OAAO;QACPC,QAAQ;YAAEC,WAAW;YAAGC,UAAU;QAAE;QACpCC,mBAAmB,EAAE;QACrBC,iBAAiB;QACjB,GAAGZ,4BAA4BI,YAAY;IAC7C;IAEA,MAAM,EAAES,SAAS,EAAEC,YAAY,EAAE,GAAGb,eAAeI;IAEnD,OAAO;QAACS;QAAcD;KAAU;AAClC"}
@@ -0,0 +1,39 @@
1
+ // Brought from Fluent UI
2
+ import * as React from 'react';
3
+ /**
4
+ * A hook for managing a collection of child Options
5
+ */
6
+ export const useOptionCollection = () => {
7
+ const optionsById = React.useRef(new Map());
8
+ const collectionAPI = React.useMemo(() => {
9
+ const getCount = () => optionsById.current.size;
10
+ // index searches are no longer used
11
+ const getOptionById = id => {
12
+ return optionsById.current.get(id);
13
+ };
14
+ const getOptionsMatchingValue = matcher => {
15
+ const matches = [];
16
+ for (const option of optionsById.current.values()) {
17
+ if (matcher(option.value)) {
18
+ matches.push(option);
19
+ }
20
+ }
21
+ return matches;
22
+ };
23
+ return {
24
+ getCount,
25
+ getOptionById,
26
+ getOptionsMatchingValue
27
+ };
28
+ }, []);
29
+ const registerOption = React.useCallback(option => {
30
+ optionsById.current.set(option.id, option);
31
+ return () => optionsById.current.delete(option.id);
32
+ }, []);
33
+ return {
34
+ ...collectionAPI,
35
+ options: Array.from(optionsById.current.values()),
36
+ registerOption
37
+ };
38
+ };
39
+ //# sourceMappingURL=useOptionCollection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["useOptionCollection.ts"],"sourcesContent":["// Brought from Fluent UI\n\nimport * as React from 'react';\nimport type { OptionCollectionState, OptionValue } from './OptionCollection.types';\n\n/**\n * A hook for managing a collection of child Options\n */\nexport const useOptionCollection = (): OptionCollectionState => {\n const optionsById = React.useRef(new Map<string, OptionValue>());\n\n const collectionAPI = React.useMemo(() => {\n const getCount = () => optionsById.current.size;\n\n // index searches are no longer used\n\n const getOptionById = (id: string) => {\n return optionsById.current.get(id);\n };\n\n const getOptionsMatchingValue = (matcher: (value: string) => boolean) => {\n const matches: OptionValue[] = [];\n for (const option of optionsById.current.values()) {\n if (matcher(option.value)) {\n matches.push(option);\n }\n }\n\n return matches;\n };\n\n return {\n getCount,\n getOptionById,\n getOptionsMatchingValue,\n };\n }, []);\n\n const registerOption = React.useCallback((option: OptionValue) => {\n optionsById.current.set(option.id, option);\n\n return () => optionsById.current.delete(option.id);\n }, []);\n\n return {\n ...collectionAPI,\n options: Array.from(optionsById.current.values()),\n registerOption,\n };\n};\n"],"names":["React","useOptionCollection","optionsById","useRef","Map","collectionAPI","useMemo","getCount","current","size","getOptionById","id","get","getOptionsMatchingValue","matcher","matches","option","values","value","push","registerOption","useCallback","set","delete","options","Array","from"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,yBAAyB;AAEzB,YAAYA,WAAW,QAAQ;AAG/B;;CAEC,GACD,OAAO,MAAMC,sBAAsB;IACjC,MAAMC,cAAcF,MAAMG,MAAM,CAAC,IAAIC;IAErC,MAAMC,gBAAgBL,MAAMM,OAAO,CAAC;QAClC,MAAMC,WAAW,IAAML,YAAYM,OAAO,CAACC,IAAI;QAE/C,oCAAoC;QAEpC,MAAMC,gBAAgB,CAACC;YACrB,OAAOT,YAAYM,OAAO,CAACI,GAAG,CAACD;QACjC;QAEA,MAAME,0BAA0B,CAACC;YAC/B,MAAMC,UAAyB,EAAE;YACjC,KAAK,MAAMC,UAAUd,YAAYM,OAAO,CAACS,MAAM,GAAI;gBACjD,IAAIH,QAAQE,OAAOE,KAAK,GAAG;oBACzBH,QAAQI,IAAI,CAACH;gBACf;YACF;YAEA,OAAOD;QACT;QAEA,OAAO;YACLR;YACAG;YACAG;QACF;IACF,GAAG,EAAE;IAEL,MAAMO,iBAAiBpB,MAAMqB,WAAW,CAAC,CAACL;QACxCd,YAAYM,OAAO,CAACc,GAAG,CAACN,OAAOL,EAAE,EAAEK;QAEnC,OAAO,IAAMd,YAAYM,OAAO,CAACe,MAAM,CAACP,OAAOL,EAAE;IACnD,GAAG,EAAE;IAEL,OAAO;QACL,GAAGN,aAAa;QAChBmB,SAASC,MAAMC,IAAI,CAACxB,YAAYM,OAAO,CAACS,MAAM;QAC9CG;IACF;AACF,EAAE"}
@@ -0,0 +1,143 @@
1
+ import * as React from 'react';
2
+ import { useActiveDescendant } from '@fluentui/react-aria';
3
+ import { optionClassNames } from '@fluentui/react-components';
4
+ import { mergeCallbacks, useControllableState, useEventCallback, useMergedRefs } from '@fluentui/react-utilities';
5
+ import { getDropdownActionFromKey } from './dropdownKeyActions';
6
+ import { TextCursorPositionPlugin } from '../../plugins/TextCursorPositionPlugin';
7
+ import { useOptionCollection } from './useOptionCollection';
8
+ import { useSelection } from './useSelection';
9
+ import { ArrowDown, ArrowLeft, ArrowRight, ArrowUp } from '@fluentui/keyboard-keys';
10
+ import { useComboboxPositioning } from './useComboboxPositioning';
11
+ import { useTriggerKeydown } from './useTriggerKeyDown';
12
+ import { PromptListbox } from '../PromptListbox';
13
+ export function usePromptListboxFunctionality(params) {
14
+ const {
15
+ positioning,
16
+ onOpenChange,
17
+ onSelectionModeChange,
18
+ listboxProps
19
+ } = params;
20
+ const {
21
+ listboxRef: activeDescendantListboxRef,
22
+ activeParentRef,
23
+ controller: activeDescendantController
24
+ } = useActiveDescendant({
25
+ matchOption: el => el.classList.contains(optionClassNames.root)
26
+ });
27
+ // useMergedRefs to normalize the ref into a React.RefObject type
28
+ const triggerRef = useMergedRefs(activeParentRef);
29
+ const selectionState = useSelection(listboxProps !== null && listboxProps !== void 0 ? listboxProps : {});
30
+ const {
31
+ selectOption
32
+ } = selectionState;
33
+ const optionCollection = useOptionCollection();
34
+ const {
35
+ getOptionById
36
+ } = optionCollection;
37
+ const [isInLastPosition, setIsInLastPosition] = React.useState(true);
38
+ const [isInSelectionMode, setIsInSelectionMode] = React.useState(false);
39
+ const [open, setOpen] = useControllableState({
40
+ state: params.open,
41
+ defaultState: params.defaultOpen,
42
+ initialState: false
43
+ });
44
+ const onBlur = event => {
45
+ setOpen(false);
46
+ onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(event, {
47
+ event,
48
+ type: 'focus',
49
+ open: false
50
+ });
51
+ };
52
+ const onFocus = event => {
53
+ if (event.target === event.currentTarget) {
54
+ setOpen(true);
55
+ onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(event, {
56
+ event,
57
+ type: 'focus',
58
+ open: true
59
+ });
60
+ }
61
+ };
62
+ const cursorPositionPlugin = /*#__PURE__*/React.createElement(TextCursorPositionPlugin, {
63
+ setIsInLastPosition: setIsInLastPosition
64
+ });
65
+ const onListboxBlur = React.useCallback(() => {
66
+ setIsInSelectionMode(false);
67
+ onSelectionModeChange === null || onSelectionModeChange === void 0 ? void 0 : onSelectionModeChange(false);
68
+ }, [onSelectionModeChange]);
69
+ // handle combobox keyboard interaction
70
+ const onKeyDown = useTriggerKeydown({
71
+ ...optionCollection,
72
+ activeDescendantController,
73
+ getOptionById,
74
+ onBlur: onListboxBlur,
75
+ selectOption,
76
+ isInLastPosition,
77
+ open,
78
+ multiselect: false
79
+ });
80
+ // NVDA and JAWS have bugs that suppress reading the input value text when aria-activedescendant is set
81
+ // To prevent this, we clear the HTML attribute (but save the state) when a user presses left/right arrows
82
+ // ref: https://github.com/microsoft/fluentui/issues/26359#issuecomment-1397759888
83
+ const [hideActiveDescendant, setHideActiveDescendant] = React.useState(false);
84
+ /**
85
+ * Freeform combobox should not select
86
+ */
87
+ const onInputTriggerKeyDown = useEventCallback(event => {
88
+ // update typing state to true if the user is typing
89
+ const action = getDropdownActionFromKey(event, {
90
+ open,
91
+ multiselect: false,
92
+ isInLastPosition
93
+ });
94
+ if (event.key === ArrowLeft || event.key === ArrowRight || !isInLastPosition && (event.key === ArrowDown || event.key === ArrowUp) || action === 'Type' && isInLastPosition || action === 'Type') {
95
+ activeDescendantController.blur();
96
+ setHideActiveDescendant(true);
97
+ setIsInSelectionMode(false);
98
+ onSelectionModeChange === null || onSelectionModeChange === void 0 ? void 0 : onSelectionModeChange(false);
99
+ } else if (action === 'Next' || action === 'Previous' || action === 'First' || action === 'Last' || action === 'PageUp' || action === 'PageDown') {
100
+ setHideActiveDescendant(false);
101
+ setIsInSelectionMode(true);
102
+ onSelectionModeChange === null || onSelectionModeChange === void 0 ? void 0 : onSelectionModeChange(true);
103
+ }
104
+ });
105
+ React.useEffect(() => {
106
+ if (hideActiveDescendant) {
107
+ var _triggerRef_current;
108
+ (_triggerRef_current = triggerRef.current) === null || _triggerRef_current === void 0 ? void 0 : _triggerRef_current.removeAttribute('aria-activedescendant');
109
+ }
110
+ // We only want to run this when the hideActiveDescendant changes, if the triggerRef
111
+ // is undefined, there's no need to remove theAttribute and we shouldn't be adding
112
+ // refs as dependencies since it can blow up the number of runs.
113
+ // eslint-disable-next-line react-compiler/react-compiler
114
+ // eslint-disable-next-line react-hooks/exhaustive-deps
115
+ }, [hideActiveDescendant]);
116
+ const [comboboxPopupRef, comboboxTargetRef] = useComboboxPositioning({
117
+ positioning
118
+ });
119
+ const listboxMergedRef = useMergedRefs(comboboxPopupRef, activeDescendantListboxRef, listboxProps === null || listboxProps === void 0 ? void 0 : listboxProps.ref);
120
+ const listbox = React.useMemo(() => {
121
+ return /*#__PURE__*/React.createElement(PromptListbox, {
122
+ open: open,
123
+ ...listboxProps,
124
+ ...optionCollection,
125
+ ...selectionState,
126
+ ref: listboxMergedRef,
127
+ activeDescendantController: activeDescendantController
128
+ });
129
+ }, [activeDescendantController, listboxMergedRef, listboxProps, open, optionCollection, selectionState]);
130
+ return {
131
+ promptListbox: listbox,
132
+ triggerProps: {
133
+ ref: triggerRef,
134
+ onBlur,
135
+ onFocus,
136
+ onKeyDown: useEventCallback(mergeCallbacks(onKeyDown, onInputTriggerKeyDown)),
137
+ isInSelectionMode
138
+ },
139
+ targetRef: comboboxTargetRef,
140
+ cursorPositionPlugin
141
+ };
142
+ }
143
+ //# sourceMappingURL=usePromptListboxFunctionality.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["usePromptListboxFunctionality.tsx"],"sourcesContent":["import * as React from 'react';\nimport { useActiveDescendant } from '@fluentui/react-aria';\nimport { optionClassNames } from '@fluentui/react-components';\nimport { mergeCallbacks, useControllableState, useEventCallback, useMergedRefs } from '@fluentui/react-utilities';\nimport { getDropdownActionFromKey } from './dropdownKeyActions';\nimport { TextCursorPositionPlugin } from '../../plugins/TextCursorPositionPlugin';\nimport { useOptionCollection } from './useOptionCollection';\nimport { useSelection } from './useSelection';\nimport { ArrowDown, ArrowLeft, ArrowRight, ArrowUp } from '@fluentui/keyboard-keys';\nimport { useComboboxPositioning } from './useComboboxPositioning';\nimport { useTriggerKeydown } from './useTriggerKeyDown';\nimport { PromptListbox } from '../PromptListbox';\nimport type { EditorInputProps } from '@fluentui-copilot/react-editor-input';\nimport type {\n UsePromptListboxFunctionalityParams,\n UsePromptListboxFunctionality,\n} from './PromptListboxFunctionality.types';\n\nexport function usePromptListboxFunctionality(\n params: UsePromptListboxFunctionalityParams,\n): UsePromptListboxFunctionality {\n const { positioning, onOpenChange, onSelectionModeChange, listboxProps } = params;\n const {\n listboxRef: activeDescendantListboxRef,\n activeParentRef,\n controller: activeDescendantController,\n } = useActiveDescendant<HTMLSpanElement, HTMLDivElement>({\n matchOption: el => el.classList.contains(optionClassNames.root),\n });\n // useMergedRefs to normalize the ref into a React.RefObject type\n const triggerRef = useMergedRefs(activeParentRef);\n const selectionState = useSelection(listboxProps ?? {});\n const { selectOption } = selectionState;\n const optionCollection = useOptionCollection();\n const { getOptionById } = optionCollection;\n const [isInLastPosition, setIsInLastPosition] = React.useState(true);\n const [isInSelectionMode, setIsInSelectionMode] = React.useState(false);\n const [open, setOpen] = useControllableState({\n state: params.open,\n defaultState: params.defaultOpen,\n initialState: false,\n });\n\n const onBlur = (event: React.FocusEvent<HTMLSpanElement>) => {\n setOpen(false);\n onOpenChange?.(event, { event, type: 'focus', open: false });\n };\n\n const onFocus = (event: React.FocusEvent<HTMLSpanElement>) => {\n if (event.target === event.currentTarget) {\n setOpen(true);\n onOpenChange?.(event, { event, type: 'focus', open: true });\n }\n };\n\n const cursorPositionPlugin = <TextCursorPositionPlugin setIsInLastPosition={setIsInLastPosition} />;\n\n const onListboxBlur = React.useCallback(() => {\n setIsInSelectionMode(false);\n onSelectionModeChange?.(false);\n }, [onSelectionModeChange]);\n\n // handle combobox keyboard interaction\n const onKeyDown = useTriggerKeydown({\n ...optionCollection,\n activeDescendantController,\n getOptionById,\n onBlur: onListboxBlur,\n selectOption,\n isInLastPosition,\n open,\n multiselect: false,\n });\n\n // NVDA and JAWS have bugs that suppress reading the input value text when aria-activedescendant is set\n // To prevent this, we clear the HTML attribute (but save the state) when a user presses left/right arrows\n // ref: https://github.com/microsoft/fluentui/issues/26359#issuecomment-1397759888\n const [hideActiveDescendant, setHideActiveDescendant] = React.useState(false);\n\n /**\n * Freeform combobox should not select\n */\n const onInputTriggerKeyDown: EditorInputProps['onKeyDown'] = useEventCallback(event => {\n // update typing state to true if the user is typing\n const action = getDropdownActionFromKey(event, { open, multiselect: false, isInLastPosition });\n if (\n event.key === ArrowLeft ||\n event.key === ArrowRight ||\n (!isInLastPosition && (event.key === ArrowDown || event.key === ArrowUp)) ||\n (action === 'Type' && isInLastPosition) ||\n action === 'Type'\n ) {\n activeDescendantController.blur();\n setHideActiveDescendant(true);\n setIsInSelectionMode(false);\n onSelectionModeChange?.(false);\n } else if (\n action === 'Next' ||\n action === 'Previous' ||\n action === 'First' ||\n action === 'Last' ||\n action === 'PageUp' ||\n action === 'PageDown'\n ) {\n setHideActiveDescendant(false);\n setIsInSelectionMode(true);\n onSelectionModeChange?.(true);\n }\n });\n\n React.useEffect(() => {\n if (hideActiveDescendant) {\n triggerRef.current?.removeAttribute('aria-activedescendant');\n }\n // We only want to run this when the hideActiveDescendant changes, if the triggerRef\n // is undefined, there's no need to remove theAttribute and we shouldn't be adding\n // refs as dependencies since it can blow up the number of runs.\n // eslint-disable-next-line react-compiler/react-compiler\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [hideActiveDescendant]);\n\n const [comboboxPopupRef, comboboxTargetRef] = useComboboxPositioning({ positioning });\n\n const listboxMergedRef = useMergedRefs(comboboxPopupRef, activeDescendantListboxRef, listboxProps?.ref);\n const listbox = React.useMemo(() => {\n return (\n <PromptListbox\n open={open}\n {...listboxProps}\n {...optionCollection}\n {...selectionState}\n ref={listboxMergedRef}\n activeDescendantController={activeDescendantController}\n />\n );\n }, [activeDescendantController, listboxMergedRef, listboxProps, open, optionCollection, selectionState]);\n\n return {\n promptListbox: listbox,\n triggerProps: {\n ref: triggerRef,\n onBlur,\n onFocus,\n onKeyDown: useEventCallback(mergeCallbacks(onKeyDown, onInputTriggerKeyDown)),\n isInSelectionMode,\n },\n targetRef: comboboxTargetRef,\n cursorPositionPlugin,\n };\n}\n"],"names":["React","useActiveDescendant","optionClassNames","mergeCallbacks","useControllableState","useEventCallback","useMergedRefs","getDropdownActionFromKey","TextCursorPositionPlugin","useOptionCollection","useSelection","ArrowDown","ArrowLeft","ArrowRight","ArrowUp","useComboboxPositioning","useTriggerKeydown","PromptListbox","usePromptListboxFunctionality","params","positioning","onOpenChange","onSelectionModeChange","listboxProps","listboxRef","activeDescendantListboxRef","activeParentRef","controller","activeDescendantController","matchOption","el","classList","contains","root","triggerRef","selectionState","selectOption","optionCollection","getOptionById","isInLastPosition","setIsInLastPosition","useState","isInSelectionMode","setIsInSelectionMode","open","setOpen","state","defaultState","defaultOpen","initialState","onBlur","event","type","onFocus","target","currentTarget","cursorPositionPlugin","onListboxBlur","useCallback","onKeyDown","multiselect","hideActiveDescendant","setHideActiveDescendant","onInputTriggerKeyDown","action","key","blur","useEffect","current","removeAttribute","comboboxPopupRef","comboboxTargetRef","listboxMergedRef","ref","listbox","useMemo","promptListbox","triggerProps","targetRef"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"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"}
@@ -0,0 +1,54 @@
1
+ // Brought from Fluent UI
2
+ import { useCallback } from 'react';
3
+ import { useControllableState } from '@fluentui/react-utilities';
4
+ export const useSelection = props => {
5
+ const {
6
+ defaultSelectedOptions,
7
+ multiselect,
8
+ onOptionSelect
9
+ } = props;
10
+ const [selectedOptions, setSelectedOptions] = useControllableState({
11
+ state: props.selectedOptions,
12
+ defaultState: defaultSelectedOptions,
13
+ initialState: []
14
+ });
15
+ const selectOption = useCallback((event, option) => {
16
+ // if the option is disabled, do nothing
17
+ if (option.disabled) {
18
+ return;
19
+ }
20
+ // for single-select, always return the selected option
21
+ let newSelection = [option.value];
22
+ // toggle selected state of the option for multiselect
23
+ if (multiselect) {
24
+ const selectedIndex = selectedOptions.findIndex(o => o === option.value);
25
+ if (selectedIndex > -1) {
26
+ // deselect option
27
+ newSelection = [...selectedOptions.slice(0, selectedIndex), ...selectedOptions.slice(selectedIndex + 1)];
28
+ } else {
29
+ // select option
30
+ newSelection = [...selectedOptions, option.value];
31
+ }
32
+ }
33
+ setSelectedOptions(newSelection);
34
+ onOptionSelect === null || onOptionSelect === void 0 ? void 0 : onOptionSelect(event, {
35
+ optionValue: option.value,
36
+ optionText: option.text,
37
+ selectedOptions: newSelection
38
+ });
39
+ }, [onOptionSelect, multiselect, selectedOptions, setSelectedOptions]);
40
+ const clearSelection = event => {
41
+ setSelectedOptions([]);
42
+ onOptionSelect === null || onOptionSelect === void 0 ? void 0 : onOptionSelect(event, {
43
+ optionValue: undefined,
44
+ optionText: undefined,
45
+ selectedOptions: []
46
+ });
47
+ };
48
+ return {
49
+ clearSelection,
50
+ selectOption,
51
+ selectedOptions
52
+ };
53
+ };
54
+ //# sourceMappingURL=useSelection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["useSelection.ts"],"sourcesContent":["// Brought from Fluent UI\n\nimport { useCallback } from 'react';\nimport { useControllableState } from '@fluentui/react-utilities';\nimport type { OptionValue } from './OptionCollection.types';\nimport type { SelectionEvents, SelectionProps, SelectionState } from './Selection.types';\n\nexport const useSelection = (props: SelectionProps): SelectionState => {\n const { defaultSelectedOptions, multiselect, onOptionSelect } = props;\n\n const [selectedOptions, setSelectedOptions] = useControllableState({\n state: props.selectedOptions,\n defaultState: defaultSelectedOptions,\n initialState: [],\n });\n\n const selectOption = useCallback(\n (event: SelectionEvents, option: OptionValue) => {\n // if the option is disabled, do nothing\n if (option.disabled) {\n return;\n }\n\n // for single-select, always return the selected option\n let newSelection = [option.value];\n\n // toggle selected state of the option for multiselect\n if (multiselect) {\n const selectedIndex = selectedOptions.findIndex(o => o === option.value);\n if (selectedIndex > -1) {\n // deselect option\n newSelection = [...selectedOptions.slice(0, selectedIndex), ...selectedOptions.slice(selectedIndex + 1)];\n } else {\n // select option\n newSelection = [...selectedOptions, option.value];\n }\n }\n\n setSelectedOptions(newSelection);\n onOptionSelect?.(event, { optionValue: option.value, optionText: option.text, selectedOptions: newSelection });\n },\n [onOptionSelect, multiselect, selectedOptions, setSelectedOptions],\n );\n\n const clearSelection = (event: SelectionEvents) => {\n setSelectedOptions([]);\n onOptionSelect?.(event, { optionValue: undefined, optionText: undefined, selectedOptions: [] });\n };\n\n return { clearSelection, selectOption, selectedOptions };\n};\n"],"names":["useCallback","useControllableState","useSelection","props","defaultSelectedOptions","multiselect","onOptionSelect","selectedOptions","setSelectedOptions","state","defaultState","initialState","selectOption","event","option","disabled","newSelection","value","selectedIndex","findIndex","o","slice","optionValue","optionText","text","clearSelection","undefined"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,yBAAyB;AAEzB,SAASA,WAAW,QAAQ,QAAQ;AACpC,SAASC,oBAAoB,QAAQ,4BAA4B;AAIjE,OAAO,MAAMC,eAAe,CAACC;IAC3B,MAAM,EAAEC,sBAAsB,EAAEC,WAAW,EAAEC,cAAc,EAAE,GAAGH;IAEhE,MAAM,CAACI,iBAAiBC,mBAAmB,GAAGP,qBAAqB;QACjEQ,OAAON,MAAMI,eAAe;QAC5BG,cAAcN;QACdO,cAAc,EAAE;IAClB;IAEA,MAAMC,eAAeZ,YACnB,CAACa,OAAwBC;QACvB,wCAAwC;QACxC,IAAIA,OAAOC,QAAQ,EAAE;YACnB;QACF;QAEA,uDAAuD;QACvD,IAAIC,eAAe;YAACF,OAAOG,KAAK;SAAC;QAEjC,sDAAsD;QACtD,IAAIZ,aAAa;YACf,MAAMa,gBAAgBX,gBAAgBY,SAAS,CAACC,CAAAA,IAAKA,MAAMN,OAAOG,KAAK;YACvE,IAAIC,gBAAgB,CAAC,GAAG;gBACtB,kBAAkB;gBAClBF,eAAe;uBAAIT,gBAAgBc,KAAK,CAAC,GAAGH;uBAAmBX,gBAAgBc,KAAK,CAACH,gBAAgB;iBAAG;YAC1G,OAAO;gBACL,gBAAgB;gBAChBF,eAAe;uBAAIT;oBAAiBO,OAAOG,KAAK;iBAAC;YACnD;QACF;QAEAT,mBAAmBQ;QACnBV,2BAAAA,qCAAAA,eAAiBO,OAAO;YAAES,aAAaR,OAAOG,KAAK;YAAEM,YAAYT,OAAOU,IAAI;YAAEjB,iBAAiBS;QAAa;IAC9G,GACA;QAACV;QAAgBD;QAAaE;QAAiBC;KAAmB;IAGpE,MAAMiB,iBAAiB,CAACZ;QACtBL,mBAAmB,EAAE;QACrBF,2BAAAA,qCAAAA,eAAiBO,OAAO;YAAES,aAAaI;YAAWH,YAAYG;YAAWnB,iBAAiB,EAAE;QAAC;IAC/F;IAEA,OAAO;QAAEkB;QAAgBb;QAAcL;IAAgB;AACzD,EAAE"}
@@ -0,0 +1,129 @@
1
+ /**
2
+ * Note, this is mainly brought from Fluent UI, only removed the closing and
3
+ * opening logic since that's not needed for this use case and added the bluring
4
+ * functionality.
5
+ */import * as React from 'react';
6
+ import { useSetKeyboardNavigation } from '@fluentui/react-tabster';
7
+ import { useEventCallback } from '@fluentui/react-utilities';
8
+ import { getDropdownActionFromKey } from './dropdownKeyActions';
9
+ export function useTriggerKeydown(options) {
10
+ const {
11
+ activeDescendantController,
12
+ getOptionById,
13
+ selectOption,
14
+ multiselect,
15
+ open,
16
+ isInLastPosition,
17
+ onBlur
18
+ } = options;
19
+ const getActiveOption = React.useCallback(() => {
20
+ const activeOptionId = activeDescendantController.active();
21
+ return activeOptionId ? getOptionById(activeOptionId) : undefined;
22
+ }, [activeDescendantController, getOptionById]);
23
+ const first = () => {
24
+ activeDescendantController.first();
25
+ };
26
+ const last = () => {
27
+ activeDescendantController.last();
28
+ };
29
+ const blur = () => {
30
+ activeDescendantController.blur();
31
+ onBlur();
32
+ };
33
+ const next = activeOption => {
34
+ if (activeOption) {
35
+ activeDescendantController.next();
36
+ } else {
37
+ activeDescendantController.first();
38
+ }
39
+ };
40
+ const previous = activeOption => {
41
+ if (activeOption) {
42
+ activeDescendantController.prev();
43
+ } else {
44
+ activeDescendantController.first();
45
+ }
46
+ };
47
+ const pageUp = () => {
48
+ for (let i = 0; i < 10; i++) {
49
+ activeDescendantController.prev();
50
+ }
51
+ };
52
+ const pageDown = () => {
53
+ for (let i = 0; i < 10; i++) {
54
+ activeDescendantController.next();
55
+ }
56
+ };
57
+ const setKeyboardNavigation = useSetKeyboardNavigation();
58
+ return useEventCallback(e => {
59
+ const action = getDropdownActionFromKey(e, {
60
+ open,
61
+ multiselect,
62
+ isInLastPosition
63
+ });
64
+ const activeOption = getActiveOption();
65
+ const firstOption = activeDescendantController.first({
66
+ passive: true
67
+ });
68
+ switch (action) {
69
+ case 'Last':
70
+ case 'First':
71
+ case 'PageDown':
72
+ case 'PageUp':
73
+ case 'CloseSelect':
74
+ case 'Select':
75
+ e.preventDefault();
76
+ break;
77
+ case 'Previous':
78
+ // when active option is the first option and the action was "Previous",
79
+ // this means we were in the first option and we are "leaving" the listbox
80
+ if ((activeOption === null || activeOption === void 0 ? void 0 : activeOption.id) === firstOption) {
81
+ blur();
82
+ e.preventDefault();
83
+ } else if (activeOption) {
84
+ e.preventDefault();
85
+ }
86
+ break;
87
+ case 'Next':
88
+ e.preventDefault();
89
+ break;
90
+ }
91
+ setKeyboardNavigation(true);
92
+ switch (action) {
93
+ case 'First':
94
+ first();
95
+ break;
96
+ case 'Last':
97
+ last();
98
+ break;
99
+ case 'Next':
100
+ next(activeOption);
101
+ break;
102
+ case 'Previous':
103
+ if (activeOption && activeOption.id !== firstOption) {
104
+ previous(activeOption);
105
+ } else {
106
+ blur();
107
+ }
108
+ break;
109
+ case 'PageDown':
110
+ pageDown();
111
+ break;
112
+ case 'PageUp':
113
+ pageUp();
114
+ break;
115
+ case 'CloseSelect':
116
+ if (!multiselect && !(activeOption === null || activeOption === void 0 ? void 0 : activeOption.disabled)) {
117
+ blur();
118
+ }
119
+ // fallthrough
120
+ case 'Select':
121
+ activeOption && selectOption(e, activeOption);
122
+ break;
123
+ case 'Tab':
124
+ !multiselect && activeOption && selectOption(e, activeOption);
125
+ break;
126
+ }
127
+ });
128
+ }
129
+ //# sourceMappingURL=useTriggerKeyDown.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["useTriggerKeyDown.ts"],"sourcesContent":["/**\n * Note, this is mainly brought from Fluent UI, only removed the closing and\n * opening logic since that's not needed for this use case and added the bluring\n * functionality.\n */\n\nimport * as React from 'react';\nimport { useSetKeyboardNavigation } from '@fluentui/react-tabster';\nimport { useEventCallback } from '@fluentui/react-utilities';\nimport { getDropdownActionFromKey } from './dropdownKeyActions';\nimport type { ActiveDescendantImperativeRef } from '@fluentui/react-aria';\nimport type { OptionCollectionState, OptionValue } from './OptionCollection.types';\nimport type { SelectionProps, SelectionState } from './Selection.types';\n\nexport function useTriggerKeydown(\n options: {\n activeDescendantController: ActiveDescendantImperativeRef;\n isInLastPosition: boolean;\n open: boolean;\n onBlur: () => void;\n } & OptionCollectionState &\n Pick<SelectionProps, 'multiselect'> &\n Pick<SelectionState, 'selectOption'>,\n) {\n const { activeDescendantController, getOptionById, selectOption, multiselect, open, isInLastPosition, onBlur } =\n options;\n\n const getActiveOption = React.useCallback(() => {\n const activeOptionId = activeDescendantController.active();\n return activeOptionId ? getOptionById(activeOptionId) : undefined;\n }, [activeDescendantController, getOptionById]);\n\n const first = () => {\n activeDescendantController.first();\n };\n\n const last = () => {\n activeDescendantController.last();\n };\n\n const blur = () => {\n activeDescendantController.blur();\n onBlur();\n };\n\n const next = (activeOption: OptionValue | undefined) => {\n if (activeOption) {\n activeDescendantController.next();\n } else {\n activeDescendantController.first();\n }\n };\n\n const previous = (activeOption: OptionValue | undefined) => {\n if (activeOption) {\n activeDescendantController.prev();\n } else {\n activeDescendantController.first();\n }\n };\n\n const pageUp = () => {\n for (let i = 0; i < 10; i++) {\n activeDescendantController.prev();\n }\n };\n\n const pageDown = () => {\n for (let i = 0; i < 10; i++) {\n activeDescendantController.next();\n }\n };\n\n const setKeyboardNavigation = useSetKeyboardNavigation();\n return useEventCallback((e: React.KeyboardEvent<HTMLSpanElement>) => {\n const action = getDropdownActionFromKey(e, { open, multiselect, isInLastPosition });\n const activeOption = getActiveOption();\n const firstOption = activeDescendantController.first({ passive: true });\n\n switch (action) {\n case 'Last':\n case 'First':\n case 'PageDown':\n case 'PageUp':\n case 'CloseSelect':\n case 'Select':\n e.preventDefault();\n break;\n case 'Previous':\n // when active option is the first option and the action was \"Previous\",\n // this means we were in the first option and we are \"leaving\" the listbox\n if (activeOption?.id === firstOption) {\n blur();\n e.preventDefault();\n } else if (activeOption) {\n e.preventDefault();\n }\n break;\n case 'Next':\n e.preventDefault();\n break;\n }\n\n setKeyboardNavigation(true);\n\n switch (action) {\n case 'First':\n first();\n break;\n case 'Last':\n last();\n break;\n case 'Next':\n next(activeOption);\n break;\n case 'Previous':\n if (activeOption && activeOption.id !== firstOption) {\n previous(activeOption);\n } else {\n blur();\n }\n break;\n case 'PageDown':\n pageDown();\n break;\n case 'PageUp':\n pageUp();\n break;\n case 'CloseSelect':\n if (!multiselect && !activeOption?.disabled) {\n blur();\n }\n // fallthrough\n case 'Select':\n activeOption && selectOption(e, activeOption);\n break;\n case 'Tab':\n !multiselect && activeOption && selectOption(e, activeOption);\n break;\n }\n });\n}\n"],"names":["React","useSetKeyboardNavigation","useEventCallback","getDropdownActionFromKey","useTriggerKeydown","options","activeDescendantController","getOptionById","selectOption","multiselect","open","isInLastPosition","onBlur","getActiveOption","useCallback","activeOptionId","active","undefined","first","last","blur","next","activeOption","previous","prev","pageUp","i","pageDown","setKeyboardNavigation","e","action","firstOption","passive","preventDefault","id","disabled"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;;;;CAIC,GAED,YAAYA,WAAW,QAAQ;AAC/B,SAASC,wBAAwB,QAAQ,0BAA0B;AACnE,SAASC,gBAAgB,QAAQ,4BAA4B;AAC7D,SAASC,wBAAwB,QAAQ,uBAAuB;AAKhE,OAAO,SAASC,kBACdC,OAOsC;IAEtC,MAAM,EAAEC,0BAA0B,EAAEC,aAAa,EAAEC,YAAY,EAAEC,WAAW,EAAEC,IAAI,EAAEC,gBAAgB,EAAEC,MAAM,EAAE,GAC5GP;IAEF,MAAMQ,kBAAkBb,MAAMc,WAAW,CAAC;QACxC,MAAMC,iBAAiBT,2BAA2BU,MAAM;QACxD,OAAOD,iBAAiBR,cAAcQ,kBAAkBE;IAC1D,GAAG;QAACX;QAA4BC;KAAc;IAE9C,MAAMW,QAAQ;QACZZ,2BAA2BY,KAAK;IAClC;IAEA,MAAMC,OAAO;QACXb,2BAA2Ba,IAAI;IACjC;IAEA,MAAMC,OAAO;QACXd,2BAA2Bc,IAAI;QAC/BR;IACF;IAEA,MAAMS,OAAO,CAACC;QACZ,IAAIA,cAAc;YAChBhB,2BAA2Be,IAAI;QACjC,OAAO;YACLf,2BAA2BY,KAAK;QAClC;IACF;IAEA,MAAMK,WAAW,CAACD;QAChB,IAAIA,cAAc;YAChBhB,2BAA2BkB,IAAI;QACjC,OAAO;YACLlB,2BAA2BY,KAAK;QAClC;IACF;IAEA,MAAMO,SAAS;QACb,IAAK,IAAIC,IAAI,GAAGA,IAAI,IAAIA,IAAK;YAC3BpB,2BAA2BkB,IAAI;QACjC;IACF;IAEA,MAAMG,WAAW;QACf,IAAK,IAAID,IAAI,GAAGA,IAAI,IAAIA,IAAK;YAC3BpB,2BAA2Be,IAAI;QACjC;IACF;IAEA,MAAMO,wBAAwB3B;IAC9B,OAAOC,iBAAiB,CAAC2B;QACvB,MAAMC,SAAS3B,yBAAyB0B,GAAG;YAAEnB;YAAMD;YAAaE;QAAiB;QACjF,MAAMW,eAAeT;QACrB,MAAMkB,cAAczB,2BAA2BY,KAAK,CAAC;YAAEc,SAAS;QAAK;QAErE,OAAQF;YACN,KAAK;YACL,KAAK;YACL,KAAK;YACL,KAAK;YACL,KAAK;YACL,KAAK;gBACHD,EAAEI,cAAc;gBAChB;YACF,KAAK;gBACH,wEAAwE;gBACxE,0EAA0E;gBAC1E,IAAIX,CAAAA,yBAAAA,mCAAAA,aAAcY,EAAE,MAAKH,aAAa;oBACpCX;oBACAS,EAAEI,cAAc;gBAClB,OAAO,IAAIX,cAAc;oBACvBO,EAAEI,cAAc;gBAClB;gBACA;YACF,KAAK;gBACHJ,EAAEI,cAAc;gBAChB;QACJ;QAEAL,sBAAsB;QAEtB,OAAQE;YACN,KAAK;gBACHZ;gBACA;YACF,KAAK;gBACHC;gBACA;YACF,KAAK;gBACHE,KAAKC;gBACL;YACF,KAAK;gBACH,IAAIA,gBAAgBA,aAAaY,EAAE,KAAKH,aAAa;oBACnDR,SAASD;gBACX,OAAO;oBACLF;gBACF;gBACA;YACF,KAAK;gBACHO;gBACA;YACF,KAAK;gBACHF;gBACA;YACF,KAAK;gBACH,IAAI,CAAChB,eAAe,EAACa,yBAAAA,mCAAAA,aAAca,QAAQ,GAAE;oBAC3Cf;gBACF;YACF,cAAc;YACd,KAAK;gBACHE,gBAAgBd,aAAaqB,GAAGP;gBAChC;YACF,KAAK;gBACH,CAACb,eAAea,gBAAgBd,aAAaqB,GAAGP;gBAChD;QACJ;IACF;AACF"}
package/lib/index.js ADDED
@@ -0,0 +1,4 @@
1
+ export { PromptListbox, promptListboxClassNames, renderPromptListbox_unstable, usePromptListboxStyles_unstable, usePromptListbox_unstable } from './PromptListbox';
2
+ export { usePromptListboxFunctionality } from './components/utils/usePromptListboxFunctionality';
3
+ export { TextCursorPositionPlugin } from './plugins/TextCursorPositionPlugin';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["index.ts"],"sourcesContent":["export type { PromptListboxProps, PromptListboxSlots, PromptListboxState } from './PromptListbox';\nexport {\n PromptListbox,\n promptListboxClassNames,\n renderPromptListbox_unstable,\n usePromptListboxStyles_unstable,\n usePromptListbox_unstable,\n} from './PromptListbox';\n\nexport { usePromptListboxFunctionality } from './components/utils/usePromptListboxFunctionality';\nexport type {\n OnOpenChangeData,\n ProcessedPromptListboxProps,\n UsePromptListboxFunctionality,\n UsePromptListboxFunctionalityParams,\n} from './components/utils/PromptListboxFunctionality.types';\n\nexport type { TextCursorPositionPluginProps } from './plugins/TextCursorPositionPlugin';\nexport { TextCursorPositionPlugin } from './plugins/TextCursorPositionPlugin';\n"],"names":["PromptListbox","promptListboxClassNames","renderPromptListbox_unstable","usePromptListboxStyles_unstable","usePromptListbox_unstable","usePromptListboxFunctionality","TextCursorPositionPlugin"],"rangeMappings":";;","mappings":"AACA,SACEA,aAAa,EACbC,uBAAuB,EACvBC,4BAA4B,EAC5BC,+BAA+B,EAC/BC,yBAAyB,QACpB,kBAAkB;AAEzB,SAASC,6BAA6B,QAAQ,mDAAmD;AASjG,SAASC,wBAAwB,QAAQ,qCAAqC"}
@@ -0,0 +1,44 @@
1
+ import { $isSentinelNode } from '@fluentui-copilot/chat-input-plugins';
2
+ import { COMMAND_PRIORITY_CRITICAL, KEY_ARROW_DOWN_COMMAND, KEY_ARROW_UP_COMMAND, $getSelection, useLexicalComposerContext, $getLeafNodes, $getRoot, $isRangeSelection, mergeRegister } from '@fluentui-copilot/react-text-editor';
3
+ import * as React from 'react';
4
+ export const TextCursorPositionPlugin = ({
5
+ setIsInLastPosition
6
+ }) => {
7
+ const [editor] = useLexicalComposerContext();
8
+ const keypressHandler = _ev => {
9
+ const root = $getRoot();
10
+ const leafNodes = $getLeafNodes(root);
11
+ const lastLeafNode = leafNodes.length === 0 ? undefined : leafNodes[leafNodes.length - 1];
12
+ const selection = $getSelection();
13
+ if (selection === null || !$isRangeSelection(selection) || !selection.isCollapsed()) {
14
+ setIsInLastPosition(false);
15
+ return false;
16
+ }
17
+ const selectionNodes = selection.getNodes();
18
+ // if we don't have a lead node, then we don't have any nodes, so we are in the last position
19
+ if (selectionNodes.length === 0 || !lastLeafNode) {
20
+ setIsInLastPosition(true);
21
+ return false;
22
+ }
23
+ const lastSelectionNode = selectionNodes[selectionNodes.length - 1];
24
+ // if the selection node is a sentinel and it matches the sentinel at the end
25
+ if ($isSentinelNode(lastSelectionNode) && lastSelectionNode.is(lastLeafNode)) {
26
+ setIsInLastPosition(true);
27
+ return false;
28
+ } else if ($isSentinelNode(lastSelectionNode.getNextSibling()) && selection.focus.offset === lastSelectionNode.getTextContentSize()) {
29
+ setIsInLastPosition(true);
30
+ return false;
31
+ }
32
+ setIsInLastPosition(false);
33
+ return false;
34
+ };
35
+ React.useEffect(() => {
36
+ return mergeRegister(editor.registerCommand(KEY_ARROW_DOWN_COMMAND, keypressHandler, COMMAND_PRIORITY_CRITICAL), editor.registerCommand(KEY_ARROW_UP_COMMAND, keypressHandler, COMMAND_PRIORITY_CRITICAL));
37
+ // We are disabling exhaustive-deps because we only want to register the command once on mount and the
38
+ // the teardown function when unmounting
39
+ // eslint-disable-next-line react-compiler/react-compiler
40
+ // eslint-disable-next-line react-hooks/exhaustive-deps
41
+ }, []);
42
+ return null;
43
+ };
44
+ //# sourceMappingURL=TextCursorPositionPlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["TextCursorPositionPlugin.ts"],"sourcesContent":["import { $isSentinelNode } from '@fluentui-copilot/chat-input-plugins';\nimport {\n COMMAND_PRIORITY_CRITICAL,\n KEY_ARROW_DOWN_COMMAND,\n KEY_ARROW_UP_COMMAND,\n $getSelection,\n useLexicalComposerContext,\n $getLeafNodes,\n $getRoot,\n $isRangeSelection,\n mergeRegister,\n} from '@fluentui-copilot/react-text-editor';\nimport * as React from 'react';\n\nexport type TextCursorPositionPluginProps = {\n setIsInLastPosition: (isInLastPosition: boolean) => void;\n};\n\nexport const TextCursorPositionPlugin: React.FunctionComponent<TextCursorPositionPluginProps> = ({\n setIsInLastPosition,\n}) => {\n const [editor] = useLexicalComposerContext();\n\n const keypressHandler = (_ev: KeyboardEvent) => {\n const root = $getRoot();\n const leafNodes = $getLeafNodes(root);\n const lastLeafNode = leafNodes.length === 0 ? undefined : leafNodes[leafNodes.length - 1];\n const selection = $getSelection();\n if (selection === null || !$isRangeSelection(selection) || !selection.isCollapsed()) {\n setIsInLastPosition(false);\n return false;\n }\n\n const selectionNodes = selection.getNodes();\n // if we don't have a lead node, then we don't have any nodes, so we are in the last position\n if (selectionNodes.length === 0 || !lastLeafNode) {\n setIsInLastPosition(true);\n return false;\n }\n const lastSelectionNode = selectionNodes[selectionNodes.length - 1];\n\n // if the selection node is a sentinel and it matches the sentinel at the end\n if ($isSentinelNode(lastSelectionNode) && lastSelectionNode.is(lastLeafNode)) {\n setIsInLastPosition(true);\n return false;\n }\n // else if the selection node is not a sentinel, check that the next sibling node is a sentinel\n // and check if the focus offset is in the last position of the node.\n else if (\n $isSentinelNode(lastSelectionNode.getNextSibling()) &&\n selection.focus.offset === lastSelectionNode.getTextContentSize()\n ) {\n setIsInLastPosition(true);\n return false;\n }\n\n setIsInLastPosition(false);\n return false;\n };\n\n React.useEffect(() => {\n return mergeRegister(\n editor.registerCommand(KEY_ARROW_DOWN_COMMAND, keypressHandler, COMMAND_PRIORITY_CRITICAL),\n editor.registerCommand(KEY_ARROW_UP_COMMAND, keypressHandler, COMMAND_PRIORITY_CRITICAL),\n );\n // We are disabling exhaustive-deps because we only want to register the command once on mount and the\n // the teardown function when unmounting\n // eslint-disable-next-line react-compiler/react-compiler\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n return null;\n};\n"],"names":["$isSentinelNode","COMMAND_PRIORITY_CRITICAL","KEY_ARROW_DOWN_COMMAND","KEY_ARROW_UP_COMMAND","$getSelection","useLexicalComposerContext","$getLeafNodes","$getRoot","$isRangeSelection","mergeRegister","React","TextCursorPositionPlugin","setIsInLastPosition","editor","keypressHandler","_ev","root","leafNodes","lastLeafNode","length","undefined","selection","isCollapsed","selectionNodes","getNodes","lastSelectionNode","is","getNextSibling","focus","offset","getTextContentSize","useEffect","registerCommand"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,eAAe,QAAQ,uCAAuC;AACvE,SACEC,yBAAyB,EACzBC,sBAAsB,EACtBC,oBAAoB,EACpBC,aAAa,EACbC,yBAAyB,EACzBC,aAAa,EACbC,QAAQ,EACRC,iBAAiB,EACjBC,aAAa,QACR,sCAAsC;AAC7C,YAAYC,WAAW,QAAQ;AAM/B,OAAO,MAAMC,2BAAmF,CAAC,EAC/FC,mBAAmB,EACpB;IACC,MAAM,CAACC,OAAO,GAAGR;IAEjB,MAAMS,kBAAkB,CAACC;QACvB,MAAMC,OAAOT;QACb,MAAMU,YAAYX,cAAcU;QAChC,MAAME,eAAeD,UAAUE,MAAM,KAAK,IAAIC,YAAYH,SAAS,CAACA,UAAUE,MAAM,GAAG,EAAE;QACzF,MAAME,YAAYjB;QAClB,IAAIiB,cAAc,QAAQ,CAACb,kBAAkBa,cAAc,CAACA,UAAUC,WAAW,IAAI;YACnFV,oBAAoB;YACpB,OAAO;QACT;QAEA,MAAMW,iBAAiBF,UAAUG,QAAQ;QACzC,6FAA6F;QAC7F,IAAID,eAAeJ,MAAM,KAAK,KAAK,CAACD,cAAc;YAChDN,oBAAoB;YACpB,OAAO;QACT;QACA,MAAMa,oBAAoBF,cAAc,CAACA,eAAeJ,MAAM,GAAG,EAAE;QAEnE,6EAA6E;QAC7E,IAAInB,gBAAgByB,sBAAsBA,kBAAkBC,EAAE,CAACR,eAAe;YAC5EN,oBAAoB;YACpB,OAAO;QACT,OAGK,IACHZ,gBAAgByB,kBAAkBE,cAAc,OAChDN,UAAUO,KAAK,CAACC,MAAM,KAAKJ,kBAAkBK,kBAAkB,IAC/D;YACAlB,oBAAoB;YACpB,OAAO;QACT;QAEAA,oBAAoB;QACpB,OAAO;IACT;IAEAF,MAAMqB,SAAS,CAAC;QACd,OAAOtB,cACLI,OAAOmB,eAAe,CAAC9B,wBAAwBY,iBAAiBb,4BAChEY,OAAOmB,eAAe,CAAC7B,sBAAsBW,iBAAiBb;IAEhE,sGAAsG;IACtG,wCAAwC;IACxC,yDAAyD;IACzD,uDAAuD;IACzD,GAAG,EAAE;IAEL,OAAO;AACT,EAAE"}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ const _export_star = require("@swc/helpers/_/_export_star");
6
+ _export_star._(require("./components/PromptListbox/index"), exports);
7
+ //# sourceMappingURL=PromptListbox.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["PromptListbox.ts"],"sourcesContent":["export * from './components/PromptListbox/index';\n"],"names":[],"rangeMappings":";;;;;","mappings":";;;;;uBAAc"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "PromptListbox", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return PromptListbox;
9
+ }
10
+ });
11
+ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
12
+ const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
13
+ const _usePromptListbox = require("./usePromptListbox");
14
+ const _renderPromptListbox = require("./renderPromptListbox");
15
+ const _usePromptListboxStylesstyles = require("./usePromptListboxStyles.styles");
16
+ const _usePromptListboxContextValues = require("./usePromptListboxContextValues");
17
+ const PromptListbox = /*#__PURE__*/ _react.forwardRef((props, ref)=>{
18
+ const state = (0, _usePromptListbox.usePromptListbox_unstable)(props, ref);
19
+ const contextValues = (0, _usePromptListboxContextValues.usePromptListboxContextValues)(state);
20
+ (0, _usePromptListboxStylesstyles.usePromptListboxStyles_unstable)(state);
21
+ return (0, _renderPromptListbox.renderPromptListbox_unstable)(state, contextValues);
22
+ });
23
+ PromptListbox.displayName = 'PromptListbox'; //# sourceMappingURL=PromptListbox.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["PromptListbox.tsx"],"sourcesContent":["import * as React from 'react';\nimport { usePromptListbox_unstable } from './usePromptListbox';\nimport { renderPromptListbox_unstable } from './renderPromptListbox';\nimport { usePromptListboxStyles_unstable } from './usePromptListboxStyles.styles';\nimport { usePromptListboxContextValues } from './usePromptListboxContextValues';\nimport type { PromptListboxProps } from './PromptListbox.types';\nimport type { ForwardRefComponent } from '@fluentui/react-components';\n\n// PromptListbox component - TODO: add more docs\nexport const PromptListbox: ForwardRefComponent<PromptListboxProps> = React.forwardRef((props, ref) => {\n const state = usePromptListbox_unstable(props, ref);\n const contextValues = usePromptListboxContextValues(state);\n\n usePromptListboxStyles_unstable(state);\n return renderPromptListbox_unstable(state, contextValues);\n});\n\nPromptListbox.displayName = 'PromptListbox';\n"],"names":["PromptListbox","React","forwardRef","props","state","usePromptListbox_unstable","contextValues","usePromptListboxContextValues","usePromptListboxStyles_unstable","renderPromptListbox_unstable","displayName"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BASaA;;;eAAAA;;;;iEATU;kCACmB;qCACG;8CACG;+CACF;AAKvC,MAAMA,gBAAAA,WAAAA,GAAAA,OAAyDC,UAAMC,CAAU,CAACC,OAACA;UACtFC,QAAMA,IAAAA,2CAAQC,EAAAA,OAA0BF;UACxCG,gBAAMA,IAAAA,4DAAgBC,EAAAA;qEAEtBC,EAAAA;WACAC,IAAAA,iDAAOA,EAAAA,OAA6BL;AACtC;AAEAJ,cAAcU,WAAW,GAAG"}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ //# sourceMappingURL=PromptListbox.types.js.map