@vuu-ui/vuu-popups 0.8.28-debug → 0.8.29-debug

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.
package/esm/index.js CHANGED
@@ -1711,7 +1711,7 @@ var PopupMenu = ({
1711
1711
  className,
1712
1712
  disabled = false,
1713
1713
  label,
1714
- icon = label ? "chevron-down" : "more-vert",
1714
+ icon: icon2 = label ? "chevron-down" : "more-vert",
1715
1715
  id: idProp,
1716
1716
  menuActionHandler,
1717
1717
  menuBuilder,
@@ -1753,12 +1753,12 @@ var PopupMenu = ({
1753
1753
  ref: rootRef,
1754
1754
  variant: "secondary",
1755
1755
  children: [
1756
- icon ? /* @__PURE__ */ jsx9(Icon, { name: icon }) : null,
1756
+ icon2 ? /* @__PURE__ */ jsx9(Icon, { name: icon2 }) : null,
1757
1757
  label
1758
1758
  ]
1759
1759
  }
1760
1760
  );
1761
- } else if (icon) {
1761
+ } else if (icon2) {
1762
1762
  return /* @__PURE__ */ jsx9(
1763
1763
  IconButton,
1764
1764
  {
@@ -1769,7 +1769,7 @@ var PopupMenu = ({
1769
1769
  "saltButton-active": menuOpen
1770
1770
  }),
1771
1771
  disabled,
1772
- icon,
1772
+ icon: icon2,
1773
1773
  ref: rootRef,
1774
1774
  variant
1775
1775
  }
@@ -1793,7 +1793,7 @@ var Prompt = ({
1793
1793
  PopupProps = EMPTY_PROPS2,
1794
1794
  cancelButtonLabel = "Cancel",
1795
1795
  confirmButtonLabel = "Confirm",
1796
- icon,
1796
+ icon: icon2,
1797
1797
  onCancel,
1798
1798
  onConfirm,
1799
1799
  style,
@@ -1838,7 +1838,7 @@ var Prompt = ({
1838
1838
  ref: rootRef,
1839
1839
  style: { ...style, ...position },
1840
1840
  children: /* @__PURE__ */ jsxs4("form", { className: `${classBase5}-form`, children: [
1841
- /* @__PURE__ */ jsx10("div", { className: `${classBase5}-header`, "data-icon": icon, children: title }),
1841
+ /* @__PURE__ */ jsx10("div", { className: `${classBase5}-header`, "data-icon": icon2, children: title }),
1842
1842
  /* @__PURE__ */ jsx10("div", { className: `${classBase5}-text`, children: text }),
1843
1843
  /* @__PURE__ */ jsxs4("div", { className: `${classBase5}-buttonBar`, children: [
1844
1844
  /* @__PURE__ */ jsx10(Button3, { onClick: onCancel, variant: "secondary", children: cancelButtonLabel }),
@@ -2062,60 +2062,30 @@ var useTooltip = ({
2062
2062
  };
2063
2063
 
2064
2064
  // src/notifications/NotificationsProvider.tsx
2065
- import React4, { useState as useState8, useContext as useContext2, useCallback as useCallback13, useEffect } from "react";
2066
- import classNames from "clsx";
2065
+ import React4, { useContext as useContext2 } from "react";
2066
+
2067
+ // src/notifications/NotificationsCenter.tsx
2068
+ import { useMemo as useMemo7, useState as useState9 } from "react";
2067
2069
  import { getUniqueId } from "@vuu-ui/vuu-utils";
2070
+
2071
+ // src/notifications/ToastNotification.tsx
2072
+ import { Icon as Icon2 } from "@vuu-ui/vuu-ui-controls";
2073
+ import cx10 from "clsx";
2074
+ import { useEffect, useState as useState8 } from "react";
2068
2075
  import { jsx as jsx12, jsxs as jsxs5 } from "react/jsx-runtime";
2069
- var toastOffsetTop = 60;
2076
+ var toastWidth = 300;
2077
+ var toastContainerRightPadding = 50;
2070
2078
  var toastDisplayDuration = 6e3;
2071
2079
  var horizontalTransitionDuration = 1e3;
2072
- var verticalTransitionDuration = 300;
2073
2080
  var toastHeight = 56;
2074
- var toastWidth = 300;
2075
- var toastContainerContentGap = 10;
2076
- var toastContainerLeftPadding = 10;
2077
- var toastContainerRightPadding = 50;
2078
- var classBase7 = "vuuToastNotifications";
2079
- var NotificationLevel = /* @__PURE__ */ ((NotificationLevel2) => {
2080
- NotificationLevel2["Info"] = "info";
2081
- NotificationLevel2["Success"] = "success";
2082
- NotificationLevel2["Warning"] = "warning";
2083
- NotificationLevel2["Error"] = "error";
2084
- return NotificationLevel2;
2085
- })(NotificationLevel || {});
2086
- var NotificationsContext = React4.createContext({
2087
- notify: () => "have you forgotten to provide a NotificationProvider?"
2088
- });
2089
- var NotificationsProvider = (props) => {
2090
- const [notifications, setNotifications] = useState8([]);
2091
- const notify = useCallback13((notification) => {
2092
- const newNotification = { ...notification, id: getUniqueId() };
2093
- setNotifications((prev) => [...prev, newNotification]);
2094
- setTimeout(() => {
2095
- setNotifications((prev) => prev.filter((n) => n !== newNotification));
2096
- }, toastDisplayDuration + horizontalTransitionDuration * 2);
2097
- }, []);
2098
- return /* @__PURE__ */ jsxs5(NotificationsContext.Provider, { value: { notify }, children: [
2099
- /* @__PURE__ */ jsx12(
2100
- "div",
2101
- {
2102
- style: {
2103
- width: toastWidth + toastContainerRightPadding + toastContainerLeftPadding
2104
- },
2105
- children: notifications.map((notification, i) => /* @__PURE__ */ jsx12(
2106
- ToastNotification,
2107
- {
2108
- top: toastOffsetTop + (toastHeight + toastContainerContentGap) * i,
2109
- notification
2110
- },
2111
- notification.id
2112
- ))
2113
- }
2114
- ),
2115
- props.children
2116
- ] });
2081
+ var verticalTransitionDuration = 300;
2082
+ var classBase7 = "vuuToastNotification";
2083
+ var icon = {
2084
+ error: "error",
2085
+ info: "info-circle",
2086
+ success: "tick",
2087
+ warning: "warn-triangle"
2117
2088
  };
2118
- var useNotifications = () => useContext2(NotificationsContext);
2119
2089
  var ToastNotification = (props) => {
2120
2090
  const { top, notification, animated = true } = props;
2121
2091
  const [right, setRight] = useState8(-toastWidth - toastContainerRightPadding);
@@ -2131,7 +2101,7 @@ var ToastNotification = (props) => {
2131
2101
  return /* @__PURE__ */ jsx12(Portal, { children: /* @__PURE__ */ jsxs5(
2132
2102
  "div",
2133
2103
  {
2134
- className: classNames(`${classBase7}-toast`, notification.type),
2104
+ className: cx10(classBase7, `${classBase7}-${notification.type}`),
2135
2105
  style: {
2136
2106
  height: toastHeight,
2137
2107
  right,
@@ -2140,15 +2110,7 @@ var ToastNotification = (props) => {
2140
2110
  transition: animated ? `right ${horizontalTransitionDuration}ms, top ${verticalTransitionDuration}ms ` : "none"
2141
2111
  },
2142
2112
  children: [
2143
- /* @__PURE__ */ jsx12(
2144
- "div",
2145
- {
2146
- className: classNames(
2147
- `${classBase7}-toastIcon`,
2148
- `${notification.type}-icon`
2149
- )
2150
- }
2151
- ),
2113
+ /* @__PURE__ */ jsx12(Icon2, { name: icon[notification.type] }),
2152
2114
  /* @__PURE__ */ jsxs5("div", { className: `${classBase7}-toastContent`, children: [
2153
2115
  /* @__PURE__ */ jsx12("strong", { className: `${classBase7}-toastHeader`, children: notification.header }),
2154
2116
  /* @__PURE__ */ jsx12("div", { children: notification.body })
@@ -2157,6 +2119,64 @@ var ToastNotification = (props) => {
2157
2119
  }
2158
2120
  ) });
2159
2121
  };
2122
+
2123
+ // src/notifications/NotificationsCenter.tsx
2124
+ import { Fragment as Fragment3, jsx as jsx13 } from "react/jsx-runtime";
2125
+ var toastOffsetTop = 60;
2126
+ var toastDisplayDuration2 = 6e3;
2127
+ var horizontalTransitionDuration2 = 1e3;
2128
+ var toastHeight2 = 56;
2129
+ var toastContainerContentGap = 10;
2130
+ var NotificationsCenter = ({
2131
+ notificationsContext
2132
+ }) => {
2133
+ const [notifications, setNotifications] = useState9([]);
2134
+ useMemo7(() => {
2135
+ notificationsContext.setNotify((notification) => {
2136
+ const newNotification = {
2137
+ ...notification,
2138
+ id: getUniqueId()
2139
+ };
2140
+ setNotifications((prev) => prev.concat(newNotification));
2141
+ setTimeout(() => {
2142
+ setNotifications((prev) => prev.filter((n) => n !== newNotification));
2143
+ }, toastDisplayDuration2 + horizontalTransitionDuration2 * 2);
2144
+ });
2145
+ }, [notificationsContext]);
2146
+ return /* @__PURE__ */ jsx13(Fragment3, { children: notifications.map((notification, i) => /* @__PURE__ */ jsx13(
2147
+ ToastNotification,
2148
+ {
2149
+ top: toastOffsetTop + (toastHeight2 + toastContainerContentGap) * i,
2150
+ notification
2151
+ },
2152
+ notification.id
2153
+ )) });
2154
+ };
2155
+
2156
+ // src/notifications/NotificationsProvider.tsx
2157
+ import { jsx as jsx14, jsxs as jsxs6 } from "react/jsx-runtime";
2158
+ var NotificationsContextObject = class {
2159
+ constructor() {
2160
+ this.notify = () => "have you forgotten to provide a NotificationsCenter?";
2161
+ this.setNotify = (dispatcher) => {
2162
+ this.notify = dispatcher;
2163
+ };
2164
+ }
2165
+ };
2166
+ var NotificationsContext = React4.createContext(
2167
+ new NotificationsContextObject()
2168
+ );
2169
+ var NotificationsProvider = (props) => {
2170
+ const context = useContext2(NotificationsContext);
2171
+ return /* @__PURE__ */ jsxs6(NotificationsContext.Provider, { value: context, children: [
2172
+ /* @__PURE__ */ jsx14(NotificationsCenter, { notificationsContext: context }),
2173
+ props.children
2174
+ ] });
2175
+ };
2176
+ var useNotifications = () => {
2177
+ const { notify } = useContext2(NotificationsContext);
2178
+ return notify;
2179
+ };
2160
2180
  export {
2161
2181
  ContextMenu,
2162
2182
  ContextMenuContext,
@@ -2167,8 +2187,6 @@ export {
2167
2187
  MenuItem,
2168
2188
  MenuItemGroup,
2169
2189
  MenuList,
2170
- NotificationLevel,
2171
- NotificationsContext,
2172
2190
  NotificationsProvider,
2173
2191
  PopupComponent2 as PopupComponent,
2174
2192
  PopupMenu,