@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.
Files changed (34) hide show
  1. package/package.json +4 -4
  2. package/src/components/asset-selection-surface.tsx +264 -67
  3. package/src/components/citation.examples.tsx +14 -0
  4. package/src/components/citation.tsx +27 -0
  5. package/src/components/column-layout.examples.tsx +34 -0
  6. package/src/components/column-layout.tsx +36 -0
  7. package/src/components/combobox.tsx +9 -4
  8. package/src/components/compact-settings-dialog.tsx +80 -21
  9. package/src/components/date-picker.tsx +49 -8
  10. package/src/components/delivery/send-to-print-modal.tsx +191 -225
  11. package/src/components/field-appearance.ts +11 -1
  12. package/src/components/icon-button.examples.tsx +16 -0
  13. package/src/components/icon-button.tsx +20 -0
  14. package/src/components/input.tsx +25 -12
  15. package/src/components/island-toolbar.examples.tsx +27 -0
  16. package/src/components/island-toolbar.tsx +39 -0
  17. package/src/components/media-asset-panel.examples.tsx +44 -5
  18. package/src/components/media-asset-panel.tsx +339 -28
  19. package/src/components/media-collection.examples.tsx +18 -0
  20. package/src/components/media-collection.tsx +206 -0
  21. package/src/components/number-field.tsx +18 -9
  22. package/src/components/preview-error.examples.tsx +20 -0
  23. package/src/components/preview-error.tsx +29 -0
  24. package/src/components/preview-metadata-card.examples.tsx +32 -0
  25. package/src/components/preview-metadata-card.tsx +112 -0
  26. package/src/components/search-field.tsx +27 -7
  27. package/src/components/select.tsx +81 -50
  28. package/src/components/settings-dialog-surface.tsx +553 -114
  29. package/src/components/template-catalog-card.tsx +309 -78
  30. package/src/components/textarea.tsx +160 -12
  31. package/src/components/tile.tsx +30 -16
  32. package/src/components/zoomable-image.examples.tsx +33 -0
  33. package/src/components/zoomable-image.tsx +185 -0
  34. package/src/index.ts +96 -78
@@ -131,16 +131,10 @@ function TileBands({
131
131
  'theme' | 'eyebrow' | 'badge' | 'title' | 'titleAlign' | 'subtleTitle' | 'text' | 'footer' | 'image' | 'children'
132
132
  > & { theme: TileTheme }) {
133
133
  const titleNode =
134
- title != null ? (
135
- <p className={`${tileStatClass} ${titleTone(theme, subtleTitle)}`}>
136
- {title}
137
- </p>
138
- ) : null
134
+ title != null ? <p className={`${tileStatClass} ${titleTone(theme, subtleTitle)}`}>{title}</p> : null
139
135
  const textNode =
140
136
  text != null ? (
141
- <p className={`text-small leading-4 ${mutedTone(theme)} ${title != null ? 'mt-3' : ''}`}>
142
- {text}
143
- </p>
137
+ <p className={`text-small leading-4 ${mutedTone(theme)} ${title != null ? 'mt-3' : ''}`}>{text}</p>
144
138
  ) : null
145
139
 
146
140
  // Content band: custom children win; else a right-side image → two columns; else
@@ -201,7 +195,17 @@ function MediaHero({
201
195
  className,
202
196
  }: Pick<
203
197
  TileProps,
204
- 'backgroundImage' | 'imageAlt' | 'video' | 'eyebrow' | 'title' | 'footer' | 'badge' | 'onPress' | 'pressLabel' | 'closeLabel' | 'className'
198
+ | 'backgroundImage'
199
+ | 'imageAlt'
200
+ | 'video'
201
+ | 'eyebrow'
202
+ | 'title'
203
+ | 'footer'
204
+ | 'badge'
205
+ | 'onPress'
206
+ | 'pressLabel'
207
+ | 'closeLabel'
208
+ | 'className'
205
209
  >) {
206
210
  const [playing, setPlaying] = useState(false)
207
211
  const hasVideo = Boolean(video)
@@ -213,7 +217,10 @@ function MediaHero({
213
217
 
214
218
  return (
215
219
  <div
216
- className={['@container relative isolate h-full min-h-[200px] w-full overflow-hidden rounded-lg bg-surface-inverted', className]
220
+ className={[
221
+ '@container relative isolate h-full min-h-[200px] w-full overflow-hidden rounded-lg bg-surface-inverted',
222
+ className,
223
+ ]
217
224
  .filter(Boolean)
218
225
  .join(' ')}
219
226
  >
@@ -244,7 +251,10 @@ function MediaHero({
244
251
  <img src={backgroundImage} alt={imageAlt ?? ''} className="absolute inset-0 h-full w-full object-cover" />
245
252
  ) : null}
246
253
  {/* Legibility scrim — darkens top + bottom where text sits. */}
247
- <div aria-hidden="true" className="absolute inset-0 bg-gradient-to-b from-black/30 via-transparent to-black/60" />
254
+ <div
255
+ aria-hidden="true"
256
+ className="absolute inset-0 bg-gradient-to-b from-black/30 via-transparent to-black/60"
257
+ />
248
258
 
249
259
  {pressable ? (
250
260
  <button
@@ -274,9 +284,7 @@ function MediaHero({
274
284
  press overlay; only `footer` re-enables its own pointer events. */}
275
285
  <div data-slot="media-content" className="mt-auto flex min-h-0 flex-col gap-2 @sm:gap-4">
276
286
  {title ? (
277
- <h2 className="max-w-md text-title font-medium leading-tight text-white @sm:text-display">
278
- {title}
279
- </h2>
287
+ <h2 className="max-w-md text-title font-medium leading-tight text-white @sm:text-display">{title}</h2>
280
288
  ) : null}
281
289
  {footer != null || badge != null ? (
282
290
  <div className="flex items-center justify-between gap-3 @sm:gap-4">
@@ -363,7 +371,12 @@ export function Tile({
363
371
 
364
372
  if (onPress) {
365
373
  return (
366
- <button type="button" onClick={onPress} aria-label={rest['aria-label']} className={`${surface} w-full text-left ${interactive}`}>
374
+ <button
375
+ type="button"
376
+ onClick={onPress}
377
+ aria-label={rest['aria-label']}
378
+ className={`${surface} w-full text-left ${interactive}`}
379
+ >
367
380
  {body}
368
381
  </button>
369
382
  )
@@ -377,7 +390,7 @@ export function Tile({
377
390
  * label pill, distinct from podoba's interactive React-Aria `Tag` (tag-group.tsx);
378
391
  * named `Badge` to avoid the collision.
379
392
  */
380
- export type BadgeColor = 'green' | 'yellow' | 'grey' | 'dark'
393
+ export type BadgeColor = 'green' | 'yellow' | 'grey' | 'dark' | 'red'
381
394
 
382
395
  const BADGE: Record<BadgeColor, string> = {
383
396
  // gs `GSTag` green = the brand green (not the pale accent-mint). One saturated
@@ -390,6 +403,7 @@ const BADGE: Record<BadgeColor, string> = {
390
403
  green: 'bg-brand-green text-fg-on-brand',
391
404
  yellow: 'bg-accent-yellow text-fg-on-brand',
392
405
  grey: 'bg-surface-muted text-fg',
406
+ red: 'bg-danger text-white',
393
407
  dark: 'bg-surface-inverted text-fg-inverted',
394
408
  }
395
409
 
@@ -0,0 +1,33 @@
1
+ import { ZoomableImage } from './zoomable-image'
2
+ const src =
3
+ 'data:image/svg+xml,' +
4
+ encodeURIComponent(
5
+ '<svg xmlns="http://www.w3.org/2000/svg" width="400" height="600"><rect width="400" height="600" fill="white"/><text x="30" y="100">Artwork</text></svg>',
6
+ )
7
+ export const examples = {
8
+ default: () => (
9
+ <div className="h-96">
10
+ <ZoomableImage src={src} alt="Artwork page" label="Zoom with wheel or plus and minus; pan with arrow keys" />
11
+ </div>
12
+ ),
13
+ variants: () => (
14
+ <div className="h-96">
15
+ <ZoomableImage
16
+ src={src}
17
+ alt="Artwork page"
18
+ label="Rule source"
19
+ region={{ x: 0.05, y: 0.1, width: 0.8, height: 0.15 }}
20
+ regionLabel="Rule source area"
21
+ />
22
+ </div>
23
+ ),
24
+ states: () => (
25
+ <div className="h-48">
26
+ <ZoomableImage src={src} alt="Compact artwork page" label="Compact rule source" />
27
+ </div>
28
+ ),
29
+ }
30
+ export const meta = {
31
+ category: 'Composite',
32
+ description: 'Accessible image stage with initial region focus, wheel zoom and pointer pan.',
33
+ }
@@ -0,0 +1,185 @@
1
+ import { useEffect, useRef, useState, type PointerEvent } from 'react'
2
+ import { MediaPreviewScene } from './media-collection'
3
+
4
+ export interface ImageFocusRegion {
5
+ x: number
6
+ y: number
7
+ width: number
8
+ height: number
9
+ }
10
+ interface Pose {
11
+ scale: number
12
+ x: number
13
+ y: number
14
+ }
15
+ /** A document stage with cursor-anchored wheel zoom and keyboard/pointer panning. */
16
+ export function ZoomableImage({
17
+ src,
18
+ alt,
19
+ label,
20
+ region,
21
+ regionLabel,
22
+ onError,
23
+ }: {
24
+ src: string
25
+ alt: string
26
+ label: string
27
+ region?: ImageFocusRegion
28
+ regionLabel?: string
29
+ onError?: () => void
30
+ }) {
31
+ const viewport = useRef<HTMLDivElement>(null)
32
+ const [size, setSize] = useState({ width: 0, height: 0 })
33
+ const [pose, setPose] = useState<Pose>({ scale: 1, x: 0, y: 0 })
34
+ const poseRef = useRef(pose),
35
+ geometry = useRef({ width: 0, height: 0, fit: 1, max: 6 })
36
+ const drag = useRef<{ id: number; x: number; y: number; pose: Pose } | null>(null)
37
+ const commit = (next: Pose) => {
38
+ poseRef.current = next
39
+ setPose(next)
40
+ }
41
+ useEffect(() => {
42
+ const node = viewport.current
43
+ if (!node || !size.width || !size.height) return
44
+ const measure = () => {
45
+ const width = node.clientWidth,
46
+ height = node.clientHeight
47
+ if (!width || !height) return
48
+ const fit = Math.min(width / size.width, height / size.height),
49
+ max = Math.max(fit * 6, 1)
50
+ geometry.current = { width, height, fit, max }
51
+ const scale = region
52
+ ? Math.min(
53
+ max,
54
+ Math.max(
55
+ fit,
56
+ Math.min(width / (size.width * region.width * 1.2), height / (size.height * region.height * 1.5)),
57
+ ),
58
+ )
59
+ : fit
60
+ commit({
61
+ scale,
62
+ x: width / 2 - (region ? region.x + region.width / 2 : 0.5) * size.width * scale,
63
+ y: height / 2 - (region ? region.y + region.height / 2 : 0.5) * size.height * scale,
64
+ })
65
+ }
66
+ measure()
67
+ const observer = new ResizeObserver(measure)
68
+ observer.observe(node)
69
+ const wheel = (event: WheelEvent) => {
70
+ event.preventDefault()
71
+ event.stopPropagation()
72
+ const rect = node.getBoundingClientRect(),
73
+ old = poseRef.current,
74
+ g = geometry.current
75
+ const delta = event.deltaY * (event.deltaMode === 1 ? 16 : event.deltaMode === 2 ? g.height : 1)
76
+ const scale = Math.max(g.fit, Math.min(g.max, old.scale * Math.exp(-Math.max(-80, Math.min(80, delta)) * 0.0015)))
77
+ const x = event.clientX - rect.left,
78
+ y = event.clientY - rect.top,
79
+ ratio = scale / old.scale
80
+ commit(
81
+ scale <= g.fit
82
+ ? { scale: g.fit, x: (g.width - size.width * g.fit) / 2, y: (g.height - size.height * g.fit) / 2 }
83
+ : { scale, x: x - (x - old.x) * ratio, y: y - (y - old.y) * ratio },
84
+ )
85
+ }
86
+ node.addEventListener('wheel', wheel, { passive: false })
87
+ return () => {
88
+ observer.disconnect()
89
+ node.removeEventListener('wheel', wheel)
90
+ }
91
+ }, [src, size.width, size.height, region?.x, region?.y, region?.width, region?.height])
92
+ const end = (event: PointerEvent<HTMLDivElement>) => {
93
+ if (drag.current?.id === event.pointerId) drag.current = null
94
+ }
95
+ return (
96
+ <MediaPreviewScene
97
+ ref={viewport}
98
+ role="group"
99
+ tabIndex={0}
100
+ aria-label={label}
101
+ className="h-full w-full touch-none p-0 focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring"
102
+ style={{ overscrollBehavior: 'contain', cursor: 'grab' }}
103
+ onKeyDown={(event) => {
104
+ const old = poseRef.current,
105
+ g = geometry.current
106
+ if (['+', '=', '-'].includes(event.key)) {
107
+ event.preventDefault()
108
+ const scale = Math.max(g.fit, Math.min(g.max, old.scale * (event.key === '-' ? 1 / 1.15 : 1.15))),
109
+ ratio = scale / old.scale
110
+ commit({
111
+ scale,
112
+ x: g.width / 2 - (g.width / 2 - old.x) * ratio,
113
+ y: g.height / 2 - (g.height / 2 - old.y) * ratio,
114
+ })
115
+ }
116
+ const movement: Record<string, readonly [number, number]> = {
117
+ ArrowLeft: [28, 0],
118
+ ArrowRight: [-28, 0],
119
+ ArrowUp: [0, 28],
120
+ ArrowDown: [0, -28],
121
+ }
122
+ const move = movement[event.key]
123
+ if (move) {
124
+ event.preventDefault()
125
+ commit({ ...old, x: old.x + move[0], y: old.y + move[1] })
126
+ }
127
+ }}
128
+ onPointerDown={(event) => {
129
+ if (event.button !== 0) return
130
+ event.preventDefault()
131
+ event.currentTarget.focus({ preventScroll: true })
132
+ event.currentTarget.setPointerCapture(event.pointerId)
133
+ drag.current = { id: event.pointerId, x: event.clientX, y: event.clientY, pose: poseRef.current }
134
+ }}
135
+ onPointerMove={(event) => {
136
+ const start = drag.current
137
+ if (start?.id === event.pointerId)
138
+ commit({
139
+ ...start.pose,
140
+ x: start.pose.x + event.clientX - start.x,
141
+ y: start.pose.y + event.clientY - start.y,
142
+ })
143
+ }}
144
+ onPointerUp={end}
145
+ onPointerCancel={end}
146
+ onLostPointerCapture={end}
147
+ >
148
+ <div
149
+ className="absolute start-0 top-0 select-none"
150
+ style={{
151
+ width: size.width || '100%',
152
+ height: size.height || '100%',
153
+ transform: `translate(${pose.x}px,${pose.y}px) scale(${pose.scale})`,
154
+ transformOrigin: '0 0',
155
+ }}
156
+ >
157
+ <img
158
+ key={src}
159
+ src={src}
160
+ alt={alt}
161
+ draggable={false}
162
+ className="pointer-events-none block h-full w-full max-w-none"
163
+ onLoad={(event) =>
164
+ setSize({ width: event.currentTarget.naturalWidth, height: event.currentTarget.naturalHeight })
165
+ }
166
+ onError={onError}
167
+ />
168
+ {region ? (
169
+ <div
170
+ role="img"
171
+ aria-label={regionLabel}
172
+ data-testid="document-evidence-region"
173
+ className="pointer-events-none absolute border border-brand-green bg-brand-green/5"
174
+ style={{
175
+ insetInlineStart: `${region.x * 100}%`,
176
+ top: `${region.y * 100}%`,
177
+ width: `${region.width * 100}%`,
178
+ height: `${region.height * 100}%`,
179
+ }}
180
+ />
181
+ ) : null}
182
+ </div>
183
+ </MediaPreviewScene>
184
+ )
185
+ }
package/src/index.ts CHANGED
@@ -7,92 +7,110 @@
7
7
  // renderer) stays in GS and consumes this. See ../../EXTRACTION.md.
8
8
 
9
9
  // --- factory ---
10
- export { uic, uiconfig, type ConfigVariants, type NoInfer } from "./utils/uic";
10
+ export { uic, uiconfig, type ConfigVariants, type NoInfer } from './utils/uic'
11
11
 
12
12
  // --- primitives ---
13
- export * from "./components/button";
14
- export * from "./components/compact-action-button";
15
- export * from "./components/input";
16
- export * from "./components/field-appearance";
17
- export * from "./components/textarea";
18
- export * from "./components/rich-text-editor";
19
- export * from "./components/focus-field";
20
- export * from "./components/focus-context";
21
- export * from "./components/checkbox";
22
- export * from "./components/radio";
23
- export * from "./components/switch";
24
- export * from "./components/select";
25
- export * from "./components/combobox";
26
- export * from "./components/multiselect";
27
- export * from "./components/number-field";
28
- export * from "./components/search-field";
29
- export * from "./components/slider";
30
- export * from "./components/tag-group";
31
- export * from "./components/file-upload";
32
- export * from "./components/document-upload-panel";
33
- export * from "./components/csv-binding-presentation";
34
- export * from "./components/dialog-action-button";
35
- export * from "./components/reload-icon";
36
- export * from "./components/source-icons";
37
- export * from "./components/animated-summary-text";
38
- export * from "./components/date-field";
39
- export * from "./components/date-picker";
40
- export * from "./components/dialog";
41
- export { AssetSelectionSurface, AssetSelectionEmpty, AssetLibraryPreview, AssetSelectionFilters, AssetSelectionGrid, type AssetSelectionSurfaceProps } from "./components/asset-selection-surface";
42
- export { AssetMasonryGrid, assetMasonryColumns, assetMasonryPositions } from './components/asset-masonry-grid';
43
- export * from "./components/side-panel";
44
- export * from "./components/dropdown-menu";
45
- export * from "./components/context-menu";
46
- export * from "./components/context-search-panel";
47
- export * from "./components/media-gallery";
48
- export * from "./components/media-settings-dialog";
49
- export * from "./components/media-asset-panel";
50
- export * from "./components/tooltip";
51
- export * from "./components/toast";
52
- export * from "./components/disclosure";
53
- export * from "./components/collapsible-card";
54
- export * from "./components/tabs";
55
- export * from "./components/section-tabs";
56
- export * from "./components/separator";
57
- export * from "./components/text";
58
- export * from "./components/view-toggle";
13
+ export * from './components/button'
14
+ export * from './components/compact-action-button'
15
+ export * from './components/input'
16
+ export * from './components/field-appearance'
17
+ export * from './components/textarea'
18
+ export * from './components/rich-text-editor'
19
+ export * from './components/focus-field'
20
+ export * from './components/focus-context'
21
+ export * from './components/checkbox'
22
+ export * from './components/radio'
23
+ export * from './components/switch'
24
+ export * from './components/select'
25
+ export * from './components/combobox'
26
+ export * from './components/multiselect'
27
+ export * from './components/number-field'
28
+ export * from './components/search-field'
29
+ export * from './components/slider'
30
+ export * from './components/tag-group'
31
+ export * from './components/file-upload'
32
+ export * from './components/document-upload-panel'
33
+ export * from './components/csv-binding-presentation'
34
+ export * from './components/dialog-action-button'
35
+ export * from './components/reload-icon'
36
+ export * from './components/source-icons'
37
+ export * from './components/animated-summary-text'
38
+ export * from './components/date-field'
39
+ export * from './components/date-picker'
40
+ export * from './components/dialog'
41
+ export {
42
+ AssetSelectionSurface,
43
+ AssetSelectionEmpty,
44
+ AssetLibraryPreview,
45
+ AssetSelectionFilters,
46
+ AssetSelectionGrid,
47
+ type AssetSelectionSurfaceProps,
48
+ } from './components/asset-selection-surface'
49
+ export { AssetMasonryGrid, assetMasonryColumns, assetMasonryPositions } from './components/asset-masonry-grid'
50
+ export * from './components/side-panel'
51
+ export * from './components/dropdown-menu'
52
+ export * from './components/context-menu'
53
+ export * from './components/context-search-panel'
54
+ export * from './components/media-gallery'
55
+ export * from './components/media-settings-dialog'
56
+ export * from './components/media-asset-panel'
57
+ export * from './components/tooltip'
58
+ export * from './components/toast'
59
+ export * from './components/disclosure'
60
+ export * from './components/collapsible-card'
61
+ export * from './components/tabs'
62
+ export * from './components/section-tabs'
63
+ export * from './components/separator'
64
+ export * from './components/text'
65
+ export * from './components/view-toggle'
59
66
 
60
67
  // --- layout ---
61
- export * from "./layout/card";
62
- export * from "./layout/section";
63
- export * from "./layout/page-container";
64
- export * from "./layout/app-shell";
65
- export * from "./layout/topbar";
66
- export * from "./layout/persistent-page-shell";
68
+ export * from './layout/card'
69
+ export * from './layout/section'
70
+ export * from './layout/page-container'
71
+ export * from './layout/app-shell'
72
+ export * from './layout/topbar'
73
+ export * from './layout/persistent-page-shell'
67
74
 
68
75
  // --- product patterns (label-driven; no domain coupling) ---
69
- export * from "./components/avatar";
70
- export * from "./components/brand-page-header";
71
- export * from "./components/count-up";
72
- export * from "./components/preview-motion";
73
- export * from "./components/cta-pill";
74
- export * from "./components/stat-stack";
75
- export * from "./components/icons";
76
- export * from "./components/context-action-glyph";
77
- export * from "./components/subtle";
78
- export * from "./components/stats-card";
79
- export * from "./components/settings-dialog-surface";
80
- export * from "./components/template-catalog-card";
81
- export * from "./components/tile";
82
- export * from "./components/preview-info-card";
83
- export * from "./components/empty-panel-action";
84
- export * from "./components/table";
85
- export * from "./components/table-header-icon";
86
- export * from "./components/dashboard-grid";
87
- export * from "./components/task-approval-modal";
88
- export * from "./components/request-changes-modal";
89
- export * from "./components/delivery/download-modal";
90
- export * from "./components/delivery/send-to-print-modal";
91
- export * from "./components/delivery/publish-modal";
92
- export * from "./components/delivery/delivery-status-module";
76
+ export * from './components/avatar'
77
+ export * from './components/brand-page-header'
78
+ export * from './components/count-up'
79
+ export * from './components/preview-motion'
80
+ export * from './components/cta-pill'
81
+ export * from './components/stat-stack'
82
+ export * from './components/icons'
83
+ export * from './components/context-action-glyph'
84
+ export * from './components/subtle'
85
+ export * from './components/stats-card'
86
+ export * from './components/settings-dialog-surface'
87
+ export * from './components/template-catalog-card'
88
+ export * from './components/tile'
89
+ export * from './components/preview-info-card'
90
+ export * from './components/empty-panel-action'
91
+ export * from './components/table'
92
+ export * from './components/table-header-icon'
93
+ export * from './components/dashboard-grid'
94
+ export * from './components/task-approval-modal'
95
+ export * from './components/request-changes-modal'
96
+ export * from './components/delivery/download-modal'
97
+ export * from './components/delivery/send-to-print-modal'
98
+ export * from './components/delivery/publish-modal'
99
+ export * from './components/delivery/delivery-status-module'
93
100
  export * from './components/date-selection-calendar'
94
101
  export * from './components/compact-settings-dialog'
95
102
 
96
- export * from "./components/round-check-toggle";
103
+ export * from './components/round-check-toggle'
97
104
 
98
105
  export { InlineAlert, type InlineAlertProps } from './components/inline-alert'
106
+
107
+ export * from './components/island-toolbar'
108
+
109
+ export * from './components/column-layout'
110
+
111
+ export * from './components/media-collection'
112
+ export * from './components/zoomable-image'
113
+ export * from './components/preview-metadata-card'
114
+ export * from './components/icon-button'
115
+ export * from './components/citation'
116
+ export * from './components/preview-error'