@hanzo/ui 8.27.10 → 8.27.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/backends/gui/comparison.cjs +17 -21
- package/dist/backends/gui/comparison.d.ts +4 -5
- package/dist/backends/gui/comparison.d.ts.map +1 -1
- package/dist/backends/gui/comparison.js +18 -22
- package/dist/backends/gui/comparison.js.map +1 -1
- package/dist/backends/gui/crypto-screener.cjs +21 -31
- package/dist/backends/gui/crypto-screener.d.ts +20 -24
- package/dist/backends/gui/crypto-screener.d.ts.map +1 -1
- package/dist/backends/gui/crypto-screener.js +21 -31
- package/dist/backends/gui/crypto-screener.js.map +1 -1
- package/dist/backends/gui/cursor.cjs +15 -18
- package/dist/backends/gui/cursor.d.ts +4 -3
- package/dist/backends/gui/cursor.d.ts.map +1 -1
- package/dist/backends/gui/cursor.js +15 -18
- package/dist/backends/gui/cursor.js.map +1 -1
- package/dist/backends/gui/data-table.cjs +144 -184
- package/dist/backends/gui/data-table.d.ts +64 -44
- package/dist/backends/gui/data-table.d.ts.map +1 -1
- package/dist/backends/gui/data-table.js +146 -152
- package/dist/backends/gui/data-table.js.map +1 -1
- package/dist/backends/gui/dock.cjs +1 -1
- package/dist/backends/gui/dock.d.ts.map +1 -1
- package/dist/backends/gui/dock.js +1 -1
- package/dist/backends/gui/dock.js.map +1 -1
- package/dist/backends/gui/editor.cjs +35 -31
- package/dist/backends/gui/editor.d.ts +11 -11
- package/dist/backends/gui/editor.d.ts.map +1 -1
- package/dist/backends/gui/editor.js +35 -31
- package/dist/backends/gui/editor.js.map +1 -1
- package/dist/backends/gui/field.cjs +132 -0
- package/dist/backends/gui/field.d.ts +74 -0
- package/dist/backends/gui/field.d.ts.map +1 -0
- package/dist/backends/gui/field.js +121 -0
- package/dist/backends/gui/field.js.map +1 -0
- package/dist/backends/gui/gantt.cjs +17 -19
- package/dist/backends/gui/gantt.d.ts +4 -5
- package/dist/backends/gui/gantt.d.ts.map +1 -1
- package/dist/backends/gui/gantt.js +18 -21
- package/dist/backends/gui/gantt.js.map +1 -1
- package/dist/backends/gui/glimpse.cjs +88 -0
- package/dist/backends/gui/glimpse.d.ts +57 -0
- package/dist/backends/gui/glimpse.d.ts.map +1 -0
- package/dist/backends/gui/glimpse.js +81 -0
- package/dist/backends/gui/glimpse.js.map +1 -0
- package/dist/backends/gui/grid-pattern.cjs +119 -0
- package/dist/backends/gui/grid-pattern.d.ts +96 -0
- package/dist/backends/gui/grid-pattern.d.ts.map +1 -0
- package/dist/backends/gui/grid-pattern.js +84 -0
- package/dist/backends/gui/grid-pattern.js.map +1 -0
- package/dist/backends/gui/image-crop.cjs +35 -0
- package/dist/backends/gui/image-crop.d.ts +20 -0
- package/dist/backends/gui/image-crop.d.ts.map +1 -0
- package/dist/backends/gui/image-crop.js +33 -0
- package/dist/backends/gui/image-crop.js.map +1 -0
- package/dist/backends/gui/image-zoom.cjs +58 -0
- package/dist/backends/gui/image-zoom.d.ts +16 -0
- package/dist/backends/gui/image-zoom.d.ts.map +1 -0
- package/dist/backends/gui/image-zoom.js +56 -0
- package/dist/backends/gui/image-zoom.js.map +1 -0
- package/dist/backends/gui/index.cjs +159 -1
- package/dist/backends/gui/index.d.ts +49 -0
- package/dist/backends/gui/index.d.ts.map +1 -1
- package/dist/backends/gui/index.js +49 -0
- package/dist/backends/gui/index.js.map +1 -1
- package/dist/backends/gui/interactive-grid-pattern.cjs +61 -0
- package/dist/backends/gui/interactive-grid-pattern.d.ts +28 -0
- package/dist/backends/gui/interactive-grid-pattern.d.ts.map +1 -0
- package/dist/backends/gui/interactive-grid-pattern.js +26 -0
- package/dist/backends/gui/interactive-grid-pattern.js.map +1 -0
- package/dist/backends/gui/iphone-15-pro.cjs +83 -0
- package/dist/backends/gui/iphone-15-pro.d.ts +16 -0
- package/dist/backends/gui/iphone-15-pro.d.ts.map +1 -0
- package/dist/backends/gui/iphone-15-pro.js +81 -0
- package/dist/backends/gui/iphone-15-pro.js.map +1 -0
- package/dist/backends/gui/item.cjs +154 -0
- package/dist/backends/gui/item.d.ts +72 -0
- package/dist/backends/gui/item.d.ts.map +1 -0
- package/dist/backends/gui/item.js +143 -0
- package/dist/backends/gui/item.js.map +1 -0
- package/dist/backends/gui/kanban.cjs +247 -0
- package/dist/backends/gui/kanban.d.ts +37 -0
- package/dist/backends/gui/kanban.d.ts.map +1 -0
- package/dist/backends/gui/kanban.js +212 -0
- package/dist/backends/gui/kanban.js.map +1 -0
- package/dist/backends/gui/kbd.cjs +45 -0
- package/dist/backends/gui/kbd.d.ts +8 -0
- package/dist/backends/gui/kbd.d.ts.map +1 -0
- package/dist/backends/gui/kbd.js +42 -0
- package/dist/backends/gui/kbd.js.map +1 -0
- package/dist/backends/gui/limelight-nav.cjs +201 -0
- package/dist/backends/gui/limelight-nav.d.ts +20 -0
- package/dist/backends/gui/limelight-nav.d.ts.map +1 -0
- package/dist/backends/gui/limelight-nav.js +166 -0
- package/dist/backends/gui/limelight-nav.js.map +1 -0
- package/dist/backends/gui/list.cjs +26 -0
- package/dist/backends/gui/list.d.ts +15 -0
- package/dist/backends/gui/list.d.ts.map +1 -0
- package/dist/backends/gui/list.js +23 -0
- package/dist/backends/gui/list.js.map +1 -0
- package/dist/backends/gui/macos-dock.cjs +84 -0
- package/dist/backends/gui/macos-dock.d.ts +30 -0
- package/dist/backends/gui/macos-dock.d.ts.map +1 -0
- package/dist/backends/gui/macos-dock.js +82 -0
- package/dist/backends/gui/macos-dock.js.map +1 -0
- package/dist/backends/gui/magnetic.cjs +40 -0
- package/dist/backends/gui/magnetic.d.ts +12 -0
- package/dist/backends/gui/magnetic.d.ts.map +1 -0
- package/dist/backends/gui/magnetic.js +38 -0
- package/dist/backends/gui/magnetic.js.map +1 -0
- package/dist/backends/gui/marquee.cjs +110 -0
- package/dist/backends/gui/marquee.d.ts +44 -0
- package/dist/backends/gui/marquee.d.ts.map +1 -0
- package/dist/backends/gui/marquee.js +75 -0
- package/dist/backends/gui/marquee.js.map +1 -0
- package/dist/backends/gui/menu-dock.cjs +64 -0
- package/dist/backends/gui/menu-dock.d.ts +21 -0
- package/dist/backends/gui/menu-dock.d.ts.map +1 -0
- package/dist/backends/gui/menu-dock.js +62 -0
- package/dist/backends/gui/menu-dock.js.map +1 -0
- package/dist/backends/gui/menubar.cjs +227 -0
- package/dist/backends/gui/menubar.d.ts +106 -0
- package/dist/backends/gui/menubar.d.ts.map +1 -0
- package/dist/backends/gui/menubar.js +177 -0
- package/dist/backends/gui/menubar.js.map +1 -0
- package/dist/backends/gui/message-dock.cjs +111 -0
- package/dist/backends/gui/message-dock.d.ts +22 -0
- package/dist/backends/gui/message-dock.d.ts.map +1 -0
- package/dist/backends/gui/message-dock.js +110 -0
- package/dist/backends/gui/message-dock.js.map +1 -0
- package/dist/backends/gui/mini-calendar.cjs +25 -0
- package/dist/backends/gui/mini-calendar.d.ts +22 -0
- package/dist/backends/gui/mini-calendar.d.ts.map +1 -0
- package/dist/backends/gui/mini-calendar.js +24 -0
- package/dist/backends/gui/mini-calendar.js.map +1 -0
- package/dist/backends/gui/minimal-tiptap.cjs +56 -0
- package/dist/backends/gui/minimal-tiptap.d.ts +20 -0
- package/dist/backends/gui/minimal-tiptap.d.ts.map +1 -0
- package/dist/backends/gui/minimal-tiptap.js +21 -0
- package/dist/backends/gui/minimal-tiptap.js.map +1 -0
- package/dist/backends/gui/motion-highlight.cjs +83 -0
- package/dist/backends/gui/motion-highlight.d.ts +27 -0
- package/dist/backends/gui/motion-highlight.d.ts.map +1 -0
- package/dist/backends/gui/motion-highlight.js +48 -0
- package/dist/backends/gui/motion-highlight.js.map +1 -0
- package/dist/backends/gui/navigation-bar.cjs +47 -0
- package/dist/backends/gui/navigation-bar.d.ts +48 -0
- package/dist/backends/gui/navigation-bar.d.ts.map +1 -0
- package/dist/backends/gui/navigation-bar.js +45 -0
- package/dist/backends/gui/navigation-bar.js.map +1 -0
- package/dist/backends/gui/news-timeline.cjs +47 -0
- package/dist/backends/gui/news-timeline.d.ts +39 -0
- package/dist/backends/gui/news-timeline.d.ts.map +1 -0
- package/dist/backends/gui/news-timeline.js +45 -0
- package/dist/backends/gui/news-timeline.js.map +1 -0
- package/dist/backends/gui/order-entry.cjs +53 -0
- package/dist/backends/gui/order-entry.d.ts +21 -0
- package/dist/backends/gui/order-entry.d.ts.map +1 -0
- package/dist/backends/gui/order-entry.js +52 -0
- package/dist/backends/gui/order-entry.js.map +1 -0
- package/dist/backends/gui/orders-history.cjs +102 -0
- package/dist/backends/gui/orders-history.d.ts +24 -0
- package/dist/backends/gui/orders-history.d.ts.map +1 -0
- package/dist/backends/gui/orders-history.js +67 -0
- package/dist/backends/gui/orders-history.js.map +1 -0
- package/dist/backends/gui/pagination.cjs +51 -0
- package/dist/backends/gui/pagination.d.ts +52 -0
- package/dist/backends/gui/pagination.d.ts.map +1 -0
- package/dist/backends/gui/pagination.js +42 -0
- package/dist/backends/gui/pagination.js.map +1 -0
- package/dist/backends/gui/particles-background.cjs +135 -0
- package/dist/backends/gui/particles-background.d.ts +24 -0
- package/dist/backends/gui/particles-background.d.ts.map +1 -0
- package/dist/backends/gui/particles-background.js +133 -0
- package/dist/backends/gui/particles-background.js.map +1 -0
- package/dist/backends/gui/particles.cjs +145 -0
- package/dist/backends/gui/particles.d.ts +25 -0
- package/dist/backends/gui/particles.d.ts.map +1 -0
- package/dist/backends/gui/particles.js +143 -0
- package/dist/backends/gui/particles.js.map +1 -0
- package/dist/backends/gui/pill.cjs +82 -0
- package/dist/backends/gui/pill.d.ts +12 -0
- package/dist/backends/gui/pill.d.ts.map +1 -0
- package/dist/backends/gui/pill.js +78 -0
- package/dist/backends/gui/pill.js.map +1 -0
- package/dist/backends/gui/pin-list.cjs +82 -0
- package/dist/backends/gui/pin-list.d.ts +42 -0
- package/dist/backends/gui/pin-list.d.ts.map +1 -0
- package/dist/backends/gui/pin-list.js +80 -0
- package/dist/backends/gui/pin-list.js.map +1 -0
- package/dist/backends/gui/pixel-image.cjs +63 -0
- package/dist/backends/gui/pixel-image.d.ts +21 -0
- package/dist/backends/gui/pixel-image.d.ts.map +1 -0
- package/dist/backends/gui/pixel-image.js +61 -0
- package/dist/backends/gui/pixel-image.js.map +1 -0
- package/dist/backends/gui/positions-list.cjs +60 -0
- package/dist/backends/gui/positions-list.d.ts +14 -0
- package/dist/backends/gui/positions-list.d.ts.map +1 -0
- package/dist/backends/gui/positions-list.js +58 -0
- package/dist/backends/gui/positions-list.js.map +1 -0
- package/dist/backends/gui/qr-code.cjs +438 -0
- package/dist/backends/gui/qr-code.d.ts +42 -0
- package/dist/backends/gui/qr-code.d.ts.map +1 -0
- package/dist/backends/gui/qr-code.js +402 -0
- package/dist/backends/gui/qr-code.js.map +1 -0
- package/dist/backends/gui/relative-time.cjs +167 -0
- package/dist/backends/gui/relative-time.d.ts +10 -0
- package/dist/backends/gui/relative-time.d.ts.map +1 -0
- package/dist/backends/gui/relative-time.js +132 -0
- package/dist/backends/gui/relative-time.js.map +1 -0
- package/dist/backends/gui/safari.cjs +65 -0
- package/dist/backends/gui/safari.d.ts +23 -0
- package/dist/backends/gui/safari.d.ts.map +1 -0
- package/dist/backends/gui/safari.js +63 -0
- package/dist/backends/gui/safari.js.map +1 -0
- package/dist/backends/gui/snippet.cjs +144 -0
- package/dist/backends/gui/snippet.d.ts +38 -0
- package/dist/backends/gui/snippet.d.ts.map +1 -0
- package/dist/backends/gui/snippet.js +141 -0
- package/dist/backends/gui/snippet.js.map +1 -0
- package/dist/backends/gui/stars-scrolling-wheel.cjs +106 -0
- package/dist/backends/gui/stars-scrolling-wheel.d.ts +24 -0
- package/dist/backends/gui/stars-scrolling-wheel.d.ts.map +1 -0
- package/dist/backends/gui/stars-scrolling-wheel.js +104 -0
- package/dist/backends/gui/stars-scrolling-wheel.js.map +1 -0
- package/dist/backends/gui/status.cjs +79 -0
- package/dist/backends/gui/status.d.ts +15 -0
- package/dist/backends/gui/status.d.ts.map +1 -0
- package/dist/backends/gui/status.js +77 -0
- package/dist/backends/gui/status.js.map +1 -0
- package/dist/backends/gui/stock-market.cjs +21 -0
- package/dist/backends/gui/stock-market.d.ts +17 -0
- package/dist/backends/gui/stock-market.d.ts.map +1 -0
- package/dist/backends/gui/stock-market.js +19 -0
- package/dist/backends/gui/stock-market.js.map +1 -0
- package/dist/backends/gui/stock-screener.cjs +55 -0
- package/dist/backends/gui/stock-screener.d.ts +41 -0
- package/dist/backends/gui/stock-screener.d.ts.map +1 -0
- package/dist/backends/gui/stock-screener.js +53 -0
- package/dist/backends/gui/stock-screener.js.map +1 -0
- package/dist/backends/gui/symbol-info.cjs +46 -0
- package/dist/backends/gui/symbol-info.d.ts +36 -0
- package/dist/backends/gui/symbol-info.d.ts.map +1 -0
- package/dist/backends/gui/symbol-info.js +44 -0
- package/dist/backends/gui/symbol-info.js.map +1 -0
- package/dist/backends/gui/table.cjs +104 -0
- package/dist/backends/gui/table.d.ts +57 -0
- package/dist/backends/gui/table.d.ts.map +1 -0
- package/dist/backends/gui/table.js +95 -0
- package/dist/backends/gui/table.js.map +1 -0
- package/dist/backends/gui/tags.cjs +22 -0
- package/dist/backends/gui/tags.d.ts +22 -0
- package/dist/backends/gui/tags.d.ts.map +1 -0
- package/dist/backends/gui/tags.js +20 -0
- package/dist/backends/gui/tags.js.map +1 -0
- package/dist/backends/gui/technical-analysis.cjs +58 -0
- package/dist/backends/gui/technical-analysis.d.ts +41 -0
- package/dist/backends/gui/technical-analysis.d.ts.map +1 -0
- package/dist/backends/gui/technical-analysis.js +56 -0
- package/dist/backends/gui/technical-analysis.js.map +1 -0
- package/dist/backends/gui/terminal.cjs +266 -0
- package/dist/backends/gui/terminal.d.ts +38 -0
- package/dist/backends/gui/terminal.d.ts.map +1 -0
- package/dist/backends/gui/terminal.js +231 -0
- package/dist/backends/gui/terminal.js.map +1 -0
- package/dist/backends/gui/ticker.cjs +79 -0
- package/dist/backends/gui/ticker.d.ts +19 -0
- package/dist/backends/gui/ticker.d.ts.map +1 -0
- package/dist/backends/gui/ticker.js +44 -0
- package/dist/backends/gui/ticker.js.map +1 -0
- package/dist/backends/gui/timeline.cjs +154 -0
- package/dist/backends/gui/timeline.d.ts +42 -0
- package/dist/backends/gui/timeline.d.ts.map +1 -0
- package/dist/backends/gui/timeline.js +118 -0
- package/dist/backends/gui/timeline.js.map +1 -0
- package/dist/backends/gui/toggle.cjs +96 -0
- package/dist/backends/gui/toggle.d.ts +29 -0
- package/dist/backends/gui/toggle.d.ts.map +1 -0
- package/dist/backends/gui/toggle.js +95 -0
- package/dist/backends/gui/toggle.js.map +1 -0
- package/dist/backends/gui/video-player.cjs +383 -0
- package/dist/backends/gui/video-player.d.ts +54 -0
- package/dist/backends/gui/video-player.d.ts.map +1 -0
- package/dist/backends/gui/video-player.js +348 -0
- package/dist/backends/gui/video-player.js.map +1 -0
- package/dist/gallery.html +249 -249
- package/dist/gui-config.cjs +5 -0
- package/dist/gui-config.d.ts +18 -3
- package/dist/gui-config.d.ts.map +1 -1
- package/dist/gui-config.js +5 -0
- package/dist/gui-config.js.map +1 -1
- package/dist/index.cjs +110 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.node.cjs +110 -1
- package/dist/index.node.js +1 -1
- package/dist/styles.css +124 -124
- package/package.json +1 -1
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Editor — a rich-text
|
|
3
|
-
*
|
|
2
|
+
* Editor — a minimal rich-text field: a toolbar of formatting buttons above a
|
|
3
|
+
* `contentEditable` surface.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* `contentEditable`
|
|
8
|
-
*
|
|
9
|
-
*
|
|
5
|
+
* Bold, italic and the two list commands run through the browser's own
|
|
6
|
+
* `document.execCommand`, the one API that turns a toolbar click into a real
|
|
7
|
+
* selection edit inside a `contentEditable` region — there is no gui primitive
|
|
8
|
+
* for rich-text editing, so this wraps that platform primitive in a gui frame
|
|
9
|
+
* the way `CodeEditor` wraps a plain field. The surface is HTML: `value` and
|
|
10
|
+
* `onChange` carry the region's `innerHTML`, matching what the toolbar
|
|
11
|
+
* commands actually produce.
|
|
10
12
|
*/
|
|
11
13
|
import { type YStackProps } from '@hanzo/gui';
|
|
12
14
|
import * as React from 'react';
|
|
13
|
-
/** The four formatting commands the toolbar issues via `document.execCommand`. */
|
|
14
15
|
export type EditorCommand = 'bold' | 'italic' | 'insertUnorderedList' | 'insertOrderedList';
|
|
15
16
|
export interface EditorProps extends Omit<YStackProps, 'children' | 'onChange'> {
|
|
16
|
-
/**
|
|
17
|
+
/** The region's HTML. Omit it and the region keeps its own content. */
|
|
17
18
|
value?: string;
|
|
18
19
|
onChange?: (value: string) => void;
|
|
19
20
|
placeholder?: string;
|
|
20
|
-
readOnly?: boolean;
|
|
21
21
|
}
|
|
22
|
-
export declare function Editor({ value, onChange, placeholder,
|
|
22
|
+
export declare function Editor({ value, onChange, placeholder, ...props }: EditorProps): React.JSX.Element;
|
|
23
23
|
//# sourceMappingURL=editor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editor.d.ts","sourceRoot":"","sources":["../../../src/backends/gui/editor.tsx"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"editor.d.ts","sourceRoot":"","sources":["../../../src/backends/gui/editor.tsx"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AACH,OAAO,EAAkB,KAAK,WAAW,EAAE,MAAM,YAAY,CAAA;AAE7D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAK9B,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,QAAQ,GAAG,qBAAqB,GAAG,mBAAmB,CAAA;AAE3F,MAAM,WAAW,WAAY,SAAQ,IAAI,CAAC,WAAW,EAAE,UAAU,GAAG,UAAU,CAAC;IAC7E,uEAAuE;IACvE,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IAClC,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED,wBAAgB,MAAM,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,WAA+B,EAAE,GAAG,KAAK,EAAE,EAAE,WAAW,qBA6EjG"}
|
|
@@ -1,45 +1,49 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
/**
|
|
4
|
-
* Editor — a rich-text
|
|
5
|
-
*
|
|
4
|
+
* Editor — a minimal rich-text field: a toolbar of formatting buttons above a
|
|
5
|
+
* `contentEditable` surface.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* `contentEditable`
|
|
10
|
-
*
|
|
11
|
-
*
|
|
7
|
+
* Bold, italic and the two list commands run through the browser's own
|
|
8
|
+
* `document.execCommand`, the one API that turns a toolbar click into a real
|
|
9
|
+
* selection edit inside a `contentEditable` region — there is no gui primitive
|
|
10
|
+
* for rich-text editing, so this wraps that platform primitive in a gui frame
|
|
11
|
+
* the way `CodeEditor` wraps a plain field. The surface is HTML: `value` and
|
|
12
|
+
* `onChange` carry the region's `innerHTML`, matching what the toolbar
|
|
13
|
+
* commands actually produce.
|
|
12
14
|
*/
|
|
13
15
|
import { XStack, YStack } from '@hanzo/gui';
|
|
14
16
|
import { Bold, Italic, List, ListOrdered } from '@hanzogui/lucide-icons-2';
|
|
15
17
|
import * as React from 'react';
|
|
16
18
|
import { Button } from './button.js';
|
|
17
19
|
import { slot } from './slot.js';
|
|
18
|
-
export function Editor({ value, onChange, placeholder = 'Start typing...',
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
export function Editor({ value, onChange, placeholder = 'Start typing...', ...props }) {
|
|
21
|
+
const field = React.useRef(null);
|
|
22
|
+
const shown = React.useRef(value);
|
|
23
|
+
const run = (command) => {
|
|
24
|
+
document.execCommand(command, false);
|
|
25
|
+
field.current?.focus();
|
|
26
|
+
};
|
|
27
|
+
const input = () => {
|
|
28
|
+
if (field.current)
|
|
29
|
+
onChange?.(field.current.innerHTML);
|
|
30
|
+
};
|
|
31
|
+
// A controlled `value` is only ever WRITTEN into the region when it changed
|
|
32
|
+
// out from under the caller — writing it on every render would reset the
|
|
33
|
+
// caret to the start on each keystroke, because `innerHTML` replaces the
|
|
34
|
+
// whole subtree rather than patching it.
|
|
24
35
|
React.useEffect(() => {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
36
|
+
if (field.current && value !== undefined && value !== shown.current) {
|
|
37
|
+
field.current.innerHTML = value;
|
|
38
|
+
}
|
|
39
|
+
shown.current = value;
|
|
28
40
|
}, [value]);
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const command = (name) => () => {
|
|
37
|
-
document.execCommand(name);
|
|
38
|
-
surface.current?.focus();
|
|
39
|
-
report();
|
|
40
|
-
};
|
|
41
|
-
return (_jsxs(YStack, { ...slot('editor'), gap: "$2", ...props, children: [_jsxs(XStack, { ...slot('editor-toolbar'), gap: "$1", borderBottomWidth: 1, borderColor: "$borderColor", pb: "$2", children: [_jsx(Button, { ...slot('editor-bold'), variant: "ghost", size: "icon-sm", type: "button", onClick: command('bold'), "aria-label": "Bold", children: _jsx(Bold, { size: 16 }) }), _jsx(Button, { ...slot('editor-italic'), variant: "ghost", size: "icon-sm", type: "button", onClick: command('italic'), "aria-label": "Italic", children: _jsx(Italic, { size: 16 }) }), _jsx(Button, { ...slot('editor-bullet-list'), variant: "ghost", size: "icon-sm", type: "button", onClick: command('insertUnorderedList'), "aria-label": "Bulleted list", children: _jsx(List, { size: 16 }) }), _jsx(Button, { ...slot('editor-ordered-list'), variant: "ghost", size: "icon-sm", type: "button", onClick: command('insertOrderedList'), "aria-label": "Numbered list", children: _jsx(ListOrdered, { size: 16 }) })] }), _jsx(YStack, { ...slot('editor-surface'), ref: surface,
|
|
42
|
-
// @ts-expect-error — contentEditable is a DOM attribute gui does not type; it forwards unknown props on web and drops them on native
|
|
43
|
-
contentEditable: !readOnly, suppressContentEditableWarning: true, "data-placeholder": placeholder, "data-empty": empty || undefined, minH: 200, borderWidth: 1, borderColor: "$borderColor", rounded: "$3", p: "$4", onInput: report, dangerouslySetInnerHTML: value === undefined ? { __html: '' } : undefined, style: { outline: 'none' } })] }));
|
|
41
|
+
return (_jsxs(YStack, { ...slot('editor'), gap: "$2", ...props, children: [_jsxs(XStack, { ...slot('editor-toolbar'), items: "center", gap: "$1", borderBottomWidth: 1, borderColor: "$borderColor", pb: "$2", children: [_jsx(Button, { ...slot('editor-bold'), variant: "ghost", size: "sm", type: "button", onClick: () => run('bold'), children: _jsx(Bold, { size: 16 }) }), _jsx(Button, { ...slot('editor-italic'), variant: "ghost", size: "sm", type: "button", onClick: () => run('italic'), children: _jsx(Italic, { size: 16 }) }), _jsx(Button, { ...slot('editor-bullet-list'), variant: "ghost", size: "sm", type: "button", onClick: () => run('insertUnorderedList'), children: _jsx(List, { size: 16 }) }), _jsx(Button, { ...slot('editor-ordered-list'), variant: "ghost", size: "sm", type: "button", onClick: () => run('insertOrderedList'), children: _jsx(ListOrdered, { size: 16 }) })] }), _jsx("div", { ref: field, ...slot('editor-content'), contentEditable: true, onInput: input, "data-placeholder": placeholder, suppressContentEditableWarning: true, dangerouslySetInnerHTML: value === undefined ? undefined : { __html: value }, style: {
|
|
42
|
+
minHeight: 200,
|
|
43
|
+
borderRadius: 8,
|
|
44
|
+
border: '1px solid var(--borderColor)',
|
|
45
|
+
padding: 16,
|
|
46
|
+
outline: 'none',
|
|
47
|
+
} })] }));
|
|
44
48
|
}
|
|
45
49
|
//# sourceMappingURL=editor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editor.js","sourceRoot":"","sources":["../../../src/backends/gui/editor.tsx"],"names":[],"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QAAQ,EACb,OAAO,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,mBAAmB,CAAC,YAEvC,KAAC,WAAW,IAAC,IAAI,EAAE,EAAE,GAAI,GAClB,IACF,EACT,cACE,GAAG,EAAE,KAAK,KACN,IAAI,CAAC,gBAAgB,CAAC,EAC1B,eAAe,QACf,OAAO,EAAE,KAAK,sBACI,WAAW,EAC7B,8BAA8B,QAC9B,uBAAuB,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,EAC5E,KAAK,EAAE;oBACL,SAAS,EAAE,GAAG;oBACd,YAAY,EAAE,CAAC;oBACf,MAAM,EAAE,8BAA8B;oBACtC,OAAO,EAAE,EAAE;oBACX,OAAO,EAAE,MAAM;iBAChB,GACD,IACK,CACV,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
'use client';"use strict";
|
|
2
|
+
'use client';
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.FieldGroup = exports.FieldContent = void 0;
|
|
5
|
+
exports.Field = Field;
|
|
6
|
+
exports.FieldDescription = FieldDescription;
|
|
7
|
+
exports.FieldError = FieldError;
|
|
8
|
+
exports.FieldLabel = FieldLabel;
|
|
9
|
+
exports.FieldLegend = FieldLegend;
|
|
10
|
+
exports.FieldSeparator = FieldSeparator;
|
|
11
|
+
exports.FieldSet = FieldSet;
|
|
12
|
+
exports.FieldTitle = FieldTitle;
|
|
13
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
14
|
+
/**
|
|
15
|
+
* Field — the parts a form composes a labeled control from.
|
|
16
|
+
*
|
|
17
|
+
* `FieldSet`/`FieldLegend` group related fields inside a real `<fieldset>` so
|
|
18
|
+
* keyboard and screen-reader users get the grouping for free. `FieldGroup`
|
|
19
|
+
* stacks `Field`s with one rhythm. `Field` is the per-control wrapper —
|
|
20
|
+
* `role="group"`, an `orientation` (vertical / horizontal / responsive), and a
|
|
21
|
+
* `data-invalid` switch that turns the whole block destructive-colored so a
|
|
22
|
+
* sighted user and a screen reader see the same boundary. `FieldContent` keeps
|
|
23
|
+
* a label and its description together when the label sits beside the control.
|
|
24
|
+
* `FieldLabel` also doubles as a selectable "choice card" when its only child
|
|
25
|
+
* is a `Field` — border, radius and padding appear around it.
|
|
26
|
+
* `FieldTitle`/`FieldDescription`/`FieldError` are the text leaves;
|
|
27
|
+
* `FieldSeparator` divides a `FieldGroup`.
|
|
28
|
+
*
|
|
29
|
+
* `responsive` is mobile-first like `vertical` already is: a column below
|
|
30
|
+
* `$md`, a row from `$md` up — this config's media props are min-width (see
|
|
31
|
+
* the compiled `@media (min-width: …)` any `$md` prop emits), so there are no
|
|
32
|
+
* container queries to reach for and none are needed: the same direction every
|
|
33
|
+
* other responsive prop in this codebase is written in.
|
|
34
|
+
*/
|
|
35
|
+
const gui_1 = require("@hanzo/gui");
|
|
36
|
+
const react_1 = require("react");
|
|
37
|
+
const box_1 = require("../../box.cjs");
|
|
38
|
+
const label_1 = require("./label.cjs");
|
|
39
|
+
const layout_1 = require("./layout.cjs");
|
|
40
|
+
const ink_1 = require("./ink.cjs");
|
|
41
|
+
const slot_1 = require("./slot.cjs");
|
|
42
|
+
function FieldSet({ children, ...props }) {
|
|
43
|
+
return ((0, jsx_runtime_1.jsx)(box_1.Box, { tag: "fieldset", className: "flex flex-col gap-6", ...(0, slot_1.slot)('field-set'), ...props, children: children }));
|
|
44
|
+
}
|
|
45
|
+
function FieldLegend({ variant = 'legend', children, ...props }) {
|
|
46
|
+
return ((0, jsx_runtime_1.jsx)(box_1.Box, { tag: "legend", className: variant === 'label' ? 'mb-3 text-sm font-medium' : 'mb-3 text-base font-medium', ...(0, slot_1.slot)('field-legend'), "data-variant": variant, ...props, children: children }));
|
|
47
|
+
}
|
|
48
|
+
const FieldGroup = (0, gui_1.styled)(gui_1.YStack, {
|
|
49
|
+
name: 'FieldGroup',
|
|
50
|
+
width: '100%',
|
|
51
|
+
gap: '$7',
|
|
52
|
+
});
|
|
53
|
+
exports.FieldGroup = FieldGroup;
|
|
54
|
+
const FieldContext = /* @__PURE__ */ (0, gui_1.createStyledContext)({
|
|
55
|
+
orientation: 'vertical',
|
|
56
|
+
});
|
|
57
|
+
const FieldFrame = (0, gui_1.styled)(gui_1.XStack, {
|
|
58
|
+
name: 'Field',
|
|
59
|
+
context: FieldContext,
|
|
60
|
+
width: '100%',
|
|
61
|
+
gap: '$3',
|
|
62
|
+
variants: {
|
|
63
|
+
orientation: {
|
|
64
|
+
vertical: { flexDirection: 'column' },
|
|
65
|
+
horizontal: { flexDirection: 'row', items: 'center' },
|
|
66
|
+
// Mobile-first, the way `vertical` already is: a column below `$md`,
|
|
67
|
+
// a row from `$md` up — this config's media props are min-width, so the
|
|
68
|
+
// base case is the narrow one and `$md` is where it widens.
|
|
69
|
+
responsive: {
|
|
70
|
+
flexDirection: 'column',
|
|
71
|
+
$md: { flexDirection: 'row', items: 'center' },
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
invalid: {
|
|
75
|
+
true: { color: '$red9' },
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
defaultVariants: { orientation: 'vertical' },
|
|
79
|
+
});
|
|
80
|
+
function Field({ orientation = 'vertical', ...props }) {
|
|
81
|
+
const invalid = props['data-invalid'];
|
|
82
|
+
return ((0, jsx_runtime_1.jsx)(FieldFrame, { role: "group", ...(0, slot_1.slot)('field'), "data-orientation": orientation, orientation: orientation, invalid: invalid, ...props }));
|
|
83
|
+
}
|
|
84
|
+
const FieldContent = (0, gui_1.styled)(gui_1.YStack, {
|
|
85
|
+
name: 'FieldContent',
|
|
86
|
+
flex: 1,
|
|
87
|
+
gap: '$1.5',
|
|
88
|
+
});
|
|
89
|
+
exports.FieldContent = FieldContent;
|
|
90
|
+
/** A `Field` nested directly inside a `FieldLabel` reads as a choice card. */
|
|
91
|
+
const isFieldChild = (children) => (0, react_1.isValidElement)(children) && children.type === Field;
|
|
92
|
+
function FieldLabel({ className, children, ...props }) {
|
|
93
|
+
const card = isFieldChild(children);
|
|
94
|
+
return ((0, jsx_runtime_1.jsx)(label_1.Label, { ...(0, slot_1.slot)('field-label'), gap: "$2", ...(card
|
|
95
|
+
? {
|
|
96
|
+
width: '100%',
|
|
97
|
+
flexDirection: 'column',
|
|
98
|
+
rounded: '$3',
|
|
99
|
+
borderWidth: 1,
|
|
100
|
+
borderColor: '$borderColor',
|
|
101
|
+
p: '$4',
|
|
102
|
+
}
|
|
103
|
+
: { self: 'flex-start' }), className: className, ...props, children: children }));
|
|
104
|
+
}
|
|
105
|
+
function FieldTitle({ children, ...props }) {
|
|
106
|
+
return ((0, jsx_runtime_1.jsx)(gui_1.XStack, { ...(0, slot_1.slot)('field-label'), self: "flex-start", items: "center", gap: "$2", ...props, children: (0, ink_1.ink)(children, gui_1.SizableText, { fontSize: '$2', fontWeight: '500' }) }));
|
|
107
|
+
}
|
|
108
|
+
function FieldDescription({ children, ...props }) {
|
|
109
|
+
return ((0, jsx_runtime_1.jsx)(gui_1.SizableText, { ...(0, slot_1.slot)('field-description'), fontSize: "$2", fontWeight: "400", color: "$quiet", ...props, children: children }));
|
|
110
|
+
}
|
|
111
|
+
function FieldSeparator({ children, ...props }) {
|
|
112
|
+
return ((0, jsx_runtime_1.jsxs)(gui_1.XStack, { ...(0, slot_1.slot)('field-separator'), "data-content": !!children, items: "center", gap: "$2", ...props, children: [(0, jsx_runtime_1.jsx)(layout_1.Separator, { flex: 1 }), children && ((0, jsx_runtime_1.jsx)(gui_1.SizableText, { ...(0, slot_1.slot)('field-separator-content'), color: "$quiet", fontSize: "$2", children: children })), children && (0, jsx_runtime_1.jsx)(layout_1.Separator, { flex: 1 })] }));
|
|
113
|
+
}
|
|
114
|
+
function fieldErrorContent(children, errors, issues) {
|
|
115
|
+
if (children)
|
|
116
|
+
return children;
|
|
117
|
+
const list = errors ?? issues;
|
|
118
|
+
if (!list)
|
|
119
|
+
return null;
|
|
120
|
+
const messages = list.filter((e) => !!e?.message);
|
|
121
|
+
if (messages.length === 0)
|
|
122
|
+
return null;
|
|
123
|
+
if (messages.length === 1)
|
|
124
|
+
return messages[0].message;
|
|
125
|
+
return ((0, jsx_runtime_1.jsx)(box_1.Box, { tag: "ul", className: "ml-4 flex flex-col gap-1", style: { listStyleType: 'disc' }, ...(0, slot_1.slot)('field-error-list'), children: messages.map((error, index) => ((0, jsx_runtime_1.jsx)(box_1.Box, { tag: "li", className: "text-sm text-red9", children: error.message }, index))) }));
|
|
126
|
+
}
|
|
127
|
+
function FieldError({ children, errors, issues, ...props }) {
|
|
128
|
+
const content = fieldErrorContent(children, errors, issues);
|
|
129
|
+
if (!content)
|
|
130
|
+
return null;
|
|
131
|
+
return ((0, jsx_runtime_1.jsx)(gui_1.XStack, { role: "alert", ...(0, slot_1.slot)('field-error'), ...props, children: (0, ink_1.ink)(content, gui_1.SizableText, { fontSize: '$2', fontWeight: '400', color: '$red9' }) }));
|
|
132
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Field — the parts a form composes a labeled control from.
|
|
3
|
+
*
|
|
4
|
+
* `FieldSet`/`FieldLegend` group related fields inside a real `<fieldset>` so
|
|
5
|
+
* keyboard and screen-reader users get the grouping for free. `FieldGroup`
|
|
6
|
+
* stacks `Field`s with one rhythm. `Field` is the per-control wrapper —
|
|
7
|
+
* `role="group"`, an `orientation` (vertical / horizontal / responsive), and a
|
|
8
|
+
* `data-invalid` switch that turns the whole block destructive-colored so a
|
|
9
|
+
* sighted user and a screen reader see the same boundary. `FieldContent` keeps
|
|
10
|
+
* a label and its description together when the label sits beside the control.
|
|
11
|
+
* `FieldLabel` also doubles as a selectable "choice card" when its only child
|
|
12
|
+
* is a `Field` — border, radius and padding appear around it.
|
|
13
|
+
* `FieldTitle`/`FieldDescription`/`FieldError` are the text leaves;
|
|
14
|
+
* `FieldSeparator` divides a `FieldGroup`.
|
|
15
|
+
*
|
|
16
|
+
* `responsive` is mobile-first like `vertical` already is: a column below
|
|
17
|
+
* `$md`, a row from `$md` up — this config's media props are min-width (see
|
|
18
|
+
* the compiled `@media (min-width: …)` any `$md` prop emits), so there are no
|
|
19
|
+
* container queries to reach for and none are needed: the same direction every
|
|
20
|
+
* other responsive prop in this codebase is written in.
|
|
21
|
+
*/
|
|
22
|
+
import { SizableText, XStack } from '@hanzo/gui';
|
|
23
|
+
import { type ComponentProps, type ReactNode } from 'react';
|
|
24
|
+
import { Label } from './label.js';
|
|
25
|
+
export type FieldOrientation = 'vertical' | 'horizontal' | 'responsive';
|
|
26
|
+
export type FieldLegendVariant = 'legend' | 'label';
|
|
27
|
+
declare function FieldSet({ children, ...props }: ComponentProps<'fieldset'>): import("react").JSX.Element;
|
|
28
|
+
export type FieldSetProps = ComponentProps<typeof FieldSet>;
|
|
29
|
+
declare function FieldLegend({ variant, children, ...props }: ComponentProps<'legend'> & {
|
|
30
|
+
variant?: FieldLegendVariant;
|
|
31
|
+
}): import("react").JSX.Element;
|
|
32
|
+
export type FieldLegendProps = ComponentProps<typeof FieldLegend>;
|
|
33
|
+
declare const FieldGroup: 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 FieldGroupProps = ComponentProps<typeof FieldGroup>;
|
|
38
|
+
declare const FieldFrame: import("@hanzogui/web").GuiComponent<import("@hanzogui/web").TamaDefer, import("@hanzogui/web").GuiElement, import("@hanzogui/core").RNGuiViewNonStyleProps, import("@hanzogui/web").StackStyleBase, {
|
|
39
|
+
elevation?: number | import("@hanzogui/web").SizeTokens | undefined;
|
|
40
|
+
fullscreen?: boolean | undefined;
|
|
41
|
+
invalid?: boolean | undefined;
|
|
42
|
+
orientation?: "horizontal" | "responsive" | "vertical" | undefined;
|
|
43
|
+
}, import("@hanzogui/web").StaticConfigPublic>;
|
|
44
|
+
export type FieldProps = Omit<ComponentProps<typeof FieldFrame>, 'orientation'> & {
|
|
45
|
+
orientation?: FieldOrientation;
|
|
46
|
+
'data-invalid'?: boolean;
|
|
47
|
+
};
|
|
48
|
+
declare function Field({ orientation, ...props }: FieldProps): import("react").JSX.Element;
|
|
49
|
+
declare const FieldContent: import("@hanzogui/web").GuiComponent<import("@hanzogui/web").TamaDefer, import("@hanzogui/web").GuiElement, import("@hanzogui/core").RNGuiViewNonStyleProps, import("@hanzogui/web").StackStyleBase, {
|
|
50
|
+
elevation?: number | import("@hanzogui/web").SizeTokens | undefined;
|
|
51
|
+
fullscreen?: boolean | undefined;
|
|
52
|
+
}, import("@hanzogui/web").StaticConfigPublic>;
|
|
53
|
+
export type FieldContentProps = ComponentProps<typeof FieldContent>;
|
|
54
|
+
declare function FieldLabel({ className, children, ...props }: ComponentProps<typeof Label>): import("react").JSX.Element;
|
|
55
|
+
export type FieldLabelProps = ComponentProps<typeof FieldLabel>;
|
|
56
|
+
declare function FieldTitle({ children, ...props }: ComponentProps<typeof XStack>): import("react").JSX.Element;
|
|
57
|
+
export type FieldTitleProps = ComponentProps<typeof FieldTitle>;
|
|
58
|
+
declare function FieldDescription({ children, ...props }: ComponentProps<typeof SizableText>): import("react").JSX.Element;
|
|
59
|
+
export type FieldDescriptionProps = ComponentProps<typeof FieldDescription>;
|
|
60
|
+
declare function FieldSeparator({ children, ...props }: ComponentProps<typeof XStack> & {
|
|
61
|
+
children?: ReactNode;
|
|
62
|
+
}): import("react").JSX.Element;
|
|
63
|
+
export type FieldSeparatorProps = ComponentProps<typeof FieldSeparator>;
|
|
64
|
+
export type FieldErrorIssue = {
|
|
65
|
+
message?: string;
|
|
66
|
+
};
|
|
67
|
+
export type FieldErrorProps = ComponentProps<typeof XStack> & {
|
|
68
|
+
errors?: Array<FieldErrorIssue | undefined>;
|
|
69
|
+
/** Issues from any [Standard Schema](https://standardschema.dev/) validator. */
|
|
70
|
+
issues?: Array<FieldErrorIssue | undefined>;
|
|
71
|
+
};
|
|
72
|
+
declare function FieldError({ children, errors, issues, ...props }: FieldErrorProps): import("react").JSX.Element | null;
|
|
73
|
+
export { Field, FieldContent, FieldDescription, FieldError, FieldGroup, FieldLabel, FieldLegend, FieldSeparator, FieldSet, FieldTitle, };
|
|
74
|
+
//# sourceMappingURL=field.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"field.d.ts","sourceRoot":"","sources":["../../../src/backends/gui/field.tsx"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,EAAuC,MAAM,YAAY,CAAA;AACrF,OAAO,EAAkB,KAAK,cAAc,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAE3E,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAK/B,MAAM,MAAM,gBAAgB,GAAG,UAAU,GAAG,YAAY,GAAG,YAAY,CAAA;AACvE,MAAM,MAAM,kBAAkB,GAAG,QAAQ,GAAG,OAAO,CAAA;AAEnD,iBAAS,QAAQ,CAAC,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,cAAc,CAAC,UAAU,CAAC,+BAMnE;AAED,MAAM,MAAM,aAAa,GAAG,cAAc,CAAC,OAAO,QAAQ,CAAC,CAAA;AAE3D,iBAAS,WAAW,CAAC,EAAE,OAAkB,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,cAAc,CAAC,QAAQ,CAAC,GAAG;IAC1F,OAAO,CAAC,EAAE,kBAAkB,CAAA;CAC7B,+BAYA;AAED,MAAM,MAAM,gBAAgB,GAAG,cAAc,CAAC,OAAO,WAAW,CAAC,CAAA;AAEjE,QAAA,MAAM,UAAU;;;8CAId,CAA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O,cAAc,CAAC,CAAA;AAEvE,MAAM,MAAM,eAAe,GAAG;IAAE,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AAiClD,MAAM,MAAM,eAAe,GAAG,cAAc,CAAC,OAAO,MAAM,CAAC,GAAG;IAC5D,MAAM,CAAC,EAAE,KAAK,CAAC,eAAe,GAAG,SAAS,CAAC,CAAA;IAC3C,gFAAgF;IAChF,MAAM,CAAC,EAAE,KAAK,CAAC,eAAe,GAAG,SAAS,CAAC,CAAA;CAC5C,CAAA;AAED,iBAAS,UAAU,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,KAAK,EAAE,EAAE,eAAe,sCAQ1E;AAED,OAAO,EACL,KAAK,EACL,YAAY,EACZ,gBAAgB,EAChB,UAAU,EACV,UAAU,EACV,UAAU,EACV,WAAW,EACX,cAAc,EACd,QAAQ,EACR,UAAU,GACX,CAAA"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
/**
|
|
4
|
+
* Field — the parts a form composes a labeled control from.
|
|
5
|
+
*
|
|
6
|
+
* `FieldSet`/`FieldLegend` group related fields inside a real `<fieldset>` so
|
|
7
|
+
* keyboard and screen-reader users get the grouping for free. `FieldGroup`
|
|
8
|
+
* stacks `Field`s with one rhythm. `Field` is the per-control wrapper —
|
|
9
|
+
* `role="group"`, an `orientation` (vertical / horizontal / responsive), and a
|
|
10
|
+
* `data-invalid` switch that turns the whole block destructive-colored so a
|
|
11
|
+
* sighted user and a screen reader see the same boundary. `FieldContent` keeps
|
|
12
|
+
* a label and its description together when the label sits beside the control.
|
|
13
|
+
* `FieldLabel` also doubles as a selectable "choice card" when its only child
|
|
14
|
+
* is a `Field` — border, radius and padding appear around it.
|
|
15
|
+
* `FieldTitle`/`FieldDescription`/`FieldError` are the text leaves;
|
|
16
|
+
* `FieldSeparator` divides a `FieldGroup`.
|
|
17
|
+
*
|
|
18
|
+
* `responsive` is mobile-first like `vertical` already is: a column below
|
|
19
|
+
* `$md`, a row from `$md` up — this config's media props are min-width (see
|
|
20
|
+
* the compiled `@media (min-width: …)` any `$md` prop emits), so there are no
|
|
21
|
+
* container queries to reach for and none are needed: the same direction every
|
|
22
|
+
* other responsive prop in this codebase is written in.
|
|
23
|
+
*/
|
|
24
|
+
import { SizableText, XStack, YStack, createStyledContext, styled } from '@hanzo/gui';
|
|
25
|
+
import { isValidElement } from 'react';
|
|
26
|
+
import { Box } from '../../box.js';
|
|
27
|
+
import { Label } from './label.js';
|
|
28
|
+
import { Separator } from './layout.js';
|
|
29
|
+
import { ink } from './ink.js';
|
|
30
|
+
import { slot } from './slot.js';
|
|
31
|
+
function FieldSet({ children, ...props }) {
|
|
32
|
+
return (_jsx(Box, { tag: "fieldset", className: "flex flex-col gap-6", ...slot('field-set'), ...props, children: children }));
|
|
33
|
+
}
|
|
34
|
+
function FieldLegend({ variant = 'legend', children, ...props }) {
|
|
35
|
+
return (_jsx(Box, { tag: "legend", className: variant === 'label' ? 'mb-3 text-sm font-medium' : 'mb-3 text-base font-medium', ...slot('field-legend'), "data-variant": variant, ...props, children: children }));
|
|
36
|
+
}
|
|
37
|
+
const FieldGroup = styled(YStack, {
|
|
38
|
+
name: 'FieldGroup',
|
|
39
|
+
width: '100%',
|
|
40
|
+
gap: '$7',
|
|
41
|
+
});
|
|
42
|
+
const FieldContext = /* @__PURE__ */ createStyledContext({
|
|
43
|
+
orientation: 'vertical',
|
|
44
|
+
});
|
|
45
|
+
const FieldFrame = styled(XStack, {
|
|
46
|
+
name: 'Field',
|
|
47
|
+
context: FieldContext,
|
|
48
|
+
width: '100%',
|
|
49
|
+
gap: '$3',
|
|
50
|
+
variants: {
|
|
51
|
+
orientation: {
|
|
52
|
+
vertical: { flexDirection: 'column' },
|
|
53
|
+
horizontal: { flexDirection: 'row', items: 'center' },
|
|
54
|
+
// Mobile-first, the way `vertical` already is: a column below `$md`,
|
|
55
|
+
// a row from `$md` up — this config's media props are min-width, so the
|
|
56
|
+
// base case is the narrow one and `$md` is where it widens.
|
|
57
|
+
responsive: {
|
|
58
|
+
flexDirection: 'column',
|
|
59
|
+
$md: { flexDirection: 'row', items: 'center' },
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
invalid: {
|
|
63
|
+
true: { color: '$red9' },
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
defaultVariants: { orientation: 'vertical' },
|
|
67
|
+
});
|
|
68
|
+
function Field({ orientation = 'vertical', ...props }) {
|
|
69
|
+
const invalid = props['data-invalid'];
|
|
70
|
+
return (_jsx(FieldFrame, { role: "group", ...slot('field'), "data-orientation": orientation, orientation: orientation, invalid: invalid, ...props }));
|
|
71
|
+
}
|
|
72
|
+
const FieldContent = styled(YStack, {
|
|
73
|
+
name: 'FieldContent',
|
|
74
|
+
flex: 1,
|
|
75
|
+
gap: '$1.5',
|
|
76
|
+
});
|
|
77
|
+
/** A `Field` nested directly inside a `FieldLabel` reads as a choice card. */
|
|
78
|
+
const isFieldChild = (children) => isValidElement(children) && children.type === Field;
|
|
79
|
+
function FieldLabel({ className, children, ...props }) {
|
|
80
|
+
const card = isFieldChild(children);
|
|
81
|
+
return (_jsx(Label, { ...slot('field-label'), gap: "$2", ...(card
|
|
82
|
+
? {
|
|
83
|
+
width: '100%',
|
|
84
|
+
flexDirection: 'column',
|
|
85
|
+
rounded: '$3',
|
|
86
|
+
borderWidth: 1,
|
|
87
|
+
borderColor: '$borderColor',
|
|
88
|
+
p: '$4',
|
|
89
|
+
}
|
|
90
|
+
: { self: 'flex-start' }), className: className, ...props, children: children }));
|
|
91
|
+
}
|
|
92
|
+
function FieldTitle({ children, ...props }) {
|
|
93
|
+
return (_jsx(XStack, { ...slot('field-label'), self: "flex-start", items: "center", gap: "$2", ...props, children: ink(children, SizableText, { fontSize: '$2', fontWeight: '500' }) }));
|
|
94
|
+
}
|
|
95
|
+
function FieldDescription({ children, ...props }) {
|
|
96
|
+
return (_jsx(SizableText, { ...slot('field-description'), fontSize: "$2", fontWeight: "400", color: "$quiet", ...props, children: children }));
|
|
97
|
+
}
|
|
98
|
+
function FieldSeparator({ children, ...props }) {
|
|
99
|
+
return (_jsxs(XStack, { ...slot('field-separator'), "data-content": !!children, items: "center", gap: "$2", ...props, children: [_jsx(Separator, { flex: 1 }), children && (_jsx(SizableText, { ...slot('field-separator-content'), color: "$quiet", fontSize: "$2", children: children })), children && _jsx(Separator, { flex: 1 })] }));
|
|
100
|
+
}
|
|
101
|
+
function fieldErrorContent(children, errors, issues) {
|
|
102
|
+
if (children)
|
|
103
|
+
return children;
|
|
104
|
+
const list = errors ?? issues;
|
|
105
|
+
if (!list)
|
|
106
|
+
return null;
|
|
107
|
+
const messages = list.filter((e) => !!e?.message);
|
|
108
|
+
if (messages.length === 0)
|
|
109
|
+
return null;
|
|
110
|
+
if (messages.length === 1)
|
|
111
|
+
return messages[0].message;
|
|
112
|
+
return (_jsx(Box, { tag: "ul", className: "ml-4 flex flex-col gap-1", style: { listStyleType: 'disc' }, ...slot('field-error-list'), children: messages.map((error, index) => (_jsx(Box, { tag: "li", className: "text-sm text-red9", children: error.message }, index))) }));
|
|
113
|
+
}
|
|
114
|
+
function FieldError({ children, errors, issues, ...props }) {
|
|
115
|
+
const content = fieldErrorContent(children, errors, issues);
|
|
116
|
+
if (!content)
|
|
117
|
+
return null;
|
|
118
|
+
return (_jsx(XStack, { role: "alert", ...slot('field-error'), ...props, children: ink(content, SizableText, { fontSize: '$2', fontWeight: '400', color: '$red9' }) }));
|
|
119
|
+
}
|
|
120
|
+
export { Field, FieldContent, FieldDescription, FieldError, FieldGroup, FieldLabel, FieldLegend, FieldSeparator, FieldSet, FieldTitle, };
|
|
121
|
+
//# sourceMappingURL=field.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"field.js","sourceRoot":"","sources":["../../../src/backends/gui/field.tsx"],"names":[],"mappings":"AAAA,Y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AC,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,KAAK,EAAmB;IACzE,MAAM,OAAO,GAAG,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;IAC3D,IAAI,CAAC,OAAO;QAAE,OAAO,IAAI,CAAA;IACzB,OAAO,CACL,KAAC,MAAM,IAAC,IAAI,EAAC,OAAO,KAAK,IAAI,CAAC,aAAa,CAAC,KAAM,KAAK,YACpD,GAAG,CAAC,OAAO,EAAE,WAAW,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,GAC1E,CACV,CAAA;AACH,CAAC;AAED,OAAO,EACL,KAAK,EACL,YAAY,EACZ,gBAAgB,EAChB,UAAU,EACV,UAAU,EACV,UAAU,EACV,WAAW,EACX,cAAc,EACd,QAAQ,EACR,UAAU,GACX,CAAA"}
|
|
@@ -4,47 +4,45 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
exports.Gantt = Gantt;
|
|
5
5
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
6
|
/**
|
|
7
|
-
* Gantt — a
|
|
8
|
-
* spanning its own start and end date.
|
|
7
|
+
* Gantt — a task list with a per-row progress track and a start/end date.
|
|
9
8
|
*
|
|
10
|
-
* One row is
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* needs no `Grid`.
|
|
9
|
+
* One row is three lines: name and percent, a filled track, then the two
|
|
10
|
+
* dates. The substrate is @hanzo/gui: `styled()` frames and theme tokens, so
|
|
11
|
+
* it renders on web, native (expo) and Tauri. An empty task list renders a
|
|
12
|
+
* placeholder rather than nothing.
|
|
15
13
|
*/
|
|
16
14
|
const gui_1 = require("@hanzo/gui");
|
|
17
15
|
const ink_1 = require("./ink.cjs");
|
|
18
16
|
const slot_1 = require("./slot.cjs");
|
|
19
|
-
const
|
|
17
|
+
const TRACK_HEIGHT = 32;
|
|
18
|
+
const GanttFrame = (0, gui_1.styled)(gui_1.YStack, {
|
|
20
19
|
name: 'Gantt',
|
|
21
20
|
bg: '$background',
|
|
22
21
|
borderWidth: 1,
|
|
23
22
|
borderColor: '$borderColor',
|
|
24
23
|
rounded: '$6',
|
|
25
24
|
p: '$6',
|
|
26
|
-
gap: '$4',
|
|
27
25
|
});
|
|
28
|
-
const
|
|
26
|
+
const RowFrame = (0, gui_1.styled)(gui_1.YStack, { name: 'GanttRow', gap: '$2' });
|
|
27
|
+
const TrackFrame = (0, gui_1.styled)(gui_1.YStack, {
|
|
29
28
|
name: 'GanttTrack',
|
|
30
|
-
height:
|
|
29
|
+
height: TRACK_HEIGHT,
|
|
31
30
|
rounded: '$3',
|
|
32
31
|
bg: '$edge',
|
|
33
32
|
overflow: 'hidden',
|
|
34
33
|
});
|
|
35
|
-
const
|
|
36
|
-
name: '
|
|
34
|
+
const BarFrame = (0, gui_1.styled)(gui_1.YStack, {
|
|
35
|
+
name: 'GanttBar',
|
|
37
36
|
height: '100%',
|
|
38
37
|
rounded: '$3',
|
|
39
38
|
bg: '$accentBackground',
|
|
40
39
|
});
|
|
41
|
-
const clamp = (n) => Math.min(100, Math.max(0, n));
|
|
42
40
|
function Gantt({ tasks = [], ...props }) {
|
|
43
|
-
return ((0, jsx_runtime_1.jsx)(
|
|
41
|
+
return ((0, jsx_runtime_1.jsx)(GanttFrame, { ...(0, slot_1.slot)('gantt'), ...props, children: tasks.length === 0 ? ((0, jsx_runtime_1.jsx)(gui_1.XStack, { ...(0, slot_1.slot)('gantt-empty'), items: "center", justify: "center", p: "$8", children: (0, ink_1.ink)('No tasks available. Add tasks to display Gantt chart.', gui_1.SizableText, {
|
|
44
42
|
size: '$2',
|
|
45
43
|
color: '$quiet',
|
|
46
|
-
}) })) : (tasks.map((task) => {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
44
|
+
}) })) : ((0, jsx_runtime_1.jsx)(gui_1.YStack, { gap: "$4", children: tasks.map((task) => {
|
|
45
|
+
const progress = Math.min(100, Math.max(0, task.progress ?? 0));
|
|
46
|
+
return ((0, jsx_runtime_1.jsxs)(RowFrame, { ...(0, slot_1.slot)('gantt-task'), "data-progress": progress, children: [(0, jsx_runtime_1.jsxs)(gui_1.XStack, { justify: "space-between", items: "center", children: [(0, ink_1.ink)(task.name, gui_1.SizableText, { size: '$3', fontWeight: '600' }), (0, ink_1.ink)(`${progress}%`, gui_1.SizableText, { size: '$3', color: '$quiet' })] }), (0, jsx_runtime_1.jsx)(TrackFrame, { ...(0, slot_1.slot)('gantt-track'), children: (0, jsx_runtime_1.jsx)(BarFrame, { ...(0, slot_1.slot)('gantt-bar'), width: `${progress}%` }) }), (0, jsx_runtime_1.jsxs)(gui_1.XStack, { justify: "space-between", children: [(0, ink_1.ink)(task.start.toLocaleDateString(), gui_1.SizableText, { size: '$1', color: '$quiet' }), (0, ink_1.ink)(task.end.toLocaleDateString(), gui_1.SizableText, { size: '$1', color: '$quiet' })] })] }, task.id));
|
|
47
|
+
}) })) }));
|
|
50
48
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { ComponentProps } from 'react';
|
|
2
1
|
export interface GanttTask {
|
|
3
2
|
id: string;
|
|
4
3
|
name: string;
|
|
@@ -7,13 +6,13 @@ export interface GanttTask {
|
|
|
7
6
|
/** 0–100. Defaults to 0. */
|
|
8
7
|
progress?: number;
|
|
9
8
|
}
|
|
10
|
-
declare const
|
|
9
|
+
declare const GanttFrame: import("@hanzogui/web").GuiComponent<import("@hanzogui/web").TamaDefer, import("@hanzogui/web").GuiElement, import("@hanzogui/core").RNGuiViewNonStyleProps, import("@hanzogui/web").StackStyleBase, {
|
|
11
10
|
elevation?: number | import("@hanzogui/web").SizeTokens | undefined;
|
|
12
11
|
fullscreen?: boolean | undefined;
|
|
13
12
|
}, import("@hanzogui/web").StaticConfigPublic>;
|
|
14
|
-
export type GanttProps = ComponentProps<typeof
|
|
13
|
+
export type GanttProps = Omit<import('react').ComponentProps<typeof GanttFrame>, 'children'> & {
|
|
15
14
|
tasks?: GanttTask[];
|
|
16
15
|
};
|
|
17
|
-
declare function Gantt({ tasks, ...props }: GanttProps): import("react").JSX.Element;
|
|
18
|
-
export {
|
|
16
|
+
export declare function Gantt({ tasks, ...props }: GanttProps): import("react").JSX.Element;
|
|
17
|
+
export {};
|
|
19
18
|
//# sourceMappingURL=gantt.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gantt.d.ts","sourceRoot":"","sources":["../../../src/backends/gui/gantt.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"gantt.d.ts","sourceRoot":"","sources":["../../../src/backends/gui/gantt.tsx"],"names":[],"mappings":"AAgBA,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,IAAI,CAAA;IACX,GAAG,EAAE,IAAI,CAAA;IACT,4BAA4B;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED,QAAA,MAAM,UAAU;;;8CAOd,CAAA;AAmBF,MAAM,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,OAAO,EAAE,cAAc,CAAC,OAAO,UAAU,CAAC,EAAE,UAAU,CAAC,GAAG;IAC7F,KAAK,CAAC,EAAE,SAAS,EAAE,CAAA;CACpB,CAAA;AAED,wBAAgB,KAAK,CAAC,EAAE,KAAU,EAAE,GAAG,KAAK,EAAE,EAAE,UAAU,+BAkCzD"}
|