@cloudscape-design/components-themeable 3.0.165 → 3.0.167
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/lib/internal/manifest.json +1 -1
- package/lib/internal/scss/code-editor/resizable-box/styles.scss +37 -0
- package/lib/internal/scss/code-editor/styles.scss +1 -29
- package/lib/internal/scss/select/parts/styles.scss +9 -0
- package/lib/internal/scss/table/body-cell/styles.scss +131 -29
- package/lib/internal/scss/table/header-cell/styles.scss +15 -7
- package/lib/internal/template/button/internal.d.ts +1 -0
- package/lib/internal/template/button/internal.d.ts.map +1 -1
- package/lib/internal/template/button/internal.js +2 -2
- package/lib/internal/template/button/internal.js.map +1 -1
- package/lib/internal/template/code-editor/index.d.ts.map +1 -1
- package/lib/internal/template/code-editor/index.js +5 -8
- package/lib/internal/template/code-editor/index.js.map +1 -1
- package/lib/internal/template/code-editor/pane.d.ts.map +1 -1
- package/lib/internal/template/code-editor/pane.js +4 -4
- package/lib/internal/template/code-editor/pane.js.map +1 -1
- package/lib/internal/template/code-editor/resizable-box/index.d.ts +9 -0
- package/lib/internal/template/code-editor/resizable-box/index.d.ts.map +1 -0
- package/lib/internal/template/code-editor/resizable-box/index.js +44 -0
- package/lib/internal/template/code-editor/resizable-box/index.js.map +1 -0
- package/lib/internal/template/code-editor/resizable-box/styles.css.js +8 -0
- package/lib/internal/template/code-editor/resizable-box/styles.scoped.css +62 -0
- package/lib/internal/template/code-editor/resizable-box/styles.selectors.js +9 -0
- package/lib/internal/template/code-editor/styles.css.js +32 -33
- package/lib/internal/template/code-editor/styles.scoped.css +157 -199
- package/lib/internal/template/code-editor/styles.selectors.js +32 -33
- package/lib/internal/template/form-field/interfaces.d.ts +10 -0
- package/lib/internal/template/form-field/interfaces.d.ts.map +1 -1
- package/lib/internal/template/form-field/interfaces.js.map +1 -1
- package/lib/internal/template/form-field/internal.d.ts +1 -1
- package/lib/internal/template/form-field/internal.d.ts.map +1 -1
- package/lib/internal/template/form-field/internal.js +5 -4
- package/lib/internal/template/form-field/internal.js.map +1 -1
- package/lib/internal/template/input/internal.d.ts.map +1 -1
- package/lib/internal/template/input/internal.js +16 -4
- package/lib/internal/template/input/internal.js.map +1 -1
- package/lib/internal/template/internal/components/live-region/index.d.ts +1 -1
- package/lib/internal/template/internal/components/live-region/index.d.ts.map +1 -1
- package/lib/internal/template/internal/components/live-region/index.js +29 -6
- package/lib/internal/template/internal/components/live-region/index.js.map +1 -1
- package/lib/internal/template/internal/context/form-field-context.d.ts +6 -2
- package/lib/internal/template/internal/context/form-field-context.d.ts.map +1 -1
- package/lib/internal/template/internal/context/form-field-context.js +7 -1
- package/lib/internal/template/internal/context/form-field-context.js.map +1 -1
- package/lib/internal/template/internal/environment.js +1 -1
- package/lib/internal/template/internal/hooks/use-telemetry/index.d.ts.map +1 -1
- package/lib/internal/template/internal/hooks/use-telemetry/index.js +4 -0
- package/lib/internal/template/internal/hooks/use-telemetry/index.js.map +1 -1
- package/lib/internal/template/internal/metrics.d.ts +2 -2
- package/lib/internal/template/internal/metrics.d.ts.map +1 -1
- package/lib/internal/template/internal/metrics.js +20 -17
- package/lib/internal/template/internal/metrics.js.map +1 -1
- package/lib/internal/template/internal/types.d.ts +9 -0
- package/lib/internal/template/internal/types.d.ts.map +1 -1
- package/lib/internal/template/internal/types.js +0 -2
- package/lib/internal/template/internal/types.js.map +1 -1
- package/lib/internal/template/internal/vendor/d3-scale.js +8 -8
- package/lib/internal/template/package.json +0 -1
- package/lib/internal/template/progress-bar/index.d.ts.map +1 -1
- package/lib/internal/template/progress-bar/index.js +14 -3
- package/lib/internal/template/progress-bar/index.js.map +1 -1
- package/lib/internal/template/select/parts/styles.css.js +9 -9
- package/lib/internal/template/select/parts/styles.scoped.css +27 -9
- package/lib/internal/template/select/parts/styles.selectors.js +9 -9
- package/lib/internal/template/side-navigation/internal.d.ts.map +1 -1
- package/lib/internal/template/side-navigation/internal.js +2 -2
- package/lib/internal/template/side-navigation/internal.js.map +1 -1
- package/lib/internal/template/table/body-cell/click-away.d.ts +9 -0
- package/lib/internal/template/table/body-cell/click-away.d.ts.map +1 -0
- package/lib/internal/template/table/body-cell/click-away.js +38 -0
- package/lib/internal/template/table/body-cell/click-away.js.map +1 -0
- package/lib/internal/template/table/body-cell/index.d.ts +10 -19
- package/lib/internal/template/table/body-cell/index.d.ts.map +1 -1
- package/lib/internal/template/table/body-cell/index.js +49 -9
- package/lib/internal/template/table/body-cell/index.js.map +1 -1
- package/lib/internal/template/table/body-cell/inline-editor.d.ts +12 -0
- package/lib/internal/template/table/body-cell/inline-editor.d.ts.map +1 -0
- package/lib/internal/template/table/body-cell/inline-editor.js +88 -0
- package/lib/internal/template/table/body-cell/inline-editor.js.map +1 -0
- package/lib/internal/template/table/body-cell/styles.css.js +18 -12
- package/lib/internal/template/table/body-cell/styles.scoped.css +229 -46
- package/lib/internal/template/table/body-cell/styles.selectors.js +18 -12
- package/lib/internal/template/table/body-cell/td-element.d.ts +21 -0
- package/lib/internal/template/table/body-cell/td-element.d.ts.map +1 -0
- package/lib/internal/template/table/body-cell/td-element.js +11 -0
- package/lib/internal/template/table/body-cell/td-element.js.map +1 -0
- package/lib/internal/template/table/body-cell/use-stable-scroll-position.d.ts +17 -0
- package/lib/internal/template/table/body-cell/use-stable-scroll-position.d.ts.map +1 -0
- package/lib/internal/template/table/body-cell/use-stable-scroll-position.js +48 -0
- package/lib/internal/template/table/body-cell/use-stable-scroll-position.js.map +1 -0
- package/lib/internal/template/table/header-cell/index.d.ts +8 -7
- package/lib/internal/template/table/header-cell/index.d.ts.map +1 -1
- package/lib/internal/template/table/header-cell/index.js +6 -2
- package/lib/internal/template/table/header-cell/index.js.map +1 -1
- package/lib/internal/template/table/header-cell/styles.css.js +19 -18
- package/lib/internal/template/table/header-cell/styles.scoped.css +40 -35
- package/lib/internal/template/table/header-cell/styles.selectors.js +19 -18
- package/lib/internal/template/table/interfaces.d.ts +73 -6
- package/lib/internal/template/table/interfaces.d.ts.map +1 -1
- package/lib/internal/template/table/interfaces.js.map +1 -1
- package/lib/internal/template/table/internal.d.ts.map +1 -1
- package/lib/internal/template/table/internal.js +68 -18
- package/lib/internal/template/table/internal.js.map +1 -1
- package/lib/internal/template/table/thead.d.ts.map +1 -1
- package/lib/internal/template/table/thead.js +1 -1
- package/lib/internal/template/table/thead.js.map +1 -1
- package/lib/internal/template/table/use-table-focus-navigation.d.ts +16 -0
- package/lib/internal/template/table/use-table-focus-navigation.d.ts.map +1 -0
- package/lib/internal/template/table/use-table-focus-navigation.js +131 -0
- package/lib/internal/template/table/use-table-focus-navigation.js.map +1 -0
- package/lib/internal/template/tabs/index.d.ts +1 -1
- package/lib/internal/template/tabs/index.d.ts.map +1 -1
- package/lib/internal/template/tabs/index.js +2 -2
- package/lib/internal/template/tabs/index.js.map +1 -1
- package/lib/internal/template/tabs/interfaces.d.ts +14 -0
- package/lib/internal/template/tabs/interfaces.d.ts.map +1 -1
- package/lib/internal/template/tabs/interfaces.js.map +1 -1
- package/lib/internal/template/tabs/tab-header-bar.d.ts +2 -1
- package/lib/internal/template/tabs/tab-header-bar.d.ts.map +1 -1
- package/lib/internal/template/tabs/tab-header-bar.js +3 -7
- package/lib/internal/template/tabs/tab-header-bar.js.map +1 -1
- package/lib/internal/template/test-utils/dom/table/index.d.ts +4 -0
- package/lib/internal/template/test-utils/dom/table/index.js +21 -5
- package/lib/internal/template/test-utils/dom/table/index.js.map +1 -1
- package/lib/internal/template/test-utils/selectors/table/index.d.ts +4 -0
- package/lib/internal/template/test-utils/selectors/table/index.js +21 -5
- package/lib/internal/template/test-utils/selectors/table/index.js.map +1 -1
- package/lib/internal/template/test-utils/tsconfig.tsbuildinfo +1 -1
- package/lib/internal/template/wizard/internal/analytics.js +3 -3
- package/lib/internal/template/wizard/internal/analytics.js.map +1 -1
- package/package.json +1 -1
- package/lib/internal/template/code-editor/resize-handler.d.ts +0 -3
- package/lib/internal/template/code-editor/resize-handler.d.ts.map +0 -1
- package/lib/internal/template/code-editor/resize-handler.js +0 -7
- package/lib/internal/template/code-editor/resize-handler.js.map +0 -1
- package/lib/internal/template/internal/components/dynamic-aria-live/index.d.ts +0 -28
- package/lib/internal/template/internal/components/dynamic-aria-live/index.d.ts.map +0 -1
- package/lib/internal/template/internal/components/dynamic-aria-live/index.js +0 -38
- package/lib/internal/template/internal/components/dynamic-aria-live/index.js.map +0 -1
- package/lib/internal/template/internal/components/live-region/aria-liva-tag.d.ts +0 -13
- package/lib/internal/template/internal/components/live-region/aria-liva-tag.d.ts.map +0 -1
- package/lib/internal/template/internal/components/live-region/aria-liva-tag.js +0 -18
- package/lib/internal/template/internal/components/live-region/aria-liva-tag.js.map +0 -1
- package/lib/internal/template/internal/components/live-region/utils.d.ts +0 -8
- package/lib/internal/template/internal/components/live-region/utils.d.ts.map +0 -1
- package/lib/internal/template/internal/components/live-region/utils.js +0 -24
- package/lib/internal/template/internal/components/live-region/utils.js.map +0 -1
- package/lib/internal/template/package-lock.json +0 -15689
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
@use '../../internal/styles/tokens' as awsui;
|
|
6
|
+
@use '../background-inline-svg.scss' as utils;
|
|
7
|
+
|
|
8
|
+
.resizable-box {
|
|
9
|
+
position: relative;
|
|
10
|
+
width: 100%;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.resizable-box-handle {
|
|
14
|
+
position: absolute;
|
|
15
|
+
right: 0;
|
|
16
|
+
bottom: 0;
|
|
17
|
+
z-index: 10; // above editor, when editor is overflowing
|
|
18
|
+
|
|
19
|
+
width: awsui.$space-l;
|
|
20
|
+
height: awsui.$space-l;
|
|
21
|
+
|
|
22
|
+
background-repeat: no-repeat;
|
|
23
|
+
background-origin: content-box;
|
|
24
|
+
box-sizing: border-box;
|
|
25
|
+
background-position: bottom right;
|
|
26
|
+
background-size: awsui.$space-l;
|
|
27
|
+
@include utils.background-inline-svg(
|
|
28
|
+
$path: '../assets/resize-handler.svg',
|
|
29
|
+
$stroke: 'colorStrokeCodeEditorResizeHandler'
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
cursor: ns-resize;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.resize-active {
|
|
36
|
+
user-select: none;
|
|
37
|
+
}
|
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
@use '../internal/styles/tokens' as awsui;
|
|
8
8
|
@use '../internal/styles/foundation' as foundation;
|
|
9
9
|
@use '../internal/hooks/focus-visible' as focus-visible;
|
|
10
|
-
@use './background-inline-svg.scss' as utils;
|
|
11
10
|
@use './ace-editor';
|
|
12
11
|
@use './pane';
|
|
13
12
|
|
|
@@ -19,33 +18,6 @@
|
|
|
19
18
|
width: 100%;
|
|
20
19
|
}
|
|
21
20
|
|
|
22
|
-
.resizable-box {
|
|
23
|
-
position: relative;
|
|
24
|
-
width: 100%;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
.resizable-box-handle {
|
|
28
|
-
position: absolute;
|
|
29
|
-
right: 0;
|
|
30
|
-
bottom: 0;
|
|
31
|
-
z-index: 10; // above editor, when editor is overflowing
|
|
32
|
-
|
|
33
|
-
width: awsui.$space-l;
|
|
34
|
-
height: awsui.$space-l;
|
|
35
|
-
|
|
36
|
-
background-repeat: no-repeat;
|
|
37
|
-
background-origin: content-box;
|
|
38
|
-
box-sizing: border-box;
|
|
39
|
-
background-position: bottom right;
|
|
40
|
-
background-size: awsui.$space-l;
|
|
41
|
-
@include utils.background-inline-svg(
|
|
42
|
-
$path: './assets/resize-handler.svg',
|
|
43
|
-
$stroke: 'colorStrokeCodeEditorResizeHandler'
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
cursor: ns-resize;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
21
|
.editor {
|
|
50
22
|
position: absolute;
|
|
51
23
|
top: 0;
|
|
@@ -60,7 +32,7 @@
|
|
|
60
32
|
}
|
|
61
33
|
}
|
|
62
34
|
|
|
63
|
-
.
|
|
35
|
+
.editor-refresh {
|
|
64
36
|
border-top-left-radius: calc(awsui.$border-radius-code-editor - awsui.$border-item-width);
|
|
65
37
|
border-top-right-radius: calc(awsui.$border-radius-code-editor - awsui.$border-item-width);
|
|
66
38
|
}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
@use '../../internal/styles' as styles;
|
|
7
7
|
@use '../../internal/styles/tokens' as awsui;
|
|
8
|
+
@use '../../internal/hooks/focus-visible' as focus-visible;
|
|
8
9
|
|
|
9
10
|
.placeholder {
|
|
10
11
|
@include styles.form-placeholder;
|
|
@@ -36,6 +37,14 @@ $checkbox-size: awsui.$size-control;
|
|
|
36
37
|
|
|
37
38
|
.trigger {
|
|
38
39
|
@include styles.text-overflow-ellipsis;
|
|
40
|
+
@include focus-visible.when-visible {
|
|
41
|
+
@include styles.focus-highlight(
|
|
42
|
+
(
|
|
43
|
+
'vertical': calc(-1 * #{awsui.$space-scaled-xxs}),
|
|
44
|
+
'horizontal': calc(-1 * #{awsui.$space-scaled-xs}),
|
|
45
|
+
)
|
|
46
|
+
);
|
|
47
|
+
}
|
|
39
48
|
}
|
|
40
49
|
|
|
41
50
|
.layout-strut {
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
+
@use '../../internal/styles' as styles;
|
|
6
7
|
@use '../../internal/styles/tokens' as awsui;
|
|
8
|
+
@use '../../internal/hooks/focus-visible' as focus-visible;
|
|
7
9
|
|
|
8
10
|
$cell-vertical-padding: awsui.$space-scaled-xs;
|
|
9
11
|
// Calculate padding to prevent a shift in content after selection due to the difference
|
|
@@ -36,6 +38,35 @@ $border-placeholder: awsui.$border-item-width solid transparent;
|
|
|
36
38
|
border-right: $border-placeholder;
|
|
37
39
|
padding-right: $cell-edge-horizontal-padding;
|
|
38
40
|
}
|
|
41
|
+
&.is-visual-refresh:first-child {
|
|
42
|
+
&:not(.has-striped-rows) {
|
|
43
|
+
padding-left: awsui.$space-xxxs;
|
|
44
|
+
&:not(.body-cell-edit-active).body-cell-editable:hover {
|
|
45
|
+
padding-left: calc(#{awsui.$space-xxxs} + #{awsui.$border-divider-list-width});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/*
|
|
50
|
+
Striped rows requires additional left padding because the
|
|
51
|
+
shaded background makes the child content appear too close
|
|
52
|
+
to the table edge.
|
|
53
|
+
*/
|
|
54
|
+
&:first-child.has-striped-rows {
|
|
55
|
+
padding-left: awsui.$space-xxs;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/*
|
|
59
|
+
Remove the placeholder border if the row is not selectable.
|
|
60
|
+
Rows that are not selectable will reserve the horizontal space
|
|
61
|
+
that the placeholder border would consume.
|
|
62
|
+
*/
|
|
63
|
+
&:not(.has-selection):not(.body-cell-editable) {
|
|
64
|
+
border-left: none;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
&:first-child:not(.is-visual-refresh) {
|
|
68
|
+
padding-left: $cell-edge-horizontal-padding;
|
|
69
|
+
}
|
|
39
70
|
&-first-row {
|
|
40
71
|
border-top: $border-placeholder;
|
|
41
72
|
}
|
|
@@ -47,7 +78,7 @@ $border-placeholder: awsui.$border-item-width solid transparent;
|
|
|
47
78
|
|
|
48
79
|
&.has-footer {
|
|
49
80
|
/*
|
|
50
|
-
Add a bottom border to the body cells of the last row as a separator between the
|
|
81
|
+
Add a bottom border to the body cells of the last row as a separator between the
|
|
51
82
|
table and the footer
|
|
52
83
|
*/
|
|
53
84
|
border-bottom: awsui.$border-divider-section-width solid awsui.$color-border-divider-default;
|
|
@@ -104,38 +135,109 @@ $border-placeholder: awsui.$border-item-width solid transparent;
|
|
|
104
135
|
&-selected:not(.body-cell-prev-selected) {
|
|
105
136
|
padding-top: $cell-vertical-padding;
|
|
106
137
|
}
|
|
107
|
-
|
|
138
|
+
&-editor {
|
|
139
|
+
top: 0;
|
|
140
|
+
right: 0;
|
|
141
|
+
bottom: 0;
|
|
142
|
+
position: absolute;
|
|
108
143
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
*/
|
|
113
|
-
.body-cell:not(.is-visual-refresh) {
|
|
114
|
-
&:first-child {
|
|
115
|
-
padding-left: $cell-edge-horizontal-padding;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
144
|
+
display: flex;
|
|
145
|
+
align-items: center;
|
|
146
|
+
justify-content: flex-end;
|
|
118
147
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
148
|
+
padding-right: awsui.$space-xs;
|
|
149
|
+
|
|
150
|
+
&-form {
|
|
151
|
+
margin: calc(-1 * #{awsui.$space-xs}) calc(-1.5 * #{awsui.$space-xs});
|
|
152
|
+
.is-visual-refresh.body-cell:first-child.has-striped-rows > & {
|
|
153
|
+
margin-left: calc(-1 * #{awsui.$space-xxs});
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.is-visual-refresh.body-cell:first-child:not(.has-striped-rows) > & {
|
|
157
|
+
margin-left: calc(-1 * #{awsui.$space-xxxs});
|
|
158
|
+
}
|
|
159
|
+
}
|
|
128
160
|
|
|
129
|
-
|
|
130
|
-
|
|
161
|
+
&-row {
|
|
162
|
+
display: flex;
|
|
163
|
+
flex-flow: row nowrap;
|
|
164
|
+
align-items: center;
|
|
165
|
+
justify-content: space-between;
|
|
166
|
+
column-gap: awsui.$space-xxs;
|
|
167
|
+
& > :not(:last-child) {
|
|
168
|
+
flex-grow: 1;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
&-controls {
|
|
172
|
+
flex-shrink: 0;
|
|
173
|
+
}
|
|
131
174
|
}
|
|
175
|
+
&.body-cell-editable {
|
|
176
|
+
position: relative;
|
|
177
|
+
cursor: pointer;
|
|
178
|
+
|
|
179
|
+
&.body-cell-edit-active {
|
|
180
|
+
overflow: visible;
|
|
181
|
+
}
|
|
132
182
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
183
|
+
&:not(.body-cell-edit-active) {
|
|
184
|
+
& > .body-cell-editor {
|
|
185
|
+
opacity: 0;
|
|
186
|
+
}
|
|
187
|
+
&:hover {
|
|
188
|
+
position: relative;
|
|
189
|
+
background-color: awsui.$color-background-dropdown-item-hover;
|
|
190
|
+
border: awsui.$border-divider-list-width solid awsui.$color-border-control-default;
|
|
191
|
+
left: calc(-1 * #{awsui.$border-divider-list-width});
|
|
192
|
+
right: calc(-1 * #{awsui.$border-divider-list-width});
|
|
193
|
+
& > .body-cell-editor {
|
|
194
|
+
padding-right: calc(#{awsui.$space-xs} - (2 * #{awsui.$border-divider-list-width}));
|
|
195
|
+
}
|
|
196
|
+
&.body-cell-last-row.body-cell-selected,
|
|
197
|
+
&.body-cell-next-selected {
|
|
198
|
+
padding-top: calc(#{$cell-vertical-padding} - calc(#{awsui.$border-divider-list-width} / 2));
|
|
199
|
+
padding-bottom: calc(#{$cell-vertical-padding} - calc(#{awsui.$border-divider-list-width} / 2));
|
|
200
|
+
}
|
|
201
|
+
&.body-cell-last-row:not(.body-cell-selected) {
|
|
202
|
+
padding-top: calc(#{$cell-vertical-padding} - calc(#{awsui.$border-divider-list-width}));
|
|
203
|
+
}
|
|
204
|
+
&.body-cell-first-row:not(.body-cell-selected) {
|
|
205
|
+
padding-top: calc(#{$cell-vertical-padding} - calc(#{awsui.$border-divider-list-width}));
|
|
206
|
+
padding-bottom: calc(#{$cell-vertical-padding} - calc(#{awsui.$border-divider-list-width}));
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
&:hover,
|
|
210
|
+
&[data-awsui-focus-visible='true']:focus-within {
|
|
211
|
+
padding-right: calc(#{$cell-horizontal-padding} + #{awsui.$space-l});
|
|
212
|
+
& > .body-cell-editor {
|
|
213
|
+
opacity: 1;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
&:hover:first-child {
|
|
217
|
+
left: 0;
|
|
218
|
+
right: 0;
|
|
219
|
+
}
|
|
220
|
+
&[data-awsui-focus-visible='true']:not(:hover):focus-within {
|
|
221
|
+
@include styles.focus-highlight(
|
|
222
|
+
(
|
|
223
|
+
'vertical': calc(-1 * #{awsui.$space-scaled-xxs}),
|
|
224
|
+
'horizontal': calc(-1 * #{awsui.$space-scaled-xxs}),
|
|
225
|
+
)
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
&-editable.is-visual-refresh:not(.body-cell-edit-active):hover {
|
|
231
|
+
&:first-child {
|
|
232
|
+
border-top-left-radius: awsui.$border-radius-control-default-focus-ring;
|
|
233
|
+
border-bottom-left-radius: awsui.$border-radius-control-default-focus-ring;
|
|
234
|
+
}
|
|
235
|
+
&:last-child {
|
|
236
|
+
border-top-right-radius: awsui.$border-radius-control-default-focus-ring;
|
|
237
|
+
border-bottom-right-radius: awsui.$border-radius-control-default-focus-ring;
|
|
238
|
+
}
|
|
239
|
+
&.body-cell-first-row > .body-cell-editor {
|
|
240
|
+
padding-top: awsui.$border-divider-list-width;
|
|
241
|
+
}
|
|
140
242
|
}
|
|
141
243
|
}
|
|
@@ -53,8 +53,10 @@
|
|
|
53
53
|
color: awsui.$color-text-column-sorting-icon;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
.
|
|
57
|
-
|
|
56
|
+
.edit-icon {
|
|
57
|
+
margin-left: awsui.$space-xxs;
|
|
58
|
+
margin-top: awsui.$space-scaled-xxs;
|
|
59
|
+
color: inherit;
|
|
58
60
|
}
|
|
59
61
|
|
|
60
62
|
.header-cell-content {
|
|
@@ -76,6 +78,12 @@
|
|
|
76
78
|
&.header-cell-fake-focus {
|
|
77
79
|
@include styles.focus-highlight(awsui.$space-table-header-focus-outline-gutter);
|
|
78
80
|
}
|
|
81
|
+
|
|
82
|
+
.header-cell-disabled.header-cell-sorted > & {
|
|
83
|
+
& > .sorting-icon {
|
|
84
|
+
color: awsui.$color-text-interactive-disabled;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
79
87
|
}
|
|
80
88
|
|
|
81
89
|
.header-cell-sortable:not(.header-cell-disabled) {
|
|
@@ -85,7 +93,7 @@
|
|
|
85
93
|
& > .header-cell-content:hover,
|
|
86
94
|
&.header-cell-sorted > .header-cell-content {
|
|
87
95
|
color: awsui.$color-text-interactive-active;
|
|
88
|
-
> .sorting-icon {
|
|
96
|
+
& > .sorting-icon {
|
|
89
97
|
color: awsui.$color-text-interactive-active;
|
|
90
98
|
}
|
|
91
99
|
}
|
|
@@ -106,8 +114,8 @@
|
|
|
106
114
|
|
|
107
115
|
/*
|
|
108
116
|
In Visual Refresh the first cell in the header should align
|
|
109
|
-
with the left edge of the table as closely as possible. If the
|
|
110
|
-
last header cell is sortable the sort icon should align with the
|
|
117
|
+
with the left edge of the table as closely as possible. If the
|
|
118
|
+
last header cell is sortable the sort icon should align with the
|
|
111
119
|
settings icon in the pagination slot.
|
|
112
120
|
*/
|
|
113
121
|
.header-cell:not(.is-visual-refresh) {
|
|
@@ -122,8 +130,8 @@ settings icon in the pagination slot.
|
|
|
122
130
|
}
|
|
123
131
|
|
|
124
132
|
/*
|
|
125
|
-
Striped rows requires additional left padding because the
|
|
126
|
-
shaded background makes the child content appear too close
|
|
133
|
+
Striped rows requires additional left padding because the
|
|
134
|
+
shaded background makes the child content appear too close
|
|
127
135
|
to the table edge.
|
|
128
136
|
*/
|
|
129
137
|
&:first-child.has-striped-rows {
|
|
@@ -6,6 +6,7 @@ export declare const InternalButton: React.ForwardRefExoticComponent<Omit<Button
|
|
|
6
6
|
__nativeAttributes?: Record<string, any> | undefined;
|
|
7
7
|
__iconClass?: string | undefined;
|
|
8
8
|
__activated?: boolean | undefined;
|
|
9
|
+
__hideFocusOutline?: boolean | undefined;
|
|
9
10
|
} & InternalBaseComponentProps & React.RefAttributes<ButtonProps.Ref>>;
|
|
10
11
|
export default InternalButton;
|
|
11
12
|
//# sourceMappingURL=internal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/button/internal.tsx"],"names":[],"mappings":"AAGA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAMnD,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/button/internal.tsx"],"names":[],"mappings":"AAGA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAMnD,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAalF,eAAO,MAAM,cAAc;cAPf,WAAW,CAAC,SAAS,CAAC,GAAG,eAAe,GAAG,kBAAkB,GAAG,cAAc,GAAG,eAAe;;;;;sEAmI3G,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -13,7 +13,7 @@ import { useMergeRefs } from '../internal/hooks/use-merge-refs';
|
|
|
13
13
|
import LiveRegion from '../internal/components/live-region';
|
|
14
14
|
export var InternalButton = React.forwardRef(function (_a, ref) {
|
|
15
15
|
var _b;
|
|
16
|
-
var children = _a.children, iconName = _a.iconName, __iconClass = _a.__iconClass, onClick = _a.onClick, onFollow = _a.onFollow, _c = _a.iconAlign, iconAlign = _c === void 0 ? 'left' : _c, iconUrl = _a.iconUrl, iconSvg = _a.iconSvg, iconAlt = _a.iconAlt, _d = _a.variant, variant = _d === void 0 ? 'normal' : _d, _e = _a.loading, loading = _e === void 0 ? false : _e, loadingText = _a.loadingText, _f = _a.disabled, disabled = _f === void 0 ? false : _f, _g = _a.wrapText, wrapText = _g === void 0 ? true : _g, href = _a.href, target = _a.target, download = _a.download, _h = _a.formAction, formAction = _h === void 0 ? 'submit' : _h, ariaLabel = _a.ariaLabel, ariaExpanded = _a.ariaExpanded, __nativeAttributes = _a.__nativeAttributes,
|
|
16
|
+
var children = _a.children, iconName = _a.iconName, __iconClass = _a.__iconClass, onClick = _a.onClick, onFollow = _a.onFollow, _c = _a.iconAlign, iconAlign = _c === void 0 ? 'left' : _c, iconUrl = _a.iconUrl, iconSvg = _a.iconSvg, iconAlt = _a.iconAlt, _d = _a.variant, variant = _d === void 0 ? 'normal' : _d, _e = _a.loading, loading = _e === void 0 ? false : _e, loadingText = _a.loadingText, _f = _a.disabled, disabled = _f === void 0 ? false : _f, _g = _a.wrapText, wrapText = _g === void 0 ? true : _g, href = _a.href, target = _a.target, download = _a.download, _h = _a.formAction, formAction = _h === void 0 ? 'submit' : _h, ariaLabel = _a.ariaLabel, ariaExpanded = _a.ariaExpanded, _j = _a.__hideFocusOutline, __hideFocusOutline = _j === void 0 ? false : _j, __nativeAttributes = _a.__nativeAttributes, _k = _a.__internalRootRef, __internalRootRef = _k === void 0 ? null : _k, _l = _a.__activated, __activated = _l === void 0 ? false : _l, props = __rest(_a, ["children", "iconName", "__iconClass", "onClick", "onFollow", "iconAlign", "iconUrl", "iconSvg", "iconAlt", "variant", "loading", "loadingText", "disabled", "wrapText", "href", "target", "download", "formAction", "ariaLabel", "ariaExpanded", "__hideFocusOutline", "__nativeAttributes", "__internalRootRef", "__activated"]);
|
|
17
17
|
checkSafeUrl('Button', href);
|
|
18
18
|
var focusVisible = useFocusVisible();
|
|
19
19
|
var isAnchor = Boolean(href);
|
|
@@ -37,7 +37,7 @@ export var InternalButton = React.forwardRef(function (_a, ref) {
|
|
|
37
37
|
_b[styles['button-no-text']] = !shouldHaveContent,
|
|
38
38
|
_b[styles['is-activated']] = __activated,
|
|
39
39
|
_b));
|
|
40
|
-
var buttonProps = __assign(__assign(__assign(__assign({}, props), focusVisible), __nativeAttributes), {
|
|
40
|
+
var buttonProps = __assign(__assign(__assign(__assign({}, props), (__hideFocusOutline ? undefined : focusVisible)), __nativeAttributes), {
|
|
41
41
|
// https://github.com/microsoft/TypeScript/issues/36659
|
|
42
42
|
ref: useMergeRefs(buttonRef, __internalRootRef), 'aria-label': ariaLabel, 'aria-expanded': ariaExpanded, className: buttonClass, onClick: handleClick });
|
|
43
43
|
var iconProps = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/button/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3E,OAAO,eAAe,MAAM,iCAAiC,CAAC;AAC9D,OAAO,eAAe,MAAM,iCAAiC,CAAC;AAC9D,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAmB,QAAQ,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAGrE,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,UAAU,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/button/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3E,OAAO,eAAe,MAAM,iCAAiC,CAAC;AAC9D,OAAO,eAAe,MAA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,CAAC,CAAC,SAAS,EAC5C,QAAQ,EAAE,QAAQ,KAEjB,aAAa,CACZ;YACH,OAAO,IAAI,WAAW,IAAI,oBAAC,UAAU,QAAE,WAAW,CAAc,CAChE,CACJ,CAAC;KACH;IACD,OAAO,CACL;QACE,2CAAY,WAAW,IAAE,IAAI,EAAE,UAAU,KAAK,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,EAAE,QAAQ,EAAE,UAAU,KAC7F,aAAa,CACP;QACR,OAAO,IAAI,WAAW,IAAI,oBAAC,UAAU,QAAE,WAAW,CAAc,CAChE,CACJ,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,cAAc,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, { useCallback, useRef } from 'react';\nimport { fireCancelableEvent, isPlainLeftClick } from '../internal/events';\nimport useFocusVisible from '../internal/hooks/focus-visible';\nimport useForwardFocus from '../internal/hooks/forward-focus';\nimport styles from './styles.css.js';\nimport { ButtonIconProps, LeftIcon, RightIcon } from './icon-helper';\nimport { ButtonProps } from './interfaces';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport { checkSafeUrl } from '../internal/utils/check-safe-url';\nimport { useMergeRefs } from '../internal/hooks/use-merge-refs';\nimport LiveRegion from '../internal/components/live-region';\n\ntype InternalButtonProps = Omit<ButtonProps, 'variant'> & {\n variant?: ButtonProps['variant'] | 'flashbar-icon' | 'breadcrumb-group' | 'menu-trigger' | 'modal-dismiss';\n __nativeAttributes?: Record<string, any>;\n __iconClass?: string;\n __activated?: boolean;\n __hideFocusOutline?: boolean;\n} & InternalBaseComponentProps;\n\nexport const InternalButton = React.forwardRef(\n (\n {\n children,\n iconName,\n __iconClass,\n onClick,\n onFollow,\n iconAlign = 'left',\n iconUrl,\n iconSvg,\n iconAlt,\n variant = 'normal',\n loading = false,\n loadingText,\n disabled = false,\n wrapText = true,\n href,\n target,\n download,\n formAction = 'submit',\n ariaLabel,\n ariaExpanded,\n __hideFocusOutline = false,\n __nativeAttributes,\n __internalRootRef = null,\n __activated = false,\n ...props\n }: InternalButtonProps,\n ref: React.Ref<ButtonProps.Ref>\n ) => {\n checkSafeUrl('Button', href);\n const focusVisible = useFocusVisible();\n const isAnchor = Boolean(href);\n const isDisabled = loading || disabled;\n const shouldHaveContent =\n children && ['icon', 'inline-icon', 'flashbar-icon', 'modal-dismiss'].indexOf(variant) === -1;\n\n const buttonRef = useRef<HTMLElement>(null);\n useForwardFocus(ref, buttonRef);\n\n const handleClick = useCallback(\n (event: React.MouseEvent) => {\n if (isAnchor && isDisabled) {\n return event.preventDefault();\n }\n\n if (isAnchor && isPlainLeftClick(event)) {\n fireCancelableEvent(onFollow, null, event);\n }\n\n const { altKey, button, ctrlKey, metaKey, shiftKey } = event;\n fireCancelableEvent(onClick, { altKey, button, ctrlKey, metaKey, shiftKey }, event);\n },\n [isAnchor, isDisabled, onClick, onFollow]\n );\n\n const buttonClass = clsx(props.className, styles.button, styles[`variant-${variant}`], {\n [styles.disabled]: isDisabled,\n [styles['button-no-wrap']]: !wrapText,\n [styles['button-no-text']]: !shouldHaveContent,\n [styles['is-activated']]: __activated,\n });\n\n const buttonProps = {\n ...props,\n ...(__hideFocusOutline ? undefined : focusVisible),\n ...__nativeAttributes,\n // https://github.com/microsoft/TypeScript/issues/36659\n ref: useMergeRefs(buttonRef as any, __internalRootRef),\n 'aria-label': ariaLabel,\n 'aria-expanded': ariaExpanded,\n className: buttonClass,\n onClick: handleClick,\n } as const;\n const iconProps: ButtonIconProps = {\n loading,\n iconName,\n iconAlign,\n iconUrl,\n iconSvg,\n iconAlt,\n variant,\n iconClass: __iconClass,\n iconSize: variant === 'modal-dismiss' ? 'medium' : 'normal',\n };\n const buttonContent = (\n <>\n <LeftIcon {...iconProps} />\n {shouldHaveContent && <span className={styles.content}>{children}</span>}\n <RightIcon {...iconProps} />\n </>\n );\n\n if (isAnchor) {\n return (\n // https://github.com/yannickcr/eslint-plugin-react/issues/2962\n // eslint-disable-next-line react/jsx-no-target-blank\n <>\n <a\n {...buttonProps}\n href={href}\n target={target}\n // security recommendation: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#target\n rel={target === '_blank' ? 'noopener noreferrer' : undefined}\n tabIndex={isDisabled ? -1 : undefined}\n aria-disabled={isDisabled ? true : undefined}\n download={download}\n >\n {buttonContent}\n </a>\n {loading && loadingText && <LiveRegion>{loadingText}</LiveRegion>}\n </>\n );\n }\n return (\n <>\n <button {...buttonProps} type={formAction === 'none' ? 'button' : 'submit'} disabled={isDisabled}>\n {buttonContent}\n </button>\n {loading && loadingText && <LiveRegion>{loadingText}</LiveRegion>}\n </>\n );\n }\n);\n\nexport default InternalButton;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/code-editor/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/code-editor/index.tsx"],"names":[],"mappings":"AAUA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AA+B/C,OAAO,EAAE,eAAe,EAAE,CAAC;AAE3B,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,KAAK,EAAE,eAAe,eAoTxD"}
|
|
@@ -3,7 +3,6 @@ import { __assign, __rest } from "tslib";
|
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
5
5
|
import clsx from 'clsx';
|
|
6
|
-
import { ResizableBox } from 'react-resizable';
|
|
7
6
|
import { useMergeRefs } from '../internal/hooks/use-merge-refs';
|
|
8
7
|
import { getBaseProps } from '../internal/base-component';
|
|
9
8
|
import { KeyCode } from '../internal/keycode';
|
|
@@ -13,7 +12,7 @@ import { useChangeEffect } from './listeners';
|
|
|
13
12
|
import { getDefaultConfig, getAceTheme, getLanguageLabel, DEFAULT_DARK_THEME, DEFAULT_LIGHT_THEME, getDefaultTheme, } from './util';
|
|
14
13
|
import { fireNonCancelableEvent } from '../internal/events';
|
|
15
14
|
import { setupEditor } from './setup-editor';
|
|
16
|
-
import
|
|
15
|
+
import { ResizableBox } from './resizable-box';
|
|
17
16
|
import PreferencesModal from './preferences-modal';
|
|
18
17
|
import LoadingScreen from './loading-screen';
|
|
19
18
|
import ErrorScreen from './error-screen';
|
|
@@ -192,14 +191,12 @@ export default function CodeEditor(props) {
|
|
|
192
191
|
React.createElement(LiveRegion, { visible: true }, i18nStrings.loadingState))),
|
|
193
192
|
!ace && !props.loading && (React.createElement(ErrorScreen, { recoveryText: i18nStrings.errorStateRecovery, onRecoveryClick: props.onRecoveryClick }, i18nStrings.errorState)),
|
|
194
193
|
ace && !props.loading && (React.createElement(React.Fragment, null,
|
|
195
|
-
React.createElement(ResizableBox, {
|
|
196
|
-
setEditorHeight(
|
|
194
|
+
React.createElement(ResizableBox, { height: Math.max(editorHeight, 20), minHeight: 20, onResize: function (height) {
|
|
195
|
+
setEditorHeight(height);
|
|
197
196
|
onResize();
|
|
198
|
-
fireNonCancelableEvent(onEditorContentResize, {
|
|
199
|
-
height: data.size.height
|
|
200
|
-
});
|
|
197
|
+
fireNonCancelableEvent(onEditorContentResize, { height: height });
|
|
201
198
|
} },
|
|
202
|
-
React.createElement("div", { ref: editorRef, className: clsx(styles.editor, styles.ace), onKeyDown: onEditorKeydown, tabIndex: 0, role: "group", "aria-label": i18nStrings.editorGroupAriaLabel })),
|
|
199
|
+
React.createElement("div", { ref: editorRef, className: clsx(styles.editor, styles.ace, isRefresh && styles['editor-refresh']), onKeyDown: onEditorKeydown, tabIndex: 0, role: "group", "aria-label": i18nStrings.editorGroupAriaLabel })),
|
|
203
200
|
React.createElement("div", { role: "group", "aria-label": i18nStrings.statusBarGroupAriaLabel },
|
|
204
201
|
React.createElement(StatusBar, { languageLabel: languageLabel, cursorPosition: i18nStrings.cursorPosition(cursorPosition.row + 1, 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: paneId, onPreferencesOpen: onPreferencesOpen, isRefresh: isRefresh }),
|
|
205
202
|
React.createElement(Pane, { id: paneId, visible: paneStatus !== 'hidden', annotations: currentAnnotations, highlighted: highlightedAnnotation, onAnnotationClick: onAnnotationClick, onAnnotationClear: onAnnotationClear, onClose: onPaneClose, onAllowlist: shouldHandleFocus, cursorPositionLabel: i18nStrings.cursorPosition, closeButtonAriaLabel: i18nStrings.paneCloseButtonAriaLabel })),
|
|
@@ -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,EA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B,oBAAC,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"]}
|
|
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,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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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 { 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 { 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 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={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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pane.d.ts","sourceRoot":"","sources":["../../../src/code-editor/pane.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pane.d.ts","sourceRoot":"","sources":["../../../src/code-editor/pane.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAcjC,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IAEX,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,GAAG,CAAC,UAAU,EAAE,CAAC;IAC9B,WAAW,CAAC,EAAE,GAAG,CAAC,UAAU,CAAC;IAE7B,mBAAmB,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC;IAC7D,oBAAoB,EAAE,MAAM,CAAC;IAE7B,WAAW,EAAE,CAAC,aAAa,EAAE,WAAW,KAAK,OAAO,CAAC;IACrD,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,iBAAiB,EAAE,CAAC,UAAU,EAAE,GAAG,CAAC,UAAU,KAAK,IAAI,CAAC;IACxD,iBAAiB,EAAE,MAAM,IAAI,CAAC;CAC/B;AAED,eAAO,MAAM,IAAI,sJAWd,SAAS,uBAuGX,CAAC"}
|