@fluentui-copilot/react-prompt-listbox 0.7.2 → 0.8.1-hotfix.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.
- package/CHANGELOG.json +46 -1
- package/CHANGELOG.md +20 -2
- package/lib/PromptListbox.js +0 -1
- package/lib/PromptOption.js +0 -1
- package/lib/components/PromptListbox/PromptListbox.js +5 -7
- package/lib/components/PromptListbox/PromptListbox.types.js +1 -2
- package/lib/components/PromptListbox/index.js +0 -1
- package/lib/components/PromptListbox/renderPromptListbox.js +17 -21
- package/lib/components/PromptListbox/usePromptListbox.js +53 -67
- package/lib/components/PromptListbox/usePromptListboxContextValues.js +22 -30
- package/lib/components/PromptListbox/usePromptListboxStyles.styles.raw.js +31 -0
- package/lib/components/PromptListbox/usePromptListboxStyles.styles.raw.js.map +1 -0
- package/lib/components/PromptOption/PromptOption.js +4 -6
- package/lib/components/PromptOption/PromptOption.types.js +1 -2
- package/lib/components/PromptOption/index.js +0 -1
- package/lib/components/PromptOption/renderPromptOption.js +4 -6
- package/lib/components/PromptOption/usePromptOption.js +84 -84
- package/lib/components/PromptOption/usePromptOptionStyles.styles.raw.js +68 -0
- package/lib/components/PromptOption/usePromptOptionStyles.styles.raw.js.map +1 -0
- package/lib/components/motion/PromptListboxMotion.js +52 -50
- package/lib/components/utils/OptionCollection.types.js +1 -2
- package/lib/components/utils/PromptListboxFunctionality.types.js +1 -2
- package/lib/components/utils/Selection.types.js +1 -2
- package/lib/components/utils/dropdownKeyActions.js +49 -60
- package/lib/components/utils/useListboxPositioning.js +22 -24
- package/lib/components/utils/useOptionCollection.js +30 -32
- package/lib/components/utils/usePromptListboxFunctionality.js +121 -123
- package/lib/components/utils/usePromptListboxFunctionalityV2.js +109 -124
- package/lib/components/utils/useSelection.js +57 -49
- package/lib/components/utils/useTriggerKeyDown.js +124 -133
- package/lib/index.js +0 -1
- package/lib/plugins/CursorPositionPlugin.js +39 -39
- package/lib-commonjs/PromptListbox.js +0 -1
- package/lib-commonjs/PromptOption.js +0 -1
- package/lib-commonjs/components/PromptListbox/PromptListbox.js +1 -1
- package/lib-commonjs/components/PromptListbox/PromptListbox.js.map +1 -1
- package/lib-commonjs/components/PromptListbox/PromptListbox.types.js +0 -1
- package/lib-commonjs/components/PromptListbox/index.js +0 -1
- package/lib-commonjs/components/PromptListbox/renderPromptListbox.js +1 -1
- package/lib-commonjs/components/PromptListbox/renderPromptListbox.js.map +1 -1
- package/lib-commonjs/components/PromptListbox/usePromptListbox.js +1 -1
- package/lib-commonjs/components/PromptListbox/usePromptListbox.js.map +1 -1
- package/lib-commonjs/components/PromptListbox/usePromptListboxContextValues.js +1 -1
- package/lib-commonjs/components/PromptListbox/usePromptListboxContextValues.js.map +1 -1
- package/lib-commonjs/components/PromptListbox/usePromptListboxStyles.styles.raw.js +47 -0
- package/lib-commonjs/components/PromptListbox/usePromptListboxStyles.styles.raw.js.map +1 -0
- package/lib-commonjs/components/PromptOption/PromptOption.js +1 -1
- package/lib-commonjs/components/PromptOption/PromptOption.js.map +1 -1
- package/lib-commonjs/components/PromptOption/PromptOption.types.js +0 -1
- package/lib-commonjs/components/PromptOption/index.js +0 -1
- package/lib-commonjs/components/PromptOption/renderPromptOption.js +1 -1
- package/lib-commonjs/components/PromptOption/renderPromptOption.js.map +1 -1
- package/lib-commonjs/components/PromptOption/usePromptOption.js +1 -1
- package/lib-commonjs/components/PromptOption/usePromptOption.js.map +1 -1
- package/lib-commonjs/components/PromptOption/usePromptOptionStyles.styles.raw.js +84 -0
- package/lib-commonjs/components/PromptOption/usePromptOptionStyles.styles.raw.js.map +1 -0
- package/lib-commonjs/components/motion/PromptListboxMotion.js +1 -1
- package/lib-commonjs/components/motion/PromptListboxMotion.js.map +1 -1
- package/lib-commonjs/components/utils/OptionCollection.types.js +0 -1
- package/lib-commonjs/components/utils/PromptListboxFunctionality.types.js +0 -1
- package/lib-commonjs/components/utils/Selection.types.js +0 -1
- package/lib-commonjs/components/utils/dropdownKeyActions.js +1 -1
- package/lib-commonjs/components/utils/dropdownKeyActions.js.map +1 -1
- package/lib-commonjs/components/utils/useListboxPositioning.js +1 -1
- package/lib-commonjs/components/utils/useListboxPositioning.js.map +1 -1
- package/lib-commonjs/components/utils/useOptionCollection.js +1 -1
- package/lib-commonjs/components/utils/useOptionCollection.js.map +1 -1
- package/lib-commonjs/components/utils/usePromptListboxFunctionality.js +1 -1
- package/lib-commonjs/components/utils/usePromptListboxFunctionality.js.map +1 -1
- package/lib-commonjs/components/utils/usePromptListboxFunctionalityV2.js +1 -1
- package/lib-commonjs/components/utils/usePromptListboxFunctionalityV2.js.map +1 -1
- package/lib-commonjs/components/utils/useSelection.js +1 -1
- package/lib-commonjs/components/utils/useSelection.js.map +1 -1
- package/lib-commonjs/components/utils/useTriggerKeyDown.js +1 -1
- package/lib-commonjs/components/utils/useTriggerKeyDown.js.map +1 -1
- package/lib-commonjs/index.js +0 -1
- package/lib-commonjs/plugins/CursorPositionPlugin.js +1 -1
- package/lib-commonjs/plugins/CursorPositionPlugin.js.map +1 -1
- package/package.json +16 -20
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { makeStyles, 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
|
+
*/ const useStyles = makeStyles({
|
|
10
|
+
root: {
|
|
11
|
+
alignItems: 'center',
|
|
12
|
+
borderRadius: tokens.borderRadiusMedium,
|
|
13
|
+
color: tokens.colorNeutralForeground1,
|
|
14
|
+
columnGap: tokens.spacingHorizontalXS,
|
|
15
|
+
cursor: 'pointer',
|
|
16
|
+
display: 'flex',
|
|
17
|
+
fontFamily: tokens.fontFamilyBase,
|
|
18
|
+
fontSize: tokens.fontSizeBase300,
|
|
19
|
+
lineHeight: tokens.lineHeightBase300,
|
|
20
|
+
padding: `${tokens.spacingVerticalSNudge} ${tokens.spacingHorizontalS}`,
|
|
21
|
+
position: 'relative',
|
|
22
|
+
':hover': {
|
|
23
|
+
backgroundColor: tokens.colorNeutralBackground1Hover,
|
|
24
|
+
color: tokens.colorNeutralForeground1Hover
|
|
25
|
+
},
|
|
26
|
+
':active': {
|
|
27
|
+
backgroundColor: tokens.colorNeutralBackground1Pressed,
|
|
28
|
+
color: tokens.colorNeutralForeground1Pressed
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
active: {
|
|
32
|
+
[`[${ACTIVEDESCENDANT_FOCUSVISIBLE_ATTRIBUTE}]::after`]: {
|
|
33
|
+
content: '""',
|
|
34
|
+
position: 'absolute',
|
|
35
|
+
pointerEvents: 'none',
|
|
36
|
+
zIndex: 1,
|
|
37
|
+
...shorthands.border(tokens.strokeWidthThick, `solid`, tokens.colorStrokeFocus2),
|
|
38
|
+
borderRadius: tokens.borderRadiusMedium,
|
|
39
|
+
top: '-2px',
|
|
40
|
+
bottom: '-2px',
|
|
41
|
+
left: '-2px',
|
|
42
|
+
right: '-2px'
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
disabled: {
|
|
46
|
+
color: tokens.colorNeutralForegroundDisabled,
|
|
47
|
+
':hover': {
|
|
48
|
+
backgroundColor: tokens.colorTransparentBackground,
|
|
49
|
+
color: tokens.colorNeutralForegroundDisabled
|
|
50
|
+
},
|
|
51
|
+
':active': {
|
|
52
|
+
backgroundColor: tokens.colorTransparentBackground,
|
|
53
|
+
color: tokens.colorNeutralForegroundDisabled
|
|
54
|
+
},
|
|
55
|
+
'@media (forced-colors: active)': {
|
|
56
|
+
color: 'GrayText'
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
/**
|
|
61
|
+
* Apply styling to the PromptOption slots based on the state
|
|
62
|
+
*/ export const usePromptOptionStyles_unstable = (state)=>{
|
|
63
|
+
'use no memo';
|
|
64
|
+
const { disabled } = state;
|
|
65
|
+
const styles = useStyles();
|
|
66
|
+
state.root.className = mergeClasses(promptOptionClassNames.root, styles.root, styles.active, disabled && styles.disabled, state.root.className);
|
|
67
|
+
return state;
|
|
68
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
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,53 +1,55 @@
|
|
|
1
1
|
import { createPresenceComponent, motionTokens } from '@fluentui/react-components';
|
|
2
|
-
const collapseMotion = ({
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
2
|
+
const collapseMotion = ({ element })=>{
|
|
3
|
+
const fromOpacity = 0;
|
|
4
|
+
const toOpacity = 1;
|
|
5
|
+
const fromHeight = '0';
|
|
6
|
+
const toHeight = `${element.scrollHeight}px`;
|
|
7
|
+
const overflow = 'hidden';
|
|
8
|
+
const duration = motionTokens.durationNormal;
|
|
9
|
+
const easing = motionTokens.curveEasyEaseMax;
|
|
10
|
+
const enterKeyframes = [
|
|
11
|
+
{
|
|
12
|
+
opacity: fromOpacity,
|
|
13
|
+
maxHeight: fromHeight,
|
|
14
|
+
overflow
|
|
15
|
+
},
|
|
16
|
+
// Transition to the height of the content, at 99.99% of the duration.
|
|
17
|
+
{
|
|
18
|
+
opacity: toOpacity,
|
|
19
|
+
maxHeight: toHeight,
|
|
20
|
+
offset: 0.9999,
|
|
21
|
+
overflow
|
|
22
|
+
},
|
|
23
|
+
// On completion, remove the maxHeight because the content might need to expand later.
|
|
24
|
+
{
|
|
25
|
+
opacity: toOpacity,
|
|
26
|
+
maxHeight: 'unset',
|
|
27
|
+
overflow
|
|
28
|
+
}
|
|
29
|
+
];
|
|
30
|
+
const exitKeyframes = [
|
|
31
|
+
{
|
|
32
|
+
opacity: toOpacity,
|
|
33
|
+
maxHeight: toHeight,
|
|
34
|
+
overflow
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
opacity: fromOpacity,
|
|
38
|
+
maxHeight: fromHeight,
|
|
39
|
+
overflow
|
|
40
|
+
}
|
|
41
|
+
];
|
|
42
|
+
return {
|
|
43
|
+
enter: {
|
|
44
|
+
duration,
|
|
45
|
+
easing,
|
|
46
|
+
keyframes: enterKeyframes
|
|
47
|
+
},
|
|
48
|
+
exit: {
|
|
49
|
+
duration,
|
|
50
|
+
easing,
|
|
51
|
+
keyframes: exitKeyframes
|
|
52
|
+
}
|
|
53
|
+
};
|
|
51
54
|
};
|
|
52
55
|
export const PromptListboxMotion = createPresenceComponent(collapseMotion);
|
|
53
|
-
//# sourceMappingURL=PromptListboxMotion.js.map
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export {};
|
|
2
|
-
//# sourceMappingURL=PromptListboxFunctionality.types.js.map
|
|
1
|
+
export { };
|
|
@@ -1,68 +1,57 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Note, this is mainly brought from Fluent UI, only removed the closing and
|
|
3
3
|
* opening logic since that's not needed for this use case.
|
|
4
|
-
*/import * as keys from '@fluentui/keyboard-keys';
|
|
4
|
+
*/ import * as keys from '@fluentui/keyboard-keys';
|
|
5
5
|
/**
|
|
6
6
|
* Converts a keyboard interaction into a defined action
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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';
|
|
7
|
+
*/ export function getDropdownActionFromKey(e, options) {
|
|
8
|
+
const { cursorPosition, allowArrowUpNavigation, isInSelectionMode } = options;
|
|
9
|
+
const code = e.key;
|
|
10
|
+
const { altKey, ctrlKey, key, metaKey } = e;
|
|
11
|
+
// typing action occurs whether open or closed
|
|
12
|
+
if (key.length === 1 && code !== keys.Space && !altKey && !ctrlKey && !metaKey) {
|
|
13
|
+
return 'Type';
|
|
37
14
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
if (atEnd && isInSelectionMode) {
|
|
42
|
-
return 'Previous';
|
|
43
|
-
} else if (atStart && !isInSelectionMode) {
|
|
44
|
-
return 'Next';
|
|
45
|
-
} else if (atStart && isInSelectionMode) {
|
|
46
|
-
return 'Previous';
|
|
15
|
+
// select or close actions
|
|
16
|
+
if (code === keys.ArrowUp && altKey || code === keys.Enter) {
|
|
17
|
+
return 'CloseSelect';
|
|
47
18
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
19
|
+
// navigation interactions
|
|
20
|
+
const atStart = allowArrowUpNavigation && (cursorPosition === 'start' || cursorPosition === 'start-end');
|
|
21
|
+
const atEnd = cursorPosition === 'end' || cursorPosition === 'start-end';
|
|
22
|
+
if (code === keys.ArrowDown) {
|
|
23
|
+
if (atEnd) {
|
|
24
|
+
return 'Next';
|
|
25
|
+
} else if (atStart && isInSelectionMode) {
|
|
26
|
+
return 'Next';
|
|
27
|
+
}
|
|
28
|
+
return 'Type';
|
|
29
|
+
}
|
|
30
|
+
if (code === keys.ArrowUp) {
|
|
31
|
+
if (atEnd && isInSelectionMode) {
|
|
32
|
+
return 'Previous';
|
|
33
|
+
} else if (atStart && !isInSelectionMode) {
|
|
34
|
+
return 'Next';
|
|
35
|
+
} else if (atStart && isInSelectionMode) {
|
|
36
|
+
return 'Previous';
|
|
37
|
+
}
|
|
38
|
+
return 'Type';
|
|
39
|
+
}
|
|
40
|
+
if (code === keys.Home) {
|
|
41
|
+
return atEnd || atStart ? 'First' : 'Type';
|
|
42
|
+
}
|
|
43
|
+
if (code === keys.End) {
|
|
44
|
+
return atEnd || atStart ? 'Last' : 'Type';
|
|
45
|
+
}
|
|
46
|
+
if (code === keys.PageUp) {
|
|
47
|
+
return 'PageUp';
|
|
48
|
+
}
|
|
49
|
+
if (code === keys.PageDown) {
|
|
50
|
+
return 'PageDown';
|
|
51
|
+
}
|
|
52
|
+
if (code === keys.Tab) {
|
|
53
|
+
return 'Tab';
|
|
54
|
+
}
|
|
55
|
+
// if nothing matched, return none
|
|
56
|
+
return 'None';
|
|
67
57
|
}
|
|
68
|
-
//# sourceMappingURL=dropdownKeyActions.js.map
|
|
@@ -1,28 +1,26 @@
|
|
|
1
1
|
// Brought from Fluent UI
|
|
2
2
|
import { resolvePositioningShorthand, usePositioning } from '@fluentui/react-positioning';
|
|
3
3
|
export function useListboxPositioning(props) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return [listboxRef, anchorRef];
|
|
4
|
+
const { positioning, fluid } = props;
|
|
5
|
+
const fallbackPositions = [
|
|
6
|
+
'below'
|
|
7
|
+
];
|
|
8
|
+
// popper options
|
|
9
|
+
const popperOptions = {
|
|
10
|
+
position: 'below',
|
|
11
|
+
align: 'start',
|
|
12
|
+
offset: {
|
|
13
|
+
crossAxis: 0,
|
|
14
|
+
mainAxis: 2
|
|
15
|
+
},
|
|
16
|
+
fallbackPositions: fallbackPositions,
|
|
17
|
+
matchTargetSize: fluid ? 'width' : undefined,
|
|
18
|
+
autoSize: true,
|
|
19
|
+
...resolvePositioningShorthand(positioning)
|
|
20
|
+
};
|
|
21
|
+
const { containerRef: listboxRef, targetRef: anchorRef } = usePositioning(popperOptions);
|
|
22
|
+
return [
|
|
23
|
+
listboxRef,
|
|
24
|
+
anchorRef
|
|
25
|
+
];
|
|
27
26
|
}
|
|
28
|
-
//# sourceMappingURL=useListboxPositioning.js.map
|
|
@@ -2,38 +2,36 @@
|
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
/**
|
|
4
4
|
* A hook for managing a collection of child Options
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
5
|
+
*/ export const useOptionCollection = ()=>{
|
|
6
|
+
const optionsById = React.useRef(new Map());
|
|
7
|
+
const collectionAPI = React.useMemo(()=>{
|
|
8
|
+
const getCount = ()=>optionsById.current.size;
|
|
9
|
+
// index searches are no longer used
|
|
10
|
+
const getOptionById = (id)=>{
|
|
11
|
+
return optionsById.current.get(id);
|
|
12
|
+
};
|
|
13
|
+
const getOptionsMatchingValue = (matcher)=>{
|
|
14
|
+
const matches = [];
|
|
15
|
+
for (const option of optionsById.current.values()){
|
|
16
|
+
if (matcher(option.value)) {
|
|
17
|
+
matches.push(option);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return matches;
|
|
21
|
+
};
|
|
22
|
+
return {
|
|
23
|
+
getCount,
|
|
24
|
+
getOptionById,
|
|
25
|
+
getOptionsMatchingValue
|
|
26
|
+
};
|
|
27
|
+
}, []);
|
|
28
|
+
const registerOption = React.useCallback((option)=>{
|
|
29
|
+
optionsById.current.set(option.id, option);
|
|
30
|
+
return ()=>optionsById.current.delete(option.id);
|
|
31
|
+
}, []);
|
|
23
32
|
return {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
33
|
+
...collectionAPI,
|
|
34
|
+
options: Array.from(optionsById.current.values()),
|
|
35
|
+
registerOption
|
|
27
36
|
};
|
|
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
37
|
};
|
|
39
|
-
//# sourceMappingURL=useOptionCollection.js.map
|