@wavv/ui 2.4.4-alpha.4 → 2.4.4-alpha.5

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,10 +1,13 @@
1
1
  import type { CSSProperties, ReactNode, RefObject } from 'react';
2
+ import type { IconName } from './Icon/Icon';
2
3
  import type { Attributes } from './typeDefs/elementTypes';
3
4
  import type { MaxWidthHeight, MinWidthHeight, Padding, PositionType, WidthHeight } from './types';
4
5
  type DivAttributes = Attributes<HTMLDivElement>;
5
6
  type DialogProps = {
6
7
  /** The header content displayed at the top of the dialog */
7
8
  header: ReactNode;
9
+ /** The icon displayed to the left of the header text */
10
+ headerIcon?: IconName;
8
11
  /** The main text content displayed in the dialog body */
9
12
  text?: ReactNode;
10
13
  /** Additional children content */
@@ -60,5 +63,5 @@ type DialogProps = {
60
63
  /** The `aria-label` of the dialog */
61
64
  'aria-label'?: string;
62
65
  } & WidthHeight & MaxWidthHeight & MinWidthHeight & Padding & DivAttributes;
63
- declare const Dialog: ({ header, text, children, cancelText, confirmText, middleText, negative, confirmDisabled, confirmLoading, middleDisabled, middleLoading, onConfirm, onMiddle, onCancel, visible, width, height, onClose, closeIcon, preventOverlayClose, overlayBlur, overlayColor, backgroundColor, inert, scopeRef, position, zIndex, ...props }: DialogProps) => import("react/jsx-runtime").JSX.Element;
66
+ declare const Dialog: ({ header, headerIcon, text, children, cancelText, confirmText, middleText, negative, confirmDisabled, confirmLoading, middleDisabled, middleLoading, onConfirm, onMiddle, onCancel, visible, width, height, onClose, closeIcon, preventOverlayClose, overlayBlur, overlayColor, backgroundColor, inert, scopeRef, position, zIndex, ...props }: DialogProps) => import("react/jsx-runtime").JSX.Element;
64
67
  export default Dialog;
@@ -3,9 +3,10 @@ import styled from "@emotion/styled";
3
3
  import { Dialog, Heading, Modal, ModalOverlay } from "react-aria-components";
4
4
  import Button from "./Button/index.js";
5
5
  import { body1, head3, maxWidthHeightProps, minWidthHeightProps, paddingProps } from "./helpers/styledProps.js";
6
+ import getIcon from "./helpers/getIcon.js";
6
7
  import Icon from "./Icon/index.js";
7
8
  import PortalScope from "./PortalScope.js";
8
- const Dialog_Dialog = ({ header, text, children, cancelText = 'Cancel', confirmText = 'Okay', middleText, negative, confirmDisabled, confirmLoading, middleDisabled, middleLoading, onConfirm, onMiddle, onCancel, visible, width, height, onClose, closeIcon, preventOverlayClose, overlayBlur = true, overlayColor, backgroundColor, inert, scopeRef, position, zIndex, ...props })=>{
9
+ const Dialog_Dialog = ({ header, headerIcon, text, children, cancelText = 'Cancel', confirmText = 'Okay', middleText, negative, confirmDisabled, confirmLoading, middleDisabled, middleLoading, onConfirm, onMiddle, onCancel, visible, width, height, onClose, closeIcon, preventOverlayClose, overlayBlur = true, overlayColor, backgroundColor, inert, scopeRef, position, zIndex, ...props })=>{
9
10
  const { 'aria-label': ariaLabel, ...rest } = props;
10
11
  const handleOpenChange = (open)=>{
11
12
  if (!open) onClose();
@@ -38,7 +39,12 @@ const Dialog_Dialog = ({ header, text, children, cancelText = 'Cancel', confirmT
38
39
  /*#__PURE__*/ jsxs(DialogHeader, {
39
40
  slot: "title",
40
41
  children: [
41
- header,
42
+ /*#__PURE__*/ jsxs(HeaderContent, {
43
+ children: [
44
+ headerIcon && getIcon(headerIcon),
45
+ header
46
+ ]
47
+ }),
42
48
  closeIcon && /*#__PURE__*/ jsx(CloseInHeader, {
43
49
  children: /*#__PURE__*/ jsx(Icon, {
44
50
  name: "close",
@@ -100,6 +106,11 @@ const DialogHeader = styled(Heading)(({ theme })=>({
100
106
  width: '100%',
101
107
  boxSizing: 'border-box'
102
108
  }), head3);
109
+ const HeaderContent = styled.div({
110
+ display: 'flex',
111
+ alignItems: 'center',
112
+ gap: 8
113
+ });
103
114
  const DialogContent = styled.div(({ theme, hasFooter })=>({
104
115
  color: theme.modal.color.body,
105
116
  padding: hasFooter ? '16px 16px 8px' : 16,
@@ -9,6 +9,14 @@ const Icon = ({ name, svg, external, size, width, height, color, hoverColor, poi
9
9
  let SvgComponent = null;
10
10
  let svgContent = null;
11
11
  let WrappedIconComponent = null;
12
+ const iconSizes = {
13
+ tiny: 12,
14
+ small: 18,
15
+ medium: 24,
16
+ large: 40
17
+ };
18
+ let iconSize = 'number' == typeof size ? size : iconSizes.medium;
19
+ if ('tiny' === size || 'small' === size || 'medium' === size || 'large' === size) iconSize = iconSizes[size];
12
20
  if (name) {
13
21
  if (name in customIcons) SvgComponent = customIcons[name];
14
22
  else if (name in icons) WrappedIconComponent = icons[name];
@@ -16,19 +24,11 @@ const Icon = ({ name, svg, external, size, width, height, color, hoverColor, poi
16
24
  let element = svg;
17
25
  if ('function' == typeof svg) element = svg();
18
26
  const clonedSvg = /*#__PURE__*/ cloneElement(element, {
19
- width: width || size,
20
- height: height || size
27
+ width: width || iconSize,
28
+ height: height || iconSize
21
29
  });
22
30
  svgContent = clonedSvg;
23
31
  }
24
- const iconSizes = {
25
- tiny: 12,
26
- small: 18,
27
- medium: 24,
28
- large: 40
29
- };
30
- let iconSize = 'number' == typeof size ? size : iconSizes.medium;
31
- if ('tiny' === size || 'small' === size || 'medium' === size || 'large' === size) iconSize = iconSizes[size];
32
32
  if (external) return /*#__PURE__*/ jsx(DynamicIcon, {
33
33
  ...props,
34
34
  name: external,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wavv/ui",
3
- "version": "2.4.4-alpha.4",
3
+ "version": "2.4.4-alpha.5",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {