@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.
Files changed (42) hide show
  1. package/README.md +21 -36
  2. package/dist/CollectionRenderer.d.ts +2 -2
  3. package/dist/CollectionRenderer.d.ts.map +1 -1
  4. package/dist/CollectionRenderer.js +305 -292
  5. package/dist/CollectionRenderer.js.map +1 -1
  6. package/dist/CollectionView.d.ts +13 -0
  7. package/dist/CollectionView.d.ts.map +1 -0
  8. package/dist/CollectionView.js +42 -0
  9. package/dist/CollectionView.js.map +1 -0
  10. package/dist/assets/spine/BurnBlend.png +0 -0
  11. package/dist/assets/spine/FlatEdges.webp +0 -0
  12. package/dist/assets/spine/FlatShadow.webp +0 -0
  13. package/dist/assets/spine/NormalBlend.webp +0 -0
  14. package/dist/assets/spine/SoftLightBlend.webp +0 -0
  15. package/dist/collectionV2Model.d.ts +43 -0
  16. package/dist/collectionV2Model.d.ts.map +1 -0
  17. package/dist/collectionV2Model.js +4 -0
  18. package/dist/collectionV2Model.js.map +1 -0
  19. package/dist/createAdapters.d.ts +66 -74
  20. package/dist/createAdapters.d.ts.map +1 -1
  21. package/dist/createAdapters.js +223 -223
  22. package/dist/createAdapters.js.map +1 -1
  23. package/dist/defaultAdapters.d.ts +7 -7
  24. package/dist/defaultAdapters.js +8 -8
  25. package/dist/index.d.ts +14 -11
  26. package/dist/index.d.ts.map +1 -1
  27. package/dist/index.js +7 -6
  28. package/dist/index.js.map +1 -1
  29. package/dist/layoutPresets.d.ts +18 -18
  30. package/dist/layoutPresets.js +129 -129
  31. package/dist/primitives/BookSpine.d.ts +11 -11
  32. package/dist/primitives/BookSpine.js +10 -10
  33. package/dist/primitives/CollectionCarousel.d.ts +3 -3
  34. package/dist/primitives/CollectionCarousel.d.ts.map +1 -1
  35. package/dist/primitives/CollectionCarousel.js +22 -13
  36. package/dist/primitives/CollectionCarousel.js.map +1 -1
  37. package/dist/styles.css +236 -51
  38. package/dist/types.d.ts +141 -141
  39. package/dist/types.js +1 -1
  40. package/dist/utils.d.ts +8 -8
  41. package/dist/utils.js +26 -26
  42. 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, and Collection V2 normalization. Apps still configure route prefixes, image base URLs, item type checks, tracking, and framework-specific adapters when needed.
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 swiper
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
- ## Collection V2 Usage
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
- const adapters = createCollectionRendererAdapters({
30
- collectionBasePath: "/collection",
31
- itemBasePath: "/entity/id",
32
- thumbBaseUrl: "https://image.internom.mn/public/product-thumb/",
33
- isAudioType: (type) => type === "AUDIO" || type === "audio",
34
- isProductType: (type) => ["TOY", "GIFT", "STATIONARY"].includes(String(type)),
35
- readMoreLabel: "Дэлгэрэнгүй үзэх",
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
- <CollectionRenderer
41
- collection={normalizeCollection(collection as any)}
42
- adapters={adapters}
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 and caps the preview height so the form controls stay usable. Drop that class for storefront/full-page rendering.
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
- `normalizeCollection` accepts Collection V2-style REST fields:
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
- ## Exact App Integration
115
+ ## Optional App Integration
129
116
 
130
- The built-in package skin is framework-free and production-oriented. If an app needs exact internom.mn parity with app-specific components, provide adapters:
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 `normalizeCollection` on the Collection V2 REST payload.
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
- - Configure `thumbBaseUrl`, `collectionBasePath`, `itemBasePath`, `isAudioType`, and `isProductType`.
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":"AAEA,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,kDA0BzB"}
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"}