docblocks-react-ui 0.8.0 → 0.8.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.
- package/CHANGELOG.md +25 -0
- package/dist/{Editor-3Oh9KNyH.mjs → Editor-ByjnrYiw.mjs} +303 -167
- package/dist/index.mjs +1 -1
- package/dist/mermaid/index.mjs +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
# docblocks-react-ui
|
|
2
2
|
|
|
3
|
+
## 0.8.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 94f3f9a: **fixed:** the 0.8.1's filter's date/datetime's pickers' entry's code
|
|
8
|
+
lands — the filter value's `DatePicker` / `DateTimePicker`'s stand over
|
|
9
|
+
the raw's native's inputs (the 0.8.1's published build stood the raw's
|
|
10
|
+
inputs — the code's commit landed over the 0.8.1's release's cut).
|
|
11
|
+
|
|
12
|
+
## 0.8.1
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- ce42093: **fix:** the HTML paste and the whole-document import keep a bare `br`
|
|
17
|
+
between the block's text nodes as the soft line break (the `htmlToBlocks`'
|
|
18
|
+
edge whitespace drop no longer erases the line break — the non-browser
|
|
19
|
+
serializers stand the `<br>` between the blockquote's text nodes without
|
|
20
|
+
the `p`'s wrapper).
|
|
21
|
+
- **changed:** the database's filter value's date / datetime stand over the
|
|
22
|
+
house's `DatePicker` / `DateTimePicker` (the raw's native's `<input
|
|
23
|
+
type="date">` / `<input type="datetime-local">`'s stands are gone — the
|
|
24
|
+
commit stands the cell's same wire's format: the "YYYY-MM-DD" the
|
|
25
|
+
midnight's zero, the "THH:MM"[:SS] over the time's; the datetime's
|
|
26
|
+
commit stands on the popover's close).
|
|
27
|
+
|
|
3
28
|
## 0.8.0
|
|
4
29
|
|
|
5
30
|
### Minor Changes
|
|
@@ -5406,6 +5406,50 @@ function PopoverDescription({ className, ...props }) {
|
|
|
5406
5406
|
});
|
|
5407
5407
|
}
|
|
5408
5408
|
//#endregion
|
|
5409
|
+
//#region src/shared/ui/DatePicker.tsx
|
|
5410
|
+
/**
|
|
5411
|
+
* The single-date picker: the trigger stands the calendar icon + the
|
|
5412
|
+
* formatted date (the `PPP` long form) or the placeholder (the empty
|
|
5413
|
+
* state), and the calendar stands in the portaled popover content.
|
|
5414
|
+
*
|
|
5415
|
+
* The component is controlled: the `value` is a local-calendar `Date`
|
|
5416
|
+
* (the consumer converts the cell / doc value to it), and `onSelect`
|
|
5417
|
+
* fires on a day pick (picking the selected day again clears it — the
|
|
5418
|
+
* day-picker's toggle) and the popover closes on the pick (the cell's
|
|
5419
|
+
* focus stands back on the trigger). The extra props stand on the trigger
|
|
5420
|
+
* button (the `data-*` hooks included; the native `value` / `onSelect`
|
|
5421
|
+
* button props are omitted — they stand the picker's own contract).
|
|
5422
|
+
*/
|
|
5423
|
+
function DatePicker({ value, onSelect, className, placeholder = "—", ...triggerProps }) {
|
|
5424
|
+
const [open, setOpen] = React.useState(false);
|
|
5425
|
+
const onDateSelect = (date) => {
|
|
5426
|
+
setOpen(false);
|
|
5427
|
+
onSelect(date ?? null);
|
|
5428
|
+
};
|
|
5429
|
+
return /* @__PURE__ */ jsxs(Popover, {
|
|
5430
|
+
open,
|
|
5431
|
+
onOpenChange: setOpen,
|
|
5432
|
+
children: [/* @__PURE__ */ jsx(PopoverTrigger, {
|
|
5433
|
+
asChild: true,
|
|
5434
|
+
children: /* @__PURE__ */ jsxs(Button, {
|
|
5435
|
+
type: "button",
|
|
5436
|
+
variant: "outline",
|
|
5437
|
+
"data-empty": value ? void 0 : true,
|
|
5438
|
+
className: cn("justify-start text-left font-normal data-[empty=true]:text-muted-foreground", className),
|
|
5439
|
+
...triggerProps,
|
|
5440
|
+
children: [/* @__PURE__ */ jsx(CalendarIcon, {}), value ? format(value, "PPP") : /* @__PURE__ */ jsx("span", { children: placeholder })]
|
|
5441
|
+
})
|
|
5442
|
+
}), /* @__PURE__ */ jsx(PopoverContent, {
|
|
5443
|
+
className: "w-auto p-0",
|
|
5444
|
+
children: /* @__PURE__ */ jsx(Calendar, {
|
|
5445
|
+
mode: "single",
|
|
5446
|
+
selected: value ?? void 0,
|
|
5447
|
+
onSelect: onDateSelect
|
|
5448
|
+
})
|
|
5449
|
+
})]
|
|
5450
|
+
});
|
|
5451
|
+
}
|
|
5452
|
+
//#endregion
|
|
5409
5453
|
//#region src/shared/ui/Separator.tsx
|
|
5410
5454
|
function Separator({ className, orientation = "horizontal", decorative = true, ...props }) {
|
|
5411
5455
|
return /* @__PURE__ */ jsx(SeparatorPrimitive.Root, {
|
|
@@ -5594,6 +5638,98 @@ function TimeSegmentsInner({ id, value, onChange, disabled, clearable, className
|
|
|
5594
5638
|
});
|
|
5595
5639
|
}
|
|
5596
5640
|
//#endregion
|
|
5641
|
+
//#region src/shared/ui/DateTimePicker.tsx
|
|
5642
|
+
/** The trigger's label: the compact date, + the time when it is not the
|
|
5643
|
+
* midnight zero (the seconds stand only when they are not zero). */
|
|
5644
|
+
function labelOf(value) {
|
|
5645
|
+
const base = format(value, "dd.MM.yyyy");
|
|
5646
|
+
if (value.getHours() === 0 && value.getMinutes() === 0 && value.getSeconds() === 0) return base;
|
|
5647
|
+
const label = format(value, "HH:mm");
|
|
5648
|
+
return value.getSeconds() !== 0 ? `${base} ${label}:${format(value, "ss")}` : `${base} ${label}`;
|
|
5649
|
+
}
|
|
5650
|
+
function hasTime$1(value) {
|
|
5651
|
+
return value !== null && (value.getHours() !== 0 || value.getMinutes() !== 0 || value.getSeconds() !== 0);
|
|
5652
|
+
}
|
|
5653
|
+
function datePart(value) {
|
|
5654
|
+
return new Date(value.getFullYear(), value.getMonth(), value.getDate());
|
|
5655
|
+
}
|
|
5656
|
+
/**
|
|
5657
|
+
* The date-and-time picker: the `DatePicker`'s calendar + the `TimeSegments`
|
|
5658
|
+
* box in one portaled popover.
|
|
5659
|
+
*
|
|
5660
|
+
* The component is controlled: the `value` is a local-calendar `Date`, and
|
|
5661
|
+
* `onSelect` commits the picked date + the typed time (the commit stands on
|
|
5662
|
+
* the popover close — the escape / the outside press / an explicit close —
|
|
5663
|
+
* as one step; a no-op close stands no commit). The drafts stand from the
|
|
5664
|
+
* value at the open (the in-flight draft stands the mid-session value
|
|
5665
|
+
* changes), the day pick edits the draft date (the same-day toggle stands no
|
|
5666
|
+
* reset — the deferred commit's contract), the time box edits the draft
|
|
5667
|
+
* time; the extra props stand on the
|
|
5668
|
+
* trigger button (the `data-*` hooks included; the native `value` /
|
|
5669
|
+
* `onSelect` button props are omitted — they stand the picker's contract).
|
|
5670
|
+
*/
|
|
5671
|
+
function DateTimePicker({ value, onSelect, className, placeholder = "—", ...triggerProps }) {
|
|
5672
|
+
const [open, setOpen] = React.useState(false);
|
|
5673
|
+
const [draftDate, setDraftDate] = React.useState(null);
|
|
5674
|
+
const [draftTime, setDraftTime] = React.useState(null);
|
|
5675
|
+
const timeSegmentsId = React.useId();
|
|
5676
|
+
const handleOpenChange = (next) => {
|
|
5677
|
+
if (next) {
|
|
5678
|
+
setDraftDate(value !== null ? datePart(value) : null);
|
|
5679
|
+
setDraftTime(value !== null && hasTime$1(value) ? format(value, "HH:mm:ss") : null);
|
|
5680
|
+
setOpen(true);
|
|
5681
|
+
return;
|
|
5682
|
+
}
|
|
5683
|
+
setOpen(false);
|
|
5684
|
+
const committed = draftDate === null ? null : datePart(draftDate);
|
|
5685
|
+
if (draftTime !== null && committed !== null) {
|
|
5686
|
+
const [hours, minutes, seconds] = draftTime.split(":");
|
|
5687
|
+
committed.setHours(Number(hours), Number(minutes), Number(seconds));
|
|
5688
|
+
}
|
|
5689
|
+
if ((value?.getTime() ?? null) === (committed?.getTime() ?? null)) return;
|
|
5690
|
+
onSelect(committed);
|
|
5691
|
+
};
|
|
5692
|
+
const onDraftDateSelect = (date) => {
|
|
5693
|
+
if (date === void 0 || date === null) return;
|
|
5694
|
+
setDraftDate(datePart(date));
|
|
5695
|
+
};
|
|
5696
|
+
return /* @__PURE__ */ jsxs(Popover, {
|
|
5697
|
+
open,
|
|
5698
|
+
onOpenChange: handleOpenChange,
|
|
5699
|
+
children: [/* @__PURE__ */ jsx(PopoverTrigger, {
|
|
5700
|
+
asChild: true,
|
|
5701
|
+
children: /* @__PURE__ */ jsxs(Button, {
|
|
5702
|
+
type: "button",
|
|
5703
|
+
variant: "outline",
|
|
5704
|
+
"data-empty": value ? void 0 : true,
|
|
5705
|
+
className: cn("justify-start text-left font-normal data-[empty=true]:text-muted-foreground", className),
|
|
5706
|
+
...triggerProps,
|
|
5707
|
+
children: [/* @__PURE__ */ jsx(CalendarIcon, {}), value ? labelOf(value) : /* @__PURE__ */ jsx("span", { children: placeholder })]
|
|
5708
|
+
})
|
|
5709
|
+
}), /* @__PURE__ */ jsxs(PopoverContent, {
|
|
5710
|
+
className: "w-auto p-0",
|
|
5711
|
+
children: [
|
|
5712
|
+
/* @__PURE__ */ jsx(Calendar, {
|
|
5713
|
+
mode: "single",
|
|
5714
|
+
selected: draftDate ?? void 0,
|
|
5715
|
+
...value !== null ? { defaultMonth: value } : {},
|
|
5716
|
+
onSelect: onDraftDateSelect
|
|
5717
|
+
}),
|
|
5718
|
+
/* @__PURE__ */ jsx(Separator, {}),
|
|
5719
|
+
/* @__PURE__ */ jsx("div", {
|
|
5720
|
+
className: "p-2",
|
|
5721
|
+
children: /* @__PURE__ */ jsx(TimeSegments, {
|
|
5722
|
+
id: timeSegmentsId,
|
|
5723
|
+
value: draftTime,
|
|
5724
|
+
onChange: setDraftTime,
|
|
5725
|
+
clearable: true
|
|
5726
|
+
})
|
|
5727
|
+
})
|
|
5728
|
+
]
|
|
5729
|
+
})]
|
|
5730
|
+
});
|
|
5731
|
+
}
|
|
5732
|
+
//#endregion
|
|
5597
5733
|
//#region src/shared/ui/Datalist.tsx
|
|
5598
5734
|
function Datalist({ className, ...props }) {
|
|
5599
5735
|
return /* @__PURE__ */ jsx("datalist", {
|
|
@@ -7493,6 +7629,163 @@ function validateProtocolDescriptor(descriptor) {
|
|
|
7493
7629
|
for (const capability of BASELINE_CAPABILITIES) if (!capabilities.has(capability)) throw new BridgeError("protocol_mismatch", `The bridge lacks the required protocol capability "${capability}".`);
|
|
7494
7630
|
return capabilities;
|
|
7495
7631
|
}
|
|
7632
|
+
//#endregion
|
|
7633
|
+
//#region src/database/grid/utils.ts
|
|
7634
|
+
/** The database grid's pure helpers: the visible-column derivation, the
|
|
7635
|
+
* number column's display attributes / input step, the cell's selection
|
|
7636
|
+
* key, and the date/datetime value parsing + labels. */
|
|
7637
|
+
/** The full known id order: explicit ids first, then new schema columns. */
|
|
7638
|
+
function normalizeColumnOrder(columns, columnOrder) {
|
|
7639
|
+
const byId = new Map((columns ?? []).map((column) => [column.id, column]));
|
|
7640
|
+
const ordered = [];
|
|
7641
|
+
for (const id of columnOrder ?? []) {
|
|
7642
|
+
if (!byId.has(id) || ordered.includes(id)) continue;
|
|
7643
|
+
ordered.push(id);
|
|
7644
|
+
byId.delete(id);
|
|
7645
|
+
}
|
|
7646
|
+
for (const column of byId.values()) ordered.push(column.id);
|
|
7647
|
+
return ordered;
|
|
7648
|
+
}
|
|
7649
|
+
/** The block's visible columns: the full order minus the hidden ids. */
|
|
7650
|
+
function visibleColumns(columns, columnOrder, hiddenColumns) {
|
|
7651
|
+
const byId = new Map((columns ?? []).map((column) => [column.id, column]));
|
|
7652
|
+
const hidden = new Set(hiddenColumns ?? []);
|
|
7653
|
+
return normalizeColumnOrder(columns, columnOrder).flatMap((id) => {
|
|
7654
|
+
const column = byId.get(id);
|
|
7655
|
+
return column === void 0 || hidden.has(id) ? [] : [column];
|
|
7656
|
+
});
|
|
7657
|
+
}
|
|
7658
|
+
/** One immutable list move; an invalid or identity move returns the input. */
|
|
7659
|
+
function reorderItems(items, fromIndex, toIndex) {
|
|
7660
|
+
if (fromIndex === toIndex || fromIndex < 0 || toIndex < 0 || fromIndex >= items.length || toIndex >= items.length) return items;
|
|
7661
|
+
const next = [...items];
|
|
7662
|
+
const [moved] = next.splice(fromIndex, 1);
|
|
7663
|
+
if (moved === void 0) return items;
|
|
7664
|
+
next.splice(toIndex, 0, moved);
|
|
7665
|
+
return next;
|
|
7666
|
+
}
|
|
7667
|
+
/** A visible header drop mapped into the full order without moving hidden ids over an anchor. */
|
|
7668
|
+
function moveVisibleColumn(columns, columnOrder, hiddenColumns, columnId, toIndex) {
|
|
7669
|
+
const fullOrder = normalizeColumnOrder(columns, columnOrder);
|
|
7670
|
+
const visibleIds = visibleColumns(columns, columnOrder, hiddenColumns).map((column) => column.id);
|
|
7671
|
+
const stationary = visibleIds.filter((id) => id !== columnId);
|
|
7672
|
+
if (stationary.length === visibleIds.length || toIndex < 0 || toIndex > stationary.length) return fullOrder;
|
|
7673
|
+
const next = fullOrder.filter((id) => id !== columnId);
|
|
7674
|
+
const targetId = stationary[toIndex];
|
|
7675
|
+
if (targetId !== void 0) {
|
|
7676
|
+
next.splice(next.indexOf(targetId), 0, columnId);
|
|
7677
|
+
return next;
|
|
7678
|
+
}
|
|
7679
|
+
const anchorId = stationary.at(-1);
|
|
7680
|
+
if (anchorId === void 0) return fullOrder;
|
|
7681
|
+
next.splice(next.indexOf(anchorId) + 1, 0, columnId);
|
|
7682
|
+
return next;
|
|
7683
|
+
}
|
|
7684
|
+
/** The number input's step stand: the explicit `decimals` stands the
|
|
7685
|
+
* `10^-decimals` step; the absent stand follows the integer types only
|
|
7686
|
+
* (the float types stand no step — the 0.5 must be typeable). */
|
|
7687
|
+
function numberStepFor(column) {
|
|
7688
|
+
if (column.decimals !== void 0) {
|
|
7689
|
+
const decimals = Math.max(0, Math.min(10, Math.trunc(Number(column.decimals)) || 0));
|
|
7690
|
+
return decimals === 0 ? "1" : String(10 ** -decimals);
|
|
7691
|
+
}
|
|
7692
|
+
const base = column.type.replace(/\[\]$/, "").trim();
|
|
7693
|
+
return base === "integer" || base === "int" || base === "smallint" || base === "bigint" ? "1" : void 0;
|
|
7694
|
+
}
|
|
7695
|
+
/** The display's attributes stand: the explicit `decimals` (or the
|
|
7696
|
+
* integer stand) takes the fixed-digit format; the float types without
|
|
7697
|
+
* the explicit digits stand the RAW value (no rounding — the display
|
|
7698
|
+
* must not lose the value's own stand). */
|
|
7699
|
+
function numberDisplayAttrs(column) {
|
|
7700
|
+
const base = column.type.replace(/\[\]$/, "").trim();
|
|
7701
|
+
return {
|
|
7702
|
+
decimals: column.decimals !== void 0 || base === "integer" || base === "int" || base === "smallint" || base === "bigint" || base === "number" ? column.decimals ?? 0 : null,
|
|
7703
|
+
thousands: column.thousands,
|
|
7704
|
+
prefix: column.prefix,
|
|
7705
|
+
suffix: column.suffix
|
|
7706
|
+
};
|
|
7707
|
+
}
|
|
7708
|
+
/** The cell's selection/editing key (the row id + the column id). */
|
|
7709
|
+
const cellKeyOf = (rowId, colId) => `${rowId}\u0000${colId}`;
|
|
7710
|
+
/** The cell's clipboard text: the TSV's flat stand (the tab / the
|
|
7711
|
+
* newline stand the space — the TSV's shape stands; the row-link's array
|
|
7712
|
+
* joins over the comma — the label's stand, never the id). */
|
|
7713
|
+
function cellTextOf(value) {
|
|
7714
|
+
if (value === void 0 || value === null) return "";
|
|
7715
|
+
if (Array.isArray(value)) return value.map((item) => cellTextOf(item)).join(",");
|
|
7716
|
+
return String(value).replace(/[\t\n\r]/g, " ");
|
|
7717
|
+
}
|
|
7718
|
+
/** The TSV's parse (the clipboard's plain text over the grid's paste):
|
|
7719
|
+
* the rows over the newline (the carriage return stands the newline),
|
|
7720
|
+
* the cells over the tab; the trailing empty row stands no stand (the
|
|
7721
|
+
* clipboard's trailing newline). An empty text stands no grid. */
|
|
7722
|
+
function parseClipboardTsv(text) {
|
|
7723
|
+
const lines = text.replace(/\r\n?/g, "\n").split("\n");
|
|
7724
|
+
if (lines.length > 1 && lines[lines.length - 1] === "") lines.pop();
|
|
7725
|
+
if (lines.length === 0 || lines.length === 1 && lines[0] === "") return [];
|
|
7726
|
+
return lines.map((line) => line.split(" "));
|
|
7727
|
+
}
|
|
7728
|
+
/** The local-calendar day (the year / month / date stand, the time is
|
|
7729
|
+
* dropped) — the picker's draft stand. */
|
|
7730
|
+
function dateOnly(value) {
|
|
7731
|
+
return new Date(value.getFullYear(), value.getMonth(), value.getDate());
|
|
7732
|
+
}
|
|
7733
|
+
/** The time stand (the hours / minutes / the seconds are not all zero). */
|
|
7734
|
+
function hasTime(value) {
|
|
7735
|
+
return value.getHours() !== 0 || value.getMinutes() !== 0 || value.getSeconds() !== 0;
|
|
7736
|
+
}
|
|
7737
|
+
/** The datetime cell's value (the optional "THH:MM" / "THH:MM:SS" time
|
|
7738
|
+
* part) parsed to the local-calendar Date; null when absent / invalid. */
|
|
7739
|
+
function parseCellDateTime(value) {
|
|
7740
|
+
const raw = value === void 0 || value === null ? "" : String(value);
|
|
7741
|
+
if (raw === "") return null;
|
|
7742
|
+
if (raw.includes("T")) {
|
|
7743
|
+
const withSeconds = parse(raw, "yyyy-MM-dd'T'HH:mm:ss", /* @__PURE__ */ new Date());
|
|
7744
|
+
const result = Number.isNaN(withSeconds.getTime()) ? parse(raw, "yyyy-MM-dd'T'HH:mm", /* @__PURE__ */ new Date()) : withSeconds;
|
|
7745
|
+
return Number.isNaN(result.getTime()) ? null : result;
|
|
7746
|
+
}
|
|
7747
|
+
const dateOnlyResult = parse(raw, "yyyy-MM-dd", /* @__PURE__ */ new Date());
|
|
7748
|
+
return Number.isNaN(dateOnlyResult.getTime()) ? null : dateOnlyResult;
|
|
7749
|
+
}
|
|
7750
|
+
/** The datetime's compact label (`dd.MM.yyyy HH:mm` — the seconds stand
|
|
7751
|
+
* only when they are not zero; the midnight zero stands the date only). */
|
|
7752
|
+
function dateTimeLabel(value) {
|
|
7753
|
+
const base = format(value, "dd.MM.yyyy");
|
|
7754
|
+
if (!hasTime(value)) return base;
|
|
7755
|
+
const label = format(value, "HH:mm");
|
|
7756
|
+
return value.getSeconds() !== 0 ? `${base} ${label}:${format(value, "ss")}` : `${base} ${label}`;
|
|
7757
|
+
}
|
|
7758
|
+
/** The datetime's committed wire value (the "YYYY-MM-DD" base; the
|
|
7759
|
+
* "THH:MM" part when the time is not the midnight zero; the ":SS" only
|
|
7760
|
+
* when the seconds are not zero) — the cell's commit and the filter's
|
|
7761
|
+
* value stand the same format (the bridge's match runs over the stored
|
|
7762
|
+
* cell's strings). */
|
|
7763
|
+
function formatCellDateTime(value) {
|
|
7764
|
+
if (value === null) return null;
|
|
7765
|
+
const base = format(value, "yyyy-MM-dd");
|
|
7766
|
+
if (!hasTime(value)) return base;
|
|
7767
|
+
const time = format(value, "HH:mm");
|
|
7768
|
+
return value.getSeconds() !== 0 ? `${base}T${time}:${format(value, "ss")}` : `${base}T${time}`;
|
|
7769
|
+
}
|
|
7770
|
+
/** The form draft over a catalog entry (the name prefills the type's
|
|
7771
|
+
* label — the create's commit takes the input's name). */
|
|
7772
|
+
function emptyColumnForm(entry) {
|
|
7773
|
+
return {
|
|
7774
|
+
key: entry.key,
|
|
7775
|
+
type: entry.type,
|
|
7776
|
+
name: entry.label,
|
|
7777
|
+
numberKind: entry.numberKind,
|
|
7778
|
+
decimals: entry.numberKind === "decimal" ? 2 : 0,
|
|
7779
|
+
thousands: false,
|
|
7780
|
+
prefix: "",
|
|
7781
|
+
suffix: "",
|
|
7782
|
+
allowNegative: true,
|
|
7783
|
+
refKind: entry.refKind,
|
|
7784
|
+
refMany: entry.refMany,
|
|
7785
|
+
refPick: "",
|
|
7786
|
+
newTableName: ""
|
|
7787
|
+
};
|
|
7788
|
+
}
|
|
7496
7789
|
/** The cursor's continuation's retry bound (the `cursor_expired` over
|
|
7497
7790
|
* the concurrent commit stands the fresh snapshot; the bound stands the
|
|
7498
7791
|
* churn's livelock — over it the partial page set stands the lenient
|
|
@@ -7988,21 +8281,17 @@ function ValueInput({ column, operator, value, onChange, refTableData }) {
|
|
|
7988
8281
|
})
|
|
7989
8282
|
]
|
|
7990
8283
|
});
|
|
7991
|
-
case "date": return /* @__PURE__ */ jsx(
|
|
7992
|
-
type: "date",
|
|
7993
|
-
size: "sm",
|
|
8284
|
+
case "date": return /* @__PURE__ */ jsx(DatePicker, {
|
|
7994
8285
|
"data-slot": "docblocks/filter-value",
|
|
7995
|
-
className: "min-w-0 flex-1
|
|
7996
|
-
value:
|
|
7997
|
-
|
|
8286
|
+
className: "h-8 min-w-0 flex-1 px-2 py-0.5",
|
|
8287
|
+
value: parseCellDateTime(value),
|
|
8288
|
+
onSelect: (date) => onChange(formatCellDateTime(date) ?? void 0)
|
|
7998
8289
|
});
|
|
7999
|
-
case "datetime": return /* @__PURE__ */ jsx(
|
|
8000
|
-
type: "datetime-local",
|
|
8001
|
-
size: "sm",
|
|
8290
|
+
case "datetime": return /* @__PURE__ */ jsx(DateTimePicker, {
|
|
8002
8291
|
"data-slot": "docblocks/filter-value",
|
|
8003
|
-
className: "min-w-0 flex-1
|
|
8004
|
-
value:
|
|
8005
|
-
|
|
8292
|
+
className: "h-8 min-w-0 flex-1 px-2 py-0.5",
|
|
8293
|
+
value: parseCellDateTime(value),
|
|
8294
|
+
onSelect: (date) => onChange(formatCellDateTime(date) ?? void 0)
|
|
8006
8295
|
});
|
|
8007
8296
|
case "enum":
|
|
8008
8297
|
case "row-link": {
|
|
@@ -9152,151 +9441,6 @@ function useDatabaseTable(bridge, tableId, filter) {
|
|
|
9152
9441
|
};
|
|
9153
9442
|
}
|
|
9154
9443
|
//#endregion
|
|
9155
|
-
//#region src/database/grid/utils.ts
|
|
9156
|
-
/** The database grid's pure helpers: the visible-column derivation, the
|
|
9157
|
-
* number column's display attributes / input step, the cell's selection
|
|
9158
|
-
* key, and the date/datetime value parsing + labels. */
|
|
9159
|
-
/** The full known id order: explicit ids first, then new schema columns. */
|
|
9160
|
-
function normalizeColumnOrder(columns, columnOrder) {
|
|
9161
|
-
const byId = new Map((columns ?? []).map((column) => [column.id, column]));
|
|
9162
|
-
const ordered = [];
|
|
9163
|
-
for (const id of columnOrder ?? []) {
|
|
9164
|
-
if (!byId.has(id) || ordered.includes(id)) continue;
|
|
9165
|
-
ordered.push(id);
|
|
9166
|
-
byId.delete(id);
|
|
9167
|
-
}
|
|
9168
|
-
for (const column of byId.values()) ordered.push(column.id);
|
|
9169
|
-
return ordered;
|
|
9170
|
-
}
|
|
9171
|
-
/** The block's visible columns: the full order minus the hidden ids. */
|
|
9172
|
-
function visibleColumns(columns, columnOrder, hiddenColumns) {
|
|
9173
|
-
const byId = new Map((columns ?? []).map((column) => [column.id, column]));
|
|
9174
|
-
const hidden = new Set(hiddenColumns ?? []);
|
|
9175
|
-
return normalizeColumnOrder(columns, columnOrder).flatMap((id) => {
|
|
9176
|
-
const column = byId.get(id);
|
|
9177
|
-
return column === void 0 || hidden.has(id) ? [] : [column];
|
|
9178
|
-
});
|
|
9179
|
-
}
|
|
9180
|
-
/** One immutable list move; an invalid or identity move returns the input. */
|
|
9181
|
-
function reorderItems(items, fromIndex, toIndex) {
|
|
9182
|
-
if (fromIndex === toIndex || fromIndex < 0 || toIndex < 0 || fromIndex >= items.length || toIndex >= items.length) return items;
|
|
9183
|
-
const next = [...items];
|
|
9184
|
-
const [moved] = next.splice(fromIndex, 1);
|
|
9185
|
-
if (moved === void 0) return items;
|
|
9186
|
-
next.splice(toIndex, 0, moved);
|
|
9187
|
-
return next;
|
|
9188
|
-
}
|
|
9189
|
-
/** A visible header drop mapped into the full order without moving hidden ids over an anchor. */
|
|
9190
|
-
function moveVisibleColumn(columns, columnOrder, hiddenColumns, columnId, toIndex) {
|
|
9191
|
-
const fullOrder = normalizeColumnOrder(columns, columnOrder);
|
|
9192
|
-
const visibleIds = visibleColumns(columns, columnOrder, hiddenColumns).map((column) => column.id);
|
|
9193
|
-
const stationary = visibleIds.filter((id) => id !== columnId);
|
|
9194
|
-
if (stationary.length === visibleIds.length || toIndex < 0 || toIndex > stationary.length) return fullOrder;
|
|
9195
|
-
const next = fullOrder.filter((id) => id !== columnId);
|
|
9196
|
-
const targetId = stationary[toIndex];
|
|
9197
|
-
if (targetId !== void 0) {
|
|
9198
|
-
next.splice(next.indexOf(targetId), 0, columnId);
|
|
9199
|
-
return next;
|
|
9200
|
-
}
|
|
9201
|
-
const anchorId = stationary.at(-1);
|
|
9202
|
-
if (anchorId === void 0) return fullOrder;
|
|
9203
|
-
next.splice(next.indexOf(anchorId) + 1, 0, columnId);
|
|
9204
|
-
return next;
|
|
9205
|
-
}
|
|
9206
|
-
/** The number input's step stand: the explicit `decimals` stands the
|
|
9207
|
-
* `10^-decimals` step; the absent stand follows the integer types only
|
|
9208
|
-
* (the float types stand no step — the 0.5 must be typeable). */
|
|
9209
|
-
function numberStepFor(column) {
|
|
9210
|
-
if (column.decimals !== void 0) {
|
|
9211
|
-
const decimals = Math.max(0, Math.min(10, Math.trunc(Number(column.decimals)) || 0));
|
|
9212
|
-
return decimals === 0 ? "1" : String(10 ** -decimals);
|
|
9213
|
-
}
|
|
9214
|
-
const base = column.type.replace(/\[\]$/, "").trim();
|
|
9215
|
-
return base === "integer" || base === "int" || base === "smallint" || base === "bigint" ? "1" : void 0;
|
|
9216
|
-
}
|
|
9217
|
-
/** The display's attributes stand: the explicit `decimals` (or the
|
|
9218
|
-
* integer stand) takes the fixed-digit format; the float types without
|
|
9219
|
-
* the explicit digits stand the RAW value (no rounding — the display
|
|
9220
|
-
* must not lose the value's own stand). */
|
|
9221
|
-
function numberDisplayAttrs(column) {
|
|
9222
|
-
const base = column.type.replace(/\[\]$/, "").trim();
|
|
9223
|
-
return {
|
|
9224
|
-
decimals: column.decimals !== void 0 || base === "integer" || base === "int" || base === "smallint" || base === "bigint" || base === "number" ? column.decimals ?? 0 : null,
|
|
9225
|
-
thousands: column.thousands,
|
|
9226
|
-
prefix: column.prefix,
|
|
9227
|
-
suffix: column.suffix
|
|
9228
|
-
};
|
|
9229
|
-
}
|
|
9230
|
-
/** The cell's selection/editing key (the row id + the column id). */
|
|
9231
|
-
const cellKeyOf = (rowId, colId) => `${rowId}\u0000${colId}`;
|
|
9232
|
-
/** The cell's clipboard text: the TSV's flat stand (the tab / the
|
|
9233
|
-
* newline stand the space — the TSV's shape stands; the row-link's array
|
|
9234
|
-
* joins over the comma — the label's stand, never the id). */
|
|
9235
|
-
function cellTextOf(value) {
|
|
9236
|
-
if (value === void 0 || value === null) return "";
|
|
9237
|
-
if (Array.isArray(value)) return value.map((item) => cellTextOf(item)).join(",");
|
|
9238
|
-
return String(value).replace(/[\t\n\r]/g, " ");
|
|
9239
|
-
}
|
|
9240
|
-
/** The TSV's parse (the clipboard's plain text over the grid's paste):
|
|
9241
|
-
* the rows over the newline (the carriage return stands the newline),
|
|
9242
|
-
* the cells over the tab; the trailing empty row stands no stand (the
|
|
9243
|
-
* clipboard's trailing newline). An empty text stands no grid. */
|
|
9244
|
-
function parseClipboardTsv(text) {
|
|
9245
|
-
const lines = text.replace(/\r\n?/g, "\n").split("\n");
|
|
9246
|
-
if (lines.length > 1 && lines[lines.length - 1] === "") lines.pop();
|
|
9247
|
-
if (lines.length === 0 || lines.length === 1 && lines[0] === "") return [];
|
|
9248
|
-
return lines.map((line) => line.split(" "));
|
|
9249
|
-
}
|
|
9250
|
-
/** The local-calendar day (the year / month / date stand, the time is
|
|
9251
|
-
* dropped) — the picker's draft stand. */
|
|
9252
|
-
function dateOnly(value) {
|
|
9253
|
-
return new Date(value.getFullYear(), value.getMonth(), value.getDate());
|
|
9254
|
-
}
|
|
9255
|
-
/** The time stand (the hours / minutes / the seconds are not all zero). */
|
|
9256
|
-
function hasTime(value) {
|
|
9257
|
-
return value.getHours() !== 0 || value.getMinutes() !== 0 || value.getSeconds() !== 0;
|
|
9258
|
-
}
|
|
9259
|
-
/** The datetime cell's value (the optional "THH:MM" / "THH:MM:SS" time
|
|
9260
|
-
* part) parsed to the local-calendar Date; null when absent / invalid. */
|
|
9261
|
-
function parseCellDateTime(value) {
|
|
9262
|
-
const raw = value === void 0 || value === null ? "" : String(value);
|
|
9263
|
-
if (raw === "") return null;
|
|
9264
|
-
if (raw.includes("T")) {
|
|
9265
|
-
const withSeconds = parse(raw, "yyyy-MM-dd'T'HH:mm:ss", /* @__PURE__ */ new Date());
|
|
9266
|
-
const result = Number.isNaN(withSeconds.getTime()) ? parse(raw, "yyyy-MM-dd'T'HH:mm", /* @__PURE__ */ new Date()) : withSeconds;
|
|
9267
|
-
return Number.isNaN(result.getTime()) ? null : result;
|
|
9268
|
-
}
|
|
9269
|
-
const dateOnlyResult = parse(raw, "yyyy-MM-dd", /* @__PURE__ */ new Date());
|
|
9270
|
-
return Number.isNaN(dateOnlyResult.getTime()) ? null : dateOnlyResult;
|
|
9271
|
-
}
|
|
9272
|
-
/** The datetime's compact label (`dd.MM.yyyy HH:mm` — the seconds stand
|
|
9273
|
-
* only when they are not zero; the midnight zero stands the date only). */
|
|
9274
|
-
function dateTimeLabel(value) {
|
|
9275
|
-
const base = format(value, "dd.MM.yyyy");
|
|
9276
|
-
if (!hasTime(value)) return base;
|
|
9277
|
-
const label = format(value, "HH:mm");
|
|
9278
|
-
return value.getSeconds() !== 0 ? `${base} ${label}:${format(value, "ss")}` : `${base} ${label}`;
|
|
9279
|
-
}
|
|
9280
|
-
/** The form draft over a catalog entry (the name prefills the type's
|
|
9281
|
-
* label — the create's commit takes the input's name). */
|
|
9282
|
-
function emptyColumnForm(entry) {
|
|
9283
|
-
return {
|
|
9284
|
-
key: entry.key,
|
|
9285
|
-
type: entry.type,
|
|
9286
|
-
name: entry.label,
|
|
9287
|
-
numberKind: entry.numberKind,
|
|
9288
|
-
decimals: entry.numberKind === "decimal" ? 2 : 0,
|
|
9289
|
-
thousands: false,
|
|
9290
|
-
prefix: "",
|
|
9291
|
-
suffix: "",
|
|
9292
|
-
allowNegative: true,
|
|
9293
|
-
refKind: entry.refKind,
|
|
9294
|
-
refMany: entry.refMany,
|
|
9295
|
-
refPick: "",
|
|
9296
|
-
newTableName: ""
|
|
9297
|
-
};
|
|
9298
|
-
}
|
|
9299
|
-
//#endregion
|
|
9300
9444
|
//#region src/database/grid/ColumnManager.tsx
|
|
9301
9445
|
function ColumnRow({ column, hidden, hideDisabled, onToggle, onMove, onDragStart, onDragEnd }) {
|
|
9302
9446
|
const { t } = useTranslation("database");
|
|
@@ -10335,16 +10479,7 @@ function DatabaseCell({ rowId, column, value, revision, rowIndex, colIndex, firs
|
|
|
10335
10479
|
committed.setHours(Number(hours), Number(minutes), Number(seconds));
|
|
10336
10480
|
}
|
|
10337
10481
|
if ((committed?.getTime() ?? null) === (openDateRef.current?.getTime() ?? null)) return;
|
|
10338
|
-
|
|
10339
|
-
if (committed === null) iso = null;
|
|
10340
|
-
else {
|
|
10341
|
-
const base = format(committed, "yyyy-MM-dd");
|
|
10342
|
-
if (!hasTime(committed)) iso = base;
|
|
10343
|
-
else {
|
|
10344
|
-
const time = format(committed, "HH:mm");
|
|
10345
|
-
iso = committed.getSeconds() !== 0 ? `${base}T${time}:${format(committed, "ss")}` : `${base}T${time}`;
|
|
10346
|
-
}
|
|
10347
|
-
}
|
|
10482
|
+
const iso = formatCellDateTime(committed);
|
|
10348
10483
|
if (iso === committedIsoRef.current) return;
|
|
10349
10484
|
committedIsoRef.current = iso;
|
|
10350
10485
|
onChange(iso, openRevisionRef.current);
|
|
@@ -15555,6 +15690,7 @@ function runsOf(node, inherited, raw) {
|
|
|
15555
15690
|
const roots = node.nodeType === Node.DOCUMENT_FRAGMENT_NODE ? Array.from(node.childNodes) : [node];
|
|
15556
15691
|
for (const root of roots) visit(root, raw ? {} : inherited);
|
|
15557
15692
|
if (node.nodeType === Node.TEXT_NODE) return runs;
|
|
15693
|
+
if (node.nodeType === Node.ELEMENT_NODE && node.nodeName.toUpperCase() === "BR") return runs;
|
|
15558
15694
|
return dropEdgeWhitespaceRuns(runs);
|
|
15559
15695
|
}
|
|
15560
15696
|
/** The table's rows (the parser hoists the tr into the implicit tbody). */
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as SelectScrollUpButton, A as parseCellValue, At as CardAction, B as useText, Bt as badgeVariants, C as validateProtocolDescriptor, Ct as PopoverDescription, D as isBridgeErrorCode, Dt as Input, E as isBridgeError, Et as PopoverTrigger, F as useMeta, Ft as CardTitle, G as SegmentSelector, H as useEditorContext, Ht as AlertDescription, I as usePresence, It as Button, J as SelectContent, Jt as Eye, K as ScrollArea, Kt as renderRuns, L as usePresenceSharing, Lt as buttonVariants, M as columnAnnotation, Mt as CardDescription, N as useBlock, Nt as CardFooter, O as toBridgeError, Ot as Checkbox, P as useDoc, Pt as CardHeader, Q as SelectScrollDownButton, R as useSelection, Rt as BareSelect, S as isDatabaseBridge, St as PopoverContent, T as BridgeError, Tt as PopoverTitle, U as DEFAULT_EMBED_SANDBOX, Ut as AlertTitle, V as EditorProvider, Vt as Alert, W as Skeleton, Wt as DocblocksI18nProvider, X as SelectItem, Xt as BookOpen, Y as SelectGroup, Z as SelectLabel, Zt as createMemoryBlobStore, _ as FilterBuilder, _t as DropdownMenuSubTrigger, a as SHAPE_FONT_STACKS, at as DropdownMenuCheckboxItem, b as BASELINE_CAPABILITIES, bt as Popover, ct as DropdownMenuItem, d as insertNative, dt as DropdownMenuRadioGroup, et as SelectSeparator, f as mdToBlocks, ft as DropdownMenuRadioItem, g as newMutationContext, gt as DropdownMenuSubContent, h as cellValueEqual, ht as DropdownMenuSub, i as SHAPE_FONT_OPTIONS, it as DropdownMenu, j as TEXT_TYPES, jt as CardContent, k as conditionMatches, kt as Card, l as markToggleAction, lt as DropdownMenuLabel, m as useDatabaseTable, mt as DropdownMenuShortcut, nt as SelectValue, ot as DropdownMenuContent, p as GridBody, pt as DropdownMenuSeparator, q as Select, qt as Pen, rt as Label, s as FORMAT_PALETTE, st as DropdownMenuGroup, t as Editor, tt as SelectTrigger, u as htmlToBlocks, ut as DropdownMenuPortal, v as emptyFilter, vt as DropdownMenuTrigger, w as BRIDGE_ERROR_CODES, wt as PopoverHeader, x as PROTOCOL_VERSION, xt as PopoverAnchor, y as filterIsComplete, yt as Separator, z as useSelectionView, zt as Badge } from "./Editor-
|
|
1
|
+
import { $ as SelectScrollUpButton, A as parseCellValue, At as CardAction, B as useText, Bt as badgeVariants, C as validateProtocolDescriptor, Ct as PopoverDescription, D as isBridgeErrorCode, Dt as Input, E as isBridgeError, Et as PopoverTrigger, F as useMeta, Ft as CardTitle, G as SegmentSelector, H as useEditorContext, Ht as AlertDescription, I as usePresence, It as Button, J as SelectContent, Jt as Eye, K as ScrollArea, Kt as renderRuns, L as usePresenceSharing, Lt as buttonVariants, M as columnAnnotation, Mt as CardDescription, N as useBlock, Nt as CardFooter, O as toBridgeError, Ot as Checkbox, P as useDoc, Pt as CardHeader, Q as SelectScrollDownButton, R as useSelection, Rt as BareSelect, S as isDatabaseBridge, St as PopoverContent, T as BridgeError, Tt as PopoverTitle, U as DEFAULT_EMBED_SANDBOX, Ut as AlertTitle, V as EditorProvider, Vt as Alert, W as Skeleton, Wt as DocblocksI18nProvider, X as SelectItem, Xt as BookOpen, Y as SelectGroup, Z as SelectLabel, Zt as createMemoryBlobStore, _ as FilterBuilder, _t as DropdownMenuSubTrigger, a as SHAPE_FONT_STACKS, at as DropdownMenuCheckboxItem, b as BASELINE_CAPABILITIES, bt as Popover, ct as DropdownMenuItem, d as insertNative, dt as DropdownMenuRadioGroup, et as SelectSeparator, f as mdToBlocks, ft as DropdownMenuRadioItem, g as newMutationContext, gt as DropdownMenuSubContent, h as cellValueEqual, ht as DropdownMenuSub, i as SHAPE_FONT_OPTIONS, it as DropdownMenu, j as TEXT_TYPES, jt as CardContent, k as conditionMatches, kt as Card, l as markToggleAction, lt as DropdownMenuLabel, m as useDatabaseTable, mt as DropdownMenuShortcut, nt as SelectValue, ot as DropdownMenuContent, p as GridBody, pt as DropdownMenuSeparator, q as Select, qt as Pen, rt as Label, s as FORMAT_PALETTE, st as DropdownMenuGroup, t as Editor, tt as SelectTrigger, u as htmlToBlocks, ut as DropdownMenuPortal, v as emptyFilter, vt as DropdownMenuTrigger, w as BRIDGE_ERROR_CODES, wt as PopoverHeader, x as PROTOCOL_VERSION, xt as PopoverAnchor, y as filterIsComplete, yt as Separator, z as useSelectionView, zt as Badge } from "./Editor-ByjnrYiw.mjs";
|
|
2
2
|
import { a as preventDefault, s as cn } from "./constants-D8PSgkwi.mjs";
|
|
3
3
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
4
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
package/dist/mermaid/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { G as SegmentSelector, Gt as INLINE_CODE_CLASS, H as useEditorContext, Ht as AlertDescription, Jt as Eye, Ut as AlertTitle, Vt as Alert, W as Skeleton, Yt as CodeXml, c as textOf, n as childrenSlot, o as TextBlock, r as CodeHeader } from "../Editor-
|
|
1
|
+
import { G as SegmentSelector, Gt as INLINE_CODE_CLASS, H as useEditorContext, Ht as AlertDescription, Jt as Eye, Ut as AlertTitle, Vt as Alert, W as Skeleton, Yt as CodeXml, c as textOf, n as childrenSlot, o as TextBlock, r as CodeHeader } from "../Editor-ByjnrYiw.mjs";
|
|
2
2
|
import { f as LoaderCircle, l as TriangleAlert } from "../constants-D8PSgkwi.mjs";
|
|
3
3
|
import { useEffect, useRef, useState } from "react";
|
|
4
4
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
package/package.json
CHANGED