@superdispatch/ui-lab 0.17.1 → 0.19.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.
@@ -0,0 +1,80 @@
1
+ import { Menu, MenuItem, Typography } from '@material-ui/core';
2
+ import { Color, Inline } from '@superdispatch/ui';
3
+ import { useState } from 'react';
4
+ import styled from 'styled-components';
5
+ import { useNavbarContext } from "./NavbarContext.js";
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
+ import { jsxs as _jsxs } from "react/jsx-runtime";
8
+ import { Fragment as _Fragment } from "react/jsx-runtime";
9
+ var Divider = /*#__PURE__*/styled.div.withConfig({
10
+ displayName: "NavbarMenu__Divider",
11
+ componentId: "SD__sc-1c8icpt-0"
12
+ })(["border-bottom:1px solid ", ";margin:8px -16px;"], Color.Silver400);
13
+ var StyledMenuItem = /*#__PURE__*/styled(MenuItem).withConfig({
14
+ displayName: "NavbarMenu__StyledMenuItem",
15
+ componentId: "SD__sc-1c8icpt-1"
16
+ })(["& svg{font-size:24px;color:", ";}"], Color.Dark100);
17
+ var Wrapper = /*#__PURE__*/styled.div.withConfig({
18
+ displayName: "NavbarMenu__Wrapper",
19
+ componentId: "SD__sc-1c8icpt-2"
20
+ })(["width:100%;padding:8px 16px;cursor:pointer;background:", ";border-left:4px solid ", ";&:hover{border-left-color:", ";background:", ";}"], Color.Dark400, _ref => {
21
+ var {
22
+ active
23
+ } = _ref;
24
+ return active ? Color.Blue300 : 'transparent';
25
+ }, Color.Blue300, Color.Dark400);
26
+ export function NavbarMenu(_ref2) {
27
+ var {
28
+ items,
29
+ children
30
+ } = _ref2;
31
+ var {
32
+ setDrawerOpen
33
+ } = useNavbarContext();
34
+ var [anchor, setAnchor] = useState(null);
35
+
36
+ function showProfileMenu(event) {
37
+ setAnchor(event.currentTarget);
38
+ }
39
+
40
+ function hideProfileMenu() {
41
+ setAnchor(null);
42
+ setDrawerOpen(false);
43
+ }
44
+
45
+ return /*#__PURE__*/_jsxs(_Fragment, {
46
+ children: [/*#__PURE__*/_jsx(Wrapper, {
47
+ onClick: showProfileMenu,
48
+ active: !!anchor,
49
+ children: children
50
+ }), /*#__PURE__*/_jsx(Menu, {
51
+ open: !!anchor,
52
+ anchorEl: anchor,
53
+ onClose: hideProfileMenu,
54
+ onClick: hideProfileMenu,
55
+ anchorOrigin: {
56
+ vertical: 'top',
57
+ horizontal: 'center'
58
+ },
59
+ transformOrigin: {
60
+ vertical: 'bottom',
61
+ horizontal: 'center'
62
+ },
63
+ children: items.filter(item => item.visible !== false).flatMap((item, index, arr) => {
64
+ return [/*#__PURE__*/_jsx(StyledMenuItem, {
65
+ onClick: item.onClick,
66
+ children: /*#__PURE__*/_jsxs(Inline, {
67
+ space: "small",
68
+ verticalAlign: "center",
69
+ children: [item.icon, /*#__PURE__*/_jsx(Typography, {
70
+ style: {
71
+ color: Color.Dark500
72
+ },
73
+ children: item.label
74
+ })]
75
+ })
76
+ }, item.key), index !== arr.length - 1 && /*#__PURE__*/_jsx(Divider, {}, "".concat(item.key, "-divider"))];
77
+ })
78
+ })]
79
+ });
80
+ }
@@ -1,11 +1,12 @@
1
1
  /// <reference types="react" />
2
- import { ReactNode, ForwardRefExoticComponent, RefAttributes, Ref, AriaAttributes, MouseEventHandler, FocusEventHandler, ReactChild, MouseEvent, ReactElement } from 'react';
2
+ import { ReactNode, ForwardRefExoticComponent, RefAttributes, Ref, AriaAttributes, MouseEventHandler, FocusEventHandler, HTMLAttributes, AnchorHTMLAttributes, FunctionComponent, ReactElement, ComponentType, MouseEvent, Key, CSSProperties, ReactChild } from 'react';
3
3
  import { CSSTransition } from 'react-transition-group';
4
4
  import { CSSTransitionProps } from 'react-transition-group/CSSTransition';
5
5
  import { SpaceProp, NegativeSpaceProp, ResponsiveProp, ColorProp } from '@superdispatch/ui';
6
6
  import { Property } from 'csstype';
7
- import { ButtonBaseProps, TooltipProps } from '@material-ui/core';
7
+ import { ButtonBaseProps, AvatarProps, TooltipProps } from '@material-ui/core';
8
8
  import { FileRejection } from 'react-dropzone';
9
+ import { StyledComponent, DefaultTheme } from 'styled-components';
9
10
 
10
11
  declare type AlertSeverityProp = 'positive' | 'info' | 'caution' | 'critical';
11
12
  interface AlertProps {
@@ -117,6 +118,13 @@ interface AnchorButtonProps extends BaseButtonProps<HTMLAnchorElement> {
117
118
  }
118
119
  declare const AnchorButton: ForwardRefExoticComponent<AnchorButtonProps & RefAttributes<HTMLAnchorElement>>;
119
120
 
121
+ declare type ContainerProps = HTMLAttributes<HTMLDivElement> & {
122
+ fullViewportHeight?: boolean;
123
+ };
124
+ declare const Container: ForwardRefExoticComponent<HTMLAttributes<HTMLDivElement> & {
125
+ fullViewportHeight?: boolean | undefined;
126
+ } & RefAttributes<HTMLDivElement>>;
127
+
120
128
  interface DescriptionItemProps {
121
129
  id?: string;
122
130
  'aria-label'?: string;
@@ -155,6 +163,123 @@ interface FileListItemProps {
155
163
  }
156
164
  declare const FileListItem: ForwardRefExoticComponent<FileListItemProps & RefAttributes<HTMLDivElement>>;
157
165
 
166
+ declare type LinkComponentProps = Omit<AnchorHTMLAttributes<HTMLAnchorElement>, 'href'> & {
167
+ href: string;
168
+ truncate?: number;
169
+ };
170
+ interface LinkedTextProps extends Omit<LinkComponentProps, 'ref' | 'href'> {
171
+ children?: null | string;
172
+ linkComponent?: FunctionComponent<LinkComponentProps>;
173
+ }
174
+ declare function LinkedText({ children, linkComponent, ...props }: LinkedTextProps): ReactElement | null;
175
+
176
+ interface MultilineTextProps {
177
+ overflowWrap?: Extract<Property.OverflowWrap, 'anywhere' | 'break-word' | 'normal'>;
178
+ }
179
+ declare const MultilineText: StyledComponent<"span", DefaultTheme, MultilineTextProps, never>;
180
+
181
+ interface NavbarBottomBarItem {
182
+ active?: boolean;
183
+ value: string;
184
+ hasBadge?: boolean;
185
+ label: ReactNode;
186
+ icon: ReactNode;
187
+ onClick?: () => void;
188
+ component?: ComponentType<HTMLAttributes<HTMLElement>>;
189
+ }
190
+ interface NavbarBottomBarProps {
191
+ items: NavbarBottomBarItem[];
192
+ hasMenuBadge?: boolean;
193
+ }
194
+ declare function NavbarBottomBar({ items, hasMenuBadge, }: NavbarBottomBarProps): ReactElement;
195
+
196
+ interface NavbarAccordionProps {
197
+ label: ReactNode;
198
+ icon?: ReactNode;
199
+ gutter?: boolean;
200
+ items: NavbarItemOptions[];
201
+ onClick: (event: MouseEvent<HTMLDivElement>) => void;
202
+ }
203
+
204
+ declare const NavbarBadge: StyledComponent<"span", DefaultTheme, {}, never>;
205
+ declare const NavbarLabel: StyledComponent<"span", DefaultTheme, {}, never>;
206
+ interface NavbarItemProps {
207
+ onClick?: (event: MouseEvent<HTMLElement>) => void;
208
+ component?: ComponentType<HTMLAttributes<HTMLElement>>;
209
+ label: ReactNode;
210
+ icon?: ReactNode;
211
+ badge?: ReactNode;
212
+ ident?: number;
213
+ gutter?: boolean;
214
+ variant?: 'danger' | 'primary';
215
+ active?: boolean;
216
+ }
217
+ declare function NavbarItem({ label, gutter, badge, icon, component, onClick, variant, ident, active, }: NavbarItemProps): ReactElement;
218
+
219
+ interface NavbarMenuItemProps {
220
+ icon?: ReactNode;
221
+ label: ReactNode;
222
+ onClick?: (event: MouseEvent<HTMLElement>) => void;
223
+ component?: ComponentType<HTMLAttributes<HTMLElement>>;
224
+ }
225
+ declare function NavbarMenuItem({ label, icon, onClick, component, }: NavbarMenuItemProps): ReactElement;
226
+ interface NavbarAccordionOptions extends NavbarAccordionProps {
227
+ key: Key;
228
+ groupKey?: Key;
229
+ hide?: boolean;
230
+ }
231
+ interface NavbarItemOptions extends NavbarItemProps {
232
+ key: Key;
233
+ groupKey?: Key;
234
+ hide?: boolean;
235
+ }
236
+ interface NavbarListProps {
237
+ header: ReactNode;
238
+ items: Array<NavbarItemOptions | NavbarAccordionOptions>;
239
+ footer?: ReactNode;
240
+ }
241
+ declare function NavbarList({ header, items, footer, }: NavbarListProps): ReactElement;
242
+
243
+ interface NavbarProps {
244
+ containerStyle?: CSSProperties;
245
+ children: ReactNode;
246
+ header?: ReactNode;
247
+ items: NavbarItemOptions[];
248
+ bottomItems: NavbarBottomBarItem[];
249
+ footer?: ReactNode;
250
+ hasExtraBadge?: boolean;
251
+ }
252
+ declare function Navbar({ footer, items, header, bottomItems, children, containerStyle, hasExtraBadge, }: NavbarProps): ReactElement;
253
+
254
+ interface NavbarAvatarProps extends Omit<AvatarProps, 'title'> {
255
+ title: ReactNode;
256
+ subtitle: ReactNode;
257
+ children: ReactNode;
258
+ }
259
+ declare function NavbarAvatar({ title, subtitle, children, ...props }: NavbarAvatarProps): ReactElement;
260
+
261
+
262
+ interface NavbarContextType {
263
+ isDrawerOpen: boolean;
264
+ isExpanded: boolean;
265
+ setIsExpanded: (value: boolean) => void;
266
+ setDrawerOpen: (value: boolean) => void;
267
+ }
268
+ declare function useNavbarContext(): NavbarContextType;
269
+
270
+ interface NavbarMenuItemOption {
271
+ key: Key;
272
+ icon: ReactNode;
273
+ label: ReactNode;
274
+ visible?: boolean;
275
+ onClick: () => void;
276
+ }
277
+ interface NavbarMenuProps {
278
+ children: ReactNode;
279
+ items: NavbarMenuItemOption[];
280
+ }
281
+ declare function NavbarMenu({ items, children }: NavbarMenuProps): ReactElement;
282
+
158
283
  interface SidebarProps {
159
284
  id?: string;
160
285
  title?: ReactNode;
@@ -226,4 +351,4 @@ interface TextBoxProps {
226
351
  }
227
352
  declare const TextBox: ForwardRefExoticComponent<TextBoxProps & RefAttributes<HTMLElement>>;
228
353
 
229
- export { Alert, AlertProps, AlertSeverityProp, AnchorButton, AnchorButtonProps, Banner, BorderRadiusProp, BorderWidthProp, Box, BoxProps, Button, ButtonArea, ButtonAreaProps, ButtonProps, ButtonSizeProp, ButtonVariantProp, DescriptionItem, DescriptionItemProps, FileDropZone, FileDropZoneProps, FileListItem, FileListItemProps, MarginProp, Sidebar, SidebarContainer, SidebarContainerProps, SidebarDivider, SidebarMenuItem, SidebarMenuItemAction, SidebarMenuItemActionProps, SidebarMenuItemAvatar, SidebarMenuItemAvatarProps, SidebarMenuItemProps, SidebarProps, SidebarSubheader, SidebarSubheaderProps, TextAlignProp, TextBox, TextBoxProps, TextColorProp, TextDisplayProp, TextVariantProp, formatBytes, toBytes };
354
+ export { Alert, AlertProps, AlertSeverityProp, AnchorButton, AnchorButtonProps, Banner, BorderRadiusProp, BorderWidthProp, Box, BoxProps, Button, ButtonArea, ButtonAreaProps, ButtonProps, ButtonSizeProp, ButtonVariantProp, Container, ContainerProps, DescriptionItem, DescriptionItemProps, FileDropZone, FileDropZoneProps, FileListItem, FileListItemProps, LinkComponentProps, LinkedText, LinkedTextProps, MarginProp, MultilineText, MultilineTextProps, Navbar, NavbarAccordionOptions, NavbarAvatar, NavbarBadge, NavbarBottomBar, NavbarBottomBarItem, NavbarItem, NavbarItemOptions, NavbarItemProps, NavbarLabel, NavbarList, NavbarMenu, NavbarMenuItem, NavbarMenuItemOption, Sidebar, SidebarContainer, SidebarContainerProps, SidebarDivider, SidebarMenuItem, SidebarMenuItemAction, SidebarMenuItemActionProps, SidebarMenuItemAvatar, SidebarMenuItemAvatarProps, SidebarMenuItemProps, SidebarProps, SidebarSubheader, SidebarSubheaderProps, TextAlignProp, TextBox, TextBoxProps, TextColorProp, TextDisplayProp, TextVariantProp, formatBytes, toBytes, useNavbarContext };