@byline/ui 1.7.3 → 1.7.4
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.
|
@@ -3,7 +3,7 @@ import { useState } from "react";
|
|
|
3
3
|
import { isPendingStoredFileValue } from "@byline/core";
|
|
4
4
|
import classnames from "classnames";
|
|
5
5
|
import { useFieldError, useFieldValue, useFormContext, useIsDirty } from "../../forms/form-context.js";
|
|
6
|
-
import { ErrorText } from "../../uikit.js";
|
|
6
|
+
import { ErrorText, HelpText, Label } from "../../uikit.js";
|
|
7
7
|
import { ImageLightbox } from "../../widgets/image-lightbox/image-lightbox.js";
|
|
8
8
|
import { useFieldChangeHandler } from "../use-field-change-handler.js";
|
|
9
9
|
import image_field_module from "./image-field.module.js";
|
|
@@ -31,26 +31,18 @@ const ImageField = ({ field, collectionPath, value, defaultValue, onChange: _onC
|
|
|
31
31
|
};
|
|
32
32
|
const [lightboxOpen, setLightboxOpen] = useState(false);
|
|
33
33
|
const canOpenLightbox = !isPending && !!incomingValue?.storageUrl;
|
|
34
|
+
const htmlId = fieldPath;
|
|
34
35
|
return /*#__PURE__*/ jsxs("div", {
|
|
35
36
|
className: `byline-field-image ${field.name}`,
|
|
36
37
|
children: [
|
|
37
38
|
/*#__PURE__*/ jsxs("div", {
|
|
38
39
|
className: classnames('byline-field-image-header', image_field_module.header),
|
|
39
40
|
children: [
|
|
40
|
-
/*#__PURE__*/
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
field.label ?? field.name,
|
|
46
|
-
field.optional ? '' : ' *'
|
|
47
|
-
]
|
|
48
|
-
}),
|
|
49
|
-
field.helpText && /*#__PURE__*/ jsx("div", {
|
|
50
|
-
className: classnames('byline-field-image-help', image_field_module.help),
|
|
51
|
-
children: field.helpText
|
|
52
|
-
})
|
|
53
|
-
]
|
|
41
|
+
/*#__PURE__*/ jsx(Label, {
|
|
42
|
+
id: htmlId,
|
|
43
|
+
htmlFor: htmlId,
|
|
44
|
+
label: field.label ?? field.name,
|
|
45
|
+
required: !field.optional
|
|
54
46
|
}),
|
|
55
47
|
!showUploadWidget && collectionPath && /*#__PURE__*/ jsx("button", {
|
|
56
48
|
type: "button",
|
|
@@ -207,6 +199,9 @@ const ImageField = ({ field, collectionPath, value, defaultValue, onChange: _onC
|
|
|
207
199
|
})
|
|
208
200
|
]
|
|
209
201
|
}),
|
|
202
|
+
field.helpText && /*#__PURE__*/ jsx(HelpText, {
|
|
203
|
+
text: field.helpText
|
|
204
|
+
}),
|
|
210
205
|
fieldError && /*#__PURE__*/ jsx(ErrorText, {
|
|
211
206
|
id: `${field.name}-error`,
|
|
212
207
|
text: fieldError
|
|
@@ -5,18 +5,6 @@
|
|
|
5
5
|
display: flex;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
:is(.label-NX4rr4, .byline-field-image-label) {
|
|
9
|
-
color: var(--gray-100);
|
|
10
|
-
font-size: var(--font-size-sm);
|
|
11
|
-
font-weight: var(--font-weight-medium);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
:is(.help-M8XvYp, .byline-field-image-help) {
|
|
15
|
-
color: var(--gray-400);
|
|
16
|
-
font-size: var(--font-size-xs);
|
|
17
|
-
margin-top: .125rem;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
8
|
:is(.remove-ib7eKx, .byline-field-image-remove) {
|
|
21
9
|
color: var(--red-500);
|
|
22
10
|
font-size: var(--font-size-xs);
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"private": false,
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MPL-2.0",
|
|
6
|
-
"version": "1.7.
|
|
6
|
+
"version": "1.7.4",
|
|
7
7
|
"engines": {
|
|
8
8
|
"node": ">=20.9.0"
|
|
9
9
|
},
|
|
@@ -65,9 +65,9 @@
|
|
|
65
65
|
"react-diff-viewer-continued": "^4.2.2",
|
|
66
66
|
"zod": "^4.4.2",
|
|
67
67
|
"zod-form-data": "^3.0.1",
|
|
68
|
-
"@byline/admin": "1.7.
|
|
69
|
-
"@byline/
|
|
70
|
-
"@byline/
|
|
68
|
+
"@byline/admin": "1.7.4",
|
|
69
|
+
"@byline/core": "1.7.4",
|
|
70
|
+
"@byline/client": "1.7.4"
|
|
71
71
|
},
|
|
72
72
|
"peerDependencies": {
|
|
73
73
|
"react": "^19.0.0",
|
|
@@ -4,8 +4,6 @@
|
|
|
4
4
|
* Override handles:
|
|
5
5
|
* .byline-field-image — wrapper div
|
|
6
6
|
* .byline-field-image-header — label + remove button row
|
|
7
|
-
* .byline-field-image-label — primary label text
|
|
8
|
-
* .byline-field-image-help — secondary help text
|
|
9
7
|
* .byline-field-image-remove — remove-button text-link
|
|
10
8
|
* .byline-field-image-empty — empty-state hint text
|
|
11
9
|
* .byline-field-image-tile — bordered preview/metadata tile
|
|
@@ -26,20 +24,6 @@
|
|
|
26
24
|
margin-bottom: 0.25rem;
|
|
27
25
|
}
|
|
28
26
|
|
|
29
|
-
.label,
|
|
30
|
-
:global(.byline-field-image-label) {
|
|
31
|
-
color: var(--gray-100);
|
|
32
|
-
font-size: var(--font-size-sm);
|
|
33
|
-
font-weight: var(--font-weight-medium);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
.help,
|
|
37
|
-
:global(.byline-field-image-help) {
|
|
38
|
-
margin-top: 0.125rem;
|
|
39
|
-
color: var(--gray-400);
|
|
40
|
-
font-size: var(--font-size-xs);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
27
|
.remove,
|
|
44
28
|
:global(.byline-field-image-remove) {
|
|
45
29
|
background: none;
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
import cx from 'classnames'
|
|
17
17
|
|
|
18
18
|
import { useFieldError, useFieldValue, useFormContext, useIsDirty } from '../../forms/form-context'
|
|
19
|
-
import { ErrorText } from '../../uikit.js'
|
|
19
|
+
import { ErrorText, HelpText, Label } from '../../uikit.js'
|
|
20
20
|
import { ImageLightbox } from '../../widgets/image-lightbox/image-lightbox.js'
|
|
21
21
|
import { useFieldChangeHandler } from '../use-field-change-handler'
|
|
22
22
|
import styles from './image-field.module.css'
|
|
@@ -92,18 +92,17 @@ export const ImageField = ({
|
|
|
92
92
|
const [lightboxOpen, setLightboxOpen] = useState(false)
|
|
93
93
|
const canOpenLightbox = !isPending && !!incomingValue?.storageUrl
|
|
94
94
|
|
|
95
|
+
const htmlId = fieldPath
|
|
96
|
+
|
|
95
97
|
return (
|
|
96
98
|
<div className={`byline-field-image ${field.name}`}>
|
|
97
99
|
<div className={cx('byline-field-image-header', styles.header)}>
|
|
98
|
-
<
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
<div className={cx('byline-field-image-help', styles.help)}>{field.helpText}</div>
|
|
105
|
-
)}
|
|
106
|
-
</div>
|
|
100
|
+
<Label
|
|
101
|
+
id={htmlId}
|
|
102
|
+
htmlFor={htmlId}
|
|
103
|
+
label={field.label ?? field.name}
|
|
104
|
+
required={!field.optional}
|
|
105
|
+
/>
|
|
107
106
|
{/* Remove button — shown when an image is set (including pending) */}
|
|
108
107
|
{!showUploadWidget && collectionPath && (
|
|
109
108
|
<button
|
|
@@ -244,6 +243,8 @@ export const ImageField = ({
|
|
|
244
243
|
</div>
|
|
245
244
|
)}
|
|
246
245
|
|
|
246
|
+
{field.helpText && <HelpText text={field.helpText} />}
|
|
247
|
+
|
|
247
248
|
{fieldError && <ErrorText id={`${field.name}-error`} text={fieldError} />}
|
|
248
249
|
|
|
249
250
|
{canOpenLightbox && incomingValue?.storageUrl && (
|