@podoba/react 0.0.52 → 0.0.53
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/package.json +4 -4
- package/src/components/asset-selection-surface.tsx +264 -67
- package/src/components/citation.examples.tsx +14 -0
- package/src/components/citation.tsx +27 -0
- package/src/components/column-layout.examples.tsx +34 -0
- package/src/components/column-layout.tsx +36 -0
- package/src/components/combobox.tsx +9 -4
- package/src/components/compact-settings-dialog.tsx +80 -21
- package/src/components/date-picker.tsx +49 -8
- package/src/components/delivery/send-to-print-modal.tsx +191 -225
- package/src/components/field-appearance.ts +11 -1
- package/src/components/icon-button.examples.tsx +16 -0
- package/src/components/icon-button.tsx +20 -0
- package/src/components/input.tsx +25 -12
- package/src/components/island-toolbar.examples.tsx +27 -0
- package/src/components/island-toolbar.tsx +39 -0
- package/src/components/media-asset-panel.examples.tsx +44 -5
- package/src/components/media-asset-panel.tsx +339 -28
- package/src/components/media-collection.examples.tsx +18 -0
- package/src/components/media-collection.tsx +206 -0
- package/src/components/number-field.tsx +18 -9
- package/src/components/preview-error.examples.tsx +20 -0
- package/src/components/preview-error.tsx +29 -0
- package/src/components/preview-metadata-card.examples.tsx +32 -0
- package/src/components/preview-metadata-card.tsx +112 -0
- package/src/components/search-field.tsx +27 -7
- package/src/components/select.tsx +81 -50
- package/src/components/settings-dialog-surface.tsx +553 -114
- package/src/components/template-catalog-card.tsx +309 -78
- package/src/components/textarea.tsx +160 -12
- package/src/components/tile.tsx +30 -16
- package/src/components/zoomable-image.examples.tsx +33 -0
- package/src/components/zoomable-image.tsx +185 -0
- package/src/index.ts +96 -78
|
@@ -22,8 +22,7 @@
|
|
|
22
22
|
// shows a pending state and disables while in flight / invalid.
|
|
23
23
|
|
|
24
24
|
import { useId, useMemo, useState } from 'react'
|
|
25
|
-
import {
|
|
26
|
-
import { ModalDialog, ModalOverlay, ModalSurface } from '../dialog'
|
|
25
|
+
import { SettingsDialogAction, SettingsDialogSurface } from '../settings-dialog-surface'
|
|
27
26
|
import { Input } from '../input'
|
|
28
27
|
|
|
29
28
|
/** The validated print spec the modal yields on confirm. */
|
|
@@ -121,6 +120,8 @@ export interface SendToPrintModalProps {
|
|
|
121
120
|
/** Server / mutation error message to surface inline (role="alert"). */
|
|
122
121
|
error?: string
|
|
123
122
|
/** App-supplied i18n strings. */
|
|
123
|
+
/** Optional emphasized heading using the shared settings typography. */
|
|
124
|
+
heading?: React.ReactNode
|
|
124
125
|
labels: SendToPrintModalLabels
|
|
125
126
|
/** Output title shown in the old Manager print-order summary card. */
|
|
126
127
|
outputName?: string
|
|
@@ -130,7 +131,7 @@ export interface SendToPrintModalProps {
|
|
|
130
131
|
materialOptions?: PrintMaterialOption[]
|
|
131
132
|
/** Initial quantity. Old Manager opens print with a production-like quantity instead of blank. */
|
|
132
133
|
initialQuantity?: number
|
|
133
|
-
/**
|
|
134
|
+
/** @deprecated Print uses the shared basic settings surface for every caller. */
|
|
134
135
|
surfaceVariant?: 'standard' | 'dashboard'
|
|
135
136
|
/** Optional test id forwarded to the dialog. */
|
|
136
137
|
'data-testid'?: string
|
|
@@ -159,14 +160,13 @@ export function SendToPrintModal({
|
|
|
159
160
|
isPending = false,
|
|
160
161
|
error,
|
|
161
162
|
labels,
|
|
163
|
+
heading,
|
|
162
164
|
outputName,
|
|
163
165
|
outputDescription,
|
|
164
166
|
materialOptions = [],
|
|
165
167
|
initialQuantity = 500,
|
|
166
|
-
surfaceVariant = 'standard',
|
|
167
168
|
'data-testid': testId,
|
|
168
169
|
}: SendToPrintModalProps): React.ReactNode {
|
|
169
|
-
const titleId = useId()
|
|
170
170
|
const descriptionId = useId()
|
|
171
171
|
// `materialOptions` is normally fetched, so it is [] on mount. Seeding useState
|
|
172
172
|
// from it captures that empty first render forever; deriving the fallback each
|
|
@@ -249,235 +249,201 @@ export function SendToPrintModal({
|
|
|
249
249
|
})
|
|
250
250
|
}
|
|
251
251
|
|
|
252
|
-
const surfaceClassName = surfaceVariant === 'dashboard'
|
|
253
|
-
? 'box-border flex h-[min(90vh,72rem)] max-h-[min(90vh,72rem)] w-[min(50vw,72rem)] max-w-[min(50vw,72rem)] flex-col overflow-hidden p-0 max-[900px]:h-[90vh] max-[900px]:w-[92vw] max-[900px]:max-w-[92vw]'
|
|
254
|
-
: 'box-border flex h-[min(90vh,72rem)] max-h-[min(90vh,72rem)] w-[min(90vw,51rem)] max-w-[min(90vw,51rem)] flex-col overflow-hidden p-0 max-[900px]:h-[90vh] max-[900px]:w-[92vw] max-[900px]:max-w-[92vw]'
|
|
255
|
-
|
|
256
252
|
return (
|
|
257
|
-
<
|
|
253
|
+
<SettingsDialogSurface
|
|
254
|
+
variant="edit"
|
|
258
255
|
isOpen={isOpen}
|
|
259
256
|
onOpenChange={handleOpenChange}
|
|
260
|
-
|
|
257
|
+
isPending={isPending}
|
|
258
|
+
label={labels.title}
|
|
259
|
+
title={heading ?? labels.title}
|
|
260
|
+
closeLabel={labels.closeLabel ?? labels.cancel}
|
|
261
|
+
describedBy={descriptionId}
|
|
262
|
+
bodyTestId={testId ?? 'delivery-print-modal'}
|
|
263
|
+
footer={
|
|
264
|
+
<>
|
|
265
|
+
<SettingsDialogAction variant="secondary" isDisabled={isPending} onPress={() => handleOpenChange(false)}>
|
|
266
|
+
{labels.cancel}
|
|
267
|
+
</SettingsDialogAction>
|
|
268
|
+
<SettingsDialogAction
|
|
269
|
+
data-testid="delivery-print-confirm"
|
|
270
|
+
isDisabled={!canConfirm}
|
|
271
|
+
isPending={isPending}
|
|
272
|
+
onPress={handleConfirm}
|
|
273
|
+
>
|
|
274
|
+
{isPending ? labels.submitting : labels.confirm}
|
|
275
|
+
</SettingsDialogAction>
|
|
276
|
+
</>
|
|
277
|
+
}
|
|
261
278
|
>
|
|
262
|
-
<
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
noValidate
|
|
277
|
-
>
|
|
278
|
-
<div className="mx-auto box-border w-full max-w-[50rem] px-5">
|
|
279
|
-
<div className="flex items-start justify-between gap-4">
|
|
280
|
-
<h2 id={titleId} className="m-0 max-w-[19ch] text-heading1 font-medium leading-[1.02] tracking-tight text-fg">
|
|
281
|
-
{labels.title}
|
|
282
|
-
</h2>
|
|
283
|
-
<button
|
|
284
|
-
type="button"
|
|
285
|
-
onClick={close}
|
|
286
|
-
aria-label={labels.closeLabel ?? 'Close'}
|
|
287
|
-
className="-mr-1 -mt-1 inline-flex h-8 w-8 shrink-0 cursor-pointer items-center justify-center rounded-md text-fg-subtle outline-none transition-colors hover:bg-surface-muted hover:text-fg focus-visible:ring-2 focus-visible:ring-ring"
|
|
288
|
-
>
|
|
289
|
-
<svg
|
|
290
|
-
width="18"
|
|
291
|
-
height="18"
|
|
292
|
-
viewBox="0 0 24 24"
|
|
293
|
-
fill="none"
|
|
294
|
-
stroke="currentColor"
|
|
295
|
-
strokeWidth="2"
|
|
296
|
-
strokeLinecap="round"
|
|
297
|
-
aria-hidden="true"
|
|
298
|
-
>
|
|
299
|
-
<path d="M6 6l12 12M18 6 6 18" />
|
|
300
|
-
</svg>
|
|
301
|
-
</button>
|
|
302
|
-
</div>
|
|
303
|
-
</div>
|
|
304
|
-
|
|
305
|
-
<div className="min-h-0 flex-1 overflow-y-auto [scrollbar-gutter:stable]">
|
|
306
|
-
<div className="mx-auto box-border flex w-full max-w-[50rem] flex-col gap-6 px-5">
|
|
307
|
-
<div className="flex flex-col gap-1">
|
|
308
|
-
<p className="m-0 text-body font-medium text-fg">
|
|
309
|
-
{labels.sectionLabel ?? labels.title}
|
|
310
|
-
</p>
|
|
311
|
-
<p id={descriptionId} className="m-0 max-w-[48ch] text-body font-normal text-fg">
|
|
312
|
-
{labels.body}
|
|
313
|
-
</p>
|
|
314
|
-
</div>
|
|
279
|
+
<form
|
|
280
|
+
className="flex flex-col gap-6"
|
|
281
|
+
onSubmit={(event) => {
|
|
282
|
+
event.preventDefault()
|
|
283
|
+
handleConfirm()
|
|
284
|
+
}}
|
|
285
|
+
noValidate
|
|
286
|
+
>
|
|
287
|
+
<div className="flex flex-col gap-1">
|
|
288
|
+
<p className="m-0 text-body font-medium text-fg">{labels.sectionLabel ?? labels.title}</p>
|
|
289
|
+
<p id={descriptionId} className="m-0 max-w-[48ch] text-body font-normal text-fg">
|
|
290
|
+
{labels.body}
|
|
291
|
+
</p>
|
|
292
|
+
</div>
|
|
315
293
|
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
294
|
+
<div className="flex flex-col gap-1 rounded-md bg-surface-card p-3 text-caption leading-4 text-fg-muted">
|
|
295
|
+
<span>{outputName?.trim() || labels.outputName || labels.sizeLabel}</span>
|
|
296
|
+
{outputDescription?.trim() || labels.outputDescription || labels.sizePlaceholder ? (
|
|
297
|
+
<strong className="font-medium text-fg">
|
|
298
|
+
{outputDescription?.trim() || labels.outputDescription || labels.sizePlaceholder}
|
|
299
|
+
</strong>
|
|
300
|
+
) : null}
|
|
301
|
+
</div>
|
|
324
302
|
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
label={labels.quantityLabel}
|
|
338
|
-
placeholder={labels.quantityPlaceholder}
|
|
339
|
-
value={quantityRaw}
|
|
340
|
-
onChange={setQuantityRaw}
|
|
341
|
-
type="number"
|
|
342
|
-
inputMode="numeric"
|
|
343
|
-
isInvalid={quantityInvalid}
|
|
344
|
-
errorMessage={quantityInvalid ? labels.quantityError : undefined}
|
|
345
|
-
data-testid="delivery-print-quantity"
|
|
346
|
-
/>
|
|
303
|
+
<div className="grid gap-3">
|
|
304
|
+
{derivedSize ? null : (
|
|
305
|
+
<Input
|
|
306
|
+
appearance="filled"
|
|
307
|
+
isDisabled={isPending}
|
|
308
|
+
label={labels.sizeLabel}
|
|
309
|
+
placeholder={labels.sizePlaceholder}
|
|
310
|
+
value={sizeRaw}
|
|
311
|
+
onChange={setSizeRaw}
|
|
312
|
+
data-testid="delivery-print-size"
|
|
313
|
+
/>
|
|
314
|
+
)}
|
|
347
315
|
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
))}
|
|
362
|
-
</select>
|
|
363
|
-
</label>
|
|
364
|
-
) : selectedMaterial ? (
|
|
365
|
-
<div
|
|
366
|
-
data-testid="delivery-print-material"
|
|
367
|
-
className="flex flex-col gap-1 rounded-md bg-surface-card p-3 text-caption leading-4 text-fg-muted"
|
|
368
|
-
>
|
|
369
|
-
<span>{labels.materialLabel}</span>
|
|
370
|
-
<strong className="font-medium text-fg">{selectedMaterial.label}</strong>
|
|
371
|
-
</div>
|
|
372
|
-
) : (
|
|
373
|
-
<p
|
|
374
|
-
role="note"
|
|
375
|
-
data-testid="delivery-print-material"
|
|
376
|
-
className="m-0 rounded-md bg-surface-card p-3 text-caption leading-4 text-fg-muted"
|
|
377
|
-
>
|
|
378
|
-
{labels.noMaterialConfigured ?? labels.materialPlaceholder}
|
|
379
|
-
</p>
|
|
380
|
-
)}
|
|
316
|
+
<Input
|
|
317
|
+
appearance="filled"
|
|
318
|
+
isDisabled={isPending}
|
|
319
|
+
label={labels.quantityLabel}
|
|
320
|
+
placeholder={labels.quantityPlaceholder}
|
|
321
|
+
value={quantityRaw}
|
|
322
|
+
onChange={setQuantityRaw}
|
|
323
|
+
type="number"
|
|
324
|
+
inputMode="numeric"
|
|
325
|
+
isInvalid={quantityInvalid}
|
|
326
|
+
errorMessage={quantityInvalid ? labels.quantityError : undefined}
|
|
327
|
+
data-testid="delivery-print-quantity"
|
|
328
|
+
/>
|
|
381
329
|
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
value={contactName}
|
|
417
|
-
onChange={setContactName}
|
|
418
|
-
data-testid="delivery-print-contact"
|
|
419
|
-
/>
|
|
420
|
-
<Input
|
|
421
|
-
label={labels.phoneLabel ?? labels.addressLabel}
|
|
422
|
-
placeholder={labels.phonePlaceholder ?? labels.addressPlaceholder}
|
|
423
|
-
value={phone}
|
|
424
|
-
onChange={setPhone}
|
|
425
|
-
type="tel"
|
|
426
|
-
data-testid="delivery-print-phone"
|
|
427
|
-
/>
|
|
428
|
-
</div>
|
|
429
|
-
<Input
|
|
430
|
-
label={labels.noteLabel ?? labels.addressLabel}
|
|
431
|
-
placeholder={labels.notePlaceholder ?? labels.addressPlaceholder}
|
|
432
|
-
value={note}
|
|
433
|
-
onChange={setNote}
|
|
434
|
-
data-testid="delivery-print-note"
|
|
435
|
-
/>
|
|
436
|
-
</div>
|
|
330
|
+
{materialOptions.length > 1 ? (
|
|
331
|
+
<label className="grid gap-1.5 text-small font-medium text-fg">
|
|
332
|
+
<span>{labels.materialLabel}</span>
|
|
333
|
+
<select
|
|
334
|
+
disabled={isPending}
|
|
335
|
+
value={effectiveMaterialId}
|
|
336
|
+
onChange={(event) => setMaterialId(event.currentTarget.value)}
|
|
337
|
+
data-testid="delivery-print-material"
|
|
338
|
+
className="h-12 rounded-md border border-border bg-surface px-3 text-body font-normal text-fg outline-none transition-colors hover:border-border-muted focus:border-fg focus:ring-2 focus:ring-ring"
|
|
339
|
+
>
|
|
340
|
+
{materialOptions.map((option) => (
|
|
341
|
+
<option key={option.id} value={option.id}>
|
|
342
|
+
{option.label}
|
|
343
|
+
</option>
|
|
344
|
+
))}
|
|
345
|
+
</select>
|
|
346
|
+
</label>
|
|
347
|
+
) : selectedMaterial ? (
|
|
348
|
+
<div
|
|
349
|
+
data-testid="delivery-print-material"
|
|
350
|
+
className="flex flex-col gap-1 rounded-md bg-surface-card p-3 text-caption leading-4 text-fg-muted"
|
|
351
|
+
>
|
|
352
|
+
<span>{labels.materialLabel}</span>
|
|
353
|
+
<strong className="font-medium text-fg">{selectedMaterial.label}</strong>
|
|
354
|
+
</div>
|
|
355
|
+
) : (
|
|
356
|
+
<p
|
|
357
|
+
role="note"
|
|
358
|
+
data-testid="delivery-print-material"
|
|
359
|
+
className="m-0 rounded-md bg-surface-card p-3 text-caption leading-4 text-fg-muted"
|
|
360
|
+
>
|
|
361
|
+
{labels.noMaterialConfigured ?? labels.materialPlaceholder}
|
|
362
|
+
</p>
|
|
363
|
+
)}
|
|
437
364
|
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
365
|
+
<Input
|
|
366
|
+
appearance="filled"
|
|
367
|
+
isDisabled={isPending}
|
|
368
|
+
label={labels.companyLabel ?? labels.addressLabel}
|
|
369
|
+
placeholder={labels.companyPlaceholder ?? labels.addressPlaceholder}
|
|
370
|
+
value={company}
|
|
371
|
+
onChange={setCompany}
|
|
372
|
+
data-testid="delivery-print-company"
|
|
373
|
+
/>
|
|
374
|
+
<Input
|
|
375
|
+
appearance="filled"
|
|
376
|
+
isDisabled={isPending}
|
|
377
|
+
label={labels.streetLabel ?? labels.addressLabel}
|
|
378
|
+
placeholder={labels.streetPlaceholder ?? labels.addressPlaceholder}
|
|
379
|
+
value={street}
|
|
380
|
+
onChange={(value) => setStreet(capitalizeFirstAddressLetter(value))}
|
|
381
|
+
data-testid="delivery-print-street"
|
|
382
|
+
/>
|
|
383
|
+
<div className="grid gap-4 sm:grid-cols-[1fr_10rem]">
|
|
384
|
+
<Input
|
|
385
|
+
appearance="filled"
|
|
386
|
+
isDisabled={isPending}
|
|
387
|
+
label={labels.cityLabel ?? labels.addressLabel}
|
|
388
|
+
placeholder={labels.cityPlaceholder ?? labels.addressPlaceholder}
|
|
389
|
+
value={city}
|
|
390
|
+
onChange={setCity}
|
|
391
|
+
data-testid="delivery-print-city"
|
|
392
|
+
/>
|
|
393
|
+
<Input
|
|
394
|
+
appearance="filled"
|
|
395
|
+
isDisabled={isPending}
|
|
396
|
+
label={labels.zipLabel ?? labels.addressLabel}
|
|
397
|
+
placeholder={labels.zipPlaceholder ?? labels.addressPlaceholder}
|
|
398
|
+
value={zip}
|
|
399
|
+
onChange={setZip}
|
|
400
|
+
data-testid="delivery-print-zip"
|
|
401
|
+
/>
|
|
402
|
+
</div>
|
|
403
|
+
<div className="grid gap-4 sm:grid-cols-2">
|
|
404
|
+
<Input
|
|
405
|
+
appearance="filled"
|
|
406
|
+
isDisabled={isPending}
|
|
407
|
+
label={labels.contactNameLabel ?? labels.addressLabel}
|
|
408
|
+
placeholder={labels.contactNamePlaceholder ?? labels.addressPlaceholder}
|
|
409
|
+
value={contactName}
|
|
410
|
+
onChange={setContactName}
|
|
411
|
+
data-testid="delivery-print-contact"
|
|
412
|
+
/>
|
|
413
|
+
<Input
|
|
414
|
+
appearance="filled"
|
|
415
|
+
isDisabled={isPending}
|
|
416
|
+
label={labels.phoneLabel ?? labels.addressLabel}
|
|
417
|
+
placeholder={labels.phonePlaceholder ?? labels.addressPlaceholder}
|
|
418
|
+
value={phone}
|
|
419
|
+
onChange={setPhone}
|
|
420
|
+
type="tel"
|
|
421
|
+
data-testid="delivery-print-phone"
|
|
422
|
+
/>
|
|
423
|
+
</div>
|
|
424
|
+
<Input
|
|
425
|
+
appearance="filled"
|
|
426
|
+
isDisabled={isPending}
|
|
427
|
+
label={labels.noteLabel ?? labels.addressLabel}
|
|
428
|
+
placeholder={labels.notePlaceholder ?? labels.addressPlaceholder}
|
|
429
|
+
value={note}
|
|
430
|
+
onChange={setNote}
|
|
431
|
+
data-testid="delivery-print-note"
|
|
432
|
+
/>
|
|
433
|
+
</div>
|
|
445
434
|
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
isDisabled={isPending}
|
|
460
|
-
onPress={() => handleOpenChange(false)}
|
|
461
|
-
>
|
|
462
|
-
{labels.cancel}
|
|
463
|
-
</Button>
|
|
464
|
-
<Button
|
|
465
|
-
data-testid="delivery-print-confirm"
|
|
466
|
-
variant="primary"
|
|
467
|
-
size="sm"
|
|
468
|
-
isDisabled={!canConfirm}
|
|
469
|
-
isPending={isPending}
|
|
470
|
-
onPress={handleConfirm}
|
|
471
|
-
>
|
|
472
|
-
{isPending ? labels.submitting : labels.confirm}
|
|
473
|
-
</Button>
|
|
474
|
-
</div>
|
|
475
|
-
</div>
|
|
476
|
-
</div>
|
|
477
|
-
</form>
|
|
478
|
-
)}
|
|
479
|
-
</ModalDialog>
|
|
480
|
-
</ModalSurface>
|
|
481
|
-
</ModalOverlay>
|
|
435
|
+
{error ? (
|
|
436
|
+
<p data-testid="delivery-print-error" role="alert" className="m-0 text-small text-danger">
|
|
437
|
+
{error}
|
|
438
|
+
</p>
|
|
439
|
+
) : null}
|
|
440
|
+
{labels.priceEyebrow || labels.priceIdle ? (
|
|
441
|
+
<div className="flex flex-col gap-1 text-small text-fg-muted">
|
|
442
|
+
{labels.priceEyebrow ? <span>{labels.priceEyebrow}</span> : null}
|
|
443
|
+
{labels.priceIdle ? <span>{labels.priceIdle}</span> : null}
|
|
444
|
+
</div>
|
|
445
|
+
) : null}
|
|
446
|
+
</form>
|
|
447
|
+
</SettingsDialogSurface>
|
|
482
448
|
)
|
|
483
449
|
}
|
|
@@ -21,7 +21,7 @@ export const filledFieldClasses =
|
|
|
21
21
|
export const fieldDescriptionClass = 'text-small text-fg-muted'
|
|
22
22
|
|
|
23
23
|
/** gs `.errorText`: 16px, line-height normal, error red (`danger`, 4.83:1 on white). */
|
|
24
|
-
export const fieldErrorClass = 'text-
|
|
24
|
+
export const fieldErrorClass = 'text-label leading-4 text-danger'
|
|
25
25
|
|
|
26
26
|
/** Field label, shared by every labelled form control (gs 17px/20px field label). */
|
|
27
27
|
export const fieldLabelClass = 'text-panel-heading font-medium text-fg'
|
|
@@ -66,3 +66,13 @@ export const outlinedFieldClasses = ({
|
|
|
66
66
|
invalid = 'self',
|
|
67
67
|
}: { focus?: keyof typeof outlinedFocus; invalid?: keyof typeof outlinedInvalid } = {}) =>
|
|
68
68
|
`${outlinedBase} ${outlinedFocus[focus]} ${outlinedInvalid[invalid]}`
|
|
69
|
+
|
|
70
|
+
/** Compact labels for dense settings cards; the value remains 14 px. */
|
|
71
|
+
export const fieldLabelClasses = { default: fieldLabelClass, compact: 'text-label font-normal text-fg-muted' } as const
|
|
72
|
+
export type FieldLabelSize = keyof typeof fieldLabelClasses
|
|
73
|
+
|
|
74
|
+
/** Filled single-line controls share the same 42 px geometry. */
|
|
75
|
+
export const fieldControlClasses = (appearance: FieldAppearance, size: FieldSize = 'md', within = false) =>
|
|
76
|
+
appearance === 'filled'
|
|
77
|
+
? `${filledFieldClasses} h-10.5 ${within ? 'data-[focus-within]:outline-solid data-[focus-within]:outline-2 data-[focus-within]:outline-ring data-[focus-within]:outline-offset-2 group-data-[invalid]:ring-1 group-data-[invalid]:ring-danger' : ''}`
|
|
78
|
+
: `${fieldSizeClasses[size]} ${outlinedFieldClasses({ focus: within ? 'within' : 'self', invalid: 'group' })}`
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { IconButton } from './icon-button'
|
|
2
|
+
export const examples = {
|
|
3
|
+
default: () => <IconButton label="Close">×</IconButton>,
|
|
4
|
+
variants: () => (
|
|
5
|
+
<div className="flex gap-3">
|
|
6
|
+
<IconButton label="Previous">‹</IconButton>
|
|
7
|
+
<IconButton label="Next">›</IconButton>
|
|
8
|
+
</div>
|
|
9
|
+
),
|
|
10
|
+
states: () => (
|
|
11
|
+
<IconButton label="Remove" isDisabled>
|
|
12
|
+
×
|
|
13
|
+
</IconButton>
|
|
14
|
+
),
|
|
15
|
+
}
|
|
16
|
+
export const meta = { category: 'Primitives', description: 'Compact ghost icon action with an accessible tooltip.' }
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ComponentProps, ReactNode } from 'react'
|
|
2
|
+
import { Button } from './button'
|
|
3
|
+
import { Tooltip, TooltipTrigger } from './tooltip'
|
|
4
|
+
|
|
5
|
+
/** The shared 36 px ghost action and its hover/keyboard hint. */
|
|
6
|
+
export function IconButton({
|
|
7
|
+
label,
|
|
8
|
+
children,
|
|
9
|
+
className,
|
|
10
|
+
...props
|
|
11
|
+
}: Omit<ComponentProps<typeof Button>, 'children' | 'aria-label'> & { label: string; children: ReactNode }) {
|
|
12
|
+
return (
|
|
13
|
+
<TooltipTrigger>
|
|
14
|
+
<Button variant="ghost" {...props} aria-label={label} className={`h-9 w-9 shrink-0 p-0 ${className ?? ''}`}>
|
|
15
|
+
{children}
|
|
16
|
+
</Button>
|
|
17
|
+
<Tooltip>{label}</Tooltip>
|
|
18
|
+
</TooltipTrigger>
|
|
19
|
+
)
|
|
20
|
+
}
|
package/src/components/input.tsx
CHANGED
|
@@ -1,17 +1,11 @@
|
|
|
1
1
|
import type { ReactNode } from 'react'
|
|
2
|
-
import {
|
|
3
|
-
FieldError,
|
|
4
|
-
Input as RACInput,
|
|
5
|
-
Label,
|
|
6
|
-
Text,
|
|
7
|
-
TextField,
|
|
8
|
-
type TextFieldProps,
|
|
9
|
-
} from 'react-aria-components'
|
|
2
|
+
import { FieldError, Input as RACInput, Label, Text, TextField, type TextFieldProps } from 'react-aria-components'
|
|
10
3
|
import { uic } from '../utils/uic'
|
|
11
4
|
import {
|
|
12
5
|
fieldDescriptionClass,
|
|
13
6
|
fieldErrorClass,
|
|
14
|
-
|
|
7
|
+
fieldLabelClasses,
|
|
8
|
+
type FieldLabelSize,
|
|
15
9
|
fieldSizeClasses,
|
|
16
10
|
fieldStackClass,
|
|
17
11
|
filledFieldClasses,
|
|
@@ -59,6 +53,7 @@ export type InputProps = TextFieldProps & {
|
|
|
59
53
|
/** Filled matches the original Manager dialog fields; outlined remains the default. */
|
|
60
54
|
appearance?: FieldAppearance
|
|
61
55
|
/** Visible field label (required for accessibility). */
|
|
56
|
+
labelSize?: FieldLabelSize
|
|
62
57
|
label: ReactNode
|
|
63
58
|
/** Helper text rendered under the field. */
|
|
64
59
|
description?: ReactNode
|
|
@@ -72,10 +67,28 @@ export type InputProps = TextFieldProps & {
|
|
|
72
67
|
inputClassName?: string
|
|
73
68
|
}
|
|
74
69
|
|
|
75
|
-
export const Input = ({
|
|
70
|
+
export const Input = ({
|
|
71
|
+
label,
|
|
72
|
+
labelSize = 'default',
|
|
73
|
+
description,
|
|
74
|
+
errorMessage,
|
|
75
|
+
placeholder,
|
|
76
|
+
size,
|
|
77
|
+
appearance = 'outlined',
|
|
78
|
+
rootClassName,
|
|
79
|
+
inputClassName,
|
|
80
|
+
autoFocus,
|
|
81
|
+
...props
|
|
82
|
+
}: InputProps) => (
|
|
76
83
|
<TextField {...props} className={`${fieldStackClass} w-full ${rootClassName ?? ''}`}>
|
|
77
|
-
<Label className={
|
|
78
|
-
<StyledInput
|
|
84
|
+
<Label className={fieldLabelClasses[labelSize]}>{label}</Label>
|
|
85
|
+
<StyledInput
|
|
86
|
+
autoFocus={autoFocus}
|
|
87
|
+
className={inputClassName}
|
|
88
|
+
placeholder={placeholder}
|
|
89
|
+
appearance={appearance}
|
|
90
|
+
fieldSize={size ?? (appearance === 'filled' ? 'filled' : undefined)}
|
|
91
|
+
/>
|
|
79
92
|
{description ? (
|
|
80
93
|
<Text slot="description" className={fieldDescriptionClass}>
|
|
81
94
|
{description}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { IslandToolbar, IslandToolbarButton, IslandToolbarSeparator } from './island-toolbar'
|
|
2
|
+
|
|
3
|
+
export const examples = {
|
|
4
|
+
default: () => (
|
|
5
|
+
<IslandToolbar aria-label="Formatting">
|
|
6
|
+
<IslandToolbarButton label="Bold" icon={<strong>B</strong>} />
|
|
7
|
+
<IslandToolbarButton label="Italic" icon={<em>I</em>} />
|
|
8
|
+
</IslandToolbar>
|
|
9
|
+
),
|
|
10
|
+
variants: () => (
|
|
11
|
+
<IslandToolbar aria-label="Formatting">
|
|
12
|
+
<IslandToolbarButton label="Bold" icon={<strong>B</strong>} />
|
|
13
|
+
<IslandToolbarSeparator />
|
|
14
|
+
<IslandToolbarButton label="Link" icon={<span>↗</span>} />
|
|
15
|
+
</IslandToolbar>
|
|
16
|
+
),
|
|
17
|
+
states: () => (
|
|
18
|
+
<IslandToolbar aria-label="Formatting">
|
|
19
|
+
<IslandToolbarButton label="Bold" icon={<strong>B</strong>} aria-pressed />
|
|
20
|
+
<IslandToolbarButton label="Italic" icon={<em>I</em>} isDisabled />
|
|
21
|
+
</IslandToolbar>
|
|
22
|
+
),
|
|
23
|
+
}
|
|
24
|
+
export const meta = {
|
|
25
|
+
category: 'Composite',
|
|
26
|
+
description: 'Studio formatting island with expanding accessible command labels.',
|
|
27
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { ReactNode } from 'react'
|
|
2
|
+
import { Button } from './button'
|
|
3
|
+
import { uic } from '../utils/uic'
|
|
4
|
+
|
|
5
|
+
/** Shared Studio/editor island. The app owns commands and selection retention. */
|
|
6
|
+
export const IslandToolbar = uic('div', {
|
|
7
|
+
displayName: 'IslandToolbar',
|
|
8
|
+
baseClass:
|
|
9
|
+
'flex max-w-full items-center gap-1 overflow-x-auto rounded-full bg-surface-inverted px-2 py-1 text-fg-inverted shadow-lg',
|
|
10
|
+
defaultProps: { role: 'toolbar' },
|
|
11
|
+
})
|
|
12
|
+
export const IslandToolbarSeparator = uic('span', {
|
|
13
|
+
displayName: 'IslandToolbarSeparator',
|
|
14
|
+
baseClass: 'mx-1 h-5 w-px shrink-0 bg-white/25',
|
|
15
|
+
defaultProps: { 'aria-hidden': true },
|
|
16
|
+
})
|
|
17
|
+
const Control = uic(Button, {
|
|
18
|
+
displayName: 'IslandToolbarControl',
|
|
19
|
+
baseClass:
|
|
20
|
+
'group/island-control h-8 min-w-8 shrink-0 justify-center gap-0 rounded-full px-2 py-0 text-fg-inverted hover:gap-2 hover:bg-white/15 focus-visible:gap-2 aria-pressed:bg-white/20',
|
|
21
|
+
defaultVariants: { variant: 'ghost', size: 'sm' },
|
|
22
|
+
})
|
|
23
|
+
export function IslandToolbarButton({
|
|
24
|
+
label,
|
|
25
|
+
icon,
|
|
26
|
+
...props
|
|
27
|
+
}: Omit<Parameters<typeof Control>[0], 'children'> & { label: string; icon: ReactNode }) {
|
|
28
|
+
return (
|
|
29
|
+
<Control {...props} aria-label={label}>
|
|
30
|
+
{icon}
|
|
31
|
+
<span
|
|
32
|
+
aria-hidden="true"
|
|
33
|
+
className="max-w-0 overflow-hidden truncate whitespace-nowrap text-compact font-normal leading-4 opacity-0 transition-[max-width,opacity] duration-150 group-hover/island-control:max-w-40 group-hover/island-control:opacity-100 group-focus-visible/island-control:max-w-40 group-focus-visible/island-control:opacity-100 motion-reduce:transition-none"
|
|
34
|
+
>
|
|
35
|
+
{label}
|
|
36
|
+
</span>
|
|
37
|
+
</Control>
|
|
38
|
+
)
|
|
39
|
+
}
|