@open-mercato/ui 0.6.7-develop.6788.1.c2a1520a30 → 0.6.7-develop.6814.1.0627c7e9f1

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.
@@ -0,0 +1,27 @@
1
+ import React from 'react'
2
+ import figma from '@figma/code-connect'
3
+ import { Tag } from '../src/primitives/tag'
4
+
5
+ // TODO(figma): resolve the real node id in the DS file before ds:code-connect:publish.
6
+ figma.connect(Tag, 'https://www.figma.com/design/qCq9z6q1if0mpoRstV5OEA/Design-System?node-id=0-1', {
7
+ imports: ["import { Tag } from '@open-mercato/ui/primitives/tag'"],
8
+ props: {
9
+ variant: figma.enum('Variant', {
10
+ Default: 'default',
11
+ Success: 'success',
12
+ Warning: 'warning',
13
+ Error: 'error',
14
+ Info: 'info',
15
+ Neutral: 'neutral',
16
+ Brand: 'brand',
17
+ Pink: 'pink',
18
+ }),
19
+ dot: figma.boolean('Dot'),
20
+ label: figma.string('Label'),
21
+ },
22
+ example: ({ variant, dot, label }) => (
23
+ <Tag variant={variant} dot={dot}>
24
+ {label}
25
+ </Tag>
26
+ ),
27
+ })
@@ -0,0 +1,6 @@
1
+ {
2
+ "codeConnect": {
3
+ "parser": "react",
4
+ "include": ["figma/**/*.figma.tsx", "src/primitives/**/*.tsx"]
5
+ }
6
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-mercato/ui",
3
- "version": "0.6.7-develop.6788.1.c2a1520a30",
3
+ "version": "0.6.7-develop.6814.1.0627c7e9f1",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -137,31 +137,32 @@
137
137
  "@dnd-kit/sortable": "^10.0.0",
138
138
  "@dnd-kit/utilities": "^3.2.2",
139
139
  "@mdxeditor/editor": "^4.0.4",
140
- "@radix-ui/react-accordion": "^1.2.16",
141
- "@radix-ui/react-dialog": "^1.1.19",
142
- "@radix-ui/react-popover": "^1.1.19",
143
- "@radix-ui/react-radio-group": "^1.4.3",
144
- "@radix-ui/react-scroll-area": "^1.2.14",
145
- "@radix-ui/react-select": "^2.3.3",
146
- "@radix-ui/react-slider": "^1.4.3",
147
- "@radix-ui/react-tooltip": "^1.2.12",
140
+ "@radix-ui/react-accordion": "^1.2.20",
141
+ "@radix-ui/react-dialog": "^1.1.23",
142
+ "@radix-ui/react-popover": "^1.1.23",
143
+ "@radix-ui/react-radio-group": "^1.4.7",
144
+ "@radix-ui/react-scroll-area": "^1.2.18",
145
+ "@radix-ui/react-select": "^2.3.7",
146
+ "@radix-ui/react-slider": "^1.4.7",
147
+ "@radix-ui/react-tooltip": "^1.2.16",
148
148
  "@tanstack/react-virtual": "^3.14.6",
149
149
  "cmdk": "^1.0.0",
150
150
  "date-fns": "4.4.0",
151
151
  "react-big-calendar": "^1.20.0",
152
152
  "react-day-picker": "^10.0.1",
153
153
  "react-markdown": "^10.1.0",
154
- "recharts": "^3.9.2",
154
+ "recharts": "^3.10.1",
155
155
  "remark-gfm": "^4.0.1"
156
156
  },
157
157
  "peerDependencies": {
158
- "@open-mercato/shared": "0.6.7-develop.6788.1.c2a1520a30",
158
+ "@open-mercato/shared": "0.6.7-develop.6814.1.0627c7e9f1",
159
159
  "react": ">=18.0.0",
160
160
  "react-dom": ">=18.0.0",
161
161
  "react-is": ">=18.0.0"
162
162
  },
163
163
  "devDependencies": {
164
- "@open-mercato/shared": "0.6.7-develop.6788.1.c2a1520a30",
164
+ "@figma/code-connect": "^1.3.4",
165
+ "@open-mercato/shared": "0.6.7-develop.6814.1.0627c7e9f1",
165
166
  "@testing-library/dom": "^10.4.1",
166
167
  "@testing-library/jest-dom": "^6.9.1",
167
168
  "@testing-library/react": "^16.3.1",
@@ -170,10 +171,10 @@
170
171
  "@types/react-dom": "^19.2.3",
171
172
  "jest": "^30.4.2",
172
173
  "jest-environment-jsdom": "^30.4.1",
173
- "react": "19.2.7",
174
- "react-dom": "19.2.7",
175
- "react-is": "^19.2.7",
176
- "ts-jest": "^29.4.11",
174
+ "react": "19.2.8",
175
+ "react-dom": "19.2.8",
176
+ "react-is": "^19.2.8",
177
+ "ts-jest": "^29.4.12",
177
178
  "ts-morph": "^28.0.0",
178
179
  "typescript": "7.0.2"
179
180
  },
@@ -42,16 +42,16 @@ type NextStepCalloutProps = {
42
42
  const STEP_STYLES: Record<NonNullable<NextStepCalloutStep['state']>, string> = {
43
43
  pending: '',
44
44
  active: 'border-primary/40 bg-primary/10 text-primary',
45
- completed: 'border-emerald-500/30 bg-emerald-500/10 text-emerald-200',
45
+ completed: 'border-status-success-border bg-status-success-bg text-status-success-text',
46
46
  }
47
47
 
48
48
  const STATUS_STYLES: Record<NextStepCalloutStatusTone, string> = {
49
49
  default: 'border-border bg-background/80 text-foreground',
50
50
  info: 'border-primary/20 bg-primary/5 text-primary',
51
- success: 'border-emerald-500/20 bg-emerald-500/5 text-emerald-200',
52
- warning: 'border-amber-500/20 bg-amber-500/5 text-amber-200',
51
+ success: 'border-status-success-border bg-status-success-bg text-status-success-text',
52
+ warning: 'border-status-warning-border bg-status-warning-bg text-status-warning-text',
53
53
  danger: 'border-destructive/20 bg-destructive/5 text-destructive',
54
- muted: 'border-zinc-500/20 bg-zinc-500/5 text-zinc-200',
54
+ muted: 'border-status-neutral-border bg-status-neutral-bg text-status-neutral-text',
55
55
  }
56
56
 
57
57
  export function NextStepCallout({
@@ -0,0 +1,98 @@
1
+ /** @jest-environment jsdom */
2
+ jest.setTimeout(15000)
3
+
4
+ // Regression guard for #4400: an injected group widget placed in column 1 must
5
+ // render as a full-width row in the main stack — CrudForm must NOT switch to
6
+ // the narrow 7fr/3fr secondary-column layout unless a widget explicitly asks
7
+ // for column 2. The hook is mocked so the test drives the injected widgets
8
+ // directly, following the CrudForm.fieldInjection.test.tsx pattern.
9
+ let injectedGroupWidgets: unknown[] = []
10
+
11
+ jest.mock('next/navigation', () => ({
12
+ useRouter: () => ({ push: () => {} }),
13
+ usePathname: () => '/',
14
+ useSearchParams: () => new URLSearchParams(),
15
+ }))
16
+ jest.mock('remark-gfm', () => ({ __esModule: true, default: {} }))
17
+ jest.mock('../injection/InjectionSpot', () => ({
18
+ __esModule: true,
19
+ InjectionSpot: () => null,
20
+ useInjectionWidgets: () => ({ widgets: injectedGroupWidgets, loading: false, error: null }),
21
+ useInjectionSpotEvents: () => ({ triggerEvent: jest.fn(async () => ({ ok: true, data: {} })) }),
22
+ }))
23
+ jest.mock('../injection/useInjectionDataWidgets', () => ({
24
+ __esModule: true,
25
+ useInjectionDataWidgets: () => ({ widgets: [], isLoading: false, error: null }),
26
+ }))
27
+
28
+ import * as React from 'react'
29
+ import { waitFor } from '@testing-library/react'
30
+ import { renderWithProviders } from '@open-mercato/shared/lib/testing/renderWithProviders'
31
+ import { CrudForm, type CrudField, type CrudFormGroup } from '../CrudForm'
32
+
33
+ const fields: CrudField[] = [
34
+ { id: 'name', label: 'Name', type: 'text' },
35
+ ]
36
+
37
+ const groups: CrudFormGroup[] = [
38
+ { id: 'contact', label: 'Contact', fields: ['name'] },
39
+ ]
40
+
41
+ function makeGroupWidget(column: 1 | 2) {
42
+ return {
43
+ widgetId: 'customer_accounts.injection.company-users',
44
+ placement: { kind: 'group', column, groupLabel: 'Portal users', priority: 200 },
45
+ module: {
46
+ metadata: { title: 'Portal users', description: '' },
47
+ Widget: () => <div data-testid="portal-users-widget">portal users</div>,
48
+ },
49
+ }
50
+ }
51
+
52
+ function renderForm() {
53
+ return renderWithProviders(
54
+ React.createElement(CrudForm as never, {
55
+ title: 'Company',
56
+ entityId: 'customers:company',
57
+ fields,
58
+ groups,
59
+ onSubmit: () => {},
60
+ }),
61
+ )
62
+ }
63
+
64
+ describe('CrudForm injected group column placement (#4400)', () => {
65
+ afterEach(() => {
66
+ injectedGroupWidgets = []
67
+ })
68
+
69
+ it('renders a column-1 group widget as a full-width row without the secondary column', async () => {
70
+ injectedGroupWidgets = [makeGroupWidget(1)]
71
+
72
+ const { container } = renderForm()
73
+
74
+ await waitFor(() => {
75
+ expect(container.querySelector('[data-testid="portal-users-widget"]')).toBeTruthy()
76
+ })
77
+
78
+ expect(container.querySelector('[data-crud-injection-region]')).toBeNull()
79
+ const twoColumnGrid = Array.from(container.querySelectorAll('div')).find((node) =>
80
+ node.className.includes('7fr_3fr'),
81
+ )
82
+ expect(twoColumnGrid).toBeUndefined()
83
+ })
84
+
85
+ it('still supports an explicit column-2 group widget via the secondary column (sanity)', async () => {
86
+ injectedGroupWidgets = [makeGroupWidget(2)]
87
+
88
+ const { container } = renderForm()
89
+
90
+ await waitFor(() => {
91
+ expect(container.querySelector('[data-testid="portal-users-widget"]')).toBeTruthy()
92
+ })
93
+
94
+ const secondaryRegion = container.querySelector('[data-crud-injection-region]')
95
+ expect(secondaryRegion).toBeTruthy()
96
+ expect(secondaryRegion?.querySelector('[data-testid="portal-users-widget"]')).toBeTruthy()
97
+ })
98
+ })
@@ -7,7 +7,7 @@ import { flash } from '@open-mercato/ui/backend/FlashMessages'
7
7
  import { TabEmptyState } from '@open-mercato/ui/backend/detail'
8
8
  import { useOrganizationScopeVersion } from '@open-mercato/shared/lib/frontend/useOrganizationScope'
9
9
  import { normalizeCoordinateInput, validateCoordinateInput } from '@open-mercato/shared/lib/location/coordinates'
10
- import { AddressView, formatAddressString, type AddressFormatStrategy } from './addressFormat'
10
+ import { AddressView, type AddressFormatStrategy } from './addressFormat'
11
11
  import AddressEditor, { type AddressTypesAdapter } from './AddressEditor'
12
12
  import {
13
13
  Dialog,
@@ -176,7 +176,7 @@ export function AddressTiles<C = unknown>({
176
176
  t,
177
177
  emptyLabel,
178
178
  isSubmitting = false,
179
- gridClassName = 'grid grid-cols-1 gap-2 sm:gap-4 sm:grid-cols-2 lg:grid-cols-3 2xl:grid-cols-4',
179
+ gridClassName = 'grid grid-cols-[repeat(auto-fill,minmax(240px,1fr))] gap-2 sm:gap-4',
180
180
  hideAddButton = false,
181
181
  onAddActionChange,
182
182
  emptyStateTitle,
@@ -480,7 +480,7 @@ export function AddressTiles<C = unknown>({
480
480
  addressTypesAdapter={addressTypesAdapter}
481
481
  addressTypesContext={addressTypesContext}
482
482
  />
483
- {generalError ? <p className="text-xs text-red-600">{generalError}</p> : null}
483
+ {generalError ? <p className="text-xs text-status-error-text">{generalError}</p> : null}
484
484
  <div className="flex flex-wrap justify-end gap-2">
485
485
  <Button type="button" variant="outline" onClick={handleCancel} disabled={disableActions}>
486
486
  {label('cancel', 'Cancel')}
@@ -569,9 +569,6 @@ export function AddressTiles<C = unknown>({
569
569
  </p>
570
570
  ) : null}
571
571
  <AddressView address={address} format={format} className="text-sm text-foreground" />
572
- <p className="text-xs text-muted-foreground">
573
- {formatAddressString(address, format)}
574
- </p>
575
572
  </div>
576
573
  <div className="flex items-center gap-1 opacity-100 md:opacity-0 transition-opacity md:group-hover:opacity-100 focus-within:opacity-100">
577
574
  <Button
@@ -77,7 +77,7 @@ type AttachmentMetadataFormValues = {
77
77
  assignments?: AssignmentDraft[]
78
78
  } & Record<string, unknown>
79
79
 
80
- type AssignmentEditorLabels = {
80
+ export type AssignmentEditorLabels = {
81
81
  title: string
82
82
  description: string
83
83
  type: string
@@ -75,4 +75,25 @@ describe('AttachmentAssignmentsEditor (metadata dialog)', () => {
75
75
  fireEvent.click(screen.getByRole('button', { name: 'Remove assignment' }))
76
76
  expect(screen.queryByPlaceholderText('catalog.product')).toBeNull()
77
77
  })
78
+
79
+ it('keeps the surviving assignment values after removing a middle row', () => {
80
+ render(
81
+ <EditorHarness
82
+ initial={[
83
+ { type: 'catalog.product', id: 'p-1', href: '', label: '' },
84
+ { type: 'sales.order', id: 'o-2', href: '', label: '' },
85
+ { type: 'customers.person', id: 'c-3', href: '', label: '' },
86
+ ]}
87
+ />,
88
+ )
89
+
90
+ fireEvent.click(screen.getAllByRole('button', { name: labels.remove })[1])
91
+
92
+ const typeInputs = screen.getAllByPlaceholderText('catalog.product') as HTMLInputElement[]
93
+ const idInputs = screen.getAllByPlaceholderText('Record ID') as HTMLInputElement[]
94
+ expect(typeInputs[0]).toHaveValue('catalog.product')
95
+ expect(idInputs[0]).toHaveValue('p-1')
96
+ expect(typeInputs[1]).toHaveValue('customers.person')
97
+ expect(idInputs[1]).toHaveValue('c-3')
98
+ })
78
99
  })
@@ -1,8 +1,19 @@
1
1
  "use client"
2
2
 
3
3
  import * as React from 'react'
4
- import { Button } from '../../primitives/button'
5
- import { Input } from '../../primitives/input'
4
+ import { DateRangePicker } from '../../primitives/date-range-picker'
5
+ import { IconButton } from '../../primitives/icon-button'
6
+ import {
7
+ SegmentedControl,
8
+ SegmentedControlItem,
9
+ } from '../../primitives/segmented-control'
10
+ import {
11
+ Select,
12
+ SelectContent,
13
+ SelectItem,
14
+ SelectTrigger,
15
+ SelectValue,
16
+ } from '../../primitives/select'
6
17
  import type { ScheduleRange, ScheduleViewMode } from './types'
7
18
  import { cn } from '@open-mercato/shared/lib/utils'
8
19
  import { useT } from '@open-mercato/shared/lib/i18n/context'
@@ -27,17 +38,19 @@ const VIEW_OPTIONS: Array<{ id: ScheduleViewMode; labelKey: string; fallback: st
27
38
  { id: 'agenda', labelKey: 'schedule.view.agenda', fallback: 'Agenda' },
28
39
  ]
29
40
 
30
- function formatDateInputValue(value: Date): string {
31
- const year = value.getFullYear()
32
- const month = String(value.getMonth() + 1).padStart(2, '0')
33
- const day = String(value.getDate()).padStart(2, '0')
34
- return `${year}-${month}-${day}`
35
- }
36
-
37
- function parseDateInputValue(value: string, fallback: Date): Date {
38
- if (!value) return fallback
39
- const next = new Date(`${value}T00:00:00`)
40
- return Number.isNaN(next.getTime()) ? fallback : next
41
+ function getTimezoneOptions(current?: string): string[] {
42
+ const options = new Set<string>()
43
+ if (current) options.add(current)
44
+ options.add('UTC')
45
+ const resolved = Intl.DateTimeFormat().resolvedOptions().timeZone
46
+ if (resolved) options.add(resolved)
47
+ const intlWithSupportedValues = Intl as typeof Intl & { supportedValuesOf?: (input: 'timeZone') => string[] }
48
+ if (typeof intlWithSupportedValues.supportedValuesOf === 'function') {
49
+ intlWithSupportedValues.supportedValuesOf('timeZone').forEach((timezone) => {
50
+ if (timezone) options.add(timezone)
51
+ })
52
+ }
53
+ return Array.from(options).sort((a, b) => a.localeCompare(b))
41
54
  }
42
55
 
43
56
  export type ScheduleToolbarProps = {
@@ -120,68 +133,76 @@ export function ScheduleToolbar({
120
133
  onRangeChange({ start: nextStart, end: endOfDay(addDays(nextStart, rangeLength - 1)) })
121
134
  }, [onRangeChange, range.start, rangeLength, view])
122
135
 
136
+ const timezoneOptions = React.useMemo(() => getTimezoneOptions(timezone), [timezone])
137
+
123
138
  return (
124
- <div className={cn('flex flex-col gap-3 rounded-xl border bg-card p-4 md:flex-row md:items-center md:justify-between', className)}>
125
- <div className="flex flex-wrap items-center gap-2">
139
+ <div className={cn('flex flex-wrap items-center gap-x-4 gap-y-2 rounded-xl border bg-card p-3', className)}>
140
+ <SegmentedControl
141
+ value={view}
142
+ onValueChange={(value) => {
143
+ const nextView = value as ScheduleViewMode
144
+ if (nextView === view) return
145
+ onViewChange(nextView)
146
+ onRangeChange(deriveRangeForView(new Date(), nextView))
147
+ }}
148
+ aria-label={t('schedule.view.label', 'Schedule view')}
149
+ className="shrink-0"
150
+ >
126
151
  {VIEW_OPTIONS.map((option) => (
127
- <Button
128
- key={option.id}
129
- variant={view === option.id ? 'default' : 'outline'}
130
- size="sm"
131
- onClick={() => {
132
- if (option.id === view) return
133
- onViewChange(option.id)
134
- onRangeChange(deriveRangeForView(new Date(), option.id))
135
- }}
136
- >
152
+ <SegmentedControlItem key={option.id} value={option.id}>
137
153
  {t(option.labelKey, option.fallback)}
138
- </Button>
154
+ </SegmentedControlItem>
139
155
  ))}
140
- </div>
141
- <div className="flex flex-wrap items-center gap-2">
142
- <Button type="button" variant="outline" size="sm" onClick={() => shiftRange('prev')} aria-label={t('schedule.range.prev', 'Previous')}>
156
+ </SegmentedControl>
157
+ <div className="flex shrink-0 items-center gap-1">
158
+ <IconButton
159
+ type="button"
160
+ variant="outline"
161
+ onClick={() => shiftRange('prev')}
162
+ aria-label={t('schedule.range.prev', 'Previous')}
163
+ >
143
164
  <ChevronLeft className="size-4" aria-hidden />
144
- </Button>
145
- <div className="text-sm font-medium text-foreground">{rangeLabel}</div>
146
- <Button type="button" variant="outline" size="sm" onClick={() => shiftRange('next')} aria-label={t('schedule.range.next', 'Next')}>
165
+ </IconButton>
166
+ <div className="min-w-0 whitespace-nowrap px-1 text-sm font-medium text-foreground">{rangeLabel}</div>
167
+ <IconButton
168
+ type="button"
169
+ variant="outline"
170
+ onClick={() => shiftRange('next')}
171
+ aria-label={t('schedule.range.next', 'Next')}
172
+ >
147
173
  <ChevronRight className="size-4" aria-hidden />
148
- </Button>
174
+ </IconButton>
149
175
  </div>
150
- <div className="flex flex-wrap items-center gap-3">
151
- <label className="flex items-center gap-2 text-xs text-muted-foreground">
152
- <span>{t('schedule.range.start', 'Start')}</span>
153
- <Input
154
- type="date"
155
- value={formatDateInputValue(range.start)}
156
- onChange={(event) => {
157
- const nextStart = parseDateInputValue(event.target.value, range.start)
158
- onRangeChange({ start: nextStart, end: range.end })
159
- }}
160
- className="h-8 w-full sm:w-[140px]"
161
- />
162
- </label>
163
- <label className="flex items-center gap-2 text-xs text-muted-foreground">
164
- <span>{t('schedule.range.end', 'End')}</span>
165
- <Input
166
- type="date"
167
- value={formatDateInputValue(range.end)}
168
- onChange={(event) => {
169
- const nextEnd = parseDateInputValue(event.target.value, range.end)
170
- onRangeChange({ start: range.start, end: nextEnd })
171
- }}
172
- className="h-8 w-full sm:w-[140px]"
173
- />
174
- </label>
175
- <label className="flex items-center gap-2 text-xs text-muted-foreground">
176
- <span>{t('schedule.range.timezone', 'Timezone')}</span>
177
- <Input
178
- type="text"
179
- value={timezone ?? ''}
180
- onChange={(event) => onTimezoneChange?.(event.target.value)}
181
- className="h-8 w-full sm:w-[180px]"
182
- placeholder={t('schedule.range.timezone.placeholder', 'UTC')}
183
- />
184
- </label>
176
+ <div className="flex min-w-0 flex-wrap items-center gap-x-3 gap-y-2 md:ml-auto">
177
+ <DateRangePicker
178
+ value={range}
179
+ onChange={(next) => {
180
+ if (!next) return
181
+ onRangeChange({ start: startOfDay(next.start), end: endOfDay(next.end) })
182
+ }}
183
+ size="sm"
184
+ showPresets={false}
185
+ numberOfMonths={2}
186
+ aria-label={t('schedule.range.label', 'Date range')}
187
+ />
188
+ {onTimezoneChange ? (
189
+ <Select value={timezone ?? undefined} onValueChange={onTimezoneChange}>
190
+ <SelectTrigger
191
+ size="sm"
192
+ className="w-auto min-w-[10rem]"
193
+ aria-label={t('schedule.range.timezone', 'Timezone')}
194
+ >
195
+ <SelectValue placeholder={t('schedule.range.timezone.placeholder', 'UTC')} />
196
+ </SelectTrigger>
197
+ <SelectContent>
198
+ {timezoneOptions.map((option) => (
199
+ <SelectItem key={option} value={option}>
200
+ {option}
201
+ </SelectItem>
202
+ ))}
203
+ </SelectContent>
204
+ </Select>
205
+ ) : null}
185
206
  </div>
186
207
  </div>
187
208
  )