baseui 0.0.0-next-3a57782 → 0.0.0-next-d12da36

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.
@@ -13,8 +13,3 @@ export declare const PLACEMENT: Readonly<{
13
13
  readonly bottomCenter: "bottomCenter";
14
14
  readonly bottomRight: "bottomRight";
15
15
  }>;
16
- export declare const CLOSE_KIND: Readonly<{
17
- readonly notCloseable: "notCloseable";
18
- readonly closeable: "closeable";
19
- readonly closeableWithButton: "closeableWithButton";
20
- }>;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.SIZE = exports.PLACEMENT = exports.CLOSE_KIND = void 0;
6
+ exports.SIZE = exports.PLACEMENT = void 0;
7
7
 
8
8
  /*
9
9
  Copyright (c) Uber Technologies, Inc.
@@ -27,10 +27,4 @@ var PLACEMENT = Object.freeze({
27
27
  bottomCenter: 'bottomCenter',
28
28
  bottomRight: 'bottomRight'
29
29
  });
30
- exports.PLACEMENT = PLACEMENT;
31
- var CLOSE_KIND = Object.freeze({
32
- notCloseable: 'notCloseable',
33
- closeable: 'closeable',
34
- closeableWithButton: 'closeableWithButton'
35
- });
36
- exports.CLOSE_KIND = CLOSE_KIND;
30
+ exports.PLACEMENT = PLACEMENT;
@@ -1,4 +1,4 @@
1
1
  /// <reference types="react" />
2
2
  import type { DialogProps } from './types';
3
- declare const Dialog: ({ artwork, buttonDock, children, closeKind, handleClose, hasOverlay, heading, isOpen, overrides, placement, numHeadingLines, size, }: DialogProps) => JSX.Element;
3
+ declare const Dialog: ({ artwork, buttonDock, children, handleDismiss, showDismissButton, hasOverlay, heading, isOpen, overrides, placement, numHeadingLines, size, }: DialogProps) => JSX.Element;
4
4
  export default Dialog;
package/dialog/dialog.js CHANGED
@@ -52,7 +52,7 @@ function renderArtwork(artwork) {
52
52
  return null;
53
53
  }
54
54
 
55
- var DefaultCloseButton = function DefaultCloseButton(props) {
55
+ var DefaultDismissButton = function DefaultDismissButton(props) {
56
56
  var overrides = {
57
57
  BaseButton: {
58
58
  style: {
@@ -97,9 +97,9 @@ var Dialog = function Dialog(_ref) {
97
97
  var artwork = _ref.artwork,
98
98
  buttonDock = _ref.buttonDock,
99
99
  children = _ref.children,
100
- _ref$closeKind = _ref.closeKind,
101
- closeKind = _ref$closeKind === void 0 ? _constants.CLOSE_KIND.closeableWithButton : _ref$closeKind,
102
- handleClose = _ref.handleClose,
100
+ handleDismiss = _ref.handleDismiss,
101
+ _ref$showDismissButto = _ref.showDismissButton,
102
+ showDismissButton = _ref$showDismissButto === void 0 ? true : _ref$showDismissButto,
103
103
  _ref$hasOverlay = _ref.hasOverlay,
104
104
  hasOverlay = _ref$hasOverlay === void 0 ? true : _ref$hasOverlay,
105
105
  heading = _ref.heading,
@@ -138,10 +138,10 @@ var Dialog = function Dialog(_ref) {
138
138
  ButtonDock = _getOverrides10[0],
139
139
  buttonDockProps = _getOverrides10[1];
140
140
 
141
- var _getOverrides11 = (0, _overrides.getOverrides)(overrides.CloseButton, DefaultCloseButton),
141
+ var _getOverrides11 = (0, _overrides.getOverrides)(overrides.DismissButton, DefaultDismissButton),
142
142
  _getOverrides12 = _slicedToArray(_getOverrides11, 2),
143
- CloseButton = _getOverrides12[0],
144
- closeButtonProps = _getOverrides12[1];
143
+ DismissButton = _getOverrides12[0],
144
+ dismissButtonProps = _getOverrides12[1];
145
145
 
146
146
  var dialogRef = _react.default.useRef(null);
147
147
 
@@ -159,13 +159,13 @@ var Dialog = function Dialog(_ref) {
159
159
 
160
160
  function handleOutsideClick(e) {
161
161
  if (!dialogRef.current.contains(e.target) || e.target.nodeName === 'DIALOG') {
162
- handleClose();
162
+ handleDismiss();
163
163
  }
164
164
  }
165
165
 
166
166
  function handleEscapeKey(e) {
167
167
  if (e.key === 'Escape') {
168
- handleClose();
168
+ handleDismiss();
169
169
  }
170
170
  }
171
171
 
@@ -193,11 +193,11 @@ var Dialog = function Dialog(_ref) {
193
193
  $isOpen: isOpen,
194
194
  $size: size,
195
195
  $placement: placement
196
- }, rootProps), closeKind === _constants.CLOSE_KIND.closeableWithButton && /*#__PURE__*/_react.default.createElement(CloseButton, _extends({
196
+ }, rootProps), handleDismiss && showDismissButton && /*#__PURE__*/_react.default.createElement(DismissButton, _extends({
197
197
  onClick: function onClick() {
198
- return handleClose();
198
+ return handleDismiss();
199
199
  }
200
- }, closeButtonProps)), /*#__PURE__*/_react.default.createElement(ScrollContainer, _extends({}, scrollContainerProps, {
200
+ }, dismissButtonProps)), /*#__PURE__*/_react.default.createElement(ScrollContainer, _extends({}, scrollContainerProps, {
201
201
  tabIndex: 0
202
202
  }), renderArtwork(artwork), /*#__PURE__*/_react.default.createElement(Heading, _extends({
203
203
  $numHeadingLines: numHeadingLines
@@ -27,24 +27,17 @@ declare export var PLACEMENT: {
27
27
  bottomRight: 'bottomRight',
28
28
  };
29
29
 
30
- declare export var CLOSE_KIND: {
31
- notCloseable: 'notCloseable',
32
- closeable: 'closeable',
33
- closeableWithButton: 'closeableWithButton',
34
- };
35
-
36
30
  export type DialogOverridesT = {
37
31
  Root?: OverrideT,
38
32
  ScrollContainer?: OverrideT,
39
33
  Heading?: OverrideT,
40
34
  Body?: OverrideT,
41
35
  ButtonDock?: OverrideT,
42
- CloseButton?: OverrideT,
36
+ DismissButton?: OverrideT,
43
37
  };
44
38
 
45
39
  export type SizeT = $Values<typeof SIZE>;
46
40
  export type PlacementT = $Values<typeof PLACEMENT>;
47
- export type CloseKindT = $Values<typeof CLOSE_KIND>;
48
41
  //flowlint-next-line unclear-type:off
49
42
  export type ArtworkT = React.Element<any> | React.ComponentType<{}>;
50
43
 
@@ -52,8 +45,8 @@ export type DialogPropsT = {
52
45
  artwork?: ArtworkT,
53
46
  buttonDock?: ButtonDockPropsT,
54
47
  children?: React.Node,
55
- closeKind?: CloseKindT,
56
- handleClose?: () => void,
48
+ handleDismiss?: () => void,
49
+ showDismissButton?: boolean,
57
50
  hasOverlay?: boolean,
58
51
  heading: string,
59
52
  isOpen: boolean,
@@ -91,6 +91,8 @@ var StyledRoot = (0, _styles.styled)('dialog', function (_ref) {
91
91
  maxWidth: "calc(100% - 2 * ".concat(wideViewportGutter, ")"),
92
92
  borderRadius: $theme.borders.radius500,
93
93
  boxShadow: $theme.lighting.shallowBelow,
94
+ backgroundColor: $theme.colors.backgroundPrimary,
95
+ color: $theme.colors.contentPrimary,
94
96
  overflow: 'hidden',
95
97
  border: 'none',
96
98
  width: DIALOG_WIDTHS[$size]
package/dialog/types.d.ts CHANGED
@@ -2,30 +2,36 @@ import type * as React from 'react';
2
2
  import type { ComponentType, ReactElement } from 'react';
3
3
  import type { Override } from '../helpers/overrides';
4
4
  import type { ButtonDockProps } from '../button-dock';
5
- import type { SIZE, PLACEMENT, CLOSE_KIND } from './constants';
5
+ import type { SIZE, PLACEMENT } from './constants';
6
6
  export type DialogOverrides = {
7
7
  Root?: Override;
8
8
  ScrollContainer?: Override;
9
9
  Heading?: Override;
10
10
  Body?: Override;
11
11
  ButtonDock?: Override;
12
- CloseButton?: Override;
12
+ DismissButton?: Override;
13
13
  };
14
14
  export type Size = (typeof SIZE)[keyof typeof SIZE];
15
15
  export type Placement = (typeof PLACEMENT)[keyof typeof PLACEMENT];
16
- export type CloseKind = (typeof CLOSE_KIND)[keyof typeof CLOSE_KIND];
17
- export type Artwork<P = {}> = ReactElement | ComponentType<P>;
16
+ export type Artwork = ReactElement | ComponentType<{}>;
18
17
  export type DialogProps = {
19
18
  artwork?: Artwork;
19
+ /** Passes through directly to the internal ButtonDock instance within the Dialog component. */
20
20
  buttonDock?: ButtonDockProps;
21
+ /** The contents of the body of Dialog */
21
22
  children?: React.ReactNode | (() => React.ReactNode);
22
- closeKind?: CloseKind;
23
- handleClose?: () => void;
23
+ /** Determine if and how dialog can be dismissed */
24
+ handleDismiss?: () => void | null;
25
+ /** Should Dialog include a dedicated X button to dismiss the dialog. Ignored if handleDismiss is not supplied. */
26
+ showDismissButton?: boolean;
27
+ /** Determines whether the background behind the Dialog is dimmed when Dialog is open */
24
28
  hasOverlay?: boolean;
25
29
  heading: string;
26
30
  isOpen: boolean;
31
+ /** The maximum number of lines before heading truncates */
27
32
  numHeadingLines?: number;
28
33
  overrides?: DialogOverrides;
34
+ /** Determines where on the screen the dialog appears when open */
29
35
  placement?: Placement;
30
36
  size?: Size;
31
37
  };
@@ -18,9 +18,4 @@ export const PLACEMENT = Object.freeze({
18
18
  bottomLeft: 'bottomLeft',
19
19
  bottomCenter: 'bottomCenter',
20
20
  bottomRight: 'bottomRight'
21
- });
22
- export const CLOSE_KIND = Object.freeze({
23
- notCloseable: 'notCloseable',
24
- closeable: 'closeable',
25
- closeableWithButton: 'closeableWithButton'
26
21
  });
@@ -13,7 +13,7 @@ import { ButtonDock } from '../button-dock';
13
13
  import { Button, KIND, SHAPE } from '../button';
14
14
  import { Delete } from '../icon';
15
15
  import { StyledHeading, StyledBody, StyledRoot, StyledScrollContainer } from './styled-components';
16
- import { CLOSE_KIND, PLACEMENT, SIZE } from './constants';
16
+ import { PLACEMENT, SIZE } from './constants';
17
17
 
18
18
  function renderArtwork(artwork) {
19
19
  if ( /*#__PURE__*/isValidElement(artwork)) {
@@ -26,7 +26,7 @@ function renderArtwork(artwork) {
26
26
  return null;
27
27
  }
28
28
 
29
- const DefaultCloseButton = props => {
29
+ const DefaultDismissButton = props => {
30
30
  const overrides = {
31
31
  BaseButton: {
32
32
  style: {
@@ -68,8 +68,8 @@ const Dialog = ({
68
68
  artwork,
69
69
  buttonDock,
70
70
  children,
71
- closeKind = CLOSE_KIND.closeableWithButton,
72
- handleClose,
71
+ handleDismiss,
72
+ showDismissButton = true,
73
73
  hasOverlay = true,
74
74
  heading,
75
75
  isOpen,
@@ -83,7 +83,7 @@ const Dialog = ({
83
83
  const [Heading, headingProps] = getOverrides(overrides.Heading, StyledHeading);
84
84
  const [Body, bodyProps] = getOverrides(overrides.Body, StyledBody);
85
85
  const [ButtonDock, buttonDockProps] = getOverrides(overrides.ButtonDock, DefaultButtonDock);
86
- const [CloseButton, closeButtonProps] = getOverrides(overrides.CloseButton, DefaultCloseButton);
86
+ const [DismissButton, dismissButtonProps] = getOverrides(overrides.DismissButton, DefaultDismissButton);
87
87
  const dialogRef = React.useRef(null);
88
88
  React.useEffect(() => {
89
89
  if (isOpen) {
@@ -99,13 +99,13 @@ const Dialog = ({
99
99
 
100
100
  function handleOutsideClick(e) {
101
101
  if (!dialogRef.current.contains(e.target) || e.target.nodeName === 'DIALOG') {
102
- handleClose();
102
+ handleDismiss();
103
103
  }
104
104
  }
105
105
 
106
106
  function handleEscapeKey(e) {
107
107
  if (e.key === 'Escape') {
108
- handleClose();
108
+ handleDismiss();
109
109
  }
110
110
  }
111
111
 
@@ -132,9 +132,9 @@ const Dialog = ({
132
132
  $isOpen: isOpen,
133
133
  $size: size,
134
134
  $placement: placement
135
- }, rootProps), closeKind === CLOSE_KIND.closeableWithButton && /*#__PURE__*/React.createElement(CloseButton, _extends({
136
- onClick: () => handleClose()
137
- }, closeButtonProps)), /*#__PURE__*/React.createElement(ScrollContainer, _extends({}, scrollContainerProps, {
135
+ }, rootProps), handleDismiss && showDismissButton && /*#__PURE__*/React.createElement(DismissButton, _extends({
136
+ onClick: () => handleDismiss()
137
+ }, dismissButtonProps)), /*#__PURE__*/React.createElement(ScrollContainer, _extends({}, scrollContainerProps, {
138
138
  tabIndex: 0
139
139
  }), renderArtwork(artwork), /*#__PURE__*/React.createElement(Heading, _extends({
140
140
  $numHeadingLines: numHeadingLines
@@ -86,6 +86,8 @@ export const StyledRoot = styled('dialog', ({
86
86
  maxWidth: `calc(100% - 2 * ${wideViewportGutter})`,
87
87
  borderRadius: $theme.borders.radius500,
88
88
  boxShadow: $theme.lighting.shallowBelow,
89
+ backgroundColor: $theme.colors.backgroundPrimary,
90
+ color: $theme.colors.contentPrimary,
89
91
  overflow: 'hidden',
90
92
  border: 'none',
91
93
  width: DIALOG_WIDTHS[$size],
@@ -204,10 +204,11 @@ export const RadioMarkInner = styled('div', props => {
204
204
  borderTopRightRadius: '50%',
205
205
  borderBottomRightRadius: '50%',
206
206
  borderBottomLeftRadius: '50%',
207
- height: props.$checked ? sizing.scale200 : sizing.scale550,
207
+ height: '100%',
208
208
  transitionDuration: animation.timing200,
209
209
  transitionTimingFunction: animation.easeOutCurve,
210
- width: props.$checked ? sizing.scale200 : sizing.scale550
210
+ width: '100%',
211
+ transform: props.$checked ? 'scale(.3)' : 'scale(.7)'
211
212
  };
212
213
  });
213
214
  RadioMarkInner.displayName = "RadioMarkInner";
@@ -18,9 +18,4 @@ export var PLACEMENT = Object.freeze({
18
18
  bottomLeft: 'bottomLeft',
19
19
  bottomCenter: 'bottomCenter',
20
20
  bottomRight: 'bottomRight'
21
- });
22
- export var CLOSE_KIND = Object.freeze({
23
- notCloseable: 'notCloseable',
24
- closeable: 'closeable',
25
- closeableWithButton: 'closeableWithButton'
26
21
  });
@@ -25,7 +25,7 @@ import { ButtonDock } from '../button-dock';
25
25
  import { Button, KIND, SHAPE } from '../button';
26
26
  import { Delete } from '../icon';
27
27
  import { StyledHeading, StyledBody, StyledRoot, StyledScrollContainer } from './styled-components';
28
- import { CLOSE_KIND, PLACEMENT, SIZE } from './constants';
28
+ import { PLACEMENT, SIZE } from './constants';
29
29
 
30
30
  function renderArtwork(artwork) {
31
31
  if ( /*#__PURE__*/isValidElement(artwork)) {
@@ -38,7 +38,7 @@ function renderArtwork(artwork) {
38
38
  return null;
39
39
  }
40
40
 
41
- var DefaultCloseButton = function DefaultCloseButton(props) {
41
+ var DefaultDismissButton = function DefaultDismissButton(props) {
42
42
  var overrides = {
43
43
  BaseButton: {
44
44
  style: {
@@ -83,9 +83,9 @@ var Dialog = function Dialog(_ref) {
83
83
  var artwork = _ref.artwork,
84
84
  buttonDock = _ref.buttonDock,
85
85
  children = _ref.children,
86
- _ref$closeKind = _ref.closeKind,
87
- closeKind = _ref$closeKind === void 0 ? CLOSE_KIND.closeableWithButton : _ref$closeKind,
88
- handleClose = _ref.handleClose,
86
+ handleDismiss = _ref.handleDismiss,
87
+ _ref$showDismissButto = _ref.showDismissButton,
88
+ showDismissButton = _ref$showDismissButto === void 0 ? true : _ref$showDismissButto,
89
89
  _ref$hasOverlay = _ref.hasOverlay,
90
90
  hasOverlay = _ref$hasOverlay === void 0 ? true : _ref$hasOverlay,
91
91
  heading = _ref.heading,
@@ -124,10 +124,10 @@ var Dialog = function Dialog(_ref) {
124
124
  ButtonDock = _getOverrides10[0],
125
125
  buttonDockProps = _getOverrides10[1];
126
126
 
127
- var _getOverrides11 = getOverrides(overrides.CloseButton, DefaultCloseButton),
127
+ var _getOverrides11 = getOverrides(overrides.DismissButton, DefaultDismissButton),
128
128
  _getOverrides12 = _slicedToArray(_getOverrides11, 2),
129
- CloseButton = _getOverrides12[0],
130
- closeButtonProps = _getOverrides12[1];
129
+ DismissButton = _getOverrides12[0],
130
+ dismissButtonProps = _getOverrides12[1];
131
131
 
132
132
  var dialogRef = React.useRef(null);
133
133
  React.useEffect(function () {
@@ -144,13 +144,13 @@ var Dialog = function Dialog(_ref) {
144
144
 
145
145
  function handleOutsideClick(e) {
146
146
  if (!dialogRef.current.contains(e.target) || e.target.nodeName === 'DIALOG') {
147
- handleClose();
147
+ handleDismiss();
148
148
  }
149
149
  }
150
150
 
151
151
  function handleEscapeKey(e) {
152
152
  if (e.key === 'Escape') {
153
- handleClose();
153
+ handleDismiss();
154
154
  }
155
155
  }
156
156
 
@@ -177,11 +177,11 @@ var Dialog = function Dialog(_ref) {
177
177
  $isOpen: isOpen,
178
178
  $size: size,
179
179
  $placement: placement
180
- }, rootProps), closeKind === CLOSE_KIND.closeableWithButton && /*#__PURE__*/React.createElement(CloseButton, _extends({
180
+ }, rootProps), handleDismiss && showDismissButton && /*#__PURE__*/React.createElement(DismissButton, _extends({
181
181
  onClick: function onClick() {
182
- return handleClose();
182
+ return handleDismiss();
183
183
  }
184
- }, closeButtonProps)), /*#__PURE__*/React.createElement(ScrollContainer, _extends({}, scrollContainerProps, {
184
+ }, dismissButtonProps)), /*#__PURE__*/React.createElement(ScrollContainer, _extends({}, scrollContainerProps, {
185
185
  tabIndex: 0
186
186
  }), renderArtwork(artwork), /*#__PURE__*/React.createElement(Heading, _extends({
187
187
  $numHeadingLines: numHeadingLines
@@ -89,6 +89,8 @@ export var StyledRoot = styled('dialog', function (_ref) {
89
89
  maxWidth: "calc(100% - 2 * ".concat(wideViewportGutter, ")"),
90
90
  borderRadius: $theme.borders.radius500,
91
91
  boxShadow: $theme.lighting.shallowBelow,
92
+ backgroundColor: $theme.colors.backgroundPrimary,
93
+ color: $theme.colors.contentPrimary,
92
94
  overflow: 'hidden',
93
95
  border: 'none',
94
96
  width: DIALOG_WIDTHS[$size]
@@ -186,10 +186,11 @@ export var RadioMarkInner = styled('div', function (props) {
186
186
  borderTopRightRadius: '50%',
187
187
  borderBottomRightRadius: '50%',
188
188
  borderBottomLeftRadius: '50%',
189
- height: props.$checked ? sizing.scale200 : sizing.scale550,
189
+ height: '100%',
190
190
  transitionDuration: animation.timing200,
191
191
  transitionTimingFunction: animation.easeOutCurve,
192
- width: props.$checked ? sizing.scale200 : sizing.scale550
192
+ width: '100%',
193
+ transform: props.$checked ? 'scale(.3)' : 'scale(.7)'
193
194
  };
194
195
  });
195
196
  RadioMarkInner.displayName = "RadioMarkInner";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "baseui",
3
- "version": "0.0.0-next-3a57782",
3
+ "version": "0.0.0-next-d12da36",
4
4
  "description": "A React Component library implementing the Base design language",
5
5
  "keywords": [
6
6
  "react",
@@ -190,10 +190,11 @@ var RadioMarkInner = (0, _styles.styled)('div', function (props) {
190
190
  borderTopRightRadius: '50%',
191
191
  borderBottomRightRadius: '50%',
192
192
  borderBottomLeftRadius: '50%',
193
- height: props.$checked ? sizing.scale200 : sizing.scale550,
193
+ height: '100%',
194
194
  transitionDuration: animation.timing200,
195
195
  transitionTimingFunction: animation.easeOutCurve,
196
- width: props.$checked ? sizing.scale200 : sizing.scale550
196
+ width: '100%',
197
+ transform: props.$checked ? 'scale(.3)' : 'scale(.7)'
197
198
  };
198
199
  });
199
200
  exports.RadioMarkInner = RadioMarkInner;