@hanzo/ui 8.27.9 → 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/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/gallery.html +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/package.json +1 -1
|
@@ -0,0 +1,100 @@
|
|
|
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.AnimatedTooltip = AnimatedTooltip;
|
|
38
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
39
|
+
/**
|
|
40
|
+
* AnimatedTooltip — a floating label that fades up above whatever it wraps
|
|
41
|
+
* while the pointer or keyboard focus rests there.
|
|
42
|
+
*
|
|
43
|
+
* `content` is the label, `children` the trigger, and `delay` holds the
|
|
44
|
+
* entrance for that many milliseconds. The panel mounts only while visible, so
|
|
45
|
+
* mounting is the animation: `hz-fade-up` from `styles/motion.css` plays on
|
|
46
|
+
* every appearance, its `animation-delay` carries `delay`, and the
|
|
47
|
+
* reduced-motion guard lives in that stylesheet. It unmounts with no exit,
|
|
48
|
+
* the same trade AnimatedTestimonials makes. The keyframe owns
|
|
49
|
+
* `transform`, so the panel is centred by layout — an anchor spanning the
|
|
50
|
+
* trigger's width aligns it — never by a translate the animation would
|
|
51
|
+
* overwrite.
|
|
52
|
+
*/
|
|
53
|
+
const gui_1 = require("@hanzo/gui");
|
|
54
|
+
const React = __importStar(require("react"));
|
|
55
|
+
const ink_1 = require("./ink.cjs");
|
|
56
|
+
const slot_1 = require("./slot.cjs");
|
|
57
|
+
const Frame = (0, gui_1.styled)(gui_1.XStack, {
|
|
58
|
+
name: 'AnimatedTooltip',
|
|
59
|
+
display: 'inline-flex',
|
|
60
|
+
position: 'relative',
|
|
61
|
+
});
|
|
62
|
+
const Anchor = (0, gui_1.styled)(gui_1.YStack, {
|
|
63
|
+
name: 'AnimatedTooltipAnchor',
|
|
64
|
+
position: 'absolute',
|
|
65
|
+
b: '100%',
|
|
66
|
+
l: 0,
|
|
67
|
+
r: 0,
|
|
68
|
+
mb: '$2',
|
|
69
|
+
items: 'center',
|
|
70
|
+
z: 50,
|
|
71
|
+
});
|
|
72
|
+
const Panel = (0, gui_1.styled)(gui_1.YStack, {
|
|
73
|
+
name: 'AnimatedTooltipPanel',
|
|
74
|
+
position: 'relative',
|
|
75
|
+
bg: '$panel',
|
|
76
|
+
borderColor: '$borderColor',
|
|
77
|
+
borderWidth: 1,
|
|
78
|
+
rounded: '$3',
|
|
79
|
+
px: '$3',
|
|
80
|
+
py: '$1.5',
|
|
81
|
+
});
|
|
82
|
+
const Arrow = (0, gui_1.styled)(gui_1.YStack, {
|
|
83
|
+
name: 'AnimatedTooltipArrow',
|
|
84
|
+
position: 'absolute',
|
|
85
|
+
t: '100%',
|
|
86
|
+
l: '50%',
|
|
87
|
+
ml: -4,
|
|
88
|
+
width: 0,
|
|
89
|
+
height: 0,
|
|
90
|
+
borderLeftWidth: 4,
|
|
91
|
+
borderRightWidth: 4,
|
|
92
|
+
borderTopWidth: 4,
|
|
93
|
+
borderLeftColor: 'transparent',
|
|
94
|
+
borderRightColor: 'transparent',
|
|
95
|
+
borderTopColor: '$panel',
|
|
96
|
+
});
|
|
97
|
+
function AnimatedTooltip({ content, children, delay = 0, ...props }) {
|
|
98
|
+
const [isVisible, setIsVisible] = React.useState(false);
|
|
99
|
+
return ((0, jsx_runtime_1.jsxs)(Frame, { ...(0, slot_1.slot)('animated-tooltip'), "data-state": isVisible ? 'visible' : 'hidden', onMouseEnter: () => setIsVisible(true), onMouseLeave: () => setIsVisible(false), onFocus: () => setIsVisible(true), onBlur: () => setIsVisible(false), ...props, children: [children, isVisible && ((0, jsx_runtime_1.jsx)(Anchor, { ...(0, slot_1.slot)('animated-tooltip-anchor'), children: (0, jsx_runtime_1.jsxs)(Panel, { ...(0, slot_1.slot)('animated-tooltip-panel'), role: "tooltip", className: "hz-fade-up", style: { animationDelay: `${delay}ms` }, children: [(0, ink_1.ink)(content, undefined, { size: '$1', whiteSpace: 'nowrap' }), (0, jsx_runtime_1.jsx)(Arrow, { ...(0, slot_1.slot)('animated-tooltip-arrow') })] }) }))] }));
|
|
100
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as React 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 AnimatedTooltipProps = Omit<React.ComponentProps<typeof Frame>, 'content'> & {
|
|
7
|
+
/** What the floating panel shows. */
|
|
8
|
+
content: React.ReactNode;
|
|
9
|
+
children: React.ReactNode;
|
|
10
|
+
/** Milliseconds to hold before the entrance animation starts. */
|
|
11
|
+
delay?: number;
|
|
12
|
+
};
|
|
13
|
+
export declare function AnimatedTooltip({ content, children, delay, ...props }: AnimatedTooltipProps): React.JSX.Element;
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=animated-tooltip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"animated-tooltip.d.ts","sourceRoot":"","sources":["../../../src/backends/gui/animated-tooltip.tsx"],"names":[],"mappings":"AAiBA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAI9B,QAAA,MAAM,KAAK;;;8CAIT,CAAA;AAwCF,MAAM,MAAM,oBAAoB,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,KAAK,CAAC,EAAE,SAAS,CAAC,GAAG;IACvF,qCAAqC;IACrC,OAAO,EAAE,KAAK,CAAC,SAAS,CAAA;IACxB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,iEAAiE;IACjE,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAED,wBAAgB,eAAe,CAAC,EAC9B,OAAO,EACP,QAAQ,EACR,KAAS,EACT,GAAG,KAAK,EACT,EAAE,oBAAoB,qBA6BtB"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
/**
|
|
4
|
+
* AnimatedTooltip — a floating label that fades up above whatever it wraps
|
|
5
|
+
* while the pointer or keyboard focus rests there.
|
|
6
|
+
*
|
|
7
|
+
* `content` is the label, `children` the trigger, and `delay` holds the
|
|
8
|
+
* entrance for that many milliseconds. The panel mounts only while visible, so
|
|
9
|
+
* mounting is the animation: `hz-fade-up` from `styles/motion.css` plays on
|
|
10
|
+
* every appearance, its `animation-delay` carries `delay`, and the
|
|
11
|
+
* reduced-motion guard lives in that stylesheet. It unmounts with no exit,
|
|
12
|
+
* the same trade AnimatedTestimonials makes. The keyframe owns
|
|
13
|
+
* `transform`, so the panel is centred by layout — an anchor spanning the
|
|
14
|
+
* trigger's width aligns it — never by a translate the animation would
|
|
15
|
+
* overwrite.
|
|
16
|
+
*/
|
|
17
|
+
import { XStack, YStack, styled } from '@hanzo/gui';
|
|
18
|
+
import * as React from 'react';
|
|
19
|
+
import { ink } from './ink.js';
|
|
20
|
+
import { slot } from './slot.js';
|
|
21
|
+
const Frame = styled(XStack, {
|
|
22
|
+
name: 'AnimatedTooltip',
|
|
23
|
+
display: 'inline-flex',
|
|
24
|
+
position: 'relative',
|
|
25
|
+
});
|
|
26
|
+
const Anchor = styled(YStack, {
|
|
27
|
+
name: 'AnimatedTooltipAnchor',
|
|
28
|
+
position: 'absolute',
|
|
29
|
+
b: '100%',
|
|
30
|
+
l: 0,
|
|
31
|
+
r: 0,
|
|
32
|
+
mb: '$2',
|
|
33
|
+
items: 'center',
|
|
34
|
+
z: 50,
|
|
35
|
+
});
|
|
36
|
+
const Panel = styled(YStack, {
|
|
37
|
+
name: 'AnimatedTooltipPanel',
|
|
38
|
+
position: 'relative',
|
|
39
|
+
bg: '$panel',
|
|
40
|
+
borderColor: '$borderColor',
|
|
41
|
+
borderWidth: 1,
|
|
42
|
+
rounded: '$3',
|
|
43
|
+
px: '$3',
|
|
44
|
+
py: '$1.5',
|
|
45
|
+
});
|
|
46
|
+
const Arrow = styled(YStack, {
|
|
47
|
+
name: 'AnimatedTooltipArrow',
|
|
48
|
+
position: 'absolute',
|
|
49
|
+
t: '100%',
|
|
50
|
+
l: '50%',
|
|
51
|
+
ml: -4,
|
|
52
|
+
width: 0,
|
|
53
|
+
height: 0,
|
|
54
|
+
borderLeftWidth: 4,
|
|
55
|
+
borderRightWidth: 4,
|
|
56
|
+
borderTopWidth: 4,
|
|
57
|
+
borderLeftColor: 'transparent',
|
|
58
|
+
borderRightColor: 'transparent',
|
|
59
|
+
borderTopColor: '$panel',
|
|
60
|
+
});
|
|
61
|
+
export function AnimatedTooltip({ content, children, delay = 0, ...props }) {
|
|
62
|
+
const [isVisible, setIsVisible] = React.useState(false);
|
|
63
|
+
return (_jsxs(Frame, { ...slot('animated-tooltip'), "data-state": isVisible ? 'visible' : 'hidden', onMouseEnter: () => setIsVisible(true), onMouseLeave: () => setIsVisible(false), onFocus: () => setIsVisible(true), onBlur: () => setIsVisible(false), ...props, children: [children, isVisible && (_jsx(Anchor, { ...slot('animated-tooltip-anchor'), children: _jsxs(Panel, { ...slot('animated-tooltip-panel'), role: "tooltip", className: "hz-fade-up", style: { animationDelay: `${delay}ms` }, children: [ink(content, undefined, { size: '$1', whiteSpace: 'nowrap' }), _jsx(Arrow, { ...slot('animated-tooltip-arrow') })] }) }))] }));
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=animated-tooltip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"animated-tooltip.js","sourceRoot":"","sources":["../../../src/backends/gui/animated-tooltip.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AACnD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAC3B,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAE7B,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE;IAC3B,IAAI,EAAE,iBAAiB;IACvB,OAAO,EAAE,aAAa;IACtB,QAAQ,EAAE,UAAU;CACrB,CAAC,CAAA;AAEF,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE;IAC5B,IAAI,EAAE,uBAAuB;IAC7B,QAAQ,EAAE,UAAU;IACpB,CAAC,EAAE,MAAM;IACT,CAAC,EAAE,CAAC;IACJ,CAAC,EAAE,CAAC;IACJ,EAAE,EAAE,IAAI;IACR,KAAK,EAAE,QAAQ;IACf,CAAC,EAAE,EAAE;CACN,CAAC,CAAA;AAEF,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE;IAC3B,IAAI,EAAE,sBAAsB;IAC5B,QAAQ,EAAE,UAAU;IACpB,EAAE,EAAE,QAAQ;IACZ,WAAW,EAAE,cAAc;IAC3B,WAAW,EAAE,CAAC;IACd,OAAO,EAAE,IAAI;IACb,EAAE,EAAE,IAAI;IACR,EAAE,EAAE,MAAM;CACX,CAAC,CAAA;AAEF,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE;IAC3B,IAAI,EAAE,sBAAsB;IAC5B,QAAQ,EAAE,UAAU;IACpB,CAAC,EAAE,MAAM;IACT,CAAC,EAAE,KAAK;IACR,EAAE,EAAE,CAAC,CAAC;IACN,KAAK,EAAE,CAAC;IACR,MAAM,EAAE,CAAC;IACT,eAAe,EAAE,CAAC;IAClB,gBAAgB,EAAE,CAAC;IACnB,cAAc,EAAE,CAAC;IACjB,eAAe,EAAE,aAAa;IAC9B,gBAAgB,EAAE,aAAa;IAC/B,cAAc,EAAE,QAAQ;CACzB,CAAC,CAAA;AAUF,MAAM,UAAU,eAAe,CAAC,EAC9B,OAAO,EACP,QAAQ,EACR,KAAK,GAAG,CAAC,EACT,GAAG,KAAK,EACa;IACrB,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;IAEvD,OAAO,CACL,MAAC,KAAK,OACA,IAAI,CAAC,kBAAkB,CAAC,gBAChB,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,EAC5C,YAAY,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,EACtC,YAAY,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,EACvC,OAAO,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,EACjC,MAAM,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,KAC7B,KAAK,aAER,QAAQ,EACR,SAAS,IAAI,CACZ,KAAC,MAAM,OAAK,IAAI,CAAC,yBAAyB,CAAC,YACzC,MAAC,KAAK,OACA,IAAI,CAAC,wBAAwB,CAAC,EAClC,IAAI,EAAC,SAAS,EACd,SAAS,EAAC,YAAY,EACtB,KAAK,EAAE,EAAE,cAAc,EAAE,GAAG,KAAK,IAAI,EAAE,aAEtC,GAAG,CAAC,OAAO,EAAE,SAAS,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC,EAC9D,KAAC,KAAK,OAAK,IAAI,CAAC,wBAAwB,CAAC,GAAI,IACvC,GACD,CACV,IACK,CACT,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
'use client';"use strict";
|
|
2
|
+
'use client';
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.Announcement = Announcement;
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
/**
|
|
7
|
+
* Announcement — an inline strip for a short message, with an optional dismiss
|
|
8
|
+
* button. Unlike Banner (an edge-anchored, role="alert" strip with a variant
|
|
9
|
+
* ladder), an Announcement is a bordered box that sits wherever it is placed,
|
|
10
|
+
* holds its own dismissed/visible state, and calls `onDismiss` once when the
|
|
11
|
+
* close button is pressed.
|
|
12
|
+
*
|
|
13
|
+
* Surface and message share no variant — there is only one look — so this is a
|
|
14
|
+
* styled frame and a styled text host. The message renders straight into that
|
|
15
|
+
* host, the way Banner's does: a Text host already gives a string somewhere to
|
|
16
|
+
* live on native, and a second one per string would carry its own type scale
|
|
17
|
+
* over the host's.
|
|
18
|
+
*/
|
|
19
|
+
const react_1 = require("react");
|
|
20
|
+
const gui_1 = require("@hanzo/gui");
|
|
21
|
+
const lucide_icons_2_1 = require("@hanzogui/lucide-icons-2");
|
|
22
|
+
const slot_1 = require("./slot.cjs");
|
|
23
|
+
const gesture_1 = require("./gesture.cjs");
|
|
24
|
+
const button_1 = require("./button.cjs");
|
|
25
|
+
const CLOSE = 24;
|
|
26
|
+
const AnnouncementFrame = (0, gui_1.styled)(gui_1.XStack, {
|
|
27
|
+
name: 'Announcement',
|
|
28
|
+
position: 'relative',
|
|
29
|
+
items: 'center',
|
|
30
|
+
gap: '$4',
|
|
31
|
+
rounded: '$3',
|
|
32
|
+
borderWidth: 1,
|
|
33
|
+
borderColor: '$borderColor',
|
|
34
|
+
bg: '$background',
|
|
35
|
+
px: '$4',
|
|
36
|
+
py: '$3',
|
|
37
|
+
});
|
|
38
|
+
const AnnouncementText = (0, gui_1.styled)(gui_1.SizableText, {
|
|
39
|
+
name: 'AnnouncementText',
|
|
40
|
+
render: 'div',
|
|
41
|
+
flex: 1,
|
|
42
|
+
size: '$2',
|
|
43
|
+
color: '$ink',
|
|
44
|
+
});
|
|
45
|
+
function Announcement({ children, dismissible = true, onDismiss, ...props }) {
|
|
46
|
+
const [visible, setVisible] = (0, react_1.useState)(true);
|
|
47
|
+
if (!visible)
|
|
48
|
+
return null;
|
|
49
|
+
const dismiss = () => {
|
|
50
|
+
setVisible(false);
|
|
51
|
+
onDismiss?.();
|
|
52
|
+
};
|
|
53
|
+
return ((0, jsx_runtime_1.jsxs)(AnnouncementFrame, { ...(0, slot_1.slot)('announcement'), ...props, children: [(0, jsx_runtime_1.jsx)(AnnouncementText, { ...(0, slot_1.slot)('announcement-message'), children: children }), dismissible ? ((0, jsx_runtime_1.jsx)(button_1.Button, { ...(0, slot_1.slot)('announcement-dismiss'), variant: "ghost", size: "icon", minH: CLOSE, minW: CLOSE, ...(0, gesture_1.touch)(CLOSE), "aria-label": "Dismiss", onPress: dismiss, children: (0, jsx_runtime_1.jsx)(lucide_icons_2_1.X, { size: 16 }) })) : null] }));
|
|
54
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Announcement — an inline strip for a short message, with an optional dismiss
|
|
3
|
+
* button. Unlike Banner (an edge-anchored, role="alert" strip with a variant
|
|
4
|
+
* ladder), an Announcement is a bordered box that sits wherever it is placed,
|
|
5
|
+
* holds its own dismissed/visible state, and calls `onDismiss` once when the
|
|
6
|
+
* close button is pressed.
|
|
7
|
+
*
|
|
8
|
+
* Surface and message share no variant — there is only one look — so this is a
|
|
9
|
+
* styled frame and a styled text host. The message renders straight into that
|
|
10
|
+
* host, the way Banner's does: a Text host already gives a string somewhere to
|
|
11
|
+
* live on native, and a second one per string would carry its own type scale
|
|
12
|
+
* over the host's.
|
|
13
|
+
*/
|
|
14
|
+
import { type ComponentProps, type ReactNode } from 'react';
|
|
15
|
+
declare const AnnouncementFrame: import("@hanzogui/web").GuiComponent<import("@hanzogui/web").TamaDefer, import("@hanzogui/web").GuiElement, import("@hanzogui/core").RNGuiViewNonStyleProps, import("@hanzogui/web").StackStyleBase, {
|
|
16
|
+
elevation?: number | import("@hanzogui/web").SizeTokens | undefined;
|
|
17
|
+
fullscreen?: boolean | undefined;
|
|
18
|
+
}, import("@hanzogui/web").StaticConfigPublic>;
|
|
19
|
+
export type AnnouncementProps = Omit<ComponentProps<typeof AnnouncementFrame>, 'children'> & {
|
|
20
|
+
children: ReactNode;
|
|
21
|
+
dismissible?: boolean;
|
|
22
|
+
onDismiss?: () => void;
|
|
23
|
+
};
|
|
24
|
+
export declare function Announcement({ children, dismissible, onDismiss, ...props }: AnnouncementProps): import("react").JSX.Element | null;
|
|
25
|
+
export {};
|
|
26
|
+
//# sourceMappingURL=announcement.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"announcement.d.ts","sourceRoot":"","sources":["../../../src/backends/gui/announcement.tsx"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAY,KAAK,cAAc,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AASrE,QAAA,MAAM,iBAAiB;;;8CAWrB,CAAA;AAUF,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,cAAc,CAAC,OAAO,iBAAiB,CAAC,EAAE,UAAU,CAAC,GAAG;IAC3F,QAAQ,EAAE,SAAS,CAAA;IACnB,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAA;CACvB,CAAA;AAED,wBAAgB,YAAY,CAAC,EAC3B,QAAQ,EACR,WAAkB,EAClB,SAAS,EACT,GAAG,KAAK,EACT,EAAE,iBAAiB,sCA4BnB"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
/**
|
|
4
|
+
* Announcement — an inline strip for a short message, with an optional dismiss
|
|
5
|
+
* button. Unlike Banner (an edge-anchored, role="alert" strip with a variant
|
|
6
|
+
* ladder), an Announcement is a bordered box that sits wherever it is placed,
|
|
7
|
+
* holds its own dismissed/visible state, and calls `onDismiss` once when the
|
|
8
|
+
* close button is pressed.
|
|
9
|
+
*
|
|
10
|
+
* Surface and message share no variant — there is only one look — so this is a
|
|
11
|
+
* styled frame and a styled text host. The message renders straight into that
|
|
12
|
+
* host, the way Banner's does: a Text host already gives a string somewhere to
|
|
13
|
+
* live on native, and a second one per string would carry its own type scale
|
|
14
|
+
* over the host's.
|
|
15
|
+
*/
|
|
16
|
+
import { useState } from 'react';
|
|
17
|
+
import { SizableText, XStack, styled } from '@hanzo/gui';
|
|
18
|
+
import { X } from '@hanzogui/lucide-icons-2';
|
|
19
|
+
import { slot } from './slot.js';
|
|
20
|
+
import { touch } from './gesture.js';
|
|
21
|
+
import { Button } from './button.js';
|
|
22
|
+
const CLOSE = 24;
|
|
23
|
+
const AnnouncementFrame = styled(XStack, {
|
|
24
|
+
name: 'Announcement',
|
|
25
|
+
position: 'relative',
|
|
26
|
+
items: 'center',
|
|
27
|
+
gap: '$4',
|
|
28
|
+
rounded: '$3',
|
|
29
|
+
borderWidth: 1,
|
|
30
|
+
borderColor: '$borderColor',
|
|
31
|
+
bg: '$background',
|
|
32
|
+
px: '$4',
|
|
33
|
+
py: '$3',
|
|
34
|
+
});
|
|
35
|
+
const AnnouncementText = styled(SizableText, {
|
|
36
|
+
name: 'AnnouncementText',
|
|
37
|
+
render: 'div',
|
|
38
|
+
flex: 1,
|
|
39
|
+
size: '$2',
|
|
40
|
+
color: '$ink',
|
|
41
|
+
});
|
|
42
|
+
export function Announcement({ children, dismissible = true, onDismiss, ...props }) {
|
|
43
|
+
const [visible, setVisible] = useState(true);
|
|
44
|
+
if (!visible)
|
|
45
|
+
return null;
|
|
46
|
+
const dismiss = () => {
|
|
47
|
+
setVisible(false);
|
|
48
|
+
onDismiss?.();
|
|
49
|
+
};
|
|
50
|
+
return (_jsxs(AnnouncementFrame, { ...slot('announcement'), ...props, children: [_jsx(AnnouncementText, { ...slot('announcement-message'), children: children }), dismissible ? (_jsx(Button, { ...slot('announcement-dismiss'), variant: "ghost", size: "icon", minH: CLOSE, minW: CLOSE, ...touch(CLOSE), "aria-label": "Dismiss", onPress: dismiss, children: _jsx(X, { size: 16 }) })) : null] }));
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=announcement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"announcement.js","sourceRoot":"","sources":["../../../src/backends/gui/announcement.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,QAAQ,EAAuC,MAAM,OAAO,CAAA;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AACxD,OAAO,EAAE,CAAC,EAAE,MAAM,0BAA0B,CAAA;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAC7B,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAA;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAEjC,MAAM,KAAK,GAAG,EAAE,CAAA;AAEhB,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE;IACvC,IAAI,EAAE,cAAc;IACpB,QAAQ,EAAE,UAAU;IACpB,KAAK,EAAE,QAAQ;IACf,GAAG,EAAE,IAAI;IACT,OAAO,EAAE,IAAI;IACb,WAAW,EAAE,CAAC;IACd,WAAW,EAAE,cAAc;IAC3B,EAAE,EAAE,aAAa;IACjB,EAAE,EAAE,IAAI;IACR,EAAE,EAAE,IAAI;CACT,CAAC,CAAA;AAEF,MAAM,gBAAgB,GAAG,MAAM,CAAC,WAAW,EAAE;IAC3C,IAAI,EAAE,kBAAkB;IACxB,MAAM,EAAE,KAAK;IACb,IAAI,EAAE,CAAC;IACP,IAAI,EAAE,IAAI;IACV,KAAK,EAAE,MAAM;CACd,CAAC,CAAA;AAQF,MAAM,UAAU,YAAY,CAAC,EAC3B,QAAQ,EACR,WAAW,GAAG,IAAI,EAClB,SAAS,EACT,GAAG,KAAK,EACU;IAClB,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAA;IAC5C,IAAI,CAAC,OAAO;QAAE,OAAO,IAAI,CAAA;IAEzB,MAAM,OAAO,GAAG,GAAG,EAAE;QACnB,UAAU,CAAC,KAAK,CAAC,CAAA;QACjB,SAAS,EAAE,EAAE,CAAA;IACf,CAAC,CAAA;IAED,OAAO,CACL,MAAC,iBAAiB,OAAK,IAAI,CAAC,cAAc,CAAC,KAAM,KAAK,aACpD,KAAC,gBAAgB,OAAK,IAAI,CAAC,sBAAsB,CAAC,YAAG,QAAQ,GAAoB,EAChF,WAAW,CAAC,CAAC,CAAC,CACb,KAAC,MAAM,OACD,IAAI,CAAC,sBAAsB,CAAC,EAChC,OAAO,EAAC,OAAO,EACf,IAAI,EAAC,MAAM,EACX,IAAI,EAAE,KAAK,EACX,IAAI,EAAE,KAAK,KACP,KAAK,CAAC,KAAK,CAAC,gBACL,SAAS,EACpB,OAAO,EAAE,OAAO,YAEhB,KAAC,CAAC,IAAC,IAAI,EAAE,EAAE,GAAI,GACR,CACV,CAAC,CAAC,CAAC,IAAI,IACU,CACrB,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,198 @@
|
|
|
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.gradientPresets = void 0;
|
|
38
|
+
exports.AppleCardsCarousel = AppleCardsCarousel;
|
|
39
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
40
|
+
/**
|
|
41
|
+
* AppleCardsCarousel — a stack of full-bleed cards with one in front and the
|
|
42
|
+
* next two peeking out behind it, each a step smaller and further to the side,
|
|
43
|
+
* the way App Store "Today" cards fan out.
|
|
44
|
+
*
|
|
45
|
+
* A pointer drag on the front card carries it sideways and slides its
|
|
46
|
+
* background image the other way for depth; releasing past `swipeThreshold`,
|
|
47
|
+
* or with a quick flick, commits to the neighbour and the stack springs into
|
|
48
|
+
* its new order. A press that begins on a control inside the card belongs to
|
|
49
|
+
* the control, not to a drag. Arrow keys while the region has focus, the arrow
|
|
50
|
+
* buttons, the dots and an optional auto-play (held while the pointer is over
|
|
51
|
+
* the region, and never started under a reduced-motion preference) all move
|
|
52
|
+
* the same index. Cards more than two steps from the front are not drawn.
|
|
53
|
+
*
|
|
54
|
+
* Motion is CSS transform + transition on the card, switched off for the
|
|
55
|
+
* duration of a drag so the card tracks the pointer without lag, and off
|
|
56
|
+
* altogether under a reduced-motion preference.
|
|
57
|
+
*/
|
|
58
|
+
const React = __importStar(require("react"));
|
|
59
|
+
const gui_1 = require("@hanzo/gui");
|
|
60
|
+
const lucide_icons_2_1 = require("@hanzogui/lucide-icons-2");
|
|
61
|
+
const glass_1 = require("../../glass.cjs");
|
|
62
|
+
const sx_1 = require("../../sx.cjs");
|
|
63
|
+
const gesture_1 = require("./gesture.cjs");
|
|
64
|
+
const SPRING = 'transform .4s cubic-bezier(.2,.8,.2,1), opacity .4s ease';
|
|
65
|
+
/** px/ms — a flick commits regardless of distance. */
|
|
66
|
+
const FLICK = 0.5;
|
|
67
|
+
/** Two pointer samples closer than half a frame say nothing about speed. */
|
|
68
|
+
const FRAME = 8;
|
|
69
|
+
/** A pointer that has been still this long before release is not flicking. */
|
|
70
|
+
const STALE = 100;
|
|
71
|
+
const ARROW = 36;
|
|
72
|
+
/** What a press inside a card must not turn into a drag. */
|
|
73
|
+
const CONTROL = 'a,button,input,select,textarea';
|
|
74
|
+
const WHITE = (a) => `rgba(255,255,255,${a})`;
|
|
75
|
+
/** Position, scale, opacity and stacking order for the card `offset` slots from the front. */
|
|
76
|
+
const layerAt = (offset, cardCount, stackOffset, stackScale) => {
|
|
77
|
+
const abs = Math.abs(offset);
|
|
78
|
+
if (abs > 2)
|
|
79
|
+
return { visible: false, x: 0, scale: 1, opacity: 0, zIndex: 0 };
|
|
80
|
+
return {
|
|
81
|
+
visible: true,
|
|
82
|
+
x: offset * stackOffset,
|
|
83
|
+
scale: Math.pow(stackScale, abs),
|
|
84
|
+
opacity: Math.max(0, 1 - abs * 0.3),
|
|
85
|
+
zIndex: cardCount - abs,
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
const still = () => typeof window !== 'undefined' && !!window.matchMedia?.('(prefers-reduced-motion: reduce)').matches;
|
|
89
|
+
function AppleCardsCarousel({ cards, autoPlay = false, autoPlayInterval = 5000, className, cardClassName, showArrows = true, showDots = true, parallaxOffset = 50, stackOffset = 10, stackScale = 0.95, swipeThreshold = 50, }) {
|
|
90
|
+
const [index, setIndex] = React.useState(0);
|
|
91
|
+
const [hovering, setHovering] = React.useState(false);
|
|
92
|
+
const [dragX, setDragX] = React.useState(0);
|
|
93
|
+
const [dragging, setDragging] = React.useState(false);
|
|
94
|
+
/**
|
|
95
|
+
* The drag in flight — pointer origin, offset so far, and the sample its
|
|
96
|
+
* velocity is measured from — or null between drags. `pointermove` fires for
|
|
97
|
+
* a pointer that is merely passing over the card, so null is what keeps a
|
|
98
|
+
* hover from moving it.
|
|
99
|
+
*/
|
|
100
|
+
const track = React.useRef(null);
|
|
101
|
+
/** The reduced-motion preference, read once mounted so the server and the client agree. */
|
|
102
|
+
const [calm, setCalm] = React.useState(false);
|
|
103
|
+
React.useEffect(() => setCalm(still()), []);
|
|
104
|
+
const count = cards.length;
|
|
105
|
+
const step = React.useCallback((by) => setIndex((i) => (count ? (i + by + count) % count : 0)), [count]);
|
|
106
|
+
const goNext = React.useCallback(() => step(1), [step]);
|
|
107
|
+
const goPrevious = React.useCallback(() => step(-1), [step]);
|
|
108
|
+
React.useEffect(() => {
|
|
109
|
+
if (!autoPlay || hovering || count < 2 || calm)
|
|
110
|
+
return;
|
|
111
|
+
const t = setInterval(goNext, autoPlayInterval);
|
|
112
|
+
return () => clearInterval(t);
|
|
113
|
+
}, [autoPlay, hovering, autoPlayInterval, goNext, count, calm]);
|
|
114
|
+
const onKeyDown = React.useCallback((e) => {
|
|
115
|
+
if (e.key === 'ArrowLeft')
|
|
116
|
+
goPrevious();
|
|
117
|
+
else if (e.key === 'ArrowRight')
|
|
118
|
+
goNext();
|
|
119
|
+
}, [goNext, goPrevious]);
|
|
120
|
+
const begin = React.useCallback((e) => {
|
|
121
|
+
// The pointer capture `drag()` took would retarget the control's click to
|
|
122
|
+
// the card, so the capture goes back and the drag never arms.
|
|
123
|
+
const on = e.target;
|
|
124
|
+
if (on?.closest?.(CONTROL)) {
|
|
125
|
+
const card = e.currentTarget;
|
|
126
|
+
if (e.pointerId != null)
|
|
127
|
+
card?.releasePointerCapture?.(e.pointerId);
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
track.current = { origin: (0, gesture_1.dragPos)(e, true), x: 0, v: 0, sample: { x: 0, t: Date.now() } };
|
|
131
|
+
setDragging(true);
|
|
132
|
+
}, []);
|
|
133
|
+
const move = React.useCallback((e) => {
|
|
134
|
+
const k = track.current;
|
|
135
|
+
if (!k)
|
|
136
|
+
return;
|
|
137
|
+
k.x = (0, gesture_1.dragPos)(e, true) - k.origin;
|
|
138
|
+
const t = Date.now();
|
|
139
|
+
const dt = t - k.sample.t;
|
|
140
|
+
if (dt >= FRAME) {
|
|
141
|
+
k.v = (k.x - k.sample.x) / dt;
|
|
142
|
+
k.sample = { x: k.x, t };
|
|
143
|
+
}
|
|
144
|
+
setDragX(k.x);
|
|
145
|
+
}, []);
|
|
146
|
+
const end = React.useCallback(() => {
|
|
147
|
+
const k = track.current;
|
|
148
|
+
if (!k)
|
|
149
|
+
return;
|
|
150
|
+
track.current = null;
|
|
151
|
+
const { x, v, sample } = k;
|
|
152
|
+
const flick = Date.now() - sample.t <= STALE && Math.abs(v) > FLICK;
|
|
153
|
+
if (Math.abs(x) > swipeThreshold || flick)
|
|
154
|
+
step(x > 0 ? -1 : 1);
|
|
155
|
+
setDragging(false);
|
|
156
|
+
setDragX(0);
|
|
157
|
+
}, [step, swipeThreshold]);
|
|
158
|
+
const gesture = (0, gesture_1.drag)({ begin, move, end, enabled: count > 1 });
|
|
159
|
+
const settle = dragging || calm ? 'none' : SPRING;
|
|
160
|
+
return ((0, jsx_runtime_1.jsxs)(gui_1.YStack, { "data-slot": "apple-carousel", role: "region", "aria-roledescription": "carousel", "aria-label": "Cards", position: "relative", width: "100%", maxW: 1152, mx: "auto", px: "$4", py: "$6", tabIndex: 0, onKeyDown: onKeyDown, onMouseEnter: () => setHovering(true), onMouseLeave: () => setHovering(false), ...(0, sx_1.sx)(className), children: [(0, jsx_runtime_1.jsx)(gui_1.XStack, { position: "relative", width: "100%", height: 400, $md: { height: 500 }, $lg: { height: 600 }, items: "center", justify: "center", children: cards.map((card, i) => {
|
|
161
|
+
const layer = layerAt(i - index, count, stackOffset, stackScale);
|
|
162
|
+
const active = i === index;
|
|
163
|
+
const x = layer.x + (active ? dragX : 0);
|
|
164
|
+
const parallax = active
|
|
165
|
+
? Math.max(-parallaxOffset, Math.min(parallaxOffset, (-dragX / 200) * parallaxOffset))
|
|
166
|
+
: 0;
|
|
167
|
+
return ((0, jsx_runtime_1.jsx)(gui_1.YStack, { "data-slot": "apple-carousel-card", "data-active": active || undefined, role: "group", "aria-roledescription": "slide", "aria-label": `${i + 1} of ${count}`, "aria-hidden": !active || undefined, position: "absolute", inset: 0, pointerEvents: active ? 'auto' : 'none', display: layer.visible ? 'flex' : 'none', cursor: active ? (dragging ? 'grabbing' : 'grab') : undefined, style: {
|
|
168
|
+
transform: `translateX(${x}px) scale(${layer.scale})`,
|
|
169
|
+
opacity: layer.opacity,
|
|
170
|
+
zIndex: layer.zIndex,
|
|
171
|
+
transition: settle,
|
|
172
|
+
// A sideways swipe is the card's; the page keeps vertical
|
|
173
|
+
// scroll. Without this a touch browser takes the pan as a
|
|
174
|
+
// scroll and cancels the pointer before the threshold.
|
|
175
|
+
touchAction: 'pan-y',
|
|
176
|
+
userSelect: 'none',
|
|
177
|
+
}, ...(active ? gesture : null), children: (0, jsx_runtime_1.jsxs)(gui_1.YStack, { position: "relative", width: "100%", height: "100%", overflow: "hidden", rounded: "$6", borderWidth: 1, borderColor: "$borderColor", bg: "$panel", shadowColor: "rgba(0,0,0,0.25)", shadowOffset: { width: 0, height: 25 }, shadowRadius: 50, style: { background: card.gradient }, ...(0, sx_1.sx)(cardClassName), children: [card.image ? ((0, jsx_runtime_1.jsxs)(gui_1.YStack, { position: "absolute", inset: 0, style: {
|
|
178
|
+
transform: `translateX(${parallax}px)`,
|
|
179
|
+
transition: dragging || calm ? 'none' : 'transform .2s ease',
|
|
180
|
+
}, children: [(0, jsx_runtime_1.jsx)(gui_1.Image, { src: card.image, alt: card.title, width: "100%", height: "100%", objectFit: "cover" }), (0, jsx_runtime_1.jsx)(gui_1.YStack, { position: "absolute", inset: 0, style: { background: 'linear-gradient(to top, rgba(0,0,0,.6), rgba(0,0,0,.2), transparent)' } })] })) : null, (0, jsx_runtime_1.jsx)(gui_1.YStack, { position: "relative", justify: "flex-end", height: "100%", p: "$6", $md: { p: '$8' }, gap: "$2", children: card.content ?? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(gui_1.SizableText, { size: "$9", fontWeight: "700", color: "white", children: card.title }), card.subtitle ? ((0, jsx_runtime_1.jsx)(gui_1.SizableText, { size: "$6", color: WHITE(0.8), children: card.subtitle })) : null, card.description ? ((0, jsx_runtime_1.jsx)(gui_1.SizableText, { size: "$4", color: WHITE(0.7), maxW: 640, children: card.description })) : null] })) })] }) }, card.id));
|
|
181
|
+
}) }), showArrows
|
|
182
|
+
? [
|
|
183
|
+
['previous', 'Previous card', goPrevious, lucide_icons_2_1.ChevronLeft, { left: 16 }],
|
|
184
|
+
['next', 'Next card', goNext, lucide_icons_2_1.ChevronRight, { right: 16 }],
|
|
185
|
+
].map(([name, label, go, Chevron, side]) => ((0, jsx_runtime_1.jsx)(gui_1.XStack, { "data-slot": `apple-carousel-${name}`, render: (0, jsx_runtime_1.jsx)("button", { type: "button" }), "aria-label": label, position: "absolute", display: "none", $md: { display: 'flex' }, style: { top: '50%', transform: 'translateY(-50%)', zIndex: 20, ...side }, items: "center", justify: "center", width: ARROW, height: ARROW, rounded: 999, ...(0, glass_1.glass)(2), bg: WHITE(0.1), hoverStyle: { bg: WHITE(0.2) }, borderWidth: 1, borderColor: WHITE(0.2), cursor: "pointer", ...(0, gesture_1.touch)(ARROW, 44), onClick: go, children: (0, jsx_runtime_1.jsx)(Chevron, { size: 20, color: "white" }) }, name)))
|
|
186
|
+
: null, showDots ? ((0, jsx_runtime_1.jsx)(gui_1.XStack, { position: "absolute", style: { bottom: 16, left: '50%', transform: 'translateX(-50%)', zIndex: 20 }, gap: "$2", children: cards.map((card, i) => ((0, jsx_runtime_1.jsx)(gui_1.XStack, { "data-slot": "apple-carousel-dot", render: (0, jsx_runtime_1.jsx)("button", { type: "button" }), "aria-label": `Go to card ${i + 1}`, "aria-current": i === index || undefined, "data-active": i === index || undefined, height: 8, width: i === index ? 32 : 8, rounded: 999, bg: i === index ? 'white' : WHITE(0.4), hoverStyle: { bg: i === index ? 'white' : WHITE(0.6) }, cursor: "pointer", style: { transition: 'width .3s ease, background-color .3s ease' }, ...(0, gesture_1.touch)(8, 44, 'y'), onClick: () => setIndex(i) }, card.id))) })) : null] }));
|
|
187
|
+
}
|
|
188
|
+
/** Pre-built CSS gradients for cards that skip `image`. */
|
|
189
|
+
exports.gradientPresets = {
|
|
190
|
+
sunset: 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)',
|
|
191
|
+
ocean: 'linear-gradient(135deg, #667eea 0%, #4ca1af 100%)',
|
|
192
|
+
fire: 'linear-gradient(135deg, #f093fb 0%, #f5576c 100%)',
|
|
193
|
+
forest: 'linear-gradient(135deg, #4facfe 0%, #00f2fe 100%)',
|
|
194
|
+
galaxy: 'linear-gradient(135deg, #7303c0 0%, #ec38bc 50%, #fdeff9 100%)',
|
|
195
|
+
aurora: 'linear-gradient(135deg, #89f7fe 0%, #66a6ff 100%)',
|
|
196
|
+
peach: 'linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%)',
|
|
197
|
+
lavender: 'linear-gradient(135deg, #a8edea 0%, #fed6e3 100%)',
|
|
198
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AppleCardsCarousel — a stack of full-bleed cards with one in front and the
|
|
3
|
+
* next two peeking out behind it, each a step smaller and further to the side,
|
|
4
|
+
* the way App Store "Today" cards fan out.
|
|
5
|
+
*
|
|
6
|
+
* A pointer drag on the front card carries it sideways and slides its
|
|
7
|
+
* background image the other way for depth; releasing past `swipeThreshold`,
|
|
8
|
+
* or with a quick flick, commits to the neighbour and the stack springs into
|
|
9
|
+
* its new order. A press that begins on a control inside the card belongs to
|
|
10
|
+
* the control, not to a drag. Arrow keys while the region has focus, the arrow
|
|
11
|
+
* buttons, the dots and an optional auto-play (held while the pointer is over
|
|
12
|
+
* the region, and never started under a reduced-motion preference) all move
|
|
13
|
+
* the same index. Cards more than two steps from the front are not drawn.
|
|
14
|
+
*
|
|
15
|
+
* Motion is CSS transform + transition on the card, switched off for the
|
|
16
|
+
* duration of a drag so the card tracks the pointer without lag, and off
|
|
17
|
+
* altogether under a reduced-motion preference.
|
|
18
|
+
*/
|
|
19
|
+
import * as React from 'react';
|
|
20
|
+
export type CarouselCard = {
|
|
21
|
+
id: string;
|
|
22
|
+
title: string;
|
|
23
|
+
subtitle?: string;
|
|
24
|
+
description?: string;
|
|
25
|
+
image?: string;
|
|
26
|
+
gradient?: string;
|
|
27
|
+
content?: React.ReactNode;
|
|
28
|
+
};
|
|
29
|
+
export type AppleCardsCarouselProps = {
|
|
30
|
+
cards: CarouselCard[];
|
|
31
|
+
autoPlay?: boolean;
|
|
32
|
+
autoPlayInterval?: number;
|
|
33
|
+
className?: string;
|
|
34
|
+
cardClassName?: string;
|
|
35
|
+
showArrows?: boolean;
|
|
36
|
+
showDots?: boolean;
|
|
37
|
+
parallaxOffset?: number;
|
|
38
|
+
stackOffset?: number;
|
|
39
|
+
stackScale?: number;
|
|
40
|
+
swipeThreshold?: number;
|
|
41
|
+
};
|
|
42
|
+
export declare function AppleCardsCarousel({ cards, autoPlay, autoPlayInterval, className, cardClassName, showArrows, showDots, parallaxOffset, stackOffset, stackScale, swipeThreshold, }: AppleCardsCarouselProps): React.JSX.Element;
|
|
43
|
+
/** Pre-built CSS gradients for cards that skip `image`. */
|
|
44
|
+
export declare const gradientPresets: Record<'sunset' | 'ocean' | 'fire' | 'forest' | 'galaxy' | 'aurora' | 'peach' | 'lavender', string>;
|
|
45
|
+
//# sourceMappingURL=apple-cards-carousel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apple-cards-carousel.d.ts","sourceRoot":"","sources":["../../../src/backends/gui/apple-cards-carousel.tsx"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAQ9B,MAAM,MAAM,YAAY,GAAG;IACzB,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAC1B,CAAA;AAED,MAAM,MAAM,uBAAuB,GAAG;IACpC,KAAK,EAAE,YAAY,EAAE,CAAA;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB,CAAA;AAgCD,wBAAgB,kBAAkB,CAAC,EACjC,KAAK,EACL,QAAgB,EAChB,gBAAuB,EACvB,SAAS,EACT,aAAa,EACb,UAAiB,EACjB,QAAe,EACf,cAAmB,EACnB,WAAgB,EAChB,UAAiB,EACjB,cAAmB,GACpB,EAAE,uBAAuB,qBAyQzB;AAED,2DAA2D;AAC3D,eAAO,MAAM,eAAe,EAAE,MAAM,CAClC,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,OAAO,GAAG,UAAU,EACnF,MAAM,CAUP,CAAA"}
|