@cloudscape-design/components 3.0.125 → 3.0.127
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/annotation-context/annotation/annotation-popover.d.ts.map +1 -1
- package/annotation-context/annotation/annotation-popover.js +8 -2
- package/annotation-context/annotation/annotation-popover.js.map +1 -1
- package/annotation-context/annotation/annotation-trigger.d.ts +2 -0
- package/annotation-context/annotation/annotation-trigger.d.ts.map +1 -1
- package/annotation-context/annotation/annotation-trigger.js +2 -2
- package/annotation-context/annotation/annotation-trigger.js.map +1 -1
- package/annotation-context/annotation/closed-annotation.d.ts +3 -1
- package/annotation-context/annotation/closed-annotation.d.ts.map +1 -1
- package/annotation-context/annotation/closed-annotation.js +2 -2
- package/annotation-context/annotation/closed-annotation.js.map +1 -1
- package/annotation-context/annotation/open-annotation.d.ts.map +1 -1
- package/annotation-context/annotation/open-annotation.js +1 -1
- package/annotation-context/annotation/open-annotation.js.map +1 -1
- package/annotation-context/annotation/styles.css.js +24 -24
- package/annotation-context/annotation/styles.scoped.css +30 -30
- package/annotation-context/annotation/styles.selectors.js +24 -24
- package/annotation-context/index.d.ts.map +1 -1
- package/annotation-context/index.js +3 -1
- package/annotation-context/index.js.map +1 -1
- package/annotation-context/interfaces.d.ts +1 -1
- package/annotation-context/interfaces.d.ts.map +1 -1
- package/annotation-context/interfaces.js.map +1 -1
- package/app-layout/visual-refresh/main.d.ts.map +1 -1
- package/app-layout/visual-refresh/main.js +8 -3
- package/app-layout/visual-refresh/main.js.map +1 -1
- package/app-layout/visual-refresh/styles.css.js +60 -60
- package/app-layout/visual-refresh/styles.scoped.css +255 -237
- package/app-layout/visual-refresh/styles.selectors.js +60 -60
- package/area-chart/internal.d.ts.map +1 -1
- package/area-chart/internal.js +5 -0
- package/area-chart/internal.js.map +1 -1
- package/area-chart/model/index.d.ts +1 -0
- package/area-chart/model/index.d.ts.map +1 -1
- package/area-chart/model/index.js.map +1 -1
- package/area-chart/model/use-chart-model.d.ts.map +1 -1
- package/area-chart/model/use-chart-model.js +8 -1
- package/area-chart/model/use-chart-model.js.map +1 -1
- package/attribute-editor/row.d.ts.map +1 -1
- package/attribute-editor/row.js +4 -3
- package/attribute-editor/row.js.map +1 -1
- package/attribute-editor/styles.css.js +13 -12
- package/attribute-editor/styles.scoped.css +27 -23
- package/attribute-editor/styles.selectors.js +13 -12
- package/breadcrumb-group/interfaces.d.ts +1 -0
- package/breadcrumb-group/interfaces.d.ts.map +1 -1
- package/breadcrumb-group/interfaces.js.map +1 -1
- package/breadcrumb-group/internal.d.ts.map +1 -1
- package/breadcrumb-group/internal.js +1 -1
- package/breadcrumb-group/internal.js.map +1 -1
- package/breadcrumb-group/item/item.d.ts +1 -1
- package/breadcrumb-group/item/item.d.ts.map +1 -1
- package/breadcrumb-group/item/item.js +68 -8
- package/breadcrumb-group/item/item.js.map +1 -1
- package/breadcrumb-group/item/styles.css.js +9 -7
- package/breadcrumb-group/item/styles.scoped.css +26 -16
- package/breadcrumb-group/item/styles.selectors.js +9 -7
- package/code-editor/index.d.ts.map +1 -1
- package/code-editor/index.js +11 -16
- package/code-editor/index.js.map +1 -1
- package/code-editor/interfaces.d.ts +12 -1
- package/code-editor/interfaces.d.ts.map +1 -1
- package/code-editor/interfaces.js.map +1 -1
- package/code-editor/status-bar.d.ts.map +1 -1
- package/code-editor/status-bar.js +7 -1
- package/code-editor/status-bar.js.map +1 -1
- package/code-editor/util.js +1 -1
- package/code-editor/util.js.map +1 -1
- package/container/internal.d.ts.map +1 -1
- package/container/internal.js +7 -4
- package/container/internal.js.map +1 -1
- package/date-range-picker/calendar/grids/index.d.ts +0 -1
- package/date-range-picker/calendar/grids/index.d.ts.map +1 -1
- package/date-range-picker/calendar/grids/index.js +2 -14
- package/date-range-picker/calendar/grids/index.js.map +1 -1
- package/date-range-picker/calendar/index.d.ts +6 -4
- package/date-range-picker/calendar/index.d.ts.map +1 -1
- package/date-range-picker/calendar/index.js +111 -123
- package/date-range-picker/calendar/index.js.map +1 -1
- package/date-range-picker/calendar/utils.d.ts +4 -0
- package/date-range-picker/calendar/utils.d.ts.map +1 -0
- package/date-range-picker/calendar/utils.js +31 -0
- package/date-range-picker/calendar/utils.js.map +1 -0
- package/date-range-picker/dropdown.d.ts +2 -1
- package/date-range-picker/dropdown.d.ts.map +1 -1
- package/date-range-picker/dropdown.js +8 -6
- package/date-range-picker/dropdown.js.map +1 -1
- package/date-range-picker/index.d.ts.map +1 -1
- package/date-range-picker/index.js +2 -2
- package/date-range-picker/index.js.map +1 -1
- package/date-range-picker/interfaces.d.ts +14 -4
- package/date-range-picker/interfaces.d.ts.map +1 -1
- package/date-range-picker/interfaces.js.map +1 -1
- package/date-range-picker/styles.css.js +38 -38
- package/date-range-picker/styles.scoped.css +45 -50
- package/date-range-picker/styles.selectors.js +38 -38
- package/date-range-picker/utils.d.ts +2 -8
- package/date-range-picker/utils.d.ts.map +1 -1
- package/date-range-picker/utils.js +17 -12
- package/date-range-picker/utils.js.map +1 -1
- package/flashbar/styles.css.js +33 -33
- package/flashbar/styles.scoped.css +121 -121
- package/flashbar/styles.selectors.js +33 -33
- package/internal/components/dropdown/index.d.ts.map +1 -1
- package/internal/components/dropdown/index.js +2 -9
- package/internal/components/dropdown/index.js.map +1 -1
- package/internal/components/dropdown-status/index.d.ts +1 -4
- package/internal/components/dropdown-status/index.d.ts.map +1 -1
- package/internal/components/dropdown-status/index.js +3 -5
- package/internal/components/dropdown-status/index.js.map +1 -1
- package/internal/components/filtering-token/index.d.ts +2 -1
- package/internal/components/filtering-token/index.d.ts.map +1 -1
- package/internal/components/filtering-token/index.js +2 -2
- package/internal/components/filtering-token/index.js.map +1 -1
- package/internal/components/option/index.js +4 -4
- package/internal/components/option/index.js.map +1 -1
- package/internal/environment.js +1 -1
- package/internal/generated/custom-css-properties/index.d.ts.map +1 -1
- package/internal/generated/custom-css-properties/index.js +27 -26
- package/internal/generated/custom-css-properties/index.js.map +1 -1
- package/internal/hooks/use-analytics/index.d.ts +2 -0
- package/internal/hooks/use-analytics/index.d.ts.map +1 -0
- package/internal/hooks/use-analytics/index.js +16 -0
- package/internal/hooks/use-analytics/index.js.map +1 -0
- package/internal/manifest.json +1 -1
- package/internal/utils/date-time/format-date-time.d.ts +2 -0
- package/internal/utils/date-time/format-date-time.d.ts.map +1 -0
- package/internal/utils/date-time/format-date-time.js +8 -0
- package/internal/utils/date-time/format-date-time.js.map +1 -0
- package/internal/utils/date-time/index.d.ts +2 -1
- package/internal/utils/date-time/index.d.ts.map +1 -1
- package/internal/utils/date-time/index.js +2 -1
- package/internal/utils/date-time/index.js.map +1 -1
- package/internal/utils/date-time/join-date-time.d.ts +4 -0
- package/internal/utils/date-time/join-date-time.d.ts.map +1 -1
- package/internal/utils/date-time/join-date-time.js +4 -0
- package/internal/utils/date-time/join-date-time.js.map +1 -1
- package/mixed-line-bar-chart/chart-container.d.ts.map +1 -1
- package/mixed-line-bar-chart/chart-container.js +14 -5
- package/mixed-line-bar-chart/chart-container.js.map +1 -1
- package/package.json +1 -1
- package/pie-chart/pie-chart.d.ts.map +1 -1
- package/pie-chart/pie-chart.js +10 -1
- package/pie-chart/pie-chart.js.map +1 -1
- package/popover/body.d.ts +2 -1
- package/popover/body.d.ts.map +1 -1
- package/popover/body.js +2 -2
- package/popover/body.js.map +1 -1
- package/property-filter/interfaces.d.ts +1 -0
- package/property-filter/interfaces.d.ts.map +1 -1
- package/property-filter/interfaces.js.map +1 -1
- package/property-filter/token.d.ts.map +1 -1
- package/property-filter/token.js +1 -1
- package/property-filter/token.js.map +1 -1
- package/select/parts/filter.d.ts +1 -1
- package/select/utils/use-select.d.ts +1 -7
- package/select/utils/use-select.d.ts.map +1 -1
- package/select/utils/use-select.js +1 -1
- package/select/utils/use-select.js.map +1 -1
- package/split-panel/index.d.ts.map +1 -1
- package/split-panel/index.js +11 -9
- package/split-panel/index.js.map +1 -1
- package/table/styles.css.js +34 -34
- package/table/styles.scoped.css +42 -40
- package/table/styles.selectors.js +34 -34
- package/tabs/index.d.ts.map +1 -1
- package/tabs/index.js +9 -11
- package/tabs/index.js.map +1 -1
- package/tabs/styles.css.js +21 -21
- package/tabs/styles.scoped.css +48 -41
- package/tabs/styles.selectors.js +21 -21
- package/tabs/tab-header-bar.d.ts +4 -0
- package/tabs/tab-header-bar.d.ts.map +1 -1
- package/tabs/tab-header-bar.js +5 -1
- package/tabs/tab-header-bar.js.map +1 -1
- package/tag-editor/internal.d.ts.map +1 -1
- package/tag-editor/internal.js +6 -7
- package/tag-editor/internal.js.map +1 -1
- package/test-utils/tsconfig.tsbuildinfo +1 -1
- package/tutorial-panel/components/tutorial-detail-view/index.d.ts.map +1 -1
- package/tutorial-panel/components/tutorial-detail-view/index.js +3 -1
- package/tutorial-panel/components/tutorial-detail-view/index.js.map +1 -1
- package/tutorial-panel/components/tutorial-detail-view/task.d.ts.map +1 -1
- package/tutorial-panel/components/tutorial-detail-view/task.js +2 -1
- package/tutorial-panel/components/tutorial-detail-view/task.js.map +1 -1
- package/tutorial-panel/components/tutorial-list/index.d.ts.map +1 -1
- package/tutorial-panel/components/tutorial-list/index.js +2 -2
- package/tutorial-panel/components/tutorial-list/index.js.map +1 -1
- package/tutorial-panel/interfaces.d.ts +2 -0
- package/tutorial-panel/interfaces.d.ts.map +1 -1
- package/tutorial-panel/interfaces.js.map +1 -1
- package/wizard/index.d.ts.map +1 -1
- package/wizard/index.js +9 -5
- package/wizard/index.js.map +1 -1
- package/wizard/wizard-form.d.ts.map +1 -1
- package/wizard/wizard-form.js +7 -2
- package/wizard/wizard-form.js.map +1 -1
- package/date-range-picker/calendar/use-date-time.d.ts +0 -9
- package/date-range-picker/calendar/use-date-time.d.ts.map +0 -1
- package/date-range-picker/calendar/use-date-time.js +0 -16
- package/date-range-picker/calendar/use-date-time.js.map +0 -1
package/code-editor/index.js
CHANGED
|
@@ -17,7 +17,6 @@ import handler from './resize-handler';
|
|
|
17
17
|
import PreferencesModal from './preferences-modal';
|
|
18
18
|
import LoadingScreen from './loading-screen';
|
|
19
19
|
import ErrorScreen from './error-screen';
|
|
20
|
-
import styles from './styles.css.js';
|
|
21
20
|
import { applyDisplayName } from '../internal/utils/apply-display-name';
|
|
22
21
|
import { useContainerQuery } from '../internal/hooks/container-queries/use-container-query';
|
|
23
22
|
import useBaseComponent from '../internal/hooks/use-base-component';
|
|
@@ -27,11 +26,12 @@ import { useFormFieldContext } from '../internal/context/form-field-context';
|
|
|
27
26
|
import { useVisualRefresh } from '../internal/hooks/use-visual-mode';
|
|
28
27
|
import { useControllable } from '../internal/hooks/use-controllable';
|
|
29
28
|
import LiveRegion from '../internal/components/live-region';
|
|
29
|
+
import styles from './styles.css.js';
|
|
30
30
|
export default function CodeEditor(props) {
|
|
31
31
|
var _a;
|
|
32
32
|
var __internalRootRef = useBaseComponent('CodeEditor').__internalRootRef;
|
|
33
33
|
var _b = useFormFieldContext(props), controlId = _b.controlId, ariaLabelledby = _b.ariaLabelledby, ariaDescribedby = _b.ariaDescribedby;
|
|
34
|
-
var ace = props.ace, value = props.value, language = props.language, i18nStrings = props.i18nStrings, editorContentHeight = props.editorContentHeight, onEditorContentResize = props.onEditorContentResize, rest = __rest(props, ["ace", "value", "language", "i18nStrings", "editorContentHeight", "onEditorContentResize"]);
|
|
34
|
+
var ace = props.ace, value = props.value, language = props.language, i18nStrings = props.i18nStrings, editorContentHeight = props.editorContentHeight, onEditorContentResize = props.onEditorContentResize, customLanguageLabel = props.languageLabel, rest = __rest(props, ["ace", "value", "language", "i18nStrings", "editorContentHeight", "onEditorContentResize", "languageLabel"]);
|
|
35
35
|
var _c = useControllable(editorContentHeight, onEditorContentResize, 480, {
|
|
36
36
|
componentName: 'code-editor',
|
|
37
37
|
changeHandler: 'onEditorContentResize',
|
|
@@ -47,7 +47,7 @@ export default function CodeEditor(props) {
|
|
|
47
47
|
}
|
|
48
48
|
var config = getDefaultConfig();
|
|
49
49
|
setEditor(ace.edit(elem, __assign(__assign({}, config), { theme: getAceTheme(getDefaultTheme(elem)) })));
|
|
50
|
-
}, [ace]);
|
|
50
|
+
}, [ace]);
|
|
51
51
|
useEffect(function () {
|
|
52
52
|
if (!editor) {
|
|
53
53
|
return;
|
|
@@ -66,12 +66,11 @@ export default function CodeEditor(props) {
|
|
|
66
66
|
var _f = useState('hidden'), paneStatus = _f[0], setPaneStatus = _f[1];
|
|
67
67
|
var _g = useState([]), annotations = _g[0], setAnnotations = _g[1];
|
|
68
68
|
var _h = useState(), highlightedAnnotation = _h[0], setHighlightedAnnotation = _h[1];
|
|
69
|
-
var _j = useState(
|
|
70
|
-
var _k = useState(
|
|
71
|
-
var _l = useState(false), isTabFocused = _l[0], setTabFocused = _l[1];
|
|
69
|
+
var _j = useState({ row: 0, column: 0 }), cursorPosition = _j[0], setCursorPosition = _j[1];
|
|
70
|
+
var _k = useState(false), isTabFocused = _k[0], setTabFocused = _k[1];
|
|
72
71
|
var errorsTabRef = useRef(null);
|
|
73
72
|
var warningsTabRef = useRef(null);
|
|
74
|
-
var
|
|
73
|
+
var _l = useContainerQuery(function (rect) { return rect.width; }), codeEditorWidth = _l[0], codeEditorMeasureRef = _l[1];
|
|
75
74
|
var mergedRef = useMergeRefs(codeEditorMeasureRef, __internalRootRef);
|
|
76
75
|
var isRefresh = useVisualRefresh();
|
|
77
76
|
useEffect(function () {
|
|
@@ -85,7 +84,7 @@ export default function CodeEditor(props) {
|
|
|
85
84
|
setupEditor(ace, editor, setAnnotations, setCursorPosition, setHighlightedAnnotation, setPaneStatus);
|
|
86
85
|
return function () {
|
|
87
86
|
editor === null || editor === void 0 ? void 0 : editor.destroy();
|
|
88
|
-
};
|
|
87
|
+
};
|
|
89
88
|
}, [ace, editor, __internalRootRef]);
|
|
90
89
|
useEffect(function () {
|
|
91
90
|
if (!editor) {
|
|
@@ -100,11 +99,7 @@ export default function CodeEditor(props) {
|
|
|
100
99
|
editor.session.selection.fromJSON(pos);
|
|
101
100
|
}, [editor, value]);
|
|
102
101
|
useEffect(function () {
|
|
103
|
-
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
editor.session.setMode("ace/mode/".concat(language));
|
|
107
|
-
setLanguageLabel(getLanguageLabel(language));
|
|
102
|
+
editor === null || editor === void 0 ? void 0 : editor.session.setMode("ace/mode/".concat(language));
|
|
108
103
|
}, [editor, language]);
|
|
109
104
|
useEffect(function () {
|
|
110
105
|
var _a, _b, _c, _d;
|
|
@@ -115,9 +110,8 @@ export default function CodeEditor(props) {
|
|
|
115
110
|
editor.setTheme(getAceTheme(theme));
|
|
116
111
|
editor.session.setUseWrapMode((_d = (_c = props.preferences) === null || _c === void 0 ? void 0 : _c.wrapLines) !== null && _d !== void 0 ? _d : true);
|
|
117
112
|
}, [editor, defaultTheme, props.preferences]);
|
|
118
|
-
// listeners
|
|
113
|
+
// Change listeners
|
|
119
114
|
useChangeEffect(editor, props.onChange, props.onDelayedChange);
|
|
120
|
-
// TODO implement other listeners
|
|
121
115
|
// Hide error panel when there are no errors to show.
|
|
122
116
|
useEffect(function () {
|
|
123
117
|
if (annotations.length === 0) {
|
|
@@ -127,6 +121,7 @@ export default function CodeEditor(props) {
|
|
|
127
121
|
fireNonCancelableEvent(props.onValidate, { annotations: annotations });
|
|
128
122
|
}
|
|
129
123
|
}, [annotations, props.onValidate]);
|
|
124
|
+
var languageLabel = customLanguageLabel !== null && customLanguageLabel !== void 0 ? customLanguageLabel : getLanguageLabel(language);
|
|
130
125
|
var errorCount = annotations.filter(function (a) { return a.type === 'error'; }).length;
|
|
131
126
|
var warningCount = annotations.filter(function (a) { return a.type === 'warning'; }).length;
|
|
132
127
|
var currentAnnotations = useMemo(function () { return annotations.filter(function (a) { return a.type === paneStatus; }); }, [annotations, paneStatus]);
|
|
@@ -185,7 +180,7 @@ export default function CodeEditor(props) {
|
|
|
185
180
|
activeElement !== warningsTabRef.current &&
|
|
186
181
|
!(editor === null || editor === void 0 ? void 0 : editor.container.contains(activeElement)));
|
|
187
182
|
}, [editor]);
|
|
188
|
-
var
|
|
183
|
+
var _m = useState(false), isPreferencesModalVisible = _m[0], setPreferencesModalVisible = _m[1];
|
|
189
184
|
var onPreferencesOpen = function () { return setPreferencesModalVisible(true); };
|
|
190
185
|
var onPreferencesConfirm = function (p) {
|
|
191
186
|
fireNonCancelableEvent(props.onPreferencesChange, p);
|
package/code-editor/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/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,MAAM,OAAO,CAAC;AAEjF,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,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,EACL,gBAAgB,EAChB,WAAW,EAEX,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACnB,eAAe,GAChB,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,OAAO,MAAM,kBAAkB,CAAC;AACvC,OAAO,gBAAgB,MAAM,qBAAqB,CAAC;AACnD,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAC7C,OAAO,WAAW,MAAM,gBAAgB,CAAC;AAEzC,OAAO,MAAM,MAAM,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MAAM,EAAE,WAAW,CAAC,sBAAsB;oBAC1C,OAAO,EAAE,WAAW,CAAC,uBAAuB;oBAC5C,SAAS,EAAE,WAAW,CAAC,yBAAyB;oBAChD,KAAK,EAAE,WAAW,CAAC,qBAAqB;oBACxC,WAAW,EAAE,WAAW,CAAC,2BAA2B;oBACpD,UAAU,EAAE,WAAW,CAAC,0BAA0B;iBACnD,GACD,CACH,CACA,CACJ,CACG,CACP,CAAC;AACJ,CAAC;AAED,gBAAgB,CAAC,UAAU,EAAE,YAAY,CAAC,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 } from 'react';\nimport { Ace } from 'ace-builds';\nimport clsx from 'clsx';\nimport { ResizableBox } from 'react-resizable';\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 handler from './resize-handler';\nimport PreferencesModal from './preferences-modal';\nimport LoadingScreen from './loading-screen';\nimport ErrorScreen from './error-screen';\n\nimport styles from './styles.css.js';\nimport { applyDisplayName } from '../internal/utils/apply-display-name';\nimport { useContainerQuery } from '../internal/hooks/container-queries/use-container-query';\nimport useBaseComponent from '../internal/hooks/use-base-component';\nimport { useCurrentMode } from '../internal/hooks/use-visual-mode';\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';\nexport { CodeEditorProps };\n\nexport default function CodeEditor(props: CodeEditorProps) {\n const { __internalRootRef } = useBaseComponent('CodeEditor');\n const { controlId, ariaLabelledby, ariaDescribedby } = useFormFieldContext(props);\n const { ace, value, language, i18nStrings, editorContentHeight, onEditorContentResize, ...rest } = 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\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 const editorRef = useCallback(\n (elem: HTMLDivElement) => {\n if (!ace || !elem) {\n return;\n }\n\n const config = getDefaultConfig();\n setEditor(\n ace.edit(elem, {\n ...config,\n theme: getAceTheme(getDefaultTheme(elem)),\n })\n );\n },\n [ace]\n ); // loads as soon as ace lib is available\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-labelledby', ariaLabelledby);\n updateAttribute('aria-describedby', ariaDescribedby);\n }, [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 [languageLabel, setLanguageLabel] = useState<string>('');\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\n const [codeEditorWidth, codeEditorMeasureRef] = useContainerQuery(rect => rect.width);\n const mergedRef = useMergeRefs(codeEditorMeasureRef, __internalRootRef);\n\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 }; // TODO profile/monitor this\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 if (!editor) {\n return;\n }\n editor.session.setMode(`ace/mode/${language}`);\n\n setLanguageLabel(getLanguageLabel(language));\n }, [editor, language]);\n\n useEffect(() => {\n if (!editor) {\n return;\n }\n\n const theme: CodeEditorProps.Theme = props.preferences?.theme ?? defaultTheme;\n\n editor.setTheme(getAceTheme(theme));\n\n editor.session.setUseWrapMode(props.preferences?.wrapLines ?? true);\n }, [editor, defaultTheme, props.preferences]);\n\n // listeners\n useChangeEffect(editor, props.onChange, props.onDelayedChange);\n // TODO implement other listeners\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 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 = useCallback(() => {\n if (paneStatus === 'error' && errorsTabRef.current) {\n errorsTabRef.current.focus();\n }\n if (paneStatus === 'warning' && warningsTabRef.current) {\n warningsTabRef.current.focus();\n }\n setPaneStatus('hidden');\n }, [paneStatus]);\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 /**\n * Ignore focus lock if focused element is the pane tab button or within editor tree.\n * This check is required:\n * - When closing the pane with `ESC` key: The panel closes asynchronously and its focus lock\n * still exists when trying to focus the tab button in higher-order component.\n * - When clicking or hittin `Enter` on an annotation: The panel remains open but focus lock\n * deactivates asynchronously.\n */\n const shouldHandleFocus = useCallback(\n (activeElement: HTMLElement): boolean => {\n return (\n activeElement !== errorsTabRef.current &&\n activeElement !== warningsTabRef.current &&\n !editor?.container.contains(activeElement)\n );\n },\n [editor]\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 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}>{i18nStrings.loadingState}</LiveRegion>\n </LoadingScreen>\n )}\n\n {!ace && !props.loading && (\n <ErrorScreen recoveryText={i18nStrings.errorStateRecovery} onRecoveryClick={props.onRecoveryClick}>\n {i18nStrings.errorState}\n </ErrorScreen>\n )}\n\n {ace && !props.loading && (\n <>\n <ResizableBox\n className={styles['resizable-box']}\n width={Infinity}\n height={Math.max(editorHeight, 20)}\n minConstraints={[Infinity, 20]}\n axis=\"y\"\n handle={handler}\n onResize={(e, data) => {\n setEditorHeight(data.size.height);\n onResize();\n fireNonCancelableEvent(onEditorContentResize, {\n height: data.size.height,\n });\n }}\n >\n <div\n ref={editorRef}\n className={clsx(styles.editor, styles.ace)}\n onKeyDown={onEditorKeydown}\n tabIndex={0}\n role=\"group\"\n aria-label={i18nStrings.editorGroupAriaLabel}\n />\n </ResizableBox>\n <div role=\"group\" aria-label={i18nStrings.statusBarGroupAriaLabel}>\n <StatusBar\n languageLabel={languageLabel}\n cursorPosition={i18nStrings.cursorPosition(cursorPosition.row + 1, cursorPosition.column + 1)}\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={paneId}\n onPreferencesOpen={onPreferencesOpen}\n isRefresh={isRefresh}\n />\n <Pane\n id={paneId}\n visible={paneStatus !== 'hidden'}\n annotations={currentAnnotations}\n highlighted={highlightedAnnotation}\n onAnnotationClick={onAnnotationClick}\n onAnnotationClear={onAnnotationClear}\n onClose={onPaneClose}\n onAllowlist={shouldHandleFocus}\n cursorPositionLabel={i18nStrings.cursorPosition}\n closeButtonAriaLabel={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: i18nStrings.preferencesModalHeader,\n cancel: i18nStrings.preferencesModalCancel,\n confirm: i18nStrings.preferencesModalConfirm,\n wrapLines: i18nStrings.preferencesModalWrapLines,\n theme: i18nStrings.preferencesModalTheme,\n lightThemes: i18nStrings.preferencesModalLightThemes,\n darkThemes: i18nStrings.preferencesModalDarkThemes,\n }}\n />\n )}\n </>\n )}\n </div>\n );\n}\n\napplyDisplayName(CodeEditor, 'CodeEditor');\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/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,MAAM,OAAO,CAAC;AAEjF,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,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,EACL,gBAAgB,EAChB,WAAW,EAEX,gBAAgB,EAChB,kBAAkB,EAClB,mBAAm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gBAAgB,IACf,SAAS,EAAE,oBAAoB,EAC/B,SAAS,EAAE,oBAAoB,EAC/B,MAAM,EAAE,KAAK,CAAC,MAAM,EACpB,WAAW,EAAE,KAAK,CAAC,WAAW,EAC9B,YAAY,EAAE,YAAY,EAC1B,WAAW,EAAE;oBACX,MAAM,EAAE,WAAW,CAAC,sBAAsB;oBAC1C,MAAM,EAAE,WAAW,CAAC,sBAAsB;oBAC1C,OAAO,EAAE,WAAW,CAAC,uBAAuB;oBAC5C,SAAS,EAAE,WAAW,CAAC,yBAAyB;oBAChD,KAAK,EAAE,WAAW,CAAC,qBAAqB;oBACxC,WAAW,EAAE,WAAW,CAAC,2BAA2B;oBACpD,UAAU,EAAE,WAAW,CAAC,0BAA0B;iBACnD,GACD,CACH,CACA,CACJ,CACG,CACP,CAAC;AACJ,CAAC;AAED,gBAAgB,CAAC,UAAU,EAAE,YAAY,CAAC,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 } from 'react';\nimport { Ace } from 'ace-builds';\nimport clsx from 'clsx';\nimport { ResizableBox } from 'react-resizable';\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 handler from './resize-handler';\nimport PreferencesModal from './preferences-modal';\nimport LoadingScreen from './loading-screen';\nimport ErrorScreen from './error-screen';\n\nimport { applyDisplayName } from '../internal/utils/apply-display-name';\nimport { useContainerQuery } from '../internal/hooks/container-queries/use-container-query';\nimport useBaseComponent from '../internal/hooks/use-base-component';\nimport { useCurrentMode } from '../internal/hooks/use-visual-mode';\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';\n\nexport { CodeEditorProps };\n\nexport default function CodeEditor(props: CodeEditorProps) {\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 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\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 const editorRef = useCallback(\n (elem: HTMLDivElement) => {\n if (!ace || !elem) {\n return;\n }\n\n const config = getDefaultConfig();\n setEditor(\n ace.edit(elem, {\n ...config,\n theme: getAceTheme(getDefaultTheme(elem)),\n })\n );\n },\n [ace]\n );\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-labelledby', ariaLabelledby);\n updateAttribute('aria-describedby', ariaDescribedby);\n }, [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\n const [codeEditorWidth, codeEditorMeasureRef] = useContainerQuery(rect => rect.width);\n const mergedRef = useMergeRefs(codeEditorMeasureRef, __internalRootRef);\n\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 = useCallback(() => {\n if (paneStatus === 'error' && errorsTabRef.current) {\n errorsTabRef.current.focus();\n }\n if (paneStatus === 'warning' && warningsTabRef.current) {\n warningsTabRef.current.focus();\n }\n setPaneStatus('hidden');\n }, [paneStatus]);\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 /**\n * Ignore focus lock if focused element is the pane tab button or within editor tree.\n * This check is required:\n * - When closing the pane with `ESC` key: The panel closes asynchronously and its focus lock\n * still exists when trying to focus the tab button in higher-order component.\n * - When clicking or hittin `Enter` on an annotation: The panel remains open but focus lock\n * deactivates asynchronously.\n */\n const shouldHandleFocus = useCallback(\n (activeElement: HTMLElement): boolean => {\n return (\n activeElement !== errorsTabRef.current &&\n activeElement !== warningsTabRef.current &&\n !editor?.container.contains(activeElement)\n );\n },\n [editor]\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 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}>{i18nStrings.loadingState}</LiveRegion>\n </LoadingScreen>\n )}\n\n {!ace && !props.loading && (\n <ErrorScreen recoveryText={i18nStrings.errorStateRecovery} onRecoveryClick={props.onRecoveryClick}>\n {i18nStrings.errorState}\n </ErrorScreen>\n )}\n\n {ace && !props.loading && (\n <>\n <ResizableBox\n className={styles['resizable-box']}\n width={Infinity}\n height={Math.max(editorHeight, 20)}\n minConstraints={[Infinity, 20]}\n axis=\"y\"\n handle={handler}\n onResize={(e, data) => {\n setEditorHeight(data.size.height);\n onResize();\n fireNonCancelableEvent(onEditorContentResize, {\n height: data.size.height,\n });\n }}\n >\n <div\n ref={editorRef}\n className={clsx(styles.editor, styles.ace)}\n onKeyDown={onEditorKeydown}\n tabIndex={0}\n role=\"group\"\n aria-label={i18nStrings.editorGroupAriaLabel}\n />\n </ResizableBox>\n <div role=\"group\" aria-label={i18nStrings.statusBarGroupAriaLabel}>\n <StatusBar\n languageLabel={languageLabel}\n cursorPosition={i18nStrings.cursorPosition(cursorPosition.row + 1, cursorPosition.column + 1)}\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={paneId}\n onPreferencesOpen={onPreferencesOpen}\n isRefresh={isRefresh}\n />\n <Pane\n id={paneId}\n visible={paneStatus !== 'hidden'}\n annotations={currentAnnotations}\n highlighted={highlightedAnnotation}\n onAnnotationClick={onAnnotationClick}\n onAnnotationClear={onAnnotationClear}\n onClose={onPaneClose}\n onAllowlist={shouldHandleFocus}\n cursorPositionLabel={i18nStrings.cursorPosition}\n closeButtonAriaLabel={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: i18nStrings.preferencesModalHeader,\n cancel: i18nStrings.preferencesModalCancel,\n confirm: i18nStrings.preferencesModalConfirm,\n wrapLines: i18nStrings.preferencesModalWrapLines,\n theme: i18nStrings.preferencesModalTheme,\n lightThemes: i18nStrings.preferencesModalLightThemes,\n darkThemes: i18nStrings.preferencesModalDarkThemes,\n }}\n />\n )}\n </>\n )}\n </div>\n );\n}\n\napplyDisplayName(CodeEditor, 'CodeEditor');\n"]}
|
|
@@ -15,8 +15,14 @@ export interface CodeEditorProps extends BaseComponentProps, FormFieldControlPro
|
|
|
15
15
|
value: string;
|
|
16
16
|
/**
|
|
17
17
|
* Specifies the programming language. You can use any of the programming languages supported by the `ace` object that you provide.
|
|
18
|
+
* Alternatively, this can be used to set a language that is not supported by the default `language` list. Make sure you've added the highlighting support for this language to the Ace instance.
|
|
19
|
+
* For more info on custom languages, see the [Code editor API](/components/code-editor?tabId=api) page.
|
|
18
20
|
*/
|
|
19
21
|
language: CodeEditorProps.Language;
|
|
22
|
+
/**
|
|
23
|
+
* Specifies a custom label language. If set, it overrides the default language label.
|
|
24
|
+
*/
|
|
25
|
+
languageLabel?: string;
|
|
20
26
|
/**
|
|
21
27
|
* An event handler called when the value changes.
|
|
22
28
|
* The event `detail` contains the current value of the code editor content.
|
|
@@ -88,8 +94,12 @@ export interface CodeEditorProps extends BaseComponentProps, FormFieldControlPro
|
|
|
88
94
|
*/
|
|
89
95
|
onEditorContentResize?: NonCancelableEventHandler<CodeEditorProps.ResizeDetail>;
|
|
90
96
|
}
|
|
97
|
+
declare type LiteralUnion<LiteralType, BaseType extends string> = LiteralType | (BaseType & {
|
|
98
|
+
_?: never;
|
|
99
|
+
});
|
|
100
|
+
declare type BuiltInLanguage = typeof AceModes[number]['value'];
|
|
91
101
|
export declare namespace CodeEditorProps {
|
|
92
|
-
type Language =
|
|
102
|
+
type Language = LiteralUnion<BuiltInLanguage, string>;
|
|
93
103
|
type Theme = typeof LightThemes[number]['value'] | typeof DarkThemes[number]['value'];
|
|
94
104
|
interface AvailableThemes {
|
|
95
105
|
light: ReadonlyArray<string>;
|
|
@@ -128,4 +138,5 @@ export declare namespace CodeEditorProps {
|
|
|
128
138
|
annotations: Ace.Annotation[];
|
|
129
139
|
}
|
|
130
140
|
}
|
|
141
|
+
export {};
|
|
131
142
|
//# sourceMappingURL=interfaces.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/code-editor/interfaces.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,wCAAwC,CAAC;AAE/E,MAAM,WAAW,eAAgB,SAAQ,kBAAkB,EAAE,qBAAqB;IAChF;;OAEG;IACH,GAAG,EAAE,GAAG,CAAC;IAET;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IA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,0BAA0B,EAAE,MAAM,CAAC;QACnC,wBAAwB,EAAE,MAAM,CAAC;QAEjC,sBAAsB,EAAE,MAAM,CAAC;QAC/B,sBAAsB,EAAE,MAAM,CAAC;QAC/B,uBAAuB,EAAE,MAAM,CAAC;QAChC,yBAAyB,EAAE,MAAM,CAAC;QAClC,qBAAqB,EAAE,MAAM,CAAC;QAC9B,2BAA2B,EAAE,MAAM,CAAC;QACpC,0BAA0B,EAAE,MAAM,CAAC;KACpC;IACD,UAAiB,YAAY;QAC3B,MAAM,EAAE,MAAM,CAAC;KAChB;IACD,UAAiB,YAAY;QAC3B,KAAK,EAAE,MAAM,CAAC;KACf;IAED,UAAiB,cAAc;QAC7B,WAAW,EAAE,GAAG,CAAC,UAAU,EAAE,CAAC;KAC/B;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/code-editor/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Ace } from 'ace-builds';\nimport { BaseComponentProps } from '../internal/base-component';\nimport { NonCancelableEventHandler } from '../internal/events';\nimport { AceModes } from './ace-modes';\nimport { DarkThemes, LightThemes } from './ace-themes';\nimport { FormFieldControlProps } from '../internal/context/form-field-context';\n\nexport interface CodeEditorProps extends BaseComponentProps, FormFieldControlProps {\n /**\n * The ace object.\n */\n ace: any;\n\n /**\n * Specifies the content that's displayed in the code editor.\n */\n value: string;\n\n /**\n * Specifies the programming language. You can use any of the programming languages supported by the `ace` object that you provide.\n */\n language: CodeEditorProps.Language;\n\n /**\n * An event handler called when the value changes.\n * The event `detail` contains the current value of the code editor content.\n * **Deprecated**, replaced by `onDelayedChange`.\n */\n onChange?: NonCancelableEventHandler<CodeEditorProps.ChangeDetail>;\n\n /**\n * An event handler called when the value changes.\n * The event `detail` contains the current value of the code editor content.\n * A user interaction can cause multiple change events to be emitted by the Ace editor. They are batched together into a single `onDelayedChange` event to avoid bugs when controlling the `value` field.\n */\n onDelayedChange?: NonCancelableEventHandler<CodeEditorProps.ChangeDetail>;\n\n /**\n * Annotations returned from Ace syntax checker after code validation.\n */\n onValidate?: NonCancelableEventHandler<CodeEditorProps.ValidateDetail>;\n\n /**\n * Specifies the component preferences.\n *\n * If set to `undefined`, the component uses the following default value:\n *\n * ```\n * {\n * wrapLines: true,\n * theme: 'dawn'\n * }\n * ```\n *\n * You can use any theme provided by Ace.\n */\n preferences?: Partial<CodeEditorProps.Preferences>;\n\n /**\n * List of Ace themes available for selection in preferences dialog. Make sure you include at least one light and at\n * least one dark theme. If not set explicitly, it will render all Ace themes available for selection.\n */\n themes?: CodeEditorProps.AvailableThemes;\n\n /**\n * Called when any of the preferences change.\n * The event `detail` contains the value of all the preferences as submitted by the user.\n *\n */\n onPreferencesChange: NonCancelableEventHandler<CodeEditorProps.Preferences>;\n\n /**\n * Renders the code editor in a loading state.\n */\n loading?: boolean;\n\n /**\n * Called when the user clicks the recovery button in the error state.\n * Use this to retry loading the code editor or to provide another option for the user to recover from the error.\n */\n onRecoveryClick?: NonCancelableEventHandler<void>;\n\n /**\n * An object containing all the necessary localized strings required by the component.\n * The object should contain, among others:\n *\n * * `loadingState` - Specifies the text to display while the component is loading.\n * * `errorState` - Specifies the text to display if there is an error loading Ace.\n * * `errorStateRecovery`: Specifies the text for the recovery button that's displayed next to the error text.\n * Use the `recoveryClick` event to do a recovery action (for example, retrying the request).\n */\n i18nStrings: CodeEditorProps.I18nStrings;\n\n /**\n * Specifies the height of the code editor document.\n */\n editorContentHeight?: number;\n\n /**\n * Called when the user resizes the editor by dragging the resize icon.\n * The event `detail` contains the new height of the editor in pixels.\n */\n onEditorContentResize?: NonCancelableEventHandler<CodeEditorProps.ResizeDetail>;\n}\n\
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/code-editor/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Ace } from 'ace-builds';\nimport { BaseComponentProps } from '../internal/base-component';\nimport { NonCancelableEventHandler } from '../internal/events';\nimport { AceModes } from './ace-modes';\nimport { DarkThemes, LightThemes } from './ace-themes';\nimport { FormFieldControlProps } from '../internal/context/form-field-context';\n\nexport interface CodeEditorProps extends BaseComponentProps, FormFieldControlProps {\n /**\n * The ace object.\n */\n ace: any;\n\n /**\n * Specifies the content that's displayed in the code editor.\n */\n value: string;\n\n /**\n * Specifies the programming language. You can use any of the programming languages supported by the `ace` object that you provide.\n * Alternatively, this can be used to set a language that is not supported by the default `language` list. Make sure you've added the highlighting support for this language to the Ace instance.\n * For more info on custom languages, see the [Code editor API](/components/code-editor?tabId=api) page.\n */\n language: CodeEditorProps.Language;\n\n /**\n * Specifies a custom label language. If set, it overrides the default language label.\n */\n languageLabel?: string;\n\n /**\n * An event handler called when the value changes.\n * The event `detail` contains the current value of the code editor content.\n * **Deprecated**, replaced by `onDelayedChange`.\n */\n onChange?: NonCancelableEventHandler<CodeEditorProps.ChangeDetail>;\n\n /**\n * An event handler called when the value changes.\n * The event `detail` contains the current value of the code editor content.\n * A user interaction can cause multiple change events to be emitted by the Ace editor. They are batched together into a single `onDelayedChange` event to avoid bugs when controlling the `value` field.\n */\n onDelayedChange?: NonCancelableEventHandler<CodeEditorProps.ChangeDetail>;\n\n /**\n * Annotations returned from Ace syntax checker after code validation.\n */\n onValidate?: NonCancelableEventHandler<CodeEditorProps.ValidateDetail>;\n\n /**\n * Specifies the component preferences.\n *\n * If set to `undefined`, the component uses the following default value:\n *\n * ```\n * {\n * wrapLines: true,\n * theme: 'dawn'\n * }\n * ```\n *\n * You can use any theme provided by Ace.\n */\n preferences?: Partial<CodeEditorProps.Preferences>;\n\n /**\n * List of Ace themes available for selection in preferences dialog. Make sure you include at least one light and at\n * least one dark theme. If not set explicitly, it will render all Ace themes available for selection.\n */\n themes?: CodeEditorProps.AvailableThemes;\n\n /**\n * Called when any of the preferences change.\n * The event `detail` contains the value of all the preferences as submitted by the user.\n *\n */\n onPreferencesChange: NonCancelableEventHandler<CodeEditorProps.Preferences>;\n\n /**\n * Renders the code editor in a loading state.\n */\n loading?: boolean;\n\n /**\n * Called when the user clicks the recovery button in the error state.\n * Use this to retry loading the code editor or to provide another option for the user to recover from the error.\n */\n onRecoveryClick?: NonCancelableEventHandler<void>;\n\n /**\n * An object containing all the necessary localized strings required by the component.\n * The object should contain, among others:\n *\n * * `loadingState` - Specifies the text to display while the component is loading.\n * * `errorState` - Specifies the text to display if there is an error loading Ace.\n * * `errorStateRecovery`: Specifies the text for the recovery button that's displayed next to the error text.\n * Use the `recoveryClick` event to do a recovery action (for example, retrying the request).\n */\n i18nStrings: CodeEditorProps.I18nStrings;\n\n /**\n * Specifies the height of the code editor document.\n */\n editorContentHeight?: number;\n\n /**\n * Called when the user resizes the editor by dragging the resize icon.\n * The event `detail` contains the new height of the editor in pixels.\n */\n onEditorContentResize?: NonCancelableEventHandler<CodeEditorProps.ResizeDetail>;\n}\n\n// Prevents typescript from collapsing a string union type into a string type while still allowing any string.\n// This leads to more helpful editor suggestions for known values.\n// See: https://github.com/microsoft/TypeScript/issues/29729\ntype LiteralUnion<LiteralType, BaseType extends string> = LiteralType | (BaseType & { _?: never });\n\ntype BuiltInLanguage = typeof AceModes[number]['value'];\n\nexport namespace CodeEditorProps {\n export type Language = LiteralUnion<BuiltInLanguage, string>;\n export type Theme = typeof LightThemes[number]['value'] | typeof DarkThemes[number]['value'];\n\n export interface AvailableThemes {\n light: ReadonlyArray<string>;\n dark: ReadonlyArray<string>;\n }\n\n export interface Preferences {\n wrapLines: boolean;\n theme: Theme;\n }\n\n export interface I18nStrings {\n loadingState: string;\n errorState: string;\n errorStateRecovery: string;\n\n editorGroupAriaLabel: string;\n statusBarGroupAriaLabel: string;\n\n cursorPosition: (row: number, column: number) => string;\n errorsTab: string;\n warningsTab: string;\n preferencesButtonAriaLabel: string;\n paneCloseButtonAriaLabel: string;\n\n preferencesModalHeader: string;\n preferencesModalCancel: string;\n preferencesModalConfirm: string;\n preferencesModalWrapLines: string;\n preferencesModalTheme: string;\n preferencesModalLightThemes: string;\n preferencesModalDarkThemes: string;\n }\n export interface ResizeDetail {\n height: number;\n }\n export interface ChangeDetail {\n value: string;\n }\n\n export interface ValidateDetail {\n annotations: Ace.Annotation[];\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"status-bar.d.ts","sourceRoot":"","sources":["../../../src/code-editor/status-bar.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"status-bar.d.ts","sourceRoot":"","sources":["../../../src/code-editor/status-bar.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAO1B,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,UAAU,cAAc;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,KAAK,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC;IACjD,cAAc,EAAE,KAAK,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC;IACnD,YAAY,EAAE,OAAO,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,eAAe,CAAC,WAAW,CAAC;IACzC,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,OAAO,CAAC;IAEnB,iBAAiB,EAAE,MAAM,IAAI,CAAC;IAC9B,mBAAmB,EAAE,MAAM,IAAI,CAAC;IAChC,UAAU,CAAC,EAAE,KAAK,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,CAAC;IACxD,SAAS,CAAC,EAAE,KAAK,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,CAAC;IACvD,iBAAiB,EAAE,MAAM,IAAI,CAAC;IAC9B,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;CAClD;AA+GD,eAAO,MAAM,SAAS,UAAW,cAAc,gBAc9C,CAAC"}
|
|
@@ -4,6 +4,7 @@ import { __assign } from "tslib";
|
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import clsx from 'clsx';
|
|
6
6
|
import styles from './styles.css.js';
|
|
7
|
+
import LiveRegion from '../internal/components/live-region/index';
|
|
7
8
|
import { TabButton } from './tab-button';
|
|
8
9
|
import { InternalButton } from '../button/internal';
|
|
9
10
|
import { useContainerQuery } from '../internal/hooks/container-queries/use-container-query';
|
|
@@ -25,7 +26,12 @@ function InternalStatusBar(_a) {
|
|
|
25
26
|
React.createElement("div", { role: "tablist" },
|
|
26
27
|
React.createElement(TabButton, { text: minifyCounters ? " ".concat(errorCount) : errorText, className: styles['tab-button--errors'], iconName: "status-negative", disabled: errorCount === 0 || isVirtual, active: paneStatus === 'error', onClick: onErrorPaneToggle, onFocus: onTabFocus, onBlur: onTabBlur, ref: errorsTabRef, ariaLabel: errorText, paneId: paneId, isRefresh: isRefresh }),
|
|
27
28
|
React.createElement("span", { className: styles['tab-button--divider'] }),
|
|
28
|
-
React.createElement(TabButton, { text: minifyCounters ? " ".concat(warningCount) : warningText, className: styles['tab-button--warnings'], iconName: "status-warning", disabled: warningCount === 0 || isVirtual, active: paneStatus === 'warning', onClick: onWarningPaneToggle, onFocus: onTabFocus, onBlur: onTabBlur, ref: warningsTabRef, tabIndex: paneStatus === 'error' && isTabFocused ? -1 : undefined, ariaHidden: paneStatus === 'error' && isTabFocused ? true : undefined, ariaLabel: warningText, paneId: paneId, isRefresh: isRefresh }))
|
|
29
|
+
React.createElement(TabButton, { text: minifyCounters ? " ".concat(warningCount) : warningText, className: styles['tab-button--warnings'], iconName: "status-warning", disabled: warningCount === 0 || isVirtual, active: paneStatus === 'warning', onClick: onWarningPaneToggle, onFocus: onTabFocus, onBlur: onTabBlur, ref: warningsTabRef, tabIndex: paneStatus === 'error' && isTabFocused ? -1 : undefined, ariaHidden: paneStatus === 'error' && isTabFocused ? true : undefined, ariaLabel: warningText, paneId: paneId, isRefresh: isRefresh })),
|
|
30
|
+
React.createElement(LiveRegion, { assertive: true },
|
|
31
|
+
React.createElement("span", null,
|
|
32
|
+
errorText,
|
|
33
|
+
" "),
|
|
34
|
+
React.createElement("span", null, warningText))),
|
|
29
35
|
React.createElement("div", { className: styles['status-bar__right'] },
|
|
30
36
|
React.createElement("div", { className: styles['status-bar__cog-button'] },
|
|
31
37
|
React.createElement(InternalButton, { disabled: isVirtual, formAction: "none", variant: "icon", iconName: "settings", iconAlt: "Settings", ariaLabel: i18nStrings.preferencesButtonAriaLabel, onClick: onPreferencesOpen, __nativeAttributes: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"status-bar.js","sourceRoot":"","sources":["../../../src/code-editor/status-bar.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yDAAyD,CAAC;AA8B5F,SAAS,iBAAiB,CAAC,EAoBF;;QAnBvB,aAAa,mBAAA,EACb,cAAc,oBAAA,EACd,UAAU,gBAAA,EACV,iBAAiB,uBAAA,EACjB,mBAAmB,yBAAA,EACnB,UAAU,gBAAA,EACV,SAAS,eAAA,EACT,YAAY,kBAAA,EACZ,cAAc,oBAAA,EACd,YAAY,kBAAA,EACZ,MAAM,YAAA,EACN,iBAAiB,uBAAA,EACjB,WAAW,iBAAA,EACX,UAAU,g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AE,WAAW,CAAC,0BAA0B,EACjD,OAAO,EAAE,iBAAiB,EAC1B,kBAAkB,EAAE;wBAClB,QAAQ,EAAE,UAAU,KAAK,QAAQ,IAAI,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS;wBAClE,aAAa,EAAE,UAAU,KAAK,QAAQ,IAAI,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;qBAC1E,GACD,CACE,CACF,CACF,CACP,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,IAAM,SAAS,GAAG,UAAC,KAAqB;IAC7C,yFAAyF;IACzF,oDAAoD;IAC9C,IAAA,KAAgC,iBAAiB,CAAC,UAAA,IAAI,IAAI,OAAA,IAAI,CAAC,KAAK,EAAV,CAAU,CAAC,EAApE,SAAS,QAAA,EAAE,gBAAgB,QAAyC,CAAC;IACtE,IAAA,KAA0C,iBAAiB,CAAC,UAAA,IAAI,IAAI,OAAA,IAAI,CAAC,KAAK,EAAV,CAAU,CAAC,EAA9E,YAAY,QAAA,EAAE,uBAAuB,QAAyC,CAAC;IAEtF,IAAM,cAAc,GAAG,YAAY,KAAK,IAAI,IAAI,SAAS,KAAK,IAAI,IAAI,YAAY,GAAG,SAAS,CAAC;IAE/F,OAAO,CACL;QACE,oBAAC,iBAAiB,aAAC,SAAS,EAAE,KAAK,IAAM,KAAK,IAAE,UAAU,EAAE,gBAAgB,EAAE,cAAc,EAAE,cAAc,IAAI;QAChH,oBAAC,iBAAiB,aAAC,SAAS,EAAE,IAAI,IAAM,KAAK,IAAE,UAAU,EAAE,uBAAuB,EAAE,cAAc,EAAE,KAAK,IAAI,CAC5G,CACJ,CAAC;AACJ,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\nimport clsx from 'clsx';\nimport styles from './styles.css.js';\nimport LiveRegion from '../internal/components/live-region/index';\nimport { TabButton } from './tab-button';\nimport { InternalButton } from '../button/internal';\nimport { useContainerQuery } from '../internal/hooks/container-queries/use-container-query';\nimport { CodeEditorProps } from './interfaces';\n\ninterface StatusBarProps {\n languageLabel: string;\n cursorPosition: string;\n paneStatus: string;\n errorsTabRef: React.RefObject<HTMLButtonElement>;\n warningsTabRef: React.RefObject<HTMLButtonElement>;\n isTabFocused: boolean;\n paneId: string;\n i18nStrings: CodeEditorProps.I18nStrings;\n errorCount: number;\n warningCount: number;\n isRefresh: boolean;\n\n onErrorPaneToggle: () => void;\n onWarningPaneToggle: () => void;\n onTabFocus?: React.FocusEventHandler<HTMLButtonElement>;\n onTabBlur?: React.FocusEventHandler<HTMLButtonElement>;\n onPreferencesOpen: () => void;\n onHeightChange?: (height: number | null) => void;\n}\n\ntype InternalStatusBarProps = StatusBarProps & {\n leftBarRef: React.Ref<HTMLDivElement>;\n isVirtual: boolean;\n minifyCounters: boolean;\n};\n\nfunction InternalStatusBar({\n languageLabel,\n cursorPosition,\n paneStatus,\n onErrorPaneToggle,\n onWarningPaneToggle,\n onTabFocus,\n onTabBlur,\n errorsTabRef,\n warningsTabRef,\n isTabFocused,\n paneId,\n onPreferencesOpen,\n i18nStrings,\n errorCount,\n warningCount,\n leftBarRef,\n isVirtual,\n minifyCounters,\n isRefresh,\n}: InternalStatusBarProps) {\n const errorText = `${i18nStrings.errorsTab}: ${errorCount}`;\n const warningText = `${i18nStrings.warningsTab}: ${warningCount}`;\n\n // Virtual status bar is inaccessible for screen readers and keyboard interactions.\n\n return (\n <div\n className={clsx(styles['status-bar'], {\n [styles['status-bar-with-hidden-pane']]: paneStatus === 'hidden',\n [styles['status-bar-virtual']]: isVirtual,\n })}\n aria-hidden={isVirtual}\n >\n <div\n className={clsx(styles['status-bar__left'], {\n [styles['status-bar__left-virtual']]: isVirtual,\n })}\n ref={leftBarRef}\n >\n <span className={styles['status-bar__language-mode']}>{languageLabel}</span>\n <span className={styles['status-bar__cursor-position']}>{cursorPosition}</span>\n\n <div role=\"tablist\">\n <TabButton\n text={minifyCounters ? ` ${errorCount}` : errorText}\n className={styles['tab-button--errors']}\n iconName=\"status-negative\"\n disabled={errorCount === 0 || isVirtual}\n active={paneStatus === 'error'}\n onClick={onErrorPaneToggle}\n onFocus={onTabFocus}\n onBlur={onTabBlur}\n ref={errorsTabRef}\n ariaLabel={errorText}\n paneId={paneId}\n isRefresh={isRefresh}\n />\n <span className={styles['tab-button--divider']}></span>\n <TabButton\n text={minifyCounters ? ` ${warningCount}` : warningText}\n className={styles['tab-button--warnings']}\n iconName=\"status-warning\"\n disabled={warningCount === 0 || isVirtual}\n active={paneStatus === 'warning'}\n onClick={onWarningPaneToggle}\n onFocus={onTabFocus}\n onBlur={onTabBlur}\n ref={warningsTabRef}\n tabIndex={paneStatus === 'error' && isTabFocused ? -1 : undefined}\n ariaHidden={paneStatus === 'error' && isTabFocused ? true : undefined}\n ariaLabel={warningText}\n paneId={paneId}\n isRefresh={isRefresh}\n />\n </div>\n <LiveRegion assertive={true}>\n <span>{errorText} </span>\n <span>{warningText}</span>\n </LiveRegion>\n </div>\n\n <div className={styles['status-bar__right']}>\n <div className={styles['status-bar__cog-button']}>\n <InternalButton\n disabled={isVirtual}\n formAction=\"none\"\n variant=\"icon\"\n iconName=\"settings\"\n iconAlt=\"Settings\"\n ariaLabel={i18nStrings.preferencesButtonAriaLabel}\n onClick={onPreferencesOpen}\n __nativeAttributes={{\n tabIndex: paneStatus !== 'hidden' && isTabFocused ? -1 : undefined,\n 'aria-hidden': paneStatus !== 'hidden' && isTabFocused ? true : undefined,\n }}\n />\n </div>\n </div>\n </div>\n );\n}\n\nexport const StatusBar = (props: StatusBarProps) => {\n // create a virtual status bar, in order to calculate the width with full tab button text\n // and decide if tab button text needs to be reduced\n const [realWidth, statusLeftBarRef] = useContainerQuery(rect => rect.width);\n const [virtualWidth, virtualStatusLeftBarRef] = useContainerQuery(rect => rect.width);\n\n const minifyCounters = virtualWidth !== null && realWidth !== null && virtualWidth > realWidth;\n\n return (\n <>\n <InternalStatusBar isVirtual={false} {...props} leftBarRef={statusLeftBarRef} minifyCounters={minifyCounters} />\n <InternalStatusBar isVirtual={true} {...props} leftBarRef={virtualStatusLeftBarRef} minifyCounters={false} />\n </>\n );\n};\n"]}
|
package/code-editor/util.js
CHANGED
|
@@ -16,6 +16,6 @@ export function getAceTheme(theme) {
|
|
|
16
16
|
}
|
|
17
17
|
export function getLanguageLabel(language) {
|
|
18
18
|
var _a;
|
|
19
|
-
return ((_a = AceModes.filter(function (mode) { return mode.value === language; })[0]) === null || _a === void 0 ? void 0 : _a.label) ||
|
|
19
|
+
return ((_a = AceModes.filter(function (mode) { return mode.value === language; })[0]) === null || _a === void 0 ? void 0 : _a.label) || language;
|
|
20
20
|
}
|
|
21
21
|
//# sourceMappingURL=util.js.map
|
package/code-editor/util.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../../src/code-editor/util.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAGvC,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAIpD,MAAM,CAAC,IAAM,mBAAmB,GAAwC,MAAM,CAAC;AAC/E,MAAM,CAAC,IAAM,kBAAkB,GAAuC,uBAAuB,CAAC;AAE9F,MAAM,UAAU,gBAAgB;IAC9B,OAAO;QACL,iBAAiB,EAAE,IAAI;KACxB,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,OAAoB;IAClD,IAAM,UAAU,GAAG,CAAC,CAAC,WAAW,CAC9B,OAAO,EACP,UAAA,IAAI,IAAI,OAAA,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,yBAAyB,CAAC,IAAI,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,iBAAiB,CAAC,EAAhG,CAAgG,CACzG,CAAC;IACF,OAAO,UAAU,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC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AAK,OAAA,IAAI,CAAC,KAAK,KAAK,QAAQ,EAAvB,CAAuB,CAAC,CAAC,CAAC,CAAC,0CAAE,KAAK,KAAI,QAAQ,CAAC;AACrG,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Ace } from 'ace-builds';\n\nimport { AceModes } from './ace-modes';\nimport { LightThemes, DarkThemes } from './ace-themes';\nimport { CodeEditorProps } from './interfaces';\nimport { findUpUntil } from '../internal/utils/dom';\n\nexport type PaneStatus = 'error' | 'warning' | 'hidden';\n\nexport const DEFAULT_LIGHT_THEME: typeof LightThemes[number]['value'] = 'dawn';\nexport const DEFAULT_DARK_THEME: typeof DarkThemes[number]['value'] = 'tomorrow_night_bright';\n\nexport function getDefaultConfig(): Partial<Ace.EditorOptions> {\n return {\n behavioursEnabled: true,\n };\n}\n\nexport function getDefaultTheme(element: HTMLElement): CodeEditorProps.Theme {\n const isDarkMode = !!findUpUntil(\n element,\n node => node.classList.contains('awsui-polaris-dark-mode') || node.classList.contains('awsui-dark-mode')\n );\n return isDarkMode ? DEFAULT_DARK_THEME : DEFAULT_LIGHT_THEME;\n}\n\nexport function getAceTheme(theme: CodeEditorProps.Theme) {\n return `ace/theme/${theme}`;\n}\n\nexport function getLanguageLabel(language: CodeEditorProps.Language): string {\n return AceModes.filter((mode: { value: string }) => mode.value === language)[0]?.label || language;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/container/internal.tsx"],"names":[],"mappings":"AAGA,OAAO,
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/container/internal.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAwC,MAAM,OAAO,CAAC;AAE7D,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAOlF,MAAM,WAAW,sBAAuB,SAAQ,IAAI,CAAC,cAAc,EAAE,SAAS,CAAC,EAAE,0BAA0B;IACzG,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAC9C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,cAAc,CAAC,SAAS,CAAC,GAAG,UAAU,GAAG,WAAW,GAAG,OAAO,CAAC;CAC1E;AAED,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,EACxC,MAAM,EACN,MAAM,EACN,QAAQ,EACR,OAAmB,EACnB,qBAA6B,EAC7B,sBAA8B,EAC9B,cAAc,EACd,cAAsB,EACtB,iBAAwB,EACxB,sBAA8B,EAC9B,uBAA+B,EAC/B,eAAuB,EACvB,WAAW,EACX,UAAU,EACV,YAAoB,EACpB,GAAG,SAAS,EACb,EAAE,sBAAsB,eAoFxB"}
|
package/container/internal.js
CHANGED
|
@@ -2,7 +2,7 @@ import { __assign, __rest } from "tslib";
|
|
|
2
2
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
import clsx from 'clsx';
|
|
5
|
-
import React, { useContext,
|
|
5
|
+
import React, { useContext, useEffect, useRef } from 'react';
|
|
6
6
|
import { AppLayoutContext } from '../app-layout/visual-refresh/context';
|
|
7
7
|
import { getBaseProps } from '../internal/base-component';
|
|
8
8
|
import { StickyHeaderContext, useStickyHeader } from './use-sticky-header';
|
|
@@ -29,12 +29,15 @@ export default function InternalContainer(_a) {
|
|
|
29
29
|
* has a high constrast sticky header. This is to make sure the background element
|
|
30
30
|
* stays in the same vertical position as the header content.
|
|
31
31
|
*/
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
useEffect(function handleHasStickyBackground() {
|
|
33
|
+
var shouldUpdateStickyBackground = isRefresh && isSticky && variant === 'full-page';
|
|
34
|
+
if (shouldUpdateStickyBackground) {
|
|
34
35
|
setHasStickyBackground(true);
|
|
35
36
|
}
|
|
36
37
|
return function cleanup() {
|
|
37
|
-
|
|
38
|
+
if (shouldUpdateStickyBackground) {
|
|
39
|
+
setHasStickyBackground(false);
|
|
40
|
+
}
|
|
38
41
|
};
|
|
39
42
|
}, [isRefresh, isSticky, setHasStickyBackground, variant]);
|
|
40
43
|
return (React.createElement("div", __assign({}, baseProps, { className: clsx(baseProps.className, styles.root, styles["variant-".concat(variant)]), ref: mergedRef }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/container/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/container/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAExE,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE1D,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,wDAAwD,CAAC;AAC3F,OAAO,EAAE,YAAY,EAAE,MAAM,k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uBAAuB,CAAC,IAAG,QAAQ;oBAC3C,GAAC,MAAM,CAAC,uBAAuB,CAAC,IAAG,gBAAgB;oBACnD,GAAC,MAAM,CAAC,cAAc,CAAC,IAAG,OAAO;oBACjC,GAAC,MAAM,CAAC,eAAe,CAAC,IAAG,CAAC,qBAAqB;oBACjD,GAAC,MAAM,CAAC,qBAAqB,CAAC,IAAG,eAAe;wBAChD,IACE,YAAY,EACZ,YAAY,IAChB,GAAG,EAAE,eAAe,KAEnB,YAAY,CAAC,CAAC,CAAC,CACd,6BAAK,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,8BAA8B,CAAC,IAAG,MAAM,CAAO,CAC5F,CAAC,CAAC,CAAC,CACF,MAAM,CACP,CACG,CACuB,CAChC;QACD,6BACE,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO;gBAC5B,GAAC,MAAM,CAAC,eAAe,CAAC,IAAG,CAAC,sBAAsB;oBAClD,IAED,QAAQ,CACL;QACL,MAAM,IAAI,CACT,6BACE,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM;gBAC3B,GAAC,MAAM,CAAC,cAAc,CAAC,IAAG,CAAC,sBAAsB;gBACjD,GAAC,MAAM,CAAC,eAAe,CAAC,IAAG,CAAC,uBAAuB;oBACnD,IAED,MAAM,CACH,CACP,CACG,CACP,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport clsx from 'clsx';\nimport React, { useContext, useEffect, useRef } from 'react';\nimport { AppLayoutContext } from '../app-layout/visual-refresh/context';\nimport { ContainerProps } from './interfaces';\nimport { getBaseProps } from '../internal/base-component';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport { StickyHeaderContext, useStickyHeader } from './use-sticky-header';\nimport { useDynamicOverlap } from '../app-layout/visual-refresh/hooks/use-dynamic-overlap';\nimport { useMergeRefs } from '../internal/hooks/use-merge-refs';\nimport { useVisualRefresh } from '../internal/hooks/use-visual-mode';\nimport styles from './styles.css.js';\n\nexport interface InternalContainerProps extends Omit<ContainerProps, 'variant'>, InternalBaseComponentProps {\n __stickyHeader?: boolean;\n __stickyOffset?: number;\n __disableFooterDivider?: boolean;\n __disableFooterPaddings?: boolean;\n __hiddenContent?: boolean;\n __headerRef?: React.RefObject<HTMLDivElement>;\n __headerId?: string;\n __darkHeader?: boolean;\n /**\n * Additional internal variant:\n * * `embedded` - Use this variant within a parent container (such as a modal,\n * expandable section, container or split panel).\n * * `full-page` – Only for internal use in table, cards and other components\n */\n variant?: ContainerProps['variant'] | 'embedded' | 'full-page' | 'cards';\n}\n\nexport default function InternalContainer({\n header,\n footer,\n children,\n variant = 'default',\n disableHeaderPaddings = false,\n disableContentPaddings = false,\n __stickyOffset,\n __stickyHeader = false,\n __internalRootRef = null,\n __disableFooterDivider = false,\n __disableFooterPaddings = false,\n __hiddenContent = false,\n __headerRef,\n __headerId,\n __darkHeader = false,\n ...restProps\n}: InternalContainerProps) {\n const baseProps = getBaseProps(restProps);\n const rootRef = useRef<HTMLDivElement>(null);\n const headerRef = useRef<HTMLDivElement>(null);\n const { isSticky, isStuck, stickyStyles } = useStickyHeader(rootRef, headerRef, __stickyHeader, __stickyOffset);\n const { setHasStickyBackground } = useContext(AppLayoutContext);\n const isRefresh = useVisualRefresh();\n\n const hasDynamicHeight = isRefresh && variant === 'full-page';\n const overlapElement = useDynamicOverlap({ disabled: !hasDynamicHeight || !__darkHeader });\n\n const mergedRef = useMergeRefs(rootRef, __internalRootRef);\n const headerMergedRef = useMergeRefs(headerRef, overlapElement, __headerRef);\n const headerIdProp = __headerId ? { id: __headerId } : {};\n\n /**\n * The visual refresh AppLayout component needs to know if a child component\n * has a high constrast sticky header. This is to make sure the background element\n * stays in the same vertical position as the header content.\n */\n useEffect(\n function handleHasStickyBackground() {\n const shouldUpdateStickyBackground = isRefresh && isSticky && variant === 'full-page';\n if (shouldUpdateStickyBackground) {\n setHasStickyBackground(true);\n }\n\n return function cleanup() {\n if (shouldUpdateStickyBackground) {\n setHasStickyBackground(false);\n }\n };\n },\n [isRefresh, isSticky, setHasStickyBackground, variant]\n );\n\n return (\n <div\n {...baseProps}\n className={clsx(baseProps.className, styles.root, styles[`variant-${variant}`])}\n ref={mergedRef}\n >\n {header && (\n <StickyHeaderContext.Provider value={{ isStuck }}>\n <div\n className={clsx(styles.header, styles[`header-variant-${variant}`], {\n [styles['header-sticky-disabled']]: __stickyHeader && !isSticky,\n [styles['header-sticky-enabled']]: isSticky,\n [styles['header-dynamic-height']]: hasDynamicHeight,\n [styles['header-stuck']]: isStuck,\n [styles['with-paddings']]: !disableHeaderPaddings,\n [styles['with-hidden-content']]: __hiddenContent,\n })}\n {...headerIdProp}\n {...stickyStyles}\n ref={headerMergedRef}\n >\n {__darkHeader ? (\n <div className={clsx(styles['dark-header'], 'awsui-context-content-header')}>{header}</div>\n ) : (\n header\n )}\n </div>\n </StickyHeaderContext.Provider>\n )}\n <div\n className={clsx(styles.content, {\n [styles['with-paddings']]: !disableContentPaddings,\n })}\n >\n {children}\n </div>\n {footer && (\n <div\n className={clsx(styles.footer, {\n [styles['with-divider']]: !__disableFooterDivider,\n [styles['with-paddings']]: !__disableFooterPaddings,\n })}\n >\n {footer}\n </div>\n )}\n </div>\n );\n}\n"]}
|
|
@@ -15,6 +15,5 @@ export interface GridProps {
|
|
|
15
15
|
todayAriaLabel: string;
|
|
16
16
|
headingIdPrefix: string;
|
|
17
17
|
}
|
|
18
|
-
export declare function selectFocusedDate(selected: Date | null, baseDate: Date, isDateEnabled: DateRangePickerProps.IsDateEnabledFunction): Date | null;
|
|
19
18
|
export declare const Grids: ({ baseDate, selectedStartDate, selectedEndDate, focusedDate, onFocusedDateChange, isDateEnabled, isSingleGrid, onSelectDate, onChangeMonth, locale, startOfWeek, todayAriaLabel, headingIdPrefix, }: GridProps) => JSX.Element;
|
|
20
19
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/date-range-picker/calendar/grids/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAI3D,OAAO,EAAE,oBAAoB,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/date-range-picker/calendar/grids/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAI3D,OAAO,EAAE,oBAAoB,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAqBlE,MAAM,WAAW,SAAS;IACxB,QAAQ,EAAE,IAAI,CAAC;IACf,iBAAiB,EAAE,IAAI,GAAG,IAAI,CAAC;IAC/B,eAAe,EAAE,IAAI,GAAG,IAAI,CAAC;IAE7B,WAAW,EAAE,IAAI,GAAG,IAAI,CAAC;IACzB,mBAAmB,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC;IAEvE,aAAa,EAAE,oBAAoB,CAAC,qBAAqB,CAAC;IAC1D,YAAY,EAAE,OAAO,CAAC;IAEtB,YAAY,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IACnC,aAAa,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IAEpC,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,QAAQ,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,eAAO,MAAM,KAAK,wMAkBf,SAAS,gBAyJX,CAAC"}
|
|
@@ -10,6 +10,7 @@ import useFocusVisible from '../../../internal/hooks/focus-visible/index';
|
|
|
10
10
|
import { hasValue } from '../../../internal/utils/has-value';
|
|
11
11
|
import { useDateCache } from '../../../internal/hooks/use-date-cache';
|
|
12
12
|
import { moveNextDay, movePrevDay, moveNextWeek, movePrevWeek, getBaseDate } from '../../../calendar/utils/navigation';
|
|
13
|
+
import { findDateToFocus } from '../utils';
|
|
13
14
|
function isVisible(date, baseDate, isSingleGrid) {
|
|
14
15
|
if (isSingleGrid) {
|
|
15
16
|
return isSameMonth(date, baseDate);
|
|
@@ -17,19 +18,6 @@ function isVisible(date, baseDate, isSingleGrid) {
|
|
|
17
18
|
var previousMonth = addMonths(baseDate, -1);
|
|
18
19
|
return isSameMonth(date, previousMonth) || isSameMonth(date, baseDate);
|
|
19
20
|
}
|
|
20
|
-
export function selectFocusedDate(selected, baseDate, isDateEnabled) {
|
|
21
|
-
if (selected && isDateEnabled(selected) && isSameMonth(selected, baseDate)) {
|
|
22
|
-
return selected;
|
|
23
|
-
}
|
|
24
|
-
var today = new Date();
|
|
25
|
-
if (isDateEnabled(today) && isSameMonth(today, baseDate)) {
|
|
26
|
-
return today;
|
|
27
|
-
}
|
|
28
|
-
if (isDateEnabled(baseDate)) {
|
|
29
|
-
return baseDate;
|
|
30
|
-
}
|
|
31
|
-
return null;
|
|
32
|
-
}
|
|
33
21
|
export var Grids = function (_a) {
|
|
34
22
|
var baseDate = _a.baseDate, selectedStartDate = _a.selectedStartDate, selectedEndDate = _a.selectedEndDate, focusedDate = _a.focusedDate, onFocusedDateChange = _a.onFocusedDateChange, isDateEnabled = _a.isDateEnabled, isSingleGrid = _a.isSingleGrid, onSelectDate = _a.onSelectDate, onChangeMonth = _a.onChangeMonth, locale = _a.locale, startOfWeek = _a.startOfWeek, todayAriaLabel = _a.todayAriaLabel, headingIdPrefix = _a.headingIdPrefix;
|
|
35
23
|
var containerRef = useRef(null);
|
|
@@ -43,7 +31,7 @@ export var Grids = function (_a) {
|
|
|
43
31
|
var direction = isAfter(focusedDate, baseDate) ? -1 : 1;
|
|
44
32
|
var newMonth = !isSingleGrid && direction === -1 ? addMonths(baseDate, -1) : baseDate;
|
|
45
33
|
var nearestBaseDate = getBaseDate(newMonth, isDateEnabled);
|
|
46
|
-
var newFocusedDate =
|
|
34
|
+
var newFocusedDate = findDateToFocus(focusedDate, nearestBaseDate, isDateEnabled);
|
|
47
35
|
onFocusedDateChange(newFocusedDate);
|
|
48
36
|
}
|
|
49
37
|
}, [baseDate, focusedDate, isSingleGrid, isDateEnabled, onFocusedDateChange]);
|