@base44/app-plugin-commerce 0.5.1 → 0.6.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 +2 -2
- package/package.json +1 -1
- package/skills/commerce/SKILL.md +64 -50
- package/skills/commerce/install/01-install.md +1 -1
- package/skills/commerce/install/02-storefront.md +165 -155
- package/skills/commerce/references/storefront-verification.md +0 -4
- package/src/commerce/storefront/AddressFields.jsx +150 -0
- package/src/commerce/storefront/StorefrontProvider.jsx +3 -10
- package/src/commerce/storefront/cartUI.jsx +17 -63
- package/src/commerce/storefront/index.js +6 -30
- package/src/commerce/storefront/useCheckout.jsx +0 -27
- package/skills/commerce/references/storefront-custom.md +0 -150
- package/skills/commerce/references/storefront-parts.md +0 -184
- package/src/commerce/storefront/parts/cart.jsx +0 -191
- package/src/commerce/storefront/parts/checkout.jsx +0 -540
- package/src/commerce/storefront/parts/drawer.jsx +0 -87
- package/src/commerce/storefront/parts/labels.jsx +0 -140
- package/src/commerce/storefront/parts/orderReceived.jsx +0 -200
- package/src/commerce/storefront/parts/parts.css +0 -215
- package/src/commerce/storefront/parts/shared.jsx +0 -137
- package/src/commerce/storefront/parts/visibility.js +0 -36
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `show` — the parts' display settings: which of a part's sub-elements render,
|
|
3
|
-
* decided in JSX rather than hidden with CSS. Hiding with `display: none` leaves
|
|
4
|
-
* the element in the layout and in the accessibility tree (an empty thumbnail
|
|
5
|
-
* box, a screen reader still announcing a row's attributes); `show` renders
|
|
6
|
-
* nothing at all.
|
|
7
|
-
*
|
|
8
|
-
* Two shapes, both accepted everywhere:
|
|
9
|
-
*
|
|
10
|
-
* show={{ media: false }} // overrides on the part's defaults
|
|
11
|
-
* show={["subtotal", "total"]} // exactly these, nothing else
|
|
12
|
-
*
|
|
13
|
-
* Keys are the part's `data-part` names (`media`, `attributes`, `stepper`,
|
|
14
|
-
* `lineTotal`, `blockers`, a totals row key, an address field key) — the same
|
|
15
|
-
* vocabulary as `classes` and the CSS selectors, so there is one set of names
|
|
16
|
-
* to know. Per-part key lists: the commerce skill's install/02-storefront.md.
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Build the predicate a part asks for each sub-element.
|
|
21
|
-
*
|
|
22
|
-
* @param {object|string[]|undefined} show the part's `show` prop
|
|
23
|
-
* @param {Record<string, boolean>} [defaults] keys whose default is not `true`
|
|
24
|
-
* @returns {(key: string) => boolean}
|
|
25
|
-
*/
|
|
26
|
-
export function visible(show, defaults = {}) {
|
|
27
|
-
if (Array.isArray(show)) {
|
|
28
|
-
const only = new Set(show);
|
|
29
|
-
return (key) => only.has(key);
|
|
30
|
-
}
|
|
31
|
-
return (key) => {
|
|
32
|
-
const asked = show?.[key];
|
|
33
|
-
if (asked !== undefined) return Boolean(asked);
|
|
34
|
-
return defaults[key] ?? true;
|
|
35
|
-
};
|
|
36
|
-
}
|