@hanzo/ui 8.27.10 → 8.27.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/backends/gui/comparison.cjs +17 -21
- package/dist/backends/gui/comparison.d.ts +4 -5
- package/dist/backends/gui/comparison.d.ts.map +1 -1
- package/dist/backends/gui/comparison.js +18 -22
- package/dist/backends/gui/comparison.js.map +1 -1
- package/dist/backends/gui/crypto-screener.cjs +21 -31
- package/dist/backends/gui/crypto-screener.d.ts +20 -24
- package/dist/backends/gui/crypto-screener.d.ts.map +1 -1
- package/dist/backends/gui/crypto-screener.js +21 -31
- package/dist/backends/gui/crypto-screener.js.map +1 -1
- package/dist/backends/gui/cursor.cjs +15 -18
- package/dist/backends/gui/cursor.d.ts +4 -3
- package/dist/backends/gui/cursor.d.ts.map +1 -1
- package/dist/backends/gui/cursor.js +15 -18
- package/dist/backends/gui/cursor.js.map +1 -1
- package/dist/backends/gui/data-table.cjs +144 -184
- package/dist/backends/gui/data-table.d.ts +64 -44
- package/dist/backends/gui/data-table.d.ts.map +1 -1
- package/dist/backends/gui/data-table.js +146 -152
- package/dist/backends/gui/data-table.js.map +1 -1
- package/dist/backends/gui/dock.cjs +1 -1
- package/dist/backends/gui/dock.d.ts.map +1 -1
- package/dist/backends/gui/dock.js +1 -1
- package/dist/backends/gui/dock.js.map +1 -1
- package/dist/backends/gui/editor.cjs +35 -31
- package/dist/backends/gui/editor.d.ts +11 -11
- package/dist/backends/gui/editor.d.ts.map +1 -1
- package/dist/backends/gui/editor.js +35 -31
- package/dist/backends/gui/editor.js.map +1 -1
- package/dist/backends/gui/field.cjs +132 -0
- package/dist/backends/gui/field.d.ts +74 -0
- package/dist/backends/gui/field.d.ts.map +1 -0
- package/dist/backends/gui/field.js +121 -0
- package/dist/backends/gui/field.js.map +1 -0
- package/dist/backends/gui/gantt.cjs +17 -19
- package/dist/backends/gui/gantt.d.ts +4 -5
- package/dist/backends/gui/gantt.d.ts.map +1 -1
- package/dist/backends/gui/gantt.js +18 -21
- package/dist/backends/gui/gantt.js.map +1 -1
- package/dist/backends/gui/glimpse.cjs +88 -0
- package/dist/backends/gui/glimpse.d.ts +57 -0
- package/dist/backends/gui/glimpse.d.ts.map +1 -0
- package/dist/backends/gui/glimpse.js +81 -0
- package/dist/backends/gui/glimpse.js.map +1 -0
- package/dist/backends/gui/grid-pattern.cjs +119 -0
- package/dist/backends/gui/grid-pattern.d.ts +96 -0
- package/dist/backends/gui/grid-pattern.d.ts.map +1 -0
- package/dist/backends/gui/grid-pattern.js +84 -0
- package/dist/backends/gui/grid-pattern.js.map +1 -0
- package/dist/backends/gui/image-crop.cjs +35 -0
- package/dist/backends/gui/image-crop.d.ts +20 -0
- package/dist/backends/gui/image-crop.d.ts.map +1 -0
- package/dist/backends/gui/image-crop.js +33 -0
- package/dist/backends/gui/image-crop.js.map +1 -0
- package/dist/backends/gui/image-zoom.cjs +58 -0
- package/dist/backends/gui/image-zoom.d.ts +16 -0
- package/dist/backends/gui/image-zoom.d.ts.map +1 -0
- package/dist/backends/gui/image-zoom.js +56 -0
- package/dist/backends/gui/image-zoom.js.map +1 -0
- package/dist/backends/gui/index.cjs +159 -1
- package/dist/backends/gui/index.d.ts +49 -0
- package/dist/backends/gui/index.d.ts.map +1 -1
- package/dist/backends/gui/index.js +49 -0
- package/dist/backends/gui/index.js.map +1 -1
- package/dist/backends/gui/interactive-grid-pattern.cjs +61 -0
- package/dist/backends/gui/interactive-grid-pattern.d.ts +28 -0
- package/dist/backends/gui/interactive-grid-pattern.d.ts.map +1 -0
- package/dist/backends/gui/interactive-grid-pattern.js +26 -0
- package/dist/backends/gui/interactive-grid-pattern.js.map +1 -0
- package/dist/backends/gui/iphone-15-pro.cjs +83 -0
- package/dist/backends/gui/iphone-15-pro.d.ts +16 -0
- package/dist/backends/gui/iphone-15-pro.d.ts.map +1 -0
- package/dist/backends/gui/iphone-15-pro.js +81 -0
- package/dist/backends/gui/iphone-15-pro.js.map +1 -0
- package/dist/backends/gui/item.cjs +154 -0
- package/dist/backends/gui/item.d.ts +72 -0
- package/dist/backends/gui/item.d.ts.map +1 -0
- package/dist/backends/gui/item.js +143 -0
- package/dist/backends/gui/item.js.map +1 -0
- package/dist/backends/gui/kanban.cjs +247 -0
- package/dist/backends/gui/kanban.d.ts +37 -0
- package/dist/backends/gui/kanban.d.ts.map +1 -0
- package/dist/backends/gui/kanban.js +212 -0
- package/dist/backends/gui/kanban.js.map +1 -0
- package/dist/backends/gui/kbd.cjs +45 -0
- package/dist/backends/gui/kbd.d.ts +8 -0
- package/dist/backends/gui/kbd.d.ts.map +1 -0
- package/dist/backends/gui/kbd.js +42 -0
- package/dist/backends/gui/kbd.js.map +1 -0
- package/dist/backends/gui/limelight-nav.cjs +201 -0
- package/dist/backends/gui/limelight-nav.d.ts +20 -0
- package/dist/backends/gui/limelight-nav.d.ts.map +1 -0
- package/dist/backends/gui/limelight-nav.js +166 -0
- package/dist/backends/gui/limelight-nav.js.map +1 -0
- package/dist/backends/gui/list.cjs +26 -0
- package/dist/backends/gui/list.d.ts +15 -0
- package/dist/backends/gui/list.d.ts.map +1 -0
- package/dist/backends/gui/list.js +23 -0
- package/dist/backends/gui/list.js.map +1 -0
- package/dist/backends/gui/macos-dock.cjs +84 -0
- package/dist/backends/gui/macos-dock.d.ts +30 -0
- package/dist/backends/gui/macos-dock.d.ts.map +1 -0
- package/dist/backends/gui/macos-dock.js +82 -0
- package/dist/backends/gui/macos-dock.js.map +1 -0
- package/dist/backends/gui/magnetic.cjs +40 -0
- package/dist/backends/gui/magnetic.d.ts +12 -0
- package/dist/backends/gui/magnetic.d.ts.map +1 -0
- package/dist/backends/gui/magnetic.js +38 -0
- package/dist/backends/gui/magnetic.js.map +1 -0
- package/dist/backends/gui/marquee.cjs +110 -0
- package/dist/backends/gui/marquee.d.ts +44 -0
- package/dist/backends/gui/marquee.d.ts.map +1 -0
- package/dist/backends/gui/marquee.js +75 -0
- package/dist/backends/gui/marquee.js.map +1 -0
- package/dist/backends/gui/menu-dock.cjs +64 -0
- package/dist/backends/gui/menu-dock.d.ts +21 -0
- package/dist/backends/gui/menu-dock.d.ts.map +1 -0
- package/dist/backends/gui/menu-dock.js +62 -0
- package/dist/backends/gui/menu-dock.js.map +1 -0
- package/dist/backends/gui/menubar.cjs +227 -0
- package/dist/backends/gui/menubar.d.ts +106 -0
- package/dist/backends/gui/menubar.d.ts.map +1 -0
- package/dist/backends/gui/menubar.js +177 -0
- package/dist/backends/gui/menubar.js.map +1 -0
- package/dist/backends/gui/message-dock.cjs +111 -0
- package/dist/backends/gui/message-dock.d.ts +22 -0
- package/dist/backends/gui/message-dock.d.ts.map +1 -0
- package/dist/backends/gui/message-dock.js +110 -0
- package/dist/backends/gui/message-dock.js.map +1 -0
- package/dist/backends/gui/mini-calendar.cjs +25 -0
- package/dist/backends/gui/mini-calendar.d.ts +22 -0
- package/dist/backends/gui/mini-calendar.d.ts.map +1 -0
- package/dist/backends/gui/mini-calendar.js +24 -0
- package/dist/backends/gui/mini-calendar.js.map +1 -0
- package/dist/backends/gui/minimal-tiptap.cjs +56 -0
- package/dist/backends/gui/minimal-tiptap.d.ts +20 -0
- package/dist/backends/gui/minimal-tiptap.d.ts.map +1 -0
- package/dist/backends/gui/minimal-tiptap.js +21 -0
- package/dist/backends/gui/minimal-tiptap.js.map +1 -0
- package/dist/backends/gui/motion-highlight.cjs +83 -0
- package/dist/backends/gui/motion-highlight.d.ts +27 -0
- package/dist/backends/gui/motion-highlight.d.ts.map +1 -0
- package/dist/backends/gui/motion-highlight.js +48 -0
- package/dist/backends/gui/motion-highlight.js.map +1 -0
- package/dist/backends/gui/navigation-bar.cjs +47 -0
- package/dist/backends/gui/navigation-bar.d.ts +48 -0
- package/dist/backends/gui/navigation-bar.d.ts.map +1 -0
- package/dist/backends/gui/navigation-bar.js +45 -0
- package/dist/backends/gui/navigation-bar.js.map +1 -0
- package/dist/backends/gui/news-timeline.cjs +47 -0
- package/dist/backends/gui/news-timeline.d.ts +39 -0
- package/dist/backends/gui/news-timeline.d.ts.map +1 -0
- package/dist/backends/gui/news-timeline.js +45 -0
- package/dist/backends/gui/news-timeline.js.map +1 -0
- package/dist/backends/gui/order-entry.cjs +53 -0
- package/dist/backends/gui/order-entry.d.ts +21 -0
- package/dist/backends/gui/order-entry.d.ts.map +1 -0
- package/dist/backends/gui/order-entry.js +52 -0
- package/dist/backends/gui/order-entry.js.map +1 -0
- package/dist/backends/gui/orders-history.cjs +102 -0
- package/dist/backends/gui/orders-history.d.ts +24 -0
- package/dist/backends/gui/orders-history.d.ts.map +1 -0
- package/dist/backends/gui/orders-history.js +67 -0
- package/dist/backends/gui/orders-history.js.map +1 -0
- package/dist/backends/gui/pagination.cjs +51 -0
- package/dist/backends/gui/pagination.d.ts +52 -0
- package/dist/backends/gui/pagination.d.ts.map +1 -0
- package/dist/backends/gui/pagination.js +42 -0
- package/dist/backends/gui/pagination.js.map +1 -0
- package/dist/backends/gui/particles-background.cjs +135 -0
- package/dist/backends/gui/particles-background.d.ts +24 -0
- package/dist/backends/gui/particles-background.d.ts.map +1 -0
- package/dist/backends/gui/particles-background.js +133 -0
- package/dist/backends/gui/particles-background.js.map +1 -0
- package/dist/backends/gui/particles.cjs +145 -0
- package/dist/backends/gui/particles.d.ts +25 -0
- package/dist/backends/gui/particles.d.ts.map +1 -0
- package/dist/backends/gui/particles.js +143 -0
- package/dist/backends/gui/particles.js.map +1 -0
- package/dist/backends/gui/pill.cjs +82 -0
- package/dist/backends/gui/pill.d.ts +12 -0
- package/dist/backends/gui/pill.d.ts.map +1 -0
- package/dist/backends/gui/pill.js +78 -0
- package/dist/backends/gui/pill.js.map +1 -0
- package/dist/backends/gui/pin-list.cjs +82 -0
- package/dist/backends/gui/pin-list.d.ts +42 -0
- package/dist/backends/gui/pin-list.d.ts.map +1 -0
- package/dist/backends/gui/pin-list.js +80 -0
- package/dist/backends/gui/pin-list.js.map +1 -0
- package/dist/backends/gui/pixel-image.cjs +63 -0
- package/dist/backends/gui/pixel-image.d.ts +21 -0
- package/dist/backends/gui/pixel-image.d.ts.map +1 -0
- package/dist/backends/gui/pixel-image.js +61 -0
- package/dist/backends/gui/pixel-image.js.map +1 -0
- package/dist/backends/gui/positions-list.cjs +60 -0
- package/dist/backends/gui/positions-list.d.ts +14 -0
- package/dist/backends/gui/positions-list.d.ts.map +1 -0
- package/dist/backends/gui/positions-list.js +58 -0
- package/dist/backends/gui/positions-list.js.map +1 -0
- package/dist/backends/gui/qr-code.cjs +438 -0
- package/dist/backends/gui/qr-code.d.ts +42 -0
- package/dist/backends/gui/qr-code.d.ts.map +1 -0
- package/dist/backends/gui/qr-code.js +402 -0
- package/dist/backends/gui/qr-code.js.map +1 -0
- package/dist/backends/gui/relative-time.cjs +167 -0
- package/dist/backends/gui/relative-time.d.ts +10 -0
- package/dist/backends/gui/relative-time.d.ts.map +1 -0
- package/dist/backends/gui/relative-time.js +132 -0
- package/dist/backends/gui/relative-time.js.map +1 -0
- package/dist/backends/gui/safari.cjs +65 -0
- package/dist/backends/gui/safari.d.ts +23 -0
- package/dist/backends/gui/safari.d.ts.map +1 -0
- package/dist/backends/gui/safari.js +63 -0
- package/dist/backends/gui/safari.js.map +1 -0
- package/dist/backends/gui/snippet.cjs +144 -0
- package/dist/backends/gui/snippet.d.ts +38 -0
- package/dist/backends/gui/snippet.d.ts.map +1 -0
- package/dist/backends/gui/snippet.js +141 -0
- package/dist/backends/gui/snippet.js.map +1 -0
- package/dist/backends/gui/stars-scrolling-wheel.cjs +106 -0
- package/dist/backends/gui/stars-scrolling-wheel.d.ts +24 -0
- package/dist/backends/gui/stars-scrolling-wheel.d.ts.map +1 -0
- package/dist/backends/gui/stars-scrolling-wheel.js +104 -0
- package/dist/backends/gui/stars-scrolling-wheel.js.map +1 -0
- package/dist/backends/gui/status.cjs +79 -0
- package/dist/backends/gui/status.d.ts +15 -0
- package/dist/backends/gui/status.d.ts.map +1 -0
- package/dist/backends/gui/status.js +77 -0
- package/dist/backends/gui/status.js.map +1 -0
- package/dist/backends/gui/stock-market.cjs +21 -0
- package/dist/backends/gui/stock-market.d.ts +17 -0
- package/dist/backends/gui/stock-market.d.ts.map +1 -0
- package/dist/backends/gui/stock-market.js +19 -0
- package/dist/backends/gui/stock-market.js.map +1 -0
- package/dist/backends/gui/stock-screener.cjs +55 -0
- package/dist/backends/gui/stock-screener.d.ts +41 -0
- package/dist/backends/gui/stock-screener.d.ts.map +1 -0
- package/dist/backends/gui/stock-screener.js +53 -0
- package/dist/backends/gui/stock-screener.js.map +1 -0
- package/dist/backends/gui/symbol-info.cjs +46 -0
- package/dist/backends/gui/symbol-info.d.ts +36 -0
- package/dist/backends/gui/symbol-info.d.ts.map +1 -0
- package/dist/backends/gui/symbol-info.js +44 -0
- package/dist/backends/gui/symbol-info.js.map +1 -0
- package/dist/backends/gui/table.cjs +104 -0
- package/dist/backends/gui/table.d.ts +57 -0
- package/dist/backends/gui/table.d.ts.map +1 -0
- package/dist/backends/gui/table.js +95 -0
- package/dist/backends/gui/table.js.map +1 -0
- package/dist/backends/gui/tags.cjs +22 -0
- package/dist/backends/gui/tags.d.ts +22 -0
- package/dist/backends/gui/tags.d.ts.map +1 -0
- package/dist/backends/gui/tags.js +20 -0
- package/dist/backends/gui/tags.js.map +1 -0
- package/dist/backends/gui/technical-analysis.cjs +58 -0
- package/dist/backends/gui/technical-analysis.d.ts +41 -0
- package/dist/backends/gui/technical-analysis.d.ts.map +1 -0
- package/dist/backends/gui/technical-analysis.js +56 -0
- package/dist/backends/gui/technical-analysis.js.map +1 -0
- package/dist/backends/gui/terminal.cjs +266 -0
- package/dist/backends/gui/terminal.d.ts +38 -0
- package/dist/backends/gui/terminal.d.ts.map +1 -0
- package/dist/backends/gui/terminal.js +231 -0
- package/dist/backends/gui/terminal.js.map +1 -0
- package/dist/backends/gui/ticker.cjs +79 -0
- package/dist/backends/gui/ticker.d.ts +19 -0
- package/dist/backends/gui/ticker.d.ts.map +1 -0
- package/dist/backends/gui/ticker.js +44 -0
- package/dist/backends/gui/ticker.js.map +1 -0
- package/dist/backends/gui/timeline.cjs +154 -0
- package/dist/backends/gui/timeline.d.ts +42 -0
- package/dist/backends/gui/timeline.d.ts.map +1 -0
- package/dist/backends/gui/timeline.js +118 -0
- package/dist/backends/gui/timeline.js.map +1 -0
- package/dist/backends/gui/toggle.cjs +96 -0
- package/dist/backends/gui/toggle.d.ts +29 -0
- package/dist/backends/gui/toggle.d.ts.map +1 -0
- package/dist/backends/gui/toggle.js +95 -0
- package/dist/backends/gui/toggle.js.map +1 -0
- package/dist/backends/gui/video-player.cjs +383 -0
- package/dist/backends/gui/video-player.d.ts +54 -0
- package/dist/backends/gui/video-player.d.ts.map +1 -0
- package/dist/backends/gui/video-player.js +348 -0
- package/dist/backends/gui/video-player.js.map +1 -0
- package/dist/gallery.html +249 -249
- package/dist/gui-config.cjs +5 -0
- package/dist/gui-config.d.ts +18 -3
- package/dist/gui-config.d.ts.map +1 -1
- package/dist/gui-config.js +5 -0
- package/dist/gui-config.js.map +1 -1
- package/dist/index.cjs +110 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.node.cjs +110 -1
- package/dist/index.node.js +1 -1
- package/dist/styles.css +124 -124
- package/package.json +1 -1
|
@@ -1,49 +1,46 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
/**
|
|
4
|
-
* Gantt — a
|
|
5
|
-
* spanning its own start and end date.
|
|
4
|
+
* Gantt — a task list with a per-row progress track and a start/end date.
|
|
6
5
|
*
|
|
7
|
-
* One row is
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* needs no `Grid`.
|
|
6
|
+
* One row is three lines: name and percent, a filled track, then the two
|
|
7
|
+
* dates. The substrate is @hanzo/gui: `styled()` frames and theme tokens, so
|
|
8
|
+
* it renders on web, native (expo) and Tauri. An empty task list renders a
|
|
9
|
+
* placeholder rather than nothing.
|
|
12
10
|
*/
|
|
13
11
|
import { SizableText, XStack, YStack, styled } from '@hanzo/gui';
|
|
14
12
|
import { ink } from './ink.js';
|
|
15
13
|
import { slot } from './slot.js';
|
|
16
|
-
const
|
|
14
|
+
const TRACK_HEIGHT = 32;
|
|
15
|
+
const GanttFrame = styled(YStack, {
|
|
17
16
|
name: 'Gantt',
|
|
18
17
|
bg: '$background',
|
|
19
18
|
borderWidth: 1,
|
|
20
19
|
borderColor: '$borderColor',
|
|
21
20
|
rounded: '$6',
|
|
22
21
|
p: '$6',
|
|
23
|
-
gap: '$4',
|
|
24
22
|
});
|
|
25
|
-
const
|
|
23
|
+
const RowFrame = styled(YStack, { name: 'GanttRow', gap: '$2' });
|
|
24
|
+
const TrackFrame = styled(YStack, {
|
|
26
25
|
name: 'GanttTrack',
|
|
27
|
-
height:
|
|
26
|
+
height: TRACK_HEIGHT,
|
|
28
27
|
rounded: '$3',
|
|
29
28
|
bg: '$edge',
|
|
30
29
|
overflow: 'hidden',
|
|
31
30
|
});
|
|
32
|
-
const
|
|
33
|
-
name: '
|
|
31
|
+
const BarFrame = styled(YStack, {
|
|
32
|
+
name: 'GanttBar',
|
|
34
33
|
height: '100%',
|
|
35
34
|
rounded: '$3',
|
|
36
35
|
bg: '$accentBackground',
|
|
37
36
|
});
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
return (_jsx(Frame, { ...slot('gantt'), ...props, children: tasks.length === 0 ? (_jsx(XStack, { ...slot('gantt-empty'), items: "center", justify: "center", p: "$8", children: ink('No tasks available. Add tasks to display Gantt chart.', SizableText, {
|
|
37
|
+
export function Gantt({ tasks = [], ...props }) {
|
|
38
|
+
return (_jsx(GanttFrame, { ...slot('gantt'), ...props, children: tasks.length === 0 ? (_jsx(XStack, { ...slot('gantt-empty'), items: "center", justify: "center", p: "$8", children: ink('No tasks available. Add tasks to display Gantt chart.', SizableText, {
|
|
41
39
|
size: '$2',
|
|
42
40
|
color: '$quiet',
|
|
43
|
-
}) })) : (tasks.map((task) => {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
41
|
+
}) })) : (_jsx(YStack, { gap: "$4", children: tasks.map((task) => {
|
|
42
|
+
const progress = Math.min(100, Math.max(0, task.progress ?? 0));
|
|
43
|
+
return (_jsxs(RowFrame, { ...slot('gantt-task'), "data-progress": progress, children: [_jsxs(XStack, { justify: "space-between", items: "center", children: [ink(task.name, SizableText, { size: '$3', fontWeight: '600' }), ink(`${progress}%`, SizableText, { size: '$3', color: '$quiet' })] }), _jsx(TrackFrame, { ...slot('gantt-track'), children: _jsx(BarFrame, { ...slot('gantt-bar'), width: `${progress}%` }) }), _jsxs(XStack, { justify: "space-between", children: [ink(task.start.toLocaleDateString(), SizableText, { size: '$1', color: '$quiet' }), ink(task.end.toLocaleDateString(), SizableText, { size: '$1', color: '$quiet' })] })] }, task.id));
|
|
44
|
+
}) })) }));
|
|
47
45
|
}
|
|
48
|
-
export { Gantt };
|
|
49
46
|
//# sourceMappingURL=gantt.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gantt.js","sourceRoot":"","sources":["../../../src/backends/gui/gantt.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ
|
|
1
|
+
{"version":3,"file":"gantt.js","sourceRoot":"","sources":["../../../src/backends/gui/gantt.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ;;;;;;;GAOG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAChE,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAC3B,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAE7B,MAAM,YAAY,GAAG,EAAE,CAAA;AAWvB,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE;IAChC,IAAI,EAAE,OAAO;IACb,EAAE,EAA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AC,EAAE,IAAI,CAAC,QAAQ,IAAI,CAAC,CAAC,CAAC,CAAA;gBAC/D,OAAO,CACL,MAAC,QAAQ,OAAmB,IAAI,CAAC,YAAY,CAAC,mBAAiB,QAAQ,aACrE,MAAC,MAAM,IAAC,OAAO,EAAC,eAAe,EAAC,KAAK,EAAC,QAAQ,aAC3C,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,WAAW,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,EAC9D,GAAG,CAAC,GAAG,QAAQ,GAAG,EAAE,WAAW,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,IAC3D,EACT,KAAC,UAAU,OAAK,IAAI,CAAC,aAAa,CAAC,YACjC,KAAC,QAAQ,OAAK,IAAI,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,GAAG,QAAQ,GAAG,GAAI,GAC/C,EACb,MAAC,MAAM,IAAC,OAAO,EAAC,eAAe,aAC5B,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,kBAAkB,EAAE,EAAE,WAAW,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,EAClF,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,kBAAkB,EAAE,EAAE,WAAW,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,IAC1E,KAXI,IAAI,CAAC,EAAE,CAYX,CACZ,CAAA;YACH,CAAC,CAAC,GACK,CACV,GACU,CACd,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
'use client';"use strict";
|
|
2
|
+
'use client';
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.GlimpseDescription = exports.GlimpseTitle = exports.GlimpseImage = exports.GlimpseContent = exports.GlimpseTrigger = void 0;
|
|
5
|
+
exports.Glimpse = Glimpse;
|
|
6
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
+
/**
|
|
8
|
+
* Glimpse — a link preview: rest a pointer on a trigger and see the page it
|
|
9
|
+
* points to, image and title and description, before following it.
|
|
10
|
+
*
|
|
11
|
+
* Built the way `hover-card.tsx` is: a `Popover` in hover mode. `hoverable`
|
|
12
|
+
* puts floating-ui's `useHover` + `safePolygon` on the popper so the cursor can
|
|
13
|
+
* cross the gap into the panel without it closing, `useFocus` opens it from the
|
|
14
|
+
* keyboard, and `place()` rejoins the `side`/`align`/`sideOffset` API a call
|
|
15
|
+
* site is written against onto the one `placement`/`offset` the popper root
|
|
16
|
+
* owns (shared with `popover.tsx` and `hover-card.tsx` rather than spelled
|
|
17
|
+
* again here). Press is not a trigger — the trigger is usually a link whose
|
|
18
|
+
* click must navigate.
|
|
19
|
+
*
|
|
20
|
+
* Content is composed directly on `GuiPopover.Content` rather than by wrapping
|
|
21
|
+
* `HoverCard`, because a link preview's layout is not uniform padding: the
|
|
22
|
+
* image bleeds to the panel's rounded edges and only the text sits in a
|
|
23
|
+
* margin, which `HoverCardContent`'s single `p` cannot express. Content itself
|
|
24
|
+
* carries no padding — `GlimpseImage` fills it edge to edge, `GlimpseTitle` and
|
|
25
|
+
* `GlimpseDescription` carry their own.
|
|
26
|
+
*
|
|
27
|
+
* `GlimpseImage` owns one bit of state Radix's original left to `next/image`:
|
|
28
|
+
* a broken `src` swaps the frame for an `ImageOff` glyph rather than the
|
|
29
|
+
* browser's own broken-image icon.
|
|
30
|
+
*/
|
|
31
|
+
const gui_1 = require("@hanzo/gui");
|
|
32
|
+
const lucide_icons_2_1 = require("@hanzogui/lucide-icons-2");
|
|
33
|
+
const react_1 = require("react");
|
|
34
|
+
const aspect_ratio_1 = require("./aspect-ratio.cjs");
|
|
35
|
+
const ink_1 = require("./ink.cjs");
|
|
36
|
+
const place_1 = require("./place.cjs");
|
|
37
|
+
const slot_1 = require("./slot.cjs");
|
|
38
|
+
const portal_theme_1 = require("../../product/menu/portal-theme.cjs");
|
|
39
|
+
/** Radix's hover card defaults, kept so a migrated call site behaves identically. */
|
|
40
|
+
const OPEN_DELAY = 700;
|
|
41
|
+
const CLOSE_DELAY = 300;
|
|
42
|
+
const DEFAULT_OFFSET = 4;
|
|
43
|
+
/** Radix/shadcn ship `w-80`. */
|
|
44
|
+
const WIDTH = 320;
|
|
45
|
+
const DEFAULT_RATIO = 16 / 9;
|
|
46
|
+
/** Root-owned floating geometry. Content publishes into it; see `place.ts`. */
|
|
47
|
+
const FloatContext = /* @__PURE__ */ (0, react_1.createContext)(null);
|
|
48
|
+
function Glimpse({ openDelay = OPEN_DELAY, closeDelay = CLOSE_DELAY, ...props }) {
|
|
49
|
+
const [float, setFloat] = (0, react_1.useState)({
|
|
50
|
+
placement: 'bottom',
|
|
51
|
+
offset: DEFAULT_OFFSET,
|
|
52
|
+
});
|
|
53
|
+
// Identity-stable: an unchanged publish returns the same object, so Content's
|
|
54
|
+
// effect cannot drive a render loop.
|
|
55
|
+
const publish = (0, react_1.useCallback)((placement, offset) => setFloat((f) => (f.placement === placement && f.offset === offset ? f : { placement, offset })), []);
|
|
56
|
+
return ((0, jsx_runtime_1.jsx)(FloatContext.Provider, { value: publish, children: (0, jsx_runtime_1.jsx)(gui_1.Popover, { hoverable: { delay: { open: openDelay, close: closeDelay } }, placement: float.placement, offset: float.offset, ...props }) }));
|
|
57
|
+
}
|
|
58
|
+
const GlimpseTrigger = (props) => ((0, jsx_runtime_1.jsx)(gui_1.Popover.Trigger, { ...(0, slot_1.slot)('glimpse-trigger'), disablePressTrigger: true, ...props }));
|
|
59
|
+
exports.GlimpseTrigger = GlimpseTrigger;
|
|
60
|
+
const GlimpseContent = ({ side = 'bottom', align = 'center', sideOffset = DEFAULT_OFFSET, children, ...props }) => {
|
|
61
|
+
const themeName = (0, portal_theme_1.useThemeName)();
|
|
62
|
+
const publish = (0, react_1.useContext)(FloatContext);
|
|
63
|
+
(0, react_1.useEffect)(() => publish?.((0, place_1.place)(side, align), sideOffset), [publish, side, align, sideOffset]);
|
|
64
|
+
return ((0, jsx_runtime_1.jsx)(portal_theme_1.PortalTheme, { name: themeName, children: (0, jsx_runtime_1.jsx)(gui_1.Popover.Content, { ...(0, slot_1.slot)('glimpse-content'), bg: "$panel", borderWidth: 1, borderColor: "$borderColor", rounded: "$4", overflow: "hidden", width: WIDTH, ...props, children: (0, ink_1.ink)(children, undefined, { size: '$2' }) }) }));
|
|
65
|
+
};
|
|
66
|
+
exports.GlimpseContent = GlimpseContent;
|
|
67
|
+
/**
|
|
68
|
+
* The preview thumbnail. Fills its frame edge to edge — `GlimpseContent` gives
|
|
69
|
+
* it no margin to bleed out of, unlike Radix/shadcn's negative-margin trick.
|
|
70
|
+
* A `src` that fails to load swaps the frame for an `ImageOff` glyph rather
|
|
71
|
+
* than the browser's own broken-image icon.
|
|
72
|
+
*/
|
|
73
|
+
const GlimpseImage = ({ ratio = DEFAULT_RATIO, onError, ...props }) => {
|
|
74
|
+
const [failed, setFailed] = (0, react_1.useState)(false);
|
|
75
|
+
return ((0, jsx_runtime_1.jsx)(aspect_ratio_1.AspectRatio, { ratio: ratio, bg: "$edge", ...(0, slot_1.slot)('glimpse-image'), children: failed ? ((0, jsx_runtime_1.jsx)(gui_1.YStack, { width: "100%", height: "100%", items: "center", justify: "center", children: (0, jsx_runtime_1.jsx)(lucide_icons_2_1.ImageOff, { size: 20, color: "$quiet" }) })) : ((0, jsx_runtime_1.jsx)(gui_1.Image, { width: "100%", height: "100%", objectFit: "cover", onError: (event) => {
|
|
76
|
+
setFailed(true);
|
|
77
|
+
// gui's Image intersects RN's and web's onError, two incompatible
|
|
78
|
+
// event types; this branch is always the web one, forwarding it
|
|
79
|
+
// through the union-typed prop is what the cast is for.
|
|
80
|
+
// @ts-expect-error see above
|
|
81
|
+
onError?.(event);
|
|
82
|
+
}, ...props })) }));
|
|
83
|
+
};
|
|
84
|
+
exports.GlimpseImage = GlimpseImage;
|
|
85
|
+
const GlimpseTitle = ({ children, ...props }) => ((0, jsx_runtime_1.jsx)(gui_1.SizableText, { ...(0, slot_1.slot)('glimpse-title'), size: "$3", fontWeight: "600", px: "$3", pt: "$3", numberOfLines: 1, ...props, children: children }));
|
|
86
|
+
exports.GlimpseTitle = GlimpseTitle;
|
|
87
|
+
const GlimpseDescription = ({ children, ...props }) => ((0, jsx_runtime_1.jsx)(gui_1.SizableText, { ...(0, slot_1.slot)('glimpse-description'), size: "$2", color: "$quiet", px: "$3", pb: "$3", numberOfLines: 2, ...props, children: children }));
|
|
88
|
+
exports.GlimpseDescription = GlimpseDescription;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Glimpse — a link preview: rest a pointer on a trigger and see the page it
|
|
3
|
+
* points to, image and title and description, before following it.
|
|
4
|
+
*
|
|
5
|
+
* Built the way `hover-card.tsx` is: a `Popover` in hover mode. `hoverable`
|
|
6
|
+
* puts floating-ui's `useHover` + `safePolygon` on the popper so the cursor can
|
|
7
|
+
* cross the gap into the panel without it closing, `useFocus` opens it from the
|
|
8
|
+
* keyboard, and `place()` rejoins the `side`/`align`/`sideOffset` API a call
|
|
9
|
+
* site is written against onto the one `placement`/`offset` the popper root
|
|
10
|
+
* owns (shared with `popover.tsx` and `hover-card.tsx` rather than spelled
|
|
11
|
+
* again here). Press is not a trigger — the trigger is usually a link whose
|
|
12
|
+
* click must navigate.
|
|
13
|
+
*
|
|
14
|
+
* Content is composed directly on `GuiPopover.Content` rather than by wrapping
|
|
15
|
+
* `HoverCard`, because a link preview's layout is not uniform padding: the
|
|
16
|
+
* image bleeds to the panel's rounded edges and only the text sits in a
|
|
17
|
+
* margin, which `HoverCardContent`'s single `p` cannot express. Content itself
|
|
18
|
+
* carries no padding — `GlimpseImage` fills it edge to edge, `GlimpseTitle` and
|
|
19
|
+
* `GlimpseDescription` carry their own.
|
|
20
|
+
*
|
|
21
|
+
* `GlimpseImage` owns one bit of state Radix's original left to `next/image`:
|
|
22
|
+
* a broken `src` swaps the frame for an `ImageOff` glyph rather than the
|
|
23
|
+
* browser's own broken-image icon.
|
|
24
|
+
*/
|
|
25
|
+
import { Popover as GuiPopover, SizableText, type ImageProps } from '@hanzo/gui';
|
|
26
|
+
import { type ComponentProps } from 'react';
|
|
27
|
+
import { type Align, type Side } from './place.js';
|
|
28
|
+
export type GlimpseProps = Omit<ComponentProps<typeof GuiPopover>, 'hoverable' | 'placement' | 'offset'> & {
|
|
29
|
+
openDelay?: number;
|
|
30
|
+
closeDelay?: number;
|
|
31
|
+
};
|
|
32
|
+
declare function Glimpse({ openDelay, closeDelay, ...props }: GlimpseProps): import("react").JSX.Element;
|
|
33
|
+
export type GlimpseTriggerProps = ComponentProps<typeof GuiPopover.Trigger>;
|
|
34
|
+
declare const GlimpseTrigger: (props: GlimpseTriggerProps) => import("react").JSX.Element;
|
|
35
|
+
export type GlimpseContentProps = ComponentProps<typeof GuiPopover.Content> & {
|
|
36
|
+
side?: Side;
|
|
37
|
+
align?: Align;
|
|
38
|
+
sideOffset?: number;
|
|
39
|
+
};
|
|
40
|
+
declare const GlimpseContent: ({ side, align, sideOffset, children, ...props }: GlimpseContentProps) => import("react").JSX.Element;
|
|
41
|
+
export type GlimpseImageProps = Omit<ImageProps, 'width' | 'height'> & {
|
|
42
|
+
/** Width divided by height of the preview frame. 16:9 by default. */
|
|
43
|
+
ratio?: number;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* The preview thumbnail. Fills its frame edge to edge — `GlimpseContent` gives
|
|
47
|
+
* it no margin to bleed out of, unlike Radix/shadcn's negative-margin trick.
|
|
48
|
+
* A `src` that fails to load swaps the frame for an `ImageOff` glyph rather
|
|
49
|
+
* than the browser's own broken-image icon.
|
|
50
|
+
*/
|
|
51
|
+
declare const GlimpseImage: ({ ratio, onError, ...props }: GlimpseImageProps) => import("react").JSX.Element;
|
|
52
|
+
export type GlimpseTitleProps = ComponentProps<typeof SizableText>;
|
|
53
|
+
declare const GlimpseTitle: ({ children, ...props }: GlimpseTitleProps) => import("react").JSX.Element;
|
|
54
|
+
export type GlimpseDescriptionProps = ComponentProps<typeof SizableText>;
|
|
55
|
+
declare const GlimpseDescription: ({ children, ...props }: GlimpseDescriptionProps) => import("react").JSX.Element;
|
|
56
|
+
export { Glimpse, GlimpseTrigger, GlimpseContent, GlimpseImage, GlimpseTitle, GlimpseDescription };
|
|
57
|
+
//# sourceMappingURL=glimpse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"glimpse.d.ts","sourceRoot":"","sources":["../../../src/backends/gui/glimpse.tsx"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,EAAS,OAAO,IAAI,UAAU,EAAE,WAAW,EAAU,KAAK,UAAU,EAAE,MAAM,YAAY,CAAA;AAE/F,OAAO,EAML,KAAK,cAAc,EACpB,MAAM,OAAO,CAAA;AAId,OAAO,EAAS,KAAK,KAAK,EAAE,KAAK,IAAI,EAAE,MAAM,SAAS,CAAA;AAmBtD,MAAM,MAAM,YAAY,GAAG,IAAI,CAC7B,cAAc,CAAC,OAAO,UAAU,CAAC,EACjC,WAAW,GAAG,WAAW,GAAG,QAAQ,CACrC,GAAG;IACF,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB,CAAA;AAED,iBAAS,OAAO,CAAC,EAAE,SAAsB,EAAE,UAAwB,EAAE,GAAG,KAAK,EAAE,EAAE,YAAY,+BAsB5F;AAED,MAAM,MAAM,mBAAmB,GAAG,cAAc,CAAC,OAAO,UAAU,CAAC,OAAO,CAAC,CAAA;AAE3E,QAAA,MAAM,cAAc,UAAW,mBAAmB,gCAEjD,CAAA;AAED,MAAM,MAAM,mBAAmB,GAAG,cAAc,CAAC,OAAO,UAAU,CAAC,OAAO,CAAC,GAAG;IAC5E,IAAI,CAAC,EAAE,IAAI,CAAA;IACX,KAAK,CAAC,EAAE,KAAK,CAAA;IACb,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB,CAAA;AAED,QAAA,MAAM,cAAc,oDAMjB,mBAAmB,gCAuBrB,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,UAAU,EAAE,OAAO,GAAG,QAAQ,CAAC,GAAG;IACrE,qEAAqE;IACrE,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAED;;;;;GAKG;AACH,QAAA,MAAM,YAAY,iCAAkD,iBAAiB,gCA0BpF,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG,cAAc,CAAC,OAAO,WAAW,CAAC,CAAA;AAElE,QAAA,MAAM,YAAY,2BAA4B,iBAAiB,gCAY9D,CAAA;AAED,MAAM,MAAM,uBAAuB,GAAG,cAAc,CAAC,OAAO,WAAW,CAAC,CAAA;AAExE,QAAA,MAAM,kBAAkB,2BAA4B,uBAAuB,gCAY1E,CAAA;AAED,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,YAAY,EAAE,YAAY,EAAE,kBAAkB,EAAE,CAAA"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
/**
|
|
4
|
+
* Glimpse — a link preview: rest a pointer on a trigger and see the page it
|
|
5
|
+
* points to, image and title and description, before following it.
|
|
6
|
+
*
|
|
7
|
+
* Built the way `hover-card.tsx` is: a `Popover` in hover mode. `hoverable`
|
|
8
|
+
* puts floating-ui's `useHover` + `safePolygon` on the popper so the cursor can
|
|
9
|
+
* cross the gap into the panel without it closing, `useFocus` opens it from the
|
|
10
|
+
* keyboard, and `place()` rejoins the `side`/`align`/`sideOffset` API a call
|
|
11
|
+
* site is written against onto the one `placement`/`offset` the popper root
|
|
12
|
+
* owns (shared with `popover.tsx` and `hover-card.tsx` rather than spelled
|
|
13
|
+
* again here). Press is not a trigger — the trigger is usually a link whose
|
|
14
|
+
* click must navigate.
|
|
15
|
+
*
|
|
16
|
+
* Content is composed directly on `GuiPopover.Content` rather than by wrapping
|
|
17
|
+
* `HoverCard`, because a link preview's layout is not uniform padding: the
|
|
18
|
+
* image bleeds to the panel's rounded edges and only the text sits in a
|
|
19
|
+
* margin, which `HoverCardContent`'s single `p` cannot express. Content itself
|
|
20
|
+
* carries no padding — `GlimpseImage` fills it edge to edge, `GlimpseTitle` and
|
|
21
|
+
* `GlimpseDescription` carry their own.
|
|
22
|
+
*
|
|
23
|
+
* `GlimpseImage` owns one bit of state Radix's original left to `next/image`:
|
|
24
|
+
* a broken `src` swaps the frame for an `ImageOff` glyph rather than the
|
|
25
|
+
* browser's own broken-image icon.
|
|
26
|
+
*/
|
|
27
|
+
import { Image, Popover as GuiPopover, SizableText, YStack } from '@hanzo/gui';
|
|
28
|
+
import { ImageOff } from '@hanzogui/lucide-icons-2';
|
|
29
|
+
import { createContext, useCallback, useContext, useEffect, useState, } from 'react';
|
|
30
|
+
import { AspectRatio } from './aspect-ratio.js';
|
|
31
|
+
import { ink } from './ink.js';
|
|
32
|
+
import { place } from './place.js';
|
|
33
|
+
import { slot } from './slot.js';
|
|
34
|
+
import { PortalTheme, useThemeName } from '../../product/menu/portal-theme.js';
|
|
35
|
+
/** Radix's hover card defaults, kept so a migrated call site behaves identically. */
|
|
36
|
+
const OPEN_DELAY = 700;
|
|
37
|
+
const CLOSE_DELAY = 300;
|
|
38
|
+
const DEFAULT_OFFSET = 4;
|
|
39
|
+
/** Radix/shadcn ship `w-80`. */
|
|
40
|
+
const WIDTH = 320;
|
|
41
|
+
const DEFAULT_RATIO = 16 / 9;
|
|
42
|
+
/** Root-owned floating geometry. Content publishes into it; see `place.ts`. */
|
|
43
|
+
const FloatContext = /* @__PURE__ */ createContext(null);
|
|
44
|
+
function Glimpse({ openDelay = OPEN_DELAY, closeDelay = CLOSE_DELAY, ...props }) {
|
|
45
|
+
const [float, setFloat] = useState({
|
|
46
|
+
placement: 'bottom',
|
|
47
|
+
offset: DEFAULT_OFFSET,
|
|
48
|
+
});
|
|
49
|
+
// Identity-stable: an unchanged publish returns the same object, so Content's
|
|
50
|
+
// effect cannot drive a render loop.
|
|
51
|
+
const publish = useCallback((placement, offset) => setFloat((f) => (f.placement === placement && f.offset === offset ? f : { placement, offset })), []);
|
|
52
|
+
return (_jsx(FloatContext.Provider, { value: publish, children: _jsx(GuiPopover, { hoverable: { delay: { open: openDelay, close: closeDelay } }, placement: float.placement, offset: float.offset, ...props }) }));
|
|
53
|
+
}
|
|
54
|
+
const GlimpseTrigger = (props) => (_jsx(GuiPopover.Trigger, { ...slot('glimpse-trigger'), disablePressTrigger: true, ...props }));
|
|
55
|
+
const GlimpseContent = ({ side = 'bottom', align = 'center', sideOffset = DEFAULT_OFFSET, children, ...props }) => {
|
|
56
|
+
const themeName = useThemeName();
|
|
57
|
+
const publish = useContext(FloatContext);
|
|
58
|
+
useEffect(() => publish?.(place(side, align), sideOffset), [publish, side, align, sideOffset]);
|
|
59
|
+
return (_jsx(PortalTheme, { name: themeName, children: _jsx(GuiPopover.Content, { ...slot('glimpse-content'), bg: "$panel", borderWidth: 1, borderColor: "$borderColor", rounded: "$4", overflow: "hidden", width: WIDTH, ...props, children: ink(children, undefined, { size: '$2' }) }) }));
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* The preview thumbnail. Fills its frame edge to edge — `GlimpseContent` gives
|
|
63
|
+
* it no margin to bleed out of, unlike Radix/shadcn's negative-margin trick.
|
|
64
|
+
* A `src` that fails to load swaps the frame for an `ImageOff` glyph rather
|
|
65
|
+
* than the browser's own broken-image icon.
|
|
66
|
+
*/
|
|
67
|
+
const GlimpseImage = ({ ratio = DEFAULT_RATIO, onError, ...props }) => {
|
|
68
|
+
const [failed, setFailed] = useState(false);
|
|
69
|
+
return (_jsx(AspectRatio, { ratio: ratio, bg: "$edge", ...slot('glimpse-image'), children: failed ? (_jsx(YStack, { width: "100%", height: "100%", items: "center", justify: "center", children: _jsx(ImageOff, { size: 20, color: "$quiet" }) })) : (_jsx(Image, { width: "100%", height: "100%", objectFit: "cover", onError: (event) => {
|
|
70
|
+
setFailed(true);
|
|
71
|
+
// gui's Image intersects RN's and web's onError, two incompatible
|
|
72
|
+
// event types; this branch is always the web one, forwarding it
|
|
73
|
+
// through the union-typed prop is what the cast is for.
|
|
74
|
+
// @ts-expect-error see above
|
|
75
|
+
onError?.(event);
|
|
76
|
+
}, ...props })) }));
|
|
77
|
+
};
|
|
78
|
+
const GlimpseTitle = ({ children, ...props }) => (_jsx(SizableText, { ...slot('glimpse-title'), size: "$3", fontWeight: "600", px: "$3", pt: "$3", numberOfLines: 1, ...props, children: children }));
|
|
79
|
+
const GlimpseDescription = ({ children, ...props }) => (_jsx(SizableText, { ...slot('glimpse-description'), size: "$2", color: "$quiet", px: "$3", pb: "$3", numberOfLines: 2, ...props, children: children }));
|
|
80
|
+
export { Glimpse, GlimpseTrigger, GlimpseContent, GlimpseImage, GlimpseTitle, GlimpseDescription };
|
|
81
|
+
//# sourceMappingURL=glimpse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"glimpse.js","sourceRoot":"","sources":["../../../src/backends/gui/glimpse.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,EAAE,KAAK,EAAE,OAAO,IAAI,UAAU,EAAE,WAAW,EAAE,MAAM,EAAmB,MAAM,YAAY,CAAA;AAC/F,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAA;AACnD,OAAO,EACL,aAAa,EACb,WAAW,EACX,UAAU,EACV,SAAS,EACT,QAAQ,GAET,MAAM,OAAO,CAAA;AAEd,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAC3B,OAAO,EAAE,KAAK,EAAyB,MAAM,SAAS,CAAA;AACtD,OAAO,EAAE,IAAI,EAAE,MAAM,QAA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AAA;AAED,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,YAAY,EAAE,YAAY,EAAE,kBAAkB,EAAE,CAAA"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
'use client';"use strict";
|
|
2
|
+
'use client';
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
36
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
exports.GridPatternPresets = exports.GridPattern = void 0;
|
|
38
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
39
|
+
/**
|
|
40
|
+
* GridPattern — a decorative, tiled SVG background: dots, lines, crosses,
|
|
41
|
+
* plus-marks or squares repeated across the whole of its parent.
|
|
42
|
+
*
|
|
43
|
+
* It is purely visual, so it draws with a plain <svg>, the same choice
|
|
44
|
+
* `AnimatedBeam` makes — gui has no vector primitive of its own. One `<pattern>`
|
|
45
|
+
* tile carries the chosen mark and is stamped across a full-size `<rect>`; an
|
|
46
|
+
* optional mask (a linear or radial gradient of white-to-transparent) fades the
|
|
47
|
+
* tile at its edges, its center, or radially outward, and an optional second
|
|
48
|
+
* `<rect>` paints a linear-gradient tint over the top. Motion is one CSS
|
|
49
|
+
* animation, hoisted once as a `<style>` sibling the way the beam's keyframe
|
|
50
|
+
* is: the keyframe itself only ever slides by the two custom properties
|
|
51
|
+
* `--grid-pattern-x`/`-y`, so any number of instances at any gap share it.
|
|
52
|
+
*/
|
|
53
|
+
const React = __importStar(require("react"));
|
|
54
|
+
const gui_1 = require("@hanzo/gui");
|
|
55
|
+
const slot_1 = require("./slot.cjs");
|
|
56
|
+
const KEYFRAMES = `
|
|
57
|
+
@keyframes grid-pattern-move { from { transform: translate(0, 0) } to { transform: translate(var(--grid-pattern-x, 0px), var(--grid-pattern-y, 0px)) } }
|
|
58
|
+
@media (prefers-reduced-motion: reduce) { [data-slot="grid-pattern"] { animation: none !important } }
|
|
59
|
+
`;
|
|
60
|
+
const mark = (variant, size, step, color, opacity, strokeWidth) => {
|
|
61
|
+
switch (variant) {
|
|
62
|
+
case 'dots':
|
|
63
|
+
return (0, jsx_runtime_1.jsx)("circle", { cx: size.width / 2, cy: size.height / 2, r: size.width / 2, fill: color, opacity: opacity });
|
|
64
|
+
case 'lines':
|
|
65
|
+
// Spans the full tile (gap), not the mark size, so adjoining tiles meet into one continuous grid line.
|
|
66
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("line", { x1: 0, y1: 0, x2: 0, y2: step.y, stroke: color, strokeWidth: strokeWidth, opacity: opacity }), (0, jsx_runtime_1.jsx)("line", { x1: 0, y1: 0, x2: step.x, y2: 0, stroke: color, strokeWidth: strokeWidth, opacity: opacity })] }));
|
|
67
|
+
case 'crosses':
|
|
68
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("line", { x1: size.width / 2, y1: 0, x2: size.width / 2, y2: size.height, stroke: color, strokeWidth: strokeWidth, opacity: opacity }), (0, jsx_runtime_1.jsx)("line", { x1: 0, y1: size.height / 2, x2: size.width, y2: size.height / 2, stroke: color, strokeWidth: strokeWidth, opacity: opacity })] }));
|
|
69
|
+
case 'plus':
|
|
70
|
+
return ((0, jsx_runtime_1.jsx)("path", { d: `M ${size.width / 2} 0 L ${size.width / 2} ${size.height} M 0 ${size.height / 2} L ${size.width} ${size.height / 2}`, stroke: color, strokeWidth: strokeWidth, opacity: opacity, fill: "none", strokeLinecap: "round" }));
|
|
71
|
+
case 'squares':
|
|
72
|
+
return (0, jsx_runtime_1.jsx)("rect", { width: size.width, height: size.height, fill: "none", stroke: color, strokeWidth: strokeWidth, opacity: opacity });
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
const fadeStops = (fade) => {
|
|
76
|
+
if (fade === 'center')
|
|
77
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("stop", { offset: "0%", stopColor: "white", stopOpacity: 1 }), (0, jsx_runtime_1.jsx)("stop", { offset: "70%", stopColor: "white", stopOpacity: 1 }), (0, jsx_runtime_1.jsx)("stop", { offset: "100%", stopColor: "white", stopOpacity: 0 })] }));
|
|
78
|
+
if (fade === 'radial')
|
|
79
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("stop", { offset: "0%", stopColor: "white", stopOpacity: 0 }), (0, jsx_runtime_1.jsx)("stop", { offset: "30%", stopColor: "white", stopOpacity: 1 }), (0, jsx_runtime_1.jsx)("stop", { offset: "100%", stopColor: "white", stopOpacity: 1 })] }));
|
|
80
|
+
// 'edges' and `true` share the same edge-to-edge fade.
|
|
81
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("stop", { offset: "0%", stopColor: "white", stopOpacity: 0 }), (0, jsx_runtime_1.jsx)("stop", { offset: "10%", stopColor: "white", stopOpacity: 1 }), (0, jsx_runtime_1.jsx)("stop", { offset: "90%", stopColor: "white", stopOpacity: 1 }), (0, jsx_runtime_1.jsx)("stop", { offset: "100%", stopColor: "white", stopOpacity: 0 })] }));
|
|
82
|
+
};
|
|
83
|
+
exports.GridPattern = React.forwardRef(({ variant = 'dots', size = 4, gap = 20, color = 'currentColor', opacity = 0.4, strokeWidth = 1, fade = false, gradient, animation, offset, maxArea, style, ...props }, ref) => {
|
|
84
|
+
const patternId = React.useId();
|
|
85
|
+
const maskId = React.useId();
|
|
86
|
+
const gradientId = React.useId();
|
|
87
|
+
const tile = typeof size === 'number' ? { width: size, height: size } : { width: size.width ?? 4, height: size.height ?? 4 };
|
|
88
|
+
const step = typeof gap === 'number' ? { x: gap, y: gap } : { x: gap.x ?? 20, y: gap.y ?? 20 };
|
|
89
|
+
const shift = { x: offset?.x ?? 0, y: offset?.y ?? 0 };
|
|
90
|
+
const animationStyle = animation
|
|
91
|
+
? {
|
|
92
|
+
animationName: 'grid-pattern-move',
|
|
93
|
+
animationDuration: `${animation.duration ?? 10}s`,
|
|
94
|
+
animationTimingFunction: animation.timing ?? 'linear',
|
|
95
|
+
animationDirection: animation.direction ?? 'normal',
|
|
96
|
+
animationIterationCount: 'infinite',
|
|
97
|
+
'--grid-pattern-x': `${step.x}px`,
|
|
98
|
+
'--grid-pattern-y': `${step.y}px`,
|
|
99
|
+
}
|
|
100
|
+
: {};
|
|
101
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("style", { href: "grid-pattern", precedence: "default", children: KEYFRAMES }), (0, jsx_runtime_1.jsx)(gui_1.YStack, { ref: ref, ...(0, slot_1.slot)('grid-pattern'), position: "absolute", inset: 0, overflow: "hidden", pointerEvents: "none", style: { ...animationStyle, ...style }, ...props, children: (0, jsx_runtime_1.jsxs)("svg", { ...(0, slot_1.slot)('grid-pattern-svg'), style: {
|
|
102
|
+
position: 'absolute',
|
|
103
|
+
width: '100%',
|
|
104
|
+
height: '100%',
|
|
105
|
+
transform: `translate(${shift.x}px, ${shift.y}px)`,
|
|
106
|
+
}, children: [(0, jsx_runtime_1.jsxs)("defs", { children: [(0, jsx_runtime_1.jsx)("pattern", { id: patternId, x: 0, y: 0, width: step.x, height: step.y, patternUnits: "userSpaceOnUse", children: mark(variant, tile, step, color, opacity, strokeWidth) }), fade && (fade === 'center' || fade === 'radial' ? ((0, jsx_runtime_1.jsx)("radialGradient", { id: maskId, children: fadeStops(fade) })) : ((0, jsx_runtime_1.jsx)("linearGradient", { id: maskId, children: fadeStops(fade) }))), gradient && ((0, jsx_runtime_1.jsxs)("linearGradient", { id: gradientId, x1: "0%", y1: "0%", x2: "100%", y2: "100%", children: [(0, jsx_runtime_1.jsx)("stop", { offset: "0%", stopColor: gradient.from ?? 'transparent' }), gradient.via && (0, jsx_runtime_1.jsx)("stop", { offset: "50%", stopColor: gradient.via }), (0, jsx_runtime_1.jsx)("stop", { offset: "100%", stopColor: gradient.to ?? 'transparent' })] }))] }), (0, jsx_runtime_1.jsx)("rect", { ...(0, slot_1.slot)('grid-pattern-tiles'), width: maxArea?.width ?? '100%', height: maxArea?.height ?? '100%', fill: `url(#${patternId})`, mask: fade ? `url(#${maskId})` : undefined }), gradient && ((0, jsx_runtime_1.jsx)("rect", { ...(0, slot_1.slot)('grid-pattern-tint'), width: maxArea?.width ?? '100%', height: maxArea?.height ?? '100%', fill: `url(#${gradientId})`, opacity: gradient.opacity ?? 0.5 }))] }) })] }));
|
|
107
|
+
});
|
|
108
|
+
exports.GridPattern.displayName = 'GridPattern';
|
|
109
|
+
/** Named, ready-to-spread configurations for the common backgrounds. */
|
|
110
|
+
exports.GridPatternPresets = {
|
|
111
|
+
dotMatrix: { variant: 'dots', size: 3, gap: 30, opacity: 0.3 },
|
|
112
|
+
fineDots: { variant: 'dots', size: 1, gap: 10, opacity: 0.4 },
|
|
113
|
+
gridLines: { variant: 'lines', gap: 40, strokeWidth: 1, opacity: 0.2 },
|
|
114
|
+
crosshatch: { variant: 'crosses', size: 10, gap: 20, strokeWidth: 1, opacity: 0.3 },
|
|
115
|
+
blueprint: { variant: 'lines', gap: 20, strokeWidth: 0.5, color: '#3b82f6', opacity: 0.3 },
|
|
116
|
+
graph: { variant: 'lines', gap: { x: 50, y: 50 }, strokeWidth: 1, opacity: 0.15, fade: 'edges' },
|
|
117
|
+
isometric: { variant: 'lines', gap: { x: 30, y: 17.32 }, strokeWidth: 0.5, opacity: 0.2 },
|
|
118
|
+
hexagon: { variant: 'dots', size: 2, gap: { x: 30, y: 26 }, opacity: 0.3 },
|
|
119
|
+
};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GridPattern — a decorative, tiled SVG background: dots, lines, crosses,
|
|
3
|
+
* plus-marks or squares repeated across the whole of its parent.
|
|
4
|
+
*
|
|
5
|
+
* It is purely visual, so it draws with a plain <svg>, the same choice
|
|
6
|
+
* `AnimatedBeam` makes — gui has no vector primitive of its own. One `<pattern>`
|
|
7
|
+
* tile carries the chosen mark and is stamped across a full-size `<rect>`; an
|
|
8
|
+
* optional mask (a linear or radial gradient of white-to-transparent) fades the
|
|
9
|
+
* tile at its edges, its center, or radially outward, and an optional second
|
|
10
|
+
* `<rect>` paints a linear-gradient tint over the top. Motion is one CSS
|
|
11
|
+
* animation, hoisted once as a `<style>` sibling the way the beam's keyframe
|
|
12
|
+
* is: the keyframe itself only ever slides by the two custom properties
|
|
13
|
+
* `--grid-pattern-x`/`-y`, so any number of instances at any gap share it.
|
|
14
|
+
*/
|
|
15
|
+
import * as React from 'react';
|
|
16
|
+
import { type GuiElement } from '@hanzo/gui';
|
|
17
|
+
export type GridPatternVariant = 'dots' | 'lines' | 'crosses' | 'plus' | 'squares';
|
|
18
|
+
export type GridPatternSize = number | {
|
|
19
|
+
width?: number;
|
|
20
|
+
height?: number;
|
|
21
|
+
};
|
|
22
|
+
export type GridPatternGap = number | {
|
|
23
|
+
x?: number;
|
|
24
|
+
y?: number;
|
|
25
|
+
};
|
|
26
|
+
export type GridPatternFade = boolean | 'edges' | 'center' | 'radial';
|
|
27
|
+
export type GridPatternGradient = {
|
|
28
|
+
from?: string;
|
|
29
|
+
via?: string;
|
|
30
|
+
to?: string;
|
|
31
|
+
opacity?: number;
|
|
32
|
+
};
|
|
33
|
+
export type GridPatternAnimation = {
|
|
34
|
+
duration?: number;
|
|
35
|
+
direction?: 'normal' | 'reverse' | 'alternate';
|
|
36
|
+
timing?: 'linear' | 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out';
|
|
37
|
+
};
|
|
38
|
+
export type GridPatternOffset = {
|
|
39
|
+
x?: number;
|
|
40
|
+
y?: number;
|
|
41
|
+
};
|
|
42
|
+
export type GridPatternMaxArea = {
|
|
43
|
+
width?: number;
|
|
44
|
+
height?: number;
|
|
45
|
+
};
|
|
46
|
+
export type GridPatternProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
47
|
+
/** Which mark repeats across the tile. */
|
|
48
|
+
variant?: GridPatternVariant;
|
|
49
|
+
/** Size of the mark itself, uniform or per axis. */
|
|
50
|
+
size?: GridPatternSize;
|
|
51
|
+
/** Spacing between tiles, uniform or per axis. */
|
|
52
|
+
gap?: GridPatternGap;
|
|
53
|
+
/** Color of the mark. */
|
|
54
|
+
color?: string;
|
|
55
|
+
/** Opacity of the mark. */
|
|
56
|
+
opacity?: number;
|
|
57
|
+
/** Stroke width for the line-based variants. */
|
|
58
|
+
strokeWidth?: number;
|
|
59
|
+
/** Fades the whole pattern at its edges, its center, or radially. */
|
|
60
|
+
fade?: GridPatternFade;
|
|
61
|
+
/** A linear-gradient tint painted over the pattern. */
|
|
62
|
+
gradient?: GridPatternGradient;
|
|
63
|
+
/** Slides the whole pattern by one tile, on a loop. */
|
|
64
|
+
animation?: GridPatternAnimation;
|
|
65
|
+
/** Shifts the pattern's origin before any animation is applied. */
|
|
66
|
+
offset?: GridPatternOffset;
|
|
67
|
+
/** Caps the area the pattern rect covers, for very large viewports. */
|
|
68
|
+
maxArea?: GridPatternMaxArea;
|
|
69
|
+
};
|
|
70
|
+
export declare const GridPattern: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & {
|
|
71
|
+
/** Which mark repeats across the tile. */
|
|
72
|
+
variant?: GridPatternVariant;
|
|
73
|
+
/** Size of the mark itself, uniform or per axis. */
|
|
74
|
+
size?: GridPatternSize;
|
|
75
|
+
/** Spacing between tiles, uniform or per axis. */
|
|
76
|
+
gap?: GridPatternGap;
|
|
77
|
+
/** Color of the mark. */
|
|
78
|
+
color?: string;
|
|
79
|
+
/** Opacity of the mark. */
|
|
80
|
+
opacity?: number;
|
|
81
|
+
/** Stroke width for the line-based variants. */
|
|
82
|
+
strokeWidth?: number;
|
|
83
|
+
/** Fades the whole pattern at its edges, its center, or radially. */
|
|
84
|
+
fade?: GridPatternFade;
|
|
85
|
+
/** A linear-gradient tint painted over the pattern. */
|
|
86
|
+
gradient?: GridPatternGradient;
|
|
87
|
+
/** Slides the whole pattern by one tile, on a loop. */
|
|
88
|
+
animation?: GridPatternAnimation;
|
|
89
|
+
/** Shifts the pattern's origin before any animation is applied. */
|
|
90
|
+
offset?: GridPatternOffset;
|
|
91
|
+
/** Caps the area the pattern rect covers, for very large viewports. */
|
|
92
|
+
maxArea?: GridPatternMaxArea;
|
|
93
|
+
} & React.RefAttributes<GuiElement>>;
|
|
94
|
+
/** Named, ready-to-spread configurations for the common backgrounds. */
|
|
95
|
+
export declare const GridPatternPresets: Record<string, GridPatternProps>;
|
|
96
|
+
//# sourceMappingURL=grid-pattern.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grid-pattern.d.ts","sourceRoot":"","sources":["../../../src/backends/gui/grid-pattern.tsx"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAU,KAAK,UAAU,EAAE,MAAM,YAAY,CAAA;AAGpD,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAAA;AAElF,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AAC1E,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG;IAAE,CAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AAEhE,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,CAAA;AAErE,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,oBAAoB,GAAG;IACjC,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,SAAS,CAAC,EAAE,QAAQ,GAAG,SAAS,GAAG,WAAW,CAAA;IAC9C,MAAM,CAAC,EAAE,QAAQ,GAAG,MAAM,GAAG,SAAS,GAAG,UAAU,GAAG,aAAa,C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