@fluentui-copilot/react-prompt-listbox 0.0.0-nightly-20240719-0406-ee8d99d6.1 → 0.0.0-nightly-20240722-0406-476bfcb7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/CHANGELOG.json +15 -15
  2. package/CHANGELOG.md +9 -9
  3. package/dist/index.d.ts +42 -3
  4. package/lib/PromptOption.js +2 -0
  5. package/lib/PromptOption.js.map +1 -0
  6. package/lib/components/PromptOption/PromptOption.js +12 -0
  7. package/lib/components/PromptOption/PromptOption.js.map +1 -0
  8. package/lib/components/PromptOption/PromptOption.types.js +5 -0
  9. package/lib/components/PromptOption/PromptOption.types.js.map +1 -0
  10. package/lib/components/PromptOption/index.js +6 -0
  11. package/lib/components/PromptOption/index.js.map +1 -0
  12. package/lib/components/PromptOption/renderPromptOption.js +11 -0
  13. package/lib/components/PromptOption/renderPromptOption.js.map +1 -0
  14. package/lib/components/PromptOption/usePromptOption.js +29 -0
  15. package/lib/components/PromptOption/usePromptOption.js.map +1 -0
  16. package/lib/components/PromptOption/usePromptOptionStyles.styles.js +23 -0
  17. package/lib/components/PromptOption/usePromptOptionStyles.styles.js.map +1 -0
  18. package/lib/components/utils/PromptListboxFunctionality.types.js.map +1 -1
  19. package/lib/components/utils/usePromptListboxFunctionality.js +1 -1
  20. package/lib/components/utils/usePromptListboxFunctionality.js.map +1 -1
  21. package/lib/index.js +1 -0
  22. package/lib/index.js.map +1 -1
  23. package/lib-commonjs/PromptOption.js +7 -0
  24. package/lib-commonjs/PromptOption.js.map +1 -0
  25. package/lib-commonjs/components/PromptOption/PromptOption.js +21 -0
  26. package/lib-commonjs/components/PromptOption/PromptOption.js.map +1 -0
  27. package/lib-commonjs/components/PromptOption/PromptOption.types.js +9 -0
  28. package/lib-commonjs/components/PromptOption/PromptOption.types.js.map +1 -0
  29. package/lib-commonjs/components/PromptOption/index.js +11 -0
  30. package/lib-commonjs/components/PromptOption/index.js.map +1 -0
  31. package/lib-commonjs/components/PromptOption/renderPromptOption.js +17 -0
  32. package/lib-commonjs/components/PromptOption/renderPromptOption.js.map +1 -0
  33. package/lib-commonjs/components/PromptOption/usePromptOption.js +28 -0
  34. package/lib-commonjs/components/PromptOption/usePromptOption.js.map +1 -0
  35. package/lib-commonjs/components/PromptOption/usePromptOptionStyles.styles.js +35 -0
  36. package/lib-commonjs/components/PromptOption/usePromptOptionStyles.styles.js.map +1 -0
  37. package/lib-commonjs/components/utils/PromptListboxFunctionality.types.js.map +1 -1
  38. package/lib-commonjs/components/utils/usePromptListboxFunctionality.js +1 -1
  39. package/lib-commonjs/components/utils/usePromptListboxFunctionality.js.map +1 -1
  40. package/lib-commonjs/index.js +16 -0
  41. package/lib-commonjs/index.js.map +1 -1
  42. package/package.json +7 -7
package/CHANGELOG.json CHANGED
@@ -2,9 +2,9 @@
2
2
  "name": "@fluentui-copilot/react-prompt-listbox",
3
3
  "entries": [
4
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",
5
+ "date": "Mon, 22 Jul 2024 04:13:12 GMT",
6
+ "tag": "@fluentui-copilot/react-prompt-listbox_v0.0.0-nightly-20240722-0406-476bfcb7.1",
7
+ "version": "0.0.0-nightly-20240722-0406-476bfcb7.1",
8
8
  "comments": {
9
9
  "prerelease": [
10
10
  {
@@ -16,38 +16,38 @@
16
16
  {
17
17
  "author": "beachball",
18
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"
19
+ "comment": "Bump @fluentui-copilot/chat-input-plugins to v0.0.0-nightly-20240722-0406-476bfcb7.1",
20
+ "commit": "e8afe224d02de2aef9778bb216e4d3228442e02f"
21
21
  },
22
22
  {
23
23
  "author": "beachball",
24
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"
25
+ "comment": "Bump @fluentui-copilot/react-chat-input-plugins to v0.0.0-nightly-20240722-0406-476bfcb7.1",
26
+ "commit": "e8afe224d02de2aef9778bb216e4d3228442e02f"
27
27
  },
28
28
  {
29
29
  "author": "beachball",
30
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"
31
+ "comment": "Bump @fluentui-copilot/react-editor-input to v0.0.0-nightly-20240722-0406-476bfcb7.1",
32
+ "commit": "e8afe224d02de2aef9778bb216e4d3228442e02f"
33
33
  },
34
34
  {
35
35
  "author": "beachball",
36
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"
37
+ "comment": "Bump @fluentui-copilot/react-provider to v0.0.0-nightly-20240722-0406-476bfcb7.1",
38
+ "commit": "e8afe224d02de2aef9778bb216e4d3228442e02f"
39
39
  },
40
40
  {
41
41
  "author": "beachball",
42
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"
43
+ "comment": "Bump @fluentui-copilot/react-text-editor to v0.0.0-nightly-20240722-0406-476bfcb7.1",
44
+ "commit": "e8afe224d02de2aef9778bb216e4d3228442e02f"
45
45
  },
46
46
  {
47
47
  "author": "beachball",
48
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"
49
+ "comment": "Bump @fluentui-copilot/text-editor to v0.0.0-nightly-20240722-0406-476bfcb7.1",
50
+ "commit": "e8afe224d02de2aef9778bb216e4d3228442e02f"
51
51
  }
52
52
  ]
53
53
  }
package/CHANGELOG.md CHANGED
@@ -1,19 +1,19 @@
1
1
  # Change Log - @fluentui-copilot/react-prompt-listbox
2
2
 
3
- This log was last generated on Fri, 19 Jul 2024 04:13:27 GMT and should not be manually modified.
3
+ This log was last generated on Mon, 22 Jul 2024 04:13:12 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
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)
7
+ ## [0.0.0-nightly-20240722-0406-476bfcb7.1](https://github.com/microsoft/fluentai/tree/@fluentui-copilot/react-prompt-listbox_v0.0.0-nightly-20240722-0406-476bfcb7.1)
8
8
 
9
- Fri, 19 Jul 2024 04:13:27 GMT
9
+ Mon, 22 Jul 2024 04:13:12 GMT
10
10
 
11
11
  ### Changes
12
12
 
13
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)
14
+ - Bump @fluentui-copilot/chat-input-plugins to v0.0.0-nightly-20240722-0406-476bfcb7.1 ([commit](https://github.com/microsoft/fluentai/commit/e8afe224d02de2aef9778bb216e4d3228442e02f) by beachball)
15
+ - Bump @fluentui-copilot/react-chat-input-plugins to v0.0.0-nightly-20240722-0406-476bfcb7.1 ([commit](https://github.com/microsoft/fluentai/commit/e8afe224d02de2aef9778bb216e4d3228442e02f) by beachball)
16
+ - Bump @fluentui-copilot/react-editor-input to v0.0.0-nightly-20240722-0406-476bfcb7.1 ([commit](https://github.com/microsoft/fluentai/commit/e8afe224d02de2aef9778bb216e4d3228442e02f) by beachball)
17
+ - Bump @fluentui-copilot/react-provider to v0.0.0-nightly-20240722-0406-476bfcb7.1 ([commit](https://github.com/microsoft/fluentai/commit/e8afe224d02de2aef9778bb216e4d3228442e02f) by beachball)
18
+ - Bump @fluentui-copilot/react-text-editor to v0.0.0-nightly-20240722-0406-476bfcb7.1 ([commit](https://github.com/microsoft/fluentai/commit/e8afe224d02de2aef9778bb216e4d3228442e02f) by beachball)
19
+ - Bump @fluentui-copilot/text-editor to v0.0.0-nightly-20240722-0406-476bfcb7.1 ([commit](https://github.com/microsoft/fluentai/commit/e8afe224d02de2aef9778bb216e4d3228442e02f) by beachball)
package/dist/index.d.ts CHANGED
@@ -144,11 +144,34 @@ export declare type PromptListboxSlots = {
144
144
  */
145
145
  export declare type PromptListboxState = ComponentState<PromptListboxSlots> & PromptListboxContextState & Required<Pick<PromptListboxProps, 'open' | 'inlinePopup'>> & Pick<PromptListboxProps, 'mountNode'>;
146
146
 
147
+ export declare const PromptOption: ForwardRefComponent<PromptOptionProps>;
148
+
149
+ export declare const promptOptionClassNames: SlotClassNames<PromptOptionSlots>;
150
+
151
+ /**
152
+ * PromptOption Props
153
+ */
154
+ export declare type PromptOptionProps = ComponentProps<PromptOptionSlots> & {};
155
+
156
+ export declare type PromptOptionSlots = {
157
+ root: Slot<'div'>;
158
+ };
159
+
160
+ /**
161
+ * State used in rendering PromptOption
162
+ */
163
+ export declare type PromptOptionState = ComponentState<PromptOptionSlots>;
164
+
147
165
  /**
148
166
  * Render the final JSX of PromptListbox
149
167
  */
150
168
  export declare const renderPromptListbox_unstable: (state: PromptListboxState, contextValues: PromptListboxContextValues) => JSX.Element;
151
169
 
170
+ /**
171
+ * Render the final JSX of PromptOption
172
+ */
173
+ export declare const renderPromptOption_unstable: (state: PromptOptionState) => JSX.Element;
174
+
152
175
  /** Possible event types for onOptionSelect */
153
176
  declare type SelectionEvents = React_2.ChangeEvent<HTMLElement> | React_2.KeyboardEvent<HTMLElement> | React_2.MouseEvent<HTMLElement>;
154
177
 
@@ -197,10 +220,10 @@ export declare type UsePromptListboxFunctionality = {
197
220
  * will provide this prop to the PromptInput's EditorInput (since this is the root slot,
198
221
  * this is provided directly to the component and not the slot).
199
222
  *
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);`
223
+ * Note: If the containerRef is the same as the trigger, the ref provided in triggerProps needs
224
+ * to be merged with this one using `useMergedRefs(containerRef, triggerProps.ref);`
202
225
  */
203
- targetRef: React_3.MutableRefObject<any>;
226
+ containerRef: React_3.MutableRefObject<any>;
204
227
  /**
205
228
  * Plugin used to tell where the cursor is in the EditorInput, this is important for the
206
229
  * keyboard behavior. This should be passed as children in the PromptInput.
@@ -227,4 +250,20 @@ export declare type UsePromptListboxFunctionalityParams = {
227
250
  */
228
251
  export declare const usePromptListboxStyles_unstable: (state: PromptListboxState) => PromptListboxState;
229
252
 
253
+ /**
254
+ * Create the state required to render PromptOption.
255
+ *
256
+ * The returned state can be modified with hooks such as usePromptOptionStyles_unstable,
257
+ * before being passed to renderPromptOption_unstable.
258
+ *
259
+ * @param props - props from this instance of PromptOption
260
+ * @param ref - reference to root HTMLElement of PromptOption
261
+ */
262
+ export declare const usePromptOption_unstable: (props: PromptOptionProps, ref: React_2.Ref<HTMLDivElement>) => PromptOptionState;
263
+
264
+ /**
265
+ * Apply styling to the PromptOption slots based on the state
266
+ */
267
+ export declare const usePromptOptionStyles_unstable: (state: PromptOptionState) => PromptOptionState;
268
+
230
269
  export { }
@@ -0,0 +1,2 @@
1
+ export * from './components/PromptOption/index';
2
+ //# sourceMappingURL=PromptOption.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["PromptOption.ts"],"sourcesContent":["export * from './components/PromptOption/index';\n"],"names":[],"rangeMappings":"","mappings":"AAAA,cAAc,kCAAkC"}
@@ -0,0 +1,12 @@
1
+ import * as React from 'react';
2
+ import { usePromptOption_unstable } from './usePromptOption';
3
+ import { renderPromptOption_unstable } from './renderPromptOption';
4
+ import { usePromptOptionStyles_unstable } from './usePromptOptionStyles.styles';
5
+ // PromptOption component - TODO: add more docs
6
+ export const PromptOption = /*#__PURE__*/React.forwardRef((props, ref) => {
7
+ const state = usePromptOption_unstable(props, ref);
8
+ usePromptOptionStyles_unstable(state);
9
+ return renderPromptOption_unstable(state);
10
+ });
11
+ PromptOption.displayName = 'PromptOption';
12
+ //# sourceMappingURL=PromptOption.js.map
@@ -0,0 +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// PromptOption component - TODO: add more docs\nexport const PromptOption: ForwardRefComponent<PromptOptionProps> = React.forwardRef((props, ref) => {\n const state = usePromptOption_unstable(props, ref);\n\n usePromptOptionStyles_unstable(state);\n return renderPromptOption_unstable(state);\n});\n\nPromptOption.displayName = 'PromptOption';\n"],"names":["React","usePromptOption_unstable","renderPromptOption_unstable","usePromptOptionStyles_unstable","PromptOption","forwardRef","props","ref","state","displayName"],"rangeMappings":";;;;;;;;;;","mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,wBAAwB,QAAQ,oBAAoB;AAC7D,SAASC,2BAA2B,QAAQ,uBAAuB;AACnE,SAASC,8BAA8B,QAAQ,iCAAiC;AAIhF,+CAA+C;AAC/C,OAAO,MAAMC,6BAAuDJ,MAAMK,UAAU,CAAC,CAACC,OAAOC;IAC3F,MAAMC,QAAQP,yBAAyBK,OAAOC;IAE9CJ,+BAA+BK;IAC/B,OAAON,4BAA4BM;AACrC,GAAG;AAEHJ,aAAaK,WAAW,GAAG"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * State used in rendering PromptOption
3
+ */export {}; // TODO: Remove semicolon from previous line, uncomment next line, and provide union of props to pick from PromptOptionProps.
4
+ // & Required<Pick<PromptOptionProps, 'propName'>>
5
+ //# sourceMappingURL=PromptOption.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["PromptOption.types.ts"],"sourcesContent":["import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-components';\n\nexport type PromptOptionSlots = {\n root: Slot<'div'>;\n};\n\n/**\n * PromptOption Props\n */\nexport type PromptOptionProps = ComponentProps<PromptOptionSlots> & {};\n\n/**\n * State used in rendering PromptOption\n */\nexport type PromptOptionState = ComponentState<PromptOptionSlots>;\n// TODO: Remove semicolon from previous line, uncomment next line, and provide union of props to pick from PromptOptionProps.\n// & Required<Pick<PromptOptionProps, 'propName'>>\n"],"names":[],"rangeMappings":";;;","mappings":"AAWA;;CAEC,GACD,WAAkE,CAClE,6HAA6H;CAC7H,kDAAkD"}
@@ -0,0 +1,6 @@
1
+ export * from './PromptOption';
2
+ export * from './PromptOption.types';
3
+ export * from './renderPromptOption';
4
+ export * from './usePromptOption';
5
+ export * from './usePromptOptionStyles.styles';
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["index.ts"],"sourcesContent":["export * from './PromptOption';\nexport * from './PromptOption.types';\nexport * from './renderPromptOption';\nexport * from './usePromptOption';\nexport * from './usePromptOptionStyles.styles';\n"],"names":[],"rangeMappings":";;;;","mappings":"AAAA,cAAc,iBAAiB;AAC/B,cAAc,uBAAuB;AACrC,cAAc,uBAAuB;AACrC,cAAc,oBAAoB;AAClC,cAAc,iCAAiC"}
@@ -0,0 +1,11 @@
1
+ import { jsx as _jsx } from "@fluentui/react-jsx-runtime/jsx-runtime";
2
+ import { assertSlots } from '@fluentui/react-components';
3
+ /**
4
+ * Render the final JSX of PromptOption
5
+ */
6
+ export const renderPromptOption_unstable = state => {
7
+ assertSlots(state);
8
+ // TODO Add additional slots in the appropriate place
9
+ return /*#__PURE__*/_jsx(state.root, {});
10
+ };
11
+ //# sourceMappingURL=renderPromptOption.js.map
@@ -0,0 +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 { PromptOptionState, PromptOptionSlots } 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 // TODO Add additional slots in the appropriate place\n return <state.root />;\n};\n"],"names":["assertSlots","renderPromptOption_unstable","state","root"],"rangeMappings":";;;;;;;;","mappings":"AAAA,0BAA0B,GAC1B,iDAAiD;AAEjD,SAASA,WAAW,QAAQ,6BAA6B;AAGzD;;CAEC,GACD,OAAO,MAAMC,8BAA8B,CAACC;IAC1CF,YAA+BE;IAE/B,qDAAqD;IACrD,qBAAO,KAACA,MAAMC,IAAI;AACpB,EAAE"}
@@ -0,0 +1,29 @@
1
+ import { getIntrinsicElementProps, slot } from '@fluentui/react-components';
2
+ // If you add JSX to this file, be sure to change the file type to .tsx
3
+ /**
4
+ * Create the state required to render PromptOption.
5
+ *
6
+ * The returned state can be modified with hooks such as usePromptOptionStyles_unstable,
7
+ * before being passed to renderPromptOption_unstable.
8
+ *
9
+ * @param props - props from this instance of PromptOption
10
+ * @param ref - reference to root HTMLElement of PromptOption
11
+ */
12
+ export const usePromptOption_unstable = (props, ref) => {
13
+ return {
14
+ // TODO add appropriate props/defaults
15
+ components: {
16
+ // TODO add each slot's element type or component
17
+ root: 'div'
18
+ },
19
+ // TODO add appropriate slots, for example:
20
+ // mySlot: slot.optional(props.mySlot),
21
+ root: slot.always(getIntrinsicElementProps('div', {
22
+ ref,
23
+ ...props
24
+ }), {
25
+ elementType: 'div'
26
+ })
27
+ };
28
+ };
29
+ //# sourceMappingURL=usePromptOption.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["usePromptOption.ts"],"sourcesContent":["import type * as React from 'react';\nimport { getIntrinsicElementProps, slot } from '@fluentui/react-components';\nimport type { PromptOptionProps, PromptOptionState } from './PromptOption.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 return {\n // TODO add appropriate props/defaults\n components: {\n // TODO add each slot's element type or component\n root: 'div',\n },\n // TODO add appropriate slots, for example:\n // mySlot: slot.optional(props.mySlot),\n root: slot.always(\n getIntrinsicElementProps('div', {\n ref,\n ...props,\n }),\n { elementType: 'div' },\n ),\n };\n};\n"],"names":["getIntrinsicElementProps","slot","usePromptOption_unstable","props","ref","components","root","always","elementType"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AACA,SAASA,wBAAwB,EAAEC,IAAI,QAAQ,6BAA6B;AAG5E,uEAAuE;AAEvE;;;;;;;;CAQC,GACD,OAAO,MAAMC,2BAA2B,CACtCC,OACAC;IAEA,OAAO;QACL,sCAAsC;QACtCC,YAAY;YACV,iDAAiD;YACjDC,MAAM;QACR;QACA,2CAA2C;QAC3C,uCAAuC;QACvCA,MAAML,KAAKM,MAAM,CACfP,yBAAyB,OAAO;YAC9BI;YACA,GAAGD,KAAK;QACV,IACA;YAAEK,aAAa;QAAM;IAEzB;AACF,EAAE"}
@@ -0,0 +1,23 @@
1
+ import { __styles, mergeClasses } from '@fluentui/react-components';
2
+ export const promptOptionClassNames = {
3
+ root: 'fai-PromptOption'
4
+ };
5
+ /**
6
+ * Styles for the root slot
7
+ */
8
+ const useStyles = __styles({
9
+ root: {}
10
+ }, {});
11
+ /**
12
+ * Apply styling to the PromptOption slots based on the state
13
+ */
14
+ export const usePromptOptionStyles_unstable = state => {
15
+ 'use no memo';
16
+
17
+ const styles = useStyles();
18
+ state.root.className = mergeClasses(promptOptionClassNames.root, styles.root, state.root.className);
19
+ // TODO Add class names to slots, for example:
20
+ // state.mySlot.className = mergeClasses(styles.mySlot, state.mySlot.className);
21
+ return state;
22
+ };
23
+ //# sourceMappingURL=usePromptOptionStyles.styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["usePromptOptionStyles.styles.ts"],"sourcesContent":["import { makeStyles, mergeClasses } from '@fluentui/react-components';\nimport type { PromptOptionSlots, PromptOptionState } from './PromptOption.types';\nimport type { SlotClassNames } from '@fluentui/react-components';\n\nexport const promptOptionClassNames: SlotClassNames<PromptOptionSlots> = {\n root: 'fai-PromptOption',\n // TODO: add class names for all slots on PromptOptionSlots.\n // Should be of the form `<slotName>: 'fai-PromptOption__<slotName>`\n};\n\n/**\n * Styles for the root slot\n */\nconst useStyles = makeStyles({\n root: {\n // TODO Add default styles for the root element\n },\n\n // TODO add additional classes for different states and/or slots\n});\n\n/**\n * Apply styling to the PromptOption slots based on the state\n */\nexport const usePromptOptionStyles_unstable = (state: PromptOptionState): PromptOptionState => {\n 'use no memo';\n\n const styles = useStyles();\n state.root.className = mergeClasses(promptOptionClassNames.root, styles.root, state.root.className);\n\n // TODO Add class names to slots, for example:\n // state.mySlot.className = mergeClasses(styles.mySlot, state.mySlot.className);\n\n return state;\n};\n"],"names":["makeStyles","mergeClasses","promptOptionClassNames","root","useStyles","usePromptOptionStyles_unstable","state","styles","className"],"rangeMappings":";;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,UAAU,EAAEC,YAAY,QAAQ,6BAA6B;AAItE,OAAO,MAAMC,yBAA4D;IACvEC,MAAM;AAGR,EAAE;AAEF;;CAEC,GACD,MAAMC,YAAYJ,WAAW;IAC3BG,MAAM;IAEN;AAGF;AAEA;;CAEC,GACD,OAAO,MAAME,iCAAiC,CAACC;IAC7C;IAEA,MAAMC,SAASH;IACfE,MAAMH,IAAI,CAACK,SAAS,GAAGP,aAAaC,uBAAuBC,IAAI,EAAEI,OAAOJ,IAAI,EAAEG,MAAMH,IAAI,CAACK,SAAS;IAElG,8CAA8C;IAC9C,gFAAgF;IAEhF,OAAOF;AACT,EAAE"}
@@ -1 +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"}
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 containerRef is the same as the trigger, the ref provided in triggerProps needs\n * to be merged with this one using `useMergedRefs(containerRef, triggerProps.ref);`\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n containerRef: React.MutableRefObject<any>;\n /**\n * Plugin used to tell where the cursor is in the EditorInput, this is important for the\n * keyboard behavior. This should be passed as children in the PromptInput.\n */\n cursorPositionPlugin: JSX.Element;\n};\n\nexport type UsePromptListboxFunctionalityParams = {\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: EventHandler<OnOpenChangeData>;\n 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"}
@@ -136,7 +136,7 @@ export function usePromptListboxFunctionality(params) {
136
136
  onKeyDown: useEventCallback(mergeCallbacks(onKeyDown, onInputTriggerKeyDown)),
137
137
  isInSelectionMode
138
138
  },
139
- targetRef: comboboxTargetRef,
139
+ containerRef: comboboxTargetRef,
140
140
  cursorPositionPlugin
141
141
  };
142
142
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["usePromptListboxFunctionality.tsx"],"sourcesContent":["import * as React from 'react';\nimport { useActiveDescendant } from '@fluentui/react-aria';\nimport { optionClassNames } from '@fluentui/react-components';\nimport { mergeCallbacks, useControllableState, useEventCallback, useMergedRefs } from '@fluentui/react-utilities';\nimport { getDropdownActionFromKey } from './dropdownKeyActions';\nimport { TextCursorPositionPlugin } from '../../plugins/TextCursorPositionPlugin';\nimport { useOptionCollection } from './useOptionCollection';\nimport { useSelection } from './useSelection';\nimport { ArrowDown, ArrowLeft, ArrowRight, ArrowUp } from '@fluentui/keyboard-keys';\nimport { useComboboxPositioning } from './useComboboxPositioning';\nimport { useTriggerKeydown } from './useTriggerKeyDown';\nimport { PromptListbox } from '../PromptListbox';\nimport type { EditorInputProps } from '@fluentui-copilot/react-editor-input';\nimport type {\n UsePromptListboxFunctionalityParams,\n UsePromptListboxFunctionality,\n} from './PromptListboxFunctionality.types';\n\nexport function usePromptListboxFunctionality(\n params: UsePromptListboxFunctionalityParams,\n): UsePromptListboxFunctionality {\n const { positioning, onOpenChange, onSelectionModeChange, listboxProps } = params;\n const {\n listboxRef: activeDescendantListboxRef,\n activeParentRef,\n controller: activeDescendantController,\n } = useActiveDescendant<HTMLSpanElement, HTMLDivElement>({\n matchOption: el => el.classList.contains(optionClassNames.root),\n });\n // useMergedRefs to normalize the ref into a React.RefObject type\n const triggerRef = useMergedRefs(activeParentRef);\n const selectionState = useSelection(listboxProps ?? {});\n const { selectOption } = selectionState;\n const optionCollection = useOptionCollection();\n const { getOptionById } = optionCollection;\n const [isInLastPosition, setIsInLastPosition] = React.useState(true);\n const [isInSelectionMode, setIsInSelectionMode] = React.useState(false);\n const [open, setOpen] = useControllableState({\n state: params.open,\n defaultState: params.defaultOpen,\n initialState: false,\n });\n\n const onBlur = (event: React.FocusEvent<HTMLSpanElement>) => {\n setOpen(false);\n onOpenChange?.(event, { event, type: 'focus', open: false });\n };\n\n const onFocus = (event: React.FocusEvent<HTMLSpanElement>) => {\n if (event.target === event.currentTarget) {\n setOpen(true);\n onOpenChange?.(event, { event, type: 'focus', open: true });\n }\n };\n\n const cursorPositionPlugin = <TextCursorPositionPlugin setIsInLastPosition={setIsInLastPosition} />;\n\n const onListboxBlur = React.useCallback(() => {\n setIsInSelectionMode(false);\n onSelectionModeChange?.(false);\n }, [onSelectionModeChange]);\n\n // handle combobox keyboard interaction\n const onKeyDown = useTriggerKeydown({\n ...optionCollection,\n activeDescendantController,\n getOptionById,\n onBlur: onListboxBlur,\n selectOption,\n isInLastPosition,\n open,\n multiselect: false,\n });\n\n // NVDA and JAWS have bugs that suppress reading the input value text when aria-activedescendant is set\n // To prevent this, we clear the HTML attribute (but save the state) when a user presses left/right arrows\n // ref: https://github.com/microsoft/fluentui/issues/26359#issuecomment-1397759888\n const [hideActiveDescendant, setHideActiveDescendant] = React.useState(false);\n\n /**\n * Freeform combobox should not select\n */\n const onInputTriggerKeyDown: EditorInputProps['onKeyDown'] = useEventCallback(event => {\n // update typing state to true if the user is typing\n const action = getDropdownActionFromKey(event, { open, multiselect: false, isInLastPosition });\n if (\n event.key === ArrowLeft ||\n event.key === ArrowRight ||\n (!isInLastPosition && (event.key === ArrowDown || event.key === ArrowUp)) ||\n (action === 'Type' && isInLastPosition) ||\n action === 'Type'\n ) {\n activeDescendantController.blur();\n setHideActiveDescendant(true);\n setIsInSelectionMode(false);\n onSelectionModeChange?.(false);\n } else if (\n action === 'Next' ||\n action === 'Previous' ||\n action === 'First' ||\n action === 'Last' ||\n action === 'PageUp' ||\n action === 'PageDown'\n ) {\n setHideActiveDescendant(false);\n setIsInSelectionMode(true);\n onSelectionModeChange?.(true);\n }\n });\n\n React.useEffect(() => {\n if (hideActiveDescendant) {\n triggerRef.current?.removeAttribute('aria-activedescendant');\n }\n // We only want to run this when the hideActiveDescendant changes, if the triggerRef\n // is undefined, there's no need to remove theAttribute and we shouldn't be adding\n // refs as dependencies since it can blow up the number of runs.\n // eslint-disable-next-line react-compiler/react-compiler\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [hideActiveDescendant]);\n\n const [comboboxPopupRef, comboboxTargetRef] = useComboboxPositioning({ positioning });\n\n const listboxMergedRef = useMergedRefs(comboboxPopupRef, activeDescendantListboxRef, listboxProps?.ref);\n const listbox = React.useMemo(() => {\n return (\n <PromptListbox\n open={open}\n {...listboxProps}\n {...optionCollection}\n {...selectionState}\n ref={listboxMergedRef}\n activeDescendantController={activeDescendantController}\n />\n );\n }, [activeDescendantController, listboxMergedRef, listboxProps, open, optionCollection, selectionState]);\n\n return {\n promptListbox: listbox,\n triggerProps: {\n ref: triggerRef,\n onBlur,\n onFocus,\n onKeyDown: useEventCallback(mergeCallbacks(onKeyDown, onInputTriggerKeyDown)),\n isInSelectionMode,\n },\n targetRef: comboboxTargetRef,\n cursorPositionPlugin,\n };\n}\n"],"names":["React","useActiveDescendant","optionClassNames","mergeCallbacks","useControllableState","useEventCallback","useMergedRefs","getDropdownActionFromKey","TextCursorPositionPlugin","useOptionCollection","useSelection","ArrowDown","ArrowLeft","ArrowRight","ArrowUp","useComboboxPositioning","useTriggerKeydown","PromptListbox","usePromptListboxFunctionality","params","positioning","onOpenChange","onSelectionModeChange","listboxProps","listboxRef","activeDescendantListboxRef","activeParentRef","controller","activeDescendantController","matchOption","el","classList","contains","root","triggerRef","selectionState","selectOption","optionCollection","getOptionById","isInLastPosition","setIsInLastPosition","useState","isInSelectionMode","setIsInSelectionMode","open","setOpen","state","defaultState","defaultOpen","initialState","onBlur","event","type","onFocus","target","currentTarget","cursorPositionPlugin","onListboxBlur","useCallback","onKeyDown","multiselect","hideActiveDescendant","setHideActiveDescendant","onInputTriggerKeyDown","action","key","blur","useEffect","current","removeAttribute","comboboxPopupRef","comboboxTargetRef","listboxMergedRef","ref","listbox","useMemo","promptListbox","triggerProps","targetRef"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,mBAAmB,QAAQ,uBAAuB;AAC3D,SAASC,gBAAgB,QAAQ,6BAA6B;AAC9D,SAASC,cAAc,EAAEC,oBAAoB,EAAEC,gBAAgB,EAAEC,aAAa,QAAQ,4BAA4B;AAClH,SAASC,wBAAwB,QAAQ,uBAAuB;AAChE,SAASC,wBAAwB,QAAQ,yCAAyC;AAClF,SAASC,mBAAmB,QAAQ,wBAAwB;AAC5D,SAASC,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,SAAS,EAAEC,SAAS,EAAEC,UAAU,EAAEC,OAAO,QAAQ,0BAA0B;AACpF,SAASC,sBAAsB,QAAQ,2BAA2B;AAClE,SAASC,iBAAiB,QAAQ,sBAAsB;AACxD,SAASC,aAAa,QAAQ,mBAAmB;AAOjD,OAAO,SAASC,8BACdC,MAA2C;IAE3C,MAAM,EAAEC,WAAW,EAAEC,YAAY,EAAEC,qBAAqB,EAAEC,YAAY,EAAE,GAAGJ;IAC3E,MAAM,EACJK,YAAYC,0BAA0B,EACtCC,eAAe,EACfC,YAAYC,0BAA0B,EACvC,GAAG3B,oBAAqD;QACvD4B,aAAaC,CAAAA,KAAMA,GAAGC,SAAS,CAACC,QAAQ,C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ACLyC,eAAeF;QACfG,cAAc;YACZJ,KAAKvC;YACLgB;YACAG;YACAM,WAAWtD,iBAAiBF,eAAewD,WAAWI;YACtDrB;QACF;QACAoC,WAAWP;QACXf;IACF;AACF"}
1
+ {"version":3,"sources":["usePromptListboxFunctionality.tsx"],"sourcesContent":["import * as React from 'react';\nimport { useActiveDescendant } from '@fluentui/react-aria';\nimport { optionClassNames } from '@fluentui/react-components';\nimport { mergeCallbacks, useControllableState, useEventCallback, useMergedRefs } from '@fluentui/react-utilities';\nimport { getDropdownActionFromKey } from './dropdownKeyActions';\nimport { TextCursorPositionPlugin } from '../../plugins/TextCursorPositionPlugin';\nimport { useOptionCollection } from './useOptionCollection';\nimport { useSelection } from './useSelection';\nimport { ArrowDown, ArrowLeft, ArrowRight, ArrowUp } from '@fluentui/keyboard-keys';\nimport { useComboboxPositioning } from './useComboboxPositioning';\nimport { useTriggerKeydown } from './useTriggerKeyDown';\nimport { PromptListbox } from '../PromptListbox';\nimport type { EditorInputProps } from '@fluentui-copilot/react-editor-input';\nimport type {\n UsePromptListboxFunctionalityParams,\n UsePromptListboxFunctionality,\n} from './PromptListboxFunctionality.types';\n\nexport function usePromptListboxFunctionality(\n params: UsePromptListboxFunctionalityParams,\n): UsePromptListboxFunctionality {\n const { positioning, onOpenChange, onSelectionModeChange, listboxProps } = params;\n const {\n listboxRef: activeDescendantListboxRef,\n activeParentRef,\n controller: activeDescendantController,\n } = useActiveDescendant<HTMLSpanElement, HTMLDivElement>({\n matchOption: el => el.classList.contains(optionClassNames.root),\n });\n // useMergedRefs to normalize the ref into a React.RefObject type\n const triggerRef = useMergedRefs(activeParentRef);\n const selectionState = useSelection(listboxProps ?? {});\n const { selectOption } = selectionState;\n const optionCollection = useOptionCollection();\n const { getOptionById } = optionCollection;\n const [isInLastPosition, setIsInLastPosition] = React.useState(true);\n const [isInSelectionMode, setIsInSelectionMode] = React.useState(false);\n const [open, setOpen] = useControllableState({\n state: params.open,\n defaultState: params.defaultOpen,\n initialState: false,\n });\n\n const onBlur = (event: React.FocusEvent<HTMLSpanElement>) => {\n setOpen(false);\n onOpenChange?.(event, { event, type: 'focus', open: false });\n };\n\n const onFocus = (event: React.FocusEvent<HTMLSpanElement>) => {\n if (event.target === event.currentTarget) {\n setOpen(true);\n onOpenChange?.(event, { event, type: 'focus', open: true });\n }\n };\n\n const cursorPositionPlugin = <TextCursorPositionPlugin setIsInLastPosition={setIsInLastPosition} />;\n\n const onListboxBlur = React.useCallback(() => {\n setIsInSelectionMode(false);\n onSelectionModeChange?.(false);\n }, [onSelectionModeChange]);\n\n // handle combobox keyboard interaction\n const onKeyDown = useTriggerKeydown({\n ...optionCollection,\n activeDescendantController,\n getOptionById,\n onBlur: onListboxBlur,\n selectOption,\n isInLastPosition,\n open,\n multiselect: false,\n });\n\n // NVDA and JAWS have bugs that suppress reading the input value text when aria-activedescendant is set\n // To prevent this, we clear the HTML attribute (but save the state) when a user presses left/right arrows\n // ref: https://github.com/microsoft/fluentui/issues/26359#issuecomment-1397759888\n const [hideActiveDescendant, setHideActiveDescendant] = React.useState(false);\n\n /**\n * Freeform combobox should not select\n */\n const onInputTriggerKeyDown: EditorInputProps['onKeyDown'] = useEventCallback(event => {\n // update typing state to true if the user is typing\n const action = getDropdownActionFromKey(event, { open, multiselect: false, isInLastPosition });\n if (\n event.key === ArrowLeft ||\n event.key === ArrowRight ||\n (!isInLastPosition && (event.key === ArrowDown || event.key === ArrowUp)) ||\n (action === 'Type' && isInLastPosition) ||\n action === 'Type'\n ) {\n activeDescendantController.blur();\n setHideActiveDescendant(true);\n setIsInSelectionMode(false);\n onSelectionModeChange?.(false);\n } else if (\n action === 'Next' ||\n action === 'Previous' ||\n action === 'First' ||\n action === 'Last' ||\n action === 'PageUp' ||\n action === 'PageDown'\n ) {\n setHideActiveDescendant(false);\n setIsInSelectionMode(true);\n onSelectionModeChange?.(true);\n }\n });\n\n React.useEffect(() => {\n if (hideActiveDescendant) {\n triggerRef.current?.removeAttribute('aria-activedescendant');\n }\n // We only want to run this when the hideActiveDescendant changes, if the triggerRef\n // is undefined, there's no need to remove theAttribute and we shouldn't be adding\n // refs as dependencies since it can blow up the number of runs.\n // eslint-disable-next-line react-compiler/react-compiler\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [hideActiveDescendant]);\n\n const [comboboxPopupRef, comboboxTargetRef] = useComboboxPositioning({ positioning });\n\n const listboxMergedRef = useMergedRefs(comboboxPopupRef, activeDescendantListboxRef, listboxProps?.ref);\n const listbox = React.useMemo(() => {\n return (\n <PromptListbox\n open={open}\n {...listboxProps}\n {...optionCollection}\n {...selectionState}\n ref={listboxMergedRef}\n activeDescendantController={activeDescendantController}\n />\n );\n }, [activeDescendantController, listboxMergedRef, listboxProps, open, optionCollection, selectionState]);\n\n return {\n promptListbox: listbox,\n triggerProps: {\n ref: triggerRef,\n onBlur,\n onFocus,\n onKeyDown: useEventCallback(mergeCallbacks(onKeyDown, onInputTriggerKeyDown)),\n isInSelectionMode,\n },\n containerRef: comboboxTargetRef,\n cursorPositionPlugin,\n };\n}\n"],"names":["React","useActiveDescendant","optionClassNames","mergeCallbacks","useControllableState","useEventCallback","useMergedRefs","getDropdownActionFromKey","TextCursorPositionPlugin","useOptionCollection","useSelection","ArrowDown","ArrowLeft","ArrowRight","ArrowUp","useComboboxPositioning","useTriggerKeydown","PromptListbox","usePromptListboxFunctionality","params","positioning","onOpenChange","onSelectionModeChange","listboxProps","listboxRef","activeDescendantListboxRef","activeParentRef","controller","activeDescendantController","matchOption","el","classList","contains","root","triggerRef","selectionState","selectOption","optionCollection","getOptionById","isInLastPosition","setIsInLastPosition","useState","isInSelectionMode","setIsInSelectionMode","open","setOpen","state","defaultState","defaultOpen","initialState","onBlur","event","type","onFocus","target","currentTarget","cursorPositionPlugin","onListboxBlur","useCallback","onKeyDown","multiselect","hideActiveDescendant","setHideActiveDescendant","onInputTriggerKeyDown","action","key","blur","useEffect","current","removeAttribute","comboboxPopupRef","comboboxTargetRef","listboxMergedRef","ref","list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KAAKtD,aAAawC,MAAMc,GAAG,KAAKnD,OAAM,KACrEkD,WAAW,UAAUzB,oBACtByB,WAAW,QACX;YACApC,2BAA2BsC,IAAI;YAC/BJ,wBAAwB;YACxBnB,qBAAqB;YACrBrB,kCAAAA,4CAAAA,sBAAwB;QAC1B,OAAO,IACL0C,WAAW,UACXA,WAAW,cACXA,WAAW,WACXA,WAAW,UACXA,WAAW,YACXA,WAAW,YACX;YACAF,wBAAwB;YACxBnB,qBAAqB;YACrBrB,kCAAAA,4CAAAA,sBAAwB;QAC1B;IACF;IAEAtB,MAAMmE,SAAS,CAAC;QACd,IAAIN,sBAAsB;gBACxB3B;aAAAA,sBAAAA,WAAWkC,OAAO,cAAlBlC,0CAAAA,oBAAoBmC,eAAe,CAAC;QACtC;IACA,oFAAoF;IACpF,kFAAkF;IAClF,gEAAgE;IAChE,yDAAyD;IACzD,uDAAuD;IACzD,GAAG;QAACR;KAAqB;IAEzB,MAAM,CAACS,kBAAkBC,kBAAkB,GAAGxD,uBAAuB;QAAEK;IAAY;IAEnF,MAAMoD,mBAAmBlE,cAAcgE,kBAAkB7C,4BAA4BF,yBAAAA,mCAAAA,aAAckD,GAAG;IACtG,MAAMC,UAAU1E,MAAM2E,OAAO,CAAC;QAC5B,qBACE,oBAAC1D;YACC2B,MAAMA;YACL,GAAGrB,YAAY;YACf,GAAGc,gBAAgB;YACnB,GAAGF,cAAc;YAClBsC,KAAKD;YACL5C,4BAA4BA;;IAGlC,GAAG;QAACA;QAA4B4C;QAAkBjD;QAAcqB;QAAMP;QAAkBF;KAAe;IAEvG,OAAO;QACLyC,eAAeF;QACfG,cAAc;YACZJ,KAAKvC;YACLgB;YACAG;YACAM,WAAWtD,iBAAiBF,eAAewD,WAAWI;YACtDrB;QACF;QACAoC,cAAcP;QACdf;IACF;AACF"}
package/lib/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export { PromptListbox, promptListboxClassNames, renderPromptListbox_unstable, usePromptListboxStyles_unstable, usePromptListbox_unstable } from './PromptListbox';
2
2
  export { usePromptListboxFunctionality } from './components/utils/usePromptListboxFunctionality';
3
3
  export { TextCursorPositionPlugin } from './plugins/TextCursorPositionPlugin';
4
+ export { PromptOption, promptOptionClassNames, renderPromptOption_unstable, usePromptOptionStyles_unstable, usePromptOption_unstable } from './PromptOption';
4
5
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"sourcesContent":["export type { PromptListboxProps, PromptListboxSlots, PromptListboxState } from './PromptListbox';\nexport {\n PromptListbox,\n promptListboxClassNames,\n renderPromptListbox_unstable,\n usePromptListboxStyles_unstable,\n usePromptListbox_unstable,\n} from './PromptListbox';\n\nexport { usePromptListboxFunctionality } from './components/utils/usePromptListboxFunctionality';\nexport type {\n OnOpenChangeData,\n ProcessedPromptListboxProps,\n UsePromptListboxFunctionality,\n UsePromptListboxFunctionalityParams,\n} from './components/utils/PromptListboxFunctionality.types';\n\nexport type { TextCursorPositionPluginProps } from './plugins/TextCursorPositionPlugin';\nexport { TextCursorPositionPlugin } from './plugins/TextCursorPositionPlugin';\n"],"names":["PromptListbox","promptListboxClassNames","renderPromptListbox_unstable","usePromptListboxStyles_unstable","usePromptListbox_unstable","usePromptListboxFunctionality","TextCursorPositionPlugin"],"rangeMappings":";;","mappings":"AACA,SACEA,aAAa,EACbC,uBAAuB,EACvBC,4BAA4B,EAC5BC,+BAA+B,EAC/BC,yBAAyB,QACpB,kBAAkB;AAEzB,SAASC,6BAA6B,QAAQ,mDAAmD;AASjG,SAASC,wBAAwB,QAAQ,qCAAqC"}
1
+ {"version":3,"sources":["index.ts"],"sourcesContent":["export type { PromptListboxProps, PromptListboxSlots, PromptListboxState } from './PromptListbox';\nexport {\n PromptListbox,\n promptListboxClassNames,\n renderPromptListbox_unstable,\n usePromptListboxStyles_unstable,\n usePromptListbox_unstable,\n} from './PromptListbox';\n\nexport { usePromptListboxFunctionality } from './components/utils/usePromptListboxFunctionality';\nexport type {\n OnOpenChangeData,\n ProcessedPromptListboxProps,\n UsePromptListboxFunctionality,\n UsePromptListboxFunctionalityParams,\n} from './components/utils/PromptListboxFunctionality.types';\n\nexport type { TextCursorPositionPluginProps } from './plugins/TextCursorPositionPlugin';\nexport { TextCursorPositionPlugin } from './plugins/TextCursorPositionPlugin';\n\nexport type { PromptOptionProps, PromptOptionSlots, PromptOptionState } from './PromptOption';\nexport { PromptOption, promptOptionClassNames, renderPromptOption_unstable, usePromptOptionStyles_unstable, usePromptOption_unstable } from './PromptOption';\n"],"names":["PromptListbox","promptListboxClassNames","renderPromptListbox_unstable","usePromptListboxStyles_unstable","usePromptListbox_unstable","usePromptListboxFunctionality","TextCursorPositionPlugin","PromptOption","promptOptionClassNames","renderPromptOption_unstable","usePromptOptionStyles_unstable","usePromptOption_unstable"],"rangeMappings":";;;","mappings":"AACA,SACEA,aAAa,EACbC,uBAAuB,EACvBC,4BAA4B,EAC5BC,+BAA+B,EAC/BC,yBAAyB,QACpB,kBAAkB;AAEzB,SAASC,6BAA6B,QAAQ,mDAAmD;AASjG,SAASC,wBAAwB,QAAQ,qCAAqC;AAG9E,SAASC,YAAY,EAAEC,sBAAsB,EAAEC,2BAA2B,EAAEC,8BAA8B,EAAEC,wBAAwB,QAAQ,iBAAiB"}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ const _export_star = require("@swc/helpers/_/_export_star");
6
+ _export_star._(require("./components/PromptOption/index"), exports);
7
+ //# sourceMappingURL=PromptOption.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["PromptOption.ts"],"sourcesContent":["export * from './components/PromptOption/index';\n"],"names":[],"rangeMappings":";;;;;","mappings":";;;;;uBAAc"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "PromptOption", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return PromptOption;
9
+ }
10
+ });
11
+ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
12
+ const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
13
+ const _usePromptOption = require("./usePromptOption");
14
+ const _renderPromptOption = require("./renderPromptOption");
15
+ const _usePromptOptionStylesstyles = require("./usePromptOptionStyles.styles");
16
+ const PromptOption = /*#__PURE__*/ _react.forwardRef((props, ref)=>{
17
+ const state = (0, _usePromptOption.usePromptOption_unstable)(props, ref);
18
+ (0, _usePromptOptionStylesstyles.usePromptOptionStyles_unstable)(state);
19
+ return (0, _renderPromptOption.renderPromptOption_unstable)(state);
20
+ });
21
+ PromptOption.displayName = 'PromptOption'; //# sourceMappingURL=PromptOption.js.map
@@ -0,0 +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// PromptOption component - TODO: add more docs\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":["PromptOption","React","forwardRef","props","state","usePromptOption_unstable","usePromptOptionStyles_unstable","renderPromptOption_unstable","displayName"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAQaA;;;eAAAA;;;;iEARU;iCACkB;oCACG;6CACG;AAKxC,MAAMA,eAAAA,WAAAA,GAAAA,OAAuDC,UAAMC,CAAU,CAACC,OAACA;UACpFC,QAAMA,IAAAA,yCAAQC,EAAAA,OAAyBF;mEAEvCG,EAAAA;WACAC,IAAAA,+CAAOA,EAAAA;AACT;AAEAP,aAAaQ,WAAW,GAAG"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * State used in rendering PromptOption
3
+ */ "use strict";
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ // TODO: Remove semicolon from previous line, uncomment next line, and provide union of props to pick from PromptOptionProps.
8
+ // & Required<Pick<PromptOptionProps, 'propName'>>
9
+ //# sourceMappingURL=PromptOption.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["PromptOption.types.ts"],"sourcesContent":["import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-components';\n\nexport type PromptOptionSlots = {\n root: Slot<'div'>;\n};\n\n/**\n * PromptOption Props\n */\nexport type PromptOptionProps = ComponentProps<PromptOptionSlots> & {};\n\n/**\n * State used in rendering PromptOption\n */\nexport type PromptOptionState = ComponentState<PromptOptionSlots>;\n// TODO: Remove semicolon from previous line, uncomment next line, and provide union of props to pick from PromptOptionProps.\n// & Required<Pick<PromptOptionProps, 'propName'>>\n"],"names":[],"rangeMappings":";;;;;;;","mappings":"AAWA;;CAEC;;;;CACD,6HACA;mDACA"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ const _export_star = require("@swc/helpers/_/_export_star");
6
+ _export_star._(require("./PromptOption"), exports);
7
+ _export_star._(require("./PromptOption.types"), exports);
8
+ _export_star._(require("./renderPromptOption"), exports);
9
+ _export_star._(require("./usePromptOption"), exports);
10
+ _export_star._(require("./usePromptOptionStyles.styles"), exports);
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["index.ts"],"sourcesContent":["export * from './PromptOption';\nexport * from './PromptOption.types';\nexport * from './renderPromptOption';\nexport * from './usePromptOption';\nexport * from './usePromptOptionStyles.styles';\n"],"names":[],"rangeMappings":";;;;;;;;;","mappings":";;;;;uBAAc;uBACA;uBACA;uBACA;uBACA"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "renderPromptOption_unstable", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return renderPromptOption_unstable;
9
+ }
10
+ });
11
+ const _jsxruntime = require("@fluentui/react-jsx-runtime/jsx-runtime");
12
+ const _reactcomponents = require("@fluentui/react-components");
13
+ const renderPromptOption_unstable = (state)=>{
14
+ (0, _reactcomponents.assertSlots)(state);
15
+ // TODO Add additional slots in the appropriate place
16
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)(state.root, {});
17
+ }; //# sourceMappingURL=renderPromptOption.js.map
@@ -0,0 +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 { PromptOptionState, PromptOptionSlots } 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 // TODO Add additional slots in the appropriate place\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;yDACkB;IAClB,OAAA,WAAA,GAAAC,IAAAA,eAAA,EAAAD,MAAAE,IAAA,EAAA,CAAA"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "usePromptOption_unstable", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return usePromptOption_unstable;
9
+ }
10
+ });
11
+ const _reactcomponents = require("@fluentui/react-components");
12
+ const usePromptOption_unstable = (props, ref)=>{
13
+ return {
14
+ // TODO add appropriate props/defaults
15
+ components: {
16
+ // TODO add each slot's element type or component
17
+ root: 'div'
18
+ },
19
+ // TODO add appropriate slots, for example:
20
+ // mySlot: slot.optional(props.mySlot),
21
+ root: _reactcomponents.slot.always((0, _reactcomponents.getIntrinsicElementProps)('div', {
22
+ ref,
23
+ ...props
24
+ }), {
25
+ elementType: 'div'
26
+ })
27
+ };
28
+ }; //# sourceMappingURL=usePromptOption.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["usePromptOption.ts"],"sourcesContent":["import type * as React from 'react';\nimport { getIntrinsicElementProps, slot } from '@fluentui/react-components';\nimport type { PromptOptionProps, PromptOptionState } from './PromptOption.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 return {\n // TODO add appropriate props/defaults\n components: {\n // TODO add each slot's element type or component\n root: 'div',\n },\n // TODO add appropriate slots, for example:\n // mySlot: slot.optional(props.mySlot),\n root: slot.always(\n getIntrinsicElementProps('div', {\n ref,\n ...props,\n }),\n { elementType: 'div' },\n ),\n };\n};\n"],"names":["usePromptOption_unstable","props","ref","getIntrinsicElementProps"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAmBSA;;;eAAAA;;;iCAlBsC;AAkB7C,MAAOA,2BAAA,CAAAC,OAAAC;WACL;8CACY;oBACV;6DACM;kBACR;;mDAEuC;+CAErCC;mCACED,CAAAA,MAAAA,CAAAA,IAAAA,yCAAAA,EAAAA,OAAAA;;eAEFD,KACA;;yBAAqB;QAEzB;IACA"}
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ promptOptionClassNames: function() {
13
+ return promptOptionClassNames;
14
+ },
15
+ usePromptOptionStyles_unstable: function() {
16
+ return usePromptOptionStyles_unstable;
17
+ }
18
+ });
19
+ const _reactcomponents = require("@fluentui/react-components");
20
+ const promptOptionClassNames = {
21
+ root: 'fai-PromptOption'
22
+ };
23
+ /**
24
+ * Styles for the root slot
25
+ */ const useStyles = (0, _reactcomponents.__styles)({
26
+ root: {}
27
+ }, {});
28
+ const usePromptOptionStyles_unstable = (state)=>{
29
+ 'use no memo';
30
+ const styles = useStyles();
31
+ state.root.className = (0, _reactcomponents.mergeClasses)(promptOptionClassNames.root, styles.root, state.root.className);
32
+ // TODO Add class names to slots, for example:
33
+ // state.mySlot.className = mergeClasses(styles.mySlot, state.mySlot.className);
34
+ return state;
35
+ }; //# sourceMappingURL=usePromptOptionStyles.styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["usePromptOptionStyles.styles.ts"],"sourcesContent":["import { makeStyles, mergeClasses } from '@fluentui/react-components';\nimport type { PromptOptionSlots, PromptOptionState } from './PromptOption.types';\nimport type { SlotClassNames } from '@fluentui/react-components';\n\nexport const promptOptionClassNames: SlotClassNames<PromptOptionSlots> = {\n root: 'fai-PromptOption',\n // TODO: add class names for all slots on PromptOptionSlots.\n // Should be of the form `<slotName>: 'fai-PromptOption__<slotName>`\n};\n\n/**\n * Styles for the root slot\n */\nconst useStyles = makeStyles({\n root: {\n // TODO Add default styles for the root element\n },\n\n // TODO add additional classes for different states and/or slots\n});\n\n/**\n * Apply styling to the PromptOption slots based on the state\n */\nexport const usePromptOptionStyles_unstable = (state: PromptOptionState): PromptOptionState => {\n 'use no memo';\n\n const styles = useStyles();\n state.root.className = mergeClasses(promptOptionClassNames.root, styles.root, state.root.className);\n\n // TODO Add class names to slots, for example:\n // state.mySlot.className = mergeClasses(styles.mySlot, state.mySlot.className);\n\n return state;\n};\n"],"names":["promptOptionClassNames","usePromptOptionStyles_unstable","root","__styles","state","styles","useStyles","className","mergeClasses"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;;;;;;;;IAIaA,sBAAAA;eAAAA;;IAqBXC,8BAAA;eAAAA;;;iCAzB+B;AAI1B,MAAMD,yBAA4D;UACvEE;AAGF;AAEA;;CAEC,SAECA,YAAMC,IAAAA,yBAAA,EAAA;UAEN,CAAA;AAGF,GAAA,CAAA;AAME,MAAAF,iCAAAG,CAAAA;;UAKAC,SAAAC;UACAJ,IAAA,CAAAK,SAAA,GAAAC,IAAAA,6BAAA,EAAAR,uBAAAE,IAAA,EAAAG,OAAAH,IAAA,EAAAE,MAAgFF,IAAA,CAAAK,SAAA;kDAEzEH;IACP,gFAAA"}
@@ -1 +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":""}
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 containerRef is the same as the trigger, the ref provided in triggerProps needs\n * to be merged with this one using `useMergedRefs(containerRef, triggerProps.ref);`\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n containerRef: React.MutableRefObject<any>;\n /**\n * Plugin used to tell where the cursor is in the EditorInput, this is important for the\n * keyboard behavior. This should be passed as children in the PromptInput.\n */\n cursorPositionPlugin: JSX.Element;\n};\n\nexport type UsePromptListboxFunctionalityParams = {\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: EventHandler<OnOpenChangeData>;\n 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":""}
@@ -144,7 +144,7 @@ function usePromptListboxFunctionality(params) {
144
144
  onKeyDown: (0, _reactutilities.useEventCallback)((0, _reactutilities.mergeCallbacks)(onKeyDown, onInputTriggerKeyDown)),
145
145
  isInSelectionMode
146
146
  },
147
- targetRef: comboboxTargetRef,
147
+ containerRef: comboboxTargetRef,
148
148
  cursorPositionPlugin
149
149
  };
150
150
  } //# sourceMappingURL=usePromptListboxFunctionality.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["usePromptListboxFunctionality.tsx"],"sourcesContent":["import * as React from 'react';\nimport { useActiveDescendant } from '@fluentui/react-aria';\nimport { optionClassNames } from '@fluentui/react-components';\nimport { mergeCallbacks, useControllableState, useEventCallback, useMergedRefs } from '@fluentui/react-utilities';\nimport { getDropdownActionFromKey } from './dropdownKeyActions';\nimport { TextCursorPositionPlugin } from '../../plugins/TextCursorPositionPlugin';\nimport { useOptionCollection } from './useOptionCollection';\nimport { useSelection } from './useSelection';\nimport { ArrowDown, ArrowLeft, ArrowRight, ArrowUp } from '@fluentui/keyboard-keys';\nimport { useComboboxPositioning } from './useComboboxPositioning';\nimport { useTriggerKeydown } from './useTriggerKeyDown';\nimport { PromptListbox } from '../PromptListbox';\nimport type { EditorInputProps } from '@fluentui-copilot/react-editor-input';\nimport type {\n UsePromptListboxFunctionalityParams,\n UsePromptListboxFunctionality,\n} from './PromptListboxFunctionality.types';\n\nexport function usePromptListboxFunctionality(\n params: UsePromptListboxFunctionalityParams,\n): UsePromptListboxFunctionality {\n const { positioning, onOpenChange, onSelectionModeChange, listboxProps } = params;\n const {\n listboxRef: activeDescendantListboxRef,\n activeParentRef,\n controller: activeDescendantController,\n } = useActiveDescendant<HTMLSpanElement, HTMLDivElement>({\n matchOption: el => el.classList.contains(optionClassNames.root),\n });\n // useMergedRefs to normalize the ref into a React.RefObject type\n const triggerRef = useMergedRefs(activeParentRef);\n const selectionState = useSelection(listboxProps ?? {});\n const { selectOption } = selectionState;\n const optionCollection = useOptionCollection();\n const { getOptionById } = optionCollection;\n const [isInLastPosition, setIsInLastPosition] = React.useState(true);\n const [isInSelectionMode, setIsInSelectionMode] = React.useState(false);\n const [open, setOpen] = useControllableState({\n state: params.open,\n defaultState: params.defaultOpen,\n initialState: false,\n });\n\n const onBlur = (event: React.FocusEvent<HTMLSpanElement>) => {\n setOpen(false);\n onOpenChange?.(event, { event, type: 'focus', open: false });\n };\n\n const onFocus = (event: React.FocusEvent<HTMLSpanElement>) => {\n if (event.target === event.currentTarget) {\n setOpen(true);\n onOpenChange?.(event, { event, type: 'focus', open: true });\n }\n };\n\n const cursorPositionPlugin = <TextCursorPositionPlugin setIsInLastPosition={setIsInLastPosition} />;\n\n const onListboxBlur = React.useCallback(() => {\n setIsInSelectionMode(false);\n onSelectionModeChange?.(false);\n }, [onSelectionModeChange]);\n\n // handle combobox keyboard interaction\n const onKeyDown = useTriggerKeydown({\n ...optionCollection,\n activeDescendantController,\n getOptionById,\n onBlur: onListboxBlur,\n selectOption,\n isInLastPosition,\n open,\n multiselect: false,\n });\n\n // NVDA and JAWS have bugs that suppress reading the input value text when aria-activedescendant is set\n // To prevent this, we clear the HTML attribute (but save the state) when a user presses left/right arrows\n // ref: https://github.com/microsoft/fluentui/issues/26359#issuecomment-1397759888\n const [hideActiveDescendant, setHideActiveDescendant] = React.useState(false);\n\n /**\n * Freeform combobox should not select\n */\n const onInputTriggerKeyDown: EditorInputProps['onKeyDown'] = useEventCallback(event => {\n // update typing state to true if the user is typing\n const action = getDropdownActionFromKey(event, { open, multiselect: false, isInLastPosition });\n if (\n event.key === ArrowLeft ||\n event.key === ArrowRight ||\n (!isInLastPosition && (event.key === ArrowDown || event.key === ArrowUp)) ||\n (action === 'Type' && isInLastPosition) ||\n action === 'Type'\n ) {\n activeDescendantController.blur();\n setHideActiveDescendant(true);\n setIsInSelectionMode(false);\n onSelectionModeChange?.(false);\n } else if (\n action === 'Next' ||\n action === 'Previous' ||\n action === 'First' ||\n action === 'Last' ||\n action === 'PageUp' ||\n action === 'PageDown'\n ) {\n setHideActiveDescendant(false);\n setIsInSelectionMode(true);\n onSelectionModeChange?.(true);\n }\n });\n\n React.useEffect(() => {\n if (hideActiveDescendant) {\n triggerRef.current?.removeAttribute('aria-activedescendant');\n }\n // We only want to run this when the hideActiveDescendant changes, if the triggerRef\n // is undefined, there's no need to remove theAttribute and we shouldn't be adding\n // refs as dependencies since it can blow up the number of runs.\n // eslint-disable-next-line react-compiler/react-compiler\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [hideActiveDescendant]);\n\n const [comboboxPopupRef, comboboxTargetRef] = useComboboxPositioning({ positioning });\n\n const listboxMergedRef = useMergedRefs(comboboxPopupRef, activeDescendantListboxRef, listboxProps?.ref);\n const listbox = React.useMemo(() => {\n return (\n <PromptListbox\n open={open}\n {...listboxProps}\n {...optionCollection}\n {...selectionState}\n ref={listboxMergedRef}\n activeDescendantController={activeDescendantController}\n />\n );\n }, [activeDescendantController, listboxMergedRef, listboxProps, open, optionCollection, selectionState]);\n\n return {\n promptListbox: listbox,\n triggerProps: {\n ref: triggerRef,\n onBlur,\n onFocus,\n onKeyDown: useEventCallback(mergeCallbacks(onKeyDown, onInputTriggerKeyDown)),\n isInSelectionMode,\n },\n targetRef: comboboxTargetRef,\n cursorPositionPlugin,\n };\n}\n"],"names":["usePromptListboxFunctionality","params","positioning","listboxRef","matchOption","onSelectionModeChange","listboxProps","selectOption","selectionState","activeParentRef","optionCollection","controller","getOptionById","useActiveDescendant","isInLastPosition","isInSelectionMode","setIsInSelectionMode","useState","defaultState","defaultOpen","initialState","useSelection","onBlur","onOpenChange","type","setIsInLastPosition","React","open","onFocus","event","target","setOpen","cursorPositionPlugin","onListboxBlur","currentTarget","onKeyDown","useTriggerKeydown","activeDescendantController","onInputTriggerKeyDown","useEventCallback","action","hideActiveDescendant","key","ArrowRight","ArrowDown","ArrowUp","triggerRef","setHideActiveDescendant","useEffect","comboboxTargetRef","_triggerRef_current","current","removeAttribute","PromptListbox","listboxMergedRef","useMergedRefs","comboboxPopupRef","activeDescendantListboxRef","ref","targetRef"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAkBgBA;;;eAAAA;;;;iEAlBO;2BACa;iCACH;gCACqD;oCAC7C;0CACA;q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GAAAA,OAAAA,aAAAA,CAAAA,4BAAAA,EAAAA;kBAAkBhD;eAAcqB,YAAAA;eAAMjB,gBAAAA;eAAkBF,cAAAA;YAAekD,KAAAJ;YAEvGjB,4BAAOA;;;;QAESiB;QAAAhD;QAAAqB;QAAAjB;QAAAF;KAAA;;uBAEZc;sBACAM;;;;uBAIF+B,IAAAA,gCAAWV,EAAAA,IAAAA,8BAAAA,EAAAA,WAAAA;;QAEb;QACFU,WAAAV"}
1
+ {"version":3,"sources":["usePromptListboxFunctionality.tsx"],"sourcesContent":["import * as React from 'react';\nimport { useActiveDescendant } from '@fluentui/react-aria';\nimport { optionClassNames } from '@fluentui/react-components';\nimport { mergeCallbacks, useControllableState, useEventCallback, useMergedRefs } from '@fluentui/react-utilities';\nimport { getDropdownActionFromKey } from './dropdownKeyActions';\nimport { TextCursorPositionPlugin } from '../../plugins/TextCursorPositionPlugin';\nimport { useOptionCollection } from './useOptionCollection';\nimport { useSelection } from './useSelection';\nimport { ArrowDown, ArrowLeft, ArrowRight, ArrowUp } from '@fluentui/keyboard-keys';\nimport { useComboboxPositioning } from './useComboboxPositioning';\nimport { useTriggerKeydown } from './useTriggerKeyDown';\nimport { PromptListbox } from '../PromptListbox';\nimport type { EditorInputProps } from '@fluentui-copilot/react-editor-input';\nimport type {\n UsePromptListboxFunctionalityParams,\n UsePromptListboxFunctionality,\n} from './PromptListboxFunctionality.types';\n\nexport function usePromptListboxFunctionality(\n params: UsePromptListboxFunctionalityParams,\n): UsePromptListboxFunctionality {\n const { positioning, onOpenChange, onSelectionModeChange, listboxProps } = params;\n const {\n listboxRef: activeDescendantListboxRef,\n activeParentRef,\n controller: activeDescendantController,\n } = useActiveDescendant<HTMLSpanElement, HTMLDivElement>({\n matchOption: el => el.classList.contains(optionClassNames.root),\n });\n // useMergedRefs to normalize the ref into a React.RefObject type\n const triggerRef = useMergedRefs(activeParentRef);\n const selectionState = useSelection(listboxProps ?? {});\n const { selectOption } = selectionState;\n const optionCollection = useOptionCollection();\n const { getOptionById } = optionCollection;\n const [isInLastPosition, setIsInLastPosition] = React.useState(true);\n const [isInSelectionMode, setIsInSelectionMode] = React.useState(false);\n const [open, setOpen] = useControllableState({\n state: params.open,\n defaultState: params.defaultOpen,\n initialState: false,\n });\n\n const onBlur = (event: React.FocusEvent<HTMLSpanElement>) => {\n setOpen(false);\n onOpenChange?.(event, { event, type: 'focus', open: false });\n };\n\n const onFocus = (event: React.FocusEvent<HTMLSpanElement>) => {\n if (event.target === event.currentTarget) {\n setOpen(true);\n onOpenChange?.(event, { event, type: 'focus', open: true });\n }\n };\n\n const cursorPositionPlugin = <TextCursorPositionPlugin setIsInLastPosition={setIsInLastPosition} />;\n\n const onListboxBlur = React.useCallback(() => {\n setIsInSelectionMode(false);\n onSelectionModeChange?.(false);\n }, [onSelectionModeChange]);\n\n // handle combobox keyboard interaction\n const onKeyDown = useTriggerKeydown({\n ...optionCollection,\n activeDescendantController,\n getOptionById,\n onBlur: onListboxBlur,\n selectOption,\n isInLastPosition,\n open,\n multiselect: false,\n });\n\n // NVDA and JAWS have bugs that suppress reading the input value text when aria-activedescendant is set\n // To prevent this, we clear the HTML attribute (but save the state) when a user presses left/right arrows\n // ref: https://github.com/microsoft/fluentui/issues/26359#issuecomment-1397759888\n const [hideActiveDescendant, setHideActiveDescendant] = React.useState(false);\n\n /**\n * Freeform combobox should not select\n */\n const onInputTriggerKeyDown: EditorInputProps['onKeyDown'] = useEventCallback(event => {\n // update typing state to true if the user is typing\n const action = getDropdownActionFromKey(event, { open, multiselect: false, isInLastPosition });\n if (\n event.key === ArrowLeft ||\n event.key === ArrowRight ||\n (!isInLastPosition && (event.key === ArrowDown || event.key === ArrowUp)) ||\n (action === 'Type' && isInLastPosition) ||\n action === 'Type'\n ) {\n activeDescendantController.blur();\n setHideActiveDescendant(true);\n setIsInSelectionMode(false);\n onSelectionModeChange?.(false);\n } else if (\n action === 'Next' ||\n action === 'Previous' ||\n action === 'First' ||\n action === 'Last' ||\n action === 'PageUp' ||\n action === 'PageDown'\n ) {\n setHideActiveDescendant(false);\n setIsInSelectionMode(true);\n onSelectionModeChange?.(true);\n }\n });\n\n React.useEffect(() => {\n if (hideActiveDescendant) {\n triggerRef.current?.removeAttribute('aria-activedescendant');\n }\n // We only want to run this when the hideActiveDescendant changes, if the triggerRef\n // is undefined, there's no need to remove theAttribute and we shouldn't be adding\n // refs as dependencies since it can blow up the number of runs.\n // eslint-disable-next-line react-compiler/react-compiler\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [hideActiveDescendant]);\n\n const [comboboxPopupRef, comboboxTargetRef] = useComboboxPositioning({ positioning });\n\n const listboxMergedRef = useMergedRefs(comboboxPopupRef, activeDescendantListboxRef, listboxProps?.ref);\n const listbox = React.useMemo(() => {\n return (\n <PromptListbox\n open={open}\n {...listboxProps}\n {...optionCollection}\n {...selectionState}\n ref={listboxMergedRef}\n activeDescendantController={activeDescendantController}\n />\n );\n }, [activeDescendantController, listboxMergedRef, listboxProps, open, optionCollection, selectionState]);\n\n return {\n promptListbox: listbox,\n triggerProps: {\n ref: triggerRef,\n onBlur,\n onFocus,\n onKeyDown: useEventCallback(mergeCallbacks(onKeyDown, onInputTriggerKeyDown)),\n isInSelectionMode,\n },\n containerRef: comboboxTargetRef,\n cursorPositionPlugin,\n };\n}\n"],"names":["usePromptListboxFunctionality","params","positioning","listboxRef","matchOption","onSelectionModeChange","listboxProps","selectOption","selectionState","activeParentRef","optionCollection","controller","getOptionById","useActiveDescendant","isInLastPosition","isInSelectionMode","setIsInSelectionMode","useState","defaultState","defaultOpen","initialState","useSelection","onBlur","onOpenChange","type","setIsInLastPosition","React","open","onFocus","event","target","setOpen","cursorPositionPlugin","onListboxBlur","currentTarget","onKeyDown","useTriggerKeydown","activeDescendantController","onInputTriggerKeyDown","useEventCallback","action","hideActiveDescendant","key","ArrowRight","ArrowDown","ArrowUp","triggerRef","setHideActiveDescendant","useEffect","comboboxTargetRef","_triggerRef_current","current","removeAttribute","PromptListbox","listboxM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A,KAAA,IAAAA,oBAAAE,eAAA,CAAA;QAEnF;IACA,oFAA8B;sFAEzBC;oEACO1B;6DACU;2DACI;;;KAChBnB;6BACC8C,kBAAAA,GAAAA,IAAAA,8CAAAA,EAAAA;;;UAIRA,mBAAAC,IAAAA,6BAAA,EAAAC,kBAAAC,4BAAAnD,iBAAA,QAAAA,iBAAA,KAAA,IAAA,KAAA,IAAAA,aAAAoD,GAAA;UAACrB,UAAAA,OAAAA,OAAAA,CAAAA;eAA4BiB,WAAAA,GAAAA,OAAAA,aAAAA,CAAAA,4BAAAA,EAAAA;kBAAkBhD;eAAcqB,YAAAA;eAAMjB,gBAAAA;eAAkBF,cAAAA;YAAekD,KAAAJ;YAEvGjB,4BAAOA;;;;QAESiB;QAAAhD;QAAAqB;QAAAjB;QAAAF;KAAA;;uBAEZc;sBACAM;;;;uBAIF+B,IAAAA,gCAAcV,EAAAA,IAAAA,8BAAAA,EAAAA,WAAAA;;QAEhB;QACFU,cAAAV"}
@@ -12,15 +12,24 @@ _export(exports, {
12
12
  PromptListbox: function() {
13
13
  return _PromptListbox.PromptListbox;
14
14
  },
15
+ PromptOption: function() {
16
+ return _PromptOption.PromptOption;
17
+ },
15
18
  TextCursorPositionPlugin: function() {
16
19
  return _TextCursorPositionPlugin.TextCursorPositionPlugin;
17
20
  },
18
21
  promptListboxClassNames: function() {
19
22
  return _PromptListbox.promptListboxClassNames;
20
23
  },
24
+ promptOptionClassNames: function() {
25
+ return _PromptOption.promptOptionClassNames;
26
+ },
21
27
  renderPromptListbox_unstable: function() {
22
28
  return _PromptListbox.renderPromptListbox_unstable;
23
29
  },
30
+ renderPromptOption_unstable: function() {
31
+ return _PromptOption.renderPromptOption_unstable;
32
+ },
24
33
  usePromptListboxFunctionality: function() {
25
34
  return _usePromptListboxFunctionality.usePromptListboxFunctionality;
26
35
  },
@@ -29,9 +38,16 @@ _export(exports, {
29
38
  },
30
39
  usePromptListbox_unstable: function() {
31
40
  return _PromptListbox.usePromptListbox_unstable;
41
+ },
42
+ usePromptOptionStyles_unstable: function() {
43
+ return _PromptOption.usePromptOptionStyles_unstable;
44
+ },
45
+ usePromptOption_unstable: function() {
46
+ return _PromptOption.usePromptOption_unstable;
32
47
  }
33
48
  });
34
49
  const _PromptListbox = require("./PromptListbox");
35
50
  const _usePromptListboxFunctionality = require("./components/utils/usePromptListboxFunctionality");
36
51
  const _TextCursorPositionPlugin = require("./plugins/TextCursorPositionPlugin");
52
+ const _PromptOption = require("./PromptOption");
37
53
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"sourcesContent":["export type { PromptListboxProps, PromptListboxSlots, PromptListboxState } from './PromptListbox';\nexport {\n PromptListbox,\n promptListboxClassNames,\n renderPromptListbox_unstable,\n usePromptListboxStyles_unstable,\n usePromptListbox_unstable,\n} from './PromptListbox';\n\nexport { usePromptListboxFunctionality } from './components/utils/usePromptListboxFunctionality';\nexport type {\n OnOpenChangeData,\n ProcessedPromptListboxProps,\n UsePromptListboxFunctionality,\n UsePromptListboxFunctionalityParams,\n} from './components/utils/PromptListboxFunctionality.types';\n\nexport type { TextCursorPositionPluginProps } from './plugins/TextCursorPositionPlugin';\nexport { TextCursorPositionPlugin } from './plugins/TextCursorPositionPlugin';\n"],"names":["PromptListbox","TextCursorPositionPlugin","promptListboxClassNames","renderPromptListbox_unstable","usePromptListboxFunctionality","usePromptListboxStyles_unstable","usePromptListbox_unstable"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;;;;;;;;IAEEA,aAAa;eAAbA,4BAAa;;IAgBNC,wBAAwB;eAAxBA,kDAAwB;;IAf/BC,uBAAuB;eAAvBA,sCAAuB;;IACvBC,4BAA4B;eAA5BA,2CAA4B;;IAKrBC,6BAA6B;eAA7BA,4DAA6B;;IAJpCC,+BAA+B;eAA/BA,8CAA+B;;IAC/BC,yBAAyB;eAAzBA,wCAAyB;;;+BACpB;+CAEuC;0CASL"}
1
+ {"version":3,"sources":["index.ts"],"sourcesContent":["export type { PromptListboxProps, PromptListboxSlots, PromptListboxState } from './PromptListbox';\nexport {\n PromptListbox,\n promptListboxClassNames,\n renderPromptListbox_unstable,\n usePromptListboxStyles_unstable,\n usePromptListbox_unstable,\n} from './PromptListbox';\n\nexport { usePromptListboxFunctionality } from './components/utils/usePromptListboxFunctionality';\nexport type {\n OnOpenChangeData,\n ProcessedPromptListboxProps,\n UsePromptListboxFunctionality,\n UsePromptListboxFunctionalityParams,\n} from './components/utils/PromptListboxFunctionality.types';\n\nexport type { TextCursorPositionPluginProps } from './plugins/TextCursorPositionPlugin';\nexport { TextCursorPositionPlugin } from './plugins/TextCursorPositionPlugin';\n\nexport type { PromptOptionProps, PromptOptionSlots, PromptOptionState } from './PromptOption';\nexport { PromptOption, promptOptionClassNames, renderPromptOption_unstable, usePromptOptionStyles_unstable, usePromptOption_unstable } from './PromptOption';\n"],"names":["PromptListbox","PromptOption","TextCursorPositionPlugin","promptListboxClassNames","promptOptionClassNames","renderPromptListbox_unstable","renderPromptOption_unstable","usePromptListboxFunctionality","usePromptListboxStyles_unstable","usePromptListbox_unstable","usePromptOptionStyles_unstable","usePromptOption_unstable"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;;;;;;;;IAEEA,aAAa;eAAbA,4BAAa;;IAmBNC,YAAY;eAAZA,0BAAY;;IAHZC,wBAAwB;eAAxBA,kDAAwB;;IAf/BC,uBAAuB;eAAvBA,sCAAuB;;IAkBFC,sBAAsB;eAAtBA,oCAAsB;;IAjB3CC,4BAA4B;eAA5BA,2CAA4B;;IAiBiBC,2BAA2B;eAA3BA,yCAA2B;;IAZjEC,6BAA6B;eAA7BA,4DAA6B;;IAJpCC,+BAA+B;eAA/BA,8CAA+B;;IAC/BC,yBAAyB;eAAzBA,wCAAyB;;IAeiDC,8BAA8B;eAA9BA,4CAA8B;;IAAEC,wBAAwB;eAAxBA,sCAAwB;;;+BAd7H;+CAEuC;0CASL;8BAGmG"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluentui-copilot/react-prompt-listbox",
3
- "version": "0.0.0-nightly-20240719-0406-ee8d99d6.1",
3
+ "version": "0.0.0-nightly-20240722-0406-476bfcb7.1",
4
4
  "description": "PromptListbox for input components using EditorInput.",
5
5
  "main": "lib-commonjs/index.js",
6
6
  "module": "lib/index.js",
@@ -12,12 +12,12 @@
12
12
  },
13
13
  "license": "MIT",
14
14
  "dependencies": {
15
- "@fluentui-copilot/chat-input-plugins": "0.0.0-nightly-20240719-0406-ee8d99d6.1",
16
- "@fluentui-copilot/react-chat-input-plugins": "0.0.0-nightly-20240719-0406-ee8d99d6.1",
17
- "@fluentui-copilot/react-editor-input": "0.0.0-nightly-20240719-0406-ee8d99d6.1",
18
- "@fluentui-copilot/react-provider": "0.0.0-nightly-20240719-0406-ee8d99d6.1",
19
- "@fluentui-copilot/react-text-editor": "0.0.0-nightly-20240719-0406-ee8d99d6.1",
20
- "@fluentui-copilot/text-editor": "0.0.0-nightly-20240719-0406-ee8d99d6.1",
15
+ "@fluentui-copilot/chat-input-plugins": "0.0.0-nightly-20240722-0406-476bfcb7.1",
16
+ "@fluentui-copilot/react-chat-input-plugins": "0.0.0-nightly-20240722-0406-476bfcb7.1",
17
+ "@fluentui-copilot/react-editor-input": "0.0.0-nightly-20240722-0406-476bfcb7.1",
18
+ "@fluentui-copilot/react-provider": "0.0.0-nightly-20240722-0406-476bfcb7.1",
19
+ "@fluentui-copilot/react-text-editor": "0.0.0-nightly-20240722-0406-476bfcb7.1",
20
+ "@fluentui-copilot/text-editor": "0.0.0-nightly-20240722-0406-476bfcb7.1",
21
21
  "@swc/helpers": "^0.5.1"
22
22
  },
23
23
  "peerDependencies": {