@shware/workflow-ui 2.0.1 → 2.0.2

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 (39) hide show
  1. package/dist/index.mjs +56 -56
  2. package/dist/index.mjs.map +1 -1
  3. package/dist/postgres.mjs +4 -4
  4. package/dist/postgres.mjs.map +1 -1
  5. package/package.json +2 -2
  6. package/src/app/integrations/toast/toast-provider.tsx +2 -2
  7. package/src/app/routes/__root.tsx +9 -9
  8. package/src/app/routes/emails.tsx +2 -2
  9. package/src/app/routes/home.tsx +4 -4
  10. package/src/app/routes/metrics.tsx +19 -19
  11. package/src/app/routes/segment-overview.tsx +21 -21
  12. package/src/app/routes/segments.tsx +2 -2
  13. package/src/app/routes/settings.tsx +6 -6
  14. package/src/app/routes/workflows.tsx +5 -5
  15. package/src/components/avatar.tsx +1 -1
  16. package/src/components/breadcrumb.tsx +3 -3
  17. package/src/components/button/index.tsx +4 -4
  18. package/src/components/chat-markup.tsx +6 -6
  19. package/src/components/date-range.tsx +6 -6
  20. package/src/components/dropdown/index.tsx +8 -8
  21. package/src/components/email-defaults.tsx +3 -3
  22. package/src/components/email-list.tsx +6 -6
  23. package/src/components/flag.tsx +7 -4
  24. package/src/components/input/index.tsx +2 -2
  25. package/src/components/input/search-input.tsx +1 -1
  26. package/src/components/menu/index.tsx +2 -2
  27. package/src/components/metric-card.tsx +7 -7
  28. package/src/components/modal/index.tsx +2 -2
  29. package/src/components/nav-drawer.tsx +3 -3
  30. package/src/components/node-inspector.tsx +5 -5
  31. package/src/components/profile-drawer.tsx +8 -8
  32. package/src/components/segment-list.tsx +9 -9
  33. package/src/components/select/index.tsx +3 -3
  34. package/src/components/tabs/index.tsx +2 -2
  35. package/src/components/templates-page.tsx +23 -23
  36. package/src/components/textarea/index.tsx +2 -2
  37. package/src/components/thumbnail-window.tsx +1 -1
  38. package/src/components/workflow-list.tsx +8 -8
  39. package/src/postgres.ts +4 -2
@@ -41,8 +41,8 @@ export function Select({
41
41
  value={value}
42
42
  className={cn(
43
43
  'w-full cursor-pointer appearance-none truncate transition-colors duration-100',
44
- 'bg-textfield focus-visible:border-accent border focus:outline-none',
45
- 'dark:focus-visible:ring-accent/50 focus-visible:ring-accent/40',
44
+ 'border bg-textfield focus:outline-none focus-visible:border-accent',
45
+ 'focus-visible:ring-accent/40 dark:focus-visible:ring-accent/50',
46
46
  value === '' || value === undefined ? 'text-placeholder' : 'text-primary',
47
47
  SIZE_STYLE[size]
48
48
  )}
@@ -63,7 +63,7 @@ export function Select({
63
63
  size={16}
64
64
  strokeWidth={2}
65
65
  aria-hidden
66
- className="text-secondary pointer-events-none absolute top-1/2 right-2.5 -translate-y-1/2"
66
+ className="pointer-events-none absolute top-1/2 right-2.5 -translate-y-1/2 text-secondary"
67
67
  />
68
68
  </div>
69
69
  );
@@ -24,7 +24,7 @@ interface Props {
24
24
  export function Tabs({ items, params, className }: Props) {
25
25
  return (
26
26
  <nav
27
- className={cn('bg-selected flex items-center gap-0.5 rounded-lg p-0.5', className)}
27
+ className={cn('flex items-center gap-0.5 rounded-lg bg-selected p-0.5', className)}
28
28
  style={superellipse}
29
29
  >
30
30
  {items.map((item) => (
@@ -33,7 +33,7 @@ export function Tabs({ items, params, className }: Props) {
33
33
  to={item.to as LinkProps['to']}
34
34
  params={params as LinkProps['params']}
35
35
  activeOptions={{ exact: item.exact ?? false }}
36
- className="text-secondary hover:text-primary rounded-md px-3 py-1 text-sm font-medium transition-colors"
36
+ className="rounded-md px-3 py-1 text-sm font-medium text-secondary transition-colors hover:text-primary"
37
37
  activeProps={{ className: '!bg-card !text-primary shadow-sm' }}
38
38
  style={superellipse}
39
39
  >
@@ -93,8 +93,8 @@ export interface TemplatesPageProps {
93
93
  function Field({ label, children }: { label: string; children: ReactNode }) {
94
94
  return (
95
95
  <>
96
- <dt className="text-muted whitespace-nowrap">{label}</dt>
97
- <dd className="text-secondary min-w-0 break-words">{children}</dd>
96
+ <dt className="whitespace-nowrap text-muted">{label}</dt>
97
+ <dd className="min-w-0 break-words text-secondary">{children}</dd>
98
98
  </>
99
99
  );
100
100
  }
@@ -166,9 +166,9 @@ function PreviewPropsEditor({
166
166
  const [draft, setDraft] = useState<string | undefined>(undefined);
167
167
  const text = draft ?? JSON.stringify(initial, null, 2);
168
168
  return (
169
- <div className="border-border bg-card border-b px-6 py-4">
169
+ <div className="border-b border-border bg-card px-6 py-4">
170
170
  <div className="flex items-center justify-between">
171
- <label htmlFor="preview-props" className="text-muted text-sm">
171
+ <label htmlFor="preview-props" className="text-sm text-muted">
172
172
  {t('emails.previewProps')}
173
173
  </label>
174
174
  <button
@@ -177,7 +177,7 @@ function PreviewPropsEditor({
177
177
  setDraft(undefined);
178
178
  onReset();
179
179
  }}
180
- className="text-muted hover:text-primary text-xs transition-colors"
180
+ className="text-xs text-muted transition-colors hover:text-primary"
181
181
  >
182
182
  {t('emails.previewPropsReset')}
183
183
  </button>
@@ -206,7 +206,7 @@ function PreviewPropsEditor({
206
206
  onChange(parsed as Props);
207
207
  }}
208
208
  />
209
- <p className="text-muted mt-1.5 text-xs">{t('emails.previewPropsHint')}</p>
209
+ <p className="mt-1.5 text-xs text-muted">{t('emails.previewPropsHint')}</p>
210
210
  </div>
211
211
  );
212
212
  }
@@ -335,9 +335,9 @@ export function TemplatesPage({
335
335
  return (
336
336
  <div className="flex flex-1">
337
337
  {/* Preview; the template list lives on the /emails index and the header dropdown. */}
338
- <section className="bg-page flex min-w-0 flex-1 flex-col">
338
+ <section className="flex min-w-0 flex-1 flex-col bg-page">
339
339
  {active === undefined ? (
340
- <div className="text-muted flex flex-1 items-center justify-center text-sm">
340
+ <div className="flex flex-1 items-center justify-center text-sm text-muted">
341
341
  {selected === undefined ? t('emails.empty') : t('emails.notFound', { key: selected })}
342
342
  </div>
343
343
  ) : (
@@ -348,7 +348,7 @@ export function TemplatesPage({
348
348
  the project's envelope; a push's "envelope" is its content.
349
349
  */}
350
350
  {((isEmail && activeEmail !== undefined) || push !== undefined) && (
351
- <div className="border-border bg-card border-b px-6 py-4">
351
+ <div className="border-b border-border bg-card px-6 py-4">
352
352
  <dl className="grid grid-cols-[max-content_1fr] gap-x-8 gap-y-2.5 text-sm">
353
353
  {isEmail && activeEmail !== undefined && resolved !== undefined && (
354
354
  <>
@@ -419,13 +419,13 @@ export function TemplatesPage({
419
419
  {isChat ? (
420
420
  (isDiscord ? activeDiscord : activeSlack) === undefined ? (
421
421
  <div
422
- className="border-border bg-card mx-auto max-w-xl rounded-2xl border border-dashed p-8 text-center"
422
+ className="mx-auto max-w-xl rounded-2xl border border-dashed border-border bg-card p-8 text-center"
423
423
  style={superellipse}
424
424
  >
425
- <p className="text-primary text-sm font-medium">
425
+ <p className="text-sm font-medium text-primary">
426
426
  {t('emails.notRegistered')}
427
427
  </p>
428
- <p className="text-muted mt-2 text-sm">
428
+ <p className="mt-2 text-sm text-muted">
429
429
  {t('emails.chatNotRegisteredHint', {
430
430
  key: active.key,
431
431
  channel: isDiscord ? 'discord' : 'slack',
@@ -452,13 +452,13 @@ export function TemplatesPage({
452
452
  ) : isPush ? (
453
453
  activePush === undefined ? (
454
454
  <div
455
- className="border-border bg-card mx-auto max-w-xl rounded-2xl border border-dashed p-8 text-center"
455
+ className="mx-auto max-w-xl rounded-2xl border border-dashed border-border bg-card p-8 text-center"
456
456
  style={superellipse}
457
457
  >
458
- <p className="text-primary text-sm font-medium">
458
+ <p className="text-sm font-medium text-primary">
459
459
  {t('emails.notRegistered')}
460
460
  </p>
461
- <p className="text-muted mt-2 text-sm">
461
+ <p className="mt-2 text-sm text-muted">
462
462
  {t('emails.pushNotRegisteredHint', { key: active.key })}
463
463
  </p>
464
464
  </div>
@@ -475,18 +475,18 @@ export function TemplatesPage({
475
475
  )
476
476
  ) : activeEmail === undefined ? (
477
477
  <div
478
- className="border-border bg-card mx-auto max-w-xl rounded-2xl border border-dashed p-8 text-center"
478
+ className="mx-auto max-w-xl rounded-2xl border border-dashed border-border bg-card p-8 text-center"
479
479
  style={superellipse}
480
480
  >
481
- <p className="text-primary text-sm font-medium">{t('emails.notRegistered')}</p>
482
- <p className="text-muted mt-2 text-sm">
481
+ <p className="text-sm font-medium text-primary">{t('emails.notRegistered')}</p>
482
+ <p className="mt-2 text-sm text-muted">
483
483
  {t('emails.notRegisteredHint', { key: active.key })}
484
484
  </p>
485
485
  </div>
486
486
  ) : failure !== undefined ? (
487
487
  <TemplateFailurePanel failure={failure} />
488
488
  ) : loading ? (
489
- <div className="text-muted text-center text-sm">{t('emails.rendering')}</div>
489
+ <div className="text-center text-sm text-muted">{t('emails.rendering')}</div>
490
490
  ) : error !== undefined ? (
491
491
  <div
492
492
  className="mx-auto max-w-xl rounded-2xl border border-red-200 bg-red-50 p-6 text-sm text-red-700 dark:border-red-400/20 dark:bg-red-400/10 dark:text-red-300"
@@ -546,7 +546,7 @@ export function TemplatesPage({
546
546
  error === undefined &&
547
547
  failure === undefined) && (
548
548
  <div className="pointer-events-none sticky bottom-0 z-10 flex justify-center pt-2 pb-4">
549
- <div className="border-border bg-card pointer-events-auto flex items-center gap-0.5 rounded-full border p-1 shadow-lg">
549
+ <div className="pointer-events-auto flex items-center gap-0.5 rounded-full border border-border bg-card p-1 shadow-lg">
550
550
  <ToolButton
551
551
  active={scheme === 'light'}
552
552
  label={t('emails.previewLight')}
@@ -564,7 +564,7 @@ export function TemplatesPage({
564
564
  {/* Device widths are an email concern; a push shows both platforms, a chat message its client. */}
565
565
  {isEmail && (
566
566
  <>
567
- <div className="bg-border mx-1 h-4 w-px" />
567
+ <div className="mx-1 h-4 w-px bg-border" />
568
568
  <ToolButton
569
569
  active={device === 'desktop'}
570
570
  label={t('emails.previewDesktop')}
@@ -581,7 +581,7 @@ export function TemplatesPage({
581
581
  </ToolButton>
582
582
  </>
583
583
  )}
584
- <div className="bg-border mx-1 h-4 w-px" />
584
+ <div className="mx-1 h-4 w-px bg-border" />
585
585
  <ToolButton
586
586
  label={t('emails.zoomOut')}
587
587
  onClick={() => setZoom((level) => Math.max(0.5, level - 0.25))}
@@ -592,7 +592,7 @@ export function TemplatesPage({
592
592
  type="button"
593
593
  title={t('emails.zoomReset')}
594
594
  onClick={() => setZoom(1)}
595
- className="text-secondary hover:text-primary w-11 text-center text-xs font-medium tabular-nums transition-colors"
595
+ className="w-11 text-center text-xs font-medium text-secondary tabular-nums transition-colors hover:text-primary"
596
596
  >
597
597
  {Math.round(zoom * 100)}%
598
598
  </button>
@@ -27,8 +27,8 @@ export function Textarea({ size = 'md', className, ...props }: Props) {
27
27
  {...props}
28
28
  className={cn(
29
29
  'transition-colors duration-100 focus:outline-none',
30
- 'placeholder-placeholder bg-textfield focus-visible:border-accent border',
31
- 'dark:focus-visible:ring-accent/50 focus-visible:ring-accent/40',
30
+ 'border bg-textfield placeholder-placeholder focus-visible:border-accent',
31
+ 'focus-visible:ring-accent/40 dark:focus-visible:ring-accent/50',
32
32
  SIZE_STYLE[size],
33
33
  className
34
34
  )}
@@ -29,7 +29,7 @@ export function ThumbnailWindow({
29
29
  <div className="mb-4">
30
30
  <div
31
31
  ref={ref}
32
- className={cn('border-border h-48 overflow-hidden rounded-xl border', className)}
32
+ className={cn('h-48 overflow-hidden rounded-xl border border-border', className)}
33
33
  style={{ ...superellipse, ...style }}
34
34
  >
35
35
  {children}
@@ -85,12 +85,12 @@ export function WorkflowList({ items, reports, onOpen }: WorkflowListProps) {
85
85
  * the page is the one scroller (see __root). Nothing clips, so the corners
86
86
  * are re-cut on the first and last cells below.
87
87
  */
88
- <div className="border-border bg-card rounded-2xl border" style={superellipse}>
88
+ <div className="rounded-2xl border border-border bg-card" style={superellipse}>
89
89
  {/* Below `md` the table leaves table layout entirely and each row lays
90
90
  itself out as a four-column grid — see the row classes. */}
91
91
  <table className="w-full table-fixed border-separate border-spacing-0 text-sm max-md:block">
92
92
  <thead className="max-md:hidden">
93
- <tr className="text-muted text-left text-xs font-medium">
93
+ <tr className="text-left text-xs font-medium text-muted">
94
94
  <th className={clsx(HEAD_CELL, 'min-w-0 px-6')} style={superellipse}>
95
95
  {t('common.name')}
96
96
  </th>
@@ -126,12 +126,12 @@ export function WorkflowList({ items, reports, onOpen }: WorkflowListProps) {
126
126
  * poke square grey corners out of the card. Stacked, the row
127
127
  * is an ordinary grid box and takes fill and radius itself.
128
128
  */
129
- 'md:hover:[&>td]:bg-hover md:last:[&>td]:border-b-0',
129
+ 'md:last:[&>td]:border-b-0 md:hover:[&>td]:bg-hover',
130
130
  'md:last:[&>td:first-child]:rounded-bl-2xl md:last:[&>td:last-child]:rounded-br-2xl',
131
131
  /* Stacked: title / status / the metrics two by two
132
132
  — four across a phone leaves no room for a label, let
133
133
  alone the sparkline under it. */
134
- 'border-border max-md:hover:bg-hover max-md:grid max-md:grid-cols-6',
134
+ 'border-border max-md:grid max-md:grid-cols-6 max-md:hover:bg-hover',
135
135
  'max-md:border-b max-md:px-3 max-md:first:rounded-t-2xl',
136
136
  'max-md:last:rounded-b-2xl max-md:last:border-b-0'
137
137
  )}
@@ -142,7 +142,7 @@ export function WorkflowList({ items, reports, onOpen }: WorkflowListProps) {
142
142
  style={superellipse}
143
143
  >
144
144
  <div className="flex items-start gap-3">
145
- <WorkflowIcon className="text-muted mt-0.5 size-4 shrink-0" strokeWidth={2} />
145
+ <WorkflowIcon className="mt-0.5 size-4 shrink-0 text-muted" strokeWidth={2} />
146
146
  <div className="min-w-0">
147
147
  <div
148
148
  className={clsx(
@@ -159,11 +159,11 @@ export function WorkflowList({ items, reports, onOpen }: WorkflowListProps) {
159
159
  so keeping the indent here left a notch down the side.
160
160
  */}
161
161
  {ir.meta?.description !== undefined && (
162
- <p className="text-muted mt-1 truncate text-sm max-md:-ml-7">
162
+ <p className="mt-1 truncate text-sm text-muted max-md:-ml-7">
163
163
  {ir.meta.description}
164
164
  </p>
165
165
  )}
166
- <div className="text-muted mt-2 flex items-center gap-3 text-xs max-md:-ml-7">
166
+ <div className="mt-2 flex items-center gap-3 text-xs text-muted max-md:-ml-7">
167
167
  <span className="flex items-center gap-1">
168
168
  <Mail className="size-3.5" strokeWidth={2} />
169
169
  {shape.messages}
@@ -214,7 +214,7 @@ export function WorkflowList({ items, reports, onOpen }: WorkflowListProps) {
214
214
  style={superellipse}
215
215
  >
216
216
  {/* The head is gone when stacked, so each figure names itself. */}
217
- <div className="text-muted mb-1 truncate text-xs md:hidden">
217
+ <div className="mb-1 truncate text-xs text-muted md:hidden">
218
218
  {t(`workflows.columns.${column}`)}
219
219
  </div>
220
220
  <div className="tabular-nums">{values[column]}</div>
package/src/postgres.ts CHANGED
@@ -84,13 +84,14 @@ export function postgresStats(options: PostgresStatsOptions): StatsSource {
84
84
  anchor = Date.now();
85
85
  return;
86
86
  }
87
- const [row] = await sql<{ latest: Date | null }[]>`
87
+ const rows = await sql<{ latest: Date | null }[]>`
88
88
  select greatest(
89
89
  (select max(sent_at) from ${t('message')}),
90
90
  (select max(node_at) from ${t('instance')}),
91
91
  (select max(finished_at) from ${t('instance')}),
92
92
  (select max(taken_at) from ${t('segment_snapshot')})
93
93
  ) as latest`;
94
+ const row = rows.at(0);
94
95
  const latest =
95
96
  row?.latest === null || row?.latest === undefined
96
97
  ? Date.now()
@@ -382,8 +383,9 @@ export function postgresStats(options: PostgresStatsOptions): StatsSource {
382
383
 
383
384
  async profiles(segment, { limit, offset }) {
384
385
  await refreshAnchor();
385
- const [count] = await sql<{ total: number }[]>`
386
+ const counts = await sql<{ total: number }[]>`
386
387
  select count(*)::int as total from ${t('segment_member')} where segment = ${segment}`;
388
+ const count = counts.at(0);
387
389
  // "Created" is the user's first event: the engine knows nothing older about them
388
390
  const rows = await sql<
389
391
  { id: string; props: Record<string, unknown> | null; created_at: Date | null }[]