feat(signage): stacks, menu and text widgets, widget order (owner review 2)

- Stacks: horizontal / vertical, 2-6 parts with % shares; each part shows
  a widget, a stack one level deep, or a whole Slides-library slide
- Menu widget (a board's list in its box), text widget, weather for
  tomorrow / the day after and in picture / degrees / both styles
- Widgets' order (arrows, drag with a drop line), drawn in list order;
  arrow keys move the picked widget from its card too
- Server: extras by widget path (QR links, menus, embedded slides),
  POST /preview/slide, resolve(keep_hidden) so hidden products stay
  greyed in the editor's list; screens told when an embedded slide changes
- Editor rows tidied: framed sliders, colours as fields, text look on one
  row, Switch boxed toggles from its whole frame

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-21 09:44:23 +02:00
co-authored by Claude Opus 5.5
parent 83551714f7
commit 1b993e4573
23 changed files with 1231 additions and 377 deletions
@@ -1,73 +1,125 @@
// The widgets of a text, menu or blank slide (plan step 5.6b; reworked 2026-11-21): logo, name,
// date, clock, message of the day, QR code, weather. Each in its own card: its name first, then
// its settings on one row (where, size, alignment, its own options). Where / size read "Custom"
// once it was moved or sized by hand on the preview (WidgetCanvas); picking a corner or a bar
// puts it back. The card of the widget picked on the preview is highlighted (the page doesn't
// jump to it: the preview stays in view while you drag).
// The widgets of a text, menu or blank slide (plan step 5.6b; reworked 2026-11-21): logo or picture,
// name, date, clock, message of the day, a text of its own, QR code, weather, a menu, and stacks.
// Each in its own card: its name first, then its settings on one row (where, size, alignment, its
// own options), what needs more room on the rows under it. Where / size read "Custom" once it was
// moved or sized by hand on the preview (WidgetCanvas); picking a corner or a bar puts it back. The
// card of the widget picked on the preview is highlighted (the page doesn't jump to it: the preview
// stays in view while you drag).
// Owner review 2 (2026-11-21): the widgets' order (arrows, or drag a card by its handle; a later
// widget is drawn over an earlier one, and comes later in a bar); a text widget; weather for
// tomorrow / the day after and in three styles; a menu widget (a board's list in its box); stacks:
// parts side by side or one over the other, each its share (%), showing a widget, another stack (one
// level deep) or a whole slide from the Slides library.
// Up to 10 (the server's limit).
import { AlignCenter, AlignLeft, AlignRight, CalendarDays, Clock, CloudSun, ImageIcon, MessageSquare, Plus, QrCode, Store, Trash2 } from 'lucide-react'
import { useEffect, useState } from 'react'
import {
AlignCenter, AlignLeft, AlignRight, ArrowDown, ArrowUp, CalendarDays, ChevronDown, Clock, CloudSun, Columns3, GripVertical,
ImageIcon, LayoutList, MessageSquare, Plus, QrCode, Rows3, Store, Trash2, Type, UtensilsCrossed,
} from 'lucide-react'
import { evenShares, setShare } from '@xenia/signage'
import { useTranslation } from '@xenia/i18n'
import { Button, Dropdown, Field, IconButton, Input, Segmented, Switch } from '@xenia/ui'
import * as api from './signageApi'
import MenuEditor from './MenuEditor'
import { MediaPick, Section } from './SignageFields'
import { presetWidget, WIDGET_KINDS, WIDGET_POSITIONS } from './signageLogic'
import {
CELL_KINDS, cellWidget, moved, newWidget, pickedAfterMove, presetWidget, WEATHER_CHOICES, weatherChoice, WIDGET_KINDS, WIDGET_POSITIONS,
} from './signageLogic'
const ICON = { logo: ImageIcon, name: Store, date: CalendarDays, clock: Clock, message: MessageSquare, qr: QrCode, weather: CloudSun }
const ICON = { logo: ImageIcon, name: Store, date: CalendarDays, clock: Clock, message: MessageSquare, text: Type, qr: QrCode, weather: CloudSun, menu: UtensilsCrossed, hstack: Columns3, vstack: Rows3 }
const iconOf = w => (w.kind === 'stack' ? (w.direction === 'column' ? Rows3 : Columns3) : ICON[w.kind] || LayoutList)
const kindLabel = (t, w) => t(`signage.widgets.kinds.${w.kind === 'stack' ? (w.direction === 'column' ? 'vstack' : 'hstack') : w.kind}`)
const ROW = 'grid gap-4 items-end grid-cols-[repeat(auto-fill,minmax(11rem,1fr))]'
export default function WidgetsEditor({ widgets = [], onChange, media, onMedia, selected = null, onSelect }) {
let library = null // the Slides library (for stacks' parts), read once
function useLibrary() {
const [list, setList] = useState(library || [])
useEffect(() => {
api.listSaved().then(r => { library = r.slides; setList(r.slides) }).catch(() => {})
}, [])
return list
}
export default function WidgetsEditor({ widgets = [], onChange, media, onMedia, selected = null, onSelect, extras = {} }) {
const { t } = useTranslation('manager')
const [drag, setDrag] = useState(null) // { from, at }: the card dragged and where it would land
const set = (i, patch) => onChange(widgets.map((w, j) => (j === i ? { ...w, ...patch } : w)))
const add = kind => {
onChange([...widgets, { kind, position: kind === 'message' ? 'bottom-bar' : 'top-right', size: 'medium', align: 'auto' }])
onChange([...widgets, newWidget(kind)])
onSelect?.(widgets.length)
}
const move = (from, to) => {
if (to < 0 || to >= widgets.length || from === to) return
onChange(moved(widgets, from, to))
onSelect?.(pickedAfterMove(selected, from, to))
}
const over = (e, i) => {
if (!drag) return
e.preventDefault()
const r = e.currentTarget.getBoundingClientRect()
const at = e.clientY < r.top + r.height / 2 ? i : i + 1
if (at !== drag.at) setDrag(d => ({ ...d, at }))
}
const drop = () => {
if (drag && drag.at != null) move(drag.from, drag.at > drag.from ? drag.at - 1 : drag.at)
setDrag(null)
}
const line = i => drag && drag.at === i && drag.at !== drag.from && drag.at !== drag.from + 1 && (
<div className="h-0.5 -my-1.5 rounded-full bg-accent" data-testid="signage-widget-drop-line" aria-hidden="true" />
)
return (
<Section title={t('signage.widgets.title')} testid="signage-widgets">
<p className="text-caption text-ink-3 -mt-1">{t(widgets.length ? 'signage.widgets.dragHint' : 'signage.widgets.none')}</p>
{widgets.map((w, i) => {
const Icon = ICON[w.kind] || ImageIcon
const Icon = iconOf(w)
const custom = w.position === 'custom'
const on = selected === i
return (
<div key={i} onPointerDown={() => onSelect?.(i)}
className={`grid gap-3 rounded-card border p-4 transition-colors duration-fast ${on ? 'border-accent bg-accent-soft/40 ring-1 ring-accent' : 'border-line bg-surface-2'}`}
data-testid="signage-widget" data-kind={w.kind} data-selected={on ? 'true' : undefined}>
<div className="flex items-center gap-2">
<Icon size={16} className="text-ink-2 shrink-0" aria-hidden="true" />
<span className="text-body font-semibold text-ink">{t(`signage.widgets.kinds.${w.kind}`)}</span>
<span className="flex-1" />
<IconButton size="sm" tone="danger" label={t('fees.delete')} data-testid="signage-widget-remove"
onClick={e => { e.stopPropagation(); onChange(widgets.filter((_, j) => j !== i)); onSelect?.(null) }}><Trash2 size={16} /></IconButton>
<div key={i} className="grid gap-3">
{line(i)}
<div onPointerDown={() => onSelect?.(i)} onDragOver={e => over(e, i)} onDrop={drop}
className={`grid gap-4 rounded-card border p-4 transition-colors duration-fast ${on ? 'border-accent bg-accent-soft/40 ring-1 ring-accent' : 'border-line bg-surface-2'}
${drag?.from === i ? 'opacity-50' : ''}`}
data-testid="signage-widget" data-kind={w.kind} data-index={i} data-selected={on ? 'true' : undefined}>
<div className="flex items-center gap-2">
<span draggable onDragStart={e => { e.dataTransfer.effectAllowed = 'move'; setDrag({ from: i, at: null }) }} onDragEnd={() => setDrag(null)}
className="cursor-grab active:cursor-grabbing text-ink-3 hover:text-ink -ml-1 p-0.5 rounded" title={t('signage.widgets.dragToOrder')}
aria-hidden="true" data-testid="signage-widget-grip"><GripVertical size={16} /></span>
<Icon size={16} className="text-ink-2 shrink-0" aria-hidden="true" />
<span className="text-body font-semibold text-ink">{kindLabel(t, w)}</span>
<span className="flex-1" />
<IconButton size="sm" label={t('signage.widgets.earlier')} disabled={i === 0} onClick={e => { e.stopPropagation(); move(i, i - 1) }}
data-testid="signage-widget-up"><ArrowUp size={16} /></IconButton>
<IconButton size="sm" label={t('signage.widgets.later')} disabled={i === widgets.length - 1} onClick={e => { e.stopPropagation(); move(i, i + 1) }}
data-testid="signage-widget-down"><ArrowDown size={16} /></IconButton>
<IconButton size="sm" tone="danger" label={t('fees.delete')} data-testid="signage-widget-remove"
onClick={e => { e.stopPropagation(); onChange(widgets.filter((_, j) => j !== i)); onSelect?.(null) }}><Trash2 size={16} /></IconButton>
</div>
<div className={ROW}>
<Field label={t('signage.widgets.position')}>
<Dropdown value={w.position} onChange={p => p !== 'custom' && onChange(widgets.map((x, j) => (j === i ? presetWidget(x, p) : x)))}
data-testid="signage-widget-position"
options={[...WIDGET_POSITIONS.map(p => ({ value: p, label: t(`signage.widgets.positions.${p}`) })),
...(custom ? [{ value: 'custom', label: t('signage.widgets.custom') }] : [])]} />
</Field>
<Field label={t('signage.widgets.size')}>
<Dropdown value={custom ? 'custom' : (w.size || 'medium')} disabled={custom} onChange={size => set(i, { size })} data-testid="signage-widget-size"
options={[...['small', 'medium', 'large'].map(s => ({ value: s, label: t(`signage.widgets.sizes.${s}`) })),
...(custom ? [{ value: 'custom', label: t('signage.widgets.custom') }] : [])]} />
</Field>
{w.kind !== 'stack' && <AlignField w={w} set={patch => set(i, patch)} />}
<InlineFields w={w} set={patch => set(i, patch)} />
</div>
<BelowFields w={w} set={patch => set(i, patch)} media={media} onMedia={onMedia} extras={extras} path={String(i)} depth={0} />
</div>
<div className="flex flex-wrap items-end gap-3">
<Field label={t('signage.widgets.position')} className="w-44">
<Dropdown value={w.position} onChange={p => p !== 'custom' && onChange(widgets.map((x, j) => (j === i ? presetWidget(x, p) : x)))}
data-testid="signage-widget-position"
options={[...WIDGET_POSITIONS.map(p => ({ value: p, label: t(`signage.widgets.positions.${p}`) })),
...(custom ? [{ value: 'custom', label: t('signage.widgets.custom') }] : [])]} />
</Field>
<Field label={t('signage.widgets.size')} className="w-36">
<Dropdown value={custom ? 'custom' : (w.size || 'medium')} disabled={custom} onChange={size => set(i, { size })} data-testid="signage-widget-size"
options={[...['small', 'medium', 'large'].map(s => ({ value: s, label: t(`signage.widgets.sizes.${s}`) })),
...(custom ? [{ value: 'custom', label: t('signage.widgets.custom') }] : [])]} />
</Field>
<Field label={t('signage.widgets.align')}>
<Segmented value={w.align || 'auto'} onChange={align => set(i, { align })} aria-label={t('signage.widgets.align')} data-testid="signage-widget-align"
options={[
{ value: 'auto', label: t('signage.widgets.alignAuto'), testId: 'signage-widget-align-auto' },
{ value: 'left', icon: <AlignLeft size={16} aria-hidden="true" />, ariaLabel: t('signage.aligns.left'), testId: 'signage-widget-align-left' },
{ value: 'center', icon: <AlignCenter size={16} aria-hidden="true" />, ariaLabel: t('signage.aligns.center'), testId: 'signage-widget-align-center' },
{ value: 'right', icon: <AlignRight size={16} aria-hidden="true" />, ariaLabel: t('signage.aligns.right'), testId: 'signage-widget-align-right' },
]} />
</Field>
<KindFields w={w} set={patch => set(i, patch)} media={media} onMedia={onMedia} />
</div>
{w.kind === 'weather' && <p className="text-caption text-ink-3">{t('signage.widgets.weatherNeedsInternet')}</p>}
</div>
)
})}
{line(widgets.length)}
{widgets.length < 10 && (
<div className="flex flex-wrap items-center gap-1.5">
{WIDGET_KINDS.map(k => {
{[...WIDGET_KINDS, 'hstack', 'vstack'].map(k => {
const Icon = ICON[k]
return (
<Button key={k} size="sm" variant="secondary" icon={<Plus size={14} />} onClick={() => add(k)} data-testid={`signage-widget-add-${k}`}>
@@ -81,50 +133,202 @@ export default function WidgetsEditor({ widgets = [], onChange, media, onMedia,
)
}
/** The options only some widgets have, on the same row. */
function KindFields({ w, set, media, onMedia }) {
/** How the widget lines up in its place: auto, left, centre, right. */
function AlignField({ w, set, testid = 'signage-widget-align' }) {
const { t } = useTranslation('manager')
return (
<Field label={t('signage.widgets.align')}>
<Segmented value={w.align || 'auto'} onChange={align => set({ align })} aria-label={t('signage.widgets.align')} data-testid={testid} fill
options={[
{ value: 'auto', label: t('signage.widgets.alignAuto'), testId: `${testid}-auto` },
{ value: 'left', icon: <AlignLeft size={16} aria-hidden="true" />, ariaLabel: t('signage.aligns.left'), testId: `${testid}-left` },
{ value: 'center', icon: <AlignCenter size={16} aria-hidden="true" />, ariaLabel: t('signage.aligns.center'), testId: `${testid}-center` },
{ value: 'right', icon: <AlignRight size={16} aria-hidden="true" />, ariaLabel: t('signage.aligns.right'), testId: `${testid}-right` },
]} />
</Field>
)
}
/** The options only some widgets have, on the same row as where / size / alignment. */
function InlineFields({ w, set }) {
const { t } = useTranslation('manager')
if (w.kind === 'logo') {
return <MediaPick kind="image" value={w.media_id} entry={media[String(w.media_id)]} testid="signage-widget-logo"
onChange={item => { onMedia(item); set({ media_id: item.id }) }} />
}
if (w.kind === 'message') {
return (
<Field label={t('signage.widgets.ownText')} hint={t('signage.widgets.ownTextHint')} className="flex-1 min-w-[14rem]">
<Input value={w.text || ''} maxLength={200} onChange={e => set({ text: e.target.value || null })} data-testid="signage-widget-text" />
<Field label={t('signage.widgets.ownText')} className="col-span-2">
<Input value={w.text || ''} maxLength={200} placeholder={t('signage.widgets.ownTextPlaceholder')} onChange={e => set({ text: e.target.value || null })} data-testid="signage-widget-text" />
</Field>
)
}
if (w.kind === 'text') {
return (
<Field label={t('signage.widgets.theText')} className="col-span-2">
<Input value={w.text || ''} maxLength={200} onChange={e => set({ text: e.target.value || null })} data-testid="signage-widget-own-text" />
</Field>
)
}
if (w.kind === 'date') {
return (
<Field label={t('signage.widgets.dateStyle')} className="w-56">
<Field label={t('signage.widgets.dateStyle')}>
<Dropdown value={w.date_style || 'long'} onChange={date_style => set({ date_style })}
options={[{ value: 'long', label: t('signage.widgets.dateLong') }, { value: 'short', label: t('signage.widgets.dateShort') }]} />
</Field>
)
}
if (w.kind === 'clock') {
return <Switch boxed className="w-44" checked={!!w.clock_seconds} onChange={on => set({ clock_seconds: on })} label={t('signage.widgets.seconds')} />
}
if (w.kind === 'qr') {
return (<>
<Field label={t('display.qrTarget')} className="w-48">
<Dropdown value={w.qr_target || 'ordering'} onChange={qr_target => set({ qr_target })}
options={['ordering', 'menu', 'custom'].map(q => ({ value: q, label: t(`display.qrTargets.${q}`) }))} />
</Field>
{w.qr_target === 'custom' && (
<Field label={t('display.qrUrl')} className="flex-1 min-w-[12rem]"><Input value={w.qr_url || ''} placeholder="https://" onChange={e => set({ qr_url: e.target.value || null })} /></Field>
)}
<Field label={t('display.qrCaption')} className="flex-1 min-w-[10rem]"><Input value={w.qr_caption || ''} maxLength={80} onChange={e => set({ qr_caption: e.target.value || null })} /></Field>
</>)
}
if (w.kind === 'weather') {
return (
<Field label={t('signage.widgets.weatherDays')} className="w-48">
<Dropdown value={String(w.weather_days || 1)} onChange={v => set({ weather_days: Number(v) })}
options={[1, 2, 3].map(n => ({ value: String(n), label: t('signage.widgets.days', { count: n }) }))} />
<Field label={t('signage.widgets.clockShows')}>
<Switch boxed className="h-control" checked={!!w.clock_seconds} onChange={on => set({ clock_seconds: on })} label={t('signage.widgets.seconds')} data-testid="signage-widget-seconds" />
</Field>
)
}
if (w.kind === 'qr') {
return (
<Field label={t('display.qrTarget')}>
<Dropdown value={w.qr_target || 'ordering'} onChange={qr_target => set({ qr_target })}
options={['ordering', 'menu', 'custom'].map(q => ({ value: q, label: t(`display.qrTargets.${q}`) }))} />
</Field>
)
}
if (w.kind === 'weather') {
return (<>
<Field label={t('signage.widgets.weatherDays')}>
<Dropdown value={weatherChoice(w)} data-testid="signage-widget-weather-days"
onChange={v => { const [from, days] = v.split('-').map(Number); set({ weather_from: from, weather_days: days }) }}
options={WEATHER_CHOICES.map(([from, days]) => ({ value: `${from}-${days}`, label: t(`signage.widgets.weatherChoices.${from}-${days}`) }))} />
</Field>
<Field label={t('signage.widgets.weatherStyle')}>
<Dropdown value={w.weather_style || 'both'} onChange={weather_style => set({ weather_style })} data-testid="signage-widget-weather-style"
options={['both', 'icon', 'text'].map(s => ({ value: s, label: t(`signage.widgets.weatherStyles.${s}`) }))} />
</Field>
</>)
}
return null
}
/** What needs more room, under the row: the picture, hints, the QR's own link, a menu's list, a stack's parts. */
function BelowFields({ w, set, media, onMedia, extras, path, depth }) {
const { t } = useTranslation('manager')
if (w.kind === 'logo') {
return <MediaPick kind="image" value={w.media_id} entry={media[String(w.media_id)]} testid="signage-widget-logo"
onChange={item => { onMedia(item); set({ media_id: item.id }) }} />
}
if (w.kind === 'message') return <p className="text-caption text-ink-3 -mt-2">{t('signage.widgets.ownTextHint')}</p>
if (w.kind === 'weather') return <p className="text-caption text-ink-3 -mt-2">{t('signage.widgets.weatherNeedsInternet')}</p>
if (w.kind === 'qr') {
return (
<div className={ROW}>
{w.qr_target === 'custom' && (
<Field label={t('display.qrUrl')} className="col-span-2"><Input value={w.qr_url || ''} placeholder="https://" onChange={e => set({ qr_url: e.target.value || null })} /></Field>
)}
<Field label={t('display.qrCaption')} className="col-span-2"><Input value={w.qr_caption || ''} maxLength={80} onChange={e => set({ qr_caption: e.target.value || null })} /></Field>
</div>
)
}
if (w.kind === 'menu') return <MenuBoardFields w={w} set={set} extras={extras} path={path} />
if (w.kind === 'stack') return <StackFields w={w} set={set} media={media} onMedia={onMedia} extras={extras} path={path} depth={depth} />
return null
}
/** A menu widget's list and look: the menu board's editor, folded away until it is opened. */
function MenuBoardFields({ w, set, extras, path }) {
const { t } = useTranslation('manager')
const [open, setOpen] = useState(false)
const menu = extras?.[path]?.menu
return (
<div className="grid gap-4 rounded-control border border-line bg-surface p-3">
<button type="button" onClick={() => setOpen(o => !o)} aria-expanded={open} data-testid="signage-widget-menu-toggle"
className="flex items-center gap-2 text-left text-label font-medium text-ink">
<UtensilsCrossed size={15} className="text-ink-2" aria-hidden="true" />
<span className="flex-1">{t('signage.widgets.menuEdit', { count: menu?.count ?? 0 })}</span>
<ChevronDown size={16} className={`text-ink-3 transition-transform duration-fast ${open ? 'rotate-180' : ''}`} aria-hidden="true" />
</button>
{open && (
<MenuEditor board testid="signage-widget-menu-editor" slide={{ kind: 'menu', content: w.board || {}, menu }}
onChange={s => set({ board: s.content })} />
)}
</div>
)
}
/**
* A stack's parts: side by side or one over the other, how many (2–6), each its share (%; changing
* one gives or takes from its neighbour, "even" splits them equally) and what it shows.
*/
function StackFields({ w, set, media, onMedia, extras, path, depth }) {
const { t } = useTranslation('manager')
const slides = useLibrary()
const cells = w.cells || []
const shares = cells.map(c => Math.round(c.share || 0))
const setCells = next => set({ cells: next })
const setCell = (j, patch) => setCells(cells.map((c, k) => (k === j ? { ...c, ...patch } : c)))
const count = n => {
const even = evenShares(n)
setCells(Array.from({ length: n }, (_, k) => ({ ...(cells[k] || {}), share: even[k] })))
}
const shows = c => (c.slide_id ? 'slide' : c.widget ? (c.widget.kind === 'stack' ? (c.widget.direction === 'column' ? 'vstack' : 'hstack') : c.widget.kind) : '')
const pick = (j, v) => {
if (!v) setCell(j, { widget: null, slide_id: null })
else if (v === 'slide') setCell(j, { widget: null, slide_id: slides[0]?.id ?? null })
else setCell(j, { widget: cellWidget(v), slide_id: null })
}
const kinds = [...CELL_KINDS, ...(depth === 0 ? ['hstack', 'vstack'] : [])]
return (
<div className="grid gap-3 rounded-control border border-line bg-surface p-3" data-testid="signage-stack-editor" data-depth={depth}>
<div className={ROW}>
<Field label={t('signage.widgets.stack.direction')}>
<Segmented value={w.direction || 'row'} onChange={direction => set({ direction })} fill data-testid="signage-stack-direction"
options={[{ value: 'row', icon: <Columns3 size={16} aria-hidden="true" />, ariaLabel: t('signage.widgets.stack.row'), testId: 'signage-stack-row' },
{ value: 'column', icon: <Rows3 size={16} aria-hidden="true" />, ariaLabel: t('signage.widgets.stack.column'), testId: 'signage-stack-column' }]} />
</Field>
<Field label={t('signage.widgets.stack.parts')}>
<Segmented value={String(cells.length)} onChange={v => count(Number(v))} fill data-testid="signage-stack-count"
options={[2, 3, 4, 5, 6].map(n => ({ value: String(n), label: String(n), testId: `signage-stack-count-${n}` }))} />
</Field>
<div className="flex items-end">
<Button variant="secondary" onClick={() => count(cells.length)} data-testid="signage-stack-even">{t('signage.widgets.stack.even')}</Button>
</div>
</div>
{/* the parts as they share the stack */}
<div className={`flex ${w.direction === 'column' ? 'flex-col h-20 w-32' : 'h-8'} gap-0.5 rounded-control overflow-hidden`} aria-hidden="true">
{cells.map((c, j) => (
<span key={j} style={{ flex: `${c.share || 1} 1 0%` }}
className="grid place-items-center bg-accent-soft text-accent-ink text-caption font-semibold tabular-nums min-w-0 min-h-0">{shares[j]}%</span>
))}
</div>
{cells.map((c, j) => {
const cp = `${path}.${j}`
const v = shows(c)
return (
<div key={j} className="grid gap-3 rounded-control border border-line bg-surface-2 p-3" data-testid="signage-stack-cell-editor" data-index={j}>
<div className={ROW}>
<Field label={t('signage.widgets.stack.part', { n: j + 1 })}>
<Input inputMode="numeric" value={String(shares[j])} data-testid="signage-stack-share"
onChange={e => { const next = setShare(shares, j, e.target.value.replace(/\D/g, '')); setCells(cells.map((x, k) => ({ ...x, share: next[k] }))) }} />
</Field>
<Field label={t('signage.widgets.stack.shows')}>
<Dropdown value={v} onChange={x => pick(j, x)} data-testid="signage-stack-shows"
options={[{ value: '', label: t('signage.widgets.stack.nothing') },
...kinds.map(k => ({ value: k, label: t(`signage.widgets.kinds.${k}`) })),
{ value: 'slide', label: t('signage.widgets.stack.aSlide') }]} />
</Field>
{c.slide_id != null || v === 'slide' ? (
<Field label={t('signage.widgets.stack.slide')} className="col-span-2">
<Dropdown value={c.slide_id != null ? String(c.slide_id) : ''} onChange={x => setCell(j, { slide_id: x ? Number(x) : null })} data-testid="signage-stack-slide"
options={slides.length ? slides.map(s => ({ value: String(s.id), label: s.name }))
: [{ value: '', label: t('signage.widgets.stack.noSlides') }]} />
</Field>
) : c.widget && <>
{c.widget.kind !== 'stack' && <AlignField w={c.widget} set={patch => setCell(j, { widget: { ...c.widget, ...patch } })} testid="signage-cell-align" />}
<InlineFields w={c.widget} set={patch => setCell(j, { widget: { ...c.widget, ...patch } })} />
</>}
</div>
{c.widget && (
<BelowFields w={c.widget} set={patch => setCell(j, { widget: { ...c.widget, ...patch } })} media={media} onMedia={onMedia}
extras={extras} path={cp} depth={depth + 1} />
)}
</div>
)
})}
</div>
)
}