@dashx/react 0.1.3 → 0.1.4

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,5 +1,6 @@
1
- import type { ProductVariantReleaseRule } from '@dashx/browser';
1
+ import type { ProductVariantRelease, ProductVariantReleaseRule } from '@dashx/browser';
2
2
  type UseProductReleaseHookResponse = {
3
+ productVariantRelease: ProductVariantRelease | null;
3
4
  productVariantReleaseRule: ProductVariantReleaseRule | null;
4
5
  };
5
6
  declare const useProductRelease: () => UseProductReleaseHookResponse;
@@ -1,2 +1,2 @@
1
- "use strict";var d=Object.create;var u=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var P=Object.getPrototypeOf,f=Object.prototype.hasOwnProperty;var m=(e,t)=>{for(var s in t)u(e,s,{get:t[s],enumerable:!0})},c=(e,t,s,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of b(t))!f.call(e,r)&&r!==s&&u(e,r,{get:()=>t[r],enumerable:!(o=p(t,r))||o.enumerable});return e};var V=(e,t,s)=>(s=e!=null?d(P(e)):{},c(t||!e||!e.__esModule?u(s,"default",{value:e,enumerable:!0}):s,e)),k=e=>c(u({},"__esModule",{value:!0}),e);var y={};m(y,{default:()=>h});module.exports=k(y);var a=require("react"),R=require("@dashx/browser"),n=V(require("./use-dashx-provider.js")),i=require("../providers/DashXProvider.js");const E=()=>{let e=(0,n.default)();const{subscribe:t}=(0,i.useWebSocket)(),[s,o]=(0,a.useState)(null);return(0,a.useEffect)(()=>{e.watchFetchProductVariantReleaseRule(o)},[e]),(0,a.useEffect)(()=>t(l=>{l?.type===R.WebsocketMessage.PRODUCT_VARIANT_RELEASE_RULE_UPDATED&&o(l.data)}),[t]),{productVariantReleaseRule:s}};var h=E;
1
+ "use strict";var p=Object.create;var u=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var V=Object.getOwnPropertyNames;var b=Object.getPrototypeOf,f=Object.prototype.hasOwnProperty;var m=(e,t)=>{for(var a in t)u(e,a,{get:t[a],enumerable:!0})},n=(e,t,a,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of V(t))!f.call(e,r)&&r!==a&&u(e,r,{get:()=>t[r],enumerable:!(o=P(t,r))||o.enumerable});return e};var h=(e,t,a)=>(a=e!=null?p(b(e)):{},n(t||!e||!e.__esModule?u(a,"default",{value:e,enumerable:!0}):a,e)),k=e=>n(u({},"__esModule",{value:!0}),e);var T={};m(T,{default:()=>y});module.exports=k(T);var s=require("react"),R=require("@dashx/browser"),i=h(require("./use-dashx-provider.js")),d=require("../providers/DashXProvider.js");const E=()=>{let e=(0,i.default)();const{subscribe:t}=(0,d.useWebSocket)(),[a,o]=(0,s.useState)(null),[r,l]=(0,s.useState)(null);return(0,s.useEffect)(()=>{e.fetchProductVariantRelease().then(o),e.watchFetchProductVariantReleaseRule(l)},[e]),(0,s.useEffect)(()=>t(c=>{c?.type===R.WebsocketMessage.PRODUCT_VARIANT_RELEASE_RULE_UPDATED&&l(c.data)}),[t]),{productVariantRelease:a,productVariantReleaseRule:r}};var y=E;
2
2
  //# sourceMappingURL=use-product-release.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/hooks/use-product-release.ts"],
4
- "sourcesContent": ["import { useEffect, useState } from 'react';\nimport { WebsocketMessage } from '@dashx/browser';\nimport type { ProductVariantReleaseRule, WebsocketMessageType } from '@dashx/browser';\n\nimport useDashXProvider from './use-dashx-provider.js';\nimport { useWebSocket } from '../providers/DashXProvider.js';\n\ntype UseProductReleaseHookResponse = {\n productVariantReleaseRule: ProductVariantReleaseRule | null;\n};\n\nconst useProductRelease = (): UseProductReleaseHookResponse => {\n let dashX = useDashXProvider();\n const { subscribe } = useWebSocket();\n const [productVariantReleaseRule, setProductVariantReleaseRule] = useState<ProductVariantReleaseRule | null>(null);\n\n useEffect(() => {\n // Set up product variant release rule watcher (automatically refetch on WebSocket reconnection)\n dashX.watchFetchProductVariantReleaseRule(setProductVariantReleaseRule);\n }, [dashX]);\n\n useEffect(() => {\n // Subscribe to WebSocket messages for product variant release updates\n const unsubscribe = subscribe((message: WebsocketMessageType) => {\n if (message?.type === WebsocketMessage.PRODUCT_VARIANT_RELEASE_RULE_UPDATED) {\n setProductVariantReleaseRule(message.data);\n }\n });\n\n return unsubscribe;\n }, [subscribe]);\n\n return {\n productVariantReleaseRule,\n };\n};\n\nexport default useProductRelease;\n"],
5
- "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAoC,iBACpCC,EAAiC,0BAGjCC,EAA6B,sCAC7BC,EAA6B,yCAM7B,MAAMC,EAAoB,IAAqC,CAC7D,IAAIC,KAAQ,EAAAC,SAAiB,EAC7B,KAAM,CAAE,UAAAC,CAAU,KAAI,gBAAa,EAC7B,CAACC,EAA2BC,CAA4B,KAAI,YAA2C,IAAI,EAEjH,sBAAU,IAAM,CAEdJ,EAAM,oCAAoCI,CAA4B,CACxE,EAAG,CAACJ,CAAK,CAAC,KAEV,aAAU,IAEYE,EAAWG,GAAkC,CAC3DA,GAAS,OAAS,mBAAiB,sCACrCD,EAA6BC,EAAQ,IAAI,CAE7C,CAAC,EAGA,CAACH,CAAS,CAAC,EAEP,CACL,0BAAAC,CACF,CACF,EAEA,IAAOV,EAAQM",
6
- "names": ["use_product_release_exports", "__export", "use_product_release_default", "__toCommonJS", "import_react", "import_browser", "import_use_dashx_provider", "import_DashXProvider", "useProductRelease", "dashX", "useDashXProvider", "subscribe", "productVariantReleaseRule", "setProductVariantReleaseRule", "message"]
4
+ "sourcesContent": ["import { useEffect, useState } from 'react';\nimport { WebsocketMessage } from '@dashx/browser';\nimport type { ProductVariantRelease, ProductVariantReleaseRule, WebsocketMessageType } from '@dashx/browser';\n\nimport useDashXProvider from './use-dashx-provider.js';\nimport { useWebSocket } from '../providers/DashXProvider.js';\n\ntype UseProductReleaseHookResponse = {\n productVariantRelease: ProductVariantRelease | null;\n productVariantReleaseRule: ProductVariantReleaseRule | null;\n};\n\nconst useProductRelease = (): UseProductReleaseHookResponse => {\n let dashX = useDashXProvider();\n const { subscribe } = useWebSocket();\n const [productVariantRelease, setProductVariantRelease] = useState<ProductVariantRelease | null>(null);\n const [productVariantReleaseRule, setProductVariantReleaseRule] = useState<ProductVariantReleaseRule | null>(null);\n\n useEffect(() => {\n dashX\n .fetchProductVariantRelease()\n .then(setProductVariantRelease)\n // Set up product variant release rule watcher (automatically refetch on WebSocket reconnection)\n dashX.watchFetchProductVariantReleaseRule(setProductVariantReleaseRule);\n }, [dashX]);\n\n useEffect(() => {\n // Subscribe to WebSocket messages for product variant release updates\n const unsubscribe = subscribe((message: WebsocketMessageType) => {\n if (message?.type === WebsocketMessage.PRODUCT_VARIANT_RELEASE_RULE_UPDATED) {\n setProductVariantReleaseRule(message.data);\n }\n });\n\n return unsubscribe;\n }, [subscribe]);\n\n return {\n productVariantRelease,\n productVariantReleaseRule,\n };\n};\n\nexport default useProductRelease;\n"],
5
+ "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAoC,iBACpCC,EAAiC,0BAGjCC,EAA6B,sCAC7BC,EAA6B,yCAO7B,MAAMC,EAAoB,IAAqC,CAC7D,IAAIC,KAAQ,EAAAC,SAAiB,EAC7B,KAAM,CAAE,UAAAC,CAAU,KAAI,gBAAa,EAC7B,CAACC,EAAuBC,CAAwB,KAAI,YAAuC,IAAI,EAC/F,CAACC,EAA2BC,CAA4B,KAAI,YAA2C,IAAI,EAEjH,sBAAU,IAAM,CACdN,EACG,2BAA2B,EAC3B,KAAKI,CAAwB,EAEhCJ,EAAM,oCAAoCM,CAA4B,CACxE,EAAG,CAACN,CAAK,CAAC,KAEV,aAAU,IAEYE,EAAWK,GAAkC,CAC3DA,GAAS,OAAS,mBAAiB,sCACrCD,EAA6BC,EAAQ,IAAI,CAE7C,CAAC,EAGA,CAACL,CAAS,CAAC,EAEP,CACL,sBAAAC,EACA,0BAAAE,CACF,CACF,EAEA,IAAOZ,EAAQM",
6
+ "names": ["use_product_release_exports", "__export", "use_product_release_default", "__toCommonJS", "import_react", "import_browser", "import_use_dashx_provider", "import_DashXProvider", "useProductRelease", "dashX", "useDashXProvider", "subscribe", "productVariantRelease", "setProductVariantRelease", "productVariantReleaseRule", "setProductVariantReleaseRule", "message"]
7
7
  }
@@ -1,3 +1,2 @@
1
- export * from './components/index.js';
2
1
  export * from './hooks/index.js';
3
2
  export * from './providers/index.js';
package/dist/cjs/index.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var a=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var t=(f,r,p,x)=>{if(r&&typeof r=="object"||typeof r=="function")for(let m of c(r))!d.call(f,m)&&m!==p&&a(f,m,{get:()=>r[m],enumerable:!(x=b(r,m))||x.enumerable});return f},e=(f,r,p)=>(t(f,r,"default"),p&&t(p,r,"default"));var g=f=>t(a({},"__esModule",{value:!0}),f);var o={};module.exports=g(o);e(o,require("./components/index.js"),module.exports);e(o,require("./hooks/index.js"),module.exports);e(o,require("./providers/index.js"),module.exports);
1
+ "use strict";var a=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var t=(r,o,p,x)=>{if(o&&typeof o=="object"||typeof o=="function")for(let m of c(o))!d.call(r,m)&&m!==p&&a(r,m,{get:()=>o[m],enumerable:!(x=b(o,m))||x.enumerable});return r},f=(r,o,p)=>(t(r,o,"default"),p&&t(p,o,"default"));var g=r=>t(a({},"__esModule",{value:!0}),r);var e={};module.exports=g(e);f(e,require("./hooks/index.js"),module.exports);f(e,require("./providers/index.js"),module.exports);
2
2
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.ts"],
4
- "sourcesContent": ["export * from './components/index.js';\nexport * from './hooks/index.js';\nexport * from './providers/index.js';\n"],
5
- "mappings": "iaAAA,IAAAA,EAAA,kBAAAC,EAAAD,GAAAE,EAAAF,EAAc,iCAAd,gBACAE,EAAAF,EAAc,4BADd,gBAEAE,EAAAF,EAAc,gCAFd",
4
+ "sourcesContent": ["// export * from './components/index.js';\nexport * from './hooks/index.js';\nexport * from './providers/index.js';\n"],
5
+ "mappings": "iaAAA,IAAAA,EAAA,kBAAAC,EAAAD,GACAE,EAAAF,EAAc,4BADd,gBAEAE,EAAAF,EAAc,gCAFd",
6
6
  "names": ["src_exports", "__toCommonJS", "__reExport"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var l=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var m=(a,r)=>{for(var n in r)l(a,n,{get:r[n],enumerable:!0})},T=(a,r,n,s)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of u(r))!c.call(a,o)&&o!==n&&l(a,o,{get:()=>r[o],enumerable:!(s=g(r,o))||s.enumerable});return a};var h=a=>T(l({},"__esModule",{value:!0}),a);var f={};m(f,{default:()=>x});module.exports=h(f);var t=require("react/jsx-runtime"),d=require("date-fns"),p=require("../hooks/index.js"),e=require("../index.js"),i=require("../icons/index.js");const v=()=>{let{markNotificationAsRead:a,markNotificationAsUnread:r,notifications:n,unreadNotificationsCount:s}=(0,p.useInApp)();return(0,t.jsx)(e.Theme,{children:(0,t.jsxs)(e.Popover.Root,{children:[(0,t.jsxs)(e.Tooltip.Root,{children:[(0,t.jsx)(e.Tooltip.Trigger,{children:(0,t.jsx)(e.Popover.Trigger,{children:(0,t.jsx)(e.Button,{shape:"square",roundness:"full",variant:s?"fill":"ghost",children:(0,t.jsx)(i.Inbox,{})})})}),(0,t.jsx)(e.Tooltip.Content,{content:"Notification"})]}),(0,t.jsxs)(e.Popover.Content,{spacing:"large",width:"350px",height:"450px",children:[(0,t.jsx)(e.Popover.Header,{asChild:!0,children:(0,t.jsxs)(e.Flex,{justify:"between",align:"center",children:[(0,t.jsx)(e.Heading,{size:3,children:"Notifications"}),(0,t.jsx)(e.Popover.Close,{children:(0,t.jsx)(e.Button,{shape:"square",roundness:"full",variant:"ghost",mode:"subtle",inset:"right",children:(0,t.jsx)(i.X,{})})})]})}),(0,t.jsx)(e.Popover.Body,{children:(0,t.jsxs)(e.Flex,{direction:"column",gap:1,children:[n.length<0&&(0,t.jsx)(e.Flex,{justify:"center",align:"center",children:(0,t.jsx)(e.Text,{variant:"tertiary",size:2,children:"No notifications yet."})}),n.map(o=>(0,t.jsx)(e.Card,{children:(0,t.jsxs)(e.Flex,{align:"center",gap:4,justify:"between",children:[(0,t.jsxs)(e.Flex,{direction:"column",gap:1,children:[(0,t.jsx)(e.Text,{as:"p",variant:"secondary",weight:"semibold",size:2,children:o.renderedContent.body}),(0,t.jsx)(e.Text,{size:1,variant:"tertiary",children:(0,d.intlFormatDistance)(o.sentAt,new Date)})]}),(0,t.jsxs)(e.Tooltip.Root,{children:[(0,t.jsx)(e.Tooltip.Trigger,{children:(0,t.jsx)(e.Button,{shape:"square",variant:"ghost",roundness:"full",mode:o.readAt?"subtle":"distinct",onPress:()=>{o.readAt?r(o.id):a(o.id)},children:o.readAt?(0,t.jsx)(i.MailOpen,{}):(0,t.jsx)(i.Mail,{})})}),(0,t.jsx)(e.Tooltip.Content,{content:o.readAt?"Mark as unread":"Mark as read"})]})]})},o.id))]})}),(0,t.jsx)(e.Popover.Footer,{asChild:!0,children:(0,t.jsx)(e.Text,{as:"p",align:"center",color:"accent",variant:"tertiary",size:1,children:"Powered by DashX"})})]})]})})};var x=v;
1
+ "use strict";var l=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var m=(a,r)=>{for(var n in r)l(a,n,{get:r[n],enumerable:!0})},T=(a,r,n,s)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of u(r))!c.call(a,o)&&o!==n&&l(a,o,{get:()=>r[o],enumerable:!(s=g(r,o))||s.enumerable});return a};var h=a=>T(l({},"__esModule",{value:!0}),a);var f={};m(f,{default:()=>x});module.exports=h(f);var t=require("react/jsx-runtime"),d=require("date-fns"),p=require("../hooks/index.js"),e=require("../components"),i=require("../icons/index.js");const v=()=>{let{markNotificationAsRead:a,markNotificationAsUnread:r,notifications:n,unreadNotificationsCount:s}=(0,p.useInApp)();return(0,t.jsx)(e.Theme,{children:(0,t.jsxs)(e.Popover.Root,{children:[(0,t.jsxs)(e.Tooltip.Root,{children:[(0,t.jsx)(e.Tooltip.Trigger,{children:(0,t.jsx)(e.Popover.Trigger,{children:(0,t.jsx)(e.Button,{shape:"square",roundness:"full",variant:s?"fill":"ghost",children:(0,t.jsx)(i.Inbox,{})})})}),(0,t.jsx)(e.Tooltip.Content,{content:"Notification"})]}),(0,t.jsxs)(e.Popover.Content,{spacing:"large",width:"350px",height:"450px",children:[(0,t.jsx)(e.Popover.Header,{asChild:!0,children:(0,t.jsxs)(e.Flex,{justify:"between",align:"center",children:[(0,t.jsx)(e.Heading,{size:3,children:"Notifications"}),(0,t.jsx)(e.Popover.Close,{children:(0,t.jsx)(e.Button,{shape:"square",roundness:"full",variant:"ghost",mode:"subtle",inset:"right",children:(0,t.jsx)(i.X,{})})})]})}),(0,t.jsx)(e.Popover.Body,{children:(0,t.jsxs)(e.Flex,{direction:"column",gap:1,children:[n.length<0&&(0,t.jsx)(e.Flex,{justify:"center",align:"center",children:(0,t.jsx)(e.Text,{variant:"tertiary",size:2,children:"No notifications yet."})}),n.map(o=>(0,t.jsx)(e.Card,{children:(0,t.jsxs)(e.Flex,{align:"center",gap:4,justify:"between",children:[(0,t.jsxs)(e.Flex,{direction:"column",gap:1,children:[(0,t.jsx)(e.Text,{as:"p",variant:"secondary",weight:"semibold",size:2,children:o.renderedContent.body}),(0,t.jsx)(e.Text,{size:1,variant:"tertiary",children:(0,d.intlFormatDistance)(o.sentAt,new Date)})]}),(0,t.jsxs)(e.Tooltip.Root,{children:[(0,t.jsx)(e.Tooltip.Trigger,{children:(0,t.jsx)(e.Button,{shape:"square",variant:"ghost",roundness:"full",mode:o.readAt?"subtle":"distinct",onPress:()=>{o.readAt?r(o.id):a(o.id)},children:o.readAt?(0,t.jsx)(i.MailOpen,{}):(0,t.jsx)(i.Mail,{})})}),(0,t.jsx)(e.Tooltip.Content,{content:o.readAt?"Mark as unread":"Mark as read"})]})]})},o.id))]})}),(0,t.jsx)(e.Popover.Footer,{asChild:!0,children:(0,t.jsx)(e.Text,{as:"p",align:"center",color:"accent",variant:"tertiary",size:1,children:"Powered by DashX"})})]})]})})};var x=v;
2
2
  //# sourceMappingURL=NotificationBell.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/widgets/NotificationBell.tsx"],
4
- "sourcesContent": ["import { intlFormatDistance } from 'date-fns';\n\nimport { useInApp } from '../hooks/index.js';\nimport { Button, Card, Flex, Heading, Popover, Text, Theme, Tooltip } from '../index.js';\nimport { Inbox, Mail, MailOpen, X } from '../icons/index.js';\n\nconst NotificationBell = () => {\n let {\n markNotificationAsRead,\n markNotificationAsUnread,\n notifications,\n unreadNotificationsCount,\n } = useInApp();\n\n return (\n <Theme>\n <Popover.Root>\n <Tooltip.Root>\n <Tooltip.Trigger>\n <Popover.Trigger>\n <Button\n shape=\"square\"\n roundness=\"full\"\n variant={unreadNotificationsCount ? 'fill' : 'ghost'}\n >\n <Inbox />\n </Button>\n </Popover.Trigger>\n </Tooltip.Trigger>\n <Tooltip.Content content=\"Notification\" />\n </Tooltip.Root>\n <Popover.Content spacing=\"large\" width=\"350px\" height=\"450px\">\n <Popover.Header asChild>\n <Flex justify=\"between\" align=\"center\">\n <Heading size={3}>Notifications</Heading>\n <Popover.Close>\n <Button shape=\"square\" roundness=\"full\" variant=\"ghost\" mode=\"subtle\" inset=\"right\">\n <X />\n </Button>\n </Popover.Close>\n </Flex>\n </Popover.Header>\n <Popover.Body>\n <Flex direction=\"column\" gap={1}>\n {notifications.length < 0 && (\n <Flex justify=\"center\" align=\"center\">\n <Text variant=\"tertiary\" size={2}>\n No notifications yet.\n </Text>\n </Flex>\n )}\n {notifications.map((notification) => (\n <Card key={notification.id}>\n <Flex align=\"center\" gap={4} justify=\"between\">\n <Flex direction=\"column\" gap={1}>\n <Text as=\"p\" variant=\"secondary\" weight=\"semibold\" size={2}>\n {notification.renderedContent.body}\n </Text>\n <Text size={1} variant=\"tertiary\">\n {intlFormatDistance(notification.sentAt, new Date())}\n </Text>\n </Flex>\n <Tooltip.Root>\n <Tooltip.Trigger>\n <Button\n shape=\"square\"\n variant=\"ghost\"\n roundness=\"full\"\n mode={notification.readAt ? 'subtle' : 'distinct'}\n onPress={() => {\n if (notification.readAt) {\n markNotificationAsUnread(notification.id);\n } else {\n markNotificationAsRead(notification.id);\n }\n }}\n >\n {notification.readAt ? <MailOpen /> : <Mail />}\n </Button>\n </Tooltip.Trigger>\n <Tooltip.Content\n content={notification.readAt ? 'Mark as unread' : 'Mark as read'}\n />\n </Tooltip.Root>\n </Flex>\n </Card>\n ))}\n </Flex>\n </Popover.Body>\n <Popover.Footer asChild>\n <Text as=\"p\" align=\"center\" color=\"accent\" variant=\"tertiary\" size={1}>\n Powered by DashX\n </Text>\n </Popover.Footer>\n </Popover.Content>\n </Popover.Root>\n </Theme>\n );\n};\n\nexport default NotificationBell;\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAiBQ,IAAAI,EAAA,6BAjBRC,EAAmC,oBAEnCC,EAAyB,6BACzBC,EAA2E,uBAC3EC,EAAyC,6BAEzC,MAAMC,EAAmB,IAAM,CAC7B,GAAI,CACF,uBAAAC,EACA,yBAAAC,EACA,cAAAC,EACA,yBAAAC,CACF,KAAI,YAAS,EAEb,SACE,OAAC,SACC,oBAAC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,EAAuBI,EAAa,EAAE,CAE1C,EAEC,SAAAA,EAAa,UAAS,OAAC,aAAS,KAAK,OAAC,SAAK,EAC9C,EACF,KACA,OAAC,UAAQ,QAAR,CACC,QAASA,EAAa,OAAS,iBAAmB,eACpD,GACF,GACF,GAhCSA,EAAa,EAiCxB,CACD,GACH,EACF,KACA,OAAC,UAAQ,OAAR,CAAe,QAAO,GACrB,mBAAC,QAAK,GAAG,IAAI,MAAM,SAAS,MAAM,SAAS,QAAQ,WAAW,KAAM,EAAG,4BAEvE,EACF,GACF,GACF,EACF,CAEJ,EAEA,IAAOZ,EAAQO",
6
- "names": ["NotificationBell_exports", "__export", "NotificationBell_default", "__toCommonJS", "import_jsx_runtime", "import_date_fns", "import_hooks", "import__", "import_icons", "NotificationBell", "markNotificationAsRead", "markNotificationAsUnread", "notifications", "unreadNotificationsCount", "notification"]
4
+ "sourcesContent": ["import { intlFormatDistance } from 'date-fns';\n\nimport { useInApp } from '../hooks/index.js';\nimport { Button, Card, Flex, Heading, Popover, Text, Theme, Tooltip } from '../components';\nimport { Inbox, Mail, MailOpen, X } from '../icons/index.js';\n\nconst NotificationBell = () => {\n let {\n markNotificationAsRead,\n markNotificationAsUnread,\n notifications,\n unreadNotificationsCount,\n } = useInApp();\n\n return (\n <Theme>\n <Popover.Root>\n <Tooltip.Root>\n <Tooltip.Trigger>\n <Popover.Trigger>\n <Button\n shape=\"square\"\n roundness=\"full\"\n variant={unreadNotificationsCount ? 'fill' : 'ghost'}\n >\n <Inbox />\n </Button>\n </Popover.Trigger>\n </Tooltip.Trigger>\n <Tooltip.Content content=\"Notification\" />\n </Tooltip.Root>\n <Popover.Content spacing=\"large\" width=\"350px\" height=\"450px\">\n <Popover.Header asChild>\n <Flex justify=\"between\" align=\"center\">\n <Heading size={3}>Notifications</Heading>\n <Popover.Close>\n <Button shape=\"square\" roundness=\"full\" variant=\"ghost\" mode=\"subtle\" inset=\"right\">\n <X />\n </Button>\n </Popover.Close>\n </Flex>\n </Popover.Header>\n <Popover.Body>\n <Flex direction=\"column\" gap={1}>\n {notifications.length < 0 && (\n <Flex justify=\"center\" align=\"center\">\n <Text variant=\"tertiary\" size={2}>\n No notifications yet.\n </Text>\n </Flex>\n )}\n {notifications.map((notification) => (\n <Card key={notification.id}>\n <Flex align=\"center\" gap={4} justify=\"between\">\n <Flex direction=\"column\" gap={1}>\n <Text as=\"p\" variant=\"secondary\" weight=\"semibold\" size={2}>\n {notification.renderedContent.body}\n </Text>\n <Text size={1} variant=\"tertiary\">\n {intlFormatDistance(notification.sentAt, new Date())}\n </Text>\n </Flex>\n <Tooltip.Root>\n <Tooltip.Trigger>\n <Button\n shape=\"square\"\n variant=\"ghost\"\n roundness=\"full\"\n mode={notification.readAt ? 'subtle' : 'distinct'}\n onPress={() => {\n if (notification.readAt) {\n markNotificationAsUnread(notification.id);\n } else {\n markNotificationAsRead(notification.id);\n }\n }}\n >\n {notification.readAt ? <MailOpen /> : <Mail />}\n </Button>\n </Tooltip.Trigger>\n <Tooltip.Content\n content={notification.readAt ? 'Mark as unread' : 'Mark as read'}\n />\n </Tooltip.Root>\n </Flex>\n </Card>\n ))}\n </Flex>\n </Popover.Body>\n <Popover.Footer asChild>\n <Text as=\"p\" align=\"center\" color=\"accent\" variant=\"tertiary\" size={1}>\n Powered by DashX\n </Text>\n </Popover.Footer>\n </Popover.Content>\n </Popover.Root>\n </Theme>\n );\n};\n\nexport default NotificationBell;\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAiBQ,IAAAI,EAAA,6BAjBRC,EAAmC,oBAEnCC,EAAyB,6BACzBC,EAA2E,yBAC3EC,EAAyC,6BAEzC,MAAMC,EAAmB,IAAM,CAC7B,GAAI,CACF,uBAAAC,EACA,yBAAAC,EACA,cAAAC,EACA,yBAAAC,CACF,KAAI,YAAS,EAEb,SACE,OAAC,SACC,oBAAC,UAAQ,KAAR,CACC,qBAAC,UAAQ,KA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SAAAA,EAAa,UAAS,OAAC,aAAS,KAAK,OAAC,SAAK,EAC9C,EACF,KACA,OAAC,UAAQ,QAAR,CACC,QAASA,EAAa,OAAS,iBAAmB,eACpD,GACF,GACF,GAhCSA,EAAa,EAiCxB,CACD,GACH,EACF,KACA,OAAC,UAAQ,OAAR,CAAe,QAAO,GACrB,mBAAC,QAAK,GAAG,IAAI,MAAM,SAAS,MAAM,SAAS,QAAQ,WAAW,KAAM,EAAG,4BAEvE,EACF,GACF,GACF,EACF,CAEJ,EAEA,IAAOZ,EAAQO",
6
+ "names": ["NotificationBell_exports", "__export", "NotificationBell_default", "__toCommonJS", "import_jsx_runtime", "import_date_fns", "import_hooks", "import_components", "import_icons", "NotificationBell", "markNotificationAsRead", "markNotificationAsUnread", "notifications", "unreadNotificationsCount", "notification"]
7
7
  }
@@ -1,5 +1,6 @@
1
- import type { ProductVariantReleaseRule } from '@dashx/browser';
1
+ import type { ProductVariantRelease, ProductVariantReleaseRule } from '@dashx/browser';
2
2
  type UseProductReleaseHookResponse = {
3
+ productVariantRelease: ProductVariantRelease | null;
3
4
  productVariantReleaseRule: ProductVariantReleaseRule | null;
4
5
  };
5
6
  declare const useProductRelease: () => UseProductReleaseHookResponse;
@@ -1,2 +1,2 @@
1
- import{useEffect as o,useState as u}from"react";import{WebsocketMessage as l}from"@dashx/browser";import c from"./use-dashx-provider.js";import{useWebSocket as R}from"../providers/DashXProvider.js";const n=()=>{let e=c();const{subscribe:t}=R(),[a,s]=u(null);return o(()=>{e.watchFetchProductVariantReleaseRule(s)},[e]),o(()=>t(r=>{r?.type===l.PRODUCT_VARIANT_RELEASE_RULE_UPDATED&&s(r.data)}),[t]),{productVariantReleaseRule:a}};var f=n;export{f as default};
1
+ import{useEffect as s,useState as o}from"react";import{WebsocketMessage as n}from"@dashx/browser";import R from"./use-dashx-provider.js";import{useWebSocket as i}from"../providers/DashXProvider.js";const d=()=>{let e=R();const{subscribe:t}=i(),[u,l]=o(null),[c,a]=o(null);return s(()=>{e.fetchProductVariantRelease().then(l),e.watchFetchProductVariantReleaseRule(a)},[e]),s(()=>t(r=>{r?.type===n.PRODUCT_VARIANT_RELEASE_RULE_UPDATED&&a(r.data)}),[t]),{productVariantRelease:u,productVariantReleaseRule:c}};var m=d;export{m as default};
2
2
  //# sourceMappingURL=use-product-release.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/hooks/use-product-release.ts"],
4
- "sourcesContent": ["import { useEffect, useState } from 'react';\nimport { WebsocketMessage } from '@dashx/browser';\nimport type { ProductVariantReleaseRule, WebsocketMessageType } from '@dashx/browser';\n\nimport useDashXProvider from './use-dashx-provider.js';\nimport { useWebSocket } from '../providers/DashXProvider.js';\n\ntype UseProductReleaseHookResponse = {\n productVariantReleaseRule: ProductVariantReleaseRule | null;\n};\n\nconst useProductRelease = (): UseProductReleaseHookResponse => {\n let dashX = useDashXProvider();\n const { subscribe } = useWebSocket();\n const [productVariantReleaseRule, setProductVariantReleaseRule] = useState<ProductVariantReleaseRule | null>(null);\n\n useEffect(() => {\n // Set up product variant release rule watcher (automatically refetch on WebSocket reconnection)\n dashX.watchFetchProductVariantReleaseRule(setProductVariantReleaseRule);\n }, [dashX]);\n\n useEffect(() => {\n // Subscribe to WebSocket messages for product variant release updates\n const unsubscribe = subscribe((message: WebsocketMessageType) => {\n if (message?.type === WebsocketMessage.PRODUCT_VARIANT_RELEASE_RULE_UPDATED) {\n setProductVariantReleaseRule(message.data);\n }\n });\n\n return unsubscribe;\n }, [subscribe]);\n\n return {\n productVariantReleaseRule,\n };\n};\n\nexport default useProductRelease;\n"],
5
- "mappings": "AAAA,OAAS,aAAAA,EAAW,YAAAC,MAAgB,QACpC,OAAS,oBAAAC,MAAwB,iBAGjC,OAAOC,MAAsB,0BAC7B,OAAS,gBAAAC,MAAoB,gCAM7B,MAAMC,EAAoB,IAAqC,CAC7D,IAAIC,EAAQH,EAAiB,EAC7B,KAAM,CAAE,UAAAI,CAAU,EAAIH,EAAa,EAC7B,CAACI,EAA2BC,CAA4B,EAAIR,EAA2C,IAAI,EAEjH,OAAAD,EAAU,IAAM,CAEdM,EAAM,oCAAoCG,CAA4B,CACxE,EAAG,CAACH,CAAK,CAAC,EAEVN,EAAU,IAEYO,EAAWG,GAAkC,CAC3DA,GAAS,OAASR,EAAiB,sCACrCO,EAA6BC,EAAQ,IAAI,CAE7C,CAAC,EAGA,CAACH,CAAS,CAAC,EAEP,CACL,0BAAAC,CACF,CACF,EAEA,IAAOG,EAAQN",
6
- "names": ["useEffect", "useState", "WebsocketMessage", "useDashXProvider", "useWebSocket", "useProductRelease", "dashX", "subscribe", "productVariantReleaseRule", "setProductVariantReleaseRule", "message", "use_product_release_default"]
4
+ "sourcesContent": ["import { useEffect, useState } from 'react';\nimport { WebsocketMessage } from '@dashx/browser';\nimport type { ProductVariantRelease, ProductVariantReleaseRule, WebsocketMessageType } from '@dashx/browser';\n\nimport useDashXProvider from './use-dashx-provider.js';\nimport { useWebSocket } from '../providers/DashXProvider.js';\n\ntype UseProductReleaseHookResponse = {\n productVariantRelease: ProductVariantRelease | null;\n productVariantReleaseRule: ProductVariantReleaseRule | null;\n};\n\nconst useProductRelease = (): UseProductReleaseHookResponse => {\n let dashX = useDashXProvider();\n const { subscribe } = useWebSocket();\n const [productVariantRelease, setProductVariantRelease] = useState<ProductVariantRelease | null>(null);\n const [productVariantReleaseRule, setProductVariantReleaseRule] = useState<ProductVariantReleaseRule | null>(null);\n\n useEffect(() => {\n dashX\n .fetchProductVariantRelease()\n .then(setProductVariantRelease)\n // Set up product variant release rule watcher (automatically refetch on WebSocket reconnection)\n dashX.watchFetchProductVariantReleaseRule(setProductVariantReleaseRule);\n }, [dashX]);\n\n useEffect(() => {\n // Subscribe to WebSocket messages for product variant release updates\n const unsubscribe = subscribe((message: WebsocketMessageType) => {\n if (message?.type === WebsocketMessage.PRODUCT_VARIANT_RELEASE_RULE_UPDATED) {\n setProductVariantReleaseRule(message.data);\n }\n });\n\n return unsubscribe;\n }, [subscribe]);\n\n return {\n productVariantRelease,\n productVariantReleaseRule,\n };\n};\n\nexport default useProductRelease;\n"],
5
+ "mappings": "AAAA,OAAS,aAAAA,EAAW,YAAAC,MAAgB,QACpC,OAAS,oBAAAC,MAAwB,iBAGjC,OAAOC,MAAsB,0BAC7B,OAAS,gBAAAC,MAAoB,gCAO7B,MAAMC,EAAoB,IAAqC,CAC7D,IAAIC,EAAQH,EAAiB,EAC7B,KAAM,CAAE,UAAAI,CAAU,EAAIH,EAAa,EAC7B,CAACI,EAAuBC,CAAwB,EAAIR,EAAuC,IAAI,EAC/F,CAACS,EAA2BC,CAA4B,EAAIV,EAA2C,IAAI,EAEjH,OAAAD,EAAU,IAAM,CACdM,EACG,2BAA2B,EAC3B,KAAKG,CAAwB,EAEhCH,EAAM,oCAAoCK,CAA4B,CACxE,EAAG,CAACL,CAAK,CAAC,EAEVN,EAAU,IAEYO,EAAWK,GAAkC,CAC3DA,GAAS,OAASV,EAAiB,sCACrCS,EAA6BC,EAAQ,IAAI,CAE7C,CAAC,EAGA,CAACL,CAAS,CAAC,EAEP,CACL,sBAAAC,EACA,0BAAAE,CACF,CACF,EAEA,IAAOG,EAAQR",
6
+ "names": ["useEffect", "useState", "WebsocketMessage", "useDashXProvider", "useWebSocket", "useProductRelease", "dashX", "subscribe", "productVariantRelease", "setProductVariantRelease", "productVariantReleaseRule", "setProductVariantReleaseRule", "message", "use_product_release_default"]
7
7
  }
@@ -1,3 +1,2 @@
1
- export * from './components/index.js';
2
1
  export * from './hooks/index.js';
3
2
  export * from './providers/index.js';
package/dist/esm/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export*from"./components/index.js";export*from"./hooks/index.js";export*from"./providers/index.js";
1
+ export*from"./hooks/index.js";export*from"./providers/index.js";
2
2
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.ts"],
4
- "sourcesContent": ["export * from './components/index.js';\nexport * from './hooks/index.js';\nexport * from './providers/index.js';\n"],
5
- "mappings": "AAAA,WAAc,wBACd,WAAc,mBACd,WAAc",
4
+ "sourcesContent": ["// export * from './components/index.js';\nexport * from './hooks/index.js';\nexport * from './providers/index.js';\n"],
5
+ "mappings": "AACA,WAAc,mBACd,WAAc",
6
6
  "names": []
7
7
  }
@@ -1,2 +1,2 @@
1
- import{jsx as e,jsxs as o}from"react/jsx-runtime";import{intlFormatDistance as u}from"date-fns";import{useInApp as c}from"../hooks/index.js";import{Button as s,Card as m,Flex as i,Heading as T,Popover as r,Text as n,Theme as h,Tooltip as a}from"../index.js";import{Inbox as v,Mail as x,MailOpen as f,X as y}from"../icons/index.js";const C=()=>{let{markNotificationAsRead:d,markNotificationAsUnread:p,notifications:l,unreadNotificationsCount:g}=c();return e(h,{children:o(r.Root,{children:[o(a.Root,{children:[e(a.Trigger,{children:e(r.Trigger,{children:e(s,{shape:"square",roundness:"full",variant:g?"fill":"ghost",children:e(v,{})})})}),e(a.Content,{content:"Notification"})]}),o(r.Content,{spacing:"large",width:"350px",height:"450px",children:[e(r.Header,{asChild:!0,children:o(i,{justify:"between",align:"center",children:[e(T,{size:3,children:"Notifications"}),e(r.Close,{children:e(s,{shape:"square",roundness:"full",variant:"ghost",mode:"subtle",inset:"right",children:e(y,{})})})]})}),e(r.Body,{children:o(i,{direction:"column",gap:1,children:[l.length<0&&e(i,{justify:"center",align:"center",children:e(n,{variant:"tertiary",size:2,children:"No notifications yet."})}),l.map(t=>e(m,{children:o(i,{align:"center",gap:4,justify:"between",children:[o(i,{direction:"column",gap:1,children:[e(n,{as:"p",variant:"secondary",weight:"semibold",size:2,children:t.renderedContent.body}),e(n,{size:1,variant:"tertiary",children:u(t.sentAt,new Date)})]}),o(a.Root,{children:[e(a.Trigger,{children:e(s,{shape:"square",variant:"ghost",roundness:"full",mode:t.readAt?"subtle":"distinct",onPress:()=>{t.readAt?p(t.id):d(t.id)},children:t.readAt?e(f,{}):e(x,{})})}),e(a.Content,{content:t.readAt?"Mark as unread":"Mark as read"})]})]})},t.id))]})}),e(r.Footer,{asChild:!0,children:e(n,{as:"p",align:"center",color:"accent",variant:"tertiary",size:1,children:"Powered by DashX"})})]})]})})};var B=C;export{B as default};
1
+ import{jsx as e,jsxs as o}from"react/jsx-runtime";import{intlFormatDistance as u}from"date-fns";import{useInApp as c}from"../hooks/index.js";import{Button as s,Card as m,Flex as i,Heading as T,Popover as r,Text as n,Theme as h,Tooltip as a}from"../components";import{Inbox as v,Mail as x,MailOpen as f,X as y}from"../icons/index.js";const C=()=>{let{markNotificationAsRead:d,markNotificationAsUnread:p,notifications:l,unreadNotificationsCount:g}=c();return e(h,{children:o(r.Root,{children:[o(a.Root,{children:[e(a.Trigger,{children:e(r.Trigger,{children:e(s,{shape:"square",roundness:"full",variant:g?"fill":"ghost",children:e(v,{})})})}),e(a.Content,{content:"Notification"})]}),o(r.Content,{spacing:"large",width:"350px",height:"450px",children:[e(r.Header,{asChild:!0,children:o(i,{justify:"between",align:"center",children:[e(T,{size:3,children:"Notifications"}),e(r.Close,{children:e(s,{shape:"square",roundness:"full",variant:"ghost",mode:"subtle",inset:"right",children:e(y,{})})})]})}),e(r.Body,{children:o(i,{direction:"column",gap:1,children:[l.length<0&&e(i,{justify:"center",align:"center",children:e(n,{variant:"tertiary",size:2,children:"No notifications yet."})}),l.map(t=>e(m,{children:o(i,{align:"center",gap:4,justify:"between",children:[o(i,{direction:"column",gap:1,children:[e(n,{as:"p",variant:"secondary",weight:"semibold",size:2,children:t.renderedContent.body}),e(n,{size:1,variant:"tertiary",children:u(t.sentAt,new Date)})]}),o(a.Root,{children:[e(a.Trigger,{children:e(s,{shape:"square",variant:"ghost",roundness:"full",mode:t.readAt?"subtle":"distinct",onPress:()=>{t.readAt?p(t.id):d(t.id)},children:t.readAt?e(f,{}):e(x,{})})}),e(a.Content,{content:t.readAt?"Mark as unread":"Mark as read"})]})]})},t.id))]})}),e(r.Footer,{asChild:!0,children:e(n,{as:"p",align:"center",color:"accent",variant:"tertiary",size:1,children:"Powered by DashX"})})]})]})})};var B=C;export{B as default};
2
2
  //# sourceMappingURL=NotificationBell.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/widgets/NotificationBell.tsx"],
4
- "sourcesContent": ["import { intlFormatDistance } from 'date-fns';\n\nimport { useInApp } from '../hooks/index.js';\nimport { Button, Card, Flex, Heading, Popover, Text, Theme, Tooltip } from '../index.js';\nimport { Inbox, Mail, MailOpen, X } from '../icons/index.js';\n\nconst NotificationBell = () => {\n let {\n markNotificationAsRead,\n markNotificationAsUnread,\n notifications,\n unreadNotificationsCount,\n } = useInApp();\n\n return (\n <Theme>\n <Popover.Root>\n <Tooltip.Root>\n <Tooltip.Trigger>\n <Popover.Trigger>\n <Button\n shape=\"square\"\n roundness=\"full\"\n variant={unreadNotificationsCount ? 'fill' : 'ghost'}\n >\n <Inbox />\n </Button>\n </Popover.Trigger>\n </Tooltip.Trigger>\n <Tooltip.Content content=\"Notification\" />\n </Tooltip.Root>\n <Popover.Content spacing=\"large\" width=\"350px\" height=\"450px\">\n <Popover.Header asChild>\n <Flex justify=\"between\" align=\"center\">\n <Heading size={3}>Notifications</Heading>\n <Popover.Close>\n <Button shape=\"square\" roundness=\"full\" variant=\"ghost\" mode=\"subtle\" inset=\"right\">\n <X />\n </Button>\n </Popover.Close>\n </Flex>\n </Popover.Header>\n <Popover.Body>\n <Flex direction=\"column\" gap={1}>\n {notifications.length < 0 && (\n <Flex justify=\"center\" align=\"center\">\n <Text variant=\"tertiary\" size={2}>\n No notifications yet.\n </Text>\n </Flex>\n )}\n {notifications.map((notification) => (\n <Card key={notification.id}>\n <Flex align=\"center\" gap={4} justify=\"between\">\n <Flex direction=\"column\" gap={1}>\n <Text as=\"p\" variant=\"secondary\" weight=\"semibold\" size={2}>\n {notification.renderedContent.body}\n </Text>\n <Text size={1} variant=\"tertiary\">\n {intlFormatDistance(notification.sentAt, new Date())}\n </Text>\n </Flex>\n <Tooltip.Root>\n <Tooltip.Trigger>\n <Button\n shape=\"square\"\n variant=\"ghost\"\n roundness=\"full\"\n mode={notification.readAt ? 'subtle' : 'distinct'}\n onPress={() => {\n if (notification.readAt) {\n markNotificationAsUnread(notification.id);\n } else {\n markNotificationAsRead(notification.id);\n }\n }}\n >\n {notification.readAt ? <MailOpen /> : <Mail />}\n </Button>\n </Tooltip.Trigger>\n <Tooltip.Content\n content={notification.readAt ? 'Mark as unread' : 'Mark as read'}\n />\n </Tooltip.Root>\n </Flex>\n </Card>\n ))}\n </Flex>\n </Popover.Body>\n <Popover.Footer asChild>\n <Text as=\"p\" align=\"center\" color=\"accent\" variant=\"tertiary\" size={1}>\n Powered by DashX\n </Text>\n </Popover.Footer>\n </Popover.Content>\n </Popover.Root>\n </Theme>\n );\n};\n\nexport default NotificationBell;\n"],
5
- "mappings": "AAiBQ,OAQQ,OAAAA,EARR,QAAAC,MAAA,oBAjBR,OAAS,sBAAAC,MAA0B,WAEnC,OAAS,YAAAC,MAAgB,oBACzB,OAAS,UAAAC,EAAQ,QAAAC,EAAM,QAAAC,EAAM,WAAAC,EAAS,WAAAC,EAAS,QAAAC,EAAM,SAAAC,EAAO,WAAAC,MAAe,cAC3E,OAAS,SAAAC,EAAO,QAAAC,EAAM,YAAAC,EAAU,KAAAC,MAAS,oBAEzC,MAAMC,EAAmB,IAAM,CAC7B,GAAI,CACF,uBAAAC,EACA,yBAAAC,EACA,cAAAC,EACA,yBAAAC,CACF,EAAIjB,EAAS,EAEb,OACEH,EAACU,EAAA,CACC,SAAAT,EAACO,EAAQ,KAAR,CACC,UAAAP,EAACU,EAAQ,KAAR,CACC,UAAAX,EAACW,EAAQ,QAAR,CACC,SAAAX,EAACQ,EAAQ,QAAR,CACC,SAAAR,EAACI,EAAA,CACC,MAAM,SACN,UAAU,OACV,QAASgB,EAA2B,OAAS,QAE7C,SAAApB,EAACY,EAAA,EAAM,EACT,EACF,EACF,EACAZ,EAACW,EAAQ,QA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C,EAEC,SAAAA,EAAa,OAASrB,EAACc,EAAA,EAAS,EAAKd,EAACa,EAAA,EAAK,EAC9C,EACF,EACAb,EAACW,EAAQ,QAAR,CACC,QAASU,EAAa,OAAS,iBAAmB,eACpD,GACF,GACF,GAhCSA,EAAa,EAiCxB,CACD,GACH,EACF,EACArB,EAACQ,EAAQ,OAAR,CAAe,QAAO,GACrB,SAAAR,EAACS,EAAA,CAAK,GAAG,IAAI,MAAM,SAAS,MAAM,SAAS,QAAQ,WAAW,KAAM,EAAG,4BAEvE,EACF,GACF,GACF,EACF,CAEJ,EAEA,IAAOa,EAAQN",
4
+ "sourcesContent": ["import { intlFormatDistance } from 'date-fns';\n\nimport { useInApp } from '../hooks/index.js';\nimport { Button, Card, Flex, Heading, Popover, Text, Theme, Tooltip } from '../components';\nimport { Inbox, Mail, MailOpen, X } from '../icons/index.js';\n\nconst NotificationBell = () => {\n let {\n markNotificationAsRead,\n markNotificationAsUnread,\n notifications,\n unreadNotificationsCount,\n } = useInApp();\n\n return (\n <Theme>\n <Popover.Root>\n <Tooltip.Root>\n <Tooltip.Trigger>\n <Popover.Trigger>\n <Button\n shape=\"square\"\n roundness=\"full\"\n variant={unreadNotificationsCount ? 'fill' : 'ghost'}\n >\n <Inbox />\n </Button>\n </Popover.Trigger>\n </Tooltip.Trigger>\n <Tooltip.Content content=\"Notification\" />\n </Tooltip.Root>\n <Popover.Content spacing=\"large\" width=\"350px\" height=\"450px\">\n <Popover.Header asChild>\n <Flex justify=\"between\" align=\"center\">\n <Heading size={3}>Notifications</Heading>\n <Popover.Close>\n <Button shape=\"square\" roundness=\"full\" variant=\"ghost\" mode=\"subtle\" inset=\"right\">\n <X />\n </Button>\n </Popover.Close>\n </Flex>\n </Popover.Header>\n <Popover.Body>\n <Flex direction=\"column\" gap={1}>\n {notifications.length < 0 && (\n <Flex justify=\"center\" align=\"center\">\n <Text variant=\"tertiary\" size={2}>\n No notifications yet.\n </Text>\n </Flex>\n )}\n {notifications.map((notification) => (\n <Card key={notification.id}>\n <Flex align=\"center\" gap={4} justify=\"between\">\n <Flex direction=\"column\" gap={1}>\n <Text as=\"p\" variant=\"secondary\" weight=\"semibold\" size={2}>\n {notification.renderedContent.body}\n </Text>\n <Text size={1} variant=\"tertiary\">\n {intlFormatDistance(notification.sentAt, new Date())}\n </Text>\n </Flex>\n <Tooltip.Root>\n <Tooltip.Trigger>\n <Button\n shape=\"square\"\n variant=\"ghost\"\n roundness=\"full\"\n mode={notification.readAt ? 'subtle' : 'distinct'}\n onPress={() => {\n if (notification.readAt) {\n markNotificationAsUnread(notification.id);\n } else {\n markNotificationAsRead(notification.id);\n }\n }}\n >\n {notification.readAt ? <MailOpen /> : <Mail />}\n </Button>\n </Tooltip.Trigger>\n <Tooltip.Content\n content={notification.readAt ? 'Mark as unread' : 'Mark as read'}\n />\n </Tooltip.Root>\n </Flex>\n </Card>\n ))}\n </Flex>\n </Popover.Body>\n <Popover.Footer asChild>\n <Text as=\"p\" align=\"center\" color=\"accent\" variant=\"tertiary\" size={1}>\n Powered by DashX\n </Text>\n </Popover.Footer>\n </Popover.Content>\n </Popover.Root>\n </Theme>\n );\n};\n\nexport default NotificationBell;\n"],
5
+ "mappings": "AAiBQ,OAQQ,OAAAA,EARR,QAAAC,MAAA,oBAjBR,OAAS,sBAAAC,MAA0B,WAEnC,OAAS,YAAAC,MAAgB,oBACzB,OAAS,UAAAC,EAAQ,QAAAC,EAAM,QAAAC,EAAM,WAAAC,EAAS,WAAAC,EAAS,QAAAC,EAAM,SAAAC,EAAO,WAAAC,MAAe,gBAC3E,OAAS,SAAAC,EAAO,QAAAC,EAAM,YAAAC,EAAU,KAAAC,MAAS,oBAEzC,MAAMC,EAAmB,IAAM,CAC7B,GAAI,CACF,uBAAAC,EACA,yBAAAC,EACA,cAAAC,EACA,yBAAAC,CACF,EAAIjB,EAAS,EAEb,OACEH,EAACU,EAAA,CACC,SAAAT,EAACO,EAAQ,KAAR,CACC,UAAAP,EAACU,EAAQ,KAAR,C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AAX,EAACW,EAAQ,QAAR,CACC,SAAAX,EAACI,EAAA,CACC,MAAM,SACN,QAAQ,QACR,UAAU,OACV,KAAMiB,EAAa,OAAS,SAAW,WACvC,QAAS,IAAM,CACTA,EAAa,OACfH,EAAyBG,EAAa,EAAE,EAExCJ,EAAuBI,EAAa,EAAE,CAE1C,EAEC,SAAAA,EAAa,OAASrB,EAACc,EAAA,EAAS,EAAKd,EAACa,EAAA,EAAK,EAC9C,EACF,EACAb,EAACW,EAAQ,QAAR,CACC,QAASU,EAAa,OAAS,iBAAmB,eACpD,GACF,GACF,GAhCSA,EAAa,EAiCxB,CACD,GACH,EACF,EACArB,EAACQ,EAAQ,OAAR,CAAe,QAAO,GACrB,SAAAR,EAACS,EAAA,CAAK,GAAG,IAAI,MAAM,SAAS,MAAM,SAAS,QAAQ,WAAW,KAAM,EAAG,4BAEvE,EACF,GACF,GACF,EACF,CAEJ,EAEA,IAAOa,EAAQN",
6
6
  "names": ["jsx", "jsxs", "intlFormatDistance", "useInApp", "Button", "Card", "Flex", "Heading", "Popover", "Text", "Theme", "Tooltip", "Inbox", "Mail", "MailOpen", "X", "NotificationBell", "markNotificationAsRead", "markNotificationAsUnread", "notifications", "unreadNotificationsCount", "notification", "NotificationBell_default"]
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dashx/react",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "license": "UNLICENSED",
5
5
  "type": "commonjs",
6
6
  "main": "./dist/cjs/index.js",
@@ -75,7 +75,7 @@
75
75
  "clean": "rm -rf .turbo node_modules dist tokens layout *.css"
76
76
  },
77
77
  "dependencies": {
78
- "@dashx/browser": "^0.4.1",
78
+ "@dashx/browser": "^0.4.2",
79
79
  "@radix-ui/colors": "^3.0.0",
80
80
  "@radix-ui/primitive": "^1.0.1",
81
81
  "@radix-ui/react-accessible-icon": "^1.0.3",
@@ -1,20 +1,25 @@
1
1
  import { useEffect, useState } from 'react';
2
2
  import { WebsocketMessage } from '@dashx/browser';
3
- import type { ProductVariantReleaseRule, WebsocketMessageType } from '@dashx/browser';
3
+ import type { ProductVariantRelease, ProductVariantReleaseRule, WebsocketMessageType } from '@dashx/browser';
4
4
 
5
5
  import useDashXProvider from './use-dashx-provider.js';
6
6
  import { useWebSocket } from '../providers/DashXProvider.js';
7
7
 
8
8
  type UseProductReleaseHookResponse = {
9
+ productVariantRelease: ProductVariantRelease | null;
9
10
  productVariantReleaseRule: ProductVariantReleaseRule | null;
10
11
  };
11
12
 
12
13
  const useProductRelease = (): UseProductReleaseHookResponse => {
13
14
  let dashX = useDashXProvider();
14
15
  const { subscribe } = useWebSocket();
16
+ const [productVariantRelease, setProductVariantRelease] = useState<ProductVariantRelease | null>(null);
15
17
  const [productVariantReleaseRule, setProductVariantReleaseRule] = useState<ProductVariantReleaseRule | null>(null);
16
18
 
17
19
  useEffect(() => {
20
+ dashX
21
+ .fetchProductVariantRelease()
22
+ .then(setProductVariantRelease)
18
23
  // Set up product variant release rule watcher (automatically refetch on WebSocket reconnection)
19
24
  dashX.watchFetchProductVariantReleaseRule(setProductVariantReleaseRule);
20
25
  }, [dashX]);
@@ -31,6 +36,7 @@ const useProductRelease = (): UseProductReleaseHookResponse => {
31
36
  }, [subscribe]);
32
37
 
33
38
  return {
39
+ productVariantRelease,
34
40
  productVariantReleaseRule,
35
41
  };
36
42
  };
package/src/index.ts CHANGED
@@ -1,3 +1,3 @@
1
- export * from './components/index.js';
1
+ // export * from './components/index.js';
2
2
  export * from './hooks/index.js';
3
3
  export * from './providers/index.js';
@@ -1,7 +1,7 @@
1
1
  import { intlFormatDistance } from 'date-fns';
2
2
 
3
3
  import { useInApp } from '../hooks/index.js';
4
- import { Button, Card, Flex, Heading, Popover, Text, Theme, Tooltip } from '../index.js';
4
+ import { Button, Card, Flex, Heading, Popover, Text, Theme, Tooltip } from '../components';
5
5
  import { Inbox, Mail, MailOpen, X } from '../icons/index.js';
6
6
 
7
7
  const NotificationBell = () => {