@cloudscape-design/components 3.0.2 → 3.0.5

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 (58) hide show
  1. package/alert/interfaces.d.ts +1 -0
  2. package/alert/interfaces.d.ts.map +1 -1
  3. package/alert/interfaces.js.map +1 -1
  4. package/app-layout/index.d.ts.map +1 -1
  5. package/app-layout/index.js +14 -11
  6. package/app-layout/index.js.map +1 -1
  7. package/app-layout/visual-refresh/context.d.ts +4 -2
  8. package/app-layout/visual-refresh/context.d.ts.map +1 -1
  9. package/app-layout/visual-refresh/context.js +31 -21
  10. package/app-layout/visual-refresh/context.js.map +1 -1
  11. package/app-layout/visual-refresh/layout.d.ts.map +1 -1
  12. package/app-layout/visual-refresh/layout.js +2 -13
  13. package/app-layout/visual-refresh/layout.js.map +1 -1
  14. package/app-layout/visual-refresh/split-panel.d.ts.map +1 -1
  15. package/app-layout/visual-refresh/split-panel.js +6 -2
  16. package/app-layout/visual-refresh/split-panel.js.map +1 -1
  17. package/code-editor/preferences-modal.js +2 -2
  18. package/code-editor/preferences-modal.js.map +1 -1
  19. package/container/styles.css.js +15 -14
  20. package/container/styles.scoped.css +28 -24
  21. package/container/styles.selectors.js +15 -14
  22. package/flashbar/interfaces.d.ts +4 -4
  23. package/flashbar/interfaces.js.map +1 -1
  24. package/form-field/internal.js +3 -3
  25. package/form-field/internal.js.map +1 -1
  26. package/internal/base-component/styles.scoped.css +3 -0
  27. package/internal/context/app-layout-context.d.ts +1 -1
  28. package/internal/context/app-layout-context.d.ts.map +1 -1
  29. package/internal/context/app-layout-context.js +3 -4
  30. package/internal/context/app-layout-context.js.map +1 -1
  31. package/internal/context/form-field-context.d.ts +1 -1
  32. package/internal/context/form-field-context.d.ts.map +1 -1
  33. package/internal/context/form-field-context.js +3 -4
  34. package/internal/context/form-field-context.js.map +1 -1
  35. package/internal/environment.js +1 -1
  36. package/internal/generated/theming/index.cjs +14 -3
  37. package/internal/generated/theming/index.js +14 -3
  38. package/package.json +1 -1
  39. package/select/utils/use-select.d.ts.map +1 -1
  40. package/select/utils/use-select.js +1 -0
  41. package/select/utils/use-select.js.map +1 -1
  42. package/split-panel/index.js +2 -2
  43. package/split-panel/index.js.map +1 -1
  44. package/split-panel/utils/size-utils.d.ts +11 -0
  45. package/split-panel/utils/size-utils.d.ts.map +1 -1
  46. package/split-panel/utils/size-utils.js +12 -1
  47. package/split-panel/utils/size-utils.js.map +1 -1
  48. package/tag-editor/index.js +1 -1
  49. package/tag-editor/index.js.map +1 -1
  50. package/tag-editor/interfaces.d.ts +1 -1
  51. package/tag-editor/interfaces.d.ts.map +1 -1
  52. package/tag-editor/interfaces.js.map +1 -1
  53. package/tutorial-panel/components/tutorial-list/index.js +1 -1
  54. package/tutorial-panel/components/tutorial-list/index.js.map +1 -1
  55. package/internal/hooks/dom-context/index.d.ts +0 -14
  56. package/internal/hooks/dom-context/index.d.ts.map +0 -1
  57. package/internal/hooks/dom-context/index.js +0 -70
  58. package/internal/hooks/dom-context/index.js.map +0 -1
@@ -2,19 +2,20 @@
2
2
  // es-module interop with Babel and Typescript
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  module.exports.default = {
5
- "root": "awsui_root_14iqq_1tfbz_97",
6
- "variant-default": "awsui_variant-default_14iqq_1tfbz_109",
7
- "variant-stacked": "awsui_variant-stacked_14iqq_1tfbz_109",
8
- "header": "awsui_header_14iqq_1tfbz_132",
9
- "header-sticky-disabled": "awsui_header-sticky-disabled_14iqq_1tfbz_136",
10
- "header-sticky-enabled": "awsui_header-sticky-enabled_14iqq_1tfbz_140",
11
- "header-stuck": "awsui_header-stuck_14iqq_1tfbz_146",
12
- "header-dynamic-height": "awsui_header-dynamic-height_14iqq_1tfbz_151",
13
- "with-paddings": "awsui_with-paddings_14iqq_1tfbz_157",
14
- "header-variant-cards": "awsui_header-variant-cards_14iqq_1tfbz_160",
15
- "dark-header": "awsui_dark-header_14iqq_1tfbz_189",
16
- "content": "awsui_content_14iqq_1tfbz_193",
17
- "footer": "awsui_footer_14iqq_1tfbz_200",
18
- "with-divider": "awsui_with-divider_14iqq_1tfbz_203"
5
+ "root": "awsui_root_14iqq_1cpw0_97",
6
+ "variant-default": "awsui_variant-default_14iqq_1cpw0_109",
7
+ "variant-stacked": "awsui_variant-stacked_14iqq_1cpw0_109",
8
+ "header": "awsui_header_14iqq_1cpw0_132",
9
+ "header-sticky-disabled": "awsui_header-sticky-disabled_14iqq_1cpw0_136",
10
+ "header-sticky-enabled": "awsui_header-sticky-enabled_14iqq_1cpw0_140",
11
+ "header-stuck": "awsui_header-stuck_14iqq_1cpw0_146",
12
+ "header-dynamic-height": "awsui_header-dynamic-height_14iqq_1cpw0_151",
13
+ "with-paddings": "awsui_with-paddings_14iqq_1cpw0_157",
14
+ "header-variant-cards": "awsui_header-variant-cards_14iqq_1cpw0_160",
15
+ "header-variant-full-page": "awsui_header-variant-full-page_14iqq_1cpw0_184",
16
+ "dark-header": "awsui_dark-header_14iqq_1cpw0_192",
17
+ "content": "awsui_content_14iqq_1cpw0_196",
18
+ "footer": "awsui_footer_14iqq_1cpw0_203",
19
+ "with-divider": "awsui_with-divider_14iqq_1cpw0_206"
19
20
  };
20
21
 
@@ -35,12 +35,12 @@ export interface FlashbarProps extends BaseComponentProps {
35
35
  * * `buttonText` (string) - Specifies that an action button should be displayed, with the specified text.
36
36
  * When a user clicks on this button the `onButtonClick` handler is called. If the `action` property is set, this property is ignored.
37
37
  * **Deprecated**, replaced by `action`.
38
- * *`id` (string) - Specifies a unique flash message identifier. This property is used in two ways:
39
- * 1. As a [keys](https://reactjs.org/docs/lists-and-keys.html#keys) source for React rendering.
40
- * 2. To identify which flash message will be removed from the DOM when it is dismissed, to animate it out.
41
- * @visualrefresh `id` property
42
38
  * * `onButtonClick` (event => void) - Called when a user clicks on the action button. This is not called if you create a custom button
43
39
  * using the `action` property. **Deprecated**, replaced by `action`.
40
+ * * `id` (string) - Specifies a unique flash message identifier. This property is used in two ways:
41
+ * 1. As a [keys](https://reactjs.org/docs/lists-and-keys.html#keys) source for React rendering.
42
+ * 2. To identify which flash message will be removed from the DOM when it is dismissed, to animate it out.
43
+ * @visualrefresh `id` property
44
44
  */
45
45
  items: ReadonlyArray<FlashbarProps.MessageDefinition>;
46
46
  }
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/flashbar/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { BaseComponentProps } from '../internal/base-component';\nimport React from 'react';\nimport { ButtonProps } from '../button/interfaces';\n\nexport namespace FlashbarProps {\n export interface MessageDefinition {\n header?: React.ReactNode;\n content?: React.ReactNode;\n dismissible?: boolean;\n dismissLabel?: string;\n loading?: boolean;\n type?: FlashbarProps.Type;\n action?: React.ReactNode;\n id?: string;\n buttonText?: ButtonProps['children'];\n onButtonClick?: ButtonProps['onClick'];\n onDismiss?: ButtonProps['onClick'];\n }\n\n export type Type = 'success' | 'warning' | 'info' | 'error';\n}\n\nexport interface FlashbarProps extends BaseComponentProps {\n /**\n * Specifies flash messages that appear in the same order that they are listed.\n * The value is an array of flash message definition objects.\n *\n * A flash message object contains the following properties:\n * * `header` (ReactNode) - Specifies the heading text.\n * * `content` (ReactNode) - Specifies the primary text displayed in the flash element.\n * * `type` (string) - Indicates the type of the message to be displayed. Allowed values are as follows: `success, error, warning, info`. The default is `info`.\n * * `loading` (boolean) - Replaces the status icon with a spinner and forces the type to `info`.\n * * `dismissible` (boolean) - Determines whether the component includes a close button icon. By default, the close button is not included.\n * When a user clicks on this button the `onDismiss` handler is called.\n * * `dismissLabel` (string) - Specifies an `aria-label` for to the dismiss icon button for improved accessibility.\n * * `action` (ReactNode) - Specifies an action for the flash message. Although it is technically possible to insert any content,\n * our UX guidelines only allow you to add a button.\n * * `buttonText` (string) - Specifies that an action button should be displayed, with the specified text.\n * When a user clicks on this button the `onButtonClick` handler is called. If the `action` property is set, this property is ignored.\n * **Deprecated**, replaced by `action`.\n * *`id` (string) - Specifies a unique flash message identifier. This property is used in two ways:\n * 1. As a [keys](https://reactjs.org/docs/lists-and-keys.html#keys) source for React rendering.\n * 2. To identify which flash message will be removed from the DOM when it is dismissed, to animate it out.\n * @visualrefresh `id` property\n * * `onButtonClick` (event => void) - Called when a user clicks on the action button. This is not called if you create a custom button\n * using the `action` property. **Deprecated**, replaced by `action`.\n */\n items: ReadonlyArray<FlashbarProps.MessageDefinition>;\n}\n"]}
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/flashbar/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { BaseComponentProps } from '../internal/base-component';\nimport React from 'react';\nimport { ButtonProps } from '../button/interfaces';\n\nexport namespace FlashbarProps {\n export interface MessageDefinition {\n header?: React.ReactNode;\n content?: React.ReactNode;\n dismissible?: boolean;\n dismissLabel?: string;\n loading?: boolean;\n type?: FlashbarProps.Type;\n action?: React.ReactNode;\n id?: string;\n buttonText?: ButtonProps['children'];\n onButtonClick?: ButtonProps['onClick'];\n onDismiss?: ButtonProps['onClick'];\n }\n\n export type Type = 'success' | 'warning' | 'info' | 'error';\n}\n\nexport interface FlashbarProps extends BaseComponentProps {\n /**\n * Specifies flash messages that appear in the same order that they are listed.\n * The value is an array of flash message definition objects.\n *\n * A flash message object contains the following properties:\n * * `header` (ReactNode) - Specifies the heading text.\n * * `content` (ReactNode) - Specifies the primary text displayed in the flash element.\n * * `type` (string) - Indicates the type of the message to be displayed. Allowed values are as follows: `success, error, warning, info`. The default is `info`.\n * * `loading` (boolean) - Replaces the status icon with a spinner and forces the type to `info`.\n * * `dismissible` (boolean) - Determines whether the component includes a close button icon. By default, the close button is not included.\n * When a user clicks on this button the `onDismiss` handler is called.\n * * `dismissLabel` (string) - Specifies an `aria-label` for to the dismiss icon button for improved accessibility.\n * * `action` (ReactNode) - Specifies an action for the flash message. Although it is technically possible to insert any content,\n * our UX guidelines only allow you to add a button.\n * * `buttonText` (string) - Specifies that an action button should be displayed, with the specified text.\n * When a user clicks on this button the `onButtonClick` handler is called. If the `action` property is set, this property is ignored.\n * **Deprecated**, replaced by `action`.\n * * `onButtonClick` (event => void) - Called when a user clicks on the action button. This is not called if you create a custom button\n * using the `action` property. **Deprecated**, replaced by `action`.\n * * `id` (string) - Specifies a unique flash message identifier. This property is used in two ways:\n * 1. As a [keys](https://reactjs.org/docs/lists-and-keys.html#keys) source for React rendering.\n * 2. To identify which flash message will be removed from the DOM when it is dismissed, to animate it out.\n * @visualrefresh `id` property\n */\n items: ReadonlyArray<FlashbarProps.MessageDefinition>;\n}\n"]}
@@ -4,7 +4,7 @@ import { __assign, __rest } from "tslib";
4
4
  import React, { useRef } from 'react';
5
5
  import clsx from 'clsx';
6
6
  import { getBaseProps } from '../internal/base-component';
7
- import { FormFieldDomContext, useFormFieldContext } from '../internal/context/form-field-context';
7
+ import { FormFieldContext, useFormFieldContext } from '../internal/context/form-field-context';
8
8
  import { useUniqueId } from '../internal/hooks/use-unique-id';
9
9
  import { useVisualRefresh } from '../internal/hooks/use-visual-mode';
10
10
  import InternalGrid from '../grid/internal';
@@ -46,8 +46,8 @@ export default function InternalFormField(_a) {
46
46
  description && (React.createElement("div", { className: styles.description, id: slotIds.description }, description)),
47
47
  React.createElement("div", { className: clsx(styles.controls, __hideLabel && styles['label-hidden']) },
48
48
  React.createElement(InternalGrid, { gridDefinition: gridDefinition },
49
- React.createElement(FormFieldDomContext.RootProvider, { value: __assign({ controlId: generatedControlId }, contextValuesWithoutControlId) }, children && React.createElement("div", { className: styles.control }, children)),
50
- secondaryControl && (React.createElement(FormFieldDomContext.RootProvider, { value: contextValuesWithoutControlId },
49
+ React.createElement(FormFieldContext.Provider, { value: __assign({ controlId: generatedControlId }, contextValuesWithoutControlId) }, children && React.createElement("div", { className: styles.control }, children)),
50
+ secondaryControl && (React.createElement(FormFieldContext.Provider, { value: contextValuesWithoutControlId },
51
51
  React.createElement("div", { className: styles['secondary-control'] }, secondaryControl))))),
52
52
  (constraintText || errorText) && (React.createElement("div", { className: styles.hints },
53
53
  errorText && React.createElement(FormFieldError, { id: slotIds.error }, errorText),
@@ -1 +1 @@
1
- {"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/form-field/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAClG,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAErE,OAAO,YAAY,MAAM,kBAAkB,CAAC;AAC5C,OAAO,YAAY,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAE3E,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAErC,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAOxD,MAAM,CAAC,IAAM,cAAc,GAAG,UAAC,EAAqC;QAAnC,EAAE,QAAA,EAAE,QAAQ,cAAA;IAA4B,OAAA,CACvE,6BAAK,SAAS,EAAE,MAAM,CAAC,KAAK;QAC1B,6BAAK,SAAS,EAAE,MAAM,CAAC,0BAA0B,CAAC;YAChD,6BAAK,SAAS,EAAE,MAAM,CAAC,0BAA0B,CAAC;gBAChD,oBAAC,YAAY,IAAC,IAAI,EAAC,gBAAgB,EAAC,I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,IAAC,KAAK,EAAE,6BAA6B;oBACpE,6BAAK,SAAS,EAAE,MAAM,CAAC,mBAAmB,CAAC,IAAG,gBAAgB,CAAO,CACpC,CACpC,CACY,CACX;QAEL,CAAC,cAAc,IAAI,SAAS,CAAC,IAAI,CAChC,6BAAK,SAAS,EAAE,MAAM,CAAC,KAAK;YACzB,SAAS,IAAI,oBAAC,cAAc,IAAC,EAAE,EAAE,OAAO,CAAC,KAAK,IAAG,SAAS,CAAkB;YAC5E,cAAc,IAAI,CACjB,6BACE,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,SAAS,IAAI,MAAM,CAAC,sBAAsB,CAAC,CAAC,EAC/E,EAAE,EAAE,OAAO,CAAC,UAAU,IAErB,cAAc,CACX,CACP,CACG,CACP,CACG,CACP,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useRef } from 'react';\nimport clsx from 'clsx';\n\nimport { getBaseProps } from '../internal/base-component';\nimport { FormFieldDomContext, useFormFieldContext } from '../internal/context/form-field-context';\nimport { useUniqueId } from '../internal/hooks/use-unique-id';\nimport { useVisualRefresh } from '../internal/hooks/use-visual-mode';\n\nimport InternalGrid from '../grid/internal';\nimport InternalIcon from '../icon/internal';\nimport { getAriaDescribedBy, getGridDefinition, getSlotIds } from './util';\n\nimport styles from './styles.css.js';\nimport { InternalFormFieldProps } from './interfaces';\nimport { useMergeRefs } from '../internal/hooks/use-merge-refs';\nimport { joinStrings } from '../internal/utils/strings';\n\ninterface FormFieldErrorProps {\n id?: string;\n children?: React.ReactNode;\n}\n\nexport const FormFieldError = ({ id, children }: FormFieldErrorProps) => (\n <div className={styles.error}>\n <div className={styles['error-icon-shake-wrapper']}>\n <div className={styles['error-icon-scale-wrapper']}>\n <InternalIcon name=\"status-warning\" size=\"small\" />\n </div>\n </div>\n <span id={id} className={styles.error__message}>\n {children}\n </span>\n </div>\n);\n\nexport default function InternalFormField({\n controlId,\n stretch = false,\n label,\n info,\n children,\n secondaryControl,\n description,\n constraintText,\n errorText,\n __hideLabel,\n __internalRootRef = null,\n ...rest\n}: InternalFormFieldProps) {\n const baseProps = getBaseProps(rest);\n const ref = useRef<HTMLElement>(null);\n const isRefresh = useVisualRefresh(ref);\n\n const instanceUniqueId = useUniqueId('formField');\n const generatedControlId = controlId || instanceUniqueId;\n const formFieldId = controlId || generatedControlId;\n\n const slotIds = getSlotIds(formFieldId, label, description, constraintText, errorText);\n\n const ariaDescribedBy = getAriaDescribedBy(slotIds);\n\n const gridDefinition = getGridDefinition(stretch, !!secondaryControl, isRefresh);\n\n const {\n ariaLabelledby: parentAriaLabelledby,\n ariaDescribedby: parentAriaDescribedby,\n invalid: parentInvalid,\n } = useFormFieldContext({});\n\n const contextValuesWithoutControlId = {\n ariaLabelledby: joinStrings(parentAriaLabelledby, slotIds.label) || undefined,\n ariaDescribedby: joinStrings(parentAriaDescribedby, ariaDescribedBy) || undefined,\n invalid: !!errorText || !!parentInvalid,\n };\n\n const mergedRef = useMergeRefs(ref, __internalRootRef);\n\n return (\n <div {...baseProps} className={clsx(baseProps.className, styles.root)} ref={mergedRef}>\n <div className={clsx(__hideLabel && styles['visually-hidden'])}>\n {label && (\n <label className={styles.label} id={slotIds.label} htmlFor={generatedControlId}>\n {label}\n </label>\n )}\n {!__hideLabel && info && <span className={styles.info}>{info}</span>}\n </div>\n\n {description && (\n <div className={styles.description} id={slotIds.description}>\n {description}\n </div>\n )}\n\n <div className={clsx(styles.controls, __hideLabel && styles['label-hidden'])}>\n <InternalGrid gridDefinition={gridDefinition}>\n <FormFieldDomContext.RootProvider\n value={{\n controlId: generatedControlId,\n ...contextValuesWithoutControlId,\n }}\n >\n {children && <div className={styles.control}>{children}</div>}\n </FormFieldDomContext.RootProvider>\n\n {secondaryControl && (\n <FormFieldDomContext.RootProvider value={contextValuesWithoutControlId}>\n <div className={styles['secondary-control']}>{secondaryControl}</div>\n </FormFieldDomContext.RootProvider>\n )}\n </InternalGrid>\n </div>\n\n {(constraintText || errorText) && (\n <div className={styles.hints}>\n {errorText && <FormFieldError id={slotIds.error}>{errorText}</FormFieldError>}\n {constraintText && (\n <div\n className={clsx(styles.constraint, errorText && styles['constraint-has-error'])}\n id={slotIds.constraint}\n >\n {constraintText}\n </div>\n )}\n </div>\n )}\n </div>\n );\n}\n"]}
1
+ {"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/form-field/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAC/F,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAErE,OAAO,YAAY,MAAM,kBAAkB,CAAC;AAC5C,OAAO,YAAY,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAE3E,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAErC,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAOxD,MAAM,CAAC,IAAM,cAAc,GAAG,UAAC,EAAqC;QAAnC,EAAE,QAAA,EAAE,QAAQ,cAAA;IAA4B,OAAA,CACvE,6BAAK,SAAS,EAAE,MAAM,CAAC,KAAK;QAC1B,6BAAK,SAAS,EAAE,MAAM,CAAC,0BAA0B,CAAC;YAChD,6BAAK,SAAS,EAAE,MAAM,CAAC,0BAA0B,CAAC;gBAChD,oBAAC,YA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AAI,CACnB,oBAAC,gBAAgB,CAAC,QAAQ,IAAC,KAAK,EAAE,6BAA6B;oBAC7D,6BAAK,SAAS,EAAE,MAAM,CAAC,mBAAmB,CAAC,IAAG,gBAAgB,CAAO,CAC3C,CAC7B,CACY,CACX;QAEL,CAAC,cAAc,IAAI,SAAS,CAAC,IAAI,CAChC,6BAAK,SAAS,EAAE,MAAM,CAAC,KAAK;YACzB,SAAS,IAAI,oBAAC,cAAc,IAAC,EAAE,EAAE,OAAO,CAAC,KAAK,IAAG,SAAS,CAAkB;YAC5E,cAAc,IAAI,CACjB,6BACE,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,SAAS,IAAI,MAAM,CAAC,sBAAsB,CAAC,CAAC,EAC/E,EAAE,EAAE,OAAO,CAAC,UAAU,IAErB,cAAc,CACX,CACP,CACG,CACP,CACG,CACP,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useRef } from 'react';\nimport clsx from 'clsx';\n\nimport { getBaseProps } from '../internal/base-component';\nimport { FormFieldContext, useFormFieldContext } from '../internal/context/form-field-context';\nimport { useUniqueId } from '../internal/hooks/use-unique-id';\nimport { useVisualRefresh } from '../internal/hooks/use-visual-mode';\n\nimport InternalGrid from '../grid/internal';\nimport InternalIcon from '../icon/internal';\nimport { getAriaDescribedBy, getGridDefinition, getSlotIds } from './util';\n\nimport styles from './styles.css.js';\nimport { InternalFormFieldProps } from './interfaces';\nimport { useMergeRefs } from '../internal/hooks/use-merge-refs';\nimport { joinStrings } from '../internal/utils/strings';\n\ninterface FormFieldErrorProps {\n id?: string;\n children?: React.ReactNode;\n}\n\nexport const FormFieldError = ({ id, children }: FormFieldErrorProps) => (\n <div className={styles.error}>\n <div className={styles['error-icon-shake-wrapper']}>\n <div className={styles['error-icon-scale-wrapper']}>\n <InternalIcon name=\"status-warning\" size=\"small\" />\n </div>\n </div>\n <span id={id} className={styles.error__message}>\n {children}\n </span>\n </div>\n);\n\nexport default function InternalFormField({\n controlId,\n stretch = false,\n label,\n info,\n children,\n secondaryControl,\n description,\n constraintText,\n errorText,\n __hideLabel,\n __internalRootRef = null,\n ...rest\n}: InternalFormFieldProps) {\n const baseProps = getBaseProps(rest);\n const ref = useRef<HTMLElement>(null);\n const isRefresh = useVisualRefresh(ref);\n\n const instanceUniqueId = useUniqueId('formField');\n const generatedControlId = controlId || instanceUniqueId;\n const formFieldId = controlId || generatedControlId;\n\n const slotIds = getSlotIds(formFieldId, label, description, constraintText, errorText);\n\n const ariaDescribedBy = getAriaDescribedBy(slotIds);\n\n const gridDefinition = getGridDefinition(stretch, !!secondaryControl, isRefresh);\n\n const {\n ariaLabelledby: parentAriaLabelledby,\n ariaDescribedby: parentAriaDescribedby,\n invalid: parentInvalid,\n } = useFormFieldContext({});\n\n const contextValuesWithoutControlId = {\n ariaLabelledby: joinStrings(parentAriaLabelledby, slotIds.label) || undefined,\n ariaDescribedby: joinStrings(parentAriaDescribedby, ariaDescribedBy) || undefined,\n invalid: !!errorText || !!parentInvalid,\n };\n\n const mergedRef = useMergeRefs(ref, __internalRootRef);\n\n return (\n <div {...baseProps} className={clsx(baseProps.className, styles.root)} ref={mergedRef}>\n <div className={clsx(__hideLabel && styles['visually-hidden'])}>\n {label && (\n <label className={styles.label} id={slotIds.label} htmlFor={generatedControlId}>\n {label}\n </label>\n )}\n {!__hideLabel && info && <span className={styles.info}>{info}</span>}\n </div>\n\n {description && (\n <div className={styles.description} id={slotIds.description}>\n {description}\n </div>\n )}\n\n <div className={clsx(styles.controls, __hideLabel && styles['label-hidden'])}>\n <InternalGrid gridDefinition={gridDefinition}>\n <FormFieldContext.Provider\n value={{\n controlId: generatedControlId,\n ...contextValuesWithoutControlId,\n }}\n >\n {children && <div className={styles.control}>{children}</div>}\n </FormFieldContext.Provider>\n\n {secondaryControl && (\n <FormFieldContext.Provider value={contextValuesWithoutControlId}>\n <div className={styles['secondary-control']}>{secondaryControl}</div>\n </FormFieldContext.Provider>\n )}\n </InternalGrid>\n </div>\n\n {(constraintText || errorText) && (\n <div className={styles.hints}>\n {errorText && <FormFieldError id={slotIds.error}>{errorText}</FormFieldError>}\n {constraintText && (\n <div\n className={clsx(styles.constraint, errorText && styles['constraint-has-error'])}\n id={slotIds.constraint}\n >\n {constraintText}\n </div>\n )}\n </div>\n )}\n </div>\n );\n}\n"]}
@@ -567,6 +567,7 @@
567
567
  --shadow-split-bottom-otfetg:0px -36px 36px -36px rgba(0, 7, 22, 0.10);
568
568
  --shadow-split-side-qv353u:-1px 0px 1px 0px #e9ebed, -36px 6px 36px -36px rgba(0, 7, 22, 0.10);
569
569
  --shadow-sticky-aijlo6:0px 4px 20px 1px rgba(0, 7, 22, 0.10);
570
+ --shadow-sticky-embedded-qit8ba:0px 2px 0px 0px #e9ebed, 0px 16px 16px -12px rgba(0, 7, 22, 0.10);
570
571
  }
571
572
 
572
573
  .awsui-dark-mode:not(#\9) {
@@ -902,6 +903,7 @@
902
903
  --shadow-split-bottom-otfetg:0px -36px 36px -36px rgba(0, 7, 22, 1);
903
904
  --shadow-split-side-qv353u:-1px 0px 1px 0px #192534, -36px 6px 36px -36px rgba(0, 7, 22, 1);
904
905
  --shadow-sticky-aijlo6:0px 4px 20px 1px rgba(0, 7, 22, 1);
906
+ --shadow-sticky-embedded-qit8ba:0px 2px 0px 0px #414d5c, 0px 16px 16px -12px rgba(0, 7, 22, 1);
905
907
  }
906
908
 
907
909
  .awsui-compact-mode:not(#\9) {
@@ -1304,6 +1306,7 @@
1304
1306
  --shadow-split-bottom-otfetg:0px -36px 36px -36px rgba(0, 7, 22, 1);
1305
1307
  --shadow-split-side-qv353u:-1px 0px 1px 0px #192534, -36px 6px 36px -36px rgba(0, 7, 22, 1);
1306
1308
  --shadow-sticky-aijlo6:0px 4px 20px 1px rgba(0, 7, 22, 1);
1309
+ --shadow-sticky-embedded-qit8ba:0px 2px 0px 0px #414d5c, 0px 16px 16px -12px rgba(0, 7, 22, 1);
1307
1310
  }
1308
1311
 
1309
1312
  .awsui-context-flashbar:not(#\9) {
@@ -2,7 +2,7 @@ export interface AppLayoutContextProps {
2
2
  stickyOffsetBottom: number;
3
3
  stickyOffsetTop: number;
4
4
  }
5
- export declare const AppLayoutDomContext: import("../hooks/dom-context").DomContextDeclaration<AppLayoutContextProps>;
5
+ export declare const AppLayoutContext: import("react").Context<AppLayoutContextProps>;
6
6
  export declare function useAppLayoutContext(): {
7
7
  stickyOffsetBottom: number;
8
8
  stickyOffsetTop: number;
@@ -1 +1 @@
1
- {"version":3,"file":"app-layout-context.d.ts","sourceRoot":"","sources":["../../../../src/internal/context/app-layout-context.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,qBAAqB;IACpC,kBAAkB,EAAE,MAAM,CAAC;IAC3B,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,eAAO,MAAM,mBAAmB,6EAG9B,CAAC;AAEH,wBAAgB,mBAAmB;;;EAGlC"}
1
+ {"version":3,"file":"app-layout-context.d.ts","sourceRoot":"","sources":["../../../../src/internal/context/app-layout-context.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,qBAAqB;IACpC,kBAAkB,EAAE,MAAM,CAAC;IAC3B,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,eAAO,MAAM,gBAAgB,gDAG3B,CAAC;AAEH,wBAAgB,mBAAmB;;;EAGlC"}
@@ -1,14 +1,13 @@
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 { useContext } from 'react';
5
- import { createDomContext } from '../hooks/dom-context';
6
- export var AppLayoutDomContext = createDomContext('app-layout-context', {
4
+ import { useContext, createContext } from 'react';
5
+ export var AppLayoutContext = createContext({
7
6
  stickyOffsetTop: 0,
8
7
  stickyOffsetBottom: 0
9
8
  });
10
9
  export function useAppLayoutContext() {
11
- var context = useContext(AppLayoutDomContext.context);
10
+ var context = useContext(AppLayoutContext);
12
11
  return __assign({}, context);
13
12
  }
14
13
  //# sourceMappingURL=app-layout-context.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"app-layout-context.js","sourceRoot":"","sources":["../../../../src/internal/context/app-layout-context.ts"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAOxD,MAAM,CAAC,IAAM,mBAAmB,GAAG,gBAAgB,CAAwB,oBAAoB,EAAE;IAC/F,eAAe,EAAE,CAAC;IAClB,kBAAkB,EAAE,CAAC;CACtB,CAAC,CAAC;AAEH,MAAM,UAAU,mBAAmB;IACjC,IAAM,OAAO,GAAG,UAAU,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC;IACxD,oBAAY,OAAO,EAAG;AACxB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { useContext } from 'react';\nimport { createDomContext } from '../hooks/dom-context';\n\nexport interface AppLayoutContextProps {\n stickyOffsetBottom: number;\n stickyOffsetTop: number;\n}\n\nexport const AppLayoutDomContext = createDomContext<AppLayoutContextProps>('app-layout-context', {\n stickyOffsetTop: 0,\n stickyOffsetBottom: 0,\n});\n\nexport function useAppLayoutContext() {\n const context = useContext(AppLayoutDomContext.context);\n return { ...context };\n}\n"]}
1
+ {"version":3,"file":"app-layout-context.js","sourceRoot":"","sources":["../../../../src/internal/context/app-layout-context.ts"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAOlD,MAAM,CAAC,IAAM,gBAAgB,GAAG,aAAa,CAAwB;IACnE,eAAe,EAAE,CAAC;IAClB,kBAAkB,EAAE,CAAC;CACtB,CAAC,CAAC;AAEH,MAAM,UAAU,mBAAmB;IACjC,IAAM,OAAO,GAAG,UAAU,CAAC,gBAAgB,CAAC,CAAC;IAC7C,oBAAY,OAAO,EAAG;AACxB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { useContext, createContext } from 'react';\n\nexport interface AppLayoutContextProps {\n stickyOffsetBottom: number;\n stickyOffsetTop: number;\n}\n\nexport const AppLayoutContext = createContext<AppLayoutContextProps>({\n stickyOffsetTop: 0,\n stickyOffsetBottom: 0,\n});\n\nexport function useAppLayoutContext() {\n const context = useContext(AppLayoutContext);\n return { ...context };\n}\n"]}
@@ -39,6 +39,6 @@ export interface FormFieldValidationControlProps extends FormFieldControlProps {
39
39
  */
40
40
  invalid?: boolean;
41
41
  }
42
- export declare const FormFieldDomContext: import("../hooks/dom-context").DomContextDeclaration<FormFieldValidationControlProps>;
42
+ export declare const FormFieldContext: import("react").Context<FormFieldValidationControlProps>;
43
43
  export declare function useFormFieldContext(props: FormFieldValidationControlProps): FormFieldValidationControlProps;
44
44
  //# sourceMappingURL=form-field-context.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"form-field-context.d.ts","sourceRoot":"","sources":["../../../../src/internal/context/form-field-context.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,qBAAqB;IACpC;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;;;;;;OAQG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;;;;;;;;OASG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,+BAAgC,SAAQ,qBAAqB;IAC5E;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,eAAO,MAAM,mBAAmB,uFAA8E,CAAC;AAU/G,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,+BAA+B,mCAGzE"}
1
+ {"version":3,"file":"form-field-context.d.ts","sourceRoot":"","sources":["../../../../src/internal/context/form-field-context.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,qBAAqB;IACpC;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;;;;;;OAQG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;;;;;;;;OASG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,+BAAgC,SAAQ,qBAAqB;IAC5E;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,eAAO,MAAM,gBAAgB,0DAAqD,CAAC;AAUnF,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,+BAA+B,mCAGzE"}
@@ -1,8 +1,7 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
- import { useContext } from 'react';
4
- import { createDomContext } from '../hooks/dom-context';
5
- export var FormFieldDomContext = createDomContext('form-field-context', {});
3
+ import { useContext, createContext } from 'react';
4
+ export var FormFieldContext = createContext({});
6
5
  function applyDefault(fields, defaults, keys) {
7
6
  var result = {};
8
7
  keys.forEach(function (key) {
@@ -11,7 +10,7 @@ function applyDefault(fields, defaults, keys) {
11
10
  return result;
12
11
  }
13
12
  export function useFormFieldContext(props) {
14
- var context = useContext(FormFieldDomContext.context);
13
+ var context = useContext(FormFieldContext);
15
14
  return applyDefault(props, context, ['invalid', 'controlId', 'ariaLabelledby', 'ariaDescribedby']);
16
15
  }
17
16
  //# sourceMappingURL=form-field-context.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"form-field-context.js","sourceRoot":"","sources":["../../../../src/internal/context/form-field-context.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AA+CxD,MAAM,CAAC,IAAM,mBAAmB,GAAG,gBAAgB,CAAkC,oBAAoB,EAAE,EAAE,CAAC,CAAC;AAE/G,SAAS,YAAY,CAAI,MAAS,EAAE,QAAW,EAAE,IAAiB;IAChE,IAAM,MAAM,GAAM,EAAE,CAAC;IACrB,IAAI,CAAC,OAAO,CAAC,UAAA,GAAG;QACd,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACxE,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,KAAsC;IACxE,IAAM,OAAO,GAAG,UAAU,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC;IACxD,OAAO,YAAY,CAAC,KAAK,EAAE,OAAO,EAAE,CAAC,SAAS,EAAE,WAAW,EAAE,gBAAgB,EAAE,iBAAiB,CAAC,CAAC,CAAC;AACrG,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { useContext } from 'react';\nimport { createDomContext } from '../hooks/dom-context';\n\nexport interface FormFieldControlProps {\n /**\n * Specifies the ID of the native form element. You can use it to relate\n * a label element's `for` attribute to this control.\n *\n * It defaults to an automatically generated ID that\n * is provided by its parent form field component.\n */\n controlId?: string;\n\n /**\n * Adds `aria-labelledby` to the component. If you're using this component within a form field,\n * don't set this property because the form field component automatically sets it.\n *\n * Use this property if the component isn't surrounded by a form field, or you want to override the value\n * automatically set by the form field (for example, if you have two components within a single form field).\n *\n * To use it correctly, define an ID for the element you want to use as label and set the property to that ID.\n */\n ariaLabelledby?: string;\n\n /**\n * Adds `aria-describedby` to the component. If you're using this component within a form field,\n * don't set this property because the form field component automatically sets it.\n *\n * Use this property if the component isn't surrounded by a form field, or you want to override the value\n * automatically set by the form field (for example, if you have two components within a single form field).\n *\n * To use it correctly, define an ID for each element that you want to use as a description\n * and set the property to a string of each ID separated by spaces (for example, `\"id1 id2 id3\"`).\n */\n ariaDescribedby?: string;\n}\n\nexport interface FormFieldValidationControlProps extends FormFieldControlProps {\n /**\n * Overrides the invalidation state. Usually the invalid state\n * comes from the parent `FormField`component,\n * however sometimes you need to override its\n * state when you have more than one input within a\n * single form field.\n */\n invalid?: boolean;\n}\n\nexport const FormFieldDomContext = createDomContext<FormFieldValidationControlProps>('form-field-context', {});\n\nfunction applyDefault<T>(fields: T, defaults: T, keys: (keyof T)[]) {\n const result = <T>{};\n keys.forEach(key => {\n result[key] = fields[key] === undefined ? defaults[key] : fields[key];\n });\n return result;\n}\n\nexport function useFormFieldContext(props: FormFieldValidationControlProps) {\n const context = useContext(FormFieldDomContext.context);\n return applyDefault(props, context, ['invalid', 'controlId', 'ariaLabelledby', 'ariaDescribedby']);\n}\n"]}
1
+ {"version":3,"file":"form-field-context.js","sourceRoot":"","sources":["../../../../src/internal/context/form-field-context.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AA+ClD,MAAM,CAAC,IAAM,gBAAgB,GAAG,aAAa,CAAkC,EAAE,CAAC,CAAC;AAEnF,SAAS,YAAY,CAAI,MAAS,EAAE,QAAW,EAAE,IAAiB;IAChE,IAAM,MAAM,GAAM,EAAE,CAAC;IACrB,IAAI,CAAC,OAAO,CAAC,UAAA,GAAG;QACd,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACxE,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,KAAsC;IACxE,IAAM,OAAO,GAAG,UAAU,CAAC,gBAAgB,CAAC,CAAC;IAC7C,OAAO,YAAY,CAAC,KAAK,EAAE,OAAO,EAAE,CAAC,SAAS,EAAE,WAAW,EAAE,gBAAgB,EAAE,iBAAiB,CAAC,CAAC,CAAC;AACrG,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { useContext, createContext } from 'react';\n\nexport interface FormFieldControlProps {\n /**\n * Specifies the ID of the native form element. You can use it to relate\n * a label element's `for` attribute to this control.\n *\n * It defaults to an automatically generated ID that\n * is provided by its parent form field component.\n */\n controlId?: string;\n\n /**\n * Adds `aria-labelledby` to the component. If you're using this component within a form field,\n * don't set this property because the form field component automatically sets it.\n *\n * Use this property if the component isn't surrounded by a form field, or you want to override the value\n * automatically set by the form field (for example, if you have two components within a single form field).\n *\n * To use it correctly, define an ID for the element you want to use as label and set the property to that ID.\n */\n ariaLabelledby?: string;\n\n /**\n * Adds `aria-describedby` to the component. If you're using this component within a form field,\n * don't set this property because the form field component automatically sets it.\n *\n * Use this property if the component isn't surrounded by a form field, or you want to override the value\n * automatically set by the form field (for example, if you have two components within a single form field).\n *\n * To use it correctly, define an ID for each element that you want to use as a description\n * and set the property to a string of each ID separated by spaces (for example, `\"id1 id2 id3\"`).\n */\n ariaDescribedby?: string;\n}\n\nexport interface FormFieldValidationControlProps extends FormFieldControlProps {\n /**\n * Overrides the invalidation state. Usually the invalid state\n * comes from the parent `FormField`component,\n * however sometimes you need to override its\n * state when you have more than one input within a\n * single form field.\n */\n invalid?: boolean;\n}\n\nexport const FormFieldContext = createContext<FormFieldValidationControlProps>({});\n\nfunction applyDefault<T>(fields: T, defaults: T, keys: (keyof T)[]) {\n const result = <T>{};\n keys.forEach(key => {\n result[key] = fields[key] === undefined ? defaults[key] : fields[key];\n });\n return result;\n}\n\nexport function useFormFieldContext(props: FormFieldValidationControlProps) {\n const context = useContext(FormFieldContext);\n return applyDefault(props, context, ['invalid', 'controlId', 'ariaLabelledby', 'ariaDescribedby']);\n}\n"]}
@@ -1,5 +1,5 @@
1
1
 
2
- export var PACKAGE_VERSION = '3.0.0 (fda2a3d)';
2
+ export var PACKAGE_VERSION = '3.0.0 (f3388c5)';
3
3
  export var THEME = 'open-source-visual-refresh';
4
4
  export var ALWAYS_VISUAL_REFRESH = true;
5
5
 
@@ -2203,6 +2203,10 @@ module.exports.preset = {
2203
2203
  "shadowSticky": {
2204
2204
  "light": "{shadowDropdown}",
2205
2205
  "dark": "{shadowDropdown}"
2206
+ },
2207
+ "shadowStickyEmbedded": {
2208
+ "light": "0px 2px 0px 0px #e9ebed, 0px 16px 16px -12px rgba(0, 7, 22, 0.10)",
2209
+ "dark": "0px 2px 0px 0px #414d5c, 0px 16px 16px -12px rgba(0, 7, 22, 1)"
2206
2210
  }
2207
2211
  },
2208
2212
  "contexts": {
@@ -3108,6 +3112,10 @@ module.exports.preset = {
3108
3112
  "light": "{shadowDropdown}",
3109
3113
  "dark": "{shadowDropdown}"
3110
3114
  },
3115
+ "shadowStickyEmbedded": {
3116
+ "light": "0px 2px 0px 0px #414d5c, 0px 16px 16px -12px rgba(0, 7, 22, 1)",
3117
+ "dark": "0px 2px 0px 0px #414d5c, 0px 16px 16px -12px rgba(0, 7, 22, 1)"
3118
+ },
3111
3119
  "colorGreyOpaque25": {
3112
3120
  "light": "rgba(255, 255, 255, 0.25)",
3113
3121
  "dark": "rgba(255, 255, 255, 0.25)"
@@ -6165,7 +6173,8 @@ module.exports.preset = {
6165
6173
  "shadowPopover": "color",
6166
6174
  "shadowSplitBottom": "color",
6167
6175
  "shadowSplitSide": "color",
6168
- "shadowSticky": "color"
6176
+ "shadowSticky": "color",
6177
+ "shadowStickyEmbedded": "color"
6169
6178
  }
6170
6179
  },
6171
6180
  "secondary": [],
@@ -7214,7 +7223,8 @@ module.exports.preset = {
7214
7223
  "shadowPopover": "shadow-popover",
7215
7224
  "shadowSplitBottom": "shadow-split-bottom",
7216
7225
  "shadowSplitSide": "shadow-split-side",
7217
- "shadowSticky": "shadow-sticky"
7226
+ "shadowSticky": "shadow-sticky",
7227
+ "shadowStickyEmbedded": "shadow-sticky-embedded"
7218
7228
  },
7219
7229
  "propertiesMap": {
7220
7230
  "colorAmazonOrange": "--color-amazon-orange-ds51uu",
@@ -7852,6 +7862,7 @@ module.exports.preset = {
7852
7862
  "shadowPopover": "--shadow-popover-kzy6rd",
7853
7863
  "shadowSplitBottom": "--shadow-split-bottom-otfetg",
7854
7864
  "shadowSplitSide": "--shadow-split-side-qv353u",
7855
- "shadowSticky": "--shadow-sticky-aijlo6"
7865
+ "shadowSticky": "--shadow-sticky-aijlo6",
7866
+ "shadowStickyEmbedded": "--shadow-sticky-embedded-qit8ba"
7856
7867
  }
7857
7868
  };
@@ -2203,6 +2203,10 @@ export var preset = {
2203
2203
  "shadowSticky": {
2204
2204
  "light": "{shadowDropdown}",
2205
2205
  "dark": "{shadowDropdown}"
2206
+ },
2207
+ "shadowStickyEmbedded": {
2208
+ "light": "0px 2px 0px 0px #e9ebed, 0px 16px 16px -12px rgba(0, 7, 22, 0.10)",
2209
+ "dark": "0px 2px 0px 0px #414d5c, 0px 16px 16px -12px rgba(0, 7, 22, 1)"
2206
2210
  }
2207
2211
  },
2208
2212
  "contexts": {
@@ -3108,6 +3112,10 @@ export var preset = {
3108
3112
  "light": "{shadowDropdown}",
3109
3113
  "dark": "{shadowDropdown}"
3110
3114
  },
3115
+ "shadowStickyEmbedded": {
3116
+ "light": "0px 2px 0px 0px #414d5c, 0px 16px 16px -12px rgba(0, 7, 22, 1)",
3117
+ "dark": "0px 2px 0px 0px #414d5c, 0px 16px 16px -12px rgba(0, 7, 22, 1)"
3118
+ },
3111
3119
  "colorGreyOpaque25": {
3112
3120
  "light": "rgba(255, 255, 255, 0.25)",
3113
3121
  "dark": "rgba(255, 255, 255, 0.25)"
@@ -6165,7 +6173,8 @@ export var preset = {
6165
6173
  "shadowPopover": "color",
6166
6174
  "shadowSplitBottom": "color",
6167
6175
  "shadowSplitSide": "color",
6168
- "shadowSticky": "color"
6176
+ "shadowSticky": "color",
6177
+ "shadowStickyEmbedded": "color"
6169
6178
  }
6170
6179
  },
6171
6180
  "secondary": [],
@@ -7214,7 +7223,8 @@ export var preset = {
7214
7223
  "shadowPopover": "shadow-popover",
7215
7224
  "shadowSplitBottom": "shadow-split-bottom",
7216
7225
  "shadowSplitSide": "shadow-split-side",
7217
- "shadowSticky": "shadow-sticky"
7226
+ "shadowSticky": "shadow-sticky",
7227
+ "shadowStickyEmbedded": "shadow-sticky-embedded"
7218
7228
  },
7219
7229
  "propertiesMap": {
7220
7230
  "colorAmazonOrange": "--color-amazon-orange-ds51uu",
@@ -7852,6 +7862,7 @@ export var preset = {
7852
7862
  "shadowPopover": "--shadow-popover-kzy6rd",
7853
7863
  "shadowSplitBottom": "--shadow-split-bottom-otfetg",
7854
7864
  "shadowSplitSide": "--shadow-split-side-qv353u",
7855
- "shadowSticky": "--shadow-sticky-aijlo6"
7865
+ "shadowSticky": "--shadow-sticky-aijlo6",
7866
+ "shadowStickyEmbedded": "--shadow-sticky-embedded-qit8ba"
7856
7867
  }
7857
7868
  };
package/package.json CHANGED
@@ -110,6 +110,6 @@
110
110
  "./internal/base-component/index.js",
111
111
  "./internal/base-component/styles.css.js"
112
112
  ],
113
- "version": "3.0.2",
113
+ "version": "3.0.5",
114
114
  "license": "Apache-2.0"
115
115
  }
@@ -1 +1 @@
1
- {"version":3,"file":"use-select.d.ts","sourceRoot":"","sources":["../../../../src/select/utils/use-select.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAe,MAAM,6CAA6C,CAAC;AAS5G,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAC1E,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe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;IACvC,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,sBAAsB,CAAC;IAChC,OAAO,CAAC,EAAE,sBAAsB,CAAC;IACjC,WAAW,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC5B,aAAa,EAAE,CAAC,aAAa,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/C,iBAAiB,EAAE,CAAC,aAAa,EAAE,MAAM,KAAK,IAAI,CAAC;IACnD,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC;AAED,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,SAAS,CAAC,iBAAiB,CAAC,CAAC;IAClC,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;IAC3C,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,aAAa,CAAC,KAAK,IAAI,CAAC;IACxD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,yBAAyB,CAAC;IACnC,MAAM,EAAE,yBAAyB,CAAC;QAAE,aAAa,EAAE,IAAI,GAAG,IAAI,CAAA;KAAE,CAAC,CAAC;CACnE;AAED,wBAAgB,SAAS,CAAC,EACxB,eAAe,EACf,oBAAoB,EACpB,OAAO,EACP,aAAa,EACb,MAAM,EACN,OAAO,EACP,WAAW,EACX,QAAQ,EACR,aAAa,EACb,iBAAiB,EACjB,oBAA4B,GAC7B,EAAE,cAAc;;;;;;0BAuHY,QAAQ,WAAW,CAAC;6BAiEf,cAAc,SAAS,MAAM;;;;;EA4D9D"}
@@ -135,6 +135,7 @@ export function useSelect(_a) {
135
135
  'aria-activedescendant': highlightedOptionId
136
136
  },
137
137
  _a['aria-owns'] = menuId,
138
+ _a['aria-controls'] = menuId,
138
139
  _a)
139
140
  };
140
141
  };
@@ -1 +1 @@
1
- {"version":3,"file":"use-select.js","sourceRoot":"","sources":["../../../../src/select/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O,0CAAE,KAAK,CAAC,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;SACnD;IACH,CAAC,EAAE,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;IAExB,eAAe,CAAC,WAAW,EAAE,UAA0C,CAAC,CAAC;IACzE,IAAM,wBAAwB,GAC5B,CAAC,CAAC,iBAAiB,IAAI,OAAO,CAAC,iBAAiB,CAAC,MAAM,CAAC,IAAI,aAAa,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC;IAC/G,IAAM,gBAAgB,GACpB,CAAC,CAAC,iBAAiB,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,IAAI,wBAAwB,CAAC,CAAC;IAEzG,OAAO;QACL,MAAM,QAAA;QACN,iBAAiB,mBAAA;QACjB,gBAAgB,kBAAA;QAChB,eAAe,iBAAA;QACf,YAAY,cAAA;QACZ,cAAc,gBAAA;QACd,cAAc,gBAAA;QACd,UAAU,YAAA;QACV,eAAe,iBAAA;QACf,YAAY,cAAA;QACZ,gBAAgB,kBAAA;KACjB,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { RefObject } from 'react';\nimport { DropdownOption, OptionDefinition, OptionGroup } from '../../internal/components/option/interfaces';\nimport { isInteractive, isGroupInteractive, isGroup } from '../../internal/components/option/utils/filter-options';\nimport { useEffect, useRef, MutableRefObject } from 'react';\nimport { createHighlightedOptionHook } from '../../internal/components/options-list/utils/use-highlight-option';\nimport { useOpenState } from '../../internal/components/options-list/utils/use-open-state';\nimport { useMenuKeyboard, useTriggerKeyboard } from '../../internal/components/options-list/utils/use-keyboard';\nimport { useIds, getOptionId } from '../../internal/components/options-list/utils/use-ids';\nimport { connectOptionsByValue } from './connect-options';\nimport useForwardFocus from '../../internal/hooks/forward-focus';\nimport { OptionsListProps } from '../../internal/components/options-list';\nimport { FilterProps } from '../parts/filter';\nimport { ItemProps } from '../parts/item';\nimport { usePrevious } from '../../internal/hooks/use-previous';\nimport { BaseKeyDetail } from '../../internal/events';\nimport { CancelableEventHandler, fireCancelableEvent, NonCancelableEventHandler } from '../../internal/events/index';\nimport { containsOrEqual } from '../../internal/utils/dom';\n\nexport type MenuProps = Omit<OptionsListProps, 'children'> & { ref: React.RefObject<HTMLUListElement> };\nexport type GetOptionProps = (option: DropdownOption, index: number) => ItemProps;\n\ninterface UseSelectProps {\n selectedOptions: ReadonlyArray<OptionDefinition>;\n updateSelectedOption: (option: OptionDefinition) => void;\n options: ReadonlyArray<DropdownOption>;\n filteringType: string;\n keepOpen?: boolean;\n onBlur?: CancelableEventHandler;\n onFocus?: CancelableEventHandler;\n externalRef: React.Ref<any>;\n fireLoadItems: (filteringText: string) => void;\n setFilteringValue: (filteringText: string) => void;\n useInteractiveGroups?: boolean;\n}\n\nexport interface SelectTriggerProps {\n ref: RefObject<HTMLButtonElement>;\n onMouseDown?: (event: CustomEvent) => void;\n onKeyDown?: (event: CustomEvent<BaseKeyDetail>) => void;\n ariaLabelledby?: string;\n onFocus: NonCancelableEventHandler;\n onBlur: NonCancelableEventHandler<{ relatedTarget: Node | null }>;\n}\n\nexport function useSelect({\n selectedOptions,\n updateSelectedOption,\n options,\n filteringType,\n onBlur,\n onFocus,\n externalRef,\n keepOpen,\n fireLoadItems,\n setFilteringValue,\n useInteractiveGroups = false,\n}: UseSelectProps) {\n const interactivityCheck = useInteractiveGroups ? isGroupInteractive : isInteractive;\n\n const isHighlightable = (option?: DropdownOption) => !!option && (useInteractiveGroups || option.type !== 'parent');\n const useHighlightedOption = createHighlightedOptionHook({ isHighlightable: isHighlightable });\n\n const filterRef = useRef<HTMLInputElement>(null);\n const triggerRef = useRef<HTMLButtonElement>(null);\n const menuRef = useRef<HTMLUListElement>(null);\n const hasFilter = filteringType !== 'none';\n const activeRef = hasFilter ? filterRef : menuRef;\n const isKeyboard = useRef<boolean>(false);\n const isSelectingUsingSpace = useRef<boolean>(false);\n const __selectedOptions = connectOptionsByValue(options, selectedOptions);\n const __selectedValuesSet = selectedOptions.reduce((selectedValuesSet: Set<string>, item: OptionDefinition) => {\n if (item.value) {\n selectedValuesSet.add(item.value);\n }\n return selectedValuesSet;\n }, new Set<string>());\n const {\n highlightedOption,\n highlightedIndex,\n moveHighlight,\n resetHighlight,\n setHighlightedIndex,\n highlightOption,\n goHome,\n goEnd,\n } = useHighlightedOption(options);\n\n const { isOpen, openDropdown, closeDropdown, toggleDropdown } = useOpenState({\n onOpen: () => fireLoadItems(''),\n onClose: () => {\n resetHighlight();\n setFilteringValue('');\n },\n });\n\n const focused: MutableRefObject<boolean> = useRef<boolean>(false);\n const handleFocus = () => {\n if (!focused.current) {\n fireCancelableEvent(onFocus, {});\n focused.current = true;\n }\n };\n const handleBlur = ({ detail }: { detail: { relatedTarget: Node | null } }) => {\n const { relatedTarget } = detail;\n const nextFocusedIsTrigger = relatedTarget ? containsOrEqual(triggerRef.current, relatedTarget) : false;\n const nextFocusedInsideDropdown = relatedTarget\n ? containsOrEqual(menuRef.current, relatedTarget) || containsOrEqual(filterRef.current, relatedTarget)\n : false;\n const nextFocusedInsideComponent = nextFocusedIsTrigger || nextFocusedInsideDropdown;\n const focusingOut = focused.current && !nextFocusedInsideComponent;\n\n if (nextFocusedIsTrigger || focusingOut) {\n closeDropdown();\n }\n if (focusingOut) {\n fireCancelableEvent(onBlur, {});\n focused.current = false;\n }\n };\n\n const hasSelectedOption = __selectedOptions.length > 0;\n const { selectedOptionId, menuId } = useIds({ hasSelectedOption });\n const highlightedOptionId = getOptionId(menuId, highlightedIndex);\n\n const selectOption = (option?: DropdownOption) => {\n isSelectingUsingSpace.current = false;\n const optionToSelect = option || highlightedOption;\n if (!optionToSelect || !interactivityCheck(optionToSelect)) {\n return;\n }\n updateSelectedOption(optionToSelect.option);\n if (!keepOpen) {\n triggerRef.current?.focus();\n closeDropdown();\n }\n };\n\n const activeKeyDownHandler = useMenuKeyboard({\n moveHighlight,\n selectOption,\n goHome,\n goEnd,\n closeDropdown: () => {\n triggerRef.current?.focus();\n closeDropdown();\n },\n isKeyboard,\n isSelectingUsingSpace,\n preventNativeSpace: !hasFilter,\n });\n\n const triggerKeyDownHandler = useTriggerKeyboard({ openDropdown, goHome, isKeyboard });\n\n const getTriggerProps = (disabled = false) => {\n const triggerProps: SelectTriggerProps = {\n ref: triggerRef,\n onFocus: handleFocus,\n onBlur: handleBlur,\n };\n if (!disabled) {\n triggerProps.onMouseDown = (event: CustomEvent) => {\n event.preventDefault(); // prevent current focus from blurring as it immediately closes the dropdown\n if (isOpen) {\n triggerRef.current?.focus();\n }\n toggleDropdown();\n };\n triggerProps.onKeyDown = triggerKeyDownHandler;\n }\n if (hasSelectedOption) {\n triggerProps.ariaLabelledby = selectedOptionId;\n }\n return triggerProps;\n };\n\n const getFilterProps = (): Partial<FilterProps> => {\n if (!hasFilter) {\n return {};\n }\n\n return {\n ref: filterRef,\n onKeyDown: activeKeyDownHandler,\n __onBlurWithDetail: handleBlur,\n onFocus: handleFocus,\n onChange: event => {\n setFilteringValue(event.detail.value);\n resetHighlight();\n },\n __onDelayedInput: event => {\n fireLoadItems(event.detail.value);\n },\n __nativeAttributes: {\n 'aria-activedescendant': highlightedOptionId,\n ['aria-owns']: menuId,\n },\n };\n };\n\n const getMenuProps = () => {\n const menuProps: MenuProps = {\n id: menuId,\n ref: menuRef,\n open: isOpen,\n onFocus: handleFocus,\n onBlur: handleBlur,\n onMouseUp: itemIndex => {\n isKeyboard.current = false;\n if (itemIndex > -1) {\n selectOption(options[itemIndex]);\n }\n },\n onMouseMove: itemIndex => {\n isKeyboard.current = false;\n if (itemIndex > -1) {\n setHighlightedIndex(itemIndex);\n }\n },\n };\n if (!hasFilter) {\n menuProps.onKeyDown = activeKeyDownHandler;\n menuProps.onBlur = handleBlur;\n menuProps.onFocus = handleFocus;\n menuProps.nativeAttributes = {\n 'aria-activedescendant': highlightedOptionId,\n };\n }\n return menuProps;\n };\n const getGroupState = (option: OptionGroup) => {\n const totalSelected = option.options.filter(item => !!item.value && __selectedValuesSet.has(item.value)).length;\n const hasSelected = totalSelected > 0;\n const allSelected = totalSelected === option.options.length;\n return {\n selected: hasSelected && allSelected,\n indeterminate: hasSelected && !allSelected,\n };\n };\n\n const getOptionProps = (option: DropdownOption, index: number) => {\n const highlighted = option === highlightedOption;\n const groupState = isGroup(option.option) ? getGroupState(option.option) : undefined;\n const selected = __selectedOptions.indexOf(option) > -1 || !!groupState?.selected;\n const nextOption = options[index + 1]?.option;\n const isNextSelected =\n !!nextOption && isGroup(nextOption)\n ? getGroupState(nextOption).selected\n : __selectedOptions.indexOf(options[index + 1]) > -1;\n\n const optionProps: any = {\n key: index,\n option,\n highlighted,\n selected,\n isNextSelected,\n indeterminate: !!groupState?.indeterminate,\n ['data-mouse-target']: isHighlightable(option) ? index : -1,\n id: getOptionId(menuId, index),\n };\n\n return optionProps;\n };\n\n const prevOpen = usePrevious<boolean>(isOpen);\n useEffect(() => {\n // highlight the first selected option, when opening the Select component\n if (isOpen && !prevOpen && hasSelectedOption) {\n setHighlightedIndex(options.indexOf(__selectedOptions[0]));\n }\n }, [isOpen, __selectedOptions, hasSelectedOption, setHighlightedIndex, options, prevOpen]);\n\n useEffect(() => {\n if (isOpen) {\n // dropdown-fit calculations ensure that the dropdown will fit inside the current\n // viewport, so prevent the browser from trying to scroll it into view (e.g. if\n // scroll-padding-top is set on a parent)\n activeRef.current?.focus({ preventScroll: true });\n }\n }, [isOpen, activeRef]);\n\n useForwardFocus(externalRef, triggerRef as React.RefObject<HTMLElement>);\n const highlightedGroupSelected =\n !!highlightedOption && isGroup(highlightedOption.option) && getGroupState(highlightedOption.option).selected;\n const announceSelected =\n !!highlightedOption && (__selectedOptions.indexOf(highlightedOption) > -1 || highlightedGroupSelected);\n\n return {\n isOpen,\n highlightedOption,\n highlightedIndex,\n getTriggerProps,\n getMenuProps,\n getFilterProps,\n getOptionProps,\n isKeyboard,\n highlightOption,\n selectOption,\n announceSelected,\n };\n}\n"]}
1
+ {"version":3,"file":"use-select.js","sourceRoot":"","sources":["../../../../src/select/utils/use-select.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,OAAO,EAAE,MAAM,uDAAuD,CAAC;AACnH,OAAO,EAAE,SAAS,EAAE,MAAM,EAAoB,MAAM,OAAO,CAAC;AAC5D,OAAO,EAAE,2BAA2B,EAAE,MAAM,mEAAmE,CAAC;AAChH,OAAO,EAAE,YAAY,EAAE,MAAM,6DAA6D,CAAC;AAC3F,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,2DAA2D,CAAC;AAChH,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,sDAAsD,CAAC;AAC3F,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,eAAe,MAAM,oCAAoC,CAAC;AAIjE,OAAO,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAC;AAEhE,OAAO,EAA0B,mBAAmB,EAA6B,MAAM,6BAA6B,CAAC;AACrH,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AA4B3D,MAAM,UAAU,SAAS,CAAC,EAYT;QAXf,eAAe,qBAAA,EACf,oBAAoB,0BAAA,EACpB,OAAO,aAAA,EACP,aAAa,mBAAA,EACb,MAAM,YAAA,EACN,OAAO,aAAA,EACP,WAAW,iBAAA,EACX,QAAQ,cAAA,EACR,aAAa,mBAAA,EACb,iBAAiB,uBAAA,EACjB,4BAA4B,EAA5B,oBAAoB,mBAAG,KAAK,KAAA;IAE5B,IAAM,kBAAkB,GAAG,oBAAoB,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,aAAa,CAAC;IAErF,IAAM,eAAe,GAAG,UAAC,MAAuB,IAAK,OAAA,CAAC,CAAC,MAAM,IAAI,CAAC,oBAAoB,IAAI,MAAM,CAAC,IAAI,KAAK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CAAC,CAAC,CAAC;IAE3F,SAAS,CAAC;;QACR,IAAI,MAAM,EAAE;YACV,iFAAiF;YACjF,+EAA+E;YAC/E,yCAAyC;YACzC,MAAA,SAAS,CAAC,OAAO,0CAAE,KAAK,CAAC,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;SACnD;IACH,CAAC,EAAE,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;IAExB,eAAe,CAAC,WAAW,EAAE,UAA0C,CAAC,CAAC;IACzE,IAAM,wBAAwB,GAC5B,CAAC,CAAC,iBAAiB,IAAI,OAAO,CAAC,iBAAiB,CAAC,MAAM,CAAC,IAAI,aAAa,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC;IAC/G,IAAM,gBAAgB,GACpB,CAAC,CAAC,iBAAiB,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,IAAI,wBAAwB,CAAC,CAAC;IAEzG,OAAO;QACL,MAAM,QAAA;QACN,iBAAiB,mBAAA;QACjB,gBAAgB,kBAAA;QAChB,eAAe,iBAAA;QACf,YAAY,cAAA;QACZ,cAAc,gBAAA;QACd,cAAc,gBAAA;QACd,UAAU,YAAA;QACV,eAAe,iBAAA;QACf,YAAY,cAAA;QACZ,gBAAgB,kBAAA;KACjB,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { RefObject } from 'react';\nimport { DropdownOption, OptionDefinition, OptionGroup } from '../../internal/components/option/interfaces';\nimport { isInteractive, isGroupInteractive, isGroup } from '../../internal/components/option/utils/filter-options';\nimport { useEffect, useRef, MutableRefObject } from 'react';\nimport { createHighlightedOptionHook } from '../../internal/components/options-list/utils/use-highlight-option';\nimport { useOpenState } from '../../internal/components/options-list/utils/use-open-state';\nimport { useMenuKeyboard, useTriggerKeyboard } from '../../internal/components/options-list/utils/use-keyboard';\nimport { useIds, getOptionId } from '../../internal/components/options-list/utils/use-ids';\nimport { connectOptionsByValue } from './connect-options';\nimport useForwardFocus from '../../internal/hooks/forward-focus';\nimport { OptionsListProps } from '../../internal/components/options-list';\nimport { FilterProps } from '../parts/filter';\nimport { ItemProps } from '../parts/item';\nimport { usePrevious } from '../../internal/hooks/use-previous';\nimport { BaseKeyDetail } from '../../internal/events';\nimport { CancelableEventHandler, fireCancelableEvent, NonCancelableEventHandler } from '../../internal/events/index';\nimport { containsOrEqual } from '../../internal/utils/dom';\n\nexport type MenuProps = Omit<OptionsListProps, 'children'> & { ref: React.RefObject<HTMLUListElement> };\nexport type GetOptionProps = (option: DropdownOption, index: number) => ItemProps;\n\ninterface UseSelectProps {\n selectedOptions: ReadonlyArray<OptionDefinition>;\n updateSelectedOption: (option: OptionDefinition) => void;\n options: ReadonlyArray<DropdownOption>;\n filteringType: string;\n keepOpen?: boolean;\n onBlur?: CancelableEventHandler;\n onFocus?: CancelableEventHandler;\n externalRef: React.Ref<any>;\n fireLoadItems: (filteringText: string) => void;\n setFilteringValue: (filteringText: string) => void;\n useInteractiveGroups?: boolean;\n}\n\nexport interface SelectTriggerProps {\n ref: RefObject<HTMLButtonElement>;\n onMouseDown?: (event: CustomEvent) => void;\n onKeyDown?: (event: CustomEvent<BaseKeyDetail>) => void;\n ariaLabelledby?: string;\n onFocus: NonCancelableEventHandler;\n onBlur: NonCancelableEventHandler<{ relatedTarget: Node | null }>;\n}\n\nexport function useSelect({\n selectedOptions,\n updateSelectedOption,\n options,\n filteringType,\n onBlur,\n onFocus,\n externalRef,\n keepOpen,\n fireLoadItems,\n setFilteringValue,\n useInteractiveGroups = false,\n}: UseSelectProps) {\n const interactivityCheck = useInteractiveGroups ? isGroupInteractive : isInteractive;\n\n const isHighlightable = (option?: DropdownOption) => !!option && (useInteractiveGroups || option.type !== 'parent');\n const useHighlightedOption = createHighlightedOptionHook({ isHighlightable: isHighlightable });\n\n const filterRef = useRef<HTMLInputElement>(null);\n const triggerRef = useRef<HTMLButtonElement>(null);\n const menuRef = useRef<HTMLUListElement>(null);\n const hasFilter = filteringType !== 'none';\n const activeRef = hasFilter ? filterRef : menuRef;\n const isKeyboard = useRef<boolean>(false);\n const isSelectingUsingSpace = useRef<boolean>(false);\n const __selectedOptions = connectOptionsByValue(options, selectedOptions);\n const __selectedValuesSet = selectedOptions.reduce((selectedValuesSet: Set<string>, item: OptionDefinition) => {\n if (item.value) {\n selectedValuesSet.add(item.value);\n }\n return selectedValuesSet;\n }, new Set<string>());\n const {\n highlightedOption,\n highlightedIndex,\n moveHighlight,\n resetHighlight,\n setHighlightedIndex,\n highlightOption,\n goHome,\n goEnd,\n } = useHighlightedOption(options);\n\n const { isOpen, openDropdown, closeDropdown, toggleDropdown } = useOpenState({\n onOpen: () => fireLoadItems(''),\n onClose: () => {\n resetHighlight();\n setFilteringValue('');\n },\n });\n\n const focused: MutableRefObject<boolean> = useRef<boolean>(false);\n const handleFocus = () => {\n if (!focused.current) {\n fireCancelableEvent(onFocus, {});\n focused.current = true;\n }\n };\n const handleBlur = ({ detail }: { detail: { relatedTarget: Node | null } }) => {\n const { relatedTarget } = detail;\n const nextFocusedIsTrigger = relatedTarget ? containsOrEqual(triggerRef.current, relatedTarget) : false;\n const nextFocusedInsideDropdown = relatedTarget\n ? containsOrEqual(menuRef.current, relatedTarget) || containsOrEqual(filterRef.current, relatedTarget)\n : false;\n const nextFocusedInsideComponent = nextFocusedIsTrigger || nextFocusedInsideDropdown;\n const focusingOut = focused.current && !nextFocusedInsideComponent;\n\n if (nextFocusedIsTrigger || focusingOut) {\n closeDropdown();\n }\n if (focusingOut) {\n fireCancelableEvent(onBlur, {});\n focused.current = false;\n }\n };\n\n const hasSelectedOption = __selectedOptions.length > 0;\n const { selectedOptionId, menuId } = useIds({ hasSelectedOption });\n const highlightedOptionId = getOptionId(menuId, highlightedIndex);\n\n const selectOption = (option?: DropdownOption) => {\n isSelectingUsingSpace.current = false;\n const optionToSelect = option || highlightedOption;\n if (!optionToSelect || !interactivityCheck(optionToSelect)) {\n return;\n }\n updateSelectedOption(optionToSelect.option);\n if (!keepOpen) {\n triggerRef.current?.focus();\n closeDropdown();\n }\n };\n\n const activeKeyDownHandler = useMenuKeyboard({\n moveHighlight,\n selectOption,\n goHome,\n goEnd,\n closeDropdown: () => {\n triggerRef.current?.focus();\n closeDropdown();\n },\n isKeyboard,\n isSelectingUsingSpace,\n preventNativeSpace: !hasFilter,\n });\n\n const triggerKeyDownHandler = useTriggerKeyboard({ openDropdown, goHome, isKeyboard });\n\n const getTriggerProps = (disabled = false) => {\n const triggerProps: SelectTriggerProps = {\n ref: triggerRef,\n onFocus: handleFocus,\n onBlur: handleBlur,\n };\n if (!disabled) {\n triggerProps.onMouseDown = (event: CustomEvent) => {\n event.preventDefault(); // prevent current focus from blurring as it immediately closes the dropdown\n if (isOpen) {\n triggerRef.current?.focus();\n }\n toggleDropdown();\n };\n triggerProps.onKeyDown = triggerKeyDownHandler;\n }\n if (hasSelectedOption) {\n triggerProps.ariaLabelledby = selectedOptionId;\n }\n return triggerProps;\n };\n\n const getFilterProps = (): Partial<FilterProps> => {\n if (!hasFilter) {\n return {};\n }\n\n return {\n ref: filterRef,\n onKeyDown: activeKeyDownHandler,\n __onBlurWithDetail: handleBlur,\n onFocus: handleFocus,\n onChange: event => {\n setFilteringValue(event.detail.value);\n resetHighlight();\n },\n __onDelayedInput: event => {\n fireLoadItems(event.detail.value);\n },\n __nativeAttributes: {\n 'aria-activedescendant': highlightedOptionId,\n ['aria-owns']: menuId,\n ['aria-controls']: menuId,\n },\n };\n };\n\n const getMenuProps = () => {\n const menuProps: MenuProps = {\n id: menuId,\n ref: menuRef,\n open: isOpen,\n onFocus: handleFocus,\n onBlur: handleBlur,\n onMouseUp: itemIndex => {\n isKeyboard.current = false;\n if (itemIndex > -1) {\n selectOption(options[itemIndex]);\n }\n },\n onMouseMove: itemIndex => {\n isKeyboard.current = false;\n if (itemIndex > -1) {\n setHighlightedIndex(itemIndex);\n }\n },\n };\n if (!hasFilter) {\n menuProps.onKeyDown = activeKeyDownHandler;\n menuProps.onBlur = handleBlur;\n menuProps.onFocus = handleFocus;\n menuProps.nativeAttributes = {\n 'aria-activedescendant': highlightedOptionId,\n };\n }\n return menuProps;\n };\n const getGroupState = (option: OptionGroup) => {\n const totalSelected = option.options.filter(item => !!item.value && __selectedValuesSet.has(item.value)).length;\n const hasSelected = totalSelected > 0;\n const allSelected = totalSelected === option.options.length;\n return {\n selected: hasSelected && allSelected,\n indeterminate: hasSelected && !allSelected,\n };\n };\n\n const getOptionProps = (option: DropdownOption, index: number) => {\n const highlighted = option === highlightedOption;\n const groupState = isGroup(option.option) ? getGroupState(option.option) : undefined;\n const selected = __selectedOptions.indexOf(option) > -1 || !!groupState?.selected;\n const nextOption = options[index + 1]?.option;\n const isNextSelected =\n !!nextOption && isGroup(nextOption)\n ? getGroupState(nextOption).selected\n : __selectedOptions.indexOf(options[index + 1]) > -1;\n\n const optionProps: any = {\n key: index,\n option,\n highlighted,\n selected,\n isNextSelected,\n indeterminate: !!groupState?.indeterminate,\n ['data-mouse-target']: isHighlightable(option) ? index : -1,\n id: getOptionId(menuId, index),\n };\n\n return optionProps;\n };\n\n const prevOpen = usePrevious<boolean>(isOpen);\n useEffect(() => {\n // highlight the first selected option, when opening the Select component\n if (isOpen && !prevOpen && hasSelectedOption) {\n setHighlightedIndex(options.indexOf(__selectedOptions[0]));\n }\n }, [isOpen, __selectedOptions, hasSelectedOption, setHighlightedIndex, options, prevOpen]);\n\n useEffect(() => {\n if (isOpen) {\n // dropdown-fit calculations ensure that the dropdown will fit inside the current\n // viewport, so prevent the browser from trying to scroll it into view (e.g. if\n // scroll-padding-top is set on a parent)\n activeRef.current?.focus({ preventScroll: true });\n }\n }, [isOpen, activeRef]);\n\n useForwardFocus(externalRef, triggerRef as React.RefObject<HTMLElement>);\n const highlightedGroupSelected =\n !!highlightedOption && isGroup(highlightedOption.option) && getGroupState(highlightedOption.option).selected;\n const announceSelected =\n !!highlightedOption && (__selectedOptions.indexOf(highlightedOption) > -1 || highlightedGroupSelected);\n\n return {\n isOpen,\n highlightedOption,\n highlightedIndex,\n getTriggerProps,\n getMenuProps,\n getFilterProps,\n getOptionProps,\n isKeyboard,\n highlightOption,\n selectOption,\n announceSelected,\n };\n}\n"]}
@@ -15,7 +15,7 @@ import { useKeyboardEvents } from './utils/use-keyboard-events';
15
15
  import styles from './styles.css.js';
16
16
  import useBaseComponent from '../internal/hooks/use-base-component';
17
17
  import { useMergeRefs } from '../internal/hooks/use-merge-refs';
18
- import { AppLayoutDomContext } from '../internal/context/app-layout-context';
18
+ import { AppLayoutContext } from '../internal/context/app-layout-context';
19
19
  import { getLimitedValue } from './utils/size-utils';
20
20
  import { Transition } from '../internal/components/transition';
21
21
  import { useEffectOnUpdate } from '../internal/hooks/use-effect-on-update';
@@ -140,7 +140,7 @@ export default function SplitPanel(_a) {
140
140
  return;
141
141
  }
142
142
  }, [lastInteraction]);
143
- var wrappedChildren = (React.createElement(AppLayoutDomContext.RootProvider, { value: {
143
+ var wrappedChildren = (React.createElement(AppLayoutContext.Provider, { value: {
144
144
  stickyOffsetTop: topOffset,
145
145
  stickyOffsetBottom: bottomOffset
146
146
  } }, children));