@byline/admin 2.5.2 → 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,8 @@
|
|
|
1
|
+
import "./field-renderer_module.css";
|
|
2
|
+
const field_renderer_module = {
|
|
3
|
+
"localized-wrap": "localized-wrap-bv51Y7",
|
|
4
|
+
localizedWrap: "localized-wrap-bv51Y7",
|
|
5
|
+
"localized-badge": "localized-badge-D5MrbH",
|
|
6
|
+
localizedBadge: "localized-badge-D5MrbH"
|
|
7
|
+
};
|
|
8
|
+
export default field_renderer_module;
|
|
@@ -0,0 +1,16 @@
|
|
|
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 ReactNode } from 'react';
|
|
9
|
+
import type { BylineFieldServices } from './field-services-types';
|
|
10
|
+
interface BylineFieldServicesProviderProps {
|
|
11
|
+
services: BylineFieldServices;
|
|
12
|
+
children: ReactNode;
|
|
13
|
+
}
|
|
14
|
+
export declare const BylineFieldServicesProvider: ({ services, children, }: BylineFieldServicesProviderProps) => import("react").JSX.Element;
|
|
15
|
+
export declare const useBylineFieldServices: () => BylineFieldServices;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext } from "react";
|
|
3
|
+
const FieldServicesContext = /*#__PURE__*/ createContext(null);
|
|
4
|
+
const BylineFieldServicesProvider = ({ services, children })=>/*#__PURE__*/ jsx(FieldServicesContext.Provider, {
|
|
5
|
+
value: services,
|
|
6
|
+
children: children
|
|
7
|
+
});
|
|
8
|
+
const useBylineFieldServices = ()=>{
|
|
9
|
+
const ctx = useContext(FieldServicesContext);
|
|
10
|
+
if (!ctx) throw new Error('@byline/ui: BylineFieldServicesProvider missing. Wrap your admin tree with <BylineFieldServicesProvider services={…} />.');
|
|
11
|
+
return ctx;
|
|
12
|
+
};
|
|
13
|
+
export { BylineFieldServicesProvider, useBylineFieldServices };
|
|
@@ -0,0 +1,63 @@
|
|
|
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
|
+
/**
|
|
9
|
+
* Framework-neutral function contracts that field/form components in
|
|
10
|
+
* `@byline/ui` need from the host application. The host wires concrete
|
|
11
|
+
* implementations via `BylineFieldServicesProvider` — typically thin
|
|
12
|
+
* adapters around TanStack Start server functions, Next.js server
|
|
13
|
+
* actions, or any other RPC-style transport.
|
|
14
|
+
*/
|
|
15
|
+
import type { StoredFileValue } from '@byline/core';
|
|
16
|
+
export interface CollectionListParams {
|
|
17
|
+
page?: number;
|
|
18
|
+
page_size?: number;
|
|
19
|
+
order?: string;
|
|
20
|
+
desc?: boolean;
|
|
21
|
+
query?: string;
|
|
22
|
+
locale?: string;
|
|
23
|
+
status?: string;
|
|
24
|
+
fields?: string[];
|
|
25
|
+
}
|
|
26
|
+
export interface CollectionListDoc {
|
|
27
|
+
id: string;
|
|
28
|
+
path?: string;
|
|
29
|
+
[field: string]: unknown;
|
|
30
|
+
}
|
|
31
|
+
export interface CollectionListResponse {
|
|
32
|
+
docs: CollectionListDoc[];
|
|
33
|
+
meta: {
|
|
34
|
+
totalPages?: number;
|
|
35
|
+
[k: string]: unknown;
|
|
36
|
+
};
|
|
37
|
+
included: {
|
|
38
|
+
collection: {
|
|
39
|
+
id: string;
|
|
40
|
+
[k: string]: unknown;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
export type GetCollectionDocumentsFn = (input: {
|
|
45
|
+
collection: string;
|
|
46
|
+
params: CollectionListParams;
|
|
47
|
+
}) => Promise<CollectionListResponse>;
|
|
48
|
+
export interface UploadedFileResult {
|
|
49
|
+
documentId?: string;
|
|
50
|
+
documentVersionId?: string;
|
|
51
|
+
/**
|
|
52
|
+
* The persisted file value, including the `variants` array with
|
|
53
|
+
* `storagePath`, `storageUrl`, `width`, `height`, and `format` for each
|
|
54
|
+
* generated derivative. Single source of truth — the legacy top-level
|
|
55
|
+
* `variants: { name, url }[]` is gone.
|
|
56
|
+
*/
|
|
57
|
+
storedFile: StoredFileValue;
|
|
58
|
+
}
|
|
59
|
+
export type UploadFieldFn = (collection: string, formData: FormData, createDocument?: boolean) => Promise<UploadedFileResult>;
|
|
60
|
+
export interface BylineFieldServices {
|
|
61
|
+
getCollectionDocuments: GetCollectionDocumentsFn;
|
|
62
|
+
uploadField: UploadFieldFn;
|
|
63
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,19 @@
|
|
|
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 FileField as FieldType, type StoredFileValue } from '@byline/core';
|
|
9
|
+
interface FileFieldProps {
|
|
10
|
+
field: FieldType;
|
|
11
|
+
/** Collection path required to call the /upload endpoint. */
|
|
12
|
+
collectionPath?: string;
|
|
13
|
+
value?: StoredFileValue | null;
|
|
14
|
+
defaultValue?: StoredFileValue | null;
|
|
15
|
+
onChange?: (value: StoredFileValue | null) => void;
|
|
16
|
+
path?: string;
|
|
17
|
+
}
|
|
18
|
+
export declare const FileField: ({ field, collectionPath, value, defaultValue, onChange: _onChange, path, }: FileFieldProps) => import("react").JSX.Element;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { isPendingStoredFileValue } from "@byline/core";
|
|
3
|
+
import { useTranslation } from "@byline/i18n/react";
|
|
4
|
+
import { CloseIcon, DocumentIcon, DownloadIcon, ErrorText, HelpText, IconButton, Label, LoaderRing, VideoIcon } from "@byline/ui/react";
|
|
5
|
+
import classnames from "classnames";
|
|
6
|
+
import { useFieldError, useFieldValue, useFormContext, useIsDirty, useIsFieldUploading } from "../../forms/form-context.js";
|
|
7
|
+
import { useFieldChangeHandler } from "../use-field-change-handler.js";
|
|
8
|
+
import file_field_module from "./file-field.module.js";
|
|
9
|
+
import { FileUploadField } from "./file-upload-field.js";
|
|
10
|
+
function triggerDownload(url, filename) {
|
|
11
|
+
if ("u" < typeof document) return;
|
|
12
|
+
const a = document.createElement('a');
|
|
13
|
+
a.href = url;
|
|
14
|
+
if (filename) a.download = filename;
|
|
15
|
+
a.target = '_blank';
|
|
16
|
+
a.rel = 'noreferrer';
|
|
17
|
+
document.body.appendChild(a);
|
|
18
|
+
a.click();
|
|
19
|
+
document.body.removeChild(a);
|
|
20
|
+
}
|
|
21
|
+
const FileField = ({ field, collectionPath, value, defaultValue, onChange: _onChange, path })=>{
|
|
22
|
+
const fieldPath = path ?? field.name;
|
|
23
|
+
const { t } = useTranslation('byline-admin');
|
|
24
|
+
const fieldError = useFieldError(fieldPath);
|
|
25
|
+
const isDirty = useIsDirty(fieldPath);
|
|
26
|
+
const fieldValue = useFieldValue(fieldPath);
|
|
27
|
+
const isUploading = useIsFieldUploading(fieldPath);
|
|
28
|
+
const { removePendingUpload } = useFormContext();
|
|
29
|
+
const handleChange = useFieldChangeHandler(field, fieldPath);
|
|
30
|
+
const incomingValue = isDirty ? fieldValue ?? null : value ?? fieldValue ?? defaultValue ?? null;
|
|
31
|
+
const isPending = isPendingStoredFileValue(incomingValue);
|
|
32
|
+
const isOldPlaceholder = (v)=>{
|
|
33
|
+
if (!v || 'object' != typeof v) return false;
|
|
34
|
+
const maybe = v;
|
|
35
|
+
return 'placeholder' === maybe.storageProvider && 'pending' === maybe.storagePath;
|
|
36
|
+
};
|
|
37
|
+
const showUploadWidget = null == incomingValue || isOldPlaceholder(incomingValue);
|
|
38
|
+
const handleRemove = ()=>{
|
|
39
|
+
if (isPending) removePendingUpload(fieldPath);
|
|
40
|
+
handleChange(null);
|
|
41
|
+
};
|
|
42
|
+
const isVideo = incomingValue?.mimeType?.startsWith('video/') === true;
|
|
43
|
+
const FileGlyph = isVideo ? VideoIcon : DocumentIcon;
|
|
44
|
+
const htmlId = fieldPath;
|
|
45
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
46
|
+
className: `byline-field-file ${field.name}`,
|
|
47
|
+
children: [
|
|
48
|
+
/*#__PURE__*/ jsx("div", {
|
|
49
|
+
className: classnames('byline-field-file-header', file_field_module.header),
|
|
50
|
+
children: /*#__PURE__*/ jsx(Label, {
|
|
51
|
+
id: htmlId,
|
|
52
|
+
htmlFor: htmlId,
|
|
53
|
+
label: field.label ?? field.name,
|
|
54
|
+
required: !field.optional
|
|
55
|
+
})
|
|
56
|
+
}),
|
|
57
|
+
showUploadWidget ? collectionPath ? /*#__PURE__*/ jsx(FileUploadField, {
|
|
58
|
+
field: field,
|
|
59
|
+
collectionPath: collectionPath,
|
|
60
|
+
fieldPath: fieldPath,
|
|
61
|
+
onUploaded: (uploaded)=>{
|
|
62
|
+
handleChange(uploaded);
|
|
63
|
+
}
|
|
64
|
+
}) : /*#__PURE__*/ jsx("div", {
|
|
65
|
+
className: classnames('byline-field-file-empty', file_field_module.empty),
|
|
66
|
+
children: t('fields.file.empty')
|
|
67
|
+
}) : /*#__PURE__*/ jsxs("div", {
|
|
68
|
+
className: classnames('byline-field-file-tile', file_field_module.tile),
|
|
69
|
+
children: [
|
|
70
|
+
isUploading && /*#__PURE__*/ jsx("div", {
|
|
71
|
+
className: classnames('byline-field-file-uploading', file_field_module.uploading),
|
|
72
|
+
"aria-live": "polite",
|
|
73
|
+
"aria-busy": "true",
|
|
74
|
+
children: /*#__PURE__*/ jsx(LoaderRing, {})
|
|
75
|
+
}),
|
|
76
|
+
collectionPath && /*#__PURE__*/ jsxs("div", {
|
|
77
|
+
className: classnames('byline-field-file-actions', file_field_module.actions),
|
|
78
|
+
children: [
|
|
79
|
+
!isPending && incomingValue?.storageUrl && /*#__PURE__*/ jsx(IconButton, {
|
|
80
|
+
type: "button",
|
|
81
|
+
intent: "noeffect",
|
|
82
|
+
onClick: ()=>triggerDownload(incomingValue.storageUrl, incomingValue.originalFilename ?? incomingValue.filename),
|
|
83
|
+
size: "xs",
|
|
84
|
+
disabled: isUploading,
|
|
85
|
+
"aria-label": t('fields.file.downloadAriaLabel'),
|
|
86
|
+
children: /*#__PURE__*/ jsx(DownloadIcon, {
|
|
87
|
+
width: "15px",
|
|
88
|
+
height: "15px"
|
|
89
|
+
})
|
|
90
|
+
}),
|
|
91
|
+
/*#__PURE__*/ jsx(IconButton, {
|
|
92
|
+
type: "button",
|
|
93
|
+
intent: "noeffect",
|
|
94
|
+
onClick: handleRemove,
|
|
95
|
+
size: "xs",
|
|
96
|
+
disabled: isUploading,
|
|
97
|
+
"aria-label": t('fields.file.removeAriaLabel'),
|
|
98
|
+
children: /*#__PURE__*/ jsx(CloseIcon, {
|
|
99
|
+
width: "15px",
|
|
100
|
+
height: "15px"
|
|
101
|
+
})
|
|
102
|
+
})
|
|
103
|
+
]
|
|
104
|
+
}),
|
|
105
|
+
!isPending && incomingValue?.storageUrl ? /*#__PURE__*/ jsx("a", {
|
|
106
|
+
href: incomingValue.storageUrl,
|
|
107
|
+
target: "_blank",
|
|
108
|
+
rel: "noreferrer",
|
|
109
|
+
"aria-label": t('fields.file.openInNewTabAriaLabel', {
|
|
110
|
+
filename: incomingValue.originalFilename ?? incomingValue.filename
|
|
111
|
+
}),
|
|
112
|
+
className: classnames('byline-field-file-icon-wrap', file_field_module["icon-wrap"]),
|
|
113
|
+
children: /*#__PURE__*/ jsx(FileGlyph, {
|
|
114
|
+
width: "48px",
|
|
115
|
+
height: "48px",
|
|
116
|
+
className: classnames('byline-field-file-icon', file_field_module.icon)
|
|
117
|
+
})
|
|
118
|
+
}) : /*#__PURE__*/ jsxs("div", {
|
|
119
|
+
className: classnames('byline-field-file-icon-wrap', file_field_module["icon-wrap"]),
|
|
120
|
+
children: [
|
|
121
|
+
/*#__PURE__*/ jsx(FileGlyph, {
|
|
122
|
+
width: "48px",
|
|
123
|
+
height: "48px",
|
|
124
|
+
className: classnames('byline-field-file-icon', file_field_module.icon)
|
|
125
|
+
}),
|
|
126
|
+
isPending && /*#__PURE__*/ jsx("div", {
|
|
127
|
+
className: classnames('byline-field-file-pending', file_field_module.pending),
|
|
128
|
+
children: t('fields.fileMeta.pendingUpload')
|
|
129
|
+
})
|
|
130
|
+
]
|
|
131
|
+
}),
|
|
132
|
+
/*#__PURE__*/ jsxs("div", {
|
|
133
|
+
className: classnames('byline-field-file-meta', file_field_module.meta),
|
|
134
|
+
children: [
|
|
135
|
+
/*#__PURE__*/ jsxs("div", {
|
|
136
|
+
children: [
|
|
137
|
+
/*#__PURE__*/ jsx("span", {
|
|
138
|
+
className: classnames('byline-field-file-meta-key', file_field_module["meta-key"]),
|
|
139
|
+
children: t('fields.fileMeta.filename')
|
|
140
|
+
}),
|
|
141
|
+
' ',
|
|
142
|
+
incomingValue?.filename
|
|
143
|
+
]
|
|
144
|
+
}),
|
|
145
|
+
/*#__PURE__*/ jsxs("div", {
|
|
146
|
+
children: [
|
|
147
|
+
/*#__PURE__*/ jsx("span", {
|
|
148
|
+
className: classnames('byline-field-file-meta-key', file_field_module["meta-key"]),
|
|
149
|
+
children: t('fields.fileMeta.original')
|
|
150
|
+
}),
|
|
151
|
+
' ',
|
|
152
|
+
incomingValue?.originalFilename
|
|
153
|
+
]
|
|
154
|
+
}),
|
|
155
|
+
/*#__PURE__*/ jsxs("div", {
|
|
156
|
+
children: [
|
|
157
|
+
/*#__PURE__*/ jsx("span", {
|
|
158
|
+
className: classnames('byline-field-file-meta-key', file_field_module["meta-key"]),
|
|
159
|
+
children: t('fields.fileMeta.type')
|
|
160
|
+
}),
|
|
161
|
+
' ',
|
|
162
|
+
incomingValue?.mimeType
|
|
163
|
+
]
|
|
164
|
+
}),
|
|
165
|
+
/*#__PURE__*/ jsxs("div", {
|
|
166
|
+
children: [
|
|
167
|
+
/*#__PURE__*/ jsx("span", {
|
|
168
|
+
className: classnames('byline-field-file-meta-key', file_field_module["meta-key"]),
|
|
169
|
+
children: t('fields.fileMeta.size')
|
|
170
|
+
}),
|
|
171
|
+
' ',
|
|
172
|
+
incomingValue?.fileSize
|
|
173
|
+
]
|
|
174
|
+
}),
|
|
175
|
+
isPending ? /*#__PURE__*/ jsxs("div", {
|
|
176
|
+
children: [
|
|
177
|
+
/*#__PURE__*/ jsx("span", {
|
|
178
|
+
className: classnames('byline-field-file-meta-key', file_field_module["meta-key"]),
|
|
179
|
+
children: t('fields.fileMeta.status')
|
|
180
|
+
}),
|
|
181
|
+
' ',
|
|
182
|
+
/*#__PURE__*/ jsx("span", {
|
|
183
|
+
className: classnames('byline-field-file-meta-pending', file_field_module["meta-pending"]),
|
|
184
|
+
children: t('fields.fileMeta.willUploadOnSave')
|
|
185
|
+
})
|
|
186
|
+
]
|
|
187
|
+
}) : /*#__PURE__*/ jsxs(Fragment, {
|
|
188
|
+
children: [
|
|
189
|
+
/*#__PURE__*/ jsxs("div", {
|
|
190
|
+
children: [
|
|
191
|
+
/*#__PURE__*/ jsx("span", {
|
|
192
|
+
className: classnames('byline-field-file-meta-key', file_field_module["meta-key"]),
|
|
193
|
+
children: t('fields.fileMeta.storage')
|
|
194
|
+
}),
|
|
195
|
+
' ',
|
|
196
|
+
incomingValue?.storageProvider
|
|
197
|
+
]
|
|
198
|
+
}),
|
|
199
|
+
/*#__PURE__*/ jsxs("div", {
|
|
200
|
+
children: [
|
|
201
|
+
/*#__PURE__*/ jsx("span", {
|
|
202
|
+
className: classnames('byline-field-file-meta-key', file_field_module["meta-key"]),
|
|
203
|
+
children: t('fields.fileMeta.path')
|
|
204
|
+
}),
|
|
205
|
+
' ',
|
|
206
|
+
incomingValue?.storagePath
|
|
207
|
+
]
|
|
208
|
+
})
|
|
209
|
+
]
|
|
210
|
+
})
|
|
211
|
+
]
|
|
212
|
+
})
|
|
213
|
+
]
|
|
214
|
+
}),
|
|
215
|
+
field.helpText && /*#__PURE__*/ jsx(HelpText, {
|
|
216
|
+
text: field.helpText
|
|
217
|
+
}),
|
|
218
|
+
fieldError && /*#__PURE__*/ jsx(ErrorText, {
|
|
219
|
+
id: `${field.name}-error`,
|
|
220
|
+
text: fieldError
|
|
221
|
+
})
|
|
222
|
+
]
|
|
223
|
+
});
|
|
224
|
+
};
|
|
225
|
+
export { FileField };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import "./file-field_module.css";
|
|
2
|
+
const file_field_module = {
|
|
3
|
+
header: "header-4BiMwv",
|
|
4
|
+
actions: "actions-Yd3WIq",
|
|
5
|
+
empty: "empty-Afgknj",
|
|
6
|
+
tile: "tile-K1K1D_",
|
|
7
|
+
uploading: "uploading-KCIPa6",
|
|
8
|
+
"icon-wrap": "icon-wrap-TckWPs",
|
|
9
|
+
iconWrap: "icon-wrap-TckWPs",
|
|
10
|
+
icon: "icon-HnknJj",
|
|
11
|
+
pending: "pending-mh5ZKa",
|
|
12
|
+
meta: "meta-mm1UmQ",
|
|
13
|
+
"meta-key": "meta-key-q6cipk",
|
|
14
|
+
metaKey: "meta-key-q6cipk",
|
|
15
|
+
"meta-pending": "meta-pending-Q0ICzl",
|
|
16
|
+
metaPending: "meta-pending-Q0ICzl"
|
|
17
|
+
};
|
|
18
|
+
export default file_field_module;
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
:is(.header-4BiMwv, .byline-field-file-header) {
|
|
2
|
+
align-items: baseline;
|
|
3
|
+
gap: var(--spacing-8);
|
|
4
|
+
margin-bottom: .25rem;
|
|
5
|
+
display: flex;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
:is(.actions-Yd3WIq, .byline-field-file-actions) {
|
|
9
|
+
top: var(--spacing-6);
|
|
10
|
+
right: var(--spacing-6);
|
|
11
|
+
z-index: 1;
|
|
12
|
+
align-items: center;
|
|
13
|
+
gap: var(--spacing-4);
|
|
14
|
+
display: flex;
|
|
15
|
+
position: absolute;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.byline-field-file-actions .byline-button {
|
|
19
|
+
color: var(--gray-900);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
:is(.dark .byline-field-file-actions .byline-button, [data-theme="dark"] .byline-field-file-actions .byline-button) {
|
|
23
|
+
color: var(--gray-200);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
:is(.empty-Afgknj, .byline-field-file-empty) {
|
|
27
|
+
color: var(--gray-500);
|
|
28
|
+
font-size: var(--font-size-xs);
|
|
29
|
+
font-style: italic;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
:is(.tile-K1K1D_, .byline-field-file-tile) {
|
|
33
|
+
gap: var(--spacing-16);
|
|
34
|
+
padding: var(--spacing-8);
|
|
35
|
+
border: var(--border-width-thin) var(--border-style-solid) var(--primary-500);
|
|
36
|
+
border-radius: var(--border-radius-md);
|
|
37
|
+
margin-top: .25rem;
|
|
38
|
+
display: flex;
|
|
39
|
+
position: relative;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
:is(.uploading-KCIPa6, .byline-field-file-uploading) {
|
|
43
|
+
z-index: 2;
|
|
44
|
+
background-color: oklch(from var(--gray-950) l c h / .5);
|
|
45
|
+
border-radius: var(--border-radius-md);
|
|
46
|
+
justify-content: center;
|
|
47
|
+
align-items: center;
|
|
48
|
+
display: flex;
|
|
49
|
+
position: absolute;
|
|
50
|
+
inset: 0;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
:is(.icon-wrap-TckWPs, .byline-field-file-icon-wrap) {
|
|
54
|
+
border: var(--border-width-thin) var(--border-style-solid) var(--gray-600);
|
|
55
|
+
border-radius: var(--border-radius-sm);
|
|
56
|
+
width: 4rem;
|
|
57
|
+
height: 4rem;
|
|
58
|
+
color: var(--gray-300);
|
|
59
|
+
flex-shrink: 0;
|
|
60
|
+
justify-content: center;
|
|
61
|
+
align-self: flex-start;
|
|
62
|
+
align-items: center;
|
|
63
|
+
display: flex;
|
|
64
|
+
position: relative;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
a.icon-wrap-TckWPs {
|
|
68
|
+
cursor: pointer;
|
|
69
|
+
text-decoration: none;
|
|
70
|
+
transition: border-color .12s, color .12s;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
a.byline-field-file-icon-wrap {
|
|
74
|
+
cursor: pointer;
|
|
75
|
+
text-decoration: none;
|
|
76
|
+
transition: border-color .12s, color .12s;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
a.icon-wrap-TckWPs:hover {
|
|
80
|
+
border-color: var(--primary-500);
|
|
81
|
+
color: var(--primary-400);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
a.byline-field-file-icon-wrap:hover {
|
|
85
|
+
border-color: var(--primary-500);
|
|
86
|
+
color: var(--primary-400);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
a.icon-wrap-TckWPs:focus-visible {
|
|
90
|
+
outline: 2px solid var(--primary-500);
|
|
91
|
+
outline-offset: 2px;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
a.byline-field-file-icon-wrap:focus-visible {
|
|
95
|
+
outline: 2px solid var(--primary-500);
|
|
96
|
+
outline-offset: 2px;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
:is(.icon-HnknJj, .byline-field-file-icon) {
|
|
100
|
+
opacity: .85;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
:is(.pending-mh5ZKa, .byline-field-file-pending) {
|
|
104
|
+
background-color: oklch(from var(--yellow-600) l c h / .9);
|
|
105
|
+
color: var(--yellow-100);
|
|
106
|
+
font-size: .6rem;
|
|
107
|
+
font-weight: var(--font-weight-medium);
|
|
108
|
+
border-radius: var(--border-radius-sm);
|
|
109
|
+
padding: .125rem .375rem;
|
|
110
|
+
position: absolute;
|
|
111
|
+
top: .25rem;
|
|
112
|
+
left: .25rem;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
:is(.meta-mm1UmQ, .byline-field-file-meta) {
|
|
116
|
+
padding-right: var(--spacing-32);
|
|
117
|
+
color: var(--gray-200);
|
|
118
|
+
font-size: var(--font-size-xs);
|
|
119
|
+
flex-direction: column;
|
|
120
|
+
gap: .125rem;
|
|
121
|
+
display: flex;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
:is(.meta-key-q6cipk, .byline-field-file-meta-key) {
|
|
125
|
+
font-weight: var(--font-weight-semibold);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
:is(.meta-pending-Q0ICzl, .byline-field-file-meta-pending) {
|
|
129
|
+
color: var(--yellow-400);
|
|
130
|
+
}
|
|
131
|
+
|
|
@@ -0,0 +1,21 @@
|
|
|
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 FileField as FieldType, type PendingStoredFileValue, type StoredFileValue } from '@byline/core';
|
|
9
|
+
interface FileUploadFieldProps {
|
|
10
|
+
field: FieldType;
|
|
11
|
+
/** Collection path used to build the upload URL (e.g. `'media'`). */
|
|
12
|
+
collectionPath: string;
|
|
13
|
+
/** Field path in the form (e.g. `'attachment'` or `'content.0.attachment'`). */
|
|
14
|
+
fieldPath: string;
|
|
15
|
+
/** Called with the PendingStoredFileValue for immediate UI update. */
|
|
16
|
+
onUploaded: (value: StoredFileValue | PendingStoredFileValue) => void;
|
|
17
|
+
/** Optional `accept` MIME-type / extension string for the native file input. */
|
|
18
|
+
accept?: string;
|
|
19
|
+
}
|
|
20
|
+
export declare const FileUploadField: ({ field: _field, collectionPath, fieldPath, onUploaded, accept, }: FileUploadFieldProps) => import("react").JSX.Element;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { 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 file_upload_field_module from "./file-upload-field.module.js";
|
|
8
|
+
const FileUploadField = ({ field: _field, collectionPath, fieldPath, onUploaded, accept })=>{
|
|
9
|
+
const inputRef = useRef(null);
|
|
10
|
+
const { t } = useTranslation('byline-admin');
|
|
11
|
+
const [status, setStatus] = useState('idle');
|
|
12
|
+
const [errorMessage, setErrorMessage] = useState(null);
|
|
13
|
+
const [isDragOver, setIsDragOver] = useState(false);
|
|
14
|
+
const { addPendingUpload } = useFormContext();
|
|
15
|
+
const handleFileSelected = useCallback((file)=>{
|
|
16
|
+
setStatus('processing');
|
|
17
|
+
setErrorMessage(null);
|
|
18
|
+
const previewUrl = URL.createObjectURL(file);
|
|
19
|
+
const pendingValue = createPendingStoredFileValue(file, previewUrl);
|
|
20
|
+
addPendingUpload(fieldPath, {
|
|
21
|
+
file,
|
|
22
|
+
previewUrl,
|
|
23
|
+
collectionPath
|
|
24
|
+
});
|
|
25
|
+
setStatus('idle');
|
|
26
|
+
onUploaded(pendingValue);
|
|
27
|
+
}, [
|
|
28
|
+
collectionPath,
|
|
29
|
+
fieldPath,
|
|
30
|
+
addPendingUpload,
|
|
31
|
+
onUploaded
|
|
32
|
+
]);
|
|
33
|
+
const handleFileChange = useCallback((e)=>{
|
|
34
|
+
const file = e.target.files?.[0];
|
|
35
|
+
if (file) handleFileSelected(file);
|
|
36
|
+
e.target.value = '';
|
|
37
|
+
}, [
|
|
38
|
+
handleFileSelected
|
|
39
|
+
]);
|
|
40
|
+
const handleBrowseClick = useCallback(()=>{
|
|
41
|
+
inputRef.current?.click();
|
|
42
|
+
}, []);
|
|
43
|
+
const handleDragOver = useCallback((e)=>{
|
|
44
|
+
e.preventDefault();
|
|
45
|
+
setIsDragOver(true);
|
|
46
|
+
}, []);
|
|
47
|
+
const handleDragLeave = useCallback((e)=>{
|
|
48
|
+
e.preventDefault();
|
|
49
|
+
setIsDragOver(false);
|
|
50
|
+
}, []);
|
|
51
|
+
const handleDrop = useCallback((e)=>{
|
|
52
|
+
e.preventDefault();
|
|
53
|
+
setIsDragOver(false);
|
|
54
|
+
const file = e.dataTransfer.files?.[0];
|
|
55
|
+
if (file) handleFileSelected(file);
|
|
56
|
+
}, [
|
|
57
|
+
handleFileSelected
|
|
58
|
+
]);
|
|
59
|
+
const isProcessing = 'processing' === status;
|
|
60
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
61
|
+
className: classnames('byline-field-file-upload', file_upload_field_module.root),
|
|
62
|
+
children: [
|
|
63
|
+
/*#__PURE__*/ jsx("input", {
|
|
64
|
+
ref: inputRef,
|
|
65
|
+
type: "file",
|
|
66
|
+
accept: accept,
|
|
67
|
+
className: classnames('byline-field-file-upload-input', file_upload_field_module.input),
|
|
68
|
+
onChange: handleFileChange,
|
|
69
|
+
disabled: isProcessing,
|
|
70
|
+
"aria-hidden": "true",
|
|
71
|
+
tabIndex: -1
|
|
72
|
+
}),
|
|
73
|
+
/*#__PURE__*/ jsxs("div", {
|
|
74
|
+
role: "button",
|
|
75
|
+
tabIndex: 0,
|
|
76
|
+
"aria-label": t('fields.file.upload.zoneAriaLabel'),
|
|
77
|
+
onDragOver: handleDragOver,
|
|
78
|
+
onDragLeave: handleDragLeave,
|
|
79
|
+
onDrop: handleDrop,
|
|
80
|
+
onClick: handleBrowseClick,
|
|
81
|
+
onKeyDown: (e)=>{
|
|
82
|
+
if ('Enter' === e.key || ' ' === e.key) {
|
|
83
|
+
e.preventDefault();
|
|
84
|
+
handleBrowseClick();
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
className: classnames('byline-field-file-upload-zone', file_upload_field_module.zone, isDragOver && !isProcessing && [
|
|
88
|
+
'byline-field-file-upload-zone-active',
|
|
89
|
+
file_upload_field_module["zone-active"]
|
|
90
|
+
], isProcessing && [
|
|
91
|
+
'byline-field-file-upload-zone-busy',
|
|
92
|
+
file_upload_field_module["zone-busy"]
|
|
93
|
+
]),
|
|
94
|
+
children: [
|
|
95
|
+
/*#__PURE__*/ jsx("svg", {
|
|
96
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
97
|
+
className: classnames('byline-field-file-upload-icon', file_upload_field_module.icon),
|
|
98
|
+
fill: "none",
|
|
99
|
+
viewBox: "0 0 24 24",
|
|
100
|
+
stroke: "currentColor",
|
|
101
|
+
strokeWidth: 1.5,
|
|
102
|
+
"aria-hidden": "true",
|
|
103
|
+
children: /*#__PURE__*/ jsx("path", {
|
|
104
|
+
strokeLinecap: "round",
|
|
105
|
+
strokeLinejoin: "round",
|
|
106
|
+
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"
|
|
107
|
+
})
|
|
108
|
+
}),
|
|
109
|
+
/*#__PURE__*/ jsxs("span", {
|
|
110
|
+
className: classnames('byline-field-file-upload-label', file_upload_field_module.label),
|
|
111
|
+
children: [
|
|
112
|
+
t('fields.file.upload.label'),
|
|
113
|
+
' ',
|
|
114
|
+
/*#__PURE__*/ jsx("span", {
|
|
115
|
+
className: classnames('byline-field-file-upload-action', file_upload_field_module.action),
|
|
116
|
+
children: t('fields.file.upload.browse')
|
|
117
|
+
})
|
|
118
|
+
]
|
|
119
|
+
})
|
|
120
|
+
]
|
|
121
|
+
}),
|
|
122
|
+
'error' === status && errorMessage && /*#__PURE__*/ jsx("p", {
|
|
123
|
+
className: classnames('byline-field-file-upload-error', file_upload_field_module.error),
|
|
124
|
+
role: "alert",
|
|
125
|
+
children: errorMessage
|
|
126
|
+
})
|
|
127
|
+
]
|
|
128
|
+
});
|
|
129
|
+
};
|
|
130
|
+
export { FileUploadField };
|