@fluentui-copilot/react-prompt-listbox 0.8.1-hotfix.1 → 0.8.1-hotfix.2
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 +4 -4
- package/CHANGELOG.md +5 -5
- package/lib/PromptListbox.js +1 -0
- package/lib/PromptOption.js +1 -0
- package/lib/components/PromptListbox/PromptListbox.js +7 -5
- package/lib/components/PromptListbox/PromptListbox.types.js +2 -1
- package/lib/components/PromptListbox/index.js +1 -0
- package/lib/components/PromptListbox/renderPromptListbox.js +21 -17
- package/lib/components/PromptListbox/usePromptListbox.js +67 -53
- package/lib/components/PromptListbox/usePromptListboxContextValues.js +30 -22
- package/lib/components/PromptListbox/usePromptListboxStyles.styles.raw.js +25 -21
- package/lib/components/PromptOption/PromptOption.js +6 -4
- package/lib/components/PromptOption/PromptOption.types.js +2 -1
- package/lib/components/PromptOption/index.js +1 -0
- package/lib/components/PromptOption/renderPromptOption.js +6 -4
- package/lib/components/PromptOption/usePromptOption.js +84 -84
- package/lib/components/PromptOption/usePromptOptionStyles.styles.raw.js +60 -54
- package/lib/components/motion/PromptListboxMotion.js +50 -52
- package/lib/components/utils/OptionCollection.types.js +2 -1
- package/lib/components/utils/PromptListboxFunctionality.types.js +2 -1
- package/lib/components/utils/Selection.types.js +2 -1
- package/lib/components/utils/dropdownKeyActions.js +60 -49
- package/lib/components/utils/useListboxPositioning.js +24 -22
- package/lib/components/utils/useOptionCollection.js +32 -30
- package/lib/components/utils/usePromptListboxFunctionality.js +123 -121
- package/lib/components/utils/usePromptListboxFunctionalityV2.js +124 -109
- package/lib/components/utils/useSelection.js +49 -57
- package/lib/components/utils/useTriggerKeyDown.js +133 -124
- package/lib/index.js +1 -0
- package/lib/plugins/CursorPositionPlugin.js +39 -39
- package/lib-commonjs/PromptListbox.js +1 -0
- package/lib-commonjs/PromptOption.js +1 -0
- 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 +1 -0
- package/lib-commonjs/components/PromptListbox/index.js +1 -0
- 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 +1 -1
- package/lib-commonjs/components/PromptListbox/usePromptListboxStyles.styles.raw.js.map +1 -1
- 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 +1 -0
- package/lib-commonjs/components/PromptOption/index.js +1 -0
- 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 +1 -1
- package/lib-commonjs/components/PromptOption/usePromptOptionStyles.styles.raw.js.map +1 -1
- 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 +1 -0
- package/lib-commonjs/components/utils/PromptListboxFunctionality.types.js +1 -0
- package/lib-commonjs/components/utils/Selection.types.js +1 -0
- 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 +1 -0
- package/lib-commonjs/plugins/CursorPositionPlugin.js +1 -1
- package/lib-commonjs/plugins/CursorPositionPlugin.js.map +1 -1
- package/package.json +10 -10
|
@@ -2,139 +2,148 @@
|
|
|
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 and added the bluring
|
|
4
4
|
* functionality.
|
|
5
|
-
*/
|
|
5
|
+
*/import * as React from 'react';
|
|
6
6
|
import { useSetKeyboardNavigation } from '@fluentui/react-tabster';
|
|
7
7
|
import { useEventCallback } from '@fluentui/react-utilities';
|
|
8
8
|
import { getDropdownActionFromKey } from './dropdownKeyActions';
|
|
9
9
|
import { ArrowLeft, ArrowRight } from '@fluentui/keyboard-keys';
|
|
10
10
|
export function useTriggerKeydown(options) {
|
|
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
|
-
|
|
11
|
+
const {
|
|
12
|
+
activeDescendantController,
|
|
13
|
+
getOptionById,
|
|
14
|
+
selectOption,
|
|
15
|
+
multiselect,
|
|
16
|
+
open,
|
|
17
|
+
cursorPosition,
|
|
18
|
+
onBlur,
|
|
19
|
+
allowArrowUpNavigation,
|
|
20
|
+
isInSelectionMode,
|
|
21
|
+
setSelectionMode
|
|
22
|
+
} = options;
|
|
23
|
+
const getActiveOption = React.useCallback(() => {
|
|
24
|
+
const activeOptionId = activeDescendantController.active();
|
|
25
|
+
return activeOptionId ? getOptionById(activeOptionId) : undefined;
|
|
26
|
+
}, [activeDescendantController, getOptionById]);
|
|
27
|
+
const first = () => {
|
|
28
|
+
activeDescendantController.first();
|
|
29
|
+
};
|
|
30
|
+
const last = () => {
|
|
31
|
+
activeDescendantController.last();
|
|
32
|
+
};
|
|
33
|
+
const blur = () => {
|
|
34
|
+
activeDescendantController.blur();
|
|
35
|
+
onBlur();
|
|
36
|
+
};
|
|
37
|
+
const next = activeOption => {
|
|
38
|
+
if (activeOption) {
|
|
39
|
+
activeDescendantController.next();
|
|
40
|
+
} else {
|
|
41
|
+
activeDescendantController.first();
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
const previous = activeOption => {
|
|
45
|
+
if (activeOption) {
|
|
46
|
+
activeDescendantController.prev();
|
|
47
|
+
} else {
|
|
48
|
+
activeDescendantController.first();
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
const pageUp = () => {
|
|
52
|
+
for (let i = 0; i < 10; i++) {
|
|
53
|
+
activeDescendantController.prev();
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
const pageDown = () => {
|
|
57
|
+
for (let i = 0; i < 10; i++) {
|
|
58
|
+
activeDescendantController.next();
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
const setKeyboardNavigation = useSetKeyboardNavigation();
|
|
62
|
+
return useEventCallback(e => {
|
|
63
|
+
const action = getDropdownActionFromKey(e, {
|
|
64
|
+
open,
|
|
65
|
+
multiselect,
|
|
66
|
+
cursorPosition,
|
|
67
|
+
allowArrowUpNavigation,
|
|
68
|
+
isInSelectionMode
|
|
69
|
+
});
|
|
70
|
+
const activeOption = getActiveOption();
|
|
71
|
+
const firstOption = activeDescendantController.first({
|
|
72
|
+
passive: true
|
|
73
|
+
});
|
|
74
|
+
if (e.key === ArrowLeft || e.key === ArrowRight || action === 'Type') {
|
|
75
|
+
setSelectionMode(false);
|
|
76
|
+
} else if (action === 'Next' || action === 'Previous' || action === 'First' || action === 'Last' || action === 'PageUp' || action === 'PageDown') {
|
|
77
|
+
setSelectionMode(true);
|
|
78
|
+
}
|
|
79
|
+
switch (action) {
|
|
80
|
+
case 'Last':
|
|
81
|
+
case 'First':
|
|
82
|
+
case 'PageDown':
|
|
83
|
+
case 'PageUp':
|
|
84
|
+
case 'CloseSelect':
|
|
85
|
+
case 'Select':
|
|
86
|
+
e.preventDefault();
|
|
87
|
+
break;
|
|
88
|
+
case 'Previous':
|
|
89
|
+
e.preventDefault();
|
|
90
|
+
break;
|
|
91
|
+
case 'Next':
|
|
92
|
+
e.preventDefault();
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
setKeyboardNavigation(true);
|
|
96
|
+
switch (action) {
|
|
97
|
+
case 'First':
|
|
98
|
+
first();
|
|
99
|
+
if (!isInSelectionMode) {
|
|
100
|
+
setSelectionMode(true);
|
|
41
101
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
102
|
+
break;
|
|
103
|
+
case 'Last':
|
|
104
|
+
last();
|
|
105
|
+
if (!isInSelectionMode) {
|
|
106
|
+
setSelectionMode(true);
|
|
46
107
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
108
|
+
break;
|
|
109
|
+
case 'Next':
|
|
110
|
+
next(activeOption);
|
|
111
|
+
if (!isInSelectionMode) {
|
|
112
|
+
setSelectionMode(true);
|
|
51
113
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
allowArrowUpNavigation,
|
|
60
|
-
isInSelectionMode
|
|
61
|
-
});
|
|
62
|
-
const activeOption = getActiveOption();
|
|
63
|
-
const firstOption = activeDescendantController.first({
|
|
64
|
-
passive: true
|
|
65
|
-
});
|
|
66
|
-
if (e.key === ArrowLeft || e.key === ArrowRight || action === 'Type') {
|
|
67
|
-
setSelectionMode(false);
|
|
68
|
-
} else if (action === 'Next' || action === 'Previous' || action === 'First' || action === 'Last' || action === 'PageUp' || action === 'PageDown') {
|
|
114
|
+
break;
|
|
115
|
+
case 'Previous':
|
|
116
|
+
// when active option is the first option and the action was "Previous",
|
|
117
|
+
// this means we were in the first option and we are "leaving" the listbox
|
|
118
|
+
if (activeOption && activeOption.id !== firstOption) {
|
|
119
|
+
previous(activeOption);
|
|
120
|
+
if (!isInSelectionMode) {
|
|
69
121
|
setSelectionMode(true);
|
|
122
|
+
}
|
|
123
|
+
} else {
|
|
124
|
+
blur();
|
|
125
|
+
setSelectionMode(false);
|
|
70
126
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
break;
|
|
83
|
-
case 'Next':
|
|
84
|
-
e.preventDefault();
|
|
85
|
-
break;
|
|
86
|
-
}
|
|
87
|
-
setKeyboardNavigation(true);
|
|
88
|
-
switch(action){
|
|
89
|
-
case 'First':
|
|
90
|
-
first();
|
|
91
|
-
if (!isInSelectionMode) {
|
|
92
|
-
setSelectionMode(true);
|
|
93
|
-
}
|
|
94
|
-
break;
|
|
95
|
-
case 'Last':
|
|
96
|
-
last();
|
|
97
|
-
if (!isInSelectionMode) {
|
|
98
|
-
setSelectionMode(true);
|
|
99
|
-
}
|
|
100
|
-
break;
|
|
101
|
-
case 'Next':
|
|
102
|
-
next(activeOption);
|
|
103
|
-
if (!isInSelectionMode) {
|
|
104
|
-
setSelectionMode(true);
|
|
105
|
-
}
|
|
106
|
-
break;
|
|
107
|
-
case 'Previous':
|
|
108
|
-
// when active option is the first option and the action was "Previous",
|
|
109
|
-
// this means we were in the first option and we are "leaving" the listbox
|
|
110
|
-
if (activeOption && activeOption.id !== firstOption) {
|
|
111
|
-
previous(activeOption);
|
|
112
|
-
if (!isInSelectionMode) {
|
|
113
|
-
setSelectionMode(true);
|
|
114
|
-
}
|
|
115
|
-
} else {
|
|
116
|
-
blur();
|
|
117
|
-
setSelectionMode(false);
|
|
118
|
-
}
|
|
119
|
-
break;
|
|
120
|
-
case 'PageDown':
|
|
121
|
-
pageDown();
|
|
122
|
-
break;
|
|
123
|
-
case 'PageUp':
|
|
124
|
-
pageUp();
|
|
125
|
-
break;
|
|
126
|
-
case 'CloseSelect':
|
|
127
|
-
if (!multiselect && !(activeOption === null || activeOption === void 0 ? void 0 : activeOption.disabled)) {
|
|
128
|
-
blur();
|
|
129
|
-
setSelectionMode(false);
|
|
130
|
-
}
|
|
131
|
-
// fallthrough
|
|
132
|
-
case 'Select':
|
|
133
|
-
activeOption && selectOption(e, activeOption);
|
|
134
|
-
break;
|
|
135
|
-
case 'Tab':
|
|
136
|
-
!multiselect && activeOption && selectOption(e, activeOption);
|
|
137
|
-
break;
|
|
127
|
+
break;
|
|
128
|
+
case 'PageDown':
|
|
129
|
+
pageDown();
|
|
130
|
+
break;
|
|
131
|
+
case 'PageUp':
|
|
132
|
+
pageUp();
|
|
133
|
+
break;
|
|
134
|
+
case 'CloseSelect':
|
|
135
|
+
if (!multiselect && !(activeOption === null || activeOption === void 0 ? void 0 : activeOption.disabled)) {
|
|
136
|
+
blur();
|
|
137
|
+
setSelectionMode(false);
|
|
138
138
|
}
|
|
139
|
-
|
|
139
|
+
// fallthrough
|
|
140
|
+
case 'Select':
|
|
141
|
+
activeOption && selectOption(e, activeOption);
|
|
142
|
+
break;
|
|
143
|
+
case 'Tab':
|
|
144
|
+
!multiselect && activeOption && selectOption(e, activeOption);
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
147
|
+
});
|
|
140
148
|
}
|
|
149
|
+
//# sourceMappingURL=useTriggerKeyDown.js.map
|
package/lib/index.js
CHANGED
|
@@ -3,3 +3,4 @@ export { usePromptListboxFunctionality } from './components/utils/usePromptListb
|
|
|
3
3
|
export { usePromptListboxFunctionality as usePromptListboxFunctionalityDeprecated } from './components/utils/usePromptListboxFunctionality';
|
|
4
4
|
export { PromptOption, promptOptionClassNames, renderPromptOption_unstable, usePromptOptionStyles_unstable, usePromptOption_unstable } from './PromptOption';
|
|
5
5
|
export { Option, optionClassNames, renderOption_unstable, useOption_unstable, useInputListboxOptionStyles_unstable } from '@fluentui-copilot/react-input-listbox';
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1,43 +1,43 @@
|
|
|
1
1
|
import { $isSentinelNode } from '@fluentui-copilot/chat-input-plugins';
|
|
2
2
|
import { SELECTION_CHANGE_COMMAND, $getSelection, useLexicalComposerContext, $isRangeSelection, $isElementNode, COMMAND_PRIORITY_HIGH } from '@fluentui-copilot/react-text-editor';
|
|
3
3
|
import * as React from 'react';
|
|
4
|
-
export const CursorPositionPlugin = ({
|
|
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
|
-
return null;
|
|
4
|
+
export const CursorPositionPlugin = ({
|
|
5
|
+
setCursorPosition
|
|
6
|
+
}) => {
|
|
7
|
+
const [editor] = useLexicalComposerContext();
|
|
8
|
+
React.useEffect(() => {
|
|
9
|
+
const $selectionChangeHandler = () => {
|
|
10
|
+
const selection = $getSelection();
|
|
11
|
+
// If selection is null, the cursor is not active in the editor and we should just noop
|
|
12
|
+
if (selection === null || !$isRangeSelection(selection) || !selection.isCollapsed()) {
|
|
13
|
+
setCursorPosition('between-text');
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
// Should only be one node in the selection because the selection is collapsed
|
|
17
|
+
const selectedNode = selection.getNodes().at(0);
|
|
18
|
+
// If there's no selected node, focus isn't in the editor
|
|
19
|
+
if (!selectedNode) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
// If there are no leaf nodes, the paragraph node will be selected
|
|
23
|
+
if ($isElementNode(selectedNode)) {
|
|
24
|
+
setCursorPosition('start-end');
|
|
25
|
+
return false;
|
|
26
|
+
} else if ($isSentinelNode(selectedNode) && !selectedNode.getNextSibling()) {
|
|
27
|
+
setCursorPosition('end');
|
|
28
|
+
return false;
|
|
29
|
+
} else if ($isSentinelNode(selectedNode.getNextSibling()) && selection.focus.offset === selectedNode.getTextContentSize()) {
|
|
30
|
+
setCursorPosition('end');
|
|
31
|
+
return false;
|
|
32
|
+
} else if (selectedNode.getPreviousSibling() === null && selection.focus.offset === 0) {
|
|
33
|
+
setCursorPosition('start');
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
setCursorPosition('between-text');
|
|
37
|
+
return false;
|
|
38
|
+
};
|
|
39
|
+
return editor.registerCommand(SELECTION_CHANGE_COMMAND, $selectionChangeHandler, COMMAND_PRIORITY_HIGH);
|
|
40
|
+
}, [editor, setCursorPosition]);
|
|
41
|
+
return null;
|
|
43
42
|
};
|
|
43
|
+
//# sourceMappingURL=CursorPositionPlugin.js.map
|
|
@@ -20,4 +20,4 @@ const PromptListbox = /*#__PURE__*/ _react.forwardRef((props, ref)=>{
|
|
|
20
20
|
(0, _usePromptListboxStylesstyles.usePromptListboxStyles_unstable)(state);
|
|
21
21
|
return (0, _renderPromptListbox.renderPromptListbox_unstable)(state, contextValues);
|
|
22
22
|
});
|
|
23
|
-
PromptListbox.displayName = 'PromptListbox';
|
|
23
|
+
PromptListbox.displayName = 'PromptListbox'; //# sourceMappingURL=PromptListbox.js.map
|
|
@@ -1 +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/**@deprecated - use InputListbox instead */\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":["
|
|
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/**@deprecated - use InputListbox instead */\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":["state","usePromptListbox_unstable","props","ref","contextValues","usePromptListboxContextValues","usePromptListboxStyles_unstable","renderPromptListbox_unstable","PromptListbox"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAUQA;;;eAAAA;;;;iEAVe;kCACmB;qCACG;8CACG;+CACF;AAM5C,MAAMA,gBAAQC,WAAAA,GAAAA,OAA0BC,UAAOC,CAAAA,CAAAA,OAAAA;UAC/CH,QAAMI,IAAAA,2CAAgBC,EAAAA,OAAAA;UAEtBC,gBAAAA,IAAAA,4DAAgCN,EAAAA;qEACzBO,EAAAA;IACT,OAAGA,IAAAA,iDAAA,EAAAP,OAAAI;AAEHI"}
|
|
@@ -29,3 +29,4 @@ const _PromptListbox = require("./PromptListbox");
|
|
|
29
29
|
const _renderPromptListbox = require("./renderPromptListbox");
|
|
30
30
|
const _usePromptListbox = require("./usePromptListbox");
|
|
31
31
|
const _usePromptListboxStylesstyles = require("./usePromptListboxStyles.styles");
|
|
32
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["renderPromptListbox.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\n\nimport { assertSlots, ListboxProvider, Portal } from '@fluentui/react-components';\nimport { ActiveDescendantContextProvider } from '@fluentui/react-aria';\nimport type { PromptListboxState, PromptListboxSlots, PromptListboxContextValues } from './PromptListbox.types';\n\n/**\n * Render the final JSX of PromptListbox\n */\nexport const renderPromptListbox_unstable = (state: PromptListboxState, contextValues: PromptListboxContextValues) => {\n assertSlots<PromptListboxSlots>(state);\n const { open } = state;\n\n return (\n <ListboxProvider value={contextValues.listbox}>\n <ActiveDescendantContextProvider value={contextValues.activeDescendant}>\n <span aria-owns={open ? state.root.id : undefined}>\n {open &&\n (state.inlinePopup ? (\n <state.root />\n ) : (\n <Portal mountNode={state.mountNode}>\n <state.root />\n </Portal>\n ))}\n </span>\n </ActiveDescendantContextProvider>\n </ListboxProvider>\n );\n};\n"],"names":["
|
|
1
|
+
{"version":3,"sources":["renderPromptListbox.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\n\nimport { assertSlots, ListboxProvider, Portal } from '@fluentui/react-components';\nimport { ActiveDescendantContextProvider } from '@fluentui/react-aria';\nimport type { PromptListboxState, PromptListboxSlots, PromptListboxContextValues } from './PromptListbox.types';\n\n/**\n * Render the final JSX of PromptListbox\n */\nexport const renderPromptListbox_unstable = (state: PromptListboxState, contextValues: PromptListboxContextValues) => {\n assertSlots<PromptListboxSlots>(state);\n const { open } = state;\n\n return (\n <ListboxProvider value={contextValues.listbox}>\n <ActiveDescendantContextProvider value={contextValues.activeDescendant}>\n <span aria-owns={open ? state.root.id : undefined}>\n {open &&\n (state.inlinePopup ? (\n <state.root />\n ) : (\n <Portal mountNode={state.mountNode}>\n <state.root />\n </Portal>\n ))}\n </span>\n </ActiveDescendantContextProvider>\n </ListboxProvider>\n );\n};\n"],"names":["assertSlots","state","open","value","contextValues","activeDescendant","listbox","aria-owns","undefined","inlinePopup","mountNode","root","id","_jsx","Portal"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAWEA;;;eAAAA;;;4BAXwB;iCAG2B;2BACL;AAO9CA,MAAAA,+BAAgCC,CAAAA,OAAAA;oCACxBC,EAAAA;UAER,MACmBC;sBACyBC,GAAAA,IAAAA,eAAAA,EAAAA,gCAAcC,EAAAA;6BACpDC,OAAA;6BAAMC,GAAAA,IAAAA,eAAWL,EAAAA,0CAAuBM,EAAAA;iCACrCN,gBACQO;iCAGGC,GAAAA,IAAAA,eAAWT,EAAAA,QAAMS;0CACvBC,IAAA,CAAAC,EAAA,GAAAJ;0BAEJN,QAAAD,CAAAA,MAAAQ,WAAA,GAAA,WAAA,GAAAI,IAAAA,eAAA,EAAAZ,MAAAU,IAAA,EAAA,CAAA,KAAA,WAAA,GAAAE,IAAAA,eAAA,EAAAC,uBAAA,EAAA;;;;YAKV"}
|
|
@@ -1 +1 @@
|
|
|
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":["
|
|
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":["id","inlinePopup","previousOption","nextOption","onActiveOptionChange","event","selectOption","registerOption","open","getOptionById","getOptionsMatchingValue","selectedOptions","onActiveDescendantChange","root","elementType","Listbox","state","ref","useMergedRefs","onClick","preventDefault","tabIndex","role","noop","deprecatedPropsDefaults","activeOption","setActiveOption","onOptionClick"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAuBIA;;;eAAAA;;;iCAtByC;gCACW;AAoBtD,MACEA,4BAEAC,CAAAA,OAAAA;UAUF,EAEAD,EAAA,sBACQE,gBACAC,KAAAA,cACNC,SAAAA,aAAgCC,4BAAa,eAAUH,yBAAgBC,iBAAW,EACpFG,YAAA,EAEAC,cAAkC;UAEhCC,YAAAA,IAAAA,qBAAAA,EAAAA,kBAAAA;UACAC,2BAAAA,IAAAA,gCAAAA,EAAAA,CAAAA;cACAC,iBAAAA,MAAAA,MAAAA,CAAAA,UAAAA,GAAAA,cAAAA,MAAAA,MAAAA,CAAAA,UAAAA,IAAAA;cACAC,aAAAA,cAAAA,MAAAA,MAAAA,CAAAA,EAAAA;iCACAL,QAAAA,yBAAAA,KAAAA,IAAAA,KAAAA,IAAAA,qBAAAA,OAAAA;;kBAEAM;;;;;kBAMEC;kCACF;;;;;;;;;;;oBAWIC;kBACFC,wBAAA;QAEJ;QAEAC,MAAMH,qBAAI,CAACI,MAAMC,CAAAA;YACjBF,GAAAA,KAAU;;QAGR,GAAGA;YAGLA,cAAWG;gBAEPd,kBAAMe;gBACLJ,IAAAA;gBAGLK,UAAOL;gBACPM,MAAA;YAEIC;YAEAC,aAAAA,wBAAAA;QAIJC;;UAEAC,IAAAA,CAAAA,GAAAA,GAAAA,IAAAA,8BAAiBH,EAAAA,KAAAA,MAAAA,IAAAA,CAAAA,GAAAA;UACjBI,IAAAA,CAAAA,WAAeJ,GAAAA,IAAAA,gCAAAA,EAAAA,IAAAA,8BAAAA,EAAAA,CAAAA;QACjBlB,MAAAe,cAAA"}
|
|
@@ -1 +1 @@
|
|
|
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":["usePromptListboxContextValues","state","getOptionById","
|
|
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":["usePromptListboxContextValues","state","getOptionById","activeDescendant","activeDescendantController","activeOption","getOptionsMatchingValue","registerOption","selectedOptions","selectOption","setActiveOption","onOptionClick"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAOgBA;;;eAAAA;;;;iEAPO;AAOhB,SAASA,8BAA8BC,KAAgC;UAC5E,EAWAC,aAAMC,yBAEUC,gBAEd,iBAACA,cAA2B,EAG9BA,0BAAgB,eACdC,0BACc;UAEdC,mBAAAA,OAAAA,OAAAA,CAAAA,IAAAA,CAAAA;wBACAC;;;KACAC;UACAC,UAAAA;sBACAC;sBACAC;;QAEFL;QAEAC;;;QAGAG,iBAAA,IAAA;QACFC"}
|
|
@@ -44,4 +44,4 @@ const usePromptListboxStyles_unstable = (state)=>{
|
|
|
44
44
|
const styles = useStyles();
|
|
45
45
|
state.root.className = (0, _reactcomponents.mergeClasses)(promptListboxClassNames.root, styles.listbox, state.inlinePopup && styles.inlineListbox, !state.open && styles.listboxCollapsed, state.root.className);
|
|
46
46
|
return state;
|
|
47
|
-
};
|
|
47
|
+
}; //# sourceMappingURL=usePromptListboxStyles.styles.raw.js.map
|
|
@@ -1 +1 @@
|
|
|
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":["promptListboxClassNames","
|
|
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":["promptListboxClassNames","styles","useStyles","root","listbox","makeStyles","boxShadow","borderRadius","tokens","borderRadiusMedium","maxHeight","boxSizing","display","zIndex"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;;;;;;;;IAKaA,uBAAAA;eAAAA;;IAgCLC,+BAASC;eAATD;;;iCArCiC;wBAClB;AAIhB,MAAMD,0BAA8D;UACzEG;AACF;AAEA;;CAEC,SAECC,YAASC,IAAAA,2BAAA,EAAA;aACPC;mBACAC,cAAAA,CAAcC,QAAOC;sBACrBC,cAAW,CAAAD,kBAAA;mBACXE;QACFA,WAAA;;sBAGW;QACXC,SAAA;;mHAG0G;8GAC3F;mBACL;QACVC,QAAA;IACF;AAEA;AAME,MAAMZ,kCAASC,CAAAA;;IAUf,MAAAD,SAAAC"}
|
|
@@ -18,4 +18,4 @@ const PromptOption = /*#__PURE__*/ _react.forwardRef((props, ref)=>{
|
|
|
18
18
|
(0, _usePromptOptionStylesstyles.usePromptOptionStyles_unstable)(state);
|
|
19
19
|
return (0, _renderPromptOption.renderPromptOption_unstable)(state);
|
|
20
20
|
});
|
|
21
|
-
PromptOption.displayName = 'PromptOption';
|
|
21
|
+
PromptOption.displayName = 'PromptOption'; //# sourceMappingURL=PromptOption.js.map
|
|
@@ -1 +1 @@
|
|
|
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":["
|
|
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":["state","usePromptOption_unstable","props","ref","usePromptOptionStyles_unstable","renderPromptOption_unstable","PromptOption"],"rangeMappings":";;;;;;;;;;;;;;;;;;;","mappings":";;;;+BASQA;;;eAAAA;;;;iEATe;iCACkB;oCACG;6CACG;AAM7C,MAAMA,eAAQC,WAAAA,GAAAA,OAAyBC,UAAOC,CAAAA,CAAAA,OAAAA;UAE9CC,QAAAA,IAAAA,yCAA+BJ,EAAAA,OAAAA;mEACxBK,EAAAA;IACT,OAAGA,IAAAA,+CAAA,EAAAL;AAEHM"}
|
|
@@ -29,3 +29,4 @@ const _PromptOption = require("./PromptOption");
|
|
|
29
29
|
const _renderPromptOption = require("./renderPromptOption");
|
|
30
30
|
const _usePromptOption = require("./usePromptOption");
|
|
31
31
|
const _usePromptOptionStylesstyles = require("./usePromptOptionStyles.styles");
|
|
32
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -13,4 +13,4 @@ const _reactcomponents = require("@fluentui/react-components");
|
|
|
13
13
|
const renderPromptOption_unstable = (state)=>{
|
|
14
14
|
(0, _reactcomponents.assertSlots)(state);
|
|
15
15
|
return /*#__PURE__*/ (0, _jsxruntime.jsx)(state.root, {});
|
|
16
|
-
};
|
|
16
|
+
}; //# sourceMappingURL=renderPromptOption.js.map
|
|
@@ -1 +1 @@
|
|
|
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":["
|
|
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","state","_jsx","root"],"rangeMappings":";;;;;;;;;;;;;;","mappings":";;;;+BAUEA;;;eAAAA;;;4BAVwB;iCAGE;AAO1BA,MAAAA,8BAA+BC,CAAAA;oCAE/B,EAAAA;IACA,OAAA,WAAA,GAAAC,IAAAA,eAAA,EAAAD,MAAAE,IAAA,EAAA,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
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":["
|
|
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":["controller","activeDescendantController","optionRef","useActiveDescendantContext","getTextString","children","disabled","id","text","value","optionText","optionValue","registerOption","selected","useListboxContext_unstable","selectedOptions","find","ctx","selectOption","onOptionClick","undefined","props","preventDefault","event","optionData","React","onClick","_props_onClick","call","useEffect","current","components","slot","always","getIntrinsicElementProps","root","ref","useMergedRefs","role","textString","hasNonStringChild","child","Children","forEach","warn"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAsBUA;;;eAAAA;;;;iEAtBa;iCAC8C;2BAC1B;+BACA;AAmBzC,MAAQA,2BAAYC,CAAAA,OAAAA;UACpB,EACAD,YAAME,0BAAyC,KAC/CC,IAAAA,qCAAmBC;UACnB,EAEAC,QAAA,EACAC,QAAMC,EAENC,IAAA,EACAC,KAAA;sBACeH,OAAAA,MAAAA,CAAAA;uBAAgBI,cAAAA,MAAAA;wBAAmBC,UAAAA,QAAAA,UAAAA,KAAAA,IAAAA,QAAAA;2DAChD;UAACJ,KAAAA,IAAAA,sBAAAA,EAAAA,iBAAAA,MAAAA,EAAAA;kDAAID;UAAUI,aAAAA,OAAAA,OAAAA,CAAAA,IAAAA,CAAAA;;;YAGjBF,MAAAE;YACAD,OAAMG;YACN;QAAAL;QAAMM;QAAWC;QAAAA;KAAAA;qBACTC;UAENH,iBAAOD,IAAAA,yCAA6BI,EAAAA,CAAAA,MAAAA,IAAgBC,cAAgBL;UACtEE,WAAAC,IAAAA,yCAAA,EAAAG,CAAAA;QACA,MAAMC,kBAAeJ,IAAAA,eAAAA;QACrB,OAAMK,gBAAgBL,aAAAA,gBAA2BG,IAAOA,CAAAA,CAAAA,IAAIE,MAAAA,iBAAaC;;yBAcvEC,IAAAA,yCAAAA,EAAAA,CAAAA,MAAAA,IAAAA,YAAAA;UAXAF,gBAAcL,IAAAA,yCAAA,EAAAG,CAAAA,MAAAA,IAAAE,aAAA;oBACNG,CAAAA;;YAERhB,UAAA;kBAEAL,cAAAA;;;mCAKcsB,KAAAA,CAAAA;kCACdF;QACFH,aAAAK,OAAAC;QAEAL,cAAAI;QACAE,CAAAA,iBAAgBJ,MAAAK,OAAA,MAAA,QAAAC,mBAAA,KAAA,IAAA,KAAA,IAAAA,eAAAC,IAAA,CAAAP,OAAAE;;wCAEUC;WACxBK,SAAA,CAAA;QACF,IAAGtB,MAAAL,UAAA4B,OAAA,EAAA;mBAACvB,eAAAA,YAAAA,UAAAA,OAAAA;;;;QAAgBK;QAAAA;KAAAA;WAAe;QAEnCmB,YAAO;kBACLA;;cAEAC,qBAAA,CAAAC,MAAA,CAAAC,IAAAA,yCAAA,EAAA,OAAA;iBACAC,IAAAA,8BAAWF,EAAMG,KACfF;6BACOG,WAAcD,OAAKlC;;kBAExBK;oBACA+B;;;yBAIF;;;;;;AAKN,SAAElC,cAAAI,IAAA,EAAAH,QAAA;IAEF,IAAAG,SAASJ,WAAcI;QACrB,OAAIA;;QAEJ+B,aAAA;QAEAC,oBAAiB;WACbA,QAAAA,CAAAA,OAAAA,CAAAA,UAAoBC,CAAAA;QACxBhB,IAAAA,OAAMiB,UAASC,UAAQtC;0BACVoC;;gCAEJ;;;iEAGT;QAEAD,mBAAA;QACA,sCAAuB;gBACrBI,IAAA,CAAA;;WAEFL;EAGF,2CAAA"}
|