@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/providers/index.js
CHANGED
|
@@ -33068,6 +33068,33 @@ var init_Lightbox = __esm({
|
|
|
33068
33068
|
Lightbox.displayName = "Lightbox";
|
|
33069
33069
|
}
|
|
33070
33070
|
});
|
|
33071
|
+
|
|
33072
|
+
// lib/relationLabel.ts
|
|
33073
|
+
function relationLabel(value) {
|
|
33074
|
+
if (value === null || typeof value !== "object" || Array.isArray(value) || value instanceof Date)
|
|
33075
|
+
return null;
|
|
33076
|
+
for (const key of ["name", "title", "label"]) {
|
|
33077
|
+
const candidate = value[key];
|
|
33078
|
+
if (typeof candidate === "string" && candidate !== "") return candidate;
|
|
33079
|
+
}
|
|
33080
|
+
const id = value.id;
|
|
33081
|
+
return id !== void 0 && id !== null ? String(id) : null;
|
|
33082
|
+
}
|
|
33083
|
+
function relationDisplayLabels(value, options) {
|
|
33084
|
+
if (value === void 0 || value === null || value === "") return [];
|
|
33085
|
+
if (Array.isArray(value)) {
|
|
33086
|
+
return value.flatMap((item) => relationDisplayLabels(item, options));
|
|
33087
|
+
}
|
|
33088
|
+
const hydrated = relationLabel(value);
|
|
33089
|
+
if (hydrated !== null) return [hydrated];
|
|
33090
|
+
const raw = String(value);
|
|
33091
|
+
const match = options?.find((opt) => opt.value === raw);
|
|
33092
|
+
return [match ? match.label : raw];
|
|
33093
|
+
}
|
|
33094
|
+
var init_relationLabel = __esm({
|
|
33095
|
+
"lib/relationLabel.ts"() {
|
|
33096
|
+
}
|
|
33097
|
+
});
|
|
33071
33098
|
function renderIconInput3(icon, props) {
|
|
33072
33099
|
return typeof icon === "string" ? /* @__PURE__ */ jsx(Icon, { name: icon, ...props }) : /* @__PURE__ */ jsx(Icon, { icon, ...props });
|
|
33073
33100
|
}
|
|
@@ -33385,6 +33412,7 @@ var init_TableView = __esm({
|
|
|
33385
33412
|
"use client";
|
|
33386
33413
|
init_cn();
|
|
33387
33414
|
init_format();
|
|
33415
|
+
init_relationLabel();
|
|
33388
33416
|
init_getNestedValue();
|
|
33389
33417
|
init_useEventBus();
|
|
33390
33418
|
init_Box();
|
|
@@ -33398,7 +33426,13 @@ var init_TableView = __esm({
|
|
|
33398
33426
|
init_Menu();
|
|
33399
33427
|
init_useDataDnd();
|
|
33400
33428
|
tableViewLog = createLogger("almadar:ui:table-view");
|
|
33401
|
-
formatCell = (value, format) =>
|
|
33429
|
+
formatCell = (value, format) => {
|
|
33430
|
+
if (value !== null && value !== void 0 && typeof value === "object" && !(value instanceof Date)) {
|
|
33431
|
+
const labels = relationDisplayLabels(value);
|
|
33432
|
+
if (labels.length > 0) return labels.join(", ");
|
|
33433
|
+
}
|
|
33434
|
+
return formatValue(value, format);
|
|
33435
|
+
};
|
|
33402
33436
|
MAX_MEASURED_COL_CH = 32;
|
|
33403
33437
|
BADGE_CHROME_CH = 4;
|
|
33404
33438
|
alignClass = {
|
|
@@ -37013,6 +37047,13 @@ var init_RichTextEditor = __esm({
|
|
|
37013
37047
|
document.execCommand("createLink", false, safe);
|
|
37014
37048
|
afterEdit();
|
|
37015
37049
|
}, [afterEdit, t, toolbar.link]);
|
|
37050
|
+
const execImage = useCallback(() => {
|
|
37051
|
+
const url = window.prompt(t("richTextEditor.imagePrompt"));
|
|
37052
|
+
if (!url) return;
|
|
37053
|
+
const safe = safeUrl(url, ["http://", "https://", "data:image/"]) ?? `https://${url}`;
|
|
37054
|
+
document.execCommand("insertImage", false, safe);
|
|
37055
|
+
afterEdit();
|
|
37056
|
+
}, [afterEdit, t]);
|
|
37016
37057
|
const execRule = useCallback(() => {
|
|
37017
37058
|
document.execCommand("insertHorizontalRule", false);
|
|
37018
37059
|
afterEdit();
|
|
@@ -37050,6 +37091,7 @@ var init_RichTextEditor = __esm({
|
|
|
37050
37091
|
/* @__PURE__ */ jsx(ToolbarButton, { icon: Quote, label: t("richTextEditor.quote"), active: toolbar.block === "blockquote", onExec: () => execBlock("blockquote") }),
|
|
37051
37092
|
/* @__PURE__ */ jsx(ToolbarButton, { icon: Code, label: t("richTextEditor.code"), active: toolbar.block === "pre", onExec: () => execBlock("pre") }),
|
|
37052
37093
|
/* @__PURE__ */ jsx(ToolbarButton, { icon: Link$1, label: toolbar.link ? t("richTextEditor.removeLink") : t("richTextEditor.link"), active: toolbar.link, onExec: execLink }),
|
|
37094
|
+
/* @__PURE__ */ jsx(ToolbarButton, { icon: Image$1, label: t("richTextEditor.image"), onExec: execImage }),
|
|
37053
37095
|
/* @__PURE__ */ jsx(ToolbarButton, { icon: Minus, label: t("richTextEditor.divider"), onExec: execRule })
|
|
37054
37096
|
]
|
|
37055
37097
|
}
|
|
@@ -37087,9 +37129,11 @@ function renderIconInput4(icon, props) {
|
|
|
37087
37129
|
return typeof icon === "string" ? /* @__PURE__ */ jsx(Icon, { name: icon, ...props }) : /* @__PURE__ */ jsx(Icon, { icon, ...props });
|
|
37088
37130
|
}
|
|
37089
37131
|
function DocumentPanel({
|
|
37090
|
-
|
|
37132
|
+
id,
|
|
37091
37133
|
title,
|
|
37092
37134
|
subtitle,
|
|
37135
|
+
coverImage,
|
|
37136
|
+
icon,
|
|
37093
37137
|
value,
|
|
37094
37138
|
actions,
|
|
37095
37139
|
maxInlineActions,
|
|
@@ -37107,14 +37151,14 @@ function DocumentPanel({
|
|
|
37107
37151
|
const eventBus = useEventBus();
|
|
37108
37152
|
const { t } = useTranslate();
|
|
37109
37153
|
const [titleDraft, setTitleDraft] = useState(null);
|
|
37110
|
-
const recordId =
|
|
37154
|
+
const recordId = id ?? "";
|
|
37111
37155
|
const actionDefs = actions ?? [];
|
|
37112
37156
|
const inlineCap = Math.min(maxInlineActions ?? 1, 1);
|
|
37113
37157
|
const inlineActions = actionDefs.filter((a) => a.variant === "primary").slice(0, inlineCap);
|
|
37114
37158
|
const menuActions = actionDefs.filter((a) => !inlineActions.includes(a));
|
|
37115
37159
|
const fireAction = (action) => {
|
|
37116
37160
|
if (!action.event) return;
|
|
37117
|
-
eventBus.emit(`UI:${action.event}`, { id: recordId,
|
|
37161
|
+
eventBus.emit(`UI:${action.event}`, { id: recordId, title: title ?? "" });
|
|
37118
37162
|
};
|
|
37119
37163
|
const commitTitle = () => {
|
|
37120
37164
|
if (!titleCommitEvent) return;
|
|
@@ -37165,62 +37209,74 @@ function DocumentPanel({
|
|
|
37165
37209
|
const emitWithId = (event) => () => {
|
|
37166
37210
|
if (event) eventBus.emit(`UI:${event}`, { id: recordId });
|
|
37167
37211
|
};
|
|
37168
|
-
return /* @__PURE__ */
|
|
37169
|
-
/* @__PURE__ */
|
|
37170
|
-
|
|
37171
|
-
titleNode,
|
|
37172
|
-
subtitle ? /* @__PURE__ */ jsx(Typography, { variant: "small", color: "secondary", children: subtitle }) : null
|
|
37173
|
-
] }),
|
|
37174
|
-
/* @__PURE__ */ jsx(HStack, { gap: "xs", className: "flex-shrink-0 pt-1 items-center", children: editing ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
37175
|
-
/* @__PURE__ */ jsx(Typography, { variant: "caption", color: "muted", className: "hidden sm:block", children: autosaveHint ?? (t("documentPanel.autosaveHint") || "") }),
|
|
37176
|
-
/* @__PURE__ */ jsx(Button, { variant: "primary", size: "sm", onClick: emitWithId(doneEvent), "data-testid": "document-done", children: doneLabel ?? (t("documentPanel.done") || "Done") })
|
|
37177
|
-
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
37178
|
-
editEvent && /* @__PURE__ */ jsxs(Button, { variant: "ghost", size: "sm", onClick: emitWithId(editEvent), "data-testid": "document-edit", children: [
|
|
37179
|
-
/* @__PURE__ */ jsx(Icon, { name: "edit", size: "xs", className: "mr-1" }),
|
|
37180
|
-
editLabel ?? (t("documentPanel.edit") || "Edit")
|
|
37181
|
-
] }),
|
|
37182
|
-
inlineActions.map((action, idx) => /* @__PURE__ */ jsxs(
|
|
37183
|
-
Button,
|
|
37184
|
-
{
|
|
37185
|
-
variant: "primary",
|
|
37186
|
-
size: "sm",
|
|
37187
|
-
onClick: () => fireAction(action),
|
|
37188
|
-
"data-testid": `action-${action.event}`,
|
|
37189
|
-
children: [
|
|
37190
|
-
action.icon && renderIconInput4(action.icon, { size: "xs", className: "mr-1" }),
|
|
37191
|
-
action.label
|
|
37192
|
-
]
|
|
37193
|
-
},
|
|
37194
|
-
idx
|
|
37195
|
-
)),
|
|
37196
|
-
menuActions.length > 0 && /* @__PURE__ */ jsx(
|
|
37197
|
-
Menu,
|
|
37198
|
-
{
|
|
37199
|
-
position: "bottom-end",
|
|
37200
|
-
trigger: /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "sm", "aria-label": t("common.actions"), "data-testid": "action-overflow", children: /* @__PURE__ */ jsx(Icon, { name: "more-horizontal", size: "xs" }) }),
|
|
37201
|
-
items: menuActions.map((action) => ({
|
|
37202
|
-
label: action.label,
|
|
37203
|
-
icon: action.icon,
|
|
37204
|
-
variant: action.variant === "danger" ? "danger" : "default",
|
|
37205
|
-
onClick: () => fireAction(action)
|
|
37206
|
-
}))
|
|
37207
|
-
}
|
|
37208
|
-
)
|
|
37209
|
-
] }) })
|
|
37210
|
-
] }),
|
|
37211
|
-
editing ? /* @__PURE__ */ jsx(RichTextEditor, { value, changeEvent: contentChangeEvent, placeholder }) : /* @__PURE__ */ jsx(
|
|
37212
|
-
Box,
|
|
37212
|
+
return /* @__PURE__ */ jsxs(Card, { variant: "elevated", className: cn("w-full overflow-hidden", className), children: [
|
|
37213
|
+
coverImage ? /* @__PURE__ */ jsx(Box, { className: "h-44 w-full sm:h-52", "data-testid": "document-cover", children: /* @__PURE__ */ jsx(
|
|
37214
|
+
"img",
|
|
37213
37215
|
{
|
|
37214
|
-
|
|
37215
|
-
|
|
37216
|
-
|
|
37217
|
-
|
|
37218
|
-
|
|
37219
|
-
|
|
37220
|
-
|
|
37221
|
-
|
|
37222
|
-
|
|
37223
|
-
|
|
37216
|
+
src: coverImage,
|
|
37217
|
+
alt: "",
|
|
37218
|
+
"aria-hidden": "true",
|
|
37219
|
+
className: "h-full w-full object-cover"
|
|
37220
|
+
}
|
|
37221
|
+
) }) : null,
|
|
37222
|
+
/* @__PURE__ */ jsxs(VStack, { gap: "sm", className: "p-6 sm:p-8", children: [
|
|
37223
|
+
/* @__PURE__ */ jsxs(HStack, { gap: "sm", className: "justify-between items-start", children: [
|
|
37224
|
+
/* @__PURE__ */ jsxs(VStack, { gap: "xs", className: "flex-1 min-w-0", children: [
|
|
37225
|
+
icon ? /* @__PURE__ */ jsx(Box, { className: "text-muted-foreground", "data-testid": "document-icon", children: renderIconInput4(icon, { size: "lg" }) }) : null,
|
|
37226
|
+
titleNode,
|
|
37227
|
+
subtitle ? /* @__PURE__ */ jsx(Typography, { variant: "small", color: "secondary", children: subtitle }) : null
|
|
37228
|
+
] }),
|
|
37229
|
+
/* @__PURE__ */ jsx(HStack, { gap: "xs", className: "flex-shrink-0 pt-1 items-center", children: editing ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
37230
|
+
/* @__PURE__ */ jsx(Typography, { variant: "caption", color: "muted", className: "hidden sm:block", children: autosaveHint ?? (t("documentPanel.autosaveHint") || "") }),
|
|
37231
|
+
/* @__PURE__ */ jsx(Button, { variant: "primary", size: "sm", onClick: emitWithId(doneEvent), "data-testid": "document-done", children: doneLabel ?? (t("documentPanel.done") || "Done") })
|
|
37232
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
37233
|
+
editEvent && /* @__PURE__ */ jsxs(Button, { variant: "ghost", size: "sm", onClick: emitWithId(editEvent), "data-testid": "document-edit", children: [
|
|
37234
|
+
/* @__PURE__ */ jsx(Icon, { name: "edit", size: "xs", className: "mr-1" }),
|
|
37235
|
+
editLabel ?? (t("documentPanel.edit") || "Edit")
|
|
37236
|
+
] }),
|
|
37237
|
+
inlineActions.map((action, idx) => /* @__PURE__ */ jsxs(
|
|
37238
|
+
Button,
|
|
37239
|
+
{
|
|
37240
|
+
variant: "primary",
|
|
37241
|
+
size: "sm",
|
|
37242
|
+
onClick: () => fireAction(action),
|
|
37243
|
+
"data-testid": `action-${action.event}`,
|
|
37244
|
+
children: [
|
|
37245
|
+
action.icon && renderIconInput4(action.icon, { size: "xs", className: "mr-1" }),
|
|
37246
|
+
action.label
|
|
37247
|
+
]
|
|
37248
|
+
},
|
|
37249
|
+
idx
|
|
37250
|
+
)),
|
|
37251
|
+
menuActions.length > 0 && /* @__PURE__ */ jsx(
|
|
37252
|
+
Menu,
|
|
37253
|
+
{
|
|
37254
|
+
position: "bottom-end",
|
|
37255
|
+
trigger: /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "sm", "aria-label": t("common.actions"), "data-testid": "action-overflow", children: /* @__PURE__ */ jsx(Icon, { name: "more-horizontal", size: "xs" }) }),
|
|
37256
|
+
items: menuActions.map((action) => ({
|
|
37257
|
+
label: action.label,
|
|
37258
|
+
icon: action.icon,
|
|
37259
|
+
variant: action.variant === "danger" ? "danger" : "default",
|
|
37260
|
+
onClick: () => fireAction(action)
|
|
37261
|
+
}))
|
|
37262
|
+
}
|
|
37263
|
+
)
|
|
37264
|
+
] }) })
|
|
37265
|
+
] }),
|
|
37266
|
+
editing ? /* @__PURE__ */ jsx(RichTextEditor, { value, changeEvent: contentChangeEvent, placeholder }) : /* @__PURE__ */ jsx(
|
|
37267
|
+
Box,
|
|
37268
|
+
{
|
|
37269
|
+
onClick: emitWithId(editEvent),
|
|
37270
|
+
className: cn(
|
|
37271
|
+
"rounded-md px-1 -mx-1 min-h-[16rem]",
|
|
37272
|
+
editEvent && "cursor-text transition-colors hover:bg-muted/30"
|
|
37273
|
+
),
|
|
37274
|
+
"data-testid": "document-body",
|
|
37275
|
+
children: value && value !== "" ? /* @__PURE__ */ jsx(RichTextEditor, { value, readOnly: true }) : /* @__PURE__ */ jsx(Typography, { variant: "body", color: "muted", children: placeholder ?? (t("documentPanel.placeholder") || "") })
|
|
37276
|
+
}
|
|
37277
|
+
)
|
|
37278
|
+
] })
|
|
37279
|
+
] });
|
|
37224
37280
|
}
|
|
37225
37281
|
var init_DocumentPanel = __esm({
|
|
37226
37282
|
"components/core/molecules/DocumentPanel.tsx"() {
|
|
@@ -37244,17 +37300,16 @@ function renderIconInput5(icon, props) {
|
|
|
37244
37300
|
function fieldName(field) {
|
|
37245
37301
|
return field.name ?? field.key ?? "";
|
|
37246
37302
|
}
|
|
37247
|
-
function
|
|
37248
|
-
if (value
|
|
37249
|
-
|
|
37250
|
-
|
|
37251
|
-
if (typeof candidate === "string" && candidate !== "") return candidate;
|
|
37303
|
+
function relationId(value) {
|
|
37304
|
+
if (value !== null && typeof value === "object" && !Array.isArray(value) && !(value instanceof Date)) {
|
|
37305
|
+
const id = value.id;
|
|
37306
|
+
if (id !== void 0 && id !== null) return String(id);
|
|
37252
37307
|
}
|
|
37253
|
-
|
|
37254
|
-
return id !== void 0 && id !== null ? String(id) : null;
|
|
37308
|
+
return String(value);
|
|
37255
37309
|
}
|
|
37256
37310
|
function fieldKind(field, value) {
|
|
37257
37311
|
if (field.kind) return field.kind;
|
|
37312
|
+
if (field.type === "image") return "image";
|
|
37258
37313
|
if (field.options && field.options.length > 0) return "select";
|
|
37259
37314
|
if (typeof value === "boolean" || field.format === "boolean") return "boolean";
|
|
37260
37315
|
if (Array.isArray(value) || relationLabel(value ?? null) !== null) return "readonly";
|
|
@@ -37264,6 +37319,7 @@ function DocumentDetails({
|
|
|
37264
37319
|
entity,
|
|
37265
37320
|
fields,
|
|
37266
37321
|
metaCommitEvent,
|
|
37322
|
+
relationEvent,
|
|
37267
37323
|
title,
|
|
37268
37324
|
className
|
|
37269
37325
|
}) {
|
|
@@ -37278,11 +37334,51 @@ function DocumentDetails({
|
|
|
37278
37334
|
if (!metaCommitEvent || next === current) return;
|
|
37279
37335
|
eventBus.emit(`UI:${metaCommitEvent}`, { id: recordId, patch: { id: recordId, [name]: next } });
|
|
37280
37336
|
};
|
|
37337
|
+
const relationChip = (item, name, key) => {
|
|
37338
|
+
const label = relationLabel(item) ?? humanizeEnumValue(String(item));
|
|
37339
|
+
if (!relationEvent) {
|
|
37340
|
+
return /* @__PURE__ */ jsx(Badge, { variant: "default", children: label }, key);
|
|
37341
|
+
}
|
|
37342
|
+
const emitClick = () => eventBus.emit(`UI:${relationEvent}`, { field: name, id: relationId(item), name: label });
|
|
37343
|
+
return /* @__PURE__ */ jsx(
|
|
37344
|
+
Badge,
|
|
37345
|
+
{
|
|
37346
|
+
variant: "default",
|
|
37347
|
+
role: "button",
|
|
37348
|
+
tabIndex: 0,
|
|
37349
|
+
className: "cursor-pointer transition-colors hover:bg-accent",
|
|
37350
|
+
onClick: emitClick,
|
|
37351
|
+
onKeyDown: (e) => {
|
|
37352
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
37353
|
+
e.preventDefault();
|
|
37354
|
+
emitClick();
|
|
37355
|
+
}
|
|
37356
|
+
},
|
|
37357
|
+
"data-testid": `relation-chip-${name}`,
|
|
37358
|
+
children: label
|
|
37359
|
+
},
|
|
37360
|
+
key
|
|
37361
|
+
);
|
|
37362
|
+
};
|
|
37281
37363
|
const renderValue = (field) => {
|
|
37282
37364
|
const name = fieldName(field);
|
|
37283
37365
|
const raw = getNestedValue(entity ?? {}, name);
|
|
37284
37366
|
const kind = fieldKind(field, raw);
|
|
37285
37367
|
const label = field.label ?? field.header ?? humanizeFieldName(name);
|
|
37368
|
+
if (kind === "image") {
|
|
37369
|
+
const url = typeof raw === "string" ? raw : "";
|
|
37370
|
+
if (!url) return /* @__PURE__ */ jsx(Typography, { variant: "small", color: "secondary", children: "\u2014" });
|
|
37371
|
+
return /* @__PURE__ */ jsx(
|
|
37372
|
+
"img",
|
|
37373
|
+
{
|
|
37374
|
+
src: url,
|
|
37375
|
+
alt: label,
|
|
37376
|
+
loading: "lazy",
|
|
37377
|
+
className: "max-h-32 w-full rounded-md border border-border object-cover",
|
|
37378
|
+
"data-testid": `document-property-image-${name}`
|
|
37379
|
+
}
|
|
37380
|
+
);
|
|
37381
|
+
}
|
|
37286
37382
|
if (kind === "boolean") {
|
|
37287
37383
|
return /* @__PURE__ */ jsx(
|
|
37288
37384
|
Switch,
|
|
@@ -37312,9 +37408,12 @@ function DocumentDetails({
|
|
|
37312
37408
|
if (raw.length === 0) {
|
|
37313
37409
|
return /* @__PURE__ */ jsx(Typography, { variant: "small", color: "secondary", children: "\u2014" });
|
|
37314
37410
|
}
|
|
37315
|
-
return /* @__PURE__ */ jsx(HStack, { gap: "xs", className: "flex-wrap", children: raw.map((item, i) =>
|
|
37411
|
+
return /* @__PURE__ */ jsx(HStack, { gap: "xs", className: "flex-wrap", children: raw.map((item, i) => relationChip(item, name, i)) });
|
|
37412
|
+
}
|
|
37413
|
+
if (raw !== void 0 && raw !== null && raw !== "" && relationLabel(raw) !== null) {
|
|
37414
|
+
return relationChip(raw, name);
|
|
37316
37415
|
}
|
|
37317
|
-
const shown2 = raw === void 0 || raw === null || raw === "" ? "\u2014" :
|
|
37416
|
+
const shown2 = raw === void 0 || raw === null || raw === "" ? "\u2014" : formatValue(raw, field.format);
|
|
37318
37417
|
return /* @__PURE__ */ jsx(Typography, { variant: "small", className: "break-words", children: shown2 });
|
|
37319
37418
|
}
|
|
37320
37419
|
if (fieldDraft?.name === name) {
|
|
@@ -37383,6 +37482,7 @@ var init_DocumentDetails = __esm({
|
|
|
37383
37482
|
init_cn();
|
|
37384
37483
|
init_format();
|
|
37385
37484
|
init_getNestedValue();
|
|
37485
|
+
init_relationLabel();
|
|
37386
37486
|
init_useEventBus();
|
|
37387
37487
|
init_Box();
|
|
37388
37488
|
init_Stack();
|
|
@@ -42377,7 +42477,18 @@ function renderRichFieldValue(value, fieldName2, fieldType, meta) {
|
|
|
42377
42477
|
if (value === void 0 || value === null) return "\u2014";
|
|
42378
42478
|
const str = String(value);
|
|
42379
42479
|
switch (fieldType) {
|
|
42380
|
-
case "image":
|
|
42480
|
+
case "image": {
|
|
42481
|
+
if (!str) return "\u2014";
|
|
42482
|
+
return /* @__PURE__ */ jsx(Box, { className: "mt-1 max-w-full", children: /* @__PURE__ */ jsx(
|
|
42483
|
+
"img",
|
|
42484
|
+
{
|
|
42485
|
+
src: str,
|
|
42486
|
+
alt: formatFieldLabel(fieldName2),
|
|
42487
|
+
className: "max-w-full max-h-64 rounded-md object-contain",
|
|
42488
|
+
loading: "lazy"
|
|
42489
|
+
}
|
|
42490
|
+
) });
|
|
42491
|
+
}
|
|
42381
42492
|
case "url": {
|
|
42382
42493
|
if (str.match(/\.(png|jpe?g|gif|svg|webp|avif)(\?|$)/i) || str.startsWith("data:image/")) {
|
|
42383
42494
|
return /* @__PURE__ */ jsx(Box, { className: "mt-1 max-w-full", children: /* @__PURE__ */ jsx(
|
|
@@ -42390,7 +42501,7 @@ function renderRichFieldValue(value, fieldName2, fieldType, meta) {
|
|
|
42390
42501
|
}
|
|
42391
42502
|
) });
|
|
42392
42503
|
}
|
|
42393
|
-
if (
|
|
42504
|
+
if (/^https?:\/\//i.test(str)) {
|
|
42394
42505
|
return /* @__PURE__ */ jsx(
|
|
42395
42506
|
"a",
|
|
42396
42507
|
{
|
|
@@ -42476,8 +42587,10 @@ function renderRichFieldValue(value, fieldName2, fieldType, meta) {
|
|
|
42476
42587
|
return str;
|
|
42477
42588
|
}
|
|
42478
42589
|
case "relation": {
|
|
42479
|
-
const
|
|
42480
|
-
|
|
42590
|
+
const labels = relationDisplayLabels(value, meta?.options);
|
|
42591
|
+
if (labels.length === 0) return "\u2014";
|
|
42592
|
+
if (labels.length === 1) return labels[0];
|
|
42593
|
+
return /* @__PURE__ */ jsx(HStack, { gap: "xs", wrap: true, children: labels.map((label, i) => /* @__PURE__ */ jsx(Badge, { variant: "default", children: label }, i)) });
|
|
42481
42594
|
}
|
|
42482
42595
|
case "file": {
|
|
42483
42596
|
if (value !== null && typeof value === "object" && !Array.isArray(value)) {
|
|
@@ -42579,6 +42692,7 @@ var init_DetailPanel = __esm({
|
|
|
42579
42692
|
init_cn();
|
|
42580
42693
|
init_format();
|
|
42581
42694
|
init_getNestedValue();
|
|
42695
|
+
init_relationLabel();
|
|
42582
42696
|
init_useEventBus();
|
|
42583
42697
|
init_UploadDropZone();
|
|
42584
42698
|
formatFieldLabel = humanizeFieldName;
|
|
@@ -43237,6 +43351,8 @@ function determineInputType(field) {
|
|
|
43237
43351
|
return "url";
|
|
43238
43352
|
case "file":
|
|
43239
43353
|
return "file";
|
|
43354
|
+
case "image":
|
|
43355
|
+
return "image";
|
|
43240
43356
|
case "money":
|
|
43241
43357
|
return "currency";
|
|
43242
43358
|
case "number":
|
|
@@ -43836,6 +43952,49 @@ var init_Form = __esm({
|
|
|
43836
43952
|
}
|
|
43837
43953
|
}
|
|
43838
43954
|
);
|
|
43955
|
+
case "image": {
|
|
43956
|
+
const imageUrl = typeof currentValue === "string" ? currentValue : "";
|
|
43957
|
+
return /* @__PURE__ */ jsxs(VStack, { gap: "sm", children: [
|
|
43958
|
+
imageUrl ? /* @__PURE__ */ jsx(
|
|
43959
|
+
"img",
|
|
43960
|
+
{
|
|
43961
|
+
src: imageUrl,
|
|
43962
|
+
alt: "",
|
|
43963
|
+
"aria-hidden": "true",
|
|
43964
|
+
className: "h-24 w-full max-w-xs rounded-md border border-border object-cover",
|
|
43965
|
+
"data-testid": `image-preview-${fieldName2}`
|
|
43966
|
+
}
|
|
43967
|
+
) : null,
|
|
43968
|
+
/* @__PURE__ */ jsx(
|
|
43969
|
+
Input,
|
|
43970
|
+
{
|
|
43971
|
+
...commonProps,
|
|
43972
|
+
type: "url",
|
|
43973
|
+
value: imageUrl,
|
|
43974
|
+
onChange: (e) => handleChange(fieldName2, e.target.value)
|
|
43975
|
+
}
|
|
43976
|
+
),
|
|
43977
|
+
/* @__PURE__ */ jsx(
|
|
43978
|
+
UploadDropZone,
|
|
43979
|
+
{
|
|
43980
|
+
accept: "image/*",
|
|
43981
|
+
maxFiles: 1,
|
|
43982
|
+
maxSize: 2 * 1024 * 1024,
|
|
43983
|
+
disabled: isLoading,
|
|
43984
|
+
onFiles: (files) => {
|
|
43985
|
+
const f3 = files[0];
|
|
43986
|
+
if (!f3) return;
|
|
43987
|
+
const reader = new FileReader();
|
|
43988
|
+
reader.onload = () => handleChange(
|
|
43989
|
+
fieldName2,
|
|
43990
|
+
typeof reader.result === "string" ? reader.result : ""
|
|
43991
|
+
);
|
|
43992
|
+
reader.readAsDataURL(f3);
|
|
43993
|
+
}
|
|
43994
|
+
}
|
|
43995
|
+
)
|
|
43996
|
+
] });
|
|
43997
|
+
}
|
|
43839
43998
|
case "date":
|
|
43840
43999
|
return /* @__PURE__ */ jsx(
|
|
43841
44000
|
Input,
|