@almadar/ui 5.161.0 → 5.163.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.
- package/dist/avl/index.cjs +231 -72
- package/dist/avl/index.js +231 -72
- package/dist/components/index.cjs +233 -72
- package/dist/components/index.d.cts +26 -7
- package/dist/components/index.d.ts +26 -7
- package/dist/components/index.js +233 -72
- package/dist/hooks/index.cjs +2 -0
- package/dist/hooks/index.js +2 -0
- package/dist/locales/index.cjs +6 -0
- package/dist/locales/index.js +6 -0
- package/dist/providers/index.cjs +231 -72
- package/dist/providers/index.js +231 -72
- package/dist/runtime/index.cjs +231 -72
- package/dist/runtime/index.js +231 -72
- package/locales/ar.json +8 -6
- package/locales/en.json +3 -1
- package/locales/sl.json +3 -1
- package/package.json +4 -4
package/dist/runtime/index.cjs
CHANGED
|
@@ -32643,6 +32643,33 @@ var init_Lightbox = __esm({
|
|
|
32643
32643
|
Lightbox.displayName = "Lightbox";
|
|
32644
32644
|
}
|
|
32645
32645
|
});
|
|
32646
|
+
|
|
32647
|
+
// lib/relationLabel.ts
|
|
32648
|
+
function relationLabel(value) {
|
|
32649
|
+
if (value === null || typeof value !== "object" || Array.isArray(value) || value instanceof Date)
|
|
32650
|
+
return null;
|
|
32651
|
+
for (const key of ["name", "title", "label"]) {
|
|
32652
|
+
const candidate = value[key];
|
|
32653
|
+
if (typeof candidate === "string" && candidate !== "") return candidate;
|
|
32654
|
+
}
|
|
32655
|
+
const id = value.id;
|
|
32656
|
+
return id !== void 0 && id !== null ? String(id) : null;
|
|
32657
|
+
}
|
|
32658
|
+
function relationDisplayLabels(value, options) {
|
|
32659
|
+
if (value === void 0 || value === null || value === "") return [];
|
|
32660
|
+
if (Array.isArray(value)) {
|
|
32661
|
+
return value.flatMap((item) => relationDisplayLabels(item, options));
|
|
32662
|
+
}
|
|
32663
|
+
const hydrated = relationLabel(value);
|
|
32664
|
+
if (hydrated !== null) return [hydrated];
|
|
32665
|
+
const raw = String(value);
|
|
32666
|
+
const match = options?.find((opt) => opt.value === raw);
|
|
32667
|
+
return [match ? match.label : raw];
|
|
32668
|
+
}
|
|
32669
|
+
var init_relationLabel = __esm({
|
|
32670
|
+
"lib/relationLabel.ts"() {
|
|
32671
|
+
}
|
|
32672
|
+
});
|
|
32646
32673
|
function renderIconInput3(icon, props) {
|
|
32647
32674
|
return typeof icon === "string" ? /* @__PURE__ */ jsxRuntime.jsx(Icon, { name: icon, ...props }) : /* @__PURE__ */ jsxRuntime.jsx(Icon, { icon, ...props });
|
|
32648
32675
|
}
|
|
@@ -32960,6 +32987,7 @@ var init_TableView = __esm({
|
|
|
32960
32987
|
"use client";
|
|
32961
32988
|
init_cn();
|
|
32962
32989
|
init_format();
|
|
32990
|
+
init_relationLabel();
|
|
32963
32991
|
init_getNestedValue();
|
|
32964
32992
|
init_useEventBus();
|
|
32965
32993
|
init_Box();
|
|
@@ -32973,7 +33001,13 @@ var init_TableView = __esm({
|
|
|
32973
33001
|
init_Menu();
|
|
32974
33002
|
init_useDataDnd();
|
|
32975
33003
|
tableViewLog = logger.createLogger("almadar:ui:table-view");
|
|
32976
|
-
formatCell = (value, format) =>
|
|
33004
|
+
formatCell = (value, format) => {
|
|
33005
|
+
if (value !== null && value !== void 0 && typeof value === "object" && !(value instanceof Date)) {
|
|
33006
|
+
const labels = relationDisplayLabels(value);
|
|
33007
|
+
if (labels.length > 0) return labels.join(", ");
|
|
33008
|
+
}
|
|
33009
|
+
return formatValue(value, format);
|
|
33010
|
+
};
|
|
32977
33011
|
MAX_MEASURED_COL_CH = 32;
|
|
32978
33012
|
BADGE_CHROME_CH = 4;
|
|
32979
33013
|
alignClass = {
|
|
@@ -36450,6 +36484,13 @@ var init_RichTextEditor = __esm({
|
|
|
36450
36484
|
document.execCommand("createLink", false, safe);
|
|
36451
36485
|
afterEdit();
|
|
36452
36486
|
}, [afterEdit, t, toolbar.link]);
|
|
36487
|
+
const execImage = React85.useCallback(() => {
|
|
36488
|
+
const url = window.prompt(t("richTextEditor.imagePrompt"));
|
|
36489
|
+
if (!url) return;
|
|
36490
|
+
const safe = safeUrl(url, ["http://", "https://", "data:image/"]) ?? `https://${url}`;
|
|
36491
|
+
document.execCommand("insertImage", false, safe);
|
|
36492
|
+
afterEdit();
|
|
36493
|
+
}, [afterEdit, t]);
|
|
36453
36494
|
const execRule = React85.useCallback(() => {
|
|
36454
36495
|
document.execCommand("insertHorizontalRule", false);
|
|
36455
36496
|
afterEdit();
|
|
@@ -36487,6 +36528,7 @@ var init_RichTextEditor = __esm({
|
|
|
36487
36528
|
/* @__PURE__ */ jsxRuntime.jsx(ToolbarButton, { icon: LucideIcons2.Quote, label: t("richTextEditor.quote"), active: toolbar.block === "blockquote", onExec: () => execBlock("blockquote") }),
|
|
36488
36529
|
/* @__PURE__ */ jsxRuntime.jsx(ToolbarButton, { icon: LucideIcons2.Code, label: t("richTextEditor.code"), active: toolbar.block === "pre", onExec: () => execBlock("pre") }),
|
|
36489
36530
|
/* @__PURE__ */ jsxRuntime.jsx(ToolbarButton, { icon: LucideIcons2.Link, label: toolbar.link ? t("richTextEditor.removeLink") : t("richTextEditor.link"), active: toolbar.link, onExec: execLink }),
|
|
36531
|
+
/* @__PURE__ */ jsxRuntime.jsx(ToolbarButton, { icon: LucideIcons2.Image, label: t("richTextEditor.image"), onExec: execImage }),
|
|
36490
36532
|
/* @__PURE__ */ jsxRuntime.jsx(ToolbarButton, { icon: LucideIcons2.Minus, label: t("richTextEditor.divider"), onExec: execRule })
|
|
36491
36533
|
]
|
|
36492
36534
|
}
|
|
@@ -36524,9 +36566,11 @@ function renderIconInput4(icon, props) {
|
|
|
36524
36566
|
return typeof icon === "string" ? /* @__PURE__ */ jsxRuntime.jsx(Icon, { name: icon, ...props }) : /* @__PURE__ */ jsxRuntime.jsx(Icon, { icon, ...props });
|
|
36525
36567
|
}
|
|
36526
36568
|
function DocumentPanel({
|
|
36527
|
-
|
|
36569
|
+
id,
|
|
36528
36570
|
title,
|
|
36529
36571
|
subtitle,
|
|
36572
|
+
coverImage,
|
|
36573
|
+
icon,
|
|
36530
36574
|
value,
|
|
36531
36575
|
actions,
|
|
36532
36576
|
maxInlineActions,
|
|
@@ -36544,14 +36588,14 @@ function DocumentPanel({
|
|
|
36544
36588
|
const eventBus = useEventBus();
|
|
36545
36589
|
const { t } = hooks.useTranslate();
|
|
36546
36590
|
const [titleDraft, setTitleDraft] = React85.useState(null);
|
|
36547
|
-
const recordId =
|
|
36591
|
+
const recordId = id ?? "";
|
|
36548
36592
|
const actionDefs = actions ?? [];
|
|
36549
36593
|
const inlineCap = Math.min(maxInlineActions ?? 1, 1);
|
|
36550
36594
|
const inlineActions = actionDefs.filter((a) => a.variant === "primary").slice(0, inlineCap);
|
|
36551
36595
|
const menuActions = actionDefs.filter((a) => !inlineActions.includes(a));
|
|
36552
36596
|
const fireAction = (action) => {
|
|
36553
36597
|
if (!action.event) return;
|
|
36554
|
-
eventBus.emit(`UI:${action.event}`, { id: recordId,
|
|
36598
|
+
eventBus.emit(`UI:${action.event}`, { id: recordId, title: title ?? "" });
|
|
36555
36599
|
};
|
|
36556
36600
|
const commitTitle = () => {
|
|
36557
36601
|
if (!titleCommitEvent) return;
|
|
@@ -36602,62 +36646,74 @@ function DocumentPanel({
|
|
|
36602
36646
|
const emitWithId = (event) => () => {
|
|
36603
36647
|
if (event) eventBus.emit(`UI:${event}`, { id: recordId });
|
|
36604
36648
|
};
|
|
36605
|
-
return /* @__PURE__ */ jsxRuntime.
|
|
36606
|
-
/* @__PURE__ */ jsxRuntime.
|
|
36607
|
-
|
|
36608
|
-
titleNode,
|
|
36609
|
-
subtitle ? /* @__PURE__ */ jsxRuntime.jsx(Typography, { variant: "small", color: "secondary", children: subtitle }) : null
|
|
36610
|
-
] }),
|
|
36611
|
-
/* @__PURE__ */ jsxRuntime.jsx(HStack, { gap: "xs", className: "flex-shrink-0 pt-1 items-center", children: editing ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
36612
|
-
/* @__PURE__ */ jsxRuntime.jsx(Typography, { variant: "caption", color: "muted", className: "hidden sm:block", children: autosaveHint ?? (t("documentPanel.autosaveHint") || "") }),
|
|
36613
|
-
/* @__PURE__ */ jsxRuntime.jsx(Button, { variant: "primary", size: "sm", onClick: emitWithId(doneEvent), "data-testid": "document-done", children: doneLabel ?? (t("documentPanel.done") || "Done") })
|
|
36614
|
-
] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
36615
|
-
editEvent && /* @__PURE__ */ jsxRuntime.jsxs(Button, { variant: "ghost", size: "sm", onClick: emitWithId(editEvent), "data-testid": "document-edit", children: [
|
|
36616
|
-
/* @__PURE__ */ jsxRuntime.jsx(Icon, { name: "edit", size: "xs", className: "mr-1" }),
|
|
36617
|
-
editLabel ?? (t("documentPanel.edit") || "Edit")
|
|
36618
|
-
] }),
|
|
36619
|
-
inlineActions.map((action, idx) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
36620
|
-
Button,
|
|
36621
|
-
{
|
|
36622
|
-
variant: "primary",
|
|
36623
|
-
size: "sm",
|
|
36624
|
-
onClick: () => fireAction(action),
|
|
36625
|
-
"data-testid": `action-${action.event}`,
|
|
36626
|
-
children: [
|
|
36627
|
-
action.icon && renderIconInput4(action.icon, { size: "xs", className: "mr-1" }),
|
|
36628
|
-
action.label
|
|
36629
|
-
]
|
|
36630
|
-
},
|
|
36631
|
-
idx
|
|
36632
|
-
)),
|
|
36633
|
-
menuActions.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
36634
|
-
Menu,
|
|
36635
|
-
{
|
|
36636
|
-
position: "bottom-end",
|
|
36637
|
-
trigger: /* @__PURE__ */ jsxRuntime.jsx(Button, { variant: "ghost", size: "sm", "aria-label": t("common.actions"), "data-testid": "action-overflow", children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { name: "more-horizontal", size: "xs" }) }),
|
|
36638
|
-
items: menuActions.map((action) => ({
|
|
36639
|
-
label: action.label,
|
|
36640
|
-
icon: action.icon,
|
|
36641
|
-
variant: action.variant === "danger" ? "danger" : "default",
|
|
36642
|
-
onClick: () => fireAction(action)
|
|
36643
|
-
}))
|
|
36644
|
-
}
|
|
36645
|
-
)
|
|
36646
|
-
] }) })
|
|
36647
|
-
] }),
|
|
36648
|
-
editing ? /* @__PURE__ */ jsxRuntime.jsx(RichTextEditor, { value, changeEvent: contentChangeEvent, placeholder }) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
36649
|
-
Box,
|
|
36649
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Card, { variant: "elevated", className: cn("w-full overflow-hidden", className), children: [
|
|
36650
|
+
coverImage ? /* @__PURE__ */ jsxRuntime.jsx(Box, { className: "h-44 w-full sm:h-52", "data-testid": "document-cover", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
36651
|
+
"img",
|
|
36650
36652
|
{
|
|
36651
|
-
|
|
36652
|
-
|
|
36653
|
-
|
|
36654
|
-
|
|
36655
|
-
|
|
36656
|
-
|
|
36657
|
-
|
|
36658
|
-
|
|
36659
|
-
|
|
36660
|
-
|
|
36653
|
+
src: coverImage,
|
|
36654
|
+
alt: "",
|
|
36655
|
+
"aria-hidden": "true",
|
|
36656
|
+
className: "h-full w-full object-cover"
|
|
36657
|
+
}
|
|
36658
|
+
) }) : null,
|
|
36659
|
+
/* @__PURE__ */ jsxRuntime.jsxs(VStack, { gap: "sm", className: "p-6 sm:p-8", children: [
|
|
36660
|
+
/* @__PURE__ */ jsxRuntime.jsxs(HStack, { gap: "sm", className: "justify-between items-start", children: [
|
|
36661
|
+
/* @__PURE__ */ jsxRuntime.jsxs(VStack, { gap: "xs", className: "flex-1 min-w-0", children: [
|
|
36662
|
+
icon ? /* @__PURE__ */ jsxRuntime.jsx(Box, { className: "text-muted-foreground", "data-testid": "document-icon", children: renderIconInput4(icon, { size: "lg" }) }) : null,
|
|
36663
|
+
titleNode,
|
|
36664
|
+
subtitle ? /* @__PURE__ */ jsxRuntime.jsx(Typography, { variant: "small", color: "secondary", children: subtitle }) : null
|
|
36665
|
+
] }),
|
|
36666
|
+
/* @__PURE__ */ jsxRuntime.jsx(HStack, { gap: "xs", className: "flex-shrink-0 pt-1 items-center", children: editing ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
36667
|
+
/* @__PURE__ */ jsxRuntime.jsx(Typography, { variant: "caption", color: "muted", className: "hidden sm:block", children: autosaveHint ?? (t("documentPanel.autosaveHint") || "") }),
|
|
36668
|
+
/* @__PURE__ */ jsxRuntime.jsx(Button, { variant: "primary", size: "sm", onClick: emitWithId(doneEvent), "data-testid": "document-done", children: doneLabel ?? (t("documentPanel.done") || "Done") })
|
|
36669
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
36670
|
+
editEvent && /* @__PURE__ */ jsxRuntime.jsxs(Button, { variant: "ghost", size: "sm", onClick: emitWithId(editEvent), "data-testid": "document-edit", children: [
|
|
36671
|
+
/* @__PURE__ */ jsxRuntime.jsx(Icon, { name: "edit", size: "xs", className: "mr-1" }),
|
|
36672
|
+
editLabel ?? (t("documentPanel.edit") || "Edit")
|
|
36673
|
+
] }),
|
|
36674
|
+
inlineActions.map((action, idx) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
36675
|
+
Button,
|
|
36676
|
+
{
|
|
36677
|
+
variant: "primary",
|
|
36678
|
+
size: "sm",
|
|
36679
|
+
onClick: () => fireAction(action),
|
|
36680
|
+
"data-testid": `action-${action.event}`,
|
|
36681
|
+
children: [
|
|
36682
|
+
action.icon && renderIconInput4(action.icon, { size: "xs", className: "mr-1" }),
|
|
36683
|
+
action.label
|
|
36684
|
+
]
|
|
36685
|
+
},
|
|
36686
|
+
idx
|
|
36687
|
+
)),
|
|
36688
|
+
menuActions.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
36689
|
+
Menu,
|
|
36690
|
+
{
|
|
36691
|
+
position: "bottom-end",
|
|
36692
|
+
trigger: /* @__PURE__ */ jsxRuntime.jsx(Button, { variant: "ghost", size: "sm", "aria-label": t("common.actions"), "data-testid": "action-overflow", children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { name: "more-horizontal", size: "xs" }) }),
|
|
36693
|
+
items: menuActions.map((action) => ({
|
|
36694
|
+
label: action.label,
|
|
36695
|
+
icon: action.icon,
|
|
36696
|
+
variant: action.variant === "danger" ? "danger" : "default",
|
|
36697
|
+
onClick: () => fireAction(action)
|
|
36698
|
+
}))
|
|
36699
|
+
}
|
|
36700
|
+
)
|
|
36701
|
+
] }) })
|
|
36702
|
+
] }),
|
|
36703
|
+
editing ? /* @__PURE__ */ jsxRuntime.jsx(RichTextEditor, { value, changeEvent: contentChangeEvent, placeholder }) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
36704
|
+
Box,
|
|
36705
|
+
{
|
|
36706
|
+
onClick: emitWithId(editEvent),
|
|
36707
|
+
className: cn(
|
|
36708
|
+
"rounded-md px-1 -mx-1 min-h-[16rem]",
|
|
36709
|
+
editEvent && "cursor-text transition-colors hover:bg-muted/30"
|
|
36710
|
+
),
|
|
36711
|
+
"data-testid": "document-body",
|
|
36712
|
+
children: value && value !== "" ? /* @__PURE__ */ jsxRuntime.jsx(RichTextEditor, { value, readOnly: true }) : /* @__PURE__ */ jsxRuntime.jsx(Typography, { variant: "body", color: "muted", children: placeholder ?? (t("documentPanel.placeholder") || "") })
|
|
36713
|
+
}
|
|
36714
|
+
)
|
|
36715
|
+
] })
|
|
36716
|
+
] });
|
|
36661
36717
|
}
|
|
36662
36718
|
var init_DocumentPanel = __esm({
|
|
36663
36719
|
"components/core/molecules/DocumentPanel.tsx"() {
|
|
@@ -36681,17 +36737,16 @@ function renderIconInput5(icon, props) {
|
|
|
36681
36737
|
function fieldName(field) {
|
|
36682
36738
|
return field.name ?? field.key ?? "";
|
|
36683
36739
|
}
|
|
36684
|
-
function
|
|
36685
|
-
if (value
|
|
36686
|
-
|
|
36687
|
-
|
|
36688
|
-
if (typeof candidate === "string" && candidate !== "") return candidate;
|
|
36740
|
+
function relationId(value) {
|
|
36741
|
+
if (value !== null && typeof value === "object" && !Array.isArray(value) && !(value instanceof Date)) {
|
|
36742
|
+
const id = value.id;
|
|
36743
|
+
if (id !== void 0 && id !== null) return String(id);
|
|
36689
36744
|
}
|
|
36690
|
-
|
|
36691
|
-
return id !== void 0 && id !== null ? String(id) : null;
|
|
36745
|
+
return String(value);
|
|
36692
36746
|
}
|
|
36693
36747
|
function fieldKind(field, value) {
|
|
36694
36748
|
if (field.kind) return field.kind;
|
|
36749
|
+
if (field.type === "image") return "image";
|
|
36695
36750
|
if (field.options && field.options.length > 0) return "select";
|
|
36696
36751
|
if (typeof value === "boolean" || field.format === "boolean") return "boolean";
|
|
36697
36752
|
if (Array.isArray(value) || relationLabel(value ?? null) !== null) return "readonly";
|
|
@@ -36701,6 +36756,7 @@ function DocumentDetails({
|
|
|
36701
36756
|
entity,
|
|
36702
36757
|
fields,
|
|
36703
36758
|
metaCommitEvent,
|
|
36759
|
+
relationEvent,
|
|
36704
36760
|
title,
|
|
36705
36761
|
className
|
|
36706
36762
|
}) {
|
|
@@ -36715,11 +36771,51 @@ function DocumentDetails({
|
|
|
36715
36771
|
if (!metaCommitEvent || next === current) return;
|
|
36716
36772
|
eventBus.emit(`UI:${metaCommitEvent}`, { id: recordId, patch: { id: recordId, [name]: next } });
|
|
36717
36773
|
};
|
|
36774
|
+
const relationChip = (item, name, key) => {
|
|
36775
|
+
const label = relationLabel(item) ?? humanizeEnumValue(String(item));
|
|
36776
|
+
if (!relationEvent) {
|
|
36777
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Badge, { variant: "default", children: label }, key);
|
|
36778
|
+
}
|
|
36779
|
+
const emitClick = () => eventBus.emit(`UI:${relationEvent}`, { field: name, id: relationId(item), name: label });
|
|
36780
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
36781
|
+
Badge,
|
|
36782
|
+
{
|
|
36783
|
+
variant: "default",
|
|
36784
|
+
role: "button",
|
|
36785
|
+
tabIndex: 0,
|
|
36786
|
+
className: "cursor-pointer transition-colors hover:bg-accent",
|
|
36787
|
+
onClick: emitClick,
|
|
36788
|
+
onKeyDown: (e) => {
|
|
36789
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
36790
|
+
e.preventDefault();
|
|
36791
|
+
emitClick();
|
|
36792
|
+
}
|
|
36793
|
+
},
|
|
36794
|
+
"data-testid": `relation-chip-${name}`,
|
|
36795
|
+
children: label
|
|
36796
|
+
},
|
|
36797
|
+
key
|
|
36798
|
+
);
|
|
36799
|
+
};
|
|
36718
36800
|
const renderValue = (field) => {
|
|
36719
36801
|
const name = fieldName(field);
|
|
36720
36802
|
const raw = getNestedValue(entity ?? {}, name);
|
|
36721
36803
|
const kind = fieldKind(field, raw);
|
|
36722
36804
|
const label = field.label ?? field.header ?? humanizeFieldName(name);
|
|
36805
|
+
if (kind === "image") {
|
|
36806
|
+
const url = typeof raw === "string" ? raw : "";
|
|
36807
|
+
if (!url) return /* @__PURE__ */ jsxRuntime.jsx(Typography, { variant: "small", color: "secondary", children: "\u2014" });
|
|
36808
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
36809
|
+
"img",
|
|
36810
|
+
{
|
|
36811
|
+
src: url,
|
|
36812
|
+
alt: label,
|
|
36813
|
+
loading: "lazy",
|
|
36814
|
+
className: "max-h-32 w-full rounded-md border border-border object-cover",
|
|
36815
|
+
"data-testid": `document-property-image-${name}`
|
|
36816
|
+
}
|
|
36817
|
+
);
|
|
36818
|
+
}
|
|
36723
36819
|
if (kind === "boolean") {
|
|
36724
36820
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
36725
36821
|
Switch,
|
|
@@ -36749,9 +36845,12 @@ function DocumentDetails({
|
|
|
36749
36845
|
if (raw.length === 0) {
|
|
36750
36846
|
return /* @__PURE__ */ jsxRuntime.jsx(Typography, { variant: "small", color: "secondary", children: "\u2014" });
|
|
36751
36847
|
}
|
|
36752
|
-
return /* @__PURE__ */ jsxRuntime.jsx(HStack, { gap: "xs", className: "flex-wrap", children: raw.map((item, i) =>
|
|
36848
|
+
return /* @__PURE__ */ jsxRuntime.jsx(HStack, { gap: "xs", className: "flex-wrap", children: raw.map((item, i) => relationChip(item, name, i)) });
|
|
36849
|
+
}
|
|
36850
|
+
if (raw !== void 0 && raw !== null && raw !== "" && relationLabel(raw) !== null) {
|
|
36851
|
+
return relationChip(raw, name);
|
|
36753
36852
|
}
|
|
36754
|
-
const shown2 = raw === void 0 || raw === null || raw === "" ? "\u2014" :
|
|
36853
|
+
const shown2 = raw === void 0 || raw === null || raw === "" ? "\u2014" : formatValue(raw, field.format);
|
|
36755
36854
|
return /* @__PURE__ */ jsxRuntime.jsx(Typography, { variant: "small", className: "break-words", children: shown2 });
|
|
36756
36855
|
}
|
|
36757
36856
|
if (fieldDraft?.name === name) {
|
|
@@ -36820,6 +36919,7 @@ var init_DocumentDetails = __esm({
|
|
|
36820
36919
|
init_cn();
|
|
36821
36920
|
init_format();
|
|
36822
36921
|
init_getNestedValue();
|
|
36922
|
+
init_relationLabel();
|
|
36823
36923
|
init_useEventBus();
|
|
36824
36924
|
init_Box();
|
|
36825
36925
|
init_Stack();
|
|
@@ -41814,7 +41914,18 @@ function renderRichFieldValue(value, fieldName2, fieldType, meta) {
|
|
|
41814
41914
|
if (value === void 0 || value === null) return "\u2014";
|
|
41815
41915
|
const str = String(value);
|
|
41816
41916
|
switch (fieldType) {
|
|
41817
|
-
case "image":
|
|
41917
|
+
case "image": {
|
|
41918
|
+
if (!str) return "\u2014";
|
|
41919
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Box, { className: "mt-1 max-w-full", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
41920
|
+
"img",
|
|
41921
|
+
{
|
|
41922
|
+
src: str,
|
|
41923
|
+
alt: formatFieldLabel(fieldName2),
|
|
41924
|
+
className: "max-w-full max-h-64 rounded-md object-contain",
|
|
41925
|
+
loading: "lazy"
|
|
41926
|
+
}
|
|
41927
|
+
) });
|
|
41928
|
+
}
|
|
41818
41929
|
case "url": {
|
|
41819
41930
|
if (str.match(/\.(png|jpe?g|gif|svg|webp|avif)(\?|$)/i) || str.startsWith("data:image/")) {
|
|
41820
41931
|
return /* @__PURE__ */ jsxRuntime.jsx(Box, { className: "mt-1 max-w-full", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -41827,7 +41938,7 @@ function renderRichFieldValue(value, fieldName2, fieldType, meta) {
|
|
|
41827
41938
|
}
|
|
41828
41939
|
) });
|
|
41829
41940
|
}
|
|
41830
|
-
if (
|
|
41941
|
+
if (/^https?:\/\//i.test(str)) {
|
|
41831
41942
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
41832
41943
|
"a",
|
|
41833
41944
|
{
|
|
@@ -41913,8 +42024,10 @@ function renderRichFieldValue(value, fieldName2, fieldType, meta) {
|
|
|
41913
42024
|
return str;
|
|
41914
42025
|
}
|
|
41915
42026
|
case "relation": {
|
|
41916
|
-
const
|
|
41917
|
-
|
|
42027
|
+
const labels = relationDisplayLabels(value, meta?.options);
|
|
42028
|
+
if (labels.length === 0) return "\u2014";
|
|
42029
|
+
if (labels.length === 1) return labels[0];
|
|
42030
|
+
return /* @__PURE__ */ jsxRuntime.jsx(HStack, { gap: "xs", wrap: true, children: labels.map((label, i) => /* @__PURE__ */ jsxRuntime.jsx(Badge, { variant: "default", children: label }, i)) });
|
|
41918
42031
|
}
|
|
41919
42032
|
case "file": {
|
|
41920
42033
|
if (value !== null && typeof value === "object" && !Array.isArray(value)) {
|
|
@@ -42016,6 +42129,7 @@ var init_DetailPanel = __esm({
|
|
|
42016
42129
|
init_cn();
|
|
42017
42130
|
init_format();
|
|
42018
42131
|
init_getNestedValue();
|
|
42132
|
+
init_relationLabel();
|
|
42019
42133
|
init_useEventBus();
|
|
42020
42134
|
init_UploadDropZone();
|
|
42021
42135
|
formatFieldLabel = humanizeFieldName;
|
|
@@ -42674,6 +42788,8 @@ function determineInputType(field) {
|
|
|
42674
42788
|
return "url";
|
|
42675
42789
|
case "file":
|
|
42676
42790
|
return "file";
|
|
42791
|
+
case "image":
|
|
42792
|
+
return "image";
|
|
42677
42793
|
case "money":
|
|
42678
42794
|
return "currency";
|
|
42679
42795
|
case "number":
|
|
@@ -43273,6 +43389,49 @@ var init_Form = __esm({
|
|
|
43273
43389
|
}
|
|
43274
43390
|
}
|
|
43275
43391
|
);
|
|
43392
|
+
case "image": {
|
|
43393
|
+
const imageUrl = typeof currentValue === "string" ? currentValue : "";
|
|
43394
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(VStack, { gap: "sm", children: [
|
|
43395
|
+
imageUrl ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
43396
|
+
"img",
|
|
43397
|
+
{
|
|
43398
|
+
src: imageUrl,
|
|
43399
|
+
alt: "",
|
|
43400
|
+
"aria-hidden": "true",
|
|
43401
|
+
className: "h-24 w-full max-w-xs rounded-md border border-border object-cover",
|
|
43402
|
+
"data-testid": `image-preview-${fieldName2}`
|
|
43403
|
+
}
|
|
43404
|
+
) : null,
|
|
43405
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
43406
|
+
Input,
|
|
43407
|
+
{
|
|
43408
|
+
...commonProps,
|
|
43409
|
+
type: "url",
|
|
43410
|
+
value: imageUrl,
|
|
43411
|
+
onChange: (e) => handleChange(fieldName2, e.target.value)
|
|
43412
|
+
}
|
|
43413
|
+
),
|
|
43414
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
43415
|
+
UploadDropZone,
|
|
43416
|
+
{
|
|
43417
|
+
accept: "image/*",
|
|
43418
|
+
maxFiles: 1,
|
|
43419
|
+
maxSize: 2 * 1024 * 1024,
|
|
43420
|
+
disabled: isLoading,
|
|
43421
|
+
onFiles: (files) => {
|
|
43422
|
+
const f3 = files[0];
|
|
43423
|
+
if (!f3) return;
|
|
43424
|
+
const reader = new FileReader();
|
|
43425
|
+
reader.onload = () => handleChange(
|
|
43426
|
+
fieldName2,
|
|
43427
|
+
typeof reader.result === "string" ? reader.result : ""
|
|
43428
|
+
);
|
|
43429
|
+
reader.readAsDataURL(f3);
|
|
43430
|
+
}
|
|
43431
|
+
}
|
|
43432
|
+
)
|
|
43433
|
+
] });
|
|
43434
|
+
}
|
|
43276
43435
|
case "date":
|
|
43277
43436
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
43278
43437
|
Input,
|