@brytdesigns/shopify-product-info-components 1.0.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.
@@ -0,0 +1,7 @@
1
+ export * from './product-info.js';
2
+ export * from './product-variant-render.js';
3
+ export * from './product-options.js';
4
+ export * from './product-option-group.js';
5
+ export * from './product-variant-input.js';
6
+ //# sourceMappingURL=index.js.map
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js","sourcesContent":[]}
@@ -0,0 +1,25 @@
1
+ import { provideProductContext } from '../hooks/index.js';
2
+
3
+ const ProductInfo = (props, { element }) => {
4
+ if (!props.product)
5
+ return console.warn("product-info: product attribute is required");
6
+ if (!props.product.variants)
7
+ return console.warn("product-info: product attribute needs variants array");
8
+ if (!props.product.selected_or_first_available_variant)
9
+ return console.warn(
10
+ "product-info: product attribute needs selected or first available variant object"
11
+ );
12
+ provideProductContext(
13
+ {
14
+ get product() {
15
+ return props.product;
16
+ },
17
+ element
18
+ },
19
+ element
20
+ );
21
+ };
22
+
23
+ export { ProductInfo };
24
+ //# sourceMappingURL=product-info.js.map
25
+ //# sourceMappingURL=product-info.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/product-info.ts"],"names":[],"mappings":";;AASO,MAAM,WAAsD,GAAA,CACjE,KACA,EAAA,EAAE,SACC,KAAA;AACH,EAAA,IAAI,CAAC,KAAM,CAAA,OAAA;AACT,IAAO,OAAA,OAAA,CAAQ,KAAK,6CAA6C,CAAA;AACnE,EAAI,IAAA,CAAC,MAAM,OAAQ,CAAA,QAAA;AACjB,IAAO,OAAA,OAAA,CAAQ,KAAK,sDAAsD,CAAA;AAC5E,EAAI,IAAA,CAAC,MAAM,OAAQ,CAAA,mCAAA;AACjB,IAAA,OAAO,OAAQ,CAAA,IAAA;AAAA,MACb;AAAA,KACF;AACF,EAAA,qBAAA;AAAA,IACE;AAAA,MACE,IAAI,OAAU,GAAA;AACZ,QAAA,OAAO,KAAM,CAAA,OAAA;AAAA,OACf;AAAA,MACA;AAAA,KACF;AAAA,IACA;AAAA,GACF;AACF","file":"product-info.js","sourcesContent":["import type { CorrectComponentType } from \"@brytdesigns/web-component-utils\";\nimport { provideProductContext } from \"../hooks/index.js\";\n\nimport type { Product } from \"../types.js\";\n\ntype ProductInfoProps = {\n product?: Product;\n};\n\nexport const ProductInfo: CorrectComponentType<ProductInfoProps> = (\n props,\n { element },\n) => {\n if (!props.product)\n return console.warn(\"product-info: product attribute is required\");\n if (!props.product.variants)\n return console.warn(\"product-info: product attribute needs variants array\");\n if (!props.product.selected_or_first_available_variant)\n return console.warn(\n \"product-info: product attribute needs selected or first available variant object\",\n );\n provideProductContext(\n {\n get product() {\n return props.product!;\n },\n element,\n },\n element,\n );\n};\n"]}
@@ -0,0 +1,68 @@
1
+ import { createEffect, on, onCleanup } from 'solid-js';
2
+ import { useProductOptions } from '../hooks/index.js';
3
+
4
+ const ProductOptionGroup = (props, { element }) => {
5
+ const [context, methods] = useProductOptions(element);
6
+ createEffect(
7
+ on(
8
+ () => ({
9
+ selectedOption: context.selectedOptions[props.position - 1],
10
+ position: props.position,
11
+ name: props.name,
12
+ inputType: props.inputType
13
+ }),
14
+ ({ selectedOption, position, name, inputType }) => {
15
+ if (inputType !== "radio" && inputType !== "select") return;
16
+ const optionName = `${name}-${position}`;
17
+ if (inputType === "radio") {
18
+ const inputs = element.querySelectorAll(
19
+ `input[name="${optionName}"]`
20
+ );
21
+ inputs.forEach((input) => {
22
+ const prevValue = input.checked;
23
+ if (input.value === selectedOption) input.checked = true;
24
+ else input.checked = false;
25
+ if (prevValue !== input.checked) {
26
+ input.dispatchEvent(new Event("change", { bubbles: true }));
27
+ }
28
+ });
29
+ return;
30
+ }
31
+ const select = element.querySelector(
32
+ `select[name="${optionName}"]`
33
+ );
34
+ if (!select || !selectedOption) return;
35
+ select.value = selectedOption;
36
+ select.dispatchEvent(new Event("change", { bubbles: true }));
37
+ }
38
+ )
39
+ );
40
+ createEffect(() => {
41
+ const position = props.position;
42
+ function handleChange(event) {
43
+ const target = event.target;
44
+ if (!target) return;
45
+ const selectedOption = target.value;
46
+ if (context.selectedOptions[position - 1] === selectedOption) return;
47
+ element.dispatchEvent(
48
+ new CustomEvent("option-updated", {
49
+ detail: {
50
+ group: props.name,
51
+ position,
52
+ selectedOption
53
+ },
54
+ bubbles: true
55
+ })
56
+ );
57
+ methods.options.updateOption(selectedOption, position - 1);
58
+ }
59
+ element.addEventListener("change", handleChange);
60
+ return onCleanup(() => {
61
+ element.removeEventListener("change", handleChange);
62
+ });
63
+ });
64
+ };
65
+
66
+ export { ProductOptionGroup };
67
+ //# sourceMappingURL=product-option-group.js.map
68
+ //# sourceMappingURL=product-option-group.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/product-option-group.ts"],"names":[],"mappings":";;;AAYO,MAAM,kBAET,GAAA,CAAC,KAAO,EAAA,EAAE,SAAc,KAAA;AAC1B,EAAA,MAAM,CAAC,OAAA,EAAS,OAAO,CAAA,GAAI,kBAAkB,OAAO,CAAA;AAEpD,EAAA,YAAA;AAAA,IACE,EAAA;AAAA,MACE,OAAO;AAAA,QACL,cAAgB,EAAA,OAAA,CAAQ,eAAgB,CAAA,KAAA,CAAM,WAAW,CAAC,CAAA;AAAA,QAC1D,UAAU,KAAM,CAAA,QAAA;AAAA,QAChB,MAAM,KAAM,CAAA,IAAA;AAAA,QACZ,WAAW,KAAM,CAAA;AAAA,OACnB,CAAA;AAAA,MACA,CAAC,EAAE,cAAA,EAAgB,QAAU,EAAA,IAAA,EAAM,WAAgB,KAAA;AACjD,QAAI,IAAA,SAAA,KAAc,OAAW,IAAA,SAAA,KAAc,QAAU,EAAA;AAErD,QAAA,MAAM,UAAa,GAAA,CAAA,EAAG,IAAI,CAAA,CAAA,EAAI,QAAQ,CAAA,CAAA;AAEtC,QAAA,IAAI,cAAc,OAAS,EAAA;AACzB,U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AAA,YACN,OAAO,KAAM,CAAA,IAAA;AAAA,YACb,QAAA;AAAA,YACA;AAAA,WACF;AAAA,UACA,OAAS,EAAA;AAAA,SACV;AAAA,OACH;AAEA,MAAA,OAAA,CAAQ,OAAQ,CAAA,YAAA,CAAa,cAAgB,EAAA,QAAA,GAAW,CAAC,CAAA;AAAA;AAG3D,IAAQ,OAAA,CAAA,gBAAA,CAAiB,UAAU,YAAY,CAAA;AAE/C,IAAA,OAAO,UAAU,MAAM;AACrB,MAAQ,OAAA,CAAA,mBAAA,CAAoB,UAAU,YAAY,CAAA;AAAA,KACnD,CAAA;AAAA,GACF,CAAA;AACH","file":"product-option-group.js","sourcesContent":["import type { CorrectComponentType } from \"@brytdesigns/web-component-utils\";\n\nimport { createEffect, on, onCleanup } from \"solid-js\";\n\nimport { useProductOptions } from \"../hooks/index.js\";\n\ntype ProductOptionGroupProps = {\n position: number;\n name: string;\n inputType: \"radio\" | \"select\";\n};\n\nexport const ProductOptionGroup: CorrectComponentType<\n ProductOptionGroupProps\n> = (props, { element }) => {\n const [context, methods] = useProductOptions(element);\n\n createEffect(\n on(\n () => ({\n selectedOption: context.selectedOptions[props.position - 1],\n position: props.position,\n name: props.name,\n inputType: props.inputType,\n }),\n ({ selectedOption, position, name, inputType }) => {\n if (inputType !== \"radio\" && inputType !== \"select\") return;\n\n const optionName = `${name}-${position}`;\n\n if (inputType === \"radio\") {\n const inputs = element.querySelectorAll<HTMLInputElement>(\n `input[name=\"${optionName}\"]`,\n );\n inputs.forEach((input) => {\n const prevValue = input.checked;\n if (input.value === selectedOption) input.checked = true;\n else input.checked = false;\n if (prevValue !== input.checked) {\n input.dispatchEvent(new Event(\"change\", { bubbles: true }));\n }\n });\n return;\n }\n\n const select = element.querySelector<HTMLSelectElement>(\n `select[name=\"${optionName}\"]`,\n );\n if (!select || !selectedOption) return;\n select.value = selectedOption;\n select.dispatchEvent(new Event(\"change\", { bubbles: true }));\n },\n ),\n );\n\n createEffect(() => {\n const position = props.position;\n\n function handleChange(event: Event) {\n const target = event.target as HTMLInputElement;\n if (!target) return;\n const selectedOption = target.value;\n if (context.selectedOptions[position - 1] === selectedOption) return;\n\n element.dispatchEvent(\n new CustomEvent(\"option-updated\", {\n detail: {\n group: props.name,\n position: position,\n selectedOption,\n },\n bubbles: true,\n }),\n );\n\n methods.options.updateOption(selectedOption, position - 1);\n }\n\n element.addEventListener(\"change\", handleChange);\n\n return onCleanup(() => {\n element.removeEventListener(\"change\", handleChange);\n });\n });\n};\n"]}
@@ -0,0 +1,21 @@
1
+ import { provideProductOptionsContext } from '../hooks/index.js';
2
+
3
+ const ProductOptions = (props, { element }) => {
4
+ if (!props.selectedOptions)
5
+ return console.warn(
6
+ "product-options: selected-options attribute is required"
7
+ );
8
+ provideProductOptionsContext(
9
+ {
10
+ get selectedOptions() {
11
+ return props.selectedOptions;
12
+ },
13
+ element
14
+ },
15
+ element
16
+ );
17
+ };
18
+
19
+ export { ProductOptions };
20
+ //# sourceMappingURL=product-options.js.map
21
+ //# sourceMappingURL=product-options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/product-options.ts"],"names":[],"mappings":";;AAOO,MAAM,cAA4D,GAAA,CACvE,KACA,EAAA,EAAE,SACC,KAAA;AACH,EAAA,IAAI,CAAC,KAAM,CAAA,eAAA;AACT,IAAA,OAAO,OAAQ,CAAA,IAAA;AAAA,MACb;AAAA,KACF;AACF,EAAA,4BAAA;AAAA,IACE;AAAA,MACE,IAAI,eAAkB,GAAA;AACpB,QAAA,OAAO,KAAM,CAAA,eAAA;AAAA,OACf;AAAA,MACA;AAAA,KACF;AAAA,IACA;AAAA,GACF;AACF","file":"product-options.js","sourcesContent":["import type { CorrectComponentType } from \"@brytdesigns/web-component-utils\";\nimport { provideProductOptionsContext } from \"../hooks/index.js\";\n\ntype ProductOptionsProps = {\n selectedOptions: string[];\n};\n\nexport const ProductOptions: CorrectComponentType<ProductOptionsProps> = (\n props,\n { element },\n) => {\n if (!props.selectedOptions)\n return console.warn(\n \"product-options: selected-options attribute is required\",\n );\n provideProductOptionsContext(\n {\n get selectedOptions() {\n return props.selectedOptions;\n },\n element,\n },\n element,\n );\n};\n"]}
@@ -0,0 +1,49 @@
1
+ import { createEffect, onCleanup } from 'solid-js';
2
+ import { useProduct, useProductOptions } from '../hooks/index.js';
3
+
4
+ const ProductVariantInput = (props, { element }) => {
5
+ const [productContext, productContextMethods] = useProduct(element);
6
+ const [_, optionsMethods] = useProductOptions(element);
7
+ createEffect(() => {
8
+ let target = null;
9
+ if (props.target) target = element.querySelector(props.target);
10
+ if (!target) target = element;
11
+ const preventDefault = props.preventDefault;
12
+ function handleChange(event) {
13
+ if (preventDefault) event.preventDefault();
14
+ const target2 = event.target;
15
+ if (!target2) return;
16
+ const value = target2.value;
17
+ if (value === productContext?.product?.selected_or_first_available_variant?.id)
18
+ return;
19
+ const variant = productContext?.product?.variants.find(
20
+ (variant2) => variant2.id.toString() === value.toString()
21
+ );
22
+ if (!variant) return;
23
+ if (optionsMethods) optionsMethods.options.update(variant.options);
24
+ else productContextMethods.variant.update(variant.id);
25
+ }
26
+ target.addEventListener("change", handleChange);
27
+ return onCleanup(() => {
28
+ target.removeEventListener("change", handleChange);
29
+ });
30
+ });
31
+ createEffect(() => {
32
+ let target = null;
33
+ if (props.target)
34
+ target = element.querySelector(props.target);
35
+ if (!target)
36
+ target = element.querySelector("input[name='id']");
37
+ if (!target)
38
+ return console.warn("product-variant-input: target input not found");
39
+ const variantId = productContext?.product?.selected_or_first_available_variant?.id;
40
+ if (!variantId) return;
41
+ if (target.value === variantId.toString()) return;
42
+ target.value = variantId.toString();
43
+ target.dispatchEvent(new Event("change", { bubbles: true }));
44
+ });
45
+ };
46
+
47
+ export { ProductVariantInput };
48
+ //# sourceMappingURL=product-variant-input.js.map
49
+ //# sourceMappingURL=product-variant-input.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/product-variant-input.ts"],"names":["target","variant"],"mappings":";;;AAWO,MAA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AAA,CAAoB,UAAU,YAAY,CAAA;AAAA,KAClD,CAAA;AAAA,GACF,CAAA;AAED,EAAA,YAAA,CAAa,MAAM;AACjB,IAAA,IAAI,MAAS,GAAA,IAAA;AACb,IAAA,IAAI,KAAM,CAAA,MAAA;AACR,MAAS,MAAA,GAAA,OAAA,CAAQ,aAAgC,CAAA,KAAA,CAAM,MAAM,CAAA;AAC/D,IAAA,IAAI,CAAC,MAAA;AACH,MAAS,MAAA,GAAA,OAAA,CAAQ,cAAgC,kBAAkB,CAAA;AACrE,IAAA,IAAI,CAAC,MAAA;AACH,MAAO,OAAA,OAAA,CAAQ,KAAK,+CAA+C,CAAA;AAErE,IAAM,MAAA,SAAA,GACJ,cAAgB,EAAA,OAAA,EAAS,mCAAqC,EAAA,EAAA;AAChE,IAAA,IAAI,CAAC,SAAW,EAAA;AAChB,IAAA,IAAI,MAAO,CAAA,KAAA,KAAU,SAAU,CAAA,QAAA,EAAY,EAAA;AAC3C,IAAO,MAAA,CAAA,KAAA,GAAQ,UAAU,QAAS,EAAA;AAClC,IAAO,MAAA,CAAA,aAAA,CAAc,IAAI,KAAM,CAAA,QAAA,EAAU,EAAE,OAAS,EAAA,IAAA,EAAM,CAAC,CAAA;AAAA,GAC5D,CAAA;AACH","file":"product-variant-input.js","sourcesContent":["import type { CorrectComponentType } from \"@brytdesigns/web-component-utils\";\n\nimport { createEffect, onCleanup } from \"solid-js\";\n\nimport { useProduct, useProductOptions } from \"../hooks/index.js\";\n\ntype ProductVariantInputProps = {\n target: string | null;\n preventDefault?: boolean;\n};\n\nexport const ProductVariantInput: CorrectComponentType<\n ProductVariantInputProps\n> = (props, { element }) => {\n const [productContext, productContextMethods] = useProduct(element);\n const [_, optionsMethods] = useProductOptions(element);\n\n createEffect(() => {\n let target = null;\n if (props.target) target = element.querySelector(props.target);\n if (!target) target = element;\n\n const preventDefault = props.preventDefault;\n\n function handleChange(event: Event) {\n if (preventDefault) event.preventDefault();\n const target = event.target as HTMLInputElement;\n if (!target) return;\n const value = target.value;\n if (\n value ===\n productContext?.product?.selected_or_first_available_variant?.id\n )\n return;\n const variant = productContext?.product?.variants.find(\n (variant) => variant.id.toString() === value.toString(),\n );\n if (!variant) return;\n if (optionsMethods) optionsMethods.options.update(variant.options);\n else productContextMethods.variant.update(variant.id);\n }\n\n target.addEventListener(\"change\", handleChange);\n\n return onCleanup(() => {\n target.removeEventListener(\"change\", handleChange);\n });\n });\n\n createEffect(() => {\n let target = null;\n if (props.target)\n target = element.querySelector<HTMLInputElement>(props.target);\n if (!target)\n target = element.querySelector<HTMLInputElement>(\"input[name='id']\");\n if (!target)\n return console.warn(\"product-variant-input: target input not found\");\n\n const variantId =\n productContext?.product?.selected_or_first_available_variant?.id;\n if (!variantId) return;\n if (target.value === variantId.toString()) return;\n target.value = variantId.toString();\n target.dispatchEvent(new Event(\"change\", { bubbles: true }));\n });\n};\n"]}
@@ -0,0 +1,36 @@
1
+ import { createMemo, Show } from 'solid-js';
2
+ import html from 'solid-js/html';
3
+ import { useProduct } from '../hooks/index.js';
4
+
5
+ const ProductVariantRender = (_, { element }) => {
6
+ const templates = Array.from(
7
+ element.querySelectorAll("template[variant-id]")
8
+ );
9
+ if (!templates.length)
10
+ return console.warn("product-variant-render: No variant templates found");
11
+ const [state] = useProduct(element);
12
+ const fallbackChildren = Array.from(element.children);
13
+ const activeVariantTemplate = createMemo(() => {
14
+ const variantId = state.product?.selected_or_first_available_variant?.id;
15
+ if (!variantId) return null;
16
+ const template = templates.find(
17
+ (t) => t.getAttribute("variant-id") === `${variantId}`
18
+ );
19
+ return template || null;
20
+ });
21
+ element.replaceChildren(...[]);
22
+ return html`
23
+ <${Show}
24
+ when=${() => !!activeVariantTemplate()}
25
+ fallback=${fallbackChildren}
26
+ >
27
+ ${() => Array.from(
28
+ activeVariantTemplate()?.content.cloneNode(true).childNodes || []
29
+ )}
30
+ <//>
31
+ `;
32
+ };
33
+
34
+ export { ProductVariantRender };
35
+ //# sourceMappingURL=product-variant-render.js.map
36
+ //# sourceMappingURL=product-variant-render.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/product-variant-render.ts"],"names":[],"mappings":";;;;AASO,MAAM,oBAET,GAAA,CAAC,CAAG,EAAA,EAAE,SAAc,KAAA;AACtB,EAAA,MAAM,YAAY,KAAM,CAAA,IAAA;AAAA,IACtB,OAAA,CAAQ,iBAAsC,sBAAsB;AAAA,GACtE;AACA,EAAA,IAAI,CAAC,SAAU,CAAA,MAAA;AACb,IAAO,OAAA,OAAA,CAAQ,KAAK,oDAAoD,CAAA;AAC1E,EAAA,MAAM,CAAC,KAAK,CAAI,GAAA,UAAA,CAAW,OAAO,CAAA;AAElC,EAAA,MAAM,gBAAmB,GAAA,KAAA,CAAM,IAAK,CAAA,OAAA,CAAQ,QAAQ,CAAA;AAEpD,EAAM,MAAA,qBAAA,GAAwB,WAAW,MAAM;AAC7C,IAAM,MAAA,SAAA,GAAY,KAAM,CAAA,OAAA,EAAS,mCAAqC,EAAA,EAAA;AACtE,IAAI,IAAA,CAAC,WAAkB,OAAA,IAAA;AACvB,IAAA,MAAM,WAAW,SAAU,CAAA,IAAA;AAAA,MACzB,CAAC,CAAM,KAAA,CAAA,CAAE,aAAa,YAAY,CAAA,KAAM,GAAG,SAAS,CAAA;AAAA,KACtD;AACA,IAAA,OAAO,QAAY,IAAA,IAAA;AAAA,GACpB,CAAA;AAED,EAAQ,OAAA,CAAA,eAAA,CAAgB,GAAG,EAAE,CAAA;AAE7B,EAAO,OAAA,IAAA;AAAA,KAAA,EACF,IAAI;AAAA,WAAA,EACE,MAAM,CAAC,CAAC,qBAAA,EAAuB;AAAA,eAAA,EAC3B,gBAAgB;AAAA;AAAA,MAAA,EAEzB,MACF,KAAM,CAAA,IAAA;AAAA,IACJ,uBAAyB,EAAA,OAAA,CAAQ,UAAU,IAAI,CAAA,CAAE,cAAc;AAAC,GACjE;AAAA;AAAA,EAAA,CAAA;AAGP","file":"product-variant-render.js","sourcesContent":["import type { CorrectComponentType } from \"@brytdesigns/web-component-utils\";\n\nimport { createMemo, Show } from \"solid-js\";\nimport html from \"solid-js/html\";\n\nimport { useProduct } from \"../hooks/index.js\";\n\ntype ProductVariantRenderProps = {};\n\nexport const ProductVariantRender: CorrectComponentType<\n ProductVariantRenderProps\n> = (_, { element }) => {\n const templates = Array.from(\n element.querySelectorAll<HTMLTemplateElement>(\"template[variant-id]\"),\n );\n if (!templates.length)\n return console.warn(\"product-variant-render: No variant templates found\");\n const [state] = useProduct(element);\n\n const fallbackChildren = Array.from(element.children);\n\n const activeVariantTemplate = createMemo(() => {\n const variantId = state.product?.selected_or_first_available_variant?.id;\n if (!variantId) return null;\n const template = templates.find(\n (t) => t.getAttribute(\"variant-id\") === `${variantId}`,\n );\n return template || null;\n });\n\n element.replaceChildren(...[]);\n\n return html`\n <${Show}\n when=${() => !!activeVariantTemplate()}\n fallback=${fallbackChildren}\n >\n ${() =>\n Array.from(\n activeVariantTemplate()?.content.cloneNode(true).childNodes || [],\n )}\n <//>\n `;\n};\n"]}
@@ -0,0 +1,4 @@
1
+ export * from './useProduct.js';
2
+ export * from './useProductOptions.js';
3
+ //# sourceMappingURL=index.js.map
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js","sourcesContent":[]}
@@ -0,0 +1,65 @@
1
+ import { createContext, provide, consume } from 'component-register';
2
+ import { splitProps, mergeProps } from 'solid-js';
3
+ import { getContextFromProvider } from '@brytdesigns/web-component-utils';
4
+
5
+ function initializeProductContext(props) {
6
+ const [privateProps, publicProps] = splitProps(props, ["element"]);
7
+ const state = mergeProps(publicProps, {});
8
+ function updateSelectedVariant(variantId) {
9
+ if (typeof state?.product?.selected_or_first_available_variant === "undefined" || typeof state?.product === "undefined" || typeof state?.product?.variants === "undefined")
10
+ return;
11
+ const newVariant = state.product.variants.find(
12
+ (variant) => variant.id.toString() === variantId.toString()
13
+ );
14
+ const newState = {
15
+ ...props.product,
16
+ selected_or_first_available_variant: newVariant
17
+ };
18
+ privateProps.element.setAttribute("product", JSON.stringify(newState));
19
+ privateProps.element.dispatchEvent(
20
+ new CustomEvent("variant-updated", {
21
+ detail: {
22
+ variant: newVariant,
23
+ product: newState
24
+ },
25
+ bubbles: true
26
+ })
27
+ );
28
+ }
29
+ return [
30
+ state,
31
+ {
32
+ variant: {
33
+ update: updateSelectedVariant
34
+ }
35
+ }
36
+ ];
37
+ }
38
+ const ProductContextState = createContext(initializeProductContext);
39
+ const provideProductContext = (initialState, element) => {
40
+ const props = mergeProps(initialState, { root: element });
41
+ return provide(ProductContextState, props, element);
42
+ };
43
+ const useProductContext = (context) => {
44
+ return context;
45
+ };
46
+ const useProduct = (element) => {
47
+ const context = consume(ProductContextState, element);
48
+ if (!context) {
49
+ throw console.error(
50
+ "DrawerContext not found! Please ensure to wrap your custom element with drawer-context element."
51
+ );
52
+ }
53
+ return useProductContext(context);
54
+ };
55
+ const getProductContext = (element) => {
56
+ const context = getContextFromProvider(
57
+ ProductContextState,
58
+ element
59
+ );
60
+ return useProductContext(context);
61
+ };
62
+
63
+ export { getProductContext, provideProductContext, useProduct, useProductContext };
64
+ //# sourceMappingURL=useProduct.js.map
65
+ //# sourceMappingURL=useProduct.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/hooks/useProduct.ts"],"names":[],"mappings":";;;;AAoBA,SAAS,yBAAyB,KAA6B,EAAA;AAC7D,EAAM,MAAA,CAAC,cAAc,WAAW,CAAA,GAAI,WAAW,KAAO,EAAA,CAAC,SAAS,CAAC,CAAA;AACjE,EAAA,MAAM,KAAQ,GAAA,UAAA,CAAW,WAAa,EAAA,EAAE,CAAA;AAExC,EAAA,SAAS,sBAAsB,SAA4B,EAAA;AACzD,IAAA,IACE,OAAO,KAAA,EAAO,OAAS,EAAA,mCAAA,KACvB,WACA,IAAA,OAAO,KAAO,EAAA,OAAA,KAAY,WAC1B,IAAA,OAAO,KAAO,EAAA,OAAA,EAAS,QAA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M,OAAQ,CAAA,KAAA;AAAA,MACZ;AAAA,KACF;AAAA;AAGF,EAAA,OAAO,kBAAkB,OAAO,CAAA;AAClC;AAEa,MAAA,iBAAA,GAAoB,CAAC,OAAqB,KAAA;AACrD,EAAA,MAAM,OAAU,GAAA,sBAAA;AAAA,IACd,mBAAA;AAAA,IACA;AAAA,GACF;AACA,EAAA,OAAO,kBAAkB,OAAO,CAAA;AAClC","file":"useProduct.js","sourcesContent":["import {\n type ICustomElement,\n createContext,\n provide,\n consume,\n} from \"component-register\";\nimport { mergeProps, splitProps } from \"solid-js\";\nimport { getContextFromProvider } from \"@brytdesigns/web-component-utils\";\n\nimport type { Product } from \"../types\";\n\ntype CreateContextOptions = {\n element: HTMLElement & ICustomElement;\n product: Product;\n};\n\ntype WalkableNode = Parameters<typeof provide>[2];\n\ntype ProductContext = ReturnType<typeof initializeProductContext>;\n\nfunction initializeProductContext(props: CreateContextOptions) {\n const [privateProps, publicProps] = splitProps(props, [\"element\"]);\n const state = mergeProps(publicProps, {});\n\n function updateSelectedVariant(variantId: string | number) {\n if (\n typeof state?.product?.selected_or_first_available_variant ===\n \"undefined\" ||\n typeof state?.product === \"undefined\" ||\n typeof state?.product?.variants === \"undefined\"\n )\n return;\n const newVariant = state.product.variants.find(\n (variant) => variant.id.toString() === variantId.toString(),\n );\n\n const newState = {\n ...props.product,\n selected_or_first_available_variant: newVariant,\n };\n\n privateProps.element.setAttribute(\"product\", JSON.stringify(newState));\n\n privateProps.element.dispatchEvent(\n new CustomEvent(\"variant-updated\", {\n detail: {\n variant: newVariant,\n product: newState,\n },\n bubbles: true,\n }),\n );\n }\n\n return [\n state,\n {\n variant: {\n update: updateSelectedVariant,\n },\n },\n ] as const;\n}\n\nconst ProductContextState = createContext(initializeProductContext);\n\nexport const provideProductContext = (\n initialState: Omit<CreateContextOptions, \"root\">,\n element: WalkableNode,\n): ProductContext => {\n const props = mergeProps(initialState, { root: element });\n return provide(ProductContextState, props, element);\n};\n\nexport const useProductContext = (context: ProductContext) => {\n return context;\n};\n\nexport const useProduct = (element: HTMLElement & ICustomElement) => {\n const context: ProductContext = consume(ProductContextState, element);\n\n if (!context) {\n throw console.error(\n \"DrawerContext not found! Please ensure to wrap your custom element with drawer-context element.\",\n );\n }\n\n return useProductContext(context);\n};\n\nexport const getProductContext = (element: Element) => {\n const context = getContextFromProvider<ProductContext>(\n ProductContextState,\n element,\n );\n return useProductContext(context);\n};\n"]}
@@ -0,0 +1,73 @@
1
+ import { createContext, provide, consume } from 'component-register';
2
+ import { splitProps, createEffect, mergeProps } from 'solid-js';
3
+ import { getContextFromProvider } from '@brytdesigns/web-component-utils';
4
+ import { useProduct } from './useProduct.js';
5
+
6
+ function initializeProductOptionsContext(props) {
7
+ const [privateProps, publicProps] = splitProps(props, ["element"]);
8
+ const [context, methods] = useProduct(privateProps.element);
9
+ function updateSelectedOptions(options) {
10
+ privateProps.element.setAttribute(
11
+ "selected-options",
12
+ JSON.stringify(options)
13
+ );
14
+ }
15
+ function updateSelectedOption(option, index) {
16
+ const options = [...props.selectedOptions];
17
+ options[index] = option;
18
+ return updateSelectedOptions(options);
19
+ }
20
+ createEffect(() => {
21
+ const variant = context.product.variants.find((variant2) => {
22
+ return publicProps.selectedOptions.every(
23
+ (option) => variant2.options.includes(option)
24
+ );
25
+ });
26
+ if (!variant) return;
27
+ if (variant.id === context.product.selected_or_first_available_variant.id)
28
+ return;
29
+ methods.variant.update(variant.id);
30
+ });
31
+ return [
32
+ props,
33
+ {
34
+ options: {
35
+ update: updateSelectedOptions,
36
+ updateOption: updateSelectedOption
37
+ }
38
+ }
39
+ ];
40
+ }
41
+ const ProductOptionsContextState = createContext(
42
+ initializeProductOptionsContext
43
+ );
44
+ const provideProductOptionsContext = (initialState, element) => {
45
+ const props = mergeProps(initialState, { root: element });
46
+ return provide(ProductOptionsContextState, props, element);
47
+ };
48
+ const useProductOptionsContext = (context) => {
49
+ return context;
50
+ };
51
+ const useProductOptions = (element) => {
52
+ const context = consume(
53
+ ProductOptionsContextState,
54
+ element
55
+ );
56
+ if (!context) {
57
+ throw console.error(
58
+ "DrawerContext not found! Please ensure to wrap your custom element with drawer-context element."
59
+ );
60
+ }
61
+ return useProductOptionsContext(context);
62
+ };
63
+ const getProductOptionsContext = (element) => {
64
+ const context = getContextFromProvider(
65
+ ProductOptionsContextState,
66
+ element
67
+ );
68
+ return useProductOptionsContext(context);
69
+ };
70
+
71
+ export { getProductOptionsContext, provideProductOptionsContext, useProductOptions, useProductOptionsContext };
72
+ //# sourceMappingURL=useProductOptions.js.map
73
+ //# sourceMappingURL=useProductOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/hooks/useProductOptions.ts"],"names":["variant"],"mappings":";;;;;AAoBA,SAAS,gCAAgC,KAA6B,EAAA;AACpE,EAAM,MAAA,CAAC,cAAc,WAAW,CAAA,GAAI,WAAW,KAAO,EAAA,CAAC,SAAS,CAAC,CAAA;AACjE,EAAA,MAAM,CAAC,OAAS,EAAA,OAAO,CAAI,GAAA,UAAA,CAAW,aAAa,OAAO,CAAA;AAE1D,EAAA,SAAS,sBAAsB,OAAmB,EAAA;AAChD,IAAA,YAAA,CAAa,OAAQ,CAAA,YAAA;AAAA,MACnB,kBAAA;AAAA,MACA,IAAA,CAAK,UAAU,OAAO;AAAA,KACxB;AAAA;AAGF,EAAS,SAAA,oBAAA,CAAqB,QAAgB,KAAe,EAAA;AAC3D,IAAA,MAAM,OAAU,GAAA,CAAC,GAAG,KAAA,CAAM,eAAe,CAAA;AACzC,IAAA,OAAA,CAAQ,KAAK,CAAI,GAAA,MAAA;AACjB,IAAA,OAAO,sBAAsB,OAAO,CAAA;AAAA;AAGtC,EAAA,YAAA,CAAa,MAAM;AACjB,IAAA,MAAM,UAAU,OAAQ,CAAA,OAAA,CAAQ,QAAS,CAAA,IAAA,CAAK,CAACA,QAAY,KAAA;AACzD,MAAA,OAAO,YAAY,eAAgB,CAAA,KAAA;AAAA,QAAM,CAAC,MAAA,KACxCA,QA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ProductOptions.js","sourcesContent":["import {\n type ICustomElement,\n createContext,\n provide,\n consume,\n} from \"component-register\";\nimport { createEffect, mergeProps, splitProps } from \"solid-js\";\nimport { getContextFromProvider } from \"@brytdesigns/web-component-utils\";\n\nimport { useProduct } from \"./useProduct.js\";\n\ntype CreateContextOptions = {\n element: HTMLElement & ICustomElement;\n selectedOptions: string[];\n};\n\ntype WalkableNode = Parameters<typeof provide>[2];\n\ntype ProductOptionsContext = ReturnType<typeof initializeProductOptionsContext>;\n\nfunction initializeProductOptionsContext(props: CreateContextOptions) {\n const [privateProps, publicProps] = splitProps(props, [\"element\"]);\n const [context, methods] = useProduct(privateProps.element);\n\n function updateSelectedOptions(options: string[]) {\n privateProps.element.setAttribute(\n \"selected-options\",\n JSON.stringify(options),\n );\n }\n\n function updateSelectedOption(option: string, index: number) {\n const options = [...props.selectedOptions];\n options[index] = option;\n return updateSelectedOptions(options);\n }\n\n createEffect(() => {\n const variant = context.product.variants.find((variant) => {\n return publicProps.selectedOptions.every((option) =>\n variant.options.includes(option),\n );\n });\n if (!variant) return;\n if (variant.id === context.product.selected_or_first_available_variant.id)\n return;\n methods.variant.update(variant.id);\n });\n\n return [\n props,\n {\n options: {\n update: updateSelectedOptions,\n updateOption: updateSelectedOption,\n },\n },\n ] as const;\n}\n\nconst ProductOptionsContextState = createContext(\n initializeProductOptionsContext,\n);\n\nexport const provideProductOptionsContext = (\n initialState: Omit<CreateContextOptions, \"root\">,\n element: WalkableNode,\n): ProductOptionsContext => {\n const props = mergeProps(initialState, { root: element });\n return provide(ProductOptionsContextState, props, element);\n};\n\nexport const useProductOptionsContext = (context: ProductOptionsContext) => {\n return context;\n};\n\nexport const useProductOptions = (element: HTMLElement & ICustomElement) => {\n const context: ProductOptionsContext = consume(\n ProductOptionsContextState,\n element,\n );\n\n if (!context) {\n throw console.error(\n \"DrawerContext not found! Please ensure to wrap your custom element with drawer-context element.\",\n );\n }\n\n return useProductOptionsContext(context);\n};\n\nexport const getProductOptionsContext = (element: Element) => {\n const context = getContextFromProvider<ProductOptionsContext>(\n ProductOptionsContextState,\n element,\n );\n return useProductOptionsContext(context);\n};\n"]}
@@ -0,0 +1,57 @@
1
+ // Generated by dts-bundle-generator v9.5.1
2
+
3
+ import { ICustomElement } from 'component-register';
4
+
5
+ export type Variant = {
6
+ id: string | number;
7
+ options: string[];
8
+ };
9
+ export type Product = {
10
+ id: string | number;
11
+ variants: Variant[];
12
+ selected_or_first_available_variant: Variant;
13
+ };
14
+ export declare const useProduct: (element: HTMLElement & ICustomElement) => readonly [
15
+ {
16
+ product: Product;
17
+ },
18
+ {
19
+ readonly variant: {
20
+ readonly update: (variantId: string | number) => void;
21
+ };
22
+ }
23
+ ];
24
+ export declare const getProductContext: (element: Element) => readonly [
25
+ {
26
+ product: Product;
27
+ },
28
+ {
29
+ readonly variant: {
30
+ readonly update: (variantId: string | number) => void;
31
+ };
32
+ }
33
+ ];
34
+ export type CreateContextOptions = {
35
+ element: HTMLElement & ICustomElement;
36
+ selectedOptions: string[];
37
+ };
38
+ export declare const useProductOptions: (element: HTMLElement & ICustomElement) => readonly [
39
+ CreateContextOptions,
40
+ {
41
+ readonly options: {
42
+ readonly update: (options: string[]) => void;
43
+ readonly updateOption: (option: string, index: number) => void;
44
+ };
45
+ }
46
+ ];
47
+ export declare const getProductOptionsContext: (element: Element) => readonly [
48
+ CreateContextOptions,
49
+ {
50
+ readonly options: {
51
+ readonly update: (options: string[]) => void;
52
+ readonly updateOption: (option: string, index: number) => void;
53
+ };
54
+ }
55
+ ];
56
+
57
+ export {};
@@ -0,0 +1,42 @@
1
+ import { customShadowlessElement, correctElementType } from '@brytdesigns/web-component-utils';
2
+ import { ProductInfo, ProductOptions, ProductOptionGroup, ProductVariantInput, ProductVariantRender } from './components/index.js';
3
+ export { getProductContext, getProductOptionsContext, useProduct, useProductOptions } from './hooks/index.js';
4
+
5
+ customShadowlessElement(
6
+ "product-info",
7
+ {
8
+ product: void 0
9
+ },
10
+ correctElementType(ProductInfo)
11
+ );
12
+ customShadowlessElement(
13
+ "product-options",
14
+ {
15
+ selectedOptions: []
16
+ },
17
+ correctElementType(ProductOptions)
18
+ );
19
+ customShadowlessElement(
20
+ "product-option-group",
21
+ {
22
+ position: 0,
23
+ name: "",
24
+ inputType: "radio"
25
+ },
26
+ correctElementType(ProductOptionGroup)
27
+ );
28
+ customShadowlessElement(
29
+ "product-variant-input",
30
+ {
31
+ target: "",
32
+ preventDefault: true
33
+ },
34
+ correctElementType(ProductVariantInput)
35
+ );
36
+ customShadowlessElement(
37
+ "product-variant-render",
38
+ {},
39
+ correctElementType(ProductVariantRender)
40
+ );
41
+ //# sourceMappingURL=index.js.map
42
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/index.ts"],"names":[],"mappings":";;;;AAaA,uBAAA;AAAA,EACE,cAAA;AAAA,EACA;AAAA,IACE,OAAS,EAAA;AAAA,GACX;AAAA,EACA,mBAAmB,WAAW;AAChC,CAAA;AAEA,uBAAA;AAAA,EACE,iBAAA;AAAA,EACA;AAAA,IACE,iBAAiB;AAAC,GACpB;AAAA,EACA,mBAAmB,cAAc;AACnC,CAAA;AAEA,uBAAA;AAAA,EACE,sBAAA;AAAA,EACA;AAAA,IACE,QAAU,EAAA,CAAA;AAAA,IACV,IAAM,EAAA,EAAA;AAAA,IACN,SAAW,EAAA;AAAA,GACb;AAAA,EACA,mBAAmB,kBAAkB;AACvC,CAAA;AAEA,uBAAA;AAAA,EACE,uBAAA;AAAA,EACA;AAAA,IACE,MAAQ,EAAA,EAAA;AAAA,IACR,cAAgB,EAAA;AAAA,GAClB;AAAA,EACA,mBAAmB,mBAAmB;AACxC,CAAA;AAEA,uBAAA;AAAA,EACE,wBAAA;AAAA,EACA,EAAC;AAAA,EACD,mBAAmB,oBAAoB;AACzC,CAAA","file":"index.js","sourcesContent":["import {\n customShadowlessElement,\n correctElementType,\n} from \"@brytdesigns/web-component-utils\";\n\nimport {\n ProductInfo,\n ProductOptions,\n ProductOptionGroup,\n ProductVariantInput,\n ProductVariantRender,\n} from \"./components/index.js\";\n\ncustomShadowlessElement(\n \"product-info\",\n {\n product: undefined,\n },\n correctElementType(ProductInfo),\n);\n\ncustomShadowlessElement(\n \"product-options\",\n {\n selectedOptions: [],\n },\n correctElementType(ProductOptions),\n);\n\ncustomShadowlessElement(\n \"product-option-group\",\n {\n position: 0,\n name: \"\",\n inputType: \"radio\",\n },\n correctElementType(ProductOptionGroup),\n);\n\ncustomShadowlessElement(\n \"product-variant-input\",\n {\n target: \"\",\n preventDefault: true,\n },\n correctElementType(ProductVariantInput),\n);\n\ncustomShadowlessElement(\n \"product-variant-render\",\n {},\n correctElementType(ProductVariantRender),\n);\n\nexport {\n useProduct,\n useProductOptions,\n getProductContext,\n getProductOptionsContext,\n} from \"./hooks/index.js\";\n"]}
@@ -0,0 +1,3 @@
1
+
2
+ //# sourceMappingURL=types.js.map
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"types.js"}
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@brytdesigns/shopify-product-info-components",
3
+ "version": "1.0.0",
4
+ "description": "Headless web components used to render product information based on active product variants",
5
+ "main": "./dist/main/index.js",
6
+ "module": "./dist/main/index.js",
7
+ "types": "./dist/main/index.d.ts",
8
+ "type": "module",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/main/index.d.ts",
12
+ "module": "./dist/main/index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "keywords": [],
19
+ "author": "Bryt Designs",
20
+ "license": "ISC",
21
+ "dependencies": {
22
+ "component-register": "^0.8.7",
23
+ "solid-element": "^1.9.1",
24
+ "solid-js": "^1.9.5",
25
+ "@brytdesigns/web-component-utils": "0.1.8"
26
+ },
27
+ "devDependencies": {
28
+ "dts-bundle-generator": "^9.5.1",
29
+ "tsup": "^8.4.0"
30
+ },
31
+ "scripts": {
32
+ "build": "tsup --clean",
33
+ "typecheck": "tsc --noEmit"
34
+ }
35
+ }