@dashx/react 0.1.2 → 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.
Files changed (36) hide show
  1. package/dist/cjs/components/flex.d.ts +292 -4
  2. package/dist/cjs/hooks/use-product-release.d.ts +2 -1
  3. package/dist/cjs/hooks/use-product-release.js +1 -1
  4. package/dist/cjs/hooks/use-product-release.js.map +3 -3
  5. package/dist/cjs/index.d.ts +0 -1
  6. package/dist/cjs/index.js +1 -1
  7. package/dist/cjs/index.js.map +3 -3
  8. package/dist/cjs/variants/base-element.d.ts +86 -2
  9. package/dist/cjs/variants/base-field.d.ts +129 -3
  10. package/dist/cjs/variants/base-input.d.ts +1 -1
  11. package/dist/cjs/variants/button.d.ts +138 -3
  12. package/dist/cjs/variants/card.d.ts +62 -2
  13. package/dist/cjs/variants/checkbox.d.ts +19 -1
  14. package/dist/cjs/variants/field-error.d.ts +86 -2
  15. package/dist/cjs/variants/heading.d.ts +234 -3
  16. package/dist/cjs/variants/link.d.ts +259 -4
  17. package/dist/cjs/variants/popover.d.ts +61 -5
  18. package/dist/cjs/variants/text-area.d.ts +161 -4
  19. package/dist/cjs/variants/text-field.d.ts +161 -4
  20. package/dist/cjs/variants/text.d.ts +235 -3
  21. package/dist/cjs/variants/tooltip.d.ts +1 -1
  22. package/dist/cjs/variants/typography.d.ts +182 -2
  23. package/dist/cjs/widgets/NotificationBell.js +1 -1
  24. package/dist/cjs/widgets/NotificationBell.js.map +3 -3
  25. package/dist/esm/hooks/use-product-release.d.ts +2 -1
  26. package/dist/esm/hooks/use-product-release.js +1 -1
  27. package/dist/esm/hooks/use-product-release.js.map +3 -3
  28. package/dist/esm/index.d.ts +0 -1
  29. package/dist/esm/index.js +1 -1
  30. package/dist/esm/index.js.map +2 -2
  31. package/dist/esm/widgets/NotificationBell.js +1 -1
  32. package/dist/esm/widgets/NotificationBell.js.map +2 -2
  33. package/package.json +2 -2
  34. package/src/hooks/use-product-release.ts +7 -1
  35. package/src/index.ts +1 -1
  36. package/src/widgets/NotificationBell.tsx +1 -1
@@ -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 </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EAACK,EAAA,CAAK,UAAU,SAAS,IAAK,EAC3B,UAAAa,EAAc,OAAS,GACtBnB,EAACM,EAAA,CAAK,QAAQ,SAAS,MAAM,SAC3B,SAAAN,EAACS,EAAA,CAAK,QAAQ,WAAW,KAAM,EAAG,iCAElC,EACF,EAEDU,EAAc,IAAKE,GAClBrB,EAACK,EAAA,CACC,SAAAJ,EAACK,EAAA,CAAK,MAAM,SAAS,IAAK,EAAG,QAAQ,UACnC,UAAAL,EAACK,EAAA,CAAK,UAAU,SAAS,IAAK,EAC5B,UAAAN,EAACS,EAAA,CAAK,GAAG,IAAI,QAAQ,YAAY,OAAO,WAAW,KAAM,EACtD,SAAAY,EAAa,gBAAgB,KAChC,EACArB,EAACS,EAAA,CAAK,KAAM,EAAG,QAAQ,WACpB,SAAAP,EAAmBmB,EAAa,OAAQ,IAAI,IAAM,EACrD,GACF,EACApB,EAACU,EAAQ,KAAR,CACC,UAAAX,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",
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,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,QAAR,CAAgB,QAAQ,eAAe,GAC1C,EACAV,EAACO,EAAQ,QAAR,CAAgB,QAAQ,QAAQ,MAAM,QAAQ,OAAO,QACpD,UAAAR,EAACQ,EAAQ,OAAR,CAAe,QAAO,GACrB,SAAAP,EAACK,EAAA,CAAK,QAAQ,UAAU,MAAM,SAC5B,UAAAN,EAACO,EAAA,CAAQ,KAAM,EAAG,yBAAa,EAC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,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.2",
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.0",
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 = () => {