@cossistant/react 0.0.1
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/_virtual/rolldown_runtime.js +13 -0
- package/conversation.d.ts +312 -0
- package/conversation.d.ts.map +1 -0
- package/hooks/index.d.ts +23 -0
- package/hooks/index.js +24 -0
- package/hooks/private/store/use-conversations-store.d.ts +13 -0
- package/hooks/private/store/use-conversations-store.d.ts.map +1 -0
- package/hooks/private/store/use-conversations-store.js +34 -0
- package/hooks/private/store/use-conversations-store.js.map +1 -0
- package/hooks/private/store/use-store-selector.d.ts +10 -0
- package/hooks/private/store/use-store-selector.d.ts.map +1 -0
- package/hooks/private/store/use-store-selector.js +17 -0
- package/hooks/private/store/use-store-selector.js.map +1 -0
- package/hooks/private/store/use-website-store.d.ts +18 -0
- package/hooks/private/store/use-website-store.d.ts.map +1 -0
- package/hooks/private/store/use-website-store.js +39 -0
- package/hooks/private/store/use-website-store.js.map +1 -0
- package/hooks/private/use-client-query.d.ts +25 -0
- package/hooks/private/use-client-query.d.ts.map +1 -0
- package/hooks/private/use-client-query.js +122 -0
- package/hooks/private/use-client-query.js.map +1 -0
- package/hooks/private/use-default-messages.d.ts +18 -0
- package/hooks/private/use-default-messages.d.ts.map +1 -0
- package/hooks/private/use-default-messages.js +45 -0
- package/hooks/private/use-default-messages.js.map +1 -0
- package/hooks/private/use-grouped-messages.d.ts +54 -0
- package/hooks/private/use-grouped-messages.d.ts.map +1 -0
- package/hooks/private/use-grouped-messages.js +157 -0
- package/hooks/private/use-grouped-messages.js.map +1 -0
- package/hooks/private/use-multimodal-input.d.ts +40 -0
- package/hooks/private/use-multimodal-input.d.ts.map +1 -0
- package/hooks/private/use-multimodal-input.js +129 -0
- package/hooks/private/use-multimodal-input.js.map +1 -0
- package/hooks/private/use-rest-client.d.ts +17 -0
- package/hooks/private/use-rest-client.d.ts.map +1 -0
- package/hooks/private/use-rest-client.js +41 -0
- package/hooks/private/use-rest-client.js.map +1 -0
- package/hooks/private/use-visitor-typing-reporter.d.ts +19 -0
- package/hooks/private/use-visitor-typing-reporter.d.ts.map +1 -0
- package/hooks/private/use-visitor-typing-reporter.js +140 -0
- package/hooks/private/use-visitor-typing-reporter.js.map +1 -0
- package/hooks/use-composer-refocus.d.ts +20 -0
- package/hooks/use-composer-refocus.d.ts.map +1 -0
- package/hooks/use-composer-refocus.js +32 -0
- package/hooks/use-composer-refocus.js.map +1 -0
- package/hooks/use-conversation-auto-seen.d.ts +54 -0
- package/hooks/use-conversation-auto-seen.d.ts.map +1 -0
- package/hooks/use-conversation-auto-seen.js +106 -0
- package/hooks/use-conversation-auto-seen.js.map +1 -0
- package/hooks/use-conversation-history-page.d.ts +86 -0
- package/hooks/use-conversation-history-page.d.ts.map +1 -0
- package/hooks/use-conversation-history-page.js +97 -0
- package/hooks/use-conversation-history-page.js.map +1 -0
- package/hooks/use-conversation-lifecycle.d.ts +80 -0
- package/hooks/use-conversation-lifecycle.d.ts.map +1 -0
- package/hooks/use-conversation-lifecycle.js +54 -0
- package/hooks/use-conversation-lifecycle.js.map +1 -0
- package/hooks/use-conversation-page.d.ts +82 -0
- package/hooks/use-conversation-page.d.ts.map +1 -0
- package/hooks/use-conversation-page.js +138 -0
- package/hooks/use-conversation-page.js.map +1 -0
- package/hooks/use-conversation-seen.d.ts +17 -0
- package/hooks/use-conversation-seen.d.ts.map +1 -0
- package/hooks/use-conversation-seen.js +58 -0
- package/hooks/use-conversation-seen.js.map +1 -0
- package/hooks/use-conversation-timeline-items.d.ts +21 -0
- package/hooks/use-conversation-timeline-items.d.ts.map +1 -0
- package/hooks/use-conversation-timeline-items.js +87 -0
- package/hooks/use-conversation-timeline-items.js.map +1 -0
- package/hooks/use-conversation-typing.d.ts +13 -0
- package/hooks/use-conversation-typing.d.ts.map +1 -0
- package/hooks/use-conversation-typing.js +34 -0
- package/hooks/use-conversation-typing.js.map +1 -0
- package/hooks/use-conversation.d.ts +18 -0
- package/hooks/use-conversation.d.ts.map +1 -0
- package/hooks/use-conversation.js +44 -0
- package/hooks/use-conversation.js.map +1 -0
- package/hooks/use-conversations.d.ts +20 -0
- package/hooks/use-conversations.d.ts.map +1 -0
- package/hooks/use-conversations.js +68 -0
- package/hooks/use-conversations.js.map +1 -0
- package/hooks/use-create-conversation.d.ts +30 -0
- package/hooks/use-create-conversation.d.ts.map +1 -0
- package/hooks/use-create-conversation.js +67 -0
- package/hooks/use-create-conversation.js.map +1 -0
- package/hooks/use-home-page.d.ts +82 -0
- package/hooks/use-home-page.d.ts.map +1 -0
- package/hooks/use-home-page.js +89 -0
- package/hooks/use-home-page.js.map +1 -0
- package/hooks/use-message-composer.d.ts +88 -0
- package/hooks/use-message-composer.d.ts.map +1 -0
- package/hooks/use-message-composer.js +94 -0
- package/hooks/use-message-composer.js.map +1 -0
- package/hooks/use-realtime-support.d.ts +25 -0
- package/hooks/use-realtime-support.d.ts.map +1 -0
- package/hooks/use-realtime-support.js +29 -0
- package/hooks/use-realtime-support.js.map +1 -0
- package/hooks/use-send-message.d.ts +34 -0
- package/hooks/use-send-message.d.ts.map +1 -0
- package/hooks/use-send-message.js +118 -0
- package/hooks/use-send-message.js.map +1 -0
- package/hooks/use-visitor.d.ts +28 -0
- package/hooks/use-visitor.d.ts.map +1 -0
- package/hooks/use-visitor.js +59 -0
- package/hooks/use-visitor.js.map +1 -0
- package/hooks/use-window-visibility-focus.d.ts +9 -0
- package/hooks/use-window-visibility-focus.d.ts.map +1 -0
- package/hooks/use-window-visibility-focus.js +53 -0
- package/hooks/use-window-visibility-focus.js.map +1 -0
- package/identify-visitor.d.ts +18 -0
- package/identify-visitor.d.ts.map +1 -0
- package/identify-visitor.js +26 -0
- package/identify-visitor.js.map +1 -0
- package/index.d.ts +38 -0
- package/index.js +38 -0
- package/package.json +121 -0
- package/primitives/avatar/avatar.d.ts +31 -0
- package/primitives/avatar/avatar.d.ts.map +1 -0
- package/primitives/avatar/avatar.js +49 -0
- package/primitives/avatar/avatar.js.map +1 -0
- package/primitives/avatar/fallback.d.ts +24 -0
- package/primitives/avatar/fallback.d.ts.map +1 -0
- package/primitives/avatar/fallback.js +57 -0
- package/primitives/avatar/fallback.js.map +1 -0
- package/primitives/avatar/image.d.ts +27 -0
- package/primitives/avatar/image.d.ts.map +1 -0
- package/primitives/avatar/image.js +58 -0
- package/primitives/avatar/image.js.map +1 -0
- package/primitives/avatar/index.d.ts +4 -0
- package/primitives/avatar/index.js +5 -0
- package/primitives/avatar/index.parts.d.ts +4 -0
- package/primitives/avatar/index.parts.js +5 -0
- package/primitives/bubble.d.ts +28 -0
- package/primitives/bubble.d.ts.map +1 -0
- package/primitives/bubble.js +43 -0
- package/primitives/bubble.js.map +1 -0
- package/primitives/button.d.ts +19 -0
- package/primitives/button.d.ts.map +1 -0
- package/primitives/button.js +27 -0
- package/primitives/button.js.map +1 -0
- package/primitives/conversation-timeline.d.ts +86 -0
- package/primitives/conversation-timeline.d.ts.map +1 -0
- package/primitives/conversation-timeline.js +119 -0
- package/primitives/conversation-timeline.js.map +1 -0
- package/primitives/index.d.ts +20 -0
- package/primitives/index.d.ts.map +1 -0
- package/primitives/index.js +45 -0
- package/primitives/index.js.map +1 -0
- package/primitives/index.parts.d.ts +13 -0
- package/primitives/index.parts.js +14 -0
- package/primitives/multimodal-input.d.ts +53 -0
- package/primitives/multimodal-input.d.ts.map +1 -0
- package/primitives/multimodal-input.js +106 -0
- package/primitives/multimodal-input.js.map +1 -0
- package/primitives/timeline-item-group.d.ts +166 -0
- package/primitives/timeline-item-group.d.ts.map +1 -0
- package/primitives/timeline-item-group.js +204 -0
- package/primitives/timeline-item-group.js.map +1 -0
- package/primitives/timeline-item.d.ts +75 -0
- package/primitives/timeline-item.d.ts.map +1 -0
- package/primitives/timeline-item.js +145 -0
- package/primitives/timeline-item.js.map +1 -0
- package/primitives/window.d.ts +31 -0
- package/primitives/window.d.ts.map +1 -0
- package/primitives/window.js +58 -0
- package/primitives/window.js.map +1 -0
- package/provider.d.ts +95 -0
- package/provider.d.ts.map +1 -0
- package/provider.js +124 -0
- package/provider.js.map +1 -0
- package/realtime/event-filter.d.ts +8 -0
- package/realtime/event-filter.d.ts.map +1 -0
- package/realtime/event-filter.js +21 -0
- package/realtime/event-filter.js.map +1 -0
- package/realtime/index.d.ts +6 -0
- package/realtime/index.js +7 -0
- package/realtime/provider.d.ts +57 -0
- package/realtime/provider.d.ts.map +1 -0
- package/realtime/provider.js +351 -0
- package/realtime/provider.js.map +1 -0
- package/realtime/seen-store.d.ts +23 -0
- package/realtime/seen-store.d.ts.map +1 -0
- package/realtime/seen-store.js +34 -0
- package/realtime/seen-store.js.map +1 -0
- package/realtime/support-provider.d.ts +17 -0
- package/realtime/support-provider.d.ts.map +1 -0
- package/realtime/support-provider.js +54 -0
- package/realtime/support-provider.js.map +1 -0
- package/realtime/typing-store.d.ts +30 -0
- package/realtime/typing-store.d.ts.map +1 -0
- package/realtime/typing-store.js +34 -0
- package/realtime/typing-store.js.map +1 -0
- package/realtime/use-realtime.d.ts +29 -0
- package/realtime/use-realtime.d.ts.map +1 -0
- package/realtime/use-realtime.js +47 -0
- package/realtime/use-realtime.js.map +1 -0
- package/realtime-events.d.ts +344 -0
- package/realtime-events.d.ts.map +1 -0
- package/schemas.d.ts +90 -0
- package/schemas.d.ts.map +1 -0
- package/support/components/avatar-stack.d.ts +45 -0
- package/support/components/avatar-stack.d.ts.map +1 -0
- package/support/components/avatar-stack.js +72 -0
- package/support/components/avatar-stack.js.map +1 -0
- package/support/components/avatar.d.ts +15 -0
- package/support/components/avatar.d.ts.map +1 -0
- package/support/components/avatar.js +23 -0
- package/support/components/avatar.js.map +1 -0
- package/support/components/bubble.d.ts +10 -0
- package/support/components/bubble.d.ts.map +1 -0
- package/support/components/bubble.js +95 -0
- package/support/components/bubble.js.map +1 -0
- package/support/components/button.d.ts +20 -0
- package/support/components/button.d.ts.map +1 -0
- package/support/components/button.js +41 -0
- package/support/components/button.js.map +1 -0
- package/support/components/container.d.ts +14 -0
- package/support/components/container.d.ts.map +1 -0
- package/support/components/container.js +115 -0
- package/support/components/container.js.map +1 -0
- package/support/components/conversation-button-link.d.ts +34 -0
- package/support/components/conversation-button-link.d.ts.map +1 -0
- package/support/components/conversation-button-link.js +195 -0
- package/support/components/conversation-button-link.js.map +1 -0
- package/support/components/conversation-event.d.ts +14 -0
- package/support/components/conversation-event.d.ts.map +1 -0
- package/support/components/conversation-event.js +76 -0
- package/support/components/conversation-event.js.map +1 -0
- package/support/components/conversation-timeline.d.ts +17 -0
- package/support/components/conversation-timeline.d.ts.map +1 -0
- package/support/components/conversation-timeline.js +95 -0
- package/support/components/conversation-timeline.js.map +1 -0
- package/support/components/cossistant-branding.d.ts +12 -0
- package/support/components/cossistant-branding.d.ts.map +1 -0
- package/support/components/cossistant-branding.js +22 -0
- package/support/components/cossistant-branding.js.map +1 -0
- package/support/components/header.d.ts +11 -0
- package/support/components/header.d.ts.map +1 -0
- package/support/components/header.js +43 -0
- package/support/components/header.js.map +1 -0
- package/support/components/icons.d.ts +21 -0
- package/support/components/icons.d.ts.map +1 -0
- package/support/components/icons.js +131 -0
- package/support/components/icons.js.map +1 -0
- package/support/components/index.d.ts +11 -0
- package/support/components/index.js +12 -0
- package/support/components/multimodal-input.d.ts +28 -0
- package/support/components/multimodal-input.d.ts.map +1 -0
- package/support/components/multimodal-input.js +138 -0
- package/support/components/multimodal-input.js.map +1 -0
- package/support/components/navigation-tab.d.ts +7 -0
- package/support/components/navigation-tab.d.ts.map +1 -0
- package/support/components/navigation-tab.js +40 -0
- package/support/components/navigation-tab.js.map +1 -0
- package/support/components/support-content.d.ts +22 -0
- package/support/components/support-content.d.ts.map +1 -0
- package/support/components/support-content.js +50 -0
- package/support/components/support-content.js.map +1 -0
- package/support/components/text-effect.d.ts +49 -0
- package/support/components/text-effect.d.ts.map +1 -0
- package/support/components/text-effect.js +221 -0
- package/support/components/text-effect.js.map +1 -0
- package/support/components/timeline-message-group.d.ts +16 -0
- package/support/components/timeline-message-group.d.ts.map +1 -0
- package/support/components/timeline-message-group.js +117 -0
- package/support/components/timeline-message-group.js.map +1 -0
- package/support/components/timeline-message-item.d.ts +17 -0
- package/support/components/timeline-message-item.d.ts.map +1 -0
- package/support/components/timeline-message-item.js +42 -0
- package/support/components/timeline-message-item.js.map +1 -0
- package/support/components/typing-indicator.d.ts +26 -0
- package/support/components/typing-indicator.d.ts.map +1 -0
- package/support/components/typing-indicator.js +37 -0
- package/support/components/typing-indicator.js.map +1 -0
- package/support/components/watermark.d.ts +8 -0
- package/support/components/watermark.d.ts.map +1 -0
- package/support/components/watermark.js +34 -0
- package/support/components/watermark.js.map +1 -0
- package/support/context/config.d.ts +32 -0
- package/support/context/config.d.ts.map +1 -0
- package/support/context/config.js +27 -0
- package/support/context/config.js.map +1 -0
- package/support/context/websocket.d.ts +22 -0
- package/support/context/websocket.d.ts.map +1 -0
- package/support/context/websocket.js +113 -0
- package/support/context/websocket.js.map +1 -0
- package/support/index.d.ts +39 -0
- package/support/index.d.ts.map +1 -0
- package/support/index.js +43 -0
- package/support/index.js.map +1 -0
- package/support/pages/articles.d.ts +7 -0
- package/support/pages/articles.d.ts.map +1 -0
- package/support/pages/articles.js +39 -0
- package/support/pages/articles.js.map +1 -0
- package/support/pages/conversation-history.d.ts +18 -0
- package/support/pages/conversation-history.d.ts.map +1 -0
- package/support/pages/conversation-history.js +120 -0
- package/support/pages/conversation-history.js.map +1 -0
- package/support/pages/conversation.d.ts +32 -0
- package/support/pages/conversation.d.ts.map +1 -0
- package/support/pages/conversation.js +92 -0
- package/support/pages/conversation.js.map +1 -0
- package/support/pages/home.d.ts +20 -0
- package/support/pages/home.d.ts.map +1 -0
- package/support/pages/home.js +184 -0
- package/support/pages/home.js.map +1 -0
- package/support/router.d.ts +14 -0
- package/support/router.d.ts.map +1 -0
- package/support/router.js +31 -0
- package/support/router.js.map +1 -0
- package/support/store/index.d.ts +2 -0
- package/support/store/index.js +3 -0
- package/support/store/support-store.d.ts +42 -0
- package/support/store/support-store.d.ts.map +1 -0
- package/support/store/support-store.js +66 -0
- package/support/store/support-store.js.map +1 -0
- package/support/support-CMoDLQoC.css +408 -0
- package/support/support-CMoDLQoC.css.map +1 -0
- package/support/support.js +1 -0
- package/support/text/index.d.ts +35 -0
- package/support/text/index.d.ts.map +1 -0
- package/support/text/index.js +71 -0
- package/support/text/index.js.map +1 -0
- package/support/text/locales/en.d.ts +7 -0
- package/support/text/locales/en.d.ts.map +1 -0
- package/support/text/locales/en.js +65 -0
- package/support/text/locales/en.js.map +1 -0
- package/support/text/locales/es.d.ts +7 -0
- package/support/text/locales/es.d.ts.map +1 -0
- package/support/text/locales/es.js +64 -0
- package/support/text/locales/es.js.map +1 -0
- package/support/text/locales/fr.d.ts +7 -0
- package/support/text/locales/fr.d.ts.map +1 -0
- package/support/text/locales/fr.js +64 -0
- package/support/text/locales/fr.js.map +1 -0
- package/support/text/locales/keys.d.ts +216 -0
- package/support/text/locales/keys.d.ts.map +1 -0
- package/support/text/locales/keys.js +54 -0
- package/support/text/locales/keys.js.map +1 -0
- package/support/text/runtime.d.ts +17 -0
- package/support/text/runtime.d.ts.map +1 -0
- package/support/text/runtime.js +156 -0
- package/support/text/runtime.js.map +1 -0
- package/support/utils/index.d.ts +7 -0
- package/support/utils/index.d.ts.map +1 -0
- package/support/utils/index.js +11 -0
- package/support/utils/index.js.map +1 -0
- package/support/utils/time.d.ts +5 -0
- package/support/utils/time.d.ts.map +1 -0
- package/support/utils/time.js +28 -0
- package/support/utils/time.js.map +1 -0
- package/support-config.d.ts +20 -0
- package/support-config.d.ts.map +1 -0
- package/support-config.js +25 -0
- package/support-config.js.map +1 -0
- package/support.css +2 -0
- package/timeline-item.d.ts +133 -0
- package/timeline-item.d.ts.map +1 -0
- package/utils/id.d.ts +6 -0
- package/utils/id.d.ts.map +1 -0
- package/utils/id.js +13 -0
- package/utils/id.js.map +1 -0
- package/utils/index.d.ts +3 -0
- package/utils/index.js +4 -0
- package/utils/text.d.ts +5 -0
- package/utils/text.d.ts.map +1 -0
- package/utils/text.js +9 -0
- package/utils/text.js.map +1 -0
- package/utils/use-render-element.d.ts +22 -0
- package/utils/use-render-element.d.ts.map +1 -0
- package/utils/use-render-element.js +35 -0
- package/utils/use-render-element.js.map +1 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { useVisitor } from "./hooks/use-visitor.js";
|
|
2
|
+
import { useEffect } from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/identify-visitor.tsx
|
|
5
|
+
/**
|
|
6
|
+
* Component exposed by Cossistant allowing you to identify a visitor whenever rendered with either an `externalId` or `email`.
|
|
7
|
+
*/
|
|
8
|
+
const IdentifySupportVisitor = ({ externalId, email }) => {
|
|
9
|
+
const { visitor, identify } = useVisitor();
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
if (!visitor?.contact && (externalId || email)) identify({
|
|
12
|
+
externalId,
|
|
13
|
+
email
|
|
14
|
+
});
|
|
15
|
+
}, [
|
|
16
|
+
visitor?.contact,
|
|
17
|
+
externalId,
|
|
18
|
+
email
|
|
19
|
+
]);
|
|
20
|
+
return null;
|
|
21
|
+
};
|
|
22
|
+
IdentifySupportVisitor.displayName = "IdentifySupportVisitor";
|
|
23
|
+
|
|
24
|
+
//#endregion
|
|
25
|
+
export { IdentifySupportVisitor };
|
|
26
|
+
//# sourceMappingURL=identify-visitor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identify-visitor.js","names":[],"sources":["../src/identify-visitor.tsx"],"sourcesContent":["/** biome-ignore-all lint/correctness/useExhaustiveDependencies: wanted here */\nimport { useEffect } from \"react\";\nimport { useVisitor } from \"./hooks\";\n\nexport type IdentifySupportVisitorProps = {\n\texternalId?: string;\n\temail?: string;\n};\n\n/**\n * Component exposed by Cossistant allowing you to identify a visitor whenever rendered with either an `externalId` or `email`.\n */\nexport const IdentifySupportVisitor = ({\n\texternalId,\n\temail,\n}: IdentifySupportVisitorProps) => {\n\tconst { visitor, identify } = useVisitor();\n\n\t// Only update when the arrays actually change content\n\tuseEffect(() => {\n\t\tif (!visitor?.contact && (externalId || email)) {\n\t\t\tidentify({ externalId, email });\n\t\t}\n\t}, [visitor?.contact, externalId, email]);\n\n\treturn null;\n};\n\nIdentifySupportVisitor.displayName = \"IdentifySupportVisitor\";\n"],"mappings":";;;;;;;AAYA,MAAa,0BAA0B,EACtC,YACA,YACkC;CAClC,MAAM,EAAE,SAAS,aAAa,YAAY;AAG1C,iBAAgB;AACf,MAAI,CAAC,SAAS,YAAY,cAAc,OACvC,UAAS;GAAE;GAAY;GAAO,CAAC;IAE9B;EAAC,SAAS;EAAS;EAAY;EAAM,CAAC;AAEzC,QAAO;;AAGR,uBAAuB,cAAc"}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { useClientQuery } from "./hooks/private/use-client-query.js";
|
|
2
|
+
import { useDefaultMessages } from "./hooks/private/use-default-messages.js";
|
|
3
|
+
import { ConversationItem, GroupedMessage, TimelineEventItem, UseGroupedMessagesOptions, UseGroupedMessagesProps, useGroupedMessages } from "./hooks/private/use-grouped-messages.js";
|
|
4
|
+
import { UseMultimodalInputOptions, UseMultimodalInputReturn, useMultimodalInput } from "./hooks/private/use-multimodal-input.js";
|
|
5
|
+
import { UseClientResult, useClient } from "./hooks/private/use-rest-client.js";
|
|
6
|
+
import { UseComposerRefocusOptions, UseComposerRefocusReturn, useComposerRefocus } from "./hooks/use-composer-refocus.js";
|
|
7
|
+
import { UseConversationOptions, UseConversationResult, useConversation } from "./hooks/use-conversation.js";
|
|
8
|
+
import { CONVERSATION_AUTO_SEEN_DELAY_MS, UseConversationAutoSeenOptions, useConversationAutoSeen } from "./hooks/use-conversation-auto-seen.js";
|
|
9
|
+
import { UseConversationHistoryPageOptions, UseConversationHistoryPageReturn, useConversationHistoryPage } from "./hooks/use-conversation-history-page.js";
|
|
10
|
+
import { ConversationLifecycleState, UseConversationLifecycleOptions, UseConversationLifecycleReturn, useConversationLifecycle } from "./hooks/use-conversation-lifecycle.js";
|
|
11
|
+
import { UseConversationPageOptions, UseConversationPageReturn, useConversationPage } from "./hooks/use-conversation-page.js";
|
|
12
|
+
import { useConversationSeen, useDebouncedConversationSeen } from "./hooks/use-conversation-seen.js";
|
|
13
|
+
import { UseConversationTimelineItemsOptions, UseConversationTimelineItemsResult, useConversationTimelineItems } from "./hooks/use-conversation-timeline-items.js";
|
|
14
|
+
import { ConversationTypingParticipant, useConversationTyping } from "./hooks/use-conversation-typing.js";
|
|
15
|
+
import { UseConversationsOptions, UseConversationsResult, useConversations } from "./hooks/use-conversations.js";
|
|
16
|
+
import { CreateConversationVariables, UseCreateConversationOptions, UseCreateConversationResult, useCreateConversation } from "./hooks/use-create-conversation.js";
|
|
17
|
+
import { UseHomePageOptions, UseHomePageReturn, useHomePage } from "./hooks/use-home-page.js";
|
|
18
|
+
import { UseMessageComposerOptions, UseMessageComposerReturn, useMessageComposer } from "./hooks/use-message-composer.js";
|
|
19
|
+
import { UseRealtimeSupportOptions, UseRealtimeSupportResult, useRealtimeSupport } from "./hooks/use-realtime-support.js";
|
|
20
|
+
import { SendMessageOptions, SendMessageResult, UseSendMessageOptions, UseSendMessageResult, useSendMessage } from "./hooks/use-send-message.js";
|
|
21
|
+
import { UseVisitorReturn, useVisitor } from "./hooks/use-visitor.js";
|
|
22
|
+
import { WindowVisibilityFocusState, useWindowVisibilityFocus } from "./hooks/use-window-visibility-focus.js";
|
|
23
|
+
import { IdentifySupportVisitor, IdentifySupportVisitorProps } from "./identify-visitor.js";
|
|
24
|
+
import { SupportConfig, SupportConfigProps } from "./support-config.js";
|
|
25
|
+
import { index_d_exports } from "./primitives/index.js";
|
|
26
|
+
import { CossistantContextValue, CossistantProviderProps, SupportProvider, SupportProviderProps, useSupport } from "./provider.js";
|
|
27
|
+
import { RealtimeAuthConfig, RealtimeContextValue, RealtimeProvider, RealtimeProviderProps, useRealtimeConnection } from "./realtime/provider.js";
|
|
28
|
+
import { applyConversationSeenEvent, hydrateConversationSeen, upsertConversationSeen } from "./realtime/seen-store.js";
|
|
29
|
+
import { SupportRealtimeProvider } from "./realtime/support-provider.js";
|
|
30
|
+
import { applyConversationTypingEvent, clearTypingFromTimelineItem, clearTypingState, setTypingState } from "./realtime/typing-store.js";
|
|
31
|
+
import { RealtimeEventHandler, RealtimeEventHandlerEntry, RealtimeEventHandlersMap, RealtimeEventMeta, useRealtime } from "./realtime/use-realtime.js";
|
|
32
|
+
import { SupportLocale, SupportTextContentOverrides } from "./support/text/locales/keys.js";
|
|
33
|
+
import { Text, useSupportText } from "./support/text/index.js";
|
|
34
|
+
import { useSupportConfig } from "./support/context/config.js";
|
|
35
|
+
import { WebSocketContextValue, WebSocketProvider, useWebSocket } from "./support/context/websocket.js";
|
|
36
|
+
import { useSupportStore } from "./support/store/support-store.js";
|
|
37
|
+
import { Support, SupportProps } from "./support/index.js";
|
|
38
|
+
export { CONVERSATION_AUTO_SEEN_DELAY_MS, ConversationItem, ConversationLifecycleState, ConversationTypingParticipant, CossistantContextValue, CossistantProviderProps, CreateConversationVariables, GroupedMessage, IdentifySupportVisitor, IdentifySupportVisitorProps, index_d_exports as Primitives, RealtimeAuthConfig, RealtimeContextValue, RealtimeEventHandler, RealtimeEventHandlerEntry, RealtimeEventHandlersMap, RealtimeEventMeta, RealtimeProvider, RealtimeProviderProps, SendMessageOptions, SendMessageResult, Support, SupportConfig, SupportConfigProps, SupportLocale, SupportProps, SupportProvider, SupportProviderProps, SupportRealtimeProvider, SupportTextContentOverrides, Text, TimelineEventItem, UseClientResult, UseComposerRefocusOptions, UseComposerRefocusReturn, UseConversationAutoSeenOptions, UseConversationHistoryPageOptions, UseConversationHistoryPageReturn, UseConversationLifecycleOptions, UseConversationLifecycleReturn, UseConversationOptions, UseConversationPageOptions, UseConversationPageReturn, UseConversationResult, UseConversationTimelineItemsOptions, UseConversationTimelineItemsResult, UseConversationsOptions, UseConversationsResult, UseCreateConversationOptions, UseCreateConversationResult, UseGroupedMessagesOptions, UseGroupedMessagesProps, UseHomePageOptions, UseHomePageReturn, UseMessageComposerOptions, UseMessageComposerReturn, UseMultimodalInputOptions, UseMultimodalInputReturn, UseRealtimeSupportOptions, UseRealtimeSupportResult, UseSendMessageOptions, UseSendMessageResult, UseVisitorReturn, WebSocketContextValue, WebSocketProvider, WindowVisibilityFocusState, applyConversationSeenEvent, applyConversationTypingEvent, clearTypingFromTimelineItem, clearTypingState, hydrateConversationSeen, setTypingState, upsertConversationSeen, useClient, useClientQuery, useComposerRefocus, useConversation, useConversationAutoSeen, useConversationHistoryPage, useConversationLifecycle, useConversationPage, useConversationSeen, useConversationTimelineItems, useConversationTyping, useConversations, useCreateConversation, useDebouncedConversationSeen, useDefaultMessages, useGroupedMessages, useHomePage, useMessageComposer, useMultimodalInput, useRealtime, useRealtimeConnection, useRealtimeSupport, useSendMessage, useSupport, useSupportConfig, useSupportStore, useSupportText, useVisitor, useWebSocket, useWindowVisibilityFocus };
|
package/index.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { useClientQuery } from "./hooks/private/use-client-query.js";
|
|
2
|
+
import { useClient } from "./hooks/private/use-rest-client.js";
|
|
3
|
+
import { RealtimeProvider, useRealtimeConnection } from "./realtime/provider.js";
|
|
4
|
+
import { applyConversationSeenEvent, hydrateConversationSeen, upsertConversationSeen } from "./realtime/seen-store.js";
|
|
5
|
+
import { applyConversationTypingEvent, clearTypingFromTimelineItem, clearTypingState, setTypingState } from "./realtime/typing-store.js";
|
|
6
|
+
import { useRealtime } from "./realtime/use-realtime.js";
|
|
7
|
+
import { SupportRealtimeProvider } from "./realtime/support-provider.js";
|
|
8
|
+
import { SupportConfig } from "./support-config.js";
|
|
9
|
+
import { useSupportStore } from "./support/store/support-store.js";
|
|
10
|
+
import { useSupportConfig } from "./support/context/config.js";
|
|
11
|
+
import { primitives_exports } from "./primitives/index.js";
|
|
12
|
+
import { Text, useSupportText } from "./support/text/index.js";
|
|
13
|
+
import { useWindowVisibilityFocus } from "./hooks/use-window-visibility-focus.js";
|
|
14
|
+
import { CONVERSATION_AUTO_SEEN_DELAY_MS, useConversationAutoSeen } from "./hooks/use-conversation-auto-seen.js";
|
|
15
|
+
import { useConversationLifecycle } from "./hooks/use-conversation-lifecycle.js";
|
|
16
|
+
import { useConversationTimelineItems } from "./hooks/use-conversation-timeline-items.js";
|
|
17
|
+
import { useMultimodalInput } from "./hooks/private/use-multimodal-input.js";
|
|
18
|
+
import { useSendMessage } from "./hooks/use-send-message.js";
|
|
19
|
+
import { useMessageComposer } from "./hooks/use-message-composer.js";
|
|
20
|
+
import { useConversationPage } from "./hooks/use-conversation-page.js";
|
|
21
|
+
import { useGroupedMessages } from "./hooks/private/use-grouped-messages.js";
|
|
22
|
+
import { useComposerRefocus } from "./hooks/use-composer-refocus.js";
|
|
23
|
+
import { useConversations } from "./hooks/use-conversations.js";
|
|
24
|
+
import { useConversationHistoryPage } from "./hooks/use-conversation-history-page.js";
|
|
25
|
+
import { useHomePage } from "./hooks/use-home-page.js";
|
|
26
|
+
import { WebSocketProvider, useWebSocket } from "./support/context/websocket.js";
|
|
27
|
+
import { Support } from "./support/index.js";
|
|
28
|
+
import { SupportProvider, useSupport } from "./provider.js";
|
|
29
|
+
import { useDefaultMessages } from "./hooks/private/use-default-messages.js";
|
|
30
|
+
import { useConversation } from "./hooks/use-conversation.js";
|
|
31
|
+
import { useConversationSeen, useDebouncedConversationSeen } from "./hooks/use-conversation-seen.js";
|
|
32
|
+
import { useConversationTyping } from "./hooks/use-conversation-typing.js";
|
|
33
|
+
import { useCreateConversation } from "./hooks/use-create-conversation.js";
|
|
34
|
+
import { useRealtimeSupport } from "./hooks/use-realtime-support.js";
|
|
35
|
+
import { useVisitor } from "./hooks/use-visitor.js";
|
|
36
|
+
import { IdentifySupportVisitor } from "./identify-visitor.js";
|
|
37
|
+
|
|
38
|
+
export { CONVERSATION_AUTO_SEEN_DELAY_MS, IdentifySupportVisitor, primitives_exports as Primitives, RealtimeProvider, Support, SupportConfig, SupportProvider, SupportRealtimeProvider, Text, WebSocketProvider, applyConversationSeenEvent, applyConversationTypingEvent, clearTypingFromTimelineItem, clearTypingState, hydrateConversationSeen, setTypingState, upsertConversationSeen, useClient, useClientQuery, useComposerRefocus, useConversation, useConversationAutoSeen, useConversationHistoryPage, useConversationLifecycle, useConversationPage, useConversationSeen, useConversationTimelineItems, useConversationTyping, useConversations, useCreateConversation, useDebouncedConversationSeen, useDefaultMessages, useGroupedMessages, useHomePage, useMessageComposer, useMultimodalInput, useRealtime, useRealtimeConnection, useRealtimeSupport, useSendMessage, useSupport, useSupportConfig, useSupportStore, useSupportText, useVisitor, useWebSocket, useWindowVisibilityFocus };
|
package/package.json
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cossistant/react",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"private": false,
|
|
5
|
+
"author": "Cossistant team",
|
|
6
|
+
"description": "Headless React SDK for building AI-powered support/chat widgets. Hooks + primitives, WS-driven, TypeScript-first. Next.js-ready, Tailwind optional.",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"react",
|
|
9
|
+
"headless",
|
|
10
|
+
"headless-ui",
|
|
11
|
+
"support",
|
|
12
|
+
"customer support",
|
|
13
|
+
"helpdesk",
|
|
14
|
+
"support widget",
|
|
15
|
+
"chat widget",
|
|
16
|
+
"live chat",
|
|
17
|
+
"ai",
|
|
18
|
+
"ai support",
|
|
19
|
+
"ai-agent",
|
|
20
|
+
"support agent",
|
|
21
|
+
"typescript",
|
|
22
|
+
"nextjs",
|
|
23
|
+
"tailwind",
|
|
24
|
+
"shadcn",
|
|
25
|
+
"accessibility"
|
|
26
|
+
],
|
|
27
|
+
"bugs": {
|
|
28
|
+
"url": "https://github.com/cossistantcom/cossistant/issues"
|
|
29
|
+
},
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "git+https://github.com/cossistantcom/cossistant.git",
|
|
33
|
+
"directory": "packages/react"
|
|
34
|
+
},
|
|
35
|
+
"license": "MIT",
|
|
36
|
+
"homepage": "https://cossistant.com",
|
|
37
|
+
"exports": {
|
|
38
|
+
".": {
|
|
39
|
+
"types": "./index.d.ts",
|
|
40
|
+
"import": "./index.js"
|
|
41
|
+
},
|
|
42
|
+
"./primitives": {
|
|
43
|
+
"types": "./primitives/index.d.ts",
|
|
44
|
+
"import": "./primitives/index.js"
|
|
45
|
+
},
|
|
46
|
+
"./primitives/*": {
|
|
47
|
+
"types": "./primitives/*.d.ts",
|
|
48
|
+
"import": "./primitives/*.js"
|
|
49
|
+
},
|
|
50
|
+
"./support": {
|
|
51
|
+
"types": "./support/index.d.ts",
|
|
52
|
+
"import": "./support/index.js"
|
|
53
|
+
},
|
|
54
|
+
"./hooks": {
|
|
55
|
+
"types": "./hooks/index.d.ts",
|
|
56
|
+
"import": "./hooks/index.js"
|
|
57
|
+
},
|
|
58
|
+
"./hooks/*": {
|
|
59
|
+
"types": "./hooks/*d.ts",
|
|
60
|
+
"import": "./hooks/*js"
|
|
61
|
+
},
|
|
62
|
+
"./support.css": "./support/support.css",
|
|
63
|
+
"./realtime": {
|
|
64
|
+
"types": "./realtime/index.d.ts",
|
|
65
|
+
"import": "./realtime/index.js"
|
|
66
|
+
},
|
|
67
|
+
"./utils": {
|
|
68
|
+
"types": "./utils/index.d.ts",
|
|
69
|
+
"import": "./utils/index.js"
|
|
70
|
+
},
|
|
71
|
+
"./utils/*": {
|
|
72
|
+
"types": "./utils/*.d.ts",
|
|
73
|
+
"import": "./utils/*.js"
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
"main": "./index.js",
|
|
77
|
+
"module": "./index.js",
|
|
78
|
+
"types": "./index.d.ts",
|
|
79
|
+
"sideEffects": [
|
|
80
|
+
"*.css"
|
|
81
|
+
],
|
|
82
|
+
"dependencies": {
|
|
83
|
+
"@cossistant/core": "workspace:*",
|
|
84
|
+
"@cossistant/types": "workspace:*",
|
|
85
|
+
"nanoid": "^5.1.5",
|
|
86
|
+
"react-markdown": "^10.1.0",
|
|
87
|
+
"react-use-websocket": "^4.13.0",
|
|
88
|
+
"tailwind-merge": "^3.3.1",
|
|
89
|
+
"ulid": "^3.0.1"
|
|
90
|
+
},
|
|
91
|
+
"peerDependencies": {
|
|
92
|
+
"react": ">=18 <20",
|
|
93
|
+
"react-dom": ">=18 <20",
|
|
94
|
+
"@types/react": "^18 || ^19",
|
|
95
|
+
"motion": "^12.18.1",
|
|
96
|
+
"tailwindcss": "*"
|
|
97
|
+
},
|
|
98
|
+
"peerDependenciesMeta": {
|
|
99
|
+
"@types/react": {
|
|
100
|
+
"optional": true
|
|
101
|
+
},
|
|
102
|
+
"tailwindcss": {
|
|
103
|
+
"optional": true
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
"browserslist": {
|
|
107
|
+
"production": [
|
|
108
|
+
">0.2%",
|
|
109
|
+
"not dead",
|
|
110
|
+
"not op_mini all"
|
|
111
|
+
],
|
|
112
|
+
"development": [
|
|
113
|
+
"last 1 chrome version",
|
|
114
|
+
"last 1 firefox version",
|
|
115
|
+
"last 1 safari version"
|
|
116
|
+
]
|
|
117
|
+
},
|
|
118
|
+
"publishConfig": {
|
|
119
|
+
"access": "public"
|
|
120
|
+
}
|
|
121
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as React$1 from "react";
|
|
2
|
+
|
|
3
|
+
//#region src/primitives/avatar/avatar.d.ts
|
|
4
|
+
type AvatarState = {
|
|
5
|
+
imageLoadingStatus: "idle" | "loading" | "loaded" | "error";
|
|
6
|
+
};
|
|
7
|
+
type AvatarProps = Omit<React$1.HTMLAttributes<HTMLSpanElement>, "children"> & {
|
|
8
|
+
children?: React$1.ReactNode;
|
|
9
|
+
asChild?: boolean;
|
|
10
|
+
className?: string;
|
|
11
|
+
};
|
|
12
|
+
interface AvatarContextValue extends AvatarState {
|
|
13
|
+
onImageLoadingStatusChange: (status: AvatarState["imageLoadingStatus"]) => void;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Consumer hook for the `Avatar` compound components. Throws when components are
|
|
17
|
+
* rendered outside of the `Avatar` tree to surface integration errors early.
|
|
18
|
+
*/
|
|
19
|
+
declare const useAvatarContext: () => AvatarContextValue;
|
|
20
|
+
/**
|
|
21
|
+
* Root avatar wrapper that coordinates image loading state with fallback
|
|
22
|
+
* children so consumers can compose initials, images and status rings.
|
|
23
|
+
*/
|
|
24
|
+
declare const Avatar: React$1.ForwardRefExoticComponent<Omit<React$1.HTMLAttributes<HTMLSpanElement>, "children"> & {
|
|
25
|
+
children?: React$1.ReactNode;
|
|
26
|
+
asChild?: boolean;
|
|
27
|
+
className?: string;
|
|
28
|
+
} & React$1.RefAttributes<HTMLSpanElement>>;
|
|
29
|
+
//#endregion
|
|
30
|
+
export { Avatar, AvatarContextValue, AvatarProps, useAvatarContext };
|
|
31
|
+
//# sourceMappingURL=avatar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"avatar.d.ts","names":[],"sources":["../../../src/primitives/avatar/avatar.tsx"],"sourcesContent":[],"mappings":";;;KAGK,WAAA;;AAH0B,CAAA;AAOnB,KAAA,WAAA,GAAc,IAAH,CACtB,OAAA,CAAM,cADgB,CACD,eADC,CAAA,EAAA,UAAA,CAAA,GAAA;EAAA,QAAA,CAAA,EAIX,OAAA,CAAM,SAJK;SACD,CAAA,EAAA,OAAA;WAArB,CAAA,EAAM,MAAA;;AAGK,UAKK,kBAAA,SAA2B,WAL1B,CAAA;EAAS,0BAAA,EAAA,CAAA,MAAA,EAOjB,WAPiB,CAAA,oBAAA,CAAA,EAAA,GAAA,IAAA;AAK3B;;;;;AAYa,cAAA,gBAAgB,EAAA,GAAA,GAAA,kBAQ5B;AAMD;;;;AAAmB,cAAN,MAAM,EAAA,OAAA,CAAA,yBAAA,CAAA,IAAA,CAAA,OAAA,CAAA,cAAA,CAAA,eAAA,CAAA,EAAA,UAAA,CAAA,GAAA;UA/BP,CAAA,EAAA,OAAA,CAAM,SAAA;;;yBA+BC,gBAAA,CAAA,CAAA"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { useRenderElement } from "../../utils/use-render-element.js";
|
|
2
|
+
import * as React$1 from "react";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
|
|
5
|
+
//#region src/primitives/avatar/avatar.tsx
|
|
6
|
+
const AvatarContext = React$1.createContext(null);
|
|
7
|
+
/**
|
|
8
|
+
* Consumer hook for the `Avatar` compound components. Throws when components are
|
|
9
|
+
* rendered outside of the `Avatar` tree to surface integration errors early.
|
|
10
|
+
*/
|
|
11
|
+
const useAvatarContext = () => {
|
|
12
|
+
const context = React$1.useContext(AvatarContext);
|
|
13
|
+
if (!context) throw new Error("Avatar compound components cannot be rendered outside the Avatar component");
|
|
14
|
+
return context;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Root avatar wrapper that coordinates image loading state with fallback
|
|
18
|
+
* children so consumers can compose initials, images and status rings.
|
|
19
|
+
*/
|
|
20
|
+
const Avatar = (() => {
|
|
21
|
+
const Component = React$1.forwardRef(({ children, className, asChild = false,...props }, ref) => {
|
|
22
|
+
const [imageLoadingStatus, setImageLoadingStatus] = React$1.useState("idle");
|
|
23
|
+
const contextValue = React$1.useMemo(() => ({
|
|
24
|
+
imageLoadingStatus,
|
|
25
|
+
onImageLoadingStatusChange: setImageLoadingStatus
|
|
26
|
+
}), [imageLoadingStatus]);
|
|
27
|
+
const state = { imageLoadingStatus };
|
|
28
|
+
return /* @__PURE__ */ jsx(AvatarContext.Provider, {
|
|
29
|
+
value: contextValue,
|
|
30
|
+
children: useRenderElement("div", {
|
|
31
|
+
asChild,
|
|
32
|
+
className
|
|
33
|
+
}, {
|
|
34
|
+
ref,
|
|
35
|
+
state,
|
|
36
|
+
props: {
|
|
37
|
+
...props,
|
|
38
|
+
children
|
|
39
|
+
}
|
|
40
|
+
})
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
Component.displayName = "Avatar";
|
|
44
|
+
return Component;
|
|
45
|
+
})();
|
|
46
|
+
|
|
47
|
+
//#endregion
|
|
48
|
+
export { Avatar, useAvatarContext };
|
|
49
|
+
//# sourceMappingURL=avatar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"avatar.js","names":["React","contextValue: AvatarContextValue","state: AvatarState"],"sources":["../../../src/primitives/avatar/avatar.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { useRenderElement } from \"../../utils/use-render-element\";\n\ntype AvatarState = {\n\timageLoadingStatus: \"idle\" | \"loading\" | \"loaded\" | \"error\";\n};\n\nexport type AvatarProps = Omit<\n\tReact.HTMLAttributes<HTMLSpanElement>,\n\t\"children\"\n> & {\n\tchildren?: React.ReactNode;\n\tasChild?: boolean;\n\tclassName?: string;\n};\n\nexport interface AvatarContextValue extends AvatarState {\n\tonImageLoadingStatusChange: (\n\t\tstatus: AvatarState[\"imageLoadingStatus\"]\n\t) => void;\n}\n\nconst AvatarContext = React.createContext<AvatarContextValue | null>(null);\n\n/**\n * Consumer hook for the `Avatar` compound components. Throws when components are\n * rendered outside of the `Avatar` tree to surface integration errors early.\n */\nexport const useAvatarContext = () => {\n\tconst context = React.useContext(AvatarContext);\n\tif (!context) {\n\t\tthrow new Error(\n\t\t\t\"Avatar compound components cannot be rendered outside the Avatar component\"\n\t\t);\n\t}\n\treturn context;\n};\n\n/**\n * Root avatar wrapper that coordinates image loading state with fallback\n * children so consumers can compose initials, images and status rings.\n */\nexport const Avatar = (() => {\n\tconst Component = React.forwardRef<HTMLSpanElement, AvatarProps>(\n\t\t({ children, className, asChild = false, ...props }, ref) => {\n\t\t\tconst [imageLoadingStatus, setImageLoadingStatus] =\n\t\t\t\tReact.useState<AvatarState[\"imageLoadingStatus\"]>(\"idle\");\n\n\t\t\tconst contextValue: AvatarContextValue = React.useMemo(\n\t\t\t\t() => ({\n\t\t\t\t\timageLoadingStatus,\n\t\t\t\t\tonImageLoadingStatusChange: setImageLoadingStatus,\n\t\t\t\t}),\n\t\t\t\t[imageLoadingStatus]\n\t\t\t);\n\n\t\t\tconst state: AvatarState = {\n\t\t\t\timageLoadingStatus,\n\t\t\t};\n\n\t\t\treturn (\n\t\t\t\t<AvatarContext.Provider value={contextValue}>\n\t\t\t\t\t{useRenderElement(\n\t\t\t\t\t\t\"div\",\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tasChild,\n\t\t\t\t\t\t\tclassName,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tref,\n\t\t\t\t\t\t\tstate,\n\t\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\t\t...props,\n\t\t\t\t\t\t\t\tchildren,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t}\n\t\t\t\t\t)}\n\t\t\t\t</AvatarContext.Provider>\n\t\t\t);\n\t\t}\n\t);\n\n\tComponent.displayName = \"Avatar\";\n\treturn Component;\n})();\n"],"mappings":";;;;;AAsBA,MAAM,gBAAgBA,QAAM,cAAyC,KAAK;;;;;AAM1E,MAAa,yBAAyB;CACrC,MAAM,UAAUA,QAAM,WAAW,cAAc;AAC/C,KAAI,CAAC,QACJ,OAAM,IAAI,MACT,6EACA;AAEF,QAAO;;;;;;AAOR,MAAa,gBAAgB;CAC5B,MAAM,YAAYA,QAAM,YACtB,EAAE,UAAU,WAAW,UAAU,MAAO,GAAG,SAAS,QAAQ;EAC5D,MAAM,CAAC,oBAAoB,yBAC1BA,QAAM,SAA4C,OAAO;EAE1D,MAAMC,eAAmCD,QAAM,eACvC;GACN;GACA,4BAA4B;GAC5B,GACD,CAAC,mBAAmB,CACpB;EAED,MAAME,QAAqB,EAC1B,oBACA;AAED,SACC,oBAAC,cAAc;GAAS,OAAO;aAC7B,iBACA,OACA;IACC;IACA;IACA,EACD;IACC;IACA;IACA,OAAO;KACN,GAAG;KACH;KACA;IACD,CACD;IACuB;GAG3B;AAED,WAAU,cAAc;AACxB,QAAO;IACJ"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as React$1 from "react";
|
|
2
|
+
|
|
3
|
+
//#region src/primitives/avatar/fallback.d.ts
|
|
4
|
+
type AvatarFallbackProps = Omit<React$1.HTMLAttributes<HTMLSpanElement>, "children"> & {
|
|
5
|
+
children?: React$1.ReactNode;
|
|
6
|
+
name?: string;
|
|
7
|
+
delayMs?: number;
|
|
8
|
+
asChild?: boolean;
|
|
9
|
+
className?: string;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Displays initials or custom content while the avatar image loads or fails.
|
|
13
|
+
* Optional delay avoids flashes when images load instantly.
|
|
14
|
+
*/
|
|
15
|
+
declare const AvatarFallback: React$1.ForwardRefExoticComponent<Omit<React$1.HTMLAttributes<HTMLSpanElement>, "children"> & {
|
|
16
|
+
children?: React$1.ReactNode;
|
|
17
|
+
name?: string;
|
|
18
|
+
delayMs?: number;
|
|
19
|
+
asChild?: boolean;
|
|
20
|
+
className?: string;
|
|
21
|
+
} & React$1.RefAttributes<HTMLSpanElement>>;
|
|
22
|
+
//#endregion
|
|
23
|
+
export { AvatarFallback, AvatarFallbackProps };
|
|
24
|
+
//# sourceMappingURL=fallback.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fallback.d.ts","names":[],"sources":["../../../src/primitives/avatar/fallback.tsx"],"sourcesContent":[],"mappings":";;;KASY,mBAAA,GAAsB,KACjC,OAAA,CAAM,eAAe;aAGV,OAAA,CAAM;EAJN,IAAA,CAAA,EAAA,MAAA;EAAmB,OAAA,CAAA,EAAA,MAAA;SACT,CAAA,EAAA,OAAA;WAArB,CAAA,EAAM,MAAA;;;;AA+BP;;AAA2B,cAAd,cAAc,EAAA,OAAA,CAAA,yBAAA,CAAA,IAAA,CAAA,OAAA,CAAA,cAAA,CAAA,eAAA,CAAA,EAAA,UAAA,CAAA,GAAA;UAAA,CAAA,EA5Bf,OAAA,CAAM,SA4BS;MAAA,CAAA,EAAA,MAAA;SA5Bf,CAAA,EAAA,MAAM;;;yBA4BS,gBAAA,CAAA,CAAA"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { useRenderElement } from "../../utils/use-render-element.js";
|
|
2
|
+
import { useAvatarContext } from "./avatar.js";
|
|
3
|
+
import * as React$1 from "react";
|
|
4
|
+
|
|
5
|
+
//#region src/primitives/avatar/fallback.tsx
|
|
6
|
+
const getInitials = (name) => {
|
|
7
|
+
const names = name.trim().split(" ");
|
|
8
|
+
if (names.length === 0) return "";
|
|
9
|
+
if (names.length === 1) return names[0]?.charAt(0).toUpperCase() || "";
|
|
10
|
+
const firstInitial = names[0]?.charAt(0) || "";
|
|
11
|
+
const lastInitial = names[names.length - 1]?.charAt(0) || "";
|
|
12
|
+
return (firstInitial + lastInitial).toUpperCase();
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Displays initials or custom content while the avatar image loads or fails.
|
|
16
|
+
* Optional delay avoids flashes when images load instantly.
|
|
17
|
+
*/
|
|
18
|
+
const AvatarFallback = (() => {
|
|
19
|
+
const Component = React$1.forwardRef(({ children, name = "", delayMs = 0, className, asChild = false,...props }, ref) => {
|
|
20
|
+
const { imageLoadingStatus } = useAvatarContext();
|
|
21
|
+
const [canRender, setCanRender] = React$1.useState(delayMs === 0);
|
|
22
|
+
React$1.useEffect(() => {
|
|
23
|
+
if (delayMs > 0) {
|
|
24
|
+
const timerId = window.setTimeout(() => setCanRender(true), delayMs);
|
|
25
|
+
return () => window.clearTimeout(timerId);
|
|
26
|
+
}
|
|
27
|
+
}, [delayMs]);
|
|
28
|
+
const initials = React$1.useMemo(() => {
|
|
29
|
+
if (name) return getInitials(name);
|
|
30
|
+
return "";
|
|
31
|
+
}, [name]);
|
|
32
|
+
const state = {
|
|
33
|
+
imageLoadingStatus,
|
|
34
|
+
initials
|
|
35
|
+
};
|
|
36
|
+
const shouldRender = canRender && imageLoadingStatus !== "loaded" && imageLoadingStatus !== "loading";
|
|
37
|
+
const content = children || initials;
|
|
38
|
+
return useRenderElement("span", {
|
|
39
|
+
asChild,
|
|
40
|
+
className
|
|
41
|
+
}, {
|
|
42
|
+
ref,
|
|
43
|
+
state,
|
|
44
|
+
enabled: shouldRender,
|
|
45
|
+
props: {
|
|
46
|
+
...props,
|
|
47
|
+
children: content
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
Component.displayName = "AvatarFallback";
|
|
52
|
+
return Component;
|
|
53
|
+
})();
|
|
54
|
+
|
|
55
|
+
//#endregion
|
|
56
|
+
export { AvatarFallback };
|
|
57
|
+
//# sourceMappingURL=fallback.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fallback.js","names":["React","state: FallbackState"],"sources":["../../../src/primitives/avatar/fallback.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { useRenderElement } from \"../../utils/use-render-element\";\nimport { useAvatarContext } from \"./avatar\";\n\ntype FallbackState = {\n\timageLoadingStatus: \"idle\" | \"loading\" | \"loaded\" | \"error\";\n\tinitials?: string;\n};\n\nexport type AvatarFallbackProps = Omit<\n\tReact.HTMLAttributes<HTMLSpanElement>,\n\t\"children\"\n> & {\n\tchildren?: React.ReactNode;\n\tname?: string;\n\tdelayMs?: number;\n\tasChild?: boolean;\n\tclassName?: string;\n};\n\nconst getInitials = (name: string): string => {\n\tconst names = name.trim().split(\" \");\n\tif (names.length === 0) {\n\t\treturn \"\";\n\t}\n\n\tif (names.length === 1) {\n\t\treturn names[0]?.charAt(0).toUpperCase() || \"\";\n\t}\n\n\tconst firstInitial = names[0]?.charAt(0) || \"\";\n\t// biome-ignore lint/style/useAtIndex: ok here\n\tconst lastInitial = names[names.length - 1]?.charAt(0) || \"\";\n\n\treturn (firstInitial + lastInitial).toUpperCase();\n};\n\n/**\n * Displays initials or custom content while the avatar image loads or fails.\n * Optional delay avoids flashes when images load instantly.\n */\nexport const AvatarFallback = (() => {\n\tconst Component = React.forwardRef<HTMLSpanElement, AvatarFallbackProps>(\n\t\t(\n\t\t\t{\n\t\t\t\tchildren,\n\t\t\t\tname = \"\",\n\t\t\t\tdelayMs = 0,\n\t\t\t\tclassName,\n\t\t\t\tasChild = false,\n\t\t\t\t...props\n\t\t\t},\n\t\t\tref\n\t\t) => {\n\t\t\tconst { imageLoadingStatus } = useAvatarContext();\n\t\t\tconst [canRender, setCanRender] = React.useState(delayMs === 0);\n\n\t\t\tReact.useEffect(() => {\n\t\t\t\tif (delayMs > 0) {\n\t\t\t\t\tconst timerId = window.setTimeout(() => setCanRender(true), delayMs);\n\t\t\t\t\treturn () => window.clearTimeout(timerId);\n\t\t\t\t}\n\t\t\t}, [delayMs]);\n\n\t\t\tconst initials = React.useMemo(() => {\n\t\t\t\tif (name) {\n\t\t\t\t\treturn getInitials(name);\n\t\t\t\t}\n\t\t\t\treturn \"\";\n\t\t\t}, [name]);\n\n\t\t\tconst state: FallbackState = {\n\t\t\t\timageLoadingStatus,\n\t\t\t\tinitials,\n\t\t\t};\n\n\t\t\tconst shouldRender =\n\t\t\t\tcanRender &&\n\t\t\t\timageLoadingStatus !== \"loaded\" &&\n\t\t\t\timageLoadingStatus !== \"loading\";\n\n\t\t\tconst content = children || initials;\n\n\t\t\treturn useRenderElement(\n\t\t\t\t\"span\",\n\t\t\t\t{\n\t\t\t\t\tasChild,\n\t\t\t\t\tclassName,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tref,\n\t\t\t\t\tstate,\n\t\t\t\t\tenabled: shouldRender,\n\t\t\t\t\tprops: {\n\t\t\t\t\t\t...props,\n\t\t\t\t\t\tchildren: content,\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t);\n\n\tComponent.displayName = \"AvatarFallback\";\n\treturn Component;\n})();\n"],"mappings":";;;;;AAoBA,MAAM,eAAe,SAAyB;CAC7C,MAAM,QAAQ,KAAK,MAAM,CAAC,MAAM,IAAI;AACpC,KAAI,MAAM,WAAW,EACpB,QAAO;AAGR,KAAI,MAAM,WAAW,EACpB,QAAO,MAAM,IAAI,OAAO,EAAE,CAAC,aAAa,IAAI;CAG7C,MAAM,eAAe,MAAM,IAAI,OAAO,EAAE,IAAI;CAE5C,MAAM,cAAc,MAAM,MAAM,SAAS,IAAI,OAAO,EAAE,IAAI;AAE1D,SAAQ,eAAe,aAAa,aAAa;;;;;;AAOlD,MAAa,wBAAwB;CACpC,MAAM,YAAYA,QAAM,YAEtB,EACC,UACA,OAAO,IACP,UAAU,GACV,WACA,UAAU,MACV,GAAG,SAEJ,QACI;EACJ,MAAM,EAAE,uBAAuB,kBAAkB;EACjD,MAAM,CAAC,WAAW,gBAAgBA,QAAM,SAAS,YAAY,EAAE;AAE/D,UAAM,gBAAgB;AACrB,OAAI,UAAU,GAAG;IAChB,MAAM,UAAU,OAAO,iBAAiB,aAAa,KAAK,EAAE,QAAQ;AACpE,iBAAa,OAAO,aAAa,QAAQ;;KAExC,CAAC,QAAQ,CAAC;EAEb,MAAM,WAAWA,QAAM,cAAc;AACpC,OAAI,KACH,QAAO,YAAY,KAAK;AAEzB,UAAO;KACL,CAAC,KAAK,CAAC;EAEV,MAAMC,QAAuB;GAC5B;GACA;GACA;EAED,MAAM,eACL,aACA,uBAAuB,YACvB,uBAAuB;EAExB,MAAM,UAAU,YAAY;AAE5B,SAAO,iBACN,QACA;GACC;GACA;GACA,EACD;GACC;GACA;GACA,SAAS;GACT,OAAO;IACN,GAAG;IACH,UAAU;IACV;GACD,CACD;GAEF;AAED,WAAU,cAAc;AACxB,QAAO;IACJ"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as React$1 from "react";
|
|
2
|
+
|
|
3
|
+
//#region src/primitives/avatar/image.d.ts
|
|
4
|
+
type ImageState = {
|
|
5
|
+
imageLoadingStatus: "idle" | "loading" | "loaded" | "error";
|
|
6
|
+
};
|
|
7
|
+
type AvatarImageProps = Omit<React$1.ImgHTMLAttributes<HTMLImageElement>, "src" | "alt"> & {
|
|
8
|
+
src: string;
|
|
9
|
+
alt?: string;
|
|
10
|
+
asChild?: boolean;
|
|
11
|
+
className?: string;
|
|
12
|
+
onLoadingStatusChange?: (status: ImageState["imageLoadingStatus"]) => void;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Controlled `<img>` that syncs its loading status back to the avatar context
|
|
16
|
+
* so fallbacks know when to display.
|
|
17
|
+
*/
|
|
18
|
+
declare const AvatarImage: React$1.ForwardRefExoticComponent<Omit<React$1.ImgHTMLAttributes<HTMLImageElement>, "alt" | "src"> & {
|
|
19
|
+
src: string;
|
|
20
|
+
alt?: string;
|
|
21
|
+
asChild?: boolean;
|
|
22
|
+
className?: string;
|
|
23
|
+
onLoadingStatusChange?: (status: ImageState["imageLoadingStatus"]) => void;
|
|
24
|
+
} & React$1.RefAttributes<HTMLImageElement>>;
|
|
25
|
+
//#endregion
|
|
26
|
+
export { AvatarImage, AvatarImageProps };
|
|
27
|
+
//# sourceMappingURL=image.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image.d.ts","names":[],"sources":["../../../src/primitives/avatar/image.tsx"],"sourcesContent":[],"mappings":";;;KAIK,UAAA;;AAJ0B,CAAA;AAQnB,KAAA,gBAAA,GAAmB,IAAH,CAC3B,OAAA,CAAM,iBADqB,CACH,gBADG,CAAA,EAAA,KAAA,GAAA,KAAA,CAAA,GAAA;EAAA,GAAA,EAAA,MAAA;KACH,CAAA,EAAA,MAAA;SAAxB,CAAA,EAAA,OAAM;WADwB,CAAA,EAAA,MAAA;uBAQG,CAAA,EAAA,CAAA,MAAA,EAAA,UAAA,CAAA,oBAAA,CAAA,EAAA,GAAA,IAAA;CAAU;AAO5C;;;;AAAwB,cAAX,WAAW,EAAA,OAAA,CAAA,yBAAA,CAAA,IAAA,CAAA,OAAA,CAAA,iBAAA,CAAA,gBAAA,CAAA,EAAA,KAAA,GAAA,KAAA,CAAA,GAAA;KAPU,EAAA,MAAA;;;WAOV,CAAA,EAAA,MAAA;EAAA,qBAAA,CAAA,EAAA,CAAA,MAAA,EAPU,UAOV,CAAA,oBAAA,CAAA,EAAA,GAAA,IAAA"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { useRenderElement } from "../../utils/use-render-element.js";
|
|
2
|
+
import { useAvatarContext } from "./avatar.js";
|
|
3
|
+
import * as React$1 from "react";
|
|
4
|
+
|
|
5
|
+
//#region src/primitives/avatar/image.tsx
|
|
6
|
+
/**
|
|
7
|
+
* Controlled `<img>` that syncs its loading status back to the avatar context
|
|
8
|
+
* so fallbacks know when to display.
|
|
9
|
+
*/
|
|
10
|
+
const AvatarImage = (() => {
|
|
11
|
+
const Component = React$1.forwardRef(({ src, alt = "", className, asChild = false, onLoadingStatusChange,...props }, ref) => {
|
|
12
|
+
const { imageLoadingStatus, onImageLoadingStatusChange } = useAvatarContext();
|
|
13
|
+
const imageRef = React$1.useRef(null);
|
|
14
|
+
React$1.useImperativeHandle(ref, () => imageRef.current);
|
|
15
|
+
const updateImageLoadingStatus = React$1.useCallback((status) => {
|
|
16
|
+
onImageLoadingStatusChange(status);
|
|
17
|
+
onLoadingStatusChange?.(status);
|
|
18
|
+
}, [onImageLoadingStatusChange, onLoadingStatusChange]);
|
|
19
|
+
React$1.useLayoutEffect(() => {
|
|
20
|
+
if (!src) {
|
|
21
|
+
updateImageLoadingStatus("error");
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
let isMounted = true;
|
|
25
|
+
const image = new Image();
|
|
26
|
+
const updateStatus = (status) => {
|
|
27
|
+
if (!isMounted) return;
|
|
28
|
+
updateImageLoadingStatus(status);
|
|
29
|
+
};
|
|
30
|
+
updateStatus("loading");
|
|
31
|
+
image.onload = () => updateStatus("loaded");
|
|
32
|
+
image.onerror = () => updateStatus("error");
|
|
33
|
+
image.src = src;
|
|
34
|
+
return () => {
|
|
35
|
+
isMounted = false;
|
|
36
|
+
};
|
|
37
|
+
}, [src, updateImageLoadingStatus]);
|
|
38
|
+
return useRenderElement("img", {
|
|
39
|
+
asChild,
|
|
40
|
+
className
|
|
41
|
+
}, {
|
|
42
|
+
ref: imageRef,
|
|
43
|
+
state: { imageLoadingStatus },
|
|
44
|
+
enabled: imageLoadingStatus === "loaded",
|
|
45
|
+
props: {
|
|
46
|
+
...props,
|
|
47
|
+
src,
|
|
48
|
+
alt
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
Component.displayName = "AvatarImage";
|
|
53
|
+
return Component;
|
|
54
|
+
})();
|
|
55
|
+
|
|
56
|
+
//#endregion
|
|
57
|
+
export { AvatarImage };
|
|
58
|
+
//# sourceMappingURL=image.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image.js","names":["React"],"sources":["../../../src/primitives/avatar/image.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { useRenderElement } from \"../../utils/use-render-element\";\nimport { useAvatarContext } from \"./avatar\";\n\ntype ImageState = {\n\timageLoadingStatus: \"idle\" | \"loading\" | \"loaded\" | \"error\";\n};\n\nexport type AvatarImageProps = Omit<\n\tReact.ImgHTMLAttributes<HTMLImageElement>,\n\t\"src\" | \"alt\"\n> & {\n\tsrc: string;\n\talt?: string;\n\tasChild?: boolean;\n\tclassName?: string;\n\tonLoadingStatusChange?: (status: ImageState[\"imageLoadingStatus\"]) => void;\n};\n\n/**\n * Controlled `<img>` that syncs its loading status back to the avatar context\n * so fallbacks know when to display.\n */\nexport const AvatarImage = (() => {\n\tconst Component = React.forwardRef<HTMLImageElement, AvatarImageProps>(\n\t\t(\n\t\t\t{\n\t\t\t\tsrc,\n\t\t\t\talt = \"\",\n\t\t\t\tclassName,\n\t\t\t\tasChild = false,\n\t\t\t\tonLoadingStatusChange,\n\t\t\t\t...props\n\t\t\t},\n\t\t\tref\n\t\t) => {\n\t\t\tconst { imageLoadingStatus, onImageLoadingStatusChange } =\n\t\t\t\tuseAvatarContext();\n\n\t\t\tconst imageRef = React.useRef<HTMLImageElement>(null);\n\t\t\t// biome-ignore lint/style/noNonNullAssertion: ok\n\t\t\tReact.useImperativeHandle(ref, () => imageRef.current!);\n\n\t\t\tconst updateImageLoadingStatus = React.useCallback(\n\t\t\t\t(status: ImageState[\"imageLoadingStatus\"]) => {\n\t\t\t\t\tonImageLoadingStatusChange(status);\n\t\t\t\t\tonLoadingStatusChange?.(status);\n\t\t\t\t},\n\t\t\t\t[onImageLoadingStatusChange, onLoadingStatusChange]\n\t\t\t);\n\n\t\t\tReact.useLayoutEffect(() => {\n\t\t\t\tif (!src) {\n\t\t\t\t\tupdateImageLoadingStatus(\"error\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tlet isMounted = true;\n\t\t\t\tconst image = new Image();\n\n\t\t\t\tconst updateStatus = (status: ImageState[\"imageLoadingStatus\"]) => {\n\t\t\t\t\tif (!isMounted) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tupdateImageLoadingStatus(status);\n\t\t\t\t};\n\n\t\t\t\tupdateStatus(\"loading\");\n\n\t\t\t\timage.onload = () => updateStatus(\"loaded\");\n\t\t\t\timage.onerror = () => updateStatus(\"error\");\n\t\t\t\timage.src = src;\n\n\t\t\t\treturn () => {\n\t\t\t\t\tisMounted = false;\n\t\t\t\t};\n\t\t\t}, [src, updateImageLoadingStatus]);\n\n\t\t\tconst state: ImageState = {\n\t\t\t\timageLoadingStatus,\n\t\t\t};\n\n\t\t\treturn useRenderElement(\n\t\t\t\t\"img\",\n\t\t\t\t{\n\t\t\t\t\tasChild,\n\t\t\t\t\tclassName,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tref: imageRef,\n\t\t\t\t\tstate,\n\t\t\t\t\tenabled: imageLoadingStatus === \"loaded\",\n\t\t\t\t\tprops: {\n\t\t\t\t\t\t...props,\n\t\t\t\t\t\tsrc,\n\t\t\t\t\t\talt,\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t);\n\n\tComponent.displayName = \"AvatarImage\";\n\treturn Component;\n})();\n"],"mappings":";;;;;;;;;AAuBA,MAAa,qBAAqB;CACjC,MAAM,YAAYA,QAAM,YAEtB,EACC,KACA,MAAM,IACN,WACA,UAAU,OACV,sBACA,GAAG,SAEJ,QACI;EACJ,MAAM,EAAE,oBAAoB,+BAC3B,kBAAkB;EAEnB,MAAM,WAAWA,QAAM,OAAyB,KAAK;AAErD,UAAM,oBAAoB,WAAW,SAAS,QAAS;EAEvD,MAAM,2BAA2BA,QAAM,aACrC,WAA6C;AAC7C,8BAA2B,OAAO;AAClC,2BAAwB,OAAO;KAEhC,CAAC,4BAA4B,sBAAsB,CACnD;AAED,UAAM,sBAAsB;AAC3B,OAAI,CAAC,KAAK;AACT,6BAAyB,QAAQ;AACjC;;GAGD,IAAI,YAAY;GAChB,MAAM,QAAQ,IAAI,OAAO;GAEzB,MAAM,gBAAgB,WAA6C;AAClE,QAAI,CAAC,UACJ;AAED,6BAAyB,OAAO;;AAGjC,gBAAa,UAAU;AAEvB,SAAM,eAAe,aAAa,SAAS;AAC3C,SAAM,gBAAgB,aAAa,QAAQ;AAC3C,SAAM,MAAM;AAEZ,gBAAa;AACZ,gBAAY;;KAEX,CAAC,KAAK,yBAAyB,CAAC;AAMnC,SAAO,iBACN,OACA;GACC;GACA;GACA,EACD;GACC,KAAK;GACL,OAZwB,EACzB,oBACA;GAWC,SAAS,uBAAuB;GAChC,OAAO;IACN,GAAG;IACH;IACA;IACA;GACD,CACD;GAEF;AAED,WAAU,cAAc;AACxB,QAAO;IACJ"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Avatar, AvatarProps } from "./avatar.js";
|
|
2
|
+
import { AvatarFallback, AvatarFallbackProps } from "./fallback.js";
|
|
3
|
+
import { AvatarImage, AvatarImageProps } from "./image.js";
|
|
4
|
+
export { Avatar, AvatarFallback, AvatarFallbackProps, AvatarImage, AvatarImageProps, AvatarProps };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Avatar, AvatarProps } from "./avatar.js";
|
|
2
|
+
import { AvatarFallback, AvatarFallbackProps } from "./fallback.js";
|
|
3
|
+
import { AvatarImage, AvatarImageProps } from "./image.js";
|
|
4
|
+
export { Avatar, AvatarFallback, type AvatarFallbackProps, AvatarImage, type AvatarImageProps, type AvatarProps };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as React$1 from "react";
|
|
2
|
+
|
|
3
|
+
//#region src/primitives/bubble.d.ts
|
|
4
|
+
type SupportBubbleProps = Omit<React$1.ButtonHTMLAttributes<HTMLButtonElement>, "children"> & {
|
|
5
|
+
children?: React$1.ReactNode | ((props: {
|
|
6
|
+
isOpen: boolean;
|
|
7
|
+
unreadCount: number;
|
|
8
|
+
toggle: () => void;
|
|
9
|
+
}) => React$1.ReactNode);
|
|
10
|
+
asChild?: boolean;
|
|
11
|
+
className?: string;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Floating action button that toggles the support window. Exposes widget state
|
|
15
|
+
* and unread counts to render-prop children for fully custom UI shells.
|
|
16
|
+
*/
|
|
17
|
+
declare const SupportBubble: React$1.ForwardRefExoticComponent<Omit<React$1.ButtonHTMLAttributes<HTMLButtonElement>, "children"> & {
|
|
18
|
+
children?: React$1.ReactNode | ((props: {
|
|
19
|
+
isOpen: boolean;
|
|
20
|
+
unreadCount: number;
|
|
21
|
+
toggle: () => void;
|
|
22
|
+
}) => React$1.ReactNode);
|
|
23
|
+
asChild?: boolean;
|
|
24
|
+
className?: string;
|
|
25
|
+
} & React$1.RefAttributes<HTMLButtonElement>>;
|
|
26
|
+
//#endregion
|
|
27
|
+
export { SupportBubble, SupportBubbleProps };
|
|
28
|
+
//# sourceMappingURL=bubble.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bubble.d.ts","names":[],"sources":["../../src/primitives/bubble.tsx"],"sourcesContent":[],"mappings":";;;KAKY,kBAAA,GAAqB,KAChC,OAAA,CAAM,qBAAqB;aAIxB,OAAA,CAAM;IALE,MAAA,EAAA,OAAA;IAAkB,WAAA,EAAA,MAAA;IACF,MAAA,EAAA,GAAA,GAAA,IAAA;KAA3B,GASS,OAAA,CAAM,SATT,CAAA;SAD0B,CAAA,EAAA,OAAA;WAK7B,CAAA,EAAM,MAAA;;;AAcV;;;AAA0B,cAAb,aAAa,EAAA,OAAA,CAAA,yBAAA,CAAA,IAAA,CAAA,OAAA,CAAA,oBAAA,CAAA,iBAAA,CAAA,EAAA,UAAA,CAAA,GAAA;UAAA,CAAA,EAdtB,OAAA,CAAM,SAcgB,GAAA,CAAA,CAAA,KAAA,EAAA;IAdtB,MAAA,EAAM,OAAA;IAKA,WAAM,EAAA,MAAA;;QAAN,OAAA,CAAM;SASU,CAAA,EAAA,OAAA;EAAA,SAAA,CAAA,EAAA,MAAA"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { useRenderElement } from "../utils/use-render-element.js";
|
|
2
|
+
import { useSupportConfig } from "../support/context/config.js";
|
|
3
|
+
import { useSupport } from "../provider.js";
|
|
4
|
+
import * as React$1 from "react";
|
|
5
|
+
|
|
6
|
+
//#region src/primitives/bubble.tsx
|
|
7
|
+
/**
|
|
8
|
+
* Floating action button that toggles the support window. Exposes widget state
|
|
9
|
+
* and unread counts to render-prop children for fully custom UI shells.
|
|
10
|
+
*/
|
|
11
|
+
const SupportBubble = (() => {
|
|
12
|
+
const Component = React$1.forwardRef(({ children, className, asChild = false,...props }, ref) => {
|
|
13
|
+
const { isOpen, toggle } = useSupportConfig();
|
|
14
|
+
const { unreadCount } = useSupport();
|
|
15
|
+
const renderProps = {
|
|
16
|
+
isOpen,
|
|
17
|
+
unreadCount,
|
|
18
|
+
toggle
|
|
19
|
+
};
|
|
20
|
+
const content = typeof children === "function" ? children(renderProps) : children;
|
|
21
|
+
return useRenderElement("button", {
|
|
22
|
+
asChild,
|
|
23
|
+
className
|
|
24
|
+
}, {
|
|
25
|
+
ref,
|
|
26
|
+
state: renderProps,
|
|
27
|
+
props: {
|
|
28
|
+
type: "button",
|
|
29
|
+
"aria-haspopup": "dialog",
|
|
30
|
+
"aria-expanded": isOpen,
|
|
31
|
+
onClick: toggle,
|
|
32
|
+
...props,
|
|
33
|
+
children: content
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
Component.displayName = "SupportBubble";
|
|
38
|
+
return Component;
|
|
39
|
+
})();
|
|
40
|
+
|
|
41
|
+
//#endregion
|
|
42
|
+
export { SupportBubble };
|
|
43
|
+
//# sourceMappingURL=bubble.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bubble.js","names":["React"],"sources":["../../src/primitives/bubble.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { useSupport } from \"../provider\";\nimport { useSupportConfig } from \"../support\";\nimport { useRenderElement } from \"../utils/use-render-element\";\n\nexport type SupportBubbleProps = Omit<\n\tReact.ButtonHTMLAttributes<HTMLButtonElement>,\n\t\"children\"\n> & {\n\tchildren?:\n\t\t| React.ReactNode\n\t\t| ((props: {\n\t\t\t\tisOpen: boolean;\n\t\t\t\tunreadCount: number;\n\t\t\t\ttoggle: () => void;\n\t\t }) => React.ReactNode);\n\tasChild?: boolean;\n\tclassName?: string;\n};\n\n/**\n * Floating action button that toggles the support window. Exposes widget state\n * and unread counts to render-prop children for fully custom UI shells.\n */\nexport const SupportBubble = (() => {\n\tconst Component = React.forwardRef<HTMLButtonElement, SupportBubbleProps>(\n\t\t({ children, className, asChild = false, ...props }, ref) => {\n\t\t\tconst { isOpen, toggle } = useSupportConfig();\n\t\t\tconst { unreadCount } = useSupport();\n\n\t\t\tconst renderProps = { isOpen, unreadCount, toggle };\n\n\t\t\tconst content =\n\t\t\t\ttypeof children === \"function\" ? children(renderProps) : children;\n\n\t\t\treturn useRenderElement(\n\t\t\t\t\"button\",\n\t\t\t\t{\n\t\t\t\t\tasChild,\n\t\t\t\t\tclassName,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tref,\n\t\t\t\t\tstate: renderProps,\n\t\t\t\t\tprops: {\n\t\t\t\t\t\ttype: \"button\",\n\t\t\t\t\t\t\"aria-haspopup\": \"dialog\",\n\t\t\t\t\t\t\"aria-expanded\": isOpen,\n\t\t\t\t\t\tonClick: toggle,\n\t\t\t\t\t\t...props,\n\t\t\t\t\t\tchildren: content,\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t);\n\n\tComponent.displayName = \"SupportBubble\";\n\treturn Component;\n})();\n"],"mappings":";;;;;;;;;;AAwBA,MAAa,uBAAuB;CACnC,MAAM,YAAYA,QAAM,YACtB,EAAE,UAAU,WAAW,UAAU,MAAO,GAAG,SAAS,QAAQ;EAC5D,MAAM,EAAE,QAAQ,WAAW,kBAAkB;EAC7C,MAAM,EAAE,gBAAgB,YAAY;EAEpC,MAAM,cAAc;GAAE;GAAQ;GAAa;GAAQ;EAEnD,MAAM,UACL,OAAO,aAAa,aAAa,SAAS,YAAY,GAAG;AAE1D,SAAO,iBACN,UACA;GACC;GACA;GACA,EACD;GACC;GACA,OAAO;GACP,OAAO;IACN,MAAM;IACN,iBAAiB;IACjB,iBAAiB;IACjB,SAAS;IACT,GAAG;IACH,UAAU;IACV;GACD,CACD;GAEF;AAED,WAAU,cAAc;AACxB,QAAO;IACJ"}
|