@cloudscape-design/components-themeable 3.0.973 → 3.0.975
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/lib/internal/manifest.json +1 -1
- package/lib/internal/scss/internal/components/drag-handle-wrapper/motion.scss +53 -161
- package/lib/internal/scss/internal/components/panel-resize-handle/styles.scss +3 -20
- package/lib/internal/scss/internal/generated/custom-css-properties/index.scss +59 -57
- package/lib/internal/template/annotation-context/annotation/styles.css.js +24 -24
- package/lib/internal/template/annotation-context/annotation/styles.scoped.css +32 -32
- package/lib/internal/template/annotation-context/annotation/styles.selectors.js +24 -24
- package/lib/internal/template/annotation-context/index.js +2 -2
- package/lib/internal/template/annotation-context/index.js.map +1 -1
- package/lib/internal/template/app-layout/classic.d.ts.map +1 -1
- package/lib/internal/template/app-layout/classic.js +3 -2
- package/lib/internal/template/app-layout/classic.js.map +1 -1
- package/lib/internal/template/app-layout/drawer/interfaces.d.ts +1 -0
- package/lib/internal/template/app-layout/drawer/interfaces.d.ts.map +1 -1
- package/lib/internal/template/app-layout/drawer/interfaces.js.map +1 -1
- package/lib/internal/template/app-layout/drawer/resizable-drawer.d.ts.map +1 -1
- package/lib/internal/template/app-layout/drawer/resizable-drawer.js +6 -6
- package/lib/internal/template/app-layout/drawer/resizable-drawer.js.map +1 -1
- package/lib/internal/template/app-layout/interfaces.d.ts +1 -0
- package/lib/internal/template/app-layout/interfaces.d.ts.map +1 -1
- package/lib/internal/template/app-layout/interfaces.js.map +1 -1
- package/lib/internal/template/app-layout/notifications/styles.css.js +3 -3
- package/lib/internal/template/app-layout/notifications/styles.scoped.css +7 -7
- package/lib/internal/template/app-layout/notifications/styles.selectors.js +3 -3
- package/lib/internal/template/app-layout/runtime-drawer/index.js +1 -1
- package/lib/internal/template/app-layout/runtime-drawer/index.js.map +1 -1
- package/lib/internal/template/app-layout/runtime-drawer/use-runtime-drawer-context.d.ts +6 -0
- package/lib/internal/template/app-layout/runtime-drawer/use-runtime-drawer-context.d.ts.map +1 -0
- package/lib/internal/template/app-layout/runtime-drawer/use-runtime-drawer-context.js +29 -0
- package/lib/internal/template/app-layout/runtime-drawer/use-runtime-drawer-context.js.map +1 -0
- package/lib/internal/template/app-layout/utils/use-keyboard-events.d.ts +5 -1
- package/lib/internal/template/app-layout/utils/use-keyboard-events.d.ts.map +1 -1
- package/lib/internal/template/app-layout/utils/use-keyboard-events.js +65 -42
- package/lib/internal/template/app-layout/utils/use-keyboard-events.js.map +1 -1
- package/lib/internal/template/app-layout/utils/use-resize.d.ts.map +1 -1
- package/lib/internal/template/app-layout/utils/use-resize.js +3 -3
- package/lib/internal/template/app-layout/utils/use-resize.js.map +1 -1
- package/lib/internal/template/app-layout/visual-refresh/styles.css.js +86 -86
- package/lib/internal/template/app-layout/visual-refresh/styles.scoped.css +258 -258
- package/lib/internal/template/app-layout/visual-refresh/styles.selectors.js +86 -86
- package/lib/internal/template/app-layout/visual-refresh-toolbar/drawer/global-drawer.d.ts.map +1 -1
- package/lib/internal/template/app-layout/visual-refresh-toolbar/drawer/global-drawer.js +2 -2
- package/lib/internal/template/app-layout/visual-refresh-toolbar/drawer/global-drawer.js.map +1 -1
- package/lib/internal/template/app-layout/visual-refresh-toolbar/drawer/local-drawer.d.ts.map +1 -1
- package/lib/internal/template/app-layout/visual-refresh-toolbar/drawer/local-drawer.js +2 -2
- package/lib/internal/template/app-layout/visual-refresh-toolbar/drawer/local-drawer.js.map +1 -1
- package/lib/internal/template/app-layout/visual-refresh-toolbar/drawer/styles.css.js +10 -10
- package/lib/internal/template/app-layout/visual-refresh-toolbar/drawer/styles.scoped.css +12 -12
- package/lib/internal/template/app-layout/visual-refresh-toolbar/drawer/styles.selectors.js +10 -10
- package/lib/internal/template/app-layout/visual-refresh-toolbar/drawer/use-resize.d.ts +1 -0
- package/lib/internal/template/app-layout/visual-refresh-toolbar/drawer/use-resize.d.ts.map +1 -1
- package/lib/internal/template/app-layout/visual-refresh-toolbar/drawer/use-resize.js +2 -2
- package/lib/internal/template/app-layout/visual-refresh-toolbar/drawer/use-resize.js.map +1 -1
- package/lib/internal/template/app-layout/visual-refresh-toolbar/navigation/styles.css.js +4 -4
- package/lib/internal/template/app-layout/visual-refresh-toolbar/navigation/styles.scoped.css +7 -7
- package/lib/internal/template/app-layout/visual-refresh-toolbar/navigation/styles.selectors.js +4 -4
- package/lib/internal/template/app-layout/visual-refresh-toolbar/skeleton/styles.css.js +19 -19
- package/lib/internal/template/app-layout/visual-refresh-toolbar/skeleton/styles.scoped.css +43 -43
- package/lib/internal/template/app-layout/visual-refresh-toolbar/skeleton/styles.selectors.js +19 -19
- package/lib/internal/template/content-layout/styles.css.js +14 -14
- package/lib/internal/template/content-layout/styles.scoped.css +27 -27
- package/lib/internal/template/content-layout/styles.selectors.js +14 -14
- package/lib/internal/template/date-range-picker/calendar/grids/index.js.map +1 -1
- package/lib/internal/template/date-range-picker/calendar/grids/interfaces.d.ts +3 -4
- package/lib/internal/template/date-range-picker/calendar/grids/interfaces.d.ts.map +1 -1
- package/lib/internal/template/date-range-picker/calendar/grids/interfaces.js.map +1 -1
- package/lib/internal/template/date-range-picker/calendar/header/header-button.d.ts +0 -2
- package/lib/internal/template/date-range-picker/calendar/header/header-button.d.ts.map +1 -1
- package/lib/internal/template/date-range-picker/calendar/header/header-button.js.map +1 -1
- package/lib/internal/template/date-range-picker/calendar/header/index.d.ts +2 -3
- package/lib/internal/template/date-range-picker/calendar/header/index.d.ts.map +1 -1
- package/lib/internal/template/date-range-picker/calendar/header/index.js.map +1 -1
- package/lib/internal/template/date-range-picker/calendar/index.d.ts +2 -2
- package/lib/internal/template/date-range-picker/calendar/index.d.ts.map +1 -1
- package/lib/internal/template/date-range-picker/calendar/index.js.map +1 -1
- package/lib/internal/template/date-range-picker/calendar/range-inputs.d.ts +3 -3
- package/lib/internal/template/date-range-picker/calendar/range-inputs.d.ts.map +1 -1
- package/lib/internal/template/date-range-picker/calendar/range-inputs.js.map +1 -1
- package/lib/internal/template/date-range-picker/dropdown.d.ts +2 -2
- package/lib/internal/template/date-range-picker/dropdown.d.ts.map +1 -1
- package/lib/internal/template/date-range-picker/dropdown.js.map +1 -1
- package/lib/internal/template/date-range-picker/interfaces.d.ts +2 -7
- package/lib/internal/template/date-range-picker/interfaces.d.ts.map +1 -1
- package/lib/internal/template/date-range-picker/interfaces.js.map +1 -1
- package/lib/internal/template/date-range-picker/relative-range/index.d.ts +2 -2
- package/lib/internal/template/date-range-picker/relative-range/index.d.ts.map +1 -1
- package/lib/internal/template/date-range-picker/relative-range/index.js.map +1 -1
- package/lib/internal/template/flashbar/styles.css.js +50 -50
- package/lib/internal/template/flashbar/styles.scoped.css +166 -166
- package/lib/internal/template/flashbar/styles.selectors.js +50 -50
- package/lib/internal/template/i18n/messages/all.all.js +1 -1
- package/lib/internal/template/i18n/messages/all.all.json +1 -1
- package/lib/internal/template/i18n/messages/all.ar.js +1 -1
- package/lib/internal/template/i18n/messages/all.ar.json +1 -1
- package/lib/internal/template/i18n/messages/all.de.js +1 -1
- package/lib/internal/template/i18n/messages/all.de.json +1 -1
- package/lib/internal/template/i18n/messages/all.en-GB.js +1 -1
- package/lib/internal/template/i18n/messages/all.en-GB.json +1 -1
- package/lib/internal/template/i18n/messages/all.en.js +1 -1
- package/lib/internal/template/i18n/messages/all.en.json +1 -1
- package/lib/internal/template/i18n/messages/all.es.js +1 -1
- package/lib/internal/template/i18n/messages/all.es.json +1 -1
- package/lib/internal/template/i18n/messages/all.fr.js +1 -1
- package/lib/internal/template/i18n/messages/all.fr.json +1 -1
- package/lib/internal/template/i18n/messages/all.id.js +1 -1
- package/lib/internal/template/i18n/messages/all.id.json +1 -1
- package/lib/internal/template/i18n/messages/all.it.js +1 -1
- package/lib/internal/template/i18n/messages/all.it.json +1 -1
- package/lib/internal/template/i18n/messages/all.ja.js +1 -1
- package/lib/internal/template/i18n/messages/all.ja.json +1 -1
- package/lib/internal/template/i18n/messages/all.ko.js +1 -1
- package/lib/internal/template/i18n/messages/all.ko.json +1 -1
- package/lib/internal/template/i18n/messages/all.pt-BR.js +1 -1
- package/lib/internal/template/i18n/messages/all.pt-BR.json +1 -1
- package/lib/internal/template/i18n/messages/all.tr.js +1 -1
- package/lib/internal/template/i18n/messages/all.tr.json +1 -1
- package/lib/internal/template/i18n/messages/all.zh-CN.js +1 -1
- package/lib/internal/template/i18n/messages/all.zh-CN.json +1 -1
- package/lib/internal/template/i18n/messages/all.zh-TW.js +1 -1
- package/lib/internal/template/i18n/messages/all.zh-TW.json +1 -1
- package/lib/internal/template/i18n/messages-types.d.ts +1 -0
- package/lib/internal/template/i18n/messages-types.d.ts.map +1 -1
- package/lib/internal/template/i18n/messages-types.js.map +1 -1
- package/lib/internal/template/i18n/provider.js +2 -2
- package/lib/internal/template/i18n/provider.js.map +1 -1
- package/lib/internal/template/internal/components/drag-handle/button.d.ts +1 -1
- package/lib/internal/template/internal/components/drag-handle/button.d.ts.map +1 -1
- package/lib/internal/template/internal/components/drag-handle/button.js +2 -3
- package/lib/internal/template/internal/components/drag-handle/button.js.map +1 -1
- package/lib/internal/template/internal/components/drag-handle/index.d.ts +1 -1
- package/lib/internal/template/internal/components/drag-handle/index.d.ts.map +1 -1
- package/lib/internal/template/internal/components/drag-handle/index.js.map +1 -1
- package/lib/internal/template/internal/components/drag-handle/interfaces.d.ts +0 -3
- package/lib/internal/template/internal/components/drag-handle/interfaces.d.ts.map +1 -1
- package/lib/internal/template/internal/components/drag-handle/interfaces.js.map +1 -1
- package/lib/internal/template/internal/components/drag-handle-wrapper/index.d.ts.map +1 -1
- package/lib/internal/template/internal/components/drag-handle-wrapper/index.js +8 -6
- package/lib/internal/template/internal/components/drag-handle-wrapper/index.js.map +1 -1
- package/lib/internal/template/internal/components/drag-handle-wrapper/styles.css.js +21 -27
- package/lib/internal/template/internal/components/drag-handle-wrapper/styles.scoped.css +58 -235
- package/lib/internal/template/internal/components/drag-handle-wrapper/styles.selectors.js +21 -27
- package/lib/internal/template/internal/components/dropdown/styles.css.js +20 -20
- package/lib/internal/template/internal/components/dropdown/styles.scoped.css +38 -38
- package/lib/internal/template/internal/components/dropdown/styles.selectors.js +20 -20
- package/lib/internal/template/internal/components/panel-resize-handle/index.d.ts +3 -0
- package/lib/internal/template/internal/components/panel-resize-handle/index.d.ts.map +1 -1
- package/lib/internal/template/internal/components/panel-resize-handle/index.js +11 -4
- package/lib/internal/template/internal/components/panel-resize-handle/index.js.map +1 -1
- package/lib/internal/template/internal/components/panel-resize-handle/styles.css.js +2 -5
- package/lib/internal/template/internal/components/panel-resize-handle/styles.scoped.css +9 -26
- package/lib/internal/template/internal/components/panel-resize-handle/styles.selectors.js +2 -5
- package/lib/internal/template/internal/environment.js +1 -1
- package/lib/internal/template/internal/environment.json +1 -1
- package/lib/internal/template/internal/generated/custom-css-properties/index.d.ts +2 -0
- package/lib/internal/template/internal/generated/custom-css-properties/index.d.ts.map +1 -1
- package/lib/internal/template/internal/generated/custom-css-properties/index.js +59 -57
- package/lib/internal/template/internal/generated/custom-css-properties/index.js.map +1 -1
- package/lib/internal/template/internal/hooks/use-base-component/index.d.ts.map +1 -1
- package/lib/internal/template/internal/hooks/use-base-component/index.js +8 -5
- package/lib/internal/template/internal/hooks/use-base-component/index.js.map +1 -1
- package/lib/internal/template/internal/plugins/controllers/alert-flash-content.d.ts +2 -0
- package/lib/internal/template/internal/plugins/controllers/alert-flash-content.d.ts.map +1 -1
- package/lib/internal/template/internal/plugins/controllers/alert-flash-content.js.map +1 -1
- package/lib/internal/template/internal/plugins/controllers/drawers.d.ts +7 -0
- package/lib/internal/template/internal/plugins/controllers/drawers.d.ts.map +1 -1
- package/lib/internal/template/internal/plugins/controllers/drawers.js +17 -1
- package/lib/internal/template/internal/plugins/controllers/drawers.js.map +1 -1
- package/lib/internal/template/internal/plugins/helpers/use-discovered-content.d.ts +7 -7
- package/lib/internal/template/internal/plugins/helpers/use-discovered-content.d.ts.map +1 -1
- package/lib/internal/template/internal/plugins/helpers/use-discovered-content.js +5 -2
- package/lib/internal/template/internal/plugins/helpers/use-discovered-content.js.map +1 -1
- package/lib/internal/template/popover/container.d.ts.map +1 -1
- package/lib/internal/template/popover/container.js +20 -7
- package/lib/internal/template/popover/container.js.map +1 -1
- package/lib/internal/template/slider/styles.css.js +26 -26
- package/lib/internal/template/slider/styles.scoped.css +86 -86
- package/lib/internal/template/slider/styles.selectors.js +26 -26
- package/lib/internal/template/spinner/styles.css.js +13 -13
- package/lib/internal/template/spinner/styles.scoped.css +39 -39
- package/lib/internal/template/spinner/styles.selectors.js +13 -13
- package/lib/internal/template/split-panel/implementation.d.ts.map +1 -1
- package/lib/internal/template/split-panel/implementation.js +3 -3
- package/lib/internal/template/split-panel/implementation.js.map +1 -1
- package/lib/internal/template/split-panel/index.d.ts.map +1 -1
- package/lib/internal/template/split-panel/index.js +1 -1
- package/lib/internal/template/split-panel/index.js.map +1 -1
- package/lib/internal/template/split-panel/interfaces.d.ts +1 -0
- package/lib/internal/template/split-panel/interfaces.d.ts.map +1 -1
- package/lib/internal/template/split-panel/interfaces.js.map +1 -1
- package/lib/internal/template/table/body-cell/inline-editor.d.ts.map +1 -1
- package/lib/internal/template/table/body-cell/inline-editor.js +2 -1
- package/lib/internal/template/table/body-cell/inline-editor.js.map +1 -1
- package/package.json +1 -1
- package/lib/internal/template/internal/components/panel-resize-handle/icon.d.ts +0 -5
- package/lib/internal/template/internal/components/panel-resize-handle/icon.d.ts.map +0 -1
- package/lib/internal/template/internal/components/panel-resize-handle/icon.js +0 -9
- package/lib/internal/template/internal/components/panel-resize-handle/icon.js.map +0 -1
- package/lib/internal/template/internal/hooks/use-telemetry/index.d.ts +0 -3
- package/lib/internal/template/internal/hooks/use-telemetry/index.d.ts.map +0 -1
- package/lib/internal/template/internal/hooks/use-telemetry/index.js +0 -12
- package/lib/internal/template/internal/hooks/use-telemetry/index.js.map +0 -1
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
import { useComponentMetadata, useFocusVisible, } from '@cloudscape-design/component-toolkit/internal';
|
|
2
|
-
import { PACKAGE_VERSION } from '../../environment';
|
|
3
|
-
import {
|
|
1
|
+
import { useComponentMetadata, useComponentMetrics, useFocusVisible, } from '@cloudscape-design/component-toolkit/internal';
|
|
2
|
+
import { PACKAGE_SOURCE, PACKAGE_VERSION, THEME } from '../../environment';
|
|
3
|
+
import { getVisualTheme } from '../../utils/get-visual-theme';
|
|
4
|
+
import { useVisualRefresh } from '../use-visual-mode';
|
|
4
5
|
/**
|
|
5
6
|
* This hook is used for components which are exported to customers. The returned __internalRootRef needs to be
|
|
6
7
|
* attached to the (internal) component's root DOM node. The hook takes care of attaching the metadata to this
|
|
7
8
|
* root DOM node and emits the telemetry for this component.
|
|
8
9
|
*/
|
|
9
10
|
export default function useBaseComponent(componentName, config, analyticsMetadata) {
|
|
10
|
-
|
|
11
|
+
const isVisualRefresh = useVisualRefresh();
|
|
12
|
+
const theme = getVisualTheme(THEME, isVisualRefresh);
|
|
13
|
+
useComponentMetrics(componentName, { packageSource: PACKAGE_SOURCE, packageVersion: PACKAGE_VERSION, theme }, config);
|
|
11
14
|
useFocusVisible();
|
|
12
|
-
const elementRef = useComponentMetadata(componentName, PACKAGE_VERSION,
|
|
15
|
+
const elementRef = useComponentMetadata(componentName, { packageName: PACKAGE_SOURCE, version: PACKAGE_VERSION, theme }, analyticsMetadata);
|
|
13
16
|
return { __internalRootRef: elementRef };
|
|
14
17
|
}
|
|
15
18
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/hooks/use-base-component/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAEL,oBAAoB,EACpB,eAAe,GAChB,MAAM,+CAA+C,CAAC;AAGvD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/hooks/use-base-component/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAEL,oBAAoB,EACpB,mBAAmB,EACnB,eAAe,GAChB,MAAM,+CAA+C,CAAC;AAGvD,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAMtD;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,gBAAgB,CACtC,aAAqB,EACrB,MAA+B,EAC/B,iBAAqC;IAErC,MAAM,eAAe,GAAG,gBAAgB,EAAE,CAAC;IAC3C,MAAM,KAAK,GAAG,cAAc,CAAC,KAAK,EAAE,eAAe,CAAC,CAAC;IACrD,mBAAmB,CAAC,aAAa,EAAE,EAAE,aAAa,EAAE,cAAc,EAAE,cAAc,EAAE,eAAe,EAAE,KAAK,EAAE,EAAE,MAAM,CAAC,CAAC;IACtH,eAAe,EAAE,CAAC;IAClB,MAAM,UAAU,GAAG,oBAAoB,CACrC,aAAa,EACb,EAAE,WAAW,EAAE,cAAc,EAAE,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,EAChE,iBAAwB,CACzB,CAAC;IACF,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,CAAC;AAC3C,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { MutableRefObject } from 'react';\n\nimport {\n ComponentConfiguration,\n useComponentMetadata,\n useComponentMetrics,\n useFocusVisible,\n} from '@cloudscape-design/component-toolkit/internal';\n\nimport { AnalyticsMetadata } from '../../analytics/interfaces';\nimport { PACKAGE_SOURCE, PACKAGE_VERSION, THEME } from '../../environment';\nimport { getVisualTheme } from '../../utils/get-visual-theme';\nimport { useVisualRefresh } from '../use-visual-mode';\n\nexport interface InternalBaseComponentProps<T = any> {\n __internalRootRef?: MutableRefObject<T | null> | null;\n}\n\n/**\n * This hook is used for components which are exported to customers. The returned __internalRootRef needs to be\n * attached to the (internal) component's root DOM node. The hook takes care of attaching the metadata to this\n * root DOM node and emits the telemetry for this component.\n */\nexport default function useBaseComponent<T = any>(\n componentName: string,\n config?: ComponentConfiguration,\n analyticsMetadata?: AnalyticsMetadata\n) {\n const isVisualRefresh = useVisualRefresh();\n const theme = getVisualTheme(THEME, isVisualRefresh);\n useComponentMetrics(componentName, { packageSource: PACKAGE_SOURCE, packageVersion: PACKAGE_VERSION, theme }, config);\n useFocusVisible();\n const elementRef = useComponentMetadata<T>(\n componentName,\n { packageName: PACKAGE_SOURCE, version: PACKAGE_VERSION, theme },\n analyticsMetadata as any\n );\n return { __internalRootRef: elementRef };\n}\n"]}
|
|
@@ -3,11 +3,13 @@ interface RefShim<T> {
|
|
|
3
3
|
current: T | null;
|
|
4
4
|
}
|
|
5
5
|
interface AlertFlashContentContext {
|
|
6
|
+
instanceId: string;
|
|
6
7
|
type: string;
|
|
7
8
|
headerRef: RefShim<HTMLElement>;
|
|
8
9
|
contentRef: RefShim<HTMLElement>;
|
|
9
10
|
}
|
|
10
11
|
interface AlertFlashContentInitialContext {
|
|
12
|
+
instanceId: string;
|
|
11
13
|
type: string;
|
|
12
14
|
header?: ReactNode;
|
|
13
15
|
content?: ReactNode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alert-flash-content.d.ts","sourceRoot":"","sources":["../../../../../src/internal/plugins/controllers/alert-flash-content.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAMlC,UAAU,OAAO,CAAC,CAAC;IACjB,OAAO,EAAE,CAAC,GAAG,IAAI,CAAC;CACnB;AAED,UAAU,wBAAwB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;IAChC,UAAU,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;CAClC;AAED,UAAU,+BAA+B;IACvC,IAAI,EAAE,MAAM,CAAC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ED,qBAAa,2BAA2B;;IAgBtC,uBAAuB,YAAa,uBAAuB,UAYzD;IAEF,uBAAuB,aAErB;IAEF,YAAY,YAAa,+BAA+B,KAAG,OAAO,CAKhE;IAEF,mBAAmB,aAAc,qCAAqC,gBAapE;IAEF,aAAa,CAAC,GAAG,GAAE,OAAO,CAAC,0BAA0B,CAAM,GAAG,0BAA0B;IAKxF,eAAe,CAAC,WAAW,GAAE,OAAO,CAAC,4BAA4B,CAAM,GAAG,4BAA4B;CAMvG"}
|
|
1
|
+
{"version":3,"file":"alert-flash-content.d.ts","sourceRoot":"","sources":["../../../../../src/internal/plugins/controllers/alert-flash-content.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAMlC,UAAU,OAAO,CAAC,CAAC;IACjB,OAAO,EAAE,CAAC,GAAG,IAAI,CAAC;CACnB;AAED,UAAU,wBAAwB;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;IAChC,UAAU,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;CAClC;AAED,UAAU,+BAA+B;IACvC,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,OAAO,CAAC,EAAE,SAAS,CAAC;CACrB;AAED,MAAM,MAAM,eAAe,GAAG,UAAU,GAAG,QAAQ,GAAG,UAAU,CAAC;AAEjE,UAAU,cAAc;IACtB,UAAU,IAAI,IAAI,CAAC;IACnB,aAAa,IAAI,IAAI,CAAC;IACtB,aAAa,CAAC,QAAQ,EAAE,CAAC,SAAS,EAAE,WAAW,KAAK,IAAI,GAAG,IAAI,CAAC;IAChE,WAAW,IAAI,IAAI,CAAC;IACpB,cAAc,IAAI,IAAI,CAAC;IACvB,cAAc,CAAC,QAAQ,EAAE,CAAC,SAAS,EAAE,WAAW,KAAK,IAAI,GAAG,IAAI,CAAC;CAClE;AAED,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,OAAO,EAAE,CAAC,UAAU,EAAE;QAAE,0BAA0B,EAAE,WAAW,CAAC;QAAC,2BAA2B,EAAE,WAAW,CAAA;KAAE,KAAK,IAAI,CAAC;CACtH;AAED,MAAM,WAAW,uBAAuB;IACtC,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,CAAC,OAAO,EAAE,wBAAwB,EAAE,cAAc,EAAE,cAAc,KAAK,uBAAuB,CAAC;IAC5G,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,+BAA+B,KAAK,OAAO,CAAC;CACtE;AAED,KAAK,qCAAqC,GAAG,CAAC,QAAQ,EAAE,uBAAuB,KAAK,MAAM,IAAI,CAAC;AAE/F,MAAM,WAAW,0BAA0B;IACzC,uBAAuB,CAAC,MAAM,EAAE,uBAAuB,GAAG,IAAI,CAAC;CAChE;AAED,MAAM,WAAW,4BAA4B;IAC3C,uBAAuB,IAAI,IAAI,CAAC;IAChC,mBAAmB,CAAC,QAAQ,EAAE,qCAAqC,GAAG,MAAM,IAAI,CAAC;IACjF,YAAY,CAAC,OAAO,EAAE,+BAA+B,GAAG,OAAO,CAAC;CACjE;AAED,qBAAa,2BAA2B;;IAgBtC,uBAAuB,YAAa,uBAAuB,UAYzD;IAEF,uBAAuB,aAErB;IAEF,YAAY,YAAa,+BAA+B,KAAG,OAAO,CAKhE;IAEF,mBAAmB,aAAc,qCAAqC,gBAapE;IAEF,aAAa,CAAC,GAAG,GAAE,OAAO,CAAC,0BAA0B,CAAM,GAAG,0BAA0B;IAKxF,eAAe,CAAC,WAAW,GAAE,OAAO,CAAC,4BAA4B,CAAM,GAAG,4BAA4B;CAMvG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alert-flash-content.js","sourceRoot":"","sources":["../../../../../src/internal/plugins/controllers/alert-flash-content.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;;;AAItC,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"alert-flash-content.js","sourceRoot":"","sources":["../../../../../src/internal/plugins/controllers/alert-flash-content.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;;;AAItC,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAuD7D,MAAM,OAAO,2BAA2B;IAAxC;QACE,iDAA2D,EAAE,EAAC;QAC9D,gDAAY,IAAI,GAAG,EAAqD,EAAC;QACzE,wDAAoC;QAEpC,sDAAkB,QAAQ,CACxB,GAAG,EAAE,CACH,uBAAA,IAAI,8CAAW,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;YACjC,IAAI,uBAAA,IAAI,6CAAU,EAAE;gBAClB,MAAM,OAAO,GAAG,QAAQ,CAAC,uBAAA,IAAI,6CAAU,CAAC,CAAC;gBACzC,uBAAA,IAAI,6CAAU,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;aACvC;QACH,CAAC,CAAC,EACJ,CAAC,CACF,EAAC;QAEF,4BAAuB,GAAG,CAAC,OAAgC,EAAE,EAAE;YAC7D,IAAI,uBAAA,IAAI,6CAAU,EAAE;gBAClB,uBAAuB,CACrB,qBAAqB,EACrB,gFAAgF,uBAAA,IAAI,6CAAU,CAAC,EAAE,uBAAuB,CACzH,CAAC;gBACF,OAAO;aACR;YACD,uBAAA,IAAI,yCAAa,OAAO,MAAA,CAAC;YAEzB,wFAAwF;YACxF,uBAAA,IAAI,mDAAgB,MAApB,IAAI,CAAkB,CAAC;QACzB,CAAC,CAAC;QAEF,4BAAuB,GAAG,GAAG,EAAE;YAC7B,uBAAA,IAAI,yCAAa,SAAS,MAAA,CAAC;QAC7B,CAAC,CA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,EAAC;QACrE,MAAA,WAAW,CAAC,mBAAmB,oCAA/B,WAAW,CAAC,mBAAmB,GAAK,IAAI,CAAC,mBAAmB,EAAC;QAC7D,MAAA,WAAW,CAAC,YAAY,oCAAxB,WAAW,CAAC,YAAY,GAAK,IAAI,CAAC,YAAY,EAAC;QAC/C,OAAO,WAA2C,CAAC;IACrD,CAAC;CACF","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { ReactNode } from 'react';\n\nimport debounce from '../../debounce';\nimport { reportRuntimeApiWarning } from '../helpers/metrics';\n\n// this code should not depend on React typings, because it is portable between major versions\ninterface RefShim<T> {\n current: T | null;\n}\n\ninterface AlertFlashContentContext {\n instanceId: string;\n type: string;\n headerRef: RefShim<HTMLElement>;\n contentRef: RefShim<HTMLElement>;\n}\n\ninterface AlertFlashContentInitialContext {\n instanceId: string;\n type: string;\n header?: ReactNode;\n content?: ReactNode;\n}\n\nexport type ReplacementType = 'original' | 'remove' | 'replaced';\n\ninterface ReplacementApi {\n hideHeader(): void;\n restoreHeader(): void;\n replaceHeader(replacer: (container: HTMLElement) => void): void;\n hideContent(): void;\n restoreContent(): void;\n replaceContent(replacer: (container: HTMLElement) => void): void;\n}\n\nexport interface AlertFlashContentResult {\n update: () => void;\n unmount: (containers: { replacementHeaderContainer: HTMLElement; replacementContentContainer: HTMLElement }) => void;\n}\n\nexport interface AlertFlashContentConfig {\n id: string;\n runReplacer: (context: AlertFlashContentContext, replacementApi: ReplacementApi) => AlertFlashContentResult;\n initialCheck?: (context: AlertFlashContentInitialContext) => boolean;\n}\n\ntype AlertFlashContentRegistrationListener = (provider: AlertFlashContentConfig) => () => void;\n\nexport interface AlertFlashContentApiPublic {\n registerContentReplacer(config: AlertFlashContentConfig): void;\n}\n\nexport interface AlertFlashContentApiInternal {\n clearRegisteredReplacer(): void;\n onContentRegistered(listener: AlertFlashContentRegistrationListener): () => void;\n initialCheck(context: AlertFlashContentInitialContext): boolean;\n}\n\nexport class AlertFlashContentController {\n #listeners: Array<AlertFlashContentRegistrationListener> = [];\n #cleanups = new Map<AlertFlashContentRegistrationListener, () => void>();\n #provider?: AlertFlashContentConfig;\n\n #scheduleUpdate = debounce(\n () =>\n this.#listeners.forEach(listener => {\n if (this.#provider) {\n const cleanup = listener(this.#provider);\n this.#cleanups.set(listener, cleanup);\n }\n }),\n 0\n );\n\n registerContentReplacer = (content: AlertFlashContentConfig) => {\n if (this.#provider) {\n reportRuntimeApiWarning(\n 'alert-flash-content',\n `Cannot call \\`registerContentReplacer\\` with new provider: provider with id \"${this.#provider.id}\" already registered.`\n );\n return;\n }\n this.#provider = content;\n\n // Notify existing components if registration happens after the components are rendered.\n this.#scheduleUpdate();\n };\n\n clearRegisteredReplacer = () => {\n this.#provider = undefined;\n };\n\n initialCheck = (context: AlertFlashContentInitialContext): boolean => {\n if (this.#provider?.initialCheck) {\n return this.#provider.initialCheck(context);\n }\n return false;\n };\n\n onContentRegistered = (listener: AlertFlashContentRegistrationListener) => {\n if (this.#provider) {\n const cleanup = listener(this.#provider);\n this.#listeners.push(listener);\n this.#cleanups.set(listener, cleanup);\n } else {\n this.#listeners.push(listener);\n }\n return () => {\n this.#cleanups.get(listener)?.();\n this.#listeners = this.#listeners.filter(item => item !== listener);\n this.#cleanups.delete(listener);\n };\n };\n\n installPublic(api: Partial<AlertFlashContentApiPublic> = {}): AlertFlashContentApiPublic {\n api.registerContentReplacer ??= this.registerContentReplacer;\n return api as AlertFlashContentApiPublic;\n }\n\n installInternal(internalApi: Partial<AlertFlashContentApiInternal> = {}): AlertFlashContentApiInternal {\n internalApi.clearRegisteredReplacer ??= this.clearRegisteredReplacer;\n internalApi.onContentRegistered ??= this.onContentRegistered;\n internalApi.initialCheck ??= this.initialCheck;\n return internalApi as AlertFlashContentApiInternal;\n }\n}\n"]}
|
|
@@ -15,6 +15,7 @@ export interface DrawerConfig {
|
|
|
15
15
|
closeButton?: string;
|
|
16
16
|
triggerButton?: string;
|
|
17
17
|
resizeHandle?: string;
|
|
18
|
+
resizeHandleTooltipText?: string;
|
|
18
19
|
};
|
|
19
20
|
badge?: boolean;
|
|
20
21
|
resizable?: boolean;
|
|
@@ -38,6 +39,7 @@ export type UpdateDrawerConfig = {
|
|
|
38
39
|
id: DrawerConfig['id'];
|
|
39
40
|
} & Partial<Pick<DrawerConfig, (typeof updatableProperties)[number]>>;
|
|
40
41
|
type DrawersRegistrationListener = (drawers: Array<DrawerConfig>) => void;
|
|
42
|
+
type DrawersUpdateListener = (drawers: Array<DrawerConfig>) => void;
|
|
41
43
|
export type DrawersToggledListener = (drawerId: string, params?: OpenCloseDrawerParams) => void;
|
|
42
44
|
interface OpenCloseDrawerParams {
|
|
43
45
|
initiatedByUserAction: boolean;
|
|
@@ -53,12 +55,15 @@ export interface DrawersApiInternal {
|
|
|
53
55
|
onDrawersRegistered(listener: DrawersRegistrationListener): () => void;
|
|
54
56
|
onDrawerOpened(listener: DrawersToggledListener): () => void;
|
|
55
57
|
onDrawerClosed(listener: DrawersToggledListener): () => void;
|
|
58
|
+
onDrawersUpdated(listener: DrawersUpdateListener): void;
|
|
59
|
+
getDrawersState(): Array<DrawerConfig>;
|
|
56
60
|
}
|
|
57
61
|
export declare class DrawersController {
|
|
58
62
|
private drawers;
|
|
59
63
|
private drawersRegistrationListener;
|
|
60
64
|
private drawerOpenedListener;
|
|
61
65
|
private drawerClosedListener;
|
|
66
|
+
private drawersUpdateListeners;
|
|
62
67
|
scheduleUpdate: () => void;
|
|
63
68
|
registerDrawer: (config: DrawerConfig) => void;
|
|
64
69
|
updateDrawer: ({ id: drawerId, ...rest }: UpdateDrawerConfig) => void;
|
|
@@ -68,6 +73,8 @@ export declare class DrawersController {
|
|
|
68
73
|
onDrawerClosed: (listener: DrawersToggledListener) => () => void;
|
|
69
74
|
openDrawer: (drawerId: string, params?: OpenCloseDrawerParams) => void;
|
|
70
75
|
closeDrawer: (drawerId: string, params?: OpenCloseDrawerParams) => void;
|
|
76
|
+
onDrawersUpdated: (listener: DrawersUpdateListener) => () => void;
|
|
77
|
+
getDrawersState: () => DrawerConfig[];
|
|
71
78
|
installPublic(api?: Partial<DrawersApiPublic>): DrawersApiPublic;
|
|
72
79
|
installInternal(internalApi?: Partial<DrawersApiInternal>): DrawersApiInternal;
|
|
73
80
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"drawers.d.ts","sourceRoot":"","sources":["../../../../../src/internal/plugins/controllers/drawers.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AAGzD,KAAK,sBAAsB,GAAG,CAAC,QAAQ,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,KAAK,IAAI,CAAC;AAE/E,UAAU,mBAAmB;IAC3B,kBAAkB,EAAE,sBAAsB,CAAC;CAC5C;AAED,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,OAAO,CAAC;IAChB,qBAAqB,CAAC,EAAE,OAAO,CAAC;CACjC;AAED,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;IAC1B,UAAU,EAAE;QACV,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,YAAY,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"drawers.d.ts","sourceRoot":"","sources":["../../../../../src/internal/plugins/controllers/drawers.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AAGzD,KAAK,sBAAsB,GAAG,CAAC,QAAQ,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,KAAK,IAAI,CAAC;AAE/E,UAAU,mBAAmB;IAC3B,kBAAkB,EAAE,sBAAsB,CAAC;CAC5C;AAED,MAAM,WA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CAAoC;IAElE,cAAc,aAKR;IAEN,cAAc,WAAY,YAAY,UAMpC;IAEF,YAAY,8BAA+B,kBAAkB,UAgB3D;IAEF,mBAAmB,aAAc,2BAA2B,gBAa1D;IAEF,sBAAsB,aAEpB;IAEF,cAAc,aAAc,sBAAsB,gBAahD;IAEF,cAAc,aAAc,sBAAsB,gBAahD;IAEF,UAAU,aAAc,MAAM,WAAW,qBAAqB,UAE5D;IAEF,WAAW,aAAc,MAAM,WAAW,qBAAqB,UAE7D;IAEF,gBAAgB,aAAc,qBAAqB,gBAMjD;IAEF,eAAe,uBAEb;IAEF,aAAa,CAAC,GAAG,GAAE,OAAO,CAAC,gBAAgB,CAAM,GAAG,gBAAgB;IAQpE,eAAe,CAAC,WAAW,GAAE,OAAO,CAAC,kBAAkB,CAAM,GAAG,kBAAkB;CASnF"}
|
|
@@ -17,9 +17,13 @@ export class DrawersController {
|
|
|
17
17
|
this.drawersRegistrationListener = null;
|
|
18
18
|
this.drawerOpenedListener = null;
|
|
19
19
|
this.drawerClosedListener = null;
|
|
20
|
+
this.drawersUpdateListeners = [];
|
|
20
21
|
this.scheduleUpdate = debounce(() => {
|
|
21
22
|
var _a;
|
|
22
23
|
(_a = this.drawersRegistrationListener) === null || _a === void 0 ? void 0 : _a.call(this, this.drawers);
|
|
24
|
+
this.drawersUpdateListeners.forEach(drawersUpdateListeners => {
|
|
25
|
+
drawersUpdateListeners === null || drawersUpdateListeners === void 0 ? void 0 : drawersUpdateListeners(this.drawers);
|
|
26
|
+
});
|
|
23
27
|
}, 0);
|
|
24
28
|
this.registerDrawer = (config) => {
|
|
25
29
|
if (this.drawers.find(drawer => drawer.id === config.id)) {
|
|
@@ -55,6 +59,7 @@ export class DrawersController {
|
|
|
55
59
|
this.scheduleUpdate();
|
|
56
60
|
return () => {
|
|
57
61
|
this.drawersRegistrationListener = null;
|
|
62
|
+
this.drawersUpdateListeners = [];
|
|
58
63
|
};
|
|
59
64
|
};
|
|
60
65
|
this.clearRegisteredDrawers = () => {
|
|
@@ -86,6 +91,15 @@ export class DrawersController {
|
|
|
86
91
|
var _a;
|
|
87
92
|
(_a = this.drawerClosedListener) === null || _a === void 0 ? void 0 : _a.call(this, drawerId, params);
|
|
88
93
|
};
|
|
94
|
+
this.onDrawersUpdated = (listener) => {
|
|
95
|
+
this.drawersUpdateListeners.push(listener);
|
|
96
|
+
return () => {
|
|
97
|
+
this.drawersUpdateListeners = this.drawersUpdateListeners.filter(item => item !== listener);
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
this.getDrawersState = () => {
|
|
101
|
+
return this.drawers;
|
|
102
|
+
};
|
|
89
103
|
}
|
|
90
104
|
installPublic(api = {}) {
|
|
91
105
|
var _a, _b, _c, _d;
|
|
@@ -96,11 +110,13 @@ export class DrawersController {
|
|
|
96
110
|
return api;
|
|
97
111
|
}
|
|
98
112
|
installInternal(internalApi = {}) {
|
|
99
|
-
var _a, _b, _c, _d;
|
|
113
|
+
var _a, _b, _c, _d, _e, _f;
|
|
100
114
|
(_a = internalApi.clearRegisteredDrawers) !== null && _a !== void 0 ? _a : (internalApi.clearRegisteredDrawers = this.clearRegisteredDrawers);
|
|
101
115
|
(_b = internalApi.onDrawersRegistered) !== null && _b !== void 0 ? _b : (internalApi.onDrawersRegistered = this.onDrawersRegistered);
|
|
102
116
|
(_c = internalApi.onDrawerOpened) !== null && _c !== void 0 ? _c : (internalApi.onDrawerOpened = this.onDrawerOpened);
|
|
103
117
|
(_d = internalApi.onDrawerClosed) !== null && _d !== void 0 ? _d : (internalApi.onDrawerClosed = this.onDrawerClosed);
|
|
118
|
+
(_e = internalApi.onDrawersUpdated) !== null && _e !== void 0 ? _e : (internalApi.onDrawersUpdated = this.onDrawersUpdated);
|
|
119
|
+
(_f = internalApi.getDrawersState) !== null && _f !== void 0 ? _f : (internalApi.getDrawersState = this.getDrawersState);
|
|
104
120
|
return internalApi;
|
|
105
121
|
}
|
|
106
122
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
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AAW,CAAC,sBAAsB,oCAAlC,WAAW,CAAC,sBAAsB,GAAK,IAAI,CAAC,sBAAsB,EAAC;QACnE,MAAA,WAAW,CAAC,mBAAmB,oCAA/B,WAAW,CAAC,mBAAmB,GAAK,IAAI,CAAC,mBAAmB,EAAC;QAC7D,MAAA,WAAW,CAAC,cAAc,oCAA1B,WAAW,CAAC,cAAc,GAAK,IAAI,CAAC,cAAc,EAAC;QACnD,MAAA,WAAW,CAAC,cAAc,oCAA1B,WAAW,CAAC,cAAc,GAAK,IAAI,CAAC,cAAc,EAAC;QACnD,OAAO,WAAiC,CAAC;IAC3C,CAAC;CACF","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport debounce from '../../debounce';\nimport { NonCancelableEventHandler } from '../../events';\nimport { reportRuntimeApiWarning } from '../helpers/metrics';\n\ntype DrawerVisibilityChange = (callback: (isVisible: boolean) => void) => void;\n\ninterface MountContentContext {\n onVisibilityChange: DrawerVisibilityChange;\n}\n\nexport interface DrawerStateChangeParams {\n isOpen: boolean;\n initiatedByUserAction?: boolean;\n}\n\nexport interface DrawerConfig {\n id: string;\n type?: 'local' | 'global';\n ariaLabels: {\n content?: string;\n closeButton?: string;\n triggerButton?: string;\n resizeHandle?: string;\n };\n badge?: boolean;\n resizable?: boolean;\n defaultSize?: number;\n onResize?: NonCancelableEventHandler<{ size: number; id: string }>;\n orderPriority?: number;\n defaultActive?: boolean;\n trigger?: {\n iconSvg: string;\n };\n mountContent: (container: HTMLElement, mountContext: MountContentContext) => void;\n unmountContent: (container: HTMLElement) => void;\n preserveInactiveContent?: boolean;\n onToggle?: NonCancelableEventHandler<DrawerStateChangeParams>;\n}\n\nconst updatableProperties = [\n 'badge',\n 'resizable',\n 'defaultSize',\n 'orderPriority',\n 'defaultActive',\n 'onResize',\n] as const;\n\nexport type UpdateDrawerConfig = { id: DrawerConfig['id'] } & Partial<\n Pick<DrawerConfig, (typeof updatableProperties)[number]>\n>;\n\ntype DrawersRegistrationListener = (drawers: Array<DrawerConfig>) => void;\n\nexport type DrawersToggledListener = (drawerId: string, params?: OpenCloseDrawerParams) => void;\n\ninterface OpenCloseDrawerParams {\n initiatedByUserAction: boolean;\n}\n\nexport interface DrawersApiPublic {\n registerDrawer(config: DrawerConfig): void;\n updateDrawer(config: UpdateDrawerConfig): void;\n openDrawer(drawerId: string, params?: OpenCloseDrawerParams): void;\n closeDrawer(drawerId: string, params?: OpenCloseDrawerParams): void;\n}\n\nexport interface DrawersApiInternal {\n clearRegisteredDrawers(): void;\n onDrawersRegistered(listener: DrawersRegistrationListener): () => void;\n onDrawerOpened(listener: DrawersToggledListener): () => void;\n onDrawerClosed(listener: DrawersToggledListener): () => void;\n}\n\nexport class DrawersController {\n private drawers: Array<DrawerConfig> = [];\n private drawersRegistrationListener: DrawersRegistrationListener | null = null;\n private drawerOpenedListener: DrawersToggledListener | null = null;\n private drawerClosedListener: DrawersToggledListener | null = null;\n\n scheduleUpdate = debounce(() => {\n this.drawersRegistrationListener?.(this.drawers);\n }, 0);\n\n registerDrawer = (config: DrawerConfig) => {\n if (this.drawers.find(drawer => drawer.id === config.id)) {\n reportRuntimeApiWarning('app-layout-drawers', `drawer with id \"${config.id}\" is already registered`);\n }\n this.drawers = this.drawers.concat(config);\n this.scheduleUpdate();\n };\n\n updateDrawer = ({ id: drawerId, ...rest }: UpdateDrawerConfig) => {\n const drawerIndex = this.drawers.findIndex(({ id }) => id === drawerId);\n const oldDrawerConfig = this.drawers?.[drawerIndex];\n if (!oldDrawerConfig) {\n throw new Error(`[AwsUi] [runtime drawers] drawer with id ${drawerId} not found`);\n }\n const drawers = this.drawers.slice();\n const updatedDrawer = { ...oldDrawerConfig };\n for (const key of updatableProperties) {\n if (key in rest) {\n updatedDrawer[key] = (rest as any)[key];\n }\n }\n drawers[drawerIndex] = updatedDrawer;\n this.drawers = drawers;\n this.scheduleUpdate();\n };\n\n onDrawersRegistered = (listener: DrawersRegistrationListener) => {\n if (this.drawersRegistrationListener !== null) {\n reportRuntimeApiWarning(\n 'app-layout-drawers',\n 'multiple app layout instances detected when calling onDrawersRegistered'\n );\n }\n this.drawersRegistrationListener = listener;\n this.scheduleUpdate();\n return () => {\n this.drawersRegistrationListener = null;\n };\n };\n\n clearRegisteredDrawers = () => {\n this.drawers = [];\n };\n\n onDrawerOpened = (listener: DrawersToggledListener) => {\n if (this.drawerOpenedListener !== null) {\n reportRuntimeApiWarning(\n 'app-layout-drawers',\n 'multiple app layout instances detected when calling onDrawerOpened'\n );\n }\n\n this.drawerOpenedListener = listener;\n\n return () => {\n this.drawerOpenedListener = null;\n };\n };\n\n onDrawerClosed = (listener: DrawersToggledListener) => {\n if (this.drawerClosedListener !== null) {\n reportRuntimeApiWarning(\n 'app-layout-drawers',\n 'multiple app layout instances detected when calling onDrawerClosed'\n );\n }\n\n this.drawerClosedListener = listener;\n\n return () => {\n this.drawerClosedListener = null;\n };\n };\n\n openDrawer = (drawerId: string, params?: OpenCloseDrawerParams) => {\n this.drawerOpenedListener?.(drawerId, params);\n };\n\n closeDrawer = (drawerId: string, params?: OpenCloseDrawerParams) => {\n this.drawerClosedListener?.(drawerId, params);\n };\n\n installPublic(api: Partial<DrawersApiPublic> = {}): DrawersApiPublic {\n api.registerDrawer ??= this.registerDrawer;\n api.updateDrawer ??= this.updateDrawer;\n api.openDrawer ??= this.openDrawer;\n api.closeDrawer ??= this.closeDrawer;\n return api as DrawersApiPublic;\n }\n\n installInternal(internalApi: Partial<DrawersApiInternal> = {}): DrawersApiInternal {\n internalApi.clearRegisteredDrawers ??= this.clearRegisteredDrawers;\n internalApi.onDrawersRegistered ??= this.onDrawersRegistered;\n internalApi.onDrawerOpened ??= this.onDrawerOpened;\n internalApi.onDrawerClosed ??= this.onDrawerClosed;\n return internalApi as DrawersApiInternal;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"drawers.js","sourceRoot":"","sources":["../../../../../src/internal/plugins/controllers/drawers.ts"],"names":[],"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QAEF,oBAAe,GAAG,GAAG,EAAE;YACrB,OAAO,IAAI,CAAC,OAAO,CAAC;QACtB,CAAC,CAAC;IAmBJ,CAAC;IAjBC,aAAa,CAAC,MAAiC,EAAE;;QAC/C,MAAA,GAAG,CAAC,cAAc,oCAAlB,GAAG,CAAC,cAAc,GAAK,IAAI,CAAC,cAAc,EAAC;QAC3C,MAAA,GAAG,CAAC,YAAY,oCAAhB,GAAG,CAAC,YAAY,GAAK,IAAI,CAAC,YAAY,EAAC;QACvC,MAAA,GAAG,CAAC,UAAU,oCAAd,GAAG,CAAC,UAAU,GAAK,IAAI,CAAC,UAAU,EAAC;QACnC,MAAA,GAAG,CAAC,WAAW,oCAAf,GAAG,CAAC,WAAW,GAAK,IAAI,CAAC,WAAW,EAAC;QACrC,OAAO,GAAuB,CAAC;IACjC,CAAC;IAED,eAAe,CAAC,cAA2C,EAAE;;QAC3D,MAAA,WAAW,CAAC,sBAAsB,oCAAlC,WAAW,CAAC,sBAAsB,GAAK,IAAI,CAAC,sBAAsB,EAAC;QACnE,MAAA,WAAW,CAAC,mBAAmB,oCAA/B,WAAW,CAAC,mBAAmB,GAAK,IAAI,CAAC,mBAAmB,EAAC;QAC7D,MAAA,WAAW,CAAC,cAAc,oCAA1B,WAAW,CAAC,cAAc,GAAK,IAAI,CAAC,cAAc,EAAC;QACnD,MAAA,WAAW,CAAC,cAAc,oCAA1B,WAAW,CAAC,cAAc,GAAK,IAAI,CAAC,cAAc,EAAC;QACnD,MAAA,WAAW,CAAC,gBAAgB,oCAA5B,WAAW,CAAC,gBAAgB,GAAK,IAAI,CAAC,gBAAgB,EAAC;QACvD,MAAA,WAAW,CAAC,eAAe,oCAA3B,WAAW,CAAC,eAAe,GAAK,IAAI,CAAC,eAAe,EAAC;QACrD,OAAO,WAAiC,CAAC;IAC3C,CAAC;CACF","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport debounce from '../../debounce';\nimport { NonCancelableEventHandler } from '../../events';\nimport { reportRuntimeApiWarning } from '../helpers/metrics';\n\ntype DrawerVisibilityChange = (callback: (isVisible: boolean) => void) => void;\n\ninterface MountContentContext {\n onVisibilityChange: DrawerVisibilityChange;\n}\n\nexport interface DrawerStateChangeParams {\n isOpen: boolean;\n initiatedByUserAction?: boolean;\n}\n\nexport interface DrawerConfig {\n id: string;\n type?: 'local' | 'global';\n ariaLabels: {\n content?: string;\n closeButton?: string;\n triggerButton?: string;\n resizeHandle?: string;\n resizeHandleTooltipText?: string;\n };\n badge?: boolean;\n resizable?: boolean;\n defaultSize?: number;\n onResize?: NonCancelableEventHandler<{ size: number; id: string }>;\n orderPriority?: number;\n defaultActive?: boolean;\n trigger?: {\n iconSvg: string;\n };\n mountContent: (container: HTMLElement, mountContext: MountContentContext) => void;\n unmountContent: (container: HTMLElement) => void;\n preserveInactiveContent?: boolean;\n onToggle?: NonCancelableEventHandler<DrawerStateChangeParams>;\n}\n\nconst updatableProperties = [\n 'badge',\n 'resizable',\n 'defaultSize',\n 'orderPriority',\n 'defaultActive',\n 'onResize',\n] as const;\n\nexport type UpdateDrawerConfig = { id: DrawerConfig['id'] } & Partial<\n Pick<DrawerConfig, (typeof updatableProperties)[number]>\n>;\n\ntype DrawersRegistrationListener = (drawers: Array<DrawerConfig>) => void;\ntype DrawersUpdateListener = (drawers: Array<DrawerConfig>) => void;\n\nexport type DrawersToggledListener = (drawerId: string, params?: OpenCloseDrawerParams) => void;\n\ninterface OpenCloseDrawerParams {\n initiatedByUserAction: boolean;\n}\n\nexport interface DrawersApiPublic {\n registerDrawer(config: DrawerConfig): void;\n updateDrawer(config: UpdateDrawerConfig): void;\n openDrawer(drawerId: string, params?: OpenCloseDrawerParams): void;\n closeDrawer(drawerId: string, params?: OpenCloseDrawerParams): void;\n}\n\nexport interface DrawersApiInternal {\n clearRegisteredDrawers(): void;\n onDrawersRegistered(listener: DrawersRegistrationListener): () => void;\n onDrawerOpened(listener: DrawersToggledListener): () => void;\n onDrawerClosed(listener: DrawersToggledListener): () => void;\n onDrawersUpdated(listener: DrawersUpdateListener): void;\n getDrawersState(): Array<DrawerConfig>;\n}\n\nexport class DrawersController {\n private drawers: Array<DrawerConfig> = [];\n private drawersRegistrationListener: DrawersRegistrationListener | null = null;\n private drawerOpenedListener: DrawersToggledListener | null = null;\n private drawerClosedListener: DrawersToggledListener | null = null;\n private drawersUpdateListeners: Array<DrawersUpdateListener> = [];\n\n scheduleUpdate = debounce(() => {\n this.drawersRegistrationListener?.(this.drawers);\n this.drawersUpdateListeners.forEach(drawersUpdateListeners => {\n drawersUpdateListeners?.(this.drawers);\n });\n }, 0);\n\n registerDrawer = (config: DrawerConfig) => {\n if (this.drawers.find(drawer => drawer.id === config.id)) {\n reportRuntimeApiWarning('app-layout-drawers', `drawer with id \"${config.id}\" is already registered`);\n }\n this.drawers = this.drawers.concat(config);\n this.scheduleUpdate();\n };\n\n updateDrawer = ({ id: drawerId, ...rest }: UpdateDrawerConfig) => {\n const drawerIndex = this.drawers.findIndex(({ id }) => id === drawerId);\n const oldDrawerConfig = this.drawers?.[drawerIndex];\n if (!oldDrawerConfig) {\n throw new Error(`[AwsUi] [runtime drawers] drawer with id ${drawerId} not found`);\n }\n const drawers = this.drawers.slice();\n const updatedDrawer = { ...oldDrawerConfig };\n for (const key of updatableProperties) {\n if (key in rest) {\n updatedDrawer[key] = (rest as any)[key];\n }\n }\n drawers[drawerIndex] = updatedDrawer;\n this.drawers = drawers;\n this.scheduleUpdate();\n };\n\n onDrawersRegistered = (listener: DrawersRegistrationListener) => {\n if (this.drawersRegistrationListener !== null) {\n reportRuntimeApiWarning(\n 'app-layout-drawers',\n 'multiple app layout instances detected when calling onDrawersRegistered'\n );\n }\n this.drawersRegistrationListener = listener;\n this.scheduleUpdate();\n return () => {\n this.drawersRegistrationListener = null;\n this.drawersUpdateListeners = [];\n };\n };\n\n clearRegisteredDrawers = () => {\n this.drawers = [];\n };\n\n onDrawerOpened = (listener: DrawersToggledListener) => {\n if (this.drawerOpenedListener !== null) {\n reportRuntimeApiWarning(\n 'app-layout-drawers',\n 'multiple app layout instances detected when calling onDrawerOpened'\n );\n }\n\n this.drawerOpenedListener = listener;\n\n return () => {\n this.drawerOpenedListener = null;\n };\n };\n\n onDrawerClosed = (listener: DrawersToggledListener) => {\n if (this.drawerClosedListener !== null) {\n reportRuntimeApiWarning(\n 'app-layout-drawers',\n 'multiple app layout instances detected when calling onDrawerClosed'\n );\n }\n\n this.drawerClosedListener = listener;\n\n return () => {\n this.drawerClosedListener = null;\n };\n };\n\n openDrawer = (drawerId: string, params?: OpenCloseDrawerParams) => {\n this.drawerOpenedListener?.(drawerId, params);\n };\n\n closeDrawer = (drawerId: string, params?: OpenCloseDrawerParams) => {\n this.drawerClosedListener?.(drawerId, params);\n };\n\n onDrawersUpdated = (listener: DrawersUpdateListener) => {\n this.drawersUpdateListeners.push(listener);\n\n return () => {\n this.drawersUpdateListeners = this.drawersUpdateListeners.filter(item => item !== listener);\n };\n };\n\n getDrawersState = () => {\n return this.drawers;\n };\n\n installPublic(api: Partial<DrawersApiPublic> = {}): DrawersApiPublic {\n api.registerDrawer ??= this.registerDrawer;\n api.updateDrawer ??= this.updateDrawer;\n api.openDrawer ??= this.openDrawer;\n api.closeDrawer ??= this.closeDrawer;\n return api as DrawersApiPublic;\n }\n\n installInternal(internalApi: Partial<DrawersApiInternal> = {}): DrawersApiInternal {\n internalApi.clearRegisteredDrawers ??= this.clearRegisteredDrawers;\n internalApi.onDrawersRegistered ??= this.onDrawersRegistered;\n internalApi.onDrawerOpened ??= this.onDrawerOpened;\n internalApi.onDrawerClosed ??= this.onDrawerClosed;\n internalApi.onDrawersUpdated ??= this.onDrawersUpdated;\n internalApi.getDrawersState ??= this.getDrawersState;\n return internalApi as DrawersApiInternal;\n }\n}\n"]}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { AlertFlashContentApiInternal, ReplacementType } from '../controllers/alert-flash-content';
|
|
3
3
|
export declare function createUseDiscoveredContent(componentName: string, controller: AlertFlashContentApiInternal): ({ type, header, children, }: {
|
|
4
4
|
type: string;
|
|
5
|
-
header: ReactNode;
|
|
6
|
-
children: ReactNode;
|
|
5
|
+
header: React.ReactNode;
|
|
6
|
+
children: React.ReactNode;
|
|
7
7
|
}) => {
|
|
8
8
|
initialHidden: boolean;
|
|
9
9
|
headerReplacementType: ReplacementType;
|
|
10
10
|
contentReplacementType: ReplacementType;
|
|
11
|
-
headerRef:
|
|
12
|
-
replacementHeaderRef:
|
|
13
|
-
contentRef:
|
|
14
|
-
replacementContentRef:
|
|
11
|
+
headerRef: React.Ref<HTMLDivElement>;
|
|
12
|
+
replacementHeaderRef: React.Ref<HTMLDivElement>;
|
|
13
|
+
contentRef: React.Ref<HTMLDivElement>;
|
|
14
|
+
replacementContentRef: React.Ref<HTMLDivElement>;
|
|
15
15
|
};
|
|
16
16
|
//# sourceMappingURL=use-discovered-content.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-discovered-content.d.ts","sourceRoot":"","sources":["../../../../../src/internal/plugins/helpers/use-discovered-content.tsx"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"use-discovered-content.d.ts","sourceRoot":"","sources":["../../../../../src/internal/plugins/helpers/use-discovered-content.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAG3D,OAAO,EACL,4BAA4B,EAE5B,eAAe,EAChB,MAAM,oCAAoC,CAAC;AAG5C,wBAAgB,0BAA0B,CAAC,aAAa,EAAE,MAAM,EAAE,UAAU,EAAE,4BAA4B;UAMhG,MAAM;YACJ,MAAM,SAAS;cACb,MAAM,SAAS;;;;;;;;;EAiG5B"}
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
import { useEffect, useRef, useState } from 'react';
|
|
4
|
+
import { useUniqueId } from '../../hooks/use-unique-id';
|
|
4
5
|
import { reportRuntimeApiWarning } from './metrics';
|
|
5
6
|
export function createUseDiscoveredContent(componentName, controller) {
|
|
6
7
|
return function useDiscoveredContent({ type, header, children, }) {
|
|
8
|
+
const instanceId = useUniqueId(`${componentName}-discovered-content`);
|
|
7
9
|
const headerRef = useRef(null);
|
|
8
10
|
const contentRef = useRef(null);
|
|
9
11
|
const replacementHeaderRef = useRef(null);
|
|
10
12
|
const replacementContentRef = useRef(null);
|
|
11
13
|
const [initialHidden, setInitialHidden] = useState(() => controller.initialCheck({
|
|
14
|
+
instanceId,
|
|
12
15
|
type,
|
|
13
16
|
header,
|
|
14
17
|
content: children,
|
|
@@ -17,7 +20,7 @@ export function createUseDiscoveredContent(componentName, controller) {
|
|
|
17
20
|
const [contentReplacementType, setFoundContentReplacement] = useState('original');
|
|
18
21
|
const mountedProvider = useRef();
|
|
19
22
|
useEffect(() => {
|
|
20
|
-
const context = { type, headerRef, contentRef };
|
|
23
|
+
const context = { instanceId, type, headerRef, contentRef };
|
|
21
24
|
setInitialHidden(false);
|
|
22
25
|
return controller.onContentRegistered(provider => {
|
|
23
26
|
let mounted = true;
|
|
@@ -71,7 +74,7 @@ export function createUseDiscoveredContent(componentName, controller) {
|
|
|
71
74
|
mounted = false;
|
|
72
75
|
};
|
|
73
76
|
});
|
|
74
|
-
}, [type]);
|
|
77
|
+
}, [instanceId, type]);
|
|
75
78
|
useEffect(() => {
|
|
76
79
|
var _a;
|
|
77
80
|
(_a = mountedProvider.current) === null || _a === void 0 ? void 0 : _a.update();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-discovered-content.js","sourceRoot":"","sources":["../../../../../src/internal/plugins/helpers/use-discovered-content.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,
|
|
1
|
+
{"version":3,"file":"use-discovered-content.js","sourceRoot":"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gBAEH,OAAO,GAAG,EAAE;;oBACV,MAAA,eAAe,CAAC,OAAO,0CAAE,OAAO,CAAC;wBAC/B,0BAA0B,EAAE,oBAAoB,CAAC,OAAQ;wBACzD,2BAA2B,EAAE,qBAAqB,CAAC,OAAQ;qBAC5D,CAAC,CAAC;oBACH,OAAO,GAAG,KAAK,CAAC;gBAClB,CAAC,CAAC;YACJ,CAAC,CAAC,CAAC;QACL,CAAC,EAAE,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC,CAAC;QAEvB,SAAS,CAAC,GAAG,EAAE;;YACb,MAAA,eAAe,CAAC,OAAO,0CAAE,MAAM,EAAE,CAAC;QACpC,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;QAE7B,OAAO;YACL,aAAa;YACb,qBAAqB;YACrB,sBAAsB;YACtB,SAAS,EAAE,SAAsC;YACjD,oBAAoB,EAAE,oBAAiD;YACvE,UAAU,EAAE,UAAuC;YACnD,qBAAqB,EAAE,qBAAkD;SAC1E,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useEffect, useRef, useState } from 'react';\n\nimport { useUniqueId } from '../../hooks/use-unique-id';\nimport {\n AlertFlashContentApiInternal,\n AlertFlashContentResult,\n ReplacementType,\n} from '../controllers/alert-flash-content';\nimport { reportRuntimeApiWarning } from './metrics';\n\nexport function createUseDiscoveredContent(componentName: string, controller: AlertFlashContentApiInternal) {\n return function useDiscoveredContent({\n type,\n header,\n children,\n }: {\n type: string;\n header: React.ReactNode;\n children: React.ReactNode;\n }) {\n const instanceId = useUniqueId(`${componentName}-discovered-content`);\n const headerRef = useRef<HTMLDivElement>(null);\n const contentRef = useRef<HTMLDivElement>(null);\n const replacementHeaderRef = useRef<HTMLDivElement>(null);\n const replacementContentRef = useRef<HTMLDivElement>(null);\n const [initialHidden, setInitialHidden] = useState(() =>\n controller.initialCheck({\n instanceId,\n type,\n header,\n content: children,\n })\n );\n const [headerReplacementType, setFoundHeaderReplacement] = useState<ReplacementType>('original');\n const [contentReplacementType, setFoundContentReplacement] = useState<ReplacementType>('original');\n const mountedProvider = useRef<AlertFlashContentResult | undefined>();\n\n useEffect(() => {\n const context = { instanceId, type, headerRef, contentRef };\n\n setInitialHidden(false);\n\n return controller.onContentRegistered(provider => {\n let mounted = true;\n\n function checkMounted(methodName: string) {\n if (!mounted) {\n reportRuntimeApiWarning(\n `${componentName}-content-replacer`,\n `\"${methodName}\" called after component unmounted`\n );\n return false;\n }\n return true;\n }\n\n mountedProvider.current = provider.runReplacer(context, {\n hideHeader() {\n if (checkMounted('hideHeader')) {\n setFoundHeaderReplacement('remove');\n }\n },\n restoreHeader() {\n if (checkMounted('restoreHeader')) {\n setFoundHeaderReplacement('original');\n }\n },\n replaceHeader(replacer: (container: HTMLElement) => void) {\n if (checkMounted('replaceHeader')) {\n replacer(replacementHeaderRef.current!);\n setFoundHeaderReplacement('replaced');\n }\n },\n hideContent() {\n if (checkMounted('hideContent')) {\n setFoundContentReplacement('remove');\n }\n },\n restoreContent() {\n if (checkMounted('restoreContent')) {\n setFoundContentReplacement('original');\n }\n },\n replaceContent(replacer: (container: HTMLElement) => void) {\n if (checkMounted('replaceContent')) {\n replacer(replacementContentRef.current!);\n setFoundContentReplacement('replaced');\n }\n },\n });\n\n return () => {\n mountedProvider.current?.unmount({\n replacementHeaderContainer: replacementHeaderRef.current!,\n replacementContentContainer: replacementContentRef.current!,\n });\n mounted = false;\n };\n });\n }, [instanceId, type]);\n\n useEffect(() => {\n mountedProvider.current?.update();\n }, [type, header, children]);\n\n return {\n initialHidden,\n headerReplacementType,\n contentReplacementType,\n headerRef: headerRef as React.Ref<HTMLDivElement>,\n replacementHeaderRef: replacementHeaderRef as React.Ref<HTMLDivElement>,\n contentRef: contentRef as React.Ref<HTMLDivElement>,\n replacementContentRef: replacementContentRef as React.Ref<HTML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EhC,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,EACvC,QAAQ,EACR,QAAQ,EACR,QAAQ,EAAE,gBAAgB,EAC1B,QAAQ,EACR,mBAAmB,EACnB,KAAK,EACL,QAAQ,EACR,MAAM,EACN,gBAAgB,EAChB,IAAI,EACJ,UAAU,EACV,OAAO,EACP,YAAY,EACZ,gBAAgB,EAChB,qBAAqB,EACrB,gBAAgB,EAChB,SAAS,EACT,SAAS,GACV,EAAE,qBAAqB,sBAiIvB"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
1
2
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
4
|
import React, { useLayoutEffect, useRef } from 'react';
|
|
@@ -50,10 +51,9 @@ export default function PopoverContainer({ position, trackRef, getTrack: externa
|
|
|
50
51
|
/*
|
|
51
52
|
This is a heuristic. Some layout changes are caused by user clicks (e.g. toggling the tools panel, submitting a form),
|
|
52
53
|
and by tracking the click event we can adapt the popover's position to the new layout.
|
|
53
|
-
|
|
54
|
-
TODO: extend this to Enter and Spacebar?
|
|
55
54
|
*/
|
|
56
|
-
const
|
|
55
|
+
const controller = new AbortController();
|
|
56
|
+
const onClick = (event) => __awaiter(this, void 0, void 0, function* () {
|
|
57
57
|
if (
|
|
58
58
|
// Do not update position if keepPosition is true.
|
|
59
59
|
keepPosition ||
|
|
@@ -62,13 +62,26 @@ export default function PopoverContainer({ position, trackRef, getTrack: externa
|
|
|
62
62
|
nodeContains(getTrack.current(), event.target)) {
|
|
63
63
|
return;
|
|
64
64
|
}
|
|
65
|
-
|
|
65
|
+
// Continuously update the popover position for one second to account for any layout changes
|
|
66
|
+
// and animations. On browsers where `requestIdleCallback` is supported,
|
|
67
|
+
// this runs only while the CPU is otherwise idle. In other browsers (mainly Safari), we call it
|
|
68
|
+
// with a low frequency.
|
|
69
|
+
const targetTime = performance.now() + 1000;
|
|
70
|
+
while (performance.now() < targetTime) {
|
|
71
|
+
if (controller.signal.aborted) {
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
66
74
|
updatePositionHandler();
|
|
67
|
-
|
|
68
|
-
|
|
75
|
+
if (typeof requestIdleCallback !== 'undefined') {
|
|
76
|
+
yield new Promise(r => requestIdleCallback(r));
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
yield new Promise(r => setTimeout(r, 50));
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
});
|
|
69
83
|
const updatePositionOnResize = () => requestAnimationFrame(() => updatePositionHandler());
|
|
70
84
|
const refreshPosition = () => requestAnimationFrame(() => positionHandlerRef.current());
|
|
71
|
-
const controller = new AbortController();
|
|
72
85
|
window.addEventListener('click', onClick, { signal: controller.signal });
|
|
73
86
|
window.addEventListener('resize', updatePositionOnResize, { signal: controller.signal });
|
|
74
87
|
window.addEventListener('scroll', refreshPosition, { capture: true, signal: controller.signal });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"container.js","sourceRoot":"","sources":["../../../src/popover/container.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACvD,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AACxE,OAAO,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAElF,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAErE,OAAO,kBAAkB,MAAM,2BAA2B,CAAC;AAE3D,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAqCrC,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAA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,CAAC,gBAAgB,EAAE,YAAY,EAAE,kBAAkB,EAAE,QAAQ,EAAE,qBAAqB,CAAC,CAAC,CAAC;IAE1F,OAAO,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAC9B,6BACE,GAAG,EAAE,UAAU,EACf,KAAK,kCAAO,YAAY,KAAE,MAAM,KAChC,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,SAAS,IAAI,MAAM,CAAC,OAAO,EAAE,SAAS,CAAC;QAEzE,6BACE,GAAG,EAAE,QAAQ,EACb,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC,4BAA4B,gBAAgB,EAAE,CAAC,CAAC,iBACrF,IAAI,IAEhB,KAAK,CAAC,gBAAgB,CAAC,CACpB;QAEN,6BACE,GAAG,EAAE,OAAO,EACZ,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC,uBAAuB,IAAI,EAAE,CAAC,EAAE;gBAC/E,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,EAAE,UAAU;gBACnC,CAAC,MAAM,CAAC,0BAA0B,OAAO,EAAE,CAAC,CAAC,EAAE,OAAO;aACvD,CAAC,IAED,SAAS,CAAC,CAAC,CAAC,CACX,6BAAK,SAAS,EAAE,MAAM,CAAC,YAAY,CAAC;YAClC,6BAAK,GAAG,EAAE,UAAU,IAAG,QAAQ,CAAO,CAClC,CACP,CAAC,CAAC,CAAC,CACF,6BAAK,GAAG,EAAE,UAAU,IAAG,QAAQ,CAAO,CACvC,CACG,CACF,CACP,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useLayoutEffect, useRef } from 'react';\nimport clsx from 'clsx';\n\nimport { nodeContains } from '@cloudscape-design/component-toolkit/dom';\nimport { useResizeObserver } from '@cloudscape-design/component-toolkit/internal';\n\nimport { useVisualRefresh } from '../internal/hooks/use-visual-mode';\nimport { InternalPosition, PopoverProps } from './interfaces';\nimport usePopoverPosition from './use-popover-position.js';\n\nimport styles from './styles.css.js';\n\ninterface PopoverContainerProps {\n /** References the element the container is positioned against. */\n trackRef?: React.RefObject<HTMLElement | SVGElement>;\n getTrack?: () => null | HTMLElement | SVGElement;\n /**\n Used to update the container position in case track or track position changes:\n \n const trackRef = useRef<Element>(null)\n return (<>\n <Track style={getPosition(selectedItemId)} ref={trackRef} />\n <PopoverContainer trackRef={trackRef} trackKey={selectedItemId} .../>\n </>)\n */\n trackKey?: string | number;\n minVisibleBlockSize?: number;\n position: PopoverProps.Position;\n zIndex?: React.CSSProperties['zIndex'];\n arrow: (position: InternalPosition | null) => React.ReactNode;\n children: React.ReactNode;\n renderWithPortal?: boolean;\n size: PopoverProps.Size | 'content';\n fixedWidth: boolean;\n variant?: 'annotation';\n // When keepPosition is true, the popover will not recalculate its position when it resizes nor when it receives clicks.\n keepPosition?: boolean;\n // When allowScrollToFit is true, we will scroll to the the popover if it overflows the viewport even when choosing the best possible position for it.\n // Do not use this if the popover is open on hover, in order to avoid unexpected movement.\n allowScrollToFit?: boolean;\n allowVerticalOverflow?: boolean;\n // Whether the popover should be hidden when the trigger is scrolled away.\n hideOnOverscroll?: boolean;\n hoverArea?: boolean;\n className?: string;\n}\n\nexport default function PopoverContainer({\n position,\n trackRef,\n getTrack: externalGetTrack,\n trackKey,\n minVisibleBlockSize,\n arrow,\n children,\n zIndex,\n renderWithPortal,\n size,\n fixedWidth,\n variant,\n keepPosition,\n allowScrollToFit,\n allowVerticalOverflow,\n hideOnOverscroll,\n hoverArea,\n className,\n}: PopoverContainerProps) {\n const bodyRef = useRef<HTMLDivElement | null>(null);\n const contentRef = useRef<HTMLDivElement | null>(null);\n const popoverRef = useRef<HTMLDivElement | null>(null);\n const arrowRef = useRef<HTMLDivElement | null>(null);\n\n const isRefresh = useVisualRefresh();\n\n const getTrack = useRef(() => {\n if (trackRef) {\n return trackRef.current;\n }\n if (externalGetTrack) {\n return externalGetTrack();\n }\n throw new Error('Invariant violation: must provide either trackRef or getTrack.');\n });\n\n // Updates the position handler.\n const { updatePositionHandler, popoverStyle, internalPosition, positionHandlerRef, isOverscrolling } =\n usePopoverPosition({\n popoverRef,\n bodyRef,\n arrowRef,\n getTrack: getTrack.current,\n contentRef,\n allowScrollToFit,\n allowVerticalOverflow,\n preferredPosition: position,\n renderWithPortal,\n keepPosition,\n hideOnOverscroll,\n minVisibleBlockSize,\n });\n\n // Recalculate position when properties change.\n useLayoutEffect(() => {\n updatePositionHandler();\n }, [updatePositionHandler, trackKey]);\n\n // Recalculate position when content size changes.\n useResizeObserver(contentRef, () => {\n updatePositionHandler(true);\n });\n\n // Recalculate position on DOM events.\n useLayoutEffect(() => {\n /*\n This is a heuristic. Some layout changes are caused by user clicks (e.g. toggling the tools panel, submitting a form),\n and by tracking the click event we can adapt the popover's position to the new layout.\n\n TODO: extend this to Enter and Spacebar?\n */\n\n const onClick = (event: UIEvent | KeyboardEvent) => {\n if (\n // Do not update position if keepPosition is true.\n keepPosition ||\n // If the click was on the trigger, this will make the popover appear or disappear,\n // so no need to update its position either in this case.\n nodeContains(getTrack.current(), event.target)\n ) {\n return;\n }\n\n requestAnimationFrame(() => {\n updatePositionHandler();\n });\n };\n\n const updatePositionOnResize = () => requestAnimationFrame(() => updatePositionHandler());\n const refreshPosition = () => requestAnimationFrame(() => positionHandlerRef.current());\n const controller = new AbortController();\n\n window.addEventListener('click', onClick, { signal: controller.signal });\n window.addEventListener('resize', updatePositionOnResize, { signal: controller.signal });\n window.addEventListener('scroll', refreshPosition, { capture: true, signal: controller.signal });\n\n return () => {\n controller.abort();\n };\n }, [hideOnOverscroll, keepPosition, positionHandlerRef, trackRef, updatePositionHandler]);\n\n return isOverscrolling ? null : (\n <div\n ref={popoverRef}\n style={{ ...popoverStyle, zIndex }}\n className={clsx(styles.container, isRefresh && styles.refresh, className)}\n >\n <div\n ref={arrowRef}\n className={clsx(styles[`container-arrow`], styles[`container-arrow-position-${internalPosition}`])}\n aria-hidden={true}\n >\n {arrow(internalPosition)}\n </div>\n\n <div\n ref={bodyRef}\n className={clsx(styles['container-body'], styles[`container-body-size-${size}`], {\n [styles['fixed-width']]: fixedWidth,\n [styles[`container-body-variant-${variant}`]]: variant,\n })}\n >\n {hoverArea ? (\n <div className={styles['hover-area']}>\n <div ref={contentRef}>{children}</div>\n </div>\n ) : (\n <div ref={contentRef}>{children}</div>\n )}\n </div>\n </div>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"container.js","sourceRoot":"","sources":["../../../src/popover/container.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACvD,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AACxE,OAAO,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAElF,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAErE,OAAO,kBAAkB,MAAM,2BAA2B,CAAC;AAE3D,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAqCrC,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,EACvC,QAAQ,EACR,QAAQ,EACR,QAAQ,EAAE,gBAAgB,EAC1B,QAAQ,EACR,mBAAmB,EACnB,KAAK,EACL,QAAQ,EACR,MAAM,EACN,gBAAgB,EAChB,IAAI,EACJ,UAAU,EACV,OAAO,EACP,YAAY,EACZ,gBAAgB,EAChB,qBAAqB,EACrB,gBAAgB,EAChB,SAAS,EACT,SAAS,GACa;IACtB,MAAM,OAAO,GAAG,MAAM,CAAwB,IAAI,CAAC,CAAC;IACpD,MAAM,UAAU,GAAG,MAAM,CAAwB,IAAI,CAAC,CAAC;IACvD,MAAM,UAAU,GAAG,MAAM,CAAwB,I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YACV,UAAU,CAAC,KAAK,EAAE,CAAC;QACrB,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,gBAAgB,EAAE,YAAY,EAAE,kBAAkB,EAAE,QAAQ,EAAE,qBAAqB,CAAC,CAAC,CAAC;IAE1F,OAAO,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAC9B,6BACE,GAAG,EAAE,UAAU,EACf,KAAK,kCAAO,YAAY,KAAE,MAAM,KAChC,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,SAAS,IAAI,MAAM,CAAC,OAAO,EAAE,SAAS,CAAC;QAEzE,6BACE,GAAG,EAAE,QAAQ,EACb,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC,4BAA4B,gBAAgB,EAAE,CAAC,CAAC,iBACrF,IAAI,IAEhB,KAAK,CAAC,gBAAgB,CAAC,CACpB;QAEN,6BACE,GAAG,EAAE,OAAO,EACZ,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC,uBAAuB,IAAI,EAAE,CAAC,EAAE;gBAC/E,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,EAAE,UAAU;gBACnC,CAAC,MAAM,CAAC,0BAA0B,OAAO,EAAE,CAAC,CAAC,EAAE,OAAO;aACvD,CAAC,IAED,SAAS,CAAC,CAAC,CAAC,CACX,6BAAK,SAAS,EAAE,MAAM,CAAC,YAAY,CAAC;YAClC,6BAAK,GAAG,EAAE,UAAU,IAAG,QAAQ,CAAO,CAClC,CACP,CAAC,CAAC,CAAC,CACF,6BAAK,GAAG,EAAE,UAAU,IAAG,QAAQ,CAAO,CACvC,CACG,CACF,CACP,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useLayoutEffect, useRef } from 'react';\nimport clsx from 'clsx';\n\nimport { nodeContains } from '@cloudscape-design/component-toolkit/dom';\nimport { useResizeObserver } from '@cloudscape-design/component-toolkit/internal';\n\nimport { useVisualRefresh } from '../internal/hooks/use-visual-mode';\nimport { InternalPosition, PopoverProps } from './interfaces';\nimport usePopoverPosition from './use-popover-position.js';\n\nimport styles from './styles.css.js';\n\ninterface PopoverContainerProps {\n /** References the element the container is positioned against. */\n trackRef?: React.RefObject<HTMLElement | SVGElement>;\n getTrack?: () => null | HTMLElement | SVGElement;\n /**\n Used to update the container position in case track or track position changes:\n \n const trackRef = useRef<Element>(null)\n return (<>\n <Track style={getPosition(selectedItemId)} ref={trackRef} />\n <PopoverContainer trackRef={trackRef} trackKey={selectedItemId} .../>\n </>)\n */\n trackKey?: string | number;\n minVisibleBlockSize?: number;\n position: PopoverProps.Position;\n zIndex?: React.CSSProperties['zIndex'];\n arrow: (position: InternalPosition | null) => React.ReactNode;\n children: React.ReactNode;\n renderWithPortal?: boolean;\n size: PopoverProps.Size | 'content';\n fixedWidth: boolean;\n variant?: 'annotation';\n // When keepPosition is true, the popover will not recalculate its position when it resizes nor when it receives clicks.\n keepPosition?: boolean;\n // When allowScrollToFit is true, we will scroll to the the popover if it overflows the viewport even when choosing the best possible position for it.\n // Do not use this if the popover is open on hover, in order to avoid unexpected movement.\n allowScrollToFit?: boolean;\n allowVerticalOverflow?: boolean;\n // Whether the popover should be hidden when the trigger is scrolled away.\n hideOnOverscroll?: boolean;\n hoverArea?: boolean;\n className?: string;\n}\n\nexport default function PopoverContainer({\n position,\n trackRef,\n getTrack: externalGetTrack,\n trackKey,\n minVisibleBlockSize,\n arrow,\n children,\n zIndex,\n renderWithPortal,\n size,\n fixedWidth,\n variant,\n keepPosition,\n allowScrollToFit,\n allowVerticalOverflow,\n hideOnOverscroll,\n hoverArea,\n className,\n}: PopoverContainerProps) {\n const bodyRef = useRef<HTMLDivElement | null>(null);\n const contentRef = useRef<HTMLDivElement | null>(null);\n const popoverRef = useRef<HTMLDivElement | null>(null);\n const arrowRef = useRef<HTMLDivElement | null>(null);\n\n const isRefresh = useVisualRefresh();\n\n const getTrack = useRef(() => {\n if (trackRef) {\n return trackRef.current;\n }\n if (externalGetTrack) {\n return externalGetTrack();\n }\n throw new Error('Invariant violation: must provide either trackRef or getTrack.');\n });\n\n // Updates the position handler.\n const { updatePositionHandler, popoverStyle, internalPosition, positionHandlerRef, isOverscrolling } =\n usePopoverPosition({\n popoverRef,\n bodyRef,\n arrowRef,\n getTrack: getTrack.current,\n contentRef,\n allowScrollToFit,\n allowVerticalOverflow,\n preferredPosition: position,\n renderWithPortal,\n keepPosition,\n hideOnOverscroll,\n minVisibleBlockSize,\n });\n\n // Recalculate position when properties change.\n useLayoutEffect(() => {\n updatePositionHandler();\n }, [updatePositionHandler, trackKey]);\n\n // Recalculate position when content size changes.\n useResizeObserver(contentRef, () => {\n updatePositionHandler(true);\n });\n\n // Recalculate position on DOM events.\n useLayoutEffect(() => {\n /*\n This is a heuristic. Some layout changes are caused by user clicks (e.g. toggling the tools panel, submitting a form),\n and by tracking the click event we can adapt the popover's position to the new layout.\n */\n\n const controller = new AbortController();\n\n const onClick = async (event: UIEvent | KeyboardEvent) => {\n if (\n // Do not update position if keepPosition is true.\n keepPosition ||\n // If the click was on the trigger, this will make the popover appear or disappear,\n // so no need to update its position either in this case.\n nodeContains(getTrack.current(), event.target)\n ) {\n return;\n }\n\n // Continuously update the popover position for one second to account for any layout changes\n // and animations. On browsers where `requestIdleCallback` is supported,\n // this runs only while the CPU is otherwise idle. In other browsers (mainly Safari), we call it\n // with a low frequency.\n const targetTime = performance.now() + 1_000;\n\n while (performance.now() < targetTime) {\n if (controller.signal.aborted) {\n break;\n }\n\n updatePositionHandler();\n\n if (typeof requestIdleCallback !== 'undefined') {\n await new Promise(r => requestIdleCallback(r));\n } else {\n await new Promise(r => setTimeout(r, 50));\n }\n }\n };\n\n const updatePositionOnResize = () => requestAnimationFrame(() => updatePositionHandler());\n const refreshPosition = () => requestAnimationFrame(() => positionHandlerRef.current());\n\n window.addEventListener('click', onClick, { signal: controller.signal });\n window.addEventListener('resize', updatePositionOnResize, { signal: controller.signal });\n window.addEventListener('scroll', refreshPosition, { capture: true, signal: controller.signal });\n\n return () => {\n controller.abort();\n };\n }, [hideOnOverscroll, keepPosition, positionHandlerRef, trackRef, updatePositionHandler]);\n\n return isOverscrolling ? null : (\n <div\n ref={popoverRef}\n style={{ ...popoverStyle, zIndex }}\n className={clsx(styles.container, isRefresh && styles.refresh, className)}\n >\n <div\n ref={arrowRef}\n className={clsx(styles[`container-arrow`], styles[`container-arrow-position-${internalPosition}`])}\n aria-hidden={true}\n >\n {arrow(internalPosition)}\n </div>\n\n <div\n ref={bodyRef}\n className={clsx(styles['container-body'], styles[`container-body-size-${size}`], {\n [styles['fixed-width']]: fixedWidth,\n [styles[`container-body-variant-${variant}`]]: variant,\n })}\n >\n {hoverArea ? (\n <div className={styles['hover-area']}>\n <div ref={contentRef}>{children}</div>\n </div>\n ) : (\n <div ref={contentRef}>{children}</div>\n )}\n </div>\n </div>\n );\n}\n"]}
|
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
|
|
2
2
|
import './styles.scoped.css';
|
|
3
3
|
export default {
|
|
4
|
-
"root": "
|
|
5
|
-
"slider": "
|
|
6
|
-
"slider-track": "awsui_slider-
|
|
7
|
-
"slider-range": "awsui_slider-
|
|
8
|
-
"disabled": "
|
|
9
|
-
"readonly": "
|
|
10
|
-
"error": "
|
|
11
|
-
"warning": "
|
|
12
|
-
"active": "
|
|
13
|
-
"error-active": "awsui_error-
|
|
14
|
-
"warning-active": "awsui_warning-
|
|
15
|
-
"labels": "
|
|
16
|
-
"labels-noref": "awsui_labels-
|
|
17
|
-
"labels-reference": "awsui_labels-
|
|
18
|
-
"labels-min": "awsui_labels-
|
|
19
|
-
"labels-max": "awsui_labels-
|
|
20
|
-
"labels-aria-description": "awsui_labels-aria-
|
|
21
|
-
"ticks": "
|
|
22
|
-
"ticks-wrapper": "awsui_ticks-
|
|
23
|
-
"tick": "
|
|
24
|
-
"middle": "
|
|
25
|
-
"filled": "
|
|
26
|
-
"tooltip-thumb": "awsui_tooltip-
|
|
27
|
-
"thumb": "
|
|
28
|
-
"min": "
|
|
29
|
-
"max": "
|
|
4
|
+
"root": "awsui_root_pcgz5_13gck_153",
|
|
5
|
+
"slider": "awsui_slider_pcgz5_13gck_190",
|
|
6
|
+
"slider-track": "awsui_slider-track_pcgz5_13gck_194",
|
|
7
|
+
"slider-range": "awsui_slider-range_pcgz5_13gck_194",
|
|
8
|
+
"disabled": "awsui_disabled_pcgz5_13gck_209",
|
|
9
|
+
"readonly": "awsui_readonly_pcgz5_13gck_213",
|
|
10
|
+
"error": "awsui_error_pcgz5_13gck_222",
|
|
11
|
+
"warning": "awsui_warning_pcgz5_13gck_225",
|
|
12
|
+
"active": "awsui_active_pcgz5_13gck_228",
|
|
13
|
+
"error-active": "awsui_error-active_pcgz5_13gck_231",
|
|
14
|
+
"warning-active": "awsui_warning-active_pcgz5_13gck_234",
|
|
15
|
+
"labels": "awsui_labels_pcgz5_13gck_245",
|
|
16
|
+
"labels-noref": "awsui_labels-noref_pcgz5_13gck_251",
|
|
17
|
+
"labels-reference": "awsui_labels-reference_pcgz5_13gck_254",
|
|
18
|
+
"labels-min": "awsui_labels-min_pcgz5_13gck_261",
|
|
19
|
+
"labels-max": "awsui_labels-max_pcgz5_13gck_267",
|
|
20
|
+
"labels-aria-description": "awsui_labels-aria-description_pcgz5_13gck_275",
|
|
21
|
+
"ticks": "awsui_ticks_pcgz5_13gck_293",
|
|
22
|
+
"ticks-wrapper": "awsui_ticks-wrapper_pcgz5_13gck_299",
|
|
23
|
+
"tick": "awsui_tick_pcgz5_13gck_293",
|
|
24
|
+
"middle": "awsui_middle_pcgz5_13gck_314",
|
|
25
|
+
"filled": "awsui_filled_pcgz5_13gck_317",
|
|
26
|
+
"tooltip-thumb": "awsui_tooltip-thumb_pcgz5_13gck_345",
|
|
27
|
+
"thumb": "awsui_thumb_pcgz5_13gck_358",
|
|
28
|
+
"min": "awsui_min_pcgz5_13gck_394",
|
|
29
|
+
"max": "awsui_max_pcgz5_13gck_397"
|
|
30
30
|
};
|
|
31
31
|
|