@ai-matrx/records-ui 0.102.17 → 0.102.20
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 +16 -0
- package/dist/index.cjs +2189 -2170
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -24
- package/dist/index.d.ts +3 -24
- package/dist/index.js +89 -70
- package/dist/index.js.map +1 -1
- package/dist/pickers.cjs +26 -5
- package/dist/pickers.cjs.map +1 -1
- package/dist/pickers.js +27 -6
- package/dist/pickers.js.map +1 -1
- package/dist/table-shape.cjs +4 -24
- package/dist/table-shape.cjs.map +1 -1
- package/dist/table-shape.js +5 -25
- package/dist/table-shape.js.map +1 -1
- package/package.json +4 -4
package/dist/pickers.js
CHANGED
|
@@ -40,7 +40,7 @@ function fieldOptionsOnce(client, fieldId) {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
// src/editors.tsx
|
|
43
|
-
import { useCallback as useCallback5, useEffect as useEffect10, useRef as useRef11, useState as useState14 } from "react";
|
|
43
|
+
import { useCallback as useCallback5, useEffect as useEffect10, useLayoutEffect, useRef as useRef11, useState as useState14 } from "react";
|
|
44
44
|
import { allowsOtherValues, choiceValuesOf, coerceTypedAnswer, newerKindOf as newerKindOf4, decideTypedChoice, isTheChosen, optionKey as optionKey2, rankTypedMatches as rankTypedMatches3, readTypedTime as readTypedTime2, typedDateText as typedDateText2, typedTimeText as typedTimeText2 } from "@ai-matrx/records";
|
|
45
45
|
import { useOptionalRecordsClient as useOptionalRecordsClient7 } from "@ai-matrx/records/react";
|
|
46
46
|
import {
|
|
@@ -3038,7 +3038,13 @@ function ClockGlyph() {
|
|
|
3038
3038
|
/* @__PURE__ */ jsx16("path", { d: "M12 6v6l4 2" })
|
|
3039
3039
|
] });
|
|
3040
3040
|
}
|
|
3041
|
-
function TypedDateHelper({
|
|
3041
|
+
function TypedDateHelper({
|
|
3042
|
+
kind,
|
|
3043
|
+
text,
|
|
3044
|
+
onText,
|
|
3045
|
+
label,
|
|
3046
|
+
onPicked
|
|
3047
|
+
}) {
|
|
3042
3048
|
const [open, setOpen] = useState12(false);
|
|
3043
3049
|
const held = readBox(text, kind);
|
|
3044
3050
|
const today = /* @__PURE__ */ new Date();
|
|
@@ -3053,12 +3059,16 @@ function TypedDateHelper({ kind, text, onText, label }) {
|
|
|
3053
3059
|
const pickDay = (d) => {
|
|
3054
3060
|
const day = `${shown2.y}-${pad(shown2.m + 1)}-${pad(d)}`;
|
|
3055
3061
|
onText(wordsFor(kind, day, held.time));
|
|
3056
|
-
if (kind === "date")
|
|
3062
|
+
if (kind === "date") {
|
|
3063
|
+
setOpen(false);
|
|
3064
|
+
onPicked?.();
|
|
3065
|
+
}
|
|
3057
3066
|
};
|
|
3058
3067
|
const pickTime = (t) => {
|
|
3059
3068
|
const day = kind === "datetime" ? held.day ?? todayKey : null;
|
|
3060
3069
|
onText(wordsFor(kind, day, t));
|
|
3061
3070
|
setOpen(false);
|
|
3071
|
+
onPicked?.();
|
|
3062
3072
|
};
|
|
3063
3073
|
const turn = (by) => {
|
|
3064
3074
|
const at = new Date(shown2.y, shown2.m + by, 1);
|
|
@@ -3311,6 +3321,17 @@ function openingText(field, value) {
|
|
|
3311
3321
|
const format = formatForField(field);
|
|
3312
3322
|
return format ? typedText(format, value) : String(value);
|
|
3313
3323
|
}
|
|
3324
|
+
function ReadsAsNote({ typed, always, children }) {
|
|
3325
|
+
const note = useRef11(null);
|
|
3326
|
+
const [repeats, setRepeats] = useState14(false);
|
|
3327
|
+
useLayoutEffect(() => {
|
|
3328
|
+
if (always) return;
|
|
3329
|
+
const words = (t) => (t ?? "").replace(/^Reads as/, "").replace(/\s+/g, "").toLowerCase();
|
|
3330
|
+
setRepeats(words(note.current?.textContent) === words(typed));
|
|
3331
|
+
}, [typed, always]);
|
|
3332
|
+
if (repeats) return null;
|
|
3333
|
+
return /* @__PURE__ */ jsx17("span", { ref: note, "data-records-typed-reads-as": "", "data-records-cell-note": "", className: "text-[10px] text-muted-foreground", children });
|
|
3334
|
+
}
|
|
3314
3335
|
function TypedTextControl({ field, value, onChange, disabled, id, onCommit, onCancel }) {
|
|
3315
3336
|
const client = useOptionalRecordsClient7();
|
|
3316
3337
|
const kind = String(editorKindFor(field));
|
|
@@ -3354,7 +3375,7 @@ function TypedTextControl({ field, value, onChange, disabled, id, onCommit, onCa
|
|
|
3354
3375
|
return /* @__PURE__ */ jsxs15("span", { className: "flex flex-col gap-0.5", children: [
|
|
3355
3376
|
helper && !disabled ? /* @__PURE__ */ jsxs15("span", { className: "flex min-w-0 items-center gap-0.5", children: [
|
|
3356
3377
|
box,
|
|
3357
|
-
/* @__PURE__ */ jsx17(TypedDateHelper, { kind: helper, text: value.text, onText: retype, label: fieldName(field) })
|
|
3378
|
+
/* @__PURE__ */ jsx17(TypedDateHelper, { kind: helper, text: value.text, onText: retype, label: fieldName(field), onPicked: onCommit })
|
|
3358
3379
|
] }) : box,
|
|
3359
3380
|
judged === null ? /* @__PURE__ */ jsxs15("span", { "data-records-cell-note": "", className: "text-[10px] text-muted-foreground", children: [
|
|
3360
3381
|
"Reading ",
|
|
@@ -3388,7 +3409,7 @@ function TypedTextControl({ field, value, onChange, disabled, id, onCommit, onCa
|
|
|
3388
3409
|
}
|
|
3389
3410
|
),
|
|
3390
3411
|
judged.cancelOnly && onCancel ? /* @__PURE__ */ jsx17("span", { "data-records-choice-ask": "", children: /* @__PURE__ */ jsx17(Button7, { type: "button", size: "sm", variant: "ghost", className: "h-6 px-2 text-xs", onClick: () => onCancel(), children: "Cancel" }) }) : null
|
|
3391
|
-
] }) : judged.value === null || judged.value === void 0 ? null : /* @__PURE__ */ jsxs15(
|
|
3412
|
+
] }) : judged.value === null || judged.value === void 0 ? null : /* @__PURE__ */ jsxs15(ReadsAsNote, { typed: value.text, always: isChoiceAddition(judged.value), children: [
|
|
3392
3413
|
isChoiceAddition(judged.value) ? `Adds ${quoted(judged.value.add)} to the choices for ${fieldName(field)}. ` : null,
|
|
3393
3414
|
"Reads as",
|
|
3394
3415
|
" ",
|
|
@@ -3401,7 +3422,7 @@ function TypedTextControl({ field, value, onChange, disabled, id, onCommit, onCa
|
|
|
3401
3422
|
const shown2 = format ?? (kind === "datetime" ? { id: carriesTimeOfDay(field, judged.value) ? "datetime" : "date" } : void 0);
|
|
3402
3423
|
return shown2 ? /* @__PURE__ */ jsx17(FormattedValue, { value: judged.value, format: shown2 }) : String(judged.value);
|
|
3403
3424
|
})()
|
|
3404
|
-
] })
|
|
3425
|
+
] }, value.text)
|
|
3405
3426
|
] });
|
|
3406
3427
|
}
|
|
3407
3428
|
function isPersonsName(field) {
|