@hanzo/ui 8.27.8 → 8.27.10
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.md +2 -1
- package/dist/backends/gui/3d-card.cjs +100 -0
- package/dist/backends/gui/3d-card.d.ts +59 -0
- package/dist/backends/gui/3d-card.d.ts.map +1 -0
- package/dist/backends/gui/3d-card.js +92 -0
- package/dist/backends/gui/3d-card.js.map +1 -0
- package/dist/backends/gui/3d-marquee.cjs +225 -0
- package/dist/backends/gui/3d-marquee.d.ts +114 -0
- package/dist/backends/gui/3d-marquee.d.ts.map +1 -0
- package/dist/backends/gui/3d-marquee.js +190 -0
- package/dist/backends/gui/3d-marquee.js.map +1 -0
- package/dist/backends/gui/3d-pin.cjs +51 -0
- package/dist/backends/gui/3d-pin.d.ts +14 -0
- package/dist/backends/gui/3d-pin.d.ts.map +1 -0
- package/dist/backends/gui/3d-pin.js +49 -0
- package/dist/backends/gui/3d-pin.js.map +1 -0
- package/dist/backends/gui/advanced-chart.cjs +61 -0
- package/dist/backends/gui/advanced-chart.d.ts +38 -0
- package/dist/backends/gui/advanced-chart.d.ts.map +1 -0
- package/dist/backends/gui/advanced-chart.js +59 -0
- package/dist/backends/gui/advanced-chart.js.map +1 -0
- package/dist/backends/gui/alert.cjs +106 -0
- package/dist/backends/gui/alert.d.ts +39 -0
- package/dist/backends/gui/alert.d.ts.map +1 -0
- package/dist/backends/gui/alert.js +102 -0
- package/dist/backends/gui/alert.js.map +1 -0
- package/dist/backends/gui/android.cjs +52 -0
- package/dist/backends/gui/android.d.ts +16 -0
- package/dist/backends/gui/android.d.ts.map +1 -0
- package/dist/backends/gui/android.js +50 -0
- package/dist/backends/gui/android.js.map +1 -0
- package/dist/backends/gui/animated-beam.cjs +97 -0
- package/dist/backends/gui/animated-beam.d.ts +57 -0
- package/dist/backends/gui/animated-beam.d.ts.map +1 -0
- package/dist/backends/gui/animated-beam.js +62 -0
- package/dist/backends/gui/animated-beam.js.map +1 -0
- package/dist/backends/gui/animated-cursor.cjs +183 -0
- package/dist/backends/gui/animated-cursor.d.ts +42 -0
- package/dist/backends/gui/animated-cursor.d.ts.map +1 -0
- package/dist/backends/gui/animated-cursor.js +181 -0
- package/dist/backends/gui/animated-cursor.js.map +1 -0
- package/dist/backends/gui/animated-testimonials.cjs +109 -0
- package/dist/backends/gui/animated-testimonials.d.ts +23 -0
- package/dist/backends/gui/animated-testimonials.d.ts.map +1 -0
- package/dist/backends/gui/animated-testimonials.js +74 -0
- package/dist/backends/gui/animated-testimonials.js.map +1 -0
- package/dist/backends/gui/animated-tooltip.cjs +100 -0
- package/dist/backends/gui/animated-tooltip.d.ts +15 -0
- package/dist/backends/gui/animated-tooltip.d.ts.map +1 -0
- package/dist/backends/gui/animated-tooltip.js +65 -0
- package/dist/backends/gui/animated-tooltip.js.map +1 -0
- package/dist/backends/gui/announcement.cjs +54 -0
- package/dist/backends/gui/announcement.d.ts +26 -0
- package/dist/backends/gui/announcement.d.ts.map +1 -0
- package/dist/backends/gui/announcement.js +52 -0
- package/dist/backends/gui/announcement.js.map +1 -0
- package/dist/backends/gui/apple-cards-carousel.cjs +198 -0
- package/dist/backends/gui/apple-cards-carousel.d.ts +45 -0
- package/dist/backends/gui/apple-cards-carousel.d.ts.map +1 -0
- package/dist/backends/gui/apple-cards-carousel.js +162 -0
- package/dist/backends/gui/apple-cards-carousel.js.map +1 -0
- package/dist/backends/gui/apple-hello-effect.cjs +38 -0
- package/dist/backends/gui/apple-hello-effect.d.ts +9 -0
- package/dist/backends/gui/apple-hello-effect.d.ts.map +1 -0
- package/dist/backends/gui/apple-hello-effect.js +36 -0
- package/dist/backends/gui/apple-hello-effect.js.map +1 -0
- package/dist/backends/gui/banner.cjs +108 -0
- package/dist/backends/gui/banner.d.ts +33 -0
- package/dist/backends/gui/banner.d.ts.map +1 -0
- package/dist/backends/gui/banner.js +106 -0
- package/dist/backends/gui/banner.js.map +1 -0
- package/dist/backends/gui/calendar.cjs +152 -0
- package/dist/backends/gui/calendar.d.ts +41 -0
- package/dist/backends/gui/calendar.d.ts.map +1 -0
- package/dist/backends/gui/calendar.js +151 -0
- package/dist/backends/gui/calendar.js.map +1 -0
- package/dist/backends/gui/choicebox.cjs +50 -0
- package/dist/backends/gui/choicebox.d.ts +33 -0
- package/dist/backends/gui/choicebox.d.ts.map +1 -0
- package/dist/backends/gui/choicebox.js +49 -0
- package/dist/backends/gui/choicebox.js.map +1 -0
- package/dist/backends/gui/code-block.cjs +120 -0
- package/dist/backends/gui/code-block.d.ts +22 -0
- package/dist/backends/gui/code-block.d.ts.map +1 -0
- package/dist/backends/gui/code-block.js +118 -0
- package/dist/backends/gui/code-block.js.map +1 -0
- package/dist/backends/gui/code-editor.cjs +195 -0
- package/dist/backends/gui/code-editor.d.ts +43 -0
- package/dist/backends/gui/code-editor.d.ts.map +1 -0
- package/dist/backends/gui/code-editor.js +160 -0
- package/dist/backends/gui/code-editor.js.map +1 -0
- package/dist/backends/gui/code-tabs.cjs +21 -0
- package/dist/backends/gui/code-tabs.d.ts +22 -0
- package/dist/backends/gui/code-tabs.d.ts.map +1 -0
- package/dist/backends/gui/code-tabs.js +19 -0
- package/dist/backends/gui/code-tabs.js.map +1 -0
- package/dist/backends/gui/color-picker.cjs +141 -0
- package/dist/backends/gui/color-picker.d.ts +25 -0
- package/dist/backends/gui/color-picker.d.ts.map +1 -0
- package/dist/backends/gui/color-picker.js +139 -0
- package/dist/backends/gui/color-picker.js.map +1 -0
- package/dist/backends/gui/combobox.cjs +42 -0
- package/dist/backends/gui/combobox.d.ts +39 -0
- package/dist/backends/gui/combobox.d.ts.map +1 -0
- package/dist/backends/gui/combobox.js +40 -0
- package/dist/backends/gui/combobox.js.map +1 -0
- package/dist/backends/gui/company-profile.cjs +43 -0
- package/dist/backends/gui/company-profile.d.ts +33 -0
- package/dist/backends/gui/company-profile.d.ts.map +1 -0
- package/dist/backends/gui/company-profile.js +41 -0
- package/dist/backends/gui/company-profile.js.map +1 -0
- package/dist/backends/gui/comparison.cjs +43 -0
- package/dist/backends/gui/comparison.d.ts +16 -0
- package/dist/backends/gui/comparison.d.ts.map +1 -0
- package/dist/backends/gui/comparison.js +41 -0
- package/dist/backends/gui/comparison.js.map +1 -0
- package/dist/backends/gui/credit-card.cjs +80 -0
- package/dist/backends/gui/credit-card.d.ts +21 -0
- package/dist/backends/gui/credit-card.d.ts.map +1 -0
- package/dist/backends/gui/credit-card.js +78 -0
- package/dist/backends/gui/credit-card.js.map +1 -0
- package/dist/backends/gui/crypto-market.cjs +128 -0
- package/dist/backends/gui/crypto-market.d.ts +52 -0
- package/dist/backends/gui/crypto-market.d.ts.map +1 -0
- package/dist/backends/gui/crypto-market.js +126 -0
- package/dist/backends/gui/crypto-market.js.map +1 -0
- package/dist/backends/gui/crypto-screener.cjs +55 -0
- package/dist/backends/gui/crypto-screener.d.ts +42 -0
- package/dist/backends/gui/crypto-screener.d.ts.map +1 -0
- package/dist/backends/gui/crypto-screener.js +53 -0
- package/dist/backends/gui/crypto-screener.js.map +1 -0
- package/dist/backends/gui/cursor.cjs +40 -0
- package/dist/backends/gui/cursor.d.ts +16 -0
- package/dist/backends/gui/cursor.d.ts.map +1 -0
- package/dist/backends/gui/cursor.js +38 -0
- package/dist/backends/gui/cursor.js.map +1 -0
- package/dist/backends/gui/data-table.cjs +211 -0
- package/dist/backends/gui/data-table.d.ts +71 -0
- package/dist/backends/gui/data-table.d.ts.map +1 -0
- package/dist/backends/gui/data-table.js +175 -0
- package/dist/backends/gui/data-table.js.map +1 -0
- package/dist/backends/gui/date-picker.cjs +66 -0
- package/dist/backends/gui/date-picker.d.ts +29 -0
- package/dist/backends/gui/date-picker.d.ts.map +1 -0
- package/dist/backends/gui/date-picker.js +64 -0
- package/dist/backends/gui/date-picker.js.map +1 -0
- package/dist/backends/gui/desktop-spotlight.cjs +46 -0
- package/dist/backends/gui/desktop-spotlight.d.ts +34 -0
- package/dist/backends/gui/desktop-spotlight.d.ts.map +1 -0
- package/dist/backends/gui/desktop-spotlight.js +44 -0
- package/dist/backends/gui/desktop-spotlight.js.map +1 -0
- package/dist/backends/gui/desktop-window.cjs +180 -0
- package/dist/backends/gui/desktop-window.d.ts +51 -0
- package/dist/backends/gui/desktop-window.d.ts.map +1 -0
- package/dist/backends/gui/desktop-window.js +177 -0
- package/dist/backends/gui/desktop-window.js.map +1 -0
- package/dist/backends/gui/desktop.cjs +238 -0
- package/dist/backends/gui/desktop.d.ts +109 -0
- package/dist/backends/gui/desktop.d.ts.map +1 -0
- package/dist/backends/gui/desktop.js +199 -0
- package/dist/backends/gui/desktop.js.map +1 -0
- package/dist/backends/gui/dialog-stack.cjs +26 -0
- package/dist/backends/gui/dialog-stack.d.ts +23 -0
- package/dist/backends/gui/dialog-stack.d.ts.map +1 -0
- package/dist/backends/gui/dialog-stack.js +24 -0
- package/dist/backends/gui/dialog-stack.js.map +1 -0
- package/dist/backends/gui/dock.cjs +99 -0
- package/dist/backends/gui/dock.d.ts +41 -0
- package/dist/backends/gui/dock.d.ts.map +1 -0
- package/dist/backends/gui/dock.js +96 -0
- package/dist/backends/gui/dock.js.map +1 -0
- package/dist/backends/gui/dropzone.cjs +142 -0
- package/dist/backends/gui/dropzone.d.ts +12 -0
- package/dist/backends/gui/dropzone.d.ts.map +1 -0
- package/dist/backends/gui/dropzone.js +140 -0
- package/dist/backends/gui/dropzone.js.map +1 -0
- package/dist/backends/gui/editor.cjs +80 -0
- package/dist/backends/gui/editor.d.ts +23 -0
- package/dist/backends/gui/editor.d.ts.map +1 -0
- package/dist/backends/gui/editor.js +45 -0
- package/dist/backends/gui/editor.js.map +1 -0
- package/dist/backends/gui/empty.cjs +71 -0
- package/dist/backends/gui/empty.d.ts +43 -0
- package/dist/backends/gui/empty.d.ts.map +1 -0
- package/dist/backends/gui/empty.js +63 -0
- package/dist/backends/gui/empty.js.map +1 -0
- package/dist/backends/gui/financials.cjs +45 -0
- package/dist/backends/gui/financials.d.ts +36 -0
- package/dist/backends/gui/financials.d.ts.map +1 -0
- package/dist/backends/gui/financials.js +43 -0
- package/dist/backends/gui/financials.js.map +1 -0
- package/dist/backends/gui/forex-market.cjs +21 -0
- package/dist/backends/gui/forex-market.d.ts +17 -0
- package/dist/backends/gui/forex-market.d.ts.map +1 -0
- package/dist/backends/gui/forex-market.js +19 -0
- package/dist/backends/gui/forex-market.js.map +1 -0
- package/dist/backends/gui/forex-screener.cjs +57 -0
- package/dist/backends/gui/forex-screener.d.ts +45 -0
- package/dist/backends/gui/forex-screener.d.ts.map +1 -0
- package/dist/backends/gui/forex-screener.js +55 -0
- package/dist/backends/gui/forex-screener.js.map +1 -0
- package/dist/backends/gui/gantt.cjs +50 -0
- package/dist/backends/gui/gantt.d.ts +19 -0
- package/dist/backends/gui/gantt.d.ts.map +1 -0
- package/dist/backends/gui/gantt.js +49 -0
- package/dist/backends/gui/gantt.js.map +1 -0
- package/dist/backends/gui/index.cjs +108 -1
- package/dist/backends/gui/index.d.ts +41 -0
- package/dist/backends/gui/index.d.ts.map +1 -1
- package/dist/backends/gui/index.js +41 -0
- package/dist/backends/gui/index.js.map +1 -1
- package/dist/canvas.cjs +3 -3
- package/dist/canvas.js +3 -3
- package/dist/canvas.js.map +1 -1
- package/dist/gallery.html +2 -2
- package/dist/grid.cjs +19 -43
- package/dist/grid.d.ts +36 -1
- package/dist/grid.d.ts.map +1 -1
- package/dist/grid.js +19 -43
- package/dist/grid.js.map +1 -1
- package/dist/index.cjs +70 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/index.node.cjs +70 -1
- package/dist/index.node.js +3 -0
- package/dist/product/ChunkGuard.cjs +58 -0
- package/dist/product/ChunkGuard.d.ts +7 -0
- package/dist/product/ChunkGuard.d.ts.map +1 -0
- package/dist/product/ChunkGuard.js +56 -0
- package/dist/product/ChunkGuard.js.map +1 -0
- package/dist/product/DetailPane.cjs +46 -0
- package/dist/product/DetailPane.d.ts +47 -0
- package/dist/product/DetailPane.d.ts.map +1 -0
- package/dist/product/DetailPane.js +43 -0
- package/dist/product/DetailPane.js.map +1 -0
- package/dist/product/Fact.cjs +19 -0
- package/dist/product/Fact.d.ts +23 -0
- package/dist/product/Fact.d.ts.map +1 -0
- package/dist/product/Fact.js +17 -0
- package/dist/product/Fact.js.map +1 -0
- package/dist/product/chunkGuard.logic.cjs +54 -0
- package/dist/product/chunkGuard.logic.d.ts +26 -0
- package/dist/product/chunkGuard.logic.d.ts.map +1 -0
- package/dist/product/chunkGuard.logic.js +49 -0
- package/dist/product/chunkGuard.logic.js.map +1 -0
- package/dist/product/index.cjs +10 -0
- package/dist/product/index.d.ts +3 -0
- package/dist/product/index.d.ts.map +1 -1
- package/dist/product/index.js +10 -0
- package/dist/product/index.js.map +1 -1
- package/package.json +5 -3
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
/**
|
|
4
|
+
* Marquee3D — an endless ticker seen through a CSS perspective.
|
|
5
|
+
*
|
|
6
|
+
* A stage holds the tilt (`perspective` and `rotateX`/`rotateY`/`rotateZ`) and
|
|
7
|
+
* a track inside it carries the items past, so a tilted row reads as a plane
|
|
8
|
+
* receding into the page rather than a flat crawl. The loop is one keyframe:
|
|
9
|
+
* `children` is laid out `repeat` times as a group, the group is rendered
|
|
10
|
+
* twice back to back, and the animation slides the pair by exactly half its own
|
|
11
|
+
* length, so the second copy lands where the first began and the seam never
|
|
12
|
+
* shows. A reader hears the first copy once: every other is `aria-hidden`.
|
|
13
|
+
* Duration is that length over `speed` (px/s), read off the rendered track,
|
|
14
|
+
* so a long set of items moves at the same pace as a short one.
|
|
15
|
+
*
|
|
16
|
+
* Six looks (`variant`) fix their own surface and ink on every theme, except
|
|
17
|
+
* `default`, which takes the host's. `size` sets height and type size together.
|
|
18
|
+
* `Marquee3DPreset` bundles the five named looks; `Marquee3DFloating` bobs each
|
|
19
|
+
* glyph of a text child on top of the scroll.
|
|
20
|
+
*
|
|
21
|
+
* The keyframes ride along as a hoisted `<style>`: React keys it by `href`, so
|
|
22
|
+
* any number of marquees on a page emit it once, and a consumer that mounts none
|
|
23
|
+
* of this package's stylesheets still gets a marquee that moves.
|
|
24
|
+
*/
|
|
25
|
+
import { glass } from '../../glass.js';
|
|
26
|
+
import { Text, XStack, YStack, styled } from '@hanzo/gui';
|
|
27
|
+
import * as React from 'react';
|
|
28
|
+
import { ink } from './ink.js';
|
|
29
|
+
import { slot } from './slot.js';
|
|
30
|
+
/** Frame height and type size per `size`, px. */
|
|
31
|
+
const HEIGHT = { sm: 32, default: 48, lg: 64, xl: 80, '2xl': 96, '3xl': 128 };
|
|
32
|
+
const FONT = { sm: 14, default: 16, lg: 18, xl: 20, '2xl': 24, '3xl': 30 };
|
|
33
|
+
/** Viewing distance per `perspective`, px; 0 draws flat. */
|
|
34
|
+
const DEPTH = { none: 0, sm: 500, default: 1000, lg: 1500, xl: 2000 };
|
|
35
|
+
/** A gradient painted through the glyphs. */
|
|
36
|
+
const clip = (backgroundImage) => ({
|
|
37
|
+
backgroundImage,
|
|
38
|
+
WebkitBackgroundClip: 'text',
|
|
39
|
+
backgroundClip: 'text',
|
|
40
|
+
color: 'transparent',
|
|
41
|
+
});
|
|
42
|
+
/**
|
|
43
|
+
* The ink per variant. It sits on the item, the nearest stack to the glyphs,
|
|
44
|
+
* and every child inherits it — a caller's own elements included — which is
|
|
45
|
+
* why it is an inline style and not a property of the text primitive. Nearest,
|
|
46
|
+
* because gui's stylesheet gives every stack the theme's weight, line height
|
|
47
|
+
* and letter spacing; a stack between the ink and the glyph would reset them.
|
|
48
|
+
*/
|
|
49
|
+
const INK = {
|
|
50
|
+
default: {},
|
|
51
|
+
neon: {
|
|
52
|
+
color: '#22d3ee',
|
|
53
|
+
filter: 'drop-shadow(0 0 10px currentColor)',
|
|
54
|
+
animation: 'marquee-3d-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite',
|
|
55
|
+
},
|
|
56
|
+
rainbow: clip('linear-gradient(90deg, #ef4444, #eab308, #22c55e, #3b82f6, #a855f7)'),
|
|
57
|
+
metallic: clip('linear-gradient(180deg, #e5e7eb, #9ca3af, #4b5563)'),
|
|
58
|
+
fire: {
|
|
59
|
+
...clip('linear-gradient(0deg, #dc2626, #f97316, #facc15)'),
|
|
60
|
+
filter: 'drop-shadow(0 0 20px #ff6600)',
|
|
61
|
+
},
|
|
62
|
+
glass: { color: 'rgba(255,255,255,0.9)', filter: 'drop-shadow(0 0 10px rgba(255,255,255,0.3))' },
|
|
63
|
+
};
|
|
64
|
+
const Frame = styled(XStack, {
|
|
65
|
+
name: 'Marquee3D',
|
|
66
|
+
position: 'relative',
|
|
67
|
+
overflow: 'hidden',
|
|
68
|
+
width: '100%',
|
|
69
|
+
items: 'center',
|
|
70
|
+
variants: {
|
|
71
|
+
variant: {
|
|
72
|
+
default: { bg: '$background', color: '$color' },
|
|
73
|
+
neon: { bg: '#000000' },
|
|
74
|
+
rainbow: { bg: '#000000' },
|
|
75
|
+
metallic: { bg: '#0f172a' },
|
|
76
|
+
fire: { bg: '#000000' },
|
|
77
|
+
glass: {},
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
defaultVariants: { variant: 'default' },
|
|
81
|
+
});
|
|
82
|
+
/** The host for a bare text child. Ink and size come down from the item. */
|
|
83
|
+
const Label = styled(Text, { name: 'Marquee3DText', color: 'inherit' });
|
|
84
|
+
/**
|
|
85
|
+
* The pair of loops slides the doubled track by half of itself; `direction`
|
|
86
|
+
* only ever flips their play direction. The hover rule and the reduced-motion
|
|
87
|
+
* rule select on the slot markers, so nothing here needs a class.
|
|
88
|
+
*/
|
|
89
|
+
const KEYFRAMES = `
|
|
90
|
+
@keyframes marquee-3d-x { to { transform: translateX(-50%) } }
|
|
91
|
+
@keyframes marquee-3d-y { to { transform: translateY(-50%) } }
|
|
92
|
+
@keyframes marquee-3d-pulse { 50% { opacity: 0.5 } }
|
|
93
|
+
@keyframes marquee-3d-float { 50% { transform: translateY(var(--float)) rotateX(5deg) rotateY(2deg) } }
|
|
94
|
+
[data-slot="marquee-3d"][data-pause-hover]:hover [data-slot="marquee-3d-track"] { animation-play-state: paused }
|
|
95
|
+
@media (prefers-reduced-motion: reduce) {
|
|
96
|
+
[data-slot="marquee-3d-track"], [data-slot="marquee-3d-group"], [data-slot="marquee-3d-char"] { animation: none !important }
|
|
97
|
+
}
|
|
98
|
+
`;
|
|
99
|
+
const UNMEASURED = { stage: 0, track: 0, item: 0 };
|
|
100
|
+
/** The DOM box behind a ref, if there is one; a native view has none. */
|
|
101
|
+
const box = (el) => typeof HTMLElement !== 'undefined' && el instanceof HTMLElement ? el : null;
|
|
102
|
+
export const Marquee3D = React.forwardRef(({ variant = 'default', size = 'default', direction = 'left', perspective = 'default', children, speed = 50, pauseOnHover = false, reverse = false, repeat = 5, autoFill = false, gap = 0, rotateX = 0, rotateY = 0, rotateZ = 0, gradient = false, gradientColor = '#ffffff', gradientWidth = 200, style, ...props }, ref) => {
|
|
103
|
+
const vertical = direction === 'up' || direction === 'down';
|
|
104
|
+
const flipped = direction === 'right' || direction === 'down';
|
|
105
|
+
const Axis = vertical ? YStack : XStack;
|
|
106
|
+
const stageRef = React.useRef(null);
|
|
107
|
+
const trackRef = React.useRef(null);
|
|
108
|
+
const itemRef = React.useRef(null);
|
|
109
|
+
const [span, setSpan] = React.useState(UNMEASURED);
|
|
110
|
+
// Half the track must cover the stage or the loop shows bare ground; one
|
|
111
|
+
// more copy keeps that true while the last one is still partly in view.
|
|
112
|
+
const count = autoFill && span.item > 0 ? Math.ceil(span.stage / (span.item + gap)) + 1 : repeat;
|
|
113
|
+
// Layout sizes, not bounding boxes: the stage is tilted, and a bounding box
|
|
114
|
+
// reports the projection. Re-read whenever the track's length can change:
|
|
115
|
+
// `count` and `size` move it from inside, the observer catches the rest.
|
|
116
|
+
React.useEffect(() => {
|
|
117
|
+
const along = (el) => {
|
|
118
|
+
const b = box(el);
|
|
119
|
+
return b ? (vertical ? b.offsetHeight : b.offsetWidth) : 0;
|
|
120
|
+
};
|
|
121
|
+
const measure = () => {
|
|
122
|
+
const next = { stage: along(stageRef.current), track: along(trackRef.current), item: along(itemRef.current) };
|
|
123
|
+
setSpan((s) => (s.stage === next.stage && s.track === next.track && s.item === next.item ? s : next));
|
|
124
|
+
};
|
|
125
|
+
measure();
|
|
126
|
+
if (typeof ResizeObserver === 'undefined') {
|
|
127
|
+
window.addEventListener('resize', measure);
|
|
128
|
+
return () => window.removeEventListener('resize', measure);
|
|
129
|
+
}
|
|
130
|
+
const observer = new ResizeObserver(measure);
|
|
131
|
+
for (const el of [stageRef.current, trackRef.current]) {
|
|
132
|
+
const b = box(el);
|
|
133
|
+
if (b)
|
|
134
|
+
observer.observe(b);
|
|
135
|
+
}
|
|
136
|
+
return () => observer.disconnect();
|
|
137
|
+
}, [vertical, children, count, size, gap]);
|
|
138
|
+
const duration = span.track > 0 ? span.track / 2 / speed : 20;
|
|
139
|
+
const play = flipped !== reverse ? 'reverse' : 'normal';
|
|
140
|
+
const tilt = `${DEPTH[perspective] ? `perspective(${DEPTH[perspective]}px) ` : ''}rotateX(${rotateX}deg) rotateY(${rotateY}deg) rotateZ(${rotateZ}deg)`;
|
|
141
|
+
const mask = gradient &&
|
|
142
|
+
`linear-gradient(${vertical ? 'to bottom' : 'to right'}, transparent, ${gradientColor} ${gradientWidth}px, ${gradientColor} calc(100% - ${gradientWidth}px), transparent)`;
|
|
143
|
+
// The trailing pad is the gap between the last item of one copy and the
|
|
144
|
+
// first of the next, so the period is exactly half the track.
|
|
145
|
+
const group = (hidden) => (_jsx(Axis, { ...slot('marquee-3d-group'), shrink: 0, items: "center", gap: gap, ...(vertical ? { pb: gap } : { pr: gap }), children: Array.from({ length: count }, (_, i) => (_jsx(Axis, { ref: i === 0 && !hidden ? itemRef : undefined, "aria-hidden": hidden || i > 0 || undefined, ...slot('marquee-3d-item'), shrink: 0, items: "center", gap: gap,
|
|
146
|
+
// The keyword, not a ratio: gui reads a bare number as px, and a
|
|
147
|
+
// 1.2px line box stacks every glyph on one line.
|
|
148
|
+
style: { fontSize: FONT[size], fontWeight: 700, lineHeight: 'normal', whiteSpace: 'nowrap', ...INK[variant] }, children: ink(children, Label, { ...slot('marquee-3d-text') }) }, i))) }));
|
|
149
|
+
return (_jsxs(Frame, { ref: ref, ...slot('marquee-3d'), "data-variant": variant, "data-direction": direction, "data-pause-hover": pauseOnHover || undefined, variant: variant, ...(variant === 'glass' ? glass(2) : null), height: HEIGHT[size], style: { ...(mask && { maskImage: mask, WebkitMaskImage: mask }), ...style }, ...props, children: [_jsx("style", { href: "marquee-3d", precedence: "default", children: KEYFRAMES }), _jsx(Axis, { ref: stageRef, ...slot('marquee-3d-stage'), width: "100%", height: "100%", items: "center", style: { transform: tilt }, children: _jsxs(Axis, { ref: trackRef, ...slot('marquee-3d-track'), shrink: 0,
|
|
150
|
+
// Longhands, so the play state is left to the hover rule: an
|
|
151
|
+
// inline `animation` shorthand would set it too and outrank the sheet.
|
|
152
|
+
style: {
|
|
153
|
+
willChange: 'transform',
|
|
154
|
+
animationName: `marquee-3d-${vertical ? 'y' : 'x'}`,
|
|
155
|
+
animationDuration: `${duration}s`,
|
|
156
|
+
animationTimingFunction: 'linear',
|
|
157
|
+
animationIterationCount: 'infinite',
|
|
158
|
+
animationDirection: play,
|
|
159
|
+
}, children: [group(false), group(true)] }) })] }));
|
|
160
|
+
});
|
|
161
|
+
Marquee3D.displayName = 'Marquee3D';
|
|
162
|
+
/** The five named looks, each a `Marquee3D` pinned to a variant and size; every other prop stays open. */
|
|
163
|
+
export const Marquee3DPreset = {
|
|
164
|
+
Hero: React.forwardRef((props, ref) => (_jsx(Marquee3D, { ref: ref, variant: "rainbow", size: "3xl", speed: 30, rotateX: -10, gradient: true, ...props }))),
|
|
165
|
+
Neon: React.forwardRef((props, ref) => (_jsx(Marquee3D, { ref: ref, variant: "neon", size: "xl", speed: 40, rotateY: 5, pauseOnHover: true, ...props }))),
|
|
166
|
+
Metallic: React.forwardRef((props, ref) => (_jsx(Marquee3D, { ref: ref, variant: "metallic", size: "lg", speed: 35, rotateX: -5, rotateY: 2, gradient: true, gradientColor: "#c4c4c4", ...props }))),
|
|
167
|
+
Fire: React.forwardRef((props, ref) => (_jsx(Marquee3D, { ref: ref, variant: "fire", size: "2xl", speed: 60, rotateZ: 1, gradient: true, gradientColor: "#ff6600", ...props }))),
|
|
168
|
+
Glass: React.forwardRef((props, ref) => (_jsx(Marquee3D, { ref: ref, variant: "glass", size: "lg", speed: 25, rotateX: -8, pauseOnHover: true, gradient: true, gradientColor: "rgba(255,255,255,0.9)", ...props }))),
|
|
169
|
+
};
|
|
170
|
+
Marquee3DPreset.Hero.displayName = 'Marquee3DPreset.Hero';
|
|
171
|
+
Marquee3DPreset.Neon.displayName = 'Marquee3DPreset.Neon';
|
|
172
|
+
Marquee3DPreset.Metallic.displayName = 'Marquee3DPreset.Metallic';
|
|
173
|
+
Marquee3DPreset.Fire.displayName = 'Marquee3DPreset.Fire';
|
|
174
|
+
Marquee3DPreset.Glass.displayName = 'Marquee3DPreset.Glass';
|
|
175
|
+
/**
|
|
176
|
+
* A `Marquee3D` whose text child floats glyph by glyph: each runs the same bob,
|
|
177
|
+
* offset by a tenth of a second per position, on top of the scroll. Any other
|
|
178
|
+
* child passes through untouched.
|
|
179
|
+
*/
|
|
180
|
+
export const Marquee3DFloating = React.forwardRef(({ children, floatIntensity = 10, floatSpeed = 3, ...props }, ref) => {
|
|
181
|
+
const text = typeof children === 'string' ? children : '';
|
|
182
|
+
return (_jsx(Marquee3D, { ref: ref, ...props, children: text ? (_jsx(Label, { ...slot('marquee-3d-text'), style: { display: 'inline-flex', gap: 4 }, children: [...text].map((char, i) => (_jsx(Label, { ...slot('marquee-3d-char'), style: {
|
|
183
|
+
display: 'inline-block',
|
|
184
|
+
['--float']: `${-floatIntensity}px`,
|
|
185
|
+
animation: `marquee-3d-float ${floatSpeed}s ease-in-out infinite`,
|
|
186
|
+
animationDelay: `${i * 0.1}s`,
|
|
187
|
+
}, children: char === ' ' ? '\u00A0' : char }, i))) })) : (children) }));
|
|
188
|
+
});
|
|
189
|
+
Marquee3DFloating.displayName = 'Marquee3DFloating';
|
|
190
|
+
//# sourceMappingURL=3d-marquee.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"3d-marquee.js","sourceRoot":"","sources":["../../../src/backends/gui/3d-marquee.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACnC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAmB,MAAM,YAAY,CAAA;AAC1E,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAC3B,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAO7B,iDAAiD;AACjD,MAAM,MAAM,GAAkC,EAAE,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAA;AAC5G,MAAM,IAAI,GAAkC,EAAE,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAAA;AAEzG,4DAA4D;AAC5D,MAAM,KAAK,GAAyC,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,CAAA;AAE3G,6CAA6C;AAC7C,MAAM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AAC,iBAAiB,CAAC,EAC3B,KAAK,EAAE;oBACL,OAAO,EAAE,cAAc;oBACvB,CAAC,SAAmB,CAAC,EAAE,GAAG,CAAC,cAAc,IAAI;oBAC7C,SAAS,EAAE,oBAAoB,UAAU,wBAAwB;oBACjE,cAAc,EAAE,GAAG,CAAC,GAAG,GAAG,GAAG;iBAC9B,YAEA,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,IAT1B,CAAC,CAUA,CACT,CAAC,GACI,CACT,CAAC,CAAC,CAAC,CACF,QAAQ,CACT,GACS,CACb,CAAA;AACH,CAAC,CACF,CAAA;AACD,iBAAiB,CAAC,WAAW,GAAG,mBAAmB,CAAA"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
'use client';"use strict";
|
|
2
|
+
'use client';
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.Pin3D = Pin3D;
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
/**
|
|
7
|
+
* Pin3D — a frame that lifts what is inside it while it is hovered.
|
|
8
|
+
*
|
|
9
|
+
* A white wash fades in over the scene at half strength and the scene shrinks
|
|
10
|
+
* to 95% while the pointer is on the frame or, when the frame is a link, while
|
|
11
|
+
* it holds keyboard focus; both ease back over half a second. The frame is a
|
|
12
|
+
* gui `group`, so the wash and the scene each declare their lifted look against
|
|
13
|
+
* the frame's own pseudo state and the whole effect is one compiled stylesheet
|
|
14
|
+
* with nothing held on the client.
|
|
15
|
+
*
|
|
16
|
+
* `href` renders the frame as an anchor; `title` rides along as its tooltip.
|
|
17
|
+
*/
|
|
18
|
+
const gui_1 = require("@hanzo/gui");
|
|
19
|
+
const slot_1 = require("./slot.cjs");
|
|
20
|
+
const EASE = 'cubic-bezier(0.4, 0, 0.2, 1)';
|
|
21
|
+
const DURATION = 500;
|
|
22
|
+
/** Inline, as gui's `transition` prop names a driver rung rather than a property. */
|
|
23
|
+
const ease = (property) => ({ transition: `${property} ${DURATION}ms ${EASE}` });
|
|
24
|
+
const Frame = (0, gui_1.styled)(gui_1.YStack, {
|
|
25
|
+
name: 'Pin3D',
|
|
26
|
+
group: true,
|
|
27
|
+
// A group is a size container unless told otherwise, and inline-size
|
|
28
|
+
// containment shrinks an auto-width frame in a row to nothing.
|
|
29
|
+
containerType: 'normal',
|
|
30
|
+
position: 'relative',
|
|
31
|
+
cursor: 'pointer',
|
|
32
|
+
});
|
|
33
|
+
const Wash = (0, gui_1.styled)(gui_1.YStack, {
|
|
34
|
+
name: 'Pin3DWash',
|
|
35
|
+
position: 'absolute',
|
|
36
|
+
inset: 0,
|
|
37
|
+
pointerEvents: 'none',
|
|
38
|
+
bg: '$white1',
|
|
39
|
+
opacity: 0,
|
|
40
|
+
'$group-hover': { opacity: 0.5 },
|
|
41
|
+
'$group-focusVisible': { opacity: 0.5 },
|
|
42
|
+
});
|
|
43
|
+
const Scene = (0, gui_1.styled)(gui_1.YStack, {
|
|
44
|
+
name: 'Pin3DScene',
|
|
45
|
+
scale: 1,
|
|
46
|
+
'$group-hover': { scale: 0.95 },
|
|
47
|
+
'$group-focusVisible': { scale: 0.95 },
|
|
48
|
+
});
|
|
49
|
+
function Pin3D({ title, href, children, ...props }) {
|
|
50
|
+
return ((0, jsx_runtime_1.jsxs)(Frame, { ...(0, slot_1.slot)('3d-pin'), render: href ? 'a' : 'div', ...{ href, title }, ...props, children: [(0, jsx_runtime_1.jsx)(Wash, { ...(0, slot_1.slot)('3d-pin-wash'), style: { zIndex: 10, ...ease('opacity') } }), (0, jsx_runtime_1.jsx)(Scene, { ...(0, slot_1.slot)('3d-pin-scene'), style: ease('transform'), children: children })] }));
|
|
51
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ComponentProps } from 'react';
|
|
2
|
+
declare const Frame: import("@hanzogui/web").GuiComponent<import("@hanzogui/web").TamaDefer, import("@hanzogui/web").GuiElement, import("@hanzogui/core").RNGuiViewNonStyleProps, import("@hanzogui/web").StackStyleBase, {
|
|
3
|
+
elevation?: number | import("@hanzogui/web").SizeTokens | undefined;
|
|
4
|
+
fullscreen?: boolean | undefined;
|
|
5
|
+
}, import("@hanzogui/web").StaticConfigPublic>;
|
|
6
|
+
export type Pin3DProps = ComponentProps<typeof Frame> & {
|
|
7
|
+
/** Tooltip for the destination; carried through as the title attribute. */
|
|
8
|
+
title?: string;
|
|
9
|
+
/** Where the pin leads. Renders the frame as a link when set. */
|
|
10
|
+
href?: string;
|
|
11
|
+
};
|
|
12
|
+
export declare function Pin3D({ title, href, children, ...props }: Pin3DProps): import("react").JSX.Element;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=3d-pin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"3d-pin.d.ts","sourceRoot":"","sources":["../../../src/backends/gui/3d-pin.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;AAS3C,QAAA,MAAM,KAAK;;;8CAQT,CAAA;AAoBF,MAAM,MAAM,UAAU,GAAG,cAAc,CAAC,OAAO,KAAK,CAAC,GAAG;IACtD,2EAA2E;IAC3E,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,iEAAiE;IACjE,IAAI,CAAC,EAAE,MAAM,CAAA;CACd,CAAA;AAED,wBAAgB,KAAK,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,UAAU,+BAepE"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
/**
|
|
4
|
+
* Pin3D — a frame that lifts what is inside it while it is hovered.
|
|
5
|
+
*
|
|
6
|
+
* A white wash fades in over the scene at half strength and the scene shrinks
|
|
7
|
+
* to 95% while the pointer is on the frame or, when the frame is a link, while
|
|
8
|
+
* it holds keyboard focus; both ease back over half a second. The frame is a
|
|
9
|
+
* gui `group`, so the wash and the scene each declare their lifted look against
|
|
10
|
+
* the frame's own pseudo state and the whole effect is one compiled stylesheet
|
|
11
|
+
* with nothing held on the client.
|
|
12
|
+
*
|
|
13
|
+
* `href` renders the frame as an anchor; `title` rides along as its tooltip.
|
|
14
|
+
*/
|
|
15
|
+
import { YStack, styled } from '@hanzo/gui';
|
|
16
|
+
import { slot } from './slot.js';
|
|
17
|
+
const EASE = 'cubic-bezier(0.4, 0, 0.2, 1)';
|
|
18
|
+
const DURATION = 500;
|
|
19
|
+
/** Inline, as gui's `transition` prop names a driver rung rather than a property. */
|
|
20
|
+
const ease = (property) => ({ transition: `${property} ${DURATION}ms ${EASE}` });
|
|
21
|
+
const Frame = styled(YStack, {
|
|
22
|
+
name: 'Pin3D',
|
|
23
|
+
group: true,
|
|
24
|
+
// A group is a size container unless told otherwise, and inline-size
|
|
25
|
+
// containment shrinks an auto-width frame in a row to nothing.
|
|
26
|
+
containerType: 'normal',
|
|
27
|
+
position: 'relative',
|
|
28
|
+
cursor: 'pointer',
|
|
29
|
+
});
|
|
30
|
+
const Wash = styled(YStack, {
|
|
31
|
+
name: 'Pin3DWash',
|
|
32
|
+
position: 'absolute',
|
|
33
|
+
inset: 0,
|
|
34
|
+
pointerEvents: 'none',
|
|
35
|
+
bg: '$white1',
|
|
36
|
+
opacity: 0,
|
|
37
|
+
'$group-hover': { opacity: 0.5 },
|
|
38
|
+
'$group-focusVisible': { opacity: 0.5 },
|
|
39
|
+
});
|
|
40
|
+
const Scene = styled(YStack, {
|
|
41
|
+
name: 'Pin3DScene',
|
|
42
|
+
scale: 1,
|
|
43
|
+
'$group-hover': { scale: 0.95 },
|
|
44
|
+
'$group-focusVisible': { scale: 0.95 },
|
|
45
|
+
});
|
|
46
|
+
export function Pin3D({ title, href, children, ...props }) {
|
|
47
|
+
return (_jsxs(Frame, { ...slot('3d-pin'), render: href ? 'a' : 'div', ...{ href, title }, ...props, children: [_jsx(Wash, { ...slot('3d-pin-wash'), style: { zIndex: 10, ...ease('opacity') } }), _jsx(Scene, { ...slot('3d-pin-scene'), style: ease('transform'), children: children })] }));
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=3d-pin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"3d-pin.js","sourceRoot":"","sources":["../../../src/backends/gui/3d-pin.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAE3C,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAE7B,MAAM,IAAI,GAAG,8BAA8B,CAAA;AAC3C,MAAM,QAAQ,GAAG,GAAG,CAAA;AAEpB,qFAAqF;AACrF,MAAM,IAAI,GAAG,CAAC,QAAgB,EAAE,EAAE,CAAC,CAAC,EAAE,UAAU,EAAE,GAAG,QAAQ,IAAI,QAAQ,MAAM,IAAI,EAAE,EAAE,CAAC,CAAA;AAExF,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE;IAC3B,IAAI,EAAE,OAAO;IACb,KAAK,EAAE,IAAI;IACX,qEAAqE;IACrE,+DAA+D;IAC/D,aAAa,EAAE,QAAQ;IACvB,QAAQ,EAAE,UAAU;IACpB,MAAM,EAAE,SAAS;CAClB,CAAC,CAAA;AAEF,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE;IAC1B,IAAI,EAAE,WAAW;IACjB,QAAQ,EAAE,UAAU;IACpB,KAAK,EAAE,CAAC;IACR,aAAa,EAAE,MAAM;IACrB,EAAE,EAAE,SAAS;IACb,OAAO,EAAE,CAAC;IACV,cAAc,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE;IAChC,qBAAqB,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE;CACxC,CAAC,CAAA;AAEF,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE;IAC3B,IAAI,EAAE,YAAY;IAClB,KAAK,EAAE,CAAC;IACR,cAAc,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE;IAC/B,qBAAqB,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE;CACvC,CAAC,CAAA;AASF,MAAM,UAAU,KAAK,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAc;IACnE,OAAO,CACL,MAAC,KAAK,OACA,IAAI,CAAC,QAAQ,CAAC,EAClB,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,KACrB,EAAE,IAAI,EAAE,KAAK,EAAa,KAC3B,KAAK,aAGT,KAAC,IAAI,OAAK,IAAI,CAAC,aAAa,CAAC,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,GAAI,EAC5E,KAAC,KAAK,OAAK,IAAI,CAAC,cAAc,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,YACtD,QAAQ,GACH,IACF,CACT,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
'use client';"use strict";
|
|
2
|
+
'use client';
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.AdvancedChart = void 0;
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
/**
|
|
7
|
+
* AdvancedChart — a TradingView chart of one symbol, in a gui frame.
|
|
8
|
+
*
|
|
9
|
+
* The candles are TradingView's, drawn inside TradingView's own document, so
|
|
10
|
+
* the chart is an `<iframe>` and nothing here draws a pixel of it. What this
|
|
11
|
+
* owns is the frame around it and the settings the chart opens with — symbol,
|
|
12
|
+
* interval, theme, the toolbars, the save-image control — written into the
|
|
13
|
+
* iframe's address the way TradingView's own embed script writes them:
|
|
14
|
+
* `/embed-widget/advanced-chart/?locale=…#<settings as JSON>`. Nothing is
|
|
15
|
+
* fetched or injected at mount, so the markup is the same on the server and in
|
|
16
|
+
* the browser, and the frame has its height before the chart arrives.
|
|
17
|
+
*
|
|
18
|
+
* The iframe is keyed on that address. A browser treats a `src` that differs
|
|
19
|
+
* only in its fragment as a same-document navigation and does not reload, so
|
|
20
|
+
* without the key a new `symbol` would change the URL and leave the old chart
|
|
21
|
+
* on screen.
|
|
22
|
+
*/
|
|
23
|
+
const gui_1 = require("@hanzo/gui");
|
|
24
|
+
const slot_1 = require("./slot.cjs");
|
|
25
|
+
const EMBED = 'https://www.tradingview-widget.com/embed-widget/advanced-chart/?locale=en#';
|
|
26
|
+
/** The settings TradingView reads, with the documented defaults filled in. */
|
|
27
|
+
const settings = ({ symbol = 'NASDAQ:AAPL', interval = 'D', theme = 'dark', width = '100%', height = 500, autosize = true, hideTopToolbar = false, hideSideToolbar = false, saveImage = true, }) => ({
|
|
28
|
+
symbol,
|
|
29
|
+
interval,
|
|
30
|
+
theme,
|
|
31
|
+
width,
|
|
32
|
+
height,
|
|
33
|
+
autosize,
|
|
34
|
+
hide_top_toolbar: hideTopToolbar,
|
|
35
|
+
hide_side_toolbar: hideSideToolbar,
|
|
36
|
+
save_image: saveImage,
|
|
37
|
+
allow_symbol_change: true,
|
|
38
|
+
timezone: 'Etc/UTC',
|
|
39
|
+
style: '1',
|
|
40
|
+
calendar: false,
|
|
41
|
+
support_host: 'https://www.tradingview.com',
|
|
42
|
+
});
|
|
43
|
+
const AdvancedChart = ({ symbol, interval, theme, width, height, autosize, hideTopToolbar, hideSideToolbar, saveImage, ...props }) => {
|
|
44
|
+
const s = settings({
|
|
45
|
+
symbol,
|
|
46
|
+
interval,
|
|
47
|
+
theme,
|
|
48
|
+
width,
|
|
49
|
+
height,
|
|
50
|
+
autosize,
|
|
51
|
+
hideTopToolbar,
|
|
52
|
+
hideSideToolbar,
|
|
53
|
+
saveImage,
|
|
54
|
+
});
|
|
55
|
+
const src = EMBED + encodeURIComponent(JSON.stringify(s));
|
|
56
|
+
return ((0, jsx_runtime_1.jsx)(gui_1.YStack, { ...(0, slot_1.slot)('advanced-chart'), "data-symbol": s.symbol, "data-interval": s.interval,
|
|
57
|
+
// The documented size is TradingView's — a number or a percent string —
|
|
58
|
+
// and gui declares a narrower one; on web both reach CSS as written.
|
|
59
|
+
width: s.width, height: s.height, overflow: "hidden", position: "relative", bg: "$panel", ...props, children: gui_1.isWeb && ((0, jsx_runtime_1.jsx)("iframe", { src: src, title: `${s.symbol} chart`, loading: "lazy", scrolling: "no", allowFullScreen: true, style: { display: 'block', width: '100%', height: '100%', border: 0 } }, src)) }));
|
|
60
|
+
};
|
|
61
|
+
exports.AdvancedChart = AdvancedChart;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AdvancedChart — a TradingView chart of one symbol, in a gui frame.
|
|
3
|
+
*
|
|
4
|
+
* The candles are TradingView's, drawn inside TradingView's own document, so
|
|
5
|
+
* the chart is an `<iframe>` and nothing here draws a pixel of it. What this
|
|
6
|
+
* owns is the frame around it and the settings the chart opens with — symbol,
|
|
7
|
+
* interval, theme, the toolbars, the save-image control — written into the
|
|
8
|
+
* iframe's address the way TradingView's own embed script writes them:
|
|
9
|
+
* `/embed-widget/advanced-chart/?locale=…#<settings as JSON>`. Nothing is
|
|
10
|
+
* fetched or injected at mount, so the markup is the same on the server and in
|
|
11
|
+
* the browser, and the frame has its height before the chart arrives.
|
|
12
|
+
*
|
|
13
|
+
* The iframe is keyed on that address. A browser treats a `src` that differs
|
|
14
|
+
* only in its fragment as a same-document navigation and does not reload, so
|
|
15
|
+
* without the key a new `symbol` would change the URL and leave the old chart
|
|
16
|
+
* on screen.
|
|
17
|
+
*/
|
|
18
|
+
import { type YStackProps } from '@hanzo/gui';
|
|
19
|
+
export type AdvancedChartInterval = '1' | '3' | '5' | '15' | '30' | '60' | '120' | '180' | '240' | 'D' | 'W' | 'M';
|
|
20
|
+
export type AdvancedChartTheme = 'light' | 'dark';
|
|
21
|
+
export interface AdvancedChartProps extends Omit<YStackProps, 'width' | 'height' | 'theme'> {
|
|
22
|
+
/** The symbol to chart, exchange-qualified. */
|
|
23
|
+
symbol?: string;
|
|
24
|
+
/** Minutes, or a day, a week, a month per bar. */
|
|
25
|
+
interval?: AdvancedChartInterval;
|
|
26
|
+
/** The chart's own palette; independent of the surrounding gui theme. */
|
|
27
|
+
theme?: AdvancedChartTheme;
|
|
28
|
+
width?: string | number;
|
|
29
|
+
height?: string | number;
|
|
30
|
+
/** Fill the frame; the chart then ignores its own `width` and `height`. */
|
|
31
|
+
autosize?: boolean;
|
|
32
|
+
hideTopToolbar?: boolean;
|
|
33
|
+
hideSideToolbar?: boolean;
|
|
34
|
+
saveImage?: boolean;
|
|
35
|
+
}
|
|
36
|
+
declare const AdvancedChart: ({ symbol, interval, theme, width, height, autosize, hideTopToolbar, hideSideToolbar, saveImage, ...props }: AdvancedChartProps) => import("react").JSX.Element;
|
|
37
|
+
export { AdvancedChart };
|
|
38
|
+
//# sourceMappingURL=advanced-chart.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"advanced-chart.d.ts","sourceRoot":"","sources":["../../../src/backends/gui/advanced-chart.tsx"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAiB,KAAK,WAAW,EAAE,MAAM,YAAY,CAAA;AAG5D,MAAM,MAAM,qBAAqB,GAC7B,GAAG,GACH,GAAG,GACH,GAAG,GACH,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,KAAK,GACL,KAAK,GACL,KAAK,GACL,GAAG,GACH,GAAG,GACH,GAAG,CAAA;AAEP,MAAM,MAAM,kBAAkB,GAAG,OAAO,GAAG,MAAM,CAAA;AAEjD,MAAM,WAAW,kBAAmB,SAAQ,IAAI,CAAC,WAAW,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;IACzF,+CAA+C;IAC/C,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,kDAAkD;IAClD,QAAQ,CAAC,EAAE,qBAAqB,CAAA;IAChC,yEAAyE;IACzE,KAAK,CAAC,EAAE,kBAAkB,CAAA;IAC1B,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACvB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACxB,2EAA2E;IAC3E,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB;AAgCD,QAAA,MAAM,aAAa,+GAWhB,kBAAkB,gCAwCpB,CAAA;AAED,OAAO,EAAE,aAAa,EAAE,CAAA"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
/**
|
|
4
|
+
* AdvancedChart — a TradingView chart of one symbol, in a gui frame.
|
|
5
|
+
*
|
|
6
|
+
* The candles are TradingView's, drawn inside TradingView's own document, so
|
|
7
|
+
* the chart is an `<iframe>` and nothing here draws a pixel of it. What this
|
|
8
|
+
* owns is the frame around it and the settings the chart opens with — symbol,
|
|
9
|
+
* interval, theme, the toolbars, the save-image control — written into the
|
|
10
|
+
* iframe's address the way TradingView's own embed script writes them:
|
|
11
|
+
* `/embed-widget/advanced-chart/?locale=…#<settings as JSON>`. Nothing is
|
|
12
|
+
* fetched or injected at mount, so the markup is the same on the server and in
|
|
13
|
+
* the browser, and the frame has its height before the chart arrives.
|
|
14
|
+
*
|
|
15
|
+
* The iframe is keyed on that address. A browser treats a `src` that differs
|
|
16
|
+
* only in its fragment as a same-document navigation and does not reload, so
|
|
17
|
+
* without the key a new `symbol` would change the URL and leave the old chart
|
|
18
|
+
* on screen.
|
|
19
|
+
*/
|
|
20
|
+
import { YStack, isWeb } from '@hanzo/gui';
|
|
21
|
+
import { slot } from './slot.js';
|
|
22
|
+
const EMBED = 'https://www.tradingview-widget.com/embed-widget/advanced-chart/?locale=en#';
|
|
23
|
+
/** The settings TradingView reads, with the documented defaults filled in. */
|
|
24
|
+
const settings = ({ symbol = 'NASDAQ:AAPL', interval = 'D', theme = 'dark', width = '100%', height = 500, autosize = true, hideTopToolbar = false, hideSideToolbar = false, saveImage = true, }) => ({
|
|
25
|
+
symbol,
|
|
26
|
+
interval,
|
|
27
|
+
theme,
|
|
28
|
+
width,
|
|
29
|
+
height,
|
|
30
|
+
autosize,
|
|
31
|
+
hide_top_toolbar: hideTopToolbar,
|
|
32
|
+
hide_side_toolbar: hideSideToolbar,
|
|
33
|
+
save_image: saveImage,
|
|
34
|
+
allow_symbol_change: true,
|
|
35
|
+
timezone: 'Etc/UTC',
|
|
36
|
+
style: '1',
|
|
37
|
+
calendar: false,
|
|
38
|
+
support_host: 'https://www.tradingview.com',
|
|
39
|
+
});
|
|
40
|
+
const AdvancedChart = ({ symbol, interval, theme, width, height, autosize, hideTopToolbar, hideSideToolbar, saveImage, ...props }) => {
|
|
41
|
+
const s = settings({
|
|
42
|
+
symbol,
|
|
43
|
+
interval,
|
|
44
|
+
theme,
|
|
45
|
+
width,
|
|
46
|
+
height,
|
|
47
|
+
autosize,
|
|
48
|
+
hideTopToolbar,
|
|
49
|
+
hideSideToolbar,
|
|
50
|
+
saveImage,
|
|
51
|
+
});
|
|
52
|
+
const src = EMBED + encodeURIComponent(JSON.stringify(s));
|
|
53
|
+
return (_jsx(YStack, { ...slot('advanced-chart'), "data-symbol": s.symbol, "data-interval": s.interval,
|
|
54
|
+
// The documented size is TradingView's — a number or a percent string —
|
|
55
|
+
// and gui declares a narrower one; on web both reach CSS as written.
|
|
56
|
+
width: s.width, height: s.height, overflow: "hidden", position: "relative", bg: "$panel", ...props, children: isWeb && (_jsx("iframe", { src: src, title: `${s.symbol} chart`, loading: "lazy", scrolling: "no", allowFullScreen: true, style: { display: 'block', width: '100%', height: '100%', border: 0 } }, src)) }));
|
|
57
|
+
};
|
|
58
|
+
export { AdvancedChart };
|
|
59
|
+
//# sourceMappingURL=advanced-chart.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"advanced-chart.js","sourceRoot":"","sources":["../../../src/backends/gui/advanced-chart.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAE,MAAM,EAAE,KAAK,EAAoB,MAAM,YAAY,CAAA;AAC5D,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAkC7B,MAAM,KAAK,GAAG,4EAA4E,CAAA;AAE1F,8EAA8E;AAC9E,MAAM,QAAQ,GAAG,CAAC,EAChB,MAAM,GAAG,aAAa,EACtB,QAAQ,GAAG,GAAG,EACd,KAAK,GAAG,MAAM,EACd,KAAK,GAAG,MAAM,EACd,MAAM,GAAG,GAAG,EACZ,QAAQ,GAAG,IAAI,EACf,cAAc,GAAG,KAAK,EACtB,eAAe,GAAG,KAAK,EACvB,SAAS,GAAG,IAAI,GACG,EAAE,EAAE,CAAC,CAAC;IACzB,MAAM;IACN,QAAQ;IACR,KAAK;IACL,KAAK;IACL,MAAM;IACN,QAAQ;IACR,gBAAgB,EAAE,cAAc;IAChC,iBAAiB,EAAE,eAAe;IAClC,UAAU,EAAE,SAAS;IACrB,mBAAmB,EAAE,IAAI;IACzB,QAAQ,EAAE,SAAS;IACnB,KAAK,EAAE,GAAG;IACV,QAAQ,EAAE,KAAK;IACf,YAAY,EAAE,6BAA6B;CAC5C,CAAC,CAAA;AAEF,MAAM,aAAa,GAAG,CAAC,EACrB,MAAM,EACN,QAAQ,EACR,KAAK,EACL,KAAK,EACL,MAAM,EACN,QAAQ,EACR,cAAc,EACd,eAAe,EACf,SAAS,EACT,GAAG,KAAK,EACW,EAAE,EAAE;IACvB,MAAM,CAAC,GAAG,QAAQ,CAAC;QACjB,MAAM;QACN,QAAQ;QACR,KAAK;QACL,KAAK;QACL,MAAM;QACN,QAAQ;QACR,cAAc;QACd,eAAe;QACf,SAAS;KACV,CAAC,CAAA;IACF,MAAM,GAAG,GAAG,KAAK,GAAG,kBAAkB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAA;IACzD,OAAO,CACL,KAAC,MAAM,OACD,IAAI,CAAC,gBAAgB,CAAC,iBACb,CAAC,CAAC,MAAM,mBACN,CAAC,CAAC,QAAQ;QACzB,wEAAwE;QACxE,qEAAqE;QACrE,KAAK,EAAE,CAAC,CAAC,KAA6B,EACtC,MAAM,EAAE,CAAC,CAAC,MAA+B,EACzC,QAAQ,EAAC,QAAQ,EACjB,QAAQ,EAAC,UAAU,EACnB,EAAE,EAAC,QAAQ,KACP,KAAK,YAER,KAAK,IAAI,CACR,iBAEE,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,GAAG,CAAC,CAAC,MAAM,QAAQ,EAC1B,OAAO,EAAC,MAAM,EACd,SAAS,EAAC,IAAI,EACd,eAAe,QACf,KAAK,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,IANhE,GAAG,CAOR,CACH,GACM,CACV,CAAA;AACH,CAAC,CAAA;AAED,OAAO,EAAE,aAAa,EAAE,CAAA"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
'use client';"use strict";
|
|
2
|
+
'use client';
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.AlertDescription = exports.AlertTitle = void 0;
|
|
5
|
+
exports.Alert = Alert;
|
|
6
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
+
/**
|
|
8
|
+
* Alert — a callout for one piece of information the page wants read: an
|
|
9
|
+
* optional leading icon, a title and a description in a bordered box, with a
|
|
10
|
+
* `default` and a `destructive` variant.
|
|
11
|
+
*
|
|
12
|
+
* The icon is the first child when that child is neither `AlertTitle` nor
|
|
13
|
+
* `AlertDescription`. It sits absolutely at the top-left corner and the text
|
|
14
|
+
* column indents to clear it, so `<Alert><Icon /><AlertTitle /><AlertDescription /></Alert>`
|
|
15
|
+
* needs no `icon` prop and a trailing action stays in the flow. Surface, icon,
|
|
16
|
+
* title and description are four styled parts sharing one `variant` through a
|
|
17
|
+
* styled context — the surface owns the border, the other three own color.
|
|
18
|
+
*/
|
|
19
|
+
const react_1 = require("react");
|
|
20
|
+
const gui_1 = require("@hanzo/gui");
|
|
21
|
+
const ink_1 = require("./ink.cjs");
|
|
22
|
+
const slot_1 = require("./slot.cjs");
|
|
23
|
+
const ICON = 16;
|
|
24
|
+
const ICON_GUTTER = 28;
|
|
25
|
+
const AlertContext = /* @__PURE__ */ (0, gui_1.createStyledContext)({ variant: 'default' });
|
|
26
|
+
const AlertFrame = (0, gui_1.styled)(gui_1.YStack, {
|
|
27
|
+
name: 'Alert',
|
|
28
|
+
context: AlertContext,
|
|
29
|
+
position: 'relative',
|
|
30
|
+
width: '100%',
|
|
31
|
+
rounded: '$4',
|
|
32
|
+
borderWidth: 1,
|
|
33
|
+
borderColor: '$borderColor',
|
|
34
|
+
bg: '$background',
|
|
35
|
+
p: '$4',
|
|
36
|
+
variants: {
|
|
37
|
+
variant: {
|
|
38
|
+
default: {},
|
|
39
|
+
destructive: { borderColor: '$red9' },
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
defaultVariants: { variant: 'default' },
|
|
43
|
+
});
|
|
44
|
+
const AlertTitleText = (0, gui_1.styled)(gui_1.SizableText, {
|
|
45
|
+
name: 'AlertTitle',
|
|
46
|
+
context: AlertContext,
|
|
47
|
+
render: 'h5',
|
|
48
|
+
size: '$3',
|
|
49
|
+
fontWeight: '500',
|
|
50
|
+
lineHeight: 16,
|
|
51
|
+
mb: '$1',
|
|
52
|
+
color: '$ink',
|
|
53
|
+
variants: {
|
|
54
|
+
variant: {
|
|
55
|
+
default: {},
|
|
56
|
+
destructive: { color: '$red9' },
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
// A div, so a paragraph or a list inside the description is valid markup.
|
|
61
|
+
const AlertDescriptionText = (0, gui_1.styled)(gui_1.SizableText, {
|
|
62
|
+
name: 'AlertDescription',
|
|
63
|
+
context: AlertContext,
|
|
64
|
+
render: 'div',
|
|
65
|
+
size: '$2',
|
|
66
|
+
color: '$quiet',
|
|
67
|
+
variants: {
|
|
68
|
+
variant: {
|
|
69
|
+
default: {},
|
|
70
|
+
destructive: { color: '$red9' },
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
// A Text host because a View takes no `color`, and an svg child paints in
|
|
75
|
+
// `currentColor`.
|
|
76
|
+
const IconSlot = (0, gui_1.styled)(gui_1.SizableText, {
|
|
77
|
+
name: 'AlertIcon',
|
|
78
|
+
context: AlertContext,
|
|
79
|
+
display: 'flex',
|
|
80
|
+
position: 'absolute',
|
|
81
|
+
t: '$4',
|
|
82
|
+
l: '$4',
|
|
83
|
+
width: ICON,
|
|
84
|
+
height: ICON,
|
|
85
|
+
items: 'center',
|
|
86
|
+
justify: 'center',
|
|
87
|
+
color: '$ink',
|
|
88
|
+
variants: {
|
|
89
|
+
variant: {
|
|
90
|
+
default: {},
|
|
91
|
+
destructive: { color: '$red9' },
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
function Alert({ variant = 'default', children, ...props }) {
|
|
96
|
+
const resolved = variant ?? 'default';
|
|
97
|
+
const items = react_1.Children.toArray(children);
|
|
98
|
+
const head = items[0];
|
|
99
|
+
const icon = (0, react_1.isValidElement)(head) && head.type !== AlertTitle && head.type !== AlertDescription ? head : null;
|
|
100
|
+
const body = icon ? items.slice(1) : items;
|
|
101
|
+
return ((0, jsx_runtime_1.jsxs)(AlertFrame, { role: "alert", variant: resolved, ...(0, slot_1.slot)('alert'), "data-variant": resolved, ...props, children: [icon ? ((0, jsx_runtime_1.jsx)(IconSlot, { variant: resolved, ...(0, slot_1.slot)('alert-icon'), children: icon })) : null, (0, jsx_runtime_1.jsx)(gui_1.YStack, { pl: icon ? ICON_GUTTER : 0, children: (0, ink_1.ink)(body) })] }));
|
|
102
|
+
}
|
|
103
|
+
const AlertTitle = (props) => (0, jsx_runtime_1.jsx)(AlertTitleText, { ...(0, slot_1.slot)('alert-title'), ...props });
|
|
104
|
+
exports.AlertTitle = AlertTitle;
|
|
105
|
+
const AlertDescription = (props) => ((0, jsx_runtime_1.jsx)(AlertDescriptionText, { ...(0, slot_1.slot)('alert-description'), ...props }));
|
|
106
|
+
exports.AlertDescription = AlertDescription;
|