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

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.
@@ -8,12 +8,14 @@ import DropdownMenu from "../DropdownMenu.js";
8
8
  import { marginProps } from "../helpers/styledProps.js";
9
9
  import Icon from "../Icon/index.js";
10
10
  import ButtonLoader from "./ButtonLoader.js";
11
+ import dropdown_caret from "./dropdown-caret.js";
11
12
  import Group from "./Group.js";
12
13
  const Button_Button = ({ content, children, dropdown, options, ref, ...rest })=>{
13
14
  const text = content || children;
14
- if (dropdown && options) return /*#__PURE__*/ jsx(DropdownButton, {
15
+ if ((true === dropdown || 'single' === dropdown) && options) return /*#__PURE__*/ jsx(DropdownButton, {
15
16
  ref: ref,
16
17
  options: options,
18
+ dropdown: dropdown,
17
19
  ...rest,
18
20
  children: text
19
21
  });
@@ -66,8 +68,20 @@ const BasicButton = ({ children, onClick, onPress, icon, iconPosition, iconColor
66
68
  ]
67
69
  });
68
70
  };
69
- const DropdownButton = ({ children, options, onClick, onPress, afterShow, afterHide, secondary, negative, positive, caution, outline, subtle, link, size, small, tiny, large, disabled, buttonDisabled, optionsDisabled, loading, direction, collapse, width, hideDivider, gap, ref, ...props })=>{
71
+ const DropdownButton = ({ children, options, dropdown = true, onClick, onPress, afterShow, afterHide, secondary, negative, positive, caution, outline, subtle, link, size, small, tiny, large, disabled, buttonDisabled, optionsDisabled, loading, direction, collapse, width, hideDivider, gap, icon, iconPosition, ref, ...props })=>{
70
72
  const [optionsOpen, setOptionsOpen] = useState(false);
73
+ const isSingle = 'single' === dropdown;
74
+ let buttonSize = size || 'medium';
75
+ if (small) buttonSize = 'small';
76
+ else if (large) buttonSize = 'large';
77
+ else if (tiny) buttonSize = 'tiny';
78
+ const caretDimensions = {
79
+ large: 7,
80
+ medium: 6,
81
+ small: 5,
82
+ tiny: 4
83
+ };
84
+ const caretSize = caretDimensions[buttonSize];
71
85
  const buttonStyleProps = {
72
86
  secondary,
73
87
  negative,
@@ -93,6 +107,38 @@ const DropdownButton = ({ children, options, onClick, onPress, afterShow, afterH
93
107
  if (afterHide) afterHide();
94
108
  setOptionsOpen(false);
95
109
  };
110
+ if (isSingle) return /*#__PURE__*/ jsx(DropdownContainer, {
111
+ children: /*#__PURE__*/ jsx(DropdownMenu, {
112
+ options: options,
113
+ position: `${direction || 'bottom'} right`,
114
+ afterShow: handleShow,
115
+ afterHide: handleHide,
116
+ isTriggerButton: true,
117
+ trigger: /*#__PURE__*/ jsxs(BasicButton, {
118
+ ...buttonStyleProps,
119
+ ...props,
120
+ ref: ref,
121
+ disabled: disabled,
122
+ width: width && !collapse ? '100%' : void 0,
123
+ collapse: collapse,
124
+ loading: loading,
125
+ icon: icon,
126
+ iconPosition: iconPosition,
127
+ children: [
128
+ children && /*#__PURE__*/ jsx(DropdownButtonChildren, {
129
+ children: children
130
+ }),
131
+ /*#__PURE__*/ jsx(CaretIconWrapper, {
132
+ isOpen: optionsOpen,
133
+ children: /*#__PURE__*/ jsx(Icon, {
134
+ svg: /*#__PURE__*/ jsx(dropdown_caret, {}),
135
+ size: caretSize
136
+ })
137
+ })
138
+ ]
139
+ })
140
+ })
141
+ });
96
142
  return /*#__PURE__*/ jsx(DropdownContainer, {
97
143
  children: /*#__PURE__*/ jsxs(Group, {
98
144
  width: collapse ? void 0 : width,
@@ -247,10 +293,23 @@ const DropdownContainer = styled.div({
247
293
  position: 'relative'
248
294
  });
249
295
  const DropdownButtonChildren = styled.div({
250
- marginRight: 8
296
+ marginRight: 8,
297
+ display: 'inline-flex',
298
+ alignItems: 'center'
251
299
  });
300
+ const CaretIconWrapper = styled.span(({ isOpen })=>({
301
+ display: 'inline-flex',
302
+ alignItems: 'center',
303
+ flexShrink: 0,
304
+ '& > div': {
305
+ transform: isOpen ? 'rotate(-180deg)' : 'rotate(0deg)',
306
+ transition: 'transform 0.2s ease-in-out'
307
+ }
308
+ }));
252
309
  const Inner = styled.span({
253
- pointerEvents: 'none'
310
+ pointerEvents: 'none',
311
+ display: 'inline-flex',
312
+ alignItems: 'center'
254
313
  });
255
314
  const components_Button_Button = Object.assign(Button_Button, {
256
315
  Group: Group
@@ -112,7 +112,7 @@ export type DropdownProps = {
112
112
  optionsDisabled?: never;
113
113
  } | {
114
114
  /** Adds a dropdown button to the main button, allowing for multiple button options */
115
- dropdown: true;
115
+ dropdown: true | 'single';
116
116
  /** The dropdown options array of { id: string; label: string; action: () => void; } */
117
117
  options: ListItem[];
118
118
  /** The direction the options should open in relation to the button */
@@ -131,6 +131,7 @@ export type DropdownProps = {
131
131
  optionsDisabled?: boolean;
132
132
  };
133
133
  export type ButtonDropdownProps = {
134
+ dropdown: true | 'single';
134
135
  options: ListItem[];
135
136
  direction?: 'top' | 'bottom';
136
137
  afterShow?: () => void;
@@ -0,0 +1,2 @@
1
+ import dropdown_caret_namespaceObject from "../../static/svg/dropdown-caret.svg";
2
+ export { dropdown_caret_namespaceObject as default };
@@ -2,8 +2,8 @@ import { jsx, jsxs } from "react/jsx-runtime";
2
2
  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
- import { body1, head3, maxWidthHeightProps, minWidthHeightProps, paddingProps } from "./helpers/styledProps.js";
6
5
  import getIcon from "./helpers/getIcon.js";
6
+ import { body1, head3, maxWidthHeightProps, minWidthHeightProps, paddingProps } from "./helpers/styledProps.js";
7
7
  import Icon from "./Icon/index.js";
8
8
  import PortalScope from "./PortalScope.js";
9
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 })=>{
@@ -104,6 +104,8 @@ declare const icons: {
104
104
  readonly 'pause-circle': ComponentType<WrappedIconProps>;
105
105
  readonly person: ComponentType<WrappedIconProps>;
106
106
  readonly 'person-add': ComponentType<WrappedIconProps>;
107
+ readonly pin: ComponentType<WrappedIconProps>;
108
+ readonly 'pin-off': ComponentType<WrappedIconProps>;
107
109
  readonly play: ComponentType<WrappedIconProps>;
108
110
  readonly 'play-circle': ComponentType<WrappedIconProps>;
109
111
  readonly priority: ComponentType<WrappedIconProps>;
@@ -1,4 +1,4 @@
1
- import { ArrowDown, ArrowDownWideNarrow, ArrowLeft, ArrowRight, ArrowRightLeft, ArrowUp, ArrowUpWideNarrow, BadgeCheck, Ban, Bell, BellDot, Bold, Bot, Braces, Bug, CalendarDays, Camera, ChartColumn, Check, ChevronDown, ChevronLeft, ChevronRight, ChevronUp, ChevronsLeft, ChevronsRight, ChevronsUpDown, Circle, CircleAlert, CircleCheck, CirclePause, CirclePlay, CirclePlus, CircleQuestionMark, CircleStop, CircleUserRound, CircleX, Clapperboard, Clock, Copy, CopyCheck, CopyPlus, CreditCard, Download, Ear, EllipsisVertical, ExternalLink, Eye, EyeOff, Facebook, FileText, Flag, FlaskConical, Frown, Funnel, Globe, GripVertical, Hash, Heading, Heading1, Heading2, Heading3, Heading4, Heading5, Heading6, Headset, Heart, Highlighter, Hourglass, House, IdCard, Info, Instagram, Italic, Kanban, Layers2, LayoutDashboard, Lightbulb, Link, Linkedin, List, ListChecks, ListFilter, ListOrdered, ListTodo, Loader, LogIn, LogOut, MapPin, MapPinned, Maximize2, Meh, Menu, Merge, MessageSquareMore, Mic, MicOff, Minimize2, Minus, MonitorSmartphone, NotebookPen, Paperclip, Pause, Pencil, Pilcrow, Play, Plus, Redo, RefreshCcwDot, RefreshCw, Rocket, RotateCw, Search, Settings, Share, Share2, Shield, ShieldCheck, ShieldOff, ShieldPlus, ShoppingCart, Smartphone, Smile, Sparkles, Square, SquareStack, Star, Strikethrough, TextQuote, Trash2, TriangleAlert, Trophy, Underline, Undo, Upload, UserRound, UserRoundPlus, Users, Video, Voicemail, Volume2, X, Youtube } from "lucide-react";
1
+ import { ArrowDown, ArrowDownWideNarrow, ArrowLeft, ArrowRight, ArrowRightLeft, ArrowUp, ArrowUpWideNarrow, BadgeCheck, Ban, Bell, BellDot, Bold, Bot, Braces, Bug, CalendarDays, Camera, ChartColumn, Check, ChevronDown, ChevronLeft, ChevronRight, ChevronUp, ChevronsLeft, ChevronsRight, ChevronsUpDown, Circle, CircleAlert, CircleCheck, CirclePause, CirclePlay, CirclePlus, CircleQuestionMark, CircleStop, CircleUserRound, CircleX, Clapperboard, Clock, Copy, CopyCheck, CopyPlus, CreditCard, Download, Ear, EllipsisVertical, ExternalLink, Eye, EyeOff, Facebook, FileText, Flag, FlaskConical, Frown, Funnel, Globe, GripVertical, Hash, Heading, Heading1, Heading2, Heading3, Heading4, Heading5, Heading6, Headset, Heart, Highlighter, Hourglass, House, IdCard, Info, Instagram, Italic, Kanban, Layers2, LayoutDashboard, Lightbulb, Link, Linkedin, List, ListChecks, ListFilter, ListOrdered, ListTodo, Loader, LogIn, LogOut, MapPin, MapPinned, Maximize2, Meh, Menu, Merge, MessageSquareMore, Mic, MicOff, Minimize2, Minus, MonitorSmartphone, NotebookPen, Paperclip, Pause, Pencil, Pilcrow, Pin, PinOff, Play, Plus, Redo, RefreshCcwDot, RefreshCw, Rocket, RotateCw, Search, Settings, Share, Share2, Shield, ShieldCheck, ShieldOff, ShieldPlus, ShoppingCart, Smartphone, Smile, Sparkles, Square, SquareStack, Star, Strikethrough, TextQuote, Trash2, TriangleAlert, Trophy, Underline, Undo, Upload, UserRound, UserRoundPlus, Users, Video, Voicemail, Volume2, X, Youtube } from "lucide-react";
2
2
  import createWrappedIcon from "./createWrappedIcon.js";
3
3
  const icons = {
4
4
  'activity-history': createWrappedIcon(IdCard),
@@ -104,6 +104,8 @@ const icons = {
104
104
  'pause-circle': createWrappedIcon(CirclePause),
105
105
  person: createWrappedIcon(UserRound),
106
106
  'person-add': createWrappedIcon(UserRoundPlus),
107
+ pin: createWrappedIcon(Pin),
108
+ 'pin-off': createWrappedIcon(PinOff),
107
109
  play: createWrappedIcon(Play),
108
110
  'play-circle': createWrappedIcon(CirclePlay),
109
111
  priority: createWrappedIcon(ArrowUpWideNarrow),
@@ -0,0 +1,3 @@
1
+ <svg width="6" height="4" viewBox="0 0 6 4" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M0.75 0.75L3 3L5.25 0.75" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
3
+ </svg>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wavv/ui",
3
- "version": "2.4.4-alpha.5",
3
+ "version": "2.4.4-alpha.7",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {