@gem-sdk/core 2.0.0-dev.462 → 2.0.0-dev.468
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/cjs/components/ComponentToolbarPreview.js +5 -7
- package/dist/cjs/contexts/ProductContext.js +1 -1
- package/dist/cjs/helpers/is-safari.js +4 -1
- package/dist/esm/components/ComponentToolbarPreview.js +5 -7
- package/dist/esm/contexts/ProductContext.js +1 -1
- package/dist/esm/helpers/is-safari.js +4 -1
- package/dist/types/index.d.ts +27 -12
- package/package.json +2 -2
|
@@ -247,6 +247,10 @@ const ComponentToolbarPreview = (props)=>{
|
|
|
247
247
|
}
|
|
248
248
|
return -1;
|
|
249
249
|
};
|
|
250
|
+
const getToolbarParentLabel = (parent)=>{
|
|
251
|
+
const parentLength = parent?.childrens?.length ?? 0;
|
|
252
|
+
return parent.label === 'Row' ? `Row ${parentLength} col${parentLength === 1 ? '' : 's'}` : parent.label;
|
|
253
|
+
};
|
|
250
254
|
const onShowParent = (e)=>{
|
|
251
255
|
if (!parents.length) return;
|
|
252
256
|
const $target = (e?.target) || null;
|
|
@@ -512,12 +516,6 @@ const ComponentToolbarPreview = (props)=>{
|
|
|
512
516
|
]
|
|
513
517
|
}),
|
|
514
518
|
isActiveToolbarComponent && isShowParent && parents.map((parent, index)=>{
|
|
515
|
-
// Update count columns of Row
|
|
516
|
-
const parentLength = parent?.childrens?.length ?? 0;
|
|
517
|
-
let parent_label = parent.label;
|
|
518
|
-
if (parent.label === 'Row') {
|
|
519
|
-
parent_label = parentLength <= 1 ? parent.label + ' ' + parentLength + ' col' : parent.label + ' ' + parentLength + ' cols';
|
|
520
|
-
}
|
|
521
519
|
return /*#__PURE__*/ jsxRuntime.jsxs("div", {
|
|
522
520
|
"data-toolbar-parent": true,
|
|
523
521
|
"data-component-tag": parent.tag,
|
|
@@ -566,7 +564,7 @@ const ComponentToolbarPreview = (props)=>{
|
|
|
566
564
|
}),
|
|
567
565
|
/*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
568
566
|
"data-toolbar-name": true,
|
|
569
|
-
children:
|
|
567
|
+
children: getToolbarParentLabel(parent)
|
|
570
568
|
})
|
|
571
569
|
]
|
|
572
570
|
}, parent.uid);
|
|
@@ -143,7 +143,7 @@ const ProductProvider = ({ children, product, initialVariantId, quantity = 1, is
|
|
|
143
143
|
const firstVariant = variants[0];
|
|
144
144
|
const firstVariantInStock = variants.find((item)=>variant.checkInStock(item));
|
|
145
145
|
const initialVariant = variants.find((v)=>v?.id === initialVariantId) ?? firstVariantInStock ?? firstVariant;
|
|
146
|
-
selectedOptions = initialVariant?.selectedOptions
|
|
146
|
+
selectedOptions = initialVariant?.selectedOptions?.reduce((acc, option)=>{
|
|
147
147
|
if (option.name) {
|
|
148
148
|
return {
|
|
149
149
|
...acc,
|
|
@@ -3,7 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
function isSafari() {
|
|
6
|
-
|
|
6
|
+
if (typeof window !== 'undefined' && window.navigator) {
|
|
7
|
+
return window.navigator.userAgent.indexOf('Safari') !== -1 && window.navigator.userAgent.indexOf('Chrome') === -1;
|
|
8
|
+
}
|
|
9
|
+
return false;
|
|
7
10
|
}
|
|
8
11
|
|
|
9
12
|
exports.default = isSafari;
|
|
@@ -243,6 +243,10 @@ const ComponentToolbarPreview = (props)=>{
|
|
|
243
243
|
}
|
|
244
244
|
return -1;
|
|
245
245
|
};
|
|
246
|
+
const getToolbarParentLabel = (parent)=>{
|
|
247
|
+
const parentLength = parent?.childrens?.length ?? 0;
|
|
248
|
+
return parent.label === 'Row' ? `Row ${parentLength} col${parentLength === 1 ? '' : 's'}` : parent.label;
|
|
249
|
+
};
|
|
246
250
|
const onShowParent = (e)=>{
|
|
247
251
|
if (!parents.length) return;
|
|
248
252
|
const $target = (e?.target) || null;
|
|
@@ -508,12 +512,6 @@ const ComponentToolbarPreview = (props)=>{
|
|
|
508
512
|
]
|
|
509
513
|
}),
|
|
510
514
|
isActiveToolbarComponent && isShowParent && parents.map((parent, index)=>{
|
|
511
|
-
// Update count columns of Row
|
|
512
|
-
const parentLength = parent?.childrens?.length ?? 0;
|
|
513
|
-
let parent_label = parent.label;
|
|
514
|
-
if (parent.label === 'Row') {
|
|
515
|
-
parent_label = parentLength <= 1 ? parent.label + ' ' + parentLength + ' col' : parent.label + ' ' + parentLength + ' cols';
|
|
516
|
-
}
|
|
517
515
|
return /*#__PURE__*/ jsxs("div", {
|
|
518
516
|
"data-toolbar-parent": true,
|
|
519
517
|
"data-component-tag": parent.tag,
|
|
@@ -562,7 +560,7 @@ const ComponentToolbarPreview = (props)=>{
|
|
|
562
560
|
}),
|
|
563
561
|
/*#__PURE__*/ jsx("div", {
|
|
564
562
|
"data-toolbar-name": true,
|
|
565
|
-
children:
|
|
563
|
+
children: getToolbarParentLabel(parent)
|
|
566
564
|
})
|
|
567
565
|
]
|
|
568
566
|
}, parent.uid);
|
|
@@ -141,7 +141,7 @@ const ProductProvider = ({ children, product, initialVariantId, quantity = 1, is
|
|
|
141
141
|
const firstVariant = variants[0];
|
|
142
142
|
const firstVariantInStock = variants.find((item)=>checkInStock(item));
|
|
143
143
|
const initialVariant = variants.find((v)=>v?.id === initialVariantId) ?? firstVariantInStock ?? firstVariant;
|
|
144
|
-
selectedOptions = initialVariant?.selectedOptions
|
|
144
|
+
selectedOptions = initialVariant?.selectedOptions?.reduce((acc, option)=>{
|
|
145
145
|
if (option.name) {
|
|
146
146
|
return {
|
|
147
147
|
...acc,
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
function isSafari() {
|
|
2
|
-
|
|
2
|
+
if (typeof window !== 'undefined' && window.navigator) {
|
|
3
|
+
return window.navigator.userAgent.indexOf('Safari') !== -1 && window.navigator.userAgent.indexOf('Chrome') === -1;
|
|
4
|
+
}
|
|
5
|
+
return false;
|
|
3
6
|
}
|
|
4
7
|
|
|
5
8
|
export { isSafari as default };
|
package/dist/types/index.d.ts
CHANGED
|
@@ -34561,6 +34561,7 @@ type AddonProviderProps = Pick<AddonContextProps, 'components'> & {
|
|
|
34561
34561
|
children: React.ReactNode;
|
|
34562
34562
|
key?: React.Key;
|
|
34563
34563
|
};
|
|
34564
|
+
|
|
34564
34565
|
declare const AddonProvider: React.FC<AddonProviderProps>;
|
|
34565
34566
|
declare const useAddons: () => Record<string, React.ComponentType<any>>;
|
|
34566
34567
|
declare const useAddon: (id?: string) => React.FC<BaseProps & {
|
|
@@ -34575,6 +34576,7 @@ type BuilderComponentProviderProps = Pick<BuilderComponentProps, 'components'> &
|
|
|
34575
34576
|
children: React.ReactNode;
|
|
34576
34577
|
key?: React.Key;
|
|
34577
34578
|
};
|
|
34579
|
+
|
|
34578
34580
|
declare const BuilderComponentProvider: React.FC<BuilderComponentProviderProps>;
|
|
34579
34581
|
declare const useBuilderComponent: (id?: string) => React.FC<BaseProps & {
|
|
34580
34582
|
children?: React.ReactNode;
|
|
@@ -34593,6 +34595,7 @@ type BuilderProviderProps = Pick<BuilderContextProps, 'state' | 'isPostPurchase'
|
|
|
34593
34595
|
lazy?: boolean;
|
|
34594
34596
|
priority?: boolean;
|
|
34595
34597
|
};
|
|
34598
|
+
|
|
34596
34599
|
declare const BuilderProvider: React.FC<BuilderProviderProps>;
|
|
34597
34600
|
declare const useBuilderStore: <U>(selector: (state: ExtractState<StoreApi<BuilderContextProps>>) => U, equalityFn?: ((a: U, b: U) => boolean) | undefined) => U;
|
|
34598
34601
|
|
|
@@ -34633,6 +34636,7 @@ type BuilderPreviewProviderProps = Pick<BuilderPreviewContextProps, 'state'> & {
|
|
|
34633
34636
|
isThemeSectionEditor?: boolean;
|
|
34634
34637
|
pageName?: string;
|
|
34635
34638
|
};
|
|
34639
|
+
|
|
34636
34640
|
declare const BuilderPreviewProvider: React.FC<BuilderPreviewProviderProps>;
|
|
34637
34641
|
declare const useBuilderPreviewStore: <U>(selector: (state: ExtractState<StoreApi<BuilderPreviewContextProps>>) => U, equalityFn?: ((a: U, b: U) => boolean) | undefined) => U;
|
|
34638
34642
|
|
|
@@ -34642,6 +34646,7 @@ type CartLineContextProps = {
|
|
|
34642
34646
|
type CartLineProviderProps = Pick<CartLineContextProps, 'line'> & {
|
|
34643
34647
|
children: React.ReactNode;
|
|
34644
34648
|
};
|
|
34649
|
+
|
|
34645
34650
|
declare const CartLineProvider: React.FC<CartLineProviderProps>;
|
|
34646
34651
|
declare const useCartLineStore: <U>(selector: (state: ExtractState<StoreApi<CartLineContextProps>>) => U, equalityFn?: ((a: U, b: U) => boolean) | undefined) => U;
|
|
34647
34652
|
|
|
@@ -34723,11 +34728,10 @@ type ProductListContextProps = {
|
|
|
34723
34728
|
type ProductListProviderProps = ProductListContextProps & {
|
|
34724
34729
|
children: React.ReactNode;
|
|
34725
34730
|
};
|
|
34731
|
+
|
|
34726
34732
|
declare const ProductListProvider: React.FC<ProductListProviderProps>;
|
|
34727
34733
|
declare const useProductListStore: <U>(selector: (state: ExtractState<StoreApi<ProductListContextProps>>) => U, equalityFn?: ((a: U, b: U) => boolean) | undefined) => U;
|
|
34728
34734
|
|
|
34729
|
-
type MediaSelectFragment = Pick<Media$1, 'id' | 'contentType' | 'previewImage' | 'src' | 'width' | 'height' | 'alt'>;
|
|
34730
|
-
|
|
34731
34735
|
type VariantSelectFragment = Pick<ProductVariant$1, 'id' | 'title' | 'barcode' | 'baseID' | 'costPrice' | 'height' | 'inventoryPolicy' | 'inventoryQuantity' | 'inventoryStatus' | 'isDigital' | 'length' | 'lowInventoryAmount' | 'manageInventory' | 'mediaId' | 'platform' | 'price' | 'salePrice' | 'sku' | 'soldIndividually' | 'weight' | 'width'> & {
|
|
34732
34736
|
selectedOptions: Array<Pick<SelectedOption$1, 'name' | 'value' | 'optionType'>>;
|
|
34733
34737
|
media?: Maybe$1<Pick<Media$1, 'id' | 'contentType' | 'previewImage' | 'src' | 'width' | 'height' | 'alt'>>;
|
|
@@ -34771,6 +34775,8 @@ type CollectionSelectFragment = Pick<Collection$1, 'id' | 'createdAt' | 'updated
|
|
|
34771
34775
|
collectionMedia?: Maybe$1<Pick<CollectionMedia$1, 'src'>>;
|
|
34772
34776
|
};
|
|
34773
34777
|
|
|
34778
|
+
type MediaSelectFragment = Pick<Media$1, 'id' | 'contentType' | 'previewImage' | 'src' | 'width' | 'height' | 'alt'>;
|
|
34779
|
+
|
|
34774
34780
|
type AttributeProp = {
|
|
34775
34781
|
key: string;
|
|
34776
34782
|
value?: string;
|
|
@@ -34811,20 +34817,22 @@ type ProductProviderProps = Pick<ProductContextProps, 'product' | 'quantity' | '
|
|
|
34811
34817
|
readOnly?: boolean;
|
|
34812
34818
|
children: React.ReactNode;
|
|
34813
34819
|
};
|
|
34820
|
+
|
|
34814
34821
|
declare const ProductProvider: React.FC<ProductProviderProps>;
|
|
34815
34822
|
declare const useProductStore: <U>(selector: (state: ExtractState<StoreApi<ProductContextProps>>) => U, equalityFn?: ((a: U, b: U) => boolean) | undefined) => U;
|
|
34816
34823
|
|
|
34824
|
+
type SectionProviderProps = {
|
|
34825
|
+
children: React.ReactNode;
|
|
34826
|
+
data?: SectionContextProps['data'];
|
|
34827
|
+
key?: React.Key;
|
|
34828
|
+
};
|
|
34817
34829
|
type SectionContextProps = {
|
|
34818
34830
|
data: Record<string, SectionData>;
|
|
34819
34831
|
getSection: (id: string) => SectionData | undefined;
|
|
34820
34832
|
addSection: (id: string, data: BuilderEntityNested) => void;
|
|
34821
34833
|
removeSection: (id: string) => void;
|
|
34822
34834
|
};
|
|
34823
|
-
|
|
34824
|
-
children: React.ReactNode;
|
|
34825
|
-
data?: SectionContextProps['data'];
|
|
34826
|
-
key?: React.Key;
|
|
34827
|
-
};
|
|
34835
|
+
|
|
34828
34836
|
declare const SectionProvider: React.FC<SectionProviderProps>;
|
|
34829
34837
|
declare const useSectionStore: <U>(selector: (state: ExtractState<StoreApi<SectionContextProps>>) => U, equalityFn?: ((a: U, b: U) => boolean) | undefined) => U;
|
|
34830
34838
|
declare const useSection: (id: string) => SectionData | undefined;
|
|
@@ -34884,6 +34892,7 @@ type ShopProviderProps = {
|
|
|
34884
34892
|
storeOption: Omit<ShopContextProps, 'changeLocale' | 'changeStorefrontInfo' | 'changeCurrency' | 'changeSwatches' | 'changeLayoutSettings' | 'changeCreateThemeSectionCount' | 'changeShopPlan' | 'changeLimitCreateThemeSection'>;
|
|
34885
34893
|
queryOption?: React.ComponentProps<typeof SWRConfig>['value'];
|
|
34886
34894
|
};
|
|
34895
|
+
|
|
34887
34896
|
declare const ShopProvider: React.FC<ShopProviderProps>;
|
|
34888
34897
|
declare const useShopStore: <U>(selector: (state: ExtractState<StoreApi<ShopContextProps>>) => U, equalityFn?: ((a: U, b: U) => boolean) | undefined) => U;
|
|
34889
34898
|
|
|
@@ -34918,6 +34927,7 @@ type PageProviderProps = Pick<PageContextProps, 'dynamicProduct' | 'dynamicColle
|
|
|
34918
34927
|
key?: React.Key;
|
|
34919
34928
|
publicStoreFrontData?: PublicStoreFrontData | null;
|
|
34920
34929
|
};
|
|
34930
|
+
|
|
34921
34931
|
declare const PageProvider: React.FC<PageProviderProps>;
|
|
34922
34932
|
declare const usePageStore: <U>(selector: (state: ExtractState<StoreApi<PageContextProps>>) => U, equalityFn?: ((a: U, b: U) => boolean) | undefined) => U;
|
|
34923
34933
|
|
|
@@ -34932,6 +34942,7 @@ type CollectionProviderProps = Pick<CollectionContextProps, 'collection'> & {
|
|
|
34932
34942
|
readOnly?: boolean;
|
|
34933
34943
|
children: React.ReactNode;
|
|
34934
34944
|
};
|
|
34945
|
+
|
|
34935
34946
|
declare const CollectionProvider: React.FC<CollectionProviderProps>;
|
|
34936
34947
|
declare const useCollectionStore: <U>(selector: (state: ExtractState<StoreApi<CollectionContextProps>>) => U, equalityFn?: ((a: U, b: U) => boolean) | undefined) => U;
|
|
34937
34948
|
|
|
@@ -34943,6 +34954,7 @@ type ModalContextProps = {
|
|
|
34943
34954
|
type ModalProviderProps = Pick<ModalContextProps, 'activeId'> & {
|
|
34944
34955
|
children: React.ReactNode;
|
|
34945
34956
|
};
|
|
34957
|
+
|
|
34946
34958
|
declare const ModalProvider: React.FC<ModalProviderProps>;
|
|
34947
34959
|
declare const useModalStore: <U>(selector: (state: ExtractState<StoreApi<ModalContextProps>>) => U, equalityFn?: ((a: U, b: U) => boolean) | undefined) => U;
|
|
34948
34960
|
|
|
@@ -34963,6 +34975,7 @@ type ArticleListContextProps = {
|
|
|
34963
34975
|
type ArticleListProviderProps = ArticleListContextProps & {
|
|
34964
34976
|
children: React.ReactNode;
|
|
34965
34977
|
};
|
|
34978
|
+
|
|
34966
34979
|
declare const ArticleListProvider: React.FC<ArticleListProviderProps>;
|
|
34967
34980
|
declare const useArticleListStore: <U>(selector: (state: ExtractState<StoreApi<ArticleListContextProps>>) => U, equalityFn?: ((a: U, b: U) => boolean) | undefined) => U;
|
|
34968
34981
|
|
|
@@ -34975,6 +34988,7 @@ type ArticleProviderProps = Pick<ArticleContextProps, 'article'> & {
|
|
|
34975
34988
|
readOnly?: boolean;
|
|
34976
34989
|
children: React.ReactNode;
|
|
34977
34990
|
};
|
|
34991
|
+
|
|
34978
34992
|
declare const ArticleProvider: React.FC<ArticleProviderProps>;
|
|
34979
34993
|
declare const useArticleStore: <U>(selector: (state: ExtractState<StoreApi<ArticleContextProps>>) => U, equalityFn?: ((a: U, b: U) => boolean) | undefined) => U;
|
|
34980
34994
|
|
|
@@ -34985,6 +34999,7 @@ type I18nProviderProps = I18nContextProps & {
|
|
|
34985
34999
|
readOnly?: boolean;
|
|
34986
35000
|
children: React.ReactNode;
|
|
34987
35001
|
};
|
|
35002
|
+
|
|
34988
35003
|
declare const I18nProvider: React.FC<I18nProviderProps>;
|
|
34989
35004
|
declare const useI18nStore: () => I18nContextProps;
|
|
34990
35005
|
|
|
@@ -42555,7 +42570,7 @@ type RequiredCursorEdge<T> = {
|
|
|
42555
42570
|
};
|
|
42556
42571
|
declare const fetchVariants: (fetcher: FetchFunc, { id, isSample, isStorefront }: FetchProductParams) => Promise<RequiredCursorEdge<VariantSelectFragment>[]>;
|
|
42557
42572
|
declare const fetchMedias: (fetcher: FetchFunc, { id, isSample, isStorefront }: FetchProductParams) => Promise<(Pick<MediaEdge$1, "cursor"> & {
|
|
42558
|
-
node?: Maybe$1<Pick<Media$1, "id" | "width" | "height" | "
|
|
42573
|
+
node?: Maybe$1<Pick<Media$1, "id" | "width" | "height" | "contentType" | "previewImage" | "src" | "alt">>;
|
|
42559
42574
|
})[]>;
|
|
42560
42575
|
|
|
42561
42576
|
type FetchProductsParams = {
|
|
@@ -47676,13 +47691,13 @@ declare const useSelectedOption: () => {
|
|
|
47676
47691
|
setSelectedOption: (optionId?: Maybe$1<string>, optionValue?: Maybe$1<string>, productId?: Maybe$1<string>, noEmit?: boolean) => void;
|
|
47677
47692
|
forceSelectedOption: (selectedOption?: Record<string, string>, productId?: Maybe$1<string>, noEmit?: boolean) => void;
|
|
47678
47693
|
};
|
|
47679
|
-
declare const useVariants: () => Maybe$1<Pick<ProductVariant$1, "id" | "title" | "price" | "width" | "length" | "weight" | "height" | "
|
|
47694
|
+
declare const useVariants: () => Maybe$1<Pick<ProductVariant$1, "id" | "title" | "price" | "width" | "length" | "weight" | "height" | "barcode" | "baseID" | "costPrice" | "inventoryPolicy" | "inventoryQuantity" | "inventoryStatus" | "isDigital" | "lowInventoryAmount" | "manageInventory" | "mediaId" | "platform" | "salePrice" | "sku" | "soldIndividually"> & {
|
|
47680
47695
|
selectedOptions: Pick<SelectedOption$1, "name" | "value" | "optionType">[];
|
|
47681
|
-
media?: Maybe$1<Pick<Media$1, "id" | "width" | "height" | "
|
|
47696
|
+
media?: Maybe$1<Pick<Media$1, "id" | "width" | "height" | "contentType" | "previewImage" | "src" | "alt">>;
|
|
47682
47697
|
}>[];
|
|
47683
|
-
declare const useVariant: (id: string) => Maybe$1<Pick<ProductVariant$1, "id" | "title" | "price" | "width" | "length" | "weight" | "height" | "
|
|
47698
|
+
declare const useVariant: (id: string) => Maybe$1<Pick<ProductVariant$1, "id" | "title" | "price" | "width" | "length" | "weight" | "height" | "barcode" | "baseID" | "costPrice" | "inventoryPolicy" | "inventoryQuantity" | "inventoryStatus" | "isDigital" | "lowInventoryAmount" | "manageInventory" | "mediaId" | "platform" | "salePrice" | "sku" | "soldIndividually"> & {
|
|
47684
47699
|
selectedOptions: Pick<SelectedOption$1, "name" | "value" | "optionType">[];
|
|
47685
|
-
media?: Maybe$1<Pick<Media$1, "id" | "width" | "height" | "
|
|
47700
|
+
media?: Maybe$1<Pick<Media$1, "id" | "width" | "height" | "contentType" | "previewImage" | "src" | "alt">>;
|
|
47686
47701
|
}>;
|
|
47687
47702
|
declare const useCurrentVariant: () => Maybe$1<VariantSelectFragment>;
|
|
47688
47703
|
declare const useCurrentVariantInStock: () => boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gem-sdk/core",
|
|
3
|
-
"version": "2.0.0-dev.
|
|
3
|
+
"version": "2.0.0-dev.468",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "dist/cjs/index.js",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@gem-sdk/adapter-shopify": "2.0.0-dev.324",
|
|
31
|
-
"@gem-sdk/styles": "2.0.0-dev.
|
|
31
|
+
"@gem-sdk/styles": "2.0.0-dev.464",
|
|
32
32
|
"@types/classnames": "^2.3.1"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|