@fluentui-copilot/react-editor-input 0.0.0-nightly-20240606-0406-a04dfe79.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 (38) hide show
  1. package/CHANGELOG.json +38 -0
  2. package/CHANGELOG.md +16 -0
  3. package/LICENSE +23 -0
  4. package/README.md +5 -0
  5. package/dist/index.d.ts +101 -0
  6. package/lib/EditorInput.js +2 -0
  7. package/lib/EditorInput.js.map +1 -0
  8. package/lib/components/EditorInput/EditorInput.js +12 -0
  9. package/lib/components/EditorInput/EditorInput.js.map +1 -0
  10. package/lib/components/EditorInput/EditorInput.types.js +4 -0
  11. package/lib/components/EditorInput/EditorInput.types.js.map +1 -0
  12. package/lib/components/EditorInput/index.js +6 -0
  13. package/lib/components/EditorInput/index.js.map +1 -0
  14. package/lib/components/EditorInput/renderEditorInput.js +30 -0
  15. package/lib/components/EditorInput/renderEditorInput.js.map +1 -0
  16. package/lib/components/EditorInput/useEditorInput.js +128 -0
  17. package/lib/components/EditorInput/useEditorInput.js.map +1 -0
  18. package/lib/components/EditorInput/useEditorInputStyles.styles.js +57 -0
  19. package/lib/components/EditorInput/useEditorInputStyles.styles.js.map +1 -0
  20. package/lib/index.js +2 -0
  21. package/lib/index.js.map +1 -0
  22. package/lib-commonjs/EditorInput.js +7 -0
  23. package/lib-commonjs/EditorInput.js.map +1 -0
  24. package/lib-commonjs/components/EditorInput/EditorInput.js +21 -0
  25. package/lib-commonjs/components/EditorInput/EditorInput.js.map +1 -0
  26. package/lib-commonjs/components/EditorInput/EditorInput.types.js +7 -0
  27. package/lib-commonjs/components/EditorInput/EditorInput.types.js.map +1 -0
  28. package/lib-commonjs/components/EditorInput/index.js +11 -0
  29. package/lib-commonjs/components/EditorInput/index.js.map +1 -0
  30. package/lib-commonjs/components/EditorInput/renderEditorInput.js +43 -0
  31. package/lib-commonjs/components/EditorInput/renderEditorInput.js.map +1 -0
  32. package/lib-commonjs/components/EditorInput/useEditorInput.js +142 -0
  33. package/lib-commonjs/components/EditorInput/useEditorInput.js.map +1 -0
  34. package/lib-commonjs/components/EditorInput/useEditorInputStyles.styles.js +95 -0
  35. package/lib-commonjs/components/EditorInput/useEditorInputStyles.styles.js.map +1 -0
  36. package/lib-commonjs/index.js +29 -0
  37. package/lib-commonjs/index.js.map +1 -0
  38. package/package.json +39 -0
package/CHANGELOG.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "@fluentui-copilot/react-editor-input",
3
+ "entries": [
4
+ {
5
+ "date": "Thu, 06 Jun 2024 04:13:07 GMT",
6
+ "tag": "@fluentui-copilot/react-editor-input_v0.0.0-nightly-20240606-0406-a04dfe79.1",
7
+ "version": "0.0.0-nightly-20240606-0406-a04dfe79.1",
8
+ "comments": {
9
+ "prerelease": [
10
+ {
11
+ "author": "fluentui-internal@service.microsoft.com",
12
+ "package": "@fluentui-copilot/react-editor-input",
13
+ "commit": "not available",
14
+ "comment": "Release nightly"
15
+ },
16
+ {
17
+ "author": "beachball",
18
+ "package": "@fluentui-copilot/react-editor-input",
19
+ "comment": "Bump @fluentui-copilot/chat-input-plugins to v0.0.0-nightly-20240606-0406-a04dfe79.1",
20
+ "commit": "cb816fbdda3d217f11d702a97bdc55cb412c9da5"
21
+ },
22
+ {
23
+ "author": "beachball",
24
+ "package": "@fluentui-copilot/react-editor-input",
25
+ "comment": "Bump @fluentui-copilot/react-chat-input-plugins to v0.0.0-nightly-20240606-0406-a04dfe79.1",
26
+ "commit": "cb816fbdda3d217f11d702a97bdc55cb412c9da5"
27
+ },
28
+ {
29
+ "author": "beachball",
30
+ "package": "@fluentui-copilot/react-editor-input",
31
+ "comment": "Bump @fluentui-copilot/react-text-editor to v0.0.0-nightly-20240606-0406-a04dfe79.1",
32
+ "commit": "cb816fbdda3d217f11d702a97bdc55cb412c9da5"
33
+ }
34
+ ]
35
+ }
36
+ }
37
+ ]
38
+ }
package/CHANGELOG.md ADDED
@@ -0,0 +1,16 @@
1
+ # Change Log - @fluentui-copilot/react-editor-input
2
+
3
+ This log was last generated on Thu, 06 Jun 2024 04:13:07 GMT and should not be manually modified.
4
+
5
+ <!-- Start content -->
6
+
7
+ ## [0.0.0-nightly-20240606-0406-a04dfe79.1](https://github.com/microsoft/fluentai/tree/@fluentui-copilot/react-editor-input_v0.0.0-nightly-20240606-0406-a04dfe79.1)
8
+
9
+ Thu, 06 Jun 2024 04:13:07 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-20240606-0406-a04dfe79.1 ([commit](https://github.com/microsoft/fluentai/commit/cb816fbdda3d217f11d702a97bdc55cb412c9da5) by beachball)
15
+ - Bump @fluentui-copilot/react-chat-input-plugins to v0.0.0-nightly-20240606-0406-a04dfe79.1 ([commit](https://github.com/microsoft/fluentai/commit/cb816fbdda3d217f11d702a97bdc55cb412c9da5) by beachball)
16
+ - Bump @fluentui-copilot/react-text-editor to v0.0.0-nightly-20240606-0406-a04dfe79.1 ([commit](https://github.com/microsoft/fluentai/commit/cb816fbdda3d217f11d702a97bdc55cb412c9da5) by beachball)
package/LICENSE ADDED
@@ -0,0 +1,23 @@
1
+ @fluentui-copilot/react-editor-input
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
@@ -0,0 +1,5 @@
1
+ # @fluentui-copilot/react-editor-input
2
+
3
+ **For internal use only. External use is not supported at this time.**
4
+
5
+ **React Editor Input components for [Fluent AI React](https://ai.fluentui.dev/)**
@@ -0,0 +1,101 @@
1
+ /// <reference types="react" />
2
+
3
+ import type { ComponentProps } from '@fluentui/react-components';
4
+ import type { ComponentState } from '@fluentui/react-components';
5
+ import type { ForwardRefComponent } from '@fluentui/react-components';
6
+ import { InitialConfigType } from '@lexical/react/LexicalComposer';
7
+ import { LexicalEditor } from 'lexical';
8
+ import { PlainTextPlugin } from '@lexical/react/LexicalPlainTextPlugin';
9
+ import * as React_2 from 'react';
10
+ import type { Slot } from '@fluentui/react-components';
11
+ import type { SlotClassNames } from '@fluentui/react-components';
12
+
13
+ export declare const EditorInput: ForwardRefComponent<EditorInputProps>;
14
+
15
+ export declare const editorInputClassNames: SlotClassNames<EditorInputSlots>;
16
+
17
+ /**
18
+ * EditorInput Props
19
+ */
20
+ export declare type EditorInputProps = Omit<ComponentProps<Partial<EditorInputSlots>, 'input'>, 'onChange' | 'onPaste' | 'defaultValue' | 'onSubmit'> & {
21
+ disabled?: boolean;
22
+ /**
23
+ * If defaultValue is a string, it will be added to the input on first render.
24
+ * If defaultValue is a function, it can call lexical $ functions to imperatively set the initial content with more complex nodes.
25
+ */
26
+ defaultValue?: string | (() => void);
27
+ /**
28
+ * Callback for when the user changes the value.
29
+ * TODO: Add proper event type for callback
30
+ */
31
+ onChange?: (ev: any, data: EditorInputValueData) => void;
32
+ /**
33
+ * Callback for when content is pasted into the Editor.
34
+ */
35
+ onPaste?: (ev: ClipboardEvent) => void;
36
+ /**
37
+ * When true, the input will be cleared when only whitespace is remaining.
38
+ * @default false
39
+ */
40
+ trimWhiteSpace?: boolean;
41
+ /**
42
+ * Used to register any custom nodes used by plugins added. Can also be used to override the default nodes.
43
+ */
44
+ customNodes?: InitialConfigType['nodes'];
45
+ /**
46
+ * The plugin which is in charge of initializing Lexical and is given the `input` and `placeholder` slots
47
+ * @default LexicalPlainTextPlugin
48
+ */
49
+ textPlugin?: typeof PlainTextPlugin;
50
+ /**
51
+ * Controls whether history is tracked to provide undo and redo functionality
52
+ * @default true
53
+ */
54
+ history?: boolean;
55
+ };
56
+
57
+ export declare type EditorInputSlots = {
58
+ root: NonNullable<Slot<'span'>>;
59
+ input: NonNullable<Slot<'span'>>;
60
+ placeholderValue?: Slot<'span'>;
61
+ };
62
+
63
+ /**
64
+ * State used in rendering EditorInput
65
+ */
66
+ export declare type EditorInputState = ComponentState<EditorInputSlots> & Required<Pick<EditorInputProps, 'disabled' | 'textPlugin' | 'history' | 'trimWhiteSpace'>> & Partial<Pick<EditorInputProps, 'onPaste'>> & {
67
+ lexicalInitialConfig: InitialConfigType;
68
+ editorRef: React.RefObject<LexicalEditor>;
69
+ defaultValue?: string;
70
+ handleOnChange: (value: string) => void;
71
+ };
72
+
73
+ /**
74
+ * Data passed to the `onChange` callback when the chat input's value changes.
75
+ */
76
+ export declare type EditorInputValueData = {
77
+ value: string;
78
+ };
79
+
80
+ /**
81
+ * Render the final JSX of EditorInput
82
+ */
83
+ export declare const renderEditorInput_unstable: (state: EditorInputState) => JSX.Element;
84
+
85
+ /**
86
+ * Create the state required to render EditorInput.
87
+ *
88
+ * The returned state can be modified with hooks such as useEditorInputStyles_unstable,
89
+ * before being passed to renderEditorInput_unstable.
90
+ *
91
+ * @param props - props from this instance of EditorInput
92
+ * @param ref - reference to root HTMLElement of EditorInput
93
+ */
94
+ export declare const useEditorInput_unstable: (props: EditorInputProps, ref: React_2.Ref<HTMLSpanElement>) => EditorInputState;
95
+
96
+ /**
97
+ * Apply styling to the EditorInput slots based on the state
98
+ */
99
+ export declare const useEditorInputStyles_unstable: (state: EditorInputState) => EditorInputState;
100
+
101
+ export { }
@@ -0,0 +1,2 @@
1
+ export * from './components/EditorInput/index';
2
+ //# sourceMappingURL=EditorInput.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["EditorInput.ts"],"sourcesContent":["export * from './components/EditorInput/index';\n"],"names":[],"rangeMappings":"","mappings":"AAAA,cAAc,iCAAiC"}
@@ -0,0 +1,12 @@
1
+ import * as React from 'react';
2
+ import { useEditorInput_unstable } from './useEditorInput';
3
+ import { renderEditorInput_unstable } from './renderEditorInput';
4
+ import { useEditorInputStyles_unstable } from './useEditorInputStyles.styles';
5
+ // EditorInput component - TODO: add more docs
6
+ export const EditorInput = /*#__PURE__*/React.forwardRef((props, ref) => {
7
+ const state = useEditorInput_unstable(props, ref);
8
+ useEditorInputStyles_unstable(state);
9
+ return renderEditorInput_unstable(state);
10
+ });
11
+ EditorInput.displayName = 'EditorInput';
12
+ //# sourceMappingURL=EditorInput.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["EditorInput.tsx"],"sourcesContent":["import * as React from 'react';\nimport { useEditorInput_unstable } from './useEditorInput';\nimport { renderEditorInput_unstable } from './renderEditorInput';\nimport { useEditorInputStyles_unstable } from './useEditorInputStyles.styles';\nimport type { EditorInputProps } from './EditorInput.types';\nimport type { ForwardRefComponent } from '@fluentui/react-components';\n\n// EditorInput component - TODO: add more docs\nexport const EditorInput: ForwardRefComponent<EditorInputProps> = React.forwardRef((props, ref) => {\n const state = useEditorInput_unstable(props, ref);\n\n useEditorInputStyles_unstable(state);\n return renderEditorInput_unstable(state);\n});\n\nEditorInput.displayName = 'EditorInput';\n"],"names":["React","useEditorInput_unstable","renderEditorInput_unstable","useEditorInputStyles_unstable","EditorInput","forwardRef","props","ref","state","displayName"],"rangeMappings":";;;;;;;;;;","mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,uBAAuB,QAAQ,mBAAmB;AAC3D,SAASC,0BAA0B,QAAQ,sBAAsB;AACjE,SAASC,6BAA6B,QAAQ,gCAAgC;AAI9E,8CAA8C;AAC9C,OAAO,MAAMC,4BAAqDJ,MAAMK,UAAU,CAAC,CAACC,OAAOC;IACzF,MAAMC,QAAQP,wBAAwBK,OAAOC;IAE7CJ,8BAA8BK;IAC9B,OAAON,2BAA2BM;AACpC,GAAG;AAEHJ,YAAYK,WAAW,GAAG"}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Data passed to the `onChange` callback when the chat input's value changes.
3
+ */export {};
4
+ //# sourceMappingURL=EditorInput.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["EditorInput.types.ts"],"sourcesContent":["import type { InitialConfigType, LexicalEditor, LexicalPlainTextPlugin } from '@fluentui-copilot/react-text-editor';\nimport type { ComponentProps, ComponentState, Slot } from '@fluentui/react-components';\n\nexport type EditorInputSlots = {\n root: NonNullable<Slot<'span'>>;\n input: NonNullable<Slot<'span'>>;\n placeholderValue?: Slot<'span'>;\n};\n\n/**\n * EditorInput Props\n */\nexport type EditorInputProps = Omit<\n ComponentProps<Partial<EditorInputSlots>, 'input'>,\n 'onChange' | 'onPaste' | 'defaultValue' | 'onSubmit'\n> & {\n disabled?: boolean;\n /**\n * If defaultValue is a string, it will be added to the input on first render.\n * If defaultValue is a function, it can call lexical $ functions to imperatively set the initial content with more complex nodes.\n */\n defaultValue?: string | (() => void);\n /**\n * Callback for when the user changes the value.\n * TODO: Add proper event type for callback\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n onChange?: (ev: any, data: EditorInputValueData) => void;\n /**\n * Callback for when content is pasted into the Editor.\n */\n onPaste?: (ev: ClipboardEvent) => void;\n /**\n * When true, the input will be cleared when only whitespace is remaining.\n * @default false\n */\n trimWhiteSpace?: boolean;\n /**\n * Used to register any custom nodes used by plugins added. Can also be used to override the default nodes.\n */\n customNodes?: InitialConfigType['nodes'];\n /**\n * The plugin which is in charge of initializing Lexical and is given the `input` and `placeholder` slots\n * @default LexicalPlainTextPlugin\n */\n textPlugin?: typeof LexicalPlainTextPlugin;\n /**\n * Controls whether history is tracked to provide undo and redo functionality\n * @default true\n */\n history?: boolean;\n};\n\n/**\n * State used in rendering EditorInput\n */\nexport type EditorInputState = ComponentState<EditorInputSlots> &\n Required<Pick<EditorInputProps, 'disabled' | 'textPlugin' | 'history' | 'trimWhiteSpace'>> &\n Partial<Pick<EditorInputProps, 'onPaste'>> & {\n lexicalInitialConfig: InitialConfigType;\n editorRef: React.RefObject<LexicalEditor>;\n defaultValue?: string;\n handleOnChange: (value: string) => void;\n };\n\n/**\n * Data passed to the `onChange` callback when the chat input's value changes.\n */\nexport type EditorInputValueData = {\n value: string;\n};\n"],"names":[],"rangeMappings":";;","mappings":"AAiEA;;CAEC,GACD,WAEE"}
@@ -0,0 +1,6 @@
1
+ export * from './EditorInput';
2
+ export * from './EditorInput.types';
3
+ export * from './renderEditorInput';
4
+ export * from './useEditorInput';
5
+ export * from './useEditorInputStyles.styles';
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["index.ts"],"sourcesContent":["export * from './EditorInput';\nexport * from './EditorInput.types';\nexport * from './renderEditorInput';\nexport * from './useEditorInput';\nexport * from './useEditorInputStyles.styles';\n"],"names":[],"rangeMappings":";;;;","mappings":"AAAA,cAAc,gBAAgB;AAC9B,cAAc,sBAAsB;AACpC,cAAc,sBAAsB;AACpC,cAAc,mBAAmB;AACjC,cAAc,gCAAgC"}
@@ -0,0 +1,30 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@fluentui/react-jsx-runtime/jsx-runtime";
2
+ import { assertSlots } from '@fluentui/react-components';
3
+ import { LexicalComposer, LexicalErrorBoundary, LexicalEditorRefPlugin, LexicalHistoryPlugin } from '@fluentui-copilot/react-text-editor';
4
+ import { BasicFunctionalityPlugin } from '@fluentui-copilot/react-chat-input-plugins';
5
+ /**
6
+ * Render the final JSX of EditorInput
7
+ */
8
+ export const renderEditorInput_unstable = state => {
9
+ assertSlots(state);
10
+ return /*#__PURE__*/_jsx(state.root, {
11
+ children: /*#__PURE__*/_jsxs(LexicalComposer, {
12
+ initialConfig: state.lexicalInitialConfig,
13
+ children: [/*#__PURE__*/_jsx(state.textPlugin, {
14
+ contentEditable: /*#__PURE__*/_jsx(state.input, {}),
15
+ ErrorBoundary: LexicalErrorBoundary,
16
+ placeholder: state.placeholderValue ? /*#__PURE__*/_jsx(state.placeholderValue, {}) : null
17
+ }), /*#__PURE__*/_jsxs(_Fragment, {
18
+ children: [/*#__PURE__*/_jsx(BasicFunctionalityPlugin, {
19
+ onContentChange: state.handleOnChange,
20
+ onPaste: state.onPaste,
21
+ trimWhitespace: state.trimWhiteSpace,
22
+ defaultValue: state.defaultValue
23
+ }), state.history && /*#__PURE__*/_jsx(LexicalHistoryPlugin, {})]
24
+ }), /*#__PURE__*/_jsx(LexicalEditorRefPlugin, {
25
+ editorRef: state.editorRef
26
+ })]
27
+ })
28
+ });
29
+ };
30
+ //# sourceMappingURL=renderEditorInput.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["renderEditorInput.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\n\nimport { assertSlots } from '@fluentui/react-components';\nimport type { EditorInputState, EditorInputSlots } from './EditorInput.types';\nimport {\n LexicalComposer,\n LexicalErrorBoundary,\n LexicalEditorRefPlugin,\n LexicalHistoryPlugin,\n} from '@fluentui-copilot/react-text-editor';\nimport { BasicFunctionalityPlugin } from '@fluentui-copilot/react-chat-input-plugins';\n\n/**\n * Render the final JSX of EditorInput\n */\nexport const renderEditorInput_unstable = (state: EditorInputState) => {\n assertSlots<EditorInputSlots>(state);\n\n return (\n <state.root>\n <LexicalComposer initialConfig={state.lexicalInitialConfig}>\n <state.textPlugin\n contentEditable={<state.input />}\n ErrorBoundary={LexicalErrorBoundary}\n placeholder={state.placeholderValue ? <state.placeholderValue /> : null}\n />\n <>\n <BasicFunctionalityPlugin\n onContentChange={state.handleOnChange}\n onPaste={state.onPaste}\n trimWhitespace={state.trimWhiteSpace}\n defaultValue={state.defaultValue}\n />\n {state.history && <LexicalHistoryPlugin />}\n </>\n <LexicalEditorRefPlugin editorRef={state.editorRef} />\n </LexicalComposer>\n </state.root>\n );\n};\n"],"names":["assertSlots","LexicalComposer","LexicalErrorBoundary","LexicalEditorRefPlugin","LexicalHistoryPlugin","BasicFunctionalityPlugin","renderEditorInput_unstable","state","root","initialConfig","lexicalInitialConfig","textPlugin","contentEditable","input","ErrorBoundary","placeholder","placeholderValue","onContentChange","handleOnChange","onPaste","trimWhitespace","trimWhiteSpace","defaultValue","history","editorRef"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,0BAA0B,GAC1B,iDAAiD;AAEjD,SAASA,WAAW,QAAQ,6BAA6B;AAEzD,SACEC,eAAe,EACfC,oBAAoB,EACpBC,sBAAsB,EACtBC,oBAAoB,QACf,sCAAsC;AAC7C,SAASC,wBAAwB,QAAQ,6CAA6C;AAEtF;;CAEC,GACD,OAAO,MAAMC,6BAA6B,CAACC;IACzCP,YAA8BO;IAE9B,qBACE,KAACA,MAAMC,IAAI;kBACT,cAAA,MAACP;YAAgBQ,eAAeF,MAAMG,oBAAoB;;8BACxD,KAACH,MAAMI,UAAU;oBACfC,+BAAiB,KAACL,MAAMM,KAAK;oBAC7BC,eAAeZ;oBACfa,aAAaR,MAAMS,gBAAgB,iBAAG,KAACT,MAAMS,gBAAgB,QAAM;;8BAErE;;sCACE,KAACX;4BACCY,iBAAiBV,MAAMW,cAAc;4BACrCC,SAASZ,MAAMY,OAAO;4BACtBC,gBAAgBb,MAAMc,cAAc;4BACpCC,cAAcf,MAAMe,YAAY;;wBAEjCf,MAAMgB,OAAO,kBAAI,KAACnB;;;8BAErB,KAACD;oBAAuBqB,WAAWjB,MAAMiB,SAAS;;;;;AAI1D,EAAE"}
@@ -0,0 +1,128 @@
1
+ import * as React from 'react';
2
+ import { getPartitionedNativeProps, slot, useId, useIsomorphicLayoutEffect, useMergedRefs } from '@fluentui/react-components';
3
+ import { SentinelNode } from '@fluentui-copilot/chat-input-plugins';
4
+ import { LexicalPlainTextPlugin, mergeRegister } from '@fluentui-copilot/react-text-editor';
5
+ import { useControllableState } from '@fluentui/react-utilities';
6
+ /**
7
+ * Create the state required to render EditorInput.
8
+ *
9
+ * The returned state can be modified with hooks such as useEditorInputStyles_unstable,
10
+ * before being passed to renderEditorInput_unstable.
11
+ *
12
+ * @param props - props from this instance of EditorInput
13
+ * @param ref - reference to root HTMLElement of EditorInput
14
+ */
15
+ export const useEditorInput_unstable = (props, ref) => {
16
+ const {
17
+ onChange,
18
+ onPaste,
19
+ trimWhiteSpace = false,
20
+ textPlugin = LexicalPlainTextPlugin,
21
+ history = true
22
+ } = props;
23
+ const {
24
+ root,
25
+ primary
26
+ } = getPartitionedNativeProps({
27
+ primarySlotTagName: 'span',
28
+ props,
29
+ excludedPropNames: ['onChange', 'onPaste', 'defaultValue']
30
+ });
31
+ const editorRef = React.useRef(null);
32
+ // The disabled state can also be changed by lexical (e.g. by a custom plugin) so
33
+ // we use `useControllableState` to coordinate
34
+ const [disabled, setDisabled] = useControllableState({
35
+ state: props.disabled,
36
+ initialState: false
37
+ });
38
+ const customNodes = props.customNodes ? [...props.customNodes, SentinelNode] : [SentinelNode];
39
+ const spanRef = React.useCallback(span => {
40
+ var
41
+ // Register the `input` span with lexical
42
+ _editorRef_current;
43
+ (_editorRef_current = editorRef.current) === null || _editorRef_current === void 0 ? void 0 : _editorRef_current.setRootElement(span);
44
+ }, [editorRef]);
45
+ // Update lexical when disabled changes
46
+ useIsomorphicLayoutEffect(() => {
47
+ if (editorRef.current) {
48
+ var _editorRef_current;
49
+ (_editorRef_current = editorRef.current) === null || _editorRef_current === void 0 ? void 0 : _editorRef_current.setEditable(!disabled);
50
+ }
51
+ }, [disabled]);
52
+ useIsomorphicLayoutEffect(() => {
53
+ if (editorRef.current) {
54
+ var _editorRef_current;
55
+ return mergeRegister(editorRef.current.registerEditableListener(isEditable => {
56
+ setDisabled(!isEditable);
57
+ }), (_editorRef_current = editorRef.current) === null || _editorRef_current === void 0 ? void 0 : _editorRef_current.registerRootListener(root => {
58
+ if (!root) {
59
+ return;
60
+ }
61
+ // Remove lexical's inline style so we can apply our own
62
+ // Lexical needs the whitespace style to be either `pre` or `pre-wrap` to work correctly
63
+ root.style.whiteSpace = '';
64
+ }));
65
+ }
66
+ }, [editorRef]);
67
+ const handleOnChange = React.useCallback(newValue => {
68
+ onChange === null || onChange === void 0 ? void 0 : onChange({}, {
69
+ value: newValue
70
+ });
71
+ }, [onChange]);
72
+ const [defaultString, defaultValueFunction] = (() => {
73
+ if (typeof props.defaultValue === 'function') {
74
+ return [undefined, props.defaultValue];
75
+ }
76
+ return [props.defaultValue, undefined];
77
+ })();
78
+ const placeholderValue = slot.optional(props.placeholderValue, {
79
+ elementType: 'span'
80
+ });
81
+ const placeholderId = useId('chat-input-placeholder', placeholderValue === null || placeholderValue === void 0 ? void 0 : placeholderValue.id);
82
+ if (placeholderValue) {
83
+ placeholderValue.id = placeholderId;
84
+ }
85
+ return {
86
+ components: {
87
+ root: 'span',
88
+ input: 'span',
89
+ placeholderValue: 'span'
90
+ },
91
+ root: slot.always(props.root, {
92
+ defaultProps: {
93
+ ...root
94
+ },
95
+ elementType: 'span'
96
+ }),
97
+ input: slot.always(props.input, {
98
+ defaultProps: {
99
+ ref: useMergedRefs(ref, spanRef),
100
+ role: 'textbox',
101
+ contentEditable: !disabled,
102
+ 'aria-readonly': disabled ? true : undefined,
103
+ tabIndex: disabled ? -1 : 0,
104
+ disabled,
105
+ suppressContentEditableWarning: true,
106
+ ...primary,
107
+ 'aria-describedby': primary['aria-describedby'] ? `${primary['aria-describedby']} ${placeholderId}` : placeholderId
108
+ },
109
+ elementType: 'span'
110
+ }),
111
+ placeholderValue,
112
+ lexicalInitialConfig: {
113
+ namespace: 'fai-EditorInput',
114
+ onError: console.error,
115
+ nodes: customNodes,
116
+ editorState: defaultValueFunction
117
+ },
118
+ editorRef,
119
+ disabled,
120
+ textPlugin,
121
+ onPaste,
122
+ handleOnChange,
123
+ defaultValue: defaultString,
124
+ trimWhiteSpace,
125
+ history
126
+ };
127
+ };
128
+ //# sourceMappingURL=useEditorInput.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["useEditorInput.tsx"],"sourcesContent":["import * as React from 'react';\nimport {\n getPartitionedNativeProps,\n slot,\n useId,\n useIsomorphicLayoutEffect,\n useMergedRefs,\n} from '@fluentui/react-components';\nimport type { EditorInputProps, EditorInputState } from './EditorInput.types';\nimport { SentinelNode } from '@fluentui-copilot/chat-input-plugins';\nimport type { LexicalEditor } from '@fluentui-copilot/react-text-editor';\nimport { LexicalPlainTextPlugin, mergeRegister } from '@fluentui-copilot/react-text-editor';\nimport { useControllableState } from '@fluentui/react-utilities';\n\n/**\n * Create the state required to render EditorInput.\n *\n * The returned state can be modified with hooks such as useEditorInputStyles_unstable,\n * before being passed to renderEditorInput_unstable.\n *\n * @param props - props from this instance of EditorInput\n * @param ref - reference to root HTMLElement of EditorInput\n */\nexport const useEditorInput_unstable = (props: EditorInputProps, ref: React.Ref<HTMLSpanElement>): EditorInputState => {\n const { onChange, onPaste, trimWhiteSpace = false, textPlugin = LexicalPlainTextPlugin, history = true } = props;\n const { root, primary } = getPartitionedNativeProps({\n primarySlotTagName: 'span',\n props,\n excludedPropNames: ['onChange', 'onPaste', 'defaultValue'],\n });\n\n const editorRef = React.useRef<LexicalEditor>(null);\n // The disabled state can also be changed by lexical (e.g. by a custom plugin) so\n // we use `useControllableState` to coordinate\n const [disabled, setDisabled] = useControllableState({\n state: props.disabled,\n initialState: false,\n });\n\n const customNodes = props.customNodes ? [...props.customNodes, SentinelNode] : [SentinelNode];\n\n const spanRef = React.useCallback(\n span => {\n // Register the `input` span with lexical\n editorRef.current?.setRootElement(span);\n },\n [editorRef],\n );\n\n // Update lexical when disabled changes\n useIsomorphicLayoutEffect(() => {\n if (editorRef.current) {\n editorRef.current?.setEditable(!disabled);\n }\n }, [disabled]);\n\n useIsomorphicLayoutEffect(() => {\n if (editorRef.current) {\n return mergeRegister(\n editorRef.current.registerEditableListener(isEditable => {\n setDisabled(!isEditable);\n }),\n editorRef.current?.registerRootListener(root => {\n if (!root) {\n return;\n }\n\n // Remove lexical's inline style so we can apply our own\n // Lexical needs the whitespace style to be either `pre` or `pre-wrap` to work correctly\n root.style.whiteSpace = '';\n }),\n );\n }\n }, [editorRef]);\n\n const handleOnChange = React.useCallback(\n (newValue: string) => {\n onChange?.({}, { value: newValue });\n },\n [onChange],\n );\n\n const [defaultString, defaultValueFunction] = (() => {\n if (typeof props.defaultValue === 'function') {\n return [undefined, props.defaultValue];\n }\n return [props.defaultValue, undefined];\n })();\n\n const placeholderValue = slot.optional(props.placeholderValue, { elementType: 'span' });\n const placeholderId = useId('chat-input-placeholder', placeholderValue?.id);\n if (placeholderValue) {\n placeholderValue.id = placeholderId;\n }\n\n return {\n components: {\n root: 'span',\n input: 'span',\n placeholderValue: 'span',\n },\n root: slot.always(props.root, { defaultProps: { ...root }, elementType: 'span' }),\n input: slot.always(props.input, {\n defaultProps: {\n ref: useMergedRefs(ref, spanRef),\n role: 'textbox',\n contentEditable: !disabled,\n 'aria-readonly': disabled ? true : undefined,\n tabIndex: disabled ? -1 : 0,\n disabled,\n suppressContentEditableWarning: true,\n ...primary,\n 'aria-describedby': primary['aria-describedby']\n ? `${primary['aria-describedby']} ${placeholderId}`\n : placeholderId,\n },\n elementType: 'span',\n }),\n placeholderValue,\n lexicalInitialConfig: {\n namespace: 'fai-EditorInput',\n onError: console.error,\n nodes: customNodes,\n editorState: defaultValueFunction,\n },\n editorRef,\n disabled,\n textPlugin,\n onPaste,\n handleOnChange,\n defaultValue: defaultString,\n trimWhiteSpace,\n history,\n };\n};\n"],"names":["React","getPartitionedNativeProps","slot","useId","useIsomorphicLayoutEffect","useMergedRefs","SentinelNode","LexicalPlainTextPlugin","mergeRegister","useControllableState","useEditorInput_unstable","props","ref","onChange","onPaste","trimWhiteSpace","textPlugin","history","root","primary","primarySlotTagName","excludedPropNames","editorRef","useRef","disabled","setDisabled","state","initialState","customNodes","spanRef","useCallback","span","current","setRootElement","setEditable","registerEditableListener","isEditable","registerRootListener","style","whiteSpace","handleOnChange","newValue","value","defaultString","defaultValueFunction","defaultValue","undefined","placeholderValue","optional","elementType","placeholderId","id","components","input","always","defaultProps","role","contentEditable","tabIndex","suppressContentEditableWarning","lexicalInitialConfig","namespace","onError","console","error","nodes","editorState"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SACEC,yBAAyB,EACzBC,IAAI,EACJC,KAAK,EACLC,yBAAyB,EACzBC,aAAa,QACR,6BAA6B;AAEpC,SAASC,YAAY,QAAQ,uCAAuC;AAEpE,SAASC,sBAAsB,EAAEC,aAAa,QAAQ,sCAAsC;AAC5F,SAASC,oBAAoB,QAAQ,4BAA4B;AAEjE;;;;;;;;CAQC,GACD,OAAO,MAAMC,0BAA0B,CAACC,OAAyBC;IAC/D,MAAM,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,iBAAiB,KAAK,EAAEC,aAAaT,sBAAsB,EAAEU,UAAU,IAAI,EAAE,GAAGN;IAC3G,MAAM,EAAEO,IAAI,EAAEC,OAAO,EAAE,GAAGlB,0BAA0B;QAClDmB,oBAAoB;QACpBT;QACAU,mBAAmB;YAAC;YAAY;YAAW;SAAe;IAC5D;IAEA,MAAMC,YAAYtB,MAAMuB,MAAM,CAAgB;IAC9C,iFAAiF;IACjF,8CAA8C;IAC9C,MAAM,CAACC,UAAUC,YAAY,GAAGhB,qBAAqB;QACnDiB,OAAOf,MAAMa,QAAQ;QACrBG,cAAc;IAChB;IAEA,MAAMC,cAAcjB,MAAMiB,WAAW,GAAG;WAAIjB,MAAMiB,WAAW;QAAEtB;KAAa,GAAG;QAACA;KAAa;IAE7F,MAAMuB,UAAU7B,MAAM8B,WAAW,CAC/BC,CAAAA;YACE,yCAAyC;QACzCT;SAAAA,qBAAAA,UAAUU,OAAO,cAAjBV,yCAAAA,mBAAmBW,cAAc,CAACF;IACpC,GACA;QAACT;KAAU;IAGb,uCAAuC;IACvClB,0BAA0B;QACxB,IAAIkB,UAAUU,OAAO,EAAE;gBACrBV;aAAAA,qBAAAA,UAAUU,OAAO,cAAjBV,yCAAAA,mBAAmBY,WAAW,CAAC,CAACV;QAClC;IACF,GAAG;QAACA;KAAS;IAEbpB,0BAA0B;QACxB,IAAIkB,UAAUU,OAAO,EAAE;gBAKnBV;YAJF,OAAOd,cACLc,UAAUU,OAAO,CAACG,wBAAwB,CAACC,CAAAA;gBACzCX,YAAY,CAACW;YACf,KACAd,qBAAAA,UAAUU,OAAO,cAAjBV,yCAAAA,mBAAmBe,oBAAoB,CAACnB,CAAAA;gBACtC,IAAI,CAACA,MAAM;oBACT;gBACF;gBAEA,wDAAwD;gBACxD,wFAAwF;gBACxFA,KAAKoB,KAAK,CAACC,UAAU,GAAG;YAC1B;QAEJ;IACF,GAAG;QAACjB;KAAU;IAEd,MAAMkB,iBAAiBxC,MAAM8B,WAAW,CACtC,CAACW;QACC5B,qBAAAA,+BAAAA,SAAW,CAAC,GAAG;YAAE6B,OAAOD;QAAS;IACnC,GACA;QAAC5B;KAAS;IAGZ,MAAM,CAAC8B,eAAeC,qBAAqB,GAAG,AAAC,CAAA;QAC7C,IAAI,OAAOjC,MAAMkC,YAAY,KAAK,YAAY;YAC5C,OAAO;gBAACC;gBAAWnC,MAAMkC,YAAY;aAAC;QACxC;QACA,OAAO;YAAClC,MAAMkC,YAAY;YAAEC;SAAU;IACxC,CAAA;IAEA,MAAMC,mBAAmB7C,KAAK8C,QAAQ,CAACrC,MAAMoC,gBAAgB,EAAE;QAAEE,aAAa;IAAO;IACrF,MAAMC,gBAAgB/C,MAAM,0BAA0B4C,6BAAAA,uCAAAA,iBAAkBI,EAAE;IAC1E,IAAIJ,kBAAkB;QACpBA,iBAAiBI,EAAE,GAAGD;IACxB;IAEA,OAAO;QACLE,YAAY;YACVlC,MAAM;YACNmC,OAAO;YACPN,kBAAkB;QACpB;QACA7B,MAAMhB,KAAKoD,MAAM,CAAC3C,MAAMO,IAAI,EAAE;YAAEqC,cAAc;gBAAE,GAAGrC,IAAI;YAAC;YAAG+B,aAAa;QAAO;QAC/EI,OAAOnD,KAAKoD,MAAM,CAAC3C,MAAM0C,KAAK,EAAE;YAC9BE,cAAc;gBACZ3C,KAAKP,cAAcO,KAAKiB;gBACxB2B,MAAM;gBACNC,iBAAiB,CAACjC;gBAClB,iBAAiBA,WAAW,OAAOsB;gBACnCY,UAAUlC,WAAW,CAAC,IAAI;gBAC1BA;gBACAmC,gCAAgC;gBAChC,GAAGxC,OAAO;gBACV,oBAAoBA,OAAO,CAAC,mBAAmB,GAC3C,CAAC,EAAEA,OAAO,CAAC,mBAAmB,CAAC,CAAC,EAAE+B,cAAc,CAAC,GACjDA;YACN;YACAD,aAAa;QACf;QACAF;QACAa,sBAAsB;YACpBC,WAAW;YACXC,SAASC,QAAQC,KAAK;YACtBC,OAAOrC;YACPsC,aAAatB;QACf;QACAtB;QACAE;QACAR;QACAF;QACA0B;QACAK,cAAcF;QACd5B;QACAE;IACF;AACF,EAAE"}
@@ -0,0 +1,57 @@
1
+ import { __resetStyles, __styles, mergeClasses, shorthands, tokens, typographyStyles } from '@fluentui/react-components';
2
+ export const editorInputClassNames = {
3
+ root: 'fai-EditorInput',
4
+ input: 'fai-EditorInput__input',
5
+ placeholderValue: 'fai-EditorInput__placeholderValue'
6
+ };
7
+ /**
8
+ * Styles for the root slot
9
+ */
10
+ const useRootClassName = __resetStyles("r1x54j0a", null, [".r1x54j0a{display:inline-grid;white-space:pre-wrap;}"]);
11
+ export const useLexicalStyles = __styles({
12
+ paragraph: {
13
+ B6of3ja: "f1hu3pq6",
14
+ t21cq0: ["f11qmguv", "f1tyq0we"],
15
+ jrapky: "f19f4twv",
16
+ Frg6f3: ["f1tyq0we", "f11qmguv"]
17
+ }
18
+ }, {
19
+ d: [".f1hu3pq6{margin-top:0;}", ".f11qmguv{margin-right:0;}", ".f1tyq0we{margin-left:0;}", ".f19f4twv{margin-bottom:0;}"]
20
+ });
21
+ export const usePlaceholderClassName = __resetStyles("r1tldilo", null, [".r1tldilo{z-index:0;grid-area:1/1/1/1;color:var(--colorNeutralForeground3);font-family:var(--fontFamilyBase);font-size:var(--fontSizeBase300);font-weight:var(--fontWeightRegular);line-height:var(--lineHeightBase300);}"]);
22
+ export const useInputClassName = __resetStyles("r18fti29", null, [".r18fti29{grid-area:1/1/1/1;z-index:1;width:100%;}"]);
23
+ const useStyles = __styles({
24
+ placeholderDisabled: {
25
+ sj55zd: "f1s2aq7o"
26
+ }
27
+ }, {
28
+ d: [".f1s2aq7o{color:var(--colorNeutralForegroundDisabled);}"]
29
+ });
30
+ /**
31
+ * Apply styling to the EditorInput slots based on the state
32
+ */
33
+ export const useEditorInputStyles_unstable = state => {
34
+ 'use no memo';
35
+
36
+ const {
37
+ disabled
38
+ } = state;
39
+ const placeholderClassName = usePlaceholderClassName();
40
+ const rootClassName = useRootClassName();
41
+ const inputClassName = useInputClassName();
42
+ const styles = useStyles();
43
+ state.root.className = mergeClasses(editorInputClassNames.root, rootClassName, state.root.className);
44
+ state.input.className = mergeClasses(editorInputClassNames.input, inputClassName, state.input.className);
45
+ state.lexicalInitialConfig = {
46
+ ...state.lexicalInitialConfig,
47
+ theme: {
48
+ ...useLexicalStyles(),
49
+ ...state.lexicalInitialConfig.theme
50
+ }
51
+ };
52
+ if (state.placeholderValue) {
53
+ state.placeholderValue.className = mergeClasses(editorInputClassNames.placeholderValue, placeholderClassName, disabled && styles.placeholderDisabled, state.placeholderValue.className);
54
+ }
55
+ return state;
56
+ };
57
+ //# sourceMappingURL=useEditorInputStyles.styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["useEditorInputStyles.styles.ts"],"sourcesContent":["import {\n makeResetStyles,\n makeStyles,\n mergeClasses,\n shorthands,\n tokens,\n typographyStyles,\n} from '@fluentui/react-components';\nimport type { SlotClassNames } from '@fluentui/react-components';\nimport type { EditorInputSlots, EditorInputState } from './EditorInput.types';\n\nexport const editorInputClassNames: SlotClassNames<EditorInputSlots> = {\n root: 'fai-EditorInput',\n input: 'fai-EditorInput__input',\n placeholderValue: 'fai-EditorInput__placeholderValue',\n};\n\n/**\n * Styles for the root slot\n */\nconst useRootClassName = makeResetStyles({\n display: 'inline-grid',\n whiteSpace: 'pre-wrap',\n});\n\nexport const useLexicalStyles = makeStyles({\n paragraph: {\n ...shorthands.margin(0),\n },\n});\n\nexport const usePlaceholderClassName = makeResetStyles({\n zIndex: 0,\n gridArea: '1 / 1 / 1 / 1',\n\n color: tokens.colorNeutralForeground3,\n ...typographyStyles.body1,\n});\n\nexport const useInputClassName = makeResetStyles({\n gridArea: '1 / 1 / 1 / 1',\n zIndex: 1,\n width: '100%',\n});\n\nconst useStyles = makeStyles({\n placeholderDisabled: {\n color: tokens.colorNeutralForegroundDisabled,\n },\n});\n/**\n * Apply styling to the EditorInput slots based on the state\n */\nexport const useEditorInputStyles_unstable = (state: EditorInputState): EditorInputState => {\n 'use no memo';\n\n const { disabled } = state;\n const placeholderClassName = usePlaceholderClassName();\n const rootClassName = useRootClassName();\n const inputClassName = useInputClassName();\n const styles = useStyles();\n\n state.root.className = mergeClasses(editorInputClassNames.root, rootClassName, state.root.className);\n\n state.input.className = mergeClasses(editorInputClassNames.input, inputClassName, state.input.className);\n\n state.lexicalInitialConfig = {\n ...state.lexicalInitialConfig,\n theme: { ...useLexicalStyles(), ...state.lexicalInitialConfig.theme },\n };\n\n if (state.placeholderValue) {\n state.placeholderValue.className = mergeClasses(\n editorInputClassNames.placeholderValue,\n placeholderClassName,\n disabled && styles.placeholderDisabled,\n state.placeholderValue.className,\n );\n }\n\n return state;\n};\n"],"names":["makeResetStyles","makeStyles","mergeClasses","shorthands","tokens","typographyStyles","editorInputClassNames","root","input","placeholderValue","useRootClassName","display","whiteSpace","useLexicalStyles","paragraph","margin","usePlaceholderClassName","zIndex","gridArea","color","colorNeutralForeground3","body1","useInputClassName","width","useStyles","placeholderDisabled","colorNeutralForegroundDisabled","useEditorInputStyles_unstable","state","disabled","placeholderClassName","rootClassName","inputClassName","styles","className","lexicalInitialConfig","theme"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SACEA,eAAe,EACfC,UAAU,EACVC,YAAY,EACZC,UAAU,EACVC,MAAM,EACNC,gBAAgB,QACX,6BAA6B;AAIpC,OAAO,MAAMC,wBAA0D;IACrEC,MAAM;IACNC,OAAO;IACPC,kBAAkB;AACpB,EAAE;AAEF;;CAEC,GACD,MAAMC,mBAAmBV,gBAAgB;IACvCW,SAAS;IACTC,YAAY;AACd;AAEA,OAAO,MAAMC,mBAAmBZ,WAAW;IACzCa,WAAW;QACT,GAAGX,WAAWY,MAAM,CAAC,EAAE;IACzB;AACF,GAAG;AAEH,OAAO,MAAMC,0BAA0BhB,gBAAgB;IACrDiB,QAAQ;IACRC,UAAU;IAEVC,OAAOf,OAAOgB,uBAAuB;IACrC,GAAGf,iBAAiBgB,KAAK;AAC3B,GAAG;AAEH,OAAO,MAAMC,oBAAoBtB,gBAAgB;IAC/CkB,UAAU;IACVD,QAAQ;IACRM,OAAO;AACT,GAAG;AAEH,MAAMC,YAAYvB,WAAW;IAC3BwB,qBAAqB;QACnBN,OAAOf,OAAOsB,8BAA8B;IAC9C;AACF;AACA;;CAEC,GACD,OAAO,MAAMC,gCAAgC,CAACC;IAC5C;IAEA,MAAM,EAAEC,QAAQ,EAAE,GAAGD;IACrB,MAAME,uBAAuBd;IAC7B,MAAMe,gBAAgBrB;IACtB,MAAMsB,iBAAiBV;IACvB,MAAMW,SAAST;IAEfI,MAAMrB,IAAI,CAAC2B,SAAS,GAAGhC,aAAaI,sBAAsBC,IAAI,EAAEwB,eAAeH,MAAMrB,IAAI,CAAC2B,SAAS;IAEnGN,MAAMpB,KAAK,CAAC0B,SAAS,GAAGhC,aAAaI,sBAAsBE,KAAK,EAAEwB,gBAAgBJ,MAAMpB,KAAK,CAAC0B,SAAS;IAEvGN,MAAMO,oBAAoB,GAAG;QAC3B,GAAGP,MAAMO,oBAAoB;QAC7BC,OAAO;YAAE,GAAGvB,kBAAkB;YAAE,GAAGe,MAAMO,oBAAoB,CAACC,KAAK;QAAC;IACtE;IAEA,IAAIR,MAAMnB,gBAAgB,EAAE;QAC1BmB,MAAMnB,gBAAgB,CAACyB,SAAS,GAAGhC,aACjCI,sBAAsBG,gBAAgB,EACtCqB,sBACAD,YAAYI,OAAOR,mBAAmB,EACtCG,MAAMnB,gBAAgB,CAACyB,SAAS;IAEpC;IAEA,OAAON;AACT,EAAE"}
package/lib/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { EditorInput, editorInputClassNames, renderEditorInput_unstable, useEditorInputStyles_unstable, useEditorInput_unstable } from './EditorInput';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["index.ts"],"sourcesContent":["export type { EditorInputProps, EditorInputSlots, EditorInputState, EditorInputValueData } from './EditorInput';\nexport {\n EditorInput,\n editorInputClassNames,\n renderEditorInput_unstable,\n useEditorInputStyles_unstable,\n useEditorInput_unstable,\n} from './EditorInput';\n"],"names":["EditorInput","editorInputClassNames","renderEditorInput_unstable","useEditorInputStyles_unstable","useEditorInput_unstable"],"rangeMappings":"","mappings":"AACA,SACEA,WAAW,EACXC,qBAAqB,EACrBC,0BAA0B,EAC1BC,6BAA6B,EAC7BC,uBAAuB,QAClB,gBAAgB"}
@@ -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/EditorInput/index"), exports);
7
+ //# sourceMappingURL=EditorInput.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["EditorInput.ts"],"sourcesContent":["export * from './components/EditorInput/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, "EditorInput", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return EditorInput;
9
+ }
10
+ });
11
+ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
12
+ const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
13
+ const _useEditorInput = require("./useEditorInput");
14
+ const _renderEditorInput = require("./renderEditorInput");
15
+ const _useEditorInputStylesstyles = require("./useEditorInputStyles.styles");
16
+ const EditorInput = /*#__PURE__*/ _react.forwardRef((props, ref)=>{
17
+ const state = (0, _useEditorInput.useEditorInput_unstable)(props, ref);
18
+ (0, _useEditorInputStylesstyles.useEditorInputStyles_unstable)(state);
19
+ return (0, _renderEditorInput.renderEditorInput_unstable)(state);
20
+ });
21
+ EditorInput.displayName = 'EditorInput'; //# sourceMappingURL=EditorInput.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["EditorInput.tsx"],"sourcesContent":["import * as React from 'react';\nimport { useEditorInput_unstable } from './useEditorInput';\nimport { renderEditorInput_unstable } from './renderEditorInput';\nimport { useEditorInputStyles_unstable } from './useEditorInputStyles.styles';\nimport type { EditorInputProps } from './EditorInput.types';\nimport type { ForwardRefComponent } from '@fluentui/react-components';\n\n// EditorInput component - TODO: add more docs\nexport const EditorInput: ForwardRefComponent<EditorInputProps> = React.forwardRef((props, ref) => {\n const state = useEditorInput_unstable(props, ref);\n\n useEditorInputStyles_unstable(state);\n return renderEditorInput_unstable(state);\n});\n\nEditorInput.displayName = 'EditorInput';\n"],"names":["EditorInput","React","forwardRef","props","state","useEditorInput_unstable","useEditorInputStyles_unstable","renderEditorInput_unstable","displayName"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAQaA;;;eAAAA;;;;iEARU;gCACiB;mCACG;4CACG;AAKvC,MAAMA,cAAAA,WAAAA,GAAAA,OAAqDC,UAAMC,CAAU,CAACC,OAACA;UAClFC,QAAMA,IAAAA,uCAAQC,EAAAA,OAAwBF;iEAEtCG,EAAAA;WACAC,IAAAA,6CAAOA,EAAAA;AACT;AAEAP,YAAYQ,WAAW,GAAG"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Data passed to the `onChange` callback when the chat input's value changes.
3
+ */ "use strict";
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ //# sourceMappingURL=EditorInput.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["EditorInput.types.ts"],"sourcesContent":["import type { InitialConfigType, LexicalEditor, LexicalPlainTextPlugin } from '@fluentui-copilot/react-text-editor';\nimport type { ComponentProps, ComponentState, Slot } from '@fluentui/react-components';\n\nexport type EditorInputSlots = {\n root: NonNullable<Slot<'span'>>;\n input: NonNullable<Slot<'span'>>;\n placeholderValue?: Slot<'span'>;\n};\n\n/**\n * EditorInput Props\n */\nexport type EditorInputProps = Omit<\n ComponentProps<Partial<EditorInputSlots>, 'input'>,\n 'onChange' | 'onPaste' | 'defaultValue' | 'onSubmit'\n> & {\n disabled?: boolean;\n /**\n * If defaultValue is a string, it will be added to the input on first render.\n * If defaultValue is a function, it can call lexical $ functions to imperatively set the initial content with more complex nodes.\n */\n defaultValue?: string | (() => void);\n /**\n * Callback for when the user changes the value.\n * TODO: Add proper event type for callback\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n onChange?: (ev: any, data: EditorInputValueData) => void;\n /**\n * Callback for when content is pasted into the Editor.\n */\n onPaste?: (ev: ClipboardEvent) => void;\n /**\n * When true, the input will be cleared when only whitespace is remaining.\n * @default false\n */\n trimWhiteSpace?: boolean;\n /**\n * Used to register any custom nodes used by plugins added. Can also be used to override the default nodes.\n */\n customNodes?: InitialConfigType['nodes'];\n /**\n * The plugin which is in charge of initializing Lexical and is given the `input` and `placeholder` slots\n * @default LexicalPlainTextPlugin\n */\n textPlugin?: typeof LexicalPlainTextPlugin;\n /**\n * Controls whether history is tracked to provide undo and redo functionality\n * @default true\n */\n history?: boolean;\n};\n\n/**\n * State used in rendering EditorInput\n */\nexport type EditorInputState = ComponentState<EditorInputSlots> &\n Required<Pick<EditorInputProps, 'disabled' | 'textPlugin' | 'history' | 'trimWhiteSpace'>> &\n Partial<Pick<EditorInputProps, 'onPaste'>> & {\n lexicalInitialConfig: InitialConfigType;\n editorRef: React.RefObject<LexicalEditor>;\n defaultValue?: string;\n handleOnChange: (value: string) => void;\n };\n\n/**\n * Data passed to the `onChange` callback when the chat input's value changes.\n */\nexport type EditorInputValueData = {\n value: string;\n};\n"],"names":[],"rangeMappings":";;","mappings":"AAiEA;;CAEC"}
@@ -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("./EditorInput"), exports);
7
+ _export_star._(require("./EditorInput.types"), exports);
8
+ _export_star._(require("./renderEditorInput"), exports);
9
+ _export_star._(require("./useEditorInput"), exports);
10
+ _export_star._(require("./useEditorInputStyles.styles"), exports);
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["index.ts"],"sourcesContent":["export * from './EditorInput';\nexport * from './EditorInput.types';\nexport * from './renderEditorInput';\nexport * from './useEditorInput';\nexport * from './useEditorInputStyles.styles';\n"],"names":[],"rangeMappings":";;;;;;;;;","mappings":";;;;;uBAAc;uBACA;uBACA;uBACA;uBACA"}
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "renderEditorInput_unstable", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return renderEditorInput_unstable;
9
+ }
10
+ });
11
+ const _jsxruntime = require("@fluentui/react-jsx-runtime/jsx-runtime");
12
+ const _reactcomponents = require("@fluentui/react-components");
13
+ const _reacttexteditor = require("@fluentui-copilot/react-text-editor");
14
+ const _reactchatinputplugins = require("@fluentui-copilot/react-chat-input-plugins");
15
+ const renderEditorInput_unstable = (state)=>{
16
+ (0, _reactcomponents.assertSlots)(state);
17
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)(state.root, {
18
+ children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_reacttexteditor.LexicalComposer, {
19
+ initialConfig: state.lexicalInitialConfig,
20
+ children: [
21
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(state.textPlugin, {
22
+ contentEditable: /*#__PURE__*/ (0, _jsxruntime.jsx)(state.input, {}),
23
+ ErrorBoundary: _reacttexteditor.LexicalErrorBoundary,
24
+ placeholder: state.placeholderValue ? /*#__PURE__*/ (0, _jsxruntime.jsx)(state.placeholderValue, {}) : null
25
+ }),
26
+ /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
27
+ children: [
28
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_reactchatinputplugins.BasicFunctionalityPlugin, {
29
+ onContentChange: state.handleOnChange,
30
+ onPaste: state.onPaste,
31
+ trimWhitespace: state.trimWhiteSpace,
32
+ defaultValue: state.defaultValue
33
+ }),
34
+ state.history && /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacttexteditor.LexicalHistoryPlugin, {})
35
+ ]
36
+ }),
37
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacttexteditor.LexicalEditorRefPlugin, {
38
+ editorRef: state.editorRef
39
+ })
40
+ ]
41
+ })
42
+ });
43
+ }; //# sourceMappingURL=renderEditorInput.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["renderEditorInput.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\n\nimport { assertSlots } from '@fluentui/react-components';\nimport type { EditorInputState, EditorInputSlots } from './EditorInput.types';\nimport {\n LexicalComposer,\n LexicalErrorBoundary,\n LexicalEditorRefPlugin,\n LexicalHistoryPlugin,\n} from '@fluentui-copilot/react-text-editor';\nimport { BasicFunctionalityPlugin } from '@fluentui-copilot/react-chat-input-plugins';\n\n/**\n * Render the final JSX of EditorInput\n */\nexport const renderEditorInput_unstable = (state: EditorInputState) => {\n assertSlots<EditorInputSlots>(state);\n\n return (\n <state.root>\n <LexicalComposer initialConfig={state.lexicalInitialConfig}>\n <state.textPlugin\n contentEditable={<state.input />}\n ErrorBoundary={LexicalErrorBoundary}\n placeholder={state.placeholderValue ? <state.placeholderValue /> : null}\n />\n <>\n <BasicFunctionalityPlugin\n onContentChange={state.handleOnChange}\n onPaste={state.onPaste}\n trimWhitespace={state.trimWhiteSpace}\n defaultValue={state.defaultValue}\n />\n {state.history && <LexicalHistoryPlugin />}\n </>\n <LexicalEditorRefPlugin editorRef={state.editorRef} />\n </LexicalComposer>\n </state.root>\n );\n};\n"],"names":["assertSlots","state","_jsx","root","LexicalComposer","initialConfig","lexicalInitialConfig","textPlugin","contentEditable","ErrorBoundary","LexicalErrorBoundary","placeholder","placeholderValue","BasicFunctionalityPlugin","onContentChange","onPaste","trimWhitespace","defaultValue","editorRef"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAiBEA;;;eAAAA;;;4BAhBF;iCAE4B;iCAOrB;uCACkC;AAMvCA,MAAAA,6BAA8BC,CAAAA;oCAE9B,EAAAA;sBAEI,GAAAC,IAAAA,eAAA,EAAAD,MAAAE,IAAA,EAACC;kBAAgBC,WAAAA,GAAeJ,IAAAA,gBAAAA,EAAMK,gCAAAA,EAAAA;;;8BACpCJ,IAAAA,eAAA,EAACD,MAAMM,UAAU,EAAA;qCACfC,WAAAA,GAAAA,IAAAA,eAAAA,EAAAA,MAAAA,KAAiB,EAACP,CAAAA;mCAClBQ,qCAAeC;iCACfC,MAAAA,gBAAmBC,GAAAA,WAAgB,GAAAV,IAAAA,eAAA,EAAAD,MAAAW,gBAAUA,EAAAA,CAAAA,KAAAA;;;;mCAE/C,GAAAV,IAAAA,eAAA,EAAAW,+CAAA,EAAA;;;kDAEIC,cAAiBb;gDACjBc,YAASd;;yCACTe,WAAAA,GAAAA,IAAAA,eAAgBf,EAAAA,qCAAoB,EAAA,CAAA;qBAAA;;mDACpCgB,uCAAoBA,EAAAA;;;;;;gDAIiBC"}
@@ -0,0 +1,142 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "useEditorInput_unstable", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return useEditorInput_unstable;
9
+ }
10
+ });
11
+ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
12
+ const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
13
+ const _reactcomponents = require("@fluentui/react-components");
14
+ const _chatinputplugins = require("@fluentui-copilot/chat-input-plugins");
15
+ const _reacttexteditor = require("@fluentui-copilot/react-text-editor");
16
+ const _reactutilities = require("@fluentui/react-utilities");
17
+ const useEditorInput_unstable = (props, ref)=>{
18
+ const { onChange, onPaste, trimWhiteSpace = false, textPlugin = _reacttexteditor.LexicalPlainTextPlugin, history = true } = props;
19
+ const { root, primary } = (0, _reactcomponents.getPartitionedNativeProps)({
20
+ primarySlotTagName: 'span',
21
+ props,
22
+ excludedPropNames: [
23
+ 'onChange',
24
+ 'onPaste',
25
+ 'defaultValue'
26
+ ]
27
+ });
28
+ const editorRef = _react.useRef(null);
29
+ // The disabled state can also be changed by lexical (e.g. by a custom plugin) so
30
+ // we use `useControllableState` to coordinate
31
+ const [disabled, setDisabled] = (0, _reactutilities.useControllableState)({
32
+ state: props.disabled,
33
+ initialState: false
34
+ });
35
+ const customNodes = props.customNodes ? [
36
+ ...props.customNodes,
37
+ _chatinputplugins.SentinelNode
38
+ ] : [
39
+ _chatinputplugins.SentinelNode
40
+ ];
41
+ const spanRef = _react.useCallback((span)=>{
42
+ var // Register the `input` span with lexical
43
+ _editorRef_current;
44
+ (_editorRef_current = editorRef.current) === null || _editorRef_current === void 0 ? void 0 : _editorRef_current.setRootElement(span);
45
+ }, [
46
+ editorRef
47
+ ]);
48
+ // Update lexical when disabled changes
49
+ (0, _reactcomponents.useIsomorphicLayoutEffect)(()=>{
50
+ if (editorRef.current) {
51
+ var _editorRef_current;
52
+ (_editorRef_current = editorRef.current) === null || _editorRef_current === void 0 ? void 0 : _editorRef_current.setEditable(!disabled);
53
+ }
54
+ }, [
55
+ disabled
56
+ ]);
57
+ (0, _reactcomponents.useIsomorphicLayoutEffect)(()=>{
58
+ if (editorRef.current) {
59
+ var _editorRef_current;
60
+ return (0, _reacttexteditor.mergeRegister)(editorRef.current.registerEditableListener((isEditable)=>{
61
+ setDisabled(!isEditable);
62
+ }), (_editorRef_current = editorRef.current) === null || _editorRef_current === void 0 ? void 0 : _editorRef_current.registerRootListener((root)=>{
63
+ if (!root) {
64
+ return;
65
+ }
66
+ // Remove lexical's inline style so we can apply our own
67
+ // Lexical needs the whitespace style to be either `pre` or `pre-wrap` to work correctly
68
+ root.style.whiteSpace = '';
69
+ }));
70
+ }
71
+ }, [
72
+ editorRef
73
+ ]);
74
+ const handleOnChange = _react.useCallback((newValue)=>{
75
+ onChange === null || onChange === void 0 ? void 0 : onChange({}, {
76
+ value: newValue
77
+ });
78
+ }, [
79
+ onChange
80
+ ]);
81
+ const [defaultString, defaultValueFunction] = (()=>{
82
+ if (typeof props.defaultValue === 'function') {
83
+ return [
84
+ undefined,
85
+ props.defaultValue
86
+ ];
87
+ }
88
+ return [
89
+ props.defaultValue,
90
+ undefined
91
+ ];
92
+ })();
93
+ const placeholderValue = _reactcomponents.slot.optional(props.placeholderValue, {
94
+ elementType: 'span'
95
+ });
96
+ const placeholderId = (0, _reactcomponents.useId)('chat-input-placeholder', placeholderValue === null || placeholderValue === void 0 ? void 0 : placeholderValue.id);
97
+ if (placeholderValue) {
98
+ placeholderValue.id = placeholderId;
99
+ }
100
+ return {
101
+ components: {
102
+ root: 'span',
103
+ input: 'span',
104
+ placeholderValue: 'span'
105
+ },
106
+ root: _reactcomponents.slot.always(props.root, {
107
+ defaultProps: {
108
+ ...root
109
+ },
110
+ elementType: 'span'
111
+ }),
112
+ input: _reactcomponents.slot.always(props.input, {
113
+ defaultProps: {
114
+ ref: (0, _reactcomponents.useMergedRefs)(ref, spanRef),
115
+ role: 'textbox',
116
+ contentEditable: !disabled,
117
+ 'aria-readonly': disabled ? true : undefined,
118
+ tabIndex: disabled ? -1 : 0,
119
+ disabled,
120
+ suppressContentEditableWarning: true,
121
+ ...primary,
122
+ 'aria-describedby': primary['aria-describedby'] ? `${primary['aria-describedby']} ${placeholderId}` : placeholderId
123
+ },
124
+ elementType: 'span'
125
+ }),
126
+ placeholderValue,
127
+ lexicalInitialConfig: {
128
+ namespace: 'fai-EditorInput',
129
+ onError: console.error,
130
+ nodes: customNodes,
131
+ editorState: defaultValueFunction
132
+ },
133
+ editorRef,
134
+ disabled,
135
+ textPlugin,
136
+ onPaste,
137
+ handleOnChange,
138
+ defaultValue: defaultString,
139
+ trimWhiteSpace,
140
+ history
141
+ };
142
+ }; //# sourceMappingURL=useEditorInput.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["useEditorInput.tsx"],"sourcesContent":["import * as React from 'react';\nimport {\n getPartitionedNativeProps,\n slot,\n useId,\n useIsomorphicLayoutEffect,\n useMergedRefs,\n} from '@fluentui/react-components';\nimport type { EditorInputProps, EditorInputState } from './EditorInput.types';\nimport { SentinelNode } from '@fluentui-copilot/chat-input-plugins';\nimport type { LexicalEditor } from '@fluentui-copilot/react-text-editor';\nimport { LexicalPlainTextPlugin, mergeRegister } from '@fluentui-copilot/react-text-editor';\nimport { useControllableState } from '@fluentui/react-utilities';\n\n/**\n * Create the state required to render EditorInput.\n *\n * The returned state can be modified with hooks such as useEditorInputStyles_unstable,\n * before being passed to renderEditorInput_unstable.\n *\n * @param props - props from this instance of EditorInput\n * @param ref - reference to root HTMLElement of EditorInput\n */\nexport const useEditorInput_unstable = (props: EditorInputProps, ref: React.Ref<HTMLSpanElement>): EditorInputState => {\n const { onChange, onPaste, trimWhiteSpace = false, textPlugin = LexicalPlainTextPlugin, history = true } = props;\n const { root, primary } = getPartitionedNativeProps({\n primarySlotTagName: 'span',\n props,\n excludedPropNames: ['onChange', 'onPaste', 'defaultValue'],\n });\n\n const editorRef = React.useRef<LexicalEditor>(null);\n // The disabled state can also be changed by lexical (e.g. by a custom plugin) so\n // we use `useControllableState` to coordinate\n const [disabled, setDisabled] = useControllableState({\n state: props.disabled,\n initialState: false,\n });\n\n const customNodes = props.customNodes ? [...props.customNodes, SentinelNode] : [SentinelNode];\n\n const spanRef = React.useCallback(\n span => {\n // Register the `input` span with lexical\n editorRef.current?.setRootElement(span);\n },\n [editorRef],\n );\n\n // Update lexical when disabled changes\n useIsomorphicLayoutEffect(() => {\n if (editorRef.current) {\n editorRef.current?.setEditable(!disabled);\n }\n }, [disabled]);\n\n useIsomorphicLayoutEffect(() => {\n if (editorRef.current) {\n return mergeRegister(\n editorRef.current.registerEditableListener(isEditable => {\n setDisabled(!isEditable);\n }),\n editorRef.current?.registerRootListener(root => {\n if (!root) {\n return;\n }\n\n // Remove lexical's inline style so we can apply our own\n // Lexical needs the whitespace style to be either `pre` or `pre-wrap` to work correctly\n root.style.whiteSpace = '';\n }),\n );\n }\n }, [editorRef]);\n\n const handleOnChange = React.useCallback(\n (newValue: string) => {\n onChange?.({}, { value: newValue });\n },\n [onChange],\n );\n\n const [defaultString, defaultValueFunction] = (() => {\n if (typeof props.defaultValue === 'function') {\n return [undefined, props.defaultValue];\n }\n return [props.defaultValue, undefined];\n })();\n\n const placeholderValue = slot.optional(props.placeholderValue, { elementType: 'span' });\n const placeholderId = useId('chat-input-placeholder', placeholderValue?.id);\n if (placeholderValue) {\n placeholderValue.id = placeholderId;\n }\n\n return {\n components: {\n root: 'span',\n input: 'span',\n placeholderValue: 'span',\n },\n root: slot.always(props.root, { defaultProps: { ...root }, elementType: 'span' }),\n input: slot.always(props.input, {\n defaultProps: {\n ref: useMergedRefs(ref, spanRef),\n role: 'textbox',\n contentEditable: !disabled,\n 'aria-readonly': disabled ? true : undefined,\n tabIndex: disabled ? -1 : 0,\n disabled,\n suppressContentEditableWarning: true,\n ...primary,\n 'aria-describedby': primary['aria-describedby']\n ? `${primary['aria-describedby']} ${placeholderId}`\n : placeholderId,\n },\n elementType: 'span',\n }),\n placeholderValue,\n lexicalInitialConfig: {\n namespace: 'fai-EditorInput',\n onError: console.error,\n nodes: customNodes,\n editorState: defaultValueFunction,\n },\n editorRef,\n disabled,\n textPlugin,\n onPaste,\n handleOnChange,\n defaultValue: defaultString,\n trimWhiteSpace,\n history,\n };\n};\n"],"names":["onChange","trimWhiteSpace","primarySlotTagName","props","excludedPropNames","LexicalPlainTextPlugin","root","primary","editorRef","getPartitionedNativeProps","disabled","React","useRef","SentinelNode","customNodes","useCallback","span","current","_editorRef_current","useIsomorphicLayoutEffect","setEditable","registerEditableListener","isEditable","mergeRegister","setDisabled","whiteSpace","handleOnChange","newValue","value","undefined","defaultValue","placeholderValue","defaultValueFunction","id","placeholderId","elementType","defaultProps","input","slot","always","ref","spanRef","contentEditable","error"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAwBUA;;;eAAAA;;;;iEAxBa;iCAOhB;kCAEsB;iCAEyB;gCACjB;AAYnC,MAAQA,0BAAmBC,CAAAA,OAAAA;UAC3B,UACEC,SACAC,mBACAC,KAAAA,eAAoBC,uCAAA,YAAY,IAAA;YAClCC,IAAA,EAEAC,OAAMC,KACNC,IAAAA,0CAAA,EAAA;QACAP,oBAAA;QACAC;2BACeO;YAAAA;YAAQ;YAAA;SAAA;;UAEvBF,YAAAG,OAAAC,MAAA,CAAA;qFAEwC;kDAAqB;UAAEC,CAAAA,UAAAA,YAAAA,GAAAA,IAAAA,oCAAAA,EAAAA;eAAgBV,MAAAO,QAAA;sBAACG;;UAEhFC,cAAgBH,MAAMI,WACpBC,GAAAA;WAAAA,MAAAA,WAAAA;QAAAA,8BAAAA;KAAAA,GAAAA;QAAAA,8BAAAA;KAAAA;oBACEL,OAAAI,WAAA,CAAAC,CAAAA;qDACUC;QACZC;8BACCV,UAAAA,OAAAA,MAAAA,QAAAA,uBAAAA,KAAAA,IAAAA,KAAAA,IAAAA,mBAAAA,cAAAA,CAAAA;OAAU;QAAAA;KAAA;2CAGb;kDACAW,EAAAA;YACEX,UAAIA,OAAUS,EAAAA;;kCACZT,UAAAA,OAAUS,MAAO,QAAAC,uBAAjBV,KAAAA,IAAAA,KAAAA,IAAAA,mBAAAA,WAAmBY,CAAAA,CAAAA;;OAEvB;QAAAV;KAAG;kDAACA,EAAAA;YAASF,UAAAS,OAAA,EAAA;YAEbE,IAAAA;mBACMX,IAAAA,8BAAUS,EAAAA,UAASA,OAAA,CAAAI,wBAAA,CAAAC,CAAAA;4BAKnBd,CAAAA;sCAJKe,UACLf,OAAUS,MAAQI,QAAAA,uBAAyBC,KAAAA,IAAAA,KAAAA,IAAAA,mBAAAA,oBAAAA,CAAAA,CAAAA;2BACzCE;;;wEAIE;wGACF;0BAEA,CAAAC,UAAA,GAAA;;;;;KAGF;UAEJC,iBAAAf,OAAAI,WAAA,CAAAY,CAAAA;QACF3B,aAAG,QAAAA,aAAA,KAAA,IAAA,KAAA,IAAAA,SAAA,CAAA,GAAA;mBAACQ;;OAEJ;QAAAR;KAAM0B;UAEF1B,CAAAA,eAAAA,qBAAAA,GAAAA,CAAAA;mBAAiB4B,MAAOD,YAAAA,KAAAA,YAAAA;mBAAS;gBAAAE;gBAAA1B,MAAA2B,YAAA;aAAA;QACnC;eACC9B;YAAAA,MAAAA,YAAAA;YAAAA;SAAAA;;UAGH+B,mBAAsBC,qBAAAA,CAAAA,QAAAA,CAAAA,MAAqBD,gBAAI,EAAA;qBACzC;;0BACMF,IAAAA,sBAAAA,EAAAA,0BAAAA,qBAAAA,QAAAA,qBAAAA,KAAAA,IAAAA,KAAAA,IAAAA,iBAAAA,EAAAA;0BAAiBC;yBAAaG,EAAA,GAAAC;;WAExC;oBAAQ/B;kBAAoB0B;mBAAU;YACxCE,kBAAA;QAEA;cAAiEI,qBAAAA,CAAAA,MAAa,CAAAhC,MAAAG,IAAA,EAAA;YAAO8B,cAAA;gBACrF,GAAMF,IAAAA;YACN;yBACEH;QACF;QAEAM,OAAOC,qBAAA,CAAAC,MAAA,CAAApC,MAAAkC,KAAA,EAAA;0BACO;qBACV/B,IAAAA,8BAAM,EAAAkC,KAAAC;sBACNJ;iCACAN,CAAAA;gBACF,iBAAArB,WAAA,OAAAmB;gBACAvB,UAAMgC,WAAYnC,CAAAA,IAAMG;;gDAA+B;0BAAC;oCAAgBC,OAAA,CAAA,mBAAA,GAAA,CAAA,EAAAA,OAAA,CAAA,mBAAA,CAAA,CAAA,EAAA2B,cAAA,CAAA,GAAAA;;yBACjEI;;;8BAGG;uBACNI;6BACAC,KAAA;;yBAEAjC;;;;;;;sBASJqB;;;;6CAKeC"}
@@ -0,0 +1,95 @@
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
+ editorInputClassNames: function() {
13
+ return editorInputClassNames;
14
+ },
15
+ useEditorInputStyles_unstable: function() {
16
+ return useEditorInputStyles_unstable;
17
+ },
18
+ useInputClassName: function() {
19
+ return useInputClassName;
20
+ },
21
+ useLexicalStyles: function() {
22
+ return useLexicalStyles;
23
+ },
24
+ usePlaceholderClassName: function() {
25
+ return usePlaceholderClassName;
26
+ }
27
+ });
28
+ const _reactcomponents = require("@fluentui/react-components");
29
+ const editorInputClassNames = {
30
+ root: 'fai-EditorInput',
31
+ input: 'fai-EditorInput__input',
32
+ placeholderValue: 'fai-EditorInput__placeholderValue'
33
+ };
34
+ /**
35
+ * Styles for the root slot
36
+ */ const useRootClassName = (0, _reactcomponents.__resetStyles)("r1x54j0a", null, [
37
+ ".r1x54j0a{display:inline-grid;white-space:pre-wrap;}"
38
+ ]);
39
+ const useLexicalStyles = (0, _reactcomponents.__styles)({
40
+ paragraph: {
41
+ B6of3ja: "f1hu3pq6",
42
+ t21cq0: [
43
+ "f11qmguv",
44
+ "f1tyq0we"
45
+ ],
46
+ jrapky: "f19f4twv",
47
+ Frg6f3: [
48
+ "f1tyq0we",
49
+ "f11qmguv"
50
+ ]
51
+ }
52
+ }, {
53
+ d: [
54
+ ".f1hu3pq6{margin-top:0;}",
55
+ ".f11qmguv{margin-right:0;}",
56
+ ".f1tyq0we{margin-left:0;}",
57
+ ".f19f4twv{margin-bottom:0;}"
58
+ ]
59
+ });
60
+ const usePlaceholderClassName = (0, _reactcomponents.__resetStyles)("r1tldilo", null, [
61
+ ".r1tldilo{z-index:0;grid-area:1/1/1/1;color:var(--colorNeutralForeground3);font-family:var(--fontFamilyBase);font-size:var(--fontSizeBase300);font-weight:var(--fontWeightRegular);line-height:var(--lineHeightBase300);}"
62
+ ]);
63
+ const useInputClassName = (0, _reactcomponents.__resetStyles)("r18fti29", null, [
64
+ ".r18fti29{grid-area:1/1/1/1;z-index:1;width:100%;}"
65
+ ]);
66
+ const useStyles = (0, _reactcomponents.__styles)({
67
+ placeholderDisabled: {
68
+ sj55zd: "f1s2aq7o"
69
+ }
70
+ }, {
71
+ d: [
72
+ ".f1s2aq7o{color:var(--colorNeutralForegroundDisabled);}"
73
+ ]
74
+ });
75
+ const useEditorInputStyles_unstable = (state)=>{
76
+ 'use no memo';
77
+ const { disabled } = state;
78
+ const placeholderClassName = usePlaceholderClassName();
79
+ const rootClassName = useRootClassName();
80
+ const inputClassName = useInputClassName();
81
+ const styles = useStyles();
82
+ state.root.className = (0, _reactcomponents.mergeClasses)(editorInputClassNames.root, rootClassName, state.root.className);
83
+ state.input.className = (0, _reactcomponents.mergeClasses)(editorInputClassNames.input, inputClassName, state.input.className);
84
+ state.lexicalInitialConfig = {
85
+ ...state.lexicalInitialConfig,
86
+ theme: {
87
+ ...useLexicalStyles(),
88
+ ...state.lexicalInitialConfig.theme
89
+ }
90
+ };
91
+ if (state.placeholderValue) {
92
+ state.placeholderValue.className = (0, _reactcomponents.mergeClasses)(editorInputClassNames.placeholderValue, placeholderClassName, disabled && styles.placeholderDisabled, state.placeholderValue.className);
93
+ }
94
+ return state;
95
+ }; //# sourceMappingURL=useEditorInputStyles.styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["useEditorInputStyles.styles.ts"],"sourcesContent":["import {\n makeResetStyles,\n makeStyles,\n mergeClasses,\n shorthands,\n tokens,\n typographyStyles,\n} from '@fluentui/react-components';\nimport type { SlotClassNames } from '@fluentui/react-components';\nimport type { EditorInputSlots, EditorInputState } from './EditorInput.types';\n\nexport const editorInputClassNames: SlotClassNames<EditorInputSlots> = {\n root: 'fai-EditorInput',\n input: 'fai-EditorInput__input',\n placeholderValue: 'fai-EditorInput__placeholderValue',\n};\n\n/**\n * Styles for the root slot\n */\nconst useRootClassName = makeResetStyles({\n display: 'inline-grid',\n whiteSpace: 'pre-wrap',\n});\n\nexport const useLexicalStyles = makeStyles({\n paragraph: {\n ...shorthands.margin(0),\n },\n});\n\nexport const usePlaceholderClassName = makeResetStyles({\n zIndex: 0,\n gridArea: '1 / 1 / 1 / 1',\n\n color: tokens.colorNeutralForeground3,\n ...typographyStyles.body1,\n});\n\nexport const useInputClassName = makeResetStyles({\n gridArea: '1 / 1 / 1 / 1',\n zIndex: 1,\n width: '100%',\n});\n\nconst useStyles = makeStyles({\n placeholderDisabled: {\n color: tokens.colorNeutralForegroundDisabled,\n },\n});\n/**\n * Apply styling to the EditorInput slots based on the state\n */\nexport const useEditorInputStyles_unstable = (state: EditorInputState): EditorInputState => {\n 'use no memo';\n\n const { disabled } = state;\n const placeholderClassName = usePlaceholderClassName();\n const rootClassName = useRootClassName();\n const inputClassName = useInputClassName();\n const styles = useStyles();\n\n state.root.className = mergeClasses(editorInputClassNames.root, rootClassName, state.root.className);\n\n state.input.className = mergeClasses(editorInputClassNames.input, inputClassName, state.input.className);\n\n state.lexicalInitialConfig = {\n ...state.lexicalInitialConfig,\n theme: { ...useLexicalStyles(), ...state.lexicalInitialConfig.theme },\n };\n\n if (state.placeholderValue) {\n state.placeholderValue.className = mergeClasses(\n editorInputClassNames.placeholderValue,\n placeholderClassName,\n disabled && styles.placeholderDisabled,\n state.placeholderValue.className,\n );\n }\n\n return state;\n};\n"],"names":["editorInputClassNames","useEditorInputStyles_unstable","typographyStyles","whiteSpace","tokens","colorNeutralForeground3","root","input","placeholderValue","display","__resetStyles","__styles","paragraph","B6of3ja","useLexicalStyles","shorthands","Frg6f3","zIndex","color","useStyles","placeholderDisabled","useInputClassName","gridArea","d","state","disabled","placeholderClassName","rootClassName","inputClassName","styles","className","mergeClasses","lexicalInitialConfig","theme"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;;;;;;;;IAWaA,qBAAAA;eAAAA;;IAsCbC,6BAAA;eAAAA;;IAbKC,iBAAsB;eAAtBA;;IAdHC,gBAAY;eAAZA;;IAaOC,uBAAOC;eAAPD;;;iCA7BS;AAKX,MAAMJ,wBAA0D;UACrEM;WACAC;sBACAC;AACF;AAEA;;CAEC,SAECC,mBAASC,IAAAA,8BAAA,EAAA,YAAA,MAAA;IAAA;CAAA;AACTP,MAAAA,mBAAYQ,IAAAA,yBAAA,EAAA;IACdC,WAAA;QAEAC,SAAaC;QACXF,QAAAA;YAAAA;YAAW;SAAA;gBACNG;QACLC,QAAA;YAAA;YAAA;SAAA;IACF;AAEA,GAAA;OACEC;QAAAA;QAAQ;QAAA;QAAA;KAAA;;AAGRC,MAAOd,0BAAOC,IAAAA,8BAAuB,EAAA,YAAA,MAAA;IAAA;CAAA;AAClCH,MAAAA,oBAAsBQ,IAAAA,8BAAA,EAAA,YAAA,MAAA;IAAA;CAAA;AAC3B,MAAGS,YAAAR,IAAAA,yBAAA,EAAA;IAEHS,qBAAaC;QACXC,QAAAA;;;IAGFC,GAAG;QAAA;KAAA;AAEH;AAIA,MAAAtB,gCAAAuB,CAAAA;IACA;IAEC,MACD,EACEC,QAAA,KAEAD;UACAE,uBAAMA;UACNC,gBAAMA;UACNC,iBAAMA;UACNC,SAAMA;UAENL,IAAMlB,CAAAA,SAAKwB,GAASC,IAAAA,6BAAGA,EAAAA,sBAAa/B,IAAsBM,EAAIqB,eAAEA,MAAeH,IAAMlB,CAAAA,SAAKwB;UAE1FN,KAAMjB,CAAAA,SAAMuB,GAASC,IAAAA,6BAAGA,EAAAA,sBAAa/B,KAAsBO,EAAKqB,gBAAEA,MAAgBJ,KAAMjB,CAAAA,SAAMuB;UAE9FN,oBAAMQ,GAAoB;iBACrBR,oBAAMQ;eACTC;iCAAYnB;qBAAuBU,oBAAMQ,CAAAA,KAAoB;;;QAG/DR,MAAIA,gBAAMhB,EAAgB;cACxBgB,gBAAMhB,CAAAA,SAAiBsB,GAAAA,IAAAA,6BAAYC,EAAAA,sBACjC/B,gBAAsBQ,EAAAA,sBACtBkB,YACAD,OAAYI,mBAAOT,EAAAA,MACnBI,gBAAMhB,CAAAA,SAAiBsB;;WAI3BN;AACF"}
@@ -0,0 +1,29 @@
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
+ EditorInput: function() {
13
+ return _EditorInput.EditorInput;
14
+ },
15
+ editorInputClassNames: function() {
16
+ return _EditorInput.editorInputClassNames;
17
+ },
18
+ renderEditorInput_unstable: function() {
19
+ return _EditorInput.renderEditorInput_unstable;
20
+ },
21
+ useEditorInputStyles_unstable: function() {
22
+ return _EditorInput.useEditorInputStyles_unstable;
23
+ },
24
+ useEditorInput_unstable: function() {
25
+ return _EditorInput.useEditorInput_unstable;
26
+ }
27
+ });
28
+ const _EditorInput = require("./EditorInput");
29
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["index.ts"],"sourcesContent":["export type { EditorInputProps, EditorInputSlots, EditorInputState, EditorInputValueData } from './EditorInput';\nexport {\n EditorInput,\n editorInputClassNames,\n renderEditorInput_unstable,\n useEditorInputStyles_unstable,\n useEditorInput_unstable,\n} from './EditorInput';\n"],"names":["EditorInput","editorInputClassNames","renderEditorInput_unstable","useEditorInputStyles_unstable","useEditorInput_unstable"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;;;;;;;;IAEEA,WAAW;eAAXA,wBAAW;;IACXC,qBAAqB;eAArBA,kCAAqB;;IACrBC,0BAA0B;eAA1BA,uCAA0B;;IAC1BC,6BAA6B;eAA7BA,0CAA6B;;IAC7BC,uBAAuB;eAAvBA,oCAAuB;;;6BAClB"}
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@fluentui-copilot/react-editor-input",
3
+ "version": "0.0.0-nightly-20240606-0406-a04dfe79.1",
4
+ "description": "a base rich editor input.",
5
+ "main": "lib-commonjs/index.js",
6
+ "module": "lib/index.js",
7
+ "typings": "./dist/index.d.ts",
8
+ "sideEffects": false,
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/microsoft/fluentai"
12
+ },
13
+ "license": "MIT",
14
+ "dependencies": {
15
+ "@fluentui-copilot/chat-input-plugins": "0.0.0-nightly-20240606-0406-a04dfe79.1",
16
+ "@fluentui-copilot/react-chat-input-plugins": "0.0.0-nightly-20240606-0406-a04dfe79.1",
17
+ "@fluentui-copilot/react-text-editor": "0.0.0-nightly-20240606-0406-a04dfe79.1",
18
+ "@swc/helpers": "^0.5.1"
19
+ },
20
+ "peerDependencies": {
21
+ "@fluentui/react-components": ">=9.52.0 <10.0.0",
22
+ "@fluentui/react-jsx-runtime": ">=9.0.38 <10.0.0",
23
+ "@fluentui/react-utilities": ">=9.18.9 <10.0.0",
24
+ "@types/react": ">=16.14.0 <19.0.0",
25
+ "@types/react-dom": ">=16.9.8 <19.0.0",
26
+ "react": ">=16.14.0 <19.0.0",
27
+ "react-dom": ">=16.14.0 <19.0.0"
28
+ },
29
+ "beachball": {},
30
+ "exports": {
31
+ ".": {
32
+ "types": "./dist/index.d.ts",
33
+ "node": "./lib-commonjs/index.js",
34
+ "import": "./lib/index.js",
35
+ "require": "./lib-commonjs/index.js"
36
+ },
37
+ "./package.json": "./package.json"
38
+ }
39
+ }