@byline/admin 2.5.1 → 2.6.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/fields/array/array-field.d.ts +14 -0
- package/dist/fields/array/array-field.js +177 -0
- package/dist/fields/array/array-field.module.js +11 -0
- package/dist/fields/array/array-field_module.css +32 -0
- package/dist/fields/blocks/blocks-field.d.ts +13 -0
- package/dist/fields/blocks/blocks-field.js +245 -0
- package/dist/fields/blocks/blocks-field.module.js +26 -0
- package/dist/fields/blocks/blocks-field_module.css +107 -0
- package/dist/fields/checkbox/checkbox-field.d.ts +16 -0
- package/dist/fields/checkbox/checkbox-field.js +28 -0
- package/dist/fields/checkbox/checkbox-field.module.js +6 -0
- package/dist/fields/checkbox/checkbox-field_module.css +4 -0
- package/dist/fields/column-formatter.d.ts +20 -0
- package/dist/fields/column-formatter.js +15 -0
- package/dist/fields/date-time-formatter.d.ts +16 -0
- package/dist/fields/date-time-formatter.js +8 -0
- package/dist/fields/datetime/datetime-field.d.ts +16 -0
- package/dist/fields/datetime/datetime-field.js +37 -0
- package/dist/fields/datetime/datetime-field.module.js +5 -0
- package/dist/fields/datetime/datetime-field_module.css +4 -0
- package/dist/fields/draggable-context-menu.d.ts +6 -0
- package/dist/fields/draggable-context-menu.js +85 -0
- package/dist/fields/draggable-context-menu.module.js +15 -0
- package/dist/fields/draggable-context-menu_module.css +91 -0
- package/dist/fields/field-helpers.d.ts +26 -0
- package/dist/fields/field-helpers.js +50 -0
- package/dist/fields/field-renderer.d.ts +37 -0
- package/dist/fields/field-renderer.js +206 -0
- package/dist/fields/field-renderer.module.js +8 -0
- package/dist/fields/field-renderer_module.css +11 -0
- package/dist/fields/field-services-context.d.ts +16 -0
- package/dist/fields/field-services-context.js +13 -0
- package/dist/fields/field-services-types.d.ts +63 -0
- package/dist/fields/field-services-types.js +1 -0
- package/dist/fields/file/file-field.d.ts +19 -0
- package/dist/fields/file/file-field.js +225 -0
- package/dist/fields/file/file-field.module.js +18 -0
- package/dist/fields/file/file-field_module.css +131 -0
- package/dist/fields/file/file-upload-field.d.ts +21 -0
- package/dist/fields/file/file-upload-field.js +130 -0
- package/dist/fields/file/file-upload-field.module.js +15 -0
- package/dist/fields/file/file-upload-field_module.css +74 -0
- package/dist/fields/group/group-field.d.ts +15 -0
- package/dist/fields/group/group-field.js +59 -0
- package/dist/fields/group/group-field.module.js +9 -0
- package/dist/fields/group/group-field_module.css +27 -0
- package/dist/fields/image/image-field.d.ts +19 -0
- package/dist/fields/image/image-field.js +241 -0
- package/dist/fields/image/image-field.module.js +22 -0
- package/dist/fields/image/image-field_module.css +121 -0
- package/dist/fields/image/image-upload-field.d.ts +21 -0
- package/dist/fields/image/image-upload-field.js +190 -0
- package/dist/fields/image/image-upload-field.module.js +19 -0
- package/dist/fields/image/image-upload-field_module.css +92 -0
- package/dist/fields/local-date-time.d.ts +27 -0
- package/dist/fields/local-date-time.js +49 -0
- package/dist/fields/locale-badge.d.ts +18 -0
- package/dist/fields/locale-badge.js +10 -0
- package/dist/fields/locale-badge.module.js +5 -0
- package/dist/fields/locale-badge_module.css +27 -0
- package/dist/fields/numerical/numerical-field.d.ts +18 -0
- package/dist/fields/numerical/numerical-field.js +74 -0
- package/dist/fields/relation/relation-display.d.ts +40 -0
- package/dist/fields/relation/relation-display.js +58 -0
- package/dist/fields/relation/relation-display.module.js +9 -0
- package/dist/fields/relation/relation-display_module.css +21 -0
- package/dist/fields/relation/relation-field.d.ts +18 -0
- package/dist/fields/relation/relation-field.js +138 -0
- package/dist/fields/relation/relation-field.module.js +13 -0
- package/dist/fields/relation/relation-field_module.css +62 -0
- package/dist/fields/relation/relation-picker.d.ts +49 -0
- package/dist/fields/relation/relation-picker.js +236 -0
- package/dist/fields/relation/relation-picker.module.js +26 -0
- package/dist/fields/relation/relation-picker_module.css +124 -0
- package/dist/fields/relation/relation-summary.d.ts +31 -0
- package/dist/fields/relation/relation-summary.js +50 -0
- package/dist/fields/relation/relation-summary.module.js +11 -0
- package/dist/fields/relation/relation-summary_module.css +37 -0
- package/dist/fields/select/select-field.d.ts +16 -0
- package/dist/fields/select/select-field.js +50 -0
- package/dist/fields/select/select-field.module.js +5 -0
- package/dist/fields/select/select-field_module.css +4 -0
- package/dist/fields/sortable-item.d.ts +15 -0
- package/dist/fields/sortable-item.js +81 -0
- package/dist/fields/sortable-item.module.js +22 -0
- package/dist/fields/sortable-item_module.css +124 -0
- package/dist/fields/text/text-field.d.ts +20 -0
- package/dist/fields/text/text-field.js +104 -0
- package/dist/fields/text/text-field.module.js +6 -0
- package/dist/fields/text/text-field_module.css +5 -0
- package/dist/fields/text-area/text-area-field.d.ts +20 -0
- package/dist/fields/text-area/text-area-field.js +105 -0
- package/dist/fields/text-area/text-area-field.module.js +6 -0
- package/dist/fields/text-area/text-area-field_module.css +5 -0
- package/dist/fields/use-field-change-handler.d.ts +23 -0
- package/dist/fields/use-field-change-handler.js +52 -0
- package/dist/forms/document-actions.d.ts +48 -0
- package/dist/forms/document-actions.js +475 -0
- package/dist/forms/document-actions.module.js +34 -0
- package/dist/forms/document-actions_module.css +118 -0
- package/dist/forms/form-context.d.ts +89 -0
- package/dist/forms/form-context.js +466 -0
- package/dist/forms/form-renderer.d.ts +98 -0
- package/dist/forms/form-renderer.js +597 -0
- package/dist/forms/form-renderer.module.js +46 -0
- package/dist/forms/form-renderer_module.css +245 -0
- package/dist/forms/navigation-guard.d.ts +54 -0
- package/dist/forms/navigation-guard.js +22 -0
- package/dist/forms/path-widget.d.ts +36 -0
- package/dist/forms/path-widget.js +116 -0
- package/dist/forms/path-widget.module.js +8 -0
- package/dist/forms/path-widget_module.css +29 -0
- package/dist/forms/upload-executor.d.ts +57 -0
- package/dist/forms/upload-executor.js +94 -0
- package/dist/lib/translate-validation-error.d.ts +36 -0
- package/dist/lib/translate-validation-error.js +11 -0
- package/dist/modules/admin-account/commands.d.ts +2 -1
- package/dist/modules/admin-account/commands.js +13 -2
- package/dist/modules/admin-account/components/change-password.js +45 -36
- package/dist/modules/admin-account/components/container.js +185 -134
- package/dist/modules/admin-account/components/preferences.d.ts +8 -0
- package/dist/modules/admin-account/components/preferences.js +152 -0
- package/dist/modules/admin-account/components/preferences.module.js +11 -0
- package/dist/modules/admin-account/components/preferences_module.css +41 -0
- package/dist/modules/admin-account/components/update.js +50 -31
- package/dist/modules/admin-account/index.d.ts +3 -3
- package/dist/modules/admin-account/index.js +2 -2
- package/dist/modules/admin-account/schemas.d.ts +4 -0
- package/dist/modules/admin-account/schemas.js +4 -1
- package/dist/modules/admin-account/service.d.ts +1 -0
- package/dist/modules/admin-account/service.js +8 -0
- package/dist/modules/admin-permissions/components/inspector.js +31 -41
- package/dist/modules/admin-roles/components/create.js +43 -26
- package/dist/modules/admin-roles/components/permissions.js +26 -35
- package/dist/modules/admin-roles/components/update.js +26 -16
- package/dist/modules/admin-users/components/create.js +60 -40
- package/dist/modules/admin-users/components/roles.js +9 -15
- package/dist/modules/admin-users/components/set-password.js +30 -31
- package/dist/modules/admin-users/components/update.js +58 -39
- package/dist/modules/admin-users/dto.js +1 -0
- package/dist/modules/admin-users/repository.d.ts +17 -0
- package/dist/modules/admin-users/schemas.d.ts +4 -0
- package/dist/modules/admin-users/schemas.js +6 -2
- package/dist/modules/auth/components/sign-in-form.js +10 -8
- package/dist/presentation/group.d.ts +27 -0
- package/dist/presentation/group.js +14 -0
- package/dist/presentation/group.module.js +6 -0
- package/dist/presentation/group_module.css +19 -0
- package/dist/presentation/row.d.ts +25 -0
- package/dist/presentation/row.js +8 -0
- package/dist/presentation/row.module.js +5 -0
- package/dist/presentation/row_module.css +18 -0
- package/dist/presentation/tabs.d.ts +25 -0
- package/dist/presentation/tabs.js +39 -0
- package/dist/presentation/tabs.module.js +10 -0
- package/dist/presentation/tabs_module.css +68 -0
- package/dist/react.d.ts +66 -0
- package/dist/react.js +36 -0
- package/dist/services/admin-services-types.d.ts +16 -0
- package/dist/widgets/diff-viewer/diff-modal.d.ts +22 -0
- package/dist/widgets/diff-viewer/diff-modal.js +149 -0
- package/dist/widgets/diff-viewer/diff-modal.module.js +14 -0
- package/dist/widgets/diff-viewer/diff-modal_module.css +56 -0
- package/dist/widgets/status-badge/status-badge.d.ts +25 -0
- package/dist/widgets/status-badge/status-badge.js +37 -0
- package/dist/widgets/status-badge/status-badge.module.js +7 -0
- package/dist/widgets/status-badge/status-badge_module.css +20 -0
- package/package.json +14 -4
- package/src/fields/array/array-field.module.css +48 -0
- package/src/fields/array/array-field.tsx +267 -0
- package/src/fields/blocks/blocks-field.module.css +148 -0
- package/src/fields/blocks/blocks-field.tsx +323 -0
- package/src/fields/checkbox/checkbox-field.module.css +4 -0
- package/src/fields/checkbox/checkbox-field.tsx +54 -0
- package/src/fields/column-formatter.tsx +31 -0
- package/src/fields/date-time-formatter.tsx +22 -0
- package/src/fields/datetime/datetime-field.module.css +13 -0
- package/src/fields/datetime/datetime-field.tsx +54 -0
- package/src/fields/draggable-context-menu.module.css +127 -0
- package/src/fields/draggable-context-menu.tsx +87 -0
- package/src/fields/field-helpers.ts +69 -0
- package/src/fields/field-renderer.module.css +22 -0
- package/src/fields/field-renderer.tsx +288 -0
- package/src/fields/field-services-context.tsx +35 -0
- package/src/fields/field-services-types.ts +68 -0
- package/src/fields/file/file-field.module.css +153 -0
- package/src/fields/file/file-field.tsx +286 -0
- package/src/fields/file/file-upload-field.module.css +101 -0
- package/src/fields/file/file-upload-field.tsx +187 -0
- package/src/fields/group/group-field.module.css +43 -0
- package/src/fields/group/group-field.tsx +84 -0
- package/src/fields/image/image-field.module.css +155 -0
- package/src/fields/image/image-field.tsx +306 -0
- package/src/fields/image/image-upload-field.module.css +123 -0
- package/src/fields/image/image-upload-field.tsx +276 -0
- package/src/fields/local-date-time.tsx +88 -0
- package/src/fields/locale-badge.module.css +37 -0
- package/src/fields/locale-badge.tsx +32 -0
- package/src/fields/numerical/numerical-field.tsx +114 -0
- package/src/fields/relation/relation-display.module.css +36 -0
- package/src/fields/relation/relation-display.tsx +130 -0
- package/src/fields/relation/relation-field.module.css +83 -0
- package/src/fields/relation/relation-field.tsx +211 -0
- package/src/fields/relation/relation-picker.module.css +168 -0
- package/src/fields/relation/relation-picker.tsx +326 -0
- package/src/fields/relation/relation-summary.module.css +55 -0
- package/src/fields/relation/relation-summary.tsx +123 -0
- package/src/fields/select/select-field.module.css +13 -0
- package/src/fields/select/select-field.tsx +61 -0
- package/src/fields/sortable-item.module.css +167 -0
- package/src/fields/sortable-item.tsx +106 -0
- package/src/fields/text/text-field.module.css +13 -0
- package/src/fields/text/text-field.tsx +146 -0
- package/src/fields/text-area/text-area-field.module.css +13 -0
- package/src/fields/text-area/text-area-field.tsx +147 -0
- package/src/fields/use-field-change-handler.ts +112 -0
- package/src/forms/document-actions.module.css +160 -0
- package/src/forms/document-actions.tsx +482 -0
- package/src/forms/form-context.tsx +704 -0
- package/src/forms/form-renderer.module.css +321 -0
- package/src/forms/form-renderer.tsx +891 -0
- package/src/forms/navigation-guard.tsx +98 -0
- package/src/forms/path-widget.module.css +41 -0
- package/src/forms/path-widget.test.tsx +217 -0
- package/src/forms/path-widget.tsx +183 -0
- package/src/forms/upload-executor.ts +192 -0
- package/src/lib/translate-validation-error.ts +56 -0
- package/src/modules/admin-account/commands.ts +13 -0
- package/src/modules/admin-account/components/change-password.tsx +46 -31
- package/src/modules/admin-account/components/container.tsx +83 -38
- package/src/modules/admin-account/components/preferences.module.css +60 -0
- package/src/modules/admin-account/components/preferences.tsx +203 -0
- package/src/modules/admin-account/components/update.tsx +53 -27
- package/src/modules/admin-account/index.ts +3 -0
- package/src/modules/admin-account/schemas.ts +13 -0
- package/src/modules/admin-account/service.ts +12 -0
- package/src/modules/admin-permissions/components/inspector.tsx +22 -14
- package/src/modules/admin-roles/components/create.tsx +51 -23
- package/src/modules/admin-roles/components/permissions.tsx +25 -21
- package/src/modules/admin-roles/components/update.tsx +37 -19
- package/src/modules/admin-users/components/create.tsx +63 -34
- package/src/modules/admin-users/components/roles.tsx +9 -8
- package/src/modules/admin-users/components/set-password.tsx +34 -28
- package/src/modules/admin-users/components/update.tsx +58 -36
- package/src/modules/admin-users/dto.ts +1 -0
- package/src/modules/admin-users/repository.ts +17 -0
- package/src/modules/admin-users/schemas.ts +12 -0
- package/src/modules/auth/components/sign-in-form.tsx +14 -8
- package/src/presentation/group.module.css +41 -0
- package/src/presentation/group.tsx +40 -0
- package/src/presentation/row.module.css +32 -0
- package/src/presentation/row.tsx +33 -0
- package/src/presentation/tabs.module.css +107 -0
- package/src/presentation/tabs.tsx +84 -0
- package/src/react.ts +84 -0
- package/src/services/admin-services-types.ts +18 -0
- package/src/widgets/diff-viewer/diff-modal.module.css +79 -0
- package/src/widgets/diff-viewer/diff-modal.tsx +186 -0
- package/src/widgets/status-badge/status-badge.module.css +31 -0
- package/src/widgets/status-badge/status-badge.tsx +71 -0
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useRef, useState } from "react";
|
|
3
|
+
import { createPendingStoredFileValue } from "@byline/core";
|
|
4
|
+
import { useTranslation } from "@byline/i18n/react";
|
|
5
|
+
import classnames from "classnames";
|
|
6
|
+
import { useFormContext } from "../../forms/form-context.js";
|
|
7
|
+
import image_upload_field_module from "./image-upload-field.module.js";
|
|
8
|
+
const ImageUploadField = ({ field: _field, collectionPath, fieldPath, onUploaded, accept = 'image/*' })=>{
|
|
9
|
+
const inputRef = useRef(null);
|
|
10
|
+
const [status, setStatus] = useState('idle');
|
|
11
|
+
const [errorMessage, setErrorMessage] = useState(null);
|
|
12
|
+
const [isDragOver, setIsDragOver] = useState(false);
|
|
13
|
+
const { addPendingUpload } = useFormContext();
|
|
14
|
+
const { t } = useTranslation('byline-admin');
|
|
15
|
+
const handleFileSelected = useCallback((file)=>{
|
|
16
|
+
setStatus('processing');
|
|
17
|
+
setErrorMessage(null);
|
|
18
|
+
if (!file.type.startsWith('image/')) {
|
|
19
|
+
setStatus('error');
|
|
20
|
+
setErrorMessage(t('fields.image.upload.errors.notAnImage'));
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const previewUrl = URL.createObjectURL(file);
|
|
24
|
+
const img = new Image();
|
|
25
|
+
img.onload = ()=>{
|
|
26
|
+
const w = img.naturalWidth;
|
|
27
|
+
const h = img.naturalHeight;
|
|
28
|
+
const dimensions = w > 0 && h > 0 ? {
|
|
29
|
+
width: w,
|
|
30
|
+
height: h
|
|
31
|
+
} : void 0;
|
|
32
|
+
const pendingValue = createPendingStoredFileValue(file, previewUrl, dimensions);
|
|
33
|
+
addPendingUpload(fieldPath, {
|
|
34
|
+
file,
|
|
35
|
+
previewUrl,
|
|
36
|
+
collectionPath
|
|
37
|
+
});
|
|
38
|
+
setStatus('idle');
|
|
39
|
+
onUploaded(pendingValue);
|
|
40
|
+
};
|
|
41
|
+
img.onerror = ()=>{
|
|
42
|
+
URL.revokeObjectURL(previewUrl);
|
|
43
|
+
setStatus('error');
|
|
44
|
+
setErrorMessage(t('fields.image.upload.errors.cannotRead'));
|
|
45
|
+
};
|
|
46
|
+
img.src = previewUrl;
|
|
47
|
+
}, [
|
|
48
|
+
collectionPath,
|
|
49
|
+
fieldPath,
|
|
50
|
+
addPendingUpload,
|
|
51
|
+
onUploaded,
|
|
52
|
+
t
|
|
53
|
+
]);
|
|
54
|
+
const handleFileChange = useCallback((e)=>{
|
|
55
|
+
const file = e.target.files?.[0];
|
|
56
|
+
if (file) handleFileSelected(file);
|
|
57
|
+
e.target.value = '';
|
|
58
|
+
}, [
|
|
59
|
+
handleFileSelected
|
|
60
|
+
]);
|
|
61
|
+
const handleBrowseClick = useCallback(()=>{
|
|
62
|
+
inputRef.current?.click();
|
|
63
|
+
}, []);
|
|
64
|
+
const handleDragOver = useCallback((e)=>{
|
|
65
|
+
e.preventDefault();
|
|
66
|
+
setIsDragOver(true);
|
|
67
|
+
}, []);
|
|
68
|
+
const handleDragLeave = useCallback((e)=>{
|
|
69
|
+
e.preventDefault();
|
|
70
|
+
setIsDragOver(false);
|
|
71
|
+
}, []);
|
|
72
|
+
const handleDrop = useCallback((e)=>{
|
|
73
|
+
e.preventDefault();
|
|
74
|
+
setIsDragOver(false);
|
|
75
|
+
const file = e.dataTransfer.files?.[0];
|
|
76
|
+
if (file) handleFileSelected(file);
|
|
77
|
+
}, [
|
|
78
|
+
handleFileSelected
|
|
79
|
+
]);
|
|
80
|
+
const isProcessing = 'processing' === status;
|
|
81
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
82
|
+
className: classnames('byline-field-image-upload', image_upload_field_module.root),
|
|
83
|
+
children: [
|
|
84
|
+
/*#__PURE__*/ jsx("input", {
|
|
85
|
+
ref: inputRef,
|
|
86
|
+
type: "file",
|
|
87
|
+
accept: accept,
|
|
88
|
+
className: classnames('byline-field-image-upload-input', image_upload_field_module.input),
|
|
89
|
+
onChange: handleFileChange,
|
|
90
|
+
disabled: isProcessing,
|
|
91
|
+
"aria-hidden": "true",
|
|
92
|
+
tabIndex: -1
|
|
93
|
+
}),
|
|
94
|
+
/*#__PURE__*/ jsx("div", {
|
|
95
|
+
role: "button",
|
|
96
|
+
tabIndex: 0,
|
|
97
|
+
"aria-label": t('fields.image.upload.zoneAriaLabel'),
|
|
98
|
+
onDragOver: handleDragOver,
|
|
99
|
+
onDragLeave: handleDragLeave,
|
|
100
|
+
onDrop: handleDrop,
|
|
101
|
+
onClick: handleBrowseClick,
|
|
102
|
+
onKeyDown: (e)=>{
|
|
103
|
+
if ('Enter' === e.key || ' ' === e.key) {
|
|
104
|
+
e.preventDefault();
|
|
105
|
+
handleBrowseClick();
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
className: classnames('byline-field-image-upload-zone', image_upload_field_module.zone, isDragOver && !isProcessing && [
|
|
109
|
+
'byline-field-image-upload-zone-active',
|
|
110
|
+
image_upload_field_module["zone-active"]
|
|
111
|
+
], isProcessing && [
|
|
112
|
+
'byline-field-image-upload-zone-busy',
|
|
113
|
+
image_upload_field_module["zone-busy"]
|
|
114
|
+
]),
|
|
115
|
+
children: isProcessing ? /*#__PURE__*/ jsxs(Fragment, {
|
|
116
|
+
children: [
|
|
117
|
+
/*#__PURE__*/ jsxs("svg", {
|
|
118
|
+
className: classnames('byline-field-image-upload-spinner', image_upload_field_module.spinner),
|
|
119
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
120
|
+
fill: "none",
|
|
121
|
+
viewBox: "0 0 24 24",
|
|
122
|
+
"aria-hidden": "true",
|
|
123
|
+
children: [
|
|
124
|
+
/*#__PURE__*/ jsx("circle", {
|
|
125
|
+
style: {
|
|
126
|
+
opacity: 0.25
|
|
127
|
+
},
|
|
128
|
+
cx: "12",
|
|
129
|
+
cy: "12",
|
|
130
|
+
r: "10",
|
|
131
|
+
stroke: "currentColor",
|
|
132
|
+
strokeWidth: "4"
|
|
133
|
+
}),
|
|
134
|
+
/*#__PURE__*/ jsx("path", {
|
|
135
|
+
style: {
|
|
136
|
+
opacity: 0.75
|
|
137
|
+
},
|
|
138
|
+
fill: "currentColor",
|
|
139
|
+
d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"
|
|
140
|
+
})
|
|
141
|
+
]
|
|
142
|
+
}),
|
|
143
|
+
/*#__PURE__*/ jsx("span", {
|
|
144
|
+
className: classnames('byline-field-image-upload-label', image_upload_field_module.label),
|
|
145
|
+
children: t('fields.image.upload.processing')
|
|
146
|
+
})
|
|
147
|
+
]
|
|
148
|
+
}) : /*#__PURE__*/ jsxs(Fragment, {
|
|
149
|
+
children: [
|
|
150
|
+
/*#__PURE__*/ jsx("svg", {
|
|
151
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
152
|
+
className: classnames('byline-field-image-upload-icon', image_upload_field_module.icon),
|
|
153
|
+
fill: "none",
|
|
154
|
+
viewBox: "0 0 24 24",
|
|
155
|
+
stroke: "currentColor",
|
|
156
|
+
strokeWidth: 1.5,
|
|
157
|
+
"aria-hidden": "true",
|
|
158
|
+
children: /*#__PURE__*/ jsx("path", {
|
|
159
|
+
strokeLinecap: "round",
|
|
160
|
+
strokeLinejoin: "round",
|
|
161
|
+
d: "M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5m-13.5-9L12 3m0 0l4.5 4.5M12 3v13.5"
|
|
162
|
+
})
|
|
163
|
+
}),
|
|
164
|
+
/*#__PURE__*/ jsxs("span", {
|
|
165
|
+
className: classnames('byline-field-image-upload-label', image_upload_field_module.label),
|
|
166
|
+
children: [
|
|
167
|
+
t('fields.image.upload.label'),
|
|
168
|
+
' ',
|
|
169
|
+
/*#__PURE__*/ jsx("span", {
|
|
170
|
+
className: classnames('byline-field-image-upload-action', image_upload_field_module.action),
|
|
171
|
+
children: t('fields.image.upload.browse')
|
|
172
|
+
})
|
|
173
|
+
]
|
|
174
|
+
}),
|
|
175
|
+
/*#__PURE__*/ jsx("span", {
|
|
176
|
+
className: classnames('byline-field-image-upload-hint', image_upload_field_module.hint),
|
|
177
|
+
children: t('fields.image.upload.hint')
|
|
178
|
+
})
|
|
179
|
+
]
|
|
180
|
+
})
|
|
181
|
+
}),
|
|
182
|
+
'error' === status && errorMessage && /*#__PURE__*/ jsx("p", {
|
|
183
|
+
className: classnames('byline-field-image-upload-error', image_upload_field_module.error),
|
|
184
|
+
role: "alert",
|
|
185
|
+
children: errorMessage
|
|
186
|
+
})
|
|
187
|
+
]
|
|
188
|
+
});
|
|
189
|
+
};
|
|
190
|
+
export { ImageUploadField };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import "./image-upload-field_module.css";
|
|
2
|
+
const image_upload_field_module = {
|
|
3
|
+
root: "root-RQ8s0u",
|
|
4
|
+
input: "input-DnqmLy",
|
|
5
|
+
zone: "zone-ZQQueP",
|
|
6
|
+
"zone-active": "zone-active-GgYY5w",
|
|
7
|
+
zoneActive: "zone-active-GgYY5w",
|
|
8
|
+
"zone-busy": "zone-busy-QscsjT",
|
|
9
|
+
zoneBusy: "zone-busy-QscsjT",
|
|
10
|
+
spinner: "spinner-vgmURt",
|
|
11
|
+
"byline-image-upload-spin": "byline-image-upload-spin-PnC9WU",
|
|
12
|
+
bylineImageUploadSpin: "byline-image-upload-spin-PnC9WU",
|
|
13
|
+
icon: "icon-ZueG4I",
|
|
14
|
+
label: "label-jdwMD2",
|
|
15
|
+
action: "action-g1CZcT",
|
|
16
|
+
hint: "hint-WOpqdr",
|
|
17
|
+
error: "error-bRg83I"
|
|
18
|
+
};
|
|
19
|
+
export default image_upload_field_module;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
:is(.root-RQ8s0u, .byline-field-image-upload) {
|
|
2
|
+
margin-top: .25rem;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
:is(.input-DnqmLy, .byline-field-image-upload-input) {
|
|
6
|
+
clip: rect(0, 0, 0, 0);
|
|
7
|
+
white-space: nowrap;
|
|
8
|
+
border: 0;
|
|
9
|
+
width: 1px;
|
|
10
|
+
height: 1px;
|
|
11
|
+
margin: -1px;
|
|
12
|
+
padding: 0;
|
|
13
|
+
position: absolute;
|
|
14
|
+
overflow: hidden;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
:is(.zone-ZQQueP, .byline-field-image-upload-zone) {
|
|
18
|
+
justify-content: center;
|
|
19
|
+
align-items: center;
|
|
20
|
+
gap: var(--spacing-8);
|
|
21
|
+
border: 2px dashed var(--gray-600);
|
|
22
|
+
border-radius: var(--border-radius-lg);
|
|
23
|
+
color: var(--gray-400);
|
|
24
|
+
text-align: center;
|
|
25
|
+
cursor: pointer;
|
|
26
|
+
-webkit-user-select: none;
|
|
27
|
+
user-select: none;
|
|
28
|
+
flex-direction: column;
|
|
29
|
+
padding: 1.5rem 1rem;
|
|
30
|
+
transition: color .15s, background-color .15s, border-color .15s;
|
|
31
|
+
display: flex;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
:is(.zone-ZQQueP:hover, .byline-field-image-upload-zone:hover) {
|
|
35
|
+
border-color: var(--primary-500);
|
|
36
|
+
background-color: oklch(from var(--primary-900) l c h / .1);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
:is(.zone-active-GgYY5w, .byline-field-image-upload-zone-active) {
|
|
40
|
+
border-color: var(--primary-400);
|
|
41
|
+
background-color: oklch(from var(--primary-900) l c h / .2);
|
|
42
|
+
color: var(--primary-300);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
:is(.zone-busy-QscsjT, .byline-field-image-upload-zone-busy) {
|
|
46
|
+
border-color: var(--gray-700);
|
|
47
|
+
background-color: oklch(from var(--canvas-800) l c h / .5);
|
|
48
|
+
color: var(--gray-600);
|
|
49
|
+
cursor: not-allowed;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
:is(.spinner-vgmURt, .byline-field-image-upload-spinner) {
|
|
53
|
+
width: 1.5rem;
|
|
54
|
+
height: 1.5rem;
|
|
55
|
+
color: var(--primary-400);
|
|
56
|
+
animation: 1s linear infinite byline-image-upload-spin-PnC9WU;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
@keyframes byline-image-upload-spin-PnC9WU {
|
|
60
|
+
to {
|
|
61
|
+
transform: rotate(360deg);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
:is(.icon-ZueG4I, .byline-field-image-upload-icon) {
|
|
66
|
+
opacity: .6;
|
|
67
|
+
width: 1.75rem;
|
|
68
|
+
height: 1.75rem;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
:is(.label-jdwMD2, .byline-field-image-upload-label) {
|
|
72
|
+
font-size: var(--font-size-xs);
|
|
73
|
+
font-weight: var(--font-weight-medium);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
:is(.action-g1CZcT, .byline-field-image-upload-action) {
|
|
77
|
+
color: var(--primary-400);
|
|
78
|
+
text-underline-offset: 2px;
|
|
79
|
+
text-decoration: underline;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
:is(.hint-WOpqdr, .byline-field-image-upload-hint) {
|
|
83
|
+
color: var(--gray-500);
|
|
84
|
+
font-size: .65rem;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
:is(.error-bRg83I, .byline-field-image-upload-error) {
|
|
88
|
+
color: var(--red-400);
|
|
89
|
+
font-size: var(--font-size-xs);
|
|
90
|
+
margin-top: .375rem;
|
|
91
|
+
}
|
|
92
|
+
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
interface LocalDateTimeProps {
|
|
2
|
+
value: string | Date | null | undefined;
|
|
3
|
+
mode?: 'datetime' | 'date';
|
|
4
|
+
className?: string;
|
|
5
|
+
fallback?: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Client-side date/time formatter that displays dates in the user's local timezone.
|
|
9
|
+
*
|
|
10
|
+
* This component avoids hydration mismatches by:
|
|
11
|
+
* 1. Rendering a placeholder on the server/initial render
|
|
12
|
+
* 2. Updating to the correctly formatted date after hydration
|
|
13
|
+
*
|
|
14
|
+
* Use this instead of formatDateTime when you need to display dates
|
|
15
|
+
* in the user's local timezone rather than UTC.
|
|
16
|
+
*/
|
|
17
|
+
export declare function LocalDateTime({ value, mode, className, fallback, }: LocalDateTimeProps): React.JSX.Element;
|
|
18
|
+
/**
|
|
19
|
+
* Formats a date string to the user's local timezone.
|
|
20
|
+
*
|
|
21
|
+
* WARNING: Only use this in client components where hydration
|
|
22
|
+
* mismatches are acceptable or managed. For most cases, prefer
|
|
23
|
+
* the <LocalDateTime /> component.
|
|
24
|
+
*/
|
|
25
|
+
export declare function formatLocalDateTime(value: string | Date | null | undefined): string;
|
|
26
|
+
export declare function formatLocalDate(value: string | Date | null | undefined): string;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useState } from "react";
|
|
4
|
+
const dateTimeFormatter = new Intl.DateTimeFormat(void 0, {
|
|
5
|
+
year: 'numeric',
|
|
6
|
+
month: 'short',
|
|
7
|
+
day: '2-digit',
|
|
8
|
+
hour: 'numeric',
|
|
9
|
+
minute: 'numeric'
|
|
10
|
+
});
|
|
11
|
+
const dateFormatter = new Intl.DateTimeFormat(void 0, {
|
|
12
|
+
year: 'numeric',
|
|
13
|
+
month: 'short',
|
|
14
|
+
day: '2-digit'
|
|
15
|
+
});
|
|
16
|
+
function LocalDateTime({ value, mode = 'datetime', className, fallback = '—' }) {
|
|
17
|
+
const [formattedDate, setFormattedDate] = useState(null);
|
|
18
|
+
useEffect(()=>{
|
|
19
|
+
if (null == value) return void setFormattedDate(null);
|
|
20
|
+
const date = 'string' == typeof value ? Date.parse(value) : value.getTime();
|
|
21
|
+
if (Number.isNaN(date)) return void setFormattedDate('Error');
|
|
22
|
+
const formatter = 'datetime' === mode ? dateTimeFormatter : dateFormatter;
|
|
23
|
+
setFormattedDate(formatter.format(date));
|
|
24
|
+
}, [
|
|
25
|
+
value,
|
|
26
|
+
mode
|
|
27
|
+
]);
|
|
28
|
+
if (null === formattedDate) return /*#__PURE__*/ jsx("span", {
|
|
29
|
+
className: className,
|
|
30
|
+
children: value ? '...' : fallback
|
|
31
|
+
});
|
|
32
|
+
return /*#__PURE__*/ jsx("span", {
|
|
33
|
+
className: className,
|
|
34
|
+
children: formattedDate
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
function formatLocalDateTime(value) {
|
|
38
|
+
if (null == value) return '—';
|
|
39
|
+
const date = 'string' == typeof value ? Date.parse(value) : value.getTime();
|
|
40
|
+
if (Number.isNaN(date)) return 'Error';
|
|
41
|
+
return dateTimeFormatter.format(date);
|
|
42
|
+
}
|
|
43
|
+
function formatLocalDate(value) {
|
|
44
|
+
if (null == value) return '—';
|
|
45
|
+
const date = 'string' == typeof value ? Date.parse(value) : value.getTime();
|
|
46
|
+
if (Number.isNaN(date)) return 'Error';
|
|
47
|
+
return dateFormatter.format(date);
|
|
48
|
+
}
|
|
49
|
+
export { LocalDateTime, formatLocalDate, formatLocalDateTime };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This Source Code is subject to the terms of the Mozilla Public
|
|
3
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
4
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) Infonomic Company Limited
|
|
7
|
+
*/
|
|
8
|
+
export interface LocaleBadgeProps {
|
|
9
|
+
locale: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Small inline badge shown next to the label of a field that has
|
|
13
|
+
* `localized: true` in its schema definition. Indicates which locale
|
|
14
|
+
* the editor is currently working in.
|
|
15
|
+
*
|
|
16
|
+
* Stable override handle: `.byline-locale-badge`.
|
|
17
|
+
*/
|
|
18
|
+
export declare const LocaleBadge: ({ locale }: LocaleBadgeProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import classnames from "classnames";
|
|
3
|
+
import locale_badge_module from "./locale-badge.module.js";
|
|
4
|
+
const LocaleBadge = ({ locale })=>/*#__PURE__*/ jsx("span", {
|
|
5
|
+
"aria-hidden": "true",
|
|
6
|
+
title: `Localised — editing ${locale.toUpperCase()} content`,
|
|
7
|
+
className: classnames('byline-locale-badge', locale_badge_module.badge),
|
|
8
|
+
children: locale
|
|
9
|
+
});
|
|
10
|
+
export { LocaleBadge };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
:is(.badge-w0AW86, .byline-locale-badge) {
|
|
2
|
+
border: var(--border-width-thin) var(--border-style-solid) var(--yellow-400);
|
|
3
|
+
border-radius: var(--border-radius-sm);
|
|
4
|
+
background-color: var(--yellow-100);
|
|
5
|
+
color: var(--yellow-800);
|
|
6
|
+
font-size: .6rem;
|
|
7
|
+
font-weight: var(--font-weight-semibold);
|
|
8
|
+
letter-spacing: var(--letter-spacing-wide);
|
|
9
|
+
text-transform: uppercase;
|
|
10
|
+
pointer-events: none;
|
|
11
|
+
-webkit-user-select: none;
|
|
12
|
+
user-select: none;
|
|
13
|
+
vertical-align: middle;
|
|
14
|
+
align-items: center;
|
|
15
|
+
gap: .125rem;
|
|
16
|
+
margin-left: .375rem;
|
|
17
|
+
padding: .125rem .375rem;
|
|
18
|
+
line-height: 1;
|
|
19
|
+
display: inline-flex;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
:is(:is([data-theme="dark"], .dark) .badge-w0AW86, :is([data-theme="dark"], .dark) .byline-locale-badge) {
|
|
23
|
+
border-color: var(--yellow-700);
|
|
24
|
+
background-color: oklch(from var(--yellow-900) l c h / .4);
|
|
25
|
+
color: var(--yellow-400);
|
|
26
|
+
}
|
|
27
|
+
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This Source Code is subject to the terms of the Mozilla Public
|
|
3
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
4
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) Infonomic Company Limited
|
|
7
|
+
*/
|
|
8
|
+
import type { CounterField, DecimalField, FieldComponentSlots, FloatField, IntegerField } from '@byline/core';
|
|
9
|
+
export declare const NumericalField: ({ field, value, defaultValue, onChange, id, path, components, }: {
|
|
10
|
+
field: IntegerField | FloatField | DecimalField | CounterField;
|
|
11
|
+
value?: string | number | null;
|
|
12
|
+
defaultValue?: string | number | null;
|
|
13
|
+
onChange?: (value: string) => void;
|
|
14
|
+
id?: string;
|
|
15
|
+
path?: string;
|
|
16
|
+
/** Optional UI component slot overrides from the admin config. */
|
|
17
|
+
components?: FieldComponentSlots;
|
|
18
|
+
}) => import("react").JSX.Element;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Input } from "@byline/ui/react";
|
|
3
|
+
import { useFieldError, useFieldValue } from "../../forms/form-context.js";
|
|
4
|
+
const NumericalField = ({ field, value, defaultValue, onChange, id, path, components })=>{
|
|
5
|
+
const fieldPath = path ?? field.name;
|
|
6
|
+
const fieldError = useFieldError(fieldPath);
|
|
7
|
+
const fieldValue = useFieldValue(fieldPath);
|
|
8
|
+
const incomingValue = value ?? fieldValue ?? defaultValue ?? '';
|
|
9
|
+
const htmlId = id ?? fieldPath;
|
|
10
|
+
const displayValue = null == incomingValue ? '' : String(incomingValue);
|
|
11
|
+
const slots = components;
|
|
12
|
+
const CustomLabel = slots?.Label;
|
|
13
|
+
const CustomHelpText = slots?.HelpText;
|
|
14
|
+
const CustomField = slots?.Field;
|
|
15
|
+
const BeforeField = slots?.beforeField;
|
|
16
|
+
const AfterField = slots?.afterField;
|
|
17
|
+
const slotBaseProps = {
|
|
18
|
+
field: field,
|
|
19
|
+
path: fieldPath,
|
|
20
|
+
value: incomingValue,
|
|
21
|
+
error: fieldError,
|
|
22
|
+
id: htmlId
|
|
23
|
+
};
|
|
24
|
+
const hasCustomLabel = !!CustomLabel;
|
|
25
|
+
const suppressInputLabel = hasCustomLabel;
|
|
26
|
+
const suppressInputHelpText = !!CustomHelpText;
|
|
27
|
+
const renderLabel = ()=>{
|
|
28
|
+
if (hasCustomLabel) return /*#__PURE__*/ jsx(CustomLabel, {
|
|
29
|
+
...slotBaseProps,
|
|
30
|
+
label: field.label,
|
|
31
|
+
required: !field.optional
|
|
32
|
+
});
|
|
33
|
+
return null;
|
|
34
|
+
};
|
|
35
|
+
const renderInput = ()=>{
|
|
36
|
+
if (CustomField) return /*#__PURE__*/ jsx(CustomField, {
|
|
37
|
+
...slotBaseProps,
|
|
38
|
+
onChange: (v)=>onChange?.(v),
|
|
39
|
+
defaultValue: defaultValue,
|
|
40
|
+
placeholder: field.placeholder
|
|
41
|
+
});
|
|
42
|
+
return /*#__PURE__*/ jsx(Input, {
|
|
43
|
+
type: "number",
|
|
44
|
+
id: htmlId,
|
|
45
|
+
name: field.name,
|
|
46
|
+
label: suppressInputLabel ? void 0 : field.label,
|
|
47
|
+
required: !field.optional,
|
|
48
|
+
readOnly: field.readOnly,
|
|
49
|
+
helpText: suppressInputHelpText ? void 0 : field.helpText,
|
|
50
|
+
value: displayValue,
|
|
51
|
+
onChange: (e)=>onChange?.(e.target.value),
|
|
52
|
+
error: null != fieldError,
|
|
53
|
+
errorText: fieldError
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
57
|
+
className: `byline-field-${field.type} ${field.name}`,
|
|
58
|
+
children: [
|
|
59
|
+
renderLabel(),
|
|
60
|
+
BeforeField && /*#__PURE__*/ jsx(BeforeField, {
|
|
61
|
+
...slotBaseProps
|
|
62
|
+
}),
|
|
63
|
+
renderInput(),
|
|
64
|
+
AfterField && /*#__PURE__*/ jsx(AfterField, {
|
|
65
|
+
...slotBaseProps
|
|
66
|
+
}),
|
|
67
|
+
CustomHelpText && /*#__PURE__*/ jsx(CustomHelpText, {
|
|
68
|
+
...slotBaseProps,
|
|
69
|
+
helpText: field.helpText
|
|
70
|
+
})
|
|
71
|
+
]
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
export { NumericalField };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This Source Code is subject to the terms of the Mozilla Public
|
|
3
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
4
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) Infonomic Company Limited
|
|
7
|
+
*/
|
|
8
|
+
import type { CollectionDefinition, ColumnDefinition } from '@byline/core';
|
|
9
|
+
/**
|
|
10
|
+
* Render a single row cell from a `ColumnDefinition`, reading the value
|
|
11
|
+
* from the document's `fields` (with a fallback to top-level metadata like
|
|
12
|
+
* `status`, `updated_at`, `path`). Honours both formatter shapes — plain
|
|
13
|
+
* function → its return value, `{ component }` → the component is rendered.
|
|
14
|
+
*/
|
|
15
|
+
export declare function PickerCell({ column, record, }: {
|
|
16
|
+
column: ColumnDefinition;
|
|
17
|
+
record: Record<string, any>;
|
|
18
|
+
}): import("react").JSX.Element;
|
|
19
|
+
/** First top-level `text` field name on a collection, or null. */
|
|
20
|
+
export declare function resolveFallbackDisplayField(def: CollectionDefinition | null | undefined): string | null;
|
|
21
|
+
/** Resolve the row's primary label text from the document. */
|
|
22
|
+
export declare function resolveRowLabel(doc: Record<string, any> | null | undefined, displayField: string | null): string | null;
|
|
23
|
+
/**
|
|
24
|
+
* Build the `fields` projection for the picker listing. Unions:
|
|
25
|
+
* - caller-supplied `displayField`
|
|
26
|
+
* - target schema's `useAsTitle` (always included, even when not visible)
|
|
27
|
+
* - every `fieldName` declared in the admin config's `picker` columns
|
|
28
|
+
* - `title` (metadata fallback for rows with no explicit picker columns)
|
|
29
|
+
*
|
|
30
|
+
* Note that the document `path` is top-level metadata on every list response
|
|
31
|
+
* — it is always returned by `getCollectionDocuments` regardless of the
|
|
32
|
+
* `fields` projection. Callers that need `{ title, path }` for downstream
|
|
33
|
+
* normalisation (e.g. the rich-text link plugin) can rely on:
|
|
34
|
+
* - `record.fields[def.useAsTitle]` for the title
|
|
35
|
+
* - `record.path` for the path
|
|
36
|
+
*
|
|
37
|
+
* Returns `undefined` when no target definition is available, leaving the
|
|
38
|
+
* listing endpoint to decide its own default projection.
|
|
39
|
+
*/
|
|
40
|
+
export declare function resolveSelectFields(def: CollectionDefinition | null | undefined, displayField: string | undefined, pickerColumns: ColumnDefinition[] | undefined): string[] | undefined;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import classnames from "classnames";
|
|
3
|
+
import relation_display_module from "./relation-display.module.js";
|
|
4
|
+
function PickerCell({ column, record }) {
|
|
5
|
+
const name = String(column.fieldName);
|
|
6
|
+
const value = record?.fields?.[name] ?? record?.[name];
|
|
7
|
+
let content;
|
|
8
|
+
if (column.formatter) if ('function' == typeof column.formatter) content = column.formatter(value, record);
|
|
9
|
+
else {
|
|
10
|
+
const Comp = column.formatter.component;
|
|
11
|
+
content = /*#__PURE__*/ jsx(Comp, {
|
|
12
|
+
value: value,
|
|
13
|
+
record: record
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
else content = null == value ? null : 'string' == typeof value || 'number' == typeof value || 'boolean' == typeof value ? String(value) : null;
|
|
17
|
+
return /*#__PURE__*/ jsx("div", {
|
|
18
|
+
className: classnames('byline-relation-cell', relation_display_module.cell, 'center' === column.align && [
|
|
19
|
+
'byline-relation-cell-center',
|
|
20
|
+
relation_display_module["cell-center"]
|
|
21
|
+
], 'right' === column.align && [
|
|
22
|
+
'byline-relation-cell-right',
|
|
23
|
+
relation_display_module["cell-right"]
|
|
24
|
+
], column.className),
|
|
25
|
+
children: content
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
function resolveFallbackDisplayField(def) {
|
|
29
|
+
if (!def) return null;
|
|
30
|
+
const textField = def.fields.find((f)=>'text' === f.type);
|
|
31
|
+
return textField?.name ?? null;
|
|
32
|
+
}
|
|
33
|
+
function resolveRowLabel(doc, displayField) {
|
|
34
|
+
if (!doc) return null;
|
|
35
|
+
if (displayField) {
|
|
36
|
+
const v = doc.fields?.[displayField];
|
|
37
|
+
if ('string' == typeof v && v.length > 0) return v;
|
|
38
|
+
}
|
|
39
|
+
if ('string' == typeof doc.fields?.title && doc.fields.title.length > 0) return doc.fields.title;
|
|
40
|
+
if ('string' == typeof doc.path && doc.path.length > 0) return doc.path;
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
function resolveSelectFields(def, displayField, pickerColumns) {
|
|
44
|
+
if (!def) return;
|
|
45
|
+
const out = new Set();
|
|
46
|
+
if (displayField) out.add(displayField);
|
|
47
|
+
if (def.useAsTitle) out.add(def.useAsTitle);
|
|
48
|
+
const fallback = resolveFallbackDisplayField(def);
|
|
49
|
+
if (fallback) out.add(fallback);
|
|
50
|
+
if (pickerColumns) for (const col of pickerColumns){
|
|
51
|
+
const name = String(col.fieldName);
|
|
52
|
+
if (def.fields.some((f)=>f.name === name)) out.add(name);
|
|
53
|
+
}
|
|
54
|
+
if (def.fields.some((f)=>'title' === f.name)) out.add('title');
|
|
55
|
+
if (0 === out.size) return;
|
|
56
|
+
return Array.from(out);
|
|
57
|
+
}
|
|
58
|
+
export { PickerCell, resolveFallbackDisplayField, resolveRowLabel, resolveSelectFields };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import "./relation-display_module.css";
|
|
2
|
+
const relation_display_module = {
|
|
3
|
+
cell: "cell-ax9SO1",
|
|
4
|
+
"cell-center": "cell-center-DhmZOy",
|
|
5
|
+
cellCenter: "cell-center-DhmZOy",
|
|
6
|
+
"cell-right": "cell-right-GKn6SW",
|
|
7
|
+
cellRight: "cell-right-GKn6SW"
|
|
8
|
+
};
|
|
9
|
+
export default relation_display_module;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
:is(.cell-ax9SO1, .byline-relation-cell) {
|
|
2
|
+
min-width: 0;
|
|
3
|
+
color: var(--gray-700);
|
|
4
|
+
font-size: var(--font-size-sm);
|
|
5
|
+
text-overflow: ellipsis;
|
|
6
|
+
white-space: nowrap;
|
|
7
|
+
overflow: hidden;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
:is(.cell-center-DhmZOy, .byline-relation-cell-center) {
|
|
11
|
+
text-align: center;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
:is(.cell-right-GKn6SW, .byline-relation-cell-right) {
|
|
15
|
+
text-align: right;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
:is(:is([data-theme="dark"], .dark) .cell-ax9SO1, :is([data-theme="dark"], .dark) .byline-relation-cell) {
|
|
19
|
+
color: var(--gray-100);
|
|
20
|
+
}
|
|
21
|
+
|