@ai-matrx/records-ui 0.115.94 → 0.115.96
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.
- package/CHANGELOG.md +17 -0
- package/dist/index.cjs +103 -49
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +676 -622
- package/dist/index.js.map +1 -1
- package/dist/pickers.cjs +103 -49
- package/dist/pickers.cjs.map +1 -1
- package/dist/pickers.js +127 -73
- package/dist/pickers.js.map +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,23 @@
|
|
|
1
1
|
# Changelog — @ai-matrx/records-ui
|
|
2
2
|
|
|
3
|
+
## 0.115.96
|
|
4
|
+
|
|
5
|
+
UNVERIFIED: this release has no Unreleased entry and the source comparison could not be made (the caller supplied no source comparison). Whether source changed is unknown; consumer action is unknown.
|
|
6
|
+
Check the package's gitHead on npm against this version's gitHead: `git diff <previous gitHead> <this gitHead> -- apps/shared/records-ui/src`.
|
|
7
|
+
|
|
3
8
|
## 0.115.94
|
|
9
|
+
|
|
10
|
+
SOURCE CHANGED WITH NO RELEASE NOTE. This release shipped source changes that nobody described in an Unreleased entry,
|
|
11
|
+
so they may include breaking API changes. Consumer action is UNKNOWN: read the diff before upgrading.
|
|
12
|
+
Diff: `git diff 84cf41cf37 c127354b27 -- apps/shared/records-ui/src`
|
|
13
|
+
|
|
14
|
+
Changed shipped source files (4):
|
|
15
|
+
- `apps/shared/records-ui/src/InterfaceScreen.tsx`
|
|
16
|
+
- `apps/shared/records-ui/src/PageCanvas.tsx`
|
|
17
|
+
- `apps/shared/records-ui/src/index.ts`
|
|
18
|
+
- `apps/shared/records-ui/src/interfaces.ts`
|
|
19
|
+
|
|
20
|
+
## 0.115.93
|
|
4
21
|
### Unreleased
|
|
5
22
|
|
|
6
23
|
- URL preview (Airtable's "Preview links"): a URL cell shows the page's title, description, site icon and image in a hover card, read through the new optional host port `linkPreview.read(url)` (the host asks its server; the browser never fetches the page). Unbound, the cell is the plain link chip.
|
package/dist/index.cjs
CHANGED
|
@@ -11133,6 +11133,15 @@ function buttonPressWords(label, pressed) {
|
|
|
11133
11133
|
const status = pressed.status ?? "ran";
|
|
11134
11134
|
return [`${pressed.automation ?? label}: ${status}.`, pressed.says].filter(Boolean).join(" ");
|
|
11135
11135
|
}
|
|
11136
|
+
var POLL_EVERY_MS = 1200;
|
|
11137
|
+
var POLL_FOR_MS = 12e4;
|
|
11138
|
+
function runAnswerWords(label, run) {
|
|
11139
|
+
const steps = run.steps ?? [];
|
|
11140
|
+
const failedStep = [...steps].reverse().find((s) => s.status === "failed");
|
|
11141
|
+
if (run.status === "failed") return [failedStep?.output_text ?? failedStep?.says, run.says].filter((t, i, all) => t && all.indexOf(t) === i).join(" ") || `${label} failed.`;
|
|
11142
|
+
const answered = [...steps].reverse().find((s) => s.output_text && s.output_text.trim() !== "");
|
|
11143
|
+
return answered?.output_text?.trim() || run.says || `${label} ran.`;
|
|
11144
|
+
}
|
|
11136
11145
|
var stop = (event) => event.stopPropagation();
|
|
11137
11146
|
function ButtonValue({ field: field2, recordId, inCell }) {
|
|
11138
11147
|
const client = (0, import_react59.useOptionalRecordsClient)();
|
|
@@ -11140,76 +11149,121 @@ function ButtonValue({ field: field2, recordId, inCell }) {
|
|
|
11140
11149
|
const [busy, setBusy] = (0, import_react58.useState)(false);
|
|
11141
11150
|
const [said2, setSaid] = (0, import_react58.useState)(null);
|
|
11142
11151
|
const [settingUp, setSettingUp] = (0, import_react58.useState)(false);
|
|
11152
|
+
const waitingOn = (0, import_react58.useRef)(0);
|
|
11153
|
+
(0, import_react58.useEffect)(() => () => void (waitingOn.current += 1), []);
|
|
11143
11154
|
if (!b) return null;
|
|
11144
11155
|
const color = (0, import_data_table7.isStyleColor)(b.color) ? import_data_table7.CHOICE_CHIP_CLASS[b.color] : import_data_table7.NEUTRAL_CHIP_CLASS;
|
|
11145
11156
|
const needs = (0, import_records29.buttonNeeds)(b);
|
|
11146
11157
|
const tableId = field2.entity_definition_id;
|
|
11147
11158
|
const press = async () => {
|
|
11148
11159
|
if (!client || !recordId) return setSaid({ kind: "public" });
|
|
11149
|
-
if (needs) return setSaid({ kind: "needs", says: needs });
|
|
11160
|
+
if (needs && b.do) return setSaid({ kind: "needs", says: needs });
|
|
11150
11161
|
setBusy(true);
|
|
11151
11162
|
const answered = await client.buttonPress({ record_id: recordId, field_id: field2.id });
|
|
11152
11163
|
setBusy(false);
|
|
11153
|
-
if (!answered.ok)
|
|
11164
|
+
if (!answered.ok) {
|
|
11165
|
+
if (needs && (answered.error.sqlstate === "22023" || answered.error.code === "invalid_argument")) return setSaid({ kind: "needs", says: needs });
|
|
11166
|
+
return setSaid({ kind: "refused", error: answered.error });
|
|
11167
|
+
}
|
|
11154
11168
|
const pressed = answered.data;
|
|
11155
11169
|
if (pressed.do === "open_url") {
|
|
11156
11170
|
const opened = typeof window !== "undefined" ? (0, import_outbound.openOutbound)(pressed.url, "_blank", "noopener") : null;
|
|
11157
11171
|
return setSaid({ kind: "ran", says: opened ? `${b.label} opened.` : `${b.label} is ready:`, link: pressed.url });
|
|
11158
11172
|
}
|
|
11159
|
-
|
|
11173
|
+
const words2 = buttonPressWords(b.label, pressed);
|
|
11174
|
+
if (pressed.do === "run_automation" && pressed.status === "waiting" && pressed.run_id && b.automation_id) {
|
|
11175
|
+
const mine = waitingOn.current += 1;
|
|
11176
|
+
setBusy(true);
|
|
11177
|
+
setSaid({ kind: "waiting", says: `${b.label} is running` });
|
|
11178
|
+
const until = Date.now() + POLL_FOR_MS;
|
|
11179
|
+
while (waitingOn.current === mine) {
|
|
11180
|
+
await new Promise((r) => setTimeout(r, POLL_EVERY_MS));
|
|
11181
|
+
if (waitingOn.current !== mine) return;
|
|
11182
|
+
const runs = await client.automationRuns({ automation_id: b.automation_id, limit: 10 });
|
|
11183
|
+
if (!runs.ok) {
|
|
11184
|
+
setBusy(false);
|
|
11185
|
+
return setSaid({ kind: "refused", error: runs.error });
|
|
11186
|
+
}
|
|
11187
|
+
const run = runs.data.runs.find((r) => r.run_id === pressed.run_id);
|
|
11188
|
+
if (run && run.status !== "waiting") {
|
|
11189
|
+
setBusy(false);
|
|
11190
|
+
return setSaid(run.status === "ran" ? { kind: "ran", says: runAnswerWords(b.label, run) } : { kind: "failed", says: runAnswerWords(b.label, run) });
|
|
11191
|
+
}
|
|
11192
|
+
if (Date.now() > until) {
|
|
11193
|
+
setBusy(false);
|
|
11194
|
+
return setSaid({ kind: "ran", says: `${b.label} is still running. Its answer will be in the automation's runs.` });
|
|
11195
|
+
}
|
|
11196
|
+
}
|
|
11197
|
+
return;
|
|
11198
|
+
}
|
|
11199
|
+
setSaid({ kind: "ran", says: words2 });
|
|
11160
11200
|
};
|
|
11161
11201
|
return /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(import_jsx_runtime40.Fragment, { children: [
|
|
11162
|
-
/* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(
|
|
11163
|
-
|
|
11164
|
-
|
|
11165
|
-
|
|
11166
|
-
|
|
11167
|
-
|
|
11168
|
-
|
|
11169
|
-
|
|
11170
|
-
|
|
11171
|
-
|
|
11172
|
-
|
|
11173
|
-
|
|
11174
|
-
onPointerDown: stop,
|
|
11175
|
-
onDoubleClick: stop,
|
|
11176
|
-
onClick: (event) => {
|
|
11177
|
-
event.stopPropagation();
|
|
11178
|
-
event.preventDefault();
|
|
11179
|
-
void press();
|
|
11180
|
-
},
|
|
11181
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("span", { className: "truncate", children: b.label })
|
|
11182
|
-
}
|
|
11183
|
-
) }),
|
|
11184
|
-
/* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(import_design_system35.PopoverContent, { className: "w-72 space-y-2 p-3 text-sm", onClick: stop, onPointerDown: stop, "data-records-button-said": said2?.kind, children: [
|
|
11185
|
-
said2?.kind === "refused" ? /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(RefusalLine, { error: said2.error }) : null,
|
|
11186
|
-
said2?.kind === "public" ? /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("p", { children: "Buttons run for signed-in people." }) : null,
|
|
11187
|
-
said2?.kind === "ran" ? /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("p", { className: "break-words", children: [
|
|
11188
|
-
said2.says,
|
|
11189
|
-
" ",
|
|
11190
|
-
said2.link ? /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_outbound_react6.OutboundLink, { href: said2.link, className: "text-primary underline", children: said2.link }) : null
|
|
11191
|
-
] }) : null,
|
|
11192
|
-
said2?.kind === "needs" ? /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(import_jsx_runtime40.Fragment, { children: [
|
|
11193
|
-
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)("p", { children: said2.says }),
|
|
11194
|
-
tableId ? /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(
|
|
11202
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(
|
|
11203
|
+
import_design_system35.Popover,
|
|
11204
|
+
{
|
|
11205
|
+
open: said2 !== null,
|
|
11206
|
+
onOpenChange: (open) => {
|
|
11207
|
+
if (open) return;
|
|
11208
|
+
waitingOn.current += 1;
|
|
11209
|
+
setBusy(false);
|
|
11210
|
+
setSaid(null);
|
|
11211
|
+
},
|
|
11212
|
+
children: [
|
|
11213
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_design_system35.PopoverTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
|
11195
11214
|
import_design_system35.Button,
|
|
11196
11215
|
{
|
|
11197
11216
|
type: "button",
|
|
11198
|
-
size: "
|
|
11199
|
-
|
|
11200
|
-
|
|
11201
|
-
|
|
11202
|
-
|
|
11217
|
+
size: "xs",
|
|
11218
|
+
variant: "outline",
|
|
11219
|
+
"data-records-button": field2.key,
|
|
11220
|
+
"data-records-button-unset": needs ? "" : void 0,
|
|
11221
|
+
"aria-busy": busy || void 0,
|
|
11222
|
+
disabled: busy,
|
|
11223
|
+
className: (0, import_design_system35.cn)("max-w-full gap-1 border px-2 font-medium", inCell ? "h-5" : "h-6", color, needs && "border-dashed opacity-80"),
|
|
11224
|
+
onPointerDown: stop,
|
|
11225
|
+
onDoubleClick: stop,
|
|
11226
|
+
onClick: (event) => {
|
|
11227
|
+
event.stopPropagation();
|
|
11228
|
+
event.preventDefault();
|
|
11229
|
+
void press();
|
|
11203
11230
|
},
|
|
11204
|
-
children:
|
|
11205
|
-
"Set up ",
|
|
11206
|
-
b.label
|
|
11207
|
-
]
|
|
11231
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("span", { className: "truncate", children: b.label })
|
|
11208
11232
|
}
|
|
11209
|
-
)
|
|
11210
|
-
|
|
11211
|
-
|
|
11212
|
-
|
|
11233
|
+
) }),
|
|
11234
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(import_design_system35.PopoverContent, { className: "w-72 space-y-2 p-3 text-sm", onClick: stop, onPointerDown: stop, "data-records-button-said": said2?.kind, children: [
|
|
11235
|
+
said2?.kind === "refused" ? /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(RefusalLine, { error: said2.error }) : null,
|
|
11236
|
+
said2?.kind === "waiting" ? /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("p", { className: "matrx-shimmer rounded px-1 py-0.5", role: "status", "aria-live": "polite", children: said2.says }) : null,
|
|
11237
|
+
said2?.kind === "failed" ? /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("p", { className: "break-words text-destructive", role: "alert", children: said2.says }) : null,
|
|
11238
|
+
said2?.kind === "public" ? /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("p", { children: "Buttons run for signed-in people." }) : null,
|
|
11239
|
+
said2?.kind === "ran" ? /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("p", { className: "break-words", children: [
|
|
11240
|
+
said2.says,
|
|
11241
|
+
" ",
|
|
11242
|
+
said2.link ? /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_outbound_react6.OutboundLink, { href: said2.link, className: "text-primary underline", children: said2.link }) : null
|
|
11243
|
+
] }) : null,
|
|
11244
|
+
said2?.kind === "needs" ? /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(import_jsx_runtime40.Fragment, { children: [
|
|
11245
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)("p", { children: said2.says }),
|
|
11246
|
+
tableId ? /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(
|
|
11247
|
+
import_design_system35.Button,
|
|
11248
|
+
{
|
|
11249
|
+
type: "button",
|
|
11250
|
+
size: "sm",
|
|
11251
|
+
"data-records-button-set-up": "",
|
|
11252
|
+
onClick: () => {
|
|
11253
|
+
setSaid(null);
|
|
11254
|
+
setSettingUp(true);
|
|
11255
|
+
},
|
|
11256
|
+
children: [
|
|
11257
|
+
"Set up ",
|
|
11258
|
+
b.label
|
|
11259
|
+
]
|
|
11260
|
+
}
|
|
11261
|
+
) : null
|
|
11262
|
+
] }) : null
|
|
11263
|
+
] })
|
|
11264
|
+
]
|
|
11265
|
+
}
|
|
11266
|
+
),
|
|
11213
11267
|
settingUp && tableId ? /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_design_system35.Dialog, { open: true, onOpenChange: (open) => open ? null : setSettingUp(false), children: /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(import_design_system35.DialogContent, { className: "max-h-[85vh] overflow-y-auto sm:max-w-2xl", onClick: stop, onPointerDown: stop, children: [
|
|
11214
11268
|
/* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(import_design_system35.DialogHeader, { children: [
|
|
11215
11269
|
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_design_system35.DialogTitle, { children: `Column settings \xB7 ${fieldName(field2)}` }),
|