@cloudscape-design/components 3.0.1047 → 3.0.1049

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/app-layout/visual-refresh-toolbar/skeleton/breadcrumbs/index.d.ts.map +1 -1
  2. package/app-layout/visual-refresh-toolbar/skeleton/breadcrumbs/index.js +4 -2
  3. package/app-layout/visual-refresh-toolbar/skeleton/breadcrumbs/index.js.map +1 -1
  4. package/app-layout/visual-refresh-toolbar/skeleton/breadcrumbs/styles.css.js +7 -0
  5. package/app-layout/visual-refresh-toolbar/skeleton/breadcrumbs/styles.scoped.css +7 -0
  6. package/app-layout/visual-refresh-toolbar/skeleton/breadcrumbs/styles.selectors.js +8 -0
  7. package/attribute-editor/styles.css.js +15 -15
  8. package/attribute-editor/styles.scoped.css +28 -28
  9. package/attribute-editor/styles.selectors.js +15 -15
  10. package/breadcrumb-group/item/styles.css.js +7 -7
  11. package/breadcrumb-group/item/styles.scoped.css +28 -28
  12. package/breadcrumb-group/item/styles.selectors.js +7 -7
  13. package/button-dropdown/item-element/styles.css.js +16 -16
  14. package/button-dropdown/item-element/styles.scoped.css +27 -27
  15. package/button-dropdown/item-element/styles.selectors.js +16 -16
  16. package/date-input/index.d.ts +1 -1
  17. package/date-input/index.d.ts.map +1 -1
  18. package/date-input/index.js.map +1 -1
  19. package/date-input/interfaces.d.ts +29 -0
  20. package/date-input/interfaces.d.ts.map +1 -1
  21. package/date-input/interfaces.js.map +1 -1
  22. package/date-input/internal.d.ts +1 -4
  23. package/date-input/internal.d.ts.map +1 -1
  24. package/date-input/internal.js +39 -4
  25. package/date-input/internal.js.map +1 -1
  26. package/date-input/utils.d.ts +9 -1
  27. package/date-input/utils.d.ts.map +1 -1
  28. package/date-input/utils.js +32 -7
  29. package/date-input/utils.js.map +1 -1
  30. package/help-panel/styles.css.js +6 -6
  31. package/help-panel/styles.scoped.css +73 -73
  32. package/help-panel/styles.selectors.js +6 -6
  33. package/internal/base-component/styles.scoped.css +1 -1
  34. package/internal/components/masked-input/index.d.ts.map +1 -1
  35. package/internal/components/masked-input/index.js +2 -2
  36. package/internal/components/masked-input/index.js.map +1 -1
  37. package/internal/components/masked-input/interfaces.d.ts +6 -1
  38. package/internal/components/masked-input/interfaces.d.ts.map +1 -1
  39. package/internal/components/masked-input/interfaces.js.map +1 -1
  40. package/internal/components/masked-input/use-mask.d.ts +1 -1
  41. package/internal/components/masked-input/use-mask.d.ts.map +1 -1
  42. package/internal/components/masked-input/use-mask.js +7 -5
  43. package/internal/components/masked-input/use-mask.js.map +1 -1
  44. package/internal/components/masked-input/utils/mask-format.d.ts.map +1 -1
  45. package/internal/components/masked-input/utils/mask-format.js +19 -20
  46. package/internal/components/masked-input/utils/mask-format.js.map +1 -1
  47. package/internal/components/token-list/styles.css.js +10 -10
  48. package/internal/components/token-list/styles.scoped.css +25 -25
  49. package/internal/components/token-list/styles.selectors.js +10 -10
  50. package/internal/environment.js +2 -2
  51. package/internal/environment.json +2 -2
  52. package/internal/manifest.json +1 -1
  53. package/internal/plugins/helpers/use-global-breadcrumbs.d.ts.map +1 -1
  54. package/internal/plugins/helpers/use-global-breadcrumbs.js +5 -1
  55. package/internal/plugins/helpers/use-global-breadcrumbs.js.map +1 -1
  56. package/internal/utils/date-time/format-date-iso.d.ts.map +1 -1
  57. package/internal/utils/date-time/format-date-iso.js.map +1 -1
  58. package/internal/utils/date-time/interfaces.d.ts +16 -0
  59. package/internal/utils/date-time/interfaces.d.ts.map +1 -0
  60. package/internal/utils/date-time/interfaces.js +4 -0
  61. package/internal/utils/date-time/interfaces.js.map +1 -0
  62. package/link/index.d.ts.map +1 -1
  63. package/link/index.js +11 -27
  64. package/link/interfaces.d.ts +23 -0
  65. package/link/interfaces.d.ts.map +1 -1
  66. package/link/interfaces.js.map +1 -1
  67. package/link/internal-do-not-use-core.js +34 -0
  68. package/link/internal-do-not-use-core.js.map +1 -0
  69. package/link/internal.d.ts.map +1 -1
  70. package/link/internal.js +3 -2
  71. package/link/internal.js.map +1 -1
  72. package/link/style.d.ts +2 -0
  73. package/link/style.d.ts.map +1 -0
  74. package/link/style.js +21 -0
  75. package/link/style.js.map +1 -0
  76. package/link/styles.css.js +20 -20
  77. package/link/styles.scoped.css +103 -102
  78. package/link/styles.selectors.js +20 -20
  79. package/package.json +1 -1
  80. package/table/body-cell/styles.css.js +47 -47
  81. package/table/body-cell/styles.scoped.css +374 -375
  82. package/table/body-cell/styles.selectors.js +47 -47
  83. package/tag-editor/styles.css.js +3 -3
  84. package/tag-editor/styles.scoped.css +13 -13
  85. package/tag-editor/styles.selectors.js +3 -3
  86. package/text-content/styles.css.js +1 -1
  87. package/text-content/styles.scoped.css +66 -66
  88. package/text-content/styles.selectors.js +1 -1
  89. package/link/index.js.map +0 -1
@@ -2,21 +2,21 @@
2
2
  // es-module interop with Babel and Typescript
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  module.exports.default = {
5
- "item-element": "awsui_item-element_93a1u_idixt_145",
6
- "disabled": "awsui_disabled_93a1u_idixt_157",
7
- "show-divider": "awsui_show-divider_93a1u_idixt_164",
8
- "highlighted": "awsui_highlighted_93a1u_idixt_167",
9
- "is-focused": "awsui_is-focused_93a1u_idixt_182",
10
- "visual-refresh": "awsui_visual-refresh_93a1u_idixt_185",
11
- "menu-item": "awsui_menu-item_93a1u_idixt_189",
12
- "link-style": "awsui_link-style_93a1u_idixt_201",
13
- "current-breadcrumb": "awsui_current-breadcrumb_93a1u_idixt_237",
14
- "link-style-highlighted": "awsui_link-style-highlighted_93a1u_idixt_245",
15
- "has-category-header": "awsui_has-category-header_93a1u_idixt_251",
16
- "item-tooltip-wrapper": "awsui_item-tooltip-wrapper_93a1u_idixt_251",
17
- "has-checkmark": "awsui_has-checkmark_93a1u_idixt_251",
18
- "icon": "awsui_icon_93a1u_idixt_255",
19
- "checkmark": "awsui_checkmark_93a1u_idixt_259",
20
- "external-icon": "awsui_external-icon_93a1u_idixt_266"
5
+ "item-element": "awsui_item-element_93a1u_so9cs_145",
6
+ "disabled": "awsui_disabled_93a1u_so9cs_157",
7
+ "show-divider": "awsui_show-divider_93a1u_so9cs_164",
8
+ "highlighted": "awsui_highlighted_93a1u_so9cs_167",
9
+ "is-focused": "awsui_is-focused_93a1u_so9cs_182",
10
+ "visual-refresh": "awsui_visual-refresh_93a1u_so9cs_185",
11
+ "menu-item": "awsui_menu-item_93a1u_so9cs_189",
12
+ "link-style": "awsui_link-style_93a1u_so9cs_201",
13
+ "current-breadcrumb": "awsui_current-breadcrumb_93a1u_so9cs_237",
14
+ "link-style-highlighted": "awsui_link-style-highlighted_93a1u_so9cs_245",
15
+ "has-category-header": "awsui_has-category-header_93a1u_so9cs_251",
16
+ "item-tooltip-wrapper": "awsui_item-tooltip-wrapper_93a1u_so9cs_251",
17
+ "has-checkmark": "awsui_has-checkmark_93a1u_so9cs_251",
18
+ "icon": "awsui_icon_93a1u_so9cs_255",
19
+ "checkmark": "awsui_checkmark_93a1u_so9cs_259",
20
+ "external-icon": "awsui_external-icon_93a1u_so9cs_266"
21
21
  };
22
22
 
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
2
  import { DateInputProps } from './interfaces';
3
3
  export { DateInputProps };
4
- declare const DateInput: React.ForwardRefExoticComponent<DateInputProps & React.RefAttributes<HTMLInputElement>>;
4
+ declare const DateInput: React.ForwardRefExoticComponent<DateInputProps & React.RefAttributes<import("..").InputProps.Ref>>;
5
5
  export default DateInput;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/date-input/index.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAc,MAAM,OAAO,CAAC;AAInC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAG9C,OAAO,EAAE,cAAc,EAAE,CAAC;AAE1B,QAAA,MAAM,SAAS,yFAKb,CAAC;AAIH,eAAe,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/date-input/index.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAc,MAAM,OAAO,CAAC;AAInC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAG9C,OAAO,EAAE,cAAc,EAAE,CAAC;AAE1B,QAAA,MAAM,SAAS,oGAKb,CAAC;AAIH,eAAe,SAAS,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/date-input/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,YAAY,CAAC;AACb,OAAO,KAAc,MAAM,OAAO,CAAC;AAEnC,OAAO,gBAAgB,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAExE,OAAO,iBAAiB,MAAM,YAAY,CAAC;AAI3C,MAAM,SAAS,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,KAAqB,EAAE,GAA0B,EAAE,EAAE;IACvF,MAAM,kBAAkB,GAAG,gBAAgB,CAAC,WAAW,EAAE;QACvD,KAAK,EAAE,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE;KAChE,CAAC,CAAC;IACH,OAAO,oBAAC,iBAAiB,oBAAK,KAAK,EAAM,kBAAkB,IAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAC5E,CAAC,CAAC,CAAC;AAEH,gBAAgB,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;AAEzC,eAAe,SAAS,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\n'use client';\nimport React, { Ref } from 'react';\n\nimport useBaseComponent from '../internal/hooks/use-base-component';\nimport { applyDisplayName } from '../internal/utils/apply-display-name';\nimport { DateInputProps } from './interfaces';\nimport InternalDateInput from './internal';\n\nexport { DateInputProps };\n\nconst DateInput = React.forwardRef((props: DateInputProps, ref: Ref<HTMLInputElement>) => {\n const baseComponentProps = useBaseComponent('DateInput', {\n props: { autoFocus: props.autoFocus, readOnly: props.readOnly },\n });\n return <InternalDateInput {...props} {...baseComponentProps} ref={ref} />;\n});\n\napplyDisplayName(DateInput, 'DateInput');\n\nexport default DateInput;\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/date-input/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,YAAY,CAAC;AACb,OAAO,KAAc,MAAM,OAAO,CAAC;AAEnC,OAAO,gBAAgB,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAExE,OAAO,iBAAiB,MAAM,YAAY,CAAC;AAI3C,MAAM,SAAS,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,KAAqB,EAAE,GAA4B,EAAE,EAAE;IACzF,MAAM,kBAAkB,GAAG,gBAAgB,CAAC,WAAW,EAAE;QACvD,KAAK,EAAE,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE;KAChE,CAAC,CAAC;IACH,OAAO,oBAAC,iBAAiB,oBAAK,KAAK,EAAM,kBAAkB,IAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAC5E,CAAC,CAAC,CAAC;AAEH,gBAAgB,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;AAEzC,eAAe,SAAS,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\n'use client';\nimport React, { Ref } from 'react';\n\nimport useBaseComponent from '../internal/hooks/use-base-component';\nimport { applyDisplayName } from '../internal/utils/apply-display-name';\nimport { DateInputProps } from './interfaces';\nimport InternalDateInput from './internal';\n\nexport { DateInputProps };\n\nconst DateInput = React.forwardRef((props: DateInputProps, ref: Ref<DateInputProps.Ref>) => {\n const baseComponentProps = useBaseComponent('DateInput', {\n props: { autoFocus: props.autoFocus, readOnly: props.readOnly },\n });\n return <InternalDateInput {...props} {...baseComponentProps} ref={ref} />;\n});\n\napplyDisplayName(DateInput, 'DateInput');\n\nexport default DateInput;\n"]}
@@ -1,12 +1,41 @@
1
1
  import { BaseInputProps, InputProps } from '../input/interfaces';
2
2
  import { BaseComponentProps } from '../internal/base-component';
3
3
  import { FormFieldValidationControlProps } from '../internal/context/form-field-context';
4
+ import { DateFormat, DateGranularity, EditableDateFormat } from '../internal/utils/date-time/interfaces';
4
5
  export interface DateInputProps extends BaseInputProps, FormFieldValidationControlProps, BaseComponentProps {
5
6
  /**
6
7
  * The current input value, in YYYY-MM-DD format.
7
8
  */
8
9
  value: string;
10
+ /**
11
+ * Specifies the locale to use to render month names and determine the starting day of the week.
12
+ * If you don't provide this, the locale is determined by the page and browser locales.
13
+ * Supported values and formats are listed in the [JavaScript Intl API specification](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_identification_and_negotiation).
14
+ */
15
+ locale?: string;
16
+ /**
17
+ * Specifies the granularity at which users will be able to select a date.
18
+ * Defaults to `day`.
19
+ **/
20
+ granularity?: DateInputProps.Granularity;
21
+ /**
22
+ * The format as it is displayed. It can take the following values:
23
+ * * `iso`: ISO 8601 format without time, e.g.: 2024-01-30 (or 2024-01).
24
+ * * `long-localized`: a more human-readable, localized format, e.g.: January 30, 2024 (or January, 2024).
25
+ * * `slashed`: similar to ISO 8601 but with '/' in place of '-'. e.g.: 2024/01/30 (or 2024/01).
26
+ */
27
+ format?: DateInputProps.Format;
28
+ /**
29
+ * Specifies the date format to use when the format is 'long-localized' and editing the date.
30
+ * The format of the input as it is being interacted with. It can take the following values:
31
+ * * `iso`: ISO 8601 format without time, e.g.: 2024-01-30 (or 2024-01).
32
+ * * `slashed`: similar to ISO 8601 but with '/' in place of '-'. e.g.: 2024/01/30 (or 2024/01).
33
+ */
34
+ inputFormat?: DateInputProps.InputFormat;
9
35
  }
10
36
  export declare namespace DateInputProps {
11
37
  type Ref = InputProps.Ref;
38
+ type Format = DateFormat;
39
+ type InputFormat = EditableDateFormat;
40
+ type Granularity = DateGranularity;
12
41
  }
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/date-input/interfaces.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,+BAA+B,EAAE,MAAM,wCAAwC,CAAC;AAEzF,MAAM,WAAW,cAAe,SAAQ,cAAc,EAAE,+BAA+B,EAAE,kBAAkB;IACzG;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;CACf;AAED,yBAAiB,cAAc,CAAC;IAC9B,KAAY,GAAG,GAAG,UAAU,CAAC,GAAG,CAAC;CAClC"}
1
+ {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/date-input/interfaces.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,+BAA+B,EAAE,MAAM,wCAAwC,CAAC;AACzF,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAEzG,MAAM,WAAW,cAAe,SAAQ,cAAc,EAAE,+BAA+B,EAAE,kBAAkB;IACzG;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;QAGI;IACJ,WAAW,CAAC,EAAE,cAAc,CAAC,WAAW,CAAC;IAEzC;;;;;OAKG;IACH,MAAM,CAAC,EAAE,cAAc,CAAC,MAAM,CAAC;IAE/B;;;;;OAKG;IACH,WAAW,CAAC,EAAE,cAAc,CAAC,WAAW,CAAC;CAC1C;AAED,yBAAiB,cAAc,CAAC;IAC9B,KAAY,GAAG,GAAG,UAAU,CAAC,GAAG,CAAC;IAEjC,KAAY,MAAM,GAAG,UAAU,CAAC;IAEhC,KAAY,WAAW,GAAG,kBAAkB,CAAC;IAE7C,KAAY,WAAW,GAAG,eAAe,CAAC;CAC3C"}
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/date-input/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 { BaseInputProps, InputProps } from '../input/interfaces';\nimport { BaseComponentProps } from '../internal/base-component';\nimport { FormFieldValidationControlProps } from '../internal/context/form-field-context';\n\nexport interface DateInputProps extends BaseInputProps, FormFieldValidationControlProps, BaseComponentProps {\n /**\n * The current input value, in YYYY-MM-DD format.\n */\n value: string;\n}\n\nexport namespace DateInputProps {\n export type Ref = InputProps.Ref;\n}\n"]}
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/date-input/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 { BaseInputProps, InputProps } from '../input/interfaces';\nimport { BaseComponentProps } from '../internal/base-component';\nimport { FormFieldValidationControlProps } from '../internal/context/form-field-context';\nimport { DateFormat, DateGranularity, EditableDateFormat } from '../internal/utils/date-time/interfaces';\n\nexport interface DateInputProps extends BaseInputProps, FormFieldValidationControlProps, BaseComponentProps {\n /**\n * The current input value, in YYYY-MM-DD format.\n */\n value: string;\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 [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 * Specifies the granularity at which users will be able to select a date.\n * Defaults to `day`.\n **/\n granularity?: DateInputProps.Granularity;\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 format?: DateInputProps.Format;\n\n /**\n * Specifies the date format to use when the format is 'long-localized' and editing the date.\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 inputFormat?: DateInputProps.InputFormat;\n}\n\nexport namespace DateInputProps {\n export type Ref = InputProps.Ref;\n\n export type Format = DateFormat;\n\n export type InputFormat = EditableDateFormat;\n\n export type Granularity = DateGranularity;\n}\n"]}
@@ -1,8 +1,5 @@
1
1
  import React from 'react';
2
- import { CalendarProps } from '../calendar/interfaces';
3
2
  import { InternalBaseComponentProps } from '../internal/hooks/use-base-component';
4
3
  import { DateInputProps } from './interfaces';
5
- declare const InternalDateInput: React.ForwardRefExoticComponent<DateInputProps & InternalBaseComponentProps<any> & {
6
- granularity?: CalendarProps.Granularity | undefined;
7
- } & React.RefAttributes<HTMLInputElement>>;
4
+ declare const InternalDateInput: React.ForwardRefExoticComponent<DateInputProps & InternalBaseComponentProps<any> & React.RefAttributes<import("..").InputProps.Ref>>;
8
5
  export default InternalDateInput;
@@ -1 +1 @@
1
- {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/date-input/internal.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAc,MAAM,OAAO,CAAC;AAGnC,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAGvD,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAElF,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAU9C,QAAA,MAAM,iBAAiB;;0CAqBtB,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
1
+ {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/date-input/internal.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAyC,MAAM,OAAO,CAAC;AAM9D,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAIlF,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAO9C,QAAA,MAAM,iBAAiB,sIAyEtB,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
@@ -1,16 +1,51 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  import { __rest } from "tslib";
4
- import React from 'react';
4
+ import React, { useMemo, useRef, useState } from 'react';
5
5
  import clsx from 'clsx';
6
6
  import MaskedInput from '../internal/components/masked-input';
7
7
  import { fireNonCancelableEvent } from '../internal/events';
8
+ import useForwardFocus from '../internal/hooks/forward-focus';
8
9
  import { displayToIso, isoToDisplay } from '../internal/utils/date-time';
9
- import { generateMaskArgs } from './utils';
10
+ import formatDateIso from '../internal/utils/date-time/format-date-iso';
11
+ import formatDateLocalized from '../internal/utils/date-time/format-date-localized';
12
+ import { generateMaskArgs, normalizeIsoDateString } from './utils';
10
13
  import styles from './styles.css.js';
11
14
  const InternalDateInput = React.forwardRef((_a, ref) => {
12
- var { value, onChange, granularity, __internalRootRef = null } = _a, props = __rest(_a, ["value", "onChange", "granularity", "__internalRootRef"]);
13
- return (React.createElement(MaskedInput, Object.assign({ ref: ref }, props, { value: isoToDisplay(value || ''), onChange: event => fireNonCancelableEvent(onChange, { value: displayToIso(event.detail.value) }), className: clsx(styles.root, props.className), mask: generateMaskArgs({ granularity }), autofix: true, autoComplete: false, disableAutocompleteOnBlur: false, disableBrowserAutocorrect: true, __internalRootRef: __internalRootRef })));
15
+ var { value, onChange, onBlur, onFocus, granularity = 'day', locale, format = 'slashed', inputFormat = 'slashed', __internalRootRef = null } = _a, props = __rest(_a, ["value", "onChange", "onBlur", "onFocus", "granularity", "locale", "format", "inputFormat", "__internalRootRef"]);
16
+ const [isFocused, setIsFocused] = useState(false);
17
+ const inputRef = useRef(null);
18
+ const isIso = format === 'iso' || (format === 'long-localized' && inputFormat === 'iso');
19
+ useForwardFocus(ref, inputRef);
20
+ const onInputFocus = (event) => {
21
+ setIsFocused(true);
22
+ onFocus === null || onFocus === void 0 ? void 0 : onFocus(event);
23
+ };
24
+ const onInputBlur = (event) => {
25
+ setIsFocused(false);
26
+ onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
27
+ };
28
+ const onInputChange = (event) => {
29
+ const isNonFocusedLongLocalized = format === 'long-localized' && !(isFocused || props.readOnly);
30
+ if (!isNonFocusedLongLocalized) {
31
+ fireNonCancelableEvent(onChange, { value: displayToIso(event.detail.value) });
32
+ }
33
+ };
34
+ const usesLongLocalizedValue = format === 'long-localized' && !(isFocused && !props.readOnly);
35
+ const displayedValue = useMemo(() => {
36
+ if (!value) {
37
+ return '';
38
+ }
39
+ const isoValue = displayToIso(value);
40
+ const formatProps = { hideTimeOffset: true, isDateOnly: true, isMonthOnly: granularity === 'month', locale };
41
+ const normalizedValue = normalizeIsoDateString(isoValue, granularity);
42
+ return usesLongLocalizedValue && normalizedValue
43
+ ? formatDateLocalized(Object.assign({ date: normalizedValue }, formatProps))
44
+ : isIso
45
+ ? formatDateIso(Object.assign({ date: isoValue }, formatProps))
46
+ : isoToDisplay(isoValue);
47
+ }, [value, isIso, granularity, locale, usesLongLocalizedValue]);
48
+ return (React.createElement(MaskedInput, Object.assign({ ref: inputRef }, props, { value: displayedValue, onChange: onInputChange, onFocus: onInputFocus, onBlur: onInputBlur, className: clsx(styles.root, props.className), mask: generateMaskArgs({ granularity, isIso }), autofix: !usesLongLocalizedValue, disableAutocompleteOnBlur: false, disableBrowserAutocorrect: true, showUnmaskedValue: usesLongLocalizedValue, autoComplete: false, __internalRootRef: __internalRootRef })));
14
49
  });
15
50
  export default InternalDateInput;
16
51
  //# sourceMappingURL=internal.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/date-input/internal.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;;AAEtC,OAAO,KAAc,MAAM,OAAO,CAAC;AACnC,OAAO,IAAI,MAAM,MAAM,CAAC;AAGxB,OAAO,WAAW,MAAM,qCAAqC,CAAC;AAC9D,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAE5D,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE3C,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAOrC,MAAM,iBAAiB,GAAG,KAAK,CAAC,UAAU,CACxC,CACE,EAA4F,EAC5F,GAA0B,EAC1B,EAAE;QAFF,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,iBAAiB,GAAG,IAAI,OAAoC,EAA/B,KAAK,cAAlE,yDAAoE,CAAF;IAGlE,OAAO,CACL,oBAAC,WAAW,kBACV,GAAG,EAAE,GAAG,IACJ,KAAK,IACT,KAAK,EAAE,YAAY,CAAC,KAAK,IAAI,EAAE,CAAC,EAChC,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,sBAAsB,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,YAAY,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,EAChG,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,SAAS,CAAC,EAC7C,IAAI,EAAE,gBAAgB,CAAC,EAAE,WAAW,EAAE,CAAC,EACvC,OAAO,EAAE,IAAI,EACb,YAAY,EAAE,KAAK,EACnB,yBAAyB,EAAE,KAAK,EAChC,yBAAyB,EAAE,IAAI,EAC/B,iBAAiB,EAAE,iBAAiB,IACpC,CACH,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,iBAAiB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React, { Ref } from 'react';\nimport clsx from 'clsx';\n\nimport { CalendarProps } from '../calendar/interfaces';\nimport MaskedInput from '../internal/components/masked-input';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport { displayToIso, isoToDisplay } from '../internal/utils/date-time';\nimport { DateInputProps } from './interfaces';\nimport { generateMaskArgs } from './utils';\n\nimport styles from './styles.css.js';\n\ntype InternalDateInputProps = DateInputProps &\n InternalBaseComponentProps & {\n granularity?: CalendarProps.Granularity;\n };\n\nconst InternalDateInput = React.forwardRef(\n (\n { value, onChange, granularity, __internalRootRef = null, ...props }: InternalDateInputProps,\n ref: Ref<HTMLInputElement>\n ) => {\n return (\n <MaskedInput\n ref={ref}\n {...props}\n value={isoToDisplay(value || '')}\n onChange={event => fireNonCancelableEvent(onChange, { value: displayToIso(event.detail.value) })}\n className={clsx(styles.root, props.className)}\n mask={generateMaskArgs({ granularity })}\n autofix={true}\n autoComplete={false}\n disableAutocompleteOnBlur={false}\n disableBrowserAutocorrect={true}\n __internalRootRef={__internalRootRef}\n />\n );\n }\n);\n\nexport default InternalDateInput;\n"]}
1
+ {"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/date-input/internal.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;;AAEtC,OAAO,KAAK,EAAE,EAAO,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC9D,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,WAAW,M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AW,kBACV,GAAG,EAAE,QAAQ,IACT,KAAK,IACT,KAAK,EAAE,cAAc,EACrB,QAAQ,EAAE,aAAa,EACvB,OAAO,EAAE,YAAY,EACrB,MAAM,EAAE,WAAW,EACnB,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,SAAS,CAAC,EAC7C,IAAI,EAAE,gBAAgB,CAAC,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC,EAC9C,OAAO,EAAE,CAAC,sBAAsB,EAChC,yBAAyB,EAAE,KAAK,EAChC,yBAAyB,EAAE,IAAI,EAC/B,iBAAiB,EAAE,sBAAsB,EACzC,YAAY,EAAE,KAAK,EACnB,iBAAiB,EAAE,iBAAiB,IACpC,CACH,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,iBAAiB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React, { Ref, useMemo, useRef, useState } from 'react';\nimport clsx from 'clsx';\n\nimport MaskedInput from '../internal/components/masked-input';\nimport { fireNonCancelableEvent, NonCancelableCustomEvent } from '../internal/events';\nimport useForwardFocus from '../internal/hooks/forward-focus';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport { displayToIso, isoToDisplay } from '../internal/utils/date-time';\nimport formatDateIso from '../internal/utils/date-time/format-date-iso';\nimport formatDateLocalized from '../internal/utils/date-time/format-date-localized';\nimport { DateInputProps } from './interfaces';\nimport { generateMaskArgs, normalizeIsoDateString } from './utils';\n\nimport styles from './styles.css.js';\n\ntype InternalDateInputProps = DateInputProps & InternalBaseComponentProps;\n\nconst InternalDateInput = React.forwardRef(\n (\n {\n value,\n onChange,\n onBlur,\n onFocus,\n granularity = 'day',\n locale,\n format = 'slashed',\n inputFormat = 'slashed',\n __internalRootRef = null,\n ...props\n }: InternalDateInputProps,\n ref: Ref<DateInputProps.Ref>\n ) => {\n const [isFocused, setIsFocused] = useState(false);\n const inputRef = useRef<HTMLInputElement>(null);\n const isIso = format === 'iso' || (format === 'long-localized' && inputFormat === 'iso');\n\n useForwardFocus(ref, inputRef);\n\n const onInputFocus = (event: NonCancelableCustomEvent<null>) => {\n setIsFocused(true);\n onFocus?.(event);\n };\n\n const onInputBlur = (event: NonCancelableCustomEvent<null>) => {\n setIsFocused(false);\n onBlur?.(event);\n };\n\n const onInputChange = (event: NonCancelableCustomEvent<{ value: string }>) => {\n const isNonFocusedLongLocalized = format === 'long-localized' && !(isFocused || props.readOnly);\n if (!isNonFocusedLongLocalized) {\n fireNonCancelableEvent(onChange, { value: displayToIso(event.detail.value) });\n }\n };\n\n const usesLongLocalizedValue = format === 'long-localized' && !(isFocused && !props.readOnly);\n const displayedValue = useMemo(() => {\n if (!value) {\n return '';\n }\n const isoValue = displayToIso(value);\n const formatProps = { hideTimeOffset: true, isDateOnly: true, isMonthOnly: granularity === 'month', locale };\n const normalizedValue = normalizeIsoDateString(isoValue, granularity);\n return usesLongLocalizedValue && normalizedValue\n ? formatDateLocalized({ date: normalizedValue, ...formatProps })\n : isIso\n ? formatDateIso({ date: isoValue, ...formatProps })\n : isoToDisplay(isoValue);\n }, [value, isIso, granularity, locale, usesLongLocalizedValue]);\n\n return (\n <MaskedInput\n ref={inputRef}\n {...props}\n value={displayedValue}\n onChange={onInputChange}\n onFocus={onInputFocus}\n onBlur={onInputBlur}\n className={clsx(styles.root, props.className)}\n mask={generateMaskArgs({ granularity, isIso })}\n autofix={!usesLongLocalizedValue}\n disableAutocompleteOnBlur={false}\n disableBrowserAutocorrect={true}\n showUnmaskedValue={usesLongLocalizedValue}\n autoComplete={false}\n __internalRootRef={__internalRootRef}\n />\n );\n }\n);\n\nexport default InternalDateInput;\n"]}
@@ -6,4 +6,12 @@ export interface GenerateMaskArgsProps extends Pick<CalendarProps, 'granularity'
6
6
  export declare const generateMaskArgs: ({
7
7
  granularity,
8
8
  isIso
9
- }?: GenerateMaskArgsProps) => MaskArgs;
9
+ }?: GenerateMaskArgsProps) => MaskArgs;
10
+ /**
11
+ * Normalizes a partial ISO date string by trimming incomplete segments.
12
+ *
13
+ * @param dateString - The date string to normalize (e.g., "2012-", "2012-0", "2012-01-3").
14
+ * @param granularity - The level of detail required ('month' or 'day').
15
+ * @returns a properly formatted date string or empty string, if invalid.
16
+ */
17
+ export declare function normalizeIsoDateString(dateString: string, granularity: CalendarProps.Granularity): string;
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/date-input/utils.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,uDAAuD,CAAC;AAajF,MAAM,WAAW,qBAAsB,SAAQ,IAAI,CAAC,aAAa,EAAE,aAAa,CAAC;IAC/E,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,eAAO,MAAM,gBAAgB,6BAO1B,qBAAqB,KAAQ,QAM/B,CAAC"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/date-input/utils.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,uDAAuD,CAAC;AAcjF,MAAM,WAAW,qBAAsB,SAAQ,IAAI,CAAC,aAAa,EAAE,aAAa,CAAC;IAC/E,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,eAAO,MAAM,gBAAgB,6BAO1B,qBAAqB,KAAQ,QAM/B,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,aAAa,CAAC,WAAW,GAAG,MAAM,CAgBzG"}
@@ -2,24 +2,49 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  import { getDaysInMonth } from 'date-fns';
4
4
  import { displayToIso, parseDate } from '../internal/utils/date-time';
5
- function daysMax(value) {
6
- // force to first day in month, as new Date('2018-02-30') -> March 2nd 2018
5
+ const yearMask = { min: 0, max: 9999, default: 2000, length: 4 };
6
+ const monthMask = { min: 1, max: 12, length: 2 };
7
+ const dayMask = { min: 1, max: getMaxDaysForDate, length: 2 };
8
+ function getMaxDaysForDate(value) {
9
+ // Forcing to first day in month to ensure the correct month is used in case the date is incorrect.
10
+ // For example, the date '2018-02-30' is parsed as '2018-03-02' (because there is only 28 days in February 2018).
7
11
  const baseDate = displayToIso(value).substring(0, 7);
8
12
  return getDaysInMonth(parseDate(baseDate));
9
13
  }
10
- const yearMask = { min: 0, max: 9999, default: 2000, length: 4 };
11
- const monthMask = { min: 1, max: 12, length: 2 };
12
- const dayMask = { min: 1, max: daysMax, length: 2 };
13
14
  export const generateMaskArgs = ({ granularity = 'day',
14
15
  /**
15
16
  * There are only two options, 'iso' and 'slashed' which is our current default format. If more formats are entered
16
- * we should take the formatting type rather than teh boolean when we make an update
17
+ * we should take the formatting type rather than the boolean when we make an update.
17
18
  */
18
19
  isIso = false, } = {}) => {
19
20
  return {
20
21
  separator: isIso ? '-' : '/',
21
- inputSeparators: [...(isIso ? ['/'] : ['-']), '.', ' '],
22
+ inputSeparators: isIso ? ['/', '.', ' '] : ['-', '.', ' '],
22
23
  segments: granularity === 'month' ? [yearMask, monthMask] : [yearMask, monthMask, dayMask],
23
24
  };
24
25
  };
26
+ /**
27
+ * Normalizes a partial ISO date string by trimming incomplete segments.
28
+ *
29
+ * @param dateString - The date string to normalize (e.g., "2012-", "2012-0", "2012-01-3").
30
+ * @param granularity - The level of detail required ('month' or 'day').
31
+ * @returns a properly formatted date string or empty string, if invalid.
32
+ */
33
+ export function normalizeIsoDateString(dateString, granularity) {
34
+ if (!dateString) {
35
+ return '';
36
+ }
37
+ const match = dateString.match(/^(\d{4})(?:-(\d{1,2})?)?(?:-(\d{1,2})?)?$/);
38
+ if (!match) {
39
+ return '';
40
+ }
41
+ const [, year, month, day] = match;
42
+ if (granularity === 'day' && (month === null || month === void 0 ? void 0 : month.length) === 2 && (day === null || day === void 0 ? void 0 : day.length) === 2) {
43
+ return `${year}-${month}-${day}`;
44
+ }
45
+ if ((month === null || month === void 0 ? void 0 : month.length) === 2) {
46
+ return `${year}-${month}`;
47
+ }
48
+ return year;
49
+ }
25
50
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/date-input/utils.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAI1C,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAEtE,SAAS,OAAO,CAAC,KAAa;IAC5B,2EAA2E;IAC3E,MAAM,QAAQ,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACrD,OAAO,cAAc,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC;AAC7C,CAAC;AAED,MAAM,QAAQ,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;AACjE,MAAM,SAAS,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;AACjD,MAAM,OAAO,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;AAMpD,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,EAC/B,WAAW,GAAG,KAAK;AACnB;;;GAGG;AACH,KAAK,GAAG,KAAK,MACY,EAAE,EAAY,EAAE;IACzC,OAAO;QACL,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG;QAC5B,eAAe,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC;QACvD,QAAQ,EAAE,WAAW,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,SAAS,EAAE,OAAO,CAAC;KAC3F,CAAC;AACJ,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { getDaysInMonth } from 'date-fns';\n\nimport { CalendarProps } from '../calendar/interfaces';\nimport { MaskArgs } from '../internal/components/masked-input/utils/mask-format';\nimport { displayToIso, parseDate } from '../internal/utils/date-time';\n\nfunction daysMax(value: string): number {\n // force to first day in month, as new Date('2018-02-30') -> March 2nd 2018\n const baseDate = displayToIso(value).substring(0, 7);\n return getDaysInMonth(parseDate(baseDate));\n}\n\nconst yearMask = { min: 0, max: 9999, default: 2000, length: 4 };\nconst monthMask = { min: 1, max: 12, length: 2 };\nconst dayMask = { min: 1, max: daysMax, length: 2 };\n\nexport interface GenerateMaskArgsProps extends Pick<CalendarProps, 'granularity'> {\n isIso?: boolean;\n}\n\nexport const generateMaskArgs = ({\n granularity = 'day',\n /**\n * There are only two options, 'iso' and 'slashed' which is our current default format. If more formats are entered\n * we should take the formatting type rather than teh boolean when we make an update\n */\n isIso = false,\n}: GenerateMaskArgsProps = {}): MaskArgs => {\n return {\n separator: isIso ? '-' : '/',\n inputSeparators: [...(isIso ? ['/'] : ['-']), '.', ' '],\n segments: granularity === 'month' ? [yearMask, monthMask] : [yearMask, monthMask, dayMask],\n };\n};\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/date-input/utils.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAE,cAAc,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;AACH,MAAM,UAAU,sBAAsB,CAAC,UAAkB,EAAE,WAAsC;IAC/F,IAAI,CAAC,UAAU,EAAE;QACf,OAAO,EAAE,CAAC;KACX;IACD,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,2CAA2C,CAAC,CAAC;IAC5E,IAAI,CAAC,KAAK,EAAE;QACV,OAAO,EAAE,CAAC;KACX;IACD,MAAM,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,GAAG,KAAK,CAAC;IACnC,IAAI,WAAW,KAAK,KAAK,IAAI,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,MAAM,MAAK,CAAC,IAAI,CAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,MAAM,MAAK,CAAC,EAAE;QACrE,OAAO,GAAG,IAAI,IAAI,KAAK,IAAI,GAAG,EAAE,CAAC;KAClC;IACD,IAAI,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,MAAM,MAAK,CAAC,EAAE;QACvB,OAAO,GAAG,IAAI,IAAI,KAAK,EAAE,CAAC;KAC3B;IACD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { getDaysInMonth } from 'date-fns';\n\nimport { CalendarProps } from '../calendar/interfaces';\nimport { MaskArgs } from '../internal/components/masked-input/utils/mask-format';\nimport { displayToIso, parseDate } from '../internal/utils/date-time';\n\nconst yearMask = { min: 0, max: 9999, default: 2000, length: 4 };\nconst monthMask = { min: 1, max: 12, length: 2 };\nconst dayMask = { min: 1, max: getMaxDaysForDate, length: 2 };\n\nfunction getMaxDaysForDate(value: string): number {\n // Forcing to first day in month to ensure the correct month is used in case the date is incorrect.\n // For example, the date '2018-02-30' is parsed as '2018-03-02' (because there is only 28 days in February 2018).\n const baseDate = displayToIso(value).substring(0, 7);\n return getDaysInMonth(parseDate(baseDate));\n}\n\nexport interface GenerateMaskArgsProps extends Pick<CalendarProps, 'granularity'> {\n isIso?: boolean;\n}\n\nexport const generateMaskArgs = ({\n granularity = 'day',\n /**\n * There are only two options, 'iso' and 'slashed' which is our current default format. If more formats are entered\n * we should take the formatting type rather than the boolean when we make an update.\n */\n isIso = false,\n}: GenerateMaskArgsProps = {}): MaskArgs => {\n return {\n separator: isIso ? '-' : '/',\n inputSeparators: isIso ? ['/', '.', ' '] : ['-', '.', ' '],\n segments: granularity === 'month' ? [yearMask, monthMask] : [yearMask, monthMask, dayMask],\n };\n};\n\n/**\n * Normalizes a partial ISO date string by trimming incomplete segments.\n *\n * @param dateString - The date string to normalize (e.g., \"2012-\", \"2012-0\", \"2012-01-3\").\n * @param granularity - The level of detail required ('month' or 'day').\n * @returns a properly formatted date string or empty string, if invalid.\n */\nexport function normalizeIsoDateString(dateString: string, granularity: CalendarProps.Granularity): string {\n if (!dateString) {\n return '';\n }\n const match = dateString.match(/^(\\d{4})(?:-(\\d{1,2})?)?(?:-(\\d{1,2})?)?$/);\n if (!match) {\n return '';\n }\n const [, year, month, day] = match;\n if (granularity === 'day' && month?.length === 2 && day?.length === 2) {\n return `${year}-${month}-${day}`;\n }\n if (month?.length === 2) {\n return `${year}-${month}`;\n }\n return year;\n}\n"]}
@@ -1,11 +1,11 @@
1
1
 
2
2
  import './styles.scoped.css';
3
3
  export default {
4
- "help-panel": "awsui_help-panel_1d237_wbmoj_181",
5
- "loading": "awsui_loading_1d237_wbmoj_348",
6
- "header": "awsui_header_1d237_wbmoj_353",
7
- "with-toolbar": "awsui_with-toolbar_1d237_wbmoj_371",
8
- "content": "awsui_content_1d237_wbmoj_390",
9
- "footer": "awsui_footer_1d237_wbmoj_441"
4
+ "help-panel": "awsui_help-panel_1d237_2srcz_181",
5
+ "loading": "awsui_loading_1d237_2srcz_348",
6
+ "header": "awsui_header_1d237_2srcz_353",
7
+ "with-toolbar": "awsui_with-toolbar_1d237_2srcz_371",
8
+ "content": "awsui_content_1d237_2srcz_390",
9
+ "footer": "awsui_footer_1d237_2srcz_441"
10
10
  };
11
11