@chinggis.systems/collection-ui 1.0.0 → 1.0.1
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/README.md +21 -36
- package/dist/CollectionRenderer.d.ts +2 -2
- package/dist/CollectionRenderer.d.ts.map +1 -1
- package/dist/CollectionRenderer.js +305 -292
- package/dist/CollectionRenderer.js.map +1 -1
- package/dist/CollectionView.d.ts +13 -0
- package/dist/CollectionView.d.ts.map +1 -0
- package/dist/CollectionView.js +42 -0
- package/dist/CollectionView.js.map +1 -0
- package/dist/assets/spine/BurnBlend.png +0 -0
- package/dist/assets/spine/FlatEdges.webp +0 -0
- package/dist/assets/spine/FlatShadow.webp +0 -0
- package/dist/assets/spine/NormalBlend.webp +0 -0
- package/dist/assets/spine/SoftLightBlend.webp +0 -0
- package/dist/collectionV2Model.d.ts +43 -0
- package/dist/collectionV2Model.d.ts.map +1 -0
- package/dist/collectionV2Model.js +4 -0
- package/dist/collectionV2Model.js.map +1 -0
- package/dist/createAdapters.d.ts +66 -74
- package/dist/createAdapters.d.ts.map +1 -1
- package/dist/createAdapters.js +223 -223
- package/dist/createAdapters.js.map +1 -1
- package/dist/defaultAdapters.d.ts +7 -7
- package/dist/defaultAdapters.js +8 -8
- package/dist/index.d.ts +14 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -6
- package/dist/index.js.map +1 -1
- package/dist/layoutPresets.d.ts +18 -18
- package/dist/layoutPresets.js +129 -129
- package/dist/primitives/BookSpine.d.ts +11 -11
- package/dist/primitives/BookSpine.js +10 -10
- package/dist/primitives/CollectionCarousel.d.ts +3 -3
- package/dist/primitives/CollectionCarousel.d.ts.map +1 -1
- package/dist/primitives/CollectionCarousel.js +22 -13
- package/dist/primitives/CollectionCarousel.js.map +1 -1
- package/dist/styles.css +236 -51
- package/dist/types.d.ts +141 -141
- package/dist/types.js +1 -1
- package/dist/utils.d.ts +8 -8
- package/dist/utils.js +26 -26
- package/package.json +1 -1
package/dist/types.d.ts
CHANGED
|
@@ -1,142 +1,142 @@
|
|
|
1
|
-
import type { CSSProperties, ReactNode } from "react";
|
|
2
|
-
export type CollectionLayoutName = "banner" | "block-grid" | "carousel" | "dynamic" | "featured" | "grid" | "grid-title" | "hero" | "image-grid" | "list" | "relative" | "slide" | "special";
|
|
3
|
-
export type CollectionLayoutDirection = "horizontal" | "vertical";
|
|
4
|
-
export type CollectionLayoutShape = "circle" | "rectangle" | "square";
|
|
5
|
-
export type CollectionItemMediaKind = "audio" | "book" | "ebook" | string;
|
|
6
|
-
export interface CollectionItem {
|
|
7
|
-
id: string;
|
|
8
|
-
title?: string | null;
|
|
9
|
-
author?: string | null;
|
|
10
|
-
description?: string | null;
|
|
11
|
-
imageUrl?: string | null;
|
|
12
|
-
productId?: string | null;
|
|
13
|
-
type?: CollectionItemMediaKind | null;
|
|
14
|
-
price?: number | null;
|
|
15
|
-
discountPrice?: number | null;
|
|
16
|
-
href?: string | null;
|
|
17
|
-
sort?: number | null;
|
|
18
|
-
metadata?: Record<string, unknown>;
|
|
19
|
-
}
|
|
20
|
-
export interface CollectionLayout {
|
|
21
|
-
name: CollectionLayoutName;
|
|
22
|
-
direction?: CollectionLayoutDirection | null;
|
|
23
|
-
isNumbered?: boolean | null;
|
|
24
|
-
columns?: number | null;
|
|
25
|
-
itemLimit?: number | null;
|
|
26
|
-
shape?: CollectionLayoutShape | null;
|
|
27
|
-
}
|
|
28
|
-
export interface Collection {
|
|
29
|
-
id: string;
|
|
30
|
-
name?: string | null;
|
|
31
|
-
description?: string | null;
|
|
32
|
-
imageUrl?: string | null;
|
|
33
|
-
linkName?: string | null;
|
|
34
|
-
href?: string | null;
|
|
35
|
-
type?: string | null;
|
|
36
|
-
sort?: number | null;
|
|
37
|
-
layout?: CollectionLayout | null;
|
|
38
|
-
items?: CollectionItem[] | null;
|
|
39
|
-
collections?: Collection[] | null;
|
|
40
|
-
metadata?: Record<string, unknown>;
|
|
41
|
-
}
|
|
42
|
-
export interface LinkRenderProps {
|
|
43
|
-
href: string;
|
|
44
|
-
children: ReactNode;
|
|
45
|
-
className?: string;
|
|
46
|
-
collection?: Collection;
|
|
47
|
-
item?: CollectionItem;
|
|
48
|
-
onClick?: () => void;
|
|
49
|
-
}
|
|
50
|
-
export interface ImageRenderProps {
|
|
51
|
-
src: string;
|
|
52
|
-
alt: string;
|
|
53
|
-
width: number;
|
|
54
|
-
height: number;
|
|
55
|
-
className?: string;
|
|
56
|
-
priority?: boolean;
|
|
57
|
-
sizes?: string;
|
|
58
|
-
style?: CSSProperties;
|
|
59
|
-
collection?: Collection;
|
|
60
|
-
item?: CollectionItem;
|
|
61
|
-
}
|
|
62
|
-
export interface BookMediaRenderProps {
|
|
63
|
-
item: CollectionItem;
|
|
64
|
-
src?: string | null;
|
|
65
|
-
alt: string;
|
|
66
|
-
width?: number;
|
|
67
|
-
height?: number;
|
|
68
|
-
isAudio?: boolean;
|
|
69
|
-
priority?: boolean;
|
|
70
|
-
className?: string;
|
|
71
|
-
}
|
|
72
|
-
export interface PriceRenderProps {
|
|
73
|
-
value?: number | null;
|
|
74
|
-
compareAtValue?: number | null;
|
|
75
|
-
className?: string;
|
|
76
|
-
compareAtClassName?: string;
|
|
77
|
-
}
|
|
78
|
-
export interface HtmlRenderProps {
|
|
79
|
-
html: string;
|
|
80
|
-
className?: string;
|
|
81
|
-
onReadMore?: () => void;
|
|
82
|
-
maxHeight?: "sm" | "md" | "lg";
|
|
83
|
-
}
|
|
84
|
-
export interface ItemRenderProps {
|
|
85
|
-
item: CollectionItem;
|
|
86
|
-
href?: string | null;
|
|
87
|
-
index: number;
|
|
88
|
-
number?: number;
|
|
89
|
-
variant: "card" | "featured" | "special" | "vertical";
|
|
90
|
-
collection?: Collection;
|
|
91
|
-
renderBookMedia?: (props: BookMediaRenderProps) => ReactNode;
|
|
92
|
-
renderPrice?: (props: PriceRenderProps) => ReactNode;
|
|
93
|
-
renderHtml?: (props: HtmlRenderProps) => ReactNode;
|
|
94
|
-
}
|
|
95
|
-
export interface CarouselRenderProps {
|
|
96
|
-
id: string;
|
|
97
|
-
slides: ReactNode[];
|
|
98
|
-
className?: string;
|
|
99
|
-
slideClassName?: string;
|
|
100
|
-
previousLabel: string;
|
|
101
|
-
nextLabel: string;
|
|
102
|
-
showControls?: boolean;
|
|
103
|
-
effect?: "slide" | "coverflow";
|
|
104
|
-
centeredSlides?: boolean;
|
|
105
|
-
loop?: boolean;
|
|
106
|
-
slidesPerView?: number | "auto";
|
|
107
|
-
slidesPerGroupAuto?: boolean;
|
|
108
|
-
spaceBetween?: number;
|
|
109
|
-
breakpoints?: Record<string | number, unknown>;
|
|
110
|
-
}
|
|
111
|
-
export interface CollectionRendererLabels {
|
|
112
|
-
all?: string;
|
|
113
|
-
viewAll?: string;
|
|
114
|
-
readMore?: string;
|
|
115
|
-
previous?: string;
|
|
116
|
-
next?: string;
|
|
117
|
-
}
|
|
118
|
-
export interface CollectionRendererAdapters {
|
|
119
|
-
renderLink?: (props: LinkRenderProps) => ReactNode;
|
|
120
|
-
renderImage?: (props: ImageRenderProps) => ReactNode;
|
|
121
|
-
renderItem?: (props: ItemRenderProps) => ReactNode;
|
|
122
|
-
renderBookMedia?: (props: BookMediaRenderProps) => ReactNode;
|
|
123
|
-
renderPrice?: (props: PriceRenderProps) => ReactNode;
|
|
124
|
-
renderHtml?: (props: HtmlRenderProps) => ReactNode;
|
|
125
|
-
renderCarousel?: (props: CarouselRenderProps) => ReactNode;
|
|
126
|
-
resolveCollectionHref?: (collection: Collection) => string | null | undefined;
|
|
127
|
-
resolveItemHref?: (item: CollectionItem) => string | null | undefined;
|
|
128
|
-
onCollectionClick?: (collection: Collection, href?: string | null) => void;
|
|
129
|
-
onItemClick?: (item: CollectionItem, href?: string | null) => void;
|
|
130
|
-
renderContainer?: (children: ReactNode, props: {
|
|
131
|
-
className?: string;
|
|
132
|
-
}) => ReactNode;
|
|
133
|
-
formatCollectionType?: (type: string) => ReactNode;
|
|
134
|
-
}
|
|
135
|
-
export interface CollectionRendererProps {
|
|
136
|
-
collection: Collection;
|
|
137
|
-
layout?: CollectionLayout | null;
|
|
138
|
-
adapters?: CollectionRendererAdapters;
|
|
139
|
-
labels?: CollectionRendererLabels;
|
|
140
|
-
className?: string;
|
|
141
|
-
}
|
|
1
|
+
import type { CSSProperties, ReactNode } from "react";
|
|
2
|
+
export type CollectionLayoutName = "banner" | "block-grid" | "carousel" | "dynamic" | "featured" | "grid" | "grid-title" | "hero" | "image-grid" | "list" | "relative" | "slide" | "special";
|
|
3
|
+
export type CollectionLayoutDirection = "horizontal" | "vertical";
|
|
4
|
+
export type CollectionLayoutShape = "circle" | "rectangle" | "square";
|
|
5
|
+
export type CollectionItemMediaKind = "audio" | "book" | "ebook" | string;
|
|
6
|
+
export interface CollectionItem {
|
|
7
|
+
id: string;
|
|
8
|
+
title?: string | null;
|
|
9
|
+
author?: string | null;
|
|
10
|
+
description?: string | null;
|
|
11
|
+
imageUrl?: string | null;
|
|
12
|
+
productId?: string | null;
|
|
13
|
+
type?: CollectionItemMediaKind | null;
|
|
14
|
+
price?: number | null;
|
|
15
|
+
discountPrice?: number | null;
|
|
16
|
+
href?: string | null;
|
|
17
|
+
sort?: number | null;
|
|
18
|
+
metadata?: Record<string, unknown>;
|
|
19
|
+
}
|
|
20
|
+
export interface CollectionLayout {
|
|
21
|
+
name: CollectionLayoutName;
|
|
22
|
+
direction?: CollectionLayoutDirection | null;
|
|
23
|
+
isNumbered?: boolean | null;
|
|
24
|
+
columns?: number | null;
|
|
25
|
+
itemLimit?: number | null;
|
|
26
|
+
shape?: CollectionLayoutShape | null;
|
|
27
|
+
}
|
|
28
|
+
export interface Collection {
|
|
29
|
+
id: string;
|
|
30
|
+
name?: string | null;
|
|
31
|
+
description?: string | null;
|
|
32
|
+
imageUrl?: string | null;
|
|
33
|
+
linkName?: string | null;
|
|
34
|
+
href?: string | null;
|
|
35
|
+
type?: string | null;
|
|
36
|
+
sort?: number | null;
|
|
37
|
+
layout?: CollectionLayout | null;
|
|
38
|
+
items?: CollectionItem[] | null;
|
|
39
|
+
collections?: Collection[] | null;
|
|
40
|
+
metadata?: Record<string, unknown>;
|
|
41
|
+
}
|
|
42
|
+
export interface LinkRenderProps {
|
|
43
|
+
href: string;
|
|
44
|
+
children: ReactNode;
|
|
45
|
+
className?: string;
|
|
46
|
+
collection?: Collection;
|
|
47
|
+
item?: CollectionItem;
|
|
48
|
+
onClick?: () => void;
|
|
49
|
+
}
|
|
50
|
+
export interface ImageRenderProps {
|
|
51
|
+
src: string;
|
|
52
|
+
alt: string;
|
|
53
|
+
width: number;
|
|
54
|
+
height: number;
|
|
55
|
+
className?: string;
|
|
56
|
+
priority?: boolean;
|
|
57
|
+
sizes?: string;
|
|
58
|
+
style?: CSSProperties;
|
|
59
|
+
collection?: Collection;
|
|
60
|
+
item?: CollectionItem;
|
|
61
|
+
}
|
|
62
|
+
export interface BookMediaRenderProps {
|
|
63
|
+
item: CollectionItem;
|
|
64
|
+
src?: string | null;
|
|
65
|
+
alt: string;
|
|
66
|
+
width?: number;
|
|
67
|
+
height?: number;
|
|
68
|
+
isAudio?: boolean;
|
|
69
|
+
priority?: boolean;
|
|
70
|
+
className?: string;
|
|
71
|
+
}
|
|
72
|
+
export interface PriceRenderProps {
|
|
73
|
+
value?: number | null;
|
|
74
|
+
compareAtValue?: number | null;
|
|
75
|
+
className?: string;
|
|
76
|
+
compareAtClassName?: string;
|
|
77
|
+
}
|
|
78
|
+
export interface HtmlRenderProps {
|
|
79
|
+
html: string;
|
|
80
|
+
className?: string;
|
|
81
|
+
onReadMore?: () => void;
|
|
82
|
+
maxHeight?: "sm" | "md" | "lg";
|
|
83
|
+
}
|
|
84
|
+
export interface ItemRenderProps {
|
|
85
|
+
item: CollectionItem;
|
|
86
|
+
href?: string | null;
|
|
87
|
+
index: number;
|
|
88
|
+
number?: number;
|
|
89
|
+
variant: "card" | "featured" | "special" | "vertical";
|
|
90
|
+
collection?: Collection;
|
|
91
|
+
renderBookMedia?: (props: BookMediaRenderProps) => ReactNode;
|
|
92
|
+
renderPrice?: (props: PriceRenderProps) => ReactNode;
|
|
93
|
+
renderHtml?: (props: HtmlRenderProps) => ReactNode;
|
|
94
|
+
}
|
|
95
|
+
export interface CarouselRenderProps {
|
|
96
|
+
id: string;
|
|
97
|
+
slides: ReactNode[];
|
|
98
|
+
className?: string;
|
|
99
|
+
slideClassName?: string;
|
|
100
|
+
previousLabel: string;
|
|
101
|
+
nextLabel: string;
|
|
102
|
+
showControls?: boolean;
|
|
103
|
+
effect?: "slide" | "coverflow";
|
|
104
|
+
centeredSlides?: boolean;
|
|
105
|
+
loop?: boolean;
|
|
106
|
+
slidesPerView?: number | "auto";
|
|
107
|
+
slidesPerGroupAuto?: boolean;
|
|
108
|
+
spaceBetween?: number;
|
|
109
|
+
breakpoints?: Record<string | number, unknown>;
|
|
110
|
+
}
|
|
111
|
+
export interface CollectionRendererLabels {
|
|
112
|
+
all?: string;
|
|
113
|
+
viewAll?: string;
|
|
114
|
+
readMore?: string;
|
|
115
|
+
previous?: string;
|
|
116
|
+
next?: string;
|
|
117
|
+
}
|
|
118
|
+
export interface CollectionRendererAdapters {
|
|
119
|
+
renderLink?: (props: LinkRenderProps) => ReactNode;
|
|
120
|
+
renderImage?: (props: ImageRenderProps) => ReactNode;
|
|
121
|
+
renderItem?: (props: ItemRenderProps) => ReactNode;
|
|
122
|
+
renderBookMedia?: (props: BookMediaRenderProps) => ReactNode;
|
|
123
|
+
renderPrice?: (props: PriceRenderProps) => ReactNode;
|
|
124
|
+
renderHtml?: (props: HtmlRenderProps) => ReactNode;
|
|
125
|
+
renderCarousel?: (props: CarouselRenderProps) => ReactNode;
|
|
126
|
+
resolveCollectionHref?: (collection: Collection) => string | null | undefined;
|
|
127
|
+
resolveItemHref?: (item: CollectionItem) => string | null | undefined;
|
|
128
|
+
onCollectionClick?: (collection: Collection, href?: string | null) => void;
|
|
129
|
+
onItemClick?: (item: CollectionItem, href?: string | null) => void;
|
|
130
|
+
renderContainer?: (children: ReactNode, props: {
|
|
131
|
+
className?: string;
|
|
132
|
+
}) => ReactNode;
|
|
133
|
+
formatCollectionType?: (type: string) => ReactNode;
|
|
134
|
+
}
|
|
135
|
+
export interface CollectionRendererProps {
|
|
136
|
+
collection: Collection;
|
|
137
|
+
layout?: CollectionLayout | null;
|
|
138
|
+
adapters?: CollectionRendererAdapters;
|
|
139
|
+
labels?: CollectionRendererLabels;
|
|
140
|
+
className?: string;
|
|
141
|
+
}
|
|
142
142
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
2
2
|
//# sourceMappingURL=types.js.map
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { Collection, CollectionItem } from "./types";
|
|
2
|
-
export declare function cx(...values: Array<string | false | null | undefined>): string;
|
|
3
|
-
export declare function sortCollections(items?: Collection[] | null): Collection[];
|
|
4
|
-
export declare function compact<T>(items?: Array<T | null | undefined> | null): T[];
|
|
5
|
-
export declare function hasItems(collection: Collection): boolean;
|
|
6
|
-
export declare function hasCollections(collection: Collection): boolean;
|
|
7
|
-
export declare function defaultCollectionHref(collection: Collection): string | null;
|
|
8
|
-
export declare function defaultItemHref(item: CollectionItem): string | null;
|
|
1
|
+
import type { Collection, CollectionItem } from "./types";
|
|
2
|
+
export declare function cx(...values: Array<string | false | null | undefined>): string;
|
|
3
|
+
export declare function sortCollections(items?: Collection[] | null): Collection[];
|
|
4
|
+
export declare function compact<T>(items?: Array<T | null | undefined> | null): T[];
|
|
5
|
+
export declare function hasItems(collection: Collection): boolean;
|
|
6
|
+
export declare function hasCollections(collection: Collection): boolean;
|
|
7
|
+
export declare function defaultCollectionHref(collection: Collection): string | null;
|
|
8
|
+
export declare function defaultItemHref(item: CollectionItem): string | null;
|
|
9
9
|
//# sourceMappingURL=utils.d.ts.map
|
package/dist/utils.js
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
export function cx(...values) {
|
|
2
|
-
return values.filter(Boolean).join(" ");
|
|
3
|
-
}
|
|
4
|
-
export function sortCollections(items) {
|
|
5
|
-
return [...compact(items)].sort((a, b) => {
|
|
6
|
-
if (a.sort != null || b.sort != null) {
|
|
7
|
-
return (b.sort ?? Number.NEGATIVE_INFINITY) - (a.sort ?? Number.NEGATIVE_INFINITY);
|
|
8
|
-
}
|
|
9
|
-
return (a.name ?? "").localeCompare(b.name ?? "");
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
export function compact(items) {
|
|
13
|
-
return (items ?? []).filter((item) => Boolean(item));
|
|
14
|
-
}
|
|
15
|
-
export function hasItems(collection) {
|
|
16
|
-
return compact(collection.items).length > 0;
|
|
17
|
-
}
|
|
18
|
-
export function hasCollections(collection) {
|
|
19
|
-
return compact(collection.collections).length > 0;
|
|
20
|
-
}
|
|
21
|
-
export function defaultCollectionHref(collection) {
|
|
22
|
-
return collection.href ?? collection.linkName ?? null;
|
|
23
|
-
}
|
|
24
|
-
export function defaultItemHref(item) {
|
|
25
|
-
return item.href ?? null;
|
|
26
|
-
}
|
|
1
|
+
export function cx(...values) {
|
|
2
|
+
return values.filter(Boolean).join(" ");
|
|
3
|
+
}
|
|
4
|
+
export function sortCollections(items) {
|
|
5
|
+
return [...compact(items)].sort((a, b) => {
|
|
6
|
+
if (a.sort != null || b.sort != null) {
|
|
7
|
+
return (b.sort ?? Number.NEGATIVE_INFINITY) - (a.sort ?? Number.NEGATIVE_INFINITY);
|
|
8
|
+
}
|
|
9
|
+
return (a.name ?? "").localeCompare(b.name ?? "");
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
export function compact(items) {
|
|
13
|
+
return (items ?? []).filter((item) => Boolean(item));
|
|
14
|
+
}
|
|
15
|
+
export function hasItems(collection) {
|
|
16
|
+
return compact(collection.items).length > 0;
|
|
17
|
+
}
|
|
18
|
+
export function hasCollections(collection) {
|
|
19
|
+
return compact(collection.collections).length > 0;
|
|
20
|
+
}
|
|
21
|
+
export function defaultCollectionHref(collection) {
|
|
22
|
+
return collection.href ?? collection.linkName ?? null;
|
|
23
|
+
}
|
|
24
|
+
export function defaultItemHref(item) {
|
|
25
|
+
return item.href ?? null;
|
|
26
|
+
}
|
|
27
27
|
//# sourceMappingURL=utils.js.map
|
package/package.json
CHANGED