@ai-matrx/records-ui 0.116.52 → 0.116.54
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 +13 -1
- package/dist/index.cjs +88 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +88 -1
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -2892,6 +2892,18 @@ function useEnrichCells(tableId, recordIds) {
|
|
|
2892
2892
|
return { cells, refresh, error };
|
|
2893
2893
|
}
|
|
2894
2894
|
var NEVER = "Fill it in once and leave it alone";
|
|
2895
|
+
var FILL_TRY_MAX = 10;
|
|
2896
|
+
var FILL_ROWS_MAX = 50;
|
|
2897
|
+
var FILL_N_DEFAULT = "3";
|
|
2898
|
+
function dueRowsEstimate(row) {
|
|
2899
|
+
const empty = Math.max(0, Number(row.rows_total) - Number(row.rows_filled));
|
|
2900
|
+
return Math.max(1, Math.min(FILL_ROWS_MAX, empty));
|
|
2901
|
+
}
|
|
2902
|
+
function fillCountFrom(text) {
|
|
2903
|
+
if (!/^\d+$/.test(text.trim())) return null;
|
|
2904
|
+
const n = Number(text);
|
|
2905
|
+
return n >= 1 && n <= FILL_ROWS_MAX ? n : null;
|
|
2906
|
+
}
|
|
2895
2907
|
function EnrichPanel({ tableId, fieldId, className }) {
|
|
2896
2908
|
const client = useRecordsClient7();
|
|
2897
2909
|
const host = useRecordsUi();
|
|
@@ -2903,6 +2915,8 @@ function EnrichPanel({ tableId, fieldId, className }) {
|
|
|
2903
2915
|
const [busy, setBusy] = useState7(null);
|
|
2904
2916
|
const [outcome, setOutcome] = useState7(null);
|
|
2905
2917
|
const [preview, setPreview] = useState7(null);
|
|
2918
|
+
const [fillN, setFillN] = useState7({});
|
|
2919
|
+
const [confirming, setConfirming] = useState7(null);
|
|
2906
2920
|
const [draft, setDraft] = useState7({});
|
|
2907
2921
|
const load = useCallback4(async () => {
|
|
2908
2922
|
const answered = await client.enrichments({ table_id: tableId });
|
|
@@ -2973,6 +2987,17 @@ function EnrichPanel({ tableId, fieldId, className }) {
|
|
|
2973
2987
|
},
|
|
2974
2988
|
[host, load, tableId]
|
|
2975
2989
|
);
|
|
2990
|
+
const startFill = useCallback4(
|
|
2991
|
+
(row, count) => {
|
|
2992
|
+
if (count > FILL_TRY_MAX) {
|
|
2993
|
+
setConfirming({ fieldId: row.field_id, count });
|
|
2994
|
+
return;
|
|
2995
|
+
}
|
|
2996
|
+
setConfirming(null);
|
|
2997
|
+
void runIt(row, false, count);
|
|
2998
|
+
},
|
|
2999
|
+
[runIt]
|
|
3000
|
+
);
|
|
2976
3001
|
if (error) return /* @__PURE__ */ jsx6(RefusalNotice, { error, className });
|
|
2977
3002
|
if (rows === null) return /* @__PURE__ */ jsx6(Skeleton, { className: cn2("h-40 w-full", className) });
|
|
2978
3003
|
if (shown4.length === 0 && fieldId) {
|
|
@@ -3210,17 +3235,77 @@ function EnrichPanel({ tableId, fieldId, className }) {
|
|
|
3210
3235
|
children: "Preview on five rows"
|
|
3211
3236
|
}
|
|
3212
3237
|
),
|
|
3238
|
+
/* @__PURE__ */ jsxs5("span", { className: "inline-flex items-center gap-1", "data-enrich-fill-n": "", children: [
|
|
3239
|
+
/* @__PURE__ */ jsx6(
|
|
3240
|
+
Input,
|
|
3241
|
+
{
|
|
3242
|
+
type: "number",
|
|
3243
|
+
inputMode: "numeric",
|
|
3244
|
+
min: 1,
|
|
3245
|
+
max: FILL_ROWS_MAX,
|
|
3246
|
+
className: "h-8 w-16",
|
|
3247
|
+
"aria-label": "How many rows to fill",
|
|
3248
|
+
value: fillN[row.field_id] ?? FILL_N_DEFAULT,
|
|
3249
|
+
onChange: (e) => setFillN((prev) => ({ ...prev, [row.field_id]: e.target.value }))
|
|
3250
|
+
}
|
|
3251
|
+
),
|
|
3252
|
+
/* @__PURE__ */ jsx6(
|
|
3253
|
+
Button5,
|
|
3254
|
+
{
|
|
3255
|
+
size: "sm",
|
|
3256
|
+
variant: "outline",
|
|
3257
|
+
disabled: busy === row.field_id || !row.enabled || fillCountFrom(fillN[row.field_id] ?? FILL_N_DEFAULT) === null,
|
|
3258
|
+
"data-enrich-fill-rows": "",
|
|
3259
|
+
onClick: () => {
|
|
3260
|
+
const n = fillCountFrom(fillN[row.field_id] ?? FILL_N_DEFAULT);
|
|
3261
|
+
if (n !== null) startFill(row, n);
|
|
3262
|
+
},
|
|
3263
|
+
children: (() => {
|
|
3264
|
+
const n = fillCountFrom(fillN[row.field_id] ?? FILL_N_DEFAULT);
|
|
3265
|
+
return n === null ? "Fill rows" : `Fill ${n} ${n === 1 ? "row" : "rows"}`;
|
|
3266
|
+
})()
|
|
3267
|
+
}
|
|
3268
|
+
)
|
|
3269
|
+
] }),
|
|
3213
3270
|
/* @__PURE__ */ jsx6(
|
|
3214
3271
|
Button5,
|
|
3215
3272
|
{
|
|
3216
3273
|
size: "sm",
|
|
3217
3274
|
disabled: busy === row.field_id || !row.enabled,
|
|
3218
|
-
|
|
3275
|
+
"data-enrich-fill-due": "",
|
|
3276
|
+
onClick: () => startFill(row, dueRowsEstimate(row)),
|
|
3219
3277
|
children: "Fill in what is due"
|
|
3220
3278
|
}
|
|
3221
3279
|
)
|
|
3222
3280
|
] }) : null
|
|
3223
3281
|
] }) : null,
|
|
3282
|
+
confirming && confirming.fieldId === row.field_id ? /* @__PURE__ */ jsxs5("div", { className: "space-y-2 rounded border p-2 text-xs", role: "alertdialog", "data-enrich-confirm": "", children: [
|
|
3283
|
+
/* @__PURE__ */ jsxs5("p", { children: [
|
|
3284
|
+
`Fill ${confirming.count} rows`,
|
|
3285
|
+
(() => {
|
|
3286
|
+
const each = row.cost_per_row_cents === null ? null : Number(row.cost_per_row_cents);
|
|
3287
|
+
const total = each === null ? null : costInPoints(each * confirming.count, host.pointsRate);
|
|
3288
|
+
return total !== null ? ` \xB7 about ${total}` : " \xB7 no estimate yet, it has not run";
|
|
3289
|
+
})()
|
|
3290
|
+
] }),
|
|
3291
|
+
/* @__PURE__ */ jsxs5("div", { className: "flex gap-2", children: [
|
|
3292
|
+
/* @__PURE__ */ jsx6(
|
|
3293
|
+
Button5,
|
|
3294
|
+
{
|
|
3295
|
+
size: "sm",
|
|
3296
|
+
"data-enrich-confirm-go": "",
|
|
3297
|
+
disabled: busy === row.field_id,
|
|
3298
|
+
onClick: () => {
|
|
3299
|
+
const n = confirming.count;
|
|
3300
|
+
setConfirming(null);
|
|
3301
|
+
void runIt(row, false, n);
|
|
3302
|
+
},
|
|
3303
|
+
children: `Fill ${confirming.count} rows`
|
|
3304
|
+
}
|
|
3305
|
+
),
|
|
3306
|
+
/* @__PURE__ */ jsx6(Button5, { size: "sm", variant: "ghost", onClick: () => setConfirming(null), children: "Cancel" })
|
|
3307
|
+
] })
|
|
3308
|
+
] }) : null,
|
|
3224
3309
|
!host.enrich && rights.admin ? /* @__PURE__ */ jsx6("p", { className: "text-[11px] text-muted-foreground", children: NO_ENRICH_REASON }) : null,
|
|
3225
3310
|
preview && preview.length > 0 ? /* @__PURE__ */ jsxs5("div", { className: "rounded border p-2 text-xs", children: [
|
|
3226
3311
|
/* @__PURE__ */ jsxs5("p", { className: "mb-1 font-medium", children: [
|
|
@@ -25171,6 +25256,8 @@ function ChartLayout({ view, fields, filter, onChange, remembered }) {
|
|
|
25171
25256
|
...question.bucket ? { bucket: question.bucket } : {},
|
|
25172
25257
|
measures: question.measures,
|
|
25173
25258
|
limit: 200,
|
|
25259
|
+
// a chart counts each option of a multi-value column under its own group (Airtable); the grid group-by does not
|
|
25260
|
+
splitMulti: true,
|
|
25174
25261
|
...Object.keys(asked2).length > 0 ? { filter: asked2 } : {}
|
|
25175
25262
|
}), whole]).then(([answered, overall]) => {
|
|
25176
25263
|
if (cancelled) return;
|