@fluentui-copilot/react-editor-input 0.5.2 → 0.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.json CHANGED
@@ -2,7 +2,22 @@
2
2
  "name": "@fluentui-copilot/react-editor-input",
3
3
  "entries": [
4
4
  {
5
- "date": "Tue, 01 Jul 2025 14:43:46 GMT",
5
+ "date": "Thu, 17 Jul 2025 17:49:26 GMT",
6
+ "tag": "@fluentui-copilot/react-editor-input_v0.5.3",
7
+ "version": "0.5.3",
8
+ "comments": {
9
+ "patch": [
10
+ {
11
+ "author": "hochelmartin@gmail.com",
12
+ "package": "@fluentui-copilot/react-editor-input",
13
+ "commit": "fef5160c07333e8d9996952a305b34e357604919",
14
+ "comment": "feat: enable griffel raw styles"
15
+ }
16
+ ]
17
+ }
18
+ },
19
+ {
20
+ "date": "Tue, 01 Jul 2025 14:45:28 GMT",
6
21
  "tag": "@fluentui-copilot/react-editor-input_v0.5.2",
7
22
  "version": "0.5.2",
8
23
  "comments": {
package/CHANGELOG.md CHANGED
@@ -1,12 +1,21 @@
1
1
  # Change Log - @fluentui-copilot/react-editor-input
2
2
 
3
- This log was last generated on Tue, 01 Jul 2025 14:43:46 GMT and should not be manually modified.
3
+ This log was last generated on Thu, 17 Jul 2025 17:49:26 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## [0.5.3](https://github.com/microsoft/fluentai/tree/@fluentui-copilot/react-editor-input_v0.5.3)
8
+
9
+ Thu, 17 Jul 2025 17:49:26 GMT
10
+ [Compare changes](https://github.com/microsoft/fluentai/compare/@fluentui-copilot/react-editor-input_v0.5.2..@fluentui-copilot/react-editor-input_v0.5.3)
11
+
12
+ ### Patches
13
+
14
+ - feat: enable griffel raw styles ([PR #3227](https://github.com/microsoft/fluentai/pull/3227) by hochelmartin@gmail.com)
15
+
7
16
  ## [0.5.2](https://github.com/microsoft/fluentai/tree/@fluentui-copilot/react-editor-input_v0.5.2)
8
17
 
9
- Tue, 01 Jul 2025 14:43:46 GMT
18
+ Tue, 01 Jul 2025 14:45:28 GMT
10
19
  [Compare changes](https://github.com/microsoft/fluentai/compare/@fluentui-copilot/react-editor-input_v0.5.1..@fluentui-copilot/react-editor-input_v0.5.2)
11
20
 
12
21
  ### Patches
@@ -1,2 +1 @@
1
1
  export { EditorInput, editorInputClassNames, renderEditorInput_unstable, useEditorInputStyles_unstable, useEditorInput_unstable, useInputClassName, useLexicalStyles, usePlaceholderClassName } from './components/EditorInput/index';
2
- //# sourceMappingURL=EditorInput.js.map
@@ -3,10 +3,9 @@ import { useEditorInput_unstable } from './useEditorInput';
3
3
  import { renderEditorInput_unstable } from './renderEditorInput';
4
4
  import { useEditorInputStyles_unstable } from './useEditorInputStyles.styles';
5
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);
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
10
  });
11
11
  EditorInput.displayName = 'EditorInput';
12
- //# sourceMappingURL=EditorInput.js.map
@@ -1,4 +1,3 @@
1
1
  /**
2
2
  * Data passed to the `onChange` callback when the chat input's value changes.
3
- */export {};
4
- //# sourceMappingURL=EditorInput.types.js.map
3
+ */ export { };
@@ -2,4 +2,3 @@ export { EditorInput } from './EditorInput';
2
2
  export { renderEditorInput_unstable } from './renderEditorInput';
3
3
  export { useEditorInput_unstable } from './useEditorInput';
4
4
  export { editorInputClassNames, useEditorInputStyles_unstable, useInputClassName, useLexicalStyles, usePlaceholderClassName } from './useEditorInputStyles.styles';
5
- //# sourceMappingURL=index.js.map
@@ -1,30 +1,35 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@fluentui/react-jsx-runtime/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@fluentui/react-jsx-runtime/jsx-runtime";
2
2
  import { assertSlots } from '@fluentui/react-components';
3
3
  import { LexicalComposer, LexicalErrorBoundary, LexicalEditorRefPlugin, LexicalHistoryPlugin } from '@fluentui-copilot/react-text-editor';
4
4
  import { BasicFunctionalityPlugin } from '@fluentui-copilot/react-chat-input-plugins';
5
5
  /**
6
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
- isSentinelNodeEnabled: state.isSentinelNodeEnabled
23
- }), state.history && /*#__PURE__*/_jsx(LexicalHistoryPlugin, {})]
24
- }), /*#__PURE__*/_jsx(LexicalEditorRefPlugin, {
25
- editorRef: state.editorRef
26
- })]
27
- })
28
- });
7
+ */ export const renderEditorInput_unstable = (state)=>{
8
+ assertSlots(state);
9
+ return /*#__PURE__*/ _jsx(state.root, {
10
+ children: /*#__PURE__*/ _jsxs(LexicalComposer, {
11
+ initialConfig: state.lexicalInitialConfig,
12
+ children: [
13
+ /*#__PURE__*/ _jsx(state.textPlugin, {
14
+ contentEditable: /*#__PURE__*/ _jsx(state.input, {}),
15
+ ErrorBoundary: LexicalErrorBoundary,
16
+ placeholder: state.placeholderValue ? /*#__PURE__*/ _jsx(state.placeholderValue, {}) : null
17
+ }),
18
+ /*#__PURE__*/ _jsxs(_Fragment, {
19
+ children: [
20
+ /*#__PURE__*/ _jsx(BasicFunctionalityPlugin, {
21
+ onContentChange: state.handleOnChange,
22
+ onPaste: state.onPaste,
23
+ trimWhitespace: state.trimWhiteSpace,
24
+ isSentinelNodeEnabled: state.isSentinelNodeEnabled
25
+ }),
26
+ state.history && /*#__PURE__*/ _jsx(LexicalHistoryPlugin, {})
27
+ ]
28
+ }),
29
+ /*#__PURE__*/ _jsx(LexicalEditorRefPlugin, {
30
+ editorRef: state.editorRef
31
+ })
32
+ ]
33
+ })
34
+ });
29
35
  };
30
- //# sourceMappingURL=renderEditorInput.js.map
@@ -13,148 +13,147 @@ import { mergeCallbacks, useControllableState } from '@fluentui/react-utilities'
13
13
  *
14
14
  * @param props - props from this instance of EditorInput
15
15
  * @param ref - reference to root HTMLElement of EditorInput
16
- */
17
- export const useEditorInput_unstable = (props, ref) => {
18
- const {
19
- onChange,
20
- onPaste,
21
- trimWhiteSpace = false,
22
- textPlugin = LexicalPlainTextPlugin,
23
- history = true,
24
- editorRef: userEditorRef,
25
- customTheme,
26
- isSentinelNodeEnabled = true
27
- } = props;
28
- const {
29
- root,
30
- primary
31
- } = getPartitionedNativeProps({
32
- primarySlotTagName: 'span',
33
- props,
34
- excludedPropNames: ['onChange', 'onPaste', 'defaultValue']
35
- });
36
- const editorRef = useMergedRefs(React.useRef(null), userEditorRef);
37
- // The disabled state can also be changed by lexical (e.g. by a custom plugin) so
38
- // we use `useControllableState` to coordinate
39
- const [disabled, setDisabled] = useControllableState({
40
- state: props.disabled,
41
- initialState: false
42
- });
43
- const customNodes = props.customNodes ? [...props.customNodes, SentinelNode] : [SentinelNode];
44
- const spanRef = React.useCallback(span => {
45
- var
46
- // Register the `input` span with lexical
47
- _editorRef_current;
48
- (_editorRef_current = editorRef.current) === null || _editorRef_current === void 0 ? void 0 : _editorRef_current.setRootElement(span);
49
- }, [editorRef]);
50
- // Update lexical when disabled changes
51
- useIsomorphicLayoutEffect(() => {
52
- if (editorRef.current) {
53
- var _editorRef_current;
54
- (_editorRef_current = editorRef.current) === null || _editorRef_current === void 0 ? void 0 : _editorRef_current.setEditable(!disabled);
55
- }
56
- }, [disabled]);
57
- useIsomorphicLayoutEffect(() => {
58
- if (editorRef.current) {
59
- var _editorRef_current;
60
- return 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;
16
+ */ export const useEditorInput_unstable = (props, ref)=>{
17
+ const { onChange, onPaste, trimWhiteSpace = false, textPlugin = LexicalPlainTextPlugin, history = true, editorRef: userEditorRef, customTheme, isSentinelNodeEnabled = true } = props;
18
+ const { root, primary } = getPartitionedNativeProps({
19
+ primarySlotTagName: 'span',
20
+ props,
21
+ excludedPropNames: [
22
+ 'onChange',
23
+ 'onPaste',
24
+ 'defaultValue'
25
+ ]
26
+ });
27
+ const editorRef = useMergedRefs(React.useRef(null), userEditorRef);
28
+ // The disabled state can also be changed by lexical (e.g. by a custom plugin) so
29
+ // we use `useControllableState` to coordinate
30
+ const [disabled, setDisabled] = useControllableState({
31
+ state: props.disabled,
32
+ initialState: false
33
+ });
34
+ const customNodes = props.customNodes ? [
35
+ ...props.customNodes,
36
+ SentinelNode
37
+ ] : [
38
+ SentinelNode
39
+ ];
40
+ const spanRef = React.useCallback((span)=>{
41
+ var // 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
+ }, [
45
+ editorRef
46
+ ]);
47
+ // Update lexical when disabled changes
48
+ useIsomorphicLayoutEffect(()=>{
49
+ if (editorRef.current) {
50
+ var _editorRef_current;
51
+ (_editorRef_current = editorRef.current) === null || _editorRef_current === void 0 ? void 0 : _editorRef_current.setEditable(!disabled);
65
52
  }
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
- }, [editorRef]);
72
- const handleOnChange = React.useCallback(newValue => {
73
- onChange === null || onChange === void 0 ? void 0 : onChange({}, {
74
- value: newValue
53
+ }, [
54
+ disabled
55
+ ]);
56
+ useIsomorphicLayoutEffect(()=>{
57
+ if (editorRef.current) {
58
+ var _editorRef_current;
59
+ return mergeRegister(editorRef.current.registerEditableListener((isEditable)=>{
60
+ setDisabled(!isEditable);
61
+ }), (_editorRef_current = editorRef.current) === null || _editorRef_current === void 0 ? void 0 : _editorRef_current.registerRootListener((root)=>{
62
+ if (!root) {
63
+ return;
64
+ }
65
+ // Remove lexical's inline style so we can apply our own
66
+ // Lexical needs the whitespace style to be either `pre` or `pre-wrap` to work correctly
67
+ root.style.whiteSpace = '';
68
+ }));
69
+ }
70
+ }, [
71
+ editorRef
72
+ ]);
73
+ const handleOnChange = React.useCallback((newValue)=>{
74
+ onChange === null || onChange === void 0 ? void 0 : onChange({}, {
75
+ value: newValue
76
+ });
77
+ }, [
78
+ onChange
79
+ ]);
80
+ const defaultValueFunction = useDefaultValueFunction(props);
81
+ const placeholderValue = slot.optional(props.placeholderValue, {
82
+ elementType: 'span'
75
83
  });
76
- }, [onChange]);
77
- const defaultValueFunction = useDefaultValueFunction(props);
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,
84
+ const placeholderId = useId('chat-input-placeholder', placeholderValue === null || placeholderValue === void 0 ? void 0 : placeholderValue.id);
85
+ if (placeholderValue) {
86
+ placeholderValue.id = placeholderId;
87
+ }
88
+ return {
89
+ components: {
90
+ root: 'span',
91
+ input: 'span',
92
+ placeholderValue: 'span'
93
+ },
94
+ root: slot.always(props.root, {
95
+ defaultProps: {
96
+ ...root
97
+ },
98
+ elementType: 'span'
99
+ }),
100
+ input: slot.always(props.input, {
101
+ defaultProps: {
102
+ ref: useMergedRefs(ref, spanRef),
103
+ role: 'textbox',
104
+ contentEditable: !disabled,
105
+ 'aria-readonly': disabled ? true : undefined,
106
+ disabled,
107
+ suppressContentEditableWarning: true,
108
+ tabIndex: disabled ? undefined : 0,
109
+ ...primary,
110
+ 'aria-describedby': primary['aria-describedby'] ? `${primary['aria-describedby']} ${placeholderId}` : placeholderId
111
+ },
112
+ elementType: 'span'
113
+ }),
114
+ placeholderValue,
115
+ lexicalInitialConfig: {
116
+ namespace: 'fai-EditorInput',
117
+ onError: console.error,
118
+ nodes: customNodes,
119
+ editorState: defaultValueFunction,
120
+ theme: customTheme
121
+ },
122
+ editorRef,
103
123
  disabled,
104
- suppressContentEditableWarning: true,
105
- tabIndex: disabled ? undefined : 0,
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
- theme: customTheme
118
- },
119
- editorRef,
120
- disabled,
121
- textPlugin,
122
- onPaste,
123
- handleOnChange,
124
- trimWhiteSpace,
125
- history,
126
- isSentinelNodeEnabled
127
- };
124
+ textPlugin,
125
+ onPaste,
126
+ handleOnChange,
127
+ trimWhiteSpace,
128
+ history,
129
+ isSentinelNodeEnabled
130
+ };
128
131
  };
129
132
  function useDefaultValueFunction(props) {
130
- var _targetDocument_defaultView;
131
- const {
132
- targetDocument
133
- } = useFluent();
134
- const requestAnimationFrame = targetDocument === null || targetDocument === void 0 ? void 0 : (_targetDocument_defaultView = targetDocument.defaultView) === null || _targetDocument_defaultView === void 0 ? void 0 : _targetDocument_defaultView.requestAnimationFrame;
135
- const [defaultValueFunction] = React.useState(() => {
136
- const {
137
- defaultValue,
138
- onDefaultValueSet
139
- } = props;
140
- if (defaultValue === undefined) {
141
- return undefined;
142
- }
143
- const insertDefaultValueFunction = typeof defaultValue === 'function' ? defaultValue : () => {
144
- $insertNodes([$createTextNode(defaultValue)]);
145
- };
146
- // After the defaultValue function has run, read back the result and give
147
- // it to the onDefaultValueSet callback.
148
- const readDefaultValueFunction = onDefaultValueSet ? () => {
149
- const text = $getRoot().getTextContent().replace(SENTINEL_VALUE, '');
150
- // This runs while rendering `LexicalComposer` so delay calling back into the parent
151
- // until after finished rendering `LexicalComposer`
152
- requestAnimationFrame === null || requestAnimationFrame === void 0 ? void 0 : requestAnimationFrame(() => {
153
- onDefaultValueSet === null || onDefaultValueSet === void 0 ? void 0 : onDefaultValueSet(text);
154
- });
155
- } : undefined;
156
- return mergeCallbacks(insertDefaultValueFunction, readDefaultValueFunction);
157
- });
158
- return defaultValueFunction;
133
+ var _targetDocument_defaultView;
134
+ const { targetDocument } = useFluent();
135
+ const requestAnimationFrame = targetDocument === null || targetDocument === void 0 ? void 0 : (_targetDocument_defaultView = targetDocument.defaultView) === null || _targetDocument_defaultView === void 0 ? void 0 : _targetDocument_defaultView.requestAnimationFrame;
136
+ const [defaultValueFunction] = React.useState(()=>{
137
+ const { defaultValue, onDefaultValueSet } = props;
138
+ if (defaultValue === undefined) {
139
+ return undefined;
140
+ }
141
+ const insertDefaultValueFunction = typeof defaultValue === 'function' ? defaultValue : ()=>{
142
+ $insertNodes([
143
+ $createTextNode(defaultValue)
144
+ ]);
145
+ };
146
+ // After the defaultValue function has run, read back the result and give
147
+ // it to the onDefaultValueSet callback.
148
+ const readDefaultValueFunction = onDefaultValueSet ? ()=>{
149
+ const text = $getRoot().getTextContent().replace(SENTINEL_VALUE, '');
150
+ // This runs while rendering `LexicalComposer` so delay calling back into the parent
151
+ // until after finished rendering `LexicalComposer`
152
+ requestAnimationFrame === null || requestAnimationFrame === void 0 ? void 0 : requestAnimationFrame(()=>{
153
+ onDefaultValueSet === null || onDefaultValueSet === void 0 ? void 0 : onDefaultValueSet(text);
154
+ });
155
+ } : undefined;
156
+ return mergeCallbacks(insertDefaultValueFunction, readDefaultValueFunction);
157
+ });
158
+ return defaultValueFunction;
159
159
  }
160
- //# sourceMappingURL=useEditorInput.js.map
@@ -0,0 +1,61 @@
1
+ import { makeResetStyles, makeStyles, mergeClasses } from '@fluentui/react-components';
2
+ import { tokens, typographyStyles } from '@fluentui-copilot/tokens';
3
+ export const editorInputClassNames = {
4
+ root: 'fai-EditorInput',
5
+ input: 'fai-EditorInput__input',
6
+ placeholderValue: 'fai-EditorInput__placeholderValue'
7
+ };
8
+ /**
9
+ * Styles for the root slot
10
+ */ const useRootClassName = makeResetStyles({
11
+ display: 'inline-grid',
12
+ whiteSpace: 'pre-wrap'
13
+ });
14
+ export const useLexicalStyles = makeStyles({
15
+ paragraph: {
16
+ margin: 0,
17
+ textAlign: 'start'
18
+ }
19
+ });
20
+ export const usePlaceholderClassName = makeResetStyles({
21
+ zIndex: 0,
22
+ gridArea: '1 / 1 / 1 / 1',
23
+ color: tokens.colorNeutralForeground4,
24
+ ...typographyStyles.body1,
25
+ '@media (forced-colors: active)': {
26
+ color: 'GrayText'
27
+ }
28
+ });
29
+ export const useInputClassName = makeResetStyles({
30
+ gridArea: '1 / 1 / 1 / 1',
31
+ zIndex: 1,
32
+ width: '100%'
33
+ });
34
+ const useStyles = makeStyles({
35
+ placeholderDisabled: {
36
+ color: tokens.colorNeutralForegroundDisabled
37
+ }
38
+ });
39
+ /**
40
+ * Apply styling to the EditorInput slots based on the state
41
+ */ export const useEditorInputStyles_unstable = (state)=>{
42
+ 'use no memo';
43
+ const { disabled } = state;
44
+ const placeholderClassName = usePlaceholderClassName();
45
+ const rootClassName = useRootClassName();
46
+ const inputClassName = useInputClassName();
47
+ const styles = useStyles();
48
+ state.root.className = mergeClasses(editorInputClassNames.root, rootClassName, state.root.className);
49
+ state.input.className = mergeClasses(editorInputClassNames.input, inputClassName, state.input.className);
50
+ state.lexicalInitialConfig = {
51
+ ...state.lexicalInitialConfig,
52
+ theme: {
53
+ ...useLexicalStyles(),
54
+ ...state.lexicalInitialConfig.theme
55
+ }
56
+ };
57
+ if (state.placeholderValue) {
58
+ state.placeholderValue.className = mergeClasses(editorInputClassNames.placeholderValue, placeholderClassName, disabled && styles.placeholderDisabled, state.placeholderValue.className);
59
+ }
60
+ return state;
61
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["useEditorInputStyles.styles.ts"],"sourcesContent":["import { makeResetStyles, makeStyles, mergeClasses } from '@fluentui/react-components';\nimport { tokens, typographyStyles } from '@fluentui-copilot/tokens';\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 margin: 0,\n textAlign: 'start',\n },\n});\n\nexport const usePlaceholderClassName = makeResetStyles({\n zIndex: 0,\n gridArea: '1 / 1 / 1 / 1',\n\n color: tokens.colorNeutralForeground4,\n ...typographyStyles.body1,\n\n '@media (forced-colors: active)': {\n color: 'GrayText',\n },\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","tokens","typographyStyles","editorInputClassNames","root","input","placeholderValue","useRootClassName","display","whiteSpace","useLexicalStyles","paragraph","margin","textAlign","usePlaceholderClassName","zIndex","gridArea","color","colorNeutralForeground4","body1","useInputClassName","width","useStyles","placeholderDisabled","colorNeutralForegroundDisabled","useEditorInputStyles_unstable","state","disabled","placeholderClassName","rootClassName","inputClassName","styles","className","lexicalInitialConfig","theme"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,eAAe,EAAEC,UAAU,EAAEC,YAAY,QAAQ,6BAA6B;AACvF,SAASC,MAAM,EAAEC,gBAAgB,QAAQ,2BAA2B;AAIpE,OAAO,MAAMC,wBAA0D;IACrEC,MAAM;IACNC,OAAO;IACPC,kBAAkB;AACpB,EAAE;AAEF;;CAEC,GACD,MAAMC,mBAAmBT,gBAAgB;IACvCU,SAAS;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T,EAAE"}
package/lib/index.js CHANGED
@@ -1,2 +1 @@
1
1
  export { EditorInput, editorInputClassNames, renderEditorInput_unstable, useEditorInputStyles_unstable, useEditorInput_unstable } from './EditorInput';
2
- //# sourceMappingURL=index.js.map
@@ -35,4 +35,3 @@ _export(exports, {
35
35
  }
36
36
  });
37
37
  const _index = require("./components/EditorInput/index");
38
- //# sourceMappingURL=EditorInput.js.map
@@ -18,4 +18,4 @@ const EditorInput = /*#__PURE__*/ _react.forwardRef((props, ref)=>{
18
18
  (0, _useEditorInputStylesstyles.useEditorInputStyles_unstable)(state);
19
19
  return (0, _renderEditorInput.renderEditorInput_unstable)(state);
20
20
  });
21
- EditorInput.displayName = 'EditorInput'; //# sourceMappingURL=EditorInput.js.map
21
+ EditorInput.displayName = 'EditorInput';
@@ -1 +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"}
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","ref","state","useEditorInput_unstable","useEditorInputStyles_unstable","renderEditorInput_unstable","displayName"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAQaA;;;eAAAA;;;;iEARU;gCACiB;mCACG;4CACG;AAKvC,MAAMA,cAAAA,WAAAA,GAAqDC,OAAMC,UAAU,CAAC,CAACC,OAAOC;IACzF,MAAMC,QAAQC,IAAAA,uCAAAA,EAAwBH,OAAOC;IAE7CG,IAAAA,yDAAAA,EAA8BF;IAC9B,OAAOG,IAAAA,6CAAAA,EAA2BH;AACpC;AAEAL,YAAYS,WAAW,GAAG"}
@@ -4,4 +4,3 @@
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- //# sourceMappingURL=EditorInput.types.js.map
@@ -38,4 +38,3 @@ const _EditorInput = require("./EditorInput");
38
38
  const _renderEditorInput = require("./renderEditorInput");
39
39
  const _useEditorInput = require("./useEditorInput");
40
40
  const _useEditorInputStylesstyles = require("./useEditorInputStyles.styles");
41
- //# sourceMappingURL=index.js.map
@@ -40,4 +40,4 @@ const renderEditorInput_unstable = (state)=>{
40
40
  ]
41
41
  })
42
42
  });
43
- }; //# sourceMappingURL=renderEditorInput.js.map
43
+ };
@@ -1 +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 isSentinelNodeEnabled={state.isSentinelNodeEnabled}\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","isSentinelNodeEnabled","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;mDACjBc,MAASd,qBAAa;;yCACtBe,WAAAA,GAAAA,IAAAA,eAAgBf,EAAAA,qCAAoB,EAAA,CAAA;qBAAA;;mDACpCgB,uCAAAA,EAAuBhB;;;;;;gDAIciB"}
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 isSentinelNodeEnabled={state.isSentinelNodeEnabled}\n />\n {state.history && <LexicalHistoryPlugin />}\n </>\n <LexicalEditorRefPlugin editorRef={state.editorRef} />\n </LexicalComposer>\n </state.root>\n );\n};\n"],"names":["renderEditorInput_unstable","state","assertSlots","_jsx","root","_jsxs","LexicalComposer","initialConfig","lexicalInitialConfig","textPlugin","contentEditable","input","ErrorBoundary","LexicalErrorBoundary","placeholder","placeholderValue","_Fragment","BasicFunctionalityPlugin","onContentChange","handleOnChange","onPaste","trimWhitespace","trimWhiteSpace","isSentinelNodeEnabled","history","LexicalHistoryPlugin","LexicalEditorRefPlugin","editorRef"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAgBaA;;;eAAAA;;;4BAfb;iCAE4B;iCAOrB;uCACkC;AAKlC,MAAMA,6BAA6B,CAACC;IACzCC,IAAAA,4BAAAA,EAA8BD;IAE9B,OAAA,WAAA,GACEE,IAAAA,eAAA,EAACF,MAAMG,IAAI,EAAA;kBACT,WAAA,GAAAC,IAAAA,gBAAA,EAACC,gCAAAA,EAAAA;YAAgBC,eAAeN,MAAMO,oBAAoB;;8BACxDL,IAAAA,eAAA,EAACF,MAAMQ,UAAU,EAAA;oBACfC,iBAAAA,WAAAA,GAAiBP,IAAAA,eAAA,EAACF,MAAMU,KAAK,EAAA,CAAA;oBAC7BC,eAAeC,qCAAAA;oBACfC,aAAab,MAAMc,gBAAgB,GAAA,WAAA,GAAGZ,IAAAA,eAAA,EAACF,MAAMc,gBAAgB,EAAA,CAAA,KAAM;;8BAErEV,IAAAA,gBAAA,EAAAW,oBAAA,EAAA;;sCACEb,IAAAA,eAAA,EAACc,+CAAAA,EAAAA;4BACCC,iBAAiBjB,MAAMkB,cAAc;4BACrCC,SAASnB,MAAMmB,OAAO;4BACtBC,gBAAgBpB,MAAMqB,cAAc;4BACpCC,uBAAuBtB,MAAMsB,qBAAqB;;wBAEnDtB,MAAMuB,OAAO,IAAA,WAAA,GAAIrB,IAAAA,eAAA,EAACsB,qCAAAA,EAAAA,CAAAA;;;8BAErBtB,IAAAA,eAAA,EAACuB,uCAAAA,EAAAA;oBAAuBC,WAAW1B,MAAM0B,SAAS;;;;;AAI1D"}
@@ -39,8 +39,7 @@ const useEditorInput_unstable = (props, ref)=>{
39
39
  _chatinputplugins.SentinelNode
40
40
  ];
41
41
  const spanRef = _react.useCallback((span)=>{
42
- var // Register the `input` span with lexical
43
- _editorRef_current;
42
+ var _editorRef_current;
44
43
  (_editorRef_current = editorRef.current) === null || _editorRef_current === void 0 ? void 0 : _editorRef_current.setRootElement(span);
45
44
  }, [
46
45
  editorRef
@@ -157,4 +156,4 @@ function useDefaultValueFunction(props) {
157
156
  return (0, _reactutilities.mergeCallbacks)(insertDefaultValueFunction, readDefaultValueFunction);
158
157
  });
159
158
  return defaultValueFunction;
160
- } //# sourceMappingURL=useEditorInput.js.map
159
+ }
@@ -1 +1 @@
1
- {"version":3,"sources":["useEditorInput.tsx"],"sourcesContent":["import * as React from 'react';\nimport {\n getPartitionedNativeProps,\n slot,\n useFluent,\n useId,\n useIsomorphicLayoutEffect,\n useMergedRefs,\n} from '@fluentui/react-components';\nimport type { EditorInputProps, EditorInputState } from './EditorInput.types';\nimport { SentinelNode, SENTINEL_VALUE } from '@fluentui-copilot/chat-input-plugins';\nimport type { LexicalEditor } from '@fluentui-copilot/react-text-editor';\nimport { $createTextNode, $insertNodes } from '@fluentui-copilot/react-text-editor';\nimport { $getRoot } from '@fluentui-copilot/react-text-editor';\nimport { LexicalPlainTextPlugin, mergeRegister } from '@fluentui-copilot/react-text-editor';\nimport { mergeCallbacks, 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 {\n onChange,\n onPaste,\n trimWhiteSpace = false,\n textPlugin = LexicalPlainTextPlugin,\n history = true,\n editorRef: userEditorRef,\n customTheme,\n isSentinelNodeEnabled = true,\n } = props;\n const { root, primary } = getPartitionedNativeProps({\n primarySlotTagName: 'span',\n props,\n excludedPropNames: ['onChange', 'onPaste', 'defaultValue'],\n });\n\n const editorRef = useMergedRefs(React.useRef<LexicalEditor>(null), userEditorRef);\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 defaultValueFunction = useDefaultValueFunction(props);\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 disabled,\n suppressContentEditableWarning: true,\n tabIndex: disabled ? undefined : 0,\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 theme: customTheme,\n },\n editorRef,\n disabled,\n textPlugin,\n onPaste,\n handleOnChange,\n trimWhiteSpace,\n history,\n isSentinelNodeEnabled,\n };\n};\n\nfunction useDefaultValueFunction(props: EditorInputProps) {\n const { targetDocument } = useFluent();\n const requestAnimationFrame = targetDocument?.defaultView?.requestAnimationFrame;\n\n const [defaultValueFunction] = React.useState(() => {\n const { defaultValue, onDefaultValueSet } = props;\n if (defaultValue === undefined) {\n return undefined;\n }\n\n const insertDefaultValueFunction =\n typeof defaultValue === 'function'\n ? defaultValue\n : () => {\n $insertNodes([$createTextNode(defaultValue)]);\n };\n\n // After the defaultValue function has run, read back the result and give\n // it to the onDefaultValueSet callback.\n const readDefaultValueFunction = onDefaultValueSet\n ? () => {\n const text = $getRoot().getTextContent().replace(SENTINEL_VALUE, '');\n\n // This runs while rendering `LexicalComposer` so delay calling back into the parent\n // until after finished rendering `LexicalComposer`\n requestAnimationFrame?.(() => {\n onDefaultValueSet?.(text);\n });\n }\n : undefined;\n\n return mergeCallbacks(insertDefaultValueFunction, readDefaultValueFunction);\n });\n\n return defaultValueFunction;\n}\n"],"names":["onChange","trimWhiteSpace","primarySlotTagName","props","excludedPropNames","LexicalPlainTextPlugin","userEditorRef","isSentinelNodeEnabled","root","primary","disabled","customNodes","SentinelNode","setDisabled","useControllableState","state","spanRef","React","editorRef","current","useCallback","span","_editorRef_current","useIsomorphicLayoutEffect","setRootElement","isEditable","registerRootListener","style","whiteSpace","handleOnChange","newValue","defaultValueFunction","useDefaultValueFunction","placeholderId","placeholderValue","slot","id","input","defaultProps","always","elementType","ref","useMergedRefs","undefined","suppressContentEditableWarning","lexicalInitialConfig","namespace","onError","_targetDocument_defaultView","targetDocument","requestAnimationFrame","useFluent","defaultValue","$createTextNode","readDefaultValueFunction","onDefaultValueSet","text","$getRoot","getTextContent","replace","SENTINEL_VALUE","mergeCallbacks","insertDefaultValueFunction"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BA4BIA;;;eAAAA;;;;iEA5BmB;iCAQhB;kCAEsC;iCAEC;gCAGO;AAYnD,MACEA,0BAEAC,CAAAA,OAAAA;UAOF,UACEC,SACAC,mBACAC,KAAAA,eAAoBC,uCAAA,YAAY,IAAA,aAAWC,aAAA,aAAe,EAC5DC,wBAAA,IAAA,KAEAJ;UACA,EACAK,IAAA,EACAC,OAAOC,mDACgB,EAAA;4BACP;QAChBP;QAEAC,mBAAMO;YAAcR;YAAMQ;YAAc;SAAA;;UAAuBC,YAAAA,IAAAA,8BAAAA,EAAAA,OAAAA,MAAAA,CAAAA,OAAAA;qFAAgB;kDAACA;UAAa,CAAAF,UAAAG,YAAA,GAAAC,IAAAA,oCAAA,EAAA;QAE7FC,OAAMC,MAAAA,QAAUC;sBAEZ;;wBACAC,MAAAA,WAAAA,GAAUC;WAAAA,MAAOR,WAAjBO;QAAAA,8BAAAA;KAAAA,GAAAA;QAAAA,8BAAAA;KAAAA;UAEFF,UAAAC,OAAAG,WAAA,CAAAC,CAAAA;qDAAW;QAGbC;QACAC,CAAAA,qBAAAA,UAA0BJ,OAAA,MAAA,QAAAG,uBAAA,KAAA,IAAA,KAAA,IAAAA,mBAAAE,cAAA,CAAAH;;;KACpBH;2CACFA;kDAAAA,EAAAA;YACFA,UAAAC,OAAA,EAAA;YACF,IAAGG;kCAACZ,UAAAA,OAAAA,MAAAA,QAAAA,uBAAAA,KAA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B;;;8BAKQ;uBACf;qBACAyB,QAAAA,KAAAA;mBACAW;yBACEC;mBACAC;;;;;;;;;;;;SAYFxC,wBAAAA,KAAAA;QACFyC;IACA,MAAA,EAEFC,cAASjB,mCAEuBiB;UAD9BC,wBAA2BC,mBAAAA,QAAAA,mBAAAA,KAAAA,IAAAA,KAAAA,IAAAA,CAAAA,8BAAAA,eAAAA,WAAAA,MAAAA,QAAAA,gCAAAA,KAAAA,IAAAA,KAAAA,IAAAA,4BAAAA,qBAAAA;UAC3B,CAAApB,qBAAMmB,GAAAA,OAAwBD,QAAAA,CAAAA;QAE9B,MAAM,cACIG,mBACJA;YAEJA,iBAAAT,WAAA;mBAEAA;;2CAIsCS,OAAAA,iBAAAA,aAAAA,eAAAA;6CAAc,EAAA;gBAAAC,IAAAA,gCAAA,EAAAD;aAAA;;iFAGpD;gDACA;cACAE,2BAAMA,oBAA2BC;kBAE3BC,OAAMA,IAAAA,yBAAOC,IAAAA,cAAWC,GAAAA,OAAiBC,CAAAA,gCAAQC,EAAAA;gGAEjD;+DACA;sCACAV,QAAAA,0BAAAA,KAAAA,IAAAA,KAAAA,IAAAA,sBAAAA;sCACEK,QAAAA,sBAAAA,KAAAA,IAAAA,KAAAA,IAAAA,kBAAAA;;YAEJZ;eAGJkB,IAAAA,8BAAOA,EAAAA,4BAAeC;;WAGxB/B;AACF"}
1
+ {"version":3,"sources":["useEditorInput.tsx"],"sourcesContent":["import * as React from 'react';\nimport {\n getPartitionedNativeProps,\n slot,\n useFluent,\n useId,\n useIsomorphicLayoutEffect,\n useMergedRefs,\n} from '@fluentui/react-components';\nimport type { EditorInputProps, EditorInputState } from './EditorInput.types';\nimport { SentinelNode, SENTINEL_VALUE } from '@fluentui-copilot/chat-input-plugins';\nimport type { LexicalEditor } from '@fluentui-copilot/react-text-editor';\nimport { $createTextNode, $insertNodes } from '@fluentui-copilot/react-text-editor';\nimport { $getRoot } from '@fluentui-copilot/react-text-editor';\nimport { LexicalPlainTextPlugin, mergeRegister } from '@fluentui-copilot/react-text-editor';\nimport { mergeCallbacks, 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 {\n onChange,\n onPaste,\n trimWhiteSpace = false,\n textPlugin = LexicalPlainTextPlugin,\n history = true,\n editorRef: userEditorRef,\n customTheme,\n isSentinelNodeEnabled = true,\n } = props;\n const { root, primary } = getPartitionedNativeProps({\n primarySlotTagName: 'span',\n props,\n excludedPropNames: ['onChange', 'onPaste', 'defaultValue'],\n });\n\n const editorRef = useMergedRefs(React.useRef<LexicalEditor>(null), userEditorRef);\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 defaultValueFunction = useDefaultValueFunction(props);\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 disabled,\n suppressContentEditableWarning: true,\n tabIndex: disabled ? undefined : 0,\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 theme: customTheme,\n },\n editorRef,\n disabled,\n textPlugin,\n onPaste,\n handleOnChange,\n trimWhiteSpace,\n history,\n isSentinelNodeEnabled,\n };\n};\n\nfunction useDefaultValueFunction(props: EditorInputProps) {\n const { targetDocument } = useFluent();\n const requestAnimationFrame = targetDocument?.defaultView?.requestAnimationFrame;\n\n const [defaultValueFunction] = React.useState(() => {\n const { defaultValue, onDefaultValueSet } = props;\n if (defaultValue === undefined) {\n return undefined;\n }\n\n const insertDefaultValueFunction =\n typeof defaultValue === 'function'\n ? defaultValue\n : () => {\n $insertNodes([$createTextNode(defaultValue)]);\n };\n\n // After the defaultValue function has run, read back the result and give\n // it to the onDefaultValueSet callback.\n const readDefaultValueFunction = onDefaultValueSet\n ? () => {\n const text = $getRoot().getTextContent().replace(SENTINEL_VALUE, '');\n\n // This runs while rendering `LexicalComposer` so delay calling back into the parent\n // until after finished rendering `LexicalComposer`\n requestAnimationFrame?.(() => {\n onDefaultValueSet?.(text);\n });\n }\n : undefined;\n\n return mergeCallbacks(insertDefaultValueFunction, readDefaultValueFunction);\n });\n\n return defaultValueFunction;\n}\n"],"names":["useEditorInput_unstable","props","ref","onChange","onPaste","trimWhiteSpace","textPlugin","LexicalPlainTextPlugin","history","editorRef","userEditorRef","customTheme","isSentinelNodeEnabled","root","primary","getPartitionedNativeProps","primarySlotTagName","excludedPropNames","useMergedRefs","React","useRef","disabled","setDisabled","useControllableState","state","initialState","customNodes","SentinelNode","spanRef","useCallback","span","current","setRootElement","useIsomorphicLayoutEffect","setEditable","mergeRegister","registerEditableListener","isEditable","registerRootListener","style","whiteSpace","handleOnChange","newValue","value","defaultValueFunction","useDefaultValueFunction","placeholderValue","slot","optional","elementType","placeholderId","useId","id","components","input","always","defaultProps","role","contentEditable","undefined","suppressContentEditableWarning","tabIndex","lexicalInitialConfig","namespace","onError","console","error","nodes","editorState","theme","targetDocument","useFluent","requestAnimationFrame","defaultView","useState","defaultValue","onDefaultValueSet","insertDefaultValueFunction","$insertNodes","$createTextNode","readDefaultValueFunction","text","$getRoot","getTextContent","replace","SENTINEL_VALUE","mergeCallbacks"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BA0BaA;;;eAAAA;;;;iEA1BU;iCAQhB;kCAEsC;iCAEC;gCAGO;AAW9C,MAAMA,0BAA0B,CAACC,OAAyBC;IAC/D,MAAM,EACJC,QAAQ,EACRC,OAAO,EACPC,iBAAiB,KAAK,EACtBC,aAAaC,uCAAsB,EACnCC,UAAU,IAAI,EACdC,WAAWC,aAAa,EACxBC,WAAW,EACXC,wBAAwB,IAAI,EAC7B,GAAGX;IACJ,MAAM,EAAEY,IAAI,EAAEC,OAAO,EAAE,GAAGC,IAAAA,0CAAAA,EAA0B;QAClDC,oBAAoB;QACpBf;QACAgB,mB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axB;YACbyB,OAAO1D;QACT;QACAF;QACAY;QACAf;QACAF;QACAqC;QACApC;QACAG;QACAI;IACF;AACF;AAEA,SAASiC,wBAAwB5C,KAAuB;QAExBqE;IAD9B,MAAM,EAAEA,cAAc,EAAE,GAAGC,IAAAA,0BAAAA;IAC3B,MAAMC,wBAAwBF,mBAAAA,QAAAA,mBAAAA,KAAAA,IAAAA,KAAAA,IAAAA,CAAAA,8BAAAA,eAAgBG,WAAW,AAAXA,MAAW,QAA3BH,gCAAAA,KAAAA,IAAAA,KAAAA,IAAAA,4BAA6BE,qBAAqB;IAEhF,MAAM,CAAC5B,qBAAqB,GAAGzB,OAAMuD,QAAQ,CAAC;QAC5C,MAAM,EAAEC,YAAY,EAAEC,iBAAiB,EAAE,GAAG3E;QAC5C,IAAI0E,iBAAiBhB,WAAW;YAC9B,OAAOA;QACT;QAEA,MAAMkB,6BACJ,OAAOF,iBAAiB,aACpBA,eACA;YACEG,IAAAA,6BAAAA,EAAa;gBAACC,IAAAA,gCAAAA,EAAgBJ;aAAc;QAC9C;QAEN,yEAAyE;QACzE,wCAAwC;QACxC,MAAMK,2BAA2BJ,oBAC7B;YACE,MAAMK,OAAOC,IAAAA,yBAAAA,IAAWC,cAAc,GAAGC,OAAO,CAACC,gCAAAA,EAAgB;YAEjE,oFAAoF;YACpF,mDAAmD;YACnDb,0BAAAA,QAAAA,0BAAAA,KAAAA,IAAAA,KAAAA,IAAAA,sBAAwB;gBACtBI,sBAAAA,QAAAA,sBAAAA,KAAAA,IAAAA,KAAAA,IAAAA,kBAAoBK;YACtB;QACF,IACAtB;QAEJ,OAAO2B,IAAAA,8BAAAA,EAAeT,4BAA4BG;IACpD;IAEA,OAAOpC;AACT"}
@@ -0,0 +1,86 @@
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 _tokens = require("@fluentui-copilot/tokens");
30
+ const editorInputClassNames = {
31
+ root: 'fai-EditorInput',
32
+ input: 'fai-EditorInput__input',
33
+ placeholderValue: 'fai-EditorInput__placeholderValue'
34
+ };
35
+ /**
36
+ * Styles for the root slot
37
+ */ const useRootClassName = (0, _reactcomponents.makeResetStyles)({
38
+ display: 'inline-grid',
39
+ whiteSpace: 'pre-wrap'
40
+ });
41
+ const useLexicalStyles = (0, _reactcomponents.makeStyles)({
42
+ paragraph: {
43
+ margin: 0,
44
+ textAlign: 'start'
45
+ }
46
+ });
47
+ const usePlaceholderClassName = (0, _reactcomponents.makeResetStyles)({
48
+ zIndex: 0,
49
+ gridArea: '1 / 1 / 1 / 1',
50
+ color: _tokens.tokens.colorNeutralForeground4,
51
+ ..._tokens.typographyStyles.body1,
52
+ '@media (forced-colors: active)': {
53
+ color: 'GrayText'
54
+ }
55
+ });
56
+ const useInputClassName = (0, _reactcomponents.makeResetStyles)({
57
+ gridArea: '1 / 1 / 1 / 1',
58
+ zIndex: 1,
59
+ width: '100%'
60
+ });
61
+ const useStyles = (0, _reactcomponents.makeStyles)({
62
+ placeholderDisabled: {
63
+ color: _tokens.tokens.colorNeutralForegroundDisabled
64
+ }
65
+ });
66
+ const useEditorInputStyles_unstable = (state)=>{
67
+ 'use no memo';
68
+ const { disabled } = state;
69
+ const placeholderClassName = usePlaceholderClassName();
70
+ const rootClassName = useRootClassName();
71
+ const inputClassName = useInputClassName();
72
+ const styles = useStyles();
73
+ state.root.className = (0, _reactcomponents.mergeClasses)(editorInputClassNames.root, rootClassName, state.root.className);
74
+ state.input.className = (0, _reactcomponents.mergeClasses)(editorInputClassNames.input, inputClassName, state.input.className);
75
+ state.lexicalInitialConfig = {
76
+ ...state.lexicalInitialConfig,
77
+ theme: {
78
+ ...useLexicalStyles(),
79
+ ...state.lexicalInitialConfig.theme
80
+ }
81
+ };
82
+ if (state.placeholderValue) {
83
+ state.placeholderValue.className = (0, _reactcomponents.mergeClasses)(editorInputClassNames.placeholderValue, placeholderClassName, disabled && styles.placeholderDisabled, state.placeholderValue.className);
84
+ }
85
+ return state;
86
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["useEditorInputStyles.styles.ts"],"sourcesContent":["import { makeResetStyles, makeStyles, mergeClasses } from '@fluentui/react-components';\nimport { tokens, typographyStyles } from '@fluentui-copilot/tokens';\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 margin: 0,\n textAlign: 'start',\n },\n});\n\nexport const usePlaceholderClassName = makeResetStyles({\n zIndex: 0,\n gridArea: '1 / 1 / 1 / 1',\n\n color: tokens.colorNeutralForeground4,\n ...typographyStyles.body1,\n\n '@media (forced-colors: active)': {\n color: 'GrayText',\n },\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","useInputClassName","useLexicalStyles","usePlaceholderClassName","root","input","placeholderValue","useRootClassName","makeResetStyles","display","whiteSpace","makeStyles","paragraph","margin","textAlign","zIndex","gridArea","color","tokens","colorNeutralForeground4","typographyStyles","body1","width","useStyles","placeholderDisabled","colorNeutralForegroundDisabled","state","disabled","placeholderClassName","rootClassName","inputClassName","styles","className","mergeClasses","lexicalInitialConfig","theme"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;;;;;;;;IAKaA,qBAAAA;eAAAA;;IA+CAC,6BAAAA;eAAAA;;IAdAC,iBAAAA;eAAAA;;IAnBAC,gBAAAA;eAAAA;;IAOAC,uBAAAA;eAAAA;;;iCA1B6C;wBACjB;AAIlC,MAAMJ,wBAA0D;IACrEK,MAAM;IACNC,OAAO;IACPC,kBAAkB;AACpB;AAEA;;CAEC,GACD,MAAMC,mBAAmBC,IAAAA,gCAAAA,EAAgB;IACvCC,SAAS;IACTC,YAAY;AACd;AAEO,MAAMR,mBAAmBS,IAAAA,2BAAAA,EAAW;IACzCC,WAAW;QACTC,QAAQ;QACRC,WAAW;IACb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exports, {
26
26
  }
27
27
  });
28
28
  const _EditorInput = require("./EditorInput");
29
- //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluentui-copilot/react-editor-input",
3
- "version": "0.5.2",
3
+ "version": "0.5.4",
4
4
  "description": "a base rich editor input.",
5
5
  "main": "lib-commonjs/index.js",
6
6
  "module": "lib/index.js",
@@ -12,10 +12,10 @@
12
12
  },
13
13
  "license": "MIT",
14
14
  "dependencies": {
15
- "@fluentui-copilot/chat-input-plugins": "^0.5.0",
16
- "@fluentui-copilot/react-chat-input-plugins": "^0.5.2",
17
- "@fluentui-copilot/react-text-editor": "^0.4.1",
18
- "@fluentui-copilot/tokens": "^0.3.11",
15
+ "@fluentui-copilot/chat-input-plugins": "^0.5.1",
16
+ "@fluentui-copilot/react-chat-input-plugins": "^0.5.4",
17
+ "@fluentui-copilot/react-text-editor": "^0.4.2",
18
+ "@fluentui-copilot/tokens": "^0.3.13",
19
19
  "@swc/helpers": "^0.5.1"
20
20
  },
21
21
  "peerDependencies": {