@cloudscape-design/components 3.0.521 → 3.0.522
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/calendar/interfaces.d.ts +23 -3
- package/calendar/interfaces.d.ts.map +1 -1
- package/calendar/interfaces.js.map +1 -1
- package/calendar/internal.d.ts +1 -1
- package/calendar/internal.d.ts.map +1 -1
- package/calendar/internal.js +5 -4
- package/calendar/internal.js.map +1 -1
- package/code-editor/ace-themes.d.ts +6 -0
- package/code-editor/ace-themes.d.ts.map +1 -1
- package/code-editor/ace-themes.js +2 -0
- package/code-editor/ace-themes.js.map +1 -1
- package/code-editor/index.js +3 -3
- package/code-editor/index.js.map +1 -1
- package/code-editor/preferences-modal.d.ts +1 -1
- package/code-editor/preferences-modal.d.ts.map +1 -1
- package/code-editor/preferences-modal.js +3 -6
- package/code-editor/preferences-modal.js.map +1 -1
- package/code-editor/use-editor.d.ts.map +1 -1
- package/code-editor/use-editor.js +4 -2
- package/code-editor/use-editor.js.map +1 -1
- package/code-editor/util.d.ts +3 -4
- package/code-editor/util.d.ts.map +1 -1
- package/code-editor/util.js +29 -10
- package/code-editor/util.js.map +1 -1
- package/date-picker/index.d.ts.map +1 -1
- package/date-picker/index.js +6 -2
- package/date-picker/index.js.map +1 -1
- package/date-picker/interfaces.d.ts +7 -0
- package/date-picker/interfaces.d.ts.map +1 -1
- package/date-picker/interfaces.js.map +1 -1
- package/internal/environment.js +1 -1
- package/internal/environment.json +1 -1
- package/internal/manifest.json +1 -1
- package/package.json +1 -1
package/calendar/interfaces.d.ts
CHANGED
|
@@ -39,17 +39,17 @@ export interface CalendarProps extends BaseComponentProps {
|
|
|
39
39
|
ariaDescribedby?: string;
|
|
40
40
|
/**
|
|
41
41
|
* Used as part of the `aria-label` for today's date in the calendar.
|
|
42
|
-
* @
|
|
42
|
+
* @deprecated Use `i18nString.todayAriaLabel` instead.
|
|
43
43
|
*/
|
|
44
44
|
todayAriaLabel?: string;
|
|
45
45
|
/**
|
|
46
46
|
* Specifies an `aria-label` for the 'next month' button.
|
|
47
|
-
* @
|
|
47
|
+
* @deprecated Use `i18nStrings.nextMonthAriaLabel` instead.
|
|
48
48
|
*/
|
|
49
49
|
nextMonthAriaLabel?: string;
|
|
50
50
|
/**
|
|
51
51
|
* Specifies an `aria-label` for the 'previous month' button.
|
|
52
|
-
* @
|
|
52
|
+
* @deprecated Use `i18nStrings.previousMonthAriaLabel` instead.
|
|
53
53
|
*/
|
|
54
54
|
previousMonthAriaLabel?: string;
|
|
55
55
|
/**
|
|
@@ -57,6 +57,12 @@ export interface CalendarProps extends BaseComponentProps {
|
|
|
57
57
|
* The event `detail` contains the current value of the field.
|
|
58
58
|
*/
|
|
59
59
|
onChange?: NonCancelableEventHandler<CalendarProps.ChangeDetail>;
|
|
60
|
+
/**
|
|
61
|
+
* An object containing all the necessary localized strings required by
|
|
62
|
+
* the component.
|
|
63
|
+
* @i18n
|
|
64
|
+
*/
|
|
65
|
+
i18nStrings?: CalendarProps.I18nStrings;
|
|
60
66
|
}
|
|
61
67
|
export declare namespace CalendarProps {
|
|
62
68
|
interface ChangeDetail {
|
|
@@ -68,5 +74,19 @@ export declare namespace CalendarProps {
|
|
|
68
74
|
interface IsDateEnabledFunction {
|
|
69
75
|
(date: Date): boolean;
|
|
70
76
|
}
|
|
77
|
+
interface I18nStrings {
|
|
78
|
+
/**
|
|
79
|
+
* Used as part of the `aria-label` for today's date in the calendar.
|
|
80
|
+
*/
|
|
81
|
+
todayAriaLabel?: string;
|
|
82
|
+
/**
|
|
83
|
+
* Specifies an `aria-label` for the 'next month' button.
|
|
84
|
+
*/
|
|
85
|
+
nextMonthAriaLabel?: string;
|
|
86
|
+
/**
|
|
87
|
+
* Specifies an `aria-label` for the 'previous month' button.
|
|
88
|
+
*/
|
|
89
|
+
previousMonthAriaLabel?: string;
|
|
90
|
+
}
|
|
71
91
|
}
|
|
72
92
|
//# sourceMappingURL=interfaces.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"lib/default/","sources":["calendar/interfaces.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAE/D,MAAM,WAAW,aAAc,SAAQ,kBAAkB;IACvD;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;;;;;OAMG;IACH,aAAa,CAAC,EAAE,aAAa,CAAC,qBAAqB,CAAC;IAEpD;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;;OAGG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAE5B;;;OAGG;IACH,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAEhC;;;OAGG;IACH,QAAQ,CAAC,EAAE,yBAAyB,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"interfaces.d.ts","sourceRoot":"lib/default/","sources":["calendar/interfaces.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAE/D,MAAM,WAAW,aAAc,SAAQ,kBAAkB;IACvD;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;;;;;OAMG;IACH,aAAa,CAAC,EAAE,aAAa,CAAC,qBAAqB,CAAC;IAEpD;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;;OAGG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAE5B;;;OAGG;IACH,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAEhC;;;OAGG;IACH,QAAQ,CAAC,EAAE,yBAAyB,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC;IAEjE;;;;OAIG;IACH,WAAW,CAAC,EAAE,aAAa,CAAC,WAAW,CAAC;CACzC;AAED,yBAAiB,aAAa,CAAC;IAC7B,UAAiB,YAAY;QAC3B;;WAEG;QACH,KAAK,EAAE,MAAM,CAAC;KACf;IAED,UAAiB,qBAAqB;QACpC,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC;KACvB;IAED,UAAiB,WAAW;QAC1B;;WAEG;QACH,cAAc,CAAC,EAAE,MAAM,CAAC;QAExB;;WAEG;QACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;QAE5B;;WAEG;QACH,sBAAsB,CAAC,EAAE,MAAM,CAAC;KACjC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"lib/default/","sources":["calendar/interfaces.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { BaseComponentProps } from '../internal/base-component';\nimport { NonCancelableEventHandler } from '../internal/events';\n\nexport interface CalendarProps extends BaseComponentProps {\n /**\n * The current input value, in YYYY-MM-DD format.\n */\n value: string;\n\n /**\n * Defines whether a particular date is enabled in the calendar or not.\n * If you disable a date in the calendar, users can still enter this date using a keyboard.\n * We recommend that you also validate these constraints on the client-side and server-side\n * as you would for other form elements.\n * @param date\n */\n isDateEnabled?: CalendarProps.IsDateEnabledFunction;\n\n /**\n * Specifies the locale to use to render month names and determine the starting day of the week.\n * If you don't provide this, the locale is determined by the page and browser locales.\n * Supported values and formats are listed in the\n * [JavaScript Intl API specification](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_identification_and_negotiation).\n */\n locale?: string;\n\n /**\n * Determines the starting day of the week. The values 0-6 map to Sunday-Saturday.\n * By default the starting day of the week is defined by the locale, but you can use this property to override it.\n */\n startOfWeek?: number;\n\n /**\n * Adds an `aria-label` to the calendar.\n */\n ariaLabel?: string;\n\n /**\n * Adds `aria-labelledby` to the calendar.\n */\n ariaLabelledby?: string;\n\n /**\n * Adds `aria-describedby` to the calendar.\n */\n ariaDescribedby?: string;\n\n /**\n * Used as part of the `aria-label` for today's date in the calendar.\n * @
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"lib/default/","sources":["calendar/interfaces.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { BaseComponentProps } from '../internal/base-component';\nimport { NonCancelableEventHandler } from '../internal/events';\n\nexport interface CalendarProps extends BaseComponentProps {\n /**\n * The current input value, in YYYY-MM-DD format.\n */\n value: string;\n\n /**\n * Defines whether a particular date is enabled in the calendar or not.\n * If you disable a date in the calendar, users can still enter this date using a keyboard.\n * We recommend that you also validate these constraints on the client-side and server-side\n * as you would for other form elements.\n * @param date\n */\n isDateEnabled?: CalendarProps.IsDateEnabledFunction;\n\n /**\n * Specifies the locale to use to render month names and determine the starting day of the week.\n * If you don't provide this, the locale is determined by the page and browser locales.\n * Supported values and formats are listed in the\n * [JavaScript Intl API specification](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_identification_and_negotiation).\n */\n locale?: string;\n\n /**\n * Determines the starting day of the week. The values 0-6 map to Sunday-Saturday.\n * By default the starting day of the week is defined by the locale, but you can use this property to override it.\n */\n startOfWeek?: number;\n\n /**\n * Adds an `aria-label` to the calendar.\n */\n ariaLabel?: string;\n\n /**\n * Adds `aria-labelledby` to the calendar.\n */\n ariaLabelledby?: string;\n\n /**\n * Adds `aria-describedby` to the calendar.\n */\n ariaDescribedby?: string;\n\n /**\n * Used as part of the `aria-label` for today's date in the calendar.\n * @deprecated Use `i18nString.todayAriaLabel` instead.\n */\n todayAriaLabel?: string;\n\n /**\n * Specifies an `aria-label` for the 'next month' button.\n * @deprecated Use `i18nStrings.nextMonthAriaLabel` instead.\n */\n nextMonthAriaLabel?: string;\n\n /**\n * Specifies an `aria-label` for the 'previous month' button.\n * @deprecated Use `i18nStrings.previousMonthAriaLabel` instead.\n */\n previousMonthAriaLabel?: string;\n\n /**\n * Called whenever a user changes the input value (by typing, pasting, or selecting a value).\n * The event `detail` contains the current value of the field.\n */\n onChange?: NonCancelableEventHandler<CalendarProps.ChangeDetail>;\n\n /**\n * An object containing all the necessary localized strings required by\n * the component.\n * @i18n\n */\n i18nStrings?: CalendarProps.I18nStrings;\n}\n\nexport namespace CalendarProps {\n export interface ChangeDetail {\n /**\n * The new value of this component.\n */\n value: string;\n }\n\n export interface IsDateEnabledFunction {\n (date: Date): boolean;\n }\n\n export interface I18nStrings {\n /**\n * Used as part of the `aria-label` for today's date in the calendar.\n */\n todayAriaLabel?: string;\n\n /**\n * Specifies an `aria-label` for the 'next month' button.\n */\n nextMonthAriaLabel?: string;\n\n /**\n * Specifies an `aria-label` for the 'previous month' button.\n */\n previousMonthAriaLabel?: string;\n }\n}\n"]}
|
package/calendar/internal.d.ts
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
import { CalendarProps } from './interfaces.js';
|
|
3
3
|
import { InternalBaseComponentProps } from '../internal/hooks/use-base-component/index.js';
|
|
4
4
|
export type DayIndex = 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
5
|
-
export default function Calendar({ value, locale, startOfWeek, isDateEnabled, ariaLabel, ariaLabelledby, ariaDescribedby, onChange, __internalRootRef, ...rest }: CalendarProps & InternalBaseComponentProps): JSX.Element;
|
|
5
|
+
export default function Calendar({ value, locale, startOfWeek, isDateEnabled, ariaLabel, ariaLabelledby, ariaDescribedby, onChange, __internalRootRef, i18nStrings, ...rest }: CalendarProps & InternalBaseComponentProps): JSX.Element;
|
|
6
6
|
//# sourceMappingURL=internal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.d.ts","sourceRoot":"lib/default/","sources":["calendar/internal.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAE,0BAA0B,EAAE,MAAM,+CAA+C,CAAC;AAM3F,MAAM,MAAM,QAAQ,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAEjD,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,EAC/B,KAAK,EACL,MAAW,EACX,WAAW,EACX,aAA0B,EAC1B,SAAS,EACT,cAAc,EACd,eAAe,EACf,QAAQ,EACR,iBAAiB,EACjB,GAAG,IAAI,EACR,EAAE,aAAa,GAAG,0BAA0B,
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"lib/default/","sources":["calendar/internal.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAE,0BAA0B,EAAE,MAAM,+CAA+C,CAAC;AAM3F,MAAM,MAAM,QAAQ,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAEjD,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,EAC/B,KAAK,EACL,MAAW,EACX,WAAW,EACX,aAA0B,EAC1B,SAAS,EACT,cAAc,EACd,eAAe,EACf,QAAQ,EACR,iBAAiB,EACjB,WAAW,EACX,GAAG,IAAI,EACR,EAAE,aAAa,GAAG,0BAA0B,eAoH5C"}
|
package/calendar/internal.js
CHANGED
|
@@ -17,7 +17,8 @@ import { useDateCache } from '../internal/hooks/use-date-cache/index.js';
|
|
|
17
17
|
import { useUniqueId } from '../internal/hooks/use-unique-id/index.js';
|
|
18
18
|
import { useInternalI18n } from '../i18n/context.js';
|
|
19
19
|
export default function Calendar(_a) {
|
|
20
|
-
var
|
|
20
|
+
var _b, _c, _d;
|
|
21
|
+
var { value, locale = '', startOfWeek, isDateEnabled = () => true, ariaLabel, ariaLabelledby, ariaDescribedby, onChange, __internalRootRef, i18nStrings } = _a, rest = __rest(_a, ["value", "locale", "startOfWeek", "isDateEnabled", "ariaLabel", "ariaLabelledby", "ariaDescribedby", "onChange", "__internalRootRef", "i18nStrings"]);
|
|
21
22
|
checkControlled('Calendar', 'value', value, 'onChange', onChange);
|
|
22
23
|
const baseProps = getBaseProps(rest);
|
|
23
24
|
const normalizedLocale = normalizeLocale('Calendar', locale);
|
|
@@ -33,9 +34,9 @@ export default function Calendar(_a) {
|
|
|
33
34
|
const [displayedDate, setDisplayedDate] = useState(defaultDisplayedDate);
|
|
34
35
|
const headingId = useUniqueId('calendar-heading');
|
|
35
36
|
const i18n = useInternalI18n('calendar');
|
|
36
|
-
const nextMonthAriaLabel = i18n('nextMonthAriaLabel', rest.nextMonthAriaLabel);
|
|
37
|
-
const previousMonthAriaLabel = i18n('previousMonthAriaLabel', rest.previousMonthAriaLabel);
|
|
38
|
-
const todayAriaLabel = i18n('todayAriaLabel', rest.todayAriaLabel);
|
|
37
|
+
const nextMonthAriaLabel = i18n('nextMonthAriaLabel', (_b = i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.nextMonthAriaLabel) !== null && _b !== void 0 ? _b : rest.nextMonthAriaLabel);
|
|
38
|
+
const previousMonthAriaLabel = i18n('previousMonthAriaLabel', (_c = i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.previousMonthAriaLabel) !== null && _c !== void 0 ? _c : rest.previousMonthAriaLabel);
|
|
39
|
+
const todayAriaLabel = i18n('todayAriaLabel', (_d = i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.todayAriaLabel) !== null && _d !== void 0 ? _d : rest.todayAriaLabel);
|
|
39
40
|
// Update displayed date if value changes.
|
|
40
41
|
useEffect(() => {
|
|
41
42
|
memoizedValue && setDisplayedDate(prev => (prev.getTime() !== memoizedValue.getTime() ? memoizedValue : prev));
|
package/calendar/internal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.js","sourceRoot":"lib/default/","sources":["calendar/internal.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;;AAEtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,cAAc,MAAM,UAAU,CAAC;AACtC,OAAO,IAAI,MAAM,QAAQ,CAAC;AAC1B,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AACjF,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,eAAe,MAAM,6CAA6C,CAAC;AAC1E,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE1D,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE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AAI,EAAE,MAAM,CAAC,QAAQ,EAAE,SAAS,CAAC,SAAS,CAAC;QAElE,6BAAK,SAAS,EAAE,MAAM,CAAC,gBAAgB,CAAC;YACtC,oBAAC,cAAc,IACb,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,gBAAgB,EACxB,aAAa,EAAE,0BAA0B,EACzC,kBAAkB,EAAE,sBAAsB,EAC1C,cAAc,EAAE,kBAAkB,EAClC,SAAS,EAAE,SAAS,GACpB;YACF,6BAAK,MAAM,EAAE,UAAU,EAAE,GAAG,EAAE,cAAc;gBAC1C,oBAAC,IAAI,IACH,MAAM,EAAE,gBAAgB,EACxB,QAAQ,EAAE,QAAQ,EAClB,aAAa,EAAE,aAAa,EAC5B,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,uBAAuB,EACrC,WAAW,EAAE,sBAAsB,EACnC,aAAa,EAAE,wBAAwB,EACvC,WAAW,EAAE,qBAAqB,EAClC,cAAc,EAAE,cAAc,EAC9B,YAAY,EAAE,aAAa,EAC3B,cAAc,EAAE,SAAS,GACzB,CACE,CACF,CACF,CACP,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React, { useEffect, useRef, useState } from 'react';\nimport { isSameMonth } from 'date-fns';\nimport styles from './styles.css.js';\nimport CalendarHeader from './header';\nimport Grid from './grid';\nimport { normalizeLocale, normalizeStartOfWeek } from '../internal/utils/locale';\nimport { formatDate, parseDate } from '../internal/utils/date-time';\nimport { fireNonCancelableEvent } from '../internal/events/index.js';\nimport checkControlled from '../internal/hooks/check-controlled/index.js';\nimport clsx from 'clsx';\nimport { CalendarProps } from './interfaces.js';\nimport { getBaseProps } from '../internal/base-component';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component/index.js';\nimport { getBaseDate } from './utils/navigation';\nimport { useDateCache } from '../internal/hooks/use-date-cache/index.js';\nimport { useUniqueId } from '../internal/hooks/use-unique-id/index.js';\nimport { useInternalI18n } from '../i18n/context.js';\n\nexport type DayIndex = 0 | 1 | 2 | 3 | 4 | 5 | 6;\n\nexport default function Calendar({\n value,\n locale = '',\n startOfWeek,\n isDateEnabled = () => true,\n ariaLabel,\n ariaLabelledby,\n ariaDescribedby,\n onChange,\n __internalRootRef,\n ...rest\n}: CalendarProps & InternalBaseComponentProps) {\n checkControlled('Calendar', 'value', value, 'onChange', onChange);\n\n const baseProps = getBaseProps(rest);\n const normalizedLocale = normalizeLocale('Calendar', locale);\n const normalizedStartOfWeek = normalizeStartOfWeek(startOfWeek, normalizedLocale);\n const gridWrapperRef = useRef<HTMLDivElement>(null);\n const [focusedDate, setFocusedDate] = useState<Date | null>(null);\n\n const valueDateCache = useDateCache();\n const focusedDateCache = useDateCache();\n\n // Set displayed date to value if defined or to current date otherwise.\n const parsedValue = value && value.length >= 4 ? parseDate(value) : null;\n const memoizedValue = parsedValue ? valueDateCache(parsedValue) : null;\n const defaultDisplayedDate = memoizedValue ?? new Date();\n const [displayedDate, setDisplayedDate] = useState(defaultDisplayedDate);\n\n const headingId = useUniqueId('calendar-heading');\n\n const i18n = useInternalI18n('calendar');\n const nextMonthAriaLabel = i18n('nextMonthAriaLabel', rest.nextMonthAriaLabel);\n const previousMonthAriaLabel = i18n('previousMonthAriaLabel', rest.previousMonthAriaLabel);\n const todayAriaLabel = i18n('todayAriaLabel', rest.todayAriaLabel);\n\n // Update displayed date if value changes.\n useEffect(() => {\n memoizedValue && setDisplayedDate(prev => (prev.getTime() !== memoizedValue.getTime() ? memoizedValue : prev));\n }, [memoizedValue]);\n\n const selectFocusedDate = (selected: Date | null, baseDate: Date): Date | null => {\n if (selected && isDateEnabled(selected) && isSameMonth(selected, baseDate)) {\n return selected;\n }\n const today = new Date();\n if (isDateEnabled(today) && isSameMonth(today, baseDate)) {\n return today;\n }\n if (isDateEnabled(baseDate)) {\n return baseDate;\n }\n return null;\n };\n\n const baseDate = getBaseDate(displayedDate, isDateEnabled);\n const focusableDate = focusedDate || selectFocusedDate(memoizedValue, baseDate);\n\n const onHeaderChangeMonthHandler = (date: Date) => {\n setDisplayedDate(date);\n setFocusedDate(null);\n };\n\n const onGridChangeMonthHandler = (newMonth: Date) => {\n setDisplayedDate(newMonth);\n setFocusedDate(null);\n };\n\n const onGridFocusDateHandler = (date: null | Date) => {\n if (date) {\n setFocusedDate(date ? focusedDateCache(date) : null);\n }\n };\n\n const onGridSelectDateHandler = (date: Date) => {\n fireNonCancelableEvent(onChange, { value: formatDate(date) });\n setFocusedDate(null);\n };\n\n const onGridBlur = (event: React.FocusEvent) => {\n const newFocusTargetIsInGrid = event.relatedTarget && gridWrapperRef.current?.contains(event.relatedTarget as Node);\n if (!newFocusTargetIsInGrid) {\n setFocusedDate(null);\n }\n };\n\n return (\n <div\n ref={__internalRootRef}\n {...baseProps}\n role=\"group\"\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledby}\n aria-describedby={ariaDescribedby}\n className={clsx(styles.root, styles.calendar, baseProps.className)}\n >\n <div className={styles['calendar-inner']}>\n <CalendarHeader\n baseDate={baseDate}\n locale={normalizedLocale}\n onChangeMonth={onHeaderChangeMonthHandler}\n previousMonthLabel={previousMonthAriaLabel}\n nextMonthLabel={nextMonthAriaLabel}\n headingId={headingId}\n />\n <div onBlur={onGridBlur} ref={gridWrapperRef}>\n <Grid\n locale={normalizedLocale}\n baseDate={baseDate}\n isDateEnabled={isDateEnabled}\n focusedDate={focusedDate}\n focusableDate={focusableDate}\n onSelectDate={onGridSelectDateHandler}\n onFocusDate={onGridFocusDateHandler}\n onChangeMonth={onGridChangeMonthHandler}\n startOfWeek={normalizedStartOfWeek}\n todayAriaLabel={todayAriaLabel}\n selectedDate={memoizedValue}\n ariaLabelledby={headingId}\n />\n </div>\n </div>\n </div>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"lib/default/","sources":["calendar/internal.tsx"],"names":[],"mappings":"AAA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E,gBAAgB,EACxB,QAAQ,EAAE,QAAQ,EAClB,aAAa,EAAE,aAAa,EAC5B,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,uBAAuB,EACrC,WAAW,EAAE,sBAAsB,EACnC,aAAa,EAAE,wBAAwB,EACvC,WAAW,EAAE,qBAAqB,EAClC,cAAc,EAAE,cAAc,EAC9B,YAAY,EAAE,aAAa,EAC3B,cAAc,EAAE,SAAS,GACzB,CACE,CACF,CACF,CACP,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React, { useEffect, useRef, useState } from 'react';\nimport { isSameMonth } from 'date-fns';\nimport styles from './styles.css.js';\nimport CalendarHeader from './header';\nimport Grid from './grid';\nimport { normalizeLocale, normalizeStartOfWeek } from '../internal/utils/locale';\nimport { formatDate, parseDate } from '../internal/utils/date-time';\nimport { fireNonCancelableEvent } from '../internal/events/index.js';\nimport checkControlled from '../internal/hooks/check-controlled/index.js';\nimport clsx from 'clsx';\nimport { CalendarProps } from './interfaces.js';\nimport { getBaseProps } from '../internal/base-component';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component/index.js';\nimport { getBaseDate } from './utils/navigation';\nimport { useDateCache } from '../internal/hooks/use-date-cache/index.js';\nimport { useUniqueId } from '../internal/hooks/use-unique-id/index.js';\nimport { useInternalI18n } from '../i18n/context.js';\n\nexport type DayIndex = 0 | 1 | 2 | 3 | 4 | 5 | 6;\n\nexport default function Calendar({\n value,\n locale = '',\n startOfWeek,\n isDateEnabled = () => true,\n ariaLabel,\n ariaLabelledby,\n ariaDescribedby,\n onChange,\n __internalRootRef,\n i18nStrings,\n ...rest\n}: CalendarProps & InternalBaseComponentProps) {\n checkControlled('Calendar', 'value', value, 'onChange', onChange);\n\n const baseProps = getBaseProps(rest);\n const normalizedLocale = normalizeLocale('Calendar', locale);\n const normalizedStartOfWeek = normalizeStartOfWeek(startOfWeek, normalizedLocale);\n const gridWrapperRef = useRef<HTMLDivElement>(null);\n const [focusedDate, setFocusedDate] = useState<Date | null>(null);\n\n const valueDateCache = useDateCache();\n const focusedDateCache = useDateCache();\n\n // Set displayed date to value if defined or to current date otherwise.\n const parsedValue = value && value.length >= 4 ? parseDate(value) : null;\n const memoizedValue = parsedValue ? valueDateCache(parsedValue) : null;\n const defaultDisplayedDate = memoizedValue ?? new Date();\n const [displayedDate, setDisplayedDate] = useState(defaultDisplayedDate);\n\n const headingId = useUniqueId('calendar-heading');\n\n const i18n = useInternalI18n('calendar');\n const nextMonthAriaLabel = i18n('nextMonthAriaLabel', i18nStrings?.nextMonthAriaLabel ?? rest.nextMonthAriaLabel);\n const previousMonthAriaLabel = i18n(\n 'previousMonthAriaLabel',\n i18nStrings?.previousMonthAriaLabel ?? rest.previousMonthAriaLabel\n );\n const todayAriaLabel = i18n('todayAriaLabel', i18nStrings?.todayAriaLabel ?? rest.todayAriaLabel);\n\n // Update displayed date if value changes.\n useEffect(() => {\n memoizedValue && setDisplayedDate(prev => (prev.getTime() !== memoizedValue.getTime() ? memoizedValue : prev));\n }, [memoizedValue]);\n\n const selectFocusedDate = (selected: Date | null, baseDate: Date): Date | null => {\n if (selected && isDateEnabled(selected) && isSameMonth(selected, baseDate)) {\n return selected;\n }\n const today = new Date();\n if (isDateEnabled(today) && isSameMonth(today, baseDate)) {\n return today;\n }\n if (isDateEnabled(baseDate)) {\n return baseDate;\n }\n return null;\n };\n\n const baseDate = getBaseDate(displayedDate, isDateEnabled);\n const focusableDate = focusedDate || selectFocusedDate(memoizedValue, baseDate);\n\n const onHeaderChangeMonthHandler = (date: Date) => {\n setDisplayedDate(date);\n setFocusedDate(null);\n };\n\n const onGridChangeMonthHandler = (newMonth: Date) => {\n setDisplayedDate(newMonth);\n setFocusedDate(null);\n };\n\n const onGridFocusDateHandler = (date: null | Date) => {\n if (date) {\n setFocusedDate(date ? focusedDateCache(date) : null);\n }\n };\n\n const onGridSelectDateHandler = (date: Date) => {\n fireNonCancelableEvent(onChange, { value: formatDate(date) });\n setFocusedDate(null);\n };\n\n const onGridBlur = (event: React.FocusEvent) => {\n const newFocusTargetIsInGrid = event.relatedTarget && gridWrapperRef.current?.contains(event.relatedTarget as Node);\n if (!newFocusTargetIsInGrid) {\n setFocusedDate(null);\n }\n };\n\n return (\n <div\n ref={__internalRootRef}\n {...baseProps}\n role=\"group\"\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledby}\n aria-describedby={ariaDescribedby}\n className={clsx(styles.root, styles.calendar, baseProps.className)}\n >\n <div className={styles['calendar-inner']}>\n <CalendarHeader\n baseDate={baseDate}\n locale={normalizedLocale}\n onChangeMonth={onHeaderChangeMonthHandler}\n previousMonthLabel={previousMonthAriaLabel}\n nextMonthLabel={nextMonthAriaLabel}\n headingId={headingId}\n />\n <div onBlur={onGridBlur} ref={gridWrapperRef}>\n <Grid\n locale={normalizedLocale}\n baseDate={baseDate}\n isDateEnabled={isDateEnabled}\n focusedDate={focusedDate}\n focusableDate={focusableDate}\n onSelectDate={onGridSelectDateHandler}\n onFocusDate={onGridFocusDateHandler}\n onChangeMonth={onGridChangeMonthHandler}\n startOfWeek={normalizedStartOfWeek}\n todayAriaLabel={todayAriaLabel}\n selectedDate={memoizedValue}\n ariaLabelledby={headingId}\n />\n </div>\n </div>\n </div>\n );\n}\n"]}
|
|
@@ -43,6 +43,9 @@ export declare const LightThemes: readonly [{
|
|
|
43
43
|
}, {
|
|
44
44
|
readonly value: "sqlserver";
|
|
45
45
|
readonly label: "SQL Server";
|
|
46
|
+
}, {
|
|
47
|
+
readonly value: "cloud_editor";
|
|
48
|
+
readonly label: "CloudEditor";
|
|
46
49
|
}];
|
|
47
50
|
export declare const DarkThemes: readonly [{
|
|
48
51
|
readonly value: "ambiance";
|
|
@@ -113,5 +116,8 @@ export declare const DarkThemes: readonly [{
|
|
|
113
116
|
}, {
|
|
114
117
|
readonly value: "vibrant_ink";
|
|
115
118
|
readonly label: "Vibrant Ink";
|
|
119
|
+
}, {
|
|
120
|
+
readonly value: "cloud_editor_dark";
|
|
121
|
+
readonly label: "CloudEditor Dark";
|
|
116
122
|
}];
|
|
117
123
|
//# sourceMappingURL=ace-themes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ace-themes.d.ts","sourceRoot":"lib/default/","sources":["code-editor/ace-themes.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ace-themes.d.ts","sourceRoot":"lib/default/","sources":["code-editor/ace-themes.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiBd,CAAC;AAEX,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyBb,CAAC"}
|
|
@@ -16,6 +16,7 @@ export const LightThemes = [
|
|
|
16
16
|
{ value: 'kuroir', label: 'Kuroir' },
|
|
17
17
|
{ value: 'katzenmilch', label: 'KatzenMilch' },
|
|
18
18
|
{ value: 'sqlserver', label: 'SQL Server' },
|
|
19
|
+
{ value: 'cloud_editor', label: 'CloudEditor' },
|
|
19
20
|
];
|
|
20
21
|
export const DarkThemes = [
|
|
21
22
|
{ value: 'ambiance', label: 'Ambiance' },
|
|
@@ -41,5 +42,6 @@ export const DarkThemes = [
|
|
|
41
42
|
{ value: 'tomorrow_night_eighties', label: 'Tomorrow Night 80s' },
|
|
42
43
|
{ value: 'twilight', label: 'Twilight' },
|
|
43
44
|
{ value: 'vibrant_ink', label: 'Vibrant Ink' },
|
|
45
|
+
{ value: 'cloud_editor_dark', label: 'CloudEditor Dark' },
|
|
44
46
|
];
|
|
45
47
|
//# sourceMappingURL=ace-themes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ace-themes.js","sourceRoot":"lib/default/","sources":["code-editor/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KAAK,EAAE,uBAAuB,EAAE;IAClE,EAAE,KAAK,EAAE,yBAAyB,EAAE,KAAK,EAAE,oBAAoB,EAAE;IACjE,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE;IACxC,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,aAAa,EAAE;IAC9C,EAAE,KAAK,EAAE,mBAAmB,EAAE,KAAK,EAAE,kBAAkB,EAAE;CACjD,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nexport const LightThemes = [\n { value: 'chrome', label: 'Chrome' },\n { value: 'clouds', label: 'Clouds' },\n { value: 'crimson_editor', label: 'Crimson Editor' },\n { value: 'dawn', label: 'Dawn' },\n { value: 'dreamweaver', label: 'Dreamweaver' },\n { value: 'eclipse', label: 'Eclipse' },\n { value: 'github', label: 'GitHub' },\n { value: 'iplastic', label: 'IPlastic' },\n { value: 'solarized_light', label: 'Solarized Light' },\n { value: 'textmate', label: 'TextMate' },\n { value: 'tomorrow', label: 'Tomorrow' },\n { value: 'xcode', label: 'Xcode' },\n { value: 'kuroir', label: 'Kuroir' },\n { value: 'katzenmilch', label: 'KatzenMilch' },\n { value: 'sqlserver', label: 'SQL Server' },\n { value: 'cloud_editor', label: 'CloudEditor' },\n] as const;\n\nexport const DarkThemes = [\n { value: 'ambiance', label: 'Ambiance' },\n { value: 'chaos', label: 'Chaos' },\n { value: 'clouds_midnight', label: 'Clouds Midnight' },\n { value: 'dracula', label: 'Dracula' },\n { value: 'cobalt', label: 'Cobalt' },\n { value: 'gruvbox', label: 'Gruvbox' },\n { value: 'gob', label: 'Green on Black' },\n { value: 'idle_fingers', label: 'idle Fingers' },\n { value: 'kr_theme', label: 'krTheme' },\n { value: 'merbivore', label: 'Merbivore' },\n { value: 'merbivore_soft', label: 'Merbivore Soft' },\n { value: 'mono_industrial', label: 'Mono Industrial' },\n { value: 'monokai', label: 'Monokai' },\n { value: 'nord_dark', label: 'Nord Dark' },\n { value: 'pastel_on_dark', label: 'Pastel on dark' },\n { value: 'solarized_dark', label: 'Solarized Dark' },\n { value: 'terminal', label: 'Terminal' },\n { value: 'tomorrow_night', label: 'Tomorrow Night' },\n { value: 'tomorrow_night_blue', label: 'Tomorrow Night Blue' },\n { value: 'tomorrow_night_bright', label: 'Tomorrow Night Bright' },\n { value: 'tomorrow_night_eighties', label: 'Tomorrow Night 80s' },\n { value: 'twilight', label: 'Twilight' },\n { value: 'vibrant_ink', label: 'Vibrant Ink' },\n { value: 'cloud_editor_dark', label: 'CloudEditor Dark' },\n] as const;\n"]}
|
package/code-editor/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import { KeyCode } from '../internal/keycode';
|
|
|
9
9
|
import { useUniqueId } from '../internal/hooks/use-unique-id';
|
|
10
10
|
import { Pane } from './pane';
|
|
11
11
|
import { useChangeEffect } from './listeners';
|
|
12
|
-
import {
|
|
12
|
+
import { getLanguageLabel, getDefaultTheme, getDefaultSupportedThemes } from './util';
|
|
13
13
|
import { fireNonCancelableEvent } from '../internal/events';
|
|
14
14
|
import { setupEditor } from './setup-editor';
|
|
15
15
|
import { ResizableBox } from './resizable-box';
|
|
@@ -69,7 +69,7 @@ const CodeEditor = forwardRef((props, ref) => {
|
|
|
69
69
|
useSyncEditorValue(editor, value);
|
|
70
70
|
useSyncEditorLanguage(editor, language);
|
|
71
71
|
useSyncEditorWrapLines(editor, preferences === null || preferences === void 0 ? void 0 : preferences.wrapLines);
|
|
72
|
-
const defaultTheme = mode
|
|
72
|
+
const defaultTheme = getDefaultTheme(ace, mode);
|
|
73
73
|
useSyncEditorTheme(editor, (_a = preferences === null || preferences === void 0 ? void 0 : preferences.theme) !== null && _a !== void 0 ? _a : defaultTheme);
|
|
74
74
|
// Change listeners
|
|
75
75
|
useChangeEffect(editor, props.onChange, props.onDelayedChange);
|
|
@@ -140,7 +140,7 @@ const CodeEditor = forwardRef((props, ref) => {
|
|
|
140
140
|
React.createElement("div", { role: "group", "aria-label": i18n('i18nStrings.statusBarGroupAriaLabel', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.statusBarGroupAriaLabel) },
|
|
141
141
|
React.createElement(StatusBar, { languageLabel: languageLabel, cursorPosition: i18n('i18nStrings.cursorPosition', (_b = i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.cursorPosition) === null || _b === void 0 ? void 0 : _b.call(i18nStrings, cursorPosition.row + 1, cursorPosition.column + 1), format => format({ row: cursorPosition.row + 1, column: cursorPosition.column + 1 })), errorCount: errorCount, warningCount: warningCount, paneStatus: paneStatus, onErrorPaneToggle: onErrorPaneToggle, onWarningPaneToggle: onWarningPaneToggle, onTabFocus: onTabFocus, onTabBlur: onTabBlur, errorsTabRef: errorsTabRef, warningsTabRef: warningsTabRef, i18nStrings: i18nStrings, isTabFocused: isTabFocused, paneId: isPaneVisible ? paneId : undefined, onPreferencesOpen: onPreferencesOpen, isRefresh: isRefresh }),
|
|
142
142
|
React.createElement(Pane, { id: paneId, visible: isPaneVisible, annotations: currentAnnotations, highlighted: highlightedAnnotation, onAnnotationClick: onAnnotationClick, onAnnotationClear: onAnnotationClear, onClose: onPaneClose, cursorPositionLabel: i18n('i18nStrings.cursorPosition', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.cursorPosition, format => (row, column) => format({ row, column })), closeButtonAriaLabel: i18n('i18nStrings.paneCloseButtonAriaLabel', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.paneCloseButtonAriaLabel) })),
|
|
143
|
-
isPreferencesModalVisible && (React.createElement(PreferencesModal, { onConfirm: onPreferencesConfirm, onDismiss: onPreferencesDismiss, themes: themes, preferences: preferences, defaultTheme: defaultTheme, i18nStrings: {
|
|
143
|
+
isPreferencesModalVisible && (React.createElement(PreferencesModal, { onConfirm: onPreferencesConfirm, onDismiss: onPreferencesDismiss, themes: themes !== null && themes !== void 0 ? themes : getDefaultSupportedThemes(ace), preferences: preferences, defaultTheme: defaultTheme, i18nStrings: {
|
|
144
144
|
header: i18n('i18nStrings.preferencesModalHeader', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.preferencesModalHeader),
|
|
145
145
|
cancel: i18n('i18nStrings.preferencesModalCancel', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.preferencesModalCancel),
|
|
146
146
|
confirm: i18n('i18nStrings.preferencesModalConfirm', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.preferencesModalConfirm),
|
package/code-editor/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"lib/default/","sources":["code-editor/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAE7F,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAEhE,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAE9D,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAc,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAC/F,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,gBAAgB,MAAM,qBAAqB,CAAC;AACnD,OAAO,aAAa,MA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AAI,CAAC,mCAAmC,EAAE,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,qBAAqB,CAAC;oBACpF,WAAW,EAAE,IAAI,CAAC,yCAAyC,EAAE,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,2BAA2B,CAAC;oBACtG,UAAU,EAAE,IAAI,CAAC,wCAAwC,EAAE,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,0BAA0B,CAAC;oBACnG,uBAAuB,EAAE,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,uCAAuC;oBAC7E,4BAA4B,EAAE,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,4CAA4C;oBACvF,yBAAyB,EAAE,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,yCAAyC;iBAClF,GACD,CACH,CACA,CACJ,CACG,CACP,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,gBAAgB,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;AAC3C,eAAe,UAAU,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useCallback, useEffect, useMemo, useRef, useState, forwardRef } from 'react';\nimport { Ace } from 'ace-builds';\nimport clsx from 'clsx';\nimport { useMergeRefs } from '../internal/hooks/use-merge-refs';\n\nimport { getBaseProps } from '../internal/base-component';\nimport { KeyCode } from '../internal/keycode';\nimport { useUniqueId } from '../internal/hooks/use-unique-id';\nimport { CodeEditorProps } from './interfaces';\nimport { Pane } from './pane';\nimport { useChangeEffect } from './listeners';\nimport { DEFAULT_DARK_THEME, DEFAULT_LIGHT_THEME, PaneStatus, getLanguageLabel } from './util';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport { setupEditor } from './setup-editor';\nimport { ResizableBox } from './resizable-box';\nimport PreferencesModal from './preferences-modal';\nimport LoadingScreen from './loading-screen';\nimport ErrorScreen from './error-screen';\n\nimport useBaseComponent from '../internal/hooks/use-base-component';\nimport useForwardFocus from '../internal/hooks/forward-focus';\nimport { applyDisplayName } from '../internal/utils/apply-display-name';\nimport { useCurrentMode } from '@cloudscape-design/component-toolkit/internal';\nimport { useInternalI18n } from '../i18n/context';\nimport { StatusBar } from './status-bar';\nimport { useFormFieldContext } from '../internal/context/form-field-context';\nimport { useVisualRefresh } from '../internal/hooks/use-visual-mode';\nimport { useControllable } from '../internal/hooks/use-controllable';\nimport LiveRegion from '../internal/components/live-region';\n\nimport styles from './styles.css.js';\nimport { useContainerQuery } from '@cloudscape-design/component-toolkit';\nimport {\n useEditor,\n useSyncEditorSize,\n useSyncEditorLabels,\n useSyncEditorValue,\n useSyncEditorLanguage,\n useSyncEditorWrapLines,\n useSyncEditorTheme,\n} from './use-editor';\n\nexport { CodeEditorProps };\n\nconst CodeEditor = forwardRef((props: CodeEditorProps, ref: React.Ref<CodeEditorProps.Ref>) => {\n const { __internalRootRef } = useBaseComponent('CodeEditor');\n const { controlId, ariaLabelledby, ariaDescribedby } = useFormFieldContext(props);\n const {\n ace,\n value,\n language,\n i18nStrings,\n editorContentHeight,\n onEditorContentResize,\n ariaLabel,\n languageLabel: customLanguageLabel,\n preferences,\n loading,\n themes,\n ...rest\n } = props;\n const [editorHeight = 480, setEditorHeight] = useControllable(editorContentHeight, onEditorContentResize, 480, {\n componentName: 'code-editor',\n changeHandler: 'onEditorContentResize',\n controlledProp: 'editorContentHeight',\n });\n const mode = useCurrentMode(__internalRootRef);\n const isRefresh = useVisualRefresh();\n const baseProps = getBaseProps(rest);\n const i18n = useInternalI18n('code-editor');\n\n const errorsTabRef = useRef<HTMLButtonElement>(null);\n const warningsTabRef = useRef<HTMLButtonElement>(null);\n const [codeEditorWidth, codeEditorMeasureRef] = useContainerQuery(rect => rect.contentBoxWidth);\n const mergedRef = useMergeRefs(codeEditorMeasureRef, __internalRootRef);\n\n const paneId = useUniqueId('code-editor-pane');\n\n const [paneStatus, setPaneStatus] = useState<PaneStatus>('hidden');\n const [annotations, setAnnotations] = useState<Ace.Annotation[]>([]);\n const [highlightedAnnotation, setHighlightedAnnotation] = useState<Ace.Annotation>();\n const [cursorPosition, setCursorPosition] = useState<Ace.Point>({ row: 0, column: 0 });\n const [isTabFocused, setTabFocused] = useState<boolean>(false);\n\n const { editorRef, editor } = useEditor(ace, loading);\n\n useForwardFocus(ref, editorRef);\n\n useEffect(() => {\n if (!ace || !editor) {\n return;\n }\n\n setupEditor(ace, editor, setAnnotations, setCursorPosition, setHighlightedAnnotation, setPaneStatus);\n\n return () => {\n editor?.destroy();\n };\n }, [ace, editor]);\n\n useSyncEditorLabels(editor, { controlId, ariaLabel, ariaLabelledby, ariaDescribedby });\n\n const { onResize } = useSyncEditorSize(editor, { width: codeEditorWidth, height: editorContentHeight });\n\n useSyncEditorValue(editor, value);\n\n useSyncEditorLanguage(editor, language);\n\n useSyncEditorWrapLines(editor, preferences?.wrapLines);\n\n const defaultTheme = mode === 'dark' ? DEFAULT_DARK_THEME : DEFAULT_LIGHT_THEME;\n useSyncEditorTheme(editor, preferences?.theme ?? defaultTheme);\n\n // Change listeners\n useChangeEffect(editor, props.onChange, props.onDelayedChange);\n\n // Hide error panel when there are no errors to show.\n useEffect(() => {\n if (annotations.length === 0) {\n setPaneStatus('hidden');\n }\n\n if (props.onValidate) {\n fireNonCancelableEvent(props.onValidate, { annotations });\n }\n }, [annotations, props.onValidate]);\n\n const languageLabel = customLanguageLabel ?? getLanguageLabel(language);\n\n const errorCount = annotations.filter(a => a.type === 'error').length;\n const warningCount = annotations.filter(a => a.type === 'warning').length;\n const currentAnnotations = useMemo(() => annotations.filter(a => a.type === paneStatus), [annotations, paneStatus]);\n\n /*\n * Callbacks\n */\n\n const onEditorKeydown = useCallback(\n (e: React.KeyboardEvent) => {\n if (editor && e.target === editor.container && e.keyCode === KeyCode.enter) {\n e.stopPropagation();\n e.preventDefault();\n editor.focus();\n }\n },\n [editor]\n );\n\n const onTabFocus = useCallback(() => setTabFocused(true), []);\n const onTabBlur = useCallback(() => setTabFocused(false), []);\n\n const onErrorPaneToggle = useCallback(() => {\n setPaneStatus(paneStatus !== 'error' ? 'error' : 'hidden');\n }, [paneStatus]);\n\n const onWarningPaneToggle = useCallback(() => {\n setPaneStatus(paneStatus !== 'warning' ? 'warning' : 'hidden');\n }, [paneStatus]);\n\n const onPaneClose = () => {\n setPaneStatus('hidden');\n };\n\n const onAnnotationClick = ({ row = 0, column = 0 }: Ace.Annotation) => {\n if (!editor) {\n return;\n }\n editor.focus();\n editor.gotoLine(row + 1, column, false);\n setHighlightedAnnotation(undefined);\n };\n\n const onAnnotationClear = useCallback(() => {\n setHighlightedAnnotation(undefined);\n }, []);\n\n const [isPreferencesModalVisible, setPreferencesModalVisible] = useState(false);\n const onPreferencesOpen = () => setPreferencesModalVisible(true);\n const onPreferencesConfirm = (p: CodeEditorProps.Preferences) => {\n fireNonCancelableEvent(props.onPreferencesChange, p);\n setPreferencesModalVisible(false);\n };\n const onPreferencesDismiss = () => setPreferencesModalVisible(false);\n\n const isPaneVisible = paneStatus !== 'hidden';\n\n return (\n <div\n {...baseProps}\n className={clsx(styles['code-editor'], baseProps.className, { [styles['code-editor-refresh']]: isRefresh })}\n ref={mergedRef}\n >\n {loading && (\n <LoadingScreen>\n <LiveRegion visible={true}>{i18n('i18nStrings.loadingState', i18nStrings?.loadingState)}</LiveRegion>\n </LoadingScreen>\n )}\n\n {!ace && !loading && (\n <ErrorScreen\n recoveryText={i18n('i18nStrings.errorStateRecovery', i18nStrings?.errorStateRecovery)}\n onRecoveryClick={props.onRecoveryClick}\n >\n {i18n('i18nStrings.errorState', i18nStrings?.errorState)}\n </ErrorScreen>\n )}\n\n {ace && !loading && (\n <>\n <ResizableBox\n height={Math.max(editorHeight, 20)}\n minHeight={20}\n onResize={height => {\n setEditorHeight(height);\n onResize();\n fireNonCancelableEvent(onEditorContentResize, { height });\n }}\n >\n <div\n ref={editorRef}\n className={clsx(styles.editor, styles.ace, isRefresh && styles['editor-refresh'])}\n onKeyDown={onEditorKeydown}\n tabIndex={0}\n role=\"group\"\n aria-label={i18n('i18nStrings.editorGroupAriaLabel', i18nStrings?.editorGroupAriaLabel)}\n />\n </ResizableBox>\n <div\n role=\"group\"\n aria-label={i18n('i18nStrings.statusBarGroupAriaLabel', i18nStrings?.statusBarGroupAriaLabel)}\n >\n <StatusBar\n languageLabel={languageLabel}\n cursorPosition={i18n(\n 'i18nStrings.cursorPosition',\n i18nStrings?.cursorPosition?.(cursorPosition.row + 1, cursorPosition.column + 1),\n format => format({ row: cursorPosition.row + 1, column: cursorPosition.column + 1 })\n )}\n errorCount={errorCount}\n warningCount={warningCount}\n paneStatus={paneStatus}\n onErrorPaneToggle={onErrorPaneToggle}\n onWarningPaneToggle={onWarningPaneToggle}\n onTabFocus={onTabFocus}\n onTabBlur={onTabBlur}\n errorsTabRef={errorsTabRef}\n warningsTabRef={warningsTabRef}\n i18nStrings={i18nStrings}\n isTabFocused={isTabFocused}\n paneId={isPaneVisible ? paneId : undefined}\n onPreferencesOpen={onPreferencesOpen}\n isRefresh={isRefresh}\n />\n <Pane\n id={paneId}\n visible={isPaneVisible}\n annotations={currentAnnotations}\n highlighted={highlightedAnnotation}\n onAnnotationClick={onAnnotationClick}\n onAnnotationClear={onAnnotationClear}\n onClose={onPaneClose}\n cursorPositionLabel={i18n(\n 'i18nStrings.cursorPosition',\n i18nStrings?.cursorPosition,\n format => (row, column) => format({ row, column })\n )}\n closeButtonAriaLabel={i18n('i18nStrings.paneCloseButtonAriaLabel', i18nStrings?.paneCloseButtonAriaLabel)}\n />\n </div>\n {isPreferencesModalVisible && (\n <PreferencesModal\n onConfirm={onPreferencesConfirm}\n onDismiss={onPreferencesDismiss}\n themes={themes}\n preferences={preferences}\n defaultTheme={defaultTheme}\n i18nStrings={{\n header: i18n('i18nStrings.preferencesModalHeader', i18nStrings?.preferencesModalHeader),\n cancel: i18n('i18nStrings.preferencesModalCancel', i18nStrings?.preferencesModalCancel),\n confirm: i18n('i18nStrings.preferencesModalConfirm', i18nStrings?.preferencesModalConfirm),\n wrapLines: i18n('i18nStrings.preferencesModalWrapLines', i18nStrings?.preferencesModalWrapLines),\n theme: i18n('i18nStrings.preferencesModalTheme', i18nStrings?.preferencesModalTheme),\n lightThemes: i18n('i18nStrings.preferencesModalLightThemes', i18nStrings?.preferencesModalLightThemes),\n darkThemes: i18n('i18nStrings.preferencesModalDarkThemes', i18nStrings?.preferencesModalDarkThemes),\n themeFilteringAriaLabel: i18nStrings?.preferencesModalThemeFilteringAriaLabel,\n themeFilteringClearAriaLabel: i18nStrings?.preferencesModalThemeFilteringClearAriaLabel,\n themeFilteringPlaceholder: i18nStrings?.preferencesModalThemeFilteringPlaceholder,\n }}\n />\n )}\n </>\n )}\n </div>\n );\n});\n\napplyDisplayName(CodeEditor, 'CodeEditor');\nexport default CodeEditor;\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"lib/default/","sources":["code-editor/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAE7F,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAEhE,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAE9D,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAc,gBAAgB,EAAE,eAAe,EAAE,yBAAyB,EAAE,MAAM,QAAQ,CAAC;AAClG,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAA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,uBAAX,WAAW,CAAE,uBAAuB,CAAC;oBAC1F,SAAS,EAAE,IAAI,CAAC,uCAAuC,EAAE,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,yBAAyB,CAAC;oBAChG,KAAK,EAAE,IAAI,CAAC,mCAAmC,EAAE,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,qBAAqB,CAAC;oBACpF,WAAW,EAAE,IAAI,CAAC,yCAAyC,EAAE,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,2BAA2B,CAAC;oBACtG,UAAU,EAAE,IAAI,CAAC,wCAAwC,EAAE,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,0BAA0B,CAAC;oBACnG,uBAAuB,EAAE,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,uCAAuC;oBAC7E,4BAA4B,EAAE,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,4CAA4C;oBACvF,yBAAyB,EAAE,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,yCAAyC;iBAClF,GACD,CACH,CACA,CACJ,CACG,CACP,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,gBAAgB,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;AAC3C,eAAe,UAAU,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useCallback, useEffect, useMemo, useRef, useState, forwardRef } from 'react';\nimport { Ace } from 'ace-builds';\nimport clsx from 'clsx';\nimport { useMergeRefs } from '../internal/hooks/use-merge-refs';\n\nimport { getBaseProps } from '../internal/base-component';\nimport { KeyCode } from '../internal/keycode';\nimport { useUniqueId } from '../internal/hooks/use-unique-id';\nimport { CodeEditorProps } from './interfaces';\nimport { Pane } from './pane';\nimport { useChangeEffect } from './listeners';\nimport { PaneStatus, getLanguageLabel, getDefaultTheme, getDefaultSupportedThemes } from './util';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport { setupEditor } from './setup-editor';\nimport { ResizableBox } from './resizable-box';\nimport PreferencesModal from './preferences-modal';\nimport LoadingScreen from './loading-screen';\nimport ErrorScreen from './error-screen';\n\nimport useBaseComponent from '../internal/hooks/use-base-component';\nimport useForwardFocus from '../internal/hooks/forward-focus';\nimport { applyDisplayName } from '../internal/utils/apply-display-name';\nimport { useCurrentMode } from '@cloudscape-design/component-toolkit/internal';\nimport { useInternalI18n } from '../i18n/context';\nimport { StatusBar } from './status-bar';\nimport { useFormFieldContext } from '../internal/context/form-field-context';\nimport { useVisualRefresh } from '../internal/hooks/use-visual-mode';\nimport { useControllable } from '../internal/hooks/use-controllable';\nimport LiveRegion from '../internal/components/live-region';\n\nimport styles from './styles.css.js';\nimport { useContainerQuery } from '@cloudscape-design/component-toolkit';\nimport {\n useEditor,\n useSyncEditorSize,\n useSyncEditorLabels,\n useSyncEditorValue,\n useSyncEditorLanguage,\n useSyncEditorWrapLines,\n useSyncEditorTheme,\n} from './use-editor';\n\nexport { CodeEditorProps };\n\nconst CodeEditor = forwardRef((props: CodeEditorProps, ref: React.Ref<CodeEditorProps.Ref>) => {\n const { __internalRootRef } = useBaseComponent('CodeEditor');\n const { controlId, ariaLabelledby, ariaDescribedby } = useFormFieldContext(props);\n const {\n ace,\n value,\n language,\n i18nStrings,\n editorContentHeight,\n onEditorContentResize,\n ariaLabel,\n languageLabel: customLanguageLabel,\n preferences,\n loading,\n themes,\n ...rest\n } = props;\n const [editorHeight = 480, setEditorHeight] = useControllable(editorContentHeight, onEditorContentResize, 480, {\n componentName: 'code-editor',\n changeHandler: 'onEditorContentResize',\n controlledProp: 'editorContentHeight',\n });\n const mode = useCurrentMode(__internalRootRef);\n const isRefresh = useVisualRefresh();\n const baseProps = getBaseProps(rest);\n const i18n = useInternalI18n('code-editor');\n\n const errorsTabRef = useRef<HTMLButtonElement>(null);\n const warningsTabRef = useRef<HTMLButtonElement>(null);\n const [codeEditorWidth, codeEditorMeasureRef] = useContainerQuery(rect => rect.contentBoxWidth);\n const mergedRef = useMergeRefs(codeEditorMeasureRef, __internalRootRef);\n\n const paneId = useUniqueId('code-editor-pane');\n\n const [paneStatus, setPaneStatus] = useState<PaneStatus>('hidden');\n const [annotations, setAnnotations] = useState<Ace.Annotation[]>([]);\n const [highlightedAnnotation, setHighlightedAnnotation] = useState<Ace.Annotation>();\n const [cursorPosition, setCursorPosition] = useState<Ace.Point>({ row: 0, column: 0 });\n const [isTabFocused, setTabFocused] = useState<boolean>(false);\n\n const { editorRef, editor } = useEditor(ace, loading);\n\n useForwardFocus(ref, editorRef);\n\n useEffect(() => {\n if (!ace || !editor) {\n return;\n }\n\n setupEditor(ace, editor, setAnnotations, setCursorPosition, setHighlightedAnnotation, setPaneStatus);\n\n return () => {\n editor?.destroy();\n };\n }, [ace, editor]);\n\n useSyncEditorLabels(editor, { controlId, ariaLabel, ariaLabelledby, ariaDescribedby });\n\n const { onResize } = useSyncEditorSize(editor, { width: codeEditorWidth, height: editorContentHeight });\n\n useSyncEditorValue(editor, value);\n\n useSyncEditorLanguage(editor, language);\n\n useSyncEditorWrapLines(editor, preferences?.wrapLines);\n\n const defaultTheme = getDefaultTheme(ace, mode);\n useSyncEditorTheme(editor, preferences?.theme ?? defaultTheme);\n\n // Change listeners\n useChangeEffect(editor, props.onChange, props.onDelayedChange);\n\n // Hide error panel when there are no errors to show.\n useEffect(() => {\n if (annotations.length === 0) {\n setPaneStatus('hidden');\n }\n\n if (props.onValidate) {\n fireNonCancelableEvent(props.onValidate, { annotations });\n }\n }, [annotations, props.onValidate]);\n\n const languageLabel = customLanguageLabel ?? getLanguageLabel(language);\n\n const errorCount = annotations.filter(a => a.type === 'error').length;\n const warningCount = annotations.filter(a => a.type === 'warning').length;\n const currentAnnotations = useMemo(() => annotations.filter(a => a.type === paneStatus), [annotations, paneStatus]);\n\n /*\n * Callbacks\n */\n\n const onEditorKeydown = useCallback(\n (e: React.KeyboardEvent) => {\n if (editor && e.target === editor.container && e.keyCode === KeyCode.enter) {\n e.stopPropagation();\n e.preventDefault();\n editor.focus();\n }\n },\n [editor]\n );\n\n const onTabFocus = useCallback(() => setTabFocused(true), []);\n const onTabBlur = useCallback(() => setTabFocused(false), []);\n\n const onErrorPaneToggle = useCallback(() => {\n setPaneStatus(paneStatus !== 'error' ? 'error' : 'hidden');\n }, [paneStatus]);\n\n const onWarningPaneToggle = useCallback(() => {\n setPaneStatus(paneStatus !== 'warning' ? 'warning' : 'hidden');\n }, [paneStatus]);\n\n const onPaneClose = () => {\n setPaneStatus('hidden');\n };\n\n const onAnnotationClick = ({ row = 0, column = 0 }: Ace.Annotation) => {\n if (!editor) {\n return;\n }\n editor.focus();\n editor.gotoLine(row + 1, column, false);\n setHighlightedAnnotation(undefined);\n };\n\n const onAnnotationClear = useCallback(() => {\n setHighlightedAnnotation(undefined);\n }, []);\n\n const [isPreferencesModalVisible, setPreferencesModalVisible] = useState(false);\n const onPreferencesOpen = () => setPreferencesModalVisible(true);\n const onPreferencesConfirm = (p: CodeEditorProps.Preferences) => {\n fireNonCancelableEvent(props.onPreferencesChange, p);\n setPreferencesModalVisible(false);\n };\n const onPreferencesDismiss = () => setPreferencesModalVisible(false);\n\n const isPaneVisible = paneStatus !== 'hidden';\n\n return (\n <div\n {...baseProps}\n className={clsx(styles['code-editor'], baseProps.className, { [styles['code-editor-refresh']]: isRefresh })}\n ref={mergedRef}\n >\n {loading && (\n <LoadingScreen>\n <LiveRegion visible={true}>{i18n('i18nStrings.loadingState', i18nStrings?.loadingState)}</LiveRegion>\n </LoadingScreen>\n )}\n\n {!ace && !loading && (\n <ErrorScreen\n recoveryText={i18n('i18nStrings.errorStateRecovery', i18nStrings?.errorStateRecovery)}\n onRecoveryClick={props.onRecoveryClick}\n >\n {i18n('i18nStrings.errorState', i18nStrings?.errorState)}\n </ErrorScreen>\n )}\n\n {ace && !loading && (\n <>\n <ResizableBox\n height={Math.max(editorHeight, 20)}\n minHeight={20}\n onResize={height => {\n setEditorHeight(height);\n onResize();\n fireNonCancelableEvent(onEditorContentResize, { height });\n }}\n >\n <div\n ref={editorRef}\n className={clsx(styles.editor, styles.ace, isRefresh && styles['editor-refresh'])}\n onKeyDown={onEditorKeydown}\n tabIndex={0}\n role=\"group\"\n aria-label={i18n('i18nStrings.editorGroupAriaLabel', i18nStrings?.editorGroupAriaLabel)}\n />\n </ResizableBox>\n <div\n role=\"group\"\n aria-label={i18n('i18nStrings.statusBarGroupAriaLabel', i18nStrings?.statusBarGroupAriaLabel)}\n >\n <StatusBar\n languageLabel={languageLabel}\n cursorPosition={i18n(\n 'i18nStrings.cursorPosition',\n i18nStrings?.cursorPosition?.(cursorPosition.row + 1, cursorPosition.column + 1),\n format => format({ row: cursorPosition.row + 1, column: cursorPosition.column + 1 })\n )}\n errorCount={errorCount}\n warningCount={warningCount}\n paneStatus={paneStatus}\n onErrorPaneToggle={onErrorPaneToggle}\n onWarningPaneToggle={onWarningPaneToggle}\n onTabFocus={onTabFocus}\n onTabBlur={onTabBlur}\n errorsTabRef={errorsTabRef}\n warningsTabRef={warningsTabRef}\n i18nStrings={i18nStrings}\n isTabFocused={isTabFocused}\n paneId={isPaneVisible ? paneId : undefined}\n onPreferencesOpen={onPreferencesOpen}\n isRefresh={isRefresh}\n />\n <Pane\n id={paneId}\n visible={isPaneVisible}\n annotations={currentAnnotations}\n highlighted={highlightedAnnotation}\n onAnnotationClick={onAnnotationClick}\n onAnnotationClear={onAnnotationClear}\n onClose={onPaneClose}\n cursorPositionLabel={i18n(\n 'i18nStrings.cursorPosition',\n i18nStrings?.cursorPosition,\n format => (row, column) => format({ row, column })\n )}\n closeButtonAriaLabel={i18n('i18nStrings.paneCloseButtonAriaLabel', i18nStrings?.paneCloseButtonAriaLabel)}\n />\n </div>\n {isPreferencesModalVisible && (\n <PreferencesModal\n onConfirm={onPreferencesConfirm}\n onDismiss={onPreferencesDismiss}\n themes={themes ?? getDefaultSupportedThemes(ace)}\n preferences={preferences}\n defaultTheme={defaultTheme}\n i18nStrings={{\n header: i18n('i18nStrings.preferencesModalHeader', i18nStrings?.preferencesModalHeader),\n cancel: i18n('i18nStrings.preferencesModalCancel', i18nStrings?.preferencesModalCancel),\n confirm: i18n('i18nStrings.preferencesModalConfirm', i18nStrings?.preferencesModalConfirm),\n wrapLines: i18n('i18nStrings.preferencesModalWrapLines', i18nStrings?.preferencesModalWrapLines),\n theme: i18n('i18nStrings.preferencesModalTheme', i18nStrings?.preferencesModalTheme),\n lightThemes: i18n('i18nStrings.preferencesModalLightThemes', i18nStrings?.preferencesModalLightThemes),\n darkThemes: i18n('i18nStrings.preferencesModalDarkThemes', i18nStrings?.preferencesModalDarkThemes),\n themeFilteringAriaLabel: i18nStrings?.preferencesModalThemeFilteringAriaLabel,\n themeFilteringClearAriaLabel: i18nStrings?.preferencesModalThemeFilteringClearAriaLabel,\n themeFilteringPlaceholder: i18nStrings?.preferencesModalThemeFilteringPlaceholder,\n }}\n />\n )}\n </>\n )}\n </div>\n );\n});\n\napplyDisplayName(CodeEditor, 'CodeEditor');\nexport default CodeEditor;\n"]}
|
|
@@ -15,7 +15,7 @@ interface PreferencesModali18nStrings {
|
|
|
15
15
|
interface PreferencesModalProps {
|
|
16
16
|
preferences?: Partial<CodeEditorProps.Preferences>;
|
|
17
17
|
i18nStrings: PreferencesModali18nStrings;
|
|
18
|
-
themes: CodeEditorProps
|
|
18
|
+
themes: CodeEditorProps.AvailableThemes;
|
|
19
19
|
defaultTheme: CodeEditorProps.Theme;
|
|
20
20
|
onConfirm: (preferences: CodeEditorProps.Preferences) => void;
|
|
21
21
|
onDismiss: () => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preferences-modal.d.ts","sourceRoot":"lib/default/","sources":["code-editor/preferences-modal.tsx"],"names":[],"mappings":";AAeA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,UAAU,2BAA2B;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE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K,IAAI,CAAC;IAC9D,SAAS,EAAE,MAAM,IAAI,CAAC;CACvB;gCAMsB,qBAAqB;AAA5C,wBA8DE"}
|
|
@@ -11,23 +11,20 @@ import InternalSelect from '../select/internal';
|
|
|
11
11
|
import InternalSpaceBetween from '../space-between/internal';
|
|
12
12
|
import { LightThemes, DarkThemes } from './ace-themes';
|
|
13
13
|
function filterThemes(allThemes, available) {
|
|
14
|
-
if (!available) {
|
|
15
|
-
return allThemes;
|
|
16
|
-
}
|
|
17
14
|
return allThemes.filter(theme => available.indexOf(theme.value) > -1);
|
|
18
15
|
}
|
|
19
16
|
export default (props) => {
|
|
20
|
-
var _a, _b, _c, _d
|
|
17
|
+
var _a, _b, _c, _d;
|
|
21
18
|
const [wrapLines, setWrapLines] = useState((_b = (_a = props.preferences) === null || _a === void 0 ? void 0 : _a.wrapLines) !== null && _b !== void 0 ? _b : true);
|
|
22
19
|
const [theme, setTheme] = useState((_d = (_c = props.preferences) === null || _c === void 0 ? void 0 : _c.theme) !== null && _d !== void 0 ? _d : props.defaultTheme);
|
|
23
20
|
const themeOptions = [
|
|
24
21
|
{
|
|
25
22
|
label: props.i18nStrings.lightThemes,
|
|
26
|
-
options: filterThemes(LightThemes,
|
|
23
|
+
options: filterThemes(LightThemes, props.themes.light),
|
|
27
24
|
},
|
|
28
25
|
{
|
|
29
26
|
label: props.i18nStrings.darkThemes,
|
|
30
|
-
options: filterThemes(DarkThemes,
|
|
27
|
+
options: filterThemes(DarkThemes, props.themes.dark),
|
|
31
28
|
},
|
|
32
29
|
];
|
|
33
30
|
const [selectedThemeOption, setSelectedThemeOption] = useState(() => [...LightThemes, ...DarkThemes].filter(t => t.value === theme)[0]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preferences-modal.js","sourceRoot":"lib/default/","sources":["code-editor/preferences-modal.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,MAA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,KAAK,CAAC,WAAW,CAAC,MAAM,EACxC,MAAM,EACJ,oBAAC,WAAW,IAAC,KAAK,EAAC,OAAO;YACxB,oBAAC,oBAAoB,IAAC,SAAS,EAAC,YAAY,EAAC,IAAI,EAAC,IAAI;gBACpD,oBAAC,cAAc,IAAC,OAAO,EAAE,KAAK,CAAC,SAAS,IAAG,KAAK,CAAC,WAAW,CAAC,MAAM,CAAkB;gBACrF,oBAAC,cAAc,IAAC,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAC,SAAS,IACpF,KAAK,CAAC,WAAW,CAAC,OAAO,CACX,CACI,CACX;QAGhB,oBAAC,oBAAoB,IAAC,OAAO,EAAE,CAAC,EAAE,OAAO,EAAC,WAAW;YACnD;gBACE,oBAAC,gBAAgB,IAAC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,IAChF,KAAK,CAAC,WAAW,CAAC,SAAS,CACX,CACf;YACN;gBACE,oBAAC,iBAAiB,IAAC,KAAK,EAAE,KAAK,CAAC,WAAW,CAAC,KAAK;oBAC/C,oBAAC,cAAc,IACb,cAAc,EAAE,mBAAmB,EACnC,QAAQ,EAAE,eAAe,EACzB,OAAO,EAAE,YAAY,EACrB,aAAa,EAAC,MAAM,EACpB,kBAAkB,EAAE,KAAK,CAAC,WAAW,CAAC,uBAAuB,EAC7D,uBAAuB,EAAE,KAAK,CAAC,WAAW,CAAC,4BAA4B,EACvE,oBAAoB,EAAE,KAAK,CAAC,WAAW,CAAC,yBAAyB,GACjE,CACgB,CAChB,CACe,CACT,CACjB,CAAC;AACJ,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useState } from 'react';\n\nimport InternalBox from '../box/internal';\nimport { InternalButton } from '../button/internal';\nimport InternalCheckbox from '../checkbox/internal';\nimport InternalColumnLayout from '../column-layout/internal';\nimport InternalFormField from '../form-field/internal';\nimport InternalModal from '../modal/internal';\nimport { SelectProps } from '../select/interfaces';\nimport InternalSelect from '../select/internal';\nimport InternalSpaceBetween from '../space-between/internal';\nimport { NonCancelableCustomEvent } from '../internal/events';\nimport { LightThemes, DarkThemes } from './ace-themes';\nimport { CodeEditorProps } from './interfaces';\n\ninterface PreferencesModali18nStrings {\n header?: string;\n cancel?: string;\n confirm?: string;\n wrapLines?: string;\n theme?: string;\n lightThemes?: string;\n darkThemes?: string;\n themeFilteringPlaceholder?: string;\n themeFilteringAriaLabel?: string;\n themeFilteringClearAriaLabel?: string;\n}\n\ninterface PreferencesModalProps {\n preferences?: Partial<CodeEditorProps.Preferences>;\n\n i18nStrings: PreferencesModali18nStrings;\n\n themes: CodeEditorProps.AvailableThemes;\n defaultTheme: CodeEditorProps.Theme;\n\n onConfirm: (preferences: CodeEditorProps.Preferences) => void;\n onDismiss: () => void;\n}\n\nfunction filterThemes(allThemes: ReadonlyArray<SelectProps.Option>, available: ReadonlyArray<string>) {\n return allThemes.filter(theme => available.indexOf(theme.value!) > -1);\n}\n\nexport default (props: PreferencesModalProps) => {\n const [wrapLines, setWrapLines] = useState<boolean>(props.preferences?.wrapLines ?? true);\n const [theme, setTheme] = useState<CodeEditorProps.Theme>(props.preferences?.theme ?? props.defaultTheme);\n const themeOptions = [\n {\n label: props.i18nStrings.lightThemes,\n options: filterThemes(LightThemes, props.themes.light),\n },\n {\n label: props.i18nStrings.darkThemes,\n options: filterThemes(DarkThemes, props.themes.dark),\n },\n ];\n const [selectedThemeOption, setSelectedThemeOption] = useState<SelectProps.Option>(\n () => [...LightThemes, ...DarkThemes].filter(t => t.value === theme)[0]\n );\n\n const onThemeSelected = (e: NonCancelableCustomEvent<SelectProps.ChangeDetail>) => {\n setTheme(e.detail.selectedOption.value as CodeEditorProps.Theme);\n setSelectedThemeOption(e.detail.selectedOption);\n };\n\n return (\n <InternalModal\n size=\"medium\"\n visible={true}\n onDismiss={props.onDismiss}\n header={props.i18nStrings.header}\n closeAriaLabel={props.i18nStrings.cancel}\n footer={\n <InternalBox float=\"right\">\n <InternalSpaceBetween direction=\"horizontal\" size=\"xs\">\n <InternalButton onClick={props.onDismiss}>{props.i18nStrings.cancel}</InternalButton>\n <InternalButton onClick={() => props.onConfirm({ wrapLines, theme })} variant=\"primary\">\n {props.i18nStrings.confirm}\n </InternalButton>\n </InternalSpaceBetween>\n </InternalBox>\n }\n >\n <InternalColumnLayout columns={2} variant=\"text-grid\">\n <div>\n <InternalCheckbox checked={wrapLines} onChange={e => setWrapLines(e.detail.checked)}>\n {props.i18nStrings.wrapLines}\n </InternalCheckbox>\n </div>\n <div>\n <InternalFormField label={props.i18nStrings.theme}>\n <InternalSelect\n selectedOption={selectedThemeOption}\n onChange={onThemeSelected}\n options={themeOptions}\n filteringType=\"auto\"\n filteringAriaLabel={props.i18nStrings.themeFilteringAriaLabel}\n filteringClearAriaLabel={props.i18nStrings.themeFilteringClearAriaLabel}\n filteringPlaceholder={props.i18nStrings.themeFilteringPlaceholder}\n />\n </InternalFormField>\n </div>\n </InternalColumnLayout>\n </InternalModal>\n );\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-editor.d.ts","sourceRoot":"lib/default/","sources":["code-editor/use-editor.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"use-editor.d.ts","sourceRoot":"lib/default/","sources":["code-editor/use-editor.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAIjC,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,wBAAgB,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,OAAO;;;EAoBpD;AAED,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,IAAI,GAAG,GAAG,CAAC,MAAM,EACzB,EACE,SAAS,EACT,SAAS,EACT,cAAc,EACd,eAAe,GAChB,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IAAC,eAAe,CAAC,EAAE,MAAM,CAAA;CAAE,QAiBjG;AAED,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,IAAI,GAAG,GAAG,CAAC,MAAM,EACzB,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE;IAAE,KAAK,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,IAAI,GAAG,MAAM,CAAA;CAAE;;EAWrE;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,IAAI,GAAG,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,QAY1E;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,IAAI,GAAG,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,QAIhF;AAED,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,IAAI,GAAG,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,EAAE,OAAO,QAIpF;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,IAAI,GAAG,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,eAAe,CAAC,KAAK,QAIzF"}
|
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
4
|
+
import { useCurrentMode } from '@cloudscape-design/component-toolkit/internal';
|
|
4
5
|
import { getAceTheme, getDefaultConfig, getDefaultTheme } from './util';
|
|
5
6
|
export function useEditor(ace, loading) {
|
|
6
7
|
const editorRef = useRef(null);
|
|
7
8
|
const [editor, setEditor] = useState(null);
|
|
9
|
+
const [initialMode] = useState(useCurrentMode(editorRef));
|
|
8
10
|
useEffect(() => {
|
|
9
11
|
const elem = editorRef.current;
|
|
10
12
|
if (!ace || !elem) {
|
|
11
13
|
return;
|
|
12
14
|
}
|
|
13
15
|
const config = getDefaultConfig(ace);
|
|
14
|
-
setEditor(ace.edit(elem, Object.assign(Object.assign({}, config), { theme: getAceTheme(getDefaultTheme(
|
|
15
|
-
}, [ace, loading]);
|
|
16
|
+
setEditor(ace.edit(elem, Object.assign(Object.assign({}, config), { theme: getAceTheme(getDefaultTheme(ace, initialMode)) })));
|
|
17
|
+
}, [ace, loading, initialMode]);
|
|
16
18
|
return { editorRef, editor };
|
|
17
19
|
}
|
|
18
20
|
export function useSyncEditorLabels(editor, { controlId, ariaLabel, ariaLabelledby, ariaDescribedby, }) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-editor.js","sourceRoot":"lib/default/","sources":["code-editor/use-editor.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAGtC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAGxE,MAAM,UAAU,SAAS,CAAC,GAAQ,EAAE,OAAiB;IACnD,MAAM,SAAS,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAC/C,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAoB,IAAI,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"use-editor.js","sourceRoot":"lib/default/","sources":["code-editor/use-editor.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAGtC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAA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C,CAAC,CAAC;QAC3B,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IACzC,CAAC,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;AACtB,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,MAAyB,EAAE,QAAgB;IAC/E,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,OAAO,CAAC,OAAO,CAAC,YAAY,QAAQ,EAAE,CAAC,CAAC;IAClD,CAAC,EAAE,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;AACzB,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,MAAyB,EAAE,SAAmB;IACnF,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,OAAO,CAAC,cAAc,CAAC,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,IAAI,CAAC,CAAC;IACpD,CAAC,EAAE,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;AAC1B,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,MAAyB,EAAE,KAA4B;IACxF,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,QAAQ,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC;IACvC,CAAC,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;AACtB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { Ace } from 'ace-builds';\nimport { useCallback, useEffect, useRef, useState } from 'react';\nimport { useCurrentMode } from '@cloudscape-design/component-toolkit/internal';\nimport { getAceTheme, getDefaultConfig, getDefaultTheme } from './util';\nimport { CodeEditorProps } from './interfaces';\n\nexport function useEditor(ace: any, loading?: boolean) {\n const editorRef = useRef<HTMLDivElement>(null);\n const [editor, setEditor] = useState<null | Ace.Editor>(null);\n const [initialMode] = useState(useCurrentMode(editorRef));\n\n useEffect(() => {\n const elem = editorRef.current;\n if (!ace || !elem) {\n return;\n }\n const config = getDefaultConfig(ace);\n setEditor(\n ace.edit(elem, {\n ...config,\n theme: getAceTheme(getDefaultTheme(ace, initialMode)),\n })\n );\n }, [ace, loading, initialMode]);\n\n return { editorRef, editor };\n}\n\nexport function useSyncEditorLabels(\n editor: null | Ace.Editor,\n {\n controlId,\n ariaLabel,\n ariaLabelledby,\n ariaDescribedby,\n }: { controlId?: string; ariaLabel?: string; ariaLabelledby?: string; ariaDescribedby?: string }\n) {\n useEffect(() => {\n if (!editor) {\n return;\n }\n const { textarea } = editor.renderer as unknown as { textarea: HTMLTextAreaElement };\n if (!textarea) {\n return;\n }\n const updateAttribute = (attribute: string, value: string | undefined) =>\n value ? textarea.setAttribute(attribute, value) : textarea.removeAttribute(attribute);\n updateAttribute('id', controlId);\n updateAttribute('aria-label', ariaLabel);\n updateAttribute('aria-labelledby', ariaLabelledby);\n updateAttribute('aria-describedby', ariaDescribedby);\n }, [ariaLabel, ariaDescribedby, ariaLabelledby, controlId, editor]);\n}\n\nexport function useSyncEditorSize(\n editor: null | Ace.Editor,\n { width, height }: { width?: null | number; height?: null | number }\n) {\n useEffect(() => {\n editor?.resize();\n }, [editor, width, height]);\n\n const onResize = useCallback(() => {\n editor?.resize();\n }, [editor]);\n\n return { onResize };\n}\n\nexport function useSyncEditorValue(editor: null | Ace.Editor, value: string) {\n useEffect(() => {\n if (!editor) {\n return;\n }\n if (value === editor.getValue()) {\n return;\n }\n const pos = editor.session.selection.toJSON();\n editor.setValue(value, -1);\n editor.session.selection.fromJSON(pos);\n }, [editor, value]);\n}\n\nexport function useSyncEditorLanguage(editor: null | Ace.Editor, language: string) {\n useEffect(() => {\n editor?.session.setMode(`ace/mode/${language}`);\n }, [editor, language]);\n}\n\nexport function useSyncEditorWrapLines(editor: null | Ace.Editor, wrapLines?: boolean) {\n useEffect(() => {\n editor?.session.setUseWrapMode(wrapLines ?? true);\n }, [editor, wrapLines]);\n}\n\nexport function useSyncEditorTheme(editor: null | Ace.Editor, theme: CodeEditorProps.Theme) {\n useEffect(() => {\n editor?.setTheme(getAceTheme(theme));\n }, [editor, theme]);\n}\n"]}
|
package/code-editor/util.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { Ace } from 'ace-builds';
|
|
2
|
-
import { LightThemes, DarkThemes } from './ace-themes';
|
|
3
2
|
import { CodeEditorProps } from './interfaces';
|
|
4
3
|
export type PaneStatus = 'error' | 'warning' | 'hidden';
|
|
5
|
-
export declare const DEFAULT_LIGHT_THEME: typeof LightThemes[number]['value'];
|
|
6
|
-
export declare const DEFAULT_DARK_THEME: typeof DarkThemes[number]['value'];
|
|
7
4
|
export declare function supportsKeyboardAccessibility(ace: any): boolean;
|
|
5
|
+
export declare function supportsCloudEditorThemes(ace: any): boolean;
|
|
8
6
|
export declare function getDefaultConfig(ace: any): Partial<Ace.EditorOptions>;
|
|
9
|
-
export declare function getDefaultTheme(
|
|
7
|
+
export declare function getDefaultTheme(ace: any, mode: 'light' | 'dark'): CodeEditorProps.Theme;
|
|
8
|
+
export declare function getDefaultSupportedThemes(ace: any): CodeEditorProps.AvailableThemes;
|
|
10
9
|
export declare function getAceTheme(theme: CodeEditorProps.Theme): string;
|
|
11
10
|
export declare function getLanguageLabel(language: CodeEditorProps.Language): string;
|
|
12
11
|
//# sourceMappingURL=util.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.d.ts","sourceRoot":"lib/default/","sources":["code-editor/util.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"lib/default/","sources":["code-editor/util.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAIjC,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,SAAS,GAAG,QAAQ,CAAC;AAyBxD,wBAAgB,6BAA6B,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAE/D;AAED,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAE3D;AAED,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAKrE;AAED,wBAAgB,eAAe,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,eAAe,CAAC,KAAK,CAMvF;AAED,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,GAAG,GAAG,eAAe,CAAC,eAAe,CASnF;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,eAAe,CAAC,KAAK,UAEvD;AAED,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,eAAe,CAAC,QAAQ,GAAG,MAAM,CAE3E"}
|
package/code-editor/util.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { AceModes } from './ace-modes';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
2
|
+
import { LightThemes, DarkThemes } from './ace-themes';
|
|
3
|
+
const DEFAULT_LIGHT_THEME = 'cloud_editor';
|
|
4
|
+
const DEFAULT_DARK_THEME = 'cloud_editor_dark';
|
|
5
|
+
const FALLBACK_LIGHT_THEME = 'dawn';
|
|
6
|
+
const FALLBACK_DARK_THEME = 'tomorrow_night_bright';
|
|
7
|
+
function isAceVersionAtLeast(ace, minVersion) {
|
|
7
8
|
var _a;
|
|
8
9
|
// Split semantic version numbers. We don't need a full semver parser for this.
|
|
9
10
|
const semanticVersion = (_a = ace === null || ace === void 0 ? void 0 : ace.version) === null || _a === void 0 ? void 0 : _a.split('.').map((part) => {
|
|
@@ -12,16 +13,34 @@ export function supportsKeyboardAccessibility(ace) {
|
|
|
12
13
|
});
|
|
13
14
|
return (!!semanticVersion &&
|
|
14
15
|
typeof semanticVersion[0] === 'number' &&
|
|
15
|
-
semanticVersion[0] >=
|
|
16
|
+
semanticVersion[0] >= minVersion[0] &&
|
|
16
17
|
typeof semanticVersion[1] === 'number' &&
|
|
17
|
-
semanticVersion[1] >=
|
|
18
|
+
semanticVersion[1] >= minVersion[1] &&
|
|
19
|
+
typeof semanticVersion[2] === 'number' &&
|
|
20
|
+
semanticVersion[2] >= minVersion[2]);
|
|
21
|
+
}
|
|
22
|
+
export function supportsKeyboardAccessibility(ace) {
|
|
23
|
+
return isAceVersionAtLeast(ace, [1, 23, 0]);
|
|
24
|
+
}
|
|
25
|
+
export function supportsCloudEditorThemes(ace) {
|
|
26
|
+
return isAceVersionAtLeast(ace, [1, 32, 0]);
|
|
18
27
|
}
|
|
19
28
|
export function getDefaultConfig(ace) {
|
|
20
29
|
return Object.assign({ behavioursEnabled: true }, (supportsKeyboardAccessibility(ace) ? { enableKeyboardAccessibility: true } : {}));
|
|
21
30
|
}
|
|
22
|
-
export function getDefaultTheme(
|
|
23
|
-
|
|
24
|
-
|
|
31
|
+
export function getDefaultTheme(ace, mode) {
|
|
32
|
+
if (supportsCloudEditorThemes(ace)) {
|
|
33
|
+
return mode === 'dark' ? DEFAULT_DARK_THEME : DEFAULT_LIGHT_THEME;
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
return mode === 'dark' ? FALLBACK_DARK_THEME : FALLBACK_LIGHT_THEME;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
export function getDefaultSupportedThemes(ace) {
|
|
40
|
+
return {
|
|
41
|
+
light: LightThemes.map(theme => theme.value).filter(value => value !== 'cloud_editor' || supportsCloudEditorThemes(ace)),
|
|
42
|
+
dark: DarkThemes.map(theme => theme.value).filter(value => value !== 'cloud_editor_dark' || supportsCloudEditorThemes(ace)),
|
|
43
|
+
};
|
|
25
44
|
}
|
|
26
45
|
export function getAceTheme(theme) {
|
|
27
46
|
return `ace/theme/${theme}`;
|
package/code-editor/util.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.js","sourceRoot":"lib/default/","sources":["code-editor/util.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"lib/default/","sources":["code-editor/util.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAKvD,MAAM,mBAAmB,GAAwC,cAAc,CAAC;AAChF,MAAM,kBAAkB,GAAuC,mBAAmB,CAAC;AACnF,MAAM,oBAAoB,GAAwC,MAAM,CAAC;AACzE,MAAM,mBAAmB,GAAuC,uBAAuB,CAAC;AAExF,SAAS,mBAAmB,CAAC,GAAQ,EAAE,UAAoC;;IACzE,+EAA+E;IAC/E,MAAM,eAAe,GAAG,MAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,OAAO,0CAAE,KAAK,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,IAAY,EAAE,EAAE;QACpE,MAAM,MAAM,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;QAC9B,OAAO,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC;IAC9C,CAAC,CAAC,CAAC;IAEH,OAAO,CACL,CAAC,CAAC,eAAe;QACjB,OAAO,eAAe,CAAC,CAAC,CAAC,KAAK,QAAQ;QACtC,eAAe,CAAC,CAAC,CAAC,IAAI,UAAU,CAAC,CAAC,CAAC;QACnC,OAAO,eAAe,CAAC,CAAC,CAAC,KAAK,QAAQ;QACtC,eAAe,CAAC,CAAC,CAAC,IAAI,UAAU,CAAC,CAAC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AE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,CAC/C,KAAK,CAAC,EAAE,CAAC,KAAK,KAAK,mBAAmB,IAAI,yBAAyB,CAAC,GAAG,CAAC,CACzE;KACF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,KAA4B;IACtD,OAAO,aAAa,KAAK,EAAE,CAAC;AAC9B,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,QAAkC;;IACjE,OAAO,CAAA,MAAA,QAAQ,CAAC,MAAM,CAAC,CAAC,IAAuB,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,KAAK,QAAQ,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';\n\nexport type PaneStatus = 'error' | 'warning' | 'hidden';\n\nconst DEFAULT_LIGHT_THEME: typeof LightThemes[number]['value'] = 'cloud_editor';\nconst DEFAULT_DARK_THEME: typeof DarkThemes[number]['value'] = 'cloud_editor_dark';\nconst FALLBACK_LIGHT_THEME: typeof LightThemes[number]['value'] = 'dawn';\nconst FALLBACK_DARK_THEME: typeof DarkThemes[number]['value'] = 'tomorrow_night_bright';\n\nfunction isAceVersionAtLeast(ace: any, minVersion: [number, number, number]): boolean {\n // Split semantic version numbers. We don't need a full semver parser for this.\n const semanticVersion = ace?.version?.split('.').map((part: string) => {\n const parsed = parseInt(part);\n return Number.isNaN(parsed) ? part : parsed;\n });\n\n return (\n !!semanticVersion &&\n typeof semanticVersion[0] === 'number' &&\n semanticVersion[0] >= minVersion[0] &&\n typeof semanticVersion[1] === 'number' &&\n semanticVersion[1] >= minVersion[1] &&\n typeof semanticVersion[2] === 'number' &&\n semanticVersion[2] >= minVersion[2]\n );\n}\n\nexport function supportsKeyboardAccessibility(ace: any): boolean {\n return isAceVersionAtLeast(ace, [1, 23, 0]);\n}\n\nexport function supportsCloudEditorThemes(ace: any): boolean {\n return isAceVersionAtLeast(ace, [1, 32, 0]);\n}\n\nexport function getDefaultConfig(ace: any): Partial<Ace.EditorOptions> {\n return {\n behavioursEnabled: true,\n ...(supportsKeyboardAccessibility(ace) ? { enableKeyboardAccessibility: true } : {}),\n };\n}\n\nexport function getDefaultTheme(ace: any, mode: 'light' | 'dark'): CodeEditorProps.Theme {\n if (supportsCloudEditorThemes(ace)) {\n return mode === 'dark' ? DEFAULT_DARK_THEME : DEFAULT_LIGHT_THEME;\n } else {\n return mode === 'dark' ? FALLBACK_DARK_THEME : FALLBACK_LIGHT_THEME;\n }\n}\n\nexport function getDefaultSupportedThemes(ace: any): CodeEditorProps.AvailableThemes {\n return {\n light: LightThemes.map(theme => theme.value).filter(\n value => value !== 'cloud_editor' || supportsCloudEditorThemes(ace)\n ),\n dark: DarkThemes.map(theme => theme.value).filter(\n value => value !== 'cloud_editor_dark' || supportsCloudEditorThemes(ace)\n ),\n };\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":"index.d.ts","sourceRoot":"lib/default/","sources":["date-picker/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAA6C,MAAM,OAAO,CAAC;AAElE,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAyB/C,OAAO,EAAE,eAAe,EAAE,CAAC;AAE3B,QAAA,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"lib/default/","sources":["date-picker/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAA6C,MAAM,OAAO,CAAC;AAElE,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAyB/C,OAAO,EAAE,eAAe,EAAE,CAAC;AAE3B,QAAA,MAAM,UAAU,6FA6Kf,CAAC;AAGF,eAAe,UAAU,CAAC"}
|
package/date-picker/index.js
CHANGED
|
@@ -26,7 +26,7 @@ import LiveRegion from '../internal/components/live-region';
|
|
|
26
26
|
import { useFormFieldContext } from '../contexts/form-field.js';
|
|
27
27
|
import { useLocale } from '../i18n/context.js';
|
|
28
28
|
const DatePicker = React.forwardRef((_a, ref) => {
|
|
29
|
-
var { locale = '', startOfWeek, isDateEnabled, nextMonthAriaLabel, previousMonthAriaLabel, todayAriaLabel, placeholder = '', value = '', readOnly = false, disabled = false, onBlur, autoFocus = false, onChange, onFocus, name, ariaLabel, ariaRequired, controlId, invalid, openCalendarAriaLabel, expandToViewport } = _a, restProps = __rest(_a, ["locale", "startOfWeek", "isDateEnabled", "nextMonthAriaLabel", "previousMonthAriaLabel", "todayAriaLabel", "placeholder", "value", "readOnly", "disabled", "onBlur", "autoFocus", "onChange", "onFocus", "name", "ariaLabel", "ariaRequired", "controlId", "invalid", "openCalendarAriaLabel", "expandToViewport"]);
|
|
29
|
+
var { locale = '', startOfWeek, isDateEnabled, nextMonthAriaLabel, previousMonthAriaLabel, todayAriaLabel, i18nStrings, placeholder = '', value = '', readOnly = false, disabled = false, onBlur, autoFocus = false, onChange, onFocus, name, ariaLabel, ariaRequired, controlId, invalid, openCalendarAriaLabel, expandToViewport } = _a, restProps = __rest(_a, ["locale", "startOfWeek", "isDateEnabled", "nextMonthAriaLabel", "previousMonthAriaLabel", "todayAriaLabel", "i18nStrings", "placeholder", "value", "readOnly", "disabled", "onBlur", "autoFocus", "onChange", "onFocus", "name", "ariaLabel", "ariaRequired", "controlId", "invalid", "openCalendarAriaLabel", "expandToViewport"]);
|
|
30
30
|
const { __internalRootRef } = useBaseComponent('DatePicker');
|
|
31
31
|
checkControlled('DatePicker', 'value', value, 'onChange', onChange);
|
|
32
32
|
const contextLocale = useLocale();
|
|
@@ -85,7 +85,11 @@ const DatePicker = React.forwardRef((_a, ref) => {
|
|
|
85
85
|
fireNonCancelableEvent(onChange, e.detail);
|
|
86
86
|
(_a = buttonRef === null || buttonRef === void 0 ? void 0 : buttonRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
87
87
|
setIsDropDownOpen(false);
|
|
88
|
-
}, locale: normalizedLocale, startOfWeek: startOfWeek, ariaDescribedby: calendarDescriptionId, ariaLabel: ariaLabel, ariaLabelledby: ariaLabelledby, isDateEnabled: isDateEnabled,
|
|
88
|
+
}, locale: normalizedLocale, startOfWeek: startOfWeek, ariaDescribedby: calendarDescriptionId, ariaLabel: ariaLabel, ariaLabelledby: ariaLabelledby, isDateEnabled: isDateEnabled, i18nStrings: {
|
|
89
|
+
todayAriaLabel: (i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.todayAriaLabel) || todayAriaLabel,
|
|
90
|
+
nextMonthAriaLabel: (i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.nextMonthAriaLabel) || nextMonthAriaLabel,
|
|
91
|
+
previousMonthAriaLabel: (i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.previousMonthAriaLabel) || previousMonthAriaLabel,
|
|
92
|
+
} }),
|
|
89
93
|
React.createElement(LiveRegion, { id: calendarDescriptionId }, renderMonthAndYear(normalizedLocale, baseDate)))))))));
|
|
90
94
|
});
|
|
91
95
|
applyDisplayName(DatePicker, 'DatePicker');
|
package/date-picker/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"lib/default/","sources":["date-picker/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,EAAE,EAAO,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAClE,OAAO,MAAM,MAA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Ae,UAAU,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, { Ref, useCallback, useRef, useState } from 'react';\nimport styles from './styles.css.js';\nimport { DatePickerProps } from './interfaces';\nimport InternalCalendar from '../calendar/internal';\nimport { normalizeLocale } from '../internal/utils/locale';\nimport { getDateLabel, renderMonthAndYear } from '../calendar/utils/intl';\nimport { InputProps } from '../input/interfaces';\nimport { KeyCode } from '../internal/keycode';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport Dropdown from '../internal/components/dropdown';\nimport InternalDateInput from '../date-input/internal';\nimport { getBaseProps } from '../internal/base-component';\nimport { applyDisplayName } from '../internal/utils/apply-display-name.js';\nimport checkControlled from '../internal/hooks/check-controlled';\nimport { useFocusTracker } from '../internal/hooks/use-focus-tracker.js';\nimport useForwardFocus from '../internal/hooks/forward-focus';\nimport { ButtonProps } from '../button/interfaces';\nimport { InternalButton } from '../button/internal';\nimport useBaseComponent from '../internal/hooks/use-base-component';\nimport { useUniqueId } from '../internal/hooks/use-unique-id';\nimport { useMergeRefs } from '../internal/hooks/use-merge-refs';\nimport FocusLock from '../internal/components/focus-lock';\nimport { parseDate } from '../internal/utils/date-time';\nimport LiveRegion from '../internal/components/live-region';\nimport { useFormFieldContext } from '../contexts/form-field.js';\nimport { useLocale } from '../i18n/context.js';\n\nexport { DatePickerProps };\n\nconst DatePicker = React.forwardRef(\n (\n {\n locale = '',\n startOfWeek,\n isDateEnabled,\n nextMonthAriaLabel,\n previousMonthAriaLabel,\n todayAriaLabel,\n placeholder = '',\n value = '',\n readOnly = false,\n disabled = false,\n onBlur,\n autoFocus = false,\n onChange,\n onFocus,\n name,\n ariaLabel,\n ariaRequired,\n controlId,\n invalid,\n openCalendarAriaLabel,\n expandToViewport,\n ...restProps\n }: DatePickerProps,\n ref: Ref<DatePickerProps.Ref>\n ) => {\n const { __internalRootRef } = useBaseComponent('DatePicker');\n checkControlled('DatePicker', 'value', value, 'onChange', onChange);\n\n const contextLocale = useLocale();\n const normalizedLocale = normalizeLocale('DatePicker', locale || contextLocale);\n\n const baseProps = getBaseProps(restProps);\n const [isDropDownOpen, setIsDropDownOpen] = useState<boolean>(false);\n const { ariaLabelledby, ariaDescribedby } = useFormFieldContext(restProps);\n\n const internalInputRef = useRef<HTMLInputElement>(null);\n const buttonRef = useRef<ButtonProps.Ref>(null);\n useForwardFocus(ref, internalInputRef);\n\n const rootRef = useRef<HTMLDivElement>(null);\n const dropdownId = useUniqueId('calender');\n const calendarDescriptionId = useUniqueId('calendar-description-');\n const mergedRef = useMergeRefs(rootRef, __internalRootRef);\n\n useFocusTracker({ rootRef, onBlur, onFocus });\n\n const onDropdownCloseHandler = useCallback(() => setIsDropDownOpen(false), [setIsDropDownOpen]);\n\n const onButtonClickHandler = () => {\n if (!isDropDownOpen) {\n setIsDropDownOpen(true);\n }\n };\n\n const onWrapperKeyDownHandler = (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (event.keyCode === KeyCode.escape && isDropDownOpen) {\n event.stopPropagation();\n buttonRef.current?.focus();\n setIsDropDownOpen(false);\n }\n };\n\n const onInputChangeHandler: InputProps['onChange'] = event => {\n fireNonCancelableEvent(onChange, { value: event.detail.value });\n };\n\n const onInputBlurHandler: InputProps['onBlur'] = () => {\n if (!isDropDownOpen) {\n setIsDropDownOpen(false);\n }\n };\n\n // Set displayed date to value if defined or to current date otherwise.\n const parsedValue = value && value.length >= 4 ? parseDate(value) : null;\n const baseDate = parsedValue || new Date();\n\n const trigger = (\n <div className={styles['date-picker-trigger']}>\n <div className={styles['date-picker-input']}>\n <InternalDateInput\n name={name}\n invalid={invalid}\n controlId={controlId}\n ariaLabelledby={ariaLabelledby}\n ariaDescribedby={ariaDescribedby}\n ariaLabel={ariaLabel}\n ariaRequired={ariaRequired}\n value={value}\n disabled={disabled}\n readOnly={readOnly}\n onChange={onInputChangeHandler}\n onBlur={onInputBlurHandler}\n placeholder={placeholder}\n ref={internalInputRef}\n autoFocus={autoFocus}\n onFocus={onDropdownCloseHandler}\n />\n </div>\n <div>\n <InternalButton\n iconName=\"calendar\"\n className={styles['open-calendar-button']}\n onClick={onButtonClickHandler}\n ref={buttonRef}\n ariaLabel={\n openCalendarAriaLabel &&\n openCalendarAriaLabel(value.length === 10 ? getDateLabel(normalizedLocale, parsedValue!) : null)\n }\n disabled={disabled || readOnly}\n formAction=\"none\"\n />\n </div>\n </div>\n );\n\n baseProps.className = clsx(baseProps.className, styles.root, styles['date-picker-container']);\n\n const handleMouseDown = (event: React.MouseEvent) => {\n // prevent currently focused element from losing it\n event.preventDefault();\n };\n\n return (\n <div {...baseProps} ref={mergedRef} onKeyDown={!disabled && !readOnly ? onWrapperKeyDownHandler : undefined}>\n {disabled || readOnly ? (\n trigger\n ) : (\n <Dropdown\n stretchWidth={true}\n stretchHeight={true}\n open={isDropDownOpen}\n onDropdownClose={onDropdownCloseHandler}\n onMouseDown={handleMouseDown}\n trigger={trigger}\n expandToViewport={expandToViewport}\n scrollable={false}\n dropdownId={dropdownId}\n >\n {isDropDownOpen && (\n <FocusLock className={styles['focus-lock']} autoFocus={true}>\n <div tabIndex={0} className={styles.calendar} role=\"dialog\" aria-modal=\"true\">\n <InternalCalendar\n value={value}\n onChange={e => {\n fireNonCancelableEvent(onChange, e.detail);\n buttonRef?.current?.focus();\n setIsDropDownOpen(false);\n }}\n locale={normalizedLocale}\n startOfWeek={startOfWeek}\n ariaDescribedby={calendarDescriptionId}\n ariaLabel={ariaLabel}\n ariaLabelledby={ariaLabelledby}\n isDateEnabled={isDateEnabled}\n todayAriaLabel={todayAriaLabel}\n nextMonthAriaLabel={nextMonthAriaLabel}\n previousMonthAriaLabel={previousMonthAriaLabel}\n />\n <LiveRegion id={calendarDescriptionId}>{renderMonthAndYear(normalizedLocale, baseDate)}</LiveRegion>\n </div>\n </FocusLock>\n )}\n </Dropdown>\n )}\n </div>\n );\n }\n);\n\napplyDisplayName(DatePicker, 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AAc,EAAE,CAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,cAAc,KAAI,cAAc;oBAC7D,kBAAkB,EAAE,CAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,kBAAkB,KAAI,kBAAkB;oBACzE,sBAAsB,EAAE,CAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,sBAAsB,KAAI,sBAAsB;iBACtF,GACD;YACF,oBAAC,UAAU,IAAC,EAAE,EAAE,qBAAqB,IAAG,kBAAkB,CAAC,gBAAgB,EAAE,QAAQ,CAAC,CAAc,CAChG,CACI,CACb,CACQ,CACZ,CACG,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,gBAAgB,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;AAC3C,eAAe,UAAU,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport clsx from 'clsx';\nimport React, { Ref, useCallback, useRef, useState } from 'react';\nimport styles from './styles.css.js';\nimport { DatePickerProps } from './interfaces';\nimport InternalCalendar from '../calendar/internal';\nimport { normalizeLocale } from '../internal/utils/locale';\nimport { getDateLabel, renderMonthAndYear } from '../calendar/utils/intl';\nimport { InputProps } from '../input/interfaces';\nimport { KeyCode } from '../internal/keycode';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport Dropdown from '../internal/components/dropdown';\nimport InternalDateInput from '../date-input/internal';\nimport { getBaseProps } from '../internal/base-component';\nimport { applyDisplayName } from '../internal/utils/apply-display-name.js';\nimport checkControlled from '../internal/hooks/check-controlled';\nimport { useFocusTracker } from '../internal/hooks/use-focus-tracker.js';\nimport useForwardFocus from '../internal/hooks/forward-focus';\nimport { ButtonProps } from '../button/interfaces';\nimport { InternalButton } from '../button/internal';\nimport useBaseComponent from '../internal/hooks/use-base-component';\nimport { useUniqueId } from '../internal/hooks/use-unique-id';\nimport { useMergeRefs } from '../internal/hooks/use-merge-refs';\nimport FocusLock from '../internal/components/focus-lock';\nimport { parseDate } from '../internal/utils/date-time';\nimport LiveRegion from '../internal/components/live-region';\nimport { useFormFieldContext } from '../contexts/form-field.js';\nimport { useLocale } from '../i18n/context.js';\n\nexport { DatePickerProps };\n\nconst DatePicker = React.forwardRef(\n (\n {\n locale = '',\n startOfWeek,\n isDateEnabled,\n nextMonthAriaLabel,\n previousMonthAriaLabel,\n todayAriaLabel,\n i18nStrings,\n placeholder = '',\n value = '',\n readOnly = false,\n disabled = false,\n onBlur,\n autoFocus = false,\n onChange,\n onFocus,\n name,\n ariaLabel,\n ariaRequired,\n controlId,\n invalid,\n openCalendarAriaLabel,\n expandToViewport,\n ...restProps\n }: DatePickerProps,\n ref: Ref<DatePickerProps.Ref>\n ) => {\n const { __internalRootRef } = useBaseComponent('DatePicker');\n checkControlled('DatePicker', 'value', value, 'onChange', onChange);\n\n const contextLocale = useLocale();\n const normalizedLocale = normalizeLocale('DatePicker', locale || contextLocale);\n\n const baseProps = getBaseProps(restProps);\n const [isDropDownOpen, setIsDropDownOpen] = useState<boolean>(false);\n const { ariaLabelledby, ariaDescribedby } = useFormFieldContext(restProps);\n\n const internalInputRef = useRef<HTMLInputElement>(null);\n const buttonRef = useRef<ButtonProps.Ref>(null);\n useForwardFocus(ref, internalInputRef);\n\n const rootRef = useRef<HTMLDivElement>(null);\n const dropdownId = useUniqueId('calender');\n const calendarDescriptionId = useUniqueId('calendar-description-');\n const mergedRef = useMergeRefs(rootRef, __internalRootRef);\n\n useFocusTracker({ rootRef, onBlur, onFocus });\n\n const onDropdownCloseHandler = useCallback(() => setIsDropDownOpen(false), [setIsDropDownOpen]);\n\n const onButtonClickHandler = () => {\n if (!isDropDownOpen) {\n setIsDropDownOpen(true);\n }\n };\n\n const onWrapperKeyDownHandler = (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (event.keyCode === KeyCode.escape && isDropDownOpen) {\n event.stopPropagation();\n buttonRef.current?.focus();\n setIsDropDownOpen(false);\n }\n };\n\n const onInputChangeHandler: InputProps['onChange'] = event => {\n fireNonCancelableEvent(onChange, { value: event.detail.value });\n };\n\n const onInputBlurHandler: InputProps['onBlur'] = () => {\n if (!isDropDownOpen) {\n setIsDropDownOpen(false);\n }\n };\n\n // Set displayed date to value if defined or to current date otherwise.\n const parsedValue = value && value.length >= 4 ? parseDate(value) : null;\n const baseDate = parsedValue || new Date();\n\n const trigger = (\n <div className={styles['date-picker-trigger']}>\n <div className={styles['date-picker-input']}>\n <InternalDateInput\n name={name}\n invalid={invalid}\n controlId={controlId}\n ariaLabelledby={ariaLabelledby}\n ariaDescribedby={ariaDescribedby}\n ariaLabel={ariaLabel}\n ariaRequired={ariaRequired}\n value={value}\n disabled={disabled}\n readOnly={readOnly}\n onChange={onInputChangeHandler}\n onBlur={onInputBlurHandler}\n placeholder={placeholder}\n ref={internalInputRef}\n autoFocus={autoFocus}\n onFocus={onDropdownCloseHandler}\n />\n </div>\n <div>\n <InternalButton\n iconName=\"calendar\"\n className={styles['open-calendar-button']}\n onClick={onButtonClickHandler}\n ref={buttonRef}\n ariaLabel={\n openCalendarAriaLabel &&\n openCalendarAriaLabel(value.length === 10 ? getDateLabel(normalizedLocale, parsedValue!) : null)\n }\n disabled={disabled || readOnly}\n formAction=\"none\"\n />\n </div>\n </div>\n );\n\n baseProps.className = clsx(baseProps.className, styles.root, styles['date-picker-container']);\n\n const handleMouseDown = (event: React.MouseEvent) => {\n // prevent currently focused element from losing it\n event.preventDefault();\n };\n\n return (\n <div {...baseProps} ref={mergedRef} onKeyDown={!disabled && !readOnly ? onWrapperKeyDownHandler : undefined}>\n {disabled || readOnly ? (\n trigger\n ) : (\n <Dropdown\n stretchWidth={true}\n stretchHeight={true}\n open={isDropDownOpen}\n onDropdownClose={onDropdownCloseHandler}\n onMouseDown={handleMouseDown}\n trigger={trigger}\n expandToViewport={expandToViewport}\n scrollable={false}\n dropdownId={dropdownId}\n >\n {isDropDownOpen && (\n <FocusLock className={styles['focus-lock']} autoFocus={true}>\n <div tabIndex={0} className={styles.calendar} role=\"dialog\" aria-modal=\"true\">\n <InternalCalendar\n value={value}\n onChange={e => {\n fireNonCancelableEvent(onChange, e.detail);\n buttonRef?.current?.focus();\n setIsDropDownOpen(false);\n }}\n locale={normalizedLocale}\n startOfWeek={startOfWeek}\n ariaDescribedby={calendarDescriptionId}\n ariaLabel={ariaLabel}\n ariaLabelledby={ariaLabelledby}\n isDateEnabled={isDateEnabled}\n i18nStrings={{\n todayAriaLabel: i18nStrings?.todayAriaLabel || todayAriaLabel,\n nextMonthAriaLabel: i18nStrings?.nextMonthAriaLabel || nextMonthAriaLabel,\n previousMonthAriaLabel: i18nStrings?.previousMonthAriaLabel || previousMonthAriaLabel,\n }}\n />\n <LiveRegion id={calendarDescriptionId}>{renderMonthAndYear(normalizedLocale, baseDate)}</LiveRegion>\n </div>\n </FocusLock>\n )}\n </Dropdown>\n )}\n </div>\n );\n }\n);\n\napplyDisplayName(DatePicker, 'DatePicker');\nexport default DatePicker;\n"]}
|
|
@@ -59,6 +59,12 @@ export interface DatePickerProps extends BaseComponentProps, FormFieldValidation
|
|
|
59
59
|
* Called when input focus is removed from the UI control.
|
|
60
60
|
*/
|
|
61
61
|
onBlur?: NonCancelableEventHandler<null>;
|
|
62
|
+
/**
|
|
63
|
+
* An object containing all the necessary localized strings required by
|
|
64
|
+
* the component.
|
|
65
|
+
* @i18n
|
|
66
|
+
*/
|
|
67
|
+
i18nStrings?: DatePickerProps.I18nStrings;
|
|
62
68
|
}
|
|
63
69
|
export declare namespace DatePickerProps {
|
|
64
70
|
interface ChangeDetail {
|
|
@@ -79,5 +85,6 @@ export declare namespace DatePickerProps {
|
|
|
79
85
|
*/
|
|
80
86
|
focus(): void;
|
|
81
87
|
}
|
|
88
|
+
type I18nStrings = CalendarProps.I18nStrings;
|
|
82
89
|
}
|
|
83
90
|
//# sourceMappingURL=interfaces.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"lib/default/","sources":["date-picker/interfaces.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,+BAA+B,EAAE,MAAM,wCAAwC,CAAC;AACzF,OAAO,EAAE,gBAAgB,EAAE,MAAM,4CAA4C,CAAC;AAC9E,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD,MAAM,WAAW,eACf,SAAQ,kBAAkB,EACxB,+BAA+B,EAC/B,gBAAgB,EAChB,aAAa;IACf;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;;OAIG;IACH,qBAAqB,CAAC,EAAE,eAAe,CAAC,qBAAqB,CAAC;IAE9D;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB;;OAEG;IACH,OAAO,CAAC,EAAE,yBAAyB,CAAC,IAAI,CAAC,CAAC;IAE1C;;OAEG;IACH,MAAM,CAAC,EAAE,yBAAyB,CAAC,IAAI,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"interfaces.d.ts","sourceRoot":"lib/default/","sources":["date-picker/interfaces.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,+BAA+B,EAAE,MAAM,wCAAwC,CAAC;AACzF,OAAO,EAAE,gBAAgB,EAAE,MAAM,4CAA4C,CAAC;AAC9E,OAAO,EAAE,yBAAyB,EAAE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lib/default/","sources":["date-picker/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { BaseComponentProps } from '../internal/base-component';\nimport { FormFieldValidationControlProps } from '../internal/context/form-field-context';\nimport { ExpandToViewport } from '../internal/components/dropdown/interfaces';\nimport { NonCancelableEventHandler } from '../internal/events';\nimport { CalendarProps } from '../calendar/interfaces';\n\nexport interface DatePickerProps\n extends BaseComponentProps,\n FormFieldValidationControlProps,\n ExpandToViewport,\n CalendarProps {\n /**\n * Specifies the placeholder text rendered when the value is an empty string.\n */\n placeholder?: string;\n\n /**\n * Specifies a function that generates the `aria-label` for the 'open calendar' button. The `selectedDate` parameter is\n * a human-readable localised string representing the current value of the input.\n * (for example, ``selectedDate => 'Choose Date' + (selectedDate ? `, selected date is ${selectedDate}` : '')``)\n */\n openCalendarAriaLabel?: DatePickerProps.OpenCalendarAriaLabel;\n\n /**\n * Specifies the name of the control used in HTML forms.\n */\n name?: string;\n\n /**\n * Specifies if the control is disabled, which prevents the\n * user from modifying the value and prevents the value from\n * being included in a form submission. A disabled control can't\n * receive focus.\n */\n disabled?: boolean;\n\n /**\n * Specifies if the control is read only, which prevents the\n * user from modifying the value but includes it in a form\n * submission. A read-only control can receive focus.\n *\n * Do not use read-only inputs outside of a form.\n */\n readOnly?: boolean;\n\n /**\n * Indicates whether the control should be focused as\n * soon as the page loads, which enables the user to\n * start typing without having to manually focus the control. Don't\n * use this option on pages where the control may be\n * scrolled out of the viewport.\n */\n autoFocus?: boolean;\n\n /**\n * Adds an `aria-label` to the native control.\n *\n * Use this if you don't have a visible label for this control.\n */\n ariaLabel?: string;\n\n /**\n * Specifies whether to add `aria-required` to the native control.\n */\n ariaRequired?: boolean;\n\n /**\n * Called when input focus is moved to the UI control.\n */\n onFocus?: NonCancelableEventHandler<null>;\n\n /**\n * Called when input focus is removed from the UI control.\n */\n onBlur?: NonCancelableEventHandler<null>;\n}\n\nexport namespace DatePickerProps {\n export interface ChangeDetail {\n /**\n * The new value of this date-picker.\n */\n value: string;\n }\n\n export interface IsDateEnabledFunction {\n (date: Date): boolean;\n }\n\n export interface OpenCalendarAriaLabel {\n (selectedDate: string | null): string;\n }\n\n export interface Ref {\n /**\n * Sets the browser focus on the UI control\n */\n focus(): void;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"lib/default/","sources":["date-picker/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { BaseComponentProps } from '../internal/base-component';\nimport { FormFieldValidationControlProps } from '../internal/context/form-field-context';\nimport { ExpandToViewport } from '../internal/components/dropdown/interfaces';\nimport { NonCancelableEventHandler } from '../internal/events';\nimport { CalendarProps } from '../calendar/interfaces';\n\nexport interface DatePickerProps\n extends BaseComponentProps,\n FormFieldValidationControlProps,\n ExpandToViewport,\n CalendarProps {\n /**\n * Specifies the placeholder text rendered when the value is an empty string.\n */\n placeholder?: string;\n\n /**\n * Specifies a function that generates the `aria-label` for the 'open calendar' button. The `selectedDate` parameter is\n * a human-readable localised string representing the current value of the input.\n * (for example, ``selectedDate => 'Choose Date' + (selectedDate ? `, selected date is ${selectedDate}` : '')``)\n */\n openCalendarAriaLabel?: DatePickerProps.OpenCalendarAriaLabel;\n\n /**\n * Specifies the name of the control used in HTML forms.\n */\n name?: string;\n\n /**\n * Specifies if the control is disabled, which prevents the\n * user from modifying the value and prevents the value from\n * being included in a form submission. A disabled control can't\n * receive focus.\n */\n disabled?: boolean;\n\n /**\n * Specifies if the control is read only, which prevents the\n * user from modifying the value but includes it in a form\n * submission. A read-only control can receive focus.\n *\n * Do not use read-only inputs outside of a form.\n */\n readOnly?: boolean;\n\n /**\n * Indicates whether the control should be focused as\n * soon as the page loads, which enables the user to\n * start typing without having to manually focus the control. Don't\n * use this option on pages where the control may be\n * scrolled out of the viewport.\n */\n autoFocus?: boolean;\n\n /**\n * Adds an `aria-label` to the native control.\n *\n * Use this if you don't have a visible label for this control.\n */\n ariaLabel?: string;\n\n /**\n * Specifies whether to add `aria-required` to the native control.\n */\n ariaRequired?: boolean;\n\n /**\n * Called when input focus is moved to the UI control.\n */\n onFocus?: NonCancelableEventHandler<null>;\n\n /**\n * Called when input focus is removed from the UI control.\n */\n onBlur?: NonCancelableEventHandler<null>;\n\n /**\n * An object containing all the necessary localized strings required by\n * the component.\n * @i18n\n */\n i18nStrings?: DatePickerProps.I18nStrings;\n}\n\nexport namespace DatePickerProps {\n export interface ChangeDetail {\n /**\n * The new value of this date-picker.\n */\n value: string;\n }\n\n export interface IsDateEnabledFunction {\n (date: Date): boolean;\n }\n\n export interface OpenCalendarAriaLabel {\n (selectedDate: string | null): string;\n }\n\n export interface Ref {\n /**\n * Sets the browser focus on the UI control\n */\n focus(): void;\n }\n\n export type I18nStrings = CalendarProps.I18nStrings;\n}\n"]}
|
package/internal/environment.js
CHANGED
package/internal/manifest.json
CHANGED
package/package.json
CHANGED