@whity/ui 0.0.0-stage → 0.5.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 +107 -3
- package/package.json +192 -6
- package/src/access-denied.stories.tsx +179 -0
- package/src/access-denied.tsx +305 -0
- package/src/action-proposal.tsx +302 -0
- package/src/actor-chip.tsx +71 -0
- package/src/agent-activity.tsx +163 -0
- package/src/agent-collaboration.stories.tsx +156 -0
- package/src/agent-run-status.tsx +196 -0
- package/src/alert-dialog.stories.tsx +45 -0
- package/src/alert-dialog.tsx +147 -0
- package/src/alert.stories.tsx +91 -0
- package/src/alert.tsx +89 -0
- package/src/app-sidebar.stories.tsx +195 -0
- package/src/app-sidebar.tsx +500 -0
- package/src/approval-queue.tsx +108 -0
- package/src/audience-group-picker.stories.tsx +198 -0
- package/src/audience-group-picker.tsx +362 -0
- package/src/audience-people-picker.stories.tsx +102 -0
- package/src/audience-people-picker.tsx +279 -0
- package/src/avatar.tsx +83 -0
- package/src/badge.stories.tsx +105 -0
- package/src/badge.tsx +68 -0
- package/src/beta-warning.stories.tsx +79 -0
- package/src/beta-warning.tsx +189 -0
- package/src/bilingual-input.stories.tsx +82 -0
- package/src/bilingual-input.tsx +183 -0
- package/src/breadcrumb.stories.tsx +51 -0
- package/src/breadcrumb.tsx +90 -0
- package/src/button.stories.tsx +87 -0
- package/src/button.tsx +118 -0
- package/src/card.stories.tsx +423 -0
- package/src/card.tsx +180 -0
- package/src/chart.stories.tsx +66 -0
- package/src/chart.tsx +228 -0
- package/src/checkbox.stories.tsx +62 -0
- package/src/checkbox.tsx +54 -0
- package/src/collapsible.stories.tsx +48 -0
- package/src/collapsible.tsx +34 -0
- package/src/color-card.stories.tsx +61 -0
- package/src/color-card.tsx +270 -0
- package/src/color-picker.stories.tsx +65 -0
- package/src/color-picker.tsx +425 -0
- package/src/command-palette.tsx +306 -0
- package/src/copy-block.stories.tsx +38 -0
- package/src/copy-block.tsx +85 -0
- package/src/data-table.stories.tsx +200 -0
- package/src/data-table.tsx +1106 -0
- package/src/date-picker.stories.tsx +61 -0
- package/src/date-picker.tsx +422 -0
- package/src/design-cards.stories.tsx +458 -0
- package/src/dialog.stories.tsx +48 -0
- package/src/dialog.tsx +166 -0
- package/src/documents/barcode-svg.stories.tsx +72 -0
- package/src/documents/barcode-svg.tsx +79 -0
- package/src/dropdown-menu.stories.tsx +77 -0
- package/src/dropdown-menu.tsx +271 -0
- package/src/editor/behaviour.ts +279 -0
- package/src/editor/block-ids.ts +44 -0
- package/src/editor/block-list.tsx +101 -0
- package/src/editor/block-toolbar.tsx +477 -0
- package/src/editor/bubble.tsx +93 -0
- package/src/editor/catalogue.ts +103 -0
- package/src/editor/collab-rail.tsx +746 -0
- package/src/editor/collab.stories.tsx +207 -0
- package/src/editor/collab.ts +87 -0
- package/src/editor/contract.ts +408 -0
- package/src/editor/convert.ts +362 -0
- package/src/editor/doc-editor.stories.tsx +98 -0
- package/src/editor/doc-editor.tsx +1287 -0
- package/src/editor/editor.css +536 -0
- package/src/editor/extensions.ts +86 -0
- package/src/editor/field-picker.tsx +107 -0
- package/src/editor/fields.ts +100 -0
- package/src/editor/gutter.tsx +367 -0
- package/src/editor/index.ts +22 -0
- package/src/editor/label-sheet.tsx +289 -0
- package/src/editor/labels.ts +310 -0
- package/src/editor/link-tools.tsx +141 -0
- package/src/editor/node-views.tsx +450 -0
- package/src/editor/page-view.tsx +353 -0
- package/src/editor/publish-check.tsx +182 -0
- package/src/editor/rich-blocks.stories.tsx +146 -0
- package/src/editor/sample.ts +40 -0
- package/src/editor/schema-rich.ts +150 -0
- package/src/editor/schema.ts +315 -0
- package/src/editor/services.tsx +127 -0
- package/src/editor/slash.ts +64 -0
- package/src/editor/suggesting.ts +372 -0
- package/src/editor/suggestions.ts +763 -0
- package/src/editor/table-keys.ts +66 -0
- package/src/editor/templates.stories.tsx +324 -0
- package/src/editor/toolbar.tsx +358 -0
- package/src/empty-state.stories.tsx +51 -0
- package/src/empty-state.tsx +100 -0
- package/src/empty-state.usage-notes.md +30 -0
- package/src/form.stories.tsx +112 -0
- package/src/form.tsx +176 -0
- package/src/globals.css +20 -0
- package/src/icon-button.tsx +85 -0
- package/src/icon-map.ts +244 -0
- package/src/icon.tsx +41 -0
- package/src/index.ts +67 -0
- package/src/input.stories.tsx +157 -0
- package/src/input.tsx +759 -0
- package/src/locked-screen.stories.tsx +29 -0
- package/src/locked-screen.tsx +61 -0
- package/src/mark.tsx +62 -0
- package/src/math-text.stories.tsx +33 -0
- package/src/math-text.tsx +43 -0
- package/src/menu-bar.stories.tsx +198 -0
- package/src/menu-bar.tsx +373 -0
- package/src/money/currency.ts +230 -0
- package/src/page-header.stories.tsx +95 -0
- package/src/page-header.tsx +122 -0
- package/src/page-shell.stories.tsx +42 -0
- package/src/page-shell.tsx +32 -0
- package/src/pagination.stories.tsx +45 -0
- package/src/pagination.tsx +98 -0
- package/src/plugin-card.stories.tsx +180 -0
- package/src/plugin-card.tsx +848 -0
- package/src/popover.stories.tsx +48 -0
- package/src/popover.tsx +55 -0
- package/src/radio-group.stories.tsx +26 -0
- package/src/radio-group.tsx +44 -0
- package/src/route-flow/editor.tsx +1014 -0
- package/src/route-flow/model.ts +716 -0
- package/src/scope-grant.tsx +139 -0
- package/src/screen-too-small.stories.tsx +61 -0
- package/src/screen-too-small.tsx +104 -0
- package/src/select.stories.tsx +44 -0
- package/src/select.tsx +197 -0
- package/src/separator.stories.tsx +34 -0
- package/src/separator.tsx +34 -0
- package/src/sheet.stories.tsx +49 -0
- package/src/sheet.tsx +168 -0
- package/src/skeleton.stories.tsx +28 -0
- package/src/skeleton.tsx +19 -0
- package/src/slider.stories.tsx +78 -0
- package/src/slider.tsx +300 -0
- package/src/spinner.stories.tsx +33 -0
- package/src/spinner.tsx +55 -0
- package/src/switch.stories.tsx +42 -0
- package/src/switch.tsx +41 -0
- package/src/switcher.stories.tsx +111 -0
- package/src/switcher.tsx +131 -0
- package/src/table.stories.tsx +48 -0
- package/src/table.tsx +121 -0
- package/src/tabs.stories.tsx +74 -0
- package/src/tabs.tsx +90 -0
- package/src/tag-input.stories.tsx +67 -0
- package/src/tag-input.tsx +117 -0
- package/src/tenant-logo.tsx +63 -0
- package/src/tenant-switcher.stories.tsx +38 -0
- package/src/tenant-switcher.tsx +164 -0
- package/src/textarea.stories.tsx +27 -0
- package/src/textarea.tsx +18 -0
- package/src/theme-mode.ts +52 -0
- package/src/time-picker.stories.tsx +62 -0
- package/src/time-picker.tsx +615 -0
- package/src/toggle-group.tsx +138 -0
- package/src/tooltip.stories.tsx +43 -0
- package/src/tooltip.tsx +73 -0
- package/src/top-nav.stories.tsx +58 -0
- package/src/top-nav.tsx +324 -0
- package/src/undo-bar.tsx +107 -0
- package/src/utils.ts +45 -0
- package/src/view-toggle.stories.tsx +84 -0
- package/src/view-toggle.tsx +110 -0
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import type { Editor } from "@tiptap/core"
|
|
5
|
+
|
|
6
|
+
import { Icon } from "../icon"
|
|
7
|
+
import { Input } from "../input"
|
|
8
|
+
import { Popover, PopoverContent, PopoverTrigger } from "../popover"
|
|
9
|
+
import { ToggleGroup } from "../toggle-group"
|
|
10
|
+
import { cn } from "../utils"
|
|
11
|
+
import type { LabelGrid, ResolvedThemeTokens } from "./contract"
|
|
12
|
+
import { fill, type EditorLabels } from "./labels"
|
|
13
|
+
import { themeStyle } from "./page-view"
|
|
14
|
+
|
|
15
|
+
/** 96 dpi, as the page view (EditorPageView). */
|
|
16
|
+
const PX_PER_MM = 96 / 25.4
|
|
17
|
+
|
|
18
|
+
/** The sheets a label document prints on (E.43): A4 or Letter, portrait. */
|
|
19
|
+
export const SHEETS = {
|
|
20
|
+
A4: { widthMm: 210, heightMm: 297 },
|
|
21
|
+
Letter: { widthMm: 215.9, heightMm: 279.4 },
|
|
22
|
+
} as const
|
|
23
|
+
export type SheetSize = keyof typeof SHEETS
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Common label stock. The grid is centred on the sheet, which matches these
|
|
27
|
+
* sheets' own margins to within half a millimetre. A certificate is a
|
|
28
|
+
* one-label sheet.
|
|
29
|
+
*/
|
|
30
|
+
export const LABEL_PRESETS: { id: string; name: string; sheet: SheetSize; grid: LabelGrid }[] = [
|
|
31
|
+
{ id: "avery-l7160", name: "Avery L7160", sheet: "A4", grid: { columns: 3, rows: 7, size: { widthMm: 63.5, heightMm: 38.1 }, gapMm: 2.5, gapYMm: 0 } },
|
|
32
|
+
{ id: "avery-l7159", name: "Avery L7159", sheet: "A4", grid: { columns: 3, rows: 8, size: { widthMm: 63.5, heightMm: 33.9 }, gapMm: 2.5, gapYMm: 0 } },
|
|
33
|
+
{ id: "avery-l7165", name: "Avery L7165", sheet: "A4", grid: { columns: 2, rows: 4, size: { widthMm: 99.1, heightMm: 67.7 }, gapMm: 2.5, gapYMm: 0 } },
|
|
34
|
+
{ id: "avery-l7651", name: "Avery L7651", sheet: "A4", grid: { columns: 5, rows: 13, size: { widthMm: 38.1, heightMm: 21.2 }, gapMm: 2.5, gapYMm: 0 } },
|
|
35
|
+
{ id: "letter-2x5", name: "Letter 2 × 5", sheet: "Letter", grid: { columns: 2, rows: 5, size: { widthMm: 101.6, heightMm: 50.8 }, gapMm: 4.8, gapYMm: 0 } },
|
|
36
|
+
{ id: "certificate", name: "Certificate", sheet: "A4", grid: { columns: 1, rows: 1, size: { widthMm: 190, heightMm: 277 }, gapMm: 0 } },
|
|
37
|
+
]
|
|
38
|
+
|
|
39
|
+
export const DEFAULT_LABEL_GRID: LabelGrid = LABEL_PRESETS[0].grid
|
|
40
|
+
|
|
41
|
+
/** Where each label sits on the sheet, in mm from the top start corner. */
|
|
42
|
+
export function labelCells(grid: LabelGrid, sheet: SheetSize): { x: number; y: number }[] {
|
|
43
|
+
const { widthMm, heightMm } = SHEETS[sheet]
|
|
44
|
+
const gapX = grid.gapMm
|
|
45
|
+
const gapY = grid.gapYMm ?? grid.gapMm
|
|
46
|
+
const left = (widthMm - grid.columns * grid.size.widthMm - (grid.columns - 1) * gapX) / 2
|
|
47
|
+
const top = (heightMm - grid.rows * grid.size.heightMm - (grid.rows - 1) * gapY) / 2
|
|
48
|
+
const cells: { x: number; y: number }[] = []
|
|
49
|
+
for (let r = 0; r < grid.rows; r++) {
|
|
50
|
+
for (let c = 0; c < grid.columns; c++) {
|
|
51
|
+
cells.push({ x: left + c * (grid.size.widthMm + gapX), y: top + r * (grid.size.heightMm + gapY) })
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return cells
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** Whether the labels fit on the sheet. */
|
|
58
|
+
export function gridFits(grid: LabelGrid, sheet: SheetSize): boolean {
|
|
59
|
+
const cells = labelCells(grid, sheet)
|
|
60
|
+
const last = cells[cells.length - 1]
|
|
61
|
+
const { widthMm, heightMm } = SHEETS[sheet]
|
|
62
|
+
return !!last && cells[0].x >= 0 && cells[0].y >= 0 && last.x + grid.size.widthMm <= widthMm + 0.01 && last.y + grid.size.heightMm <= heightMm + 0.01
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** The inner padding of a label, in px (2 mm). */
|
|
66
|
+
const LABEL_PAD = Math.round(2 * PX_PER_MM)
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* The page view of a label sheet (E.43): one sheet with the grid. The first
|
|
70
|
+
* label is the one you edit; the others repeat it, as Print fills one label
|
|
71
|
+
* per record or CSV row. Content that runs past the label is cut off on
|
|
72
|
+
* paper, so the label shows where it ends and `onOverflow` reports it.
|
|
73
|
+
*/
|
|
74
|
+
export function LabelSheetView({
|
|
75
|
+
editor,
|
|
76
|
+
grid,
|
|
77
|
+
sheet,
|
|
78
|
+
zoom,
|
|
79
|
+
theme,
|
|
80
|
+
labels,
|
|
81
|
+
onOverflow,
|
|
82
|
+
children,
|
|
83
|
+
}: {
|
|
84
|
+
editor: Editor | null
|
|
85
|
+
grid: LabelGrid
|
|
86
|
+
sheet: SheetSize
|
|
87
|
+
zoom: number
|
|
88
|
+
/** The document's resolved theme: the print colour, and the headings with `title-and-headings`. */
|
|
89
|
+
theme?: ResolvedThemeTokens | null
|
|
90
|
+
labels: EditorLabels
|
|
91
|
+
onOverflow?: (overflow: boolean) => void
|
|
92
|
+
children: React.ReactNode
|
|
93
|
+
}) {
|
|
94
|
+
const cells = labelCells(grid, sheet)
|
|
95
|
+
const w = SHEETS[sheet].widthMm * PX_PER_MM
|
|
96
|
+
const h = SHEETS[sheet].heightMm * PX_PER_MM
|
|
97
|
+
const copies = React.useRef<(HTMLDivElement | null)[]>([])
|
|
98
|
+
const first = React.useRef<HTMLDivElement>(null)
|
|
99
|
+
const [overflow, setOverflow] = React.useState(false)
|
|
100
|
+
|
|
101
|
+
React.useEffect(() => {
|
|
102
|
+
if (!editor) return
|
|
103
|
+
let frame = 0
|
|
104
|
+
const mirror = () => {
|
|
105
|
+
cancelAnimationFrame(frame)
|
|
106
|
+
frame = requestAnimationFrame(() => {
|
|
107
|
+
if (editor.isDestroyed) return
|
|
108
|
+
const source = editor.view.dom
|
|
109
|
+
for (const slot of copies.current) {
|
|
110
|
+
if (!slot) continue
|
|
111
|
+
const copy = source.cloneNode(true) as HTMLElement
|
|
112
|
+
copy.removeAttribute("contenteditable")
|
|
113
|
+
copy.removeAttribute("role")
|
|
114
|
+
copy.removeAttribute("aria-label")
|
|
115
|
+
copy.removeAttribute("aria-multiline")
|
|
116
|
+
copy.classList.remove("ProseMirror-focused")
|
|
117
|
+
slot.replaceChildren(copy)
|
|
118
|
+
}
|
|
119
|
+
const box = first.current
|
|
120
|
+
const over = !!box && source.scrollHeight > box.clientHeight - 2 * LABEL_PAD + 1
|
|
121
|
+
setOverflow(over)
|
|
122
|
+
})
|
|
123
|
+
}
|
|
124
|
+
mirror()
|
|
125
|
+
editor.on("update", mirror)
|
|
126
|
+
const dom = editor.view.dom
|
|
127
|
+
dom.addEventListener("load", mirror, true)
|
|
128
|
+
return () => {
|
|
129
|
+
cancelAnimationFrame(frame)
|
|
130
|
+
editor.off("update", mirror)
|
|
131
|
+
dom.removeEventListener("load", mirror, true)
|
|
132
|
+
}
|
|
133
|
+
}, [editor, grid, sheet])
|
|
134
|
+
|
|
135
|
+
React.useEffect(() => onOverflow?.(overflow), [overflow, onOverflow])
|
|
136
|
+
|
|
137
|
+
const place = (i: number): React.CSSProperties => ({
|
|
138
|
+
insetInlineStart: cells[i].x * PX_PER_MM,
|
|
139
|
+
top: cells[i].y * PX_PER_MM,
|
|
140
|
+
width: grid.size.widthMm * PX_PER_MM,
|
|
141
|
+
height: grid.size.heightMm * PX_PER_MM,
|
|
142
|
+
padding: LABEL_PAD,
|
|
143
|
+
})
|
|
144
|
+
|
|
145
|
+
return (
|
|
146
|
+
<div className="wy-pv" style={{ zoom, width: w } as React.CSSProperties}>
|
|
147
|
+
<div className="wy-pv__stack wy-ls light" data-accent-use={theme?.accentUse} style={{ ...themeStyle(theme), width: w, height: h }}>
|
|
148
|
+
<div className="wy-pv__page" style={{ top: 0, width: w, height: h }} aria-hidden="true" />
|
|
149
|
+
{cells.map((_, i) =>
|
|
150
|
+
i === 0 ? (
|
|
151
|
+
<div key={i} ref={first} className={cn("wy-ls__label is-first", overflow && "is-over")} style={place(i)}>
|
|
152
|
+
{children}
|
|
153
|
+
{overflow && (
|
|
154
|
+
<span className="wy-ls__over" role="status">
|
|
155
|
+
<Icon name="alert" size={12} />
|
|
156
|
+
{labels.labelOverflow}
|
|
157
|
+
</span>
|
|
158
|
+
)}
|
|
159
|
+
</div>
|
|
160
|
+
) : (
|
|
161
|
+
<div
|
|
162
|
+
key={i}
|
|
163
|
+
ref={(el) => {
|
|
164
|
+
copies.current[i - 1] = el
|
|
165
|
+
}}
|
|
166
|
+
className="wy-ls__label"
|
|
167
|
+
style={place(i)}
|
|
168
|
+
aria-hidden="true"
|
|
169
|
+
inert
|
|
170
|
+
/>
|
|
171
|
+
)
|
|
172
|
+
)}
|
|
173
|
+
</div>
|
|
174
|
+
</div>
|
|
175
|
+
)
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/** The sheet setup for a label document: a stock preset, or the grid by hand. */
|
|
179
|
+
export function LabelSetup({
|
|
180
|
+
grid,
|
|
181
|
+
sheet,
|
|
182
|
+
onChange,
|
|
183
|
+
labels,
|
|
184
|
+
disabled,
|
|
185
|
+
}: {
|
|
186
|
+
grid: LabelGrid
|
|
187
|
+
sheet: SheetSize
|
|
188
|
+
onChange: (grid: LabelGrid, sheet: SheetSize) => void
|
|
189
|
+
labels: EditorLabels
|
|
190
|
+
disabled?: boolean
|
|
191
|
+
}) {
|
|
192
|
+
const preset = LABEL_PRESETS.find((p) => p.sheet === sheet && sameGrid(p.grid, grid))
|
|
193
|
+
const fits = gridFits(grid, sheet)
|
|
194
|
+
const num = (value: number, set: (n: number) => LabelGrid, opts: { min: number; max: number; step: number; label: string }) => (
|
|
195
|
+
<Input
|
|
196
|
+
label={opts.label}
|
|
197
|
+
type="number"
|
|
198
|
+
inputMode="decimal"
|
|
199
|
+
min={opts.min}
|
|
200
|
+
max={opts.max}
|
|
201
|
+
step={opts.step}
|
|
202
|
+
value={value}
|
|
203
|
+
onChange={(e) => {
|
|
204
|
+
const n = Number(e.target.value)
|
|
205
|
+
if (Number.isFinite(n) && n >= opts.min && n <= opts.max) onChange(set(n), sheet)
|
|
206
|
+
}}
|
|
207
|
+
/>
|
|
208
|
+
)
|
|
209
|
+
|
|
210
|
+
return (
|
|
211
|
+
<Popover>
|
|
212
|
+
<PopoverTrigger asChild>
|
|
213
|
+
<button
|
|
214
|
+
type="button"
|
|
215
|
+
disabled={disabled}
|
|
216
|
+
className="inline-flex h-7 items-center gap-1 rounded-control px-2 text-xs text-foreground hover:bg-accent disabled:opacity-50"
|
|
217
|
+
>
|
|
218
|
+
<Icon name="table" size={14} />
|
|
219
|
+
{fill(labels.labelGrid, { columns: grid.columns, rows: grid.rows })}
|
|
220
|
+
<Icon name="chevron-down" size={12} />
|
|
221
|
+
</button>
|
|
222
|
+
</PopoverTrigger>
|
|
223
|
+
<PopoverContent align="end" className="grid w-[300px] gap-3">
|
|
224
|
+
<div className="grid gap-1">
|
|
225
|
+
<span className="text-xs font-semibold text-foreground">{labels.labelStock}</span>
|
|
226
|
+
<div role="listbox" aria-label={labels.labelStock} className="grid gap-0.5">
|
|
227
|
+
{LABEL_PRESETS.map((p) => (
|
|
228
|
+
<button
|
|
229
|
+
key={p.id}
|
|
230
|
+
type="button"
|
|
231
|
+
role="option"
|
|
232
|
+
aria-selected={p === preset}
|
|
233
|
+
onClick={() => onChange(p.grid, p.sheet)}
|
|
234
|
+
className={cn(
|
|
235
|
+
"flex items-center justify-between rounded-control px-2 py-1.5 text-start text-sm hover:bg-accent",
|
|
236
|
+
p === preset && "bg-primary-tint text-primary-tint-foreground"
|
|
237
|
+
)}
|
|
238
|
+
>
|
|
239
|
+
<span>{p.id === "certificate" ? labels.labelCertificate : p.name}</span>
|
|
240
|
+
<span className="text-xs text-muted-foreground" dir="ltr">
|
|
241
|
+
{p.sheet} · {p.grid.columns} × {p.grid.rows}
|
|
242
|
+
</span>
|
|
243
|
+
</button>
|
|
244
|
+
))}
|
|
245
|
+
</div>
|
|
246
|
+
</div>
|
|
247
|
+
<div className="grid grid-cols-2 gap-2">
|
|
248
|
+
<div className="col-span-2 flex items-center justify-between gap-2 text-xs text-muted-foreground">
|
|
249
|
+
{labels.labelSheet}
|
|
250
|
+
<ToggleGroup
|
|
251
|
+
size="sm"
|
|
252
|
+
label={labels.labelSheet}
|
|
253
|
+
required
|
|
254
|
+
value={sheet}
|
|
255
|
+
onChange={(v) => v && onChange(grid, v as SheetSize)}
|
|
256
|
+
options={[
|
|
257
|
+
{ value: "A4", label: "A4" },
|
|
258
|
+
{ value: "Letter", label: "Letter" },
|
|
259
|
+
]}
|
|
260
|
+
/>
|
|
261
|
+
</div>
|
|
262
|
+
{num(grid.columns, (n) => ({ ...grid, columns: Math.round(n) }), { min: 1, max: 10, step: 1, label: labels.labelColumns })}
|
|
263
|
+
{num(grid.rows, (n) => ({ ...grid, rows: Math.round(n) }), { min: 1, max: 30, step: 1, label: labels.labelRows })}
|
|
264
|
+
{num(grid.size.widthMm, (n) => ({ ...grid, size: { ...grid.size, widthMm: n } }), { min: 10, max: 216, step: 0.1, label: labels.labelWidth })}
|
|
265
|
+
{num(grid.size.heightMm, (n) => ({ ...grid, size: { ...grid.size, heightMm: n } }), { min: 10, max: 297, step: 0.1, label: labels.labelHeight })}
|
|
266
|
+
{num(grid.gapMm, (n) => ({ ...grid, gapMm: n }), { min: 0, max: 20, step: 0.1, label: labels.labelGapX })}
|
|
267
|
+
{num(grid.gapYMm ?? grid.gapMm, (n) => ({ ...grid, gapYMm: n }), { min: 0, max: 20, step: 0.1, label: labels.labelGapY })}
|
|
268
|
+
</div>
|
|
269
|
+
{!fits && (
|
|
270
|
+
<p role="alert" className="m-0 flex items-center gap-1.5 text-xs text-error-text">
|
|
271
|
+
<Icon name="alert" size={12} />
|
|
272
|
+
{labels.labelTooBig}
|
|
273
|
+
</p>
|
|
274
|
+
)}
|
|
275
|
+
</PopoverContent>
|
|
276
|
+
</Popover>
|
|
277
|
+
)
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
function sameGrid(a: LabelGrid, b: LabelGrid): boolean {
|
|
281
|
+
return (
|
|
282
|
+
a.columns === b.columns &&
|
|
283
|
+
a.rows === b.rows &&
|
|
284
|
+
a.size.widthMm === b.size.widthMm &&
|
|
285
|
+
a.size.heightMm === b.size.heightMm &&
|
|
286
|
+
a.gapMm === b.gapMm &&
|
|
287
|
+
(a.gapYMm ?? a.gapMm) === (b.gapYMm ?? b.gapMm)
|
|
288
|
+
)
|
|
289
|
+
}
|
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every string the editor shows, with its English default. Pass Arabic (or
|
|
3
|
+
* any language) through `labels`; the feature layer fills it from t().
|
|
4
|
+
*/
|
|
5
|
+
export const EDITOR_LABELS = {
|
|
6
|
+
back: "Back",
|
|
7
|
+
documentTitle: "Document title",
|
|
8
|
+
untitled: "Untitled",
|
|
9
|
+
saved: "Saved {time}",
|
|
10
|
+
saving: "Saving…",
|
|
11
|
+
offline: "Offline. Changes save when you’re back online",
|
|
12
|
+
saveFailed: "Not saved. Try again",
|
|
13
|
+
modeEditing: "Editing",
|
|
14
|
+
modeViewing: "Viewing",
|
|
15
|
+
modeMenu: "Mode",
|
|
16
|
+
modeEditingHint: "Change the document directly",
|
|
17
|
+
modeViewingHint: "Read only",
|
|
18
|
+
formatting: "Formatting",
|
|
19
|
+
undo: "Undo",
|
|
20
|
+
redo: "Redo",
|
|
21
|
+
styleMenu: "Text style",
|
|
22
|
+
normalText: "Normal text",
|
|
23
|
+
bold: "Bold",
|
|
24
|
+
italic: "Italic",
|
|
25
|
+
underline: "Underline",
|
|
26
|
+
strike: "Strikethrough",
|
|
27
|
+
code: "Code",
|
|
28
|
+
link: "Link",
|
|
29
|
+
highlight: "Highlight",
|
|
30
|
+
insert: "Insert",
|
|
31
|
+
outline: "Outline",
|
|
32
|
+
outlineEmpty: "Headings appear here",
|
|
33
|
+
selection: "Selection",
|
|
34
|
+
linkAddress: "Link address",
|
|
35
|
+
linkApply: "Apply",
|
|
36
|
+
linkOpen: "Open link",
|
|
37
|
+
linkCopy: "Copy link",
|
|
38
|
+
linkEdit: "Edit link",
|
|
39
|
+
linkRemove: "Remove link",
|
|
40
|
+
addBelow: "Add a block below",
|
|
41
|
+
dragHandle: "Drag to move, click for options",
|
|
42
|
+
blockMenu: "Block options",
|
|
43
|
+
turnInto: "Turn into",
|
|
44
|
+
duplicate: "Duplicate",
|
|
45
|
+
copyLinkToBlock: "Copy link to block",
|
|
46
|
+
moveUp: "Move up",
|
|
47
|
+
moveDown: "Move down",
|
|
48
|
+
delete: "Delete",
|
|
49
|
+
searchBlocks: "Search blocks",
|
|
50
|
+
noBlocks: "No blocks match",
|
|
51
|
+
slashMove: "↑↓ to move",
|
|
52
|
+
slashInsert: "Enter to insert",
|
|
53
|
+
slashInsertAfter: "Enter inserts after this line",
|
|
54
|
+
slashClose: "Esc to close",
|
|
55
|
+
placeholder: "Type / for blocks, {{ for fields, or just write",
|
|
56
|
+
laterBlock: "{block} block · edited in a later version",
|
|
57
|
+
words: "{n} words",
|
|
58
|
+
word: "1 word",
|
|
59
|
+
lastEdited: "Last edited by {name} at {time}",
|
|
60
|
+
english: "English",
|
|
61
|
+
arabic: "Arabic",
|
|
62
|
+
kindTemplate: "Template",
|
|
63
|
+
kindLetter: "Letter",
|
|
64
|
+
kindReport: "Report",
|
|
65
|
+
kindNote: "Note",
|
|
66
|
+
kindWiki: "Wiki page",
|
|
67
|
+
kindLabel: "Label sheet",
|
|
68
|
+
groupBasic: "Basic",
|
|
69
|
+
groupLists: "Lists",
|
|
70
|
+
groupStructure: "Structure",
|
|
71
|
+
groupMedia: "Media",
|
|
72
|
+
groupWhity: "Whity",
|
|
73
|
+
blockCallout: "Callout",
|
|
74
|
+
blockCalloutHint: "A note or something important",
|
|
75
|
+
blockToggle: "Toggle",
|
|
76
|
+
blockToggleHint: "A line that hides blocks under it",
|
|
77
|
+
blockColumns: "Columns",
|
|
78
|
+
blockColumnsHint: "Two columns side by side",
|
|
79
|
+
blockPageBreak: "Page break",
|
|
80
|
+
blockPageBreakHint: "Start a new page when printed",
|
|
81
|
+
blockTable: "Table",
|
|
82
|
+
blockTableHint: "Rows and columns",
|
|
83
|
+
blockImage: "Image",
|
|
84
|
+
blockImageHint: "A picture with a caption",
|
|
85
|
+
blockFile: "File",
|
|
86
|
+
blockFileHint: "A file to download",
|
|
87
|
+
blockRecord: "Record",
|
|
88
|
+
blockRecordHint: "A live invoice, customer or any record",
|
|
89
|
+
blockChart: "Chart",
|
|
90
|
+
blockChartHint: "A live chart",
|
|
91
|
+
blockSignature: "Signature and stamp",
|
|
92
|
+
blockSignatureHint: "For letters and contracts",
|
|
93
|
+
blockBarcode: "Barcode",
|
|
94
|
+
blockBarcodeHint: "Code 128, EAN-13 or Code 39",
|
|
95
|
+
blockQr: "QR code",
|
|
96
|
+
blockQrHint: "A link or value as a QR code",
|
|
97
|
+
blockMath: "Maths",
|
|
98
|
+
blockMathHint: "A formula in TeX",
|
|
99
|
+
toggleOpen: "Show what’s inside",
|
|
100
|
+
toggleClose: "Hide what’s inside",
|
|
101
|
+
imageEmpty: "Choose an image",
|
|
102
|
+
fileEmpty: "Choose a file",
|
|
103
|
+
fileDownload: "Download {name}",
|
|
104
|
+
live: "Live",
|
|
105
|
+
recordEmpty: "Choose a record",
|
|
106
|
+
recordHidden: "You can’t see this record",
|
|
107
|
+
recordUnavailable: "Records aren’t available here",
|
|
108
|
+
recordFailed: "The record didn’t load",
|
|
109
|
+
chartEmpty: "Choose what the chart shows",
|
|
110
|
+
chartHidden: "You can’t see this chart’s data",
|
|
111
|
+
chartUnavailable: "Charts aren’t available here",
|
|
112
|
+
chartFailed: "The chart didn’t load",
|
|
113
|
+
chartNoData: "No data yet",
|
|
114
|
+
chartLiveRange: "{range} · live",
|
|
115
|
+
chartShowTable: "Show as table",
|
|
116
|
+
chartShowChart: "Show as chart",
|
|
117
|
+
chartCategory: "Item",
|
|
118
|
+
signatureName: "Name",
|
|
119
|
+
signatureDate: "Date",
|
|
120
|
+
signatureStamp: "Company stamp",
|
|
121
|
+
barcodeEmpty: "Set the barcode’s value",
|
|
122
|
+
qrEmpty: "Set the QR code’s value",
|
|
123
|
+
codeFromField: "Drawn from {value} when printed",
|
|
124
|
+
mathEmpty: "Write a formula",
|
|
125
|
+
blockToolbar: "Block",
|
|
126
|
+
calloutNote: "Note",
|
|
127
|
+
calloutImportant: "Important",
|
|
128
|
+
widthHalf: "Half width",
|
|
129
|
+
widthWide: "Wide",
|
|
130
|
+
widthFull: "Full width",
|
|
131
|
+
caption: "Caption",
|
|
132
|
+
altText: "Alt text",
|
|
133
|
+
replace: "Replace",
|
|
134
|
+
upload: "Upload",
|
|
135
|
+
uploading: "Uploading…",
|
|
136
|
+
uploadFailed: "The upload didn’t finish. Try again.",
|
|
137
|
+
headerRow: "Header row",
|
|
138
|
+
addRow: "Row",
|
|
139
|
+
addColumn: "Column",
|
|
140
|
+
deleteRow: "Delete row",
|
|
141
|
+
deleteColumn: "Delete column",
|
|
142
|
+
columnAlign: "Column alignment",
|
|
143
|
+
alignStart: "Align to start",
|
|
144
|
+
alignEnd: "Align to end",
|
|
145
|
+
deleteBlock: "Delete block",
|
|
146
|
+
recordChoose: "Change record",
|
|
147
|
+
recordType: "Record type",
|
|
148
|
+
recordId: "Record",
|
|
149
|
+
viewCard: "Card",
|
|
150
|
+
viewSummary: "Summary",
|
|
151
|
+
chartBar: "Bars",
|
|
152
|
+
chartLine: "Line",
|
|
153
|
+
chartDonut: "Donut",
|
|
154
|
+
chartSource: "Data",
|
|
155
|
+
chartTitle: "Title",
|
|
156
|
+
addSigner: "Signer",
|
|
157
|
+
signerRole: "Role",
|
|
158
|
+
stamp: "Stamp",
|
|
159
|
+
symbology: "Type",
|
|
160
|
+
value: "Value",
|
|
161
|
+
showText: "Show the value under it",
|
|
162
|
+
formula: "Formula",
|
|
163
|
+
done: "Done",
|
|
164
|
+
blockText: "Text",
|
|
165
|
+
blockTextHint: "Plain paragraph",
|
|
166
|
+
blockH1: "Heading 1",
|
|
167
|
+
blockH1Hint: "Big section heading",
|
|
168
|
+
blockH2: "Heading 2",
|
|
169
|
+
blockH2Hint: "Medium heading",
|
|
170
|
+
blockH3: "Heading 3",
|
|
171
|
+
blockH3Hint: "Small heading",
|
|
172
|
+
blockQuote: "Quote",
|
|
173
|
+
blockQuoteHint: "A quotation",
|
|
174
|
+
blockCode: "Code",
|
|
175
|
+
blockCodeHint: "Code or a fixed-width snippet",
|
|
176
|
+
blockBullet: "Bulleted list",
|
|
177
|
+
blockBulletHint: "A simple list",
|
|
178
|
+
blockNumber: "Numbered list",
|
|
179
|
+
blockNumberHint: "A list with numbers",
|
|
180
|
+
blockChecklist: "Checklist",
|
|
181
|
+
blockChecklistHint: "Tasks with checkboxes",
|
|
182
|
+
blockDivider: "Divider",
|
|
183
|
+
blockDividerHint: "A line between sections",
|
|
184
|
+
field: "Field",
|
|
185
|
+
fieldPicker: "Fields",
|
|
186
|
+
fieldSearch: "Search fields",
|
|
187
|
+
noFields: "No fields match",
|
|
188
|
+
fieldMissing: "No value for this record",
|
|
189
|
+
zoom: "Zoom",
|
|
190
|
+
zoomFit: "Fit width",
|
|
191
|
+
zoomPercent: "{n}%",
|
|
192
|
+
view: "View",
|
|
193
|
+
viewContinuous: "Continuous",
|
|
194
|
+
viewPage: "Page view",
|
|
195
|
+
pageOf: "Page {page} of {pages}",
|
|
196
|
+
pageContinued: "{title} · continued",
|
|
197
|
+
pageSetup: "A4 · margins 16 mm",
|
|
198
|
+
reference: "Ref",
|
|
199
|
+
preview: "Preview",
|
|
200
|
+
previewingWith: "Previewing with",
|
|
201
|
+
changeRecord: "Change record",
|
|
202
|
+
showFields: "Show fields",
|
|
203
|
+
previewStatus: "Previewing {record}: as it will print, read-only",
|
|
204
|
+
previewEditingStatus: "Previewing {record}: as it will print",
|
|
205
|
+
pdf: "PDF",
|
|
206
|
+
publish: "Publish",
|
|
207
|
+
draftSaved: "Draft saved {time}",
|
|
208
|
+
publishedInUse: "published version {n} is in use",
|
|
209
|
+
notPublished: "not published yet",
|
|
210
|
+
publishTitle: "Before you publish",
|
|
211
|
+
publishExplain: "Publishing makes this draft the version Whity Render and agents use.",
|
|
212
|
+
publishExplainFor: "Publishing makes this draft the version Whity Render and agents use for every {records}.",
|
|
213
|
+
publishChecking: "Checking the template…",
|
|
214
|
+
publishBlockers: "What blocks publishing",
|
|
215
|
+
publishClear: "Nothing blocks publishing.",
|
|
216
|
+
publishFailed: "Not published. Try again",
|
|
217
|
+
publishVersion: "Publish version {n}",
|
|
218
|
+
keepEditing: "Keep editing",
|
|
219
|
+
review: "Review",
|
|
220
|
+
show: "Show",
|
|
221
|
+
blockerSuggestion: "1 open suggestion",
|
|
222
|
+
blockerSuggestions: "{n} open suggestions",
|
|
223
|
+
blockerSuggestionsHint: "Accept or reject them first.",
|
|
224
|
+
blockerPlugin: "{plugin} is turned off",
|
|
225
|
+
blockerPluginHint: "Its blocks can’t be printed until it’s on again.",
|
|
226
|
+
blockerNoPrint: "A block has no print view",
|
|
227
|
+
blockerNoPrintHint: "It can’t be printed. Remove it, or keep it for notes.",
|
|
228
|
+
blockerField: "{field} isn’t a field of this record type",
|
|
229
|
+
blockerFieldHint: "Remove it, or pick a field the record has.",
|
|
230
|
+
blockerTheme: "This document uses a theme the workspace doesn’t have: {ref}",
|
|
231
|
+
blockerThemeHint: "Choose another theme or restore it.",
|
|
232
|
+
labelGrid: "{columns} × {rows} labels",
|
|
233
|
+
labelStock: "Label stock",
|
|
234
|
+
labelCertificate: "Certificate",
|
|
235
|
+
labelSheet: "Sheet",
|
|
236
|
+
labelColumns: "Columns",
|
|
237
|
+
labelRows: "Rows",
|
|
238
|
+
labelWidth: "Label width (mm)",
|
|
239
|
+
labelHeight: "Label height (mm)",
|
|
240
|
+
labelGapX: "Gap between columns (mm)",
|
|
241
|
+
labelGapY: "Gap between rows (mm)",
|
|
242
|
+
labelTooBig: "The labels don’t fit on the sheet.",
|
|
243
|
+
labelOverflow: "Doesn’t fit the label",
|
|
244
|
+
labelsPerSheet: "{n} labels a sheet",
|
|
245
|
+
printLabels: "Print labels",
|
|
246
|
+
fieldsThisTemplate: "This template",
|
|
247
|
+
fieldNew: "New field “{name}”",
|
|
248
|
+
fieldNewHint: "Type a name to add a field of this template.",
|
|
249
|
+
modeSuggesting: "Suggesting",
|
|
250
|
+
modeSuggestingHint: "Your edits become suggestions to accept",
|
|
251
|
+
modeSuggestingHintNoEdit: "An editor accepts your changes",
|
|
252
|
+
modeEditingLocked: "Ask an owner for edit access",
|
|
253
|
+
modeViewingCommentHint: "Read and comment, nothing changes",
|
|
254
|
+
comment: "Comment",
|
|
255
|
+
commentsAndSuggestions: "Comments and suggestions",
|
|
256
|
+
close: "Close",
|
|
257
|
+
cancel: "Cancel",
|
|
258
|
+
commentPlaceholder: "Comment or add others with @",
|
|
259
|
+
replyPlaceholder: "Reply or add others with @",
|
|
260
|
+
reply: "Reply",
|
|
261
|
+
resolve: "Resolve",
|
|
262
|
+
reopen: "Reopen",
|
|
263
|
+
resolvedBy: "Resolved by {name} · {time}",
|
|
264
|
+
accept: "Accept",
|
|
265
|
+
reject: "Reject",
|
|
266
|
+
railAll: "All",
|
|
267
|
+
acceptAll: "Accept all",
|
|
268
|
+
rejectAll: "Reject all",
|
|
269
|
+
acceptAllFrom: "Accept all from {name}",
|
|
270
|
+
rejectAllFrom: "Reject all from {name}",
|
|
271
|
+
countSuggestion: "1 suggestion",
|
|
272
|
+
countSuggestions: "{n} suggestions",
|
|
273
|
+
countComment: "1 comment",
|
|
274
|
+
countComments: "{n} comments",
|
|
275
|
+
countResolved: "{n} resolved",
|
|
276
|
+
tabAll: "All",
|
|
277
|
+
tabComments: "Comments",
|
|
278
|
+
tabSuggestions: "Suggestions",
|
|
279
|
+
tabResolved: "Resolved",
|
|
280
|
+
railEmpty: "No comments or suggestions yet. Select text and choose Comment.",
|
|
281
|
+
resolvedEmpty: "No resolved comments",
|
|
282
|
+
mentionPeople: "People",
|
|
283
|
+
mentionNone: "No one matches",
|
|
284
|
+
mentionHint: "Type a name to mention someone",
|
|
285
|
+
you: "You",
|
|
286
|
+
now: "now",
|
|
287
|
+
oneReply: "1 reply",
|
|
288
|
+
replies: "{n} replies",
|
|
289
|
+
actorFor: "for",
|
|
290
|
+
sugReplace: "Replace {from} with {to}",
|
|
291
|
+
sugAdd: "Add {text}",
|
|
292
|
+
sugDelete: "Delete {text}",
|
|
293
|
+
sugFormat: "Make {text} {mark}",
|
|
294
|
+
sugUnformat: "Remove {mark} from {text}",
|
|
295
|
+
sugAddBlocks: "Add {text}",
|
|
296
|
+
sugDeleteBlocks: "Delete {text}",
|
|
297
|
+
sugMoveBlock: "Move {text}",
|
|
298
|
+
sugBlock: "a block",
|
|
299
|
+
sugSending: "Sending…",
|
|
300
|
+
sugUnplaced: "Its text has changed since",
|
|
301
|
+
sugRefused: "That change can’t be a suggestion yet, so it was undone.",
|
|
302
|
+
collabFailed: "That didn’t work. Try again.",
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
export type EditorLabels = typeof EDITOR_LABELS
|
|
306
|
+
|
|
307
|
+
/** Fill `{name}` placeholders. */
|
|
308
|
+
export function fill(template: string, values: Record<string, string | number>): string {
|
|
309
|
+
return template.replace(/\{(\w+)\}/g, (_, key: string) => String(values[key] ?? `{${key}}`))
|
|
310
|
+
}
|