@brytdesigns/shopify-ajax-cart-components 1.2.19 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/index.js +48 -93
- package/dist/esm/index.js.map +1 -1
- package/dist/main/components/cart-context.js +7 -17
- package/dist/main/components/cart-context.js.map +1 -1
- package/dist/main/components/cart-data-array-injection.js +5 -6
- package/dist/main/components/cart-data-array-injection.js.map +1 -1
- package/dist/main/components/cart-data-array-item.js +3 -3
- package/dist/main/components/cart-data-array-item.js.map +1 -1
- package/dist/main/components/cart-data-array.js +3 -3
- package/dist/main/components/cart-data-array.js.map +1 -1
- package/dist/main/components/cart-data-conditions.js +2 -2
- package/dist/main/components/cart-data-conditions.js.map +1 -1
- package/dist/main/components/cart-data-injection.js +6 -6
- package/dist/main/components/cart-data-injection.js.map +1 -1
- package/dist/main/components/cart-data-listener.js +2 -2
- package/dist/main/components/cart-data-listener.js.map +1 -1
- package/dist/main/components/cart-data.js +3 -3
- package/dist/main/components/cart-data.js.map +1 -1
- package/dist/main/hooks/index.js +25 -3
- package/dist/main/hooks/index.js.map +1 -1
- package/dist/main/hooks/useAjaxCart.js.map +1 -1
- package/dist/main/index.d.ts +1336 -9670
- package/package.json +4 -4
- package/dist/main/hooks/useCartValue.js +0 -23
- package/dist/main/hooks/useCartValue.js.map +0 -1
- package/dist/main/hooks/useFormattedValue.js +0 -27
- package/dist/main/hooks/useFormattedValue.js.map +0 -1
- package/dist/main/hooks/useFullPropertyPath.js +0 -35
- package/dist/main/hooks/useFullPropertyPath.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brytdesigns/shopify-ajax-cart-components",
|
|
3
|
-
"version": "1.2
|
|
3
|
+
"version": "1.3.2",
|
|
4
4
|
"description": "Headless web components for the Ajax Cart Library",
|
|
5
5
|
"main": "./dist/main/index.js",
|
|
6
6
|
"types": "./dist/main/index.d.ts",
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"component-register": "^0.8.7",
|
|
20
20
|
"lodash.debounce": "^4.0.8",
|
|
21
|
-
"solid-js": "^1.9.
|
|
22
|
-
"@brytdesigns/shopify-ajax-cart": "1.
|
|
23
|
-
"@brytdesigns/web-component-core": "1.1.
|
|
21
|
+
"solid-js": "^1.9.9",
|
|
22
|
+
"@brytdesigns/shopify-ajax-cart": "1.1.1",
|
|
23
|
+
"@brytdesigns/web-component-core": "1.1.4"
|
|
24
24
|
},
|
|
25
25
|
"author": "Bryt Designs",
|
|
26
26
|
"license": "ISC",
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { createMemo } from 'solid-js';
|
|
2
|
-
import 'component-register';
|
|
3
|
-
import './useFullPropertyPath.js';
|
|
4
|
-
import { useAjaxCart } from './useAjaxCart.js';
|
|
5
|
-
import { getValueFromPath } from '../utils/index.js';
|
|
6
|
-
|
|
7
|
-
function useCartValue(options) {
|
|
8
|
-
const cart = useAjaxCart(options.element);
|
|
9
|
-
const value = createMemo(() => {
|
|
10
|
-
const c = cart();
|
|
11
|
-
if (typeof options.path !== "function") return c;
|
|
12
|
-
const path = options.path();
|
|
13
|
-
if (!path) return c;
|
|
14
|
-
const v = getValueFromPath(c, path);
|
|
15
|
-
if (v === void 0 || v === null) return null;
|
|
16
|
-
return v;
|
|
17
|
-
});
|
|
18
|
-
return value;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export { useCartValue };
|
|
22
|
-
//# sourceMappingURL=useCartValue.js.map
|
|
23
|
-
//# sourceMappingURL=useCartValue.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/hooks/useCartValue.ts"],"names":[],"mappings":";;;;;;AAYO,SAAS,aAAa,OAAkB,EAAA;AAC7C,EAAM,MAAA,IAAA,GAAO,WAAY,CAAA,OAAA,CAAQ,OAAO,CAAA;AAExC,EAAM,MAAA,KAAA,GAAQ,WAAW,MAAM;AAC7B,IAAA,MAAM,IAAI,IAAK,EAAA;AACf,IAAA,IAAI,OAAO,OAAA,CAAQ,IAAS,KAAA,UAAA,EAAmB,OAAA,CAAA;AAC/C,IAAM,MAAA,IAAA,GAAO,QAAQ,IAAK,EAAA;AAC1B,IAAI,IAAA,CAAC,MAAa,OAAA,CAAA;AAClB,IAAM,MAAA,CAAA,GAAI,gBAAiB,CAAA,CAAA,EAAG,IAAI,CAAA;AAClC,IAAA,IAAI,CAAM,KAAA,MAAA,IAAa,CAAM,KAAA,IAAA,EAAa,OAAA,IAAA;AAC1C,IAAO,OAAA,CAAA;AAAA,GACR,CAAA;AAED,EAAO,OAAA,KAAA;AACT","file":"useCartValue.js","sourcesContent":["import { type Accessor, createMemo } from \"solid-js\";\nimport { type ICustomElement } from \"component-register\";\n\nimport { type ValidAjaxPath } from \"./useFullPropertyPath.js\";\nimport { useAjaxCart } from \"./useAjaxCart.js\";\nimport { getValueFromPath } from \"../utils/index.js\";\n\ntype Options = {\n path: Accessor<ValidAjaxPath>;\n element: HTMLElement & ICustomElement;\n};\n\nexport function useCartValue(options: Options) {\n const cart = useAjaxCart(options.element);\n\n const value = createMemo(() => {\n const c = cart();\n if (typeof options.path !== \"function\") return c;\n const path = options.path();\n if (!path) return c;\n const v = getValueFromPath(c, path);\n if (v === undefined || v === null) return null;\n return v;\n });\n\n return value;\n}\n"]}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { createMemo } from 'solid-js';
|
|
2
|
-
import 'component-register';
|
|
3
|
-
import './useFullPropertyPath.js';
|
|
4
|
-
import { formatValue } from '../utils/index.js';
|
|
5
|
-
import { useCartValue } from './useCartValue.js';
|
|
6
|
-
|
|
7
|
-
function useFormattedValue(options) {
|
|
8
|
-
const value = useCartValue({ path: options.path, element: options.element });
|
|
9
|
-
const formattedValue = createMemo(() => {
|
|
10
|
-
const v = value();
|
|
11
|
-
if (v === null) return null;
|
|
12
|
-
if (typeof v === "string" || typeof v === "number" || typeof v === "boolean") {
|
|
13
|
-
return formatValue(options.format || "", v);
|
|
14
|
-
}
|
|
15
|
-
console.warn(
|
|
16
|
-
options.element,
|
|
17
|
-
`useFormattedValue: Unsupported value type. Expected string, number, or boolean. Received: ${typeof v}.`,
|
|
18
|
-
v
|
|
19
|
-
);
|
|
20
|
-
return null;
|
|
21
|
-
});
|
|
22
|
-
return formattedValue;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export { useFormattedValue };
|
|
26
|
-
//# sourceMappingURL=useFormattedValue.js.map
|
|
27
|
-
//# sourceMappingURL=useFormattedValue.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/hooks/useFormattedValue.ts"],"names":[],"mappings":";;;;;;AAaO,SAAS,kBAAkB,OAAkB,EAAA;AAClD,EAAM,MAAA,KAAA,GAAQ,aAAa,EAAE,IAAA,EAAM,QAAQ,IAAM,EAAA,OAAA,EAAS,OAAQ,CAAA,OAAA,EAAS,CAAA;AAE3E,EAAM,MAAA,cAAA,GAAiB,WAAW,MAAM;AACtC,IAAA,MAAM,IAAI,KAAM,EAAA;AAChB,IAAI,IAAA,CAAA,KAAM,MAAa,OAAA,IAAA;AACvB,IACE,IAAA,OAAO,MAAM,QACb,IAAA,OAAO,MAAM,QACb,IAAA,OAAO,MAAM,SACb,EAAA;AACA,MAAA,OAAO,WAAY,CAAA,OAAA,CAAQ,MAAU,IAAA,EAAA,EAAI,CAAC,CAAA;AAAA;AAE5C,IAAQ,OAAA,CAAA,IAAA;AAAA,MACN,OAAQ,CAAA,OAAA;AAAA,MACR,CAAA,0FAAA,EAA6F,OAAO,CAAC,CAAA,CAAA,CAAA;AAAA,MACrG;AAAA,KACF;AACA,IAAO,OAAA,IAAA;AAAA,GACR,CAAA;AAED,EAAO,OAAA,cAAA;AACT","file":"useFormattedValue.js","sourcesContent":["import { type Accessor, createMemo } from \"solid-js\";\nimport { type ICustomElement } from \"component-register\";\n\nimport { type ValidAjaxPath } from \"./useFullPropertyPath.js\";\nimport { formatValue, type Format } from \"../utils/index.js\";\nimport { useCartValue } from \"./useCartValue.js\";\n\ntype Options = {\n path: Accessor<ValidAjaxPath>;\n format?: Format;\n element: HTMLElement & ICustomElement;\n};\n\nexport function useFormattedValue(options: Options) {\n const value = useCartValue({ path: options.path, element: options.element });\n\n const formattedValue = createMemo(() => {\n const v = value();\n if (v === null) return null;\n if (\n typeof v === \"string\" ||\n typeof v === \"number\" ||\n typeof v === \"boolean\"\n ) {\n return formatValue(options.format || \"\", v);\n }\n console.warn(\n options.element,\n `useFormattedValue: Unsupported value type. Expected string, number, or boolean. Received: ${typeof v}.`,\n v,\n );\n return null;\n });\n\n return formattedValue;\n}\n"]}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import '@brytdesigns/shopify-ajax-cart';
|
|
2
|
-
import { createMemo } from 'solid-js';
|
|
3
|
-
import { createContext, provide, consume } from 'component-register';
|
|
4
|
-
|
|
5
|
-
function createFullPathPropertyContext(options) {
|
|
6
|
-
return options.path;
|
|
7
|
-
}
|
|
8
|
-
const FullPropertyPathContext = createContext(createFullPathPropertyContext);
|
|
9
|
-
function provideFullPropertyPathContext({
|
|
10
|
-
element,
|
|
11
|
-
path
|
|
12
|
-
}) {
|
|
13
|
-
return provide(FullPropertyPathContext, { path }, element);
|
|
14
|
-
}
|
|
15
|
-
function useFullPropertyPathContext(context) {
|
|
16
|
-
return context;
|
|
17
|
-
}
|
|
18
|
-
function useFullPropertyPath(props) {
|
|
19
|
-
const context = consume(FullPropertyPathContext, props.element);
|
|
20
|
-
const basePath = useFullPropertyPathContext(context);
|
|
21
|
-
return createMemo(() => {
|
|
22
|
-
if (typeof basePath !== "function" && typeof props.path === "function") {
|
|
23
|
-
return props.path();
|
|
24
|
-
} else if (typeof basePath === "function" && typeof props.path !== "function") {
|
|
25
|
-
return basePath();
|
|
26
|
-
} else if (typeof basePath === "function" && typeof props.path === "function") {
|
|
27
|
-
return `${basePath()}.${props.path()}`;
|
|
28
|
-
}
|
|
29
|
-
return "";
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export { provideFullPropertyPathContext, useFullPropertyPath, useFullPropertyPathContext };
|
|
34
|
-
//# sourceMappingURL=useFullPropertyPath.js.map
|
|
35
|
-
//# sourceMappingURL=useFullPropertyPath.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/hooks/useFullPropertyPath.ts"],"names":[],"mappings":";;;;AA0BA,SAAS,8BACP,OACyB,EAAA;AACzB,EAAA,OAAO,OAAQ,CAAA,IAAA;AACjB;AAEA,MAAM,uBAAA,GAA0B,cAAc,6BAA6B,CAAA;AAEpE,SAAS,8BAA+B,CAAA;AAAA,EAC7C,OAAA;AAAA,EACA;AACF,CAGgC,EAAA;AAC9B,EAAA,OAAO,OAAQ,CAAA,uBAAA,EAAyB,EAAE,IAAA,IAAQ,OAAO,CAAA;AAC3D;AAEO,SAAS,2BACd,OACA,EAAA;AACA,EAAO,OAAA,OAAA;AACT;AAEO,SAAS,oBAAoB,KAGjC,EAAA;AACD,EAAA,MAAM,OAAU,GAAA,OAAA,CAAQ,uBAAyB,EAAA,KAAA,CAAM,OAAO,CAAA;AAC9D,EAAM,MAAA,QAAA,GAAW,2BAA2B,OAAO,CAAA;AACnD,EAAA,OAAO,WAAW,MAAM;AACtB,IAAA,IAAI,OAAO,QAAa,KAAA,UAAA,IAAc,OAAO,KAAA,CAAM,SAAS,UAAY,EAAA;AACtE,MAAA,OAAO,MAAM,IAAK,EAAA;AAAA,eAElB,OAAO,QAAA,KAAa,cACpB,OAAO,KAAA,CAAM,SAAS,UACtB,EAAA;AACA,MAAA,OAAO,QAAS,EAAA;AAAA,eAEhB,OAAO,QAAA,KAAa,cACpB,OAAO,KAAA,CAAM,SAAS,UACtB,EAAA;AACA,MAAA,OAAO,GAAG,QAAS,EAAC,CAAI,CAAA,EAAA,KAAA,CAAM,MAAM,CAAA,CAAA;AAAA;AAEtC,IAAO,OAAA,EAAA;AAAA,GACR,CAAA;AACH","file":"useFullPropertyPath.js","sourcesContent":["import type { Path } from \"../utils\";\n\nimport AjaxCart from \"@brytdesigns/shopify-ajax-cart\";\nimport { createMemo, type Accessor } from \"solid-js\";\nimport {\n createContext,\n consume,\n provide,\n type ICustomElement,\n} from \"component-register\";\n\ntype AjaxCartData = (typeof AjaxCart)[\"data\"];\n\nexport type ValidAjaxPath = Path<AjaxCartData>;\n\ntype WalkableNode = Parameters<typeof provide>[2];\n\ntype FullPropertyPathContextType = ReturnType<\n typeof createFullPathPropertyContext\n>;\n\ntype Options = {\n path: Accessor<ValidAjaxPath>;\n element: HTMLElement & ICustomElement;\n};\n\nfunction createFullPathPropertyContext(\n options: Options,\n): Accessor<ValidAjaxPath> {\n return options.path;\n}\n\nconst FullPropertyPathContext = createContext(createFullPathPropertyContext);\n\nexport function provideFullPropertyPathContext({\n element,\n path,\n}: {\n element: WalkableNode;\n path: Accessor<ValidAjaxPath>;\n}): FullPropertyPathContextType {\n return provide(FullPropertyPathContext, { path }, element);\n}\n\nexport function useFullPropertyPathContext(\n context: FullPropertyPathContextType,\n) {\n return context;\n}\n\nexport function useFullPropertyPath(props: {\n element: HTMLElement & ICustomElement;\n path?: Accessor<ValidAjaxPath>;\n}) {\n const context = consume(FullPropertyPathContext, props.element);\n const basePath = useFullPropertyPathContext(context);\n return createMemo(() => {\n if (typeof basePath !== \"function\" && typeof props.path === \"function\") {\n return props.path();\n } else if (\n typeof basePath === \"function\" &&\n typeof props.path !== \"function\"\n ) {\n return basePath();\n } else if (\n typeof basePath === \"function\" &&\n typeof props.path === \"function\"\n ) {\n return `${basePath()}.${props.path()}` as ValidAjaxPath;\n }\n return \"\" as ValidAjaxPath;\n });\n}\n"]}
|