@loomhq/lens 10.51.1 → 10.51.3
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.
|
@@ -8,7 +8,7 @@ declare const Modal: React.ForwardRefExoticComponent<Pick<ModalProps & {
|
|
|
8
8
|
backgroundColor?: string;
|
|
9
9
|
} & React.ClassAttributes<HTMLDivElement> & React.HTMLAttributes<HTMLDivElement> & {
|
|
10
10
|
theme?: object;
|
|
11
|
-
}, "key" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "slot" | "spellCheck" | "style" | "tabIndex" | "title" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "css" | "backgroundColor" | "maxWidth" | "zIndex" | "theme" | "isOpen" | "onCloseClick" | "hasDividers" | "mainButton" | "secondaryButton" | "alternativeButton" | "onBackgroundClick"> & React.RefAttributes<HTMLDialogElement>>;
|
|
11
|
+
}, "key" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "slot" | "spellCheck" | "style" | "tabIndex" | "title" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "css" | "backgroundColor" | "maxWidth" | "zIndex" | "theme" | "isOpen" | "onCloseClick" | "hasDividers" | "noPadding" | "mainButton" | "secondaryButton" | "alternativeButton" | "onBackgroundClick"> & React.RefAttributes<HTMLDialogElement>>;
|
|
12
12
|
declare type ModalProps = {
|
|
13
13
|
children?: React.ReactNode;
|
|
14
14
|
isOpen?: boolean;
|
|
@@ -21,11 +21,13 @@ declare type ModalProps = {
|
|
|
21
21
|
onKeyDown?: React.ReactEventHandler;
|
|
22
22
|
hasDividers?: boolean;
|
|
23
23
|
maxWidth?: number | string;
|
|
24
|
+
noPadding?: boolean;
|
|
24
25
|
zIndex?: number;
|
|
25
26
|
};
|
|
26
27
|
declare type ModalCardProps = {
|
|
27
28
|
children?: React.ReactNode;
|
|
28
29
|
isOpen?: boolean;
|
|
30
|
+
onKeyDown?: React.ReactEventHandler;
|
|
29
31
|
onCloseClick?: React.ReactEventHandler;
|
|
30
32
|
maxWidth?: number | string;
|
|
31
33
|
};
|
|
@@ -11,10 +11,10 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
};
|
|
12
12
|
import FocusTrap from 'focus-trap-react';
|
|
13
13
|
import { getColorValue, getRadius, getShadow, getSize, u, } from '../../utilities';
|
|
14
|
+
import React, { useEffect } from 'react';
|
|
14
15
|
import Backdrop from '../backdrop/backdrop';
|
|
15
16
|
import Container from '../container/container';
|
|
16
17
|
import IconButton from '../icon-button/icon-button';
|
|
17
|
-
import React, { useEffect } from 'react';
|
|
18
18
|
import Spacer from '../spacer/spacer';
|
|
19
19
|
import { SvgClose } from '../icon/available-icons';
|
|
20
20
|
import Text from '../text/text';
|
|
@@ -36,6 +36,7 @@ const ModalCardWrapper = styled.dialog `
|
|
|
36
36
|
margin: 0 auto;
|
|
37
37
|
position: relative;
|
|
38
38
|
overflow: auto;
|
|
39
|
+
width: 100%;
|
|
39
40
|
// TODO: LNS-150: Bake dialog resets into native resets file
|
|
40
41
|
border: 0;
|
|
41
42
|
padding: 0;
|
|
@@ -77,10 +78,18 @@ const ChildrenSection = styled.div `
|
|
|
77
78
|
display: flex;
|
|
78
79
|
flex-direction: column;
|
|
79
80
|
overflow: auto;
|
|
80
|
-
padding-top: ${props =>
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
81
|
+
padding-top: ${props => props.hasTitle && !props.noPadding
|
|
82
|
+
? 0
|
|
83
|
+
: !props.hasTitle && !props.noPadding
|
|
84
|
+
? 'var(--lns-space-xlarge)'
|
|
85
|
+
: 0};
|
|
86
|
+
padding-bottom: ${props => props.hasButtons && !props.noPadding
|
|
87
|
+
? 0
|
|
88
|
+
: !props.hasButtons && !props.noPadding
|
|
89
|
+
? 'var(--lns-space-xlarge)'
|
|
90
|
+
: 0};
|
|
91
|
+
padding-left: ${props => (props.noPadding ? 0 : 'var(--lns-space-xlarge)')};
|
|
92
|
+
padding-right: ${props => (props.noPadding ? 0 : 'var(--lns-space-xlarge)')};
|
|
84
93
|
border-style: solid;
|
|
85
94
|
border-color: ${getColorValue('border')};
|
|
86
95
|
border-width: ${props => (props.hasDividers ? '1px 0' : '0')};
|
|
@@ -102,7 +111,6 @@ export const ModalCard = (_a) => {
|
|
|
102
111
|
}
|
|
103
112
|
const keyListener = e => {
|
|
104
113
|
if (e.key === 'Escape') {
|
|
105
|
-
e.preventDefault();
|
|
106
114
|
onCloseClick(e);
|
|
107
115
|
}
|
|
108
116
|
};
|
|
@@ -111,17 +119,28 @@ export const ModalCard = (_a) => {
|
|
|
111
119
|
window.removeEventListener('keydown', keyListener);
|
|
112
120
|
};
|
|
113
121
|
}, [isOpen, onCloseClick]);
|
|
114
|
-
return (React.createElement(FocusTrap, { active: isOpen
|
|
122
|
+
return (React.createElement(FocusTrap, { active: isOpen, focusTrapOptions: {
|
|
123
|
+
clickOutsideDeactivates: false,
|
|
124
|
+
allowOutsideClick: true,
|
|
125
|
+
} },
|
|
115
126
|
React.createElement(ModalCardWrapper, Object.assign({ open: isOpen, maxWidth: maxWidth, onClick: e => e.stopPropagation(), ref: ref }, props),
|
|
116
127
|
onCloseClick && (React.createElement(CloseIconSection, null,
|
|
117
128
|
React.createElement(IconButton, { altText: "Close", icon: React.createElement(SvgClose, null), onClick: onCloseClick }))),
|
|
118
129
|
React.createElement(ModalCardChildrenSection, null, children))));
|
|
119
130
|
};
|
|
120
131
|
const Modal = React.forwardRef((_a, ref) => {
|
|
121
|
-
var { children, isOpen, mainButton, secondaryButton, alternativeButton, title, onCloseClick, onBackgroundClick, onKeyDown, hasDividers, maxWidth = 60, zIndex = 1000 } = _a, props = __rest(_a, ["children", "isOpen", "mainButton", "secondaryButton", "alternativeButton", "title", "onCloseClick", "onBackgroundClick", "onKeyDown", "hasDividers", "maxWidth", "zIndex"]);
|
|
132
|
+
var { children, isOpen, mainButton, secondaryButton, alternativeButton, title, noPadding, onCloseClick, onBackgroundClick, onKeyDown, hasDividers, maxWidth = 60, zIndex = 1000 } = _a, props = __rest(_a, ["children", "isOpen", "mainButton", "secondaryButton", "alternativeButton", "title", "noPadding", "onCloseClick", "onBackgroundClick", "onKeyDown", "hasDividers", "maxWidth", "zIndex"]);
|
|
122
133
|
const hasButtons = mainButton || secondaryButton || alternativeButton ? true : false;
|
|
134
|
+
const closeClickHandler = e => {
|
|
135
|
+
if (onBackgroundClick) {
|
|
136
|
+
e.stopPropagation();
|
|
137
|
+
onBackgroundClick(e);
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
onCloseClick(e);
|
|
141
|
+
};
|
|
123
142
|
return (React.createElement(Backdrop, Object.assign({ isOpen: isOpen, zIndex: zIndex }, props),
|
|
124
|
-
React.createElement(Container, { height: "100%", onClick:
|
|
143
|
+
React.createElement(Container, { height: "100%", onClick: closeClickHandler, onKeyDown: onKeyDown },
|
|
125
144
|
React.createElement(ModalCard, { ref: ref,
|
|
126
145
|
// TODO: LNS-148: Add aria labelling for screenreader support
|
|
127
146
|
// ariaLabelledBy={title}
|
|
@@ -131,7 +150,7 @@ const Modal = React.forwardRef((_a, ref) => {
|
|
|
131
150
|
? 'var(--lns-space-medium)'
|
|
132
151
|
: 'var(--lns-space-xlarge)' },
|
|
133
152
|
React.createElement(Text, { variant: "title" }, title))),
|
|
134
|
-
React.createElement(ChildrenSection, { hasDividers: hasDividers, hasTitle: Boolean(title), hasButtons: hasButtons }, children && children),
|
|
153
|
+
React.createElement(ChildrenSection, { noPadding: noPadding, hasDividers: hasDividers, hasTitle: Boolean(title), hasButtons: hasButtons }, children && children),
|
|
135
154
|
hasButtons && (React.createElement(ButtonsSection, { top: children ? 'var(--lns-space-xlarge)' : 0, hasDividers: hasDividers },
|
|
136
155
|
alternativeButton,
|
|
137
156
|
React.createElement(RightButtonsSection, null,
|