@superdispatch/ui 0.17.0 → 0.18.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.
@@ -6,7 +6,6 @@ import { Button } from "../button/Button.js";
6
6
  import { mergeRefs } from "../utils/mergeRefs.js";
7
7
  import { useResizeObserver } from "../utils/ResizeObserver.js";
8
8
  import { jsx as _jsx } from "react/jsx-runtime";
9
- import { Fragment as _Fragment } from "react/jsx-runtime";
10
9
  import { jsxs as _jsxs } from "react/jsx-runtime";
11
10
  var useStyles = /*#__PURE__*/makeStyles({
12
11
  root: {
@@ -25,8 +24,10 @@ var defaultMoreElement = /*#__PURE__*/_jsx(Button, {
25
24
  export var AdaptiveVerticalToolbar = /*#__PURE__*/forwardRef((_ref, ref) => {
26
25
  var {
27
26
  items,
27
+ disableGutters,
28
28
  moreElement = defaultMoreElement,
29
- renderItem = item => item.label
29
+ renderItem = item => item.label,
30
+ renderMenuItem = item => item.label
30
31
  } = _ref;
31
32
  var styles = useStyles();
32
33
  var itemNodes = useRef([]);
@@ -64,11 +65,11 @@ export var AdaptiveVerticalToolbar = /*#__PURE__*/forwardRef((_ref, ref) => {
64
65
  setFirstHiddenIdx(hiddenIdx);
65
66
  });
66
67
  return /*#__PURE__*/_jsxs(Grid, {
67
- spacing: 1,
68
68
  direction: "column",
69
69
  container: true,
70
70
  wrap: "nowrap",
71
71
  className: styles.root,
72
+ spacing: disableGutters ? undefined : 1,
72
73
  ref: mergeRefs(ref, node => {
73
74
  setRootNode(node);
74
75
  }),
@@ -95,19 +96,17 @@ export var AdaptiveVerticalToolbar = /*#__PURE__*/forwardRef((_ref, ref) => {
95
96
  onClose: () => {
96
97
  setMenuButtonRef(undefined);
97
98
  },
98
- children: menuItems.map((item, index, arr) => {
99
+ children: menuItems.flatMap((item, index, arr) => {
99
100
  var next = arr[index + 1];
100
- return /*#__PURE__*/_jsxs(_Fragment, {
101
- children: [/*#__PURE__*/_jsx(MenuItem, {
102
- onClick: event => {
103
- var _item$onClick;
101
+ return [/*#__PURE__*/_jsx(MenuItem, {
102
+ onClick: event => {
103
+ var _item$onClick;
104
104
 
105
- (_item$onClick = item.onClick) === null || _item$onClick === void 0 ? void 0 : _item$onClick.call(item, event);
106
- setMenuButtonRef(undefined);
107
- },
108
- children: item.label
109
- }, item.key), next && next.menuGroupKey !== item.menuGroupKey && /*#__PURE__*/_jsx(Divider, {})]
110
- });
105
+ (_item$onClick = item.onClick) === null || _item$onClick === void 0 ? void 0 : _item$onClick.call(item, event);
106
+ setMenuButtonRef(undefined);
107
+ },
108
+ children: renderMenuItem(item)
109
+ }, item.key), next && next.menuGroupKey !== item.menuGroupKey && /*#__PURE__*/_jsx(Divider, {}, "".concat(item.key, "-divider"))];
111
110
  })
112
111
  })]
113
112
  })]
package/dist-src/index.js CHANGED
@@ -35,6 +35,7 @@ export * from "./theme/Color.js";
35
35
  export * from "./theme/SuperDispatchTheme.js";
36
36
  export * from "./theme/ThemeProvider.js";
37
37
  export * from "./tiles/Tiles.js";
38
+ export * from "./utils/ExitTransitionPlaceholder.js";
38
39
  export * from "./utils/isEmptyReactNode.js";
39
40
  export * from "./utils/mergeRefs.js";
40
41
  export * from "./utils/renderChildren.js";
@@ -0,0 +1,15 @@
1
+ import { useEffect, useState } from 'react';
2
+ import { renderChildren } from "./renderChildren.js";
3
+ export function ExitTransitionPlaceholder(_ref) {
4
+ var {
5
+ in: inProp,
6
+ children: childrenProp
7
+ } = _ref;
8
+ var [children, setChildren] = useState(childrenProp);
9
+ useEffect(() => {
10
+ if (inProp) {
11
+ setChildren(childrenProp);
12
+ }
13
+ }, [inProp, childrenProp]);
14
+ return renderChildren(children);
15
+ }
@@ -39,9 +39,11 @@ interface AdaptiveVerticalToolbarItem {
39
39
  menuGroupKey?: Key;
40
40
  onClick?: (event: MouseEvent<HTMLElement>) => void;
41
41
  }
42
- interface AdaptiveVerticalToolbarProps extends RefAttributes<HTMLDivElement>, Omit<ToolbarProps, 'children'> {
42
+ interface AdaptiveVerticalToolbarProps extends RefAttributes<HTMLDivElement> {
43
+ disableGutters?: boolean;
43
44
  items: AdaptiveVerticalToolbarItem[];
44
45
  renderItem?: (item: AdaptiveVerticalToolbarItem) => ReactNode;
46
+ renderMenuItem?: (item: AdaptiveVerticalToolbarItem) => ReactNode;
45
47
  moreElement?: ReactElement<{
46
48
  onClick: EventHandler<MouseEvent<HTMLElement>>;
47
49
  }>;
@@ -410,6 +412,12 @@ interface TilesProps {
410
412
  }
411
413
  declare const Tiles: ForwardRefExoticComponent<TilesProps & RefAttributes<HTMLDivElement>>;
412
414
 
415
+ interface ExitTransitionPlaceholderProps {
416
+ in: boolean;
417
+ children: ReactNode;
418
+ }
419
+ declare function ExitTransitionPlaceholder({ in: inProp, children: childrenProp, }: ExitTransitionPlaceholderProps): null | ReactElement;
420
+
413
421
  declare function isEmptyReactNode(node: ReactNode): node is null | undefined | boolean | string;
414
422
 
415
423
  declare function mergeRefs<T>(...refs: Array<null | undefined | Ref<T>>): (node: T) => void;
@@ -440,4 +448,4 @@ interface VisibilityObserverProps extends VisibilityObserverOptions {
440
448
  }
441
449
  declare function VisibilityObserver({ render, onChange, ...options }: VisibilityObserverProps): null | ReactElement;
442
450
 
443
- export { AdaptiveToolbar, AdaptiveToolbarDropdownItem, AdaptiveToolbarItem, AdaptiveToolbarProps, AdaptiveVerticalToolbar, AdaptiveVerticalToolbarItem, AdaptiveVerticalToolbarProps, AvatarButton, AvatarButtonClassKey, AvatarButtonProps, Button, ButtonProps, CardButton, CardButtonClassKey, CardButtonProps, CheckboxField, CheckboxFieldProps, CheckboxGroupField, CheckboxGroupFieldProps, CollapseBreakpoint, CollapseProp, Color, ColorProp, ColorVariant, Column, ColumnProps, ColumnWidth, Columns, ColumnsProps, DescriptionList, DescriptionListItem, DescriptionListItemProps, DescriptionListProps, DrawerActions, DrawerActionsProps, DrawerContent, DrawerContentProps, DrawerList, DrawerListProps, DrawerTitle, DrawerTitleProps, DropdownButton, ElementVisibility, GridStack, GridStackProps, HorizontalAlign, InfoCard, InfoCardClassKey, InfoCardProps, Inline, InlineGrid, InlineGridProps, InlineProps, NegativeSpaceProp, OverflowText, OverflowTextProps, PartialResponsivePropRecord, RadioField, RadioFieldProps, RadioGroupField, RadioGroupFieldProps, ResponsiveContext, ResponsiveContextProvider, ResponsiveContextProviderProps, ResponsiveProp, ResponsivePropPrimitive, ResponsivePropRecord, ResponsivePropTuple, ResponsivePropTupleInit, Snackbar, SnackbarCloseReason, SnackbarContent, SnackbarContentProps, SnackbarProps, SnackbarStack, SnackbarStackConsumer, SnackbarStackOptions, SnackbarStackProvider, SnackbarStackProviderProps, SnackbarVariant, SpaceProp, Stack, StackProps, SuperDispatchTheme, Tag, TagClassKey, TagProps, ThemeProvider, ThemeProviderProps, Tiles, TilesColumns, TilesProps, TilesSpace, VerticalAlign, VisibilityObserver, VisibilityObserverOptions, VisibilityObserverProps, VisibilityObserverRenderProps, assignRef, isColorProp, isEmptyReactNode, mergeRefs, parseAlignProp, parseCollapsedBelow, parseResponsiveProp, parseSpaceProp, renderChildren, useCollapseBreakpoint, useResizeObserver, useResponsiveContext, useResponsiveProp, useResponsivePropRecord, useResponsiveValue, useSnackbarStack, useUID, useVisibilityObserver };
451
+ export { AdaptiveToolbar, AdaptiveToolbarDropdownItem, AdaptiveToolbarItem, AdaptiveToolbarProps, AdaptiveVerticalToolbar, AdaptiveVerticalToolbarItem, AdaptiveVerticalToolbarProps, AvatarButton, AvatarButtonClassKey, AvatarButtonProps, Button, ButtonProps, CardButton, CardButtonClassKey, CardButtonProps, CheckboxField, CheckboxFieldProps, CheckboxGroupField, CheckboxGroupFieldProps, CollapseBreakpoint, CollapseProp, Color, ColorProp, ColorVariant, Column, ColumnProps, ColumnWidth, Columns, ColumnsProps, DescriptionList, DescriptionListItem, DescriptionListItemProps, DescriptionListProps, DrawerActions, DrawerActionsProps, DrawerContent, DrawerContentProps, DrawerList, DrawerListProps, DrawerTitle, DrawerTitleProps, DropdownButton, ElementVisibility, ExitTransitionPlaceholder, GridStack, GridStackProps, HorizontalAlign, InfoCard, InfoCardClassKey, InfoCardProps, Inline, InlineGrid, InlineGridProps, InlineProps, NegativeSpaceProp, OverflowText, OverflowTextProps, PartialResponsivePropRecord, RadioField, RadioFieldProps, RadioGroupField, RadioGroupFieldProps, ResponsiveContext, ResponsiveContextProvider, ResponsiveContextProviderProps, ResponsiveProp, ResponsivePropPrimitive, ResponsivePropRecord, ResponsivePropTuple, ResponsivePropTupleInit, Snackbar, SnackbarCloseReason, SnackbarContent, SnackbarContentProps, SnackbarProps, SnackbarStack, SnackbarStackConsumer, SnackbarStackOptions, SnackbarStackProvider, SnackbarStackProviderProps, SnackbarVariant, SpaceProp, Stack, StackProps, SuperDispatchTheme, Tag, TagClassKey, TagProps, ThemeProvider, ThemeProviderProps, Tiles, TilesColumns, TilesProps, TilesSpace, VerticalAlign, VisibilityObserver, VisibilityObserverOptions, VisibilityObserverProps, VisibilityObserverRenderProps, assignRef, isColorProp, isEmptyReactNode, mergeRefs, parseAlignProp, parseCollapsedBelow, parseResponsiveProp, parseSpaceProp, renderChildren, useCollapseBreakpoint, useResizeObserver, useResponsiveContext, useResponsiveProp, useResponsivePropRecord, useResponsiveValue, useSnackbarStack, useUID, useVisibilityObserver };
package/dist-web/index.js CHANGED
@@ -3,7 +3,7 @@ import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProper
3
3
  import { Button as Button$1, CircularProgress, ButtonGroup, Popover, MenuList, Toolbar, Grid, MenuItem, Typography, Menu, Divider, ButtonBase, Avatar, FormControl, FormControlLabel, Checkbox, FormHelperText, FormLabel, FormGroup, useMediaQuery, Tooltip, SvgIcon, AppBar, List, Card, CardContent, Radio, RadioGroup, SnackbarContent as SnackbarContent$1, IconButton, Portal, Snackbar as Snackbar$1, Slide, CssBaseline, createTheme, createGenerateClassName } from '@material-ui/core';
4
4
  import { MoreHoriz, Close, Warning, CheckCircle } from '@material-ui/icons';
5
5
  import { makeStyles, StylesProvider, ThemeProvider as ThemeProvider$1 } from '@material-ui/styles';
6
- import { forwardRef, useState, useRef, useLayoutEffect, cloneElement, useMemo, useContext, createContext, Children, useCallback } from 'react';
6
+ import { forwardRef, useState, useRef, useLayoutEffect, cloneElement, useMemo, useContext, createContext, Children, useCallback, useEffect } from 'react';
7
7
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
8
8
  import styled, { css, ThemeProvider as ThemeProvider$2 } from 'styled-components';
9
9
  import { ResizeObserver } from '@juggle/resize-observer';
@@ -341,8 +341,10 @@ var defaultMoreElement = /*#__PURE__*/jsx(Button, {
341
341
  var AdaptiveVerticalToolbar = /*#__PURE__*/forwardRef((_ref, ref) => {
342
342
  var {
343
343
  items,
344
+ disableGutters,
344
345
  moreElement = defaultMoreElement,
345
- renderItem = item => item.label
346
+ renderItem = item => item.label,
347
+ renderMenuItem = item => item.label
346
348
  } = _ref;
347
349
  var styles = useStyles$1();
348
350
  var itemNodes = useRef([]);
@@ -380,11 +382,11 @@ var AdaptiveVerticalToolbar = /*#__PURE__*/forwardRef((_ref, ref) => {
380
382
  setFirstHiddenIdx(hiddenIdx);
381
383
  });
382
384
  return /*#__PURE__*/jsxs(Grid, {
383
- spacing: 1,
384
385
  direction: "column",
385
386
  container: true,
386
387
  wrap: "nowrap",
387
388
  className: styles.root,
389
+ spacing: disableGutters ? undefined : 1,
388
390
  ref: mergeRefs(ref, node => {
389
391
  setRootNode(node);
390
392
  }),
@@ -411,19 +413,17 @@ var AdaptiveVerticalToolbar = /*#__PURE__*/forwardRef((_ref, ref) => {
411
413
  onClose: () => {
412
414
  setMenuButtonRef(undefined);
413
415
  },
414
- children: menuItems.map((item, index, arr) => {
416
+ children: menuItems.flatMap((item, index, arr) => {
415
417
  var next = arr[index + 1];
416
- return /*#__PURE__*/jsxs(Fragment, {
417
- children: [/*#__PURE__*/jsx(MenuItem, {
418
- onClick: event => {
419
- var _item$onClick;
420
-
421
- (_item$onClick = item.onClick) === null || _item$onClick === void 0 ? void 0 : _item$onClick.call(item, event);
422
- setMenuButtonRef(undefined);
423
- },
424
- children: item.label
425
- }, item.key), next && next.menuGroupKey !== item.menuGroupKey && /*#__PURE__*/jsx(Divider, {})]
426
- });
418
+ return [/*#__PURE__*/jsx(MenuItem, {
419
+ onClick: event => {
420
+ var _item$onClick;
421
+
422
+ (_item$onClick = item.onClick) === null || _item$onClick === void 0 ? void 0 : _item$onClick.call(item, event);
423
+ setMenuButtonRef(undefined);
424
+ },
425
+ children: renderMenuItem(item)
426
+ }, item.key), next && next.menuGroupKey !== item.menuGroupKey && /*#__PURE__*/jsx(Divider, {}, "".concat(item.key, "-divider"))];
427
427
  })
428
428
  })]
429
429
  })]
@@ -3665,5 +3665,19 @@ var Tiles = /*#__PURE__*/forwardRef((_ref, ref) => {
3665
3665
  });
3666
3666
  if (process.env.NODE_ENV !== "production") Tiles.displayName = "Tiles";
3667
3667
 
3668
- export { AdaptiveToolbar, AdaptiveVerticalToolbar, AvatarButton, Button, CardButton, CheckboxField, CheckboxGroupField, Color, Column, Columns, DescriptionList, DescriptionListItem, DrawerActions, DrawerContent, DrawerList, DrawerTitle, DropdownButton, GridStack, InfoCard, Inline, InlineGrid, OverflowText, RadioField, RadioGroupField, ResponsiveContextProvider, Snackbar, SnackbarContent, SnackbarStackConsumer, SnackbarStackProvider, Stack, Tag, ThemeProvider, Tiles, VisibilityObserver, assignRef, isColorProp, isEmptyReactNode, mergeRefs, parseAlignProp, parseCollapsedBelow, parseResponsiveProp, parseSpaceProp, renderChildren, useCollapseBreakpoint, useResizeObserver, useResponsiveContext, useResponsiveProp, useResponsivePropRecord, useResponsiveValue, useSnackbarStack, useUID, useVisibilityObserver };
3668
+ function ExitTransitionPlaceholder(_ref) {
3669
+ var {
3670
+ in: inProp,
3671
+ children: childrenProp
3672
+ } = _ref;
3673
+ var [children, setChildren] = useState(childrenProp);
3674
+ useEffect(() => {
3675
+ if (inProp) {
3676
+ setChildren(childrenProp);
3677
+ }
3678
+ }, [inProp, childrenProp]);
3679
+ return renderChildren(children);
3680
+ }
3681
+
3682
+ export { AdaptiveToolbar, AdaptiveVerticalToolbar, AvatarButton, Button, CardButton, CheckboxField, CheckboxGroupField, Color, Column, Columns, DescriptionList, DescriptionListItem, DrawerActions, DrawerContent, DrawerList, DrawerTitle, DropdownButton, ExitTransitionPlaceholder, GridStack, InfoCard, Inline, InlineGrid, OverflowText, RadioField, RadioGroupField, ResponsiveContextProvider, Snackbar, SnackbarContent, SnackbarStackConsumer, SnackbarStackProvider, Stack, Tag, ThemeProvider, Tiles, VisibilityObserver, assignRef, isColorProp, isEmptyReactNode, mergeRefs, parseAlignProp, parseCollapsedBelow, parseResponsiveProp, parseSpaceProp, renderChildren, useCollapseBreakpoint, useResizeObserver, useResponsiveContext, useResponsiveProp, useResponsivePropRecord, useResponsiveValue, useSnackbarStack, useUID, useVisibilityObserver };
3669
3683
  //# sourceMappingURL=index.js.map