@numueg/theme-sdk 0.4.0 → 0.5.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/dist/index.cjs +118 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +94 -1
- package/dist/index.d.ts +94 -1
- package/dist/index.mjs +115 -7
- package/dist/index.mjs.map +1 -1
- package/dist/validation.cjs +1 -1
- package/dist/validation.mjs +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1286,6 +1286,29 @@ interface ImageProps extends Omit<ImgHTMLAttributes<HTMLImageElement>, "src" | "
|
|
|
1286
1286
|
*/
|
|
1287
1287
|
declare function Image({ src, alt, sizes, responsive, loading, aspectRatio, objectFit, objectPosition, transform, className, style, ...rest }: ImageProps): react.JSX.Element;
|
|
1288
1288
|
|
|
1289
|
+
interface LogoProps {
|
|
1290
|
+
/** Explicit logo URL; falls back to global_settings.logo_url then shop.logo_url. */
|
|
1291
|
+
src?: string | null;
|
|
1292
|
+
/** Alt text; falls back to the brand name / shop name. */
|
|
1293
|
+
alt?: string;
|
|
1294
|
+
/** Overrides `global_settings.logo_shape` (none/square/rounded/circle/triangle). */
|
|
1295
|
+
shape?: string;
|
|
1296
|
+
/** Overrides `global_settings.logo_size` (small/medium/large). */
|
|
1297
|
+
size?: string;
|
|
1298
|
+
className?: string;
|
|
1299
|
+
style?: CSSProperties;
|
|
1300
|
+
/** Rendered when there is no logo URL (e.g. brand-name text). */
|
|
1301
|
+
fallback?: ReactNode;
|
|
1302
|
+
}
|
|
1303
|
+
/**
|
|
1304
|
+
* Engine-level store logo. Reads `logo_url`, `logo_shape`, and `logo_size` from
|
|
1305
|
+
* the theme's global settings (overridable via props), and renders a plain
|
|
1306
|
+
* `<img>` with the chosen shape/size applied via inline styles — so it works in
|
|
1307
|
+
* any theme regardless of its CSS setup and keeps **animated GIF logos playing**
|
|
1308
|
+
* under every shape. Renders `fallback` (or nothing) when no logo is set.
|
|
1309
|
+
*/
|
|
1310
|
+
declare function Logo({ src, alt, shape, size, className, style, fallback, }: LogoProps): react.JSX.Element;
|
|
1311
|
+
|
|
1289
1312
|
interface LinkProps extends Omit<AnchorHTMLAttributes<HTMLAnchorElement>, "href"> {
|
|
1290
1313
|
/**
|
|
1291
1314
|
* Path relative to the storefront root, e.g. "/products/foo",
|
|
@@ -2051,6 +2074,76 @@ declare function computeGlobalStyleTokens(globalSettings: GlobalSettings): Compu
|
|
|
2051
2074
|
*/
|
|
2052
2075
|
declare function applyGlobalStyleTokens(globalSettings: GlobalSettings, el: HTMLElement | null | undefined): void;
|
|
2053
2076
|
|
|
2077
|
+
/**
|
|
2078
|
+
* Engine-level logo appearance (shape + size).
|
|
2079
|
+
*
|
|
2080
|
+
* A merchant can crop the store logo into a shape and pick its size from the
|
|
2081
|
+
* theme editor's global settings (`logo_shape` / `logo_size`). The logic lives
|
|
2082
|
+
* here — once, in the SDK — so EVERY V3 theme renders the chosen shape the same
|
|
2083
|
+
* way instead of each theme re-implementing it.
|
|
2084
|
+
*
|
|
2085
|
+
* Why inline styles (not Tailwind classes): the SDK is consumed from
|
|
2086
|
+
* `node_modules`, which a theme's Tailwind build does not scan — so utility
|
|
2087
|
+
* classes like `rounded-full` / `h-16` would never be generated. Inline
|
|
2088
|
+
* `CSSProperties` are self-contained and work in any theme regardless of its
|
|
2089
|
+
* CSS setup. The shapes are pure CSS (border-radius / clip-path) applied to a
|
|
2090
|
+
* plain `<img>`, so animated **GIF logos keep playing** under every shape.
|
|
2091
|
+
*/
|
|
2092
|
+
|
|
2093
|
+
type LogoShape = "none" | "square" | "rounded" | "circle" | "triangle";
|
|
2094
|
+
type LogoSize = "small" | "medium" | "large";
|
|
2095
|
+
/** Bilingual options for the `logo_shape` global setting (schema authoring). */
|
|
2096
|
+
declare const LOGO_SHAPE_OPTIONS: readonly [{
|
|
2097
|
+
readonly value: "none";
|
|
2098
|
+
readonly label: "Original";
|
|
2099
|
+
readonly label_ar: "الأصلي";
|
|
2100
|
+
}, {
|
|
2101
|
+
readonly value: "square";
|
|
2102
|
+
readonly label: "Square";
|
|
2103
|
+
readonly label_ar: "مربع";
|
|
2104
|
+
}, {
|
|
2105
|
+
readonly value: "rounded";
|
|
2106
|
+
readonly label: "Rounded square";
|
|
2107
|
+
readonly label_ar: "مربع بزوايا دائرية";
|
|
2108
|
+
}, {
|
|
2109
|
+
readonly value: "circle";
|
|
2110
|
+
readonly label: "Circle";
|
|
2111
|
+
readonly label_ar: "دائرة";
|
|
2112
|
+
}, {
|
|
2113
|
+
readonly value: "triangle";
|
|
2114
|
+
readonly label: "Triangle";
|
|
2115
|
+
readonly label_ar: "مثلث";
|
|
2116
|
+
}];
|
|
2117
|
+
/** Bilingual options for the `logo_size` global setting (schema authoring). */
|
|
2118
|
+
declare const LOGO_SIZE_OPTIONS: readonly [{
|
|
2119
|
+
readonly value: "small";
|
|
2120
|
+
readonly label: "Small";
|
|
2121
|
+
readonly label_ar: "صغير";
|
|
2122
|
+
}, {
|
|
2123
|
+
readonly value: "medium";
|
|
2124
|
+
readonly label: "Medium";
|
|
2125
|
+
readonly label_ar: "متوسط";
|
|
2126
|
+
}, {
|
|
2127
|
+
readonly value: "large";
|
|
2128
|
+
readonly label: "Large";
|
|
2129
|
+
readonly label_ar: "كبير";
|
|
2130
|
+
}];
|
|
2131
|
+
/**
|
|
2132
|
+
* Inline style for a logo `<img>` given the merchant's shape + size.
|
|
2133
|
+
*
|
|
2134
|
+
* Returns `undefined` for `none` (and unknown shapes) so the theme keeps its
|
|
2135
|
+
* own native logo sizing untouched — only an explicitly chosen shape overrides
|
|
2136
|
+
* it. A shaped logo gets a fixed square box with `object-fit: cover` plus the
|
|
2137
|
+
* shape (border-radius for square/rounded/circle, clip-path for triangle).
|
|
2138
|
+
*/
|
|
2139
|
+
declare function logoImgStyle(shape: string | undefined, size: string | undefined): CSSProperties | undefined;
|
|
2140
|
+
/**
|
|
2141
|
+
* Derived CSS-custom-property tokens for the chosen logo shape/size. Emitted by
|
|
2142
|
+
* `computeGlobalStyleTokens` so host-rendered surfaces (e.g. the checkout
|
|
2143
|
+
* header) can match the storefront logo. Returns `{}` for `none`.
|
|
2144
|
+
*/
|
|
2145
|
+
declare function logoStyleTokens(shape: string | undefined, size: string | undefined): Record<string, string>;
|
|
2146
|
+
|
|
2054
2147
|
/**
|
|
2055
2148
|
* Theme-bundled locale files: load + merge.
|
|
2056
2149
|
*
|
|
@@ -2109,4 +2202,4 @@ declare function pickTranslations(bundle: LocaleBundle, locale: string): LocaleM
|
|
|
2109
2202
|
*/
|
|
2110
2203
|
declare function buildLocaleBundle<T extends Record<string, unknown>>(modules: T): LocaleBundle;
|
|
2111
2204
|
|
|
2112
|
-
export { AddToCartButton, type AddressInput, type AnalyticsApi, type AnalyticsPayload, type AppManifestBlock, type AppPayload, type AppState, Block, BlockInstance, BlockProps$1 as BlockProps, BlockSchema, Cart, type CheckoutAddress, type CheckoutApi, type CheckoutSessionState, type CheckoutStep, Collection, CollectionCard, type CollectionCardProps, type CollectionCardSlots, CollectionProvider, type ComputedStyleTokens, type CurrencyConfig, type CurrencyState, CurrencySwitcher, type CurrencySwitcherProps, Customer, type CustomerAddress, type CustomerAddressesState, type DefineBlockInput, type DefineSectionInput, type DefinedBlock, type DefinedSection, type DynamicResolveContext, type DynamicSourceRef, EditableImage, type EditableImageProps, EditableText, type EditableTextProps, type FocalSrcOptions, Form, type GiftCardBalance, ICON_NAMES, Icon, IconMap, type IconProps, Image, type ImageTransform, Link, type LocaleBundle, type LocaleMessages, LocaleSwitcher, type LocaleSwitcherProps, MenuItemData, Money, MountResult, type NavigationItem, type NavigationState, NuMuProvider, type OrderDetail, type OrderListEntry, type OrderListState, type OrderState, Page, type PlaceOrderResult, Product, ProductCard, type ProductCardProps, type ProductCardSlots, ProductProvider, ProductVariant, type RelatedProductsState, type ReorderResult, type ReorderSkipReason, type ReorderSkippedItem, RichText, type RichTextProps, type SearchResults, type SearchState, Section, SectionContext, SectionInstance, SectionProps$1 as SectionProps, SectionSchema, type ShippingRateOption, type ShopWithHelpers, SizeChart, Store, type ThemeEntry, ThemeMountContext, ThemeRenderArgs, ThemeSettingsV3, type UseGiftCardBalance, type UseReorder, type UseSearchOptions, type UseShippingRatesOptions, type UseShippingRatesState, type UseVariantSelection, type WishlistItem, type WishlistState, applyGlobalStyleTokens, applyImageTransform, asImageTransform, assetUrl, availableValues, buildLocaleBundle, clearSdkSingleton, collectBlocks, collectSections, computeGlobalStyleTokens, defaultVariant, defineBlock, defineSection, defineThemeEntry, dynamicSource, findVariantByOptions, flattenMessages, focalSrc, getReactSingleton, getSdkSingleton, isDefinedBlock, isDefinedSection, isDynamicSource, isSdkAvailable, pickTranslations, registerReactSingleton, registerSdkSingleton, resolveDynamicValue, resolveFontStack, resolveSettingsMap, resolveSizeChart, resolveSourcePath, sanitizeHtml, useAnalytics, useApp, useCart, useCheckout, useCollection, useCollectionOptional, useCollections, useCurrency, useCurrentTemplate, useCustomer, useCustomerActions, useCustomerAddresses, useDirection, useFieldTranslation, useGiftCardBalance, useImage, useLocale, useLocalization, useMoney, useNavigation, useNumberFormat, useOrder, useOrders, usePage, useProduct, useProductOptional, useProductSizeChart, useProducts, useRelatedProducts, useReorder, useResolvedSettings, useSearch, useSection, useSectionOptional, useShippingRates, useShop, useThemeSettings, useTranslation, useVariantSelection, useWishlist };
|
|
2205
|
+
export { AddToCartButton, type AddressInput, type AnalyticsApi, type AnalyticsPayload, type AppManifestBlock, type AppPayload, type AppState, Block, BlockInstance, BlockProps$1 as BlockProps, BlockSchema, Cart, type CheckoutAddress, type CheckoutApi, type CheckoutSessionState, type CheckoutStep, Collection, CollectionCard, type CollectionCardProps, type CollectionCardSlots, CollectionProvider, type ComputedStyleTokens, type CurrencyConfig, type CurrencyState, CurrencySwitcher, type CurrencySwitcherProps, Customer, type CustomerAddress, type CustomerAddressesState, type DefineBlockInput, type DefineSectionInput, type DefinedBlock, type DefinedSection, type DynamicResolveContext, type DynamicSourceRef, EditableImage, type EditableImageProps, EditableText, type EditableTextProps, type FocalSrcOptions, Form, type GiftCardBalance, ICON_NAMES, Icon, IconMap, type IconProps, Image, type ImageTransform, LOGO_SHAPE_OPTIONS, LOGO_SIZE_OPTIONS, Link, type LocaleBundle, type LocaleMessages, LocaleSwitcher, type LocaleSwitcherProps, Logo, type LogoProps, type LogoShape, type LogoSize, MenuItemData, Money, MountResult, type NavigationItem, type NavigationState, NuMuProvider, type OrderDetail, type OrderListEntry, type OrderListState, type OrderState, Page, type PlaceOrderResult, Product, ProductCard, type ProductCardProps, type ProductCardSlots, ProductProvider, ProductVariant, type RelatedProductsState, type ReorderResult, type ReorderSkipReason, type ReorderSkippedItem, RichText, type RichTextProps, type SearchResults, type SearchState, Section, SectionContext, SectionInstance, SectionProps$1 as SectionProps, SectionSchema, type ShippingRateOption, type ShopWithHelpers, SizeChart, Store, type ThemeEntry, ThemeMountContext, ThemeRenderArgs, ThemeSettingsV3, type UseGiftCardBalance, type UseReorder, type UseSearchOptions, type UseShippingRatesOptions, type UseShippingRatesState, type UseVariantSelection, type WishlistItem, type WishlistState, applyGlobalStyleTokens, applyImageTransform, asImageTransform, assetUrl, availableValues, buildLocaleBundle, clearSdkSingleton, collectBlocks, collectSections, computeGlobalStyleTokens, defaultVariant, defineBlock, defineSection, defineThemeEntry, dynamicSource, findVariantByOptions, flattenMessages, focalSrc, getReactSingleton, getSdkSingleton, isDefinedBlock, isDefinedSection, isDynamicSource, isSdkAvailable, logoImgStyle, logoStyleTokens, pickTranslations, registerReactSingleton, registerSdkSingleton, resolveDynamicValue, resolveFontStack, resolveSettingsMap, resolveSizeChart, resolveSourcePath, sanitizeHtml, useAnalytics, useApp, useCart, useCheckout, useCollection, useCollectionOptional, useCollections, useCurrency, useCurrentTemplate, useCustomer, useCustomerActions, useCustomerAddresses, useDirection, useFieldTranslation, useGiftCardBalance, useImage, useLocale, useLocalization, useMoney, useNavigation, useNumberFormat, useOrder, useOrders, usePage, useProduct, useProductOptional, useProductSizeChart, useProducts, useRelatedProducts, useReorder, useResolvedSettings, useSearch, useSection, useSectionOptional, useShippingRates, useShop, useThemeSettings, useTranslation, useVariantSelection, useWishlist };
|
package/dist/index.d.ts
CHANGED
|
@@ -1286,6 +1286,29 @@ interface ImageProps extends Omit<ImgHTMLAttributes<HTMLImageElement>, "src" | "
|
|
|
1286
1286
|
*/
|
|
1287
1287
|
declare function Image({ src, alt, sizes, responsive, loading, aspectRatio, objectFit, objectPosition, transform, className, style, ...rest }: ImageProps): react.JSX.Element;
|
|
1288
1288
|
|
|
1289
|
+
interface LogoProps {
|
|
1290
|
+
/** Explicit logo URL; falls back to global_settings.logo_url then shop.logo_url. */
|
|
1291
|
+
src?: string | null;
|
|
1292
|
+
/** Alt text; falls back to the brand name / shop name. */
|
|
1293
|
+
alt?: string;
|
|
1294
|
+
/** Overrides `global_settings.logo_shape` (none/square/rounded/circle/triangle). */
|
|
1295
|
+
shape?: string;
|
|
1296
|
+
/** Overrides `global_settings.logo_size` (small/medium/large). */
|
|
1297
|
+
size?: string;
|
|
1298
|
+
className?: string;
|
|
1299
|
+
style?: CSSProperties;
|
|
1300
|
+
/** Rendered when there is no logo URL (e.g. brand-name text). */
|
|
1301
|
+
fallback?: ReactNode;
|
|
1302
|
+
}
|
|
1303
|
+
/**
|
|
1304
|
+
* Engine-level store logo. Reads `logo_url`, `logo_shape`, and `logo_size` from
|
|
1305
|
+
* the theme's global settings (overridable via props), and renders a plain
|
|
1306
|
+
* `<img>` with the chosen shape/size applied via inline styles — so it works in
|
|
1307
|
+
* any theme regardless of its CSS setup and keeps **animated GIF logos playing**
|
|
1308
|
+
* under every shape. Renders `fallback` (or nothing) when no logo is set.
|
|
1309
|
+
*/
|
|
1310
|
+
declare function Logo({ src, alt, shape, size, className, style, fallback, }: LogoProps): react.JSX.Element;
|
|
1311
|
+
|
|
1289
1312
|
interface LinkProps extends Omit<AnchorHTMLAttributes<HTMLAnchorElement>, "href"> {
|
|
1290
1313
|
/**
|
|
1291
1314
|
* Path relative to the storefront root, e.g. "/products/foo",
|
|
@@ -2051,6 +2074,76 @@ declare function computeGlobalStyleTokens(globalSettings: GlobalSettings): Compu
|
|
|
2051
2074
|
*/
|
|
2052
2075
|
declare function applyGlobalStyleTokens(globalSettings: GlobalSettings, el: HTMLElement | null | undefined): void;
|
|
2053
2076
|
|
|
2077
|
+
/**
|
|
2078
|
+
* Engine-level logo appearance (shape + size).
|
|
2079
|
+
*
|
|
2080
|
+
* A merchant can crop the store logo into a shape and pick its size from the
|
|
2081
|
+
* theme editor's global settings (`logo_shape` / `logo_size`). The logic lives
|
|
2082
|
+
* here — once, in the SDK — so EVERY V3 theme renders the chosen shape the same
|
|
2083
|
+
* way instead of each theme re-implementing it.
|
|
2084
|
+
*
|
|
2085
|
+
* Why inline styles (not Tailwind classes): the SDK is consumed from
|
|
2086
|
+
* `node_modules`, which a theme's Tailwind build does not scan — so utility
|
|
2087
|
+
* classes like `rounded-full` / `h-16` would never be generated. Inline
|
|
2088
|
+
* `CSSProperties` are self-contained and work in any theme regardless of its
|
|
2089
|
+
* CSS setup. The shapes are pure CSS (border-radius / clip-path) applied to a
|
|
2090
|
+
* plain `<img>`, so animated **GIF logos keep playing** under every shape.
|
|
2091
|
+
*/
|
|
2092
|
+
|
|
2093
|
+
type LogoShape = "none" | "square" | "rounded" | "circle" | "triangle";
|
|
2094
|
+
type LogoSize = "small" | "medium" | "large";
|
|
2095
|
+
/** Bilingual options for the `logo_shape` global setting (schema authoring). */
|
|
2096
|
+
declare const LOGO_SHAPE_OPTIONS: readonly [{
|
|
2097
|
+
readonly value: "none";
|
|
2098
|
+
readonly label: "Original";
|
|
2099
|
+
readonly label_ar: "الأصلي";
|
|
2100
|
+
}, {
|
|
2101
|
+
readonly value: "square";
|
|
2102
|
+
readonly label: "Square";
|
|
2103
|
+
readonly label_ar: "مربع";
|
|
2104
|
+
}, {
|
|
2105
|
+
readonly value: "rounded";
|
|
2106
|
+
readonly label: "Rounded square";
|
|
2107
|
+
readonly label_ar: "مربع بزوايا دائرية";
|
|
2108
|
+
}, {
|
|
2109
|
+
readonly value: "circle";
|
|
2110
|
+
readonly label: "Circle";
|
|
2111
|
+
readonly label_ar: "دائرة";
|
|
2112
|
+
}, {
|
|
2113
|
+
readonly value: "triangle";
|
|
2114
|
+
readonly label: "Triangle";
|
|
2115
|
+
readonly label_ar: "مثلث";
|
|
2116
|
+
}];
|
|
2117
|
+
/** Bilingual options for the `logo_size` global setting (schema authoring). */
|
|
2118
|
+
declare const LOGO_SIZE_OPTIONS: readonly [{
|
|
2119
|
+
readonly value: "small";
|
|
2120
|
+
readonly label: "Small";
|
|
2121
|
+
readonly label_ar: "صغير";
|
|
2122
|
+
}, {
|
|
2123
|
+
readonly value: "medium";
|
|
2124
|
+
readonly label: "Medium";
|
|
2125
|
+
readonly label_ar: "متوسط";
|
|
2126
|
+
}, {
|
|
2127
|
+
readonly value: "large";
|
|
2128
|
+
readonly label: "Large";
|
|
2129
|
+
readonly label_ar: "كبير";
|
|
2130
|
+
}];
|
|
2131
|
+
/**
|
|
2132
|
+
* Inline style for a logo `<img>` given the merchant's shape + size.
|
|
2133
|
+
*
|
|
2134
|
+
* Returns `undefined` for `none` (and unknown shapes) so the theme keeps its
|
|
2135
|
+
* own native logo sizing untouched — only an explicitly chosen shape overrides
|
|
2136
|
+
* it. A shaped logo gets a fixed square box with `object-fit: cover` plus the
|
|
2137
|
+
* shape (border-radius for square/rounded/circle, clip-path for triangle).
|
|
2138
|
+
*/
|
|
2139
|
+
declare function logoImgStyle(shape: string | undefined, size: string | undefined): CSSProperties | undefined;
|
|
2140
|
+
/**
|
|
2141
|
+
* Derived CSS-custom-property tokens for the chosen logo shape/size. Emitted by
|
|
2142
|
+
* `computeGlobalStyleTokens` so host-rendered surfaces (e.g. the checkout
|
|
2143
|
+
* header) can match the storefront logo. Returns `{}` for `none`.
|
|
2144
|
+
*/
|
|
2145
|
+
declare function logoStyleTokens(shape: string | undefined, size: string | undefined): Record<string, string>;
|
|
2146
|
+
|
|
2054
2147
|
/**
|
|
2055
2148
|
* Theme-bundled locale files: load + merge.
|
|
2056
2149
|
*
|
|
@@ -2109,4 +2202,4 @@ declare function pickTranslations(bundle: LocaleBundle, locale: string): LocaleM
|
|
|
2109
2202
|
*/
|
|
2110
2203
|
declare function buildLocaleBundle<T extends Record<string, unknown>>(modules: T): LocaleBundle;
|
|
2111
2204
|
|
|
2112
|
-
export { AddToCartButton, type AddressInput, type AnalyticsApi, type AnalyticsPayload, type AppManifestBlock, type AppPayload, type AppState, Block, BlockInstance, BlockProps$1 as BlockProps, BlockSchema, Cart, type CheckoutAddress, type CheckoutApi, type CheckoutSessionState, type CheckoutStep, Collection, CollectionCard, type CollectionCardProps, type CollectionCardSlots, CollectionProvider, type ComputedStyleTokens, type CurrencyConfig, type CurrencyState, CurrencySwitcher, type CurrencySwitcherProps, Customer, type CustomerAddress, type CustomerAddressesState, type DefineBlockInput, type DefineSectionInput, type DefinedBlock, type DefinedSection, type DynamicResolveContext, type DynamicSourceRef, EditableImage, type EditableImageProps, EditableText, type EditableTextProps, type FocalSrcOptions, Form, type GiftCardBalance, ICON_NAMES, Icon, IconMap, type IconProps, Image, type ImageTransform, Link, type LocaleBundle, type LocaleMessages, LocaleSwitcher, type LocaleSwitcherProps, MenuItemData, Money, MountResult, type NavigationItem, type NavigationState, NuMuProvider, type OrderDetail, type OrderListEntry, type OrderListState, type OrderState, Page, type PlaceOrderResult, Product, ProductCard, type ProductCardProps, type ProductCardSlots, ProductProvider, ProductVariant, type RelatedProductsState, type ReorderResult, type ReorderSkipReason, type ReorderSkippedItem, RichText, type RichTextProps, type SearchResults, type SearchState, Section, SectionContext, SectionInstance, SectionProps$1 as SectionProps, SectionSchema, type ShippingRateOption, type ShopWithHelpers, SizeChart, Store, type ThemeEntry, ThemeMountContext, ThemeRenderArgs, ThemeSettingsV3, type UseGiftCardBalance, type UseReorder, type UseSearchOptions, type UseShippingRatesOptions, type UseShippingRatesState, type UseVariantSelection, type WishlistItem, type WishlistState, applyGlobalStyleTokens, applyImageTransform, asImageTransform, assetUrl, availableValues, buildLocaleBundle, clearSdkSingleton, collectBlocks, collectSections, computeGlobalStyleTokens, defaultVariant, defineBlock, defineSection, defineThemeEntry, dynamicSource, findVariantByOptions, flattenMessages, focalSrc, getReactSingleton, getSdkSingleton, isDefinedBlock, isDefinedSection, isDynamicSource, isSdkAvailable, pickTranslations, registerReactSingleton, registerSdkSingleton, resolveDynamicValue, resolveFontStack, resolveSettingsMap, resolveSizeChart, resolveSourcePath, sanitizeHtml, useAnalytics, useApp, useCart, useCheckout, useCollection, useCollectionOptional, useCollections, useCurrency, useCurrentTemplate, useCustomer, useCustomerActions, useCustomerAddresses, useDirection, useFieldTranslation, useGiftCardBalance, useImage, useLocale, useLocalization, useMoney, useNavigation, useNumberFormat, useOrder, useOrders, usePage, useProduct, useProductOptional, useProductSizeChart, useProducts, useRelatedProducts, useReorder, useResolvedSettings, useSearch, useSection, useSectionOptional, useShippingRates, useShop, useThemeSettings, useTranslation, useVariantSelection, useWishlist };
|
|
2205
|
+
export { AddToCartButton, type AddressInput, type AnalyticsApi, type AnalyticsPayload, type AppManifestBlock, type AppPayload, type AppState, Block, BlockInstance, BlockProps$1 as BlockProps, BlockSchema, Cart, type CheckoutAddress, type CheckoutApi, type CheckoutSessionState, type CheckoutStep, Collection, CollectionCard, type CollectionCardProps, type CollectionCardSlots, CollectionProvider, type ComputedStyleTokens, type CurrencyConfig, type CurrencyState, CurrencySwitcher, type CurrencySwitcherProps, Customer, type CustomerAddress, type CustomerAddressesState, type DefineBlockInput, type DefineSectionInput, type DefinedBlock, type DefinedSection, type DynamicResolveContext, type DynamicSourceRef, EditableImage, type EditableImageProps, EditableText, type EditableTextProps, type FocalSrcOptions, Form, type GiftCardBalance, ICON_NAMES, Icon, IconMap, type IconProps, Image, type ImageTransform, LOGO_SHAPE_OPTIONS, LOGO_SIZE_OPTIONS, Link, type LocaleBundle, type LocaleMessages, LocaleSwitcher, type LocaleSwitcherProps, Logo, type LogoProps, type LogoShape, type LogoSize, MenuItemData, Money, MountResult, type NavigationItem, type NavigationState, NuMuProvider, type OrderDetail, type OrderListEntry, type OrderListState, type OrderState, Page, type PlaceOrderResult, Product, ProductCard, type ProductCardProps, type ProductCardSlots, ProductProvider, ProductVariant, type RelatedProductsState, type ReorderResult, type ReorderSkipReason, type ReorderSkippedItem, RichText, type RichTextProps, type SearchResults, type SearchState, Section, SectionContext, SectionInstance, SectionProps$1 as SectionProps, SectionSchema, type ShippingRateOption, type ShopWithHelpers, SizeChart, Store, type ThemeEntry, ThemeMountContext, ThemeRenderArgs, ThemeSettingsV3, type UseGiftCardBalance, type UseReorder, type UseSearchOptions, type UseShippingRatesOptions, type UseShippingRatesState, type UseVariantSelection, type WishlistItem, type WishlistState, applyGlobalStyleTokens, applyImageTransform, asImageTransform, assetUrl, availableValues, buildLocaleBundle, clearSdkSingleton, collectBlocks, collectSections, computeGlobalStyleTokens, defaultVariant, defineBlock, defineSection, defineThemeEntry, dynamicSource, findVariantByOptions, flattenMessages, focalSrc, getReactSingleton, getSdkSingleton, isDefinedBlock, isDefinedSection, isDynamicSource, isSdkAvailable, logoImgStyle, logoStyleTokens, pickTranslations, registerReactSingleton, registerSdkSingleton, resolveDynamicValue, resolveFontStack, resolveSettingsMap, resolveSizeChart, resolveSourcePath, sanitizeHtml, useAnalytics, useApp, useCart, useCheckout, useCollection, useCollectionOptional, useCollections, useCurrency, useCurrentTemplate, useCustomer, useCustomerActions, useCustomerAddresses, useDirection, useFieldTranslation, useGiftCardBalance, useImage, useLocale, useLocalization, useMoney, useNavigation, useNumberFormat, useOrder, useOrders, usePage, useProduct, useProductOptional, useProductSizeChart, useProducts, useRelatedProducts, useReorder, useResolvedSettings, useSearch, useSection, useSectionOptional, useShippingRates, useShop, useThemeSettings, useTranslation, useVariantSelection, useWishlist };
|
package/dist/index.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { createContext, forwardRef, useState, useImperativeHandle, useEffect, useCallback, useMemo, useRef, useContext, StrictMode, createElement, Component } from 'react';
|
|
2
2
|
import { hydrateRoot, createRoot } from 'react-dom/client';
|
|
3
|
-
import { jsx,
|
|
3
|
+
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
4
4
|
|
|
5
5
|
// src/types/theme.ts
|
|
6
6
|
var MAX_BLOCK_DEPTH = 5;
|
|
7
7
|
|
|
8
8
|
// src/validation/index.ts
|
|
9
9
|
var THEME_CONTRACT_VERSION = 1;
|
|
10
|
-
var SDK_VERSION = "0.
|
|
10
|
+
var SDK_VERSION = "0.5.0" ;
|
|
11
11
|
var REQUIRED_TEMPLATES = [
|
|
12
12
|
"home",
|
|
13
13
|
"product",
|
|
@@ -2328,6 +2328,64 @@ function NuMuProvider({
|
|
|
2328
2328
|
function ProductProvider({ product, children }) {
|
|
2329
2329
|
return /* @__PURE__ */ jsx(ProductContext.Provider, { value: product, children });
|
|
2330
2330
|
}
|
|
2331
|
+
function CollectionProvider({ collection, children }) {
|
|
2332
|
+
return /* @__PURE__ */ jsx(CollectionContext.Provider, { value: collection, children });
|
|
2333
|
+
}
|
|
2334
|
+
|
|
2335
|
+
// src/utils/logoStyle.ts
|
|
2336
|
+
var LOGO_SHAPE_OPTIONS = [
|
|
2337
|
+
{ value: "none", label: "Original", label_ar: "\u0627\u0644\u0623\u0635\u0644\u064A" },
|
|
2338
|
+
{ value: "square", label: "Square", label_ar: "\u0645\u0631\u0628\u0639" },
|
|
2339
|
+
{ value: "rounded", label: "Rounded square", label_ar: "\u0645\u0631\u0628\u0639 \u0628\u0632\u0648\u0627\u064A\u0627 \u062F\u0627\u0626\u0631\u064A\u0629" },
|
|
2340
|
+
{ value: "circle", label: "Circle", label_ar: "\u062F\u0627\u0626\u0631\u0629" },
|
|
2341
|
+
{ value: "triangle", label: "Triangle", label_ar: "\u0645\u062B\u0644\u062B" }
|
|
2342
|
+
];
|
|
2343
|
+
var LOGO_SIZE_OPTIONS = [
|
|
2344
|
+
{ value: "small", label: "Small", label_ar: "\u0635\u063A\u064A\u0631" },
|
|
2345
|
+
{ value: "medium", label: "Medium", label_ar: "\u0645\u062A\u0648\u0633\u0637" },
|
|
2346
|
+
{ value: "large", label: "Large", label_ar: "\u0643\u0628\u064A\u0631" }
|
|
2347
|
+
];
|
|
2348
|
+
var SHAPED_PX = {
|
|
2349
|
+
small: { plain: 32, rounded: 48 },
|
|
2350
|
+
medium: { plain: 40, rounded: 64 },
|
|
2351
|
+
large: { plain: 56, rounded: 80 }
|
|
2352
|
+
};
|
|
2353
|
+
function normalizeSize(size) {
|
|
2354
|
+
return size === "large" || size === "medium" ? size : "small";
|
|
2355
|
+
}
|
|
2356
|
+
function logoImgStyle(shape, size) {
|
|
2357
|
+
if (!shape || shape === "none") return void 0;
|
|
2358
|
+
const s = normalizeSize(size);
|
|
2359
|
+
const isRound = shape === "circle" || shape === "rounded";
|
|
2360
|
+
const px = isRound ? SHAPED_PX[s].rounded : SHAPED_PX[s].plain;
|
|
2361
|
+
const base = {
|
|
2362
|
+
height: px,
|
|
2363
|
+
width: px,
|
|
2364
|
+
objectFit: "cover",
|
|
2365
|
+
flex: "0 0 auto"
|
|
2366
|
+
};
|
|
2367
|
+
switch (shape) {
|
|
2368
|
+
case "circle":
|
|
2369
|
+
return { ...base, borderRadius: "9999px" };
|
|
2370
|
+
case "rounded":
|
|
2371
|
+
return { ...base, borderRadius: "0.5rem" };
|
|
2372
|
+
case "triangle":
|
|
2373
|
+
return { ...base, clipPath: "polygon(50% 0%, 100% 100%, 0% 100%)" };
|
|
2374
|
+
case "square":
|
|
2375
|
+
default:
|
|
2376
|
+
return base;
|
|
2377
|
+
}
|
|
2378
|
+
}
|
|
2379
|
+
function logoStyleTokens(shape, size) {
|
|
2380
|
+
const style = logoImgStyle(shape, size);
|
|
2381
|
+
if (!style) return {};
|
|
2382
|
+
const box = `${style.height}px`;
|
|
2383
|
+
return {
|
|
2384
|
+
"--theme-logo-box": box,
|
|
2385
|
+
"--theme-logo-radius": typeof style.borderRadius === "string" ? style.borderRadius : "0",
|
|
2386
|
+
"--theme-logo-clip": typeof style.clipPath === "string" ? style.clipPath : "none"
|
|
2387
|
+
};
|
|
2388
|
+
}
|
|
2331
2389
|
|
|
2332
2390
|
// src/utils/styleTokens.ts
|
|
2333
2391
|
var COLOR_ROLE_ALIASES = {
|
|
@@ -2468,6 +2526,12 @@ function computeGlobalStyleTokens(globalSettings) {
|
|
|
2468
2526
|
pushHref(FONT_REGISTRY[value]?.href);
|
|
2469
2527
|
}
|
|
2470
2528
|
}
|
|
2529
|
+
const gs = globalSettings;
|
|
2530
|
+
const logoTokens = logoStyleTokens(
|
|
2531
|
+
typeof gs.logo_shape === "string" ? gs.logo_shape : void 0,
|
|
2532
|
+
typeof gs.logo_size === "string" ? gs.logo_size : void 0
|
|
2533
|
+
);
|
|
2534
|
+
for (const [k, v] of Object.entries(logoTokens)) cssVars[k] = v;
|
|
2471
2535
|
return { cssVars, fontHrefs };
|
|
2472
2536
|
}
|
|
2473
2537
|
function applyGlobalStyleTokens(globalSettings, el) {
|
|
@@ -2510,6 +2574,16 @@ function pickDemo(ctx, themeSettings) {
|
|
|
2510
2574
|
const t = themeSettings.templates;
|
|
2511
2575
|
return !t || Object.keys(t).length === 0;
|
|
2512
2576
|
}
|
|
2577
|
+
function wrapEntityProviders(app, pageData) {
|
|
2578
|
+
let inner = app;
|
|
2579
|
+
if (pageData.collection) {
|
|
2580
|
+
inner = /* @__PURE__ */ jsx(CollectionProvider, { collection: pageData.collection, children: inner });
|
|
2581
|
+
}
|
|
2582
|
+
if (pageData.product) {
|
|
2583
|
+
inner = /* @__PURE__ */ jsx(ProductProvider, { product: pageData.product, children: inner });
|
|
2584
|
+
}
|
|
2585
|
+
return inner;
|
|
2586
|
+
}
|
|
2513
2587
|
var ThemeMountBridge = forwardRef(function ThemeMountBridge2({ ctx, mountEl, renderApp }, ref) {
|
|
2514
2588
|
const [themeSettings, setThemeSettings] = useState(
|
|
2515
2589
|
ctx.themeSettings
|
|
@@ -2550,7 +2624,7 @@ var ThemeMountBridge = forwardRef(function ThemeMountBridge2({ ctx, mountEl, ren
|
|
|
2550
2624
|
initialProducts: pageData.products,
|
|
2551
2625
|
initialCollections: pageData.collections,
|
|
2552
2626
|
currentTemplate: template,
|
|
2553
|
-
children:
|
|
2627
|
+
children: wrapEntityProviders(app, pageData)
|
|
2554
2628
|
}
|
|
2555
2629
|
);
|
|
2556
2630
|
});
|
|
@@ -2586,9 +2660,6 @@ function defineThemeEntry(renderApp) {
|
|
|
2586
2660
|
createApp: (ctx) => buildThemeElement(ctx, null, renderApp)
|
|
2587
2661
|
};
|
|
2588
2662
|
}
|
|
2589
|
-
function CollectionProvider({ collection, children }) {
|
|
2590
|
-
return /* @__PURE__ */ jsx(CollectionContext.Provider, { value: collection, children });
|
|
2591
|
-
}
|
|
2592
2663
|
function Money({
|
|
2593
2664
|
amount,
|
|
2594
2665
|
currency,
|
|
@@ -2739,6 +2810,43 @@ function Image({
|
|
|
2739
2810
|
}
|
|
2740
2811
|
);
|
|
2741
2812
|
}
|
|
2813
|
+
var str = (v) => typeof v === "string" ? v : "";
|
|
2814
|
+
var NONE_HEIGHT = { small: 28, medium: 36, large: 48 };
|
|
2815
|
+
function Logo({
|
|
2816
|
+
src,
|
|
2817
|
+
alt,
|
|
2818
|
+
shape,
|
|
2819
|
+
size,
|
|
2820
|
+
className,
|
|
2821
|
+
style,
|
|
2822
|
+
fallback
|
|
2823
|
+
}) {
|
|
2824
|
+
const settings = useThemeSettings();
|
|
2825
|
+
const shop = useShop();
|
|
2826
|
+
const g = settings?.global_settings ?? {};
|
|
2827
|
+
const url = str(src) || str(g.logo_url) || shop?.logo_url || "";
|
|
2828
|
+
const resolvedShape = shape || str(g.logo_shape) || "none";
|
|
2829
|
+
const resolvedSize = size || str(g.logo_size) || "small";
|
|
2830
|
+
const altText = alt || str(g.brand_name) || shop?.name || "";
|
|
2831
|
+
if (!url) return /* @__PURE__ */ jsx(Fragment, { children: fallback ?? null });
|
|
2832
|
+
const shaped = resolvedShape !== "none";
|
|
2833
|
+
const imgStyle = shaped ? { ...logoImgStyle(resolvedShape, resolvedSize), ...style } : {
|
|
2834
|
+
height: NONE_HEIGHT[resolvedSize] ?? NONE_HEIGHT.small,
|
|
2835
|
+
width: "auto",
|
|
2836
|
+
objectFit: "contain",
|
|
2837
|
+
...style
|
|
2838
|
+
};
|
|
2839
|
+
return /* @__PURE__ */ jsx(
|
|
2840
|
+
"img",
|
|
2841
|
+
{
|
|
2842
|
+
src: url,
|
|
2843
|
+
alt: altText,
|
|
2844
|
+
className,
|
|
2845
|
+
style: imgStyle,
|
|
2846
|
+
loading: "eager"
|
|
2847
|
+
}
|
|
2848
|
+
);
|
|
2849
|
+
}
|
|
2742
2850
|
var ABSOLUTE_URL = /^[a-z]+:|^\/\//i;
|
|
2743
2851
|
function Link({ to, children, ...rest }) {
|
|
2744
2852
|
const shop = useShop();
|
|
@@ -3949,6 +4057,6 @@ function buildLocaleBundle(modules) {
|
|
|
3949
4057
|
return bundle;
|
|
3950
4058
|
}
|
|
3951
4059
|
|
|
3952
|
-
export { AddToCartButton, Block, CartContext, CollectionCard, CollectionContext, CollectionProvider, CurrencySwitcher, CustomerContext, EditableImage, EditableText, Form, ICON_NAMES, Icon, IconMap, Image, KNOWN_SETTING_TYPES, KNOWN_TEMPLATES, Link, LocaleSwitcher, LocalizationContext, MAX_BLOCK_DEPTH, Money, NavigationContext, NuMuProvider, PageContext, ProductCard, ProductContext, ProductProvider, REQUIRED_TEMPLATES, RichText, SDK_VERSION, Section, SectionContext, ShopContext, THEME_CONTRACT_VERSION, ThemeSettingsContext, applyGlobalStyleTokens, applyImageTransform, asImageTransform, assetUrl, availableValues, buildLocaleBundle, buildThemeElement, clearSdkSingleton, collectBlocks, collectSections, computeGlobalStyleTokens, defaultVariant, defineBlock, defineSection, defineThemeEntry, dynamicSource, findVariantByOptions, flattenMessages, focalSrc, getReactSingleton, getSdkSingleton, isDefinedBlock, isDefinedSection, isDynamicSource, isSdkAvailable, mergeResults, mountTheme, pickTranslations, registerReactSingleton, registerSdkSingleton, resolveDynamicValue, resolveFontStack, resolveSettingsMap, resolveSizeChart, resolveSourcePath, resolveThemeSettings, sanitizeHtml, useAnalytics, useApp, useCart, useCheckout, useCollection, useCollectionOptional, useCollections, useCurrency, useCurrentTemplate, useCustomer, useCustomerActions, useCustomerAddresses, useDirection, useFieldTranslation, useGiftCardBalance, useImage, useLocale, useLocalization, useMoney, useNavigation, useNumberFormat, useOrder, useOrders, usePage, useProduct, useProductOptional, useProductSizeChart, useProducts, useRelatedProducts, useReorder, useResolvedSettings, useSearch, useSection, useSectionOptional, useShippingRates, useShop, useThemeSettings, useTranslation, useVariantSelection, useWishlist, validateBuiltManifest, validateManifest, validateSectionSchema, validateSettingsAgainstSchema };
|
|
4060
|
+
export { AddToCartButton, Block, CartContext, CollectionCard, CollectionContext, CollectionProvider, CurrencySwitcher, CustomerContext, EditableImage, EditableText, Form, ICON_NAMES, Icon, IconMap, Image, KNOWN_SETTING_TYPES, KNOWN_TEMPLATES, LOGO_SHAPE_OPTIONS, LOGO_SIZE_OPTIONS, Link, LocaleSwitcher, LocalizationContext, Logo, MAX_BLOCK_DEPTH, Money, NavigationContext, NuMuProvider, PageContext, ProductCard, ProductContext, ProductProvider, REQUIRED_TEMPLATES, RichText, SDK_VERSION, Section, SectionContext, ShopContext, THEME_CONTRACT_VERSION, ThemeSettingsContext, applyGlobalStyleTokens, applyImageTransform, asImageTransform, assetUrl, availableValues, buildLocaleBundle, buildThemeElement, clearSdkSingleton, collectBlocks, collectSections, computeGlobalStyleTokens, defaultVariant, defineBlock, defineSection, defineThemeEntry, dynamicSource, findVariantByOptions, flattenMessages, focalSrc, getReactSingleton, getSdkSingleton, isDefinedBlock, isDefinedSection, isDynamicSource, isSdkAvailable, logoImgStyle, logoStyleTokens, mergeResults, mountTheme, pickTranslations, registerReactSingleton, registerSdkSingleton, resolveDynamicValue, resolveFontStack, resolveSettingsMap, resolveSizeChart, resolveSourcePath, resolveThemeSettings, sanitizeHtml, useAnalytics, useApp, useCart, useCheckout, useCollection, useCollectionOptional, useCollections, useCurrency, useCurrentTemplate, useCustomer, useCustomerActions, useCustomerAddresses, useDirection, useFieldTranslation, useGiftCardBalance, useImage, useLocale, useLocalization, useMoney, useNavigation, useNumberFormat, useOrder, useOrders, usePage, useProduct, useProductOptional, useProductSizeChart, useProducts, useRelatedProducts, useReorder, useResolvedSettings, useSearch, useSection, useSectionOptional, useShippingRates, useShop, useThemeSettings, useTranslation, useVariantSelection, useWishlist, validateBuiltManifest, validateManifest, validateSectionSchema, validateSettingsAgainstSchema };
|
|
3953
4061
|
//# sourceMappingURL=index.mjs.map
|
|
3954
4062
|
//# sourceMappingURL=index.mjs.map
|