@hanzo/ui 4.5.3 → 4.6.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/README-MCP.md +3 -3
- package/README.md +229 -0
- package/assets/ai-icons.tsx +207 -0
- package/assets/crypto.tsx +33 -0
- package/assets/file-type-icon.tsx +66 -0
- package/assets/file.tsx +45 -0
- package/assets/general.tsx +2318 -0
- package/assets/hanzo-logo.svg +9 -0
- package/assets/hanzo-logo.tsx +15 -0
- package/assets/index.ts +8 -0
- package/assets/index.tsx +4 -0
- package/assets/llm-provider.tsx +1094 -0
- package/bin/create-registry.js +1 -1
- package/bin/test-mcp.sh +1 -1
- package/bin/update-registry.js +2 -2
- package/blocks/components/content.tsx +1 -1
- package/blocks/components/grid-block/index.tsx +1 -1
- package/blocks/components/screenful-block/content.tsx +1 -1
- package/blocks/components/screenful-block/poster-background.tsx +1 -1
- package/components/index.ts +56 -0
- package/dist/button.d.ts +1 -0
- package/dist/button.js +1 -0
- package/dist/hooks/index.d.ts +7 -0
- package/dist/hooks/index.js +7 -0
- package/dist/hooks/use-click-away.d.ts +2 -0
- package/dist/hooks/use-click-away.js +23 -0
- package/dist/hooks/use-combined-refs.d.ts +3 -0
- package/dist/hooks/use-combined-refs.js +18 -0
- package/dist/hooks/use-copy-clipboard.d.ts +9 -0
- package/dist/hooks/use-copy-clipboard.js +21 -0
- package/dist/hooks/use-debounce.d.ts +1 -0
- package/dist/hooks/use-debounce.js +13 -0
- package/dist/hooks/use-fill-ids.d.ts +8 -0
- package/dist/hooks/use-fill-ids.js +20 -0
- package/dist/hooks/use-map.d.ts +1 -0
- package/dist/hooks/use-map.js +20 -0
- package/dist/hooks/use-measure.d.ts +8 -0
- package/dist/hooks/use-measure.js +25 -0
- package/dist/hooks/use-reverse-video-playback.d.ts +1 -0
- package/dist/hooks/use-reverse-video-playback.js +41 -0
- package/dist/hooks/use-scroll-restoration.d.ts +8 -0
- package/dist/hooks/use-scroll-restoration.js +36 -0
- package/dist/mcp/enhanced-server.js +3 -3
- package/dist/mcp/index.js +1 -1
- package/dist/registry/api.d.ts +1 -1
- package/dist/registry/api.js +3 -4
- package/dist/registry/index.d.ts +348 -4
- package/dist/registry/index.js +3 -3
- package/dist/utils.d.ts +1 -0
- package/dist/utils.js +1 -0
- package/helpers/file.ts +33 -0
- package/helpers/memoization.ts +40 -0
- package/package.json +27 -6
- package/primitives/accordion.tsx +53 -45
- package/primitives/alert-dialog.tsx +185 -0
- package/primitives/alert.tsx +74 -0
- package/primitives/apply-typography.tsx +1 -1
- package/primitives/avatar.tsx +37 -29
- package/primitives/background-beams.tsx +142 -0
- package/primitives/badge.tsx +27 -19
- package/primitives/breadcrumb.tsx +77 -62
- package/primitives/button.tsx +69 -72
- package/primitives/card.tsx +73 -59
- package/primitives/chat/chat-input-area.tsx +87 -0
- package/primitives/chat/chat-input.tsx +71 -0
- package/primitives/chat/files-preview.tsx +330 -0
- package/primitives/chat/index.ts +6 -0
- package/primitives/chat/json-form.tsx +8 -0
- package/primitives/chat/message-list.tsx +307 -0
- package/primitives/chat/message.tsx +569 -0
- package/primitives/chat/sqlite-preview.tsx +215 -0
- package/primitives/checkbox.tsx +18 -19
- package/primitives/collapsible.tsx +9 -0
- package/primitives/command.tsx +75 -83
- package/primitives/context-menu.tsx +115 -109
- package/primitives/copy-to-clipboard-icon.tsx +60 -0
- package/primitives/dialog-video-controller.tsx +1 -1
- package/primitives/dialog.tsx +111 -145
- package/primitives/dot-pattern.tsx +57 -0
- package/primitives/dots-loader.tsx +13 -0
- package/primitives/drawer.tsx +59 -87
- package/primitives/dropdown-menu.tsx +199 -0
- package/primitives/error-message.tsx +19 -0
- package/primitives/file-uploader.tsx +200 -0
- package/primitives/form.tsx +92 -87
- package/primitives/hover-card.tsx +28 -0
- package/primitives/icons/github.tsx +1 -1
- package/primitives/icons/youtube-logo.tsx +1 -1
- package/primitives/index-common.ts +121 -42
- package/primitives/index-next.ts +3 -1
- package/primitives/input.tsx +115 -20
- package/primitives/label.tsx +15 -23
- package/primitives/loading-spinner.tsx +1 -1
- package/primitives/markdown-preview.tsx +609 -0
- package/primitives/mermaid.tsx +196 -0
- package/primitives/next/link-element.tsx +1 -1
- package/primitives/next/mdx-link.tsx +1 -1
- package/primitives/pagination.tsx +117 -0
- package/primitives/popover.tsx +20 -25
- package/primitives/pretty-json-print.tsx +28 -0
- package/primitives/progress.tsx +14 -15
- package/primitives/prompt-textarea.tsx +72 -0
- package/primitives/qr-code.tsx +112 -0
- package/primitives/radio-group.tsx +25 -39
- package/primitives/resizable.tsx +47 -0
- package/primitives/scroll-area.tsx +35 -25
- package/primitives/search-input.tsx +66 -0
- package/primitives/select.tsx +62 -109
- package/primitives/separator.tsx +22 -26
- package/primitives/sheet.tsx +78 -117
- package/primitives/skeleton.tsx +13 -16
- package/primitives/slider.tsx +50 -60
- package/primitives/stepper.tsx +272 -0
- package/primitives/switch.tsx +14 -23
- package/primitives/table.tsx +65 -77
- package/primitives/tabs.tsx +29 -39
- package/primitives/text-link.tsx +25 -0
- package/primitives/textarea.tsx +61 -0
- package/primitives/textfield.tsx +75 -0
- package/primitives/toast.tsx +30 -0
- package/primitives/toggle-group.tsx +33 -33
- package/primitives/toggle.tsx +22 -51
- package/primitives/tooltip.tsx +37 -38
- package/registry.json +1 -1
- package/src/button.ts +1 -0
- package/src/hooks/index.ts +7 -0
- package/src/hooks/use-click-away.ts +31 -0
- package/src/hooks/use-combined-refs.ts +22 -0
- package/src/hooks/use-copy-clipboard.ts +30 -0
- package/src/hooks/use-debounce.ts +17 -0
- package/src/hooks/use-fill-ids.ts +25 -0
- package/src/hooks/use-map.ts +26 -0
- package/src/hooks/use-measure.ts +42 -0
- package/src/hooks/use-reverse-video-playback.ts +43 -0
- package/src/hooks/use-scroll-restoration.ts +50 -0
- package/{mcp → src/mcp}/README.md +1 -1
- package/{mcp → src/mcp}/enhanced-server.ts +2 -2
- package/{registry → src/registry}/api.ts +3 -3
- package/{registry → src/registry}/index.ts +3 -3
- package/src/utils.ts +1 -0
- package/style/theme-provider.tsx +1 -1
- package/test-imports.mjs +19 -0
- package/tsconfig.json +9 -4
- package/types/animation-def.ts +1 -1
- package/types/button-def.ts +1 -1
- package/types/index.ts +1 -1
- package/util/blob.ts +28 -0
- package/util/copy-to-clipboard.ts +17 -0
- package/util/create-shadow-root.ts +22 -0
- package/util/date.ts +83 -0
- package/util/debounce.ts +11 -0
- package/util/file.ts +15 -0
- package/util/format-and-abbreviate-as-currency.ts +1 -1
- package/util/format-text.ts +33 -0
- package/util/index.ts +9 -78
- package/util/timing.ts +3 -0
- package/util/toasts.tsx +17 -0
- package/utils.ts +9 -0
- package/dist/blocks/components/accordian-block.d.ts +0 -4
- package/dist/blocks/components/accordian-block.jsx +0 -25
- package/dist/blocks/components/block-component-props.d.ts +0 -7
- package/dist/blocks/components/block-component-props.js +0 -1
- package/dist/blocks/components/bullet-cards-block.d.ts +0 -4
- package/dist/blocks/components/bullet-cards-block.jsx +0 -25
- package/dist/blocks/components/card-block/index.d.ts +0 -6
- package/dist/blocks/components/card-block/index.jsx +0 -87
- package/dist/blocks/components/card-block/link-out-button.d.ts +0 -6
- package/dist/blocks/components/card-block/link-out-button.jsx +0 -4
- package/dist/blocks/components/card-block/util.d.ts +0 -4
- package/dist/blocks/components/card-block/util.js +0 -6
- package/dist/blocks/components/carte-blanche-block/index.d.ts +0 -4
- package/dist/blocks/components/carte-blanche-block/index.jsx +0 -82
- package/dist/blocks/components/carte-blanche-block/variant-content-left.d.ts +0 -10
- package/dist/blocks/components/carte-blanche-block/variant-content-left.jsx +0 -23
- package/dist/blocks/components/content.d.ts +0 -10
- package/dist/blocks/components/content.jsx +0 -47
- package/dist/blocks/components/cta-block.d.ts +0 -12
- package/dist/blocks/components/cta-block.jsx +0 -69
- package/dist/blocks/components/enh-heading-block.d.ts +0 -7
- package/dist/blocks/components/enh-heading-block.jsx +0 -142
- package/dist/blocks/components/grid-block/grid-block-mutator.d.ts +0 -5
- package/dist/blocks/components/grid-block/grid-block-mutator.js +0 -1
- package/dist/blocks/components/grid-block/index.d.ts +0 -9
- package/dist/blocks/components/grid-block/index.jsx +0 -56
- package/dist/blocks/components/grid-block/mutator-registry.d.ts +0 -3
- package/dist/blocks/components/grid-block/mutator-registry.js +0 -5
- package/dist/blocks/components/grid-block/table-borders.mutator.d.ts +0 -3
- package/dist/blocks/components/grid-block/table-borders.mutator.js +0 -36
- package/dist/blocks/components/group-block.d.ts +0 -7
- package/dist/blocks/components/group-block.jsx +0 -61
- package/dist/blocks/components/heading-block.d.ts +0 -4
- package/dist/blocks/components/heading-block.jsx +0 -99
- package/dist/blocks/components/image-block.d.ts +0 -7
- package/dist/blocks/components/image-block.jsx +0 -69
- package/dist/blocks/components/index.d.ts +0 -14
- package/dist/blocks/components/index.js +0 -13
- package/dist/blocks/components/screenful-block/content.d.ts +0 -8
- package/dist/blocks/components/screenful-block/content.jsx +0 -71
- package/dist/blocks/components/screenful-block/index.d.ts +0 -12
- package/dist/blocks/components/screenful-block/index.jsx +0 -57
- package/dist/blocks/components/screenful-block/poster-background.d.ts +0 -7
- package/dist/blocks/components/screenful-block/poster-background.jsx +0 -14
- package/dist/blocks/components/screenful-block/video-background.d.ts +0 -8
- package/dist/blocks/components/screenful-block/video-background.jsx +0 -20
- package/dist/blocks/components/space-block.d.ts +0 -4
- package/dist/blocks/components/space-block.jsx +0 -42
- package/dist/blocks/components/video-block.d.ts +0 -9
- package/dist/blocks/components/video-block.jsx +0 -83
- package/dist/blocks/def/accordian-block.d.ts +0 -10
- package/dist/blocks/def/accordian-block.js +0 -2
- package/dist/blocks/def/block.d.ts +0 -4
- package/dist/blocks/def/block.js +0 -1
- package/dist/blocks/def/bullet-cards-block.d.ts +0 -17
- package/dist/blocks/def/bullet-cards-block.js +0 -1
- package/dist/blocks/def/card-block.d.ts +0 -17
- package/dist/blocks/def/card-block.js +0 -2
- package/dist/blocks/def/carte-blanche-block.d.ts +0 -12
- package/dist/blocks/def/carte-blanche-block.js +0 -1
- package/dist/blocks/def/cta-block.d.ts +0 -8
- package/dist/blocks/def/cta-block.js +0 -1
- package/dist/blocks/def/element-block.d.ts +0 -7
- package/dist/blocks/def/element-block.js +0 -2
- package/dist/blocks/def/enh-heading-block.d.ts +0 -22
- package/dist/blocks/def/enh-heading-block.js +0 -1
- package/dist/blocks/def/grid-block.d.ts +0 -12
- package/dist/blocks/def/grid-block.js +0 -1
- package/dist/blocks/def/group-block.d.ts +0 -7
- package/dist/blocks/def/group-block.js +0 -1
- package/dist/blocks/def/heading-block.d.ts +0 -11
- package/dist/blocks/def/heading-block.js +0 -1
- package/dist/blocks/def/image-block.d.ts +0 -26
- package/dist/blocks/def/image-block.js +0 -1
- package/dist/blocks/def/index.d.ts +0 -17
- package/dist/blocks/def/index.js +0 -2
- package/dist/blocks/def/screenful-block.d.ts +0 -41
- package/dist/blocks/def/screenful-block.js +0 -1
- package/dist/blocks/def/space-block.d.ts +0 -47
- package/dist/blocks/def/space-block.js +0 -8
- package/dist/blocks/def/video-block.d.ts +0 -5
- package/dist/blocks/def/video-block.js +0 -1
- package/dist/blocks/index.d.ts +0 -2
- package/dist/blocks/index.js +0 -2
- package/dist/primitives/accordion.d.ts +0 -10
- package/dist/primitives/accordion.jsx +0 -21
- package/dist/primitives/action-button.d.ts +0 -9
- package/dist/primitives/action-button.jsx +0 -16
- package/dist/primitives/apply-typography.d.ts +0 -7
- package/dist/primitives/apply-typography.jsx +0 -38
- package/dist/primitives/aspect-ratio.d.ts +0 -3
- package/dist/primitives/aspect-ratio.jsx +0 -4
- package/dist/primitives/avatar.d.ts +0 -6
- package/dist/primitives/avatar.jsx +0 -11
- package/dist/primitives/badge.d.ts +0 -9
- package/dist/primitives/badge.jsx +0 -18
- package/dist/primitives/breadcrumb.d.ts +0 -19
- package/dist/primitives/breadcrumb.jsx +0 -27
- package/dist/primitives/breakpoint-indicator.d.ts +0 -3
- package/dist/primitives/breakpoint-indicator.jsx +0 -14
- package/dist/primitives/button.d.ts +0 -12
- package/dist/primitives/button.jsx +0 -55
- package/dist/primitives/calendar.d.ts +0 -8
- package/dist/primitives/calendar.jsx +0 -40
- package/dist/primitives/card.d.ts +0 -8
- package/dist/primitives/card.jsx +0 -18
- package/dist/primitives/carousel.d.ts +0 -18
- package/dist/primitives/carousel.jsx +0 -106
- package/dist/primitives/checkbox.d.ts +0 -4
- package/dist/primitives/checkbox.jsx +0 -15
- package/dist/primitives/combobox.d.ts +0 -41
- package/dist/primitives/combobox.jsx +0 -77
- package/dist/primitives/command.d.ts +0 -17
- package/dist/primitives/command.jsx +0 -38
- package/dist/primitives/context-menu.d.ts +0 -27
- package/dist/primitives/context-menu.jsx +0 -57
- package/dist/primitives/dialog-video-controller.d.ts +0 -3
- package/dist/primitives/dialog-video-controller.jsx +0 -24
- package/dist/primitives/dialog.d.ts +0 -28
- package/dist/primitives/dialog.jsx +0 -37
- package/dist/primitives/drawer.d.ts +0 -29
- package/dist/primitives/drawer.jsx +0 -34
- package/dist/primitives/form.d.ts +0 -12
- package/dist/primitives/form.jsx +0 -69
- package/dist/primitives/icons/github.d.ts +0 -4
- package/dist/primitives/icons/github.jsx +0 -6
- package/dist/primitives/icons/index.d.ts +0 -4
- package/dist/primitives/icons/index.js +0 -4
- package/dist/primitives/icons/youtube-logo.d.ts +0 -4
- package/dist/primitives/icons/youtube-logo.jsx +0 -39
- package/dist/primitives/index-common.d.ts +0 -47
- package/dist/primitives/index-common.js +0 -46
- package/dist/primitives/index-next.d.ts +0 -2
- package/dist/primitives/index-next.js +0 -2
- package/dist/primitives/input-otp.d.ts +0 -7
- package/dist/primitives/input-otp.jsx +0 -24
- package/dist/primitives/input.d.ts +0 -5
- package/dist/primitives/input.jsx +0 -11
- package/dist/primitives/label.d.ts +0 -5
- package/dist/primitives/label.jsx +0 -11
- package/dist/primitives/list-adaptor.d.ts +0 -9
- package/dist/primitives/list-adaptor.js +0 -1
- package/dist/primitives/list-box.d.ts +0 -10
- package/dist/primitives/list-box.jsx +0 -14
- package/dist/primitives/loading-spinner.d.ts +0 -5
- package/dist/primitives/loading-spinner.jsx +0 -8
- package/dist/primitives/navigation-menu.d.ts +0 -12
- package/dist/primitives/navigation-menu.jsx +0 -38
- package/dist/primitives/next/image.d.ts +0 -11
- package/dist/primitives/next/image.jsx +0 -42
- package/dist/primitives/next/index.d.ts +0 -7
- package/dist/primitives/next/index.js +0 -7
- package/dist/primitives/next/inline-icon.d.ts +0 -13
- package/dist/primitives/next/inline-icon.jsx +0 -15
- package/dist/primitives/next/link-element.d.ts +0 -23
- package/dist/primitives/next/link-element.jsx +0 -56
- package/dist/primitives/next/mdx-link.d.ts +0 -3
- package/dist/primitives/next/mdx-link.jsx +0 -12
- package/dist/primitives/next/media-stack.d.ts +0 -8
- package/dist/primitives/next/media-stack.jsx +0 -28
- package/dist/primitives/next/nav-items.d.ts +0 -10
- package/dist/primitives/next/nav-items.jsx +0 -24
- package/dist/primitives/next/youtube-embed.d.ts +0 -11
- package/dist/primitives/next/youtube-embed.jsx +0 -23
- package/dist/primitives/popover.d.ts +0 -9
- package/dist/primitives/popover.jsx +0 -18
- package/dist/primitives/progress.d.ts +0 -4
- package/dist/primitives/progress.jsx +0 -9
- package/dist/primitives/radio-group.d.ts +0 -7
- package/dist/primitives/radio-group.jsx +0 -18
- package/dist/primitives/scroll-area.d.ts +0 -5
- package/dist/primitives/scroll-area.jsx +0 -19
- package/dist/primitives/select.d.ts +0 -13
- package/dist/primitives/select.jsx +0 -62
- package/dist/primitives/separator.d.ts +0 -4
- package/dist/primitives/separator.jsx +0 -7
- package/dist/primitives/sheet.d.ts +0 -30
- package/dist/primitives/sheet.jsx +0 -56
- package/dist/primitives/skeleton.d.ts +0 -4
- package/dist/primitives/skeleton.jsx +0 -3
- package/dist/primitives/slider.d.ts +0 -9
- package/dist/primitives/slider.jsx +0 -30
- package/dist/primitives/sonner.d.ts +0 -5
- package/dist/primitives/sonner.jsx +0 -16
- package/dist/primitives/step-indicator.d.ts +0 -9
- package/dist/primitives/step-indicator.jsx +0 -23
- package/dist/primitives/switch.d.ts +0 -6
- package/dist/primitives/switch.jsx +0 -14
- package/dist/primitives/table.d.ts +0 -10
- package/dist/primitives/table.jsx +0 -21
- package/dist/primitives/tabs.d.ts +0 -7
- package/dist/primitives/tabs.jsx +0 -18
- package/dist/primitives/text-area.d.ts +0 -5
- package/dist/primitives/text-area.jsx +0 -9
- package/dist/primitives/toggle-group.d.ts +0 -14
- package/dist/primitives/toggle-group.jsx +0 -28
- package/dist/primitives/toggle.d.ts +0 -14
- package/dist/primitives/toggle.jsx +0 -52
- package/dist/primitives/tooltip.d.ts +0 -11
- package/dist/primitives/tooltip.jsx +0 -18
- package/dist/primitives/video-player.d.ts +0 -6
- package/dist/primitives/video-player.jsx +0 -8
- package/dist/style/theme-provider.d.ts +0 -4
- package/dist/style/theme-provider.jsx +0 -11
- package/dist/tailwind/fontFamily.tailwind.d.ts +0 -8
- package/dist/tailwind/fontFamily.tailwind.js +0 -7
- package/dist/tailwind/fontSize.tailwind.d.ts +0 -36
- package/dist/tailwind/fontSize.tailwind.js +0 -13
- package/dist/tailwind/index.d.ts +0 -3
- package/dist/tailwind/index.js +0 -2
- package/dist/tailwind/screens.tailwind.d.ts +0 -9
- package/dist/tailwind/screens.tailwind.js +0 -8
- package/dist/tailwind/tw-font-desc.d.ts +0 -6
- package/dist/tailwind/tw-font-desc.js +0 -6
- package/dist/types/animation-def.d.ts +0 -2
- package/dist/types/animation-def.js +0 -1
- package/dist/types/breakpoints.d.ts +0 -4
- package/dist/types/breakpoints.js +0 -4
- package/dist/types/bullet-item.d.ts +0 -6
- package/dist/types/bullet-item.js +0 -2
- package/dist/types/button-def.d.ts +0 -29
- package/dist/types/button-def.js +0 -2
- package/dist/types/dimensions.d.ts +0 -5
- package/dist/types/dimensions.js +0 -1
- package/dist/types/grid-def.d.ts +0 -36
- package/dist/types/grid-def.js +0 -33
- package/dist/types/image-def.d.ts +0 -27
- package/dist/types/image-def.js +0 -1
- package/dist/types/index.d.ts +0 -13
- package/dist/types/index.js +0 -2
- package/dist/types/link-def.d.ts +0 -44
- package/dist/types/link-def.js +0 -1
- package/dist/types/media-stack-def.d.ts +0 -25
- package/dist/types/media-stack-def.js +0 -1
- package/dist/types/t-shirt-size.d.ts +0 -2
- package/dist/types/t-shirt-size.js +0 -1
- package/dist/types/tshirt-dimensions.d.ts +0 -12
- package/dist/types/tshirt-dimensions.js +0 -1
- package/dist/types/video-def.d.ts +0 -9
- package/dist/types/video-def.js +0 -1
- package/dist/util/format-and-abbreviate-as-currency.d.ts +0 -11
- package/dist/util/format-and-abbreviate-as-currency.js +0 -91
- package/dist/util/format-to-max-char.d.ts +0 -5
- package/dist/util/format-to-max-char.js +0 -57
- package/dist/util/index-client.d.ts +0 -2
- package/dist/util/index-client.js +0 -3
- package/dist/util/index.d.ts +0 -17
- package/dist/util/index.js +0 -41
- package/dist/util/number-abbreviate.d.ts +0 -9
- package/dist/util/number-abbreviate.js +0 -30
- package/dist/util/specifier.d.ts +0 -7
- package/dist/util/specifier.js +0 -31
- package/dist/util/spread-to-transform.d.ts +0 -7
- package/dist/util/spread-to-transform.js +0 -18
- package/dist/util/step-animation.d.ts +0 -5
- package/dist/util/step-animation.js +0 -60
- package/dist/util/two-way-map.d.ts +0 -8
- package/dist/util/two-way-map.js +0 -16
- /package/{mcp → src/mcp}/index.ts +0 -0
- /package/{mcp → src/mcp}/package.json +0 -0
- /package/{registry → src/registry}/package.json +0 -0
package/util/blob.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Buffer } from 'buffer';
|
|
2
|
+
|
|
3
|
+
export const blobToBase64 = (blob: Blob): Promise<string> => {
|
|
4
|
+
const reader = new FileReader();
|
|
5
|
+
reader.readAsDataURL(blob);
|
|
6
|
+
return new Promise((resolve) => {
|
|
7
|
+
reader.onloadend = () => {
|
|
8
|
+
resolve(reader.result as string);
|
|
9
|
+
};
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const dataUrlToFile = (
|
|
14
|
+
dataUrl: string,
|
|
15
|
+
filename: string,
|
|
16
|
+
): File | undefined => {
|
|
17
|
+
const arr = dataUrl.split(',');
|
|
18
|
+
if (arr.length < 2) {
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
const mimeArr = arr[0].match(/:(.*?);/);
|
|
22
|
+
if (!mimeArr || mimeArr.length < 2) {
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
const mime = mimeArr[1];
|
|
26
|
+
const buff = Buffer.from(arr[1], 'base64');
|
|
27
|
+
return new File([buff], filename, { type: mime });
|
|
28
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export async function copyToClipboard(text: string) {
|
|
2
|
+
try {
|
|
3
|
+
await navigator.clipboard.writeText(text);
|
|
4
|
+
} catch {
|
|
5
|
+
// Fallback for browsers where the Clipboard API is not supported
|
|
6
|
+
const textarea = document.createElement('textarea');
|
|
7
|
+
textarea.style.position = 'fixed';
|
|
8
|
+
textarea.style.top = '-9999px';
|
|
9
|
+
textarea.style.left = '-9999px';
|
|
10
|
+
textarea.innerText = text;
|
|
11
|
+
document.body.appendChild(textarea);
|
|
12
|
+
textarea.focus();
|
|
13
|
+
textarea.select();
|
|
14
|
+
document.execCommand('copy');
|
|
15
|
+
textarea.remove();
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { createRoot } from 'react-dom/client';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Creates a shadow root with the specified styles and returns a React root in it.
|
|
5
|
+
* @param {string} tagName - Node name to be applied to the shadow root.
|
|
6
|
+
* @param {string} styles - CSS styles to be applied to the shadow root.
|
|
7
|
+
* @returns {ReactRoot} - React root rendered inside the shadow root.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export function createShadowRoot(tagName: string, styles: string) {
|
|
11
|
+
const container = document.createElement(tagName);
|
|
12
|
+
const shadow = container.attachShadow({ mode: 'open' });
|
|
13
|
+
|
|
14
|
+
// Create a new CSS style sheet and apply the specified styles and apply the style sheet to the shadow root
|
|
15
|
+
const globalStyleSheet = new CSSStyleSheet();
|
|
16
|
+
globalStyleSheet.replaceSync(styles);
|
|
17
|
+
shadow.adoptedStyleSheets = [globalStyleSheet];
|
|
18
|
+
|
|
19
|
+
const html = document.querySelector('html') as HTMLHtmlElement;
|
|
20
|
+
html.prepend(container);
|
|
21
|
+
return createRoot(shadow);
|
|
22
|
+
}
|
package/util/date.ts
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { FormattedMessage } from '@hanzo_network/hanzo-node-state/v2/queries/getChatConversation/types';
|
|
2
|
+
|
|
3
|
+
export type ChatConversationMessage = {
|
|
4
|
+
hash: string;
|
|
5
|
+
parentHash: string;
|
|
6
|
+
inboxId: string;
|
|
7
|
+
scheduledTime: string | undefined;
|
|
8
|
+
content: string;
|
|
9
|
+
isLocal: boolean;
|
|
10
|
+
sender: {
|
|
11
|
+
avatar: string;
|
|
12
|
+
};
|
|
13
|
+
fileInbox?: {
|
|
14
|
+
id: string;
|
|
15
|
+
files: {
|
|
16
|
+
name: string;
|
|
17
|
+
preview?: string;
|
|
18
|
+
}[];
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export type GetChatConversationOutput = ChatConversationMessage[];
|
|
22
|
+
|
|
23
|
+
export const formatDateToUSLocaleString = (date: Date | undefined) => {
|
|
24
|
+
if (!date) return '-';
|
|
25
|
+
return new Date(date).toLocaleDateString('en-US', {
|
|
26
|
+
year: 'numeric',
|
|
27
|
+
month: 'numeric',
|
|
28
|
+
day: 'numeric',
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
export const formatDateToLocaleStringWithTime = (date: Date | undefined) => {
|
|
32
|
+
if (!date) return '-';
|
|
33
|
+
return new Date(date).toLocaleDateString('en-US', {
|
|
34
|
+
year: 'numeric',
|
|
35
|
+
month: 'numeric',
|
|
36
|
+
day: 'numeric',
|
|
37
|
+
hour: 'numeric',
|
|
38
|
+
minute: 'numeric',
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const getRelativeDateLabel = (date: Date): string => {
|
|
43
|
+
const today = new Date();
|
|
44
|
+
const yesterday = new Date();
|
|
45
|
+
yesterday.setDate(today.getDate() - 1);
|
|
46
|
+
if (date.toDateString() === today.toDateString()) {
|
|
47
|
+
return 'today';
|
|
48
|
+
} else if (date.toDateString() === yesterday.toDateString()) {
|
|
49
|
+
return 'yesterday';
|
|
50
|
+
} else {
|
|
51
|
+
return date.toDateString();
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export const groupMessagesByDate = (messages: FormattedMessage[]) => {
|
|
56
|
+
const groupedMessages: Record<string, FormattedMessage[]> = {};
|
|
57
|
+
for (const message of messages) {
|
|
58
|
+
const date = new Date(message.createdAt ?? '').toDateString();
|
|
59
|
+
if (!groupedMessages[date]) {
|
|
60
|
+
groupedMessages[date] = [];
|
|
61
|
+
}
|
|
62
|
+
groupedMessages[date].push(message);
|
|
63
|
+
}
|
|
64
|
+
return groupedMessages;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export const formatDateToMonthAndDay = (date: Date): string => {
|
|
68
|
+
const today = new Date();
|
|
69
|
+
if (
|
|
70
|
+
date.getDate() === today.getDate() &&
|
|
71
|
+
date.getMonth() === today.getMonth() &&
|
|
72
|
+
date.getFullYear() === today.getFullYear()
|
|
73
|
+
) {
|
|
74
|
+
return date.toLocaleTimeString('en-US', {
|
|
75
|
+
hour: 'numeric',
|
|
76
|
+
minute: 'numeric',
|
|
77
|
+
hour12: true,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
const month = date.getMonth() + 1;
|
|
81
|
+
const day = date.getDate();
|
|
82
|
+
return `${month}/${day}`;
|
|
83
|
+
};
|
package/util/debounce.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export const debounce = (func: Function, delay: number) => {
|
|
2
|
+
let timeoutId: NodeJS.Timeout | null = null;
|
|
3
|
+
return (...args: any[]) => {
|
|
4
|
+
if (timeoutId) {
|
|
5
|
+
clearTimeout(timeoutId);
|
|
6
|
+
}
|
|
7
|
+
timeoutId = setTimeout(() => {
|
|
8
|
+
func(...args);
|
|
9
|
+
}, delay);
|
|
10
|
+
};
|
|
11
|
+
};
|
package/util/file.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export const getFileName = (fileName: string): string => {
|
|
2
|
+
const nameParts = fileName.split('.');
|
|
3
|
+
return nameParts.slice(0, -1).join('.');
|
|
4
|
+
};
|
|
5
|
+
export const getFileExt = (fileName: string): string => {
|
|
6
|
+
const nameParts = fileName.split('.');
|
|
7
|
+
return nameParts.pop() || '';
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const isFileTypeImageOrPdf = (file: File): boolean => {
|
|
11
|
+
if (!file) return false;
|
|
12
|
+
return (
|
|
13
|
+
file?.type.startsWith('image/') || file?.type.startsWith('application/pdf')
|
|
14
|
+
);
|
|
15
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { HanzoToolHeader } from '@hanzo_network/hanzo-message-ts/api/tools/types';
|
|
2
|
+
|
|
3
|
+
export const formatText = (text: string) => {
|
|
4
|
+
const camelToSpaces = text.replace(/([a-z])([A-Z])/g, '$1 $2');
|
|
5
|
+
const snakeToSpaces = camelToSpaces.replace(/_/g, ' ');
|
|
6
|
+
return snakeToSpaces
|
|
7
|
+
.split(' ')
|
|
8
|
+
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
|
|
9
|
+
.join(' ');
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const formatCamelCaseText = (text: string) => {
|
|
13
|
+
const words = text.split(/(?=[A-Z])/);
|
|
14
|
+
|
|
15
|
+
const formattedWords = words.map((word) => {
|
|
16
|
+
return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
const result = formattedWords.join(' ');
|
|
20
|
+
|
|
21
|
+
return result.charAt(0).toUpperCase() + result.slice(1);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const getVersionFromTool = (toolRouterKey: HanzoToolHeader) => {
|
|
25
|
+
if (toolRouterKey.version) {
|
|
26
|
+
return toolRouterKey.version;
|
|
27
|
+
}
|
|
28
|
+
const parts = toolRouterKey.name.split(':::');
|
|
29
|
+
if (parts.length === 4) {
|
|
30
|
+
return parts[3];
|
|
31
|
+
}
|
|
32
|
+
return 'latest';
|
|
33
|
+
};
|
package/util/index.ts
CHANGED
|
@@ -1,78 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export const cn = (...inputs: ClassValue[]) => (
|
|
12
|
-
twMerge(clsx(inputs))
|
|
13
|
-
)
|
|
14
|
-
|
|
15
|
-
export const markdown = (s: string, options?: any): JSX.Element => (
|
|
16
|
-
mdCompiler(s, {
|
|
17
|
-
wrapper: null,
|
|
18
|
-
...options
|
|
19
|
-
})
|
|
20
|
-
)
|
|
21
|
-
|
|
22
|
-
export const round = (num: number): string => (
|
|
23
|
-
num
|
|
24
|
-
.toFixed(7)
|
|
25
|
-
.replace(/(\.[0-9]+?)0+$/, '$1')
|
|
26
|
-
.replace(/\.0$/, '')
|
|
27
|
-
)
|
|
28
|
-
|
|
29
|
-
export const pxToRem = (px: number, base: number): string => (`${round(px / base)}rem`)
|
|
30
|
-
|
|
31
|
-
export const pxToEm = (px: number, base: number): string => (`${round(px / base)}em`)
|
|
32
|
-
|
|
33
|
-
export const hexToRgb = (hex: string): string => {
|
|
34
|
-
hex = hex.replace('#', '')
|
|
35
|
-
hex = hex.length === 3 ? hex.replace(/./g, '$&$&') : hex
|
|
36
|
-
const r = parseInt(hex.substring(0, 2), 16)
|
|
37
|
-
const g = parseInt(hex.substring(2, 4), 16)
|
|
38
|
-
const b = parseInt(hex.substring(4, 6), 16)
|
|
39
|
-
return `${r} ${g} ${b}`
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
export const asNum = (n: number | `${number}`): number => (
|
|
44
|
-
(typeof n === 'number') ? n : parseInt(n, 10)
|
|
45
|
-
)
|
|
46
|
-
|
|
47
|
-
// https://stackoverflow.com/questions/3971841/how-to-resize-images-proportionally-keeping-the-aspect-ratio
|
|
48
|
-
export const constrain = (d: Dimensions, c: Dimensions): Dimensions => {
|
|
49
|
-
|
|
50
|
-
const ratio = Math.min(c.w / d.w, c.h / d.h)
|
|
51
|
-
return {
|
|
52
|
-
w: Math.round(d.w * ratio),
|
|
53
|
-
h: Math.round(d.h * ratio)
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export const containsToken = (s: string | undefined, toFind: string): boolean => (s ? s.split(' ').includes(toFind) : false)
|
|
58
|
-
|
|
59
|
-
export const ldMerge = (
|
|
60
|
-
result: any,
|
|
61
|
-
...sources: any[]
|
|
62
|
-
): any => (_merge(result, ...sources))
|
|
63
|
-
|
|
64
|
-
export const capitalize = (str: string): string => (
|
|
65
|
-
str.charAt(0).toUpperCase() + str.slice(1)
|
|
66
|
-
)
|
|
67
|
-
|
|
68
|
-
export { default as spreadToTransform } from './spread-to-transform'
|
|
69
|
-
export { default as formatToMaxChar } from './format-to-max-char'
|
|
70
|
-
export {
|
|
71
|
-
default as formatAndAbbreviateAsCurrency,
|
|
72
|
-
type FormatThreshold,
|
|
73
|
-
type QuantityAbbrSymbol
|
|
74
|
-
} from './format-and-abbreviate-as-currency'
|
|
75
|
-
|
|
76
|
-
// Must be imported from 'use client', so can't include this...
|
|
77
|
-
// export * from './step-animation'
|
|
78
|
-
|
|
1
|
+
export * from './date';
|
|
2
|
+
export * from './file';
|
|
3
|
+
export * from './create-shadow-root';
|
|
4
|
+
export * from './timing';
|
|
5
|
+
export * from './blob';
|
|
6
|
+
export * from './copy-to-clipboard';
|
|
7
|
+
export * from './format-text';
|
|
8
|
+
export * from './toasts';
|
|
9
|
+
export * from './debounce';
|
package/util/timing.ts
ADDED
package/util/toasts.tsx
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { toast } from 'sonner';
|
|
2
|
+
|
|
3
|
+
export const submitRegistrationNoCodeNonPristineError = () => {
|
|
4
|
+
return toast.error(
|
|
5
|
+
<div>
|
|
6
|
+
Your Hanzo Node is currently locked by existing keys, please restore your
|
|
7
|
+
connection or reset your Hanzo Node Storage
|
|
8
|
+
</div>,
|
|
9
|
+
{ position: 'bottom-center' },
|
|
10
|
+
);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const submitRegistrationNoCodeError = () => {
|
|
14
|
+
return toast.error(<div>Error connecting to your Hanzo Node</div>, {
|
|
15
|
+
position: 'bottom-center',
|
|
16
|
+
});
|
|
17
|
+
};
|
package/utils.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type ClassValue, clsx } from "clsx";
|
|
2
|
+
import { twMerge } from "tailwind-merge";
|
|
3
|
+
|
|
4
|
+
export function cn(...inputs: ClassValue[]) {
|
|
5
|
+
return twMerge(clsx(inputs));
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
// Re-export from src/utils for backward compatibility
|
|
9
|
+
export * from './src/utils';
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Accordion, AccordionContent, AccordionItem, AccordionTrigger, ApplyTypography } from '../../primitives/index-common';
|
|
3
|
-
import { cn } from '../../util';
|
|
4
|
-
const AccordianBlockComponent = ({ block, className = '' }) => {
|
|
5
|
-
if (block.blockType !== 'accordian') {
|
|
6
|
-
return <>accordian block required</>;
|
|
7
|
-
}
|
|
8
|
-
const accordian = block;
|
|
9
|
-
return (<Accordion type="single" collapsible className={cn('w-full border rounded-xl overflow-hidden', className)}>
|
|
10
|
-
{accordian.items.map((item, index) => (<AccordionItem className='border-b last:border-0 overflow-hidden' value={`value-${index}`} key={index}>
|
|
11
|
-
<AccordionTrigger className='px-3 md:px-4 lg:px-6 hover:no-underline hover:bg-level-3'>
|
|
12
|
-
<ApplyTypography>
|
|
13
|
-
{/* styles specific to accordion. From old site */}
|
|
14
|
-
<h6 className='leading-[1.2] text-[1.05rem] font-semibold '>{item.trigger}</h6>
|
|
15
|
-
</ApplyTypography>
|
|
16
|
-
</AccordionTrigger>
|
|
17
|
-
<AccordionContent className='p-4 border-t bg-level-1'>
|
|
18
|
-
<ApplyTypography className='flex flex-col justify-start items-start '>
|
|
19
|
-
{(typeof item.content === 'string') ? (<p>{item.content}</p>) : item.content}
|
|
20
|
-
</ApplyTypography>
|
|
21
|
-
</AccordionContent>
|
|
22
|
-
</AccordionItem>))}
|
|
23
|
-
</Accordion>);
|
|
24
|
-
};
|
|
25
|
-
export default AccordianBlockComponent;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { containsToken, cn } from '../../util';
|
|
3
|
-
import InlineIcon from '../../primitives/next/inline-icon';
|
|
4
|
-
import GridBlockComponent from './grid-block';
|
|
5
|
-
const BulletCardsBlockComponent = ({ block, className = '', agent }) => {
|
|
6
|
-
if (block.blockType !== 'bullet-cards') {
|
|
7
|
-
return <>bullet cards block required</>;
|
|
8
|
-
}
|
|
9
|
-
const b = block;
|
|
10
|
-
const specified = (s) => (containsToken(b.specifiers, s));
|
|
11
|
-
const noBorder = specified('no-card-border') ? 'border-0' : 'md:border';
|
|
12
|
-
const mobileTextXs = specified('mobile-small-text') ? 'text-xs' : 'text-sm';
|
|
13
|
-
const borderclx = specified('border-muted-3') ?
|
|
14
|
-
'md:border-muted-3'
|
|
15
|
-
:
|
|
16
|
-
(specified('border-muted-1') ? 'md:border-muted-1' : 'md:border-muted-2');
|
|
17
|
-
return (<GridBlockComponent block={{ blockType: 'grid', grid: b.grid }} className={className} agent={agent}>
|
|
18
|
-
{b.cards.map((card, index) => (<div key={index} className={cn('px-0 sm:px-4 py-1 md:py-4 rounded-lg ' +
|
|
19
|
-
'flex flex-row justify-start items-center not-typography text-foreground', noBorder, borderclx)}>
|
|
20
|
-
<InlineIcon icon={card.icon} size={b.iconSize ?? 28} agent={agent} className='shrink-0 mr-2 md:mr-4 '/>
|
|
21
|
-
<p className={cn('m-0 sm:text-base', mobileTextXs)}>{card.text}</p>
|
|
22
|
-
</div>))}
|
|
23
|
-
</GridBlockComponent>);
|
|
24
|
-
};
|
|
25
|
-
export default BulletCardsBlockComponent;
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { ApplyTypography, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from '../../../primitives/index-common';
|
|
3
|
-
import ImageBlockComponent from '../image-block';
|
|
4
|
-
import VideoBlockComponent from '../video-block';
|
|
5
|
-
import CTABlockComponent from '../cta-block';
|
|
6
|
-
import { cn } from '../../../util';
|
|
7
|
-
import { getTypographySize } from './util';
|
|
8
|
-
import LinkOutButton from './link-out-button';
|
|
9
|
-
const CardBlockComponent = ({ block, className = '', contentClassName = '' }) => {
|
|
10
|
-
if (block.blockType !== 'card') {
|
|
11
|
-
return <>card block required</>;
|
|
12
|
-
}
|
|
13
|
-
const card = block;
|
|
14
|
-
const has = (s) => (card.specifiers?.includes(s));
|
|
15
|
-
const ghost = has('ghost'); // no outer padding, no borders, larger title, all left-aligned bg is same (default)
|
|
16
|
-
const contentclx = (has('content-left') ? 'items-start ' : ' items-center ') + (has('content-top') ? '!justify-start' : '') + contentClassName;
|
|
17
|
-
const disabledBorder = (has('appear-disabled') ? ' border-muted-4' : ' border-muted-3');
|
|
18
|
-
const outerBorder = ((has('no-outer-border') || ghost) ? ' border-0' : '');
|
|
19
|
-
const innerBorder = (ghost ? ' border-0' : '');
|
|
20
|
-
const paddingclx = ghost ? ' px-0 py-0' : ' px-6 py-3';
|
|
21
|
-
const mainGap = ghost ? ' gap-2' : '';
|
|
22
|
-
const disabledText = (has('appear-disabled') ? ' text-muted-2' : '');
|
|
23
|
-
const disabledTypoText = (has('appear-disabled') ? ' typography-p:text-muted-2' : '');
|
|
24
|
-
const bgclx = (has('bg-card') ? ' bg-level-1' : '');
|
|
25
|
-
const titleclx = (has('heading-style-title') ? ' font-heading text-base leading-tight' : '') +
|
|
26
|
-
(ghost ? ' text-left md:text-xl' : '');
|
|
27
|
-
const typoSize = (card.specifiers) ? getTypographySize(card.specifiers) : 'responsive';
|
|
28
|
-
const typoclx = (typoSize === 'sm') ? 'typography-sm typography-p:text-sm ' : (typoSize === 'lg') ? 'typography-lg ' : '';
|
|
29
|
-
const contentBefore = has('content-before');
|
|
30
|
-
const iconInline = has('icon-inline');
|
|
31
|
-
const contentOnHover = has('reveal-content-on-hover');
|
|
32
|
-
//const smallIconDim = (contentOnHover && card.specifiers) ? getSmallIconDim(card.specifiers) : undefined
|
|
33
|
-
const Header = ({ inContent = false, className = '' }) => ((card.title || card.byline || card.icon) ? (<CardHeader className={'not-typography' + ' text-accent' + disabledText + paddingclx + innerBorder + className}>
|
|
34
|
-
<div className={(iconInline || inContent) ? 'flex flex-row justify-start items-end my-3' : ''}>
|
|
35
|
-
{(card.icon && !card.iconAfter) && (<div className={iconInline ? 'mr-1' : 'mb-2'}>{card.icon}</div>)}
|
|
36
|
-
{card.title && (<CardTitle className={'text-center text-lg font-medium' + titleclx + (iconInline ? ' md:text-xl/none' : '')}>
|
|
37
|
-
{card.title}
|
|
38
|
-
</CardTitle>)}
|
|
39
|
-
{(card.icon && card.iconAfter) && (<div className={iconInline ? 'ml-1' : 'my-1'}>{card.icon}</div>)}
|
|
40
|
-
</div>
|
|
41
|
-
{card.byline && (<CardDescription>{card.byline}</CardDescription>)}
|
|
42
|
-
</CardHeader>) : null);
|
|
43
|
-
const MediaAndContent = ({ className = '' }) => (has('media-left') ? (
|
|
44
|
-
// media left layout
|
|
45
|
-
<CardContent className={'flex flex-row justify-start items-stretch p-0 grow ' + disabledBorder + bgclx + contentclx + className}>
|
|
46
|
-
{card.media && (<div className={'box-content grow-0 not-typography' + paddingclx} style={{
|
|
47
|
-
// If this layout has been specified, assume media is video, and that the 'sm' dim exists.
|
|
48
|
-
width: card.media.dim.sm.w
|
|
49
|
-
}}>
|
|
50
|
-
<VideoBlockComponent block={card.media} usePoster={has('video-use-poster')} size='sm' className={has('appear-disabled') ? 'opacity-[0.6]' : ''}/>
|
|
51
|
-
</div>)}
|
|
52
|
-
{card.content && (<ApplyTypography className={'grow border-l flex flex-col justify-center ' + disabledTypoText + paddingclx + disabledBorder + contentclx} size={typoSize}>
|
|
53
|
-
{(typeof card.content === 'string') ? (<p>{card.content}</p>) : card.content}
|
|
54
|
-
</ApplyTypography>)}
|
|
55
|
-
</CardContent>) : ( // default layout
|
|
56
|
-
<CardContent className={'grow typography flex flex-col justify-center ' +
|
|
57
|
-
typoclx + disabledTypoText + bgclx + paddingclx + contentclx + (has('full-width') ? ' p-0 ' : ' ') +
|
|
58
|
-
className}>
|
|
59
|
-
{contentOnHover && (<Header inContent/>)}
|
|
60
|
-
{card.content && contentBefore && ((typeof card.content === 'string') ? (<p>{card.content}</p>) : card.content)}
|
|
61
|
-
{card.media && (card.media.blockType === 'image' ? (<ImageBlockComponent block={card.media}/>) : (<VideoBlockComponent block={card.media}/>))}
|
|
62
|
-
{card.content && !contentBefore && ((typeof card.content === 'string') ? (<p>{card.content}</p>) : card.content)}
|
|
63
|
-
</CardContent>));
|
|
64
|
-
const Footer = () => (!card.cta ? null : (has('links-w-arrow') ? (
|
|
65
|
-
// links w arrow
|
|
66
|
-
<CardFooter className={'typography typography-a:text-muted-2 typography-a:hover:text-muted-1 typography-a:text-xs typography-a:no-underline typography-a:hover:underline ' +
|
|
67
|
-
'flex flex-col justify-start items-stretch ' + paddingclx}>
|
|
68
|
-
<CTABlockComponent block={card.cta} renderLink={(def, key) => (<LinkOutButton def={def} key={key}/>)}/>
|
|
69
|
-
</CardFooter>) : ( // default
|
|
70
|
-
<CardFooter className={'grid grid-cols-1 gap-2 md:flex md:flex-row md:justify-center ' + paddingclx}>
|
|
71
|
-
<CTABlockComponent block={card.cta}/>
|
|
72
|
-
</CardFooter>)));
|
|
73
|
-
return (<Card className={cn('flex flex-col self-stretch ' +
|
|
74
|
-
(contentOnHover ? 'group relative' : '') +
|
|
75
|
-
disabledBorder +
|
|
76
|
-
outerBorder +
|
|
77
|
-
bgclx +
|
|
78
|
-
mainGap, className)}>
|
|
79
|
-
<Header className={(contentOnHover ? ' absolute top-[0px] left-[0px] w-full hidden ' : '')}/>
|
|
80
|
-
<MediaAndContent className={(contentOnHover ?
|
|
81
|
-
' bg-gradient-to-t from-secondary to-65%' +
|
|
82
|
-
' items-start justify-start rounded-lg p-4' +
|
|
83
|
-
' transition-opacity duration-500 ease-out opacity-100 ' : '')}/>
|
|
84
|
-
<Footer />
|
|
85
|
-
</Card>);
|
|
86
|
-
};
|
|
87
|
-
export default CardBlockComponent;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { LinkElement, Icons } from '../../../primitives/index-next';
|
|
3
|
-
const ArrowLinkElement = ({ def }) => (<LinkElement def={def} className='justify-between' variant='link' icon={<Icons.linkOut className='w-[18px] h-[18px]'/>} iconAfter/>);
|
|
4
|
-
export default ArrowLinkElement;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { Dimensions } from '../../../types';
|
|
2
|
-
import type { TypographySize } from '../../../primitives/index-common';
|
|
3
|
-
export declare const getTypographySize: (s: string) => TypographySize;
|
|
4
|
-
export declare const getSmallIconDim: (s: string) => Dimensions | undefined;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { getSpecifierData, getPrimaryStartingWith, getDim, } from '../../../util/specifier';
|
|
2
|
-
export const getTypographySize = (s) => getSpecifierData(s, (s) => (getPrimaryStartingWith(s, 'typography')), (s) => {
|
|
3
|
-
const subTokenArray = s.split('-');
|
|
4
|
-
return subTokenArray[subTokenArray.length - 1];
|
|
5
|
-
}, 'responsive');
|
|
6
|
-
export const getSmallIconDim = (s) => (getSpecifierData(s, (s) => (getPrimaryStartingWith(s, 'small-icon')), getDim));
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Card, CardContent, CardFooter, CardHeader, } from '../../../primitives/index-common';
|
|
3
|
-
import { cn, containsToken } from '../../../util';
|
|
4
|
-
import { getSpecifierData, getPrimaryStartingWith, getDim, } from '../../../util/specifier';
|
|
5
|
-
import CTABlockComponent from '../cta-block';
|
|
6
|
-
import Content from '../content';
|
|
7
|
-
import { EnhHeadingBlockComponent } from '..';
|
|
8
|
-
import VariantContentLeft from './variant-content-left';
|
|
9
|
-
const _getClx = (specifier, section) => {
|
|
10
|
-
let result = '';
|
|
11
|
-
if (specifier === 'big-padding') {
|
|
12
|
-
switch (section) {
|
|
13
|
-
// defaults: p-4 lg:p-6 xl:p-8
|
|
14
|
-
case 'header':
|
|
15
|
-
{
|
|
16
|
-
result = 'md:p-8 lg:p-12 xl:p-16';
|
|
17
|
-
}
|
|
18
|
-
break;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
if (specifier === 'big-padding-content') {
|
|
22
|
-
switch (section) {
|
|
23
|
-
case 'content':
|
|
24
|
-
{
|
|
25
|
-
result = 'md:p-8 lg:p-12 xl:p-16';
|
|
26
|
-
}
|
|
27
|
-
break;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
else if (specifier === 'no-inner-borders') {
|
|
31
|
-
switch (section) {
|
|
32
|
-
case 'header':
|
|
33
|
-
{
|
|
34
|
-
result = 'border-none';
|
|
35
|
-
}
|
|
36
|
-
break;
|
|
37
|
-
case 'footer':
|
|
38
|
-
{
|
|
39
|
-
result = 'border-t-0';
|
|
40
|
-
}
|
|
41
|
-
break;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
return result;
|
|
45
|
-
};
|
|
46
|
-
const CarteBlancheBlockComponent = ({ block, className = '', agent, }) => {
|
|
47
|
-
if (block.blockType !== 'carte-blanche') {
|
|
48
|
-
return <>carte blanche block required</>;
|
|
49
|
-
}
|
|
50
|
-
const b = block;
|
|
51
|
-
const specified = (s) => (containsToken(b.specifiers, s));
|
|
52
|
-
const getClx = (specifier, section) => ((specified(specifier)) ? _getClx(specifier, section) : '');
|
|
53
|
-
//const bigPadding = specified('big-padding')
|
|
54
|
-
const headingclx = [
|
|
55
|
-
getClx('big-padding', 'header'),
|
|
56
|
-
getClx('no-inner-borders', 'header'),
|
|
57
|
-
].join(' ');
|
|
58
|
-
const contentclx = [
|
|
59
|
-
getClx('big-padding-content', 'content'),
|
|
60
|
-
].join(' ');
|
|
61
|
-
const footerclx = [
|
|
62
|
-
getClx('no-inner-borders', 'footer'),
|
|
63
|
-
].join(' ');
|
|
64
|
-
const noOuterBorders = specified('no-outer-borders');
|
|
65
|
-
const contentLeft = specified('variant-content-left');
|
|
66
|
-
const mobileContentLeft = specified('variant-mobile-content-left');
|
|
67
|
-
return (<Card className={cn('flex flex-col', className, noOuterBorders ? 'border-none' : '')}>
|
|
68
|
-
{contentLeft || (mobileContentLeft && agent === 'phone') ? (<VariantContentLeft block={b} agent={agent} className={className} headingclx={headingclx} contentclx={contentclx} footerclx={footerclx}/>) : (<>
|
|
69
|
-
{(b.heading || b.topContent) && (<CardHeader className={cn('typography-img:m-0', headingclx)}>
|
|
70
|
-
{b.topContent && (<Content blocks={b.topContent} agent={agent} className=''/>)}
|
|
71
|
-
{b.heading && (<EnhHeadingBlockComponent block={b.heading} className='text-accent' agent={agent}/>)}
|
|
72
|
-
</CardHeader>)}
|
|
73
|
-
{b.content && (<CardContent className={cn('typography flex flex-col justify-center', contentclx, className)}>
|
|
74
|
-
<Content blocks={b.content} agent={agent}/>
|
|
75
|
-
</CardContent>)}
|
|
76
|
-
{b.cta && (<CardFooter className={cn('grid grid-cols-1 gap-2 md:flex md:flex-row md:justify-center', footerclx)}>
|
|
77
|
-
<CTABlockComponent block={b.cta} agent={agent}/>
|
|
78
|
-
</CardFooter>)}
|
|
79
|
-
</>)}
|
|
80
|
-
</Card>);
|
|
81
|
-
};
|
|
82
|
-
export default CarteBlancheBlockComponent;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { type CarteBlancheBlock } from '../..';
|
|
2
|
-
declare const VariantContentLeft: React.FC<{
|
|
3
|
-
block: CarteBlancheBlock;
|
|
4
|
-
agent?: string;
|
|
5
|
-
className?: string;
|
|
6
|
-
headingclx?: string;
|
|
7
|
-
contentclx?: string;
|
|
8
|
-
footerclx?: string;
|
|
9
|
-
}>;
|
|
10
|
-
export default VariantContentLeft;
|