@loomhq/lens 10.55.1 → 10.56.1
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,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
declare const ModalCardWrapper: import("@emotion/styled-base").StyledComponent<React.DetailedHTMLProps<React.DialogHTMLAttributes<HTMLDialogElement>, HTMLDialogElement>, ModalCardProps, object>;
|
|
3
|
-
export declare const ModalCard: ({ children, onCloseClick, isOpen, maxWidth, ref, ...props }: ModalCardProps & React.ComponentProps<typeof ModalCardWrapper>) => JSX.Element;
|
|
3
|
+
export declare const ModalCard: ({ children, onCloseClick, isOpen, maxWidth, maxHeight, placement, ref, ...props }: ModalCardProps & React.ComponentProps<typeof ModalCardWrapper>) => JSX.Element;
|
|
4
4
|
declare const Modal: React.ForwardRefExoticComponent<Pick<ModalProps & {
|
|
5
5
|
isOpen?: boolean;
|
|
6
6
|
children?: React.ReactNode;
|
|
@@ -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" | "noPadding" | "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" | "maxHeight" | "maxWidth" | "zIndex" | "theme" | "isOpen" | "onCloseClick" | "placement" | "hasDividers" | "noPadding" | "mainButton" | "secondaryButton" | "alternativeButton" | "onBackgroundClick"> & React.RefAttributes<HTMLDialogElement>>;
|
|
12
12
|
declare type ModalProps = {
|
|
13
13
|
children?: React.ReactNode;
|
|
14
14
|
isOpen?: boolean;
|
|
@@ -20,8 +20,10 @@ declare type ModalProps = {
|
|
|
20
20
|
onBackgroundClick?: React.ReactEventHandler;
|
|
21
21
|
onKeyDown?: React.ReactEventHandler;
|
|
22
22
|
hasDividers?: boolean;
|
|
23
|
+
maxHeight?: number | string;
|
|
23
24
|
maxWidth?: number | string;
|
|
24
25
|
noPadding?: boolean;
|
|
26
|
+
placement?: 'center' | 'bottom';
|
|
25
27
|
zIndex?: number;
|
|
26
28
|
};
|
|
27
29
|
declare type ModalCardProps = {
|
|
@@ -30,6 +32,8 @@ declare type ModalCardProps = {
|
|
|
30
32
|
isOpen?: boolean;
|
|
31
33
|
onKeyDown?: React.ReactEventHandler;
|
|
32
34
|
onCloseClick?: React.ReactEventHandler;
|
|
35
|
+
placement?: string;
|
|
36
|
+
maxHeight?: number | string;
|
|
33
37
|
maxWidth?: number | string;
|
|
34
38
|
};
|
|
35
39
|
export default Modal;
|
|
@@ -9,8 +9,9 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
+
// TODO(LNS-183): Implement scroll-lock
|
|
12
13
|
import FocusTrap from 'focus-trap-react';
|
|
13
|
-
import { getColorValue, getRadius, getShadow, getSize, u, } from '../../utilities';
|
|
14
|
+
import { getColorValue, getPlacement, getRadius, getShadow, getSize, getSizeValue, u, } from '../../utilities';
|
|
14
15
|
import React, { useEffect } from 'react';
|
|
15
16
|
import Backdrop from '../backdrop/backdrop';
|
|
16
17
|
import Container from '../container/container';
|
|
@@ -24,17 +25,21 @@ const ContentWrapper = styled.div `
|
|
|
24
25
|
display: grid;
|
|
25
26
|
grid-template-rows: ${props => props.rows};
|
|
26
27
|
position: relative;
|
|
27
|
-
max-height: ${modalCardHeight};
|
|
28
28
|
`;
|
|
29
29
|
const ModalCardWrapper = styled.dialog `
|
|
30
|
-
|
|
31
|
-
top: 15vh;
|
|
30
|
+
top: ${props => getPlacement(getSizeValue(props.maxHeight), props.placement).top};
|
|
32
31
|
background-color: ${getColorValue('overlay')};
|
|
32
|
+
color: ${getColorValue('body')};
|
|
33
|
+
bottom: ${props => getPlacement(props.maxHeight, props.placement).bottom};
|
|
33
34
|
${getShadow('large')};
|
|
34
35
|
${getRadius('thdMediumToXlarge')};
|
|
36
|
+
// Unsets bottom-radius for bottom-aligned modals
|
|
37
|
+
border-bottom-left-radius: ${props => props.placement === 'bottom' ? 'initial' : undefined};
|
|
38
|
+
border-bottom-right-radius: ${props => props.placement === 'bottom' ? 'initial' : undefined};
|
|
39
|
+
${props => getSize('max-height', props.maxHeight)};
|
|
35
40
|
${props => getSize('max-width', props.maxWidth)};
|
|
36
41
|
margin: 0 auto;
|
|
37
|
-
position:
|
|
42
|
+
position: ${props => getPlacement(props.maxHeight, props.placement).position};
|
|
38
43
|
overflow: auto;
|
|
39
44
|
width: 100%;
|
|
40
45
|
// TODO: LNS-150: Bake dialog resets into native resets file
|
|
@@ -104,7 +109,7 @@ const ModalCardChildrenSection = styled.div `
|
|
|
104
109
|
`;
|
|
105
110
|
export const ModalCard = (_a) => {
|
|
106
111
|
// TODO: LNS-151: Abstract into useKeyDown hook for reuse
|
|
107
|
-
var { children, onCloseClick, isOpen, maxWidth = 60, ref } = _a, props = __rest(_a, ["children", "onCloseClick", "isOpen", "maxWidth", "ref"]);
|
|
112
|
+
var { children, onCloseClick, isOpen, maxWidth = 60, maxHeight = '70vh', placement = 'center', ref } = _a, props = __rest(_a, ["children", "onCloseClick", "isOpen", "maxWidth", "maxHeight", "placement", "ref"]);
|
|
108
113
|
useEffect(() => {
|
|
109
114
|
if (!isOpen) {
|
|
110
115
|
return;
|
|
@@ -124,13 +129,13 @@ export const ModalCard = (_a) => {
|
|
|
124
129
|
clickOutsideDeactivates: false,
|
|
125
130
|
allowOutsideClick: true,
|
|
126
131
|
} },
|
|
127
|
-
React.createElement(ModalCardWrapper, Object.assign({ open: isOpen, maxWidth: maxWidth, onClick: e => e.stopPropagation(), ref: ref }, props),
|
|
132
|
+
React.createElement(ModalCardWrapper, Object.assign({ open: isOpen, maxWidth: maxWidth, maxHeight: maxHeight, placement: placement, onClick: e => e.stopPropagation(), ref: ref }, props),
|
|
128
133
|
onCloseClick && (React.createElement(CloseIconSection, null,
|
|
129
134
|
React.createElement(IconButton, { altText: "Close", icon: React.createElement(SvgClose, null), onClick: onCloseClick }))),
|
|
130
135
|
React.createElement(ModalCardChildrenSection, null, children))));
|
|
131
136
|
};
|
|
132
137
|
const Modal = React.forwardRef((_a, ref) => {
|
|
133
|
-
var { children, id, isOpen, mainButton, secondaryButton, alternativeButton, title, noPadding, onCloseClick, onBackgroundClick, onKeyDown, hasDividers, maxWidth = 60, zIndex = 1000 } = _a, props = __rest(_a, ["children", "id", "isOpen", "mainButton", "secondaryButton", "alternativeButton", "title", "noPadding", "onCloseClick", "onBackgroundClick", "onKeyDown", "hasDividers", "maxWidth", "zIndex"]);
|
|
138
|
+
var { children, id, isOpen, mainButton, secondaryButton, alternativeButton, title, noPadding, onCloseClick, onBackgroundClick, onKeyDown, hasDividers, maxHeight = '70vh', maxWidth = 60, placement = 'center', zIndex = 1000 } = _a, props = __rest(_a, ["children", "id", "isOpen", "mainButton", "secondaryButton", "alternativeButton", "title", "noPadding", "onCloseClick", "onBackgroundClick", "onKeyDown", "hasDividers", "maxHeight", "maxWidth", "placement", "zIndex"]);
|
|
134
139
|
const hasButtons = mainButton || secondaryButton || alternativeButton ? true : false;
|
|
135
140
|
const closeClickHandler = e => {
|
|
136
141
|
if (onBackgroundClick) {
|
|
@@ -145,7 +150,7 @@ const Modal = React.forwardRef((_a, ref) => {
|
|
|
145
150
|
React.createElement(ModalCard, { ref: ref,
|
|
146
151
|
// TODO: LNS-148: Add aria labelling for screenreader support
|
|
147
152
|
// ariaLabelledBy={title}
|
|
148
|
-
id: id, isOpen: isOpen, maxWidth: maxWidth, onCloseClick: onCloseClick },
|
|
153
|
+
id: id, isOpen: isOpen, maxHeight: maxHeight, maxWidth: maxWidth, placement: placement, onCloseClick: onCloseClick },
|
|
149
154
|
React.createElement(ContentWrapper, { rows: `${title ? 'auto ' : ''} ${children ? '1fr ' : ''} ${hasButtons ? 'auto' : ''}` },
|
|
150
155
|
title && (React.createElement(TitleSection, { bottom: children
|
|
151
156
|
? 'var(--lns-space-medium)'
|
|
@@ -3,3 +3,4 @@ export function getRadius(size: any): string;
|
|
|
3
3
|
export function getFontWeight(fontWeight: any): string;
|
|
4
4
|
export function getShadow(size: any): string;
|
|
5
5
|
export function getFocusRing(color: any, position: any): string;
|
|
6
|
+
export function getPlacement(maxHeight: any, placement: any): any;
|
package/dist/utilities/styles.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// TODO(LNS-185): Convert all utils to ts
|
|
1
2
|
import { getColorValue } from './color';
|
|
2
3
|
export const getTextSize = size => size &&
|
|
3
4
|
`
|
|
@@ -11,3 +12,23 @@ export const getFocusRing = (color, position) => {
|
|
|
11
12
|
const focusColor = color ? color : getColorValue('focusRing');
|
|
12
13
|
return `box-shadow:${position ? position : ''} 0 0 0 2px ${focusColor};`;
|
|
13
14
|
};
|
|
15
|
+
export const getPlacement = (maxHeight, placement) => {
|
|
16
|
+
const placementStyles = {
|
|
17
|
+
center: {
|
|
18
|
+
bottom: 0,
|
|
19
|
+
top: `calc((100vh - ${maxHeight}) / 2)`,
|
|
20
|
+
position: 'relative',
|
|
21
|
+
},
|
|
22
|
+
bottom: {
|
|
23
|
+
bottom: 0,
|
|
24
|
+
top: 'unset',
|
|
25
|
+
position: 'absolute',
|
|
26
|
+
},
|
|
27
|
+
undefined: {
|
|
28
|
+
bottom: undefined,
|
|
29
|
+
top: '15vh',
|
|
30
|
+
position: 'relative',
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
return placementStyles[placement];
|
|
34
|
+
};
|