@numueg/theme-sdk 0.3.1 → 0.3.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/dist/index.cjs +13 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +13 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.mjs +13 -5
- package/dist/index.mjs.map +1 -1
- package/dist/v2-compat.cjs.map +1 -1
- package/dist/v2-compat.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -146,6 +146,12 @@ interface MenuItemData {
|
|
|
146
146
|
url: string;
|
|
147
147
|
type?: string | null;
|
|
148
148
|
resource_id?: string | null;
|
|
149
|
+
/**
|
|
150
|
+
* §5 hide-page → hide-nav-link. `false` when the item targets a CMS page
|
|
151
|
+
* (`/pages/<handle>`) that is currently unpublished or deleted. The backend
|
|
152
|
+
* menus resolver annotates it; absent/`true` means visible (back-compat).
|
|
153
|
+
*/
|
|
154
|
+
target_visible?: boolean;
|
|
149
155
|
children?: MenuItemData[];
|
|
150
156
|
}
|
|
151
157
|
/**
|
|
@@ -485,6 +491,13 @@ interface NavigationItem {
|
|
|
485
491
|
/** Optional foreign keys when the item references a typed resource. */
|
|
486
492
|
resource_type?: "product" | "collection" | "page" | "blog" | "article" | "url" | null;
|
|
487
493
|
resource_handle?: string | null;
|
|
494
|
+
/**
|
|
495
|
+
* §5 hide-page → hide-nav-link. `false` when the target CMS page is
|
|
496
|
+
* unpublished/deleted (backend-annotated). Defaults to `true` (visible)
|
|
497
|
+
* when the backend doesn't annotate, so themes can safely filter on
|
|
498
|
+
* `item.target_visible !== false`.
|
|
499
|
+
*/
|
|
500
|
+
target_visible: boolean;
|
|
488
501
|
children: NavigationItem[];
|
|
489
502
|
}
|
|
490
503
|
interface NavigationState {
|
package/dist/index.d.ts
CHANGED
|
@@ -146,6 +146,12 @@ interface MenuItemData {
|
|
|
146
146
|
url: string;
|
|
147
147
|
type?: string | null;
|
|
148
148
|
resource_id?: string | null;
|
|
149
|
+
/**
|
|
150
|
+
* §5 hide-page → hide-nav-link. `false` when the item targets a CMS page
|
|
151
|
+
* (`/pages/<handle>`) that is currently unpublished or deleted. The backend
|
|
152
|
+
* menus resolver annotates it; absent/`true` means visible (back-compat).
|
|
153
|
+
*/
|
|
154
|
+
target_visible?: boolean;
|
|
149
155
|
children?: MenuItemData[];
|
|
150
156
|
}
|
|
151
157
|
/**
|
|
@@ -485,6 +491,13 @@ interface NavigationItem {
|
|
|
485
491
|
/** Optional foreign keys when the item references a typed resource. */
|
|
486
492
|
resource_type?: "product" | "collection" | "page" | "blog" | "article" | "url" | null;
|
|
487
493
|
resource_handle?: string | null;
|
|
494
|
+
/**
|
|
495
|
+
* §5 hide-page → hide-nav-link. `false` when the target CMS page is
|
|
496
|
+
* unpublished/deleted (backend-annotated). Defaults to `true` (visible)
|
|
497
|
+
* when the backend doesn't annotate, so themes can safely filter on
|
|
498
|
+
* `item.target_visible !== false`.
|
|
499
|
+
*/
|
|
500
|
+
target_visible: boolean;
|
|
488
501
|
children: NavigationItem[];
|
|
489
502
|
}
|
|
490
503
|
interface NavigationState {
|
package/dist/index.mjs
CHANGED
|
@@ -526,9 +526,8 @@ function toNavigationItem(raw, locale) {
|
|
|
526
526
|
url: raw.url || "/",
|
|
527
527
|
resource_type: mapResourceType(raw.type),
|
|
528
528
|
resource_handle: raw.resource_id ?? null,
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
)
|
|
529
|
+
target_visible: raw.target_visible !== false,
|
|
530
|
+
children: (raw.children ?? []).map((child) => toNavigationItem(child, locale)).filter((child) => child.target_visible)
|
|
532
531
|
};
|
|
533
532
|
}
|
|
534
533
|
function useNavigation(handle, options) {
|
|
@@ -538,7 +537,8 @@ function useNavigation(handle, options) {
|
|
|
538
537
|
const hostProvidedAny = !!navMap && Object.keys(navMap).length > 0;
|
|
539
538
|
const rawItems = handle ? navMap?.[handle] : void 0;
|
|
540
539
|
const hostItems = useMemo(() => {
|
|
541
|
-
if (rawItems)
|
|
540
|
+
if (rawItems)
|
|
541
|
+
return rawItems.map((it) => toNavigationItem(it, locale)).filter((it) => it.target_visible);
|
|
542
542
|
if (hostProvidedAny) return [];
|
|
543
543
|
return null;
|
|
544
544
|
}, [rawItems, hostProvidedAny, locale]);
|
|
@@ -1475,7 +1475,15 @@ function normalizeCartFromServer(cart) {
|
|
|
1475
1475
|
subtotal: toMajor(cart.subtotal),
|
|
1476
1476
|
total: toMajor(cart.total),
|
|
1477
1477
|
...cart.discount_amount != null ? { discount_amount: toMajor(cart.discount_amount) } : {},
|
|
1478
|
-
items: Array.isArray(cart.items) ? cart.items.map((it) =>
|
|
1478
|
+
items: Array.isArray(cart.items) ? cart.items.map((it) => {
|
|
1479
|
+
const raw = it;
|
|
1480
|
+
return {
|
|
1481
|
+
...it,
|
|
1482
|
+
name: raw.name || raw.product_name || "",
|
|
1483
|
+
price: toMajor(raw.price ?? raw.unit_price),
|
|
1484
|
+
variant_name: raw.variant_name ?? void 0
|
|
1485
|
+
};
|
|
1486
|
+
}) : []
|
|
1479
1487
|
};
|
|
1480
1488
|
}
|
|
1481
1489
|
function unwrapCart(json) {
|