@cloudscape-design/components 3.0.577 → 3.0.579
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app-layout/classic.d.ts +5 -0
- package/app-layout/classic.d.ts.map +1 -0
- package/app-layout/classic.js +308 -0
- package/app-layout/classic.js.map +1 -0
- package/app-layout/implementation.d.ts +4 -0
- package/app-layout/implementation.d.ts.map +1 -0
- package/app-layout/implementation.js +11 -0
- package/app-layout/implementation.js.map +1 -0
- package/app-layout/index.d.ts.map +1 -1
- package/app-layout/index.js +6 -309
- package/app-layout/index.js.map +1 -1
- package/app-layout/internal.d.ts +3 -0
- package/app-layout/internal.d.ts.map +1 -0
- package/app-layout/internal.js +5 -0
- package/app-layout/internal.js.map +1 -0
- package/app-layout/widget.d.ts +6 -0
- package/app-layout/widget.d.ts.map +1 -0
- package/app-layout/widget.js +16 -0
- package/app-layout/widget.js.map +1 -0
- package/internal/environment.js +1 -1
- package/internal/environment.json +1 -1
- package/internal/manifest.json +1 -1
- package/internal/utils/global-flags.d.ts +1 -0
- package/internal/utils/global-flags.d.ts.map +1 -1
- package/internal/utils/global-flags.js.map +1 -1
- package/package.json +1 -1
- package/split-panel/implementation.d.ts +5 -0
- package/split-panel/implementation.d.ts.map +1 -0
- package/split-panel/implementation.js +112 -0
- package/split-panel/implementation.js.map +1 -0
- package/split-panel/index.d.ts +1 -1
- package/split-panel/index.d.ts.map +1 -1
- package/split-panel/index.js +4 -102
- package/split-panel/index.js.map +1 -1
- package/split-panel/internal.d.ts +3 -0
- package/split-panel/internal.d.ts.map +1 -0
- package/split-panel/internal.js +5 -0
- package/split-panel/internal.js.map +1 -0
- package/split-panel/widget.d.ts +6 -0
- package/split-panel/widget.d.ts.map +1 -0
- package/split-panel/widget.js +16 -0
- package/split-panel/widget.js.map +1 -0
|
@@ -0,0 +1,112 @@
|
|
|
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, { useState, useEffect, useLayoutEffect, useRef } from 'react';
|
|
5
|
+
import clsx from 'clsx';
|
|
6
|
+
import { InternalButton } from '../button/internal';
|
|
7
|
+
import { getBaseProps } from '../internal/base-component';
|
|
8
|
+
import { useSplitPanelContext } from '../internal/context/split-panel-context';
|
|
9
|
+
import ResizeHandler from './icons/resize-handler';
|
|
10
|
+
import PreferencesModal from './preferences-modal';
|
|
11
|
+
import { usePointerEvents } from '../app-layout/utils/use-pointer-events';
|
|
12
|
+
import { useKeyboardEvents } from '../app-layout/utils/use-keyboard-events';
|
|
13
|
+
import styles from './styles.css.js';
|
|
14
|
+
import { useMergeRefs } from '../internal/hooks/use-merge-refs';
|
|
15
|
+
import { AppLayoutContext } from '../internal/context/app-layout-context';
|
|
16
|
+
import { Transition } from '../internal/components/transition';
|
|
17
|
+
import { useVisualRefresh } from '../internal/hooks/use-visual-mode';
|
|
18
|
+
import { useUniqueId } from '../internal/hooks/use-unique-id';
|
|
19
|
+
import { SplitPanelContentSide } from './side';
|
|
20
|
+
import { SplitPanelContentBottom } from './bottom';
|
|
21
|
+
import { useInternalI18n } from '../i18n/context';
|
|
22
|
+
export const SplitPanelImplementation = React.forwardRef((_a, __internalRootRef) => {
|
|
23
|
+
var { header, children, hidePreferencesButton = false, closeBehavior = 'collapse', i18nStrings } = _a, restProps = __rest(_a, ["header", "children", "hidePreferencesButton", "closeBehavior", "i18nStrings"]);
|
|
24
|
+
const isRefresh = useVisualRefresh();
|
|
25
|
+
const { position, topOffset, bottomOffset, rightOffset, contentWidthStyles, isOpen, isForcedPosition, onPreferencesChange, onResize, onToggle, size, relativeSize, setSplitPanelToggle, refs, } = useSplitPanelContext();
|
|
26
|
+
const baseProps = getBaseProps(restProps);
|
|
27
|
+
const i18n = useInternalI18n('split-panel');
|
|
28
|
+
const [isPreferencesOpen, setPreferencesOpen] = useState(false);
|
|
29
|
+
const appLayoutMaxWidth = isRefresh && position === 'bottom' ? contentWidthStyles : undefined;
|
|
30
|
+
const openButtonAriaLabel = i18n('i18nStrings.openButtonAriaLabel', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.openButtonAriaLabel);
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
setSplitPanelToggle({ displayed: closeBehavior === 'collapse', ariaLabel: openButtonAriaLabel });
|
|
33
|
+
}, [setSplitPanelToggle, openButtonAriaLabel, closeBehavior]);
|
|
34
|
+
const splitPanelRefObject = useRef(null);
|
|
35
|
+
const sizeControlProps = {
|
|
36
|
+
position,
|
|
37
|
+
panelRef: splitPanelRefObject,
|
|
38
|
+
handleRef: refs.slider,
|
|
39
|
+
onResize,
|
|
40
|
+
};
|
|
41
|
+
const onSliderPointerDown = usePointerEvents(sizeControlProps);
|
|
42
|
+
const onKeyDown = useKeyboardEvents(sizeControlProps);
|
|
43
|
+
const wrappedChildren = (React.createElement(AppLayoutContext.Provider, { value: {
|
|
44
|
+
stickyOffsetTop: topOffset,
|
|
45
|
+
stickyOffsetBottom: bottomOffset,
|
|
46
|
+
} }, children));
|
|
47
|
+
const panelHeaderId = useUniqueId('split-panel-header');
|
|
48
|
+
const wrappedHeader = (React.createElement("div", { className: styles.header, style: appLayoutMaxWidth },
|
|
49
|
+
React.createElement("h2", { className: styles['header-text'], id: panelHeaderId }, header),
|
|
50
|
+
React.createElement("div", { className: styles['header-actions'] },
|
|
51
|
+
!hidePreferencesButton && isOpen && (React.createElement(React.Fragment, null,
|
|
52
|
+
React.createElement(InternalButton, { className: styles['preferences-button'], iconName: "settings", variant: "icon", onClick: () => setPreferencesOpen(true), formAction: "none", ariaLabel: i18n('i18nStrings.preferencesTitle', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.preferencesTitle), ref: refs.preferences }),
|
|
53
|
+
React.createElement("span", { className: styles.divider }))),
|
|
54
|
+
isOpen ? (React.createElement(InternalButton, { className: styles['close-button'], iconName: isRefresh && closeBehavior === 'collapse'
|
|
55
|
+
? position === 'side'
|
|
56
|
+
? 'angle-right'
|
|
57
|
+
: 'angle-down'
|
|
58
|
+
: 'close', variant: "icon", onClick: onToggle, formAction: "none", ariaLabel: i18n('i18nStrings.closeButtonAriaLabel', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.closeButtonAriaLabel), ariaExpanded: isOpen })) : position === 'side' ? null : (React.createElement(InternalButton, { className: styles['open-button'], iconName: "angle-up", variant: "icon", formAction: "none", ariaLabel: i18n('i18nStrings.openButtonAriaLabel', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.openButtonAriaLabel), ref: refs.toggle, ariaExpanded: isOpen })))));
|
|
59
|
+
const resizeHandle = (React.createElement("div", { ref: refs.slider, role: "slider", tabIndex: 0, "aria-label": i18n('i18nStrings.resizeHandleAriaLabel', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.resizeHandleAriaLabel), "aria-valuemax": 100, "aria-valuemin": 0, "aria-valuenow": position === 'bottom' ? relativeSize : 100 - relativeSize, className: clsx(styles.slider, styles[`slider-${position}`]), onKeyDown: onKeyDown, onPointerDown: onSliderPointerDown },
|
|
60
|
+
React.createElement(ResizeHandler, { className: clsx(styles['slider-icon'], styles[`slider-icon-${position}`]) })));
|
|
61
|
+
/*
|
|
62
|
+
This effect forces the browser to recalculate the layout
|
|
63
|
+
whenever the split panel might have moved.
|
|
64
|
+
|
|
65
|
+
This is needed as a workaround for a bug in Safari, which does
|
|
66
|
+
not automatically calculate the new position of the split panel
|
|
67
|
+
_content_ when the split panel moves.
|
|
68
|
+
*/
|
|
69
|
+
useLayoutEffect(() => {
|
|
70
|
+
const root = splitPanelRefObject.current;
|
|
71
|
+
if (root) {
|
|
72
|
+
const property = 'transform';
|
|
73
|
+
const temporaryValue = 'translateZ(0)';
|
|
74
|
+
const valueBefore = root.style[property];
|
|
75
|
+
root.style[property] = temporaryValue;
|
|
76
|
+
// This line forces the browser to recalculate the layout
|
|
77
|
+
void root.offsetHeight;
|
|
78
|
+
root.style[property] = valueBefore;
|
|
79
|
+
}
|
|
80
|
+
}, [rightOffset, __internalRootRef]);
|
|
81
|
+
const mergedRef = useMergeRefs(splitPanelRefObject, __internalRootRef);
|
|
82
|
+
if (closeBehavior === 'hide' && !isOpen) {
|
|
83
|
+
return React.createElement(React.Fragment, null);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* The AppLayout factor moved the circular buttons out of the
|
|
87
|
+
* SplitPanel and into the Tools component. This conditional
|
|
88
|
+
* is still needed for the early return to prevent execution
|
|
89
|
+
* of the following code.
|
|
90
|
+
*/
|
|
91
|
+
if (isRefresh && !isOpen && position === 'side') {
|
|
92
|
+
return React.createElement(React.Fragment, null);
|
|
93
|
+
}
|
|
94
|
+
return (React.createElement(Transition, { in: isOpen !== null && isOpen !== void 0 ? isOpen : false }, (state, transitioningElementRef) => (React.createElement(React.Fragment, null,
|
|
95
|
+
position === 'side' && (React.createElement(SplitPanelContentSide, { resizeHandle: resizeHandle, baseProps: baseProps, isOpen: isOpen, splitPanelRef: mergedRef, cappedSize: size, onToggle: onToggle, openButtonAriaLabel: i18n('i18nStrings.openButtonAriaLabel', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.openButtonAriaLabel), toggleRef: refs.toggle, header: wrappedHeader, panelHeaderId: panelHeaderId }, wrappedChildren)),
|
|
96
|
+
position === 'bottom' && (React.createElement(SplitPanelContentBottom, { resizeHandle: resizeHandle, baseProps: baseProps, isOpen: isOpen, splitPanelRef: mergedRef, cappedSize: size, onToggle: onToggle, header: wrappedHeader, panelHeaderId: panelHeaderId, state: state, transitioningElementRef: transitioningElementRef, appLayoutMaxWidth: appLayoutMaxWidth }, wrappedChildren)),
|
|
97
|
+
isPreferencesOpen && (React.createElement(PreferencesModal, { visible: true, preferences: { position }, disabledSidePosition: position === 'bottom' && isForcedPosition, isRefresh: isRefresh, i18nStrings: {
|
|
98
|
+
header: i18n('i18nStrings.preferencesTitle', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.preferencesTitle),
|
|
99
|
+
confirm: i18n('i18nStrings.preferencesConfirm', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.preferencesConfirm),
|
|
100
|
+
cancel: i18n('i18nStrings.preferencesCancel', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.preferencesCancel),
|
|
101
|
+
positionLabel: i18n('i18nStrings.preferencesPositionLabel', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.preferencesPositionLabel),
|
|
102
|
+
positionDescription: i18n('i18nStrings.preferencesPositionDescription', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.preferencesPositionDescription),
|
|
103
|
+
positionBottom: i18n('i18nStrings.preferencesPositionBottom', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.preferencesPositionBottom),
|
|
104
|
+
positionSide: i18n('i18nStrings.preferencesPositionSide', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.preferencesPositionSide),
|
|
105
|
+
}, onConfirm: preferences => {
|
|
106
|
+
onPreferencesChange(Object.assign({}, preferences));
|
|
107
|
+
setPreferencesOpen(false);
|
|
108
|
+
}, onDismiss: () => {
|
|
109
|
+
setPreferencesOpen(false);
|
|
110
|
+
} }))))));
|
|
111
|
+
});
|
|
112
|
+
//# sourceMappingURL=implementation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"implementation.js","sourceRoot":"","sources":["../../../src/split-panel/implementation.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC5E,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,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License-Identifier: Apache-2.0\nimport React, { useState, useEffect, useLayoutEffect, useRef } from 'react';\nimport clsx from 'clsx';\n\nimport { InternalButton } from '../button/internal';\nimport { getBaseProps } from '../internal/base-component';\nimport { useSplitPanelContext } from '../internal/context/split-panel-context';\n\nimport { SplitPanelProps } from './interfaces';\nimport ResizeHandler from './icons/resize-handler';\nimport PreferencesModal from './preferences-modal';\nimport { usePointerEvents } from '../app-layout/utils/use-pointer-events';\nimport { useKeyboardEvents } from '../app-layout/utils/use-keyboard-events';\nimport { SizeControlProps } from '../app-layout/utils/interfaces';\n\nimport styles from './styles.css.js';\nimport { useMergeRefs } from '../internal/hooks/use-merge-refs';\nimport { AppLayoutContext } from '../internal/context/app-layout-context';\nimport { Transition } from '../internal/components/transition';\nimport { useVisualRefresh } from '../internal/hooks/use-visual-mode';\nimport { useUniqueId } from '../internal/hooks/use-unique-id';\nimport { SplitPanelContentSide } from './side';\nimport { SplitPanelContentBottom } from './bottom';\nimport { useInternalI18n } from '../i18n/context';\n\nexport { SplitPanelProps };\n\nexport const SplitPanelImplementation = React.forwardRef<HTMLElement, SplitPanelProps>(\n (\n { header, children, hidePreferencesButton = false, closeBehavior = 'collapse', i18nStrings, ...restProps },\n __internalRootRef\n ) => {\n const isRefresh = useVisualRefresh();\n\n const {\n position,\n topOffset,\n bottomOffset,\n rightOffset,\n contentWidthStyles,\n isOpen,\n isForcedPosition,\n onPreferencesChange,\n onResize,\n onToggle,\n size,\n relativeSize,\n setSplitPanelToggle,\n refs,\n } = useSplitPanelContext();\n const baseProps = getBaseProps(restProps);\n const i18n = useInternalI18n('split-panel');\n const [isPreferencesOpen, setPreferencesOpen] = useState<boolean>(false);\n\n const appLayoutMaxWidth = isRefresh && position === 'bottom' ? contentWidthStyles : undefined;\n\n const openButtonAriaLabel = i18n('i18nStrings.openButtonAriaLabel', i18nStrings?.openButtonAriaLabel);\n useEffect(() => {\n setSplitPanelToggle({ displayed: closeBehavior === 'collapse', ariaLabel: openButtonAriaLabel });\n }, [setSplitPanelToggle, openButtonAriaLabel, closeBehavior]);\n\n const splitPanelRefObject = useRef<HTMLDivElement>(null);\n\n const sizeControlProps: SizeControlProps = {\n position,\n panelRef: splitPanelRefObject,\n handleRef: refs.slider,\n onResize,\n };\n const onSliderPointerDown = usePointerEvents(sizeControlProps);\n const onKeyDown = useKeyboardEvents(sizeControlProps);\n\n const wrappedChildren = (\n <AppLayoutContext.Provider\n value={{\n stickyOffsetTop: topOffset,\n stickyOffsetBottom: bottomOffset,\n }}\n >\n {children}\n </AppLayoutContext.Provider>\n );\n\n const panelHeaderId = useUniqueId('split-panel-header');\n\n const wrappedHeader = (\n <div className={styles.header} style={appLayoutMaxWidth}>\n <h2 className={styles['header-text']} id={panelHeaderId}>\n {header}\n </h2>\n <div className={styles['header-actions']}>\n {!hidePreferencesButton && isOpen && (\n <>\n <InternalButton\n className={styles['preferences-button']}\n iconName=\"settings\"\n variant=\"icon\"\n onClick={() => setPreferencesOpen(true)}\n formAction=\"none\"\n ariaLabel={i18n('i18nStrings.preferencesTitle', i18nStrings?.preferencesTitle)}\n ref={refs.preferences}\n />\n <span className={styles.divider} />\n </>\n )}\n\n {isOpen ? (\n <InternalButton\n className={styles['close-button']}\n iconName={\n isRefresh && closeBehavior === 'collapse'\n ? position === 'side'\n ? 'angle-right'\n : 'angle-down'\n : 'close'\n }\n variant=\"icon\"\n onClick={onToggle}\n formAction=\"none\"\n ariaLabel={i18n('i18nStrings.closeButtonAriaLabel', i18nStrings?.closeButtonAriaLabel)}\n ariaExpanded={isOpen}\n />\n ) : position === 'side' ? null : (\n <InternalButton\n className={styles['open-button']}\n iconName=\"angle-up\"\n variant=\"icon\"\n formAction=\"none\"\n ariaLabel={i18n('i18nStrings.openButtonAriaLabel', i18nStrings?.openButtonAriaLabel)}\n ref={refs.toggle}\n ariaExpanded={isOpen}\n />\n )}\n </div>\n </div>\n );\n\n const resizeHandle = (\n <div\n ref={refs.slider}\n role=\"slider\"\n tabIndex={0}\n aria-label={i18n('i18nStrings.resizeHandleAriaLabel', i18nStrings?.resizeHandleAriaLabel)}\n aria-valuemax={100}\n aria-valuemin={0}\n // Allows us to use the logical left/right keys to move the slider left/right,\n // but match aria keyboard behavior of using left/right to decrease/increase\n // the slider value.\n aria-valuenow={position === 'bottom' ? relativeSize : 100 - relativeSize}\n className={clsx(styles.slider, styles[`slider-${position}`])}\n onKeyDown={onKeyDown}\n onPointerDown={onSliderPointerDown}\n >\n <ResizeHandler className={clsx(styles['slider-icon'], styles[`slider-icon-${position}`])} />\n </div>\n );\n\n /*\n This effect forces the browser to recalculate the layout\n whenever the split panel might have moved.\n\n This is needed as a workaround for a bug in Safari, which does\n not automatically calculate the new position of the split panel\n _content_ when the split panel moves.\n */\n useLayoutEffect(() => {\n const root = splitPanelRefObject.current;\n\n if (root) {\n const property = 'transform';\n const temporaryValue = 'translateZ(0)';\n\n const valueBefore = root.style[property];\n root.style[property] = temporaryValue;\n\n // This line forces the browser to recalculate the layout\n void root.offsetHeight;\n\n root.style[property] = valueBefore;\n }\n }, [rightOffset, __internalRootRef]);\n\n const mergedRef = useMergeRefs(splitPanelRefObject, __internalRootRef);\n\n if (closeBehavior === 'hide' && !isOpen) {\n return <></>;\n }\n\n /**\n * The AppLayout factor moved the circular buttons out of the\n * SplitPanel and into the Tools component. This conditional\n * is still needed for the early return to prevent execution\n * of the following code.\n */\n if (isRefresh && !isOpen && position === 'side') {\n return <></>;\n }\n\n return (\n <Transition in={isOpen ?? false}>\n {(state, transitioningElementRef) => (\n <>\n {position === 'side' && (\n <SplitPanelContentSide\n resizeHandle={resizeHandle}\n baseProps={baseProps}\n isOpen={isOpen}\n splitPanelRef={mergedRef}\n cappedSize={size}\n onToggle={onToggle}\n openButtonAriaLabel={i18n('i18nStrings.openButtonAriaLabel', i18nStrings?.openButtonAriaLabel)}\n toggleRef={refs.toggle}\n header={wrappedHeader}\n panelHeaderId={panelHeaderId}\n >\n {wrappedChildren}\n </SplitPanelContentSide>\n )}\n\n {position === 'bottom' && (\n <SplitPanelContentBottom\n resizeHandle={resizeHandle}\n baseProps={baseProps}\n isOpen={isOpen}\n splitPanelRef={mergedRef}\n cappedSize={size}\n onToggle={onToggle}\n header={wrappedHeader}\n panelHeaderId={panelHeaderId}\n state={state}\n transitioningElementRef={transitioningElementRef}\n appLayoutMaxWidth={appLayoutMaxWidth}\n >\n {wrappedChildren}\n </SplitPanelContentBottom>\n )}\n {isPreferencesOpen && (\n <PreferencesModal\n visible={true}\n preferences={{ position }}\n disabledSidePosition={position === 'bottom' && isForcedPosition}\n isRefresh={isRefresh}\n i18nStrings={{\n header: i18n('i18nStrings.preferencesTitle', i18nStrings?.preferencesTitle),\n confirm: i18n('i18nStrings.preferencesConfirm', i18nStrings?.preferencesConfirm),\n cancel: i18n('i18nStrings.preferencesCancel', i18nStrings?.preferencesCancel),\n positionLabel: i18n('i18nStrings.preferencesPositionLabel', i18nStrings?.preferencesPositionLabel),\n positionDescription: i18n(\n 'i18nStrings.preferencesPositionDescription',\n i18nStrings?.preferencesPositionDescription\n ),\n positionBottom: i18n('i18nStrings.preferencesPositionBottom', i18nStrings?.preferencesPositionBottom),\n positionSide: i18n('i18nStrings.preferencesPositionSide', i18nStrings?.preferencesPositionSide),\n }}\n onConfirm={preferences => {\n onPreferencesChange({ ...preferences });\n setPreferencesOpen(false);\n }}\n onDismiss={() => {\n setPreferencesOpen(false);\n }}\n />\n )}\n </>\n )}\n </Transition>\n );\n }\n);\n"]}
|
package/split-panel/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { SplitPanelProps } from './interfaces';
|
|
3
3
|
export { SplitPanelProps };
|
|
4
|
-
export default function SplitPanel({
|
|
4
|
+
export default function SplitPanel({ hidePreferencesButton, closeBehavior, ...restProps }: SplitPanelProps): JSX.Element;
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/split-panel/index.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/split-panel/index.tsx"],"names":[],"mappings":";AAMA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,OAAO,EAAE,eAAe,EAAE,CAAC;AAE3B,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,EACjC,qBAA6B,EAC7B,aAA0B,EAC1B,GAAG,SAAS,EACb,EAAE,eAAe,eAYjB"}
|
package/split-panel/index.js
CHANGED
|
@@ -1,114 +1,16 @@
|
|
|
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
|
|
5
|
-
import clsx from 'clsx';
|
|
6
|
-
import { InternalButton } from '../button/internal';
|
|
7
|
-
import { getBaseProps } from '../internal/base-component';
|
|
8
|
-
import { useSplitPanelContext } from '../internal/context/split-panel-context';
|
|
4
|
+
import React from 'react';
|
|
9
5
|
import { applyDisplayName } from '../internal/utils/apply-display-name';
|
|
10
|
-
import ResizeHandler from './icons/resize-handler';
|
|
11
|
-
import PreferencesModal from './preferences-modal';
|
|
12
|
-
import { usePointerEvents } from '../app-layout/utils/use-pointer-events';
|
|
13
|
-
import { useKeyboardEvents } from '../app-layout/utils/use-keyboard-events';
|
|
14
|
-
import styles from './styles.css.js';
|
|
15
6
|
import useBaseComponent from '../internal/hooks/use-base-component';
|
|
16
|
-
import {
|
|
17
|
-
import { AppLayoutContext } from '../internal/context/app-layout-context';
|
|
18
|
-
import { Transition } from '../internal/components/transition';
|
|
19
|
-
import { useVisualRefresh } from '../internal/hooks/use-visual-mode';
|
|
20
|
-
import { useUniqueId } from '../internal/hooks/use-unique-id';
|
|
21
|
-
import { SplitPanelContentSide } from './side';
|
|
22
|
-
import { SplitPanelContentBottom } from './bottom';
|
|
23
|
-
import { useInternalI18n } from '../i18n/context';
|
|
7
|
+
import { SplitPanelInternal } from './internal';
|
|
24
8
|
export default function SplitPanel(_a) {
|
|
25
|
-
var {
|
|
26
|
-
const isRefresh = useVisualRefresh();
|
|
9
|
+
var { hidePreferencesButton = false, closeBehavior = 'collapse' } = _a, restProps = __rest(_a, ["hidePreferencesButton", "closeBehavior"]);
|
|
27
10
|
const { __internalRootRef } = useBaseComponent('SplitPanel', {
|
|
28
11
|
props: { closeBehavior, hidePreferencesButton },
|
|
29
12
|
});
|
|
30
|
-
|
|
31
|
-
const baseProps = getBaseProps(restProps);
|
|
32
|
-
const i18n = useInternalI18n('split-panel');
|
|
33
|
-
const [isPreferencesOpen, setPreferencesOpen] = useState(false);
|
|
34
|
-
const appLayoutMaxWidth = isRefresh && position === 'bottom' ? contentWidthStyles : undefined;
|
|
35
|
-
const openButtonAriaLabel = i18n('i18nStrings.openButtonAriaLabel', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.openButtonAriaLabel);
|
|
36
|
-
useEffect(() => {
|
|
37
|
-
setSplitPanelToggle({ displayed: closeBehavior === 'collapse', ariaLabel: openButtonAriaLabel });
|
|
38
|
-
}, [setSplitPanelToggle, openButtonAriaLabel, closeBehavior]);
|
|
39
|
-
const splitPanelRefObject = useRef(null);
|
|
40
|
-
const sizeControlProps = {
|
|
41
|
-
position,
|
|
42
|
-
panelRef: splitPanelRefObject,
|
|
43
|
-
handleRef: refs.slider,
|
|
44
|
-
onResize,
|
|
45
|
-
};
|
|
46
|
-
const onSliderPointerDown = usePointerEvents(sizeControlProps);
|
|
47
|
-
const onKeyDown = useKeyboardEvents(sizeControlProps);
|
|
48
|
-
const wrappedChildren = (React.createElement(AppLayoutContext.Provider, { value: {
|
|
49
|
-
stickyOffsetTop: topOffset,
|
|
50
|
-
stickyOffsetBottom: bottomOffset,
|
|
51
|
-
} }, children));
|
|
52
|
-
const panelHeaderId = useUniqueId('split-panel-header');
|
|
53
|
-
const wrappedHeader = (React.createElement("div", { className: styles.header, style: appLayoutMaxWidth },
|
|
54
|
-
React.createElement("h2", { className: styles['header-text'], id: panelHeaderId }, header),
|
|
55
|
-
React.createElement("div", { className: styles['header-actions'] },
|
|
56
|
-
!hidePreferencesButton && isOpen && (React.createElement(React.Fragment, null,
|
|
57
|
-
React.createElement(InternalButton, { className: styles['preferences-button'], iconName: "settings", variant: "icon", onClick: () => setPreferencesOpen(true), formAction: "none", ariaLabel: i18n('i18nStrings.preferencesTitle', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.preferencesTitle), ref: refs.preferences }),
|
|
58
|
-
React.createElement("span", { className: styles.divider }))),
|
|
59
|
-
isOpen ? (React.createElement(InternalButton, { className: styles['close-button'], iconName: isRefresh && closeBehavior === 'collapse' ? (position === 'side' ? 'angle-right' : 'angle-down') : 'close', variant: "icon", onClick: onToggle, formAction: "none", ariaLabel: i18n('i18nStrings.closeButtonAriaLabel', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.closeButtonAriaLabel), ariaExpanded: isOpen })) : position === 'side' ? null : (React.createElement(InternalButton, { className: styles['open-button'], iconName: "angle-up", variant: "icon", formAction: "none", ariaLabel: i18n('i18nStrings.openButtonAriaLabel', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.openButtonAriaLabel), ref: refs.toggle, ariaExpanded: isOpen })))));
|
|
60
|
-
const resizeHandle = (React.createElement("div", { ref: refs.slider, role: "slider", tabIndex: 0, "aria-label": i18n('i18nStrings.resizeHandleAriaLabel', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.resizeHandleAriaLabel), "aria-valuemax": 100, "aria-valuemin": 0, "aria-valuenow": position === 'bottom' ? relativeSize : 100 - relativeSize, className: clsx(styles.slider, styles[`slider-${position}`]), onKeyDown: onKeyDown, onPointerDown: onSliderPointerDown },
|
|
61
|
-
React.createElement(ResizeHandler, { className: clsx(styles['slider-icon'], styles[`slider-icon-${position}`]) })));
|
|
62
|
-
/*
|
|
63
|
-
This effect forces the browser to recalculate the layout
|
|
64
|
-
whenever the split panel might have moved.
|
|
65
|
-
|
|
66
|
-
This is needed as a workaround for a bug in Safari, which does
|
|
67
|
-
not automatically calculate the new position of the split panel
|
|
68
|
-
_content_ when the split panel moves.
|
|
69
|
-
*/
|
|
70
|
-
useLayoutEffect(() => {
|
|
71
|
-
const root = __internalRootRef.current;
|
|
72
|
-
if (root) {
|
|
73
|
-
const property = 'transform';
|
|
74
|
-
const temporaryValue = 'translateZ(0)';
|
|
75
|
-
const valueBefore = root.style[property];
|
|
76
|
-
root.style[property] = temporaryValue;
|
|
77
|
-
// This line forces the browser to recalculate the layout
|
|
78
|
-
void root.offsetHeight;
|
|
79
|
-
root.style[property] = valueBefore;
|
|
80
|
-
}
|
|
81
|
-
}, [rightOffset, __internalRootRef]);
|
|
82
|
-
const mergedRef = useMergeRefs(splitPanelRefObject, __internalRootRef);
|
|
83
|
-
if (closeBehavior === 'hide' && !isOpen) {
|
|
84
|
-
return React.createElement(React.Fragment, null);
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* The AppLayout factor moved the circular buttons out of the
|
|
88
|
-
* SplitPanel and into the Tools component. This conditional
|
|
89
|
-
* is still needed for the early return to prevent execution
|
|
90
|
-
* of the following code.
|
|
91
|
-
*/
|
|
92
|
-
if (isRefresh && !isOpen && position === 'side') {
|
|
93
|
-
return React.createElement(React.Fragment, null);
|
|
94
|
-
}
|
|
95
|
-
return (React.createElement(Transition, { in: isOpen !== null && isOpen !== void 0 ? isOpen : false }, (state, transitioningElementRef) => (React.createElement(React.Fragment, null,
|
|
96
|
-
position === 'side' && (React.createElement(SplitPanelContentSide, { resizeHandle: resizeHandle, baseProps: baseProps, isOpen: isOpen, splitPanelRef: mergedRef, cappedSize: size, onToggle: onToggle, openButtonAriaLabel: i18n('i18nStrings.openButtonAriaLabel', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.openButtonAriaLabel), toggleRef: refs.toggle, header: wrappedHeader, panelHeaderId: panelHeaderId }, wrappedChildren)),
|
|
97
|
-
position === 'bottom' && (React.createElement(SplitPanelContentBottom, { resizeHandle: resizeHandle, baseProps: baseProps, isOpen: isOpen, splitPanelRef: mergedRef, cappedSize: size, onToggle: onToggle, header: wrappedHeader, panelHeaderId: panelHeaderId, state: state, transitioningElementRef: transitioningElementRef, appLayoutMaxWidth: appLayoutMaxWidth }, wrappedChildren)),
|
|
98
|
-
isPreferencesOpen && (React.createElement(PreferencesModal, { visible: true, preferences: { position }, disabledSidePosition: position === 'bottom' && isForcedPosition, isRefresh: isRefresh, i18nStrings: {
|
|
99
|
-
header: i18n('i18nStrings.preferencesTitle', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.preferencesTitle),
|
|
100
|
-
confirm: i18n('i18nStrings.preferencesConfirm', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.preferencesConfirm),
|
|
101
|
-
cancel: i18n('i18nStrings.preferencesCancel', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.preferencesCancel),
|
|
102
|
-
positionLabel: i18n('i18nStrings.preferencesPositionLabel', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.preferencesPositionLabel),
|
|
103
|
-
positionDescription: i18n('i18nStrings.preferencesPositionDescription', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.preferencesPositionDescription),
|
|
104
|
-
positionBottom: i18n('i18nStrings.preferencesPositionBottom', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.preferencesPositionBottom),
|
|
105
|
-
positionSide: i18n('i18nStrings.preferencesPositionSide', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.preferencesPositionSide),
|
|
106
|
-
}, onConfirm: preferences => {
|
|
107
|
-
onPreferencesChange(Object.assign({}, preferences));
|
|
108
|
-
setPreferencesOpen(false);
|
|
109
|
-
}, onDismiss: () => {
|
|
110
|
-
setPreferencesOpen(false);
|
|
111
|
-
} }))))));
|
|
13
|
+
return (React.createElement(SplitPanelInternal, Object.assign({}, restProps, { ref: __internalRootRef, hidePreferencesButton: hidePreferencesButton, closeBehavior: closeBehavior })));
|
|
112
14
|
}
|
|
113
15
|
applyDisplayName(SplitPanel, 'SplitPanel');
|
|
114
16
|
//# sourceMappingURL=index.js.map
|
package/split-panel/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/split-panel/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC5E,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,yCAAyC,CAAC;AAC/E,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAGxE,OAAO,aAAa,MAAM,wBAAwB,CAAC;AACnD,OAAO,gBAAgB,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AAG5E,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,gBAAgB,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAC1E,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,MA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uBAAX,WAAW,CAAE,iBAAiB,CAAC;gBAC7E,aAAa,EAAE,IAAI,CAAC,sCAAsC,EAAE,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,wBAAwB,CAAC;gBAClG,mBAAmB,EAAE,IAAI,CACvB,4CAA4C,EAC5C,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,8BAA8B,CAC5C;gBACD,cAAc,EAAE,IAAI,CAAC,uCAAuC,EAAE,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,yBAAyB,CAAC;gBACrG,YAAY,EAAE,IAAI,CAAC,qCAAqC,EAAE,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,uBAAuB,CAAC;aAChG,EACD,SAAS,EAAE,WAAW,CAAC,EAAE;gBACvB,mBAAmB,mBAAM,WAAW,EAAG,CAAC;gBACxC,kBAAkB,CAAC,KAAK,CAAC,CAAC;YAC5B,CAAC,EACD,SAAS,EAAE,GAAG,EAAE;gBACd,kBAAkB,CAAC,KAAK,CAAC,CAAC;YAC5B,CAAC,GACD,CACH,CACA,CACJ,CACU,CACd,CAAC;AACJ,CAAC;AAED,gBAAgB,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useState, useEffect, useLayoutEffect, useRef } from 'react';\nimport clsx from 'clsx';\n\nimport { InternalButton } from '../button/internal';\nimport { getBaseProps } from '../internal/base-component';\nimport { useSplitPanelContext } from '../internal/context/split-panel-context';\nimport { applyDisplayName } from '../internal/utils/apply-display-name';\n\nimport { SplitPanelProps } from './interfaces';\nimport ResizeHandler from './icons/resize-handler';\nimport PreferencesModal from './preferences-modal';\nimport { usePointerEvents } from '../app-layout/utils/use-pointer-events';\nimport { useKeyboardEvents } from '../app-layout/utils/use-keyboard-events';\nimport { SizeControlProps } from '../app-layout/utils/interfaces';\n\nimport styles from './styles.css.js';\nimport useBaseComponent from '../internal/hooks/use-base-component';\nimport { useMergeRefs } from '../internal/hooks/use-merge-refs';\nimport { AppLayoutContext } from '../internal/context/app-layout-context';\nimport { Transition } from '../internal/components/transition';\nimport { useVisualRefresh } from '../internal/hooks/use-visual-mode';\nimport { useUniqueId } from '../internal/hooks/use-unique-id';\nimport { SplitPanelContentSide } from './side';\nimport { SplitPanelContentBottom } from './bottom';\nimport { useInternalI18n } from '../i18n/context';\n\nexport { SplitPanelProps };\n\nexport default function SplitPanel({\n header,\n children,\n hidePreferencesButton = false,\n closeBehavior = 'collapse',\n i18nStrings,\n ...restProps\n}: SplitPanelProps) {\n const isRefresh = useVisualRefresh();\n const { __internalRootRef } = useBaseComponent('SplitPanel', {\n props: { closeBehavior, hidePreferencesButton },\n });\n const {\n position,\n topOffset,\n bottomOffset,\n rightOffset,\n contentWidthStyles,\n isOpen,\n isForcedPosition,\n onPreferencesChange,\n onResize,\n onToggle,\n size,\n relativeSize,\n setSplitPanelToggle,\n refs,\n } = useSplitPanelContext();\n const baseProps = getBaseProps(restProps);\n const i18n = useInternalI18n('split-panel');\n const [isPreferencesOpen, setPreferencesOpen] = useState<boolean>(false);\n\n const appLayoutMaxWidth = isRefresh && position === 'bottom' ? contentWidthStyles : undefined;\n\n const openButtonAriaLabel = i18n('i18nStrings.openButtonAriaLabel', i18nStrings?.openButtonAriaLabel);\n useEffect(() => {\n setSplitPanelToggle({ displayed: closeBehavior === 'collapse', ariaLabel: openButtonAriaLabel });\n }, [setSplitPanelToggle, openButtonAriaLabel, closeBehavior]);\n\n const splitPanelRefObject = useRef<HTMLDivElement>(null);\n\n const sizeControlProps: SizeControlProps = {\n position,\n panelRef: splitPanelRefObject,\n handleRef: refs.slider,\n onResize,\n };\n const onSliderPointerDown = usePointerEvents(sizeControlProps);\n const onKeyDown = useKeyboardEvents(sizeControlProps);\n\n const wrappedChildren = (\n <AppLayoutContext.Provider\n value={{\n stickyOffsetTop: topOffset,\n stickyOffsetBottom: bottomOffset,\n }}\n >\n {children}\n </AppLayoutContext.Provider>\n );\n\n const panelHeaderId = useUniqueId('split-panel-header');\n\n const wrappedHeader = (\n <div className={styles.header} style={appLayoutMaxWidth}>\n <h2 className={styles['header-text']} id={panelHeaderId}>\n {header}\n </h2>\n <div className={styles['header-actions']}>\n {!hidePreferencesButton && isOpen && (\n <>\n <InternalButton\n className={styles['preferences-button']}\n iconName=\"settings\"\n variant=\"icon\"\n onClick={() => setPreferencesOpen(true)}\n formAction=\"none\"\n ariaLabel={i18n('i18nStrings.preferencesTitle', i18nStrings?.preferencesTitle)}\n ref={refs.preferences}\n />\n <span className={styles.divider} />\n </>\n )}\n\n {isOpen ? (\n <InternalButton\n className={styles['close-button']}\n iconName={\n isRefresh && closeBehavior === 'collapse' ? (position === 'side' ? 'angle-right' : 'angle-down') : 'close'\n }\n variant=\"icon\"\n onClick={onToggle}\n formAction=\"none\"\n ariaLabel={i18n('i18nStrings.closeButtonAriaLabel', i18nStrings?.closeButtonAriaLabel)}\n ariaExpanded={isOpen}\n />\n ) : position === 'side' ? null : (\n <InternalButton\n className={styles['open-button']}\n iconName=\"angle-up\"\n variant=\"icon\"\n formAction=\"none\"\n ariaLabel={i18n('i18nStrings.openButtonAriaLabel', i18nStrings?.openButtonAriaLabel)}\n ref={refs.toggle}\n ariaExpanded={isOpen}\n />\n )}\n </div>\n </div>\n );\n\n const resizeHandle = (\n <div\n ref={refs.slider}\n role=\"slider\"\n tabIndex={0}\n aria-label={i18n('i18nStrings.resizeHandleAriaLabel', i18nStrings?.resizeHandleAriaLabel)}\n aria-valuemax={100}\n aria-valuemin={0}\n // Allows us to use the logical left/right keys to move the slider left/right,\n // but match aria keyboard behavior of using left/right to decrease/increase\n // the slider value.\n aria-valuenow={position === 'bottom' ? relativeSize : 100 - relativeSize}\n className={clsx(styles.slider, styles[`slider-${position}`])}\n onKeyDown={onKeyDown}\n onPointerDown={onSliderPointerDown}\n >\n <ResizeHandler className={clsx(styles['slider-icon'], styles[`slider-icon-${position}`])} />\n </div>\n );\n\n /*\n This effect forces the browser to recalculate the layout\n whenever the split panel might have moved.\n\n This is needed as a workaround for a bug in Safari, which does\n not automatically calculate the new position of the split panel\n _content_ when the split panel moves.\n */\n useLayoutEffect(() => {\n const root = __internalRootRef.current;\n\n if (root) {\n const property = 'transform';\n const temporaryValue = 'translateZ(0)';\n\n const valueBefore = root.style[property];\n root.style[property] = temporaryValue;\n\n // This line forces the browser to recalculate the layout\n void root.offsetHeight;\n\n root.style[property] = valueBefore;\n }\n }, [rightOffset, __internalRootRef]);\n\n const mergedRef = useMergeRefs(splitPanelRefObject, __internalRootRef);\n\n if (closeBehavior === 'hide' && !isOpen) {\n return <></>;\n }\n\n /**\n * The AppLayout factor moved the circular buttons out of the\n * SplitPanel and into the Tools component. This conditional\n * is still needed for the early return to prevent execution\n * of the following code.\n */\n if (isRefresh && !isOpen && position === 'side') {\n return <></>;\n }\n\n return (\n <Transition in={isOpen ?? false}>\n {(state, transitioningElementRef) => (\n <>\n {position === 'side' && (\n <SplitPanelContentSide\n resizeHandle={resizeHandle}\n baseProps={baseProps}\n isOpen={isOpen}\n splitPanelRef={mergedRef}\n cappedSize={size}\n onToggle={onToggle}\n openButtonAriaLabel={i18n('i18nStrings.openButtonAriaLabel', i18nStrings?.openButtonAriaLabel)}\n toggleRef={refs.toggle}\n header={wrappedHeader}\n panelHeaderId={panelHeaderId}\n >\n {wrappedChildren}\n </SplitPanelContentSide>\n )}\n\n {position === 'bottom' && (\n <SplitPanelContentBottom\n resizeHandle={resizeHandle}\n baseProps={baseProps}\n isOpen={isOpen}\n splitPanelRef={mergedRef}\n cappedSize={size}\n onToggle={onToggle}\n header={wrappedHeader}\n panelHeaderId={panelHeaderId}\n state={state}\n transitioningElementRef={transitioningElementRef}\n appLayoutMaxWidth={appLayoutMaxWidth}\n >\n {wrappedChildren}\n </SplitPanelContentBottom>\n )}\n {isPreferencesOpen && (\n <PreferencesModal\n visible={true}\n preferences={{ position }}\n disabledSidePosition={position === 'bottom' && isForcedPosition}\n isRefresh={isRefresh}\n i18nStrings={{\n header: i18n('i18nStrings.preferencesTitle', i18nStrings?.preferencesTitle),\n confirm: i18n('i18nStrings.preferencesConfirm', i18nStrings?.preferencesConfirm),\n cancel: i18n('i18nStrings.preferencesCancel', i18nStrings?.preferencesCancel),\n positionLabel: i18n('i18nStrings.preferencesPositionLabel', i18nStrings?.preferencesPositionLabel),\n positionDescription: i18n(\n 'i18nStrings.preferencesPositionDescription',\n i18nStrings?.preferencesPositionDescription\n ),\n positionBottom: i18n('i18nStrings.preferencesPositionBottom', i18nStrings?.preferencesPositionBottom),\n positionSide: i18n('i18nStrings.preferencesPositionSide', i18nStrings?.preferencesPositionSide),\n }}\n onConfirm={preferences => {\n onPreferencesChange({ ...preferences });\n setPreferencesOpen(false);\n }}\n onDismiss={() => {\n setPreferencesOpen(false);\n }}\n />\n )}\n </>\n )}\n </Transition>\n );\n}\n\napplyDisplayName(SplitPanel, 'SplitPanel');\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/split-panel/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,gBAAgB,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAKhD,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,EAIjB;QAJiB,EACjC,qBAAqB,GAAG,KAAK,EAC7B,aAAa,GAAG,UAAU,OAEV,EADb,SAAS,cAHqB,0CAIlC,CADa;IAEZ,MAAM,EAAE,iBAAiB,EAAE,GAAG,gBAAgB,CAAC,YAAY,EAAE;QAC3D,KAAK,EAAE,EAAE,aAAa,EAAE,qBAAqB,EAAE;KAChD,CAAC,CAAC;IACH,OAAO,CACL,oBAAC,kBAAkB,oBACb,SAAS,IACb,GAAG,EAAE,iBAAiB,EACtB,qBAAqB,EAAE,qBAAqB,EAC5C,aAAa,EAAE,aAAa,IAC5B,CACH,CAAC;AACJ,CAAC;AAED,gBAAgB,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\nimport { applyDisplayName } from '../internal/utils/apply-display-name';\nimport useBaseComponent from '../internal/hooks/use-base-component';\nimport { SplitPanelInternal } from './internal';\nimport { SplitPanelProps } from './interfaces';\n\nexport { SplitPanelProps };\n\nexport default function SplitPanel({\n hidePreferencesButton = false,\n closeBehavior = 'collapse',\n ...restProps\n}: SplitPanelProps) {\n const { __internalRootRef } = useBaseComponent('SplitPanel', {\n props: { closeBehavior, hidePreferencesButton },\n });\n return (\n <SplitPanelInternal\n {...restProps}\n ref={__internalRootRef}\n hidePreferencesButton={hidePreferencesButton}\n closeBehavior={closeBehavior}\n />\n );\n}\n\napplyDisplayName(SplitPanel, 'SplitPanel');\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/split-panel/internal.tsx"],"names":[],"mappings":";AAIA,eAAO,MAAM,kBAAkB,gIAA+B,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { createWidgetizedSplitPanel } from './widget';
|
|
4
|
+
export const SplitPanelInternal = createWidgetizedSplitPanel();
|
|
5
|
+
//# sourceMappingURL=internal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/split-panel/internal.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,0BAA0B,EAAE,MAAM,UAAU,CAAC;AAEtD,MAAM,CAAC,MAAM,kBAAkB,GAAG,0BAA0B,EAAE,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { createWidgetizedSplitPanel } from './widget';\n\nexport const SplitPanelInternal = createWidgetizedSplitPanel();\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SplitPanelProps } from './interfaces';
|
|
3
|
+
type SplitPanelType = React.ForwardRefExoticComponent<SplitPanelProps & React.RefAttributes<HTMLElement>>;
|
|
4
|
+
export declare function createWidgetizedSplitPanel(SplitPanelLoader?: SplitPanelType): SplitPanelType;
|
|
5
|
+
export {};
|
|
6
|
+
//# sourceMappingURL=widget.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"widget.d.ts","sourceRoot":"","sources":["../../../src/split-panel/widget.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAI/C,KAAK,cAAc,GAAG,KAAK,CAAC,yBAAyB,CAAC,eAAe,GAAG,KAAK,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC,CAAC;AAE1G,wBAAgB,0BAA0B,CAAC,gBAAgB,CAAC,EAAE,cAAc,GAAG,cAAc,CAS5F"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { getGlobalFlag } from '../internal/utils/global-flags';
|
|
5
|
+
import { useVisualRefresh } from '../internal/hooks/use-visual-mode';
|
|
6
|
+
import { SplitPanelImplementation } from './implementation';
|
|
7
|
+
export function createWidgetizedSplitPanel(SplitPanelLoader) {
|
|
8
|
+
return React.forwardRef((props, ref) => {
|
|
9
|
+
const isRefresh = useVisualRefresh();
|
|
10
|
+
if (isRefresh && getGlobalFlag('appLayoutWidget') && SplitPanelLoader) {
|
|
11
|
+
return React.createElement(SplitPanelLoader, Object.assign({ ref: ref }, props));
|
|
12
|
+
}
|
|
13
|
+
return React.createElement(SplitPanelImplementation, Object.assign({ ref: ref }, props));
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=widget.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"widget.js","sourceRoot":"","sources":["../../../src/split-panel/widget.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAE/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAI5D,MAAM,UAAU,0BAA0B,CAAC,gBAAiC;IAC1E,OAAO,KAAK,CAAC,UAAU,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;QACrC,MAAM,SAAS,GAAG,gBAAgB,EAAE,CAAC;QACrC,IAAI,SAAS,IAAI,aAAa,CAAC,iBAAiB,CAAC,IAAI,gBAAgB,EAAE;YACrE,OAAO,oBAAC,gBAAgB,kBAAC,GAAG,EAAE,GAAG,IAAM,KAAK,EAAI,CAAC;SAClD;QAED,OAAO,oBAAC,wBAAwB,kBAAC,GAAG,EAAE,GAAG,IAAM,KAAK,EAAI,CAAC;IAC3D,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\nimport { getGlobalFlag } from '../internal/utils/global-flags';\nimport { SplitPanelProps } from './interfaces';\nimport { useVisualRefresh } from '../internal/hooks/use-visual-mode';\nimport { SplitPanelImplementation } from './implementation';\n\ntype SplitPanelType = React.ForwardRefExoticComponent<SplitPanelProps & React.RefAttributes<HTMLElement>>;\n\nexport function createWidgetizedSplitPanel(SplitPanelLoader?: SplitPanelType): SplitPanelType {\n return React.forwardRef((props, ref) => {\n const isRefresh = useVisualRefresh();\n if (isRefresh && getGlobalFlag('appLayoutWidget') && SplitPanelLoader) {\n return <SplitPanelLoader ref={ref} {...props} />;\n }\n\n return <SplitPanelImplementation ref={ref} {...props} />;\n });\n}\n"]}
|