@cloudscape-design/components 3.0.1061 → 3.0.1063

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 (134) hide show
  1. package/app-layout/utils/use-focus-control.d.ts +2 -1
  2. package/app-layout/utils/use-focus-control.d.ts.map +1 -1
  3. package/app-layout/utils/use-focus-control.js +66 -6
  4. package/app-layout/utils/use-focus-control.js.map +1 -1
  5. package/app-layout/utils/use-split-panel-focus-control.d.ts.map +1 -1
  6. package/app-layout/utils/use-split-panel-focus-control.js +15 -13
  7. package/app-layout/utils/use-split-panel-focus-control.js.map +1 -1
  8. package/app-layout/visual-refresh-toolbar/index.d.ts.map +1 -1
  9. package/app-layout/visual-refresh-toolbar/index.js +37 -350
  10. package/app-layout/visual-refresh-toolbar/index.js.map +1 -1
  11. package/app-layout/visual-refresh-toolbar/interfaces.d.ts +21 -1
  12. package/app-layout/visual-refresh-toolbar/interfaces.d.ts.map +1 -1
  13. package/app-layout/visual-refresh-toolbar/interfaces.js.map +1 -1
  14. package/app-layout/visual-refresh-toolbar/internal.d.ts +24 -1
  15. package/app-layout/visual-refresh-toolbar/internal.d.ts.map +1 -1
  16. package/app-layout/visual-refresh-toolbar/internal.js +13 -0
  17. package/app-layout/visual-refresh-toolbar/internal.js.map +1 -1
  18. package/app-layout/visual-refresh-toolbar/navigation/index.js +1 -1
  19. package/app-layout/visual-refresh-toolbar/navigation/index.js.map +1 -1
  20. package/app-layout/visual-refresh-toolbar/notifications/index.js +2 -2
  21. package/app-layout/visual-refresh-toolbar/notifications/index.js.map +1 -1
  22. package/app-layout/visual-refresh-toolbar/skeleton/index.d.ts +17 -16
  23. package/app-layout/visual-refresh-toolbar/skeleton/index.d.ts.map +1 -1
  24. package/app-layout/visual-refresh-toolbar/skeleton/index.js +21 -30
  25. package/app-layout/visual-refresh-toolbar/skeleton/index.js.map +1 -1
  26. package/app-layout/visual-refresh-toolbar/skeleton/interfaces.d.ts +20 -0
  27. package/app-layout/visual-refresh-toolbar/skeleton/interfaces.d.ts.map +1 -0
  28. package/app-layout/visual-refresh-toolbar/skeleton/interfaces.js +2 -0
  29. package/app-layout/visual-refresh-toolbar/skeleton/interfaces.js.map +1 -0
  30. package/app-layout/visual-refresh-toolbar/skeleton/multi-layout.d.ts +7 -0
  31. package/app-layout/visual-refresh-toolbar/skeleton/multi-layout.d.ts.map +1 -0
  32. package/app-layout/visual-refresh-toolbar/skeleton/multi-layout.js +41 -0
  33. package/app-layout/visual-refresh-toolbar/skeleton/multi-layout.js.map +1 -0
  34. package/app-layout/visual-refresh-toolbar/skeleton/{slot-skeletons.d.ts → skeleton-parts.d.ts} +8 -0
  35. package/app-layout/visual-refresh-toolbar/skeleton/skeleton-parts.d.ts.map +1 -0
  36. package/app-layout/visual-refresh-toolbar/skeleton/skeleton-parts.js +21 -0
  37. package/app-layout/visual-refresh-toolbar/skeleton/skeleton-parts.js.map +1 -0
  38. package/app-layout/visual-refresh-toolbar/skeleton/{slot-wrappers.d.ts → slots.d.ts} +9 -0
  39. package/app-layout/visual-refresh-toolbar/skeleton/slots.d.ts.map +1 -0
  40. package/app-layout/visual-refresh-toolbar/skeleton/{breadcrumbs/index.js → slots.js} +6 -3
  41. package/app-layout/visual-refresh-toolbar/skeleton/slots.js.map +1 -0
  42. package/app-layout/visual-refresh-toolbar/skeleton/styles.css.js +23 -21
  43. package/app-layout/visual-refresh-toolbar/skeleton/styles.scoped.css +42 -37
  44. package/app-layout/visual-refresh-toolbar/skeleton/styles.selectors.js +23 -21
  45. package/app-layout/visual-refresh-toolbar/state/index.d.ts +29 -0
  46. package/app-layout/visual-refresh-toolbar/state/index.d.ts.map +1 -0
  47. package/app-layout/visual-refresh-toolbar/state/index.js +27 -0
  48. package/app-layout/visual-refresh-toolbar/state/index.js.map +1 -0
  49. package/app-layout/visual-refresh-toolbar/{multi-layout.d.ts → state/interfaces.d.ts} +11 -16
  50. package/app-layout/visual-refresh-toolbar/state/interfaces.d.ts.map +1 -0
  51. package/app-layout/visual-refresh-toolbar/state/interfaces.js +2 -0
  52. package/app-layout/visual-refresh-toolbar/state/interfaces.js.map +1 -0
  53. package/app-layout/visual-refresh-toolbar/state/invariants.d.ts +2 -0
  54. package/app-layout/visual-refresh-toolbar/state/invariants.d.ts.map +1 -0
  55. package/app-layout/visual-refresh-toolbar/state/invariants.js +4 -0
  56. package/app-layout/visual-refresh-toolbar/state/invariants.js.map +1 -0
  57. package/app-layout/visual-refresh-toolbar/state/props-merger.d.ts +4 -0
  58. package/app-layout/visual-refresh-toolbar/state/props-merger.d.ts.map +1 -0
  59. package/app-layout/visual-refresh-toolbar/{multi-layout.js → state/props-merger.js} +28 -40
  60. package/app-layout/visual-refresh-toolbar/state/props-merger.js.map +1 -0
  61. package/app-layout/visual-refresh-toolbar/state/use-app-layout.d.ts +31 -0
  62. package/app-layout/visual-refresh-toolbar/state/use-app-layout.d.ts.map +1 -0
  63. package/app-layout/visual-refresh-toolbar/state/use-app-layout.js +322 -0
  64. package/app-layout/visual-refresh-toolbar/state/use-app-layout.js.map +1 -0
  65. package/app-layout/visual-refresh-toolbar/state/use-skeleton-slots-attributes.d.ts +3 -0
  66. package/app-layout/visual-refresh-toolbar/state/use-skeleton-slots-attributes.d.ts.map +1 -0
  67. package/app-layout/visual-refresh-toolbar/state/use-skeleton-slots-attributes.js +59 -0
  68. package/app-layout/visual-refresh-toolbar/state/use-skeleton-slots-attributes.js.map +1 -0
  69. package/app-layout/visual-refresh-toolbar/toolbar/drawer-triggers.d.ts +2 -2
  70. package/app-layout/visual-refresh-toolbar/toolbar/drawer-triggers.d.ts.map +1 -1
  71. package/app-layout/visual-refresh-toolbar/toolbar/drawer-triggers.js.map +1 -1
  72. package/app-layout/visual-refresh-toolbar/toolbar/index.d.ts.map +1 -1
  73. package/app-layout/visual-refresh-toolbar/toolbar/index.js +2 -3
  74. package/app-layout/visual-refresh-toolbar/toolbar/index.js.map +1 -1
  75. package/app-layout/visual-refresh-toolbar/widget-areas/after-main-slot.d.ts +13 -0
  76. package/app-layout/visual-refresh-toolbar/widget-areas/after-main-slot.d.ts.map +1 -0
  77. package/app-layout/visual-refresh-toolbar/widget-areas/after-main-slot.js +29 -0
  78. package/app-layout/visual-refresh-toolbar/widget-areas/after-main-slot.js.map +1 -0
  79. package/app-layout/visual-refresh-toolbar/widget-areas/before-main-slot.d.ts +16 -0
  80. package/app-layout/visual-refresh-toolbar/widget-areas/before-main-slot.d.ts.map +1 -0
  81. package/app-layout/visual-refresh-toolbar/widget-areas/before-main-slot.js +28 -0
  82. package/app-layout/visual-refresh-toolbar/widget-areas/before-main-slot.js.map +1 -0
  83. package/app-layout/visual-refresh-toolbar/widget-areas/bottom-content-slot.d.ts +13 -0
  84. package/app-layout/visual-refresh-toolbar/widget-areas/bottom-content-slot.d.ts.map +1 -0
  85. package/app-layout/visual-refresh-toolbar/widget-areas/bottom-content-slot.js +17 -0
  86. package/app-layout/visual-refresh-toolbar/widget-areas/bottom-content-slot.js.map +1 -0
  87. package/app-layout/visual-refresh-toolbar/widget-areas/top-content-slot.d.ts +13 -0
  88. package/app-layout/visual-refresh-toolbar/widget-areas/top-content-slot.d.ts.map +1 -0
  89. package/app-layout/visual-refresh-toolbar/widget-areas/top-content-slot.js +19 -0
  90. package/app-layout/visual-refresh-toolbar/widget-areas/top-content-slot.js.map +1 -0
  91. package/breadcrumb-group/internal.d.ts +2 -1
  92. package/breadcrumb-group/internal.d.ts.map +1 -1
  93. package/breadcrumb-group/internal.js +3 -2
  94. package/breadcrumb-group/internal.js.map +1 -1
  95. package/button/internal.d.ts.map +1 -1
  96. package/button/internal.js +3 -26
  97. package/button/internal.js.map +1 -1
  98. package/button/style.d.ts +7 -0
  99. package/button/style.d.ts.map +1 -0
  100. package/button/style.js +33 -0
  101. package/button/style.js.map +1 -0
  102. package/internal/base-component/styles.scoped.css +1 -1
  103. package/internal/environment.js +2 -2
  104. package/internal/environment.json +2 -2
  105. package/internal/manifest.json +1 -1
  106. package/internal/types.d.ts +9 -0
  107. package/internal/types.d.ts.map +1 -1
  108. package/internal/types.js.map +1 -1
  109. package/internal/widget-exports.d.ts +5 -0
  110. package/internal/widget-exports.d.ts.map +1 -1
  111. package/internal/widget-exports.js +7 -0
  112. package/internal/widget-exports.js.map +1 -1
  113. package/internal/widgets/index.d.ts +3 -4
  114. package/internal/widgets/index.d.ts.map +1 -1
  115. package/internal/widgets/index.js.map +1 -1
  116. package/internal/widgets/loader-mock.d.ts +2 -0
  117. package/internal/widgets/loader-mock.d.ts.map +1 -0
  118. package/internal/widgets/loader-mock.js +43 -0
  119. package/internal/widgets/loader-mock.js.map +1 -0
  120. package/package.json +1 -1
  121. package/app-layout/visual-refresh-toolbar/multi-layout.d.ts.map +0 -1
  122. package/app-layout/visual-refresh-toolbar/multi-layout.js.map +0 -1
  123. package/app-layout/visual-refresh-toolbar/skeleton/breadcrumbs/index.d.ts +0 -11
  124. package/app-layout/visual-refresh-toolbar/skeleton/breadcrumbs/index.d.ts.map +0 -1
  125. package/app-layout/visual-refresh-toolbar/skeleton/breadcrumbs/index.js.map +0 -1
  126. package/app-layout/visual-refresh-toolbar/skeleton/breadcrumbs/styles.css.js +0 -7
  127. package/app-layout/visual-refresh-toolbar/skeleton/breadcrumbs/styles.scoped.css +0 -7
  128. package/app-layout/visual-refresh-toolbar/skeleton/breadcrumbs/styles.selectors.js +0 -8
  129. package/app-layout/visual-refresh-toolbar/skeleton/slot-skeletons.d.ts.map +0 -1
  130. package/app-layout/visual-refresh-toolbar/skeleton/slot-skeletons.js +0 -9
  131. package/app-layout/visual-refresh-toolbar/skeleton/slot-skeletons.js.map +0 -1
  132. package/app-layout/visual-refresh-toolbar/skeleton/slot-wrappers.d.ts.map +0 -1
  133. package/app-layout/visual-refresh-toolbar/skeleton/slot-wrappers.js +0 -8
  134. package/app-layout/visual-refresh-toolbar/skeleton/slot-wrappers.js.map +0 -1
@@ -0,0 +1,2 @@
1
+ import { AppLayoutPendingState, AppLayoutState } from '../interfaces';
2
+ export declare function isWidgetReady(state: AppLayoutPendingState): state is AppLayoutState;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invariants.d.ts","sourceRoot":"","sources":["../../../../../src/app-layout/visual-refresh-toolbar/state/invariants.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEtE,wBAAgB,aAAa,CAAC,KAAK,EAAE,qBAAqB,GAAG,KAAK,IAAI,cAAc,CAEnF"}
@@ -0,0 +1,4 @@
1
+ export function isWidgetReady(state) {
2
+ return !!state.widgetizedState;
3
+ }
4
+ //# sourceMappingURL=invariants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invariants.js","sourceRoot":"","sources":["../../../../../src/app-layout/visual-refresh-toolbar/state/invariants.ts"],"names":[],"mappings":"AAIA,MAAM,UAAU,aAAa,CAAC,KAA4B;IACxD,OAAO,CAAC,CAAC,KAAK,CAAC,eAAe,CAAC;AACjC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { AppLayoutPendingState, AppLayoutState } from '../interfaces';\n\nexport function isWidgetReady(state: AppLayoutPendingState): state is AppLayoutState {\n return !!state.widgetizedState;\n}\n"]}
@@ -0,0 +1,4 @@
1
+ import { AppLayoutInternalProps, AppLayoutPendingState } from '../interfaces';
2
+ import { MergeProps, SharedProps } from './interfaces';
3
+ export declare const mergeProps: MergeProps;
4
+ export declare const getPropsToMerge: (props: AppLayoutInternalProps, appLayoutState: AppLayoutPendingState) => SharedProps;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"props-merger.d.ts","sourceRoot":"","sources":["../../../../../src/app-layout/visual-refresh-toolbar/state/props-merger.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAE9E,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAavD,eAAO,MAAM,UAAU,EAAE,UA8CxB,CAAC;AAEF,eAAO,MAAM,eAAe,UAAW,sBAAsB,kBAAkB,qBAAqB,KAAG,WA8BtG,CAAC"}
@@ -1,9 +1,6 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
- import { useLayoutEffect, useState } from 'react';
4
3
  import { warnOnce } from '@cloudscape-design/component-toolkit/internal';
5
- import { awsuiPluginsInternal } from '../../internal/plugins/api';
6
- import { useAppLayoutFlagEnabled } from '../utils/feature-flags';
7
4
  function checkAlreadyExists(value, propName) {
8
5
  if (value) {
9
6
  warnOnce('AppLayout', `Another app layout instance on this page already defines ${propName} property. This instance will be ignored.`);
@@ -11,7 +8,7 @@ function checkAlreadyExists(value, propName) {
11
8
  }
12
9
  return false;
13
10
  }
14
- export function mergeProps(ownProps, additionalProps) {
11
+ export const mergeProps = (ownProps, additionalProps) => {
15
12
  var _a, _b;
16
13
  const toolbar = {};
17
14
  for (const props of [ownProps, ...additionalProps]) {
@@ -54,41 +51,32 @@ export function mergeProps(ownProps, additionalProps) {
54
51
  }
55
52
  // do not render toolbar if no fields are defined, except ariaLabels, which are always there
56
53
  return Object.keys(toolbar).filter(key => key !== 'ariaLabels').length > 0 ? toolbar : null;
57
- }
58
- export function useMultiAppLayout(props, isEnabled) {
59
- const [registration, setRegistration] = useState(null);
60
- const { forceDeduplicationType } = props;
61
- const isToolbar = useAppLayoutFlagEnabled();
62
- useLayoutEffect(() => {
63
- if (!isEnabled || forceDeduplicationType === 'suspended' || !isToolbar) {
64
- return;
65
- }
66
- if (forceDeduplicationType === 'off') {
67
- setRegistration({ type: 'primary', discoveredProps: [] });
68
- return;
69
- }
70
- const unregister = awsuiPluginsInternal.appLayoutWidget.register(forceDeduplicationType, props => setRegistration(props));
71
- return () => {
72
- unregister();
73
- setRegistration({ type: 'suspended' });
74
- };
75
- }, [forceDeduplicationType, isEnabled, isToolbar]);
76
- useLayoutEffect(() => {
77
- if ((registration === null || registration === void 0 ? void 0 : registration.type) === 'secondary') {
78
- registration.update(props);
79
- }
80
- });
81
- if (!isToolbar) {
82
- return {
83
- registered: true,
84
- // mergeProps is needed here because the toolbar's behavior depends on reconciliation logic
85
- // in this function. For example, navigation trigger visibility
86
- toolbarProps: mergeProps(props, []),
87
- };
88
- }
54
+ };
55
+ export const getPropsToMerge = (props, appLayoutState) => {
56
+ var _a, _b, _c, _d;
57
+ const state = appLayoutState.widgetizedState;
89
58
  return {
90
- registered: !!(registration === null || registration === void 0 ? void 0 : registration.type),
91
- toolbarProps: (registration === null || registration === void 0 ? void 0 : registration.type) === 'primary' ? mergeProps(props, registration.discoveredProps) : null,
59
+ breadcrumbs: props.breadcrumbs,
60
+ ariaLabels: state ? state.ariaLabels : props.ariaLabels,
61
+ navigation: !props.navigationTriggerHide && !props.navigationHide,
62
+ navigationOpen: state ? state.navigationOpen : props.navigationOpen,
63
+ onNavigationToggle: state === null || state === void 0 ? void 0 : state.onNavigationToggle,
64
+ navigationFocusRef: state === null || state === void 0 ? void 0 : state.navigationFocusControl.refs.toggle,
65
+ activeDrawerId: (_b = (_a = state === null || state === void 0 ? void 0 : state.activeDrawer) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : null,
66
+ // only pass it down if there are non-empty drawers or tools
67
+ drawers: ((_c = state === null || state === void 0 ? void 0 : state.drawers) === null || _c === void 0 ? void 0 : _c.length) || !props.toolsHide ? state === null || state === void 0 ? void 0 : state.drawers : undefined,
68
+ globalDrawersFocusControl: state === null || state === void 0 ? void 0 : state.globalDrawersFocusControl,
69
+ globalDrawers: ((_d = state === null || state === void 0 ? void 0 : state.globalDrawers) === null || _d === void 0 ? void 0 : _d.length) ? state.globalDrawers : undefined,
70
+ activeGlobalDrawersIds: state === null || state === void 0 ? void 0 : state.activeGlobalDrawersIds,
71
+ onActiveGlobalDrawersChange: state === null || state === void 0 ? void 0 : state.onActiveGlobalDrawersChange,
72
+ onActiveDrawerChange: state === null || state === void 0 ? void 0 : state.onActiveDrawerChange,
73
+ drawersFocusRef: state === null || state === void 0 ? void 0 : state.drawersFocusControl.refs.toggle,
74
+ splitPanel: props.splitPanel,
75
+ splitPanelToggleProps: (state === null || state === void 0 ? void 0 : state.splitPanelToggleConfig) && Object.assign(Object.assign({}, state.splitPanelToggleConfig), { active: state === null || state === void 0 ? void 0 : state.splitPanelOpen, controlId: state === null || state === void 0 ? void 0 : state.splitPanelControlId, position: state === null || state === void 0 ? void 0 : state.splitPanelPosition }),
76
+ splitPanelFocusRef: state === null || state === void 0 ? void 0 : state.splitPanelFocusControl.refs.toggle,
77
+ onSplitPanelToggle: state === null || state === void 0 ? void 0 : state.onSplitPanelToggle,
78
+ expandedDrawerId: state === null || state === void 0 ? void 0 : state.expandedDrawerId,
79
+ setExpandedDrawerId: state === null || state === void 0 ? void 0 : state.setExpandedDrawerId,
92
80
  };
93
- }
94
- //# sourceMappingURL=multi-layout.js.map
81
+ };
82
+ //# sourceMappingURL=props-merger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"props-merger.js","sourceRoot":"","sources":["../../../../../src/app-layout/visual-refresh-toolbar/state/props-merger.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,+CAA+C,CAAC;AAMzE,SAAS,kBAAkB,CAAC,KAAc,EAAE,QAAgB;IAC1D,IAAI,KAAK,EAAE;QACT,QAAQ,CACN,WAAW,EACX,4DAA4D,QAAQ,2CAA2C,CAChH,CAAC;QACF,OAAO,IAAI,CAAC;KACb;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,CAAC,MAAM,UAAU,GAAe,CAAC,QAAQ,EAAE,eAAe,EAAE,EAAE;;IAClE,MAAM,OAAO,GAAiB,EAAE,CAAC;IACjC,KAAK,MAAM,KAAK,IAAI,CAAC,QAAQ,EAAE,GAAG,eAAe,CAAC,EAAE;QAClD,OAAO,CAAC,UAAU,G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;QAC5B,qBAAqB,EAAE,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,sBAAsB,qCAC/C,KAAK,CAAC,sBAAsB,KAC/B,MAAM,EAAE,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,cAAc,EAC7B,SAAS,EAAE,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,mBAAmB,EACrC,QAAQ,EAAE,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,kBAAkB,GACpC;QACD,kBAAkB,EAAE,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,sBAAsB,CAAC,IAAI,CAAC,MAAM;QAC7D,kBAAkB,EAAE,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,kBAAkB;QAC7C,gBAAgB,EAAE,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,gBAAgB;QACzC,mBAAmB,EAAE,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,mBAAmB;KAChD,CAAC;AACJ,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { warnOnce } from '@cloudscape-design/component-toolkit/internal';\n\nimport { AppLayoutInternalProps, AppLayoutPendingState } from '../interfaces';\nimport { ToolbarProps } from '../toolbar';\nimport { MergeProps, SharedProps } from './interfaces';\n\nfunction checkAlreadyExists(value: boolean, propName: string) {\n if (value) {\n warnOnce(\n 'AppLayout',\n `Another app layout instance on this page already defines ${propName} property. This instance will be ignored.`\n );\n return true;\n }\n return false;\n}\n\nexport const mergeProps: MergeProps = (ownProps, additionalProps) => {\n const toolbar: ToolbarProps = {};\n for (const props of [ownProps, ...additionalProps]) {\n toolbar.ariaLabels = Object.assign(toolbar.ariaLabels ?? {}, props.ariaLabels);\n if (\n props.drawers &&\n props.drawers.some(drawer => drawer.trigger) &&\n !checkAlreadyExists(!!toolbar.drawers, 'tools or drawers')\n ) {\n toolbar.drawers = props.drawers;\n toolbar.activeDrawerId = props.activeDrawerId;\n toolbar.drawersFocusRef = props.drawersFocusRef;\n toolbar.onActiveDrawerChange = props.onActiveDrawerChange;\n }\n if (props.globalDrawers && !checkAlreadyExists(!!toolbar.globalDrawers, 'globalDrawers')) {\n toolbar.globalDrawersFocusControl = props.globalDrawersFocusControl;\n toolbar.globalDrawers = props.globalDrawers;\n toolbar.activeGlobalDrawersIds = props.activeGlobalDrawersIds;\n toolbar.onActiveGlobalDrawersChange = props.onActiveGlobalDrawersChange;\n }\n if (props.navigation && !checkAlreadyExists(!!toolbar.hasNavigation, 'navigation')) {\n toolbar.hasNavigation = true;\n toolbar.navigationOpen = props.navigationOpen;\n toolbar.navigationFocusRef = props.navigationFocusRef;\n toolbar.onNavigationToggle = props.onNavigationToggle;\n }\n if (\n props.splitPanel &&\n props.splitPanelToggleProps?.displayed &&\n !checkAlreadyExists(!!toolbar.hasSplitPanel, 'splitPanel')\n ) {\n toolbar.hasSplitPanel = true;\n toolbar.splitPanelFocusRef = props.splitPanelFocusRef;\n toolbar.splitPanelToggleProps = props.splitPanelToggleProps;\n toolbar.onSplitPanelToggle = props.onSplitPanelToggle;\n }\n if (props.breadcrumbs && !checkAlreadyExists(!!toolbar.hasBreadcrumbsPortal, 'hasBreadcrumbsPortal')) {\n toolbar.hasBreadcrumbsPortal = true;\n }\n if (props.expandedDrawerId && !checkAlreadyExists(!!toolbar.expandedDrawerId, 'expandedDrawerId')) {\n toolbar.expandedDrawerId = props.expandedDrawerId;\n toolbar.setExpandedDrawerId = props.setExpandedDrawerId;\n }\n }\n // do not render toolbar if no fields are defined, except ariaLabels, which are always there\n return Object.keys(toolbar).filter(key => key !== 'ariaLabels').length > 0 ? toolbar : null;\n};\n\nexport const getPropsToMerge = (props: AppLayoutInternalProps, appLayoutState: AppLayoutPendingState): SharedProps => {\n const state = appLayoutState.widgetizedState;\n return {\n breadcrumbs: props.breadcrumbs,\n ariaLabels: state ? state.ariaLabels : props.ariaLabels,\n navigation: !props.navigationTriggerHide && !props.navigationHide,\n navigationOpen: state ? state.navigationOpen : props.navigationOpen,\n onNavigationToggle: state?.onNavigationToggle,\n navigationFocusRef: state?.navigationFocusControl.refs.toggle,\n activeDrawerId: state?.activeDrawer?.id ?? null,\n // only pass it down if there are non-empty drawers or tools\n drawers: state?.drawers?.length || !props.toolsHide ? state?.drawers : undefined,\n globalDrawersFocusControl: state?.globalDrawersFocusControl,\n globalDrawers: state?.globalDrawers?.length ? state.globalDrawers : undefined,\n activeGlobalDrawersIds: state?.activeGlobalDrawersIds,\n onActiveGlobalDrawersChange: state?.onActiveGlobalDrawersChange,\n onActiveDrawerChange: state?.onActiveDrawerChange,\n drawersFocusRef: state?.drawersFocusControl.refs.toggle,\n splitPanel: props.splitPanel,\n splitPanelToggleProps: state?.splitPanelToggleConfig && {\n ...state.splitPanelToggleConfig,\n active: state?.splitPanelOpen,\n controlId: state?.splitPanelControlId,\n position: state?.splitPanelPosition,\n },\n splitPanelFocusRef: state?.splitPanelFocusControl.refs.toggle,\n onSplitPanelToggle: state?.onSplitPanelToggle,\n expandedDrawerId: state?.expandedDrawerId,\n setExpandedDrawerId: state?.setExpandedDrawerId,\n };\n};\n"]}
@@ -0,0 +1,31 @@
1
+ import { ForwardedRef } from 'react';
2
+ import { AppLayoutProps } from '../../interfaces';
3
+ import { AppLayoutState } from '../interfaces';
4
+ import { AppLayoutInternalProps } from '../interfaces';
5
+ export declare const useAppLayout: (hasToolbar: boolean, {
6
+ ariaLabels,
7
+ navigationOpen,
8
+ navigationWidth,
9
+ navigation,
10
+ navigationHide,
11
+ onNavigationChange,
12
+ tools,
13
+ toolsOpen: controlledToolsOpen,
14
+ onToolsChange,
15
+ toolsHide,
16
+ toolsWidth,
17
+ headerVariant,
18
+ breadcrumbs,
19
+ stickyNotifications,
20
+ splitPanelPreferences: controlledSplitPanelPreferences,
21
+ splitPanelOpen: controlledSplitPanelOpen,
22
+ splitPanel,
23
+ splitPanelSize: controlledSplitPanelSize,
24
+ onSplitPanelToggle,
25
+ onSplitPanelResize,
26
+ onSplitPanelPreferencesChange,
27
+ minContentWidth,
28
+ placement,
29
+ navigationTriggerHide,
30
+ ...rest
31
+ }: AppLayoutInternalProps, forwardRef: ForwardedRef<AppLayoutProps.Ref>) => AppLayoutState;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-app-layout.d.ts","sourceRoot":"","sources":["../../../../../src/app-layout/visual-refresh-toolbar/state/use-app-layout.tsx"],"names":[],"mappings":"AAEA,OAAc,EAAE,YAAY,EAAiE,MAAM,OAAO,CAAC;AAY3G,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAYlD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,sBAAsB,EAAsB,MAAM,eAAe,CAAC;AAE3E,eAAO,MAAM,YAAY,eACX,OAAO,4fA2BhB,sBAAsB,cACb,aAAa,eAAe,GAAG,CAAC,KAC3C,cAiYF,CAAC"}
@@ -0,0 +1,322 @@
1
+ import { __rest } from "tslib";
2
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ // SPDX-License-Identifier: Apache-2.0
4
+ import React, { useCallback, useEffect, useImperativeHandle, useRef, useState } from 'react';
5
+ import { useMergeRefs, useStableCallback, useUniqueId } from '@cloudscape-design/component-toolkit/internal';
6
+ import { fireNonCancelableEvent } from '../../../internal/events';
7
+ import { useControllable } from '../../../internal/hooks/use-controllable';
8
+ import { useIntersectionObserver } from '../../../internal/hooks/use-intersection-observer';
9
+ import { useMobile } from '../../../internal/hooks/use-mobile';
10
+ import { useGetGlobalBreadcrumbs } from '../../../internal/plugins/helpers/use-global-breadcrumbs';
11
+ import globalVars from '../../../internal/styles/global-vars';
12
+ import { getSplitPanelDefaultSize } from '../../../split-panel/utils/size-utils';
13
+ import { MIN_DRAWER_SIZE, useDrawers } from '../../utils/use-drawers';
14
+ import { useAsyncFocusControl, useMultipleFocusControl } from '../../utils/use-focus-control';
15
+ import { useGlobalScrollPadding } from '../../utils/use-global-scroll-padding';
16
+ import { useSplitPanelFocusControl } from '../../utils/use-split-panel-focus-control';
17
+ import { computeHorizontalLayout, computeSplitPanelOffsets, computeVerticalLayout, CONTENT_PADDING, } from '../compute-layout';
18
+ export const useAppLayout = (hasToolbar, _a, forwardRef) => {
19
+ var _b, _c;
20
+ var { ariaLabels, navigationOpen, navigationWidth, navigation, navigationHide, onNavigationChange, tools, toolsOpen: controlledToolsOpen, onToolsChange, toolsHide, toolsWidth, headerVariant, breadcrumbs, stickyNotifications, splitPanelPreferences: controlledSplitPanelPreferences, splitPanelOpen: controlledSplitPanelOpen, splitPanel, splitPanelSize: controlledSplitPanelSize, onSplitPanelToggle, onSplitPanelResize, onSplitPanelPreferencesChange, minContentWidth, placement, navigationTriggerHide } = _a, rest = __rest(_a, ["ariaLabels", "navigationOpen", "navigationWidth", "navigation", "navigationHide", "onNavigationChange", "tools", "toolsOpen", "onToolsChange", "toolsHide", "toolsWidth", "headerVariant", "breadcrumbs", "stickyNotifications", "splitPanelPreferences", "splitPanelOpen", "splitPanel", "splitPanelSize", "onSplitPanelToggle", "onSplitPanelResize", "onSplitPanelPreferencesChange", "minContentWidth", "placement", "navigationTriggerHide"]);
21
+ const isMobile = useMobile();
22
+ const splitPanelControlId = useUniqueId('split-panel');
23
+ const [toolbarState, setToolbarState] = useState('show');
24
+ const [toolbarHeight, setToolbarHeight] = useState(0);
25
+ const [notificationsHeight, setNotificationsHeight] = useState(0);
26
+ const [navigationAnimationDisabled, setNavigationAnimationDisabled] = useState(true);
27
+ const [splitPanelAnimationDisabled, setSplitPanelAnimationDisabled] = useState(true);
28
+ const [isNested, setIsNested] = useState(false);
29
+ const rootRefInternal = useRef(null);
30
+ // This workaround ensures the ref is defined before checking if the app layout is nested.
31
+ // On initial render, the ref might be undefined because this component loads asynchronously via the widget API.
32
+ const onMountRootRef = useCallback(node => {
33
+ setIsNested(getIsNestedInAppLayout(node));
34
+ }, []);
35
+ const [toolsOpen = false, setToolsOpen] = useControllable(controlledToolsOpen, onToolsChange, false, {
36
+ componentName: 'AppLayout',
37
+ controlledProp: 'toolsOpen',
38
+ changeHandler: 'onToolsChange',
39
+ });
40
+ const onToolsToggle = (open) => {
41
+ setToolsOpen(open);
42
+ drawersFocusControl.setFocus();
43
+ fireNonCancelableEvent(onToolsChange, { open });
44
+ };
45
+ const onGlobalDrawerFocus = (drawerId, open) => {
46
+ globalDrawersFocusControl.setFocus({ force: true, drawerId, open });
47
+ };
48
+ const onAddNewActiveDrawer = (drawerId) => {
49
+ var _a, _b;
50
+ // If a local drawer is already open, and we attempt to open a new one,
51
+ // it will replace the existing one instead of opening an additional drawer,
52
+ // since only one local drawer is supported. Therefore, layout calculations are not necessary.
53
+ if (activeDrawer && (drawers === null || drawers === void 0 ? void 0 : drawers.find(drawer => drawer.id === drawerId))) {
54
+ return;
55
+ }
56
+ // get the size of drawerId. it could be either local or global drawer
57
+ const combinedDrawers = [...(drawers || []), ...globalDrawers];
58
+ const newDrawer = combinedDrawers.find(drawer => drawer.id === drawerId);
59
+ if (!newDrawer) {
60
+ return;
61
+ }
62
+ const newDrawerSize = Math.min((_b = (_a = newDrawer.defaultSize) !== null && _a !== void 0 ? _a : drawerSizes[drawerId]) !== null && _b !== void 0 ? _b : MIN_DRAWER_SIZE, MIN_DRAWER_SIZE);
63
+ // check if the active drawers could be resized to fit the new drawers
64
+ // to do this, we need to take all active drawers, sum up their min sizes, truncate it from resizableSpaceAvailable
65
+ // and compare a given number with the new drawer id min size
66
+ // the total size of all global drawers resized to their min size
67
+ const availableSpaceForNewDrawer = resizableSpaceAvailable - totalActiveDrawersMinSize;
68
+ if (availableSpaceForNewDrawer >= newDrawerSize) {
69
+ return;
70
+ }
71
+ // now we made sure we cannot accommodate the new drawer with existing ones
72
+ closeFirstDrawer();
73
+ };
74
+ const { drawers, activeDrawer, minDrawerSize, minGlobalDrawersSizes, activeDrawerSize, ariaLabelsWithDrawers, globalDrawers, activeGlobalDrawers, activeGlobalDrawersIds, activeGlobalDrawersSizes, drawerSizes, drawersOpenQueue, onActiveDrawerChange, onActiveDrawerResize, onActiveGlobalDrawersChange, expandedDrawerId, setExpandedDrawerId, } = useDrawers(Object.assign(Object.assign({}, rest), { onGlobalDrawerFocus, onAddNewActiveDrawer }), ariaLabels, {
75
+ ariaLabels,
76
+ toolsHide,
77
+ toolsOpen,
78
+ tools,
79
+ toolsWidth,
80
+ onToolsToggle,
81
+ });
82
+ const onActiveDrawerChangeHandler = (drawerId, params = { initiatedByUserAction: true }) => {
83
+ onActiveDrawerChange(drawerId, params);
84
+ drawersFocusControl.setFocus();
85
+ };
86
+ const [splitPanelOpen = false, setSplitPanelOpen] = useControllable(controlledSplitPanelOpen, onSplitPanelToggle, false, {
87
+ componentName: 'AppLayout',
88
+ controlledProp: 'splitPanelOpen',
89
+ changeHandler: 'onSplitPanelToggle',
90
+ });
91
+ const onSplitPanelToggleHandler = () => {
92
+ setSplitPanelAnimationDisabled(false);
93
+ setSplitPanelOpen(!splitPanelOpen);
94
+ splitPanelFocusControl.setLastInteraction({ type: splitPanelOpen ? 'close' : 'open' });
95
+ fireNonCancelableEvent(onSplitPanelToggle, { open: !splitPanelOpen });
96
+ };
97
+ const [splitPanelPreferences, setSplitPanelPreferences] = useControllable(controlledSplitPanelPreferences, onSplitPanelPreferencesChange, undefined, {
98
+ componentName: 'AppLayout',
99
+ controlledProp: 'splitPanelPreferences',
100
+ changeHandler: 'onSplitPanelPreferencesChange',
101
+ });
102
+ const onSplitPanelPreferencesChangeHandler = (detail) => {
103
+ setSplitPanelPreferences(detail);
104
+ splitPanelFocusControl.setLastInteraction({ type: 'position' });
105
+ fireNonCancelableEvent(onSplitPanelPreferencesChange, detail);
106
+ };
107
+ const [splitPanelSize = 0, setSplitPanelSize] = useControllable(controlledSplitPanelSize, onSplitPanelResize, getSplitPanelDefaultSize((_b = splitPanelPreferences === null || splitPanelPreferences === void 0 ? void 0 : splitPanelPreferences.position) !== null && _b !== void 0 ? _b : 'bottom'), { componentName: 'AppLayout', controlledProp: 'splitPanelSize', changeHandler: 'onSplitPanelResize' });
108
+ const [splitPanelReportedSize, setSplitPanelReportedSize] = useState(0);
109
+ const [splitPanelHeaderBlockSize, setSplitPanelHeaderBlockSize] = useState(0);
110
+ const onSplitPanelResizeHandler = (size) => {
111
+ setSplitPanelSize(size);
112
+ fireNonCancelableEvent(onSplitPanelResize, { size });
113
+ };
114
+ const [splitPanelToggleConfig, setSplitPanelToggleConfig] = useState({
115
+ ariaLabel: undefined,
116
+ displayed: false,
117
+ });
118
+ const globalDrawersFocusControl = useMultipleFocusControl(true, activeGlobalDrawersIds);
119
+ const drawersFocusControl = useAsyncFocusControl(!!(activeDrawer === null || activeDrawer === void 0 ? void 0 : activeDrawer.id), true, activeDrawer === null || activeDrawer === void 0 ? void 0 : activeDrawer.id);
120
+ const navigationFocusControl = useAsyncFocusControl(navigationOpen, navigationTriggerHide);
121
+ const splitPanelFocusControl = useSplitPanelFocusControl([splitPanelPreferences, splitPanelOpen]);
122
+ const onNavigationToggle = useStableCallback((open) => {
123
+ setNavigationAnimationDisabled(false);
124
+ navigationFocusControl.setFocus();
125
+ fireNonCancelableEvent(onNavigationChange, { open });
126
+ });
127
+ useImperativeHandle(forwardRef, () => ({
128
+ closeNavigationIfNecessary: () => isMobile && onNavigationToggle(false),
129
+ openTools: () => onToolsToggle(true),
130
+ focusToolsClose: () => drawersFocusControl.setFocus(true),
131
+ focusActiveDrawer: () => drawersFocusControl.setFocus(true),
132
+ focusSplitPanel: () => splitPanelFocusControl.setLastInteraction({ type: 'open' }),
133
+ focusNavigation: () => navigationFocusControl.setFocus(true),
134
+ }));
135
+ const resolvedStickyNotifications = !!stickyNotifications && !isMobile;
136
+ //navigation must be null if hidden so toolbar knows to hide the toggle button
137
+ const resolvedNavigation = navigationHide ? null : navigation || React.createElement(React.Fragment, null);
138
+ //navigation must not be open if navigationHide is true
139
+ const resolvedNavigationOpen = !!resolvedNavigation && navigationOpen;
140
+ const { maxDrawerSize, maxSplitPanelSize, splitPanelForcedPosition, splitPanelPosition, maxGlobalDrawersSizes, resizableSpaceAvailable, } = computeHorizontalLayout({
141
+ activeDrawerSize: activeDrawer ? activeDrawerSize : 0,
142
+ splitPanelSize,
143
+ minContentWidth,
144
+ navigationOpen: resolvedNavigationOpen,
145
+ navigationWidth,
146
+ placement,
147
+ splitPanelOpen,
148
+ splitPanelPosition: splitPanelPreferences === null || splitPanelPreferences === void 0 ? void 0 : splitPanelPreferences.position,
149
+ isMobile,
150
+ activeGlobalDrawersSizes,
151
+ });
152
+ const verticalOffsets = computeVerticalLayout({
153
+ topOffset: placement.insetBlockStart,
154
+ hasVisibleToolbar: hasToolbar && toolbarState !== 'hide',
155
+ notificationsHeight: notificationsHeight !== null && notificationsHeight !== void 0 ? notificationsHeight : 0,
156
+ toolbarHeight: toolbarHeight !== null && toolbarHeight !== void 0 ? toolbarHeight : 0,
157
+ stickyNotifications: resolvedStickyNotifications,
158
+ });
159
+ const { ref: intersectionObserverRef, isIntersecting } = useIntersectionObserver({ initialState: true });
160
+ const rootRef = useMergeRefs(rootRefInternal, intersectionObserverRef, onMountRootRef);
161
+ const discoveredBreadcrumbs = useGetGlobalBreadcrumbs(hasToolbar && !breadcrumbs);
162
+ useGlobalScrollPadding((_c = verticalOffsets.header) !== null && _c !== void 0 ? _c : 0);
163
+ const appLayoutInternals = {
164
+ ariaLabels: ariaLabelsWithDrawers,
165
+ headerVariant,
166
+ isMobile,
167
+ breadcrumbs,
168
+ discoveredBreadcrumbs,
169
+ stickyNotifications: resolvedStickyNotifications,
170
+ navigationOpen: resolvedNavigationOpen,
171
+ navigation: resolvedNavigation,
172
+ navigationFocusControl,
173
+ activeDrawer,
174
+ activeDrawerSize,
175
+ minDrawerSize,
176
+ maxDrawerSize,
177
+ minGlobalDrawersSizes,
178
+ maxGlobalDrawersSizes,
179
+ drawers: drawers,
180
+ globalDrawers,
181
+ activeGlobalDrawers,
182
+ activeGlobalDrawersIds,
183
+ activeGlobalDrawersSizes,
184
+ onActiveGlobalDrawersChange,
185
+ drawersFocusControl,
186
+ globalDrawersFocusControl,
187
+ splitPanelPosition,
188
+ splitPanelToggleConfig,
189
+ splitPanelOpen,
190
+ splitPanelControlId,
191
+ splitPanelFocusControl,
192
+ placement,
193
+ toolbarState,
194
+ setToolbarState,
195
+ verticalOffsets,
196
+ drawersOpenQueue,
197
+ setToolbarHeight,
198
+ setNotificationsHeight,
199
+ onSplitPanelToggle: onSplitPanelToggleHandler,
200
+ onNavigationToggle,
201
+ onActiveDrawerChange: onActiveDrawerChangeHandler,
202
+ onActiveDrawerResize,
203
+ splitPanelAnimationDisabled,
204
+ expandedDrawerId,
205
+ setExpandedDrawerId,
206
+ };
207
+ const splitPanelInternals = {
208
+ bottomOffset: 0,
209
+ getMaxHeight: useStableCallback(() => {
210
+ const availableHeight = document.documentElement.clientHeight - placement.insetBlockStart - placement.insetBlockEnd;
211
+ // If the page is likely zoomed in at 200%, allow the split panel to fill the content area.
212
+ return availableHeight < 400 ? availableHeight - 40 : availableHeight - 250;
213
+ }),
214
+ maxWidth: maxSplitPanelSize,
215
+ isForcedPosition: splitPanelForcedPosition,
216
+ isOpen: splitPanelOpen,
217
+ leftOffset: 0,
218
+ onPreferencesChange: onSplitPanelPreferencesChangeHandler,
219
+ onResize: onSplitPanelResizeHandler,
220
+ onToggle: onSplitPanelToggleHandler,
221
+ position: splitPanelPosition,
222
+ reportSize: useStableCallback(size => setSplitPanelReportedSize(size)),
223
+ reportHeaderHeight: useStableCallback(size => setSplitPanelHeaderBlockSize(size)),
224
+ headerHeight: splitPanelHeaderBlockSize,
225
+ rightOffset: 0,
226
+ size: splitPanelSize,
227
+ topOffset: 0,
228
+ setSplitPanelToggle: setSplitPanelToggleConfig,
229
+ refs: splitPanelFocusControl.refs,
230
+ };
231
+ const closeFirstDrawer = useStableCallback(() => {
232
+ const drawerToClose = drawersOpenQueue[drawersOpenQueue.length - 1];
233
+ if (activeDrawer && (activeDrawer === null || activeDrawer === void 0 ? void 0 : activeDrawer.id) === drawerToClose) {
234
+ onActiveDrawerChange(null, { initiatedByUserAction: true });
235
+ }
236
+ else if (activeGlobalDrawersIds.includes(drawerToClose)) {
237
+ onActiveGlobalDrawersChange(drawerToClose, { initiatedByUserAction: true });
238
+ }
239
+ });
240
+ useEffect(() => {
241
+ // Close navigation drawer on mobile so that the main content is visible
242
+ if (isMobile) {
243
+ onNavigationToggle(false);
244
+ }
245
+ // eslint-disable-next-line react-hooks/exhaustive-deps
246
+ }, [isMobile]);
247
+ const getTotalActiveDrawersMinSize = () => {
248
+ var _a;
249
+ const combinedDrawers = [...(drawers || []), ...globalDrawers];
250
+ let result = activeGlobalDrawersIds
251
+ .map(activeDrawerId => {
252
+ var _a, _b;
253
+ return Math.min((_b = (_a = combinedDrawers.find(drawer => drawer.id === activeDrawerId)) === null || _a === void 0 ? void 0 : _a.defaultSize) !== null && _b !== void 0 ? _b : MIN_DRAWER_SIZE, MIN_DRAWER_SIZE);
254
+ })
255
+ .reduce((acc, curr) => acc + curr, 0);
256
+ if (activeDrawer) {
257
+ result += Math.min((_a = activeDrawer === null || activeDrawer === void 0 ? void 0 : activeDrawer.defaultSize) !== null && _a !== void 0 ? _a : MIN_DRAWER_SIZE, MIN_DRAWER_SIZE);
258
+ }
259
+ return result;
260
+ };
261
+ const totalActiveDrawersMinSize = getTotalActiveDrawersMinSize();
262
+ useEffect(() => {
263
+ if (isMobile) {
264
+ return;
265
+ }
266
+ const activeNavigationWidth = !navigationHide && navigationOpen ? navigationWidth : 0;
267
+ const scrollWidth = activeNavigationWidth + CONTENT_PADDING + totalActiveDrawersMinSize;
268
+ const hasHorizontalScroll = scrollWidth > placement.inlineSize;
269
+ if (hasHorizontalScroll) {
270
+ if (!navigationHide && navigationOpen) {
271
+ onNavigationToggle(false);
272
+ return;
273
+ }
274
+ closeFirstDrawer();
275
+ }
276
+ }, [
277
+ totalActiveDrawersMinSize,
278
+ closeFirstDrawer,
279
+ isMobile,
280
+ navigationHide,
281
+ navigationOpen,
282
+ navigationWidth,
283
+ onNavigationToggle,
284
+ placement.inlineSize,
285
+ ]);
286
+ /**
287
+ * Returns true if the AppLayout is nested
288
+ * Does not apply to iframe
289
+ */
290
+ const getIsNestedInAppLayout = (element) => {
291
+ var _a;
292
+ let currentElement = (_a = element === null || element === void 0 ? void 0 : element.parentElement) !== null && _a !== void 0 ? _a : null;
293
+ // this traverse is needed only for JSDOM
294
+ // in real browsers the globalVar will be propagated to all descendants and this loops exits after initial iteration
295
+ while (currentElement) {
296
+ if (getComputedStyle(currentElement).getPropertyValue(globalVars.stickyVerticalTopOffset)) {
297
+ return true;
298
+ }
299
+ currentElement = currentElement.parentElement;
300
+ }
301
+ return false;
302
+ };
303
+ const splitPanelOffsets = computeSplitPanelOffsets({
304
+ placement,
305
+ hasSplitPanel: !!splitPanel,
306
+ splitPanelOpen,
307
+ splitPanelPosition,
308
+ splitPanelFullHeight: splitPanelReportedSize,
309
+ splitPanelHeaderHeight: splitPanelHeaderBlockSize,
310
+ });
311
+ return {
312
+ rootRef,
313
+ isIntersecting,
314
+ appLayoutInternals,
315
+ splitPanelInternals,
316
+ widgetizedState: Object.assign(Object.assign({}, appLayoutInternals), { isNested,
317
+ navigationAnimationDisabled,
318
+ verticalOffsets,
319
+ splitPanelOffsets }),
320
+ };
321
+ };
322
+ //# sourceMappingURL=use-app-layout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-app-layout.js","sourceRoot":"","sources":["../../../../../src/app-layout/visual-refresh-toolbar/state/use-app-layout.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAgB,WAAW,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE3G,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,+CAA+C,CAAC;AAG7G,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;A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gBACzF,OAAO,IAAI,CAAC;aACb;YACD,cAAc,GAAG,cAAc,CAAC,aAAa,CAAC;SAC/C;QAED,OAAO,KAAK,CAAC;IACf,CAAC,CAAC;IAEF,MAAM,iBAAiB,GAAG,wBAAwB,CAAC;QACjD,SAAS;QACT,aAAa,EAAE,CAAC,CAAC,UAAU;QAC3B,cAAc;QACd,kBAAkB;QAClB,oBAAoB,EAAE,sBAAsB;QAC5C,sBAAsB,EAAE,yBAAyB;KAClD,CAAC,CAAC;IAEH,OAAO;QACL,OAAO;QACP,cAAc;QACd,kBAAkB;QAClB,mBAAmB;QACnB,eAAe,kCACV,kBAAkB,KACrB,QAAQ;YACR,2BAA2B;YAC3B,eAAe;YACf,iBAAiB,GAClB;KACF,CAAC;AACJ,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { ForwardedRef, useCallback, useEffect, useImperativeHandle, useRef, useState } from 'react';\n\nimport { useMergeRefs, useStableCallback, useUniqueId } from '@cloudscape-design/component-toolkit/internal';\n\nimport { SplitPanelSideToggleProps } from '../../../internal/context/split-panel-context';\nimport { fireNonCancelableEvent } from '../../../internal/events';\nimport { useControllable } from '../../../internal/hooks/use-controllable';\nimport { useIntersectionObserver } from '../../../internal/hooks/use-intersection-observer';\nimport { useMobile } from '../../../internal/hooks/use-mobile';\nimport { useGetGlobalBreadcrumbs } from '../../../internal/plugins/helpers/use-global-breadcrumbs';\nimport globalVars from '../../../internal/styles/global-vars';\nimport { getSplitPanelDefaultSize } from '../../../split-panel/utils/size-utils';\nimport { AppLayoutProps } from '../../interfaces';\nimport { SplitPanelProviderProps } from '../../split-panel';\nimport { MIN_DRAWER_SIZE, OnChangeParams, useDrawers } from '../../utils/use-drawers';\nimport { useAsyncFocusControl, useMultipleFocusControl } from '../../utils/use-focus-control';\nimport { useGlobalScrollPadding } from '../../utils/use-global-scroll-padding';\nimport { useSplitPanelFocusControl } from '../../utils/use-split-panel-focus-control';\nimport {\n computeHorizontalLayout,\n computeSplitPanelOffsets,\n computeVerticalLayout,\n CONTENT_PADDING,\n} from '../compute-layout';\nimport { AppLayoutState } from '../interfaces';\nimport { AppLayoutInternalProps, AppLayoutInternals } from '../interfaces';\n\nexport const useAppLayout = (\n hasToolbar: boolean,\n {\n ariaLabels,\n navigationOpen,\n navigationWidth,\n navigation,\n navigationHide,\n onNavigationChange,\n tools,\n toolsOpen: controlledToolsOpen,\n onToolsChange,\n toolsHide,\n toolsWidth,\n headerVariant,\n breadcrumbs,\n stickyNotifications,\n splitPanelPreferences: controlledSplitPanelPreferences,\n splitPanelOpen: controlledSplitPanelOpen,\n splitPanel,\n splitPanelSize: controlledSplitPanelSize,\n onSplitPanelToggle,\n onSplitPanelResize,\n onSplitPanelPreferencesChange,\n minContentWidth,\n placement,\n navigationTriggerHide,\n ...rest\n }: AppLayoutInternalProps,\n forwardRef: ForwardedRef<AppLayoutProps.Ref>\n): AppLayoutState => {\n const isMobile = useMobile();\n const splitPanelControlId = useUniqueId('split-panel');\n const [toolbarState, setToolbarState] = useState<'show' | 'hide'>('show');\n const [toolbarHeight, setToolbarHeight] = useState(0);\n const [notificationsHeight, setNotificationsHeight] = useState(0);\n const [navigationAnimationDisabled, setNavigationAnimationDisabled] = useState(true);\n const [splitPanelAnimationDisabled, setSplitPanelAnimationDisabled] = useState(true);\n const [isNested, setIsNested] = useState(false);\n const rootRefInternal = useRef<HTMLDivElement>(null);\n // This workaround ensures the ref is defined before checking if the app layout is nested.\n // On initial render, the ref might be undefined because this component loads asynchronously via the widget API.\n const onMountRootRef = useCallback(node => {\n setIsNested(getIsNestedInAppLayout(node));\n }, []);\n\n const [toolsOpen = false, setToolsOpen] = useControllable(controlledToolsOpen, onToolsChange, false, {\n componentName: 'AppLayout',\n controlledProp: 'toolsOpen',\n changeHandler: 'onToolsChange',\n });\n const onToolsToggle = (open: boolean) => {\n setToolsOpen(open);\n drawersFocusControl.setFocus();\n fireNonCancelableEvent(onToolsChange, { open });\n };\n\n const onGlobalDrawerFocus = (drawerId: string, open: boolean) => {\n globalDrawersFocusControl.setFocus({ force: true, drawerId, open });\n };\n\n const onAddNewActiveDrawer = (drawerId: string) => {\n // If a local drawer is already open, and we attempt to open a new one,\n // it will replace the existing one instead of opening an additional drawer,\n // since only one local drawer is supported. Therefore, layout calculations are not necessary.\n if (activeDrawer && drawers?.find(drawer => drawer.id === drawerId)) {\n return;\n }\n // get the size of drawerId. it could be either local or global drawer\n const combinedDrawers = [...(drawers || []), ...globalDrawers];\n const newDrawer = combinedDrawers.find(drawer => drawer.id === drawerId);\n if (!newDrawer) {\n return;\n }\n const newDrawerSize = Math.min(newDrawer.defaultSize ?? drawerSizes[drawerId] ?? MIN_DRAWER_SIZE, MIN_DRAWER_SIZE);\n // check if the active drawers could be resized to fit the new drawers\n // to do this, we need to take all active drawers, sum up their min sizes, truncate it from resizableSpaceAvailable\n // and compare a given number with the new drawer id min size\n\n // the total size of all global drawers resized to their min size\n const availableSpaceForNewDrawer = resizableSpaceAvailable - totalActiveDrawersMinSize;\n if (availableSpaceForNewDrawer >= newDrawerSize) {\n return;\n }\n\n // now we made sure we cannot accommodate the new drawer with existing ones\n closeFirstDrawer();\n };\n\n const {\n drawers,\n activeDrawer,\n minDrawerSize,\n minGlobalDrawersSizes,\n activeDrawerSize,\n ariaLabelsWithDrawers,\n globalDrawers,\n activeGlobalDrawers,\n activeGlobalDrawersIds,\n activeGlobalDrawersSizes,\n drawerSizes,\n drawersOpenQueue,\n onActiveDrawerChange,\n onActiveDrawerResize,\n onActiveGlobalDrawersChange,\n expandedDrawerId,\n setExpandedDrawerId,\n } = useDrawers({ ...rest, onGlobalDrawerFocus, onAddNewActiveDrawer }, ariaLabels, {\n ariaLabels,\n toolsHide,\n toolsOpen,\n tools,\n toolsWidth,\n onToolsToggle,\n });\n\n const onActiveDrawerChangeHandler = (\n drawerId: string | null,\n params: OnChangeParams = { initiatedByUserAction: true }\n ) => {\n onActiveDrawerChange(drawerId, params);\n drawersFocusControl.setFocus();\n };\n\n const [splitPanelOpen = false, setSplitPanelOpen] = useControllable(\n controlledSplitPanelOpen,\n onSplitPanelToggle,\n false,\n {\n componentName: 'AppLayout',\n controlledProp: 'splitPanelOpen',\n changeHandler: 'onSplitPanelToggle',\n }\n );\n\n const onSplitPanelToggleHandler = () => {\n setSplitPanelAnimationDisabled(false);\n setSplitPanelOpen(!splitPanelOpen);\n splitPanelFocusControl.setLastInteraction({ type: splitPanelOpen ? 'close' : 'open' });\n fireNonCancelableEvent(onSplitPanelToggle, { open: !splitPanelOpen });\n };\n\n const [splitPanelPreferences, setSplitPanelPreferences] = useControllable(\n controlledSplitPanelPreferences,\n onSplitPanelPreferencesChange,\n undefined,\n {\n componentName: 'AppLayout',\n controlledProp: 'splitPanelPreferences',\n changeHandler: 'onSplitPanelPreferencesChange',\n }\n );\n\n const onSplitPanelPreferencesChangeHandler = (detail: AppLayoutProps.SplitPanelPreferences) => {\n setSplitPanelPreferences(detail);\n splitPanelFocusControl.setLastInteraction({ type: 'position' });\n fireNonCancelableEvent(onSplitPanelPreferencesChange, detail);\n };\n\n const [splitPanelSize = 0, setSplitPanelSize] = useControllable(\n controlledSplitPanelSize,\n onSplitPanelResize,\n getSplitPanelDefaultSize(splitPanelPreferences?.position ?? 'bottom'),\n { componentName: 'AppLayout', controlledProp: 'splitPanelSize', changeHandler: 'onSplitPanelResize' }\n );\n\n const [splitPanelReportedSize, setSplitPanelReportedSize] = useState(0);\n const [splitPanelHeaderBlockSize, setSplitPanelHeaderBlockSize] = useState(0);\n\n const onSplitPanelResizeHandler = (size: number) => {\n setSplitPanelSize(size);\n fireNonCancelableEvent(onSplitPanelResize, { size });\n };\n\n const [splitPanelToggleConfig, setSplitPanelToggleConfig] = useState<SplitPanelSideToggleProps>({\n ariaLabel: undefined,\n displayed: false,\n });\n\n const globalDrawersFocusControl = useMultipleFocusControl(true, activeGlobalDrawersIds);\n const drawersFocusControl = useAsyncFocusControl(!!activeDrawer?.id, true, activeDrawer?.id);\n const navigationFocusControl = useAsyncFocusControl(navigationOpen, navigationTriggerHide);\n const splitPanelFocusControl = useSplitPanelFocusControl([splitPanelPreferences, splitPanelOpen]);\n\n const onNavigationToggle = useStableCallback((open: boolean) => {\n setNavigationAnimationDisabled(false);\n navigationFocusControl.setFocus();\n fireNonCancelableEvent(onNavigationChange, { open });\n });\n\n useImperativeHandle(forwardRef, () => ({\n closeNavigationIfNecessary: () => isMobile && onNavigationToggle(false),\n openTools: () => onToolsToggle(true),\n focusToolsClose: () => drawersFocusControl.setFocus(true),\n focusActiveDrawer: () => drawersFocusControl.setFocus(true),\n focusSplitPanel: () => splitPanelFocusControl.setLastInteraction({ type: 'open' }),\n focusNavigation: () => navigationFocusControl.setFocus(true),\n }));\n\n const resolvedStickyNotifications = !!stickyNotifications && !isMobile;\n //navigation must be null if hidden so toolbar knows to hide the toggle button\n const resolvedNavigation = navigationHide ? null : navigation || <></>;\n //navigation must not be open if navigationHide is true\n const resolvedNavigationOpen = !!resolvedNavigation && navigationOpen;\n const {\n maxDrawerSize,\n maxSplitPanelSize,\n splitPanelForcedPosition,\n splitPanelPosition,\n maxGlobalDrawersSizes,\n resizableSpaceAvailable,\n } = computeHorizontalLayout({\n activeDrawerSize: activeDrawer ? activeDrawerSize : 0,\n splitPanelSize,\n minContentWidth,\n navigationOpen: resolvedNavigationOpen,\n navigationWidth,\n placement,\n splitPanelOpen,\n splitPanelPosition: splitPanelPreferences?.position,\n isMobile,\n activeGlobalDrawersSizes,\n });\n\n const verticalOffsets = computeVerticalLayout({\n topOffset: placement.insetBlockStart,\n hasVisibleToolbar: hasToolbar && toolbarState !== 'hide',\n notificationsHeight: notificationsHeight ?? 0,\n toolbarHeight: toolbarHeight ?? 0,\n stickyNotifications: resolvedStickyNotifications,\n });\n\n const { ref: intersectionObserverRef, isIntersecting } = useIntersectionObserver({ initialState: true });\n\n const rootRef = useMergeRefs(rootRefInternal, intersectionObserverRef, onMountRootRef);\n\n const discoveredBreadcrumbs = useGetGlobalBreadcrumbs(hasToolbar && !breadcrumbs);\n\n useGlobalScrollPadding(verticalOffsets.header ?? 0);\n\n const appLayoutInternals: AppLayoutInternals = {\n ariaLabels: ariaLabelsWithDrawers,\n headerVariant,\n isMobile,\n breadcrumbs,\n discoveredBreadcrumbs,\n stickyNotifications: resolvedStickyNotifications,\n navigationOpen: resolvedNavigationOpen,\n navigation: resolvedNavigation,\n navigationFocusControl,\n activeDrawer,\n activeDrawerSize,\n minDrawerSize,\n maxDrawerSize,\n minGlobalDrawersSizes,\n maxGlobalDrawersSizes,\n drawers: drawers!,\n globalDrawers,\n activeGlobalDrawers,\n activeGlobalDrawersIds,\n activeGlobalDrawersSizes,\n onActiveGlobalDrawersChange,\n drawersFocusControl,\n globalDrawersFocusControl,\n splitPanelPosition,\n splitPanelToggleConfig,\n splitPanelOpen,\n splitPanelControlId,\n splitPanelFocusControl,\n placement,\n toolbarState,\n setToolbarState,\n verticalOffsets,\n drawersOpenQueue,\n setToolbarHeight,\n setNotificationsHeight,\n onSplitPanelToggle: onSplitPanelToggleHandler,\n onNavigationToggle,\n onActiveDrawerChange: onActiveDrawerChangeHandler,\n onActiveDrawerResize,\n splitPanelAnimationDisabled,\n expandedDrawerId,\n setExpandedDrawerId,\n };\n\n const splitPanelInternals: SplitPanelProviderProps = {\n bottomOffset: 0,\n getMaxHeight: useStableCallback(() => {\n const availableHeight =\n document.documentElement.clientHeight - placement.insetBlockStart - placement.insetBlockEnd;\n // If the page is likely zoomed in at 200%, allow the split panel to fill the content area.\n return availableHeight < 400 ? availableHeight - 40 : availableHeight - 250;\n }),\n maxWidth: maxSplitPanelSize,\n isForcedPosition: splitPanelForcedPosition,\n isOpen: splitPanelOpen,\n leftOffset: 0,\n onPreferencesChange: onSplitPanelPreferencesChangeHandler,\n onResize: onSplitPanelResizeHandler,\n onToggle: onSplitPanelToggleHandler,\n position: splitPanelPosition,\n reportSize: useStableCallback(size => setSplitPanelReportedSize(size)),\n reportHeaderHeight: useStableCallback(size => setSplitPanelHeaderBlockSize(size)),\n headerHeight: splitPanelHeaderBlockSize,\n rightOffset: 0,\n size: splitPanelSize,\n topOffset: 0,\n setSplitPanelToggle: setSplitPanelToggleConfig,\n refs: splitPanelFocusControl.refs,\n };\n\n const closeFirstDrawer = useStableCallback(() => {\n const drawerToClose = drawersOpenQueue[drawersOpenQueue.length - 1];\n if (activeDrawer && activeDrawer?.id === drawerToClose) {\n onActiveDrawerChange(null, { initiatedByUserAction: true });\n } else if (activeGlobalDrawersIds.includes(drawerToClose)) {\n onActiveGlobalDrawersChange(drawerToClose, { initiatedByUserAction: true });\n }\n });\n\n useEffect(() => {\n // Close navigation drawer on mobile so that the main content is visible\n if (isMobile) {\n onNavigationToggle(false);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [isMobile]);\n\n const getTotalActiveDrawersMinSize = () => {\n const combinedDrawers = [...(drawers || []), ...globalDrawers];\n let result = activeGlobalDrawersIds\n .map(activeDrawerId =>\n Math.min(\n combinedDrawers.find(drawer => drawer.id === activeDrawerId)?.defaultSize ?? MIN_DRAWER_SIZE,\n MIN_DRAWER_SIZE\n )\n )\n .reduce((acc, curr) => acc + curr, 0);\n if (activeDrawer) {\n result += Math.min(activeDrawer?.defaultSize ?? MIN_DRAWER_SIZE, MIN_DRAWER_SIZE);\n }\n\n return result;\n };\n\n const totalActiveDrawersMinSize = getTotalActiveDrawersMinSize();\n\n useEffect(() => {\n if (isMobile) {\n return;\n }\n\n const activeNavigationWidth = !navigationHide && navigationOpen ? navigationWidth : 0;\n const scrollWidth = activeNavigationWidth + CONTENT_PADDING + totalActiveDrawersMinSize;\n const hasHorizontalScroll = scrollWidth > placement.inlineSize;\n if (hasHorizontalScroll) {\n if (!navigationHide && navigationOpen) {\n onNavigationToggle(false);\n return;\n }\n\n closeFirstDrawer();\n }\n }, [\n totalActiveDrawersMinSize,\n closeFirstDrawer,\n isMobile,\n navigationHide,\n navigationOpen,\n navigationWidth,\n onNavigationToggle,\n placement.inlineSize,\n ]);\n\n /**\n * Returns true if the AppLayout is nested\n * Does not apply to iframe\n */\n const getIsNestedInAppLayout = (element: HTMLElement | null): boolean => {\n let currentElement: Element | null = element?.parentElement ?? null;\n\n // this traverse is needed only for JSDOM\n // in real browsers the globalVar will be propagated to all descendants and this loops exits after initial iteration\n while (currentElement) {\n if (getComputedStyle(currentElement).getPropertyValue(globalVars.stickyVerticalTopOffset)) {\n return true;\n }\n currentElement = currentElement.parentElement;\n }\n\n return false;\n };\n\n const splitPanelOffsets = computeSplitPanelOffsets({\n placement,\n hasSplitPanel: !!splitPanel,\n splitPanelOpen,\n splitPanelPosition,\n splitPanelFullHeight: splitPanelReportedSize,\n splitPanelHeaderHeight: splitPanelHeaderBlockSize,\n });\n\n return {\n rootRef,\n isIntersecting,\n appLayoutInternals,\n splitPanelInternals,\n widgetizedState: {\n ...appLayoutInternals,\n isNested,\n navigationAnimationDisabled,\n verticalOffsets,\n splitPanelOffsets,\n },\n };\n};\n"]}
@@ -0,0 +1,3 @@
1
+ import { AppLayoutInternalProps, AppLayoutState } from '../interfaces';
2
+ import { SkeletonSlotsAttributes } from '../skeleton/interfaces';
3
+ export declare const useSkeletonSlotsAttributes: (hasToolbar: boolean, appLayoutProps: AppLayoutInternalProps, appLayoutState: AppLayoutState) => SkeletonSlotsAttributes;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-skeleton-slots-attributes.d.ts","sourceRoot":"","sources":["../../../../../src/app-layout/visual-refresh-toolbar/state/use-skeleton-slots-attributes.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAOjE,eAAO,MAAM,0BAA0B,eACzB,OAAO,kBACH,sBAAsB,kBACtB,cAAc,KAC7B,uBAsEF,CAAC"}
@@ -0,0 +1,59 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import clsx from 'clsx';
4
+ import customCssProps from '../../../internal/generated/custom-css-properties';
5
+ import { useMobile } from '../../../internal/hooks/use-mobile';
6
+ import globalVars from '../../../internal/styles/global-vars';
7
+ import testutilStyles from '../../test-classes/styles.css.js';
8
+ import styles from '../skeleton/styles.css.js';
9
+ const contentTypeCustomWidths = ['dashboard', 'cards', 'table'];
10
+ export const useSkeletonSlotsAttributes = (hasToolbar, appLayoutProps, appLayoutState) => {
11
+ var _a, _b, _c;
12
+ const { isNested, activeDrawerSize, navigationOpen, verticalOffsets, splitPanelOffsets, activeDrawer, expandedDrawerId, } = (_a = appLayoutState.widgetizedState) !== null && _a !== void 0 ? _a : {};
13
+ const { contentType, placement, maxContentWidth, navigationWidth, minContentWidth, disableContentPaddings } = appLayoutProps;
14
+ const isMobile = useMobile();
15
+ const toolsOpen = !!activeDrawer;
16
+ const drawerExpandedMode = !!expandedDrawerId;
17
+ const anyPanelOpen = navigationOpen || toolsOpen;
18
+ const isMaxWidth = maxContentWidth === Number.MAX_VALUE || maxContentWidth === Number.MAX_SAFE_INTEGER;
19
+ const wrapperElAttributes = {
20
+ className: clsx(styles.root, testutilStyles.root, {
21
+ [styles['has-adaptive-widths-default']]: !contentTypeCustomWidths.includes(contentType),
22
+ [styles['has-adaptive-widths-dashboard']]: contentType === 'dashboard',
23
+ [styles['drawer-expanded-mode']]: drawerExpandedMode,
24
+ }),
25
+ style: {
26
+ minBlockSize: isNested ? '100%' : `calc(100vh - ${placement.insetBlockStart + placement.insetBlockEnd}px)`,
27
+ [customCssProps.maxContentWidth]: isMaxWidth ? '100%' : maxContentWidth ? `${maxContentWidth}px` : '',
28
+ [customCssProps.navigationWidth]: `${navigationWidth}px`,
29
+ [customCssProps.toolsWidth]: `${activeDrawerSize}px`,
30
+ },
31
+ 'data-awsui-app-layout-widget-loaded': true,
32
+ };
33
+ const mainElAttributes = {
34
+ className: clsx(styles['main-landmark'], isMobile && anyPanelOpen && styles['unfocusable-mobile'], drawerExpandedMode && styles.hidden),
35
+ };
36
+ const contentWrapperElAttributes = {
37
+ className: clsx(styles.main, { [styles['main-disable-paddings']]: disableContentPaddings }),
38
+ style: Object.assign(Object.assign({ paddingBlockEnd: splitPanelOffsets === null || splitPanelOffsets === void 0 ? void 0 : splitPanelOffsets.mainContentPaddingBlockEnd }, (hasToolbar || !isNested
39
+ ? {
40
+ [globalVars.stickyVerticalTopOffset]: `${(_b = verticalOffsets === null || verticalOffsets === void 0 ? void 0 : verticalOffsets.header) !== null && _b !== void 0 ? _b : 0}px`,
41
+ [globalVars.stickyVerticalBottomOffset]: `${(_c = splitPanelOffsets === null || splitPanelOffsets === void 0 ? void 0 : splitPanelOffsets.stickyVerticalBottomOffset) !== null && _c !== void 0 ? _c : 0}px`,
42
+ }
43
+ : {})), (!isMobile ? { minWidth: `${minContentWidth}px` } : {})),
44
+ };
45
+ const contentHeaderElAttributes = {
46
+ className: styles['content-header'],
47
+ };
48
+ const contentElAttributes = {
49
+ className: clsx(styles.content, testutilStyles.content),
50
+ };
51
+ return {
52
+ wrapperElAttributes,
53
+ mainElAttributes,
54
+ contentWrapperElAttributes,
55
+ contentHeaderElAttributes,
56
+ contentElAttributes,
57
+ };
58
+ };
59
+ //# sourceMappingURL=use-skeleton-slots-attributes.js.map