@cloudscape-design/components 3.0.1058 → 3.0.1060

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.
@@ -1,5 +1,6 @@
1
1
  import { BaseComponentProps } from '../internal/base-component';
2
2
  import { NonCancelableEventHandler } from '../internal/events';
3
+ import { DateGranularity } from '../internal/utils/date-time/interfaces';
3
4
  export interface CalendarProps extends BaseComponentProps {
4
5
  /**
5
6
  * The current input value, in YYYY-MM-DD format.
@@ -88,7 +89,7 @@ export declare namespace CalendarProps {
88
89
  interface DateDisabledReasonFunction {
89
90
  (date: Date): string;
90
91
  }
91
- type Granularity = 'day' | 'month';
92
+ type Granularity = DateGranularity;
92
93
  interface I18nStrings {
93
94
  /**
94
95
  * Used as part of the `aria-label` for today's date in the calendar.
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/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;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,aAAa,CAAC,0BAA0B,CAAC;IAE9D;;;;;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;;;OA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,CAAC;QAEhC;;;WAGG;QACH,qBAAqB,CAAC,EAAE,MAAM,CAAC;QAE/B;;;WAGG;QACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAE3B;;;WAGG;QACH,qBAAqB,CAAC,EAAE,MAAM,CAAC;KAChC;CACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/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 * Provides a reason why a particular date in the calendar is not enabled (only when `isDateEnabled` returns `false`).\n * If provided, the date becomes focusable.\n * @param date\n */\n dateDisabledReason?: CalendarProps.DateDisabledReasonFunction;\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 /**\n * Specifies the granularity at which users will be able to select a date.\n * Defaults to `day`.\n **/\n granularity?: CalendarProps.Granularity;\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 DateDisabledReasonFunction {\n (date: Date): string;\n }\n\n export type Granularity = 'day' | 'month';\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 * Used as part of the `aria-label` for the current month in the calendar.\n * @i18n\n */\n currentMonthAriaLabel?: string;\n\n /**\n * Specifies an `aria-label` for the 'next year' button.\n * @i18n\n */\n nextYearAriaLabel?: string;\n\n /**\n * Specifies an `aria-label` for the 'previous year' button.\n * @i18n\n */\n previousYearAriaLabel?: string;\n }\n}\n"]}
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/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';\nimport { DateGranularity } from '../internal/utils/date-time/interfaces';\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 * Provides a reason why a particular date in the calendar is not enabled (only when `isDateEnabled` returns `false`).\n * If provided, the date becomes focusable.\n * @param date\n */\n dateDisabledReason?: CalendarProps.DateDisabledReasonFunction;\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 /**\n * Specifies the granularity at which users will be able to select a date.\n * Defaults to `day`.\n **/\n granularity?: CalendarProps.Granularity;\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 DateDisabledReasonFunction {\n (date: Date): string;\n }\n\n export type Granularity = DateGranularity;\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 * Used as part of the `aria-label` for the current month in the calendar.\n * @i18n\n */\n currentMonthAriaLabel?: string;\n\n /**\n * Specifies an `aria-label` for the 'next year' button.\n * @i18n\n */\n nextYearAriaLabel?: string;\n\n /**\n * Specifies an `aria-label` for the 'previous year' button.\n * @i18n\n */\n previousYearAriaLabel?: string;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/date-picker/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAA6C,MAAM,OAAO,CAAC;AAyBlE,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAK/C,OAAO,EAAE,eAAe,EAAE,CAAC;AAE3B,QAAA,MAAM,UAAU,6FA2Lf,CAAC;AAGF,eAAe,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/date-picker/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAA6C,MAAM,OAAO,CAAC;AAyBlE,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAK/C,OAAO,EAAE,eAAe,EAAE,CAAC;AAE3B,QAAA,MAAM,UAAU,6FAgMf,CAAC;AAGF,eAAe,UAAU,CAAC"}
@@ -27,7 +27,7 @@ import { getBaseDateLabel, getSelectedDateLabel, isValidFullDate } from './utils
27
27
  import styles from './styles.css.js';
28
28
  const DatePicker = React.forwardRef((_a, ref) => {
29
29
  var _b, _c, _d;
30
- var { locale = '', startOfWeek, isDateEnabled, dateDisabledReason, nextMonthAriaLabel, previousMonthAriaLabel, todayAriaLabel, i18nStrings, placeholder = '', value = '', readOnly = false, disabled = false, onBlur, autoFocus = false, onChange, onFocus, name, ariaLabel, ariaRequired, controlId, invalid, warning, openCalendarAriaLabel, expandToViewport, granularity = 'day' } = _a, restProps = __rest(_a, ["locale", "startOfWeek", "isDateEnabled", "dateDisabledReason", "nextMonthAriaLabel", "previousMonthAriaLabel", "todayAriaLabel", "i18nStrings", "placeholder", "value", "readOnly", "disabled", "onBlur", "autoFocus", "onChange", "onFocus", "name", "ariaLabel", "ariaRequired", "controlId", "invalid", "warning", "openCalendarAriaLabel", "expandToViewport", "granularity"]);
30
+ var { locale, startOfWeek, isDateEnabled, dateDisabledReason, nextMonthAriaLabel, previousMonthAriaLabel, todayAriaLabel, i18nStrings, placeholder = '', value = '', readOnly = false, disabled = false, onBlur, autoFocus = false, onChange, onFocus, name, ariaLabel, ariaRequired, controlId, invalid, warning, openCalendarAriaLabel, expandToViewport, granularity = 'day', format = 'slashed', inputFormat = 'slashed' } = _a, restProps = __rest(_a, ["locale", "startOfWeek", "isDateEnabled", "dateDisabledReason", "nextMonthAriaLabel", "previousMonthAriaLabel", "todayAriaLabel", "i18nStrings", "placeholder", "value", "readOnly", "disabled", "onBlur", "autoFocus", "onChange", "onFocus", "name", "ariaLabel", "ariaRequired", "controlId", "invalid", "warning", "openCalendarAriaLabel", "expandToViewport", "granularity", "format", "inputFormat"]);
31
31
  const { __internalRootRef } = useBaseComponent('DatePicker', {
32
32
  props: { autoFocus, expandToViewport, granularity, readOnly },
33
33
  metadata: { hasDisabledReasons: Boolean(dateDisabledReason) },
@@ -78,7 +78,7 @@ const DatePicker = React.forwardRef((_a, ref) => {
78
78
  : null);
79
79
  const trigger = (React.createElement("div", { className: styles['date-picker-trigger'] },
80
80
  React.createElement("div", { className: styles['date-picker-input'] },
81
- React.createElement(InternalDateInput, { name: name, invalid: invalid, warning: warning, controlId: controlId, ariaLabelledby: ariaLabelledby, ariaDescribedby: ariaDescribedby, ariaLabel: ariaLabel, ariaRequired: ariaRequired, value: value, disabled: disabled, readOnly: readOnly, onChange: onInputChangeHandler, onBlur: onInputBlurHandler, placeholder: placeholder, ref: internalInputRef, autoFocus: autoFocus, onFocus: onDropdownCloseHandler, granularity: granularity })),
81
+ React.createElement(InternalDateInput, { name: name, invalid: invalid, warning: warning, controlId: controlId, ariaLabelledby: ariaLabelledby, ariaDescribedby: ariaDescribedby, ariaLabel: ariaLabel, ariaRequired: ariaRequired, value: value, disabled: disabled, readOnly: readOnly, onChange: onInputChangeHandler, onBlur: onInputBlurHandler, placeholder: placeholder, ref: internalInputRef, autoFocus: autoFocus, onFocus: onDropdownCloseHandler, granularity: granularity, locale: locale, format: format, inputFormat: inputFormat })),
82
82
  React.createElement("div", null,
83
83
  React.createElement(InternalButton, { iconName: "calendar", className: styles['open-calendar-button'], onClick: onButtonClickHandler, ref: buttonRef, ariaLabel: buttonAriaLabel, disabled: disabled || readOnly, formAction: "none" }))));
84
84
  baseProps.className = clsx(baseProps.className, styles.root, styles['date-picker-container']);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/date-picker/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,YAAY,CAAC;;AACb,OAAO,KAAK,EAAE,EAAO,WAAW,EAAE,MAAM,EAA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,cAAc,EAC9B,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,aAAa,EAC5B,kBAAkB,EAAE,kBAAkB,EACtC,WAAW,kCACN,WAAW,KACd,cAAc,EAAE,MAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,cAAc,mCAAI,cAAc,EAC7D,kBAAkB,EAAE,MAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,kBAAkB,mCAAI,kBAAkB,EACzE,sBAAsB,EAAE,MAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,sBAAsB,mCAAI,sBAAsB,MAEvF;YACF,oBAAC,kBAAkB,IAAC,EAAE,EAAE,qBAAqB,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAC,MAAM,IACxE,gBAAgB,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE,gBAAgB,EAAE,CAAC,CACzD,CACjB,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\n'use client';\nimport React, { Ref, useCallback, useRef, useState } from 'react';\nimport clsx from 'clsx';\n\nimport { useMergeRefs, useUniqueId } from '@cloudscape-design/component-toolkit/internal';\n\nimport { ButtonProps } from '../button/interfaces';\nimport { InternalButton } from '../button/internal';\nimport InternalCalendar from '../calendar/internal';\nimport { useFormFieldContext } from '../contexts/form-field.js';\nimport InternalDateInput from '../date-input/internal';\nimport { useLocale } from '../i18n/context.js';\nimport { InputProps } from '../input/interfaces';\nimport { getBaseProps } from '../internal/base-component';\nimport Dropdown from '../internal/components/dropdown';\nimport FocusLock from '../internal/components/focus-lock';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport checkControlled from '../internal/hooks/check-controlled';\nimport useForwardFocus from '../internal/hooks/forward-focus';\nimport useBaseComponent from '../internal/hooks/use-base-component';\nimport { useFocusTracker } from '../internal/hooks/use-focus-tracker.js';\nimport { KeyCode } from '../internal/keycode';\nimport { applyDisplayName } from '../internal/utils/apply-display-name.js';\nimport { parseDate } from '../internal/utils/date-time';\nimport { normalizeLocale } from '../internal/utils/locale';\nimport InternalLiveRegion from '../live-region/internal';\nimport { DatePickerProps } from './interfaces';\nimport { getBaseDateLabel, getSelectedDateLabel, isValidFullDate } from './utils';\n\nimport styles from './styles.css.js';\n\nexport { DatePickerProps };\n\nconst DatePicker = React.forwardRef(\n (\n {\n locale = '',\n startOfWeek,\n isDateEnabled,\n dateDisabledReason,\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 warning,\n openCalendarAriaLabel,\n expandToViewport,\n granularity = 'day',\n ...restProps\n }: DatePickerProps,\n ref: Ref<DatePickerProps.Ref>\n ) => {\n const { __internalRootRef } = useBaseComponent('DatePicker', {\n props: { autoFocus, expandToViewport, granularity, readOnly },\n metadata: { hasDisabledReasons: Boolean(dateDisabledReason) },\n });\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 hasFullValue = isValidFullDate({ date: value, granularity });\n\n const buttonAriaLabel =\n openCalendarAriaLabel &&\n openCalendarAriaLabel(\n hasFullValue && parsedValue\n ? getSelectedDateLabel({ date: parsedValue, granularity, locale: normalizedLocale })\n : null\n );\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 warning={warning}\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 granularity={granularity}\n />\n </div>\n <div>\n <InternalButton\n iconName=\"calendar\"\n className={styles['open-calendar-button']}\n onClick={onButtonClickHandler}\n ref={buttonRef}\n ariaLabel={buttonAriaLabel}\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 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 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\">\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 granularity={granularity}\n isDateEnabled={isDateEnabled}\n dateDisabledReason={dateDisabledReason}\n i18nStrings={{\n ...i18nStrings,\n todayAriaLabel: i18nStrings?.todayAriaLabel ?? todayAriaLabel,\n nextMonthAriaLabel: i18nStrings?.nextMonthAriaLabel ?? nextMonthAriaLabel,\n previousMonthAriaLabel: i18nStrings?.previousMonthAriaLabel ?? previousMonthAriaLabel,\n }}\n />\n <InternalLiveRegion id={calendarDescriptionId} hidden={true} tagName=\"span\">\n {getBaseDateLabel({ date: baseDate, granularity, locale: normalizedLocale })}\n </InternalLiveRegion>\n </div>\n </FocusLock>\n )}\n </Dropdown>\n )}\n </div>\n );\n }\n);\n\napplyDisplayName(DatePicker, 'DatePicker');\nexport default DatePicker;\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/date-picker/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,YAAY,CAAC;;AACb,OAAO,KAAK,EAAE,EAAO,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,O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AW,EAAE,WAAW,EACxB,eAAe,EAAE,qBAAqB,EACtC,SAAS,EAAE,SAAS,EACpB,cAAc,EAAE,cAAc,EAC9B,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,aAAa,EAC5B,kBAAkB,EAAE,kBAAkB,EACtC,WAAW,kCACN,WAAW,KACd,cAAc,EAAE,MAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,cAAc,mCAAI,cAAc,EAC7D,kBAAkB,EAAE,MAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,kBAAkB,mCAAI,kBAAkB,EACzE,sBAAsB,EAAE,MAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,sBAAsB,mCAAI,sBAAsB,MAEvF;YACF,oBAAC,kBAAkB,IAAC,EAAE,EAAE,qBAAqB,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAC,MAAM,IACxE,gBAAgB,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE,gBAAgB,EAAE,CAAC,CACzD,CACjB,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\n'use client';\nimport React, { Ref, useCallback, useRef, useState } from 'react';\nimport clsx from 'clsx';\n\nimport { useMergeRefs, useUniqueId } from '@cloudscape-design/component-toolkit/internal';\n\nimport { ButtonProps } from '../button/interfaces';\nimport { InternalButton } from '../button/internal';\nimport InternalCalendar from '../calendar/internal';\nimport { useFormFieldContext } from '../contexts/form-field.js';\nimport InternalDateInput from '../date-input/internal';\nimport { useLocale } from '../i18n/context.js';\nimport { InputProps } from '../input/interfaces';\nimport { getBaseProps } from '../internal/base-component';\nimport Dropdown from '../internal/components/dropdown';\nimport FocusLock from '../internal/components/focus-lock';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport checkControlled from '../internal/hooks/check-controlled';\nimport useForwardFocus from '../internal/hooks/forward-focus';\nimport useBaseComponent from '../internal/hooks/use-base-component';\nimport { useFocusTracker } from '../internal/hooks/use-focus-tracker.js';\nimport { KeyCode } from '../internal/keycode';\nimport { applyDisplayName } from '../internal/utils/apply-display-name.js';\nimport { parseDate } from '../internal/utils/date-time';\nimport { normalizeLocale } from '../internal/utils/locale';\nimport InternalLiveRegion from '../live-region/internal';\nimport { DatePickerProps } from './interfaces';\nimport { getBaseDateLabel, getSelectedDateLabel, isValidFullDate } from './utils';\n\nimport styles from './styles.css.js';\n\nexport { DatePickerProps };\n\nconst DatePicker = React.forwardRef(\n (\n {\n locale,\n startOfWeek,\n isDateEnabled,\n dateDisabledReason,\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 warning,\n openCalendarAriaLabel,\n expandToViewport,\n granularity = 'day',\n format = 'slashed',\n inputFormat = 'slashed',\n ...restProps\n }: DatePickerProps,\n ref: Ref<DatePickerProps.Ref>\n ) => {\n const { __internalRootRef } = useBaseComponent('DatePicker', {\n props: { autoFocus, expandToViewport, granularity, readOnly },\n metadata: { hasDisabledReasons: Boolean(dateDisabledReason) },\n });\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 hasFullValue = isValidFullDate({ date: value, granularity });\n\n const buttonAriaLabel =\n openCalendarAriaLabel &&\n openCalendarAriaLabel(\n hasFullValue && parsedValue\n ? getSelectedDateLabel({ date: parsedValue, granularity, locale: normalizedLocale })\n : null\n );\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 warning={warning}\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 granularity={granularity}\n locale={locale}\n format={format}\n inputFormat={inputFormat}\n />\n </div>\n <div>\n <InternalButton\n iconName=\"calendar\"\n className={styles['open-calendar-button']}\n onClick={onButtonClickHandler}\n ref={buttonRef}\n ariaLabel={buttonAriaLabel}\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 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 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\">\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 granularity={granularity}\n isDateEnabled={isDateEnabled}\n dateDisabledReason={dateDisabledReason}\n i18nStrings={{\n ...i18nStrings,\n todayAriaLabel: i18nStrings?.todayAriaLabel ?? todayAriaLabel,\n nextMonthAriaLabel: i18nStrings?.nextMonthAriaLabel ?? nextMonthAriaLabel,\n previousMonthAriaLabel: i18nStrings?.previousMonthAriaLabel ?? previousMonthAriaLabel,\n }}\n />\n <InternalLiveRegion id={calendarDescriptionId} hidden={true} tagName=\"span\">\n {getBaseDateLabel({ date: baseDate, granularity, locale: normalizedLocale })}\n </InternalLiveRegion>\n </div>\n </FocusLock>\n )}\n </Dropdown>\n )}\n </div>\n );\n }\n);\n\napplyDisplayName(DatePicker, 'DatePicker');\nexport default DatePicker;\n"]}
@@ -3,6 +3,7 @@ import { BaseComponentProps } from '../internal/base-component';
3
3
  import { ExpandToViewport } from '../internal/components/dropdown/interfaces';
4
4
  import { FormFieldValidationControlProps } from '../internal/context/form-field-context';
5
5
  import { NonCancelableEventHandler } from '../internal/events';
6
+ import { DateFormat, DateGranularity, EditableDateFormat } from '../internal/utils/date-time/interfaces';
6
7
  export interface DatePickerProps extends BaseComponentProps, FormFieldValidationControlProps, ExpandToViewport, CalendarProps {
7
8
  /**
8
9
  * Specifies the placeholder text rendered when the value is an empty string.
@@ -51,6 +52,25 @@ export interface DatePickerProps extends BaseComponentProps, FormFieldValidation
51
52
  * Specifies whether to add `aria-required` to the native control.
52
53
  */
53
54
  ariaRequired?: boolean;
55
+ /**
56
+ * The format as it is displayed. It can take the following values:
57
+ * * `iso`: ISO 8601 format without time, e.g.: 2024-01-30 (or 2024-01)
58
+ * * `long-localized`: a more human-readable, localized format, e.g.: January 30, 2024 (or January, 2024)
59
+ * * `slashed`: similar to ISO 8601 but with '/' in place of '-'. e.g.: 2024/01/30 (or 2024/01)
60
+ *
61
+ * @default 'slashed'
62
+ */
63
+ format?: DatePickerProps.Format;
64
+ /**
65
+ * Specifies the date format to use when the format is 'long-localized' and the user needs to edit the date.
66
+ *
67
+ * The format of the input as it is being interacted with. It can take the following values:
68
+ * * `iso`: ISO 8601 format without time, e.g.: 2024-01-30 (or 2024-01)
69
+ * * `slashed`: similar to ISO 8601 but with '/' in place of '-'. e.g.: 2024/01/30 (or 2024/01)
70
+ *
71
+ * @default 'slashed'.
72
+ */
73
+ inputFormat?: DatePickerProps.InputFormat;
54
74
  /**
55
75
  * Called when input focus is moved to the UI control.
56
76
  */
@@ -86,4 +106,7 @@ export declare namespace DatePickerProps {
86
106
  focus(): void;
87
107
  }
88
108
  type I18nStrings = CalendarProps.I18nStrings;
109
+ type Granularity = DateGranularity;
110
+ type Format = DateFormat;
111
+ type InputFormat = EditableDateFormat;
89
112
  }
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/date-picker/interfaces.ts"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,CAAC,EAAE,yBAAyB,CAAC,IAAI,CAAC,CAAC;IAE1C;;OAEG;IACH,MAAM,CAAC,EAAE,yBAAyB,CAAC,IAAI,CAAC,CAAC;IAEzC;;;;OAIG;IACH,WAAW,CAAC,EAAE,eAAe,CAAC,WAAW,CAAC;CAC3C;AAED,yBAAiB,eAAe,CAAC;IAC/B,UAAiB,YAAY;QAC3B;;WAEG;QACH,KAAK,EAAE,MAAM,CAAC;KACf;IAED,UAAiB,qBAAqB;QACpC,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC;KACvB;IAED,UAAiB,qBAAqB;QACpC,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAAC;KACvC;IAED,UAAiB,GAAG;QAClB;;WAEG;QACH,KAAK,IAAI,IAAI,CAAC;KACf;IAED,KAAY,WAAW,GAAG,aAAa,CAAC,WAAW,CAAC;IAEpD,KAAY,WAAW,GAAG,eAAe,CAAC;IAE1C,KAAY,MAAM,GAAG,UAAU,CAAC;IAEhC,KAAY,WAAW,GAAG,kBAAkB,CAAC;CAC9C"}
@@ -1,2 +1,4 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
1
3
  export {};
2
4
  //# sourceMappingURL=interfaces.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/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 { CalendarProps } from '../calendar/interfaces';\nimport { BaseComponentProps } from '../internal/base-component';\nimport { ExpandToViewport } from '../internal/components/dropdown/interfaces';\nimport { FormFieldValidationControlProps } from '../internal/context/form-field-context';\nimport { NonCancelableEventHandler } from '../internal/events';\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"]}
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/date-picker/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 { CalendarProps } from '../calendar/interfaces';\nimport { BaseComponentProps } from '../internal/base-component';\nimport { ExpandToViewport } from '../internal/components/dropdown/interfaces';\nimport { FormFieldValidationControlProps } from '../internal/context/form-field-context';\nimport { NonCancelableEventHandler } from '../internal/events';\nimport { DateFormat, DateGranularity, EditableDateFormat } from '../internal/utils/date-time/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 * The format as it is displayed. It can take the following values:\n * * `iso`: ISO 8601 format without time, e.g.: 2024-01-30 (or 2024-01)\n * * `long-localized`: a more human-readable, localized format, e.g.: January 30, 2024 (or January, 2024)\n * * `slashed`: similar to ISO 8601 but with '/' in place of '-'. e.g.: 2024/01/30 (or 2024/01)\n *\n * @default 'slashed'\n */\n format?: DatePickerProps.Format;\n\n /**\n * Specifies the date format to use when the format is 'long-localized' and the user needs to edit the date.\n *\n * The format of the input as it is being interacted with. It can take the following values:\n * * `iso`: ISO 8601 format without time, e.g.: 2024-01-30 (or 2024-01)\n * * `slashed`: similar to ISO 8601 but with '/' in place of '-'. e.g.: 2024/01/30 (or 2024/01)\n *\n * @default 'slashed'.\n */\n inputFormat?: DatePickerProps.InputFormat;\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 export type Granularity = DateGranularity;\n\n export type Format = DateFormat;\n\n export type InputFormat = EditableDateFormat;\n}\n"]}
@@ -2039,5 +2039,5 @@
2039
2039
  }
2040
2040
  }
2041
2041
  :root {
2042
- --awsui-version-info-58f61d03: true;
2042
+ --awsui-version-info-d12aac57: true;
2043
2043
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/internal/components/masked-input/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAyC,MAAM,OAAO,CAAC;AAQ9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAIhD,QAAA,MAAM,WAAW,+FA0DhB,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAC5B,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/internal/components/masked-input/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAyC,MAAM,OAAO,CAAC;AAQ9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAIhD,QAAA,MAAM,WAAW,+FA2DhB,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAC5B,eAAe,WAAW,CAAC"}
@@ -31,6 +31,7 @@ const MaskedInput = React.forwardRef((_a, ref) => {
31
31
  onKeyDown: (event) => !rest.readOnly && onKeyDown && fireCancelableEvent(onKeyDown, event.detail, event),
32
32
  onBlur: () => fireNonCancelableEvent(onBlur),
33
33
  setPosition: setCursorPosition,
34
+ showUnmaskedValue,
34
35
  }), { onPaste } = _b, maskProps = __rest(_b, ["onPaste"]);
35
36
  const inputProps = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, rest), baseProps), formFieldContext), maskProps), { value: showUnmaskedValue ? value : maskProps.value });
36
37
  const mergedRef = useMergeRefs(ref, inputRef);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/components/masked-input/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAO,eAAe,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE9D,OAAO,EAAE,YAAY,EAAE,MAAM,+CAA+C,CAAC;AAE7E,OAAO,aAAa,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAE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E,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC;QACpF,MAAM,EAAE,GAAG,EAAE,CAAC,sBAAsB,CAAC,MAAM,CAAC;QAC5C,WAAW,EAAE,iBAAiB;KAC/B,CAAC,EAXI,EAAE,OAAO,OAWb,EAXkB,SAAS,cAAvB,WAAyB,CAW7B,CAAC;IAEH,MAAM,UAAU,6EACX,IAAI,GACJ,SAAS,GACT,gBAAgB,GAChB,SAAS,KACZ,KAAK,EAAE,iBAAiB,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,GACnD,CAAC;IAEF,MAAM,SAAS,GAAG,YAAY,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;IAC9C,OAAO,CACL,oBAAC,aAAa,oBACR,UAAU,IACd,GAAG,EAAE,SAAS,EACd,kBAAkB,EAAE;YAClB,OAAO;SACR,IACD,CACH,CAAC;AACJ,CAAC,CACF,CAAC;AAGF,eAAe,WAAW,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { Ref, useLayoutEffect, useState } from 'react';\n\nimport { useMergeRefs } from '@cloudscape-design/component-toolkit/internal';\n\nimport InternalInput from '../../../input/internal';\nimport { getBaseProps } from '../../base-component';\nimport { useFormFieldContext } from '../../context/form-field-context';\nimport { fireCancelableEvent, fireNonCancelableEvent } from '../../events';\nimport { MaskedInputProps } from './interfaces';\nimport useMask from './use-mask';\nimport MaskFormat from './utils/mask-format';\n\nconst MaskedInput = React.forwardRef(\n (\n {\n value,\n onBlur,\n onChange,\n onKeyDown,\n mask,\n autofix = false,\n disableAutocompleteOnBlur = false,\n showUnmaskedValue = false,\n ...rest\n }: MaskedInputProps,\n ref: Ref<MaskedInputProps.Ref>\n ) => {\n const baseProps = getBaseProps(rest);\n const formFieldContext = useFormFieldContext(rest);\n const inputRef = React.useRef<HTMLInputElement>(null);\n const [cursorPosition, setCursorPosition] = useState<number | null>(null);\n\n useLayoutEffect(() => {\n if (cursorPosition !== null) {\n inputRef.current?.setSelectionRange(cursorPosition, cursorPosition);\n }\n }, [cursorPosition, inputRef]);\n\n const { onPaste, ...maskProps } = useMask({\n format: new MaskFormat(mask),\n value,\n inputRef,\n autofix,\n disableAutocompleteOnBlur,\n onChange: (value: string) => !rest.readOnly && fireNonCancelableEvent(onChange, { value }),\n onKeyDown: (event: CustomEvent) =>\n !rest.readOnly && onKeyDown && fireCancelableEvent(onKeyDown, event.detail, event),\n onBlur: () => fireNonCancelableEvent(onBlur),\n setPosition: setCursorPosition,\n });\n\n const inputProps = {\n ...rest,\n ...baseProps,\n ...formFieldContext,\n ...maskProps,\n value: showUnmaskedValue ? value : maskProps.value,\n };\n\n const mergedRef = useMergeRefs(ref, inputRef);\n return (\n <InternalInput\n {...inputProps}\n ref={mergedRef}\n __nativeAttributes={{\n onPaste,\n }}\n />\n );\n }\n);\n\nexport { MaskedInputProps };\nexport default MaskedInput;\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/components/masked-input/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAO,eAAe,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE9D,OAAO,EAAE,YAAY,EAAE,MAAM,+CAA+C,CAAC;AAE7E,OAAO,aAAa,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAE3E,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,OAAO,UAAU,MAAM,qBAAqB,CAAC;AAE7C,MAAM,WAAW,GAAG,KAAK,CAAC,UAAU,CAClC,CACE,EAUmB,EACnB,GAA8B,EAC9B,EAAE;QAZF,EACE,KAAK,E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CAAC;IAEH,MAAM,UAAU,6EACX,IAAI,GACJ,SAAS,GACT,gBAAgB,GAChB,SAAS,KACZ,KAAK,EAAE,iBAAiB,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,GACnD,CAAC;IAEF,MAAM,SAAS,GAAG,YAAY,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;IAC9C,OAAO,CACL,oBAAC,aAAa,oBACR,UAAU,IACd,GAAG,EAAE,SAAS,EACd,kBAAkB,EAAE;YAClB,OAAO;SACR,IACD,CACH,CAAC;AACJ,CAAC,CACF,CAAC;AAGF,eAAe,WAAW,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { Ref, useLayoutEffect, useState } from 'react';\n\nimport { useMergeRefs } from '@cloudscape-design/component-toolkit/internal';\n\nimport InternalInput from '../../../input/internal';\nimport { getBaseProps } from '../../base-component';\nimport { useFormFieldContext } from '../../context/form-field-context';\nimport { fireCancelableEvent, fireNonCancelableEvent } from '../../events';\nimport { MaskedInputProps } from './interfaces';\nimport useMask from './use-mask';\nimport MaskFormat from './utils/mask-format';\n\nconst MaskedInput = React.forwardRef(\n (\n {\n value,\n onBlur,\n onChange,\n onKeyDown,\n mask,\n autofix = false,\n disableAutocompleteOnBlur = false,\n showUnmaskedValue = false,\n ...rest\n }: MaskedInputProps,\n ref: Ref<MaskedInputProps.Ref>\n ) => {\n const baseProps = getBaseProps(rest);\n const formFieldContext = useFormFieldContext(rest);\n const inputRef = React.useRef<HTMLInputElement>(null);\n const [cursorPosition, setCursorPosition] = useState<number | null>(null);\n\n useLayoutEffect(() => {\n if (cursorPosition !== null) {\n inputRef.current?.setSelectionRange(cursorPosition, cursorPosition);\n }\n }, [cursorPosition, inputRef]);\n\n const { onPaste, ...maskProps } = useMask({\n format: new MaskFormat(mask),\n value,\n inputRef,\n autofix,\n disableAutocompleteOnBlur,\n onChange: (value: string) => !rest.readOnly && fireNonCancelableEvent(onChange, { value }),\n onKeyDown: (event: CustomEvent) =>\n !rest.readOnly && onKeyDown && fireCancelableEvent(onKeyDown, event.detail, event),\n onBlur: () => fireNonCancelableEvent(onBlur),\n setPosition: setCursorPosition,\n showUnmaskedValue,\n });\n\n const inputProps = {\n ...rest,\n ...baseProps,\n ...formFieldContext,\n ...maskProps,\n value: showUnmaskedValue ? value : maskProps.value,\n };\n\n const mergedRef = useMergeRefs(ref, inputRef);\n return (\n <InternalInput\n {...inputProps}\n ref={mergedRef}\n __nativeAttributes={{\n onPaste,\n }}\n />\n );\n }\n);\n\nexport { MaskedInputProps };\nexport default MaskedInput;\n"]}
@@ -19,6 +19,7 @@ export interface UseMaskProps {
19
19
  inputRef: RefObject<HTMLInputElement>;
20
20
  disableAutocompleteOnBlur?: boolean;
21
21
  setPosition: (position: number | null) => void;
22
+ showUnmaskedValue?: boolean;
22
23
  }
23
24
  declare const useMask: ({
24
25
  value,
@@ -29,6 +30,7 @@ declare const useMask: ({
29
30
  inputRef,
30
31
  autofix,
31
32
  disableAutocompleteOnBlur,
32
- setPosition
33
+ setPosition,
34
+ showUnmaskedValue
33
35
  }: UseMaskProps) => UseMaskHook;
34
36
  export default useMask;
@@ -1 +1 @@
1
- {"version":3,"file":"use-mask.d.ts","sourceRoot":"","sources":["../../../../../src/internal/components/masked-input/use-mask.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIlC,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,sBAAsB,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AAIjF,OAAO,UAAU,MAAM,qBAAqB,CAAC;AAE7C,UAAU,WAAW;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,yBAAyB,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;IAC7D,SAAS,EAAE,sBAAsB,CAAC,UAAU,CAAC,S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,KAAK,EAAE,KAAK,CAAC,cAAc,KAAK,IAAI,CAAC;CAChD;AAED,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;IACzC,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,MAAM,EAAE,UAAU,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,SAAS,CAAC,gBAAgB,CAAC,CAAC;IACtC,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,WAAW,EAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IAC/C,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAgBD,QAAA,MAAM,OAAO,kIAWV,YAAY,KAAG,WAmEjB,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -13,8 +13,8 @@ const onAutoComplete = (value, onChange, maskFormat) => {
13
13
  }
14
14
  };
15
15
  const preventDefault = (event, result) => result && event.preventDefault();
16
- const useMask = ({ value = '', onBlur, onChange, onKeyDown, format, inputRef, autofix = false, disableAutocompleteOnBlur = false, setPosition, }) => {
17
- if (!format.isValid(value)) {
16
+ const useMask = ({ value = '', onBlur, onChange, onKeyDown, format, inputRef, autofix = false, disableAutocompleteOnBlur = false, setPosition, showUnmaskedValue = false, }) => {
17
+ if (!format.isValid(value) && !showUnmaskedValue) {
18
18
  warnOnce('useMask', `Invalid string "${value}" provided`);
19
19
  }
20
20
  const onMaskChange = (updatedValue) => {
@@ -1 +1 @@
1
- {"version":3,"file":"use-mask.js","sourceRoot":"","sources":["../../../../../src/internal/components/masked-input/use-mask.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,QAAQ,EAAE,MAAM,+CAA+C,CAAC;AAIzE,OAAO,EAAE,OAAO,EA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YAED,IAAI,MAAM,EAAE;gBACV,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAC;gBAEnC,YAAY,CAAC,KAAK,CAAC,CAAC;gBACpB,WAAW,CAAC,QAAQ,CAAC,CAAC;aACvB;YAED,uBAAuB;YACvB,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAG,KAAK,CAAC,CAAC;QACrB,CAAC;QACD,QAAQ,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,YAAY,CAAC,MAAM,CAAC,KAAK,CAAC;QACpD,MAAM,EAAE,GAAG,EAAE;YACX,IAAI,CAAC,yBAAyB,EAAE;gBAC9B,cAAc,CAAC,WAAW,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;aAC/C;YAED,MAAM,aAAN,MAAM,uBAAN,MAAM,EAAI,CAAC;QACb,CAAC;QACD,OAAO,EAAE,CAAC,KAA2B,EAAE,EAAE;;YACvC,IAAI,KAAK,CAAC,aAAa,EAAE;gBACvB,MAAM,IAAI,GAAG,KAAK,CAAC,aAAa,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;gBAEjD,MAAM,cAAc,GAAG,CAAA,MAAA,QAAQ,CAAC,OAAO,0CAAE,cAAc,KAAI,CAAC,CAAC;gBAC7D,MAAM,YAAY,GAAG,CAAA,MAAA,QAAQ,CAAC,OAAO,0CAAE,YAAY,KAAI,CAAC,CAAC;gBAEzD,MAAM,aAAa,GAAG,MAAM,CAAC,gBAAgB,CAAC,IAAI,EAAE,WAAW,EAAE,cAAc,EAAE,YAAY,CAAC,CAAC;gBAC/F,YAAY,CAAC,aAAa,CAAC,CAAC;aAC7B;QACH,CAAC;KACF,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,OAAO,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { RefObject } from 'react';\n\nimport { warnOnce } from '@cloudscape-design/component-toolkit/internal';\n\nimport { InputProps } from '../../../input/interfaces';\nimport { CancelableEventHandler, NonCancelableEventHandler } from '../../events';\nimport { KeyCode } from '../../keycode';\nimport { backspaceHandler, enterHandler, HandlerResult, keyHandler } from './keyboard-handler';\nimport { isCommand, isDigit } from './utils/keys';\nimport MaskFormat from './utils/mask-format';\n\ninterface UseMaskHook {\n value: string;\n onChange: NonCancelableEventHandler<InputProps.ChangeDetail>;\n onKeyDown: CancelableEventHandler<InputProps.KeyDetail>;\n onBlur: NonCancelableEventHandler<null>;\n onPaste: (event: React.ClipboardEvent) => void;\n}\n\nexport interface UseMaskProps {\n value: string;\n onChange: (value: string) => void;\n onKeyDown?: (event: CustomEvent) => void;\n onBlur?: () => void;\n format: MaskFormat;\n autofix?: boolean;\n inputRef: RefObject<HTMLInputElement>;\n disableAutocompleteOnBlur?: boolean;\n setPosition: (position: number | null) => void;\n}\n\nconst onAutoComplete = (value: string, onChange: UseMaskProps['onChange'], maskFormat: MaskFormat) => {\n // Do not autocomplete if input is empty\n if (!value) {\n return;\n }\n\n const autoCompletedValue = maskFormat.autoComplete(value);\n if (autoCompletedValue !== value) {\n onChange(autoCompletedValue);\n }\n};\n\nconst preventDefault = (event: CustomEvent, result?: HandlerResult | null) => result && event.preventDefault();\n\nconst useMask = ({\n value = '',\n onBlur,\n onChange,\n onKeyDown,\n format,\n inputRef,\n autofix = false,\n disableAutocompleteOnBlur = false,\n setPosition,\n}: UseMaskProps): UseMaskHook => {\n if (!format.isValid(value)) {\n warnOnce('useMask', `Invalid string \"${value}\" provided`);\n }\n\n const onMaskChange = (updatedValue: string) => {\n const autofixedUpdatedValue = autofix ? format.correctMinMaxValues(updatedValue) : updatedValue;\n if (autofixedUpdatedValue === value || !format.isValid(autofixedUpdatedValue)) {\n return;\n }\n\n onChange(autofixedUpdatedValue);\n };\n\n const initialValue = autofix ? format.correctMinMaxValues(value) : value;\n const maskedValue = format.getValidValue(initialValue);\n\n return {\n value: maskedValue,\n onKeyDown: (event: CustomEvent) => {\n const selectionStart = inputRef.current?.selectionStart || 0;\n const selectionEnd = inputRef.current?.selectionEnd || 0;\n\n let result: HandlerResult | undefined;\n const { keyCode, key, ctrlKey, metaKey } = event.detail;\n if (isDigit(key) || format.isSeparator(key)) {\n result = keyHandler(maskedValue, key, format, selectionStart, selectionEnd);\n preventDefault(event, result);\n } else if (keyCode === KeyCode.backspace) {\n result = backspaceHandler(maskedValue, format, selectionStart, selectionEnd);\n preventDefault(event, result);\n } else if (keyCode === KeyCode.enter) {\n result = enterHandler(maskedValue, format);\n } else if (!isCommand(keyCode, ctrlKey, metaKey)) {\n event.preventDefault();\n }\n\n if (result) {\n const { value, position } = result;\n\n onMaskChange(value);\n setPosition(position);\n }\n\n // Proxy original event\n onKeyDown?.(event);\n },\n onChange: ({ detail }) => onMaskChange(detail.value),\n onBlur: () => {\n if (!disableAutocompleteOnBlur) {\n onAutoComplete(maskedValue, onChange, format);\n }\n\n onBlur?.();\n },\n onPaste: (event: React.ClipboardEvent) => {\n if (event.clipboardData) {\n const text = event.clipboardData.getData('text');\n\n const selectionStart = inputRef.current?.selectionStart || 0;\n const selectionEnd = inputRef.current?.selectionEnd || 0;\n\n const formattedText = format.formatPastedText(text, maskedValue, selectionStart, selectionEnd);\n onMaskChange(formattedText);\n }\n },\n };\n};\n\nexport default useMask;\n"]}
1
+ {"version":3,"file":"use-mask.js","sourceRoot":"","sources":["../../../../../src/internal/components/masked-input/use-mask.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,QAAQ,EAAE,MAAM,+CAA+C,CAAC;AAIzE,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAiB,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC/F,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAwBlD,MAAM,cAAc,GAAG,CAAC,KAAa,EAAE,QAAkC,EAAE,UAAsB,EAAE,EAAE;IACnG,wCAAwC;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AAT,SAAS,CAAG,KAAK,CAAC,CAAC;QACrB,CAAC;QACD,QAAQ,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,YAAY,CAAC,MAAM,CAAC,KAAK,CAAC;QACpD,MAAM,EAAE,GAAG,EAAE;YACX,IAAI,CAAC,yBAAyB,EAAE;gBAC9B,cAAc,CAAC,WAAW,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;aAC/C;YAED,MAAM,aAAN,MAAM,uBAAN,MAAM,EAAI,CAAC;QACb,CAAC;QACD,OAAO,EAAE,CAAC,KAA2B,EAAE,EAAE;;YACvC,IAAI,KAAK,CAAC,aAAa,EAAE;gBACvB,MAAM,IAAI,GAAG,KAAK,CAAC,aAAa,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;gBAEjD,MAAM,cAAc,GAAG,CAAA,MAAA,QAAQ,CAAC,OAAO,0CAAE,cAAc,KAAI,CAAC,CAAC;gBAC7D,MAAM,YAAY,GAAG,CAAA,MAAA,QAAQ,CAAC,OAAO,0CAAE,YAAY,KAAI,CAAC,CAAC;gBAEzD,MAAM,aAAa,GAAG,MAAM,CAAC,gBAAgB,CAAC,IAAI,EAAE,WAAW,EAAE,cAAc,EAAE,YAAY,CAAC,CAAC;gBAC/F,YAAY,CAAC,aAAa,CAAC,CAAC;aAC7B;QACH,CAAC;KACF,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,OAAO,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { RefObject } from 'react';\n\nimport { warnOnce } from '@cloudscape-design/component-toolkit/internal';\n\nimport { InputProps } from '../../../input/interfaces';\nimport { CancelableEventHandler, NonCancelableEventHandler } from '../../events';\nimport { KeyCode } from '../../keycode';\nimport { backspaceHandler, enterHandler, HandlerResult, keyHandler } from './keyboard-handler';\nimport { isCommand, isDigit } from './utils/keys';\nimport MaskFormat from './utils/mask-format';\n\ninterface UseMaskHook {\n value: string;\n onChange: NonCancelableEventHandler<InputProps.ChangeDetail>;\n onKeyDown: CancelableEventHandler<InputProps.KeyDetail>;\n onBlur: NonCancelableEventHandler<null>;\n onPaste: (event: React.ClipboardEvent) => void;\n}\n\nexport interface UseMaskProps {\n value: string;\n onChange: (value: string) => void;\n onKeyDown?: (event: CustomEvent) => void;\n onBlur?: () => void;\n format: MaskFormat;\n autofix?: boolean;\n inputRef: RefObject<HTMLInputElement>;\n disableAutocompleteOnBlur?: boolean;\n setPosition: (position: number | null) => void;\n showUnmaskedValue?: boolean;\n}\n\nconst onAutoComplete = (value: string, onChange: UseMaskProps['onChange'], maskFormat: MaskFormat) => {\n // Do not autocomplete if input is empty\n if (!value) {\n return;\n }\n\n const autoCompletedValue = maskFormat.autoComplete(value);\n if (autoCompletedValue !== value) {\n onChange(autoCompletedValue);\n }\n};\n\nconst preventDefault = (event: CustomEvent, result?: HandlerResult | null) => result && event.preventDefault();\n\nconst useMask = ({\n value = '',\n onBlur,\n onChange,\n onKeyDown,\n format,\n inputRef,\n autofix = false,\n disableAutocompleteOnBlur = false,\n setPosition,\n showUnmaskedValue = false,\n}: UseMaskProps): UseMaskHook => {\n if (!format.isValid(value) && !showUnmaskedValue) {\n warnOnce('useMask', `Invalid string \"${value}\" provided`);\n }\n\n const onMaskChange = (updatedValue: string) => {\n const autofixedUpdatedValue = autofix ? format.correctMinMaxValues(updatedValue) : updatedValue;\n if (autofixedUpdatedValue === value || !format.isValid(autofixedUpdatedValue)) {\n return;\n }\n\n onChange(autofixedUpdatedValue);\n };\n\n const initialValue = autofix ? format.correctMinMaxValues(value) : value;\n const maskedValue = format.getValidValue(initialValue);\n\n return {\n value: maskedValue,\n onKeyDown: (event: CustomEvent) => {\n const selectionStart = inputRef.current?.selectionStart || 0;\n const selectionEnd = inputRef.current?.selectionEnd || 0;\n\n let result: HandlerResult | undefined;\n const { keyCode, key, ctrlKey, metaKey } = event.detail;\n if (isDigit(key) || format.isSeparator(key)) {\n result = keyHandler(maskedValue, key, format, selectionStart, selectionEnd);\n preventDefault(event, result);\n } else if (keyCode === KeyCode.backspace) {\n result = backspaceHandler(maskedValue, format, selectionStart, selectionEnd);\n preventDefault(event, result);\n } else if (keyCode === KeyCode.enter) {\n result = enterHandler(maskedValue, format);\n } else if (!isCommand(keyCode, ctrlKey, metaKey)) {\n event.preventDefault();\n }\n\n if (result) {\n const { value, position } = result;\n\n onMaskChange(value);\n setPosition(position);\n }\n\n // Proxy original event\n onKeyDown?.(event);\n },\n onChange: ({ detail }) => onMaskChange(detail.value),\n onBlur: () => {\n if (!disableAutocompleteOnBlur) {\n onAutoComplete(maskedValue, onChange, format);\n }\n\n onBlur?.();\n },\n onPaste: (event: React.ClipboardEvent) => {\n if (event.clipboardData) {\n const text = event.clipboardData.getData('text');\n\n const selectionStart = inputRef.current?.selectionStart || 0;\n const selectionEnd = inputRef.current?.selectionEnd || 0;\n\n const formattedText = format.formatPastedText(text, maskedValue, selectionStart, selectionEnd);\n onMaskChange(formattedText);\n }\n },\n };\n};\n\nexport default useMask;\n"]}
@@ -33,5 +33,5 @@ export interface SplitPanelContextProps extends SplitPanelContextBaseProps {
33
33
  relativeSize: number;
34
34
  animationDisabled?: boolean;
35
35
  }
36
- export declare const SplitPanelContextProvider: React.Provider<SplitPanelContextProps | null>;
36
+ export declare const SplitPanelContextProvider: React.Provider<SplitPanelContextProps | null | undefined>;
37
37
  export declare function useSplitPanelContext(): SplitPanelContextProps;
@@ -1 +1 @@
1
- {"version":3,"file":"split-panel-context.d.ts","sourceRoot":"","sources":["../../../../src/internal/context/split-panel-context.ts"],"names":[],"mappings":"AAEA,OAAO,KAAoC,MAAM,OAAO,CAAC;AAEzD,OAAO,EAAE,0BAA0B,EAAE,MAAM,sDAAsD,CAAC;AAElG,MAAM,WAAW,yBAAyB;IACxC,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;CAC/B;AAED,MAAM,WAAW,0BAA0B;IACzC,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,GAAG,QAAQ,CAAC;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,kBAAkB,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IACzC,sBAAsB,CAAC,EAAE;QACvB,SAAS,EAAE,OAAO,CAAC;QACnB,WAAW,EAAE,OAAO,CAAC;KACtB,CAAC;IACF,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,QAAQ,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,mBAAmB,EAAE,CAAC,MAAM,EAAE;QAAE,QAAQ,EAAE,MAAM,GAAG,QAAQ,CAAA;KAAE,KAAK,IAAI,CAAC;IACvE,kBAAkB,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,mBAAmB,EAAE,CAAC,MAAM,EAAE,yBAAyB,KAAK,IAAI,CAAC;IACjE,IAAI,EAAE,0BAA0B,CAAC;CAClC;AAED,MAAM,WAAW,sBAAuB,SAAQ,0BAA0B;IACxE,YAAY,EAAE,MAAM,CAAC;IACrB,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAID,eAAO,MAAM,yBAAyB,+CAA6B,CAAC;AAEpE,wBAAgB,oBAAoB,2BAMnC"}
1
+ {"version":3,"file":"split-panel-context.d.ts","sourceRoot":"","sources":["../../../../src/internal/context/split-panel-context.ts"],"names":[],"mappings":"AAEA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAE1C,OAAO,EAAE,0BAA0B,EAAE,MAAM,sDAAsD,CAAC;AAGlG,MAA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Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
- import { createContext, useContext } from 'react';
4
- const SplitPanelContext = createContext(null);
5
- export const SplitPanelContextProvider = SplitPanelContext.Provider;
3
+ import React, { useContext } from 'react';
4
+ import { awsuiPluginsInternal } from '../plugins/api';
5
+ const AppLayoutWidgetSplitPanelContext = awsuiPluginsInternal.sharedReactContexts.createContext(React, 'AppLayoutWidgetSplitPanelContext');
6
+ export const SplitPanelContextProvider = AppLayoutWidgetSplitPanelContext.Provider;
6
7
  export function useSplitPanelContext() {
7
- const ctx = useContext(SplitPanelContext);
8
+ const ctx = useContext(AppLayoutWidgetSplitPanelContext);
8
9
  if (!ctx) {
9
10
  throw new Error('Split panel can only be used inside app layout');
10
11
  }
@@ -1 +1 @@
1
- {"version":3,"file":"split-panel-context.js","sourceRoot":"","sources":["../../../../src/internal/context/split-panel-context.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAc,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAsCzD,MAAM,iBAAiB,GAAG,aAAa,CAAgC,IAAI,CAAC,CAAC;AAE7E,MAAM,CAAC,MAAM,yBAAyB,GAAG,iBAAiB,CAAC,QAAQ,CAAC;AAEpE,MAAM,UAAU,oBAAoB;IAClC,MAAM,GAAG,GAAG,UAAU,CAAC,iBAAiB,CAAC,CAAC;IAC1C,IAAI,CAAC,GAAG,EAAE;QACR,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;KACnE;IACD,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { createContext, useContext } from 'react';\n\nimport { SplitPanelFocusControlRefs } from '../../app-layout/utils/use-split-panel-focus-control';\n\nexport interface SplitPanelSideToggleProps {\n displayed: boolean;\n ariaLabel: string | undefined;\n}\n\nexport interface SplitPanelContextBaseProps {\n topOffset: number;\n bottomOffset: number;\n leftOffset: number;\n rightOffset: number;\n position: 'side' | 'bottom';\n size: number;\n disableContentPaddings?: boolean;\n contentWidthStyles?: React.CSSProperties;\n contentWrapperPaddings?: {\n closedNav: boolean;\n closedTools: boolean;\n };\n isOpen?: boolean;\n isForcedPosition: boolean;\n onResize: (newSize: number) => void;\n onToggle: () => void;\n onPreferencesChange: (detail: { position: 'side' | 'bottom' }) => void;\n reportHeaderHeight: (pixels: number) => void;\n headerHeight?: number;\n setSplitPanelToggle: (config: SplitPanelSideToggleProps) => void;\n refs: SplitPanelFocusControlRefs;\n}\n\nexport interface SplitPanelContextProps extends SplitPanelContextBaseProps {\n relativeSize: number;\n animationDisabled?: boolean;\n}\n\nconst SplitPanelContext = createContext<SplitPanelContextProps | null>(null);\n\nexport const SplitPanelContextProvider = SplitPanelContext.Provider;\n\nexport function useSplitPanelContext() {\n const ctx = useContext(SplitPanelContext);\n if (!ctx) {\n throw new Error('Split panel can only be used inside app layout');\n }\n return ctx;\n}\n"]}
1
+ {"version":3,"file":"split-panel-context.js","sourceRoot":"","sources":["../../../../src/internal/context/split-panel-context.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAG1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAoCtD,MAAM,gCAAgC,GACpC,oBAAoB,CAAC,mBAAmB,CAAC,aAAa,CACpD,KAAK,EACL,kCAAkC,CACnC,CAAC;AAEJ,MAAM,CAAC,MAAM,yBAAyB,GAAG,gCAAgC,CAAC,QAAQ,CAAC;AAEnF,MAAM,UAAU,oBAAoB;IAClC,MAAM,GAAG,GAAG,UAAU,CAAC,gCAAgC,CAAC,CAAC;IACzD,IAAI,CAAC,GAAG,EAAE;QACR,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;KACnE;IACD,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useContext } from 'react';\n\nimport { SplitPanelFocusControlRefs } from '../../app-layout/utils/use-split-panel-focus-control';\nimport { awsuiPluginsInternal } from '../plugins/api';\n\nexport interface SplitPanelSideToggleProps {\n displayed: boolean;\n ariaLabel: string | undefined;\n}\n\nexport interface SplitPanelContextBaseProps {\n topOffset: number;\n bottomOffset: number;\n leftOffset: number;\n rightOffset: number;\n position: 'side' | 'bottom';\n size: number;\n disableContentPaddings?: boolean;\n contentWidthStyles?: React.CSSProperties;\n contentWrapperPaddings?: {\n closedNav: boolean;\n closedTools: boolean;\n };\n isOpen?: boolean;\n isForcedPosition: boolean;\n onResize: (newSize: number) => void;\n onToggle: () => void;\n onPreferencesChange: (detail: { position: 'side' | 'bottom' }) => void;\n reportHeaderHeight: (pixels: number) => void;\n headerHeight?: number;\n setSplitPanelToggle: (config: SplitPanelSideToggleProps) => void;\n refs: SplitPanelFocusControlRefs;\n}\n\nexport interface SplitPanelContextProps extends SplitPanelContextBaseProps {\n relativeSize: number;\n animationDisabled?: boolean;\n}\n\nconst AppLayoutWidgetSplitPanelContext =\n awsuiPluginsInternal.sharedReactContexts.createContext<SplitPanelContextProps | null>(\n React,\n 'AppLayoutWidgetSplitPanelContext'\n );\n\nexport const SplitPanelContextProvider = AppLayoutWidgetSplitPanelContext.Provider;\n\nexport function useSplitPanelContext() {\n const ctx = useContext(AppLayoutWidgetSplitPanelContext);\n if (!ctx) {\n throw new Error('Split panel can only be used inside app layout');\n }\n return ctx;\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  export var PACKAGE_SOURCE = "components";
2
- export var PACKAGE_VERSION = "3.0.0 (58f61d03)";
3
- export var GIT_SHA = "58f61d03";
2
+ export var PACKAGE_VERSION = "3.0.0 (d12aac57)";
3
+ export var GIT_SHA = "d12aac57";
4
4
  export var THEME = "open-source-visual-refresh";
5
5
  export var SYSTEM = "console";
6
6
  export var ALWAYS_VISUAL_REFRESH = true;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "PACKAGE_SOURCE": "components",
3
- "PACKAGE_VERSION": "3.0.0 (58f61d03)",
4
- "GIT_SHA": "58f61d03",
3
+ "PACKAGE_VERSION": "3.0.0 (d12aac57)",
4
+ "GIT_SHA": "d12aac57",
5
5
  "THEME": "open-source-visual-refresh",
6
6
  "SYSTEM": "console",
7
7
  "ALWAYS_VISUAL_REFRESH": true
@@ -1,3 +1,3 @@
1
1
  {
2
- "commit": "58f61d030206557bcf35a3128075ef0ff5712afe"
2
+ "commit": "d12aac57013b0d0b361d44f2af5e0c44294ab01c"
3
3
  }
package/package.json CHANGED
@@ -150,7 +150,7 @@
150
150
  "./internal/base-component/index.js",
151
151
  "./internal/base-component/styles.css.js"
152
152
  ],
153
- "version": "3.0.1058",
153
+ "version": "3.0.1060",
154
154
  "repository": {
155
155
  "type": "git",
156
156
  "url": "https://github.com/cloudscape-design/components.git"