@cloudscape-design/components 3.0.51 → 3.0.54
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/collection-preferences/styles.css.js +19 -19
- package/collection-preferences/styles.scoped.css +20 -21
- package/collection-preferences/styles.selectors.js +19 -19
- package/{internal/components/date-input → date-input}/index.d.ts +1 -1
- package/date-input/index.d.ts.map +1 -0
- package/date-input/index.js +15 -0
- package/date-input/index.js.map +1 -0
- package/date-input/interfaces.d.ts +9 -0
- package/date-input/interfaces.d.ts.map +1 -0
- package/date-input/interfaces.js +4 -0
- package/date-input/interfaces.js.map +1 -0
- package/date-input/internal.d.ts +6 -0
- package/date-input/internal.d.ts.map +1 -0
- package/date-input/internal.js +30 -0
- package/date-input/internal.js.map +1 -0
- package/date-input/styles.css.js +6 -0
- package/date-input/styles.scoped.css +7 -0
- package/date-input/styles.selectors.js +7 -0
- package/date-picker/calendar/grid/index.d.ts +4 -8
- package/date-picker/calendar/grid/index.d.ts.map +1 -1
- package/date-picker/calendar/grid/index.js +4 -6
- package/date-picker/calendar/grid/index.js.map +1 -1
- package/date-picker/calendar/index.d.ts +11 -19
- package/date-picker/calendar/index.d.ts.map +1 -1
- package/date-picker/calendar/index.js +29 -19
- package/date-picker/calendar/index.js.map +1 -1
- package/date-picker/calendar/utils/memoized-date.d.ts +1 -1
- package/date-picker/calendar/utils/memoized-date.d.ts.map +1 -1
- package/date-picker/calendar/utils/memoized-date.js +1 -1
- package/date-picker/calendar/utils/memoized-date.js.map +1 -1
- package/date-picker/index.d.ts.map +1 -1
- package/date-picker/index.js +11 -19
- package/date-picker/index.js.map +1 -1
- package/date-range-picker/calendar/index.js +3 -3
- package/date-range-picker/calendar/index.js.map +1 -1
- package/internal/environment.js +1 -1
- package/package.json +1 -1
- package/property-filter/index.d.ts.map +1 -1
- package/property-filter/index.js +1 -1
- package/property-filter/index.js.map +1 -1
- package/property-filter/property-filter-autosuggest.d.ts.map +1 -1
- package/property-filter/property-filter-autosuggest.js +4 -2
- package/property-filter/property-filter-autosuggest.js.map +1 -1
- package/property-filter/styles.css.js +30 -27
- package/property-filter/styles.scoped.css +59 -34
- package/property-filter/styles.selectors.js +30 -27
- package/property-filter/token-editor.d.ts.map +1 -1
- package/property-filter/token-editor.js +17 -22
- package/property-filter/token-editor.js.map +1 -1
- package/test-utils/dom/date-input/index.d.ts +4 -0
- package/test-utils/dom/date-input/index.js +31 -0
- package/test-utils/dom/date-input/index.js.map +1 -0
- package/test-utils/selectors/date-input/index.d.ts +4 -0
- package/test-utils/selectors/date-input/index.js +31 -0
- package/test-utils/selectors/date-input/index.js.map +1 -0
- package/test-utils/tsconfig.tsbuildinfo +1 -1
- package/date-picker/calendar/definitions.d.ts +0 -9
- package/date-picker/calendar/definitions.d.ts.map +0 -1
- package/date-picker/calendar/definitions.js +0 -2
- package/date-picker/calendar/definitions.js.map +0 -1
- package/date-picker/embedded.d.ts +0 -3
- package/date-picker/embedded.d.ts.map +0 -1
- package/date-picker/embedded.js +0 -15
- package/date-picker/embedded.js.map +0 -1
- package/date-picker/use-date-picker.d.ts +0 -17
- package/date-picker/use-date-picker.d.ts.map +0 -1
- package/date-picker/use-date-picker.js +0 -48
- package/date-picker/use-date-picker.js.map +0 -1
- package/internal/components/date-input/index.d.ts.map +0 -1
- package/internal/components/date-input/index.js +0 -28
- package/internal/components/date-input/index.js.map +0 -1
- package/internal/components/date-input/interfaces.d.ts +0 -16
- package/internal/components/date-input/interfaces.d.ts.map +0 -1
- package/internal/components/date-input/interfaces.js +0 -2
- package/internal/components/date-input/interfaces.js.map +0 -1
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
|
|
2
2
|
import './styles.scoped.css';
|
|
3
3
|
export default {
|
|
4
|
-
"visible-content": "awsui_visible-
|
|
5
|
-
"visible-content-toggle": "awsui_visible-content-
|
|
6
|
-
"visible-content-groups": "awsui_visible-content-
|
|
7
|
-
"visible-content-group": "awsui_visible-content-
|
|
8
|
-
"visible-content-title": "awsui_visible-content-
|
|
9
|
-
"visible-content-group-label": "awsui_visible-content-group-
|
|
10
|
-
"visible-content-option": "awsui_visible-content-
|
|
11
|
-
"visible-content-option-label": "awsui_visible-content-option-
|
|
12
|
-
"root": "
|
|
13
|
-
"modal-root": "awsui_modal-
|
|
14
|
-
"trigger-button": "awsui_trigger-
|
|
15
|
-
"cancel-button": "awsui_cancel-
|
|
16
|
-
"confirm-button": "awsui_confirm-
|
|
17
|
-
"custom": "
|
|
18
|
-
"second-column-small": "awsui_second-column-
|
|
19
|
-
"wrap-lines": "awsui_wrap-
|
|
20
|
-
"page-size": "awsui_page-
|
|
21
|
-
"page-size-form-field": "awsui_page-size-form-
|
|
22
|
-
"page-size-radio-group": "awsui_page-size-radio-
|
|
4
|
+
"visible-content": "awsui_visible-content_tc96w_1qp7a_185",
|
|
5
|
+
"visible-content-toggle": "awsui_visible-content-toggle_tc96w_1qp7a_186",
|
|
6
|
+
"visible-content-groups": "awsui_visible-content-groups_tc96w_1qp7a_187",
|
|
7
|
+
"visible-content-group": "awsui_visible-content-group_tc96w_1qp7a_187",
|
|
8
|
+
"visible-content-title": "awsui_visible-content-title_tc96w_1qp7a_192",
|
|
9
|
+
"visible-content-group-label": "awsui_visible-content-group-label_tc96w_1qp7a_200",
|
|
10
|
+
"visible-content-option": "awsui_visible-content-option_tc96w_1qp7a_206",
|
|
11
|
+
"visible-content-option-label": "awsui_visible-content-option-label_tc96w_1qp7a_217",
|
|
12
|
+
"root": "awsui_root_tc96w_1qp7a_224",
|
|
13
|
+
"modal-root": "awsui_modal-root_tc96w_1qp7a_225",
|
|
14
|
+
"trigger-button": "awsui_trigger-button_tc96w_1qp7a_226",
|
|
15
|
+
"cancel-button": "awsui_cancel-button_tc96w_1qp7a_227",
|
|
16
|
+
"confirm-button": "awsui_confirm-button_tc96w_1qp7a_228",
|
|
17
|
+
"custom": "awsui_custom_tc96w_1qp7a_229",
|
|
18
|
+
"second-column-small": "awsui_second-column-small_tc96w_1qp7a_233",
|
|
19
|
+
"wrap-lines": "awsui_wrap-lines_tc96w_1qp7a_237",
|
|
20
|
+
"page-size": "awsui_page-size_tc96w_1qp7a_238",
|
|
21
|
+
"page-size-form-field": "awsui_page-size-form-field_tc96w_1qp7a_239",
|
|
22
|
+
"page-size-radio-group": "awsui_page-size-radio-group_tc96w_1qp7a_240"
|
|
23
23
|
};
|
|
24
24
|
|
|
@@ -182,14 +182,14 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
|
|
|
182
182
|
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
183
183
|
SPDX-License-Identifier: Apache-2.0
|
|
184
184
|
*/
|
|
185
|
-
.awsui_visible-
|
|
186
|
-
.awsui_visible-content-
|
|
187
|
-
.awsui_visible-content-
|
|
188
|
-
.awsui_visible-content-
|
|
185
|
+
.awsui_visible-content_tc96w_1qp7a_185:not(#\9),
|
|
186
|
+
.awsui_visible-content-toggle_tc96w_1qp7a_186:not(#\9),
|
|
187
|
+
.awsui_visible-content-groups_tc96w_1qp7a_187:not(#\9),
|
|
188
|
+
.awsui_visible-content-group_tc96w_1qp7a_187:not(#\9) {
|
|
189
189
|
/* used in test-utils */
|
|
190
190
|
}
|
|
191
191
|
|
|
192
|
-
.awsui_visible-content-
|
|
192
|
+
.awsui_visible-content-title_tc96w_1qp7a_192:not(#\9) {
|
|
193
193
|
font-size: var(--font-body-m-size-sregvd, 14px);
|
|
194
194
|
line-height: var(--font-body-m-line-height-i7xxvv, 22px);
|
|
195
195
|
font-weight: var(--font-display-label-weight-m18hjh, 700);
|
|
@@ -197,47 +197,46 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
|
|
|
197
197
|
margin-bottom: var(--space-scaled-l-t03y3z, 20px);
|
|
198
198
|
}
|
|
199
199
|
|
|
200
|
-
.awsui_visible-content-group-
|
|
200
|
+
.awsui_visible-content-group-label_tc96w_1qp7a_200:not(#\9) {
|
|
201
201
|
color: var(--color-text-group-label-w9to2i, #414d5c);
|
|
202
202
|
padding-bottom: var(--space-xs-rsr2qu, 8px);
|
|
203
203
|
border-bottom: var(--border-divider-list-width-hacikr, 1px) solid var(--color-border-divider-default-7s2wjw, #e9ebed);
|
|
204
204
|
}
|
|
205
205
|
|
|
206
|
-
.awsui_visible-content-
|
|
206
|
+
.awsui_visible-content-option_tc96w_1qp7a_206:not(#\9) {
|
|
207
207
|
display: flex;
|
|
208
208
|
flex-wrap: nowrap;
|
|
209
209
|
justify-content: space-between;
|
|
210
210
|
padding: var(--space-xs-rsr2qu, 8px) 0px var(--space-xs-rsr2qu, 8px) var(--space-scaled-l-t03y3z, 20px);
|
|
211
211
|
border-bottom: var(--border-divider-list-width-hacikr, 1px) solid var(--color-border-divider-default-7s2wjw, #e9ebed);
|
|
212
212
|
}
|
|
213
|
-
.awsui_visible-content-
|
|
213
|
+
.awsui_visible-content-option_tc96w_1qp7a_206:not(#\9):last-child {
|
|
214
214
|
border-bottom: none;
|
|
215
215
|
}
|
|
216
216
|
|
|
217
|
-
.awsui_visible-content-option-
|
|
218
|
-
white-space: nowrap;
|
|
217
|
+
.awsui_visible-content-option-label_tc96w_1qp7a_217:not(#\9) {
|
|
219
218
|
overflow: hidden;
|
|
220
219
|
text-overflow: ellipsis;
|
|
221
220
|
padding-right: var(--space-l-4vl6xu, 20px);
|
|
222
221
|
flex-grow: 1;
|
|
223
222
|
}
|
|
224
223
|
|
|
225
|
-
.
|
|
226
|
-
.awsui_modal-
|
|
227
|
-
.awsui_trigger-
|
|
228
|
-
.awsui_cancel-
|
|
229
|
-
.awsui_confirm-
|
|
230
|
-
.
|
|
224
|
+
.awsui_root_tc96w_1qp7a_224:not(#\9),
|
|
225
|
+
.awsui_modal-root_tc96w_1qp7a_225:not(#\9),
|
|
226
|
+
.awsui_trigger-button_tc96w_1qp7a_226:not(#\9),
|
|
227
|
+
.awsui_cancel-button_tc96w_1qp7a_227:not(#\9),
|
|
228
|
+
.awsui_confirm-button_tc96w_1qp7a_228:not(#\9),
|
|
229
|
+
.awsui_custom_tc96w_1qp7a_229:not(#\9) {
|
|
231
230
|
/* used in test-utils */
|
|
232
231
|
}
|
|
233
232
|
|
|
234
|
-
.awsui_second-column-
|
|
233
|
+
.awsui_second-column-small_tc96w_1qp7a_233:not(#\9) {
|
|
235
234
|
padding-top: calc(2 * var(--space-scaled-l-t03y3z, 20px));
|
|
236
235
|
}
|
|
237
236
|
|
|
238
|
-
.awsui_wrap-
|
|
239
|
-
.awsui_page-
|
|
240
|
-
.awsui_page-size-form-
|
|
241
|
-
.awsui_page-size-radio-
|
|
237
|
+
.awsui_wrap-lines_tc96w_1qp7a_237:not(#\9),
|
|
238
|
+
.awsui_page-size_tc96w_1qp7a_238:not(#\9),
|
|
239
|
+
.awsui_page-size-form-field_tc96w_1qp7a_239:not(#\9),
|
|
240
|
+
.awsui_page-size-radio-group_tc96w_1qp7a_240:not(#\9) {
|
|
242
241
|
/* used in test-utils */
|
|
243
242
|
}
|
|
@@ -2,24 +2,24 @@
|
|
|
2
2
|
// es-module interop with Babel and Typescript
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
module.exports.default = {
|
|
5
|
-
"visible-content": "awsui_visible-
|
|
6
|
-
"visible-content-toggle": "awsui_visible-content-
|
|
7
|
-
"visible-content-groups": "awsui_visible-content-
|
|
8
|
-
"visible-content-group": "awsui_visible-content-
|
|
9
|
-
"visible-content-title": "awsui_visible-content-
|
|
10
|
-
"visible-content-group-label": "awsui_visible-content-group-
|
|
11
|
-
"visible-content-option": "awsui_visible-content-
|
|
12
|
-
"visible-content-option-label": "awsui_visible-content-option-
|
|
13
|
-
"root": "
|
|
14
|
-
"modal-root": "awsui_modal-
|
|
15
|
-
"trigger-button": "awsui_trigger-
|
|
16
|
-
"cancel-button": "awsui_cancel-
|
|
17
|
-
"confirm-button": "awsui_confirm-
|
|
18
|
-
"custom": "
|
|
19
|
-
"second-column-small": "awsui_second-column-
|
|
20
|
-
"wrap-lines": "awsui_wrap-
|
|
21
|
-
"page-size": "awsui_page-
|
|
22
|
-
"page-size-form-field": "awsui_page-size-form-
|
|
23
|
-
"page-size-radio-group": "awsui_page-size-radio-
|
|
5
|
+
"visible-content": "awsui_visible-content_tc96w_1qp7a_185",
|
|
6
|
+
"visible-content-toggle": "awsui_visible-content-toggle_tc96w_1qp7a_186",
|
|
7
|
+
"visible-content-groups": "awsui_visible-content-groups_tc96w_1qp7a_187",
|
|
8
|
+
"visible-content-group": "awsui_visible-content-group_tc96w_1qp7a_187",
|
|
9
|
+
"visible-content-title": "awsui_visible-content-title_tc96w_1qp7a_192",
|
|
10
|
+
"visible-content-group-label": "awsui_visible-content-group-label_tc96w_1qp7a_200",
|
|
11
|
+
"visible-content-option": "awsui_visible-content-option_tc96w_1qp7a_206",
|
|
12
|
+
"visible-content-option-label": "awsui_visible-content-option-label_tc96w_1qp7a_217",
|
|
13
|
+
"root": "awsui_root_tc96w_1qp7a_224",
|
|
14
|
+
"modal-root": "awsui_modal-root_tc96w_1qp7a_225",
|
|
15
|
+
"trigger-button": "awsui_trigger-button_tc96w_1qp7a_226",
|
|
16
|
+
"cancel-button": "awsui_cancel-button_tc96w_1qp7a_227",
|
|
17
|
+
"confirm-button": "awsui_confirm-button_tc96w_1qp7a_228",
|
|
18
|
+
"custom": "awsui_custom_tc96w_1qp7a_229",
|
|
19
|
+
"second-column-small": "awsui_second-column-small_tc96w_1qp7a_233",
|
|
20
|
+
"wrap-lines": "awsui_wrap-lines_tc96w_1qp7a_237",
|
|
21
|
+
"page-size": "awsui_page-size_tc96w_1qp7a_238",
|
|
22
|
+
"page-size-form-field": "awsui_page-size-form-field_tc96w_1qp7a_239",
|
|
23
|
+
"page-size-radio-group": "awsui_page-size-radio-group_tc96w_1qp7a_240"
|
|
24
24
|
};
|
|
25
25
|
|
|
@@ -1,6 +1,6 @@
|
|
|
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<
|
|
4
|
+
declare const DateInput: React.ForwardRefExoticComponent<DateInputProps & React.RefAttributes<HTMLInputElement>>;
|
|
5
5
|
export default DateInput;
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/date-input/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAc,MAAM,OAAO,CAAC;AAEnC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAK9C,OAAO,EAAE,cAAc,EAAE,CAAC;AAE1B,QAAA,MAAM,SAAS,yFAYd,CAAC;AAIF,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { __assign, __rest } from "tslib";
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { applyDisplayName } from '../internal/utils/apply-display-name';
|
|
6
|
+
import useBaseComponent from '../internal/hooks/use-base-component';
|
|
7
|
+
import InternalDateInput from './internal';
|
|
8
|
+
var DateInput = React.forwardRef(function (_a, ref) {
|
|
9
|
+
var _b = _a.disableBrowserAutocorrect, disableBrowserAutocorrect = _b === void 0 ? true : _b, props = __rest(_a, ["disableBrowserAutocorrect"]);
|
|
10
|
+
var baseComponentProps = useBaseComponent('DateInput');
|
|
11
|
+
return (React.createElement(InternalDateInput, __assign({}, props, baseComponentProps, { disableBrowserAutocorrect: disableBrowserAutocorrect, ref: ref })));
|
|
12
|
+
});
|
|
13
|
+
applyDisplayName(DateInput, 'DateInput');
|
|
14
|
+
export default DateInput;
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/date-input/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;;AAEtC,OAAO,KAAc,MAAM,OAAO,CAAC;AAGnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,gBAAgB,MAAM,sCAAsC,CAAC;AACpE,OAAO,iBAAiB,MAAM,YAAY,CAAC;AAI3C,IAAM,SAAS,GAAG,KAAK,CAAC,UAAU,CAChC,UAAC,EAA8D,EAAE,GAA0B;IAAxF,IAAA,iCAAgC,EAAhC,yBAAyB,mBAAG,IAAI,KAAA,EAAK,KAAK,cAA5C,6BAA8C,CAAF;IAC3C,IAAM,kBAAkB,GAAG,gBAAgB,CAAC,WAAW,CAAC,CAAC;IACzD,OAAO,CACL,oBAAC,iBAAiB,eACZ,KAAK,EACL,kBAAkB,IACtB,yBAAyB,EAAE,yBAAyB,EACpD,GAAG,EAAE,GAAG,IACR,CACH,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,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\nimport React, { Ref } from 'react';\n\nimport { DateInputProps } from './interfaces';\nimport { applyDisplayName } from '../internal/utils/apply-display-name';\nimport useBaseComponent from '../internal/hooks/use-base-component';\nimport InternalDateInput from './internal';\n\nexport { DateInputProps };\n\nconst DateInput = React.forwardRef(\n ({ disableBrowserAutocorrect = true, ...props }: DateInputProps, ref: Ref<HTMLInputElement>) => {\n const baseComponentProps = useBaseComponent('DateInput');\n return (\n <InternalDateInput\n {...props}\n {...baseComponentProps}\n disableBrowserAutocorrect={disableBrowserAutocorrect}\n ref={ref}\n />\n );\n }\n);\n\napplyDisplayName(DateInput, 'DateInput');\n\nexport default DateInput;\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BaseInputProps, InputProps } from '../input/interfaces';
|
|
2
|
+
import { BaseComponentProps } from '../internal/base-component';
|
|
3
|
+
import { FormFieldValidationControlProps } from '../internal/context/form-field-context';
|
|
4
|
+
export interface DateInputProps extends BaseInputProps, FormFieldValidationControlProps, BaseComponentProps {
|
|
5
|
+
}
|
|
6
|
+
export declare namespace DateInputProps {
|
|
7
|
+
type Ref = InputProps.Ref;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=interfaces.d.ts.map
|
|
@@ -0,0 +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;CAAG;AAE9G,yBAAiB,cAAc,CAAC;IAC9B,KAAY,GAAG,GAAG,UAAU,CAAC,GAAG,CAAC;CAClC"}
|
|
@@ -0,0 +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\nexport namespace DateInputProps {\n export type Ref = InputProps.Ref;\n}\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { DateInputProps } from './interfaces';
|
|
3
|
+
import { InternalBaseComponentProps } from '../internal/hooks/use-base-component';
|
|
4
|
+
declare const InternalDateInput: React.ForwardRefExoticComponent<DateInputProps & InternalBaseComponentProps & React.RefAttributes<HTMLInputElement>>;
|
|
5
|
+
export default InternalDateInput;
|
|
6
|
+
//# sourceMappingURL=internal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/date-input/internal.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAc,MAAM,OAAO,CAAC;AAQnC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAoBlF,QAAA,MAAM,iBAAiB,sHAqBtB,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { __assign, __rest } from "tslib";
|
|
4
|
+
import clsx from 'clsx';
|
|
5
|
+
import { getDaysInMonth } from 'date-fns';
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import { fireNonCancelableEvent } from '../internal/events';
|
|
8
|
+
import { displayToIso, isoToDisplay, parseDate } from '../internal/utils/date-time';
|
|
9
|
+
import MaskedInput from '../internal/components/masked-input';
|
|
10
|
+
import styles from './styles.css.js';
|
|
11
|
+
function daysMax(value) {
|
|
12
|
+
// force to first day in month, as new Date('2018-02-30') -> March 2nd 2018
|
|
13
|
+
var baseDate = displayToIso(value).substring(0, 7);
|
|
14
|
+
return getDaysInMonth(parseDate(baseDate));
|
|
15
|
+
}
|
|
16
|
+
var maskArgs = {
|
|
17
|
+
separator: '/',
|
|
18
|
+
inputSeparators: ['-', '.', ' '],
|
|
19
|
+
segments: [
|
|
20
|
+
{ min: 0, max: 9999, "default": 2000, length: 4 },
|
|
21
|
+
{ min: 1, max: 12, length: 2 },
|
|
22
|
+
{ min: 1, max: daysMax, length: 2 },
|
|
23
|
+
]
|
|
24
|
+
};
|
|
25
|
+
var InternalDateInput = React.forwardRef(function (_a, ref) {
|
|
26
|
+
var value = _a.value, onChange = _a.onChange, _b = _a.disableBrowserAutocorrect, disableBrowserAutocorrect = _b === void 0 ? true : _b, _c = _a.__internalRootRef, __internalRootRef = _c === void 0 ? null : _c, props = __rest(_a, ["value", "onChange", "disableBrowserAutocorrect", "__internalRootRef"]);
|
|
27
|
+
return (React.createElement(MaskedInput, __assign({ ref: ref }, props, { value: isoToDisplay(value), onChange: function (event) { return fireNonCancelableEvent(onChange, { value: displayToIso(event.detail.value) }); }, className: clsx(styles.root, props.className), mask: maskArgs, autofix: true, autoComplete: false, disableAutocompleteOnBlur: false, disableBrowserAutocorrect: disableBrowserAutocorrect, __internalRootRef: __internalRootRef })));
|
|
28
|
+
});
|
|
29
|
+
export default InternalDateInput;
|
|
30
|
+
//# sourceMappingURL=internal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/date-input/internal.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;;AAEtC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,KAAc,MAAM,OAAO,CAAC;AACnC,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAEpF,OAAO,WAAW,MAAM,qCAAqC,CAAC;AAG9D,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAMrC,SAAS,OAAO,CAAC,KAAa;IAC5B,2EAA2E;IAC3E,IAAM,QAAQ,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACrD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B,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 clsx from 'clsx';\nimport { getDaysInMonth } from 'date-fns';\nimport React, { Ref } from 'react';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport { displayToIso, isoToDisplay, parseDate } from '../internal/utils/date-time';\n\nimport MaskedInput from '../internal/components/masked-input';\nimport { MaskArgs } from '../internal/components/masked-input/utils/mask-format';\n\nimport styles from './styles.css.js';\nimport { DateInputProps } from './interfaces';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\n\ntype InternalDateInputProps = DateInputProps & InternalBaseComponentProps;\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 maskArgs: MaskArgs = {\n separator: '/',\n inputSeparators: ['-', '.', ' '],\n segments: [\n { min: 0, max: 9999, default: 2000, length: 4 },\n { min: 1, max: 12, length: 2 },\n { min: 1, max: daysMax, length: 2 },\n ],\n};\n\nconst InternalDateInput = React.forwardRef(\n (\n { value, onChange, disableBrowserAutocorrect = true, __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={maskArgs}\n autofix={true}\n autoComplete={false}\n disableAutocompleteOnBlur={false}\n disableBrowserAutocorrect={disableBrowserAutocorrect}\n __internalRootRef={__internalRootRef}\n />\n );\n }\n);\n\nexport default InternalDateInput;\n"]}
|
|
@@ -1,23 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DayIndex } from '../index';
|
|
2
2
|
import { MoveFocusHandler } from '../utils/move-focus-handler';
|
|
3
|
-
import { CalendarTypes } from '../definitions';
|
|
4
3
|
import { DatePickerProps } from '../../interfaces';
|
|
5
4
|
export interface GridProps {
|
|
6
5
|
locale: string;
|
|
7
6
|
baseDate: Date;
|
|
8
7
|
isDateEnabled: DatePickerProps.IsDateEnabledFunction;
|
|
9
8
|
focusedDate: Date | null;
|
|
10
|
-
onSelectDate:
|
|
11
|
-
onFocusDate:
|
|
12
|
-
onChangeMonth:
|
|
9
|
+
onSelectDate: (date: Date) => void;
|
|
10
|
+
onFocusDate: (date: null | Date) => void;
|
|
11
|
+
onChangeMonth: (date: Date) => void;
|
|
13
12
|
startOfWeek: DayIndex;
|
|
14
13
|
todayAriaLabel: string;
|
|
15
14
|
selectedDate: Date | null;
|
|
16
15
|
handleFocusMove: MoveFocusHandler;
|
|
17
16
|
}
|
|
18
|
-
export interface DateChangeHandlerNullable {
|
|
19
|
-
(detail: CalendarTypes.DateDetailNullable): void;
|
|
20
|
-
}
|
|
21
17
|
declare const Grid: ({ locale, baseDate, isDateEnabled, focusedDate, onSelectDate, onFocusDate, onChangeMonth, startOfWeek, todayAriaLabel, selectedDate, handleFocusMove, }: GridProps) => JSX.Element;
|
|
22
18
|
export default Grid;
|
|
23
19
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/date-picker/calendar/grid/index.tsx"],"names":[],"mappings":"AAQA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/date-picker/calendar/grid/index.tsx"],"names":[],"mappings":"AAQA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAInD,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,IAAI,CAAC;IACf,aAAa,EAAE,eAAe,CAAC,qBAAqB,CAAC;IACrD,WAAW,EAAE,IAAI,GAAG,IAAI,CAAC;IACzB,YAAY,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IACnC,WAAW,EAAE,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,KAAK,IAAI,CAAC;IACzC,aAAa,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IACpC,WAAW,EAAE,QAAQ,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,IAAI,GAAG,IAAI,CAAC;IAC1B,eAAe,EAAE,gBAAgB,CAAC;CACnC;AAED,QAAA,MAAM,IAAI,4JAYP,SAAS,gBAoFX,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -19,8 +19,8 @@ var Grid = function (_a) {
|
|
|
19
19
|
case KeyCode.enter:
|
|
20
20
|
event.preventDefault();
|
|
21
21
|
if (focusedDate) {
|
|
22
|
-
onFocusDate(
|
|
23
|
-
onSelectDate(
|
|
22
|
+
onFocusDate(null);
|
|
23
|
+
onSelectDate(focusedDate);
|
|
24
24
|
}
|
|
25
25
|
return;
|
|
26
26
|
case KeyCode.right:
|
|
@@ -45,7 +45,7 @@ var Grid = function (_a) {
|
|
|
45
45
|
if (!isSameMonth(updatedFocusDate, baseDate)) {
|
|
46
46
|
onChangeMonth(updatedFocusDate);
|
|
47
47
|
}
|
|
48
|
-
onFocusDate(
|
|
48
|
+
onFocusDate(updatedFocusDate);
|
|
49
49
|
};
|
|
50
50
|
var weeks = useMemo(function () { return getCalendarMonth(baseDate, { firstDayOfWeek: startOfWeek }); }, [baseDate, startOfWeek]);
|
|
51
51
|
return (React.createElement("div", null,
|
|
@@ -53,9 +53,7 @@ var Grid = function (_a) {
|
|
|
53
53
|
React.createElement("div", { className: styles['calendar-dates'], onKeyDown: onGridKeyDownHandler }, weeks.map(function (week, weekIndex) {
|
|
54
54
|
var isDateInLastWeek = weeks.length - 1 === weekIndex;
|
|
55
55
|
return (React.createElement("div", { key: "week-".concat(weekIndex), className: styles['calendar-week'] }, week.map(function (date, dateIndex) {
|
|
56
|
-
return (React.createElement(GridDay, { key: "date-".concat(weekIndex, "-").concat(dateIndex), locale: locale, baseDate: baseDate, selectedDate: selectedDate, date: date, focusedDate: focusedDate, todayAriaLabel: todayAriaLabel, onSelectDate: function (date) {
|
|
57
|
-
onSelectDate({ date: date });
|
|
58
|
-
}, isDateEnabled: isDateEnabled, isDateInLastWeek: isDateInLastWeek }));
|
|
56
|
+
return (React.createElement(GridDay, { key: "date-".concat(weekIndex, "-").concat(dateIndex), locale: locale, baseDate: baseDate, selectedDate: selectedDate, date: date, focusedDate: focusedDate, todayAriaLabel: todayAriaLabel, onSelectDate: function (date) { return onSelectDate(date); }, isDateEnabled: isDateEnabled, isDateInLastWeek: isDateInLastWeek }));
|
|
59
57
|
})));
|
|
60
58
|
}))));
|
|
61
59
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/date-picker/calendar/grid/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,MAAM,MAAM,qBAAqB,CAAC;AACzC,OAAO,OAAO,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/date-picker/calendar/grid/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO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AmB,CAAC,IAC9D,aAAa,CAAC,MAAM,EAAE,CAAC,CAAC,CACrB,CACP,EAJuC,CAIvC,CAAC,CACE;QACN,6BAAK,SAAS,EAAE,MAAM,CAAC,gBAAgB,CAAC,EAAE,SAAS,EAAE,oBAAoB,IACtE,KAAK,CAAC,GAAG,CAAC,UAAC,IAAI,EAAE,SAAS;YACzB,IAAM,gBAAgB,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,KAAK,SAAS,CAAC;YAExD,OAAO,CACL,6BAAK,GAAG,EAAE,eAAQ,SAAS,CAAE,EAAE,SAAS,EAAE,MAAM,CAAC,eAAe,CAAC,IAC9D,IAAI,CAAC,GAAG,CAAC,UAAC,IAAI,EAAE,SAAS;gBACxB,OAAO,CACL,oBAAC,OAAO,IACN,GAAG,EAAE,eAAQ,SAAS,cAAI,SAAS,CAAE,EACrC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,QAAQ,EAClB,YAAY,EAAE,YAAY,EAC1B,IAAI,EAAE,IAAI,EACV,WAAW,EAAE,WAAW,EACxB,cAAc,EAAE,cAAc,EAC9B,YAAY,EAAE,UAAA,IAAI,IAAI,OAAA,YAAY,CAAC,IAAI,CAAC,EAAlB,CAAkB,EACxC,aAAa,EAAE,aAAa,EAC5B,gBAAgB,EAAE,gBAAgB,GAClC,CACH,CAAC;YACJ,CAAC,CAAC,CACE,CACP,CAAC;QACJ,CAAC,CAAC,CACE,CACF,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,IAAI,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useMemo } from 'react';\nimport styles from '../../styles.css.js';\nimport GridDay from './day';\nimport { KeyCode } from '../../../internal/keycode';\nimport { addDays, addWeeks, isSameMonth } from 'date-fns';\nimport { getCalendarMonth } from 'mnth';\nimport { DayIndex } from '../index';\nimport { MoveFocusHandler } from '../utils/move-focus-handler';\nimport { DatePickerProps } from '../../interfaces';\nimport rotateDayIndexes from '../utils/rotate-day-indexes';\nimport { renderDayName } from '../utils/intl';\n\nexport interface GridProps {\n locale: string;\n baseDate: Date;\n isDateEnabled: DatePickerProps.IsDateEnabledFunction;\n focusedDate: Date | null;\n onSelectDate: (date: Date) => void;\n onFocusDate: (date: null | Date) => void;\n onChangeMonth: (date: Date) => void;\n startOfWeek: DayIndex;\n todayAriaLabel: string;\n selectedDate: Date | null;\n handleFocusMove: MoveFocusHandler;\n}\n\nconst Grid = ({\n locale,\n baseDate,\n isDateEnabled,\n focusedDate,\n onSelectDate,\n onFocusDate,\n onChangeMonth,\n startOfWeek,\n todayAriaLabel,\n selectedDate,\n handleFocusMove,\n}: GridProps) => {\n const onGridKeyDownHandler = (event: React.KeyboardEvent) => {\n let updatedFocusDate;\n\n if (focusedDate === null) {\n return;\n }\n\n switch (event.keyCode) {\n case KeyCode.enter:\n event.preventDefault();\n if (focusedDate) {\n onFocusDate(null);\n onSelectDate(focusedDate);\n }\n return;\n case KeyCode.right:\n event.preventDefault();\n updatedFocusDate = handleFocusMove(focusedDate, isDateEnabled, date => addDays(date, 1));\n break;\n case KeyCode.left:\n event.preventDefault();\n updatedFocusDate = handleFocusMove(focusedDate, isDateEnabled, date => addDays(date, -1));\n break;\n case KeyCode.up:\n event.preventDefault();\n updatedFocusDate = handleFocusMove(focusedDate, isDateEnabled, date => addWeeks(date, -1));\n break;\n case KeyCode.down:\n event.preventDefault();\n updatedFocusDate = handleFocusMove(focusedDate, isDateEnabled, date => addWeeks(date, 1));\n break;\n default:\n return;\n }\n\n if (!isSameMonth(updatedFocusDate, baseDate)) {\n onChangeMonth(updatedFocusDate);\n }\n onFocusDate(updatedFocusDate);\n };\n\n const weeks = useMemo<Date[][]>(\n () => getCalendarMonth(baseDate, { firstDayOfWeek: startOfWeek }),\n [baseDate, startOfWeek]\n );\n\n return (\n <div>\n <div className={styles['calendar-day-names']}>\n {rotateDayIndexes(startOfWeek).map(i => (\n <div key={`day-name-${i}`} className={styles['calendar-day-name']}>\n {renderDayName(locale, i)}\n </div>\n ))}\n </div>\n <div className={styles['calendar-dates']} onKeyDown={onGridKeyDownHandler}>\n {weeks.map((week, weekIndex) => {\n const isDateInLastWeek = weeks.length - 1 === weekIndex;\n\n return (\n <div key={`week-${weekIndex}`} className={styles['calendar-week']}>\n {week.map((date, dateIndex) => {\n return (\n <GridDay\n key={`date-${weekIndex}-${dateIndex}`}\n locale={locale}\n baseDate={baseDate}\n selectedDate={selectedDate}\n date={date}\n focusedDate={focusedDate}\n todayAriaLabel={todayAriaLabel}\n onSelectDate={date => onSelectDate(date)}\n isDateEnabled={isDateEnabled}\n isDateInLastWeek={isDateInLastWeek}\n />\n );\n })}\n </div>\n );\n })}\n </div>\n </div>\n );\n};\n\nexport default Grid;\n"]}
|
|
@@ -1,25 +1,17 @@
|
|
|
1
1
|
import { BaseComponentProps } from '../../internal/base-component';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
export interface DateChangeHandler {
|
|
5
|
-
(detail: CalendarTypes.DateDetail): void;
|
|
6
|
-
}
|
|
7
|
-
export interface MonthChangeHandler {
|
|
8
|
-
(newMonth: Date): void;
|
|
9
|
-
}
|
|
2
|
+
import { NonCancelableEventHandler } from '../../internal/events/index.js';
|
|
3
|
+
import { DatePickerProps } from '../interfaces.js';
|
|
10
4
|
export declare type DayIndex = 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
11
5
|
interface CalendarProps extends BaseComponentProps {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
isDateEnabled:
|
|
17
|
-
nextMonthLabel: string;
|
|
18
|
-
previousMonthLabel: string;
|
|
6
|
+
value: string;
|
|
7
|
+
onChange?: NonCancelableEventHandler<DatePickerProps.ChangeDetail>;
|
|
8
|
+
locale?: string;
|
|
9
|
+
startOfWeek?: number;
|
|
10
|
+
isDateEnabled?: (date: Date) => boolean;
|
|
19
11
|
todayAriaLabel: string;
|
|
20
|
-
|
|
21
|
-
|
|
12
|
+
nextMonthAriaLabel: string;
|
|
13
|
+
previousMonthAriaLabel: string;
|
|
22
14
|
}
|
|
23
|
-
|
|
24
|
-
export
|
|
15
|
+
export default function Calendar({ value, locale, startOfWeek, isDateEnabled, todayAriaLabel, nextMonthAriaLabel, previousMonthAriaLabel, onChange, }: CalendarProps): JSX.Element;
|
|
16
|
+
export {};
|
|
25
17
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/date-picker/calendar/index.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/date-picker/calendar/index.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAUnE,OAAO,EAA0B,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AACnG,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAGnD,oBAAY,QAAQ,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAEjD,UAAU,aAAc,SAAQ,kBAAkB;IAChD,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,yBAAyB,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;IACnE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC;IACxC,cAAc,EAAE,MAAM,CAAC;IACvB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,sBAAsB,EAAE,MAAM,CAAC;CAChC;AAED,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,EAC/B,KAAK,EACL,MAAW,EACX,WAAW,EACX,aAA0B,EAC1B,cAAc,EACd,kBAAkB,EAClB,sBAAsB,EACtB,QAAQ,GACT,EAAE,aAAa,eA4Hf"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __assign } from "tslib";
|
|
2
2
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
import React, { useRef, useState } from 'react';
|
|
4
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
5
5
|
import { addDays, addMonths, getDaysInMonth, isSameMonth, startOfMonth } from 'date-fns';
|
|
6
6
|
import styles from '../styles.css.js';
|
|
7
7
|
import useFocusVisible from '../../internal/hooks/focus-visible/index.js';
|
|
@@ -11,16 +11,28 @@ import moveFocusHandler from './utils/move-focus-handler';
|
|
|
11
11
|
import { useUniqueId } from '../../internal/hooks/use-unique-id/index.js';
|
|
12
12
|
import { memoizedDate } from './utils/memoized-date.js';
|
|
13
13
|
import { useEffectOnUpdate } from '../../internal/hooks/use-effect-on-update.js';
|
|
14
|
-
import { normalizeStartOfWeek } from './utils/locales.js';
|
|
14
|
+
import { normalizeLocale, normalizeStartOfWeek } from './utils/locales.js';
|
|
15
15
|
import { formatDate } from '../../internal/utils/date-time';
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
import { fireNonCancelableEvent } from '../../internal/events/index.js';
|
|
17
|
+
import checkControlled from '../../internal/hooks/check-controlled/index.js';
|
|
18
|
+
export default function Calendar(_a) {
|
|
19
|
+
var value = _a.value, _b = _a.locale, locale = _b === void 0 ? '' : _b, startOfWeek = _a.startOfWeek, _c = _a.isDateEnabled, isDateEnabled = _c === void 0 ? function () { return true; } : _c, todayAriaLabel = _a.todayAriaLabel, nextMonthAriaLabel = _a.nextMonthAriaLabel, previousMonthAriaLabel = _a.previousMonthAriaLabel, onChange = _a.onChange;
|
|
20
|
+
checkControlled('Calendar', 'value', value, 'onChange', onChange);
|
|
21
|
+
var normalizedLocale = normalizeLocale('Calendar', locale);
|
|
18
22
|
var normalizedStartOfWeek = normalizeStartOfWeek(startOfWeek, locale);
|
|
19
23
|
var focusVisible = useFocusVisible();
|
|
20
24
|
var headerId = useUniqueId('calendar-dialog-title-');
|
|
21
25
|
var elementRef = useRef(null);
|
|
22
26
|
var gridWrapperRef = useRef(null);
|
|
23
|
-
var
|
|
27
|
+
var _d = useState(null), focusedDate = _d[0], setFocusedDate = _d[1];
|
|
28
|
+
// Set displayed date to value if defined or to current date otherwise.
|
|
29
|
+
var memoizedValue = memoizedDate('value', value);
|
|
30
|
+
var defaultDisplayedDate = memoizedValue !== null && memoizedValue !== void 0 ? memoizedValue : new Date();
|
|
31
|
+
var _e = useState(defaultDisplayedDate), displayedDate = _e[0], setDisplayedDate = _e[1];
|
|
32
|
+
// Update displayed date if value changes.
|
|
33
|
+
useEffect(function () {
|
|
34
|
+
memoizedValue && setDisplayedDate(function (prev) { return (prev.getTime() !== memoizedValue.getTime() ? memoizedValue : prev); });
|
|
35
|
+
}, [memoizedValue]);
|
|
24
36
|
var selectFocusedDate = function (selected, baseDate) {
|
|
25
37
|
if (selected && isDateEnabled(selected) && isSameMonth(selected, baseDate)) {
|
|
26
38
|
return selected;
|
|
@@ -47,24 +59,23 @@ var Calendar = function (_a) {
|
|
|
47
59
|
return startDate;
|
|
48
60
|
};
|
|
49
61
|
var baseDate = getBaseDate(displayedDate);
|
|
50
|
-
var focusedOrSelectedDate = focusedDate || selectFocusedDate(
|
|
51
|
-
var onHeaderChangeMonthHandler = function (
|
|
52
|
-
|
|
62
|
+
var focusedOrSelectedDate = focusedDate || selectFocusedDate(memoizedValue, baseDate);
|
|
63
|
+
var onHeaderChangeMonthHandler = function (isPreviousButtonClick) {
|
|
64
|
+
setDisplayedDate(addMonths(baseDate, isPreviousButtonClick ? -1 : 1));
|
|
53
65
|
setFocusedDate(null);
|
|
54
66
|
};
|
|
55
67
|
var onGridChangeMonthHandler = function (newMonth) {
|
|
56
|
-
|
|
68
|
+
setDisplayedDate(newMonth);
|
|
57
69
|
setFocusedDate(null);
|
|
58
70
|
};
|
|
59
|
-
var onGridFocusDateHandler = function (
|
|
60
|
-
var date = _a.date;
|
|
71
|
+
var onGridFocusDateHandler = function (date) {
|
|
61
72
|
if (date) {
|
|
62
|
-
var
|
|
63
|
-
setFocusedDate(
|
|
73
|
+
var value_1 = memoizedDate('focused', formatDate(date));
|
|
74
|
+
setFocusedDate(value_1);
|
|
64
75
|
}
|
|
65
76
|
};
|
|
66
|
-
var onGridSelectDateHandler = function (
|
|
67
|
-
|
|
77
|
+
var onGridSelectDateHandler = function (date) {
|
|
78
|
+
fireNonCancelableEvent(onChange, { value: formatDate(date) });
|
|
68
79
|
setFocusedDate(null);
|
|
69
80
|
};
|
|
70
81
|
// The focused date changes as a feedback to keyboard navigation in the grid.
|
|
@@ -84,9 +95,8 @@ var Calendar = function (_a) {
|
|
|
84
95
|
};
|
|
85
96
|
return (React.createElement("div", __assign({}, focusVisible, { className: styles.calendar, tabIndex: 0, role: "application", "aria-describedby": headerId, ref: elementRef }),
|
|
86
97
|
React.createElement("div", { className: styles['calendar-inner'] },
|
|
87
|
-
React.createElement(CalendarHeader, { headerId: headerId, baseDate: baseDate, locale:
|
|
98
|
+
React.createElement(CalendarHeader, { headerId: headerId, baseDate: baseDate, locale: normalizedLocale, onChangeMonth: onHeaderChangeMonthHandler, previousMonthLabel: previousMonthAriaLabel, nextMonthLabel: nextMonthAriaLabel }),
|
|
88
99
|
React.createElement("div", { onBlur: onGridBlur, ref: gridWrapperRef },
|
|
89
|
-
React.createElement(Grid, { locale:
|
|
90
|
-
}
|
|
91
|
-
export default Calendar;
|
|
100
|
+
React.createElement(Grid, { locale: normalizedLocale, baseDate: baseDate, isDateEnabled: isDateEnabled, focusedDate: focusedOrSelectedDate, onSelectDate: onGridSelectDateHandler, onFocusDate: onGridFocusDateHandler, onChangeMonth: onGridChangeMonthHandler, startOfWeek: normalizedStartOfWeek, todayAriaLabel: todayAriaLabel, selectedDate: memoizedValue, handleFocusMove: moveFocusHandler })))));
|
|
101
|
+
}
|
|
92
102
|
//# sourceMappingURL=index.js.map
|