@cloudscape-design/components 3.0.362 → 3.0.364

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 (144) hide show
  1. package/alert/index.d.ts.map +1 -1
  2. package/alert/index.js +21 -16
  3. package/alert/index.js.map +1 -1
  4. package/alert/internal.d.ts.map +1 -1
  5. package/alert/internal.js +13 -14
  6. package/alert/internal.js.map +1 -1
  7. package/alert/styles.css.js +25 -25
  8. package/alert/styles.scoped.css +52 -66
  9. package/alert/styles.selectors.js +25 -25
  10. package/area-chart/model/use-chart-model.js +1 -1
  11. package/area-chart/model/use-chart-model.js.map +1 -1
  12. package/breadcrumb-group/internal.d.ts.map +1 -1
  13. package/breadcrumb-group/internal.js +5 -5
  14. package/breadcrumb-group/internal.js.map +1 -1
  15. package/button-dropdown/interfaces.d.ts +9 -1
  16. package/button-dropdown/interfaces.d.ts.map +1 -1
  17. package/button-dropdown/interfaces.js.map +1 -1
  18. package/button-dropdown/internal.d.ts.map +1 -1
  19. package/button-dropdown/internal.js +9 -2
  20. package/button-dropdown/internal.js.map +1 -1
  21. package/button-dropdown/styles.css.js +15 -14
  22. package/button-dropdown/styles.scoped.css +25 -21
  23. package/button-dropdown/styles.selectors.js +15 -14
  24. package/code-editor/index.d.ts.map +1 -1
  25. package/code-editor/index.js +26 -71
  26. package/code-editor/index.js.map +1 -1
  27. package/code-editor/listeners.d.ts +1 -1
  28. package/code-editor/listeners.d.ts.map +1 -1
  29. package/code-editor/listeners.js.map +1 -1
  30. package/code-editor/setup-editor.d.ts.map +1 -1
  31. package/code-editor/setup-editor.js +39 -36
  32. package/code-editor/setup-editor.js.map +1 -1
  33. package/code-editor/use-editor.d.ts +24 -0
  34. package/code-editor/use-editor.d.ts.map +1 -0
  35. package/code-editor/use-editor.js +71 -0
  36. package/code-editor/use-editor.js.map +1 -0
  37. package/form/index.d.ts.map +1 -1
  38. package/form/index.js +2 -1
  39. package/form/index.js.map +1 -1
  40. package/form-field/internal.d.ts.map +1 -1
  41. package/form-field/internal.js +17 -12
  42. package/form-field/internal.js.map +1 -1
  43. package/internal/analytics/components/analytics-funnel.d.ts +1 -1
  44. package/internal/analytics/components/analytics-funnel.d.ts.map +1 -1
  45. package/internal/analytics/components/analytics-funnel.js +92 -26
  46. package/internal/analytics/components/analytics-funnel.js.map +1 -1
  47. package/internal/analytics/context/analytics-context.d.ts +4 -0
  48. package/internal/analytics/context/analytics-context.d.ts.map +1 -1
  49. package/internal/analytics/context/analytics-context.js +4 -0
  50. package/internal/analytics/context/analytics-context.js.map +1 -1
  51. package/internal/analytics/hooks/use-funnel.d.ts +2 -0
  52. package/internal/analytics/hooks/use-funnel.d.ts.map +1 -1
  53. package/internal/components/chart-popover/index.d.ts.map +1 -1
  54. package/internal/components/chart-popover/index.js +1 -1
  55. package/internal/components/chart-popover/index.js.map +1 -1
  56. package/internal/components/menu-dropdown/index.d.ts +1 -1
  57. package/internal/components/menu-dropdown/index.d.ts.map +1 -1
  58. package/internal/components/menu-dropdown/index.js +7 -5
  59. package/internal/components/menu-dropdown/index.js.map +1 -1
  60. package/internal/components/menu-dropdown/interfaces.d.ts +1 -0
  61. package/internal/components/menu-dropdown/interfaces.d.ts.map +1 -1
  62. package/internal/components/menu-dropdown/interfaces.js.map +1 -1
  63. package/internal/environment.js +1 -1
  64. package/internal/environment.json +1 -1
  65. package/internal/manifest.json +1 -1
  66. package/internal/plugins/api.d.ts +21 -25
  67. package/internal/plugins/api.d.ts.map +1 -1
  68. package/internal/plugins/api.js +15 -35
  69. package/internal/plugins/api.js.map +1 -1
  70. package/internal/plugins/controllers/action-buttons.d.ts +9 -0
  71. package/internal/plugins/controllers/action-buttons.d.ts.map +1 -1
  72. package/internal/plugins/controllers/action-buttons.js +11 -0
  73. package/internal/plugins/controllers/action-buttons.js.map +1 -1
  74. package/internal/plugins/controllers/drawers.d.ts +9 -0
  75. package/internal/plugins/controllers/drawers.d.ts.map +1 -1
  76. package/internal/plugins/controllers/drawers.js +11 -0
  77. package/internal/plugins/controllers/drawers.js.map +1 -1
  78. package/internal/utils/dom.d.ts +1 -8
  79. package/internal/utils/dom.d.ts.map +1 -1
  80. package/internal/utils/dom.js +1 -22
  81. package/internal/utils/dom.js.map +1 -1
  82. package/mixed-line-bar-chart/bar-series.d.ts.map +1 -1
  83. package/mixed-line-bar-chart/bar-series.js +14 -3
  84. package/mixed-line-bar-chart/bar-series.js.map +1 -1
  85. package/mixed-line-bar-chart/hooks/use-mouse-hover.js +1 -1
  86. package/mixed-line-bar-chart/hooks/use-mouse-hover.js.map +1 -1
  87. package/mixed-line-bar-chart/styles.css.js +11 -11
  88. package/mixed-line-bar-chart/styles.scoped.css +17 -22
  89. package/mixed-line-bar-chart/styles.selectors.js +11 -11
  90. package/modal/internal.d.ts.map +1 -1
  91. package/modal/internal.js +14 -12
  92. package/modal/internal.js.map +1 -1
  93. package/package.json +1 -1
  94. package/pie-chart/pie-chart.d.ts.map +1 -1
  95. package/pie-chart/pie-chart.js +1 -1
  96. package/pie-chart/pie-chart.js.map +1 -1
  97. package/popover/container.d.ts.map +1 -1
  98. package/popover/container.js +3 -2
  99. package/popover/container.js.map +1 -1
  100. package/progress-bar/index.d.ts.map +1 -1
  101. package/progress-bar/index.js +7 -4
  102. package/progress-bar/index.js.map +1 -1
  103. package/table/body-cell/td-element.d.ts +2 -1
  104. package/table/body-cell/td-element.d.ts.map +1 -1
  105. package/table/body-cell/td-element.js +3 -3
  106. package/table/body-cell/td-element.js.map +1 -1
  107. package/table/header-cell/index.d.ts +1 -1
  108. package/table/header-cell/index.d.ts.map +1 -1
  109. package/table/header-cell/index.js +2 -2
  110. package/table/header-cell/index.js.map +1 -1
  111. package/table/internal.d.ts.map +1 -1
  112. package/table/internal.js +12 -14
  113. package/table/internal.js.map +1 -1
  114. package/table/table-role/index.d.ts +3 -1
  115. package/table/table-role/index.d.ts.map +1 -1
  116. package/table/table-role/index.js +2 -1
  117. package/table/table-role/index.js.map +1 -1
  118. package/table/table-role/interfaces.d.ts +18 -0
  119. package/table/table-role/interfaces.d.ts.map +1 -0
  120. package/table/table-role/interfaces.js +4 -0
  121. package/table/table-role/interfaces.js.map +1 -0
  122. package/table/table-role/table-role-helper.d.ts +16 -4
  123. package/table/table-role/table-role-helper.d.ts.map +1 -1
  124. package/table/table-role/table-role-helper.js +39 -4
  125. package/table/table-role/table-role-helper.js.map +1 -1
  126. package/table/table-role/use-grid-navigation.d.ts +7 -0
  127. package/table/table-role/use-grid-navigation.d.ts.map +1 -0
  128. package/table/table-role/use-grid-navigation.js +185 -0
  129. package/table/table-role/use-grid-navigation.js.map +1 -0
  130. package/table/table-role/utils.d.ts +23 -0
  131. package/table/table-role/utils.d.ts.map +1 -0
  132. package/table/table-role/utils.js +141 -0
  133. package/table/table-role/utils.js.map +1 -0
  134. package/table/thead.d.ts.map +1 -1
  135. package/table/thead.js +4 -4
  136. package/table/thead.js.map +1 -1
  137. package/test-utils/dom/button-dropdown/index.js +1 -3
  138. package/test-utils/dom/button-dropdown/index.js.map +1 -1
  139. package/test-utils/selectors/button-dropdown/index.js +1 -3
  140. package/test-utils/selectors/button-dropdown/index.js.map +1 -1
  141. package/test-utils/tsconfig.tsbuildinfo +1 -1
  142. package/wizard/index.d.ts.map +1 -1
  143. package/wizard/index.js +8 -1
  144. package/wizard/index.js.map +1 -1
@@ -2,19 +2,20 @@
2
2
  // es-module interop with Babel and Typescript
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  module.exports.default = {
5
- "button-dropdown": "awsui_button-dropdown_sne0l_15mtc_93",
6
- "items-list-container": "awsui_items-list-container_sne0l_15mtc_97",
7
- "awsui-motion-fade-in-0": "awsui_awsui-motion-fade-in-0_sne0l_15mtc_1",
8
- "rotate-up": "awsui_rotate-up_sne0l_15mtc_114",
9
- "rotate-down": "awsui_rotate-down_sne0l_15mtc_129",
10
- "header": "awsui_header_sne0l_15mtc_144",
11
- "title": "awsui_title_sne0l_15mtc_153",
12
- "description": "awsui_description_sne0l_15mtc_154",
13
- "split-trigger-wrapper": "awsui_split-trigger-wrapper_sne0l_15mtc_158",
14
- "trigger-item": "awsui_trigger-item_sne0l_15mtc_161",
15
- "trigger-button": "awsui_trigger-button_sne0l_15mtc_164",
16
- "visual-refresh": "awsui_visual-refresh_sne0l_15mtc_176",
17
- "split-trigger": "awsui_split-trigger_sne0l_15mtc_158",
18
- "dropdown-trigger": "awsui_dropdown-trigger_sne0l_15mtc_184"
5
+ "button-dropdown": "awsui_button-dropdown_sne0l_hitos_93",
6
+ "items-list-container": "awsui_items-list-container_sne0l_hitos_97",
7
+ "awsui-motion-fade-in-0": "awsui_awsui-motion-fade-in-0_sne0l_hitos_1",
8
+ "rotate-up": "awsui_rotate-up_sne0l_hitos_114",
9
+ "rotate-down": "awsui_rotate-down_sne0l_hitos_129",
10
+ "header": "awsui_header_sne0l_hitos_144",
11
+ "title": "awsui_title_sne0l_hitos_153",
12
+ "description": "awsui_description_sne0l_hitos_154",
13
+ "split-trigger-wrapper": "awsui_split-trigger-wrapper_sne0l_hitos_158",
14
+ "trigger-item": "awsui_trigger-item_sne0l_hitos_161",
15
+ "trigger-button": "awsui_trigger-button_sne0l_hitos_164",
16
+ "visual-refresh": "awsui_visual-refresh_sne0l_hitos_176",
17
+ "split-trigger": "awsui_split-trigger_sne0l_hitos_158",
18
+ "dropdown-trigger": "awsui_dropdown-trigger_sne0l_hitos_184",
19
+ "test-utils-button-trigger": "awsui_test-utils-button-trigger_sne0l_hitos_188"
19
20
  };
20
21
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"lib/default/","sources":["code-editor/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAwE,MAAM,OAAO,CAAC;AAQ7F,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAiC/C,OAAO,EAAE,eAAe,EAAE,CAAC;AAE3B,QAAA,MAAM,UAAU,6FA4Sd,CAAC;AAGH,eAAe,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"lib/default/","sources":["code-editor/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAwE,MAAM,OAAO,CAAC;AAQ7F,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAkC/C,OAAO,EAAE,eAAe,EAAE,CAAC;AAE3B,QAAA,MAAM,UAAU,6FA0Pd,CAAC;AAGH,eAAe,UAAU,CAAC"}
@@ -9,7 +9,7 @@ import { KeyCode } from '../internal/keycode';
9
9
  import { useUniqueId } from '../internal/hooks/use-unique-id';
10
10
  import { Pane } from './pane';
11
11
  import { useChangeEffect } from './listeners';
12
- import { getDefaultConfig, getAceTheme, getLanguageLabel, DEFAULT_DARK_THEME, DEFAULT_LIGHT_THEME, getDefaultTheme, } from './util';
12
+ import { DEFAULT_DARK_THEME, DEFAULT_LIGHT_THEME, getLanguageLabel } from './util';
13
13
  import { fireNonCancelableEvent } from '../internal/events';
14
14
  import { setupEditor } from './setup-editor';
15
15
  import { ResizableBox } from './resizable-box';
@@ -28,58 +28,33 @@ import { useControllable } from '../internal/hooks/use-controllable';
28
28
  import LiveRegion from '../internal/components/live-region';
29
29
  import styles from './styles.css.js';
30
30
  import { useContainerQuery } from '@cloudscape-design/component-toolkit';
31
+ import { useEditor, useSyncEditorSize, useSyncEditorLabels, useSyncEditorValue, useSyncEditorLanguage, useSyncEditorWrapLines, useSyncEditorTheme, } from './use-editor';
31
32
  const CodeEditor = forwardRef((props, ref) => {
32
- const codeEditorRef = useRef(null);
33
+ var _a;
33
34
  const { __internalRootRef } = useBaseComponent('CodeEditor');
34
35
  const { controlId, ariaLabelledby, ariaDescribedby } = useFormFieldContext(props);
35
- const { ace, value, language, i18nStrings, editorContentHeight, onEditorContentResize, ariaLabel, languageLabel: customLanguageLabel } = props, rest = __rest(props, ["ace", "value", "language", "i18nStrings", "editorContentHeight", "onEditorContentResize", "ariaLabel", "languageLabel"]);
36
+ const { ace, value, language, i18nStrings, editorContentHeight, onEditorContentResize, ariaLabel, languageLabel: customLanguageLabel, preferences, loading, themes } = props, rest = __rest(props, ["ace", "value", "language", "i18nStrings", "editorContentHeight", "onEditorContentResize", "ariaLabel", "languageLabel", "preferences", "loading", "themes"]);
36
37
  const [editorHeight = 480, setEditorHeight] = useControllable(editorContentHeight, onEditorContentResize, 480, {
37
38
  componentName: 'code-editor',
38
39
  changeHandler: 'onEditorContentResize',
39
40
  controlledProp: 'editorContentHeight',
40
41
  });
42
+ const mode = useCurrentMode(__internalRootRef);
43
+ const isRefresh = useVisualRefresh();
41
44
  const baseProps = getBaseProps(rest);
42
45
  const i18n = useInternalI18n('code-editor');
43
- const [editor, setEditor] = useState();
44
- const mode = useCurrentMode(__internalRootRef);
45
- const defaultTheme = mode === 'dark' ? DEFAULT_DARK_THEME : DEFAULT_LIGHT_THEME;
46
- useEffect(() => {
47
- if (!editor) {
48
- return;
49
- }
50
- const { textarea } = editor.renderer;
51
- if (!textarea) {
52
- return;
53
- }
54
- const updateAttribute = (attribute, value) => value ? textarea.setAttribute(attribute, value) : textarea.removeAttribute(attribute);
55
- updateAttribute('id', controlId);
56
- updateAttribute('aria-label', ariaLabel);
57
- updateAttribute('aria-labelledby', ariaLabelledby);
58
- updateAttribute('aria-describedby', ariaDescribedby);
59
- }, [ariaLabel, ariaDescribedby, ariaLabelledby, controlId, editor]);
60
- const [paneStatus, setPaneStatus] = useState('hidden');
61
- const [annotations, setAnnotations] = useState([]);
62
- const [highlightedAnnotation, setHighlightedAnnotation] = useState();
63
- const [cursorPosition, setCursorPosition] = useState({ row: 0, column: 0 });
64
- const [isTabFocused, setTabFocused] = useState(false);
65
46
  const errorsTabRef = useRef(null);
66
47
  const warningsTabRef = useRef(null);
67
- useEffect(() => {
68
- const elem = codeEditorRef.current;
69
- if (!ace || !elem) {
70
- return;
71
- }
72
- const config = getDefaultConfig(ace);
73
- setEditor(ace.edit(elem, Object.assign(Object.assign({}, config), { theme: getAceTheme(getDefaultTheme(elem)) })));
74
- }, [ace, props.loading]);
75
48
  const [codeEditorWidth, codeEditorMeasureRef] = useContainerQuery(rect => rect.contentBoxWidth);
76
49
  const mergedRef = useMergeRefs(codeEditorMeasureRef, __internalRootRef);
77
- useForwardFocus(ref, codeEditorRef);
78
- const isRefresh = useVisualRefresh();
79
- useEffect(() => {
80
- editor === null || editor === void 0 ? void 0 : editor.resize();
81
- }, [editor, editorContentHeight, codeEditorWidth]);
82
50
  const paneId = useUniqueId('code-editor-pane');
51
+ const [paneStatus, setPaneStatus] = useState('hidden');
52
+ const [annotations, setAnnotations] = useState([]);
53
+ const [highlightedAnnotation, setHighlightedAnnotation] = useState();
54
+ const [cursorPosition, setCursorPosition] = useState({ row: 0, column: 0 });
55
+ const [isTabFocused, setTabFocused] = useState(false);
56
+ const { editorRef, editor } = useEditor(ace, loading);
57
+ useForwardFocus(ref, editorRef);
83
58
  useEffect(() => {
84
59
  if (!ace || !editor) {
85
60
  return;
@@ -88,31 +63,14 @@ const CodeEditor = forwardRef((props, ref) => {
88
63
  return () => {
89
64
  editor === null || editor === void 0 ? void 0 : editor.destroy();
90
65
  };
91
- }, [ace, editor, __internalRootRef]);
92
- useEffect(() => {
93
- if (!editor) {
94
- return;
95
- }
96
- if (value === editor.getValue()) {
97
- return;
98
- }
99
- // TODO maintain cursor position?
100
- const pos = editor.session.selection.toJSON();
101
- editor.setValue(value, -1);
102
- editor.session.selection.fromJSON(pos);
103
- }, [editor, value]);
104
- useEffect(() => {
105
- editor === null || editor === void 0 ? void 0 : editor.session.setMode(`ace/mode/${language}`);
106
- }, [editor, language]);
107
- useEffect(() => {
108
- var _a, _b, _c, _d;
109
- if (!editor) {
110
- return;
111
- }
112
- const theme = (_b = (_a = props.preferences) === null || _a === void 0 ? void 0 : _a.theme) !== null && _b !== void 0 ? _b : defaultTheme;
113
- editor.setTheme(getAceTheme(theme));
114
- editor.session.setUseWrapMode((_d = (_c = props.preferences) === null || _c === void 0 ? void 0 : _c.wrapLines) !== null && _d !== void 0 ? _d : true);
115
- }, [editor, defaultTheme, props.preferences]);
66
+ }, [ace, editor]);
67
+ useSyncEditorLabels(editor, { controlId, ariaLabel, ariaLabelledby, ariaDescribedby });
68
+ const { onResize } = useSyncEditorSize(editor, { width: codeEditorWidth, height: editorContentHeight });
69
+ useSyncEditorValue(editor, value);
70
+ useSyncEditorLanguage(editor, language);
71
+ useSyncEditorWrapLines(editor, preferences === null || preferences === void 0 ? void 0 : preferences.wrapLines);
72
+ const defaultTheme = mode === 'dark' ? DEFAULT_DARK_THEME : DEFAULT_LIGHT_THEME;
73
+ useSyncEditorTheme(editor, (_a = preferences === null || preferences === void 0 ? void 0 : preferences.theme) !== null && _a !== void 0 ? _a : defaultTheme);
116
74
  // Change listeners
117
75
  useChangeEffect(editor, props.onChange, props.onDelayedChange);
118
76
  // Hide error panel when there are no errors to show.
@@ -140,9 +98,6 @@ const CodeEditor = forwardRef((props, ref) => {
140
98
  }, [editor]);
141
99
  const onTabFocus = useCallback(() => setTabFocused(true), []);
142
100
  const onTabBlur = useCallback(() => setTabFocused(false), []);
143
- const onResize = useCallback(() => {
144
- editor === null || editor === void 0 ? void 0 : editor.resize();
145
- }, [editor]);
146
101
  const onErrorPaneToggle = useCallback(() => {
147
102
  setPaneStatus(paneStatus !== 'error' ? 'error' : 'hidden');
148
103
  }, [paneStatus]);
@@ -172,20 +127,20 @@ const CodeEditor = forwardRef((props, ref) => {
172
127
  const onPreferencesDismiss = () => setPreferencesModalVisible(false);
173
128
  const isPaneVisible = paneStatus !== 'hidden';
174
129
  return (React.createElement("div", Object.assign({}, baseProps, { className: clsx(styles['code-editor'], baseProps.className, { [styles['code-editor-refresh']]: isRefresh }), ref: mergedRef }),
175
- props.loading && (React.createElement(LoadingScreen, null,
130
+ loading && (React.createElement(LoadingScreen, null,
176
131
  React.createElement(LiveRegion, { visible: true }, i18n('i18nStrings.loadingState', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.loadingState)))),
177
- !ace && !props.loading && (React.createElement(ErrorScreen, { recoveryText: i18n('i18nStrings.errorStateRecovery', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.errorStateRecovery), onRecoveryClick: props.onRecoveryClick }, i18n('i18nStrings.errorState', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.errorState))),
178
- ace && !props.loading && (React.createElement(React.Fragment, null,
132
+ !ace && !loading && (React.createElement(ErrorScreen, { recoveryText: i18n('i18nStrings.errorStateRecovery', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.errorStateRecovery), onRecoveryClick: props.onRecoveryClick }, i18n('i18nStrings.errorState', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.errorState))),
133
+ ace && !loading && (React.createElement(React.Fragment, null,
179
134
  React.createElement(ResizableBox, { height: Math.max(editorHeight, 20), minHeight: 20, onResize: height => {
180
135
  setEditorHeight(height);
181
136
  onResize();
182
137
  fireNonCancelableEvent(onEditorContentResize, { height });
183
138
  } },
184
- React.createElement("div", { ref: codeEditorRef, className: clsx(styles.editor, styles.ace, isRefresh && styles['editor-refresh']), onKeyDown: onEditorKeydown, tabIndex: 0, role: "group", "aria-label": i18n('i18nStrings.editorGroupAriaLabel', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.editorGroupAriaLabel) })),
139
+ React.createElement("div", { ref: editorRef, className: clsx(styles.editor, styles.ace, isRefresh && styles['editor-refresh']), onKeyDown: onEditorKeydown, tabIndex: 0, role: "group", "aria-label": i18n('i18nStrings.editorGroupAriaLabel', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.editorGroupAriaLabel) })),
185
140
  React.createElement("div", { role: "group", "aria-label": i18n('i18nStrings.statusBarGroupAriaLabel', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.statusBarGroupAriaLabel) },
186
141
  React.createElement(StatusBar, { languageLabel: languageLabel, cursorPosition: i18n('i18nStrings.cursorPosition', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.cursorPosition(cursorPosition.row + 1, cursorPosition.column + 1), format => format({ row: cursorPosition.row + 1, column: cursorPosition.column + 1 })), errorCount: errorCount, warningCount: warningCount, paneStatus: paneStatus, onErrorPaneToggle: onErrorPaneToggle, onWarningPaneToggle: onWarningPaneToggle, onTabFocus: onTabFocus, onTabBlur: onTabBlur, errorsTabRef: errorsTabRef, warningsTabRef: warningsTabRef, i18nStrings: i18nStrings, isTabFocused: isTabFocused, paneId: isPaneVisible ? paneId : undefined, onPreferencesOpen: onPreferencesOpen, isRefresh: isRefresh }),
187
142
  React.createElement(Pane, { id: paneId, visible: isPaneVisible, annotations: currentAnnotations, highlighted: highlightedAnnotation, onAnnotationClick: onAnnotationClick, onAnnotationClear: onAnnotationClear, onClose: onPaneClose, cursorPositionLabel: i18n('i18nStrings.cursorPosition', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.cursorPosition, format => (row, column) => format({ row, column })), closeButtonAriaLabel: i18n('i18nStrings.paneCloseButtonAriaLabel', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.paneCloseButtonAriaLabel) })),
188
- isPreferencesModalVisible && (React.createElement(PreferencesModal, { onConfirm: onPreferencesConfirm, onDismiss: onPreferencesDismiss, themes: props.themes, preferences: props.preferences, defaultTheme: defaultTheme, i18nStrings: {
143
+ isPreferencesModalVisible && (React.createElement(PreferencesModal, { onConfirm: onPreferencesConfirm, onDismiss: onPreferencesDismiss, themes: themes, preferences: preferences, defaultTheme: defaultTheme, i18nStrings: {
189
144
  header: i18n('i18nStrings.preferencesModalHeader', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.preferencesModalHeader),
190
145
  cancel: i18n('i18nStrings.preferencesModalCancel', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.preferencesModalCancel),
191
146
  confirm: i18n('i18nStrings.preferencesModalConfirm', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.preferencesModalConfirm),
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"lib/default/","sources":["code-editor/index.t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aAAX,WAAW,uBAAX,WAAW,CAAE,sBAAsB,CAAC;oBACvF,OAAO,EAAE,IAAI,CAAC,qCAAqC,EAAE,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,uBAAuB,CAAC;oBAC1F,SAAS,EAAE,IAAI,CAAC,uCAAuC,EAAE,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,yBAAyB,CAAC;oBAChG,KAAK,EAAE,IAAI,CAAC,mCAAmC,EAAE,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,qBAAqB,CAAC;oBACpF,WAAW,EAAE,IAAI,CAAC,yCAAyC,EAAE,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,2BAA2B,CAAC;oBACtG,UAAU,EAAE,IAAI,CAAC,wCAAwC,EAAE,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,0BAA0B,CAAC;oBACnG,uBAAuB,EAAE,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,uCAAuC;oBAC7E,4BAA4B,EAAE,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,4CAA4C;oBACvF,yBAAyB,EAAE,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,yCAAyC;iBAClF,GACD,CACH,CACA,CACJ,CACG,CACP,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,gBAAgB,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;AAC3C,eAAe,UAAU,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useCallback, useEffect, useMemo, useRef, useState, forwardRef } from 'react';\nimport { Ace } from 'ace-builds';\nimport clsx from 'clsx';\nimport { useMergeRefs } from '../internal/hooks/use-merge-refs';\n\nimport { getBaseProps } from '../internal/base-component';\nimport { KeyCode } from '../internal/keycode';\nimport { useUniqueId } from '../internal/hooks/use-unique-id';\nimport { CodeEditorProps } from './interfaces';\nimport { Pane } from './pane';\nimport { useChangeEffect } from './listeners';\nimport {\n getDefaultConfig,\n getAceTheme,\n PaneStatus,\n getLanguageLabel,\n DEFAULT_DARK_THEME,\n DEFAULT_LIGHT_THEME,\n getDefaultTheme,\n} from './util';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport { setupEditor } from './setup-editor';\nimport { ResizableBox } from './resizable-box';\nimport PreferencesModal from './preferences-modal';\nimport LoadingScreen from './loading-screen';\nimport ErrorScreen from './error-screen';\n\nimport useBaseComponent from '../internal/hooks/use-base-component';\nimport useForwardFocus from '../internal/hooks/forward-focus';\nimport { applyDisplayName } from '../internal/utils/apply-display-name';\nimport { useCurrentMode } from '@cloudscape-design/component-toolkit/internal';\nimport { useInternalI18n } from '../i18n/context';\nimport { StatusBar } from './status-bar';\nimport { useFormFieldContext } from '../internal/context/form-field-context';\nimport { useVisualRefresh } from '../internal/hooks/use-visual-mode';\nimport { useControllable } from '../internal/hooks/use-controllable';\nimport LiveRegion from '../internal/components/live-region';\n\nimport styles from './styles.css.js';\nimport { useContainerQuery } from '@cloudscape-design/component-toolkit';\n\nexport { CodeEditorProps };\n\nconst CodeEditor = forwardRef((props: CodeEditorProps, ref: React.Ref<CodeEditorProps.Ref>) => {\n const codeEditorRef = useRef<HTMLDivElement>(null);\n const { __internalRootRef } = useBaseComponent('CodeEditor');\n const { controlId, ariaLabelledby, ariaDescribedby } = useFormFieldContext(props);\n const {\n ace,\n value,\n language,\n i18nStrings,\n editorContentHeight,\n onEditorContentResize,\n ariaLabel,\n languageLabel: customLanguageLabel,\n ...rest\n } = props;\n const [editorHeight = 480, setEditorHeight] = useControllable(editorContentHeight, onEditorContentResize, 480, {\n componentName: 'code-editor',\n changeHandler: 'onEditorContentResize',\n controlledProp: 'editorContentHeight',\n });\n const baseProps = getBaseProps(rest);\n const i18n = useInternalI18n('code-editor');\n\n const [editor, setEditor] = useState<Ace.Editor>();\n const mode = useCurrentMode(__internalRootRef);\n const defaultTheme = mode === 'dark' ? DEFAULT_DARK_THEME : DEFAULT_LIGHT_THEME;\n\n useEffect(() => {\n if (!editor) {\n return;\n }\n const { textarea } = editor.renderer as unknown as { textarea: HTMLTextAreaElement };\n if (!textarea) {\n return;\n }\n const updateAttribute = (attribute: string, value: string | undefined) =>\n value ? textarea.setAttribute(attribute, value) : textarea.removeAttribute(attribute);\n updateAttribute('id', controlId);\n updateAttribute('aria-label', ariaLabel);\n updateAttribute('aria-labelledby', ariaLabelledby);\n updateAttribute('aria-describedby', ariaDescribedby);\n }, [ariaLabel, ariaDescribedby, ariaLabelledby, controlId, editor]);\n\n const [paneStatus, setPaneStatus] = useState<PaneStatus>('hidden');\n const [annotations, setAnnotations] = useState<Ace.Annotation[]>([]);\n const [highlightedAnnotation, setHighlightedAnnotation] = useState<Ace.Annotation>();\n const [cursorPosition, setCursorPosition] = useState<Ace.Point>({ row: 0, column: 0 });\n const [isTabFocused, setTabFocused] = useState<boolean>(false);\n\n const errorsTabRef = useRef<HTMLButtonElement>(null);\n const warningsTabRef = useRef<HTMLButtonElement>(null);\n useEffect(() => {\n const elem = codeEditorRef.current;\n if (!ace || !elem) {\n return;\n }\n const config = getDefaultConfig(ace);\n setEditor(\n ace.edit(elem, {\n ...config,\n theme: getAceTheme(getDefaultTheme(elem)),\n })\n );\n }, [ace, props.loading]);\n const [codeEditorWidth, codeEditorMeasureRef] = useContainerQuery(rect => rect.contentBoxWidth);\n const mergedRef = useMergeRefs(codeEditorMeasureRef, __internalRootRef);\n useForwardFocus(ref, codeEditorRef);\n const isRefresh = useVisualRefresh();\n\n useEffect(() => {\n editor?.resize();\n }, [editor, editorContentHeight, codeEditorWidth]);\n\n const paneId = useUniqueId('code-editor-pane');\n\n useEffect(() => {\n if (!ace || !editor) {\n return;\n }\n\n setupEditor(ace, editor, setAnnotations, setCursorPosition, setHighlightedAnnotation, setPaneStatus);\n\n return () => {\n editor?.destroy();\n };\n }, [ace, editor, __internalRootRef]);\n\n useEffect(() => {\n if (!editor) {\n return;\n }\n if (value === editor.getValue()) {\n return;\n }\n // TODO maintain cursor position?\n const pos = editor.session.selection.toJSON();\n editor.setValue(value, -1);\n editor.session.selection.fromJSON(pos);\n }, [editor, value]);\n\n useEffect(() => {\n editor?.session.setMode(`ace/mode/${language}`);\n }, [editor, language]);\n\n useEffect(() => {\n if (!editor) {\n return;\n }\n\n const theme: CodeEditorProps.Theme = props.preferences?.theme ?? defaultTheme;\n editor.setTheme(getAceTheme(theme));\n\n editor.session.setUseWrapMode(props.preferences?.wrapLines ?? true);\n }, [editor, defaultTheme, props.preferences]);\n\n // Change listeners\n useChangeEffect(editor, props.onChange, props.onDelayedChange);\n\n // Hide error panel when there are no errors to show.\n useEffect(() => {\n if (annotations.length === 0) {\n setPaneStatus('hidden');\n }\n\n if (props.onValidate) {\n fireNonCancelableEvent(props.onValidate, { annotations });\n }\n }, [annotations, props.onValidate]);\n\n const languageLabel = customLanguageLabel ?? getLanguageLabel(language);\n\n const errorCount = annotations.filter(a => a.type === 'error').length;\n const warningCount = annotations.filter(a => a.type === 'warning').length;\n const currentAnnotations = useMemo(() => annotations.filter(a => a.type === paneStatus), [annotations, paneStatus]);\n\n /*\n * Callbacks\n */\n\n const onEditorKeydown = useCallback(\n (e: React.KeyboardEvent) => {\n if (editor && e.target === editor.container && e.keyCode === KeyCode.enter) {\n e.stopPropagation();\n e.preventDefault();\n editor.focus();\n }\n },\n [editor]\n );\n\n const onTabFocus = useCallback(() => setTabFocused(true), []);\n const onTabBlur = useCallback(() => setTabFocused(false), []);\n\n const onResize = useCallback(() => {\n editor?.resize();\n }, [editor]);\n\n const onErrorPaneToggle = useCallback(() => {\n setPaneStatus(paneStatus !== 'error' ? 'error' : 'hidden');\n }, [paneStatus]);\n\n const onWarningPaneToggle = useCallback(() => {\n setPaneStatus(paneStatus !== 'warning' ? 'warning' : 'hidden');\n }, [paneStatus]);\n\n const onPaneClose = () => {\n setPaneStatus('hidden');\n };\n\n const onAnnotationClick = ({ row = 0, column = 0 }: Ace.Annotation) => {\n if (!editor) {\n return;\n }\n editor.focus();\n editor.gotoLine(row + 1, column, false);\n setHighlightedAnnotation(undefined);\n };\n\n const onAnnotationClear = useCallback(() => {\n setHighlightedAnnotation(undefined);\n }, []);\n\n const [isPreferencesModalVisible, setPreferencesModalVisible] = useState(false);\n const onPreferencesOpen = () => setPreferencesModalVisible(true);\n const onPreferencesConfirm = (p: CodeEditorProps.Preferences) => {\n fireNonCancelableEvent(props.onPreferencesChange, p);\n setPreferencesModalVisible(false);\n };\n const onPreferencesDismiss = () => setPreferencesModalVisible(false);\n\n const isPaneVisible = paneStatus !== 'hidden';\n\n return (\n <div\n {...baseProps}\n className={clsx(styles['code-editor'], baseProps.className, { [styles['code-editor-refresh']]: isRefresh })}\n ref={mergedRef}\n >\n {props.loading && (\n <LoadingScreen>\n <LiveRegion visible={true}>{i18n('i18nStrings.loadingState', i18nStrings?.loadingState)}</LiveRegion>\n </LoadingScreen>\n )}\n\n {!ace && !props.loading && (\n <ErrorScreen\n recoveryText={i18n('i18nStrings.errorStateRecovery', i18nStrings?.errorStateRecovery)}\n onRecoveryClick={props.onRecoveryClick}\n >\n {i18n('i18nStrings.errorState', i18nStrings?.errorState)}\n </ErrorScreen>\n )}\n\n {ace && !props.loading && (\n <>\n <ResizableBox\n height={Math.max(editorHeight, 20)}\n minHeight={20}\n onResize={height => {\n setEditorHeight(height);\n onResize();\n fireNonCancelableEvent(onEditorContentResize, { height });\n }}\n >\n <div\n ref={codeEditorRef}\n className={clsx(styles.editor, styles.ace, isRefresh && styles['editor-refresh'])}\n onKeyDown={onEditorKeydown}\n tabIndex={0}\n role=\"group\"\n aria-label={i18n('i18nStrings.editorGroupAriaLabel', i18nStrings?.editorGroupAriaLabel)}\n />\n </ResizableBox>\n <div\n role=\"group\"\n aria-label={i18n('i18nStrings.statusBarGroupAriaLabel', i18nStrings?.statusBarGroupAriaLabel)}\n >\n <StatusBar\n languageLabel={languageLabel}\n cursorPosition={i18n(\n 'i18nStrings.cursorPosition',\n i18nStrings?.cursorPosition(cursorPosition.row + 1, cursorPosition.column + 1),\n format => format({ row: cursorPosition.row + 1, column: cursorPosition.column + 1 })\n )}\n errorCount={errorCount}\n warningCount={warningCount}\n paneStatus={paneStatus}\n onErrorPaneToggle={onErrorPaneToggle}\n onWarningPaneToggle={onWarningPaneToggle}\n onTabFocus={onTabFocus}\n onTabBlur={onTabBlur}\n errorsTabRef={errorsTabRef}\n warningsTabRef={warningsTabRef}\n i18nStrings={i18nStrings}\n isTabFocused={isTabFocused}\n paneId={isPaneVisible ? paneId : undefined}\n onPreferencesOpen={onPreferencesOpen}\n isRefresh={isRefresh}\n />\n <Pane\n id={paneId}\n visible={isPaneVisible}\n annotations={currentAnnotations}\n highlighted={highlightedAnnotation}\n onAnnotationClick={onAnnotationClick}\n onAnnotationClear={onAnnotationClear}\n onClose={onPaneClose}\n cursorPositionLabel={i18n(\n 'i18nStrings.cursorPosition',\n i18nStrings?.cursorPosition,\n format => (row, column) => format({ row, column })\n )}\n closeButtonAriaLabel={i18n('i18nStrings.paneCloseButtonAriaLabel', i18nStrings?.paneCloseButtonAriaLabel)}\n />\n </div>\n {isPreferencesModalVisible && (\n <PreferencesModal\n onConfirm={onPreferencesConfirm}\n onDismiss={onPreferencesDismiss}\n themes={props.themes}\n preferences={props.preferences}\n defaultTheme={defaultTheme}\n i18nStrings={{\n header: i18n('i18nStrings.preferencesModalHeader', i18nStrings?.preferencesModalHeader),\n cancel: i18n('i18nStrings.preferencesModalCancel', i18nStrings?.preferencesModalCancel),\n confirm: i18n('i18nStrings.preferencesModalConfirm', i18nStrings?.preferencesModalConfirm),\n wrapLines: i18n('i18nStrings.preferencesModalWrapLines', i18nStrings?.preferencesModalWrapLines),\n theme: i18n('i18nStrings.preferencesModalTheme', i18nStrings?.preferencesModalTheme),\n lightThemes: i18n('i18nStrings.preferencesModalLightThemes', i18nStrings?.preferencesModalLightThemes),\n darkThemes: i18n('i18nStrings.preferencesModalDarkThemes', i18nStrings?.preferencesModalDarkThemes),\n themeFilteringAriaLabel: i18nStrings?.preferencesModalThemeFilteringAriaLabel,\n themeFilteringClearAriaLabel: i18nStrings?.preferencesModalThemeFilteringClearAriaLabel,\n themeFilteringPlaceholder: i18nStrings?.preferencesModalThemeFilteringPlaceholder,\n }}\n />\n )}\n </>\n )}\n </div>\n );\n});\n\napplyDisplayName(CodeEditor, 'CodeEditor');\nexport default CodeEditor;\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"lib/default/","sources":["code-editor/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAE7F,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAEhE,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAE9D,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAc,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAC/F,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,gBAAgB,MAAM,qBAAqB,CAAC;AACnD,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAC7C,OAAO,WAAW,MAAM,gBAAgB,CAAC;AAEzC,OAAO,gBAAgB,MAAM,sCAAsC,CAAC;AACpE,OAAO,eAAe,MAAM,iCAAiC,CAAC;AAC9D,O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,CAAE,2BAA2B,CAAC;oBACtG,UAAU,EAAE,IAAI,CAAC,wCAAwC,EAAE,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,0BAA0B,CAAC;oBACnG,uBAAuB,EAAE,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,uCAAuC;oBAC7E,4BAA4B,EAAE,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,4CAA4C;oBACvF,yBAAyB,EAAE,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,yCAAyC;iBAClF,GACD,CACH,CACA,CACJ,CACG,CACP,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,gBAAgB,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;AAC3C,eAAe,UAAU,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useCallback, useEffect, useMemo, useRef, useState, forwardRef } from 'react';\nimport { Ace } from 'ace-builds';\nimport clsx from 'clsx';\nimport { useMergeRefs } from '../internal/hooks/use-merge-refs';\n\nimport { getBaseProps } from '../internal/base-component';\nimport { KeyCode } from '../internal/keycode';\nimport { useUniqueId } from '../internal/hooks/use-unique-id';\nimport { CodeEditorProps } from './interfaces';\nimport { Pane } from './pane';\nimport { useChangeEffect } from './listeners';\nimport { DEFAULT_DARK_THEME, DEFAULT_LIGHT_THEME, PaneStatus, getLanguageLabel } from './util';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport { setupEditor } from './setup-editor';\nimport { ResizableBox } from './resizable-box';\nimport PreferencesModal from './preferences-modal';\nimport LoadingScreen from './loading-screen';\nimport ErrorScreen from './error-screen';\n\nimport useBaseComponent from '../internal/hooks/use-base-component';\nimport useForwardFocus from '../internal/hooks/forward-focus';\nimport { applyDisplayName } from '../internal/utils/apply-display-name';\nimport { useCurrentMode } from '@cloudscape-design/component-toolkit/internal';\nimport { useInternalI18n } from '../i18n/context';\nimport { StatusBar } from './status-bar';\nimport { useFormFieldContext } from '../internal/context/form-field-context';\nimport { useVisualRefresh } from '../internal/hooks/use-visual-mode';\nimport { useControllable } from '../internal/hooks/use-controllable';\nimport LiveRegion from '../internal/components/live-region';\n\nimport styles from './styles.css.js';\nimport { useContainerQuery } from '@cloudscape-design/component-toolkit';\nimport {\n useEditor,\n useSyncEditorSize,\n useSyncEditorLabels,\n useSyncEditorValue,\n useSyncEditorLanguage,\n useSyncEditorWrapLines,\n useSyncEditorTheme,\n} from './use-editor';\n\nexport { CodeEditorProps };\n\nconst CodeEditor = forwardRef((props: CodeEditorProps, ref: React.Ref<CodeEditorProps.Ref>) => {\n const { __internalRootRef } = useBaseComponent('CodeEditor');\n const { controlId, ariaLabelledby, ariaDescribedby } = useFormFieldContext(props);\n const {\n ace,\n value,\n language,\n i18nStrings,\n editorContentHeight,\n onEditorContentResize,\n ariaLabel,\n languageLabel: customLanguageLabel,\n preferences,\n loading,\n themes,\n ...rest\n } = props;\n const [editorHeight = 480, setEditorHeight] = useControllable(editorContentHeight, onEditorContentResize, 480, {\n componentName: 'code-editor',\n changeHandler: 'onEditorContentResize',\n controlledProp: 'editorContentHeight',\n });\n const mode = useCurrentMode(__internalRootRef);\n const isRefresh = useVisualRefresh();\n const baseProps = getBaseProps(rest);\n const i18n = useInternalI18n('code-editor');\n\n const errorsTabRef = useRef<HTMLButtonElement>(null);\n const warningsTabRef = useRef<HTMLButtonElement>(null);\n const [codeEditorWidth, codeEditorMeasureRef] = useContainerQuery(rect => rect.contentBoxWidth);\n const mergedRef = useMergeRefs(codeEditorMeasureRef, __internalRootRef);\n\n const paneId = useUniqueId('code-editor-pane');\n\n const [paneStatus, setPaneStatus] = useState<PaneStatus>('hidden');\n const [annotations, setAnnotations] = useState<Ace.Annotation[]>([]);\n const [highlightedAnnotation, setHighlightedAnnotation] = useState<Ace.Annotation>();\n const [cursorPosition, setCursorPosition] = useState<Ace.Point>({ row: 0, column: 0 });\n const [isTabFocused, setTabFocused] = useState<boolean>(false);\n\n const { editorRef, editor } = useEditor(ace, loading);\n\n useForwardFocus(ref, editorRef);\n\n useEffect(() => {\n if (!ace || !editor) {\n return;\n }\n\n setupEditor(ace, editor, setAnnotations, setCursorPosition, setHighlightedAnnotation, setPaneStatus);\n\n return () => {\n editor?.destroy();\n };\n }, [ace, editor]);\n\n useSyncEditorLabels(editor, { controlId, ariaLabel, ariaLabelledby, ariaDescribedby });\n\n const { onResize } = useSyncEditorSize(editor, { width: codeEditorWidth, height: editorContentHeight });\n\n useSyncEditorValue(editor, value);\n\n useSyncEditorLanguage(editor, language);\n\n useSyncEditorWrapLines(editor, preferences?.wrapLines);\n\n const defaultTheme = mode === 'dark' ? DEFAULT_DARK_THEME : DEFAULT_LIGHT_THEME;\n useSyncEditorTheme(editor, preferences?.theme ?? defaultTheme);\n\n // Change listeners\n useChangeEffect(editor, props.onChange, props.onDelayedChange);\n\n // Hide error panel when there are no errors to show.\n useEffect(() => {\n if (annotations.length === 0) {\n setPaneStatus('hidden');\n }\n\n if (props.onValidate) {\n fireNonCancelableEvent(props.onValidate, { annotations });\n }\n }, [annotations, props.onValidate]);\n\n const languageLabel = customLanguageLabel ?? getLanguageLabel(language);\n\n const errorCount = annotations.filter(a => a.type === 'error').length;\n const warningCount = annotations.filter(a => a.type === 'warning').length;\n const currentAnnotations = useMemo(() => annotations.filter(a => a.type === paneStatus), [annotations, paneStatus]);\n\n /*\n * Callbacks\n */\n\n const onEditorKeydown = useCallback(\n (e: React.KeyboardEvent) => {\n if (editor && e.target === editor.container && e.keyCode === KeyCode.enter) {\n e.stopPropagation();\n e.preventDefault();\n editor.focus();\n }\n },\n [editor]\n );\n\n const onTabFocus = useCallback(() => setTabFocused(true), []);\n const onTabBlur = useCallback(() => setTabFocused(false), []);\n\n const onErrorPaneToggle = useCallback(() => {\n setPaneStatus(paneStatus !== 'error' ? 'error' : 'hidden');\n }, [paneStatus]);\n\n const onWarningPaneToggle = useCallback(() => {\n setPaneStatus(paneStatus !== 'warning' ? 'warning' : 'hidden');\n }, [paneStatus]);\n\n const onPaneClose = () => {\n setPaneStatus('hidden');\n };\n\n const onAnnotationClick = ({ row = 0, column = 0 }: Ace.Annotation) => {\n if (!editor) {\n return;\n }\n editor.focus();\n editor.gotoLine(row + 1, column, false);\n setHighlightedAnnotation(undefined);\n };\n\n const onAnnotationClear = useCallback(() => {\n setHighlightedAnnotation(undefined);\n }, []);\n\n const [isPreferencesModalVisible, setPreferencesModalVisible] = useState(false);\n const onPreferencesOpen = () => setPreferencesModalVisible(true);\n const onPreferencesConfirm = (p: CodeEditorProps.Preferences) => {\n fireNonCancelableEvent(props.onPreferencesChange, p);\n setPreferencesModalVisible(false);\n };\n const onPreferencesDismiss = () => setPreferencesModalVisible(false);\n\n const isPaneVisible = paneStatus !== 'hidden';\n\n return (\n <div\n {...baseProps}\n className={clsx(styles['code-editor'], baseProps.className, { [styles['code-editor-refresh']]: isRefresh })}\n ref={mergedRef}\n >\n {loading && (\n <LoadingScreen>\n <LiveRegion visible={true}>{i18n('i18nStrings.loadingState', i18nStrings?.loadingState)}</LiveRegion>\n </LoadingScreen>\n )}\n\n {!ace && !loading && (\n <ErrorScreen\n recoveryText={i18n('i18nStrings.errorStateRecovery', i18nStrings?.errorStateRecovery)}\n onRecoveryClick={props.onRecoveryClick}\n >\n {i18n('i18nStrings.errorState', i18nStrings?.errorState)}\n </ErrorScreen>\n )}\n\n {ace && !loading && (\n <>\n <ResizableBox\n height={Math.max(editorHeight, 20)}\n minHeight={20}\n onResize={height => {\n setEditorHeight(height);\n onResize();\n fireNonCancelableEvent(onEditorContentResize, { height });\n }}\n >\n <div\n ref={editorRef}\n className={clsx(styles.editor, styles.ace, isRefresh && styles['editor-refresh'])}\n onKeyDown={onEditorKeydown}\n tabIndex={0}\n role=\"group\"\n aria-label={i18n('i18nStrings.editorGroupAriaLabel', i18nStrings?.editorGroupAriaLabel)}\n />\n </ResizableBox>\n <div\n role=\"group\"\n aria-label={i18n('i18nStrings.statusBarGroupAriaLabel', i18nStrings?.statusBarGroupAriaLabel)}\n >\n <StatusBar\n languageLabel={languageLabel}\n cursorPosition={i18n(\n 'i18nStrings.cursorPosition',\n i18nStrings?.cursorPosition(cursorPosition.row + 1, cursorPosition.column + 1),\n format => format({ row: cursorPosition.row + 1, column: cursorPosition.column + 1 })\n )}\n errorCount={errorCount}\n warningCount={warningCount}\n paneStatus={paneStatus}\n onErrorPaneToggle={onErrorPaneToggle}\n onWarningPaneToggle={onWarningPaneToggle}\n onTabFocus={onTabFocus}\n onTabBlur={onTabBlur}\n errorsTabRef={errorsTabRef}\n warningsTabRef={warningsTabRef}\n i18nStrings={i18nStrings}\n isTabFocused={isTabFocused}\n paneId={isPaneVisible ? paneId : undefined}\n onPreferencesOpen={onPreferencesOpen}\n isRefresh={isRefresh}\n />\n <Pane\n id={paneId}\n visible={isPaneVisible}\n annotations={currentAnnotations}\n highlighted={highlightedAnnotation}\n onAnnotationClick={onAnnotationClick}\n onAnnotationClear={onAnnotationClear}\n onClose={onPaneClose}\n cursorPositionLabel={i18n(\n 'i18nStrings.cursorPosition',\n i18nStrings?.cursorPosition,\n format => (row, column) => format({ row, column })\n )}\n closeButtonAriaLabel={i18n('i18nStrings.paneCloseButtonAriaLabel', i18nStrings?.paneCloseButtonAriaLabel)}\n />\n </div>\n {isPreferencesModalVisible && (\n <PreferencesModal\n onConfirm={onPreferencesConfirm}\n onDismiss={onPreferencesDismiss}\n themes={themes}\n preferences={preferences}\n defaultTheme={defaultTheme}\n i18nStrings={{\n header: i18n('i18nStrings.preferencesModalHeader', i18nStrings?.preferencesModalHeader),\n cancel: i18n('i18nStrings.preferencesModalCancel', i18nStrings?.preferencesModalCancel),\n confirm: i18n('i18nStrings.preferencesModalConfirm', i18nStrings?.preferencesModalConfirm),\n wrapLines: i18n('i18nStrings.preferencesModalWrapLines', i18nStrings?.preferencesModalWrapLines),\n theme: i18n('i18nStrings.preferencesModalTheme', i18nStrings?.preferencesModalTheme),\n lightThemes: i18n('i18nStrings.preferencesModalLightThemes', i18nStrings?.preferencesModalLightThemes),\n darkThemes: i18n('i18nStrings.preferencesModalDarkThemes', i18nStrings?.preferencesModalDarkThemes),\n themeFilteringAriaLabel: i18nStrings?.preferencesModalThemeFilteringAriaLabel,\n themeFilteringClearAriaLabel: i18nStrings?.preferencesModalThemeFilteringClearAriaLabel,\n themeFilteringPlaceholder: i18nStrings?.preferencesModalThemeFilteringPlaceholder,\n }}\n />\n )}\n </>\n )}\n </div>\n );\n});\n\napplyDisplayName(CodeEditor, 'CodeEditor');\nexport default CodeEditor;\n"]}
@@ -1,5 +1,5 @@
1
1
  import { Ace } from 'ace-builds';
2
2
  import { CodeEditorProps } from './interfaces';
3
3
  import { NonCancelableEventHandler } from '../internal/events';
4
- export declare function useChangeEffect(editor?: Ace.Editor, onChange?: NonCancelableEventHandler<CodeEditorProps.ChangeDetail>, onDelayedChange?: NonCancelableEventHandler<CodeEditorProps.ChangeDetail>): void;
4
+ export declare function useChangeEffect(editor: null | Ace.Editor, onChange?: NonCancelableEventHandler<CodeEditorProps.ChangeDetail>, onDelayedChange?: NonCancelableEventHandler<CodeEditorProps.ChangeDetail>): void;
5
5
  //# sourceMappingURL=listeners.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"listeners.d.ts","sourceRoot":"lib/default/","sources":["code-editor/listeners.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAA0B,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAIvF,wBAAgB,eAAe,CAC7B,MAAM,CAAC,EAAE,GAAG,CAAC,MAAM,EACnB,QAAQ,CAAC,EAAE,yBAAyB,CAAC,eAAe,CAAC,YAAY,CAAC,EAClE,eAAe,CAAC,EAAE,yBAAyB,CAAC,eAAe,CAAC,YAAY,CAAC,QAkB1E"}
1
+ {"version":3,"file":"listeners.d.ts","sourceRoot":"lib/default/","sources":["code-editor/list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C,GAAG,EAAE;QACb,IAAI,CAAC,MAAM,EAAE;YACX,OAAO;SACR;QAED,MAAM,CAAC,EAAE,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;QAClC,OAAO,GAAG,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;IAClD,CAAC,EAAE,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC;AAC7B,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { useEffect } from 'react';\nimport { Ace } from 'ace-builds';\nimport { CodeEditorProps } from './interfaces';\nimport { fireNonCancelableEvent, NonCancelableEventHandler } from '../internal/events';\nimport { useDebounceCallback } from '../internal/hooks/use-debounce-callback';\nimport { useStableCallback } from '@cloudscape-design/component-toolkit/internal';\n\nexport function useChangeEffect(\n editor?: Ace.Editor,\n onChange?: NonCancelableEventHandler<CodeEditorProps.ChangeDetail>,\n onDelayedChange?: NonCancelableEventHandler<CodeEditorProps.ChangeDetail>\n) {\n const debouncedChangeHandler = useDebounceCallback((detail: CodeEditorProps.ChangeDetail) => {\n fireNonCancelableEvent(onDelayedChange, detail);\n }, 0);\n const handleChange = useStableCallback(() => {\n const changeDetail = { value: editor?.getValue() || '' };\n fireNonCancelableEvent(onChange, changeDetail);\n debouncedChangeHandler(changeDetail);\n });\n useEffect(() => {\n if (!editor) {\n return;\n }\n\n editor.on('change', handleChange);\n return () => editor.off('change', handleChange);\n }, [editor, handleChange]);\n}\n"]}
1
+ {"version":3,"file":"listeners.js","sourceRoot":"lib/default/","sources":["code-editor/listeners.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGlC,OAAO,EAAE,sBAAsB,EAA6B,MAAM,oBAAoB,CAAC;AACvF,OAAO,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AAC9E,OAAO,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAElF,MAAM,UAAU,eAAe,CAC7B,MAAyB,EACzB,QAAkE,EAClE,eAAyE;IAEzE,MAAM,sBAAsB,GAAG,mBAAmB,CAAC,CAAC,MAAoC,EAAE,EAAE;QAC1F,sBAAsB,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;IAClD,CAAC,EAAE,CAAC,CAAC,CAAC;IACN,MAAM,YAAY,GAAG,iBAAiB,CAAC,GAAG,EAAE;QAC1C,MAAM,YAAY,GAAG,EAAE,KAAK,EAAE,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,QAAQ,EAAE,KAAI,EAAE,EAAE,CAAC;QACzD,sBAAsB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;QAC/C,sBAAsB,CAAC,YAAY,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;IACH,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,MAAM,EAAE;YACX,OAAO;SACR;QAED,MAAM,CAAC,EAAE,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;QAClC,OAAO,GAAG,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;IAClD,CAAC,EAAE,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC;AAC7B,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { useEffect } from 'react';\nimport { Ace } from 'ace-builds';\nimport { CodeEditorProps } from './interfaces';\nimport { fireNonCancelableEvent, NonCancelableEventHandler } from '../internal/events';\nimport { useDebounceCallback } from '../internal/hooks/use-debounce-callback';\nimport { useStableCallback } from '@cloudscape-design/component-toolkit/internal';\n\nexport function useChangeEffect(\n editor: null | Ace.Editor,\n onChange?: NonCancelableEventHandler<CodeEditorProps.ChangeDetail>,\n onDelayedChange?: NonCancelableEventHandler<CodeEditorProps.ChangeDetail>\n) {\n const debouncedChangeHandler = useDebounceCallback((detail: CodeEditorProps.ChangeDetail) => {\n fireNonCancelableEvent(onDelayedChange, detail);\n }, 0);\n const handleChange = useStableCallback(() => {\n const changeDetail = { value: editor?.getValue() || '' };\n fireNonCancelableEvent(onChange, changeDetail);\n debouncedChangeHandler(changeDetail);\n });\n useEffect(() => {\n if (!editor) {\n return;\n }\n\n editor.on('change', handleChange);\n return () => editor.off('change', handleChange);\n }, [editor, handleChange]);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"setup-editor.d.ts","sourceRoot":"lib/default/","sources":["code-editor/setup-editor.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,EAAE,UAAU,EAAiC,MAAM,QAAQ,CAAC;AAEnE,wBAAgB,WAAW,CACzB,GAAG,EAAE,GAAG,EACR,MAAM,EAAE,GAAG,CAAC,MAAM,EAClB,cAAc,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC,CAAC,EACtE,iBAAiB,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAClE,wBAAwB,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,UAAU,GAAG,SAAS,CAAC,CAAC,EAC1F,aAAa,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,QAyIhE"}
1
+ {"version":3,"file":"setup-editor.d.ts","sourceRoot":"lib/default/","sources":["code-editor/setup-editor.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,EAAE,UAAU,EAAiC,MAAM,QAAQ,CAAC;AAEnE,wBAAgB,WAAW,CACzB,GAAG,EAAE,GAAG,EACR,MAAM,EAAE,GAAG,CAAC,MAAM,EAClB,cAAc,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC,CAAC,EACtE,iBAAiB,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAClE,wBAAwB,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,UAAU,GAAG,SAAS,CAAC,CAAC,EAC1F,aAAa,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,QA8DhE"}
@@ -1,13 +1,6 @@
1
1
  import { supportsKeyboardAccessibility } from './util';
2
2
  export function setupEditor(ace, editor, setAnnotations, setCursorPosition, setHighlightedAnnotation, setPaneStatus) {
3
- ace.config.loadModule('ace/ext/language_tools', function () {
4
- editor.setOptions({
5
- displayIndentGuides: false,
6
- enableSnippets: true,
7
- enableBasicAutocompletion: true,
8
- });
9
- });
10
- editor.setAutoScrollEditorIntoView(true);
3
+ setEditorDefaults(ace, editor);
11
4
  // To display cursor position in status bar
12
5
  editor.session.selection.on('changeCursor', () => {
13
6
  setCursorPosition(editor.getCursorPosition());
@@ -20,28 +13,6 @@ export function setupEditor(ace, editor, setAnnotations, setCursorPosition, setH
20
13
  }
21
14
  setAnnotations(newAnnotations);
22
15
  });
23
- if (!supportsKeyboardAccessibility(ace)) {
24
- editor.commands.addCommand({
25
- name: 'exitCodeEditor',
26
- bindKey: 'Esc',
27
- exec: () => {
28
- editor.container.focus();
29
- },
30
- });
31
- }
32
- editor.on('focus', () => {
33
- editor.textInput.getElement().setAttribute('tabindex', 0);
34
- });
35
- editor.on('blur', () => {
36
- editor.textInput.getElement().setAttribute('tabindex', -1);
37
- });
38
- // prevent users to step into editor directly by keyboard
39
- editor.textInput.getElement().setAttribute('tabindex', -1);
40
- editor.commands.removeCommand('showSettingsMenu', false);
41
- // Prevent default behavior on error/warning icon click
42
- editor.on('guttermousedown', (e) => {
43
- e.stop();
44
- });
45
16
  const moveCursorToAnnotation = (a) => {
46
17
  if (typeof a.row === 'number') {
47
18
  editor.gotoLine(a.row + 1, a.column || 0, false);
@@ -78,6 +49,44 @@ export function setupEditor(ace, editor, setAnnotations, setCursorPosition, setH
78
49
  openAnnotation(row);
79
50
  }
80
51
  });
52
+ // HACK: Annotations aren't cleared when editor is empty.
53
+ editor.on('change', () => {
54
+ if (editor.getValue().length === 0) {
55
+ editor.session.clearAnnotations();
56
+ }
57
+ });
58
+ }
59
+ function setEditorDefaults(ace, editor) {
60
+ ace.config.loadModule('ace/ext/language_tools', function () {
61
+ editor.setOptions({
62
+ displayIndentGuides: false,
63
+ enableSnippets: true,
64
+ enableBasicAutocompletion: true,
65
+ });
66
+ });
67
+ editor.setAutoScrollEditorIntoView(true);
68
+ if (!supportsKeyboardAccessibility(ace)) {
69
+ editor.commands.addCommand({
70
+ name: 'exitCodeEditor',
71
+ bindKey: 'Esc',
72
+ exec: () => {
73
+ editor.container.focus();
74
+ },
75
+ });
76
+ }
77
+ editor.on('focus', () => {
78
+ editor.textInput.getElement().setAttribute('tabindex', 0);
79
+ });
80
+ editor.on('blur', () => {
81
+ editor.textInput.getElement().setAttribute('tabindex', -1);
82
+ });
83
+ // prevent users to step into editor directly by keyboard
84
+ editor.textInput.getElement().setAttribute('tabindex', -1);
85
+ editor.commands.removeCommand('showSettingsMenu', false);
86
+ // Prevent default behavior on error/warning icon click
87
+ editor.on('guttermousedown', (e) => {
88
+ e.stop();
89
+ });
81
90
  // HACK: Wrapped lines are highlighted individually. This is seriously the recommended fix.
82
91
  // See: https://github.com/ajaxorg/ace/issues/3067
83
92
  editor.setHighlightActiveLine(false);
@@ -109,12 +118,6 @@ export function setupEditor(ace, editor, setAnnotations, setCursorPosition, setH
109
118
  }
110
119
  };
111
120
  editor.setHighlightActiveLine(true);
112
- // HACK: Annotations aren't cleared when editor is empty.
113
- editor.on('change', () => {
114
- if (editor.getValue().length === 0) {
115
- editor.session.clearAnnotations();
116
- }
117
- });
118
121
  // HACK: "disable" error tooltips by hiding them as soon as they appear.
119
122
  // See https://github.com/ajaxorg/ace/issues/4004
120
123
  editor.on('showGutterTooltip', (tooltip) => {
@@ -1 +1 @@
1
- {"version":3,"file":"setup-editor.js","sourceRoot":"lib/default/","sources":["code-editor/setup-editor.ts"],"names":[],"mappings":"AAIA,OAAO,EAAc,6BAA6B,EAAE,MAAM,QAAQ,CAAC;AAEnE,MAAM,UAAU,WAAW,CACzB,GAAQ,EACR,MAAkB,EAClB,cAAsE,EACtE,iBAAkE,EAClE,wBAA0F,EAC1F,aAA+D;IAE/D,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,wBAAwB,EAAE;QAC9C,MAAM,CAAC,UAAU,CAAC;YAChB,mBAAmB,EAAE,KAAK;YAC1B,cAAc,EAAE,IAAI;YACpB,yBAAyB,EAAE,IAAI;SAChC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,2BAA2B,CAAC,IAAI,CAAC,CAAC;IAEzC,2CAA2C;IAC3C,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC,cAAc,EAAE,GAAG,EAAE;QAC/C,iBAAiB,CAAC,MAAM,CAAC,iBAAiB,EAAE,CAAC,CAAC;IAChD,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,kBAAyB,EAAE,GAAG,EAAE;QAChD,MAAM,iBAAiB,GAAG,MAAM,CAAC,OAAO,CAAC,cAAc,EAAE,CAAC;QAC1D,MAAM,cAAc,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC;QACxE,IAAI,iB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;YACrD,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,EAAE,SAAS,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;YACtE,KAAa,CAAC,EAAE,GAAG,OAAO,CAAC,SAAS,CAAC,KAAK,EAAE,iBAAiB,EAAE,UAAU,CAAC,CAAC;YAC5E,OAAO,CAAC,oBAAoB,GAAG,KAAK,CAAC;SACtC;aAAM,IAAI,SAAS,EAAE;YACpB,OAAO,CAAC,oBAAoB,CAAC,KAAK,CAAC,GAAG,GAAG,SAAS,CAAC,GAAG,CAAC;YACvD,OAAO,CAAC,oBAAoB,CAAC,GAAG,CAAC,GAAG,GAAG,SAAS,CAAC,GAAG,CAAC;YACrD,OAAO,CAAC,oBAAoB,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;YAC9C,OAAO,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC;SACrC;IACH,CAAC,CAAC;IAEF,MAAM,CAAC,sBAAsB,CAAC,IAAI,CAAC,CAAC;IAEpC,yDAAyD;IACzD,MAAM,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE;QACvB,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE;YAClC,MAAM,CAAC,OAAO,CAAC,gBAAgB,EAAE,CAAC;SACnC;IACH,CAAC,CAAC,CAAC;IAEH,wEAAwE;IACxE,iDAAiD;IACjD,MAAM,CAAC,EAAE,CAAC,mBAA0B,EAAE,CAAC,OAAY,EAAE,EAAE;QACrD,OAAO,CAAC,IAAI,EAAE,CAAC;IACjB,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\nimport { Ace } from 'ace-builds';\nimport { PaneStatus, supportsKeyboardAccessibility } from './util';\n\nexport function setupEditor(\n ace: any,\n editor: Ace.Editor,\n setAnnotations: React.Dispatch<React.SetStateAction<Ace.Annotation[]>>,\n setCursorPosition: React.Dispatch<React.SetStateAction<Ace.Point>>,\n setHighlightedAnnotation: React.Dispatch<React.SetStateAction<Ace.Annotation | undefined>>,\n setPaneStatus: React.Dispatch<React.SetStateAction<PaneStatus>>\n) {\n ace.config.loadModule('ace/ext/language_tools', function () {\n editor.setOptions({\n displayIndentGuides: false,\n enableSnippets: true,\n enableBasicAutocompletion: true,\n });\n });\n\n editor.setAutoScrollEditorIntoView(true);\n\n // To display cursor position in status bar\n editor.session.selection.on('changeCursor', () => {\n setCursorPosition(editor.getCursorPosition());\n });\n\n editor.session.on('changeAnnotation' as any, () => {\n const editorAnnotations = editor.session.getAnnotations();\n const newAnnotations = editorAnnotations.filter(a => a.type !== 'info');\n if (editorAnnotations.length !== newAnnotations.length) {\n editor.session.setAnnotations(newAnnotations);\n }\n setAnnotations(newAnnotations);\n });\n\n if (!supportsKeyboardAccessibility(ace)) {\n editor.commands.addCommand({\n name: 'exitCodeEditor',\n bindKey: 'Esc',\n exec: () => {\n editor.container.focus();\n },\n });\n }\n\n editor.on('focus', () => {\n (editor as any).textInput.getElement().setAttribute('tabindex', 0);\n });\n\n editor.on('blur', () => {\n (editor as any).textInput.getElement().setAttribute('tabindex', -1);\n });\n\n // prevent users to step into editor directly by keyboard\n (editor as any).textInput.getElement().setAttribute('tabindex', -1);\n\n editor.commands.removeCommand('showSettingsMenu', false);\n\n // Prevent default behavior on error/warning icon click\n editor.on('guttermousedown' as any, (e: any) => {\n e.stop();\n });\n\n const moveCursorToAnnotation = (a: Ace.Annotation) => {\n if (typeof a.row === 'number') {\n editor.gotoLine(a.row + 1, a.column || 0, false);\n }\n };\n\n const openAnnotation = (row: number) => {\n const currentAnnotations = editor.session.getAnnotations().filter(a => a.row === row && a.type !== 'info');\n const errors = currentAnnotations.filter(a => a.type === 'error');\n if (errors.length > 0) {\n setHighlightedAnnotation(errors[0]);\n setPaneStatus('error');\n moveCursorToAnnotation(errors[0]);\n } else if (currentAnnotations.length > 0) {\n setHighlightedAnnotation(currentAnnotations[0]);\n setPaneStatus('warning');\n moveCursorToAnnotation(currentAnnotations[0]);\n } else {\n setHighlightedAnnotation(undefined);\n setPaneStatus('hidden');\n editor.gotoLine(row + 1, 0, false);\n }\n };\n\n // open error/warning pane when user clicks on gutter icon\n editor.on('gutterclick' as any, (e: any) => {\n const { row }: Ace.Point = e.getDocumentPosition();\n openAnnotation(row);\n });\n\n // open error/warning pane when user presses space/enter on gutter icon\n editor.on('gutterkeydown', e => {\n if (e.isInAnnotationLane() && (e.getKey() === 'space' || e.getKey() === 'return')) {\n const row: number = e.getRow();\n openAnnotation(row);\n }\n });\n\n // HACK: Wrapped lines are highlighted individually. This is seriously the recommended fix.\n // See: https://github.com/ajaxorg/ace/issues/3067\n editor.setHighlightActiveLine(false);\n (editor as any).$updateHighlightActiveLine = function () {\n const session = this.getSession();\n\n let highlight;\n if (this.$highlightActiveLine) {\n if (this.$selectionStyle !== 'line' || !this.selection.isMultiLine()) {\n highlight = this.getCursorPosition();\n }\n if (this.renderer.$maxLines && this.session.getLength() === 1 && !(this.renderer.$minLines > 1)) {\n highlight = false;\n }\n }\n\n if (session.$highlightLineMarker && !highlight) {\n session.removeMarker(session.$highlightLineMarker.id);\n session.$highlightLineMarker = null;\n } else if (!session.$highlightLineMarker && highlight) {\n const range = new ace.Range(highlight.row, 0, highlight.row, Infinity);\n (range as any).id = session.addMarker(range, 'ace_active-line', 'fullLine');\n session.$highlightLineMarker = range;\n } else if (highlight) {\n session.$highlightLineMarker.start.row = highlight.row;\n session.$highlightLineMarker.end.row = highlight.row;\n session.$highlightLineMarker.start.column = 0;\n session._signal('changeBackMarker');\n }\n };\n\n editor.setHighlightActiveLine(true);\n\n // HACK: Annotations aren't cleared when editor is empty.\n editor.on('change', () => {\n if (editor.getValue().length === 0) {\n editor.session.clearAnnotations();\n }\n });\n\n // HACK: \"disable\" error tooltips by hiding them as soon as they appear.\n // See https://github.com/ajaxorg/ace/issues/4004\n editor.on('showGutterTooltip' as any, (tooltip: any) => {\n tooltip.hide();\n });\n}\n"]}
1
+ {"version":3,"file":"setup-editor.js","sourceRoot":"lib/default/","sources":["code-editor/setup-editor.ts"],"names":[],"mappings":"AAIA,OAAO,EAAc,6BAA6B,EAAE,MAAM,QAAQ,CAAC;AAEnE,MAAM,UAAU,WAAW,CACzB,GAAQ,EACR,MAAkB,EAClB,cAAsE,EACtE,iBAAkE,EAClE,wBAA0F,EAC1F,aAA+D;IAE/D,iBAAiB,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IAE/B,2CAA2C;IAC3C,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC,cAAc,EAAE,GAAG,EAAE;QAC/C,iBAAiB,CAAC,MAAM,CAAC,iBAAiB,EAAE,CAAC,CAAC;IAChD,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,kBAAyB,EAAE,GAAG,EAAE;QAChD,MAAM,iBAAiB,GAAG,MAAM,CAAC,OAAO,CAAC,cAAc,EAAE,CAAC;QAC1D,MAAM,cAAc,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC;QACxE,IAAI,iBAAiB,CAAC,MAAM,KAAK,cAAc,CAAC,MAAM,EAAE;YACtD,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,cAAc,CAAC,CAAC;SAC/C;QACD,cAAc,CAAC,cAAc,CAAC,CAAC;IACjC,CAAC,CAAC,CAAC;IAEH,MAAM,sBAAsB,GAAG,CAAC,CAAiB,EAAE,EAAE;QACnD,IAAI,OAAO,CAAC,CAAC,GAAG,KAAK,QAAQ,EAAE;YAC7B,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,EAAE,CAAC,CAAC,MAAM,IAAI,CAAC,EAAE,KAAK,CAAC,CAAC;SAClD;IACH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CAAC,CAAC;YACtD,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC;SACrC;aAAM,IAAI,CAAC,OAAO,CAAC,oBAAoB,IAAI,SAAS,EAAE;YACrD,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,EAAE,SAAS,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;YACtE,KAAa,CAAC,EAAE,GAAG,OAAO,CAAC,SAAS,CAAC,KAAK,EAAE,iBAAiB,EAAE,UAAU,CAAC,CAAC;YAC5E,OAAO,CAAC,oBAAoB,GAAG,KAAK,CAAC;SACtC;aAAM,IAAI,SAAS,EAAE;YACpB,OAAO,CAAC,oBAAoB,CAAC,KAAK,CAAC,GAAG,GAAG,SAAS,CAAC,GAAG,CAAC;YACvD,OAAO,CAAC,oBAAoB,CAAC,GAAG,CAAC,GAAG,GAAG,SAAS,CAAC,GAAG,CAAC;YACrD,OAAO,CAAC,oBAAoB,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;YAC9C,OAAO,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC;SACrC;IACH,CAAC,CAAC;IAEF,MAAM,CAAC,sBAAsB,CAAC,IAAI,CAAC,CAAC;IAEpC,wEAAwE;IACxE,iDAAiD;IACjD,MAAM,CAAC,EAAE,CAAC,mBAA0B,EAAE,CAAC,OAAY,EAAE,EAAE;QACrD,OAAO,CAAC,IAAI,EAAE,CAAC;IACjB,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\nimport { Ace } from 'ace-builds';\nimport { PaneStatus, supportsKeyboardAccessibility } from './util';\n\nexport function setupEditor(\n ace: any,\n editor: Ace.Editor,\n setAnnotations: React.Dispatch<React.SetStateAction<Ace.Annotation[]>>,\n setCursorPosition: React.Dispatch<React.SetStateAction<Ace.Point>>,\n setHighlightedAnnotation: React.Dispatch<React.SetStateAction<Ace.Annotation | undefined>>,\n setPaneStatus: React.Dispatch<React.SetStateAction<PaneStatus>>\n) {\n setEditorDefaults(ace, editor);\n\n // To display cursor position in status bar\n editor.session.selection.on('changeCursor', () => {\n setCursorPosition(editor.getCursorPosition());\n });\n\n editor.session.on('changeAnnotation' as any, () => {\n const editorAnnotations = editor.session.getAnnotations();\n const newAnnotations = editorAnnotations.filter(a => a.type !== 'info');\n if (editorAnnotations.length !== newAnnotations.length) {\n editor.session.setAnnotations(newAnnotations);\n }\n setAnnotations(newAnnotations);\n });\n\n const moveCursorToAnnotation = (a: Ace.Annotation) => {\n if (typeof a.row === 'number') {\n editor.gotoLine(a.row + 1, a.column || 0, false);\n }\n };\n\n const openAnnotation = (row: number) => {\n const currentAnnotations = editor.session.getAnnotations().filter(a => a.row === row && a.type !== 'info');\n const errors = currentAnnotations.filter(a => a.type === 'error');\n if (errors.length > 0) {\n setHighlightedAnnotation(errors[0]);\n setPaneStatus('error');\n moveCursorToAnnotation(errors[0]);\n } else if (currentAnnotations.length > 0) {\n setHighlightedAnnotation(currentAnnotations[0]);\n setPaneStatus('warning');\n moveCursorToAnnotation(currentAnnotations[0]);\n } else {\n setHighlightedAnnotation(undefined);\n setPaneStatus('hidden');\n editor.gotoLine(row + 1, 0, false);\n }\n };\n\n // open error/warning pane when user clicks on gutter icon\n editor.on('gutterclick' as any, (e: any) => {\n const { row }: Ace.Point = e.getDocumentPosition();\n openAnnotation(row);\n });\n\n // open error/warning pane when user presses space/enter on gutter icon\n editor.on('gutterkeydown', e => {\n if (e.isInAnnotationLane() && (e.getKey() === 'space' || e.getKey() === 'return')) {\n const row: number = e.getRow();\n openAnnotation(row);\n }\n });\n\n // HACK: Annotations aren't cleared when editor is empty.\n editor.on('change', () => {\n if (editor.getValue().length === 0) {\n editor.session.clearAnnotations();\n }\n });\n}\n\nfunction setEditorDefaults(ace: any, editor: Ace.Editor) {\n ace.config.loadModule('ace/ext/language_tools', function () {\n editor.setOptions({\n displayIndentGuides: false,\n enableSnippets: true,\n enableBasicAutocompletion: true,\n });\n });\n\n editor.setAutoScrollEditorIntoView(true);\n\n if (!supportsKeyboardAccessibility(ace)) {\n editor.commands.addCommand({\n name: 'exitCodeEditor',\n bindKey: 'Esc',\n exec: () => {\n editor.container.focus();\n },\n });\n }\n\n editor.on('focus', () => {\n (editor as any).textInput.getElement().setAttribute('tabindex', 0);\n });\n\n editor.on('blur', () => {\n (editor as any).textInput.getElement().setAttribute('tabindex', -1);\n });\n\n // prevent users to step into editor directly by keyboard\n (editor as any).textInput.getElement().setAttribute('tabindex', -1);\n\n editor.commands.removeCommand('showSettingsMenu', false);\n\n // Prevent default behavior on error/warning icon click\n editor.on('guttermousedown' as any, (e: any) => {\n e.stop();\n });\n\n // HACK: Wrapped lines are highlighted individually. This is seriously the recommended fix.\n // See: https://github.com/ajaxorg/ace/issues/3067\n editor.setHighlightActiveLine(false);\n (editor as any).$updateHighlightActiveLine = function () {\n const session = this.getSession();\n\n let highlight;\n if (this.$highlightActiveLine) {\n if (this.$selectionStyle !== 'line' || !this.selection.isMultiLine()) {\n highlight = this.getCursorPosition();\n }\n if (this.renderer.$maxLines && this.session.getLength() === 1 && !(this.renderer.$minLines > 1)) {\n highlight = false;\n }\n }\n\n if (session.$highlightLineMarker && !highlight) {\n session.removeMarker(session.$highlightLineMarker.id);\n session.$highlightLineMarker = null;\n } else if (!session.$highlightLineMarker && highlight) {\n const range = new ace.Range(highlight.row, 0, highlight.row, Infinity);\n (range as any).id = session.addMarker(range, 'ace_active-line', 'fullLine');\n session.$highlightLineMarker = range;\n } else if (highlight) {\n session.$highlightLineMarker.start.row = highlight.row;\n session.$highlightLineMarker.end.row = highlight.row;\n session.$highlightLineMarker.start.column = 0;\n session._signal('changeBackMarker');\n }\n };\n\n editor.setHighlightActiveLine(true);\n\n // HACK: \"disable\" error tooltips by hiding them as soon as they appear.\n // See https://github.com/ajaxorg/ace/issues/4004\n editor.on('showGutterTooltip' as any, (tooltip: any) => {\n tooltip.hide();\n });\n}\n"]}
@@ -0,0 +1,24 @@
1
+ /// <reference types="react" />
2
+ import { Ace } from 'ace-builds';
3
+ import { CodeEditorProps } from './interfaces';
4
+ export declare function useEditor(ace: any, loading?: boolean): {
5
+ editorRef: import("react").RefObject<HTMLDivElement>;
6
+ editor: Ace.Editor | null;
7
+ };
8
+ export declare function useSyncEditorLabels(editor: null | Ace.Editor, { controlId, ariaLabel, ariaLabelledby, ariaDescribedby, }: {
9
+ controlId?: string;
10
+ ariaLabel?: string;
11
+ ariaLabelledby?: string;
12
+ ariaDescribedby?: string;
13
+ }): void;
14
+ export declare function useSyncEditorSize(editor: null | Ace.Editor, { width, height }: {
15
+ width?: null | number;
16
+ height?: null | number;
17
+ }): {
18
+ onResize: () => void;
19
+ };
20
+ export declare function useSyncEditorValue(editor: null | Ace.Editor, value: string): void;
21
+ export declare function useSyncEditorLanguage(editor: null | Ace.Editor, language: string): void;
22
+ export declare function useSyncEditorWrapLines(editor: null | Ace.Editor, wrapLines?: boolean): void;
23
+ export declare function useSyncEditorTheme(editor: null | Ace.Editor, theme: CodeEditorProps.Theme): void;
24
+ //# sourceMappingURL=use-editor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-editor.d.ts","sourceRoot":"lib/default/","sources":["code-editor/use-editor.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAGjC,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,wBAAgB,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,OAAO;;;EAmBpD;AAED,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,IAAI,GAAG,GAAG,CAAC,MAAM,EACzB,EACE,SAAS,EACT,SAAS,EACT,cAAc,EACd,eAAe,GAChB,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IAAC,eAAe,CAAC,EAAE,MAAM,CAAA;CAAE,QAiBjG;AAED,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,IAAI,GAAG,GAAG,CAAC,MAAM,EACzB,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE;IAAE,KAAK,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,IAAI,GAAG,MAAM,CAAA;CAAE;;EAWrE;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,IAAI,GAAG,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,QAY1E;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,IAAI,GAAG,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,QAIhF;AAED,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,IAAI,GAAG,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,EAAE,OAAO,QAIpF;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,IAAI,GAAG,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,eAAe,CAAC,KAAK,QAIzF"}
@@ -0,0 +1,71 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import { useCallback, useEffect, useRef, useState } from 'react';
4
+ import { getAceTheme, getDefaultConfig, getDefaultTheme } from './util';
5
+ export function useEditor(ace, loading) {
6
+ const editorRef = useRef(null);
7
+ const [editor, setEditor] = useState(null);
8
+ useEffect(() => {
9
+ const elem = editorRef.current;
10
+ if (!ace || !elem) {
11
+ return;
12
+ }
13
+ const config = getDefaultConfig(ace);
14
+ setEditor(ace.edit(elem, Object.assign(Object.assign({}, config), { theme: getAceTheme(getDefaultTheme(elem)) })));
15
+ }, [ace, loading]);
16
+ return { editorRef, editor };
17
+ }
18
+ export function useSyncEditorLabels(editor, { controlId, ariaLabel, ariaLabelledby, ariaDescribedby, }) {
19
+ useEffect(() => {
20
+ if (!editor) {
21
+ return;
22
+ }
23
+ const { textarea } = editor.renderer;
24
+ if (!textarea) {
25
+ return;
26
+ }
27
+ const updateAttribute = (attribute, value) => value ? textarea.setAttribute(attribute, value) : textarea.removeAttribute(attribute);
28
+ updateAttribute('id', controlId);
29
+ updateAttribute('aria-label', ariaLabel);
30
+ updateAttribute('aria-labelledby', ariaLabelledby);
31
+ updateAttribute('aria-describedby', ariaDescribedby);
32
+ }, [ariaLabel, ariaDescribedby, ariaLabelledby, controlId, editor]);
33
+ }
34
+ export function useSyncEditorSize(editor, { width, height }) {
35
+ useEffect(() => {
36
+ editor === null || editor === void 0 ? void 0 : editor.resize();
37
+ }, [editor, width, height]);
38
+ const onResize = useCallback(() => {
39
+ editor === null || editor === void 0 ? void 0 : editor.resize();
40
+ }, [editor]);
41
+ return { onResize };
42
+ }
43
+ export function useSyncEditorValue(editor, value) {
44
+ useEffect(() => {
45
+ if (!editor) {
46
+ return;
47
+ }
48
+ if (value === editor.getValue()) {
49
+ return;
50
+ }
51
+ const pos = editor.session.selection.toJSON();
52
+ editor.setValue(value, -1);
53
+ editor.session.selection.fromJSON(pos);
54
+ }, [editor, value]);
55
+ }
56
+ export function useSyncEditorLanguage(editor, language) {
57
+ useEffect(() => {
58
+ editor === null || editor === void 0 ? void 0 : editor.session.setMode(`ace/mode/${language}`);
59
+ }, [editor, language]);
60
+ }
61
+ export function useSyncEditorWrapLines(editor, wrapLines) {
62
+ useEffect(() => {
63
+ editor === null || editor === void 0 ? void 0 : editor.session.setUseWrapMode(wrapLines !== null && wrapLines !== void 0 ? wrapLines : true);
64
+ }, [editor, wrapLines]);
65
+ }
66
+ export function useSyncEditorTheme(editor, theme) {
67
+ useEffect(() => {
68
+ editor === null || editor === void 0 ? void 0 : editor.setTheme(getAceTheme(theme));
69
+ }, [editor, theme]);
70
+ }
71
+ //# sourceMappingURL=use-editor.js.map