@assistant-ui/react 0.7.91 → 0.8.0
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/dist/cloud/auiV0.js.map +1 -1
- package/dist/cloud/auiV0.mjs.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +0 -1
- package/dist/index.mjs.map +1 -1
- package/dist/internal.d.ts +0 -1
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +0 -3
- package/dist/internal.js.map +1 -1
- package/dist/internal.mjs +0 -2
- package/dist/internal.mjs.map +1 -1
- package/dist/model-context/ModelContextTypes.d.ts +11 -0
- package/dist/model-context/ModelContextTypes.d.ts.map +1 -1
- package/dist/model-context/ModelContextTypes.js.map +1 -1
- package/dist/model-context/ModelContextTypes.mjs.map +1 -1
- package/dist/model-context/makeAssistantVisible.d.ts.map +1 -1
- package/dist/model-context/makeAssistantVisible.js +4 -2
- package/dist/model-context/makeAssistantVisible.js.map +1 -1
- package/dist/model-context/makeAssistantVisible.mjs +4 -2
- package/dist/model-context/makeAssistantVisible.mjs.map +1 -1
- package/dist/primitives/contentPart/index.d.ts +0 -1
- package/dist/primitives/contentPart/index.d.ts.map +1 -1
- package/dist/primitives/contentPart/index.js +0 -3
- package/dist/primitives/contentPart/index.js.map +1 -1
- package/dist/primitives/contentPart/index.mjs +0 -2
- package/dist/primitives/contentPart/index.mjs.map +1 -1
- package/dist/primitives/index.d.ts +0 -1
- package/dist/primitives/index.d.ts.map +1 -1
- package/dist/primitives/index.js +0 -3
- package/dist/primitives/index.js.map +1 -1
- package/dist/primitives/index.mjs +0 -2
- package/dist/primitives/index.mjs.map +1 -1
- package/dist/primitives/message/MessageContent.d.ts +1 -2
- package/dist/primitives/message/MessageContent.d.ts.map +1 -1
- package/dist/primitives/message/MessageContent.js +2 -7
- package/dist/primitives/message/MessageContent.js.map +1 -1
- package/dist/primitives/message/MessageContent.mjs +2 -7
- package/dist/primitives/message/MessageContent.mjs.map +1 -1
- package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.js +1 -3
- package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.js.map +1 -1
- package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.mjs +1 -3
- package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.mjs.map +1 -1
- package/dist/runtimes/edge/converters/toCoreMessages.d.ts.map +1 -1
- package/dist/runtimes/edge/converters/toCoreMessages.js +1 -6
- package/dist/runtimes/edge/converters/toCoreMessages.js.map +1 -1
- package/dist/runtimes/edge/converters/toCoreMessages.mjs +1 -6
- package/dist/runtimes/edge/converters/toCoreMessages.mjs.map +1 -1
- package/dist/runtimes/edge/converters/toLanguageModelMessages.js.map +1 -1
- package/dist/runtimes/edge/converters/toLanguageModelMessages.mjs.map +1 -1
- package/dist/runtimes/external-store/ThreadMessageLike.d.ts +2 -2
- package/dist/runtimes/external-store/ThreadMessageLike.d.ts.map +1 -1
- package/dist/runtimes/external-store/ThreadMessageLike.js +0 -3
- package/dist/runtimes/external-store/ThreadMessageLike.js.map +1 -1
- package/dist/runtimes/external-store/ThreadMessageLike.mjs +0 -3
- package/dist/runtimes/external-store/ThreadMessageLike.mjs.map +1 -1
- package/dist/types/AssistantTypes.d.ts +3 -7
- package/dist/types/AssistantTypes.d.ts.map +1 -1
- package/dist/types/AssistantTypes.js.map +1 -1
- package/dist/types/ContentPartComponentTypes.d.ts +1 -3
- package/dist/types/ContentPartComponentTypes.d.ts.map +1 -1
- package/dist/types/ContentPartComponentTypes.js.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/package.json +1 -21
- package/src/cloud/auiV0.ts +1 -1
- package/src/index.ts +0 -1
- package/src/internal.ts +0 -1
- package/src/model-context/ModelContextTypes.ts +19 -0
- package/src/model-context/makeAssistantVisible.tsx +4 -2
- package/src/primitives/contentPart/index.ts +0 -1
- package/src/primitives/index.ts +0 -1
- package/src/primitives/message/MessageContent.tsx +0 -9
- package/src/runtimes/composer/DefaultEditComposerRuntimeCore.tsx +1 -3
- package/src/runtimes/edge/converters/toCoreMessages.ts +11 -14
- package/src/runtimes/edge/converters/toLanguageModelMessages.ts +2 -2
- package/src/runtimes/external-store/ThreadMessageLike.tsx +0 -6
- package/src/types/AssistantTypes.ts +4 -9
- package/src/types/ContentPartComponentTypes.tsx +0 -4
- package/src/types/index.ts +0 -2
- package/dist/primitives/contentPart/ContentPartDisplay.d.ts +0 -9
- package/dist/primitives/contentPart/ContentPartDisplay.d.ts.map +0 -1
- package/dist/primitives/contentPart/ContentPartDisplay.js +0 -37
- package/dist/primitives/contentPart/ContentPartDisplay.js.map +0 -1
- package/dist/primitives/contentPart/ContentPartDisplay.mjs +0 -13
- package/dist/primitives/contentPart/ContentPartDisplay.mjs.map +0 -1
- package/dist/primitives/contentPart/useContentPartDisplay.d.ts +0 -8
- package/dist/primitives/contentPart/useContentPartDisplay.d.ts.map +0 -1
- package/dist/primitives/contentPart/useContentPartDisplay.js +0 -42
- package/dist/primitives/contentPart/useContentPartDisplay.js.map +0 -1
- package/dist/primitives/contentPart/useContentPartDisplay.mjs +0 -18
- package/dist/primitives/contentPart/useContentPartDisplay.mjs.map +0 -1
- package/dist/styles/index.css +0 -1261
- package/dist/styles/index.css.map +0 -1
- package/dist/styles/modal.css +0 -143
- package/dist/styles/modal.css.map +0 -1
- package/dist/styles/tailwindcss/base-components.css +0 -69
- package/dist/styles/tailwindcss/base-components.css.json +0 -48
- package/dist/styles/tailwindcss/modal.css +0 -29
- package/dist/styles/tailwindcss/modal.css.json +0 -26
- package/dist/styles/tailwindcss/thread.css +0 -262
- package/dist/styles/tailwindcss/thread.css.json +0 -183
- package/dist/styles/themes/default.css +0 -64
- package/dist/styles/themes/default.css.json +0 -46
- package/dist/styles/themes/shadcn-extras.css +0 -4
- package/dist/styles/themes/shadcn-extras.css.json +0 -5
- package/dist/tailwindcss/index.d.ts +0 -49
- package/dist/tailwindcss/index.d.ts.map +0 -1
- package/dist/tailwindcss/index.js +0 -189
- package/dist/tailwindcss/index.js.map +0 -1
- package/dist/tailwindcss/index.mjs +0 -181
- package/dist/tailwindcss/index.mjs.map +0 -1
- package/dist/ui/assistant-action-bar.d.ts +0 -24
- package/dist/ui/assistant-action-bar.d.ts.map +0 -1
- package/dist/ui/assistant-action-bar.js +0 -193
- package/dist/ui/assistant-action-bar.js.map +0 -1
- package/dist/ui/assistant-action-bar.mjs +0 -181
- package/dist/ui/assistant-action-bar.mjs.map +0 -1
- package/dist/ui/assistant-message.d.ts +0 -13
- package/dist/ui/assistant-message.d.ts.map +0 -1
- package/dist/ui/assistant-message.js +0 -107
- package/dist/ui/assistant-message.js.map +0 -1
- package/dist/ui/assistant-message.mjs +0 -77
- package/dist/ui/assistant-message.mjs.map +0 -1
- package/dist/ui/assistant-modal.d.ts +0 -23
- package/dist/ui/assistant-modal.d.ts.map +0 -1
- package/dist/ui/assistant-modal.js +0 -126
- package/dist/ui/assistant-modal.js.map +0 -1
- package/dist/ui/assistant-modal.mjs +0 -99
- package/dist/ui/assistant-modal.mjs.map +0 -1
- package/dist/ui/attachment-ui.d.ts +0 -12
- package/dist/ui/attachment-ui.d.ts.map +0 -1
- package/dist/ui/attachment-ui.js +0 -170
- package/dist/ui/attachment-ui.js.map +0 -1
- package/dist/ui/attachment-ui.mjs +0 -160
- package/dist/ui/attachment-ui.mjs.map +0 -1
- package/dist/ui/base/CircleStopIcon.d.ts +0 -3
- package/dist/ui/base/CircleStopIcon.d.ts.map +0 -1
- package/dist/ui/base/CircleStopIcon.js +0 -45
- package/dist/ui/base/CircleStopIcon.js.map +0 -1
- package/dist/ui/base/CircleStopIcon.mjs +0 -20
- package/dist/ui/base/CircleStopIcon.mjs.map +0 -1
- package/dist/ui/base/avatar.d.ts +0 -12
- package/dist/ui/base/avatar.d.ts.map +0 -1
- package/dist/ui/base/avatar.js +0 -69
- package/dist/ui/base/avatar.js.map +0 -1
- package/dist/ui/base/avatar.mjs +0 -31
- package/dist/ui/base/avatar.mjs.map +0 -1
- package/dist/ui/base/button.d.ts +0 -16
- package/dist/ui/base/button.d.ts.map +0 -1
- package/dist/ui/base/button.js +0 -66
- package/dist/ui/base/button.js.map +0 -1
- package/dist/ui/base/button.mjs +0 -40
- package/dist/ui/base/button.mjs.map +0 -1
- package/dist/ui/base/dialog.d.ts +0 -9
- package/dist/ui/base/dialog.d.ts.map +0 -1
- package/dist/ui/base/dialog.js +0 -80
- package/dist/ui/base/dialog.js.map +0 -1
- package/dist/ui/base/dialog.mjs +0 -40
- package/dist/ui/base/dialog.mjs.map +0 -1
- package/dist/ui/base/index.d.ts +0 -6
- package/dist/ui/base/index.d.ts.map +0 -1
- package/dist/ui/base/index.js +0 -55
- package/dist/ui/base/index.js.map +0 -1
- package/dist/ui/base/index.mjs +0 -25
- package/dist/ui/base/index.mjs.map +0 -1
- package/dist/ui/base/tooltip-icon-button.d.ts +0 -17
- package/dist/ui/base/tooltip-icon-button.d.ts.map +0 -1
- package/dist/ui/base/tooltip-icon-button.js +0 -44
- package/dist/ui/base/tooltip-icon-button.js.map +0 -1
- package/dist/ui/base/tooltip-icon-button.mjs +0 -19
- package/dist/ui/base/tooltip-icon-button.mjs.map +0 -1
- package/dist/ui/base/tooltip.d.ts +0 -6
- package/dist/ui/base/tooltip.d.ts.map +0 -1
- package/dist/ui/base/tooltip.js +0 -57
- package/dist/ui/base/tooltip.js.map +0 -1
- package/dist/ui/base/tooltip.mjs +0 -20
- package/dist/ui/base/tooltip.mjs.map +0 -1
- package/dist/ui/branch-picker.d.ts +0 -15
- package/dist/ui/branch-picker.d.ts.map +0 -1
- package/dist/ui/branch-picker.js +0 -89
- package/dist/ui/branch-picker.js.map +0 -1
- package/dist/ui/branch-picker.mjs +0 -69
- package/dist/ui/branch-picker.mjs.map +0 -1
- package/dist/ui/composer.d.ts +0 -25
- package/dist/ui/composer.d.ts.map +0 -1
- package/dist/ui/composer.js +0 -168
- package/dist/ui/composer.js.map +0 -1
- package/dist/ui/composer.mjs +0 -138
- package/dist/ui/composer.mjs.map +0 -1
- package/dist/ui/content-part.d.ts +0 -7
- package/dist/ui/content-part.d.ts.map +0 -1
- package/dist/ui/content-part.js +0 -61
- package/dist/ui/content-part.js.map +0 -1
- package/dist/ui/content-part.mjs +0 -27
- package/dist/ui/content-part.mjs.map +0 -1
- package/dist/ui/edit-composer.d.ts +0 -22
- package/dist/ui/edit-composer.d.ts.map +0 -1
- package/dist/ui/edit-composer.js +0 -77
- package/dist/ui/edit-composer.js.map +0 -1
- package/dist/ui/edit-composer.mjs +0 -57
- package/dist/ui/edit-composer.mjs.map +0 -1
- package/dist/ui/index.d.ts +0 -75
- package/dist/ui/index.d.ts.map +0 -1
- package/dist/ui/index.js +0 -86
- package/dist/ui/index.js.map +0 -1
- package/dist/ui/index.mjs +0 -38
- package/dist/ui/index.mjs.map +0 -1
- package/dist/ui/thread-config.d.ts +0 -162
- package/dist/ui/thread-config.d.ts.map +0 -1
- package/dist/ui/thread-config.js +0 -63
- package/dist/ui/thread-config.js.map +0 -1
- package/dist/ui/thread-config.mjs +0 -41
- package/dist/ui/thread-config.mjs.map +0 -1
- package/dist/ui/thread-list-item.d.ts +0 -13
- package/dist/ui/thread-list-item.d.ts.map +0 -1
- package/dist/ui/thread-list-item.js +0 -94
- package/dist/ui/thread-list-item.js.map +0 -1
- package/dist/ui/thread-list-item.mjs +0 -64
- package/dist/ui/thread-list-item.mjs.map +0 -1
- package/dist/ui/thread-list.d.ts +0 -27
- package/dist/ui/thread-list.d.ts.map +0 -1
- package/dist/ui/thread-list.js +0 -91
- package/dist/ui/thread-list.js.map +0 -1
- package/dist/ui/thread-list.mjs +0 -61
- package/dist/ui/thread-list.mjs.map +0 -1
- package/dist/ui/thread-welcome.d.ts +0 -21
- package/dist/ui/thread-welcome.d.ts.map +0 -1
- package/dist/ui/thread-welcome.js +0 -101
- package/dist/ui/thread-welcome.js.map +0 -1
- package/dist/ui/thread-welcome.mjs +0 -81
- package/dist/ui/thread-welcome.mjs.map +0 -1
- package/dist/ui/thread.d.ts +0 -30
- package/dist/ui/thread.d.ts.map +0 -1
- package/dist/ui/thread.js +0 -152
- package/dist/ui/thread.js.map +0 -1
- package/dist/ui/thread.mjs +0 -125
- package/dist/ui/thread.mjs.map +0 -1
- package/dist/ui/user-action-bar.d.ts +0 -16
- package/dist/ui/user-action-bar.d.ts.map +0 -1
- package/dist/ui/user-action-bar.js +0 -63
- package/dist/ui/user-action-bar.js.map +0 -1
- package/dist/ui/user-action-bar.mjs +0 -43
- package/dist/ui/user-action-bar.mjs.map +0 -1
- package/dist/ui/user-message.d.ts +0 -13
- package/dist/ui/user-message.d.ts.map +0 -1
- package/dist/ui/user-message.js +0 -96
- package/dist/ui/user-message.js.map +0 -1
- package/dist/ui/user-message.mjs +0 -65
- package/dist/ui/user-message.mjs.map +0 -1
- package/dist/ui/utils/withDefaults.d.ts +0 -7
- package/dist/ui/utils/withDefaults.d.ts.map +0 -1
- package/dist/ui/utils/withDefaults.js +0 -66
- package/dist/ui/utils/withDefaults.js.map +0 -1
- package/dist/ui/utils/withDefaults.mjs +0 -30
- package/dist/ui/utils/withDefaults.mjs.map +0 -1
- package/src/primitives/contentPart/ContentPartDisplay.tsx +0 -20
- package/src/primitives/contentPart/useContentPartDisplay.tsx +0 -21
- package/src/styles/base.css +0 -37
- package/src/styles/index.css +0 -4
- package/src/styles/modal.css +0 -1
- package/src/styles/tailwindcss/base-components.css +0 -69
- package/src/styles/tailwindcss/modal.css +0 -29
- package/src/styles/tailwindcss/thread.css +0 -262
- package/src/styles/themes/default.css +0 -64
- package/src/styles/themes/shadcn-extras.css +0 -4
- package/src/tailwindcss/index.ts +0 -149
- package/src/ui/assistant-action-bar.tsx +0 -301
- package/src/ui/assistant-message.tsx +0 -96
- package/src/ui/assistant-modal.tsx +0 -146
- package/src/ui/attachment-ui.tsx +0 -211
- package/src/ui/base/CircleStopIcon.tsx +0 -17
- package/src/ui/base/avatar.tsx +0 -41
- package/src/ui/base/button.tsx +0 -42
- package/src/ui/base/dialog.tsx +0 -113
- package/src/ui/base/index.ts +0 -15
- package/src/ui/base/tooltip-icon-button.tsx +0 -29
- package/src/ui/base/tooltip.tsx +0 -22
- package/src/ui/branch-picker.tsx +0 -117
- package/src/ui/composer.tsx +0 -210
- package/src/ui/content-part.tsx +0 -23
- package/src/ui/edit-composer.tsx +0 -98
- package/src/ui/index.ts +0 -98
- package/src/ui/thread-config.tsx +0 -246
- package/src/ui/thread-list-item.tsx +0 -91
- package/src/ui/thread-list.tsx +0 -78
- package/src/ui/thread-welcome.tsx +0 -140
- package/src/ui/thread.tsx +0 -176
- package/src/ui/user-action-bar.tsx +0 -66
- package/src/ui/user-message.tsx +0 -92
- package/src/ui/utils/withDefaults.tsx +0 -35
- package/tailwindcss/README.md +0 -1
- package/tailwindcss/package-lock.json +0 -6
- package/tailwindcss/package.json +0 -5
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../../src/ui/assistant-modal.tsx"],"sourcesContent":["\"use client\";\n\nimport { type FC, forwardRef } from \"react\";\nimport { BotIcon, ChevronDownIcon } from \"lucide-react\";\n\nimport { AssistantModalPrimitive } from \"../primitives\";\nimport Thread from \"./thread\";\nimport { withDefaults } from \"./utils/withDefaults\";\nimport { TooltipIconButton } from \"./base/tooltip-icon-button\";\nimport {\n ThreadConfig,\n ThreadConfigProvider,\n ThreadConfigProviderProps,\n useThreadConfig,\n} from \"./thread-config\";\n\nconst AssistantModal: FC<ThreadConfig> = (config) => {\n return (\n <AssistantModalRoot config={config}>\n <AssistantModalTrigger />\n <AssistantModalContent>\n <Thread />\n </AssistantModalContent>\n </AssistantModalRoot>\n );\n};\n\nAssistantModal.displayName = \"AssistantModal\";\n\nnamespace AssistantModalRoot {\n export type Props = AssistantModalPrimitive.Root.Props &\n ThreadConfigProviderProps;\n}\n\nconst AssistantModalRoot: FC<AssistantModalRoot.Props> = ({\n config,\n ...props\n}) => {\n return (\n <ThreadConfigProvider config={config}>\n <AssistantModalPrimitive.Root {...props} />\n </ThreadConfigProvider>\n );\n};\n\nAssistantModalRoot.displayName = \"AssistantModalRoot\";\n\nnamespace AssistantModalTrigger {\n export type Element = HTMLButtonElement;\n export type Props = Partial<TooltipIconButton.Props>;\n}\n\nconst AssistantModalTrigger = forwardRef<\n AssistantModalTrigger.Element,\n AssistantModalTrigger.Props\n>((props, ref) => {\n return (\n <AssistantModalAnchor>\n <AssistantModalPrimitive.Trigger asChild>\n <AssistantModalButton {...props} ref={ref} />\n </AssistantModalPrimitive.Trigger>\n </AssistantModalAnchor>\n );\n});\n\nAssistantModalTrigger.displayName = \"AssistantModalTrigger\";\n\nconst AssistantModalAnchor = withDefaults(AssistantModalPrimitive.Anchor, {\n className: \"aui-root aui-modal-anchor\",\n});\n\nAssistantModalAnchor.displayName = \"AssistantModalAnchor\";\n\nconst ModalButtonStyled = withDefaults(TooltipIconButton, {\n variant: \"default\",\n className: \"aui-modal-button\",\n});\n\nnamespace AssistantModalButton {\n export type Element = HTMLButtonElement;\n export type Props = Partial<TooltipIconButton.Props> & {\n \"data-state\"?: \"open\" | \"closed\";\n };\n}\n\nconst AssistantModalButton = forwardRef<\n AssistantModalButton.Element,\n AssistantModalButton.Props\n>(({ \"data-state\": state, ...rest }, ref) => {\n const {\n strings: {\n assistantModal: {\n open: {\n button: { tooltip: openTooltip = \"Close Assistant\" } = {},\n } = {},\n closed: {\n button: { tooltip: closedTooltip = \"Open Assistant\" } = {},\n } = {},\n } = {},\n } = {},\n } = useThreadConfig();\n const tooltip = state === \"open\" ? openTooltip : closedTooltip;\n\n return (\n <ModalButtonStyled\n side=\"left\"\n tooltip={tooltip}\n data-state={state}\n {...rest}\n ref={ref}\n >\n {rest.children ?? (\n <>\n <BotIcon\n data-state={state}\n className=\"aui-modal-button-closed-icon\"\n />\n <ChevronDownIcon\n data-state={state}\n className=\"aui-modal-button-open-icon\"\n />\n </>\n )}\n </ModalButtonStyled>\n );\n});\n\nAssistantModalButton.displayName = \"AssistantModalButton\";\n\nconst AssistantModalContent = withDefaults(AssistantModalPrimitive.Content, {\n className: \"aui-root aui-modal-content\",\n sideOffset: 16,\n});\n\nAssistantModalContent.displayName = \"AssistantModalContent\";\n\nconst exports = {\n Root: AssistantModalRoot,\n Trigger: AssistantModalTrigger,\n Content: AssistantModalContent,\n Button: AssistantModalButton,\n Anchor: AssistantModalAnchor,\n};\n\nexport default Object.assign(AssistantModal, exports) as typeof AssistantModal &\n typeof exports;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAAoC;AACpC,0BAAyC;AAEzC,wBAAwC;AACxC,oBAAmB;AACnB,0BAA6B;AAC7B,iCAAkC;AAClC,2BAKO;AAIH;AAFJ,IAAM,iBAAmC,CAAC,WAAW;AACnD,SACE,6CAAC,sBAAmB,QAClB;AAAA,gDAAC,yBAAsB;AAAA,IACvB,4CAAC,yBACC,sDAAC,cAAAA,SAAA,EAAO,GACV;AAAA,KACF;AAEJ;AAEA,eAAe,cAAc;AAO7B,IAAM,qBAAmD,CAAC;AAAA,EACxD;AAAA,EACA,GAAG;AACL,MAAM;AACJ,SACE,4CAAC,6CAAqB,QACpB,sDAAC,0CAAwB,MAAxB,EAA8B,GAAG,OAAO,GAC3C;AAEJ;AAEA,mBAAmB,cAAc;AAOjC,IAAM,4BAAwB,yBAG5B,CAAC,OAAO,QAAQ;AAChB,SACE,4CAAC,wBACC,sDAAC,0CAAwB,SAAxB,EAAgC,SAAO,MACtC,sDAAC,wBAAsB,GAAG,OAAO,KAAU,GAC7C,GACF;AAEJ,CAAC;AAED,sBAAsB,cAAc;AAEpC,IAAM,2BAAuB,kCAAa,0CAAwB,QAAQ;AAAA,EACxE,WAAW;AACb,CAAC;AAED,qBAAqB,cAAc;AA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.tsx
|
4
|
-
import { forwardRef } from "react";
|
5
|
-
import { BotIcon, ChevronDownIcon } from "lucide-react";
|
6
|
-
import { AssistantModalPrimitive } from "../primitives/index.mjs";
|
7
|
-
import Thread from "./thread.mjs";
|
8
|
-
import { withDefaults } from "./utils/withDefaults.mjs";
|
9
|
-
import { TooltipIconButton } from "./base/tooltip-icon-button.mjs";
|
10
|
-
import {
|
11
|
-
ThreadConfigProvider,
|
12
|
-
useThreadConfig
|
13
|
-
} from "./thread-config.mjs";
|
14
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
15
|
-
var AssistantModal = (config) => {
|
16
|
-
return /* @__PURE__ */ jsxs(AssistantModalRoot, { config, children: [
|
17
|
-
/* @__PURE__ */ jsx(AssistantModalTrigger, {}),
|
18
|
-
/* @__PURE__ */ jsx(AssistantModalContent, { children: /* @__PURE__ */ jsx(Thread, {}) })
|
19
|
-
] });
|
20
|
-
};
|
21
|
-
AssistantModal.displayName = "AssistantModal";
|
22
|
-
var AssistantModalRoot = ({
|
23
|
-
config,
|
24
|
-
...props
|
25
|
-
}) => {
|
26
|
-
return /* @__PURE__ */ jsx(ThreadConfigProvider, { config, children: /* @__PURE__ */ jsx(AssistantModalPrimitive.Root, { ...props }) });
|
27
|
-
};
|
28
|
-
AssistantModalRoot.displayName = "AssistantModalRoot";
|
29
|
-
var AssistantModalTrigger = forwardRef((props, ref) => {
|
30
|
-
return /* @__PURE__ */ jsx(AssistantModalAnchor, { children: /* @__PURE__ */ jsx(AssistantModalPrimitive.Trigger, { asChild: true, children: /* @__PURE__ */ jsx(AssistantModalButton, { ...props, ref }) }) });
|
31
|
-
});
|
32
|
-
AssistantModalTrigger.displayName = "AssistantModalTrigger";
|
33
|
-
var AssistantModalAnchor = withDefaults(AssistantModalPrimitive.Anchor, {
|
34
|
-
className: "aui-root aui-modal-anchor"
|
35
|
-
});
|
36
|
-
AssistantModalAnchor.displayName = "AssistantModalAnchor";
|
37
|
-
var ModalButtonStyled = withDefaults(TooltipIconButton, {
|
38
|
-
variant: "default",
|
39
|
-
className: "aui-modal-button"
|
40
|
-
});
|
41
|
-
var AssistantModalButton = forwardRef(({ "data-state": state, ...rest }, ref) => {
|
42
|
-
const {
|
43
|
-
strings: {
|
44
|
-
assistantModal: {
|
45
|
-
open: {
|
46
|
-
button: { tooltip: openTooltip = "Close Assistant" } = {}
|
47
|
-
} = {},
|
48
|
-
closed: {
|
49
|
-
button: { tooltip: closedTooltip = "Open Assistant" } = {}
|
50
|
-
} = {}
|
51
|
-
} = {}
|
52
|
-
} = {}
|
53
|
-
} = useThreadConfig();
|
54
|
-
const tooltip = state === "open" ? openTooltip : closedTooltip;
|
55
|
-
return /* @__PURE__ */ jsx(
|
56
|
-
ModalButtonStyled,
|
57
|
-
{
|
58
|
-
side: "left",
|
59
|
-
tooltip,
|
60
|
-
"data-state": state,
|
61
|
-
...rest,
|
62
|
-
ref,
|
63
|
-
children: rest.children ?? /* @__PURE__ */ jsxs(Fragment, { children: [
|
64
|
-
/* @__PURE__ */ jsx(
|
65
|
-
BotIcon,
|
66
|
-
{
|
67
|
-
"data-state": state,
|
68
|
-
className: "aui-modal-button-closed-icon"
|
69
|
-
}
|
70
|
-
),
|
71
|
-
/* @__PURE__ */ jsx(
|
72
|
-
ChevronDownIcon,
|
73
|
-
{
|
74
|
-
"data-state": state,
|
75
|
-
className: "aui-modal-button-open-icon"
|
76
|
-
}
|
77
|
-
)
|
78
|
-
] })
|
79
|
-
}
|
80
|
-
);
|
81
|
-
});
|
82
|
-
AssistantModalButton.displayName = "AssistantModalButton";
|
83
|
-
var AssistantModalContent = withDefaults(AssistantModalPrimitive.Content, {
|
84
|
-
className: "aui-root aui-modal-content",
|
85
|
-
sideOffset: 16
|
86
|
-
});
|
87
|
-
AssistantModalContent.displayName = "AssistantModalContent";
|
88
|
-
var exports = {
|
89
|
-
Root: AssistantModalRoot,
|
90
|
-
Trigger: AssistantModalTrigger,
|
91
|
-
Content: AssistantModalContent,
|
92
|
-
Button: AssistantModalButton,
|
93
|
-
Anchor: AssistantModalAnchor
|
94
|
-
};
|
95
|
-
var assistant_modal_default = Object.assign(AssistantModal, exports);
|
96
|
-
export {
|
97
|
-
assistant_modal_default as default
|
98
|
-
};
|
99
|
-
//# sourceMappingURL=assistant-modal.mjs.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../../src/ui/assistant-modal.tsx"],"sourcesContent":["\"use client\";\n\nimport { type FC, forwardRef } from \"react\";\nimport { BotIcon, ChevronDownIcon } from \"lucide-react\";\n\nimport { AssistantModalPrimitive } from \"../primitives\";\nimport Thread from \"./thread\";\nimport { withDefaults } from \"./utils/withDefaults\";\nimport { TooltipIconButton } from \"./base/tooltip-icon-button\";\nimport {\n ThreadConfig,\n ThreadConfigProvider,\n ThreadConfigProviderProps,\n useThreadConfig,\n} from \"./thread-config\";\n\nconst AssistantModal: FC<ThreadConfig> = (config) => {\n return (\n <AssistantModalRoot config={config}>\n <AssistantModalTrigger />\n <AssistantModalContent>\n <Thread />\n </AssistantModalContent>\n </AssistantModalRoot>\n );\n};\n\nAssistantModal.displayName = \"AssistantModal\";\n\nnamespace AssistantModalRoot {\n export type Props = AssistantModalPrimitive.Root.Props &\n ThreadConfigProviderProps;\n}\n\nconst AssistantModalRoot: FC<AssistantModalRoot.Props> = ({\n config,\n ...props\n}) => {\n return (\n <ThreadConfigProvider config={config}>\n <AssistantModalPrimitive.Root {...props} />\n </ThreadConfigProvider>\n );\n};\n\nAssistantModalRoot.displayName = \"AssistantModalRoot\";\n\nnamespace AssistantModalTrigger {\n export type Element = HTMLButtonElement;\n export type Props = Partial<TooltipIconButton.Props>;\n}\n\nconst AssistantModalTrigger = forwardRef<\n AssistantModalTrigger.Element,\n AssistantModalTrigger.Props\n>((props, ref) => {\n return (\n <AssistantModalAnchor>\n <AssistantModalPrimitive.Trigger asChild>\n <AssistantModalButton {...props} ref={ref} />\n </AssistantModalPrimitive.Trigger>\n </AssistantModalAnchor>\n );\n});\n\nAssistantModalTrigger.displayName = \"AssistantModalTrigger\";\n\nconst AssistantModalAnchor = withDefaults(AssistantModalPrimitive.Anchor, {\n className: \"aui-root aui-modal-anchor\",\n});\n\nAssistantModalAnchor.displayName = \"AssistantModalAnchor\";\n\nconst ModalButtonStyled = withDefaults(TooltipIconButton, {\n variant: \"default\",\n className: \"aui-modal-button\",\n});\n\nnamespace AssistantModalButton {\n export type Element = HTMLButtonElement;\n export type Props = Partial<TooltipIconButton.Props> & {\n \"data-state\"?: \"open\" | \"closed\";\n };\n}\n\nconst AssistantModalButton = forwardRef<\n AssistantModalButton.Element,\n AssistantModalButton.Props\n>(({ \"data-state\": state, ...rest }, ref) => {\n const {\n strings: {\n assistantModal: {\n open: {\n button: { tooltip: openTooltip = \"Close Assistant\" } = {},\n } = {},\n closed: {\n button: { tooltip: closedTooltip = \"Open Assistant\" } = {},\n } = {},\n } = {},\n } = {},\n } = useThreadConfig();\n const tooltip = state === \"open\" ? openTooltip : closedTooltip;\n\n return (\n <ModalButtonStyled\n side=\"left\"\n tooltip={tooltip}\n data-state={state}\n {...rest}\n ref={ref}\n >\n {rest.children ?? (\n <>\n <BotIcon\n data-state={state}\n className=\"aui-modal-button-closed-icon\"\n />\n <ChevronDownIcon\n data-state={state}\n className=\"aui-modal-button-open-icon\"\n />\n </>\n )}\n </ModalButtonStyled>\n );\n});\n\nAssistantModalButton.displayName = \"AssistantModalButton\";\n\nconst AssistantModalContent = withDefaults(AssistantModalPrimitive.Content, {\n className: \"aui-root aui-modal-content\",\n sideOffset: 16,\n});\n\nAssistantModalContent.displayName = \"AssistantModalContent\";\n\nconst exports = {\n Root: AssistantModalRoot,\n Trigger: AssistantModalTrigger,\n Content: AssistantModalContent,\n Button: AssistantModalButton,\n Anchor: AssistantModalAnchor,\n};\n\nexport default Object.assign(AssistantModal, exports) as typeof AssistantModal &\n typeof exports;\n"],"mappings":";;;AAEA,SAAkB,kBAAkB;AACpC,SAAS,SAAS,uBAAuB;AAEzC,SAAS,+BAA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BAAgB;AACpB,QAAM,UAAU,UAAU,SAAS,cAAc;AAEjD,SACE;AAAA,IAAC;AAAA;AAAA,MACC,MAAK;AAAA,MACL;AAAA,MACA,cAAY;AAAA,MACX,GAAG;AAAA,MACJ;AAAA,MAEC,eAAK,YACJ,iCACE;AAAA;AAAA,UAAC;AAAA;AAAA,YACC,cAAY;AAAA,YACZ,WAAU;AAAA;AAAA,QACZ;AAAA,QACA;AAAA,UAAC;AAAA;AAAA,YACC,cAAY;AAAA,YACZ,WAAU;AAAA;AAAA,QACZ;AAAA,SACF;AAAA;AAAA,EAEJ;AAEJ,CAAC;AAED,qBAAqB,cAAc;AAEnC,IAAM,wBAAwB,aAAa,wBAAwB,SAAS;AAAA,EAC1E,WAAW;AAAA,EACX,YAAY;AACd,CAAC;AAED,sBAAsB,cAAc;AAEpC,IAAM,UAAU;AAAA,EACd,MAAM;AAAA,EACN,SAAS;AAAA,EACT,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,QAAQ;AACV;AAEA,IAAO,0BAAQ,OAAO,OAAO,gBAAgB,OAAO;","names":[]}
|
@@ -1,12 +0,0 @@
|
|
1
|
-
import { type FC } from "react";
|
2
|
-
import { TooltipIconButton } from "./base/tooltip-icon-button";
|
3
|
-
declare const AttachmentUI: FC;
|
4
|
-
declare const exports: {
|
5
|
-
Root: import("react").ForwardRefExoticComponent<Partial<Omit<Omit<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
|
6
|
-
asChild?: boolean;
|
7
|
-
}, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref">> & import("react").RefAttributes<HTMLDivElement>>;
|
8
|
-
Remove: import("react").ForwardRefExoticComponent<Partial<TooltipIconButton.Props> & import("react").RefAttributes<HTMLButtonElement>>;
|
9
|
-
};
|
10
|
-
declare const _default: typeof AttachmentUI & typeof exports;
|
11
|
-
export default _default;
|
12
|
-
//# sourceMappingURL=attachment-ui.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"attachment-ui.d.ts","sourceRoot":"","sources":["../../src/ui/attachment-ui.tsx"],"names":[],"mappings":"AAEA,OAAO,EAKL,KAAK,EAAE,EACR,MAAM,OAAO,CAAC;AAIf,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAqH/D,QAAA,MAAM,YAAY,EAAE,EAuCnB,CAAC;AAoCF,QAAA,MAAM,OAAO;;;;;CAGZ,CAAC;wBAEqD,OAAO,YAAY,GACxE,OAAO,OAAO;AADhB,wBACiB"}
|
package/dist/ui/attachment-ui.js
DELETED
@@ -1,170 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
"use client";
|
3
|
-
var __defProp = Object.defineProperty;
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
7
|
-
var __export = (target, all) => {
|
8
|
-
for (var name in all)
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
10
|
-
};
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
13
|
-
for (let key of __getOwnPropNames(from))
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
16
|
-
}
|
17
|
-
return to;
|
18
|
-
};
|
19
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
20
|
-
|
21
|
-
// src/ui/attachment-ui.tsx
|
22
|
-
var attachment_ui_exports = {};
|
23
|
-
__export(attachment_ui_exports, {
|
24
|
-
default: () => attachment_ui_default
|
25
|
-
});
|
26
|
-
module.exports = __toCommonJS(attachment_ui_exports);
|
27
|
-
var import_react = require("react");
|
28
|
-
var import_lucide_react = require("lucide-react");
|
29
|
-
var import_withDefaults = require("./utils/withDefaults.js");
|
30
|
-
var import_thread_config = require("./thread-config.js");
|
31
|
-
var import_tooltip_icon_button = require("./base/tooltip-icon-button.js");
|
32
|
-
var import_primitives = require("../primitives/index.js");
|
33
|
-
var import_AttachmentContext = require("../context/react/AttachmentContext.js");
|
34
|
-
var import_base = require("./base/index.js");
|
35
|
-
var import_dialog = require("./base/dialog.js");
|
36
|
-
var import_react_avatar = require("@radix-ui/react-avatar");
|
37
|
-
var import_shallow = require("zustand/shallow");
|
38
|
-
var import_react_dialog = require("@radix-ui/react-dialog");
|
39
|
-
var import_jsx_runtime = (
|
40
|
-
// eslint-disable-next-line @next/next/no-img-element
|
41
|
-
require("react/jsx-runtime")
|
42
|
-
);
|
43
|
-
var AttachmentRoot = (0, import_withDefaults.withDefaults)(import_primitives.AttachmentPrimitive.Root, {
|
44
|
-
className: "aui-attachment-root"
|
45
|
-
});
|
46
|
-
var AttachmentContent = (0, import_withDefaults.withDefaults)("div", {
|
47
|
-
className: "aui-attachment-content"
|
48
|
-
});
|
49
|
-
AttachmentRoot.displayName = "AttachmentRoot";
|
50
|
-
var useFileSrc = (file) => {
|
51
|
-
const [src, setSrc] = (0, import_react.useState)(void 0);
|
52
|
-
(0, import_react.useEffect)(() => {
|
53
|
-
if (!file) {
|
54
|
-
setSrc(void 0);
|
55
|
-
return;
|
56
|
-
}
|
57
|
-
const objectUrl = URL.createObjectURL(file);
|
58
|
-
setSrc(objectUrl);
|
59
|
-
return () => {
|
60
|
-
URL.revokeObjectURL(objectUrl);
|
61
|
-
};
|
62
|
-
}, [file]);
|
63
|
-
return src;
|
64
|
-
};
|
65
|
-
var useAttachmentSrc = () => {
|
66
|
-
const { file, src } = (0, import_AttachmentContext.useAttachment)(
|
67
|
-
(0, import_shallow.useShallow)((a) => {
|
68
|
-
if (a.type !== "image") return {};
|
69
|
-
if (a.file) return { file: a.file };
|
70
|
-
const src2 = a.content?.filter((c) => c.type === "image")[0]?.image;
|
71
|
-
if (!src2) return {};
|
72
|
-
return { src: src2 };
|
73
|
-
})
|
74
|
-
);
|
75
|
-
return useFileSrc(file) ?? src;
|
76
|
-
};
|
77
|
-
var AttachmentPreview = ({ src }) => {
|
78
|
-
const [isLoaded, setIsLoaded] = (0, import_react.useState)(false);
|
79
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
80
|
-
"img",
|
81
|
-
{
|
82
|
-
src,
|
83
|
-
style: {
|
84
|
-
width: "auto",
|
85
|
-
height: "auto",
|
86
|
-
maxWidth: "75dvh",
|
87
|
-
maxHeight: "75dvh",
|
88
|
-
display: isLoaded ? "block" : "none",
|
89
|
-
overflow: "clip"
|
90
|
-
},
|
91
|
-
onLoad: () => setIsLoaded(true),
|
92
|
-
alt: "Image Preview"
|
93
|
-
}
|
94
|
-
);
|
95
|
-
};
|
96
|
-
var AttachmentPreviewDialog = ({ children }) => {
|
97
|
-
const src = useAttachmentSrc();
|
98
|
-
if (!src) return children;
|
99
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_dialog.Dialog, { children: [
|
100
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dialog.DialogTrigger, { className: "aui-attachment-preview-trigger", asChild: true, children }),
|
101
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_dialog.DialogContent, { children: [
|
102
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_dialog.DialogTitle, { className: "aui-sr-only", children: "Image Attachment Preview" }),
|
103
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(AttachmentPreview, { src })
|
104
|
-
] })
|
105
|
-
] });
|
106
|
-
};
|
107
|
-
var AttachmentThumb = () => {
|
108
|
-
const isImage = (0, import_AttachmentContext.useAttachment)((a) => a.type === "image");
|
109
|
-
const src = useAttachmentSrc();
|
110
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_base.AvatarRoot, { className: "aui-attachment-thumb", children: [
|
111
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_avatar.AvatarFallback, { delayMs: isImage ? 200 : 0, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.FileIcon, {}) }),
|
112
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_base.AvatarImage, { src })
|
113
|
-
] });
|
114
|
-
};
|
115
|
-
var AttachmentUI = () => {
|
116
|
-
const canRemove = (0, import_AttachmentContext.useAttachment)((a) => a.source !== "message");
|
117
|
-
const typeLabel = (0, import_AttachmentContext.useAttachment)((a) => {
|
118
|
-
const type = a.type;
|
119
|
-
switch (type) {
|
120
|
-
case "image":
|
121
|
-
return "Image";
|
122
|
-
case "document":
|
123
|
-
return "Document";
|
124
|
-
case "file":
|
125
|
-
return "File";
|
126
|
-
default:
|
127
|
-
const _exhaustiveCheck = type;
|
128
|
-
throw new Error(`Unknown attachment type: ${_exhaustiveCheck}`);
|
129
|
-
}
|
130
|
-
});
|
131
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_base.Tooltip, { children: [
|
132
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(AttachmentRoot, { children: [
|
133
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(AttachmentPreviewDialog, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_base.TooltipTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(AttachmentContent, { children: [
|
134
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(AttachmentThumb, {}),
|
135
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "aui-attachment-text", children: [
|
136
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "aui-attachment-name", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_primitives.AttachmentPrimitive.Name, {}) }),
|
137
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "aui-attachment-type", children: typeLabel })
|
138
|
-
] })
|
139
|
-
] }) }) }),
|
140
|
-
canRemove && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AttachmentRemove, {})
|
141
|
-
] }),
|
142
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_base.TooltipContent, { side: "top", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_primitives.AttachmentPrimitive.Name, {}) })
|
143
|
-
] });
|
144
|
-
};
|
145
|
-
AttachmentUI.displayName = "Attachment";
|
146
|
-
var AttachmentRemove = (0, import_react.forwardRef)((props, ref) => {
|
147
|
-
const {
|
148
|
-
strings: {
|
149
|
-
composer: { removeAttachment: { tooltip = "Remove file" } = {} } = {}
|
150
|
-
} = {}
|
151
|
-
} = (0, import_thread_config.useThreadConfig)();
|
152
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_primitives.AttachmentPrimitive.Remove, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
153
|
-
import_tooltip_icon_button.TooltipIconButton,
|
154
|
-
{
|
155
|
-
tooltip,
|
156
|
-
className: "aui-attachment-remove",
|
157
|
-
side: "top",
|
158
|
-
...props,
|
159
|
-
ref,
|
160
|
-
children: props.children ?? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.CircleXIcon, {})
|
161
|
-
}
|
162
|
-
) });
|
163
|
-
});
|
164
|
-
AttachmentRemove.displayName = "AttachmentRemove";
|
165
|
-
var exports2 = {
|
166
|
-
Root: AttachmentRoot,
|
167
|
-
Remove: AttachmentRemove
|
168
|
-
};
|
169
|
-
var attachment_ui_default = Object.assign(AttachmentUI, exports2);
|
170
|
-
//# sourceMappingURL=attachment-ui.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../../src/ui/attachment-ui.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n forwardRef,\n PropsWithChildren,\n useEffect,\n useState,\n type FC,\n} from \"react\";\nimport { CircleXIcon, FileIcon } from \"lucide-react\";\nimport { withDefaults } from \"./utils/withDefaults\";\nimport { useThreadConfig } from \"./thread-config\";\nimport { TooltipIconButton } from \"./base/tooltip-icon-button\";\nimport { AttachmentPrimitive } from \"../primitives\";\nimport { useAttachment } from \"../context/react/AttachmentContext\";\nimport {\n AvatarImage,\n AvatarRoot,\n Tooltip,\n TooltipContent,\n TooltipTrigger,\n} from \"./base\";\nimport { Dialog, DialogTrigger, DialogContent } from \"./base/dialog\";\nimport { AvatarFallback } from \"@radix-ui/react-avatar\";\nimport { useShallow } from \"zustand/shallow\";\nimport { DialogTitle } from \"@radix-ui/react-dialog\";\n\nconst AttachmentRoot = withDefaults(AttachmentPrimitive.Root, {\n className: \"aui-attachment-root\",\n});\n\nconst AttachmentContent = withDefaults(\"div\", {\n className: \"aui-attachment-content\",\n});\n\nAttachmentRoot.displayName = \"AttachmentRoot\";\n\nconst useFileSrc = (file: File | undefined) => {\n const [src, setSrc] = useState<string | undefined>(undefined);\n\n useEffect(() => {\n if (!file) {\n setSrc(undefined);\n return;\n }\n\n const objectUrl = URL.createObjectURL(file);\n setSrc(objectUrl);\n\n return () => {\n URL.revokeObjectURL(objectUrl);\n };\n }, [file]);\n\n return src;\n};\n\nconst useAttachmentSrc = () => {\n const { file, src } = useAttachment(\n useShallow((a): { file?: File; src?: string } => {\n if (a.type !== \"image\") return {};\n if (a.file) return { file: a.file };\n const src = a.content?.filter((c) => c.type === \"image\")[0]?.image;\n if (!src) return {};\n return { src };\n }),\n );\n\n return useFileSrc(file) ?? src;\n};\n\ntype AttachmentPreviewProps = {\n src: string;\n};\n\nconst AttachmentPreview: FC<AttachmentPreviewProps> = ({ src }) => {\n const [isLoaded, setIsLoaded] = useState(false);\n\n return (\n // eslint-disable-next-line @next/next/no-img-element\n <img\n src={src}\n style={{\n width: \"auto\",\n height: \"auto\",\n maxWidth: \"75dvh\",\n maxHeight: \"75dvh\",\n display: isLoaded ? \"block\" : \"none\",\n overflow: \"clip\",\n }}\n onLoad={() => setIsLoaded(true)}\n alt=\"Image Preview\"\n />\n );\n};\n\nconst AttachmentPreviewDialog: FC<PropsWithChildren> = ({ children }) => {\n const src = useAttachmentSrc();\n\n if (!src) return children;\n\n return (\n <Dialog>\n <DialogTrigger className=\"aui-attachment-preview-trigger\" asChild>\n {children}\n </DialogTrigger>\n <DialogContent>\n <DialogTitle className=\"aui-sr-only\">\n Image Attachment Preview\n </DialogTitle>\n <AttachmentPreview src={src} />\n </DialogContent>\n </Dialog>\n );\n};\n\nconst AttachmentThumb: FC = () => {\n const isImage = useAttachment((a) => a.type === \"image\");\n const src = useAttachmentSrc();\n return (\n <AvatarRoot className=\"aui-attachment-thumb\">\n <AvatarFallback delayMs={isImage ? 200 : 0}>\n <FileIcon />\n </AvatarFallback>\n <AvatarImage src={src}></AvatarImage>\n </AvatarRoot>\n );\n};\n\nconst AttachmentUI: FC = () => {\n const canRemove = useAttachment((a) => a.source !== \"message\");\n const typeLabel = useAttachment((a) => {\n const type = a.type;\n switch (type) {\n case \"image\":\n return \"Image\";\n case \"document\":\n return \"Document\";\n case \"file\":\n return \"File\";\n default:\n const _exhaustiveCheck: never = type;\n throw new Error(`Unknown attachment type: ${_exhaustiveCheck}`);\n }\n });\n return (\n <Tooltip>\n <AttachmentRoot>\n <AttachmentPreviewDialog>\n <TooltipTrigger asChild>\n <AttachmentContent>\n <AttachmentThumb />\n <div className=\"aui-attachment-text\">\n <p className=\"aui-attachment-name\">\n <AttachmentPrimitive.Name />\n </p>\n <p className=\"aui-attachment-type\">{typeLabel}</p>\n </div>\n </AttachmentContent>\n </TooltipTrigger>\n </AttachmentPreviewDialog>\n {canRemove && <AttachmentRemove />}\n </AttachmentRoot>\n <TooltipContent side=\"top\">\n <AttachmentPrimitive.Name />\n </TooltipContent>\n </Tooltip>\n );\n};\n\nAttachmentUI.displayName = \"Attachment\";\n\nnamespace AttachmentRemove {\n export type Element = HTMLButtonElement;\n export type Props = Partial<TooltipIconButton.Props>;\n}\n\nconst AttachmentRemove = forwardRef<\n AttachmentRemove.Element,\n AttachmentRemove.Props\n>((props, ref) => {\n const {\n strings: {\n composer: { removeAttachment: { tooltip = \"Remove file\" } = {} } = {},\n } = {},\n } = useThreadConfig();\n\n return (\n <AttachmentPrimitive.Remove asChild>\n <TooltipIconButton\n tooltip={tooltip}\n className=\"aui-attachment-remove\"\n side=\"top\"\n {...props}\n ref={ref}\n >\n {props.children ?? <CircleXIcon />}\n </TooltipIconButton>\n </AttachmentPrimitive.Remove>\n );\n});\n\nAttachmentRemove.displayName = \"AttachmentRemove\";\n\nconst exports = {\n Root: AttachmentRoot,\n Remove: AttachmentRemove,\n};\n\nexport default Object.assign(AttachmentUI, exports) as typeof AttachmentUI &\n typeof exports;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAMO;AACP,0BAAsC;AACtC,0BAA6B;AAC7B,2BAAgC;AAChC,iCAAkC;AAClC,wBAAoC;AACpC,+BAA8B;AAC9B,kBAMO;AACP,oBAAqD;AACrD,0BAA+B;AAC/B,qBAA2B;AAC3B,0BAA4B;AAuDxB;AAAA;AAAA;AAAA;AArDJ,IAAM,qBAAiB,kCAAa,sCAAoB,MAAM;AAAA,EAC5D,WAAW;AACb,CAAC;AAED,IAAM,wBAAoB,kCAAa,OAAO;AAAA,EAC5C,WAAW;AACb,CAAC;AAED,eAAe,cAAc;AAE7B,IAAM,aAAa,CAAC,SAA2B;AAC7C,QAAM,CAAC,KAAK,MAAM,QAAI,uBAA6B,MAAS;AAE5D,8BAAU,MAAM;AACd,QAAI,CAAC,MAAM;AACT,aAAO,MAAS;AAChB;AAAA,IACF;AAEA,UAAM,YAAY,IAAI,gBAAgB,IAAI;AAC1C,WAAO,SAAS;AAEhB,WAAO,MAAM;AACX,UAAI,gBAAgB,SAAS;AAAA,IAC/B;AAAA,EACF,GAAG,CAAC,IAAI,CAAC;AAET,SAAO;AACT;AAEA,IAAM,mBAAmB,MAAM;AAC7B,QAAM,EAAE,MAAM,IAAI,QAAI;AAAA,QACpB,2BA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C,mCAAY;AAAA;AAAA,EAClC,GACF;AAEJ,CAAC;AAED,iBAAiB,cAAc;AAE/B,IAAMC,WAAU;AAAA,EACd,MAAM;AAAA,EACN,QAAQ;AACV;AAEA,IAAO,wBAAQ,OAAO,OAAO,cAAcA,QAAO;","names":["src","exports"]}
|
@@ -1,160 +0,0 @@
|
|
1
|
-
"use client";
|
2
|
-
|
3
|
-
// src/ui/attachment-ui.tsx
|
4
|
-
import {
|
5
|
-
forwardRef,
|
6
|
-
useEffect,
|
7
|
-
useState
|
8
|
-
} from "react";
|
9
|
-
import { CircleXIcon, FileIcon } from "lucide-react";
|
10
|
-
import { withDefaults } from "./utils/withDefaults.mjs";
|
11
|
-
import { useThreadConfig } from "./thread-config.mjs";
|
12
|
-
import { TooltipIconButton } from "./base/tooltip-icon-button.mjs";
|
13
|
-
import { AttachmentPrimitive } from "../primitives/index.mjs";
|
14
|
-
import { useAttachment } from "../context/react/AttachmentContext.mjs";
|
15
|
-
import {
|
16
|
-
AvatarImage,
|
17
|
-
AvatarRoot,
|
18
|
-
Tooltip,
|
19
|
-
TooltipContent,
|
20
|
-
TooltipTrigger
|
21
|
-
} from "./base/index.mjs";
|
22
|
-
import { Dialog, DialogTrigger, DialogContent } from "./base/dialog.mjs";
|
23
|
-
import { AvatarFallback } from "@radix-ui/react-avatar";
|
24
|
-
import { useShallow } from "zustand/shallow";
|
25
|
-
import { DialogTitle } from "@radix-ui/react-dialog";
|
26
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
27
|
-
var AttachmentRoot = withDefaults(AttachmentPrimitive.Root, {
|
28
|
-
className: "aui-attachment-root"
|
29
|
-
});
|
30
|
-
var AttachmentContent = withDefaults("div", {
|
31
|
-
className: "aui-attachment-content"
|
32
|
-
});
|
33
|
-
AttachmentRoot.displayName = "AttachmentRoot";
|
34
|
-
var useFileSrc = (file) => {
|
35
|
-
const [src, setSrc] = useState(void 0);
|
36
|
-
useEffect(() => {
|
37
|
-
if (!file) {
|
38
|
-
setSrc(void 0);
|
39
|
-
return;
|
40
|
-
}
|
41
|
-
const objectUrl = URL.createObjectURL(file);
|
42
|
-
setSrc(objectUrl);
|
43
|
-
return () => {
|
44
|
-
URL.revokeObjectURL(objectUrl);
|
45
|
-
};
|
46
|
-
}, [file]);
|
47
|
-
return src;
|
48
|
-
};
|
49
|
-
var useAttachmentSrc = () => {
|
50
|
-
const { file, src } = useAttachment(
|
51
|
-
useShallow((a) => {
|
52
|
-
if (a.type !== "image") return {};
|
53
|
-
if (a.file) return { file: a.file };
|
54
|
-
const src2 = a.content?.filter((c) => c.type === "image")[0]?.image;
|
55
|
-
if (!src2) return {};
|
56
|
-
return { src: src2 };
|
57
|
-
})
|
58
|
-
);
|
59
|
-
return useFileSrc(file) ?? src;
|
60
|
-
};
|
61
|
-
var AttachmentPreview = ({ src }) => {
|
62
|
-
const [isLoaded, setIsLoaded] = useState(false);
|
63
|
-
return (
|
64
|
-
// eslint-disable-next-line @next/next/no-img-element
|
65
|
-
/* @__PURE__ */ jsx(
|
66
|
-
"img",
|
67
|
-
{
|
68
|
-
src,
|
69
|
-
style: {
|
70
|
-
width: "auto",
|
71
|
-
height: "auto",
|
72
|
-
maxWidth: "75dvh",
|
73
|
-
maxHeight: "75dvh",
|
74
|
-
display: isLoaded ? "block" : "none",
|
75
|
-
overflow: "clip"
|
76
|
-
},
|
77
|
-
onLoad: () => setIsLoaded(true),
|
78
|
-
alt: "Image Preview"
|
79
|
-
}
|
80
|
-
)
|
81
|
-
);
|
82
|
-
};
|
83
|
-
var AttachmentPreviewDialog = ({ children }) => {
|
84
|
-
const src = useAttachmentSrc();
|
85
|
-
if (!src) return children;
|
86
|
-
return /* @__PURE__ */ jsxs(Dialog, { children: [
|
87
|
-
/* @__PURE__ */ jsx(DialogTrigger, { className: "aui-attachment-preview-trigger", asChild: true, children }),
|
88
|
-
/* @__PURE__ */ jsxs(DialogContent, { children: [
|
89
|
-
/* @__PURE__ */ jsx(DialogTitle, { className: "aui-sr-only", children: "Image Attachment Preview" }),
|
90
|
-
/* @__PURE__ */ jsx(AttachmentPreview, { src })
|
91
|
-
] })
|
92
|
-
] });
|
93
|
-
};
|
94
|
-
var AttachmentThumb = () => {
|
95
|
-
const isImage = useAttachment((a) => a.type === "image");
|
96
|
-
const src = useAttachmentSrc();
|
97
|
-
return /* @__PURE__ */ jsxs(AvatarRoot, { className: "aui-attachment-thumb", children: [
|
98
|
-
/* @__PURE__ */ jsx(AvatarFallback, { delayMs: isImage ? 200 : 0, children: /* @__PURE__ */ jsx(FileIcon, {}) }),
|
99
|
-
/* @__PURE__ */ jsx(AvatarImage, { src })
|
100
|
-
] });
|
101
|
-
};
|
102
|
-
var AttachmentUI = () => {
|
103
|
-
const canRemove = useAttachment((a) => a.source !== "message");
|
104
|
-
const typeLabel = useAttachment((a) => {
|
105
|
-
const type = a.type;
|
106
|
-
switch (type) {
|
107
|
-
case "image":
|
108
|
-
return "Image";
|
109
|
-
case "document":
|
110
|
-
return "Document";
|
111
|
-
case "file":
|
112
|
-
return "File";
|
113
|
-
default:
|
114
|
-
const _exhaustiveCheck = type;
|
115
|
-
throw new Error(`Unknown attachment type: ${_exhaustiveCheck}`);
|
116
|
-
}
|
117
|
-
});
|
118
|
-
return /* @__PURE__ */ jsxs(Tooltip, { children: [
|
119
|
-
/* @__PURE__ */ jsxs(AttachmentRoot, { children: [
|
120
|
-
/* @__PURE__ */ jsx(AttachmentPreviewDialog, { children: /* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(AttachmentContent, { children: [
|
121
|
-
/* @__PURE__ */ jsx(AttachmentThumb, {}),
|
122
|
-
/* @__PURE__ */ jsxs("div", { className: "aui-attachment-text", children: [
|
123
|
-
/* @__PURE__ */ jsx("p", { className: "aui-attachment-name", children: /* @__PURE__ */ jsx(AttachmentPrimitive.Name, {}) }),
|
124
|
-
/* @__PURE__ */ jsx("p", { className: "aui-attachment-type", children: typeLabel })
|
125
|
-
] })
|
126
|
-
] }) }) }),
|
127
|
-
canRemove && /* @__PURE__ */ jsx(AttachmentRemove, {})
|
128
|
-
] }),
|
129
|
-
/* @__PURE__ */ jsx(TooltipContent, { side: "top", children: /* @__PURE__ */ jsx(AttachmentPrimitive.Name, {}) })
|
130
|
-
] });
|
131
|
-
};
|
132
|
-
AttachmentUI.displayName = "Attachment";
|
133
|
-
var AttachmentRemove = forwardRef((props, ref) => {
|
134
|
-
const {
|
135
|
-
strings: {
|
136
|
-
composer: { removeAttachment: { tooltip = "Remove file" } = {} } = {}
|
137
|
-
} = {}
|
138
|
-
} = useThreadConfig();
|
139
|
-
return /* @__PURE__ */ jsx(AttachmentPrimitive.Remove, { asChild: true, children: /* @__PURE__ */ jsx(
|
140
|
-
TooltipIconButton,
|
141
|
-
{
|
142
|
-
tooltip,
|
143
|
-
className: "aui-attachment-remove",
|
144
|
-
side: "top",
|
145
|
-
...props,
|
146
|
-
ref,
|
147
|
-
children: props.children ?? /* @__PURE__ */ jsx(CircleXIcon, {})
|
148
|
-
}
|
149
|
-
) });
|
150
|
-
});
|
151
|
-
AttachmentRemove.displayName = "AttachmentRemove";
|
152
|
-
var exports = {
|
153
|
-
Root: AttachmentRoot,
|
154
|
-
Remove: AttachmentRemove
|
155
|
-
};
|
156
|
-
var attachment_ui_default = Object.assign(AttachmentUI, exports);
|
157
|
-
export {
|
158
|
-
attachment_ui_default as default
|
159
|
-
};
|
160
|
-
//# sourceMappingURL=attachment-ui.mjs.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../../src/ui/attachment-ui.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n forwardRef,\n PropsWithChildren,\n useEffect,\n useState,\n type FC,\n} from \"react\";\nimport { CircleXIcon, FileIcon } from \"lucide-react\";\nimport { withDefaults } from \"./utils/withDefaults\";\nimport { useThreadConfig } from \"./thread-config\";\nimport { TooltipIconButton } from \"./base/tooltip-icon-button\";\nimport { AttachmentPrimitive } from \"../primitives\";\nimport { useAttachment } from \"../context/react/AttachmentContext\";\nimport {\n AvatarImage,\n AvatarRoot,\n Tooltip,\n TooltipContent,\n TooltipTrigger,\n} from \"./base\";\nimport { Dialog, DialogTrigger, DialogContent } from \"./base/dialog\";\nimport { AvatarFallback } from \"@radix-ui/react-avatar\";\nimport { useShallow } from \"zustand/shallow\";\nimport { DialogTitle } from \"@radix-ui/react-dialog\";\n\nconst AttachmentRoot = withDefaults(AttachmentPrimitive.Root, {\n className: \"aui-attachment-root\",\n});\n\nconst AttachmentContent = withDefaults(\"div\", {\n className: \"aui-attachment-content\",\n});\n\nAttachmentRoot.displayName = \"AttachmentRoot\";\n\nconst useFileSrc = (file: File | undefined) => {\n const [src, setSrc] = useState<string | undefined>(undefined);\n\n useEffect(() => {\n if (!file) {\n setSrc(undefined);\n return;\n }\n\n const objectUrl = URL.createObjectURL(file);\n setSrc(objectUrl);\n\n return () => {\n URL.revokeObjectURL(objectUrl);\n };\n }, [file]);\n\n return src;\n};\n\nconst useAttachmentSrc = () => {\n const { file, src } = useAttachment(\n useShallow((a): { file?: File; src?: string } => {\n if (a.type !== \"image\") return {};\n if (a.file) return { file: a.file };\n const src = a.content?.filter((c) => c.type === \"image\")[0]?.image;\n if (!src) return {};\n return { src };\n }),\n );\n\n return useFileSrc(file) ?? src;\n};\n\ntype AttachmentPreviewProps = {\n src: string;\n};\n\nconst AttachmentPreview: FC<AttachmentPreviewProps> = ({ src }) => {\n const [isLoaded, setIsLoaded] = useState(false);\n\n return (\n // eslint-disable-next-line @next/next/no-img-element\n <img\n src={src}\n style={{\n width: \"auto\",\n height: \"auto\",\n maxWidth: \"75dvh\",\n maxHeight: \"75dvh\",\n display: isLoaded ? \"block\" : \"none\",\n overflow: \"clip\",\n }}\n onLoad={() => setIsLoaded(true)}\n alt=\"Image Preview\"\n />\n );\n};\n\nconst AttachmentPreviewDialog: FC<PropsWithChildren> = ({ children }) => {\n const src = useAttachmentSrc();\n\n if (!src) return children;\n\n return (\n <Dialog>\n <DialogTrigger className=\"aui-attachment-preview-trigger\" asChild>\n {children}\n </DialogTrigger>\n <DialogContent>\n <DialogTitle className=\"aui-sr-only\">\n Image Attachment Preview\n </DialogTitle>\n <AttachmentPreview src={src} />\n </DialogContent>\n </Dialog>\n );\n};\n\nconst AttachmentThumb: FC = () => {\n const isImage = useAttachment((a) => a.type === \"image\");\n const src = useAttachmentSrc();\n return (\n <AvatarRoot className=\"aui-attachment-thumb\">\n <AvatarFallback delayMs={isImage ? 200 : 0}>\n <FileIcon />\n </AvatarFallback>\n <AvatarImage src={src}></AvatarImage>\n </AvatarRoot>\n );\n};\n\nconst AttachmentUI: FC = () => {\n const canRemove = useAttachment((a) => a.source !== \"message\");\n const typeLabel = useAttachment((a) => {\n const type = a.type;\n switch (type) {\n case \"image\":\n return \"Image\";\n case \"document\":\n return \"Document\";\n case \"file\":\n return \"File\";\n default:\n const _exhaustiveCheck: never = type;\n throw new Error(`Unknown attachment type: ${_exhaustiveCheck}`);\n }\n });\n return (\n <Tooltip>\n <AttachmentRoot>\n <AttachmentPreviewDialog>\n <TooltipTrigger asChild>\n <AttachmentContent>\n <AttachmentThumb />\n <div className=\"aui-attachment-text\">\n <p className=\"aui-attachment-name\">\n <AttachmentPrimitive.Name />\n </p>\n <p className=\"aui-attachment-type\">{typeLabel}</p>\n </div>\n </AttachmentContent>\n </TooltipTrigger>\n </AttachmentPreviewDialog>\n {canRemove && <AttachmentRemove />}\n </AttachmentRoot>\n <TooltipContent side=\"top\">\n <AttachmentPrimitive.Name />\n </TooltipContent>\n </Tooltip>\n );\n};\n\nAttachmentUI.displayName = \"Attachment\";\n\nnamespace AttachmentRemove {\n export type Element = HTMLButtonElement;\n export type Props = Partial<TooltipIconButton.Props>;\n}\n\nconst AttachmentRemove = forwardRef<\n AttachmentRemove.Element,\n AttachmentRemove.Props\n>((props, ref) => {\n const {\n strings: {\n composer: { removeAttachment: { tooltip = \"Remove file\" } = {} } = {},\n } = {},\n } = useThreadConfig();\n\n return (\n <AttachmentPrimitive.Remove asChild>\n <TooltipIconButton\n tooltip={tooltip}\n className=\"aui-attachment-remove\"\n side=\"top\"\n {...props}\n ref={ref}\n >\n {props.children ?? <CircleXIcon />}\n </TooltipIconButton>\n </AttachmentPrimitive.Remove>\n );\n});\n\nAttachmentRemove.displayName = \"AttachmentRemove\";\n\nconst exports = {\n Root: AttachmentRoot,\n Remove: AttachmentRemove,\n};\n\nexport default Object.assign(AttachmentUI, exports) as typeof AttachmentUI &\n typeof exports;\n"],"mappings":";;;AAEA;AAAA,EACE;AAAA,EAEA;AAAA,EACA;AAAA,OAEK;AACP,SAAS,aAAa,gBAAgB;AACtC,SAAS,oBAAoB;AAC7B,SAAS,uBAAuB;AAChC,SAAS,yBAAyB;AAClC,SAAS,2BAA2B;AACpC,SAAS,qBAAqB;AAC9B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,QAAQ,eAAe,qBAAqB;AACrD,SAAS,sBAAsB;AAC/B,SAAS,kBAAkB;AAC3B,SAAS,mBAAmB;AAuDxB,cA0BE,YA1BF;AArDJ,IAAM,iBAAiB,aAAa,oBAAoB,MAAM;AAAA,EAC5D,WAAW;AACb,CAAC;AAED,IAAM,oBAAoB,aAAa,OAAO;AAAA,EAC5C,WAAW;AACb,CAAC;AAED,eAAe,cAAc;AAE7B,IAAM,aAAa,CAAC,SAA2B;AAC7C,QAAM,CAAC,KAAK,MAAM,IAAI,SAA6B,MAAS;AAE5D,YAAU,MAAM;AACd,QAAI,CAAC,MAAM;AACT,aAAO,MAAS;AAChB;AAAA,IACF;AAEA,UAAM,YAAY,IAAI,gBAAgB,IAAI;AAC1C,WAAO,SAAS;AAEhB,WAAO,MAAM;AACX,UAAI,gBAAgB,SAAS;AAAA,IAC/B;AAAA,EACF,GAAG,CAAC,IAAI,CAAC;AAET,SAAO;AACT;AAEA,IAAM,mBAAmB,MAAM;AAC7B,QAAM,EAAE,MAAM,IAAI,IAAI;AAAA,IACpB,WAAW,CAAC,MAA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AA;AAAA,EAClC,GACF;AAEJ,CAAC;AAED,iBAAiB,cAAc;AAE/B,IAAM,UAAU;AAAA,EACd,MAAM;AAAA,EACN,QAAQ;AACV;AAEA,IAAO,wBAAQ,OAAO,OAAO,cAAc,OAAO;","names":["src"]}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"CircleStopIcon.d.ts","sourceRoot":"","sources":["../../../src/ui/base/CircleStopIcon.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAE3B,eAAO,MAAM,cAAc,EAAE,EAY5B,CAAC"}
|
@@ -1,45 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __defProp = Object.defineProperty;
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
-
var __export = (target, all) => {
|
7
|
-
for (var name in all)
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
9
|
-
};
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
12
|
-
for (let key of __getOwnPropNames(from))
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
15
|
-
}
|
16
|
-
return to;
|
17
|
-
};
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
|
-
|
20
|
-
// src/ui/base/CircleStopIcon.tsx
|
21
|
-
var CircleStopIcon_exports = {};
|
22
|
-
__export(CircleStopIcon_exports, {
|
23
|
-
CircleStopIcon: () => CircleStopIcon
|
24
|
-
});
|
25
|
-
module.exports = __toCommonJS(CircleStopIcon_exports);
|
26
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
27
|
-
var CircleStopIcon = () => {
|
28
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
29
|
-
"svg",
|
30
|
-
{
|
31
|
-
xmlns: "http://www.w3.org/2000/svg",
|
32
|
-
viewBox: "0 0 16 16",
|
33
|
-
fill: "currentColor",
|
34
|
-
width: "16",
|
35
|
-
height: "16",
|
36
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("rect", { width: "10", height: "10", x: "3", y: "3", rx: "2" })
|
37
|
-
}
|
38
|
-
);
|
39
|
-
};
|
40
|
-
CircleStopIcon.displayName = "CircleStopIcon";
|
41
|
-
// Annotate the CommonJS export names for ESM import in node:
|
42
|
-
0 && (module.exports = {
|
43
|
-
CircleStopIcon
|
44
|
-
});
|
45
|
-
//# sourceMappingURL=CircleStopIcon.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/ui/base/CircleStopIcon.tsx"],"sourcesContent":["import { FC } from \"react\";\n\nexport const CircleStopIcon: FC = () => {\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 16 16\"\n fill=\"currentColor\"\n width=\"16\"\n height=\"16\"\n >\n <rect width=\"10\" height=\"10\" x=\"3\" y=\"3\" rx=\"2\" />\n </svg>\n );\n};\n\nCircleStopIcon.displayName = \"CircleStopIcon\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAWM;AATC,IAAM,iBAAqB,MAAM;AACtC,SACE;AAAA,IAAC;AAAA;AAAA,MACC,OAAM;AAAA,MACN,SAAQ;AAAA,MACR,MAAK;AAAA,MACL,OAAM;AAAA,MACN,QAAO;AAAA,MAEP,sDAAC,UAAK,OAAM,MAAK,QAAO,MAAK,GAAE,KAAI,GAAE,KAAI,IAAG,KAAI;AAAA;AAAA,EAClD;AAEJ;AAEA,eAAe,cAAc;","names":[]}
|
@@ -1,20 +0,0 @@
|
|
1
|
-
// src/ui/base/CircleStopIcon.tsx
|
2
|
-
import { jsx } from "react/jsx-runtime";
|
3
|
-
var CircleStopIcon = () => {
|
4
|
-
return /* @__PURE__ */ jsx(
|
5
|
-
"svg",
|
6
|
-
{
|
7
|
-
xmlns: "http://www.w3.org/2000/svg",
|
8
|
-
viewBox: "0 0 16 16",
|
9
|
-
fill: "currentColor",
|
10
|
-
width: "16",
|
11
|
-
height: "16",
|
12
|
-
children: /* @__PURE__ */ jsx("rect", { width: "10", height: "10", x: "3", y: "3", rx: "2" })
|
13
|
-
}
|
14
|
-
);
|
15
|
-
};
|
16
|
-
CircleStopIcon.displayName = "CircleStopIcon";
|
17
|
-
export {
|
18
|
-
CircleStopIcon
|
19
|
-
};
|
20
|
-
//# sourceMappingURL=CircleStopIcon.mjs.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/ui/base/CircleStopIcon.tsx"],"sourcesContent":["import { FC } from \"react\";\n\nexport const CircleStopIcon: FC = () => {\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 16 16\"\n fill=\"currentColor\"\n width=\"16\"\n height=\"16\"\n >\n <rect width=\"10\" height=\"10\" x=\"3\" y=\"3\" rx=\"2\" />\n </svg>\n );\n};\n\nCircleStopIcon.displayName = \"CircleStopIcon\";\n"],"mappings":";AAWM;AATC,IAAM,iBAAqB,MAAM;AACtC,SACE;AAAA,IAAC;AAAA;AAAA,MACC,OAAM;AAAA,MACN,SAAQ;AAAA,MACR,MAAK;AAAA,MACL,OAAM;AAAA,MACN,QAAO;AAAA,MAEP,8BAAC,UAAK,OAAM,MAAK,QAAO,MAAK,GAAE,KAAI,GAAE,KAAI,IAAG,KAAI;AAAA;AAAA,EAClD;AAEJ;AAEA,eAAe,cAAc;","names":[]}
|
package/dist/ui/base/avatar.d.ts
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
import type { FC } from "react";
|
2
|
-
import * as AvatarPrimitive from "@radix-ui/react-avatar";
|
3
|
-
export type AvatarProps = {
|
4
|
-
src?: string | undefined;
|
5
|
-
alt?: string | undefined;
|
6
|
-
fallback?: string | undefined;
|
7
|
-
};
|
8
|
-
export declare const Avatar: FC<AvatarProps>;
|
9
|
-
export declare const AvatarRoot: import("react").ForwardRefExoticComponent<Partial<Omit<AvatarPrimitive.AvatarProps & import("react").RefAttributes<HTMLSpanElement>, "ref">> & import("react").RefAttributes<HTMLSpanElement>>;
|
10
|
-
export declare const AvatarImage: import("react").ForwardRefExoticComponent<Partial<Omit<AvatarPrimitive.AvatarImageProps & import("react").RefAttributes<HTMLImageElement>, "ref">> & import("react").RefAttributes<HTMLImageElement>>;
|
11
|
-
export declare const AvatarFallback: import("react").ForwardRefExoticComponent<Partial<Omit<AvatarPrimitive.AvatarFallbackProps & import("react").RefAttributes<HTMLSpanElement>, "ref">> & import("react").RefAttributes<HTMLSpanElement>>;
|
12
|
-
//# sourceMappingURL=avatar.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"avatar.d.ts","sourceRoot":"","sources":["../../../src/ui/base/avatar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,KAAK,eAAe,MAAM,wBAAwB,CAAC;AAI1D,MAAM,MAAM,WAAW,GAAG;IACxB,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC/B,CAAC;AAEF,eAAO,MAAM,MAAM,EAAE,EAAE,CAAC,WAAW,CASlC,CAAC;AAIF,eAAO,MAAM,UAAU,gMAErB,CAAC;AAIH,eAAO,MAAM,WAAW,uMAEtB,CAAC;AAIH,eAAO,MAAM,cAAc,wMAEzB,CAAC"}
|