@fluentui-copilot/react-prompt-listbox 0.0.0-nightly-20240719-0406-ee8d99d6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.json +56 -0
- package/CHANGELOG.md +19 -0
- package/LICENSE +23 -0
- package/README.md +5 -0
- package/dist/index.d.ts +230 -0
- package/lib/PromptListbox.js +2 -0
- package/lib/PromptListbox.js.map +1 -0
- package/lib/components/PromptListbox/PromptListbox.js +14 -0
- package/lib/components/PromptListbox/PromptListbox.js.map +1 -0
- package/lib/components/PromptListbox/PromptListbox.types.js +2 -0
- package/lib/components/PromptListbox/PromptListbox.types.js.map +1 -0
- package/lib/components/PromptListbox/index.js +6 -0
- package/lib/components/PromptListbox/index.js.map +1 -0
- package/lib/components/PromptListbox/renderPromptListbox.js +20 -0
- package/lib/components/PromptListbox/renderPromptListbox.js.map +1 -0
- package/lib/components/PromptListbox/usePromptListbox.js +81 -0
- package/lib/components/PromptListbox/usePromptListbox.js.map +1 -0
- package/lib/components/PromptListbox/usePromptListboxContextValues.js +33 -0
- package/lib/components/PromptListbox/usePromptListboxContextValues.js.map +1 -0
- package/lib/components/PromptListbox/usePromptListboxStyles.styles.js +37 -0
- package/lib/components/PromptListbox/usePromptListboxStyles.styles.js.map +1 -0
- package/lib/components/utils/OptionCollection.types.js +3 -0
- package/lib/components/utils/OptionCollection.types.js.map +1 -0
- package/lib/components/utils/PromptListboxFunctionality.types.js +2 -0
- package/lib/components/utils/PromptListboxFunctionality.types.js.map +1 -0
- package/lib/components/utils/Selection.types.js +3 -0
- package/lib/components/utils/Selection.types.js.map +1 -0
- package/lib/components/utils/dropdownKeyActions.js +52 -0
- package/lib/components/utils/dropdownKeyActions.js.map +1 -0
- package/lib/components/utils/useComboboxPositioning.js +25 -0
- package/lib/components/utils/useComboboxPositioning.js.map +1 -0
- package/lib/components/utils/useOptionCollection.js +39 -0
- package/lib/components/utils/useOptionCollection.js.map +1 -0
- package/lib/components/utils/usePromptListboxFunctionality.js +143 -0
- package/lib/components/utils/usePromptListboxFunctionality.js.map +1 -0
- package/lib/components/utils/useSelection.js +54 -0
- package/lib/components/utils/useSelection.js.map +1 -0
- package/lib/components/utils/useTriggerKeyDown.js +129 -0
- package/lib/components/utils/useTriggerKeyDown.js.map +1 -0
- package/lib/index.js +4 -0
- package/lib/index.js.map +1 -0
- package/lib/plugins/TextCursorPositionPlugin.js +44 -0
- package/lib/plugins/TextCursorPositionPlugin.js.map +1 -0
- package/lib-commonjs/PromptListbox.js +7 -0
- package/lib-commonjs/PromptListbox.js.map +1 -0
- package/lib-commonjs/components/PromptListbox/PromptListbox.js +23 -0
- package/lib-commonjs/components/PromptListbox/PromptListbox.js.map +1 -0
- package/lib-commonjs/components/PromptListbox/PromptListbox.types.js +5 -0
- package/lib-commonjs/components/PromptListbox/PromptListbox.types.js.map +1 -0
- package/lib-commonjs/components/PromptListbox/index.js +11 -0
- package/lib-commonjs/components/PromptListbox/index.js.map +1 -0
- package/lib-commonjs/components/PromptListbox/renderPromptListbox.js +26 -0
- package/lib-commonjs/components/PromptListbox/renderPromptListbox.js.map +1 -0
- package/lib-commonjs/components/PromptListbox/usePromptListbox.js +68 -0
- package/lib-commonjs/components/PromptListbox/usePromptListbox.js.map +1 -0
- package/lib-commonjs/components/PromptListbox/usePromptListboxContextValues.js +36 -0
- package/lib-commonjs/components/PromptListbox/usePromptListboxContextValues.js.map +1 -0
- package/lib-commonjs/components/PromptListbox/usePromptListboxStyles.styles.js +71 -0
- package/lib-commonjs/components/PromptListbox/usePromptListboxStyles.styles.js.map +1 -0
- package/lib-commonjs/components/utils/OptionCollection.types.js +6 -0
- package/lib-commonjs/components/utils/OptionCollection.types.js.map +1 -0
- package/lib-commonjs/components/utils/PromptListboxFunctionality.types.js +5 -0
- package/lib-commonjs/components/utils/PromptListboxFunctionality.types.js.map +1 -0
- package/lib-commonjs/components/utils/Selection.types.js +6 -0
- package/lib-commonjs/components/utils/Selection.types.js.map +1 -0
- package/lib-commonjs/components/utils/dropdownKeyActions.js +52 -0
- package/lib-commonjs/components/utils/dropdownKeyActions.js.map +1 -0
- package/lib-commonjs/components/utils/useComboboxPositioning.js +32 -0
- package/lib-commonjs/components/utils/useComboboxPositioning.js.map +1 -0
- package/lib-commonjs/components/utils/useOptionCollection.js +46 -0
- package/lib-commonjs/components/utils/useOptionCollection.js.map +1 -0
- package/lib-commonjs/components/utils/usePromptListboxFunctionality.js +150 -0
- package/lib-commonjs/components/utils/usePromptListboxFunctionality.js.map +1 -0
- package/lib-commonjs/components/utils/useSelection.js +72 -0
- package/lib-commonjs/components/utils/useSelection.js.map +1 -0
- package/lib-commonjs/components/utils/useTriggerKeyDown.js +134 -0
- package/lib-commonjs/components/utils/useTriggerKeyDown.js.map +1 -0
- package/lib-commonjs/index.js +37 -0
- package/lib-commonjs/index.js.map +1 -0
- package/lib-commonjs/plugins/TextCursorPositionPlugin.js +52 -0
- package/lib-commonjs/plugins/TextCursorPositionPlugin.js.map +1 -0
- package/package.json +49 -0
package/CHANGELOG.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@fluentui-copilot/react-prompt-listbox",
|
|
3
|
+
"entries": [
|
|
4
|
+
{
|
|
5
|
+
"date": "Fri, 19 Jul 2024 04:13:27 GMT",
|
|
6
|
+
"tag": "@fluentui-copilot/react-prompt-listbox_v0.0.0-nightly-20240719-0406-ee8d99d6.1",
|
|
7
|
+
"version": "0.0.0-nightly-20240719-0406-ee8d99d6.1",
|
|
8
|
+
"comments": {
|
|
9
|
+
"prerelease": [
|
|
10
|
+
{
|
|
11
|
+
"author": "fluentui-internal@service.microsoft.com",
|
|
12
|
+
"package": "@fluentui-copilot/react-prompt-listbox",
|
|
13
|
+
"commit": "not available",
|
|
14
|
+
"comment": "Release nightly"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"author": "beachball",
|
|
18
|
+
"package": "@fluentui-copilot/react-prompt-listbox",
|
|
19
|
+
"comment": "Bump @fluentui-copilot/chat-input-plugins to v0.0.0-nightly-20240719-0406-ee8d99d6.1",
|
|
20
|
+
"commit": "e568e817e90915ee691011151b826dc43e4c0778"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"author": "beachball",
|
|
24
|
+
"package": "@fluentui-copilot/react-prompt-listbox",
|
|
25
|
+
"comment": "Bump @fluentui-copilot/react-chat-input-plugins to v0.0.0-nightly-20240719-0406-ee8d99d6.1",
|
|
26
|
+
"commit": "e568e817e90915ee691011151b826dc43e4c0778"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"author": "beachball",
|
|
30
|
+
"package": "@fluentui-copilot/react-prompt-listbox",
|
|
31
|
+
"comment": "Bump @fluentui-copilot/react-editor-input to v0.0.0-nightly-20240719-0406-ee8d99d6.1",
|
|
32
|
+
"commit": "e568e817e90915ee691011151b826dc43e4c0778"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"author": "beachball",
|
|
36
|
+
"package": "@fluentui-copilot/react-prompt-listbox",
|
|
37
|
+
"comment": "Bump @fluentui-copilot/react-provider to v0.0.0-nightly-20240719-0406-ee8d99d6.1",
|
|
38
|
+
"commit": "e568e817e90915ee691011151b826dc43e4c0778"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"author": "beachball",
|
|
42
|
+
"package": "@fluentui-copilot/react-prompt-listbox",
|
|
43
|
+
"comment": "Bump @fluentui-copilot/react-text-editor to v0.0.0-nightly-20240719-0406-ee8d99d6.1",
|
|
44
|
+
"commit": "e568e817e90915ee691011151b826dc43e4c0778"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"author": "beachball",
|
|
48
|
+
"package": "@fluentui-copilot/react-prompt-listbox",
|
|
49
|
+
"comment": "Bump @fluentui-copilot/text-editor to v0.0.0-nightly-20240719-0406-ee8d99d6.1",
|
|
50
|
+
"commit": "e568e817e90915ee691011151b826dc43e4c0778"
|
|
51
|
+
}
|
|
52
|
+
]
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
]
|
|
56
|
+
}
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Change Log - @fluentui-copilot/react-prompt-listbox
|
|
2
|
+
|
|
3
|
+
This log was last generated on Fri, 19 Jul 2024 04:13:27 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
<!-- Start content -->
|
|
6
|
+
|
|
7
|
+
## [0.0.0-nightly-20240719-0406-ee8d99d6.1](https://github.com/microsoft/fluentai/tree/@fluentui-copilot/react-prompt-listbox_v0.0.0-nightly-20240719-0406-ee8d99d6.1)
|
|
8
|
+
|
|
9
|
+
Fri, 19 Jul 2024 04:13:27 GMT
|
|
10
|
+
|
|
11
|
+
### Changes
|
|
12
|
+
|
|
13
|
+
- Release nightly ([commit](https://github.com/microsoft/fluentai/commit/not available) by fluentui-internal@service.microsoft.com)
|
|
14
|
+
- Bump @fluentui-copilot/chat-input-plugins to v0.0.0-nightly-20240719-0406-ee8d99d6.1 ([commit](https://github.com/microsoft/fluentai/commit/e568e817e90915ee691011151b826dc43e4c0778) by beachball)
|
|
15
|
+
- Bump @fluentui-copilot/react-chat-input-plugins to v0.0.0-nightly-20240719-0406-ee8d99d6.1 ([commit](https://github.com/microsoft/fluentai/commit/e568e817e90915ee691011151b826dc43e4c0778) by beachball)
|
|
16
|
+
- Bump @fluentui-copilot/react-editor-input to v0.0.0-nightly-20240719-0406-ee8d99d6.1 ([commit](https://github.com/microsoft/fluentai/commit/e568e817e90915ee691011151b826dc43e4c0778) by beachball)
|
|
17
|
+
- Bump @fluentui-copilot/react-provider to v0.0.0-nightly-20240719-0406-ee8d99d6.1 ([commit](https://github.com/microsoft/fluentai/commit/e568e817e90915ee691011151b826dc43e4c0778) by beachball)
|
|
18
|
+
- Bump @fluentui-copilot/react-text-editor to v0.0.0-nightly-20240719-0406-ee8d99d6.1 ([commit](https://github.com/microsoft/fluentai/commit/e568e817e90915ee691011151b826dc43e4c0778) by beachball)
|
|
19
|
+
- Bump @fluentui-copilot/text-editor to v0.0.0-nightly-20240719-0406-ee8d99d6.1 ([commit](https://github.com/microsoft/fluentai/commit/e568e817e90915ee691011151b826dc43e4c0778) by beachball)
|
package/LICENSE
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
@fluentui-copilot/react-prompt-listbox
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Copyright (c) Microsoft Corporation.
|
|
6
|
+
|
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
in the Software without restriction, including without limitation the rights
|
|
10
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
furnished to do so, subject to the following conditions:
|
|
13
|
+
|
|
14
|
+
The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
SOFTWARE
|
package/README.md
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
|
|
3
|
+
import type { ActiveDescendantContextValue } from '@fluentui/react-aria';
|
|
4
|
+
import type { ComboboxBaseState } from '@fluentui/react-combobox';
|
|
5
|
+
import type { ComboboxProps } from '@fluentui/react-components';
|
|
6
|
+
import type { ComboboxState } from '@fluentui/react-combobox';
|
|
7
|
+
import type { ComponentProps } from '@fluentui/react-components';
|
|
8
|
+
import type { ComponentState } from '@fluentui/react-components';
|
|
9
|
+
import type { EventData } from '@fluentui/react-utilities';
|
|
10
|
+
import type { EventHandler } from '@fluentui/react-utilities';
|
|
11
|
+
import type { ForwardRefComponent } from '@fluentui/react-components';
|
|
12
|
+
import { InitialConfigType } from '@lexical/react/LexicalComposer';
|
|
13
|
+
import type { Listbox } from '@fluentui/react-components';
|
|
14
|
+
import type { ListboxContextValue } from '@fluentui/react-combobox';
|
|
15
|
+
import type { ListboxContextValue as ListboxContextValue_2 } from '@fluentui/react-components';
|
|
16
|
+
import { PlainTextPlugin } from '@lexical/react/LexicalPlainTextPlugin';
|
|
17
|
+
import type { PortalProps } from '@fluentui/react-components';
|
|
18
|
+
import type { PositioningShorthand } from '@fluentui/react-components';
|
|
19
|
+
import * as React_2 from 'react';
|
|
20
|
+
import type { default as React_3 } from 'react';
|
|
21
|
+
import type { Slot } from '@fluentui/react-components';
|
|
22
|
+
import type { SlotClassNames } from '@fluentui/react-components';
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* EditorInput Props
|
|
26
|
+
*/
|
|
27
|
+
declare type EditorInputProps = Omit<ComponentProps<Partial<EditorInputSlots>, 'input'>, 'onChange' | 'onPaste' | 'defaultValue' | 'onSubmit'> & {
|
|
28
|
+
disabled?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* If defaultValue is a string, it will be added to the input on first render.
|
|
31
|
+
* If defaultValue is a function, it can call lexical $ functions to imperatively set the initial content with more complex nodes.
|
|
32
|
+
*/
|
|
33
|
+
defaultValue?: string | (() => void);
|
|
34
|
+
/**
|
|
35
|
+
* Callback for when the user changes the value.
|
|
36
|
+
* TODO: Add proper event type for callback
|
|
37
|
+
*/
|
|
38
|
+
onChange?: (ev: any, data: EditorInputValueData) => void;
|
|
39
|
+
/**
|
|
40
|
+
* Callback for when content is pasted into the Editor.
|
|
41
|
+
*/
|
|
42
|
+
onPaste?: (ev: ClipboardEvent) => void;
|
|
43
|
+
/**
|
|
44
|
+
* When true, the input will be cleared when only whitespace is remaining.
|
|
45
|
+
* @default false
|
|
46
|
+
*/
|
|
47
|
+
trimWhiteSpace?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Used to register any custom nodes used by plugins added. Can also be used to override the default nodes.
|
|
50
|
+
*/
|
|
51
|
+
customNodes?: InitialConfigType['nodes'];
|
|
52
|
+
/**
|
|
53
|
+
* The plugin which is in charge of initializing Lexical and is given the `input` and `placeholder` slots
|
|
54
|
+
* @default LexicalPlainTextPlugin
|
|
55
|
+
*/
|
|
56
|
+
textPlugin?: typeof PlainTextPlugin;
|
|
57
|
+
/**
|
|
58
|
+
* Controls whether history is tracked to provide undo and redo functionality
|
|
59
|
+
* @default true
|
|
60
|
+
*/
|
|
61
|
+
history?: boolean;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
declare type EditorInputSlots = {
|
|
65
|
+
root: NonNullable<Slot<'span'>>;
|
|
66
|
+
input: NonNullable<Slot<'span'>>;
|
|
67
|
+
placeholderValue?: Slot<'span'>;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Data passed to the `onChange` callback when the chat input's value changes.
|
|
72
|
+
*/
|
|
73
|
+
declare type EditorInputValueData = {
|
|
74
|
+
value: string;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export declare type OnOpenChangeData = (EventData<'click', React_3.MouseEvent<HTMLSpanElement>> | EventData<'focus', React_3.FocusEvent<HTMLSpanElement>> | EventData<'keyboard', React_3.KeyboardEvent<HTMLSpanElement>>) & {
|
|
78
|
+
open: boolean;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
declare type OptionCollectionState = {
|
|
82
|
+
/** The total number of options in the collection. */
|
|
83
|
+
getCount: () => number;
|
|
84
|
+
/** Returns the option data by key. */
|
|
85
|
+
getOptionById(id: string): OptionValue | undefined;
|
|
86
|
+
/** Returns an array of options filtered by a value matching function against the option's value string. */
|
|
87
|
+
getOptionsMatchingValue(matcher: (value: string) => boolean): OptionValue[];
|
|
88
|
+
/** The unordered option data. */
|
|
89
|
+
options: OptionValue[];
|
|
90
|
+
/** A function that child options call to register their values. Returns a function to unregister the option. */
|
|
91
|
+
registerOption: (option: OptionValue, element: HTMLElement) => () => void;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
declare type OptionValue = {
|
|
95
|
+
/** The disabled state of the option. */
|
|
96
|
+
disabled?: boolean;
|
|
97
|
+
/** The `id` attribute of the option. */
|
|
98
|
+
id: string;
|
|
99
|
+
/** The `text` string for the option. */
|
|
100
|
+
text: string;
|
|
101
|
+
/** The value string of the option. */
|
|
102
|
+
value: string;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
export declare type ProcessedPromptListboxProps = Partial<Omit<PromptListboxProps, 'activeDescendantController' | 'multiselect'>> & {
|
|
106
|
+
ref?: React_3.MutableRefObject<any>;
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
export declare const PromptListbox: ForwardRefComponent<PromptListboxProps>;
|
|
110
|
+
|
|
111
|
+
export declare const promptListboxClassNames: SlotClassNames<PromptListboxSlots>;
|
|
112
|
+
|
|
113
|
+
declare type PromptListboxContextState = Pick<ComboboxBaseState, keyof ListboxContextValue> & Pick<ComboboxState, 'activeDescendantController'>;
|
|
114
|
+
|
|
115
|
+
declare type PromptListboxContextValues = {
|
|
116
|
+
listbox: ListboxContextValue_2;
|
|
117
|
+
activeDescendant: ActiveDescendantContextValue;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* PromptListbox Props
|
|
122
|
+
*/
|
|
123
|
+
export declare type PromptListboxProps = ComponentProps<PromptListboxSlots> & Pick<PortalProps, 'mountNode'> & OptionCollectionState & SelectionState & Pick<PromptListboxContextState, 'activeDescendantController'> & Pick<ComboboxProps, 'onActiveOptionChange'> & {
|
|
124
|
+
/**
|
|
125
|
+
* Whether to listbox should be rendered.
|
|
126
|
+
*
|
|
127
|
+
* @default false
|
|
128
|
+
*/
|
|
129
|
+
open?: boolean;
|
|
130
|
+
/**
|
|
131
|
+
* Whether to render the listbox inline or in a portal.
|
|
132
|
+
*
|
|
133
|
+
* @default false
|
|
134
|
+
*/
|
|
135
|
+
inlinePopup?: boolean;
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
export declare type PromptListboxSlots = {
|
|
139
|
+
root: Slot<typeof Listbox>;
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* State used in rendering PromptListbox
|
|
144
|
+
*/
|
|
145
|
+
export declare type PromptListboxState = ComponentState<PromptListboxSlots> & PromptListboxContextState & Required<Pick<PromptListboxProps, 'open' | 'inlinePopup'>> & Pick<PromptListboxProps, 'mountNode'>;
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Render the final JSX of PromptListbox
|
|
149
|
+
*/
|
|
150
|
+
export declare const renderPromptListbox_unstable: (state: PromptListboxState, contextValues: PromptListboxContextValues) => JSX.Element;
|
|
151
|
+
|
|
152
|
+
/** Possible event types for onOptionSelect */
|
|
153
|
+
declare type SelectionEvents = React_2.ChangeEvent<HTMLElement> | React_2.KeyboardEvent<HTMLElement> | React_2.MouseEvent<HTMLElement>;
|
|
154
|
+
|
|
155
|
+
/** Values returned by the useSelection hook */
|
|
156
|
+
declare type SelectionState = {
|
|
157
|
+
clearSelection: (event: SelectionEvents) => void;
|
|
158
|
+
selectedOptions: string[];
|
|
159
|
+
selectOption: (event: SelectionEvents, option: OptionValue) => void;
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
export declare const TextCursorPositionPlugin: React_2.FunctionComponent<TextCursorPositionPluginProps>;
|
|
163
|
+
|
|
164
|
+
export declare type TextCursorPositionPluginProps = {
|
|
165
|
+
setIsInLastPosition: (isInLastPosition: boolean) => void;
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Create the state required to render PromptListbox.
|
|
170
|
+
*
|
|
171
|
+
* The returned state can be modified with hooks such as usePromptListboxStyles_unstable,
|
|
172
|
+
* before being passed to renderPromptListbox_unstable.
|
|
173
|
+
*
|
|
174
|
+
* @param props - props from this instance of PromptListbox
|
|
175
|
+
* @param ref - reference to root HTMLElement of PromptListbox
|
|
176
|
+
*/
|
|
177
|
+
export declare const usePromptListbox_unstable: (props: PromptListboxProps, ref: React_2.Ref<HTMLDivElement>) => PromptListboxState;
|
|
178
|
+
|
|
179
|
+
export declare type UsePromptListboxFunctionality = {
|
|
180
|
+
/**
|
|
181
|
+
* Component to be rendered in the Input component. This should be passed to the listbox prop.
|
|
182
|
+
*/
|
|
183
|
+
promptListbox: JSX.Element;
|
|
184
|
+
/**
|
|
185
|
+
* Props to be spread in the PromptInput, these props are needed for the keyboard behavior to
|
|
186
|
+
* work correctly.
|
|
187
|
+
*/
|
|
188
|
+
triggerProps: {
|
|
189
|
+
ref: React_3.RefObject<HTMLSpanElement>;
|
|
190
|
+
/**
|
|
191
|
+
* Whether the listbox is being used to go through options or the user is currently typing.
|
|
192
|
+
*/
|
|
193
|
+
isInSelectionMode: boolean;
|
|
194
|
+
} & Required<Pick<EditorInputProps, 'onBlur' | 'onFocus' | 'onKeyDown'>>;
|
|
195
|
+
/**
|
|
196
|
+
* Ref used to point which element the listbox should be anchored to. Most use cases
|
|
197
|
+
* will provide this prop to the PromptInput's EditorInput (since this is the root slot,
|
|
198
|
+
* this is provided directly to the component and not the slot).
|
|
199
|
+
*
|
|
200
|
+
* Note: If the targetRef is the same as the trigger, the ref provided in triggerProps needs
|
|
201
|
+
* to be merged with this one using `useMergedRefs(targetRef, triggerProps.ref);`
|
|
202
|
+
*/
|
|
203
|
+
targetRef: React_3.MutableRefObject<any>;
|
|
204
|
+
/**
|
|
205
|
+
* Plugin used to tell where the cursor is in the EditorInput, this is important for the
|
|
206
|
+
* keyboard behavior. This should be passed as children in the PromptInput.
|
|
207
|
+
*/
|
|
208
|
+
cursorPositionPlugin: JSX.Element;
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
export declare function usePromptListboxFunctionality(params: UsePromptListboxFunctionalityParams): UsePromptListboxFunctionality;
|
|
212
|
+
|
|
213
|
+
export declare type UsePromptListboxFunctionalityParams = {
|
|
214
|
+
open?: boolean;
|
|
215
|
+
defaultOpen?: boolean;
|
|
216
|
+
onOpenChange?: EventHandler<OnOpenChangeData>;
|
|
217
|
+
onSelectionModeChange?: (isInSelectionMode: boolean) => void;
|
|
218
|
+
positioning?: PositioningShorthand;
|
|
219
|
+
/**
|
|
220
|
+
* Props to be passed to the ListboxComponent
|
|
221
|
+
*/
|
|
222
|
+
listboxProps?: ProcessedPromptListboxProps;
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Apply styling to the PromptListbox slots based on the state
|
|
227
|
+
*/
|
|
228
|
+
export declare const usePromptListboxStyles_unstable: (state: PromptListboxState) => PromptListboxState;
|
|
229
|
+
|
|
230
|
+
export { }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["PromptListbox.ts"],"sourcesContent":["export * from './components/PromptListbox/index';\n"],"names":[],"rangeMappings":"","mappings":"AAAA,cAAc,mCAAmC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { usePromptListbox_unstable } from './usePromptListbox';
|
|
3
|
+
import { renderPromptListbox_unstable } from './renderPromptListbox';
|
|
4
|
+
import { usePromptListboxStyles_unstable } from './usePromptListboxStyles.styles';
|
|
5
|
+
import { usePromptListboxContextValues } from './usePromptListboxContextValues';
|
|
6
|
+
// PromptListbox component - TODO: add more docs
|
|
7
|
+
export const PromptListbox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
8
|
+
const state = usePromptListbox_unstable(props, ref);
|
|
9
|
+
const contextValues = usePromptListboxContextValues(state);
|
|
10
|
+
usePromptListboxStyles_unstable(state);
|
|
11
|
+
return renderPromptListbox_unstable(state, contextValues);
|
|
12
|
+
});
|
|
13
|
+
PromptListbox.displayName = 'PromptListbox';
|
|
14
|
+
//# sourceMappingURL=PromptListbox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["PromptListbox.tsx"],"sourcesContent":["import * as React from 'react';\nimport { usePromptListbox_unstable } from './usePromptListbox';\nimport { renderPromptListbox_unstable } from './renderPromptListbox';\nimport { usePromptListboxStyles_unstable } from './usePromptListboxStyles.styles';\nimport { usePromptListboxContextValues } from './usePromptListboxContextValues';\nimport type { PromptListboxProps } from './PromptListbox.types';\nimport type { ForwardRefComponent } from '@fluentui/react-components';\n\n// PromptListbox component - TODO: add more docs\nexport const PromptListbox: ForwardRefComponent<PromptListboxProps> = React.forwardRef((props, ref) => {\n const state = usePromptListbox_unstable(props, ref);\n const contextValues = usePromptListboxContextValues(state);\n\n usePromptListboxStyles_unstable(state);\n return renderPromptListbox_unstable(state, contextValues);\n});\n\nPromptListbox.displayName = 'PromptListbox';\n"],"names":["React","usePromptListbox_unstable","renderPromptListbox_unstable","usePromptListboxStyles_unstable","usePromptListboxContextValues","PromptListbox","forwardRef","props","ref","state","contextValues","displayName"],"rangeMappings":";;;;;;;;;;;;","mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,yBAAyB,QAAQ,qBAAqB;AAC/D,SAASC,4BAA4B,QAAQ,wBAAwB;AACrE,SAASC,+BAA+B,QAAQ,kCAAkC;AAClF,SAASC,6BAA6B,QAAQ,kCAAkC;AAIhF,gDAAgD;AAChD,OAAO,MAAMC,8BAAyDL,MAAMM,UAAU,CAAC,CAACC,OAAOC;IAC7F,MAAMC,QAAQR,0BAA0BM,OAAOC;IAC/C,MAAME,gBAAgBN,8BAA8BK;IAEpDN,gCAAgCM;IAChC,OAAOP,6BAA6BO,OAAOC;AAC7C,GAAG;AAEHL,cAAcM,WAAW,GAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["PromptListbox.types.ts"],"sourcesContent":["import type { ActiveDescendantContextValue } from '@fluentui/react-aria';\nimport type {\n ComboboxProps,\n ComponentProps,\n ComponentState,\n Listbox,\n ListboxContextValue,\n PortalProps,\n Slot,\n} from '@fluentui/react-components';\nimport type { PromptListboxContextState } from './usePromptListboxContextValues';\nimport type { OptionCollectionState } from '../utils/OptionCollection.types';\nimport type { SelectionState } from '../utils/Selection.types';\n\nexport type PromptListboxSlots = {\n root: Slot<typeof Listbox>;\n};\n\n/**\n * PromptListbox Props\n */\nexport type PromptListboxProps = ComponentProps<PromptListboxSlots> &\n Pick<PortalProps, 'mountNode'> &\n OptionCollectionState &\n SelectionState &\n Pick<PromptListboxContextState, 'activeDescendantController'> &\n Pick<ComboboxProps, 'onActiveOptionChange'> & {\n /**\n * Whether to listbox should be rendered.\n *\n * @default false\n */\n open?: boolean;\n /**\n * Whether to render the listbox inline or in a portal.\n *\n * @default false\n */\n inlinePopup?: boolean;\n };\n\n/**\n * State used in rendering PromptListbox\n */\nexport type PromptListboxState = ComponentState<PromptListboxSlots> &\n PromptListboxContextState &\n Required<Pick<PromptListboxProps, 'open' | 'inlinePopup'>> &\n Pick<PromptListboxProps, 'mountNode'>;\n\nexport type PromptListboxContextValues = {\n listbox: ListboxContextValue;\n activeDescendant: ActiveDescendantContextValue;\n};\n"],"names":[],"rangeMappings":"","mappings":"AAiDA,WAGE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["index.ts"],"sourcesContent":["export * from './PromptListbox';\nexport * from './PromptListbox.types';\nexport * from './renderPromptListbox';\nexport * from './usePromptListbox';\nexport * from './usePromptListboxStyles.styles';\n"],"names":[],"rangeMappings":";;;;","mappings":"AAAA,cAAc,kBAAkB;AAChC,cAAc,wBAAwB;AACtC,cAAc,wBAAwB;AACtC,cAAc,qBAAqB;AACnC,cAAc,kCAAkC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx } from "@fluentui/react-jsx-runtime/jsx-runtime";
|
|
2
|
+
import { assertSlots, ListboxProvider, Portal } from '@fluentui/react-components';
|
|
3
|
+
import { ActiveDescendantContextProvider } from '@fluentui/react-aria';
|
|
4
|
+
/**
|
|
5
|
+
* Render the final JSX of PromptListbox
|
|
6
|
+
*/
|
|
7
|
+
export const renderPromptListbox_unstable = (state, contextValues) => {
|
|
8
|
+
assertSlots(state);
|
|
9
|
+
return /*#__PURE__*/_jsx(ListboxProvider, {
|
|
10
|
+
value: contextValues.listbox,
|
|
11
|
+
children: /*#__PURE__*/_jsx(ActiveDescendantContextProvider, {
|
|
12
|
+
value: contextValues.activeDescendant,
|
|
13
|
+
children: state.open && (state.inlinePopup ? /*#__PURE__*/_jsx(state.root, {}) : /*#__PURE__*/_jsx(Portal, {
|
|
14
|
+
mountNode: state.mountNode,
|
|
15
|
+
children: /*#__PURE__*/_jsx(state.root, {})
|
|
16
|
+
}))
|
|
17
|
+
})
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=renderPromptListbox.js.map
|
|
@@ -0,0 +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\n return (\n <ListboxProvider value={contextValues.listbox}>\n <ActiveDescendantContextProvider value={contextValues.activeDescendant}>\n {state.open &&\n (state.inlinePopup ? (\n <state.root />\n ) : (\n <Portal mountNode={state.mountNode}>\n <state.root />\n </Portal>\n ))}\n </ActiveDescendantContextProvider>\n </ListboxProvider>\n );\n};\n"],"names":["assertSlots","ListboxProvider","Portal","ActiveDescendantContextProvider","renderPromptListbox_unstable","state","contextValues","value","listbox","activeDescendant","open","inlinePopup","root","mountNode"],"rangeMappings":";;;;;;;;;;;;;;;;;","mappings":"AAAA,0BAA0B,GAC1B,iDAAiD;AAEjD,SAASA,WAAW,EAAEC,eAAe,EAAEC,MAAM,QAAQ,6BAA6B;AAClF,SAASC,+BAA+B,QAAQ,uBAAuB;AAGvE;;CAEC,GACD,OAAO,MAAMC,+BAA+B,CAACC,OAA2BC;IACtEN,YAAgCK;IAEhC,qBACE,KAACJ;QAAgBM,OAAOD,cAAcE,OAAO;kBAC3C,cAAA,KAACL;YAAgCI,OAAOD,cAAcG,gBAAgB;sBACnEJ,MAAMK,IAAI,IACRL,CAAAA,MAAMM,WAAW,iBAChB,KAACN,MAAMO,IAAI,sBAEX,KAACV;gBAAOW,WAAWR,MAAMQ,SAAS;0BAChC,cAAA,KAACR,MAAMO,IAAI;cAEf;;;AAIV,EAAE"}
|
|
@@ -0,0 +1,81 @@
|
|
|
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
|
+
},
|
|
62
|
+
elementType: Listbox
|
|
63
|
+
})
|
|
64
|
+
};
|
|
65
|
+
state.root.ref = useMergedRefs(ref, state.root.ref);
|
|
66
|
+
state.root.onMouseDown = useEventCallback(mergeCallbacks(event => {
|
|
67
|
+
event.preventDefault();
|
|
68
|
+
}, state.root.onMouseDown));
|
|
69
|
+
state.root.onClick = useEventCallback(mergeCallbacks(event => {
|
|
70
|
+
event.preventDefault();
|
|
71
|
+
}, state.root.onClick));
|
|
72
|
+
return state;
|
|
73
|
+
};
|
|
74
|
+
const noop = () => null;
|
|
75
|
+
const deprecatedPropsDefaults = {
|
|
76
|
+
activeOption: undefined,
|
|
77
|
+
focusVisible: false,
|
|
78
|
+
setActiveOption: noop,
|
|
79
|
+
onOptionClick: noop
|
|
80
|
+
};
|
|
81
|
+
//# sourceMappingURL=usePromptListbox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["usePromptListbox.ts"],"sourcesContent":["import { Listbox, slot, useMergedRefs } from '@fluentui/react-components';\nimport { mergeCallbacks, useEventCallback, useId } from '@fluentui/react-utilities';\nimport type * as React from 'react';\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 },\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","elementType","onMouseDown","preventDefault","onClick","noop","activeOption","focusVisible","setActiveOption","onOptionClick"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,OAAO,EAAEC,IAAI,EAAEC,aAAa,QAAQ,6BAA6B;AAC1E,SAASC,cAAc,EAAEC,gBAAgB,EAAEC,KAAK,QAAQ,4BAA4B;AAMpF,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;YACZ;YACAwB,aAAarC;QACf;IAEJ;IAEA6B,MAAMG,IAAI,CAACxB,GAAG,GAAGN,cAAcM,KAAKqB,MAAMG,IAAI,CAACxB,GAAG;IAClDqB,MAAMG,IAAI,CAACM,WAAW,GAAGlC,iBACvBD,eAAe,CAACoB;QACdA,MAAMgB,cAAc;IACtB,GAAGV,MAAMG,IAAI,CAACM,WAAW;IAG3BT,MAAMG,IAAI,CAACQ,OAAO,GAAGpC,iBACnBD,eAAe,CAACoB;QACdA,MAAMgB,cAAc;IACtB,GAAGV,MAAMG,IAAI,CAACQ,OAAO;IAGvB,OAAOX;AACT,EAAE;AAEF,MAAMY,OAAO,IAAM;AAEnB,MAAMX,0BAGF;IACFY,cAAc7B;IACd8B,cAAc;IACdC,iBAAiBH;IACjBI,eAAeJ;AACjB"}
|
|
@@ -0,0 +1,33 @@
|
|
|
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
|
|
@@ -0,0 +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":["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"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { __styles, mergeClasses, shorthands, tokens } from '@fluentui/react-components';
|
|
2
|
+
export const promptListboxClassNames = {
|
|
3
|
+
root: 'fai-PromptListbox'
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Styles for the root slot
|
|
7
|
+
*/
|
|
8
|
+
const useStyles = __styles({
|
|
9
|
+
listbox: {
|
|
10
|
+
E5pizo: "f1hg901r",
|
|
11
|
+
Bbmb7ep: ["f1aa9q02", "f16jpd5f"],
|
|
12
|
+
Beyfa6y: ["f16jpd5f", "f1aa9q02"],
|
|
13
|
+
B7oj6ja: ["f1jar5jt", "fyu767a"],
|
|
14
|
+
Btl43ni: ["fyu767a", "f1jar5jt"],
|
|
15
|
+
Bxyxcbc: "fmmk62d",
|
|
16
|
+
B7ck84d: "f1ewtqcl"
|
|
17
|
+
},
|
|
18
|
+
listboxCollapsed: {
|
|
19
|
+
mc9l5x: "fjseox"
|
|
20
|
+
},
|
|
21
|
+
inlineListbox: {
|
|
22
|
+
Bj3rh1h: "f19g0ac"
|
|
23
|
+
}
|
|
24
|
+
}, {
|
|
25
|
+
d: [".f1hg901r{box-shadow:var(--shadow16);}", ".f1aa9q02{border-bottom-right-radius:var(--borderRadiusMedium);}", ".f16jpd5f{border-bottom-left-radius:var(--borderRadiusMedium);}", ".f1jar5jt{border-top-right-radius:var(--borderRadiusMedium);}", ".fyu767a{border-top-left-radius:var(--borderRadiusMedium);}", ".fmmk62d{max-height:80vh;}", ".f1ewtqcl{box-sizing:border-box;}", ".fjseox{display:none;}", ".f19g0ac{z-index:1;}"]
|
|
26
|
+
});
|
|
27
|
+
/**
|
|
28
|
+
* Apply styling to the PromptListbox slots based on the state
|
|
29
|
+
*/
|
|
30
|
+
export const usePromptListboxStyles_unstable = state => {
|
|
31
|
+
'use no memo';
|
|
32
|
+
|
|
33
|
+
const styles = useStyles();
|
|
34
|
+
state.root.className = mergeClasses(promptListboxClassNames.root, styles.listbox, state.inlinePopup && styles.inlineListbox, !state.open && styles.listboxCollapsed, state.root.className);
|
|
35
|
+
return state;
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=usePromptListboxStyles.styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["usePromptListboxStyles.styles.ts"],"sourcesContent":["import { makeStyles, mergeClasses, shorthands, tokens } from '@fluentui/react-components';\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 ...shorthands.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","shorthands","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,EAAEC,UAAU,EAAEC,MAAM,QAAQ,6BAA6B;AAI1F,OAAO,MAAMC,0BAA8D;IACzEC,MAAM;AACR,EAAE;AAEF;;CAEC,GACD,MAAMC,YAAYN,WAAW;IAC3BO,SAAS;QACPC,WAAWL,OAAOM,QAAQ;QAC1B,GAAGP,WAAWQ,YAAY,CAACP,OAAOQ,kBAAkB,CAAC;QACrDC,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,GAAGpB,aACrBG,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"}
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["PromptListboxFunctionality.types.ts"],"sourcesContent":["import type 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 targetRef is the same as the trigger, the ref provided in triggerProps needs\n * to be merged with this one using `useMergedRefs(targetRef, triggerProps.ref);`\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n targetRef: 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 onSelectionModeChange?: (isInSelectionMode: boolean) => void;\n positioning?: PositioningShorthand;\n /**\n * Props to be passed to the ListboxComponent\n */\n listboxProps?: ProcessedPromptListboxProps;\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":"AA4DA,WAME"}
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|