@brytdesigns/shopify-ajax-cart-components 1.3.14 → 3.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.
- package/dist/main/components/cart-context.js +19 -15
- package/dist/main/components/cart-context.js.map +1 -1
- package/dist/main/components/cart-data-array-injection.js +70 -81
- package/dist/main/components/cart-data-array-injection.js.map +1 -1
- package/dist/main/components/cart-data-array-item.js +16 -17
- package/dist/main/components/cart-data-array-item.js.map +1 -1
- package/dist/main/components/cart-data-array.js +64 -55
- package/dist/main/components/cart-data-array.js.map +1 -1
- package/dist/main/components/cart-data-conditions.js +61 -100
- package/dist/main/components/cart-data-conditions.js.map +1 -1
- package/dist/main/components/cart-data-injection.js +78 -84
- package/dist/main/components/cart-data-injection.js.map +1 -1
- package/dist/main/components/cart-data-listener-status.js +32 -31
- package/dist/main/components/cart-data-listener-status.js.map +1 -1
- package/dist/main/components/cart-data-listener.js +98 -155
- package/dist/main/components/cart-data-listener.js.map +1 -1
- package/dist/main/components/cart-data.js +29 -25
- package/dist/main/components/cart-data.js.map +1 -1
- package/dist/main/components/cart-loading-state.js +51 -37
- package/dist/main/components/cart-loading-state.js.map +1 -1
- package/dist/main/components/index.js +10 -22
- package/dist/main/hooks/index.js +24 -25
- package/dist/main/hooks/index.js.map +1 -1
- package/dist/main/hooks/useAjaxCart.js +14 -18
- package/dist/main/hooks/useAjaxCart.js.map +1 -1
- package/dist/main/hooks/useListenerStatus.js +23 -28
- package/dist/main/hooks/useListenerStatus.js.map +1 -1
- package/dist/main/index.d.ts +5182 -4789
- package/dist/main/index.js +56 -82
- package/dist/main/index.js.map +1 -1
- package/dist/main/utils/formatValue.js +14 -18
- package/dist/main/utils/formatValue.js.map +1 -1
- package/dist/main/utils/getTargetElement.js +10 -9
- package/dist/main/utils/getTargetElement.js.map +1 -1
- package/dist/main/utils/getTemplateContent.js +6 -7
- package/dist/main/utils/getTemplateContent.js.map +1 -1
- package/dist/main/utils/getValueFromPath.js +9 -10
- package/dist/main/utils/getValueFromPath.js.map +1 -1
- package/dist/main/utils/parseNestedObject.js +48 -28
- package/dist/main/utils/parseNestedObject.js.map +1 -1
- package/dist/main/utils/safeInjection.js +120 -0
- package/dist/main/utils/safeInjection.js.map +1 -0
- package/dist/main/utils/traverseObject.js +13 -15
- package/dist/main/utils/traverseObject.js.map +1 -1
- package/package.json +9 -8
- package/dist/esm/index.js +0 -883
- package/dist/esm/index.js.map +0 -1
- package/dist/main/components/index.js.map +0 -1
- package/dist/main/utils/index.js +0 -8
- package/dist/main/utils/index.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"cart-data-conditions.js","names":["<For each={conditionTemplates} keyed={false}>\n\t\t\t{(tmpl, idx) => (\n\t\t\t\t<Show when={validateConditions(allConditions()[idx], data())}>\n\t\t\t\t\t{Array.from(\n\t\t\t\t\t\t(tmpl() as HTMLTemplateElement).content.cloneNode(true).childNodes,\n\t\t\t\t\t)}\n\t\t\t\t</Show>\n\t\t\t)}\n\t\t</For>","each={conditionTemplates}","keyed={false}","<Show when={validateConditions(allConditions()[idx], data())}>\n\t\t\t\t\t{Array.from(\n\t\t\t\t\t\t(tmpl() as HTMLTemplateElement).content.cloneNode(true).childNodes,\n\t\t\t\t\t)}\n\t\t\t\t</Show>"],"sources":["../../../src/components/cart-data-conditions.tsx"],"sourcesContent":["import type { CorrectComponentType } from \"@brytdesigns/web-component-core/utils\";\nimport { For, Show } from \"@solidjs/web\";\n\nimport { type Accessor, createMemo } from \"solid-js\";\n\nimport { useCartPath, useCartValue } from \"../hooks/index.js\";\nimport { type Format, formatValue, getValueFromPath } from \"../utils/index.js\";\n\nexport type Props = {};\n\ntype ConditionValue = {\n\ttype: \"primitive\" | \"property\";\n\tname?: string;\n\tvalue?: string | number | boolean | null;\n\tproperty_name?: string;\n};\n\ntype Condition = {\n\ttype:\n\t\t| \"typeof\"\n\t\t| \"includes\"\n\t\t| \"includes_property\"\n\t\t| \"equals\"\n\t\t| \"not_equals\"\n\t\t| \"starts_with\"\n\t\t| \"lt\"\n\t\t| \"lte\"\n\t\t| \"gt\"\n\t\t| \"gte\";\n\tformat?: Format;\n\tinvert?: boolean;\n\tvalueA: ConditionValue;\n\tvalueB: ConditionValue;\n};\n\nfunction getValue<T>(data: T, value: ConditionValue): any {\n\tif (typeof value === \"undefined\" || !data) return undefined;\n\n\tif (value.type === \"primitive\") {\n\t\treturn value.value;\n\t}\n\n\tif (value.type === \"property\" && value.name) {\n\t\t//@ts-expect-error\n\t\treturn getValueFromPath<T>(data, value.name);\n\t}\n\n\treturn null;\n}\n\nfunction invertResult(result: boolean, invert = false) {\n\tif (invert) return !result;\n\treturn result;\n}\n\nfunction validateConditions<T>(conditions: Condition[], data: T) {\n\tif (!data) return false;\n\tconst result = conditions.every((condition) => {\n\t\tlet valueA = getValue(data, condition.valueA),\n\t\t\tvalueB = getValue(data, condition.valueB),\n\t\t\tresult = false;\n\n\t\tif (typeof valueA === \"undefined\" && typeof valueB === \"undefined\")\n\t\t\treturn false;\n\n\t\tif (condition.type === \"typeof\") {\n\t\t\tresult = typeof valueA === valueB;\n\t\t}\n\n\t\tif (condition.type === \"includes\") {\n\t\t\tresult = formatValue(condition.format || \"\", valueA).includes(\n\t\t\t\tformatValue(condition.format || \"\", valueB),\n\t\t\t);\n\t\t}\n\n\t\tif (condition.type === \"includes_property\") {\n\t\t\tresult = valueA.some(\n\t\t\t\t(v: any) => v[condition.valueA?.property_name || \"\"] === valueB,\n\t\t\t);\n\t\t}\n\n\t\tif (condition.type === \"starts_with\") {\n\t\t\tresult = formatValue(\"string\", valueA).startsWith(\n\t\t\t\tformatValue(condition.format || \"\", valueB),\n\t\t\t);\n\t\t}\n\n\t\tif (condition.type === \"equals\") {\n\t\t\tresult =\n\t\t\t\tformatValue(condition.format || \"\", valueA) ===\n\t\t\t\tformatValue(condition.format || \"\", valueB);\n\t\t}\n\n\t\tif (condition.type === \"not_equals\") {\n\t\t\tresult =\n\t\t\t\tformatValue(condition.format || \"\", valueA) !==\n\t\t\t\tformatValue(condition.format || \"\", valueB);\n\t\t}\n\n\t\tif (condition.type === \"lt\") {\n\t\t\tresult =\n\t\t\t\tformatValue(condition.format || \"\", valueA) <\n\t\t\t\tformatValue(condition.format || \"\", valueB);\n\t\t}\n\n\t\tif (condition.type === \"lte\") {\n\t\t\tresult =\n\t\t\t\tformatValue(condition.format || \"\", valueA) <=\n\t\t\t\tformatValue(condition.format || \"\", valueB);\n\t\t}\n\n\t\tif (condition.type === \"gt\") {\n\t\t\tresult =\n\t\t\t\tformatValue(condition.format || \"\", valueA) >\n\t\t\t\tformatValue(condition.format || \"\", valueB);\n\t\t}\n\n\t\tif (condition.type === \"gte\") {\n\t\t\tresult =\n\t\t\t\tformatValue(condition.format || \"\", valueA) >=\n\t\t\t\tformatValue(condition.format || \"\", valueB);\n\t\t}\n\n\t\treturn invertResult(result, condition.invert);\n\t});\n\n\treturn result;\n}\n\nexport const Name = \"cart-data-conditions\";\n\nexport const Component: CorrectComponentType<Props> = (_, { element }) => {\n\tconst conditionTemplates = Array.from(element.children).filter(\n\t\t(child) => child.tagName === \"TEMPLATE\" && child.hasAttribute(\"conditions\"),\n\t);\n\tif (!conditionTemplates.length)\n\t\treturn console.error(\n\t\t\t`${Name}: no templates found with any conditions attribute!`,\n\t\t);\n\n\tconst allConditions = createMemo(() =>\n\t\tconditionTemplates.map((tmpl) => {\n\t\t\tconst conditions = tmpl.getAttribute(\"conditions\");\n\t\t\tif (!conditions)\n\t\t\t\tconsole.warn(`${Name}: conditions attribute is required!`);\n\n\t\t\ttry {\n\t\t\t\treturn JSON.parse(conditions!);\n\t\t\t} catch (e) {\n\t\t\t\treturn [];\n\t\t\t}\n\t\t}),\n\t);\n\n\tconst fullPath = useCartPath({ element });\n\tconst data = useCartValue({\n\t\tpath: fullPath,\n\t\telement,\n\t});\n\n\telement.replaceChildren(...[]);\n\n\treturn (\n\t\t// keyed={false} gives a stable numeric index, which is what pairs a\n\t\t// template with its condition set.\n\t\t<For each={conditionTemplates} keyed={false}>\n\t\t\t{(tmpl, idx) => (\n\t\t\t\t<Show when={validateConditions(allConditions()[idx], data())}>\n\t\t\t\t\t{Array.from(\n\t\t\t\t\t\t(tmpl() as HTMLTemplateElement).content.cloneNode(true).childNodes,\n\t\t\t\t\t)}\n\t\t\t\t</Show>\n\t\t\t)}\n\t\t</For>\n\t);\n};\n"],"mappings":";;;;;;AAmCA,SAAS,SAAY,MAAS,OAA4B;CACzD,IAAI,OAAO,UAAU,eAAe,CAAC,MAAM,OAAO,KAAA;CAElD,IAAI,MAAM,SAAS,aAClB,OAAO,MAAM;CAGd,IAAI,MAAM,SAAS,cAAc,MAAM,MAEtC,OAAO,iBAAoB,MAAM,MAAM,IAAI;CAG5C,OAAO;AACR;AAEA,SAAS,aAAa,QAAiB,SAAS,OAAO;CACtD,IAAI,QAAQ,OAAO,CAAC;CACpB,OAAO;AACR;AAEA,SAAS,mBAAsB,YAAyB,MAAS;CAChE,IAAI,CAAC,MAAM,OAAO;CAsElB,OArEe,WAAW,OAAO,cAAc;EAC9C,IAAI,SAAS,SAAS,MAAM,UAAU,MAAM,GAC3C,SAAS,SAAS,MAAM,UAAU,MAAM,GACxC,SAAS;EAEV,IAAI,OAAO,WAAW,eAAe,OAAO,WAAW,aACtD,OAAO;EAER,IAAI,UAAU,SAAS,UACtB,SAAS,OAAO,WAAW;EAG5B,IAAI,UAAU,SAAS,YACtB,SAAS,YAAY,UAAU,UAAU,IAAI,MAAM,CAAC,CAAC,SACpD,YAAY,UAAU,UAAU,IAAI,MAAM,CAC3C;EAGD,IAAI,UAAU,SAAS,qBACtB,SAAS,OAAO,MACd,MAAW,EAAE,UAAU,QAAQ,iBAAiB,QAAQ,MAC1D;EAGD,IAAI,UAAU,SAAS,eACtB,SAAS,YAAY,UAAU,MAAM,CAAC,CAAC,WACtC,YAAY,UAAU,UAAU,IAAI,MAAM,CAC3C;EAGD,IAAI,UAAU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
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
target.setAttribute(attributeName, tmpValue);
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
)
|
|
82
|
-
);
|
|
1
|
+
import { getTargetElement } from "../utils/getTargetElement.js";
|
|
2
|
+
import { injectionRefusal, styleInjectionRefusal } from "../utils/safeInjection.js";
|
|
3
|
+
import { useCartFormattedValue, useCartPath } from "../hooks/index.js";
|
|
4
|
+
import { createGuardedEffect } from "@brytdesigns/web-component-core/utils";
|
|
5
|
+
import { untrack } from "solid-js";
|
|
6
|
+
//#region src/components/cart-data-injection.ts
|
|
7
|
+
var VALID_INJECTION_TYPES = [
|
|
8
|
+
"attribute",
|
|
9
|
+
"property",
|
|
10
|
+
"template"
|
|
11
|
+
];
|
|
12
|
+
var Name = "cart-data-injection";
|
|
13
|
+
var Component = (props, { element }) => {
|
|
14
|
+
if (untrack(() => !props.propertyName)) return console.warn(`${Name}: No path attribute provided.`);
|
|
15
|
+
if (untrack(() => !props.target)) return console.warn(`${Name}: No target attribute found!`);
|
|
16
|
+
if (untrack(() => !props.attributeName)) return console.warn(`${Name}: No attribute-name attribute found!`);
|
|
17
|
+
if (!props.injectionType || props.injectionType && !VALID_INJECTION_TYPES.includes(props.injectionType)) return console.warn(`${Name}: Invalid injection-type attribute provided.`);
|
|
18
|
+
const fullPath = useCartPath({
|
|
19
|
+
element,
|
|
20
|
+
path: () => props.propertyName
|
|
21
|
+
});
|
|
22
|
+
const value = useCartFormattedValue({
|
|
23
|
+
element,
|
|
24
|
+
path: fullPath,
|
|
25
|
+
get format() {
|
|
26
|
+
return props.format;
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
createGuardedEffect(() => {
|
|
30
|
+
return {
|
|
31
|
+
target: getTargetElement(element, props.target),
|
|
32
|
+
value: value(),
|
|
33
|
+
attributeName: props.attributeName,
|
|
34
|
+
injectionType: props.injectionType,
|
|
35
|
+
propertyName: props.propertyName
|
|
36
|
+
};
|
|
37
|
+
}, ({ target, value, attributeName, injectionType, propertyName }) => {
|
|
38
|
+
if (!target) return console.warn(`${Name}: Unable to find element with selector of: ${props.target}`);
|
|
39
|
+
if (injectionType === "attribute" && value !== null && value !== void 0) {
|
|
40
|
+
const refusal = injectionRefusal(attributeName, `${value}`);
|
|
41
|
+
if (refusal) return console.warn(`${Name}: ${refusal}`);
|
|
42
|
+
target.setAttribute(attributeName, `${value}`);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
if (injectionType === "property" && value !== null && value !== void 0) {
|
|
46
|
+
const refusal = injectionRefusal(attributeName, `${value}`);
|
|
47
|
+
if (refusal) return console.warn(`${Name}: ${refusal}`);
|
|
48
|
+
target[attributeName] = value;
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
if (injectionType === "template" && value !== null && value !== void 0) {
|
|
52
|
+
const substitute = (template) => template.replace(`{${propertyName}}`, () => `${value}`);
|
|
53
|
+
if (attributeName === "style") {
|
|
54
|
+
const styleRefusal = styleInjectionRefusal(`${value}`);
|
|
55
|
+
if (styleRefusal) return console.warn(`${Name}: ${styleRefusal}`);
|
|
56
|
+
const styleTmpl = target[attributeName].cssText;
|
|
57
|
+
setTimeout(() => {
|
|
58
|
+
target[attributeName].cssText = substitute(styleTmpl);
|
|
59
|
+
});
|
|
60
|
+
return () => {
|
|
61
|
+
target[attributeName].cssText = styleTmpl;
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
const tmpValue = target.getAttribute(attributeName);
|
|
65
|
+
if (!tmpValue || !value) return console.warn(`${Name}: Unable to inject value into template`);
|
|
66
|
+
const composed = substitute(tmpValue);
|
|
67
|
+
const refusal = injectionRefusal(attributeName, composed);
|
|
68
|
+
if (refusal) return console.warn(`${Name}: ${refusal}`);
|
|
69
|
+
setTimeout(() => {
|
|
70
|
+
target.setAttribute(attributeName, composed);
|
|
71
|
+
});
|
|
72
|
+
return () => {
|
|
73
|
+
target.setAttribute(attributeName, tmpValue);
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
});
|
|
83
77
|
};
|
|
84
|
-
|
|
78
|
+
//#endregion
|
|
85
79
|
export { Component, Name };
|
|
86
|
-
|
|
80
|
+
|
|
87
81
|
//# sourceMappingURL=cart-data-injection.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"cart-data-injection.js","names":[],"sources":["../../../src/components/cart-data-injection.ts"],"sourcesContent":["import type { CorrectComponentType } from \"@brytdesigns/web-component-core/utils\";\nimport { createGuardedEffect } from \"@brytdesigns/web-component-core/utils\";\nimport { untrack } from \"solid-js\";\nimport {\n\ttype CartPath,\n\tuseCartFormattedValue,\n\tuseCartPath,\n} from \"../hooks/index.js\";\nimport {\n\ttype Format,\n\tgetTargetElement,\n\tinjectionRefusal,\n\tstyleInjectionRefusal,\n} from \"../utils/index.js\";\n\nexport type Props = {\n\tpropertyName: CartPath;\n\tformat?: Format;\n\ttarget: string;\n\tattributeName: string;\n\tinjectionType: \"attribute\" | \"property\" | \"template\";\n};\n\nconst VALID_INJECTION_TYPES = [\"attribute\", \"property\", \"template\"];\n\nexport const Name = \"cart-data-injection\";\n\nexport const Component: CorrectComponentType<Props> = (props, { element }) => {\n\tif (untrack(() => !props.propertyName))\n\t\treturn console.warn(`${Name}: No path attribute provided.`);\n\tif (untrack(() => !props.target))\n\t\treturn console.warn(`${Name}: No target attribute found!`);\n\tif (untrack(() => !props.attributeName))\n\t\treturn console.warn(`${Name}: No attribute-name attribute found!`);\n\n\tif (\n\t\t!props.injectionType ||\n\t\t(props.injectionType &&\n\t\t\t!VALID_INJECTION_TYPES.includes(props.injectionType))\n\t)\n\t\treturn console.warn(`${Name}: Invalid injection-type attribute provided.`);\n\n\tconst mergedProps = {\n\t\telement,\n\t\tpath: () => props.propertyName,\n\t};\n\tconst fullPath = useCartPath(mergedProps);\n\tconst value = useCartFormattedValue({\n\t\telement,\n\t\tpath: fullPath,\n\t\tget format() {\n\t\t\treturn props.format;\n\t\t},\n\t});\n\n\tcreateGuardedEffect(\n\t\t() => {\n\t\t\treturn {\n\t\t\t\ttarget: getTargetElement(element, props.target),\n\t\t\t\tvalue: value(),\n\t\t\t\tattributeName: props.attributeName,\n\t\t\t\tinjectionType: props.injectionType,\n\t\t\t\tpropertyName: props.propertyName,\n\t\t\t};\n\t\t},\n\t\t({ target, value, attributeName, injectionType, propertyName }) => {\n\t\t\tif (!target)\n\t\t\t\treturn console.warn(\n\t\t\t\t\t`${Name}: Unable to find element with selector of: ${props.target}`,\n\t\t\t\t);\n\n\t\t\tif (\n\t\t\t\tinjectionType === \"attribute\" &&\n\t\t\t\tvalue !== null &&\n\t\t\t\tvalue !== undefined\n\t\t\t) {\n\t\t\t\tconst refusal = injectionRefusal(attributeName, `${value}`);\n\t\t\t\tif (refusal) return console.warn(`${Name}: ${refusal}`);\n\t\t\t\ttarget.setAttribute(attributeName, `${value}`);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\tinjectionType === \"property\" &&\n\t\t\t\tvalue !== null &&\n\t\t\t\tvalue !== undefined\n\t\t\t) {\n\t\t\t\tconst refusal = injectionRefusal(attributeName, `${value}`);\n\t\t\t\tif (refusal) return console.warn(`${Name}: ${refusal}`);\n\t\t\t\t//@ts-expect-error\n\t\t\t\ttarget[attributeName] = value;\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\tinjectionType === \"template\" &&\n\t\t\t\tvalue !== null &&\n\t\t\t\tvalue !== undefined\n\t\t\t) {\n\t\t\t\t// A function replacement, not a string one. `String.prototype\n\t\t\t\t// .replace` expands `$&`, `` $` ``, `$'` and `$1` in a *string*\n\t\t\t\t// replacement, and the replacement here is the shopper-supplied\n\t\t\t\t// cart value — so a note containing `` $` `` rewrites the parts of\n\t\t\t\t// the template it was supposed to be substituted into. This is the\n\t\t\t\t// same expansion that `ajax-client` escapes around `:handle`.\n\t\t\t\tconst substitute = (template: string) =>\n\t\t\t\t\ttemplate.replace(`{${propertyName}}`, () => `${value}`);\n\n\t\t\t\tif (attributeName === \"style\") {\n\t\t\t\t\t// Checked against the VALUE, not the composed stylesheet: the\n\t\t\t\t\t// author's own template legitimately contains the `;` and `{}`\n\t\t\t\t\t// that would otherwise read as a breakout. What must not get\n\t\t\t\t\t// through is a cart value that ends the declaration it was\n\t\t\t\t\t// substituted into and starts another.\n\t\t\t\t\tconst styleRefusal = styleInjectionRefusal(`${value}`);\n\t\t\t\t\tif (styleRefusal) return console.warn(`${Name}: ${styleRefusal}`);\n\n\t\t\t\t\t//@ts-expect-error\n\t\t\t\t\tconst styleTmpl = target[attributeName].cssText;\n\t\t\t\t\tsetTimeout(() => {\n\t\t\t\t\t\t//@ts-expect-error\n\t\t\t\t\t\ttarget[attributeName].cssText = substitute(styleTmpl);\n\t\t\t\t\t});\n\t\t\t\t\treturn () => {\n\t\t\t\t\t\t//@ts-expect-error\n\t\t\t\t\t\ttarget[attributeName].cssText = styleTmpl;\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tconst tmpValue = target.getAttribute(attributeName);\n\t\t\t\tif (!tmpValue || !value)\n\t\t\t\t\treturn console.warn(`${Name}: Unable to inject value into template`);\n\n\t\t\t\t// Checked against the substituted result rather than the raw value:\n\t\t\t\t// a template of `javascript:{note}` is unsafe however benign the\n\t\t\t\t// value is, and only the composed string shows that.\n\t\t\t\tconst composed = substitute(tmpValue);\n\t\t\t\tconst refusal = injectionRefusal(attributeName, composed);\n\t\t\t\tif (refusal) return console.warn(`${Name}: ${refusal}`);\n\n\t\t\t\tsetTimeout(() => {\n\t\t\t\t\ttarget.setAttribute(attributeName, composed);\n\t\t\t\t});\n\t\t\t\treturn () => {\n\t\t\t\t\ttarget.setAttribute(attributeName, tmpValue);\n\t\t\t\t};\n\t\t\t}\n\t\t},\n\t);\n};\n"],"mappings":";;;;;;AAuBA,IAAM,wBAAwB;CAAC;CAAa;CA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/getTemplateContent.js";
|
|
2
|
+
import { useListenerStatus } from "../hooks/useListenerStatus.js";
|
|
3
|
+
import "../hooks/index.js";
|
|
4
|
+
import { createMemo } from "solid-js";
|
|
5
|
+
//#region src/components/cart-data-listener-status.ts
|
|
6
|
+
var Name = "cart-data-listener-status";
|
|
7
|
+
var Component = (_, { element }) => {
|
|
8
|
+
const [status] = useListenerStatus(element);
|
|
9
|
+
if (!status) return console.error(`${Name}: no listener context provided!`);
|
|
10
|
+
const templates = {
|
|
11
|
+
default: getTemplateContent(element, "default"),
|
|
12
|
+
loading: getTemplateContent(element, "loading"),
|
|
13
|
+
success: getTemplateContent(element, "success"),
|
|
14
|
+
error: getTemplateContent(element, "error")
|
|
15
|
+
};
|
|
16
|
+
let previousState = null;
|
|
17
|
+
const currentStatus = () => {
|
|
18
|
+
const s = status();
|
|
19
|
+
if (!templates[s]) return previousState;
|
|
20
|
+
previousState = s;
|
|
21
|
+
return s;
|
|
22
|
+
};
|
|
23
|
+
element.replaceChildren(...[]);
|
|
24
|
+
return createMemo(() => {
|
|
25
|
+
const state = currentStatus();
|
|
26
|
+
if (!state) return null;
|
|
27
|
+
const template = templates[state];
|
|
28
|
+
if (!template) return null;
|
|
29
|
+
return Array.from(template.cloneNode(true).childNodes);
|
|
30
|
+
});
|
|
30
31
|
};
|
|
31
|
-
|
|
32
|
+
//#endregion
|
|
32
33
|
export { Component, Name };
|
|
33
|
-
|
|
34
|
+
|
|
34
35
|
//# sourceMappingURL=cart-data-listener-status.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"cart-data-listener-status.js","names":[],"sources":["../../../src/components/cart-data-listener-status.ts"],"sourcesContent":["import type { CorrectComponentType } from \"@brytdesigns/web-component-core/utils\";\n\nimport { createMemo } from \"solid-js\";\n\nimport { type Status, useListenerStatus } from \"../hooks/index.js\";\nimport { getTemplateContent } from \"../utils/index.js\";\n\nexport const Name = \"cart-data-listener-status\";\n\nexport const Component: CorrectComponentType<{}> = (_, { element }) => {\n\tconst [status] = useListenerStatus(element);\n\tif (!status) return console.error(`${Name}: no listener context provided!`);\n\n\tconst templates = {\n\t\tdefault: getTemplateContent(element, \"default\"),\n\t\tloading: getTemplateContent(element, \"loading\"),\n\t\tsuccess: getTemplateContent(element, \"success\"),\n\t\terror: getTemplateContent(element, \"error\"),\n\t};\n\n\tlet previousState: Status | null = null;\n\n\tconst currentStatus = () => {\n\t\tconst s = status() as Status;\n\t\tif (!templates[s]) return previousState;\n\t\tpreviousState = s;\n\t\treturn s;\n\t};\n\n\telement.replaceChildren(...[]);\n\n\treturn createMemo(() => {\n\t\tconst state = currentStatus();\n\t\tif (!state) return null;\n\t\tconst template = templates[state];\n\t\tif (!template) return null;\n\t\treturn Array.from(template.cloneNode(true).childNodes);\n\t});\n};\n"],"mappings":";;;;;AAOA,IAAa,OAAO;AAEpB,IAAa,aAAuC,GAAG,EAAE,cAAc;CACtE,MAAM,CAAC,UAAU,kBAAkB,OAAO;CAC1C,IAAI,CAAC,QAAQ,OAAO,QAAQ,MAAM,GAAG,KAAK,gCAAgC;CAE1E,MAAM,YAAY;EACjB,SAAS,mBAAmB,SAAS,SAAS;EAC9C,SAAS,mBAAmB,SAAS,SAAS;EAC9C,SAAS,mBAAmB,SAAS,SAAS;EAC9C,OAAO,mBAAmB,SAAS,OAAO;CAC3C;CAEA,IAAI,gBAA+B;CAEnC,MAAM,sBAAsB;EAC3B,MAAM,IAAI,OAAO;EACjB,IAAI,CAAC,UAAU,IAAI,OAAO;EAC1B,gBAAgB;EAChB,OAAO;CACR;CAEA,QAAQ,gBAAgB,GAAG,CAAC,CAAC;CAE7B,OAAO,iBAAiB;EACvB,MAAM,QAAQ,cAAc;EAC5B,IAAI,CAAC,OAAO,OAAO;EACnB,MAAM,WAAW,UAAU;EAC3B,IAAI,CAAC,UAAU,OAAO;EACtB,OAAO,MAAM,KAAK,SAAS,UAAU,IAAI,CAAC,CAAC,UAAU;CACtD,CAAC;AACF"}
|
|
@@ -1,158 +1,101 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
return handleStatus(cart.removeItem(formObj.key)).finally(reset2);
|
|
98
|
-
}
|
|
99
|
-
if (method === "addDiscount") {
|
|
100
|
-
return handleStatus(cart.addDiscount(formObj.code)).finally(
|
|
101
|
-
reset2
|
|
102
|
-
);
|
|
103
|
-
}
|
|
104
|
-
if (method === "removeDiscount") {
|
|
105
|
-
return handleStatus(cart.removeDiscount(formObj.code)).finally(
|
|
106
|
-
reset2
|
|
107
|
-
);
|
|
108
|
-
}
|
|
109
|
-
if (method === "updateNote") {
|
|
110
|
-
return handleStatus(cart.updateNote(formObj.note)).finally(reset2);
|
|
111
|
-
}
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
const input = e.target;
|
|
115
|
-
if (method === "removeItem") {
|
|
116
|
-
return handleStatus(cart.removeItem(data2.key));
|
|
117
|
-
}
|
|
118
|
-
if (method === "updateQuantity") {
|
|
119
|
-
return handleStatus(
|
|
120
|
-
cart.updateItem({
|
|
121
|
-
id: data2.key,
|
|
122
|
-
quantity: input.valueAsNumber
|
|
123
|
-
})
|
|
124
|
-
);
|
|
125
|
-
}
|
|
126
|
-
if (method === "updateItemVariant") {
|
|
127
|
-
return handleStatus(
|
|
128
|
-
cart.replaceItem({
|
|
129
|
-
key: data2.key,
|
|
130
|
-
id: input.value
|
|
131
|
-
})
|
|
132
|
-
);
|
|
133
|
-
}
|
|
134
|
-
if (method === "updateNote") {
|
|
135
|
-
return handleStatus(cart.updateNote(input.value));
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
const handleEvent = debounce(onEvent, debounceDelay), controller = new AbortController();
|
|
139
|
-
element.addEventListener(
|
|
140
|
-
on2,
|
|
141
|
-
(e) => {
|
|
142
|
-
if (preventDefault) e.preventDefault();
|
|
143
|
-
handleEvent(e);
|
|
144
|
-
},
|
|
145
|
-
{ signal: controller.signal }
|
|
146
|
-
);
|
|
147
|
-
return onCleanup(() => {
|
|
148
|
-
controller.abort();
|
|
149
|
-
if (resetStatusId) clearTimeout(resetStatusId);
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
)
|
|
153
|
-
);
|
|
1
|
+
import { parseNestedObject } from "../utils/parseNestedObject.js";
|
|
2
|
+
import { provideListenerStatusContext } from "../hooks/useListenerStatus.js";
|
|
3
|
+
import { useCartPath, useCartValue } from "../hooks/index.js";
|
|
4
|
+
import { createGuardedEffect } from "@brytdesigns/web-component-core/utils";
|
|
5
|
+
import AjaxCart from "@brytdesigns/shopify-ajax-cart";
|
|
6
|
+
import debounce from "lodash.debounce";
|
|
7
|
+
//#region src/components/cart-data-listener.ts
|
|
8
|
+
var Name = "cart-data-listener";
|
|
9
|
+
var Component = (props, { element }) => {
|
|
10
|
+
const [_, setStatus] = provideListenerStatusContext({
|
|
11
|
+
element,
|
|
12
|
+
get status() {
|
|
13
|
+
return props.status;
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
const path = useCartPath({ element });
|
|
17
|
+
const data = useCartValue({
|
|
18
|
+
element,
|
|
19
|
+
path
|
|
20
|
+
});
|
|
21
|
+
createGuardedEffect(() => ({
|
|
22
|
+
method: props.method,
|
|
23
|
+
on: props.on,
|
|
24
|
+
preventDefault: props.preventDefault,
|
|
25
|
+
data: data(),
|
|
26
|
+
debounceDelay: props.debounceDelay,
|
|
27
|
+
resetForm: props.resetForm,
|
|
28
|
+
resetStatusDelay: props.resetStatusDelay
|
|
29
|
+
}), ({ method, on, preventDefault, data, debounceDelay, resetForm, resetStatusDelay }) => {
|
|
30
|
+
if (!method) return console.error(`${Name}: method property is required!`);
|
|
31
|
+
if (!on) return console.error(`${Name}: on property is required!`);
|
|
32
|
+
let resetStatusId = null;
|
|
33
|
+
function onEvent(e) {
|
|
34
|
+
const cart = AjaxCart;
|
|
35
|
+
if (preventDefault) e.preventDefault();
|
|
36
|
+
async function handleStatus(promise) {
|
|
37
|
+
setStatus("loading");
|
|
38
|
+
return promise.then((data) => {
|
|
39
|
+
setStatus("success");
|
|
40
|
+
return data;
|
|
41
|
+
}).catch((error) => {
|
|
42
|
+
setStatus("error");
|
|
43
|
+
return error;
|
|
44
|
+
}).finally(() => {
|
|
45
|
+
if (resetStatusDelay > 0) resetStatusId = setTimeout(() => {
|
|
46
|
+
setStatus("default");
|
|
47
|
+
resetStatusId = null;
|
|
48
|
+
}, resetStatusDelay);
|
|
49
|
+
else setStatus("default");
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
if (on === "submit") {
|
|
53
|
+
const form = e.target;
|
|
54
|
+
const formData = new FormData(form);
|
|
55
|
+
const formObj = parseNestedObject(Object.fromEntries(formData.entries()));
|
|
56
|
+
function reset() {
|
|
57
|
+
if (resetForm) form.reset();
|
|
58
|
+
}
|
|
59
|
+
if (method === "replaceItem") return handleStatus(cart.replaceItem({
|
|
60
|
+
key: formObj.key,
|
|
61
|
+
id: formObj.id
|
|
62
|
+
})).finally(reset);
|
|
63
|
+
if (method === "updateItem") return handleStatus(cart.updateItem({
|
|
64
|
+
id: formObj.id,
|
|
65
|
+
quantity: formObj?.quantity || void 0,
|
|
66
|
+
properties: formObj?.properties || {},
|
|
67
|
+
selling_plan: formObj?.selling_plan || void 0
|
|
68
|
+
})).finally(reset);
|
|
69
|
+
if (method === "removeItem") return handleStatus(cart.removeItem(formObj.key)).finally(reset);
|
|
70
|
+
if (method === "addDiscount") return handleStatus(cart.addDiscount(formObj.code)).finally(reset);
|
|
71
|
+
if (method === "removeDiscount") return handleStatus(cart.removeDiscount(formObj.code)).finally(reset);
|
|
72
|
+
if (method === "updateNote") return handleStatus(cart.updateNote(formObj.note)).finally(reset);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const input = e.target;
|
|
76
|
+
if (method === "removeItem") return handleStatus(cart.removeItem(data.key));
|
|
77
|
+
if (method === "updateQuantity") return handleStatus(cart.updateItem({
|
|
78
|
+
id: data.key,
|
|
79
|
+
quantity: input.valueAsNumber
|
|
80
|
+
}));
|
|
81
|
+
if (method === "updateItemVariant") return handleStatus(cart.replaceItem({
|
|
82
|
+
key: data.key,
|
|
83
|
+
id: input.value
|
|
84
|
+
}));
|
|
85
|
+
if (method === "updateNote") return handleStatus(cart.updateNote(input.value));
|
|
86
|
+
}
|
|
87
|
+
const handleEvent = debounce(onEvent, debounceDelay), controller = new AbortController();
|
|
88
|
+
element.addEventListener(on, (e) => {
|
|
89
|
+
if (preventDefault) e.preventDefault();
|
|
90
|
+
handleEvent(e);
|
|
91
|
+
}, { signal: controller.signal });
|
|
92
|
+
return () => {
|
|
93
|
+
controller.abort();
|
|
94
|
+
if (resetStatusId) clearTimeout(resetStatusId);
|
|
95
|
+
};
|
|
96
|
+
});
|
|
154
97
|
};
|
|
155
|
-
|
|
98
|
+
//#endregion
|
|
156
99
|
export { Component, Name };
|
|
157
|
-
|
|
100
|
+
|
|
158
101
|
//# sourceMappingURL=cart-data-listener.js.map
|