@ctrl-ui/react 0.8.6 → 0.8.8
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/action-bar.d.ts +15 -7
- package/dist/action-bar.js +39 -19
- package/dist/activity.js +7 -15
- package/dist/audio-recorder.d.ts +14 -4
- package/dist/audio-recorder.js +82 -29
- package/dist/audio-visualizer.js +1 -1
- package/dist/blocks/coding-agent.js +54 -57
- package/dist/blocks/design-canvas-data.d.ts +32 -0
- package/dist/blocks/design-canvas-data.js +100 -0
- package/dist/blocks/design-canvas-inspector.d.ts +8 -0
- package/dist/blocks/design-canvas-inspector.js +238 -0
- package/dist/blocks/design-canvas.d.ts +21 -0
- package/dist/blocks/design-canvas.js +452 -0
- package/dist/blocks/discussion.d.ts +28 -0
- package/dist/blocks/discussion.js +67 -0
- package/dist/blocks/file-explorer-data.d.ts +1 -0
- package/dist/blocks/file-explorer-data.js +4 -1
- package/dist/blocks/file-explorer.d.ts +9 -1
- package/dist/blocks/file-explorer.js +461 -192
- package/dist/blocks/settings.d.ts +2 -1
- package/dist/blocks/settings.js +101 -79
- package/dist/blocks/team-chat.d.ts +12 -0
- package/dist/blocks/team-chat.js +26 -0
- package/dist/blocks/theme-toggle.js +23 -31
- package/dist/chat-composer-attachment.d.ts +12 -3
- package/dist/chat-composer-attachment.js +61 -19
- package/dist/chat-composer-editor/extensions/mention.d.ts +5 -1
- package/dist/chat-composer-editor/extensions/mention.js +58 -27
- package/dist/chat-composer-editor/ghost.js +2 -4
- package/dist/chat-composer-editor/types.d.ts +5 -0
- package/dist/chat-composer-editor.d.ts +1 -1
- package/dist/chat-composer-editor.js +71 -28
- package/dist/chat-composer.d.ts +13 -32
- package/dist/chat-composer.js +54 -13
- package/dist/chat-layout.d.ts +19 -0
- package/dist/chat-layout.js +96 -32
- package/dist/chat-message/social.d.ts +26 -0
- package/dist/chat-message/social.js +122 -0
- package/dist/chat-message.d.ts +28 -29
- package/dist/chat-message.js +106 -25
- package/dist/context.d.ts +2 -2
- package/dist/context.js +38 -23
- package/dist/dynamic-notification-canvas-loop.d.ts +24 -0
- package/dist/dynamic-notification-canvas-loop.js +113 -0
- package/dist/dynamic-notification-glass.js +23 -114
- package/dist/dynamic-notification-liquid.js +14 -118
- package/dist/dynamic-notification.d.ts +16 -8
- package/dist/dynamic-notification.js +85 -22
- package/dist/email/email-brand.d.ts +7 -4
- package/dist/email/email-brand.js +9 -6
- package/dist/email/email-code.d.ts +3 -2
- package/dist/email/email-code.js +11 -9
- package/dist/email/email-footer.d.ts +5 -3
- package/dist/email/email-footer.js +11 -5
- package/dist/email/email.d.ts +31 -9
- package/dist/email/email.js +50 -26
- package/dist/email/templates.d.ts +10 -9
- package/dist/email/templates.js +102 -38
- package/dist/email/theme.js +1 -1
- package/dist/environment-variables.d.ts +4 -2
- package/dist/environment-variables.js +52 -32
- package/dist/filter-bar/context.d.ts +32 -0
- package/dist/filter-bar/context.js +11 -0
- package/dist/filter-bar/editor.d.ts +14 -0
- package/dist/filter-bar/editor.js +216 -0
- package/dist/filter-bar/model.d.ts +10 -0
- package/dist/filter-bar/model.js +57 -0
- package/dist/filter-bar/motion.d.ts +10 -0
- package/dist/filter-bar/motion.js +84 -0
- package/dist/filter-bar/parts.d.ts +19 -0
- package/dist/filter-bar/parts.js +244 -0
- package/dist/filter-bar/types.d.ts +54 -0
- package/dist/filter-bar/types.js +0 -0
- package/dist/filter-bar.d.ts +27 -0
- package/dist/filter-bar.js +310 -0
- package/dist/hooks/use-audio-recorder.js +12 -6
- package/dist/hooks/use-chat-composer.d.ts +21 -7
- package/dist/hooks/use-chat-composer.js +32 -5
- package/dist/hooks/use-chat-message.d.ts +28 -2
- package/dist/hooks/use-chat-message.js +41 -10
- package/dist/hooks/use-chat-thread-scroll.js +43 -7
- package/dist/hooks/use-color-area.d.ts +3 -3
- package/dist/hooks/use-color-area.js +13 -12
- package/dist/hooks/use-copy-to-clipboard.d.ts +2 -1
- package/dist/hooks/use-copy-to-clipboard.js +20 -20
- package/dist/hooks/use-dropzone.d.ts +7 -4
- package/dist/hooks/use-dropzone.js +34 -3
- package/dist/hooks/use-dynamic-notification.d.ts +6 -2
- package/dist/hooks/use-dynamic-notification.js +26 -10
- package/dist/hooks/use-mobile.d.ts +3 -2
- package/dist/hooks/use-mobile.js +8 -4
- package/dist/hooks/use-textarea-trigger-menu.js +2 -1
- package/dist/hooks/use-trigger-menu.d.ts +54 -0
- package/dist/hooks/use-trigger-menu.js +102 -47
- package/dist/hooks/use-user-ask.d.ts +2 -0
- package/dist/hooks/use-user-ask.js +35 -41
- package/dist/inline-attachment.d.ts +6 -2
- package/dist/inline-attachment.js +44 -29
- package/dist/inline-citation.d.ts +12 -5
- package/dist/inline-citation.js +25 -16
- package/dist/knob-contracts/audio-recorder-knobs.d.ts +1 -1
- package/dist/knob-contracts/audio-recorder-knobs.js +2 -1
- package/dist/knob-contracts/audio-visualizer-knobs.d.ts +1 -1
- package/dist/knob-contracts/audio-visualizer-knobs.js +2 -1
- package/dist/knob-contracts/avatar-knobs.d.ts +1 -1
- package/dist/knob-contracts/avatar-knobs.js +6 -1
- package/dist/knob-contracts/badge-knobs.d.ts +1 -1
- package/dist/knob-contracts/badge-knobs.js +2 -1
- package/dist/knob-contracts/breadcrumb-knobs.d.ts +4 -0
- package/dist/knob-contracts/breadcrumb-knobs.js +8 -0
- package/dist/knob-contracts/button-knobs.d.ts +1 -1
- package/dist/knob-contracts/button-knobs.js +1 -0
- package/dist/knob-contracts/chat-layout-knobs.d.ts +1 -1
- package/dist/knob-contracts/chat-layout-knobs.js +2 -1
- package/dist/knob-contracts/chat-message-knobs.d.ts +1 -1
- package/dist/knob-contracts/chat-message-knobs.js +8 -1
- package/dist/knob-contracts/choice-knobs.d.ts +1 -1
- package/dist/knob-contracts/choice-knobs.js +1 -0
- package/dist/knob-contracts/code-diff-knobs.d.ts +1 -1
- package/dist/knob-contracts/code-diff-knobs.js +2 -0
- package/dist/knob-contracts/code-knobs.d.ts +1 -1
- package/dist/knob-contracts/code-knobs.js +2 -1
- package/dist/knob-contracts/collapsible-knobs.d.ts +1 -1
- package/dist/knob-contracts/collapsible-knobs.js +1 -1
- package/dist/knob-contracts/dynamic-notification-knobs.d.ts +1 -1
- package/dist/knob-contracts/dynamic-notification-knobs.js +2 -0
- package/dist/knob-contracts/emoji-picker-knobs.d.ts +4 -0
- package/dist/knob-contracts/emoji-picker-knobs.js +10 -0
- package/dist/knob-contracts/field-knobs.d.ts +1 -1
- package/dist/knob-contracts/field-knobs.js +5 -1
- package/dist/knob-contracts/filter-bar-knobs.d.ts +4 -0
- package/dist/knob-contracts/filter-bar-knobs.js +15 -0
- package/dist/knob-contracts/infinite-canvas-knobs.d.ts +1 -1
- package/dist/knob-contracts/infinite-canvas-knobs.js +3 -0
- package/dist/knob-contracts/markdown-knobs.d.ts +1 -1
- package/dist/knob-contracts/markdown-knobs.js +3 -1
- package/dist/knob-contracts/page-layout-knobs.d.ts +1 -1
- package/dist/knob-contracts/page-layout-knobs.js +4 -1
- package/dist/knob-contracts/popup-knobs.d.ts +1 -1
- package/dist/knob-contracts/popup-knobs.js +28 -0
- package/dist/knob-contracts/range-knobs.d.ts +1 -1
- package/dist/knob-contracts/range-knobs.js +1 -0
- package/dist/knob-contracts/rich-tooltip-knobs.d.ts +1 -1
- package/dist/knob-contracts/rich-tooltip-knobs.js +2 -1
- package/dist/knob-contracts/sidebar-knobs.d.ts +1 -1
- package/dist/knob-contracts/sidebar-knobs.js +27 -2
- package/dist/knob-contracts/spinner-knobs.d.ts +1 -1
- package/dist/knob-contracts/spinner-knobs.js +1 -1
- package/dist/knob-contracts/stepper-knobs.d.ts +1 -1
- package/dist/knob-contracts/stepper-knobs.js +4 -1
- package/dist/knob-contracts/switch-knobs.d.ts +1 -1
- package/dist/knob-contracts/switch-knobs.js +5 -0
- package/dist/knob-contracts/table-of-contents-knobs.d.ts +1 -1
- package/dist/knob-contracts/table-of-contents-knobs.js +4 -5
- package/dist/knob-contracts/tabs-knobs.d.ts +1 -1
- package/dist/knob-contracts/tabs-knobs.js +1 -0
- package/dist/knob-contracts/tree-knobs.d.ts +1 -1
- package/dist/knob-contracts/tree-knobs.js +2 -1
- package/dist/lib/cn.js +0 -4
- package/dist/lib/contrast.d.ts +1 -0
- package/dist/lib/contrast.js +17 -5
- package/dist/lib/dropzone-validation.js +41 -28
- package/dist/lib/env-file.d.ts +1 -1
- package/dist/lib/env-file.js +5 -5
- package/dist/lib/motion.d.ts +4 -0
- package/dist/lib/motion.js +15 -0
- package/dist/lib/trigger-detect.js +6 -8
- package/dist/markdown-block.js +13 -8
- package/dist/popup-parts.d.ts +8 -0
- package/dist/popup-parts.js +43 -0
- package/dist/scripts/contrast-eval.js +5 -4
- package/dist/source-badge.js +3 -1
- package/dist/styles/code.css +0 -2
- package/dist/styles/effects.css +6 -32
- package/dist/styles/index.css +14 -8
- package/dist/styles/recipes/accordion.css +9 -6
- package/dist/styles/recipes/action-bar.css +0 -15
- package/dist/styles/recipes/activity.css +5 -11
- package/dist/styles/recipes/alert.css +4 -4
- package/dist/styles/recipes/audio-recorder.css +15 -3
- package/dist/styles/recipes/audio-visualizer.css +13 -2
- package/dist/styles/recipes/avatar.css +78 -1
- package/dist/styles/recipes/badge.css +14 -4
- package/dist/styles/recipes/breadcrumb.css +77 -0
- package/dist/styles/recipes/button-group.css +6 -8
- package/dist/styles/recipes/button-states.css +66 -0
- package/dist/styles/recipes/button.css +26 -85
- package/dist/styles/recipes/calendar.css +17 -23
- package/dist/styles/recipes/card.css +2 -2
- package/dist/styles/recipes/chat-composer-attachment.css +9 -3
- package/dist/styles/recipes/chat-composer.css +21 -16
- package/dist/styles/recipes/chat-layout.css +64 -2
- package/dist/styles/recipes/chat-message-social.css +123 -0
- package/dist/styles/recipes/chat-message.css +157 -37
- package/dist/styles/recipes/choice.css +25 -21
- package/dist/styles/recipes/code-diff.css +51 -26
- package/dist/styles/recipes/code.css +44 -18
- package/dist/styles/recipes/collapsible.css +43 -1
- package/dist/styles/recipes/color-picker-details.css +3 -4
- package/dist/styles/recipes/color-picker-values.css +9 -8
- package/dist/styles/recipes/color-picker.css +23 -4
- package/dist/styles/recipes/context.css +3 -3
- package/dist/styles/recipes/dockable-panel.css +18 -7
- package/dist/styles/recipes/dropzone.css +7 -8
- package/dist/styles/recipes/dynamic-notification-input.css +8 -5
- package/dist/styles/recipes/dynamic-notification-motion.css +12 -21
- package/dist/styles/recipes/dynamic-notification.css +40 -26
- package/dist/styles/recipes/emoji-picker.css +132 -0
- package/dist/styles/recipes/empty.css +5 -4
- package/dist/styles/recipes/environment-variables.css +4 -15
- package/dist/styles/recipes/field-parts.css +89 -21
- package/dist/styles/recipes/field.css +83 -26
- package/dist/styles/recipes/filter-bar.css +161 -0
- package/dist/styles/recipes/gradient-editor.css +18 -7
- package/dist/styles/recipes/infinite-canvas.css +51 -4
- package/dist/styles/recipes/inline-attachment.css +9 -4
- package/dist/styles/recipes/inline-citation.css +10 -4
- package/dist/styles/recipes/item.css +23 -9
- package/dist/styles/recipes/markdown-block.css +5 -4
- package/dist/styles/recipes/markdown.css +68 -26
- package/dist/styles/recipes/morphing-panel.css +8 -8
- package/dist/styles/recipes/page-layout.css +36 -10
- package/dist/styles/recipes/pagination.css +5 -6
- package/dist/styles/recipes/phone-input.css +12 -8
- package/dist/styles/recipes/popup-controls.css +175 -26
- package/dist/styles/recipes/popup-drawer.css +35 -44
- package/dist/styles/recipes/popup-lists.css +139 -29
- package/dist/styles/recipes/popup-motion.css +4 -45
- package/dist/styles/recipes/popup-toast.css +55 -26
- package/dist/styles/recipes/popup.css +149 -153
- package/dist/styles/recipes/range.css +55 -19
- package/dist/styles/recipes/resizable.css +36 -7
- package/dist/styles/recipes/rich-tooltip.css +24 -34
- package/dist/styles/recipes/scroll-area.css +8 -1
- package/dist/styles/recipes/sidebar-menu.css +149 -34
- package/dist/styles/recipes/sidebar-parts.css +154 -0
- package/dist/styles/recipes/sidebar.css +187 -128
- package/dist/styles/recipes/source-badge.css +1 -1
- package/dist/styles/recipes/spinner.css +12 -1
- package/dist/styles/recipes/stepper.css +31 -13
- package/dist/styles/recipes/switch.css +68 -23
- package/dist/styles/recipes/table-of-contents.css +49 -41
- package/dist/styles/recipes/table.css +14 -10
- package/dist/styles/recipes/tabs.css +38 -12
- package/dist/styles/recipes/task-list.css +7 -14
- package/dist/styles/recipes/thread-rail.css +42 -19
- package/dist/styles/recipes/timeline.css +2 -0
- package/dist/styles/recipes/toolbar.css +27 -25
- package/dist/styles/recipes/track-highlight.css +12 -8
- package/dist/styles/recipes/transcript-divider.css +2 -2
- package/dist/styles/recipes/tree.css +31 -4
- package/dist/styles/recipes/user-ask-details.css +0 -1
- package/dist/styles/recipes/user-ask.css +4 -4
- package/dist/styles/theme.css +287 -107
- package/dist/task-list.d.ts +4 -1
- package/dist/task-list.js +24 -8
- package/dist/thread-rail.d.ts +1 -1
- package/dist/thread-rail.js +61 -19
- package/dist/transcript-divider.js +2 -1
- package/dist/ui/alert.d.ts +3 -1
- package/dist/ui/alert.js +14 -8
- package/dist/ui/autocomplete.js +7 -1
- package/dist/ui/avatar.d.ts +8 -0
- package/dist/ui/avatar.js +23 -3
- package/dist/ui/badge.js +1 -1
- package/dist/ui/breadcrumb.d.ts +27 -0
- package/dist/ui/breadcrumb.js +88 -0
- package/dist/ui/button.d.ts +2 -1
- package/dist/ui/button.js +1 -1
- package/dist/ui/calendar.js +2 -2
- package/dist/ui/card.d.ts +3 -1
- package/dist/ui/card.js +12 -7
- package/dist/ui/checkbox-group.js +1 -1
- package/dist/ui/checkbox.d.ts +2 -0
- package/dist/ui/code-diff.d.ts +1 -1
- package/dist/ui/code-diff.js +71 -27
- package/dist/ui/code.d.ts +5 -3
- package/dist/ui/code.js +27 -28
- package/dist/ui/color-picker.d.ts +5 -2
- package/dist/ui/color-picker.js +84 -36
- package/dist/ui/combobox-disabled-selection.d.ts +1 -2
- package/dist/ui/combobox-disabled-selection.js +7 -8
- package/dist/ui/combobox.d.ts +5 -23
- package/dist/ui/combobox.js +36 -16
- package/dist/ui/command.d.ts +8 -2
- package/dist/ui/command.js +39 -15
- package/dist/ui/context-menu.js +3 -0
- package/dist/ui/dialog.d.ts +2 -1
- package/dist/ui/dialog.js +3 -22
- package/dist/ui/dockable-panel-geometry.d.ts +1 -0
- package/dist/ui/dockable-panel-geometry.js +7 -1
- package/dist/ui/dockable-panel.d.ts +9 -6
- package/dist/ui/dockable-panel.js +81 -33
- package/dist/ui/drawer.d.ts +7 -4
- package/dist/ui/drawer.js +35 -22
- package/dist/ui/dropdown-menu.js +4 -3
- package/dist/ui/dropzone.d.ts +5 -3
- package/dist/ui/dropzone.js +78 -17
- package/dist/ui/emoji-picker.d.ts +18 -0
- package/dist/ui/emoji-picker.js +136 -0
- package/dist/ui/empty.d.ts +3 -1
- package/dist/ui/empty.js +12 -7
- package/dist/ui/field.js +1 -1
- package/dist/ui/gradient-editor.d.ts +1 -1
- package/dist/ui/gradient-editor.js +37 -21
- package/dist/ui/infinite-canvas.d.ts +13 -1
- package/dist/ui/infinite-canvas.js +139 -20
- package/dist/ui/input-group.d.ts +2 -4
- package/dist/ui/input-group.js +13 -14
- package/dist/ui/input-otp.d.ts +1 -1
- package/dist/ui/input-otp.js +32 -15
- package/dist/ui/input.js +11 -2
- package/dist/ui/item.d.ts +2 -1
- package/dist/ui/item.js +11 -7
- package/dist/ui/live-status.d.ts +7 -0
- package/dist/ui/live-status.js +17 -0
- package/dist/ui/markdown-elements.d.ts +6 -0
- package/dist/ui/markdown-elements.js +42 -9
- package/dist/ui/menubar.js +2 -2
- package/dist/ui/morphing-panel.js +2 -1
- package/dist/ui/native-select.d.ts +1 -1
- package/dist/ui/native-select.js +24 -11
- package/dist/ui/number-field.d.ts +1 -1
- package/dist/ui/number-field.js +13 -2
- package/dist/ui/page-layout.d.ts +2 -2
- package/dist/ui/page-layout.js +2 -4
- package/dist/ui/pagination.d.ts +7 -5
- package/dist/ui/pagination.js +19 -13
- package/dist/ui/phone-input.d.ts +1 -0
- package/dist/ui/phone-input.js +56 -58
- package/dist/ui/radio-group.d.ts +3 -0
- package/dist/ui/radio-group.js +11 -1
- package/dist/ui/resizable.d.ts +20 -2
- package/dist/ui/resizable.js +130 -8
- package/dist/ui/responsive-dialog.d.ts +1 -1
- package/dist/ui/responsive-dialog.js +9 -23
- package/dist/ui/rich-tooltip.d.ts +10 -4
- package/dist/ui/rich-tooltip.js +81 -33
- package/dist/ui/scroll-area.d.ts +4 -1
- package/dist/ui/scroll-area.js +44 -28
- package/dist/ui/select.d.ts +2 -1
- package/dist/ui/select.js +57 -32
- package/dist/ui/sidebar-menu.d.ts +5 -1
- package/dist/ui/sidebar-menu.js +31 -33
- package/dist/ui/sidebar-provider.d.ts +10 -1
- package/dist/ui/sidebar-provider.js +38 -13
- package/dist/ui/sidebar-resize-rail.js +7 -3
- package/dist/ui/sidebar.d.ts +11 -6
- package/dist/ui/sidebar.js +46 -23
- package/dist/ui/slider.js +31 -22
- package/dist/ui/spinner.d.ts +3 -2
- package/dist/ui/spinner.js +3 -2
- package/dist/ui/stepper.d.ts +8 -1
- package/dist/ui/stepper.js +74 -25
- package/dist/ui/switch.d.ts +1 -0
- package/dist/ui/table-of-contents.d.ts +5 -4
- package/dist/ui/table-of-contents.js +143 -52
- package/dist/ui/table.js +15 -9
- package/dist/ui/textarea.d.ts +1 -1
- package/dist/ui/textarea.js +20 -9
- package/dist/ui/timeline.d.ts +3 -1
- package/dist/ui/timeline.js +17 -9
- package/dist/ui/toast.d.ts +11 -5
- package/dist/ui/toast.js +100 -54
- package/dist/ui/toggle.d.ts +1 -1
- package/dist/ui/toggle.js +2 -1
- package/dist/ui/toolbar.d.ts +3 -2
- package/dist/ui/toolbar.js +4 -2
- package/dist/ui/tooltip.js +3 -20
- package/dist/ui/tree.js +120 -80
- package/dist/ui/trigger-menu.js +7 -2
- package/dist/user-ask.d.ts +10 -5
- package/dist/user-ask.js +31 -11
- package/package.json +5 -1
- package/dist/hooks/use-keyboard-navigation.d.ts +0 -3
- package/dist/hooks/use-keyboard-navigation.js +0 -22
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { cn } from "./lib/cn.js";
|
|
3
3
|
import { Button } from "./ui/button.js";
|
|
4
|
+
import { LiveStatus } from "./ui/live-status.js";
|
|
4
5
|
import { createDynamicNotificationGlass } from "./dynamic-notification-glass.js";
|
|
5
6
|
import { createDynamicNotificationLiquid } from "./dynamic-notification-liquid.js";
|
|
6
7
|
import { useDynamicNotification } from "./hooks/use-dynamic-notification.js";
|
|
7
|
-
import { createContext, useContext, useEffect, useId, useMemo, useRef } from "react";
|
|
8
|
-
import { jsx } from "react/jsx-runtime";
|
|
8
|
+
import { createContext, useContext, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
9
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
10
|
//#region src/dynamic-notification.tsx
|
|
10
11
|
const DynamicNotificationShellContext = createContext(null);
|
|
11
12
|
const DynamicNotificationReplyContext = createContext(null);
|
|
@@ -14,6 +15,12 @@ function resolveNotificationState(open, loading) {
|
|
|
14
15
|
if (loading) return "thinking";
|
|
15
16
|
return "expanded";
|
|
16
17
|
}
|
|
18
|
+
function resolveAnnouncement({ state, loading, replyFailed, message, thinkingLabel, replyErrorLabel }) {
|
|
19
|
+
if (replyFailed) return replyErrorLabel;
|
|
20
|
+
if (loading) return thinkingLabel;
|
|
21
|
+
if (state === "expanded") return message;
|
|
22
|
+
return "";
|
|
23
|
+
}
|
|
17
24
|
function useDynamicNotificationShellContext() {
|
|
18
25
|
const context = useContext(DynamicNotificationShellContext);
|
|
19
26
|
if (!context) throw new Error("DynamicNotification compound components must be rendered inside <DynamicNotification>.");
|
|
@@ -32,7 +39,7 @@ function useDynamicNotificationContext() {
|
|
|
32
39
|
...reply
|
|
33
40
|
};
|
|
34
41
|
}
|
|
35
|
-
function DynamicNotification({ open, defaultOpen, onOpenChange, loading = false, replyValue, defaultReplyValue, onReplyValueChange, onReply, variant = "surface", disabled = false, className, children, ...props }) {
|
|
42
|
+
function DynamicNotification({ open, defaultOpen, onOpenChange, loading = false, replyValue, defaultReplyValue, onReplyValueChange, onReply, variant = "surface", disabled = false, thinkingLabel = "Assistant is thinking", replyErrorLabel = "Couldn't send your reply. Try again.", className, children, ...props }) {
|
|
36
43
|
const notification = useDynamicNotification({
|
|
37
44
|
open,
|
|
38
45
|
defaultOpen,
|
|
@@ -44,14 +51,28 @@ function DynamicNotification({ open, defaultOpen, onOpenChange, loading = false,
|
|
|
44
51
|
disabled
|
|
45
52
|
});
|
|
46
53
|
const contentId = useId();
|
|
54
|
+
const [message, setMessage] = useState("");
|
|
55
|
+
const pillRef = useRef(null);
|
|
56
|
+
const focusReplyOnExpandRef = useRef(false);
|
|
47
57
|
const state = resolveNotificationState(notification.open, loading);
|
|
58
|
+
const announcement = resolveAnnouncement({
|
|
59
|
+
state,
|
|
60
|
+
loading,
|
|
61
|
+
replyFailed: notification.replyFailed,
|
|
62
|
+
message,
|
|
63
|
+
thinkingLabel,
|
|
64
|
+
replyErrorLabel
|
|
65
|
+
});
|
|
48
66
|
const shellContext = useMemo(() => ({
|
|
49
67
|
open: notification.open,
|
|
50
68
|
disabled: notification.disabled,
|
|
51
69
|
setOpen: notification.setOpen,
|
|
52
70
|
state,
|
|
53
71
|
variant,
|
|
54
|
-
contentId
|
|
72
|
+
contentId,
|
|
73
|
+
publishMessage: setMessage,
|
|
74
|
+
pillRef,
|
|
75
|
+
focusReplyOnExpandRef
|
|
55
76
|
}), [
|
|
56
77
|
notification.open,
|
|
57
78
|
notification.disabled,
|
|
@@ -65,6 +86,9 @@ function DynamicNotification({ open, defaultOpen, onOpenChange, loading = false,
|
|
|
65
86
|
setReply: notification.setReply,
|
|
66
87
|
normalizedReply: notification.normalizedReply,
|
|
67
88
|
canSubmit: notification.canSubmit,
|
|
89
|
+
replyPending: notification.replyPending,
|
|
90
|
+
replyFailed: notification.replyFailed,
|
|
91
|
+
replyErrorLabel,
|
|
68
92
|
clear: notification.clear,
|
|
69
93
|
submitReply: notification.submitReply,
|
|
70
94
|
handleReplySubmit: notification.handleReplySubmit
|
|
@@ -73,6 +97,9 @@ function DynamicNotification({ open, defaultOpen, onOpenChange, loading = false,
|
|
|
73
97
|
notification.setReply,
|
|
74
98
|
notification.normalizedReply,
|
|
75
99
|
notification.canSubmit,
|
|
100
|
+
notification.replyPending,
|
|
101
|
+
notification.replyFailed,
|
|
102
|
+
replyErrorLabel,
|
|
76
103
|
notification.clear,
|
|
77
104
|
notification.submitReply,
|
|
78
105
|
notification.handleReplySubmit
|
|
@@ -81,7 +108,7 @@ function DynamicNotification({ open, defaultOpen, onOpenChange, loading = false,
|
|
|
81
108
|
value: shellContext,
|
|
82
109
|
children: /* @__PURE__ */ jsx(DynamicNotificationReplyContext.Provider, {
|
|
83
110
|
value: replyContext,
|
|
84
|
-
children: /* @__PURE__ */
|
|
111
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
85
112
|
"data-control-ui": "dynamic-notification",
|
|
86
113
|
"data-control-family": "dynamic-notification",
|
|
87
114
|
"data-slot": "root",
|
|
@@ -89,7 +116,7 @@ function DynamicNotification({ open, defaultOpen, onOpenChange, loading = false,
|
|
|
89
116
|
"data-variant": variant,
|
|
90
117
|
className: cn("relative flex w-full justify-center", className),
|
|
91
118
|
...props,
|
|
92
|
-
children
|
|
119
|
+
children: [/* @__PURE__ */ jsx(LiveStatus, { message: announcement }), children]
|
|
93
120
|
})
|
|
94
121
|
})
|
|
95
122
|
});
|
|
@@ -152,14 +179,32 @@ function DynamicNotificationLiquid({ className, ...props }) {
|
|
|
152
179
|
...props
|
|
153
180
|
});
|
|
154
181
|
}
|
|
155
|
-
function DynamicNotificationPill({ className, children, onClick, ...props }) {
|
|
156
|
-
const { contentId, disabled, open, setOpen } = useDynamicNotificationShellContext();
|
|
182
|
+
function DynamicNotificationPill({ className, children, onClick, ref, ...props }) {
|
|
183
|
+
const { contentId, disabled, open, setOpen, pillRef, focusReplyOnExpandRef } = useDynamicNotificationShellContext();
|
|
184
|
+
useLayoutEffect(() => {
|
|
185
|
+
if (open) return;
|
|
186
|
+
focusReplyOnExpandRef.current = false;
|
|
187
|
+
const pill = pillRef.current;
|
|
188
|
+
const active = pill?.ownerDocument.activeElement;
|
|
189
|
+
if (!pill || !active || active === pill) return;
|
|
190
|
+
if (pill.closest("[data-slot=\"island\"]")?.contains(active)) pill.focus({ preventScroll: true });
|
|
191
|
+
}, [
|
|
192
|
+
open,
|
|
193
|
+
pillRef,
|
|
194
|
+
focusReplyOnExpandRef
|
|
195
|
+
]);
|
|
196
|
+
function setPillRef(node) {
|
|
197
|
+
pillRef.current = node;
|
|
198
|
+
if (typeof ref === "function") ref(node);
|
|
199
|
+
else if (ref) ref.current = node;
|
|
200
|
+
}
|
|
157
201
|
function handleClick(event) {
|
|
158
202
|
onClick?.(event);
|
|
159
203
|
if (event.defaultPrevented) return;
|
|
160
|
-
setOpen(true, "trigger-press", event.nativeEvent, event.currentTarget);
|
|
204
|
+
if (setOpen(true, "trigger-press", event.nativeEvent, event.currentTarget)) focusReplyOnExpandRef.current = true;
|
|
161
205
|
}
|
|
162
206
|
return /* @__PURE__ */ jsx("button", {
|
|
207
|
+
ref: setPillRef,
|
|
163
208
|
type: "button",
|
|
164
209
|
"aria-expanded": open,
|
|
165
210
|
"aria-controls": contentId,
|
|
@@ -207,14 +252,18 @@ function DynamicNotificationTitle({ className, ...props }) {
|
|
|
207
252
|
});
|
|
208
253
|
}
|
|
209
254
|
function DynamicNotificationMessage({ className, children, ...props }) {
|
|
255
|
+
const { publishMessage } = useDynamicNotificationShellContext();
|
|
256
|
+
useEffect(() => {
|
|
257
|
+
publishMessage(children);
|
|
258
|
+
return () => publishMessage("");
|
|
259
|
+
}, [children, publishMessage]);
|
|
210
260
|
return /* @__PURE__ */ jsx("p", {
|
|
211
|
-
"aria-live": "polite",
|
|
212
261
|
"data-control-ui": "dynamic-notification",
|
|
213
262
|
"data-control-family": "dynamic-notification",
|
|
214
263
|
"data-slot": "message",
|
|
215
264
|
className,
|
|
216
265
|
...props,
|
|
217
|
-
children: /* @__PURE__ */ jsx(DynamicNotificationWords, { text: children }
|
|
266
|
+
children: /* @__PURE__ */ jsx(DynamicNotificationWords, { text: children })
|
|
218
267
|
});
|
|
219
268
|
}
|
|
220
269
|
function DynamicNotificationWords({ text }) {
|
|
@@ -232,31 +281,45 @@ function DynamicNotificationWords({ text }) {
|
|
|
232
281
|
}, position);
|
|
233
282
|
});
|
|
234
283
|
}
|
|
235
|
-
function DynamicNotificationReply({ className, onSubmit, ...props }) {
|
|
236
|
-
const { handleReplySubmit } = useDynamicNotificationReplyContext();
|
|
284
|
+
function DynamicNotificationReply({ className, onSubmit, children, ...props }) {
|
|
285
|
+
const { handleReplySubmit, replyPending, replyFailed, replyErrorLabel } = useDynamicNotificationReplyContext();
|
|
286
|
+
const errorId = useId();
|
|
237
287
|
function handleSubmit(event) {
|
|
238
288
|
onSubmit?.(event);
|
|
239
289
|
if (event.defaultPrevented) return;
|
|
240
290
|
handleReplySubmit(event);
|
|
241
291
|
}
|
|
242
|
-
return /* @__PURE__ */
|
|
292
|
+
return /* @__PURE__ */ jsxs("form", {
|
|
293
|
+
"aria-busy": replyPending || void 0,
|
|
294
|
+
"aria-describedby": replyFailed ? errorId : void 0,
|
|
243
295
|
"data-control-ui": "dynamic-notification",
|
|
244
296
|
"data-control-family": "dynamic-notification",
|
|
245
297
|
"data-slot": "reply",
|
|
246
298
|
onSubmit: handleSubmit,
|
|
247
|
-
className: cn("flex items-center", className),
|
|
248
|
-
...props
|
|
299
|
+
className: cn("flex flex-wrap items-center", className),
|
|
300
|
+
...props,
|
|
301
|
+
children: [children, replyFailed ? /* @__PURE__ */ jsx("p", {
|
|
302
|
+
id: errorId,
|
|
303
|
+
"data-control-ui": "dynamic-notification",
|
|
304
|
+
"data-control-family": "dynamic-notification",
|
|
305
|
+
"data-slot": "reply-error",
|
|
306
|
+
className: "basis-full",
|
|
307
|
+
children: replyErrorLabel
|
|
308
|
+
}) : null]
|
|
249
309
|
});
|
|
250
310
|
}
|
|
251
311
|
function DynamicNotificationReplyInput({ className, onChange, disabled, ...props }) {
|
|
252
|
-
const { disabled: contextDisabled, state } = useDynamicNotificationShellContext();
|
|
312
|
+
const { disabled: contextDisabled, state, focusReplyOnExpandRef } = useDynamicNotificationShellContext();
|
|
253
313
|
const { reply, setReply } = useDynamicNotificationReplyContext();
|
|
254
314
|
const inputRef = useRef(null);
|
|
255
315
|
useEffect(() => {
|
|
256
|
-
if (state !== "expanded") return;
|
|
257
|
-
const frame = requestAnimationFrame(() =>
|
|
316
|
+
if (state !== "expanded" || !focusReplyOnExpandRef.current) return;
|
|
317
|
+
const frame = requestAnimationFrame(() => {
|
|
318
|
+
focusReplyOnExpandRef.current = false;
|
|
319
|
+
inputRef.current?.focus({ preventScroll: true });
|
|
320
|
+
});
|
|
258
321
|
return () => cancelAnimationFrame(frame);
|
|
259
|
-
}, [state]);
|
|
322
|
+
}, [state, focusReplyOnExpandRef]);
|
|
260
323
|
function handleChange(event) {
|
|
261
324
|
onChange?.(event);
|
|
262
325
|
if (!event.defaultPrevented) setReply(event.currentTarget.value);
|
|
@@ -305,7 +368,7 @@ function DynamicNotificationReplySubmit({ className, disabled, children, ...prop
|
|
|
305
368
|
})
|
|
306
369
|
});
|
|
307
370
|
}
|
|
308
|
-
function DynamicNotificationClose({ className, children, onClick, ...props }) {
|
|
371
|
+
function DynamicNotificationClose({ className, children, onClick, collapseLabel = "Collapse notification", ...props }) {
|
|
309
372
|
const { setOpen } = useDynamicNotificationShellContext();
|
|
310
373
|
function handleClick(event) {
|
|
311
374
|
onClick?.(event);
|
|
@@ -320,7 +383,7 @@ function DynamicNotificationClose({ className, children, onClick, ...props }) {
|
|
|
320
383
|
size: "sm",
|
|
321
384
|
iconOnly: true,
|
|
322
385
|
shape: "circle",
|
|
323
|
-
"aria-label":
|
|
386
|
+
"aria-label": collapseLabel,
|
|
324
387
|
onClick: handleClick,
|
|
325
388
|
className: cn("shrink-0", className),
|
|
326
389
|
...props,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EmailColorScheme } from "./theme.js";
|
|
2
|
-
import { EmailFooterPlacement } from "./email.js";
|
|
2
|
+
import { EmailDirection, EmailFooterPlacement } from "./email.js";
|
|
3
3
|
import { EmailFooterAlign, EmailNavLink, EmailSocialLink } from "./email-footer.js";
|
|
4
4
|
import { ReactNode } from "react";
|
|
5
5
|
//#region src/email/email-brand.d.ts
|
|
@@ -43,18 +43,21 @@ export declare function EmailBrowserLink({ href, children }: {
|
|
|
43
43
|
children?: ReactNode;
|
|
44
44
|
}): import("react").JSX.Element;
|
|
45
45
|
export type EmailHeaderAlign = "split" | "center";
|
|
46
|
-
export declare function EmailHeader({ children, aside, align }: {
|
|
46
|
+
export declare function EmailHeader({ children, aside, align, dir }: {
|
|
47
47
|
children: ReactNode;
|
|
48
48
|
aside?: ReactNode;
|
|
49
49
|
align?: EmailHeaderAlign;
|
|
50
|
+
dir?: EmailDirection;
|
|
50
51
|
}): import("react").JSX.Element;
|
|
51
|
-
export declare function EmailBrandHeader({ brand, browserUrl, colorScheme, align }: {
|
|
52
|
+
export declare function EmailBrandHeader({ brand, browserUrl, colorScheme, align, dir }: {
|
|
52
53
|
brand: EmailBrand;
|
|
53
54
|
browserUrl?: string;
|
|
54
55
|
colorScheme?: EmailColorScheme;
|
|
55
56
|
align?: EmailHeaderAlign;
|
|
57
|
+
dir?: EmailDirection;
|
|
56
58
|
}): import("react").JSX.Element;
|
|
57
|
-
export declare function EmailBrandFooter({ footer }: {
|
|
59
|
+
export declare function EmailBrandFooter({ footer, dir }: {
|
|
58
60
|
footer: EmailFooterContent;
|
|
61
|
+
dir?: EmailDirection;
|
|
59
62
|
}): import("react").JSX.Element;
|
|
60
63
|
//#endregion
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EmailCaption, EmailMutedLink, EmailSection } from "./email.js";
|
|
1
|
+
import { EmailCaption, EmailMutedLink, EmailSection, emailSides } from "./email.js";
|
|
2
2
|
import { EmailAddress, EmailFooter, EmailFooterLegal, EmailFooterLinks, EmailSocialLinks, EmailUnsubscribe } from "./email-footer.js";
|
|
3
3
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
4
|
import { Column, Img, Link, Row } from "react-email";
|
|
@@ -26,7 +26,7 @@ function EmailBrowserLink({ href, children = "View in browser" }) {
|
|
|
26
26
|
children
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
|
-
function EmailHeader({ children, aside, align = "split" }) {
|
|
29
|
+
function EmailHeader({ children, aside, align = "split", dir }) {
|
|
30
30
|
if (align === "center") return /* @__PURE__ */ jsxs(EmailSection, {
|
|
31
31
|
align: "center",
|
|
32
32
|
className: "mb-8",
|
|
@@ -42,16 +42,17 @@ function EmailHeader({ children, aside, align = "split" }) {
|
|
|
42
42
|
className: "align-middle",
|
|
43
43
|
children
|
|
44
44
|
}), aside ? /* @__PURE__ */ jsx(Column, {
|
|
45
|
-
align:
|
|
45
|
+
align: emailSides(dir).end,
|
|
46
46
|
className: "align-middle",
|
|
47
47
|
children: aside
|
|
48
48
|
}) : null]
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
|
-
function EmailBrandHeader({ brand, browserUrl, colorScheme = "light", align = "split" }) {
|
|
51
|
+
function EmailBrandHeader({ brand, browserUrl, colorScheme = "light", align = "split", dir }) {
|
|
52
52
|
const logoUrl = colorScheme === "dark" ? brand.logoDarkUrl ?? brand.logoUrl : brand.logoUrl;
|
|
53
53
|
return /* @__PURE__ */ jsx(EmailHeader, {
|
|
54
54
|
align,
|
|
55
|
+
dir,
|
|
55
56
|
aside: browserUrl ? /* @__PURE__ */ jsx(EmailBrowserLink, { href: browserUrl }) : null,
|
|
56
57
|
children: /* @__PURE__ */ jsx(EmailLogo, {
|
|
57
58
|
name: brand.name,
|
|
@@ -62,14 +63,16 @@ function EmailBrandHeader({ brand, browserUrl, colorScheme = "light", align = "s
|
|
|
62
63
|
})
|
|
63
64
|
});
|
|
64
65
|
}
|
|
65
|
-
function EmailBrandFooter({ footer }) {
|
|
66
|
+
function EmailBrandFooter({ footer, dir }) {
|
|
66
67
|
return /* @__PURE__ */ jsxs(EmailFooter, {
|
|
67
68
|
align: footer.align,
|
|
68
69
|
placement: footer.placement,
|
|
70
|
+
dir,
|
|
69
71
|
children: [
|
|
70
72
|
/* @__PURE__ */ jsx(EmailSocialLinks, {
|
|
71
73
|
links: footer.socialLinks,
|
|
72
|
-
iconBaseUrl: footer.socialIconBaseUrl
|
|
74
|
+
iconBaseUrl: footer.socialIconBaseUrl,
|
|
75
|
+
dir
|
|
73
76
|
}),
|
|
74
77
|
/* @__PURE__ */ jsx(EmailFooterLinks, { links: footer.helpLinks }),
|
|
75
78
|
/* @__PURE__ */ jsx(EmailCaption, {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EmailTheme } from "./theme.js";
|
|
2
|
-
import { EmailVariant } from "./email.js";
|
|
2
|
+
import { EmailDirection, EmailVariant } from "./email.js";
|
|
3
3
|
import { CodeInlineProps, PrismLanguage } from "react-email";
|
|
4
4
|
//#region src/email/email-code.d.ts
|
|
5
5
|
export declare function EmailInlineCode({ className, ...props }: CodeInlineProps): import("react").JSX.Element;
|
|
@@ -10,9 +10,10 @@ export declare function EmailCodeBlock({ theme, code, language, lineNumbers, cla
|
|
|
10
10
|
lineNumbers?: boolean;
|
|
11
11
|
className?: string;
|
|
12
12
|
}): import("react").JSX.Element;
|
|
13
|
-
export declare function EmailMarkdown({ theme, variant, children }: {
|
|
13
|
+
export declare function EmailMarkdown({ theme, variant, dir, children }: {
|
|
14
14
|
theme: EmailTheme;
|
|
15
15
|
variant?: EmailVariant;
|
|
16
|
+
dir?: EmailDirection;
|
|
16
17
|
children: string;
|
|
17
18
|
}): import("react").JSX.Element;
|
|
18
19
|
//#endregion
|
package/dist/email/email-code.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { surfaceColors } from "./email.js";
|
|
1
|
+
import { emailSides, surfaceColors } from "./email.js";
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
3
|
import { CodeBlock, CodeInline, Markdown, Section } from "react-email";
|
|
4
4
|
//#region src/email/email-code.tsx
|
|
@@ -62,7 +62,7 @@ function EmailCodeBlock({ theme, code, language, lineNumbers = false, className
|
|
|
62
62
|
})
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
|
-
function markdownStyles(theme, variant) {
|
|
65
|
+
function markdownStyles(theme, variant, sides) {
|
|
66
66
|
const colors = surfaceColors(theme, variant);
|
|
67
67
|
const body = {
|
|
68
68
|
margin: "0 0 16px",
|
|
@@ -90,6 +90,8 @@ function markdownStyles(theme, variant) {
|
|
|
90
90
|
color: theme.code.foreground,
|
|
91
91
|
borderRadius: theme.radii.control
|
|
92
92
|
};
|
|
93
|
+
const startInset = (length) => sides.start === "left" ? { paddingLeft: length } : { paddingRight: length };
|
|
94
|
+
const startRule = `3px solid ${theme.colors.border}`;
|
|
93
95
|
return {
|
|
94
96
|
p: body,
|
|
95
97
|
li: {
|
|
@@ -98,11 +100,11 @@ function markdownStyles(theme, variant) {
|
|
|
98
100
|
},
|
|
99
101
|
ul: {
|
|
100
102
|
...body,
|
|
101
|
-
|
|
103
|
+
...startInset("20px")
|
|
102
104
|
},
|
|
103
105
|
ol: {
|
|
104
106
|
...body,
|
|
105
|
-
|
|
107
|
+
...startInset("20px")
|
|
106
108
|
},
|
|
107
109
|
h1: headingStyle("heading-1"),
|
|
108
110
|
h2: headingStyle("heading-2"),
|
|
@@ -129,8 +131,8 @@ function markdownStyles(theme, variant) {
|
|
|
129
131
|
},
|
|
130
132
|
blockQuote: {
|
|
131
133
|
...body,
|
|
132
|
-
borderLeft:
|
|
133
|
-
|
|
134
|
+
...sides.start === "left" ? { borderLeft: startRule } : { borderRight: startRule },
|
|
135
|
+
...startInset("16px"),
|
|
134
136
|
color: colors["muted-foreground"]
|
|
135
137
|
},
|
|
136
138
|
hr: {
|
|
@@ -150,7 +152,7 @@ function markdownStyles(theme, variant) {
|
|
|
150
152
|
th: {
|
|
151
153
|
...body,
|
|
152
154
|
margin: "0",
|
|
153
|
-
textAlign:
|
|
155
|
+
textAlign: sides.start,
|
|
154
156
|
padding: "8px 0",
|
|
155
157
|
borderBottom: `1px solid ${theme.colors.border}`
|
|
156
158
|
},
|
|
@@ -162,9 +164,9 @@ function markdownStyles(theme, variant) {
|
|
|
162
164
|
}
|
|
163
165
|
};
|
|
164
166
|
}
|
|
165
|
-
function EmailMarkdown({ theme, variant = "contained", children }) {
|
|
167
|
+
function EmailMarkdown({ theme, variant = "contained", dir, children }) {
|
|
166
168
|
return /* @__PURE__ */ jsx(Markdown, {
|
|
167
|
-
markdownCustomStyles: markdownStyles(theme, variant),
|
|
169
|
+
markdownCustomStyles: markdownStyles(theme, variant, emailSides(dir)),
|
|
168
170
|
children
|
|
169
171
|
});
|
|
170
172
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EmailFooterPlacement } from "./email.js";
|
|
1
|
+
import { EmailDirection, EmailFooterPlacement } from "./email.js";
|
|
2
2
|
import { ReactNode } from "react";
|
|
3
3
|
//#region src/email/email-footer.d.ts
|
|
4
4
|
export type EmailNavLink = {
|
|
@@ -33,19 +33,21 @@ export type EmailSocialLink = {
|
|
|
33
33
|
iconUrl?: string;
|
|
34
34
|
});
|
|
35
35
|
export type EmailFooterAlign = "start" | "center";
|
|
36
|
-
export declare function EmailFooter({ children, align, placement }: {
|
|
36
|
+
export declare function EmailFooter({ children, align, placement, dir }: {
|
|
37
37
|
children: ReactNode;
|
|
38
38
|
align?: EmailFooterAlign;
|
|
39
39
|
placement?: EmailFooterPlacement;
|
|
40
|
+
dir?: EmailDirection;
|
|
40
41
|
}): import("react").JSX.Element;
|
|
41
42
|
export declare function EmailFooterLegal({ children, className }: {
|
|
42
43
|
children: ReactNode;
|
|
43
44
|
className?: string;
|
|
44
45
|
}): import("react").JSX.Element;
|
|
45
|
-
export declare function EmailSocialLinks({ links, iconBaseUrl, iconSize }: {
|
|
46
|
+
export declare function EmailSocialLinks({ links, iconBaseUrl, iconSize, dir }: {
|
|
46
47
|
links: EmailSocialLink[];
|
|
47
48
|
iconBaseUrl?: string;
|
|
48
49
|
iconSize?: number;
|
|
50
|
+
dir?: EmailDirection;
|
|
49
51
|
}): import("react").JSX.Element | null;
|
|
50
52
|
export declare function EmailFooterLinks({ links }: {
|
|
51
53
|
links: EmailNavLink[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EmailCaption, EmailDivider, EmailMutedLink } from "./email.js";
|
|
1
|
+
import { EmailCaption, EmailDivider, EmailMutedLink, emailAlignClass, emailSides } from "./email.js";
|
|
2
2
|
import { Fragment } from "react";
|
|
3
3
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
4
4
|
import { Img, Section } from "react-email";
|
|
@@ -23,9 +23,10 @@ function separatedLinks(links) {
|
|
|
23
23
|
children: link.label
|
|
24
24
|
})] }, link.href));
|
|
25
25
|
}
|
|
26
|
-
function EmailFooter({ children, align = "start", placement = "inside" }) {
|
|
26
|
+
function EmailFooter({ children, align = "start", placement = "inside", dir }) {
|
|
27
|
+
const alignClass = emailAlignClass(align, dir);
|
|
27
28
|
return /* @__PURE__ */ jsxs(Fragment$1, { children: [placement === "inside" ? /* @__PURE__ */ jsx(EmailDivider, {}) : null, /* @__PURE__ */ jsx(Section, {
|
|
28
|
-
className: `${placement === "inside" ? "" : "pt-6"} ${
|
|
29
|
+
className: `${placement === "inside" ? "" : "pt-6"} ${alignClass}`,
|
|
29
30
|
children
|
|
30
31
|
})] });
|
|
31
32
|
}
|
|
@@ -44,13 +45,18 @@ function resolveSocialLink(link, iconBaseUrl) {
|
|
|
44
45
|
alt: link.iconAlt ?? label
|
|
45
46
|
};
|
|
46
47
|
}
|
|
47
|
-
|
|
48
|
+
const socialGapClasses = {
|
|
49
|
+
left: "ml-3",
|
|
50
|
+
right: "mr-3"
|
|
51
|
+
};
|
|
52
|
+
function EmailSocialLinks({ links, iconBaseUrl, iconSize = 24, dir }) {
|
|
53
|
+
const sides = emailSides(dir);
|
|
48
54
|
if (links.length === 0) return null;
|
|
49
55
|
return /* @__PURE__ */ jsx(Section, {
|
|
50
56
|
className: "mb-4",
|
|
51
57
|
children: links.map((link, index) => {
|
|
52
58
|
const { label, iconUrl, alt } = resolveSocialLink(link, iconBaseUrl);
|
|
53
|
-
const spacing = index < links.length - 1 ?
|
|
59
|
+
const spacing = index < links.length - 1 ? socialGapClasses[sides.end] : "";
|
|
54
60
|
return /* @__PURE__ */ jsxs(Fragment, { children: [index > 0 ? " " : null, /* @__PURE__ */ jsx(EmailMutedLink, {
|
|
55
61
|
href: link.href,
|
|
56
62
|
className: `${iconUrl ? "no-underline" : "underline"} ${spacing}`,
|
package/dist/email/email.d.ts
CHANGED
|
@@ -4,6 +4,19 @@ import { ButtonProps, HeadingProps, HrProps, LinkProps, SectionProps, TextProps
|
|
|
4
4
|
//#region src/email/email.d.ts
|
|
5
5
|
export type EmailVariant = "contained" | "plain";
|
|
6
6
|
export type EmailFooterPlacement = "inside" | "outside";
|
|
7
|
+
export type EmailDirection = "ltr" | "rtl";
|
|
8
|
+
declare const physicalSides: {
|
|
9
|
+
readonly ltr: {
|
|
10
|
+
readonly start: "left";
|
|
11
|
+
readonly end: "right";
|
|
12
|
+
};
|
|
13
|
+
readonly rtl: {
|
|
14
|
+
readonly start: "right";
|
|
15
|
+
readonly end: "left";
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
export type EmailSides = (typeof physicalSides)[EmailDirection];
|
|
19
|
+
export declare function emailSides(dir?: EmailDirection): EmailSides;
|
|
7
20
|
export declare function surfaceColors(theme: EmailTheme, variant: EmailVariant): Record<"background" | "border" | "card" | "card-foreground" | "foreground" | "muted" | "muted-foreground" | "primary" | "primary-foreground" | "primary-text", string>;
|
|
8
21
|
export declare function EmailLayout({ theme, preview, children, footer, footerPlacement, head, lang, dir, variant }: {
|
|
9
22
|
theme: EmailTheme;
|
|
@@ -13,10 +26,11 @@ export declare function EmailLayout({ theme, preview, children, footer, footerPl
|
|
|
13
26
|
footerPlacement?: EmailFooterPlacement;
|
|
14
27
|
head?: ReactNode;
|
|
15
28
|
lang?: string;
|
|
16
|
-
dir?:
|
|
29
|
+
dir?: EmailDirection;
|
|
17
30
|
variant?: EmailVariant;
|
|
18
31
|
}): import("react").JSX.Element;
|
|
19
|
-
export type EmailAlign = "
|
|
32
|
+
export type EmailAlign = "start" | "center" | "end";
|
|
33
|
+
export declare function emailAlignClass(align: EmailAlign | undefined, dir?: EmailDirection): string;
|
|
20
34
|
declare const headingSizeClasses: {
|
|
21
35
|
display: string;
|
|
22
36
|
"heading-1": string;
|
|
@@ -31,24 +45,29 @@ declare const headingSizeForTag: {
|
|
|
31
45
|
readonly h3: "heading-3";
|
|
32
46
|
readonly h4: "heading-4";
|
|
33
47
|
};
|
|
34
|
-
export declare function EmailHeading({ as, size, align, className, ...props }: Omit<HeadingProps, "as"> & {
|
|
48
|
+
export declare function EmailHeading({ as, size, align, dir, className, ...props }: Omit<HeadingProps, "as" | "dir"> & {
|
|
35
49
|
as?: keyof typeof headingSizeForTag;
|
|
36
50
|
size?: EmailHeadingSize;
|
|
37
51
|
align?: EmailAlign;
|
|
52
|
+
dir?: EmailDirection;
|
|
38
53
|
}): import("react").JSX.Element;
|
|
39
|
-
export declare function EmailSection({ align, className, ...props }: SectionProps & {
|
|
54
|
+
export declare function EmailSection({ align, dir, className, ...props }: Omit<SectionProps, "dir"> & {
|
|
40
55
|
align?: EmailAlign;
|
|
56
|
+
dir?: EmailDirection;
|
|
41
57
|
}): import("react").JSX.Element;
|
|
42
|
-
export declare function EmailText({ tone, align, className, style, ...props }: TextProps & {
|
|
58
|
+
export declare function EmailText({ tone, align, dir, className, style, ...props }: Omit<TextProps, "dir"> & {
|
|
43
59
|
tone?: "default" | "muted";
|
|
44
60
|
align?: EmailAlign;
|
|
61
|
+
dir?: EmailDirection;
|
|
45
62
|
}): import("react").JSX.Element;
|
|
46
63
|
export declare function EmailButton({ width, className, ...props }: ButtonProps & {
|
|
47
64
|
width?: "auto" | "full";
|
|
48
65
|
}): import("react").JSX.Element;
|
|
49
66
|
export declare function EmailLink({ className, ...props }: LinkProps): import("react").JSX.Element;
|
|
50
|
-
export declare function EmailCaption({ className, ...props }: TextProps & {
|
|
67
|
+
export declare function EmailCaption({ eyebrow, className, ...props }: Omit<TextProps, "dir"> & {
|
|
51
68
|
align?: EmailAlign;
|
|
69
|
+
dir?: EmailDirection;
|
|
70
|
+
eyebrow?: boolean;
|
|
52
71
|
}): import("react").JSX.Element;
|
|
53
72
|
export declare function EmailMutedLink({ className, ...props }: LinkProps): import("react").JSX.Element;
|
|
54
73
|
export declare function EmailDivider({ className, ...props }: HrProps): import("react").JSX.Element;
|
|
@@ -57,20 +76,23 @@ export declare function EmailOneTimeCode({ children, className }: {
|
|
|
57
76
|
children: ReactNode;
|
|
58
77
|
className?: string;
|
|
59
78
|
}): import("react").JSX.Element;
|
|
60
|
-
export declare function EmailBulletList({ items, className }: {
|
|
79
|
+
export declare function EmailBulletList({ items, dir, className }: {
|
|
61
80
|
items: ReactNode[];
|
|
81
|
+
dir?: EmailDirection;
|
|
62
82
|
className?: string;
|
|
63
83
|
}): import("react").JSX.Element | null;
|
|
64
|
-
export declare function EmailColumns({ children, widths, gap, verticalAlign, className }: {
|
|
84
|
+
export declare function EmailColumns({ children, widths, gap, verticalAlign, dir, className }: {
|
|
65
85
|
children: ReactNode[];
|
|
66
86
|
widths?: string[];
|
|
67
87
|
gap?: number;
|
|
68
88
|
verticalAlign?: "top" | "middle" | "bottom";
|
|
89
|
+
dir?: EmailDirection;
|
|
69
90
|
className?: string;
|
|
70
91
|
}): import("react").JSX.Element | null;
|
|
71
|
-
export declare function EmailDetailRow({ label, value, emphasis }: {
|
|
92
|
+
export declare function EmailDetailRow({ label, value, emphasis, dir }: {
|
|
72
93
|
label: ReactNode;
|
|
73
94
|
value: ReactNode;
|
|
74
95
|
emphasis?: boolean;
|
|
96
|
+
dir?: EmailDirection;
|
|
75
97
|
}): import("react").JSX.Element;
|
|
76
98
|
//#endregion
|