@jcsoftdev/ui 0.8.0 → 0.9.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/CHANGELOG.md +28 -0
- package/README.md +1 -0
- package/dist/containers/index.d.ts +1 -0
- package/dist/containers/index.js +1 -0
- package/dist/containers/order-ticket/index.d.ts +2 -0
- package/dist/containers/order-ticket/index.js +16 -0
- package/dist/containers/order-ticket/model.d.ts +18 -0
- package/dist/containers/order-ticket/model.js +36 -0
- package/dist/containers/order-ticket/order-ticket.d.ts +34 -0
- package/dist/containers/order-ticket/order-ticket.js +390 -0
- package/dist/glass/crystal-map.d.ts +3 -1
- package/dist/glass/crystal-map.js +13 -2
- package/dist/i18n/strings.d.ts +60 -0
- package/dist/i18n/strings.js +40 -0
- package/dist/icons/alarm-clock.d.ts +2 -0
- package/dist/icons/alarm-clock.js +15 -0
- package/dist/icons/hourglass.d.ts +2 -0
- package/dist/icons/hourglass.js +13 -0
- package/dist/icons/index.d.ts +2 -0
- package/dist/icons/index.js +4 -0
- package/icons/svg/alarm-clock.svg +8 -0
- package/icons/svg/hourglass.svg +6 -0
- package/package.json +2 -2
- package/src/containers/index.ts +1 -0
- package/src/containers/order-ticket/index.ts +15 -0
- package/src/containers/order-ticket/model.ts +55 -0
- package/src/containers/order-ticket/order-ticket.tsx +463 -0
- package/src/glass/crystal-map.ts +21 -3
- package/src/i18n/strings.ts +60 -0
- package/src/icons/alarm-clock.tsx +16 -0
- package/src/icons/hourglass.tsx +14 -0
- package/src/icons/index.ts +2 -0
|
@@ -0,0 +1,463 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { type ComponentPropsWithoutRef, type ReactNode, useId, useSyncExternalStore } from "react";
|
|
4
|
+
import { Button } from "../../atoms/button/button.js";
|
|
5
|
+
import { Chip } from "../../atoms/chip/chip.js";
|
|
6
|
+
import { ElapsedTime } from "../../atoms/elapsed-time/elapsed-time.js";
|
|
7
|
+
import { readElapsed } from "../../atoms/elapsed-time/model.js";
|
|
8
|
+
import { getTickerSnapshot, subscribeTicker } from "../../atoms/elapsed-time/ticker.js";
|
|
9
|
+
import { Progress, type ProgressBuiltinTone } from "../../atoms/progress/progress.js";
|
|
10
|
+
import { type UiStrings, useUiStrings } from "../../i18n/index.js";
|
|
11
|
+
import {
|
|
12
|
+
AlarmClock,
|
|
13
|
+
CircleAlert,
|
|
14
|
+
CircleCheck,
|
|
15
|
+
Hourglass,
|
|
16
|
+
Play,
|
|
17
|
+
RotateCcw,
|
|
18
|
+
Square,
|
|
19
|
+
TriangleAlert,
|
|
20
|
+
} from "../../icons/index.js";
|
|
21
|
+
import type { ClassNames } from "../../utils/class-names.js";
|
|
22
|
+
import { cn } from "../../utils/cn.js";
|
|
23
|
+
import { usePrefersReducedMotion } from "../../utils/reduced-motion.js";
|
|
24
|
+
import {
|
|
25
|
+
type OrderTicketLine,
|
|
26
|
+
type OrderTicketLineStatus,
|
|
27
|
+
type OrderTicketState,
|
|
28
|
+
orderTicketState,
|
|
29
|
+
} from "./model.js";
|
|
30
|
+
|
|
31
|
+
export type OrderTicketPart =
|
|
32
|
+
| "root"
|
|
33
|
+
| "paper"
|
|
34
|
+
| "band"
|
|
35
|
+
| "title"
|
|
36
|
+
| "meta"
|
|
37
|
+
| "timer"
|
|
38
|
+
| "progress"
|
|
39
|
+
| "lines"
|
|
40
|
+
| "line"
|
|
41
|
+
| "footer";
|
|
42
|
+
|
|
43
|
+
export interface OrderTicketChannel {
|
|
44
|
+
label: string;
|
|
45
|
+
icon?: ReactNode;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface OrderTicketProps
|
|
49
|
+
extends Omit<ComponentPropsWithoutRef<"article">, "title" | "children"> {
|
|
50
|
+
table?: string | undefined;
|
|
51
|
+
number?: string | number | undefined;
|
|
52
|
+
channel?: OrderTicketChannel | undefined;
|
|
53
|
+
guests?: number | undefined;
|
|
54
|
+
server?: string | undefined;
|
|
55
|
+
customer?: string | undefined;
|
|
56
|
+
since: Date | string;
|
|
57
|
+
targetMinutes: number;
|
|
58
|
+
serverOffsetMs?: number | undefined;
|
|
59
|
+
state?: OrderTicketState | undefined;
|
|
60
|
+
lines: readonly OrderTicketLine[];
|
|
61
|
+
partIndex?: number | undefined;
|
|
62
|
+
partCount?: number | undefined;
|
|
63
|
+
recovered?: boolean | undefined;
|
|
64
|
+
chip?: ReactNode;
|
|
65
|
+
readOnly?: boolean | undefined;
|
|
66
|
+
onStartAll?: ((lines: readonly OrderTicketLine[]) => void) | undefined;
|
|
67
|
+
onReadyAll?: ((lines: readonly OrderTicketLine[]) => void) | undefined;
|
|
68
|
+
actions?: ReactNode;
|
|
69
|
+
hanging?: boolean | undefined;
|
|
70
|
+
headingLevel?: 2 | 3 | 4 | undefined;
|
|
71
|
+
viewTransitionName?: string | undefined;
|
|
72
|
+
classNames?: ClassNames<OrderTicketPart> | undefined;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const progressTone: Record<OrderTicketState, ProgressBuiltinTone> = {
|
|
76
|
+
ok: "accent",
|
|
77
|
+
warn: "warning",
|
|
78
|
+
late: "danger",
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const timerTone: Record<OrderTicketState, string> = {
|
|
82
|
+
ok: "font-normal text-ink",
|
|
83
|
+
warn: "font-normal text-warning",
|
|
84
|
+
late: "font-normal text-current",
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const stateWord: Record<OrderTicketState, keyof UiStrings> = {
|
|
88
|
+
ok: "orderTicketOnTime",
|
|
89
|
+
warn: "orderTicketDueSoon",
|
|
90
|
+
late: "orderTicketLate",
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
const lineStateWord: Record<OrderTicketLineStatus, keyof UiStrings> = {
|
|
94
|
+
pending: "orderTicketPending",
|
|
95
|
+
"in-progress": "orderTicketInProgress",
|
|
96
|
+
done: "orderTicketDone",
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const lineStateIcon: Record<OrderTicketLineStatus, ReactNode> = {
|
|
100
|
+
pending: <Square size={18} aria-hidden="true" />,
|
|
101
|
+
"in-progress": <Play size={18} aria-hidden="true" />,
|
|
102
|
+
done: <CircleCheck size={18} aria-hidden="true" />,
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
const lineToneClasses: Record<OrderTicketLineStatus, string> = {
|
|
106
|
+
pending: "",
|
|
107
|
+
"in-progress": "bg-accent-soft",
|
|
108
|
+
done: "",
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
const lineStateClasses: Record<OrderTicketLineStatus, string> = {
|
|
112
|
+
pending: "text-ink-2",
|
|
113
|
+
"in-progress": "text-accent-ink",
|
|
114
|
+
done: "text-success",
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
const lineStateTextClasses: Record<OrderTicketLineStatus, string> = {
|
|
118
|
+
pending: "sr-only",
|
|
119
|
+
"in-progress": "sr-only @[340px]/ticket:not-sr-only",
|
|
120
|
+
done: "sr-only @[340px]/ticket:not-sr-only",
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
const pressedOf: Record<OrderTicketLineStatus, boolean | "mixed"> = {
|
|
124
|
+
pending: false,
|
|
125
|
+
"in-progress": "mixed",
|
|
126
|
+
done: true,
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
const fill = (template: string, values: Record<string, string | number>) =>
|
|
130
|
+
Object.entries(values).reduce(
|
|
131
|
+
(text, [key, value]) => text.replace(`{${key}}`, String(value)),
|
|
132
|
+
template,
|
|
133
|
+
);
|
|
134
|
+
|
|
135
|
+
const clock = (seconds: number) =>
|
|
136
|
+
`${Math.floor(seconds / 60)}:${String(seconds % 60).padStart(2, "0")}`;
|
|
137
|
+
|
|
138
|
+
const noteClasses =
|
|
139
|
+
"inline-flex max-w-full items-start gap-1 self-start rounded-chip px-1.5 py-0.5 text-meta font-medium [&_svg]:mt-0.5 [&_svg]:shrink-0";
|
|
140
|
+
|
|
141
|
+
function LineContent({
|
|
142
|
+
line,
|
|
143
|
+
status,
|
|
144
|
+
strings,
|
|
145
|
+
}: {
|
|
146
|
+
line: OrderTicketLine;
|
|
147
|
+
status: OrderTicketLineStatus;
|
|
148
|
+
strings: UiStrings;
|
|
149
|
+
}) {
|
|
150
|
+
const done = status === "done";
|
|
151
|
+
return (
|
|
152
|
+
<>
|
|
153
|
+
<span
|
|
154
|
+
className={cn(
|
|
155
|
+
"text-right text-card-title tabular-nums",
|
|
156
|
+
done && "text-ink-2 line-through decoration-2",
|
|
157
|
+
)}
|
|
158
|
+
>
|
|
159
|
+
{line.qty}
|
|
160
|
+
</span>
|
|
161
|
+
<span className="flex min-w-0 flex-col gap-0.5">
|
|
162
|
+
<span
|
|
163
|
+
className={cn(
|
|
164
|
+
"text-card-title [overflow-wrap:anywhere]",
|
|
165
|
+
done && "text-ink-2 line-through decoration-2",
|
|
166
|
+
)}
|
|
167
|
+
>
|
|
168
|
+
{line.name}
|
|
169
|
+
</span>
|
|
170
|
+
{line.modifiers && line.modifiers.length > 0 && (
|
|
171
|
+
<span className="text-meta text-ink-2 [overflow-wrap:anywhere]">
|
|
172
|
+
{line.modifiers.join(" · ")}
|
|
173
|
+
</span>
|
|
174
|
+
)}
|
|
175
|
+
{line.note && (
|
|
176
|
+
<span
|
|
177
|
+
data-part="note"
|
|
178
|
+
className={cn(noteClasses, "text-ink shadow-[inset_0_0_0_1px_var(--line-strong)]")}
|
|
179
|
+
>
|
|
180
|
+
<TriangleAlert size={14} aria-hidden="true" />
|
|
181
|
+
{fill(strings.orderTicketNote, { note: line.note })}
|
|
182
|
+
</span>
|
|
183
|
+
)}
|
|
184
|
+
{line.allergy && (
|
|
185
|
+
<span
|
|
186
|
+
data-part="allergy"
|
|
187
|
+
className={cn(
|
|
188
|
+
noteClasses,
|
|
189
|
+
"font-semibold text-danger shadow-[inset_0_0_0_1.5px_var(--danger)]",
|
|
190
|
+
)}
|
|
191
|
+
>
|
|
192
|
+
<CircleAlert size={14} aria-hidden="true" />
|
|
193
|
+
{fill(strings.orderTicketAllergy, { allergy: line.allergy })}
|
|
194
|
+
</span>
|
|
195
|
+
)}
|
|
196
|
+
</span>
|
|
197
|
+
<span
|
|
198
|
+
className={cn(
|
|
199
|
+
"inline-flex min-h-[1.4em] items-center justify-end gap-1.5 text-meta font-semibold",
|
|
200
|
+
lineStateClasses[status],
|
|
201
|
+
)}
|
|
202
|
+
>
|
|
203
|
+
<span className={lineStateTextClasses[status]}>{strings[lineStateWord[status]]}</span>
|
|
204
|
+
{lineStateIcon[status]}
|
|
205
|
+
</span>
|
|
206
|
+
</>
|
|
207
|
+
);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function TicketLineRow({
|
|
211
|
+
line,
|
|
212
|
+
readOnly,
|
|
213
|
+
strings,
|
|
214
|
+
className,
|
|
215
|
+
}: {
|
|
216
|
+
line: OrderTicketLine;
|
|
217
|
+
readOnly: boolean;
|
|
218
|
+
strings: UiStrings;
|
|
219
|
+
className: string | undefined;
|
|
220
|
+
}) {
|
|
221
|
+
const status = line.status ?? "pending";
|
|
222
|
+
const rowClasses = cn(
|
|
223
|
+
"grid min-h-[max(var(--touch-target),2rem)] w-full grid-cols-[2.4ch_minmax(0,1fr)_auto] items-start gap-x-2.5 rounded-control px-1.5 py-1 text-left text-ink",
|
|
224
|
+
lineToneClasses[status],
|
|
225
|
+
className,
|
|
226
|
+
);
|
|
227
|
+
const content = <LineContent line={line} status={status} strings={strings} />;
|
|
228
|
+
return (
|
|
229
|
+
<li data-line={line.id} data-status={status}>
|
|
230
|
+
{line.onToggle && !readOnly ? (
|
|
231
|
+
<button
|
|
232
|
+
type="button"
|
|
233
|
+
aria-pressed={pressedOf[status]}
|
|
234
|
+
onClick={line.onToggle}
|
|
235
|
+
className={cn(
|
|
236
|
+
rowClasses,
|
|
237
|
+
"cursor-pointer transition-colors focus-visible:focus-ring motion-reduce:transition-none",
|
|
238
|
+
status !== "in-progress" && "hover:bg-surface-2",
|
|
239
|
+
)}
|
|
240
|
+
>
|
|
241
|
+
{content}
|
|
242
|
+
</button>
|
|
243
|
+
) : (
|
|
244
|
+
<div className={rowClasses}>{content}</div>
|
|
245
|
+
)}
|
|
246
|
+
</li>
|
|
247
|
+
);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
export function OrderTicket({
|
|
251
|
+
table,
|
|
252
|
+
number,
|
|
253
|
+
channel,
|
|
254
|
+
guests,
|
|
255
|
+
server,
|
|
256
|
+
customer,
|
|
257
|
+
since,
|
|
258
|
+
targetMinutes,
|
|
259
|
+
serverOffsetMs,
|
|
260
|
+
state: stateProp,
|
|
261
|
+
lines,
|
|
262
|
+
partIndex,
|
|
263
|
+
partCount,
|
|
264
|
+
recovered,
|
|
265
|
+
chip,
|
|
266
|
+
readOnly = false,
|
|
267
|
+
onStartAll,
|
|
268
|
+
onReadyAll,
|
|
269
|
+
actions,
|
|
270
|
+
hanging,
|
|
271
|
+
headingLevel = 3,
|
|
272
|
+
viewTransitionName,
|
|
273
|
+
classNames,
|
|
274
|
+
className,
|
|
275
|
+
style,
|
|
276
|
+
...props
|
|
277
|
+
}: OrderTicketProps) {
|
|
278
|
+
const strings = useUiStrings();
|
|
279
|
+
const reducedMotion = usePrefersReducedMotion();
|
|
280
|
+
const headingId = useId();
|
|
281
|
+
const now = useSyncExternalStore(subscribeTicker, getTickerSnapshot, getTickerSnapshot);
|
|
282
|
+
const { seconds } = readElapsed({ since, now, serverOffsetMs });
|
|
283
|
+
const targetSeconds = Math.max(1, targetMinutes * 60);
|
|
284
|
+
const state = stateProp ?? orderTicketState(seconds, targetMinutes);
|
|
285
|
+
const late = state === "late";
|
|
286
|
+
const overrun = Math.max(0, seconds - targetSeconds);
|
|
287
|
+
const Heading = `h${headingLevel}` as const;
|
|
288
|
+
const title = table ?? fill(strings.orderTicketNumber, { number: number ?? "" });
|
|
289
|
+
const titleIcon = table ? null : channel?.icon;
|
|
290
|
+
const guestsText =
|
|
291
|
+
guests === undefined
|
|
292
|
+
? undefined
|
|
293
|
+
: fill(guests === 1 ? strings.orderTicketGuestsOne : strings.orderTicketGuests, {
|
|
294
|
+
count: guests,
|
|
295
|
+
});
|
|
296
|
+
const meta = [table ? undefined : channel?.label, guestsText, server, customer]
|
|
297
|
+
.filter(Boolean)
|
|
298
|
+
.join(" · ");
|
|
299
|
+
const split = partCount !== undefined && partCount > 1;
|
|
300
|
+
const partLabel =
|
|
301
|
+
split && (partIndex ?? 1) > 1
|
|
302
|
+
? strings.orderTicketContinued
|
|
303
|
+
: fill(strings.orderTicketPart, { index: 1, count: partCount ?? 1 });
|
|
304
|
+
const overrunText = reducedMotion
|
|
305
|
+
? fill(strings.minutesShort, { count: Math.ceil(overrun / 60) })
|
|
306
|
+
: clock(overrun);
|
|
307
|
+
const showActions = !readOnly && Boolean(actions || onStartAll || onReadyAll);
|
|
308
|
+
|
|
309
|
+
return (
|
|
310
|
+
<article
|
|
311
|
+
aria-labelledby={headingId}
|
|
312
|
+
data-state={state}
|
|
313
|
+
data-read-only={readOnly ? "" : undefined}
|
|
314
|
+
data-part-index={split ? (partIndex ?? 1) : undefined}
|
|
315
|
+
className={cn(
|
|
316
|
+
"@container/ticket relative min-w-0 [--ticket-edge:var(--hair)] data-[state=late]:[--ticket-edge:var(--danger)]",
|
|
317
|
+
"[filter:drop-shadow(1px_0_0_var(--ticket-edge))_drop-shadow(-1px_0_0_var(--ticket-edge))_drop-shadow(0_1px_0_var(--ticket-edge))_drop-shadow(0_-1px_0_var(--ticket-edge))]",
|
|
318
|
+
hanging &&
|
|
319
|
+
"pt-2.5 before:absolute before:top-0 before:left-1/2 before:z-1 before:h-4 before:w-11 before:-translate-x-1/2 before:rounded-[4px_4px_2px_2px] before:bg-line-strong before:shadow-[inset_0_-3px_0_var(--sunken)] before:content-['']",
|
|
320
|
+
classNames?.root,
|
|
321
|
+
className,
|
|
322
|
+
)}
|
|
323
|
+
style={viewTransitionName ? { ...style, viewTransitionName } : style}
|
|
324
|
+
{...props}
|
|
325
|
+
>
|
|
326
|
+
<div
|
|
327
|
+
data-part="paper"
|
|
328
|
+
className={cn(
|
|
329
|
+
"relative flex flex-col gap-2.5 rounded-t-card bg-surface p-3 pb-[calc(--spacing(3)+6px)] text-ink",
|
|
330
|
+
"[mask:conic-gradient(from_-45deg_at_bottom,transparent,black_1deg_89deg,transparent_90deg)_50%/12px_100%]",
|
|
331
|
+
classNames?.paper,
|
|
332
|
+
)}
|
|
333
|
+
>
|
|
334
|
+
<div
|
|
335
|
+
data-part="band"
|
|
336
|
+
className={cn(
|
|
337
|
+
"-mx-3 -mt-3 flex flex-col gap-1.5 rounded-t-card px-3 pt-3 pb-2.5",
|
|
338
|
+
hanging && "pt-4",
|
|
339
|
+
late && "bg-danger text-surface",
|
|
340
|
+
classNames?.band,
|
|
341
|
+
)}
|
|
342
|
+
>
|
|
343
|
+
<header className="grid grid-cols-[minmax(0,1fr)_auto] items-baseline gap-x-3">
|
|
344
|
+
<div className="flex min-w-0 flex-wrap items-baseline gap-x-2">
|
|
345
|
+
<Heading
|
|
346
|
+
id={headingId}
|
|
347
|
+
className={cn(
|
|
348
|
+
"m-0 inline-flex items-center gap-1.5 text-kpi-number text-balance [overflow-wrap:anywhere] [&_svg]:shrink-0",
|
|
349
|
+
classNames?.title,
|
|
350
|
+
)}
|
|
351
|
+
>
|
|
352
|
+
{titleIcon}
|
|
353
|
+
<span>{title}</span>
|
|
354
|
+
{split && <span className="text-control">{partLabel}</span>}
|
|
355
|
+
<span className="sr-only">{`, ${strings[stateWord[state]]}`}</span>
|
|
356
|
+
</Heading>
|
|
357
|
+
{meta && (
|
|
358
|
+
<span
|
|
359
|
+
className={cn(
|
|
360
|
+
"min-w-0 text-meta",
|
|
361
|
+
late ? "text-current" : "text-ink-2",
|
|
362
|
+
classNames?.meta,
|
|
363
|
+
)}
|
|
364
|
+
>
|
|
365
|
+
{meta}
|
|
366
|
+
</span>
|
|
367
|
+
)}
|
|
368
|
+
</div>
|
|
369
|
+
<span
|
|
370
|
+
className={cn(
|
|
371
|
+
"inline-flex items-center gap-1 whitespace-nowrap",
|
|
372
|
+
state === "warn" && "text-warning",
|
|
373
|
+
classNames?.timer,
|
|
374
|
+
)}
|
|
375
|
+
>
|
|
376
|
+
{state === "warn" && <Hourglass size={18} aria-hidden="true" />}
|
|
377
|
+
<ElapsedTime
|
|
378
|
+
since={since}
|
|
379
|
+
{...(serverOffsetMs === undefined ? {} : { serverOffsetMs })}
|
|
380
|
+
className={cn("text-kpi-number", timerTone[state])}
|
|
381
|
+
/>
|
|
382
|
+
</span>
|
|
383
|
+
</header>
|
|
384
|
+
{late && (
|
|
385
|
+
<span className="inline-flex items-center gap-1.5 text-row-title">
|
|
386
|
+
<AlarmClock size={18} aria-hidden="true" />
|
|
387
|
+
{fill(strings.orderTicketLateBy, { time: overrunText })}
|
|
388
|
+
</span>
|
|
389
|
+
)}
|
|
390
|
+
</div>
|
|
391
|
+
<Progress
|
|
392
|
+
value={Math.min(seconds, targetSeconds)}
|
|
393
|
+
max={targetSeconds}
|
|
394
|
+
tone={progressTone[state]}
|
|
395
|
+
aria-label={fill(strings.orderTicketProgress, { target: targetMinutes })}
|
|
396
|
+
getValueLabel={() =>
|
|
397
|
+
fill(strings.orderTicketProgressValue, {
|
|
398
|
+
elapsed: Math.floor(seconds / 60),
|
|
399
|
+
target: targetMinutes,
|
|
400
|
+
})
|
|
401
|
+
}
|
|
402
|
+
className={classNames?.progress}
|
|
403
|
+
/>
|
|
404
|
+
{recovered && (
|
|
405
|
+
<div className="flex flex-wrap gap-1.5">
|
|
406
|
+
<Chip tone="info" icon={<RotateCcw size={14} aria-hidden="true" />}>
|
|
407
|
+
{strings.orderTicketRecovered}
|
|
408
|
+
</Chip>
|
|
409
|
+
</div>
|
|
410
|
+
)}
|
|
411
|
+
<ul
|
|
412
|
+
aria-label={strings.orderTicketItems}
|
|
413
|
+
className={cn("-mx-1.5 my-0 flex list-none flex-col gap-0.5 p-0", classNames?.lines)}
|
|
414
|
+
>
|
|
415
|
+
{lines.map((line) => (
|
|
416
|
+
<TicketLineRow
|
|
417
|
+
key={line.id}
|
|
418
|
+
line={line}
|
|
419
|
+
readOnly={readOnly}
|
|
420
|
+
strings={strings}
|
|
421
|
+
className={classNames?.line}
|
|
422
|
+
/>
|
|
423
|
+
))}
|
|
424
|
+
</ul>
|
|
425
|
+
{(chip || showActions) && (
|
|
426
|
+
<footer
|
|
427
|
+
className={cn(
|
|
428
|
+
"flex items-center gap-2 border-t border-dashed border-line-strong pt-2.5",
|
|
429
|
+
classNames?.footer,
|
|
430
|
+
)}
|
|
431
|
+
>
|
|
432
|
+
<div className="flex min-w-0 grow flex-wrap gap-1.5 @max-[310px]/ticket:hidden">
|
|
433
|
+
{chip && (
|
|
434
|
+
<Chip tone="neutral" className="min-w-0">
|
|
435
|
+
{chip}
|
|
436
|
+
</Chip>
|
|
437
|
+
)}
|
|
438
|
+
</div>
|
|
439
|
+
{showActions && actions}
|
|
440
|
+
{showActions && onStartAll && (
|
|
441
|
+
<Button
|
|
442
|
+
variant={onReadyAll ? "secondary" : "primary"}
|
|
443
|
+
className="whitespace-nowrap @max-[310px]/ticket:flex-1"
|
|
444
|
+
onClick={() => onStartAll(lines)}
|
|
445
|
+
>
|
|
446
|
+
{strings.orderTicketStartAll}
|
|
447
|
+
</Button>
|
|
448
|
+
)}
|
|
449
|
+
{showActions && onReadyAll && (
|
|
450
|
+
<Button
|
|
451
|
+
variant="primary"
|
|
452
|
+
className="whitespace-nowrap @max-[310px]/ticket:flex-1"
|
|
453
|
+
onClick={() => onReadyAll(lines)}
|
|
454
|
+
>
|
|
455
|
+
{strings.orderTicketReadyAll}
|
|
456
|
+
</Button>
|
|
457
|
+
)}
|
|
458
|
+
</footer>
|
|
459
|
+
)}
|
|
460
|
+
</div>
|
|
461
|
+
</article>
|
|
462
|
+
);
|
|
463
|
+
}
|
package/src/glass/crystal-map.ts
CHANGED
|
@@ -61,7 +61,9 @@ export interface CrystalMapOptions {
|
|
|
61
61
|
* Margin past each side of the surface, in px (default: `margin` on all four). A surface inside
|
|
62
62
|
* a clipping ancestor (an `overflow` or `clip-path` stage) only has the backdrop within it: a
|
|
63
63
|
* layer that reaches past the clip is cut by the browser and its filter is shifted, so the map
|
|
64
|
-
* covers only the backdrop that exists
|
|
64
|
+
* covers only the backdrop that exists. A side with less room than the margin scales its offsets
|
|
65
|
+
* down so its silhouette still samples inside the room, eased across the surface; the hard clamp
|
|
66
|
+
* that remains only bites in the margin, which the layer clips away.
|
|
65
67
|
*/
|
|
66
68
|
room?: Partial<Record<"left" | "right" | "top" | "bottom", number>>;
|
|
67
69
|
/** Largest factor the offset is multiplied by (chromatic dispersion pulls red this much further). Default 1. */
|
|
@@ -112,17 +114,33 @@ export function computeCrystalField({
|
|
|
112
114
|
const [minY, maxY] = [-hy - top + slack, hy + bottom - slack];
|
|
113
115
|
const unit = Math.max(amplitude, 1e-6);
|
|
114
116
|
const f = Math.max(reach, 1);
|
|
117
|
+
// Share of the offset a side keeps so its silhouette, where the offset peaks at `amplitude
|
|
118
|
+
// extent / half`, still samples inside the room. A side with the whole margin keeps all of it.
|
|
119
|
+
const keep = (free: number, extent: number) =>
|
|
120
|
+
free >= m ? 1 : clamp((free - EDGE_SLACK) / Math.max((f * unit * extent) / half, 1e-6), 0, 1);
|
|
121
|
+
const shares = {
|
|
122
|
+
x: [keep(left, hx), keep(right, hx)],
|
|
123
|
+
y: [keep(top, hy), keep(bottom, hy)],
|
|
124
|
+
} as const;
|
|
125
|
+
// Eased from one side's share to the other across the surface, so the lens bends less towards
|
|
126
|
+
// a short side without a crease down the middle (a hard per-side switch would put one there).
|
|
127
|
+
const share = ([low, high]: readonly [number, number], p: number, extent: number) => {
|
|
128
|
+
const u = clamp((p + extent) / (2 * extent), 0, 1);
|
|
129
|
+
return low + (high - low) * u * u * (3 - 2 * u);
|
|
130
|
+
};
|
|
115
131
|
// Offset (as a fraction of `amplitude`, what the channel encodes) that keeps the source in the room.
|
|
116
132
|
const within = (p: number, offset: number, lo: number, hi: number) =>
|
|
117
133
|
clamp((bounded ? clamp(offset, (lo - p) / f, (hi - p) / f) : offset) / unit, -1, 1);
|
|
118
134
|
for (let j = 0; j < ph; j++) {
|
|
119
135
|
const py = (j + 0.5) / ry - top - hy;
|
|
136
|
+
const ky = share(shares.y, py, hy);
|
|
120
137
|
for (let i = 0; i < pw; i++) {
|
|
121
138
|
const px = (i + 0.5) / rx - left - hx;
|
|
139
|
+
const kx = share(shares.x, px, hx);
|
|
122
140
|
const s = crystalShape(crystalRadius(px, py, hx, hy));
|
|
123
141
|
const o = (j * pw + i) * 4;
|
|
124
|
-
data[o] = 128 + within(px, (s * px * amplitude) / half, minX, maxX) * 127;
|
|
125
|
-
data[o + 1] = 128 + within(py, (s * py * amplitude) / half, minY, maxY) * 127;
|
|
142
|
+
data[o] = 128 + within(px, ((s * px * amplitude) / half) * kx, minX, maxX) * 127;
|
|
143
|
+
data[o + 1] = 128 + within(py, ((s * py * amplitude) / half) * ky, minY, maxY) * 127;
|
|
126
144
|
data[o + 2] = 255;
|
|
127
145
|
data[o + 3] = 255;
|
|
128
146
|
}
|
package/src/i18n/strings.ts
CHANGED
|
@@ -44,6 +44,26 @@ export interface UiStrings {
|
|
|
44
44
|
rotate: string;
|
|
45
45
|
/** Keyboard help of an editable `FloorPlan`. */
|
|
46
46
|
floorPlanEditHint: string;
|
|
47
|
+
orderTicketNumber: string;
|
|
48
|
+
orderTicketGuests: string;
|
|
49
|
+
orderTicketGuestsOne: string;
|
|
50
|
+
orderTicketPart: string;
|
|
51
|
+
orderTicketContinued: string;
|
|
52
|
+
orderTicketOnTime: string;
|
|
53
|
+
orderTicketDueSoon: string;
|
|
54
|
+
orderTicketLate: string;
|
|
55
|
+
orderTicketLateBy: string;
|
|
56
|
+
orderTicketProgress: string;
|
|
57
|
+
orderTicketProgressValue: string;
|
|
58
|
+
orderTicketItems: string;
|
|
59
|
+
orderTicketPending: string;
|
|
60
|
+
orderTicketInProgress: string;
|
|
61
|
+
orderTicketDone: string;
|
|
62
|
+
orderTicketNote: string;
|
|
63
|
+
orderTicketAllergy: string;
|
|
64
|
+
orderTicketRecovered: string;
|
|
65
|
+
orderTicketStartAll: string;
|
|
66
|
+
orderTicketReadyAll: string;
|
|
47
67
|
remove: string;
|
|
48
68
|
noResults: string;
|
|
49
69
|
clear: string;
|
|
@@ -195,6 +215,26 @@ export const uiStrings = {
|
|
|
195
215
|
floorPlan: "Floor plan",
|
|
196
216
|
rotate: "Rotate 90°",
|
|
197
217
|
floorPlanEditHint: "Alt with arrows moves, Alt and Shift with arrows resizes, R rotates.",
|
|
218
|
+
orderTicketNumber: "No. {number}",
|
|
219
|
+
orderTicketGuests: "{count} guests",
|
|
220
|
+
orderTicketGuestsOne: "{count} guest",
|
|
221
|
+
orderTicketPart: "({index} of {count})",
|
|
222
|
+
orderTicketContinued: "(cont.)",
|
|
223
|
+
orderTicketOnTime: "on time",
|
|
224
|
+
orderTicketDueSoon: "due soon",
|
|
225
|
+
orderTicketLate: "late",
|
|
226
|
+
orderTicketLateBy: "Late +{time}",
|
|
227
|
+
orderTicketProgress: "Time against the {target} min target",
|
|
228
|
+
orderTicketProgressValue: "{elapsed} of {target} min",
|
|
229
|
+
orderTicketItems: "Items",
|
|
230
|
+
orderTicketPending: "Queued",
|
|
231
|
+
orderTicketInProgress: "Preparing",
|
|
232
|
+
orderTicketDone: "Ready",
|
|
233
|
+
orderTicketNote: "Note: {note}",
|
|
234
|
+
orderTicketAllergy: "Allergy: {allergy}",
|
|
235
|
+
orderTicketRecovered: "Recalled",
|
|
236
|
+
orderTicketStartAll: "Start all",
|
|
237
|
+
orderTicketReadyAll: "All ready",
|
|
198
238
|
remove: "Remove",
|
|
199
239
|
noResults: "No results",
|
|
200
240
|
clear: "Clear",
|
|
@@ -296,6 +336,26 @@ export const uiStrings = {
|
|
|
296
336
|
floorPlan: "Plano de sala",
|
|
297
337
|
rotate: "Girar 90°",
|
|
298
338
|
floorPlanEditHint: "Alt con flechas mueve, Alt y Mayús con flechas cambia el tamaño, R gira.",
|
|
339
|
+
orderTicketNumber: "N.º {number}",
|
|
340
|
+
orderTicketGuests: "{count} personas",
|
|
341
|
+
orderTicketGuestsOne: "{count} persona",
|
|
342
|
+
orderTicketPart: "({index} de {count})",
|
|
343
|
+
orderTicketContinued: "(cont.)",
|
|
344
|
+
orderTicketOnTime: "a tiempo",
|
|
345
|
+
orderTicketDueSoon: "por vencer",
|
|
346
|
+
orderTicketLate: "demorada",
|
|
347
|
+
orderTicketLateBy: "Demorada +{time}",
|
|
348
|
+
orderTicketProgress: "Tiempo contra los {target} min objetivo",
|
|
349
|
+
orderTicketProgressValue: "{elapsed} de {target} min",
|
|
350
|
+
orderTicketItems: "Platos",
|
|
351
|
+
orderTicketPending: "En cola",
|
|
352
|
+
orderTicketInProgress: "Preparando",
|
|
353
|
+
orderTicketDone: "Listo",
|
|
354
|
+
orderTicketNote: "Nota: {note}",
|
|
355
|
+
orderTicketAllergy: "Alergia: {allergy}",
|
|
356
|
+
orderTicketRecovered: "Recuperada",
|
|
357
|
+
orderTicketStartAll: "Empezar todo",
|
|
358
|
+
orderTicketReadyAll: "Listo todo",
|
|
299
359
|
remove: "Quitar",
|
|
300
360
|
noResults: "Sin resultados",
|
|
301
361
|
clear: "Limpiar",
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Generated by scripts/build-icons.mjs. Do not edit.
|
|
2
|
+
// Source: icons/svg/alarm-clock.svg
|
|
3
|
+
import { IconBase, type IconProps } from "./icon-base.js";
|
|
4
|
+
|
|
5
|
+
export function AlarmClock(props: IconProps) {
|
|
6
|
+
return (
|
|
7
|
+
<IconBase {...props}>
|
|
8
|
+
<circle cx="12" cy="13" r="8" />
|
|
9
|
+
<path d="M12 9v4l2 2" />
|
|
10
|
+
<path d="M5 3 2 6" />
|
|
11
|
+
<path d="m22 6-3-3" />
|
|
12
|
+
<path d="M6.38 18.7 4 21" />
|
|
13
|
+
<path d="M17.64 18.67 20 21" />
|
|
14
|
+
</IconBase>
|
|
15
|
+
);
|
|
16
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Generated by scripts/build-icons.mjs. Do not edit.
|
|
2
|
+
// Source: icons/svg/hourglass.svg
|
|
3
|
+
import { IconBase, type IconProps } from "./icon-base.js";
|
|
4
|
+
|
|
5
|
+
export function Hourglass(props: IconProps) {
|
|
6
|
+
return (
|
|
7
|
+
<IconBase {...props}>
|
|
8
|
+
<path d="M5 22h14" />
|
|
9
|
+
<path d="M5 2h14" />
|
|
10
|
+
<path d="M17 22v-4.172a2 2 0 0 0-.586-1.414L12 12l-4.414 4.414A2 2 0 0 0 7 17.828V22" />
|
|
11
|
+
<path d="M7 2v4.172a2 2 0 0 0 .586 1.414L12 12l4.414-4.414A2 2 0 0 0 17 6.172V2" />
|
|
12
|
+
</IconBase>
|
|
13
|
+
);
|
|
14
|
+
}
|
package/src/icons/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// Generated by scripts/build-icons.mjs. Do not edit.
|
|
2
2
|
export { type IconComponent, type IconProps, type LucideIcon } from "./icon-base.js";
|
|
3
|
+
export { AlarmClock } from "./alarm-clock.js";
|
|
3
4
|
export { AlertTriangle } from "./alert-triangle.js";
|
|
4
5
|
export { Archive } from "./archive.js";
|
|
5
6
|
export { Armchair } from "./armchair.js";
|
|
@@ -70,6 +71,7 @@ export { Funnel } from "./funnel.js";
|
|
|
70
71
|
export { GraduationCap } from "./graduation-cap.js";
|
|
71
72
|
export { GripVertical } from "./grip-vertical.js";
|
|
72
73
|
export { Heading2 } from "./heading-2.js";
|
|
74
|
+
export { Hourglass } from "./hourglass.js";
|
|
73
75
|
export { House } from "./house.js";
|
|
74
76
|
export { Inbox } from "./inbox.js";
|
|
75
77
|
export { Info } from "./info.js";
|