@frogbotai/next 0.29.0 → 0.30.0

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 (147) hide show
  1. package/dist/elements/ChannelCell/index.client.js +6 -3
  2. package/dist/elements/ChannelCell/index.client.js.map +1 -1
  3. package/dist/elements/CostUSD/index.client.d.ts +13 -0
  4. package/dist/elements/CostUSD/index.client.d.ts.map +1 -0
  5. package/dist/elements/CostUSD/index.client.js +42 -0
  6. package/dist/elements/CostUSD/index.client.js.map +1 -0
  7. package/dist/elements/Nav/AccountMenu.js +80 -12
  8. package/dist/elements/Nav/AccountMenu.js.map +1 -1
  9. package/dist/elements/Nav/AppSidebar.js +144 -36
  10. package/dist/elements/Nav/AppSidebar.js.map +1 -1
  11. package/dist/elements/Nav/CollectionsSection.js +45 -13
  12. package/dist/elements/Nav/CollectionsSection.js.map +1 -1
  13. package/dist/elements/Nav/MobileNavToggle.js +11 -3
  14. package/dist/elements/Nav/MobileNavToggle.js.map +1 -1
  15. package/dist/elements/Nav/NavItem.d.ts.map +1 -1
  16. package/dist/elements/Nav/NavItem.js +22 -9
  17. package/dist/elements/Nav/NavItem.js.map +1 -1
  18. package/dist/elements/Nav/NavSection.js +47 -7
  19. package/dist/elements/Nav/NavSection.js.map +1 -1
  20. package/dist/elements/Nav/RecentsSection.client.js +72 -28
  21. package/dist/elements/Nav/RecentsSection.client.js.map +1 -1
  22. package/dist/elements/Nav/RecentsSection.js +19 -9
  23. package/dist/elements/Nav/RecentsSection.js.map +1 -1
  24. package/dist/elements/Nav/buildNavModel.js +35 -29
  25. package/dist/elements/Nav/buildNavModel.js.map +1 -1
  26. package/dist/elements/Nav/fixtures/consumer/RecentsSection.js +19 -9
  27. package/dist/elements/Nav/fixtures/consumer/RecentsSection.js.map +1 -1
  28. package/dist/elements/Nav/fixtures/consumer/config.js +5 -2
  29. package/dist/elements/Nav/fixtures/consumer/config.js.map +1 -1
  30. package/dist/elements/Nav/index.client.js +86 -27
  31. package/dist/elements/Nav/index.client.js.map +1 -1
  32. package/dist/elements/Nav/index.css +0 -5
  33. package/dist/elements/Nav/index.js +93 -47
  34. package/dist/elements/Nav/index.js.map +1 -1
  35. package/dist/elements/Nav/navShellState.js +2 -2
  36. package/dist/elements/Nav/navShellState.js.map +1 -1
  37. package/dist/elements/Nav/renderNavIcon.js +11 -4
  38. package/dist/elements/Nav/renderNavIcon.js.map +1 -1
  39. package/dist/elements/SettingsNav/index.d.ts.map +1 -1
  40. package/dist/elements/SettingsNav/index.js +59 -3
  41. package/dist/elements/SettingsNav/index.js.map +1 -1
  42. package/dist/elements/SignInButtons/index.client.js +44 -8
  43. package/dist/elements/SignInButtons/index.client.js.map +1 -1
  44. package/dist/elements/SignInButtons/index.js +16 -7
  45. package/dist/elements/SignInButtons/index.js.map +1 -1
  46. package/dist/elements/StepNavReset/TabTitleSync.js +17 -12
  47. package/dist/elements/StepNavReset/TabTitleSync.js.map +1 -1
  48. package/dist/elements/StepNavReset/index.client.js +14 -6
  49. package/dist/elements/StepNavReset/index.client.js.map +1 -1
  50. package/dist/elements/ViewSwitcher/index.client.js +19 -10
  51. package/dist/elements/ViewSwitcher/index.client.js.map +1 -1
  52. package/dist/exports/ChatView.client.js +219 -101
  53. package/dist/exports/ChatView.client.js.map +1 -1
  54. package/dist/exports/client.d.ts +1 -0
  55. package/dist/exports/client.d.ts.map +1 -1
  56. package/dist/exports/client.js +6 -4
  57. package/dist/exports/client.js.map +1 -1
  58. package/dist/exports/config.js +1 -0
  59. package/dist/exports/config.js.map +1 -1
  60. package/dist/exports/css.js +1 -0
  61. package/dist/exports/css.js.map +1 -1
  62. package/dist/exports/layouts.js +15 -4
  63. package/dist/exports/layouts.js.map +1 -1
  64. package/dist/exports/routes.js +3 -2
  65. package/dist/exports/routes.js.map +1 -1
  66. package/dist/exports/rsc.js +1 -0
  67. package/dist/exports/rsc.js.map +1 -1
  68. package/dist/exports/templates.js +1 -0
  69. package/dist/exports/templates.js.map +1 -1
  70. package/dist/exports/views.d.ts.map +1 -1
  71. package/dist/exports/views.js +274 -104
  72. package/dist/exports/views.js.map +1 -1
  73. package/dist/graphics/FrogBotIcon.js +5 -1
  74. package/dist/graphics/FrogBotIcon.js.map +1 -1
  75. package/dist/graphics/FrogBotLogo.js +42 -1
  76. package/dist/graphics/FrogBotLogo.js.map +1 -1
  77. package/dist/index.js +2 -1
  78. package/dist/index.js.map +1 -1
  79. package/dist/templates/Default/index.js +7 -2
  80. package/dist/templates/Default/index.js.map +1 -1
  81. package/dist/types.js +2 -1
  82. package/dist/types.js.map +1 -1
  83. package/dist/utilities/brandImportMapErrors.js +4 -6
  84. package/dist/utilities/brandImportMapErrors.js.map +1 -1
  85. package/dist/views/Board/BoardPreference.client.js +26 -11
  86. package/dist/views/Board/BoardPreference.client.js.map +1 -1
  87. package/dist/views/Board/BoardView.client.js +155 -59
  88. package/dist/views/Board/BoardView.client.js.map +1 -1
  89. package/dist/views/Board/data.js +46 -35
  90. package/dist/views/Board/data.js.map +1 -1
  91. package/dist/views/Board/index.js +103 -63
  92. package/dist/views/Board/index.js.map +1 -1
  93. package/dist/views/Board/resolveActiveView.js +3 -2
  94. package/dist/views/Board/resolveActiveView.js.map +1 -1
  95. package/dist/views/Board/resolveColumns.js +40 -33
  96. package/dist/views/Board/resolveColumns.js.map +1 -1
  97. package/dist/views/Calendar/CalendarPreference.client.js +26 -11
  98. package/dist/views/Calendar/CalendarPreference.client.js.map +1 -1
  99. package/dist/views/Calendar/CalendarView.client.js +194 -72
  100. package/dist/views/Calendar/CalendarView.client.js.map +1 -1
  101. package/dist/views/Calendar/data.js +9 -9
  102. package/dist/views/Calendar/data.js.map +1 -1
  103. package/dist/views/Calendar/index.js +83 -52
  104. package/dist/views/Calendar/index.js.map +1 -1
  105. package/dist/views/CollectionViewShell.client.js +70 -9
  106. package/dist/views/CollectionViewShell.client.js.map +1 -1
  107. package/dist/views/CollectionViewShell.js +34 -12
  108. package/dist/views/CollectionViewShell.js.map +1 -1
  109. package/dist/views/CollectionViewSwitcher.js +18 -6
  110. package/dist/views/CollectionViewSwitcher.js.map +1 -1
  111. package/dist/views/Connections/ConnectionFields.js +141 -9
  112. package/dist/views/Connections/ConnectionFields.js.map +1 -1
  113. package/dist/views/Connections/ConnectionsView.client.js +397 -89
  114. package/dist/views/Connections/ConnectionsView.client.js.map +1 -1
  115. package/dist/views/Connections/index.js +34 -22
  116. package/dist/views/Connections/index.js.map +1 -1
  117. package/dist/views/Connections/schema.js +75 -50
  118. package/dist/views/Connections/schema.js.map +1 -1
  119. package/dist/views/Connections/types.js +2 -1
  120. package/dist/views/Connections/types.js.map +1 -1
  121. package/dist/views/CustomCollectionView.js +12 -7
  122. package/dist/views/CustomCollectionView.js.map +1 -1
  123. package/dist/views/List/DefaultListView.client.js +197 -52
  124. package/dist/views/List/DefaultListView.client.js.map +1 -1
  125. package/dist/views/Settings/metadata.d.ts +6 -0
  126. package/dist/views/Settings/metadata.d.ts.map +1 -0
  127. package/dist/views/Settings/metadata.js +40 -0
  128. package/dist/views/Settings/metadata.js.map +1 -0
  129. package/dist/views/Settings/resolveSection.d.ts +24 -0
  130. package/dist/views/Settings/resolveSection.d.ts.map +1 -0
  131. package/dist/views/Settings/resolveSection.js +24 -0
  132. package/dist/views/Settings/resolveSection.js.map +1 -0
  133. package/dist/views/cells.js +10 -17
  134. package/dist/views/cells.js.map +1 -1
  135. package/dist/views/collectionViews.js +9 -9
  136. package/dist/views/collectionViews.js.map +1 -1
  137. package/dist/views/controls/SortBuilder.client.js +140 -37
  138. package/dist/views/controls/SortBuilder.client.js.map +1 -1
  139. package/dist/views/controls/ViewControls.client.js +105 -41
  140. package/dist/views/controls/ViewControls.client.js.map +1 -1
  141. package/dist/views/controls/groupBy.js +2 -1
  142. package/dist/views/controls/groupBy.js.map +1 -1
  143. package/dist/views/preferences.js +17 -9
  144. package/dist/views/preferences.js.map +1 -1
  145. package/dist/withFrogBot.js +56 -42
  146. package/dist/withFrogBot.js.map +1 -1
  147. package/package.json +5 -5
@@ -1,26 +1,27 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
- import { Button, Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, Label, RadioGroup, RadioGroupItem, SearchInput, } from '@frogbotai/ui';
4
- import { ChevronLeftIcon, DeleteIcon, LinkSquareIcon, LoadingIcon, MoreHorizontalIcon, } from '@frogbotai/ui/icons';
3
+ import { Button, Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, Label, RadioGroup, RadioGroupItem, SearchInput } from '@frogbotai/ui';
4
+ import { ChevronLeftIcon, DeleteIcon, LinkSquareIcon, LoadingIcon, MoreHorizontalIcon } from '@frogbotai/ui/icons';
5
5
  import { useId, useRef, useState } from 'react';
6
6
  import { ConnectionFields } from './ConnectionFields.js';
7
7
  import { connectionInput, initialConnectionValue } from './schema.js';
8
- function ConnectionForm({ piece, apiPath, returnTo, onBack, onCancel, onCreated, onBusyChange, }) {
8
+ function ConnectionForm({ piece, apiPath, returnTo, onBack, onCancel, onCreated, onBusyChange }) {
9
9
  const id = useId();
10
10
  const [method, setMethod] = useState(piece.oauth ? 'oauth' : 'secret');
11
- const [value, setValue] = useState(() => piece.secretSchema ? initialConnectionValue(piece.secretSchema) : undefined);
11
+ const [value, setValue] = useState(()=>piece.secretSchema ? initialConnectionValue(piece.secretSchema) : undefined);
12
12
  const [error, setError] = useState('');
13
13
  const [busy, setBusy] = useState(false);
14
14
  const submitting = useRef(false);
15
- const submit = async () => {
16
- if (submitting.current)
17
- return;
15
+ const submit = async ()=>{
16
+ if (submitting.current) return;
18
17
  setError('');
19
18
  if (method === 'oauth') {
20
19
  submitting.current = true;
21
20
  setBusy(true);
22
21
  onBusyChange(true);
23
- window.location.assign(`${apiPath}/${encodeURIComponent(piece.slug)}/authorize?${new URLSearchParams({ returnTo })}`);
22
+ window.location.assign(`${apiPath}/${encodeURIComponent(piece.slug)}/authorize?${new URLSearchParams({
23
+ returnTo
24
+ })}`);
24
25
  return;
25
26
  }
26
27
  if (!piece.secretSchema) {
@@ -29,9 +30,11 @@ function ConnectionForm({ piece, apiPath, returnTo, onBack, onCancel, onCreated,
29
30
  }
30
31
  let body;
31
32
  try {
32
- body = JSON.stringify(connectionInput({ field: piece.secretSchema, value }));
33
- }
34
- catch (error) {
33
+ body = JSON.stringify(connectionInput({
34
+ field: piece.secretSchema,
35
+ value
36
+ }));
37
+ } catch (error) {
35
38
  setError(error instanceof Error ? error.message : 'Check your credential values.');
36
39
  return;
37
40
  }
@@ -42,81 +45,311 @@ function ConnectionForm({ piece, apiPath, returnTo, onBack, onCancel, onCreated,
42
45
  const response = await fetch(`${apiPath}/${encodeURIComponent(piece.slug)}`, {
43
46
  method: 'POST',
44
47
  credentials: 'same-origin',
45
- headers: { 'Content-Type': 'application/json' },
46
- body,
48
+ headers: {
49
+ 'Content-Type': 'application/json'
50
+ },
51
+ body
47
52
  });
48
53
  if (!response.ok) {
49
- setError(response.status === 401
50
- ? 'Your session has expired. Sign in and try again.'
51
- : response.status === 400
52
- ? 'These credentials were not accepted. Check the values and try again.'
53
- : 'Could not create the connection. Please try again.');
54
+ setError(response.status === 401 ? 'Your session has expired. Sign in and try again.' : response.status === 400 ? 'These credentials were not accepted. Check the values and try again.' : 'Could not create the connection. Please try again.');
54
55
  return;
55
56
  }
56
57
  setValue(undefined);
57
58
  onCreated();
58
- }
59
- catch {
59
+ } catch {
60
60
  setError('Could not reach the server. Please try again.');
61
- }
62
- finally {
61
+ } finally{
63
62
  submitting.current = false;
64
63
  setBusy(false);
65
64
  onBusyChange(false);
66
65
  }
67
66
  };
68
- return (_jsxs("form", { className: "frogbot-connections__form", onSubmit: (event) => {
67
+ return /*#__PURE__*/ _jsxs("form", {
68
+ className: "frogbot-connections__form",
69
+ onSubmit: (event)=>{
69
70
  event.preventDefault();
70
71
  void submit();
71
- }, children: [_jsxs(Button, { autoFocus: true, type: "button", variant: "ghost", size: "sm", className: "frogbot-connections__back", disabled: busy, onClick: onBack, children: [_jsx(ChevronLeftIcon, { size: 16 }), "Back"] }), _jsxs(DialogHeader, { children: [_jsxs(DialogTitle, { children: ["Connect to ", piece.label] }), _jsx(DialogDescription, { children: method === 'oauth'
72
- ? 'Authorize access with your account.'
73
- : 'Enter your credentials to link this integration.' })] }), _jsxs("fieldset", { disabled: busy, className: "frogbot-connections__form-fields", children: [piece.oauth && piece.secret && (_jsxs(RadioGroup, { "aria-label": "Connection method", value: method, onValueChange: (next) => {
72
+ },
73
+ children: [
74
+ /*#__PURE__*/ _jsxs(Button, {
75
+ autoFocus: true,
76
+ type: "button",
77
+ variant: "ghost",
78
+ size: "sm",
79
+ className: "frogbot-connections__back",
80
+ disabled: busy,
81
+ onClick: onBack,
82
+ children: [
83
+ /*#__PURE__*/ _jsx(ChevronLeftIcon, {
84
+ size: 16
85
+ }),
86
+ "Back"
87
+ ]
88
+ }),
89
+ /*#__PURE__*/ _jsxs(DialogHeader, {
90
+ children: [
91
+ /*#__PURE__*/ _jsxs(DialogTitle, {
92
+ children: [
93
+ "Connect to ",
94
+ piece.label
95
+ ]
96
+ }),
97
+ /*#__PURE__*/ _jsx(DialogDescription, {
98
+ children: method === 'oauth' ? 'Authorize access with your account.' : 'Enter your credentials to link this integration.'
99
+ })
100
+ ]
101
+ }),
102
+ /*#__PURE__*/ _jsxs("fieldset", {
103
+ disabled: busy,
104
+ className: "frogbot-connections__form-fields",
105
+ children: [
106
+ piece.oauth && piece.secret && /*#__PURE__*/ _jsxs(RadioGroup, {
107
+ "aria-label": "Connection method",
108
+ value: method,
109
+ onValueChange: (next)=>{
74
110
  setMethod(next);
75
111
  setError('');
76
- }, className: "frogbot-connections__methods", children: [_jsxs(Label, { className: "frogbot-connections__method", htmlFor: `${id}-oauth`, children: [_jsx(RadioGroupItem, { id: `${id}-oauth`, value: "oauth" }), "OAuth"] }), _jsxs(Label, { className: "frogbot-connections__method", htmlFor: `${id}-secret`, children: [_jsx(RadioGroupItem, { id: `${id}-secret`, value: "secret" }), "Static credentials"] })] })), method === 'secret' && piece.secretSchema && (_jsx(ConnectionFields, { field: piece.secretSchema, label: "Credential", value: value, onChange: setValue }))] }), error && (_jsx("p", { role: "alert", className: "frogbot-connections__error", children: error })), _jsxs(DialogFooter, { children: [_jsx(Button, { type: "button", variant: "outline", disabled: busy, onClick: onCancel, children: "Cancel" }), _jsxs(Button, { type: "submit", disabled: busy || (method === 'secret' && !piece.secretSchema), children: [busy && _jsx(LoadingIcon, { className: "frogbot-connections__spinner", size: 16 }), busy
77
- ? method === 'oauth'
78
- ? 'Redirecting…'
79
- : 'Connecting…'
80
- : method === 'oauth'
81
- ? `Continue with ${piece.label}`
82
- : 'Connect'] })] })] }));
112
+ },
113
+ className: "frogbot-connections__methods",
114
+ children: [
115
+ /*#__PURE__*/ _jsxs(Label, {
116
+ className: "frogbot-connections__method",
117
+ htmlFor: `${id}-oauth`,
118
+ children: [
119
+ /*#__PURE__*/ _jsx(RadioGroupItem, {
120
+ id: `${id}-oauth`,
121
+ value: "oauth"
122
+ }),
123
+ "OAuth"
124
+ ]
125
+ }),
126
+ /*#__PURE__*/ _jsxs(Label, {
127
+ className: "frogbot-connections__method",
128
+ htmlFor: `${id}-secret`,
129
+ children: [
130
+ /*#__PURE__*/ _jsx(RadioGroupItem, {
131
+ id: `${id}-secret`,
132
+ value: "secret"
133
+ }),
134
+ "Static credentials"
135
+ ]
136
+ })
137
+ ]
138
+ }),
139
+ method === 'secret' && piece.secretSchema && /*#__PURE__*/ _jsx(ConnectionFields, {
140
+ field: piece.secretSchema,
141
+ label: "Credential",
142
+ value: value,
143
+ onChange: setValue
144
+ })
145
+ ]
146
+ }),
147
+ error && /*#__PURE__*/ _jsx("p", {
148
+ role: "alert",
149
+ className: "frogbot-connections__error",
150
+ children: error
151
+ }),
152
+ /*#__PURE__*/ _jsxs(DialogFooter, {
153
+ children: [
154
+ /*#__PURE__*/ _jsx(Button, {
155
+ type: "button",
156
+ variant: "outline",
157
+ disabled: busy,
158
+ onClick: onCancel,
159
+ children: "Cancel"
160
+ }),
161
+ /*#__PURE__*/ _jsxs(Button, {
162
+ type: "submit",
163
+ disabled: busy || method === 'secret' && !piece.secretSchema,
164
+ children: [
165
+ busy && /*#__PURE__*/ _jsx(LoadingIcon, {
166
+ className: "frogbot-connections__spinner",
167
+ size: 16
168
+ }),
169
+ busy ? method === 'oauth' ? 'Redirecting…' : 'Connecting…' : method === 'oauth' ? `Continue with ${piece.label}` : 'Connect'
170
+ ]
171
+ })
172
+ ]
173
+ })
174
+ ]
175
+ });
83
176
  }
84
- function NewConnectionDialog({ pieces, apiPath, returnTo, open, onOpenChange, onCreated, }) {
177
+ function NewConnectionDialog({ pieces, apiPath, returnTo, open, onOpenChange, onCreated }) {
85
178
  const [selected, setSelected] = useState();
86
179
  const [search, setSearch] = useState('');
87
180
  const [busy, setBusy] = useState(false);
88
181
  const query = search.trim().toLowerCase();
89
- const filtered = pieces.filter((piece) => `${piece.label} ${piece.slug}`.toLowerCase().includes(query));
90
- const changeOpen = (next) => {
91
- if (busy)
92
- return;
182
+ const filtered = pieces.filter((piece)=>`${piece.label} ${piece.slug}`.toLowerCase().includes(query));
183
+ const changeOpen = (next)=>{
184
+ if (busy) return;
93
185
  if (!next) {
94
186
  setSelected(undefined);
95
187
  setSearch('');
96
188
  }
97
189
  onOpenChange(next);
98
190
  };
99
- return (_jsx(Dialog, { open: open, onOpenChange: changeOpen, children: _jsx(DialogContent, { className: `frogbot-connections__dialog${selected ? ' frogbot-connections__dialog--selected' : ''}`, onInteractOutside: (event) => event.preventDefault(), onEscapeKeyDown: (event) => {
100
- if (busy)
101
- event.preventDefault();
102
- }, withCloseButton: !busy, children: selected ? (_jsx(ConnectionForm, { piece: selected, apiPath: apiPath, returnTo: returnTo, onBack: () => setSelected(undefined), onCancel: () => changeOpen(false), onBusyChange: setBusy, onCreated: () => {
191
+ return /*#__PURE__*/ _jsx(Dialog, {
192
+ open: open,
193
+ onOpenChange: changeOpen,
194
+ children: /*#__PURE__*/ _jsx(DialogContent, {
195
+ className: `frogbot-connections__dialog${selected ? ' frogbot-connections__dialog--selected' : ''}`,
196
+ onInteractOutside: (event)=>event.preventDefault(),
197
+ onEscapeKeyDown: (event)=>{
198
+ if (busy) event.preventDefault();
199
+ },
200
+ withCloseButton: !busy,
201
+ children: selected ? /*#__PURE__*/ _jsx(ConnectionForm, {
202
+ piece: selected,
203
+ apiPath: apiPath,
204
+ returnTo: returnTo,
205
+ onBack: ()=>setSelected(undefined),
206
+ onCancel: ()=>changeOpen(false),
207
+ onBusyChange: setBusy,
208
+ onCreated: ()=>{
103
209
  setSelected(undefined);
104
210
  setSearch('');
105
211
  onCreated();
106
- } }, selected.slug)) : (_jsxs(_Fragment, { children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { children: "Select integration" }), _jsx(DialogDescription, { children: "Choose an integration to connect." })] }), _jsx(SearchInput, { autoFocus: true, "aria-label": "Search integrations", placeholder: "Search integrations\u2026", value: search, onChange: setSearch }), _jsxs("div", { className: "frogbot-connections__picker", children: [filtered.length === 0 && (_jsx("p", { className: "frogbot-connections__empty", children: "No integrations found" })), filtered.map((piece) => (_jsxs("button", { type: "button", className: "frogbot-connections__piece", onClick: () => setSelected(piece), children: [_jsx("span", { className: "frogbot-connections__icon", children: _jsx(LinkSquareIcon, { size: 20 }) }), _jsxs("span", { children: [_jsx("strong", { children: piece.label }), _jsx("span", { className: "frogbot-connections__muted", children: [piece.oauth && 'OAuth', piece.secret && 'Static credentials']
107
- .filter(Boolean)
108
- .join(' · ') })] })] }, piece.slug)))] })] })) }) }));
212
+ }
213
+ }, selected.slug) : /*#__PURE__*/ _jsxs(_Fragment, {
214
+ children: [
215
+ /*#__PURE__*/ _jsxs(DialogHeader, {
216
+ children: [
217
+ /*#__PURE__*/ _jsx(DialogTitle, {
218
+ children: "Select integration"
219
+ }),
220
+ /*#__PURE__*/ _jsx(DialogDescription, {
221
+ children: "Choose an integration to connect."
222
+ })
223
+ ]
224
+ }),
225
+ /*#__PURE__*/ _jsx(SearchInput, {
226
+ autoFocus: true,
227
+ "aria-label": "Search integrations",
228
+ placeholder: "Search integrations…",
229
+ value: search,
230
+ onChange: setSearch
231
+ }),
232
+ /*#__PURE__*/ _jsxs("div", {
233
+ className: "frogbot-connections__picker",
234
+ children: [
235
+ filtered.length === 0 && /*#__PURE__*/ _jsx("p", {
236
+ className: "frogbot-connections__empty",
237
+ children: "No integrations found"
238
+ }),
239
+ filtered.map((piece)=>/*#__PURE__*/ _jsxs("button", {
240
+ type: "button",
241
+ className: "frogbot-connections__piece",
242
+ onClick: ()=>setSelected(piece),
243
+ children: [
244
+ /*#__PURE__*/ _jsx("span", {
245
+ className: "frogbot-connections__icon",
246
+ children: /*#__PURE__*/ _jsx(LinkSquareIcon, {
247
+ size: 20
248
+ })
249
+ }),
250
+ /*#__PURE__*/ _jsxs("span", {
251
+ children: [
252
+ /*#__PURE__*/ _jsx("strong", {
253
+ children: piece.label
254
+ }),
255
+ /*#__PURE__*/ _jsx("span", {
256
+ className: "frogbot-connections__muted",
257
+ children: [
258
+ piece.oauth && 'OAuth',
259
+ piece.secret && 'Static credentials'
260
+ ].filter(Boolean).join(' · ')
261
+ })
262
+ ]
263
+ })
264
+ ]
265
+ }, piece.slug))
266
+ ]
267
+ })
268
+ ]
269
+ })
270
+ })
271
+ });
109
272
  }
110
- function ConnectionRow({ connection, label, busy, onDisconnect, }) {
111
- const expired = connection.status === 'active' &&
112
- connection.expiresAt &&
113
- Date.parse(connection.expiresAt) <= Date.now();
273
+ function ConnectionRow({ connection, label, busy, onDisconnect }) {
274
+ const expired = connection.status === 'active' && connection.expiresAt && Date.parse(connection.expiresAt) <= Date.now();
114
275
  const status = expired ? 'expired' : connection.status;
115
- return (_jsxs("div", { className: "frogbot-connections__row", children: [_jsxs("div", { className: "frogbot-connections__identity", children: [_jsx("span", { className: "frogbot-connections__icon", children: _jsx(LinkSquareIcon, { size: 20 }) }), _jsxs("div", { children: [_jsx("strong", { children: connection.account?.label || connection.account?.email || label }), _jsxs("span", { className: "frogbot-connections__muted", children: [label, connection.account?.email && connection.account.email !== connection.account.label
116
- ? ` · ${connection.account.email}`
117
- : ''] })] })] }), _jsxs("div", { className: "frogbot-connections__row-actions", children: [_jsx("span", { className: `frogbot-connections__status frogbot-connections__status--${status}`, children: status }), _jsx("span", { className: "frogbot-connections__muted", children: connection.method === 'oauth' ? 'OAuth' : 'Static credentials' }), _jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsx(Button, { variant: "ghost", size: "icon", disabled: busy, "aria-label": `Options for ${label}`, children: busy ? (_jsx(LoadingIcon, { className: "frogbot-connections__spinner", size: 16 })) : (_jsx(MoreHorizontalIcon, { size: 16 })) }) }), _jsx(DropdownMenuContent, { align: "end", children: _jsxs(DropdownMenuItem, { className: "frogbot-connections__disconnect", onSelect: onDisconnect, children: [_jsx(DeleteIcon, { size: 16 }), "Disconnect"] }) })] })] })] }));
276
+ return /*#__PURE__*/ _jsxs("div", {
277
+ className: "frogbot-connections__row",
278
+ children: [
279
+ /*#__PURE__*/ _jsxs("div", {
280
+ className: "frogbot-connections__identity",
281
+ children: [
282
+ /*#__PURE__*/ _jsx("span", {
283
+ className: "frogbot-connections__icon",
284
+ children: /*#__PURE__*/ _jsx(LinkSquareIcon, {
285
+ size: 20
286
+ })
287
+ }),
288
+ /*#__PURE__*/ _jsxs("div", {
289
+ children: [
290
+ /*#__PURE__*/ _jsx("strong", {
291
+ children: connection.account?.label || connection.account?.email || label
292
+ }),
293
+ /*#__PURE__*/ _jsxs("span", {
294
+ className: "frogbot-connections__muted",
295
+ children: [
296
+ label,
297
+ connection.account?.email && connection.account.email !== connection.account.label ? ` · ${connection.account.email}` : ''
298
+ ]
299
+ })
300
+ ]
301
+ })
302
+ ]
303
+ }),
304
+ /*#__PURE__*/ _jsxs("div", {
305
+ className: "frogbot-connections__row-actions",
306
+ children: [
307
+ /*#__PURE__*/ _jsx("span", {
308
+ className: `frogbot-connections__status frogbot-connections__status--${status}`,
309
+ children: status
310
+ }),
311
+ /*#__PURE__*/ _jsx("span", {
312
+ className: "frogbot-connections__muted",
313
+ children: connection.method === 'oauth' ? 'OAuth' : 'Static credentials'
314
+ }),
315
+ /*#__PURE__*/ _jsxs(DropdownMenu, {
316
+ children: [
317
+ /*#__PURE__*/ _jsx(DropdownMenuTrigger, {
318
+ asChild: true,
319
+ children: /*#__PURE__*/ _jsx(Button, {
320
+ variant: "ghost",
321
+ size: "icon",
322
+ disabled: busy,
323
+ "aria-label": `Options for ${label}`,
324
+ children: busy ? /*#__PURE__*/ _jsx(LoadingIcon, {
325
+ className: "frogbot-connections__spinner",
326
+ size: 16
327
+ }) : /*#__PURE__*/ _jsx(MoreHorizontalIcon, {
328
+ size: 16
329
+ })
330
+ })
331
+ }),
332
+ /*#__PURE__*/ _jsx(DropdownMenuContent, {
333
+ align: "end",
334
+ children: /*#__PURE__*/ _jsxs(DropdownMenuItem, {
335
+ className: "frogbot-connections__disconnect",
336
+ onSelect: onDisconnect,
337
+ children: [
338
+ /*#__PURE__*/ _jsx(DeleteIcon, {
339
+ size: 16
340
+ }),
341
+ "Disconnect"
342
+ ]
343
+ })
344
+ })
345
+ ]
346
+ })
347
+ ]
348
+ })
349
+ ]
350
+ });
118
351
  }
119
- export function ConnectionsViewClient({ apiPath, returnTo, pieces, initialConnections, initialError, }) {
352
+ export function ConnectionsViewClient({ apiPath, returnTo, pieces, initialConnections, initialError }) {
120
353
  const [connections, setConnections] = useState(initialConnections);
121
354
  const [error, setError] = useState(initialError ?? '');
122
355
  const [search, setSearch] = useState('');
@@ -125,72 +358,147 @@ export function ConnectionsViewClient({ apiPath, returnTo, pieces, initialConnec
125
358
  const [deleting, setDeleting] = useState();
126
359
  const requestID = useRef(0);
127
360
  const removing = useRef(false);
128
- const labels = new Map(pieces.map((piece) => [piece.slug, piece.label]));
361
+ const labels = new Map(pieces.map((piece)=>[
362
+ piece.slug,
363
+ piece.label
364
+ ]));
129
365
  const query = search.trim().toLowerCase();
130
- const filtered = connections.filter((connection) => [
131
- connection.piece,
132
- labels.get(connection.piece),
133
- connection.account?.label,
134
- connection.account?.email,
135
- ]
136
- .join(' ')
137
- .toLowerCase()
138
- .includes(query));
139
- const refresh = async () => {
366
+ const filtered = connections.filter((connection)=>[
367
+ connection.piece,
368
+ labels.get(connection.piece),
369
+ connection.account?.label,
370
+ connection.account?.email
371
+ ].join(' ').toLowerCase().includes(query));
372
+ const refresh = async ()=>{
140
373
  const request = ++requestID.current;
141
374
  setLoading(true);
142
375
  setError('');
143
376
  try {
144
377
  const response = await fetch(`${apiPath}?limit=0&depth=0`, {
145
378
  credentials: 'same-origin',
146
- cache: 'no-store',
379
+ cache: 'no-store'
147
380
  });
148
- if (!response.ok)
149
- throw new Error('Could not load your linked accounts. Please try again.');
150
- const data = (await response.json());
381
+ if (!response.ok) throw new Error('Could not load your linked accounts. Please try again.');
382
+ const data = await response.json();
151
383
  if (!Array.isArray(data.docs)) {
152
384
  throw new Error('Could not load your linked accounts. Please try again.');
153
385
  }
154
- if (request === requestID.current)
155
- setConnections(data.docs);
156
- }
157
- catch {
386
+ if (request === requestID.current) setConnections(data.docs);
387
+ } catch {
158
388
  if (request === requestID.current) {
159
389
  setError('Could not load your linked accounts. Please try again.');
160
390
  }
161
- }
162
- finally {
163
- if (request === requestID.current)
164
- setLoading(false);
391
+ } finally{
392
+ if (request === requestID.current) setLoading(false);
165
393
  }
166
394
  };
167
- const disconnect = async (id) => {
168
- if (removing.current)
169
- return;
395
+ const disconnect = async (id)=>{
396
+ if (removing.current) return;
170
397
  removing.current = true;
171
398
  setDeleting(id);
172
399
  setError('');
173
400
  try {
174
401
  const response = await fetch(`${apiPath}/${encodeURIComponent(String(id))}`, {
175
402
  method: 'DELETE',
176
- credentials: 'same-origin',
403
+ credentials: 'same-origin'
177
404
  });
178
- if (!response.ok)
179
- throw new Error('Could not disconnect this account. Please try again.');
180
- setConnections((current) => current.filter((connection) => connection.id !== id));
405
+ if (!response.ok) throw new Error('Could not disconnect this account. Please try again.');
406
+ setConnections((current)=>current.filter((connection)=>connection.id !== id));
181
407
  await refresh();
182
- }
183
- catch {
408
+ } catch {
184
409
  setError('Could not disconnect this account. Please try again.');
185
- }
186
- finally {
410
+ } finally{
187
411
  removing.current = false;
188
412
  setDeleting(undefined);
189
413
  }
190
414
  };
191
- return (_jsxs("div", { className: "frogbot-connections", children: [_jsxs("div", { className: "frogbot-connections__toolbar", children: [_jsx(SearchInput, { "aria-label": "Search connections", placeholder: "Search connections\u2026", value: search, onChange: setSearch }), _jsx(Button, { size: "sm", onClick: () => setOpen(true), disabled: pieces.length === 0, children: "+ New Connection" })] }), error && (_jsxs("div", { className: "frogbot-connections__error", role: "alert", children: [_jsx("span", { children: error }), _jsx(Button, { variant: "outline", size: "sm", disabled: loading, onClick: () => void refresh(), children: "Try again" })] })), loading ? (_jsxs("div", { role: "status", className: "frogbot-connections__empty", children: [_jsx(LoadingIcon, { size: 24, className: "frogbot-connections__spinner" }), _jsx("span", { children: "Loading connections\u2026" })] })) : filtered.length === 0 ? (error ? null : (_jsxs("div", { className: "frogbot-connections__empty frogbot-connections__empty--bordered", children: [_jsx(LinkSquareIcon, { size: 32 }), _jsx("p", { children: query ? 'No connections match your search' : 'No connections yet' }), !query && (_jsx(Button, { variant: "outline", size: "sm", disabled: pieces.length === 0, onClick: () => setOpen(true), children: "Add your first connection" }))] }))) : (_jsx("div", { className: "frogbot-connections__rows", children: filtered.map((connection) => (_jsx(ConnectionRow, { connection: connection, label: labels.get(connection.piece) ?? connection.piece, busy: deleting === connection.id, onDisconnect: () => void disconnect(connection.id) }, connection.id))) })), _jsx(NewConnectionDialog, { pieces: pieces, apiPath: apiPath, returnTo: returnTo, open: open, onOpenChange: setOpen, onCreated: () => {
415
+ return /*#__PURE__*/ _jsxs("div", {
416
+ className: "frogbot-connections",
417
+ children: [
418
+ /*#__PURE__*/ _jsxs("div", {
419
+ className: "frogbot-connections__toolbar",
420
+ children: [
421
+ /*#__PURE__*/ _jsx(SearchInput, {
422
+ "aria-label": "Search connections",
423
+ placeholder: "Search connections…",
424
+ value: search,
425
+ onChange: setSearch
426
+ }),
427
+ /*#__PURE__*/ _jsx(Button, {
428
+ size: "sm",
429
+ onClick: ()=>setOpen(true),
430
+ disabled: pieces.length === 0,
431
+ children: "+ New Connection"
432
+ })
433
+ ]
434
+ }),
435
+ error && /*#__PURE__*/ _jsxs("div", {
436
+ className: "frogbot-connections__error",
437
+ role: "alert",
438
+ children: [
439
+ /*#__PURE__*/ _jsx("span", {
440
+ children: error
441
+ }),
442
+ /*#__PURE__*/ _jsx(Button, {
443
+ variant: "outline",
444
+ size: "sm",
445
+ disabled: loading,
446
+ onClick: ()=>void refresh(),
447
+ children: "Try again"
448
+ })
449
+ ]
450
+ }),
451
+ loading ? /*#__PURE__*/ _jsxs("div", {
452
+ role: "status",
453
+ className: "frogbot-connections__empty",
454
+ children: [
455
+ /*#__PURE__*/ _jsx(LoadingIcon, {
456
+ size: 24,
457
+ className: "frogbot-connections__spinner"
458
+ }),
459
+ /*#__PURE__*/ _jsx("span", {
460
+ children: "Loading connections…"
461
+ })
462
+ ]
463
+ }) : filtered.length === 0 ? error ? null : /*#__PURE__*/ _jsxs("div", {
464
+ className: "frogbot-connections__empty frogbot-connections__empty--bordered",
465
+ children: [
466
+ /*#__PURE__*/ _jsx(LinkSquareIcon, {
467
+ size: 32
468
+ }),
469
+ /*#__PURE__*/ _jsx("p", {
470
+ children: query ? 'No connections match your search' : 'No connections yet'
471
+ }),
472
+ !query && /*#__PURE__*/ _jsx(Button, {
473
+ variant: "outline",
474
+ size: "sm",
475
+ disabled: pieces.length === 0,
476
+ onClick: ()=>setOpen(true),
477
+ children: "Add your first connection"
478
+ })
479
+ ]
480
+ }) : /*#__PURE__*/ _jsx("div", {
481
+ className: "frogbot-connections__rows",
482
+ children: filtered.map((connection)=>/*#__PURE__*/ _jsx(ConnectionRow, {
483
+ connection: connection,
484
+ label: labels.get(connection.piece) ?? connection.piece,
485
+ busy: deleting === connection.id,
486
+ onDisconnect: ()=>void disconnect(connection.id)
487
+ }, connection.id))
488
+ }),
489
+ /*#__PURE__*/ _jsx(NewConnectionDialog, {
490
+ pieces: pieces,
491
+ apiPath: apiPath,
492
+ returnTo: returnTo,
493
+ open: open,
494
+ onOpenChange: setOpen,
495
+ onCreated: ()=>{
192
496
  setOpen(false);
193
497
  void refresh();
194
- } })] }));
498
+ }
499
+ })
500
+ ]
501
+ });
195
502
  }
503
+
196
504
  //# sourceMappingURL=ConnectionsView.client.js.map