lightnet 3.10.5 → 3.10.7
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/CHANGELOG.md +14 -0
- package/__e2e__/admin.spec.ts +29 -48
- package/__e2e__/{test-utils.ts → basics-fixture.ts} +20 -23
- package/__e2e__/fixtures/basics/node_modules/.bin/astro +2 -2
- package/__e2e__/fixtures/basics/package.json +2 -2
- package/__e2e__/fixtures/basics/src/content/media/faithful-freestyle--en.json +1 -1
- package/__e2e__/fixtures/basics/src/content/media/skate-sounds--en.json +1 -1
- package/__e2e__/global.teardown.ts +5 -0
- package/__e2e__/homepage.spec.ts +17 -19
- package/__e2e__/search.spec.ts +3 -5
- package/__tests__/utils/markdown.spec.ts +16 -0
- package/package.json +6 -5
- package/playwright.config.ts +1 -0
- package/src/admin/components/form/DynamicArray.tsx +9 -6
- package/src/admin/components/form/Input.tsx +31 -13
- package/src/admin/components/form/LazyLoadedMarkdownEditor.tsx +102 -0
- package/src/admin/components/form/MarkdownEditor.tsx +54 -0
- package/src/admin/components/form/Select.tsx +24 -6
- package/src/admin/components/form/SubmitButton.tsx +11 -6
- package/src/admin/components/form/atoms/Hint.tsx +11 -2
- package/src/admin/components/form/atoms/Label.tsx +14 -11
- package/src/admin/components/form/hooks/use-field-dirty.tsx +12 -0
- package/src/admin/i18n/translations/en.yml +9 -8
- package/src/admin/pages/media/EditForm.tsx +29 -6
- package/src/admin/pages/media/EditRoute.astro +3 -3
- package/src/admin/pages/media/fields/Authors.tsx +16 -25
- package/src/admin/pages/media/fields/Categories.tsx +8 -35
- package/src/admin/pages/media/fields/Collections.tsx +25 -70
- package/src/admin/types/media-item.ts +1 -0
- package/src/components/HighlightSection.astro +1 -1
- package/src/pages/details-page/components/main-details/OpenButton.astro +1 -1
- package/src/utils/markdown.ts +6 -0
- package/src/admin/components/form/atoms/Legend.tsx +0 -20
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { type Control } from "react-hook-form"
|
|
2
2
|
|
|
3
|
-
import ErrorMessage from "../../../components/form/atoms/ErrorMessage"
|
|
4
|
-
import Label from "../../../components/form/atoms/Label"
|
|
5
3
|
import DynamicArray from "../../../components/form/DynamicArray"
|
|
6
|
-
import
|
|
4
|
+
import Input from "../../../components/form/Input"
|
|
5
|
+
import Select from "../../../components/form/Select"
|
|
7
6
|
import type { MediaItem } from "../../../types/media-item"
|
|
8
7
|
|
|
9
8
|
export default function Collections({
|
|
10
9
|
control,
|
|
11
10
|
collections,
|
|
11
|
+
defaultValue,
|
|
12
12
|
}: {
|
|
13
13
|
control: Control<MediaItem>
|
|
14
14
|
collections: { id: string; labelText: string }[]
|
|
15
|
+
defaultValue: MediaItem["collections"]
|
|
15
16
|
}) {
|
|
16
17
|
return (
|
|
17
18
|
<DynamicArray
|
|
@@ -19,13 +20,29 @@ export default function Collections({
|
|
|
19
20
|
name="collections"
|
|
20
21
|
label="ln.admin.collections"
|
|
21
22
|
renderElement={(index) => (
|
|
22
|
-
<div className="flex w-full flex-col py-2">
|
|
23
|
-
<
|
|
24
|
-
|
|
23
|
+
<div className="flex w-full flex-col gap-4 py-2">
|
|
24
|
+
<Select
|
|
25
|
+
options={collections}
|
|
26
|
+
label="ln.admin.name"
|
|
27
|
+
labelSize="small"
|
|
28
|
+
preserveHintSpace={false}
|
|
29
|
+
name={`collections.${index}.collection`}
|
|
25
30
|
control={control}
|
|
26
|
-
|
|
31
|
+
defaultValue={defaultValue[index]?.collection}
|
|
32
|
+
/>
|
|
33
|
+
<Input
|
|
34
|
+
type="number"
|
|
35
|
+
control={control}
|
|
36
|
+
label="ln.admin.position-in-collection"
|
|
37
|
+
labelSize="small"
|
|
38
|
+
step={1}
|
|
39
|
+
min={0}
|
|
40
|
+
preserveHintSpace={false}
|
|
41
|
+
defaultValue={defaultValue[index]?.index}
|
|
42
|
+
{...control.register(`collections.${index}.index`, {
|
|
43
|
+
setValueAs: (value) => (value === "" ? undefined : Number(value)),
|
|
44
|
+
})}
|
|
27
45
|
/>
|
|
28
|
-
<CollectionIndex control={control} index={index} />
|
|
29
46
|
</div>
|
|
30
47
|
)}
|
|
31
48
|
addButton={{
|
|
@@ -39,65 +56,3 @@ export default function Collections({
|
|
|
39
56
|
/>
|
|
40
57
|
)
|
|
41
58
|
}
|
|
42
|
-
|
|
43
|
-
function CollectionSelect({
|
|
44
|
-
control,
|
|
45
|
-
collections,
|
|
46
|
-
index,
|
|
47
|
-
}: {
|
|
48
|
-
control: Control<MediaItem>
|
|
49
|
-
collections: { id: string; labelText: string }[]
|
|
50
|
-
index: number
|
|
51
|
-
}) {
|
|
52
|
-
const name = `collections.${index}.collection` as const
|
|
53
|
-
const errorMessage = useFieldError({ name, control })
|
|
54
|
-
return (
|
|
55
|
-
<>
|
|
56
|
-
<Label for={name} label="ln.admin.name" size="xs" />
|
|
57
|
-
<select
|
|
58
|
-
{...control.register(name)}
|
|
59
|
-
id={name}
|
|
60
|
-
aria-invalid={!!errorMessage}
|
|
61
|
-
className={`dy-select dy-select-bordered text-base shadow-sm ${errorMessage ? "dy-select-error" : ""}`}
|
|
62
|
-
>
|
|
63
|
-
{collections.map(({ id, labelText }) => (
|
|
64
|
-
<option key={id} value={id}>
|
|
65
|
-
{labelText}
|
|
66
|
-
</option>
|
|
67
|
-
))}
|
|
68
|
-
</select>
|
|
69
|
-
<ErrorMessage message={errorMessage} />
|
|
70
|
-
</>
|
|
71
|
-
)
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function CollectionIndex({
|
|
75
|
-
control,
|
|
76
|
-
index,
|
|
77
|
-
}: {
|
|
78
|
-
control: Control<MediaItem>
|
|
79
|
-
index: number
|
|
80
|
-
}) {
|
|
81
|
-
const name = `collections.${index}.index` as const
|
|
82
|
-
const errorMessage = useFieldError({ name, control })
|
|
83
|
-
return (
|
|
84
|
-
<>
|
|
85
|
-
<Label
|
|
86
|
-
for={name}
|
|
87
|
-
label="ln.admin.position-in-collection"
|
|
88
|
-
size="xs"
|
|
89
|
-
className="mt-3"
|
|
90
|
-
/>
|
|
91
|
-
<input
|
|
92
|
-
className={`dy-input dy-input-bordered shadow-inner ${errorMessage ? "dy-input-error" : ""}`}
|
|
93
|
-
aria-invalid={!!errorMessage}
|
|
94
|
-
type="number"
|
|
95
|
-
step={1}
|
|
96
|
-
{...control.register(name, {
|
|
97
|
-
setValueAs: (value) => (value === "" ? undefined : Number(value)),
|
|
98
|
-
})}
|
|
99
|
-
/>
|
|
100
|
-
<ErrorMessage message={errorMessage} />
|
|
101
|
-
</>
|
|
102
|
-
)
|
|
103
|
-
}
|
|
@@ -53,7 +53,7 @@ const { image, id, title, text, link, className, titleClass, textClass } =
|
|
|
53
53
|
{
|
|
54
54
|
link && (
|
|
55
55
|
<a
|
|
56
|
-
class="inline-flex items-center justify-center gap-2 rounded-2xl bg-primary px-6 py-3 text-sm font-bold
|
|
56
|
+
class="inline-flex items-center justify-center gap-2 rounded-2xl bg-primary px-6 py-3 text-sm font-bold text-gray-50 shadow-sm hover:bg-primary/85 hover:text-gray-100"
|
|
57
57
|
href={link.href}
|
|
58
58
|
>
|
|
59
59
|
{link.text}
|
|
@@ -14,7 +14,7 @@ const content = createContentMetadata(item.data.content[0])
|
|
|
14
14
|
---
|
|
15
15
|
|
|
16
16
|
<a
|
|
17
|
-
class="flex min-w-52 items-center justify-center gap-2 rounded-2xl bg-gray-800 px-6 py-3 font-bold
|
|
17
|
+
class="flex min-w-52 items-center justify-center gap-2 rounded-2xl bg-gray-800 px-6 py-3 font-bold text-gray-100 shadow-sm hover:bg-gray-950 hover:text-gray-300"
|
|
18
18
|
href={content.url}
|
|
19
19
|
target={content.target}
|
|
20
20
|
hreflang={item.data.language}
|
package/src/utils/markdown.ts
CHANGED
|
@@ -19,6 +19,12 @@ export function markdownToText(markdown?: string) {
|
|
|
19
19
|
.replaceAll(/^#+ ?/gm, "")
|
|
20
20
|
// lists
|
|
21
21
|
.replaceAll(/^- /gm, "")
|
|
22
|
+
// escaped white space
|
|
23
|
+
.replaceAll(/ /g, " ")
|
|
24
|
+
// underlines
|
|
25
|
+
.replaceAll(/<\/?u>/g, "")
|
|
26
|
+
// code block
|
|
27
|
+
.replaceAll(/^```[a-zA-Z ]*\n/gm, "")
|
|
22
28
|
// block quotes
|
|
23
29
|
.replaceAll(/^>+ ?/gm, "")
|
|
24
30
|
// bold and italics
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { useI18n } from "../../../../i18n/react/useI18n"
|
|
2
|
-
|
|
3
|
-
export default function Legend({
|
|
4
|
-
label,
|
|
5
|
-
size = "sm",
|
|
6
|
-
className,
|
|
7
|
-
}: {
|
|
8
|
-
label: string
|
|
9
|
-
className?: string
|
|
10
|
-
size?: "sm" | "xs"
|
|
11
|
-
}) {
|
|
12
|
-
const { t } = useI18n()
|
|
13
|
-
return (
|
|
14
|
-
<legend
|
|
15
|
-
className={`pb-2 font-bold uppercase text-gray-500 ${size === "sm" ? "text-sm" : "text-xs"} ${className}`}
|
|
16
|
-
>
|
|
17
|
-
{t(label)}
|
|
18
|
-
</legend>
|
|
19
|
-
)
|
|
20
|
-
}
|