@chinggis.systems/collection-ui 1.0.0 → 1.0.2
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 +368 -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 +23 -13
- package/dist/primitives/CollectionCarousel.js.map +1 -1
- package/dist/styles.css +333 -52
- package/dist/types.d.ts +147 -141
- package/dist/types.d.ts.map +1 -1
- 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/README.md
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
Reusable React renderer for Internom collection layouts.
|
|
4
4
|
|
|
5
|
-
The package owns normalized collection rendering, commerce-oriented item cards, book-spine media, price/rich-text fallbacks, Swiper carousel rendering,
|
|
5
|
+
The package owns normalized collection rendering, commerce-oriented item cards, book-spine media, price/rich-text fallbacks, Swiper carousel rendering, Collection V2 normalization, and Internom storefront defaults. Apps can pass raw collection data through props and only override adapters when they need framework-specific behavior.
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
9
9
|
```sh
|
|
10
|
-
yarn add @internom/collection-ui
|
|
10
|
+
yarn add @internom/collection-ui
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
Import the package stylesheet once. It includes the Swiper base/navigation CSS used by `CollectionCarousel`.
|
|
@@ -16,46 +16,32 @@ Import the package stylesheet once. It includes the Swiper base/navigation CSS u
|
|
|
16
16
|
import "@internom/collection-ui/styles.css";
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
-
##
|
|
19
|
+
## Simple Usage
|
|
20
20
|
|
|
21
21
|
```tsx
|
|
22
|
-
import {
|
|
23
|
-
CollectionRenderer,
|
|
24
|
-
createCollectionRendererAdapters,
|
|
25
|
-
normalizeCollection,
|
|
26
|
-
} from "@internom/collection-ui";
|
|
22
|
+
import { CollectionView } from "@internom/collection-ui";
|
|
27
23
|
import "@internom/collection-ui/styles.css";
|
|
28
24
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
export function CollectionPreview({ collection }: { collection: unknown }) {
|
|
25
|
+
export function CollectionPreview({
|
|
26
|
+
collection,
|
|
27
|
+
renderStyle,
|
|
28
|
+
}: {
|
|
29
|
+
collection: unknown;
|
|
30
|
+
renderStyle?: unknown;
|
|
31
|
+
}) {
|
|
39
32
|
return (
|
|
40
|
-
<
|
|
41
|
-
collection={
|
|
42
|
-
|
|
33
|
+
<CollectionView
|
|
34
|
+
collection={collection as any}
|
|
35
|
+
renderStyle={renderStyle as any}
|
|
43
36
|
className="collection-ui--dark collection-ui--preview"
|
|
44
|
-
labels={{
|
|
45
|
-
all: "Бүгд",
|
|
46
|
-
viewAll: "Бүгдийг үзэх",
|
|
47
|
-
readMore: "Дэлгэрэнгүй үзэх",
|
|
48
|
-
previous: "Өмнөх",
|
|
49
|
-
next: "Дараах",
|
|
50
|
-
}}
|
|
51
37
|
/>
|
|
52
38
|
);
|
|
53
39
|
}
|
|
54
40
|
```
|
|
55
41
|
|
|
56
|
-
Use `collection-ui--preview` inside admin panes. It keeps media/images smaller
|
|
42
|
+
Use `collection-ui--preview` inside admin panes. It keeps media/images smaller, caps the preview height so the form controls stay usable, and prevents preview links from navigating away from the form. Drop that class for storefront/full-page rendering.
|
|
57
43
|
|
|
58
|
-
`
|
|
44
|
+
`CollectionView` accepts Collection V2 fields modeled after `shared/model/core/collection/collection.model.ts`:
|
|
59
45
|
|
|
60
46
|
```ts
|
|
61
47
|
normalizeCollection({
|
|
@@ -90,6 +76,7 @@ import {
|
|
|
90
76
|
BookSpine,
|
|
91
77
|
CollectionCarousel,
|
|
92
78
|
CollectionRenderer,
|
|
79
|
+
CollectionView,
|
|
93
80
|
getCollectionLayoutControls,
|
|
94
81
|
getCollectionLayoutDefinition,
|
|
95
82
|
createCollectionRendererAdapters,
|
|
@@ -125,9 +112,9 @@ Examples:
|
|
|
125
112
|
- `image-grid`: show shape.
|
|
126
113
|
- `list`, `dynamic`: show direction and numbered toggle.
|
|
127
114
|
|
|
128
|
-
##
|
|
115
|
+
## Optional App Integration
|
|
129
116
|
|
|
130
|
-
The built-in package skin is framework-free and production-oriented. If an app needs
|
|
117
|
+
The built-in package skin is framework-free and production-oriented. If an app needs app-specific components, provide adapters:
|
|
131
118
|
|
|
132
119
|
- `renderLink` for router links.
|
|
133
120
|
- `renderImage` for optimized images.
|
|
@@ -137,17 +124,15 @@ The built-in package skin is framework-free and production-oriented. If an app n
|
|
|
137
124
|
- `renderHtml` for app rich-text clamping.
|
|
138
125
|
- `renderItem` for app product cards.
|
|
139
126
|
|
|
140
|
-
This repository includes an example at `src/ui/collection/ecommerceCollectionRendererAdapters.tsx`.
|
|
141
|
-
|
|
142
127
|
## Admin Checklist
|
|
143
128
|
|
|
144
129
|
If admin preview still looks different from internom.mn:
|
|
145
130
|
|
|
146
131
|
- Use real REST item data, not placeholder cards.
|
|
147
|
-
- Use `
|
|
132
|
+
- Use `CollectionView` for the default independent package renderer, or `normalizeCollection` with `CollectionRenderer` for low-level control.
|
|
148
133
|
- Import `@internom/collection-ui/styles.css`.
|
|
149
134
|
- Use `className="collection-ui--dark collection-ui--preview"` in admin panes.
|
|
150
|
-
-
|
|
135
|
+
- Override `adapterOptions` only when a host app has different routes, image hosts, or item type names.
|
|
151
136
|
- Ensure the admin preview shell is not adding a conflicting fixed card/background around the collection if you expect full-width storefront parity.
|
|
152
137
|
|
|
153
138
|
## Build
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { CollectionRendererProps } from "./types";
|
|
2
|
-
export declare function CollectionRenderer({ collection, layout, adapters, labels, className, }: CollectionRendererProps): import("react/jsx-runtime").JSX.Element | null;
|
|
1
|
+
import type { CollectionRendererProps } from "./types";
|
|
2
|
+
export declare function CollectionRenderer({ collection, layout, adapters, labels, className, }: CollectionRendererProps): import("react/jsx-runtime").JSX.Element | null;
|
|
3
3
|
//# sourceMappingURL=CollectionRenderer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CollectionRenderer.d.ts","sourceRoot":"","sources":["../src/CollectionRenderer.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CollectionRenderer.d.ts","sourceRoot":"","sources":["../src/CollectionRenderer.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAMV,uBAAuB,EAGxB,MAAM,SAAS,CAAC;AAiBjB,wBAAgB,kBAAkB,CAAC,EACjC,UAAU,EACV,MAAM,EACN,QAAQ,EACR,MAAM,EACN,SAAS,GACV,EAAE,uBAAuB,kDA4BzB"}
|