@takesix/react 0.2.1 → 0.3.0

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 CHANGED
@@ -77,11 +77,16 @@ theme with the `theme` prop, or override variables through `className`:
77
77
 
78
78
  ### What is shown
79
79
 
80
- - **One level per screen**, with a breadcrumb. There is no header for the
81
- opened block: if a level needs a title or summary, make it the first block.
80
+ - **One level per screen**, with a breadcrumb below the top level. The header
81
+ shows the document's title and description on the top level, and the opened
82
+ block's below it.
83
+ - **Short screens**: a level taller than the space it has is shrunk to fit
84
+ (down to 60%), instead of scrolling.
82
85
  - **Cards** show icon, title and description, and "N more inside" when the
83
- block has children (direct children only). Click anywhere on such a card to
84
- open it; text stays selectable.
86
+ block has children (direct children only). Click anywhere on such a card,
87
+ text included, to open it; selecting text to copy it does not open it.
88
+ - **Phones**: the level keeps its structure. Blocks of a third or a half show
89
+ only icon, title and "N more inside"; the gaps between columns narrow.
85
90
 
86
91
  - **Arrows**: a link between nested blocks is drawn between their ancestors on
87
92
  the current screen. Several links between the same pair of blocks merge into
@@ -108,7 +113,9 @@ In edit mode you can:
108
113
  - group blocks: "Group blocks" in the toolbar, select two or more, Group. They
109
114
  move into a new block ("New group") where the first of them was, which frees
110
115
  room on a full level;
111
- - reorder blocks by dragging the dotted handle on their left;
116
+ - reorder blocks by dragging the dotted handle on their left, or focus the
117
+ handle and use the arrow keys; drop on the middle of another card to move the
118
+ block inside it, or on a breadcrumb to move it up to that level;
112
119
  - link blocks: press the arrow button on the source, then click the target.
113
120
  The target may be on any level: while linking, open blocks ("N more inside")
114
121
  or go back up to find it. A block's own ancestors and descendants cannot be
@@ -5,8 +5,8 @@ export interface CardRect {
5
5
  width: number;
6
6
  height: number;
7
7
  }
8
- /** Where a dragged block would land relative to this card. */
9
- export type DropPosition = 'before' | 'after';
8
+ /** Where a dragged block lands: next to this card, or inside it as its last child. */
9
+ export type DropPosition = 'before' | 'inside' | 'after';
10
10
  /** Grid columns (of 6) each size spans. */
11
11
  export declare const SIZE_SPAN: Record<Size, number>;
12
12
  interface Props {
@@ -27,9 +27,13 @@ interface Props {
27
27
  /** Drag and drop to reorder, edit mode only. */
28
28
  isDragged: boolean;
29
29
  dropPosition: DropPosition | null;
30
+ /** The dragged block may move into this one (it has room for another child). */
31
+ canDropInside: boolean;
30
32
  onDragStartBlock: (id: string) => void;
31
33
  onDragOverBlock: (id: string, position: DropPosition) => void;
32
34
  onDragEndBlock: () => void;
35
+ /** Keyboard reordering from the drag handle: one place earlier (-1) or later (1). */
36
+ onMoveBy: (id: string, delta: -1 | 1) => void;
33
37
  onShowDetails: (id: string) => void;
34
38
  /** Choosing blocks to group: a click selects instead of opening. */
35
39
  selectable: boolean;
@@ -37,5 +41,5 @@ interface Props {
37
41
  onToggleSelect: (id: string) => void;
38
42
  onResize: (id: string, size: Size) => void;
39
43
  }
40
- export declare function BlockCard({ block, editing, onRename, onDescribe, onDelete, onAddChild, onDrillIn, connectingFrom, canLinkTo, isConnected, onStartConnect, onConnectTarget, onRegisterEl, isDragged, dropPosition, onDragStartBlock, onDragOverBlock, onDragEndBlock, onShowDetails, selectable, selected, onToggleSelect, onResize, }: Props): import("react").JSX.Element;
44
+ export declare function BlockCard({ block, editing, onRename, onDescribe, onDelete, onAddChild, onDrillIn, connectingFrom, canLinkTo, isConnected, onStartConnect, onConnectTarget, onRegisterEl, isDragged, dropPosition, canDropInside, onDragStartBlock, onDragOverBlock, onDragEndBlock, onMoveBy, onShowDetails, selectable, selected, onToggleSelect, onResize, }: Props): import("react").JSX.Element;
41
45
  export {};
package/dist/fit.d.ts ADDED
@@ -0,0 +1,14 @@
1
+ import type { Rect } from './geometry.js';
2
+ /** A level is never shrunk below this; on even shorter screens it overflows. */
3
+ export declare const MIN_ZOOM = 0.6;
4
+ /**
5
+ * Zoom for a level so that its rows fit the height it has. Only ever shrinks:
6
+ * shrinking widens the columns and changes how the text wraps, so growing back
7
+ * on the next measurement could go back and forth forever. The caller starts
8
+ * again from 1 when the space or the blocks change.
9
+ *
10
+ * Works on screen rects, which already include the current zoom: `available`
11
+ * is the height of the grid, `items` its children, `rowGap` the gap between
12
+ * rows in CSS pixels before zoom.
13
+ */
14
+ export declare function fitZoom(available: number, items: Rect[], rowGap: number, current: number): number;