@hanzo/ui 8.27.8 → 8.27.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/dist/backends/gui/3d-card.cjs +100 -0
- package/dist/backends/gui/3d-card.d.ts +59 -0
- package/dist/backends/gui/3d-card.d.ts.map +1 -0
- package/dist/backends/gui/3d-card.js +92 -0
- package/dist/backends/gui/3d-card.js.map +1 -0
- package/dist/backends/gui/3d-marquee.cjs +225 -0
- package/dist/backends/gui/3d-marquee.d.ts +114 -0
- package/dist/backends/gui/3d-marquee.d.ts.map +1 -0
- package/dist/backends/gui/3d-marquee.js +190 -0
- package/dist/backends/gui/3d-marquee.js.map +1 -0
- package/dist/backends/gui/3d-pin.cjs +51 -0
- package/dist/backends/gui/3d-pin.d.ts +14 -0
- package/dist/backends/gui/3d-pin.d.ts.map +1 -0
- package/dist/backends/gui/3d-pin.js +49 -0
- package/dist/backends/gui/3d-pin.js.map +1 -0
- package/dist/backends/gui/advanced-chart.cjs +61 -0
- package/dist/backends/gui/advanced-chart.d.ts +38 -0
- package/dist/backends/gui/advanced-chart.d.ts.map +1 -0
- package/dist/backends/gui/advanced-chart.js +59 -0
- package/dist/backends/gui/advanced-chart.js.map +1 -0
- package/dist/backends/gui/alert.cjs +106 -0
- package/dist/backends/gui/alert.d.ts +39 -0
- package/dist/backends/gui/alert.d.ts.map +1 -0
- package/dist/backends/gui/alert.js +102 -0
- package/dist/backends/gui/alert.js.map +1 -0
- package/dist/backends/gui/android.cjs +52 -0
- package/dist/backends/gui/android.d.ts +16 -0
- package/dist/backends/gui/android.d.ts.map +1 -0
- package/dist/backends/gui/android.js +50 -0
- package/dist/backends/gui/android.js.map +1 -0
- package/dist/backends/gui/animated-beam.cjs +97 -0
- package/dist/backends/gui/animated-beam.d.ts +57 -0
- package/dist/backends/gui/animated-beam.d.ts.map +1 -0
- package/dist/backends/gui/animated-beam.js +62 -0
- package/dist/backends/gui/animated-beam.js.map +1 -0
- package/dist/backends/gui/animated-cursor.cjs +183 -0
- package/dist/backends/gui/animated-cursor.d.ts +42 -0
- package/dist/backends/gui/animated-cursor.d.ts.map +1 -0
- package/dist/backends/gui/animated-cursor.js +181 -0
- package/dist/backends/gui/animated-cursor.js.map +1 -0
- package/dist/backends/gui/animated-testimonials.cjs +109 -0
- package/dist/backends/gui/animated-testimonials.d.ts +23 -0
- package/dist/backends/gui/animated-testimonials.d.ts.map +1 -0
- package/dist/backends/gui/animated-testimonials.js +74 -0
- package/dist/backends/gui/animated-testimonials.js.map +1 -0
- package/dist/backends/gui/animated-tooltip.cjs +100 -0
- package/dist/backends/gui/animated-tooltip.d.ts +15 -0
- package/dist/backends/gui/animated-tooltip.d.ts.map +1 -0
- package/dist/backends/gui/animated-tooltip.js +65 -0
- package/dist/backends/gui/animated-tooltip.js.map +1 -0
- package/dist/backends/gui/announcement.cjs +54 -0
- package/dist/backends/gui/announcement.d.ts +26 -0
- package/dist/backends/gui/announcement.d.ts.map +1 -0
- package/dist/backends/gui/announcement.js +52 -0
- package/dist/backends/gui/announcement.js.map +1 -0
- package/dist/backends/gui/apple-cards-carousel.cjs +198 -0
- package/dist/backends/gui/apple-cards-carousel.d.ts +45 -0
- package/dist/backends/gui/apple-cards-carousel.d.ts.map +1 -0
- package/dist/backends/gui/apple-cards-carousel.js +162 -0
- package/dist/backends/gui/apple-cards-carousel.js.map +1 -0
- package/dist/backends/gui/apple-hello-effect.cjs +38 -0
- package/dist/backends/gui/apple-hello-effect.d.ts +9 -0
- package/dist/backends/gui/apple-hello-effect.d.ts.map +1 -0
- package/dist/backends/gui/apple-hello-effect.js +36 -0
- package/dist/backends/gui/apple-hello-effect.js.map +1 -0
- package/dist/backends/gui/banner.cjs +108 -0
- package/dist/backends/gui/banner.d.ts +33 -0
- package/dist/backends/gui/banner.d.ts.map +1 -0
- package/dist/backends/gui/banner.js +106 -0
- package/dist/backends/gui/banner.js.map +1 -0
- package/dist/backends/gui/calendar.cjs +152 -0
- package/dist/backends/gui/calendar.d.ts +41 -0
- package/dist/backends/gui/calendar.d.ts.map +1 -0
- package/dist/backends/gui/calendar.js +151 -0
- package/dist/backends/gui/calendar.js.map +1 -0
- package/dist/backends/gui/choicebox.cjs +50 -0
- package/dist/backends/gui/choicebox.d.ts +33 -0
- package/dist/backends/gui/choicebox.d.ts.map +1 -0
- package/dist/backends/gui/choicebox.js +49 -0
- package/dist/backends/gui/choicebox.js.map +1 -0
- package/dist/backends/gui/code-block.cjs +120 -0
- package/dist/backends/gui/code-block.d.ts +22 -0
- package/dist/backends/gui/code-block.d.ts.map +1 -0
- package/dist/backends/gui/code-block.js +118 -0
- package/dist/backends/gui/code-block.js.map +1 -0
- package/dist/backends/gui/code-editor.cjs +195 -0
- package/dist/backends/gui/code-editor.d.ts +43 -0
- package/dist/backends/gui/code-editor.d.ts.map +1 -0
- package/dist/backends/gui/code-editor.js +160 -0
- package/dist/backends/gui/code-editor.js.map +1 -0
- package/dist/backends/gui/code-tabs.cjs +21 -0
- package/dist/backends/gui/code-tabs.d.ts +22 -0
- package/dist/backends/gui/code-tabs.d.ts.map +1 -0
- package/dist/backends/gui/code-tabs.js +19 -0
- package/dist/backends/gui/code-tabs.js.map +1 -0
- package/dist/backends/gui/color-picker.cjs +141 -0
- package/dist/backends/gui/color-picker.d.ts +25 -0
- package/dist/backends/gui/color-picker.d.ts.map +1 -0
- package/dist/backends/gui/color-picker.js +139 -0
- package/dist/backends/gui/color-picker.js.map +1 -0
- package/dist/backends/gui/combobox.cjs +42 -0
- package/dist/backends/gui/combobox.d.ts +39 -0
- package/dist/backends/gui/combobox.d.ts.map +1 -0
- package/dist/backends/gui/combobox.js +40 -0
- package/dist/backends/gui/combobox.js.map +1 -0
- package/dist/backends/gui/company-profile.cjs +43 -0
- package/dist/backends/gui/company-profile.d.ts +33 -0
- package/dist/backends/gui/company-profile.d.ts.map +1 -0
- package/dist/backends/gui/company-profile.js +41 -0
- package/dist/backends/gui/company-profile.js.map +1 -0
- package/dist/backends/gui/comparison.cjs +43 -0
- package/dist/backends/gui/comparison.d.ts +16 -0
- package/dist/backends/gui/comparison.d.ts.map +1 -0
- package/dist/backends/gui/comparison.js +41 -0
- package/dist/backends/gui/comparison.js.map +1 -0
- package/dist/backends/gui/credit-card.cjs +80 -0
- package/dist/backends/gui/credit-card.d.ts +21 -0
- package/dist/backends/gui/credit-card.d.ts.map +1 -0
- package/dist/backends/gui/credit-card.js +78 -0
- package/dist/backends/gui/credit-card.js.map +1 -0
- package/dist/backends/gui/crypto-market.cjs +128 -0
- package/dist/backends/gui/crypto-market.d.ts +52 -0
- package/dist/backends/gui/crypto-market.d.ts.map +1 -0
- package/dist/backends/gui/crypto-market.js +126 -0
- package/dist/backends/gui/crypto-market.js.map +1 -0
- package/dist/backends/gui/crypto-screener.cjs +55 -0
- package/dist/backends/gui/crypto-screener.d.ts +42 -0
- package/dist/backends/gui/crypto-screener.d.ts.map +1 -0
- package/dist/backends/gui/crypto-screener.js +53 -0
- package/dist/backends/gui/crypto-screener.js.map +1 -0
- package/dist/backends/gui/cursor.cjs +40 -0
- package/dist/backends/gui/cursor.d.ts +16 -0
- package/dist/backends/gui/cursor.d.ts.map +1 -0
- package/dist/backends/gui/cursor.js +38 -0
- package/dist/backends/gui/cursor.js.map +1 -0
- package/dist/backends/gui/data-table.cjs +211 -0
- package/dist/backends/gui/data-table.d.ts +71 -0
- package/dist/backends/gui/data-table.d.ts.map +1 -0
- package/dist/backends/gui/data-table.js +175 -0
- package/dist/backends/gui/data-table.js.map +1 -0
- package/dist/backends/gui/date-picker.cjs +66 -0
- package/dist/backends/gui/date-picker.d.ts +29 -0
- package/dist/backends/gui/date-picker.d.ts.map +1 -0
- package/dist/backends/gui/date-picker.js +64 -0
- package/dist/backends/gui/date-picker.js.map +1 -0
- package/dist/backends/gui/desktop-spotlight.cjs +46 -0
- package/dist/backends/gui/desktop-spotlight.d.ts +34 -0
- package/dist/backends/gui/desktop-spotlight.d.ts.map +1 -0
- package/dist/backends/gui/desktop-spotlight.js +44 -0
- package/dist/backends/gui/desktop-spotlight.js.map +1 -0
- package/dist/backends/gui/desktop-window.cjs +180 -0
- package/dist/backends/gui/desktop-window.d.ts +51 -0
- package/dist/backends/gui/desktop-window.d.ts.map +1 -0
- package/dist/backends/gui/desktop-window.js +177 -0
- package/dist/backends/gui/desktop-window.js.map +1 -0
- package/dist/backends/gui/desktop.cjs +238 -0
- package/dist/backends/gui/desktop.d.ts +109 -0
- package/dist/backends/gui/desktop.d.ts.map +1 -0
- package/dist/backends/gui/desktop.js +199 -0
- package/dist/backends/gui/desktop.js.map +1 -0
- package/dist/backends/gui/dialog-stack.cjs +26 -0
- package/dist/backends/gui/dialog-stack.d.ts +23 -0
- package/dist/backends/gui/dialog-stack.d.ts.map +1 -0
- package/dist/backends/gui/dialog-stack.js +24 -0
- package/dist/backends/gui/dialog-stack.js.map +1 -0
- package/dist/backends/gui/dock.cjs +99 -0
- package/dist/backends/gui/dock.d.ts +41 -0
- package/dist/backends/gui/dock.d.ts.map +1 -0
- package/dist/backends/gui/dock.js +96 -0
- package/dist/backends/gui/dock.js.map +1 -0
- package/dist/backends/gui/dropzone.cjs +142 -0
- package/dist/backends/gui/dropzone.d.ts +12 -0
- package/dist/backends/gui/dropzone.d.ts.map +1 -0
- package/dist/backends/gui/dropzone.js +140 -0
- package/dist/backends/gui/dropzone.js.map +1 -0
- package/dist/backends/gui/editor.cjs +80 -0
- package/dist/backends/gui/editor.d.ts +23 -0
- package/dist/backends/gui/editor.d.ts.map +1 -0
- package/dist/backends/gui/editor.js +45 -0
- package/dist/backends/gui/editor.js.map +1 -0
- package/dist/backends/gui/empty.cjs +71 -0
- package/dist/backends/gui/empty.d.ts +43 -0
- package/dist/backends/gui/empty.d.ts.map +1 -0
- package/dist/backends/gui/empty.js +63 -0
- package/dist/backends/gui/empty.js.map +1 -0
- package/dist/backends/gui/financials.cjs +45 -0
- package/dist/backends/gui/financials.d.ts +36 -0
- package/dist/backends/gui/financials.d.ts.map +1 -0
- package/dist/backends/gui/financials.js +43 -0
- package/dist/backends/gui/financials.js.map +1 -0
- package/dist/backends/gui/forex-market.cjs +21 -0
- package/dist/backends/gui/forex-market.d.ts +17 -0
- package/dist/backends/gui/forex-market.d.ts.map +1 -0
- package/dist/backends/gui/forex-market.js +19 -0
- package/dist/backends/gui/forex-market.js.map +1 -0
- package/dist/backends/gui/forex-screener.cjs +57 -0
- package/dist/backends/gui/forex-screener.d.ts +45 -0
- package/dist/backends/gui/forex-screener.d.ts.map +1 -0
- package/dist/backends/gui/forex-screener.js +55 -0
- package/dist/backends/gui/forex-screener.js.map +1 -0
- package/dist/backends/gui/gantt.cjs +50 -0
- package/dist/backends/gui/gantt.d.ts +19 -0
- package/dist/backends/gui/gantt.d.ts.map +1 -0
- package/dist/backends/gui/gantt.js +49 -0
- package/dist/backends/gui/gantt.js.map +1 -0
- package/dist/backends/gui/index.cjs +108 -1
- package/dist/backends/gui/index.d.ts +41 -0
- package/dist/backends/gui/index.d.ts.map +1 -1
- package/dist/backends/gui/index.js +41 -0
- package/dist/backends/gui/index.js.map +1 -1
- package/dist/canvas.cjs +3 -3
- package/dist/canvas.js +3 -3
- package/dist/canvas.js.map +1 -1
- package/dist/gallery.html +2 -2
- package/dist/grid.cjs +19 -43
- package/dist/grid.d.ts +36 -1
- package/dist/grid.d.ts.map +1 -1
- package/dist/grid.js +19 -43
- package/dist/grid.js.map +1 -1
- package/dist/index.cjs +70 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/index.node.cjs +70 -1
- package/dist/index.node.js +3 -0
- package/dist/product/ChunkGuard.cjs +58 -0
- package/dist/product/ChunkGuard.d.ts +7 -0
- package/dist/product/ChunkGuard.d.ts.map +1 -0
- package/dist/product/ChunkGuard.js +56 -0
- package/dist/product/ChunkGuard.js.map +1 -0
- package/dist/product/DetailPane.cjs +46 -0
- package/dist/product/DetailPane.d.ts +47 -0
- package/dist/product/DetailPane.d.ts.map +1 -0
- package/dist/product/DetailPane.js +43 -0
- package/dist/product/DetailPane.js.map +1 -0
- package/dist/product/Fact.cjs +19 -0
- package/dist/product/Fact.d.ts +23 -0
- package/dist/product/Fact.d.ts.map +1 -0
- package/dist/product/Fact.js +17 -0
- package/dist/product/Fact.js.map +1 -0
- package/dist/product/chunkGuard.logic.cjs +54 -0
- package/dist/product/chunkGuard.logic.d.ts +26 -0
- package/dist/product/chunkGuard.logic.d.ts.map +1 -0
- package/dist/product/chunkGuard.logic.js +49 -0
- package/dist/product/chunkGuard.logic.js.map +1 -0
- package/dist/product/index.cjs +10 -0
- package/dist/product/index.d.ts +3 -0
- package/dist/product/index.d.ts.map +1 -1
- package/dist/product/index.js +10 -0
- package/dist/product/index.js.map +1 -1
- package/package.json +5 -3
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
/**
|
|
4
|
+
* DialogStack — a pile of panels offset diagonally, front one on top.
|
|
5
|
+
*
|
|
6
|
+
* Each dialog is an absolutely positioned card inside a relatively positioned
|
|
7
|
+
* frame; index alone decides both its offset (`translate(index*10, index*10)`)
|
|
8
|
+
* and its stacking (`zIndex: index`), so the last item in `dialogs` reads as the
|
|
9
|
+
* top of the pile. A panel closes through its own corner button, which reports
|
|
10
|
+
* the closed id back through `onClose` — nothing here removes an item from the
|
|
11
|
+
* list, the caller owns that.
|
|
12
|
+
*/
|
|
13
|
+
import { XStack, YStack } from '@hanzo/gui';
|
|
14
|
+
import { X } from '@hanzogui/lucide-icons-2';
|
|
15
|
+
import { Button } from './button.js';
|
|
16
|
+
import { ink } from './ink.js';
|
|
17
|
+
import { slot } from './slot.js';
|
|
18
|
+
import { touch } from './gesture.js';
|
|
19
|
+
const OFFSET = 10;
|
|
20
|
+
const CLOSE = 24;
|
|
21
|
+
export function DialogStack({ dialogs, onClose, children, ...props }) {
|
|
22
|
+
return (_jsxs(YStack, { ...slot('dialog-stack'), position: "relative", ...props, children: [dialogs.map((dialog, index) => (_jsxs(YStack, { ...slot('dialog-stack-item'), "data-index": index, position: "absolute", t: 0, l: 0, r: 0, b: 0, rounded: "$5", borderWidth: 1, borderColor: "$borderColor", bg: "$background", p: "$6", gap: "$4", transform: [{ translateX: index * OFFSET }, { translateY: index * OFFSET }], style: { zIndex: index }, children: [_jsxs(XStack, { items: "center", justify: "space-between", children: [ink(dialog.title, undefined, { fontSize: '$5', fontWeight: '600' }), _jsx(Button, { ...slot('dialog-stack-close'), variant: "ghost", size: "icon", minH: CLOSE, minW: CLOSE, ...touch(CLOSE), "aria-label": "Close", onPress: () => onClose?.(dialog.id), children: _jsx(X, { size: 16 }) })] }), _jsx(YStack, { children: ink(dialog.content) })] }, dialog.id))), children] }));
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=dialog-stack.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dialog-stack.js","sourceRoot":"","sources":["../../../src/backends/gui/dialog-stack.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ;;;;;;;;;GASG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAC3C,OAAO,EAAE,CAAC,EAAE,MAAM,0BAA0B,CAAA;AAE5C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAC3B,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAC7B,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAA;AAEjC,MAAM,MAAM,GAAG,EAAE,CAAA;AACjB,MAAM,KAAK,GAAG,EAAE,CAAA;AAahB,MAAM,UAAU,WAAW,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAoB;IACpF,OAAO,CACL,MAAC,MAAM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AE,CAiCP,CACV,CAAC,EACD,QAAQ,IACF,CACV,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
'use client';"use strict";
|
|
2
|
+
'use client';
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.Dock = Dock;
|
|
5
|
+
exports.DockItem = DockItem;
|
|
6
|
+
exports.DockSeparator = DockSeparator;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
/**
|
|
9
|
+
* Dock — a macOS-style icon shelf. `DockItem`s sit in a row (or a column, on
|
|
10
|
+
* `left`/`right`) and grow as the pointer nears them; `DockSeparator` splits
|
|
11
|
+
* them into clusters, the way Finder and Safari sit apart from Mail and
|
|
12
|
+
* Calendar in the real thing.
|
|
13
|
+
*
|
|
14
|
+
* The size ramp is a plain pointer-distance calculation retargeting a CSS
|
|
15
|
+
* `width`/`height` transition on each item — the same visual read as a spring
|
|
16
|
+
* without pulling in an animation library the workspace does not carry. Each
|
|
17
|
+
* item tracks its own pointer offset, so hovering one does not re-render its
|
|
18
|
+
* neighbours.
|
|
19
|
+
*/
|
|
20
|
+
const gui_1 = require("@hanzo/gui");
|
|
21
|
+
const react_1 = require("react");
|
|
22
|
+
const sx_1 = require("../../sx.cjs");
|
|
23
|
+
const ink_1 = require("./ink.cjs");
|
|
24
|
+
const slot_1 = require("./slot.cjs");
|
|
25
|
+
const gesture_1 = require("./gesture.cjs");
|
|
26
|
+
/** Resting size of an item, in px, before any magnification is applied. */
|
|
27
|
+
const BASE_SIZE = 48;
|
|
28
|
+
const DockConfigContext = /* @__PURE__ */ (0, react_1.createContext)({
|
|
29
|
+
magnification: 60,
|
|
30
|
+
distance: 140,
|
|
31
|
+
position: 'bottom',
|
|
32
|
+
});
|
|
33
|
+
const Frame = (0, gui_1.styled)(gui_1.XStack, {
|
|
34
|
+
name: 'Dock',
|
|
35
|
+
items: 'flex-end',
|
|
36
|
+
gap: '$1.5',
|
|
37
|
+
p: '$2',
|
|
38
|
+
rounded: '$6',
|
|
39
|
+
borderWidth: 1,
|
|
40
|
+
borderColor: '$borderColor',
|
|
41
|
+
bg: '$panel',
|
|
42
|
+
shadowColor: '$dim',
|
|
43
|
+
shadowRadius: 24,
|
|
44
|
+
shadowOpacity: 0.25,
|
|
45
|
+
variants: {
|
|
46
|
+
// Named `edge`, not `position`: gui's own `position` prop is the CSS
|
|
47
|
+
// property (`relative`/`absolute`/…), and a variant sharing that name
|
|
48
|
+
// would fight it instead of picking a layout.
|
|
49
|
+
edge: {
|
|
50
|
+
bottom: { flexDirection: 'row', items: 'flex-end' },
|
|
51
|
+
left: { flexDirection: 'column', items: 'flex-end' },
|
|
52
|
+
right: { flexDirection: 'column', items: 'flex-start' },
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
defaultVariants: { edge: 'bottom' },
|
|
56
|
+
});
|
|
57
|
+
function Dock({ className, position = 'bottom', magnification = 60, distance = 140, children, ...props }) {
|
|
58
|
+
return ((0, jsx_runtime_1.jsx)(DockConfigContext.Provider, { value: { magnification, distance, position }, children: (0, jsx_runtime_1.jsx)(Frame, { ...(0, slot_1.slot)('dock'), "data-position": position, edge: position, ...(0, sx_1.sx)(className), ...props, children: children }) }));
|
|
59
|
+
}
|
|
60
|
+
const ItemFrame = (0, gui_1.styled)(gui_1.XStack, {
|
|
61
|
+
name: 'DockItem',
|
|
62
|
+
items: 'center',
|
|
63
|
+
justify: 'center',
|
|
64
|
+
rounded: '$4',
|
|
65
|
+
bg: '$hover',
|
|
66
|
+
cursor: 'pointer',
|
|
67
|
+
hoverStyle: { bg: '$edge' },
|
|
68
|
+
});
|
|
69
|
+
function DockItem({ className, children, onClick, tooltip, magnification: itemMagnification, distance: itemDistance, ...props }) {
|
|
70
|
+
const { magnification: contextMagnification, distance: contextDistance } = (0, react_1.useContext)(DockConfigContext);
|
|
71
|
+
const magnification = itemMagnification ?? contextMagnification;
|
|
72
|
+
const distance = itemDistance ?? contextDistance;
|
|
73
|
+
const [size, setSize] = (0, react_1.useState)(BASE_SIZE);
|
|
74
|
+
const [hovered, setHovered] = (0, react_1.useState)(false);
|
|
75
|
+
const handleMove = (e) => {
|
|
76
|
+
const rect = e.currentTarget.getBoundingClientRect();
|
|
77
|
+
if (distance <= 0)
|
|
78
|
+
return;
|
|
79
|
+
const centerX = rect.left + rect.width / 2;
|
|
80
|
+
const offset = Math.min(Math.abs(e.clientX - centerX), distance);
|
|
81
|
+
setSize(BASE_SIZE + magnification * (1 - offset / distance));
|
|
82
|
+
};
|
|
83
|
+
const handleLeave = () => {
|
|
84
|
+
setSize(BASE_SIZE);
|
|
85
|
+
setHovered(false);
|
|
86
|
+
};
|
|
87
|
+
return ((0, jsx_runtime_1.jsxs)(gui_1.YStack, { ...(0, slot_1.slot)('dock-item-wrap'), position: "relative", items: "center", children: [tooltip && hovered ? ((0, jsx_runtime_1.jsx)(gui_1.XStack, { ...(0, slot_1.slot)('dock-tooltip'), position: "absolute", b: "100%", mb: "$2", self: "center", px: "$2", py: "$1", rounded: "$3", bg: "$ink", style: { whiteSpace: 'nowrap' }, children: (0, jsx_runtime_1.jsx)(gui_1.SizableText, { size: "$1", color: "$sunken", children: tooltip }) })) : null, (0, jsx_runtime_1.jsx)(ItemFrame, { ...(0, slot_1.slot)('dock-item'), render: "button", onClick: onClick, onPointerEnter: () => setHovered(true), onPointerMove: handleMove, onPointerLeave: handleLeave, ...(tooltip ? (0, slot_1.tip)(tooltip) : null), ...(0, gesture_1.touch)(BASE_SIZE, 44), style: { width: size, height: size, transition: 'width 150ms ease-out, height 150ms ease-out' }, ...(0, sx_1.sx)(className), ...props, children: (0, ink_1.ink)(children) })] }));
|
|
88
|
+
}
|
|
89
|
+
const SeparatorFrame = (0, gui_1.styled)(gui_1.YStack, {
|
|
90
|
+
name: 'DockSeparator',
|
|
91
|
+
self: 'center',
|
|
92
|
+
bg: '$borderColor',
|
|
93
|
+
});
|
|
94
|
+
/** A hairline divider that groups items into clusters, e.g. Finder | Mail. */
|
|
95
|
+
function DockSeparator(props) {
|
|
96
|
+
const { position } = (0, react_1.useContext)(DockConfigContext);
|
|
97
|
+
const vertical = position !== 'bottom';
|
|
98
|
+
return ((0, jsx_runtime_1.jsx)(SeparatorFrame, { ...(0, slot_1.slot)('dock-separator'), width: vertical ? 40 : 1, height: vertical ? 1 : 40, mx: vertical ? 0 : '$1', my: vertical ? '$1' : 0, ...props }));
|
|
99
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type ComponentProps, type ReactNode } from 'react';
|
|
2
|
+
export type DockPosition = 'bottom' | 'left' | 'right';
|
|
3
|
+
declare const Frame: import("@hanzogui/web").GuiComponent<import("@hanzogui/web").TamaDefer, import("@hanzogui/web").GuiElement, import("@hanzogui/core").RNGuiViewNonStyleProps, import("@hanzogui/web").StackStyleBase, {
|
|
4
|
+
edge?: "bottom" | "left" | "right" | undefined;
|
|
5
|
+
elevation?: number | import("@hanzogui/web").SizeTokens | undefined;
|
|
6
|
+
fullscreen?: boolean | undefined;
|
|
7
|
+
}, import("@hanzogui/web").StaticConfigPublic>;
|
|
8
|
+
export type DockProps = Omit<ComponentProps<typeof Frame>, 'edge' | 'position' | 'className'> & {
|
|
9
|
+
className?: string;
|
|
10
|
+
position?: DockPosition;
|
|
11
|
+
/** How far, in px, a hovered item grows beyond `BASE_SIZE`. */
|
|
12
|
+
magnification?: number;
|
|
13
|
+
/** How far, in px either side of an item's centre, the growth reaches. */
|
|
14
|
+
distance?: number;
|
|
15
|
+
children?: ReactNode;
|
|
16
|
+
};
|
|
17
|
+
declare function Dock({ className, position, magnification, distance, children, ...props }: DockProps): import("react").JSX.Element;
|
|
18
|
+
declare const ItemFrame: import("@hanzogui/web").GuiComponent<import("@hanzogui/web").TamaDefer, import("@hanzogui/web").GuiElement, import("@hanzogui/core").RNGuiViewNonStyleProps, import("@hanzogui/web").StackStyleBase, {
|
|
19
|
+
elevation?: number | import("@hanzogui/web").SizeTokens | undefined;
|
|
20
|
+
fullscreen?: boolean | undefined;
|
|
21
|
+
}, import("@hanzogui/web").StaticConfigPublic>;
|
|
22
|
+
export type DockItemProps = Omit<ComponentProps<typeof ItemFrame>, 'className' | 'onClick'> & {
|
|
23
|
+
className?: string;
|
|
24
|
+
children?: ReactNode;
|
|
25
|
+
onClick?: () => void;
|
|
26
|
+
tooltip?: string;
|
|
27
|
+
/** Overrides the Dock's `magnification` for this one item. */
|
|
28
|
+
magnification?: number;
|
|
29
|
+
/** Overrides the Dock's `distance` for this one item. */
|
|
30
|
+
distance?: number;
|
|
31
|
+
};
|
|
32
|
+
declare function DockItem({ className, children, onClick, tooltip, magnification: itemMagnification, distance: itemDistance, ...props }: DockItemProps): import("react").JSX.Element;
|
|
33
|
+
declare const SeparatorFrame: import("@hanzogui/web").GuiComponent<import("@hanzogui/web").TamaDefer, import("@hanzogui/web").GuiElement, import("@hanzogui/core").RNGuiViewNonStyleProps, import("@hanzogui/web").StackStyleBase, {
|
|
34
|
+
elevation?: number | import("@hanzogui/web").SizeTokens | undefined;
|
|
35
|
+
fullscreen?: boolean | undefined;
|
|
36
|
+
}, import("@hanzogui/web").StaticConfigPublic>;
|
|
37
|
+
export type DockSeparatorProps = ComponentProps<typeof SeparatorFrame>;
|
|
38
|
+
/** A hairline divider that groups items into clusters, e.g. Finder | Mail. */
|
|
39
|
+
declare function DockSeparator(props: DockSeparatorProps): import("react").JSX.Element;
|
|
40
|
+
export { Dock, DockItem, DockSeparator };
|
|
41
|
+
//# sourceMappingURL=dock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dock.d.ts","sourceRoot":"","sources":["../../../src/backends/gui/dock.tsx"],"names":[],"mappings":"AAeA,OAAO,EAIL,KAAK,cAAc,EAEnB,KAAK,SAAS,EACf,MAAM,OAAO,CAAA;AAMd,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAA;AAatD,QAAA,MAAM,KAAK;;;;8CAyBT,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+BAa/C;AAED,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,aAAa,EAAE,CAAA"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
/**
|
|
4
|
+
* Dock — a macOS-style icon shelf. `DockItem`s sit in a row (or a column, on
|
|
5
|
+
* `left`/`right`) and grow as the pointer nears them; `DockSeparator` splits
|
|
6
|
+
* them into clusters, the way Finder and Safari sit apart from Mail and
|
|
7
|
+
* Calendar in the real thing.
|
|
8
|
+
*
|
|
9
|
+
* The size ramp is a plain pointer-distance calculation retargeting a CSS
|
|
10
|
+
* `width`/`height` transition on each item — the same visual read as a spring
|
|
11
|
+
* without pulling in an animation library the workspace does not carry. Each
|
|
12
|
+
* item tracks its own pointer offset, so hovering one does not re-render its
|
|
13
|
+
* neighbours.
|
|
14
|
+
*/
|
|
15
|
+
import { SizableText, XStack, YStack, styled } from '@hanzo/gui';
|
|
16
|
+
import { createContext, useContext, useState, } from 'react';
|
|
17
|
+
import { sx } from '../../sx.js';
|
|
18
|
+
import { ink } from './ink.js';
|
|
19
|
+
import { slot, tip } from './slot.js';
|
|
20
|
+
import { touch } from './gesture.js';
|
|
21
|
+
/** Resting size of an item, in px, before any magnification is applied. */
|
|
22
|
+
const BASE_SIZE = 48;
|
|
23
|
+
const DockConfigContext = /* @__PURE__ */ createContext({
|
|
24
|
+
magnification: 60,
|
|
25
|
+
distance: 140,
|
|
26
|
+
position: 'bottom',
|
|
27
|
+
});
|
|
28
|
+
const Frame = styled(XStack, {
|
|
29
|
+
name: 'Dock',
|
|
30
|
+
items: 'flex-end',
|
|
31
|
+
gap: '$1.5',
|
|
32
|
+
p: '$2',
|
|
33
|
+
rounded: '$6',
|
|
34
|
+
borderWidth: 1,
|
|
35
|
+
borderColor: '$borderColor',
|
|
36
|
+
bg: '$panel',
|
|
37
|
+
shadowColor: '$dim',
|
|
38
|
+
shadowRadius: 24,
|
|
39
|
+
shadowOpacity: 0.25,
|
|
40
|
+
variants: {
|
|
41
|
+
// Named `edge`, not `position`: gui's own `position` prop is the CSS
|
|
42
|
+
// property (`relative`/`absolute`/…), and a variant sharing that name
|
|
43
|
+
// would fight it instead of picking a layout.
|
|
44
|
+
edge: {
|
|
45
|
+
bottom: { flexDirection: 'row', items: 'flex-end' },
|
|
46
|
+
left: { flexDirection: 'column', items: 'flex-end' },
|
|
47
|
+
right: { flexDirection: 'column', items: 'flex-start' },
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
defaultVariants: { edge: 'bottom' },
|
|
51
|
+
});
|
|
52
|
+
function Dock({ className, position = 'bottom', magnification = 60, distance = 140, children, ...props }) {
|
|
53
|
+
return (_jsx(DockConfigContext.Provider, { value: { magnification, distance, position }, children: _jsx(Frame, { ...slot('dock'), "data-position": position, edge: position, ...sx(className), ...props, children: children }) }));
|
|
54
|
+
}
|
|
55
|
+
const ItemFrame = styled(XStack, {
|
|
56
|
+
name: 'DockItem',
|
|
57
|
+
items: 'center',
|
|
58
|
+
justify: 'center',
|
|
59
|
+
rounded: '$4',
|
|
60
|
+
bg: '$hover',
|
|
61
|
+
cursor: 'pointer',
|
|
62
|
+
hoverStyle: { bg: '$edge' },
|
|
63
|
+
});
|
|
64
|
+
function DockItem({ className, children, onClick, tooltip, magnification: itemMagnification, distance: itemDistance, ...props }) {
|
|
65
|
+
const { magnification: contextMagnification, distance: contextDistance } = useContext(DockConfigContext);
|
|
66
|
+
const magnification = itemMagnification ?? contextMagnification;
|
|
67
|
+
const distance = itemDistance ?? contextDistance;
|
|
68
|
+
const [size, setSize] = useState(BASE_SIZE);
|
|
69
|
+
const [hovered, setHovered] = useState(false);
|
|
70
|
+
const handleMove = (e) => {
|
|
71
|
+
const rect = e.currentTarget.getBoundingClientRect();
|
|
72
|
+
if (distance <= 0)
|
|
73
|
+
return;
|
|
74
|
+
const centerX = rect.left + rect.width / 2;
|
|
75
|
+
const offset = Math.min(Math.abs(e.clientX - centerX), distance);
|
|
76
|
+
setSize(BASE_SIZE + magnification * (1 - offset / distance));
|
|
77
|
+
};
|
|
78
|
+
const handleLeave = () => {
|
|
79
|
+
setSize(BASE_SIZE);
|
|
80
|
+
setHovered(false);
|
|
81
|
+
};
|
|
82
|
+
return (_jsxs(YStack, { ...slot('dock-item-wrap'), position: "relative", items: "center", children: [tooltip && hovered ? (_jsx(XStack, { ...slot('dock-tooltip'), position: "absolute", b: "100%", mb: "$2", self: "center", px: "$2", py: "$1", rounded: "$3", bg: "$ink", style: { whiteSpace: 'nowrap' }, children: _jsx(SizableText, { size: "$1", color: "$sunken", children: tooltip }) })) : null, _jsx(ItemFrame, { ...slot('dock-item'), render: "button", onClick: onClick, onPointerEnter: () => setHovered(true), onPointerMove: handleMove, onPointerLeave: handleLeave, ...(tooltip ? tip(tooltip) : null), ...touch(BASE_SIZE, 44), style: { width: size, height: size, transition: 'width 150ms ease-out, height 150ms ease-out' }, ...sx(className), ...props, children: ink(children) })] }));
|
|
83
|
+
}
|
|
84
|
+
const SeparatorFrame = styled(YStack, {
|
|
85
|
+
name: 'DockSeparator',
|
|
86
|
+
self: 'center',
|
|
87
|
+
bg: '$borderColor',
|
|
88
|
+
});
|
|
89
|
+
/** A hairline divider that groups items into clusters, e.g. Finder | Mail. */
|
|
90
|
+
function DockSeparator(props) {
|
|
91
|
+
const { position } = useContext(DockConfigContext);
|
|
92
|
+
const vertical = position !== 'bottom';
|
|
93
|
+
return (_jsx(SeparatorFrame, { ...slot('dock-separator'), width: vertical ? 40 : 1, height: vertical ? 1 : 40, mx: vertical ? 0 : '$1', my: vertical ? '$1' : 0, ...props }));
|
|
94
|
+
}
|
|
95
|
+
export { Dock, DockItem, DockSeparator };
|
|
96
|
+
//# sourceMappingURL=dock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dock.js","sourceRoot":"","sources":["../../../src/backends/gui/dock.tsx"],"names":[],"mappings":"AAAA,YAAY,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AAI,EAAE,QAAQ,EAAE,aAAa,EAAE,CAAA"}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
'use client';"use strict";
|
|
2
|
+
'use client';
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.Dropzone = Dropzone;
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
+
/**
|
|
8
|
+
* Dropzone — a region that accepts files by drag-and-drop or by a click that
|
|
9
|
+
* opens the browser's file picker, and lists what it is holding underneath.
|
|
10
|
+
*
|
|
11
|
+
* File drag-and-drop is a DOM concept (`DataTransfer`, `<input type="file">`),
|
|
12
|
+
* so the frame reads `isWeb` from `@hanzo/gui` and no-ops the drag handlers
|
|
13
|
+
* off the web: the click-to-browse input still renders everywhere, only the
|
|
14
|
+
* drag affordance is web-only. State is a plain `useState` list of `File`,
|
|
15
|
+
* accepted or rejected against `accept`/`maxFiles`/`maxSize`.
|
|
16
|
+
*/
|
|
17
|
+
const gui_1 = require("@hanzo/gui");
|
|
18
|
+
const lucide_icons_2_1 = require("@hanzogui/lucide-icons-2");
|
|
19
|
+
const react_2 = require("react");
|
|
20
|
+
const ink_1 = require("./ink.cjs");
|
|
21
|
+
const slot_1 = require("./slot.cjs");
|
|
22
|
+
const sx_1 = require("../../sx.cjs");
|
|
23
|
+
const gesture_1 = require("./gesture.cjs");
|
|
24
|
+
/** Enter/Space activate a `role="button"` frame the way a native button would. */
|
|
25
|
+
const asButton = (onActivate) => ({
|
|
26
|
+
role: 'button',
|
|
27
|
+
tabIndex: 0,
|
|
28
|
+
onPress: onActivate,
|
|
29
|
+
onKeyDown: (event) => {
|
|
30
|
+
if (event.key !== 'Enter' && event.key !== ' ')
|
|
31
|
+
return;
|
|
32
|
+
event.preventDefault();
|
|
33
|
+
onActivate();
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
const REMOVE_SIZE = 24;
|
|
37
|
+
const Frame = (0, gui_1.styled)(gui_1.YStack, {
|
|
38
|
+
name: 'Dropzone',
|
|
39
|
+
cursor: 'pointer',
|
|
40
|
+
items: 'center',
|
|
41
|
+
justify: 'center',
|
|
42
|
+
gap: '$2',
|
|
43
|
+
rounded: '$4',
|
|
44
|
+
borderWidth: 2,
|
|
45
|
+
borderStyle: 'dashed',
|
|
46
|
+
borderColor: '$borderColor',
|
|
47
|
+
p: '$8',
|
|
48
|
+
variants: {
|
|
49
|
+
active: {
|
|
50
|
+
true: { borderColor: '$ink', bg: '$hover' },
|
|
51
|
+
},
|
|
52
|
+
disabled: {
|
|
53
|
+
true: { cursor: 'default', opacity: 0.5 },
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
hoverStyle: { borderColor: '$rim' },
|
|
57
|
+
defaultVariants: { active: false, disabled: false },
|
|
58
|
+
});
|
|
59
|
+
/** `{"image/*": [".png"]}` → an `accept` attribute value the file input reads. */
|
|
60
|
+
const acceptAttr = (accept) => Object.entries(accept)
|
|
61
|
+
.flatMap(([mime, extensions]) => [mime, ...extensions])
|
|
62
|
+
.join(',');
|
|
63
|
+
/** A file matches `accept` on its MIME type, a MIME wildcard, or its extension. */
|
|
64
|
+
const matches = (file, accept) => Object.entries(accept).some(([mime, extensions]) => {
|
|
65
|
+
if (mime.endsWith('/*') && file.type.startsWith(mime.slice(0, -1)))
|
|
66
|
+
return true;
|
|
67
|
+
if (mime === file.type)
|
|
68
|
+
return true;
|
|
69
|
+
return extensions.some((ext) => file.name.toLowerCase().endsWith(ext.toLowerCase()));
|
|
70
|
+
});
|
|
71
|
+
const sortFiles = (incoming, accept, maxSize) => {
|
|
72
|
+
const accepted = [];
|
|
73
|
+
const rejected = [];
|
|
74
|
+
for (const file of incoming) {
|
|
75
|
+
const sized = file.size <= maxSize;
|
|
76
|
+
const typed = !accept || Object.keys(accept).length === 0 || matches(file, accept);
|
|
77
|
+
(sized && typed ? accepted : rejected).push(file);
|
|
78
|
+
}
|
|
79
|
+
return { accepted, rejected };
|
|
80
|
+
};
|
|
81
|
+
const formatSize = (bytes) => `${(bytes / 1024).toFixed(1)} KB`;
|
|
82
|
+
function Dropzone({ className, onFilesAccepted, onFilesRejected, maxFiles = 5, maxSize = 5242880, accept = {
|
|
83
|
+
'image/*': ['.png', '.jpg', '.jpeg', '.gif', '.webp'],
|
|
84
|
+
'application/pdf': ['.pdf'],
|
|
85
|
+
}, disabled = false, ...props }) {
|
|
86
|
+
const [files, setFiles] = (0, react_2.useState)([]);
|
|
87
|
+
const [active, setActive] = (0, react_2.useState)(false);
|
|
88
|
+
const inputRef = (0, react_2.useRef)(null);
|
|
89
|
+
const inputId = (0, react_2.useId)();
|
|
90
|
+
const take = (incoming) => {
|
|
91
|
+
if (disabled || incoming.length === 0)
|
|
92
|
+
return;
|
|
93
|
+
const { accepted, rejected } = sortFiles(incoming, accept, maxSize);
|
|
94
|
+
if (accepted.length > 0) {
|
|
95
|
+
setFiles((prev) => [...prev, ...accepted].slice(0, maxFiles));
|
|
96
|
+
onFilesAccepted?.(accepted);
|
|
97
|
+
}
|
|
98
|
+
if (rejected.length > 0)
|
|
99
|
+
onFilesRejected?.(rejected);
|
|
100
|
+
};
|
|
101
|
+
const removeFile = (index) => setFiles((prev) => prev.filter((_, i) => i !== index));
|
|
102
|
+
const onDrop = (event) => {
|
|
103
|
+
event.preventDefault();
|
|
104
|
+
setActive(false);
|
|
105
|
+
if (disabled)
|
|
106
|
+
return;
|
|
107
|
+
take([...event.dataTransfer.files]);
|
|
108
|
+
};
|
|
109
|
+
return ((0, jsx_runtime_1.jsxs)(gui_1.YStack, { ...(0, slot_1.slot)('dropzone'), width: "100%", ...(0, sx_1.sx)(className), ...props, children: [(0, jsx_runtime_1.jsxs)(Frame, { ...(0, slot_1.slot)('dropzone-region'), "data-state": active ? 'active' : 'idle', "data-disabled": disabled || undefined, active: active, disabled: disabled, "aria-disabled": disabled, ...asButton(() => !disabled && inputRef.current?.click()), ...(gui_1.isWeb
|
|
110
|
+
? {
|
|
111
|
+
onDragEnter: (event) => {
|
|
112
|
+
event.preventDefault();
|
|
113
|
+
if (!disabled)
|
|
114
|
+
setActive(true);
|
|
115
|
+
},
|
|
116
|
+
onDragOver: (event) => {
|
|
117
|
+
event.preventDefault();
|
|
118
|
+
},
|
|
119
|
+
onDragLeave: (event) => {
|
|
120
|
+
event.preventDefault();
|
|
121
|
+
setActive(false);
|
|
122
|
+
},
|
|
123
|
+
onDrop,
|
|
124
|
+
}
|
|
125
|
+
: null), children: [(0, jsx_runtime_1.jsx)("input", { ...(0, slot_1.slot)('dropzone-input'), ref: inputRef, id: inputId, type: "file", multiple: maxFiles > 1, accept: acceptAttr(accept), disabled: disabled, style: { display: 'none' }, onChange: (event) => {
|
|
126
|
+
take([...(event.target.files ?? [])]);
|
|
127
|
+
event.target.value = '';
|
|
128
|
+
} }), (0, jsx_runtime_1.jsx)(lucide_icons_2_1.Upload, { size: 32, color: "$quiet" }), (0, jsx_runtime_1.jsxs)(gui_1.YStack, { gap: "$1", items: "center", children: [(0, ink_1.ink)(active ? 'Drop files here' : 'Drag & drop files here', gui_1.SizableText, {
|
|
129
|
+
fontWeight: '500',
|
|
130
|
+
}), (0, ink_1.ink)(`or click to browse (max ${maxFiles} files, ${Math.round(maxSize / 1024 / 1024)}MB each)`, gui_1.SizableText, { fontSize: '$1', color: '$quiet' })] })] }), files.length > 0 && ((0, jsx_runtime_1.jsx)(gui_1.YStack, { ...(0, slot_1.slot)('dropzone-list'), gap: "$2", mt: "$4", children: files.map((file, index) => ((0, react_1.createElement)(gui_1.XStack, { ...(0, slot_1.slot)('dropzone-item'), key: `${file.name}-${file.lastModified}-${index}`, items: "center", gap: "$2", rounded: "$3", borderWidth: 1, borderColor: "$borderColor", p: "$2" },
|
|
131
|
+
(0, jsx_runtime_1.jsx)(lucide_icons_2_1.File, { size: 16, color: "$quiet" }),
|
|
132
|
+
(0, ink_1.ink)(file.name, gui_1.SizableText, {
|
|
133
|
+
flex: 1,
|
|
134
|
+
fontSize: '$2',
|
|
135
|
+
numberOfLines: 1,
|
|
136
|
+
overflow: 'hidden',
|
|
137
|
+
textOverflow: 'ellipsis',
|
|
138
|
+
whiteSpace: 'nowrap',
|
|
139
|
+
}),
|
|
140
|
+
(0, ink_1.ink)(formatSize(file.size), gui_1.SizableText, { fontSize: '$1', color: '$quiet' }),
|
|
141
|
+
(0, jsx_runtime_1.jsx)(gui_1.XStack, { ...(0, slot_1.slot)('dropzone-item-remove'), "aria-label": `Remove ${file.name}`, items: "center", justify: "center", rounded: "$2", p: "$1", cursor: "pointer", hoverStyle: { bg: '$hover' }, ...asButton(() => removeFile(index)), ...(0, gesture_1.touch)(REMOVE_SIZE, 44, 'both'), children: (0, jsx_runtime_1.jsx)(lucide_icons_2_1.X, { size: 16 }) })))) }))] }));
|
|
142
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type DropzoneAccept = Record<string, string[]>;
|
|
2
|
+
export type DropzoneProps = {
|
|
3
|
+
className?: string;
|
|
4
|
+
onFilesAccepted?: (files: File[]) => void;
|
|
5
|
+
onFilesRejected?: (files: File[]) => void;
|
|
6
|
+
maxFiles?: number;
|
|
7
|
+
maxSize?: number;
|
|
8
|
+
accept?: DropzoneAccept;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
};
|
|
11
|
+
export declare function Dropzone({ className, onFilesAccepted, onFilesRejected, maxFiles, maxSize, accept, disabled, ...props }: DropzoneProps): import("react").JSX.Element;
|
|
12
|
+
//# sourceMappingURL=dropzone.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dropzone.d.ts","sourceRoot":"","sources":["../../../src/backends/gui/dropzone.tsx"],"names":[],"mappings":"AAgCA,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;AAErD,MAAM,MAAM,aAAa,GAAG;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,IAAI,CAAA;IACzC,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,IAAI,CAAA;IACzC,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,MAAM,CAAC,EAAE,cAAc,CAAA;IACvB,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAA;AA6DD,wBAAgB,QAAQ,CAAC,EACvB,SAAS,EACT,eAAe,EACf,eAAe,EACf,QAAY,EACZ,OAAiB,EACjB,MAGC,EACD,QAAgB,EAChB,GAAG,KAAK,EACT,EAAE,aAAa,+BA0Hf"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { createElement as _createElement } from "react";
|
|
3
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
|
+
/**
|
|
5
|
+
* Dropzone — a region that accepts files by drag-and-drop or by a click that
|
|
6
|
+
* opens the browser's file picker, and lists what it is holding underneath.
|
|
7
|
+
*
|
|
8
|
+
* File drag-and-drop is a DOM concept (`DataTransfer`, `<input type="file">`),
|
|
9
|
+
* so the frame reads `isWeb` from `@hanzo/gui` and no-ops the drag handlers
|
|
10
|
+
* off the web: the click-to-browse input still renders everywhere, only the
|
|
11
|
+
* drag affordance is web-only. State is a plain `useState` list of `File`,
|
|
12
|
+
* accepted or rejected against `accept`/`maxFiles`/`maxSize`.
|
|
13
|
+
*/
|
|
14
|
+
import { SizableText, XStack, YStack, isWeb, styled } from '@hanzo/gui';
|
|
15
|
+
import { File as FileIcon, Upload, X } from '@hanzogui/lucide-icons-2';
|
|
16
|
+
import { useId, useRef, useState } from 'react';
|
|
17
|
+
import { ink } from './ink.js';
|
|
18
|
+
import { slot } from './slot.js';
|
|
19
|
+
import { sx } from '../../sx.js';
|
|
20
|
+
import { touch } from './gesture.js';
|
|
21
|
+
/** Enter/Space activate a `role="button"` frame the way a native button would. */
|
|
22
|
+
const asButton = (onActivate) => ({
|
|
23
|
+
role: 'button',
|
|
24
|
+
tabIndex: 0,
|
|
25
|
+
onPress: onActivate,
|
|
26
|
+
onKeyDown: (event) => {
|
|
27
|
+
if (event.key !== 'Enter' && event.key !== ' ')
|
|
28
|
+
return;
|
|
29
|
+
event.preventDefault();
|
|
30
|
+
onActivate();
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
const REMOVE_SIZE = 24;
|
|
34
|
+
const Frame = styled(YStack, {
|
|
35
|
+
name: 'Dropzone',
|
|
36
|
+
cursor: 'pointer',
|
|
37
|
+
items: 'center',
|
|
38
|
+
justify: 'center',
|
|
39
|
+
gap: '$2',
|
|
40
|
+
rounded: '$4',
|
|
41
|
+
borderWidth: 2,
|
|
42
|
+
borderStyle: 'dashed',
|
|
43
|
+
borderColor: '$borderColor',
|
|
44
|
+
p: '$8',
|
|
45
|
+
variants: {
|
|
46
|
+
active: {
|
|
47
|
+
true: { borderColor: '$ink', bg: '$hover' },
|
|
48
|
+
},
|
|
49
|
+
disabled: {
|
|
50
|
+
true: { cursor: 'default', opacity: 0.5 },
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
hoverStyle: { borderColor: '$rim' },
|
|
54
|
+
defaultVariants: { active: false, disabled: false },
|
|
55
|
+
});
|
|
56
|
+
/** `{"image/*": [".png"]}` → an `accept` attribute value the file input reads. */
|
|
57
|
+
const acceptAttr = (accept) => Object.entries(accept)
|
|
58
|
+
.flatMap(([mime, extensions]) => [mime, ...extensions])
|
|
59
|
+
.join(',');
|
|
60
|
+
/** A file matches `accept` on its MIME type, a MIME wildcard, or its extension. */
|
|
61
|
+
const matches = (file, accept) => Object.entries(accept).some(([mime, extensions]) => {
|
|
62
|
+
if (mime.endsWith('/*') && file.type.startsWith(mime.slice(0, -1)))
|
|
63
|
+
return true;
|
|
64
|
+
if (mime === file.type)
|
|
65
|
+
return true;
|
|
66
|
+
return extensions.some((ext) => file.name.toLowerCase().endsWith(ext.toLowerCase()));
|
|
67
|
+
});
|
|
68
|
+
const sortFiles = (incoming, accept, maxSize) => {
|
|
69
|
+
const accepted = [];
|
|
70
|
+
const rejected = [];
|
|
71
|
+
for (const file of incoming) {
|
|
72
|
+
const sized = file.size <= maxSize;
|
|
73
|
+
const typed = !accept || Object.keys(accept).length === 0 || matches(file, accept);
|
|
74
|
+
(sized && typed ? accepted : rejected).push(file);
|
|
75
|
+
}
|
|
76
|
+
return { accepted, rejected };
|
|
77
|
+
};
|
|
78
|
+
const formatSize = (bytes) => `${(bytes / 1024).toFixed(1)} KB`;
|
|
79
|
+
export function Dropzone({ className, onFilesAccepted, onFilesRejected, maxFiles = 5, maxSize = 5242880, accept = {
|
|
80
|
+
'image/*': ['.png', '.jpg', '.jpeg', '.gif', '.webp'],
|
|
81
|
+
'application/pdf': ['.pdf'],
|
|
82
|
+
}, disabled = false, ...props }) {
|
|
83
|
+
const [files, setFiles] = useState([]);
|
|
84
|
+
const [active, setActive] = useState(false);
|
|
85
|
+
const inputRef = useRef(null);
|
|
86
|
+
const inputId = useId();
|
|
87
|
+
const take = (incoming) => {
|
|
88
|
+
if (disabled || incoming.length === 0)
|
|
89
|
+
return;
|
|
90
|
+
const { accepted, rejected } = sortFiles(incoming, accept, maxSize);
|
|
91
|
+
if (accepted.length > 0) {
|
|
92
|
+
setFiles((prev) => [...prev, ...accepted].slice(0, maxFiles));
|
|
93
|
+
onFilesAccepted?.(accepted);
|
|
94
|
+
}
|
|
95
|
+
if (rejected.length > 0)
|
|
96
|
+
onFilesRejected?.(rejected);
|
|
97
|
+
};
|
|
98
|
+
const removeFile = (index) => setFiles((prev) => prev.filter((_, i) => i !== index));
|
|
99
|
+
const onDrop = (event) => {
|
|
100
|
+
event.preventDefault();
|
|
101
|
+
setActive(false);
|
|
102
|
+
if (disabled)
|
|
103
|
+
return;
|
|
104
|
+
take([...event.dataTransfer.files]);
|
|
105
|
+
};
|
|
106
|
+
return (_jsxs(YStack, { ...slot('dropzone'), width: "100%", ...sx(className), ...props, children: [_jsxs(Frame, { ...slot('dropzone-region'), "data-state": active ? 'active' : 'idle', "data-disabled": disabled || undefined, active: active, disabled: disabled, "aria-disabled": disabled, ...asButton(() => !disabled && inputRef.current?.click()), ...(isWeb
|
|
107
|
+
? {
|
|
108
|
+
onDragEnter: (event) => {
|
|
109
|
+
event.preventDefault();
|
|
110
|
+
if (!disabled)
|
|
111
|
+
setActive(true);
|
|
112
|
+
},
|
|
113
|
+
onDragOver: (event) => {
|
|
114
|
+
event.preventDefault();
|
|
115
|
+
},
|
|
116
|
+
onDragLeave: (event) => {
|
|
117
|
+
event.preventDefault();
|
|
118
|
+
setActive(false);
|
|
119
|
+
},
|
|
120
|
+
onDrop,
|
|
121
|
+
}
|
|
122
|
+
: null), children: [_jsx("input", { ...slot('dropzone-input'), ref: inputRef, id: inputId, type: "file", multiple: maxFiles > 1, accept: acceptAttr(accept), disabled: disabled, style: { display: 'none' }, onChange: (event) => {
|
|
123
|
+
take([...(event.target.files ?? [])]);
|
|
124
|
+
event.target.value = '';
|
|
125
|
+
} }), _jsx(Upload, { size: 32, color: "$quiet" }), _jsxs(YStack, { gap: "$1", items: "center", children: [ink(active ? 'Drop files here' : 'Drag & drop files here', SizableText, {
|
|
126
|
+
fontWeight: '500',
|
|
127
|
+
}), ink(`or click to browse (max ${maxFiles} files, ${Math.round(maxSize / 1024 / 1024)}MB each)`, SizableText, { fontSize: '$1', color: '$quiet' })] })] }), files.length > 0 && (_jsx(YStack, { ...slot('dropzone-list'), gap: "$2", mt: "$4", children: files.map((file, index) => (_createElement(XStack, { ...slot('dropzone-item'), key: `${file.name}-${file.lastModified}-${index}`, items: "center", gap: "$2", rounded: "$3", borderWidth: 1, borderColor: "$borderColor", p: "$2" },
|
|
128
|
+
_jsx(FileIcon, { size: 16, color: "$quiet" }),
|
|
129
|
+
ink(file.name, SizableText, {
|
|
130
|
+
flex: 1,
|
|
131
|
+
fontSize: '$2',
|
|
132
|
+
numberOfLines: 1,
|
|
133
|
+
overflow: 'hidden',
|
|
134
|
+
textOverflow: 'ellipsis',
|
|
135
|
+
whiteSpace: 'nowrap',
|
|
136
|
+
}),
|
|
137
|
+
ink(formatSize(file.size), SizableText, { fontSize: '$1', color: '$quiet' }),
|
|
138
|
+
_jsx(XStack, { ...slot('dropzone-item-remove'), "aria-label": `Remove ${file.name}`, items: "center", justify: "center", rounded: "$2", p: "$1", cursor: "pointer", hoverStyle: { bg: '$hover' }, ...asButton(() => removeFile(index)), ...touch(REMOVE_SIZE, 44, 'both'), children: _jsx(X, { size: 16 }) })))) }))] }));
|
|
139
|
+
}
|
|
140
|
+
//# sourceMappingURL=dropzone.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dropzone.js","sourceRoot":"","sources":["../../../src/backends/gui/dropzone.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;;AAEZ;;;;;;;;;GASG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AACvE,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,0BAA0B,CAAA;AACtE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAwD,MAAM,OAAO,CAAA;AACrG,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAC3B,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAC7B,OAAO,EAAE,EAAE,EAAE,MAAM,UAAU,CAAA;AAC7B,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAA;AAEjC,kFAAkF;AAClF,MAAM,QAAQ,GAAG,CAAC,UAAsB,EAAE,EAAE,CAAC,CAAC;IAC5C,IAAI,EAAE,QAAiB;IACvB,QAAQ,EAAE,CAAC;IACX,OAAO,EAAE,UAAU;IACnB,SAAS,EAAE,CAAC,KAAoB,EAAE,EAAE;QAClC,IAAI,K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