@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/cjs/index.js CHANGED
@@ -39,8 +39,6 @@ __export(src_exports, {
39
39
  MenuItem: () => MenuItem,
40
40
  MenuItemGroup: () => MenuItemGroup,
41
41
  MenuList: () => MenuList,
42
- NotificationLevel: () => NotificationLevel,
43
- NotificationsContext: () => NotificationsContext,
44
42
  NotificationsProvider: () => NotificationsProvider,
45
43
  PopupComponent: () => PopupComponent2,
46
44
  PopupMenu: () => PopupMenu,
@@ -1753,7 +1751,7 @@ var PopupMenu = ({
1753
1751
  className,
1754
1752
  disabled = false,
1755
1753
  label,
1756
- icon = label ? "chevron-down" : "more-vert",
1754
+ icon: icon2 = label ? "chevron-down" : "more-vert",
1757
1755
  id: idProp,
1758
1756
  menuActionHandler,
1759
1757
  menuBuilder,
@@ -1795,12 +1793,12 @@ var PopupMenu = ({
1795
1793
  ref: rootRef,
1796
1794
  variant: "secondary",
1797
1795
  children: [
1798
- icon ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_vuu_ui_controls.Icon, { name: icon }) : null,
1796
+ icon2 ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_vuu_ui_controls.Icon, { name: icon2 }) : null,
1799
1797
  label
1800
1798
  ]
1801
1799
  }
1802
1800
  );
1803
- } else if (icon) {
1801
+ } else if (icon2) {
1804
1802
  return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1805
1803
  import_vuu_ui_controls.IconButton,
1806
1804
  {
@@ -1811,7 +1809,7 @@ var PopupMenu = ({
1811
1809
  "saltButton-active": menuOpen
1812
1810
  }),
1813
1811
  disabled,
1814
- icon,
1812
+ icon: icon2,
1815
1813
  ref: rootRef,
1816
1814
  variant
1817
1815
  }
@@ -1835,7 +1833,7 @@ var Prompt = ({
1835
1833
  PopupProps = EMPTY_PROPS2,
1836
1834
  cancelButtonLabel = "Cancel",
1837
1835
  confirmButtonLabel = "Confirm",
1838
- icon,
1836
+ icon: icon2,
1839
1837
  onCancel,
1840
1838
  onConfirm,
1841
1839
  style,
@@ -1880,7 +1878,7 @@ var Prompt = ({
1880
1878
  ref: rootRef,
1881
1879
  style: { ...style, ...position },
1882
1880
  children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("form", { className: `${classBase5}-form`, children: [
1883
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: `${classBase5}-header`, "data-icon": icon, children: title }),
1881
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: `${classBase5}-header`, "data-icon": icon2, children: title }),
1884
1882
  /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: `${classBase5}-text`, children: text }),
1885
1883
  /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: `${classBase5}-buttonBar`, children: [
1886
1884
  /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_core3.Button, { onClick: onCancel, variant: "secondary", children: cancelButtonLabel }),
@@ -2104,60 +2102,30 @@ var useTooltip = ({
2104
2102
  };
2105
2103
 
2106
2104
  // src/notifications/NotificationsProvider.tsx
2107
- var import_react18 = __toESM(require("react"));
2108
- var import_clsx10 = __toESM(require("clsx"));
2105
+ var import_react20 = __toESM(require("react"));
2106
+
2107
+ // src/notifications/NotificationsCenter.tsx
2108
+ var import_react19 = require("react");
2109
2109
  var import_vuu_utils10 = require("@vuu-ui/vuu-utils");
2110
+
2111
+ // src/notifications/ToastNotification.tsx
2112
+ var import_vuu_ui_controls2 = require("@vuu-ui/vuu-ui-controls");
2113
+ var import_clsx10 = __toESM(require("clsx"));
2114
+ var import_react18 = require("react");
2110
2115
  var import_jsx_runtime12 = require("react/jsx-runtime");
2111
- var toastOffsetTop = 60;
2116
+ var toastWidth = 300;
2117
+ var toastContainerRightPadding = 50;
2112
2118
  var toastDisplayDuration = 6e3;
2113
2119
  var horizontalTransitionDuration = 1e3;
2114
- var verticalTransitionDuration = 300;
2115
2120
  var toastHeight = 56;
2116
- var toastWidth = 300;
2117
- var toastContainerContentGap = 10;
2118
- var toastContainerLeftPadding = 10;
2119
- var toastContainerRightPadding = 50;
2120
- var classBase7 = "vuuToastNotifications";
2121
- var NotificationLevel = /* @__PURE__ */ ((NotificationLevel2) => {
2122
- NotificationLevel2["Info"] = "info";
2123
- NotificationLevel2["Success"] = "success";
2124
- NotificationLevel2["Warning"] = "warning";
2125
- NotificationLevel2["Error"] = "error";
2126
- return NotificationLevel2;
2127
- })(NotificationLevel || {});
2128
- var NotificationsContext = import_react18.default.createContext({
2129
- notify: () => "have you forgotten to provide a NotificationProvider?"
2130
- });
2131
- var NotificationsProvider = (props) => {
2132
- const [notifications, setNotifications] = (0, import_react18.useState)([]);
2133
- const notify = (0, import_react18.useCallback)((notification) => {
2134
- const newNotification = { ...notification, id: (0, import_vuu_utils10.getUniqueId)() };
2135
- setNotifications((prev) => [...prev, newNotification]);
2136
- setTimeout(() => {
2137
- setNotifications((prev) => prev.filter((n) => n !== newNotification));
2138
- }, toastDisplayDuration + horizontalTransitionDuration * 2);
2139
- }, []);
2140
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(NotificationsContext.Provider, { value: { notify }, children: [
2141
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2142
- "div",
2143
- {
2144
- style: {
2145
- width: toastWidth + toastContainerRightPadding + toastContainerLeftPadding
2146
- },
2147
- children: notifications.map((notification, i) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2148
- ToastNotification,
2149
- {
2150
- top: toastOffsetTop + (toastHeight + toastContainerContentGap) * i,
2151
- notification
2152
- },
2153
- notification.id
2154
- ))
2155
- }
2156
- ),
2157
- props.children
2158
- ] });
2121
+ var verticalTransitionDuration = 300;
2122
+ var classBase7 = "vuuToastNotification";
2123
+ var icon = {
2124
+ error: "error",
2125
+ info: "info-circle",
2126
+ success: "tick",
2127
+ warning: "warn-triangle"
2159
2128
  };
2160
- var useNotifications = () => (0, import_react18.useContext)(NotificationsContext);
2161
2129
  var ToastNotification = (props) => {
2162
2130
  const { top, notification, animated = true } = props;
2163
2131
  const [right, setRight] = (0, import_react18.useState)(-toastWidth - toastContainerRightPadding);
@@ -2173,7 +2141,7 @@ var ToastNotification = (props) => {
2173
2141
  return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
2174
2142
  "div",
2175
2143
  {
2176
- className: (0, import_clsx10.default)(`${classBase7}-toast`, notification.type),
2144
+ className: (0, import_clsx10.default)(classBase7, `${classBase7}-${notification.type}`),
2177
2145
  style: {
2178
2146
  height: toastHeight,
2179
2147
  right,
@@ -2182,15 +2150,7 @@ var ToastNotification = (props) => {
2182
2150
  transition: animated ? `right ${horizontalTransitionDuration}ms, top ${verticalTransitionDuration}ms ` : "none"
2183
2151
  },
2184
2152
  children: [
2185
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2186
- "div",
2187
- {
2188
- className: (0, import_clsx10.default)(
2189
- `${classBase7}-toastIcon`,
2190
- `${notification.type}-icon`
2191
- )
2192
- }
2193
- ),
2153
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_vuu_ui_controls2.Icon, { name: icon[notification.type] }),
2194
2154
  /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: `${classBase7}-toastContent`, children: [
2195
2155
  /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("strong", { className: `${classBase7}-toastHeader`, children: notification.header }),
2196
2156
  /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { children: notification.body })
@@ -2199,4 +2159,62 @@ var ToastNotification = (props) => {
2199
2159
  }
2200
2160
  ) });
2201
2161
  };
2162
+
2163
+ // src/notifications/NotificationsCenter.tsx
2164
+ var import_jsx_runtime13 = require("react/jsx-runtime");
2165
+ var toastOffsetTop = 60;
2166
+ var toastDisplayDuration2 = 6e3;
2167
+ var horizontalTransitionDuration2 = 1e3;
2168
+ var toastHeight2 = 56;
2169
+ var toastContainerContentGap = 10;
2170
+ var NotificationsCenter = ({
2171
+ notificationsContext
2172
+ }) => {
2173
+ const [notifications, setNotifications] = (0, import_react19.useState)([]);
2174
+ (0, import_react19.useMemo)(() => {
2175
+ notificationsContext.setNotify((notification) => {
2176
+ const newNotification = {
2177
+ ...notification,
2178
+ id: (0, import_vuu_utils10.getUniqueId)()
2179
+ };
2180
+ setNotifications((prev) => prev.concat(newNotification));
2181
+ setTimeout(() => {
2182
+ setNotifications((prev) => prev.filter((n) => n !== newNotification));
2183
+ }, toastDisplayDuration2 + horizontalTransitionDuration2 * 2);
2184
+ });
2185
+ }, [notificationsContext]);
2186
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_jsx_runtime13.Fragment, { children: notifications.map((notification, i) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2187
+ ToastNotification,
2188
+ {
2189
+ top: toastOffsetTop + (toastHeight2 + toastContainerContentGap) * i,
2190
+ notification
2191
+ },
2192
+ notification.id
2193
+ )) });
2194
+ };
2195
+
2196
+ // src/notifications/NotificationsProvider.tsx
2197
+ var import_jsx_runtime14 = require("react/jsx-runtime");
2198
+ var NotificationsContextObject = class {
2199
+ constructor() {
2200
+ this.notify = () => "have you forgotten to provide a NotificationsCenter?";
2201
+ this.setNotify = (dispatcher) => {
2202
+ this.notify = dispatcher;
2203
+ };
2204
+ }
2205
+ };
2206
+ var NotificationsContext = import_react20.default.createContext(
2207
+ new NotificationsContextObject()
2208
+ );
2209
+ var NotificationsProvider = (props) => {
2210
+ const context = (0, import_react20.useContext)(NotificationsContext);
2211
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(NotificationsContext.Provider, { value: context, children: [
2212
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(NotificationsCenter, { notificationsContext: context }),
2213
+ props.children
2214
+ ] });
2215
+ };
2216
+ var useNotifications = () => {
2217
+ const { notify } = (0, import_react20.useContext)(NotificationsContext);
2218
+ return notify;
2219
+ };
2202
2220
  //# sourceMappingURL=index.js.map