@cloudscape-design/components 3.0.815 → 3.0.816

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.
@@ -1,9 +1,9 @@
1
- import { DrawerConfig as RuntimeDrawerConfig } from '../internal/plugins/controllers/drawers';
2
- import { AppLayoutProps } from './interfaces';
1
+ import { DrawerConfig as RuntimeDrawerConfig } from '../../internal/plugins/controllers/drawers';
2
+ import { AppLayoutProps } from '../interfaces';
3
3
  export interface DrawersLayout {
4
4
  global: Array<AppLayoutProps.Drawer>;
5
5
  localBefore: Array<AppLayoutProps.Drawer>;
6
6
  localAfter: Array<AppLayoutProps.Drawer>;
7
7
  }
8
8
  export declare function convertRuntimeDrawers(localDrawers: Array<RuntimeDrawerConfig>, globalDrawers: Array<RuntimeDrawerConfig>): DrawersLayout;
9
- //# sourceMappingURL=runtime-api.d.ts.map
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/app-layout/runtime-drawer/index.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,IAAI,mBAAmB,EAAE,MAAM,4CAA4C,CAAC;AAEjG,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAG/C,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;IACrC,WAAW,EAAE,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;IAC1C,UAAU,EAAE,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;CAC1C;AAqED,wBAAgB,qBAAqB,CACnC,YAAY,EAAE,KAAK,CAAC,mBAAmB,CAAC,EACxC,aAAa,EAAE,KAAK,CAAC,mBAAmB,CAAC,GACxC,aAAa,CAQf"}
@@ -1,10 +1,34 @@
1
1
  import { __rest } from "tslib";
2
2
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
3
  // SPDX-License-Identifier: Apache-2.0
4
- import React from 'react';
5
- import { fireNonCancelableEvent } from '../internal/events';
6
- import { RuntimeContentWrapper } from '../internal/plugins/helpers';
7
- import { sortByPriority } from '../internal/plugins/helpers/utils';
4
+ import React, { useContext, useEffect, useRef } from 'react';
5
+ import { fireNonCancelableEvent } from '../../internal/events';
6
+ import { sortByPriority } from '../../internal/plugins/helpers/utils';
7
+ import { ActiveDrawersContext } from '../utils/visibility-context';
8
+ function RuntimeDrawerWrapper({ mountContent, unmountContent, id }) {
9
+ const ref = useRef(null);
10
+ const visibilityChangeCallback = useRef(null);
11
+ const activeDrawersIds = useContext(ActiveDrawersContext);
12
+ const isVisible = !!id && activeDrawersIds.includes(id);
13
+ useEffect(() => {
14
+ const container = ref.current;
15
+ mountContent(container, {
16
+ onVisibilityChange: cb => {
17
+ visibilityChangeCallback.current = cb;
18
+ },
19
+ });
20
+ return () => {
21
+ unmountContent(container);
22
+ visibilityChangeCallback.current = null;
23
+ };
24
+ // eslint-disable-next-line react-hooks/exhaustive-deps
25
+ }, []);
26
+ useEffect(() => {
27
+ var _a;
28
+ (_a = visibilityChangeCallback.current) === null || _a === void 0 ? void 0 : _a.call(visibilityChangeCallback, isVisible);
29
+ }, [isVisible]);
30
+ return React.createElement("div", { ref: ref });
31
+ }
8
32
  const mapRuntimeConfigToDrawer = (runtimeConfig) => {
9
33
  var _a;
10
34
  const { mountContent, unmountContent, trigger } = runtimeConfig, runtimeDrawer = __rest(runtimeConfig, ["mountContent", "unmountContent", "trigger"]);
@@ -14,7 +38,7 @@ const mapRuntimeConfigToDrawer = (runtimeConfig) => {
14
38
  // eslint-disable-next-line react/no-danger
15
39
  React.createElement("span", { dangerouslySetInnerHTML: { __html: trigger.iconSvg } })),
16
40
  }
17
- : undefined, content: (React.createElement(RuntimeContentWrapper, { key: runtimeDrawer.id, mountContent: mountContent, unmountContent: unmountContent, id: runtimeDrawer.id })), onResize: event => {
41
+ : undefined, content: (React.createElement(RuntimeDrawerWrapper, { key: runtimeDrawer.id, mountContent: mountContent, unmountContent: unmountContent, id: runtimeDrawer.id })), onResize: event => {
18
42
  fireNonCancelableEvent(runtimeDrawer.onResize, { size: event.detail.size, id: runtimeDrawer.id });
19
43
  } });
20
44
  };
@@ -27,4 +51,4 @@ export function convertRuntimeDrawers(localDrawers, globalDrawers) {
27
51
  localAfter: sorted.filter(item => { var _a; return ((_a = item.orderPriority) !== null && _a !== void 0 ? _a : 0) <= 0; }),
28
52
  };
29
53
  }
30
- //# sourceMappingURL=runtime-api.js.map
54
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/app-layout/runtime-drawer/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAE/D,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AAEtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAgBnE,SAAS,oBAAoB,CAAC,EAAE,YAAY,EAAE,cAAc,EAAE,EAAE,EAA8B;IAC5F,MAAM,GAAG,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IACzC,MAAM,wBAAwB,GAAG,MAAM,CAA4B,IAAI,CAAC,CAAC;IACzE,MAAM,gBAAgB,GAAG,UAAU,CAAC,oBAAoB,CAAC,CAAC;IAC1D,MAAM,SAAS,GAAG,CAAC,CAAC,EAAE,IAAI,gBAAgB,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAExD,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,SAAS,GAAG,GAAG,CAAC,OAAQ,CAAC;QAC/B,YAAY,CAAC,SAAS,EAAE;YACtB,kBAAkB,EAAE,EAAE,CAAC,EAAE;gBAC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AE,EAAE,aAAa,CAAC,EAAE,EAAE,CAAC,CAAC;QACpG,CAAC,IACD;AACJ,CAAC,CAAC;AAEF,MAAM,UAAU,qBAAqB,CACnC,YAAwC,EACxC,aAAyC;IAEzC,MAAM,SAAS,GAAG,YAAY,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;IAC7D,MAAM,MAAM,GAAG,cAAc,CAAC,SAAS,CAAC,CAAC;IACzC,OAAO;QACL,MAAM,EAAE,cAAc,CAAC,aAAa,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;QACnE,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,WAAC,OAAA,CAAC,MAAA,IAAI,CAAC,aAAa,mCAAI,CAAC,CAAC,GAAG,CAAC,CAAA,EAAA,CAAC;QACjE,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,WAAC,OAAA,CAAC,MAAA,IAAI,CAAC,aAAa,mCAAI,CAAC,CAAC,IAAI,CAAC,CAAA,EAAA,CAAC;KAClE,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useContext, useEffect, useRef } from 'react';\n\nimport { fireNonCancelableEvent } from '../../internal/events';\nimport { DrawerConfig as RuntimeDrawerConfig } from '../../internal/plugins/controllers/drawers';\nimport { sortByPriority } from '../../internal/plugins/helpers/utils';\nimport { AppLayoutProps } from '../interfaces';\nimport { ActiveDrawersContext } from '../utils/visibility-context';\n\nexport interface DrawersLayout {\n global: Array<AppLayoutProps.Drawer>;\n localBefore: Array<AppLayoutProps.Drawer>;\n localAfter: Array<AppLayoutProps.Drawer>;\n}\n\ntype VisibilityCallback = (isVisible: boolean) => void;\n\ninterface RuntimeContentWrapperProps {\n id?: string;\n mountContent: RuntimeDrawerConfig['mountContent'];\n unmountContent: RuntimeDrawerConfig['unmountContent'];\n}\n\nfunction RuntimeDrawerWrapper({ mountContent, unmountContent, id }: RuntimeContentWrapperProps) {\n const ref = useRef<HTMLDivElement>(null);\n const visibilityChangeCallback = useRef<VisibilityCallback | null>(null);\n const activeDrawersIds = useContext(ActiveDrawersContext);\n const isVisible = !!id && activeDrawersIds.includes(id);\n\n useEffect(() => {\n const container = ref.current!;\n mountContent(container, {\n onVisibilityChange: cb => {\n visibilityChangeCallback.current = cb;\n },\n });\n return () => {\n unmountContent(container);\n visibilityChangeCallback.current = null;\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n useEffect(() => {\n visibilityChangeCallback.current?.(isVisible);\n }, [isVisible]);\n\n return <div ref={ref}></div>;\n}\n\nconst mapRuntimeConfigToDrawer = (\n runtimeConfig: RuntimeDrawerConfig\n): AppLayoutProps.Drawer & {\n orderPriority?: number;\n} => {\n const { mountContent, unmountContent, trigger, ...runtimeDrawer } = runtimeConfig;\n\n return {\n ...runtimeDrawer,\n ariaLabels: { drawerName: runtimeDrawer.ariaLabels.content ?? '', ...runtimeDrawer.ariaLabels },\n trigger: trigger\n ? {\n iconSvg: (\n // eslint-disable-next-line react/no-danger\n <span dangerouslySetInnerHTML={{ __html: trigger.iconSvg }} />\n ),\n }\n : undefined,\n content: (\n <RuntimeDrawerWrapper\n key={runtimeDrawer.id}\n mountContent={mountContent}\n unmountContent={unmountContent}\n id={runtimeDrawer.id}\n />\n ),\n onResize: event => {\n fireNonCancelableEvent(runtimeDrawer.onResize, { size: event.detail.size, id: runtimeDrawer.id });\n },\n };\n};\n\nexport function convertRuntimeDrawers(\n localDrawers: Array<RuntimeDrawerConfig>,\n globalDrawers: Array<RuntimeDrawerConfig>\n): DrawersLayout {\n const converted = localDrawers.map(mapRuntimeConfigToDrawer);\n const sorted = sortByPriority(converted);\n return {\n global: sortByPriority(globalDrawers.map(mapRuntimeConfigToDrawer)),\n localBefore: sorted.filter(item => (item.orderPriority ?? 0) > 0),\n localAfter: sorted.filter(item => (item.orderPriority ?? 0) <= 0),\n };\n}\n"]}
@@ -6,7 +6,7 @@ import { fireNonCancelableEvent } from '../../internal/events';
6
6
  import { useControllable } from '../../internal/hooks/use-controllable';
7
7
  import { awsuiPluginsInternal } from '../../internal/plugins/api';
8
8
  import { sortByPriority } from '../../internal/plugins/helpers/utils';
9
- import { convertRuntimeDrawers } from '../runtime-api';
9
+ import { convertRuntimeDrawers } from '../runtime-drawer';
10
10
  import { togglesConfig } from '../toggles';
11
11
  export const TOOLS_DRAWER_ID = 'awsui-internal-tools';
12
12
  function getToolsDrawerItem(props) {
@@ -1 +1 @@
1
- {"version":3,"file":"use-drawers.js","sourceRoot":"","sources":["../../../../src/app-layout/utils/use-drawers.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAc,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAElF,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AAEtE,OAAO,EAAE,qBAAqB,EAAiB,MAAM,gBAAgB,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C,MAAM,CAAC,MAAM,eAAe,GAAG,sBAAsB,CAAC;AAYtD,SAAS,kBAAkB,CAAC,KAAiB;IAC3C,IAAI,KAAK,CAAC,SAAS,EAAE;QACnB,OAAO,IAAI,CAAC;KACb;IACD,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,aAAa,CAAC,KAAK,CAAC;IACpD,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IACzE,OAAO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EAAE,oBAAoB;QACnC,mBAAmB,EAAE,mBAAmB;QACxC,sBAAsB;QACtB,wBAAwB;QACxB,gBAAgB;QAChB,aAAa;QACb,qBAAqB;QACrB,WAAW;QACX,gBAAgB,EAAE,gBAAgB,CAAC,OAAO;QAC1C,oBAAoB;QACpB,oBAAoB;QACpB,2BAA2B;KAC5B,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 { useStableCallback } from '@cloudscape-design/component-toolkit/internal';\n\nimport { fireNonCancelableEvent } from '../../internal/events';\nimport { useControllable } from '../../internal/hooks/use-controllable';\nimport { awsuiPluginsInternal } from '../../internal/plugins/api';\nimport { sortByPriority } from '../../internal/plugins/helpers/utils';\nimport { AppLayoutProps } from '../interfaces';\nimport { convertRuntimeDrawers, DrawersLayout } from '../runtime-api';\nimport { togglesConfig } from '../toggles';\n\nexport const TOOLS_DRAWER_ID = 'awsui-internal-tools';\n\ninterface ToolsProps {\n toolsHide: boolean | undefined;\n toolsOpen: boolean | undefined;\n toolsWidth: number;\n tools: React.ReactNode | undefined;\n onToolsToggle: (newOpen: boolean) => void;\n ariaLabels: AppLayoutProps.Labels | undefined;\n disableDrawersMerge?: boolean;\n}\n\nfunction getToolsDrawerItem(props: ToolsProps): AppLayoutProps.Drawer | null {\n if (props.toolsHide) {\n return null;\n }\n const { iconName, getLabels } = togglesConfig.tools;\n const { mainLabel, closeLabel, openLabel } = getLabels(props.ariaLabels);\n return {\n id: TOOLS_DRAWER_ID,\n content: props.tools,\n resizable: false,\n ariaLabels: {\n triggerButton: openLabel,\n closeButton: closeLabel,\n drawerName: mainLabel ?? '',\n },\n trigger: {\n iconName: iconName,\n },\n };\n}\n\nconst DRAWERS_LIMIT = 2;\n\nfunction useRuntimeDrawers(\n disableRuntimeDrawers: boolean | undefined,\n activeDrawerId: string | null,\n onActiveDrawerChange: (newDrawerId: string | null) => void,\n activeGlobalDrawersIds: Array<string>,\n onActiveGlobalDrawersChange: (newDrawerId: string) => void,\n drawers: AppLayoutProps.Drawer[]\n) {\n const [runtimeDrawers, setRuntimeDrawers] = useState<DrawersLayout>({\n localBefore: [],\n localAfter: [],\n global: [],\n });\n const onLocalDrawerChangeStable = useStableCallback(onActiveDrawerChange);\n const onGlobalDrawersChangeStable = useStableCallback(onActiveGlobalDrawersChange);\n\n const localDrawerWasOpenRef = useRef(false);\n localDrawerWasOpenRef.current = localDrawerWasOpenRef.current || !!activeDrawerId;\n const activeGlobalDrawersIdsRef = useRef<Array<string>>([]);\n activeGlobalDrawersIdsRef.current = activeGlobalDrawersIds;\n\n useEffect(() => {\n if (disableRuntimeDrawers) {\n return;\n }\n const unsubscribe = awsuiPluginsInternal.appLayout.onDrawersRegistered(drawers => {\n const localDrawers = drawers.filter(drawer => drawer.type !== 'global');\n const globalDrawers = drawers.filter(drawer => drawer.type === 'global');\n setRuntimeDrawers(convertRuntimeDrawers(localDrawers, globalDrawers));\n if (!localDrawerWasOpenRef.current) {\n const defaultActiveLocalDrawer = sortByPriority(localDrawers).find(drawer => drawer.defaultActive);\n if (defaultActiveLocalDrawer) {\n onLocalDrawerChangeStable(defaultActiveLocalDrawer.id);\n }\n }\n\n const drawersNotActiveByDefault = globalDrawers.filter(drawer => !drawer.defaultActive);\n const hasDrawersOpenByUserAction = drawersNotActiveByDefault.find(drawer =>\n activeGlobalDrawersIdsRef.current.includes(drawer.id)\n );\n if (hasDrawersOpenByUserAction || activeGlobalDrawersIdsRef.current.length === DRAWERS_LIMIT) {\n return;\n }\n\n const defaultActiveGlobalDrawers = sortByPriority(globalDrawers).filter(\n drawer => !activeGlobalDrawersIdsRef.current.includes(drawer.id) && drawer.defaultActive\n );\n defaultActiveGlobalDrawers.forEach(drawer => {\n onGlobalDrawersChangeStable(drawer.id);\n });\n });\n return () => {\n unsubscribe();\n setRuntimeDrawers({ localBefore: [], localAfter: [], global: [] });\n };\n }, [disableRuntimeDrawers, onGlobalDrawersChangeStable, onLocalDrawerChangeStable]);\n\n useEffect(() => {\n const unsubscribe = awsuiPluginsInternal.appLayout.onDrawerOpened(drawerId => {\n const localDrawer = [...runtimeDrawers.localBefore, ...drawers, ...runtimeDrawers.localAfter]?.find(\n drawer => drawer.id === drawerId\n );\n const globalDrawer = runtimeDrawers.global?.find(drawer => drawer.id === drawerId);\n if (localDrawer && activeDrawerId !== drawerId) {\n onActiveDrawerChange(drawerId);\n }\n if (globalDrawer && !activeGlobalDrawersIds.includes(drawerId)) {\n onActiveGlobalDrawersChange(drawerId);\n }\n });\n\n return () => {\n unsubscribe();\n };\n }, [\n activeDrawerId,\n activeGlobalDrawersIds,\n drawers,\n onActiveDrawerChange,\n runtimeDrawers,\n onActiveGlobalDrawersChange,\n ]);\n\n useEffect(() => {\n const unsubscribe = awsuiPluginsInternal.appLayout.onDrawerClosed(drawerId => {\n const localDrawer = [...runtimeDrawers.localBefore, ...drawers, ...runtimeDrawers.localAfter]?.find(\n drawer => drawer.id === drawerId\n );\n const globalDrawer = runtimeDrawers.global?.find(drawer => drawer.id === drawerId);\n if (localDrawer && activeDrawerId === drawerId) {\n onActiveDrawerChange(null);\n }\n if (globalDrawer && activeGlobalDrawersIds.includes(drawerId)) {\n onActiveGlobalDrawersChange(drawerId);\n }\n });\n\n return () => {\n unsubscribe();\n };\n }, [\n activeDrawerId,\n activeGlobalDrawersIds,\n drawers,\n onActiveDrawerChange,\n runtimeDrawers,\n onActiveGlobalDrawersChange,\n ]);\n\n return runtimeDrawers;\n}\n\nfunction applyToolsDrawer(toolsProps: ToolsProps, runtimeDrawers: DrawersLayout) {\n const drawers = [...runtimeDrawers.localBefore, ...runtimeDrawers.localAfter];\n if (drawers.length === 0 && toolsProps.disableDrawersMerge) {\n return null;\n }\n const toolsItem = getToolsDrawerItem(toolsProps);\n if (toolsItem) {\n drawers.unshift(toolsItem);\n }\n\n return drawers;\n}\n\nexport const MIN_DRAWER_SIZE = 290;\n\ntype UseDrawersProps = Pick<AppLayoutProps, 'drawers' | 'activeDrawerId' | 'onDrawerChange'> & {\n __disableRuntimeDrawers?: boolean;\n onGlobalDrawerFocus?: (drawerId: string, open: boolean) => void;\n onAddNewActiveDrawer?: (drawerId: string) => void;\n};\n\nexport function useDrawers(\n {\n drawers,\n activeDrawerId: controlledActiveDrawerId,\n onDrawerChange,\n onGlobalDrawerFocus,\n onAddNewActiveDrawer,\n __disableRuntimeDrawers: disableRuntimeDrawers,\n }: UseDrawersProps,\n ariaLabels: AppLayoutProps['ariaLabels'],\n toolsProps: ToolsProps\n) {\n const [activeDrawerId = null, setActiveDrawerId] = useControllable(controlledActiveDrawerId, onDrawerChange, null, {\n componentName: 'AppLayout',\n controlledProp: 'activeDrawerId',\n changeHandler: 'onChange',\n });\n const [activeGlobalDrawersIds, setActiveGlobalDrawersIds] = useState<Array<string>>([]);\n const [drawerSizes, setDrawerSizes] = useState<Record<string, number>>({});\n // FIFO queue that keeps track of open drawers, where the first element is the most recently opened drawer\n const drawersOpenQueue = useRef<Array<string>>([]);\n\n function onActiveDrawerResize({ id, size }: { id: string; size: number }) {\n setDrawerSizes(oldSizes => ({ ...oldSizes, [id]: size }));\n fireNonCancelableEvent(activeDrawer?.onResize, { id, size });\n const activeGlobalDrawer = runtimeGlobalDrawers.find(drawer => drawer.id === id);\n fireNonCancelableEvent(activeGlobalDrawer?.onResize, { id, size });\n }\n\n function onActiveDrawerChange(newDrawerId: string | null) {\n setActiveDrawerId(newDrawerId);\n if (newDrawerId) {\n onAddNewActiveDrawer?.(newDrawerId);\n }\n if (hasOwnDrawers) {\n fireNonCancelableEvent(onDrawerChange, { activeDrawerId: newDrawerId });\n } else if (!toolsProps.toolsHide) {\n toolsProps.onToolsToggle(newDrawerId === TOOLS_DRAWER_ID);\n }\n\n if (newDrawerId) {\n drawersOpenQueue.current = [newDrawerId, ...drawersOpenQueue.current];\n }\n\n if (activeDrawerId) {\n drawersOpenQueue.current = drawersOpenQueue.current.filter(id => id !== activeDrawerId);\n }\n }\n\n function onActiveGlobalDrawersChange(drawerId: string) {\n if (activeGlobalDrawersIds.includes(drawerId)) {\n setActiveGlobalDrawersIds(currentState => currentState.filter(id => id !== drawerId));\n onGlobalDrawerFocus?.(drawerId, false);\n drawersOpenQueue.current = drawersOpenQueue.current.filter(id => id !== drawerId);\n } else if (drawerId) {\n onAddNewActiveDrawer?.(drawerId);\n setActiveGlobalDrawersIds(currentState => [drawerId, ...currentState].slice(0, DRAWERS_LIMIT!));\n onGlobalDrawerFocus?.(drawerId, true);\n drawersOpenQueue.current = [drawerId, ...drawersOpenQueue.current];\n }\n }\n\n const hasOwnDrawers = !!drawers;\n const runtimeDrawers = useRuntimeDrawers(\n disableRuntimeDrawers,\n activeDrawerId,\n onActiveDrawerChange,\n activeGlobalDrawersIds,\n onActiveGlobalDrawersChange,\n drawers ?? []\n );\n const { localBefore, localAfter, global: runtimeGlobalDrawers } = runtimeDrawers;\n const combinedLocalDrawers = drawers\n ? [...localBefore, ...drawers, ...localAfter]\n : applyToolsDrawer(toolsProps, runtimeDrawers);\n // support toolsOpen in runtime-drawers-only mode\n let activeDrawerIdResolved = toolsProps?.toolsOpen && !hasOwnDrawers ? TOOLS_DRAWER_ID : activeDrawerId;\n const activeDrawer = combinedLocalDrawers?.find(drawer => drawer.id === activeDrawerIdResolved);\n // ensure that id is only defined when the drawer exists\n activeDrawerIdResolved = activeDrawer?.id ?? null;\n const activeGlobalDrawers = runtimeGlobalDrawers.filter(drawer => activeGlobalDrawersIds.includes(drawer.id));\n\n const activeDrawerSize = activeDrawerIdResolved\n ? drawerSizes[activeDrawerIdResolved] ?? activeDrawer?.defaultSize ?? toolsProps.toolsWidth\n : toolsProps.toolsWidth;\n const activeGlobalDrawersSizes: Record<string, number> = activeGlobalDrawersIds.reduce(\n (acc, currentGlobalDrawerId) => {\n const currentGlobalDrawer = runtimeGlobalDrawers.find(drawer => drawer.id === currentGlobalDrawerId);\n return {\n ...acc,\n [currentGlobalDrawerId]:\n drawerSizes[currentGlobalDrawerId] ?? currentGlobalDrawer?.defaultSize ?? MIN_DRAWER_SIZE,\n };\n },\n {}\n );\n const minGlobalDrawersSizes: Record<string, number> = runtimeGlobalDrawers.reduce((acc, globalDrawer) => {\n return {\n ...acc,\n [globalDrawer.id]: Math.min(globalDrawer.defaultSize ?? MIN_DRAWER_SIZE, MIN_DRAWER_SIZE),\n };\n }, {});\n const minDrawerSize = Math.min(\n toolsProps?.toolsOpen ? toolsProps.toolsWidth : activeDrawer?.defaultSize ?? MIN_DRAWER_SIZE,\n MIN_DRAWER_SIZE\n );\n\n return {\n ariaLabelsWithDrawers: ariaLabels,\n drawers: combinedLocalDrawers || undefined,\n activeDrawer,\n activeDrawerId: activeDrawerIdResolved,\n globalDrawers: runtimeGlobalDrawers,\n activeGlobalDrawers: activeGlobalDrawers,\n activeGlobalDrawersIds,\n activeGlobalDrawersSizes,\n activeDrawerSize,\n minDrawerSize,\n minGlobalDrawersSizes,\n drawerSizes,\n drawersOpenQueue: drawersOpenQueue.current,\n onActiveDrawerChange,\n onActiveDrawerResize,\n onActiveGlobalDrawersChange,\n };\n}\n"]}
1
+ {"version":3,"file":"use-drawers.js","sourceRoot":"","sources":["../../../../src/app-layout/utils/use-drawers.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAc,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAElF,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AAEtE,OAAO,EAAE,qBAAqB,EAAiB,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAE,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ACP,MAAM,aAAa,GAAG,IAAI,CAAC,GAAG,CAC5B,CAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,SAAS,EAAC,CAAC,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,MAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,WAAW,mCAAI,eAAe,EAC5F,eAAe,CAChB,CAAC;IAEF,OAAO;QACL,qBAAqB,EAAE,UAAU;QACjC,OAAO,EAAE,oBAAoB,IAAI,SAAS;QAC1C,YAAY;QACZ,cAAc,EAAE,sBAAsB;QACtC,aAAa,EAAE,oBAAoB;QACnC,mBAAmB,EAAE,mBAAmB;QACxC,sBAAsB;QACtB,wBAAwB;QACxB,gBAAgB;QAChB,aAAa;QACb,qBAAqB;QACrB,WAAW;QACX,gBAAgB,EAAE,gBAAgB,CAAC,OAAO;QAC1C,oBAAoB;QACpB,oBAAoB;QACpB,2BAA2B;KAC5B,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 { useStableCallback } from '@cloudscape-design/component-toolkit/internal';\n\nimport { fireNonCancelableEvent } from '../../internal/events';\nimport { useControllable } from '../../internal/hooks/use-controllable';\nimport { awsuiPluginsInternal } from '../../internal/plugins/api';\nimport { sortByPriority } from '../../internal/plugins/helpers/utils';\nimport { AppLayoutProps } from '../interfaces';\nimport { convertRuntimeDrawers, DrawersLayout } from '../runtime-drawer';\nimport { togglesConfig } from '../toggles';\n\nexport const TOOLS_DRAWER_ID = 'awsui-internal-tools';\n\ninterface ToolsProps {\n toolsHide: boolean | undefined;\n toolsOpen: boolean | undefined;\n toolsWidth: number;\n tools: React.ReactNode | undefined;\n onToolsToggle: (newOpen: boolean) => void;\n ariaLabels: AppLayoutProps.Labels | undefined;\n disableDrawersMerge?: boolean;\n}\n\nfunction getToolsDrawerItem(props: ToolsProps): AppLayoutProps.Drawer | null {\n if (props.toolsHide) {\n return null;\n }\n const { iconName, getLabels } = togglesConfig.tools;\n const { mainLabel, closeLabel, openLabel } = getLabels(props.ariaLabels);\n return {\n id: TOOLS_DRAWER_ID,\n content: props.tools,\n resizable: false,\n ariaLabels: {\n triggerButton: openLabel,\n closeButton: closeLabel,\n drawerName: mainLabel ?? '',\n },\n trigger: {\n iconName: iconName,\n },\n };\n}\n\nconst DRAWERS_LIMIT = 2;\n\nfunction useRuntimeDrawers(\n disableRuntimeDrawers: boolean | undefined,\n activeDrawerId: string | null,\n onActiveDrawerChange: (newDrawerId: string | null) => void,\n activeGlobalDrawersIds: Array<string>,\n onActiveGlobalDrawersChange: (newDrawerId: string) => void,\n drawers: AppLayoutProps.Drawer[]\n) {\n const [runtimeDrawers, setRuntimeDrawers] = useState<DrawersLayout>({\n localBefore: [],\n localAfter: [],\n global: [],\n });\n const onLocalDrawerChangeStable = useStableCallback(onActiveDrawerChange);\n const onGlobalDrawersChangeStable = useStableCallback(onActiveGlobalDrawersChange);\n\n const localDrawerWasOpenRef = useRef(false);\n localDrawerWasOpenRef.current = localDrawerWasOpenRef.current || !!activeDrawerId;\n const activeGlobalDrawersIdsRef = useRef<Array<string>>([]);\n activeGlobalDrawersIdsRef.current = activeGlobalDrawersIds;\n\n useEffect(() => {\n if (disableRuntimeDrawers) {\n return;\n }\n const unsubscribe = awsuiPluginsInternal.appLayout.onDrawersRegistered(drawers => {\n const localDrawers = drawers.filter(drawer => drawer.type !== 'global');\n const globalDrawers = drawers.filter(drawer => drawer.type === 'global');\n setRuntimeDrawers(convertRuntimeDrawers(localDrawers, globalDrawers));\n if (!localDrawerWasOpenRef.current) {\n const defaultActiveLocalDrawer = sortByPriority(localDrawers).find(drawer => drawer.defaultActive);\n if (defaultActiveLocalDrawer) {\n onLocalDrawerChangeStable(defaultActiveLocalDrawer.id);\n }\n }\n\n const drawersNotActiveByDefault = globalDrawers.filter(drawer => !drawer.defaultActive);\n const hasDrawersOpenByUserAction = drawersNotActiveByDefault.find(drawer =>\n activeGlobalDrawersIdsRef.current.includes(drawer.id)\n );\n if (hasDrawersOpenByUserAction || activeGlobalDrawersIdsRef.current.length === DRAWERS_LIMIT) {\n return;\n }\n\n const defaultActiveGlobalDrawers = sortByPriority(globalDrawers).filter(\n drawer => !activeGlobalDrawersIdsRef.current.includes(drawer.id) && drawer.defaultActive\n );\n defaultActiveGlobalDrawers.forEach(drawer => {\n onGlobalDrawersChangeStable(drawer.id);\n });\n });\n return () => {\n unsubscribe();\n setRuntimeDrawers({ localBefore: [], localAfter: [], global: [] });\n };\n }, [disableRuntimeDrawers, onGlobalDrawersChangeStable, onLocalDrawerChangeStable]);\n\n useEffect(() => {\n const unsubscribe = awsuiPluginsInternal.appLayout.onDrawerOpened(drawerId => {\n const localDrawer = [...runtimeDrawers.localBefore, ...drawers, ...runtimeDrawers.localAfter]?.find(\n drawer => drawer.id === drawerId\n );\n const globalDrawer = runtimeDrawers.global?.find(drawer => drawer.id === drawerId);\n if (localDrawer && activeDrawerId !== drawerId) {\n onActiveDrawerChange(drawerId);\n }\n if (globalDrawer && !activeGlobalDrawersIds.includes(drawerId)) {\n onActiveGlobalDrawersChange(drawerId);\n }\n });\n\n return () => {\n unsubscribe();\n };\n }, [\n activeDrawerId,\n activeGlobalDrawersIds,\n drawers,\n onActiveDrawerChange,\n runtimeDrawers,\n onActiveGlobalDrawersChange,\n ]);\n\n useEffect(() => {\n const unsubscribe = awsuiPluginsInternal.appLayout.onDrawerClosed(drawerId => {\n const localDrawer = [...runtimeDrawers.localBefore, ...drawers, ...runtimeDrawers.localAfter]?.find(\n drawer => drawer.id === drawerId\n );\n const globalDrawer = runtimeDrawers.global?.find(drawer => drawer.id === drawerId);\n if (localDrawer && activeDrawerId === drawerId) {\n onActiveDrawerChange(null);\n }\n if (globalDrawer && activeGlobalDrawersIds.includes(drawerId)) {\n onActiveGlobalDrawersChange(drawerId);\n }\n });\n\n return () => {\n unsubscribe();\n };\n }, [\n activeDrawerId,\n activeGlobalDrawersIds,\n drawers,\n onActiveDrawerChange,\n runtimeDrawers,\n onActiveGlobalDrawersChange,\n ]);\n\n return runtimeDrawers;\n}\n\nfunction applyToolsDrawer(toolsProps: ToolsProps, runtimeDrawers: DrawersLayout) {\n const drawers = [...runtimeDrawers.localBefore, ...runtimeDrawers.localAfter];\n if (drawers.length === 0 && toolsProps.disableDrawersMerge) {\n return null;\n }\n const toolsItem = getToolsDrawerItem(toolsProps);\n if (toolsItem) {\n drawers.unshift(toolsItem);\n }\n\n return drawers;\n}\n\nexport const MIN_DRAWER_SIZE = 290;\n\ntype UseDrawersProps = Pick<AppLayoutProps, 'drawers' | 'activeDrawerId' | 'onDrawerChange'> & {\n __disableRuntimeDrawers?: boolean;\n onGlobalDrawerFocus?: (drawerId: string, open: boolean) => void;\n onAddNewActiveDrawer?: (drawerId: string) => void;\n};\n\nexport function useDrawers(\n {\n drawers,\n activeDrawerId: controlledActiveDrawerId,\n onDrawerChange,\n onGlobalDrawerFocus,\n onAddNewActiveDrawer,\n __disableRuntimeDrawers: disableRuntimeDrawers,\n }: UseDrawersProps,\n ariaLabels: AppLayoutProps['ariaLabels'],\n toolsProps: ToolsProps\n) {\n const [activeDrawerId = null, setActiveDrawerId] = useControllable(controlledActiveDrawerId, onDrawerChange, null, {\n componentName: 'AppLayout',\n controlledProp: 'activeDrawerId',\n changeHandler: 'onChange',\n });\n const [activeGlobalDrawersIds, setActiveGlobalDrawersIds] = useState<Array<string>>([]);\n const [drawerSizes, setDrawerSizes] = useState<Record<string, number>>({});\n // FIFO queue that keeps track of open drawers, where the first element is the most recently opened drawer\n const drawersOpenQueue = useRef<Array<string>>([]);\n\n function onActiveDrawerResize({ id, size }: { id: string; size: number }) {\n setDrawerSizes(oldSizes => ({ ...oldSizes, [id]: size }));\n fireNonCancelableEvent(activeDrawer?.onResize, { id, size });\n const activeGlobalDrawer = runtimeGlobalDrawers.find(drawer => drawer.id === id);\n fireNonCancelableEvent(activeGlobalDrawer?.onResize, { id, size });\n }\n\n function onActiveDrawerChange(newDrawerId: string | null) {\n setActiveDrawerId(newDrawerId);\n if (newDrawerId) {\n onAddNewActiveDrawer?.(newDrawerId);\n }\n if (hasOwnDrawers) {\n fireNonCancelableEvent(onDrawerChange, { activeDrawerId: newDrawerId });\n } else if (!toolsProps.toolsHide) {\n toolsProps.onToolsToggle(newDrawerId === TOOLS_DRAWER_ID);\n }\n\n if (newDrawerId) {\n drawersOpenQueue.current = [newDrawerId, ...drawersOpenQueue.current];\n }\n\n if (activeDrawerId) {\n drawersOpenQueue.current = drawersOpenQueue.current.filter(id => id !== activeDrawerId);\n }\n }\n\n function onActiveGlobalDrawersChange(drawerId: string) {\n if (activeGlobalDrawersIds.includes(drawerId)) {\n setActiveGlobalDrawersIds(currentState => currentState.filter(id => id !== drawerId));\n onGlobalDrawerFocus?.(drawerId, false);\n drawersOpenQueue.current = drawersOpenQueue.current.filter(id => id !== drawerId);\n } else if (drawerId) {\n onAddNewActiveDrawer?.(drawerId);\n setActiveGlobalDrawersIds(currentState => [drawerId, ...currentState].slice(0, DRAWERS_LIMIT!));\n onGlobalDrawerFocus?.(drawerId, true);\n drawersOpenQueue.current = [drawerId, ...drawersOpenQueue.current];\n }\n }\n\n const hasOwnDrawers = !!drawers;\n const runtimeDrawers = useRuntimeDrawers(\n disableRuntimeDrawers,\n activeDrawerId,\n onActiveDrawerChange,\n activeGlobalDrawersIds,\n onActiveGlobalDrawersChange,\n drawers ?? []\n );\n const { localBefore, localAfter, global: runtimeGlobalDrawers } = runtimeDrawers;\n const combinedLocalDrawers = drawers\n ? [...localBefore, ...drawers, ...localAfter]\n : applyToolsDrawer(toolsProps, runtimeDrawers);\n // support toolsOpen in runtime-drawers-only mode\n let activeDrawerIdResolved = toolsProps?.toolsOpen && !hasOwnDrawers ? TOOLS_DRAWER_ID : activeDrawerId;\n const activeDrawer = combinedLocalDrawers?.find(drawer => drawer.id === activeDrawerIdResolved);\n // ensure that id is only defined when the drawer exists\n activeDrawerIdResolved = activeDrawer?.id ?? null;\n const activeGlobalDrawers = runtimeGlobalDrawers.filter(drawer => activeGlobalDrawersIds.includes(drawer.id));\n\n const activeDrawerSize = activeDrawerIdResolved\n ? drawerSizes[activeDrawerIdResolved] ?? activeDrawer?.defaultSize ?? toolsProps.toolsWidth\n : toolsProps.toolsWidth;\n const activeGlobalDrawersSizes: Record<string, number> = activeGlobalDrawersIds.reduce(\n (acc, currentGlobalDrawerId) => {\n const currentGlobalDrawer = runtimeGlobalDrawers.find(drawer => drawer.id === currentGlobalDrawerId);\n return {\n ...acc,\n [currentGlobalDrawerId]:\n drawerSizes[currentGlobalDrawerId] ?? currentGlobalDrawer?.defaultSize ?? MIN_DRAWER_SIZE,\n };\n },\n {}\n );\n const minGlobalDrawersSizes: Record<string, number> = runtimeGlobalDrawers.reduce((acc, globalDrawer) => {\n return {\n ...acc,\n [globalDrawer.id]: Math.min(globalDrawer.defaultSize ?? MIN_DRAWER_SIZE, MIN_DRAWER_SIZE),\n };\n }, {});\n const minDrawerSize = Math.min(\n toolsProps?.toolsOpen ? toolsProps.toolsWidth : activeDrawer?.defaultSize ?? MIN_DRAWER_SIZE,\n MIN_DRAWER_SIZE\n );\n\n return {\n ariaLabelsWithDrawers: ariaLabels,\n drawers: combinedLocalDrawers || undefined,\n activeDrawer,\n activeDrawerId: activeDrawerIdResolved,\n globalDrawers: runtimeGlobalDrawers,\n activeGlobalDrawers: activeGlobalDrawers,\n activeGlobalDrawersIds,\n activeGlobalDrawersSizes,\n activeDrawerSize,\n minDrawerSize,\n minGlobalDrawersSizes,\n drawerSizes,\n drawersOpenQueue: drawersOpenQueue.current,\n onActiveDrawerChange,\n onActiveDrawerResize,\n onActiveGlobalDrawersChange,\n };\n}\n"]}
@@ -1,4 +1,4 @@
1
1
  export var PACKAGE_SOURCE = "components";
2
- export var PACKAGE_VERSION = "3.0.0 (0a725426)";
2
+ export var PACKAGE_VERSION = "3.0.0 (1d068084)";
3
3
  export var THEME = "open-source-visual-refresh";
4
4
  export var ALWAYS_VISUAL_REFRESH = true;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "PACKAGE_SOURCE": "components",
3
- "PACKAGE_VERSION": "3.0.0 (0a725426)",
3
+ "PACKAGE_VERSION": "3.0.0 (1d068084)",
4
4
  "THEME": "default",
5
5
  "ALWAYS_VISUAL_REFRESH": false
6
6
  }
@@ -1,3 +1,3 @@
1
1
  {
2
- "commit": "0a72542604f346f70303b63f1c746e43bda962a5"
2
+ "commit": "1d0680848f9cd27f798c7703a6005baa4f373d19"
3
3
  }
@@ -1,4 +1,3 @@
1
- export { RuntimeContentWrapper } from './runtime-content-wrapper';
2
1
  export { createUseDiscoveredAction } from './use-discovered-action';
3
2
  export { createUseDiscoveredContent } from './use-discovered-content';
4
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/internal/plugins/helpers/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/internal/plugins/helpers/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC"}
@@ -1,6 +1,5 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
- export { RuntimeContentWrapper } from './runtime-content-wrapper';
4
3
  export { createUseDiscoveredAction } from './use-discovered-action';
5
4
  export { createUseDiscoveredContent } from './use-discovered-content';
6
5
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/plugins/helpers/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nexport { RuntimeContentWrapper } from './runtime-content-wrapper';\nexport { createUseDiscoveredAction } from './use-discovered-action';\nexport { createUseDiscoveredContent } from './use-discovered-content';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/plugins/helpers/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nexport { createUseDiscoveredAction } from './use-discovered-action';\nexport { createUseDiscoveredContent } from './use-discovered-content';\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"use-discovered-action.d.ts","sourceRoot":"","sources":["../../../../../src/internal/plugins/helpers/use-discovered-action.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAE3D,OAAO,EAAE,uBAAuB,EAA+B,MAAM,+BAA+B,CAAC;AAgBrG,wBAAgB,yBAAyB,CAAC,kBAAkB,EAAE,uBAAuB,CAAC,oBAAoB,CAAC,UAC/D,MAAM;uBAC3B,MAAM,SAAS,EAAE;eACzB,MAAM,GAAG,CAAC,cAAc,CAAC;gBACxB,MAAM,GAAG,CAAC,cAAc,CAAC;EAcxC"}
1
+ {"version":3,"file":"use-discovered-action.d.ts","sourceRoot":"","sources":["../../../../../src/internal/plugins/helpers/use-discovered-action.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAE3D,OAAO,EAAE,uBAAuB,EAA+B,MAAM,+BAA+B,CAAC;AAqCrG,wBAAgB,yBAAyB,CAAC,kBAAkB,EAAE,uBAAuB,CAAC,oBAAoB,CAAC,UAC/D,MAAM;uBAC3B,MAAM,SAAS,EAAE;eACzB,MAAM,GAAG,CAAC,cAAc,CAAC;gBACxB,MAAM,GAAG,CAAC,cAAc,CAAC;EAcxC"}
@@ -1,12 +1,23 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  import React, { useEffect, useRef, useState } from 'react';
4
- import { RuntimeContentWrapper } from './runtime-content-wrapper';
4
+ function RuntimeActionWrapper({ mountContent, unmountContent, context }) {
5
+ const ref = useRef(null);
6
+ useEffect(() => {
7
+ const container = ref.current;
8
+ mountContent(container, context);
9
+ return () => {
10
+ unmountContent(container);
11
+ };
12
+ // eslint-disable-next-line react-hooks/exhaustive-deps
13
+ }, []);
14
+ return React.createElement("div", { ref: ref });
15
+ }
5
16
  function convertRuntimeAction(action, context) {
6
17
  if (!action) {
7
18
  return null;
8
19
  }
9
- return (React.createElement(RuntimeContentWrapper, { key: action.id + '-' + context.type, mountContent: container => action.mountContent(container, context), unmountContent: container => action.unmountContent(container) }));
20
+ return (React.createElement(RuntimeActionWrapper, { key: action.id + '-' + context.type, context: context, mountContent: action.mountContent, unmountContent: action.unmountContent }));
10
21
  }
11
22
  export function createUseDiscoveredAction(onActionRegistered) {
12
23
  return function useDiscoveredAction(type) {
@@ -1 +1 @@
1
- {"version":3,"file":"use-discovered-action.js","sourceRoot":"","sources":["../../../../../src/internal/plugins/helpers/use-discovered-action.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAA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2.0\nimport React, { useEffect, useRef, useState } from 'react';\n\nimport { ActionButtonsController, ActionConfig, ActionContext } from '../controllers/action-buttons';\nimport { RuntimeContentWrapper } from './runtime-content-wrapper';\n\nfunction convertRuntimeAction(action: ActionConfig | null, context: ActionContext) {\n if (!action) {\n return null;\n }\n return (\n <RuntimeContentWrapper\n key={action.id + '-' + context.type}\n mountContent={container => action.mountContent(container, context)}\n unmountContent={container => action.unmountContent(container)}\n />\n );\n}\n\nexport function createUseDiscoveredAction(onActionRegistered: ActionButtonsController['onActionRegistered']) {\n return function useDiscoveredAction(type: string): {\n discoveredActions: React.ReactNode[];\n headerRef: React.Ref<HTMLDivElement>;\n contentRef: React.Ref<HTMLDivElement>;\n } {\n const [discoveredActions, setDiscoveredActions] = useState<Array<React.ReactNode>>([]);\n const headerRef = useRef<HTMLDivElement>(null);\n const contentRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n return onActionRegistered(actions => {\n setDiscoveredActions(actions.map(action => convertRuntimeAction(action, { type, headerRef, contentRef })));\n });\n }, [type]);\n\n return { discoveredActions, headerRef, contentRef };\n };\n}\n"]}
1
+ {"version":3,"file":"use-discovered-action.js","sourceRoot":"","sources":["../../../../../src/internal/plugins/helpers/use-discovered-action.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAU3D,SAAS,oBAAoB,CAAC,EAAE,YAAY,EAAE,cAAc,EAAE,OAAO,EAA6B;IAChG,MAAM,GAAG,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAEzC,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,SAAS,GAAG,GAAG,CAAC,OAAQ,CAAC;QAC/B,YAAY,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QACjC,OAAO,GAAG,EAAE;YACV,cAAc,CAAC,SAAS,CAAC,CAAC;QAC5B,CAAC,CAAC;QACF,uDAAuD;IACzD,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,6BAAK,GAAG,EAAE,GAAG,GAAQ,CAAC;AAC/B,CAAC;AAED,SAAS,oBAAoB,CAAC,MAA2B,EAAE,OAAsB;IAC/E,IAAI,CAAC,MAAM,EAAE;QACX,OAAO,IAAI,CAAC;KACb;IACD,OAAO,CACL,oBAAC,oBAAoB,IACnB,GAAG,EAAE,MAAM,CAAC,EAAE,GAAG,GAAG,GAAG,OAAO,CAAC,IAAI,EACnC,OAAO,EAAE,OAAO,EAChB,YAAY,EAAE,MAAM,CAAC,YAAY,EACjC,cAAc,EAAE,MAAM,CAAC,cAAc,GACrC,CACH,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,yBAAyB,CAAC,kBAAiE;IACzG,OAAO,SAAS,mBAAmB,CAAC,IAAY;QAK9C,MAAM,CAAC,iBAAiB,EAAE,oBAAoB,CAAC,GAAG,QAAQ,CAAyB,EAAE,CAAC,CAAC;QACvF,MAAM,SAAS,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;QAC/C,MAAM,UAAU,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;QAEhD,SAAS,CAAC,GAAG,EAAE;YACb,OAAO,kBAAkB,CAAC,OAAO,CAAC,EAAE;gBAClC,oBAAoB,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,oBAAoB,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC;YAC7G,CAAC,CAAC,CAAC;QACL,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;QAEX,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC;IACtD,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 { ActionButtonsController, ActionConfig, ActionContext } from '../controllers/action-buttons';\n\ninterface RuntimeActionWrapperProps {\n context: ActionContext;\n mountContent: ActionConfig['mountContent'];\n unmountContent: ActionConfig['unmountContent'];\n}\n\nfunction RuntimeActionWrapper({ mountContent, unmountContent, context }: RuntimeActionWrapperProps) {\n const ref = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n const container = ref.current!;\n mountContent(container, context);\n return () => {\n unmountContent(container);\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n return <div ref={ref}></div>;\n}\n\nfunction convertRuntimeAction(action: ActionConfig | null, context: ActionContext) {\n if (!action) {\n return null;\n }\n return (\n <RuntimeActionWrapper\n key={action.id + '-' + context.type}\n context={context}\n mountContent={action.mountContent}\n unmountContent={action.unmountContent}\n />\n );\n}\n\nexport function createUseDiscoveredAction(onActionRegistered: ActionButtonsController['onActionRegistered']) {\n return function useDiscoveredAction(type: string): {\n discoveredActions: React.ReactNode[];\n headerRef: React.Ref<HTMLDivElement>;\n contentRef: React.Ref<HTMLDivElement>;\n } {\n const [discoveredActions, setDiscoveredActions] = useState<Array<React.ReactNode>>([]);\n const headerRef = useRef<HTMLDivElement>(null);\n const contentRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n return onActionRegistered(actions => {\n setDiscoveredActions(actions.map(action => convertRuntimeAction(action, { type, headerRef, contentRef })));\n });\n }, [type]);\n\n return { discoveredActions, headerRef, contentRef };\n };\n}\n"]}
package/package.json CHANGED
@@ -128,7 +128,7 @@
128
128
  "./internal/base-component/index.js",
129
129
  "./internal/base-component/styles.css.js"
130
130
  ],
131
- "version": "3.0.815",
131
+ "version": "3.0.816",
132
132
  "repository": {
133
133
  "type": "git",
134
134
  "url": "https://github.com/cloudscape-design/components.git"
@@ -1 +0,0 @@
1
- {"version":3,"file":"runtime-api.d.ts","sourceRoot":"","sources":["../../../src/app-layout/runtime-api.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY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C,SAAS,EACb,OAAO,EAAE,CACP,oBAAC,qBAAqB,IACpB,GAAG,EAAE,aAAa,CAAC,EAAE,EACrB,YAAY,EAAE,YAAY,EAC1B,cAAc,EAAE,cAAc,EAC9B,EAAE,EAAE,aAAa,CAAC,EAAE,GACpB,CACH,EACD,QAAQ,EAAE,KAAK,CAAC,EAAE;YAChB,sBAAsB,CAAC,aAAa,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,EAAE,aAAa,CAAC,EAAE,EAAE,CAAC,CAAC;QACpG,CAAC,IACD;AACJ,CAAC,CAAC;AAEF,MAAM,UAAU,qBAAqB,CACnC,YAAwC,EACxC,aAAyC;IAEzC,MAAM,SAAS,GAAG,YAAY,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;IAC7D,MAAM,MAAM,GAAG,cAAc,CAAC,SAAS,CAAC,CAAC;IACzC,OAAO;QACL,MAAM,EAAE,cAAc,CAAC,aAAa,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;QACnE,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,WAAC,OAAA,CAAC,MAAA,IAAI,CAAC,aAAa,mCAAI,CAAC,CAAC,GAAG,CAAC,CAAA,EAAA,CAAC;QACjE,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,WAAC,OAAA,CAAC,MAAA,IAAI,CAAC,aAAa,mCAAI,CAAC,CAAC,IAAI,CAAC,CAAA,EAAA,CAAC;KAClE,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\n\nimport { fireNonCancelableEvent } from '../internal/events';\nimport { DrawerConfig as RuntimeDrawerConfig } from '../internal/plugins/controllers/drawers';\nimport { RuntimeContentWrapper } from '../internal/plugins/helpers';\nimport { sortByPriority } from '../internal/plugins/helpers/utils';\nimport { AppLayoutProps } from './interfaces';\n\nexport interface DrawersLayout {\n global: Array<AppLayoutProps.Drawer>;\n localBefore: Array<AppLayoutProps.Drawer>;\n localAfter: Array<AppLayoutProps.Drawer>;\n}\n\nconst mapRuntimeConfigToDrawer = (\n runtimeConfig: RuntimeDrawerConfig\n): AppLayoutProps.Drawer & {\n orderPriority?: number;\n} => {\n const { mountContent, unmountContent, trigger, ...runtimeDrawer } = runtimeConfig;\n\n return {\n ...runtimeDrawer,\n ariaLabels: { drawerName: runtimeDrawer.ariaLabels.content ?? '', ...runtimeDrawer.ariaLabels },\n trigger: trigger\n ? {\n iconSvg: (\n // eslint-disable-next-line react/no-danger\n <span dangerouslySetInnerHTML={{ __html: trigger.iconSvg }} />\n ),\n }\n : undefined,\n content: (\n <RuntimeContentWrapper\n key={runtimeDrawer.id}\n mountContent={mountContent}\n unmountContent={unmountContent}\n id={runtimeDrawer.id}\n />\n ),\n onResize: event => {\n fireNonCancelableEvent(runtimeDrawer.onResize, { size: event.detail.size, id: runtimeDrawer.id });\n },\n };\n};\n\nexport function convertRuntimeDrawers(\n localDrawers: Array<RuntimeDrawerConfig>,\n globalDrawers: Array<RuntimeDrawerConfig>\n): DrawersLayout {\n const converted = localDrawers.map(mapRuntimeConfigToDrawer);\n const sorted = sortByPriority(converted);\n return {\n global: sortByPriority(globalDrawers.map(mapRuntimeConfigToDrawer)),\n localBefore: sorted.filter(item => (item.orderPriority ?? 0) > 0),\n localAfter: sorted.filter(item => (item.orderPriority ?? 0) <= 0),\n };\n}\n"]}
@@ -1,10 +0,0 @@
1
- /// <reference types="react" />
2
- import { MountContentContext } from '../controllers/drawers';
3
- interface RuntimeContentWrapperProps {
4
- mountContent: (container: HTMLElement, mountContent: MountContentContext) => void;
5
- unmountContent: (container: HTMLElement) => void;
6
- id?: string;
7
- }
8
- export declare function RuntimeContentWrapper({ mountContent, unmountContent, id }: RuntimeContentWrapperProps): JSX.Element;
9
- export {};
10
- //# sourceMappingURL=runtime-content-wrapper.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"runtime-content-wrapper.d.ts","sourceRoot":"","sources":["../../../../../src/internal/plugins/helpers/runtime-content-wrapper.tsx"],"names":[],"mappings":";AAKA,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAI7D,UAAU,0BAA0B;IAClC,YAAY,EAAE,CAAC,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,mBAAmB,KAAK,IAAI,CAAC;IAClF,cAAc,EAAE,CAAC,SAAS,EAAE,WAAW,KAAK,IAAI,CAAC;IACjD,EAAE,CAAC,EAAE,MAAM,CAAC;CACb;AAED,wBAAgB,qBAAqB,CAAC,EAAE,YAAY,EAAE,cAAc,EAAE,EAAE,EAAE,EAAE,0BAA0B,eAyBrG"}
@@ -1,29 +0,0 @@
1
- // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
- // SPDX-License-Identifier: Apache-2.0
3
- import React, { useContext, useEffect, useRef } from 'react';
4
- import { ActiveDrawersContext } from '../../../app-layout/utils/visibility-context';
5
- export function RuntimeContentWrapper({ mountContent, unmountContent, id }) {
6
- const ref = useRef(null);
7
- const visibilityChangeCallback = useRef(null);
8
- const activeDrawersIds = useContext(ActiveDrawersContext);
9
- const isVisible = !!id && activeDrawersIds.includes(id);
10
- useEffect(() => {
11
- const container = ref.current;
12
- mountContent(container, {
13
- onVisibilityChange: cb => {
14
- visibilityChangeCallback.current = cb;
15
- },
16
- });
17
- return () => {
18
- unmountContent(container);
19
- visibilityChangeCallback.current = null;
20
- };
21
- // eslint-disable-next-line react-hooks/exhaustive-deps
22
- }, []);
23
- useEffect(() => {
24
- var _a;
25
- (_a = visibilityChangeCallback.current) === null || _a === void 0 ? void 0 : _a.call(visibilityChangeCallback, isVisible);
26
- }, [isVisible]);
27
- return React.createElement("div", { ref: ref });
28
- }
29
- //# sourceMappingURL=runtime-content-wrapper.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"runtime-content-wrapper.js","sourceRoot":"","sources":["../../../../../src/internal/plugins/helpers/runtime-content-wrapper.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,8CAA8C,CAAC;AAWpF,MAAM,UAAU,qBAAqB,CAAC,EAAE,YAAY,EAAE,cAAc,EAAE,EAAE,EAA8B;IACpG,MAAM,GAAG,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IACzC,MAAM,wBAAwB,GAAG,MAAM,CAA4B,IAAI,CAAC,CAAC;IACzE,MAAM,gBAAgB,GAAG,UAAU,CAAC,oBAAoB,CAAC,CAAC;IAC1D,MAAM,SAAS,GAAG,CAAC,CAAC,EAAE,IAAI,gBAAgB,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAExD,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,SAAS,GAAG,GAAG,CAAC,OAAQ,CAAC;QAC/B,YAAY,CAAC,SAAS,EAAE;YACtB,kBAAkB,EAAE,EAAE,CAAC,EAAE;gBACvB,wBAAwB,CAAC,OAAO,GAAG,EAAE,CAAC;YACxC,CAAC;SACF,CAAC,CAAC;QACH,OAAO,GAAG,EAAE;YACV,cAAc,CAAC,SAAS,CAAC,CAAC;YAC1B,wBAAwB,CAAC,OAAO,GAAG,IAAI,CAAC;QAC1C,CAAC,CAAC;QACF,uDAAuD;IACzD,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,SAAS,CAAC,GAAG,EAAE;;QACb,MAAA,wBAAwB,CAAC,OAAO,yEAAG,SAAS,CAAC,CAAC;IAChD,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;IAEhB,OAAO,6BAAK,GAAG,EAAE,GAAG,GAAQ,CAAC;AAC/B,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useContext, useEffect, useRef } from 'react';\n\nimport { ActiveDrawersContext } from '../../../app-layout/utils/visibility-context';\nimport { MountContentContext } from '../controllers/drawers';\n\ntype VisibilityCallback = (isVisible: boolean) => void;\n\ninterface RuntimeContentWrapperProps {\n mountContent: (container: HTMLElement, mountContent: MountContentContext) => void;\n unmountContent: (container: HTMLElement) => void;\n id?: string;\n}\n\nexport function RuntimeContentWrapper({ mountContent, unmountContent, id }: RuntimeContentWrapperProps) {\n const ref = useRef<HTMLDivElement>(null);\n const visibilityChangeCallback = useRef<VisibilityCallback | null>(null);\n const activeDrawersIds = useContext(ActiveDrawersContext);\n const isVisible = !!id && activeDrawersIds.includes(id);\n\n useEffect(() => {\n const container = ref.current!;\n mountContent(container, {\n onVisibilityChange: cb => {\n visibilityChangeCallback.current = cb;\n },\n });\n return () => {\n unmountContent(container);\n visibilityChangeCallback.current = null;\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n useEffect(() => {\n visibilityChangeCallback.current?.(isVisible);\n }, [isVisible]);\n\n return <div ref={ref}></div>;\n}\n"]}