@shware/workflow-ui 2.0.0 → 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 (42) hide show
  1. package/dist/index.d.mts.map +1 -1
  2. package/dist/index.mjs +95 -88
  3. package/dist/index.mjs.map +1 -1
  4. package/dist/postgres.mjs +4 -4
  5. package/dist/postgres.mjs.map +1 -1
  6. package/package.json +2 -2
  7. package/src/app/integrations/theme/root-provider.tsx +24 -12
  8. package/src/app/integrations/toast/toast-provider.tsx +2 -2
  9. package/src/app/routes/__root.tsx +9 -9
  10. package/src/app/routes/emails.tsx +2 -2
  11. package/src/app/routes/home.tsx +4 -4
  12. package/src/app/routes/metrics.tsx +19 -19
  13. package/src/app/routes/segment-overview.tsx +21 -21
  14. package/src/app/routes/segments.tsx +2 -2
  15. package/src/app/routes/settings.tsx +6 -6
  16. package/src/app/routes/workflows.tsx +5 -5
  17. package/src/components/avatar.tsx +1 -1
  18. package/src/components/breadcrumb.tsx +3 -3
  19. package/src/components/button/index.tsx +4 -4
  20. package/src/components/chat-markup.tsx +6 -6
  21. package/src/components/date-range.tsx +16 -8
  22. package/src/components/dropdown/index.tsx +18 -10
  23. package/src/components/email-defaults.tsx +3 -3
  24. package/src/components/email-list.tsx +6 -6
  25. package/src/components/flag.tsx +17 -11
  26. package/src/components/input/index.tsx +2 -2
  27. package/src/components/input/search-input.tsx +1 -1
  28. package/src/components/menu/index.tsx +12 -4
  29. package/src/components/metric-card.tsx +7 -7
  30. package/src/components/modal/index.tsx +4 -3
  31. package/src/components/nav-drawer.tsx +3 -3
  32. package/src/components/node-inspector.tsx +5 -5
  33. package/src/components/profile-drawer.tsx +37 -23
  34. package/src/components/segment-list.tsx +9 -9
  35. package/src/components/select/index.tsx +3 -3
  36. package/src/components/slack-preview.tsx +33 -30
  37. package/src/components/tabs/index.tsx +2 -2
  38. package/src/components/templates-page.tsx +23 -23
  39. package/src/components/textarea/index.tsx +2 -2
  40. package/src/components/thumbnail-window.tsx +1 -1
  41. package/src/components/workflow-list.tsx +8 -8
  42. package/src/postgres.ts +4 -2
@@ -29,11 +29,11 @@ function Settings() {
29
29
  <PageChrome breadcrumb={<Breadcrumb items={[{ label: t('nav.settings') }]} />} />
30
30
 
31
31
  <section
32
- className="border-border bg-card mt-5 max-w-xl rounded-2xl border p-5"
32
+ className="mt-5 max-w-xl rounded-2xl border border-border bg-card p-5"
33
33
  style={superellipse}
34
34
  >
35
35
  <h2 className="text-sm font-medium">{t('settings.language')}</h2>
36
- <p className="text-muted mt-1 text-xs">{t('settings.languageHint')}</p>
36
+ <p className="mt-1 text-xs text-muted">{t('settings.languageHint')}</p>
37
37
  <div className="mt-3 flex gap-2">
38
38
  {supportedLngs.map((lng: SupportedLng) => (
39
39
  <Button
@@ -49,11 +49,11 @@ function Settings() {
49
49
  </section>
50
50
 
51
51
  <section
52
- className="border-border bg-card mt-4 max-w-xl rounded-2xl border p-5"
52
+ className="mt-4 max-w-xl rounded-2xl border border-border bg-card p-5"
53
53
  style={superellipse}
54
54
  >
55
55
  <h2 className="text-sm font-medium">{t('settings.theme')}</h2>
56
- <p className="text-muted mt-1 text-xs">{t('settings.themeHint')}</p>
56
+ <p className="mt-1 text-xs text-muted">{t('settings.themeHint')}</p>
57
57
  <div className="mt-3 flex gap-2">
58
58
  {themes.map((option: Theme) => (
59
59
  <Button
@@ -74,11 +74,11 @@ function Settings() {
74
74
  />
75
75
 
76
76
  <section
77
- className="border-border bg-card mt-4 max-w-xl rounded-2xl border p-5"
77
+ className="mt-4 max-w-xl rounded-2xl border border-border bg-card p-5"
78
78
  style={superellipse}
79
79
  >
80
80
  <h2 className="text-sm font-medium">{t('settings.statsSource')}</h2>
81
- <p className="text-secondary mt-2 font-mono text-xs">
81
+ <p className="mt-2 font-mono text-xs text-secondary">
82
82
  {sources.length > 0 ? sources.join(', ') : t('common.notConfigured')}
83
83
  </p>
84
84
  </section>
@@ -53,7 +53,7 @@ function WorkflowsIndex() {
53
53
 
54
54
  if (items.length === 0) {
55
55
  return (
56
- <div className="text-muted flex flex-1 items-center justify-center text-sm">
56
+ <div className="flex flex-1 items-center justify-center text-sm text-muted">
57
57
  {t('workflows.empty')}
58
58
  </div>
59
59
  );
@@ -78,7 +78,7 @@ function WorkflowsIndex() {
78
78
  </div>
79
79
  <div className="px-6 pb-6">
80
80
  {filtered.length === 0 ? (
81
- <div className="text-muted flex items-center justify-center py-24 text-sm">
81
+ <div className="flex items-center justify-center py-24 text-sm text-muted">
82
82
  {t('workflows.noMatches', { query: query.trim() })}
83
83
  </div>
84
84
  ) : (
@@ -129,7 +129,7 @@ function WorkflowDetail() {
129
129
 
130
130
  if (ir === undefined) {
131
131
  return (
132
- <div className="text-muted flex flex-1 flex-col items-center justify-center gap-3 text-sm">
132
+ <div className="flex flex-1 flex-col items-center justify-center gap-3 text-sm text-muted">
133
133
  <p>{t('workflows.notFound', { id })}</p>
134
134
  <Link to="/workflows" className="text-primary underline">
135
135
  {t('common.back')}
@@ -288,7 +288,7 @@ function CanvasTab() {
288
288
  preview = (
289
289
  <PushThumbnail
290
290
  appName={config.title ?? 'App'}
291
- title={push?.ok === true ? (push.push.title ?? message.template) : message.template}
291
+ title={push?.ok === true ? push.push.title : message.template}
292
292
  body={push?.ok === true ? push.push.body : ''}
293
293
  {...(push?.ok === false ? { error: formatIssues(push.failure) } : {})}
294
294
  registered={pushModule !== undefined}
@@ -301,7 +301,7 @@ function CanvasTab() {
301
301
  return (
302
302
  /* The exception to the shell's one-scrollport rule: this pane is pinned to
303
303
  the viewport rather than growing the page. */
304
- <div className="border-border relative flex min-h-0 flex-1 flex-col border-t">
304
+ <div className="relative flex min-h-0 flex-1 flex-col border-t border-border">
305
305
  {/*
306
306
  Absolute rather than a flex child: the shell's main column is sized by
307
307
  min-height, so its height is `auto` and the canvas's own `height: 100%`
@@ -47,7 +47,7 @@ export function Avatar({ picture, label, size = 'md' }: AvatarProps) {
47
47
  <div
48
48
  aria-hidden
49
49
  className={cn(
50
- 'bg-selected text-secondary flex shrink-0 items-center justify-center rounded-full font-medium',
50
+ 'flex shrink-0 items-center justify-center rounded-full bg-selected font-medium text-secondary',
51
51
  SIZES[size]
52
52
  )}
53
53
  >
@@ -23,20 +23,20 @@ export function Breadcrumb({ items }: { items: readonly Crumb[] }) {
23
23
  return (
24
24
  <Fragment key={index}>
25
25
  {index > 0 && (
26
- <ChevronRight className="text-muted size-3.5 shrink-0" strokeWidth={2} aria-hidden />
26
+ <ChevronRight className="size-3.5 shrink-0 text-muted" strokeWidth={2} aria-hidden />
27
27
  )}
28
28
  {item.to !== undefined && !last ? (
29
29
  <Link
30
30
  to={item.to as LinkProps['to']}
31
31
  params={item.params as LinkProps['params']}
32
32
  search={item.search as LinkProps['search']}
33
- className="text-muted hover:text-primary shrink-0 truncate transition-colors"
33
+ className="shrink-0 truncate text-muted transition-colors hover:text-primary"
34
34
  >
35
35
  {item.label}
36
36
  </Link>
37
37
  ) : (
38
38
  <span
39
- className={last ? 'text-primary min-w-0 truncate' : 'text-muted shrink-0 truncate'}
39
+ className={last ? 'min-w-0 truncate text-primary' : 'shrink-0 truncate text-muted'}
40
40
  >
41
41
  {item.label}
42
42
  </span>
@@ -28,12 +28,12 @@ const SIZE_STYLE: Record<Size, string> = {
28
28
 
29
29
  const VARIANT_STYLE = {
30
30
  text: clsx(
31
- 'text-primary border-none bg-transparent',
31
+ 'border-none bg-transparent text-primary',
32
32
  'hover:bg-gray-100 focus-visible:ring-black/10 active:bg-gray-200/80',
33
33
  'dark:hover:bg-gray-800 dark:focus-visible:ring-white/20 dark:active:bg-gray-700/80'
34
34
  ),
35
35
  accent: clsx(
36
- 'bg-accent active:bg-accent/80 text-white',
36
+ 'bg-accent text-white active:bg-accent/80',
37
37
  'focus-visible:ring-accent/40 dark:focus-visible:ring-accent/50'
38
38
  ),
39
39
  default: clsx(
@@ -41,7 +41,7 @@ const VARIANT_STYLE = {
41
41
  'active:bg-black/80 dark:focus-visible:ring-white/30 dark:active:bg-white/80'
42
42
  ),
43
43
  secondary: clsx(
44
- 'text-primary bg-gray-100 focus-visible:ring-black/10 active:bg-gray-200/80',
44
+ 'bg-gray-100 text-primary focus-visible:ring-black/10 active:bg-gray-200/80',
45
45
  'dark:bg-gray-800 dark:focus-visible:ring-white/20 dark:active:bg-gray-700/80'
46
46
  ),
47
47
  destructive: clsx(
@@ -50,7 +50,7 @@ const VARIANT_STYLE = {
50
50
  'dark:bg-red-400/70 dark:active:bg-red-400/90'
51
51
  ),
52
52
  outline: clsx(
53
- 'text-primary border',
53
+ 'border text-primary',
54
54
  'bg-white focus-visible:ring-black/10 active:bg-gray-100/70',
55
55
  'dark:bg-gray-900/70 dark:focus-visible:ring-white/30 dark:active:bg-gray-900'
56
56
  ),
@@ -31,28 +31,28 @@ const link = (href: string, text: string, key: string, className: string) => (
31
31
 
32
32
  const RULES: Record<Dialect, Rule[]> = {
33
33
  discord: [
34
- { pattern: /`([^`]+)`/, render: (m, key) => code(m[1] ?? '', key) },
34
+ { pattern: /`([^`]+)`/, render: (m, key) => code(m[1], key) },
35
35
  {
36
36
  pattern: /\[([^\]]+)\]\((https?:\/\/[^)\s]+)\)/,
37
- render: (m, key, linkClass) => link(m[2] ?? '', m[1] ?? '', key, linkClass),
37
+ render: (m, key, linkClass) => link(m[2], m[1], key, linkClass),
38
38
  },
39
39
  { pattern: /\*\*([^*]+)\*\*/, render: (m, key) => <strong key={key}>{m[1]}</strong> },
40
40
  { pattern: /(?<!\w)__([^_]+)__(?!\w)/, render: (m, key) => <u key={key}>{m[1]}</u> },
41
41
  { pattern: /~~([^~]+)~~/, render: (m, key) => <s key={key}>{m[1]}</s> },
42
42
  {
43
43
  pattern: /\*([^*]+)\*|(?<!\w)_([^_]+)_(?!\w)/,
44
- render: (m, key) => <em key={key}>{m[1] ?? m[2]}</em>,
44
+ render: (m, key) => <em key={key}>{m.at(1) ?? m.at(2)}</em>,
45
45
  },
46
46
  {
47
47
  pattern: /(https?:\/\/[^\s<]+)/,
48
- render: (m, key, linkClass) => link(m[1] ?? '', m[1] ?? '', key, linkClass),
48
+ render: (m, key, linkClass) => link(m[1], m[1], key, linkClass),
49
49
  },
50
50
  ],
51
51
  slack: [
52
- { pattern: /`([^`]+)`/, render: (m, key) => code(m[1] ?? '', key) },
52
+ { pattern: /`([^`]+)`/, render: (m, key) => code(m[1], key) },
53
53
  {
54
54
  pattern: /<((?:https?:\/\/|mailto:|tel:)[^|>]+)(?:\|([^>]+))?>/,
55
- render: (m, key, linkClass) => link(m[1] ?? '', m[2] ?? m[1] ?? '', key, linkClass),
55
+ render: (m, key, linkClass) => link(m[1], m.at(2) ?? m[1], key, linkClass),
56
56
  },
57
57
  { pattern: /(?<!\w)\*([^*]+)\*(?!\w)/, render: (m, key) => <strong key={key}>{m[1]}</strong> },
58
58
  { pattern: /(?<!\w)_([^_]+)_(?!\w)/, render: (m, key) => <em key={key}>{m[1]}</em> },
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  FloatingFocusManager,
3
+ type ReferenceType,
3
4
  autoUpdate,
4
5
  flip,
5
6
  offset,
@@ -90,6 +91,13 @@ export function DateRangePicker({ value, onChange, className }: Props) {
90
91
  whileElementsMounted: autoUpdate,
91
92
  middleware: [offset(4), flip({ padding: 8 }), shift({ padding: 8 })],
92
93
  });
94
+ const {
95
+ setFloating,
96
+ setReference,
97
+ }: {
98
+ setFloating: (this: void, node: HTMLElement | null) => void;
99
+ setReference: (this: void, node: ReferenceType | null) => void;
100
+ } = refs;
93
101
 
94
102
  const { getReferenceProps, getFloatingProps } = useInteractions([
95
103
  useClick(context),
@@ -116,13 +124,13 @@ export function DateRangePicker({ value, onChange, className }: Props) {
116
124
  return (
117
125
  <>
118
126
  <Button
119
- ref={refs.setReference}
127
+ ref={setReference}
120
128
  size="sm"
121
129
  variant="outline"
122
130
  className={cn('gap-2 font-normal', className)}
123
131
  {...getReferenceProps()}
124
132
  >
125
- <Calendar size={16} strokeWidth={2} aria-hidden className="text-secondary shrink-0" />
133
+ <Calendar size={16} strokeWidth={2} aria-hidden className="shrink-0 text-secondary" />
126
134
  <span className="tabular-nums">
127
135
  {formatDay(value.from, i18n.language)} – {formatDay(value.to, i18n.language)}
128
136
  </span>
@@ -130,16 +138,16 @@ export function DateRangePicker({ value, onChange, className }: Props) {
130
138
  {open && (
131
139
  <FloatingFocusManager context={context} modal={false}>
132
140
  <div
133
- ref={refs.setFloating}
141
+ ref={setFloating}
134
142
  style={{ ...floatingStyles, ...superellipse }}
135
- className="border-border bg-card shadow-card-shadow z-50 w-64 rounded-xl border p-2 shadow-lg"
143
+ className="z-50 w-64 rounded-xl border border-border bg-card p-2 shadow-lg shadow-card-shadow"
136
144
  {...getFloatingProps()}
137
145
  >
138
146
  {PRESETS.map((days) => (
139
147
  <button
140
148
  key={days}
141
149
  type="button"
142
- className="hover:bg-hover block w-full rounded-lg px-2.5 py-1.5 text-left text-sm"
150
+ className="block w-full rounded-lg px-2.5 py-1.5 text-left text-sm hover:bg-hover"
143
151
  style={superellipse}
144
152
  onClick={() => {
145
153
  onChange(lastDays(days));
@@ -149,9 +157,9 @@ export function DateRangePicker({ value, onChange, className }: Props) {
149
157
  {t('metrics.range.lastDays', { count: days })}
150
158
  </button>
151
159
  ))}
152
- <div className="border-border mt-2 space-y-2 border-t pt-2">
160
+ <div className="mt-2 space-y-2 border-t border-border pt-2">
153
161
  <label className="block">
154
- <span className="text-muted text-xs">{t('metrics.range.from')}</span>
162
+ <span className="text-xs text-muted">{t('metrics.range.from')}</span>
155
163
  <Input
156
164
  size="sm"
157
165
  type="date"
@@ -162,7 +170,7 @@ export function DateRangePicker({ value, onChange, className }: Props) {
162
170
  />
163
171
  </label>
164
172
  <label className="block">
165
- <span className="text-muted text-xs">{t('metrics.range.to')}</span>
173
+ <span className="text-xs text-muted">{t('metrics.range.to')}</span>
166
174
  <Input
167
175
  size="sm"
168
176
  type="date"
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  FloatingFocusManager,
3
+ type ReferenceType,
3
4
  autoUpdate,
4
5
  flip,
5
6
  offset,
@@ -63,6 +64,13 @@ export function Dropdown({ value, options, onChange, placeholder, className }: P
63
64
  }),
64
65
  ],
65
66
  });
67
+ const {
68
+ setFloating,
69
+ setReference,
70
+ }: {
71
+ setFloating: (this: void, node: HTMLElement | null) => void;
72
+ setReference: (this: void, node: ReferenceType | null) => void;
73
+ } = refs;
66
74
 
67
75
  const listRef = useRef<(HTMLElement | null)[]>([]);
68
76
  const { getReferenceProps, getFloatingProps, getItemProps } = useInteractions([
@@ -78,7 +86,7 @@ export function Dropdown({ value, options, onChange, placeholder, className }: P
78
86
  return (
79
87
  <>
80
88
  <Button
81
- ref={refs.setReference}
89
+ ref={setReference}
82
90
  size="sm"
83
91
  variant="outline"
84
92
  className={cn(
@@ -96,21 +104,21 @@ export function Dropdown({ value, options, onChange, placeholder, className }: P
96
104
  size={16}
97
105
  strokeWidth={2}
98
106
  aria-hidden
99
- className="text-secondary shrink-0"
107
+ className="shrink-0 text-secondary"
100
108
  />
101
109
  )}
102
110
  <span className="truncate">{selected?.label ?? placeholder}</span>
103
111
  </span>
104
- <ChevronDown size={16} strokeWidth={2} aria-hidden className="text-secondary shrink-0" />
112
+ <ChevronDown size={16} strokeWidth={2} aria-hidden className="shrink-0 text-secondary" />
105
113
  </Button>
106
114
  {open && (
107
115
  <FloatingFocusManager context={context} modal={false}>
108
116
  <div
109
- ref={refs.setFloating}
117
+ ref={setFloating}
110
118
  style={floatingStyles}
111
119
  className={cn(
112
- 'border-border bg-card z-50 max-w-96 min-w-64 overflow-y-auto rounded-xl border p-1',
113
- 'shadow-card-shadow shadow-lg'
120
+ 'z-50 max-w-96 min-w-64 overflow-y-auto rounded-xl border border-border bg-card p-1',
121
+ 'shadow-lg shadow-card-shadow'
114
122
  )}
115
123
  {...getFloatingProps()}
116
124
  >
@@ -144,22 +152,22 @@ export function Dropdown({ value, options, onChange, placeholder, className }: P
144
152
  size={16}
145
153
  strokeWidth={2}
146
154
  aria-hidden
147
- className="text-secondary shrink-0"
155
+ className="shrink-0 text-secondary"
148
156
  />
149
157
  )}
150
158
  <span className="min-w-0 flex-1">
151
159
  {/* One weight for every option: the accent check is what
152
160
  marks the current value, and a bolder label on top of
153
161
  it says the same thing twice. */}
154
- <span className="text-primary block truncate text-sm">{option.label}</span>
162
+ <span className="block truncate text-sm text-primary">{option.label}</span>
155
163
  {option.description !== undefined && option.description !== '' && (
156
- <span className="text-muted block truncate text-xs">
164
+ <span className="block truncate text-xs text-muted">
157
165
  {option.description}
158
166
  </span>
159
167
  )}
160
168
  </span>
161
169
  {isSelected && (
162
- <Check size={16} strokeWidth={2} aria-hidden className="text-accent shrink-0" />
170
+ <Check size={16} strokeWidth={2} aria-hidden className="shrink-0 text-accent" />
163
171
  )}
164
172
  </button>
165
173
  );
@@ -28,16 +28,16 @@ export function EmailDefaults({ unsubscribeUrl, quickClickMs }: EmailDefaultsPro
28
28
 
29
29
  return (
30
30
  <section
31
- className="border-border bg-card mt-4 max-w-xl rounded-2xl border p-5"
31
+ className="mt-4 max-w-xl rounded-2xl border border-border bg-card p-5"
32
32
  style={superellipse}
33
33
  >
34
34
  <h2 className="text-sm font-medium">{t('settings.emailDefaults')}</h2>
35
- <p className="text-muted mt-1 text-xs">{t('settings.emailDefaultsHint')}</p>
35
+ <p className="mt-1 text-xs text-muted">{t('settings.emailDefaultsHint')}</p>
36
36
  <dl className="mt-3 grid grid-cols-[max-content_1fr] gap-x-8 gap-y-2 text-sm">
37
37
  {rows.map((row) => (
38
38
  <div key={row.label} className="contents">
39
39
  <dt className="text-muted">{row.label}</dt>
40
- <dd className="text-secondary min-w-0 truncate">
40
+ <dd className="min-w-0 truncate text-secondary">
41
41
  {row.value ?? t('common.notConfigured')}
42
42
  </dd>
43
43
  </div>
@@ -46,7 +46,7 @@ function RowIcon({ channel }: { channel: string | undefined }) {
46
46
  : channel === 'slack'
47
47
  ? MessagesSquare
48
48
  : Mail;
49
- return <Icon className="text-muted mt-0.5 size-4 shrink-0" strokeWidth={2} />;
49
+ return <Icon className="mt-0.5 size-4 shrink-0 text-muted" strokeWidth={2} />;
50
50
  }
51
51
 
52
52
  export function EmailList({ items, onOpen }: EmailListProps) {
@@ -59,10 +59,10 @@ export function EmailList({ items, onOpen }: EmailListProps) {
59
59
  * the page is the one scroller (see __root). Nothing clips, so the corners
60
60
  * are re-cut on the first and last cells below.
61
61
  */
62
- <div className="border-border bg-card rounded-2xl border" style={superellipse}>
62
+ <div className="rounded-2xl border border-border bg-card" style={superellipse}>
63
63
  <table className="w-full table-fixed border-separate border-spacing-0 text-sm max-md:block">
64
64
  <thead className="max-md:hidden">
65
- <tr className="text-muted text-left text-xs font-medium">
65
+ <tr className="text-left text-xs font-medium text-muted">
66
66
  <th className={clsx(HEAD_CELL, 'min-w-0 px-6')} style={superellipse}>
67
67
  {t('common.name')}
68
68
  </th>
@@ -87,8 +87,8 @@ export function EmailList({ items, onOpen }: EmailListProps) {
87
87
  own grid, so the fill and the radius live on it there. */
88
88
  'max-md:grid max-md:grid-cols-6 max-md:border-b max-md:px-3',
89
89
  'border-border max-md:first:rounded-t-2xl max-md:last:rounded-b-2xl',
90
- 'max-md:hover:bg-hover max-md:last:border-b-0',
91
- 'md:hover:[&>td]:bg-hover last:[&>td]:border-b-0',
90
+ 'max-md:last:border-b-0 max-md:hover:bg-hover',
91
+ 'last:[&>td]:border-b-0 md:hover:[&>td]:bg-hover',
92
92
  'md:last:[&>td:first-child]:rounded-bl-2xl',
93
93
  'md:last:[&>td:last-child]:rounded-br-2xl'
94
94
  )}
@@ -110,7 +110,7 @@ export function EmailList({ items, onOpen }: EmailListProps) {
110
110
  {displayName(item.name, t('common.untitled'))}
111
111
  </div>
112
112
  {item.description !== undefined && (
113
- <p className="text-muted mt-1 truncate text-sm">{item.description}</p>
113
+ <p className="mt-1 truncate text-sm text-muted">{item.description}</p>
114
114
  )}
115
115
  </div>
116
116
  </div>
@@ -7,10 +7,13 @@ import { type ComponentType, type SVGProps, useEffect, useState } from 'react';
7
7
  * by the module system from then on. vite-only (glob + svgr) — this component
8
8
  * is app-internal and deliberately not part of the library exports.
9
9
  */
10
- const FLAGS = import.meta.glob<ComponentType<SVGProps<SVGSVGElement>>>(
11
- '../app/assets/flags/*.svg',
12
- { query: '?react', import: 'default' }
13
- );
10
+ type FlagComponent = ComponentType<SVGProps<SVGSVGElement>>;
11
+
12
+ const FLAGS: Partial<Record<string, () => Promise<FlagComponent>>> =
13
+ import.meta.glob<FlagComponent>('../app/assets/flags/*.svg', {
14
+ query: '?react',
15
+ import: 'default',
16
+ });
14
17
 
15
18
  export interface FlagProps {
16
19
  /** ISO 3166-1 alpha-2, case-insensitive. Unknown codes render nothing. */
@@ -19,22 +22,25 @@ export interface FlagProps {
19
22
  }
20
23
 
21
24
  export function Flag({ code, className }: FlagProps) {
22
- const [Component, setComponent] = useState<ComponentType<SVGProps<SVGSVGElement>> | undefined>(
23
- undefined
24
- );
25
- const load = FLAGS[`../app/assets/flags/${code.toUpperCase()}.svg`];
25
+ const key = `../app/assets/flags/${code.toUpperCase()}.svg`;
26
+ const load = Object.hasOwn(FLAGS, key) ? FLAGS[key] : undefined;
27
+ const [loaded, setLoaded] = useState<{
28
+ load: typeof load;
29
+ Component: ComponentType<SVGProps<SVGSVGElement>>;
30
+ }>();
26
31
 
27
32
  useEffect(() => {
33
+ if (load === undefined) return;
28
34
  let alive = true;
29
- setComponent(undefined);
30
- void load?.().then((mod) => {
31
- if (alive) setComponent(() => mod);
35
+ void load().then((Component) => {
36
+ if (alive) setLoaded({ load, Component });
32
37
  });
33
38
  return () => {
34
39
  alive = false;
35
40
  };
36
41
  }, [load]);
37
42
 
43
+ const Component = loaded !== undefined && loaded.load === load ? loaded.Component : undefined;
38
44
  if (Component === undefined) return null;
39
45
  return <Component className={className} aria-hidden />;
40
46
  }
@@ -30,8 +30,8 @@ export function Input({ size = 'md', type = 'text', htmlSize, className, ...prop
30
30
  size={htmlSize}
31
31
  className={cn(
32
32
  'transition-colors duration-100 focus:outline-none',
33
- 'placeholder-placeholder bg-textfield focus-visible:border-accent border',
34
- 'dark:focus-visible:ring-accent/50 focus-visible:ring-accent/40',
33
+ 'border bg-textfield placeholder-placeholder focus-visible:border-accent',
34
+ 'focus-visible:ring-accent/40 dark:focus-visible:ring-accent/50',
35
35
  SIZE_STYLE[size],
36
36
  className
37
37
  )}
@@ -16,7 +16,7 @@ export function SearchInput({ size = 'sm', className, ...props }: Props) {
16
16
  size={16}
17
17
  strokeWidth={2}
18
18
  aria-hidden
19
- className="text-muted pointer-events-none absolute top-1/2 left-2.5 -translate-y-1/2"
19
+ className="pointer-events-none absolute top-1/2 left-2.5 -translate-y-1/2 text-muted"
20
20
  />
21
21
  <Input {...props} size={size} type="search" className="w-full rounded-full pl-8" />
22
22
  </div>
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  FloatingFocusManager,
3
+ type ReferenceType,
3
4
  autoUpdate,
4
5
  flip,
5
6
  offset,
@@ -47,6 +48,13 @@ export function Menu({ items, className, ...aria }: Props) {
47
48
  whileElementsMounted: autoUpdate,
48
49
  middleware: [offset(4), flip({ padding: 8 }), shift({ padding: 8 })],
49
50
  });
51
+ const {
52
+ setFloating,
53
+ setReference,
54
+ }: {
55
+ setFloating: (this: void, node: HTMLElement | null) => void;
56
+ setReference: (this: void, node: ReferenceType | null) => void;
57
+ } = refs;
50
58
 
51
59
  const listRef = useRef<(HTMLElement | null)[]>([]);
52
60
  const { getReferenceProps, getFloatingProps, getItemProps } = useInteractions([
@@ -60,9 +68,9 @@ export function Menu({ items, className, ...aria }: Props) {
60
68
  <>
61
69
  <button
62
70
  type="button"
63
- ref={refs.setReference}
71
+ ref={setReference}
64
72
  className={cn(
65
- 'text-muted hover:bg-hover hover:text-primary flex size-8 items-center justify-center',
73
+ 'flex size-8 items-center justify-center text-muted hover:bg-hover hover:text-primary',
66
74
  'rounded-lg transition-colors focus:outline-none',
67
75
  className
68
76
  )}
@@ -79,9 +87,9 @@ export function Menu({ items, className, ...aria }: Props) {
79
87
  {open && (
80
88
  <FloatingFocusManager context={context} modal={false}>
81
89
  <div
82
- ref={refs.setFloating}
90
+ ref={setFloating}
83
91
  style={floatingStyles}
84
- className="border-border bg-card z-50 min-w-36 rounded-xl border p-1 shadow-lg"
92
+ className="z-50 min-w-36 rounded-xl border border-border bg-card p-1 shadow-lg"
85
93
  {...getFloatingProps()}
86
94
  >
87
95
  {items.map((item, index) => (
@@ -165,7 +165,7 @@ export function MetricCard({ label, value, delta, dates, series, format }: Metri
165
165
 
166
166
  return (
167
167
  <section
168
- className="border-border bg-card flex flex-col overflow-hidden rounded-2xl border"
168
+ className="flex flex-col overflow-hidden rounded-2xl border border-border bg-card"
169
169
  style={superellipse}
170
170
  >
171
171
  <div className="px-4 pt-4">
@@ -224,10 +224,10 @@ export function MetricCard({ label, value, delta, dates, series, format }: Metri
224
224
  </svg>
225
225
  {all.length > 0 && (
226
226
  <>
227
- <span className="text-muted pointer-events-none absolute top-0 left-4 text-xs tabular-nums">
227
+ <span className="pointer-events-none absolute top-0 left-4 text-xs text-muted tabular-nums">
228
228
  {format(max)}
229
229
  </span>
230
- <span className="text-muted pointer-events-none absolute right-4 bottom-1 text-xs tabular-nums">
230
+ <span className="pointer-events-none absolute right-4 bottom-1 text-xs text-muted tabular-nums">
231
231
  {format(min)}
232
232
  </span>
233
233
  </>
@@ -275,11 +275,11 @@ function HoverReadout({ x, date, rows }: { x: number; date: string; rows: readon
275
275
  const left = `${x * 100}%`;
276
276
  return (
277
277
  <div aria-hidden className="pointer-events-none">
278
- <div className="bg-border absolute inset-y-0 w-px" style={{ left }} />
278
+ <div className="absolute inset-y-0 w-px bg-border" style={{ left }} />
279
279
  {rows.map((row) => (
280
280
  <div
281
281
  key={row.label}
282
- className="border-card absolute size-2.5 rounded-full border-2"
282
+ className="absolute size-2.5 rounded-full border-2 border-card"
283
283
  style={{ left, top: row.y, background: row.color, transform: 'translate(-50%, -50%)' }}
284
284
  />
285
285
  ))}
@@ -296,7 +296,7 @@ function HoverReadout({ x, date, rows }: { x: number; date: string; rows: readon
296
296
  the label, which keeps the value flush right.
297
297
  */}
298
298
  <div
299
- className="border-border bg-card shadow-card-shadow absolute top-0 grid w-max items-center gap-x-3 gap-y-1 rounded-lg border px-2.5 py-2 text-xs shadow-md"
299
+ className="absolute top-0 grid w-max items-center gap-x-3 gap-y-1 rounded-lg border border-border bg-card px-2.5 py-2 text-xs shadow-md shadow-card-shadow"
300
300
  style={{
301
301
  ...superellipse,
302
302
  left,
@@ -311,7 +311,7 @@ function HoverReadout({ x, date, rows }: { x: number; date: string; rows: readon
311
311
  className="size-3 rounded-sm"
312
312
  style={{ ...superellipse, background: row.color }}
313
313
  />
314
- <span className="text-secondary whitespace-nowrap">{row.label}</span>
314
+ <span className="whitespace-nowrap text-secondary">{row.label}</span>
315
315
  <span className="text-right font-medium tabular-nums">{row.value}</span>
316
316
  </Fragment>
317
317
  ))}
@@ -32,6 +32,7 @@ export function Modal({ visible = false, className, disabled = false, children,
32
32
  if (!open && !disabled) onCancel?.();
33
33
  },
34
34
  });
35
+ const { setFloating }: { setFloating: (this: void, node: HTMLElement | null) => void } = refs;
35
36
 
36
37
  const { getFloatingProps } = useInteractions([
37
38
  useDismiss(context, { enabled: !disabled }),
@@ -48,10 +49,10 @@ export function Modal({ visible = false, className, disabled = false, children,
48
49
  >
49
50
  <FloatingFocusManager context={context}>
50
51
  <div
51
- ref={refs.setFloating}
52
+ ref={setFloating}
52
53
  style={superellipse}
53
54
  className={cn(
54
- 'bg-card relative max-h-dvh max-w-dvw overflow-y-auto rounded-3xl',
55
+ 'relative max-h-dvh max-w-dvw overflow-y-auto rounded-3xl bg-card',
55
56
  'shadow-lg dark:shadow-gray-700',
56
57
  className
57
58
  )}
@@ -66,5 +67,5 @@ export function Modal({ visible = false, className, disabled = false, children,
66
67
  }
67
68
 
68
69
  export function ModalTitle({ children }: { children: ReactNode }) {
69
- return <h2 className="text-primary text-lg font-semibold">{children}</h2>;
70
+ return <h2 className="text-lg font-semibold text-primary">{children}</h2>;
70
71
  }
@@ -61,7 +61,7 @@ export function NavDrawer({ open, onClose, children }: NavDrawerProps) {
61
61
  */}
62
62
  <aside
63
63
  inert={!open}
64
- className={`border-border bg-card fixed inset-y-0 left-0 z-30 flex w-60 max-w-[80%] flex-col border-r shadow-xl transition-transform duration-200 ease-out md:hidden ${
64
+ className={`fixed inset-y-0 left-0 z-30 flex w-60 max-w-[80%] flex-col border-r border-border bg-card shadow-xl transition-transform duration-200 ease-out md:hidden ${
65
65
  open ? 'translate-x-0' : '-translate-x-full'
66
66
  }`}
67
67
  >
@@ -69,10 +69,10 @@ export function NavDrawer({ open, onClose, children }: NavDrawerProps) {
69
69
  lands the logo exactly where the header would have drawn it. */}
70
70
  <div className="flex h-14 shrink-0 items-center gap-2.5 px-4">
71
71
  <div
72
- className="bg-primary flex size-7 shrink-0 items-center justify-center rounded-lg"
72
+ className="flex size-7 shrink-0 items-center justify-center rounded-lg bg-primary"
73
73
  style={superellipse}
74
74
  >
75
- <Workflow className="text-card size-4" strokeWidth={2} />
75
+ <Workflow className="size-4 text-card" strokeWidth={2} />
76
76
  </div>
77
77
  <strong className="text-sm font-semibold whitespace-nowrap">Workflow Studio</strong>
78
78
  </div>