@loomhq/lens 10.55.0 → 10.56.0

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.
@@ -18,7 +18,7 @@ import styled from '@emotion/styled';
18
18
  const MenuWrapper = styled.ul `
19
19
  background-color: ${getColorValue('overlay')};
20
20
  list-style: none;
21
- padding: ${u(1)} 0;
21
+ padding: ${u(1.5)};
22
22
  margin: 0;
23
23
  ${props => getSize('min-width', props.minWidth)};
24
24
  ${props => getSize('max-width', props.maxWidth)};
@@ -34,6 +34,7 @@ const MenuItemWrapper = styled.li `
34
34
  grid-auto-flow: column;
35
35
  grid-template-columns: ${props => props.columns};
36
36
  ${getSize('grid-gap', 'small')};
37
+ ${getRadius('thdMediumToXlarge')};
37
38
  align-items: center;
38
39
  min-height: ${u(5)};
39
40
  padding: 0 ${u(2)};
@@ -45,7 +46,16 @@ const MenuItemWrapper = styled.li `
45
46
  `};
46
47
  ${props => props.hasDivider &&
47
48
  `
48
- border-top: 1px solid ${getColorValue('border')};
49
+ position: relative;
50
+ margin-top: ${u(3)};
51
+ &:before {
52
+ content: '';
53
+ border-top: 1px solid ${getColorValue('border')};
54
+ position: absolute;
55
+ top: ${u(-1.5)};
56
+ left: ${u(-1.5)};
57
+ width: calc(100% + ${u(3)});
58
+ }
49
59
  `};
50
60
  `;
51
61
  export const MenuItem = (_a) => {
@@ -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,20 @@ 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
- max-height: ${modalCardHeight};
31
- top: 15vh;
30
+ top: ${props => getPlacement(getSizeValue(props.maxHeight), props.placement).top};
32
31
  background-color: ${getColorValue('overlay')};
32
+ bottom: ${props => getPlacement(props.maxHeight, props.placement).bottom};
33
33
  ${getShadow('large')};
34
34
  ${getRadius('thdMediumToXlarge')};
35
+ // Unsets bottom-radius for bottom-aligned modals
36
+ border-bottom-left-radius: ${props => props.placement === 'bottom' ? 'initial' : undefined};
37
+ border-bottom-right-radius: ${props => props.placement === 'bottom' ? 'initial' : undefined};
38
+ ${props => getSize('max-height', props.maxHeight)};
35
39
  ${props => getSize('max-width', props.maxWidth)};
36
40
  margin: 0 auto;
37
- position: relative;
41
+ position: ${props => getPlacement(props.maxHeight, props.placement).position};
38
42
  overflow: auto;
39
43
  width: 100%;
40
44
  // TODO: LNS-150: Bake dialog resets into native resets file
@@ -104,7 +108,7 @@ const ModalCardChildrenSection = styled.div `
104
108
  `;
105
109
  export const ModalCard = (_a) => {
106
110
  // 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"]);
111
+ var { children, onCloseClick, isOpen, maxWidth = 60, maxHeight = '70vh', placement = 'center', ref } = _a, props = __rest(_a, ["children", "onCloseClick", "isOpen", "maxWidth", "maxHeight", "placement", "ref"]);
108
112
  useEffect(() => {
109
113
  if (!isOpen) {
110
114
  return;
@@ -124,13 +128,13 @@ export const ModalCard = (_a) => {
124
128
  clickOutsideDeactivates: false,
125
129
  allowOutsideClick: true,
126
130
  } },
127
- React.createElement(ModalCardWrapper, Object.assign({ open: isOpen, maxWidth: maxWidth, onClick: e => e.stopPropagation(), ref: ref }, props),
131
+ React.createElement(ModalCardWrapper, Object.assign({ open: isOpen, maxWidth: maxWidth, maxHeight: maxHeight, placement: placement, onClick: e => e.stopPropagation(), ref: ref }, props),
128
132
  onCloseClick && (React.createElement(CloseIconSection, null,
129
133
  React.createElement(IconButton, { altText: "Close", icon: React.createElement(SvgClose, null), onClick: onCloseClick }))),
130
134
  React.createElement(ModalCardChildrenSection, null, children))));
131
135
  };
132
136
  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"]);
137
+ 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
138
  const hasButtons = mainButton || secondaryButton || alternativeButton ? true : false;
135
139
  const closeClickHandler = e => {
136
140
  if (onBackgroundClick) {
@@ -145,7 +149,7 @@ const Modal = React.forwardRef((_a, ref) => {
145
149
  React.createElement(ModalCard, { ref: ref,
146
150
  // TODO: LNS-148: Add aria labelling for screenreader support
147
151
  // ariaLabelledBy={title}
148
- id: id, isOpen: isOpen, maxWidth: maxWidth, onCloseClick: onCloseClick },
152
+ id: id, isOpen: isOpen, maxHeight: maxHeight, maxWidth: maxWidth, placement: placement, onCloseClick: onCloseClick },
149
153
  React.createElement(ContentWrapper, { rows: `${title ? 'auto ' : ''} ${children ? '1fr ' : ''} ${hasButtons ? 'auto' : ''}` },
150
154
  title && (React.createElement(TitleSection, { bottom: children
151
155
  ? '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;
@@ -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
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loomhq/lens",
3
- "version": "10.55.0",
3
+ "version": "10.56.0",
4
4
  "scripts": {
5
5
  "dev": "next",
6
6
  "build:next": "next build",