@fluentui-copilot/react-prompt-listbox 0.9.0 → 0.10.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.json +15 -0
- package/CHANGELOG.md +10 -1
- package/dist/index.d.ts +0 -252
- package/lib/components/utils/useListboxPositioning.js.map +1 -1
- package/lib/index.js +0 -3
- package/lib/index.js.map +1 -1
- package/lib-commonjs/components/utils/useListboxPositioning.js.map +1 -1
- package/lib-commonjs/index.js +0 -36
- package/lib-commonjs/index.js.map +1 -1
- package/package.json +6 -6
- package/lib/PromptListbox.js +0 -2
- package/lib/PromptListbox.js.map +0 -1
- package/lib/PromptOption.js +0 -2
- package/lib/PromptOption.js.map +0 -1
- package/lib/components/PromptListbox/PromptListbox.js +0 -14
- package/lib/components/PromptListbox/PromptListbox.js.map +0 -1
- package/lib/components/PromptListbox/PromptListbox.types.js +0 -2
- package/lib/components/PromptListbox/PromptListbox.types.js.map +0 -1
- package/lib/components/PromptListbox/index.js +0 -5
- package/lib/components/PromptListbox/index.js.map +0 -1
- package/lib/components/PromptListbox/renderPromptListbox.js +0 -26
- package/lib/components/PromptListbox/renderPromptListbox.js.map +0 -1
- package/lib/components/PromptListbox/usePromptListbox.js +0 -82
- package/lib/components/PromptListbox/usePromptListbox.js.map +0 -1
- package/lib/components/PromptListbox/usePromptListboxContextValues.js +0 -33
- package/lib/components/PromptListbox/usePromptListboxContextValues.js.map +0 -1
- package/lib/components/PromptListbox/usePromptListboxStyles.styles.js +0 -41
- package/lib/components/PromptListbox/usePromptListboxStyles.styles.js.map +0 -1
- package/lib/components/PromptOption/PromptOption.js +0 -12
- package/lib/components/PromptOption/PromptOption.js.map +0 -1
- package/lib/components/PromptOption/PromptOption.types.js +0 -4
- package/lib/components/PromptOption/PromptOption.types.js.map +0 -1
- package/lib/components/PromptOption/index.js +0 -5
- package/lib/components/PromptOption/index.js.map +0 -1
- package/lib/components/PromptOption/renderPromptOption.js +0 -10
- package/lib/components/PromptOption/renderPromptOption.js.map +0 -1
- package/lib/components/PromptOption/usePromptOption.js +0 -101
- package/lib/components/PromptOption/usePromptOption.js.map +0 -1
- package/lib/components/PromptOption/usePromptOptionStyles.styles.js +0 -98
- package/lib/components/PromptOption/usePromptOptionStyles.styles.js.map +0 -1
- package/lib/components/utils/OptionCollection.types.js +0 -3
- package/lib/components/utils/OptionCollection.types.js.map +0 -1
- package/lib/components/utils/PromptListboxFunctionality.types.js +0 -2
- package/lib/components/utils/PromptListboxFunctionality.types.js.map +0 -1
- package/lib/components/utils/Selection.types.js +0 -3
- package/lib/components/utils/Selection.types.js.map +0 -1
- package/lib/components/utils/dropdownKeyActions.js +0 -68
- package/lib/components/utils/dropdownKeyActions.js.map +0 -1
- package/lib/components/utils/useOptionCollection.js +0 -39
- package/lib/components/utils/useOptionCollection.js.map +0 -1
- package/lib/components/utils/usePromptListboxFunctionality.js +0 -143
- package/lib/components/utils/usePromptListboxFunctionality.js.map +0 -1
- package/lib/components/utils/useSelection.js +0 -54
- package/lib/components/utils/useSelection.js.map +0 -1
- package/lib/components/utils/useTriggerKeyDown.js +0 -149
- package/lib/components/utils/useTriggerKeyDown.js.map +0 -1
- package/lib-commonjs/PromptListbox.js +0 -29
- package/lib-commonjs/PromptListbox.js.map +0 -1
- package/lib-commonjs/PromptOption.js +0 -29
- package/lib-commonjs/PromptOption.js.map +0 -1
- package/lib-commonjs/components/PromptListbox/PromptListbox.js +0 -23
- package/lib-commonjs/components/PromptListbox/PromptListbox.js.map +0 -1
- package/lib-commonjs/components/PromptListbox/PromptListbox.types.js +0 -5
- package/lib-commonjs/components/PromptListbox/PromptListbox.types.js.map +0 -1
- package/lib-commonjs/components/PromptListbox/index.js +0 -32
- package/lib-commonjs/components/PromptListbox/index.js.map +0 -1
- package/lib-commonjs/components/PromptListbox/renderPromptListbox.js +0 -30
- package/lib-commonjs/components/PromptListbox/renderPromptListbox.js.map +0 -1
- package/lib-commonjs/components/PromptListbox/usePromptListbox.js +0 -69
- package/lib-commonjs/components/PromptListbox/usePromptListbox.js.map +0 -1
- package/lib-commonjs/components/PromptListbox/usePromptListboxContextValues.js +0 -36
- package/lib-commonjs/components/PromptListbox/usePromptListboxContextValues.js.map +0 -1
- package/lib-commonjs/components/PromptListbox/usePromptListboxStyles.styles.js +0 -62
- package/lib-commonjs/components/PromptListbox/usePromptListboxStyles.styles.js.map +0 -1
- package/lib-commonjs/components/PromptOption/PromptOption.js +0 -21
- package/lib-commonjs/components/PromptOption/PromptOption.js.map +0 -1
- package/lib-commonjs/components/PromptOption/PromptOption.types.js +0 -7
- package/lib-commonjs/components/PromptOption/PromptOption.types.js.map +0 -1
- package/lib-commonjs/components/PromptOption/index.js +0 -32
- package/lib-commonjs/components/PromptOption/index.js.map +0 -1
- package/lib-commonjs/components/PromptOption/renderPromptOption.js +0 -16
- package/lib-commonjs/components/PromptOption/renderPromptOption.js.map +0 -1
- package/lib-commonjs/components/PromptOption/usePromptOption.js +0 -103
- package/lib-commonjs/components/PromptOption/usePromptOption.js.map +0 -1
- package/lib-commonjs/components/PromptOption/usePromptOptionStyles.styles.js +0 -188
- package/lib-commonjs/components/PromptOption/usePromptOptionStyles.styles.js.map +0 -1
- package/lib-commonjs/components/utils/OptionCollection.types.js +0 -6
- package/lib-commonjs/components/utils/OptionCollection.types.js.map +0 -1
- package/lib-commonjs/components/utils/PromptListboxFunctionality.types.js +0 -5
- package/lib-commonjs/components/utils/PromptListboxFunctionality.types.js.map +0 -1
- package/lib-commonjs/components/utils/Selection.types.js +0 -6
- package/lib-commonjs/components/utils/Selection.types.js.map +0 -1
- package/lib-commonjs/components/utils/dropdownKeyActions.js +0 -66
- package/lib-commonjs/components/utils/dropdownKeyActions.js.map +0 -1
- package/lib-commonjs/components/utils/useOptionCollection.js +0 -46
- package/lib-commonjs/components/utils/useOptionCollection.js.map +0 -1
- package/lib-commonjs/components/utils/usePromptListboxFunctionality.js +0 -150
- package/lib-commonjs/components/utils/usePromptListboxFunctionality.js.map +0 -1
- package/lib-commonjs/components/utils/useSelection.js +0 -72
- package/lib-commonjs/components/utils/useSelection.js.map +0 -1
- package/lib-commonjs/components/utils/useTriggerKeyDown.js +0 -151
- package/lib-commonjs/components/utils/useTriggerKeyDown.js.map +0 -1
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { Listbox, slot, useMergedRefs } from '@fluentui/react-components';
|
|
2
|
-
import { mergeCallbacks, useEventCallback, useId } from '@fluentui/react-utilities';
|
|
3
|
-
// If you add JSX to this file, be sure to change the file type to .tsx
|
|
4
|
-
/**
|
|
5
|
-
* Create the state required to render PromptListbox.
|
|
6
|
-
*
|
|
7
|
-
* The returned state can be modified with hooks such as usePromptListboxStyles_unstable,
|
|
8
|
-
* before being passed to renderPromptListbox_unstable.
|
|
9
|
-
*
|
|
10
|
-
* @param props - props from this instance of PromptListbox
|
|
11
|
-
* @param ref - reference to root HTMLElement of PromptListbox
|
|
12
|
-
*/
|
|
13
|
-
export const usePromptListbox_unstable = (props, ref) => {
|
|
14
|
-
const {
|
|
15
|
-
id,
|
|
16
|
-
onActiveOptionChange,
|
|
17
|
-
inlinePopup = false,
|
|
18
|
-
mountNode = undefined,
|
|
19
|
-
open = true,
|
|
20
|
-
activeDescendantController,
|
|
21
|
-
getOptionById,
|
|
22
|
-
getOptionsMatchingValue,
|
|
23
|
-
selectedOptions,
|
|
24
|
-
selectOption,
|
|
25
|
-
registerOption
|
|
26
|
-
} = props;
|
|
27
|
-
const listboxId = useId('prompt-listbox', id);
|
|
28
|
-
const onActiveDescendantChange = useEventCallback(event => {
|
|
29
|
-
const previousOption = event.detail.previousId ? getOptionById(event.detail.previousId) : null;
|
|
30
|
-
const nextOption = getOptionById(event.detail.id);
|
|
31
|
-
onActiveOptionChange === null || onActiveOptionChange === void 0 ? void 0 : onActiveOptionChange(event, {
|
|
32
|
-
event,
|
|
33
|
-
type: 'change',
|
|
34
|
-
previousOption,
|
|
35
|
-
nextOption
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
const state = {
|
|
39
|
-
...deprecatedPropsDefaults,
|
|
40
|
-
open,
|
|
41
|
-
getOptionById,
|
|
42
|
-
getOptionsMatchingValue,
|
|
43
|
-
selectedOptions,
|
|
44
|
-
selectOption,
|
|
45
|
-
registerOption,
|
|
46
|
-
onActiveDescendantChange,
|
|
47
|
-
activeDescendantController,
|
|
48
|
-
inlinePopup,
|
|
49
|
-
mountNode,
|
|
50
|
-
components: {
|
|
51
|
-
root: Listbox
|
|
52
|
-
},
|
|
53
|
-
root: slot.always({
|
|
54
|
-
...props,
|
|
55
|
-
selectedOptions
|
|
56
|
-
}, {
|
|
57
|
-
defaultProps: {
|
|
58
|
-
disableAutoFocus: true,
|
|
59
|
-
id: listboxId,
|
|
60
|
-
tabIndex: undefined,
|
|
61
|
-
role: 'listbox'
|
|
62
|
-
},
|
|
63
|
-
elementType: Listbox
|
|
64
|
-
})
|
|
65
|
-
};
|
|
66
|
-
state.root.ref = useMergedRefs(ref, state.root.ref);
|
|
67
|
-
state.root.onMouseDown = useEventCallback(mergeCallbacks(event => {
|
|
68
|
-
event.preventDefault();
|
|
69
|
-
}, state.root.onMouseDown));
|
|
70
|
-
state.root.onClick = useEventCallback(mergeCallbacks(event => {
|
|
71
|
-
event.preventDefault();
|
|
72
|
-
}, state.root.onClick));
|
|
73
|
-
return state;
|
|
74
|
-
};
|
|
75
|
-
const noop = () => null;
|
|
76
|
-
const deprecatedPropsDefaults = {
|
|
77
|
-
activeOption: undefined,
|
|
78
|
-
focusVisible: false,
|
|
79
|
-
setActiveOption: noop,
|
|
80
|
-
onOptionClick: noop
|
|
81
|
-
};
|
|
82
|
-
//# sourceMappingURL=usePromptListbox.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["usePromptListbox.ts"],"sourcesContent":["import type * as React from 'react';\nimport { Listbox, slot, useMergedRefs } from '@fluentui/react-components';\nimport { mergeCallbacks, useEventCallback, useId } from '@fluentui/react-utilities';\nimport type { PromptListboxProps, PromptListboxState } from './PromptListbox.types';\nimport type { PromptListboxContextState } from './usePromptListboxContextValues';\nimport type { ActiveDescendantChangeEvent } from '@fluentui/react-aria';\n\n// If you add JSX to this file, be sure to change the file type to .tsx\n\n/**\n * Create the state required to render PromptListbox.\n *\n * The returned state can be modified with hooks such as usePromptListboxStyles_unstable,\n * before being passed to renderPromptListbox_unstable.\n *\n * @param props - props from this instance of PromptListbox\n * @param ref - reference to root HTMLElement of PromptListbox\n */\nexport const usePromptListbox_unstable = (\n props: PromptListboxProps,\n ref: React.Ref<HTMLDivElement>,\n): PromptListboxState => {\n const {\n id,\n onActiveOptionChange,\n inlinePopup = false,\n mountNode = undefined,\n open = true,\n activeDescendantController,\n getOptionById,\n getOptionsMatchingValue,\n selectedOptions,\n selectOption,\n registerOption,\n } = props;\n const listboxId = useId('prompt-listbox', id);\n\n const onActiveDescendantChange = useEventCallback((event: ActiveDescendantChangeEvent) => {\n const previousOption = event.detail.previousId ? getOptionById(event.detail.previousId) : null;\n const nextOption = getOptionById(event.detail.id);\n onActiveOptionChange?.(event, { event, type: 'change', previousOption, nextOption });\n });\n\n const state: PromptListboxState = {\n ...deprecatedPropsDefaults,\n open,\n getOptionById,\n getOptionsMatchingValue,\n selectedOptions,\n selectOption,\n registerOption,\n onActiveDescendantChange,\n activeDescendantController,\n inlinePopup,\n mountNode,\n\n components: {\n root: Listbox,\n },\n\n root: slot.always(\n { ...props, selectedOptions },\n {\n defaultProps: {\n disableAutoFocus: true,\n id: listboxId,\n tabIndex: undefined,\n role: 'listbox',\n },\n elementType: Listbox,\n },\n ),\n };\n\n state.root.ref = useMergedRefs(ref, state.root.ref);\n state.root.onMouseDown = useEventCallback(\n mergeCallbacks((event: React.MouseEvent<HTMLDivElement>) => {\n event.preventDefault();\n }, state.root.onMouseDown),\n );\n\n state.root.onClick = useEventCallback(\n mergeCallbacks((event: React.MouseEvent<HTMLDivElement>) => {\n event.preventDefault();\n }, state.root.onClick),\n );\n\n return state;\n};\n\nconst noop = () => null;\n\nconst deprecatedPropsDefaults: Pick<\n PromptListboxContextState,\n 'activeOption' | 'focusVisible' | 'setActiveOption' | 'onOptionClick'\n> = {\n activeOption: undefined,\n focusVisible: false,\n setActiveOption: noop,\n onOptionClick: noop,\n};\n"],"names":["Listbox","slot","useMergedRefs","mergeCallbacks","useEventCallback","useId","usePromptListbox_unstable","props","ref","id","onActiveOptionChange","inlinePopup","mountNode","undefined","open","activeDescendantController","getOptionById","getOptionsMatchingValue","selectedOptions","selectOption","registerOption","listboxId","onActiveDescendantChange","event","previousOption","detail","previousId","nextOption","type","state","deprecatedPropsDefaults","components","root","always","defaultProps","disableAutoFocus","tabIndex","role","elementType","onMouseDown","preventDefault","onClick","noop","activeOption","focusVisible","setActiveOption","onOptionClick"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AACA,SAASA,OAAO,EAAEC,IAAI,EAAEC,aAAa,QAAQ,6BAA6B;AAC1E,SAASC,cAAc,EAAEC,gBAAgB,EAAEC,KAAK,QAAQ,4BAA4B;AAKpF,uEAAuE;AAEvE;;;;;;;;CAQC,GACD,OAAO,MAAMC,4BAA4B,CACvCC,OACAC;IAEA,MAAM,EACJC,EAAE,EACFC,oBAAoB,EACpBC,cAAc,KAAK,EACnBC,YAAYC,SAAS,EACrBC,OAAO,IAAI,EACXC,0BAA0B,EAC1BC,aAAa,EACbC,uBAAuB,EACvBC,eAAe,EACfC,YAAY,EACZC,cAAc,EACf,GAAGb;IACJ,MAAMc,YAAYhB,MAAM,kBAAkBI;IAE1C,MAAMa,2BAA2BlB,iBAAiB,CAACmB;QACjD,MAAMC,iBAAiBD,MAAME,MAAM,CAACC,UAAU,GAAGV,cAAcO,MAAME,MAAM,CAACC,UAAU,IAAI;QAC1F,MAAMC,aAAaX,cAAcO,MAAME,MAAM,CAAChB,EAAE;QAChDC,iCAAAA,2CAAAA,qBAAuBa,OAAO;YAAEA;YAAOK,MAAM;YAAUJ;YAAgBG;QAAW;IACpF;IAEA,MAAME,QAA4B;QAChC,GAAGC,uBAAuB;QAC1BhB;QACAE;QACAC;QACAC;QACAC;QACAC;QACAE;QACAP;QACAJ;QACAC;QAEAmB,YAAY;YACVC,MAAMhC;QACR;QAEAgC,MAAM/B,KAAKgC,MAAM,CACf;YAAE,GAAG1B,KAAK;YAAEW;QAAgB,GAC5B;YACEgB,cAAc;gBACZC,kBAAkB;gBAClB1B,IAAIY;gBACJe,UAAUvB;gBACVwB,MAAM;YACR;YACAC,aAAatC;QACf;IAEJ;IAEA6B,MAAMG,IAAI,CAACxB,GAAG,GAAGN,cAAcM,KAAKqB,MAAMG,IAAI,CAACxB,GAAG;IAClDqB,MAAMG,IAAI,CAACO,WAAW,GAAGnC,iBACvBD,eAAe,CAACoB;QACdA,MAAMiB,cAAc;IACtB,GAAGX,MAAMG,IAAI,CAACO,WAAW;IAG3BV,MAAMG,IAAI,CAACS,OAAO,GAAGrC,iBACnBD,eAAe,CAACoB;QACdA,MAAMiB,cAAc;IACtB,GAAGX,MAAMG,IAAI,CAACS,OAAO;IAGvB,OAAOZ;AACT,EAAE;AAEF,MAAMa,OAAO,IAAM;AAEnB,MAAMZ,0BAGF;IACFa,cAAc9B;IACd+B,cAAc;IACdC,iBAAiBH;IACjBI,eAAeJ;AACjB"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
export function usePromptListboxContextValues(state) {
|
|
3
|
-
const {
|
|
4
|
-
getOptionById,
|
|
5
|
-
getOptionsMatchingValue,
|
|
6
|
-
registerOption,
|
|
7
|
-
selectedOptions,
|
|
8
|
-
selectOption,
|
|
9
|
-
activeDescendantController,
|
|
10
|
-
onOptionClick,
|
|
11
|
-
onActiveDescendantChange
|
|
12
|
-
} = state;
|
|
13
|
-
const activeDescendant = React.useMemo(() => ({
|
|
14
|
-
controller: activeDescendantController
|
|
15
|
-
}), [activeDescendantController]);
|
|
16
|
-
const listbox = {
|
|
17
|
-
activeOption: undefined,
|
|
18
|
-
focusVisible: false,
|
|
19
|
-
getOptionById,
|
|
20
|
-
getOptionsMatchingValue,
|
|
21
|
-
registerOption,
|
|
22
|
-
selectedOptions,
|
|
23
|
-
selectOption,
|
|
24
|
-
setActiveOption: () => null,
|
|
25
|
-
onOptionClick,
|
|
26
|
-
onActiveDescendantChange
|
|
27
|
-
};
|
|
28
|
-
return {
|
|
29
|
-
activeDescendant,
|
|
30
|
-
listbox
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
//# sourceMappingURL=usePromptListboxContextValues.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["usePromptListboxContextValues.ts"],"sourcesContent":["import * as React from 'react';\nimport type { ComboboxBaseState, ComboboxState, ListboxContextValue } from '@fluentui/react-combobox';\nimport type { PromptListboxContextValues } from './PromptListbox.types';\n\nexport type PromptListboxContextState = Pick<ComboboxBaseState, keyof ListboxContextValue> &\n Pick<ComboboxState, 'activeDescendantController'>;\n\nexport function usePromptListboxContextValues(state: PromptListboxContextState): PromptListboxContextValues {\n const {\n getOptionById,\n getOptionsMatchingValue,\n registerOption,\n selectedOptions,\n selectOption,\n activeDescendantController,\n onOptionClick,\n onActiveDescendantChange,\n } = state;\n\n const activeDescendant = React.useMemo(\n () => ({\n controller: activeDescendantController,\n }),\n [activeDescendantController],\n );\n\n const listbox = {\n activeOption: undefined,\n focusVisible: false,\n getOptionById,\n getOptionsMatchingValue,\n registerOption,\n selectedOptions,\n selectOption,\n setActiveOption: () => null,\n onOptionClick,\n onActiveDescendantChange,\n };\n\n return {\n activeDescendant,\n listbox,\n };\n}\n"],"names":["React","usePromptListboxContextValues","state","getOptionById","getOptionsMatchingValue","registerOption","selectedOptions","selectOption","activeDescendantController","onOptionClick","onActiveDescendantChange","activeDescendant","useMemo","controller","listbox","activeOption","undefined","focusVisible","setActiveOption"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,YAAYA,WAAW,QAAQ;AAO/B,OAAO,SAASC,8BAA8BC,KAAgC;IAC5E,MAAM,EACJC,aAAa,EACbC,uBAAuB,EACvBC,cAAc,EACdC,eAAe,EACfC,YAAY,EACZC,0BAA0B,EAC1BC,aAAa,EACbC,wBAAwB,EACzB,GAAGR;IAEJ,MAAMS,mBAAmBX,MAAMY,OAAO,CACpC,IAAO,CAAA;YACLC,YAAYL;QACd,CAAA,GACA;QAACA;KAA2B;IAG9B,MAAMM,UAAU;QACdC,cAAcC;QACdC,cAAc;QACdd;QACAC;QACAC;QACAC;QACAC;QACAW,iBAAiB,IAAM;QACvBT;QACAC;IACF;IAEA,OAAO;QACLC;QACAG;IACF;AACF"}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { __styles, mergeClasses } from '@fluentui/react-components';
|
|
2
|
-
import { tokens } from '@fluentui-copilot/tokens';
|
|
3
|
-
export const promptListboxClassNames = {
|
|
4
|
-
root: 'fai-PromptListbox'
|
|
5
|
-
};
|
|
6
|
-
/**
|
|
7
|
-
* Styles for the root slot
|
|
8
|
-
*/
|
|
9
|
-
const useStyles = __styles({
|
|
10
|
-
listbox: {
|
|
11
|
-
E5pizo: "f1hg901r",
|
|
12
|
-
Beyfa6y: 0,
|
|
13
|
-
Bbmb7ep: 0,
|
|
14
|
-
Btl43ni: 0,
|
|
15
|
-
B7oj6ja: 0,
|
|
16
|
-
Dimara: "ft85np5",
|
|
17
|
-
Bxyxcbc: "fmmk62d",
|
|
18
|
-
B7ck84d: "f1ewtqcl"
|
|
19
|
-
},
|
|
20
|
-
listboxCollapsed: {
|
|
21
|
-
mc9l5x: "fjseox"
|
|
22
|
-
},
|
|
23
|
-
inlineListbox: {
|
|
24
|
-
Bj3rh1h: "f19g0ac"
|
|
25
|
-
}
|
|
26
|
-
}, {
|
|
27
|
-
d: [".f1hg901r{box-shadow:var(--shadow16);}", [".ft85np5{border-radius:var(--borderRadiusMedium);}", {
|
|
28
|
-
p: -1
|
|
29
|
-
}], ".fmmk62d{max-height:80vh;}", ".f1ewtqcl{box-sizing:border-box;}", ".fjseox{display:none;}", ".f19g0ac{z-index:1;}"]
|
|
30
|
-
});
|
|
31
|
-
/**
|
|
32
|
-
* Apply styling to the PromptListbox slots based on the state
|
|
33
|
-
*/
|
|
34
|
-
export const usePromptListboxStyles_unstable = state => {
|
|
35
|
-
'use no memo';
|
|
36
|
-
|
|
37
|
-
const styles = useStyles();
|
|
38
|
-
state.root.className = mergeClasses(promptListboxClassNames.root, styles.listbox, state.inlinePopup && styles.inlineListbox, !state.open && styles.listboxCollapsed, state.root.className);
|
|
39
|
-
return state;
|
|
40
|
-
};
|
|
41
|
-
//# sourceMappingURL=usePromptListboxStyles.styles.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["usePromptListboxStyles.styles.ts"],"sourcesContent":["import { makeStyles, mergeClasses } from '@fluentui/react-components';\nimport { tokens } from '@fluentui-copilot/tokens';\nimport type { PromptListboxSlots, PromptListboxState } from './PromptListbox.types';\nimport type { SlotClassNames } from '@fluentui/react-components';\n\nexport const promptListboxClassNames: SlotClassNames<PromptListboxSlots> = {\n root: 'fai-PromptListbox',\n};\n\n/**\n * Styles for the root slot\n */\nconst useStyles = makeStyles({\n listbox: {\n boxShadow: tokens.shadow16,\n borderRadius: tokens.borderRadiusMedium,\n maxHeight: '80vh',\n boxSizing: 'border-box',\n },\n\n listboxCollapsed: {\n display: 'none',\n },\n\n // When rendering inline, the popupSurface will be rendered under relatively positioned elements such as Input.\n // This is due to the surface being positioned as absolute, therefore zIndex: 1 ensures that won't happen.\n inlineListbox: {\n zIndex: 1,\n },\n});\n\n/**\n * Apply styling to the PromptListbox slots based on the state\n */\nexport const usePromptListboxStyles_unstable = (state: PromptListboxState): PromptListboxState => {\n 'use no memo';\n\n const styles = useStyles();\n state.root.className = mergeClasses(\n promptListboxClassNames.root,\n styles.listbox,\n state.inlinePopup && styles.inlineListbox,\n !state.open && styles.listboxCollapsed,\n state.root.className,\n );\n\n return state;\n};\n"],"names":["makeStyles","mergeClasses","tokens","promptListboxClassNames","root","useStyles","listbox","boxShadow","shadow16","borderRadius","borderRadiusMedium","maxHeight","boxSizing","listboxCollapsed","display","inlineListbox","zIndex","usePromptListboxStyles_unstable","state","styles","className","inlinePopup","open"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,UAAU,EAAEC,YAAY,QAAQ,6BAA6B;AACtE,SAASC,MAAM,QAAQ,2BAA2B;AAIlD,OAAO,MAAMC,0BAA8D;IACzEC,MAAM;AACR,EAAE;AAEF;;CAEC,GACD,MAAMC,YAAYL,WAAW;IAC3BM,SAAS;QACPC,WAAWL,OAAOM,QAAQ;QAC1BC,cAAcP,OAAOQ,kBAAkB;QACvCC,WAAW;QACXC,WAAW;IACb;IAEAC,kBAAkB;QAChBC,SAAS;IACX;IAEA,+GAA+G;IAC/G,0GAA0G;IAC1GC,eAAe;QACbC,QAAQ;IACV;AACF;AAEA;;CAEC,GACD,OAAO,MAAMC,kCAAkC,CAACC;IAC9C;IAEA,MAAMC,SAASd;IACfa,MAAMd,IAAI,CAACgB,SAAS,GAAGnB,aACrBE,wBAAwBC,IAAI,EAC5Be,OAAOb,OAAO,EACdY,MAAMG,WAAW,IAAIF,OAAOJ,aAAa,EACzC,CAACG,MAAMI,IAAI,IAAIH,OAAON,gBAAgB,EACtCK,MAAMd,IAAI,CAACgB,SAAS;IAGtB,OAAOF;AACT,EAAE"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { usePromptOption_unstable } from './usePromptOption';
|
|
3
|
-
import { renderPromptOption_unstable } from './renderPromptOption';
|
|
4
|
-
import { usePromptOptionStyles_unstable } from './usePromptOptionStyles.styles';
|
|
5
|
-
/**@deprecated - use Option instead */
|
|
6
|
-
export const PromptOption = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
7
|
-
const state = usePromptOption_unstable(props, ref);
|
|
8
|
-
usePromptOptionStyles_unstable(state);
|
|
9
|
-
return renderPromptOption_unstable(state);
|
|
10
|
-
});
|
|
11
|
-
PromptOption.displayName = 'PromptOption';
|
|
12
|
-
//# sourceMappingURL=PromptOption.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["PromptOption.tsx"],"sourcesContent":["import * as React from 'react';\nimport { usePromptOption_unstable } from './usePromptOption';\nimport { renderPromptOption_unstable } from './renderPromptOption';\nimport { usePromptOptionStyles_unstable } from './usePromptOptionStyles.styles';\nimport type { PromptOptionProps } from './PromptOption.types';\nimport type { ForwardRefComponent } from '@fluentui/react-components';\n\n/**@deprecated - use Option instead */\nexport const PromptOption: ForwardRefComponent<PromptOptionProps> = React.forwardRef((props, ref) => {\n const state = usePromptOption_unstable(props, ref);\n\n usePromptOptionStyles_unstable(state);\n return renderPromptOption_unstable(state);\n});\n\nPromptOption.displayName = 'PromptOption';\n"],"names":["React","usePromptOption_unstable","renderPromptOption_unstable","usePromptOptionStyles_unstable","PromptOption","forwardRef","props","ref","state","displayName"],"rangeMappings":";;;;;;;;;","mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,wBAAwB,QAAQ,oBAAoB;AAC7D,SAASC,2BAA2B,QAAQ,uBAAuB;AACnE,SAASC,8BAA8B,QAAQ,iCAAiC;AAIhF,oCAAoC,GACpC,OAAO,MAAMC,6BAAuDJ,MAAMK,UAAU,CAAC,CAACC,OAAOC;IAC3F,MAAMC,QAAQP,yBAAyBK,OAAOC;IAE9CJ,+BAA+BK;IAC/B,OAAON,4BAA4BM;AACrC,GAAG;AAEHJ,aAAaK,WAAW,GAAG"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["PromptOption.types.ts"],"sourcesContent":["import type { ComponentProps, ComponentState, OptionProps, OptionState, Slot } from '@fluentui/react-components';\n\nexport type PromptOptionSlots = {\n root: NonNullable<Slot<'div'>>;\n};\n\n/**\n * PromptOption Props\n */\nexport type PromptOptionProps = ComponentProps<PromptOptionSlots> &\n Pick<OptionProps, 'disabled' | 'value'> &\n (\n | {\n /**\n * An optional override the string value of the PromptOption's display text,\n * defaulting to the PromptOption's child content.\n * This is used as the PromptInput button's or PromptInput input's value when the option is selected,\n * and as the comparison for type-to-find keyboard functionality.\n */\n text?: string;\n children: string;\n }\n | {\n /**\n * The string value of the PromptOption's display text when the PromptOption's children are not a string.\n * This is used as the PromptInput button's or PromptInput input's value when the option is selected,\n * and as the comparison for type-to-find keyboard functionality.\n */\n text: string;\n children?: React.ReactNode;\n }\n );\n\n/**\n * State used in rendering PromptOption\n */\nexport type PromptOptionState = ComponentState<PromptOptionSlots> & Pick<OptionState, 'disabled' | 'selected'>;\n"],"names":[],"rangeMappings":";;","mappings":"AAiCA;;CAEC,GACD,WAA+G"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export { PromptOption } from './PromptOption';
|
|
2
|
-
export { renderPromptOption_unstable } from './renderPromptOption';
|
|
3
|
-
export { usePromptOption_unstable } from './usePromptOption';
|
|
4
|
-
export { promptOptionClassNames, usePromptOptionStyles_unstable } from './usePromptOptionStyles.styles';
|
|
5
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["index.ts"],"sourcesContent":["export { PromptOption } from './PromptOption';\nexport type { PromptOptionProps, PromptOptionSlots, PromptOptionState } from './PromptOption.types';\nexport { renderPromptOption_unstable } from './renderPromptOption';\nexport { usePromptOption_unstable } from './usePromptOption';\nexport { promptOptionClassNames, usePromptOptionStyles_unstable } from './usePromptOptionStyles.styles';\n"],"names":["PromptOption","renderPromptOption_unstable","usePromptOption_unstable","promptOptionClassNames","usePromptOptionStyles_unstable"],"rangeMappings":";;;","mappings":"AAAA,SAASA,YAAY,QAAQ,iBAAiB;AAE9C,SAASC,2BAA2B,QAAQ,uBAAuB;AACnE,SAASC,wBAAwB,QAAQ,oBAAoB;AAC7D,SAASC,sBAAsB,EAAEC,8BAA8B,QAAQ,iCAAiC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "@fluentui/react-jsx-runtime/jsx-runtime";
|
|
2
|
-
import { assertSlots } from '@fluentui/react-components';
|
|
3
|
-
/**
|
|
4
|
-
* Render the final JSX of PromptOption
|
|
5
|
-
*/
|
|
6
|
-
export const renderPromptOption_unstable = state => {
|
|
7
|
-
assertSlots(state);
|
|
8
|
-
return /*#__PURE__*/_jsx(state.root, {});
|
|
9
|
-
};
|
|
10
|
-
//# sourceMappingURL=renderPromptOption.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["renderPromptOption.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\n\nimport { assertSlots } from '@fluentui/react-components';\nimport type { PromptOptionSlots, PromptOptionState } from './PromptOption.types';\n\n/**\n * Render the final JSX of PromptOption\n */\nexport const renderPromptOption_unstable = (state: PromptOptionState) => {\n assertSlots<PromptOptionSlots>(state);\n\n return <state.root />;\n};\n"],"names":["assertSlots","renderPromptOption_unstable","state","root"],"rangeMappings":";;;;;;;","mappings":"AAAA,0BAA0B,GAC1B,iDAAiD;AAEjD,SAASA,WAAW,QAAQ,6BAA6B;AAGzD;;CAEC,GACD,OAAO,MAAMC,8BAA8B,CAACC;IAC1CF,YAA+BE;IAE/B,qBAAO,KAACA,MAAMC,IAAI;AACpB,EAAE"}
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { getIntrinsicElementProps, slot, useId, useMergedRefs } from '@fluentui/react-components';
|
|
3
|
-
import { useActiveDescendantContext } from '@fluentui/react-aria';
|
|
4
|
-
import { useListboxContext_unstable } from '@fluentui/react-combobox';
|
|
5
|
-
// If you add JSX to this file, be sure to change the file type to .tsx
|
|
6
|
-
/**
|
|
7
|
-
* Create the state required to render PromptOption.
|
|
8
|
-
*
|
|
9
|
-
* The returned state can be modified with hooks such as usePromptOptionStyles_unstable,
|
|
10
|
-
* before being passed to renderPromptOption_unstable.
|
|
11
|
-
*
|
|
12
|
-
* @param props - props from this instance of PromptOption
|
|
13
|
-
* @param ref - reference to root HTMLElement of PromptOption
|
|
14
|
-
*/
|
|
15
|
-
export const usePromptOption_unstable = (props, ref) => {
|
|
16
|
-
const {
|
|
17
|
-
controller: activeDescendantController
|
|
18
|
-
} = useActiveDescendantContext();
|
|
19
|
-
const {
|
|
20
|
-
children,
|
|
21
|
-
disabled,
|
|
22
|
-
text,
|
|
23
|
-
value
|
|
24
|
-
} = props;
|
|
25
|
-
const optionRef = React.useRef(null);
|
|
26
|
-
const optionText = getTextString(text, children);
|
|
27
|
-
const optionValue = value !== null && value !== void 0 ? value : optionText;
|
|
28
|
-
// use the id if provided, otherwise use a generated id
|
|
29
|
-
const id = useId('fluent-option', props.id);
|
|
30
|
-
// data used for context registration & events
|
|
31
|
-
const optionData = React.useMemo(() => ({
|
|
32
|
-
id,
|
|
33
|
-
disabled,
|
|
34
|
-
text: optionText,
|
|
35
|
-
value: optionValue
|
|
36
|
-
}), [id, disabled, optionText, optionValue]);
|
|
37
|
-
// context values
|
|
38
|
-
const registerOption = useListboxContext_unstable(ctx => ctx.registerOption);
|
|
39
|
-
const selected = useListboxContext_unstable(ctx => {
|
|
40
|
-
const selectedOptions = ctx.selectedOptions;
|
|
41
|
-
return optionValue !== undefined && selectedOptions.find(o => o === optionValue) !== undefined;
|
|
42
|
-
});
|
|
43
|
-
const selectOption = useListboxContext_unstable(ctx => ctx.selectOption);
|
|
44
|
-
const onOptionClick = useListboxContext_unstable(ctx => ctx.onOptionClick);
|
|
45
|
-
const onClick = event => {
|
|
46
|
-
var _props_onClick;
|
|
47
|
-
if (disabled) {
|
|
48
|
-
event.preventDefault();
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
activeDescendantController.focus(id);
|
|
52
|
-
// handle selection change
|
|
53
|
-
selectOption(event, optionData);
|
|
54
|
-
onOptionClick(event);
|
|
55
|
-
(_props_onClick = props.onClick) === null || _props_onClick === void 0 ? void 0 : _props_onClick.call(props, event);
|
|
56
|
-
};
|
|
57
|
-
// register option data with context
|
|
58
|
-
React.useEffect(() => {
|
|
59
|
-
if (id && optionRef.current) {
|
|
60
|
-
return registerOption(optionData, optionRef.current);
|
|
61
|
-
}
|
|
62
|
-
}, [id, optionData, registerOption]);
|
|
63
|
-
return {
|
|
64
|
-
components: {
|
|
65
|
-
root: 'div'
|
|
66
|
-
},
|
|
67
|
-
root: slot.always(getIntrinsicElementProps('div', {
|
|
68
|
-
ref: useMergedRefs(ref, optionRef),
|
|
69
|
-
'aria-disabled': disabled ? true : undefined,
|
|
70
|
-
id,
|
|
71
|
-
role: 'option',
|
|
72
|
-
...props,
|
|
73
|
-
onClick
|
|
74
|
-
}), {
|
|
75
|
-
elementType: 'div'
|
|
76
|
-
}),
|
|
77
|
-
disabled,
|
|
78
|
-
selected
|
|
79
|
-
};
|
|
80
|
-
};
|
|
81
|
-
function getTextString(text, children) {
|
|
82
|
-
if (text !== undefined) {
|
|
83
|
-
return text;
|
|
84
|
-
}
|
|
85
|
-
let textString = '';
|
|
86
|
-
let hasNonStringChild = false;
|
|
87
|
-
React.Children.forEach(children, child => {
|
|
88
|
-
if (typeof child === 'string') {
|
|
89
|
-
textString += child;
|
|
90
|
-
} else {
|
|
91
|
-
hasNonStringChild = true;
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
// warn if an Option has non-string children and no text prop
|
|
95
|
-
if (hasNonStringChild) {
|
|
96
|
-
// eslint-disable-next-line no-console
|
|
97
|
-
console.warn('Provide a `text` prop to Option components when they contain non-string children.');
|
|
98
|
-
}
|
|
99
|
-
return textString;
|
|
100
|
-
}
|
|
101
|
-
//# sourceMappingURL=usePromptOption.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["usePromptOption.tsx"],"sourcesContent":["import * as React from 'react';\nimport { getIntrinsicElementProps, slot, useId, useMergedRefs } from '@fluentui/react-components';\nimport { useActiveDescendantContext } from '@fluentui/react-aria';\nimport { useListboxContext_unstable } from '@fluentui/react-combobox';\nimport type { PromptOptionProps, PromptOptionState } from './PromptOption.types';\nimport type { OptionValue } from '../utils/OptionCollection.types';\n\n// If you add JSX to this file, be sure to change the file type to .tsx\n\n/**\n * Create the state required to render PromptOption.\n *\n * The returned state can be modified with hooks such as usePromptOptionStyles_unstable,\n * before being passed to renderPromptOption_unstable.\n *\n * @param props - props from this instance of PromptOption\n * @param ref - reference to root HTMLElement of PromptOption\n */\nexport const usePromptOption_unstable = (\n props: PromptOptionProps,\n ref: React.Ref<HTMLDivElement>,\n): PromptOptionState => {\n const { controller: activeDescendantController } = useActiveDescendantContext();\n const { children, disabled, text, value } = props;\n const optionRef = React.useRef<HTMLDivElement>(null);\n const optionText = getTextString(text, children);\n const optionValue = value ?? optionText;\n\n // use the id if provided, otherwise use a generated id\n const id = useId('fluent-option', props.id);\n\n // data used for context registration & events\n const optionData = React.useMemo<OptionValue>(\n () => ({ id, disabled, text: optionText, value: optionValue }),\n [id, disabled, optionText, optionValue],\n );\n\n // context values\n const registerOption = useListboxContext_unstable(ctx => ctx.registerOption);\n const selected = useListboxContext_unstable(ctx => {\n const selectedOptions = ctx.selectedOptions;\n\n return optionValue !== undefined && selectedOptions.find(o => o === optionValue) !== undefined;\n });\n const selectOption = useListboxContext_unstable(ctx => ctx.selectOption);\n const onOptionClick = useListboxContext_unstable(ctx => ctx.onOptionClick);\n\n const onClick = (event: React.MouseEvent<HTMLDivElement>) => {\n if (disabled) {\n event.preventDefault();\n return;\n }\n\n activeDescendantController.focus(id);\n\n // handle selection change\n selectOption(event, optionData);\n\n onOptionClick(event);\n props.onClick?.(event);\n };\n\n // register option data with context\n React.useEffect(() => {\n if (id && optionRef.current) {\n return registerOption(optionData, optionRef.current);\n }\n }, [id, optionData, registerOption]);\n\n return {\n components: {\n root: 'div',\n },\n root: slot.always(\n getIntrinsicElementProps('div', {\n ref: useMergedRefs(ref, optionRef),\n 'aria-disabled': disabled ? true : undefined,\n id,\n role: 'option',\n ...props,\n onClick,\n }),\n { elementType: 'div' },\n ),\n disabled,\n selected,\n };\n};\n\nfunction getTextString(text: string | undefined, children: React.ReactNode) {\n if (text !== undefined) {\n return text;\n }\n\n let textString = '';\n let hasNonStringChild = false;\n React.Children.forEach(children, child => {\n if (typeof child === 'string') {\n textString += child;\n } else {\n hasNonStringChild = true;\n }\n });\n\n // warn if an Option has non-string children and no text prop\n if (hasNonStringChild) {\n // eslint-disable-next-line no-console\n console.warn('Provide a `text` prop to Option components when they contain non-string children.');\n }\n\n return textString;\n}\n"],"names":["React","getIntrinsicElementProps","slot","useId","useMergedRefs","useActiveDescendantContext","useListboxContext_unstable","usePromptOption_unstable","props","ref","controller","activeDescendantController","children","disabled","text","value","optionRef","useRef","optionText","getTextString","optionValue","id","optionData","useMemo","registerOption","ctx","selected","selectedOptions","undefined","find","o","selectOption","onOptionClick","onClick","event","preventDefault","focus","useEffect","current","components","root","always","role","elementType","textString","hasNonStringChild","Children","forEach","child","console","warn"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,wBAAwB,EAAEC,IAAI,EAAEC,KAAK,EAAEC,aAAa,QAAQ,6BAA6B;AAClG,SAASC,0BAA0B,QAAQ,uBAAuB;AAClE,SAASC,0BAA0B,QAAQ,2BAA2B;AAItE,uEAAuE;AAEvE;;;;;;;;CAQC,GACD,OAAO,MAAMC,2BAA2B,CACtCC,OACAC;IAEA,MAAM,EAAEC,YAAYC,0BAA0B,EAAE,GAAGN;IACnD,MAAM,EAAEO,QAAQ,EAAEC,QAAQ,EAAEC,IAAI,EAAEC,KAAK,EAAE,GAAGP;IAC5C,MAAMQ,YAAYhB,MAAMiB,MAAM,CAAiB;IAC/C,MAAMC,aAAaC,cAAcL,MAAMF;IACvC,MAAMQ,cAAcL,kBAAAA,mBAAAA,QAASG;IAE7B,uDAAuD;IACvD,MAAMG,KAAKlB,MAAM,iBAAiBK,MAAMa,EAAE;IAE1C,8CAA8C;IAC9C,MAAMC,aAAatB,MAAMuB,OAAO,CAC9B,IAAO,CAAA;YAAEF;YAAIR;YAAUC,MAAMI;YAAYH,OAAOK;QAAY,CAAA,GAC5D;QAACC;QAAIR;QAAUK;QAAYE;KAAY;IAGzC,iBAAiB;IACjB,MAAMI,iBAAiBlB,2BAA2BmB,CAAAA,MAAOA,IAAID,cAAc;IAC3E,MAAME,WAAWpB,2BAA2BmB,CAAAA;QAC1C,MAAME,kBAAkBF,IAAIE,eAAe;QAE3C,OAAOP,gBAAgBQ,aAAaD,gBAAgBE,IAAI,CAACC,CAAAA,IAAKA,MAAMV,iBAAiBQ;IACvF;IACA,MAAMG,eAAezB,2BAA2BmB,CAAAA,MAAOA,IAAIM,YAAY;IACvE,MAAMC,gBAAgB1B,2BAA2BmB,CAAAA,MAAOA,IAAIO,aAAa;IAEzE,MAAMC,UAAU,CAACC;YAYf1B;QAXA,IAAIK,UAAU;YACZqB,MAAMC,cAAc;YACpB;QACF;QAEAxB,2BAA2ByB,KAAK,CAACf;QAEjC,0BAA0B;QAC1BU,aAAaG,OAAOZ;QAEpBU,cAAcE;SACd1B,iBAAAA,MAAMyB,OAAO,cAAbzB,qCAAAA,oBAAAA,OAAgB0B;IAClB;IAEA,oCAAoC;IACpClC,MAAMqC,SAAS,CAAC;QACd,IAAIhB,MAAML,UAAUsB,OAAO,EAAE;YAC3B,OAAOd,eAAeF,YAAYN,UAAUsB,OAAO;QACrD;IACF,GAAG;QAACjB;QAAIC;QAAYE;KAAe;IAEnC,OAAO;QACLe,YAAY;YACVC,MAAM;QACR;QACAA,MAAMtC,KAAKuC,MAAM,CACfxC,yBAAyB,OAAO;YAC9BQ,KAAKL,cAAcK,KAAKO;YACxB,iBAAiBH,WAAW,OAAOe;YACnCP;YACAqB,MAAM;YACN,GAAGlC,KAAK;YACRyB;QACF,IACA;YAAEU,aAAa;QAAM;QAEvB9B;QACAa;IACF;AACF,EAAE;AAEF,SAASP,cAAcL,IAAwB,EAAEF,QAAyB;IACxE,IAAIE,SAASc,WAAW;QACtB,OAAOd;IACT;IAEA,IAAI8B,aAAa;IACjB,IAAIC,oBAAoB;IACxB7C,MAAM8C,QAAQ,CAACC,OAAO,CAACnC,UAAUoC,CAAAA;QAC/B,IAAI,OAAOA,UAAU,UAAU;YAC7BJ,cAAcI;QAChB,OAAO;YACLH,oBAAoB;QACtB;IACF;IAEA,6DAA6D;IAC7D,IAAIA,mBAAmB;QACrB,sCAAsC;QACtCI,QAAQC,IAAI,CAAC;IACf;IAEA,OAAON;AACT"}
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import { __styles, mergeClasses, shorthands } from '@fluentui/react-components';
|
|
2
|
-
import { tokens } from '@fluentui-copilot/tokens';
|
|
3
|
-
import { ACTIVEDESCENDANT_FOCUSVISIBLE_ATTRIBUTE } from '@fluentui/react-aria';
|
|
4
|
-
export const promptOptionClassNames = {
|
|
5
|
-
root: 'fai-PromptOption'
|
|
6
|
-
};
|
|
7
|
-
/**
|
|
8
|
-
* Styles for the root slot
|
|
9
|
-
*/
|
|
10
|
-
const useStyles = __styles({
|
|
11
|
-
root: {
|
|
12
|
-
Bt984gj: "f122n59",
|
|
13
|
-
Beyfa6y: 0,
|
|
14
|
-
Bbmb7ep: 0,
|
|
15
|
-
Btl43ni: 0,
|
|
16
|
-
B7oj6ja: 0,
|
|
17
|
-
Dimara: "ft85np5",
|
|
18
|
-
sj55zd: "f19n0e5",
|
|
19
|
-
i8kkvl: "f1ufnopg",
|
|
20
|
-
Bceei9c: "f1k6fduh",
|
|
21
|
-
mc9l5x: "f22iagw",
|
|
22
|
-
Bahqtrf: "fk6fouc",
|
|
23
|
-
Be2twd7: "fkhj508",
|
|
24
|
-
Bg96gwp: "f1i3iumi",
|
|
25
|
-
Byoj8tv: 0,
|
|
26
|
-
uwmqm3: 0,
|
|
27
|
-
z189sj: 0,
|
|
28
|
-
z8tnut: 0,
|
|
29
|
-
B0ocmuz: "fm5eomj",
|
|
30
|
-
qhf8xq: "f10pi13n",
|
|
31
|
-
Jwef8y: "f1knas48",
|
|
32
|
-
Bi91k9c: "feu1g3u",
|
|
33
|
-
ecr2s2: "fb40n2d",
|
|
34
|
-
lj723h: "f1g4hkjv"
|
|
35
|
-
},
|
|
36
|
-
active: {
|
|
37
|
-
Bowz1zl: "f11vrvdw",
|
|
38
|
-
oxogb1: "f17hxjb7",
|
|
39
|
-
Ix2sn8: "f1dha69c",
|
|
40
|
-
q7v32p: "f1lm7500",
|
|
41
|
-
Bqfxd14: "f1n5bo3l",
|
|
42
|
-
B53xpsf: ["fp57yr3", "f48q4c"],
|
|
43
|
-
B1wzb3v: "fg547j0",
|
|
44
|
-
f0sref: ["f48q4c", "fp57yr3"],
|
|
45
|
-
Btq9bd3: "fuyp35s",
|
|
46
|
-
Bertapg: ["f1a9nstl", "fhk0hgg"],
|
|
47
|
-
b50fsz: "f1rdp6f1",
|
|
48
|
-
avt0cx: ["fhk0hgg", "f1a9nstl"],
|
|
49
|
-
B39dzdd: "ffd7rjx",
|
|
50
|
-
Be3o27t: ["fobu5kn", "f1dbet5w"],
|
|
51
|
-
Bewtojm: "f1ap9jj5",
|
|
52
|
-
B37u8z8: ["f1dbet5w", "fobu5kn"],
|
|
53
|
-
Fffuxt: 0,
|
|
54
|
-
Bttcd12: 0,
|
|
55
|
-
Beitzug: 0,
|
|
56
|
-
Bqougee: 0,
|
|
57
|
-
B86i8pi: "f1kurthe",
|
|
58
|
-
Bhijsxg: "fwq15dy",
|
|
59
|
-
kktds4: "f1pb3wry",
|
|
60
|
-
Bmau3bo: ["ftjv2f4", "f1flhb1f"],
|
|
61
|
-
npektv: ["f1flhb1f", "ftjv2f4"]
|
|
62
|
-
},
|
|
63
|
-
disabled: {
|
|
64
|
-
sj55zd: "f1s2aq7o",
|
|
65
|
-
Jwef8y: "f9ql6rf",
|
|
66
|
-
Bi91k9c: "fvgxktp",
|
|
67
|
-
ecr2s2: "fgj9um3",
|
|
68
|
-
lj723h: "f19wldhg",
|
|
69
|
-
B7iucu3: "f1cyfu5x"
|
|
70
|
-
}
|
|
71
|
-
}, {
|
|
72
|
-
d: [".f122n59{align-items:center;}", [".ft85np5{border-radius:var(--borderRadiusMedium);}", {
|
|
73
|
-
p: -1
|
|
74
|
-
}], ".f19n0e5{color:var(--colorNeutralForeground1);}", ".f1ufnopg{column-gap:var(--spacingHorizontalXS);}", ".f1k6fduh{cursor:pointer;}", ".f22iagw{display:flex;}", ".fk6fouc{font-family:var(--fontFamilyBase);}", ".fkhj508{font-size:var(--fontSizeBase300);}", ".f1i3iumi{line-height:var(--lineHeightBase300);}", [".fm5eomj{padding:var(--spacingVerticalSNudge) var(--spacingHorizontalS);}", {
|
|
75
|
-
p: -1
|
|
76
|
-
}], ".f10pi13n{position:relative;}", ".f11vrvdw[data-activedescendant-focusvisible]::after{content:\"\";}", ".f17hxjb7[data-activedescendant-focusvisible]::after{position:absolute;}", ".f1dha69c[data-activedescendant-focusvisible]::after{pointer-events:none;}", ".f1lm7500[data-activedescendant-focusvisible]::after{z-index:1;}", ".f1n5bo3l[data-activedescendant-focusvisible]::after{border-top-width:var(--strokeWidthThick);}", ".fp57yr3[data-activedescendant-focusvisible]::after{border-right-width:var(--strokeWidthThick);}", ".f48q4c[data-activedescendant-focusvisible]::after{border-left-width:var(--strokeWidthThick);}", ".fg547j0[data-activedescendant-focusvisible]::after{border-bottom-width:var(--strokeWidthThick);}", ".fuyp35s[data-activedescendant-focusvisible]::after{border-top-style:solid;}", ".f1a9nstl[data-activedescendant-focusvisible]::after{border-right-style:solid;}", ".fhk0hgg[data-activedescendant-focusvisible]::after{border-left-style:solid;}", ".f1rdp6f1[data-activedescendant-focusvisible]::after{border-bottom-style:solid;}", ".ffd7rjx[data-activedescendant-focusvisible]::after{border-top-color:var(--colorStrokeFocus2);}", ".fobu5kn[data-activedescendant-focusvisible]::after{border-right-color:var(--colorStrokeFocus2);}", ".f1dbet5w[data-activedescendant-focusvisible]::after{border-left-color:var(--colorStrokeFocus2);}", ".f1ap9jj5[data-activedescendant-focusvisible]::after{border-bottom-color:var(--colorStrokeFocus2);}", [".f1kurthe[data-activedescendant-focusvisible]::after{border-radius:var(--borderRadiusMedium);}", {
|
|
77
|
-
p: -1
|
|
78
|
-
}], ".fwq15dy[data-activedescendant-focusvisible]::after{top:-2px;}", ".f1pb3wry[data-activedescendant-focusvisible]::after{bottom:-2px;}", ".ftjv2f4[data-activedescendant-focusvisible]::after{left:-2px;}", ".f1flhb1f[data-activedescendant-focusvisible]::after{right:-2px;}", ".f1s2aq7o{color:var(--colorNeutralForegroundDisabled);}"],
|
|
79
|
-
h: [".f1knas48:hover{background-color:var(--colorNeutralBackground1Hover);}", ".feu1g3u:hover{color:var(--colorNeutralForeground1Hover);}", ".f9ql6rf:hover{background-color:var(--colorTransparentBackground);}", ".fvgxktp:hover{color:var(--colorNeutralForegroundDisabled);}"],
|
|
80
|
-
a: [".fb40n2d:active{background-color:var(--colorNeutralBackground1Pressed);}", ".f1g4hkjv:active{color:var(--colorNeutralForeground1Pressed);}", ".fgj9um3:active{background-color:var(--colorTransparentBackground);}", ".f19wldhg:active{color:var(--colorNeutralForegroundDisabled);}"],
|
|
81
|
-
m: [["@media (forced-colors: active){.f1cyfu5x{color:GrayText;}}", {
|
|
82
|
-
m: "(forced-colors: active)"
|
|
83
|
-
}]]
|
|
84
|
-
});
|
|
85
|
-
/**
|
|
86
|
-
* Apply styling to the PromptOption slots based on the state
|
|
87
|
-
*/
|
|
88
|
-
export const usePromptOptionStyles_unstable = state => {
|
|
89
|
-
'use no memo';
|
|
90
|
-
|
|
91
|
-
const {
|
|
92
|
-
disabled
|
|
93
|
-
} = state;
|
|
94
|
-
const styles = useStyles();
|
|
95
|
-
state.root.className = mergeClasses(promptOptionClassNames.root, styles.root, styles.active, disabled && styles.disabled, state.root.className);
|
|
96
|
-
return state;
|
|
97
|
-
};
|
|
98
|
-
//# sourceMappingURL=usePromptOptionStyles.styles.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["usePromptOptionStyles.styles.ts"],"sourcesContent":["import { makeStyles, mergeClasses, shorthands } from '@fluentui/react-components';\nimport { tokens } from '@fluentui-copilot/tokens';\nimport { ACTIVEDESCENDANT_FOCUSVISIBLE_ATTRIBUTE } from '@fluentui/react-aria';\nimport type { PromptOptionSlots, PromptOptionState } from './PromptOption.types';\nimport type { SlotClassNames } from '@fluentui/react-components';\n\nexport const promptOptionClassNames: SlotClassNames<PromptOptionSlots> = {\n root: 'fai-PromptOption',\n};\n\n/**\n * Styles for the root slot\n */\nconst useStyles = makeStyles({\n root: {\n alignItems: 'center',\n borderRadius: tokens.borderRadiusMedium,\n color: tokens.colorNeutralForeground1,\n columnGap: tokens.spacingHorizontalXS,\n cursor: 'pointer',\n display: 'flex',\n fontFamily: tokens.fontFamilyBase,\n fontSize: tokens.fontSizeBase300,\n lineHeight: tokens.lineHeightBase300,\n padding: `${tokens.spacingVerticalSNudge} ${tokens.spacingHorizontalS}`,\n position: 'relative',\n\n ':hover': {\n backgroundColor: tokens.colorNeutralBackground1Hover,\n color: tokens.colorNeutralForeground1Hover,\n },\n\n ':active': {\n backgroundColor: tokens.colorNeutralBackground1Pressed,\n color: tokens.colorNeutralForeground1Pressed,\n },\n },\n\n active: {\n [`[${ACTIVEDESCENDANT_FOCUSVISIBLE_ATTRIBUTE}]::after`]: {\n content: '\"\"',\n position: 'absolute',\n pointerEvents: 'none',\n zIndex: 1,\n\n ...shorthands.border(tokens.strokeWidthThick, `solid`, tokens.colorStrokeFocus2),\n borderRadius: tokens.borderRadiusMedium,\n\n top: '-2px',\n bottom: '-2px',\n left: '-2px',\n right: '-2px',\n },\n },\n\n disabled: {\n color: tokens.colorNeutralForegroundDisabled,\n\n ':hover': {\n backgroundColor: tokens.colorTransparentBackground,\n color: tokens.colorNeutralForegroundDisabled,\n },\n\n ':active': {\n backgroundColor: tokens.colorTransparentBackground,\n color: tokens.colorNeutralForegroundDisabled,\n },\n\n '@media (forced-colors: active)': {\n color: 'GrayText',\n },\n },\n});\n\n/**\n * Apply styling to the PromptOption slots based on the state\n */\nexport const usePromptOptionStyles_unstable = (state: PromptOptionState): PromptOptionState => {\n 'use no memo';\n\n const { disabled } = state;\n const styles = useStyles();\n state.root.className = mergeClasses(\n promptOptionClassNames.root,\n styles.root,\n styles.active,\n disabled && styles.disabled,\n state.root.className,\n );\n\n return state;\n};\n"],"names":["makeStyles","mergeClasses","shorthands","tokens","ACTIVEDESCENDANT_FOCUSVISIBLE_ATTRIBUTE","promptOptionClassNames","root","useStyles","alignItems","borderRadius","borderRadiusMedium","color","colorNeutralForeground1","columnGap","spacingHorizontalXS","cursor","display","fontFamily","fontFamilyBase","fontSize","fontSizeBase300","lineHeight","lineHeightBase300","padding","spacingVerticalSNudge","spacingHorizontalS","position","backgroundColor","colorNeutralBackground1Hover","colorNeutralForeground1Hover","colorNeutralBackground1Pressed","colorNeutralForeground1Pressed","active","content","pointerEvents","zIndex","border","strokeWidthThick","colorStrokeFocus2","top","bottom","left","right","disabled","colorNeutralForegroundDisabled","colorTransparentBackground","usePromptOptionStyles_unstable","state","styles","className"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,UAAU,EAAEC,YAAY,EAAEC,UAAU,QAAQ,6BAA6B;AAClF,SAASC,MAAM,QAAQ,2BAA2B;AAClD,SAASC,uCAAuC,QAAQ,uBAAuB;AAI/E,OAAO,MAAMC,yBAA4D;IACvEC,MAAM;AACR,EAAE;AAEF;;CAEC,GACD,MAAMC,YAAYP,WAAW;IAC3BM,MAAM;QACJE,YAAY;QACZC,cAAcN,OAAOO,kBAAkB;QACvCC,OAAOR,OAAOS,uBAAuB;QACrCC,WAAWV,OAAOW,mBAAmB;QACrCC,QAAQ;QACRC,SAAS;QACTC,YAAYd,OAAOe,cAAc;QACjCC,UAAUhB,OAAOiB,eAAe;QAChCC,YAAYlB,OAAOmB,iBAAiB;QACpCC,SAAS,CAAC,EAAEpB,OAAOqB,qBAAqB,CAAC,CAAC,EAAErB,OAAOsB,kBAAkB,CAAC,CAAC;QACvEC,UAAU;QAEV,UAAU;YACRC,iBAAiBxB,OAAOyB,4BAA4B;YACpDjB,OAAOR,OAAO0B,4BAA4B;QAC5C;QAEA,WAAW;YACTF,iBAAiBxB,OAAO2B,8BAA8B;YACtDnB,OAAOR,OAAO4B,8BAA8B;QAC9C;IACF;IAEAC,QAAQ;QACN,CAAC,CAAC,CAAC,EAAE5B,wCAAwC,QAAQ,CAAC,CAAC,EAAE;YACvD6B,SAAS;YACTP,UAAU;YACVQ,eAAe;YACfC,QAAQ;YAER,GAAGjC,WAAWkC,MAAM,CAACjC,OAAOkC,gBAAgB,EAAE,CAAC,KAAK,CAAC,EAAElC,OAAOmC,iBAAiB,CAAC;YAChF7B,cAAcN,OAAOO,kBAAkB;YAEvC6B,KAAK;YACLC,QAAQ;YACRC,MAAM;YACNC,OAAO;QACT;IACF;IAEAC,UAAU;QACRhC,OAAOR,OAAOyC,8BAA8B;QAE5C,UAAU;YACRjB,iBAAiBxB,OAAO0C,0BAA0B;YAClDlC,OAAOR,OAAOyC,8BAA8B;QAC9C;QAEA,WAAW;YACTjB,iBAAiBxB,OAAO0C,0BAA0B;YAClDlC,OAAOR,OAAOyC,8BAA8B;QAC9C;QAEA,kCAAkC;YAChCjC,OAAO;QACT;IACF;AACF;AAEA;;CAEC,GACD,OAAO,MAAMmC,iCAAiC,CAACC;IAC7C;IAEA,MAAM,EAAEJ,QAAQ,EAAE,GAAGI;IACrB,MAAMC,SAASzC;IACfwC,MAAMzC,IAAI,CAAC2C,SAAS,GAAGhD,aACrBI,uBAAuBC,IAAI,EAC3B0C,OAAO1C,IAAI,EACX0C,OAAOhB,MAAM,EACbW,YAAYK,OAAOL,QAAQ,EAC3BI,MAAMzC,IAAI,CAAC2C,SAAS;IAGtB,OAAOF;AACT,EAAE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["OptionCollection.types.ts"],"sourcesContent":["// Brought from Fluent UI\n\nexport type OptionValue = {\n /** The disabled state of the option. */\n disabled?: boolean;\n\n /** The `id` attribute of the option. */\n id: string;\n\n /** The `text` string for the option. */\n text: string;\n\n /** The value string of the option. */\n value: string;\n};\n\nexport type OptionCollectionState = {\n /** The total number of options in the collection. */\n getCount: () => number;\n\n /** Returns the option data by key. */\n getOptionById(id: string): OptionValue | undefined;\n\n /** Returns an array of options filtered by a value matching function against the option's value string. */\n getOptionsMatchingValue(matcher: (value: string) => boolean): OptionValue[];\n\n /** The unordered option data. */\n options: OptionValue[];\n\n /** A function that child options call to register their values. Returns a function to unregister the option. */\n registerOption: (option: OptionValue, element: HTMLElement) => () => void;\n};\n"],"names":[],"rangeMappings":";","mappings":"AAAA,yBAAyB;AAgBzB,WAeE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["PromptListboxFunctionality.types.ts"],"sourcesContent":["import type * as React from 'react';\nimport type { PromptListboxProps } from '../../components/PromptListbox';\nimport type { PositioningShorthand } from '@fluentui/react-components';\nimport type { EventData, EventHandler } from '@fluentui/react-utilities';\nimport type { EditorInputProps } from '@fluentui-copilot/react-editor-input';\n\n// Note: While we are removing multiselect, we are keeping the logic and disabling it\n// in case it's needed in the future.\nexport type ProcessedPromptListboxProps = Partial<\n Omit<PromptListboxProps, 'activeDescendantController' | 'multiselect'>\n> & {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ref?: React.MutableRefObject<any>;\n};\n\nexport type UsePromptListboxFunctionality = {\n /**\n * Component to be rendered in the Input component. This should be passed to the listbox prop.\n */\n promptListbox: JSX.Element;\n /**\n * Props to be spread in the PromptInput, these props are needed for the keyboard behavior to\n * work correctly.\n */\n triggerProps: {\n ref: React.RefObject<HTMLSpanElement>;\n /**\n * Whether the listbox is being used to go through options or the user is currently typing.\n */\n isInSelectionMode: boolean;\n } & Required<Pick<EditorInputProps, 'onBlur' | 'onFocus' | 'onKeyDown'>>;\n /**\n * Ref used to point which element the listbox should be anchored to. Most use cases\n * will provide this prop to the PromptInput's EditorInput (since this is the root slot,\n * this is provided directly to the component and not the slot).\n *\n * Note: If the containerRef is the same as the trigger, the ref provided in triggerProps needs\n * to be merged with this one using `useMergedRefs(containerRef, triggerProps.ref);`\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n containerRef: React.MutableRefObject<any>;\n /**\n * Plugin used to tell where the cursor is in the EditorInput, this is important for the\n * keyboard behavior. This should be passed as children in the PromptInput.\n */\n cursorPositionPlugin: JSX.Element;\n};\n\nexport type UsePromptListboxFunctionalityParams = {\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: EventHandler<OnOpenChangeData>;\n positioning?: PositioningShorthand;\n\n /**\n * Callback to call when the selection mode (selecting an action vs typing) changes.\n */\n onSelectionModeChange?: (isInSelectionMode: boolean) => void;\n\n /**\n * Props to be passed to the ListboxComponent\n */\n listboxProps?: ProcessedPromptListboxProps;\n\n /**\n * Whether the listbox's width should take all the available space or only\n * the required space.\n *\n * @default false\n */\n fluid?: boolean;\n\n /**\n * Whether to allow reaching the listbox options by arrowing up at the start of the input.\n * Note, this prop is meant to be used with the following positioning props:\n * ```ts\n * usePromptListboxFunctionality({\n * positioning: {\n * position: 'above',\n * fallbackPositions: ['above']\n * }\n * });\n * ```\n * This is useful when using PromptListbox with other components such as ChatInput since\n * the input will always stay at the bottom therefore the listbox would always get cut.\n *\n * @default false\n */\n allowArrowUpNavigation?: boolean;\n};\n\nexport type OnOpenChangeData = (\n | EventData<'click', React.MouseEvent<HTMLSpanElement>>\n | EventData<'focus', React.FocusEvent<HTMLSpanElement>>\n | EventData<'keyboard', React.KeyboardEvent<HTMLSpanElement>>\n) & {\n open: boolean;\n};\n"],"names":[],"rangeMappings":"","mappings":"AA2FA,WAME"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["Selection.types.ts"],"sourcesContent":["// Brought from Fluent UI\n\nimport type * as React from 'react';\nimport type { OptionValue } from './OptionCollection.types';\n\nexport type SelectionProps = {\n /**\n * For an uncontrolled component, sets the initial selection.\n * If this is set, the `defaultValue` prop MUST also be set.\n */\n defaultSelectedOptions?: string[];\n\n /**\n * Sets the selection type to multiselect.\n * Set this to true for multiselect, even if fully controlling selection state.\n * This enables styles and accessibility properties to be set.\n * @default false\n */\n multiselect?: boolean;\n\n /** Callback when an option is selected */\n onOptionSelect?: (event: SelectionEvents, data: OptionOnSelectData) => void;\n\n /**\n * An array of selected option keys.\n * Use this with `onOptionSelect` to directly control the selected option(s)\n * If this is set, the `value` prop MUST also be controlled.\n */\n selectedOptions?: string[];\n};\n\n/** Values returned by the useSelection hook */\nexport type SelectionState = {\n clearSelection: (event: SelectionEvents) => void;\n selectedOptions: string[];\n selectOption: (event: SelectionEvents, option: OptionValue) => void;\n};\n\n/**\n * Data for the onOptionSelect callback.\n * `optionValue` and `optionText` will be undefined if multiple options are modified at once.\n */\nexport type OptionOnSelectData = {\n optionValue: string | undefined;\n optionText: string | undefined;\n selectedOptions: string[];\n};\n\n/** Possible event types for onOptionSelect */\nexport type SelectionEvents =\n | React.ChangeEvent<HTMLElement>\n | React.KeyboardEvent<HTMLElement>\n | React.MouseEvent<HTMLElement>;\n"],"names":[],"rangeMappings":";","mappings":"AAAA,yBAAyB;AAgDzB,4CAA4C,GAC5C,WAGkC"}
|
|
@@ -1,68 +0,0 @@
|
|
|
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
|
-
cursorPosition,
|
|
11
|
-
allowArrowUpNavigation,
|
|
12
|
-
isInSelectionMode
|
|
13
|
-
} = options;
|
|
14
|
-
const code = e.key;
|
|
15
|
-
const {
|
|
16
|
-
altKey,
|
|
17
|
-
ctrlKey,
|
|
18
|
-
key,
|
|
19
|
-
metaKey
|
|
20
|
-
} = e;
|
|
21
|
-
// typing action occurs whether open or closed
|
|
22
|
-
if (key.length === 1 && code !== keys.Space && !altKey && !ctrlKey && !metaKey) {
|
|
23
|
-
return 'Type';
|
|
24
|
-
}
|
|
25
|
-
// select or close actions
|
|
26
|
-
if (code === keys.ArrowUp && altKey || code === keys.Enter) {
|
|
27
|
-
return 'CloseSelect';
|
|
28
|
-
}
|
|
29
|
-
// navigation interactions
|
|
30
|
-
const atStart = allowArrowUpNavigation && (cursorPosition === 'start' || cursorPosition === 'start-end');
|
|
31
|
-
const atEnd = cursorPosition === 'end' || cursorPosition === 'start-end';
|
|
32
|
-
if (code === keys.ArrowDown) {
|
|
33
|
-
if (atEnd) {
|
|
34
|
-
return 'Next';
|
|
35
|
-
} else if (atStart && isInSelectionMode) {
|
|
36
|
-
return 'Next';
|
|
37
|
-
}
|
|
38
|
-
return 'Type';
|
|
39
|
-
}
|
|
40
|
-
if (code === keys.ArrowUp) {
|
|
41
|
-
if (atEnd && isInSelectionMode) {
|
|
42
|
-
return 'Previous';
|
|
43
|
-
} else if (atStart && !isInSelectionMode) {
|
|
44
|
-
return 'Next';
|
|
45
|
-
} else if (atStart && isInSelectionMode) {
|
|
46
|
-
return 'Previous';
|
|
47
|
-
}
|
|
48
|
-
return 'Type';
|
|
49
|
-
}
|
|
50
|
-
if (code === keys.Home) {
|
|
51
|
-
return atEnd || atStart ? 'First' : 'Type';
|
|
52
|
-
}
|
|
53
|
-
if (code === keys.End) {
|
|
54
|
-
return atEnd || atStart ? 'Last' : 'Type';
|
|
55
|
-
}
|
|
56
|
-
if (code === keys.PageUp) {
|
|
57
|
-
return 'PageUp';
|
|
58
|
-
}
|
|
59
|
-
if (code === keys.PageDown) {
|
|
60
|
-
return 'PageDown';
|
|
61
|
-
}
|
|
62
|
-
if (code === keys.Tab) {
|
|
63
|
-
return 'Tab';
|
|
64
|
-
}
|
|
65
|
-
// if nothing matched, return none
|
|
66
|
-
return 'None';
|
|
67
|
-
}
|
|
68
|
-
//# sourceMappingURL=dropdownKeyActions.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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';\nimport type { CursorPosition } from '../../plugins/CursorPositionPlugin';\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 cursorPosition: CursorPosition;\n allowArrowUpNavigation: boolean;\n isInSelectionMode: 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 { cursorPosition, allowArrowUpNavigation, isInSelectionMode } = 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 const atStart = allowArrowUpNavigation && (cursorPosition === 'start' || cursorPosition === 'start-end');\n const atEnd = cursorPosition === 'end' || cursorPosition === 'start-end';\n if (code === keys.ArrowDown) {\n if (atEnd) {\n return 'Next';\n } else if (atStart && isInSelectionMode) {\n return 'Next';\n }\n return 'Type';\n }\n if (code === keys.ArrowUp) {\n if (atEnd && isInSelectionMode) {\n return 'Previous';\n } else if (atStart && !isInSelectionMode) {\n return 'Next';\n } else if (atStart && isInSelectionMode) {\n return 'Previous';\n }\n return 'Type';\n }\n if (code === keys.Home) {\n return atEnd || atStart ? 'First' : 'Type';\n }\n if (code === keys.End) {\n return atEnd || atStart ? 'Last' : 'Type';\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","cursorPosition","allowArrowUpNavigation","isInSelectionMode","code","key","altKey","ctrlKey","metaKey","length","Space","ArrowUp","Enter","atStart","atEnd","ArrowDown","Home","End","PageUp","PageDown","Tab"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;;;CAGC,GAED,YAAYA,UAAU,0BAA0B;AA6BhD;;CAEC,GACD,OAAO,SAASC,yBACdC,CAAsC,EACtCC,OAA8B;IAE9B,MAAM,EAAEC,cAAc,EAAEC,sBAAsB,EAAEC,iBAAiB,EAAE,GAAGH;IACtE,MAAMI,OAAOL,EAAEM,GAAG;IAClB,MAAM,EAAEC,MAAM,EAAEC,OAAO,EAAEF,GAAG,EAAEG,OAAO,EAAE,GAAGT;IAE1C,8CAA8C;IAC9C,IAAIM,IAAII,MAAM,KAAK,KAAKL,SAASP,KAAKa,KAAK,IAAI,CAACJ,UAAU,CAACC,WAAW,CAACC,SAAS;QAC9E,OAAO;IACT;IAEA,0BAA0B;IAC1B,IAAI,AAACJ,SAASP,KAAKc,OAAO,IAAIL,UAAWF,SAASP,KAAKe,KAAK,EAAE;QAC5D,OAAO;IACT;IAEA,0BAA0B;IAC1B,MAAMC,UAAUX,0BAA2BD,CAAAA,mBAAmB,WAAWA,mBAAmB,WAAU;IACtG,MAAMa,QAAQb,mBAAmB,SAASA,mBAAmB;IAC7D,IAAIG,SAASP,KAAKkB,SAAS,EAAE;QAC3B,IAAID,OAAO;YACT,OAAO;QACT,OAAO,IAAID,WAAWV,mBAAmB;YACvC,OAAO;QACT;QACA,OAAO;IACT;IACA,IAAIC,SAASP,KAAKc,OAAO,EAAE;QACzB,IAAIG,SAASX,mBAAmB;YAC9B,OAAO;QACT,OAAO,IAAIU,WAAW,CAACV,mBAAmB;YACxC,OAAO;QACT,OAAO,IAAIU,WAAWV,mBAAmB;YACvC,OAAO;QACT;QACA,OAAO;IACT;IACA,IAAIC,SAASP,KAAKmB,IAAI,EAAE;QACtB,OAAOF,SAASD,UAAU,UAAU;IACtC;IACA,IAAIT,SAASP,KAAKoB,GAAG,EAAE;QACrB,OAAOH,SAASD,UAAU,SAAS;IACrC;IACA,IAAIT,SAASP,KAAKqB,MAAM,EAAE;QACxB,OAAO;IACT;IACA,IAAId,SAASP,KAAKsB,QAAQ,EAAE;QAC1B,OAAO;IACT;IACA,IAAIf,SAASP,KAAKuB,GAAG,EAAE;QACrB,OAAO;IACT;IAEA,kCAAkC;IAClC,OAAO;AACT"}
|