@vectoriox/iox-ui 5.95.0 → 5.96.0
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/package.json
CHANGED
|
@@ -2,7 +2,7 @@ import { ShopWord, shopWord } from '@vectoriox/iox-ui/commerce-core';
|
|
|
2
2
|
import type { ProductOption } from '@vectoriox/iox-ui/commerce-core';
|
|
3
3
|
import { roleClass } from '@vectoriox/iox-ui/design-core';
|
|
4
4
|
|
|
5
|
-
import { CompositeNode, CompositeNodeFactory, makeCompositePart, writeProp } from './composite-node';
|
|
5
|
+
import { CompositeNode, CompositeNodeFactory, findByRole, makeCompositePart, writeProp } from './composite-node';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* THE SHOP PARTS (commerce E1c, C-D16 — commerce board 10). Not components: recipes of ordinary builder nodes, each part
|
|
@@ -431,3 +431,28 @@ export const SHOP_RECIPES: Readonly<Record<ShopRecipe, (create: CompositeNodeFac
|
|
|
431
431
|
[ShopRecipe.CartButton]: buildCartButtonRecipe,
|
|
432
432
|
[ShopRecipe.CartDrawer]: buildCartDrawerRecipe,
|
|
433
433
|
});
|
|
434
|
+
|
|
435
|
+
/** The recipe a site holds ONCE, as a global element after the page (the bag every page opens) — never in a section. */
|
|
436
|
+
export const SHOP_GLOBAL_RECIPES: ReadonlySet<ShopRecipe> = new Set([ShopRecipe.CartDrawer]);
|
|
437
|
+
|
|
438
|
+
/** What a composed part binds by ROLE (shop-aware A-D2/A-D3 as amended by C-D7): a listing's price reads its ROW's
|
|
439
|
+
* `@price` / `@compareAt` instead of the product page's chosen variant. The money pipe stays. */
|
|
440
|
+
export enum ShopBindTarget {
|
|
441
|
+
Price = 'price',
|
|
442
|
+
CompareAt = 'compareAt',
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
export const SHOP_BINDS: Readonly<Record<ShopBindTarget, { recipe: ShopRecipe; role: ShopRole; prop: string }>> = Object.freeze({
|
|
446
|
+
[ShopBindTarget.Price]: { recipe: ShopRecipe.Price, role: ShopRole.PriceAmount, prop: 'content' },
|
|
447
|
+
[ShopBindTarget.CompareAt]: { recipe: ShopRecipe.Price, role: ShopRole.PriceCompare, prop: 'content' },
|
|
448
|
+
});
|
|
449
|
+
|
|
450
|
+
/** Bind one part of a stamped recipe to `source` + `path` (the composer's resolved role), replacing its slot binding and
|
|
451
|
+
* keeping the money pipe. False when the recipe holds no such part. */
|
|
452
|
+
export function bindShopPart(root: CompositeNode, target: ShopBindTarget, source: string, path: string): boolean {
|
|
453
|
+
const bind = SHOP_BINDS[target];
|
|
454
|
+
const part = findByRole(root, bind.role);
|
|
455
|
+
if (!part) return false;
|
|
456
|
+
bindSlot(part, bind.prop, source, path, true);
|
|
457
|
+
return true;
|
|
458
|
+
}
|